diff --git a/.changeset/mean-peaches-dream.md b/.changeset/mean-peaches-dream.md new file mode 100644 index 00000000..5b4812f1 --- /dev/null +++ b/.changeset/mean-peaches-dream.md @@ -0,0 +1,10 @@ +--- +"@rsc-parser/chrome-extension": minor +"@rsc-parser/embedded-example": minor +"@rsc-parser/core": minor +"@rsc-parser/embedded": minor +"@rsc-parser/storybook": minor +"@rsc-parser/website": minor +--- + +Restructure @rsc-parser/chrome-extension files diff --git a/packages/chrome-extension/index.html b/packages/chrome-extension/devtoolsPanel.html similarity index 100% rename from packages/chrome-extension/index.html rename to packages/chrome-extension/devtoolsPanel.html diff --git a/packages/chrome-extension/public/devtools-page.html b/packages/chrome-extension/public/devtools-page.html deleted file mode 100644 index dff9305c..00000000 --- a/packages/chrome-extension/public/devtools-page.html +++ /dev/null @@ -1,3 +0,0 @@ -
- - diff --git a/packages/chrome-extension/public/devtoolsPage.html b/packages/chrome-extension/public/devtoolsPage.html new file mode 100644 index 00000000..9a595b44 --- /dev/null +++ b/packages/chrome-extension/public/devtoolsPage.html @@ -0,0 +1,3 @@ + + + diff --git a/packages/chrome-extension/public/manifest.json b/packages/chrome-extension/public/manifest.json index 353aca97..b4023596 100644 --- a/packages/chrome-extension/public/manifest.json +++ b/packages/chrome-extension/public/manifest.json @@ -6,17 +6,17 @@ "extension_pages": "script-src 'self' http://localhost:6020; object-src 'self'" }, "manifest_version": 3, - "devtools_page": "devtools-page.html", + "devtools_page": "devtoolsPage.html", "content_scripts": [ { "matches": ["http://*/*", "https://*/*"], - "js": ["assets/content-script.js"], + "js": ["assets/contentScript.js"], "all_frames": true } ], "web_accessible_resources": [ { - "resources": ["assets/fetch-patch.js"], + "resources": ["assets/fetchPatcherInjector.js"], "matches": ["http://*/*", "https://*/*"] } ] diff --git a/packages/chrome-extension/src/content-script.ts b/packages/chrome-extension/src/assets/contentScript.ts similarity index 91% rename from packages/chrome-extension/src/content-script.ts rename to packages/chrome-extension/src/assets/contentScript.ts index defc938d..989797dc 100644 --- a/packages/chrome-extension/src/content-script.ts +++ b/packages/chrome-extension/src/assets/contentScript.ts @@ -31,13 +31,16 @@ chrome.runtime.onMessage.addListener(function (request) { // only show the ones from the current tab tabId = request.data.tabId; - injectScript(chrome.runtime.getURL("assets/fetch-patch.js"), "body"); + injectScript( + chrome.runtime.getURL("assets/fetchPatcherInjector.js"), + "body", + ); } return true; }); -// This code passes along events from fetch-patch to the devtools panel +// This code passes along events from fetchPatcherInjector to the devtools panel window.addEventListener( "message", function (event) { diff --git a/packages/chrome-extension/src/devtools.ts b/packages/chrome-extension/src/assets/devtoolsPage.ts similarity index 86% rename from packages/chrome-extension/src/devtools.ts rename to packages/chrome-extension/src/assets/devtoolsPage.ts index 63361758..ac69aef4 100644 --- a/packages/chrome-extension/src/devtools.ts +++ b/packages/chrome-extension/src/assets/devtoolsPage.ts @@ -6,11 +6,10 @@ function handleHidden() { //console.log("panel is being hidden"); } -// eslint-disable-next-line no-undef chrome.devtools.panels.create( "RSC Devtools", "", - "./index.html", + "./devtoolsPanel.html", function (panel) { // console.log("Hello! from panel create"); panel.onShown.addListener(handleShown); diff --git a/packages/chrome-extension/src/fetch-patch.ts b/packages/chrome-extension/src/assets/fetchPatcherInjector.ts similarity index 100% rename from packages/chrome-extension/src/fetch-patch.ts rename to packages/chrome-extension/src/assets/fetchPatcherInjector.ts diff --git a/packages/chrome-extension/src/react-preamble.ts b/packages/chrome-extension/src/dev/reactPreamble.ts similarity index 100% rename from packages/chrome-extension/src/react-preamble.ts rename to packages/chrome-extension/src/dev/reactPreamble.ts diff --git a/packages/chrome-extension/vite.config.ts b/packages/chrome-extension/vite.config.ts index 61c0eb83..e3b23f44 100644 --- a/packages/chrome-extension/vite.config.ts +++ b/packages/chrome-extension/vite.config.ts @@ -6,7 +6,7 @@ import { resolve } from "path"; const dev = { headScripts: [ { - src: "http://localhost:6020/src/react-preamble.ts", + src: "http://localhost:6020/src/dev/reactPreamble.ts", type: "module", } as ScriptTag, { @@ -41,13 +41,15 @@ export default defineConfig(({ mode }) => { minify: false, rollupOptions: { input: { - main: resolve(__dirname, "index.html"), - "fetch-patch": resolve(__dirname, "src/fetch-patch.ts"), - "content-script": resolve(__dirname, "src/content-script.ts"), - devtools: resolve(__dirname, "src/devtools.ts"), + main: resolve(__dirname, "devtoolsPanel.html"), + fetchPatcherInjector: resolve( + __dirname, + "src/assets/fetchPatcherInjector.ts", + ), + contentScript: resolve(__dirname, "src/assets/contentScript.ts"), + devtoolsPage: resolve(__dirname, "src/assets/devtoolsPage.ts"), }, output: { - main: resolve(__dirname, "index.html"), entryFileNames: `assets/[name].js`, chunkFileNames: `assets/[name].js`, assetFileNames: `assets/[name].[ext]`, @@ -69,10 +71,13 @@ export default defineConfig(({ mode }) => { minify: false, rollupOptions: { input: { - main: resolve(__dirname, "index.html"), - "fetch-patch": resolve(__dirname, "src/fetch-patch.ts"), - "content-script": resolve(__dirname, "src/content-script.ts"), - devtools: resolve(__dirname, "src/devtools.ts"), + main: resolve(__dirname, "devtoolsPanel.html"), + fetchPatcherInjector: resolve( + __dirname, + "src/assets/fetchPatcherInjector.ts", + ), + contentScript: resolve(__dirname, "src/assets/contentScript.ts"), + devtoolsPage: resolve(__dirname, "src/assets/devtoolsPage.ts"), }, output: { entryFileNames: `assets/[name].js`,