extension 4.0.30 → 4.0.33

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/cli.cjs CHANGED
@@ -169,7 +169,9 @@ var __webpack_modules__ = {
169
169
  async function printProdBannerOnce(opts) {
170
170
  const k = keyFor(opts.browser, opts.outPath);
171
171
  if (printedKeys.has(k) || (0, _helpers_messaging__rspack_import_3.VR)(baseKeyFor(opts.browser, opts.outPath))) return true;
172
- const browserLabel = (0, _helpers_messaging__rspack_import_3.A6)(String(opts.browser || 'unknown'), _messages__rspack_import_5.GK(String(opts.browser || ''), opts.browserVersionLine));
172
+ const browserLabel = (0, _helpers_messaging__rspack_import_3.A6)(String(opts.browser || 'unknown'), _messages__rspack_import_5.GK(String(opts.browser || ''), opts.browserVersionLine, {
173
+ pinned: 'pinned' === opts.binaryProvenance
174
+ }));
173
175
  try {
174
176
  const manifestPath = node_path__rspack_import_2.join(opts.outPath, 'manifest.json');
175
177
  const manifest = JSON.parse(node_fs__rspack_import_1.readFileSync(manifestPath, 'utf-8'));
@@ -454,9 +456,10 @@ var __webpack_modules__ = {
454
456
  function capitalizedBrowserName(browser) {
455
457
  return `${browser.charAt(0).toUpperCase() + browser.slice(1)}`;
456
458
  }
457
- function resolveBrowserVersionLine(browser, pinnedLine) {
459
+ function resolveBrowserVersionLine(browser, pinnedLine, opts) {
458
460
  const pinned = String(pinnedLine || '').trim();
459
461
  if (pinned) return pinned;
462
+ if (opts?.pinned) return '';
460
463
  try {
461
464
  if ('chromium' === browser || 'chromium-based' === browser) {
462
465
  const p = chromium_location__rspack_import_5_default()();
@@ -817,7 +820,9 @@ var __webpack_modules__ = {
817
820
  return 'unknown';
818
821
  }
819
822
  })();
820
- const baseBrowserLabel = (0, _helpers_messaging__rspack_import_9.A6)(String(browser || 'unknown'), resolveBrowserVersionLine(browser, browserVersionLine));
823
+ const baseBrowserLabel = (0, _helpers_messaging__rspack_import_9.A6)(String(browser || 'unknown'), resolveBrowserVersionLine(browser, browserVersionLine, {
824
+ pinned: opts?.binaryProvenance === 'pinned'
825
+ }));
821
826
  const provenanceNote = binaryProvenanceNote(opts?.binaryProvenance);
822
827
  const browserLabel = provenanceNote ? `${baseBrowserLabel} ${provenanceNote}` : baseBrowserLabel;
823
828
  const binaryRowValue = provenanceNote ? collapseHomeDirInCardValue(String(opts?.binaryPath || '').trim()) : '';
@@ -1083,24 +1088,57 @@ var __webpack_modules__ = {
1083
1088
  if (node_fs__rspack_import_0.existsSync(chromeNested)) scanRoots.push(chromeNested);
1084
1089
  }
1085
1090
  const versionDirPattern = /^(mac|mac_arm|win32|win64|linux)/i;
1086
- const candidateFiles = [];
1091
+ const versionDirs = [];
1087
1092
  for (const root of scanRoots)try {
1088
1093
  const entries = node_fs__rspack_import_0.readdirSync(root, {
1089
1094
  withFileTypes: true
1090
1095
  });
1091
- const versionDirs = entries.filter((entry)=>entry.isDirectory() && versionDirPattern.test(entry.name)).map((entry)=>node_path__rspack_import_1.join(root, entry.name));
1092
- for (const dir of versionDirs)candidateFiles.push(...buildCandidates(dir, browser));
1093
- } catch {}
1094
- for (const candidate of candidateFiles)try {
1095
- if (candidate && node_fs__rspack_import_0.existsSync(candidate)) return candidate;
1096
+ for (const entry of entries)if (entry.isDirectory() && versionDirPattern.test(entry.name)) versionDirs.push(node_path__rspack_import_1.join(root, entry.name));
1096
1097
  } catch {}
1098
+ versionDirs.sort(compareManagedBuildDirsNewestFirst);
1097
1099
  const names = executableNamesFor(browser);
1100
+ for (const dir of versionDirs){
1101
+ for (const candidate of buildCandidates(dir, browser))if (isUsableBinaryPath(candidate)) return candidate;
1102
+ const found = findExecutableUnder(dir, names, 6);
1103
+ if (found) return found;
1104
+ }
1098
1105
  for (const root of scanRoots){
1099
1106
  const found = findExecutableUnder(root, names, 6);
1100
1107
  if (found) return found;
1101
1108
  }
1102
1109
  return null;
1103
1110
  }
1111
+ const MANAGED_BUILD_DIR_PREFIX = /^(?:mac_arm|mac-arm|mac|win64|win32|linux64|linux)[-_]/i;
1112
+ function parseManagedBuildId(dirName) {
1113
+ const name = String(dirName || '');
1114
+ const buildId = name.replace(MANAGED_BUILD_DIR_PREFIX, '');
1115
+ return buildId.split(/[^\d]+/).filter(Boolean).map((part)=>Number(part)).filter((part)=>Number.isFinite(part));
1116
+ }
1117
+ function compareManagedBuildDirNames(a, b) {
1118
+ const partsA = parseManagedBuildId(a);
1119
+ const partsB = parseManagedBuildId(b);
1120
+ const length = Math.max(partsA.length, partsB.length);
1121
+ for(let i = 0; i < length; i++){
1122
+ const na = partsA[i] ?? 0;
1123
+ const nb = partsB[i] ?? 0;
1124
+ if (na !== nb) return na - nb;
1125
+ }
1126
+ return String(a).localeCompare(String(b));
1127
+ }
1128
+ function compareManagedBuildDirsNewestFirst(a, b) {
1129
+ const byBuild = compareManagedBuildDirNames(node_path__rspack_import_1.basename(b), node_path__rspack_import_1.basename(a));
1130
+ if (0 !== byBuild) return byBuild;
1131
+ let timeA = 0;
1132
+ let timeB = 0;
1133
+ try {
1134
+ timeA = node_fs__rspack_import_0.statSync(a).mtimeMs;
1135
+ } catch {}
1136
+ try {
1137
+ timeB = node_fs__rspack_import_0.statSync(b).mtimeMs;
1138
+ } catch {}
1139
+ if (timeA !== timeB) return timeB - timeA;
1140
+ return node_path__rspack_import_1.basename(b).localeCompare(node_path__rspack_import_1.basename(a));
1141
+ }
1104
1142
  function resolveChromiumFamilyFallback(compilation, requested = 'chromium') {
1105
1143
  const candidates = 'chrome' === requested ? [
1106
1144
  'chromium',
@@ -1134,6 +1172,13 @@ var __webpack_modules__ = {
1134
1172
  else out.push(node_path__rspack_import_1.join(dir, 'firefox'));
1135
1173
  return out;
1136
1174
  }
1175
+ function isUsableBinaryPath(candidate) {
1176
+ try {
1177
+ return Boolean(candidate) && node_fs__rspack_import_0.statSync(candidate).isFile();
1178
+ } catch {
1179
+ return false;
1180
+ }
1181
+ }
1137
1182
  function executableNamesFor(browser) {
1138
1183
  if ('chrome' === browser) return 'win32' === process.platform ? [
1139
1184
  'chrome.exe'
@@ -1152,6 +1197,7 @@ var __webpack_modules__ = {
1152
1197
  if ('edge' === browser) return 'win32' === process.platform ? [
1153
1198
  'msedge.exe'
1154
1199
  ] : [
1200
+ 'Microsoft Edge',
1155
1201
  'msedge',
1156
1202
  'microsoft-edge'
1157
1203
  ];
@@ -1545,6 +1591,9 @@ var __webpack_modules__ = {
1545
1591
  var node_net__rspack_import_1 = __webpack_require__("node:net");
1546
1592
  var node_os__rspack_import_2 = __webpack_require__("node:os");
1547
1593
  var node_path__rspack_import_3 = __webpack_require__("node:path");
1594
+ var chrome_location2__rspack_import_4 = __webpack_require__("chrome-location2");
1595
+ var chromium_location__rspack_import_5 = __webpack_require__("chromium-location");
1596
+ var edge_location__rspack_import_6 = __webpack_require__("edge-location");
1548
1597
  __webpack_require__("./browsers/browsers-lib/constants.ts");
1549
1598
  const MANAGED_EPHEMERAL_PROFILE_MARKER = '.extension-js-managed-profile';
1550
1599
  function shortInstanceId(instanceId) {
@@ -1563,8 +1612,12 @@ var __webpack_modules__ = {
1563
1612
  const finalPort = 'number' == typeof parsed && Number.isFinite(parsed) && parsed > 0 ? parsed : devServerPort;
1564
1613
  return 'number' == typeof finalPort && finalPort > 0 ? finalPort + 100 : defaultPort;
1565
1614
  }
1566
- function filterBrowserFlags(defaultFlags, excludeFlags = []) {
1567
- return defaultFlags.filter((flag)=>!excludeFlags.some((excludeFlag)=>flag === excludeFlag));
1615
+ function filterBrowserFlags(flags, excludeFlags = []) {
1616
+ return flags.filter((flag)=>!excludeFlags.some((excludeFlag)=>{
1617
+ if (!excludeFlag) return false;
1618
+ if (flag === excludeFlag) return true;
1619
+ return flag.startsWith(`${excludeFlag}=`) || flag.startsWith(`${excludeFlag},`);
1620
+ }));
1568
1621
  }
1569
1622
  function chooseChromiumBinaryPreferringStable(opts) {
1570
1623
  const managed = opts.managedSnapshotBinary;
@@ -1607,6 +1660,28 @@ var __webpack_modules__ = {
1607
1660
  const underManagedRoot = relative.length > 0 && !relative.startsWith('..') && !node_path__rspack_import_3.isAbsolute(relative);
1608
1661
  return underManagedRoot ? 'managed' : 'system';
1609
1662
  }
1663
+ function probeChromiumBinaryVersion(bin, browser) {
1664
+ const target = String(browser || '');
1665
+ const probes = [];
1666
+ if ('edge' === target) probes.push(()=>(0, edge_location__rspack_import_6.getEdgeVersion)(bin, {
1667
+ allowExec: true
1668
+ }));
1669
+ if ('chromium' === target || 'chromium-based' === target) probes.push(()=>(0, chromium_location__rspack_import_5.getChromiumVersion)(bin, {
1670
+ allowExec: true
1671
+ }));
1672
+ probes.push(()=>(0, chrome_location2__rspack_import_4.getChromeVersion)(bin, {
1673
+ allowExec: true
1674
+ }), ()=>(0, chromium_location__rspack_import_5.getChromiumVersion)(bin, {
1675
+ allowExec: true
1676
+ }), ()=>(0, edge_location__rspack_import_6.getEdgeVersion)(bin, {
1677
+ allowExec: true
1678
+ }));
1679
+ for (const probe of probes)try {
1680
+ const line = probe();
1681
+ if (line && String(line).trim()) return String(line).trim();
1682
+ } catch {}
1683
+ return '';
1684
+ }
1610
1685
  function parseEnvBrowserFlags(raw) {
1611
1686
  return String(raw || '').split(/\s+/).map((flag)=>flag.trim()).filter(Boolean);
1612
1687
  }
@@ -1789,7 +1864,8 @@ var __webpack_modules__ = {
1789
1864
  ci: ()=>isProfileLockedError,
1790
1865
  jl: ()=>deriveDebugPortWithInstance,
1791
1866
  ov: ()=>filterBrowserFlags,
1792
- sW: ()=>removeManagedEphemeralProfile
1867
+ sW: ()=>removeManagedEphemeralProfile,
1868
+ yO: ()=>probeChromiumBinaryVersion
1793
1869
  });
1794
1870
  },
1795
1871
  "./browsers/browsers-lib/wsl-support.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
@@ -2529,7 +2605,7 @@ var __webpack_modules__ = {
2529
2605
  '--remote-debugging-pipe'
2530
2606
  ] : [],
2531
2607
  ...filteredFlags,
2532
- ...configOptions.browserFlags || [],
2608
+ ...(0, shared_utils.ov)(configOptions.browserFlags || [], excludeFlags),
2533
2609
  ...(0, shared_utils.W0)(process.env.EXTENSION_BROWSER_FLAGS)
2534
2610
  ];
2535
2611
  if ((0, shared_utils.ZO)() && !baseFlags.some((flag)=>flag.startsWith('--headless'))) baseFlags.push('--headless=new');
@@ -2798,7 +2874,16 @@ var __webpack_modules__ = {
2798
2874
  });
2799
2875
  }
2800
2876
  async launchChromium(compilation, opts) {
2801
- if (this.options?.dryRun || process.env.VITEST || process.env.VITEST_WORKER_ID) return void logChromiumDryRun('chromium-mock-binary', []);
2877
+ if (this.options?.chromiumBinary) {
2878
+ const requested = String(this.options.chromiumBinary);
2879
+ const normalizedEarly = (0, wsl_support.f7)(requested);
2880
+ if (!normalizedEarly || !external_node_fs_.existsSync(normalizedEarly)) {
2881
+ (0, messaging.Gg)(messages.Sp(requested));
2882
+ if (process.env.VITEST || process.env.VITEST_WORKER_ID) throw new Error(`Invalid --chromium-binary path: ${requested}`);
2883
+ process.exit(1);
2884
+ }
2885
+ }
2886
+ if (this.options?.dryRun || process.env.VITEST || process.env.VITEST_WORKER_ID) return void logChromiumDryRun(this.options?.chromiumBinary ? (0, wsl_support.f7)(String(this.options.chromiumBinary)) : 'chromium-mock-binary', []);
2802
2887
  const browser = this.options?.browser;
2803
2888
  let browserBinaryLocation = null;
2804
2889
  let printedGuidance = false;
@@ -2858,8 +2943,18 @@ var __webpack_modules__ = {
2858
2943
  this.printEnhancedPuppeteerInstallHint(compilation, raw, browserName);
2859
2944
  printedGuidance = true;
2860
2945
  };
2861
- browserBinaryLocation = resolveManagedBinary();
2862
- if ('chromium' === browser && browserBinaryLocation) {
2946
+ const requestedPin = this.options?.chromiumBinary != null ? String(this.options.chromiumBinary) : '';
2947
+ if (requestedPin) {
2948
+ const normalized = normalizePath(requestedPin);
2949
+ if (!normalized || !isUsableBinary(normalized)) {
2950
+ (0, messaging.Gg)(messages.Sp(requestedPin));
2951
+ if (process.env.VITEST || process.env.VITEST_WORKER_ID) throw new Error(`Invalid --chromium-binary path: ${requestedPin}`);
2952
+ process.exit(1);
2953
+ }
2954
+ browserBinaryLocation = normalized;
2955
+ binaryPinnedByFlag = true;
2956
+ } else browserBinaryLocation = resolveManagedBinary();
2957
+ if ('chromium' === browser && browserBinaryLocation && !binaryPinnedByFlag) {
2863
2958
  let systemBinary = null;
2864
2959
  try {
2865
2960
  const env = {
@@ -2885,7 +2980,7 @@ var __webpack_modules__ = {
2885
2980
  }
2886
2981
  }
2887
2982
  let skipDetection = Boolean(browserBinaryLocation);
2888
- if (!browserBinaryLocation && (0, wsl_support.EV)()) {
2983
+ if (!binaryPinnedByFlag && !browserBinaryLocation && (0, wsl_support.EV)()) {
2889
2984
  const linuxFallback = resolveWslLinuxBinary(browser);
2890
2985
  if (linuxFallback) {
2891
2986
  browserBinaryLocation = linuxFallback;
@@ -2898,16 +2993,8 @@ var __webpack_modules__ = {
2898
2993
  }
2899
2994
  }
2900
2995
  }
2901
- browserBinaryLocation = preferRealChromeBinary(browserBinaryLocation);
2902
- const getBrowserVersionLine = (bin)=>{
2903
- try {
2904
- if ('edge' === browser) return (0, external_edge_location_.getEdgeVersion)(bin) || '';
2905
- if ('chromium' === browser || 'chromium-based' === browser) return (0, external_chromium_location_.getChromiumVersion)(bin) || '';
2906
- return (0, external_chrome_location2_.getChromeVersion)(bin) || '';
2907
- } catch {
2908
- return '';
2909
- }
2910
- };
2996
+ if (!binaryPinnedByFlag) browserBinaryLocation = preferRealChromeBinary(browserBinaryLocation);
2997
+ const getBrowserVersionLine = (bin)=>shared_utils.yO(bin, String(browser || ''));
2911
2998
  const looksOfficialChromeBinaryPath = (bin)=>{
2912
2999
  const p = String(bin || '');
2913
3000
  if (!p) return false;
@@ -2962,7 +3049,7 @@ var __webpack_modules__ = {
2962
3049
  return null;
2963
3050
  }
2964
3051
  };
2965
- switch(browser){
3052
+ if (!binaryPinnedByFlag) switch(browser){
2966
3053
  case 'chrome':
2967
3054
  if (isAuthorMode) (0, messaging._w)(messages.Gq(browser));
2968
3055
  if (!skipDetection) browserBinaryLocation = resolveChromeLikeBinary();
@@ -2984,15 +3071,6 @@ var __webpack_modules__ = {
2984
3071
  break;
2985
3072
  case 'chromium':
2986
3073
  if (isAuthorMode) (0, messaging._w)(messages.Gq(browser));
2987
- if (this.options?.chromiumBinary) {
2988
- const normalized = normalizePath(String(this.options.chromiumBinary));
2989
- if (!normalized || !external_node_fs_.existsSync(normalized)) {
2990
- (0, messaging.Gg)(messages.Sp(String(this.options.chromiumBinary)));
2991
- process.exit(1);
2992
- }
2993
- browserBinaryLocation = normalized;
2994
- binaryPinnedByFlag = true;
2995
- }
2996
3074
  if (!browserBinaryLocation && !skipDetection) try {
2997
3075
  const env = managedEnvFor('chromium');
2998
3076
  const p = external_chromium_location_default()({
@@ -3046,36 +3124,20 @@ var __webpack_modules__ = {
3046
3124
  }
3047
3125
  break;
3048
3126
  case 'chromium-based':
3049
- browserBinaryLocation = this.options?.chromiumBinary || null;
3050
- if (this.options?.chromiumBinary) {
3051
- const normalized = normalizePath(String(this.options.chromiumBinary));
3052
- if (!normalized || !external_node_fs_.existsSync(normalized)) {
3053
- (0, messaging.Gg)(messages.Sp(String(this.options.chromiumBinary)));
3054
- process.exit(1);
3055
- }
3056
- browserBinaryLocation = normalized;
3057
- binaryPinnedByFlag = true;
3058
- } else {
3059
- (0, messaging.Gg)(messages.ne());
3060
- process.exit(1);
3061
- }
3062
- if (!browserBinaryLocation && !skipDetection) try {
3063
- const env = managedEnvFor('chromium');
3064
- const p = external_chromium_location_default()({
3065
- env
3066
- });
3067
- const normalized = normalizePath(p || null);
3068
- if (normalized && 'string' == typeof normalized) {
3069
- if (external_node_fs_.existsSync(normalized)) browserBinaryLocation = normalized;
3070
- }
3071
- } catch {}
3072
- if (!browserBinaryLocation) browserBinaryLocation = resolveWslFallback();
3127
+ (0, messaging.Gg)(messages.ne());
3128
+ if (process.env.VITEST || process.env.VITEST_WORKER_ID) throw new Error('chromium-based requires --chromium-binary');
3129
+ process.exit(1);
3073
3130
  break;
3074
3131
  default:
3075
3132
  browserBinaryLocation = resolveChromeLikeBinary();
3076
3133
  break;
3077
3134
  }
3078
3135
  if (!browserBinaryLocation || !external_node_fs_.existsSync(browserBinaryLocation)) {
3136
+ if (binaryPinnedByFlag) {
3137
+ (0, messaging.Gg)(messages.Sp(requestedPin));
3138
+ if (process.env.VITEST || process.env.VITEST_WORKER_ID) throw new Error(`Invalid --chromium-binary path: ${requestedPin}`);
3139
+ process.exit(1);
3140
+ }
3079
3141
  browserBinaryLocation = browserBinaryLocation || resolveManagedBinary();
3080
3142
  if (!browserBinaryLocation) browserBinaryLocation = resolveWslFallback();
3081
3143
  if ((!browserBinaryLocation || !external_node_fs_.existsSync(browserBinaryLocation)) && ('chrome' === browser || 'chromium' === browser)) {
@@ -3643,7 +3705,7 @@ var __webpack_modules__ = {
3643
3705
  const { browser, profile, browserFlags = [] } = configOptions;
3644
3706
  const binaryArgs = [];
3645
3707
  const excludeFlags = configOptions.excludeBrowserFlags || [];
3646
- const filteredFlags = (browserFlags || []).filter((flag)=>excludeFlags.every((ex)=>!String(flag).startsWith(ex)));
3708
+ const filteredFlags = (0, shared_utils.ov)((browserFlags || []).map(String), excludeFlags);
3647
3709
  if (filteredFlags.length > 0) binaryArgs.push(...filteredFlags);
3648
3710
  binaryArgs.push(...(0, shared_utils.W0)(process.env.EXTENSION_BROWSER_FLAGS));
3649
3711
  if (configOptions.startingUrl && !configOptions.noOpen) binaryArgs.push('--url', String(configOptions.startingUrl));
@@ -5165,18 +5227,16 @@ var __webpack_modules__ = {
5165
5227
  },
5166
5228
  "./browsers/run-only.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
5167
5229
  var node_fs__rspack_import_0 = __webpack_require__("node:fs");
5168
- var chrome_location2__rspack_import_1 = __webpack_require__("chrome-location2");
5169
- var chromium_location__rspack_import_2 = __webpack_require__("chromium-location");
5170
- var edge_location__rspack_import_3 = __webpack_require__("edge-location");
5171
- var firefox_location2__rspack_import_4 = __webpack_require__("firefox-location2");
5172
- var _browsers_lib_banner__rspack_import_5 = __webpack_require__("./browsers/browsers-lib/banner.ts");
5173
- var _browsers_lib_browser_family__rspack_import_6 = __webpack_require__("./browsers/browsers-lib/browser-family.ts");
5174
- var _browsers_lib_output_binaries_resolver__rspack_import_7 = __webpack_require__("./browsers/browsers-lib/output-binaries-resolver.ts");
5175
- var _browsers_lib_runtime_options__rspack_import_12 = __webpack_require__("./browsers/browsers-lib/runtime-options.ts");
5176
- var _run_chromium_chromium_context__rspack_import_10 = __webpack_require__("./browsers/run-chromium/chromium-context/index.ts");
5177
- var _run_chromium_chromium_launch__rspack_import_8 = __webpack_require__("./browsers/run-chromium/chromium-launch/index.ts");
5178
- var _run_firefox_firefox_context__rspack_import_11 = __webpack_require__("./browsers/run-firefox/firefox-context/index.ts");
5179
- var _run_firefox_firefox_launch__rspack_import_9 = __webpack_require__("./browsers/run-firefox/firefox-launch/index.ts");
5230
+ var firefox_location2__rspack_import_1 = __webpack_require__("firefox-location2");
5231
+ var _browsers_lib_banner__rspack_import_2 = __webpack_require__("./browsers/browsers-lib/banner.ts");
5232
+ var _browsers_lib_browser_family__rspack_import_3 = __webpack_require__("./browsers/browsers-lib/browser-family.ts");
5233
+ var _browsers_lib_output_binaries_resolver__rspack_import_4 = __webpack_require__("./browsers/browsers-lib/output-binaries-resolver.ts");
5234
+ var _browsers_lib_runtime_options__rspack_import_10 = __webpack_require__("./browsers/browsers-lib/runtime-options.ts");
5235
+ var _browsers_lib_shared_utils__rspack_import_5 = __webpack_require__("./browsers/browsers-lib/shared-utils.ts");
5236
+ var _run_chromium_chromium_context__rspack_import_8 = __webpack_require__("./browsers/run-chromium/chromium-context/index.ts");
5237
+ var _run_chromium_chromium_launch__rspack_import_6 = __webpack_require__("./browsers/run-chromium/chromium-launch/index.ts");
5238
+ var _run_firefox_firefox_context__rspack_import_9 = __webpack_require__("./browsers/run-firefox/firefox-context/index.ts");
5239
+ var _run_firefox_firefox_launch__rspack_import_7 = __webpack_require__("./browsers/run-firefox/firefox-launch/index.ts");
5180
5240
  function createPreviewCompilationLike(opts) {
5181
5241
  return {
5182
5242
  options: {
@@ -5262,26 +5322,29 @@ var __webpack_modules__ = {
5262
5322
  }
5263
5323
  function resolvePinnedBinaryVersionLine(opts) {
5264
5324
  try {
5265
- if ((0, _browsers_lib_browser_family__rspack_import_6.M_)(opts.browser)) {
5325
+ if ((0, _browsers_lib_browser_family__rspack_import_3.M_)(opts.browser)) {
5266
5326
  if (!opts.geckoBinary || !node_fs__rspack_import_0.existsSync(opts.geckoBinary)) return;
5267
- return (0, firefox_location2__rspack_import_4.getFirefoxVersion)(opts.geckoBinary) || void 0;
5327
+ return (0, firefox_location2__rspack_import_1.getFirefoxVersion)(opts.geckoBinary) || void 0;
5268
5328
  }
5269
5329
  if (!opts.chromiumBinary || !node_fs__rspack_import_0.existsSync(opts.chromiumBinary)) return;
5270
- if ('edge' === opts.browser) return (0, edge_location__rspack_import_3.getEdgeVersion)(opts.chromiumBinary) || void 0;
5271
- if ('chromium' === opts.browser || 'chromium-based' === opts.browser) return (0, chromium_location__rspack_import_2.getChromiumVersion)(opts.chromiumBinary) || void 0;
5272
- return (0, chrome_location2__rspack_import_1.getChromeVersion)(opts.chromiumBinary) || void 0;
5330
+ return (0, _browsers_lib_shared_utils__rspack_import_5.yO)(opts.chromiumBinary, String(opts.browser)) || void 0;
5273
5331
  } catch {
5274
5332
  return;
5275
5333
  }
5276
5334
  }
5277
5335
  function buildPreviewBannerOptions(opts) {
5336
+ const chromiumPinned = !(0, _browsers_lib_browser_family__rspack_import_3.M_)(opts.browser) && 'string' == typeof opts.chromiumBinary && node_fs__rspack_import_0.existsSync(opts.chromiumBinary);
5278
5337
  return {
5279
5338
  browser: opts.browser,
5280
5339
  outPath: opts.outPath,
5281
5340
  includeExtensionId: true,
5282
5341
  includeRunId: false,
5283
5342
  readyPath: opts.readyPath,
5284
- browserVersionLine: resolvePinnedBinaryVersionLine(opts)
5343
+ browserVersionLine: resolvePinnedBinaryVersionLine(opts),
5344
+ ...chromiumPinned ? {
5345
+ binaryPath: opts.chromiumBinary,
5346
+ binaryProvenance: 'pinned'
5347
+ } : {}
5285
5348
  };
5286
5349
  }
5287
5350
  async function runOnlyPreviewBrowser(opts) {
@@ -5297,21 +5360,21 @@ var __webpack_modules__ = {
5297
5360
  const compilationLike = createPreviewCompilationLike(opts);
5298
5361
  const previewPluginOptions = buildPreviewPluginOptions(opts);
5299
5362
  const bannerOptions = buildPreviewBannerOptions(opts);
5300
- (0, _browsers_lib_output_binaries_resolver__rspack_import_7.LB)(compilationLike);
5301
- if ((0, _browsers_lib_browser_family__rspack_import_6.rG)(opts.browser)) {
5302
- const ctx = (0, _run_chromium_chromium_context__rspack_import_10.g)();
5303
- const launcher = new _run_chromium_chromium_launch__rspack_import_8.f(buildPreviewChromiumOptions(opts), ctx);
5304
- await (0, _browsers_lib_banner__rspack_import_5.MK)(bannerOptions);
5363
+ (0, _browsers_lib_output_binaries_resolver__rspack_import_4.LB)(compilationLike);
5364
+ if ((0, _browsers_lib_browser_family__rspack_import_3.rG)(opts.browser)) {
5365
+ const ctx = (0, _run_chromium_chromium_context__rspack_import_8.g)();
5366
+ const launcher = new _run_chromium_chromium_launch__rspack_import_6.f(buildPreviewChromiumOptions(opts), ctx);
5367
+ await (0, _browsers_lib_banner__rspack_import_2.MK)(bannerOptions);
5305
5368
  await launcher.runOnce(compilationLike, {
5306
5369
  enableCdpPostLaunch: false
5307
5370
  });
5308
5371
  return;
5309
5372
  }
5310
- if ((0, _browsers_lib_browser_family__rspack_import_6.M_)(opts.browser)) {
5311
- const ctx = (0, _run_firefox_firefox_context__rspack_import_11.D)();
5312
- const launcher = new _run_firefox_firefox_launch__rspack_import_9.c(buildPreviewFirefoxOptions(opts), ctx);
5313
- await (0, _browsers_lib_banner__rspack_import_5.MK)(bannerOptions);
5314
- await launcher.runOnce(compilationLike, (0, _browsers_lib_runtime_options__rspack_import_12.zU)(previewPluginOptions, 'production', {
5373
+ if ((0, _browsers_lib_browser_family__rspack_import_3.M_)(opts.browser)) {
5374
+ const ctx = (0, _run_firefox_firefox_context__rspack_import_9.D)();
5375
+ const launcher = new _run_firefox_firefox_launch__rspack_import_7.c(buildPreviewFirefoxOptions(opts), ctx);
5376
+ await (0, _browsers_lib_banner__rspack_import_2.MK)(bannerOptions);
5377
+ await launcher.runOnce(compilationLike, (0, _browsers_lib_runtime_options__rspack_import_10.zU)(previewPluginOptions, 'production', {
5315
5378
  persistProfile: previewPluginOptions.persistProfile,
5316
5379
  geckoBinary: previewPluginOptions.geckoBinary
5317
5380
  }));
@@ -6185,7 +6248,7 @@ var __webpack_modules__ = {
6185
6248
  const DEFAULT_SAMPLE_RATE = Number(process.env.EXTENSION_TELEMETRY_SAMPLE_RATE || 0.2);
6186
6249
  const DEFAULT_MAX_EVENTS = Number(process.env.EXTENSION_TELEMETRY_MAX_EVENTS || 3);
6187
6250
  const DEFAULT_DEBOUNCE_MS = Number(process.env.EXTENSION_TELEMETRY_DEBOUNCE_MS || 60000);
6188
- const DEFAULT_TIMEOUT_MS = Number(process.env.EXTENSION_TELEMETRY_TIMEOUT_MS || 300);
6251
+ const DEFAULT_TIMEOUT_MS = Number(process.env.EXTENSION_TELEMETRY_TIMEOUT_MS || 2000);
6189
6252
  const DEFAULT_AUDIT_MAX_BYTES = 1048576;
6190
6253
  function auditMaxBytes() {
6191
6254
  const raw = Number(process.env.EXTENSION_TELEMETRY_AUDIT_MAX_BYTES);
@@ -6762,9 +6825,68 @@ var __webpack_modules__ = {
6762
6825
  return await import(bridgeSpecifier);
6763
6826
  }
6764
6827
  var messaging = __webpack_require__("./helpers/messaging.ts");
6828
+ const TEMPLATE_CORPUS_REPO = 'extension-js/examples';
6829
+ const TEMPLATE_CORPUS_REF = 'f7f4e6efb56a7e5ae08d58dbff3972d94af7d021';
6830
+ const TEMPLATE_CORPUS_SLUGS = [
6831
+ 'action',
6832
+ 'action-locales',
6833
+ 'ai-chatgpt',
6834
+ 'ai-claude',
6835
+ 'ai-gemini',
6836
+ 'ai-perplexity',
6837
+ 'content',
6838
+ 'content-css-modules',
6839
+ 'content-custom-font',
6840
+ 'content-env',
6841
+ 'content-less',
6842
+ 'content-less-modules',
6843
+ 'content-main-world',
6844
+ 'content-multi-one-entry',
6845
+ 'content-multi-three-entries',
6846
+ 'content-preact',
6847
+ 'content-react',
6848
+ 'content-sass',
6849
+ 'content-sass-modules',
6850
+ 'content-svelte',
6851
+ "content-typescript",
6852
+ 'content-vue',
6853
+ 'init',
6854
+ "javascript",
6855
+ 'new',
6856
+ 'new-browser-flags',
6857
+ 'new-config-eslint',
6858
+ 'new-config-prettier',
6859
+ 'new-config-stylelint',
6860
+ 'new-crypto',
6861
+ 'new-env',
6862
+ 'new-less',
6863
+ 'new-preact',
6864
+ 'new-react',
6865
+ 'new-react-router',
6866
+ 'new-sass',
6867
+ 'new-svelte',
6868
+ "new-typescript",
6869
+ 'new-vue',
6870
+ 'playwright',
6871
+ 'preact',
6872
+ 'react',
6873
+ 'sidebar',
6874
+ 'sidebar-antd',
6875
+ 'sidebar-monorepo-turborepo',
6876
+ 'sidebar-shadcn',
6877
+ 'special-folders-pages',
6878
+ "special-folders-scripts",
6879
+ 'svelte',
6880
+ 'transformers-js',
6881
+ "typescript",
6882
+ 'vue'
6883
+ ];
6765
6884
  const DEFAULT_TEMPLATE = "javascript";
6766
- const TEMPLATE_CATALOG_URL = 'https://github.com/extension-js/examples/tree/main/examples';
6767
- const TEMPLATE_GROUPS = [
6885
+ const BUNDLED_TEMPLATES = [
6886
+ "javascript"
6887
+ ];
6888
+ const TEMPLATE_CATALOG_URL = `https://github.com/${TEMPLATE_CORPUS_REPO}/tree/${TEMPLATE_CORPUS_REF}/examples`;
6889
+ const CURATED_GROUPS = [
6768
6890
  {
6769
6891
  title: 'Starters',
6770
6892
  summary: 'a bare manifest, or one language or framework with sidebar UI',
@@ -6854,6 +6976,33 @@ var __webpack_modules__ = {
6854
6976
  ]
6855
6977
  }
6856
6978
  ];
6979
+ const UNCURATED_GROUP_TITLE = 'More templates';
6980
+ function buildTemplateGroups() {
6981
+ const published = new Set(TEMPLATE_CORPUS_SLUGS);
6982
+ const claimed = new Set();
6983
+ const groups = [];
6984
+ for (const group of CURATED_GROUPS){
6985
+ const templates = group.templates.filter((name)=>{
6986
+ if (!published.has(name) || claimed.has(name)) return false;
6987
+ claimed.add(name);
6988
+ return true;
6989
+ });
6990
+ if (templates.length) groups.push({
6991
+ ...group,
6992
+ templates
6993
+ });
6994
+ }
6995
+ const uncurated = TEMPLATE_CORPUS_SLUGS.filter((name)=>!claimed.has(name));
6996
+ if (uncurated.length) groups.push({
6997
+ title: UNCURATED_GROUP_TITLE,
6998
+ summary: 'published in the catalog, not yet grouped',
6999
+ templates: [
7000
+ ...uncurated
7001
+ ]
7002
+ });
7003
+ return groups;
7004
+ }
7005
+ const TEMPLATE_GROUPS = buildTemplateGroups();
6857
7006
  const TEMPLATE_ALIASES = [];
6858
7007
  function listTemplates() {
6859
7008
  return TEMPLATE_GROUPS.flatMap((group)=>group.templates);
@@ -6897,14 +7046,19 @@ var __webpack_modules__ = {
6897
7046
  function renderCreateTemplateHelp() {
6898
7047
  const total = listTemplates().length;
6899
7048
  const dim = (text)=>external_pintor_default().gray(text);
7049
+ const defaultIsBundled = BUNDLED_TEMPLATES.includes(DEFAULT_TEMPLATE);
6900
7050
  return [
6901
7051
  '',
6902
7052
  external_pintor_default().underline(external_pintor_default().blue(`Templates (${total})`)),
6903
7053
  renderTemplateList(),
6904
7054
  '',
6905
7055
  ` ${external_pintor_default().green('Default')}`,
6906
- ` ${external_pintor_default().blue(DEFAULT_TEMPLATE)} ${dim('is used when --template is omitted. It ships inside the CLI,')}`,
6907
- dim(' so it scaffolds with no network call.'),
7056
+ ` ${external_pintor_default().blue(DEFAULT_TEMPLATE)} ${dim('is used when --template is omitted.')}`,
7057
+ ...defaultIsBundled ? [
7058
+ dim(' It ships inside the CLI, so it scaffolds with no network.')
7059
+ ] : [
7060
+ dim(' It downloads the catalog archive like every other name.')
7061
+ ],
6908
7062
  '',
6909
7063
  ` ${external_pintor_default().green('Everything else')}`,
6910
7064
  dim(' downloads the catalog archive at create time, so it needs the'),
@@ -7097,7 +7251,7 @@ var __webpack_modules__ = {
7097
7251
  notes: [
7098
7252
  {
7099
7253
  usage: '--browser <chrome|chromium|edge|firefox|chromium-based|gecko-based|firefox-based|all>',
7100
- description: 'Install multiple browsers, browser families, or all'
7254
+ description: 'Install one or more managed browsers (comma-separated) or all'
7101
7255
  },
7102
7256
  {
7103
7257
  usage: '--where',
@@ -7116,13 +7270,17 @@ var __webpack_modules__ = {
7116
7270
  description: 'Remove managed browser binaries from the Extension.js cache',
7117
7271
  supportsSourceInspection: false,
7118
7272
  notes: [
7273
+ {
7274
+ usage: '--browser <chrome|chromium|edge|firefox|chromium-based|gecko-based|firefox-based|all>',
7275
+ description: 'Remove one or more managed browsers (comma-separated), same names as install'
7276
+ },
7119
7277
  {
7120
7278
  usage: '--all',
7121
7279
  description: 'Remove every managed browser binary'
7122
7280
  },
7123
7281
  {
7124
7282
  usage: '--where',
7125
- description: 'Print the managed browser cache root (or browser install path(s) when --browser/--all is provided)'
7283
+ description: 'Print the managed browser cache root (or browser install path(s) when a browser name, --browser, or --all is provided)'
7126
7284
  }
7127
7285
  ]
7128
7286
  },
@@ -7268,6 +7426,23 @@ AI assistants
7268
7426
  function unsupportedBrowserFlag(value, supported) {
7269
7427
  return `${getLoggingPrefix('error')} Unsupported --browser value: ${value}.\n${external_pintor_default().red('Choose one of:')} ${supported.join(', ')}${external_pintor_default().red('.')}`;
7270
7428
  }
7429
+ function browserNotInstallablePlain(value) {
7430
+ const name = String(value || '').trim().toLowerCase();
7431
+ if ('safari' === name || 'webkit-based' === name || name.includes('safari') || name.includes('webkit')) return "There is no Safari binary to install. Safari ships with macOS. Safari builds need the full Xcode app instead (Mac App Store), then run `extension build --browser safari`.";
7432
+ const display = name || String(value || 'browser');
7433
+ return `${display} cannot be installed by Extension.js. This CLI never downloads it. It is located from the system when present. Install it yourself, then run with --browser=${display}. Managed installs cover: chrome, chromium, edge, firefox.`;
7434
+ }
7435
+ function browserNotInstallable(value) {
7436
+ const name = String(value || '').trim().toLowerCase();
7437
+ if ('safari' === name || 'webkit-based' === name || name.includes('safari') || name.includes('webkit')) return `${getLoggingPrefix('error')} There is no Safari binary to install.\n${external_pintor_default().red('Safari ships with macOS. Safari builds need the full Xcode app')} ${external_pintor_default().red('(Mac App Store), then run')} ${messages_code('extension build --browser safari')}${external_pintor_default().red('.')}`;
7438
+ const display = name || String(value || 'browser');
7439
+ return `${getLoggingPrefix('error')} ${external_pintor_default().blue(display)} cannot be installed by Extension.js.\n${external_pintor_default().red('This CLI never downloads it. It is located from the system when present.')}\n${external_pintor_default().red('Install it yourself, then run with')} ${messages_code(`--browser=${display}`)}${external_pintor_default().red('.')}\n${external_pintor_default().red('Managed installs cover:')} chrome, chromium, edge, firefox${external_pintor_default().red('.')}`;
7440
+ }
7441
+ function browserDownloadFailed(browser, detail) {
7442
+ const name = String(browser || 'browser').trim() || 'browser';
7443
+ const body = String(detail || '').trim();
7444
+ return `${getLoggingPrefix('error')} Couldn't download ${external_pintor_default().blue(name)}.\n` + (body ? `${external_pintor_default().red(body)}\n` : '') + `${external_pintor_default().red('Retry, or install')} ${external_pintor_default().blue(name)} ${external_pintor_default().red('manually.')}`;
7445
+ }
7271
7446
  function safariOnlyOption(flags) {
7272
7447
  return `${getLoggingPrefix('error')} ${flags.map(messages_code).join(', ')} only appl${1 === flags.length ? 'ies' : 'y'} to Safari targets.\nAdd ${messages_code('--browser safari')} (or ${messages_code('webkit-based')}).`;
7273
7448
  }
@@ -7330,7 +7505,7 @@ Environment variables
7330
7505
 
7331
7506
  Available templates
7332
7507
  ${TEMPLATE_GROUPS.map((group)=>`- ${external_pintor_default().green(group.title)} ${messages_arg(`(${group.summary})`)}: ${group.templates.map((template)=>messages_code(template)).join(', ')}`).join('\n')}${TEMPLATE_ALIASES.length > 0 ? `\n- ${external_pintor_default().green('Alias')}: ${TEMPLATE_ALIASES.map((alias)=>`${messages_code(alias.name)} ${messages_arg(alias.note)}`).join(', ')}` : ''}
7333
- - ${messages_code(DEFAULT_TEMPLATE)} is the default when ${messages_code('--template')} is omitted. It ships inside the CLI and needs no network.
7508
+ - ${messages_code(DEFAULT_TEMPLATE)} is the default when ${messages_code('--template')} is omitted.${BUNDLED_TEMPLATES.includes(DEFAULT_TEMPLATE) ? ' It ships inside the CLI and needs no network.' : ''}
7334
7509
  - Every other name is downloaded from ${messages_code(TEMPLATE_CATALOG_URL)} at create time. A GitHub or ZIP URL works in place of a name.
7335
7510
  - A name that is not on this list fails with ${messages_code('TemplateNotFoundError')}. Run ${messages_code('extension create --help')} for the same list.
7336
7511
 
@@ -7467,9 +7642,13 @@ Cross-browser compatibility
7467
7642
  templates: {
7468
7643
  default: DEFAULT_TEMPLATE,
7469
7644
  bundled: [
7470
- DEFAULT_TEMPLATE
7645
+ ...BUNDLED_TEMPLATES
7471
7646
  ],
7472
7647
  catalogUrl: TEMPLATE_CATALOG_URL,
7648
+ corpus: {
7649
+ repo: TEMPLATE_CORPUS_REPO,
7650
+ ref: TEMPLATE_CORPUS_REF
7651
+ },
7473
7652
  names: listTemplates(),
7474
7653
  groups: TEMPLATE_GROUPS.map((group)=>({
7475
7654
  title: group.title,
@@ -7485,10 +7664,10 @@ Cross-browser compatibility
7485
7664
  },
7486
7665
  notes: [
7487
7666
  `extension create <name> with no --template scaffolds ${DEFAULT_TEMPLATE}`,
7488
- `${DEFAULT_TEMPLATE} is bundled with the CLI and scaffolds offline. Every other name downloads the examples archive at create time`,
7667
+ 'every name in bundled[] ships inside the CLI package and scaffolds offline. Every other name downloads the examples archive at create time',
7489
7668
  'a GitHub URL or a ZIP URL is accepted in place of a catalog name',
7490
7669
  'a name outside names[] fails with TemplateNotFoundError and creates nothing',
7491
- 'this list ships with the CLI, so it is the list this CLI version can scaffold, not necessarily the current contents of the catalog repository'
7670
+ `names[] is generated from ${TEMPLATE_CORPUS_REPO} at corpus.ref, the exact commit this CLI version downloads, so it is what this version can scaffold and not the current contents of the catalog repository`
7492
7671
  ]
7493
7672
  },
7494
7673
  capabilities: {
@@ -7676,6 +7855,7 @@ Cross-browser compatibility
7676
7855
  const browser = options.browser || 'chromium';
7677
7856
  const format = resolveFormat(options);
7678
7857
  const matches = makeFilter(options);
7858
+ if (options.signalsOnly) console.error("extension logs --signals-only: no signals emitter ships in this build, so dev sessions record no dx.signal events and this filter will print nothing.");
7679
7859
  if (options.follow) return void await followLogs(projectPath, browser, format, matches);
7680
7860
  const file = logsFilePath(projectPath, browser);
7681
7861
  if (!external_node_fs_default().existsSync(file)) {
@@ -8123,13 +8303,29 @@ Cross-browser compatibility
8123
8303
  'chrome',
8124
8304
  'edge',
8125
8305
  'firefox'
8126
- ] : String(value).split(',');
8306
+ ] : String(value).split(',').map((part)=>part.trim()).filter(Boolean);
8127
8307
  };
8308
+ const MANAGED_INSTALL_TARGETS = [
8309
+ 'chrome',
8310
+ 'chromium',
8311
+ 'edge',
8312
+ 'firefox',
8313
+ 'chromium-based',
8314
+ 'gecko-based',
8315
+ 'firefox-based'
8316
+ ];
8317
+ const MANAGED_INSTALL_TARGETS_HELP = [
8318
+ ...MANAGED_INSTALL_TARGETS,
8319
+ 'all'
8320
+ ].join(' | ');
8321
+ const MANAGED_INSTALL_BINARIES = [
8322
+ 'chrome',
8323
+ 'chromium',
8324
+ 'edge',
8325
+ 'firefox'
8326
+ ];
8128
8327
  const installTargets = (browser)=>'all' === browser ? [
8129
- 'chrome',
8130
- 'chromium',
8131
- 'edge',
8132
- 'firefox'
8328
+ ...MANAGED_INSTALL_BINARIES
8133
8329
  ] : vendors(browser);
8134
8330
  function validateVendors(vendorsList, onInvalid) {
8135
8331
  const supported = SUPPORTED_BROWSER_TARGETS;
@@ -8139,6 +8335,25 @@ Cross-browser compatibility
8139
8335
  }
8140
8336
  return true;
8141
8337
  }
8338
+ const MANAGED_INSTALL_TARGET_SET = new Set(MANAGED_INSTALL_TARGETS);
8339
+ const SUPPORTED_BROWSER_TARGET_SET = new Set(SUPPORTED_BROWSER_TARGETS);
8340
+ function classifyManagedInstallTarget(name) {
8341
+ const value = String(name || '').trim().toLowerCase();
8342
+ if (!value) return 'unknown';
8343
+ if (MANAGED_INSTALL_TARGET_SET.has(value)) return 'managed';
8344
+ if (SUPPORTED_BROWSER_TARGET_SET.has(value)) return 'not-installable';
8345
+ return 'unknown';
8346
+ }
8347
+ function firstNonManagedInstallTarget(targetsList) {
8348
+ for (const name of targetsList){
8349
+ const kind = classifyManagedInstallTarget(name);
8350
+ if ('managed' !== kind) return {
8351
+ name,
8352
+ kind
8353
+ };
8354
+ }
8355
+ return null;
8356
+ }
8142
8357
  function registerBuildCommand(program) {
8143
8358
  program.command('build').arguments('[project-name]').usage('[path-to-remote-extension] [options]').description(commandDescriptions.build).option(`--browser <${BROWSER_TARGETS_HELP}>`, 'specify a browser/engine to run. Defaults to `chromium`. `safari` builds a Safari app via Xcode (macOS only)').option('--polyfill [boolean]', 'whether or not to apply the cross-browser polyfill. Defaults to `false`', parseOptionalBoolean).option('--no-polyfill', 'disable the cross-browser polyfill').option('--zip [boolean]', 'whether or not to compress the extension into a ZIP file. Defaults to `false`', parseOptionalBoolean).option('--zip-source [boolean]', 'whether or not to include the source files in the ZIP file. Defaults to `false`', parseOptionalBoolean).option('--zip-filename <string>', 'specify the name of the ZIP file. Defaults to the extension name and version').option('--silent [boolean]', 'suppress the build summary output. Defaults to `false`', parseOptionalBoolean).option('--install [boolean]', '[internal] install project dependencies when missing', parseOptionalBoolean).option('--extensions <list>', 'comma-separated list of companion extensions or store URLs to load').option('--mode <development|production|none>', 'bundler mode override (also sets NODE_ENV). Defaults to `production`').option('--open [boolean]', 'open the built Safari app after packaging (safari targets only). Defaults to `false`', parseOptionalBoolean).option('--app-name <name>', 'override the Safari app name (safari targets only). Defaults to the manifest `name`').option('--bundle-id <reverse.dns>', 'set a user-owned Safari bundle identifier (safari targets only). Defaults to a generated dev.extensionjs.* id').option('--macos-only [boolean]', 'generate a macOS-only Safari Xcode project (safari targets only). Pass `false` for a universal macOS + iOS project. Defaults to `true`', parseOptionalBoolean).option('--force-regenerate', 'regenerate the Safari Xcode project even when up to date (safari targets only)').option('--output <pretty|json>', 'result format. Use json for a schema-1 envelope on stdout').addOption(new external_commander_namespaceObject.Option('--debug', 'print maintainer diagnostics alongside normal output')).addOption(new external_commander_namespaceObject.Option('--author, --author-mode', 'deprecated alias for --debug').hideHelp()).action(async (pathOrRemoteUrl, { browser = 'chromium', ...buildOptions })=>{
8144
8359
  if (buildOptions.debug || buildOptions.author || buildOptions.authorMode) {
@@ -9217,31 +9432,75 @@ Cross-browser compatibility
9217
9432
  function install_emit(frame) {
9218
9433
  console.log(JSON.stringify(frame));
9219
9434
  }
9435
+ function errorText(error) {
9436
+ return error instanceof Error ? error.message : String(error);
9437
+ }
9438
+ function isNotInstallableRefusal(error) {
9439
+ return Boolean(error && 'object' == typeof error && ('BrowserNotInstallableError' === error.name || 'BROWSER_NOT_INSTALLABLE' === error.code));
9440
+ }
9441
+ async function refuseNotInstallable(command, error, asJson) {
9442
+ const message = errorText(error);
9443
+ if (asJson) install_emit(messaging.Pr.fail(command, 'usage', {
9444
+ code: messaging.Lp.E_BROWSER_NOT_INSTALLABLE,
9445
+ message
9446
+ }));
9447
+ else console.error(message);
9448
+ await exitAfterDrain(1);
9449
+ }
9450
+ async function refuseIfNotManagedTarget(command, browserList, asJson) {
9451
+ const bad = firstNonManagedInstallTarget(browserList);
9452
+ if (!bad) return false;
9453
+ if ('not-installable' === bad.kind) {
9454
+ const message = browserNotInstallablePlain(bad.name);
9455
+ if (asJson) install_emit(messaging.Pr.fail(command, 'usage', {
9456
+ code: messaging.Lp.E_BROWSER_NOT_INSTALLABLE,
9457
+ message
9458
+ }));
9459
+ else console.error(browserNotInstallable(bad.name));
9460
+ await exitAfterDrain(1);
9461
+ return true;
9462
+ }
9463
+ if (asJson) install_emit(messaging.Pr.fail(command, 'usage', {
9464
+ code: messaging.Lp.E_UNSUPPORTED_BROWSER,
9465
+ message: `Unsupported browser: ${bad.name}.`
9466
+ }));
9467
+ else console.error(unsupportedBrowserFlag(bad.name, [
9468
+ ...MANAGED_INSTALL_TARGETS
9469
+ ]));
9470
+ await exitAfterDrain(1);
9471
+ return true;
9472
+ }
9473
+ async function refuseDownloadFailed(browser, error, asJson) {
9474
+ const detail = errorText(error);
9475
+ if (asJson) install_emit(messaging.Pr.fail('install', 'failed', {
9476
+ code: messaging.Lp.E_BROWSER_DOWNLOAD,
9477
+ message: detail
9478
+ }, {
9479
+ hint: `Retry, or install ${browser} manually.`
9480
+ }));
9481
+ else console.error(browserDownloadFailed(browser, detail));
9482
+ await exitAfterDrain(1);
9483
+ }
9220
9484
  function registerInstallCommand(program) {
9221
- program.command('install').arguments('[browser-name]').usage('[browser-name] [options]').description(commandDescriptions.install).option('--browser <chrome | chromium | edge | firefox | chromium-based | gecko-based | firefox-based | all>', 'override the positional browser name. Supports comma-separated values and `all`.').option('--where', 'print the resolved managed browser cache root').option('--output <pretty|json>', 'result format. Use json for a schema-1 envelope on stdout').action(async (browserArg, options)=>{
9485
+ program.command('install').arguments('[browser-name]').usage('[browser-name] [options]').description(commandDescriptions.install).option(`--browser <${MANAGED_INSTALL_TARGETS_HELP}>`, 'override the positional browser name. Supports comma-separated values and `all`.').option('--where', 'print the resolved managed browser cache root').option('--output <pretty|json>', 'result format. Use json for a schema-1 envelope on stdout').action(async (browserArg, options)=>{
9222
9486
  const asJson = 'json' === options.output;
9487
+ const named = Boolean(options.browser || browserArg);
9223
9488
  const selectedBrowser = options.browser || browserArg || 'chromium';
9224
9489
  const browserList = installTargets(selectedBrowser);
9225
- let unsupported = '';
9226
- const vendorsAreSupported = validateVendors(browserList, (invalid, supported)=>{
9227
- unsupported = invalid;
9228
- if (asJson) return;
9229
- console.error(unsupportedBrowserFlag(invalid, supported));
9230
- });
9231
- if (!vendorsAreSupported) {
9232
- if (asJson) install_emit(messaging.Pr.fail('install', 'usage', {
9233
- code: messaging.Lp.E_UNSUPPORTED_BROWSER,
9234
- message: `Unsupported browser: ${unsupported}.`
9235
- }));
9236
- await exitAfterDrain(1);
9237
- return;
9490
+ if (!(options.where && !named)) {
9491
+ if (await refuseIfNotManagedTarget('install', browserList, asJson)) return;
9238
9492
  }
9239
9493
  const { extensionInstall, getManagedBrowsersCacheRoot, getManagedBrowserInstallDir } = await import("extension-install");
9240
9494
  if (options.where) {
9241
- const named = Boolean(options.browser || browserArg);
9242
- const paths = named ? browserList.map((browser)=>getManagedBrowserInstallDir(browser)) : [
9243
- getManagedBrowsersCacheRoot()
9244
- ];
9495
+ let paths;
9496
+ try {
9497
+ paths = named ? browserList.map((browser)=>getManagedBrowserInstallDir(browser)) : [
9498
+ getManagedBrowsersCacheRoot()
9499
+ ];
9500
+ } catch (error) {
9501
+ await refuseNotInstallable('install', error, asJson);
9502
+ return;
9503
+ }
9245
9504
  if (asJson) install_emit(messaging.Pr.ok('install', 'located', {
9246
9505
  paths
9247
9506
  }));
@@ -9255,45 +9514,21 @@ Cross-browser compatibility
9255
9514
  });
9256
9515
  installed.push(browser);
9257
9516
  } catch (error) {
9258
- if (!asJson) throw error;
9259
- install_emit(messaging.Pr.fail('install', 'failed', {
9260
- code: messaging.Lp.E_BROWSER_DOWNLOAD,
9261
- message: error instanceof Error ? error.message : String(error)
9262
- }, {
9263
- hint: `Retry, or install ${browser} manually.`
9264
- }));
9265
- await exitAfterDrain(1);
9517
+ if (isNotInstallableRefusal(error)) return void await refuseNotInstallable('install', error, asJson);
9518
+ await refuseDownloadFailed(browser, error, asJson);
9266
9519
  return;
9267
9520
  }
9268
9521
  if (asJson) install_emit(messaging.Pr.ok('install', 'installed', {
9269
9522
  browsers: installed
9270
9523
  }));
9271
9524
  });
9272
- program.command('uninstall').usage('<browser-name> | --all | --where').description(commandDescriptions.uninstall).option('--browser <browser-name>', 'browser to uninstall').option('--all', 'remove all managed browser binaries').option('--where', 'print the resolved managed browser cache root').option('--output <pretty|json>', 'result format. Use json for a schema-1 envelope on stdout').argument('[browser-name]').action(async (browserArg, { browser, all, where, output })=>{
9525
+ program.command('uninstall').usage('<browser-name> | --all | --where').description(commandDescriptions.uninstall).option(`--browser <${MANAGED_INSTALL_TARGETS_HELP}>`, 'browser(s) to uninstall. Supports comma-separated values and `all`.').option('--all', 'remove all managed browser binaries').option('--where', 'print the resolved managed browser cache root').option('--output <pretty|json>', 'result format. Use json for a schema-1 envelope on stdout').argument('[browser-name]').action(async (browserArg, { browser, all, where, output })=>{
9273
9526
  const asJson = 'json' === output;
9274
- const target = browserArg || browser;
9527
+ const named = Boolean(browserArg || browser);
9528
+ const selected = all || 'all' === browserArg || 'all' === browser ? 'all' : browser || browserArg;
9275
9529
  const { extensionUninstall, getManagedBrowsersCacheRoot, getManagedBrowserInstallDir } = await import("extension-install");
9276
- if (where) {
9277
- let paths;
9278
- if (all) paths = installTargets('all').map((name)=>getManagedBrowserInstallDir(name));
9279
- else if (target) {
9280
- const list = vendors(target);
9281
- let unsupported = '';
9282
- const vendorsAreSupported = validateVendors(list, (invalid, supported)=>{
9283
- unsupported = invalid;
9284
- if (asJson) return;
9285
- console.error(unsupportedBrowserFlag(invalid, supported));
9286
- });
9287
- if (!vendorsAreSupported) {
9288
- if (asJson) install_emit(messaging.Pr.fail('uninstall', 'usage', {
9289
- code: messaging.Lp.E_UNSUPPORTED_BROWSER,
9290
- message: `Unsupported browser: ${unsupported}.`
9291
- }));
9292
- await exitAfterDrain(1);
9293
- return;
9294
- }
9295
- paths = list.map((name)=>getManagedBrowserInstallDir(name));
9296
- } else paths = [
9530
+ if (where && !named && !all) {
9531
+ const paths = [
9297
9532
  getManagedBrowsersCacheRoot()
9298
9533
  ];
9299
9534
  if (asJson) install_emit(messaging.Pr.ok('uninstall', 'located', {
@@ -9302,23 +9537,51 @@ Cross-browser compatibility
9302
9537
  else for (const location of paths)console.log(location);
9303
9538
  return;
9304
9539
  }
9540
+ if (!selected) {
9541
+ const message = 'A browser target is required. Pass a browser name, --browser <name>, or --all.';
9542
+ if (asJson) install_emit(messaging.Pr.fail('uninstall', 'usage', {
9543
+ code: messaging.Lp.E_ARGS,
9544
+ message
9545
+ }));
9546
+ else console.error(message);
9547
+ await exitAfterDrain(1);
9548
+ return;
9549
+ }
9550
+ const browserList = installTargets(selected);
9551
+ if (await refuseIfNotManagedTarget('uninstall', browserList, asJson)) return;
9552
+ if (where) {
9553
+ let paths;
9554
+ try {
9555
+ paths = browserList.map((name)=>getManagedBrowserInstallDir(name));
9556
+ } catch (error) {
9557
+ await refuseNotInstallable('uninstall', error, asJson);
9558
+ return;
9559
+ }
9560
+ if (asJson) install_emit(messaging.Pr.ok('uninstall', 'located', {
9561
+ paths
9562
+ }));
9563
+ else for (const location of paths)console.log(location);
9564
+ return;
9565
+ }
9566
+ const removeAll = Boolean(all || 'all' === selected);
9305
9567
  try {
9306
9568
  await extensionUninstall({
9307
- browser: target,
9308
- all
9569
+ browser: removeAll ? void 0 : browserList.join(','),
9570
+ all: removeAll
9309
9571
  });
9310
9572
  } catch (error) {
9311
- if (!asJson) throw error;
9312
- install_emit(messaging.Pr.fail('uninstall', 'failed', {
9573
+ if (isNotInstallableRefusal(error)) return void await refuseNotInstallable('uninstall', error, asJson);
9574
+ if (asJson) install_emit(messaging.Pr.fail('uninstall', 'failed', {
9313
9575
  code: messaging.Lp.E_BROWSER_UNINSTALL,
9314
- message: error instanceof Error ? error.message : String(error)
9576
+ message: errorText(error)
9315
9577
  }));
9578
+ else console.error(errorText(error));
9316
9579
  await exitAfterDrain(1);
9317
9580
  return;
9318
9581
  }
9319
9582
  if (asJson) install_emit(messaging.Pr.ok('uninstall', 'uninstalled', {
9320
- browser: target,
9321
- all
9583
+ browsers: browserList,
9584
+ all: removeAll
9322
9585
  }));
9323
9586
  });
9324
9587
  }
@@ -9328,7 +9591,7 @@ Cross-browser compatibility
9328
9591
  'Manifest file not found'
9329
9592
  ];
9330
9593
  function registerPreviewCommand(program) {
9331
- program.command('preview').arguments('[project-name]').usage('[path-to-remote-extension] [options]').description(commandDescriptions.preview).addHelpText('after', '\nAdditional option:\n --no-browser do not launch the browser\n').option('--profile <path-to-file | boolean>', 'what path to use for the browser profile. A boolean value of false sets the profile to the default user profile. Defaults to a fresh profile').option(`--browser <${NO_SAFARI_BROWSER_TARGETS_HELP}>`, 'specify a browser/engine to run. Defaults to `chromium`').option('--chromium-binary <path-to-binary>', 'specify a path to the Chromium binary. This option overrides the --browser setting. Defaults to the system default').option('--gecko-binary, --firefox-binary <path-to-binary>', 'specify a path to the Gecko binary. This option overrides the --browser setting. Defaults to the system default').option('--starting-url <url>', 'specify the starting URL for the browser. Defaults to `undefined`').option('--port <port>', 'specify the port to use for the development server. Defaults to `8080`').option('--log-context <list>', '[experimental] comma-separated contexts to include (background,content,page,sidebar,popup,options,devtools). Use `all` to include all contexts (default)').option('--logs <off|error|warn|info|debug|trace|all>', '[experimental] minimum centralized logger level to display in terminal (default: off)').option('--log-format <pretty|json|ndjson>', '[experimental] output format for logger events. Defaults to `pretty`').option('--no-log-timestamps', 'disable ISO timestamps in pretty output').option('--no-log-color', 'disable color in pretty output').option('--log-url <pattern>', '[experimental] only show logs where event.url matches this substring or regex (/re/i)').option('--log-tab <id>', 'only show logs for a specific tabId (number)').option('--extensions <list>', 'comma-separated list of companion extensions or store URLs to load').option('--output <pretty|json>', 'result format. Use json for a schema-1 envelope on stdout').addOption(new external_commander_namespaceObject.Option('--debug', 'print maintainer diagnostics alongside normal output')).addOption(new external_commander_namespaceObject.Option('--author, --author-mode', 'deprecated alias for --debug').hideHelp()).action(async (pathOrRemoteUrl, options, command)=>{
9594
+ program.command('preview').arguments('[project-name]').usage('[path-to-remote-extension] [options]').description(commandDescriptions.preview).addHelpText('after', '\nAdditional option:\n --no-browser do not launch the browser\n').option('--profile <path-to-file | boolean>', 'what path to use for the browser profile. A boolean value of false sets the profile to the default user profile. Defaults to a fresh profile').option(`--browser <${NO_SAFARI_BROWSER_TARGETS_HELP}>`, 'specify a browser/engine to run. Defaults to `chromium`').option('--chromium-binary <path-to-binary>', 'specify a path to the Chromium binary. This option overrides the --browser setting. Defaults to the system default').option('--gecko-binary, --firefox-binary <path-to-binary>', 'specify a path to the Gecko binary. This option overrides the --browser setting. Defaults to the system default').option('--starting-url <url>', 'specify the starting URL for the browser. Defaults to `undefined`').option('--port <port>', 'specify the port to use for the development server. Defaults to `8080`').option('--log-context <list>', '[experimental] comma-separated contexts to include (background,content,page,sidebar,popup,options,devtools). Use `all` to include all contexts (default)').option('--logs <off|error|warn|info|debug|trace|all>', '[experimental] minimum centralized logger level to display in terminal (default: off)').option('--log-format <pretty|json|ndjson>', '[experimental] output format for logger events. Defaults to `pretty`').option('--no-log-timestamps', 'disable ISO timestamps in pretty output').option('--no-log-color', 'disable color in pretty output').option('--log-url <pattern>', '[experimental] only show logs where event.url matches this substring or regex (/re/i)').option('--log-tab <id>', 'only show logs for a specific tabId (number)').option('--extensions <list>', 'comma-separated list of companion extensions or store URLs to load').option('--output-path <dir>', 'path to an existing unpacked extension directory. Defaults to dist/<browser> when available').option('--output <pretty|json>', 'result format. Use json for a schema-1 envelope on stdout').addOption(new external_commander_namespaceObject.Option('--debug', 'print maintainer diagnostics alongside normal output')).addOption(new external_commander_namespaceObject.Option('--author, --author-mode', 'deprecated alias for --debug').hideHelp()).action(async (pathOrRemoteUrl, options, command)=>{
9332
9595
  const { browser = 'chromium', ...previewOptions } = options;
9333
9596
  if (previewOptions.debug || previewOptions.author || previewOptions.authorMode) {
9334
9597
  process.env.EXTENSION_DEBUG = '1';
@@ -9336,6 +9599,7 @@ Cross-browser compatibility
9336
9599
  if (!process.env.EXTENSION_VERBOSE) process.env.EXTENSION_VERBOSE = '1';
9337
9600
  }
9338
9601
  const asJson = 'json' === previewOptions.output;
9602
+ if (asJson) process.env.EXTENSION_OUTPUT = 'json';
9339
9603
  const emit = (frame)=>{
9340
9604
  console.log(JSON.stringify(frame));
9341
9605
  };
@@ -9384,6 +9648,7 @@ Cross-browser compatibility
9384
9648
  port: previewOptions.port,
9385
9649
  noBrowser: await resolveNoBrowser(pathOrRemoteUrl || process.cwd(), 'preview'),
9386
9650
  extensions: parseExtensionsList(previewOptions.extensions),
9651
+ outputPath: previewOptions.outputPath,
9387
9652
  logLevel: logsOption || previewOptions.logLevel || void 0,
9388
9653
  logContexts,
9389
9654
  logFormat: previewOptions.logFormat,
@@ -9587,10 +9852,12 @@ Cross-browser compatibility
9587
9852
  if (!process.env.EXTENSION_VERBOSE) process.env.EXTENSION_VERBOSE = '1';
9588
9853
  }
9589
9854
  const asJson = 'json' === resolveOutputFormat(startOptions);
9855
+ if (asJson) process.env.EXTENSION_OUTPUT = 'json';
9590
9856
  const list = vendors(browser);
9591
9857
  let unsupportedBrowser = '';
9592
9858
  const vendorsAreSupported = validateVendors(list, (invalid, supported)=>{
9593
9859
  unsupportedBrowser = invalid;
9860
+ if (asJson) return;
9594
9861
  console.error(unsupportedBrowserFlag(invalid, supported));
9595
9862
  });
9596
9863
  if (!vendorsAreSupported) start_failAndExit(asJson, 'usage', {
@@ -9598,10 +9865,10 @@ Cross-browser compatibility
9598
9865
  message: `Unsupported browser: ${unsupportedBrowser}`
9599
9866
  });
9600
9867
  if (list.some(isSafariVendor)) {
9601
- console.error(safariCommandNotSupported('start'));
9868
+ if (!asJson) console.error(safariCommandNotSupported('start'));
9602
9869
  start_failAndExit(asJson, 'usage', {
9603
- code: messaging.Lp.E_UNSUPPORTED_BROWSER,
9604
- message: 'Safari targets are not supported by start.'
9870
+ code: messaging.Lp.E_COMMAND_UNSUPPORTED_FOR_TARGET,
9871
+ message: 'Safari is not supported by start.'
9605
9872
  });
9606
9873
  }
9607
9874
  if (startOptions.wait) {