extension-develop 3.0.0-next.9 → 3.1.0-next.2
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/README.md +56 -16
- package/dist/215.js +546 -0
- package/dist/323.js +425 -0
- package/dist/329.js +9094 -0
- package/dist/419.js +44 -0
- package/dist/552.js +54 -0
- package/dist/814.js +127125 -0
- package/dist/814.js.LICENSE.txt +24 -0
- package/dist/928.js +416 -0
- package/dist/add-centralized-logger-script-background.js +3 -3
- package/dist/add-centralized-logger-script-content.js +4 -4
- package/dist/add-centralized-logger-script.js +18 -27
- package/dist/add-hmr-accept-code.js +3 -3
- package/dist/content-script-wrapper.js +114 -32
- package/dist/ensure-hmr-for-scripts.js +3 -3
- package/dist/extension-js-devtools/chrome/assets/logo.7dc70d61.png +0 -0
- package/dist/extension-js-devtools/chrome/background/service_worker.js +26 -0
- package/dist/extension-js-devtools/chrome/chrome_url_overrides/newtab.html +23 -0
- package/dist/extension-js-devtools/chrome/devtools/index.html +12 -0
- package/dist/extension-js-devtools/chrome/devtools/index.js +1 -0
- package/dist/extension-js-devtools/chrome/icons/logo.png +0 -0
- package/dist/extension-js-devtools/chrome/logo.png +0 -0
- package/dist/extension-js-devtools/chrome/manifest.json +44 -0
- package/dist/extension-js-devtools/chrome/pages/centralized-logger.css +2 -0
- package/dist/extension-js-devtools/chrome/pages/centralized-logger.html +12 -0
- package/dist/extension-js-devtools/chrome/pages/centralized-logger.js +16 -0
- package/dist/extension-js-devtools/chrome/pages/welcome.css +2 -0
- package/dist/extension-js-devtools/chrome/pages/welcome.html +11 -0
- package/dist/extension-js-devtools/chrome/pages/welcome.js +21 -0
- package/dist/extension-js-devtools/chrome/scripts/logger-client.js +1 -0
- package/dist/extension-js-devtools/chromium/assets/logo.7dc70d61.png +0 -0
- package/dist/extension-js-devtools/chromium/background/service_worker.js +26 -0
- package/dist/extension-js-devtools/chromium/chrome_url_overrides/newtab.html +23 -0
- package/dist/extension-js-devtools/chromium/devtools/index.html +12 -0
- package/dist/extension-js-devtools/chromium/devtools/index.js +1 -0
- package/dist/extension-js-devtools/chromium/icons/logo.png +0 -0
- package/dist/extension-js-devtools/chromium/logo.png +0 -0
- package/dist/extension-js-devtools/chromium/manifest.json +44 -0
- package/dist/extension-js-devtools/chromium/pages/centralized-logger.css +2 -0
- package/dist/extension-js-devtools/chromium/pages/centralized-logger.html +12 -0
- package/dist/extension-js-devtools/chromium/pages/centralized-logger.js +16 -0
- package/dist/extension-js-devtools/chromium/pages/welcome.css +2 -0
- package/dist/extension-js-devtools/chromium/pages/welcome.html +11 -0
- package/dist/extension-js-devtools/chromium/pages/welcome.js +21 -0
- package/dist/extension-js-devtools/chromium/scripts/logger-client.js +1 -0
- package/dist/extension-js-devtools/edge/assets/logo.7dc70d61.png +0 -0
- package/dist/extension-js-devtools/edge/background/service_worker.js +26 -0
- package/dist/extension-js-devtools/edge/chrome_url_overrides/newtab.html +23 -0
- package/dist/extension-js-devtools/edge/devtools/index.html +12 -0
- package/dist/extension-js-devtools/edge/devtools/index.js +1 -0
- package/dist/extension-js-devtools/edge/icons/logo.png +0 -0
- package/dist/extension-js-devtools/edge/logo.png +0 -0
- package/dist/extension-js-devtools/edge/manifest.json +44 -0
- package/dist/extension-js-devtools/edge/pages/centralized-logger.css +2 -0
- package/dist/extension-js-devtools/edge/pages/centralized-logger.html +12 -0
- package/dist/extension-js-devtools/edge/pages/centralized-logger.js +16 -0
- package/dist/extension-js-devtools/edge/pages/welcome.css +2 -0
- package/dist/extension-js-devtools/edge/pages/welcome.html +11 -0
- package/dist/extension-js-devtools/edge/pages/welcome.js +21 -0
- package/dist/extension-js-devtools/edge/scripts/logger-client.js +1 -0
- package/dist/extension-js-devtools/firefox/assets/logo.7dc70d61.png +0 -0
- package/dist/extension-js-devtools/firefox/background/scripts.js +26 -0
- package/dist/extension-js-devtools/firefox/devtools/index.html +12 -0
- package/dist/extension-js-devtools/firefox/devtools/index.js +1 -0
- package/dist/extension-js-devtools/firefox/icons/logo.png +0 -0
- package/dist/extension-js-devtools/firefox/logo.png +0 -0
- package/dist/extension-js-devtools/firefox/manifest.json +30 -0
- package/dist/extension-js-devtools/firefox/pages/centralized-logger.css +2 -0
- package/dist/extension-js-devtools/firefox/pages/centralized-logger.html +12 -0
- package/dist/extension-js-devtools/firefox/pages/centralized-logger.js +16 -0
- package/dist/extension-js-devtools/firefox/pages/welcome.css +2 -0
- package/dist/extension-js-devtools/firefox/pages/welcome.html +11 -0
- package/dist/extension-js-devtools/firefox/pages/welcome.js +21 -0
- package/dist/extension-js-devtools/firefox/scripts/logger-client.js +1 -0
- package/dist/extension-js-theme/chrome/manifest.json +65 -0
- package/dist/extension-js-theme/chromium/manifest.json +65 -0
- package/dist/extension-js-theme/edge/manifest.json +65 -0
- package/dist/extension-js-theme/firefox/manifest.json +6 -0
- package/dist/main-world-bridge.js +109 -0
- package/dist/minimum-chromium-file.js +2 -3
- package/dist/minimum-firefox-file.js +2 -3
- package/dist/minimum-script-file.js +25 -1
- package/dist/module.js +4774 -13450
- package/dist/resolve-paths-loader.js +61 -102
- package/dist/warn-no-default-export.js +173 -10
- package/package.json +55 -49
- package/dist/930.js +0 -44
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* MIT License
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2014-present, Lee Byron and other contributors.
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
package/dist/928.js
ADDED
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.ids = [
|
|
3
|
+
"928"
|
|
4
|
+
];
|
|
5
|
+
exports.modules = {
|
|
6
|
+
"./webpack/dev-server/index.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
7
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
8
|
+
devServer: ()=>dev_server_devServer
|
|
9
|
+
});
|
|
10
|
+
var external_path_ = __webpack_require__("path");
|
|
11
|
+
var core_ = __webpack_require__("@rspack/core");
|
|
12
|
+
var dev_server_ = __webpack_require__("@rspack/dev-server");
|
|
13
|
+
var external_webpack_merge_ = __webpack_require__("webpack-merge");
|
|
14
|
+
var external_pintor_ = __webpack_require__("pintor");
|
|
15
|
+
var external_pintor_default = /*#__PURE__*/ __webpack_require__.n(external_pintor_);
|
|
16
|
+
function getLoggingPrefix(type) {
|
|
17
|
+
const isAuthor = 'true' === process.env.EXTENSION_AUTHOR_MODE;
|
|
18
|
+
if (isAuthor) {
|
|
19
|
+
const base = 'error' === type ? 'ERROR Author says' : '►►► Author says';
|
|
20
|
+
return external_pintor_default().brightMagenta(base);
|
|
21
|
+
}
|
|
22
|
+
if ('error' === type) return external_pintor_default().red('ERROR');
|
|
23
|
+
if ('warn' === type) return external_pintor_default().brightYellow('►►►');
|
|
24
|
+
if ('info' === type) return external_pintor_default().gray('►►►');
|
|
25
|
+
return external_pintor_default().green('►►►');
|
|
26
|
+
}
|
|
27
|
+
function ready(mode, browser) {
|
|
28
|
+
const extensionOutput = 'firefox' === browser || 'gecko-based' === browser || 'edge' === browser ? 'Add-on' : 'Extension';
|
|
29
|
+
const b = String(browser || '');
|
|
30
|
+
const cap = b.charAt(0).toUpperCase() + b.slice(1);
|
|
31
|
+
const pretty = external_pintor_default().green('ready for ' + mode);
|
|
32
|
+
return `${getLoggingPrefix('info')} ${cap} ${extensionOutput} ${pretty}.`;
|
|
33
|
+
}
|
|
34
|
+
function portInUse(requestedPort, newPort) {
|
|
35
|
+
return `Port: Requested port ${external_pintor_default().brightBlue(requestedPort.toString())} is in use; using ${external_pintor_default().brightBlue(newPort.toString())} instead.`;
|
|
36
|
+
}
|
|
37
|
+
function extensionJsRunnerError(error) {
|
|
38
|
+
return `Extension.js Runner Error:\n${external_pintor_default().red(String(error))}`;
|
|
39
|
+
}
|
|
40
|
+
function autoExitModeEnabled(ms) {
|
|
41
|
+
return `Auto-exit enabled. Will exit after ${external_pintor_default().brightBlue(ms.toString())} ms if idle.`;
|
|
42
|
+
}
|
|
43
|
+
function autoExitTriggered(ms) {
|
|
44
|
+
return `Auto-exit triggered after ${external_pintor_default().brightBlue(ms.toString())} ms. Cleaning up...`;
|
|
45
|
+
}
|
|
46
|
+
function autoExitForceKill(ms) {
|
|
47
|
+
return `Force-killing process after ${external_pintor_default().brightBlue(ms.toString())} ms to ensure exit.`;
|
|
48
|
+
}
|
|
49
|
+
function devServerStartTimeout(ms) {
|
|
50
|
+
return [
|
|
51
|
+
`Dev server startup is taking longer than expected (${external_pintor_default().brightBlue(ms.toString())} ms).`,
|
|
52
|
+
"The bundler may have encountered an error before emitting the first build.",
|
|
53
|
+
`If nothing else prints, try setting ${external_pintor_default().brightBlue('EXTENSION_VERBOSE=1')} for more logs.`
|
|
54
|
+
].join('\n');
|
|
55
|
+
}
|
|
56
|
+
function bundlerFatalError(error) {
|
|
57
|
+
const text = error instanceof Error ? error.stack || error.message : String(error);
|
|
58
|
+
return `Build failed to start:\n${external_pintor_default().red(text)}`;
|
|
59
|
+
}
|
|
60
|
+
function bundlerRecompiling() {
|
|
61
|
+
return `Recompiling due to file changes…`;
|
|
62
|
+
}
|
|
63
|
+
function noEntrypointsDetected(port) {
|
|
64
|
+
return [
|
|
65
|
+
"No entrypoints or assets were produced by the initial compilation.",
|
|
66
|
+
`The dev server is running on 127.0.0.1:${external_pintor_default().brightBlue(port.toString())}, but nothing is being built.`,
|
|
67
|
+
"Possible causes:",
|
|
68
|
+
` • Empty or missing entry configuration.`,
|
|
69
|
+
` • Extension-related plugins are disabled (entries not derived from manifest).`,
|
|
70
|
+
` • All sources are ignored or excluded.`,
|
|
71
|
+
`Try enabling verbose logs with ${external_pintor_default().brightBlue('EXTENSION_VERBOSE=1')} or review your extension config.`
|
|
72
|
+
].join('\n');
|
|
73
|
+
}
|
|
74
|
+
var external_crypto_ = __webpack_require__("crypto");
|
|
75
|
+
var external_net_ = __webpack_require__("net");
|
|
76
|
+
var shared_utils = __webpack_require__("./webpack/plugin-browsers/browsers-lib/shared-utils.ts");
|
|
77
|
+
function _define_property(obj, key, value) {
|
|
78
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
79
|
+
value: value,
|
|
80
|
+
enumerable: true,
|
|
81
|
+
configurable: true,
|
|
82
|
+
writable: true
|
|
83
|
+
});
|
|
84
|
+
else obj[key] = value;
|
|
85
|
+
return obj;
|
|
86
|
+
}
|
|
87
|
+
class PortManager {
|
|
88
|
+
async allocatePorts(_browser, _projectPath, requestedPort) {
|
|
89
|
+
try {
|
|
90
|
+
const isValidRequested = 'number' == typeof requestedPort && requestedPort > 0 && requestedPort < 65536;
|
|
91
|
+
const base = isValidRequested ? requestedPort : this.basePort;
|
|
92
|
+
const port = await (0, shared_utils.aY)(base);
|
|
93
|
+
const webSocketPort = await (0, shared_utils.aY)(port + 1);
|
|
94
|
+
const instanceId = external_crypto_.randomBytes(8).toString('hex');
|
|
95
|
+
this.currentInstance = {
|
|
96
|
+
instanceId,
|
|
97
|
+
port,
|
|
98
|
+
webSocketPort
|
|
99
|
+
};
|
|
100
|
+
return {
|
|
101
|
+
port,
|
|
102
|
+
webSocketPort,
|
|
103
|
+
instanceId
|
|
104
|
+
};
|
|
105
|
+
} catch (error) {
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
getCurrentInstance() {
|
|
110
|
+
return this.currentInstance;
|
|
111
|
+
}
|
|
112
|
+
async updateExtensionId(extensionId) {
|
|
113
|
+
if (this.currentInstance) this.currentInstance.extensionId = extensionId;
|
|
114
|
+
}
|
|
115
|
+
async terminateCurrentInstance() {
|
|
116
|
+
this.currentInstance = null;
|
|
117
|
+
}
|
|
118
|
+
getPortInfo(allocation) {
|
|
119
|
+
return `Port: ${allocation.port}, WebSocket: ${allocation.webSocketPort}, Instance: ${allocation.instanceId.slice(0, 8)}`;
|
|
120
|
+
}
|
|
121
|
+
async isPortInUse(port) {
|
|
122
|
+
return new Promise((resolve)=>{
|
|
123
|
+
const server = external_net_.createServer();
|
|
124
|
+
server.once('error', ()=>resolve(true));
|
|
125
|
+
server.once('listening', ()=>{
|
|
126
|
+
server.close(()=>resolve(false));
|
|
127
|
+
});
|
|
128
|
+
server.listen(port, '127.0.0.1');
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
async getRunningInstances() {
|
|
132
|
+
return this.currentInstance ? [
|
|
133
|
+
this.currentInstance
|
|
134
|
+
] : [];
|
|
135
|
+
}
|
|
136
|
+
async getStats() {
|
|
137
|
+
return {
|
|
138
|
+
total: this.currentInstance ? 1 : 0,
|
|
139
|
+
running: this.currentInstance ? 1 : 0,
|
|
140
|
+
terminated: 0,
|
|
141
|
+
error: 0
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
constructor(_browser, _projectPath, basePort = 8080){
|
|
145
|
+
_define_property(this, "basePort", void 0);
|
|
146
|
+
_define_property(this, "currentInstance", null);
|
|
147
|
+
this.basePort = basePort;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
var external_fs_ = __webpack_require__("fs");
|
|
151
|
+
function hasDependency(projectPath, dependency) {
|
|
152
|
+
const findNearestPackageJsonDirectory = (startPath)=>{
|
|
153
|
+
let currentDirectory = startPath;
|
|
154
|
+
const maxDepth = 4;
|
|
155
|
+
for(let i = 0; i < maxDepth; i++){
|
|
156
|
+
const candidate = external_path_.join(currentDirectory, 'package.json');
|
|
157
|
+
if (external_fs_.existsSync(candidate)) return currentDirectory;
|
|
158
|
+
const parentDirectory = external_path_.dirname(currentDirectory);
|
|
159
|
+
if (parentDirectory === currentDirectory) break;
|
|
160
|
+
currentDirectory = parentDirectory;
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
const packageJsonDirectory = findNearestPackageJsonDirectory(projectPath);
|
|
164
|
+
if (!packageJsonDirectory) return false;
|
|
165
|
+
const packageJsonPath = external_path_.join(packageJsonDirectory, 'package.json');
|
|
166
|
+
if (!external_fs_.existsSync(packageJsonPath)) return false;
|
|
167
|
+
const packageJson = JSON.parse(external_fs_.readFileSync(packageJsonPath, 'utf8'));
|
|
168
|
+
const dependencies = packageJson.dependencies || {};
|
|
169
|
+
const devDependencies = packageJson.devDependencies || {};
|
|
170
|
+
return !!dependencies[dependency] || !!devDependencies[dependency];
|
|
171
|
+
}
|
|
172
|
+
function isUsingJSFramework(projectPath) {
|
|
173
|
+
const frameworks = [
|
|
174
|
+
'react',
|
|
175
|
+
'vue',
|
|
176
|
+
'@angular/core',
|
|
177
|
+
'svelte',
|
|
178
|
+
'solid-js',
|
|
179
|
+
'preact'
|
|
180
|
+
];
|
|
181
|
+
return frameworks.some((fw)=>hasDependency(projectPath, fw));
|
|
182
|
+
}
|
|
183
|
+
var config_loader = __webpack_require__("./webpack/webpack-lib/config-loader.ts");
|
|
184
|
+
var sanitize = __webpack_require__("./webpack/webpack-lib/sanitize.ts");
|
|
185
|
+
var branding = __webpack_require__("./webpack/webpack-lib/branding.ts");
|
|
186
|
+
function setupCompilerHooks(compiler, port) {
|
|
187
|
+
const verbose = '1' === String(process.env.EXTENSION_VERBOSE || '').trim();
|
|
188
|
+
let reportedNoEntries = false;
|
|
189
|
+
compiler.hooks.invalid.tap('extension.js:invalid', ()=>{
|
|
190
|
+
if (verbose) console.log(bundlerRecompiling());
|
|
191
|
+
});
|
|
192
|
+
compiler.hooks.failed.tap('extension.js:failed', (error)=>{
|
|
193
|
+
console.error(bundlerFatalError(error));
|
|
194
|
+
});
|
|
195
|
+
compiler.hooks.done.tap('extension.js:done', (stats)=>{
|
|
196
|
+
try {
|
|
197
|
+
if (stats?.hasErrors?.()) {
|
|
198
|
+
const str = stats?.toString?.({
|
|
199
|
+
colors: true,
|
|
200
|
+
all: false,
|
|
201
|
+
errors: true,
|
|
202
|
+
warnings: true
|
|
203
|
+
});
|
|
204
|
+
if (str) console.error((0, branding.h)(str));
|
|
205
|
+
} else if (stats?.hasWarnings?.()) {
|
|
206
|
+
const str = stats?.toString?.({
|
|
207
|
+
colors: true,
|
|
208
|
+
all: false,
|
|
209
|
+
errors: false,
|
|
210
|
+
warnings: true
|
|
211
|
+
});
|
|
212
|
+
if (str) console.warn((0, branding.h)(str));
|
|
213
|
+
}
|
|
214
|
+
if (!reportedNoEntries) {
|
|
215
|
+
const info = stats.toJson({
|
|
216
|
+
all: false,
|
|
217
|
+
assets: true,
|
|
218
|
+
entrypoints: true
|
|
219
|
+
});
|
|
220
|
+
const hasAssets = Array.isArray(info?.assets) && info.assets.length > 0;
|
|
221
|
+
const entrypoints = info?.entrypoints || {};
|
|
222
|
+
const hasEntrypoints = entrypoints && Object.keys(entrypoints).length > 0;
|
|
223
|
+
if (!hasAssets && !hasEntrypoints) {
|
|
224
|
+
reportedNoEntries = true;
|
|
225
|
+
console.warn(noEntrypointsDetected(port));
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
} catch (error) {
|
|
229
|
+
const str = stats?.toString({
|
|
230
|
+
colors: true,
|
|
231
|
+
all: false,
|
|
232
|
+
errors: true,
|
|
233
|
+
warnings: true
|
|
234
|
+
});
|
|
235
|
+
if (str) console.error((0, branding.h)(str));
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
function parseMilliseconds(value) {
|
|
240
|
+
if ('number' == typeof value) return Number.isFinite(value) && value > 0 ? value : null;
|
|
241
|
+
if ('string' == typeof value) {
|
|
242
|
+
const parsed = parseInt(value, 10);
|
|
243
|
+
return !Number.isNaN(parsed) && parsed > 0 ? parsed : null;
|
|
244
|
+
}
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
function setupAutoExit(autoExitMsRaw, forceKillMsRaw, onCleanup) {
|
|
248
|
+
let autoExitTimer = null;
|
|
249
|
+
let forceKillTimer = null;
|
|
250
|
+
const autoExitMs = parseMilliseconds(autoExitMsRaw);
|
|
251
|
+
if (null === autoExitMs) return ()=>{};
|
|
252
|
+
try {
|
|
253
|
+
console.log(autoExitModeEnabled(autoExitMs));
|
|
254
|
+
} catch {}
|
|
255
|
+
autoExitTimer = setTimeout(async ()=>{
|
|
256
|
+
try {
|
|
257
|
+
console.log(autoExitTriggered(autoExitMs));
|
|
258
|
+
} catch {}
|
|
259
|
+
await onCleanup();
|
|
260
|
+
}, autoExitMs);
|
|
261
|
+
const parsedForceKillMs = parseMilliseconds(forceKillMsRaw);
|
|
262
|
+
const forceKillMs = null !== parsedForceKillMs && parsedForceKillMs > 0 ? parsedForceKillMs : autoExitMs + 4000;
|
|
263
|
+
forceKillTimer = setTimeout(()=>{
|
|
264
|
+
try {
|
|
265
|
+
console.log(autoExitForceKill(forceKillMs));
|
|
266
|
+
} catch {}
|
|
267
|
+
process.exit(0);
|
|
268
|
+
}, forceKillMs);
|
|
269
|
+
function cancelAutoExitTimers() {
|
|
270
|
+
if (null !== autoExitTimer) {
|
|
271
|
+
clearTimeout(autoExitTimer);
|
|
272
|
+
autoExitTimer = null;
|
|
273
|
+
}
|
|
274
|
+
if (null !== forceKillTimer) {
|
|
275
|
+
clearTimeout(forceKillTimer);
|
|
276
|
+
forceKillTimer = null;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return cancelAutoExitTimers;
|
|
280
|
+
}
|
|
281
|
+
function closeAll(devServer, portManager) {
|
|
282
|
+
return devServer.stop().then(async ()=>{
|
|
283
|
+
await portManager.terminateCurrentInstance();
|
|
284
|
+
setTimeout(()=>process.exit(), 500);
|
|
285
|
+
}).catch(async (error)=>{
|
|
286
|
+
console.log(extensionJsRunnerError(error));
|
|
287
|
+
await portManager.terminateCurrentInstance();
|
|
288
|
+
setTimeout(()=>process.exit(1), 500);
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
function setupCleanupHandlers(devServer, portManager) {
|
|
292
|
+
const cleanup = async ()=>{
|
|
293
|
+
try {
|
|
294
|
+
await closeAll(devServer, portManager);
|
|
295
|
+
} catch (error) {
|
|
296
|
+
console.error('[Extension.js Runner] Error during cleanup.', error);
|
|
297
|
+
process.exit(1);
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
process.on('uncaughtException', async (error)=>{
|
|
301
|
+
console.error('[Extension.js Runner] Uncaught exception.', error);
|
|
302
|
+
await cleanup();
|
|
303
|
+
});
|
|
304
|
+
process.on('unhandledRejection', async (reason, promise)=>{
|
|
305
|
+
console.error('[Extension.js Runner] Unhandled rejection.', promise, reason);
|
|
306
|
+
await cleanup();
|
|
307
|
+
});
|
|
308
|
+
const cancelAutoExit = setupAutoExit(process.env.EXTENSION_AUTO_EXIT_MS, process.env.EXTENSION_FORCE_KILL_MS, cleanup);
|
|
309
|
+
const cancelAndCleanup = async ()=>{
|
|
310
|
+
try {
|
|
311
|
+
cancelAutoExit();
|
|
312
|
+
} catch {}
|
|
313
|
+
await cleanup();
|
|
314
|
+
};
|
|
315
|
+
process.on('ERROR', cancelAndCleanup);
|
|
316
|
+
process.on('SIGINT', cancelAndCleanup);
|
|
317
|
+
process.on('SIGTERM', cancelAndCleanup);
|
|
318
|
+
process.on('SIGHUP', cancelAndCleanup);
|
|
319
|
+
return cancelAutoExit;
|
|
320
|
+
}
|
|
321
|
+
var webpack_config = __webpack_require__("./webpack/webpack-config.ts");
|
|
322
|
+
async function dev_server_devServer(projectStructure, devOptions) {
|
|
323
|
+
const { manifestPath, packageJsonPath } = projectStructure;
|
|
324
|
+
const manifestDir = external_path_.dirname(manifestPath);
|
|
325
|
+
const packageJsonDir = external_path_.dirname(packageJsonPath);
|
|
326
|
+
const commandConfig = await (0, config_loader.eY)(packageJsonDir, 'dev');
|
|
327
|
+
const browserConfig = await (0, config_loader.xY)(packageJsonDir, devOptions.browser);
|
|
328
|
+
const portManager = new PortManager(devOptions.browser, packageJsonDir, 8080);
|
|
329
|
+
const desiredPort = 'string' == typeof devOptions.port ? parseInt(devOptions.port, 10) : devOptions.port;
|
|
330
|
+
const portAllocation = await portManager.allocatePorts(devOptions.browser, packageJsonDir, desiredPort);
|
|
331
|
+
const currentInstance = portManager.getCurrentInstance();
|
|
332
|
+
if (!currentInstance) throw new Error('Failed to create instance');
|
|
333
|
+
const safeBrowserConfig = (0, sanitize.a)(browserConfig);
|
|
334
|
+
const safeCommandConfig = (0, sanitize.a)(commandConfig);
|
|
335
|
+
const safeDevOptions = (0, sanitize.a)(devOptions);
|
|
336
|
+
const baseConfig = (0, webpack_config["default"])(projectStructure, {
|
|
337
|
+
...safeBrowserConfig,
|
|
338
|
+
...safeCommandConfig,
|
|
339
|
+
...safeDevOptions,
|
|
340
|
+
browser: devOptions.browser,
|
|
341
|
+
mode: 'development',
|
|
342
|
+
instanceId: currentInstance.instanceId,
|
|
343
|
+
port: portAllocation.port,
|
|
344
|
+
output: {
|
|
345
|
+
clean: false,
|
|
346
|
+
path: external_path_.join(packageJsonDir, 'dist', devOptions.browser)
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
const customWebpackConfig = await (0, config_loader.Tu)(manifestDir);
|
|
350
|
+
const finalConfig = customWebpackConfig(baseConfig);
|
|
351
|
+
const compilerConfig = (0, external_webpack_merge_.merge)(finalConfig, {});
|
|
352
|
+
const compiler = (0, core_.rspack)(compilerConfig);
|
|
353
|
+
setupCompilerHooks(compiler, portAllocation.port);
|
|
354
|
+
const port = portAllocation.port;
|
|
355
|
+
if (void 0 !== devOptions.port && devOptions.port !== port) console.log(portInUse(devOptions.port, port));
|
|
356
|
+
const serverConfig = {
|
|
357
|
+
host: '127.0.0.1',
|
|
358
|
+
allowedHosts: 'all',
|
|
359
|
+
static: {
|
|
360
|
+
watch: {
|
|
361
|
+
ignored: /\bnode_modules\b/
|
|
362
|
+
}
|
|
363
|
+
},
|
|
364
|
+
compress: false,
|
|
365
|
+
devMiddleware: {
|
|
366
|
+
writeToDisk: true,
|
|
367
|
+
stats: false
|
|
368
|
+
},
|
|
369
|
+
watchFiles: {
|
|
370
|
+
paths: [
|
|
371
|
+
external_path_.join(packageJsonDir, 'public', '**/*'),
|
|
372
|
+
...isUsingJSFramework(packageJsonDir) ? [] : [
|
|
373
|
+
external_path_.join(packageJsonDir, '**/*.html')
|
|
374
|
+
]
|
|
375
|
+
],
|
|
376
|
+
options: {
|
|
377
|
+
usePolling: true,
|
|
378
|
+
interval: 1000
|
|
379
|
+
}
|
|
380
|
+
},
|
|
381
|
+
client: {
|
|
382
|
+
logging: 'none',
|
|
383
|
+
progress: false,
|
|
384
|
+
overlay: false,
|
|
385
|
+
webSocketURL: {
|
|
386
|
+
protocol: 'ws',
|
|
387
|
+
hostname: '127.0.0.1',
|
|
388
|
+
port
|
|
389
|
+
}
|
|
390
|
+
},
|
|
391
|
+
headers: {
|
|
392
|
+
'Access-Control-Allow-Origin': '*'
|
|
393
|
+
},
|
|
394
|
+
port,
|
|
395
|
+
hot: 'only',
|
|
396
|
+
liveReload: true
|
|
397
|
+
};
|
|
398
|
+
const devServer = new dev_server_.RspackDevServer(serverConfig, compiler);
|
|
399
|
+
const START_TIMEOUT_MS = parseInt(String(process.env.EXTENSION_START_TIMEOUT_MS || '30000'), 10);
|
|
400
|
+
let startTimeout;
|
|
401
|
+
try {
|
|
402
|
+
startTimeout = setTimeout(()=>{
|
|
403
|
+
console.error(devServerStartTimeout(START_TIMEOUT_MS));
|
|
404
|
+
}, START_TIMEOUT_MS);
|
|
405
|
+
await devServer.start();
|
|
406
|
+
if (startTimeout) clearTimeout(startTimeout);
|
|
407
|
+
console.log(ready('development', devOptions.browser));
|
|
408
|
+
} catch (error) {
|
|
409
|
+
if (startTimeout) clearTimeout(startTimeout);
|
|
410
|
+
console.log(extensionJsRunnerError(error));
|
|
411
|
+
process.exit(1);
|
|
412
|
+
}
|
|
413
|
+
setupCleanupHandlers(devServer, portManager);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
};
|
|
@@ -22,7 +22,7 @@ var __webpack_require__ = {};
|
|
|
22
22
|
})();
|
|
23
23
|
(()=>{
|
|
24
24
|
__webpack_require__.r = (exports1)=>{
|
|
25
|
-
if (
|
|
25
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
26
|
value: 'Module'
|
|
27
27
|
});
|
|
28
28
|
Object.defineProperty(exports1, '__esModule', {
|
|
@@ -212,9 +212,9 @@ function logger_background(source) {
|
|
|
212
212
|
return source;
|
|
213
213
|
}
|
|
214
214
|
exports["default"] = __webpack_exports__["default"];
|
|
215
|
-
for(var
|
|
215
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
216
216
|
"default"
|
|
217
|
-
].indexOf(
|
|
217
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
218
218
|
Object.defineProperty(exports, '__esModule', {
|
|
219
219
|
value: true
|
|
220
220
|
});
|
|
@@ -22,7 +22,7 @@ var __webpack_require__ = {};
|
|
|
22
22
|
})();
|
|
23
23
|
(()=>{
|
|
24
24
|
__webpack_require__.r = (exports1)=>{
|
|
25
|
-
if (
|
|
25
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
26
|
value: 'Module'
|
|
27
27
|
});
|
|
28
28
|
Object.defineProperty(exports1, '__esModule', {
|
|
@@ -153,7 +153,7 @@ function logger_script(source) {
|
|
|
153
153
|
const declaredContentJsAbsPaths = [];
|
|
154
154
|
const contentScripts = Array.isArray(manifest.content_scripts) ? manifest.content_scripts : [];
|
|
155
155
|
for (const cs of contentScripts){
|
|
156
|
-
const jsList = Array.isArray(
|
|
156
|
+
const jsList = Array.isArray(cs?.js) ? cs.js : [];
|
|
157
157
|
for (const js of jsList){
|
|
158
158
|
const abs = external_path_default().resolve(projectPath, js);
|
|
159
159
|
declaredContentJsAbsPaths.push(abs);
|
|
@@ -164,9 +164,9 @@ function logger_script(source) {
|
|
|
164
164
|
return source;
|
|
165
165
|
}
|
|
166
166
|
exports["default"] = __webpack_exports__["default"];
|
|
167
|
-
for(var
|
|
167
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
168
168
|
"default"
|
|
169
|
-
].indexOf(
|
|
169
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
170
170
|
Object.defineProperty(exports, '__esModule', {
|
|
171
171
|
value: true
|
|
172
172
|
});
|
|
@@ -13,7 +13,7 @@ var __webpack_require__ = {};
|
|
|
13
13
|
})();
|
|
14
14
|
(()=>{
|
|
15
15
|
__webpack_require__.r = (exports1)=>{
|
|
16
|
-
if (
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
17
|
value: 'Module'
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports1, '__esModule', {
|
|
@@ -41,8 +41,7 @@ function isUrl(src) {
|
|
|
41
41
|
function parseHtml(node, onResourceFound) {
|
|
42
42
|
if ('#comment' === node.nodeName || '#text' === node.nodeName) return;
|
|
43
43
|
if ("script" === node.nodeName) {
|
|
44
|
-
|
|
45
|
-
const src = null == (_node_attrs = node.attrs) ? void 0 : null == (_node_attrs_find = _node_attrs.find((attr)=>'src' === attr.name)) ? void 0 : _node_attrs_find.value;
|
|
44
|
+
const src = node.attrs?.find((attr)=>'src' === attr.name)?.value;
|
|
46
45
|
if (!src) return;
|
|
47
46
|
if (isUrl(src)) return;
|
|
48
47
|
onResourceFound({
|
|
@@ -51,9 +50,8 @@ function parseHtml(node, onResourceFound) {
|
|
|
51
50
|
assetType: "script"
|
|
52
51
|
});
|
|
53
52
|
} else if ('link' === node.nodeName) {
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
const rel = null == (_node_attrs2 = node.attrs) ? void 0 : null == (_node_attrs_find2 = _node_attrs2.find((attr)=>'rel' === attr.name)) ? void 0 : _node_attrs_find2.value;
|
|
53
|
+
const href = node.attrs?.find((attr)=>'href' === attr.name)?.value;
|
|
54
|
+
const rel = node.attrs?.find((attr)=>'rel' === attr.name)?.value;
|
|
57
55
|
if (!href) return;
|
|
58
56
|
if (isUrl(href)) return;
|
|
59
57
|
onResourceFound('dns-prefetch' === rel || 'icon' === rel || 'manifest' === rel || 'modulepreload' === rel || 'preconnect' === rel || 'prefetch' === rel || 'preload' === rel || 'prerender' === rel ? {
|
|
@@ -66,8 +64,7 @@ function parseHtml(node, onResourceFound) {
|
|
|
66
64
|
assetType: 'css'
|
|
67
65
|
});
|
|
68
66
|
} else if ('audio' === node.nodeName || 'embed' === node.nodeName || 'iframe' === node.nodeName || 'img' === node.nodeName || 'input' === node.nodeName || 'source' === node.nodeName || 'track' === node.nodeName || 'video' === node.nodeName) {
|
|
69
|
-
|
|
70
|
-
const src = null == (_node_attrs3 = node.attrs) ? void 0 : null == (_node_attrs_find3 = _node_attrs3.find((attr)=>'src' === attr.name)) ? void 0 : _node_attrs_find3.value;
|
|
67
|
+
const src = node.attrs?.find((attr)=>'src' === attr.name)?.value;
|
|
71
68
|
if (!src) return;
|
|
72
69
|
if (isUrl(src)) return;
|
|
73
70
|
onResourceFound({
|
|
@@ -75,7 +72,7 @@ function parseHtml(node, onResourceFound) {
|
|
|
75
72
|
childNode: node,
|
|
76
73
|
assetType: 'staticSrc'
|
|
77
74
|
});
|
|
78
|
-
const srcset =
|
|
75
|
+
const srcset = node.attrs?.find((attr)=>'srcset' === attr.name)?.value;
|
|
79
76
|
if (srcset) {
|
|
80
77
|
const candidates = srcset.split(',');
|
|
81
78
|
for (const candidate of candidates){
|
|
@@ -91,8 +88,7 @@ function parseHtml(node, onResourceFound) {
|
|
|
91
88
|
}
|
|
92
89
|
}
|
|
93
90
|
if ('video' === node.nodeName) {
|
|
94
|
-
|
|
95
|
-
const poster = null == (_node_attrs5 = node.attrs) ? void 0 : null == (_node_attrs_find5 = _node_attrs5.find((attr)=>'poster' === attr.name)) ? void 0 : _node_attrs_find5.value;
|
|
91
|
+
const poster = node.attrs?.find((attr)=>'poster' === attr.name)?.value;
|
|
96
92
|
if (poster && !isUrl(poster)) {
|
|
97
93
|
const { cleanPath } = cleanAssetUrl(poster);
|
|
98
94
|
if (cleanPath) onResourceFound({
|
|
@@ -103,8 +99,7 @@ function parseHtml(node, onResourceFound) {
|
|
|
103
99
|
}
|
|
104
100
|
}
|
|
105
101
|
} else if ('link' === node.nodeName) {
|
|
106
|
-
|
|
107
|
-
const imagesrcset = null == (_node_attrs6 = node.attrs) ? void 0 : null == (_node_attrs_find6 = _node_attrs6.find((attr)=>'imagesrcset' === attr.name)) ? void 0 : _node_attrs_find6.value;
|
|
102
|
+
const imagesrcset = node.attrs?.find((attr)=>'imagesrcset' === attr.name)?.value;
|
|
108
103
|
if (imagesrcset) {
|
|
109
104
|
const candidates = imagesrcset.split(',');
|
|
110
105
|
for (const candidate of candidates){
|
|
@@ -149,18 +144,15 @@ function getAssetsFromHtml(htmlFilePath, htmlContent, publicPath = 'public') {
|
|
|
149
144
|
const fileAbsolutePath = getAbsolutePath(htmlFilePath, filePath);
|
|
150
145
|
switch(assetType){
|
|
151
146
|
case "script":
|
|
152
|
-
|
|
153
|
-
null == (_assets_js = assets.js) || _assets_js.push(fileAbsolutePath);
|
|
147
|
+
assets.js?.push(fileAbsolutePath);
|
|
154
148
|
break;
|
|
155
149
|
case 'css':
|
|
156
|
-
|
|
157
|
-
null == (_assets_css = assets.css) || _assets_css.push(fileAbsolutePath);
|
|
150
|
+
assets.css?.push(fileAbsolutePath);
|
|
158
151
|
break;
|
|
159
152
|
case 'staticSrc':
|
|
160
153
|
case 'staticHref':
|
|
161
|
-
var _assets_static;
|
|
162
154
|
if (filePath.startsWith('#')) break;
|
|
163
|
-
|
|
155
|
+
assets.static?.push(fileAbsolutePath);
|
|
164
156
|
break;
|
|
165
157
|
default:
|
|
166
158
|
break;
|
|
@@ -195,11 +187,10 @@ function cleanAssetUrl(url) {
|
|
|
195
187
|
}
|
|
196
188
|
function getBaseHref(htmlDocument) {
|
|
197
189
|
const htmlChildren = htmlDocument.childNodes || [];
|
|
198
|
-
for (const node of htmlChildren)if (
|
|
199
|
-
for (const child of node.childNodes || [])if (
|
|
200
|
-
for (const headChild of child.childNodes || [])if (
|
|
201
|
-
|
|
202
|
-
const href = null == (_headChild_attrs = headChild.attrs) ? void 0 : null == (_headChild_attrs_find = _headChild_attrs.find((a)=>'href' === a.name)) ? void 0 : _headChild_attrs_find.value;
|
|
190
|
+
for (const node of htmlChildren)if (node?.nodeName === 'html') {
|
|
191
|
+
for (const child of node.childNodes || [])if (child?.nodeName === 'head') {
|
|
192
|
+
for (const headChild of child.childNodes || [])if (headChild?.nodeName === 'base') {
|
|
193
|
+
const href = headChild.attrs?.find((a)=>'href' === a.name)?.value;
|
|
203
194
|
if (href) return href;
|
|
204
195
|
}
|
|
205
196
|
}
|
|
@@ -254,7 +245,7 @@ if (import.meta.webpackHot) { import.meta.webpackHot.accept() }
|
|
|
254
245
|
if (!htmlPath) continue;
|
|
255
246
|
if (!external_fs_namespaceObject.existsSync(htmlPath)) continue;
|
|
256
247
|
const assets = getAssetsFromHtml(htmlPath);
|
|
257
|
-
const jsAssets =
|
|
248
|
+
const jsAssets = assets?.js || [];
|
|
258
249
|
const absAssets = jsAssets.map((p)=>{
|
|
259
250
|
if (p.startsWith('/')) return external_path_namespaceObject.normalize(external_path_namespaceObject.join(projectPath, 'public', p.slice(1)));
|
|
260
251
|
return external_path_namespaceObject.normalize(p);
|
|
@@ -324,9 +315,9 @@ if (import.meta.webpackHot) { import.meta.webpackHot.accept() }
|
|
|
324
315
|
return `${loggerPrelude}${source}`;
|
|
325
316
|
}
|
|
326
317
|
exports["default"] = __webpack_exports__["default"];
|
|
327
|
-
for(var
|
|
318
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
328
319
|
"default"
|
|
329
|
-
].indexOf(
|
|
320
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
330
321
|
Object.defineProperty(exports, '__esModule', {
|
|
331
322
|
value: true
|
|
332
323
|
});
|
|
@@ -22,7 +22,7 @@ var __webpack_require__ = {};
|
|
|
22
22
|
})();
|
|
23
23
|
(()=>{
|
|
24
24
|
__webpack_require__.r = (exports1)=>{
|
|
25
|
-
if (
|
|
25
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
26
|
value: 'Module'
|
|
27
27
|
});
|
|
28
28
|
Object.defineProperty(exports1, '__esModule', {
|
|
@@ -83,9 +83,9 @@ if (import.meta.webpackHot) { try { import.meta.webpackHot.accept(); } catch (_)
|
|
|
83
83
|
return source;
|
|
84
84
|
}
|
|
85
85
|
exports["default"] = __webpack_exports__["default"];
|
|
86
|
-
for(var
|
|
86
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
87
87
|
"default"
|
|
88
|
-
].indexOf(
|
|
88
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
89
89
|
Object.defineProperty(exports, '__esModule', {
|
|
90
90
|
value: true
|
|
91
91
|
});
|