From 7f1afcf1c504011d465666d239867a2805ee20e3 Mon Sep 17 00:00:00 2001 From: Bob Fanger Date: Tue, 18 Apr 2023 18:22:27 +0200 Subject: [PATCH] fix: Properties when not using __PIXI_APP__ `let mode` was declared outside the injected code. Fixes #117 Also added _lastObjectRendered as scene fallback, making the `globalThis.__PIXI_STAGE__ = yourContainer;` also optional in Pixi v5.x --- apps/chrome-extension/src/manifest.json | 2 +- apps/firefox-extension/src/manifest.json | 2 +- packages/pixi-panel/src/pixi-devtools/pixiDevtools.ts | 9 ++++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/apps/chrome-extension/src/manifest.json b/apps/chrome-extension/src/manifest.json index 2860dce..b4d09cf 100644 --- a/apps/chrome-extension/src/manifest.json +++ b/apps/chrome-extension/src/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 3, "name": "PixiJS Devtools", "description": "Debug games and apps written with PixiJS", - "version": "2.6.0", + "version": "2.6.1", "devtools_page": "pixi-devtools.html", "icons": { "16": "icon.png", diff --git a/apps/firefox-extension/src/manifest.json b/apps/firefox-extension/src/manifest.json index 258ac72..ed600ce 100644 --- a/apps/firefox-extension/src/manifest.json +++ b/apps/firefox-extension/src/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 3, "name": "PixiJS Devtools", "description": "Debug games and apps written with PixiJS", - "version": "2.6.0", + "version": "2.6.1", "devtools_page": "pixi-devtools.html", "icons": { "48": "icon.png", diff --git a/packages/pixi-panel/src/pixi-devtools/pixiDevtools.ts b/packages/pixi-panel/src/pixi-devtools/pixiDevtools.ts index 5d7fd93..ed9072b 100644 --- a/packages/pixi-panel/src/pixi-devtools/pixiDevtools.ts +++ b/packages/pixi-panel/src/pixi-devtools/pixiDevtools.ts @@ -12,11 +12,12 @@ type EventDetail = { activate: UniversalNode | undefined; }; -let mode: "PIXI" | "PHASER" | undefined; export default function pixiDevtools() { const eventTarget = new EventTarget(); const win = window as any; + let mode: "PIXI" | "PHASER" | undefined; + function getGlobal(varname: string) { if (win[varname]) { return win[varname]; @@ -57,11 +58,13 @@ export default function pixiDevtools() { } const renderer = getGlobal("__PIXI_RENDERER__"); if (renderer) { - return renderer.lastObjectRendered; + // eslint-disable-next-line no-underscore-dangle + return renderer.lastObjectRendered ?? renderer._lastObjectRendered; } const patched = getGlobal("__PATCHED_RENDERER__"); if (patched) { - return patched.lastObjectRendered; + // eslint-disable-next-line no-underscore-dangle + return patched.lastObjectRendered ?? patched._lastObjectRendered; } return undefined; },