Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: support Firefox Extension #29

Merged
merged 10 commits into from
Oct 11, 2021
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
"build": "run-s build:devtools build:panel build:extensions",
"build:devtools": "yarn workspace swr-devtools build",
"build:demo": "yarn workspace swr-devtools-demo build",
"build:extensions": "yarn workspace swr-devtools-extentions build",
"build:extensions": "yarn workspace swr-devtools-extensions build",
"build:panel": "yarn workspace swr-devtools-panel build",
"deploy:demo": "run-s build:devtools build:panel build:demo",
"prerelease": "run-s build lint",
"release": "lerna publish --conventional-commits",
"start:demo": "yarn workspace swr-devtools-demo dev",
"start:dev": "yarn workspace swr-devtools start",
"start:extensions": "yarn workspace swr-devtools-extentions start",
"start:extensions": "yarn workspace swr-devtools-extensions start",
"start:panel": "yarn workspace swr-devtools-panel start",
"start": "run-p -l start:*",
"lint:eslint": "eslint '**/pages/**/*' '**/src/**/*'",
Expand All @@ -35,4 +35,4 @@
"prettier": "^2.2.1",
"rimraf": "^3.0.2"
}
}
}
59 changes: 23 additions & 36 deletions packages/swr-devtools-extensions/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,57 +5,44 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

## [0.2.2](https://github.com/koba04/swr-devtools/compare/v0.2.0...v0.2.2) (2021-09-16)


### Bug Fixes

