From 010d64acbce5aff0f0af3ca69be79cc2c3cc7e2d Mon Sep 17 00:00:00 2001 From: Felix Hanau Date: Fri, 27 Dec 2024 10:43:33 -0500 Subject: [PATCH] Revert "html-rewriter: Support streaming content replacements (#3211)" This reverts commit c77df01c, which is causing upstream test failures. --- deps/rust/cargo.bzl | 8 +- src/workerd/api/html-rewriter.c++ | 297 +++--------------- src/workerd/api/html-rewriter.h | 80 ++--- src/workerd/api/tests/htmlrewriter-test.js | 150 --------- .../generated-snapshot/2021-11-03/index.d.ts | 55 +--- types/generated-snapshot/2021-11-03/index.ts | 55 +--- .../generated-snapshot/2022-01-31/index.d.ts | 55 +--- types/generated-snapshot/2022-01-31/index.ts | 55 +--- .../generated-snapshot/2022-03-21/index.d.ts | 55 +--- types/generated-snapshot/2022-03-21/index.ts | 55 +--- .../generated-snapshot/2022-08-04/index.d.ts | 55 +--- types/generated-snapshot/2022-08-04/index.ts | 55 +--- .../generated-snapshot/2022-10-31/index.d.ts | 55 +--- types/generated-snapshot/2022-10-31/index.ts | 55 +--- .../generated-snapshot/2022-11-30/index.d.ts | 55 +--- types/generated-snapshot/2022-11-30/index.ts | 55 +--- .../generated-snapshot/2023-03-01/index.d.ts | 55 +--- types/generated-snapshot/2023-03-01/index.ts | 55 +--- .../generated-snapshot/2023-07-01/index.d.ts | 55 +--- types/generated-snapshot/2023-07-01/index.ts | 55 +--- .../experimental/index.d.ts | 55 +--- .../generated-snapshot/experimental/index.ts | 55 +--- types/generated-snapshot/oldest/index.d.ts | 55 +--- types/generated-snapshot/oldest/index.ts | 55 +--- 24 files changed, 315 insertions(+), 1320 deletions(-) diff --git a/deps/rust/cargo.bzl b/deps/rust/cargo.bzl index c6a8ceedc7c..9663082e84b 100644 --- a/deps/rust/cargo.bzl +++ b/deps/rust/cargo.bzl @@ -16,10 +16,10 @@ PACKAGES = { "cxx": crate.spec(version = "1"), "cxxbridge-cmd": crate.spec(version = "1"), "flate2": crate.spec(version = "1"), - # Commit hash refers to lol-html v2.1.0. We then access the nested lol_html_c_api crate within. - # TODO(npaun): The next release of lol-html could change the way we access the nested crate. - # Check once https://github.com/cloudflare/lol-html/pull/247 is in a release. - "lol_html_c_api": crate.spec(git = "https://github.com/cloudflare/lol-html.git", rev = "cac9f2f59aea8ad803286b0aae0d667926f441c7"), + "lol_html_c_api": crate.spec( + git = "https://github.com/cloudflare/lol-html.git", + rev = "cac9f2f59aea8ad803286b0aae0d667926f441c7", + ), "nix": crate.spec(version = "0"), "pico-args": crate.spec(version = "0"), "proc-macro2": crate.spec(version = "1"), diff --git a/src/workerd/api/html-rewriter.c++ b/src/workerd/api/html-rewriter.c++ index f08b5ba5b5b..25b25da8e1e 100644 --- a/src/workerd/api/html-rewriter.c++ +++ b/src/workerd/api/html-rewriter.c++ @@ -235,12 +235,6 @@ class Rewriter final: public WritableStreamSink { // Implementation for `Element::onEndTag` to avoid exposing private details of Rewriter. void onEndTag(lol_html_element_t* element, ElementCallbackFunction&& callback); - lol_html_streaming_handler_t registerReplacer(jsg::Ref content, bool isHtml); - - ~Rewriter() { - KJ_ASSERT(registeredReplacers.size() == 0, "Some replacers were leaked by lol-html"); - } - private: // Wait for the write promise (if any) produced by our `output()` callback, then, if there is a // stored exception, abort the wrapped WritableStreamSink with it, then return the exception. @@ -272,15 +266,6 @@ class Rewriter final: public WritableStreamSink { friend class ::workerd::api::HTMLRewriter; - // Keeps track of streams currently being used as replacement content for tokens. - // lol-html will invoke replacerThunk with a pointer to the RegisteredReplacer to be used. - class RegisteredReplacer { - public: - Rewriter& rewriter; - bool isHtml; - jsg::Ref stream; - }; - struct RegisteredHandler { // A back-reference to the rewriter which owns this particular registered handler. Rewriter& rewriter; @@ -310,15 +295,6 @@ class Rewriter final: public WritableStreamSink { // used again. void removeEndTagHandler(RegisteredHandler& registration); - // Field stores a list of readable streams that are being used by lol-html for replacements - kj::HashMap> registeredReplacers; - - static int replacerThunk(lol_html_streaming_sink_t* sink, void* userData); - kj::Promise replacerThunkPromise( - lol_html_streaming_sink_t* sink, RegisteredReplacer& registration); - int replacerThunkImpl(lol_html_streaming_sink_t* sink, RegisteredReplacer& registration); - static void removeRegisteredReplacer(void* userData); - // Must be constructed AFTER the registered handler vector, since the function which constructs // this (buildRewriter()) modifies that vector. kj::Own rewriter; @@ -603,122 +579,6 @@ kj::Promise Rewriter::thunkPromise(CType* content, RegisteredHandler& regi }); } -lol_html_streaming_handler_t Rewriter::registerReplacer( - jsg::Ref content, bool isHtml) { - auto replacer = kj::heap(*this, isHtml, kj::mv(content)); - auto userData = replacer.get(); - registeredReplacers.insert(userData, kj::mv(replacer)); - - return { - .user_data = userData, - .write_all_callback = Rewriter::replacerThunk, - .drop_callback = Rewriter::removeRegisteredReplacer, - }; -} - -// Adapter that allows pumping a ReadableStream to a pre-established lol_html -// streaming sink, named `sink`. Writes of arbitrary bytes and sizes are allowed, -// but the content must be valid UTF-8 or lol_html will reject it. -class ReplacerStreamSink final: public WritableStreamSink { - public: - ReplacerStreamSink(lol_html_streaming_sink_t* sink, bool isHtml): sink(sink), isHtml(isHtml) {} - - kj::Promise write(kj::ArrayPtr buffer) override KJ_WARN_UNUSED_RESULT { - auto err = lol_html_streaming_sink_write_utf8_chunk( - sink, buffer.asChars().begin(), buffer.size(), isHtml); - if (err != 0) { - return getLastError(); - } - - return kj::READY_NOW; - } - - kj::Promise write(kj::ArrayPtr> pieces) override { - for (auto bytes: pieces) { - auto err = lol_html_streaming_sink_write_utf8_chunk( - sink, bytes.asChars().begin(), bytes.size(), isHtml); - if (err != 0) { - return getLastError(); - } - } - - return kj::READY_NOW; - } - - kj::Promise end() override KJ_WARN_UNUSED_RESULT { - // Nothing specific needs to be done to tell lol_html we're done writing the stream - return kj::READY_NOW; - } - - void abort(kj::Exception reason) override { - // Nothing specific needs to be done. The rewriter will be poisoned in replacerThunkImpl, - // and lol_html will bubble up the error through to write. - } - - private: - lol_html_streaming_sink_t* sink; - bool isHtml; -}; - -int Rewriter::replacerThunk(lol_html_streaming_sink_t* sink, void* userData) { - auto& registration = *reinterpret_cast(userData); - return registration.rewriter.replacerThunkImpl(sink, registration); -} - -int Rewriter::replacerThunkImpl( - lol_html_streaming_sink_t* sink, RegisteredReplacer& registeredHandler) { - if (isPoisoned()) { - // Handlers disabled due to exception. - KJ_LOG(ERROR, "poisoned rewriter should not be able to call handlers"); - return -1; - } - - try { - KJ_IF_SOME(exception, kj::runCatchingExceptions([&] { - // V8 has a thread local pointer that points to where the stack limit is on this thread which - // is tested for overflows when we enter any JS code. However since we're running in a fiber - // here, we're in an entirely different stack that V8 doesn't know about, so it gets confused - // and may think we've overflowed our stack. evalLater will run thunkPromise on the main stack - // to keep V8 from getting confused. - auto promise = kj::evalLater([&]() { return replacerThunkPromise(sink, registeredHandler); }); - promise.wait(KJ_ASSERT_NONNULL(maybeWaitScope)); - })) { - // Exception in handler. We need to abort the streaming parser, but can't do so just yet: we - // need to unwind the stack because we're probably still inside a cool_thing_rewriter_write(). - // We can't unwind with an exception across the Rust/C++ boundary, so instead we'll keep this - // exception around and disable all later handlers - maybePoison(kj::mv(exception)); - return -1; - } - } catch (kj::CanceledException) { - // The fiber is being canceled. Same as runCatchingExceptions, we need to abort the parser, - // but can't since we're still inside cool_thing_rewriter_write(). This isn't handled by - // runCatchingExceptions since CanceledException isn't a kj exception, and we wouldn't want - // runCatchingExceptions to handle it anyway. We set canceled to true and once we leave Rust, - // we rethrow it to properly cancel the fiber. - canceled = true; - return -1; - } - return 0; -} - -kj::Promise Rewriter::replacerThunkPromise( - lol_html_streaming_sink_t* sink, RegisteredReplacer& registration) { - return ioContext.run([this, sink, ®istration](Worker::Lock& lock) -> kj::Promise { - jsg::AsyncContextFrame::Scope asyncContextScope(lock, maybeAsyncContext); - - auto streamSink = kj::heap(sink, registration.isHtml); - return ioContext.waitForDeferredProxy( - registration.stream->pumpTo(lock, kj::mv(streamSink), true)); - }); -} - -void Rewriter::removeRegisteredReplacer(void* userData) { - auto& registration = *reinterpret_cast(userData); - KJ_REQUIRE(registration.rewriter.registeredReplacers.erase(userData), - "Tried to remove replacer that was not registered"); -} - void Rewriter::onEndTag(lol_html_element_t* element, ElementCallbackFunction&& callback) { auto registeredHandler = Rewriter::RegisteredHandler{*this, kj::mv(callback)}; // NOTE: this gets freed in `thunkPromise` above. @@ -748,7 +608,6 @@ void Rewriter::outputImpl(kj::ArrayPtr buffer) { } auto bufferCopy = kj::heapArray(buffer); - KJ_IF_SOME(wp, writePromise) { writePromise = wp.then([this, bufferCopy = kj::mv(bufferCopy)]() mutable { return inner->write(bufferCopy.asPtr()).attach(kj::mv(bufferCopy)); @@ -758,40 +617,6 @@ void Rewriter::outputImpl(kj::ArrayPtr buffer) { } } -// ======================================================================================= -// HTMLRewriter::Token::ImplBase - -template -HTMLRewriter::Token::ImplBase::ImplBase(CType& element, Rewriter& rewriter) - : element(element), - rewriter(rewriter) {} -template -HTMLRewriter::Token::ImplBase::~ImplBase() noexcept(false) {} -template -template -void HTMLRewriter::Token::ImplBase::rewriteContentGeneric( - Content content, jsg::Optional options) { - auto isHtml = options.orDefault({}).html.orDefault(false); - - KJ_SWITCH_ONEOF(content) { - KJ_CASE_ONEOF(stringContent, kj::String) { - check(Func(&element, stringContent.cStr(), stringContent.size(), isHtml)); - } - - KJ_CASE_ONEOF(streamContent, jsg::Ref) { - auto handler = rewriter.registerReplacer(kj::mv(streamContent), isHtml); - check(StreamingFunc(&element, &handler)); - } - - KJ_CASE_ONEOF(responseContent, jsg::Ref) { - KJ_IF_SOME(body, responseContent->getBody()) { - auto handler = rewriter.registerReplacer(kj::mv(body), isHtml); - check(StreamingFunc(&element, &handler)); - } - // Otherwise if no body, there is no replacement to make - } - } -} // ======================================================================================= // Element @@ -865,53 +690,31 @@ jsg::Ref Element::removeAttribute(kj::String name) { } namespace { + kj::String unwrapContent(Content content) { return kj::mv(JSG_REQUIRE_NONNULL(content.tryGet(), TypeError, - "Replacing content in HTML comments using a ReadableStream or Response object is not " + "Replacing HTML content using a ReadableStream or Response object is not " "implemented. You must provide a string.")); } -} // namespace - -jsg::Ref Element::before(Content content, jsg::Optional options) { - checkToken(impl) - .rewriteContentGeneric( - kj::mv(content), options); - return JSG_THIS; -} - -jsg::Ref Element::after(Content content, jsg::Optional options) { - checkToken(impl).rewriteContentGeneric( - kj::mv(content), options); - return JSG_THIS; -} -jsg::Ref Element::prepend(Content content, jsg::Optional options) { - checkToken(impl) - .rewriteContentGeneric( - kj::mv(content), options); - return JSG_THIS; -} +} // namespace -jsg::Ref Element::append(Content content, jsg::Optional options) { - checkToken(impl) - .rewriteContentGeneric( - kj::mv(content), options); - return JSG_THIS; -} +#define DEFINE_CONTENT_REWRITER_FUNCTION(camel, snake) \ + jsg::Ref Element::camel(Content content, jsg::Optional options) { \ + auto stringContent = unwrapContent(kj::mv(content)); \ + check(lol_html_element_##snake(&checkToken(impl).element, stringContent.cStr(), \ + stringContent.size(), options.orDefault({}).html.orDefault(false))); \ + return JSG_THIS; \ + } -jsg::Ref Element::replace(Content content, jsg::Optional options) { - checkToken(impl) - .rewriteContentGeneric( - kj::mv(content), options); - return JSG_THIS; -} +DEFINE_CONTENT_REWRITER_FUNCTION(before, before) +DEFINE_CONTENT_REWRITER_FUNCTION(after, after) +DEFINE_CONTENT_REWRITER_FUNCTION(prepend, prepend) +DEFINE_CONTENT_REWRITER_FUNCTION(append, append) +DEFINE_CONTENT_REWRITER_FUNCTION(replace, replace) +DEFINE_CONTENT_REWRITER_FUNCTION(setInnerContent, set_inner_content) -jsg::Ref Element::setInnerContent(Content content, jsg::Optional options) { - checkToken(impl) - .rewriteContentGeneric(kj::mv(content), options); - return JSG_THIS; -} +#undef DEFINE_CONTENT_REWRITER_FUNCTION jsg::Ref Element::remove() { lol_html_element_remove(&checkToken(impl).element); @@ -928,38 +731,39 @@ void Element::onEndTag(ElementCallbackFunction&& callback) { knownImpl.rewriter.onEndTag(&knownImpl.element, kj::mv(callback)); } -EndTag::EndTag(CType& endTag, Rewriter& rewriter) { - impl.emplace(endTag, rewriter); -} +EndTag::EndTag(CType& endTag, Rewriter&): impl(endTag) {} void EndTag::htmlContentScopeEnd() { impl = kj::none; } kj::String EndTag::getName() { - auto text = LolString(lol_html_end_tag_name_get(&checkToken(impl).element)); + auto text = LolString(lol_html_end_tag_name_get(&checkToken(impl))); return kj::str(text.asChars()); } void EndTag::setName(kj::String text) { - check(lol_html_end_tag_name_set(&checkToken(impl).element, text.cStr(), text.size())); + check(lol_html_end_tag_name_set(&checkToken(impl), text.cStr(), text.size())); } jsg::Ref EndTag::before(Content content, jsg::Optional options) { - checkToken(impl) - .rewriteContentGeneric( - kj::mv(content), kj::mv(options)); + auto stringContent = unwrapContent(kj::mv(content)); + check(lol_html_end_tag_before(&checkToken(impl), stringContent.cStr(), stringContent.size(), + options.orDefault({}).html.orDefault(false))); + return JSG_THIS; } jsg::Ref EndTag::after(Content content, jsg::Optional options) { - checkToken(impl).rewriteContentGeneric( - kj::mv(content), kj::mv(options)); + auto stringContent = unwrapContent(kj::mv(content)); + check(lol_html_end_tag_after(&checkToken(impl), stringContent.cStr(), stringContent.size(), + options.orDefault({}).html.orDefault(false))); + return JSG_THIS; } jsg::Ref EndTag::remove() { - lol_html_end_tag_remove(&checkToken(impl).element); + lol_html_end_tag_remove(&checkToken(impl)); return JSG_THIS; } @@ -967,6 +771,8 @@ void Element::htmlContentScopeEnd() { impl = kj::none; } +Element::Impl::Impl(CType& element, Rewriter& rewriter): element(element), rewriter(rewriter) {} + Element::Impl::~Impl() noexcept(false) { for (auto& jsIter: attributesIterators) { static_cast(*jsIter).htmlContentScopeEnd(); @@ -1022,8 +828,6 @@ bool Comment::getRemoved() { } jsg::Ref Comment::before(Content content, jsg::Optional options) { - // TODO(someday): If lol-html adds support for streaming replacements for comments, this - // function will need to be updated. auto stringContent = unwrapContent(kj::mv(content)); check(lol_html_comment_before(&checkToken(impl), stringContent.cStr(), stringContent.size(), options.orDefault({}).html.orDefault(false))); @@ -1032,8 +836,6 @@ jsg::Ref Comment::before(Content content, jsg::Optional } jsg::Ref Comment::after(Content content, jsg::Optional options) { - // TODO(someday): If lol-html adds support for streaming replacements for comments, this - // function will need to be updated. auto stringContent = unwrapContent(kj::mv(content)); check(lol_html_comment_after(&checkToken(impl), stringContent.cStr(), stringContent.size(), options.orDefault({}).html.orDefault(false))); @@ -1042,8 +844,6 @@ jsg::Ref Comment::after(Content content, jsg::Optional } jsg::Ref Comment::replace(Content content, jsg::Optional options) { - // TODO(someday): If lol-html adds support for streaming replacements for comments, this - // function will need to be updated. auto stringContent = unwrapContent(kj::mv(content)); check(lol_html_comment_replace(&checkToken(impl), stringContent.cStr(), stringContent.size(), options.orDefault({}).html.orDefault(false))); @@ -1064,48 +864,49 @@ void Comment::htmlContentScopeEnd() { // ======================================================================================= // Text -Text::Text(CType& text, Rewriter& rewriter) { - impl.emplace(text, rewriter); -} +Text::Text(CType& text, Rewriter&): impl(text) {} kj::String Text::getText() { - auto content = lol_html_text_chunk_content_get(&checkToken(impl).element); + auto content = lol_html_text_chunk_content_get(&checkToken(impl)); return kj::heapString(content.data, content.len); } bool Text::getLastInTextNode() { // NOTE: No error checking seems required by this function -- it returns a bool directly. - return lol_html_text_chunk_is_last_in_text_node(&checkToken(impl).element); + return lol_html_text_chunk_is_last_in_text_node(&checkToken(impl)); } bool Text::getRemoved() { // NOTE: No error checking seems required by this function -- it returns a bool directly. - return lol_html_text_chunk_is_removed(&checkToken(impl).element); + return lol_html_text_chunk_is_removed(&checkToken(impl)); } jsg::Ref Text::before(Content content, jsg::Optional options) { - checkToken(impl) - .rewriteContentGeneric( - kj::mv(content), kj::mv(options)); + auto stringContent = unwrapContent(kj::mv(content)); + check(lol_html_text_chunk_before(&checkToken(impl), stringContent.cStr(), stringContent.size(), + options.orDefault({}).html.orDefault(false))); + return JSG_THIS; } jsg::Ref Text::after(Content content, jsg::Optional options) { - checkToken(impl) - .rewriteContentGeneric( - kj::mv(content), kj::mv(options)); + auto stringContent = unwrapContent(kj::mv(content)); + check(lol_html_text_chunk_after(&checkToken(impl), stringContent.cStr(), stringContent.size(), + options.orDefault({}).html.orDefault(false))); + return JSG_THIS; } jsg::Ref Text::replace(Content content, jsg::Optional options) { - checkToken(impl) - .rewriteContentGeneric( - kj::mv(content), kj::mv(options)); + auto stringContent = unwrapContent(kj::mv(content)); + check(lol_html_text_chunk_replace(&checkToken(impl), stringContent.cStr(), stringContent.size(), + options.orDefault({}).html.orDefault(false))); + return JSG_THIS; } jsg::Ref Text::remove() { - lol_html_text_chunk_remove(&checkToken(impl).element); + lol_html_text_chunk_remove(&checkToken(impl)); return JSG_THIS; } @@ -1144,8 +945,6 @@ void Doctype::htmlContentScopeEnd() { DocumentEnd::DocumentEnd(CType& documentEnd, Rewriter&): impl(documentEnd) {} jsg::Ref DocumentEnd::append(Content content, jsg::Optional options) { - // TODO(someday): If lol-html adds support for streaming replacements for the document end, - // this function will need to be updated. auto stringContent = unwrapContent(kj::mv(content)); check(lol_html_doc_end_append(&checkToken(impl), stringContent.cStr(), stringContent.size(), options.orDefault({}).html.orDefault(false))); diff --git a/src/workerd/api/html-rewriter.h b/src/workerd/api/html-rewriter.h index ec9e7d8a14a..1c9678fbf42 100644 --- a/src/workerd/api/html-rewriter.h +++ b/src/workerd/api/html-rewriter.h @@ -118,21 +118,6 @@ class HTMLRewriter: public jsg::Object { kj::Own impl; }; -// A chunk of text or HTML which can be passed to content token mutation functions. -using Content = kj::OneOf, jsg::Ref>; -// TODO(soon): Support ReadableStream/Response types. Requires fibers or lol-html saveable state. - -// Options bag which can be passed to content token mutation functions. -struct ContentOptions { - // True if the Content being passed to the mutation function is HTML. If false, the content will - // be escaped (HTML entity-encoded). - jsg::Optional html; - - JSG_STRUCT(html); -}; - -class Rewriter; - // ======================================================================================= // HTML Content Tokens // @@ -155,25 +140,23 @@ class Rewriter; class HTMLRewriter::Token: public jsg::Object { public: virtual void htmlContentScopeEnd() = 0; +}; - // Each Token subclass has an inner ImplBase subclass which holds a reference - // to the rewriter, and the actual underlying lol-html C API handle for the token. - template - struct ImplBase { - ImplBase(CType& element, Rewriter& rewriter); - KJ_DISALLOW_COPY_AND_MOVE(ImplBase); - ~ImplBase() noexcept(false); +// A chunk of text or HTML which can be passed to content token mutation functions. +using Content = kj::OneOf, jsg::Ref>; +// TODO(soon): Support ReadableStream/Response types. Requires fibers or lol-html saveable state. - // Dispatches calls to the underlying lol_html methods for each event (e.g. before, after, replace). - // Handles replacements of each supported type (string, ReadableStream, Body). - template - void rewriteContentGeneric(Content content, jsg::Optional options); +// Options bag which can be passed to content token mutation functions. +struct ContentOptions { + // True if the Content being passed to the mutation function is HTML. If false, the content will + // be escaped (HTML entity-encoded). + jsg::Optional html; - CType& element; - Rewriter& rewriter; - }; + JSG_STRUCT(html); }; +class Rewriter; + class Element final: public HTMLRewriter::Token { public: using CType = lol_html_Element; @@ -231,16 +214,28 @@ class Element final: public HTMLRewriter::Token { JSG_TS_ROOT(); JSG_TS_OVERRIDE({ - onEndTag(handler: (tag: EndTag) => void | Promise): void; + before(content: string, options?: ContentOptions): Element; + after(content: string, options?: ContentOptions): Element; + prepend(content: string, options?: ContentOptions): Element; + append(content: string, options?: ContentOptions): Element; + replace(content: string, options?: ContentOptions): Element; + setInnerContent(content: string, options?: ContentOptions): Element; + + onEndTag(handler: (tag: EndTag) => void | Promise): void; }); - // Specify parameter type for onEndTag callback function + // Require content to be a string, and specify parameter type for onEndTag + // callback function } private: - struct Impl: public HTMLRewriter::Token::ImplBase { - using HTMLRewriter::Token::ImplBase::ImplBase; + struct Impl { + Impl(CType& element, Rewriter&); + KJ_DISALLOW_COPY_AND_MOVE(Impl); ~Impl() noexcept(false); + + CType& element; kj::Vector> attributesIterators; + Rewriter& rewriter; }; kj::Maybe impl; @@ -283,7 +278,7 @@ class EndTag final: public HTMLRewriter::Token { public: using CType = lol_html_EndTag; - explicit EndTag(CType& tag, Rewriter& rewriter); + explicit EndTag(CType& tag, Rewriter&); kj::String getName(); void setName(kj::String); @@ -300,10 +295,15 @@ class EndTag final: public HTMLRewriter::Token { JSG_METHOD(remove); JSG_TS_ROOT(); + JSG_TS_OVERRIDE({ + before(content: string, options?: ContentOptions): EndTag; + after(content: string, options?: ContentOptions): EndTag; + }); + // Require content to be a string } private: - kj::Maybe> impl; + kj::Maybe impl; void htmlContentScopeEnd() override; }; @@ -352,7 +352,7 @@ class Text final: public HTMLRewriter::Token { public: using CType = lol_html_TextChunk; - explicit Text(CType& text, Rewriter& rewriter); + explicit Text(CType& text, Rewriter&); kj::String getText(); @@ -376,10 +376,16 @@ class Text final: public HTMLRewriter::Token { JSG_METHOD(remove); JSG_TS_ROOT(); + JSG_TS_OVERRIDE({ + before(content: string, options?: ContentOptions): Text; + after(content: string, options?: ContentOptions): Text; + replace(content: string, options?: ContentOptions): Text; + }); + // Require content to be a string } private: - kj::Maybe> impl; + kj::Maybe impl; void htmlContentScopeEnd() override; }; diff --git a/src/workerd/api/tests/htmlrewriter-test.js b/src/workerd/api/tests/htmlrewriter-test.js index 7bd0a970901..aea8ca0a990 100644 --- a/src/workerd/api/tests/htmlrewriter-test.js +++ b/src/workerd/api/tests/htmlrewriter-test.js @@ -610,156 +610,6 @@ export const manualWriting2 = { }, }; -export const streamingReplacement = { - async test() { - const { readable, writable } = new TransformStream(); - - const response = new HTMLRewriter() - .on('*', { - async element(element) { - const dataStream = ( - await fetch('data:,the quick brown fox jumped over the lazy dog%20') - ).body; - element.prepend(dataStream, { html: false }); - }, - }) - .transform(new Response(readable)); - - const writer = writable.getWriter(); - const encoder = new TextEncoder(); - - await writer.write(encoder.encode('')); - await writer.write(encoder.encode('bar')); - await writer.write(encoder.encode('')); - await writer.close(); - - // This variation uses the JavaScript TransformStream, so we can - // initiate the read after doing the writes. - const promise = response.text(); - strictEqual( - await promise, - `the quick brown fox jumped over the lazy dog bar` - ); - }, -}; - -export const streamingReplacementHTML = { - async test() { - const { readable, writable } = new TransformStream(); - - const response = new HTMLRewriter() - .on('*', { - async element(element) { - const dataStream = ( - await fetch('data:,such markup much wow ') - ).body; - element.prepend(dataStream, { html: true }); - }, - }) - .transform(new Response(readable)); - - const writer = writable.getWriter(); - const encoder = new TextEncoder(); - - await writer.write(encoder.encode('')); - await writer.write(encoder.encode('bar')); - await writer.write(encoder.encode('')); - await writer.close(); - - // This variation uses the JavaScript TransformStream, so we can - // initiate the read after doing the writes. - const promise = response.text(); - strictEqual( - await promise, - `such markup much wowbar` - ); - }, -}; - -export const streamingReplacementReplace = { - async test() { - const { readable, writable } = new TransformStream(); - - const response = new HTMLRewriter() - .on('.dinosaur', { - async element(element) { - const dataStream = (await fetch('data:,goodbye world')).body; - element.replace(dataStream, { html: false }); - }, - }) - .transform(new Response(readable)); - - const writer = writable.getWriter(); - const encoder = new TextEncoder(); - - await writer.write(encoder.encode('')); - await writer.write( - encoder.encode('
hello world
') - ); - await writer.write(encoder.encode('')); - await writer.close(); - - // This variation uses the JavaScript TransformStream, so we can - // initiate the read after doing the writes. - const promise = response.text(); - strictEqual(await promise, `goodbye world`); - }, -}; - -export const streamingReplacementMultiple = { - async test() { - const { readable, writable } = new TransformStream(); - - const response = new HTMLRewriter() - .on('*', { - async element(element) { - element.prepend(await fetch('data:,alpha%20')); - element.append(await fetch('data:,%20gamma')); - }, - }) - .transform(new Response(readable)); - - const writer = writable.getWriter(); - const encoder = new TextEncoder(); - - await writer.write(encoder.encode('')); - await writer.write(encoder.encode('beta')); - await writer.write(encoder.encode('')); - await writer.close(); - - // This variation uses the JavaScript TransformStream, so we can - // initiate the read after doing the writes. - const promise = response.text(); - strictEqual(await promise, `alpha beta gamma`); - }, -}; - -export const streamingReplacementBadUTF8 = { - async test() { - const { readable, writable } = new TransformStream(); - - const response = new HTMLRewriter() - .on('*', { - async element(element) { - element.prepend(await fetch('data:,garbage%e2%28%a1')); - }, - }) - .transform(new Response(readable)); - - const writer = writable.getWriter(); - const encoder = new TextEncoder(); - - await writer.write(encoder.encode('')); - await writer.write(encoder.encode('bar')); - await writer.write(encoder.encode('')); - await writer.close(); - - // This variation uses the JavaScript TransformStream, so we can - // initiate the read after doing the writes. - await rejects(response.text(), { message: 'Parser error: Invalid UTF-8' }); - }, -}; - export const appendOnEnd = { async test() { const kInput = diff --git a/types/generated-snapshot/2021-11-03/index.d.ts b/types/generated-snapshot/2021-11-03/index.d.ts index e0abc000d03..19a8f0c3a31 100755 --- a/types/generated-snapshot/2021-11-03/index.d.ts +++ b/types/generated-snapshot/2021-11-03/index.d.ts @@ -1416,44 +1416,20 @@ interface Element { hasAttribute(name: string): boolean; setAttribute(name: string, value: string): Element; removeAttribute(name: string): Element; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - prepend( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - append( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + before(content: string, options?: ContentOptions): Element; + after(content: string, options?: ContentOptions): Element; + prepend(content: string, options?: ContentOptions): Element; + append(content: string, options?: ContentOptions): Element; + replace(content: string, options?: ContentOptions): Element; remove(): Element; removeAndKeepContent(): Element; - setInnerContent( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + setInnerContent(content: string, options?: ContentOptions): Element; onEndTag(handler: (tag: EndTag) => void | Promise): void; } interface EndTag { name: string; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; + before(content: string, options?: ContentOptions): EndTag; + after(content: string, options?: ContentOptions): EndTag; remove(): EndTag; } interface Comment { @@ -1468,18 +1444,9 @@ interface Text { readonly text: string; readonly lastInTextNode: boolean; readonly removed: boolean; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; + before(content: string, options?: ContentOptions): Text; + after(content: string, options?: ContentOptions): Text; + replace(content: string, options?: ContentOptions): Text; remove(): Text; } interface DocumentEnd { diff --git a/types/generated-snapshot/2021-11-03/index.ts b/types/generated-snapshot/2021-11-03/index.ts index e9582ba1a31..f9742194c25 100755 --- a/types/generated-snapshot/2021-11-03/index.ts +++ b/types/generated-snapshot/2021-11-03/index.ts @@ -1421,44 +1421,20 @@ export interface Element { hasAttribute(name: string): boolean; setAttribute(name: string, value: string): Element; removeAttribute(name: string): Element; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - prepend( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - append( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + before(content: string, options?: ContentOptions): Element; + after(content: string, options?: ContentOptions): Element; + prepend(content: string, options?: ContentOptions): Element; + append(content: string, options?: ContentOptions): Element; + replace(content: string, options?: ContentOptions): Element; remove(): Element; removeAndKeepContent(): Element; - setInnerContent( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + setInnerContent(content: string, options?: ContentOptions): Element; onEndTag(handler: (tag: EndTag) => void | Promise): void; } export interface EndTag { name: string; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; + before(content: string, options?: ContentOptions): EndTag; + after(content: string, options?: ContentOptions): EndTag; remove(): EndTag; } export interface Comment { @@ -1473,18 +1449,9 @@ export interface Text { readonly text: string; readonly lastInTextNode: boolean; readonly removed: boolean; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; + before(content: string, options?: ContentOptions): Text; + after(content: string, options?: ContentOptions): Text; + replace(content: string, options?: ContentOptions): Text; remove(): Text; } export interface DocumentEnd { diff --git a/types/generated-snapshot/2022-01-31/index.d.ts b/types/generated-snapshot/2022-01-31/index.d.ts index a103aff8282..c4575ca8501 100755 --- a/types/generated-snapshot/2022-01-31/index.d.ts +++ b/types/generated-snapshot/2022-01-31/index.d.ts @@ -1422,44 +1422,20 @@ interface Element { hasAttribute(name: string): boolean; setAttribute(name: string, value: string): Element; removeAttribute(name: string): Element; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - prepend( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - append( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + before(content: string, options?: ContentOptions): Element; + after(content: string, options?: ContentOptions): Element; + prepend(content: string, options?: ContentOptions): Element; + append(content: string, options?: ContentOptions): Element; + replace(content: string, options?: ContentOptions): Element; remove(): Element; removeAndKeepContent(): Element; - setInnerContent( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + setInnerContent(content: string, options?: ContentOptions): Element; onEndTag(handler: (tag: EndTag) => void | Promise): void; } interface EndTag { name: string; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; + before(content: string, options?: ContentOptions): EndTag; + after(content: string, options?: ContentOptions): EndTag; remove(): EndTag; } interface Comment { @@ -1474,18 +1450,9 @@ interface Text { readonly text: string; readonly lastInTextNode: boolean; readonly removed: boolean; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; + before(content: string, options?: ContentOptions): Text; + after(content: string, options?: ContentOptions): Text; + replace(content: string, options?: ContentOptions): Text; remove(): Text; } interface DocumentEnd { diff --git a/types/generated-snapshot/2022-01-31/index.ts b/types/generated-snapshot/2022-01-31/index.ts index 3c731c385a6..03709d2b9f7 100755 --- a/types/generated-snapshot/2022-01-31/index.ts +++ b/types/generated-snapshot/2022-01-31/index.ts @@ -1427,44 +1427,20 @@ export interface Element { hasAttribute(name: string): boolean; setAttribute(name: string, value: string): Element; removeAttribute(name: string): Element; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - prepend( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - append( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + before(content: string, options?: ContentOptions): Element; + after(content: string, options?: ContentOptions): Element; + prepend(content: string, options?: ContentOptions): Element; + append(content: string, options?: ContentOptions): Element; + replace(content: string, options?: ContentOptions): Element; remove(): Element; removeAndKeepContent(): Element; - setInnerContent( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + setInnerContent(content: string, options?: ContentOptions): Element; onEndTag(handler: (tag: EndTag) => void | Promise): void; } export interface EndTag { name: string; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; + before(content: string, options?: ContentOptions): EndTag; + after(content: string, options?: ContentOptions): EndTag; remove(): EndTag; } export interface Comment { @@ -1479,18 +1455,9 @@ export interface Text { readonly text: string; readonly lastInTextNode: boolean; readonly removed: boolean; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; + before(content: string, options?: ContentOptions): Text; + after(content: string, options?: ContentOptions): Text; + replace(content: string, options?: ContentOptions): Text; remove(): Text; } export interface DocumentEnd { diff --git a/types/generated-snapshot/2022-03-21/index.d.ts b/types/generated-snapshot/2022-03-21/index.d.ts index eabe2addc14..e929c0f17ed 100755 --- a/types/generated-snapshot/2022-03-21/index.d.ts +++ b/types/generated-snapshot/2022-03-21/index.d.ts @@ -1440,44 +1440,20 @@ interface Element { hasAttribute(name: string): boolean; setAttribute(name: string, value: string): Element; removeAttribute(name: string): Element; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - prepend( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - append( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + before(content: string, options?: ContentOptions): Element; + after(content: string, options?: ContentOptions): Element; + prepend(content: string, options?: ContentOptions): Element; + append(content: string, options?: ContentOptions): Element; + replace(content: string, options?: ContentOptions): Element; remove(): Element; removeAndKeepContent(): Element; - setInnerContent( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + setInnerContent(content: string, options?: ContentOptions): Element; onEndTag(handler: (tag: EndTag) => void | Promise): void; } interface EndTag { name: string; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; + before(content: string, options?: ContentOptions): EndTag; + after(content: string, options?: ContentOptions): EndTag; remove(): EndTag; } interface Comment { @@ -1492,18 +1468,9 @@ interface Text { readonly text: string; readonly lastInTextNode: boolean; readonly removed: boolean; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; + before(content: string, options?: ContentOptions): Text; + after(content: string, options?: ContentOptions): Text; + replace(content: string, options?: ContentOptions): Text; remove(): Text; } interface DocumentEnd { diff --git a/types/generated-snapshot/2022-03-21/index.ts b/types/generated-snapshot/2022-03-21/index.ts index 644d47b6c0a..0c8eeef7df9 100755 --- a/types/generated-snapshot/2022-03-21/index.ts +++ b/types/generated-snapshot/2022-03-21/index.ts @@ -1445,44 +1445,20 @@ export interface Element { hasAttribute(name: string): boolean; setAttribute(name: string, value: string): Element; removeAttribute(name: string): Element; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - prepend( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - append( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + before(content: string, options?: ContentOptions): Element; + after(content: string, options?: ContentOptions): Element; + prepend(content: string, options?: ContentOptions): Element; + append(content: string, options?: ContentOptions): Element; + replace(content: string, options?: ContentOptions): Element; remove(): Element; removeAndKeepContent(): Element; - setInnerContent( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + setInnerContent(content: string, options?: ContentOptions): Element; onEndTag(handler: (tag: EndTag) => void | Promise): void; } export interface EndTag { name: string; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; + before(content: string, options?: ContentOptions): EndTag; + after(content: string, options?: ContentOptions): EndTag; remove(): EndTag; } export interface Comment { @@ -1497,18 +1473,9 @@ export interface Text { readonly text: string; readonly lastInTextNode: boolean; readonly removed: boolean; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; + before(content: string, options?: ContentOptions): Text; + after(content: string, options?: ContentOptions): Text; + replace(content: string, options?: ContentOptions): Text; remove(): Text; } export interface DocumentEnd { diff --git a/types/generated-snapshot/2022-08-04/index.d.ts b/types/generated-snapshot/2022-08-04/index.d.ts index 8706e551807..fa9046bdb48 100755 --- a/types/generated-snapshot/2022-08-04/index.d.ts +++ b/types/generated-snapshot/2022-08-04/index.d.ts @@ -1440,44 +1440,20 @@ interface Element { hasAttribute(name: string): boolean; setAttribute(name: string, value: string): Element; removeAttribute(name: string): Element; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - prepend( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - append( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + before(content: string, options?: ContentOptions): Element; + after(content: string, options?: ContentOptions): Element; + prepend(content: string, options?: ContentOptions): Element; + append(content: string, options?: ContentOptions): Element; + replace(content: string, options?: ContentOptions): Element; remove(): Element; removeAndKeepContent(): Element; - setInnerContent( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + setInnerContent(content: string, options?: ContentOptions): Element; onEndTag(handler: (tag: EndTag) => void | Promise): void; } interface EndTag { name: string; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; + before(content: string, options?: ContentOptions): EndTag; + after(content: string, options?: ContentOptions): EndTag; remove(): EndTag; } interface Comment { @@ -1492,18 +1468,9 @@ interface Text { readonly text: string; readonly lastInTextNode: boolean; readonly removed: boolean; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; + before(content: string, options?: ContentOptions): Text; + after(content: string, options?: ContentOptions): Text; + replace(content: string, options?: ContentOptions): Text; remove(): Text; } interface DocumentEnd { diff --git a/types/generated-snapshot/2022-08-04/index.ts b/types/generated-snapshot/2022-08-04/index.ts index 63c668152d0..d60f657a56a 100755 --- a/types/generated-snapshot/2022-08-04/index.ts +++ b/types/generated-snapshot/2022-08-04/index.ts @@ -1445,44 +1445,20 @@ export interface Element { hasAttribute(name: string): boolean; setAttribute(name: string, value: string): Element; removeAttribute(name: string): Element; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - prepend( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - append( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + before(content: string, options?: ContentOptions): Element; + after(content: string, options?: ContentOptions): Element; + prepend(content: string, options?: ContentOptions): Element; + append(content: string, options?: ContentOptions): Element; + replace(content: string, options?: ContentOptions): Element; remove(): Element; removeAndKeepContent(): Element; - setInnerContent( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + setInnerContent(content: string, options?: ContentOptions): Element; onEndTag(handler: (tag: EndTag) => void | Promise): void; } export interface EndTag { name: string; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; + before(content: string, options?: ContentOptions): EndTag; + after(content: string, options?: ContentOptions): EndTag; remove(): EndTag; } export interface Comment { @@ -1497,18 +1473,9 @@ export interface Text { readonly text: string; readonly lastInTextNode: boolean; readonly removed: boolean; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; + before(content: string, options?: ContentOptions): Text; + after(content: string, options?: ContentOptions): Text; + replace(content: string, options?: ContentOptions): Text; remove(): Text; } export interface DocumentEnd { diff --git a/types/generated-snapshot/2022-10-31/index.d.ts b/types/generated-snapshot/2022-10-31/index.d.ts index 64317239bdf..7058bb1794d 100755 --- a/types/generated-snapshot/2022-10-31/index.d.ts +++ b/types/generated-snapshot/2022-10-31/index.d.ts @@ -1440,44 +1440,20 @@ interface Element { hasAttribute(name: string): boolean; setAttribute(name: string, value: string): Element; removeAttribute(name: string): Element; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - prepend( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - append( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + before(content: string, options?: ContentOptions): Element; + after(content: string, options?: ContentOptions): Element; + prepend(content: string, options?: ContentOptions): Element; + append(content: string, options?: ContentOptions): Element; + replace(content: string, options?: ContentOptions): Element; remove(): Element; removeAndKeepContent(): Element; - setInnerContent( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + setInnerContent(content: string, options?: ContentOptions): Element; onEndTag(handler: (tag: EndTag) => void | Promise): void; } interface EndTag { name: string; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; + before(content: string, options?: ContentOptions): EndTag; + after(content: string, options?: ContentOptions): EndTag; remove(): EndTag; } interface Comment { @@ -1492,18 +1468,9 @@ interface Text { readonly text: string; readonly lastInTextNode: boolean; readonly removed: boolean; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; + before(content: string, options?: ContentOptions): Text; + after(content: string, options?: ContentOptions): Text; + replace(content: string, options?: ContentOptions): Text; remove(): Text; } interface DocumentEnd { diff --git a/types/generated-snapshot/2022-10-31/index.ts b/types/generated-snapshot/2022-10-31/index.ts index 35de138200f..13f5db8ba95 100755 --- a/types/generated-snapshot/2022-10-31/index.ts +++ b/types/generated-snapshot/2022-10-31/index.ts @@ -1445,44 +1445,20 @@ export interface Element { hasAttribute(name: string): boolean; setAttribute(name: string, value: string): Element; removeAttribute(name: string): Element; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - prepend( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - append( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + before(content: string, options?: ContentOptions): Element; + after(content: string, options?: ContentOptions): Element; + prepend(content: string, options?: ContentOptions): Element; + append(content: string, options?: ContentOptions): Element; + replace(content: string, options?: ContentOptions): Element; remove(): Element; removeAndKeepContent(): Element; - setInnerContent( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + setInnerContent(content: string, options?: ContentOptions): Element; onEndTag(handler: (tag: EndTag) => void | Promise): void; } export interface EndTag { name: string; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; + before(content: string, options?: ContentOptions): EndTag; + after(content: string, options?: ContentOptions): EndTag; remove(): EndTag; } export interface Comment { @@ -1497,18 +1473,9 @@ export interface Text { readonly text: string; readonly lastInTextNode: boolean; readonly removed: boolean; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; + before(content: string, options?: ContentOptions): Text; + after(content: string, options?: ContentOptions): Text; + replace(content: string, options?: ContentOptions): Text; remove(): Text; } export interface DocumentEnd { diff --git a/types/generated-snapshot/2022-11-30/index.d.ts b/types/generated-snapshot/2022-11-30/index.d.ts index d289f9a40ce..0c9a38292a8 100755 --- a/types/generated-snapshot/2022-11-30/index.d.ts +++ b/types/generated-snapshot/2022-11-30/index.d.ts @@ -1445,44 +1445,20 @@ interface Element { hasAttribute(name: string): boolean; setAttribute(name: string, value: string): Element; removeAttribute(name: string): Element; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - prepend( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - append( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + before(content: string, options?: ContentOptions): Element; + after(content: string, options?: ContentOptions): Element; + prepend(content: string, options?: ContentOptions): Element; + append(content: string, options?: ContentOptions): Element; + replace(content: string, options?: ContentOptions): Element; remove(): Element; removeAndKeepContent(): Element; - setInnerContent( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + setInnerContent(content: string, options?: ContentOptions): Element; onEndTag(handler: (tag: EndTag) => void | Promise): void; } interface EndTag { name: string; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; + before(content: string, options?: ContentOptions): EndTag; + after(content: string, options?: ContentOptions): EndTag; remove(): EndTag; } interface Comment { @@ -1497,18 +1473,9 @@ interface Text { readonly text: string; readonly lastInTextNode: boolean; readonly removed: boolean; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; + before(content: string, options?: ContentOptions): Text; + after(content: string, options?: ContentOptions): Text; + replace(content: string, options?: ContentOptions): Text; remove(): Text; } interface DocumentEnd { diff --git a/types/generated-snapshot/2022-11-30/index.ts b/types/generated-snapshot/2022-11-30/index.ts index fab2ff3ab52..c2c7f426d8e 100755 --- a/types/generated-snapshot/2022-11-30/index.ts +++ b/types/generated-snapshot/2022-11-30/index.ts @@ -1450,44 +1450,20 @@ export interface Element { hasAttribute(name: string): boolean; setAttribute(name: string, value: string): Element; removeAttribute(name: string): Element; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - prepend( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - append( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + before(content: string, options?: ContentOptions): Element; + after(content: string, options?: ContentOptions): Element; + prepend(content: string, options?: ContentOptions): Element; + append(content: string, options?: ContentOptions): Element; + replace(content: string, options?: ContentOptions): Element; remove(): Element; removeAndKeepContent(): Element; - setInnerContent( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + setInnerContent(content: string, options?: ContentOptions): Element; onEndTag(handler: (tag: EndTag) => void | Promise): void; } export interface EndTag { name: string; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; + before(content: string, options?: ContentOptions): EndTag; + after(content: string, options?: ContentOptions): EndTag; remove(): EndTag; } export interface Comment { @@ -1502,18 +1478,9 @@ export interface Text { readonly text: string; readonly lastInTextNode: boolean; readonly removed: boolean; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; + before(content: string, options?: ContentOptions): Text; + after(content: string, options?: ContentOptions): Text; + replace(content: string, options?: ContentOptions): Text; remove(): Text; } export interface DocumentEnd { diff --git a/types/generated-snapshot/2023-03-01/index.d.ts b/types/generated-snapshot/2023-03-01/index.d.ts index 770ce88aa7f..9fa9a8441bd 100755 --- a/types/generated-snapshot/2023-03-01/index.d.ts +++ b/types/generated-snapshot/2023-03-01/index.d.ts @@ -1445,44 +1445,20 @@ interface Element { hasAttribute(name: string): boolean; setAttribute(name: string, value: string): Element; removeAttribute(name: string): Element; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - prepend( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - append( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + before(content: string, options?: ContentOptions): Element; + after(content: string, options?: ContentOptions): Element; + prepend(content: string, options?: ContentOptions): Element; + append(content: string, options?: ContentOptions): Element; + replace(content: string, options?: ContentOptions): Element; remove(): Element; removeAndKeepContent(): Element; - setInnerContent( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + setInnerContent(content: string, options?: ContentOptions): Element; onEndTag(handler: (tag: EndTag) => void | Promise): void; } interface EndTag { name: string; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; + before(content: string, options?: ContentOptions): EndTag; + after(content: string, options?: ContentOptions): EndTag; remove(): EndTag; } interface Comment { @@ -1497,18 +1473,9 @@ interface Text { readonly text: string; readonly lastInTextNode: boolean; readonly removed: boolean; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; + before(content: string, options?: ContentOptions): Text; + after(content: string, options?: ContentOptions): Text; + replace(content: string, options?: ContentOptions): Text; remove(): Text; } interface DocumentEnd { diff --git a/types/generated-snapshot/2023-03-01/index.ts b/types/generated-snapshot/2023-03-01/index.ts index e18feea7837..d070e0470d8 100755 --- a/types/generated-snapshot/2023-03-01/index.ts +++ b/types/generated-snapshot/2023-03-01/index.ts @@ -1450,44 +1450,20 @@ export interface Element { hasAttribute(name: string): boolean; setAttribute(name: string, value: string): Element; removeAttribute(name: string): Element; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - prepend( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - append( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + before(content: string, options?: ContentOptions): Element; + after(content: string, options?: ContentOptions): Element; + prepend(content: string, options?: ContentOptions): Element; + append(content: string, options?: ContentOptions): Element; + replace(content: string, options?: ContentOptions): Element; remove(): Element; removeAndKeepContent(): Element; - setInnerContent( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + setInnerContent(content: string, options?: ContentOptions): Element; onEndTag(handler: (tag: EndTag) => void | Promise): void; } export interface EndTag { name: string; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; + before(content: string, options?: ContentOptions): EndTag; + after(content: string, options?: ContentOptions): EndTag; remove(): EndTag; } export interface Comment { @@ -1502,18 +1478,9 @@ export interface Text { readonly text: string; readonly lastInTextNode: boolean; readonly removed: boolean; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; + before(content: string, options?: ContentOptions): Text; + after(content: string, options?: ContentOptions): Text; + replace(content: string, options?: ContentOptions): Text; remove(): Text; } export interface DocumentEnd { diff --git a/types/generated-snapshot/2023-07-01/index.d.ts b/types/generated-snapshot/2023-07-01/index.d.ts index 79d21e63bc9..c345274476a 100755 --- a/types/generated-snapshot/2023-07-01/index.d.ts +++ b/types/generated-snapshot/2023-07-01/index.d.ts @@ -1445,44 +1445,20 @@ interface Element { hasAttribute(name: string): boolean; setAttribute(name: string, value: string): Element; removeAttribute(name: string): Element; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - prepend( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - append( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + before(content: string, options?: ContentOptions): Element; + after(content: string, options?: ContentOptions): Element; + prepend(content: string, options?: ContentOptions): Element; + append(content: string, options?: ContentOptions): Element; + replace(content: string, options?: ContentOptions): Element; remove(): Element; removeAndKeepContent(): Element; - setInnerContent( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + setInnerContent(content: string, options?: ContentOptions): Element; onEndTag(handler: (tag: EndTag) => void | Promise): void; } interface EndTag { name: string; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; + before(content: string, options?: ContentOptions): EndTag; + after(content: string, options?: ContentOptions): EndTag; remove(): EndTag; } interface Comment { @@ -1497,18 +1473,9 @@ interface Text { readonly text: string; readonly lastInTextNode: boolean; readonly removed: boolean; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; + before(content: string, options?: ContentOptions): Text; + after(content: string, options?: ContentOptions): Text; + replace(content: string, options?: ContentOptions): Text; remove(): Text; } interface DocumentEnd { diff --git a/types/generated-snapshot/2023-07-01/index.ts b/types/generated-snapshot/2023-07-01/index.ts index 141aaa0cd55..dabd5224051 100755 --- a/types/generated-snapshot/2023-07-01/index.ts +++ b/types/generated-snapshot/2023-07-01/index.ts @@ -1450,44 +1450,20 @@ export interface Element { hasAttribute(name: string): boolean; setAttribute(name: string, value: string): Element; removeAttribute(name: string): Element; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - prepend( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - append( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + before(content: string, options?: ContentOptions): Element; + after(content: string, options?: ContentOptions): Element; + prepend(content: string, options?: ContentOptions): Element; + append(content: string, options?: ContentOptions): Element; + replace(content: string, options?: ContentOptions): Element; remove(): Element; removeAndKeepContent(): Element; - setInnerContent( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + setInnerContent(content: string, options?: ContentOptions): Element; onEndTag(handler: (tag: EndTag) => void | Promise): void; } export interface EndTag { name: string; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; + before(content: string, options?: ContentOptions): EndTag; + after(content: string, options?: ContentOptions): EndTag; remove(): EndTag; } export interface Comment { @@ -1502,18 +1478,9 @@ export interface Text { readonly text: string; readonly lastInTextNode: boolean; readonly removed: boolean; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; + before(content: string, options?: ContentOptions): Text; + after(content: string, options?: ContentOptions): Text; + replace(content: string, options?: ContentOptions): Text; remove(): Text; } export interface DocumentEnd { diff --git a/types/generated-snapshot/experimental/index.d.ts b/types/generated-snapshot/experimental/index.d.ts index 9b7af065b7f..c9c75b66774 100755 --- a/types/generated-snapshot/experimental/index.d.ts +++ b/types/generated-snapshot/experimental/index.d.ts @@ -1453,44 +1453,20 @@ interface Element { hasAttribute(name: string): boolean; setAttribute(name: string, value: string): Element; removeAttribute(name: string): Element; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - prepend( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - append( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + before(content: string, options?: ContentOptions): Element; + after(content: string, options?: ContentOptions): Element; + prepend(content: string, options?: ContentOptions): Element; + append(content: string, options?: ContentOptions): Element; + replace(content: string, options?: ContentOptions): Element; remove(): Element; removeAndKeepContent(): Element; - setInnerContent( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + setInnerContent(content: string, options?: ContentOptions): Element; onEndTag(handler: (tag: EndTag) => void | Promise): void; } interface EndTag { name: string; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; + before(content: string, options?: ContentOptions): EndTag; + after(content: string, options?: ContentOptions): EndTag; remove(): EndTag; } interface Comment { @@ -1505,18 +1481,9 @@ interface Text { readonly text: string; readonly lastInTextNode: boolean; readonly removed: boolean; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; + before(content: string, options?: ContentOptions): Text; + after(content: string, options?: ContentOptions): Text; + replace(content: string, options?: ContentOptions): Text; remove(): Text; } interface DocumentEnd { diff --git a/types/generated-snapshot/experimental/index.ts b/types/generated-snapshot/experimental/index.ts index 67bfcd18917..a5e148ed626 100755 --- a/types/generated-snapshot/experimental/index.ts +++ b/types/generated-snapshot/experimental/index.ts @@ -1458,44 +1458,20 @@ export interface Element { hasAttribute(name: string): boolean; setAttribute(name: string, value: string): Element; removeAttribute(name: string): Element; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - prepend( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - append( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + before(content: string, options?: ContentOptions): Element; + after(content: string, options?: ContentOptions): Element; + prepend(content: string, options?: ContentOptions): Element; + append(content: string, options?: ContentOptions): Element; + replace(content: string, options?: ContentOptions): Element; remove(): Element; removeAndKeepContent(): Element; - setInnerContent( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + setInnerContent(content: string, options?: ContentOptions): Element; onEndTag(handler: (tag: EndTag) => void | Promise): void; } export interface EndTag { name: string; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; + before(content: string, options?: ContentOptions): EndTag; + after(content: string, options?: ContentOptions): EndTag; remove(): EndTag; } export interface Comment { @@ -1510,18 +1486,9 @@ export interface Text { readonly text: string; readonly lastInTextNode: boolean; readonly removed: boolean; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; + before(content: string, options?: ContentOptions): Text; + after(content: string, options?: ContentOptions): Text; + replace(content: string, options?: ContentOptions): Text; remove(): Text; } export interface DocumentEnd { diff --git a/types/generated-snapshot/oldest/index.d.ts b/types/generated-snapshot/oldest/index.d.ts index d1d799e6106..75c0bfbc79b 100755 --- a/types/generated-snapshot/oldest/index.d.ts +++ b/types/generated-snapshot/oldest/index.d.ts @@ -1416,44 +1416,20 @@ interface Element { hasAttribute(name: string): boolean; setAttribute(name: string, value: string): Element; removeAttribute(name: string): Element; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - prepend( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - append( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + before(content: string, options?: ContentOptions): Element; + after(content: string, options?: ContentOptions): Element; + prepend(content: string, options?: ContentOptions): Element; + append(content: string, options?: ContentOptions): Element; + replace(content: string, options?: ContentOptions): Element; remove(): Element; removeAndKeepContent(): Element; - setInnerContent( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + setInnerContent(content: string, options?: ContentOptions): Element; onEndTag(handler: (tag: EndTag) => void | Promise): void; } interface EndTag { name: string; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; + before(content: string, options?: ContentOptions): EndTag; + after(content: string, options?: ContentOptions): EndTag; remove(): EndTag; } interface Comment { @@ -1468,18 +1444,9 @@ interface Text { readonly text: string; readonly lastInTextNode: boolean; readonly removed: boolean; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; + before(content: string, options?: ContentOptions): Text; + after(content: string, options?: ContentOptions): Text; + replace(content: string, options?: ContentOptions): Text; remove(): Text; } interface DocumentEnd { diff --git a/types/generated-snapshot/oldest/index.ts b/types/generated-snapshot/oldest/index.ts index ad6de110a82..f8a068217e1 100755 --- a/types/generated-snapshot/oldest/index.ts +++ b/types/generated-snapshot/oldest/index.ts @@ -1421,44 +1421,20 @@ export interface Element { hasAttribute(name: string): boolean; setAttribute(name: string, value: string): Element; removeAttribute(name: string): Element; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - prepend( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - append( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + before(content: string, options?: ContentOptions): Element; + after(content: string, options?: ContentOptions): Element; + prepend(content: string, options?: ContentOptions): Element; + append(content: string, options?: ContentOptions): Element; + replace(content: string, options?: ContentOptions): Element; remove(): Element; removeAndKeepContent(): Element; - setInnerContent( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Element; + setInnerContent(content: string, options?: ContentOptions): Element; onEndTag(handler: (tag: EndTag) => void | Promise): void; } export interface EndTag { name: string; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): EndTag; + before(content: string, options?: ContentOptions): EndTag; + after(content: string, options?: ContentOptions): EndTag; remove(): EndTag; } export interface Comment { @@ -1473,18 +1449,9 @@ export interface Text { readonly text: string; readonly lastInTextNode: boolean; readonly removed: boolean; - before( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - after( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; - replace( - content: string | ReadableStream | Response, - options?: ContentOptions, - ): Text; + before(content: string, options?: ContentOptions): Text; + after(content: string, options?: ContentOptions): Text; + replace(content: string, options?: ContentOptions): Text; remove(): Text; } export interface DocumentEnd {