extension-develop 3.8.16 → 3.9.0-canary.231.7b387a7
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/{535.cjs → 270.cjs} +6249 -6135
- package/dist/323.cjs +61 -16
- package/dist/{928.cjs → 324.cjs} +160 -173
- package/dist/552.cjs +1 -1
- package/dist/module.cjs +494 -143
- package/dist/warn-no-default-export.cjs +74 -30
- package/package.json +3 -2
- package/webpack/webpack-lib/optional-dependencies.json +20 -0
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');
|
|
@@ -387,14 +374,72 @@ exports.modules = {
|
|
|
387
374
|
} catch {}
|
|
388
375
|
return null;
|
|
389
376
|
}
|
|
377
|
+
getDeveloperModeStatus() {
|
|
378
|
+
if (!this.profilePath) return 'unknown';
|
|
379
|
+
const prefCandidates = [];
|
|
380
|
+
const seen = new Set();
|
|
381
|
+
const addPrefCandidate = (dir)=>{
|
|
382
|
+
const prefPath = external_path_.join(dir, 'Preferences');
|
|
383
|
+
if (!external_fs_.existsSync(prefPath)) return;
|
|
384
|
+
const dedupeKey = external_path_.resolve(prefPath);
|
|
385
|
+
if (seen.has(dedupeKey)) return;
|
|
386
|
+
seen.add(dedupeKey);
|
|
387
|
+
prefCandidates.push(prefPath);
|
|
388
|
+
};
|
|
389
|
+
try {
|
|
390
|
+
addPrefCandidate(this.profilePath);
|
|
391
|
+
addPrefCandidate(external_path_.join(this.profilePath, 'Default'));
|
|
392
|
+
for (const entry of external_fs_.readdirSync(this.profilePath))if (/^Profile\s+\d+$/i.test(entry)) addPrefCandidate(external_path_.join(this.profilePath, entry));
|
|
393
|
+
} catch {}
|
|
394
|
+
for (const prefPath of prefCandidates)try {
|
|
395
|
+
const prefs = JSON.parse(external_fs_.readFileSync(prefPath, 'utf-8'));
|
|
396
|
+
const uiFlag = prefs?.extensions?.ui?.developer_mode;
|
|
397
|
+
if ('boolean' == typeof uiFlag) return uiFlag ? 'enabled' : 'disabled';
|
|
398
|
+
const legacyFlag = prefs?.extensions?.developer_mode;
|
|
399
|
+
if ('boolean' == typeof legacyFlag) return legacyFlag ? 'enabled' : 'disabled';
|
|
400
|
+
} catch {}
|
|
401
|
+
return 'unknown';
|
|
402
|
+
}
|
|
390
403
|
async hardReload() {
|
|
391
|
-
if (!this.
|
|
404
|
+
if (!this.extensionId) return false;
|
|
405
|
+
try {
|
|
406
|
+
if (!this.cdp) await this.connectFreshClient();
|
|
407
|
+
if (this.cdp && await this.cdp.forceReloadExtension(this.extensionId)) return true;
|
|
408
|
+
} catch {}
|
|
392
409
|
try {
|
|
393
|
-
|
|
410
|
+
await this.reconnectForReload();
|
|
411
|
+
return Boolean(this.cdp && this.extensionId && await this.cdp.forceReloadExtension(this.extensionId));
|
|
394
412
|
} catch {
|
|
395
413
|
return false;
|
|
396
414
|
}
|
|
397
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
|
+
}
|
|
398
443
|
onProtocolEvent(cb) {
|
|
399
444
|
if (!this.cdp) throw new Error('CDP not connected');
|
|
400
445
|
this.cdp.onProtocolEvent((raw)=>{
|
package/dist/{928.cjs → 324.cjs}
RENAMED
|
@@ -1,117 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
exports.ids = [
|
|
3
|
-
"
|
|
3
|
+
"324"
|
|
4
4
|
];
|
|
5
5
|
exports.modules = {
|
|
6
6
|
"./webpack/dev-server/index.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
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");
|
|
14
|
-
var
|
|
15
|
-
var external_pintor_ = __webpack_require__("pintor");
|
|
16
|
-
var external_pintor_default = /*#__PURE__*/ __webpack_require__.n(external_pintor_);
|
|
17
|
-
function getLoggingPrefix(type) {
|
|
18
|
-
const isAuthor = 'true' === process.env.EXTENSION_AUTHOR_MODE;
|
|
19
|
-
if (isAuthor) {
|
|
20
|
-
const base = 'error' === type ? 'ERROR Author says' : '►►► Author says';
|
|
21
|
-
return external_pintor_default().brightMagenta(base);
|
|
22
|
-
}
|
|
23
|
-
if ('error' === type) return external_pintor_default().red('ERROR');
|
|
24
|
-
if ('warn' === type) return external_pintor_default().brightYellow('►►►');
|
|
25
|
-
if ('info' === type) return external_pintor_default().gray('►►►');
|
|
26
|
-
return external_pintor_default().green('►►►');
|
|
27
|
-
}
|
|
28
|
-
function messages_ready(mode, browser) {
|
|
29
|
-
const extensionOutput = 'firefox' === browser || 'gecko-based' === browser || 'edge' === browser ? 'Add-on' : 'Extension';
|
|
30
|
-
const b = String(browser || '');
|
|
31
|
-
const cap = b.charAt(0).toUpperCase() + b.slice(1);
|
|
32
|
-
const pretty = external_pintor_default().green('ready for ' + mode);
|
|
33
|
-
return `${getLoggingPrefix('info')} ${cap} ${extensionOutput} ${pretty}.`;
|
|
34
|
-
}
|
|
35
|
-
function readJsonRecord(filePath) {
|
|
36
|
-
try {
|
|
37
|
-
return JSON.parse(external_fs_.readFileSync(filePath, 'utf8'));
|
|
38
|
-
} catch {
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
function capitalizeToken(value) {
|
|
43
|
-
return value.split('-').filter(Boolean).map((token)=>token.charAt(0).toUpperCase() + token.slice(1)).join('-');
|
|
44
|
-
}
|
|
45
|
-
function getExtensionVersion() {
|
|
46
|
-
return process.env.EXTENSION_DEVELOP_VERSION || process.env.EXTENSION_CLI_VERSION || (()=>{
|
|
47
|
-
try {
|
|
48
|
-
return __webpack_require__("./package.json").rE;
|
|
49
|
-
} catch {
|
|
50
|
-
return 'unknown';
|
|
51
|
-
}
|
|
52
|
-
})();
|
|
53
|
-
}
|
|
54
|
-
function browserRunnerDisabled(args) {
|
|
55
|
-
const manifest = readJsonRecord(args.manifestPath);
|
|
56
|
-
const ready = readJsonRecord(args.readyPath);
|
|
57
|
-
const browserLabel = capitalizeToken(String(args.browser || 'unknown'));
|
|
58
|
-
const runId = String(ready?.runId || '').trim();
|
|
59
|
-
const pid = Number.isInteger(ready?.pid) ? String(ready?.pid) : '';
|
|
60
|
-
const runLabel = runId ? `${external_pintor_default().gray(runId)}${pid ? ` · ${external_pintor_default().gray(`PID ${pid}`)}` : ''}` : pid ? external_pintor_default().gray(`PID ${pid}`) : external_pintor_default().gray('n/a');
|
|
61
|
-
const extensionName = String(manifest?.name || 'Extension');
|
|
62
|
-
const extensionVersion = String(manifest?.version || '').trim();
|
|
63
|
-
const extensionLabel = extensionVersion ? `${extensionName} ${extensionVersion}` : extensionName;
|
|
64
|
-
const extensionJsVersion = getExtensionVersion();
|
|
65
|
-
return [
|
|
66
|
-
` 🧩 ${external_pintor_default().brightBlue('Extension.js')} ${external_pintor_default().gray(extensionJsVersion)}`,
|
|
67
|
-
` Browser ${external_pintor_default().gray(`${browserLabel} (build-only mode)`)}`,
|
|
68
|
-
` Extension ${external_pintor_default().gray(extensionLabel)}`,
|
|
69
|
-
` Run ID ${runLabel}`
|
|
70
|
-
].join('\n');
|
|
71
|
-
}
|
|
72
|
-
function portInUse(requestedPort, newPort) {
|
|
73
|
-
return `Port: Requested port ${external_pintor_default().brightBlue(requestedPort.toString())} is in use; using ${external_pintor_default().brightBlue(newPort.toString())} instead.`;
|
|
74
|
-
}
|
|
75
|
-
function extensionJsRunnerError(error) {
|
|
76
|
-
return `Extension.js Runner Error:\n${external_pintor_default().red(String(error))}`;
|
|
77
|
-
}
|
|
78
|
-
function autoExitModeEnabled(ms) {
|
|
79
|
-
return `Auto-exit enabled. Will exit after ${external_pintor_default().brightBlue(ms.toString())} ms if idle.`;
|
|
80
|
-
}
|
|
81
|
-
function autoExitTriggered(ms) {
|
|
82
|
-
return `Auto-exit triggered after ${external_pintor_default().brightBlue(ms.toString())} ms. Cleaning up...`;
|
|
83
|
-
}
|
|
84
|
-
function autoExitForceKill(ms) {
|
|
85
|
-
return `Force-killing process after ${external_pintor_default().brightBlue(ms.toString())} ms to ensure exit.`;
|
|
86
|
-
}
|
|
87
|
-
function devServerStartTimeout(ms) {
|
|
88
|
-
return [
|
|
89
|
-
`Dev server startup is taking longer than expected (${external_pintor_default().brightBlue(ms.toString())} ms).`,
|
|
90
|
-
"The bundler may have encountered an error before emitting the first build.",
|
|
91
|
-
`If nothing else prints, try setting ${external_pintor_default().brightBlue('EXTENSION_VERBOSE=1')} for more logs.`
|
|
92
|
-
].join('\n');
|
|
93
|
-
}
|
|
94
|
-
function bundlerFatalError(error) {
|
|
95
|
-
const text = error instanceof Error ? error.stack || error.message : String(error);
|
|
96
|
-
return `Build failed to start:\n${external_pintor_default().red(text)}`;
|
|
97
|
-
}
|
|
98
|
-
function bundlerRecompiling() {
|
|
99
|
-
return "Recompiling due to file changes…";
|
|
100
|
-
}
|
|
101
|
-
function noEntrypointsDetected(port) {
|
|
102
|
-
return [
|
|
103
|
-
"No entrypoints or assets were produced by the initial compilation.",
|
|
104
|
-
`The dev server is running on 127.0.0.1:${external_pintor_default().brightBlue(port.toString())}, but nothing is being built.`,
|
|
105
|
-
"Possible causes:",
|
|
106
|
-
" • Empty or missing entry configuration.",
|
|
107
|
-
" • Extension-related plugins are disabled (entries not derived from manifest).",
|
|
108
|
-
" • All sources are ignored or excluded.",
|
|
109
|
-
`Try enabling verbose logs with ${external_pintor_default().brightBlue('EXTENSION_VERBOSE=1')} or review your extension config.`
|
|
110
|
-
].join('\n');
|
|
111
|
-
}
|
|
112
|
-
function spacerLine() {
|
|
113
|
-
return ' ';
|
|
114
|
-
}
|
|
17
|
+
var messages = __webpack_require__("./webpack/dev-server/messages.ts");
|
|
115
18
|
var external_crypto_ = __webpack_require__("crypto");
|
|
116
19
|
var external_net_ = __webpack_require__("net");
|
|
117
20
|
var shared_utils = __webpack_require__("./webpack/plugin-browsers/browsers-lib/shared-utils.ts");
|
|
@@ -224,60 +127,7 @@ exports.modules = {
|
|
|
224
127
|
var resolve_config = __webpack_require__("./webpack/feature-special-folders/folder-extensions/resolve-config.ts");
|
|
225
128
|
var get_data = __webpack_require__("./webpack/feature-special-folders/get-data.ts");
|
|
226
129
|
var sanitize = __webpack_require__("./webpack/webpack-lib/sanitize.ts");
|
|
227
|
-
var
|
|
228
|
-
function setupCompilerHooks(compiler, port) {
|
|
229
|
-
const verbose = '1' === String(process.env.EXTENSION_VERBOSE || '').trim();
|
|
230
|
-
let reportedNoEntries = false;
|
|
231
|
-
compiler.hooks.invalid.tap('extension.js:invalid', ()=>{
|
|
232
|
-
if (verbose) console.log(bundlerRecompiling());
|
|
233
|
-
});
|
|
234
|
-
compiler.hooks.failed.tap('extension.js:failed', (error)=>{
|
|
235
|
-
console.error(bundlerFatalError(error));
|
|
236
|
-
});
|
|
237
|
-
compiler.hooks.done.tap('extension.js:done', (stats)=>{
|
|
238
|
-
try {
|
|
239
|
-
if (stats?.hasErrors?.()) {
|
|
240
|
-
const str = stats?.toString?.({
|
|
241
|
-
colors: true,
|
|
242
|
-
all: false,
|
|
243
|
-
errors: true,
|
|
244
|
-
warnings: true
|
|
245
|
-
});
|
|
246
|
-
if (str) console.error((0, branding.h)(str));
|
|
247
|
-
} else if (stats?.hasWarnings?.()) {
|
|
248
|
-
const str = stats?.toString?.({
|
|
249
|
-
colors: true,
|
|
250
|
-
all: false,
|
|
251
|
-
errors: false,
|
|
252
|
-
warnings: true
|
|
253
|
-
});
|
|
254
|
-
if (str) console.warn((0, branding.h)(str));
|
|
255
|
-
}
|
|
256
|
-
if (!reportedNoEntries) {
|
|
257
|
-
const info = stats.toJson({
|
|
258
|
-
all: false,
|
|
259
|
-
assets: true,
|
|
260
|
-
entrypoints: true
|
|
261
|
-
});
|
|
262
|
-
const hasAssets = Array.isArray(info?.assets) && info.assets.length > 0;
|
|
263
|
-
const entrypoints = info?.entrypoints || {};
|
|
264
|
-
const hasEntrypoints = entrypoints && Object.keys(entrypoints).length > 0;
|
|
265
|
-
if (!hasAssets && !hasEntrypoints) {
|
|
266
|
-
reportedNoEntries = true;
|
|
267
|
-
console.warn(noEntrypointsDetected(port));
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
} catch (error) {
|
|
271
|
-
const str = stats?.toString({
|
|
272
|
-
colors: true,
|
|
273
|
-
all: false,
|
|
274
|
-
errors: true,
|
|
275
|
-
warnings: true
|
|
276
|
-
});
|
|
277
|
-
if (str) console.error((0, branding.h)(str));
|
|
278
|
-
}
|
|
279
|
-
});
|
|
280
|
-
}
|
|
130
|
+
var compiler_hooks = __webpack_require__("./webpack/dev-server/compiler-hooks.ts");
|
|
281
131
|
function parseMilliseconds(value) {
|
|
282
132
|
if ('number' == typeof value) return Number.isFinite(value) && value > 0 ? value : null;
|
|
283
133
|
if ('string' == typeof value) {
|
|
@@ -292,11 +142,11 @@ exports.modules = {
|
|
|
292
142
|
const autoExitMs = parseMilliseconds(autoExitMsRaw);
|
|
293
143
|
if (null === autoExitMs) return ()=>{};
|
|
294
144
|
try {
|
|
295
|
-
console.log(
|
|
145
|
+
console.log(messages.o6(autoExitMs));
|
|
296
146
|
} catch {}
|
|
297
147
|
autoExitTimer = setTimeout(async ()=>{
|
|
298
148
|
try {
|
|
299
|
-
console.log(
|
|
149
|
+
console.log(messages.tJ(autoExitMs));
|
|
300
150
|
} catch {}
|
|
301
151
|
await onCleanup();
|
|
302
152
|
}, autoExitMs);
|
|
@@ -304,7 +154,7 @@ exports.modules = {
|
|
|
304
154
|
const forceKillMs = null !== parsedForceKillMs && parsedForceKillMs > 0 ? parsedForceKillMs : autoExitMs + 4000;
|
|
305
155
|
forceKillTimer = setTimeout(()=>{
|
|
306
156
|
try {
|
|
307
|
-
console.log(
|
|
157
|
+
console.log(messages.Df(forceKillMs));
|
|
308
158
|
} catch {}
|
|
309
159
|
process.exit(0);
|
|
310
160
|
}, forceKillMs);
|
|
@@ -325,7 +175,7 @@ exports.modules = {
|
|
|
325
175
|
await portManager.terminateCurrentInstance();
|
|
326
176
|
setTimeout(()=>process.exit(), 500);
|
|
327
177
|
}).catch(async (error)=>{
|
|
328
|
-
console.log(
|
|
178
|
+
console.log(messages.VL(error));
|
|
329
179
|
await portManager.terminateCurrentInstance();
|
|
330
180
|
setTimeout(()=>process.exit(1), 500);
|
|
331
181
|
});
|
|
@@ -362,6 +212,142 @@ exports.modules = {
|
|
|
362
212
|
}
|
|
363
213
|
var plugin_playwright = __webpack_require__("./webpack/plugin-playwright/index.ts");
|
|
364
214
|
var webpack_config = __webpack_require__("./webpack/webpack-config.ts");
|
|
215
|
+
function shouldWriteAssetToDisk(filePath) {
|
|
216
|
+
return !/(?:^|[/\\])manifest\.json$/i.test(filePath);
|
|
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
|
+
}
|
|
365
351
|
async function dev_server_devServer(projectStructure, devOptions) {
|
|
366
352
|
process.env.EXTENSION_BROWSER_LAUNCH_ENABLED = devOptions.noBrowser ? '0' : '1';
|
|
367
353
|
const { manifestPath, packageJsonPath } = projectStructure;
|
|
@@ -421,6 +407,9 @@ exports.modules = {
|
|
|
421
407
|
}
|
|
422
408
|
};
|
|
423
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);
|
|
424
413
|
const metadata = (0, plugin_playwright.Ih)({
|
|
425
414
|
packageJsonDir,
|
|
426
415
|
browser: String(devOptions.browser || 'chromium'),
|
|
@@ -429,8 +418,14 @@ exports.modules = {
|
|
|
429
418
|
manifestPath,
|
|
430
419
|
port
|
|
431
420
|
});
|
|
432
|
-
|
|
433
|
-
if (
|
|
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
|
+
});
|
|
428
|
+
if (void 0 !== devOptions.port && devOptions.port !== port) console.log(messages.aO(devOptions.port, port));
|
|
434
429
|
const serverConfig = {
|
|
435
430
|
host: devServerHost,
|
|
436
431
|
allowedHosts: 'all',
|
|
@@ -440,7 +435,7 @@ exports.modules = {
|
|
|
440
435
|
},
|
|
441
436
|
compress: false,
|
|
442
437
|
devMiddleware: {
|
|
443
|
-
writeToDisk:
|
|
438
|
+
writeToDisk: shouldWriteAssetToDisk,
|
|
444
439
|
stats: false
|
|
445
440
|
},
|
|
446
441
|
watchFiles: {
|
|
@@ -477,22 +472,14 @@ exports.modules = {
|
|
|
477
472
|
let startTimeout;
|
|
478
473
|
try {
|
|
479
474
|
startTimeout = setTimeout(()=>{
|
|
480
|
-
console.error(
|
|
475
|
+
console.error(messages.UF(START_TIMEOUT_MS));
|
|
481
476
|
}, START_TIMEOUT_MS);
|
|
482
477
|
await devServer.start();
|
|
483
478
|
if (startTimeout) clearTimeout(startTimeout);
|
|
484
|
-
console.log(spacerLine());
|
|
485
|
-
console.log(messages_ready('development', devOptions.browser));
|
|
486
|
-
if (devOptions.noBrowser) console.log(browserRunnerDisabled({
|
|
487
|
-
browser: String(devOptions.browser || 'chromium'),
|
|
488
|
-
manifestPath,
|
|
489
|
-
readyPath: metadata.readyPath
|
|
490
|
-
}));
|
|
491
|
-
console.log(spacerLine());
|
|
492
479
|
} catch (error) {
|
|
493
480
|
if (startTimeout) clearTimeout(startTimeout);
|
|
494
481
|
metadata.writeError('dev_server_start_failed', error instanceof Error ? error.message : String(error));
|
|
495
|
-
console.log(
|
|
482
|
+
console.log(messages.VL(error));
|
|
496
483
|
process.exit(1);
|
|
497
484
|
}
|
|
498
485
|
setupCleanupHandlers(devServer, portManager);
|
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;
|