extension-develop 2.0.0-rc.25 → 2.0.0-rc.26
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 +113 -2
- package/dist/deprecated-shadow-root.js +116 -14
- package/dist/ensure-hmr-for-scripts.js +222 -2
- package/dist/inject-chromium-client-loader.js +110 -2
- package/dist/inject-firefox-client-loader.js +124 -9
- package/dist/minimum-chromium-file.js +5 -0
- package/dist/minimum-content-file.js +5 -0
- package/dist/minimum-firefox-file.js +5 -0
- package/dist/minimum-script-file.js +5 -0
- package/dist/module.d.ts +7 -96
- package/dist/module.js +6196 -128
- package/package.json +23 -14
- package/dist/958.js +0 -157742
- package/dist/958.js.LICENSE.txt +0 -14
- package/dist/depreacated-shadow-root.js +0 -34
- package/dist/dirname.d.ts +0 -1
- package/dist/inject-content-css-during-dev.js +0 -10
- package/dist/minimum-chromium-file.mjs +0 -1
- package/dist/minimum-content-file.mjs +0 -1
- package/dist/minimum-firefox-file.mjs +0 -1
- package/dist/minimum-script-file.mjs +0 -0
- package/dist/package-lock.json +0 -2542
- package/dist/package.json +0 -10
- package/dist/resolver-loader.js +0 -1
- package/dist/resolver-module.mjs +0 -1
- package/dist/tailwind.config.js +0 -25
|
@@ -1,4 +1,115 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
25
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
+
value: 'Module'
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __webpack_exports__ = {};
|
|
34
|
+
__webpack_require__.r(__webpack_exports__);
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
default: ()=>add_hmr_accept_code
|
|
37
|
+
});
|
|
38
|
+
const external_fs_namespaceObject = require("fs");
|
|
39
|
+
var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namespaceObject);
|
|
40
|
+
const external_path_namespaceObject = require("path");
|
|
41
|
+
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
42
|
+
const external_loader_utils_namespaceObject = require("loader-utils");
|
|
43
|
+
const external_schema_utils_namespaceObject = require("schema-utils");
|
|
44
|
+
function isUsingJSFramework(projectPath) {
|
|
45
|
+
const packageJsonPath = external_path_default().join(projectPath, 'package.json');
|
|
46
|
+
if (!external_fs_default().existsSync(packageJsonPath)) return false;
|
|
47
|
+
const packageJson = JSON.parse(external_fs_default().readFileSync(packageJsonPath, 'utf-8'));
|
|
48
|
+
const frameworks = [
|
|
49
|
+
'react',
|
|
50
|
+
'vue',
|
|
51
|
+
'@angular/core',
|
|
52
|
+
'svelte',
|
|
53
|
+
'solid-js',
|
|
54
|
+
'preact'
|
|
55
|
+
];
|
|
56
|
+
const dependencies = packageJson.dependencies || {};
|
|
57
|
+
const devDependencies = packageJson.devDependencies || {};
|
|
58
|
+
for (const framework of frameworks)if (dependencies[framework] || devDependencies[framework]) return true;
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
const schema = {
|
|
62
|
+
type: 'object',
|
|
63
|
+
properties: {
|
|
64
|
+
test: {
|
|
65
|
+
type: 'string'
|
|
66
|
+
},
|
|
67
|
+
manifestPath: {
|
|
68
|
+
type: 'string'
|
|
69
|
+
},
|
|
70
|
+
mode: {
|
|
71
|
+
type: 'string'
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
function add_hmr_accept_code(source) {
|
|
76
|
+
const options = this.getOptions();
|
|
77
|
+
const manifestPath = options.manifestPath;
|
|
78
|
+
const projectPath = external_path_default().dirname(manifestPath);
|
|
79
|
+
const manifest = JSON.parse(external_fs_default().readFileSync(manifestPath, 'utf-8'));
|
|
80
|
+
(0, external_schema_utils_namespaceObject.validate)(schema, options, {
|
|
81
|
+
name: "scripts:add-hmr-accept-code",
|
|
82
|
+
baseDataPath: 'options'
|
|
83
|
+
});
|
|
84
|
+
const url = (0, external_loader_utils_namespaceObject.urlToRequest)(this.resourcePath);
|
|
85
|
+
const reloadCode = `
|
|
2
86
|
// TODO: cezaraugusto re-visit this
|
|
3
87
|
// if (import.meta.webpackHot) { import.meta.webpackHot.accept() };
|
|
4
|
-
`;
|
|
88
|
+
`;
|
|
89
|
+
if (manifest.background) {
|
|
90
|
+
if (manifest.background.scripts) for (const bgScript of manifest.background.scripts){
|
|
91
|
+
const absoluteUrl = external_path_default().resolve(projectPath, bgScript);
|
|
92
|
+
if (url.includes(absoluteUrl)) return `${reloadCode}${source}`;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (manifest.content_scripts) {
|
|
96
|
+
if (!isUsingJSFramework(projectPath)) {
|
|
97
|
+
for (const contentScript of manifest.content_scripts)if (contentScript.js) for (const js of contentScript.js){
|
|
98
|
+
const absoluteUrl = external_path_default().resolve(projectPath, js);
|
|
99
|
+
if (url.includes(absoluteUrl)) return `${reloadCode}${source}`;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (manifest.user_scripts) for (const userScript of manifest.user_scripts){
|
|
104
|
+
const absoluteUrl = external_path_default().resolve(projectPath, userScript);
|
|
105
|
+
if (url.includes(absoluteUrl)) return `${reloadCode}${source}`;
|
|
106
|
+
}
|
|
107
|
+
return source;
|
|
108
|
+
}
|
|
109
|
+
exports["default"] = __webpack_exports__["default"];
|
|
110
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
111
|
+
"default"
|
|
112
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
113
|
+
Object.defineProperty(exports, '__esModule', {
|
|
114
|
+
value: true
|
|
115
|
+
});
|
|
@@ -1,16 +1,97 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
25
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
+
value: 'Module'
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __webpack_exports__ = {};
|
|
34
|
+
__webpack_require__.r(__webpack_exports__);
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
default: ()=>deprecated_shadow_root
|
|
37
|
+
});
|
|
38
|
+
const external_path_namespaceObject = require("path");
|
|
39
|
+
const external_fs_namespaceObject = require("fs");
|
|
40
|
+
const external_loader_utils_namespaceObject = require("loader-utils");
|
|
41
|
+
const external_schema_utils_namespaceObject = require("schema-utils");
|
|
42
|
+
const external_chalk_namespaceObject = require("chalk");
|
|
43
|
+
var external_chalk_default = /*#__PURE__*/ __webpack_require__.n(external_chalk_namespaceObject);
|
|
44
|
+
external_path_namespaceObject.join(process.cwd(), 'node_modules/extension-develop/dist/certs');
|
|
45
|
+
const CHROMIUM_BASED_BROWSERS = [
|
|
46
|
+
'chrome',
|
|
47
|
+
'edge'
|
|
48
|
+
];
|
|
49
|
+
const GECKO_BASED_BROWSERS = [
|
|
50
|
+
'firefox'
|
|
51
|
+
];
|
|
52
|
+
[
|
|
53
|
+
...CHROMIUM_BASED_BROWSERS,
|
|
54
|
+
...GECKO_BASED_BROWSERS
|
|
55
|
+
];
|
|
56
|
+
require("console");
|
|
57
|
+
function getLoggingPrefix(feature, type) {
|
|
58
|
+
if ('error' === type) return `${external_chalk_default().bold(external_chalk_default().red('ERROR'))} in ${feature} ${external_chalk_default().red("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")}`;
|
|
59
|
+
if ('warn' === type) return `${feature} ${external_chalk_default().yellow("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")}`;
|
|
60
|
+
const arrow = 'info' === type ? external_chalk_default().cyan("\u25BA\u25BA\u25BA") : external_chalk_default().green("\u25BA\u25BA\u25BA");
|
|
61
|
+
return `${arrow} ${external_chalk_default().cyan(feature)}`;
|
|
62
|
+
}
|
|
63
|
+
function deprecatedShadowRoot() {
|
|
64
|
+
return `${getLoggingPrefix('DEPRECATION', 'warn')} Using ${external_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`;
|
|
65
|
+
}
|
|
66
|
+
const schema = {
|
|
67
|
+
type: 'object',
|
|
68
|
+
properties: {
|
|
69
|
+
test: {
|
|
70
|
+
type: 'string'
|
|
71
|
+
},
|
|
72
|
+
manifestPath: {
|
|
73
|
+
type: 'string'
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
function deprecated_shadow_root(source) {
|
|
78
|
+
const options = this.getOptions();
|
|
79
|
+
const manifestPath = options.manifestPath;
|
|
80
|
+
const projectPath = external_path_namespaceObject.dirname(manifestPath);
|
|
81
|
+
const manifest = JSON.parse(external_fs_namespaceObject.readFileSync(manifestPath, 'utf8'));
|
|
82
|
+
(0, external_schema_utils_namespaceObject.validate)(schema, options, {
|
|
83
|
+
name: "scripts:deprecated-shadow-root",
|
|
84
|
+
baseDataPath: 'options'
|
|
85
|
+
});
|
|
86
|
+
const url = (0, external_loader_utils_namespaceObject.urlToRequest)(this.resourcePath);
|
|
87
|
+
const patchCssTag = `
|
|
88
|
+
;const appendStyleElementForLegacyShadowRoot = (legacyShadowRoot, stylesheets) => {
|
|
89
|
+
if (typeof chrome !== 'undefined' || typeof browser !== 'undefined') {
|
|
90
|
+
const styleElement = document.createElement('link')
|
|
91
|
+
styleElement.rel = 'stylesheet'
|
|
92
|
+
styleElement.href = (typeof chrome !== 'undefined' ? chrome : browser).runtime.getURL('content_scripts/content-0.css')
|
|
93
|
+
legacyShadowRoot.appendChild(styleElement)
|
|
94
|
+
}
|
|
14
95
|
}
|
|
15
96
|
|
|
16
97
|
function injectStyles() {
|
|
@@ -31,4 +112,25 @@ function injectStyles() {
|
|
|
31
112
|
|
|
32
113
|
observer.observe(document.body, { childList: true, subtree: true })
|
|
33
114
|
}
|
|
34
|
-
};injectStyles();`;
|
|
115
|
+
};injectStyles();`;
|
|
116
|
+
if (manifest.content_scripts) {
|
|
117
|
+
for (const contentScript of manifest.content_scripts)if (contentScript.js) for (const js of contentScript.js){
|
|
118
|
+
const absoluteUrl = external_path_namespaceObject.resolve(projectPath, js);
|
|
119
|
+
if (url.includes(absoluteUrl)) {
|
|
120
|
+
if (source.includes('__EXTENSION_SHADOW_ROOT__')) {
|
|
121
|
+
console.warn(deprecatedShadowRoot());
|
|
122
|
+
return `${patchCssTag}${source}`;
|
|
123
|
+
}
|
|
124
|
+
return `${source}`;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return source;
|
|
129
|
+
}
|
|
130
|
+
exports["default"] = __webpack_exports__["default"];
|
|
131
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
132
|
+
"default"
|
|
133
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
134
|
+
Object.defineProperty(exports, '__esModule', {
|
|
135
|
+
value: true
|
|
136
|
+
});
|
|
@@ -1,3 +1,223 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
25
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
+
value: 'Module'
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __webpack_exports__ = {};
|
|
34
|
+
__webpack_require__.r(__webpack_exports__);
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
default: ()=>ensureHMRForScripts
|
|
37
|
+
});
|
|
38
|
+
const external_path_namespaceObject = require("path");
|
|
39
|
+
const external_fs_namespaceObject = require("fs");
|
|
40
|
+
const external_loader_utils_namespaceObject = require("loader-utils");
|
|
41
|
+
const external_schema_utils_namespaceObject = require("schema-utils");
|
|
42
|
+
const external_parse5_utils_namespaceObject = require("parse5-utils");
|
|
43
|
+
var external_parse5_utils_default = /*#__PURE__*/ __webpack_require__.n(external_parse5_utils_namespaceObject);
|
|
44
|
+
function isUrl(src) {
|
|
45
|
+
try {
|
|
46
|
+
new URL(src);
|
|
47
|
+
return true;
|
|
48
|
+
} catch (err) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function parseHtml(node, onResourceFound) {
|
|
53
|
+
const { childNodes = [] } = node;
|
|
54
|
+
for (const childNode of childNodes)if ("script" === childNode.nodeName) {
|
|
55
|
+
const src = external_parse5_utils_default().getAttribute(childNode, 'src');
|
|
56
|
+
if (!src) continue;
|
|
57
|
+
if (isUrl(src)) continue;
|
|
58
|
+
onResourceFound({
|
|
59
|
+
filePath: src,
|
|
60
|
+
childNode,
|
|
61
|
+
assetType: "script"
|
|
62
|
+
});
|
|
63
|
+
} else if ('link' === childNode.nodeName) {
|
|
64
|
+
const href = external_parse5_utils_default().getAttribute(childNode, 'href');
|
|
65
|
+
const rel = external_parse5_utils_default().getAttribute(childNode, 'rel');
|
|
66
|
+
if (!href) continue;
|
|
67
|
+
if (isUrl(href)) continue;
|
|
68
|
+
onResourceFound('dns-prefetch' === rel || 'icon' === rel || 'manifest' === rel || 'modulepreload' === rel || 'preconnect' === rel || 'prefetch' === rel || 'preload' === rel || 'prerender' === rel ? {
|
|
69
|
+
filePath: href,
|
|
70
|
+
childNode,
|
|
71
|
+
assetType: 'staticHref'
|
|
72
|
+
} : {
|
|
73
|
+
filePath: href,
|
|
74
|
+
childNode,
|
|
75
|
+
assetType: 'css'
|
|
76
|
+
});
|
|
77
|
+
} else if ('a' === childNode.nodeName || 'area' === childNode.nodeName) {
|
|
78
|
+
const href = external_parse5_utils_default().getAttribute(childNode, 'href');
|
|
79
|
+
if (!href) continue;
|
|
80
|
+
if (isUrl(href)) continue;
|
|
81
|
+
onResourceFound({
|
|
82
|
+
filePath: href,
|
|
83
|
+
childNode,
|
|
84
|
+
assetType: 'staticHref'
|
|
85
|
+
});
|
|
86
|
+
} 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) {
|
|
87
|
+
const src = external_parse5_utils_default().getAttribute(childNode, 'src');
|
|
88
|
+
if (!src) continue;
|
|
89
|
+
if (isUrl(src)) continue;
|
|
90
|
+
onResourceFound({
|
|
91
|
+
filePath: src,
|
|
92
|
+
childNode,
|
|
93
|
+
assetType: 'staticSrc'
|
|
94
|
+
});
|
|
95
|
+
} else parseHtml(childNode, onResourceFound);
|
|
96
|
+
}
|
|
97
|
+
function getAssetsFromHtml(htmlFilePath, htmlContent) {
|
|
98
|
+
const assets = {
|
|
99
|
+
css: [],
|
|
100
|
+
js: [],
|
|
101
|
+
static: []
|
|
102
|
+
};
|
|
103
|
+
if (!htmlFilePath) return assets;
|
|
104
|
+
const htmlString = htmlContent || external_fs_namespaceObject.readFileSync(htmlFilePath, {
|
|
105
|
+
encoding: 'utf8'
|
|
106
|
+
});
|
|
107
|
+
const htmlDocument = external_parse5_utils_default().parse(htmlString);
|
|
108
|
+
const getAbsolutePath = (htmlFilePath, filePath)=>external_path_namespaceObject.join(external_path_namespaceObject.dirname(htmlFilePath), filePath.startsWith('/') ? external_path_namespaceObject.relative(external_path_namespaceObject.dirname(htmlFilePath), filePath) : filePath);
|
|
109
|
+
for (const node of htmlDocument.childNodes)if ('html' === node.nodeName) {
|
|
110
|
+
for (const childNode of node.childNodes)if ('head' === childNode.nodeName || 'body' === childNode.nodeName) parseHtml(childNode, ({ filePath, assetType })=>{
|
|
111
|
+
const fileAbsolutePath = getAbsolutePath(htmlFilePath, filePath);
|
|
112
|
+
switch(assetType){
|
|
113
|
+
case "script":
|
|
114
|
+
var _assets_js;
|
|
115
|
+
null == (_assets_js = assets.js) || _assets_js.push(fileAbsolutePath);
|
|
116
|
+
break;
|
|
117
|
+
case 'css':
|
|
118
|
+
var _assets_css;
|
|
119
|
+
null == (_assets_css = assets.css) || _assets_css.push(fileAbsolutePath);
|
|
120
|
+
break;
|
|
121
|
+
case 'staticSrc':
|
|
122
|
+
case 'staticHref':
|
|
123
|
+
var _assets_static;
|
|
124
|
+
if (filePath.startsWith('#')) break;
|
|
125
|
+
null == (_assets_static = assets.static) || _assets_static.push(fileAbsolutePath);
|
|
126
|
+
break;
|
|
127
|
+
default:
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
return {
|
|
132
|
+
css: assets.css,
|
|
133
|
+
js: assets.js,
|
|
134
|
+
static: assets.static
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
require("child_process");
|
|
139
|
+
require("package-manager-detector");
|
|
140
|
+
require("chalk");
|
|
141
|
+
external_path_namespaceObject.join(process.cwd(), 'node_modules/extension-develop/dist/certs');
|
|
142
|
+
const constants_CHROMIUM_BASED_BROWSERS = [
|
|
143
|
+
'chrome',
|
|
144
|
+
'edge'
|
|
145
|
+
];
|
|
146
|
+
const GECKO_BASED_BROWSERS = [
|
|
147
|
+
'firefox'
|
|
148
|
+
];
|
|
149
|
+
[
|
|
150
|
+
...constants_CHROMIUM_BASED_BROWSERS,
|
|
151
|
+
...GECKO_BASED_BROWSERS
|
|
152
|
+
];
|
|
153
|
+
require("console");
|
|
154
|
+
function isUsingJSFramework(projectPath) {
|
|
155
|
+
const packageJsonPath = external_path_namespaceObject.join(projectPath, 'package.json');
|
|
156
|
+
if (!external_fs_namespaceObject.existsSync(packageJsonPath)) return false;
|
|
157
|
+
const packageJson = JSON.parse(external_fs_namespaceObject.readFileSync(packageJsonPath, 'utf-8'));
|
|
158
|
+
const frameworks = [
|
|
159
|
+
'react',
|
|
160
|
+
'vue',
|
|
161
|
+
'@angular/core',
|
|
162
|
+
'svelte',
|
|
163
|
+
'solid-js',
|
|
164
|
+
'preact'
|
|
165
|
+
];
|
|
166
|
+
const dependencies = packageJson.dependencies || {};
|
|
167
|
+
const devDependencies = packageJson.devDependencies || {};
|
|
168
|
+
for (const framework of frameworks)if (dependencies[framework] || devDependencies[framework]) return true;
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
const schema = {
|
|
172
|
+
type: 'object',
|
|
173
|
+
properties: {
|
|
174
|
+
test: {
|
|
175
|
+
type: 'string'
|
|
176
|
+
},
|
|
177
|
+
manifestPath: {
|
|
178
|
+
type: 'string'
|
|
179
|
+
},
|
|
180
|
+
includeList: {
|
|
181
|
+
type: 'object'
|
|
182
|
+
},
|
|
183
|
+
excludeList: {
|
|
184
|
+
type: 'object'
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
function ensureHMRForScripts(source) {
|
|
189
|
+
const options = this.getOptions();
|
|
190
|
+
const manifestPath = options.manifestPath;
|
|
191
|
+
const projectPath = external_path_namespaceObject.dirname(manifestPath);
|
|
192
|
+
(0, external_schema_utils_namespaceObject.validate)(schema, options, {
|
|
193
|
+
name: "html:ensure-hmr-for-scripts",
|
|
194
|
+
baseDataPath: 'options'
|
|
195
|
+
});
|
|
196
|
+
const url = (0, external_loader_utils_namespaceObject.urlToRequest)(this.resourcePath);
|
|
197
|
+
const reloadCode = `
|
|
198
|
+
// TODO: cezaraugusto re-visit this
|
|
2
199
|
if (import.meta.webpackHot) { import.meta.webpackHot.accept() };
|
|
3
|
-
`;
|
|
200
|
+
`;
|
|
201
|
+
if (isUsingJSFramework(projectPath)) return source;
|
|
202
|
+
const allEntries = options.includeList || {};
|
|
203
|
+
for (const field of Object.entries(allEntries)){
|
|
204
|
+
const [, resource] = field;
|
|
205
|
+
if (resource) {
|
|
206
|
+
if (!external_fs_namespaceObject.existsSync(resource)) return;
|
|
207
|
+
const htmlAssets = getAssetsFromHtml(resource);
|
|
208
|
+
const fileAssets = (null == htmlAssets ? void 0 : htmlAssets.js) || [];
|
|
209
|
+
for (const asset of fileAssets){
|
|
210
|
+
const absoluteUrl = external_path_namespaceObject.resolve(projectPath, asset);
|
|
211
|
+
if (url.includes(absoluteUrl)) return `${reloadCode}${source}`;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return source;
|
|
216
|
+
}
|
|
217
|
+
exports["default"] = __webpack_exports__["default"];
|
|
218
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
219
|
+
"default"
|
|
220
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
221
|
+
Object.defineProperty(exports, '__esModule', {
|
|
222
|
+
value: true
|
|
223
|
+
});
|
|
@@ -1,4 +1,84 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
default: ()=>inject_chromium_client_loader
|
|
28
|
+
});
|
|
29
|
+
const external_path_namespaceObject = require("path");
|
|
30
|
+
const external_fs_namespaceObject = require("fs");
|
|
31
|
+
const external_loader_utils_namespaceObject = require("loader-utils");
|
|
32
|
+
const external_schema_utils_namespaceObject = require("schema-utils");
|
|
33
|
+
require("child_process");
|
|
34
|
+
require("package-manager-detector");
|
|
35
|
+
require("chalk");
|
|
36
|
+
external_path_namespaceObject.join(process.cwd(), 'node_modules/extension-develop/dist/certs');
|
|
37
|
+
const CHROMIUM_BASED_BROWSERS = [
|
|
38
|
+
'chrome',
|
|
39
|
+
'edge'
|
|
40
|
+
];
|
|
41
|
+
const GECKO_BASED_BROWSERS = [
|
|
42
|
+
'firefox'
|
|
43
|
+
];
|
|
44
|
+
[
|
|
45
|
+
...CHROMIUM_BASED_BROWSERS,
|
|
46
|
+
...GECKO_BASED_BROWSERS
|
|
47
|
+
];
|
|
48
|
+
require("console");
|
|
49
|
+
function filterKeysForThisBrowser(manifest, browser) {
|
|
50
|
+
const patchedManifest = JSON.parse(JSON.stringify(manifest), function(key, value) {
|
|
51
|
+
const indexOfColon = key.indexOf(':');
|
|
52
|
+
if (-1 === indexOfColon) return value;
|
|
53
|
+
const prefix = key.substring(0, indexOfColon);
|
|
54
|
+
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;
|
|
55
|
+
});
|
|
56
|
+
return patchedManifest;
|
|
57
|
+
}
|
|
58
|
+
const schema = {
|
|
59
|
+
type: 'object',
|
|
60
|
+
properties: {
|
|
61
|
+
test: {
|
|
62
|
+
type: 'string'
|
|
63
|
+
},
|
|
64
|
+
manifestPath: {
|
|
65
|
+
type: 'string'
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
function inject_chromium_client_loader(source) {
|
|
70
|
+
const options = this.getOptions();
|
|
71
|
+
const manifestPath = options.manifestPath;
|
|
72
|
+
const browser = options.browser;
|
|
73
|
+
const projectPath = external_path_namespaceObject.dirname(manifestPath);
|
|
74
|
+
const manifest = JSON.parse(external_fs_namespaceObject.readFileSync(manifestPath, 'utf-8'));
|
|
75
|
+
const patchedManifest = filterKeysForThisBrowser(manifest, browser);
|
|
76
|
+
(0, external_schema_utils_namespaceObject.validate)(schema, options, {
|
|
77
|
+
name: 'reload:inject-background-client',
|
|
78
|
+
baseDataPath: 'options'
|
|
79
|
+
});
|
|
80
|
+
const url = (0, external_loader_utils_namespaceObject.urlToRequest)(this.resourcePath);
|
|
81
|
+
const generalReloadCode = `
|
|
2
82
|
;chrome.runtime.onMessageExternal.addListener(
|
|
3
83
|
async (request, _sender, sendResponse) => {
|
|
4
84
|
const managementInfo = await new Promise((resolve) => {
|
|
@@ -33,4 +113,32 @@
|
|
|
33
113
|
return true
|
|
34
114
|
}
|
|
35
115
|
);
|
|
36
|
-
|
|
116
|
+
`;
|
|
117
|
+
let manifestBg = patchedManifest.background;
|
|
118
|
+
if (manifestBg) {
|
|
119
|
+
const backgroundScripts = null == manifestBg ? void 0 : manifestBg.scripts;
|
|
120
|
+
if (backgroundScripts) {
|
|
121
|
+
if (2 === patchedManifest.manifest_version) for (const bgScript of [
|
|
122
|
+
backgroundScripts[0]
|
|
123
|
+
]){
|
|
124
|
+
const absoluteUrl = external_path_namespaceObject.resolve(projectPath, bgScript);
|
|
125
|
+
if (url.includes(absoluteUrl)) return `${generalReloadCode}${source}`;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const serviceWorker = null == manifestBg ? void 0 : manifestBg.service_worker;
|
|
129
|
+
if (serviceWorker) {
|
|
130
|
+
if (3 === patchedManifest.manifest_version) {
|
|
131
|
+
const absoluteUrl = external_path_namespaceObject.resolve(projectPath, serviceWorker);
|
|
132
|
+
if (url.includes(absoluteUrl)) return `${generalReloadCode}${source}`;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return source;
|
|
137
|
+
}
|
|
138
|
+
exports["default"] = __webpack_exports__["default"];
|
|
139
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
140
|
+
"default"
|
|
141
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
142
|
+
Object.defineProperty(exports, '__esModule', {
|
|
143
|
+
value: true
|
|
144
|
+
});
|