diff --git a/packages/php-wasm/progress/src/lib/progress-tracker.ts b/packages/php-wasm/progress/src/lib/progress-tracker.ts index 52dece074d..0e9fb30f35 100644 --- a/packages/php-wasm/progress/src/lib/progress-tracker.ts +++ b/packages/php-wasm/progress/src/lib/progress-tracker.ts @@ -1,3 +1,23 @@ +/** + * CustomEvent class for NodeJS + * @see https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent + */ +class CustomEventNode extends Event { + detail: T; + + constructor(type: string, customEventInit?: CustomEventInit) { + super(type, customEventInit); + this.detail = customEventInit?.detail + ? customEventInit.detail + : ({} as T); + } +} + +if (typeof CustomEvent === 'undefined') { + // @ts-expect-error + globalThis.CustomEvent = CustomEventNode; +} + /** * Options for customizing the progress tracker. */ diff --git a/packages/playground/blueprints/src/lib/steps/common.ts b/packages/playground/blueprints/src/lib/steps/common.ts index 0dae687f47..20bb29147a 100644 --- a/packages/playground/blueprints/src/lib/steps/common.ts +++ b/packages/playground/blueprints/src/lib/steps/common.ts @@ -24,6 +24,18 @@ export async function updateFile( export async function fileToUint8Array(file: File) { return new Uint8Array(await file.arrayBuffer()); } +/** + * File class for NodeJS + * @see https://developer.mozilla.org/en-US/docs/Web/API/File + */ +class FileNode { + // NodeJS has no File class +} + +if (typeof File === 'undefined') { + // @ts-expect-error + globalThis.File = FileNode; +} /** * Polyfill the File class in JSDOM which lacks arrayBuffer() method