/* * Copyright (c) 2026-present, the Ladybird developers. * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include namespace Web::Encoding { // https://encoding.spec.whatwg.org/#textdecoderstream class TextDecoderStream final : public Bindings::PlatformObject , public Streams::GenericTransformStreamMixin , public TextDecoderCommonMixin { WEB_PLATFORM_OBJECT(TextDecoderStream, Bindings::PlatformObject); GC_DECLARE_ALLOCATOR(TextDecoderStream); public: static WebIDL::ExceptionOr> construct_impl(JS::Realm&, FlyString label, TextDecoderOptions const& options = {}); virtual ~TextDecoderStream() override; private: TextDecoderStream(JS::Realm&, GC::Ref, TextCodec::Decoder&, FlyString encoding, ErrorMode, bool ignore_bom); virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; WebIDL::ExceptionOr decode_and_enqueue_chunk(JS::Value); WebIDL::ExceptionOr flush_and_enqueue(); WebIDL::ExceptionOr enqueue_decoded_output(String const&); // https://encoding.spec.whatwg.org/#textdecodercommon-i-o-queue // NB: We accumulate input bytes that have been pushed to the I/O queue but not yet decoded, so that a multi-byte // sequence which is split across chunks can be reassembled. ByteBuffer m_io_queue; }; }