From d9f622ea1e30b2a1eb07f40262a73dcb70892ae5 Mon Sep 17 00:00:00 2001 From: Zyie <24736175+Zyie@users.noreply.github.com> Date: Tue, 13 Feb 2024 20:27:09 +0000 Subject: [PATCH] update wording --- global.d.ts | 2 +- src/chrome/src/inject/devtool.ts | 16 ++++++++-------- .../src/inject/properties/PropertyPlugins.ts | 2 +- src/example/index.ts | 2 +- vite.chrome.config.ts | 15 +++++++++++++++ 5 files changed, 26 insertions(+), 11 deletions(-) diff --git a/global.d.ts b/global.d.ts index 5f4c242..8dd712c 100644 --- a/global.d.ts +++ b/global.d.ts @@ -5,7 +5,7 @@ declare global { __PIXI_RENDERER__: import('pixi.js').Renderer | undefined; __PIXI__: import('pixi.js'); __PIXI_DEVTOOLS_WRAPPER__: any; - __PIXI__DEVTOOLS__: { + __PIXI_DEVTOOLS__: { pixi: typeof import('pixi.js'); app: import('pixi.js').Application | undefined; stage?: import('pixi.js').Container | undefined; diff --git a/src/chrome/src/inject/devtool.ts b/src/chrome/src/inject/devtool.ts index 435926f..6e273ee 100644 --- a/src/chrome/src/inject/devtool.ts +++ b/src/chrome/src/inject/devtool.ts @@ -23,14 +23,14 @@ export function getPixiWrapper(): Pixi { if (!pixiWrapper) { pixiWrapper = { app: () => { - if (window.__PIXI__DEVTOOLS__?.app) { - return window.__PIXI__DEVTOOLS__.app; + if (window.__PIXI_DEVTOOLS__?.app) { + return window.__PIXI_DEVTOOLS__.app; } return window.__PIXI_APP__; }, stage: () => { - if (window.__PIXI__DEVTOOLS__?.stage) { - return window.__PIXI__DEVTOOLS__.stage; + if (window.__PIXI_DEVTOOLS__?.stage) { + return window.__PIXI_DEVTOOLS__.stage; } else if (window.__PIXI_STAGE__) { return window.__PIXI_STAGE__; } @@ -38,8 +38,8 @@ export function getPixiWrapper(): Pixi { return pixiWrapper!.app()?.stage; }, renderer: () => { - if (window.__PIXI__DEVTOOLS__?.renderer) { - return window.__PIXI__DEVTOOLS__.renderer; + if (window.__PIXI_DEVTOOLS__?.renderer) { + return window.__PIXI_DEVTOOLS__.renderer; } else if (window.__PIXI_RENDERER__) { return window.__PIXI_RENDERER__; } @@ -59,8 +59,8 @@ export function getPixiWrapper(): Pixi { return getPixiState(); }, pixi: () => { - if (window.__PIXI__DEVTOOLS__?.pixi) { - return window.__PIXI__DEVTOOLS__.pixi; + if (window.__PIXI_DEVTOOLS__?.pixi) { + return window.__PIXI_DEVTOOLS__.pixi; } return window.__PIXI__; }, diff --git a/src/chrome/src/inject/properties/PropertyPlugins.ts b/src/chrome/src/inject/properties/PropertyPlugins.ts index 188924d..7ce104a 100644 --- a/src/chrome/src/inject/properties/PropertyPlugins.ts +++ b/src/chrome/src/inject/properties/PropertyPlugins.ts @@ -70,7 +70,7 @@ export class PropertyPluginsClass { } private _getUserPlugins() { - return window.__PIXI__DEVTOOLS__?.scenePanel?.propertyPlugins || []; + return window.__PIXI_DEVTOOLS__?.scenePanel?.propertyPlugins || []; } } diff --git a/src/example/index.ts b/src/example/index.ts index b8f30b0..8c29d2d 100644 --- a/src/example/index.ts +++ b/src/example/index.ts @@ -8,7 +8,7 @@ import { Application, Assets, Container, Sprite } from 'pixi.js'; // Initialize the application await app.init({ background: '#1099bb', resizeTo: window }); - window.__PIXI__DEVTOOLS__ = { + window.__PIXI_DEVTOOLS__ = { app: app, pixi: PIXI, }; diff --git a/vite.chrome.config.ts b/vite.chrome.config.ts index be36222..a797634 100644 --- a/vite.chrome.config.ts +++ b/vite.chrome.config.ts @@ -1,6 +1,8 @@ import { crx, ManifestV3Export } from '@crxjs/vite-plugin'; import react from '@vitejs/plugin-react-swc'; import { defineConfig } from 'vite'; +import fs from 'fs'; +import path from 'path'; import { resolve } from 'path'; import pkg from './package.json'; @@ -34,6 +36,19 @@ export default defineConfig((config) => { injectCss: true, }, }), + { + name: 'manifest-plugin', + enforce: "post", + writeBundle() { + const manifestPath = path.resolve(__dirname, 'dist/chrome', 'manifest.json'); + if (fs.existsSync(manifestPath)) { + const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf-8')); + const resource = manifest.web_accessible_resources[0]; + resource.resources.push('src/inject/index.js'); + fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2)); + } + }, + }, ], publicDir, build: {