Skip to content

Commit 19a3b3b

Browse files
v3.0.5 (#22)
- Firefox support - Move search invocation into panel page - Toolbar UI changes --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent 94cc2a3 commit 19a3b3b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1807
-1078
lines changed

.gitignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ node_modules/
88
# os
99
.DS_Store
1010

11-
# typescript output
12-
.ts-built
13-
14-
# application files not for git
11+
# application autogenerated files not for git
1512
*.js.map
1613
*.zip
14+
*.crx
15+
manifest.json
16+
bundle/js

.prettierignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
/bundle/js
2-
.ts-built
32
*.min.js
43
pnpm-lock.yaml

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
"fileMatch": ["manifest.json"],
77
"url": "https://json.schemastore.org/chrome-manifest.json"
88
}
9-
]
9+
],
10+
"typescript.tsdk": "node_modules/typescript/lib"
1011
}

Makefile

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
1-
ZIP_FILE="extension.zip"
1+
ZIP_CHROME_FILE="extension.chrome.zip"
2+
ZIP_FIREFOX_FILE="extension.firefox.zip"
23
HASH_ALG="sha384"
34

45
.PHONY:
5-
install clean all lint dev prod zip
6+
install clean all lint dev prod zip_chrome zip_firefox
7+
tune2chrome tune2firefox
68

79
install:
810
npm i -g pnpm
911
pnpm i
1012

1113
clean:
1214
rm -rf ./node_modules
13-
rm -rf $(ZIP_FILE)
15+
rm -rf $(ZIP_CHROME_FILE) $(ZIP_FIREFOX_FILE)
1416
rm -rf ./bundle/js/
1517

1618
all:
1719
make lint
1820
make prod
19-
make zip
21+
make zip_chrome
22+
make zip_firefox
2023

2124
lint:
2225
npx prettier . --write
@@ -27,12 +30,28 @@ dev:
2730
npx webpack --progress --watch --mode=development
2831

2932
prod:
33+
rm -rf ./bundle/js/
3034
NODE_OPTIONS="--loader=ts-node/esm --no-warnings=ExperimentalWarning" \
3135
NODE_ENV="production" \
3236
npx webpack --mode=production
3337

34-
zip:
35-
rm -rf $(ZIP_FILE)
36-
zip -r $(ZIP_FILE) ./bundle ./manifest.json > /dev/null
37-
FILE_HASH=$$(openssl dgst -$(HASH_ALG) -binary $(ZIP_FILE) | openssl base64 -A); \
38-
echo "$(ZIP_FILE) $(HASH_ALG):$$FILE_HASH"
38+
zip_chrome:
39+
make tune2chrome
40+
rm -rf $(ZIP_CHROME_FILE)
41+
zip -r $(ZIP_CHROME_FILE) ./bundle ./manifest.json > /dev/null
42+
zip --delete $(ZIP_CHROME_FILE) "bundle/js/firefox/*"
43+
FILE_HASH=$$(openssl dgst -$(HASH_ALG) -binary $(ZIP_CHROME_FILE) | openssl base64 -A); \
44+
echo "$(ZIP_CHROME_FILE) $(HASH_ALG):$$FILE_HASH"
45+
46+
zip_firefox:
47+
make tune2firefox
48+
rm -rf $(ZIP_FIREFOX_FILE)
49+
zip -r $(ZIP_FIREFOX_FILE) ./bundle ./manifest.json > /dev/null
50+
FILE_HASH=$$(openssl dgst -$(HASH_ALG) -binary $(ZIP_FIREFOX_FILE) | openssl base64 -A); \
51+
echo "$(ZIP_FIREFOX_FILE) $(HASH_ALG):$$FILE_HASH"
52+
53+
tune2chrome:
54+
cp manifest.chrome.json manifest.json
55+
56+
tune2firefox:
57+
cp manifest.firefox.json manifest.json

README.md

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
1-
### ![](./src/img/panel-icon28.png) console.diff()
1+
### ![](./bundle/img/panel-icon28.png) console.diff()
22

