diff --git a/cmake/sources/NodeFallbacksSources.txt b/cmake/sources/NodeFallbacksSources.txt index d18c84e996..d87a3fd44a 100644 --- a/cmake/sources/NodeFallbacksSources.txt +++ b/cmake/sources/NodeFallbacksSources.txt @@ -17,6 +17,7 @@ src/node-fallbacks/stream.js src/node-fallbacks/string_decoder.js src/node-fallbacks/sys.js src/node-fallbacks/timers.js +src/node-fallbacks/timers.promises.js src/node-fallbacks/tty.js src/node-fallbacks/url.js src/node-fallbacks/util.js diff --git a/cmake/targets/BuildBun.cmake b/cmake/targets/BuildBun.cmake index 87c2545010..4a63ecf650 100644 --- a/cmake/targets/BuildBun.cmake +++ b/cmake/targets/BuildBun.cmake @@ -161,14 +161,9 @@ register_command( CWD ${BUN_NODE_FALLBACKS_SOURCE} COMMAND - ${BUN_EXECUTABLE} x - esbuild ${ESBUILD_ARGS} + ${BUN_EXECUTABLE} run build-fallbacks + ${BUN_NODE_FALLBACKS_OUTPUT} ${BUN_NODE_FALLBACKS_SOURCES} - --outdir=${BUN_NODE_FALLBACKS_OUTPUT} - --format=esm - --minify - --bundle - --platform=browser SOURCES ${BUN_NODE_FALLBACKS_SOURCES} ${BUN_NODE_FALLBACKS_NODE_MODULES} diff --git a/src/node-fallbacks/assert.js b/src/node-fallbacks/assert.js index 1e2e54d9da..c598676b2a 100644 --- a/src/node-fallbacks/assert.js +++ b/src/node-fallbacks/assert.js @@ -1,6 +1,24 @@ -/** - * Browser polyfill for the `"assert"` module. - * - * Imported on usage in `bun build --target=browser` - */ -export * from "assert"; +import assert_module from "assert"; + +export const AssertionError = assert_module.AssertionError; +export const CallTracker = assert_module.CallTracker; +export const deepEqual = assert_module.deepEqual; +export const deepStrictEqual = assert_module.deepStrictEqual; +export const doesNotMatch = assert_module.doesNotMatch; +export const doesNotReject = assert_module.doesNotReject; +export const doesNotThrow = assert_module.doesNotThrow; +export const equal = assert_module.equal; +export const fail = assert_module.fail; +export const ifError = assert_module.ifError; +export const match = assert_module.match; +export const notDeepEqual = assert_module.notDeepEqual; +export const notDeepStrictEqual = assert_module.notDeepStrictEqual; +export const notEqual = assert_module.notEqual; +export const notStrictEqual = assert_module.notStrictEqual; +export const ok = assert_module.ok; +export const rejects = assert_module.rejects; +export const strict = assert_module.strict; +export const strictEqual = assert_module.strictEqual; +export const throws = assert_module.throws; + +export * as default from "assert"; diff --git a/src/node-fallbacks/buffer.js b/src/node-fallbacks/buffer.js index 23b838ffa3..2d9e3c0f23 100644 --- a/src/node-fallbacks/buffer.js +++ b/src/node-fallbacks/buffer.js @@ -1,35 +1,2035 @@ -/** - * Browser polyfill for the `"buffer"` module. +/* + * The buffer module from node.js, for the browser. * - * Imported on usage in `bun build --target=browser` + * Modified to an ES module for usage in Bun. Additional changes were made to + * add many pure annotations, and support newer node features, such as + * re-exporting Blob and file. + * + * @author Feross Aboukhadijeh + * @license MIT */ -export * from "./node_modules/buffer"; -export { Buffer, Buffer as default } from "./node_modules/buffer"; -export var kStringMaxLength = 2 ** 32 - 1; -export var kMaxLength = 9007199254740991; -export var { Blob, File, atob, btoa } = globalThis; -export var { createObjectURL } = URL; -export var isAscii = buf => { - if (ArrayBuffer.isView(buf)) { - return buf.every(byte => byte < 128); + +"use strict"; + +import * as base64 from "./vendor/base64-js.js"; +import * as ieee754 from "./vendor/ieee754.js"; + +const customInspectSymbol = + typeof Symbol === "function" && typeof Symbol["for"] === "function" // eslint-disable-line dot-notation + ? Symbol["for"]("nodejs.util.inspect.custom") // eslint-disable-line dot-notation + : null; + +export const INSPECT_MAX_BYTES = 50; + +export const kMaxLength = 0x7fffffff; +export const kStringMaxLength = 0x1fffffe8; + +export const btoa = /* @__PURE__ */ globalThis.btoa; +export const atob = /* @__PURE__ */ globalThis.atob; +export const File = /* @__PURE__ */ globalThis.File; +export const Blob = /* @__PURE__ */ globalThis.Blob; + +export const constants = { MAX_LENGTH: kMaxLength, MAX_STRING_LENGTH: kStringMaxLength }; + +function createBuffer(length) { + if (length > kMaxLength) { + throw new RangeError('The value "' + length + '" is invalid for option "size"'); + } + // Return an augmented `Uint8Array` instance + const buf = new Uint8Array(length); + Object.setPrototypeOf(buf, Buffer.prototype); + return buf; +} + +// CUSTOM ERRORS +// ============= + +// Simplified versions from Node, changed for Buffer-only usage +function E(sym, getMessage, Base) { + return class NodeError extends Base { + constructor() { + super(); + + Object.defineProperty(this, "message", { + value: getMessage.apply(this, arguments), + writable: true, + configurable: true, + }); + + // Add the error code to the name to include it in the stack trace. + this.name = `${this.name} [${sym}]`; + // Access the stack to generate the error message including the error code + // from the name. + this.stack; // eslint-disable-line no-unused-expressions + // Reset the name to the actual name. + delete this.name; + } + + get code() { + return sym; + } + + set code(value) { + Object.defineProperty(this, "code", { + configurable: true, + enumerable: true, + value, + writable: true, + }); + } + + toString() { + return `${this.name} [${sym}]: ${this.message}`; + } + }; +} + +const ERR_BUFFER_OUT_OF_BOUNDS = /* @__PURE__ */ E( + "ERR_BUFFER_OUT_OF_BOUNDS", + function (name) { + if (name) { + return `${name} is outside of buffer bounds`; + } + + return "Attempt to access memory outside buffer bounds"; + }, + RangeError, +); + +const ERR_INVALID_ARG_TYPE = /* @__PURE__ */ E( + "ERR_INVALID_ARG_TYPE", + function (name, actual) { + return `The "${name}" argument must be of type number. Received type ${typeof actual}`; + }, + TypeError, +); + +const ERR_OUT_OF_RANGE = /* @__PURE__ */ E( + "ERR_OUT_OF_RANGE", + function (str, range, input) { + let msg = `The value of "${str}" is out of range.`; + let received = input; + if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) { + received = addNumericalSeparator(String(input)); + } else if (typeof input === "bigint") { + received = String(input); + if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) { + received = addNumericalSeparator(received); + } + received += "n"; + } + msg += ` It must be ${range}. Received ${received}`; + return msg; + }, + RangeError, +); + +/** + * The Buffer constructor returns instances of `Uint8Array` that have their + * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of + * `Uint8Array`, so the returned instances will have all the node `Buffer` methods + * and the `Uint8Array` methods. Square bracket notation works as expected -- it + * returns a single octet. + * + * The `Uint8Array` prototype remains unmodified. + */ +export function Buffer(arg, encodingOrOffset, length) { + // Common case. + if (typeof arg === "number") { + if (typeof encodingOrOffset === "string") { + throw new TypeError('The "string" argument must be of type string. Received type number'); + } + return allocUnsafe(arg); + } + return from(arg, encodingOrOffset, length); +} + +Object.defineProperty(Buffer.prototype, "parent", { + enumerable: true, + get: function () { + if (!Buffer.isBuffer(this)) return undefined; + return this.buffer; + }, +}); + +Object.defineProperty(Buffer.prototype, "offset", { + enumerable: true, + get: function () { + if (!Buffer.isBuffer(this)) return undefined; + return this.byteOffset; + }, +}); + +Buffer.poolSize = 8192; // not used by this implementation + +function from(value, encodingOrOffset, length) { + if (typeof value === "string") { + return fromString(value, encodingOrOffset); + } + + if (ArrayBuffer.isView(value)) { + return fromArrayView(value); + } + + if (value == null) { + throw new TypeError( + "The first argument must be one of type string, Buffer, ArrayBuffer, Array, " + + "or Array-like Object. Received type " + + typeof value, + ); + } + + if (isInstance(value, ArrayBuffer) || (value && isInstance(value.buffer, ArrayBuffer))) { + return fromArrayBuffer(value, encodingOrOffset, length); + } + + if ( + typeof SharedArrayBuffer !== "undefined" && + (isInstance(value, SharedArrayBuffer) || (value && isInstance(value.buffer, SharedArrayBuffer))) + ) { + return fromArrayBuffer(value, encodingOrOffset, length); + } + + if (typeof value === "number") { + throw new TypeError('The "value" argument must not be of type number. Received type number'); + } + + const valueOf = value.valueOf && value.valueOf(); + if (valueOf != null && valueOf !== value) { + return Buffer.from(valueOf, encodingOrOffset, length); + } + + const b = fromObject(value); + if (b) return b; + + if (typeof Symbol !== "undefined" && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === "function") { + return Buffer.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length); + } + + throw new TypeError( + "The first argument must be one of type string, Buffer, ArrayBuffer, Array, " + + "or Array-like Object. Received type " + + typeof value, + ); +} + +/** + * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError + * if value is a number. + * Buffer.from(str[, encoding]) + * Buffer.from(array) + * Buffer.from(buffer) + * Buffer.from(arrayBuffer[, byteOffset[, length]]) + **/ +Buffer.from = function (value, encodingOrOffset, length) { + return from(value, encodingOrOffset, length); +}; + +// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: +// https://github.com/feross/buffer/pull/148 +Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype); +Object.setPrototypeOf(Buffer, Uint8Array); + +function assertSize(size) { + if (typeof size !== "number") { + throw new TypeError('"size" argument must be of type number'); + } else if (size < 0) { + throw new RangeError('The value "' + size + '" is invalid for option "size"'); + } +} + +function alloc(size, fill, encoding) { + assertSize(size); + if (size <= 0) { + return createBuffer(size); + } + if (fill !== undefined) { + // Only pay attention to encoding if it's a string. This + // prevents accidentally sending in a number that would + // be interpreted as a start offset. + return typeof encoding === "string" ? createBuffer(size).fill(fill, encoding) : createBuffer(size).fill(fill); + } + return createBuffer(size); +} + +/** + * Creates a new filled Buffer instance. + * alloc(size[, fill[, encoding]]) + **/ +Buffer.alloc = function (size, fill, encoding) { + return alloc(size, fill, encoding); +}; + +function allocUnsafe(size) { + assertSize(size); + return createBuffer(size < 0 ? 0 : checked(size) | 0); +} + +/** + * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. + * */ +Buffer.allocUnsafe = function (size) { + return allocUnsafe(size); +}; +/** + * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. + */ +Buffer.allocUnsafeSlow = function (size) { + return allocUnsafe(size); +}; + +function fromString(string, encoding) { + if (typeof encoding !== "string" || encoding === "") { + encoding = "utf8"; + } + + if (!Buffer.isEncoding(encoding)) { + throw new TypeError("Unknown encoding: " + encoding); + } + + const length = byteLength(string, encoding) | 0; + let buf = createBuffer(length); + + const actual = buf.write(string, encoding); + + if (actual !== length) { + // Writing a hex string, for example, that contains invalid characters will + // cause everything after the first invalid character to be ignored. (e.g. + // 'abxxcd' will be treated as 'ab') + buf = buf.slice(0, actual); + } + + return buf; +} + +function fromArrayLike(array) { + const length = array.length < 0 ? 0 : checked(array.length) | 0; + const buf = createBuffer(length); + for (let i = 0; i < length; i += 1) { + buf[i] = array[i] & 255; + } + return buf; +} + +function fromArrayView(arrayView) { + if (isInstance(arrayView, Uint8Array)) { + const copy = new Uint8Array(arrayView); + return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength); + } + return fromArrayLike(arrayView); +} + +function fromArrayBuffer(array, byteOffset, length) { + if (byteOffset < 0 || array.byteLength < byteOffset) { + throw new RangeError('"offset" is outside of buffer bounds'); + } + + if (array.byteLength < byteOffset + (length || 0)) { + throw new RangeError('"length" is outside of buffer bounds'); + } + + let buf; + if (byteOffset === undefined && length === undefined) { + buf = new Uint8Array(array); + } else if (length === undefined) { + buf = new Uint8Array(array, byteOffset); } else { - return buf.split("").every(char => char.charCodeAt(0) < 128); + buf = new Uint8Array(array, byteOffset, length); + } + + // Return an augmented `Uint8Array` instance + Object.setPrototypeOf(buf, Buffer.prototype); + + return buf; +} + +function fromObject(obj) { + if (Buffer.isBuffer(obj)) { + const len = checked(obj.length) | 0; + const buf = createBuffer(len); + + if (buf.length === 0) { + return buf; + } + + obj.copy(buf, 0, 0, len); + return buf; + } + + if (obj.length !== undefined) { + if (typeof obj.length !== "number" || numberIsNaN(obj.length)) { + return createBuffer(0); + } + return fromArrayLike(obj); + } + + if (obj.type === "Buffer" && Array.isArray(obj.data)) { + return fromArrayLike(obj.data); + } +} + +function checked(length) { + // Note: cannot use `length < K_MAX_LENGTH` here because that fails when + // length is NaN (which is otherwise coerced to zero.) + if (length >= kMaxLength) { + throw new RangeError( + "Attempt to allocate Buffer larger than maximum " + "size: 0x" + kMaxLength.toString(16) + " bytes", + ); + } + return length | 0; +} + +function SlowBuffer(length) { + if (+length != length) { + // eslint-disable-line eqeqeq + length = 0; + } + return Buffer.alloc(+length); +} + +Buffer.isBuffer = function isBuffer(b) { + return b != null && b._isBuffer === true && b !== Buffer.prototype; // so Buffer.isBuffer(Buffer.prototype) will be false +}; + +Buffer.compare = function compare(a, b) { + if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength); + if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength); + if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { + throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'); + } + + if (a === b) return 0; + + let x = a.length; + let y = b.length; + + for (let i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i]; + y = b[i]; + break; + } + } + + if (x < y) return -1; + if (y < x) return 1; + return 0; +}; + +Buffer.isEncoding = function isEncoding(encoding) { + switch (String(encoding).toLowerCase()) { + case "hex": + case "utf8": + case "utf-8": + case "ascii": + case "latin1": + case "binary": + case "base64": + case "ucs2": + case "ucs-2": + case "utf16le": + case "utf-16le": + return true; + default: + return false; } }; -export var isUtf8 = buf => { - throw new Error("Not implemented"); -}; -export var constants = { - __proto__: null, - MAX_LENGTH: kStringMaxLength, - MAX_STRING_LENGTH: kStringMaxLength, - BYTES_PER_ELEMENT: 1, + +Buffer.concat = function concat(list, length) { + if (!Array.isArray(list)) { + throw new TypeError('"list" argument must be an Array of Buffers'); + } + + if (list.length === 0) { + return Buffer.alloc(0); + } + + let i; + if (length === undefined) { + length = 0; + for (i = 0; i < list.length; ++i) { + length += list[i].length; + } + } + + const buffer = Buffer.allocUnsafe(length); + let pos = 0; + for (i = 0; i < list.length; ++i) { + let buf = list[i]; + if (isInstance(buf, Uint8Array)) { + if (pos + buf.length > buffer.length) { + if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf); + buf.copy(buffer, pos); + } else { + Uint8Array.prototype.set.call(buffer, buf, pos); + } + } else if (!Buffer.isBuffer(buf)) { + throw new TypeError('"list" argument must be an Array of Buffers'); + } else { + buf.copy(buffer, pos); + } + pos += buf.length; + } + return buffer; }; -export function resolveObjectURL(url) { - throw new Error("Not implemented"); +function byteLength(string, encoding) { + if (Buffer.isBuffer(string)) { + return string.length; + } + if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) { + return string.byteLength; + } + if (typeof string !== "string") { + throw new TypeError( + 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' + "Received type " + typeof string, + ); + } + + const len = string.length; + const mustMatch = arguments.length > 2 && arguments[2] === true; + if (!mustMatch && len === 0) return 0; + + // Use a for loop to avoid recursion + let loweredCase = false; + for (;;) { + switch (encoding) { + case "ascii": + case "latin1": + case "binary": + return len; + case "utf8": + case "utf-8": + return utf8ToBytes(string).length; + case "ucs2": + case "ucs-2": + case "utf16le": + case "utf-16le": + return len * 2; + case "hex": + return len >>> 1; + case "base64": + return base64ToBytes(string).length; + default: + if (loweredCase) { + return mustMatch ? -1 : utf8ToBytes(string).length; // assume utf8 + } + encoding = ("" + encoding).toLowerCase(); + loweredCase = true; + } + } +} +Buffer.byteLength = byteLength; + +function slowToString(encoding, start, end) { + let loweredCase = false; + + // No need to verify that "this.length <= MAX_UINT32" since it's a read-only + // property of a typed array. + + // This behaves neither like String nor Uint8Array in that we set start/end + // to their upper/lower bounds if the value passed is out of range. + // undefined is handled specially as per ECMA-262 6th Edition, + // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. + if (start === undefined || start < 0) { + start = 0; + } + // Return early if start > this.length. Done here to prevent potential uint32 + // coercion fail below. + if (start > this.length) { + return ""; + } + + if (end === undefined || end > this.length) { + end = this.length; + } + + if (end <= 0) { + return ""; + } + + // Force coercion to uint32. This will also coerce falsey/NaN values to 0. + end >>>= 0; + start >>>= 0; + + if (end <= start) { + return ""; + } + + if (!encoding) encoding = "utf8"; + + while (true) { + switch (encoding) { + case "hex": + return hexSlice(this, start, end); + + case "utf8": + case "utf-8": + return utf8Slice(this, start, end); + + case "ascii": + return asciiSlice(this, start, end); + + case "latin1": + case "binary": + return latin1Slice(this, start, end); + + case "base64": + return base64Slice(this, start, end); + + case "ucs2": + case "ucs-2": + case "utf16le": + case "utf-16le": + return utf16leSlice(this, start, end); + + default: + if (loweredCase) throw new TypeError("Unknown encoding: " + encoding); + encoding = (encoding + "").toLowerCase(); + loweredCase = true; + } + } } -export function transcode(buf, from, to) { - throw new Error("Not implemented"); +// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) +// to detect a Buffer instance. It's not possible to use `instanceof Buffer` +// reliably in a browserify context because there could be multiple different +// copies of the 'buffer' package in use. This method works even for Buffer +// instances that were created from another copy of the `buffer` package. +// See: https://github.com/feross/buffer/issues/154 +Buffer.prototype._isBuffer = true; + +function swap(b, n, m) { + const i = b[n]; + b[n] = b[m]; + b[m] = i; } + +Buffer.prototype.swap16 = function swap16() { + const len = this.length; + if (len % 2 !== 0) { + throw new RangeError("Buffer size must be a multiple of 16-bits"); + } + for (let i = 0; i < len; i += 2) { + swap(this, i, i + 1); + } + return this; +}; + +Buffer.prototype.swap32 = function swap32() { + const len = this.length; + if (len % 4 !== 0) { + throw new RangeError("Buffer size must be a multiple of 32-bits"); + } + for (let i = 0; i < len; i += 4) { + swap(this, i, i + 3); + swap(this, i + 1, i + 2); + } + return this; +}; + +Buffer.prototype.swap64 = function swap64() { + const len = this.length; + if (len % 8 !== 0) { + throw new RangeError("Buffer size must be a multiple of 64-bits"); + } + for (let i = 0; i < len; i += 8) { + swap(this, i, i + 7); + swap(this, i + 1, i + 6); + swap(this, i + 2, i + 5); + swap(this, i + 3, i + 4); + } + return this; +}; + +Buffer.prototype.toString = function toString() { + const length = this.length; + if (length === 0) return ""; + if (arguments.length === 0) return utf8Slice(this, 0, length); + return slowToString.apply(this, arguments); +}; + +Buffer.prototype.toLocaleString = Buffer.prototype.toString; + +Buffer.prototype.equals = function equals(b) { + if (!Buffer.isBuffer(b)) throw new TypeError("Argument must be a Buffer"); + if (this === b) return true; + return Buffer.compare(this, b) === 0; +}; + +Buffer.prototype.inspect = function inspect() { + let str = ""; + const max = exports.INSPECT_MAX_BYTES; + str = this.toString("hex", 0, max) + .replace(/(.{2})/g, "$1 ") + .trim(); + if (this.length > max) str += " ... "; + return ""; +}; +if (customInspectSymbol) { + Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect; +} + +Buffer.prototype.compare = function compare(target, start, end, thisStart, thisEnd) { + if (isInstance(target, Uint8Array)) { + target = Buffer.from(target, target.offset, target.byteLength); + } + if (!Buffer.isBuffer(target)) { + throw new TypeError( + 'The "target" argument must be one of type Buffer or Uint8Array. ' + "Received type " + typeof target, + ); + } + + if (start === undefined) { + start = 0; + } + if (end === undefined) { + end = target ? target.length : 0; + } + if (thisStart === undefined) { + thisStart = 0; + } + if (thisEnd === undefined) { + thisEnd = this.length; + } + + if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { + throw new RangeError("out of range index"); + } + + if (thisStart >= thisEnd && start >= end) { + return 0; + } + if (thisStart >= thisEnd) { + return -1; + } + if (start >= end) { + return 1; + } + + start >>>= 0; + end >>>= 0; + thisStart >>>= 0; + thisEnd >>>= 0; + + if (this === target) return 0; + + let x = thisEnd - thisStart; + let y = end - start; + const len = Math.min(x, y); + + const thisCopy = this.slice(thisStart, thisEnd); + const targetCopy = target.slice(start, end); + + for (let i = 0; i < len; ++i) { + if (thisCopy[i] !== targetCopy[i]) { + x = thisCopy[i]; + y = targetCopy[i]; + break; + } + } + + if (x < y) return -1; + if (y < x) return 1; + return 0; +}; + +// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, +// OR the last index of `val` in `buffer` at offset <= `byteOffset`. +// +// Arguments: +// - buffer - a Buffer to search +// - val - a string, Buffer, or number +// - byteOffset - an index into `buffer`; will be clamped to an int32 +// - encoding - an optional encoding, relevant is val is a string +// - dir - true for indexOf, false for lastIndexOf +function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) { + // Empty buffer means no match + if (buffer.length === 0) return -1; + + // Normalize byteOffset + if (typeof byteOffset === "string") { + encoding = byteOffset; + byteOffset = 0; + } else if (byteOffset > 0x7fffffff) { + byteOffset = 0x7fffffff; + } else if (byteOffset < -0x80000000) { + byteOffset = -0x80000000; + } + byteOffset = +byteOffset; // Coerce to Number. + if (Number.isNaN(byteOffset)) { + // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer + byteOffset = dir ? 0 : buffer.length - 1; + } + + // Normalize byteOffset: negative offsets start from the end of the buffer + if (byteOffset < 0) byteOffset = buffer.length + byteOffset; + if (byteOffset >= buffer.length) { + if (dir) return -1; + else byteOffset = buffer.length - 1; + } else if (byteOffset < 0) { + if (dir) byteOffset = 0; + else return -1; + } + + // Normalize val + if (typeof val === "string") { + val = Buffer.from(val, encoding); + } + + // Finally, search either indexOf (if dir is true) or lastIndexOf + if (Buffer.isBuffer(val)) { + // Special case: looking for empty string/buffer always fails + if (val.length === 0) { + return -1; + } + return arrayIndexOf(buffer, val, byteOffset, encoding, dir); + } else if (typeof val === "number") { + val = val & 0xff; // Search for a byte value [0-255] + if (typeof Uint8Array.prototype.indexOf === "function") { + if (dir) { + return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset); + } else { + return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset); + } + } + return arrayIndexOf(buffer, [val], byteOffset, encoding, dir); + } + + throw new TypeError("val must be string, number or Buffer"); +} + +function arrayIndexOf(arr, val, byteOffset, encoding, dir) { + let indexSize = 1; + let arrLength = arr.length; + let valLength = val.length; + + if (encoding !== undefined) { + encoding = String(encoding).toLowerCase(); + if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") { + if (arr.length < 2 || val.length < 2) { + return -1; + } + indexSize = 2; + arrLength /= 2; + valLength /= 2; + byteOffset /= 2; + } + } + + function read(buf, i) { + if (indexSize === 1) { + return buf[i]; + } else { + return buf.readUInt16BE(i * indexSize); + } + } + + let i; + if (dir) { + let foundIndex = -1; + for (i = byteOffset; i < arrLength; i++) { + if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { + if (foundIndex === -1) foundIndex = i; + if (i - foundIndex + 1 === valLength) return foundIndex * indexSize; + } else { + if (foundIndex !== -1) i -= i - foundIndex; + foundIndex = -1; + } + } + } else { + if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength; + for (i = byteOffset; i >= 0; i--) { + let found = true; + for (let j = 0; j < valLength; j++) { + if (read(arr, i + j) !== read(val, j)) { + found = false; + break; + } + } + if (found) return i; + } + } + + return -1; +} + +Buffer.prototype.includes = function includes(val, byteOffset, encoding) { + return this.indexOf(val, byteOffset, encoding) !== -1; +}; + +Buffer.prototype.indexOf = function indexOf(val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, true); +}; + +Buffer.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, false); +}; + +function hexWrite(buf, string, offset, length) { + offset = Number(offset) || 0; + const remaining = buf.length - offset; + if (!length) { + length = remaining; + } else { + length = Number(length); + if (length > remaining) { + length = remaining; + } + } + + const strLen = string.length; + + if (length > strLen / 2) { + length = strLen / 2; + } + let i; + for (i = 0; i < length; ++i) { + const parsed = parseInt(string.substr(i * 2, 2), 16); + if (numberIsNaN(parsed)) return i; + buf[offset + i] = parsed; + } + return i; +} + +function utf8Write(buf, string, offset, length) { + return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length); +} + +function asciiWrite(buf, string, offset, length) { + return blitBuffer(asciiToBytes(string), buf, offset, length); +} + +function base64Write(buf, string, offset, length) { + return blitBuffer(base64ToBytes(string), buf, offset, length); +} + +function ucs2Write(buf, string, offset, length) { + return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length); +} + +Buffer.prototype.write = function write(string, offset, length, encoding) { + // Buffer#write(string) + if (offset === undefined) { + encoding = "utf8"; + length = this.length; + offset = 0; + // Buffer#write(string, encoding) + } else if (length === undefined && typeof offset === "string") { + encoding = offset; + length = this.length; + offset = 0; + // Buffer#write(string, offset[, length][, encoding]) + } else if (isFinite(offset)) { + offset = offset >>> 0; + if (isFinite(length)) { + length = length >>> 0; + if (encoding === undefined) encoding = "utf8"; + } else { + encoding = length; + length = undefined; + } + } else { + throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported"); + } + + const remaining = this.length - offset; + if (length === undefined || length > remaining) length = remaining; + + if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { + throw new RangeError("Attempt to write outside buffer bounds"); + } + + if (!encoding) encoding = "utf8"; + + let loweredCase = false; + for (;;) { + switch (encoding) { + case "hex": + return hexWrite(this, string, offset, length); + + case "utf8": + case "utf-8": + return utf8Write(this, string, offset, length); + + case "ascii": + case "latin1": + case "binary": + return asciiWrite(this, string, offset, length); + + case "base64": + // Warning: maxLength not taken into account in base64Write + return base64Write(this, string, offset, length); + + case "ucs2": + case "ucs-2": + case "utf16le": + case "utf-16le": + return ucs2Write(this, string, offset, length); + + default: + if (loweredCase) throw new TypeError("Unknown encoding: " + encoding); + encoding = ("" + encoding).toLowerCase(); + loweredCase = true; + } + } +}; + +Buffer.prototype.toJSON = function toJSON() { + return { + type: "Buffer", + data: Array.prototype.slice.call(this._arr || this, 0), + }; +}; + +function base64Slice(buf, start, end) { + if (start === 0 && end === buf.length) { + return base64.fromByteArray(buf); + } else { + return base64.fromByteArray(buf.slice(start, end)); + } +} + +function utf8Slice(buf, start, end) { + end = Math.min(buf.length, end); + const res = []; + + let i = start; + while (i < end) { + const firstByte = buf[i]; + let codePoint = null; + let bytesPerSequence = firstByte > 0xef ? 4 : firstByte > 0xdf ? 3 : firstByte > 0xbf ? 2 : 1; + + if (i + bytesPerSequence <= end) { + let secondByte, thirdByte, fourthByte, tempCodePoint; + + switch (bytesPerSequence) { + case 1: + if (firstByte < 0x80) { + codePoint = firstByte; + } + break; + case 2: + secondByte = buf[i + 1]; + if ((secondByte & 0xc0) === 0x80) { + tempCodePoint = ((firstByte & 0x1f) << 0x6) | (secondByte & 0x3f); + if (tempCodePoint > 0x7f) { + codePoint = tempCodePoint; + } + } + break; + case 3: + secondByte = buf[i + 1]; + thirdByte = buf[i + 2]; + if ((secondByte & 0xc0) === 0x80 && (thirdByte & 0xc0) === 0x80) { + tempCodePoint = ((firstByte & 0xf) << 0xc) | ((secondByte & 0x3f) << 0x6) | (thirdByte & 0x3f); + if (tempCodePoint > 0x7ff && (tempCodePoint < 0xd800 || tempCodePoint > 0xdfff)) { + codePoint = tempCodePoint; + } + } + break; + case 4: + secondByte = buf[i + 1]; + thirdByte = buf[i + 2]; + fourthByte = buf[i + 3]; + if ((secondByte & 0xc0) === 0x80 && (thirdByte & 0xc0) === 0x80 && (fourthByte & 0xc0) === 0x80) { + tempCodePoint = + ((firstByte & 0xf) << 0x12) | + ((secondByte & 0x3f) << 0xc) | + ((thirdByte & 0x3f) << 0x6) | + (fourthByte & 0x3f); + if (tempCodePoint > 0xffff && tempCodePoint < 0x110000) { + codePoint = tempCodePoint; + } + } + } + } + + if (codePoint === null) { + // we did not generate a valid codePoint so insert a + // replacement char (U+FFFD) and advance only 1 byte + codePoint = 0xfffd; + bytesPerSequence = 1; + } else if (codePoint > 0xffff) { + // encode to utf16 (surrogate pair dance) + codePoint -= 0x10000; + res.push(((codePoint >>> 10) & 0x3ff) | 0xd800); + codePoint = 0xdc00 | (codePoint & 0x3ff); + } + + res.push(codePoint); + i += bytesPerSequence; + } + + return decodeCodePointsArray(res); +} + +// Based on http://stackoverflow.com/a/22747272/680742, the browser with +// the lowest limit is Chrome, with 0x10000 args. +// We go 1 magnitude less, for safety +const MAX_ARGUMENTS_LENGTH = 0x1000; + +function decodeCodePointsArray(codePoints) { + const len = codePoints.length; + if (len <= MAX_ARGUMENTS_LENGTH) { + return String.fromCharCode.apply(String, codePoints); // avoid extra slice() + } + + // Decode in chunks to avoid "call stack size exceeded". + let res = ""; + let i = 0; + while (i < len) { + res += String.fromCharCode.apply(String, codePoints.slice(i, (i += MAX_ARGUMENTS_LENGTH))); + } + return res; +} + +function asciiSlice(buf, start, end) { + let ret = ""; + end = Math.min(buf.length, end); + + for (let i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i] & 0x7f); + } + return ret; +} + +function latin1Slice(buf, start, end) { + let ret = ""; + end = Math.min(buf.length, end); + + for (let i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i]); + } + return ret; +} + +function hexSlice(buf, start, end) { + const len = buf.length; + + if (!start || start < 0) start = 0; + if (!end || end < 0 || end > len) end = len; + + let out = ""; + for (let i = start; i < end; ++i) { + out += hexSliceLookupTable[buf[i]]; + } + return out; +} + +function utf16leSlice(buf, start, end) { + const bytes = buf.slice(start, end); + let res = ""; + // If bytes.length is odd, the last 8 bits must be ignored (same as node.js) + for (let i = 0; i < bytes.length - 1; i += 2) { + res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256); + } + return res; +} + +Buffer.prototype.slice = function slice(start, end) { + const len = this.length; + start = ~~start; + end = end === undefined ? len : ~~end; + + if (start < 0) { + start += len; + if (start < 0) start = 0; + } else if (start > len) { + start = len; + } + + if (end < 0) { + end += len; + if (end < 0) end = 0; + } else if (end > len) { + end = len; + } + + if (end < start) end = start; + + const newBuf = this.subarray(start, end); + // Return an augmented `Uint8Array` instance + Object.setPrototypeOf(newBuf, Buffer.prototype); + + return newBuf; +}; + +/* + * Need to make sure that buffer isn't trying to write out of bounds. + */ +function checkOffset(offset, ext, length) { + if (offset % 1 !== 0 || offset < 0) throw new RangeError("offset is not uint"); + if (offset + ext > length) throw new RangeError("Trying to access beyond buffer length"); +} + +Buffer.prototype.readUintLE = Buffer.prototype.readUIntLE = function readUIntLE(offset, byteLength, noAssert) { + offset = offset >>> 0; + byteLength = byteLength >>> 0; + if (!noAssert) checkOffset(offset, byteLength, this.length); + + let val = this[offset]; + let mul = 1; + let i = 0; + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul; + } + + return val; +}; + +Buffer.prototype.readUintBE = Buffer.prototype.readUIntBE = function readUIntBE(offset, byteLength, noAssert) { + offset = offset >>> 0; + byteLength = byteLength >>> 0; + if (!noAssert) { + checkOffset(offset, byteLength, this.length); + } + + let val = this[offset + --byteLength]; + let mul = 1; + while (byteLength > 0 && (mul *= 0x100)) { + val += this[offset + --byteLength] * mul; + } + + return val; +}; + +Buffer.prototype.readUint8 = Buffer.prototype.readUInt8 = function readUInt8(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 1, this.length); + return this[offset]; +}; + +Buffer.prototype.readUint16LE = Buffer.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 2, this.length); + return this[offset] | (this[offset + 1] << 8); +}; + +Buffer.prototype.readUint16BE = Buffer.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 2, this.length); + return (this[offset] << 8) | this[offset + 1]; +}; + +Buffer.prototype.readUint32LE = Buffer.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 4, this.length); + + return (this[offset] | (this[offset + 1] << 8) | (this[offset + 2] << 16)) + this[offset + 3] * 0x1000000; +}; + +Buffer.prototype.readUint32BE = Buffer.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 4, this.length); + + return this[offset] * 0x1000000 + ((this[offset + 1] << 16) | (this[offset + 2] << 8) | this[offset + 3]); +}; + +Buffer.prototype.readBigUInt64LE = /* @__PURE */ defineBigIntMethod(function readBigUInt64LE(offset) { + offset = offset >>> 0; + validateNumber(offset, "offset"); + const first = this[offset]; + const last = this[offset + 7]; + if (first === undefined || last === undefined) { + boundsError(offset, this.length - 8); + } + + const lo = first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24; + + const hi = this[++offset] + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + last * 2 ** 24; + + return BigInt(lo) + (BigInt(hi) << BigInt(32)); +}); + +Buffer.prototype.readBigUInt64BE = /* @__PURE */ defineBigIntMethod(function readBigUInt64BE(offset) { + offset = offset >>> 0; + validateNumber(offset, "offset"); + const first = this[offset]; + const last = this[offset + 7]; + if (first === undefined || last === undefined) { + boundsError(offset, this.length - 8); + } + + const hi = first * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset]; + + const lo = this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last; + + return (BigInt(hi) << BigInt(32)) + BigInt(lo); +}); + +Buffer.prototype.readIntLE = function readIntLE(offset, byteLength, noAssert) { + offset = offset >>> 0; + byteLength = byteLength >>> 0; + if (!noAssert) checkOffset(offset, byteLength, this.length); + + let val = this[offset]; + let mul = 1; + let i = 0; + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul; + } + mul *= 0x80; + + if (val >= mul) val -= Math.pow(2, 8 * byteLength); + + return val; +}; + +Buffer.prototype.readIntBE = function readIntBE(offset, byteLength, noAssert) { + offset = offset >>> 0; + byteLength = byteLength >>> 0; + if (!noAssert) checkOffset(offset, byteLength, this.length); + + let i = byteLength; + let mul = 1; + let val = this[offset + --i]; + while (i > 0 && (mul *= 0x100)) { + val += this[offset + --i] * mul; + } + mul *= 0x80; + + if (val >= mul) val -= Math.pow(2, 8 * byteLength); + + return val; +}; + +Buffer.prototype.readInt8 = function readInt8(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 1, this.length); + if (!(this[offset] & 0x80)) return this[offset]; + return (0xff - this[offset] + 1) * -1; +}; + +Buffer.prototype.readInt16LE = function readInt16LE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 2, this.length); + const val = this[offset] | (this[offset + 1] << 8); + return val & 0x8000 ? val | 0xffff0000 : val; +}; + +Buffer.prototype.readInt16BE = function readInt16BE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 2, this.length); + const val = this[offset + 1] | (this[offset] << 8); + return val & 0x8000 ? val | 0xffff0000 : val; +}; + +Buffer.prototype.readInt32LE = function readInt32LE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 4, this.length); + + return this[offset] | (this[offset + 1] << 8) | (this[offset + 2] << 16) | (this[offset + 3] << 24); +}; + +Buffer.prototype.readInt32BE = function readInt32BE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 4, this.length); + + return (this[offset] << 24) | (this[offset + 1] << 16) | (this[offset + 2] << 8) | this[offset + 3]; +}; + +Buffer.prototype.readBigInt64LE = /* @__PURE */ defineBigIntMethod(function readBigInt64LE(offset) { + offset = offset >>> 0; + validateNumber(offset, "offset"); + const first = this[offset]; + const last = this[offset + 7]; + if (first === undefined || last === undefined) { + boundsError(offset, this.length - 8); + } + + const val = this[offset + 4] + this[offset + 5] * 2 ** 8 + this[offset + 6] * 2 ** 16 + (last << 24); // Overflow + + return ( + (BigInt(val) << BigInt(32)) + + BigInt(first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24) + ); +}); + +Buffer.prototype.readBigInt64BE = /* @__PURE */ defineBigIntMethod(function readBigInt64BE(offset) { + offset = offset >>> 0; + validateNumber(offset, "offset"); + const first = this[offset]; + const last = this[offset + 7]; + if (first === undefined || last === undefined) { + boundsError(offset, this.length - 8); + } + + const val = + (first << 24) + // Overflow + this[++offset] * 2 ** 16 + + this[++offset] * 2 ** 8 + + this[++offset]; + + return ( + (BigInt(val) << BigInt(32)) + + BigInt(this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last) + ); +}); + +Buffer.prototype.readFloatLE = function readFloatLE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 4, this.length); + return ieee754.read(this, offset, true, 23, 4); +}; + +Buffer.prototype.readFloatBE = function readFloatBE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 4, this.length); + return ieee754.read(this, offset, false, 23, 4); +}; + +Buffer.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 8, this.length); + return ieee754.read(this, offset, true, 52, 8); +}; + +Buffer.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 8, this.length); + return ieee754.read(this, offset, false, 52, 8); +}; + +function checkInt(buf, value, offset, ext, max, min) { + if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance'); + if (value > max || value < min) throw new RangeError('"value" argument is out of bounds'); + if (offset + ext > buf.length) throw new RangeError("Index out of range"); +} + +Buffer.prototype.writeUintLE = Buffer.prototype.writeUIntLE = function writeUIntLE( + value, + offset, + byteLength, + noAssert, +) { + value = +value; + offset = offset >>> 0; + byteLength = byteLength >>> 0; + if (!noAssert) { + const maxBytes = Math.pow(2, 8 * byteLength) - 1; + checkInt(this, value, offset, byteLength, maxBytes, 0); + } + + let mul = 1; + let i = 0; + this[offset] = value & 0xff; + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xff; + } + + return offset + byteLength; +}; + +Buffer.prototype.writeUintBE = Buffer.prototype.writeUIntBE = function writeUIntBE( + value, + offset, + byteLength, + noAssert, +) { + value = +value; + offset = offset >>> 0; + byteLength = byteLength >>> 0; + if (!noAssert) { + const maxBytes = Math.pow(2, 8 * byteLength) - 1; + checkInt(this, value, offset, byteLength, maxBytes, 0); + } + + let i = byteLength - 1; + let mul = 1; + this[offset + i] = value & 0xff; + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xff; + } + + return offset + byteLength; +}; + +Buffer.prototype.writeUint8 = Buffer.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0); + this[offset] = value & 0xff; + return offset + 1; +}; + +Buffer.prototype.writeUint16LE = Buffer.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0); + this[offset] = value & 0xff; + this[offset + 1] = value >>> 8; + return offset + 2; +}; + +Buffer.prototype.writeUint16BE = Buffer.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0); + this[offset] = value >>> 8; + this[offset + 1] = value & 0xff; + return offset + 2; +}; + +Buffer.prototype.writeUint32LE = Buffer.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0); + this[offset + 3] = value >>> 24; + this[offset + 2] = value >>> 16; + this[offset + 1] = value >>> 8; + this[offset] = value & 0xff; + return offset + 4; +}; + +Buffer.prototype.writeUint32BE = Buffer.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0); + this[offset] = value >>> 24; + this[offset + 1] = value >>> 16; + this[offset + 2] = value >>> 8; + this[offset + 3] = value & 0xff; + return offset + 4; +}; + +function wrtBigUInt64LE(buf, value, offset, min, max) { + checkIntBI(value, min, max, buf, offset, 7); + + let lo = Number(value & BigInt(0xffffffff)); + buf[offset++] = lo; + lo = lo >> 8; + buf[offset++] = lo; + lo = lo >> 8; + buf[offset++] = lo; + lo = lo >> 8; + buf[offset++] = lo; + let hi = Number((value >> BigInt(32)) & BigInt(0xffffffff)); + buf[offset++] = hi; + hi = hi >> 8; + buf[offset++] = hi; + hi = hi >> 8; + buf[offset++] = hi; + hi = hi >> 8; + buf[offset++] = hi; + return offset; +} + +function wrtBigUInt64BE(buf, value, offset, min, max) { + checkIntBI(value, min, max, buf, offset, 7); + + let lo = Number(value & BigInt(0xffffffff)); + buf[offset + 7] = lo; + lo = lo >> 8; + buf[offset + 6] = lo; + lo = lo >> 8; + buf[offset + 5] = lo; + lo = lo >> 8; + buf[offset + 4] = lo; + let hi = Number((value >> BigInt(32)) & BigInt(0xffffffff)); + buf[offset + 3] = hi; + hi = hi >> 8; + buf[offset + 2] = hi; + hi = hi >> 8; + buf[offset + 1] = hi; + hi = hi >> 8; + buf[offset] = hi; + return offset + 8; +} + +Buffer.prototype.writeBigUInt64LE = /* @__PURE */ defineBigIntMethod(function writeBigUInt64LE(value, offset = 0) { + return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff")); +}); + +Buffer.prototype.writeBigUInt64BE = /* @__PURE */ defineBigIntMethod(function writeBigUInt64BE(value, offset = 0) { + return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff")); +}); + +Buffer.prototype.writeIntLE = function writeIntLE(value, offset, byteLength, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) { + const limit = Math.pow(2, 8 * byteLength - 1); + + checkInt(this, value, offset, byteLength, limit - 1, -limit); + } + + let i = 0; + let mul = 1; + let sub = 0; + this[offset] = value & 0xff; + while (++i < byteLength && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { + sub = 1; + } + this[offset + i] = (((value / mul) >> 0) - sub) & 0xff; + } + + return offset + byteLength; +}; + +Buffer.prototype.writeIntBE = function writeIntBE(value, offset, byteLength, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) { + const limit = Math.pow(2, 8 * byteLength - 1); + + checkInt(this, value, offset, byteLength, limit - 1, -limit); + } + + let i = byteLength - 1; + let mul = 1; + let sub = 0; + this[offset + i] = value & 0xff; + while (--i >= 0 && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { + sub = 1; + } + this[offset + i] = (((value / mul) >> 0) - sub) & 0xff; + } + + return offset + byteLength; +}; + +Buffer.prototype.writeInt8 = function writeInt8(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80); + if (value < 0) value = 0xff + value + 1; + this[offset] = value & 0xff; + return offset + 1; +}; + +Buffer.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000); + this[offset] = value & 0xff; + this[offset + 1] = value >>> 8; + return offset + 2; +}; + +Buffer.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000); + this[offset] = value >>> 8; + this[offset + 1] = value & 0xff; + return offset + 2; +}; + +Buffer.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000); + this[offset] = value & 0xff; + this[offset + 1] = value >>> 8; + this[offset + 2] = value >>> 16; + this[offset + 3] = value >>> 24; + return offset + 4; +}; + +Buffer.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000); + if (value < 0) value = 0xffffffff + value + 1; + this[offset] = value >>> 24; + this[offset + 1] = value >>> 16; + this[offset + 2] = value >>> 8; + this[offset + 3] = value & 0xff; + return offset + 4; +}; + +Buffer.prototype.writeBigInt64LE = /* @__PURE */ defineBigIntMethod(function writeBigInt64LE(value, offset = 0) { + return wrtBigUInt64LE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff")); +}); + +Buffer.prototype.writeBigInt64BE = /* @__PURE */ defineBigIntMethod(function writeBigInt64BE(value, offset = 0) { + return wrtBigUInt64BE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff")); +}); + +function checkIEEE754(buf, value, offset, ext, max, min) { + if (offset + ext > buf.length) throw new RangeError("Index out of range"); + if (offset < 0) throw new RangeError("Index out of range"); +} + +function writeFloat(buf, value, offset, littleEndian, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) { + checkIEEE754(buf, value, offset, 4, 3.4028234663852886e38, -3.4028234663852886e38); + } + ieee754.write(buf, value, offset, littleEndian, 23, 4); + return offset + 4; +} + +Buffer.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) { + return writeFloat(this, value, offset, true, noAssert); +}; + +Buffer.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) { + return writeFloat(this, value, offset, false, noAssert); +}; + +function writeDouble(buf, value, offset, littleEndian, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) { + checkIEEE754(buf, value, offset, 8, 1.7976931348623157e308, -1.7976931348623157e308); + } + ieee754.write(buf, value, offset, littleEndian, 52, 8); + return offset + 8; +} + +Buffer.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) { + return writeDouble(this, value, offset, true, noAssert); +}; + +Buffer.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) { + return writeDouble(this, value, offset, false, noAssert); +}; + +// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) +Buffer.prototype.copy = function copy(target, targetStart, start, end) { + if (!Buffer.isBuffer(target)) throw new TypeError("argument should be a Buffer"); + if (!start) start = 0; + if (!end && end !== 0) end = this.length; + if (targetStart >= target.length) targetStart = target.length; + if (!targetStart) targetStart = 0; + if (end > 0 && end < start) end = start; + + // Copy 0 bytes; we're done + if (end === start) return 0; + if (target.length === 0 || this.length === 0) return 0; + + // Fatal error conditions + if (targetStart < 0) { + throw new RangeError("targetStart out of bounds"); + } + if (start < 0 || start >= this.length) throw new RangeError("Index out of range"); + if (end < 0) throw new RangeError("sourceEnd out of bounds"); + + // Are we oob? + if (end > this.length) end = this.length; + if (target.length - targetStart < end - start) { + end = target.length - targetStart + start; + } + + const len = end - start; + + if (this === target && typeof Uint8Array.prototype.copyWithin === "function") { + // Use built-in when available, missing from IE11 + this.copyWithin(targetStart, start, end); + } else { + Uint8Array.prototype.set.call(target, this.subarray(start, end), targetStart); + } + + return len; +}; + +// Usage: +// buffer.fill(number[, offset[, end]]) +// buffer.fill(buffer[, offset[, end]]) +// buffer.fill(string[, offset[, end]][, encoding]) +Buffer.prototype.fill = function fill(val, start, end, encoding) { + // Handle string cases: + if (typeof val === "string") { + if (typeof start === "string") { + encoding = start; + start = 0; + end = this.length; + } else if (typeof end === "string") { + encoding = end; + end = this.length; + } + if (encoding !== undefined && typeof encoding !== "string") { + throw new TypeError("encoding must be a string"); + } + if (typeof encoding === "string" && !Buffer.isEncoding(encoding)) { + throw new TypeError("Unknown encoding: " + encoding); + } + if (val.length === 1) { + const code = val.charCodeAt(0); + if ((encoding === "utf8" && code < 128) || encoding === "latin1") { + // Fast path: If `val` fits into a single byte, use that numeric value. + val = code; + } + } + } else if (typeof val === "number") { + val = val & 255; + } else if (typeof val === "boolean") { + val = Number(val); + } + + // Invalid ranges are not set to a default, so can range check early. + if (start < 0 || this.length < start || this.length < end) { + throw new RangeError("Out of range index"); + } + + if (end <= start) { + return this; + } + + start = start >>> 0; + end = end === undefined ? this.length : end >>> 0; + + if (!val) val = 0; + + let i; + if (typeof val === "number") { + for (i = start; i < end; ++i) { + this[i] = val; + } + } else { + const bytes = Buffer.isBuffer(val) ? val : Buffer.from(val, encoding); + const len = bytes.length; + if (len === 0) { + throw new TypeError('The value "' + val + '" is invalid for argument "value"'); + } + for (i = 0; i < end - start; ++i) { + this[i + start] = bytes[i % len]; + } + } + + return this; +}; + +function addNumericalSeparator(val) { + let res = ""; + let i = val.length; + const start = val[0] === "-" ? 1 : 0; + for (; i >= start + 4; i -= 3) { + res = `_${val.slice(i - 3, i)}${res}`; + } + return `${val.slice(0, i)}${res}`; +} + +// CHECK FUNCTIONS +// =============== + +function checkBounds(buf, offset, byteLength) { + validateNumber(offset, "offset"); + if (buf[offset] === undefined || buf[offset + byteLength] === undefined) { + boundsError(offset, buf.length - (byteLength + 1)); + } +} + +function checkIntBI(value, min, max, buf, offset, byteLength) { + if (value > max || value < min) { + const n = typeof min === "bigint" ? "n" : ""; + let range; + if (byteLength > 3) { + if (min === 0 || min === BigInt(0)) { + range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`; + } else { + range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` + `${(byteLength + 1) * 8 - 1}${n}`; + } + } else { + range = `>= ${min}${n} and <= ${max}${n}`; + } + throw new ERR_OUT_OF_RANGE("value", range, value); + } + checkBounds(buf, offset, byteLength); +} + +function validateNumber(value, name) { + if (typeof value !== "number") { + throw new ERR_INVALID_ARG_TYPE(name, "number", value); + } +} + +function boundsError(value, length, type) { + if (Math.floor(value) !== value) { + validateNumber(value, type); + throw new ERR_OUT_OF_RANGE(type || "offset", "an integer", value); + } + + if (length < 0) { + throw new ERR_BUFFER_OUT_OF_BOUNDS(); + } + + throw new ERR_OUT_OF_RANGE(type || "offset", `>= ${type ? 1 : 0} and <= ${length}`, value); +} + +// HELPER FUNCTIONS +// ================ + +const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g; + +function base64clean(str) { + // Node takes equal signs as end of the Base64 encoding + str = str.split("=")[0]; + // Node strips out invalid characters like \n and \t from the string, base64-js does not + str = str.trim().replace(INVALID_BASE64_RE, ""); + // Node converts strings with length < 2 to '' + if (str.length < 2) return ""; + // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not + while (str.length % 4 !== 0) { + str = str + "="; + } + return str; +} + +function utf8ToBytes(string, units) { + units = units || Infinity; + let codePoint; + const length = string.length; + let leadSurrogate = null; + const bytes = []; + + for (let i = 0; i < length; ++i) { + codePoint = string.charCodeAt(i); + + // is surrogate component + if (codePoint > 0xd7ff && codePoint < 0xe000) { + // last char was a lead + if (!leadSurrogate) { + // no lead yet + if (codePoint > 0xdbff) { + // unexpected trail + if ((units -= 3) > -1) bytes.push(0xef, 0xbf, 0xbd); + continue; + } else if (i + 1 === length) { + // unpaired lead + if ((units -= 3) > -1) bytes.push(0xef, 0xbf, 0xbd); + continue; + } + + // valid lead + leadSurrogate = codePoint; + + continue; + } + + // 2 leads in a row + if (codePoint < 0xdc00) { + if ((units -= 3) > -1) bytes.push(0xef, 0xbf, 0xbd); + leadSurrogate = codePoint; + continue; + } + + // valid surrogate pair + codePoint = (((leadSurrogate - 0xd800) << 10) | (codePoint - 0xdc00)) + 0x10000; + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead + if ((units -= 3) > -1) bytes.push(0xef, 0xbf, 0xbd); + } + + leadSurrogate = null; + + // encode utf8 + if (codePoint < 0x80) { + if ((units -= 1) < 0) break; + bytes.push(codePoint); + } else if (codePoint < 0x800) { + if ((units -= 2) < 0) break; + bytes.push((codePoint >> 0x6) | 0xc0, (codePoint & 0x3f) | 0x80); + } else if (codePoint < 0x10000) { + if ((units -= 3) < 0) break; + bytes.push((codePoint >> 0xc) | 0xe0, ((codePoint >> 0x6) & 0x3f) | 0x80, (codePoint & 0x3f) | 0x80); + } else if (codePoint < 0x110000) { + if ((units -= 4) < 0) break; + bytes.push( + (codePoint >> 0x12) | 0xf0, + ((codePoint >> 0xc) & 0x3f) | 0x80, + ((codePoint >> 0x6) & 0x3f) | 0x80, + (codePoint & 0x3f) | 0x80, + ); + } else { + throw new Error("Invalid code point"); + } + } + + return bytes; +} + +function asciiToBytes(str) { + const byteArray = []; + for (let i = 0; i < str.length; ++i) { + // Node's code seems to be doing this and not & 0x7F.. + byteArray.push(str.charCodeAt(i) & 0xff); + } + return byteArray; +} + +function utf16leToBytes(str, units) { + let c, hi, lo; + const byteArray = []; + for (let i = 0; i < str.length; ++i) { + if ((units -= 2) < 0) break; + + c = str.charCodeAt(i); + hi = c >> 8; + lo = c % 256; + byteArray.push(lo); + byteArray.push(hi); + } + + return byteArray; +} + +function base64ToBytes(str) { + return base64.toByteArray(base64clean(str)); +} + +function blitBuffer(src, dst, offset, length) { + let i; + for (i = 0; i < length; ++i) { + if (i + offset >= dst.length || i >= src.length) break; + dst[i + offset] = src[i]; + } + return i; +} + +// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass +// the `instanceof` check but they should be treated as of that type. +// See: https://github.com/feross/buffer/issues/166 +function isInstance(obj, type) { + return ( + obj instanceof type || + (obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type.name) + ); +} + +// Create lookup table for `toString('hex')` +// See: https://github.com/feross/buffer/issues/219 +const hexSliceLookupTable = (function () { + const alphabet = "0123456789abcdef"; + const table = new Array(256); + for (let i = 0; i < 16; ++i) { + const i16 = i * 16; + for (let j = 0; j < 16; ++j) { + table[i16 + j] = alphabet[i] + alphabet[j]; + } + } + return table; +})(); + +// Return not function with Error if BigInt not supported +function defineBigIntMethod(fn) { + return typeof BigInt === "undefined" ? BufferBigIntNotDefined : fn; +} + +function BufferBigIntNotDefined() { + throw new Error("BigInt not supported"); +} + +function notimpl(name) { + return () => { + throw new Error(name + " is not implemented for node:buffer browser polyfill"); + }; +} + +export let resolveObjectURL = notimpl("resolveObjectURL"); +export let isUtf8 = notimpl("isUtf8"); +export let isAscii = str => { + for (let char of str) { + if (char.charCodeAt(0) > 127) { + return false; + } + } + return true; +}; +export let transcode = notimpl("transcode"); +export default Buffer; diff --git a/src/node-fallbacks/build-fallbacks.ts b/src/node-fallbacks/build-fallbacks.ts new file mode 100644 index 0000000000..dab8597b08 --- /dev/null +++ b/src/node-fallbacks/build-fallbacks.ts @@ -0,0 +1,60 @@ +import * as fs from "fs"; +import * as Module from "module"; +import { basename, extname } from "path"; + +const allFiles = fs.readdirSync(".").filter(f => f.endsWith(".js")); +const outdir = process.argv[2]; +const builtins = Module.builtinModules; +let commands = []; + +let moduleFiles = []; +for (const name of allFiles) { + const mod = basename(name, extname(name)).replaceAll(".", "/"); + const file = allFiles.find(f => f.startsWith(mod)); + moduleFiles.push(file); +} + +for (let fileIndex = 0; fileIndex < allFiles.length; fileIndex++) { + const name = allFiles[fileIndex]; + const mod = basename(name, extname(name)).replaceAll(".", "/"); + const file = allFiles.find(f => f.startsWith(mod)); + const externals = [...builtins]; + const i = externals.indexOf(name); + if (i !== -1) { + externals.splice(i, 1); + } + + // Build all files at once with specific options + const externalModules = builtins + .concat(moduleFiles.filter(f => f !== name)) + .flatMap(b => [`--external:node:${b}`, `--external:${b}`]) + .join(" "); + + console.log(`bun build ${file} --minify-syntax ${externalModules}`); + // Create the build command with all the specified options + const buildCommand = + Bun.$`bun build --outdir=${outdir} ${name} --minify-syntax --format=esm --target=node ${{ raw: externalModules }}`.text(); + + commands.push( + buildCommand.then(async text => { + // This is very brittle. But that should be okay for our usecase + let outfile = (await Bun.file(`${outdir}/${name}`).text()) + .replaceAll("__require(", "require(") + .replace(/var __require.*$/gim, "") + .replaceAll("global.process", "require('process')") + .trim(); + + while (outfile.startsWith("import {")) { + outfile = outfile.slice(outfile.indexOf(";\n") + 1); + } + + if (text.includes("import ")) { + throw new Error("Unexpected import in " + name); + } + + await Bun.write(`${outdir}/${name}`, outfile); + }), + ); +} + +await Promise.all(commands); diff --git a/src/node-fallbacks/bun.lock b/src/node-fallbacks/bun.lock index 1730d5da2d..e33aa6042a 100644 --- a/src/node-fallbacks/bun.lock +++ b/src/node-fallbacks/bun.lock @@ -4,47 +4,98 @@ "": { "name": "fallbacks", "dependencies": { - "assert": "^2.0.0", + "assert": "^2.1.0", "browserify-zlib": "^0.2.0", "buffer": "^6.0.3", "console-browserify": "^1.2.0", "constants-browserify": "^1.0.0", - "crypto-browserify": "^3.12.0", - "domain-browser": "^4.22.0", - "esbuild": "^0.14.10", + "crypto-browserify": "^3.12.1", + "domain-browser": "^4.23.0", + "esbuild": "^0.25.4", "events": "^3.3.0", "https-browserify": "^1.0.0", "os-browserify": "^0.3.0", "path-browserify": "^1.0.1", "process": "^0.11.10", - "punycode": "^2.1.1", + "punycode": "^2.3.1", "querystring-es3": "^1.0.0-0", - "react-refresh": "^0.16.0", - "readable-stream": "^4.1.0", + "react-refresh": "0.17.0", + "readable-stream": "^4.5.2", "stream-http": "^3.2.0", "string_decoder": "^1.3.0", "timers-browserify": "^2.0.12", "tty-browserify": "^0.0.1", - "url": "^0.11.0", - "util": "^0.12.4", + "url": "^0.11.4", + "util": "^0.12.5", "vm-browserify": "^1.1.2", }, }, }, + "overrides": { + "readable-stream": "^4.5.2", + }, "packages": { - "@esbuild/linux-loong64": ["@esbuild/linux-loong64@0.14.54", "", { "os":"linux", "cpu":"none" }, "sha512-bZBrLAIX1kpWelV0XemxBZllyRmM6vgFQQG2GdNb+r3Fkp0FOh1NJSvekXDs7jq70k4euu1cryLMfU+mTXlEpw=="], + "@esbuild/aix-ppc64": ["@esbuild/aix-ppc64@0.25.4", "", { "os": "aix", "cpu": "ppc64" }, "sha512-1VCICWypeQKhVbE9oW/sJaAmjLxhVqacdkvPLEjwlttjfwENRSClS8EjBz0KzRyFSCPDIkuXW34Je/vk7zdB7Q=="], + + "@esbuild/android-arm": ["@esbuild/android-arm@0.25.4", "", { "os": "android", "cpu": "arm" }, "sha512-QNdQEps7DfFwE3hXiU4BZeOV68HHzYwGd0Nthhd3uCkkEKK7/R6MTgM0P7H7FAs5pU/DIWsviMmEGxEoxIZ+ZQ=="], + + "@esbuild/android-arm64": ["@esbuild/android-arm64@0.25.4", "", { "os": "android", "cpu": "arm64" }, "sha512-bBy69pgfhMGtCnwpC/x5QhfxAz/cBgQ9enbtwjf6V9lnPI/hMyT9iWpR1arm0l3kttTr4L0KSLpKmLp/ilKS9A=="], + + "@esbuild/android-x64": ["@esbuild/android-x64@0.25.4", "", { "os": "android", "cpu": "x64" }, "sha512-TVhdVtQIFuVpIIR282btcGC2oGQoSfZfmBdTip2anCaVYcqWlZXGcdcKIUklfX2wj0JklNYgz39OBqh2cqXvcQ=="], + + "@esbuild/darwin-arm64": ["@esbuild/darwin-arm64@0.25.4", "", { "os": "darwin", "cpu": "arm64" }, "sha512-Y1giCfM4nlHDWEfSckMzeWNdQS31BQGs9/rouw6Ub91tkK79aIMTH3q9xHvzH8d0wDru5Ci0kWB8b3up/nl16g=="], + + "@esbuild/darwin-x64": ["@esbuild/darwin-x64@0.25.4", "", { "os": "darwin", "cpu": "x64" }, "sha512-CJsry8ZGM5VFVeyUYB3cdKpd/H69PYez4eJh1W/t38vzutdjEjtP7hB6eLKBoOdxcAlCtEYHzQ/PJ/oU9I4u0A=="], + + "@esbuild/freebsd-arm64": ["@esbuild/freebsd-arm64@0.25.4", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-yYq+39NlTRzU2XmoPW4l5Ifpl9fqSk0nAJYM/V/WUGPEFfek1epLHJIkTQM6bBs1swApjO5nWgvr843g6TjxuQ=="], + + "@esbuild/freebsd-x64": ["@esbuild/freebsd-x64@0.25.4", "", { "os": "freebsd", "cpu": "x64" }, "sha512-0FgvOJ6UUMflsHSPLzdfDnnBBVoCDtBTVyn/MrWloUNvq/5SFmh13l3dvgRPkDihRxb77Y17MbqbCAa2strMQQ=="], + + "@esbuild/linux-arm": ["@esbuild/linux-arm@0.25.4", "", { "os": "linux", "cpu": "arm" }, "sha512-kro4c0P85GMfFYqW4TWOpvmF8rFShbWGnrLqlzp4X1TNWjRY3JMYUfDCtOxPKOIY8B0WC8HN51hGP4I4hz4AaQ=="], + + "@esbuild/linux-arm64": ["@esbuild/linux-arm64@0.25.4", "", { "os": "linux", "cpu": "arm64" }, "sha512-+89UsQTfXdmjIvZS6nUnOOLoXnkUTB9hR5QAeLrQdzOSWZvNSAXAtcRDHWtqAUtAmv7ZM1WPOOeSxDzzzMogiQ=="], + + "@esbuild/linux-ia32": ["@esbuild/linux-ia32@0.25.4", "", { "os": "linux", "cpu": "ia32" }, "sha512-yTEjoapy8UP3rv8dB0ip3AfMpRbyhSN3+hY8mo/i4QXFeDxmiYbEKp3ZRjBKcOP862Ua4b1PDfwlvbuwY7hIGQ=="], + + "@esbuild/linux-loong64": ["@esbuild/linux-loong64@0.25.4", "", { "os": "linux", "cpu": "none" }, "sha512-NeqqYkrcGzFwi6CGRGNMOjWGGSYOpqwCjS9fvaUlX5s3zwOtn1qwg1s2iE2svBe4Q/YOG1q6875lcAoQK/F4VA=="], + + "@esbuild/linux-mips64el": ["@esbuild/linux-mips64el@0.25.4", "", { "os": "linux", "cpu": "none" }, "sha512-IcvTlF9dtLrfL/M8WgNI/qJYBENP3ekgsHbYUIzEzq5XJzzVEV/fXY9WFPfEEXmu3ck2qJP8LG/p3Q8f7Zc2Xg=="], + + "@esbuild/linux-ppc64": ["@esbuild/linux-ppc64@0.25.4", "", { "os": "linux", "cpu": "ppc64" }, "sha512-HOy0aLTJTVtoTeGZh4HSXaO6M95qu4k5lJcH4gxv56iaycfz1S8GO/5Jh6X4Y1YiI0h7cRyLi+HixMR+88swag=="], + + "@esbuild/linux-riscv64": ["@esbuild/linux-riscv64@0.25.4", "", { "os": "linux", "cpu": "none" }, "sha512-i8JUDAufpz9jOzo4yIShCTcXzS07vEgWzyX3NH2G7LEFVgrLEhjwL3ajFE4fZI3I4ZgiM7JH3GQ7ReObROvSUA=="], + + "@esbuild/linux-s390x": ["@esbuild/linux-s390x@0.25.4", "", { "os": "linux", "cpu": "s390x" }, "sha512-jFnu+6UbLlzIjPQpWCNh5QtrcNfMLjgIavnwPQAfoGx4q17ocOU9MsQ2QVvFxwQoWpZT8DvTLooTvmOQXkO51g=="], + + "@esbuild/linux-x64": ["@esbuild/linux-x64@0.25.4", "", { "os": "linux", "cpu": "x64" }, "sha512-6e0cvXwzOnVWJHq+mskP8DNSrKBr1bULBvnFLpc1KY+d+irZSgZ02TGse5FsafKS5jg2e4pbvK6TPXaF/A6+CA=="], + + "@esbuild/netbsd-arm64": ["@esbuild/netbsd-arm64@0.25.4", "", { "os": "none", "cpu": "arm64" }, "sha512-vUnkBYxZW4hL/ie91hSqaSNjulOnYXE1VSLusnvHg2u3jewJBz3YzB9+oCw8DABeVqZGg94t9tyZFoHma8gWZQ=="], + + "@esbuild/netbsd-x64": ["@esbuild/netbsd-x64@0.25.4", "", { "os": "none", "cpu": "x64" }, "sha512-XAg8pIQn5CzhOB8odIcAm42QsOfa98SBeKUdo4xa8OvX8LbMZqEtgeWE9P/Wxt7MlG2QqvjGths+nq48TrUiKw=="], + + "@esbuild/openbsd-arm64": ["@esbuild/openbsd-arm64@0.25.4", "", { "os": "openbsd", "cpu": "arm64" }, "sha512-Ct2WcFEANlFDtp1nVAXSNBPDxyU+j7+tId//iHXU2f/lN5AmO4zLyhDcpR5Cz1r08mVxzt3Jpyt4PmXQ1O6+7A=="], + + "@esbuild/openbsd-x64": ["@esbuild/openbsd-x64@0.25.4", "", { "os": "openbsd", "cpu": "x64" }, "sha512-xAGGhyOQ9Otm1Xu8NT1ifGLnA6M3sJxZ6ixylb+vIUVzvvd6GOALpwQrYrtlPouMqd/vSbgehz6HaVk4+7Afhw=="], + + "@esbuild/sunos-x64": ["@esbuild/sunos-x64@0.25.4", "", { "os": "sunos", "cpu": "x64" }, "sha512-Mw+tzy4pp6wZEK0+Lwr76pWLjrtjmJyUB23tHKqEDP74R3q95luY/bXqXZeYl4NYlvwOqoRKlInQialgCKy67Q=="], + + "@esbuild/win32-arm64": ["@esbuild/win32-arm64@0.25.4", "", { "os": "win32", "cpu": "arm64" }, "sha512-AVUP428VQTSddguz9dO9ngb+E5aScyg7nOeJDrF1HPYu555gmza3bDGMPhmVXL8svDSoqPCsCPjb265yG/kLKQ=="], + + "@esbuild/win32-ia32": ["@esbuild/win32-ia32@0.25.4", "", { "os": "win32", "cpu": "ia32" }, "sha512-i1sW+1i+oWvQzSgfRcxxG2k4I9n3O9NRqy8U+uugaT2Dy7kLO9Y7wI72haOahxceMX8hZAzgGou1FhndRldxRg=="], + + "@esbuild/win32-x64": ["@esbuild/win32-x64@0.25.4", "", { "os": "win32", "cpu": "x64" }, "sha512-nOT2vZNw6hJ+z43oP1SPea/G/6AbN6X+bGNhNuq8NtRHy4wsMhw765IKLNmnjek7GvjWBYQ8Q5VBoYTFg9y1UQ=="], "abort-controller": ["abort-controller@3.0.0", "", { "dependencies": { "event-target-shim": "^5.0.0" } }, "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg=="], - "asn1.js": ["asn1.js@5.4.1", "", { "dependencies": { "bn.js": "^4.0.0", "inherits": "^2.0.1", "minimalistic-assert": "^1.0.0", "safer-buffer": "^2.1.0" } }, "sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA=="], + "asn1.js": ["asn1.js@4.10.1", "", { "dependencies": { "bn.js": "^4.0.0", "inherits": "^2.0.1", "minimalistic-assert": "^1.0.0" } }, "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw=="], - "assert": ["assert@2.0.0", "", { "dependencies": { "es6-object-assign": "^1.1.0", "is-nan": "^1.2.1", "object-is": "^1.0.1", "util": "^0.12.0" } }, "sha512-se5Cd+js9dXJnu6Ag2JFc00t+HmHOen+8Q+L7O9zI0PqQXr20uk2J0XQqMxZEeo5U50o8Nvmmx7dZrl+Ufr35A=="], + "assert": ["assert@2.1.0", "", { "dependencies": { "call-bind": "^1.0.2", "is-nan": "^1.3.2", "object-is": "^1.1.5", "object.assign": "^4.1.4", "util": "^0.12.5" } }, "sha512-eLHpSK/Y4nhMJ07gDaAzoX/XAKS8PSaojml3M0DM4JpV1LAi5JOJ/p6H/XWrl8L+DzVEvVCW1z3vWAaB9oTsQw=="], - "available-typed-arrays": ["available-typed-arrays@1.0.5", "", {}, "sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw=="], + "available-typed-arrays": ["available-typed-arrays@1.0.7", "", { "dependencies": { "possible-typed-array-names": "^1.0.0" } }, "sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ=="], "base64-js": ["base64-js@1.5.1", "", {}, "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA=="], - "bn.js": ["bn.js@5.2.1", "", {}, "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ=="], + "bn.js": ["bn.js@5.2.2", "", {}, "sha512-v2YAxEmKaBLahNwE1mjp4WON6huMNeuDvagFZW+ASCuA/ku0bXR9hSMw0XpiqMoA3+rmnyck/tPRSFQkoC9Cuw=="], "brorand": ["brorand@1.1.0", "", {}, "sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w=="], @@ -54,9 +105,9 @@ "browserify-des": ["browserify-des@1.0.2", "", { "dependencies": { "cipher-base": "^1.0.1", "des.js": "^1.0.0", "inherits": "^2.0.1", "safe-buffer": "^5.1.2" } }, "sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A=="], - "browserify-rsa": ["browserify-rsa@4.1.0", "", { "dependencies": { "bn.js": "^5.0.0", "randombytes": "^2.0.1" } }, "sha512-AdEER0Hkspgno2aR97SAf6vi0y0k8NuOpGnVH3O99rcA5Q6sh8QxcngtHuJ6uXwnfAXNM4Gn1Gb7/MV1+Ymbog=="], + "browserify-rsa": ["browserify-rsa@4.1.1", "", { "dependencies": { "bn.js": "^5.2.1", "randombytes": "^2.1.0", "safe-buffer": "^5.2.1" } }, "sha512-YBjSAiTqM04ZVei6sXighu679a3SqWORA3qZTEqZImnlkDIFtKc6pNutpjyZ8RJTjQtuYfeetkxM11GwoYXMIQ=="], - "browserify-sign": ["browserify-sign@4.2.1", "", { "dependencies": { "bn.js": "^5.1.1", "browserify-rsa": "^4.0.1", "create-hash": "^1.2.0", "create-hmac": "^1.1.7", "elliptic": "^6.5.3", "inherits": "^2.0.4", "parse-asn1": "^5.1.5", "readable-stream": "^3.6.0", "safe-buffer": "^5.2.0" } }, "sha512-/vrA5fguVAKKAVTNJjgSm1tRQDHUU6DbwO9IROu/0WAzC8PKhucDSh18J0RMvVeHAn5puMd+QHC2erPRNf8lmg=="], + "browserify-sign": ["browserify-sign@4.2.3", "", { "dependencies": { "bn.js": "^5.2.1", "browserify-rsa": "^4.1.0", "create-hash": "^1.2.0", "create-hmac": "^1.1.7", "elliptic": "^6.5.5", "hash-base": "~3.0", "inherits": "^2.0.4", "parse-asn1": "^5.1.7", "readable-stream": "^2.3.8", "safe-buffer": "^5.2.1" } }, "sha512-JWCZW6SKhfhjJxO8Tyiiy+XYB7cqd2S5/+WeYHsKdNKFlCBhKbblba1A/HN/90YwtxKc8tCErjffZl++UNmGiw=="], "browserify-zlib": ["browserify-zlib@0.2.0", "", { "dependencies": { "pako": "~1.0.5" } }, "sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA=="], @@ -66,9 +117,13 @@ "builtin-status-codes": ["builtin-status-codes@3.0.0", "", {}, "sha512-HpGFw18DgFWlncDfjTa2rcQ4W88O1mC8e8yZ2AvQY5KDaktSTwo+KRf6nHK6FRI5FyRyb/5T6+TSxfP7QyGsmQ=="], - "call-bind": ["call-bind@1.0.2", "", { "dependencies": { "function-bind": "^1.1.1", "get-intrinsic": "^1.0.2" } }, "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA=="], + "call-bind": ["call-bind@1.0.8", "", { "dependencies": { "call-bind-apply-helpers": "^1.0.0", "es-define-property": "^1.0.0", "get-intrinsic": "^1.2.4", "set-function-length": "^1.2.2" } }, "sha512-oKlSFMcMwpUg2ednkhQ454wfWiU/ul3CkJe/PEHcTKuiX6RpbehUiFMXu13HalGZxfUwCQzZG747YXBn1im9ww=="], - "cipher-base": ["cipher-base@1.0.4", "", { "dependencies": { "inherits": "^2.0.1", "safe-buffer": "^5.0.1" } }, "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q=="], + "call-bind-apply-helpers": ["call-bind-apply-helpers@1.0.2", "", { "dependencies": { "es-errors": "^1.3.0", "function-bind": "^1.1.2" } }, "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ=="], + + "call-bound": ["call-bound@1.0.4", "", { "dependencies": { "call-bind-apply-helpers": "^1.0.2", "get-intrinsic": "^1.3.0" } }, "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg=="], + + "cipher-base": ["cipher-base@1.0.6", "", { "dependencies": { "inherits": "^2.0.4", "safe-buffer": "^5.2.1" } }, "sha512-3Ek9H3X6pj5TgenXYtNWdaBon1tgYCaebd+XPg0keyjEbEfkD4KkmAxkQ/i1vYvxdcT5nscLBfq9VJRmCBcFSw=="], "console-browserify": ["console-browserify@1.2.0", "", {}, "sha512-ZMkYO/LkF17QvCPqM0gxw8yUzigAOZOSWSHg91FH6orS7vcEj5dVZTidN2fQ14yBSdg97RqhSNwLUXInd52OTA=="], @@ -80,61 +135,29 @@ "create-hmac": ["create-hmac@1.1.7", "", { "dependencies": { "cipher-base": "^1.0.3", "create-hash": "^1.1.0", "inherits": "^2.0.1", "ripemd160": "^2.0.0", "safe-buffer": "^5.0.1", "sha.js": "^2.4.8" } }, "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg=="], - "crypto-browserify": ["crypto-browserify@3.12.0", "", { "dependencies": { "browserify-cipher": "^1.0.0", "browserify-sign": "^4.0.0", "create-ecdh": "^4.0.0", "create-hash": "^1.1.0", "create-hmac": "^1.1.0", "diffie-hellman": "^5.0.0", "inherits": "^2.0.1", "pbkdf2": "^3.0.3", "public-encrypt": "^4.0.0", "randombytes": "^2.0.0", "randomfill": "^1.0.3" } }, "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg=="], + "crypto-browserify": ["crypto-browserify@3.12.1", "", { "dependencies": { "browserify-cipher": "^1.0.1", "browserify-sign": "^4.2.3", "create-ecdh": "^4.0.4", "create-hash": "^1.2.0", "create-hmac": "^1.1.7", "diffie-hellman": "^5.0.3", "hash-base": "~3.0.4", "inherits": "^2.0.4", "pbkdf2": "^3.1.2", "public-encrypt": "^4.0.3", "randombytes": "^2.1.0", "randomfill": "^1.0.4" } }, "sha512-r4ESw/IlusD17lgQi1O20Fa3qNnsckR126TdUuBgAu7GBYSIPvdNyONd3Zrxh0xCwA4+6w/TDArBPsMvhur+KQ=="], - "define-properties": ["define-properties@1.2.0", "", { "dependencies": { "has-property-descriptors": "^1.0.0", "object-keys": "^1.1.1" } }, "sha512-xvqAVKGfT1+UAvPwKTVw/njhdQ8ZhXK4lI0bCIuCMrp2up9nPnaDftrLtmpTazqd1o+UY4zgzU+avtMbDP+ldA=="], + "define-data-property": ["define-data-property@1.1.4", "", { "dependencies": { "es-define-property": "^1.0.0", "es-errors": "^1.3.0", "gopd": "^1.0.1" } }, "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A=="], - "des.js": ["des.js@1.0.1", "", { "dependencies": { "inherits": "^2.0.1", "minimalistic-assert": "^1.0.0" } }, "sha512-Q0I4pfFrv2VPd34/vfLrFOoRmlYj3OV50i7fskps1jZWK1kApMWWT9G6RRUeYedLcBDIhnSDaUvJMb3AhUlaEA=="], + "define-properties": ["define-properties@1.2.1", "", { "dependencies": { "define-data-property": "^1.0.1", "has-property-descriptors": "^1.0.0", "object-keys": "^1.1.1" } }, "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg=="], + + "des.js": ["des.js@1.1.0", "", { "dependencies": { "inherits": "^2.0.1", "minimalistic-assert": "^1.0.0" } }, "sha512-r17GxjhUCjSRy8aiJpr8/UadFIzMzJGexI3Nmz4ADi9LYSFx4gTBp80+NaX/YsXWWLhpZ7v/v/ubEc/bCNfKwg=="], "diffie-hellman": ["diffie-hellman@5.0.3", "", { "dependencies": { "bn.js": "^4.1.0", "miller-rabin": "^4.0.0", "randombytes": "^2.0.0" } }, "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg=="], - "domain-browser": ["domain-browser@4.22.0", "", {}, "sha512-IGBwjF7tNk3cwypFNH/7bfzBcgSCbaMOD3GsaY1AU/JRrnHnYgEM0+9kQt52iZxjNsjBtJYtao146V+f8jFZNw=="], + "domain-browser": ["domain-browser@4.23.0", "", {}, "sha512-ArzcM/II1wCCujdCNyQjXrAFwS4mrLh4C7DZWlaI8mdh7h3BfKdNd3bKXITfl2PT9FtfQqaGvhi1vPRQPimjGA=="], - "elliptic": ["elliptic@6.5.4", "", { "dependencies": { "bn.js": "^4.11.9", "brorand": "^1.1.0", "hash.js": "^1.0.0", "hmac-drbg": "^1.0.1", "inherits": "^2.0.4", "minimalistic-assert": "^1.0.1", "minimalistic-crypto-utils": "^1.0.1" } }, "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ=="], + "dunder-proto": ["dunder-proto@1.0.1", "", { "dependencies": { "call-bind-apply-helpers": "^1.0.1", "es-errors": "^1.3.0", "gopd": "^1.2.0" } }, "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A=="], - "es6-object-assign": ["es6-object-assign@1.1.0", "", {}, "sha512-MEl9uirslVwqQU369iHNWZXsI8yaZYGg/D65aOgZkeyFJwHYSxilf7rQzXKI7DdDuBPrBXbfk3sl9hJhmd5AUw=="], + "elliptic": ["elliptic@6.6.1", "", { "dependencies": { "bn.js": "^4.11.9", "brorand": "^1.1.0", "hash.js": "^1.0.0", "hmac-drbg": "^1.0.1", "inherits": "^2.0.4", "minimalistic-assert": "^1.0.1", "minimalistic-crypto-utils": "^1.0.1" } }, "sha512-RaddvvMatK2LJHqFJ+YA4WysVN5Ita9E35botqIYspQ4TkRAlCicdzKOjlyv/1Za5RyTNn7di//eEV0uTAfe3g=="], - "esbuild": ["esbuild@0.14.54", "", { "dependencies": { "@esbuild/linux-loong64": "0.14.54", "esbuild-android-64": "0.14.54", "esbuild-android-arm64": "0.14.54", "esbuild-darwin-64": "0.14.54", "esbuild-darwin-arm64": "0.14.54", "esbuild-freebsd-64": "0.14.54", "esbuild-freebsd-arm64": "0.14.54", "esbuild-linux-32": "0.14.54", "esbuild-linux-64": "0.14.54", "esbuild-linux-arm": "0.14.54", "esbuild-linux-arm64": "0.14.54", "esbuild-linux-mips64le": "0.14.54", "esbuild-linux-ppc64le": "0.14.54", "esbuild-linux-riscv64": "0.14.54", "esbuild-linux-s390x": "0.14.54", "esbuild-netbsd-64": "0.14.54", "esbuild-openbsd-64": "0.14.54", "esbuild-sunos-64": "0.14.54", "esbuild-windows-32": "0.14.54", "esbuild-windows-64": "0.14.54", "esbuild-windows-arm64": "0.14.54" }, "bin": { "esbuild": "bin/esbuild" } }, "sha512-Cy9llcy8DvET5uznocPyqL3BFRrFXSVqbgpMJ9Wz8oVjZlh/zUSNbPRbov0VX7VxN2JH1Oa0uNxZ7eLRb62pJA=="], + "es-define-property": ["es-define-property@1.0.1", "", {}, "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g=="], - "esbuild-android-64": ["esbuild-android-64@0.14.54", "", { "os":"android", "cpu":"x64" }, "sha512-Tz2++Aqqz0rJ7kYBfz+iqyE3QMycD4vk7LBRyWaAVFgFtQ/O8EJOnVmTOiDWYZ/uYzB4kvP+bqejYdVKzE5lAQ=="], + "es-errors": ["es-errors@1.3.0", "", {}, "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw=="], - "esbuild-android-arm64": ["esbuild-android-arm64@0.14.54", "", { "os":"android", "cpu":"arm64" }, "sha512-F9E+/QDi9sSkLaClO8SOV6etqPd+5DgJje1F9lOWoNncDdOBL2YF59IhsWATSt0TLZbYCf3pNlTHvVV5VfHdvg=="], + "es-object-atoms": ["es-object-atoms@1.1.1", "", { "dependencies": { "es-errors": "^1.3.0" } }, "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA=="], - "esbuild-darwin-64": ["esbuild-darwin-64@0.14.54", "", { "os":"darwin", "cpu":"x64" }, "sha512-jtdKWV3nBviOd5v4hOpkVmpxsBy90CGzebpbO9beiqUYVMBtSc0AL9zGftFuBon7PNDcdvNCEuQqw2x0wP9yug=="], - - "esbuild-darwin-arm64": ["esbuild-darwin-arm64@0.14.54", "", { "os":"darwin", "cpu":"arm64" }, "sha512-OPafJHD2oUPyvJMrsCvDGkRrVCar5aVyHfWGQzY1dWnzErjrDuSETxwA2HSsyg2jORLY8yBfzc1MIpUkXlctmw=="], - - "esbuild-freebsd-64": ["esbuild-freebsd-64@0.14.54", "", { "os":"freebsd", "cpu":"x64" }, "sha512-OKwd4gmwHqOTp4mOGZKe/XUlbDJ4Q9TjX0hMPIDBUWWu/kwhBAudJdBoxnjNf9ocIB6GN6CPowYpR/hRCbSYAg=="], - - "esbuild-freebsd-arm64": ["esbuild-freebsd-arm64@0.14.54", "", { "os":"freebsd", "cpu":"arm64" }, "sha512-sFwueGr7OvIFiQT6WeG0jRLjkjdqWWSrfbVwZp8iMP+8UHEHRBvlaxL6IuKNDwAozNUmbb8nIMXa7oAOARGs1Q=="], - - "esbuild-linux-32": ["esbuild-linux-32@0.14.54", "", { "os":"linux", "cpu":"ia32" }, "sha512-1ZuY+JDI//WmklKlBgJnglpUL1owm2OX+8E1syCD6UAxcMM/XoWd76OHSjl/0MR0LisSAXDqgjT3uJqT67O3qw=="], - - "esbuild-linux-64": ["esbuild-linux-64@0.14.54", "", { "os":"linux", "cpu":"x64" }, "sha512-EgjAgH5HwTbtNsTqQOXWApBaPVdDn7XcK+/PtJwZLT1UmpLoznPd8c5CxqsH2dQK3j05YsB3L17T8vE7cp4cCg=="], - - "esbuild-linux-arm": ["esbuild-linux-arm@0.14.54", "", { "os":"linux", "cpu":"arm" }, "sha512-qqz/SjemQhVMTnvcLGoLOdFpCYbz4v4fUo+TfsWG+1aOu70/80RV6bgNpR2JCrppV2moUQkww+6bWxXRL9YMGw=="], - - "esbuild-linux-arm64": ["esbuild-linux-arm64@0.14.54", "", { "os":"linux", "cpu":"arm64" }, "sha512-WL71L+0Rwv+Gv/HTmxTEmpv0UgmxYa5ftZILVi2QmZBgX3q7+tDeOQNqGtdXSdsL8TQi1vIaVFHUPDe0O0kdig=="], - - "esbuild-linux-mips64le": ["esbuild-linux-mips64le@0.14.54", "", { "os":"linux", "cpu":"none" }, "sha512-qTHGQB8D1etd0u1+sB6p0ikLKRVuCWhYQhAHRPkO+OF3I/iSlTKNNS0Lh2Oc0g0UFGguaFZZiPJdJey3AGpAlw=="], - - "esbuild-linux-ppc64le": ["esbuild-linux-ppc64le@0.14.54", "", { "os":"linux", "cpu":"ppc64" }, "sha512-j3OMlzHiqwZBDPRCDFKcx595XVfOfOnv68Ax3U4UKZ3MTYQB5Yz3X1mn5GnodEVYzhtZgxEBidLWeIs8FDSfrQ=="], - - "esbuild-linux-riscv64": ["esbuild-linux-riscv64@0.14.54", "", { "os":"linux", "cpu":"none" }, "sha512-y7Vt7Wl9dkOGZjxQZnDAqqn+XOqFD7IMWiewY5SPlNlzMX39ocPQlOaoxvT4FllA5viyV26/QzHtvTjVNOxHZg=="], - - "esbuild-linux-s390x": ["esbuild-linux-s390x@0.14.54", "", { "os":"linux", "cpu":"s390x" }, "sha512-zaHpW9dziAsi7lRcyV4r8dhfG1qBidQWUXweUjnw+lliChJqQr+6XD71K41oEIC3Mx1KStovEmlzm+MkGZHnHA=="], - - "esbuild-netbsd-64": ["esbuild-netbsd-64@0.14.54", "", { "os":"none", "cpu":"x64" }, "sha512-PR01lmIMnfJTgeU9VJTDY9ZerDWVFIUzAtJuDHwwceppW7cQWjBBqP48NdeRtoP04/AtO9a7w3viI+PIDr6d+w=="], - - "esbuild-openbsd-64": ["esbuild-openbsd-64@0.14.54", "", { "os":"openbsd", "cpu":"x64" }, "sha512-Qyk7ikT2o7Wu76UsvvDS5q0amJvmRzDyVlL0qf5VLsLchjCa1+IAvd8kTBgUxD7VBUUVgItLkk609ZHUc1oCaw=="], - - "esbuild-sunos-64": ["esbuild-sunos-64@0.14.54", "", { "os":"sunos", "cpu":"x64" }, "sha512-28GZ24KmMSeKi5ueWzMcco6EBHStL3B6ubM7M51RmPwXQGLe0teBGJocmWhgwccA1GeFXqxzILIxXpHbl9Q/Kw=="], - - "esbuild-windows-32": ["esbuild-windows-32@0.14.54", "", { "os":"win32", "cpu":"ia32" }, "sha512-T+rdZW19ql9MjS7pixmZYVObd9G7kcaZo+sETqNH4RCkuuYSuv9AGHUVnPoP9hhuE1WM1ZimHz1CIBHBboLU7w=="], - - "esbuild-windows-64": ["esbuild-windows-64@0.14.54", "", { "os":"win32", "cpu":"x64" }, "sha512-AoHTRBUuYwXtZhjXZbA1pGfTo8cJo3vZIcWGLiUcTNgHpJJMC1rVA44ZereBHMJtotyN71S8Qw0npiCIkW96cQ=="], - - "esbuild-windows-arm64": ["esbuild-windows-arm64@0.14.54", "", { "os":"win32", "cpu":"arm64" }, "sha512-M0kuUvXhot1zOISQGXwWn6YtS+Y/1RT9WrVIOywZnJHo3jCDyewAc79aKNQWFCQm+xNHVTq9h8dZKvygoXQQRg=="], + "esbuild": ["esbuild@0.25.4", "", { "optionalDependencies": { "@esbuild/aix-ppc64": "0.25.4", "@esbuild/android-arm": "0.25.4", "@esbuild/android-arm64": "0.25.4", "@esbuild/android-x64": "0.25.4", "@esbuild/darwin-arm64": "0.25.4", "@esbuild/darwin-x64": "0.25.4", "@esbuild/freebsd-arm64": "0.25.4", "@esbuild/freebsd-x64": "0.25.4", "@esbuild/linux-arm": "0.25.4", "@esbuild/linux-arm64": "0.25.4", "@esbuild/linux-ia32": "0.25.4", "@esbuild/linux-loong64": "0.25.4", "@esbuild/linux-mips64el": "0.25.4", "@esbuild/linux-ppc64": "0.25.4", "@esbuild/linux-riscv64": "0.25.4", "@esbuild/linux-s390x": "0.25.4", "@esbuild/linux-x64": "0.25.4", "@esbuild/netbsd-arm64": "0.25.4", "@esbuild/netbsd-x64": "0.25.4", "@esbuild/openbsd-arm64": "0.25.4", "@esbuild/openbsd-x64": "0.25.4", "@esbuild/sunos-x64": "0.25.4", "@esbuild/win32-arm64": "0.25.4", "@esbuild/win32-ia32": "0.25.4", "@esbuild/win32-x64": "0.25.4" }, "bin": { "esbuild": "bin/esbuild" } }, "sha512-8pgjLUcUjcgDg+2Q4NYXnPbo/vncAY4UmyaCm0jZevERqCHZIaWwdJHkf8XQtu4AxSKCdvrUbT0XUr1IdZzI8Q=="], "event-target-shim": ["event-target-shim@5.0.1", "", {}, "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ=="], @@ -142,26 +165,28 @@ "evp_bytestokey": ["evp_bytestokey@1.0.3", "", { "dependencies": { "md5.js": "^1.3.4", "safe-buffer": "^5.1.1" } }, "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA=="], - "for-each": ["for-each@0.3.3", "", { "dependencies": { "is-callable": "^1.1.3" } }, "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw=="], + "for-each": ["for-each@0.3.5", "", { "dependencies": { "is-callable": "^1.2.7" } }, "sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg=="], - "function-bind": ["function-bind@1.1.1", "", {}, "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="], + "function-bind": ["function-bind@1.1.2", "", {}, "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA=="], - "get-intrinsic": ["get-intrinsic@1.2.0", "", { "dependencies": { "function-bind": "^1.1.1", "has": "^1.0.3", "has-symbols": "^1.0.3" } }, "sha512-L049y6nFOuom5wGyRc3/gdTLO94dySVKRACj1RmJZBQXlbTMhtNIgkWkUHq+jYmZvKf14EW1EoJnnjbmoHij0Q=="], + "get-intrinsic": ["get-intrinsic@1.3.0", "", { "dependencies": { "call-bind-apply-helpers": "^1.0.2", "es-define-property": "^1.0.1", "es-errors": "^1.3.0", "es-object-atoms": "^1.1.1", "function-bind": "^1.1.2", "get-proto": "^1.0.1", "gopd": "^1.2.0", "has-symbols": "^1.1.0", "hasown": "^2.0.2", "math-intrinsics": "^1.1.0" } }, "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ=="], - "gopd": ["gopd@1.0.1", "", { "dependencies": { "get-intrinsic": "^1.1.3" } }, "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA=="], + "get-proto": ["get-proto@1.0.1", "", { "dependencies": { "dunder-proto": "^1.0.1", "es-object-atoms": "^1.0.0" } }, "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g=="], - "has": ["has@1.0.3", "", { "dependencies": { "function-bind": "^1.1.1" } }, "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw=="], + "gopd": ["gopd@1.2.0", "", {}, "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg=="], - "has-property-descriptors": ["has-property-descriptors@1.0.0", "", { "dependencies": { "get-intrinsic": "^1.1.1" } }, "sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ=="], + "has-property-descriptors": ["has-property-descriptors@1.0.2", "", { "dependencies": { "es-define-property": "^1.0.0" } }, "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg=="], - "has-symbols": ["has-symbols@1.0.3", "", {}, "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A=="], + "has-symbols": ["has-symbols@1.1.0", "", {}, "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ=="], - "has-tostringtag": ["has-tostringtag@1.0.0", "", { "dependencies": { "has-symbols": "^1.0.2" } }, "sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ=="], + "has-tostringtag": ["has-tostringtag@1.0.2", "", { "dependencies": { "has-symbols": "^1.0.3" } }, "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw=="], - "hash-base": ["hash-base@3.1.0", "", { "dependencies": { "inherits": "^2.0.4", "readable-stream": "^3.6.0", "safe-buffer": "^5.2.0" } }, "sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA=="], + "hash-base": ["hash-base@3.0.5", "", { "dependencies": { "inherits": "^2.0.4", "safe-buffer": "^5.2.1" } }, "sha512-vXm0l45VbcHEVlTCzs8M+s0VeYsB2lnlAaThoLKGXr3bE/VWDOelNUnycUPEhKEaXARL2TEFjBOyUiM6+55KBg=="], "hash.js": ["hash.js@1.1.7", "", { "dependencies": { "inherits": "^2.0.3", "minimalistic-assert": "^1.0.1" } }, "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA=="], + "hasown": ["hasown@2.0.2", "", { "dependencies": { "function-bind": "^1.1.2" } }, "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ=="], + "hmac-drbg": ["hmac-drbg@1.0.1", "", { "dependencies": { "hash.js": "^1.0.3", "minimalistic-assert": "^1.0.0", "minimalistic-crypto-utils": "^1.0.1" } }, "sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg=="], "https-browserify": ["https-browserify@1.0.0", "", {}, "sha512-J+FkSdyD+0mA0N+81tMotaRMfSL9SGi+xpD3T6YApKsc3bGSXJlfXri3VyFOeYkfLRQisDk1W+jIFFKBeUBbBg=="], @@ -170,15 +195,19 @@ "inherits": ["inherits@2.0.4", "", {}, "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="], - "is-arguments": ["is-arguments@1.1.1", "", { "dependencies": { "call-bind": "^1.0.2", "has-tostringtag": "^1.0.0" } }, "sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA=="], + "is-arguments": ["is-arguments@1.2.0", "", { "dependencies": { "call-bound": "^1.0.2", "has-tostringtag": "^1.0.2" } }, "sha512-7bVbi0huj/wrIAOzb8U1aszg9kdi3KN/CyU19CTI7tAoZYEZoL9yCDXpbXN+uPsuWnP02cyug1gleqq+TU+YCA=="], "is-callable": ["is-callable@1.2.7", "", {}, "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA=="], - "is-generator-function": ["is-generator-function@1.0.10", "", { "dependencies": { "has-tostringtag": "^1.0.0" } }, "sha512-jsEjy9l3yiXEQ+PsXdmBwEPcOxaXWLspKdplFUVI9vq1iZgIekeC0L167qeu86czQaxed3q/Uzuw0swL0irL8A=="], + "is-generator-function": ["is-generator-function@1.1.0", "", { "dependencies": { "call-bound": "^1.0.3", "get-proto": "^1.0.0", "has-tostringtag": "^1.0.2", "safe-regex-test": "^1.1.0" } }, "sha512-nPUB5km40q9e8UfN/Zc24eLlzdSf9OfKByBw9CIdw4H1giPMeA0OIJvbchsCu4npfI2QcMVBsGEBHKZ7wLTWmQ=="], "is-nan": ["is-nan@1.3.2", "", { "dependencies": { "call-bind": "^1.0.0", "define-properties": "^1.1.3" } }, "sha512-E+zBKpQ2t6MEo1VsonYmluk9NxGrbzpeeLC2xIViuO2EjU2xsXsBPwTr3Ykv9l08UYEVEdWeRZNouaZqF6RN0w=="], - "is-typed-array": ["is-typed-array@1.1.10", "", { "dependencies": { "available-typed-arrays": "^1.0.5", "call-bind": "^1.0.2", "for-each": "^0.3.3", "gopd": "^1.0.1", "has-tostringtag": "^1.0.0" } }, "sha512-PJqgEHiWZvMpaFZ3uTc8kHPM4+4ADTlDniuQL7cU/UDA0Ql7F70yGfHph3cLNe+c9toaigv+DFzTJKhc2CtO6A=="], + "is-regex": ["is-regex@1.2.1", "", { "dependencies": { "call-bound": "^1.0.2", "gopd": "^1.2.0", "has-tostringtag": "^1.0.2", "hasown": "^2.0.2" } }, "sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g=="], + + "is-typed-array": ["is-typed-array@1.1.15", "", { "dependencies": { "which-typed-array": "^1.1.16" } }, "sha512-p3EcsicXjit7SaskXHs1hA91QxgTw46Fv6EFKKGS5DRFLD8yKnohjF3hxoju94b/OcMZoQukzpPpBE9uLVKzgQ=="], + + "math-intrinsics": ["math-intrinsics@1.1.0", "", {}, "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g=="], "md5.js": ["md5.js@1.3.5", "", { "dependencies": { "hash-base": "^3.0.0", "inherits": "^2.0.1", "safe-buffer": "^5.1.2" } }, "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg=="], @@ -188,27 +217,33 @@ "minimalistic-crypto-utils": ["minimalistic-crypto-utils@1.0.1", "", {}, "sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg=="], - "object-is": ["object-is@1.1.5", "", { "dependencies": { "call-bind": "^1.0.2", "define-properties": "^1.1.3" } }, "sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw=="], + "object-inspect": ["object-inspect@1.13.4", "", {}, "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew=="], + + "object-is": ["object-is@1.1.6", "", { "dependencies": { "call-bind": "^1.0.7", "define-properties": "^1.2.1" } }, "sha512-F8cZ+KfGlSGi09lJT7/Nd6KJZ9ygtvYC0/UYYLI9nmQKLMnydpB9yvbv9K1uSkEu7FU9vYPmVwLg328tX+ot3Q=="], "object-keys": ["object-keys@1.1.1", "", {}, "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA=="], + "object.assign": ["object.assign@4.1.7", "", { "dependencies": { "call-bind": "^1.0.8", "call-bound": "^1.0.3", "define-properties": "^1.2.1", "es-object-atoms": "^1.0.0", "has-symbols": "^1.1.0", "object-keys": "^1.1.1" } }, "sha512-nK28WOo+QIjBkDduTINE4JkF/UJJKyf2EJxvJKfblDpyg0Q+pkOHNTL0Qwy6NP6FhE/EnzV73BxxqcJaXY9anw=="], + "os-browserify": ["os-browserify@0.3.0", "", {}, "sha512-gjcpUc3clBf9+210TRaDWbf+rZZZEshZ+DlXMRCeAjp0xhTrnQsKHypIy1J3d5hKdUzj69t708EHtU8P6bUn0A=="], "pako": ["pako@1.0.11", "", {}, "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw=="], - "parse-asn1": ["parse-asn1@5.1.6", "", { "dependencies": { "asn1.js": "^5.2.0", "browserify-aes": "^1.0.0", "evp_bytestokey": "^1.0.0", "pbkdf2": "^3.0.3", "safe-buffer": "^5.1.1" } }, "sha512-RnZRo1EPU6JBnra2vGHj0yhp6ebyjBZpmUCLHWiFhxlzvBCCpAuZ7elsBp1PVAbQN0/04VD/19rfzlBSwLstMw=="], + "parse-asn1": ["parse-asn1@5.1.7", "", { "dependencies": { "asn1.js": "^4.10.1", "browserify-aes": "^1.2.0", "evp_bytestokey": "^1.0.3", "hash-base": "~3.0", "pbkdf2": "^3.1.2", "safe-buffer": "^5.2.1" } }, "sha512-CTM5kuWR3sx9IFamcl5ErfPl6ea/N8IYwiJ+vpeB2g+1iknv7zBl5uPwbMbRVznRVbrNY6lGuDoE5b30grmbqg=="], "path-browserify": ["path-browserify@1.0.1", "", {}, "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g=="], "pbkdf2": ["pbkdf2@3.1.2", "", { "dependencies": { "create-hash": "^1.1.2", "create-hmac": "^1.1.4", "ripemd160": "^2.0.1", "safe-buffer": "^5.0.1", "sha.js": "^2.4.8" } }, "sha512-iuh7L6jA7JEGu2WxDwtQP1ddOpaJNC4KlDEFfdQajSGgGPNi4OyDc2R7QnbY2bR9QjBVGwgvTdNJZoE7RaxUMA=="], + "possible-typed-array-names": ["possible-typed-array-names@1.1.0", "", {}, "sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg=="], + "process": ["process@0.11.10", "", {}, "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A=="], "public-encrypt": ["public-encrypt@4.0.3", "", { "dependencies": { "bn.js": "^4.1.0", "browserify-rsa": "^4.0.0", "create-hash": "^1.1.0", "parse-asn1": "^5.0.0", "randombytes": "^2.0.1", "safe-buffer": "^5.1.2" } }, "sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q=="], - "punycode": ["punycode@2.3.0", "", {}, "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA=="], + "punycode": ["punycode@2.3.1", "", {}, "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg=="], - "querystring": ["querystring@0.2.0", "", {}, "sha512-X/xY82scca2tau62i9mDyU9K+I+djTMUsvwf7xnUX5GLvVzgJybOJf4Y6o9Zx3oJK/LSXg5tTZBjwzqVPaPO2g=="], + "qs": ["qs@6.14.0", "", { "dependencies": { "side-channel": "^1.1.0" } }, "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w=="], "querystring-es3": ["querystring-es3@1.0.0-0", "", { "dependencies": { "buffer": "5.0.5" } }, "sha512-0etE6Uj4NYut0/y/6pFgVRDAaFtf6x/n4xnBRL82c8n6yigRBepcgPaBAn2o8EhA9QQR1l8b1Je5s+LsJ+zS+g=="], @@ -216,20 +251,30 @@ "randomfill": ["randomfill@1.0.4", "", { "dependencies": { "randombytes": "^2.0.5", "safe-buffer": "^5.1.0" } }, "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw=="], - "react-refresh": ["react-refresh@0.16.0", "", {}, "sha512-FPvF2XxTSikpJxcr+bHut2H4gJ17+18Uy20D5/F+SKzFap62R3cM5wH6b8WN3LyGSYeQilLEcJcR1fjBSI2S1A=="], + "react-refresh": ["react-refresh@0.17.0", "", {}, "sha512-z6F7K9bV85EfseRCp2bzrpyQ0Gkw1uLoCel9XBVWPg/TjRj94SkJzUTGfOa4bs7iJvBWtQG0Wq7wnI0syw3EBQ=="], - "readable-stream": ["readable-stream@4.3.0", "", { "dependencies": { "abort-controller": "^3.0.0", "buffer": "^6.0.3", "events": "^3.3.0", "process": "^0.11.10" } }, "sha512-MuEnA0lbSi7JS8XM+WNJlWZkHAAdm7gETHdFK//Q/mChGyj2akEFtdLZh32jSdkWGbRwCW9pn6g3LWDdDeZnBQ=="], + "readable-stream": ["readable-stream@4.7.0", "", { "dependencies": { "abort-controller": "^3.0.0", "buffer": "^6.0.3", "events": "^3.3.0", "process": "^0.11.10", "string_decoder": "^1.3.0" } }, "sha512-oIGGmcpTLwPga8Bn6/Z75SVaH1z5dUut2ibSyAMVhmUggWpmDn2dapB0n7f8nwaSiRtepAsfJyfXIO5DCVAODg=="], "ripemd160": ["ripemd160@2.0.2", "", { "dependencies": { "hash-base": "^3.0.0", "inherits": "^2.0.1" } }, "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA=="], "safe-buffer": ["safe-buffer@5.2.1", "", {}, "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="], - "safer-buffer": ["safer-buffer@2.1.2", "", {}, "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="], + "safe-regex-test": ["safe-regex-test@1.1.0", "", { "dependencies": { "call-bound": "^1.0.2", "es-errors": "^1.3.0", "is-regex": "^1.2.1" } }, "sha512-x/+Cz4YrimQxQccJf5mKEbIa1NzeCRNI5Ecl/ekmlYaampdNLPalVyIcCZNNH3MvmqBugV5TMYZXv0ljslUlaw=="], + + "set-function-length": ["set-function-length@1.2.2", "", { "dependencies": { "define-data-property": "^1.1.4", "es-errors": "^1.3.0", "function-bind": "^1.1.2", "get-intrinsic": "^1.2.4", "gopd": "^1.0.1", "has-property-descriptors": "^1.0.2" } }, "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg=="], "setimmediate": ["setimmediate@1.0.5", "", {}, "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA=="], "sha.js": ["sha.js@2.4.11", "", { "dependencies": { "inherits": "^2.0.1", "safe-buffer": "^5.0.1" }, "bin": { "sha.js": "./bin.js" } }, "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ=="], + "side-channel": ["side-channel@1.1.0", "", { "dependencies": { "es-errors": "^1.3.0", "object-inspect": "^1.13.3", "side-channel-list": "^1.0.0", "side-channel-map": "^1.0.1", "side-channel-weakmap": "^1.0.2" } }, "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw=="], + + "side-channel-list": ["side-channel-list@1.0.0", "", { "dependencies": { "es-errors": "^1.3.0", "object-inspect": "^1.13.3" } }, "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA=="], + + "side-channel-map": ["side-channel-map@1.0.1", "", { "dependencies": { "call-bound": "^1.0.2", "es-errors": "^1.3.0", "get-intrinsic": "^1.2.5", "object-inspect": "^1.13.3" } }, "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA=="], + + "side-channel-weakmap": ["side-channel-weakmap@1.0.2", "", { "dependencies": { "call-bound": "^1.0.2", "es-errors": "^1.3.0", "get-intrinsic": "^1.2.5", "object-inspect": "^1.13.3", "side-channel-map": "^1.0.1" } }, "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A=="], + "stream-http": ["stream-http@3.2.0", "", { "dependencies": { "builtin-status-codes": "^3.0.0", "inherits": "^2.0.4", "readable-stream": "^3.6.0", "xtend": "^4.0.2" } }, "sha512-Oq1bLqisTyK3TSCXpPbT4sdeYNdmyZJv1LxpEm2vu1ZhK89kSE5YXwZc3cWk0MagGaKriBh9mCFbVGtO+vY29A=="], "string_decoder": ["string_decoder@1.3.0", "", { "dependencies": { "safe-buffer": "~5.2.0" } }, "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA=="], @@ -238,38 +283,30 @@ "tty-browserify": ["tty-browserify@0.0.1", "", {}, "sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw=="], - "url": ["url@0.11.0", "", { "dependencies": { "punycode": "1.3.2", "querystring": "0.2.0" } }, "sha512-kbailJa29QrtXnxgq+DdCEGlbTeYM2eJUxsz6vjZavrCYPMIFHMKQmSKYAIuUK2i7hgPm28a8piX5NTUtM/LKQ=="], + "url": ["url@0.11.4", "", { "dependencies": { "punycode": "^1.4.1", "qs": "^6.12.3" } }, "sha512-oCwdVC7mTuWiPyjLUz/COz5TLk6wgp0RCsN+wHZ2Ekneac9w8uuV0njcbbie2ME+Vs+d6duwmYuR3HgQXs1fOg=="], "util": ["util@0.12.5", "", { "dependencies": { "inherits": "^2.0.3", "is-arguments": "^1.0.4", "is-generator-function": "^1.0.7", "is-typed-array": "^1.1.3", "which-typed-array": "^1.1.2" } }, "sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA=="], - "util-deprecate": ["util-deprecate@1.0.2", "", {}, "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="], - "vm-browserify": ["vm-browserify@1.1.2", "", {}, "sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ=="], - "which-typed-array": ["which-typed-array@1.1.9", "", { "dependencies": { "available-typed-arrays": "^1.0.5", "call-bind": "^1.0.2", "for-each": "^0.3.3", "gopd": "^1.0.1", "has-tostringtag": "^1.0.0", "is-typed-array": "^1.1.10" } }, "sha512-w9c4xkx6mPidwp7180ckYWfMmvxpjlZuIudNtDf4N/tTAUB8VJbX25qZoAsrtGuYNnGw3pa0AXgbGKRB8/EceA=="], + "which-typed-array": ["which-typed-array@1.1.19", "", { "dependencies": { "available-typed-arrays": "^1.0.7", "call-bind": "^1.0.8", "call-bound": "^1.0.4", "for-each": "^0.3.5", "get-proto": "^1.0.1", "gopd": "^1.2.0", "has-tostringtag": "^1.0.2" } }, "sha512-rEvr90Bck4WZt9HHFC4DJMsjvu7x+r6bImz0/BrbWb7A2djJ8hnZMrWnHo9F8ssv0OMErasDhftrfROTyqSDrw=="], "xtend": ["xtend@4.0.2", "", {}, "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ=="], - "asn1.js/bn.js": ["bn.js@4.12.0", "", {}, "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA=="], + "asn1.js/bn.js": ["bn.js@4.12.2", "", {}, "sha512-n4DSx829VRTRByMRGdjQ9iqsN0Bh4OolPsFnaZBLcbi8iXcB+kJ9s7EnRt4wILZNV3kPLHkRVfOc/HvhC3ovDw=="], - "browserify-sign/readable-stream": ["readable-stream@3.6.0", "", { "dependencies": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", "util-deprecate": "^1.0.1" } }, "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA=="], + "create-ecdh/bn.js": ["bn.js@4.12.2", "", {}, "sha512-n4DSx829VRTRByMRGdjQ9iqsN0Bh4OolPsFnaZBLcbi8iXcB+kJ9s7EnRt4wILZNV3kPLHkRVfOc/HvhC3ovDw=="], - "create-ecdh/bn.js": ["bn.js@4.12.0", "", {}, "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA=="], + "diffie-hellman/bn.js": ["bn.js@4.12.2", "", {}, "sha512-n4DSx829VRTRByMRGdjQ9iqsN0Bh4OolPsFnaZBLcbi8iXcB+kJ9s7EnRt4wILZNV3kPLHkRVfOc/HvhC3ovDw=="], - "diffie-hellman/bn.js": ["bn.js@4.12.0", "", {}, "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA=="], + "elliptic/bn.js": ["bn.js@4.12.2", "", {}, "sha512-n4DSx829VRTRByMRGdjQ9iqsN0Bh4OolPsFnaZBLcbi8iXcB+kJ9s7EnRt4wILZNV3kPLHkRVfOc/HvhC3ovDw=="], - "elliptic/bn.js": ["bn.js@4.12.0", "", {}, "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA=="], + "miller-rabin/bn.js": ["bn.js@4.12.2", "", {}, "sha512-n4DSx829VRTRByMRGdjQ9iqsN0Bh4OolPsFnaZBLcbi8iXcB+kJ9s7EnRt4wILZNV3kPLHkRVfOc/HvhC3ovDw=="], - "hash-base/readable-stream": ["readable-stream@3.6.0", "", { "dependencies": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", "util-deprecate": "^1.0.1" } }, "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA=="], - - "miller-rabin/bn.js": ["bn.js@4.12.0", "", {}, "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA=="], - - "public-encrypt/bn.js": ["bn.js@4.12.0", "", {}, "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA=="], + "public-encrypt/bn.js": ["bn.js@4.12.2", "", {}, "sha512-n4DSx829VRTRByMRGdjQ9iqsN0Bh4OolPsFnaZBLcbi8iXcB+kJ9s7EnRt4wILZNV3kPLHkRVfOc/HvhC3ovDw=="], "querystring-es3/buffer": ["buffer@5.0.5", "", { "dependencies": { "base64-js": "^1.0.2", "ieee754": "^1.1.4" } }, "sha512-ye69HVxM0Htf+E5YhFLOfHX8dXOkammTDtqCU5xLFMlPYTQkNJ7Kv6I90TjZiPH1yXBHQdRvSAK28EZSwSm3Dg=="], - "stream-http/readable-stream": ["readable-stream@3.6.0", "", { "dependencies": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", "util-deprecate": "^1.0.1" } }, "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA=="], - - "url/punycode": ["punycode@1.3.2", "", {}, "sha512-RofWgt/7fL5wP1Y7fxE7/EmTLzQVnB0ycyibJ0OOHIlJqTNzglYFxVwETOcIoJqJmpDXJ9xImDv+Fq34F/d4Dw=="], + "url/punycode": ["punycode@1.4.1", "", {}, "sha512-jmYNElW7yvO7TV33CjSmvSiE2yco3bV2czu/OzDKdMNVZQWfxCblURLhf+47syQRBntjfLdd/H0egrzIG+oaFQ=="], } } diff --git a/src/node-fallbacks/console.js b/src/node-fallbacks/console.js index f988876f1a..34cc54b565 100644 --- a/src/node-fallbacks/console.js +++ b/src/node-fallbacks/console.js @@ -1,6 +1 @@ -/** - * Browser polyfill for the `"console"` module. - * - * Imported on usage in `bun build --target=browser` - */ export default console; diff --git a/src/node-fallbacks/constants.js b/src/node-fallbacks/constants.js index 2b1bbddf52..5b874fa8e1 100644 --- a/src/node-fallbacks/constants.js +++ b/src/node-fallbacks/constants.js @@ -1,7 +1,208 @@ -/** - * Browser polyfill for the `"constants"` module. - * - * Imported on usage in `bun build --target=browser` - */ - -export * from "constants-browserify"; +// equivalent to browserify constants module, converted to an ES module +export const O_RDONLY = 0; +export const O_WRONLY = 1; +export const O_RDWR = 2; +export const S_IFMT = 61440; +export const S_IFREG = 32768; +export const S_IFDIR = 16384; +export const S_IFCHR = 8192; +export const S_IFBLK = 24576; +export const S_IFIFO = 4096; +export const S_IFLNK = 40960; +export const S_IFSOCK = 49152; +export const O_CREAT = 512; +export const O_EXCL = 2048; +export const O_NOCTTY = 131072; +export const O_TRUNC = 1024; +export const O_APPEND = 8; +export const O_DIRECTORY = 1048576; +export const O_NOFOLLOW = 256; +export const O_SYNC = 128; +export const O_SYMLINK = 2097152; +export const O_NONBLOCK = 4; +export const S_IRWXU = 448; +export const S_IRUSR = 256; +export const S_IWUSR = 128; +export const S_IXUSR = 64; +export const S_IRWXG = 56; +export const S_IRGRP = 32; +export const S_IWGRP = 16; +export const S_IXGRP = 8; +export const S_IRWXO = 7; +export const S_IROTH = 4; +export const S_IWOTH = 2; +export const S_IXOTH = 1; +export const E2BIG = 7; +export const EACCES = 13; +export const EADDRINUSE = 48; +export const EADDRNOTAVAIL = 49; +export const EAFNOSUPPORT = 47; +export const EAGAIN = 35; +export const EALREADY = 37; +export const EBADF = 9; +export const EBADMSG = 94; +export const EBUSY = 16; +export const ECANCELED = 89; +export const ECHILD = 10; +export const ECONNABORTED = 53; +export const ECONNREFUSED = 61; +export const ECONNRESET = 54; +export const EDEADLK = 11; +export const EDESTADDRREQ = 39; +export const EDOM = 33; +export const EDQUOT = 69; +export const EEXIST = 17; +export const EFAULT = 14; +export const EFBIG = 27; +export const EHOSTUNREACH = 65; +export const EIDRM = 90; +export const EILSEQ = 92; +export const EINPROGRESS = 36; +export const EINTR = 4; +export const EINVAL = 22; +export const EIO = 5; +export const EISCONN = 56; +export const EISDIR = 21; +export const ELOOP = 62; +export const EMFILE = 24; +export const EMLINK = 31; +export const EMSGSIZE = 40; +export const EMULTIHOP = 95; +export const ENAMETOOLONG = 63; +export const ENETDOWN = 50; +export const ENETRESET = 52; +export const ENETUNREACH = 51; +export const ENFILE = 23; +export const ENOBUFS = 55; +export const ENODATA = 96; +export const ENODEV = 19; +export const ENOENT = 2; +export const ENOEXEC = 8; +export const ENOLCK = 77; +export const ENOLINK = 97; +export const ENOMEM = 12; +export const ENOMSG = 91; +export const ENOPROTOOPT = 42; +export const ENOSPC = 28; +export const ENOSR = 98; +export const ENOSTR = 99; +export const ENOSYS = 78; +export const ENOTCONN = 57; +export const ENOTDIR = 20; +export const ENOTEMPTY = 66; +export const ENOTSOCK = 38; +export const ENOTSUP = 45; +export const ENOTTY = 25; +export const ENXIO = 6; +export const EOPNOTSUPP = 102; +export const EOVERFLOW = 84; +export const EPERM = 1; +export const EPIPE = 32; +export const EPROTO = 100; +export const EPROTONOSUPPORT = 43; +export const EPROTOTYPE = 41; +export const ERANGE = 34; +export const EROFS = 30; +export const ESPIPE = 29; +export const ESRCH = 3; +export const ESTALE = 70; +export const ETIME = 101; +export const ETIMEDOUT = 60; +export const ETXTBSY = 26; +export const EWOULDBLOCK = 35; +export const EXDEV = 18; +export const SIGHUP = 1; +export const SIGINT = 2; +export const SIGQUIT = 3; +export const SIGILL = 4; +export const SIGTRAP = 5; +export const SIGABRT = 6; +export const SIGIOT = 6; +export const SIGBUS = 10; +export const SIGFPE = 8; +export const SIGKILL = 9; +export const SIGUSR1 = 30; +export const SIGSEGV = 11; +export const SIGUSR2 = 31; +export const SIGPIPE = 13; +export const SIGALRM = 14; +export const SIGTERM = 15; +export const SIGCHLD = 20; +export const SIGCONT = 19; +export const SIGSTOP = 17; +export const SIGTSTP = 18; +export const SIGTTIN = 21; +export const SIGTTOU = 22; +export const SIGURG = 16; +export const SIGXCPU = 24; +export const SIGXFSZ = 25; +export const SIGVTALRM = 26; +export const SIGPROF = 27; +export const SIGWINCH = 28; +export const SIGIO = 23; +export const SIGSYS = 12; +export const SSL_OP_ALL = 2147486719; +export const SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION = 262144; +export const SSL_OP_CIPHER_SERVER_PREFERENCE = 4194304; +export const SSL_OP_CISCO_ANYCONNECT = 32768; +export const SSL_OP_COOKIE_EXCHANGE = 8192; +export const SSL_OP_CRYPTOPRO_TLSEXT_BUG = 2147483648; +export const SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS = 2048; +export const SSL_OP_EPHEMERAL_RSA = 0; +export const SSL_OP_LEGACY_SERVER_CONNECT = 4; +export const SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER = 32; +export const SSL_OP_MICROSOFT_SESS_ID_BUG = 1; +export const SSL_OP_MSIE_SSLV2_RSA_PADDING = 0; +export const SSL_OP_NETSCAPE_CA_DN_BUG = 536870912; +export const SSL_OP_NETSCAPE_CHALLENGE_BUG = 2; +export const SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG = 1073741824; +export const SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG = 8; +export const SSL_OP_NO_COMPRESSION = 131072; +export const SSL_OP_NO_QUERY_MTU = 4096; +export const SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION = 65536; +export const SSL_OP_NO_SSLv2 = 16777216; +export const SSL_OP_NO_SSLv3 = 33554432; +export const SSL_OP_NO_TICKET = 16384; +export const SSL_OP_NO_TLSv1 = 67108864; +export const SSL_OP_NO_TLSv1_1 = 268435456; +export const SSL_OP_NO_TLSv1_2 = 134217728; +export const SSL_OP_PKCS1_CHECK_1 = 0; +export const SSL_OP_PKCS1_CHECK_2 = 0; +export const SSL_OP_SINGLE_DH_USE = 1048576; +export const SSL_OP_SINGLE_ECDH_USE = 524288; +export const SSL_OP_SSLEAY_080_CLIENT_DH_BUG = 128; +export const SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG = 0; +export const SSL_OP_TLS_BLOCK_PADDING_BUG = 512; +export const SSL_OP_TLS_D5_BUG = 256; +export const SSL_OP_TLS_ROLLBACK_BUG = 8388608; +export const ENGINE_METHOD_DSA = 2; +export const ENGINE_METHOD_DH = 4; +export const ENGINE_METHOD_RAND = 8; +export const ENGINE_METHOD_ECDH = 16; +export const ENGINE_METHOD_ECDSA = 32; +export const ENGINE_METHOD_CIPHERS = 64; +export const ENGINE_METHOD_DIGESTS = 128; +export const ENGINE_METHOD_STORE = 256; +export const ENGINE_METHOD_PKEY_METHS = 512; +export const ENGINE_METHOD_PKEY_ASN1_METHS = 1024; +export const ENGINE_METHOD_ALL = 65535; +export const ENGINE_METHOD_NONE = 0; +export const DH_CHECK_P_NOT_SAFE_PRIME = 2; +export const DH_CHECK_P_NOT_PRIME = 1; +export const DH_UNABLE_TO_CHECK_GENERATOR = 4; +export const DH_NOT_SUITABLE_GENERATOR = 8; +export const NPN_ENABLED = 1; +export const RSA_PKCS1_PADDING = 1; +export const RSA_SSLV23_PADDING = 2; +export const RSA_NO_PADDING = 3; +export const RSA_PKCS1_OAEP_PADDING = 4; +export const RSA_X931_PADDING = 5; +export const RSA_PKCS1_PSS_PADDING = 6; +export const POINT_CONVERSION_COMPRESSED = 2; +export const POINT_CONVERSION_UNCOMPRESSED = 4; +export const POINT_CONVERSION_HYBRID = 6; +export const F_OK = 0; +export const R_OK = 4; +export const W_OK = 2; +export const X_OK = 1; +export const UV_UDP_REUSEADDR = 4; diff --git a/src/node-fallbacks/crypto.js b/src/node-fallbacks/crypto.js index 08ec208782..3780678e39 100644 --- a/src/node-fallbacks/crypto.js +++ b/src/node-fallbacks/crypto.js @@ -1,11 +1,44 @@ -/** - * Browser polyfill for the `"crypto"` module. - * - * Imported on usage in `bun build --target=browser` - */ +import cryptoBrowserify from "crypto-browserify"; -export * from "crypto-browserify"; -import * as cryptoBrowserify from "crypto-browserify"; +export const prng = cryptoBrowserify.prng; +export const pseudoRandomBytes = cryptoBrowserify.pseudoRandomBytes; +export const rng = cryptoBrowserify.rng; +export const randomBytes = cryptoBrowserify.randomBytes; +export const Hash = cryptoBrowserify.Hash; +export const createHash = cryptoBrowserify.createHash; +export const Hmac = cryptoBrowserify.Hmac; +export const createHmac = cryptoBrowserify.createHmac; +export const getHashes = cryptoBrowserify.getHashes; +export const pbkdf2 = cryptoBrowserify.pbkdf2; +export const pbkdf2Sync = cryptoBrowserify.pbkdf2Sync; +export const Cipher = cryptoBrowserify.Cipher; +export const createCipher = cryptoBrowserify.createCipher; +export const Cipheriv = cryptoBrowserify.Cipheriv; +export const createCipheriv = cryptoBrowserify.createCipheriv; +export const Decipher = cryptoBrowserify.Decipher; +export const createDecipher = cryptoBrowserify.createDecipher; +export const Decipheriv = cryptoBrowserify.Decipheriv; +export const createDecipheriv = cryptoBrowserify.createDecipheriv; +export const getCiphers = cryptoBrowserify.getCiphers; +export const listCiphers = cryptoBrowserify.listCiphers; +export const DiffieHellmanGroup = cryptoBrowserify.DiffieHellmanGroup; +export const createDiffieHellmanGroup = cryptoBrowserify.createDiffieHellmanGroup; +export const getDiffieHellman = cryptoBrowserify.getDiffieHellman; +export const createDiffieHellman = cryptoBrowserify.createDiffieHellman; +export const DiffieHellman = cryptoBrowserify.DiffieHellman; +export const createSign = cryptoBrowserify.createSign; +export const Sign = cryptoBrowserify.Sign; +export const createVerify = cryptoBrowserify.createVerify; +export const Verify = cryptoBrowserify.Verify; +export const createECDH = cryptoBrowserify.createECDH; +export const publicEncrypt = cryptoBrowserify.publicEncrypt; +export const privateEncrypt = cryptoBrowserify.privateEncrypt; +export const publicDecrypt = cryptoBrowserify.publicDecrypt; +export const privateDecrypt = cryptoBrowserify.privateDecrypt; +export const randomFill = cryptoBrowserify.randomFill; +export const randomFillSync = cryptoBrowserify.randomFillSync; +export const createCredentials = cryptoBrowserify.createCredentials; +export const constants = cryptoBrowserify.constants; export var DEFAULT_ENCODING = "buffer"; @@ -18,7 +51,7 @@ export const randomUUID = () => { return crypto.randomUUID(); }; -const harcoded_curves = [ +const hardcoded_curves = [ "p192", "p224", "p256", @@ -36,42 +69,7 @@ const harcoded_curves = [ ]; export function getCurves() { - return harcoded_curves; -} - -export const timingSafeEqual = - "timingSafeEqual" in crypto - ? (a, b) => { - const { byteLength: byteLengthA } = a; - const { byteLength: byteLengthB } = b; - if (typeof byteLengthA !== "number" || typeof byteLengthB !== "number") { - throw new TypeError("Input must be an array buffer view"); - } - - if (byteLengthA !== byteLengthB) { - throw new RangeError("Input buffers must have the same length"); - } - - // these error checks are also performed in the function - // however there is a bug where exceptions return no value - return crypto.timingSafeEqual(a, b); - } - : undefined; - -if (timingSafeEqual) { - // hide it from stack trace - Object.defineProperty(timingSafeEqual, "name", { - value: "::bunternal::", - }); + return hardcoded_curves; } export const webcrypto = crypto; - -export default { - ...cryptoBrowserify, - getRandomValues, - randomUUID, - timingSafeEqual, - webcrypto, - getCurves, -}; diff --git a/src/node-fallbacks/domain.js b/src/node-fallbacks/domain.js index 58eef6aecc..f4e83aa6b4 100644 --- a/src/node-fallbacks/domain.js +++ b/src/node-fallbacks/domain.js @@ -1,8 +1,2 @@ -/** - * Browser polyfill for the `"domain"` module. - * - * Imported on usage in `bun build --target=browser` - */ import domain from "domain-browser"; -export default domain; export var { create, createDomain } = domain; diff --git a/src/node-fallbacks/events.js b/src/node-fallbacks/events.js index 165fc3d6b4..f49cba95dc 100644 --- a/src/node-fallbacks/events.js +++ b/src/node-fallbacks/events.js @@ -1,487 +1,546 @@ -/** - * Browser polyfill for the `"events"` module. - * - * Imported on usage in `bun build --target=browser` - */ -// Copyright Joyent, Inc. and other Node contributors. +// NOTE: THIS IS A BROWSER POLYFILL - Bun's actual node:* modules are in src/js/node // -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. +// TODO: This file is copy pasted from that, and should be generated from that, +// in a way that excludes async_hooks related functions. Those will never be +// available in the browser. Also, Node.js has some addition hooks to allow +// these functions to take secret data out of EventTarget. those cannot be +// included here either. -"use strict"; +const SymbolFor = Symbol.for; -var R = typeof Reflect === "object" ? Reflect : null; -var ReflectApply = - R && typeof R.apply === "function" - ? R.apply - : function ReflectApply(target, receiver, args) { - return Function.prototype.apply.call(target, receiver, args); - }; +const kCapture = Symbol("kCapture"); +const kErrorMonitor = SymbolFor("events.errorMonitor"); +const kMaxEventTargetListeners = Symbol("events.maxEventTargetListeners"); +const kMaxEventTargetListenersWarned = Symbol("events.maxEventTargetListenersWarned"); +const kRejection = SymbolFor("nodejs.rejection"); +const captureRejectionSymbol = SymbolFor("nodejs.rejection"); +const ArrayPrototypeSlice = Array.prototype.slice; -var ReflectOwnKeys; -if (R && typeof R.ownKeys === "function") { - ReflectOwnKeys = R.ownKeys; -} else if (Object.getOwnPropertySymbols) { - ReflectOwnKeys = function ReflectOwnKeys(target) { - return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target)); - }; -} else { - ReflectOwnKeys = function ReflectOwnKeys(target) { - return Object.getOwnPropertyNames(target); - }; -} - -function ProcessEmitWarning(warning) { - if (console && console.warn) console.warn(warning); -} - -var NumberIsNaN = - Number.isNaN || - function NumberIsNaN(value) { - return value !== value; - }; - -function EventEmitter() { - EventEmitter.init.call(this); -} - -// Backwards-compat with node 0.10.x -EventEmitter.EventEmitter = EventEmitter; - -EventEmitter.prototype._events = undefined; -EventEmitter.prototype._eventsCount = 0; -EventEmitter.prototype._maxListeners = undefined; - -// By default EventEmitters will print a warning if more than 10 listeners are -// added to it. This is a useful default which helps finding memory leaks. var defaultMaxListeners = 10; -function checkListener(listener) { - if (typeof listener !== "function") { - throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener); - } -} - -Object.defineProperty(EventEmitter, "defaultMaxListeners", { - enumerable: true, - get: function () { - return defaultMaxListeners; - }, - set: function (arg) { - if (typeof arg !== "number" || arg < 0 || NumberIsNaN(arg)) { - throw new RangeError( - 'The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + ".", - ); - } - defaultMaxListeners = arg; - }, -}); - -EventEmitter.init = function () { - if (this._events === undefined || this._events === Object.getPrototypeOf(this)._events) { - this._events = Object.create(null); +// EventEmitter must be a standard function because some old code will do weird tricks like `EventEmitter.$apply(this)`. +const EventEmitter = function EventEmitter(opts) { + if (this._events === undefined || this._events === this.__proto__._events) { + this._events = { __proto__: null }; this._eventsCount = 0; } - this._maxListeners = this._maxListeners || undefined; -}; - -// Obviously not all Emitters should be limited to 10. This function allows -// that to be increased. Set to zero for unlimited. -EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) { - if (typeof n !== "number" || n < 0 || NumberIsNaN(n)) { - throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + "."); + this._maxListeners ??= undefined; + if ((this[kCapture] = opts?.captureRejections ? Boolean(opts?.captureRejections) : EventEmitterPrototype[kCapture])) { + this.emit = emitWithRejectionCapture; } +}; +const EventEmitterPrototype = (EventEmitter.prototype = {}); + +EventEmitterPrototype._events = undefined; +EventEmitterPrototype._eventsCount = 0; +EventEmitterPrototype._maxListeners = undefined; +EventEmitterPrototype.setMaxListeners = function setMaxListeners(n) { + validateNumber(n, "setMaxListeners", 0); this._maxListeners = n; return this; }; -function _getMaxListeners(that) { - if (that._maxListeners === undefined) return EventEmitter.defaultMaxListeners; - return that._maxListeners; -} +EventEmitterPrototype.constructor = EventEmitter; -EventEmitter.prototype.getMaxListeners = function getMaxListeners() { - return _getMaxListeners(this); +EventEmitterPrototype.getMaxListeners = function getMaxListeners() { + return this?._maxListeners ?? defaultMaxListeners; }; -EventEmitter.prototype.emit = function emit(type) { - var args = []; - for (var i = 1; i < arguments.length; i++) args.push(arguments[i]); - var doError = type === "error"; - - var events = this._events; - if (events !== undefined) doError = doError && events.error === undefined; - else if (!doError) return false; - - // If there is no 'error' event listener then throw. - if (doError) { - var er; - if (args.length > 0) er = args[0]; - if (er instanceof Error) { - // Note: The comments on the `throw` lines are intentional, they show - // up in Node's output if this results in an unhandled exception. - throw er; // Unhandled 'error' event +function emitError(emitter, args) { + var { _events: events } = emitter; + args[0] ??= new Error("Unhandled error."); + if (!events) throw args[0]; + var errorMonitor = events[kErrorMonitor]; + if (errorMonitor) { + for (var handler of ArrayPrototypeSlice.$call(errorMonitor)) { + handler.$apply(emitter, args); } - // At least give some kind of context to the user - var err = new Error("Unhandled error." + (er ? " (" + er.message + ")" : "")); - err.context = er; - throw err; // Unhandled 'error' event } - - var handler = events[type]; - - if (handler === undefined) return false; - - if (typeof handler === "function") { - ReflectApply(handler, this, args); - } else { - var len = handler.length; - var listeners = arrayClone(handler, len); - for (var i = 0; i < len; ++i) ReflectApply(listeners[i], this, args); + var handlers = events.error; + if (!handlers) throw args[0]; + for (var handler of ArrayPrototypeSlice.$call(handlers)) { + handler.$apply(emitter, args); } - return true; -}; - -function _addListener(target, type, listener, prepend) { - var m; - var events; - var existing; - - checkListener(listener); - - events = target._events; - if (events === undefined) { - events = target._events = Object.create(null); - target._eventsCount = 0; - } else { - // To avoid recursion in the case that type === "newListener"! Before - // adding it to the listeners, first emit "newListener". - if (events.newListener !== undefined) { - target.emit("newListener", type, listener.listener ? listener.listener : listener); - - // Re-assign `events` because a newListener handler could have caused the - // this._events to be assigned to a new object - events = target._events; - } - existing = events[type]; - } - - if (existing === undefined) { - // Optimize the case of one listener. Don't need the extra array object. - existing = events[type] = listener; - ++target._eventsCount; - } else { - if (typeof existing === "function") { - // Adding the second element, need to change to array. - existing = events[type] = prepend ? [listener, existing] : [existing, listener]; - // If we've already got an array, just append. - } else if (prepend) { - existing.unshift(listener); - } else { - existing.push(listener); - } - - // Check for listener leak - m = _getMaxListeners(target); - if (m > 0 && existing.length > m && !existing.warned) { - existing.warned = true; - // No error code for this since it is a Warning - // eslint-disable-next-line no-restricted-syntax - var w = new Error( - "Possible EventEmitter memory leak detected. " + - existing.length + - " " + - String(type) + - " listeners " + - "added. Use emitter.setMaxListeners() to " + - "increase limit", - ); - w.name = "MaxListenersExceededWarning"; - w.emitter = target; - w.type = type; - w.count = existing.length; - ProcessEmitWarning(w); - } - } - - return target; } -EventEmitter.prototype.addListener = function addListener(type, listener) { - return _addListener(this, type, listener, false); -}; - -EventEmitter.prototype.on = EventEmitter.prototype.addListener; - -EventEmitter.prototype.prependListener = function prependListener(type, listener) { - return _addListener(this, type, listener, true); -}; - -function onceWrapper() { - if (!this.fired) { - this.target.removeListener(this.type, this.wrapFn); - this.fired = true; - if (arguments.length === 0) return this.listener.call(this.target); - return this.listener.apply(this.target, arguments); - } -} - -function _onceWrap(target, type, listener) { - var state = { - fired: false, - wrapFn: undefined, - target: target, - type: type, - listener: listener, - }; - var wrapped = onceWrapper.bind(state); - wrapped.listener = listener; - state.wrapFn = wrapped; - return wrapped; -} - -EventEmitter.prototype.once = function once(type, listener) { - checkListener(listener); - this.on(type, _onceWrap(this, type, listener)); - return this; -}; - -EventEmitter.prototype.prependOnceListener = function prependOnceListener(type, listener) { - checkListener(listener); - this.prependListener(type, _onceWrap(this, type, listener)); - return this; -}; - -// Emits a 'removeListener' event if and only if the listener was removed. -EventEmitter.prototype.removeListener = function removeListener(type, listener) { - var list, events, position, i, originalListener; - - checkListener(listener); - - events = this._events; - if (events === undefined) return this; - - list = events[type]; - if (list === undefined) return this; - - if (list === listener || list.listener === listener) { - if (--this._eventsCount === 0) this._events = Object.create(null); - else { - delete events[type]; - if (events.removeListener) this.emit("removeListener", type, list.listener || listener); - } - } else if (typeof list !== "function") { - position = -1; - - for (i = list.length - 1; i >= 0; i--) { - if (list[i] === listener || list[i].listener === listener) { - originalListener = list[i].listener; - position = i; - break; - } - } - - if (position < 0) return this; - - if (position === 0) list.shift(); - else { - spliceOne(list, position); - } - - if (list.length === 1) events[type] = list[0]; - - if (events.removeListener !== undefined) this.emit("removeListener", type, originalListener || listener); - } - - return this; -}; - -EventEmitter.prototype.off = EventEmitter.prototype.removeListener; - -EventEmitter.prototype.removeAllListeners = function removeAllListeners(type) { - var listeners, events, i; - - events = this._events; - if (events === undefined) return this; - - // not listening for removeListener, no need to emit - if (events.removeListener === undefined) { - if (arguments.length === 0) { - this._events = Object.create(null); - this._eventsCount = 0; - } else if (events[type] !== undefined) { - if (--this._eventsCount === 0) this._events = Object.create(null); - else delete events[type]; - } - return this; - } - - // emit removeListener for all listeners on all events - if (arguments.length === 0) { - var keys = Object.keys(events); - var key; - for (i = 0; i < keys.length; ++i) { - key = keys[i]; - if (key === "removeListener") continue; - this.removeAllListeners(key); - } - this.removeAllListeners("removeListener"); - this._events = Object.create(null); - this._eventsCount = 0; - return this; - } - - listeners = events[type]; - - if (typeof listeners === "function") { - this.removeListener(type, listeners); - } else if (listeners !== undefined) { - // LIFO order - for (i = listeners.length - 1; i >= 0; i--) { - this.removeListener(type, listeners[i]); - } - } - - return this; -}; - -function _listeners(target, type, unwrap) { - var events = target._events; - - if (events === undefined) return []; - - var evlistener = events[type]; - if (evlistener === undefined) return []; - - if (typeof evlistener === "function") return unwrap ? [evlistener.listener || evlistener] : [evlistener]; - - return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length); -} - -EventEmitter.prototype.listeners = function listeners(type) { - return _listeners(this, type, true); -}; - -EventEmitter.prototype.rawListeners = function rawListeners(type) { - return _listeners(this, type, false); -}; - -EventEmitter.listenerCount = function (emitter, type) { - if (typeof emitter.listenerCount === "function") { - return emitter.listenerCount(type); - } else { - return listenerCount.call(emitter, type); - } -}; - -EventEmitter.prototype.listenerCount = listenerCount; -function listenerCount(type) { - var events = this._events; - - if (events !== undefined) { - var evlistener = events[type]; - - if (typeof evlistener === "function") { - return 1; - } else if (evlistener !== undefined) { - return evlistener.length; - } - } - - return 0; -} - -EventEmitter.prototype.eventNames = function eventNames() { - return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : []; -}; - -function arrayClone(arr, n) { - var copy = new Array(n); - for (var i = 0; i < n; ++i) copy[i] = arr[i]; - return copy; -} - -function spliceOne(list, index) { - for (; index + 1 < list.length; index++) list[index] = list[index + 1]; - list.pop(); -} - -function unwrapListeners(arr) { - var ret = new Array(arr.length); - for (var i = 0; i < ret.length; ++i) { - ret[i] = arr[i].listener || arr[i]; - } - return ret; -} - -function once(emitter, name) { - return new Promise(function (resolve, reject) { - function errorListener(err) { - emitter.removeListener(name, resolver); - reject(err); - } - - function resolver() { - if (typeof emitter.removeListener === "function") { - emitter.removeListener("error", errorListener); - } - resolve([].slice.call(arguments)); - } - - eventTargetAgnosticAddListener(emitter, name, resolver, { once: true }); - if (name !== "error") { - addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true }); - } +function addCatch(emitter, promise, type, args) { + promise.then(undefined, function (err) { + // The callback is called with nextTick to avoid a follow-up rejection from this promise. + process.nextTick(emitUnhandledRejectionOrErr, emitter, err, type, args); }); } -function addErrorHandlerIfEventEmitter(emitter, handler, flags) { - if (typeof emitter.on === "function") { - eventTargetAgnosticAddListener(emitter, "error", handler, flags); +function emitUnhandledRejectionOrErr(emitter, err, type, args) { + if (typeof emitter[kRejection] === "function") { + emitter[kRejection](err, type, ...args); + } else { + // If the error handler throws, it is not catchable and it will end up in 'uncaughtException'. + // We restore the previous value of kCapture in case the uncaughtException is present + // and the exception is handled. + try { + emitter[kCapture] = false; + emitter.emit("error", err); + } finally { + emitter[kCapture] = true; + } + } +} + +const emitWithoutRejectionCapture = function emit(type, ...args) { + if (type === "error") { + return emitError(this, args); + } + var { _events: events } = this; + if (events === undefined) return false; + var handlers = events[type]; + if (handlers === undefined) return false; + // Clone handlers array if necessary since handlers can be added/removed during the loop. + // Cloning is skipped for performance reasons in the case of exactly one attached handler + // since array length changes have no side-effects in a for-loop of length 1. + const maybeClonedHandlers = handlers.length > 1 ? handlers.slice() : handlers; + for (let i = 0, { length } = maybeClonedHandlers; i < length; i++) { + const handler = maybeClonedHandlers[i]; + // For performance reasons Function.call(...) is used whenever possible. + switch (args.length) { + case 0: + handler.$call(this); + break; + case 1: + handler.$call(this, args[0]); + break; + case 2: + handler.$call(this, args[0], args[1]); + break; + case 3: + handler.$call(this, args[0], args[1], args[2]); + break; + default: + handler.$apply(this, args); + break; + } + } + return true; +}; + +const emitWithRejectionCapture = function emit(type, ...args) { + if (type === "error") { + return emitError(this, args); + } + var { _events: events } = this; + if (events === undefined) return false; + var handlers = events[type]; + if (handlers === undefined) return false; + // Clone handlers array if necessary since handlers can be added/removed during the loop. + // Cloning is skipped for performance reasons in the case of exactly one attached handler + // since array length changes have no side-effects in a for-loop of length 1. + const maybeClonedHandlers = handlers.length > 1 ? handlers.slice() : handlers; + for (let i = 0, { length } = maybeClonedHandlers; i < length; i++) { + const handler = maybeClonedHandlers[i]; + let result; + // For performance reasons Function.call(...) is used whenever possible. + switch (args.length) { + case 0: + result = handler.$call(this); + break; + case 1: + result = handler.$call(this, args[0]); + break; + case 2: + result = handler.$call(this, args[0], args[1]); + break; + case 3: + result = handler.$call(this, args[0], args[1], args[2]); + break; + default: + result = handler.$apply(this, args); + break; + } + if (result !== undefined && $isPromise(result)) { + addCatch(this, result, type, args); + } + } + return true; +}; + +EventEmitterPrototype.emit = emitWithoutRejectionCapture; + +EventEmitterPrototype.addListener = function addListener(type, fn) { + checkListener(fn); + var events = this._events; + if (!events) { + events = this._events = { __proto__: null }; + this._eventsCount = 0; + } else if (events.newListener) { + this.emit("newListener", type, fn.listener ?? fn); + } + var handlers = events[type]; + if (!handlers) { + events[type] = [fn]; + this._eventsCount++; + } else { + handlers.push(fn); + var m = this._maxListeners ?? defaultMaxListeners; + if (m > 0 && handlers.length > m && !handlers.warned) { + overflowWarning(this, type, handlers); + } + } + return this; +}; + +EventEmitterPrototype.on = EventEmitterPrototype.addListener; + +EventEmitterPrototype.prependListener = function prependListener(type, fn) { + checkListener(fn); + var events = this._events; + if (!events) { + events = this._events = { __proto__: null }; + this._eventsCount = 0; + } else if (events.newListener) { + this.emit("newListener", type, fn.listener ?? fn); + } + var handlers = events[type]; + if (!handlers) { + events[type] = [fn]; + this._eventsCount++; + } else { + handlers.unshift(fn); + var m = this._maxListeners ?? defaultMaxListeners; + if (m > 0 && handlers.length > m && !handlers.warned) { + overflowWarning(this, type, handlers); + } + } + return this; +}; + +function overflowWarning(emitter, type, handlers) { + handlers.warned = true; + const warn = new Error( + `Possible EventEmitter memory leak detected. ${handlers.length} ${String(type)} listeners ` + + `added to [${emitter.constructor.name}]. Use emitter.setMaxListeners() to increase limit`, + ); + warn.name = "MaxListenersExceededWarning"; + warn.emitter = emitter; + warn.type = type; + warn.count = handlers.length; + process.emitWarning(warn); +} + +function onceWrapper(type, listener, ...args) { + this.removeListener(type, listener); + listener.$apply(this, args); +} + +EventEmitterPrototype.once = function once(type, fn) { + checkListener(fn); + const bound = onceWrapper.bind(this, type, fn); + bound.listener = fn; + this.addListener(type, bound); + return this; +}; + +EventEmitterPrototype.prependOnceListener = function prependOnceListener(type, fn) { + checkListener(fn); + const bound = onceWrapper.bind(this, type, fn); + bound.listener = fn; + this.prependListener(type, bound); + return this; +}; + +EventEmitterPrototype.removeListener = function removeListener(type, fn) { + checkListener(fn); + var { _events: events } = this; + if (!events) return this; + var handlers = events[type]; + if (!handlers) return this; + var length = handlers.length; + let position = -1; + for (let i = length - 1; i >= 0; i--) { + if (handlers[i] === fn || handlers[i].listener === fn) { + position = i; + break; + } + } + if (position < 0) return this; + if (position === 0) { + handlers.shift(); + } else { + handlers.splice(position, 1); + } + if (handlers.length === 0) { + delete events[type]; + this._eventsCount--; + } + return this; +}; + +EventEmitterPrototype.off = EventEmitterPrototype.removeListener; + +EventEmitterPrototype.removeAllListeners = function removeAllListeners(type) { + var { _events: events } = this; + if (type && events) { + if (events[type]) { + delete events[type]; + this._eventsCount--; + } + } else { + this._events = { __proto__: null }; + } + return this; +}; + +EventEmitterPrototype.listeners = function listeners(type) { + var { _events: events } = this; + if (!events) return []; + var handlers = events[type]; + if (!handlers) return []; + return handlers.map(x => x.listener ?? x); +}; + +EventEmitterPrototype.rawListeners = function rawListeners(type) { + var { _events } = this; + if (!_events) return []; + var handlers = _events[type]; + if (!handlers) return []; + return handlers.slice(); +}; + +EventEmitterPrototype.listenerCount = function listenerCount(type) { + var { _events: events } = this; + if (!events) return 0; + return events[type]?.length ?? 0; +}; + +EventEmitterPrototype.eventNames = function eventNames() { + return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : []; +}; + +EventEmitterPrototype[kCapture] = false; + +function once(emitter, type, options) { + var signal = options?.signal; + validateAbortSignal(signal, "options.signal"); + if (signal?.aborted) { + throw new AbortError(undefined, { cause: signal?.reason }); + } + const { resolve, reject, promise } = $newPromiseCapability(Promise); + const errorListener = err => { + emitter.removeListener(type, resolver); + if (signal != null) { + eventTargetAgnosticRemoveListener(signal, "abort", abortListener); + } + reject(err); + }; + const resolver = (...args) => { + if (typeof emitter.removeListener === "function") { + emitter.removeListener("error", errorListener); + } + if (signal != null) { + eventTargetAgnosticRemoveListener(signal, "abort", abortListener); + } + resolve(args); + }; + eventTargetAgnosticAddListener(emitter, type, resolver, { once: true }); + if (type !== "error" && typeof emitter.once === "function") { + // EventTarget does not have `error` event semantics like Node + // EventEmitters, we listen to `error` events only on EventEmitters. + emitter.once("error", errorListener); + } + function abortListener() { + eventTargetAgnosticRemoveListener(emitter, type, resolver); + eventTargetAgnosticRemoveListener(emitter, "error", errorListener); + reject(new AbortError(undefined, { cause: signal?.reason })); + } + if (signal != null) { + eventTargetAgnosticAddListener(signal, "abort", abortListener, { once: true }); + } + + return promise; +} + +function getEventListeners(emitter, type) { + return emitter.listeners(type); +} + +function setMaxListeners(n, ...eventTargets) { + validateNumber(n, "setMaxListeners", 0); + var length; + if (eventTargets && (length = eventTargets.length)) { + for (let i = 0; i < length; i++) { + eventTargets[i].setMaxListeners(n); + } + } else { + defaultMaxListeners = n; + } +} + +function listenerCount(emitter, type) { + return emitter.listenerCount(type); +} + +function eventTargetAgnosticRemoveListener(emitter, name, listener, flags) { + if (typeof emitter.removeListener === "function") { + emitter.removeListener(name, listener); + } else { + emitter.removeEventListener(name, listener, flags); } } function eventTargetAgnosticAddListener(emitter, name, listener, flags) { if (typeof emitter.on === "function") { - if (flags.once) { - emitter.once(name, listener); - } else { - emitter.on(name, listener); - } - } else if (typeof emitter.addEventListener === "function") { - // EventTarget does not have `error` event semantics like Node - // EventEmitters, we do not listen for `error` events here. - emitter.addEventListener(name, function wrapListener(arg) { - // IE does not have builtin `{ once: true }` support so we - // have to do it manually. - if (flags.once) { - emitter.removeEventListener(name, wrapListener); - } - listener(arg); - }); + if (flags.once) emitter.once(name, listener); + else emitter.on(name, listener); } else { - throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter); + emitter.addEventListener(name, listener, flags); } } +class AbortError extends Error { + constructor(message = "The operation was aborted", options = undefined) { + if (options !== undefined && typeof options !== "object") { + throw ERR_INVALID_ARG_TYPE("options", "Object", options); + } + super(message, options); + this.code = "ABORT_ERR"; + this.name = "AbortError"; + } +} + +function ERR_INVALID_ARG_TYPE(name, type, value) { + const err = new TypeError(`The "${name}" argument must be of type ${type}. Received ${value}`); + err.code = "ERR_INVALID_ARG_TYPE"; + return err; +} + +function ERR_OUT_OF_RANGE(name, range, value) { + const err = new RangeError(`The "${name}" argument is out of range. It must be ${range}. Received ${value}`); + err.code = "ERR_OUT_OF_RANGE"; + return err; +} + +function validateAbortSignal(signal, name) { + if (signal !== undefined && (signal === null || typeof signal !== "object" || !("aborted" in signal))) { + throw ERR_INVALID_ARG_TYPE(name, "AbortSignal", signal); + } +} + +function validateNumber(value, name, min, max) { + if (typeof value !== "number") throw ERR_INVALID_ARG_TYPE(name, "number", value); + if ( + (min != null && value < min) || + (max != null && value > max) || + ((min != null || max != null) && Number.isNaN(value)) + ) { + throw ERR_OUT_OF_RANGE( + name, + `${min != null ? `>= ${min}` : ""}${min != null && max != null ? " && " : ""}${max != null ? `<= ${max}` : ""}`, + value, + ); + } +} + +function checkListener(listener) { + if (typeof listener !== "function") { + throw new TypeError("The listener must be a function"); + } +} + +function validateBoolean(value, name) { + if (typeof value !== "boolean") throw ERR_INVALID_ARG_TYPE(name, "boolean", value); +} + +function getMaxListeners(emitterOrTarget) { + return emitterOrTarget?._maxListeners ?? defaultMaxListeners; +} + +// Copy-pasta from Node.js source code +function addAbortListener(signal, listener) { + if (signal === undefined) { + throw ERR_INVALID_ARG_TYPE("signal", "AbortSignal", signal); + } + + validateAbortSignal(signal, "signal"); + if (typeof listener !== "function") { + throw ERR_INVALID_ARG_TYPE("listener", "function", listener); + } + + let removeEventListener; + if (signal.aborted) { + queueMicrotask(() => listener()); + } else { + signal.addEventListener("abort", listener, { __proto__: null, once: true }); + removeEventListener = () => { + signal.removeEventListener("abort", listener); + }; + } + return { + __proto__: null, + [Symbol.dispose]() { + removeEventListener?.(); + }, + }; +} + +Object.defineProperties(EventEmitter, { + captureRejections: { + get() { + return EventEmitterPrototype[kCapture]; + }, + set(value) { + validateBoolean(value, "EventEmitter.captureRejections"); + + EventEmitterPrototype[kCapture] = value; + }, + enumerable: true, + }, + defaultMaxListeners: { + enumerable: true, + get: () => { + return defaultMaxListeners; + }, + set: arg => { + validateNumber(arg, "defaultMaxListeners", 0); + defaultMaxListeners = arg; + }, + }, + kMaxEventTargetListeners: { + value: kMaxEventTargetListeners, + enumerable: false, + configurable: false, + writable: false, + }, + kMaxEventTargetListenersWarned: { + value: kMaxEventTargetListenersWarned, + enumerable: false, + configurable: false, + writable: false, + }, +}); +Object.assign(EventEmitter, { + once, + // on, + getEventListeners, + getMaxListeners, + setMaxListeners, + EventEmitter, + usingDomains: false, + captureRejectionSymbol, + errorMonitor: kErrorMonitor, + addAbortListener, + init: EventEmitter, + listenerCount, +}); + export default EventEmitter; -export { EventEmitter, once }; -export var prototype = EventEmitter.prototype; +export { + EventEmitter, + addAbortListener, + captureRejectionSymbol, + getEventListeners, + getMaxListeners, + EventEmitter as init, + listenerCount, + once, + setMaxListeners, +}; diff --git a/src/node-fallbacks/http.js b/src/node-fallbacks/http.js index 46c23595c2..1ac358b4eb 100644 --- a/src/node-fallbacks/http.js +++ b/src/node-fallbacks/http.js @@ -1,18 +1,2 @@ -/** - * Browser polyfill for the `"http"` module. - * - * Imported on usage in `bun build --target=browser` - */ import http from "stream-http"; -export default http; -export var { - // - request, - get, - ClientRequest, - IncomingMessage, - Agent, - globalAgent, - STATUS_CODES, - METHODS, -} = http; +export var { request, get, ClientRequest, IncomingMessage, Agent, globalAgent, STATUS_CODES, METHODS } = http; diff --git a/src/node-fallbacks/https.js b/src/node-fallbacks/https.js index 228e9dd686..92460d5c82 100644 --- a/src/node-fallbacks/https.js +++ b/src/node-fallbacks/https.js @@ -1,7 +1,19 @@ -/** - * Browser polyfill for the `"https"` module. - * - * Imported on usage in `bun build --target=browser` - */ -export * from "https-browserify"; -export * as default from "https-browserify"; +import * as https from "https-browserify"; +export var { + Agent, + ClientRequest, + IncomingMessage, + METHODS, + OutgoingMessage, + STATUS_CODES, + Server, + ServerResponse, + createServer, + get, + globalAgent, + maxHeaderSize, + request, + setMaxIdleHTTPParsers, + validateHeaderName, + validateHeaderValue, +} = https; diff --git a/src/node-fallbacks/net.js b/src/node-fallbacks/net.js index 03221037fa..746e07415a 100644 --- a/src/node-fallbacks/net.js +++ b/src/node-fallbacks/net.js @@ -1,9 +1,3 @@ -/** - * Browser polyfill for the `"net"` module. - * - * Imported on usage in `bun build --target=browser` - */ -// ----------------------------------------------------------------------------- // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -28,11 +22,11 @@ // IPv4 Segment const v4Seg = "(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])"; const v4Str = `(?:${v4Seg}\\.){3}${v4Seg}`; -const IPv4Reg = new RegExp(`^${v4Str}$`); +const IPv4Reg = /* @__PURE__ */ new RegExp(`^${v4Str}$`); // IPv6 Segment const v6Seg = "(?:[0-9a-fA-F]{1,4})"; -const IPv6Reg = new RegExp( +const IPv6Reg = /* @__PURE__ */ new RegExp( "^(?:" + `(?:${v6Seg}:){7}(?:${v6Seg}|:)|` + `(?:${v6Seg}:){6}(?:${v4Str}|:${v6Seg}|:)|` + @@ -58,9 +52,3 @@ export function isIP(s) { if (isIPv6(s)) return 6; return 0; } - -export default { - isIP, - isIPv4, - isIPv6, -}; diff --git a/src/node-fallbacks/os.js b/src/node-fallbacks/os.js index ec627a9540..6cf5e308b9 100644 --- a/src/node-fallbacks/os.js +++ b/src/node-fallbacks/os.js @@ -1,26 +1,64 @@ -/** - * Browser polyfill for the `"os"` module. - * - * Imported on usage in `bun build --target=browser` - */ +export const endianness = function () { + return "LE"; +}; -import os from "os-browserify/browser"; -export default os; -export var { - endianness, - hostname, - loadavg, - uptime, - freemem, - totalmem, - cpus, - type, - release, - arch, - platform, - tmpdir, - EOL, - homedir, - networkInterfaces, - getNetworkInterfaces, -} = os; +export const hostname = function () { + if (typeof location !== "undefined") { + return location.hostname; + } else return ""; +}; + +export const loadavg = function () { + return []; +}; + +export const uptime = function () { + return 0; +}; + +export const freemem = function () { + return Number.MAX_VALUE; +}; + +export const totalmem = function () { + return Number.MAX_VALUE; +}; + +export const cpus = function () { + return []; +}; + +export const type = function () { + return "Browser"; +}; + +export const release = function () { + if (typeof navigator !== "undefined") { + return navigator.appVersion; + } + return ""; +}; + +export const getNetworkInterfaces = function () { + return {}; +}; +export const networkInterfaces = getNetworkInterfaces; + +export const arch = function () { + return "javascript"; +}; + +export const platform = function () { + return "browser"; +}; + +export const tmpdir = function () { + return "/tmp"; +}; +export const tmpDir = tmpdir; + +export const EOL = "\n"; + +export const homedir = function () { + return "/"; +}; diff --git a/src/node-fallbacks/package.json b/src/node-fallbacks/package.json index 99dedbb47b..5e04a633bb 100644 --- a/src/node-fallbacks/package.json +++ b/src/node-fallbacks/package.json @@ -5,36 +5,38 @@ "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "build-gen": "bash -c 'esbuild --bundle *.js --outdir=bun --format=esm --platform=browser --external:buffer --external:stream --external:util --external:util/ --external:assert'", - "build": "bash -c 'esbuild --bundle *.js --outdir=out --format=esm --minify --platform=browser'", - "build-react-refresh": "NODE_ENV=development bun build --target=browser --external=* --format=cjs --outfile=out/react-refresh.js ./node_modules/react-refresh/cjs/react-refresh-runtime.development.js --define=process.env.NODE_ENV=development --minify" + "build-gen": "bun build-fallbacks.ts", + "build": "bun run build-gen" }, "author": "", "license": "ISC", "dependencies": { - "assert": "^2.0.0", + "assert": "^2.1.0", + "react-refresh": "0.17.0", "browserify-zlib": "^0.2.0", "buffer": "^6.0.3", "console-browserify": "^1.2.0", "constants-browserify": "^1.0.0", - "crypto-browserify": "^3.12.0", - "domain-browser": "^4.22.0", - "esbuild": "^0.14.10", + "crypto-browserify": "^3.12.1", + "domain-browser": "^4.23.0", + "esbuild": "^0.25.4", "events": "^3.3.0", "https-browserify": "^1.0.0", "os-browserify": "^0.3.0", "path-browserify": "^1.0.1", "process": "^0.11.10", - "punycode": "^2.1.1", + "punycode": "^2.3.1", "querystring-es3": "^1.0.0-0", - "react-refresh": "^0.16.0", - "readable-stream": "^4.1.0", + "readable-stream": "^4.5.2", "stream-http": "^3.2.0", "string_decoder": "^1.3.0", "timers-browserify": "^2.0.12", "tty-browserify": "^0.0.1", - "url": "^0.11.0", - "util": "^0.12.4", + "url": "^0.11.4", + "util": "^0.12.5", "vm-browserify": "^1.1.2" + }, + "overrides": { + "readable-stream": "^4.5.2" } } diff --git a/src/node-fallbacks/path.js b/src/node-fallbacks/path.js index 66e4d05ea2..4e2a930d4c 100644 --- a/src/node-fallbacks/path.js +++ b/src/node-fallbacks/path.js @@ -1,61 +1,523 @@ -/** - * Browser polyfill for the `"path"` module. - * - * Imported on usage in `bun build --target=browser` - */ -import * as PathModule from "path-browserify"; +// 'path' module extracted from Node.js v8.11.1 (only the posix part) +// transplited with Babel -const bindingPosix = PathModule; -const bindingWin32 = PathModule; +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. -// path-browserify doesn't implement toNamespacedPath -const toNamespacedPathPosix = function (a) { - return a; -}; -// path-browserify doesn't implement parse -const parseFn = function () { - throw new Error("Not implemented"); -}; +"use strict"; -bindingPosix.parse ??= parseFn; -bindingWin32.parse ??= parseFn; +function assertPath(path) { + if (typeof path !== "string") { + throw new TypeError("Path must be a string. Received " + JSON.stringify(path)); + } +} -export const posix = { - resolve: bindingPosix.resolve.bind(bindingPosix), - normalize: bindingPosix.normalize.bind(bindingPosix), - isAbsolute: bindingPosix.isAbsolute.bind(bindingPosix), - join: bindingPosix.join.bind(bindingPosix), - relative: bindingPosix.relative.bind(bindingPosix), - toNamespacedPath: toNamespacedPathPosix, - dirname: bindingPosix.dirname.bind(bindingPosix), - basename: bindingPosix.basename.bind(bindingPosix), - extname: bindingPosix.extname.bind(bindingPosix), - format: bindingPosix.format.bind(bindingPosix), - parse: bindingPosix.parse.bind(bindingPosix), - sep: "/", - delimiter: ":", - win32: undefined, - posix: undefined, - _makeLong: toNamespacedPathPosix, -}; -export const win32 = { - sep: "\\", - delimiter: ";", - win32: undefined, - ...posix, - posix, -}; -posix.win32 = win32.win32 = win32; -posix.posix = posix; +// Resolves . and .. elements in a path with directory names +function normalizeStringPosix(path, allowAboveRoot) { + var res = ""; + var lastSegmentLength = 0; + var lastSlash = -1; + var dots = 0; + var code; + for (var i = 0; i <= path.length; ++i) { + if (i < path.length) code = path.charCodeAt(i); + else if (code === 47 /*/*/) break; + else code = 47 /*/*/; + if (code === 47 /*/*/) { + if (lastSlash === i - 1 || dots === 1) { + // NOOP + } else if (lastSlash !== i - 1 && dots === 2) { + if ( + res.length < 2 || + lastSegmentLength !== 2 || + res.charCodeAt(res.length - 1) !== 46 /*.*/ || + res.charCodeAt(res.length - 2) !== 46 /*.*/ + ) { + if (res.length > 2) { + var lastSlashIndex = res.lastIndexOf("/"); + if (lastSlashIndex !== res.length - 1) { + if (lastSlashIndex === -1) { + res = ""; + lastSegmentLength = 0; + } else { + res = res.slice(0, lastSlashIndex); + lastSegmentLength = res.length - 1 - res.lastIndexOf("/"); + } + lastSlash = i; + dots = 0; + continue; + } + } else if (res.length === 2 || res.length === 1) { + res = ""; + lastSegmentLength = 0; + lastSlash = i; + dots = 0; + continue; + } + } + if (allowAboveRoot) { + if (res.length > 0) res += "/.."; + else res = ".."; + lastSegmentLength = 2; + } + } else { + if (res.length > 0) res += "/" + path.slice(lastSlash + 1, i); + else res = path.slice(lastSlash + 1, i); + lastSegmentLength = i - lastSlash - 1; + } + lastSlash = i; + dots = 0; + } else if (code === 46 /*.*/ && dots !== -1) { + ++dots; + } else { + dots = -1; + } + } + return res; +} -export default posix; -export const { +function _format(sep, pathObject) { + var dir = pathObject.dir || pathObject.root; + var base = pathObject.base || (pathObject.name || "") + (pathObject.ext || ""); + if (!dir) { + return base; + } + if (dir === pathObject.root) { + return dir + base; + } + return dir + sep + base; +} + +// path.resolve([from ...], to) +export function resolve() { + var resolvedPath = ""; + var resolvedAbsolute = false; + var cwd; + + for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) { + var path; + if (i >= 0) path = arguments[i]; + else { + if (cwd === undefined) cwd = process.cwd(); + path = cwd; + } + + assertPath(path); + + // Skip empty entries + if (path.length === 0) { + continue; + } + + resolvedPath = path + "/" + resolvedPath; + resolvedAbsolute = path.charCodeAt(0) === 47 /*/*/; + } + + // At this point the path should be resolved to a full absolute path, but + // handle relative paths to be safe (might happen when process.cwd() fails) + + // Normalize the path + resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute); + + if (resolvedAbsolute) { + if (resolvedPath.length > 0) return "/" + resolvedPath; + else return "/"; + } else if (resolvedPath.length > 0) { + return resolvedPath; + } else { + return "."; + } +} + +export function normalize(path) { + assertPath(path); + + if (path.length === 0) return "."; + + var isAbsolute = path.charCodeAt(0) === 47; /*/*/ + var trailingSeparator = path.charCodeAt(path.length - 1) === 47; /*/*/ + + // Normalize the path + path = normalizeStringPosix(path, !isAbsolute); + + if (path.length === 0 && !isAbsolute) path = "."; + if (path.length > 0 && trailingSeparator) path += "/"; + + if (isAbsolute) return "/" + path; + return path; +} + +export function isAbsolute(path) { + assertPath(path); + return path.length > 0 && path.charCodeAt(0) === 47 /*/*/; +} + +export function join() { + if (arguments.length === 0) return "."; + var joined; + for (var i = 0; i < arguments.length; ++i) { + var arg = arguments[i]; + assertPath(arg); + if (arg.length > 0) { + if (joined === undefined) joined = arg; + else joined += "/" + arg; + } + } + if (joined === undefined) return "."; + return normalize(joined); +} + +export function relative(from, to) { + assertPath(from); + assertPath(to); + + if (from === to) return ""; + + from = resolve(from); + to = resolve(to); + + if (from === to) return ""; + + // Trim any leading backslashes + var fromStart = 1; + for (; fromStart < from.length; ++fromStart) { + if (from.charCodeAt(fromStart) !== 47 /*/*/) break; + } + var fromEnd = from.length; + var fromLen = fromEnd - fromStart; + + // Trim any leading backslashes + var toStart = 1; + for (; toStart < to.length; ++toStart) { + if (to.charCodeAt(toStart) !== 47 /*/*/) break; + } + var toEnd = to.length; + var toLen = toEnd - toStart; + + // Compare paths to find the longest common path from root + var length = fromLen < toLen ? fromLen : toLen; + var lastCommonSep = -1; + var i = 0; + for (; i <= length; ++i) { + if (i === length) { + if (toLen > length) { + if (to.charCodeAt(toStart + i) === 47 /*/*/) { + // We get here if `from` is the exact base path for `to`. + // For example: from='/foo/bar'; to='/foo/bar/baz' + return to.slice(toStart + i + 1); + } else if (i === 0) { + // We get here if `from` is the root + // For example: from='/'; to='/foo' + return to.slice(toStart + i); + } + } else if (fromLen > length) { + if (from.charCodeAt(fromStart + i) === 47 /*/*/) { + // We get here if `to` is the exact base path for `from`. + // For example: from='/foo/bar/baz'; to='/foo/bar' + lastCommonSep = i; + } else if (i === 0) { + // We get here if `to` is the root. + // For example: from='/foo'; to='/' + lastCommonSep = 0; + } + } + break; + } + var fromCode = from.charCodeAt(fromStart + i); + var toCode = to.charCodeAt(toStart + i); + if (fromCode !== toCode) break; + else if (fromCode === 47 /*/*/) lastCommonSep = i; + } + + var out = ""; + // Generate the relative path based on the path difference between `to` + // and `from` + for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) { + if (i === fromEnd || from.charCodeAt(i) === 47 /*/*/) { + if (out.length === 0) out += ".."; + else out += "/.."; + } + } + + // Lastly, append the rest of the destination (`to`) path that comes after + // the common path parts + if (out.length > 0) return out + to.slice(toStart + lastCommonSep); + else { + toStart += lastCommonSep; + if (to.charCodeAt(toStart) === 47 /*/*/) ++toStart; + return to.slice(toStart); + } +} + +export function _makeLong(path) { + return path; +} + +export function dirname(path) { + assertPath(path); + if (path.length === 0) return "."; + var code = path.charCodeAt(0); + var hasRoot = code === 47; /*/*/ + var end = -1; + var matchedSlash = true; + for (var i = path.length - 1; i >= 1; --i) { + code = path.charCodeAt(i); + if (code === 47 /*/*/) { + if (!matchedSlash) { + end = i; + break; + } + } else { + // We saw the first non-path separator + matchedSlash = false; + } + } + + if (end === -1) return hasRoot ? "/" : "."; + if (hasRoot && end === 1) return "//"; + return path.slice(0, end); +} + +export function basename(path, ext) { + if (ext !== undefined && typeof ext !== "string") throw new TypeError('"ext" argument must be a string'); + assertPath(path); + + var start = 0; + var end = -1; + var matchedSlash = true; + var i; + + if (ext !== undefined && ext.length > 0 && ext.length <= path.length) { + if (ext.length === path.length && ext === path) return ""; + var extIdx = ext.length - 1; + var firstNonSlashEnd = -1; + for (i = path.length - 1; i >= 0; --i) { + var code = path.charCodeAt(i); + if (code === 47 /*/*/) { + // If we reached a path separator that was not part of a set of path + // separators at the end of the string, stop now + if (!matchedSlash) { + start = i + 1; + break; + } + } else { + if (firstNonSlashEnd === -1) { + // We saw the first non-path separator, remember this index in case + // we need it if the extension ends up not matching + matchedSlash = false; + firstNonSlashEnd = i + 1; + } + if (extIdx >= 0) { + // Try to match the explicit extension + if (code === ext.charCodeAt(extIdx)) { + if (--extIdx === -1) { + // We matched the extension, so mark this as the end of our path + // component + end = i; + } + } else { + // Extension does not match, so our result is the entire path + // component + extIdx = -1; + end = firstNonSlashEnd; + } + } + } + } + + if (start === end) end = firstNonSlashEnd; + else if (end === -1) end = path.length; + return path.slice(start, end); + } else { + for (i = path.length - 1; i >= 0; --i) { + if (path.charCodeAt(i) === 47 /*/*/) { + // If we reached a path separator that was not part of a set of path + // separators at the end of the string, stop now + if (!matchedSlash) { + start = i + 1; + break; + } + } else if (end === -1) { + // We saw the first non-path separator, mark this as the end of our + // path component + matchedSlash = false; + end = i + 1; + } + } + + if (end === -1) return ""; + return path.slice(start, end); + } +} + +export function extname(path) { + assertPath(path); + var startDot = -1; + var startPart = 0; + var end = -1; + var matchedSlash = true; + // Track the state of characters (if any) we see before our first dot and + // after any path separator we find + var preDotState = 0; + for (var i = path.length - 1; i >= 0; --i) { + var code = path.charCodeAt(i); + if (code === 47 /*/*/) { + // If we reached a path separator that was not part of a set of path + // separators at the end of the string, stop now + if (!matchedSlash) { + startPart = i + 1; + break; + } + continue; + } + if (end === -1) { + // We saw the first non-path separator, mark this as the end of our + // extension + matchedSlash = false; + end = i + 1; + } + if (code === 46 /*.*/) { + // If this is our first dot, mark it as the start of our extension + if (startDot === -1) startDot = i; + else if (preDotState !== 1) preDotState = 1; + } else if (startDot !== -1) { + // We saw a non-dot and non-path separator before our dot, so we should + // have a good chance at having a non-empty extension + preDotState = -1; + } + } + + if ( + startDot === -1 || + end === -1 || + // We saw a non-dot character immediately before the dot + preDotState === 0 || + // The (right-most) trimmed path component is exactly '..' + (preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) + ) { + return ""; + } + return path.slice(startDot, end); +} + +export function format(pathObject) { + if (pathObject === null || typeof pathObject !== "object") { + throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject); + } + return _format("/", pathObject); +} + +export function parse(path) { + assertPath(path); + + var ret = { root: "", dir: "", base: "", ext: "", name: "" }; + if (path.length === 0) return ret; + var code = path.charCodeAt(0); + var isAbsolute = code === 47; /*/*/ + var start; + if (isAbsolute) { + ret.root = "/"; + start = 1; + } else { + start = 0; + } + var startDot = -1; + var startPart = 0; + var end = -1; + var matchedSlash = true; + var i = path.length - 1; + + // Track the state of characters (if any) we see before our first dot and + // after any path separator we find + var preDotState = 0; + + // Get non-dir info + for (; i >= start; --i) { + code = path.charCodeAt(i); + if (code === 47 /*/*/) { + // If we reached a path separator that was not part of a set of path + // separators at the end of the string, stop now + if (!matchedSlash) { + startPart = i + 1; + break; + } + continue; + } + if (end === -1) { + // We saw the first non-path separator, mark this as the end of our + // extension + matchedSlash = false; + end = i + 1; + } + if (code === 46 /*.*/) { + // If this is our first dot, mark it as the start of our extension + if (startDot === -1) startDot = i; + else if (preDotState !== 1) preDotState = 1; + } else if (startDot !== -1) { + // We saw a non-dot and non-path separator before our dot, so we should + // have a good chance at having a non-empty extension + preDotState = -1; + } + } + + if ( + startDot === -1 || + end === -1 || + // We saw a non-dot character immediately before the dot + preDotState === 0 || + // The (right-most) trimmed path component is exactly '..' + (preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) + ) { + if (end !== -1) { + if (startPart === 0 && isAbsolute) ret.base = ret.name = path.slice(1, end); + else ret.base = ret.name = path.slice(startPart, end); + } + } else { + if (startPart === 0 && isAbsolute) { + ret.name = path.slice(1, startDot); + ret.base = path.slice(1, end); + } else { + ret.name = path.slice(startPart, startDot); + ret.base = path.slice(startPart, end); + } + ret.ext = path.slice(startDot, end); + } + + if (startPart > 0) ret.dir = path.slice(0, startPart - 1); + else if (isAbsolute) ret.dir = "/"; + + return ret; +} + +const sep = "/"; +const delimiter = ":"; + +// Use an IIFE to allow for tree-shaking +export const posix = /* @__PURE__ */ (p => ((p.posix = p), p))({ resolve, normalize, isAbsolute, join, relative, - toNamespacedPath, + _makeLong, dirname, basename, extname, @@ -63,4 +525,9 @@ export const { parse, sep, delimiter, -} = posix; + win32: null, + posix: null, +}); + +export { delimiter, sep }; +export default posix; diff --git a/src/node-fallbacks/process.js b/src/node-fallbacks/process.js index 17ebdf5381..78a0abba4d 100644 --- a/src/node-fallbacks/process.js +++ b/src/node-fallbacks/process.js @@ -1,7 +1,96 @@ -/** - * Browser polyfill for the `"process"` module. - * - * Imported on usage in `bun build --target=browser` - */ -export * from "process/browser"; -export * as default from "process/browser"; +// shim for using process in browser +var queue = []; +var draining = false; +var currentQueue; +var queueIndex = -1; + +function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } +} + +function drainQueue() { + if (draining) { + return; + } + var timeout = setTimeout(cleanUpNextTick, 0); + draining = true; + var len = queue.length; + while (len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + var item = currentQueue[queueIndex]; + item.fun.apply(null, item.array); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + clearTimeout(timeout, 0); +} + +export function nextTick(fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push({ fun, args }); + if (queue.length === 1 && !draining) { + setTimeout(drainQueue, 0); + } +} + +export const title = "browser"; +export const browser = true; +export const env = {}; +export const argv = []; +export const version = ""; // empty string to avoid regexp issues +export const versions = {}; + +function noop() {} + +export const on = noop; +export const addListener = noop; +export const once = noop; +export const off = noop; +export const removeListener = noop; +export const removeAllListeners = noop; +export const emit = noop; +export const prependListener = noop; +export const prependOnceListener = noop; + +export const listeners = function (name) { + return []; +}; + +export const binding = function (name) { + throw new Error("process.binding is not supported in browser polyfill"); +}; + +export const cwd = function () { + return "/"; +}; + +export const chdir = function (dir) { + throw new Error("process.chdir is not supported in browser polyfill"); +}; + +export const umask = function () { + return 0; +}; diff --git a/src/node-fallbacks/punycode.js b/src/node-fallbacks/punycode.js index 31a3dabf76..afbdd68212 100644 --- a/src/node-fallbacks/punycode.js +++ b/src/node-fallbacks/punycode.js @@ -1,6 +1,2 @@ -/** - * Browser polyfill for the `"punycode"` module. - * - * Imported on usage in `bun build --target=browser` - */ -export * from "punycode"; +export * from "./node_modules/punycode"; +export { default } from "./node_modules/punycode"; diff --git a/src/node-fallbacks/querystring.js b/src/node-fallbacks/querystring.js index b58917f2e1..a5b7d3e42a 100644 --- a/src/node-fallbacks/querystring.js +++ b/src/node-fallbacks/querystring.js @@ -1,6 +1,3 @@ -/** - * Browser polyfill for the `"querystring"` module. - * - * Imported on usage in `bun build --target=browser` - */ -export { decode, default, encode, escape, parse, stringify, unescape, unescapeBuffer } from "querystring-es3"; +import querystring_module from "querystring-es3"; +export var { unescapeBuffer, unescape, escape, stringify, encode, parse, decode } = querystring_module; +export * as default from "querystring-es3"; diff --git a/src/node-fallbacks/stream.js b/src/node-fallbacks/stream.js index 65abe0ba41..f741738105 100644 --- a/src/node-fallbacks/stream.js +++ b/src/node-fallbacks/stream.js @@ -1,7 +1,26 @@ -/** - * Browser polyfill for the `"stream"` module. - * - * Imported on usage in `bun build --target=browser` - */ -export * from "readable-stream"; -export * as default from "readable-stream"; +import stream from "readable-stream"; + +export const ReadableState = stream.ReadableState; +export const _fromList = stream._fromList; +export const from = stream.from; +export const fromWeb = stream.fromWeb; +export const toWeb = stream.toWeb; +export const wrap = stream.wrap; +export const _uint8ArrayToBuffer = stream._uint8ArrayToBuffer; +export const _isUint8Array = stream._isUint8Array; +export const isDisturbed = stream.isDisturbed; +export const isErrored = stream.isErrored; +export const isReadable = stream.isReadable; +export const Readable = stream.Readable; +export const Writable = stream.Writable; +export const Duplex = stream.Duplex; +export const Transform = stream.Transform; +export const PassThrough = stream.PassThrough; +export const addAbortSignal = stream.addAbortSignal; +export const finished = stream.finished; +export const destroy = stream.destroy; +export const pipeline = stream.pipeline; +export const compose = stream.compose; +export const Stream = stream.Stream; + +export default stream; diff --git a/src/node-fallbacks/string_decoder.js b/src/node-fallbacks/string_decoder.js index 25ec353409..6e0a2c8470 100644 --- a/src/node-fallbacks/string_decoder.js +++ b/src/node-fallbacks/string_decoder.js @@ -1,6 +1,2 @@ -/** - * Browser polyfill for the `"string_decoder"` module. - * - * Imported on usage in `bun build --target=browser` - */ -export { StringDecoder, StringDecoder as default } from "string_decoder"; +// TODO: This depends on a separate buffer polyfill +export { StringDecoder, StringDecoder as default } from "./node_modules/string_decoder"; diff --git a/src/node-fallbacks/timers.js b/src/node-fallbacks/timers.js index 12cbf9b3bf..979b6a460e 100644 --- a/src/node-fallbacks/timers.js +++ b/src/node-fallbacks/timers.js @@ -1,7 +1,9 @@ -/** - * Browser polyfill for the `"timers"` module. - * - * Imported on usage in `bun build --target=browser` - */ -export * from "timers-browserify"; -export * as default from "timers-browserify"; +// Hardcoded module "node:timers" +export const setTimeout = globalThis.setTimeout; +export const clearTimeout = globalThis.clearTimeout; +export const setInterval = globalThis.setInterval; +export const setImmediate = globalThis.setImmediate; +export const clearInterval = globalThis.clearInterval; +export const clearImmediate = globalThis.clearImmediate; +export const _unrefActive = () => {}; +export * as promises from "node:timers/promises"; diff --git a/src/node-fallbacks/timers.promises.js b/src/node-fallbacks/timers.promises.js new file mode 100644 index 0000000000..30b10fa424 --- /dev/null +++ b/src/node-fallbacks/timers.promises.js @@ -0,0 +1,238 @@ +// Hardcoded module "node:timers/promises" +// https://github.com/niksy/isomorphic-timers-promises/blob/master/index.js +const symbolAsyncIterator = /* @__PURE__ */ Symbol.asyncIterator; + +class ERR_INVALID_ARG_TYPE extends Error { + constructor(name, expected, actual) { + super(`${name} must be ${expected}, ${typeof actual} given`); + this.code = "ERR_INVALID_ARG_TYPE"; + } +} + +class AbortError extends Error { + constructor() { + super("The operation was aborted"); + this.code = "ABORT_ERR"; + } +} + +function validateObject(object, name) { + if (object === null || typeof object !== "object") { + throw new ERR_INVALID_ARG_TYPE(name, "Object", object); + } +} + +function validateBoolean(value, name) { + if (typeof value !== "boolean") { + throw new ERR_INVALID_ARG_TYPE(name, "boolean", value); + } +} + +function validateAbortSignal(signal, name) { + if (typeof signal !== "undefined" && (signal === null || typeof signal !== "object" || !("aborted" in signal))) { + throw new ERR_INVALID_ARG_TYPE(name, "AbortSignal", signal); + } +} + +function asyncIterator({ next: nextFunction, return: returnFunction }) { + const result = {}; + if (typeof nextFunction === "function") { + result.next = nextFunction; + } + if (typeof returnFunction === "function") { + result.return = returnFunction; + } + result[symbolAsyncIterator] = function () { + return this; + }; + + return result; +} + +function setTimeoutPromise(after = 1, value, options = {}) { + const arguments_ = [].concat(value ?? []); + try { + validateObject(options, "options"); + } catch (error) { + return Promise.reject(error); + } + const { signal, ref: reference = true } = options; + try { + validateAbortSignal(signal, "options.signal"); + } catch (error) { + return Promise.reject(error); + } + try { + validateBoolean(reference, "options.ref"); + } catch (error) { + return Promise.reject(error); + } + if (signal?.aborted) { + return Promise.reject(new AbortError()); + } + let onCancel; + const returnValue = new Promise((resolve, reject) => { + const timeout = setTimeout(() => resolve(value), after, ...arguments_); + if (!reference) { + timeout?.unref?.(); + } + if (signal) { + onCancel = () => { + clearTimeout(timeout); + reject(new AbortError()); + }; + signal.addEventListener("abort", onCancel); + } + }); + return typeof onCancel !== "undefined" + ? returnValue.finally(() => signal.removeEventListener("abort", onCancel)) + : returnValue; +} + +function setImmediatePromise(value, options = {}) { + try { + validateObject(options, "options"); + } catch (error) { + return Promise.reject(error); + } + const { signal, ref: reference = true } = options; + try { + validateAbortSignal(signal, "options.signal"); + } catch (error) { + return Promise.reject(error); + } + try { + validateBoolean(reference, "options.ref"); + } catch (error) { + return Promise.reject(error); + } + if (signal?.aborted) { + return Promise.reject(new AbortError()); + } + let onCancel; + const returnValue = new Promise((resolve, reject) => { + const immediate = setImmediate(() => resolve(value)); + if (!reference) { + immediate?.unref?.(); + } + if (signal) { + onCancel = () => { + clearImmediate(immediate); + reject(new AbortError()); + }; + signal.addEventListener("abort", onCancel); + } + }); + return typeof onCancel !== "undefined" + ? returnValue.finally(() => signal.removeEventListener("abort", onCancel)) + : returnValue; +} + +function setIntervalPromise(after = 1, value, options = {}) { + /* eslint-disable no-undefined, no-unreachable-loop, no-loop-func */ + try { + validateObject(options, "options"); + } catch (error) { + return asyncIterator({ + next: function () { + return Promise.reject(error); + }, + }); + } + const { signal, ref: reference = true } = options; + try { + validateAbortSignal(signal, "options.signal"); + } catch (error) { + return asyncIterator({ + next: function () { + return Promise.reject(error); + }, + }); + } + try { + validateBoolean(reference, "options.ref"); + } catch (error) { + return asyncIterator({ + next: function () { + return Promise.reject(error); + }, + }); + } + if (signal?.aborted) { + return asyncIterator({ + next: function () { + return Promise.reject(new AbortError()); + }, + }); + } + + let onCancel, interval; + + try { + let notYielded = 0; + let callback; + interval = setInterval(() => { + notYielded++; + if (callback) { + callback(); + callback = undefined; + } + }, after); + if (!reference) { + interval?.unref?.(); + } + if (signal) { + onCancel = () => { + clearInterval(interval); + if (callback) { + callback(); + callback = undefined; + } + }; + signal.addEventListener("abort", onCancel); + } + + return asyncIterator({ + next: function () { + return new Promise((resolve, reject) => { + if (!signal?.aborted) { + if (notYielded === 0) { + callback = resolve; + } else { + resolve(); + } + } else if (notYielded === 0) { + reject(new AbortError()); + } else { + resolve(); + } + }).then(() => { + if (notYielded > 0) { + notYielded = notYielded - 1; + return { done: false, value: value }; + } + return { done: true }; + }); + }, + return: function () { + clearInterval(interval); + signal?.removeEventListener("abort", onCancel); + return Promise.resolve({}); + }, + }); + } catch (error) { + return asyncIterator({ + next: function () { + clearInterval(interval); + signal?.removeEventListener("abort", onCancel); + }, + }); + } +} + +export { setImmediatePromise as setImmediate, setIntervalPromise as setInterval, setTimeoutPromise as setTimeout }; + +export const scheduler = { + wait: (delay, options) => setTimeoutPromise(delay, undefined, options), + yield: setImmediatePromise, +}; diff --git a/src/node-fallbacks/tty.js b/src/node-fallbacks/tty.js index d0958436cc..985c225fad 100644 --- a/src/node-fallbacks/tty.js +++ b/src/node-fallbacks/tty.js @@ -1,8 +1,3 @@ -/** - * Browser polyfill for the `"tty"` module. - * - * Imported on usage in `bun build --target=browser` - */ let isatty = () => false; function WriteStream() { throw new Error("tty.WriteStream is not implemented for browsers"); @@ -11,4 +6,3 @@ function ReadStream() { throw new Error("tty.ReadStream is not implemented for browsers"); } export { ReadStream, WriteStream, isatty }; -export default { isatty, ReadStream, WriteStream }; diff --git a/src/node-fallbacks/url.js b/src/node-fallbacks/url.js index f33990435e..3d45a9a19a 100644 --- a/src/node-fallbacks/url.js +++ b/src/node-fallbacks/url.js @@ -1,9 +1,3 @@ -/** - * Browser polyfill for the `"url"` module. - * - * Imported on usage in `bun build --target=browser` - */ -// ----------------------------------------------------------------------------- // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -26,7 +20,8 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. "use strict"; -const { URL, URLSearchParams } = globalThis; +const URL = /* @__PURE__ */ globalThis.URL; +const URLSearchParams = /* @__PURE__ */ globalThis.URLSearchParams; function util_isString(arg) { return typeof arg === "string"; @@ -40,9 +35,6 @@ function util_isNull(arg) { function util_isNullOrUndefined(arg) { return arg == null; } -function util_isUndefined(arg) { - return arg === void 0; -} function Url() { this.protocol = null; diff --git a/src/node-fallbacks/util.js b/src/node-fallbacks/util.js index c81d2bd7d4..f10c242bd1 100644 --- a/src/node-fallbacks/util.js +++ b/src/node-fallbacks/util.js @@ -1,12 +1,949 @@ +// NOTE: THIS IS A BROWSER POLYFILL - Bun's actual node:* modules are in src/js/node +// +// This file is derived from https://www.npmjs.com/package/util v0.12.5, +// converted into an Tree-shaking ES Module. + +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +var formatRegExp = /%[sdj%]/g; +export function format(f, ...args) { + if (!isString(f)) { + var objects = [f]; + for (var i = 0; i < args.length; i++) { + objects.push(inspect(args[i])); + } + return objects.join(" "); + } + + var i = 0; + var len = args.length; + var str = String(f).replace(formatRegExp, function (x) { + if (x === "%%") return "%"; + if (i >= len) return x; + switch (x) { + case "%s": + return String(args[i++]); + case "%d": + return Number(args[i++]); + case "%j": + try { + return JSON.stringify(args[i++]); + } catch (_) { + return "[Circular]"; + } + default: + return x; + } + }); + for (var x = args[i]; i < len; x = args[++i]) { + if (isNull(x) || !isObject(x)) { + str += " " + x; + } else { + str += " " + inspect(x); + } + } + return str; +} + +// Mark that a method should not be used. +// Returns a modified function which warns once by default. +// If --no-deprecation is set, then it is a no-op. +export function deprecate(fn, msg) { + if (typeof process === "undefined" || process?.noDeprecation === true) { + return fn; + } + + var warned = false; + function deprecated(...args) { + if (!warned) { + if (process.throwDeprecation) { + throw new Error(msg); + } else if (process.traceDeprecation) { + console.trace(msg); + } else { + console.error(msg); + } + warned = true; + } + return fn.apply(this, ...args); + } + + return deprecated; +} + +// This function has been edited to be tree-shakable and minifiable +export const debuglog = /* @__PURE__ */ ((debugs = {}, debugEnvRegex = {}, debugEnv) => ( + ((debugEnv = typeof process !== "undefined" && process.env.NODE_DEBUG) && + (debugEnv = debugEnv + .replace(/[|\\{}()[\]^$+?.]/g, "\\$&") + .replace(/\*/g, ".*") + .replace(/,/g, "$|^") + .toUpperCase()), + (debugEnvRegex = new RegExp("^" + debugEnv + "$", "i"))), + set => { + set = set.toUpperCase(); + if (!debugs[set]) { + if (debugEnvRegex.test(set)) { + debugs[set] = function (...args) { + console.error("%s: %s", set, pid, format.apply(null, ...args)); + }; + } else { + debugs[set] = function () {}; + } + } + return debugs[set]; + } +))(); + /** - * Browser polyfill for the `"util"` module. + * Echos the value of a value. Tries to print the value out + * in the best way possible given the different types. * - * Imported on usage in `bun build --target=browser` + * @param {Object} obj The object to print out. + * @param {Object} opts Optional options object that alters the output. */ -export * from "util"; +/* legacy: obj, showHidden, depth, colors*/ +export const inspect = /* @__PURE__ */ (i => + ( + // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics + (i.colors = { + "bold": [1, 22], + "italic": [3, 23], + "underline": [4, 24], + "inverse": [7, 27], + "white": [37, 39], + "grey": [90, 39], + "black": [30, 39], + "blue": [34, 39], + "cyan": [36, 39], + "green": [32, 39], + "magenta": [35, 39], + "red": [31, 39], + "yellow": [33, 39], + }), + // Don't use 'blue' not visible on cmd.exe + (i.styles = { + "special": "cyan", + "number": "yellow", + "boolean": "yellow", + "undefined": "grey", + "null": "bold", + "string": "green", + "date": "magenta", + // "name": intentionally not styling + "regexp": "red", + }), + (i.custom = Symbol.for("nodejs.util.inspect.custom")), + i + ))(function inspect(obj, opts, ...rest) { + // default options + var ctx = { + seen: [], + stylize: stylizeNoColor, + }; + // legacy... + if (rest.length >= 1) ctx.depth = rest[0]; + if (rest.length >= 2) ctx.colors = rest[1]; + if (isBoolean(opts)) { + // legacy... + ctx.showHidden = opts; + } else if (opts) { + // got an "options" object + _extend(ctx, opts); + } + // set default options + if (isUndefined(ctx.showHidden)) ctx.showHidden = false; + if (isUndefined(ctx.depth)) ctx.depth = 2; + if (isUndefined(ctx.colors)) ctx.colors = false; + if (ctx.colors) ctx.stylize = stylizeWithColor; + return formatValue(ctx, obj, ctx.depth); +}); -const TextEncoder = globalThis.TextEncoder; -const TextDecoder = globalThis.TextDecoder; +function stylizeWithColor(str, styleType) { + var style = inspect.styles[styleType]; -export { TextDecoder, TextEncoder }; -export default { TextEncoder, TextDecoder }; + if (style) { + return "\u001b[" + inspect.colors[style][0] + "m" + str + "\u001b[" + inspect.colors[style][1] + "m"; + } else { + return str; + } +} + +function stylizeNoColor(str, styleType) { + return str; +} + +function arrayToHash(array) { + var hash = {}; + + array.forEach(function (val, idx) { + hash[val] = true; + }); + + return hash; +} + +function formatValue(ctx, value, recurseTimes) { + // Provide a hook for user-specified inspect functions. + // Check that value is an object with an inspect function on it + if ( + ctx.customInspect && + value && + isFunction(value.inspect) && + // Filter out the util module, it's inspect function is special + value.inspect !== inspect && + // Also filter out any prototype objects using the circular check. + !(value.constructor && value.constructor.prototype === value) + ) { + var ret = value.inspect(recurseTimes, ctx); + if (!isString(ret)) { + ret = formatValue(ctx, ret, recurseTimes); + } + return ret; + } + + // Primitive types cannot have properties + var primitive = formatPrimitive(ctx, value); + if (primitive) { + return primitive; + } + + // Look up the keys of the object. + var keys = Object.keys(value); + var visibleKeys = arrayToHash(keys); + + if (ctx.showHidden) { + keys = Object.getOwnPropertyNames(value); + } + + // IE doesn't make error fields non-enumerable + // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx + if (isError(value) && (keys.indexOf("message") >= 0 || keys.indexOf("description") >= 0)) { + return formatError(value); + } + + // Some type of object without properties can be shortcutted. + if (keys.length === 0) { + if (isFunction(value)) { + var name = value.name ? ": " + value.name : ""; + return ctx.stylize("[Function" + name + "]", "special"); + } + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), "regexp"); + } + if (isDate(value)) { + return ctx.stylize(Date.prototype.toString.call(value), "date"); + } + if (isError(value)) { + return formatError(value); + } + } + + var base = "", + array = false, + braces = ["{", "}"]; + + // Make Array say that they are Array + if (isArray(value)) { + array = true; + braces = ["[", "]"]; + } + + // Make functions say that they are functions + if (isFunction(value)) { + var n = value.name ? ": " + value.name : ""; + base = " [Function" + n + "]"; + } + + // Make RegExps say that they are RegExps + if (isRegExp(value)) { + base = " " + RegExp.prototype.toString.call(value); + } + + // Make dates with properties first say the date + if (isDate(value)) { + base = " " + Date.prototype.toUTCString.call(value); + } + + // Make error with message first say the error + if (isError(value)) { + base = " " + formatError(value); + } + + if (keys.length === 0 && (!array || value.length == 0)) { + return braces[0] + base + braces[1]; + } + + if (recurseTimes < 0) { + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), "regexp"); + } else { + return ctx.stylize("[Object]", "special"); + } + } + + ctx.seen.push(value); + + var output; + if (array) { + output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); + } else { + output = keys.map(function (key) { + return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); + }); + } + + ctx.seen.pop(); + + return reduceToSingleString(output, base, braces); +} + +function formatPrimitive(ctx, value) { + if (isUndefined(value)) return ctx.stylize("undefined", "undefined"); + if (isString(value)) { + var simple = "'" + JSON.stringify(value).replace(/^"|"$/g, "").replace(/'/g, "\\'").replace(/\\"/g, '"') + "'"; + return ctx.stylize(simple, "string"); + } + if (isNumber(value)) return ctx.stylize("" + value, "number"); + if (isBoolean(value)) return ctx.stylize("" + value, "boolean"); + // For some reason typeof null is "object", so special case here. + if (isNull(value)) return ctx.stylize("null", "null"); +} + +function formatError(value) { + return "[" + Error.prototype.toString.call(value) + "]"; +} + +function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { + var output = []; + for (var i = 0, l = value.length; i < l; ++i) { + if (hasOwnProperty(value, String(i))) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, String(i), true)); + } else { + output.push(""); + } + } + keys.forEach(function (key) { + if (!key.match(/^\d+$/)) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, key, true)); + } + }); + return output; +} + +function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { + var name, str, desc; + desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; + if (desc.get) { + if (desc.set) { + str = ctx.stylize("[Getter/Setter]", "special"); + } else { + str = ctx.stylize("[Getter]", "special"); + } + } else { + if (desc.set) { + str = ctx.stylize("[Setter]", "special"); + } + } + if (!hasOwnProperty(visibleKeys, key)) { + name = "[" + key + "]"; + } + if (!str) { + if (ctx.seen.indexOf(desc.value) < 0) { + if (isNull(recurseTimes)) { + str = formatValue(ctx, desc.value, null); + } else { + str = formatValue(ctx, desc.value, recurseTimes - 1); + } + if (str.indexOf("\n") > -1) { + if (array) { + str = str + .split("\n") + .map(function (line) { + return " " + line; + }) + .join("\n") + .slice(2); + } else { + str = + "\n" + + str + .split("\n") + .map(function (line) { + return " " + line; + }) + .join("\n"); + } + } + } else { + str = ctx.stylize("[Circular]", "special"); + } + } + if (isUndefined(name)) { + if (array && key.match(/^\d+$/)) { + return str; + } + name = JSON.stringify("" + key); + if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { + name = name.slice(1, -1); + name = ctx.stylize(name, "name"); + } else { + name = name + .replace(/'/g, "\\'") + .replace(/\\"/g, '"') + .replace(/(^"|"$)/g, "'"); + name = ctx.stylize(name, "string"); + } + } + + return name + ": " + str; +} + +function reduceToSingleString(output, base, braces) { + var numLinesEst = 0; + var length = output.reduce(function (prev, cur) { + numLinesEst++; + if (cur.indexOf("\n") >= 0) numLinesEst++; + return prev + cur.replace(/\u001b\[\d\d?m/g, "").length + 1; + }, 0); + + if (length > 60) { + return braces[0] + (base === "" ? "" : base + "\n ") + " " + output.join(",\n ") + " " + braces[1]; + } + + return braces[0] + base + " " + output.join(", ") + " " + braces[1]; +} + +// NOTE: These type checking functions intentionally don't use `instanceof` +// because it is fragile and can be easily faked with `Object.create()`. +export const types = /* @__PURE__ */ () => { + // var toStr = Object.prototype.toString; + // var fnToStr = Function.prototype.toString; + // function isArgumentsObject(value) { + // if (hasToStringTag && value && typeof value === "object" && Symbol.toStringTag in value) { + // return false; + // } + // return toStr.apply(value) === "[object Arguments]"; + // } + // var isFnRegex = /^\s*(?:function)?\*/; + // var getProto = Object.getPrototypeOf; + // var GeneratorFunction; + // function isGeneratorFunction(fn) { + // if (typeof fn !== "function") { + // return false; + // } + // if (isFnRegex.test(fnToStr.call(fn))) { + // return true; + // } + // if (typeof GeneratorFunction === "undefined") { + // var generatorFunc; + // try { + // generatorFunc = Function("return function*() {}")(); + // } catch (e) {} + // GeneratorFunction = generatorFunc ? getProto(generatorFunc) : false; + // } + // return getProto(fn) === GeneratorFunction; + // } + // // var whichTypedArray = require("which-typed-array"); + // // var isTypedArray = require("is-typed-array"); + // function uncurryThis(f) { + // return f.call.bind(f); + // } + // var BigIntSupported = typeof BigInt !== "undefined"; + // var SymbolSupported = typeof Symbol !== "undefined"; + // var ObjectToString = uncurryThis(Object.prototype.toString); + // var numberValue = uncurryThis(Number.prototype.valueOf); + // var stringValue = uncurryThis(String.prototype.valueOf); + // var booleanValue = uncurryThis(Boolean.prototype.valueOf); + // if (BigIntSupported) { + // var bigIntValue = uncurryThis(BigInt.prototype.valueOf); + // } + // if (SymbolSupported) { + // var symbolValue = uncurryThis(Symbol.prototype.valueOf); + // } + // function checkBoxedPrimitive(value, prototypeValueOf) { + // if (typeof value !== "object") { + // return false; + // } + // try { + // prototypeValueOf(value); + // return true; + // } catch (e) { + // return false; + // } + // } + // exports.isArgumentsObject = isArgumentsObject; + // exports.isGeneratorFunction = isGeneratorFunction; + // exports.isTypedArray = isTypedArray; + // // Taken from here and modified for better browser support + // // https://github.com/sindresorhus/p-is-promise/blob/cda35a513bda03f977ad5cde3a079d237e82d7ef/index.js + // function isPromise(input) { + // return ( + // (typeof Promise !== "undefined" && input instanceof Promise) || + // (input !== null && + // typeof input === "object" && + // typeof input.then === "function" && + // typeof input.catch === "function") + // ); + // } + // exports.isPromise = isPromise; + // function isArrayBufferView(value) { + // if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) { + // return ArrayBuffer.isView(value); + // } + // return isTypedArray(value) || isDataView(value); + // } + // exports.isArrayBufferView = isArrayBufferView; + // function isUint8Array(value) { + // return whichTypedArray(value) === "Uint8Array"; + // } + // exports.isUint8Array = isUint8Array; + // function isUint8ClampedArray(value) { + // return whichTypedArray(value) === "Uint8ClampedArray"; + // } + // exports.isUint8ClampedArray = isUint8ClampedArray; + // function isUint16Array(value) { + // return whichTypedArray(value) === "Uint16Array"; + // } + // exports.isUint16Array = isUint16Array; + // function isUint32Array(value) { + // return whichTypedArray(value) === "Uint32Array"; + // } + // exports.isUint32Array = isUint32Array; + // function isInt8Array(value) { + // return whichTypedArray(value) === "Int8Array"; + // } + // exports.isInt8Array = isInt8Array; + // function isInt16Array(value) { + // return whichTypedArray(value) === "Int16Array"; + // } + // exports.isInt16Array = isInt16Array; + // function isInt32Array(value) { + // return whichTypedArray(value) === "Int32Array"; + // } + // exports.isInt32Array = isInt32Array; + // function isFloat32Array(value) { + // return whichTypedArray(value) === "Float32Array"; + // } + // exports.isFloat32Array = isFloat32Array; + // function isFloat64Array(value) { + // return whichTypedArray(value) === "Float64Array"; + // } + // exports.isFloat64Array = isFloat64Array; + // function isBigInt64Array(value) { + // return whichTypedArray(value) === "BigInt64Array"; + // } + // exports.isBigInt64Array = isBigInt64Array; + // function isBigUint64Array(value) { + // return whichTypedArray(value) === "BigUint64Array"; + // } + // exports.isBigUint64Array = isBigUint64Array; + // function isMapToString(value) { + // return ObjectToString(value) === "[object Map]"; + // } + // isMapToString.working = typeof Map !== "undefined" && isMapToString(new Map()); + // function isMap(value) { + // if (typeof Map === "undefined") { + // return false; + // } + // return isMapToString.working ? isMapToString(value) : value instanceof Map; + // } + // exports.isMap = isMap; + // function isSetToString(value) { + // return ObjectToString(value) === "[object Set]"; + // } + // isSetToString.working = typeof Set !== "undefined" && isSetToString(new Set()); + // function isSet(value) { + // if (typeof Set === "undefined") { + // return false; + // } + // return isSetToString.working ? isSetToString(value) : value instanceof Set; + // } + // exports.isSet = isSet; + // function isWeakMapToString(value) { + // return ObjectToString(value) === "[object WeakMap]"; + // } + // isWeakMapToString.working = typeof WeakMap !== "undefined" && isWeakMapToString(new WeakMap()); + // function isWeakMap(value) { + // if (typeof WeakMap === "undefined") { + // return false; + // } + // return isWeakMapToString.working ? isWeakMapToString(value) : value instanceof WeakMap; + // } + // exports.isWeakMap = isWeakMap; + // function isWeakSetToString(value) { + // return ObjectToString(value) === "[object WeakSet]"; + // } + // isWeakSetToString.working = typeof WeakSet !== "undefined" && isWeakSetToString(new WeakSet()); + // function isWeakSet(value) { + // return isWeakSetToString(value); + // } + // exports.isWeakSet = isWeakSet; + // function isArrayBufferToString(value) { + // return ObjectToString(value) === "[object ArrayBuffer]"; + // } + // isArrayBufferToString.working = typeof ArrayBuffer !== "undefined" && isArrayBufferToString(new ArrayBuffer()); + // function isArrayBuffer(value) { + // if (typeof ArrayBuffer === "undefined") { + // return false; + // } + // return isArrayBufferToString.working ? isArrayBufferToString(value) : value instanceof ArrayBuffer; + // } + // exports.isArrayBuffer = isArrayBuffer; + // function isDataViewToString(value) { + // return ObjectToString(value) === "[object DataView]"; + // } + // isDataViewToString.working = + // typeof ArrayBuffer !== "undefined" && + // typeof DataView !== "undefined" && + // isDataViewToString(new DataView(new ArrayBuffer(1), 0, 1)); + // function isDataView(value) { + // if (typeof DataView === "undefined") { + // return false; + // } + // return isDataViewToString.working ? isDataViewToString(value) : value instanceof DataView; + // } + // exports.isDataView = isDataView; + // // Store a copy of SharedArrayBuffer in case it's deleted elsewhere + // var SharedArrayBufferCopy = typeof SharedArrayBuffer !== "undefined" ? SharedArrayBuffer : undefined; + // function isSharedArrayBufferToString(value) { + // return ObjectToString(value) === "[object SharedArrayBuffer]"; + // } + // function isSharedArrayBuffer(value) { + // if (typeof SharedArrayBufferCopy === "undefined") { + // return false; + // } + // if (typeof isSharedArrayBufferToString.working === "undefined") { + // isSharedArrayBufferToString.working = isSharedArrayBufferToString(new SharedArrayBufferCopy()); + // } + // return isSharedArrayBufferToString.working + // ? isSharedArrayBufferToString(value) + // : value instanceof SharedArrayBufferCopy; + // } + // exports.isSharedArrayBuffer = isSharedArrayBuffer; + // function isAsyncFunction(value) { + // return ObjectToString(value) === "[object AsyncFunction]"; + // } + // exports.isAsyncFunction = isAsyncFunction; + // function isMapIterator(value) { + // return ObjectToString(value) === "[object Map Iterator]"; + // } + // exports.isMapIterator = isMapIterator; + // function isSetIterator(value) { + // return ObjectToString(value) === "[object Set Iterator]"; + // } + // exports.isSetIterator = isSetIterator; + // function isGeneratorObject(value) { + // return ObjectToString(value) === "[object Generator]"; + // } + // exports.isGeneratorObject = isGeneratorObject; + // function isWebAssemblyCompiledModule(value) { + // return ObjectToString(value) === "[object WebAssembly.Module]"; + // } + // exports.isWebAssemblyCompiledModule = isWebAssemblyCompiledModule; + // function isNumberObject(value) { + // return checkBoxedPrimitive(value, numberValue); + // } + // exports.isNumberObject = isNumberObject; + // function isStringObject(value) { + // return checkBoxedPrimitive(value, stringValue); + // } + // exports.isStringObject = isStringObject; + // function isBooleanObject(value) { + // return checkBoxedPrimitive(value, booleanValue); + // } + // exports.isBooleanObject = isBooleanObject; + // function isBigIntObject(value) { + // return BigIntSupported && checkBoxedPrimitive(value, bigIntValue); + // } + // exports.isBigIntObject = isBigIntObject; + // function isSymbolObject(value) { + // return SymbolSupported && checkBoxedPrimitive(value, symbolValue); + // } + // exports.isSymbolObject = isSymbolObject; + // function isBoxedPrimitive(value) { + // return ( + // isNumberObject(value) || + // isStringObject(value) || + // isBooleanObject(value) || + // isBigIntObject(value) || + // isSymbolObject(value) + // ); + // } + // exports.isBoxedPrimitive = isBoxedPrimitive; + // function isAnyArrayBuffer(value) { + // return typeof Uint8Array !== "undefined" && (isArrayBuffer(value) || isSharedArrayBuffer(value)); + // } + // exports.isAnyArrayBuffer = isAnyArrayBuffer; + // ["isProxy", "isExternal", "isModuleNamespaceObject"].forEach(function (method) { + // Object.defineProperty(exports, method, { + // enumerable: false, + // value: function () { + // throw new Error(method + " is not supported in userland"); + // }, + // }); + // }); + // exports.types.isRegExp = isRegExp; + // exports.types.isDate = isDate; + // exports.types.isNativeError = isError; +}; + +export function isArray(ar) { + return Array.isArray(ar); +} + +export function isBoolean(arg) { + return typeof arg === "boolean"; +} + +export function isNull(arg) { + return arg === null; +} + +export function isNullOrUndefined(arg) { + return arg == null; +} + +export function isNumber(arg) { + return typeof arg === "number"; +} + +export function isString(arg) { + return typeof arg === "string"; +} + +export function isSymbol(arg) { + return typeof arg === "symbol"; +} + +export function isUndefined(arg) { + return arg === void 0; +} + +export function isRegExp(re) { + return isObject(re) && objectToString(re) === "[object RegExp]"; +} + +export function isObject(arg) { + return typeof arg === "object" && arg !== null; +} + +export function isDate(d) { + return isObject(d) && objectToString(d) === "[object Date]"; +} + +export function isError(e) { + return isObject(e) && (objectToString(e) === "[object Error]" || e instanceof Error); +} + +export function isFunction(arg) { + return typeof arg === "function"; +} + +export function isPrimitive(arg) { + return ( + arg === null || + typeof arg === "boolean" || + typeof arg === "number" || + typeof arg === "string" || + typeof arg === "symbol" || // ES6 symbol + typeof arg === "undefined" + ); +} + +// Compatibility with the buffer polyfill: +export function isBuffer(arg) { + return arg instanceof Buffer; +} + +function objectToString(o) { + return Object.prototype.toString.call(o); +} + +function pad(n) { + return n < 10 ? "0" + n.toString(10) : n.toString(10); +} + +var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; + +// 26 Feb 16:19:34 +function timestamp() { + var d = new Date(); + var time = [pad(d.getHours()), pad(d.getMinutes()), pad(d.getSeconds())].join(":"); + return [d.getDate(), months[d.getMonth()], time].join(" "); +} + +// log is just a thin wrapper to console.log that prepends a timestamp +export function log(...args) { + console.log("%s - %s", timestamp(), format.apply(null, args)); +} + +/** + * Inherit the prototype methods from one constructor into another. + * + * The Function.prototype.inherits from lang.js rewritten as a standalone + * function (not on Function.prototype). NOTE: If this file is to be loaded + * during bootstrapping this function needs to be rewritten using some native + * functions as prototype setup using normal JavaScript does not work as + * expected during bootstrapping (see mirror.js in r114903). + * + * @param {function} ctor Constructor function which needs to inherit the + * prototype. + * @param {function} superCtor Constructor function to inherit prototype from. + */ +export function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor; + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true, + }, + }); + } +} + +export function _extend(origin, add) { + // Don't do anything if add isn't an object + if (!add || !isObject(add)) return origin; + + var keys = Object.keys(add); + var i = keys.length; + while (i--) { + origin[keys[i]] = add[keys[i]]; + } + return origin; +} + +function hasOwnProperty(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); +} + +export const promisify = /* @__PURE__ */ (x => ((x.custom = Symbol.for("nodejs.util.promisify.custom")), x))( + function promisify(original) { + if (typeof original !== "function") throw new TypeError('The "original" argument must be of type Function'); + + if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) { + var fn = original[kCustomPromisifiedSymbol]; + + if (typeof fn !== "function") { + throw new TypeError('The "nodejs.util.promisify.custom" argument must be of type Function'); + } + + Object.defineProperty(fn, kCustomPromisifiedSymbol, { + value: fn, + enumerable: false, + writable: false, + configurable: true, + }); + return fn; + } + + function fn(...args) { + var promiseResolve, promiseReject; + var promise = new Promise(function (resolve, reject) { + promiseResolve = resolve; + promiseReject = reject; + }); + + args.push(function (err, value) { + if (err) { + promiseReject(err); + } else { + promiseResolve(value); + } + }); + + try { + original.apply(this, args); + } catch (err) { + promiseReject(err); + } + + return promise; + } + + Object.setPrototypeOf(fn, Object.getPrototypeOf(original)); + + if (kCustomPromisifiedSymbol) + Object.defineProperty(fn, kCustomPromisifiedSymbol, { + value: fn, + enumerable: false, + writable: false, + configurable: true, + }); + return Object.defineProperties(fn, Object.getOwnPropertyDescriptors(original)); + }, +); + +export function callbackifyOnRejected(reason, cb) { + // `!reason` guard inspired by bluebird (Ref: https://goo.gl/t5IS6M). + // Because `null` is a special error value in callbacks which means "no error + // occurred", we error-wrap so the callback consumer can distinguish between + // "the promise rejected with null" or "the promise fulfilled with undefined". + if (!reason) { + var newReason = new Error("Promise was rejected with a falsy value"); + newReason.reason = reason; + reason = newReason; + } + return cb(reason); +} + +export function callbackify(original) { + if (typeof original !== "function") { + throw new TypeError('The "original" argument must be of type Function'); + } + + // We DO NOT return the promise as it gives the user a false sense that + // the promise is actually somehow related to the callback's execution + // and that the callback throwing will reject the promise. + function callbackified(...args) { + var maybeCb = args.pop(); + if (typeof maybeCb !== "function") { + throw new TypeError("The last argument must be of type Function"); + } + var self = this; + var cb = function (...args) { + return maybeCb.apply(self, ...args); + }; + // In true node style we process the callback on `nextTick` with all the + // implications (stack, `uncaughtException`, `async_hooks`) + original.apply(this, args).then( + function (ret) { + process.nextTick(cb.bind(null, null, ret)); + }, + function (rej) { + process.nextTick(callbackifyOnRejected.bind(null, rej, cb)); + }, + ); + } + + Object.setPrototypeOf(callbackified, Object.getPrototypeOf(original)); + Object.defineProperties(callbackified, Object.getOwnPropertyDescriptors(original)); + + return callbackified; +} + +export const TextEncoder = /* @__PURE__ */ globalThis.TextEncoder; +export const TextDecoder = /* @__PURE__ */ globalThis.TextDecoder; diff --git a/src/node-fallbacks/vendor/base64-js.js b/src/node-fallbacks/vendor/base64-js.js new file mode 100644 index 0000000000..a691859a0d --- /dev/null +++ b/src/node-fallbacks/vendor/base64-js.js @@ -0,0 +1,126 @@ +// Vendored version of https://www.npmjs.com/package/base64-js version 1.5.1 +// Converted manually to an ES module for higher tree-shaking compatibility +"use strict"; + +var lookup = []; +var revLookup = []; + +var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +for (var i = 0, len = code.length; i < len; ++i) { + lookup[i] = code[i]; + revLookup[code.charCodeAt(i)] = i; +} + +// Support decoding URL-safe base64 strings, as Node.js does. +// See: https://en.wikipedia.org/wiki/Base64#URL_applications +revLookup["-".charCodeAt(0)] = 62; +revLookup["_".charCodeAt(0)] = 63; + +function getLens(b64) { + var len = b64.length; + + if (len % 4 > 0) { + throw new Error("Invalid string. Length must be a multiple of 4"); + } + + // Trim off extra bytes after placeholder bytes are found + // See: https://github.com/beatgammit/base64-js/issues/42 + var validLen = b64.indexOf("="); + if (validLen === -1) validLen = len; + + var placeHoldersLen = validLen === len ? 0 : 4 - (validLen % 4); + + return [validLen, placeHoldersLen]; +} + +// base64 is 4/3 + up to two characters of the original data +function byteLength(b64) { + var lens = getLens(b64); + var validLen = lens[0]; + var placeHoldersLen = lens[1]; + return ((validLen + placeHoldersLen) * 3) / 4 - placeHoldersLen; +} + +function _byteLength(validLen, placeHoldersLen) { + return ((validLen + placeHoldersLen) * 3) / 4 - placeHoldersLen; +} + +export function toByteArray(b64) { + var tmp; + var lens = getLens(b64); + var validLen = lens[0]; + var placeHoldersLen = lens[1]; + + var arr = new Uint8Array(_byteLength(validLen, placeHoldersLen)); + + var curByte = 0; + + // if there are placeholders, only get up to the last complete 4 chars + var len = placeHoldersLen > 0 ? validLen - 4 : validLen; + + var i; + for (i = 0; i < len; i += 4) { + tmp = + (revLookup[b64.charCodeAt(i)] << 18) | + (revLookup[b64.charCodeAt(i + 1)] << 12) | + (revLookup[b64.charCodeAt(i + 2)] << 6) | + revLookup[b64.charCodeAt(i + 3)]; + arr[curByte++] = (tmp >> 16) & 0xff; + arr[curByte++] = (tmp >> 8) & 0xff; + arr[curByte++] = tmp & 0xff; + } + + if (placeHoldersLen === 2) { + tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4); + arr[curByte++] = tmp & 0xff; + } + + if (placeHoldersLen === 1) { + tmp = + (revLookup[b64.charCodeAt(i)] << 10) | + (revLookup[b64.charCodeAt(i + 1)] << 4) | + (revLookup[b64.charCodeAt(i + 2)] >> 2); + arr[curByte++] = (tmp >> 8) & 0xff; + arr[curByte++] = tmp & 0xff; + } + + return arr; +} + +function tripletToBase64(num) { + return lookup[(num >> 18) & 0x3f] + lookup[(num >> 12) & 0x3f] + lookup[(num >> 6) & 0x3f] + lookup[num & 0x3f]; +} + +function encodeChunk(uint8, start, end) { + var tmp; + var output = []; + for (var i = start; i < end; i += 3) { + tmp = ((uint8[i] << 16) & 0xff0000) + ((uint8[i + 1] << 8) & 0xff00) + (uint8[i + 2] & 0xff); + output.push(tripletToBase64(tmp)); + } + return output.join(""); +} + +export function fromByteArray(uint8) { + var tmp; + var len = uint8.length; + var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes + var parts = []; + var maxChunkLength = 16383; // must be multiple of 3 + + // go through the array every three bytes, we'll deal with trailing stuff later + for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { + parts.push(encodeChunk(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength)); + } + + // pad the end with zeros, but make sure to not forget the extra bytes + if (extraBytes === 1) { + tmp = uint8[len - 1]; + parts.push(lookup[tmp >> 2] + lookup[(tmp << 4) & 0x3f] + "=="); + } else if (extraBytes === 2) { + tmp = (uint8[len - 2] << 8) + uint8[len - 1]; + parts.push(lookup[tmp >> 10] + lookup[(tmp >> 4) & 0x3f] + lookup[(tmp << 2) & 0x3f] + "="); + } + + return parts.join(""); +} diff --git a/src/node-fallbacks/vendor/ieee754.js b/src/node-fallbacks/vendor/ieee754.js new file mode 100644 index 0000000000..34f349af6f --- /dev/null +++ b/src/node-fallbacks/vendor/ieee754.js @@ -0,0 +1,85 @@ +/* ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ +export function read(buffer, offset, isLE, mLen, nBytes) { + var e, m; + var eLen = nBytes * 8 - mLen - 1; + var eMax = (1 << eLen) - 1; + var eBias = eMax >> 1; + var nBits = -7; + var i = isLE ? nBytes - 1 : 0; + var d = isLE ? -1 : 1; + var s = buffer[offset + i]; + + i += d; + + e = s & ((1 << -nBits) - 1); + s >>= -nBits; + nBits += eLen; + for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} + + m = e & ((1 << -nBits) - 1); + e >>= -nBits; + nBits += mLen; + for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} + + if (e === 0) { + e = 1 - eBias; + } else if (e === eMax) { + return m ? NaN : (s ? -1 : 1) * Infinity; + } else { + m = m + Math.pow(2, mLen); + e = e - eBias; + } + return (s ? -1 : 1) * m * Math.pow(2, e - mLen); +} + +export function write(buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c; + var eLen = nBytes * 8 - mLen - 1; + var eMax = (1 << eLen) - 1; + var eBias = eMax >> 1; + var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0; + var i = isLE ? 0 : nBytes - 1; + var d = isLE ? 1 : -1; + var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0; + + value = Math.abs(value); + + if (isNaN(value) || value === Infinity) { + m = isNaN(value) ? 1 : 0; + e = eMax; + } else { + e = Math.floor(Math.log(value) / Math.LN2); + if (value * (c = Math.pow(2, -e)) < 1) { + e--; + c *= 2; + } + if (e + eBias >= 1) { + value += rt / c; + } else { + value += rt * Math.pow(2, 1 - eBias); + } + if (value * c >= 2) { + e++; + c /= 2; + } + + if (e + eBias >= eMax) { + m = 0; + e = eMax; + } else if (e + eBias >= 1) { + m = (value * c - 1) * Math.pow(2, mLen); + e = e + eBias; + } else { + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); + e = 0; + } + } + + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} + + e = (e << mLen) | m; + eLen += mLen; + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} + + buffer[offset + i - d] |= s * 128; +} diff --git a/src/node-fallbacks/zlib.js b/src/node-fallbacks/zlib.js index 7904d47136..6e264b79be 100644 --- a/src/node-fallbacks/zlib.js +++ b/src/node-fallbacks/zlib.js @@ -1,7 +1,2 @@ -/** - * Browser polyfill for the `"zlib"` module. - * - * Imported on usage in `bun build --target=browser` - */ export * from "browserify-zlib"; -export * as default from "browserify-zlib"; +export { default } from "browserify-zlib"; diff --git a/test/bundler/bundler_browser.test.ts b/test/bundler/bundler_browser.test.ts index 634db16923..4b318056f1 100644 --- a/test/bundler/bundler_browser.test.ts +++ b/test/bundler/bundler_browser.test.ts @@ -140,92 +140,50 @@ describe("bundler", () => { import * as v8 from "node:v8"; import * as vm from "node:vm"; import * as zlib from "node:zlib"; - function scan(obj) { - if (typeof obj === 'function') obj = obj() - return Object.keys(obj).length === 0 ? 'no-op' : 'polyfill' + const modules = { + assert, + buffer, + child_process, + cluster, + console2, + constants, + crypto, + dgram, + dns, + domain, + events, + fs, + http, + https, + module: module2, + net, + os, + path, + perf_hooks, + process, + punycode, + querystring, + readline, + repl, + stream, + string_decoder, + sys, + timers, + tls, + tty, + url, + util, + v8, + vm, + zlib, } - console.log('assert :', scan(assert)) - console.log('buffer :', scan(buffer)) - console.log('child_process :', scan(child_process)) - console.log('cluster :', scan(cluster)) - console.log('console :', console2 === console ? 'equal' : 'polyfill') - console.log('constants :', scan(constants)) - console.log('crypto :', scan(crypto)) - console.log('dgram :', scan(dgram)) - console.log('dns :', scan(dns)) - console.log('domain :', scan(domain)) - console.log('events :', scan(events)) - console.log('fs :', scan(fs)) - console.log('http :', scan(http)) - console.log('https :', scan(https)) - console.log('module :', scan(module2)) - console.log('net :', scan(net)) - console.log('os :', scan(os)) - console.log('path :', scan(path)) - console.log('perf_hooks :', scan(perf_hooks)) - console.log('process :', scan(process)) - console.log('punycode :', scan(punycode)) - console.log('querystring :', scan(querystring)) - console.log('readline :', scan(readline)) - console.log('repl :', scan(repl)) - console.log('stream :', scan(stream)) - console.log('string_decoder :', scan(string_decoder)) - console.log('sys :', scan(sys)) - console.log('timers :', scan(timers)) - console.log('tls :', scan(tls)) - console.log('tty :', scan(tty)) - console.log('url :', scan(url)) - console.log('util :', scan(util)) - console.log('v8 :', scan(v8)) - console.log('vm :', scan(vm)) - console.log('zlib :', scan(zlib)) + console.log(Bun.inspect(modules)) `, }, target: "browser", - onAfterBundle(api) { - assert(!api.readFile("/out.js").includes("\0"), "bundle should not contain null bytes"); - const file = api.readFile("/out.js"); - const imports = new Bun.Transpiler().scanImports(file); - expect(imports).toStrictEqual([]); - }, run: { - stdout: ` - assert : polyfill - buffer : polyfill - child_process : no-op - cluster : no-op - console : polyfill - constants : polyfill - crypto : polyfill - dgram : no-op - dns : no-op - domain : polyfill - events : polyfill - fs : no-op - http : polyfill - https : polyfill - module : no-op - net : polyfill - os : polyfill - path : polyfill - perf_hooks : no-op - process : polyfill - punycode : polyfill - querystring : polyfill - readline : no-op - repl : no-op - stream : polyfill - string_decoder : polyfill - sys : polyfill - timers : polyfill - tls : no-op - tty : polyfill - url : polyfill - util : polyfill - v8 : no-op - vm : no-op - zlib : polyfill - `, + stdout: + "{\n assert: {\n throws: [Getter/Setter],\n strictEqual: [Getter/Setter],\n strict: [Getter/Setter],\n rejects: [Getter/Setter],\n ok: [Getter/Setter],\n notStrictEqual: [Getter/Setter],\n notEqual: [Getter/Setter],\n notDeepStrictEqual: [Getter/Setter],\n notDeepEqual: [Getter/Setter],\n match: [Getter/Setter],\n ifError: [Getter/Setter],\n fail: [Getter/Setter],\n equal: [Getter/Setter],\n doesNotThrow: [Getter/Setter],\n doesNotReject: [Getter/Setter],\n doesNotMatch: [Getter/Setter],\n default: [Getter/Setter],\n deepStrictEqual: [Getter/Setter],\n deepEqual: [Getter/Setter],\n CallTracker: [Getter/Setter],\n AssertionError: [Getter/Setter],\n },\n buffer: {\n transcode: [Getter/Setter],\n resolveObjectURL: [Getter/Setter],\n kStringMaxLength: [Getter/Setter],\n kMaxLength: [Getter/Setter],\n isUtf8: [Getter/Setter],\n isAscii: [Getter/Setter],\n default: [Getter/Setter],\n constants: [Getter/Setter],\n btoa: [Getter/Setter],\n atob: [Getter/Setter],\n INSPECT_MAX_BYTES: [Getter/Setter],\n File: [Getter/Setter],\n Buffer: [Getter/Setter],\n Blob: [Getter/Setter],\n },\n child_process: [Function: child_process],\n cluster: [Function: cluster],\n console2: {\n default: [Getter/Setter],\n },\n constants: {\n X_OK: [Getter/Setter],\n W_OK: [Getter/Setter],\n UV_UDP_REUSEADDR: [Getter/Setter],\n S_IXUSR: [Getter/Setter],\n S_IXOTH: [Getter/Setter],\n S_IXGRP: [Getter/Setter],\n S_IWUSR: [Getter/Setter],\n S_IWOTH: [Getter/Setter],\n S_IWGRP: [Getter/Setter],\n S_IRWXU: [Getter/Setter],\n S_IRWXO: [Getter/Setter],\n S_IRWXG: [Getter/Setter],\n S_IRUSR: [Getter/Setter],\n S_IROTH: [Getter/Setter],\n S_IRGRP: [Getter/Setter],\n S_IFSOCK: [Getter/Setter],\n S_IFREG: [Getter/Setter],\n S_IFMT: [Getter/Setter],\n S_IFLNK: [Getter/Setter],\n S_IFIFO: [Getter/Setter],\n S_IFDIR: [Getter/Setter],\n S_IFCHR: [Getter/Setter],\n S_IFBLK: [Getter/Setter],\n SSL_OP_TLS_ROLLBACK_BUG: [Getter/Setter],\n SSL_OP_TLS_D5_BUG: [Getter/Setter],\n SSL_OP_TLS_BLOCK_PADDING_BUG: [Getter/Setter],\n SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG: [Getter/Setter],\n SSL_OP_SSLEAY_080_CLIENT_DH_BUG: [Getter/Setter],\n SSL_OP_SINGLE_ECDH_USE: [Getter/Setter],\n SSL_OP_SINGLE_DH_USE: [Getter/Setter],\n SSL_OP_PKCS1_CHECK_2: [Getter/Setter],\n SSL_OP_PKCS1_CHECK_1: [Getter/Setter],\n SSL_OP_NO_TLSv1_2: [Getter/Setter],\n SSL_OP_NO_TLSv1_1: [Getter/Setter],\n SSL_OP_NO_TLSv1: [Getter/Setter],\n SSL_OP_NO_TICKET: [Getter/Setter],\n SSL_OP_NO_SSLv3: [Getter/Setter],\n SSL_OP_NO_SSLv2: [Getter/Setter],\n SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: [Getter/Setter],\n SSL_OP_NO_QUERY_MTU: [Getter/Setter],\n SSL_OP_NO_COMPRESSION: [Getter/Setter],\n SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: [Getter/Setter],\n SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG: [Getter/Setter],\n SSL_OP_NETSCAPE_CHALLENGE_BUG: [Getter/Setter],\n SSL_OP_NETSCAPE_CA_DN_BUG: [Getter/Setter],\n SSL_OP_MSIE_SSLV2_RSA_PADDING: [Getter/Setter],\n SSL_OP_MICROSOFT_SESS_ID_BUG: [Getter/Setter],\n SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: [Getter/Setter],\n SSL_OP_LEGACY_SERVER_CONNECT: [Getter/Setter],\n SSL_OP_EPHEMERAL_RSA: [Getter/Setter],\n SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: [Getter/Setter],\n SSL_OP_CRYPTOPRO_TLSEXT_BUG: [Getter/Setter],\n SSL_OP_COOKIE_EXCHANGE: [Getter/Setter],\n SSL_OP_CISCO_ANYCONNECT: [Getter/Setter],\n SSL_OP_CIPHER_SERVER_PREFERENCE: [Getter/Setter],\n SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: [Getter/Setter],\n SSL_OP_ALL: [Getter/Setter],\n SIGXFSZ: [Getter/Setter],\n SIGXCPU: [Getter/Setter],\n SIGWINCH: [Getter/Setter],\n SIGVTALRM: [Getter/Setter],\n SIGUSR2: [Getter/Setter],\n SIGUSR1: [Getter/Setter],\n SIGURG: [Getter/Setter],\n SIGTTOU: [Getter/Setter],\n SIGTTIN: [Getter/Setter],\n SIGTSTP: [Getter/Setter],\n SIGTRAP: [Getter/Setter],\n SIGTERM: [Getter/Setter],\n SIGSYS: [Getter/Setter],\n SIGSTOP: [Getter/Setter],\n SIGSEGV: [Getter/Setter],\n SIGQUIT: [Getter/Setter],\n SIGPROF: [Getter/Setter],\n SIGPIPE: [Getter/Setter],\n SIGKILL: [Getter/Setter],\n SIGIOT: [Getter/Setter],\n SIGIO: [Getter/Setter],\n SIGINT: [Getter/Setter],\n SIGILL: [Getter/Setter],\n SIGHUP: [Getter/Setter],\n SIGFPE: [Getter/Setter],\n SIGCONT: [Getter/Setter],\n SIGCHLD: [Getter/Setter],\n SIGBUS: [Getter/Setter],\n SIGALRM: [Getter/Setter],\n SIGABRT: [Getter/Setter],\n R_OK: [Getter/Setter],\n RSA_X931_PADDING: [Getter/Setter],\n RSA_SSLV23_PADDING: [Getter/Setter],\n RSA_PKCS1_PSS_PADDING: [Getter/Setter],\n RSA_PKCS1_PADDING: [Getter/Setter],\n RSA_PKCS1_OAEP_PADDING: [Getter/Setter],\n RSA_NO_PADDING: [Getter/Setter],\n POINT_CONVERSION_UNCOMPRESSED: [Getter/Setter],\n POINT_CONVERSION_HYBRID: [Getter/Setter],\n POINT_CONVERSION_COMPRESSED: [Getter/Setter],\n O_WRONLY: [Getter/Setter],\n O_TRUNC: [Getter/Setter],\n O_SYNC: [Getter/Setter],\n O_SYMLINK: [Getter/Setter],\n O_RDWR: [Getter/Setter],\n O_RDONLY: [Getter/Setter],\n O_NONBLOCK: [Getter/Setter],\n O_NOFOLLOW: [Getter/Setter],\n O_NOCTTY: [Getter/Setter],\n O_EXCL: [Getter/Setter],\n O_DIRECTORY: [Getter/Setter],\n O_CREAT: [Getter/Setter],\n O_APPEND: [Getter/Setter],\n NPN_ENABLED: [Getter/Setter],\n F_OK: [Getter/Setter],\n EXDEV: [Getter/Setter],\n EWOULDBLOCK: [Getter/Setter],\n ETXTBSY: [Getter/Setter],\n ETIMEDOUT: [Getter/Setter],\n ETIME: [Getter/Setter],\n ESTALE: [Getter/Setter],\n ESRCH: [Getter/Setter],\n ESPIPE: [Getter/Setter],\n EROFS: [Getter/Setter],\n ERANGE: [Getter/Setter],\n EPROTOTYPE: [Getter/Setter],\n EPROTONOSUPPORT: [Getter/Setter],\n EPROTO: [Getter/Setter],\n EPIPE: [Getter/Setter],\n EPERM: [Getter/Setter],\n EOVERFLOW: [Getter/Setter],\n EOPNOTSUPP: [Getter/Setter],\n ENXIO: [Getter/Setter],\n ENOTTY: [Getter/Setter],\n ENOTSUP: [Getter/Setter],\n ENOTSOCK: [Getter/Setter],\n ENOTEMPTY: [Getter/Setter],\n ENOTDIR: [Getter/Setter],\n ENOTCONN: [Getter/Setter],\n ENOSYS: [Getter/Setter],\n ENOSTR: [Getter/Setter],\n ENOSR: [Getter/Setter],\n ENOSPC: [Getter/Setter],\n ENOPROTOOPT: [Getter/Setter],\n ENOMSG: [Getter/Setter],\n ENOMEM: [Getter/Setter],\n ENOLINK: [Getter/Setter],\n ENOLCK: [Getter/Setter],\n ENOEXEC: [Getter/Setter],\n ENOENT: [Getter/Setter],\n ENODEV: [Getter/Setter],\n ENODATA: [Getter/Setter],\n ENOBUFS: [Getter/Setter],\n ENGINE_METHOD_STORE: [Getter/Setter],\n ENGINE_METHOD_RAND: [Getter/Setter],\n ENGINE_METHOD_PKEY_METHS: [Getter/Setter],\n ENGINE_METHOD_PKEY_ASN1_METHS: [Getter/Setter],\n ENGINE_METHOD_NONE: [Getter/Setter],\n ENGINE_METHOD_ECDSA: [Getter/Setter],\n ENGINE_METHOD_ECDH: [Getter/Setter],\n ENGINE_METHOD_DSA: [Getter/Setter],\n ENGINE_METHOD_DIGESTS: [Getter/Setter],\n ENGINE_METHOD_DH: [Getter/Setter],\n ENGINE_METHOD_CIPHERS: [Getter/Setter],\n ENGINE_METHOD_ALL: [Getter/Setter],\n ENFILE: [Getter/Setter],\n ENETUNREACH: [Getter/Setter],\n ENETRESET: [Getter/Setter],\n ENETDOWN: [Getter/Setter],\n ENAMETOOLONG: [Getter/Setter],\n EMULTIHOP: [Getter/Setter],\n EMSGSIZE: [Getter/Setter],\n EMLINK: [Getter/Setter],\n EMFILE: [Getter/Setter],\n ELOOP: [Getter/Setter],\n EISDIR: [Getter/Setter],\n EISCONN: [Getter/Setter],\n EIO: [Getter/Setter],\n EINVAL: [Getter/Setter],\n EINTR: [Getter/Setter],\n EINPROGRESS: [Getter/Setter],\n EILSEQ: [Getter/Setter],\n EIDRM: [Getter/Setter],\n EHOSTUNREACH: [Getter/Setter],\n EFBIG: [Getter/Setter],\n EFAULT: [Getter/Setter],\n EEXIST: [Getter/Setter],\n EDQUOT: [Getter/Setter],\n EDOM: [Getter/Setter],\n EDESTADDRREQ: [Getter/Setter],\n EDEADLK: [Getter/Setter],\n ECONNRESET: [Getter/Setter],\n ECONNREFUSED: [Getter/Setter],\n ECONNABORTED: [Getter/Setter],\n ECHILD: [Getter/Setter],\n ECANCELED: [Getter/Setter],\n EBUSY: [Getter/Setter],\n EBADMSG: [Getter/Setter],\n EBADF: [Getter/Setter],\n EALREADY: [Getter/Setter],\n EAGAIN: [Getter/Setter],\n EAFNOSUPPORT: [Getter/Setter],\n EADDRNOTAVAIL: [Getter/Setter],\n EADDRINUSE: [Getter/Setter],\n EACCES: [Getter/Setter],\n E2BIG: [Getter/Setter],\n DH_UNABLE_TO_CHECK_GENERATOR: [Getter/Setter],\n DH_NOT_SUITABLE_GENERATOR: [Getter/Setter],\n DH_CHECK_P_NOT_SAFE_PRIME: [Getter/Setter],\n DH_CHECK_P_NOT_PRIME: [Getter/Setter],\n },\n crypto: {\n webcrypto: [Getter/Setter],\n rng: [Getter/Setter],\n randomUUID: [Getter/Setter],\n randomFillSync: [Getter/Setter],\n randomFill: [Getter/Setter],\n randomBytes: [Getter/Setter],\n publicEncrypt: [Getter/Setter],\n publicDecrypt: [Getter/Setter],\n pseudoRandomBytes: [Getter/Setter],\n prng: [Getter/Setter],\n privateEncrypt: [Getter/Setter],\n privateDecrypt: [Getter/Setter],\n pbkdf2Sync: [Getter/Setter],\n pbkdf2: [Getter/Setter],\n listCiphers: [Getter/Setter],\n getRandomValues: [Getter/Setter],\n getHashes: [Getter/Setter],\n getDiffieHellman: [Getter/Setter],\n getCurves: [Getter/Setter],\n getCiphers: [Getter/Setter],\n createVerify: [Getter/Setter],\n createSign: [Getter/Setter],\n createHmac: [Getter/Setter],\n createHash: [Getter/Setter],\n createECDH: [Getter/Setter],\n createDiffieHellmanGroup: [Getter/Setter],\n createDiffieHellman: [Getter/Setter],\n createDecipheriv: [Getter/Setter],\n createDecipher: [Getter/Setter],\n createCredentials: [Getter/Setter],\n createCipheriv: [Getter/Setter],\n createCipher: [Getter/Setter],\n constants: [Getter/Setter],\n Verify: [Getter/Setter],\n Sign: [Getter/Setter],\n Hmac: [Getter/Setter],\n Hash: [Getter/Setter],\n DiffieHellmanGroup: [Getter/Setter],\n DiffieHellman: [Getter/Setter],\n Decipheriv: [Getter/Setter],\n Decipher: [Getter/Setter],\n DEFAULT_ENCODING: [Getter/Setter],\n Cipheriv: [Getter/Setter],\n Cipher: [Getter/Setter],\n },\n dgram: [Function: dgram],\n dns: [Function: dns],\n domain: {\n createDomain: [Getter/Setter],\n create: [Getter/Setter],\n },\n events: {\n setMaxListeners: [Getter/Setter],\n once: [Getter/Setter],\n listenerCount: [Getter/Setter],\n init: [Getter/Setter],\n getMaxListeners: [Getter/Setter],\n getEventListeners: [Getter/Setter],\n default: [Getter/Setter],\n captureRejectionSymbol: [Getter/Setter],\n addAbortListener: [Getter/Setter],\n EventEmitter: [Getter/Setter],\n },\n fs: [Function: fs],\n http: {\n request: [Getter/Setter],\n globalAgent: [Getter/Setter],\n get: [Getter/Setter],\n STATUS_CODES: [Getter/Setter],\n METHODS: [Getter/Setter],\n IncomingMessage: [Getter/Setter],\n ClientRequest: [Getter/Setter],\n Agent: [Getter/Setter],\n },\n https: {\n validateHeaderValue: [Getter/Setter],\n validateHeaderName: [Getter/Setter],\n setMaxIdleHTTPParsers: [Getter/Setter],\n request: [Getter/Setter],\n maxHeaderSize: [Getter/Setter],\n globalAgent: [Getter/Setter],\n get: [Getter/Setter],\n createServer: [Getter/Setter],\n ServerResponse: [Getter/Setter],\n Server: [Getter/Setter],\n STATUS_CODES: [Getter/Setter],\n OutgoingMessage: [Getter/Setter],\n METHODS: [Getter/Setter],\n IncomingMessage: [Getter/Setter],\n ClientRequest: [Getter/Setter],\n Agent: [Getter/Setter],\n },\n module: [Function: module2],\n net: {\n isIPv6: [Getter/Setter],\n isIPv4: [Getter/Setter],\n isIP: [Getter/Setter],\n },\n os: {\n uptime: [Getter/Setter],\n type: [Getter/Setter],\n totalmem: [Getter/Setter],\n tmpdir: [Getter/Setter],\n tmpDir: [Getter/Setter],\n release: [Getter/Setter],\n platform: [Getter/Setter],\n networkInterfaces: [Getter/Setter],\n loadavg: [Getter/Setter],\n hostname: [Getter/Setter],\n homedir: [Getter/Setter],\n getNetworkInterfaces: [Getter/Setter],\n freemem: [Getter/Setter],\n endianness: [Getter/Setter],\n cpus: [Getter/Setter],\n arch: [Getter/Setter],\n EOL: [Getter/Setter],\n },\n path: {\n sep: [Getter/Setter],\n resolve: [Getter/Setter],\n relative: [Getter/Setter],\n posix: [Getter/Setter],\n parse: [Getter/Setter],\n normalize: [Getter/Setter],\n join: [Getter/Setter],\n isAbsolute: [Getter/Setter],\n format: [Getter/Setter],\n extname: [Getter/Setter],\n dirname: [Getter/Setter],\n delimiter: [Getter/Setter],\n default: [Getter/Setter],\n basename: [Getter/Setter],\n _makeLong: [Getter/Setter],\n },\n perf_hooks: [Function: perf_hooks],\n process: {\n versions: [Getter/Setter],\n version: [Getter/Setter],\n umask: [Getter/Setter],\n title: [Getter/Setter],\n removeListener: [Getter/Setter],\n removeAllListeners: [Getter/Setter],\n prependOnceListener: [Getter/Setter],\n prependListener: [Getter/Setter],\n once: [Getter/Setter],\n on: [Getter/Setter],\n off: [Getter/Setter],\n nextTick: [Getter/Setter],\n listeners: [Getter/Setter],\n env: [Getter/Setter],\n emit: [Getter/Setter],\n cwd: [Getter/Setter],\n chdir: [Getter/Setter],\n browser: [Getter/Setter],\n binding: [Getter/Setter],\n argv: [Getter/Setter],\n addListener: [Getter/Setter],\n },\n punycode: {\n default: [Getter/Setter],\n },\n querystring: {\n unescapeBuffer: [Getter/Setter],\n unescape: [Getter/Setter],\n stringify: [Getter/Setter],\n parse: [Getter/Setter],\n escape: [Getter/Setter],\n encode: [Getter/Setter],\n default: [Getter/Setter],\n decode: [Getter/Setter],\n },\n readline: [Function: readline],\n repl: [Function: repl],\n stream: {\n wrap: [Getter/Setter],\n toWeb: [Getter/Setter],\n pipeline: [Getter/Setter],\n isReadable: [Getter/Setter],\n isErrored: [Getter/Setter],\n isDisturbed: [Getter/Setter],\n fromWeb: [Getter/Setter],\n from: [Getter/Setter],\n finished: [Getter/Setter],\n destroy: [Getter/Setter],\n default: [Getter/Setter],\n compose: [Getter/Setter],\n addAbortSignal: [Getter/Setter],\n _uint8ArrayToBuffer: [Getter/Setter],\n _isUint8Array: [Getter/Setter],\n _fromList: [Getter/Setter],\n Writable: [Getter/Setter],\n Transform: [Getter/Setter],\n Stream: [Getter/Setter],\n ReadableState: [Getter/Setter],\n Readable: [Getter/Setter],\n PassThrough: [Getter/Setter],\n Duplex: [Getter/Setter],\n },\n string_decoder: {\n default: [Getter/Setter],\n StringDecoder: [Getter/Setter],\n },\n sys: {\n types: [Getter/Setter],\n promisify: [Getter/Setter],\n log: [Getter/Setter],\n isUndefined: [Getter/Setter],\n isSymbol: [Getter/Setter],\n isString: [Getter/Setter],\n isRegExp: [Getter/Setter],\n isPrimitive: [Getter/Setter],\n isObject: [Getter/Setter],\n isNumber: [Getter/Setter],\n isNullOrUndefined: [Getter/Setter],\n isNull: [Getter/Setter],\n isFunction: [Getter/Setter],\n isError: [Getter/Setter],\n isDate: [Getter/Setter],\n isBuffer: [Getter/Setter],\n isBoolean: [Getter/Setter],\n isArray: [Getter/Setter],\n inspect: [Getter/Setter],\n inherits: [Getter/Setter],\n format: [Getter/Setter],\n deprecate: [Getter/Setter],\n default: [Getter/Setter],\n debuglog: [Getter/Setter],\n callbackifyOnRejected: [Getter/Setter],\n callbackify: [Getter/Setter],\n _extend: [Getter/Setter],\n TextEncoder: [Getter/Setter],\n TextDecoder: [Getter/Setter],\n },\n timers: {\n setTimeout: [Getter/Setter],\n setInterval: [Getter/Setter],\n setImmediate: [Getter/Setter],\n promises: [Getter/Setter],\n clearTimeout: [Getter/Setter],\n clearInterval: [Getter/Setter],\n clearImmediate: [Getter/Setter],\n _unrefActive: [Getter/Setter],\n },\n tls: [Function: tls],\n tty: {\n isatty: [Getter/Setter],\n WriteStream: [Getter/Setter],\n ReadStream: [Getter/Setter],\n },\n url: {\n resolveObject: [Getter/Setter],\n resolve: [Getter/Setter],\n parse: [Getter/Setter],\n format: [Getter/Setter],\n default: [Getter/Setter],\n Url: [Getter/Setter],\n URLSearchParams: [Getter/Setter],\n URL: [Getter/Setter],\n },\n util: {\n types: [Getter/Setter],\n promisify: [Getter/Setter],\n log: [Getter/Setter],\n isUndefined: [Getter/Setter],\n isSymbol: [Getter/Setter],\n isString: [Getter/Setter],\n isRegExp: [Getter/Setter],\n isPrimitive: [Getter/Setter],\n isObject: [Getter/Setter],\n isNumber: [Getter/Setter],\n isNullOrUndefined: [Getter/Setter],\n isNull: [Getter/Setter],\n isFunction: [Getter/Setter],\n isError: [Getter/Setter],\n isDate: [Getter/Setter],\n isBuffer: [Getter/Setter],\n isBoolean: [Getter/Setter],\n isArray: [Getter/Setter],\n inspect: [Getter/Setter],\n inherits: [Getter/Setter],\n format: [Getter/Setter],\n deprecate: [Getter/Setter],\n debuglog: [Getter/Setter],\n callbackifyOnRejected: [Getter/Setter],\n callbackify: [Getter/Setter],\n _extend: [Getter/Setter],\n TextEncoder: [Getter/Setter],\n TextDecoder: [Getter/Setter],\n },\n v8: [Function: v8],\n vm: [Function: vm],\n zlib: {\n default: [Getter/Setter],\n },\n}", }, }); itBundled("browser/NodePolyfillExternal", {