|
| 1 | +// Adapted from https://github.com/stardazed/sd-streams |
| 2 | +// |
| 3 | +// MIT License |
| 4 | +// |
| 5 | +// Copyright (c) 2018-Present @zenmumbler |
| 6 | +// |
| 7 | +// Permission is hereby granted, free of charge, to any person obtaining a copy |
| 8 | +// of this software and associated documentation files (the "Software"), to deal |
| 9 | +// in the Software without restriction, including without limitation the rights |
| 10 | +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 11 | +// copies of the Software, and to permit persons to whom the Software is |
| 12 | +// furnished to do so, subject to the following conditions: |
| 13 | +// |
| 14 | +// The above copyright notice and this permission notice shall be included in all |
| 15 | +// copies or substantial portions of the Software. |
| 16 | +// |
| 17 | +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 20 | +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 | +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 22 | +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 23 | +// SOFTWARE. |
| 24 | +var __defProp = Object.defineProperty; |
| 25 | +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
| 26 | +var __getOwnPropNames = Object.getOwnPropertyNames; |
| 27 | +var __hasOwnProp = Object.prototype.hasOwnProperty; |
| 28 | +var __export = (target, all) => { |
| 29 | + for (var name in all) |
| 30 | + __defProp(target, name, { get: all[name], enumerable: true }); |
| 31 | +}; |
| 32 | +var __copyProps = (to, from, except, desc) => { |
| 33 | + if (from && typeof from === "object" || typeof from === "function") { |
| 34 | + for (let key of __getOwnPropNames(from)) |
| 35 | + if (!__hasOwnProp.call(to, key) && key !== except) |
| 36 | + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); |
| 37 | + } |
| 38 | + return to; |
| 39 | +}; |
| 40 | +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); |
| 41 | + |
| 42 | +// /input.ts |
| 43 | +var input_exports = {}; |
| 44 | +__export(input_exports, { |
| 45 | + TextDecoderStream: () => TextDecoderStream |
| 46 | +}); |
| 47 | +module.exports = __toCommonJS(input_exports); |
| 48 | + |
| 49 | +// http-url:https://unpkg.com/@stardazed/[email protected]/dist/sd-streams-text-encoding.esm.js |
| 50 | +var decDecoder = Symbol("decDecoder"); |
| 51 | +var decTransform = Symbol("decTransform"); |
| 52 | +var TextDecodeTransformer = class { |
| 53 | + constructor(decoder) { |
| 54 | + this.decoder_ = decoder; |
| 55 | + } |
| 56 | + transform(chunk, controller) { |
| 57 | + if (!(chunk instanceof ArrayBuffer || ArrayBuffer.isView(chunk))) { |
| 58 | + throw new TypeError("Input data must be a BufferSource"); |
| 59 | + } |
| 60 | + const text = this.decoder_.decode(chunk, { stream: true }); |
| 61 | + if (text.length !== 0) { |
| 62 | + controller.enqueue(text); |
| 63 | + } |
| 64 | + } |
| 65 | + flush(controller) { |
| 66 | + const text = this.decoder_.decode(); |
| 67 | + if (text.length !== 0) { |
| 68 | + controller.enqueue(text); |
| 69 | + } |
| 70 | + } |
| 71 | +}; |
| 72 | +var TextDecoderStream = class { |
| 73 | + constructor(label, options) { |
| 74 | + const decoder = new TextDecoder(label || "utf-8", options || {}); |
| 75 | + this[decDecoder] = decoder; |
| 76 | + this[decTransform] = new TransformStream(new TextDecodeTransformer(decoder)); |
| 77 | + } |
| 78 | + get encoding() { |
| 79 | + return this[decDecoder].encoding; |
| 80 | + } |
| 81 | + get fatal() { |
| 82 | + return this[decDecoder].fatal; |
| 83 | + } |
| 84 | + get ignoreBOM() { |
| 85 | + return this[decDecoder].ignoreBOM; |
| 86 | + } |
| 87 | + get readable() { |
| 88 | + return this[decTransform].readable; |
| 89 | + } |
| 90 | + get writable() { |
| 91 | + return this[decTransform].writable; |
| 92 | + } |
| 93 | +}; |
| 94 | +var encEncoder = Symbol("encEncoder"); |
| 95 | +var encTransform = Symbol("encTransform"); |
0 commit comments