33
[![console.diff()](https://storage.googleapis.com/web-dev-uploads/image/WlD8wC6g8khYWPJUsQceQkhXSlv1/tbyBjqi7Zu733AAKA5n4.png)](https://chrome.google.com/webstore/detail/jsdiff-devtool/iefeamoljhdcpigpnpggeiiabpnpgonb)
44

55
Chrome extension to compare objects in memory with console.diff(old, new) devtools function.
66

77
<details>
8-
<summary> <strong>Screenshots</strong> </summary>
8+
<summary> <strong>Examples</strong> </summary>
99

1010
- Comparing two objects
1111
![screenshot](./doc/screenshot-01.png)
1212

1313
- Tracking changes in localStorage (unchanged are hidden)
1414
![screenshot](./doc/screenshot-02.png)
1515

16+
</details>
17+
<details>
18+
<summary> <strong>How it works</strong> </summary>
19+
20+
- Chrome mv3
21+
![screenshot](./doc/design.chrome.png)
22+
- Firefox
23+
![screenshot](./doc/design.firefox.png)
24+
1625
</details>
1726

1827
### Based on
@@ -35,7 +44,7 @@ Chrome extension to compare objects in memory with console.diff(old, new) devtoo
3544

3645
- JSDiff devtools panel reflects current state of comparison, regardless the tab[s] it was opened from.
3746

38-
- Basic integration with search functionality within devtools:
47+
- Internal search inside comparison results
3948

4049
- If search query contains at least one upper-case letter - the search will be case-sensitive.
4150

@@ -69,6 +78,8 @@ Chrome extension to compare objects in memory with console.diff(old, new) devtoo
6978

7079
- Compared objects, after being serialized, stored in `chrome.storage.local` wich has 10MB limit (before chrome v114 was 5MB).
7180

81+
- In Firefox the API is under `jsdiff` object for now, cause extension API's not fully compatible.
82+
7283
### API
7384

7485
- **console.diff(left, right)** - compare left and right arguments
@@ -113,24 +124,24 @@ Historically, left side represents the old state and right side the new state.
113124

114125
- To track changes of the same variable in timed manner you can push it with `diffPush` or `diff` with a single argument, - that will shift objects from right to left, showing differences with previous push state.
115126

116-
### How it works
117-
118-
![screenshot](./doc/design.png)
119-
120127
### How to build
121128

122-
- requires npm/nodejs
129+
Requires
130+
131+
- Linux
132+
- node 20.10 (LTS)
123133

124134
```sh
125135
make install # to install dependencies
126-
make all # build for prod and make extension.zip
136+
make all # build for prod and make extension.${browser}.zip
137+
make tune2chrome # or tune2firefox for relevant manifest.json file
127138
make dev # local development
128139
```
129140

130141
### Protection
131142

132143
- How to protect your site from this extension:
133-
- Well, tests show that even `Content-Security-Policy: default-src 'none';` header won't prevent injection of extension content-scripts...
144+
- Well, tests on chrome show that even `Content-Security-Policy: default-src 'none';` header won't prevent injection of extension content-scripts...
134145
- Avoid assigning to `window` or `globalThis` any application object.
135146
See also [accidental global variables and memory leaks](https://www.tutorialspoint.com/explain-in-detail-about-memory-leaks-in-javascript).
136147
- In general, you can incapacitate console functions:

bundle/js/jsdiff-console.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

bundle/js/jsdiff-devtools.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

bundle/js/jsdiff-panel.js

Lines changed: 0 additions & 29 deletions
This file was deleted.

bundle/js/jsdiff-proxy.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

doc/design.plantuml renamed to doc/design.chrome.plantuml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ end box
3131
User -> Console: console.diff(...)
3232

3333
activate Console
34-
Console -> Proxy: jsdiff-console-to-proxy-inprogress
34+
Console -> Proxy: jsdiff-console-\nto-proxy-inprogress
3535
activate Proxy
3636
Proxy -> Panel: jsdiff-proxy-to-panel-inprogress
3737
deactivate Proxy
3838
Console o->o Console: clone arguments
39-
Console -> Proxy: jsdiff-console-to-proxy-compare
39+
Console -> Proxy: jsdiff-console-\nto-proxy-compare
4040
deactivate Console
4141

4242
activate Proxy
@@ -53,8 +53,8 @@ Panel ->o]: Display result
5353
deactivate Panel
5454

5555
=== Search in DevTools Panel ==
56-
[-> User: ctrl+F\ncmd+F
57-
User -> Panel: jsdiff-devtools-to-panel-search
56+
User -> Panel: ^+F\n⌘+F
57+
5858
activate Panel
5959
Panel -> Panel: search in DOM
6060
Panel ->o]: Display result

doc/design.chrome.png

66.7 KB
Loading

doc/design.firefox.plantuml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
@startuml Design
2+
skinparam style strictuml
3+
4+
box "Devtools"
5+
actor "User" as User
6+
end box
7+
8+
box "Firefox Runtime Context"
9+
participant Console [
10+
=Console
11+
----
12+
content script
13+
]
14+
participant Proxy [
15+
=Proxy
16+
----
17+
content script
18+
]
19+
participant Background [
20+
=Background
21+
]
22+
database Storage
23+
participant Panel [
24+
=Panel
25+
----
26+
DevTools View
27+
]
28+
end box
29+
30+
[-> User: Open Devtools
31+
32+
Background <- Panel: jsdiff-devtools-page-connect
33+
activate Background
34+
Background <-- Panel: keep alive
35+
36+
=== Invoke API ==
37+
User -> Console: jsdiff.diff(...)
38+
activate Console
39+
Console -> Proxy: jsdiff-console-\nto-proxy-inprogress
40+
activate Proxy
41+
Proxy -> Background: jsdiff-proxy-to-panel-inprogress
42+
deactivate Proxy
43+
Console o->o Console: clone arguments
44+
Console -> Proxy: jsdiff-console-\nto-proxy-compare
45+
deactivate Console
46+
47+
activate Proxy
48+
Proxy o<->o Proxy: arrange payload
49+
Proxy -> Storage: write payload
50+
Proxy --> Background: jsdiff-proxy-to-panel-error
51+
Proxy -> Background: jsdiff-proxy-to-panel-compare
52+
deactivate Proxy
53+
Background -> Panel: relay all messages
54+
55+
deactivate Background
56+
57+
activate Panel
58+
Storage -> Panel: read payload
59+
Panel -> Panel: Compare objects
60+
Panel ->o]: Display result
61+
deactivate Panel
62+
63+
=== Search in DevTools Panel ==
64+
User -> Panel: ^+F\n⌘+F
65+
66+
activate Panel
67+
Panel -> Panel: search in DOM
68+
Panel ->o]: Display result
69+
deactivate Panel
70+
71+
@enduml

doc/design.firefox.png

105 KB
Loading

doc/design.png

-71.9 KB
Binary file not shown.

doc/screenshot-00.png

76 KB
Loading

doc/screenshot-01.png

77.3 KB
Loading

doc/screenshot-02.png

81.2 KB
Loading

manifest.json renamed to manifest.chrome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifest_version": 3,
33
"name": "console.diff(...)",
4-
"version": "3.0.4",
4+
"version": "3.0.5",
55
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlCx2Bl0li+3idvfrH9cQL/MzphafGFqMUA2P+0vbyhwxsxWl0llOaGQbkirX5qCoAVHoUCPqu3hCjpVCv35igPbfqDs5bdLZZmXt2F0HjEQnWI/eZKd9IKcKYMplEeL2BodmpU02VrP1UnUzQHZeeMWk9ybgWOqCimkwliILVubRj5dxNB9AidLwO4Z5iGq/OvW9AJMYdxKxrLP2lF6/GGNcCBg+iCJZwlQOhFB9LbUjytT4ws3bIEX4b5zmWLqGKR1NiZfGug2eCWXt9oEKg2WkbXmBBzFKqxnM/bBUrVR29N9qNgx0f42qnyhsW3Bo4kPzE3d0asXCV5nofLTLEwIDAQAB",
66
"description": "Compare objects in memory with console.diff(old, new) devtools function",
77
"minimum_chrome_version": "100.0",

manifest.firefox.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"manifest_version": 3,
3+
"name": "jsdiff.diff(...)",
4+
"version": "3.0.5",
5+
"description": "Compare objects in memory with jsdiff.diff(old, new) devtools function",
6+
"minimum_chrome_version": "100.0",
7+
"browser_specific_settings": {
8+
"gecko": {
9+
"id": "calexblock@gmail.com",
10+
"strict_min_version": "120.0"
11+
}
12+
},
13+
"homepage_url": "https://github.com/zendive/jsdiff",
14+
"author": "calexblock@gmail.com",
15+
"permissions": ["storage", "devtools", "activeTab"],
16+
"host_permissions": ["<all_urls>"],
17+
"background": {
18+
"scripts": ["bundle/js/firefox/jsdiff-background.js"]
19+
},
20+
"devtools_page": "bundle/jsdiff-devtools.html",
21+
"icons": {
22+
"28": "bundle/img/panel-icon28.png",
23+
"64": "bundle/img/panel-icon64.png",
24+
"128": "bundle/img/panel-icon128.png"
25+
},
26+
"content_scripts": [
27+
{
28+
"js": ["bundle/js/jsdiff-console.js", "bundle/js/jsdiff-proxy.js"],
29+
"matches": ["*://*/*"],
30+
"all_frames": true,
31+
"run_at": "document_start"
32+
}
33+
]
34+
}

