extension-develop 3.9.0-next.3 → 3.9.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/{946.cjs → 270.cjs} +6050 -5966
- package/dist/323.cjs +35 -16
- package/dist/324.cjs +146 -12
- package/dist/552.cjs +1 -1
- package/dist/module.cjs +108 -22
- package/dist/warn-no-default-export.cjs +74 -30
- package/package.json +1 -1
package/dist/323.cjs
CHANGED
|
@@ -268,20 +268,7 @@ exports.modules = {
|
|
|
268
268
|
class CDPExtensionController {
|
|
269
269
|
async connect() {
|
|
270
270
|
if (this.cdp) return;
|
|
271
|
-
|
|
272
|
-
try {
|
|
273
|
-
await this.cdp.sendCommand('Target.setDiscoverTargets', {
|
|
274
|
-
discover: true
|
|
275
|
-
});
|
|
276
|
-
await this.cdp.sendCommand('Target.setAutoAttach', {
|
|
277
|
-
autoAttach: true,
|
|
278
|
-
waitForDebuggerOnStart: false,
|
|
279
|
-
flatten: true
|
|
280
|
-
});
|
|
281
|
-
} catch (error) {
|
|
282
|
-
if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.warn(messages.wXK(String(error?.message || error)));
|
|
283
|
-
}
|
|
284
|
-
registerAutoEnableLogging(this.cdp, ()=>this.extensionId);
|
|
271
|
+
await this.connectFreshClient();
|
|
285
272
|
}
|
|
286
273
|
async ensureLoaded() {
|
|
287
274
|
if (!this.cdp) throw new Error('CDP not connected');
|
|
@@ -414,13 +401,45 @@ exports.modules = {
|
|
|
414
401
|
return 'unknown';
|
|
415
402
|
}
|
|
416
403
|
async hardReload() {
|
|
417
|
-
if (!this.
|
|
404
|
+
if (!this.extensionId) return false;
|
|
418
405
|
try {
|
|
419
|
-
|
|
406
|
+
if (!this.cdp) await this.connectFreshClient();
|
|
407
|
+
if (this.cdp && await this.cdp.forceReloadExtension(this.extensionId)) return true;
|
|
408
|
+
} catch {}
|
|
409
|
+
try {
|
|
410
|
+
await this.reconnectForReload();
|
|
411
|
+
return Boolean(this.cdp && this.extensionId && await this.cdp.forceReloadExtension(this.extensionId));
|
|
420
412
|
} catch {
|
|
421
413
|
return false;
|
|
422
414
|
}
|
|
423
415
|
}
|
|
416
|
+
async connectFreshClient() {
|
|
417
|
+
this.cdp = await connectToChromeCdp(this.cdpPort);
|
|
418
|
+
try {
|
|
419
|
+
await this.cdp.sendCommand('Target.setDiscoverTargets', {
|
|
420
|
+
discover: true
|
|
421
|
+
});
|
|
422
|
+
await this.cdp.sendCommand('Target.setAutoAttach', {
|
|
423
|
+
autoAttach: true,
|
|
424
|
+
waitForDebuggerOnStart: false,
|
|
425
|
+
flatten: true
|
|
426
|
+
});
|
|
427
|
+
} catch (error) {
|
|
428
|
+
if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.warn(messages.wXK(String(error?.message || error)));
|
|
429
|
+
}
|
|
430
|
+
registerAutoEnableLogging(this.cdp, ()=>this.extensionId);
|
|
431
|
+
}
|
|
432
|
+
async reconnectForReload() {
|
|
433
|
+
try {
|
|
434
|
+
this.cdp?.disconnect?.();
|
|
435
|
+
} catch {}
|
|
436
|
+
this.cdp = null;
|
|
437
|
+
await this.connectFreshClient();
|
|
438
|
+
try {
|
|
439
|
+
const derivedExtensionId = await this.deriveExtensionIdFromTargets(10, 150);
|
|
440
|
+
if (derivedExtensionId) this.extensionId = derivedExtensionId;
|
|
441
|
+
} catch {}
|
|
442
|
+
}
|
|
424
443
|
onProtocolEvent(cb) {
|
|
425
444
|
if (!this.cdp) throw new Error('CDP not connected');
|
|
426
445
|
this.cdp.onProtocolEvent((raw)=>{
|
package/dist/324.cjs
CHANGED
|
@@ -7,7 +7,10 @@ exports.modules = {
|
|
|
7
7
|
__webpack_require__.d(__webpack_exports__, {
|
|
8
8
|
devServer: ()=>dev_server_devServer
|
|
9
9
|
});
|
|
10
|
+
var external_fs_ = __webpack_require__("fs");
|
|
11
|
+
var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_);
|
|
10
12
|
var external_path_ = __webpack_require__("path");
|
|
13
|
+
var external_stream_ = __webpack_require__("stream");
|
|
11
14
|
var core_ = __webpack_require__("@rspack/core");
|
|
12
15
|
var dev_server_ = __webpack_require__("@rspack/dev-server");
|
|
13
16
|
var external_webpack_merge_ = __webpack_require__("webpack-merge");
|
|
@@ -88,7 +91,6 @@ exports.modules = {
|
|
|
88
91
|
this.basePort = basePort;
|
|
89
92
|
}
|
|
90
93
|
}
|
|
91
|
-
var external_fs_ = __webpack_require__("fs");
|
|
92
94
|
function hasDependency(projectPath, dependency) {
|
|
93
95
|
const findNearestPackageJsonDirectory = (startPath)=>{
|
|
94
96
|
let currentDirectory = startPath;
|
|
@@ -213,6 +215,139 @@ exports.modules = {
|
|
|
213
215
|
function shouldWriteAssetToDisk(filePath) {
|
|
214
216
|
return !/(?:^|[/\\])manifest\.json$/i.test(filePath);
|
|
215
217
|
}
|
|
218
|
+
function isSamePath(left, right) {
|
|
219
|
+
return external_path_.resolve(left) === external_path_.resolve(right);
|
|
220
|
+
}
|
|
221
|
+
function isManifestTempPath(filePath) {
|
|
222
|
+
const base = external_path_.basename(filePath);
|
|
223
|
+
return base.startsWith('.manifest.') && base.endsWith('.tmp');
|
|
224
|
+
}
|
|
225
|
+
function createDiscardWriteStream() {
|
|
226
|
+
const stream = new external_stream_.Writable({
|
|
227
|
+
write (_chunk, _encoding, callback) {
|
|
228
|
+
callback();
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
stream.on('finish', ()=>{
|
|
232
|
+
stream.emit('close');
|
|
233
|
+
});
|
|
234
|
+
process.nextTick(()=>{
|
|
235
|
+
stream.emit('open', 0);
|
|
236
|
+
});
|
|
237
|
+
return stream;
|
|
238
|
+
}
|
|
239
|
+
const guardedManifestDiskWritePaths = new Set();
|
|
240
|
+
let isManifestDiskWriteGuardInstalled = false;
|
|
241
|
+
function hasGuardedManifestDiskPath(filePath) {
|
|
242
|
+
if ('string' != typeof filePath) return false;
|
|
243
|
+
const resolvedPath = external_path_.resolve(filePath);
|
|
244
|
+
for (const guardedPath of guardedManifestDiskWritePaths)if (isSamePath(guardedPath, resolvedPath)) return true;
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
function suppressManifestOutputWrites(compiler, manifestOutputPath) {
|
|
248
|
+
const outputFileSystem = compiler?.outputFileSystem;
|
|
249
|
+
if (!outputFileSystem || outputFileSystem.__extensionjsManifestWriteGuard) return;
|
|
250
|
+
const isManifestPath = (filePath)=>'string' == typeof filePath && isSamePath(filePath, manifestOutputPath);
|
|
251
|
+
if ('function' == typeof outputFileSystem.writeFile) {
|
|
252
|
+
const originalWriteFile = outputFileSystem.writeFile.bind(outputFileSystem);
|
|
253
|
+
outputFileSystem.writeFile = (filePath, ...args)=>{
|
|
254
|
+
if (isManifestPath(filePath)) {
|
|
255
|
+
const callback = args[args.length - 1];
|
|
256
|
+
if ('function' == typeof callback) callback(null);
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
return originalWriteFile(filePath, ...args);
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
if ('function' == typeof outputFileSystem.writeFileSync) {
|
|
263
|
+
const originalWriteFileSync = outputFileSystem.writeFileSync.bind(outputFileSystem);
|
|
264
|
+
outputFileSystem.writeFileSync = (filePath, ...args)=>{
|
|
265
|
+
if (isManifestPath(filePath)) return;
|
|
266
|
+
return originalWriteFileSync(filePath, ...args);
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
if ('function' == typeof outputFileSystem.createWriteStream) {
|
|
270
|
+
const originalCreateWriteStream = outputFileSystem.createWriteStream.bind(outputFileSystem);
|
|
271
|
+
outputFileSystem.createWriteStream = (filePath, ...args)=>{
|
|
272
|
+
if (isManifestPath(filePath)) {
|
|
273
|
+
const stream = createDiscardWriteStream();
|
|
274
|
+
stream.path = filePath;
|
|
275
|
+
return stream;
|
|
276
|
+
}
|
|
277
|
+
return originalCreateWriteStream(filePath, ...args);
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
if ('function' == typeof outputFileSystem?.promises?.writeFile) {
|
|
281
|
+
const originalPromiseWriteFile = outputFileSystem.promises.writeFile.bind(outputFileSystem.promises);
|
|
282
|
+
outputFileSystem.promises.writeFile = async (filePath, ...args)=>{
|
|
283
|
+
if (isManifestPath(filePath)) return;
|
|
284
|
+
return originalPromiseWriteFile(filePath, ...args);
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
outputFileSystem.__extensionjsManifestWriteGuard = true;
|
|
288
|
+
}
|
|
289
|
+
function installManifestDiskWriteGuard(manifestOutputPath) {
|
|
290
|
+
const guardKey = external_path_.resolve(manifestOutputPath);
|
|
291
|
+
guardedManifestDiskWritePaths.add(guardKey);
|
|
292
|
+
if (isManifestDiskWriteGuardInstalled) return;
|
|
293
|
+
const guardedFs = external_fs_default();
|
|
294
|
+
const isManifestPath = (filePath)=>hasGuardedManifestDiskPath(filePath);
|
|
295
|
+
const allowManifestRename = (fromPath, toPath)=>'string' == typeof fromPath && 'string' == typeof toPath && isManifestPath(toPath) && isManifestTempPath(fromPath);
|
|
296
|
+
const originalWriteFile = guardedFs.writeFile.bind(guardedFs);
|
|
297
|
+
guardedFs.writeFile = (filePath, ...args)=>{
|
|
298
|
+
if (isManifestPath(filePath)) {
|
|
299
|
+
const callback = args[args.length - 1];
|
|
300
|
+
if ('function' == typeof callback) callback(null);
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
return originalWriteFile(filePath, ...args);
|
|
304
|
+
};
|
|
305
|
+
const originalWriteFileSync = guardedFs.writeFileSync.bind(guardedFs);
|
|
306
|
+
guardedFs.writeFileSync = (filePath, ...args)=>{
|
|
307
|
+
if (isManifestPath(filePath)) return;
|
|
308
|
+
return originalWriteFileSync(filePath, ...args);
|
|
309
|
+
};
|
|
310
|
+
const originalCreateWriteStream = guardedFs.createWriteStream.bind(guardedFs);
|
|
311
|
+
guardedFs.createWriteStream = (filePath, ...args)=>{
|
|
312
|
+
if (isManifestPath(filePath)) {
|
|
313
|
+
const stream = createDiscardWriteStream();
|
|
314
|
+
stream.path = String(filePath);
|
|
315
|
+
return stream;
|
|
316
|
+
}
|
|
317
|
+
return originalCreateWriteStream(filePath, ...args);
|
|
318
|
+
};
|
|
319
|
+
const originalOpen = guardedFs.open.bind(guardedFs);
|
|
320
|
+
guardedFs.open = (pathLike, flags, ...args)=>{
|
|
321
|
+
const nextPath = isManifestPath(pathLike) ? '/dev/null' : pathLike;
|
|
322
|
+
return originalOpen(nextPath, flags, ...args);
|
|
323
|
+
};
|
|
324
|
+
const originalOpenSync = guardedFs.openSync.bind(guardedFs);
|
|
325
|
+
guardedFs.openSync = (pathLike, flags, ...args)=>{
|
|
326
|
+
const nextPath = isManifestPath(pathLike) ? '/dev/null' : pathLike;
|
|
327
|
+
return originalOpenSync(nextPath, flags, ...args);
|
|
328
|
+
};
|
|
329
|
+
const originalRename = guardedFs.rename.bind(guardedFs);
|
|
330
|
+
guardedFs.rename = (oldPath, newPath, callback)=>{
|
|
331
|
+
if (isManifestPath(newPath) && !allowManifestRename(oldPath, newPath)) {
|
|
332
|
+
if ('function' == typeof callback) callback(null);
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
return originalRename(oldPath, newPath, callback);
|
|
336
|
+
};
|
|
337
|
+
const originalRenameSync = guardedFs.renameSync.bind(guardedFs);
|
|
338
|
+
guardedFs.renameSync = (oldPath, newPath)=>{
|
|
339
|
+
if (isManifestPath(newPath) && !allowManifestRename(oldPath, newPath)) return;
|
|
340
|
+
return originalRenameSync(oldPath, newPath);
|
|
341
|
+
};
|
|
342
|
+
if (guardedFs.promises?.writeFile) {
|
|
343
|
+
const originalPromiseWriteFile = guardedFs.promises.writeFile.bind(guardedFs.promises);
|
|
344
|
+
guardedFs.promises.writeFile = async (filePath, ...args)=>{
|
|
345
|
+
if (isManifestPath(filePath)) return;
|
|
346
|
+
return originalPromiseWriteFile(filePath, ...args);
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
isManifestDiskWriteGuardInstalled = true;
|
|
350
|
+
}
|
|
216
351
|
async function dev_server_devServer(projectStructure, devOptions) {
|
|
217
352
|
process.env.EXTENSION_BROWSER_LAUNCH_ENABLED = devOptions.noBrowser ? '0' : '1';
|
|
218
353
|
const { manifestPath, packageJsonPath } = projectStructure;
|
|
@@ -272,6 +407,9 @@ exports.modules = {
|
|
|
272
407
|
}
|
|
273
408
|
};
|
|
274
409
|
const compiler = (0, core_.rspack)(compilerConfig);
|
|
410
|
+
const manifestOutputPath = external_path_.join(packageJsonDir, 'dist', devOptions.browser, 'manifest.json');
|
|
411
|
+
installManifestDiskWriteGuard(manifestOutputPath);
|
|
412
|
+
suppressManifestOutputWrites(compiler, manifestOutputPath);
|
|
275
413
|
const metadata = (0, plugin_playwright.Ih)({
|
|
276
414
|
packageJsonDir,
|
|
277
415
|
browser: String(devOptions.browser || 'chromium'),
|
|
@@ -280,7 +418,13 @@ exports.modules = {
|
|
|
280
418
|
manifestPath,
|
|
281
419
|
port
|
|
282
420
|
});
|
|
283
|
-
(0, compiler_hooks.
|
|
421
|
+
(0, compiler_hooks.NP)(compiler);
|
|
422
|
+
if (devOptions.noBrowser) (0, compiler_hooks.y1)({
|
|
423
|
+
compiler,
|
|
424
|
+
browser: String(devOptions.browser || 'chromium'),
|
|
425
|
+
manifestPath,
|
|
426
|
+
readyPath: metadata.readyPath
|
|
427
|
+
});
|
|
284
428
|
if (void 0 !== devOptions.port && devOptions.port !== port) console.log(messages.aO(devOptions.port, port));
|
|
285
429
|
const serverConfig = {
|
|
286
430
|
host: devServerHost,
|
|
@@ -332,16 +476,6 @@ exports.modules = {
|
|
|
332
476
|
}, START_TIMEOUT_MS);
|
|
333
477
|
await devServer.start();
|
|
334
478
|
if (startTimeout) clearTimeout(startTimeout);
|
|
335
|
-
if (devOptions.noBrowser) {
|
|
336
|
-
console.log(messages.Gc('development', devOptions.browser));
|
|
337
|
-
console.log(messages.tl());
|
|
338
|
-
console.log(messages.bL({
|
|
339
|
-
browser: String(devOptions.browser || 'chromium'),
|
|
340
|
-
manifestPath,
|
|
341
|
-
readyPath: metadata.readyPath
|
|
342
|
-
}));
|
|
343
|
-
}
|
|
344
|
-
console.log(messages.tl());
|
|
345
479
|
} catch (error) {
|
|
346
480
|
if (startTimeout) clearTimeout(startTimeout);
|
|
347
481
|
metadata.writeError('dev_server_start_failed', error instanceof Error ? error.message : String(error));
|
package/dist/552.cjs
CHANGED
|
@@ -11,7 +11,7 @@ exports.modules = {
|
|
|
11
11
|
function scrubBrand(txt, brand = 'Extension.js') {
|
|
12
12
|
if (!txt) return txt;
|
|
13
13
|
const safeBrand = brand.replace(/\$/g, '$$$$');
|
|
14
|
-
return txt.replace(RegExp("(?<!@)\\bRspack\\b", "gi"), safeBrand).replace(RegExp("(?<!@)\\bWebpack\\b", "gi"), safeBrand).replace(RegExp("(?<!@)\\bwebpack-dev-server\\b", "gi"), `${safeBrand} dev server`).replace(RegExp("(?<!@)\\bRspackDevServer\\b", "gi"), `${safeBrand} dev server`).replace(/ModuleBuildError:\s*/g, '').replace(/ModuleParseError:\s*/g, '').replace(/Error:\s*Module\s+build\s+failed.*?\n/gi, '').replace(/\n{3,}/g, '\n\n');
|
|
14
|
+
return txt.replace(RegExp("(?<!@)\\bRspack\\b", "gi"), safeBrand).replace(RegExp("(?<!@)\\bWebpack\\b", "gi"), safeBrand).replace(RegExp("(?<!@)\\bwebpack-dev-server\\b", "gi"), `${safeBrand} dev server`).replace(RegExp("(?<!@)\\bRspackDevServer\\b", "gi"), `${safeBrand} dev server`).replace(/ModuleBuildError:\s*/g, '').replace(/ModuleParseError:\s*/g, '').replace(/Error:\s*Module\s+build\s+failed.*?\n/gi, '').replace(/\n{3,}/g, '\n\n').replace(/\n{2}(?=WARNING in )/g, '\n');
|
|
15
15
|
}
|
|
16
16
|
function makeSanitizedConsole(brand = 'Extension.js') {
|
|
17
17
|
const sanitize = (a)=>'string' == typeof a ? scrubBrand(a, brand) : a;
|
package/dist/module.cjs
CHANGED
|
@@ -129186,7 +129186,6 @@ var __webpack_modules__ = {
|
|
|
129186
129186
|
async function maybePrintDevBanner(args) {
|
|
129187
129187
|
const mode = args.compilation?.options?.mode || 'development';
|
|
129188
129188
|
if ('development' !== mode) return;
|
|
129189
|
-
if (args.enableCdp) return;
|
|
129190
129189
|
const loadExtensionFlag = args.chromiumConfig.find((flag)=>flag.startsWith('--load-extension='));
|
|
129191
129190
|
const extensionOutputPath = (0, extension_output_path.W)(args.compilation, loadExtensionFlag);
|
|
129192
129191
|
if (!extensionOutputPath) return;
|
|
@@ -129194,6 +129193,7 @@ var __webpack_modules__ = {
|
|
|
129194
129193
|
timeoutMs: 10000
|
|
129195
129194
|
});
|
|
129196
129195
|
if (!ready) return;
|
|
129196
|
+
if (args.enableCdp) return;
|
|
129197
129197
|
await (0, banner.a)({
|
|
129198
129198
|
browser: args.browser,
|
|
129199
129199
|
outPath: extensionOutputPath,
|
|
@@ -129226,7 +129226,7 @@ var __webpack_modules__ = {
|
|
|
129226
129226
|
if (this.didLaunch) return;
|
|
129227
129227
|
await this.launchChromium(stats.compilation);
|
|
129228
129228
|
this.didLaunch = true;
|
|
129229
|
-
if (!this.didReportReady)
|
|
129229
|
+
if (!this.didReportReady) console.log(dev_server_messages.Gc(stats.compilation.options.mode, this.options.browser));
|
|
129230
129230
|
} catch (error) {
|
|
129231
129231
|
try {
|
|
129232
129232
|
this.logger.error(messages._D4(this.options.browser, error));
|
|
@@ -129280,9 +129280,10 @@ var __webpack_modules__ = {
|
|
|
129280
129280
|
return 'npx extension install chrome';
|
|
129281
129281
|
}
|
|
129282
129282
|
};
|
|
129283
|
+
const isAuthorMode = 'true' === process.env.EXTENSION_AUTHOR_MODE;
|
|
129283
129284
|
switch(browser){
|
|
129284
129285
|
case 'chrome':
|
|
129285
|
-
console.log(messages.GqE(browser));
|
|
129286
|
+
if (isAuthorMode) console.log(messages.GqE(browser));
|
|
129286
129287
|
if (!skipDetection) try {
|
|
129287
129288
|
try {
|
|
129288
129289
|
const located = (0, external_chrome_location2_.locateChromeOrExplain)({
|
|
@@ -129319,7 +129320,7 @@ var __webpack_modules__ = {
|
|
|
129319
129320
|
}
|
|
129320
129321
|
break;
|
|
129321
129322
|
case 'chromium':
|
|
129322
|
-
console.log(messages.GqE(browser));
|
|
129323
|
+
if (isAuthorMode) console.log(messages.GqE(browser));
|
|
129323
129324
|
browserBinaryLocation = this.options?.chromiumBinary || null;
|
|
129324
129325
|
if (this.options?.chromiumBinary) {
|
|
129325
129326
|
const normalized = normalizePath(String(this.options.chromiumBinary));
|
|
@@ -129339,7 +129340,7 @@ var __webpack_modules__ = {
|
|
|
129339
129340
|
if (!browserBinaryLocation) browserBinaryLocation = resolveWslWindowsBinary(browser);
|
|
129340
129341
|
break;
|
|
129341
129342
|
case 'edge':
|
|
129342
|
-
console.log(messages.GqE(browser));
|
|
129343
|
+
if (isAuthorMode) console.log(messages.GqE(browser));
|
|
129343
129344
|
try {
|
|
129344
129345
|
const override = String(process.env.EDGE_BINARY || '').trim();
|
|
129345
129346
|
if (override) {
|
|
@@ -129515,7 +129516,7 @@ var __webpack_modules__ = {
|
|
|
129515
129516
|
if (this.options.dryRun) return void logChromiumDryRun(browserBinaryLocation, chromiumConfig);
|
|
129516
129517
|
await this.launchWithDirectSpawn(browserBinaryLocation, chromiumConfig);
|
|
129517
129518
|
if ('development' === compilation.options.mode && !this.didReportReady) {
|
|
129518
|
-
|
|
129519
|
+
console.log(dev_server_messages.Gc(compilation.options.mode, this.options.browser));
|
|
129519
129520
|
this.didReportReady = true;
|
|
129520
129521
|
}
|
|
129521
129522
|
try {
|
|
@@ -129656,6 +129657,42 @@ var __webpack_modules__ = {
|
|
|
129656
129657
|
return;
|
|
129657
129658
|
}
|
|
129658
129659
|
}
|
|
129660
|
+
function normalizeManifestFile(filePath) {
|
|
129661
|
+
if ('string' != typeof filePath) return;
|
|
129662
|
+
const normalized = filePath.trim().replace(/^\/+/, '');
|
|
129663
|
+
if (!normalized) return;
|
|
129664
|
+
if (/^(https?:)?\/\//i.test(filePath)) return;
|
|
129665
|
+
if (/[*?[\]{}]/.test(normalized)) return;
|
|
129666
|
+
return normalized;
|
|
129667
|
+
}
|
|
129668
|
+
function getManifestRequiredFiles(content) {
|
|
129669
|
+
try {
|
|
129670
|
+
const manifest = JSON.parse(content);
|
|
129671
|
+
const requiredFiles = new Set();
|
|
129672
|
+
const addFile = (filePath)=>{
|
|
129673
|
+
const normalized = normalizeManifestFile(filePath);
|
|
129674
|
+
if (normalized) requiredFiles.add(normalized);
|
|
129675
|
+
};
|
|
129676
|
+
addFile(manifest.background?.service_worker);
|
|
129677
|
+
addFile(manifest.background?.page);
|
|
129678
|
+
if (Array.isArray(manifest.background?.scripts)) for (const script of manifest.background?.scripts || [])addFile(script);
|
|
129679
|
+
addFile(manifest.side_panel?.default_path);
|
|
129680
|
+
if (Array.isArray(manifest.content_scripts)) for (const contentScript of manifest.content_scripts){
|
|
129681
|
+
if (Array.isArray(contentScript?.js)) for (const jsFile of contentScript.js)addFile(jsFile);
|
|
129682
|
+
if (Array.isArray(contentScript?.css)) for (const cssFile of contentScript.css)addFile(cssFile);
|
|
129683
|
+
}
|
|
129684
|
+
return [
|
|
129685
|
+
...requiredFiles
|
|
129686
|
+
];
|
|
129687
|
+
} catch {
|
|
129688
|
+
return [];
|
|
129689
|
+
}
|
|
129690
|
+
}
|
|
129691
|
+
function hasRequiredManifestFiles(outPath, content) {
|
|
129692
|
+
const requiredFiles = getManifestRequiredFiles(content);
|
|
129693
|
+
for (const relativeFile of requiredFiles)if (!fs__rspack_import_0.existsSync(path__rspack_import_1.join(outPath, relativeFile))) return false;
|
|
129694
|
+
return true;
|
|
129695
|
+
}
|
|
129659
129696
|
async function waitForStableManifest(outPath, options) {
|
|
129660
129697
|
const timeoutMs = options?.timeoutMs ?? 8000;
|
|
129661
129698
|
const pollIntervalMs = options?.pollIntervalMs ?? 150;
|
|
@@ -129666,7 +129703,7 @@ var __webpack_modules__ = {
|
|
|
129666
129703
|
let stableReads = 0;
|
|
129667
129704
|
while(Date.now() - start < timeoutMs){
|
|
129668
129705
|
const currentContent = readValidManifest(manifestPath);
|
|
129669
|
-
if (currentContent) {
|
|
129706
|
+
if (currentContent && hasRequiredManifestFiles(outPath, currentContent)) {
|
|
129670
129707
|
if (currentContent === lastValidContent) stableReads += 1;
|
|
129671
129708
|
else {
|
|
129672
129709
|
lastValidContent = currentContent;
|
|
@@ -134154,13 +134191,17 @@ var __webpack_modules__ = {
|
|
|
134154
134191
|
return `${getLoggingPrefix('success')} Dependencies installed. Run the command again to proceed.`;
|
|
134155
134192
|
}
|
|
134156
134193
|
function buildWebpack(projectDir, stats, browser) {
|
|
134157
|
-
const statsJson = stats?.toJson(
|
|
134194
|
+
const statsJson = stats?.toJson({
|
|
134195
|
+
all: false,
|
|
134196
|
+
assets: true,
|
|
134197
|
+
time: true
|
|
134198
|
+
});
|
|
134158
134199
|
const outputPath = 'string' == typeof stats?.compilation?.outputOptions?.path ? stats.compilation.outputOptions.path : '';
|
|
134159
134200
|
const manifestPath = outputPath ? path__rspack_import_1.join(outputPath, 'manifest.json') : path__rspack_import_1.join(projectDir, 'manifest.json');
|
|
134160
134201
|
const manifest = JSON.parse(fs__rspack_import_0.readFileSync(manifestPath, 'utf8'));
|
|
134161
134202
|
const assets = statsJson?.assets;
|
|
134162
134203
|
const heading = `${getLoggingPrefix('info')} Building ${pintor__rspack_import_2_default().blue(manifest.name)} extension using ${capitalizedBrowserName(browser)} defaults...\n`;
|
|
134163
|
-
const buildTime = `\nBuild completed in ${((statsJson?.time || 0) / 1000).toFixed(2)} seconds
|
|
134204
|
+
const buildTime = `\nBuild completed in ${((statsJson?.time || 0) / 1000).toFixed(2)} seconds.\n`;
|
|
134164
134205
|
const buildTarget = `Build Target: ${pintor__rspack_import_2_default().gray(capitalizedBrowserName(browser))}\n`;
|
|
134165
134206
|
const buildStatus = `Build Status: ${stats?.hasErrors() ? pintor__rspack_import_2_default().red('Failed') : pintor__rspack_import_2_default().green('Success')}\n`;
|
|
134166
134207
|
const version1 = `\nVersion: ${pintor__rspack_import_2_default().gray(manifest.version)}\n`;
|
|
@@ -134221,13 +134262,13 @@ var __webpack_modules__ = {
|
|
|
134221
134262
|
if (haystack.includes('runtime') || haystack.includes('will fail') || haystack.includes('cannot resolve') || haystack.includes('service_worker')) return 'Runtime-risk';
|
|
134222
134263
|
return 'Warning';
|
|
134223
134264
|
}
|
|
134224
|
-
function
|
|
134225
|
-
if ('Performance' === category) return '
|
|
134226
|
-
if ('Deprecation' === category) return 'Move to the supported API
|
|
134265
|
+
function suggestedHintForWarning(category) {
|
|
134266
|
+
if ('Performance' === category) return 'Inspect the largest startup bundles and split optional code paths.';
|
|
134267
|
+
if ('Deprecation' === category) return 'Move to the supported API or plugin path before the next update.';
|
|
134227
134268
|
if ('Configuration' === category) return 'Review extension and bundler config keys, then remove or rename invalid options.';
|
|
134228
134269
|
if ('Compatibility' === category) return 'Verify browser target and manifest compatibility for this build.';
|
|
134229
|
-
if ('Runtime-risk' === category) return 'Address this
|
|
134230
|
-
return 'Re-run with
|
|
134270
|
+
if ('Runtime-risk' === category) return 'Address this before release; it may fail or degrade at runtime.';
|
|
134271
|
+
return 'Re-run with EXTENSION_VERBOSE=1 to inspect full warning details.';
|
|
134231
134272
|
}
|
|
134232
134273
|
function buildSuccessWithWarnings(warningCount) {
|
|
134233
134274
|
return `${getLoggingPrefix('warn')} Build succeeded with ${warningCount} warning(s). Your extension is ${pintor__rspack_import_2_default().green('ready for deployment')}.`;
|
|
@@ -134235,19 +134276,20 @@ var __webpack_modules__ = {
|
|
|
134235
134276
|
function buildWarningsDetails(warnings) {
|
|
134236
134277
|
if (!Array.isArray(warnings) || 0 === warnings.length) return '';
|
|
134237
134278
|
const blocks = [];
|
|
134238
|
-
const sectionHeader = `${getLoggingPrefix('warn')} Warning details\n`;
|
|
134239
134279
|
warnings.forEach((warning, index)=>{
|
|
134240
134280
|
const message = getWarningMessage(warning);
|
|
134241
134281
|
const source = getWarningSource(warning);
|
|
134242
134282
|
const artifact = getWarningArtifact(warning);
|
|
134243
134283
|
const category = classifyWarning(message, source);
|
|
134244
|
-
const
|
|
134245
|
-
if (!message) return void blocks.push(
|
|
134284
|
+
const hint = suggestedHintForWarning(category);
|
|
134285
|
+
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.')}`);
|
|
134286
|
+
const performanceWarning = parsePerformanceWarning(warning, source, artifact);
|
|
134287
|
+
if (performanceWarning) return void blocks.push(performanceWarning);
|
|
134246
134288
|
const oneLine = message.replace(/\s+/g, ' ').trim();
|
|
134247
134289
|
const artifactSuffix = artifact ? ` ${pintor__rspack_import_2_default().gray(`(${artifact})`)}` : '';
|
|
134248
|
-
blocks.push(
|
|
134290
|
+
blocks.push(`${getLoggingPrefix('warn')} ${category}: ${oneLine}${artifactSuffix}\n${formatWarningLabelLine('Source', pintor__rspack_import_2_default().gray(source))}\n${formatWarningLabelLine('Hint', hint)}`);
|
|
134249
134291
|
});
|
|
134250
|
-
return
|
|
134292
|
+
return blocks.join('\n\n');
|
|
134251
134293
|
}
|
|
134252
134294
|
function fetchingProjectPath(owner, project) {
|
|
134253
134295
|
return fmt.block('Fetching project', [
|
|
@@ -134349,6 +134391,49 @@ var __webpack_modules__ = {
|
|
|
134349
134391
|
});
|
|
134350
134392
|
return `.\n${printTree(assetTree)}`;
|
|
134351
134393
|
}
|
|
134394
|
+
function formatWarningLabelLine(label, value) {
|
|
134395
|
+
return `${pintor__rspack_import_2_default().gray('│')} ${pintor__rspack_import_2_default().gray(`${label}:`)} ${value}`;
|
|
134396
|
+
}
|
|
134397
|
+
function parsePerformanceWarning(warning, source, _artifact) {
|
|
134398
|
+
const normalized = getWarningBody(warning).replace(/\r/g, '');
|
|
134399
|
+
const lower = normalized.toLowerCase();
|
|
134400
|
+
const threshold = normalized.match(/\(([\d.]+\s(?:KiB|MiB|GiB|KB|MB|GB))\)/)?.[1] || '';
|
|
134401
|
+
if (lower.includes('asset size limit')) return formatPerformanceWarningBlock({
|
|
134402
|
+
title: 'asset size limit exceeded',
|
|
134403
|
+
threshold,
|
|
134404
|
+
impact: 'Large emitted files can increase package size and slow extension startup.',
|
|
134405
|
+
source,
|
|
134406
|
+
hint: 'Inspect the largest startup bundles and split optional code paths.'
|
|
134407
|
+
});
|
|
134408
|
+
if (lower.includes('entrypoint size limit')) return formatPerformanceWarningBlock({
|
|
134409
|
+
title: 'entrypoint size limit exceeded',
|
|
134410
|
+
threshold,
|
|
134411
|
+
impact: 'Startup entrypoints are heavier than recommended.',
|
|
134412
|
+
source,
|
|
134413
|
+
hint: 'Keep startup entrypoints thin and defer non-critical code.'
|
|
134414
|
+
});
|
|
134415
|
+
}
|
|
134416
|
+
function formatPerformanceWarningBlock(options) {
|
|
134417
|
+
const lines = [
|
|
134418
|
+
`${getLoggingPrefix('warn')} Performance: ${options.title}`
|
|
134419
|
+
];
|
|
134420
|
+
if (options.threshold) lines.push(formatWarningLabelLine('Threshold', options.threshold));
|
|
134421
|
+
lines.push(formatWarningLabelLine('Impact', options.impact));
|
|
134422
|
+
lines.push(pintor__rspack_import_2_default().gray('│'));
|
|
134423
|
+
lines.push(formatWarningLabelLine('Source', pintor__rspack_import_2_default().gray(options.source)));
|
|
134424
|
+
lines.push(formatWarningLabelLine('Hint', options.hint));
|
|
134425
|
+
return lines.join('\n');
|
|
134426
|
+
}
|
|
134427
|
+
function getWarningBody(warning) {
|
|
134428
|
+
if (!warning) return '';
|
|
134429
|
+
if ('string' == typeof warning) return warning;
|
|
134430
|
+
return [
|
|
134431
|
+
warning.message,
|
|
134432
|
+
warning.details,
|
|
134433
|
+
warning.reason,
|
|
134434
|
+
warning.description
|
|
134435
|
+
].filter((value)=>'string' == typeof value && value.trim().length > 0).join('\n');
|
|
134436
|
+
}
|
|
134352
134437
|
function isUsingExperimentalConfig(integration) {
|
|
134353
134438
|
return `${getLoggingPrefix('info')} Using ${pintor__rspack_import_2_default().yellow(integration)}.`;
|
|
134354
134439
|
}
|
|
@@ -135379,7 +135464,7 @@ var __webpack_modules__ = {
|
|
|
135379
135464
|
},
|
|
135380
135465
|
"./package.json" (module) {
|
|
135381
135466
|
"use strict";
|
|
135382
|
-
module.exports = JSON.parse('{"rE":"3.9.0
|
|
135467
|
+
module.exports = JSON.parse('{"rE":"3.9.0","El":{"@rspack/core":"^1.7.5","@rspack/dev-server":"^1.1.5","@swc/core":"^1.15.8","@swc/helpers":"^0.5.18","adm-zip":"^0.5.16","browser-extension-manifest-fields":"^2.2.1","case-sensitive-paths-webpack-plugin":"^2.4.0","chrome-location2":"4.0.0","chromium-location":"2.0.0","content-security-policy-parser":"^0.6.0","cross-spawn":"^7.0.6","dotenv":"^17.2.3","edge-location":"2.2.0","extension-from-store":"^0.1.1","firefox-location2":"3.0.0","go-git-it":"^5.1.1","ignore":"^7.0.5","loader-utils":"^3.3.1","magic-string":"^0.30.21","parse5":"^8.0.0","parse5-utilities":"^1.0.0","pintor":"0.3.0","schema-utils":"^4.3.3","tiny-glob":"^0.2.9","unique-names-generator":"^4.7.1","webextension-polyfill":"^0.12.0","webpack-merge":"^6.0.1","webpack-target-webextension":"^2.1.3","ws":"^8.19.0"}}');
|
|
135383
135468
|
}
|
|
135384
135469
|
};
|
|
135385
135470
|
var __webpack_module_cache__ = {};
|
|
@@ -136259,7 +136344,7 @@ var __webpack_exports__ = {};
|
|
|
136259
136344
|
__webpack_require__.e("552").then(__webpack_require__.bind(__webpack_require__, "./webpack/webpack-lib/stats-handler.ts")),
|
|
136260
136345
|
Promise.all([
|
|
136261
136346
|
__webpack_require__.e("215"),
|
|
136262
|
-
__webpack_require__.e("
|
|
136347
|
+
__webpack_require__.e("270")
|
|
136263
136348
|
]).then(__webpack_require__.bind(__webpack_require__, "./webpack/webpack-config.ts"))
|
|
136264
136349
|
]);
|
|
136265
136350
|
const debug = isAuthor;
|
|
@@ -136296,6 +136381,7 @@ var __webpack_exports__ = {};
|
|
|
136296
136381
|
plugins: allPluginsButBrowserRunners
|
|
136297
136382
|
});
|
|
136298
136383
|
const compilerConfig = merge(userConfig);
|
|
136384
|
+
compilerConfig.stats = false;
|
|
136299
136385
|
const compiler = rspack(compilerConfig);
|
|
136300
136386
|
let summary = {
|
|
136301
136387
|
browser,
|
|
@@ -136403,7 +136489,7 @@ var __webpack_exports__ = {};
|
|
|
136403
136489
|
if ('true' === process.env.EXTENSION_DEV_DRY_RUN) return;
|
|
136404
136490
|
const { devServer } = await Promise.all([
|
|
136405
136491
|
__webpack_require__.e("215"),
|
|
136406
|
-
__webpack_require__.e("
|
|
136492
|
+
__webpack_require__.e("270"),
|
|
136407
136493
|
__webpack_require__.e("324")
|
|
136408
136494
|
]).then(__webpack_require__.bind(__webpack_require__, "./webpack/dev-server/index.ts"));
|
|
136409
136495
|
await devServer(projectStructure, {
|