// Copyright (c) 2017-2022 Cloudflare, Inc. // Licensed under the Apache 2.0 license found in the LICENSE file or at: // https://opensource.org/licenses/Apache-2.0 #pragma once #include #include #include #include namespace workerd::api { class TextEncoderStream: public TransformStream { public: using TransformStream::TransformStream; static jsg::Ref constructor(jsg::Lock& js); kj::StringPtr getEncoding() { return "utf-8"_kj; } JSG_RESOURCE_TYPE(TextEncoderStream) { JSG_INHERIT(TransformStream); JSG_READONLY_PROTOTYPE_PROPERTY(encoding, getEncoding); JSG_TS_OVERRIDE(extends TransformStream); } }; class TextDecoderStream: public TransformStream { public: struct TextDecoderStreamInit { jsg::Optional fatal; jsg::Optional ignoreBOM; JSG_STRUCT(fatal, ignoreBOM); }; TextDecoderStream(jsg::Ref decoder, jsg::Ref readable, jsg::Ref writable); static jsg::Ref constructor( jsg::Lock& js, jsg::Optional label, jsg::Optional options); kj::StringPtr getEncoding(); bool getFatal(); bool getIgnoreBOM(); JSG_RESOURCE_TYPE(TextDecoderStream) { JSG_INHERIT(TransformStream); JSG_READONLY_PROTOTYPE_PROPERTY(encoding, getEncoding); JSG_READONLY_PROTOTYPE_PROPERTY(fatal, getFatal); JSG_READONLY_PROTOTYPE_PROPERTY(ignoreBOM, getIgnoreBOM); JSG_TS_OVERRIDE(extends TransformStream); } void visitForMemoryInfo(jsg::MemoryTracker& tracker) const; private: jsg::Ref decoder; void visitForGc(jsg::GcVisitor& visitor); }; } // namespace workerd::api