248 lines
9.1 KiB
JavaScript
248 lines
9.1 KiB
JavaScript
var __bare_os_bundle_exports__ = (() => {
|
|
var __create = Object.create;
|
|
var __defProp = Object.defineProperty;
|
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
var __getProtoOf = Object.getPrototypeOf;
|
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
var __commonJS = (cb, mod) => function __require() {
|
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
};
|
|
var __export = (target, all) => {
|
|
for (var name in all)
|
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
};
|
|
var __copyProps = (to, from, except, desc) => {
|
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
for (let key of __getOwnPropNames(from))
|
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
}
|
|
return to;
|
|
};
|
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
// file that has been converted to a CommonJS file using a Babel-
|
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
mod
|
|
));
|
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
|
|
// ../../node_modules/bare-encoding/lib/utf8-decoder.js
|
|
var require_utf8_decoder = __commonJS({
|
|
"../../node_modules/bare-encoding/lib/utf8-decoder.js"(exports, module) {
|
|
module.exports = class UTF8Decoder {
|
|
constructor() {
|
|
this.codePoint = 0;
|
|
this.bytesSeen = 0;
|
|
this.bytesNeeded = 0;
|
|
this.lowerBoundary = 128;
|
|
this.upperBoundary = 191;
|
|
}
|
|
get remaining() {
|
|
return this.bytesSeen;
|
|
}
|
|
decode(data) {
|
|
if (ArrayBuffer.isView(data)) {
|
|
data = Buffer.from(data.buffer, data.byteOffset, data.byteLength);
|
|
} else {
|
|
data = Buffer.from(data);
|
|
}
|
|
if (this.bytesNeeded === 0) {
|
|
let isBoundary = true;
|
|
for (let i = Math.max(0, data.byteLength - 4), n = data.byteLength; i < n && isBoundary; i++) {
|
|
isBoundary = data[i] <= 127;
|
|
}
|
|
if (isBoundary) return data.toString("utf8");
|
|
}
|
|
let result = "";
|
|
for (let i = 0, n = data.byteLength; i < n; i++) {
|
|
const byte = data[i];
|
|
if (this.bytesNeeded === 0) {
|
|
if (byte <= 127) {
|
|
this.bytesSeen = 0;
|
|
result += String.fromCharCode(byte);
|
|
} else {
|
|
this.bytesSeen = 1;
|
|
if (byte >= 194 && byte <= 223) {
|
|
this.bytesNeeded = 2;
|
|
this.codePoint = byte & 31;
|
|
} else if (byte >= 224 && byte <= 239) {
|
|
if (byte === 224) this.lowerBoundary = 160;
|
|
else if (byte === 237) this.upperBoundary = 159;
|
|
this.bytesNeeded = 3;
|
|
this.codePoint = byte & 15;
|
|
} else if (byte >= 240 && byte <= 244) {
|
|
if (byte === 240) this.lowerBoundary = 144;
|
|
if (byte === 244) this.upperBoundary = 143;
|
|
this.bytesNeeded = 4;
|
|
this.codePoint = byte & 7;
|
|
} else {
|
|
result += "\uFFFD";
|
|
}
|
|
}
|
|
continue;
|
|
}
|
|
if (byte < this.lowerBoundary || byte > this.upperBoundary) {
|
|
this.codePoint = 0;
|
|
this.bytesNeeded = 0;
|
|
this.bytesSeen = 0;
|
|
this.lowerBoundary = 128;
|
|
this.upperBoundary = 191;
|
|
result += "\uFFFD";
|
|
i--;
|
|
continue;
|
|
}
|
|
this.lowerBoundary = 128;
|
|
this.upperBoundary = 191;
|
|
this.codePoint = this.codePoint << 6 | byte & 63;
|
|
this.bytesSeen++;
|
|
if (this.bytesSeen !== this.bytesNeeded) continue;
|
|
result += String.fromCodePoint(this.codePoint);
|
|
this.codePoint = 0;
|
|
this.bytesNeeded = 0;
|
|
this.bytesSeen = 0;
|
|
}
|
|
return result;
|
|
}
|
|
flush() {
|
|
const result = this.bytesNeeded > 0 ? "\uFFFD" : "";
|
|
this.codePoint = 0;
|
|
this.bytesNeeded = 0;
|
|
this.bytesSeen = 0;
|
|
this.lowerBoundary = 128;
|
|
this.upperBoundary = 191;
|
|
return result;
|
|
}
|
|
};
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-encoding/lib/pass-through-decoder.js
|
|
var require_pass_through_decoder = __commonJS({
|
|
"../../node_modules/bare-encoding/lib/pass-through-decoder.js"(exports, module) {
|
|
module.exports = class PassThroughDecoder {
|
|
constructor(encoding) {
|
|
this.encoding = encoding;
|
|
}
|
|
get remaining() {
|
|
return 0;
|
|
}
|
|
decode(data) {
|
|
if (ArrayBuffer.isView(data)) {
|
|
data = Buffer.from(data.buffer, data.byteOffset, data.byteLength);
|
|
} else {
|
|
data = Buffer.from(data);
|
|
}
|
|
return data.toString(this.encoding);
|
|
}
|
|
flush() {
|
|
return "";
|
|
}
|
|
};
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-encoding/lib/errors.js
|
|
var require_errors = __commonJS({
|
|
"../../node_modules/bare-encoding/lib/errors.js"(exports, module) {
|
|
module.exports = class EncodingError extends Error {
|
|
constructor(msg, code, fn = EncodingError) {
|
|
super(`${code}: ${msg}`);
|
|
this.code = code;
|
|
if (Error.captureStackTrace) {
|
|
Error.captureStackTrace(this, fn);
|
|
}
|
|
}
|
|
get name() {
|
|
return "EncodingError";
|
|
}
|
|
static INVALID_LABEL(msg) {
|
|
return new EncodingError(msg, "INVALID_LABEL", EncodingError.INVALID_LABEL);
|
|
}
|
|
};
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-encoding/index.js
|
|
var require_bare_encoding = __commonJS({
|
|
"../../node_modules/bare-encoding/index.js"(exports) {
|
|
var UTF8Decoder = require_utf8_decoder();
|
|
var PassThroughDecoder = require_pass_through_decoder();
|
|
var errors = require_errors();
|
|
exports.TextEncoder = class TextEncoder {
|
|
// https://encoding.spec.whatwg.org/#dom-textencoder-encoding
|
|
get encoding() {
|
|
return "utf-8";
|
|
}
|
|
// https://encoding.spec.whatwg.org/#dom-textencoder-encode
|
|
encode(input) {
|
|
return Buffer.from(input);
|
|
}
|
|
// https://encoding.spec.whatwg.org/#dom-textencoder-encodeinto
|
|
encodeInto(input, destination) {
|
|
if (ArrayBuffer.isView(destination)) {
|
|
destination = Buffer.from(
|
|
destination.buffer,
|
|
destination.byteOffset,
|
|
destination.byteLength
|
|
);
|
|
} else {
|
|
destination = Buffer.from(destination);
|
|
}
|
|
return {
|
|
read: input.length,
|
|
written: destination.write(input)
|
|
};
|
|
}
|
|
};
|
|
exports.TextDecoder = class TextDecoder {
|
|
// https://encoding.spec.whatwg.org/#dom-textdecoder
|
|
constructor(label = "utf-8") {
|
|
this.encoding = getEncoding(label);
|
|
switch (this.encoding) {
|
|
case "utf-8":
|
|
this.decoder = new UTF8Decoder();
|
|
break;
|
|
default:
|
|
this.decoder = new PassThroughDecoder(this.encoding);
|
|
break;
|
|
}
|
|
}
|
|
// https://encoding.spec.whatwg.org/#dom-textdecoder-decode
|
|
decode(input, options = {}) {
|
|
const result = this.decoder.decode(input);
|
|
if (options.stream) return result;
|
|
return result + this.decoder.flush();
|
|
}
|
|
};
|
|
function getEncoding(label) {
|
|
switch (label.trim().toLowerCase()) {
|
|
case "unicode-1-1-utf-8":
|
|
case "unicode11utf8":
|
|
case "unicode11utf8":
|
|
case "unicode20utf8":
|
|
case "utf-8":
|
|
case "utf8":
|
|
case "x-unicode20utf8":
|
|
return "utf-8";
|
|
default:
|
|
throw errors.INVALID_LABEL(`The label '${label}' is not a valid encoding`);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
// ../../bare-lib-entry-bareEncoding.js
|
|
var bare_lib_entry_bareEncoding_exports = {};
|
|
__export(bare_lib_entry_bareEncoding_exports, {
|
|
default: () => bare_lib_entry_bareEncoding_default
|
|
});
|
|
var import_bare_encoding = __toESM(require_bare_encoding());
|
|
var bare_lib_entry_bareEncoding_default = import_bare_encoding.default;
|
|
return __toCommonJS(bare_lib_entry_bareEncoding_exports);
|
|
})();
|
|
;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};var e=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;var v=e!=null&&typeof e==="object"&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e;g[s]["bareEncoding"]=v;})();
|