Skip to content

Commit

Permalink
Restructure @rsc-parser/chrome-extension files (#1055)
Browse files Browse the repository at this point in the history
* Restructure @rsc-parser/chrome-extension files

Trying to make things a litte bit more consistent and readable.

* Remove unnecessary output

* Rename index.html and devtools-page.html as well
  • Loading branch information
alvarlagerlof authored Jun 9, 2024
1 parent c937a64 commit 2883dd1
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 20 deletions.
10 changes: 10 additions & 0 deletions .changeset/mean-peaches-dream.md
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
3 changes: 0 additions & 3 deletions packages/chrome-extension/public/devtools-page.html

This file was deleted.

3 changes: 3 additions & 0 deletions packages/chrome-extension/public/devtoolsPage.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<body>
<script src="assets/devtoolsPage.js"></script>
</body>
6 changes: 3 additions & 3 deletions packages/chrome-extension/public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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://*/*"]
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
25 changes: 15 additions & 10 deletions packages/chrome-extension/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
{
Expand Down Expand Up @@ -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]`,
Expand All @@ -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`,
Expand Down

0 comments on commit 2883dd1

Please sign in to comment.