extension-develop 2.0.0-rc.24 → 2.0.0-rc.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/add-hmr-accept-code.js +2 -68
- package/dist/depreacated-shadow-root.js +34 -0
- package/dist/deprecated-shadow-root.js +14 -72
- package/dist/ensure-hmr-for-scripts.js +2 -179
- package/dist/inject-chromium-client-loader.js +2 -77
- package/dist/inject-content-css-during-dev.js +10 -0
- package/dist/inject-firefox-client-loader.js +9 -81
- package/dist/minimum-chromium-file.mjs +1 -0
- package/dist/minimum-content-file.mjs +1 -0
- package/dist/minimum-firefox-file.mjs +1 -0
- package/dist/minimum-script-file.mjs +0 -0
- package/dist/module.d.ts +96 -7
- package/dist/module.js +128 -6286
- package/dist/package-lock.json +2542 -0
- package/dist/package.json +10 -0
- package/dist/resolver-loader.js +1 -0
- package/dist/resolver-module.mjs +1 -0
- package/dist/tailwind.config.js +25 -0
- package/package.json +14 -23
|
@@ -1,70 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import * as __WEBPACK_EXTERNAL_MODULE_path__ from "path";
|
|
3
|
-
import * as __WEBPACK_EXTERNAL_MODULE_loader_utils_46078eb4__ from "loader-utils";
|
|
4
|
-
import * as __WEBPACK_EXTERNAL_MODULE_schema_utils_9c4f80ad__ from "schema-utils";
|
|
5
|
-
function isUsingJSFramework(projectPath) {
|
|
6
|
-
const packageJsonPath = __WEBPACK_EXTERNAL_MODULE_path__["default"].join(projectPath, 'package.json');
|
|
7
|
-
if (!__WEBPACK_EXTERNAL_MODULE_fs__["default"].existsSync(packageJsonPath)) return false;
|
|
8
|
-
const packageJson = JSON.parse(__WEBPACK_EXTERNAL_MODULE_fs__["default"].readFileSync(packageJsonPath, 'utf-8'));
|
|
9
|
-
const frameworks = [
|
|
10
|
-
'react',
|
|
11
|
-
'vue',
|
|
12
|
-
'@angular/core',
|
|
13
|
-
'svelte',
|
|
14
|
-
'solid-js',
|
|
15
|
-
'preact'
|
|
16
|
-
];
|
|
17
|
-
const dependencies = packageJson.dependencies || {};
|
|
18
|
-
const devDependencies = packageJson.devDependencies || {};
|
|
19
|
-
for (const framework of frameworks)if (dependencies[framework] || devDependencies[framework]) return true;
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
const schema = {
|
|
23
|
-
type: 'object',
|
|
24
|
-
properties: {
|
|
25
|
-
test: {
|
|
26
|
-
type: 'string'
|
|
27
|
-
},
|
|
28
|
-
manifestPath: {
|
|
29
|
-
type: 'string'
|
|
30
|
-
},
|
|
31
|
-
mode: {
|
|
32
|
-
type: 'string'
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
function add_hmr_accept_code(source) {
|
|
37
|
-
const options = this.getOptions();
|
|
38
|
-
const manifestPath = options.manifestPath;
|
|
39
|
-
const projectPath = __WEBPACK_EXTERNAL_MODULE_path__["default"].dirname(manifestPath);
|
|
40
|
-
const manifest = JSON.parse(__WEBPACK_EXTERNAL_MODULE_fs__["default"].readFileSync(manifestPath, 'utf-8'));
|
|
41
|
-
(0, __WEBPACK_EXTERNAL_MODULE_schema_utils_9c4f80ad__.validate)(schema, options, {
|
|
42
|
-
name: "scripts:add-hmr-accept-code",
|
|
43
|
-
baseDataPath: 'options'
|
|
44
|
-
});
|
|
45
|
-
const url = (0, __WEBPACK_EXTERNAL_MODULE_loader_utils_46078eb4__.urlToRequest)(this.resourcePath);
|
|
46
|
-
const reloadCode = `
|
|
1
|
+
"use strict";var b=Object.create;var f=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var y=(t,e)=>{for(var r in e)f(t,r,{get:e[r],enumerable:!0})},m=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of v(e))!j.call(t,s)&&s!==r&&f(t,s,{get:()=>e[s],enumerable:!(o=k(e,s))||o.enumerable});return t};var d=(t,e,r)=>(r=t!=null?b(S(t)):{},m(e||!t||!t.__esModule?f(r,"default",{value:t,enumerable:!0}):r,t)),P=t=>m(f({},"__esModule",{value:!0}),t);var D={};y(D,{default:()=>x});module.exports=P(D);var u=d(require("fs")),c=d(require("path")),l=require("loader-utils"),g=require("schema-utils");function $(t){let e=c.default.join(t,"package.json");if(!u.default.existsSync(e))return!1;let r=JSON.parse(u.default.readFileSync(e,"utf-8")),o=["react","vue","@angular/core","svelte","solid-js","preact"],s=r.dependencies||{},a=r.devDependencies||{};for(let n of o)if(s[n]||a[n])return!0;return!1}var w={type:"object",properties:{test:{type:"string"},manifestPath:{type:"string"},mode:{type:"string"}}};function x(t){let e=this.getOptions(),r=e.manifestPath,o=c.default.dirname(r),s=require(r);(0,g.validate)(w,e,{name:"scripts:add-hmr-accept-code",baseDataPath:"options"});let a=(0,l.urlToRequest)(this.resourcePath),n=`
|
|
47
2
|
// TODO: cezaraugusto re-visit this
|
|
48
3
|
// if (import.meta.webpackHot) { import.meta.webpackHot.accept() };
|
|
49
|
-
`;
|
|
50
|
-
if (manifest.background) {
|
|
51
|
-
if (manifest.background.scripts) for (const bgScript of manifest.background.scripts){
|
|
52
|
-
const absoluteUrl = __WEBPACK_EXTERNAL_MODULE_path__["default"].resolve(projectPath, bgScript);
|
|
53
|
-
if (url.includes(absoluteUrl)) return `${reloadCode}${source}`;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
if (manifest.content_scripts) {
|
|
57
|
-
if (!isUsingJSFramework(projectPath)) {
|
|
58
|
-
for (const contentScript of manifest.content_scripts)if (contentScript.js) for (const js of contentScript.js){
|
|
59
|
-
const absoluteUrl = __WEBPACK_EXTERNAL_MODULE_path__["default"].resolve(projectPath, js);
|
|
60
|
-
if (url.includes(absoluteUrl)) return `${reloadCode}${source}`;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
if (manifest.user_scripts) for (const userScript of manifest.user_scripts){
|
|
65
|
-
const absoluteUrl = __WEBPACK_EXTERNAL_MODULE_path__["default"].resolve(projectPath, userScript);
|
|
66
|
-
if (url.includes(absoluteUrl)) return `${reloadCode}${source}`;
|
|
67
|
-
}
|
|
68
|
-
return source;
|
|
69
|
-
}
|
|
70
|
-
export { add_hmr_accept_code as default };
|
|
4
|
+
`;if(s.background&&s.background.scripts)for(let i of s.background.scripts){let p=c.default.resolve(o,i);if(a.includes(p))return`${n}${t}`}if(s.content_scripts&&!$(o)){for(let i of s.content_scripts)if(i.js)for(let p of i.js){let h=c.default.resolve(o,p);if(a.includes(h))return`${n}${t}`}}if(s.user_scripts)for(let i of s.user_scripts){let p=c.default.resolve(o,i);if(a.includes(p))return`${n}${t}`}return t}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";var y=Object.create;var i=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var T=(e,n)=>{for(var r in n)i(e,r,{get:n[r],enumerable:!0})},l=(e,n,r,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of b(n))!v.call(e,o)&&o!==r&&i(e,o,{get:()=>n[o],enumerable:!(s=E(n,o))||s.enumerable});return e};var a=(e,n,r)=>(r=e!=null?y(w(e)):{},l(n||!e||!e.__esModule?i(r,"default",{value:e,enumerable:!0}):r,e)),S=e=>l(i({},"__esModule",{value:!0}),e);var k={};T(k,{default:()=>I});module.exports=S(k);var c=a(require("path")),f=require("loader-utils"),m=require("schema-utils");var F=a(require("path")),t=require("@colors/colors/safe");var d=a(require("path")),O=d.default.join(process.cwd(),"node_modules/extension-develop/dist/certs"),N=["chrome","edge"],R=["firefox"],U=[...N,...R];var M=require("console");function j(e,n){return n==="error"?`${(0,t.bold)((0,t.red)("ERROR"))} in ${e} ${(0,t.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")}`:n==="warn"?`${e} ${(0,t.brightYellow)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")}`:`${n==="info"?(0,t.cyan)("\u25BA\u25BA\u25BA"):(0,t.brightGreen)("\u25BA\u25BA\u25BA")} ${(0,t.cyan)(e)}`}function p(){return`${j("DEPRECATION","warn")} Using ${(0,t.brightYellow)("window.__EXTENSION_SHADOW_ROOT__")} in content_scripts is deprecated
|
|
2
|
+
and will be removed in a future version of Extension.js. To use content_scripts with
|
|
3
|
+
the shadow DOM, see one of the many examples at:
|
|
4
|
+
https://github.com/extension-js/extension.js/tree/main/examples
|
|
5
|
+
|
|
6
|
+
If you really need to use the shadow DOM as-is, the latest version of Extension.js
|
|
7
|
+
to support it is extension@2.0.0-beta.9.
|
|
8
|
+
`}var D={type:"object",properties:{test:{type:"string"},manifestPath:{type:"string"}}};function I(e){let n=this.getOptions(),r=n.manifestPath,s=c.default.dirname(r),o=require(r);(0,m.validate)(D,n,{name:"scripts:deprecated-shadow-root",baseDataPath:"options"});let $=(0,f.urlToRequest)(this.resourcePath),h=`
|
|
9
|
+
;const appendStyleElementForLegacyShadowRoot = (legacyShadowRoot, stylesheets) => {
|
|
10
|
+
const styleElement = document.createElement('link')
|
|
11
|
+
styleElement.rel = 'stylesheet'
|
|
12
|
+
styleElement.href = (typeof chrome !== 'undefined' ? chrome : browser).runtime.getURL('content_scripts/content-0.css')
|
|
13
|
+
legacyShadowRoot.appendChild(styleElement)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function injectStyles() {
|
|
17
|
+
const legacyShadowRoot = window.__EXTENSION_SHADOW_ROOT__
|
|
18
|
+
|
|
19
|
+
if (legacyShadowRoot) {
|
|
20
|
+
appendStyleElementForLegacyShadowRoot(legacyShadowRoot)
|
|
21
|
+
} else {
|
|
22
|
+
// Use MutationObserver to wait for shadow root to be available
|
|
23
|
+
const observer = new MutationObserver(() => {
|
|
24
|
+
const shadowRoot = window.__EXTENSION_SHADOW_ROOT__
|
|
25
|
+
|
|
26
|
+
if (shadowRoot) {
|
|
27
|
+
appendStyleElementForLegacyShadowRoot(shadowRoot)
|
|
28
|
+
observer.disconnect()
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
observer.observe(document.body, { childList: true, subtree: true })
|
|
33
|
+
}
|
|
34
|
+
};injectStyles();`;if(o.content_scripts){for(let u of o.content_scripts)if(u.js)for(let g of u.js){let x=c.default.resolve(s,g);if($.includes(x))return e.includes("__EXTENSION_SHADOW_ROOT__")?(console.warn(p()),`${h}${e}`):`${e}`}}return e}
|
|
@@ -1,59 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
];
|
|
15
|
-
[
|
|
16
|
-
...CHROMIUM_BASED_BROWSERS,
|
|
17
|
-
...GECKO_BASED_BROWSERS
|
|
18
|
-
];
|
|
19
|
-
function getLoggingPrefix(feature, type) {
|
|
20
|
-
if ('error' === type) return `${__WEBPACK_EXTERNAL_MODULE_chalk__["default"].bold(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].red('ERROR'))} in ${feature} ${__WEBPACK_EXTERNAL_MODULE_chalk__["default"].red("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")}`;
|
|
21
|
-
if ('warn' === type) return `${feature} ${__WEBPACK_EXTERNAL_MODULE_chalk__["default"].yellow("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")}`;
|
|
22
|
-
const arrow = 'info' === type ? __WEBPACK_EXTERNAL_MODULE_chalk__["default"].cyan("\u25BA\u25BA\u25BA") : __WEBPACK_EXTERNAL_MODULE_chalk__["default"].green("\u25BA\u25BA\u25BA");
|
|
23
|
-
return `${arrow} ${__WEBPACK_EXTERNAL_MODULE_chalk__["default"].cyan(feature)}`;
|
|
24
|
-
}
|
|
25
|
-
function deprecatedShadowRoot() {
|
|
26
|
-
return `${getLoggingPrefix('DEPRECATION', 'warn')} Using ${__WEBPACK_EXTERNAL_MODULE_chalk__["default"].yellow('window.__EXTENSION_SHADOW_ROOT__')} in content_scripts is deprecated\nand will be removed in a future version of Extension.js. To use content_scripts with\nthe shadow DOM, see one of the many examples at:\nhttps://github.com/extension-js/extension.js/tree/main/examples\n\nIf you really need to use the shadow DOM as-is, the latest version of Extension.js\nto support it is extension@2.0.0-beta.9.\n`;
|
|
27
|
-
}
|
|
28
|
-
const schema = {
|
|
29
|
-
type: 'object',
|
|
30
|
-
properties: {
|
|
31
|
-
test: {
|
|
32
|
-
type: 'string'
|
|
33
|
-
},
|
|
34
|
-
manifestPath: {
|
|
35
|
-
type: 'string'
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
function deprecated_shadow_root(source) {
|
|
40
|
-
const options = this.getOptions();
|
|
41
|
-
const manifestPath = options.manifestPath;
|
|
42
|
-
const projectPath = __WEBPACK_EXTERNAL_MODULE_path__.dirname(manifestPath);
|
|
43
|
-
const manifest = JSON.parse(__WEBPACK_EXTERNAL_MODULE_fs__.readFileSync(manifestPath, 'utf8'));
|
|
44
|
-
(0, __WEBPACK_EXTERNAL_MODULE_schema_utils_9c4f80ad__.validate)(schema, options, {
|
|
45
|
-
name: "scripts:deprecated-shadow-root",
|
|
46
|
-
baseDataPath: 'options'
|
|
47
|
-
});
|
|
48
|
-
const url = (0, __WEBPACK_EXTERNAL_MODULE_loader_utils_46078eb4__.urlToRequest)(this.resourcePath);
|
|
49
|
-
const patchCssTag = `
|
|
50
|
-
;const appendStyleElementForLegacyShadowRoot = (legacyShadowRoot, stylesheets) => {
|
|
51
|
-
if (typeof chrome !== 'undefined' || typeof browser !== 'undefined') {
|
|
52
|
-
const styleElement = document.createElement('link')
|
|
53
|
-
styleElement.rel = 'stylesheet'
|
|
54
|
-
styleElement.href = (typeof chrome !== 'undefined' ? chrome : browser).runtime.getURL('content_scripts/content-0.css')
|
|
55
|
-
legacyShadowRoot.appendChild(styleElement)
|
|
56
|
-
}
|
|
1
|
+
"use strict";var y=Object.create;var i=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var T=(e,n)=>{for(var r in n)i(e,r,{get:n[r],enumerable:!0})},l=(e,n,r,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of E(n))!v.call(e,o)&&o!==r&&i(e,o,{get:()=>n[o],enumerable:!(s=b(n,o))||s.enumerable});return e};var a=(e,n,r)=>(r=e!=null?y(w(e)):{},l(n||!e||!e.__esModule?i(r,"default",{value:e,enumerable:!0}):r,e)),S=e=>l(i({},"__esModule",{value:!0}),e);var k={};T(k,{default:()=>I});module.exports=S(k);var c=a(require("path")),f=require("loader-utils"),m=require("schema-utils");var F=a(require("path")),t=require("@colors/colors/safe");var p=a(require("path")),N=p.default.join(process.cwd(),"node_modules/extension-develop/dist/certs"),O=["chrome","edge"],R=["firefox"],U=[...O,...R];var M=require("console");function j(e,n){return n==="error"?`${(0,t.bold)((0,t.red)("ERROR"))} in ${e} ${(0,t.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")}`:n==="warn"?`${e} ${(0,t.brightYellow)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")}`:`${n==="info"?(0,t.cyan)("\u25BA\u25BA\u25BA"):(0,t.brightGreen)("\u25BA\u25BA\u25BA")} ${(0,t.cyan)(e)}`}function d(){return`${j("DEPRECATION","warn")} Using ${(0,t.brightYellow)("window.__EXTENSION_SHADOW_ROOT__")} in content_scripts is deprecated
|
|
2
|
+
and will be removed in a future version of Extension.js. To use content_scripts with
|
|
3
|
+
the shadow DOM, see one of the many examples at:
|
|
4
|
+
https://github.com/extension-js/extension.js/tree/main/examples
|
|
5
|
+
|
|
6
|
+
If you really need to use the shadow DOM as-is, the latest version of Extension.js
|
|
7
|
+
to support it is extension@2.0.0-beta.9.
|
|
8
|
+
`}var D={type:"object",properties:{test:{type:"string"},manifestPath:{type:"string"}}};function I(e){let n=this.getOptions(),r=n.manifestPath,s=c.default.dirname(r),o=require(r);(0,m.validate)(D,n,{name:"scripts:deprecated-shadow-root",baseDataPath:"options"});let $=(0,f.urlToRequest)(this.resourcePath),h=`
|
|
9
|
+
;const appendStyleElementForLegacyShadowRoot = (legacyShadowRoot, stylesheets) => {
|
|
10
|
+
const styleElement = document.createElement('link')
|
|
11
|
+
styleElement.rel = 'stylesheet'
|
|
12
|
+
styleElement.href = (typeof chrome !== 'undefined' ? chrome : browser).runtime.getURL('content_scripts/content-0.css')
|
|
13
|
+
legacyShadowRoot.appendChild(styleElement)
|
|
57
14
|
}
|
|
58
15
|
|
|
59
16
|
function injectStyles() {
|
|
@@ -74,19 +31,4 @@ function injectStyles() {
|
|
|
74
31
|
|
|
75
32
|
observer.observe(document.body, { childList: true, subtree: true })
|
|
76
33
|
}
|
|
77
|
-
};injectStyles();`;
|
|
78
|
-
if (manifest.content_scripts) {
|
|
79
|
-
for (const contentScript of manifest.content_scripts)if (contentScript.js) for (const js of contentScript.js){
|
|
80
|
-
const absoluteUrl = __WEBPACK_EXTERNAL_MODULE_path__.resolve(projectPath, js);
|
|
81
|
-
if (url.includes(absoluteUrl)) {
|
|
82
|
-
if (source.includes('__EXTENSION_SHADOW_ROOT__')) {
|
|
83
|
-
console.warn(deprecatedShadowRoot());
|
|
84
|
-
return `${patchCssTag}${source}`;
|
|
85
|
-
}
|
|
86
|
-
return `${source}`;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return source;
|
|
91
|
-
}
|
|
92
|
-
export { deprecated_shadow_root as default };
|
|
34
|
+
};injectStyles();`;if(o.content_scripts){for(let u of o.content_scripts)if(u.js)for(let g of u.js){let x=c.default.resolve(s,g);if($.includes(x))return e.includes("__EXTENSION_SHADOW_ROOT__")?(console.warn(d()),`${h}${e}`):`${e}`}}return e}
|
|
@@ -1,180 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import * as __WEBPACK_EXTERNAL_MODULE_fs__ from "fs";
|
|
3
|
-
import * as __WEBPACK_EXTERNAL_MODULE_loader_utils_46078eb4__ from "loader-utils";
|
|
4
|
-
import * as __WEBPACK_EXTERNAL_MODULE_schema_utils_9c4f80ad__ from "schema-utils";
|
|
5
|
-
import * as __WEBPACK_EXTERNAL_MODULE_parse5_utils_87ce236c__ from "parse5-utils";
|
|
6
|
-
import "child_process";
|
|
7
|
-
import "package-manager-detector";
|
|
8
|
-
import "chalk";
|
|
9
|
-
import "console";
|
|
10
|
-
import "url";
|
|
11
|
-
function isUrl(src) {
|
|
12
|
-
try {
|
|
13
|
-
new URL(src);
|
|
14
|
-
return true;
|
|
15
|
-
} catch (err) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
function parseHtml(node, onResourceFound) {
|
|
20
|
-
const { childNodes = [] } = node;
|
|
21
|
-
for (const childNode of childNodes)if ("script" === childNode.nodeName) {
|
|
22
|
-
const src = __WEBPACK_EXTERNAL_MODULE_parse5_utils_87ce236c__["default"].getAttribute(childNode, 'src');
|
|
23
|
-
if (!src) continue;
|
|
24
|
-
if (isUrl(src)) continue;
|
|
25
|
-
onResourceFound({
|
|
26
|
-
filePath: src,
|
|
27
|
-
childNode,
|
|
28
|
-
assetType: "script"
|
|
29
|
-
});
|
|
30
|
-
} else if ('link' === childNode.nodeName) {
|
|
31
|
-
const href = __WEBPACK_EXTERNAL_MODULE_parse5_utils_87ce236c__["default"].getAttribute(childNode, 'href');
|
|
32
|
-
const rel = __WEBPACK_EXTERNAL_MODULE_parse5_utils_87ce236c__["default"].getAttribute(childNode, 'rel');
|
|
33
|
-
if (!href) continue;
|
|
34
|
-
if (isUrl(href)) continue;
|
|
35
|
-
onResourceFound('dns-prefetch' === rel || 'icon' === rel || 'manifest' === rel || 'modulepreload' === rel || 'preconnect' === rel || 'prefetch' === rel || 'preload' === rel || 'prerender' === rel ? {
|
|
36
|
-
filePath: href,
|
|
37
|
-
childNode,
|
|
38
|
-
assetType: 'staticHref'
|
|
39
|
-
} : {
|
|
40
|
-
filePath: href,
|
|
41
|
-
childNode,
|
|
42
|
-
assetType: 'css'
|
|
43
|
-
});
|
|
44
|
-
} else if ('a' === childNode.nodeName || 'area' === childNode.nodeName) {
|
|
45
|
-
const href = __WEBPACK_EXTERNAL_MODULE_parse5_utils_87ce236c__["default"].getAttribute(childNode, 'href');
|
|
46
|
-
if (!href) continue;
|
|
47
|
-
if (isUrl(href)) continue;
|
|
48
|
-
onResourceFound({
|
|
49
|
-
filePath: href,
|
|
50
|
-
childNode,
|
|
51
|
-
assetType: 'staticHref'
|
|
52
|
-
});
|
|
53
|
-
} else if ('audio' === childNode.nodeName || 'embed' === childNode.nodeName || 'iframe' === childNode.nodeName || 'img' === childNode.nodeName || 'input' === childNode.nodeName || 'source' === childNode.nodeName || 'track' === childNode.nodeName || 'video' === childNode.nodeName) {
|
|
54
|
-
const src = __WEBPACK_EXTERNAL_MODULE_parse5_utils_87ce236c__["default"].getAttribute(childNode, 'src');
|
|
55
|
-
if (!src) continue;
|
|
56
|
-
if (isUrl(src)) continue;
|
|
57
|
-
onResourceFound({
|
|
58
|
-
filePath: src,
|
|
59
|
-
childNode,
|
|
60
|
-
assetType: 'staticSrc'
|
|
61
|
-
});
|
|
62
|
-
} else parseHtml(childNode, onResourceFound);
|
|
63
|
-
}
|
|
64
|
-
function getAssetsFromHtml(htmlFilePath, htmlContent) {
|
|
65
|
-
const assets = {
|
|
66
|
-
css: [],
|
|
67
|
-
js: [],
|
|
68
|
-
static: []
|
|
69
|
-
};
|
|
70
|
-
if (!htmlFilePath) return assets;
|
|
71
|
-
const htmlString = htmlContent || __WEBPACK_EXTERNAL_MODULE_fs__.readFileSync(htmlFilePath, {
|
|
72
|
-
encoding: 'utf8'
|
|
73
|
-
});
|
|
74
|
-
const htmlDocument = __WEBPACK_EXTERNAL_MODULE_parse5_utils_87ce236c__["default"].parse(htmlString);
|
|
75
|
-
const getAbsolutePath = (htmlFilePath, filePath)=>__WEBPACK_EXTERNAL_MODULE_path__.join(__WEBPACK_EXTERNAL_MODULE_path__.dirname(htmlFilePath), filePath.startsWith('/') ? __WEBPACK_EXTERNAL_MODULE_path__.relative(__WEBPACK_EXTERNAL_MODULE_path__.dirname(htmlFilePath), filePath) : filePath);
|
|
76
|
-
for (const node of htmlDocument.childNodes)if ('html' === node.nodeName) {
|
|
77
|
-
for (const childNode of node.childNodes)if ('head' === childNode.nodeName || 'body' === childNode.nodeName) parseHtml(childNode, ({ filePath, assetType })=>{
|
|
78
|
-
const fileAbsolutePath = getAbsolutePath(htmlFilePath, filePath);
|
|
79
|
-
switch(assetType){
|
|
80
|
-
case "script":
|
|
81
|
-
var _assets_js;
|
|
82
|
-
null == (_assets_js = assets.js) || _assets_js.push(fileAbsolutePath);
|
|
83
|
-
break;
|
|
84
|
-
case 'css':
|
|
85
|
-
var _assets_css;
|
|
86
|
-
null == (_assets_css = assets.css) || _assets_css.push(fileAbsolutePath);
|
|
87
|
-
break;
|
|
88
|
-
case 'staticSrc':
|
|
89
|
-
case 'staticHref':
|
|
90
|
-
var _assets_static;
|
|
91
|
-
if (filePath.startsWith('#')) break;
|
|
92
|
-
null == (_assets_static = assets.static) || _assets_static.push(fileAbsolutePath);
|
|
93
|
-
break;
|
|
94
|
-
default:
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
return {
|
|
99
|
-
css: assets.css,
|
|
100
|
-
js: assets.js,
|
|
101
|
-
static: assets.static
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
__WEBPACK_EXTERNAL_MODULE_path__.join(process.cwd(), 'node_modules/extension-develop/dist/certs');
|
|
106
|
-
const constants_CHROMIUM_BASED_BROWSERS = [
|
|
107
|
-
'chrome',
|
|
108
|
-
'edge'
|
|
109
|
-
];
|
|
110
|
-
const GECKO_BASED_BROWSERS = [
|
|
111
|
-
'firefox'
|
|
112
|
-
];
|
|
113
|
-
[
|
|
114
|
-
...constants_CHROMIUM_BASED_BROWSERS,
|
|
115
|
-
...GECKO_BASED_BROWSERS
|
|
116
|
-
];
|
|
117
|
-
function isUsingJSFramework(projectPath) {
|
|
118
|
-
const packageJsonPath = __WEBPACK_EXTERNAL_MODULE_path__.join(projectPath, 'package.json');
|
|
119
|
-
if (!__WEBPACK_EXTERNAL_MODULE_fs__.existsSync(packageJsonPath)) return false;
|
|
120
|
-
const packageJson = JSON.parse(__WEBPACK_EXTERNAL_MODULE_fs__.readFileSync(packageJsonPath, 'utf-8'));
|
|
121
|
-
const frameworks = [
|
|
122
|
-
'react',
|
|
123
|
-
'vue',
|
|
124
|
-
'@angular/core',
|
|
125
|
-
'svelte',
|
|
126
|
-
'solid-js',
|
|
127
|
-
'preact'
|
|
128
|
-
];
|
|
129
|
-
const dependencies = packageJson.dependencies || {};
|
|
130
|
-
const devDependencies = packageJson.devDependencies || {};
|
|
131
|
-
for (const framework of frameworks)if (dependencies[framework] || devDependencies[framework]) return true;
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
|
-
const schema = {
|
|
135
|
-
type: 'object',
|
|
136
|
-
properties: {
|
|
137
|
-
test: {
|
|
138
|
-
type: 'string'
|
|
139
|
-
},
|
|
140
|
-
manifestPath: {
|
|
141
|
-
type: 'string'
|
|
142
|
-
},
|
|
143
|
-
includeList: {
|
|
144
|
-
type: 'object'
|
|
145
|
-
},
|
|
146
|
-
excludeList: {
|
|
147
|
-
type: 'object'
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
function ensureHMRForScripts(source) {
|
|
152
|
-
const options = this.getOptions();
|
|
153
|
-
const manifestPath = options.manifestPath;
|
|
154
|
-
const projectPath = __WEBPACK_EXTERNAL_MODULE_path__.dirname(manifestPath);
|
|
155
|
-
(0, __WEBPACK_EXTERNAL_MODULE_schema_utils_9c4f80ad__.validate)(schema, options, {
|
|
156
|
-
name: "html:ensure-hmr-for-scripts",
|
|
157
|
-
baseDataPath: 'options'
|
|
158
|
-
});
|
|
159
|
-
const url = (0, __WEBPACK_EXTERNAL_MODULE_loader_utils_46078eb4__.urlToRequest)(this.resourcePath);
|
|
160
|
-
const reloadCode = `
|
|
161
|
-
// TODO: cezaraugusto re-visit this
|
|
1
|
+
"use strict";var I=Object.create;var m=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var P=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty;var U=(t,n)=>{for(var s in n)m(t,s,{get:n[s],enumerable:!0})},b=(t,n,s,e)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of A(n))!C.call(t,r)&&r!==s&&m(t,r,{get:()=>n[r],enumerable:!(e=R(n,r))||e.enumerable});return t};var a=(t,n,s)=>(s=t!=null?I(P(t)):{},b(n||!t||!t.__esModule?m(s,"default",{value:t,enumerable:!0}):s,t)),L=t=>b(m({},"__esModule",{value:!0}),t);var X={};U(X,{default:()=>k});module.exports=L(X);var x=a(require("path")),O=a(require("fs")),S=require("loader-utils"),M=require("schema-utils");var v=a(require("fs")),d=a(require("path")),N=a(require("parse5-utils"));var p=a(require("parse5-utils"));function g(t){try{return new URL(t),!0}catch{return!1}}function h(t,n){let{childNodes:s=[]}=t;for(let e of s)if(e.nodeName==="script"){let r=p.default.getAttribute(e,"src");if(!r||g(r))continue;n({filePath:r,childNode:e,assetType:"script"})}else if(e.nodeName==="link"){let r=p.default.getAttribute(e,"href"),o=p.default.getAttribute(e,"rel");if(!r||g(r))continue;n(o==="dns-prefetch"||o==="icon"||o==="manifest"||o==="modulepreload"||o==="preconnect"||o==="prefetch"||o==="preload"||o==="prerender"?{filePath:r,childNode:e,assetType:"staticHref"}:{filePath:r,childNode:e,assetType:"css"})}else if(e.nodeName==="a"||e.nodeName==="area"){let r=p.default.getAttribute(e,"href");if(!r||g(r))continue;n({filePath:r,childNode:e,assetType:"staticHref"})}else if(e.nodeName==="audio"||e.nodeName==="embed"||e.nodeName==="iframe"||e.nodeName==="img"||e.nodeName==="input"||e.nodeName==="source"||e.nodeName==="track"||e.nodeName==="video"){let r=p.default.getAttribute(e,"src");if(!r||g(r))continue;n({filePath:r,childNode:e,assetType:"staticSrc"})}else h(e,n)}function j(t,n){let s={css:[],js:[],static:[]};if(!t)return s;let e=n||v.default.readFileSync(t,{encoding:"utf8"}),r=N.default.parse(e),o=(i,c)=>d.default.join(d.default.dirname(i),c.startsWith("/")?d.default.relative(d.default.dirname(i),c):c);for(let i of r.childNodes)if(i.nodeName==="html"){for(let c of i.childNodes)(c.nodeName==="head"||c.nodeName==="body")&&h(c,({filePath:u,assetType:y})=>{let f=o(t,u);switch(y){case"script":s.js?.push(f);break;case"css":s.css?.push(f);break;case"staticSrc":case"staticHref":if(u.startsWith("#"))break;s.static?.push(f);break;default:break}});return{css:s.css,js:s.js,static:s.static}}}var w=a(require("path")),$=a(require("fs")),J=require("child_process"),V=require("package-manager-detector");var q=a(require("path")),l=require("@colors/colors/safe");var E=a(require("path")),H=E.default.join(process.cwd(),"node_modules/extension-develop/dist/certs"),F=["chrome","edge"],W=["firefox"],ee=[...F,...W];var B=require("console");function T(t){let n=w.default.join(t,"package.json");if(!$.default.existsSync(n))return!1;let s=JSON.parse($.default.readFileSync(n,"utf-8")),e=["react","vue","@angular/core","svelte","solid-js","preact"],r=s.dependencies||{},o=s.devDependencies||{};for(let i of e)if(r[i]||o[i])return!0;return!1}var G={type:"object",properties:{test:{type:"string"},manifestPath:{type:"string"},includeList:{type:"object"},excludeList:{type:"object"}}};function k(t){let n=this.getOptions(),s=n.manifestPath,e=x.default.dirname(s);(0,M.validate)(G,n,{name:"html:ensure-hmr-for-scripts",baseDataPath:"options"});let r=(0,S.urlToRequest)(this.resourcePath),o=`
|
|
162
2
|
if (import.meta.webpackHot) { import.meta.webpackHot.accept() };
|
|
163
|
-
`;
|
|
164
|
-
if (isUsingJSFramework(projectPath)) return source;
|
|
165
|
-
const allEntries = options.includeList || {};
|
|
166
|
-
for (const field of Object.entries(allEntries)){
|
|
167
|
-
const [, resource] = field;
|
|
168
|
-
if (resource) {
|
|
169
|
-
if (!__WEBPACK_EXTERNAL_MODULE_fs__.existsSync(resource)) return;
|
|
170
|
-
const htmlAssets = getAssetsFromHtml(resource);
|
|
171
|
-
const fileAssets = (null == htmlAssets ? void 0 : htmlAssets.js) || [];
|
|
172
|
-
for (const asset of fileAssets){
|
|
173
|
-
const absoluteUrl = __WEBPACK_EXTERNAL_MODULE_path__.resolve(projectPath, asset);
|
|
174
|
-
if (url.includes(absoluteUrl)) return `${reloadCode}${source}`;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
return source;
|
|
179
|
-
}
|
|
180
|
-
export { ensureHMRForScripts as default };
|
|
3
|
+
`;if(T(e))return t;let i=n.includeList||{};for(let c of Object.entries(i)){let[,u]=c;if(u){if(!O.default.existsSync(u))return;let f=j(u)?.js||[];for(let D of f){let _=x.default.resolve(e,D);if(r.includes(_))return`${o}${t}`}}}return t}
|
|
@@ -1,57 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import * as __WEBPACK_EXTERNAL_MODULE_fs__ from "fs";
|
|
3
|
-
import * as __WEBPACK_EXTERNAL_MODULE_loader_utils_46078eb4__ from "loader-utils";
|
|
4
|
-
import * as __WEBPACK_EXTERNAL_MODULE_schema_utils_9c4f80ad__ from "schema-utils";
|
|
5
|
-
import "child_process";
|
|
6
|
-
import "package-manager-detector";
|
|
7
|
-
import "chalk";
|
|
8
|
-
import "console";
|
|
9
|
-
import "url";
|
|
10
|
-
__WEBPACK_EXTERNAL_MODULE_path__.join(process.cwd(), 'node_modules/extension-develop/dist/certs');
|
|
11
|
-
const CHROMIUM_BASED_BROWSERS = [
|
|
12
|
-
'chrome',
|
|
13
|
-
'edge'
|
|
14
|
-
];
|
|
15
|
-
const GECKO_BASED_BROWSERS = [
|
|
16
|
-
'firefox'
|
|
17
|
-
];
|
|
18
|
-
[
|
|
19
|
-
...CHROMIUM_BASED_BROWSERS,
|
|
20
|
-
...GECKO_BASED_BROWSERS
|
|
21
|
-
];
|
|
22
|
-
function filterKeysForThisBrowser(manifest, browser) {
|
|
23
|
-
const patchedManifest = JSON.parse(JSON.stringify(manifest), function(key, value) {
|
|
24
|
-
const indexOfColon = key.indexOf(':');
|
|
25
|
-
if (-1 === indexOfColon) return value;
|
|
26
|
-
const prefix = key.substring(0, indexOfColon);
|
|
27
|
-
if (prefix === browser || 'chromium' === prefix && CHROMIUM_BASED_BROWSERS.includes(browser) || 'chromium' === prefix && browser.includes('chromium') || 'gecko' === prefix && browser.includes('gecko')) this[key.substring(indexOfColon + 1)] = value;
|
|
28
|
-
});
|
|
29
|
-
return patchedManifest;
|
|
30
|
-
}
|
|
31
|
-
const schema = {
|
|
32
|
-
type: 'object',
|
|
33
|
-
properties: {
|
|
34
|
-
test: {
|
|
35
|
-
type: 'string'
|
|
36
|
-
},
|
|
37
|
-
manifestPath: {
|
|
38
|
-
type: 'string'
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
function inject_chromium_client_loader(source) {
|
|
43
|
-
const options = this.getOptions();
|
|
44
|
-
const manifestPath = options.manifestPath;
|
|
45
|
-
const browser = options.browser;
|
|
46
|
-
const projectPath = __WEBPACK_EXTERNAL_MODULE_path__.dirname(manifestPath);
|
|
47
|
-
const manifest = JSON.parse(__WEBPACK_EXTERNAL_MODULE_fs__.readFileSync(manifestPath, 'utf-8'));
|
|
48
|
-
const patchedManifest = filterKeysForThisBrowser(manifest, browser);
|
|
49
|
-
(0, __WEBPACK_EXTERNAL_MODULE_schema_utils_9c4f80ad__.validate)(schema, options, {
|
|
50
|
-
name: 'reload:inject-background-client',
|
|
51
|
-
baseDataPath: 'options'
|
|
52
|
-
});
|
|
53
|
-
const url = (0, __WEBPACK_EXTERNAL_MODULE_loader_utils_46078eb4__.urlToRequest)(this.resourcePath);
|
|
54
|
-
const generalReloadCode = `
|
|
1
|
+
"use strict";var F=Object.create;var u=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var N=Object.getPrototypeOf,T=Object.prototype.hasOwnProperty;var O=(e,n)=>{for(var t in n)u(e,t,{get:n[t],enumerable:!0})},x=(e,n,t,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of M(n))!T.call(e,r)&&r!==t&&u(e,r,{get:()=>n[r],enumerable:!(a=j(n,r))||a.enumerable});return e};var c=(e,n,t)=>(t=e!=null?F(N(e)):{},x(n||!e||!e.__esModule?u(t,"default",{value:e,enumerable:!0}):t,e)),S=e=>x(u({},"__esModule",{value:!0}),e);var H={};O(H,{default:()=>W});module.exports=S(H);var p=c(require("path")),b=require("loader-utils"),w=require("schema-utils");var C=c(require("path")),P=c(require("fs")),U=require("child_process"),A=require("package-manager-detector");var R=c(require("path")),s=require("@colors/colors/safe");var y=c(require("path")),_=y.default.join(process.cwd(),"node_modules/extension-develop/dist/certs"),m=["chrome","edge"],k=["firefox"],z=[...m,...k];var D=require("console");function v(e,n){return JSON.parse(JSON.stringify(e),function(r,l){let o=r.indexOf(":");if(o===-1)return l;let i=r.substring(0,o);(i===n||i==="chromium"&&m.includes(n)||i==="chromium"&&n.includes("chromium")||i==="gecko"&&n.includes("gecko"))&&(this[r.substring(o+1)]=l)})}var q={type:"object",properties:{test:{type:"string"},manifestPath:{type:"string"}}};function W(e){let n=this.getOptions(),t=n.manifestPath,a=n.browser,r=p.default.dirname(t),l=require(t),o=v(l,a);(0,w.validate)(q,n,{name:"reload:inject-background-client",baseDataPath:"options"});let i=(0,b.urlToRequest)(this.resourcePath),g=`
|
|
55
2
|
;chrome.runtime.onMessageExternal.addListener(
|
|
56
3
|
async (request, _sender, sendResponse) => {
|
|
57
4
|
const managementInfo = await new Promise((resolve) => {
|
|
@@ -86,26 +33,4 @@ function inject_chromium_client_loader(source) {
|
|
|
86
33
|
return true
|
|
87
34
|
}
|
|
88
35
|
);
|
|
89
|
-
|
|
90
|
-
let manifestBg = patchedManifest.background;
|
|
91
|
-
if (manifestBg) {
|
|
92
|
-
const backgroundScripts = null == manifestBg ? void 0 : manifestBg.scripts;
|
|
93
|
-
if (backgroundScripts) {
|
|
94
|
-
if (2 === patchedManifest.manifest_version) for (const bgScript of [
|
|
95
|
-
backgroundScripts[0]
|
|
96
|
-
]){
|
|
97
|
-
const absoluteUrl = __WEBPACK_EXTERNAL_MODULE_path__.resolve(projectPath, bgScript);
|
|
98
|
-
if (url.includes(absoluteUrl)) return `${generalReloadCode}${source}`;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
const serviceWorker = null == manifestBg ? void 0 : manifestBg.service_worker;
|
|
102
|
-
if (serviceWorker) {
|
|
103
|
-
if (3 === patchedManifest.manifest_version) {
|
|
104
|
-
const absoluteUrl = __WEBPACK_EXTERNAL_MODULE_path__.resolve(projectPath, serviceWorker);
|
|
105
|
-
if (url.includes(absoluteUrl)) return `${generalReloadCode}${source}`;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return source;
|
|
110
|
-
}
|
|
111
|
-
export { inject_chromium_client_loader as default };
|
|
36
|
+
`,f=o.background;if(f){let h=f?.scripts;if(h&&o.manifest_version===2)for(let d of[h[0]]){let E=p.default.resolve(r,d);if(i.includes(E))return`${g}${e}`}let $=f?.service_worker;if($&&o.manifest_version===3){let d=p.default.resolve(r,$);if(i.includes(d))return`${g}${e}`}}return e}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";var _=Object.create;var m=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty;var L=(e,n)=>{for(var r in n)m(e,r,{get:n[r],enumerable:!0})},y=(e,n,r,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of D(n))!C.call(e,t)&&t!==r&&m(e,t,{get:()=>n[t],enumerable:!(i=I(n,t))||i.enumerable});return e};var a=(e,n,r)=>(r=e!=null?_(R(e)):{},y(n||!e||!e.__esModule?m(r,"default",{value:e,enumerable:!0}):r,e)),A=e=>y(m({},"__esModule",{value:!0}),e);var X={};L(X,{default:()=>T});module.exports=A(X);var x=a(require("path")),S=require("loader-utils"),M=require("schema-utils");var g=a(require("path")),z=a(require("fs")),B=require("child_process"),J=require("package-manager-detector");var W=a(require("path")),o=require("@colors/colors/safe");var v=a(require("path")),U=v.default.join(process.cwd(),"node_modules/extension-develop/dist/certs"),b=["chrome","edge"],P=["firefox"],Z=[...b,...P];var H=require("console");function E(e){return e.replace(/\\/g,"/")}function h(e,n={}){if(!n)return!1;let r=g.default.normalize(E(e));return Object.values(n).some(t=>typeof t!="string"?!1:E(t).includes(r))}function F(e,n){let r=g.default.relative(g.default.dirname(e),n);return!r.startsWith(".")&&!r.startsWith("..")&&(r="./"+r),r}var $=a(require("fs")),j=a(require("path"));function N(e,n){return(Array.isArray(e)?e||[]:e?[e]:[]).filter(t=>{let l=$.default.existsSync(t)&&!h(t,n),s=j.default.extname(t);return l&&(s===".js"||s===".mjs"||s===".jsx"||s===".ts"||s===".tsx")})}function w(e,n){return(Array.isArray(e)?e||[]:e?[e]:[]).filter(t=>$.default.existsSync(t)&&!h(t,n)&&(t.endsWith(".css")||t.endsWith(".scss")||t.endsWith(".sass")||t.endsWith(".less")))}var G={type:"object",properties:{test:{type:"string"},manifestPath:{type:"string"},includeList:{type:"object"},excludeList:{type:"object"}}},K=`/**
|
|
2
|
+
* Welcome to to your content_scripts CSS file during development!
|
|
3
|
+
* To speed up the development process, your styles
|
|
4
|
+
* are being injected directly into the head of the webpage,
|
|
5
|
+
* and will be removed when you build your application, along
|
|
6
|
+
* with this file. If you are seeing this file in a production build,
|
|
7
|
+
* it means that something is wrong with your build configuration.
|
|
8
|
+
*/`;function T(e){let n=this.getOptions();(0,M.validate)(G,n,{name:"scripts:inject-content-css-during-dev",baseDataPath:"options"});let r=n.includeList||{},i=[],t=Object.entries(r).filter(([s,u])=>s.startsWith("content")&&u);if(!t.length)return e;for(let s of t){let[u,d]=s,c=[...N(d,n.excludeList||{})],p=w(d,n.excludeList||{});if(p.length&&!c.length){let f=x.default.resolve(__dirname,"minimum-content-file.mjs");c.push(f)}i.push({feature:u,scriptPath:c[0],cssImports:p.map(f=>F(c[0],f))})}let l=(0,S.urlToRequest)(this.resourcePath);return i.forEach(({feature:s,scriptPath:u,cssImports:d})=>{if(l.includes(u)){let c=d.map(p=>{let[,f]=s.split("/"),O=f.split("-")[1],k=x.default.basename(p);return`import(/* webpackChunkName: "${`web_accessible_resources/resource-${O}/${k.replace(".","_")}`}" */ '${p}').then(css => console.info('content_script.css loaded', css)).catch(err => console.error(err));`}).join(`
|
|
9
|
+
`);this.emitFile(`${s}.css`,K),e=`${c}
|
|
10
|
+
${e}`}}),e}
|
|
@@ -1,66 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import "url";
|
|
10
|
-
__WEBPACK_EXTERNAL_MODULE_path__.join(process.cwd(), 'node_modules/extension-develop/dist/certs');
|
|
11
|
-
const CHROMIUM_BASED_BROWSERS = [
|
|
12
|
-
'chrome',
|
|
13
|
-
'edge'
|
|
14
|
-
];
|
|
15
|
-
const GECKO_BASED_BROWSERS = [
|
|
16
|
-
'firefox'
|
|
17
|
-
];
|
|
18
|
-
[
|
|
19
|
-
...CHROMIUM_BASED_BROWSERS,
|
|
20
|
-
...GECKO_BASED_BROWSERS
|
|
21
|
-
];
|
|
22
|
-
function getLoggingPrefix(feature, type) {
|
|
23
|
-
if ('error' === type) return `${__WEBPACK_EXTERNAL_MODULE_chalk__["default"].bold(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].red('ERROR'))} in ${feature} ${__WEBPACK_EXTERNAL_MODULE_chalk__["default"].red("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")}`;
|
|
24
|
-
if ('warn' === type) return `${feature} ${__WEBPACK_EXTERNAL_MODULE_chalk__["default"].yellow("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")}`;
|
|
25
|
-
const arrow = 'info' === type ? __WEBPACK_EXTERNAL_MODULE_chalk__["default"].cyan("\u25BA\u25BA\u25BA") : __WEBPACK_EXTERNAL_MODULE_chalk__["default"].green("\u25BA\u25BA\u25BA");
|
|
26
|
-
return `${arrow} ${__WEBPACK_EXTERNAL_MODULE_chalk__["default"].cyan(feature)}`;
|
|
27
|
-
}
|
|
28
|
-
function firefoxServiceWorkerError() {
|
|
29
|
-
return `${getLoggingPrefix('Firefox runner', 'error')} No Service Worker Support\n\nFirefox does not support the ${__WEBPACK_EXTERNAL_MODULE_chalk__["default"].yellow('background.service_worker')} field yet.\nUpdate your manifest.json file to use ${__WEBPACK_EXTERNAL_MODULE_chalk__["default"].yellow("background.scripts")} instead.\nIf you really need to keep the ${__WEBPACK_EXTERNAL_MODULE_chalk__["default"].yellow('service_worker')} field, prefix it with\n${__WEBPACK_EXTERNAL_MODULE_chalk__["default"].yellow('chromium:')} so it can target only Chromium-based browsers.\n\nMozilla bug: ${__WEBPACK_EXTERNAL_MODULE_chalk__["default"].underline('https://bugzilla.mozilla.org/show_bug.cgi?id=1573659')}.`;
|
|
30
|
-
}
|
|
31
|
-
function filterKeysForThisBrowser(manifest, browser) {
|
|
32
|
-
const patchedManifest = JSON.parse(JSON.stringify(manifest), function(key, value) {
|
|
33
|
-
const indexOfColon = key.indexOf(':');
|
|
34
|
-
if (-1 === indexOfColon) return value;
|
|
35
|
-
const prefix = key.substring(0, indexOfColon);
|
|
36
|
-
if (prefix === browser || 'chromium' === prefix && CHROMIUM_BASED_BROWSERS.includes(browser) || 'chromium' === prefix && browser.includes('chromium') || 'gecko' === prefix && browser.includes('gecko')) this[key.substring(indexOfColon + 1)] = value;
|
|
37
|
-
});
|
|
38
|
-
return patchedManifest;
|
|
39
|
-
}
|
|
40
|
-
const schema = {
|
|
41
|
-
type: 'object',
|
|
42
|
-
properties: {
|
|
43
|
-
test: {
|
|
44
|
-
type: 'string'
|
|
45
|
-
},
|
|
46
|
-
manifestPath: {
|
|
47
|
-
type: 'string'
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
function inject_firefox_client_loader(source) {
|
|
52
|
-
const options = this.getOptions();
|
|
53
|
-
const manifestPath = options.manifestPath;
|
|
54
|
-
const browser = options.browser;
|
|
55
|
-
const projectPath = __WEBPACK_EXTERNAL_MODULE_path__.dirname(manifestPath);
|
|
56
|
-
const manifest = JSON.parse(__WEBPACK_EXTERNAL_MODULE_fs__.readFileSync(manifestPath, 'utf-8'));
|
|
57
|
-
const patchedManifest = filterKeysForThisBrowser(manifest, browser);
|
|
58
|
-
(0, __WEBPACK_EXTERNAL_MODULE_schema_utils_9c4f80ad__.validate)(schema, options, {
|
|
59
|
-
name: 'reload:inject-background-client',
|
|
60
|
-
baseDataPath: 'options'
|
|
61
|
-
});
|
|
62
|
-
const url = (0, __WEBPACK_EXTERNAL_MODULE_loader_utils_46078eb4__.urlToRequest)(this.resourcePath);
|
|
63
|
-
const generalReloadCode = `
|
|
1
|
+
"use strict";var j=Object.create;var u=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,T=Object.prototype.hasOwnProperty;var O=(e,n)=>{for(var r in n)u(e,r,{get:n[r],enumerable:!0})},g=(e,n,r,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of N(n))!T.call(e,o)&&o!==r&&u(e,o,{get:()=>n[o],enumerable:!(a=M(n,o))||a.enumerable});return e};var c=(e,n,r)=>(r=e!=null?j(S(e)):{},g(n||!e||!e.__esModule?u(r,"default",{value:e,enumerable:!0}):r,e)),k=e=>g(u({},"__esModule",{value:!0}),e);var B={};O(B,{default:()=>H});module.exports=k(B);var f=c(require("path")),v=require("loader-utils"),b=require("schema-utils");var P=c(require("path")),U=c(require("fs")),A=require("child_process"),L=require("package-manager-detector");var R=c(require("path")),t=require("@colors/colors/safe");var h=c(require("path")),_=h.default.join(process.cwd(),"node_modules/extension-develop/dist/certs"),p=["chrome","edge"],D=["firefox"],J=[...p,...D];var I=require("console");function C(e,n){return n==="error"?`${(0,t.bold)((0,t.red)("ERROR"))} in ${e} ${(0,t.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")}`:n==="warn"?`${e} ${(0,t.brightYellow)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")}`:`${n==="info"?(0,t.cyan)("\u25BA\u25BA\u25BA"):(0,t.brightGreen)("\u25BA\u25BA\u25BA")} ${(0,t.cyan)(e)}`}function $(){return`${C("Firefox runner","error")} No Service Worker Support
|
|
2
|
+
|
|
3
|
+
Firefox does not support the ${(0,t.brightYellow)("background.service_worker")} field yet.
|
|
4
|
+
Update your manifest.json file to use ${(0,t.brightYellow)("background.scripts")} instead.
|
|
5
|
+
If you really need to keep the ${(0,t.brightYellow)("service_worker")} field, prefix it with
|
|
6
|
+
${(0,t.brightYellow)("chromium:")} so it can target only Chromium-based browsers.
|
|
7
|
+
|
|
8
|
+
Mozilla bug: ${(0,t.underline)("https://bugzilla.mozilla.org/show_bug.cgi?id=1573659")}.`}function y(e,n){return JSON.parse(JSON.stringify(e),function(o,l){let s=o.indexOf(":");if(s===-1)return l;let i=o.substring(0,s);(i===n||i==="chromium"&&p.includes(n)||i==="chromium"&&n.includes("chromium")||i==="gecko"&&n.includes("gecko"))&&(this[o.substring(s+1)]=l)})}var W={type:"object",properties:{test:{type:"string"},manifestPath:{type:"string"}}};function H(e){let n=this.getOptions(),r=n.manifestPath,a=n.browser,o=f.default.dirname(r),l=require(r),s=y(l,a);(0,b.validate)(W,n,{name:"reload:inject-background-client",baseDataPath:"options"});let i=(0,v.urlToRequest)(this.resourcePath),w=`
|
|
64
9
|
;browser.runtime.onMessageExternal.addListener(async (request, _sender) => {
|
|
65
10
|
const managementInfo = await browser.management.getSelf()
|
|
66
11
|
|
|
@@ -88,21 +33,4 @@ function inject_firefox_client_loader(source) {
|
|
|
88
33
|
}
|
|
89
34
|
|
|
90
35
|
return {reloaded: true}
|
|
91
|
-
})
|
|
92
|
-
const manifestBg = patchedManifest.background;
|
|
93
|
-
if (patchedManifest.service_worker) {
|
|
94
|
-
console.log(firefoxServiceWorkerError());
|
|
95
|
-
return source;
|
|
96
|
-
}
|
|
97
|
-
if (manifestBg) {
|
|
98
|
-
const backgroundScripts = null == manifestBg ? void 0 : manifestBg.scripts;
|
|
99
|
-
if (backgroundScripts) for (const bgScript of [
|
|
100
|
-
backgroundScripts[0]
|
|
101
|
-
]){
|
|
102
|
-
const absoluteUrl = __WEBPACK_EXTERNAL_MODULE_path__.resolve(projectPath, bgScript);
|
|
103
|
-
if (url.includes(absoluteUrl)) return `${generalReloadCode}${source}`;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return source;
|
|
107
|
-
}
|
|
108
|
-
export { inject_firefox_client_loader as default };
|
|
36
|
+
});`,d=s.background;if(s.service_worker)return console.log($()),e;if(d){let m=d?.scripts;if(m)for(let E of[m[0]]){let F=f.default.resolve(o,E);if(i.includes(F))return`${w}${e}`}}return e}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
chrome.runtime.onMessageExternal.addListener(async(e,r,a)=>{let n=await new Promise(i=>{chrome.management.getSelf(i)});return e.initialLoadData?(a({id:chrome.runtime.id,manifest:chrome.runtime.getManifest(),management:n}),!0):((e.changedFile==="declarative_net_request"||e.changedFile==="manifest.json"||e.changedFile==="service_worker"||e.changedFile==="_locales")&&(a({reloaded:!0}),chrome.runtime.reload()),!0)});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import.meta.webpackHot&&import.meta.webpackHot.accept();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
browser.runtime.onMessageExternal.addListener(async(e,a)=>{let n=await browser.management.getSelf();return e.initialLoadData?{id:browser.runtime.id,manifest:browser.runtime.getManifest(),management:n}:((e.changedFile==="declarative_net_request"||e.changedFile==="manifest.json"||e.changedFile==="service_worker"||e.changedFile==="_locales")&&browser.runtime.reload(),{reloaded:!0})});
|
|
File without changes
|