* reset a devtool panel when a navigation is happen ([#24](https://github.com/koba04/swr-devtools/issues/24)) ([1cc108b](https://github.com/koba04/swr-devtools/commit/1cc108bf3556b65b8d251e3b22af9505ea28e8da))
* sync SWRDevTools and a devtool panel ([#27](https://github.com/koba04/swr-devtools/issues/27)) ([ba34e6f](https://github.com/koba04/swr-devtools/commit/ba34e6ff3be261cd656a5d90f0b4bef64e1b71e8))




- reset a devtool panel when a navigation is happen ([#24](https://github.com/koba04/swr-devtools/issues/24)) ([1cc108b](https://github.com/koba04/swr-devtools/commit/1cc108bf3556b65b8d251e3b22af9505ea28e8da))
- sync SWRDevTools and a devtool panel ([#27](https://github.com/koba04/swr-devtools/issues/27)) ([ba34e6f](https://github.com/koba04/swr-devtools/commit/ba34e6ff3be261cd656a5d90f0b4bef64e1b71e8))

## [0.2.1](https://github.com/koba04/swr-devtools/compare/v0.2.0...v0.2.1) (2021-09-16)


### Bug Fixes

* reset a devtool panel when a navigation is happen ([#24](https://github.com/koba04/swr-devtools/issues/24)) ([1cc108b](https://github.com/koba04/swr-devtools/commit/1cc108bf3556b65b8d251e3b22af9505ea28e8da))
* sync SWRDevTools and a devtool panel ([#27](https://github.com/koba04/swr-devtools/issues/27)) ([ba34e6f](https://github.com/koba04/swr-devtools/commit/ba34e6ff3be261cd656a5d90f0b4bef64e1b71e8))




- reset a devtool panel when a navigation is happen ([#24](https://github.com/koba04/swr-devtools/issues/24)) ([1cc108b](https://github.com/koba04/swr-devtools/commit/1cc108bf3556b65b8d251e3b22af9505ea28e8da))
- sync SWRDevTools and a devtool panel ([#27](https://github.com/koba04/swr-devtools/issues/27)) ([ba34e6f](https://github.com/koba04/swr-devtools/commit/ba34e6ff3be261cd656a5d90f0b4bef64e1b71e8))

# 0.2.0 (2021-09-09)


### Bug Fixes

* a wrong dependency ([bc38f92](https://github.com/koba04/swr-devtools/commit/bc38f92e953a7caef7cc708fc0fc362b5a0daf62))
* an old path to the bundle js file ([56dc413](https://github.com/koba04/swr-devtools/commit/56dc4136ad698830b4e55be85841c22d0030af98))
* clean directories before running build scripts ([214150c](https://github.com/koba04/swr-devtools/commit/214150c70f6c7e823baff9ab2c16802dbb27afda))
* filter duplicated cache data and fix layouts ([501a389](https://github.com/koba04/swr-devtools/commit/501a389b269133e079bf075e1a1e619cb970a713))
* make a key name more explicit ([e263a98](https://github.com/koba04/swr-devtools/commit/e263a986b03e5e83edbf7eaf6cbed41b8752343b))
* sync cache data when opening a devtool panel ([40795db](https://github.com/koba04/swr-devtools/commit/40795dba659dbdbc883c199b59a318d9ad7c146d))
* update meta keys for v1 ([13058ac](https://github.com/koba04/swr-devtools/commit/13058ac4ec0e2f434c52246860b18b166b4af305))
* works well with v1 ([e7aba55](https://github.com/koba04/swr-devtools/commit/e7aba553ce7f2a3d77c25a0a436d58ccc4d342fa))

- a wrong dependency ([bc38f92](https://github.com/koba04/swr-devtools/commit/bc38f92e953a7caef7cc708fc0fc362b5a0daf62))
- an old path to the bundle js file ([56dc413](https://github.com/koba04/swr-devtools/commit/56dc4136ad698830b4e55be85841c22d0030af98))
- clean directories before running build scripts ([214150c](https://github.com/koba04/swr-devtools/commit/214150c70f6c7e823baff9ab2c16802dbb27afda))
- filter duplicated cache data and fix layouts ([501a389](https://github.com/koba04/swr-devtools/commit/501a389b269133e079bf075e1a1e619cb970a713))
- make a key name more explicit ([e263a98](https://github.com/koba04/swr-devtools/commit/e263a986b03e5e83edbf7eaf6cbed41b8752343b))
- sync cache data when opening a devtool panel ([40795db](https://github.com/koba04/swr-devtools/commit/40795dba659dbdbc883c199b59a318d9ad7c146d))
- update meta keys for v1 ([13058ac](https://github.com/koba04/swr-devtools/commit/13058ac4ec0e2f434c52246860b18b166b4af305))
- works well with v1 ([e7aba55](https://github.com/koba04/swr-devtools/commit/e7aba553ce7f2a3d77c25a0a436d58ccc4d342fa))

### Features

* add icons ([3e2365a](https://github.com/koba04/swr-devtools/commit/3e2365af28d9452a0536c0978798e0579c8d8e60))
* display SWRDevTools on the devtool panel ([de7e05a](https://github.com/koba04/swr-devtools/commit/de7e05a16e5be5c8211371d75f834492a11e6179))
* proxy panel events to a content port ([b727043](https://github.com/koba04/swr-devtools/commit/b72704381ee13975855eb67c1ba472f733285136))
* send cache data from a page to a content script ([97315c5](https://github.com/koba04/swr-devtools/commit/97315c501024a6346979460feb4f8b046e38f9d0))
* separate SWRDevToolsPanel as a separate package ([4ddbfdb](https://github.com/koba04/swr-devtools/commit/4ddbfdbeb7051ed4df5ded307461ab60820a4cf4))
* stop using web_accessible_resources to inject a runtime script ([0b5aad7](https://github.com/koba04/swr-devtools/commit/0b5aad79557291f8210bab369a71a9d9516098c3))
* support dark mode ([40d96a4](https://github.com/koba04/swr-devtools/commit/40d96a4b1158b367c0332737cbdb5c6cf0b0e268))
* support swr v1 beta ([9170f48](https://github.com/koba04/swr-devtools/commit/9170f4837b25436fbbde757b72c7b48bb862a16f))
* use cahce APIs exposed in v1 ([90a9775](https://github.com/koba04/swr-devtools/commit/90a977514d570c35b1157febe88b076d283f5a95))
* work on a devtools panel ([98120bd](https://github.com/koba04/swr-devtools/commit/98120bd591bddec37c2a0c69594098011b77c0a0))

- add icons ([3e2365a](https://github.com/koba04/swr-devtools/commit/3e2365af28d9452a0536c0978798e0579c8d8e60))
- display SWRDevTools on the devtool panel ([de7e05a](https://github.com/koba04/swr-devtools/commit/de7e05a16e5be5c8211371d75f834492a11e6179))
- proxy panel events to a content port ([b727043](https://github.com/koba04/swr-devtools/commit/b72704381ee13975855eb67c1ba472f733285136))
- send cache data from a page to a content script ([97315c5](https://github.com/koba04/swr-devtools/commit/97315c501024a6346979460feb4f8b046e38f9d0))
- separate SWRDevToolsPanel as a separate package ([4ddbfdb](https://github.com/koba04/swr-devtools/commit/4ddbfdbeb7051ed4df5ded307461ab60820a4cf4))
- stop using web_accessible_resources to inject a runtime script ([0b5aad7](https://github.com/koba04/swr-devtools/commit/0b5aad79557291f8210bab369a71a9d9516098c3))
- support dark mode ([40d96a4](https://github.com/koba04/swr-devtools/commit/40d96a4b1158b367c0332737cbdb5c6cf0b0e268))
- support swr v1 beta ([9170f48](https://github.com/koba04/swr-devtools/commit/9170f4837b25436fbbde757b72c7b48bb862a16f))
- use cahce APIs exposed in v1 ([90a9775](https://github.com/koba04/swr-devtools/commit/90a977514d570c35b1157febe88b076d283f5a95))
- work on a devtools panel ([98120bd](https://github.com/koba04/swr-devtools/commit/98120bd591bddec37c2a0c69594098011b77c0a0))

### BREAKING CHANGES

* drop swr v0.x support
- drop swr v0.x support
4 changes: 3 additions & 1 deletion packages/swr-devtools-extensions/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# swr-devtools-extensions

SWR Devtools is a chrome extension for [SWR](https://swr.vercel.app/), which inspects cache data of SWR.
SWR Devtools is a chrome/firefox extension for [SWR](https://swr.vercel.app/), which inspects cache data of SWR.

https://chrome.google.com/webstore/detail/swr-devtools/liidbicegefhheghhjbomajjaehnjned

Firefox: TBD

## LICENSE

[MIT](LICENSE.md)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 11 additions & 4 deletions packages/swr-devtools-extensions/manifest.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
{
"name": "SWR DevTools",
"description": "A DevTool to inspect your SWR cache",
"version": "0.2.2",
"version": "0.2.3",
"manifest_version": 2,
"icons": {
"16": "icons/swr-devtools-16.png",
"48": "icons/swr-devtools-48.png",
"64": "icons/swr-devtools-64.png",
"128": "icons/swr-devtools-128.png"
},
"devtools_page": "devtools.html",
"background": {
"scripts": ["background.js"]
"scripts": [
"background.js"
]
},
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["content.js"],
"matches": [
"<all_urls>"
],
"js": [
"content.js"
],
"run_at": "document_start"
}
]
Expand Down
8 changes: 5 additions & 3 deletions packages/swr-devtools-extensions/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "swr-devtools-extentions",
"name": "swr-devtools-extensions",
"private": "true",
"version": "0.2.2",
"version": "0.2.3",
"main": "lib/index.js",
"license": "MIT",
"scripts": {
Expand All @@ -17,9 +17,11 @@
"@types/chrome": "^0.0.154",
"@types/react": "^17.0.14",
"@types/react-dom": "^17.0.9",
"@types/webextension-polyfill": "^0.8.0",
"copy-webpack-plugin": "^9.0.1",
"ts-loader": "^9.2.3",
"typescript": "^4.3.5",
"webextension-polyfill": "^0.8.0",
"webpack": "^5.45.1",
"webpack-cli": "^4.7.2"
},
Expand All @@ -31,4 +33,4 @@
"swr-devtools": "^0.2.2",
"swr-devtools-panel": "^0.2.2"
}
}
}
5 changes: 2 additions & 3 deletions packages/swr-devtools-extensions/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import ReactDOM from "react-dom";
import { SWRDevToolPanel } from "swr-devtools-panel";
import { runtime } from "webextension-polyfill";

import type { ContentMessage } from "./content";

const cache = new Map();
const rootEl = document.getElementById("app");

// @ts-ignore
const port = chrome.runtime.connect({
const port = runtime.connect({
name: "panel",
});
port.onDisconnect.addListener(() => {
Expand All @@ -17,7 +17,6 @@ port.onDisconnect.addListener(() => {
});

let mounted = false;
// @ts-ignore
port.onMessage.addListener((message: ContentMessage) => {
switch (message.type) {
// loaded a new page
Expand Down
7 changes: 4 additions & 3 deletions packages/swr-devtools-extensions/src/background.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { runtime, Runtime } from "webextension-polyfill";
import type { ContentMessage } from "./content";
// background.js
let panelPort: chrome.runtime.Port | null = null;
let contentPort: chrome.runtime.Port | null = null;
let panelPort: Runtime.Port | null = null;
let contentPort: Runtime.Port | null = null;

// queued messages until a panel is connected
const queuedContentMessages: any[] = [];

chrome.runtime.onConnect.addListener((port) => {
runtime.onConnect.addListener((port) => {
console.log("on connect", port.name);
// A port between a content page
if (port.name === "content") {
Expand Down
3 changes: 2 additions & 1 deletion packages/swr-devtools-extensions/src/content.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DevToolsMessage } from "swr-devtools";
import { runtime } from "webextension-polyfill";

export type ContentMessage =
| {
Expand All @@ -24,7 +25,7 @@ const enqueueMessage = (message: any) => {
let isDisplayedPanel = false;

// proxy messages from applications to a background script
const port = chrome.runtime.connect({ name: "content" });
const port = runtime.connect({ name: "content" });
port.onMessage.addListener((message: any) => {
console.log("received from background -> content", message);
// a panel has been displayed, so we sent queued messages
Expand Down
9 changes: 8 additions & 1 deletion packages/swr-devtools-extensions/src/devtools.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
<meta content="utf-8" http-equiv="encoding" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>SWR devtools</title>
<script src="devtools.js"></script>
</head>
<body></body>
</html>
4 changes: 3 additions & 1 deletion packages/swr-devtools-extensions/src/devtools.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
chrome.devtools.panels.create("SWR", "", "panel.html", () => {
import { devtools } from "webextension-polyfill";

devtools.panels.create("SWR", "", "panel.html").then(() => {
console.log("The DevTools panel has been created");
});
5 changes: 3 additions & 2 deletions packages/swr-devtools-extensions/src/panel.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<style>
html {
Expand All @@ -9,7 +9,8 @@
background-color: rgb(39, 40, 34);
}
}
body, div#app {
body,
div#app {
height: 100%;
margin: 0;
}
Expand Down
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1438,6 +1438,11 @@
"@types/react" "*"
csstype "^3.0.2"

"@types/webextension-polyfill@^0.8.0":
version "0.8.0"
resolved "https://registry.yarnpkg.com/@types/webextension-polyfill/-/webextension-polyfill-0.8.0.tgz#6c40740eec531de412f6ceba27bb2cad4a24907c"
integrity sha512-usmQx2snpNkVl2VoOGZCdrPnfHL+CjuSFy84ZdTwQ2b2cvyygF/zGW5YI6Zywk+bfq9zmYpORO9lmdN7DknpRw==

"@typescript-eslint/eslint-plugin@^4.15.0":
version "4.15.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.15.0.tgz#13a5a07cf30d0d5781e43480aa2a8d38d308b084"
Expand Down Expand Up @@ -7878,6 +7883,11 @@ wcwidth@^1.0.0:
dependencies:
defaults "^1.0.3"

webextension-polyfill@^0.8.0:
version "0.8.0"
resolved "https://registry.yarnpkg.com/webextension-polyfill/-/webextension-polyfill-0.8.0.tgz#f80e9f4b7f81820c420abd6ffbebfa838c60e041"
integrity sha512-a19+DzlT6Kp9/UI+mF9XQopeZ+n2ussjhxHJ4/pmIGge9ijCDz7Gn93mNnjpZAk95T4Tae8iHZ6sSf869txqiQ==

webidl-conversions@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad"
Expand Down