Skip to content

Commit a2b6792

Browse files
committed
v0.1.0 Manifest v3 (Chrome-only)
1 parent dbf016c commit a2b6792

Some content is hidden

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

58 files changed

+4682
-3388
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ coverage
1414
/packages/*/bundle/manifest.json
1515
/packages/*/bundle/popup.html
1616
/packages/*/bundle/options.html
17+
/packages/*/bundle/offscreen.html
1718
/packages/*/bundle/*.js
1819
/packages/*/bundle/*.css
1920
/packages/*/bundle/*.svg

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Then, run the watch mode:
9292
yarn start
9393
```
9494

95-
<small>While it's building you may want to check out [how to load an unpacked extension](https://developer.chrome.com/extensions/faq#faq-dev-01) in Google Chrome.</small>
95+
<small>While it's building you may want to check out [how to load an unpacked extension](https://developer.chrome.com/docs/extensions/get-started/tutorial/hello-world#load-unpacked) in Google Chrome.</small>
9696

9797
Once it's built you will be able to load the extension from a `./bundle` directory in the appropriate package.
9898

package.json

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "ctf",
4-
"version": "0.0.16",
4+
"version": "0.1.0",
55
"scripts": {
66
"test": "jest --watch",
77
"start": "npm-run-all --print-label --parallel firefox chromium",
@@ -17,10 +17,10 @@
1717
"@hot-loader/react-dom": "^17.0.2",
1818
"buffer": "^6.0.3",
1919
"country-flag-emoji-json": "^2.0.0",
20-
"maxmind": "^4.3.6",
20+
"maxmind": "^4.3.20",
2121
"node-libs-browser": "^2.2.1",
2222
"react": "^18.1.0",
23-
"webextension-polyfill": "^0.9.0"
23+
"webextension-polyfill": "^0.12.0"
2424
},
2525
"devDependencies": {
2626
"@babel/core": "^7.17.9",
@@ -32,15 +32,17 @@
3232
"@types/node-fetch": "^2",
3333
"@types/react": "^17.0.43",
3434
"@types/react-dom": "^18.0.2",
35+
"@types/webextension-polyfill": "^0.10.7",
3536
"@types/webpack-env": "^1.16.4",
36-
"@typescript-eslint/eslint-plugin": "^5.27.1",
37-
"@typescript-eslint/parser": "^5.27.1",
37+
"@typescript-eslint/eslint-plugin": "^7.11.0",
38+
"@typescript-eslint/parser": "^7.11.0",
3839
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.7",
3940
"babel-jest": "^27.5.1",
4041
"babel-loader": "^8.2.5",
4142
"babel-plugin-rewire-exports": "^2.3.0",
4243
"babel-preset-react-app": "^10.0.0",
4344
"bundlewatch": "^0.3.3",
45+
"chrome-types": "^0.1.286",
4446
"css-loader": "^6.7.1",
4547
"css-minimizer-webpack-plugin": "^4.0.0",
4648
"enzyme": "^3.11.0",
@@ -67,13 +69,12 @@
6769
"react-dom": "^18.1.0",
6870
"react-hot-loader": "^4.13.0",
6971
"style-loader": "^3.3.1",
70-
"typescript": "^4.6.4",
71-
"webextension-polyfill-ts": "^0.26.0",
72-
"webpack": "^5.73.0",
73-
"webpack-cli": "^4.9.2",
74-
"webpack-dev-server": "^4.9.2",
72+
"typescript": "^5.4.5",
73+
"webpack": "^5.91.0",
74+
"webpack-cli": "^5.1.4",
75+
"webpack-dev-server": "^5.0.4",
7576
"webpack-manifest-plugin": "^5.0.0",
76-
"webpack-merge": "^5.8.0"
77+
"webpack-merge": "^5.10.0"
7778
},
7879
"keywords": [],
7980
"author": "Yaroslav Ilin",
@@ -97,8 +98,8 @@
9798
],
9899
"coverageThreshold": {
99100
"global": {
100-
"lines": 90,
101-
"statements": 90
101+
"lines": 84,
102+
"statements": 83
102103
}
103104
},
104105
"setupFiles": [

packages/bundler/bundle.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ class Bundle {
2424
return { basename: 'options', title: 'Options', filepath: 'options.html' };
2525
}
2626

27+
get offscreen() {
28+
const basename = 'offscreen';
29+
return { basename, title: 'Offscreen', filepath: `${basename}.html` };
30+
}
31+
2732
get isDevelopment() {
2833
return this.env.WEBPACK_SERVE;
2934
}

packages/bundler/entrypoints/_basic.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ class BasicEntrypoint {
2626
hotUpdateChunkFilename: 'hot/chunk~[id]~[fullhash].js',
2727
hotUpdateMainFilename: 'hot/main_[runtime]_[fullhash].json',
2828
},
29-
optimization: {
30-
runtimeChunk: {
31-
name: (entrypoint) => `${entrypoint.name}.runtime`,
32-
},
33-
},
3429
},
3530
this.configuration,
3631
this.bundle.extra

packages/bundler/entrypoints/background.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ const { BasicEntrypoint } = require('./_basic');
99
class BackgroundEntrypoint extends BasicEntrypoint {
1010
get configuration() {
1111
return merge(this._maxmindMocks, this._devServer, {
12+
target: 'webworker',
13+
1214
entry: {
13-
background: `${this.bundle.runtimePath}/entrypoints/background`,
15+
service_worker: `${this.bundle.runtimePath}/entrypoints/service_worker`,
1416
},
1517

1618
module: {

packages/bundler/entrypoints/ui.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class UIEntrypoint extends ReactEntrypoint {
88
constructor(bundle) {
99
super(bundle);
1010

11-
this.html = [bundle.popup, bundle.options];
11+
this.html = [bundle.popup, bundle.options, bundle.offscreen];
1212
this._createEntry = this._createEntry.bind(this);
1313
this._createHtml = this._createHtml.bind(this);
1414
}

packages/bundler/manifest.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ManifestFactory {
1313
const { author, version } = bundle.pkg;
1414

1515
return {
16-
manifest_version: 2,
16+
manifest_version: 3,
1717

1818
name: '__MSG_ext_name__',
1919
version,
@@ -22,7 +22,7 @@ class ManifestFactory {
2222
description: '__MSG_ext_description__',
2323
icons: this.icons,
2424

25-
page_action: {
25+
action: {
2626
default_icon: this.icons,
2727
default_popup: bundle.popup.filepath,
2828
show_matches: ['<all_urls>'],
@@ -34,12 +34,11 @@ class ManifestFactory {
3434

3535
author,
3636
background: {
37-
scripts: entrypoints.background,
37+
service_worker: entrypoints.service_worker[0],
3838
},
3939

40-
minimum_chrome_version: '36',
41-
42-
permissions: ['webRequest', '<all_urls>', 'storage'],
40+
permissions: ['webRequest', 'storage', 'offscreen'],
41+
host_permissions: ['*://*/*'],
4342

4443
short_name: '__MSG_ext_short_name__',
4544
version_name: this._getVersionTag(bundle.pkg),
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* @license React
3+
* react.production.min.js
4+
*
5+
* Copyright (c) Facebook, Inc. and its affiliates.
6+
*
7+
* This source code is licensed under the MIT license found in the
8+
* LICENSE file in the root directory of this source tree.
9+
*/

packages/chromium/bundle/background.js.LICENSE.txt renamed to packages/chromium/bundle/service_worker.js.LICENSE.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
/*
2-
object-assign
3-
(c) Sindre Sorhus
4-
@license MIT
5-
*/
6-
71
/*!
82
* The buffer module from node.js, for the browser.
93
*
@@ -19,3 +13,11 @@ object-assign
1913
*/
2014

2115
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
16+
17+
/**
18+
* tiny-lru
19+
*
20+
* @copyright 2024 Jason Mulligan <jason.mulligan@avoidwork.com>
21+
* @license BSD-3-Clause
22+
* @version 11.2.6
23+
*/

0 commit comments

Comments
 (0)