@php-wasm/node-polyfills 3.0.15 → 3.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../../packages/php-wasm/node-polyfills/src/lib/current-js-runtime.ts","../../../../packages/php-wasm/node-polyfills/src/lib/blob.ts","../../../../packages/php-wasm/node-polyfills/src/lib/custom-event.ts"],"sourcesContent":["export const currentJsRuntime = (function () {\n\tif (typeof process !== 'undefined' && process.release?.name === 'node') {\n\t\treturn 'NODE';\n\t} else if (typeof window !== 'undefined') {\n\t\treturn 'WEB';\n\t} else if (\n\t\t// @ts-ignore\n\t\ttypeof WorkerGlobalScope !== 'undefined' &&\n\t\t// @ts-ignore\n\t\tself instanceof (WorkerGlobalScope as any)\n\t) {\n\t\treturn 'WORKER';\n\t} else {\n\t\treturn 'NODE';\n\t}\n})();\n","import { currentJsRuntime } from './current-js-runtime';\n\n// Without this check, the polyfills below would also be applied\n// in web browsers. Unfortunately, Safari doesn't sypport BYOB streams\n// and doesn't support the polyfill provided here. Let's only apply\n// those polyfills in Node.js environments.\nif (currentJsRuntime === 'NODE') {\n\t/**\n\t * WordPress Playground heavily realies on the File class. This module\n\t * polyfill the File class for the different environments where\n\t * WordPress Playground may run.\n\t */\n\tif (typeof File === 'undefined') {\n\t\t/**\n\t\t * Polyfill the File class that isn't shipped in Node.js version 18.\n\t\t *\n\t\t * Blob conveniently provides a lot of the same methods as File, we\n\t\t * just need to implement a few File-specific properties.\n\t\t */\n\t\tclass File extends Blob {\n\t\t\treadonly name: string;\n\t\t\treadonly lastModified: number;\n\t\t\treadonly lastModifiedDate: Date;\n\t\t\twebkitRelativePath: any;\n\t\t\tconstructor(\n\t\t\t\tsources: BlobPart[],\n\t\t\t\tfileName: string,\n\t\t\t\toptions?: FilePropertyBag\n\t\t\t) {\n\t\t\t\tsuper(sources);\n\t\t\t\t/*\n\t\t\t\t * Compute a valid last modified date as that's what the\n\t\t\t\t * browsers do:\n\t\t\t\t *\n\t\t\t\t * ```\n\t\t\t\t * > new File([], '').lastModifiedDate\n\t\t\t\t * Sat Dec 16 2023 10:07:53 GMT+0100 (czas środkowoeuropejski standardowy)\n\t\t\t\t *\n\t\t\t\t * > new File([], '', { lastModified: NaN }).lastModifiedDate\n\t\t\t\t * Thu Jan 01 1970 01:00:00 GMT+0100 (czas środkowoeuropejski standardowy)\n\t\t\t\t *\n\t\t\t\t * > new File([], '', { lastModified: 'string' }).lastModifiedDate\n\t\t\t\t * Thu Jan 01 1970 01:00:00 GMT+0100 (czas środkowoeuropejski standardowy)\n\t\t\t\t *\n\t\t\t\t * > new File([], '', { lastModified: {} }).lastModifiedDate\n\t\t\t\t * Thu Jan 01 1970 01:00:00 GMT+0100 (czas środkowoeuropejski standardowy)\n\t\t\t\t * ```\n\t\t\t\t */\n\t\t\t\tlet date;\n\t\t\t\tif (options?.lastModified) {\n\t\t\t\t\tdate = new Date();\n\t\t\t\t}\n\t\t\t\tif (!date || isNaN(date.getFullYear())) {\n\t\t\t\t\tdate = new Date();\n\t\t\t\t}\n\t\t\t\tthis.lastModifiedDate = date;\n\t\t\t\tthis.lastModified = date.getMilliseconds();\n\t\t\t\tthis.name = fileName || '';\n\t\t\t}\n\t\t}\n\t\tglobal.File = File;\n\t}\n\n\t// eslint-disable-next-line no-inner-declarations\n\tfunction asPromise<T>(obj: FileReader) {\n\t\treturn new Promise<T>(function (resolve, reject) {\n\t\t\tobj.onload = obj.onerror = function (event: Event) {\n\t\t\t\tobj.onload = obj.onerror = null;\n\n\t\t\t\tif (event.type === 'load') {\n\t\t\t\t\tresolve(obj.result as T);\n\t\t\t\t} else {\n\t\t\t\t\treject(new Error('Failed to read the blob/file'));\n\t\t\t\t}\n\t\t\t};\n\t\t});\n\t}\n\n\t/**\n\t * File is a subclass of Blob. Let's polyfill the following Blob\n\t * methods that are missing in JSDOM:\n\t *\n\t * – Blob.text()\n\t * – Blob.stream()\n\t * – Blob.arrayBuffer()\n\t *\n\t * See the related JSDom issue:\n\t *\n\t * – [Implement Blob.stream, Blob.text and Blob.arrayBuffer](https://github.com/jsdom/jsdom/issues/2555).\n\t *\n\t * @source `blob-polyfill` npm package.\n\t * * By Eli Grey, https://eligrey.com\n\t * * By Jimmy Wärting, https://github.com/jimmywarting\n\t */\n\tif (typeof Blob.prototype.arrayBuffer === 'undefined') {\n\t\tBlob.prototype.arrayBuffer = function arrayBuffer() {\n\t\t\tconst reader = new FileReader();\n\t\t\treader.readAsArrayBuffer(this);\n\t\t\treturn asPromise<Uint8Array>(reader);\n\t\t};\n\t}\n\n\tif (typeof Blob.prototype.text === 'undefined') {\n\t\tBlob.prototype.text = function text() {\n\t\t\tconst reader = new FileReader();\n\t\t\treader.readAsText(this);\n\t\t\treturn asPromise<string>(reader);\n\t\t};\n\t}\n\n\t/**\n\t * Detects if BYOB (Bring Your Own Buffer) streams are supported\n\t * in the current environment.\n\t *\n\t * BYOB is a new feature in the Streams API that allows reading\n\t * an arbitrary number of bytes from a stream. It's not supported\n\t * in older versions of Node.js.\n\t *\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamBYOBReader\n\t */\n\t// eslint-disable-next-line no-inner-declarations\n\tfunction isByobSupported() {\n\t\tconst inputBytes = new Uint8Array([1, 2, 3, 4]);\n\t\tconst file = new File([inputBytes], 'test');\n\t\tconst stream = file.stream();\n\t\ttry {\n\t\t\t// This throws on older versions of node:\n\t\t\tstream.getReader({ mode: 'byob' });\n\t\t\treturn true;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Polyfill the stream() method if it either doesn't exist,\n\t * or is an older version shipped with e.g. Node.js 18 where\n\t * BYOB streams seem to be unsupported.\n\t */\n\tif (typeof Blob.prototype.stream === 'undefined' || !isByobSupported()) {\n\t\tBlob.prototype.stream = function () {\n\t\t\tlet position = 0;\n\t\t\t// eslint-disable-next-line\n\t\t\tconst blob = this;\n\t\t\treturn new ReadableStream({\n\t\t\t\ttype: 'bytes',\n\t\t\t\t// 0.5 MB seems like a reasonable chunk size, let's adjust\n\t\t\t\t// this if needed.\n\t\t\t\tautoAllocateChunkSize: 512 * 1024,\n\n\t\t\t\tasync pull(controller) {\n\t\t\t\t\tconst view = controller.byobRequest!.view;\n\n\t\t\t\t\t// Read the next chunk of data:\n\t\t\t\t\tconst chunk = blob.slice(\n\t\t\t\t\t\tposition,\n\t\t\t\t\t\tposition + view!.byteLength\n\t\t\t\t\t);\n\t\t\t\t\tconst buffer = await chunk.arrayBuffer();\n\t\t\t\t\tconst uint8array = new Uint8Array(buffer);\n\n\t\t\t\t\t// Emit that chunk:\n\t\t\t\t\tnew Uint8Array(view!.buffer).set(uint8array);\n\t\t\t\t\tconst bytesRead = uint8array.byteLength;\n\t\t\t\t\tcontroller.byobRequest!.respond(bytesRead);\n\n\t\t\t\t\t// Bump the position and close this stream once\n\t\t\t\t\t// we've read the entire blob.\n\t\t\t\t\tposition += bytesRead;\n\t\t\t\t\tif (position >= blob.size) {\n\t\t\t\t\t\tcontroller.close();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t});\n\t\t};\n\t}\n}\n\nexport default {};\n","import { currentJsRuntime } from './current-js-runtime';\n\nif (currentJsRuntime === 'NODE' && typeof CustomEvent === 'undefined') {\n\tclass CustomEvent<T = any> extends Event {\n\t\treadonly detail: T;\n\t\tconstructor(\n\t\t\tname: string,\n\t\t\toptions: {\n\t\t\t\tdetail?: T;\n\t\t\t\tbubbles?: boolean;\n\t\t\t\tcancellable?: boolean;\n\t\t\t\tcomposed?: boolean;\n\t\t\t} = {}\n\t\t) {\n\t\t\tsuper(name, options);\n\t\t\t/*\n\t\t\t * The bang symbol (`!`) here is a lie to make TypeScript happy.\n\t\t\t *\n\t\t\t * Without the bang TS has the following complaint:\n\t\t\t *\n\t\t\t * > T | undefined is not assignable to type T\n\t\t\t *\n\t\t\t * In reality, it's absolutely fine for T (or `options.detail`)\n\t\t\t * to be undefined. However, the CustomEvent interface shipped\n\t\t\t * with TypeScript doesn't think so and marks `this.details` as\n\t\t\t * a required property.\n\t\t\t *\n\t\t\t * This little and harmless trick silences that error.\n\t\t\t */\n\t\t\tthis.detail = options.detail!;\n\t\t}\n\t\tinitCustomEvent(): void {}\n\t}\n\tglobalThis.CustomEvent = CustomEvent;\n}\n"],"names":["currentJsRuntime","_a","asPromise","obj","resolve","reject","event","isByobSupported","inputBytes","stream","File","sources","fileName","options","date","reader","position","blob","controller","view","buffer","uint8array","bytesRead","CustomEvent","name"],"mappings":"aAAO,MAAMA,EAAoB,UAAY,OAC5C,OAAI,OAAO,QAAY,OAAeC,EAAA,QAAQ,UAAR,YAAAA,EAAiB,QAAS,OACxD,OACG,OAAO,OAAW,IACrB,MAGP,OAAO,kBAAsB,KAE7B,gBAAiB,kBAEV,SAEA,MAET,EAAG,ECTH,GAAID,IAAqB,OAAQ,CA0DvB,IAAAE,EAAT,SAAsBC,EAAiB,CACtC,OAAO,IAAI,QAAW,SAAUC,EAASC,EAAQ,CAChDF,EAAI,OAASA,EAAI,QAAU,SAAUG,EAAc,CAC9CH,EAAA,OAASA,EAAI,QAAU,KAEvBG,EAAM,OAAS,OAClBF,EAAQD,EAAI,MAAW,EAEhBE,EAAA,IAAI,MAAM,8BAA8B,CAAC,CAElD,CAAA,CACA,CACF,EA6CSE,EAAT,UAA2B,CACpB,MAAAC,EAAa,IAAI,WAAW,CAAC,EAAG,EAAG,EAAG,CAAC,CAAC,EAExCC,EADO,IAAI,KAAK,CAACD,CAAU,EAAG,MAAM,EACtB,OAAO,EACvB,GAAA,CAEH,OAAAC,EAAO,UAAU,CAAE,KAAM,MAAA,CAAQ,EAC1B,EAAA,MACA,CACA,MAAA,EAAA,CAET,EAxHI,GAAA,OAAO,KAAS,IAAa,CAOhC,MAAMC,UAAa,IAAK,CAKvB,YACCC,EACAC,EACAC,EACC,CACD,MAAMF,CAAO,EAmBT,IAAAG,EACAD,GAAA,MAAA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1B"}
1
+ {"version":3,"file":"index.cjs","sources":["../../../../packages/php-wasm/node-polyfills/src/lib/current-js-runtime.ts","../../../../packages/php-wasm/node-polyfills/src/lib/blob.ts","../../../../packages/php-wasm/node-polyfills/src/lib/custom-event.ts"],"sourcesContent":["export const currentJsRuntime = (function () {\n\tif (typeof process !== 'undefined' && process.release?.name === 'node') {\n\t\treturn 'NODE';\n\t} else if (typeof window !== 'undefined') {\n\t\treturn 'WEB';\n\t} else if (\n\t\t// @ts-ignore\n\t\ttypeof WorkerGlobalScope !== 'undefined' &&\n\t\t// @ts-ignore\n\t\tself instanceof (WorkerGlobalScope as any)\n\t) {\n\t\treturn 'WORKER';\n\t} else {\n\t\treturn 'NODE';\n\t}\n})();\n","import { currentJsRuntime } from './current-js-runtime';\n\n// Without this check, the polyfills below would also be applied\n// in web browsers. Unfortunately, Safari doesn't sypport BYOB streams\n// and doesn't support the polyfill provided here. Let's only apply\n// those polyfills in Node.js environments.\nif (currentJsRuntime === 'NODE') {\n\t/**\n\t * WordPress Playground heavily realies on the File class. This module\n\t * polyfill the File class for the different environments where\n\t * WordPress Playground may run.\n\t */\n\tif (typeof File === 'undefined') {\n\t\t/**\n\t\t * Polyfill the File class that isn't shipped in Node.js version 18.\n\t\t *\n\t\t * Blob conveniently provides a lot of the same methods as File, we\n\t\t * just need to implement a few File-specific properties.\n\t\t */\n\t\tclass File extends Blob {\n\t\t\treadonly name: string;\n\t\t\treadonly lastModified: number;\n\t\t\treadonly lastModifiedDate: Date;\n\t\t\twebkitRelativePath: any;\n\t\t\tconstructor(\n\t\t\t\tsources: BlobPart[],\n\t\t\t\tfileName: string,\n\t\t\t\toptions?: FilePropertyBag\n\t\t\t) {\n\t\t\t\tsuper(sources);\n\t\t\t\t/*\n\t\t\t\t * Compute a valid last modified date as that's what the\n\t\t\t\t * browsers do:\n\t\t\t\t *\n\t\t\t\t * ```\n\t\t\t\t * > new File([], '').lastModifiedDate\n\t\t\t\t * Sat Dec 16 2023 10:07:53 GMT+0100 (czas środkowoeuropejski standardowy)\n\t\t\t\t *\n\t\t\t\t * > new File([], '', { lastModified: NaN }).lastModifiedDate\n\t\t\t\t * Thu Jan 01 1970 01:00:00 GMT+0100 (czas środkowoeuropejski standardowy)\n\t\t\t\t *\n\t\t\t\t * > new File([], '', { lastModified: 'string' }).lastModifiedDate\n\t\t\t\t * Thu Jan 01 1970 01:00:00 GMT+0100 (czas środkowoeuropejski standardowy)\n\t\t\t\t *\n\t\t\t\t * > new File([], '', { lastModified: {} }).lastModifiedDate\n\t\t\t\t * Thu Jan 01 1970 01:00:00 GMT+0100 (czas środkowoeuropejski standardowy)\n\t\t\t\t * ```\n\t\t\t\t */\n\t\t\t\tlet date;\n\t\t\t\tif (options?.lastModified) {\n\t\t\t\t\tdate = new Date();\n\t\t\t\t}\n\t\t\t\tif (!date || isNaN(date.getFullYear())) {\n\t\t\t\t\tdate = new Date();\n\t\t\t\t}\n\t\t\t\tthis.lastModifiedDate = date;\n\t\t\t\tthis.lastModified = date.getMilliseconds();\n\t\t\t\tthis.name = fileName || '';\n\t\t\t}\n\t\t}\n\t\tglobal.File = File;\n\t}\n\n\t// eslint-disable-next-line no-inner-declarations\n\tfunction asPromise<T>(obj: FileReader) {\n\t\treturn new Promise<T>(function (resolve, reject) {\n\t\t\tobj.onload = obj.onerror = function (event: Event) {\n\t\t\t\tobj.onload = obj.onerror = null;\n\n\t\t\t\tif (event.type === 'load') {\n\t\t\t\t\tresolve(obj.result as T);\n\t\t\t\t} else {\n\t\t\t\t\treject(new Error('Failed to read the blob/file'));\n\t\t\t\t}\n\t\t\t};\n\t\t});\n\t}\n\n\t/**\n\t * File is a subclass of Blob. Let's polyfill the following Blob\n\t * methods that are missing in JSDOM:\n\t *\n\t * – Blob.text()\n\t * – Blob.stream()\n\t * – Blob.arrayBuffer()\n\t *\n\t * See the related JSDom issue:\n\t *\n\t * – [Implement Blob.stream, Blob.text and Blob.arrayBuffer](https://github.com/jsdom/jsdom/issues/2555).\n\t *\n\t * @source `blob-polyfill` npm package.\n\t * * By Eli Grey, https://eligrey.com\n\t * * By Jimmy Wärting, https://github.com/jimmywarting\n\t */\n\tif (typeof Blob.prototype.arrayBuffer === 'undefined') {\n\t\tBlob.prototype.arrayBuffer = function arrayBuffer() {\n\t\t\tconst reader = new FileReader();\n\t\t\treader.readAsArrayBuffer(this);\n\t\t\treturn asPromise<Uint8Array>(reader);\n\t\t};\n\t}\n\n\tif (typeof Blob.prototype.text === 'undefined') {\n\t\tBlob.prototype.text = function text() {\n\t\t\tconst reader = new FileReader();\n\t\t\treader.readAsText(this);\n\t\t\treturn asPromise<string>(reader);\n\t\t};\n\t}\n\n\t/**\n\t * Detects if BYOB (Bring Your Own Buffer) streams are supported\n\t * in the current environment.\n\t *\n\t * BYOB is a new feature in the Streams API that allows reading\n\t * an arbitrary number of bytes from a stream. It's not supported\n\t * in older versions of Node.js.\n\t *\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamBYOBReader\n\t */\n\t// eslint-disable-next-line no-inner-declarations\n\tfunction isByobSupported() {\n\t\tconst inputBytes = new Uint8Array([1, 2, 3, 4]);\n\t\tconst file = new File([inputBytes], 'test');\n\t\tconst stream = file.stream();\n\t\ttry {\n\t\t\t// This throws on older versions of node:\n\t\t\tstream.getReader({ mode: 'byob' });\n\t\t\treturn true;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Polyfill the stream() method if it either doesn't exist,\n\t * or is an older version shipped with e.g. Node.js 18 where\n\t * BYOB streams seem to be unsupported.\n\t */\n\tif (typeof Blob.prototype.stream === 'undefined' || !isByobSupported()) {\n\t\tBlob.prototype.stream = function () {\n\t\t\tlet position = 0;\n\t\t\t// eslint-disable-next-line\n\t\t\tconst blob = this;\n\t\t\treturn new ReadableStream({\n\t\t\t\ttype: 'bytes',\n\t\t\t\t// 0.5 MB seems like a reasonable chunk size, let's adjust\n\t\t\t\t// this if needed.\n\t\t\t\tautoAllocateChunkSize: 512 * 1024,\n\n\t\t\t\tasync pull(controller) {\n\t\t\t\t\tconst view = controller.byobRequest!.view;\n\n\t\t\t\t\t// Read the next chunk of data:\n\t\t\t\t\tconst chunk = blob.slice(\n\t\t\t\t\t\tposition,\n\t\t\t\t\t\tposition + view!.byteLength\n\t\t\t\t\t);\n\t\t\t\t\tconst buffer = await chunk.arrayBuffer();\n\t\t\t\t\tconst uint8array = new Uint8Array(buffer);\n\n\t\t\t\t\t// Emit that chunk:\n\t\t\t\t\tnew Uint8Array(view!.buffer).set(uint8array);\n\t\t\t\t\tconst bytesRead = uint8array.byteLength;\n\t\t\t\t\tcontroller.byobRequest!.respond(bytesRead);\n\n\t\t\t\t\t// Bump the position and close this stream once\n\t\t\t\t\t// we've read the entire blob.\n\t\t\t\t\tposition += bytesRead;\n\t\t\t\t\tif (position >= blob.size) {\n\t\t\t\t\t\tcontroller.close();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t});\n\t\t};\n\t}\n}\n\nexport default {};\n","import { currentJsRuntime } from './current-js-runtime';\n\nif (currentJsRuntime === 'NODE' && typeof CustomEvent === 'undefined') {\n\tclass CustomEvent<T = any> extends Event {\n\t\treadonly detail: T;\n\t\tconstructor(\n\t\t\tname: string,\n\t\t\toptions: {\n\t\t\t\tdetail?: T;\n\t\t\t\tbubbles?: boolean;\n\t\t\t\tcancellable?: boolean;\n\t\t\t\tcomposed?: boolean;\n\t\t\t} = {}\n\t\t) {\n\t\t\tsuper(name, options);\n\t\t\t/*\n\t\t\t * The bang symbol (`!`) here is a lie to make TypeScript happy.\n\t\t\t *\n\t\t\t * Without the bang TS has the following complaint:\n\t\t\t *\n\t\t\t * > T | undefined is not assignable to type T\n\t\t\t *\n\t\t\t * In reality, it's absolutely fine for T (or `options.detail`)\n\t\t\t * to be undefined. However, the CustomEvent interface shipped\n\t\t\t * with TypeScript doesn't think so and marks `this.details` as\n\t\t\t * a required property.\n\t\t\t *\n\t\t\t * This little and harmless trick silences that error.\n\t\t\t */\n\t\t\tthis.detail = options.detail!;\n\t\t}\n\t\tinitCustomEvent(): void {}\n\t}\n\tglobalThis.CustomEvent = CustomEvent;\n}\n"],"names":["currentJsRuntime","_a","asPromise","obj","resolve","reject","event","isByobSupported","inputBytes","stream","File","sources","fileName","options","date","reader","position","blob","controller","view","buffer","uint8array","bytesRead","CustomEvent","name"],"mappings":"aAAO,MAAMA,EAAoB,UAAY,OAC5C,OAAI,OAAO,QAAY,OAAeC,EAAA,QAAQ,UAAR,YAAAA,EAAiB,QAAS,OACxD,OACG,OAAO,OAAW,IACrB,MAGP,OAAO,kBAAsB,KAE7B,gBAAiB,kBAEV,SAEA,MAET,EAAA,ECTA,GAAID,IAAqB,OAAQ,CA0DhC,IAASE,EAAT,SAAsBC,EAAiB,CACtC,OAAO,IAAI,QAAW,SAAUC,EAASC,EAAQ,CAChDF,EAAI,OAASA,EAAI,QAAU,SAAUG,EAAc,CAClDH,EAAI,OAASA,EAAI,QAAU,KAEvBG,EAAM,OAAS,OAClBF,EAAQD,EAAI,MAAW,EAEvBE,EAAO,IAAI,MAAM,8BAA8B,CAAC,CAElD,CACD,CAAC,CACF,EA6CSE,EAAT,UAA2B,CAC1B,MAAMC,EAAa,IAAI,WAAW,CAAC,EAAG,EAAG,EAAG,CAAC,CAAC,EAExCC,EADO,IAAI,KAAK,CAACD,CAAU,EAAG,MAAM,EACtB,OAAA,EACpB,GAAI,CAEH,OAAAC,EAAO,UAAU,CAAE,KAAM,MAAA,CAAQ,EAC1B,EACR,MAAQ,CACP,MAAO,EACR,CACD,EAxHA,GAAI,OAAO,KAAS,IAAa,CAOhC,MAAMC,UAAa,IAAK,CAKvB,YACCC,EACAC,EACAC,EACC,CACD,MAAMF,CAAO,EAmBb,IAAIG,EACAD,GAAA,MAAAA,EAAS,eACZC,MAAW,OAER,CAACA,GAAQ,MAAMA,EAAK,YAAA,CAAa,KACpCA,MAAW,MAEZ,KAAK,iBAAmBA,EACxB,KAAK,aAAeA,EAAK,gBAAA,EACzB,KAAK,KAAOF,GAAY,EACzB,CAAA,CAED,OAAO,KAAOF,CACf,CAiCI,OAAO,KAAK,UAAU,YAAgB,MACzC,KAAK,UAAU,YAAc,UAAuB,CACnD,MAAMK,EAAS,IAAI,WACnB,OAAAA,EAAO,kBAAkB,IAAI,EACtBb,EAAsBa,CAAM,CACpC,GAGG,OAAO,KAAK,UAAU,KAAS,MAClC,KAAK,UAAU,KAAO,UAAgB,CACrC,MAAMA,EAAS,IAAI,WACnB,OAAAA,EAAO,WAAW,IAAI,EACfb,EAAkBa,CAAM,CAChC,IAgCG,OAAO,KAAK,UAAU,OAAW,KAAe,CAACR,OACpD,KAAK,UAAU,OAAS,UAAY,CACnC,IAAIS,EAAW,EAEf,MAAMC,EAAO,KACb,OAAO,IAAI,eAAe,CACzB,KAAM,QAGN,sBAAuB,IAAM,KAE7B,MAAM,KAAKC,EAAY,CACtB,MAAMC,EAAOD,EAAW,YAAa,KAO/BE,EAAS,MAJDH,EAAK,MAClBD,EACAA,EAAWG,EAAM,UAAA,EAES,YAAA,EACrBE,EAAa,IAAI,WAAWD,CAAM,EAGxC,IAAI,WAAWD,EAAM,MAAM,EAAE,IAAIE,CAAU,EAC3C,MAAMC,EAAYD,EAAW,WAC7BH,EAAW,YAAa,QAAQI,CAAS,EAIzCN,GAAYM,EACRN,GAAYC,EAAK,MACpBC,EAAW,MAAA,CAEb,CAAA,CACA,CACF,EAEF,CC9KA,GAAIlB,IAAqB,QAAU,OAAO,YAAgB,IAAa,CACtE,MAAMuB,UAA6B,KAAM,CAExC,YACCC,EACAX,EAKI,GACH,CACD,MAAMW,EAAMX,CAAO,EAenB,KAAK,OAASA,EAAQ,MACvB,CACA,iBAAwB,CAAC,CAAA,CAE1B,WAAW,YAAcU,CAC1B"}
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../packages/php-wasm/node-polyfills/src/lib/current-js-runtime.ts","../../../../packages/php-wasm/node-polyfills/src/lib/blob.ts","../../../../packages/php-wasm/node-polyfills/src/lib/custom-event.ts"],"sourcesContent":["export const currentJsRuntime = (function () {\n\tif (typeof process !== 'undefined' && process.release?.name === 'node') {\n\t\treturn 'NODE';\n\t} else if (typeof window !== 'undefined') {\n\t\treturn 'WEB';\n\t} else if (\n\t\t// @ts-ignore\n\t\ttypeof WorkerGlobalScope !== 'undefined' &&\n\t\t// @ts-ignore\n\t\tself instanceof (WorkerGlobalScope as any)\n\t) {\n\t\treturn 'WORKER';\n\t} else {\n\t\treturn 'NODE';\n\t}\n})();\n","import { currentJsRuntime } from './current-js-runtime';\n\n// Without this check, the polyfills below would also be applied\n// in web browsers. Unfortunately, Safari doesn't sypport BYOB streams\n// and doesn't support the polyfill provided here. Let's only apply\n// those polyfills in Node.js environments.\nif (currentJsRuntime === 'NODE') {\n\t/**\n\t * WordPress Playground heavily realies on the File class. This module\n\t * polyfill the File class for the different environments where\n\t * WordPress Playground may run.\n\t */\n\tif (typeof File === 'undefined') {\n\t\t/**\n\t\t * Polyfill the File class that isn't shipped in Node.js version 18.\n\t\t *\n\t\t * Blob conveniently provides a lot of the same methods as File, we\n\t\t * just need to implement a few File-specific properties.\n\t\t */\n\t\tclass File extends Blob {\n\t\t\treadonly name: string;\n\t\t\treadonly lastModified: number;\n\t\t\treadonly lastModifiedDate: Date;\n\t\t\twebkitRelativePath: any;\n\t\t\tconstructor(\n\t\t\t\tsources: BlobPart[],\n\t\t\t\tfileName: string,\n\t\t\t\toptions?: FilePropertyBag\n\t\t\t) {\n\t\t\t\tsuper(sources);\n\t\t\t\t/*\n\t\t\t\t * Compute a valid last modified date as that's what the\n\t\t\t\t * browsers do:\n\t\t\t\t *\n\t\t\t\t * ```\n\t\t\t\t * > new File([], '').lastModifiedDate\n\t\t\t\t * Sat Dec 16 2023 10:07:53 GMT+0100 (czas środkowoeuropejski standardowy)\n\t\t\t\t *\n\t\t\t\t * > new File([], '', { lastModified: NaN }).lastModifiedDate\n\t\t\t\t * Thu Jan 01 1970 01:00:00 GMT+0100 (czas środkowoeuropejski standardowy)\n\t\t\t\t *\n\t\t\t\t * > new File([], '', { lastModified: 'string' }).lastModifiedDate\n\t\t\t\t * Thu Jan 01 1970 01:00:00 GMT+0100 (czas środkowoeuropejski standardowy)\n\t\t\t\t *\n\t\t\t\t * > new File([], '', { lastModified: {} }).lastModifiedDate\n\t\t\t\t * Thu Jan 01 1970 01:00:00 GMT+0100 (czas środkowoeuropejski standardowy)\n\t\t\t\t * ```\n\t\t\t\t */\n\t\t\t\tlet date;\n\t\t\t\tif (options?.lastModified) {\n\t\t\t\t\tdate = new Date();\n\t\t\t\t}\n\t\t\t\tif (!date || isNaN(date.getFullYear())) {\n\t\t\t\t\tdate = new Date();\n\t\t\t\t}\n\t\t\t\tthis.lastModifiedDate = date;\n\t\t\t\tthis.lastModified = date.getMilliseconds();\n\t\t\t\tthis.name = fileName || '';\n\t\t\t}\n\t\t}\n\t\tglobal.File = File;\n\t}\n\n\t// eslint-disable-next-line no-inner-declarations\n\tfunction asPromise<T>(obj: FileReader) {\n\t\treturn new Promise<T>(function (resolve, reject) {\n\t\t\tobj.onload = obj.onerror = function (event: Event) {\n\t\t\t\tobj.onload = obj.onerror = null;\n\n\t\t\t\tif (event.type === 'load') {\n\t\t\t\t\tresolve(obj.result as T);\n\t\t\t\t} else {\n\t\t\t\t\treject(new Error('Failed to read the blob/file'));\n\t\t\t\t}\n\t\t\t};\n\t\t});\n\t}\n\n\t/**\n\t * File is a subclass of Blob. Let's polyfill the following Blob\n\t * methods that are missing in JSDOM:\n\t *\n\t * – Blob.text()\n\t * – Blob.stream()\n\t * – Blob.arrayBuffer()\n\t *\n\t * See the related JSDom issue:\n\t *\n\t * – [Implement Blob.stream, Blob.text and Blob.arrayBuffer](https://github.com/jsdom/jsdom/issues/2555).\n\t *\n\t * @source `blob-polyfill` npm package.\n\t * * By Eli Grey, https://eligrey.com\n\t * * By Jimmy Wärting, https://github.com/jimmywarting\n\t */\n\tif (typeof Blob.prototype.arrayBuffer === 'undefined') {\n\t\tBlob.prototype.arrayBuffer = function arrayBuffer() {\n\t\t\tconst reader = new FileReader();\n\t\t\treader.readAsArrayBuffer(this);\n\t\t\treturn asPromise<Uint8Array>(reader);\n\t\t};\n\t}\n\n\tif (typeof Blob.prototype.text === 'undefined') {\n\t\tBlob.prototype.text = function text() {\n\t\t\tconst reader = new FileReader();\n\t\t\treader.readAsText(this);\n\t\t\treturn asPromise<string>(reader);\n\t\t};\n\t}\n\n\t/**\n\t * Detects if BYOB (Bring Your Own Buffer) streams are supported\n\t * in the current environment.\n\t *\n\t * BYOB is a new feature in the Streams API that allows reading\n\t * an arbitrary number of bytes from a stream. It's not supported\n\t * in older versions of Node.js.\n\t *\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamBYOBReader\n\t */\n\t// eslint-disable-next-line no-inner-declarations\n\tfunction isByobSupported() {\n\t\tconst inputBytes = new Uint8Array([1, 2, 3, 4]);\n\t\tconst file = new File([inputBytes], 'test');\n\t\tconst stream = file.stream();\n\t\ttry {\n\t\t\t// This throws on older versions of node:\n\t\t\tstream.getReader({ mode: 'byob' });\n\t\t\treturn true;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Polyfill the stream() method if it either doesn't exist,\n\t * or is an older version shipped with e.g. Node.js 18 where\n\t * BYOB streams seem to be unsupported.\n\t */\n\tif (typeof Blob.prototype.stream === 'undefined' || !isByobSupported()) {\n\t\tBlob.prototype.stream = function () {\n\t\t\tlet position = 0;\n\t\t\t// eslint-disable-next-line\n\t\t\tconst blob = this;\n\t\t\treturn new ReadableStream({\n\t\t\t\ttype: 'bytes',\n\t\t\t\t// 0.5 MB seems like a reasonable chunk size, let's adjust\n\t\t\t\t// this if needed.\n\t\t\t\tautoAllocateChunkSize: 512 * 1024,\n\n\t\t\t\tasync pull(controller) {\n\t\t\t\t\tconst view = controller.byobRequest!.view;\n\n\t\t\t\t\t// Read the next chunk of data:\n\t\t\t\t\tconst chunk = blob.slice(\n\t\t\t\t\t\tposition,\n\t\t\t\t\t\tposition + view!.byteLength\n\t\t\t\t\t);\n\t\t\t\t\tconst buffer = await chunk.arrayBuffer();\n\t\t\t\t\tconst uint8array = new Uint8Array(buffer);\n\n\t\t\t\t\t// Emit that chunk:\n\t\t\t\t\tnew Uint8Array(view!.buffer).set(uint8array);\n\t\t\t\t\tconst bytesRead = uint8array.byteLength;\n\t\t\t\t\tcontroller.byobRequest!.respond(bytesRead);\n\n\t\t\t\t\t// Bump the position and close this stream once\n\t\t\t\t\t// we've read the entire blob.\n\t\t\t\t\tposition += bytesRead;\n\t\t\t\t\tif (position >= blob.size) {\n\t\t\t\t\t\tcontroller.close();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t});\n\t\t};\n\t}\n}\n\nexport default {};\n","import { currentJsRuntime } from './current-js-runtime';\n\nif (currentJsRuntime === 'NODE' && typeof CustomEvent === 'undefined') {\n\tclass CustomEvent<T = any> extends Event {\n\t\treadonly detail: T;\n\t\tconstructor(\n\t\t\tname: string,\n\t\t\toptions: {\n\t\t\t\tdetail?: T;\n\t\t\t\tbubbles?: boolean;\n\t\t\t\tcancellable?: boolean;\n\t\t\t\tcomposed?: boolean;\n\t\t\t} = {}\n\t\t) {\n\t\t\tsuper(name, options);\n\t\t\t/*\n\t\t\t * The bang symbol (`!`) here is a lie to make TypeScript happy.\n\t\t\t *\n\t\t\t * Without the bang TS has the following complaint:\n\t\t\t *\n\t\t\t * > T | undefined is not assignable to type T\n\t\t\t *\n\t\t\t * In reality, it's absolutely fine for T (or `options.detail`)\n\t\t\t * to be undefined. However, the CustomEvent interface shipped\n\t\t\t * with TypeScript doesn't think so and marks `this.details` as\n\t\t\t * a required property.\n\t\t\t *\n\t\t\t * This little and harmless trick silences that error.\n\t\t\t */\n\t\t\tthis.detail = options.detail!;\n\t\t}\n\t\tinitCustomEvent(): void {}\n\t}\n\tglobalThis.CustomEvent = CustomEvent;\n}\n"],"names":["currentJsRuntime","_a","asPromise","obj","resolve","reject","event","isByobSupported","inputBytes","stream","File","sources","fileName","options","date","reader","position","blob","controller","view","buffer","uint8array","bytesRead","CustomEvent","name"],"mappings":"AAAO,MAAMA,IAAoB,WAAY;AAAtC,MAAAC;AACN,SAAI,OAAO,UAAY,SAAeA,IAAA,QAAQ,YAAR,gBAAAA,EAAiB,UAAS,SACxD,SACG,OAAO,SAAW,MACrB;AAAA;AAAA,IAGP,OAAO,oBAAsB;AAAA,IAE7B,gBAAiB,oBAEV,WAEA;AAAA;AAET,EAAG;ACTH,IAAID,MAAqB,QAAQ;AA0DvB,MAAAE,IAAT,SAAsBC,GAAiB;AACtC,WAAO,IAAI,QAAW,SAAUC,GAASC,GAAQ;AAChD,MAAAF,EAAI,SAASA,EAAI,UAAU,SAAUG,GAAc;AAC9C,QAAAH,EAAA,SAASA,EAAI,UAAU,MAEvBG,EAAM,SAAS,SAClBF,EAAQD,EAAI,MAAW,IAEhBE,EAAA,IAAI,MAAM,8BAA8B,CAAC;AAAA,MAElD;AAAA,IAAA,CACA;AAAA,EACF,GA6CSE,IAAT,WAA2B;AACpB,UAAAC,IAAa,IAAI,WAAW,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,GAExCC,IADO,IAAI,KAAK,CAACD,CAAU,GAAG,MAAM,EACtB,OAAO;AACvB,QAAA;AAEH,aAAAC,EAAO,UAAU,EAAE,MAAM,OAAA,CAAQ,GAC1B;AAAA,IAAA,QACA;AACA,aAAA;AAAA,IAAA;AAAA,EAET;AAxHI,MAAA,OAAO,OAAS,KAAa;AAAA,IAOhC,MAAMC,UAAa,KAAK;AAAA,MAKvB,YACCC,GACAC,GACAC,GACC;AACD,cAAMF,CAAO;AAmBT,YAAAG;AACJ,QAAID,KAAA,QAAAA,EAAS,iBACZC,wBAAW,KAAK,KAEb,CAACA,KAAQ,MAAMA,EAAK,YAAa,CAAA,OACpCA,wBAAW,KAAK,IAEjB,KAAK,mBAAmBA,GACnB,KAAA,eAAeA,EAAK,gBAAgB,GACzC,KAAK,OA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,cAAcU;AAC1B;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../packages/php-wasm/node-polyfills/src/lib/current-js-runtime.ts","../../../../packages/php-wasm/node-polyfills/src/lib/blob.ts","../../../../packages/php-wasm/node-polyfills/src/lib/custom-event.ts"],"sourcesContent":["export const currentJsRuntime = (function () {\n\tif (typeof process !== 'undefined' && process.release?.name === 'node') {\n\t\treturn 'NODE';\n\t} else if (typeof window !== 'undefined') {\n\t\treturn 'WEB';\n\t} else if (\n\t\t// @ts-ignore\n\t\ttypeof WorkerGlobalScope !== 'undefined' &&\n\t\t// @ts-ignore\n\t\tself instanceof (WorkerGlobalScope as any)\n\t) {\n\t\treturn 'WORKER';\n\t} else {\n\t\treturn 'NODE';\n\t}\n})();\n","import { currentJsRuntime } from './current-js-runtime';\n\n// Without this check, the polyfills below would also be applied\n// in web browsers. Unfortunately, Safari doesn't sypport BYOB streams\n// and doesn't support the polyfill provided here. Let's only apply\n// those polyfills in Node.js environments.\nif (currentJsRuntime === 'NODE') {\n\t/**\n\t * WordPress Playground heavily realies on the File class. This module\n\t * polyfill the File class for the different environments where\n\t * WordPress Playground may run.\n\t */\n\tif (typeof File === 'undefined') {\n\t\t/**\n\t\t * Polyfill the File class that isn't shipped in Node.js version 18.\n\t\t *\n\t\t * Blob conveniently provides a lot of the same methods as File, we\n\t\t * just need to implement a few File-specific properties.\n\t\t */\n\t\tclass File extends Blob {\n\t\t\treadonly name: string;\n\t\t\treadonly lastModified: number;\n\t\t\treadonly lastModifiedDate: Date;\n\t\t\twebkitRelativePath: any;\n\t\t\tconstructor(\n\t\t\t\tsources: BlobPart[],\n\t\t\t\tfileName: string,\n\t\t\t\toptions?: FilePropertyBag\n\t\t\t) {\n\t\t\t\tsuper(sources);\n\t\t\t\t/*\n\t\t\t\t * Compute a valid last modified date as that's what the\n\t\t\t\t * browsers do:\n\t\t\t\t *\n\t\t\t\t * ```\n\t\t\t\t * > new File([], '').lastModifiedDate\n\t\t\t\t * Sat Dec 16 2023 10:07:53 GMT+0100 (czas środkowoeuropejski standardowy)\n\t\t\t\t *\n\t\t\t\t * > new File([], '', { lastModified: NaN }).lastModifiedDate\n\t\t\t\t * Thu Jan 01 1970 01:00:00 GMT+0100 (czas środkowoeuropejski standardowy)\n\t\t\t\t *\n\t\t\t\t * > new File([], '', { lastModified: 'string' }).lastModifiedDate\n\t\t\t\t * Thu Jan 01 1970 01:00:00 GMT+0100 (czas środkowoeuropejski standardowy)\n\t\t\t\t *\n\t\t\t\t * > new File([], '', { lastModified: {} }).lastModifiedDate\n\t\t\t\t * Thu Jan 01 1970 01:00:00 GMT+0100 (czas środkowoeuropejski standardowy)\n\t\t\t\t * ```\n\t\t\t\t */\n\t\t\t\tlet date;\n\t\t\t\tif (options?.lastModified) {\n\t\t\t\t\tdate = new Date();\n\t\t\t\t}\n\t\t\t\tif (!date || isNaN(date.getFullYear())) {\n\t\t\t\t\tdate = new Date();\n\t\t\t\t}\n\t\t\t\tthis.lastModifiedDate = date;\n\t\t\t\tthis.lastModified = date.getMilliseconds();\n\t\t\t\tthis.name = fileName || '';\n\t\t\t}\n\t\t}\n\t\tglobal.File = File;\n\t}\n\n\t// eslint-disable-next-line no-inner-declarations\n\tfunction asPromise<T>(obj: FileReader) {\n\t\treturn new Promise<T>(function (resolve, reject) {\n\t\t\tobj.onload = obj.onerror = function (event: Event) {\n\t\t\t\tobj.onload = obj.onerror = null;\n\n\t\t\t\tif (event.type === 'load') {\n\t\t\t\t\tresolve(obj.result as T);\n\t\t\t\t} else {\n\t\t\t\t\treject(new Error('Failed to read the blob/file'));\n\t\t\t\t}\n\t\t\t};\n\t\t});\n\t}\n\n\t/**\n\t * File is a subclass of Blob. Let's polyfill the following Blob\n\t * methods that are missing in JSDOM:\n\t *\n\t * – Blob.text()\n\t * – Blob.stream()\n\t * – Blob.arrayBuffer()\n\t *\n\t * See the related JSDom issue:\n\t *\n\t * – [Implement Blob.stream, Blob.text and Blob.arrayBuffer](https://github.com/jsdom/jsdom/issues/2555).\n\t *\n\t * @source `blob-polyfill` npm package.\n\t * * By Eli Grey, https://eligrey.com\n\t * * By Jimmy Wärting, https://github.com/jimmywarting\n\t */\n\tif (typeof Blob.prototype.arrayBuffer === 'undefined') {\n\t\tBlob.prototype.arrayBuffer = function arrayBuffer() {\n\t\t\tconst reader = new FileReader();\n\t\t\treader.readAsArrayBuffer(this);\n\t\t\treturn asPromise<Uint8Array>(reader);\n\t\t};\n\t}\n\n\tif (typeof Blob.prototype.text === 'undefined') {\n\t\tBlob.prototype.text = function text() {\n\t\t\tconst reader = new FileReader();\n\t\t\treader.readAsText(this);\n\t\t\treturn asPromise<string>(reader);\n\t\t};\n\t}\n\n\t/**\n\t * Detects if BYOB (Bring Your Own Buffer) streams are supported\n\t * in the current environment.\n\t *\n\t * BYOB is a new feature in the Streams API that allows reading\n\t * an arbitrary number of bytes from a stream. It's not supported\n\t * in older versions of Node.js.\n\t *\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamBYOBReader\n\t */\n\t// eslint-disable-next-line no-inner-declarations\n\tfunction isByobSupported() {\n\t\tconst inputBytes = new Uint8Array([1, 2, 3, 4]);\n\t\tconst file = new File([inputBytes], 'test');\n\t\tconst stream = file.stream();\n\t\ttry {\n\t\t\t// This throws on older versions of node:\n\t\t\tstream.getReader({ mode: 'byob' });\n\t\t\treturn true;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Polyfill the stream() method if it either doesn't exist,\n\t * or is an older version shipped with e.g. Node.js 18 where\n\t * BYOB streams seem to be unsupported.\n\t */\n\tif (typeof Blob.prototype.stream === 'undefined' || !isByobSupported()) {\n\t\tBlob.prototype.stream = function () {\n\t\t\tlet position = 0;\n\t\t\t// eslint-disable-next-line\n\t\t\tconst blob = this;\n\t\t\treturn new ReadableStream({\n\t\t\t\ttype: 'bytes',\n\t\t\t\t// 0.5 MB seems like a reasonable chunk size, let's adjust\n\t\t\t\t// this if needed.\n\t\t\t\tautoAllocateChunkSize: 512 * 1024,\n\n\t\t\t\tasync pull(controller) {\n\t\t\t\t\tconst view = controller.byobRequest!.view;\n\n\t\t\t\t\t// Read the next chunk of data:\n\t\t\t\t\tconst chunk = blob.slice(\n\t\t\t\t\t\tposition,\n\t\t\t\t\t\tposition + view!.byteLength\n\t\t\t\t\t);\n\t\t\t\t\tconst buffer = await chunk.arrayBuffer();\n\t\t\t\t\tconst uint8array = new Uint8Array(buffer);\n\n\t\t\t\t\t// Emit that chunk:\n\t\t\t\t\tnew Uint8Array(view!.buffer).set(uint8array);\n\t\t\t\t\tconst bytesRead = uint8array.byteLength;\n\t\t\t\t\tcontroller.byobRequest!.respond(bytesRead);\n\n\t\t\t\t\t// Bump the position and close this stream once\n\t\t\t\t\t// we've read the entire blob.\n\t\t\t\t\tposition += bytesRead;\n\t\t\t\t\tif (position >= blob.size) {\n\t\t\t\t\t\tcontroller.close();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t});\n\t\t};\n\t}\n}\n\nexport default {};\n","import { currentJsRuntime } from './current-js-runtime';\n\nif (currentJsRuntime === 'NODE' && typeof CustomEvent === 'undefined') {\n\tclass CustomEvent<T = any> extends Event {\n\t\treadonly detail: T;\n\t\tconstructor(\n\t\t\tname: string,\n\t\t\toptions: {\n\t\t\t\tdetail?: T;\n\t\t\t\tbubbles?: boolean;\n\t\t\t\tcancellable?: boolean;\n\t\t\t\tcomposed?: boolean;\n\t\t\t} = {}\n\t\t) {\n\t\t\tsuper(name, options);\n\t\t\t/*\n\t\t\t * The bang symbol (`!`) here is a lie to make TypeScript happy.\n\t\t\t *\n\t\t\t * Without the bang TS has the following complaint:\n\t\t\t *\n\t\t\t * > T | undefined is not assignable to type T\n\t\t\t *\n\t\t\t * In reality, it's absolutely fine for T (or `options.detail`)\n\t\t\t * to be undefined. However, the CustomEvent interface shipped\n\t\t\t * with TypeScript doesn't think so and marks `this.details` as\n\t\t\t * a required property.\n\t\t\t *\n\t\t\t * This little and harmless trick silences that error.\n\t\t\t */\n\t\t\tthis.detail = options.detail!;\n\t\t}\n\t\tinitCustomEvent(): void {}\n\t}\n\tglobalThis.CustomEvent = CustomEvent;\n}\n"],"names":["currentJsRuntime","_a","asPromise","obj","resolve","reject","event","isByobSupported","inputBytes","stream","File","sources","fileName","options","date","reader","position","blob","controller","view","buffer","uint8array","bytesRead","CustomEvent","name"],"mappings":"AAAO,MAAMA,IAAoB,WAAY;AAAtC,MAAAC;AACN,SAAI,OAAO,UAAY,SAAeA,IAAA,QAAQ,YAAR,gBAAAA,EAAiB,UAAS,SACxD,SACG,OAAO,SAAW,MACrB;AAAA;AAAA,IAGP,OAAO,oBAAsB;AAAA,IAE7B,gBAAiB,oBAEV,WAEA;AAAA;AAET,EAAA;ACTA,IAAID,MAAqB,QAAQ;AA0DhC,MAASE,IAAT,SAAsBC,GAAiB;AACtC,WAAO,IAAI,QAAW,SAAUC,GAASC,GAAQ;AAChD,MAAAF,EAAI,SAASA,EAAI,UAAU,SAAUG,GAAc;AAClD,QAAAH,EAAI,SAASA,EAAI,UAAU,MAEvBG,EAAM,SAAS,SAClBF,EAAQD,EAAI,MAAW,IAEvBE,EAAO,IAAI,MAAM,8BAA8B,CAAC;AAAA,MAElD;AAAA,IACD,CAAC;AAAA,EACF,GA6CSE,IAAT,WAA2B;AAC1B,UAAMC,IAAa,IAAI,WAAW,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,GAExCC,IADO,IAAI,KAAK,CAACD,CAAU,GAAG,MAAM,EACtB,OAAA;AACpB,QAAI;AAEH,aAAAC,EAAO,UAAU,EAAE,MAAM,OAAA,CAAQ,GAC1B;AAAA,IACR,QAAQ;AACP,aAAO;AAAA,IACR;AAAA,EACD;AAxHA,MAAI,OAAO,OAAS,KAAa;AAAA,IAOhC,MAAMC,UAAa,KAAK;AAAA,MAKvB,YACCC,GACAC,GACAC,GACC;AACD,cAAMF,CAAO;AAmBb,YAAIG;AACJ,QAAID,KAAA,QAAAA,EAAS,iBACZC,wBAAW,KAAA,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IACH;AACD,YAAMW,GAAMX,CAAO,GAenB,KAAK,SAASA,EAAQ;AAAA,IACvB;AAAA,IACA,kBAAwB;AAAA,IAAC;AAAA,EAAA;AAE1B,aAAW,cAAcU;AAC1B;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@php-wasm/node-polyfills",
3
- "version": "3.0.15",
3
+ "version": "3.0.16",
4
4
  "description": "PHP.wasm – polyfills for Node.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -31,7 +31,7 @@
31
31
  "directory": "../../../dist/packages/php-wasm/node-polyfills"
32
32
  },
33
33
  "license": "GPL-2.0-or-later",
34
- "gitHead": "4e8addef4a0fa0e76f26785689a1a676bbb823e1",
34
+ "gitHead": "1f96a559fda4946f36f8543a2715cee411a5c8f2",
35
35
  "packageManager": "npm@10.9.2",
36
36
  "overrides": {
37
37
  "rollup": "^4.34.6",