package.json

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jsdiff",
3-
"version": "3.0.4",
3+
"version": "3.0.5",
44
"description": "Chrome extension to compare objects in memory with console.diff(old, new) devtools function",
55
"private": true,
66
"scripts": {
@@ -13,41 +13,43 @@
1313
},
1414
"keywords": [
1515
"devtools",
16+
"diff",
1617
"chrome",
1718
"extension"
1819
],
1920
"author": "Block Alexander",
20-
"license": "proprietary",
21+
"license": "MIT",
2122
"bugs": {
2223
"url": "https://github.com/zendive/jsdiff/issues"
2324
},
2425
"homepage": "https://github.com/zendive/jsdiff#readme",
2526
"type": "module",
2627
"devDependencies": {
27-
"@types/chrome": "0.0.251",
28+
"@types/chrome": "0.0.259",
29+
"@types/diff-match-patch": "^1.0.36",
30+
"@types/firefox-webext-browser": "120.0.0",
2831
"@types/webpack-bundle-analyzer": "4.6.3",
29-
"@vue/compiler-sfc": "3.3.8",
32+
"@vue/compiler-sfc": "3.4.15",
3033
"clean-webpack-plugin": "4.0.0",
31-
"css-loader": "6.8.1",
32-
"esbuild": "0.19.5",
33-
"esbuild-loader": "4.0.2",
34-
"jsondiffpatch": "0.5.0",
35-
"prettier": "3.0.3",
36-
"sass": "1.69.5",
37-
"sass-loader": "13.3.2",
38-
"style-loader": "3.3.3",
39-
"ts-node": "10.9.1",
40-
"typescript": "5.2.2",
41-
"vue": "3.3.8",
42-
"vue-loader": "17.3.1",
43-
"webpack": "5.89.0",
44-
"webpack-bundle-analyzer": "4.9.1",
34+
"css-loader": "6.10.0",
35+
"diff-match-patch": "^1.0.5",
36+
"esbuild": "0.20.0",
37+
"esbuild-loader": "4.0.3",
38+
"jsondiffpatch": "^0.6.0",
39+
"pinia": "^2.1.7",
40+
"prettier": "3.2.4",
41+
"sass": "1.70.0",
42+
"sass-loader": "14.1.0",
43+
"style-loader": "3.3.4",
44+
"ts-node": "10.9.2",
45+
"typescript": "5.3.3",
46+
"vue": "3.4.15",
47+
"vue-loader": "17.4.2",
48+
"webpack": "5.90.0",
49+
"webpack-bundle-analyzer": "4.10.1",
4550
"webpack-cli": "5.1.4"
4651
},
4752
"pnpm": {
48-
"overrides": {
49-
"postcss@<8.4.31": ">=8.4.31",
50-
"semver@>=7.0.0 <7.5.2": ">=7.5.2"
51-
}
53+
"overrides": {}
5254
}
5355
}

0 commit comments

Comments
 (0)