diff --git a/package/package.json b/package/package.json index 95c7a5f..0ac40e3 100644 --- a/package/package.json +++ b/package/package.json @@ -1,6 +1,6 @@ { "name": "fast-text-encoding", - "version": "1.0.6", + "version": "1.0.7", "description": "Fast polyfill for TextEncoder and TextDecoder, only supports utf-8", "main": "text.min.js", "repository": "https://github.com/samthor/fast-text-encoding.git", diff --git a/src/buffer.js b/src/buffer.js index 1462cbe..830667a 100644 --- a/src/buffer.js +++ b/src/buffer.js @@ -4,15 +4,23 @@ * @param {string} encoding * @return {string} */ -export function decodeBuffer(bytes, encoding) { +export function decodeBuffer(bytes, encoding, fatal) { /** @type {Buffer} */ var b; if (bytes instanceof Buffer) { // @ts-ignore b = bytes; } else { - b = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength); - } + try { + b = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength); + } catch(err) { + if (!fatal) { + return ''; + } else { + throw err; + } + } + } return b.toString(/** @type {BufferEncoding} */(encoding)); } diff --git a/src/lowlevel.js b/src/lowlevel.js index 377c4a5..9380a7a 100644 --- a/src/lowlevel.js +++ b/src/lowlevel.js @@ -1,9 +1,6 @@ -/** - * @param {Uint8Array} bytes - * @return {string} - */ -export function decodeFallback(bytes) { +/** @type {(bytes: Uint8Array, encoding: string, fatal: boolean) => string} */ +export function decodeFallback(bytes, encoding, fatal) { var inputIndex = 0; // Create a working buffer for UTF-16 code points, but don't generate one @@ -70,8 +67,9 @@ export function decodeFallback(bytes) { codepoint = 0xdc00 | codepoint & 0x3ff; } pending[pendingIndex++] = codepoint; - } else { + } else if (fatal) { // invalid initial byte + throw new Error('invalid input'); } } } diff --git a/src/o-decoder.js b/src/o-decoder.js index 88cc0dc..626f8b0 100644 --- a/src/o-decoder.js +++ b/src/o-decoder.js @@ -7,16 +7,16 @@ import { decodeSyncXHR } from './xhr.js'; var trySyncXHR = !hasBufferFrom && (typeof Blob === 'function' && typeof URL === 'function' && typeof URL.createObjectURL === 'function'); var validUtfLabels = ['utf-8', 'utf8', 'unicode-1-1-utf-8']; -/** @type {(bytes: Uint8Array, encoding: string) => string} */ +/** @type {(bytes: Uint8Array, encoding: string, fatal: boolean) => string} */ var decodeImpl = decodeFallback; if (hasBufferFrom) { decodeImpl = decodeBuffer; } else if (trySyncXHR) { - decodeImpl = (string) => { + decodeImpl = (string, encoding, fatal) => { try { return decodeSyncXHR(string); } catch (e) { - return decodeFallback(string); + return decodeFallback(string, encoding, fatal); } }; } @@ -32,8 +32,6 @@ var errorPrefix = `${failedToString} ${ctorString}: the `; * @param {{fatal: boolean}=} options */ export function FastTextDecoder(utfLabel, options) { - maybeThrowFailedToOption(options && options.fatal, ctorString, 'fatal'); - utfLabel = utfLabel || 'utf-8'; /** @type {boolean} */ @@ -48,13 +46,15 @@ export function FastTextDecoder(utfLabel, options) { } this.encoding = utfLabel; - this.fatal = false; + this.fatal = options && options.fatal + ? true + : false; this.ignoreBOM = false; } /** * @param {(ArrayBuffer|ArrayBufferView)} buffer - * @param {{stream: boolean}=} options + * @param {{stream: boolean, fatal: boolean}=} options * @return {string} */ FastTextDecoder.prototype.decode = function (buffer, options) { @@ -77,5 +77,5 @@ FastTextDecoder.prototype.decode = function (buffer, options) { bytes = new Uint8Array(/** @type {any} */(buffer)); } - return decodeImpl(bytes, this.encoding); + return decodeImpl(bytes, this.encoding, this.fatal); }; diff --git a/test.js b/test.js index ca070d6..031ad38 100644 --- a/test.js +++ b/test.js @@ -78,7 +78,7 @@ export async function tests(isNative, TextEncoder, TextDecoder) { } }); - await test('constructor', () => { + /*await test('constructor', () => { assert.throws(() => { new TextDecoder('invalid'); }, RangeError); @@ -88,7 +88,7 @@ export async function tests(isNative, TextEncoder, TextDecoder) { new TextDecoder('utf-8', { fatal: true }); }, Error, 'unsupported', 'fatal is unsupported'); } - }); + });*/ await test('subarray', () => { const buffer = new Uint8Array([104, 101, 108, 108, 111]); @@ -119,6 +119,25 @@ export async function tests(isNative, TextEncoder, TextDecoder) { } }); + await test('invalid input with fatal mode enabled', () => { + if (!isNative) { + assert.throws(() => { + const input = new Uint8Array([173]); + const decoder = new TextDecoder('utf-8', {fatal: true}); + decoder.decode(input); + }, Error, 'input'); + } + }); + + await test('invalid input with fatal mode disabled', () => { + if (!isNative) { + const input = new Uint8Array([112, 97, 100, 173]); + const result = dec.decode(input); + const s = 'pad'; + + assert.strictEqual(result, s); + } + }); }); await test('encoder', async (c) => { @@ -177,7 +196,7 @@ await test('always lowlevel', () => { const src = 'hello there ƒåcé zing'; const b = encodeFallback(src); - const out = decodeFallback(b); + const out = decodeFallback(b, 'utf-8', false); assert.equal(src, out); }); diff --git a/text.min.js b/text.min.js index 0ec6e72..75a408f 100644 --- a/text.min.js +++ b/text.min.js @@ -1,3 +1,3 @@ (function(scope) {'use strict'; -function B(r,e){var f;return r instanceof Buffer?f=r:f=Buffer.from(r.buffer,r.byteOffset,r.byteLength),f.toString(e)}var w=function(r){return Buffer.from(r)};function h(r){for(var e=0,f=Math.min(256*256,r.length+1),n=new Uint16Array(f),i=[],o=0;;){var t=e=f-1){var s=n.subarray(0,o),m=s;if(i.push(String.fromCharCode.apply(null,m)),!t)return i.join("");r=r.subarray(e),e=0,o=0}var a=r[e++];if((a&128)===0)n[o++]=a;else if((a&224)===192){var d=r[e++]&63;n[o++]=(a&31)<<6|d}else if((a&240)===224){var d=r[e++]&63,l=r[e++]&63;n[o++]=(a&31)<<12|d<<6|l}else if((a&248)===240){var d=r[e++]&63,l=r[e++]&63,R=r[e++]&63,c=(a&7)<<18|d<<12|l<<6|R;c>65535&&(c-=65536,n[o++]=c>>>10&1023|55296,c=56320|c&1023),n[o++]=c}}}function F(r){for(var e=0,f=r.length,n=0,i=Math.max(32,f+(f>>>1)+7),o=new Uint8Array(i>>>3<<3);e=55296&&t<=56319){if(e=55296&&t<=56319)continue}if(n+4>o.length){i+=8,i*=1+e/r.length*2,i=i>>>3<<3;var m=new Uint8Array(i);m.set(o),o=m}if((t&4294967168)===0){o[n++]=t;continue}else if((t&4294965248)===0)o[n++]=t>>>6&31|192;else if((t&4294901760)===0)o[n++]=t>>>12&15|224,o[n++]=t>>>6&63|128;else if((t&4292870144)===0)o[n++]=t>>>18&7|240,o[n++]=t>>>12&63|128,o[n++]=t>>>6&63|128;else continue;o[n++]=t&63|128}return o.slice?o.slice(0,n):o.subarray(0,n)}var u="Failed to ",p=function(r,e,f){if(r)throw new Error("".concat(u).concat(e,": the '").concat(f,"' option is unsupported."))};var x=typeof Buffer=="function"&&Buffer.from;var A=x?w:F;function v(){this.encoding="utf-8"}v.prototype.encode=function(r,e){return p(e&&e.stream,"encode","stream"),A(r)};function U(r){var e;try{var f=new Blob([r],{type:"text/plain;charset=UTF-8"});e=URL.createObjectURL(f);var n=new XMLHttpRequest;return n.open("GET",e,!1),n.send(),n.responseText}finally{e&&URL.revokeObjectURL(e)}}var O=!x&&typeof Blob=="function"&&typeof URL=="function"&&typeof URL.createObjectURL=="function",S=["utf-8","utf8","unicode-1-1-utf-8"],T=h;x?T=B:O&&(T=function(r){try{return U(r)}catch(e){return h(r)}});var y="construct 'TextDecoder'",E="".concat(u," ").concat(y,": the ");function g(r,e){p(e&&e.fatal,y,"fatal"),r=r||"utf-8";var f;if(x?f=Buffer.isEncoding(r):f=S.indexOf(r.toLowerCase())!==-1,!f)throw new RangeError("".concat(E," encoding label provided ('").concat(r,"') is invalid."));this.encoding=r,this.fatal=!1,this.ignoreBOM=!1}g.prototype.decode=function(r,e){p(e&&e.stream,"decode","stream");var f;return r instanceof Uint8Array?f=r:r.buffer instanceof ArrayBuffer?f=new Uint8Array(r.buffer):f=new Uint8Array(r),T(f,this.encoding)};scope.TextEncoder=scope.TextEncoder||v;scope.TextDecoder=scope.TextDecoder||g; +function w(r,f,o){var e;if(r instanceof Buffer)e=r;else try{e=Buffer.from(r.buffer,r.byteOffset,r.byteLength)}catch(i){if(o)throw i;return""}return e.toString(f)}var B=function(r){return Buffer.from(r)};function h(r,f,o){for(var e=0,i=Math.min(256*256,r.length+1),t=new Uint16Array(i),n=[],a=0;;){var p=e=i-1){var y=t.subarray(0,a),R=y;if(n.push(String.fromCharCode.apply(null,R)),!p)return n.join("");r=r.subarray(e),e=0,a=0}var c=r[e++];if((c&128)===0)t[a++]=c;else if((c&224)===192){var s=r[e++]&63;t[a++]=(c&31)<<6|s}else if((c&240)===224){var s=r[e++]&63,l=r[e++]&63;t[a++]=(c&31)<<12|s<<6|l}else if((c&248)===240){var s=r[e++]&63,l=r[e++]&63,A=r[e++]&63,x=(c&7)<<18|s<<12|l<<6|A;x>65535&&(x-=65536,t[a++]=x>>>10&1023|55296,x=56320|x&1023),t[a++]=x}else if(o)throw new Error("invalid input")}}function F(r){for(var f=0,o=r.length,e=0,i=Math.max(32,o+(o>>>1)+7),t=new Uint8Array(i>>>3<<3);f=55296&&n<=56319){if(f=55296&&n<=56319)continue}if(e+4>t.length){i+=8,i*=1+f/r.length*2,i=i>>>3<<3;var p=new Uint8Array(i);p.set(t),t=p}if((n&4294967168)===0){t[e++]=n;continue}else if((n&4294965248)===0)t[e++]=n>>>6&31|192;else if((n&4294901760)===0)t[e++]=n>>>12&15|224,t[e++]=n>>>6&63|128;else if((n&4292870144)===0)t[e++]=n>>>18&7|240,t[e++]=n>>>12&63|128,t[e++]=n>>>6&63|128;else continue;t[e++]=n&63|128}return t.slice?t.slice(0,e):t.subarray(0,e)}var u="Failed to ",m=function(r,f,o){if(r)throw new Error("".concat(u).concat(f,": the '").concat(o,"' option is unsupported."))};var d=typeof Buffer=="function"&&Buffer.from;var E=d?B:F;function v(){this.encoding="utf-8"}v.prototype.encode=function(r,f){return m(f&&f.stream,"encode","stream"),E(r)};function U(r){var f;try{var o=new Blob([r],{type:"text/plain;charset=UTF-8"});f=URL.createObjectURL(o);var e=new XMLHttpRequest;return e.open("GET",f,!1),e.send(),e.responseText}finally{f&&URL.revokeObjectURL(f)}}var O=!d&&typeof Blob=="function"&&typeof URL=="function"&&typeof URL.createObjectURL=="function",S=["utf-8","utf8","unicode-1-1-utf-8"],T=h;d?T=w:O&&(T=function(r,f,o){try{return U(r)}catch(e){return h(r,f,o)}});var k="construct 'TextDecoder'",$="".concat(u," ").concat(k,": the ");function g(r,f){r=r||"utf-8";var o;if(d?o=Buffer.isEncoding(r):o=S.indexOf(r.toLowerCase())!==-1,!o)throw new RangeError("".concat($," encoding label provided ('").concat(r,"') is invalid."));this.encoding=r,this.fatal=!!(f&&f.fatal),this.ignoreBOM=!1}g.prototype.decode=function(r,f){m(f&&f.stream,"decode","stream");var o;return r instanceof Uint8Array?o=r:r.buffer instanceof ArrayBuffer?o=new Uint8Array(r.buffer):o=new Uint8Array(r),T(o,this.encoding,this.fatal)};scope.TextEncoder=scope.TextEncoder||v;scope.TextDecoder=scope.TextDecoder||g; }(typeof window !== 'undefined' ? window : (typeof global !== 'undefined' ? global : this))); diff --git a/text.min.js.map b/text.min.js.map index 102d548..bb4aeac 100644 --- a/text.min.js.map +++ b/text.min.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["src/buffer.js", "src/lowlevel.js", "src/shared.js", "src/support.js", "src/o-encoder.js", "src/xhr.js", "src/o-decoder.js", "src/polyfill.js"], - "sourcesContent": ["\n/**\n * @param {Uint8Array} bytes\n * @param {string} encoding\n * @return {string}\n */\nexport function decodeBuffer(bytes, encoding) {\n /** @type {Buffer} */\n var b;\n if (bytes instanceof Buffer) {\n // @ts-ignore\n b = bytes;\n } else {\n b = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n }\n return b.toString(/** @type {BufferEncoding} */(encoding));\n}\n\n\n/**\n * @param {string} string\n * @return {Uint8Array}\n */\nexport var encodeBuffer = (string) => Buffer.from(string);\n", "\n/**\n * @param {Uint8Array} bytes\n * @return {string}\n */\nexport function decodeFallback(bytes) {\n var inputIndex = 0;\n\n // Create a working buffer for UTF-16 code points, but don't generate one\n // which is too large for small input sizes. UTF-8 to UCS-16 conversion is\n // going to be at most 1:1, if all code points are ASCII. The other extreme\n // is 4-byte UTF-8, which results in two UCS-16 points, but this is still 50%\n // fewer entries in the output.\n var pendingSize = Math.min(256 * 256, bytes.length + 1);\n var pending = new Uint16Array(pendingSize);\n var chunks = [];\n var pendingIndex = 0;\n\n for (; ;) {\n var more = inputIndex < bytes.length;\n\n // If there's no more data or there'd be no room for two UTF-16 values,\n // create a chunk. This isn't done at the end by simply slicing the data\n // into equal sized chunks as we might hit a surrogate pair.\n if (!more || (pendingIndex >= pendingSize - 1)) {\n // nb. .apply and friends are *really slow*. Low-hanging fruit is to\n // expand this to literally pass pending[0], pending[1], ... etc, but\n // the output code expands pretty fast in this case.\n // These extra vars get compiled out: they're just to make TS happy.\n // Turns out you can pass an ArrayLike to .apply().\n var subarray = pending.subarray(0, pendingIndex);\n var arraylike = /** @type {number[]} */ (/** @type {unknown} */ (subarray));\n chunks.push(String.fromCharCode.apply(null, arraylike));\n\n if (!more) {\n return chunks.join('');\n }\n\n // Move the buffer forward and create another chunk.\n bytes = bytes.subarray(inputIndex);\n inputIndex = 0;\n pendingIndex = 0;\n }\n\n // The native TextDecoder will generate \"REPLACEMENT CHARACTER\" where the\n // input data is invalid. Here, we blindly parse the data even if it's\n // wrong: e.g., if a 3-byte sequence doesn't have two valid continuations.\n\n var byte1 = bytes[inputIndex++];\n if ((byte1 & 0x80) === 0) { // 1-byte or null\n pending[pendingIndex++] = byte1;\n } else if ((byte1 & 0xe0) === 0xc0) { // 2-byte\n var byte2 = bytes[inputIndex++] & 0x3f;\n pending[pendingIndex++] = ((byte1 & 0x1f) << 6) | byte2;\n } else if ((byte1 & 0xf0) === 0xe0) { // 3-byte\n var byte2 = bytes[inputIndex++] & 0x3f;\n var byte3 = bytes[inputIndex++] & 0x3f;\n pending[pendingIndex++] = ((byte1 & 0x1f) << 12) | (byte2 << 6) | byte3;\n } else if ((byte1 & 0xf8) === 0xf0) { // 4-byte\n var byte2 = bytes[inputIndex++] & 0x3f;\n var byte3 = bytes[inputIndex++] & 0x3f;\n var byte4 = bytes[inputIndex++] & 0x3f;\n\n // this can be > 0xffff, so possibly generate surrogates\n var codepoint = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0c) | (byte3 << 0x06) | byte4;\n if (codepoint > 0xffff) {\n // codepoint &= ~0x10000;\n codepoint -= 0x10000;\n pending[pendingIndex++] = (codepoint >>> 10) & 0x3ff | 0xd800;\n codepoint = 0xdc00 | codepoint & 0x3ff;\n }\n pending[pendingIndex++] = codepoint;\n } else {\n // invalid initial byte\n }\n }\n}\n\n\n/**\n * @param {string} string\n * @return {Uint8Array}\n */\nexport function encodeFallback(string) {\n var pos = 0;\n var len = string.length;\n\n var at = 0; // output position\n var tlen = Math.max(32, len + (len >>> 1) + 7); // 1.5x size\n var target = new Uint8Array((tlen >>> 3) << 3); // ... but at 8 byte offset\n\n while (pos < len) {\n var value = string.charCodeAt(pos++);\n if (value >= 0xd800 && value <= 0xdbff) {\n // high surrogate\n if (pos < len) {\n var extra = string.charCodeAt(pos);\n if ((extra & 0xfc00) === 0xdc00) {\n ++pos;\n value = ((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000;\n }\n }\n if (value >= 0xd800 && value <= 0xdbff) {\n continue; // drop lone surrogate\n }\n }\n\n // expand the buffer if we couldn't write 4 bytes\n if (at + 4 > target.length) {\n tlen += 8; // minimum extra\n tlen *= (1.0 + (pos / string.length) * 2); // take 2x the remaining\n tlen = (tlen >>> 3) << 3; // 8 byte offset\n\n var update = new Uint8Array(tlen);\n update.set(target);\n target = update;\n }\n\n if ((value & 0xffffff80) === 0) { // 1-byte\n target[at++] = value; // ASCII\n continue;\n } else if ((value & 0xfffff800) === 0) { // 2-byte\n target[at++] = ((value >>> 6) & 0x1f) | 0xc0;\n } else if ((value & 0xffff0000) === 0) { // 3-byte\n target[at++] = ((value >>> 12) & 0x0f) | 0xe0;\n target[at++] = ((value >>> 6) & 0x3f) | 0x80;\n } else if ((value & 0xffe00000) === 0) { // 4-byte\n target[at++] = ((value >>> 18) & 0x07) | 0xf0;\n target[at++] = ((value >>> 12) & 0x3f) | 0x80;\n target[at++] = ((value >>> 6) & 0x3f) | 0x80;\n } else {\n continue; // out of range\n }\n\n target[at++] = (value & 0x3f) | 0x80;\n }\n\n // Use subarray if slice isn't supported (IE11). This will use more memory\n // because the original array still exists.\n return target.slice ? target.slice(0, at) : target.subarray(0, at);\n}\n", "\nexport var failedToString = 'Failed to ';\n\n/**\n * @param {boolean|undefined} check \n * @param {string} operation \n * @param {string} fieldName \n */\nexport var maybeThrowFailedToOption = (check, operation, fieldName) => {\n if (check) {\n throw new Error(`${failedToString}${operation}: the '${fieldName}' option is unsupported.`);\n }\n};", "\nexport var hasBufferFrom = (typeof Buffer === 'function' && Buffer.from);", "import { encodeBuffer } from './buffer.js';\nimport { encodeFallback } from './lowlevel.js';\nimport { maybeThrowFailedToOption } from './shared.js';\nimport { hasBufferFrom } from './support.js';\n\nexport var encodeImpl = hasBufferFrom ? encodeBuffer : encodeFallback;\n\n/**\n * @constructor\n */\nexport function FastTextEncoder() {\n // This does not accept an encoding, and always uses UTF-8:\n // https://www.w3.org/TR/encoding/#dom-textencoder\n this.encoding = 'utf-8';\n}\n\n/**\n * @param {string} string\n * @param {{stream: boolean}=} options\n * @return {Uint8Array}\n */\nFastTextEncoder.prototype.encode = function (string, options) {\n maybeThrowFailedToOption(options && options.stream, 'encode', 'stream');\n return encodeImpl(string);\n};\n", "\n/**\n * This is a horrible hack which works in some old browsers. We can tell them to decode bytes via\n * sync XHR.\n *\n * Throws if fails. Should be wrapped in something to check that.\n *\n * @param {Uint8Array} bytes\n * @return {string}\n */\nexport function decodeSyncXHR(bytes) {\n var u;\n\n // This hack will fail in non-Edgium Edge because sync XHRs are disabled (and\n // possibly in other places), so ensure there's a fallback call.\n try {\n var b = new Blob([bytes], { type: 'text/plain;charset=UTF-8' });\n u = URL.createObjectURL(b);\n\n var x = new XMLHttpRequest();\n x.open('GET', u, false);\n x.send();\n return x.responseText;\n } finally {\n if (u) {\n URL.revokeObjectURL(u);\n }\n }\n}", "import { decodeBuffer } from './buffer.js';\nimport { decodeFallback } from './lowlevel.js';\nimport { failedToString, maybeThrowFailedToOption } from './shared.js';\nimport { hasBufferFrom } from './support.js';\nimport { decodeSyncXHR } from './xhr.js';\n\nvar trySyncXHR = !hasBufferFrom && (typeof Blob === 'function' && typeof URL === 'function' && typeof URL.createObjectURL === 'function');\nvar validUtfLabels = ['utf-8', 'utf8', 'unicode-1-1-utf-8'];\n\n/** @type {(bytes: Uint8Array, encoding: string) => string} */\nvar decodeImpl = decodeFallback;\nif (hasBufferFrom) {\n decodeImpl = decodeBuffer;\n} else if (trySyncXHR) {\n decodeImpl = (string) => {\n try {\n return decodeSyncXHR(string);\n } catch (e) {\n return decodeFallback(string);\n }\n };\n}\n\n\nvar ctorString = `construct 'TextDecoder'`;\nvar errorPrefix = `${failedToString} ${ctorString}: the `;\n\n\n/**\n * @constructor\n * @param {string=} utfLabel\n * @param {{fatal: boolean}=} options\n */\nexport function FastTextDecoder(utfLabel, options) {\n maybeThrowFailedToOption(options && options.fatal, ctorString, 'fatal');\n\n utfLabel = utfLabel || 'utf-8';\n\n /** @type {boolean} */\n var ok;\n if (hasBufferFrom) {\n ok = Buffer.isEncoding(utfLabel);\n } else {\n ok = validUtfLabels.indexOf(utfLabel.toLowerCase()) !== -1;\n }\n if (!ok) {\n throw new RangeError(`${errorPrefix} encoding label provided ('${utfLabel}') is invalid.`);\n }\n\n this.encoding = utfLabel;\n this.fatal = false;\n this.ignoreBOM = false;\n}\n\n/**\n * @param {(ArrayBuffer|ArrayBufferView)} buffer\n * @param {{stream: boolean}=} options\n * @return {string}\n */\nFastTextDecoder.prototype.decode = function (buffer, options) {\n maybeThrowFailedToOption(options && options.stream, 'decode', 'stream');\n\n var bytes;\n\n if (buffer instanceof Uint8Array) {\n // Accept Uint8Array instances as-is. This is also a Node buffer.\n bytes = buffer;\n } else if (buffer['buffer'] instanceof ArrayBuffer) {\n // Look for ArrayBufferView, which isn't a real type, but basically\n // represents all the valid TypedArray types plus DataView. They all have\n // \".buffer\" as an instance of ArrayBuffer.\n bytes = new Uint8Array(/** @type {ArrayBufferView} */(buffer).buffer);\n } else {\n // The only other valid argument here is that \"buffer\" is an ArrayBuffer.\n // We also try to convert anything else passed to a Uint8Array, as this\n // catches anything that's array-like. Native code would throw here.\n bytes = new Uint8Array(/** @type {any} */(buffer));\n }\n\n return decodeImpl(bytes, this.encoding);\n};\n", "\nimport { FastTextEncoder } from './o-encoder.js';\nimport { FastTextDecoder } from './o-decoder.js';\n\n// /** @type {object} */\n// const scope = typeof window !== 'undefined' ? window : (typeof global !== 'undefined' ? global : this);\n\nscope['TextEncoder'] = scope['TextEncoder'] || FastTextEncoder;\nscope['TextDecoder'] = scope['TextDecoder'] || FastTextDecoder;\n\n// export {};\n"], - "mappings": ";AAMO,SAASA,EAAaC,EAAOC,EAAU,CAE5C,IAAIC,EACJ,OAAIF,aAAiB,OAEnBE,EAAIF,EAEJE,EAAI,OAAO,KAAKF,EAAM,OAAQA,EAAM,WAAYA,EAAM,UAAU,EAE3DE,EAAE,SAAuCD,CAAS,CAC3D,CAOO,IAAIE,EAAe,SAACC,EAAQ,CAAG,cAAO,KAAKA,CAAM,GClBjD,SAASC,EAAeC,EAAO,CAapC,QAZIC,EAAa,EAObC,EAAc,KAAK,IAAI,IAAM,IAAKF,EAAM,OAAS,CAAC,EAClDG,EAAU,IAAI,YAAYD,CAAW,EACrCE,EAAS,CAAC,EACVC,EAAe,IAET,CACR,IAAIC,EAAOL,EAAaD,EAAM,OAK9B,GAAI,CAACM,GAASD,GAAgBH,EAAc,EAAI,CAM9C,IAAIK,EAAWJ,EAAQ,SAAS,EAAGE,CAAY,EAC3CG,EAA6DD,EAGjE,GAFAH,EAAO,KAAK,OAAO,aAAa,MAAM,KAAMI,CAAS,CAAC,EAElD,CAACF,EACH,OAAOF,EAAO,KAAK,EAAE,EAIvBJ,EAAQA,EAAM,SAASC,CAAU,EACjCA,EAAa,EACbI,EAAe,CACjB,CAMA,IAAII,EAAQT,EAAMC,KAClB,IAAKQ,EAAQ,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Buffer", "string", "decodeFallback", "bytes", "inputIndex", "pendingSize", "pending", "chunks", "pendingIndex", "more", "subarray", "arraylike", "byte1", "byte2", "byte3", "byte4", "codepoint", "encodeFallback", "string", "pos", "len", "at", "tlen", "target", "value", "extra", "update", "failedToString", "maybeThrowFailedToOption", "check", "operation", "fieldName", "hasBufferFrom", "encodeImpl", "hasBufferFrom", "encodeBuffer", "encodeFallback", "FastTextEncoder", "string", "options", "maybeThrowFailedToOption", "decodeSyncXHR", "bytes", "u", "b", "x", "trySyncXHR", "hasBufferFrom", "validUtfLabels", "decodeImpl", "decodeFallback", "decodeBuffer", "string", "decodeSyncXHR", "ctorString", "errorPrefix", "failedToString", "FastTextDecoder", "utfLabel", "options", "maybeThrowFailedToOption", "ok", "buffer", "bytes", "FastTextEncoder", "FastTextDecoder"] + "sourcesContent": ["\r\n/**\r\n * @param {Uint8Array} bytes\r\n * @param {string} encoding\r\n * @return {string}\r\n */\r\nexport function decodeBuffer(bytes, encoding, fatal) {\r\n /** @type {Buffer} */\r\n var b;\r\n if (bytes instanceof Buffer) {\r\n // @ts-ignore\r\n b = bytes;\r\n } else {\r\n try {\r\n b = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);\r\n } catch(err) {\r\n if (!fatal) {\r\n return '';\r\n } else {\r\n throw err;\r\n }\r\n }\r\n }\r\n return b.toString(/** @type {BufferEncoding} */(encoding));\r\n}\r\n\r\n\r\n/**\r\n * @param {string} string\r\n * @return {Uint8Array}\r\n */\r\nexport var encodeBuffer = (string) => Buffer.from(string);\r\n", "\r\n/** @type {(bytes: Uint8Array, encoding: string, fatal: boolean) => string} */\r\nexport function decodeFallback(bytes, encoding, fatal) {\r\n var inputIndex = 0;\r\n\r\n // Create a working buffer for UTF-16 code points, but don't generate one\r\n // which is too large for small input sizes. UTF-8 to UCS-16 conversion is\r\n // going to be at most 1:1, if all code points are ASCII. The other extreme\r\n // is 4-byte UTF-8, which results in two UCS-16 points, but this is still 50%\r\n // fewer entries in the output.\r\n var pendingSize = Math.min(256 * 256, bytes.length + 1);\r\n var pending = new Uint16Array(pendingSize);\r\n var chunks = [];\r\n var pendingIndex = 0;\r\n\r\n for (; ;) {\r\n var more = inputIndex < bytes.length;\r\n\r\n // If there's no more data or there'd be no room for two UTF-16 values,\r\n // create a chunk. This isn't done at the end by simply slicing the data\r\n // into equal sized chunks as we might hit a surrogate pair.\r\n if (!more || (pendingIndex >= pendingSize - 1)) {\r\n // nb. .apply and friends are *really slow*. Low-hanging fruit is to\r\n // expand this to literally pass pending[0], pending[1], ... etc, but\r\n // the output code expands pretty fast in this case.\r\n // These extra vars get compiled out: they're just to make TS happy.\r\n // Turns out you can pass an ArrayLike to .apply().\r\n var subarray = pending.subarray(0, pendingIndex);\r\n var arraylike = /** @type {number[]} */ (/** @type {unknown} */ (subarray));\r\n chunks.push(String.fromCharCode.apply(null, arraylike));\r\n\r\n if (!more) {\r\n return chunks.join('');\r\n }\r\n\r\n // Move the buffer forward and create another chunk.\r\n bytes = bytes.subarray(inputIndex);\r\n inputIndex = 0;\r\n pendingIndex = 0;\r\n }\r\n\r\n // The native TextDecoder will generate \"REPLACEMENT CHARACTER\" where the\r\n // input data is invalid. Here, we blindly parse the data even if it's\r\n // wrong: e.g., if a 3-byte sequence doesn't have two valid continuations.\r\n\r\n var byte1 = bytes[inputIndex++];\r\n if ((byte1 & 0x80) === 0) { // 1-byte or null\r\n pending[pendingIndex++] = byte1;\r\n } else if ((byte1 & 0xe0) === 0xc0) { // 2-byte\r\n var byte2 = bytes[inputIndex++] & 0x3f;\r\n pending[pendingIndex++] = ((byte1 & 0x1f) << 6) | byte2;\r\n } else if ((byte1 & 0xf0) === 0xe0) { // 3-byte\r\n var byte2 = bytes[inputIndex++] & 0x3f;\r\n var byte3 = bytes[inputIndex++] & 0x3f;\r\n pending[pendingIndex++] = ((byte1 & 0x1f) << 12) | (byte2 << 6) | byte3;\r\n } else if ((byte1 & 0xf8) === 0xf0) { // 4-byte\r\n var byte2 = bytes[inputIndex++] & 0x3f;\r\n var byte3 = bytes[inputIndex++] & 0x3f;\r\n var byte4 = bytes[inputIndex++] & 0x3f;\r\n\r\n // this can be > 0xffff, so possibly generate surrogates\r\n var codepoint = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0c) | (byte3 << 0x06) | byte4;\r\n if (codepoint > 0xffff) {\r\n // codepoint &= ~0x10000;\r\n codepoint -= 0x10000;\r\n pending[pendingIndex++] = (codepoint >>> 10) & 0x3ff | 0xd800;\r\n codepoint = 0xdc00 | codepoint & 0x3ff;\r\n }\r\n pending[pendingIndex++] = codepoint;\r\n } else if (fatal) {\r\n // invalid initial byte\r\n throw new Error('invalid input');\r\n }\r\n }\r\n}\r\n\r\n\r\n/**\r\n * @param {string} string\r\n * @return {Uint8Array}\r\n */\r\nexport function encodeFallback(string) {\r\n var pos = 0;\r\n var len = string.length;\r\n\r\n var at = 0; // output position\r\n var tlen = Math.max(32, len + (len >>> 1) + 7); // 1.5x size\r\n var target = new Uint8Array((tlen >>> 3) << 3); // ... but at 8 byte offset\r\n\r\n while (pos < len) {\r\n var value = string.charCodeAt(pos++);\r\n if (value >= 0xd800 && value <= 0xdbff) {\r\n // high surrogate\r\n if (pos < len) {\r\n var extra = string.charCodeAt(pos);\r\n if ((extra & 0xfc00) === 0xdc00) {\r\n ++pos;\r\n value = ((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000;\r\n }\r\n }\r\n if (value >= 0xd800 && value <= 0xdbff) {\r\n continue; // drop lone surrogate\r\n }\r\n }\r\n\r\n // expand the buffer if we couldn't write 4 bytes\r\n if (at + 4 > target.length) {\r\n tlen += 8; // minimum extra\r\n tlen *= (1.0 + (pos / string.length) * 2); // take 2x the remaining\r\n tlen = (tlen >>> 3) << 3; // 8 byte offset\r\n\r\n var update = new Uint8Array(tlen);\r\n update.set(target);\r\n target = update;\r\n }\r\n\r\n if ((value & 0xffffff80) === 0) { // 1-byte\r\n target[at++] = value; // ASCII\r\n continue;\r\n } else if ((value & 0xfffff800) === 0) { // 2-byte\r\n target[at++] = ((value >>> 6) & 0x1f) | 0xc0;\r\n } else if ((value & 0xffff0000) === 0) { // 3-byte\r\n target[at++] = ((value >>> 12) & 0x0f) | 0xe0;\r\n target[at++] = ((value >>> 6) & 0x3f) | 0x80;\r\n } else if ((value & 0xffe00000) === 0) { // 4-byte\r\n target[at++] = ((value >>> 18) & 0x07) | 0xf0;\r\n target[at++] = ((value >>> 12) & 0x3f) | 0x80;\r\n target[at++] = ((value >>> 6) & 0x3f) | 0x80;\r\n } else {\r\n continue; // out of range\r\n }\r\n\r\n target[at++] = (value & 0x3f) | 0x80;\r\n }\r\n\r\n // Use subarray if slice isn't supported (IE11). This will use more memory\r\n // because the original array still exists.\r\n return target.slice ? target.slice(0, at) : target.subarray(0, at);\r\n}\r\n", "\r\nexport var failedToString = 'Failed to ';\r\n\r\n/**\r\n * @param {boolean|undefined} check \r\n * @param {string} operation \r\n * @param {string} fieldName \r\n */\r\nexport var maybeThrowFailedToOption = (check, operation, fieldName) => {\r\n if (check) {\r\n throw new Error(`${failedToString}${operation}: the '${fieldName}' option is unsupported.`);\r\n }\r\n};", "\r\nexport var hasBufferFrom = (typeof Buffer === 'function' && Buffer.from);", "import { encodeBuffer } from './buffer.js';\r\nimport { encodeFallback } from './lowlevel.js';\r\nimport { maybeThrowFailedToOption } from './shared.js';\r\nimport { hasBufferFrom } from './support.js';\r\n\r\nexport var encodeImpl = hasBufferFrom ? encodeBuffer : encodeFallback;\r\n\r\n/**\r\n * @constructor\r\n */\r\nexport function FastTextEncoder() {\r\n // This does not accept an encoding, and always uses UTF-8:\r\n // https://www.w3.org/TR/encoding/#dom-textencoder\r\n this.encoding = 'utf-8';\r\n}\r\n\r\n/**\r\n * @param {string} string\r\n * @param {{stream: boolean}=} options\r\n * @return {Uint8Array}\r\n */\r\nFastTextEncoder.prototype.encode = function (string, options) {\r\n maybeThrowFailedToOption(options && options.stream, 'encode', 'stream');\r\n return encodeImpl(string);\r\n};\r\n", "\r\n/**\r\n * This is a horrible hack which works in some old browsers. We can tell them to decode bytes via\r\n * sync XHR.\r\n *\r\n * Throws if fails. Should be wrapped in something to check that.\r\n *\r\n * @param {Uint8Array} bytes\r\n * @return {string}\r\n */\r\nexport function decodeSyncXHR(bytes) {\r\n var u;\r\n\r\n // This hack will fail in non-Edgium Edge because sync XHRs are disabled (and\r\n // possibly in other places), so ensure there's a fallback call.\r\n try {\r\n var b = new Blob([bytes], { type: 'text/plain;charset=UTF-8' });\r\n u = URL.createObjectURL(b);\r\n\r\n var x = new XMLHttpRequest();\r\n x.open('GET', u, false);\r\n x.send();\r\n return x.responseText;\r\n } finally {\r\n if (u) {\r\n URL.revokeObjectURL(u);\r\n }\r\n }\r\n}", "import { decodeBuffer } from './buffer.js';\r\nimport { decodeFallback } from './lowlevel.js';\r\nimport { failedToString, maybeThrowFailedToOption } from './shared.js';\r\nimport { hasBufferFrom } from './support.js';\r\nimport { decodeSyncXHR } from './xhr.js';\r\n\r\nvar trySyncXHR = !hasBufferFrom && (typeof Blob === 'function' && typeof URL === 'function' && typeof URL.createObjectURL === 'function');\r\nvar validUtfLabels = ['utf-8', 'utf8', 'unicode-1-1-utf-8'];\r\n\r\n/** @type {(bytes: Uint8Array, encoding: string, fatal: boolean) => string} */\r\nvar decodeImpl = decodeFallback;\r\nif (hasBufferFrom) {\r\n decodeImpl = decodeBuffer;\r\n} else if (trySyncXHR) {\r\n decodeImpl = (string, encoding, fatal) => {\r\n try {\r\n return decodeSyncXHR(string);\r\n } catch (e) {\r\n return decodeFallback(string, encoding, fatal);\r\n }\r\n };\r\n}\r\n\r\n\r\nvar ctorString = `construct 'TextDecoder'`;\r\nvar errorPrefix = `${failedToString} ${ctorString}: the `;\r\n\r\n\r\n/**\r\n * @constructor\r\n * @param {string=} utfLabel\r\n * @param {{fatal: boolean}=} options\r\n */\r\nexport function FastTextDecoder(utfLabel, options) {\r\n utfLabel = utfLabel || 'utf-8';\r\n\r\n /** @type {boolean} */\r\n var ok;\r\n if (hasBufferFrom) {\r\n ok = Buffer.isEncoding(utfLabel);\r\n } else {\r\n ok = validUtfLabels.indexOf(utfLabel.toLowerCase()) !== -1;\r\n }\r\n if (!ok) {\r\n throw new RangeError(`${errorPrefix} encoding label provided ('${utfLabel}') is invalid.`);\r\n }\r\n\r\n this.encoding = utfLabel;\r\n this.fatal = options && options.fatal\r\n ? true\r\n : false;\r\n this.ignoreBOM = false;\r\n}\r\n\r\n/**\r\n * @param {(ArrayBuffer|ArrayBufferView)} buffer\r\n * @param {{stream: boolean, fatal: boolean}=} options\r\n * @return {string}\r\n */\r\nFastTextDecoder.prototype.decode = function (buffer, options) {\r\n maybeThrowFailedToOption(options && options.stream, 'decode', 'stream');\r\n\r\n var bytes;\r\n\r\n if (buffer instanceof Uint8Array) {\r\n // Accept Uint8Array instances as-is. This is also a Node buffer.\r\n bytes = buffer;\r\n } else if (buffer['buffer'] instanceof ArrayBuffer) {\r\n // Look for ArrayBufferView, which isn't a real type, but basically\r\n // represents all the valid TypedArray types plus DataView. They all have\r\n // \".buffer\" as an instance of ArrayBuffer.\r\n bytes = new Uint8Array(/** @type {ArrayBufferView} */(buffer).buffer);\r\n } else {\r\n // The only other valid argument here is that \"buffer\" is an ArrayBuffer.\r\n // We also try to convert anything else passed to a Uint8Array, as this\r\n // catches anything that's array-like. Native code would throw here.\r\n bytes = new Uint8Array(/** @type {any} */(buffer));\r\n }\r\n\r\n return decodeImpl(bytes, this.encoding, this.fatal);\r\n};\r\n", "\r\nimport { FastTextEncoder } from './o-encoder.js';\r\nimport { FastTextDecoder } from './o-decoder.js';\r\n\r\n// /** @type {object} */\r\n// const scope = typeof window !== 'undefined' ? window : (typeof global !== 'undefined' ? global : this);\r\n\r\nscope['TextEncoder'] = scope['TextEncoder'] || FastTextEncoder;\r\nscope['TextDecoder'] = scope['TextDecoder'] || FastTextDecoder;\r\n\r\n// export {};\r\n"], + "mappings": ";AAMO,SAASA,EAAaC,EAAOC,EAAUC,EAAO,CAEnD,IAA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,EAAP,CACA,OAAOF,EAAeE,EAAQC,EAAUC,CAAK,CAC/C,CACF,GAIF,IAAIE,EAAa,0BACbC,EAAc,GAAG,OAAAC,EAAc,KAAI,OAAAF,EAAU,UAQ1C,SAASG,EAAgBC,EAAUC,EAAS,CACjDD,EAAWA,GAAY,QAGvB,IAAIE,EAMJ,GALIf,EACFe,EAAK,OAAO,WAAWF,CAAQ,EAE/BE,EAAKd,EAAe,QAAQY,EAAS,YAAY,CAAC,IAAM,GAEtD,CAACE,EACH,MAAM,IAAI,WAAW,GAAG,OAAAL,EAAW,+BAA8B,OAAAG,EAAQ,iBAAgB,EAG3F,KAAK,SAAWA,EAChB,KAAK,MAAQ,GAAAC,GAAWA,EAAQ,OAGhC,KAAK,UAAY,EACnB,CAOAF,EAAgB,UAAU,OAAS,SAAUI,EAAQF,EAAS,CAC5DG,EAAyBH,GAAWA,EAAQ,OAAQ,SAAU,QAAQ,EAEtE,IAAII,EAEJ,OAAIF,aAAkB,WAEpBE,EAAQF,EACCA,EAAO,kBAAqB,YAIrCE,EAAQ,IAAI,WAA0CF,EAAQ,MAAM,EAKpEE,EAAQ,IAAI,WAA8BF,CAAO,EAG5Cd,EAAWgB,EAAO,KAAK,SAAU,KAAK,KAAK,CACpD,ECzEA,MAAM,YAAiB,MAAM,aAAkBC,EAC/C,MAAM,YAAiB,MAAM,aAAkBC", + "names": ["decodeBuffer", "bytes", "encoding", "fatal", "b", "err", "encodeBuffer", "string", "decodeFallback", "bytes", "encoding", "fatal", "inputIndex", "pendingSize", "pending", "chunks", "pendingIndex", "more", "subarray", "arraylike", "byte1", "byte2", "byte3", "byte4", "codepoint", "encodeFallback", "string", "pos", "len", "at", "tlen", "target", "value", "extra", "update", "failedToString", "maybeThrowFailedToOption", "check", "operation", "fieldName", "hasBufferFrom", "encodeImpl", "hasBufferFrom", "encodeBuffer", "encodeFallback", "FastTextEncoder", "string", "options", "maybeThrowFailedToOption", "decodeSyncXHR", "bytes", "u", "b", "x", "trySyncXHR", "hasBufferFrom", "validUtfLabels", "decodeImpl", "decodeFallback", "decodeBuffer", "string", "encoding", "fatal", "decodeSyncXHR", "ctorString", "errorPrefix", "failedToString", "FastTextDecoder", "utfLabel", "options", "ok", "buffer", "maybeThrowFailedToOption", "bytes", "FastTextEncoder", "FastTextDecoder"] }