Skip to content

Commit

Permalink
fix: a hydration error in SSR apps (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
koba04 authored Jul 12, 2022
1 parent 804a2f5 commit c30626f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 21 deletions.
6 changes: 6 additions & 0 deletions packages/swr-devtools-extensions/manifest-v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
"background.js"
]
},
"permissions": [
"scripting",
"tabs",
"http://*/",
"https://*/"
],
"content_scripts": [
{
"matches": [
Expand Down
20 changes: 8 additions & 12 deletions packages/swr-devtools-extensions/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
"background": {
"service_worker": "background.js"
},
"permissions": [
"scripting",
"tabs"
],
"host_permissions": [
"http://*/",
"https://*/"
],
"content_scripts": [
{
"matches": [
Expand All @@ -24,17 +32,5 @@
],
"run_at": "document_start"
}
],
"web_accessible_resources": [
{
"resources": [
"web-accessible.js"
],
"matches": [
"https://*/*",
"http://*/*"

]
}
]
}
8 changes: 0 additions & 8 deletions packages/swr-devtools-extensions/src/content.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
import { DevToolsMessage } from "swr-devtools";
import { Runtime, runtime } from "webextension-polyfill";

const injectDevToolsHook = () => {
const script = document.createElement("script");
script.setAttribute("type", "text/javascript");
script.setAttribute("src", chrome.runtime.getURL("web-accessible.js"));
document.documentElement.appendChild(script);
};
injectDevToolsHook();

export type ContentMessage =
| {
type: "load";
Expand Down
13 changes: 12 additions & 1 deletion packages/swr-devtools-extensions/src/devtools.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import { devtools } from "webextension-polyfill";
import { devtools, scripting } from "webextension-polyfill";

devtools.panels.create("SWR", "", "panel.html").then(() => {
console.log("The DevTools panel has been created");
});

scripting
.executeScript({
target: {
tabId: devtools.inspectedWindow.tabId,
allFrames: true,
},
files: ["web-accessible.js"],
})
.then((r) => console.log("executeScript has been success", r))
.catch((e) => console.log("executeScript has been failed", e));

1 comment on commit c30626f

@vercel
Copy link

@vercel vercel bot commented on c30626f Jul 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

swr-devtools – ./

swr-devtools-koba04.vercel.app
swr-devtools.vercel.app
swr-devtools-git-main-koba04.vercel.app

Please sign in to comment.