extension-develop 4.0.16 → 4.0.17

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/839.mjs CHANGED
@@ -5,7 +5,8 @@ import { buildExecEnv, detectPackageManagerFromLockfile } from "prefers-yarn";
5
5
  import pintor from "pintor";
6
6
  import { EventEmitter } from "node:events";
7
7
  import { Compilation as core_Compilation, WebpackError as core_WebpackError, sources as core_sources } from "@rspack/core";
8
- import { package_namespaceObject, buildWarningsDetails, sanitize, getDirs, projectInstallFallbackToNpm, assertNoManagedDependencyConflicts, debugDirs, browserLaunchFailed, buildSuccess, extensionLoadRecovered, writingTypeDefinitionsError, extensionLoadStillRefused, projectInstallScriptsDisabled, authorInstallNotice, getSpecialFoldersDataForProjectRoot, buildSuccessWithWarnings, loadCommandConfig, needsInstall, buildCommandFailed, writingTypeDefinitions, constants_isGeckoBasedBrowser, buildWebpack, debugBrowser, normalizeBrowser, debugOutputPath, loadCustomConfig, devCommandFailed, getProjectStructure, getDistPath, resolveCompanionExtensionsConfig, loadBrowserConfig, isChromiumBasedBrowser } from "./101.mjs";
8
+ import { isDebug, ENVELOPE, CODES, prefix as messaging_prefix, claimCardKey, card } from "./349.mjs";
9
+ import { package_namespaceObject, buildWarningsDetails, sanitize, getDirs, projectInstallFallbackToNpm, assertNoManagedDependencyConflicts, isGeckoBasedBrowser, debugDirs, browserLaunchFailed, buildSuccess, extensionLoadRecovered, writingTypeDefinitionsError, extensionLoadStillRefused, projectInstallScriptsDisabled, authorInstallNotice, getSpecialFoldersDataForProjectRoot, buildSuccessWithWarnings, loadCommandConfig, needsInstall, buildCommandFailed, writingTypeDefinitions, buildWebpack, debugBrowser, normalizeBrowser, debugOutputPath, loadCustomConfig, devCommandFailed, getProjectStructure, getDistPath, resolveCompanionExtensionsConfig, loadBrowserConfig, isChromiumBasedBrowser } from "./101.mjs";
9
10
  import { stripBom, parseJsonSafe } from "./23.mjs";
10
11
  import { hasProjectDependency, findNearestProjectManifestDirSync } from "./80.mjs";
11
12
  import { buildSummaryPath, ensureSessionArtifactsIgnoreFile } from "./494.mjs";
@@ -21,13 +22,260 @@ function ensureRustMinStack(env = process.env) {
21
22
  if (!env.RUST_MIN_STACK) env.RUST_MIN_STACK = String(RUST_MIN_STACK_BYTES);
22
23
  }
23
24
  ensureRustMinStack();
