Skip to content

Commit

Permalink
Fix: Worker ReferenceError in Node.js (#10227)
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperSodaSea committed Feb 18, 2024
1 parent e10fa5b commit b631cc5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
4 changes: 3 additions & 1 deletion global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

declare module '*.worker.ts'
{
class WorkerInstance extends Worker
class WorkerInstance
{
public worker: Worker;

constructor();

static revokeObjectURL(): void;
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"devDependencies": {
"@pixi/eslint-config": "^5.1.0",
"@pixi/webdoc-template": "^1.5.5",
"@pixi/webworker-plugins": "^0.2.0",
"@pixi/webworker-plugins": "^0.3.0",
"@rollup/plugin-alias": "^5.0.0",
"@rollup/plugin-commonjs": "^25.0.0",
"@rollup/plugin-json": "^6.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/assets/src/loader/parsers/WorkerManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class WorkerManagerClass

this._isImageBitmapSupported = new Promise((resolve) =>
{
const worker = new CheckImageBitmapWorker();
const { worker } = new CheckImageBitmapWorker();

worker.addEventListener('message', (event: MessageEvent<boolean>) =>
{
Expand Down Expand Up @@ -82,7 +82,7 @@ class WorkerManagerClass
{
// only create as many as MAX_WORKERS allows..
this._createdWorkers++;
worker = new LoadImageBitmapWorker();
worker = (new LoadImageBitmapWorker()).worker;

worker.addEventListener('message', (event: MessageEvent) =>
{
Expand Down

0 comments on commit b631cc5

Please sign in to comment.