extension-develop 3.15.1 → 3.16.0
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/0~branding.mjs +26 -0
- package/dist/0~dev-server.mjs +488 -0
- package/dist/0~rslib-runtime.mjs +40 -0
- package/dist/0~rspack-config.mjs +8648 -0
- package/dist/0~stats-handler.mjs +25 -0
- package/dist/0~zip.mjs +34 -0
- package/dist/314.mjs +35 -0
- package/dist/526.mjs +23 -0
- package/dist/946.mjs +1670 -0
- package/dist/962.mjs +1389 -0
- package/dist/ensure-hmr-for-scripts.js +12 -56
- package/dist/{ensure-hmr-for-scripts.cjs → ensure-hmr-for-scripts.mjs} +12 -56
- package/dist/feature-scripts-content-script-wrapper.js +23 -98
- package/dist/{feature-scripts-content-script-wrapper.cjs → feature-scripts-content-script-wrapper.mjs} +23 -98
- package/dist/main-world-bridge.js +0 -18
- package/dist/{main-world-bridge.cjs → main-world-bridge.mjs} +0 -18
- package/dist/minimum-chromium-file.js +0 -5
- package/dist/minimum-chromium-file.mjs +5 -0
- package/dist/minimum-firefox-file.js +0 -5
- package/dist/minimum-firefox-file.mjs +5 -0
- package/dist/minimum-script-file.js +0 -18
- package/dist/{minimum-script-file.cjs → minimum-script-file.mjs} +0 -18
- package/dist/module.mjs +3 -0
- package/dist/package.json +1 -1
- package/dist/preact-refresh-shim.mjs +7 -0
- package/dist/preview.mjs +2 -0
- package/dist/resolve-paths-loader.js +1043 -1093
- package/dist/resolve-paths-loader.mjs +1300 -0
- package/package.json +8 -8
- package/dist/221.cjs +0 -513
- package/dist/442.cjs +0 -9226
- package/dist/504.cjs +0 -65
- package/dist/787.cjs +0 -44
- package/dist/minimum-chromium-file.cjs +0 -10
- package/dist/minimum-firefox-file.cjs +0 -10
- package/dist/module.cjs +0 -3479
- package/dist/preact-refresh-shim.cjs +0 -25
- package/dist/preview.cjs +0 -1464
- package/dist/resolve-paths-loader.cjs +0 -1350
package/dist/module.cjs
DELETED
|
@@ -1,3479 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const __rslib_import_meta_url__ = /*#__PURE__*/ function() {
|
|
3
|
-
return "u" < typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
|
|
4
|
-
}();
|
|
5
|
-
var __webpack_modules__ = {
|
|
6
|
-
"./dev-server/messages.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
7
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
8
|
-
Df: ()=>autoExitForceKill,
|
|
9
|
-
Gc: ()=>ready,
|
|
10
|
-
Nq: ()=>bundlerFatalError,
|
|
11
|
-
UF: ()=>devServerStartTimeout,
|
|
12
|
-
VL: ()=>extensionJsRunnerError,
|
|
13
|
-
aO: ()=>portInUse,
|
|
14
|
-
bL: ()=>browserRunnerDisabled,
|
|
15
|
-
eP: ()=>bundlerRecompiling,
|
|
16
|
-
nI: ()=>noEntrypointsDetected,
|
|
17
|
-
o6: ()=>autoExitModeEnabled,
|
|
18
|
-
tJ: ()=>autoExitTriggered,
|
|
19
|
-
tl: ()=>spacerLine
|
|
20
|
-
});
|
|
21
|
-
var fs__rspack_import_0 = __webpack_require__("fs");
|
|
22
|
-
var pintor__rspack_import_1 = __webpack_require__("pintor");
|
|
23
|
-
var pintor__rspack_import_1_default = /*#__PURE__*/ __webpack_require__.n(pintor__rspack_import_1);
|
|
24
|
-
function getLoggingPrefix(type) {
|
|
25
|
-
const isAuthor = 'true' === process.env.EXTENSION_AUTHOR_MODE;
|
|
26
|
-
if (isAuthor) {
|
|
27
|
-
const base = 'error' === type ? 'ERROR Author says' : '⏵⏵⏵ Author says';
|
|
28
|
-
return pintor__rspack_import_1_default().brightMagenta(base);
|
|
29
|
-
}
|
|
30
|
-
if ('error' === type) return pintor__rspack_import_1_default().red('ERROR');
|
|
31
|
-
if ('warn' === type) return pintor__rspack_import_1_default().brightYellow('⏵⏵⏵');
|
|
32
|
-
if ('info' === type) return pintor__rspack_import_1_default().gray('⏵⏵⏵');
|
|
33
|
-
return pintor__rspack_import_1_default().green('⏵⏵⏵');
|
|
34
|
-
}
|
|
35
|
-
function ready(mode, browser) {
|
|
36
|
-
const key = String(browser || '').toLowerCase();
|
|
37
|
-
const extensionOutput = 'firefox' === key || 'gecko-based' === key || 'firefox-based' === key || 'edge' === key ? 'Add-on' : 'Extension';
|
|
38
|
-
const cap = 'firefox' === key || 'gecko-based' === key || 'firefox-based' === key ? 'Firefox' : String(browser || '').charAt(0).toUpperCase() + String(browser || '').slice(1);
|
|
39
|
-
const pretty = pintor__rspack_import_1_default().green('ready for ' + mode);
|
|
40
|
-
return `${getLoggingPrefix('info')} ${cap} ${extensionOutput} ${pretty}.`;
|
|
41
|
-
}
|
|
42
|
-
function readJsonRecord(filePath) {
|
|
43
|
-
try {
|
|
44
|
-
return JSON.parse(fs__rspack_import_0.readFileSync(filePath, 'utf8'));
|
|
45
|
-
} catch {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
function capitalizeToken(value) {
|
|
50
|
-
return value.split('-').filter(Boolean).map((token)=>token.charAt(0).toUpperCase() + token.slice(1)).join('-');
|
|
51
|
-
}
|
|
52
|
-
function getExtensionVersion() {
|
|
53
|
-
return process.env.EXTENSION_DEVELOP_VERSION || process.env.EXTENSION_CLI_VERSION || (()=>{
|
|
54
|
-
try {
|
|
55
|
-
return __webpack_require__("./package.json").rE;
|
|
56
|
-
} catch {
|
|
57
|
-
return 'unknown';
|
|
58
|
-
}
|
|
59
|
-
})();
|
|
60
|
-
}
|
|
61
|
-
function browserRunnerDisabled(args) {
|
|
62
|
-
const manifest = readJsonRecord(args.manifestPath);
|
|
63
|
-
const ready = readJsonRecord(args.readyPath);
|
|
64
|
-
const browserLabel = capitalizeToken(String(args.browser || 'unknown'));
|
|
65
|
-
const runId = String(ready?.runId || '').trim();
|
|
66
|
-
const pid = Number.isInteger(ready?.pid) ? String(ready?.pid) : '';
|
|
67
|
-
const runLabel = runId ? `${pintor__rspack_import_1_default().gray(runId)}${pid ? ` · ${pintor__rspack_import_1_default().gray(`PID ${pid}`)}` : ''}` : pid ? pintor__rspack_import_1_default().gray(`PID ${pid}`) : pintor__rspack_import_1_default().gray('n/a');
|
|
68
|
-
const extensionName = String(manifest?.name || 'Extension');
|
|
69
|
-
const extensionVersion = String(manifest?.version || '').trim();
|
|
70
|
-
const extensionLabel = extensionVersion ? `${extensionName} ${extensionVersion}` : extensionName;
|
|
71
|
-
const extensionJsVersion = getExtensionVersion();
|
|
72
|
-
return [
|
|
73
|
-
` 🧩 ${pintor__rspack_import_1_default().brightBlue('Extension.js')} ${pintor__rspack_import_1_default().gray(extensionJsVersion)}`,
|
|
74
|
-
` Browser ${pintor__rspack_import_1_default().gray(args.browserModeLabel || `${browserLabel} (build-only mode)`)}`,
|
|
75
|
-
` Extension ${pintor__rspack_import_1_default().gray(extensionLabel)}`,
|
|
76
|
-
` Run ID ${runLabel}`
|
|
77
|
-
].join('\n');
|
|
78
|
-
}
|
|
79
|
-
function portInUse(requestedPort, newPort) {
|
|
80
|
-
return `Port: Requested port ${pintor__rspack_import_1_default().brightBlue(requestedPort.toString())} is in use; using ${pintor__rspack_import_1_default().brightBlue(newPort.toString())} instead.`;
|
|
81
|
-
}
|
|
82
|
-
function extensionJsRunnerError(error) {
|
|
83
|
-
return `Extension.js Runner Error:\n${pintor__rspack_import_1_default().red(String(error))}`;
|
|
84
|
-
}
|
|
85
|
-
function autoExitModeEnabled(ms) {
|
|
86
|
-
return `Auto-exit enabled. Will exit after ${pintor__rspack_import_1_default().brightBlue(ms.toString())} ms if idle.`;
|
|
87
|
-
}
|
|
88
|
-
function autoExitTriggered(ms) {
|
|
89
|
-
return `Auto-exit triggered after ${pintor__rspack_import_1_default().brightBlue(ms.toString())} ms. Cleaning up...`;
|
|
90
|
-
}
|
|
91
|
-
function autoExitForceKill(ms) {
|
|
92
|
-
return `Force-killing process after ${pintor__rspack_import_1_default().brightBlue(ms.toString())} ms to ensure exit.`;
|
|
93
|
-
}
|
|
94
|
-
function devServerStartTimeout(ms) {
|
|
95
|
-
return [
|
|
96
|
-
`Dev server startup is taking longer than expected (${pintor__rspack_import_1_default().brightBlue(ms.toString())} ms).`,
|
|
97
|
-
"The bundler may have encountered an error before emitting the first build.",
|
|
98
|
-
`If nothing else prints, try setting ${pintor__rspack_import_1_default().brightBlue('EXTENSION_VERBOSE=1')} for more logs.`
|
|
99
|
-
].join('\n');
|
|
100
|
-
}
|
|
101
|
-
function bundlerFatalError(error) {
|
|
102
|
-
const text = error instanceof Error ? error.stack || error.message : String(error);
|
|
103
|
-
return `Build failed to start:\n${pintor__rspack_import_1_default().red(text)}`;
|
|
104
|
-
}
|
|
105
|
-
function bundlerRecompiling() {
|
|
106
|
-
return "Recompiling due to file changes…";
|
|
107
|
-
}
|
|
108
|
-
function noEntrypointsDetected(port) {
|
|
109
|
-
return [
|
|
110
|
-
"No entrypoints or assets were produced by the initial compilation.",
|
|
111
|
-
`The dev server is running on 127.0.0.1:${pintor__rspack_import_1_default().brightBlue(port.toString())}, but nothing is being built.`,
|
|
112
|
-
"Possible causes:",
|
|
113
|
-
" • Empty or missing entry configuration.",
|
|
114
|
-
" • Extension-related plugins are disabled (entries not derived from manifest).",
|
|
115
|
-
" • All sources are ignored or excluded.",
|
|
116
|
-
`Try enabling verbose logs with ${pintor__rspack_import_1_default().brightBlue('EXTENSION_VERBOSE=1')} or review your extension config.`
|
|
117
|
-
].join('\n');
|
|
118
|
-
}
|
|
119
|
-
function spacerLine() {
|
|
120
|
-
return ' ';
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
"./lib/config-loader.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
124
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
125
|
-
cR: ()=>loadCustomConfig,
|
|
126
|
-
eY: ()=>loadCommandConfig,
|
|
127
|
-
xY: ()=>loadBrowserConfig
|
|
128
|
-
});
|
|
129
|
-
var fs__rspack_import_0 = __webpack_require__("fs");
|
|
130
|
-
var path__rspack_import_1 = __webpack_require__("path");
|
|
131
|
-
var os__rspack_import_2 = __webpack_require__("os");
|
|
132
|
-
var vm__rspack_import_3 = __webpack_require__("vm");
|
|
133
|
-
var url__rspack_import_4 = __webpack_require__("url");
|
|
134
|
-
var module__rspack_import_5 = __webpack_require__("module");
|
|
135
|
-
var dotenv__rspack_import_6 = __webpack_require__("dotenv");
|
|
136
|
-
var dotenv__rspack_import_6_default = /*#__PURE__*/ __webpack_require__.n(dotenv__rspack_import_6);
|
|
137
|
-
var _messages__rspack_import_7 = __webpack_require__("./lib/messages.ts");
|
|
138
|
-
function loadCommonJsConfigWithStableDirname(absolutePath) {
|
|
139
|
-
const code = fs__rspack_import_0.readFileSync(absolutePath, 'utf-8');
|
|
140
|
-
const dirname = path__rspack_import_1.dirname(absolutePath);
|
|
141
|
-
const requireFn = (0, module__rspack_import_5.createRequire)(absolutePath);
|
|
142
|
-
const module = {
|
|
143
|
-
exports: {}
|
|
144
|
-
};
|
|
145
|
-
const exports1 = module.exports;
|
|
146
|
-
const wrapped = `(function (exports, require, module, __filename, __dirname) {\n${code}\n})`;
|
|
147
|
-
const fn = new vm__rspack_import_3.Script(wrapped, {
|
|
148
|
-
filename: absolutePath
|
|
149
|
-
}).runInThisContext();
|
|
150
|
-
fn(exports1, requireFn, module, absolutePath, dirname);
|
|
151
|
-
return module.exports?.default || module.exports;
|
|
152
|
-
}
|
|
153
|
-
function findNearestWorkspaceRoot(startDir) {
|
|
154
|
-
let current = path__rspack_import_1.resolve(startDir);
|
|
155
|
-
while(true){
|
|
156
|
-
if (fs__rspack_import_0.existsSync(path__rspack_import_1.join(current, 'pnpm-workspace.yaml'))) return current;
|
|
157
|
-
const parent = path__rspack_import_1.dirname(current);
|
|
158
|
-
if (parent === current) return;
|
|
159
|
-
current = parent;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
function preloadEnvFilesFromDir(envDir, options) {
|
|
163
|
-
let loadedAny = false;
|
|
164
|
-
try {
|
|
165
|
-
const defaultsPath = path__rspack_import_1.join(envDir, '.env.defaults');
|
|
166
|
-
if (fs__rspack_import_0.existsSync(defaultsPath)) {
|
|
167
|
-
dotenv__rspack_import_6_default().config({
|
|
168
|
-
path: defaultsPath,
|
|
169
|
-
override: Boolean(options?.override),
|
|
170
|
-
quiet: true
|
|
171
|
-
});
|
|
172
|
-
loadedAny = true;
|
|
173
|
-
}
|
|
174
|
-
const envCandidates = [
|
|
175
|
-
'.env.development',
|
|
176
|
-
'.env.local',
|
|
177
|
-
'.env'
|
|
178
|
-
];
|
|
179
|
-
for (const filename of envCandidates){
|
|
180
|
-
const filePath = path__rspack_import_1.join(envDir, filename);
|
|
181
|
-
if (fs__rspack_import_0.existsSync(filePath)) {
|
|
182
|
-
dotenv__rspack_import_6_default().config({
|
|
183
|
-
path: filePath,
|
|
184
|
-
override: Boolean(options?.override),
|
|
185
|
-
quiet: true
|
|
186
|
-
});
|
|
187
|
-
loadedAny = true;
|
|
188
|
-
break;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
} catch {}
|
|
192
|
-
return {
|
|
193
|
-
loadedAny,
|
|
194
|
-
envDir
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
function findConfigFile(projectPath) {
|
|
198
|
-
const candidates = [
|
|
199
|
-
path__rspack_import_1.join(projectPath, 'extension.config.js'),
|
|
200
|
-
path__rspack_import_1.join(projectPath, 'extension.config.mjs'),
|
|
201
|
-
path__rspack_import_1.join(projectPath, 'extension.config.cjs')
|
|
202
|
-
];
|
|
203
|
-
return candidates.find((p)=>fs__rspack_import_0.existsSync(p));
|
|
204
|
-
}
|
|
205
|
-
function preloadEnvFiles(projectDir) {
|
|
206
|
-
const local = preloadEnvFilesFromDir(projectDir);
|
|
207
|
-
if (local.loadedAny) return local;
|
|
208
|
-
const workspaceRoot = findNearestWorkspaceRoot(projectDir);
|
|
209
|
-
if (workspaceRoot && workspaceRoot !== projectDir) return preloadEnvFilesFromDir(workspaceRoot);
|
|
210
|
-
return local;
|
|
211
|
-
}
|
|
212
|
-
async function loadConfigFile(configPath) {
|
|
213
|
-
const absolutePath = path__rspack_import_1.resolve(configPath);
|
|
214
|
-
const projectDir = path__rspack_import_1.dirname(absolutePath);
|
|
215
|
-
preloadEnvFiles(projectDir);
|
|
216
|
-
try {
|
|
217
|
-
if (absolutePath.endsWith('.cjs')) {
|
|
218
|
-
const requireFn = (0, module__rspack_import_5.createRequire)(__rslib_import_meta_url__);
|
|
219
|
-
const required = requireFn(absolutePath);
|
|
220
|
-
return required?.default || required;
|
|
221
|
-
}
|
|
222
|
-
let esmImportPath = absolutePath;
|
|
223
|
-
try {
|
|
224
|
-
const originalContent = fs__rspack_import_0.readFileSync(absolutePath, 'utf-8');
|
|
225
|
-
if (originalContent.includes('import.meta.env')) {
|
|
226
|
-
const tmpDir = fs__rspack_import_0.mkdtempSync(path__rspack_import_1.join(os__rspack_import_2.tmpdir(), 'extension-config-esm-'));
|
|
227
|
-
const tmpPath = path__rspack_import_1.join(tmpDir, path__rspack_import_1.basename(absolutePath));
|
|
228
|
-
const envObjectLiteral = JSON.stringify(Object.fromEntries(Object.entries(process.env).map(([k, v])=>[
|
|
229
|
-
k,
|
|
230
|
-
v
|
|
231
|
-
])), null, 0);
|
|
232
|
-
const shimHeader = `const __IMPORT_META_ENV__ = Object.freeze(${envObjectLiteral});\n`;
|
|
233
|
-
const replaced = originalContent.replace(/import\.meta\.env/g, '__IMPORT_META_ENV__');
|
|
234
|
-
fs__rspack_import_0.writeFileSync(tmpPath, `${shimHeader}${replaced}`, 'utf-8');
|
|
235
|
-
esmImportPath = tmpPath;
|
|
236
|
-
}
|
|
237
|
-
} catch {}
|
|
238
|
-
const module = await import((0, url__rspack_import_4.pathToFileURL)(esmImportPath).href);
|
|
239
|
-
return module.default || module;
|
|
240
|
-
} catch (err) {
|
|
241
|
-
const error = err;
|
|
242
|
-
try {
|
|
243
|
-
if (!absolutePath.endsWith('.mjs')) {
|
|
244
|
-
const requireFn = (0, module__rspack_import_5.createRequire)(__rslib_import_meta_url__);
|
|
245
|
-
let required;
|
|
246
|
-
try {
|
|
247
|
-
required = requireFn(absolutePath);
|
|
248
|
-
} catch (requireErr) {
|
|
249
|
-
const message = String(error?.message || '') + ' ' + String(requireErr?.message || '');
|
|
250
|
-
const looksLikeCommonJsInEsm = message.includes('require is not defined in ES module scope') || message.includes('Cannot use import statement outside a module') || message.includes('ERR_REQUIRE_ESM');
|
|
251
|
-
if (looksLikeCommonJsInEsm) try {
|
|
252
|
-
required = loadCommonJsConfigWithStableDirname(absolutePath);
|
|
253
|
-
} catch {
|
|
254
|
-
const tmpDir = fs__rspack_import_0.mkdtempSync(path__rspack_import_1.join(os__rspack_import_2.tmpdir(), 'extension-config-'));
|
|
255
|
-
const tmpCjsPath = path__rspack_import_1.join(tmpDir, path__rspack_import_1.basename(absolutePath, path__rspack_import_1.extname(absolutePath)) + '.cjs');
|
|
256
|
-
fs__rspack_import_0.copyFileSync(absolutePath, tmpCjsPath);
|
|
257
|
-
required = requireFn(tmpCjsPath);
|
|
258
|
-
}
|
|
259
|
-
else throw requireErr;
|
|
260
|
-
}
|
|
261
|
-
return required?.default || required;
|
|
262
|
-
}
|
|
263
|
-
} catch {}
|
|
264
|
-
try {
|
|
265
|
-
const content = fs__rspack_import_0.readFileSync(absolutePath, 'utf-8');
|
|
266
|
-
return JSON.parse(content);
|
|
267
|
-
} catch (jsonErr) {
|
|
268
|
-
throw new Error(`Failed to load config file: ${configPath}\nError: ${error.message || error}`);
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
async function loadCustomConfig(projectPath) {
|
|
273
|
-
const configPath = findConfigFile(projectPath);
|
|
274
|
-
if (configPath) {
|
|
275
|
-
if (await isUsingExperimentalConfig(projectPath)) try {
|
|
276
|
-
const userConfig = await loadConfigFile(configPath);
|
|
277
|
-
if (userConfig && 'function' == typeof userConfig.config) return userConfig.config;
|
|
278
|
-
if (userConfig && userConfig.config && 'object' == typeof userConfig.config) {
|
|
279
|
-
const partial = userConfig.config;
|
|
280
|
-
return (config)=>{
|
|
281
|
-
const requireFn = (0, module__rspack_import_5.createRequire)(__rslib_import_meta_url__);
|
|
282
|
-
const { merge } = requireFn('webpack-merge');
|
|
283
|
-
return merge(config, partial);
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
} catch (err) {
|
|
287
|
-
const error = err;
|
|
288
|
-
console.error(_messages__rspack_import_7.f7(configPath, error));
|
|
289
|
-
throw err;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
return (config)=>config;
|
|
293
|
-
}
|
|
294
|
-
async function loadCommandConfig(projectPath, command) {
|
|
295
|
-
const configPath = findConfigFile(projectPath);
|
|
296
|
-
if (configPath) {
|
|
297
|
-
if (await isUsingExperimentalConfig(projectPath)) try {
|
|
298
|
-
const userConfig = await loadConfigFile(configPath);
|
|
299
|
-
const baseExtensions = userConfig && userConfig.extensions ? {
|
|
300
|
-
extensions: userConfig.extensions
|
|
301
|
-
} : {};
|
|
302
|
-
const baseTranspilePackages = userConfig && Array.isArray(userConfig.transpilePackages) ? {
|
|
303
|
-
transpilePackages: userConfig.transpilePackages
|
|
304
|
-
} : {};
|
|
305
|
-
const perCommand = userConfig && userConfig.commands && userConfig.commands[command] ? userConfig.commands[command] : {};
|
|
306
|
-
return {
|
|
307
|
-
...baseExtensions,
|
|
308
|
-
...baseTranspilePackages,
|
|
309
|
-
...perCommand
|
|
310
|
-
};
|
|
311
|
-
} catch (err) {
|
|
312
|
-
const error = err;
|
|
313
|
-
console.error(_messages__rspack_import_7.f7(configPath, error));
|
|
314
|
-
throw err;
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
return {};
|
|
318
|
-
}
|
|
319
|
-
async function loadBrowserConfig(projectPath, browser = 'chrome') {
|
|
320
|
-
const configPath = findConfigFile(projectPath);
|
|
321
|
-
if (configPath) {
|
|
322
|
-
if (await isUsingExperimentalConfig(projectPath)) try {
|
|
323
|
-
const userConfig = await loadConfigFile(configPath);
|
|
324
|
-
if (userConfig && userConfig.browser) {
|
|
325
|
-
const browsers = userConfig.browser;
|
|
326
|
-
if ('chromium-based' === browser) {
|
|
327
|
-
if (browsers['chromium-based']) return browsers['chromium-based'];
|
|
328
|
-
if (browsers.chromium) return browsers.chromium;
|
|
329
|
-
} else if ('gecko-based' === browser) {
|
|
330
|
-
if (browsers['gecko-based']) return browsers['gecko-based'];
|
|
331
|
-
if (browsers.firefox) return browsers.firefox;
|
|
332
|
-
} else {
|
|
333
|
-
const direct = browsers[browser];
|
|
334
|
-
if (direct) return direct;
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
} catch (err) {
|
|
338
|
-
const error = err;
|
|
339
|
-
console.error(_messages__rspack_import_7.f7(configPath, error));
|
|
340
|
-
throw err;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
return {
|
|
344
|
-
browser: browser || 'chrome'
|
|
345
|
-
};
|
|
346
|
-
}
|
|
347
|
-
let userMessageDelivered = false;
|
|
348
|
-
async function isUsingExperimentalConfig(projectPath) {
|
|
349
|
-
const configPath = findConfigFile(projectPath);
|
|
350
|
-
if (configPath) {
|
|
351
|
-
if (!userMessageDelivered) {
|
|
352
|
-
if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(_messages__rspack_import_7.BX('extension.config.js'));
|
|
353
|
-
userMessageDelivered = true;
|
|
354
|
-
}
|
|
355
|
-
return true;
|
|
356
|
-
}
|
|
357
|
-
return false;
|
|
358
|
-
}
|
|
359
|
-
},
|
|
360
|
-
"./lib/develop-context.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
361
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
362
|
-
G5: ()=>resolveDevelopDistFile,
|
|
363
|
-
He: ()=>resolveDevelopInstallRoot,
|
|
364
|
-
w1: ()=>findExtensionDevelopRoot
|
|
365
|
-
});
|
|
366
|
-
var path__rspack_import_0 = __webpack_require__("path");
|
|
367
|
-
var fs__rspack_import_1 = __webpack_require__("fs");
|
|
368
|
-
var _package_json__rspack_import_2 = __webpack_require__("./package.json");
|
|
369
|
-
var _parse_json_safe__rspack_import_3 = __webpack_require__("./lib/parse-json-safe.ts");
|
|
370
|
-
if (!process.env.EXTENSION_JS_OPTIONAL_DEPS_VERSION) process.env.EXTENSION_JS_OPTIONAL_DEPS_VERSION = _package_json__rspack_import_2.rE;
|
|
371
|
-
function resolveDevelopRootFromDir(dir) {
|
|
372
|
-
try {
|
|
373
|
-
const packageJsonPath = path__rspack_import_0.join(dir, 'package.json');
|
|
374
|
-
if (!fs__rspack_import_1.existsSync(packageJsonPath)) return;
|
|
375
|
-
const pkg = (0, _parse_json_safe__rspack_import_3.p)(fs__rspack_import_1.readFileSync(packageJsonPath, 'utf8'));
|
|
376
|
-
if (pkg?.name === 'extension-develop') return dir;
|
|
377
|
-
} catch {}
|
|
378
|
-
}
|
|
379
|
-
function findDevelopRootFrom(startDir) {
|
|
380
|
-
let currentDir = startDir;
|
|
381
|
-
const maxDepth = 6;
|
|
382
|
-
for(let i = 0; i < maxDepth; i++){
|
|
383
|
-
const root = resolveDevelopRootFromDir(currentDir);
|
|
384
|
-
if (root) return root;
|
|
385
|
-
const parent = path__rspack_import_0.dirname(currentDir);
|
|
386
|
-
if (parent === currentDir) break;
|
|
387
|
-
currentDir = parent;
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
function findExtensionDevelopRoot() {
|
|
391
|
-
const libDir = __dirname;
|
|
392
|
-
const buildDir = path__rspack_import_0.resolve(libDir, '..');
|
|
393
|
-
const packageRoot = path__rspack_import_0.resolve(buildDir, '..');
|
|
394
|
-
const packageJsonPath = path__rspack_import_0.join(packageRoot, 'package.json');
|
|
395
|
-
if (fs__rspack_import_1.existsSync(packageJsonPath)) try {
|
|
396
|
-
const pkg = JSON.parse(fs__rspack_import_1.readFileSync(packageJsonPath, 'utf-8'));
|
|
397
|
-
if ('extension-develop' === pkg.name) return packageRoot;
|
|
398
|
-
} catch {}
|
|
399
|
-
return null;
|
|
400
|
-
}
|
|
401
|
-
function resolveDevelopInstallRoot() {
|
|
402
|
-
const envRoot = process.env.EXTENSION_DEVELOP_ROOT;
|
|
403
|
-
if (envRoot) {
|
|
404
|
-
const resolvedEnvRoot = resolveDevelopRootFromDir(path__rspack_import_0.resolve(envRoot));
|
|
405
|
-
if (resolvedEnvRoot) return resolvedEnvRoot;
|
|
406
|
-
}
|
|
407
|
-
const directRoot = findExtensionDevelopRoot();
|
|
408
|
-
if (directRoot) return directRoot;
|
|
409
|
-
try {
|
|
410
|
-
const candidateRoot = findDevelopRootFrom(__dirname);
|
|
411
|
-
if (candidateRoot) return candidateRoot;
|
|
412
|
-
} catch {}
|
|
413
|
-
try {
|
|
414
|
-
const pkgPath = require.resolve('extension-develop/package.json', {
|
|
415
|
-
paths: [
|
|
416
|
-
__dirname
|
|
417
|
-
]
|
|
418
|
-
});
|
|
419
|
-
return resolveDevelopRootFromDir(path__rspack_import_0.dirname(pkgPath));
|
|
420
|
-
} catch {
|
|
421
|
-
return;
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
function resolveDevelopDistFile(stem) {
|
|
425
|
-
const installRoot = resolveDevelopInstallRoot();
|
|
426
|
-
const distRoot = installRoot ? path__rspack_import_0.join(installRoot, 'dist') : path__rspack_import_0.resolve(__dirname, '..');
|
|
427
|
-
const base = path__rspack_import_0.join(distRoot, stem);
|
|
428
|
-
const candidates = [
|
|
429
|
-
`${base}.js`,
|
|
430
|
-
`${base}.cjs`,
|
|
431
|
-
`${base}.mjs`,
|
|
432
|
-
base
|
|
433
|
-
];
|
|
434
|
-
for (const candidate of candidates)if (fs__rspack_import_1.existsSync(candidate)) {
|
|
435
|
-
if ('1' === process.env.EXTENSION_DEBUG_DEVELOP_ROOT) console.log(`[extjs:develop-root] ${stem} -> ${candidate} (installRoot=${installRoot || '<none>'})`);
|
|
436
|
-
return candidate;
|
|
437
|
-
}
|
|
438
|
-
if ('1' === process.env.EXTENSION_DEBUG_DEVELOP_ROOT) console.log(`[extjs:develop-root] ${stem} -> ${base} (fallback, installRoot=${installRoot || '<none>'})`);
|
|
439
|
-
return base;
|
|
440
|
-
}
|
|
441
|
-
},
|
|
442
|
-
"./lib/extensions-to-load.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
443
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
444
|
-
n: ()=>computeExtensionsToLoad
|
|
445
|
-
});
|
|
446
|
-
var fs__rspack_import_0 = __webpack_require__("fs");
|
|
447
|
-
var path__rspack_import_1 = __webpack_require__("path");
|
|
448
|
-
var _paths__rspack_import_2 = __webpack_require__("./lib/paths.ts");
|
|
449
|
-
function hasNewTabOverride(extensionDir) {
|
|
450
|
-
const manifestPath = path__rspack_import_1.join(extensionDir, 'manifest.json');
|
|
451
|
-
if (!fs__rspack_import_0.existsSync(manifestPath)) return false;
|
|
452
|
-
try {
|
|
453
|
-
const raw = fs__rspack_import_0.readFileSync(manifestPath, 'utf-8');
|
|
454
|
-
const manifest = JSON.parse(raw);
|
|
455
|
-
const newtab = manifest?.chrome_url_overrides?.newtab;
|
|
456
|
-
return 'string' == typeof newtab && newtab.trim().length > 0;
|
|
457
|
-
} catch {
|
|
458
|
-
return false;
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
function resolveBuiltInExtensionForBrowser(input) {
|
|
462
|
-
const engine = (0, _paths__rspack_import_2.gP)(input.browser);
|
|
463
|
-
const packageRelativeCandidates = [
|
|
464
|
-
path__rspack_import_1.join('dist', input.packageName, engine)
|
|
465
|
-
];
|
|
466
|
-
const normalizedBaseDir = path__rspack_import_1.normalize(input.baseDir);
|
|
467
|
-
const parentName = path__rspack_import_1.basename(path__rspack_import_1.dirname(normalizedBaseDir));
|
|
468
|
-
const baseName = path__rspack_import_1.basename(normalizedBaseDir);
|
|
469
|
-
if ('programs' === parentName && 'develop' === baseName) packageRelativeCandidates.push(path__rspack_import_1.join('..', '..', 'extensions', input.packageName, 'dist', engine));
|
|
470
|
-
for (const rel of packageRelativeCandidates){
|
|
471
|
-
const candidate = path__rspack_import_1.resolve(input.baseDir, rel);
|
|
472
|
-
if (fs__rspack_import_0.existsSync(candidate)) return candidate;
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
const RESERVED_BUILT_IN_NAMES = new Set([
|
|
476
|
-
'extension-js-devtools',
|
|
477
|
-
'extension-js-theme'
|
|
478
|
-
]);
|
|
479
|
-
function isReservedBuiltInPath(extensionPath) {
|
|
480
|
-
const base = path__rspack_import_1.basename(path__rspack_import_1.normalize(extensionPath));
|
|
481
|
-
if (RESERVED_BUILT_IN_NAMES.has(base)) return true;
|
|
482
|
-
const segments = path__rspack_import_1.normalize(extensionPath).split(path__rspack_import_1.sep);
|
|
483
|
-
return segments.some((segment)=>RESERVED_BUILT_IN_NAMES.has(segment));
|
|
484
|
-
}
|
|
485
|
-
function dedupeByResolvedPath(paths) {
|
|
486
|
-
const seen = new Set();
|
|
487
|
-
const result = [];
|
|
488
|
-
for (const entry of paths){
|
|
489
|
-
const resolved = path__rspack_import_1.resolve(entry);
|
|
490
|
-
if (!seen.has(resolved)) {
|
|
491
|
-
seen.add(resolved);
|
|
492
|
-
result.push(entry);
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
return result;
|
|
496
|
-
}
|
|
497
|
-
function computeExtensionsToLoad(baseDir, mode, browser, userExtensionOutputPath, extraExtensionDirs = [], userManifestPath) {
|
|
498
|
-
const list = [];
|
|
499
|
-
try {
|
|
500
|
-
const devtoolsForBrowser = resolveBuiltInExtensionForBrowser({
|
|
501
|
-
baseDir,
|
|
502
|
-
packageName: 'extension-js-devtools',
|
|
503
|
-
browser
|
|
504
|
-
});
|
|
505
|
-
const themeForBrowser = resolveBuiltInExtensionForBrowser({
|
|
506
|
-
baseDir,
|
|
507
|
-
packageName: 'extension-js-theme',
|
|
508
|
-
browser
|
|
509
|
-
});
|
|
510
|
-
const userHasNewTabOverride = hasNewTabOverride(userExtensionOutputPath) || ('string' == typeof userManifestPath ? hasNewTabOverride(path__rspack_import_1.dirname(userManifestPath)) : false);
|
|
511
|
-
const devtoolsHasNewTabOverride = devtoolsForBrowser ? hasNewTabOverride(devtoolsForBrowser) : false;
|
|
512
|
-
const shouldSkipDevtoolsForNtpConflict = userHasNewTabOverride && devtoolsHasNewTabOverride;
|
|
513
|
-
if (devtoolsForBrowser && !shouldSkipDevtoolsForNtpConflict) list.push(devtoolsForBrowser);
|
|
514
|
-
if (themeForBrowser) list.push(themeForBrowser);
|
|
515
|
-
} catch {}
|
|
516
|
-
for (const p of extraExtensionDirs)if (!isReservedBuiltInPath(p)) list.push(p);
|
|
517
|
-
list.push(userExtensionOutputPath);
|
|
518
|
-
return dedupeByResolvedPath(list);
|
|
519
|
-
}
|
|
520
|
-
},
|
|
521
|
-
"./lib/has-dependency.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
522
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
523
|
-
w: ()=>hasDependency
|
|
524
|
-
});
|
|
525
|
-
var fs__rspack_import_0 = __webpack_require__("fs");
|
|
526
|
-
var path__rspack_import_1 = __webpack_require__("path");
|
|
527
|
-
function hasDependency(projectPath, packageName) {
|
|
528
|
-
const manifestPath = path__rspack_import_1.join(projectPath, 'package.json');
|
|
529
|
-
if (!fs__rspack_import_0.existsSync(manifestPath)) return false;
|
|
530
|
-
try {
|
|
531
|
-
const raw = fs__rspack_import_0.readFileSync(manifestPath, 'utf8');
|
|
532
|
-
const pkg = JSON.parse(raw || '{}');
|
|
533
|
-
const sections = [
|
|
534
|
-
pkg.dependencies,
|
|
535
|
-
pkg.devDependencies,
|
|
536
|
-
pkg.optionalDependencies,
|
|
537
|
-
pkg.peerDependencies
|
|
538
|
-
];
|
|
539
|
-
return sections.some((s)=>s && 'object' == typeof s && packageName in s);
|
|
540
|
-
} catch {
|
|
541
|
-
return false;
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
},
|
|
545
|
-
"./lib/messages.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
546
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
547
|
-
$3: ()=>buildCommandFailed,
|
|
548
|
-
AC: ()=>debugOutputPath,
|
|
549
|
-
BT: ()=>treeWithSourceFiles,
|
|
550
|
-
BX: ()=>isUsingExperimentalConfig,
|
|
551
|
-
Cf: ()=>buildSuccess,
|
|
552
|
-
F$: ()=>downloadingProjectPath,
|
|
553
|
-
F_: ()=>packagingDistributionFiles,
|
|
554
|
-
GW: ()=>failedToDownloadOrExtractZIPFileError,
|
|
555
|
-
H3: ()=>managedDependencyConflict,
|
|
556
|
-
I: ()=>buildWebpack,
|
|
557
|
-
IV: ()=>packagingSourceFiles,
|
|
558
|
-
SG: ()=>debugDirs,
|
|
559
|
-
TL: ()=>authorInstallNotice,
|
|
560
|
-
Ud: ()=>downloadingText,
|
|
561
|
-
Ut: ()=>treeWithDistFilesbrowser,
|
|
562
|
-
V_: ()=>previewing,
|
|
563
|
-
W4: ()=>creatingProjectPath,
|
|
564
|
-
W6: ()=>treeWithSourceAndDistFiles,
|
|
565
|
-
_A: ()=>debugBrowser,
|
|
566
|
-
aw: ()=>debugContextPath,
|
|
567
|
-
ax: ()=>downloadedProjectFolderNotFound,
|
|
568
|
-
dx: ()=>manifestNotFoundError,
|
|
569
|
-
f7: ()=>configLoadingError,
|
|
570
|
-
fm: ()=>buildSuccessWithWarnings,
|
|
571
|
-
gC: ()=>unpackagingExtension,
|
|
572
|
-
jM: ()=>debugExtensionsToLoad,
|
|
573
|
-
jV: ()=>debugPreviewOutput,
|
|
574
|
-
k4: ()=>previewSkippedNoBrowser,
|
|
575
|
-
ng: ()=>writingTypeDefinitions,
|
|
576
|
-
tQ: ()=>fetchingProjectPath,
|
|
577
|
-
tc: ()=>invalidRemoteZip,
|
|
578
|
-
v_: ()=>writingTypeDefinitionsError,
|
|
579
|
-
wh: ()=>buildWarningsDetails,
|
|
580
|
-
yp: ()=>noCompanionExtensionsResolved,
|
|
581
|
-
zM: ()=>unpackagedSuccessfully
|
|
582
|
-
});
|
|
583
|
-
var fs__rspack_import_0 = __webpack_require__("fs");
|
|
584
|
-
var path__rspack_import_1 = __webpack_require__("path");
|
|
585
|
-
var pintor__rspack_import_2 = __webpack_require__("pintor");
|
|
586
|
-
var pintor__rspack_import_2_default = /*#__PURE__*/ __webpack_require__.n(pintor__rspack_import_2);
|
|
587
|
-
__webpack_require__("./package.json");
|
|
588
|
-
const fmt = {
|
|
589
|
-
heading: (title)=>pintor__rspack_import_2_default().underline(pintor__rspack_import_2_default().blue(title)),
|
|
590
|
-
label: (key)=>pintor__rspack_import_2_default().gray(key.toUpperCase()),
|
|
591
|
-
val: (value)=>pintor__rspack_import_2_default().underline(value),
|
|
592
|
-
code: (value)=>pintor__rspack_import_2_default().blue(value),
|
|
593
|
-
bullet: (value)=>`- ${value}`,
|
|
594
|
-
block (title, rows) {
|
|
595
|
-
const head = fmt.heading(title);
|
|
596
|
-
const body = rows.map(([key, value])=>`${fmt.label(key)} ${value}`).join('\n');
|
|
597
|
-
return `${head}\n${body}`;
|
|
598
|
-
},
|
|
599
|
-
truncate (input, max = 800) {
|
|
600
|
-
const s = (()=>{
|
|
601
|
-
try {
|
|
602
|
-
return 'string' == typeof input ? input : JSON.stringify(input);
|
|
603
|
-
} catch {
|
|
604
|
-
return String(input);
|
|
605
|
-
}
|
|
606
|
-
})();
|
|
607
|
-
return s.length > max ? s.slice(0, max) + '…' : s;
|
|
608
|
-
}
|
|
609
|
-
};
|
|
610
|
-
function getLoggingPrefix(type) {
|
|
611
|
-
const isAuthor = 'true' === process.env.EXTENSION_AUTHOR_MODE;
|
|
612
|
-
if (isAuthor) {
|
|
613
|
-
const base = 'error' === type ? 'ERROR Author says' : '⏵⏵⏵ Author says';
|
|
614
|
-
return pintor__rspack_import_2_default().brightMagenta(base);
|
|
615
|
-
}
|
|
616
|
-
if ('error' === type) return pintor__rspack_import_2_default().red('ERROR');
|
|
617
|
-
if ('warn' === type) return pintor__rspack_import_2_default().brightYellow('⏵⏵⏵');
|
|
618
|
-
if ('info' === type) return pintor__rspack_import_2_default().gray('⏵⏵⏵');
|
|
619
|
-
return pintor__rspack_import_2_default().green('⏵⏵⏵');
|
|
620
|
-
}
|
|
621
|
-
function isPathLike(input) {
|
|
622
|
-
return input.includes('/') || input.includes('\\') || path__rspack_import_1.isAbsolute(input);
|
|
623
|
-
}
|
|
624
|
-
function manifestNotFoundError(manifestPath) {
|
|
625
|
-
return `${getLoggingPrefix('error')} Manifest file not found.\n${pintor__rspack_import_2_default().red('Ensure the path to your extension exists and try again.')}\n${pintor__rspack_import_2_default().red('NOT FOUND')}\n${pintor__rspack_import_2_default().gray('PATH')} ${pintor__rspack_import_2_default().underline(manifestPath)}`;
|
|
626
|
-
}
|
|
627
|
-
function previewing(browser) {
|
|
628
|
-
return `${getLoggingPrefix('info')} Previewing the extension on ${capitalizedBrowserName(browser)}...`;
|
|
629
|
-
}
|
|
630
|
-
function previewSkippedNoBrowser(browser) {
|
|
631
|
-
return `${getLoggingPrefix('info')} Skipping browser launch for ${capitalizedBrowserName(browser)} (no-browser).`;
|
|
632
|
-
}
|
|
633
|
-
function authorInstallNotice(target) {
|
|
634
|
-
return `${getLoggingPrefix('warn')} Author mode: installing ${target}.`;
|
|
635
|
-
}
|
|
636
|
-
function buildWebpack(projectDir, stats, browser) {
|
|
637
|
-
const statsJson = stats?.toJson({
|
|
638
|
-
all: false,
|
|
639
|
-
assets: true,
|
|
640
|
-
time: true
|
|
641
|
-
});
|
|
642
|
-
const outputPath = 'string' == typeof stats?.compilation?.outputOptions?.path ? stats.compilation.outputOptions.path : '';
|
|
643
|
-
const manifestPath = outputPath ? path__rspack_import_1.join(outputPath, 'manifest.json') : path__rspack_import_1.join(projectDir, 'manifest.json');
|
|
644
|
-
const manifest = JSON.parse(fs__rspack_import_0.readFileSync(manifestPath, 'utf8'));
|
|
645
|
-
const assets = statsJson?.assets;
|
|
646
|
-
const heading = `${getLoggingPrefix('info')} Building ${pintor__rspack_import_2_default().blue(manifest.name)} extension using ${capitalizedBrowserName(browser)} defaults...\n`;
|
|
647
|
-
const buildTime = `\nBuild completed in ${((statsJson?.time || 0) / 1000).toFixed(2)} seconds.\n`;
|
|
648
|
-
const buildTarget = `Build Target: ${pintor__rspack_import_2_default().gray(capitalizedBrowserName(browser))}\n`;
|
|
649
|
-
const buildStatus = `Build Status: ${stats?.hasErrors() ? pintor__rspack_import_2_default().red('Failed') : pintor__rspack_import_2_default().green('Success')}\n`;
|
|
650
|
-
const version = `\nVersion: ${pintor__rspack_import_2_default().gray(manifest.version)}\n`;
|
|
651
|
-
const size = `Size: ${pintor__rspack_import_2_default().gray(getAssetsSize(assets))}\n`;
|
|
652
|
-
let output = '';
|
|
653
|
-
output += heading;
|
|
654
|
-
output += getAssetsTree(assets);
|
|
655
|
-
output += version;
|
|
656
|
-
output += size;
|
|
657
|
-
output += buildTarget;
|
|
658
|
-
output += buildStatus;
|
|
659
|
-
output += buildTime;
|
|
660
|
-
return output;
|
|
661
|
-
}
|
|
662
|
-
function buildSuccess() {
|
|
663
|
-
return `${getLoggingPrefix('success')} Build succeeded with no warnings. Your extension is ${pintor__rspack_import_2_default().green('ready for deployment')}.`;
|
|
664
|
-
}
|
|
665
|
-
function getWarningMessage(warning) {
|
|
666
|
-
if (!warning) return '';
|
|
667
|
-
if ('string' == typeof warning) return warning.trim();
|
|
668
|
-
const candidates = [
|
|
669
|
-
warning.message,
|
|
670
|
-
warning.details,
|
|
671
|
-
warning.reason,
|
|
672
|
-
warning.description
|
|
673
|
-
];
|
|
674
|
-
for (const candidate of candidates)if ('string' == typeof candidate && candidate.trim()) return candidate.trim();
|
|
675
|
-
return '';
|
|
676
|
-
}
|
|
677
|
-
function getWarningSource(warning) {
|
|
678
|
-
if (!warning || 'string' == typeof warning) return 'bundler';
|
|
679
|
-
const candidates = [
|
|
680
|
-
warning.name,
|
|
681
|
-
warning.moduleName,
|
|
682
|
-
warning.moduleIdentifier,
|
|
683
|
-
warning.originName,
|
|
684
|
-
warning.pluginName
|
|
685
|
-
];
|
|
686
|
-
for (const candidate of candidates)if ('string' == typeof candidate && candidate.trim()) return candidate.trim();
|
|
687
|
-
return 'bundler';
|
|
688
|
-
}
|
|
689
|
-
function getWarningArtifact(warning) {
|
|
690
|
-
if (!warning || 'string' == typeof warning) return '';
|
|
691
|
-
const candidates = [
|
|
692
|
-
warning.file,
|
|
693
|
-
warning.chunkName,
|
|
694
|
-
warning.moduleName
|
|
695
|
-
];
|
|
696
|
-
for (const candidate of candidates)if ('string' == typeof candidate && candidate.trim()) return candidate.trim();
|
|
697
|
-
return '';
|
|
698
|
-
}
|
|
699
|
-
function classifyWarning(message, source) {
|
|
700
|
-
const haystack = `${message} ${source}`.toLowerCase();
|
|
701
|
-
if (haystack.includes('performance') || haystack.includes('asset size') || haystack.includes('entrypoint size') || haystack.includes('exceeds the recommended size') || haystack.includes('hints')) return 'Performance';
|
|
702
|
-
if (haystack.includes('deprecat') || haystack.includes('[dep_') || haystack.includes('legacy')) return 'Deprecation';
|
|
703
|
-
if (haystack.includes('invalid') || haystack.includes('unknown option') || haystack.includes('configuration') || haystack.includes('schema')) return 'Configuration';
|
|
704
|
-
if (haystack.includes('manifest') || haystack.includes('browser') || haystack.includes('target')) return 'Compatibility';
|
|
705
|
-
if (haystack.includes('runtime') || haystack.includes('will fail') || haystack.includes('cannot resolve') || haystack.includes('service_worker')) return 'Runtime-risk';
|
|
706
|
-
return 'Warning';
|
|
707
|
-
}
|
|
708
|
-
function suggestedHintForWarning(category) {
|
|
709
|
-
if ('Performance' === category) return 'Inspect the largest startup bundles and split optional code paths.';
|
|
710
|
-
if ('Deprecation' === category) return 'Move to the supported API or plugin path before the next update.';
|
|
711
|
-
if ('Configuration' === category) return 'Review extension and bundler config keys, then remove or rename invalid options.';
|
|
712
|
-
if ('Compatibility' === category) return 'Verify browser target and manifest compatibility for this build.';
|
|
713
|
-
if ('Runtime-risk' === category) return 'Address this before release; it may fail or degrade at runtime.';
|
|
714
|
-
return 'Re-run with EXTENSION_VERBOSE=1 to inspect full warning details.';
|
|
715
|
-
}
|
|
716
|
-
function buildSuccessWithWarnings(warningCount) {
|
|
717
|
-
return `${getLoggingPrefix('warn')} Build succeeded with ${warningCount} warning(s). Your extension is ${pintor__rspack_import_2_default().green('ready for deployment')}.`;
|
|
718
|
-
}
|
|
719
|
-
function buildWarningsDetails(warnings) {
|
|
720
|
-
if (!Array.isArray(warnings) || 0 === warnings.length) return '';
|
|
721
|
-
const blocks = [];
|
|
722
|
-
warnings.forEach((warning, index)=>{
|
|
723
|
-
const message = getWarningMessage(warning);
|
|
724
|
-
const source = getWarningSource(warning);
|
|
725
|
-
const artifact = getWarningArtifact(warning);
|
|
726
|
-
const category = classifyWarning(message, source);
|
|
727
|
-
const hint = suggestedHintForWarning(category);
|
|
728
|
-
if (!message) return void blocks.push(`${getLoggingPrefix('warn')} Warning ${index + 1}: details were suppressed by tool output.\n${formatWarningLabelLine('Source', pintor__rspack_import_2_default().gray(source))}\n${formatWarningLabelLine('Hint', 'Re-run with EXTENSION_VERBOSE=1 to inspect full warning messages.')}`);
|
|
729
|
-
const performanceWarning = parsePerformanceWarning(warning, source, artifact);
|
|
730
|
-
if (performanceWarning) return void blocks.push(performanceWarning);
|
|
731
|
-
const oneLine = message.replace(/\s+/g, ' ').trim();
|
|
732
|
-
const artifactSuffix = artifact ? ` ${pintor__rspack_import_2_default().gray(`(${artifact})`)}` : '';
|
|
733
|
-
blocks.push(`${getLoggingPrefix('warn')} ${category}: ${oneLine}${artifactSuffix}\n${formatWarningLabelLine('Source', pintor__rspack_import_2_default().gray(source))}\n${formatWarningLabelLine('Hint', hint)}`);
|
|
734
|
-
});
|
|
735
|
-
return blocks.join('\n\n');
|
|
736
|
-
}
|
|
737
|
-
function fetchingProjectPath(owner, project) {
|
|
738
|
-
return fmt.block('Fetching project', [
|
|
739
|
-
[
|
|
740
|
-
'URL',
|
|
741
|
-
fmt.val(`https://github.com/${owner}/${project}`)
|
|
742
|
-
]
|
|
743
|
-
]);
|
|
744
|
-
}
|
|
745
|
-
function downloadingProjectPath(projectName) {
|
|
746
|
-
const formatted = isPathLike(projectName) ? pintor__rspack_import_2_default().underline(projectName) : pintor__rspack_import_2_default().yellow(projectName);
|
|
747
|
-
return `${getLoggingPrefix('info')} Downloading ${formatted}...`;
|
|
748
|
-
}
|
|
749
|
-
function creatingProjectPath(projectPath) {
|
|
750
|
-
return `${getLoggingPrefix('info')} Creating a new browser extension...\n${pintor__rspack_import_2_default().gray('PATH')} ${pintor__rspack_import_2_default().underline(projectPath)}`;
|
|
751
|
-
}
|
|
752
|
-
function downloadedProjectFolderNotFound(cwd, candidates) {
|
|
753
|
-
return `${getLoggingPrefix('error')} Downloaded project folder not found.\n${pintor__rspack_import_2_default().gray('PATH')} ${pintor__rspack_import_2_default().underline(cwd)}\n${pintor__rspack_import_2_default().gray('Tried')} ${pintor__rspack_import_2_default().underline(candidates.join(', '))}`;
|
|
754
|
-
}
|
|
755
|
-
function packagingSourceFiles(zipPath) {
|
|
756
|
-
return `${getLoggingPrefix('info')} Packaging source files. Files in ${pintor__rspack_import_2_default().yellow('.gitignore')} will be excluded...\n${pintor__rspack_import_2_default().gray('PATH')} ${pintor__rspack_import_2_default().underline(zipPath)}.`;
|
|
757
|
-
}
|
|
758
|
-
function packagingDistributionFiles(zipPath) {
|
|
759
|
-
return `${getLoggingPrefix('info')} Packaging extension distribution files...\n${pintor__rspack_import_2_default().gray('PATH')} ${pintor__rspack_import_2_default().underline(zipPath)}`;
|
|
760
|
-
}
|
|
761
|
-
function treeWithSourceAndDistFiles(browser, name, sourceZip, destZip) {
|
|
762
|
-
return `📦 Package name: ${pintor__rspack_import_2_default().blue(`${name}`)}, Target Browser: ${capitalizedBrowserName(browser)}\n ${pintor__rspack_import_2_default().gray('└─')} ${pintor__rspack_import_2_default().underline(`${sourceZip}`)} ${pintor__rspack_import_2_default().gray('(source)')}\n ${pintor__rspack_import_2_default().gray('└─')} ${pintor__rspack_import_2_default().underline(`${destZip}`)} ${pintor__rspack_import_2_default().gray('(distribution)')}`;
|
|
763
|
-
}
|
|
764
|
-
function treeWithDistFilesbrowser(name, ext, browser, zipPath) {
|
|
765
|
-
return `📦 Package name: ${pintor__rspack_import_2_default().blue(`${name}.${ext}`)}, Target Browser: ${capitalizedBrowserName(browser)}\n ${pintor__rspack_import_2_default().gray('└─')} ${pintor__rspack_import_2_default().underline(`${zipPath}`)} ${pintor__rspack_import_2_default().gray('(distribution)')}`;
|
|
766
|
-
}
|
|
767
|
-
function treeWithSourceFiles(name, ext, browser, zipPath) {
|
|
768
|
-
return `📦 Package name: ${pintor__rspack_import_2_default().blue(`${name}-source.${ext}`)}, Target Browser: ${capitalizedBrowserName(browser)}\n ${pintor__rspack_import_2_default().gray('└─')} ${pintor__rspack_import_2_default().underline(`${zipPath}`)} ${pintor__rspack_import_2_default().gray('(source)')}`;
|
|
769
|
-
}
|
|
770
|
-
function writingTypeDefinitions(manifest) {
|
|
771
|
-
return `${getLoggingPrefix('info')} Writing type definitions for ${pintor__rspack_import_2_default().blue(manifest.name || '')}...`;
|
|
772
|
-
}
|
|
773
|
-
function writingTypeDefinitionsError(error) {
|
|
774
|
-
return `${getLoggingPrefix('error')} Failed to write the extension type definition.\n${pintor__rspack_import_2_default().red(error)}`;
|
|
775
|
-
}
|
|
776
|
-
function downloadingText(url) {
|
|
777
|
-
return fmt.block('Downloading extension', [
|
|
778
|
-
[
|
|
779
|
-
'URL',
|
|
780
|
-
fmt.val(url)
|
|
781
|
-
]
|
|
782
|
-
]);
|
|
783
|
-
}
|
|
784
|
-
function unpackagingExtension(zipFilePath) {
|
|
785
|
-
return `${getLoggingPrefix('info')} Unpackaging browser extension...\n${pintor__rspack_import_2_default().gray('PATH')} ${pintor__rspack_import_2_default().underline(zipFilePath)}`;
|
|
786
|
-
}
|
|
787
|
-
function unpackagedSuccessfully() {
|
|
788
|
-
return `${getLoggingPrefix('info')} Browser extension unpackaged ${pintor__rspack_import_2_default().green('successfully')}.`;
|
|
789
|
-
}
|
|
790
|
-
function failedToDownloadOrExtractZIPFileError(error) {
|
|
791
|
-
return `${getLoggingPrefix('error')} Failed to download or extract ZIP file.\n${pintor__rspack_import_2_default().red(error)}`;
|
|
792
|
-
}
|
|
793
|
-
function invalidRemoteZip(url, contentType) {
|
|
794
|
-
return `${getLoggingPrefix('error')} Remote URL does not appear to be a ZIP archive.\n${pintor__rspack_import_2_default().gray('URL')} ${pintor__rspack_import_2_default().underline(url)}\n${pintor__rspack_import_2_default().gray('Content-Type')} ${pintor__rspack_import_2_default().underline(contentType || 'unknown')}`;
|
|
795
|
-
}
|
|
796
|
-
function capitalizedBrowserName(browser) {
|
|
797
|
-
const b = String(browser || '');
|
|
798
|
-
const cap = b.charAt(0).toUpperCase() + b.slice(1);
|
|
799
|
-
return pintor__rspack_import_2_default().yellow(`${cap}`);
|
|
800
|
-
}
|
|
801
|
-
function getFileSize(fileSizeInBytes) {
|
|
802
|
-
return `${(fileSizeInBytes / 1024).toFixed(2)}KB`;
|
|
803
|
-
}
|
|
804
|
-
function getAssetsSize(assets) {
|
|
805
|
-
let totalSize = 0;
|
|
806
|
-
assets?.forEach((asset)=>{
|
|
807
|
-
totalSize += asset.size;
|
|
808
|
-
});
|
|
809
|
-
return getFileSize(totalSize);
|
|
810
|
-
}
|
|
811
|
-
function printTree(node, prefix = '') {
|
|
812
|
-
let output = '';
|
|
813
|
-
Object.keys(node).forEach((key, index, array)=>{
|
|
814
|
-
const isLast = index === array.length - 1;
|
|
815
|
-
const connector = isLast ? '└─' : '├─';
|
|
816
|
-
const sizeInKB = node[key].size ? ` (${getFileSize(node[key].size)})` : '';
|
|
817
|
-
output += `${pintor__rspack_import_2_default().gray(prefix)}${pintor__rspack_import_2_default().gray(connector)} ${key}${pintor__rspack_import_2_default().gray(sizeInKB)}\n`;
|
|
818
|
-
if ('object' == typeof node[key] && !node[key].size) output += printTree(node[key], `${prefix}${isLast ? ' ' : pintor__rspack_import_2_default().gray('│ ')}`);
|
|
819
|
-
});
|
|
820
|
-
return output;
|
|
821
|
-
}
|
|
822
|
-
function getAssetsTree(assets) {
|
|
823
|
-
const assetTree = {};
|
|
824
|
-
assets?.forEach((asset)=>{
|
|
825
|
-
const paths = asset.name.split('/');
|
|
826
|
-
let currentLevel = assetTree;
|
|
827
|
-
paths.forEach((part, index)=>{
|
|
828
|
-
if (!currentLevel[part]) currentLevel[part] = {};
|
|
829
|
-
if (index === paths.length - 1) currentLevel[part] = {
|
|
830
|
-
size: asset.size
|
|
831
|
-
};
|
|
832
|
-
else currentLevel = currentLevel[part];
|
|
833
|
-
});
|
|
834
|
-
});
|
|
835
|
-
return `.\n${printTree(assetTree)}`;
|
|
836
|
-
}
|
|
837
|
-
function formatWarningLabelLine(label, value) {
|
|
838
|
-
return `${pintor__rspack_import_2_default().gray('│')} ${pintor__rspack_import_2_default().gray(`${label}:`)} ${value}`;
|
|
839
|
-
}
|
|
840
|
-
function parsePerformanceWarning(warning, source, _artifact) {
|
|
841
|
-
const normalized = getWarningBody(warning).replace(/\r/g, '');
|
|
842
|
-
const lower = normalized.toLowerCase();
|
|
843
|
-
const threshold = normalized.match(/\(([\d.]+\s(?:KiB|MiB|GiB|KB|MB|GB))\)/)?.[1] || '';
|
|
844
|
-
if (lower.includes('asset size limit')) return formatPerformanceWarningBlock({
|
|
845
|
-
title: 'asset size limit exceeded',
|
|
846
|
-
threshold,
|
|
847
|
-
impact: 'Large emitted files can increase package size and slow extension startup.',
|
|
848
|
-
source,
|
|
849
|
-
hint: 'Inspect the largest startup bundles and split optional code paths.'
|
|
850
|
-
});
|
|
851
|
-
if (lower.includes('entrypoint size limit')) return formatPerformanceWarningBlock({
|
|
852
|
-
title: 'entrypoint size limit exceeded',
|
|
853
|
-
threshold,
|
|
854
|
-
impact: 'Startup entrypoints are heavier than recommended.',
|
|
855
|
-
source,
|
|
856
|
-
hint: 'Keep startup entrypoints thin and defer non-critical code.'
|
|
857
|
-
});
|
|
858
|
-
}
|
|
859
|
-
function formatPerformanceWarningBlock(options) {
|
|
860
|
-
const lines = [
|
|
861
|
-
`${getLoggingPrefix('warn')} Performance: ${options.title}`
|
|
862
|
-
];
|
|
863
|
-
if (options.threshold) lines.push(formatWarningLabelLine('Threshold', options.threshold));
|
|
864
|
-
lines.push(formatWarningLabelLine('Impact', options.impact));
|
|
865
|
-
lines.push(pintor__rspack_import_2_default().gray('│'));
|
|
866
|
-
lines.push(formatWarningLabelLine('Source', pintor__rspack_import_2_default().gray(options.source)));
|
|
867
|
-
lines.push(formatWarningLabelLine('Hint', options.hint));
|
|
868
|
-
return lines.join('\n');
|
|
869
|
-
}
|
|
870
|
-
function getWarningBody(warning) {
|
|
871
|
-
if (!warning) return '';
|
|
872
|
-
if ('string' == typeof warning) return warning;
|
|
873
|
-
return [
|
|
874
|
-
warning.message,
|
|
875
|
-
warning.details,
|
|
876
|
-
warning.reason,
|
|
877
|
-
warning.description
|
|
878
|
-
].filter((value)=>'string' == typeof value && value.trim().length > 0).join('\n');
|
|
879
|
-
}
|
|
880
|
-
function isUsingExperimentalConfig(integration) {
|
|
881
|
-
return `${getLoggingPrefix('info')} Using ${pintor__rspack_import_2_default().yellow(integration)}.`;
|
|
882
|
-
}
|
|
883
|
-
function debugDirs(manifestDir, packageJsonDir) {
|
|
884
|
-
return `${getLoggingPrefix('info')} Directories\n${pintor__rspack_import_2_default().gray('MANIFEST_DIR')} ${pintor__rspack_import_2_default().underline(manifestDir)}\n${pintor__rspack_import_2_default().gray('PACKAGE_JSON_DIR')} ${pintor__rspack_import_2_default().underline(packageJsonDir)}`;
|
|
885
|
-
}
|
|
886
|
-
function debugBrowser(browser, chromiumBinary, geckoBinary) {
|
|
887
|
-
return `${getLoggingPrefix('info')} Browser Target\n${pintor__rspack_import_2_default().gray('BROWSER')} ${pintor__rspack_import_2_default().yellow(String(browser))}\n${pintor__rspack_import_2_default().gray('CHROMIUM_BINARY')} ${pintor__rspack_import_2_default().underline(String(chromiumBinary || 'auto'))}\n${pintor__rspack_import_2_default().gray('GECKO_BINARY')} ${pintor__rspack_import_2_default().underline(String(geckoBinary || 'auto'))}`;
|
|
888
|
-
}
|
|
889
|
-
function debugOutputPath(pathValue) {
|
|
890
|
-
return `${getLoggingPrefix('info')} Output Path\n${pintor__rspack_import_2_default().gray('PATH')} ${pintor__rspack_import_2_default().underline(pathValue)}`;
|
|
891
|
-
}
|
|
892
|
-
function debugPreviewOutput(outputPath, distPath) {
|
|
893
|
-
return `${getLoggingPrefix('info')} Preview Output\n${pintor__rspack_import_2_default().gray('OUTPUT')} ${pintor__rspack_import_2_default().underline(outputPath)}\n${pintor__rspack_import_2_default().gray('DIST')} ${pintor__rspack_import_2_default().underline(distPath)}`;
|
|
894
|
-
}
|
|
895
|
-
function debugContextPath(packageJsonDir) {
|
|
896
|
-
return `${getLoggingPrefix('info')} Context\n${pintor__rspack_import_2_default().gray('CONTEXT')} ${pintor__rspack_import_2_default().underline(packageJsonDir)}`;
|
|
897
|
-
}
|
|
898
|
-
function debugExtensionsToLoad(extensions) {
|
|
899
|
-
const header = `${getLoggingPrefix('info')} Extensions To Load (${extensions.length})`;
|
|
900
|
-
const list = extensions.map((e)=>`- ${pintor__rspack_import_2_default().underline(e)}`).join('\n');
|
|
901
|
-
return `${header}\n${list}`;
|
|
902
|
-
}
|
|
903
|
-
function noCompanionExtensionsResolved() {
|
|
904
|
-
return `${getLoggingPrefix('warn')} No companion extensions resolved from ${pintor__rspack_import_2_default().underline('extensions')} config.\n${pintor__rspack_import_2_default().gray('Ensure each companion extension is an unpacked extension directory containing a manifest.json (e.g., ./extensions/<name>/manifest.json).')}`;
|
|
905
|
-
}
|
|
906
|
-
function configLoadingError(configPath, error) {
|
|
907
|
-
return `${pintor__rspack_import_2_default().red('ERROR')} ${pintor__rspack_import_2_default().brightBlue('config load failed')}\n${fmt.label('PATH')} ${fmt.val(configPath)}\n` + pintor__rspack_import_2_default().red(fmt.truncate(error, 1200));
|
|
908
|
-
}
|
|
909
|
-
function buildCommandFailed(error) {
|
|
910
|
-
const message = (()=>{
|
|
911
|
-
if (error instanceof Error && error.message) return error.message;
|
|
912
|
-
return String(error || 'Unknown error');
|
|
913
|
-
})();
|
|
914
|
-
return `${getLoggingPrefix('error')} Build failed.\n${pintor__rspack_import_2_default().red(fmt.truncate(message, 1200))}`;
|
|
915
|
-
}
|
|
916
|
-
function managedDependencyConflict(duplicates, userPackageJsonPath) {
|
|
917
|
-
const list = duplicates.map((d)=>`- ${pintor__rspack_import_2_default().yellow(d)}`).join('\n');
|
|
918
|
-
return `${getLoggingPrefix('error')} Your project declares dependencies that are managed by ${pintor__rspack_import_2_default().blue('Extension.js')} and referenced in ${pintor__rspack_import_2_default().underline('extension.config.js')}\n${pintor__rspack_import_2_default().red('This can cause version conflicts and break the development/build process.')}\n\n${pintor__rspack_import_2_default().gray('Managed dependencies (remove these from your package.json):')}\n${list}\n\n${pintor__rspack_import_2_default().gray('PATH')} ${pintor__rspack_import_2_default().underline(userPackageJsonPath)}\nIf you need a different version, open an issue so we can consider bundling it safely.\nOperation aborted.`;
|
|
919
|
-
}
|
|
920
|
-
},
|
|
921
|
-
"./lib/optional-deps-resolver.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
922
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
923
|
-
Ci: ()=>ensureOptionalContractModuleLoaded,
|
|
924
|
-
k3: ()=>loadOptionalContractModuleWithoutInstall,
|
|
925
|
-
Eh: ()=>resolveOptionalContractPackageWithoutInstall,
|
|
926
|
-
nR: ()=>resolveOptionalDependencySync,
|
|
927
|
-
xr: ()=>ensureOptionalContractPackageResolved
|
|
928
|
-
});
|
|
929
|
-
var external_fs_ = __webpack_require__("fs");
|
|
930
|
-
var external_path_ = __webpack_require__("path");
|
|
931
|
-
var external_module_ = __webpack_require__("module");
|
|
932
|
-
var develop_context = __webpack_require__("./lib/develop-context.ts");
|
|
933
|
-
function installRootRules(packageIds) {
|
|
934
|
-
return packageIds.map((packageId)=>({
|
|
935
|
-
type: 'install-root',
|
|
936
|
-
packageId
|
|
937
|
-
}));
|
|
938
|
-
}
|
|
939
|
-
function defineContract(contract) {
|
|
940
|
-
return contract;
|
|
941
|
-
}
|
|
942
|
-
const OPTIONAL_DEPENDENCY_CONTRACTS = {
|
|
943
|
-
typescript: defineContract({
|
|
944
|
-
id: "typescript",
|
|
945
|
-
integration: 'TypeScript',
|
|
946
|
-
installPackages: [
|
|
947
|
-
"typescript@5.9.3"
|
|
948
|
-
],
|
|
949
|
-
verificationRules: installRootRules([
|
|
950
|
-
"typescript"
|
|
951
|
-
])
|
|
952
|
-
}),
|
|
953
|
-
'react-refresh': defineContract({
|
|
954
|
-
id: 'react-refresh',
|
|
955
|
-
integration: 'React',
|
|
956
|
-
installPackages: [
|
|
957
|
-
'react-refresh@0.18.0',
|
|
958
|
-
'@rspack/plugin-react-refresh@1.6.0'
|
|
959
|
-
],
|
|
960
|
-
verificationRules: [
|
|
961
|
-
...installRootRules([
|
|
962
|
-
'react-refresh',
|
|
963
|
-
'@rspack/plugin-react-refresh'
|
|
964
|
-
]),
|
|
965
|
-
{
|
|
966
|
-
type: 'module-context-resolve',
|
|
967
|
-
fromPackage: '@rspack/plugin-react-refresh',
|
|
968
|
-
packageId: 'react-refresh'
|
|
969
|
-
}
|
|
970
|
-
]
|
|
971
|
-
}),
|
|
972
|
-
'preact-refresh': defineContract({
|
|
973
|
-
id: 'preact-refresh',
|
|
974
|
-
integration: 'Preact',
|
|
975
|
-
installPackages: [
|
|
976
|
-
'@prefresh/core@1.5.9',
|
|
977
|
-
'@prefresh/utils@1.2.1',
|
|
978
|
-
'@rspack/plugin-preact-refresh@1.1.5',
|
|
979
|
-
'preact@10.27.2'
|
|
980
|
-
],
|
|
981
|
-
verificationRules: [
|
|
982
|
-
...installRootRules([
|
|
983
|
-
'@prefresh/core',
|
|
984
|
-
'@prefresh/utils',
|
|
985
|
-
'@rspack/plugin-preact-refresh',
|
|
986
|
-
'preact'
|
|
987
|
-
]),
|
|
988
|
-
{
|
|
989
|
-
type: 'module-context-resolve',
|
|
990
|
-
fromPackage: '@rspack/plugin-preact-refresh',
|
|
991
|
-
packageId: '@prefresh/core'
|
|
992
|
-
},
|
|
993
|
-
{
|
|
994
|
-
type: 'module-context-resolve',
|
|
995
|
-
fromPackage: '@rspack/plugin-preact-refresh',
|
|
996
|
-
packageId: '@prefresh/utils'
|
|
997
|
-
},
|
|
998
|
-
{
|
|
999
|
-
type: 'module-context-resolve',
|
|
1000
|
-
fromPackage: '@rspack/plugin-preact-refresh',
|
|
1001
|
-
packageId: 'preact'
|
|
1002
|
-
}
|
|
1003
|
-
]
|
|
1004
|
-
}),
|
|
1005
|
-
vue: defineContract({
|
|
1006
|
-
id: 'vue',
|
|
1007
|
-
integration: 'Vue',
|
|
1008
|
-
installPackages: [
|
|
1009
|
-
'vue-loader@17.4.2',
|
|
1010
|
-
'@vue/compiler-sfc@3.5.26',
|
|
1011
|
-
'vue@3.5.26'
|
|
1012
|
-
],
|
|
1013
|
-
verificationRules: [
|
|
1014
|
-
...installRootRules([
|
|
1015
|
-
'vue-loader',
|
|
1016
|
-
'@vue/compiler-sfc',
|
|
1017
|
-
'vue'
|
|
1018
|
-
]),
|
|
1019
|
-
{
|
|
1020
|
-
type: 'module-context-load',
|
|
1021
|
-
fromPackage: 'vue-loader',
|
|
1022
|
-
packageId: '@vue/compiler-sfc'
|
|
1023
|
-
}
|
|
1024
|
-
]
|
|
1025
|
-
}),
|
|
1026
|
-
svelte: defineContract({
|
|
1027
|
-
id: 'svelte',
|
|
1028
|
-
integration: 'Svelte',
|
|
1029
|
-
installPackages: [
|
|
1030
|
-
"typescript@5.9.3",
|
|
1031
|
-
'svelte-loader@3.2.4'
|
|
1032
|
-
],
|
|
1033
|
-
verificationRules: installRootRules([
|
|
1034
|
-
"typescript",
|
|
1035
|
-
'svelte-loader'
|
|
1036
|
-
])
|
|
1037
|
-
}),
|
|
1038
|
-
less: defineContract({
|
|
1039
|
-
id: 'less',
|
|
1040
|
-
integration: 'LESS',
|
|
1041
|
-
installPackages: [
|
|
1042
|
-
'less@4.5.1',
|
|
1043
|
-
'less-loader@12.3.0'
|
|
1044
|
-
],
|
|
1045
|
-
verificationRules: installRootRules([
|
|
1046
|
-
'less',
|
|
1047
|
-
'less-loader'
|
|
1048
|
-
])
|
|
1049
|
-
}),
|
|
1050
|
-
postcss: defineContract({
|
|
1051
|
-
id: 'postcss',
|
|
1052
|
-
integration: 'PostCSS',
|
|
1053
|
-
installPackages: [
|
|
1054
|
-
'postcss@8.5.6',
|
|
1055
|
-
'postcss-loader@8.2.0'
|
|
1056
|
-
],
|
|
1057
|
-
verificationRules: installRootRules([
|
|
1058
|
-
'postcss',
|
|
1059
|
-
'postcss-loader'
|
|
1060
|
-
])
|
|
1061
|
-
}),
|
|
1062
|
-
sass: defineContract({
|
|
1063
|
-
id: 'sass',
|
|
1064
|
-
integration: 'SASS',
|
|
1065
|
-
installPackages: [
|
|
1066
|
-
'postcss-loader@8.2.0',
|
|
1067
|
-
'postcss-scss@4.0.9',
|
|
1068
|
-
'postcss-preset-env@11.1.1',
|
|
1069
|
-
'sass-loader@16.0.6'
|
|
1070
|
-
],
|
|
1071
|
-
verificationRules: installRootRules([
|
|
1072
|
-
'postcss-loader',
|
|
1073
|
-
'postcss-scss',
|
|
1074
|
-
'postcss-preset-env',
|
|
1075
|
-
'sass-loader'
|
|
1076
|
-
])
|
|
1077
|
-
})
|
|
1078
|
-
};
|
|
1079
|
-
function getOptionalDependencyContract(contractId) {
|
|
1080
|
-
const contract = OPTIONAL_DEPENDENCY_CONTRACTS[contractId];
|
|
1081
|
-
if (!contract) throw new Error(`Unknown optional dependency contract: ${contractId}`);
|
|
1082
|
-
return contract;
|
|
1083
|
-
}
|
|
1084
|
-
function toInstallRootContract(integration, contractId, installDependencies, verifyPackageIds) {
|
|
1085
|
-
return {
|
|
1086
|
-
id: contractId,
|
|
1087
|
-
integration,
|
|
1088
|
-
installPackages: installDependencies,
|
|
1089
|
-
verificationRules: verifyPackageIds.map((packageId)=>({
|
|
1090
|
-
type: 'install-root',
|
|
1091
|
-
packageId
|
|
1092
|
-
}))
|
|
1093
|
-
};
|
|
1094
|
-
}
|
|
1095
|
-
function getVerificationContract(input) {
|
|
1096
|
-
if (input.contract) return input.contract;
|
|
1097
|
-
const installDependencies = input.installDependencies || [
|
|
1098
|
-
input.dependencyId
|
|
1099
|
-
];
|
|
1100
|
-
const verifyPackageIds = input.verifyPackageIds || installDependencies;
|
|
1101
|
-
return toInstallRootContract(input.integration, input.integration, installDependencies, verifyPackageIds);
|
|
1102
|
-
}
|
|
1103
|
-
function getResolutionBases(projectPath) {
|
|
1104
|
-
const extensionRoot = (0, develop_context.He)();
|
|
1105
|
-
const bases = [
|
|
1106
|
-
projectPath,
|
|
1107
|
-
extensionRoot || void 0,
|
|
1108
|
-
process.cwd()
|
|
1109
|
-
].filter(Boolean);
|
|
1110
|
-
if (extensionRoot && extensionRoot.includes('.pnpm')) bases.push(external_path_.join(extensionRoot, '..', '..'));
|
|
1111
|
-
return Array.from(new Set(bases));
|
|
1112
|
-
}
|
|
1113
|
-
function optional_deps_resolver_packageJsonPath(basePath) {
|
|
1114
|
-
return external_path_.join(basePath, 'package.json');
|
|
1115
|
-
}
|
|
1116
|
-
function tryResolveWithBase(dependencyId, basePath) {
|
|
1117
|
-
try {
|
|
1118
|
-
const req = (0, external_module_.createRequire)(optional_deps_resolver_packageJsonPath(basePath));
|
|
1119
|
-
return req.resolve(dependencyId);
|
|
1120
|
-
} catch {
|
|
1121
|
-
return;
|
|
1122
|
-
}
|
|
1123
|
-
}
|
|
1124
|
-
function resolveDependency(dependencyId, projectPath) {
|
|
1125
|
-
const bases = getResolutionBases(projectPath);
|
|
1126
|
-
for (const basePath of bases){
|
|
1127
|
-
const resolvedPath = tryResolveWithBase(dependencyId, basePath);
|
|
1128
|
-
if (resolvedPath) return {
|
|
1129
|
-
resolvedPath,
|
|
1130
|
-
basePath
|
|
1131
|
-
};
|
|
1132
|
-
}
|
|
1133
|
-
try {
|
|
1134
|
-
const resolvedPath = require.resolve(dependencyId, {
|
|
1135
|
-
paths: bases
|
|
1136
|
-
});
|
|
1137
|
-
return {
|
|
1138
|
-
resolvedPath,
|
|
1139
|
-
basePath: projectPath
|
|
1140
|
-
};
|
|
1141
|
-
} catch {
|
|
1142
|
-
return;
|
|
1143
|
-
}
|
|
1144
|
-
}
|
|
1145
|
-
function resolveFromKnownLocations(dependencyId, projectPath) {
|
|
1146
|
-
const direct = resolveDependency(dependencyId, projectPath)?.resolvedPath;
|
|
1147
|
-
if (direct) return direct;
|
|
1148
|
-
if (declaresDependency(projectPath, dependencyId)) return projectPath;
|
|
1149
|
-
}
|
|
1150
|
-
function declaresDependency(projectPath, dependencyId) {
|
|
1151
|
-
try {
|
|
1152
|
-
const packageJsonPath = external_path_.join(projectPath, 'package.json');
|
|
1153
|
-
if (!external_fs_.existsSync(packageJsonPath)) return false;
|
|
1154
|
-
const pkg = JSON.parse(external_fs_.readFileSync(packageJsonPath, 'utf8'));
|
|
1155
|
-
const sections = [
|
|
1156
|
-
pkg.dependencies,
|
|
1157
|
-
pkg.devDependencies,
|
|
1158
|
-
pkg.optionalDependencies,
|
|
1159
|
-
pkg.peerDependencies
|
|
1160
|
-
];
|
|
1161
|
-
return sections.some((section)=>section && 'object' == typeof section && dependencyId in section);
|
|
1162
|
-
} catch {
|
|
1163
|
-
return false;
|
|
1164
|
-
}
|
|
1165
|
-
}
|
|
1166
|
-
function dedupeFailures(packageIds) {
|
|
1167
|
-
return Array.from(new Set(packageIds));
|
|
1168
|
-
}
|
|
1169
|
-
function resolveRealPathSafe(targetPath) {
|
|
1170
|
-
try {
|
|
1171
|
-
return external_fs_.realpathSync(targetPath);
|
|
1172
|
-
} catch {
|
|
1173
|
-
return external_path_.resolve(targetPath);
|
|
1174
|
-
}
|
|
1175
|
-
}
|
|
1176
|
-
function findOwningPackageDir(resolvedPath) {
|
|
1177
|
-
let currentPath = external_path_.dirname(resolvedPath);
|
|
1178
|
-
for(let depth = 0; depth < 8; depth++){
|
|
1179
|
-
const packageJson = external_path_.join(currentPath, 'package.json');
|
|
1180
|
-
if (external_fs_.existsSync(packageJson)) return currentPath;
|
|
1181
|
-
const parent = external_path_.dirname(currentPath);
|
|
1182
|
-
if (parent === currentPath) break;
|
|
1183
|
-
currentPath = parent;
|
|
1184
|
-
}
|
|
1185
|
-
}
|
|
1186
|
-
function isSameInstalledPackage(resolvedPath, expectedInstalledPath) {
|
|
1187
|
-
const resolvedPackageDir = findOwningPackageDir(resolvedPath);
|
|
1188
|
-
const expectedPackageDir = findOwningPackageDir(expectedInstalledPath);
|
|
1189
|
-
if (resolvedPackageDir && expectedPackageDir) return resolveRealPathSafe(resolvedPackageDir) === resolveRealPathSafe(expectedPackageDir);
|
|
1190
|
-
return resolveRealPathSafe(resolvedPath) === resolveRealPathSafe(expectedInstalledPath);
|
|
1191
|
-
}
|
|
1192
|
-
function evaluateModuleContextRule(rule, fromPackagePath, options) {
|
|
1193
|
-
try {
|
|
1194
|
-
const req = (0, external_module_.createRequire)(fromPackagePath);
|
|
1195
|
-
const resolvedPeer = req.resolve(rule.packageId);
|
|
1196
|
-
if (options?.expectedInstalledPath && !isSameInstalledPackage(resolvedPeer, options.expectedInstalledPath)) return rule.packageId;
|
|
1197
|
-
if ('module-context-load' === rule.type) req(rule.packageId);
|
|
1198
|
-
return;
|
|
1199
|
-
} catch {
|
|
1200
|
-
return rule.packageId;
|
|
1201
|
-
}
|
|
1202
|
-
}
|
|
1203
|
-
function getContractVerificationFailuresFromKnownLocations(contract, projectPath) {
|
|
1204
|
-
const resolvedByPackage = new Map();
|
|
1205
|
-
const resolvePackage = (packageId)=>{
|
|
1206
|
-
if (!resolvedByPackage.has(packageId)) resolvedByPackage.set(packageId, resolveFromKnownLocations(packageId, projectPath));
|
|
1207
|
-
return resolvedByPackage.get(packageId);
|
|
1208
|
-
};
|
|
1209
|
-
const failures = [];
|
|
1210
|
-
for (const rule of contract.verificationRules){
|
|
1211
|
-
if ('install-root' === rule.type) {
|
|
1212
|
-
if (!resolvePackage(rule.packageId)) failures.push(rule.packageId);
|
|
1213
|
-
continue;
|
|
1214
|
-
}
|
|
1215
|
-
const fromPackagePath = resolvePackage(rule.fromPackage);
|
|
1216
|
-
if (!fromPackagePath) {
|
|
1217
|
-
failures.push(rule.fromPackage);
|
|
1218
|
-
continue;
|
|
1219
|
-
}
|
|
1220
|
-
const failure = evaluateModuleContextRule(rule, fromPackagePath);
|
|
1221
|
-
if (!(failure && declaresDependency(projectPath, failure))) {
|
|
1222
|
-
if (failure) failures.push(failure);
|
|
1223
|
-
}
|
|
1224
|
-
}
|
|
1225
|
-
return dedupeFailures(failures);
|
|
1226
|
-
}
|
|
1227
|
-
function buildDiagnostics(input) {
|
|
1228
|
-
const bases = getResolutionBases(input.projectPath);
|
|
1229
|
-
return {
|
|
1230
|
-
contractId: input.contract?.id || null,
|
|
1231
|
-
integration: input.integration,
|
|
1232
|
-
dependencyId: input.dependencyId,
|
|
1233
|
-
projectPath: input.projectPath,
|
|
1234
|
-
installDependencies: input.installDependencies,
|
|
1235
|
-
verifyPackageIds: input.verifyPackageIds,
|
|
1236
|
-
resolutionBases: bases
|
|
1237
|
-
};
|
|
1238
|
-
}
|
|
1239
|
-
function resolveOptionalDependencySync(dependencyId, projectPath) {
|
|
1240
|
-
const resolved = resolveFromKnownLocations(dependencyId, projectPath);
|
|
1241
|
-
if (resolved) return resolved;
|
|
1242
|
-
const bases = getResolutionBases(projectPath);
|
|
1243
|
-
throw new Error(`[CSS] ${dependencyId} could not be resolved. Searched: ${bases.join(', ')}`);
|
|
1244
|
-
}
|
|
1245
|
-
async function ensureOptionalPackageResolved(input) {
|
|
1246
|
-
const contract = getVerificationContract(input);
|
|
1247
|
-
const missing = getContractVerificationFailuresFromKnownLocations(contract, input.projectPath);
|
|
1248
|
-
const resolved = resolveFromKnownLocations(input.dependencyId, input.projectPath);
|
|
1249
|
-
if (resolved && 0 === missing.length) return resolved;
|
|
1250
|
-
const diagnostics = buildDiagnostics({
|
|
1251
|
-
integration: input.integration,
|
|
1252
|
-
dependencyId: input.dependencyId,
|
|
1253
|
-
projectPath: input.projectPath,
|
|
1254
|
-
contract,
|
|
1255
|
-
installDependencies: contract.installPackages,
|
|
1256
|
-
verifyPackageIds: contract.installPackages
|
|
1257
|
-
});
|
|
1258
|
-
throw new Error(`[${input.integration}] ${input.dependencyId} could not be resolved.` + (missing.length > 0 ? ` Missing or invalid packages: ${missing.join(', ')}.` : '') + '\n' + JSON.stringify({
|
|
1259
|
-
...diagnostics,
|
|
1260
|
-
missing
|
|
1261
|
-
}, null, 2));
|
|
1262
|
-
}
|
|
1263
|
-
function resolveOptionalPackageWithoutInstall(input) {
|
|
1264
|
-
const contract = getVerificationContract(input);
|
|
1265
|
-
const resolved = resolveFromKnownLocations(input.dependencyId, input.projectPath);
|
|
1266
|
-
const missingPeerDeps = getContractVerificationFailuresFromKnownLocations(contract, input.projectPath);
|
|
1267
|
-
if (resolved && 0 === missingPeerDeps.length) return resolved;
|
|
1268
|
-
const diagnostics = buildDiagnostics({
|
|
1269
|
-
integration: input.integration,
|
|
1270
|
-
dependencyId: input.dependencyId,
|
|
1271
|
-
projectPath: input.projectPath,
|
|
1272
|
-
contract,
|
|
1273
|
-
installDependencies: contract.installPackages,
|
|
1274
|
-
verifyPackageIds: contract.installPackages
|
|
1275
|
-
});
|
|
1276
|
-
throw new Error(`[${input.integration}] ${input.dependencyId} could not be resolved from the project or extension-develop.\n` + JSON.stringify({
|
|
1277
|
-
...diagnostics,
|
|
1278
|
-
missingPeerDeps,
|
|
1279
|
-
expectation: 'Run optional dependency preflight or reinstall extension-develop.'
|
|
1280
|
-
}, null, 2));
|
|
1281
|
-
}
|
|
1282
|
-
async function ensureOptionalModuleLoaded(input) {
|
|
1283
|
-
const resolvedPath = await ensureOptionalPackageResolved(input);
|
|
1284
|
-
const candidateBases = getResolutionBases(input.projectPath);
|
|
1285
|
-
let loaded;
|
|
1286
|
-
let didLoad = false;
|
|
1287
|
-
let lastLoadError;
|
|
1288
|
-
for (const basePath of candidateBases){
|
|
1289
|
-
const req = (0, external_module_.createRequire)(optional_deps_resolver_packageJsonPath(basePath));
|
|
1290
|
-
const candidateModuleIds = [
|
|
1291
|
-
input.dependencyId,
|
|
1292
|
-
resolvedPath
|
|
1293
|
-
];
|
|
1294
|
-
for (const candidateModuleId of candidateModuleIds)try {
|
|
1295
|
-
loaded = req(candidateModuleId);
|
|
1296
|
-
didLoad = true;
|
|
1297
|
-
break;
|
|
1298
|
-
} catch (error) {
|
|
1299
|
-
lastLoadError = error;
|
|
1300
|
-
}
|
|
1301
|
-
if (didLoad) break;
|
|
1302
|
-
}
|
|
1303
|
-
if (!didLoad) try {
|
|
1304
|
-
loaded = require(resolvedPath);
|
|
1305
|
-
didLoad = true;
|
|
1306
|
-
} catch (directRequireError) {
|
|
1307
|
-
lastLoadError = directRequireError;
|
|
1308
|
-
}
|
|
1309
|
-
if (!didLoad) {
|
|
1310
|
-
const diagnostics = {
|
|
1311
|
-
...buildDiagnostics({
|
|
1312
|
-
integration: input.integration,
|
|
1313
|
-
dependencyId: input.dependencyId,
|
|
1314
|
-
projectPath: input.projectPath,
|
|
1315
|
-
installDependencies: input.installDependencies || [
|
|
1316
|
-
input.dependencyId
|
|
1317
|
-
],
|
|
1318
|
-
verifyPackageIds: input.verifyPackageIds || input.installDependencies || [
|
|
1319
|
-
input.dependencyId
|
|
1320
|
-
]
|
|
1321
|
-
}),
|
|
1322
|
-
resolvedPath,
|
|
1323
|
-
loadError: lastLoadError instanceof Error ? lastLoadError.message : String(lastLoadError)
|
|
1324
|
-
};
|
|
1325
|
-
throw new Error(`[${input.integration}] ${input.dependencyId} could not be loaded after it resolved.\n` + JSON.stringify(diagnostics, null, 2));
|
|
1326
|
-
}
|
|
1327
|
-
return input.moduleAdapter ? input.moduleAdapter(loaded) : loaded;
|
|
1328
|
-
}
|
|
1329
|
-
function loadOptionalModuleWithoutInstall(input) {
|
|
1330
|
-
const resolvedPath = resolveOptionalPackageWithoutInstall(input);
|
|
1331
|
-
const candidateBases = getResolutionBases(input.projectPath);
|
|
1332
|
-
let loaded;
|
|
1333
|
-
let didLoad = false;
|
|
1334
|
-
let lastLoadError;
|
|
1335
|
-
for (const basePath of candidateBases){
|
|
1336
|
-
const req = (0, external_module_.createRequire)(optional_deps_resolver_packageJsonPath(basePath));
|
|
1337
|
-
const candidateModuleIds = [
|
|
1338
|
-
input.dependencyId,
|
|
1339
|
-
resolvedPath
|
|
1340
|
-
];
|
|
1341
|
-
for (const candidateModuleId of candidateModuleIds)try {
|
|
1342
|
-
loaded = req(candidateModuleId);
|
|
1343
|
-
didLoad = true;
|
|
1344
|
-
break;
|
|
1345
|
-
} catch (error) {
|
|
1346
|
-
lastLoadError = error;
|
|
1347
|
-
}
|
|
1348
|
-
if (didLoad) break;
|
|
1349
|
-
}
|
|
1350
|
-
if (!didLoad) try {
|
|
1351
|
-
loaded = require(resolvedPath);
|
|
1352
|
-
didLoad = true;
|
|
1353
|
-
} catch (directRequireError) {
|
|
1354
|
-
lastLoadError = directRequireError;
|
|
1355
|
-
}
|
|
1356
|
-
if (!didLoad) throw new Error(`[${input.integration}] ${input.dependencyId} could not be loaded after resolving.\n` + JSON.stringify({
|
|
1357
|
-
resolvedPath,
|
|
1358
|
-
loadError: lastLoadError instanceof Error ? lastLoadError.message : String(lastLoadError)
|
|
1359
|
-
}, null, 2));
|
|
1360
|
-
return input.moduleAdapter ? input.moduleAdapter(loaded) : loaded;
|
|
1361
|
-
}
|
|
1362
|
-
async function ensureOptionalContractPackageResolved(input) {
|
|
1363
|
-
const contract = getOptionalDependencyContract(input.contractId);
|
|
1364
|
-
return ensureOptionalPackageResolved({
|
|
1365
|
-
integration: contract.integration,
|
|
1366
|
-
projectPath: input.projectPath,
|
|
1367
|
-
dependencyId: input.dependencyId,
|
|
1368
|
-
contract
|
|
1369
|
-
});
|
|
1370
|
-
}
|
|
1371
|
-
async function ensureOptionalContractModuleLoaded(input) {
|
|
1372
|
-
const contract = getOptionalDependencyContract(input.contractId);
|
|
1373
|
-
return ensureOptionalModuleLoaded({
|
|
1374
|
-
integration: contract.integration,
|
|
1375
|
-
projectPath: input.projectPath,
|
|
1376
|
-
dependencyId: input.dependencyId,
|
|
1377
|
-
contract,
|
|
1378
|
-
moduleAdapter: input.moduleAdapter
|
|
1379
|
-
});
|
|
1380
|
-
}
|
|
1381
|
-
function resolveOptionalContractPackageWithoutInstall(input) {
|
|
1382
|
-
const contract = getOptionalDependencyContract(input.contractId);
|
|
1383
|
-
return resolveOptionalPackageWithoutInstall({
|
|
1384
|
-
integration: contract.integration,
|
|
1385
|
-
projectPath: input.projectPath,
|
|
1386
|
-
dependencyId: input.dependencyId,
|
|
1387
|
-
contract
|
|
1388
|
-
});
|
|
1389
|
-
}
|
|
1390
|
-
function loadOptionalContractModuleWithoutInstall(input) {
|
|
1391
|
-
const contract = getOptionalDependencyContract(input.contractId);
|
|
1392
|
-
return loadOptionalModuleWithoutInstall({
|
|
1393
|
-
integration: contract.integration,
|
|
1394
|
-
projectPath: input.projectPath,
|
|
1395
|
-
dependencyId: input.dependencyId,
|
|
1396
|
-
contract,
|
|
1397
|
-
moduleAdapter: input.moduleAdapter
|
|
1398
|
-
});
|
|
1399
|
-
}
|
|
1400
|
-
},
|
|
1401
|
-
"./lib/parse-json-safe.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
1402
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
1403
|
-
p: ()=>parseJsonSafe
|
|
1404
|
-
});
|
|
1405
|
-
function parseJsonSafe(text) {
|
|
1406
|
-
const raw = 'string' == typeof text ? text : String(text || '');
|
|
1407
|
-
const s = raw && 0xfeff === raw.charCodeAt(0) ? raw.slice(1) : raw;
|
|
1408
|
-
return JSON.parse(s || '{}');
|
|
1409
|
-
}
|
|
1410
|
-
},
|
|
1411
|
-
"./lib/paths.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
1412
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
1413
|
-
Bi: ()=>needsInstall,
|
|
1414
|
-
G6: ()=>asAbsolute,
|
|
1415
|
-
YN: ()=>normalizeBrowser,
|
|
1416
|
-
fu: ()=>getDirs,
|
|
1417
|
-
gP: ()=>devtoolsEngineFor,
|
|
1418
|
-
q4: ()=>getDistPath,
|
|
1419
|
-
u2: ()=>computePreviewOutputPath
|
|
1420
|
-
});
|
|
1421
|
-
var fs__rspack_import_0 = __webpack_require__("fs");
|
|
1422
|
-
var path__rspack_import_1 = __webpack_require__("path");
|
|
1423
|
-
function asAbsolute(p) {
|
|
1424
|
-
return path__rspack_import_1.isAbsolute(p) ? p : path__rspack_import_1.resolve(p);
|
|
1425
|
-
}
|
|
1426
|
-
function getDirs(struct) {
|
|
1427
|
-
const manifestDir = asAbsolute(path__rspack_import_1.dirname(struct.manifestPath));
|
|
1428
|
-
const packageJsonDir = asAbsolute(struct.packageJsonPath ? path__rspack_import_1.dirname(struct.packageJsonPath) : manifestDir);
|
|
1429
|
-
return {
|
|
1430
|
-
manifestDir,
|
|
1431
|
-
packageJsonDir
|
|
1432
|
-
};
|
|
1433
|
-
}
|
|
1434
|
-
function getNodeModulesDir(packageJsonDir) {
|
|
1435
|
-
return asAbsolute(path__rspack_import_1.join(packageJsonDir, 'node_modules'));
|
|
1436
|
-
}
|
|
1437
|
-
function needsInstall(packageJsonDir) {
|
|
1438
|
-
const nm = getNodeModulesDir(packageJsonDir);
|
|
1439
|
-
const packageJsonPath = path__rspack_import_1.join(packageJsonDir, 'package.json');
|
|
1440
|
-
if (!fs__rspack_import_0.existsSync(packageJsonPath)) return false;
|
|
1441
|
-
try {
|
|
1442
|
-
const raw = fs__rspack_import_0.readFileSync(packageJsonPath, 'utf-8');
|
|
1443
|
-
const packageJson = JSON.parse(raw);
|
|
1444
|
-
const depsCount = Object.keys(packageJson?.dependencies || {}).length;
|
|
1445
|
-
const devDepsCount = Object.keys(packageJson?.devDependencies || {}).length;
|
|
1446
|
-
if (depsCount + devDepsCount === 0) return false;
|
|
1447
|
-
if (!fs__rspack_import_0.existsSync(nm)) return true;
|
|
1448
|
-
const deps = Object.keys(packageJson?.dependencies || {});
|
|
1449
|
-
const devDeps = Object.keys(packageJson?.devDependencies || {});
|
|
1450
|
-
if (fs__rspack_import_0.existsSync(path__rspack_import_1.join(nm, '.pnpm'))) return false;
|
|
1451
|
-
if (fs__rspack_import_0.existsSync(path__rspack_import_1.join(nm, '.modules.yaml'))) return false;
|
|
1452
|
-
const hasInstalledDep = [
|
|
1453
|
-
...deps,
|
|
1454
|
-
...devDeps
|
|
1455
|
-
].some((dep)=>fs__rspack_import_0.existsSync(path__rspack_import_1.join(nm, dep)));
|
|
1456
|
-
return !hasInstalledDep;
|
|
1457
|
-
} catch {
|
|
1458
|
-
return true;
|
|
1459
|
-
}
|
|
1460
|
-
}
|
|
1461
|
-
function normalizeBrowser(browser, chromiumBinary, geckoBinary) {
|
|
1462
|
-
const requested = String(browser || '');
|
|
1463
|
-
if (chromiumBinary) {
|
|
1464
|
-
if (!requested || 'chromium-based' === requested) return 'chromium-based';
|
|
1465
|
-
if ('chromium' === requested) return 'chromium';
|
|
1466
|
-
if ('edge' === requested) return 'edge';
|
|
1467
|
-
if ('chrome' === requested) return 'chrome';
|
|
1468
|
-
}
|
|
1469
|
-
if (geckoBinary) {
|
|
1470
|
-
if (!requested || 'gecko-based' === requested || 'firefox-based' === requested) return 'gecko-based';
|
|
1471
|
-
if ('firefox' === requested) return 'firefox';
|
|
1472
|
-
}
|
|
1473
|
-
switch(requested){
|
|
1474
|
-
case 'chrome':
|
|
1475
|
-
return 'chrome';
|
|
1476
|
-
case 'edge':
|
|
1477
|
-
return 'edge';
|
|
1478
|
-
case 'chromium':
|
|
1479
|
-
return 'chromium';
|
|
1480
|
-
case 'chromium-based':
|
|
1481
|
-
return 'chromium-based';
|
|
1482
|
-
case 'firefox':
|
|
1483
|
-
return 'firefox';
|
|
1484
|
-
case 'gecko-based':
|
|
1485
|
-
case 'firefox-based':
|
|
1486
|
-
return 'gecko-based';
|
|
1487
|
-
default:
|
|
1488
|
-
return browser || 'chrome';
|
|
1489
|
-
}
|
|
1490
|
-
}
|
|
1491
|
-
function getDistPath(packageJsonDir, browser) {
|
|
1492
|
-
return asAbsolute(path__rspack_import_1.join(packageJsonDir, 'dist', browser));
|
|
1493
|
-
}
|
|
1494
|
-
function computePreviewOutputPath(struct, browser, explicitOutputPath) {
|
|
1495
|
-
const { manifestDir, packageJsonDir } = getDirs(struct);
|
|
1496
|
-
if (explicitOutputPath) return asAbsolute(explicitOutputPath);
|
|
1497
|
-
if (struct.packageJsonPath) {
|
|
1498
|
-
const distDir = getDistPath(packageJsonDir, browser);
|
|
1499
|
-
try {
|
|
1500
|
-
if (fs__rspack_import_0.existsSync(path__rspack_import_1.join(distDir, 'manifest.json'))) return distDir;
|
|
1501
|
-
} catch {}
|
|
1502
|
-
}
|
|
1503
|
-
return manifestDir;
|
|
1504
|
-
}
|
|
1505
|
-
function devtoolsEngineFor(browser) {
|
|
1506
|
-
switch(browser){
|
|
1507
|
-
case 'chrome':
|
|
1508
|
-
return 'chrome';
|
|
1509
|
-
case 'edge':
|
|
1510
|
-
return 'edge';
|
|
1511
|
-
case 'chromium':
|
|
1512
|
-
case 'chromium-based':
|
|
1513
|
-
return 'chromium';
|
|
1514
|
-
case 'firefox':
|
|
1515
|
-
case 'gecko-based':
|
|
1516
|
-
return 'firefox';
|
|
1517
|
-
default:
|
|
1518
|
-
return 'chrome';
|
|
1519
|
-
}
|
|
1520
|
-
}
|
|
1521
|
-
},
|
|
1522
|
-
"./lib/sanitize.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
1523
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
1524
|
-
a: ()=>sanitize
|
|
1525
|
-
});
|
|
1526
|
-
function sanitize(obj) {
|
|
1527
|
-
return Object.fromEntries(Object.entries(obj || {}).filter(([, value])=>void 0 !== value));
|
|
1528
|
-
}
|
|
1529
|
-
},
|
|
1530
|
-
"./module.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
1531
|
-
__webpack_require__.r(__webpack_exports__);
|
|
1532
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
1533
|
-
BuildEmitter: ()=>BuildEmitter,
|
|
1534
|
-
extensionDev: ()=>extensionDev,
|
|
1535
|
-
extensionPreview: ()=>extensionPreview,
|
|
1536
|
-
extensionBuild: ()=>extensionBuild
|
|
1537
|
-
});
|
|
1538
|
-
var external_fs_ = __webpack_require__("fs");
|
|
1539
|
-
function getBuildSummary(browser, info) {
|
|
1540
|
-
const assets = info?.assets || [];
|
|
1541
|
-
return {
|
|
1542
|
-
browser,
|
|
1543
|
-
total_assets: assets.length,
|
|
1544
|
-
total_bytes: assets.reduce((n, a)=>n + (a.size || 0), 0),
|
|
1545
|
-
largest_asset_bytes: assets.reduce((m, a)=>Math.max(m, a.size || 0), 0),
|
|
1546
|
-
warnings_count: (info?.warnings || []).length,
|
|
1547
|
-
errors_count: (info?.errors || []).length
|
|
1548
|
-
};
|
|
1549
|
-
}
|
|
1550
|
-
var external_module_ = __webpack_require__("module");
|
|
1551
|
-
var external_path_ = __webpack_require__("path");
|
|
1552
|
-
var messages = __webpack_require__("./lib/messages.ts");
|
|
1553
|
-
async function findUpLocal(filename, options) {
|
|
1554
|
-
const root = external_path_.parse(options.cwd).root;
|
|
1555
|
-
let currentDir = options.cwd;
|
|
1556
|
-
while(true){
|
|
1557
|
-
const candidate = external_path_.join(currentDir, filename);
|
|
1558
|
-
try {
|
|
1559
|
-
const stat = await external_fs_.promises.stat(candidate);
|
|
1560
|
-
if (stat.isFile()) return candidate;
|
|
1561
|
-
} catch {}
|
|
1562
|
-
if (currentDir === root) return;
|
|
1563
|
-
currentDir = external_path_.dirname(currentDir);
|
|
1564
|
-
}
|
|
1565
|
-
}
|
|
1566
|
-
async function findNearestPackageJson(manifestPath) {
|
|
1567
|
-
try {
|
|
1568
|
-
const manifestDir = external_path_.dirname(manifestPath);
|
|
1569
|
-
const packageJsonPath = await findUpLocal('package.json', {
|
|
1570
|
-
cwd: manifestDir
|
|
1571
|
-
});
|
|
1572
|
-
return packageJsonPath || null;
|
|
1573
|
-
} catch (error) {
|
|
1574
|
-
console.warn('Failed to find package.json:', error);
|
|
1575
|
-
return null;
|
|
1576
|
-
}
|
|
1577
|
-
}
|
|
1578
|
-
function validatePackageJson(packageJsonPath) {
|
|
1579
|
-
try {
|
|
1580
|
-
if (!external_fs_.existsSync(packageJsonPath)) return false;
|
|
1581
|
-
const content = external_fs_.readFileSync(packageJsonPath, 'utf-8');
|
|
1582
|
-
JSON.parse(content);
|
|
1583
|
-
return true;
|
|
1584
|
-
} catch (error) {
|
|
1585
|
-
console.warn('Invalid package.json at:', packageJsonPath, error);
|
|
1586
|
-
return false;
|
|
1587
|
-
}
|
|
1588
|
-
}
|
|
1589
|
-
const isUrl = (url)=>{
|
|
1590
|
-
try {
|
|
1591
|
-
new URL(url);
|
|
1592
|
-
return true;
|
|
1593
|
-
} catch (e) {
|
|
1594
|
-
return false;
|
|
1595
|
-
}
|
|
1596
|
-
};
|
|
1597
|
-
async function importUrlSourceFromGithub(pathOrRemoteUrl, text) {
|
|
1598
|
-
const cwd = process.cwd();
|
|
1599
|
-
const url = new URL(pathOrRemoteUrl);
|
|
1600
|
-
const segments = url.pathname.split('/').filter(Boolean);
|
|
1601
|
-
const repoName = segments.length >= 2 ? segments[1] : segments[segments.length - 1];
|
|
1602
|
-
const treeIndex = segments.indexOf('tree');
|
|
1603
|
-
const expectedName = -1 !== treeIndex && segments.length > treeIndex + 2 ? segments[segments.length - 1] : repoName;
|
|
1604
|
-
const expectedPath = external_path_.resolve(cwd, expectedName);
|
|
1605
|
-
if (external_fs_.existsSync(expectedPath)) try {
|
|
1606
|
-
const entries = external_fs_.readdirSync(expectedPath);
|
|
1607
|
-
if (0 === entries.length) external_fs_.rmSync(expectedPath, {
|
|
1608
|
-
recursive: true,
|
|
1609
|
-
force: true
|
|
1610
|
-
});
|
|
1611
|
-
else {
|
|
1612
|
-
const hasManifest = (dir)=>{
|
|
1613
|
-
const stack = [
|
|
1614
|
-
dir
|
|
1615
|
-
];
|
|
1616
|
-
while(stack.length){
|
|
1617
|
-
const current = stack.pop();
|
|
1618
|
-
const items = external_fs_.readdirSync(current, {
|
|
1619
|
-
withFileTypes: true
|
|
1620
|
-
});
|
|
1621
|
-
for (const it of items){
|
|
1622
|
-
if (it.isFile() && 'manifest.json' === it.name) return true;
|
|
1623
|
-
if (it.isDirectory() && 'node_modules' !== it.name && 'dist' !== it.name && !it.name.startsWith('.')) stack.push(external_path_.join(current, it.name));
|
|
1624
|
-
}
|
|
1625
|
-
}
|
|
1626
|
-
return false;
|
|
1627
|
-
};
|
|
1628
|
-
if (hasManifest(expectedPath)) return expectedPath;
|
|
1629
|
-
external_fs_.rmSync(expectedPath, {
|
|
1630
|
-
recursive: true,
|
|
1631
|
-
force: true
|
|
1632
|
-
});
|
|
1633
|
-
}
|
|
1634
|
-
} catch {}
|
|
1635
|
-
async function tryGitClone() {
|
|
1636
|
-
const { default: goGitIt } = await import("go-git-it");
|
|
1637
|
-
await goGitIt(pathOrRemoteUrl, cwd, text);
|
|
1638
|
-
}
|
|
1639
|
-
async function tryZipFallback() {
|
|
1640
|
-
const branch = -1 !== treeIndex && segments.length > treeIndex + 1 ? segments[treeIndex + 1] : 'main';
|
|
1641
|
-
const owner = segments[0];
|
|
1642
|
-
const repo = segments[1];
|
|
1643
|
-
const subdir = -1 !== treeIndex && segments.length > treeIndex + 2 ? segments.slice(treeIndex + 2).join('/') : '';
|
|
1644
|
-
const zipUrl = `https://codeload.github.com/${owner}/${repo}/zip/refs/heads/${branch}`;
|
|
1645
|
-
const extractedPath = await importUrlSourceFromZip(zipUrl);
|
|
1646
|
-
const extractedDirs = external_fs_.readdirSync(extractedPath, {
|
|
1647
|
-
withFileTypes: true
|
|
1648
|
-
}).filter((d)=>d.isDirectory()).map((d)=>d.name);
|
|
1649
|
-
const repoRootDir = extractedDirs.find((d)=>d.startsWith(`${repo}-${branch}`));
|
|
1650
|
-
const repoRoot = repoRootDir ? external_path_.join(extractedPath, repoRootDir) : extractedPath;
|
|
1651
|
-
return subdir ? external_path_.join(repoRoot, subdir) : repoRoot;
|
|
1652
|
-
}
|
|
1653
|
-
try {
|
|
1654
|
-
await tryGitClone();
|
|
1655
|
-
} catch {
|
|
1656
|
-
return await tryZipFallback();
|
|
1657
|
-
}
|
|
1658
|
-
const candidates = [];
|
|
1659
|
-
if (-1 !== treeIndex && segments.length > treeIndex + 2) candidates.push(segments[segments.length - 1]);
|
|
1660
|
-
candidates.push(repoName);
|
|
1661
|
-
for (const name of candidates){
|
|
1662
|
-
const p = external_path_.resolve(cwd, name);
|
|
1663
|
-
if (external_fs_.existsSync(p)) return p;
|
|
1664
|
-
}
|
|
1665
|
-
const dirs = external_fs_.readdirSync(cwd, {
|
|
1666
|
-
withFileTypes: true
|
|
1667
|
-
}).filter((d)=>d.isDirectory()).map((d)=>d.name);
|
|
1668
|
-
for (const dir of dirs){
|
|
1669
|
-
const manifestPath = external_path_.join(cwd, dir, 'manifest.json');
|
|
1670
|
-
if (external_fs_.existsSync(manifestPath)) return external_path_.join(cwd, dir);
|
|
1671
|
-
}
|
|
1672
|
-
try {
|
|
1673
|
-
const dirs = external_fs_.readdirSync(cwd, {
|
|
1674
|
-
withFileTypes: true
|
|
1675
|
-
}).filter((d)=>d.isDirectory()).map((d)=>d.name);
|
|
1676
|
-
const ghRoot = dirs.find((d)=>/-main$|-master$/.test(d));
|
|
1677
|
-
if (ghRoot) return external_path_.join(cwd, ghRoot);
|
|
1678
|
-
} catch {}
|
|
1679
|
-
throw new Error(messages.ax(cwd, candidates));
|
|
1680
|
-
}
|
|
1681
|
-
async function importUrlSourceFromZip(pathOrRemoteUrl) {
|
|
1682
|
-
const cwd = process.cwd();
|
|
1683
|
-
const { downloadAndExtractZip } = await __webpack_require__.e(787).then(__webpack_require__.bind(__webpack_require__, "./lib/zip.ts"));
|
|
1684
|
-
const extractedPath = await downloadAndExtractZip(pathOrRemoteUrl, cwd);
|
|
1685
|
-
return extractedPath;
|
|
1686
|
-
}
|
|
1687
|
-
async function getProjectPath(pathOrRemoteUrl) {
|
|
1688
|
-
if (!pathOrRemoteUrl) return process.cwd();
|
|
1689
|
-
if (isUrl(pathOrRemoteUrl)) {
|
|
1690
|
-
const url = new URL(pathOrRemoteUrl);
|
|
1691
|
-
if (url.protocol.startsWith('http')) {
|
|
1692
|
-
const pathname = url.pathname.toLowerCase();
|
|
1693
|
-
if (pathname.endsWith('.zip')) return await importUrlSourceFromZip(pathOrRemoteUrl);
|
|
1694
|
-
if ('https://github.com' !== url.origin) {
|
|
1695
|
-
const urlSource = await importUrlSourceFromZip(pathOrRemoteUrl);
|
|
1696
|
-
return urlSource;
|
|
1697
|
-
}
|
|
1698
|
-
const urlData = url.pathname.split('/');
|
|
1699
|
-
const owner = urlData.slice(1, 3)[0];
|
|
1700
|
-
const project = urlData.slice(1, 3)[1];
|
|
1701
|
-
console.log(messages.tQ(owner, project));
|
|
1702
|
-
const projectName = external_path_.basename(url.pathname);
|
|
1703
|
-
const urlSource = await importUrlSourceFromGithub(pathOrRemoteUrl, messages.F$(projectName));
|
|
1704
|
-
console.log(messages.W4(url.pathname));
|
|
1705
|
-
return urlSource;
|
|
1706
|
-
}
|
|
1707
|
-
}
|
|
1708
|
-
return external_path_.resolve(process.cwd(), pathOrRemoteUrl);
|
|
1709
|
-
}
|
|
1710
|
-
async function getProjectStructure(pathOrRemoteUrl) {
|
|
1711
|
-
const projectPath = await getProjectPath(pathOrRemoteUrl);
|
|
1712
|
-
const isUnderDir = (baseDir, candidatePath)=>{
|
|
1713
|
-
const rel = external_path_.relative(baseDir, candidatePath);
|
|
1714
|
-
return Boolean(rel && !rel.startsWith('..') && !external_path_.isAbsolute(rel));
|
|
1715
|
-
};
|
|
1716
|
-
const packageJsonPathFromProject = await findNearestPackageJson(external_path_.join(projectPath, 'manifest.json'));
|
|
1717
|
-
const packageJsonDirFromProject = packageJsonPathFromProject ? external_path_.dirname(packageJsonPathFromProject) : void 0;
|
|
1718
|
-
const rootManifestPath = external_path_.join(projectPath, 'manifest.json');
|
|
1719
|
-
const srcManifestPath = external_path_.join(projectPath, 'src', 'manifest.json');
|
|
1720
|
-
let manifestPath = external_fs_.existsSync(srcManifestPath) ? srcManifestPath : rootManifestPath;
|
|
1721
|
-
if (!external_fs_.existsSync(manifestPath)) {
|
|
1722
|
-
if (packageJsonDirFromProject) throw new Error(messages.dx(manifestPath));
|
|
1723
|
-
const findManifest = (dir)=>{
|
|
1724
|
-
const files = external_fs_.readdirSync(dir, {
|
|
1725
|
-
withFileTypes: true
|
|
1726
|
-
});
|
|
1727
|
-
for (const file of files){
|
|
1728
|
-
if (file.isFile() && 'manifest.json' === file.name) return external_path_.join(dir, file.name);
|
|
1729
|
-
if (file.isDirectory() && !file.name.startsWith('.') && 'node_modules' !== file.name && 'dist' !== file.name && 'public' !== file.name) {
|
|
1730
|
-
const found = findManifest(external_path_.join(dir, file.name));
|
|
1731
|
-
if (found) return found;
|
|
1732
|
-
}
|
|
1733
|
-
}
|
|
1734
|
-
return null;
|
|
1735
|
-
};
|
|
1736
|
-
const foundManifest = findManifest(projectPath);
|
|
1737
|
-
if (foundManifest) manifestPath = foundManifest;
|
|
1738
|
-
else throw new Error(messages.dx(manifestPath));
|
|
1739
|
-
}
|
|
1740
|
-
const packageJsonPath = await findNearestPackageJson(manifestPath);
|
|
1741
|
-
const packageJsonDir = packageJsonPath ? external_path_.dirname(packageJsonPath) : void 0;
|
|
1742
|
-
if (packageJsonDir) {
|
|
1743
|
-
const publicRoot = external_path_.join(packageJsonDir, 'public');
|
|
1744
|
-
if (isUnderDir(publicRoot, manifestPath)) {
|
|
1745
|
-
const fallbackSrc = external_path_.join(packageJsonDir, 'src', 'manifest.json');
|
|
1746
|
-
const fallbackRoot = external_path_.join(packageJsonDir, 'manifest.json');
|
|
1747
|
-
if (external_fs_.existsSync(fallbackSrc)) manifestPath = fallbackSrc;
|
|
1748
|
-
else if (external_fs_.existsSync(fallbackRoot)) manifestPath = fallbackRoot;
|
|
1749
|
-
else throw new Error(messages.dx(fallbackRoot));
|
|
1750
|
-
}
|
|
1751
|
-
}
|
|
1752
|
-
if (!packageJsonPath || !validatePackageJson(packageJsonPath)) return {
|
|
1753
|
-
manifestPath
|
|
1754
|
-
};
|
|
1755
|
-
return {
|
|
1756
|
-
manifestPath,
|
|
1757
|
-
packageJsonPath
|
|
1758
|
-
};
|
|
1759
|
-
}
|
|
1760
|
-
var config_loader = __webpack_require__("./lib/config-loader.ts");
|
|
1761
|
-
var package_0 = __webpack_require__("./package.json");
|
|
1762
|
-
function assertNoManagedDependencyConflicts(userPackageJsonPath, projectPath) {
|
|
1763
|
-
try {
|
|
1764
|
-
const raw = external_fs_.readFileSync(userPackageJsonPath, 'utf-8');
|
|
1765
|
-
const userPackageJson = JSON.parse(raw);
|
|
1766
|
-
const userDeps = Array.from(new Set([
|
|
1767
|
-
...Object.keys(userPackageJson.dependencies || {}),
|
|
1768
|
-
...Object.keys(userPackageJson.devDependencies || {}),
|
|
1769
|
-
...Object.keys(userPackageJson.optionalDependencies || {}),
|
|
1770
|
-
...Object.keys(userPackageJson.peerDependencies || {})
|
|
1771
|
-
]));
|
|
1772
|
-
const managedDeps = new Set([
|
|
1773
|
-
...Object.keys(package_0.El || {}),
|
|
1774
|
-
...Object.keys(package_0.optionalDependencies || {})
|
|
1775
|
-
]);
|
|
1776
|
-
managedDeps.delete('webpack');
|
|
1777
|
-
const userConfigJs = external_path_.join(projectPath, 'extension.config.js');
|
|
1778
|
-
const userConfigMjs = external_path_.join(projectPath, 'extension.config.mjs');
|
|
1779
|
-
const hasConfig = external_fs_.existsSync(userConfigJs) || external_fs_.existsSync(userConfigMjs);
|
|
1780
|
-
if (!hasConfig) return;
|
|
1781
|
-
const configPath = external_fs_.existsSync(userConfigJs) ? userConfigJs : userConfigMjs;
|
|
1782
|
-
const configSource = external_fs_.readFileSync(configPath, 'utf-8');
|
|
1783
|
-
const duplicates = userDeps.filter((d)=>managedDeps.has(d)).filter((d)=>configSource.includes(d)).sort();
|
|
1784
|
-
if (duplicates.length > 0) {
|
|
1785
|
-
console.error(messages.H3(duplicates, userPackageJsonPath));
|
|
1786
|
-
process.exit(1);
|
|
1787
|
-
}
|
|
1788
|
-
} catch (error) {
|
|
1789
|
-
if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.warn(error);
|
|
1790
|
-
}
|
|
1791
|
-
}
|
|
1792
|
-
var paths = __webpack_require__("./lib/paths.ts");
|
|
1793
|
-
var develop_context = __webpack_require__("./lib/develop-context.ts");
|
|
1794
|
-
const external_child_process_namespaceObject = require("child_process");
|
|
1795
|
-
const package_manager_require = (0, external_module_.createRequire)(__rslib_import_meta_url__);
|
|
1796
|
-
function normalizePackageManager(value) {
|
|
1797
|
-
if (!value) return;
|
|
1798
|
-
const lower = value.toLowerCase().trim();
|
|
1799
|
-
if ('pnpm' === lower) return 'pnpm';
|
|
1800
|
-
if ('yarn' === lower) return 'yarn';
|
|
1801
|
-
if ('bun' === lower) return 'bun';
|
|
1802
|
-
if ('npm' === lower) return 'npm';
|
|
1803
|
-
}
|
|
1804
|
-
function inferPackageManagerFromPath(value) {
|
|
1805
|
-
if (!value) return;
|
|
1806
|
-
const lower = value.toLowerCase();
|
|
1807
|
-
if (lower.includes('pnpm')) return 'pnpm';
|
|
1808
|
-
if (lower.includes('yarn')) return 'yarn';
|
|
1809
|
-
if (lower.includes('bun')) return 'bun';
|
|
1810
|
-
if (lower.includes('npm')) return 'npm';
|
|
1811
|
-
}
|
|
1812
|
-
function getPackageManagerOverride() {
|
|
1813
|
-
const name = normalizePackageManager(process.env.EXTENSION_JS_PACKAGE_MANAGER);
|
|
1814
|
-
const execPath = process.env.EXTENSION_JS_PM_EXEC_PATH || process.env.npm_execpath || process.env.NPM_EXEC_PATH;
|
|
1815
|
-
if (!name && !execPath) return;
|
|
1816
|
-
const inferredName = name || inferPackageManagerFromPath(execPath) || 'npm';
|
|
1817
|
-
return {
|
|
1818
|
-
name: inferredName,
|
|
1819
|
-
execPath
|
|
1820
|
-
};
|
|
1821
|
-
}
|
|
1822
|
-
function detectPackageManagerFromEnv() {
|
|
1823
|
-
const userAgent = process.env.npm_config_user_agent || '';
|
|
1824
|
-
const execPath = process.env.npm_execpath || process.env.NPM_EXEC_PATH || '';
|
|
1825
|
-
if (userAgent.includes('pnpm')) return {
|
|
1826
|
-
name: 'pnpm',
|
|
1827
|
-
execPath: execPath || void 0
|
|
1828
|
-
};
|
|
1829
|
-
if (userAgent.includes('yarn')) return {
|
|
1830
|
-
name: 'yarn',
|
|
1831
|
-
execPath: execPath || void 0
|
|
1832
|
-
};
|
|
1833
|
-
if (userAgent.includes('bun')) return {
|
|
1834
|
-
name: 'bun',
|
|
1835
|
-
execPath: execPath || void 0
|
|
1836
|
-
};
|
|
1837
|
-
if (userAgent.includes('npm')) return {
|
|
1838
|
-
name: 'npm',
|
|
1839
|
-
execPath: execPath || void 0
|
|
1840
|
-
};
|
|
1841
|
-
if (execPath) {
|
|
1842
|
-
const inferred = inferPackageManagerFromPath(execPath) || 'npm';
|
|
1843
|
-
return {
|
|
1844
|
-
name: inferred,
|
|
1845
|
-
execPath
|
|
1846
|
-
};
|
|
1847
|
-
}
|
|
1848
|
-
}
|
|
1849
|
-
function resolveNpmCliFromNode(execPath) {
|
|
1850
|
-
const execDir = external_path_.dirname(execPath);
|
|
1851
|
-
const candidates = [
|
|
1852
|
-
external_path_.join(execDir, 'node_modules', 'npm', 'bin', 'npm-cli.js'),
|
|
1853
|
-
external_path_.join(execDir, '..', 'lib', 'node_modules', 'npm', 'bin', 'npm-cli.js'),
|
|
1854
|
-
external_path_.join(execDir, '..', 'node_modules', 'npm', 'bin', 'npm-cli.js')
|
|
1855
|
-
];
|
|
1856
|
-
for (const candidate of candidates)if (external_fs_.existsSync(candidate)) return candidate;
|
|
1857
|
-
}
|
|
1858
|
-
function resolveBundledNpmCliPath() {
|
|
1859
|
-
if (process.env.EXTENSION_JS_PM_EXEC_PATH) {
|
|
1860
|
-
const overridePath = process.env.EXTENSION_JS_PM_EXEC_PATH;
|
|
1861
|
-
if (overridePath && external_fs_.existsSync(overridePath)) return overridePath;
|
|
1862
|
-
}
|
|
1863
|
-
try {
|
|
1864
|
-
const resolved = package_manager_require.resolve('npm/bin/npm-cli.js', {
|
|
1865
|
-
paths: [
|
|
1866
|
-
process.cwd(),
|
|
1867
|
-
__dirname
|
|
1868
|
-
]
|
|
1869
|
-
});
|
|
1870
|
-
if (resolved && external_fs_.existsSync(resolved)) return resolved;
|
|
1871
|
-
} catch {}
|
|
1872
|
-
return resolveNpmCliFromNode(process.execPath);
|
|
1873
|
-
}
|
|
1874
|
-
function isWindowsExecutablePath(value) {
|
|
1875
|
-
if (!value || 'win32' !== process.platform) return false;
|
|
1876
|
-
return /\.(cmd|bat|exe)$/i.test(value);
|
|
1877
|
-
}
|
|
1878
|
-
function isNodeScriptPath(value) {
|
|
1879
|
-
if (!value) return false;
|
|
1880
|
-
return /\.(mjs|cjs|js)$/i.test(value);
|
|
1881
|
-
}
|
|
1882
|
-
function resolveWindowsCommandPath(command) {
|
|
1883
|
-
if ('win32' !== process.platform) return;
|
|
1884
|
-
try {
|
|
1885
|
-
const systemRoot = process.env.SystemRoot || 'C:\\Windows';
|
|
1886
|
-
const whereExe = external_path_.join(systemRoot, 'System32', 'where.exe');
|
|
1887
|
-
const whereCommand = external_fs_.existsSync(whereExe) ? whereExe : 'where';
|
|
1888
|
-
const output = (0, external_child_process_namespaceObject.execFileSync)(whereCommand, [
|
|
1889
|
-
command
|
|
1890
|
-
], {
|
|
1891
|
-
encoding: 'utf8',
|
|
1892
|
-
stdio: [
|
|
1893
|
-
'ignore',
|
|
1894
|
-
'pipe',
|
|
1895
|
-
'ignore'
|
|
1896
|
-
],
|
|
1897
|
-
windowsHide: true
|
|
1898
|
-
});
|
|
1899
|
-
const candidates = String(output).split(/\r?\n/).map((line)=>line.trim()).filter(Boolean);
|
|
1900
|
-
const cmdMatch = candidates.find((line)=>/\.cmd$/i.test(line));
|
|
1901
|
-
return cmdMatch || candidates[0];
|
|
1902
|
-
} catch {
|
|
1903
|
-
return;
|
|
1904
|
-
}
|
|
1905
|
-
}
|
|
1906
|
-
function resolveUnixCommandPath(command) {
|
|
1907
|
-
if ('win32' === process.platform) return;
|
|
1908
|
-
try {
|
|
1909
|
-
const output = (0, external_child_process_namespaceObject.execFileSync)('which', [
|
|
1910
|
-
command
|
|
1911
|
-
], {
|
|
1912
|
-
encoding: 'utf8',
|
|
1913
|
-
stdio: [
|
|
1914
|
-
'ignore',
|
|
1915
|
-
'pipe',
|
|
1916
|
-
'ignore'
|
|
1917
|
-
]
|
|
1918
|
-
});
|
|
1919
|
-
const candidate = String(output).trim();
|
|
1920
|
-
return candidate || void 0;
|
|
1921
|
-
} catch {
|
|
1922
|
-
return;
|
|
1923
|
-
}
|
|
1924
|
-
}
|
|
1925
|
-
function resolveCommandOnPath(command) {
|
|
1926
|
-
return resolveWindowsCommandPath(command) || resolveUnixCommandPath(command) || void 0;
|
|
1927
|
-
}
|
|
1928
|
-
function canRunCorepack() {
|
|
1929
|
-
try {
|
|
1930
|
-
const fallback = package_manager_require('child_process');
|
|
1931
|
-
const spawnSync = external_child_process_namespaceObject.spawnSync?.mock !== void 0 ? external_child_process_namespaceObject.spawnSync : fallback.spawnSync || external_child_process_namespaceObject.spawnSync;
|
|
1932
|
-
const result = spawnSync('corepack', [
|
|
1933
|
-
'--version'
|
|
1934
|
-
], {
|
|
1935
|
-
stdio: 'ignore',
|
|
1936
|
-
windowsHide: true
|
|
1937
|
-
});
|
|
1938
|
-
return result?.status === 0;
|
|
1939
|
-
} catch {
|
|
1940
|
-
return false;
|
|
1941
|
-
}
|
|
1942
|
-
}
|
|
1943
|
-
function detectByLockfile(cwd) {
|
|
1944
|
-
if (!cwd) return;
|
|
1945
|
-
const hasPnpmLock = external_fs_.existsSync(external_path_.join(cwd, 'pnpm-lock.yaml'));
|
|
1946
|
-
const hasYarnLock = external_fs_.existsSync(external_path_.join(cwd, 'yarn.lock'));
|
|
1947
|
-
const hasNpmLock = external_fs_.existsSync(external_path_.join(cwd, 'package-lock.json'));
|
|
1948
|
-
if (hasPnpmLock) return 'pnpm';
|
|
1949
|
-
if (hasYarnLock) return 'yarn';
|
|
1950
|
-
if (hasNpmLock) return 'npm';
|
|
1951
|
-
}
|
|
1952
|
-
function hydrateResolvedPackageManager(name) {
|
|
1953
|
-
const resolvedCommand = resolveCommandOnPath(name);
|
|
1954
|
-
if (resolvedCommand) return {
|
|
1955
|
-
name,
|
|
1956
|
-
execPath: resolvedCommand
|
|
1957
|
-
};
|
|
1958
|
-
if ('npm' === name) {
|
|
1959
|
-
const bundledNpmCli = resolveBundledNpmCliPath();
|
|
1960
|
-
if (bundledNpmCli) return {
|
|
1961
|
-
name: 'npm',
|
|
1962
|
-
execPath: bundledNpmCli,
|
|
1963
|
-
runnerCommand: process.execPath,
|
|
1964
|
-
runnerArgs: [
|
|
1965
|
-
bundledNpmCli
|
|
1966
|
-
]
|
|
1967
|
-
};
|
|
1968
|
-
}
|
|
1969
|
-
}
|
|
1970
|
-
function resolvePackageManager(opts) {
|
|
1971
|
-
const lockPm = detectByLockfile(opts?.cwd);
|
|
1972
|
-
if (lockPm) {
|
|
1973
|
-
const hydrated = hydrateResolvedPackageManager(lockPm);
|
|
1974
|
-
if (hydrated) return hydrated;
|
|
1975
|
-
return {
|
|
1976
|
-
name: lockPm
|
|
1977
|
-
};
|
|
1978
|
-
}
|
|
1979
|
-
const override = getPackageManagerOverride();
|
|
1980
|
-
if (override) return override;
|
|
1981
|
-
const envPm = detectPackageManagerFromEnv();
|
|
1982
|
-
if (envPm) return envPm;
|
|
1983
|
-
const candidates = [
|
|
1984
|
-
'pnpm',
|
|
1985
|
-
'yarn',
|
|
1986
|
-
'bun'
|
|
1987
|
-
];
|
|
1988
|
-
for (const candidate of candidates){
|
|
1989
|
-
const resolved = resolveCommandOnPath(candidate);
|
|
1990
|
-
if (resolved) return {
|
|
1991
|
-
name: candidate,
|
|
1992
|
-
execPath: resolved
|
|
1993
|
-
};
|
|
1994
|
-
}
|
|
1995
|
-
const corepackPath = resolveCommandOnPath('corepack');
|
|
1996
|
-
if (corepackPath || canRunCorepack()) return {
|
|
1997
|
-
name: 'pnpm',
|
|
1998
|
-
runnerCommand: corepackPath || 'corepack',
|
|
1999
|
-
runnerArgs: [
|
|
2000
|
-
'pnpm'
|
|
2001
|
-
]
|
|
2002
|
-
};
|
|
2003
|
-
const bundledNpmCli = resolveBundledNpmCliPath();
|
|
2004
|
-
if (bundledNpmCli) return {
|
|
2005
|
-
name: 'npm',
|
|
2006
|
-
execPath: bundledNpmCli,
|
|
2007
|
-
runnerCommand: process.execPath,
|
|
2008
|
-
runnerArgs: [
|
|
2009
|
-
bundledNpmCli
|
|
2010
|
-
]
|
|
2011
|
-
};
|
|
2012
|
-
return {
|
|
2013
|
-
name: 'npm'
|
|
2014
|
-
};
|
|
2015
|
-
}
|
|
2016
|
-
function buildExecEnv() {
|
|
2017
|
-
if ('win32' !== process.platform) return;
|
|
2018
|
-
const nodeDir = external_path_.dirname(process.execPath);
|
|
2019
|
-
const pathSep = external_path_.delimiter;
|
|
2020
|
-
const existing = process.env.PATH || process.env.Path || '';
|
|
2021
|
-
if (existing.includes(nodeDir)) return;
|
|
2022
|
-
return {
|
|
2023
|
-
...process.env,
|
|
2024
|
-
PATH: `${nodeDir}${pathSep}${existing}`.trim(),
|
|
2025
|
-
Path: `${nodeDir}${pathSep}${existing}`.trim()
|
|
2026
|
-
};
|
|
2027
|
-
}
|
|
2028
|
-
function buildInstallCommand(pm, args) {
|
|
2029
|
-
if (pm.runnerCommand) return {
|
|
2030
|
-
command: pm.runnerCommand,
|
|
2031
|
-
args: [
|
|
2032
|
-
...pm.runnerArgs || [],
|
|
2033
|
-
...args
|
|
2034
|
-
]
|
|
2035
|
-
};
|
|
2036
|
-
if (pm.execPath) {
|
|
2037
|
-
if (isWindowsExecutablePath(pm.execPath)) return {
|
|
2038
|
-
command: pm.execPath,
|
|
2039
|
-
args
|
|
2040
|
-
};
|
|
2041
|
-
if (isNodeScriptPath(pm.execPath)) return {
|
|
2042
|
-
command: process.execPath,
|
|
2043
|
-
args: [
|
|
2044
|
-
pm.execPath,
|
|
2045
|
-
...args
|
|
2046
|
-
]
|
|
2047
|
-
};
|
|
2048
|
-
return {
|
|
2049
|
-
command: pm.execPath,
|
|
2050
|
-
args
|
|
2051
|
-
};
|
|
2052
|
-
}
|
|
2053
|
-
return {
|
|
2054
|
-
command: pm.name,
|
|
2055
|
-
args
|
|
2056
|
-
};
|
|
2057
|
-
}
|
|
2058
|
-
function buildSpawnInvocation(command, args) {
|
|
2059
|
-
return {
|
|
2060
|
-
command,
|
|
2061
|
-
args
|
|
2062
|
-
};
|
|
2063
|
-
}
|
|
2064
|
-
function execInstallCommand(command, args, options) {
|
|
2065
|
-
const invocation = buildSpawnInvocation(command, args);
|
|
2066
|
-
const env = buildExecEnv();
|
|
2067
|
-
const stdio = options?.stdio ?? 'ignore';
|
|
2068
|
-
const useShell = 'win32' === process.platform && /\.(cmd|bat)$/i.test(invocation.command);
|
|
2069
|
-
return new Promise((resolve, reject)=>{
|
|
2070
|
-
const child = (0, external_child_process_namespaceObject.spawn)(invocation.command, invocation.args, {
|
|
2071
|
-
cwd: options?.cwd,
|
|
2072
|
-
stdio,
|
|
2073
|
-
env: env || process.env,
|
|
2074
|
-
...useShell ? {
|
|
2075
|
-
shell: true
|
|
2076
|
-
} : {}
|
|
2077
|
-
});
|
|
2078
|
-
child.on('close', (code)=>{
|
|
2079
|
-
if (0 !== code) reject(new Error(`Install failed with exit code ${code}`));
|
|
2080
|
-
else resolve();
|
|
2081
|
-
});
|
|
2082
|
-
child.on('error', (error)=>reject(error));
|
|
2083
|
-
});
|
|
2084
|
-
}
|
|
2085
|
-
async function ensureUserProjectDependencies(packageJsonDir) {
|
|
2086
|
-
if (!(0, paths.Bi)(packageJsonDir)) return;
|
|
2087
|
-
const pm = resolvePackageManager({
|
|
2088
|
-
cwd: packageJsonDir
|
|
2089
|
-
});
|
|
2090
|
-
const cmd = buildInstallCommand(pm, [
|
|
2091
|
-
'install'
|
|
2092
|
-
]);
|
|
2093
|
-
await execInstallCommand(cmd.command, cmd.args, {
|
|
2094
|
-
cwd: packageJsonDir,
|
|
2095
|
-
stdio: 'inherit'
|
|
2096
|
-
});
|
|
2097
|
-
}
|
|
2098
|
-
async function ensureDevelopArtifacts() {
|
|
2099
|
-
const developRoot = (0, develop_context.w1)();
|
|
2100
|
-
if (!developRoot) return;
|
|
2101
|
-
const requiredFiles = [
|
|
2102
|
-
external_path_.join(developRoot, 'dist', "ensure-hmr-for-scripts.js"),
|
|
2103
|
-
external_path_.join(developRoot, 'dist', "minimum-script-file.js")
|
|
2104
|
-
];
|
|
2105
|
-
const missing = requiredFiles.filter((file)=>!external_fs_.existsSync(file));
|
|
2106
|
-
if (0 === missing.length) return;
|
|
2107
|
-
const pm = resolvePackageManager({
|
|
2108
|
-
cwd: developRoot
|
|
2109
|
-
});
|
|
2110
|
-
const command = buildInstallCommand(pm, [
|
|
2111
|
-
'run',
|
|
2112
|
-
'compile'
|
|
2113
|
-
]);
|
|
2114
|
-
const isAuthor = 'true' === process.env.EXTENSION_AUTHOR_MODE;
|
|
2115
|
-
const stdio = isAuthor ? 'inherit' : 'ignore';
|
|
2116
|
-
if (isAuthor) console.warn(messages.TL('extension-develop build artifacts (dist missing)'));
|
|
2117
|
-
await execInstallCommand(command.command, command.args, {
|
|
2118
|
-
cwd: developRoot,
|
|
2119
|
-
stdio
|
|
2120
|
-
});
|
|
2121
|
-
}
|
|
2122
|
-
var resolve_config = __webpack_require__("./plugin-special-folders/folder-extensions/resolve-config.ts");
|
|
2123
|
-
var get_data = __webpack_require__("./plugin-special-folders/get-data.ts");
|
|
2124
|
-
async function extensionBuild(pathOrRemoteUrl, buildOptions) {
|
|
2125
|
-
const require1 = (0, external_module_.createRequire)(__rslib_import_meta_url__);
|
|
2126
|
-
const projectStructure = await getProjectStructure(pathOrRemoteUrl);
|
|
2127
|
-
const isVitest = 'true' === process.env.VITEST;
|
|
2128
|
-
const shouldExitOnError = (buildOptions?.exitOnError ?? true) && !isVitest;
|
|
2129
|
-
const browser = (0, paths.YN)(buildOptions?.browser || 'chrome', buildOptions?.chromiumBinary, buildOptions?.geckoBinary || buildOptions?.firefoxBinary);
|
|
2130
|
-
const { manifestDir, packageJsonDir } = (0, paths.fu)(projectStructure);
|
|
2131
|
-
const isAuthor = 'true' === process.env.EXTENSION_AUTHOR_MODE;
|
|
2132
|
-
try {
|
|
2133
|
-
await ensureDevelopArtifacts();
|
|
2134
|
-
if (buildOptions?.install !== false) await ensureUserProjectDependencies(packageJsonDir);
|
|
2135
|
-
const [{ rspack }, { merge }, { handleStatsErrors }, { default: webpackConfig }] = await Promise.all([
|
|
2136
|
-
Promise.resolve(require1('@rspack/core')),
|
|
2137
|
-
import("webpack-merge"),
|
|
2138
|
-
__webpack_require__.e(504).then(__webpack_require__.bind(__webpack_require__, "./lib/stats-handler.ts")),
|
|
2139
|
-
__webpack_require__.e(442).then(__webpack_require__.bind(__webpack_require__, "./rspack-config.ts"))
|
|
2140
|
-
]);
|
|
2141
|
-
const debug = isAuthor;
|
|
2142
|
-
if (projectStructure.packageJsonPath) assertNoManagedDependencyConflicts(projectStructure.packageJsonPath, manifestDir);
|
|
2143
|
-
const commandConfig = await (0, config_loader.eY)(packageJsonDir, 'build');
|
|
2144
|
-
const specialFoldersData = (0, get_data.H)(packageJsonDir);
|
|
2145
|
-
const distPath = (0, paths.q4)(packageJsonDir, browser);
|
|
2146
|
-
try {
|
|
2147
|
-
external_fs_.rmSync(distPath, {
|
|
2148
|
-
recursive: true,
|
|
2149
|
-
force: true
|
|
2150
|
-
});
|
|
2151
|
-
} catch {}
|
|
2152
|
-
if (debug) {
|
|
2153
|
-
console.log(messages.SG(manifestDir, packageJsonDir));
|
|
2154
|
-
console.log(messages._A(browser, buildOptions?.chromiumBinary, buildOptions?.geckoBinary || buildOptions?.firefoxBinary));
|
|
2155
|
-
console.log(messages.AC(distPath));
|
|
2156
|
-
}
|
|
2157
|
-
const mergedExtensionsConfig = buildOptions?.extensions ?? commandConfig.extensions ?? specialFoldersData.extensions;
|
|
2158
|
-
const resolvedExtensionsConfig = await (0, resolve_config.R)({
|
|
2159
|
-
projectRoot: packageJsonDir,
|
|
2160
|
-
browser,
|
|
2161
|
-
config: mergedExtensionsConfig
|
|
2162
|
-
});
|
|
2163
|
-
const resolvedMode = buildOptions?.mode === 'development' || buildOptions?.mode === 'none' || buildOptions?.mode === 'production' ? buildOptions.mode : 'production';
|
|
2164
|
-
if ('development' === resolvedMode || 'production' === resolvedMode) process.env.NODE_ENV = resolvedMode;
|
|
2165
|
-
const baseConfig = webpackConfig(projectStructure, {
|
|
2166
|
-
...commandConfig,
|
|
2167
|
-
...buildOptions,
|
|
2168
|
-
extensions: resolvedExtensionsConfig,
|
|
2169
|
-
browser,
|
|
2170
|
-
mode: resolvedMode,
|
|
2171
|
-
output: {
|
|
2172
|
-
clean: true,
|
|
2173
|
-
path: distPath
|
|
2174
|
-
}
|
|
2175
|
-
});
|
|
2176
|
-
const allPluginsButBrowserRunners = baseConfig.plugins?.filter((plugin)=>plugin?.constructor.name !== 'plugin-browsers');
|
|
2177
|
-
const userExtensionConfig = await (0, config_loader.cR)(packageJsonDir);
|
|
2178
|
-
const userConfig = userExtensionConfig({
|
|
2179
|
-
...baseConfig,
|
|
2180
|
-
plugins: allPluginsButBrowserRunners
|
|
2181
|
-
});
|
|
2182
|
-
const compilerConfig = merge(userConfig);
|
|
2183
|
-
compilerConfig.stats = false;
|
|
2184
|
-
const compiler = rspack(compilerConfig);
|
|
2185
|
-
let summary = {
|
|
2186
|
-
browser,
|
|
2187
|
-
total_assets: 0,
|
|
2188
|
-
total_bytes: 0,
|
|
2189
|
-
largest_asset_bytes: 0,
|
|
2190
|
-
warnings_count: 0,
|
|
2191
|
-
errors_count: 0
|
|
2192
|
-
};
|
|
2193
|
-
await new Promise((resolve, reject)=>{
|
|
2194
|
-
compiler.run(async (err, stats)=>{
|
|
2195
|
-
if (err) {
|
|
2196
|
-
console.error(err.stack || err);
|
|
2197
|
-
return reject(err);
|
|
2198
|
-
}
|
|
2199
|
-
if (!stats || 'function' != typeof stats.hasErrors) return reject(new Error('Build failed: bundler returned invalid stats output (no reliable compilation result).'));
|
|
2200
|
-
if (!buildOptions?.silent && stats) console.log(messages.I(manifestDir, stats, browser));
|
|
2201
|
-
if (stats.hasErrors()) {
|
|
2202
|
-
handleStatsErrors(stats);
|
|
2203
|
-
if (!shouldExitOnError) return reject(new Error('Build failed with errors'));
|
|
2204
|
-
process.exit(1);
|
|
2205
|
-
} else {
|
|
2206
|
-
const info = stats?.toJson({
|
|
2207
|
-
all: false,
|
|
2208
|
-
assets: true,
|
|
2209
|
-
warnings: true,
|
|
2210
|
-
errors: true
|
|
2211
|
-
});
|
|
2212
|
-
summary = getBuildSummary(browser, info);
|
|
2213
|
-
if (summary.warnings_count > 0) {
|
|
2214
|
-
console.log(messages.fm(summary.warnings_count));
|
|
2215
|
-
const warningDetails = messages.wh(info?.warnings || []);
|
|
2216
|
-
if (warningDetails) console.log(`\n${warningDetails}`);
|
|
2217
|
-
} else console.log(messages.Cf());
|
|
2218
|
-
resolve();
|
|
2219
|
-
}
|
|
2220
|
-
});
|
|
2221
|
-
});
|
|
2222
|
-
return summary;
|
|
2223
|
-
} catch (error) {
|
|
2224
|
-
const isAuthor = 'true' === process.env.EXTENSION_AUTHOR_MODE;
|
|
2225
|
-
if (isAuthor) console.error(error);
|
|
2226
|
-
else console.error(messages.$3(error));
|
|
2227
|
-
if (!shouldExitOnError) throw error;
|
|
2228
|
-
process.exit(1);
|
|
2229
|
-
}
|
|
2230
|
-
}
|
|
2231
|
-
const promises_namespaceObject = require("fs/promises");
|
|
2232
|
-
async function generateExtensionTypes(manifestDir, packageJsonDir) {
|
|
2233
|
-
const extensionEnvFile = external_path_.join(packageJsonDir, 'extension-env.d.ts');
|
|
2234
|
-
const typePath = 'extension';
|
|
2235
|
-
const fileContent = `\
|
|
2236
|
-
// Required Extension.js types for TypeScript projects.
|
|
2237
|
-
// This file is auto-generated and should not be excluded.
|
|
2238
|
-
// If you need additional types, consider creating a new *.d.ts file and
|
|
2239
|
-
// referencing it in the "include" array of your tsconfig.json file.
|
|
2240
|
-
// See https://www.typescriptlang.org/tsconfig#include for more information.
|
|
2241
|
-
/// <reference types="${typePath}/types" />
|
|
2242
|
-
|
|
2243
|
-
// Polyfill types for browser.* APIs
|
|
2244
|
-
/// <reference types="${typePath}/types/polyfill" />
|
|
2245
|
-
`;
|
|
2246
|
-
try {
|
|
2247
|
-
await promises_namespaceObject.access(extensionEnvFile);
|
|
2248
|
-
const existingContent = await promises_namespaceObject.readFile(extensionEnvFile, 'utf8');
|
|
2249
|
-
if (existingContent.includes('develop/dist/types')) await promises_namespaceObject.writeFile(extensionEnvFile, fileContent);
|
|
2250
|
-
await promises_namespaceObject.writeFile(extensionEnvFile, fileContent);
|
|
2251
|
-
} catch (err) {
|
|
2252
|
-
const manifest = require(external_path_.join(manifestDir, 'manifest.json'));
|
|
2253
|
-
console.log(messages.ng(manifest));
|
|
2254
|
-
try {
|
|
2255
|
-
await promises_namespaceObject.writeFile(extensionEnvFile, fileContent);
|
|
2256
|
-
} catch (writeErr) {
|
|
2257
|
-
console.log(messages.v_(writeErr));
|
|
2258
|
-
}
|
|
2259
|
-
}
|
|
2260
|
-
}
|
|
2261
|
-
var sanitize = __webpack_require__("./lib/sanitize.ts");
|
|
2262
|
-
const external_node_events_namespaceObject = require("node:events");
|
|
2263
|
-
var contracts = __webpack_require__("./plugin-web-extension/feature-scripts/contracts.ts");
|
|
2264
|
-
function _define_property(obj, key, value) {
|
|
2265
|
-
if (key in obj) Object.defineProperty(obj, key, {
|
|
2266
|
-
value: value,
|
|
2267
|
-
enumerable: true,
|
|
2268
|
-
configurable: true,
|
|
2269
|
-
writable: true
|
|
2270
|
-
});
|
|
2271
|
-
else obj[key] = value;
|
|
2272
|
-
return obj;
|
|
2273
|
-
}
|
|
2274
|
-
class BuildEmitter extends external_node_events_namespaceObject.EventEmitter {
|
|
2275
|
-
constructor(){
|
|
2276
|
-
super();
|
|
2277
|
-
this.on('error', ()=>{});
|
|
2278
|
-
}
|
|
2279
|
-
}
|
|
2280
|
-
class BrowsersPlugin {
|
|
2281
|
-
apply(compiler) {
|
|
2282
|
-
let pendingReloadReason;
|
|
2283
|
-
let pendingChangedSources = [];
|
|
2284
|
-
compiler.hooks.watchRun.tap(BrowsersPlugin.name, ()=>{
|
|
2285
|
-
pendingReloadReason = void 0;
|
|
2286
|
-
pendingChangedSources = [];
|
|
2287
|
-
const modifiedFiles = compiler.modifiedFiles;
|
|
2288
|
-
if (!modifiedFiles || 0 === modifiedFiles.size) return;
|
|
2289
|
-
const contextDir = compiler.options.context || '';
|
|
2290
|
-
for (const file of modifiedFiles){
|
|
2291
|
-
const normalized = external_path_.relative(contextDir, file).replace(/\\/g, '/');
|
|
2292
|
-
pendingChangedSources.push(normalized);
|
|
2293
|
-
if (normalized.includes('manifest.json')) pendingReloadReason = 'full';
|
|
2294
|
-
else if (normalized.includes('_locales/')) pendingReloadReason = 'full';
|
|
2295
|
-
}
|
|
2296
|
-
});
|
|
2297
|
-
compiler.hooks.done.tapPromise(BrowsersPlugin.name, async (stats)=>{
|
|
2298
|
-
const compilation = stats.compilation;
|
|
2299
|
-
const hasErrors = compilation.errors && compilation.errors.length > 0;
|
|
2300
|
-
if (hasErrors) return void this.emitter.emit('error', {
|
|
2301
|
-
errors: compilation.errors.map((e)=>'string' == typeof e ? e : e.message || String(e))
|
|
2302
|
-
});
|
|
2303
|
-
const outputPath = String(compilation.options?.output?.path || '');
|
|
2304
|
-
const contextDir = String(compilation.options?.context || '');
|
|
2305
|
-
let reloadInstruction;
|
|
2306
|
-
if (!this.isFirstCompile && pendingReloadReason) reloadInstruction = {
|
|
2307
|
-
type: pendingReloadReason,
|
|
2308
|
-
changedAssets: pendingChangedSources
|
|
2309
|
-
};
|
|
2310
|
-
else if (!this.isFirstCompile && pendingChangedSources.length > 0) {
|
|
2311
|
-
const isServiceWorkerSource = (rel)=>/(^|\/)background(\.|\/)/i.test(rel) || /service[-_.]?worker/i.test(rel);
|
|
2312
|
-
const hasServiceWorkerChange = pendingChangedSources.some(isServiceWorkerSource);
|
|
2313
|
-
if (hasServiceWorkerChange) reloadInstruction = {
|
|
2314
|
-
type: 'service-worker',
|
|
2315
|
-
changedAssets: pendingChangedSources
|
|
2316
|
-
};
|
|
2317
|
-
else {
|
|
2318
|
-
const contentScriptCount = readContentScriptCount(compilation, outputPath);
|
|
2319
|
-
if (contentScriptCount > 0) {
|
|
2320
|
-
const entries = [];
|
|
2321
|
-
for(let i = 0; i < contentScriptCount; i++)entries.push((0, contracts.Y0)(i));
|
|
2322
|
-
reloadInstruction = {
|
|
2323
|
-
type: "content-scripts",
|
|
2324
|
-
changedContentScriptEntries: entries,
|
|
2325
|
-
changedAssets: pendingChangedSources
|
|
2326
|
-
};
|
|
2327
|
-
} else reloadInstruction = void 0;
|
|
2328
|
-
}
|
|
2329
|
-
}
|
|
2330
|
-
const wasFirstCompile = this.isFirstCompile;
|
|
2331
|
-
this.isFirstCompile = false;
|
|
2332
|
-
if (wasFirstCompile) try {
|
|
2333
|
-
this.controller = await this.options.launcher({
|
|
2334
|
-
...this.options.browserOptions,
|
|
2335
|
-
outputPath,
|
|
2336
|
-
contextDir,
|
|
2337
|
-
extensionsToLoad: this.extensionsToLoad
|
|
2338
|
-
});
|
|
2339
|
-
const logLevel = this.options.browserOptions.logLevel || 'off';
|
|
2340
|
-
if ('off' !== logLevel && this.controller) await this.controller.enableUnifiedLogging({
|
|
2341
|
-
level: logLevel,
|
|
2342
|
-
contexts: this.options.browserOptions.logContexts,
|
|
2343
|
-
format: this.options.browserOptions.logFormat,
|
|
2344
|
-
timestamps: this.options.browserOptions.logTimestamps,
|
|
2345
|
-
color: this.options.browserOptions.logColor,
|
|
2346
|
-
urlFilter: this.options.browserOptions.logUrl,
|
|
2347
|
-
tabFilter: this.options.browserOptions.logTab
|
|
2348
|
-
});
|
|
2349
|
-
} catch (error) {
|
|
2350
|
-
this.emitter.emit('error', {
|
|
2351
|
-
errors: [
|
|
2352
|
-
error instanceof Error ? error.message : String(error)
|
|
2353
|
-
]
|
|
2354
|
-
});
|
|
2355
|
-
}
|
|
2356
|
-
else if (this.controller && reloadInstruction) {
|
|
2357
|
-
if ('true' !== process.env.EXTENSION_NO_RELOAD) try {
|
|
2358
|
-
await this.controller.reload(reloadInstruction);
|
|
2359
|
-
} catch {}
|
|
2360
|
-
}
|
|
2361
|
-
this.emitter.emit('compiled', {
|
|
2362
|
-
outputPath,
|
|
2363
|
-
contextDir,
|
|
2364
|
-
isFirstCompile: wasFirstCompile,
|
|
2365
|
-
reloadInstruction,
|
|
2366
|
-
extensionsToLoad: wasFirstCompile ? this.extensionsToLoad : void 0
|
|
2367
|
-
});
|
|
2368
|
-
});
|
|
2369
|
-
}
|
|
2370
|
-
constructor(options){
|
|
2371
|
-
_define_property(this, "options", void 0);
|
|
2372
|
-
_define_property(this, "emitter", void 0);
|
|
2373
|
-
_define_property(this, "extensionsToLoad", void 0);
|
|
2374
|
-
_define_property(this, "isFirstCompile", void 0);
|
|
2375
|
-
_define_property(this, "controller", void 0);
|
|
2376
|
-
this.options = options;
|
|
2377
|
-
this.emitter = new BuildEmitter();
|
|
2378
|
-
this.extensionsToLoad = [];
|
|
2379
|
-
this.isFirstCompile = true;
|
|
2380
|
-
}
|
|
2381
|
-
}
|
|
2382
|
-
_define_property(BrowsersPlugin, "name", 'plugin-browsers');
|
|
2383
|
-
function readContentScriptCount(compilation, outputPath) {
|
|
2384
|
-
try {
|
|
2385
|
-
const asset = compilation.getAsset?.('manifest.json');
|
|
2386
|
-
if (asset?.source) {
|
|
2387
|
-
const manifest = JSON.parse(String(asset.source.source()));
|
|
2388
|
-
const list = manifest?.content_scripts;
|
|
2389
|
-
if (Array.isArray(list)) return list.length;
|
|
2390
|
-
}
|
|
2391
|
-
} catch {}
|
|
2392
|
-
try {
|
|
2393
|
-
const fs = __webpack_require__("fs");
|
|
2394
|
-
const manifestPath = external_path_.join(outputPath, 'manifest.json');
|
|
2395
|
-
if (fs.existsSync(manifestPath)) {
|
|
2396
|
-
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
|
2397
|
-
const list = manifest?.content_scripts;
|
|
2398
|
-
if (Array.isArray(list)) return list.length;
|
|
2399
|
-
}
|
|
2400
|
-
} catch {}
|
|
2401
|
-
return 0;
|
|
2402
|
-
}
|
|
2403
|
-
var typescript = __webpack_require__("./plugin-js-frameworks/js-tools/typescript.ts");
|
|
2404
|
-
async function extensionDev(pathOrRemoteUrl, devOptions) {
|
|
2405
|
-
let browsersPlugin;
|
|
2406
|
-
let emitter = new BuildEmitter();
|
|
2407
|
-
const projectStructure = await getProjectStructure(pathOrRemoteUrl);
|
|
2408
|
-
try {
|
|
2409
|
-
const isAuthor = 'true' === process.env.EXTENSION_AUTHOR_MODE;
|
|
2410
|
-
const debug = isAuthor;
|
|
2411
|
-
const { manifestDir, packageJsonDir } = (0, paths.fu)(projectStructure);
|
|
2412
|
-
await ensureDevelopArtifacts();
|
|
2413
|
-
if (false !== devOptions.install) await ensureUserProjectDependencies(packageJsonDir);
|
|
2414
|
-
if ((0, typescript.eE)(manifestDir)) await generateExtensionTypes(manifestDir, packageJsonDir);
|
|
2415
|
-
if (projectStructure.packageJsonPath) assertNoManagedDependencyConflicts(projectStructure.packageJsonPath, manifestDir);
|
|
2416
|
-
const browser = (0, paths.YN)(devOptions.browser || 'chrome', devOptions.chromiumBinary, devOptions.geckoBinary || devOptions.firefoxBinary);
|
|
2417
|
-
const geckoBinary = devOptions.geckoBinary || devOptions.firefoxBinary;
|
|
2418
|
-
if (debug) {
|
|
2419
|
-
console.log(messages.SG(manifestDir, packageJsonDir));
|
|
2420
|
-
console.log(messages._A(browser, devOptions.chromiumBinary, geckoBinary));
|
|
2421
|
-
}
|
|
2422
|
-
const browserConfig = await (0, config_loader.xY)(packageJsonDir, browser);
|
|
2423
|
-
const commandConfig = await (0, config_loader.eY)(packageJsonDir, 'dev');
|
|
2424
|
-
const merged = {
|
|
2425
|
-
...(0, sanitize.a)(browserConfig),
|
|
2426
|
-
...(0, sanitize.a)(commandConfig),
|
|
2427
|
-
...(0, sanitize.a)(devOptions)
|
|
2428
|
-
};
|
|
2429
|
-
if (devOptions.launcher && !devOptions.noBrowser) {
|
|
2430
|
-
browsersPlugin = new BrowsersPlugin({
|
|
2431
|
-
launcher: devOptions.launcher,
|
|
2432
|
-
browserOptions: {
|
|
2433
|
-
browser,
|
|
2434
|
-
mode: 'development',
|
|
2435
|
-
enableDevtools: true,
|
|
2436
|
-
noOpen: merged.noOpen,
|
|
2437
|
-
profile: merged.profile,
|
|
2438
|
-
persistProfile: merged.persistProfile,
|
|
2439
|
-
preferences: merged.preferences,
|
|
2440
|
-
browserFlags: merged.browserFlags,
|
|
2441
|
-
excludeBrowserFlags: merged.excludeBrowserFlags,
|
|
2442
|
-
startingUrl: merged.startingUrl,
|
|
2443
|
-
chromiumBinary: merged.chromiumBinary,
|
|
2444
|
-
geckoBinary: merged.geckoBinary || merged.firefoxBinary,
|
|
2445
|
-
port: merged.port,
|
|
2446
|
-
source: merged.source,
|
|
2447
|
-
watchSource: merged.watchSource,
|
|
2448
|
-
sourceFormat: merged.sourceFormat,
|
|
2449
|
-
sourceSummary: merged.sourceSummary,
|
|
2450
|
-
sourceMeta: merged.sourceMeta,
|
|
2451
|
-
sourceProbe: merged.sourceProbe,
|
|
2452
|
-
sourceTree: merged.sourceTree,
|
|
2453
|
-
sourceConsole: merged.sourceConsole,
|
|
2454
|
-
sourceDom: merged.sourceDom,
|
|
2455
|
-
sourceMaxBytes: merged.sourceMaxBytes,
|
|
2456
|
-
sourceRedact: merged.sourceRedact,
|
|
2457
|
-
sourceIncludeShadow: merged.sourceIncludeShadow,
|
|
2458
|
-
sourceDiff: merged.sourceDiff,
|
|
2459
|
-
logLevel: merged.logLevel,
|
|
2460
|
-
logContexts: merged.logContexts,
|
|
2461
|
-
logFormat: merged.logFormat,
|
|
2462
|
-
logTimestamps: merged.logTimestamps,
|
|
2463
|
-
logColor: merged.logColor,
|
|
2464
|
-
logUrl: merged.logUrl,
|
|
2465
|
-
logTab: merged.logTab
|
|
2466
|
-
}
|
|
2467
|
-
});
|
|
2468
|
-
emitter = browsersPlugin.emitter;
|
|
2469
|
-
}
|
|
2470
|
-
if ('true' === process.env.EXTENSION_DEV_DRY_RUN) return emitter;
|
|
2471
|
-
const { devServer } = await Promise.all([
|
|
2472
|
-
__webpack_require__.e(442),
|
|
2473
|
-
__webpack_require__.e(221)
|
|
2474
|
-
]).then(__webpack_require__.bind(__webpack_require__, "./dev-server/index.ts"));
|
|
2475
|
-
await devServer(projectStructure, {
|
|
2476
|
-
...devOptions,
|
|
2477
|
-
mode: 'development',
|
|
2478
|
-
browser,
|
|
2479
|
-
geckoBinary,
|
|
2480
|
-
browsersPlugin
|
|
2481
|
-
});
|
|
2482
|
-
return emitter;
|
|
2483
|
-
} catch (error) {
|
|
2484
|
-
console.error(error);
|
|
2485
|
-
process.exit(1);
|
|
2486
|
-
}
|
|
2487
|
-
}
|
|
2488
|
-
var plugin_playwright = __webpack_require__("./plugin-playwright/index.ts");
|
|
2489
|
-
var utils = __webpack_require__("./plugin-special-folders/folder-extensions/utils.ts");
|
|
2490
|
-
function resolveCompanionExtensionDirs(opts) {
|
|
2491
|
-
const { projectRoot, config } = opts;
|
|
2492
|
-
const normalized = (0, utils.cz)(config);
|
|
2493
|
-
const explicitPaths = normalized.paths;
|
|
2494
|
-
const scanDir = normalized.dir;
|
|
2495
|
-
const found = [];
|
|
2496
|
-
for (const p of explicitPaths){
|
|
2497
|
-
const abs = (0, utils.A$)(projectRoot, p);
|
|
2498
|
-
if ((0, utils.Uy)(abs)) found.push(abs);
|
|
2499
|
-
}
|
|
2500
|
-
if (scanDir) {
|
|
2501
|
-
const absScan = (0, utils.A$)(projectRoot, scanDir);
|
|
2502
|
-
if ((0, utils.Q7)(absScan)) {
|
|
2503
|
-
let entries = [];
|
|
2504
|
-
try {
|
|
2505
|
-
entries = external_fs_.readdirSync(absScan, {
|
|
2506
|
-
withFileTypes: true
|
|
2507
|
-
});
|
|
2508
|
-
} catch {
|
|
2509
|
-
entries = [];
|
|
2510
|
-
}
|
|
2511
|
-
const scanOneLevel = (rootDir)=>{
|
|
2512
|
-
let dirEntries = [];
|
|
2513
|
-
try {
|
|
2514
|
-
dirEntries = external_fs_.readdirSync(rootDir, {
|
|
2515
|
-
withFileTypes: true
|
|
2516
|
-
});
|
|
2517
|
-
} catch {
|
|
2518
|
-
dirEntries = [];
|
|
2519
|
-
}
|
|
2520
|
-
for (const ent of dirEntries){
|
|
2521
|
-
if (!ent.isDirectory()) continue;
|
|
2522
|
-
if (ent.name.startsWith('.')) continue;
|
|
2523
|
-
const candidate = external_path_.join(rootDir, ent.name);
|
|
2524
|
-
if ((0, utils.Uy)(candidate)) found.push(candidate);
|
|
2525
|
-
}
|
|
2526
|
-
};
|
|
2527
|
-
scanOneLevel(absScan);
|
|
2528
|
-
if ('extensions' === external_path_.basename(absScan)) for (const ent of entries){
|
|
2529
|
-
if (!ent.isDirectory()) continue;
|
|
2530
|
-
if (ent.name.startsWith('.')) continue;
|
|
2531
|
-
const browserDir = external_path_.join(absScan, ent.name);
|
|
2532
|
-
scanOneLevel(browserDir);
|
|
2533
|
-
}
|
|
2534
|
-
}
|
|
2535
|
-
}
|
|
2536
|
-
const unique = [];
|
|
2537
|
-
const seen = new Set();
|
|
2538
|
-
for (const p of found)if (!seen.has(p)) {
|
|
2539
|
-
seen.add(p);
|
|
2540
|
-
unique.push(p);
|
|
2541
|
-
}
|
|
2542
|
-
return unique;
|
|
2543
|
-
}
|
|
2544
|
-
var extensions_to_load = __webpack_require__("./lib/extensions-to-load.ts");
|
|
2545
|
-
function getDarkModeDefaults(browser) {
|
|
2546
|
-
if ('chrome' === browser || 'edge' === browser || 'chromium' === browser || 'chromium-based' === browser) return {
|
|
2547
|
-
browserFlags: [
|
|
2548
|
-
'--force-dark-mode',
|
|
2549
|
-
'--enable-features=WebUIDarkMode'
|
|
2550
|
-
],
|
|
2551
|
-
preferences: {}
|
|
2552
|
-
};
|
|
2553
|
-
if ('firefox' === browser || 'gecko-based' === browser || 'firefox-based' === browser) return {
|
|
2554
|
-
browserFlags: [],
|
|
2555
|
-
preferences: {
|
|
2556
|
-
'ui.systemUsesDarkTheme': 1,
|
|
2557
|
-
'layout.css.prefers-color-scheme.content-override': 2,
|
|
2558
|
-
'devtools.theme': 'dark'
|
|
2559
|
-
}
|
|
2560
|
-
};
|
|
2561
|
-
return {
|
|
2562
|
-
browserFlags: [],
|
|
2563
|
-
preferences: {}
|
|
2564
|
-
};
|
|
2565
|
-
}
|
|
2566
|
-
function withDarkMode(config) {
|
|
2567
|
-
const defaults = getDarkModeDefaults(config.browser);
|
|
2568
|
-
const existingFlags = Array.isArray(config.browserFlags) ? [
|
|
2569
|
-
...config.browserFlags
|
|
2570
|
-
] : [];
|
|
2571
|
-
const nextFlags = [
|
|
2572
|
-
...existingFlags
|
|
2573
|
-
];
|
|
2574
|
-
for (const flag of defaults.browserFlags || [])if (!nextFlags.some((f)=>String(f).trim() === flag)) nextFlags.push(flag);
|
|
2575
|
-
const nextPreferences = {
|
|
2576
|
-
...config.preferences || {},
|
|
2577
|
-
...Object.fromEntries(Object.entries(defaults.preferences || {}).filter(([k])=>!(k in (config.preferences || {}))))
|
|
2578
|
-
};
|
|
2579
|
-
return {
|
|
2580
|
-
...config,
|
|
2581
|
-
browserFlags: nextFlags,
|
|
2582
|
-
preferences: nextPreferences
|
|
2583
|
-
};
|
|
2584
|
-
}
|
|
2585
|
-
var dev_server_messages = __webpack_require__("./dev-server/messages.ts");
|
|
2586
|
-
async function extensionPreview(pathOrRemoteUrl, previewOptions, browserLauncher) {
|
|
2587
|
-
const projectStructure = await getProjectStructure(pathOrRemoteUrl);
|
|
2588
|
-
const debug = 'true' === process.env.EXTENSION_AUTHOR_MODE;
|
|
2589
|
-
const { manifestDir, packageJsonDir } = (0, paths.fu)(projectStructure);
|
|
2590
|
-
if (projectStructure.packageJsonPath) assertNoManagedDependencyConflicts(projectStructure.packageJsonPath, packageJsonDir);
|
|
2591
|
-
const browser = (0, paths.YN)(previewOptions.browser || 'chrome', previewOptions.chromiumBinary, previewOptions.geckoBinary || previewOptions.firefoxBinary);
|
|
2592
|
-
const outputPath = (0, paths.u2)(projectStructure, browser, previewOptions.outputPath);
|
|
2593
|
-
const distPath = (0, paths.q4)(packageJsonDir, browser);
|
|
2594
|
-
const metadataCommand = 'start' === previewOptions.metadataCommand ? 'start' : 'preview';
|
|
2595
|
-
const metadata = (0, plugin_playwright.Ih)({
|
|
2596
|
-
packageJsonDir,
|
|
2597
|
-
browser: String(browser),
|
|
2598
|
-
command: metadataCommand,
|
|
2599
|
-
distPath,
|
|
2600
|
-
manifestPath: projectStructure.manifestPath,
|
|
2601
|
-
port: 'number' == typeof previewOptions.port ? previewOptions.port : 'string' == typeof previewOptions.port ? parseInt(previewOptions.port, 10) : null
|
|
2602
|
-
});
|
|
2603
|
-
metadata.writeStarting();
|
|
2604
|
-
if (debug) {
|
|
2605
|
-
console.log(messages.SG(manifestDir, packageJsonDir));
|
|
2606
|
-
console.log(messages._A(browser, previewOptions.chromiumBinary, previewOptions.geckoBinary || previewOptions.firefoxBinary));
|
|
2607
|
-
console.log(messages.jV(outputPath, distPath));
|
|
2608
|
-
}
|
|
2609
|
-
const manifestAtOutput = external_path_.join(outputPath, 'manifest.json');
|
|
2610
|
-
if (!external_fs_.existsSync(manifestAtOutput)) {
|
|
2611
|
-
metadata.writeError('preview_manifest_missing', `Expected manifest at ${manifestAtOutput}`);
|
|
2612
|
-
throw new Error(`Preview is run-only and does not compile.\nExpected an unpacked extension at:\n ${manifestAtOutput}\n\nRun \`extension build\` or \`extension dev\` first, or pass --output-path to an existing unpacked extension directory.`);
|
|
2613
|
-
}
|
|
2614
|
-
const commandConfig = await (0, config_loader.eY)(packageJsonDir, metadataCommand);
|
|
2615
|
-
const browserConfig = await (0, config_loader.xY)(packageJsonDir, browser);
|
|
2616
|
-
console.log(messages.V_(browser));
|
|
2617
|
-
if (previewOptions.noBrowser) {
|
|
2618
|
-
console.log(messages.k4(browser));
|
|
2619
|
-
metadata.writeReady();
|
|
2620
|
-
console.log(dev_server_messages.tl());
|
|
2621
|
-
const browserLabel = String(browser || 'unknown');
|
|
2622
|
-
console.log(dev_server_messages.bL({
|
|
2623
|
-
browser: browserLabel,
|
|
2624
|
-
manifestPath: projectStructure.manifestPath,
|
|
2625
|
-
readyPath: metadata.readyPath,
|
|
2626
|
-
browserModeLabel: `${browserLabel.charAt(0).toUpperCase() + browserLabel.slice(1)} (no-browser mode)`
|
|
2627
|
-
}));
|
|
2628
|
-
return;
|
|
2629
|
-
}
|
|
2630
|
-
const safeBrowserConfig = (0, sanitize.a)(browserConfig);
|
|
2631
|
-
const safeCommandConfig = (0, sanitize.a)(commandConfig);
|
|
2632
|
-
const safePreviewOptions = (0, sanitize.a)(previewOptions);
|
|
2633
|
-
const specialFoldersData = (0, get_data.H)(packageJsonDir);
|
|
2634
|
-
const mergedExtensionsConfig = safePreviewOptions.extensions ?? safeCommandConfig.extensions ?? safeBrowserConfig.extensions ?? specialFoldersData.extensions;
|
|
2635
|
-
const resolvedExtensionsConfig = await (0, resolve_config.R)({
|
|
2636
|
-
projectRoot: packageJsonDir,
|
|
2637
|
-
browser,
|
|
2638
|
-
config: mergedExtensionsConfig
|
|
2639
|
-
});
|
|
2640
|
-
const mergedGeckoBinary = safePreviewOptions.geckoBinary || safePreviewOptions.firefoxBinary || safeCommandConfig.geckoBinary || safeCommandConfig.firefoxBinary || safeBrowserConfig.geckoBinary || safeBrowserConfig.firefoxBinary;
|
|
2641
|
-
const mergedChromiumBinary = safePreviewOptions.chromiumBinary || safeCommandConfig.chromiumBinary || safeBrowserConfig.chromiumBinary;
|
|
2642
|
-
const merged = {
|
|
2643
|
-
...safeBrowserConfig,
|
|
2644
|
-
...safeCommandConfig,
|
|
2645
|
-
...safePreviewOptions,
|
|
2646
|
-
extensions: resolvedExtensionsConfig,
|
|
2647
|
-
chromiumBinary: mergedChromiumBinary,
|
|
2648
|
-
geckoBinary: mergedGeckoBinary
|
|
2649
|
-
};
|
|
2650
|
-
const darkDefaults = withDarkMode({
|
|
2651
|
-
browser,
|
|
2652
|
-
browserFlags: merged.browserFlags,
|
|
2653
|
-
preferences: merged.preferences
|
|
2654
|
-
});
|
|
2655
|
-
const companionUnpackedExtensionDirs = resolveCompanionExtensionDirs({
|
|
2656
|
-
projectRoot: packageJsonDir,
|
|
2657
|
-
config: merged.extensions
|
|
2658
|
-
});
|
|
2659
|
-
const unpackedExtensionDirsToLoad = (0, extensions_to_load.n)(external_path_.resolve(__dirname, '..'), 'production', browser, outputPath, companionUnpackedExtensionDirs, projectStructure.manifestPath);
|
|
2660
|
-
const resolvedOpts = {
|
|
2661
|
-
browser,
|
|
2662
|
-
outPath: outputPath,
|
|
2663
|
-
contextDir: packageJsonDir,
|
|
2664
|
-
readyPath: metadata.readyPath,
|
|
2665
|
-
extensionsToLoad: unpackedExtensionDirsToLoad,
|
|
2666
|
-
noOpen: merged.noOpen,
|
|
2667
|
-
profile: merged.profile,
|
|
2668
|
-
persistProfile: merged.persistProfile,
|
|
2669
|
-
preferences: darkDefaults.preferences,
|
|
2670
|
-
browserFlags: darkDefaults.browserFlags,
|
|
2671
|
-
excludeBrowserFlags: merged.excludeBrowserFlags,
|
|
2672
|
-
startingUrl: merged.startingUrl,
|
|
2673
|
-
chromiumBinary: merged.chromiumBinary,
|
|
2674
|
-
geckoBinary: merged.geckoBinary,
|
|
2675
|
-
instanceId: merged.instanceId,
|
|
2676
|
-
port: merged.port,
|
|
2677
|
-
dryRun: merged.dryRun
|
|
2678
|
-
};
|
|
2679
|
-
if (!browserLauncher) throw new Error("extensionPreview requires a browserLauncher callback. The browser launch code has moved to programs/extension/browsers/.");
|
|
2680
|
-
await browserLauncher(resolvedOpts);
|
|
2681
|
-
metadata.writeReady();
|
|
2682
|
-
}
|
|
2683
|
-
},
|
|
2684
|
-
"./plugin-js-frameworks/frameworks-lib/integrations.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
2685
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
2686
|
-
qQ: ()=>isUsingJSFramework,
|
|
2687
|
-
ws: ()=>_lib_has_dependency__rspack_import_0.w
|
|
2688
|
-
});
|
|
2689
|
-
var _lib_has_dependency__rspack_import_0 = __webpack_require__("./lib/has-dependency.ts");
|
|
2690
|
-
__webpack_require__("./lib/develop-context.ts");
|
|
2691
|
-
function isUsingJSFramework(projectPath) {
|
|
2692
|
-
const frameworks = [
|
|
2693
|
-
'react',
|
|
2694
|
-
'vue',
|
|
2695
|
-
'@angular/core',
|
|
2696
|
-
'svelte',
|
|
2697
|
-
'solid-js',
|
|
2698
|
-
'preact'
|
|
2699
|
-
];
|
|
2700
|
-
return frameworks.some((fw)=>(0, _lib_has_dependency__rspack_import_0.w)(projectPath, fw));
|
|
2701
|
-
}
|
|
2702
|
-
},
|
|
2703
|
-
"./plugin-js-frameworks/js-frameworks-lib/messages.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
2704
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
2705
|
-
Ei: ()=>jsFrameworksHmrSummary,
|
|
2706
|
-
LR: ()=>creatingTSConfig,
|
|
2707
|
-
MH: ()=>jsFrameworksConfigsDetected,
|
|
2708
|
-
Ty: ()=>isUsingCustomLoader,
|
|
2709
|
-
jH: ()=>jsFrameworksIntegrationsEnabled,
|
|
2710
|
-
zA: ()=>isUsingIntegration
|
|
2711
|
-
});
|
|
2712
|
-
var pintor__rspack_import_0 = __webpack_require__("pintor");
|
|
2713
|
-
var pintor__rspack_import_0_default = /*#__PURE__*/ __webpack_require__.n(pintor__rspack_import_0);
|
|
2714
|
-
function isUsingIntegration(name) {
|
|
2715
|
-
return `${pintor__rspack_import_0_default().gray('⏵⏵⏵')} Using ${pintor__rspack_import_0_default().brightBlue(name)}...`;
|
|
2716
|
-
}
|
|
2717
|
-
function creatingTSConfig() {
|
|
2718
|
-
return `${pintor__rspack_import_0_default().gray('⏵⏵⏵')} Creating default tsconfig.json...`;
|
|
2719
|
-
}
|
|
2720
|
-
function isUsingCustomLoader(loaderPath) {
|
|
2721
|
-
return `${pintor__rspack_import_0_default().gray('⏵⏵⏵')} Using custom loader: ${pintor__rspack_import_0_default().yellow(loaderPath)}.`;
|
|
2722
|
-
}
|
|
2723
|
-
function jsFrameworksIntegrationsEnabled(integrations) {
|
|
2724
|
-
const list = integrations.length > 0 ? integrations.map((n)=>pintor__rspack_import_0_default().yellow(n)).join(', ') : pintor__rspack_import_0_default().gray('none');
|
|
2725
|
-
return `${pintor__rspack_import_0_default().gray('⏵⏵⏵')} JS: Integrations enabled (${pintor__rspack_import_0_default().gray(String(integrations.length))}) ${list}`;
|
|
2726
|
-
}
|
|
2727
|
-
function jsFrameworksConfigsDetected(tsConfigPath, tsRoot, targets) {
|
|
2728
|
-
const fmt = (v)=>v ? pintor__rspack_import_0_default().underline(v) : pintor__rspack_import_0_default().gray('none');
|
|
2729
|
-
const tgt = targets && targets.length ? targets.map((t)=>pintor__rspack_import_0_default().gray(t)).join(', ') : pintor__rspack_import_0_default().gray('default');
|
|
2730
|
-
return `${pintor__rspack_import_0_default().gray('⏵⏵⏵')} JS: Configs\n${pintor__rspack_import_0_default().gray('TSCONFIG')} ${fmt(tsConfigPath)}\n${pintor__rspack_import_0_default().gray('TSROOT')} ${fmt(tsRoot)}\n${pintor__rspack_import_0_default().gray('SWC_TARGETS')} ${tgt}`;
|
|
2731
|
-
}
|
|
2732
|
-
function jsFrameworksHmrSummary(enabled, frameworks) {
|
|
2733
|
-
const list = frameworks.length > 0 ? frameworks.map((n)=>pintor__rspack_import_0_default().yellow(n)).join(', ') : pintor__rspack_import_0_default().gray('none');
|
|
2734
|
-
return `${pintor__rspack_import_0_default().gray('⏵⏵⏵')} JS: HMR ${enabled ? pintor__rspack_import_0_default().green('enabled') : pintor__rspack_import_0_default().gray('disabled')} for ${list}`;
|
|
2735
|
-
}
|
|
2736
|
-
},
|
|
2737
|
-
"./plugin-js-frameworks/js-tools/typescript.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
2738
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
2739
|
-
eE: ()=>isUsingTypeScript,
|
|
2740
|
-
hB: ()=>getUserTypeScriptConfigFile
|
|
2741
|
-
});
|
|
2742
|
-
var path__rspack_import_0 = __webpack_require__("path");
|
|
2743
|
-
var fs__rspack_import_1 = __webpack_require__("fs");
|
|
2744
|
-
var pintor__rspack_import_2 = __webpack_require__("pintor");
|
|
2745
|
-
var pintor__rspack_import_2_default = /*#__PURE__*/ __webpack_require__.n(pintor__rspack_import_2);
|
|
2746
|
-
var _js_frameworks_lib_messages__rspack_import_3 = __webpack_require__("./plugin-js-frameworks/js-frameworks-lib/messages.ts");
|
|
2747
|
-
var _frameworks_lib_integrations__rspack_import_4 = __webpack_require__("./plugin-js-frameworks/frameworks-lib/integrations.ts");
|
|
2748
|
-
__webpack_require__("./lib/optional-deps-resolver.ts");
|
|
2749
|
-
var _lib_parse_json_safe__rspack_import_6 = __webpack_require__("./lib/parse-json-safe.ts");
|
|
2750
|
-
let hasShownUserMessage = false;
|
|
2751
|
-
function findNearestPackageJsonDirectory(startPath) {
|
|
2752
|
-
let currentDirectory = startPath;
|
|
2753
|
-
const maxDepth = 6;
|
|
2754
|
-
for(let i = 0; i < maxDepth; i++){
|
|
2755
|
-
const candidate = path__rspack_import_0.join(currentDirectory, 'package.json');
|
|
2756
|
-
if (fs__rspack_import_1.existsSync(candidate)) return currentDirectory;
|
|
2757
|
-
const parentDirectory = path__rspack_import_0.dirname(currentDirectory);
|
|
2758
|
-
if (parentDirectory === currentDirectory) break;
|
|
2759
|
-
currentDirectory = parentDirectory;
|
|
2760
|
-
}
|
|
2761
|
-
}
|
|
2762
|
-
function hasTypeScriptSourceFiles(projectPath) {
|
|
2763
|
-
try {
|
|
2764
|
-
const entries = fs__rspack_import_1.readdirSync(projectPath, {
|
|
2765
|
-
withFileTypes: true
|
|
2766
|
-
});
|
|
2767
|
-
return entries.some((entry)=>{
|
|
2768
|
-
if (entry.isFile()) {
|
|
2769
|
-
const name = entry.name;
|
|
2770
|
-
if (!/\.(ts|tsx|mts|mtsx)$/i.test(name)) return false;
|
|
2771
|
-
if (/\.(d\.ts|d\.mts|d\.mtsx)$/i.test(name)) return false;
|
|
2772
|
-
if (/\.(spec|test)\.(ts|tsx|mts|mtsx)$/i.test(name)) return false;
|
|
2773
|
-
return true;
|
|
2774
|
-
}
|
|
2775
|
-
if (entry.isDirectory()) {
|
|
2776
|
-
if (![
|
|
2777
|
-
'src',
|
|
2778
|
-
'content',
|
|
2779
|
-
'sidebar',
|
|
2780
|
-
'background'
|
|
2781
|
-
].includes(entry.name)) return false;
|
|
2782
|
-
const sub = path__rspack_import_0.join(projectPath, entry.name);
|
|
2783
|
-
return hasTypeScriptSourceFiles(sub);
|
|
2784
|
-
}
|
|
2785
|
-
return false;
|
|
2786
|
-
});
|
|
2787
|
-
} catch {
|
|
2788
|
-
return false;
|
|
2789
|
-
}
|
|
2790
|
-
}
|
|
2791
|
-
function isUsingTypeScript(projectPath) {
|
|
2792
|
-
const packageJsonDirectory = findNearestPackageJsonDirectory(projectPath);
|
|
2793
|
-
const tsConfigFilePath = getUserTypeScriptConfigFile(projectPath);
|
|
2794
|
-
const packageJson = packageJsonDirectory ? (0, _lib_parse_json_safe__rspack_import_6.p)(fs__rspack_import_1.readFileSync(path__rspack_import_0.join(packageJsonDirectory, 'package.json'), 'utf8')) : void 0;
|
|
2795
|
-
const TypeScriptAsDevDep = packageJson?.devDependencies?.typescript;
|
|
2796
|
-
const TypeScriptAsDep = packageJson?.dependencies?.typescript;
|
|
2797
|
-
const hasTsFiles = hasTypeScriptSourceFiles(projectPath);
|
|
2798
|
-
if (!hasShownUserMessage) {
|
|
2799
|
-
if (TypeScriptAsDevDep || TypeScriptAsDep || hasTsFiles) if (tsConfigFilePath) {
|
|
2800
|
-
if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(`${pintor__rspack_import_2_default().brightMagenta('⏵⏵⏵ Author says')} ${_js_frameworks_lib_messages__rspack_import_3.zA('TypeScript')}`);
|
|
2801
|
-
} else if (hasTsFiles) {
|
|
2802
|
-
const errorMessage = '[Extension.js] Missing tsconfig.json next to package.json. Create one to use TypeScript.';
|
|
2803
|
-
throw new Error(errorMessage);
|
|
2804
|
-
} else {
|
|
2805
|
-
console.log(_js_frameworks_lib_messages__rspack_import_3.LR());
|
|
2806
|
-
writeTsConfig(projectPath);
|
|
2807
|
-
}
|
|
2808
|
-
hasShownUserMessage = true;
|
|
2809
|
-
}
|
|
2810
|
-
return !!tsConfigFilePath && !!(TypeScriptAsDevDep || TypeScriptAsDep || hasTsFiles);
|
|
2811
|
-
}
|
|
2812
|
-
function defaultTypeScriptConfig(projectPath, _opts) {
|
|
2813
|
-
return {
|
|
2814
|
-
compilerOptions: {
|
|
2815
|
-
allowJs: true,
|
|
2816
|
-
allowSyntheticDefaultImports: true,
|
|
2817
|
-
esModuleInterop: true,
|
|
2818
|
-
forceConsistentCasingInFileNames: true,
|
|
2819
|
-
jsx: (0, _frameworks_lib_integrations__rspack_import_4.qQ)(projectPath) ? 'react-jsx' : 'preserve',
|
|
2820
|
-
lib: [
|
|
2821
|
-
'dom',
|
|
2822
|
-
'dom.iterable',
|
|
2823
|
-
'esnext'
|
|
2824
|
-
],
|
|
2825
|
-
moduleResolution: 'node',
|
|
2826
|
-
module: 'esnext',
|
|
2827
|
-
resolveJsonModule: true,
|
|
2828
|
-
strict: true,
|
|
2829
|
-
target: 'esnext',
|
|
2830
|
-
isolatedModules: false,
|
|
2831
|
-
skipLibCheck: true
|
|
2832
|
-
},
|
|
2833
|
-
exclude: [
|
|
2834
|
-
'node_modules',
|
|
2835
|
-
'dist'
|
|
2836
|
-
]
|
|
2837
|
-
};
|
|
2838
|
-
}
|
|
2839
|
-
function getUserTypeScriptConfigFile(projectPath) {
|
|
2840
|
-
const pkgDir = findNearestPackageJsonDirectory(projectPath);
|
|
2841
|
-
if (pkgDir) {
|
|
2842
|
-
const tsconfigPath = path__rspack_import_0.join(pkgDir, 'tsconfig.json');
|
|
2843
|
-
if (fs__rspack_import_1.existsSync(tsconfigPath)) return tsconfigPath;
|
|
2844
|
-
}
|
|
2845
|
-
}
|
|
2846
|
-
function writeTsConfig(projectPath) {
|
|
2847
|
-
fs__rspack_import_1.writeFileSync(path__rspack_import_0.join(projectPath, 'tsconfig.json'), JSON.stringify(defaultTypeScriptConfig(projectPath, {
|
|
2848
|
-
mode: 'development'
|
|
2849
|
-
}), null, 2));
|
|
2850
|
-
}
|
|
2851
|
-
},
|
|
2852
|
-
"./plugin-playwright/index.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
2853
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
2854
|
-
Ih: ()=>createPlaywrightMetadataWriter,
|
|
2855
|
-
Tb: ()=>PlaywrightPlugin
|
|
2856
|
-
});
|
|
2857
|
-
var fs__rspack_import_0 = __webpack_require__("fs");
|
|
2858
|
-
var path__rspack_import_1 = __webpack_require__("path");
|
|
2859
|
-
var _lib_paths__rspack_import_2 = __webpack_require__("./lib/paths.ts");
|
|
2860
|
-
function _define_property(obj, key, value) {
|
|
2861
|
-
if (key in obj) Object.defineProperty(obj, key, {
|
|
2862
|
-
value: value,
|
|
2863
|
-
enumerable: true,
|
|
2864
|
-
configurable: true,
|
|
2865
|
-
writable: true
|
|
2866
|
-
});
|
|
2867
|
-
else obj[key] = value;
|
|
2868
|
-
return obj;
|
|
2869
|
-
}
|
|
2870
|
-
function nowISO() {
|
|
2871
|
-
return new Date().toISOString();
|
|
2872
|
-
}
|
|
2873
|
-
function createRunId() {
|
|
2874
|
-
return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
2875
|
-
}
|
|
2876
|
-
function ensureDirSync(dirPath) {
|
|
2877
|
-
try {
|
|
2878
|
-
fs__rspack_import_0.mkdirSync(dirPath, {
|
|
2879
|
-
recursive: true
|
|
2880
|
-
});
|
|
2881
|
-
} catch {}
|
|
2882
|
-
}
|
|
2883
|
-
function writeJsonAtomic(filePath, value) {
|
|
2884
|
-
try {
|
|
2885
|
-
const tmpPath = `${filePath}.tmp-${process.pid}`;
|
|
2886
|
-
fs__rspack_import_0.writeFileSync(tmpPath, JSON.stringify(value, null, 2) + '\n', 'utf-8');
|
|
2887
|
-
fs__rspack_import_0.renameSync(tmpPath, filePath);
|
|
2888
|
-
} catch {}
|
|
2889
|
-
}
|
|
2890
|
-
function getPlaywrightMetadataDir(packageJsonDir, browser) {
|
|
2891
|
-
return (0, _lib_paths__rspack_import_2.G6)(path__rspack_import_1.join(packageJsonDir, 'dist', 'extension-js', browser));
|
|
2892
|
-
}
|
|
2893
|
-
function createPlaywrightMetadataWriter(options) {
|
|
2894
|
-
const metadataDir = getPlaywrightMetadataDir(options.packageJsonDir, options.browser);
|
|
2895
|
-
const readyPath = (0, _lib_paths__rspack_import_2.G6)(path__rspack_import_1.join(metadataDir, 'ready.json'));
|
|
2896
|
-
const eventsPath = (0, _lib_paths__rspack_import_2.G6)(path__rspack_import_1.join(metadataDir, 'events.ndjson'));
|
|
2897
|
-
const base = {
|
|
2898
|
-
command: options.command,
|
|
2899
|
-
browser: options.browser,
|
|
2900
|
-
runId: createRunId(),
|
|
2901
|
-
startedAt: nowISO(),
|
|
2902
|
-
distPath: options.distPath,
|
|
2903
|
-
manifestPath: options.manifestPath,
|
|
2904
|
-
port: (()=>{
|
|
2905
|
-
if ('number' == typeof options.port && Number.isFinite(options.port)) return options.port;
|
|
2906
|
-
if ('string' == typeof options.port) {
|
|
2907
|
-
const parsed = parseInt(options.port, 10);
|
|
2908
|
-
return Number.isFinite(parsed) ? parsed : null;
|
|
2909
|
-
}
|
|
2910
|
-
return null;
|
|
2911
|
-
})()
|
|
2912
|
-
};
|
|
2913
|
-
function writeReady(status, extra) {
|
|
2914
|
-
ensureDirSync(metadataDir);
|
|
2915
|
-
const payload = {
|
|
2916
|
-
...base,
|
|
2917
|
-
status,
|
|
2918
|
-
pid: process.pid,
|
|
2919
|
-
ts: nowISO(),
|
|
2920
|
-
compiledAt: extra?.compiledAt ?? null,
|
|
2921
|
-
errors: Array.isArray(extra?.errors) ? extra.errors : []
|
|
2922
|
-
};
|
|
2923
|
-
if (extra?.code) payload.code = extra.code;
|
|
2924
|
-
if (extra?.message) payload.message = extra.message;
|
|
2925
|
-
writeJsonAtomic(readyPath, payload);
|
|
2926
|
-
}
|
|
2927
|
-
function appendEvent(event) {
|
|
2928
|
-
ensureDirSync(metadataDir);
|
|
2929
|
-
try {
|
|
2930
|
-
fs__rspack_import_0.appendFileSync(eventsPath, `${JSON.stringify(event)}\n`, 'utf-8');
|
|
2931
|
-
} catch {}
|
|
2932
|
-
}
|
|
2933
|
-
return {
|
|
2934
|
-
metadataDir,
|
|
2935
|
-
readyPath,
|
|
2936
|
-
eventsPath,
|
|
2937
|
-
writeStarting () {
|
|
2938
|
-
writeReady('starting');
|
|
2939
|
-
},
|
|
2940
|
-
writeReady (compiledAt) {
|
|
2941
|
-
writeReady('ready', {
|
|
2942
|
-
compiledAt: compiledAt || nowISO()
|
|
2943
|
-
});
|
|
2944
|
-
},
|
|
2945
|
-
writeError (code, message, errors) {
|
|
2946
|
-
writeReady('error', {
|
|
2947
|
-
code,
|
|
2948
|
-
message,
|
|
2949
|
-
errors: Array.isArray(errors) ? errors : [],
|
|
2950
|
-
compiledAt: null
|
|
2951
|
-
});
|
|
2952
|
-
},
|
|
2953
|
-
appendEvent
|
|
2954
|
-
};
|
|
2955
|
-
}
|
|
2956
|
-
class PlaywrightPlugin {
|
|
2957
|
-
apply(compiler) {
|
|
2958
|
-
this.writer.writeStarting();
|
|
2959
|
-
compiler.hooks.compile.tap(PlaywrightPlugin.name, ()=>{
|
|
2960
|
-
this.writer.appendEvent({
|
|
2961
|
-
type: 'compile_start',
|
|
2962
|
-
ts: nowISO(),
|
|
2963
|
-
command: this.command,
|
|
2964
|
-
browser: this.browser
|
|
2965
|
-
});
|
|
2966
|
-
});
|
|
2967
|
-
compiler.hooks.done.tap(PlaywrightPlugin.name, (stats)=>{
|
|
2968
|
-
const durationMs = Number((stats?.compilation?.endTime || 0) - (stats?.compilation?.startTime || 0));
|
|
2969
|
-
const hasErrors = Boolean(stats?.hasErrors?.());
|
|
2970
|
-
const errorsCount = Number(Array.isArray(stats?.toJson?.({
|
|
2971
|
-
all: false,
|
|
2972
|
-
errors: true
|
|
2973
|
-
})?.errors) ? stats.toJson({
|
|
2974
|
-
all: false,
|
|
2975
|
-
errors: true
|
|
2976
|
-
}).errors.length : 0);
|
|
2977
|
-
if (hasErrors) {
|
|
2978
|
-
this.writer.appendEvent({
|
|
2979
|
-
type: 'compile_error',
|
|
2980
|
-
ts: nowISO(),
|
|
2981
|
-
command: this.command,
|
|
2982
|
-
browser: this.browser,
|
|
2983
|
-
durationMs: Number.isFinite(durationMs) ? durationMs : void 0,
|
|
2984
|
-
errorCount: Number.isFinite(errorsCount) ? errorsCount : 1
|
|
2985
|
-
});
|
|
2986
|
-
this.writer.writeError('compile_error', 'Compilation failed', [
|
|
2987
|
-
`errors: ${String(errorsCount || 1)}`
|
|
2988
|
-
]);
|
|
2989
|
-
return;
|
|
2990
|
-
}
|
|
2991
|
-
this.writer.appendEvent({
|
|
2992
|
-
type: 'compile_success',
|
|
2993
|
-
ts: nowISO(),
|
|
2994
|
-
command: this.command,
|
|
2995
|
-
browser: this.browser,
|
|
2996
|
-
durationMs: Number.isFinite(durationMs) ? durationMs : void 0,
|
|
2997
|
-
errorCount: 0
|
|
2998
|
-
});
|
|
2999
|
-
this.writer.writeReady(nowISO());
|
|
3000
|
-
});
|
|
3001
|
-
compiler.hooks.failed.tap(PlaywrightPlugin.name, (error)=>{
|
|
3002
|
-
this.writer.appendEvent({
|
|
3003
|
-
type: 'compile_error',
|
|
3004
|
-
ts: nowISO(),
|
|
3005
|
-
command: this.command,
|
|
3006
|
-
browser: this.browser,
|
|
3007
|
-
errorCount: 1
|
|
3008
|
-
});
|
|
3009
|
-
this.writer.writeError('compile_failed', error instanceof Error ? error.message : String(error));
|
|
3010
|
-
});
|
|
3011
|
-
compiler.hooks.watchClose.tap(PlaywrightPlugin.name, ()=>{
|
|
3012
|
-
this.writer.appendEvent({
|
|
3013
|
-
type: 'shutdown',
|
|
3014
|
-
ts: nowISO(),
|
|
3015
|
-
command: this.command,
|
|
3016
|
-
browser: this.browser
|
|
3017
|
-
});
|
|
3018
|
-
});
|
|
3019
|
-
}
|
|
3020
|
-
constructor(options){
|
|
3021
|
-
_define_property(this, "writer", void 0);
|
|
3022
|
-
_define_property(this, "command", void 0);
|
|
3023
|
-
_define_property(this, "browser", void 0);
|
|
3024
|
-
this.browser = String(options.browser || 'chromium');
|
|
3025
|
-
this.command = options.command || ('development' === options.mode ? 'dev' : 'start');
|
|
3026
|
-
this.writer = createPlaywrightMetadataWriter({
|
|
3027
|
-
packageJsonDir: options.packageJsonDir,
|
|
3028
|
-
browser: this.browser,
|
|
3029
|
-
command: this.command,
|
|
3030
|
-
distPath: options.outputPath,
|
|
3031
|
-
manifestPath: options.manifestPath,
|
|
3032
|
-
port: options.port
|
|
3033
|
-
});
|
|
3034
|
-
}
|
|
3035
|
-
}
|
|
3036
|
-
_define_property(PlaywrightPlugin, "name", 'plugin-playwright');
|
|
3037
|
-
},
|
|
3038
|
-
"./plugin-special-folders/folder-extensions/resolve-config.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
3039
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
3040
|
-
R: ()=>resolveCompanionExtensionsConfig
|
|
3041
|
-
});
|
|
3042
|
-
var fs__rspack_import_0 = __webpack_require__("fs");
|
|
3043
|
-
var path__rspack_import_1 = __webpack_require__("path");
|
|
3044
|
-
var extension_from_store__rspack_import_2 = __webpack_require__("extension-from-store");
|
|
3045
|
-
var _utils__rspack_import_3 = __webpack_require__("./plugin-special-folders/folder-extensions/utils.ts");
|
|
3046
|
-
function isPathLike(value) {
|
|
3047
|
-
if (path__rspack_import_1.isAbsolute(value)) return true;
|
|
3048
|
-
if (value.startsWith('./') || value.startsWith('../')) return true;
|
|
3049
|
-
return value.includes('/') || value.includes('\\');
|
|
3050
|
-
}
|
|
3051
|
-
function isSubpathOf(parent, child) {
|
|
3052
|
-
const rel = path__rspack_import_1.relative(parent, child);
|
|
3053
|
-
return '' !== rel && !rel.startsWith('..') && !path__rspack_import_1.isAbsolute(rel);
|
|
3054
|
-
}
|
|
3055
|
-
function getBrowserFolder(browser) {
|
|
3056
|
-
if ('firefox' === browser || 'gecko-based' === browser || 'firefox-based' === browser) return 'firefox';
|
|
3057
|
-
if ('edge' === browser) return 'edge';
|
|
3058
|
-
return 'chrome';
|
|
3059
|
-
}
|
|
3060
|
-
function parseChromeWebStoreId(url) {
|
|
3061
|
-
if ('chromewebstore.google.com' !== url.hostname) return null;
|
|
3062
|
-
const match = url.pathname.match(/\/([a-z]{32})(?:\/|$)/i);
|
|
3063
|
-
return match ? match[1] : null;
|
|
3064
|
-
}
|
|
3065
|
-
function parseEdgeAddonsId(url) {
|
|
3066
|
-
if ('microsoftedge.microsoft.com' !== url.hostname) return null;
|
|
3067
|
-
const match = url.pathname.match(/\/([a-z]{32})(?:\/|$)/i);
|
|
3068
|
-
return match ? match[1] : null;
|
|
3069
|
-
}
|
|
3070
|
-
function parseAmoSlug(url) {
|
|
3071
|
-
if ('addons.mozilla.org' !== url.hostname) return null;
|
|
3072
|
-
const match = url.pathname.match(/\/addon\/([^/]+)(?:\/|$)/i);
|
|
3073
|
-
return match ? match[1] : null;
|
|
3074
|
-
}
|
|
3075
|
-
function parseStoreUrl(raw) {
|
|
3076
|
-
let url;
|
|
3077
|
-
try {
|
|
3078
|
-
url = new URL(raw);
|
|
3079
|
-
} catch {
|
|
3080
|
-
return null;
|
|
3081
|
-
}
|
|
3082
|
-
const chromeId = parseChromeWebStoreId(url);
|
|
3083
|
-
if (chromeId) return {
|
|
3084
|
-
browser: 'chrome',
|
|
3085
|
-
id: chromeId
|
|
3086
|
-
};
|
|
3087
|
-
const edgeId = parseEdgeAddonsId(url);
|
|
3088
|
-
if (edgeId) return {
|
|
3089
|
-
browser: 'edge',
|
|
3090
|
-
id: edgeId
|
|
3091
|
-
};
|
|
3092
|
-
const amoSlug = parseAmoSlug(url);
|
|
3093
|
-
if (amoSlug) return {
|
|
3094
|
-
browser: 'firefox',
|
|
3095
|
-
id: amoSlug
|
|
3096
|
-
};
|
|
3097
|
-
return null;
|
|
3098
|
-
}
|
|
3099
|
-
function ensurePathsUnderExtensions(projectRoot, paths) {
|
|
3100
|
-
const extensionsRoot = path__rspack_import_1.resolve(projectRoot, 'extensions');
|
|
3101
|
-
return paths.map((p)=>{
|
|
3102
|
-
const abs = (0, _utils__rspack_import_3.A$)(projectRoot, p);
|
|
3103
|
-
if (abs !== extensionsRoot && !isSubpathOf(extensionsRoot, abs) && path__rspack_import_1.resolve(abs) !== extensionsRoot) throw new Error(`Companion extensions must be inside ${extensionsRoot}.\nInvalid path: ${abs}`);
|
|
3104
|
-
return abs;
|
|
3105
|
-
});
|
|
3106
|
-
}
|
|
3107
|
-
function findExtensionRoots(dir, maxDepth = 3) {
|
|
3108
|
-
const found = [];
|
|
3109
|
-
function walk(current, depth) {
|
|
3110
|
-
if (depth > maxDepth) return;
|
|
3111
|
-
if (!(0, _utils__rspack_import_3.Q7)(current)) return;
|
|
3112
|
-
if ((0, _utils__rspack_import_3.Uy)(current)) return void found.push(current);
|
|
3113
|
-
let entries = [];
|
|
3114
|
-
try {
|
|
3115
|
-
entries = fs__rspack_import_0.readdirSync(current, {
|
|
3116
|
-
withFileTypes: true
|
|
3117
|
-
});
|
|
3118
|
-
} catch {
|
|
3119
|
-
return;
|
|
3120
|
-
}
|
|
3121
|
-
for (const ent of entries)if (ent.isDirectory()) {
|
|
3122
|
-
if (!ent.name.startsWith('.')) walk(path__rspack_import_1.join(current, ent.name), depth + 1);
|
|
3123
|
-
}
|
|
3124
|
-
}
|
|
3125
|
-
walk(dir, 0);
|
|
3126
|
-
return found;
|
|
3127
|
-
}
|
|
3128
|
-
async function runExtensionFromStore(url, outDir) {
|
|
3129
|
-
const isAuthor = 'true' === process.env.EXTENSION_AUTHOR_MODE;
|
|
3130
|
-
await (0, extension_from_store__rspack_import_2.fetchExtensionFromStore)(url, {
|
|
3131
|
-
outDir,
|
|
3132
|
-
extract: true,
|
|
3133
|
-
logger: isAuthor ? {
|
|
3134
|
-
onInfo: (message)=>console.log(message),
|
|
3135
|
-
onWarn: (message)=>console.warn(message),
|
|
3136
|
-
onError: (message, error)=>console.error(message, error)
|
|
3137
|
-
} : void 0
|
|
3138
|
-
});
|
|
3139
|
-
}
|
|
3140
|
-
async function resolveStoreExtensionToPath(opts) {
|
|
3141
|
-
const { projectRoot, storeUrl, browser, id } = opts;
|
|
3142
|
-
const extensionsRoot = path__rspack_import_1.resolve(projectRoot, 'extensions');
|
|
3143
|
-
const targetRoot = path__rspack_import_1.join(extensionsRoot, browser, id);
|
|
3144
|
-
const manifestPath = path__rspack_import_1.join(targetRoot, 'manifest.json');
|
|
3145
|
-
if ((0, _utils__rspack_import_3.fo)(manifestPath)) return targetRoot;
|
|
3146
|
-
await runExtensionFromStore(storeUrl, path__rspack_import_1.join(extensionsRoot, browser));
|
|
3147
|
-
const candidates = findExtensionRoots(path__rspack_import_1.join(extensionsRoot, browser));
|
|
3148
|
-
let selected;
|
|
3149
|
-
if (1 === candidates.length) selected = candidates[0];
|
|
3150
|
-
else if (candidates.length > 1) {
|
|
3151
|
-
const directMatch = candidates.find((c)=>path__rspack_import_1.basename(c) === id);
|
|
3152
|
-
const versionedMatch = candidates.find((c)=>path__rspack_import_1.basename(c).startsWith(`${id}@`));
|
|
3153
|
-
if (directMatch) selected = directMatch;
|
|
3154
|
-
else if (versionedMatch) selected = versionedMatch;
|
|
3155
|
-
}
|
|
3156
|
-
if (!selected) throw new Error(`Could not locate an unpacked extension from ${storeUrl}.`);
|
|
3157
|
-
fs__rspack_import_0.mkdirSync(path__rspack_import_1.dirname(targetRoot), {
|
|
3158
|
-
recursive: true
|
|
3159
|
-
});
|
|
3160
|
-
if (path__rspack_import_1.basename(selected).startsWith(`${id}@`)) fs__rspack_import_0.renameSync(selected, targetRoot);
|
|
3161
|
-
return targetRoot;
|
|
3162
|
-
}
|
|
3163
|
-
async function resolveCompanionExtensionsConfig(opts) {
|
|
3164
|
-
const { projectRoot, browser, config } = opts;
|
|
3165
|
-
if (!config) return;
|
|
3166
|
-
const normalized = (0, _utils__rspack_import_3.cz)(config);
|
|
3167
|
-
const runtimeBrowser = getBrowserFolder(browser);
|
|
3168
|
-
const resolvedPaths = [];
|
|
3169
|
-
const localPaths = [];
|
|
3170
|
-
for (const entry of normalized.paths){
|
|
3171
|
-
const parsedStore = parseStoreUrl(entry);
|
|
3172
|
-
if (parsedStore) {
|
|
3173
|
-
if (parsedStore.browser !== runtimeBrowser) continue;
|
|
3174
|
-
const resolvedPath = await resolveStoreExtensionToPath({
|
|
3175
|
-
projectRoot,
|
|
3176
|
-
storeUrl: entry,
|
|
3177
|
-
browser: parsedStore.browser,
|
|
3178
|
-
id: parsedStore.id
|
|
3179
|
-
});
|
|
3180
|
-
resolvedPaths.push(resolvedPath);
|
|
3181
|
-
continue;
|
|
3182
|
-
}
|
|
3183
|
-
if (isPathLike(entry)) localPaths.push(entry);
|
|
3184
|
-
}
|
|
3185
|
-
if (localPaths.length > 0) {
|
|
3186
|
-
const absLocalPaths = ensurePathsUnderExtensions(projectRoot, localPaths);
|
|
3187
|
-
resolvedPaths.push(...absLocalPaths);
|
|
3188
|
-
}
|
|
3189
|
-
const output = {};
|
|
3190
|
-
if ('string' == typeof normalized.dir) {
|
|
3191
|
-
const absDir = (0, _utils__rspack_import_3.A$)(projectRoot, normalized.dir);
|
|
3192
|
-
const extensionsRoot = path__rspack_import_1.resolve(projectRoot, 'extensions');
|
|
3193
|
-
if (absDir !== extensionsRoot && !isSubpathOf(extensionsRoot, absDir)) throw new Error(`extensions.dir must be inside ${extensionsRoot}.\nInvalid dir: ${absDir}`);
|
|
3194
|
-
output.dir = normalized.dir;
|
|
3195
|
-
}
|
|
3196
|
-
if (resolvedPaths.length > 0) output.paths = resolvedPaths;
|
|
3197
|
-
return output;
|
|
3198
|
-
}
|
|
3199
|
-
},
|
|
3200
|
-
"./plugin-special-folders/folder-extensions/utils.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
3201
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
3202
|
-
A$: ()=>toAbs,
|
|
3203
|
-
Q7: ()=>isDir,
|
|
3204
|
-
Uy: ()=>isValidExtensionRoot,
|
|
3205
|
-
cz: ()=>normalizeCompanionConfig,
|
|
3206
|
-
fo: ()=>isFile
|
|
3207
|
-
});
|
|
3208
|
-
var fs__rspack_import_0 = __webpack_require__("fs");
|
|
3209
|
-
var path__rspack_import_1 = __webpack_require__("path");
|
|
3210
|
-
function isDir(p) {
|
|
3211
|
-
try {
|
|
3212
|
-
return fs__rspack_import_0.existsSync(p) && fs__rspack_import_0.statSync(p).isDirectory();
|
|
3213
|
-
} catch {
|
|
3214
|
-
return false;
|
|
3215
|
-
}
|
|
3216
|
-
}
|
|
3217
|
-
function isFile(p) {
|
|
3218
|
-
try {
|
|
3219
|
-
return fs__rspack_import_0.existsSync(p) && fs__rspack_import_0.statSync(p).isFile();
|
|
3220
|
-
} catch {
|
|
3221
|
-
return false;
|
|
3222
|
-
}
|
|
3223
|
-
}
|
|
3224
|
-
function toAbs(projectRoot, p) {
|
|
3225
|
-
return path__rspack_import_1.isAbsolute(p) ? p : path__rspack_import_1.resolve(projectRoot, p);
|
|
3226
|
-
}
|
|
3227
|
-
function isValidExtensionRoot(dir) {
|
|
3228
|
-
if (!isDir(dir)) return false;
|
|
3229
|
-
return isFile(path__rspack_import_1.join(dir, 'manifest.json'));
|
|
3230
|
-
}
|
|
3231
|
-
function normalizeCompanionConfig(config) {
|
|
3232
|
-
const explicitPaths = [];
|
|
3233
|
-
let scanDir;
|
|
3234
|
-
if (Array.isArray(config)) explicitPaths.push(...config.filter((p)=>'string' == typeof p));
|
|
3235
|
-
else if (config && 'object' == typeof config) {
|
|
3236
|
-
if (Array.isArray(config.paths)) explicitPaths.push(...config.paths.filter((p)=>'string' == typeof p));
|
|
3237
|
-
if ('string' == typeof config.dir && config.dir.trim().length > 0) scanDir = config.dir.trim();
|
|
3238
|
-
}
|
|
3239
|
-
return {
|
|
3240
|
-
dir: scanDir,
|
|
3241
|
-
paths: explicitPaths
|
|
3242
|
-
};
|
|
3243
|
-
}
|
|
3244
|
-
},
|
|
3245
|
-
"./plugin-special-folders/get-data.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
3246
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
3247
|
-
B: ()=>getSpecialFoldersDataForCompiler,
|
|
3248
|
-
H: ()=>getSpecialFoldersDataForProjectRoot
|
|
3249
|
-
});
|
|
3250
|
-
var path__rspack_import_0 = __webpack_require__("path");
|
|
3251
|
-
var path__rspack_import_0_default = /*#__PURE__*/ __webpack_require__.n(path__rspack_import_0);
|
|
3252
|
-
var browser_extension_manifest_fields__rspack_import_1 = __webpack_require__("browser-extension-manifest-fields");
|
|
3253
|
-
function isUnderPublicDir(entry, projectRoot, publicDir) {
|
|
3254
|
-
if (!entry) return false;
|
|
3255
|
-
const normalizedEntry = String(entry);
|
|
3256
|
-
const candidate = path__rspack_import_0_default().isAbsolute(normalizedEntry) ? normalizedEntry : path__rspack_import_0_default().join(projectRoot, normalizedEntry);
|
|
3257
|
-
const rel = path__rspack_import_0_default().relative(publicDir, candidate);
|
|
3258
|
-
return Boolean(rel && !rel.startsWith('..') && !path__rspack_import_0_default().isAbsolute(rel));
|
|
3259
|
-
}
|
|
3260
|
-
function filterPublicEntrypoints(list, projectRoot, publicDir) {
|
|
3261
|
-
const next = {};
|
|
3262
|
-
for (const [key, value] of Object.entries(list || {})){
|
|
3263
|
-
if (Array.isArray(value)) {
|
|
3264
|
-
const filtered = value.filter((entry)=>!isUnderPublicDir(String(entry), projectRoot, publicDir));
|
|
3265
|
-
if (filtered.length > 0) next[key] = filtered;
|
|
3266
|
-
continue;
|
|
3267
|
-
}
|
|
3268
|
-
if ('string' == typeof value) {
|
|
3269
|
-
if (!isUnderPublicDir(value, projectRoot, publicDir)) next[key] = value;
|
|
3270
|
-
continue;
|
|
3271
|
-
}
|
|
3272
|
-
}
|
|
3273
|
-
return next;
|
|
3274
|
-
}
|
|
3275
|
-
function getSpecialFoldersDataForCompiler(compiler) {
|
|
3276
|
-
const projectRoot = compiler.options.context || '';
|
|
3277
|
-
const publicDir = path__rspack_import_0_default().join(projectRoot, 'public');
|
|
3278
|
-
const data = (0, browser_extension_manifest_fields__rspack_import_1.getSpecialFoldersData)({
|
|
3279
|
-
manifestPath: path__rspack_import_0_default().join(projectRoot, 'package.json')
|
|
3280
|
-
});
|
|
3281
|
-
return finalizeSpecialFoldersData(data, projectRoot, publicDir);
|
|
3282
|
-
}
|
|
3283
|
-
function getSpecialFoldersDataForProjectRoot(projectRoot) {
|
|
3284
|
-
const publicDir = path__rspack_import_0_default().join(projectRoot, 'public');
|
|
3285
|
-
const data = (0, browser_extension_manifest_fields__rspack_import_1.getSpecialFoldersData)({
|
|
3286
|
-
manifestPath: path__rspack_import_0_default().join(projectRoot, 'package.json')
|
|
3287
|
-
});
|
|
3288
|
-
return finalizeSpecialFoldersData(data, projectRoot, publicDir);
|
|
3289
|
-
}
|
|
3290
|
-
function finalizeSpecialFoldersData(data, projectRoot, publicDir) {
|
|
3291
|
-
return {
|
|
3292
|
-
...data,
|
|
3293
|
-
pages: filterPublicEntrypoints(data.pages, projectRoot, publicDir),
|
|
3294
|
-
scripts: filterPublicEntrypoints(data.scripts, projectRoot, publicDir),
|
|
3295
|
-
extensions: {
|
|
3296
|
-
dir: './extensions'
|
|
3297
|
-
}
|
|
3298
|
-
};
|
|
3299
|
-
}
|
|
3300
|
-
},
|
|
3301
|
-
"./plugin-web-extension/feature-scripts/contracts.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
3302
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
3303
|
-
$t: ()=>EXTENSIONJS_CONTENT_SCRIPT_LAYER,
|
|
3304
|
-
J4: ()=>getCanonicalContentScriptCssAssetName,
|
|
3305
|
-
Y0: ()=>getCanonicalContentScriptEntryName,
|
|
3306
|
-
es: ()=>parseCanonicalContentScriptAsset,
|
|
3307
|
-
f6: ()=>getCanonicalContentScriptJsAssetName
|
|
3308
|
-
});
|
|
3309
|
-
const EXTENSIONJS_CONTENT_SCRIPT_LAYER = "extensionjs-content-script";
|
|
3310
|
-
const CANONICAL_CONTENT_SCRIPT_ENTRY_PREFIX = "content_scripts/content-";
|
|
3311
|
-
function getCanonicalContentScriptEntryName(index) {
|
|
3312
|
-
return `${CANONICAL_CONTENT_SCRIPT_ENTRY_PREFIX}${index}`;
|
|
3313
|
-
}
|
|
3314
|
-
function getCanonicalContentScriptJsAssetName(index) {
|
|
3315
|
-
return `${getCanonicalContentScriptEntryName(index)}.js`;
|
|
3316
|
-
}
|
|
3317
|
-
function getCanonicalContentScriptCssAssetName(index) {
|
|
3318
|
-
return `${getCanonicalContentScriptEntryName(index)}.css`;
|
|
3319
|
-
}
|
|
3320
|
-
function parseCanonicalContentScriptAsset(assetName) {
|
|
3321
|
-
const match = /^content_scripts\/content-(\d+)(?:\.[a-f0-9]+)?\.(js|css)$/i.exec(String(assetName || ''));
|
|
3322
|
-
if (!match) return;
|
|
3323
|
-
const index = Number(match[1]);
|
|
3324
|
-
if (!Number.isInteger(index)) return;
|
|
3325
|
-
return {
|
|
3326
|
-
index,
|
|
3327
|
-
extension: match[2]
|
|
3328
|
-
};
|
|
3329
|
-
}
|
|
3330
|
-
},
|
|
3331
|
-
"@rspack/core" (module) {
|
|
3332
|
-
module.exports = require("@rspack/core");
|
|
3333
|
-
},
|
|
3334
|
-
"@rspack/dev-server" (module) {
|
|
3335
|
-
module.exports = require("@rspack/dev-server");
|
|
3336
|
-
},
|
|
3337
|
-
"adm-zip" (module) {
|
|
3338
|
-
module.exports = require("adm-zip");
|
|
3339
|
-
},
|
|
3340
|
-
"browser-extension-manifest-fields" (module) {
|
|
3341
|
-
module.exports = require("browser-extension-manifest-fields");
|
|
3342
|
-
},
|
|
3343
|
-
"case-sensitive-paths-webpack-plugin" (module) {
|
|
3344
|
-
module.exports = require("case-sensitive-paths-webpack-plugin");
|
|
3345
|
-
},
|
|
3346
|
-
"content-security-policy-parser" (module) {
|
|
3347
|
-
module.exports = require("content-security-policy-parser");
|
|
3348
|
-
},
|
|
3349
|
-
crypto (module) {
|
|
3350
|
-
module.exports = require("crypto");
|
|
3351
|
-
},
|
|
3352
|
-
dotenv (module) {
|
|
3353
|
-
module.exports = require("dotenv");
|
|
3354
|
-
},
|
|
3355
|
-
"extension-from-store" (module) {
|
|
3356
|
-
module.exports = require("extension-from-store");
|
|
3357
|
-
},
|
|
3358
|
-
fs (module) {
|
|
3359
|
-
module.exports = require("fs");
|
|
3360
|
-
},
|
|
3361
|
-
ignore (module) {
|
|
3362
|
-
module.exports = require("ignore");
|
|
3363
|
-
},
|
|
3364
|
-
module (module) {
|
|
3365
|
-
module.exports = require("module");
|
|
3366
|
-
},
|
|
3367
|
-
net (module) {
|
|
3368
|
-
module.exports = require("net");
|
|
3369
|
-
},
|
|
3370
|
-
os (module) {
|
|
3371
|
-
module.exports = require("os");
|
|
3372
|
-
},
|
|
3373
|
-
"parse5-utilities" (module) {
|
|
3374
|
-
module.exports = require("parse5-utilities");
|
|
3375
|
-
},
|
|
3376
|
-
path (module) {
|
|
3377
|
-
module.exports = require("path");
|
|
3378
|
-
},
|
|
3379
|
-
pintor (module) {
|
|
3380
|
-
module.exports = require("pintor");
|
|
3381
|
-
},
|
|
3382
|
-
stream (module) {
|
|
3383
|
-
module.exports = require("stream");
|
|
3384
|
-
},
|
|
3385
|
-
"tiny-glob" (module) {
|
|
3386
|
-
module.exports = require("tiny-glob");
|
|
3387
|
-
},
|
|
3388
|
-
url (module) {
|
|
3389
|
-
module.exports = require("url");
|
|
3390
|
-
},
|
|
3391
|
-
vm (module) {
|
|
3392
|
-
module.exports = require("vm");
|
|
3393
|
-
},
|
|
3394
|
-
"webpack-merge" (module) {
|
|
3395
|
-
module.exports = require("webpack-merge");
|
|
3396
|
-
},
|
|
3397
|
-
"./package.json" (module) {
|
|
3398
|
-
module.exports = JSON.parse('{"rE":"3.15.1","El":{"@prefresh/core":"1.5.9","@prefresh/utils":"1.2.1","@rspack/core":"^2.0.1","@rspack/dev-server":"^2.0.1","@rspack/plugin-preact-refresh":"1.1.5","@rspack/plugin-react-refresh":"1.6.2","@swc/core":"^1.15.8","@swc/helpers":"^0.5.18","@vue/compiler-sfc":"3.5.26","adm-zip":"^0.5.16","browser-extension-manifest-fields":"^2.2.3","case-sensitive-paths-webpack-plugin":"^2.4.0","content-security-policy-parser":"^0.6.0","cross-spawn":"^7.0.6","dotenv":"^17.2.3","extension-from-store":"^0.1.1","go-git-it":"^5.1.5","ignore":"^7.0.5","less":"4.5.1","less-loader":"12.3.2","loader-utils":"^3.3.1","magic-string":"^0.30.21","parse5-utilities":"^1.0.0","pintor":"0.3.0","postcss":"8.5.10","postcss-loader":"8.2.1","postcss-preset-env":"11.1.1","postcss-scss":"4.0.9","preact":"10.27.3","react-refresh":"0.18.0","sass-loader":"16.0.7","schema-utils":"^4.3.3","svelte-loader":"3.2.4","tiny-glob":"^0.2.9","typescript":"5.9.3","unique-names-generator":"^4.7.1","vue":"3.5.26","vue-loader":"17.4.2","webextension-polyfill":"^0.12.0","webpack-merge":"^6.0.1","webpack-target-webextension":"^2.1.3"}}');
|
|
3399
|
-
}
|
|
3400
|
-
};
|
|
3401
|
-
var __webpack_module_cache__ = {};
|
|
3402
|
-
function __webpack_require__(moduleId) {
|
|
3403
|
-
var cachedModule = __webpack_module_cache__[moduleId];
|
|
3404
|
-
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
3405
|
-
var module = __webpack_module_cache__[moduleId] = {
|
|
3406
|
-
exports: {}
|
|
3407
|
-
};
|
|
3408
|
-
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
3409
|
-
return module.exports;
|
|
3410
|
-
}
|
|
3411
|
-
__webpack_require__.m = __webpack_modules__;
|
|
3412
|
-
(()=>{
|
|
3413
|
-
__webpack_require__.n = (module)=>{
|
|
3414
|
-
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
3415
|
-
__webpack_require__.d(getter, {
|
|
3416
|
-
a: getter
|
|
3417
|
-
});
|
|
3418
|
-
return getter;
|
|
3419
|
-
};
|
|
3420
|
-
})();
|
|
3421
|
-
(()=>{
|
|
3422
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
3423
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
3424
|
-
enumerable: true,
|
|
3425
|
-
get: definition[key]
|
|
3426
|
-
});
|
|
3427
|
-
};
|
|
3428
|
-
})();
|
|
3429
|
-
(()=>{
|
|
3430
|
-
__webpack_require__.f = {};
|
|
3431
|
-
__webpack_require__.e = (chunkId)=>Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key)=>{
|
|
3432
|
-
__webpack_require__.f[key](chunkId, promises);
|
|
3433
|
-
return promises;
|
|
3434
|
-
}, []));
|
|
3435
|
-
})();
|
|
3436
|
-
(()=>{
|
|
3437
|
-
__webpack_require__.u = (chunkId)=>"" + chunkId + ".cjs";
|
|
3438
|
-
})();
|
|
3439
|
-
(()=>{
|
|
3440
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
3441
|
-
})();
|
|
3442
|
-
(()=>{
|
|
3443
|
-
__webpack_require__.r = (exports1)=>{
|
|
3444
|
-
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
3445
|
-
value: 'Module'
|
|
3446
|
-
});
|
|
3447
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
3448
|
-
value: true
|
|
3449
|
-
});
|
|
3450
|
-
};
|
|
3451
|
-
})();
|
|
3452
|
-
(()=>{
|
|
3453
|
-
var installedChunks = {
|
|
3454
|
-
364: 1
|
|
3455
|
-
};
|
|
3456
|
-
var installChunk = (chunk)=>{
|
|
3457
|
-
var moreModules = chunk.modules, chunkIds = chunk.ids, runtime = chunk.runtime;
|
|
3458
|
-
for(var moduleId in moreModules)if (__webpack_require__.o(moreModules, moduleId)) __webpack_require__.m[moduleId] = moreModules[moduleId];
|
|
3459
|
-
if (runtime) runtime(__webpack_require__);
|
|
3460
|
-
for(var i = 0; i < chunkIds.length; i++)installedChunks[chunkIds[i]] = 1;
|
|
3461
|
-
};
|
|
3462
|
-
__webpack_require__.f.require = (chunkId, promises)=>{
|
|
3463
|
-
if (!installedChunks[chunkId]) installChunk(require("./" + __webpack_require__.u(chunkId)));
|
|
3464
|
-
};
|
|
3465
|
-
})();
|
|
3466
|
-
var __webpack_exports__ = __webpack_require__("./module.ts");
|
|
3467
|
-
exports.BuildEmitter = __webpack_exports__.BuildEmitter;
|
|
3468
|
-
exports.extensionBuild = __webpack_exports__.extensionBuild;
|
|
3469
|
-
exports.extensionDev = __webpack_exports__.extensionDev;
|
|
3470
|
-
exports.extensionPreview = __webpack_exports__.extensionPreview;
|
|
3471
|
-
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
3472
|
-
"BuildEmitter",
|
|
3473
|
-
"extensionBuild",
|
|
3474
|
-
"extensionDev",
|
|
3475
|
-
"extensionPreview"
|
|
3476
|
-
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
3477
|
-
Object.defineProperty(exports, '__esModule', {
|
|
3478
|
-
value: true
|
|
3479
|
-
});
|