24
- const MAX_SUMMARY_WARNINGS = 20;
25
+ const MAX_OUTPUT_CHARS = 2000;
25
26
  const ANSI_PATTERN = /\u001b\[[0-9;]*m/g;
27
+ const MACHINE_OUTPUT_VALUES = new Set([
28
+ 'json',
29
+ 'ndjson'
30
+ ]);
31
+ function isMachineOutput() {
32
+ return MACHINE_OUTPUT_VALUES.has(String(process.env.EXTENSION_OUTPUT || '').trim().toLowerCase());
33
+ }
34
+ function isLifecycleStreamEnabled() {
35
+ return isMachineOutput();
36
+ }
37
+ function humanLine(line) {
38
+ if (isMachineOutput()) return void process.stderr.write(`${line}\n`);
39
+ console.log(line);
40
+ }
41
+ function stripAnsi(input) {
42
+ return String(input || '').replace(ANSI_PATTERN, '');
43
+ }
44
+ function readReadyContract(readyPath) {
45
+ if (!readyPath) return null;
46
+ try {
47
+ const parsed = JSON.parse(__rspack_external_node_fs_5ea92f0c.readFileSync(readyPath, 'utf-8'));
48
+ return parsed && 'object' == typeof parsed ? parsed : null;
49
+ } catch {
50
+ return null;
51
+ }
52
+ }
53
+ function isProfileLocked(ready) {
54
+ if (!ready) return false;
55
+ const code = String(ready.code ?? '').trim().toLowerCase();
56
+ if ('profile_locked' === code || 'profile-locked' === code) return true;
57
+ if (true === ready.profileLocked) return true;
58
+ const message = String(ready.message ?? '');
59
+ return /profile\s+is\s+locked|singletonlock/i.test(message);
60
+ }
61
+ function toFiniteNumber(value) {
62
+ if ('number' == typeof value && Number.isFinite(value)) return value;
63
+ if ('string' == typeof value) {
64
+ const parsed = Number.parseInt(value, 10);
65
+ return Number.isFinite(parsed) ? parsed : null;
66
+ }
67
+ return null;
68
+ }
69
+ class LifecycleStream {
70
+ options;
71
+ writeLine;
72
+ successfulCompiles = 0;
73
+ compileAttempts = 0;
74
+ readyEmitted = false;
75
+ readyErrorEmitted = false;
76
+ browserExitEmitted = false;
77
+ boundPort = null;
78
+ exitWatcher;
79
+ constructor(options){
80
+ this.options = options;
81
+ this.writeLine = options.write || ((line)=>process.stdout.write(line));
82
+ }
83
+ get enabled() {
84
+ return isLifecycleStreamEnabled();
85
+ }
86
+ emit(frame) {
87
+ if (!this.enabled) return null;
88
+ this.writeLine(`${JSON.stringify(frame)}\n`);
89
+ return frame;
90
+ }
91
+ sessionValue(extra = {}) {
92
+ const ready = readReadyContract(this.options.readyPath);
93
+ const port = toFiniteNumber(ready?.port) ?? this.boundPort;
94
+ return {
95
+ command: this.options.command,
96
+ browser: this.options.browser,
97
+ distPath: this.options.distPath,
98
+ pid: process.pid,
99
+ port,
100
+ ...this.options.readyPath ? {
101
+ readyPath: this.options.readyPath
102
+ } : {},
103
+ ...this.options.eventsPath ? {
104
+ eventsPath: this.options.eventsPath
105
+ } : {},
106
+ ...'string' == typeof ready?.runId ? {
107
+ runId: ready.runId
108
+ } : {},
109
+ ...'string' == typeof ready?.instanceId ? {
110
+ instanceId: ready.instanceId
111
+ } : {},
112
+ ...'string' == typeof ready?.toolchainVersion ? {
113
+ toolchainVersion: ready.toolchainVersion
114
+ } : {},
115
+ ...extra
116
+ };
117
+ }
118
+ starting(args) {
119
+ this.boundPort = toFiniteNumber(args.port);
120
+ return this.emit(ENVELOPE.ok(this.options.command, 'starting', this.sessionValue({
121
+ requestedPort: toFiniteNumber(args.requestedPort),
122
+ port: toFiniteNumber(args.port)
123
+ })));
124
+ }
125
+ compiled(args) {
126
+ this.compileAttempts += 1;
127
+ this.successfulCompiles += 1;
128
+ const status = 1 === this.successfulCompiles ? 'compiled' : 'recompiled';
129
+ return this.emit(ENVELOPE.ok(this.options.command, status, this.sessionValue({
130
+ assets: toFiniteNumber(args.assets) ?? 0,
131
+ durationMs: toFiniteNumber(args.durationMs) ?? 0
132
+ })));
133
+ }
134
+ compileFailed(args) {
135
+ this.compileAttempts += 1;
136
+ const isFirst = 1 === this.compileAttempts;
137
+ const code = isFirst ? CODES.E_FIRST_COMPILE : CODES.E_COMPILE;
138
+ const raw = stripAnsi(String(args.output || ''));
139
+ const truncated = raw.length > MAX_OUTPUT_CHARS;
140
+ const output = truncated ? `${raw.slice(0, MAX_OUTPUT_CHARS)}…` : raw;
141
+ const message = args.message || (isFirst ? 'The first compilation failed.' : 'A recompilation failed after a change.');
142
+ const frame = ENVELOPE.fail(this.options.command, 'compile-failed', {
143
+ code,
144
+ message
145
+ }, {
146
+ truncated
147
+ });
148
+ frame.value = this.sessionValue({
149
+ output,
150
+ durationMs: toFiniteNumber(args.durationMs) ?? 0
151
+ });
152
+ return this.emit(frame);
153
+ }
154
+ ready(args = {}) {
155
+ if (this.readyEmitted) return null;
156
+ if (null != args.port) this.boundPort = toFiniteNumber(args.port);
157
+ const ready = readReadyContract(this.options.readyPath);
158
+ if (ready && 'error' === ready.status) {
159
+ if (this.readyErrorEmitted) return null;
160
+ this.readyErrorEmitted = true;
161
+ const frame = ENVELOPE.fail(this.options.command, 'failed', {
162
+ code: CODES.E_READY_ERROR_STATUS,
163
+ message: String(ready.message || '') || 'The ready contract reports an error for this session.'
164
+ });
165
+ frame.value = this.sessionValue({
166
+ ...'string' == typeof ready.code ? {
167
+ readyCode: ready.code
168
+ } : {}
169
+ });
170
+ return this.emit(frame);
171
+ }
172
+ this.readyEmitted = true;
173
+ return this.emit(ENVELOPE.ok(this.options.command, 'ready', this.sessionValue()));
174
+ }
175
+ browserExited(args = {}) {
176
+ if (this.browserExitEmitted) return null;
177
+ this.browserExitEmitted = true;
178
+ const ready = readReadyContract(this.options.readyPath);
179
+ const locked = isProfileLocked(ready);
180
+ const code = locked ? CODES.E_PROFILE_LOCKED : CODES.E_BROWSER_LAUNCH;
181
+ const message = args.message || String(ready?.message || '') || (locked ? 'The browser profile is locked by another session.' : 'The browser exited before the session ended.');
182
+ const frame = ENVELOPE.fail(this.options.command, 'browser-exited', {
183
+ code,
184
+ message
185
+ });
186
+ frame.value = this.sessionValue({
187
+ exitCode: toFiniteNumber(args.exitCode) ?? toFiniteNumber(ready?.browserExitCode),
188
+ ...'string' == typeof ready?.browserExitedAt ? {
189
+ browserExitedAt: ready.browserExitedAt
190
+ } : {}
191
+ });
192
+ return this.emit(frame);
193
+ }
194
+ failed(message) {
195
+ const frame = ENVELOPE.fail(this.options.command, 'failed', {
196
+ code: CODES.E_INTERNAL,
197
+ message: stripAnsi(message)
198
+ });
199
+ frame.value = this.sessionValue();
200
+ return this.emit(frame);
201
+ }
202
+ watchBrowserExit(intervalMs = 1000) {
203
+ const stop = ()=>{
204
+ if (this.exitWatcher) clearInterval(this.exitWatcher);
205
+ this.exitWatcher = void 0;
206
+ };
207
+ if (!this.enabled || !this.options.readyPath) return stop;
208
+ if (this.exitWatcher) return stop;
209
+ this.exitWatcher = setInterval(()=>{
210
+ const ready = readReadyContract(this.options.readyPath);
211
+ if ('string' != typeof ready?.browserExitedAt) return;
212
+ this.browserExited();
213
+ stop();
214
+ }, intervalMs);
215
+ this.exitWatcher.unref?.();
216
+ return stop;
217
+ }
218
+ }
219
+ function createLifecycleStream(options) {
220
+ return new LifecycleStream(options);
221
+ }
222
+ function assetCount(stats) {
223
+ const compilation = stats?.compilation;
224
+ try {
225
+ const assets = compilation?.getAssets?.();
226
+ if (Array.isArray(assets)) return assets.length;
227
+ } catch {}
228
+ return Object.keys(compilation?.assets || {}).length;
229
+ }
230
+ function compileDuration(stats) {
231
+ const compilation = stats?.compilation;
232
+ const start = Number(compilation?.startTime || 0);
233
+ const end = Number(compilation?.endTime || 0);
234
+ const duration = end - start;
235
+ return Number.isFinite(duration) && duration > 0 ? duration : 0;
236
+ }
237
+ function errorText(stats) {
238
+ try {
239
+ return String(stats?.toString?.({
240
+ all: false,
241
+ errors: true,
242
+ colors: false
243
+ }) || '');
244
+ } catch {
245
+ return '';
246
+ }
247
+ }
248
+ function attachLifecycleStream(compiler, stream) {
249
+ const hooks = compiler?.hooks;
250
+ hooks?.done?.tap('extension.js:lifecycle-stream', (stats)=>{
251
+ try {
252
+ if (stats?.hasErrors?.()) return void stream.compileFailed({
253
+ output: errorText(stats),
254
+ durationMs: compileDuration(stats)
255
+ });
256
+ stream.compiled({
257
+ assets: assetCount(stats),
258
+ durationMs: compileDuration(stats)
259
+ });
260
+ stream.ready();
261
+ } catch {}
262
+ });
263
+ hooks?.failed?.tap('extension.js:lifecycle-stream', (error)=>{
264
+ try {
265
+ stream.compileFailed({
266
+ output: error instanceof Error ? error.stack || error.message : String(error),
267
+ message: error instanceof Error ? error.message : String(error)
268
+ });
269
+ } catch {}
270
+ });
271
+ }
272
+ const MAX_SUMMARY_WARNINGS = 20;
273
+ const build_summary_ANSI_PATTERN = /\u001b\[[0-9;]*m/g;
26
274
  function getBuildSummary(browser, info) {
27
275
  const assets = info?.assets || [];
28
276
  const warnings = (info?.warnings || []).slice(0, MAX_SUMMARY_WARNINGS).map((warning)=>{
29
277
  const message = warning && 'object' == typeof warning ? String(warning.message ?? '') : String(warning ?? '');
30
- return message.replace(ANSI_PATTERN, '').trim();
278
+ return message.replace(build_summary_ANSI_PATTERN, '').trim();
31
279
  }).filter(Boolean);
32
280
  return {
33
281
  browser,
@@ -503,7 +751,7 @@ async function ensureDevelopArtifacts() {
503
751
  'run',
504
752
  'compile'
505
753
  ]);
506
- const isAuthor = 'true' === process.env.EXTENSION_AUTHOR_MODE;
754
+ const isAuthor = isDebug();
507
755
  const stdio = isAuthor ? 'inherit' : 'ignore';
508
756
  if (isAuthor) console.warn(authorInstallNotice('extension-develop build artifacts (dist missing)'));
509
757
  await execInstallCommand(command.command, command.args, {
@@ -556,26 +804,26 @@ function isUsingJSFramework(projectPath) {
556
804
  return frameworks.some((fw)=>hasDependency(projectPath, fw));
557
805
  }
558
806
  function isUsingIntegration(name) {
559
- return `${pintor.gray('⏵⏵⏵')} Using ${pintor.brightBlue(name)}...`;
807
+ return `integration use=${name}`;
560
808
  }
561
809
  function creatingTSConfig() {
562
- return `${pintor.gray('⏵⏵⏵')} Creating default tsconfig.json...`;
810
+ return `${messaging_prefix('info')} Create a default tsconfig.json.`;
563
811
  }
564
812
  function isUsingCustomLoader(loaderPath) {
565
- return `${pintor.gray('⏵⏵⏵')} Using custom loader: ${pintor.yellow(loaderPath)}.`;
813
+ return `${messaging_prefix('debug')} loader custom=${loaderPath}`;
566
814
  }
567
815
  function jsFrameworksIntegrationsEnabled(integrations) {
568
- const list = integrations.length > 0 ? integrations.map((n)=>pintor.yellow(n)).join(', ') : pintor.gray('none');
569
- return `${pintor.gray('⏵⏵⏵')} JS: Integrations enabled (${pintor.gray(String(integrations.length))}) ${list}`;
816
+ const names = integrations.length > 0 ? integrations.join(',') : 'none';
817
+ return `${messaging_prefix('debug')} js integrations=${integrations.length} names=${names}`;
570
818
  }
571
819
  function jsFrameworksConfigsDetected(tsConfigPath, tsRoot, targets) {
572
- const fmt = (v)=>v ? pintor.underline(v) : pintor.gray('none');
573
- const tgt = targets?.length ? targets.map((t)=>pintor.gray(t)).join(', ') : pintor.gray('default');
574
- return `${pintor.gray('⏵⏵⏵')} JS: Configs\n${pintor.gray('TSCONFIG')} ${fmt(tsConfigPath)}\n${pintor.gray('TSROOT')} ${fmt(tsRoot)}\n${pintor.gray('SWC_TARGETS')} ${tgt}`;
820
+ const val = (v)=>v || 'none';
821
+ const tgt = targets?.length ? targets.join(',') : 'default';
822
+ return `${messaging_prefix('debug')} js config tsconfig=${val(tsConfigPath)} tsRoot=${val(tsRoot)} swcTargets="${tgt}"`;
575
823
  }
576
824
  function jsFrameworksHmrSummary(enabled, frameworks) {
577
- const list = frameworks.length > 0 ? frameworks.map((n)=>pintor.yellow(n)).join(', ') : pintor.gray('none');
578
- return `${pintor.gray('⏵⏵⏵')} JS: HMR ${enabled ? pintor.green('enabled') : pintor.gray('disabled')} for ${list}`;
825
+ const names = frameworks.length > 0 ? frameworks.join(',') : 'none';
826
+ return `${messaging_prefix('debug')} js hmr=${enabled ? 'enabled' : 'disabled'} frameworks=${names}`;
579
827
  }
580
828
  let hasShownUserMessage = false;
581
829
  function findNearestPackageJsonDirectory(startPath) {
@@ -626,7 +874,7 @@ function ensureTypeScriptConfig(projectPath) {
626
874
  const hasDep = hasTypeScriptDependency(projectPath);
627
875
  const hasTsFiles = hasTypeScriptSourceFiles(projectPath);
628
876
  if (hasDep || hasTsFiles) if (tsConfigFilePath) {
629
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(`${pintor.brightMagenta('⏵⏵⏵ Author says')} ${isUsingIntegration('TypeScript')}`);
877
+ if (isDebug()) console.log(`${messaging_prefix('debug')} ${isUsingIntegration('TypeScript')}`);
630
878
  } else if (hasTsFiles) throw new Error('[Extension.js] Missing tsconfig.json next to package.json. Create one to use TypeScript.');
631
879
  else {
632
880
  console.log(creatingTSConfig());
@@ -673,13 +921,49 @@ function writeTsConfig(projectPath) {
673
921
  mode: 'development'
674
922
  }), null, 2));
675
923
  }
924
+ function printBuildCard(manifestPath, browser, distPath) {
925
+ if (!claimCardKey(`${browser}::${__rspack_external_node_path_c5b9b54f.resolve(distPath)}`)) return;
926
+ let extensionLabel = '';
927
+ try {
928
+ const manifest = parseJsonSafe(__rspack_external_node_fs_5ea92f0c.readFileSync(manifestPath, 'utf-8'));
929
+ const name = String(manifest?.name || '').trim();
930
+ const version = String(manifest?.version || '').trim();
931
+ extensionLabel = name && version ? `${name} ${version}` : name;
932
+ } catch {}
933
+ const browserLabel = String(browser || '').split('-').filter(Boolean).map((token)=>token.charAt(0).toUpperCase() + token.slice(1)).join('-');
934
+ const suffix = process.env.EXTENSION_CLI_UPDATE_SUFFIX || '';
935
+ if (suffix) delete process.env.EXTENSION_CLI_UPDATE_SUFFIX;
936
+ humanLine(' ');
937
+ humanLine(card({
938
+ version: process.env.EXTENSION_DEVELOP_VERSION || process.env.EXTENSION_CLI_VERSION,
939
+ suffix,
940
+ rows: [
941
+ {
942
+ label: 'Browser',
943
+ value: browserLabel
944
+ },
945
+ {
946
+ label: 'Extension',
947
+ value: extensionLabel
948
+ },
949
+ {
950
+ label: 'Output',
951
+ value: distPath
952
+ }
953
+ ]
954
+ }));
955
+ humanLine(' ');
956
+ process.env.EXTENSION_CLI_BANNER_PRINTED = 'true';
957
+ }
676
958
  async function extensionBuild(pathOrRemoteUrl, buildOptions) {
677
959
  const projectStructure = await getProjectStructure(pathOrRemoteUrl);
678
960
  const isVitest = 'true' === process.env.VITEST;
679
961
  const shouldExitOnError = (buildOptions?.exitOnError ?? false) && !isVitest;
680
962
  const browser = normalizeBrowser(buildOptions?.browser || 'chrome', buildOptions?.chromiumBinary, buildOptions?.geckoBinary || buildOptions?.firefoxBinary);
681
963
  const { manifestDir, packageJsonDir } = getDirs(projectStructure);
682
- const isAuthor = 'true' === process.env.EXTENSION_AUTHOR_MODE;
964
+ const distPath = getDistPath(packageJsonDir, browser);
965
+ const isAuthor = isDebug();
966
+ printBuildCard(projectStructure.manifestPath, browser, distPath);
683
967
  try {
684
968
  await ensureDevelopArtifacts();
685
969
  if (buildOptions?.install !== false) await ensureUserProjectDependencies(packageJsonDir);
@@ -696,7 +980,6 @@ async function extensionBuild(pathOrRemoteUrl, buildOptions) {
696
980
  if (userManifestPath) assertNoManagedDependencyConflicts(userManifestPath, manifestDir);
697
981
  const commandConfig = await loadCommandConfig(packageJsonDir, 'build');
698
982
  const specialFoldersData = getSpecialFoldersDataForProjectRoot(packageJsonDir);
699
- const distPath = getDistPath(packageJsonDir, browser);
700
983
  try {
701
984
  __rspack_external_node_fs_5ea92f0c.rmSync(distPath, {
702
985
  recursive: true,
@@ -753,7 +1036,7 @@ async function extensionBuild(pathOrRemoteUrl, buildOptions) {
753
1036
  }
754
1037
  if (!stats || 'function' != typeof stats.hasErrors) return reject(new Error('Build failed: bundler returned invalid stats output (no reliable compilation result).'));
755
1038
  if (!buildOptions?.silent && stats) try {
756
- console.log(buildWebpack(manifestDir, stats, browser));
1039
+ humanLine(buildWebpack(manifestDir, stats, browser));
757
1040
  } catch {}
758
1041
  if (stats.hasErrors()) {
759
1042
  handleStatsErrors(stats);
@@ -776,10 +1059,10 @@ async function extensionBuild(pathOrRemoteUrl, buildOptions) {
776
1059
  __rspack_external_node_fs_5ea92f0c.writeFileSync(summaryFile, JSON.stringify(summary));
777
1060
  } catch {}
778
1061
  if (summary.warnings_count > 0) {
779
- console.log(buildSuccessWithWarnings(summary.warnings_count));
1062
+ humanLine(buildSuccessWithWarnings(summary.warnings_count));
780
1063
  const warningDetails = buildWarningsDetails(info?.warnings || []);
781
- if (warningDetails) console.log(`\n${warningDetails}`);
782
- } else console.log(buildSuccess());
1064
+ if (warningDetails) humanLine(`\n${warningDetails}`);
1065
+ } else humanLine(buildSuccess());
783
1066
  resolve();
784
1067
  }
785
1068
  });
@@ -796,7 +1079,7 @@ async function extensionBuild(pathOrRemoteUrl, buildOptions) {
796
1079
  }
797
1080
  return summary;
798
1081
  } catch (error) {
799
- const isAuthor = 'true' === process.env.EXTENSION_AUTHOR_MODE;
1082
+ const isAuthor = isDebug();
800
1083
  if (isAuthor) console.error(error);
801
1084
  else console.error(buildCommandFailed(error));
802
1085
  if (!shouldExitOnError) throw error;
@@ -1556,7 +1839,7 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
1556
1839
  var fallback = kind === "content-scripts" ? "content_script"
1557
1840
  : kind === "service-worker" ? "service_worker"
1558
1841
  : "extension";
1559
- var announced = "[extension.js] Reloading " + (label || fallback) + "…";
1842
+ var announced = "[Extension.js] Reloading " + (label || fallback) + "…";
1560
1843
 
1561
1844
  notifyDevtoolsCompanion("reloading", label, kind);
1562
1845
 
@@ -2338,7 +2621,7 @@ class PruneStaleHotUpdates {
2338
2621
  function filterKeysForThisBrowser(manifest, browser) {
2339
2622
  const isSafariTarget = 'safari' === browser || 'webkit-based' === browser || String(browser).includes('webkit');
2340
2623
  const isChromiumTarget = isChromiumBasedBrowser(String(browser)) || isSafariTarget;
2341
- const isGeckoTarget = constants_isGeckoBasedBrowser(String(browser));
2624
+ const isGeckoTarget = isGeckoBasedBrowser(String(browser));
2342
2625
  const chromiumPrefixes = new Set([
2343
2626
  'chromium',
2344
2627
  'chrome',
@@ -3097,7 +3380,7 @@ class SetupBackgroundEntry {
3097
3380
  apply(compiler) {
3098
3381
  const manifest = JSON.parse(stripBom(__rspack_external_node_fs_5ea92f0c.readFileSync(this.manifestPath, 'utf-8')));
3099
3382
  const browser = this.browser;
3100
- const isGecko = constants_isGeckoBasedBrowser(String(browser));
3383
+ const isGecko = isGeckoBasedBrowser(String(browser));
3101
3384
  const minimumBgScript = resolveDevelopDistFile(isGecko ? 'minimum-firefox-file' : 'minimum-chromium-file');
3102
3385
  const dirname = __rspack_external_node_path_c5b9b54f.dirname(this.manifestPath);
3103
3386
  const filteredManifest = filterKeysForThisBrowser(manifest, browser) || manifest;
@@ -4085,7 +4368,7 @@ class SetupReloadStrategy {
4085
4368
  }
4086
4369
  getEntryName(manifest) {
4087
4370
  if (manifest.background) {
4088
- if (constants_isGeckoBasedBrowser(String(this.browser))) return {
4371
+ if (isGeckoBasedBrowser(String(this.browser))) return {
4089
4372
  pageEntry: "background/script",
4090
4373
  tryCatchWrapper: true,
4091
4374
  eagerChunkLoading: false
@@ -4688,9 +4971,10 @@ class SafariDevPlugin {
4688
4971
  async function extensionDev(pathOrRemoteUrl, devOptions) {
4689
4972
  let browsersPlugin;
4690
4973
  let emitter = new BuildEmitter();
4974
+ const shouldExitOnError = (devOptions.exitOnError ?? false) && 'true' !== process.env.VITEST;
4691
4975
  const projectStructure = await getProjectStructure(pathOrRemoteUrl);
4692
4976
  try {
4693
- const isAuthor = 'true' === process.env.EXTENSION_AUTHOR_MODE;
4977
+ const isAuthor = isDebug();
4694
4978
  const debug = isAuthor;
4695
4979
  const { manifestDir, packageJsonDir } = getDirs(projectStructure);
4696
4980
  await ensureDevelopArtifacts();
@@ -4764,9 +5048,10 @@ async function extensionDev(pathOrRemoteUrl, devOptions) {
4764
5048
  });
4765
5049
  return emitter;
4766
5050
  } catch (error) {
4767
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.error(error);
5051
+ if (isDebug()) console.error(error);
4768
5052
  else console.error(devCommandFailed(error));
5053
+ if (!shouldExitOnError) throw error;
4769
5054
  process.exit(1);
4770
5055
  }
4771
5056
  }
4772
- export { BuildEmitter, ReloadPlugin, buildCanonicalManifest, buildSourceFeatureIndex, classifyReloadFromSources, collectRootAbsoluteRefs, createChangedSourcesTracker, dispatchReload, ensureTypeScriptConfig, extensionBuild, extensionDev, filterKeysForThisBrowser, getCurrentManifestContent, getManifestContent, getManifestOverrides, getUserTypeScriptConfigFile, hasDependency, isFromFilepathList, isStaticThemeSource, isUsingCustomLoader, isUsingIntegration, isUsingTypeScript, jsFrameworksConfigsDetected, jsFrameworksHmrSummary, jsFrameworksIntegrationsEnabled, normalizeManifestOutputPath, readContentScriptCount, reportToCompilation, resolveDevelopDistFile, resolveDevelopInstallRoot, resolvePackageManager, resolveRootAbsoluteRef, setCurrentManifestContent, setOriginalManifestContent, unixify };
5057
+ export { BuildEmitter, ReloadPlugin, attachLifecycleStream, buildCanonicalManifest, buildSourceFeatureIndex, classifyReloadFromSources, collectRootAbsoluteRefs, createChangedSourcesTracker, createLifecycleStream, dispatchReload, ensureTypeScriptConfig, extensionBuild, extensionDev, filterKeysForThisBrowser, getCurrentManifestContent, getManifestContent, getManifestOverrides, getUserTypeScriptConfigFile, hasDependency, humanLine, isFromFilepathList, isStaticThemeSource, isUsingCustomLoader, isUsingIntegration, isUsingTypeScript, jsFrameworksConfigsDetected, jsFrameworksHmrSummary, jsFrameworksIntegrationsEnabled, normalizeManifestOutputPath, readContentScriptCount, reportToCompilation, resolveDevelopDistFile, resolveDevelopInstallRoot, resolvePackageManager, resolveRootAbsoluteRef, setCurrentManifestContent, setOriginalManifestContent, unixify };
package/dist/845.mjs CHANGED
@@ -1,20 +1,21 @@
1
1
  import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
2
2
  import pintor from "pintor";
3
+ import { prefix as messaging_prefix } from "./349.mjs";
3
4
  function cssIntegrationsEnabled(integrations) {
4
- const list = integrations.length > 0 ? integrations.map((n)=>pintor.yellow(n)).join(', ') : pintor.gray('none');
5
- return `${pintor.gray('⏵⏵⏵')} CSS: Integrations enabled (${pintor.gray(String(integrations.length))}) ${list}`;
5
+ const names = integrations.length > 0 ? integrations.join(',') : 'none';
6
+ return `${messaging_prefix('debug')} css integrations=${integrations.length} names=${names}`;
6
7
  }
7
8
  function cssConfigsDetected(postcssConfig, tailwindConfig, browserslistSource) {
8
- const fmt = (v)=>v ? pintor.underline(v) : pintor.gray('none');
9
- return `${pintor.gray('⏵⏵⏵')} CSS: Configs\n${pintor.gray('POSTCSS')} ${fmt(postcssConfig)}\n${pintor.gray('TAILWIND')} ${fmt(tailwindConfig)}\n${pintor.gray('BROWSERSLIST')} ${fmt(browserslistSource)}`;
9
+ const val = (v)=>v || 'none';
10
+ return `${messaging_prefix('debug')} css config postcss=${val(postcssConfig)} tailwind=${val(tailwindConfig)} browserslist=${val(browserslistSource)}`;
10
11
  }
11
12
  function isUsingIntegration(name) {
12
- return `${pintor.gray('⏵⏵⏵')} Using ${pintor.brightBlue(name)}...`;
13
+ return `integration use=${name}`;
13
14
  }
14
15
  function missingSassDependency() {
15
- const prefix = pintor.red('⏵⏵⏵');
16
16
  return [
17
- `${prefix} SASS support requires the ${pintor.brightBlue('"sass"')} package to be installed in your project.`,
17
+ `${messaging_prefix('error')} Couldn't compile the Sass styles.`,
18
+ `The ${pintor.brightBlue('"sass"')} package is not installed in your project.`,
18
19
  '',
19
20
  "Add it to your devDependencies, for example:",
20
21
  ` ${pintor.gray('npm install --save-dev sass')}`,
@@ -30,8 +31,9 @@ function missingSassDependency() {
30
31
  }
31
32
  function postCssPluginNotResolved(pluginName, projectPath) {
32
33
  return [
33
- `${pintor.yellow('⏵⏵⏵')} PostCSS plugin ${pintor.brightBlue(`"${pluginName}"`)} could not be resolved from ${pintor.underline(projectPath)}.`,
34
- 'The plugin was skipped so the build can continue. Styles it would generate are missing from the output.',
34
+ `${messaging_prefix('warn')} PostCSS plugin ${pintor.brightBlue(`"${pluginName}"`)} could not be resolved from ${pintor.underline(projectPath)}.`,
35
+ 'The plugin was skipped so the build can continue.',
36
+ 'Styles it would generate are missing from the output.',
35
37
  `Install it in your project to re-enable it, for example: ${pintor.gray(`npm install --save-dev ${pluginName}`)}`
36
38
  ].join('\n');
37
39
  }
@@ -39,15 +41,18 @@ function cssParseErrorShippedVerbatim(resourcePath, error) {
39
41
  const errObj = error;
40
42
  const reason = error && 'object' == typeof error && 'reason' in error ? String(errObj?.reason) : String(errObj?.message || error);
41
43
  return [
42
- `${pintor.yellow('⏵⏵⏵')} Invalid CSS in ${pintor.underline(resourcePath)}, ${reason}.`,
44
+ `${messaging_prefix('warn')} Invalid CSS in ${pintor.underline(resourcePath)}.`,
45
+ `Reason: ${reason}.`,
43
46
  'Browsers skip invalid rules, so the stylesheet was copied as-is instead of failing the build.',
44
- 'PostCSS/Tailwind processing was NOT applied to this file. Fix the CSS to re-enable it.'
47
+ 'PostCSS/Tailwind processing was NOT applied to this file.',
48
+ 'Fix the CSS to re-enable it.'
45
49
  ].join('\n');
46
50
  }
47
51
  function preprocessorShippedUncompiled(resourcePath, tool) {
48
52
  const pkg = 'sass' === tool ? 'sass' : 'less';
49
53
  return [
50
- `${pintor.yellow('⏵⏵⏵')} ${pintor.underline(resourcePath)} shipped UNCOMPILED, ${pintor.brightBlue(`"${pkg}"`)} is not installed in this project.`,
54
+ `${messaging_prefix('warn')} ${pintor.underline(resourcePath)} shipped UNCOMPILED.`,
55
+ `The ${pintor.brightBlue(`"${pkg}"`)} package is not installed in this project.`,
51
56
  `The raw ${'sass' === tool ? 'Sass/SCSS' : 'Less'} source was copied as-is into the output .css, which browsers will treat as broken CSS (unstyled surfaces).`,
52
57
  `Install it to compile this file, for example: ${pintor.gray(`npm install --save-dev ${pkg}`)}`
53
58
  ].join('\n');
@@ -56,7 +61,8 @@ function deadCssUrlRef(issuerPath, request) {
56
61
  return [
57
62
  `Missing file in ${pintor.underline(issuerPath)}.`,
58
63
  `The ${pintor.yellow(`url(${request})`)} reference points to a file that exists nowhere in the project.`,
59
- `Chrome applies the rest of the stylesheet and 404s this reference silently, likely dead code. Set ${pintor.yellow('EXTENSION_STRICT_REFS=true')} to make this a build error.`,
64
+ "Chrome applies the rest of the stylesheet and 404s this reference silently, so it is likely dead code.",
65
+ `Set ${pintor.yellow('EXTENSION_STRICT_REFS=true')} to make this a build error.`,
60
66
  '',
61
67
  `${pintor.red('NOT FOUND')} ${pintor.underline(request)}`
62
68
  ].join('\n');