extension 4.1.31 → 4.1.32

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.
Files changed (32) hide show
  1. package/dist/597.cjs +27 -15
  2. package/dist/browsers.cjs +623 -180
  3. package/dist/cli.cjs +996 -258
  4. package/dist/extension/__spec__/exec/gecko-system-profile.d.ts +3 -0
  5. package/dist/extension/browsers/__spec__/safari-fake-tools.d.ts +10 -1
  6. package/dist/extension/browsers/browsers-lib/instance-registry.d.ts +1 -0
  7. package/dist/extension/browsers/browsers-lib/messages.d.ts +12 -0
  8. package/dist/extension/browsers/browsers-lib/ready-stamp.d.ts +6 -0
  9. package/dist/extension/browsers/browsers-lib/resolve-profile.d.ts +1 -0
  10. package/dist/extension/browsers/browsers-types.d.ts +1 -0
  11. package/dist/extension/browsers/index.d.ts +1 -0
  12. package/dist/extension/browsers/run-chromium/cdp/cdp-client.d.ts +1 -0
  13. package/dist/extension/browsers/run-chromium/cdp/coded-error.d.ts +6 -0
  14. package/dist/extension/browsers/run-chromium/cdp/pipe-guard.d.ts +8 -0
  15. package/dist/extension/browsers/run-chromium/chromium-launch/index.d.ts +1 -0
  16. package/dist/extension/browsers/run-firefox/firefox-types.d.ts +1 -1
  17. package/dist/extension/browsers/run-firefox/rdp/evaluate-extension-document.d.ts +31 -1
  18. package/dist/extension/browsers/run-firefox/rdp/remote-firefox/evaluate.d.ts +4 -1
  19. package/dist/extension/browsers/run-firefox/rdp/remote-firefox/messaging-client.d.ts +1 -1
  20. package/dist/extension/browsers/run-only.d.ts +1 -0
  21. package/dist/extension/browsers/run-safari/safari-launch/index.d.ts +2 -1
  22. package/dist/extension/browsers/run-safari/safari-launch/tools.d.ts +11 -0
  23. package/dist/extension/browsers/run-safari/safari-launch/webdriver.d.ts +15 -0
  24. package/dist/extension/commands/act.d.ts +10 -0
  25. package/dist/extension/config-types.d.ts +15 -3
  26. package/dist/extension/helpers/messaging.d.ts +12 -4
  27. package/dist/extension/helpers/node-version-guard.d.ts +2 -1
  28. package/dist/extension/helpers/ready-contract-codes.d.ts +4 -0
  29. package/dist/extension/helpers/template-catalog.d.ts +1 -1
  30. package/dist/extension/helpers/template-corpus.generated.d.ts +1 -1
  31. package/dist/extension/index.d.ts +1 -1
  32. package/package.json +4 -4
package/dist/cli.cjs CHANGED
@@ -423,6 +423,7 @@ var __webpack_modules__ = {
423
423
  });
424
424
  },
425
425
  "./browsers/browsers-lib/instance-registry.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
426
+ var _helpers_messaging__rspack_import_0 = __webpack_require__("./helpers/messaging.ts");
426
427
  function _define_property(obj, key, value) {
427
428
  if (key in obj) Object.defineProperty(obj, key, {
428
429
  value: value,
@@ -435,7 +436,7 @@ var __webpack_modules__ = {
435
436
  }
436
437
  class AmbiguousInstanceError extends Error {
437
438
  constructor(protocol, instanceId){
438
- super(instanceId ? `Cannot resolve the ${protocol.toUpperCase()} port for instance "${instanceId}": it has not registered a port and no fallback was provided. Refusing to fall back to the most recently launched browser to avoid crossing instance streams.` : `Cannot resolve a ${protocol.toUpperCase()} port without an instance id and no fallback was provided. Refusing to fall back to the most recently launched browser to avoid crossing instance streams.`), _define_property(this, "protocol", void 0), _define_property(this, "instanceId", void 0);
439
+ super(instanceId ? `Cannot resolve the ${protocol.toUpperCase()} port for instance "${instanceId}": it has not registered a port and no fallback was provided. Refusing to fall back to the most recently launched browser to avoid crossing instance streams.` : `Cannot resolve a ${protocol.toUpperCase()} port without an instance id and no fallback was provided. Refusing to fall back to the most recently launched browser to avoid crossing instance streams.`), _define_property(this, "code", _helpers_messaging__rspack_import_0.Lp.E_INSTANCE_AMBIGUOUS), _define_property(this, "protocol", void 0), _define_property(this, "instanceId", void 0);
439
440
  this.name = 'AmbiguousInstanceError';
440
441
  this.protocol = protocol;
441
442
  this.instanceId = instanceId;
@@ -765,6 +766,24 @@ var __webpack_modules__ = {
765
766
  const next = 'dev' === command ? 'The dev server is still running but reloads cannot be delivered, restart "extension dev" to relaunch the browser.' : `The ${command} session is over.`;
766
767
  return `[browser] ${browser} ${how}. ${next}`;
767
768
  }
769
+ function systemProfileSourceLabel(source) {
770
+ if ('env' === source.kind) return `${source.name}=true`;
771
+ if ('config' === source.kind) return 'profile: false in extension.config.js';
772
+ return '--profile=false';
773
+ }
774
+ function systemProfileSourceFix(source) {
775
+ if ('env' === source.kind) return `unset ${source.name}`;
776
+ if ('config' === source.kind) return 'remove profile: false from extension.config.js';
777
+ return 'drop --profile=false';
778
+ }
779
+ function geckoSystemProfileRefused(browser, sources) {
780
+ const name = capitalizedBrowserName(browser);
781
+ const fixes = sources.map(systemProfileSourceFix).join(' and ');
782
+ return `${getLoggingPrefix('error')} ${name} can't load the add-on in its own profile, so it was not launched.\n${pintor__rspack_import_8_default().gray('SET BY')} ${sources.map(systemProfileSourceLabel).join(', ')}\nRemote debugging is off in a browser's own profile, and the add-on can only be installed over it.\nTo fix, ${fixes}, then let Extension.js manage the profile or pass ${pintor__rspack_import_8_default().blue('--profile=<path>')} to use a profile of your own.`;
783
+ }
784
+ function browserStderrTail(browser, lines) {
785
+ return `[browser] ${browser} wrote this before it exited:\n${lines.map((line)=>` ${line}`).join('\n')}`;
786
+ }
768
787
  function browserGoneBeforeReady(browser) {
769
788
  return `${getLoggingPrefix('error')} ${capitalizedBrowserName(browser)} exited before the extension loaded, so nothing is running.\nThe dev server keeps watching, but nothing will load until the browser is relaunched. Restart "extension dev".`;
770
789
  }
@@ -916,6 +935,12 @@ var __webpack_modules__ = {
916
935
  function safariNotYetRegistered(appName) {
917
936
  return `${getLoggingPrefix('info')} Safari hasn't picked up ${pintor__rspack_import_8_default().yellow(appName)} yet.\nOpen the app once, then check Safari ▸ Settings ▸ Extensions.`;
918
937
  }
938
+ function safariWebDriverSession(port, sessionId) {
939
+ return `${getLoggingPrefix('info')} WebDriver session ${pintor__rspack_import_8_default().gray(sessionId)} on port ${pintor__rspack_import_8_default().yellow(String(port))}.\nready.json carries it as ${pintor__rspack_import_8_default().gray('webdriverPort')} and ${pintor__rspack_import_8_default().gray('webdriverSessionId')}, attach to it instead of opening another.`;
940
+ }
941
+ function safariWebDriverUnavailable(reason) {
942
+ return `${getLoggingPrefix('info')} No WebDriver session for this run: ${reason}\nRun ${pintor__rspack_import_8_default().gray('safaridriver --enable')} once and turn on Safari ▸ Develop ▸ Allow Remote Automation so tools can read Safari pages.`;
943
+ }
919
944
  function safariRebuilt(appName) {
920
945
  return `${getLoggingPrefix('success')} Rebuilt ${pintor__rspack_import_8_default().yellow(appName)}.`;
921
946
  }
@@ -1136,17 +1161,20 @@ var __webpack_modules__ = {
1136
1161
  H1: ()=>safariRegenerationDiscards,
1137
1162
  HH: ()=>messageWithoutSenderError,
1138
1163
  HL: ()=>binaryNotExecutable,
1164
+ Hp: ()=>safariWebDriverSession,
1139
1165
  I5: ()=>chromiumForkNotInstalled,
1140
1166
  Ih: ()=>browserNotInstalledError,
1141
1167
  JB: ()=>devChannelSnapshotInUse,
1142
1168
  KP: ()=>safariBuildCalled,
1143
1169
  L: ()=>chromiumManifestLoadBlockers,
1144
1170
  LD: ()=>firefoxDryRunBinary,
1171
+ LT: ()=>browserStderrTail,
1145
1172
  M3: ()=>cdpClientConnected,
1146
1173
  M6: ()=>chromiumExtensionLoadRefused,
1147
1174
  MG: ()=>prettyPuppeteerInstallGuidance,
1148
1175
  MQ: ()=>firefoxFailedToStart,
1149
1176
  MS: ()=>errorConnectingToBrowser,
1177
+ Mm: ()=>geckoSystemProfileRefused,
1150
1178
  N4: ()=>enhancedProcessManagementUnhandledRejection,
1151
1179
  NO: ()=>mv3BackgroundScriptsNotSupportedByChromium,
1152
1180
  NT: ()=>firstRunInstallDeclined,
@@ -1204,6 +1232,7 @@ var __webpack_modules__ = {
1204
1232
  l9: ()=>parsingPacketError,
1205
1233
  lO: ()=>firefoxDryRunArgs,
1206
1234
  l_: ()=>safariConverted,
1235
+ lb: ()=>safariWebDriverUnavailable,
1207
1236
  lk: ()=>firstRunInstallOffer,
1208
1237
  ne: ()=>requireChromiumBinaryForChromiumBased,
1209
1238
  nn: ()=>chromeProcessExited,
@@ -1723,6 +1752,29 @@ var __webpack_modules__ = {
1723
1752
  (0, _write_json_atomic__rspack_import_3.Z)(readyPath, ready);
1724
1753
  } catch {}
1725
1754
  }
1755
+ function stampReadyWebDriver(extensionOutputPath, details, runId) {
1756
+ try {
1757
+ if (!extensionOutputPath) return;
1758
+ const readyPath = readyPathFor(extensionOutputPath);
1759
+ if (!node_fs__rspack_import_0.existsSync(readyPath)) return;
1760
+ const ready = JSON.parse(node_fs__rspack_import_0.readFileSync(readyPath, 'utf-8'));
1761
+ if (isForeignRun(ready, runId)) return;
1762
+ const sessionId = String(details?.sessionId || '').trim();
1763
+ const port = details?.port;
1764
+ if ('number' == typeof port && Number.isFinite(port) && sessionId) {
1765
+ ready.webdriverPort = port;
1766
+ ready.webdriverSessionId = sessionId;
1767
+ delete ready.webdriverUnavailableReason;
1768
+ } else {
1769
+ const reason = String(details?.unavailableReason || '').trim();
1770
+ if (!reason) return;
1771
+ delete ready.webdriverPort;
1772
+ delete ready.webdriverSessionId;
1773
+ ready.webdriverUnavailableReason = reason;
1774
+ }
1775
+ (0, _write_json_atomic__rspack_import_3.Z)(readyPath, ready);
1776
+ } catch {}
1777
+ }
1726
1778
  function stampReadyBrowserLaunch(extensionOutputPath, details, runId) {
1727
1779
  try {
1728
1780
  if (!extensionOutputPath) return;
@@ -1778,6 +1830,18 @@ var __webpack_modules__ = {
1778
1830
  const code = error?.code;
1779
1831
  return 'string' == typeof code && code.startsWith('E_') ? code : void 0;
1780
1832
  }
1833
+ function stampReadyCdpFault(extensionOutputPath, code, detail, runId) {
1834
+ try {
1835
+ if (!extensionOutputPath || !code) return;
1836
+ const readyPath = readyPathFor(extensionOutputPath);
1837
+ if (!node_fs__rspack_import_0.existsSync(readyPath)) return;
1838
+ const ready = JSON.parse(node_fs__rspack_import_0.readFileSync(readyPath, 'utf-8'));
1839
+ if (isForeignRun(ready, runId)) return;
1840
+ ready.cdpFaultCode = code;
1841
+ ready.cdpFaultMessage = String(detail || '').trim() || 'the CDP wire failed after launch';
1842
+ (0, _write_json_atomic__rspack_import_3.Z)(readyPath, ready);
1843
+ } catch {}
1844
+ }
1781
1845
  function stampReadyExtensionId(extensionOutputPath, extensionId) {
1782
1846
  try {
1783
1847
  const id = String(extensionId || '').trim();
@@ -1849,8 +1913,10 @@ var __webpack_modules__ = {
1849
1913
  M: ()=>stampReadyBrowserLaunch,
1850
1914
  NE: ()=>launchFailureCode,
1851
1915
  O3: ()=>readyPathFor,
1916
+ QP: ()=>stampReadyCdpFault,
1852
1917
  Uf: ()=>readReadyRunId,
1853
1918
  Wi: ()=>stampReadyBrowserExited,
1919
+ ZC: ()=>stampReadyWebDriver,
1854
1920
  __: ()=>stampReadyRdpPort,
1855
1921
  dT: ()=>describeLaunchFailure,
1856
1922
  dz: ()=>stampReadyBrowserLaunchFailed,
@@ -2032,7 +2098,8 @@ var __webpack_modules__ = {
2032
2098
  "./browsers/browsers-lib/resolve-profile.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
2033
2099
  __webpack_require__.d(__webpack_exports__, {
2034
2100
  Md: ()=>normalizeProfileOption,
2035
- c6: ()=>resolveProfileConfig
2101
+ c6: ()=>resolveProfileConfig,
2102
+ Jv: ()=>systemProfileEnvName
2036
2103
  });
2037
2104
  var external_node_fs_ = __webpack_require__("node:fs");
2038
2105
  var external_node_path_ = __webpack_require__("node:path");
@@ -2040,6 +2107,15 @@ var __webpack_modules__ = {
2040
2107
  var messaging = __webpack_require__("./helpers/messaging.ts");
2041
2108
  var messages = __webpack_require__("./browsers/browsers-lib/messages.ts");
2042
2109
  var shared_utils = __webpack_require__("./browsers/browsers-lib/shared-utils.ts");
2110
+ function systemProfileEnvName(env = process.env) {
2111
+ for (const name of [
2112
+ 'EXTENSION_USE_SYSTEM_PROFILE',
2113
+ 'EXTJS_USE_SYSTEM_PROFILE'
2114
+ ]){
2115
+ const value = env[name];
2116
+ if (value) return 'true' === String(value).toLowerCase().trim() ? name : void 0;
2117
+ }
2118
+ }
2043
2119
  function hasExplicit(rawProfile) {
2044
2120
  return 'string' == typeof rawProfile && rawProfile.trim().length > 0;
2045
2121
  }
@@ -2878,6 +2954,7 @@ var __webpack_modules__ = {
2878
2954
  extension: opts.extensionsToLoad,
2879
2955
  browser: opts.browser,
2880
2956
  profile: opts.profile,
2957
+ profileSource: opts.profileSource,
2881
2958
  preferences: opts.preferences,
2882
2959
  browserFlags: opts.browserFlags,
2883
2960
  startingUrl: opts.startingUrl,
@@ -2945,19 +3022,32 @@ var __webpack_modules__ = {
2945
3022
  };
2946
3023
  }
2947
3024
  },
2948
- "./browsers/run-chromium/cdp/discovery.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
3025
+ "./browsers/run-chromium/cdp/coded-error.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
3026
+ var _helpers_messaging__rspack_import_0 = __webpack_require__("./helpers/messaging.ts");
3027
+ function codedError(code, message) {
3028
+ return Object.assign(new Error(message), {
3029
+ code
3030
+ });
3031
+ }
3032
+ function declaredCode(error) {
3033
+ const code = error?.code;
3034
+ return 'string' == typeof code && Object.prototype.hasOwnProperty.call(_helpers_messaging__rspack_import_0.Lp, code) ? code : void 0;
3035
+ }
2949
3036
  __webpack_require__.d(__webpack_exports__, {
2950
- z: ()=>checkChromeRemoteDebugging,
2951
- N: ()=>discoverWebSocketDebuggerUrl
3037
+ A: ()=>codedError,
3038
+ K: ()=>declaredCode
2952
3039
  });
2953
- const external_node_http_namespaceObject = require("node:http");
2954
- var external_node_net_ = __webpack_require__("node:net");
2955
- var messaging = __webpack_require__("./helpers/messaging.ts");
2956
- var constants = __webpack_require__("./browsers/browsers-lib/constants.ts");
2957
- var messages = __webpack_require__("./browsers/browsers-lib/messages.ts");
3040
+ },
3041
+ "./browsers/run-chromium/cdp/discovery.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
3042
+ var node_http__rspack_import_0 = __webpack_require__("node:http");
3043
+ var node_net__rspack_import_1 = __webpack_require__("node:net");
3044
+ var _helpers_messaging__rspack_import_2 = __webpack_require__("./helpers/messaging.ts");
3045
+ var _browsers_lib_constants__rspack_import_3 = __webpack_require__("./browsers/browsers-lib/constants.ts");
3046
+ var _browsers_lib_messages__rspack_import_4 = __webpack_require__("./browsers/browsers-lib/messages.ts");
3047
+ var _coded_error__rspack_import_5 = __webpack_require__("./browsers/run-chromium/cdp/coded-error.ts");
2958
3048
  async function getJson(host, port, path) {
2959
3049
  return new Promise((resolve, reject)=>{
2960
- const req = external_node_http_namespaceObject.request({
3050
+ const req = node_http__rspack_import_0.request({
2961
3051
  hostname: host,
2962
3052
  port,
2963
3053
  path,
@@ -2974,8 +3064,8 @@ var __webpack_modules__ = {
2974
3064
  });
2975
3065
  });
2976
3066
  req.on('error', (err)=>reject(err));
2977
- req.setTimeout(constants.C4, ()=>{
2978
- req.destroy(new Error(`CDP endpoint timed out: ${path}`));
3067
+ req.setTimeout(_browsers_lib_constants__rspack_import_3.C4, ()=>{
3068
+ req.destroy((0, _coded_error__rspack_import_5.A)(_helpers_messaging__rspack_import_2.Lp.E_CDP_TIMEOUT, `CDP endpoint timed out: ${path}`));
2979
3069
  });
2980
3070
  req.end();
2981
3071
  });
@@ -2985,14 +3075,14 @@ var __webpack_modules__ = {
2985
3075
  const version = await getJson(host, port, '/json/version');
2986
3076
  const wsUrl = 'string' == typeof version?.webSocketDebuggerUrl ? version.webSocketDebuggerUrl : void 0;
2987
3077
  if (wsUrl) {
2988
- if (isDev) (0, messaging._w)(messages.Te());
3078
+ if (isDev) (0, _helpers_messaging__rspack_import_2._w)(_browsers_lib_messages__rspack_import_4.Te());
2989
3079
  return wsUrl;
2990
3080
  }
2991
3081
  } catch (error) {
2992
- if (isDev) (0, messaging.mR)('[CDP] Failed to read /json/version:', String(error?.message || error));
3082
+ if (isDev) (0, _helpers_messaging__rspack_import_2.mR)('[CDP] Failed to read /json/version:', String(error?.message || error));
2993
3083
  }
2994
3084
  const targets = await getJson(host, port, '/json');
2995
- if (isDev) (0, messaging._w)(messages.FF((targets || []).length || 0));
3085
+ if (isDev) (0, _helpers_messaging__rspack_import_2._w)(_browsers_lib_messages__rspack_import_4.FF((targets || []).length || 0));
2996
3086
  const pageTarget = (targets || []).find((target)=>{
2997
3087
  const type = String(target?.type || '');
2998
3088
  const ws = 'string' == typeof target?.webSocketDebuggerUrl ? target.webSocketDebuggerUrl : '';
@@ -3000,14 +3090,14 @@ var __webpack_modules__ = {
3000
3090
  });
3001
3091
  const pageWs = 'string' == typeof pageTarget?.webSocketDebuggerUrl ? pageTarget.webSocketDebuggerUrl : '';
3002
3092
  if (pageWs) {
3003
- if (isDev) (0, messaging._w)(messages.Te());
3093
+ if (isDev) (0, _helpers_messaging__rspack_import_2._w)(_browsers_lib_messages__rspack_import_4.Te());
3004
3094
  return pageWs;
3005
3095
  }
3006
- throw new Error('No CDP WebSocket URL available');
3096
+ throw (0, _coded_error__rspack_import_5.A)(_helpers_messaging__rspack_import_2.Lp.E_CDP_NOT_CONNECTED, 'No CDP WebSocket URL available');
3007
3097
  }
3008
3098
  async function checkChromeRemoteDebugging(port = 9222, host = '127.0.0.1') {
3009
3099
  return new Promise((resolve)=>{
3010
- const socket = new external_node_net_.Socket();
3100
+ const socket = new node_net__rspack_import_1.Socket();
3011
3101
  socket.on('connect', ()=>{
3012
3102
  socket.destroy();
3013
3103
  resolve(true);
@@ -3023,6 +3113,29 @@ var __webpack_modules__ = {
3023
3113
  socket.connect(port, host);
3024
3114
  });
3025
3115
  }
3116
+ __webpack_require__.d(__webpack_exports__, {
3117
+ N: ()=>discoverWebSocketDebuggerUrl,
3118
+ z: ()=>checkChromeRemoteDebugging
3119
+ });
3120
+ },
3121
+ "./browsers/run-chromium/cdp/pipe-guard.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
3122
+ const pipeOwners = new WeakMap();
3123
+ const guardedPipes = new WeakSet();
3124
+ function guardCdpPipe(stream) {
3125
+ if (!stream || 'function' != typeof stream.on) return;
3126
+ if (guardedPipes.has(stream)) return;
3127
+ guardedPipes.add(stream);
3128
+ stream.on('error', (error)=>{
3129
+ pipeOwners.get(stream)?.reportPipeGone(error);
3130
+ });
3131
+ }
3132
+ function claimCdpPipe(stream, owner) {
3133
+ pipeOwners.set(stream, owner);
3134
+ }
3135
+ __webpack_require__.d(__webpack_exports__, {
3136
+ S: ()=>claimCdpPipe,
3137
+ b: ()=>guardCdpPipe
3138
+ });
3026
3139
  },
3027
3140
  "./browsers/run-chromium/chromium-context/index.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
3028
3141
  function createChromiumContext() {
@@ -3359,7 +3472,9 @@ var __webpack_modules__ = {
3359
3472
  var runtime_options = __webpack_require__("./browsers/browsers-lib/runtime-options.ts");
3360
3473
  var shared_utils = __webpack_require__("./browsers/browsers-lib/shared-utils.ts");
3361
3474
  var version_probe = __webpack_require__("./browsers/browsers-lib/version-probe.ts");
3475
+ var coded_error = __webpack_require__("./browsers/run-chromium/cdp/coded-error.ts");
3362
3476
  var discovery = __webpack_require__("./browsers/run-chromium/cdp/discovery.ts");
3477
+ var pipe_guard = __webpack_require__("./browsers/run-chromium/cdp/pipe-guard.ts");
3363
3478
  var manifest_readiness = __webpack_require__("./browsers/run-chromium/manifest-readiness.ts");
3364
3479
  var companion_session = __webpack_require__("./browsers/browsers-lib/companion-session.ts");
3365
3480
  var resolve_profile = __webpack_require__("./browsers/browsers-lib/resolve-profile.ts");
@@ -3890,6 +4005,17 @@ var __webpack_modules__ = {
3890
4005
  code: messaging.Lp.E_BROWSER_BINARY_INVALID
3891
4006
  });
3892
4007
  }
4008
+ function binaryRequiredError() {
4009
+ return Object.assign(new Error(messages.ne()), {
4010
+ code: messaging.Lp.E_BROWSER_BINARY_REQUIRED
4011
+ });
4012
+ }
4013
+ function browserNotFoundError(reason) {
4014
+ return Object.assign(new Error(reason), {
4015
+ code: messaging.Lp.E_BROWSER_NOT_FOUND
4016
+ });
4017
+ }
4018
+ const STDERR_TAIL_LINES = 8;
3893
4019
  class ChromiumLaunchPlugin {
3894
4020
  getExtensionLoadRefusal() {
3895
4021
  return this.extensionLoadRefused || null;
@@ -3922,6 +4048,11 @@ var __webpack_modules__ = {
3922
4048
  const outputPath = (0, extension_output_path.W)(compilation, void 0);
3923
4049
  (0, ready_stamp.dz)(outputPath, (0, ready_stamp.dT)(error), (0, ready_stamp.Uf)(outputPath), (0, ready_stamp.NE)(error));
3924
4050
  }
4051
+ stampCdpFault(compilation, error) {
4052
+ const code = (0, coded_error.K)(error);
4053
+ if (!code) return;
4054
+ (0, ready_stamp.QP)((0, extension_output_path.W)(compilation, void 0), code, (0, ready_stamp.dT)(error), this.closeHandlerContext?.runId);
4055
+ }
3925
4056
  apply(compiler) {
3926
4057
  const host = compiler;
3927
4058
  this.logger = 'function' == typeof host?.getInfrastructureLogger ? host.getInfrastructureLogger('ChromiumLaunchPlugin') : {
@@ -3933,8 +4064,8 @@ var __webpack_modules__ = {
3933
4064
  host.hooks.done.tapPromise('chromium:launch', async (stats)=>{
3934
4065
  try {
3935
4066
  const hasErrors = 'function' == typeof stats?.hasErrors ? stats.hasErrors() : !!stats?.compilation?.errors?.length;
3936
- if (hasErrors) return void this.logger.info(messages.y7());
3937
4067
  if (this.didLaunch) return;
4068
+ if (hasErrors) return void this.logger.info(messages.y7());
3938
4069
  await this.launchChromium(stats.compilation);
3939
4070
  this.didLaunch = true;
3940
4071
  if (!this.didReportReady && !this.extensionLoadRefused && !this.browserGone) (0, messaging._w)((0, ready_message.G)(stats.compilation.options.mode, this.options.browser));
@@ -3958,10 +4089,6 @@ var __webpack_modules__ = {
3958
4089
  if (inTestRunner && !dryRun) return void logChromiumDryRun(this.options.browser, this.options?.chromiumBinary ? (0, wsl_support.f7)(String(this.options.chromiumBinary)) : 'chromium-mock-binary', []);
3959
4090
  if (inTestRunner && dryRun) return void this.printDryRunPlan(compilation, this.options?.chromiumBinary ? (0, wsl_support.f7)(String(this.options.chromiumBinary)) : 'chromium-mock-binary');
3960
4091
  const browser = this.options?.browser;
3961
- const exitForLaunchFailure = (reason)=>{
3962
- this.stampLaunchFailed(compilation, reason);
3963
- process.exit(1);
3964
- };
3965
4092
  const notInstalledReason = `${String(browser)} isn't installed and no binary was found`;
3966
4093
  let browserBinaryLocation = null;
3967
4094
  let printedGuidance = false;
@@ -4182,11 +4309,11 @@ var __webpack_modules__ = {
4182
4309
  const guidance = getInstallGuidanceText('edge');
4183
4310
  printInstallGuidance(guidance, 'edge');
4184
4311
  browserBinaryLocation = null;
4185
- if (process.env.VITEST || process.env.VITEST_WORKER_ID) throw new Error('Chromium launch failed');
4186
- exitForLaunchFailure(notInstalledReason);
4312
+ throw browserNotFoundError(notInstalledReason);
4187
4313
  }
4188
4314
  }
4189
- } catch {
4315
+ } catch (error) {
4316
+ if ((0, ready_stamp.NE)(error)) throw error;
4190
4317
  const guidance = getInstallGuidanceText('edge');
4191
4318
  const fallback = resolveWslFallback();
4192
4319
  if (fallback) browserBinaryLocation = fallback;
@@ -4194,15 +4321,11 @@ var __webpack_modules__ = {
4194
4321
  printInstallGuidance(guidance, 'edge');
4195
4322
  browserBinaryLocation = null;
4196
4323
  }
4197
- if (!browserBinaryLocation) if (process.env.VITEST || process.env.VITEST_WORKER_ID) throw new Error('Chromium launch failed');
4198
- else exitForLaunchFailure(notInstalledReason);
4324
+ if (!browserBinaryLocation) throw browserNotFoundError(notInstalledReason);
4199
4325
  }
4200
4326
  break;
4201
4327
  case 'chromium-based':
4202
- (0, messaging.Gg)(messages.ne());
4203
- if (process.env.VITEST || process.env.VITEST_WORKER_ID) throw new Error('chromium-based requires --chromium-binary');
4204
- exitForLaunchFailure('the chromium-based target needs --chromium-binary <abs-path>');
4205
- break;
4328
+ throw binaryRequiredError();
4206
4329
  default:
4207
4330
  browserBinaryLocation = resolveChromeLikeBinary();
4208
4331
  break;
@@ -4245,8 +4368,7 @@ var __webpack_modules__ = {
4245
4368
  const forkGuidance = chromiumForkInstallGuidance(browser);
4246
4369
  this.logger.error(null !== forkGuidance ? messages.I5(browser, forkGuidance) : messages.Ih(browser, browserBinaryLocation || ''));
4247
4370
  }
4248
- if (process.env.VITEST || process.env.VITEST_WORKER_ID) throw new Error('Browser not installed or binary path not found');
4249
- exitForLaunchFailure(notInstalledReason);
4371
+ throw browserNotFoundError(notInstalledReason);
4250
4372
  }
4251
4373
  }
4252
4374
  let browserVersionLine;
@@ -4371,6 +4493,8 @@ var __webpack_modules__ = {
4371
4493
  input: child.stdio[4],
4372
4494
  output: child.stdio[3]
4373
4495
  } : void 0;
4496
+ (0, pipe_guard.b)(pipeStreams?.input);
4497
+ (0, pipe_guard.b)(pipeStreams?.output);
4374
4498
  if (enableCdp && !pipeStreams) {
4375
4499
  let portReady = false;
4376
4500
  for(let attempt = 0; attempt < 10; attempt++){
@@ -4408,7 +4532,7 @@ var __webpack_modules__ = {
4408
4532
  const CDP_SETUP_TIMEOUT_MS = 45000;
4409
4533
  await Promise.race([
4410
4534
  mod.setupCdpAfterLaunch(compilation, cdpConfig, chromiumConfig, pipeStreams),
4411
- new Promise((_, reject)=>setTimeout(()=>reject(new Error(`CDP setup did not complete within ${CDP_SETUP_TIMEOUT_MS / 1000}s. Chrome likely rejected the extension at launch, open chrome://extensions in the dev browser window for the exact error. Common causes: MV3 content_security_policy with 'unsafe-inline', manifest keys Chrome does not support, or manifest references to files missing from the output. Reload/HMR cannot attach until this is fixed.`)), CDP_SETUP_TIMEOUT_MS).unref?.())
4535
+ new Promise((_, reject)=>setTimeout(()=>reject((0, coded_error.A)(messaging.Lp.E_CDP_TIMEOUT, `CDP setup did not complete within ${CDP_SETUP_TIMEOUT_MS / 1000}s. Chrome likely rejected the extension at launch, open chrome://extensions in the dev browser window for the exact error. Common causes: MV3 content_security_policy with 'unsafe-inline', manifest keys Chrome does not support, or manifest references to files missing from the output. Reload/HMR cannot attach until this is fixed.`)), CDP_SETUP_TIMEOUT_MS).unref?.())
4412
4536
  ]);
4413
4537
  if (cdpConfig.extensionLoadRefused) {
4414
4538
  this.extensionLoadRefused = cdpConfig.extensionLoadRefused;
@@ -4426,6 +4550,7 @@ var __webpack_modules__ = {
4426
4550
  if ('development' === compilation.options.mode) (0, messaging.Gg)(messages.u1(this.options.browser));
4427
4551
  return;
4428
4552
  }
4553
+ this.stampCdpFault(compilation, error);
4429
4554
  reportReady();
4430
4555
  }
4431
4556
  }
@@ -4468,14 +4593,21 @@ var __webpack_modules__ = {
4468
4593
  });
4469
4594
  if ((0, messaging._o)()) this.logger.debug?.('[browser] Final Chrome flags:', launchArgs.join(' '));
4470
4595
  const stderrStream = child.stdio?.[2];
4596
+ const stderrTail = [];
4597
+ let pending = '';
4598
+ const keepStderrLine = (line)=>{
4599
+ if (!line) return;
4600
+ stderrTail.push(line);
4601
+ if (stderrTail.length > STDERR_TAIL_LINES) stderrTail.shift();
4602
+ };
4471
4603
  if (stderrStream && 'function' == typeof stderrStream.on) {
4472
- let pending = '';
4473
4604
  stderrStream.on('data', (chunk)=>{
4474
4605
  pending += String(chunk);
4475
4606
  let newline;
4476
4607
  while(-1 !== (newline = pending.indexOf('\n'))){
4477
4608
  const line = pending.slice(0, newline).trim();
4478
4609
  pending = pending.slice(newline + 1);
4610
+ keepStderrLine(line);
4479
4611
  if (/Failed to load extension|Manifest file is missing or unreadable|Manifest is not valid JSON/i.test(line)) this.logger.error(`[browser] Chrome rejected an extension at launch, reload/HMR cannot attach until this is fixed:\n${line}`);
4480
4612
  }
4481
4613
  });
@@ -4488,6 +4620,11 @@ var __webpack_modules__ = {
4488
4620
  const beforeReady = !this.didReportReady;
4489
4621
  this.browserGone = true;
4490
4622
  this.logger.error(messages.NV(this.options.browser, code, signal, this.closeHandlerContext?.command || 'preview'));
4623
+ if (beforeReady) {
4624
+ keepStderrLine(pending.trim());
4625
+ pending = '';
4626
+ if (stderrTail.length > 0) this.logger.error(messages.LT(this.options.browser, stderrTail));
4627
+ }
4491
4628
  (0, ready_stamp.Wi)(this.closeHandlerContext?.extensionOutputPath, code, signal, this.closeHandlerContext?.runId, {
4492
4629
  beforeReady
4493
4630
  });
@@ -4744,6 +4881,7 @@ var __webpack_modules__ = {
4744
4881
  var ready_message = __webpack_require__("./browsers/browsers-lib/ready-message.ts");
4745
4882
  var ready_stamp = __webpack_require__("./browsers/browsers-lib/ready-stamp.ts");
4746
4883
  var resolve_live_pid = __webpack_require__("./browsers/browsers-lib/resolve-live-pid.ts");
4884
+ var resolve_profile = __webpack_require__("./browsers/browsers-lib/resolve-profile.ts");
4747
4885
  var runtime_options = __webpack_require__("./browsers/browsers-lib/runtime-options.ts");
4748
4886
  var shared_utils = __webpack_require__("./browsers/browsers-lib/shared-utils.ts");
4749
4887
  var version_probe = __webpack_require__("./browsers/browsers-lib/version-probe.ts");
@@ -4836,7 +4974,6 @@ var __webpack_modules__ = {
4836
4974
  }
4837
4975
  var external_node_path_ = __webpack_require__("node:path");
4838
4976
  var companion_session = __webpack_require__("./browsers/browsers-lib/companion-session.ts");
4839
- var resolve_profile = __webpack_require__("./browsers/browsers-lib/resolve-profile.ts");
4840
4977
  const masterPreferences = {
4841
4978
  'browser.aboutwelcome.enabled': false,
4842
4979
  'browser.startup.homepage_override.mstone': 'ignore',
@@ -4986,7 +5123,7 @@ var __webpack_modules__ = {
4986
5123
  if (launchUrl) binaryArgs.push('--url', String(launchUrl));
4987
5124
  const outPath = compilation.options.output?.path || external_node_path_.resolve(process.cwd(), 'dist/firefox');
4988
5125
  const distRoot = external_node_path_.dirname(outPath);
4989
- const useSystemProfile = 'true' === String(process.env.EXTENSION_USE_SYSTEM_PROFILE || process.env.EXTJS_USE_SYSTEM_PROFILE || '').toLowerCase().trim();
5126
+ const useSystemProfile = Boolean((0, resolve_profile.Jv)());
4990
5127
  const contextDir = compilation?.options?.context || process.cwd();
4991
5128
  const shownPath = (p)=>{
4992
5129
  try {
@@ -5220,7 +5357,9 @@ var __webpack_modules__ = {
5220
5357
  }
5221
5358
  }
5222
5359
  async function installTemporaryAddon(client, addonsActor, addonPath, openDevTools) {
5223
- if (!addonsActor) throw new Error(messages.WV('firefox', 'No addonsActor available from Firefox RDP.'));
5360
+ if (!addonsActor) throw Object.assign(new Error(messages.WV('firefox', 'No addonsActor available from Firefox RDP.')), {
5361
+ code: messaging.Lp.E_ADDON_INSTALL
5362
+ });
5224
5363
  const tryInstall = async (pathToUse)=>client.request({
5225
5364
  to: addonsActor,
5226
5365
  type: 'installTemporaryAddon',
@@ -5612,7 +5751,7 @@ var __webpack_modules__ = {
5612
5751
  await new Promise((resolve)=>setTimeout(resolve, RETRY_INTERVAL));
5613
5752
  } else {
5614
5753
  const err = error;
5615
- (0, messaging.Gg)(messages.dk(this.options.browser, err.stack || String(error)));
5754
+ (0, messaging.Gg)(messages.dk(this.options.browser, (0, messaging._o)() ? err.stack || err : err));
5616
5755
  throw err;
5617
5756
  }
5618
5757
  }
@@ -5677,7 +5816,9 @@ var __webpack_modules__ = {
5677
5816
  const outcome = classifyAddonInstallFailure(err);
5678
5817
  if ('refused' === outcome.status) this.addonInstallRefusalReason = outcome.reason;
5679
5818
  const message = requestErrorToMessage(err);
5680
- throw new Error(messages.WV(this.options.browser, message));
5819
+ throw Object.assign(new Error(messages.WV(this.options.browser, message)), {
5820
+ code: (0, ready_stamp.NE)(err) ?? messaging.Lp.E_ADDON_INSTALL
5821
+ });
5681
5822
  }
5682
5823
  }
5683
5824
  if (primaryUserAddonId) this.derivedExtensionId = primaryUserAddonId;
@@ -5912,6 +6053,23 @@ var __webpack_modules__ = {
5912
6053
  code: messaging.Lp.E_BROWSER_BINARY_INVALID
5913
6054
  });
5914
6055
  }
6056
+ function systemProfileRefusal(browser, sources) {
6057
+ return Object.assign(new Error(messages.Mm(browser, sources)), {
6058
+ code: messaging.Lp.E_FLAG_NOT_SUPPORTED_HERE
6059
+ });
6060
+ }
6061
+ function systemProfileSources(host) {
6062
+ const sources = [];
6063
+ if (false === (0, resolve_profile.Md)(host.profile)) sources.push({
6064
+ kind: 'config' === host.profileSource ? 'config' : 'flag'
6065
+ });
6066
+ const envName = (0, resolve_profile.Jv)();
6067
+ if (envName) sources.push({
6068
+ kind: 'env',
6069
+ name: envName
6070
+ });
6071
+ return sources;
6072
+ }
5915
6073
  class FirefoxLaunchPlugin {
5916
6074
  get spawnedBrowser() {
5917
6075
  return null !== this.child;
@@ -5953,12 +6111,12 @@ var __webpack_modules__ = {
5953
6111
  host.hooks.done.tapAsync('run-firefox:launch', async (stats, done)=>{
5954
6112
  try {
5955
6113
  const hasErrors = 'function' == typeof stats?.hasErrors ? stats.hasErrors() : !!stats?.compilation?.errors?.length;
6114
+ if (this.ctx.didLaunch) return void done();
5956
6115
  if (hasErrors) {
5957
6116
  this.ctx.logger?.info?.(messages.y7());
5958
6117
  done();
5959
6118
  return;
5960
6119
  }
5961
- if (this.ctx.didLaunch) return void done();
5962
6120
  await this.launch(stats.compilation, (0, runtime_options.zU)(this.host, stats.compilation.options.mode));
5963
6121
  if ('development' === stats.compilation.options.mode && !this.host.extensionLoadRefused) this.reportReady('development');
5964
6122
  this.ctx.didLaunch = true;
@@ -5967,8 +6125,6 @@ var __webpack_modules__ = {
5967
6125
  const rendered = error instanceof Error ? error.message : String(error);
5968
6126
  if ((0, messaging.Qi)(rendered)) (0, messaging.Gg)(rendered);
5969
6127
  else this.ctx.logger?.error?.(messages.MQ(error));
5970
- if (process.env.VITEST || process.env.VITEST_WORKER_ID) return void done(error);
5971
- process.exit(1);
5972
6128
  }
5973
6129
  done();
5974
6130
  });
@@ -5977,6 +6133,8 @@ var __webpack_modules__ = {
5977
6133
  const compilationErrors = compilation?.errors || [];
5978
6134
  if (compilationErrors.length > 0) return void this.ctx.logger?.info?.(messages.y7());
5979
6135
  if ((0, messaging._o)()) this.ctx.logger?.info?.(messages.A9(this.host.browser));
6136
+ const systemProfile = systemProfileSources(this.host);
6137
+ if (systemProfile.length > 0) throw systemProfileRefusal(this.host.browser, systemProfile);
5980
6138
  const normalizePath = (value)=>{
5981
6139
  const normalized = value ? (0, wsl_support.f7)(value) : null;
5982
6140
  return normalized && external_node_fs_.existsSync(normalized) ? normalized : null;
@@ -5998,19 +6156,16 @@ var __webpack_modules__ = {
5998
6156
  return 'npx extension install firefox';
5999
6157
  }
6000
6158
  };
6001
- const exitForLaunchFailure = (message)=>{
6002
- if (message) (0, messaging.Gg)(message);
6003
- this.stampLaunchFailed(message || `${this.host.browser} could not be launched`);
6004
- process.exit(1);
6005
- };
6006
6159
  const failGeckoBinaryRequirement = ()=>{
6007
6160
  if (this.host.geckoBinary) throw invalidBinaryPinError(String(this.host.geckoBinary));
6008
- return exitForLaunchFailure(messages.jk());
6161
+ throw Object.assign(new Error(messages.jk()), {
6162
+ code: messaging.Lp.E_BROWSER_BINARY_REQUIRED
6163
+ });
6009
6164
  };
6010
- const throwOrExitNotInstalled = ()=>{
6011
- if (process.env.VITEST || process.env.VITEST_WORKER_ID) throw new Error('Firefox not installed or binary path not found');
6012
- this.stampLaunchFailed(`${this.host.browser} isn't installed and no binary was found`);
6013
- process.exit(1);
6165
+ const throwNotInstalled = ()=>{
6166
+ throw Object.assign(new Error(`${this.host.browser} isn't installed and no binary was found`), {
6167
+ code: messaging.Lp.E_BROWSER_NOT_FOUND
6168
+ });
6014
6169
  };
6015
6170
  const inTestRunner = Boolean(process.env.VITEST || process.env.VITEST_WORKER_ID);
6016
6171
  const dryRun = Boolean(this.host.dryRun);
@@ -6018,12 +6173,9 @@ var __webpack_modules__ = {
6018
6173
  if (inTestRunner && dryRun) return void await this.printDryRunPlan(compilation, options, this.host.geckoBinary ? (0, wsl_support.f7)(String(this.host.geckoBinary)) : 'firefox-mock-binary');
6019
6174
  if ('librewolf' === this.host.browser) {
6020
6175
  const remoteDebugging = (0, librewolf_overrides.u5)(external_node_fs_, process.env, process.platform);
6021
- if (!remoteDebugging.enabled) {
6022
- (0, messaging.Gg)(messages.bC(remoteDebugging.expectedPath));
6023
- if (inTestRunner) throw new Error('LibreWolf remote debugging is disabled');
6024
- this.stampLaunchFailed('LibreWolf remote debugging is disabled');
6025
- process.exit(1);
6026
- }
6176
+ if (!remoteDebugging.enabled) throw Object.assign(new Error(messages.bC(remoteDebugging.expectedPath)), {
6177
+ code: messaging.Lp.E_BROWSER_CONNECT
6178
+ });
6027
6179
  }
6028
6180
  let browserBinaryLocation = resolveManagedBinary();
6029
6181
  let skipDetection = Boolean(browserBinaryLocation);
@@ -6107,7 +6259,7 @@ var __webpack_modules__ = {
6107
6259
  if (wslFallback) browserBinaryLocation = wslFallback;
6108
6260
  else {
6109
6261
  this.printInstallHint(compilation, getInstallGuidanceText());
6110
- throwOrExitNotInstalled();
6262
+ throwNotInstalled();
6111
6263
  }
6112
6264
  }
6113
6265
  }
@@ -6173,7 +6325,7 @@ var __webpack_modules__ = {
6173
6325
  const reason = error?.extensionLoadRefusedReason;
6174
6326
  if (!reason) {
6175
6327
  (0, ready_stamp.__)(this.extensionOutputPath, debugPort);
6176
- (0, ready_stamp.dz)(this.extensionOutputPath, (0, ready_stamp.dT)(error), this.launchRunId);
6328
+ (0, ready_stamp.dz)(this.extensionOutputPath, (0, ready_stamp.dT)(error), this.launchRunId, (0, ready_stamp.NE)(error));
6177
6329
  throw error;
6178
6330
  }
6179
6331
  this.reportAddonLoadRefused(reason);
@@ -6193,19 +6345,11 @@ var __webpack_modules__ = {
6193
6345
  this.ctx.logger?.info?.(messages.dw(profilePath));
6194
6346
  }
6195
6347
  } catch {}
6196
- } else {
6197
- if ((0, messaging._o)()) this.ctx.logger?.warn?.('[browser] Firefox profile not set; skipping RDP add-on install.');
6198
- this.child = await this.spawnFirefoxChild(plan.binary, plan.args, wslFallbackBinary);
6199
- (0, ready_stamp.M)(this.extensionOutputPath, {
6200
- browserPid: this.child?.pid,
6201
- binary: this.child?.spawnfile || plan.binary,
6202
- binaryProvenance: this.host.launchBinaryProvenance,
6203
- extensionId: this.extensionOutputPath ? (0, banner.MT)(this.extensionOutputPath) : void 0
6204
- }, this.launchRunId);
6205
- this.wireChildLifecycle();
6206
- if (debugPort > 0) (0, ready_stamp.__)(this.extensionOutputPath, debugPort);
6207
- this.scheduleWatchTimeout();
6208
- }
6348
+ } else throw systemProfileRefusal(this.host.browser, [
6349
+ {
6350
+ kind: 'flag'
6351
+ }
6352
+ ]);
6209
6353
  }
6210
6354
  async printDryRunPlan(compilation, options, binaryPath) {
6211
6355
  const launchConfig = await resolveFirefoxLaunchConfig(compilation, {
@@ -6263,8 +6407,6 @@ var __webpack_modules__ = {
6263
6407
  if (!child) return;
6264
6408
  child.on('error', (error)=>{
6265
6409
  this.ctx.logger?.error?.(messages._D(this.host.browser, error));
6266
- if (process.env.VITEST || process.env.VITEST_WORKER_ID) throw new Error('Firefox startup timed out');
6267
- process.exit(1);
6268
6410
  });
6269
6411
  child.on('close', (code, signal)=>{
6270
6412
  const expected = (0, process_teardown.Op)(child);
@@ -6507,15 +6649,9 @@ var __webpack_modules__ = {
6507
6649
  Tu: LIBREWOLF_REMOTE_DEBUGGING_LINES
6508
6650
  });
6509
6651
  },
6510
- "./browsers/run-firefox/rdp/remote-firefox/messaging-client.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
6511
- __webpack_require__.d(__webpack_exports__, {
6512
- G: ()=>MessagingClient
6513
- });
6514
- const external_node_events_namespaceObject = require("node:events");
6515
- var external_node_events_default = /*#__PURE__*/ __webpack_require__.n(external_node_events_namespaceObject);
6516
- var messages = __webpack_require__("./browsers/browsers-lib/messages.ts");
6517
- var constants = __webpack_require__("./browsers/browsers-lib/constants.ts");
6518
- const EVALUATION_TIMEOUT_MS = constants.pq;
6652
+ "./browsers/run-firefox/rdp/remote-firefox/evaluate.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
6653
+ var _browsers_lib_constants__rspack_import_0 = __webpack_require__("./browsers/browsers-lib/constants.ts");
6654
+ const EVALUATION_TIMEOUT_MS = _browsers_lib_constants__rspack_import_0.pq;
6519
6655
  const EVALUATION_TYPES = [
6520
6656
  'evaluateJSAsync',
6521
6657
  'evalWithOptions',
@@ -6527,16 +6663,23 @@ var __webpack_modules__ = {
6527
6663
  const initial = value?.initial;
6528
6664
  return 'string' == typeof initial ? initial : '';
6529
6665
  }
6666
+ class PageThrewError extends Error {
6667
+ constructor(message){
6668
+ super(message);
6669
+ this.name = 'PageThrewError';
6670
+ }
6671
+ }
6530
6672
  function evaluationFailure(reply) {
6531
6673
  if (!reply || 'object' != typeof reply) return;
6532
6674
  const r = reply;
6533
6675
  const message = exceptionText(r.exceptionMessage);
6534
6676
  const threw = true === r.hasException || true === r.topLevelAwaitRejected || void 0 !== r.exception && null !== r.exception || message.length > 0;
6535
6677
  if (!threw) return;
6536
- return new Error(message || 'The expression threw inside the page');
6678
+ return new PageThrewError(message || 'The expression threw inside the page');
6537
6679
  }
6538
- function buildEvaluationPayload(tabId, expression, type) {
6680
+ function buildEvaluationPayload(tabId, expression, type, extra) {
6539
6681
  const payload = {
6682
+ ...extra,
6540
6683
  to: tabId,
6541
6684
  type,
6542
6685
  text: expression
@@ -6556,8 +6699,8 @@ var __webpack_modules__ = {
6556
6699
  if ('function' == typeof client.removeListener) client.removeListener('message', listener);
6557
6700
  };
6558
6701
  }
6559
- async function requestEvaluation(client, tabId, expression, type) {
6560
- if ('evaluateJSAsync' !== type) return await client.request(buildEvaluationPayload(tabId, expression, type));
6702
+ async function requestEvaluation(client, tabId, expression, type, extra) {
6703
+ if ('evaluateJSAsync' !== type) return await client.request(buildEvaluationPayload(tabId, expression, type, extra));
6561
6704
  let expectedResultId = '';
6562
6705
  let cleanup = ()=>{};
6563
6706
  let pendingMessage;
@@ -6597,7 +6740,7 @@ var __webpack_modules__ = {
6597
6740
  }
6598
6741
  });
6599
6742
  try {
6600
- const response = await client.request(buildEvaluationPayload(tabId, expression, type));
6743
+ const response = await client.request(buildEvaluationPayload(tabId, expression, type, extra));
6601
6744
  if (response?.type === 'evaluationResult') {
6602
6745
  cleanup();
6603
6746
  return response;
@@ -6619,12 +6762,12 @@ var __webpack_modules__ = {
6619
6762
  throw error;
6620
6763
  }
6621
6764
  }
6622
- async function evaluate(client, tabId, expression) {
6765
+ async function evaluate(client, tabId, expression, extra) {
6623
6766
  let lastError = null;
6624
6767
  for (const type of EVALUATION_TYPES){
6625
6768
  let response;
6626
6769
  try {
6627
- response = await requestEvaluation(client, tabId, expression, type);
6770
+ response = await requestEvaluation(client, tabId, expression, type, extra);
6628
6771
  } catch (err) {
6629
6772
  lastError = err;
6630
6773
  continue;
@@ -6638,6 +6781,20 @@ var __webpack_modules__ = {
6638
6781
  }
6639
6782
  throw lastError || new Error('Failed to evaluate expression');
6640
6783
  }
6784
+ __webpack_require__.d(__webpack_exports__, {
6785
+ K: ()=>PageThrewError,
6786
+ _: ()=>evaluate
6787
+ });
6788
+ },
6789
+ "./browsers/run-firefox/rdp/remote-firefox/messaging-client.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
6790
+ __webpack_require__.d(__webpack_exports__, {
6791
+ G: ()=>MessagingClient
6792
+ });
6793
+ const external_node_events_namespaceObject = require("node:events");
6794
+ var external_node_events_default = /*#__PURE__*/ __webpack_require__.n(external_node_events_namespaceObject);
6795
+ var messaging = __webpack_require__("./helpers/messaging.ts");
6796
+ var messages = __webpack_require__("./browsers/browsers-lib/messages.ts");
6797
+ var evaluate = __webpack_require__("./browsers/run-firefox/rdp/remote-firefox/evaluate.ts");
6641
6798
  async function listTabs(transport) {
6642
6799
  const response = await transport.request({
6643
6800
  to: 'root',
@@ -6653,7 +6810,6 @@ var __webpack_modules__ = {
6653
6810
  }
6654
6811
  var external_node_net_ = __webpack_require__("node:net");
6655
6812
  var external_node_net_default = /*#__PURE__*/ __webpack_require__.n(external_node_net_);
6656
- var messaging = __webpack_require__("./helpers/messaging.ts");
6657
6813
  function parseRdpFrame(data) {
6658
6814
  const dataString = data.toString();
6659
6815
  const separatorIndex = dataString.indexOf(':');
@@ -6732,12 +6888,24 @@ var __webpack_modules__ = {
6732
6888
  if (emitter.listenerCount('error') > 0) return void emitter.emit('error', error);
6733
6889
  (0, messaging.Gg)(error instanceof Error ? error.message : String(error));
6734
6890
  }
6891
+ function closedError(message) {
6892
+ return Object.assign(new Error(message), {
6893
+ code: messaging.Lp.E_BROWSER_CONNECTION_CLOSED
6894
+ });
6895
+ }
6896
+ function protocolError(message) {
6897
+ return Object.assign(new Error(message), {
6898
+ code: messaging.Lp.E_RDP_PROTOCOL
6899
+ });
6900
+ }
6735
6901
  class RdpTransport extends external_node_events_default() {
6736
6902
  async connect(port, host = '127.0.0.1') {
6737
6903
  await new Promise((resolve, reject)=>{
6738
6904
  const timeoutMs = rdpRequestTimeoutMs();
6739
6905
  const timer = setTimeout(()=>{
6740
- this.settleGreeting(new Error(`Firefox sent no RDP greeting on port ${port} within ${timeoutMs}ms`));
6906
+ this.settleGreeting(Object.assign(new Error(`Firefox sent no RDP greeting on port ${port} within ${timeoutMs}ms`), {
6907
+ code: messaging.Lp.E_BROWSER_START_TIMEOUT
6908
+ }));
6741
6909
  this.onConnectionLost();
6742
6910
  }, timeoutMs);
6743
6911
  timer.unref?.();
@@ -6761,8 +6929,8 @@ var __webpack_modules__ = {
6761
6929
  this.conn = void 0;
6762
6930
  this.settleGreeting(err);
6763
6931
  });
6764
- c.on('end', this.onConnectionLost.bind(this));
6765
- c.on('close', this.onConnectionLost.bind(this));
6932
+ c.on('end', ()=>this.onConnectionLost());
6933
+ c.on('close', ()=>this.onConnectionLost());
6766
6934
  c.on('timeout', this.onTimeout.bind(this));
6767
6935
  } catch (err) {
6768
6936
  this.settleGreeting(err);
@@ -6773,7 +6941,7 @@ var __webpack_modules__ = {
6773
6941
  this.greetingPending?.(error);
6774
6942
  }
6775
6943
  disconnect() {
6776
- const closed = new Error(messages.qN('firefox'));
6944
+ const closed = closedError(messages.qN('firefox'));
6777
6945
  this.settleGreeting(closed);
6778
6946
  const c = this.conn;
6779
6947
  if (!c) return;
@@ -6816,7 +6984,7 @@ var __webpack_modules__ = {
6816
6984
  this.pending = this.pending.filter(({ to, payload, deferred })=>{
6817
6985
  if (this.active.has(to)) return true;
6818
6986
  if (!this.conn) {
6819
- deferred.reject(new Error(messages.Fm('firefox')));
6987
+ deferred.reject(closedError(messages.Fm('firefox')));
6820
6988
  return false;
6821
6989
  }
6822
6990
  try {
@@ -6829,7 +6997,7 @@ var __webpack_modules__ = {
6829
6997
  });
6830
6998
  }
6831
6999
  expectReply(to, deferred) {
6832
- if (this.active.has(to)) throw new Error(messages.cD('firefox', to));
7000
+ if (this.active.has(to)) throw protocolError(messages.cD('firefox', to));
6833
7001
  const timeoutMs = rdpRequestTimeoutMs();
6834
7002
  const timer = setTimeout(()=>{
6835
7003
  const entry = this.active.get(to);
@@ -6855,8 +7023,9 @@ var __webpack_modules__ = {
6855
7023
  const { remainingData, parsedMessage, error, fatal } = parseRdpFrame(this.incoming);
6856
7024
  this.incoming = remainingData;
6857
7025
  if (error) {
6858
- surfaceTransportError(this, new Error(messages.l9('firefox', error)));
6859
- if (fatal) this.onConnectionLost();
7026
+ const malformed = protocolError(messages.l9('firefox', error));
7027
+ surfaceTransportError(this, malformed);
7028
+ if (fatal) this.onConnectionLost(malformed);
6860
7029
  return !fatal;
6861
7030
  }
6862
7031
  if (!parsedMessage) return false;
@@ -6865,7 +7034,7 @@ var __webpack_modules__ = {
6865
7034
  }
6866
7035
  handleMessage(message) {
6867
7036
  const from = message.from;
6868
- if (!from) return void surfaceTransportError(this, new Error(messages.HH('firefox', message)));
7037
+ if (!from) return void surfaceTransportError(this, protocolError(messages.HH('firefox', message)));
6869
7038
  if (this.greetingPending && isRootGreeting(message)) this.settleGreeting();
6870
7039
  const entry = isUnsolicitedPacket(message) ? void 0 : this.active.get(from);
6871
7040
  if (entry) {
@@ -6878,7 +7047,7 @@ var __webpack_modules__ = {
6878
7047
  }
6879
7048
  this.emit('message', message);
6880
7049
  }
6881
- onConnectionLost() {
7050
+ onConnectionLost(cause) {
6882
7051
  if (this.lost) return;
6883
7052
  this.lost = true;
6884
7053
  const c = this.conn;
@@ -6889,8 +7058,8 @@ var __webpack_modules__ = {
6889
7058
  c.on('error', ()=>{});
6890
7059
  c.destroy();
6891
7060
  }
6892
- const closed = new Error(messages.qN('firefox'));
6893
- this.settleGreeting(closed);
7061
+ const closed = closedError(messages.qN('firefox'));
7062
+ this.settleGreeting(cause ?? closed);
6894
7063
  this.rejectAll(closed);
6895
7064
  this.emit('end');
6896
7065
  }
@@ -6972,7 +7141,9 @@ var __webpack_modules__ = {
6972
7141
  to
6973
7142
  });
6974
7143
  }
6975
- throw new Error(messages.jP());
7144
+ throw Object.assign(new Error(messages.jP()), {
7145
+ code: messaging.Lp.E_RDP_PROTOCOL
7146
+ });
6976
7147
  }
6977
7148
  async getTargets() {
6978
7149
  return await listTabs(this.transport);
@@ -6990,8 +7161,8 @@ var __webpack_modules__ = {
6990
7161
  return {};
6991
7162
  }
6992
7163
  }
6993
- async evaluate(tabId, expression) {
6994
- return evaluate(this, tabId, expression);
7164
+ async evaluate(tabId, expression, extra) {
7165
+ return (0, evaluate._)(this, tabId, expression, extra);
6995
7166
  }
6996
7167
  constructor(...args){
6997
7168
  super(...args), messaging_client_define_property(this, "transport", new RdpTransport()), messaging_client_define_property(this, "forwardingSetup", false), messaging_client_define_property(this, "lastPort", null), messaging_client_define_property(this, "reconnecting", false), messaging_client_define_property(this, "disconnectedByUser", false);
@@ -7000,19 +7171,18 @@ var __webpack_modules__ = {
7000
7171
  },
7001
7172
  "./browsers/run-only.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
7002
7173
  var node_fs__rspack_import_0 = __webpack_require__("node:fs");
7003
- var firefox_location2__rspack_import_1 = __webpack_require__("firefox-location2");
7004
- var _helpers_messaging__rspack_import_2 = __webpack_require__("./helpers/messaging.ts");
7005
- var _browsers_lib_banner__rspack_import_3 = __webpack_require__("./browsers/browsers-lib/banner.ts");
7006
- var _browsers_lib_browser_family__rspack_import_4 = __webpack_require__("./browsers/browsers-lib/browser-family.ts");
7007
- var _browsers_lib_messages__rspack_import_5 = __webpack_require__("./browsers/browsers-lib/messages.ts");
7008
- var _browsers_lib_output_binaries_resolver__rspack_import_6 = __webpack_require__("./browsers/browsers-lib/output-binaries-resolver.ts");
7009
- var _browsers_lib_ready_stamp__rspack_import_7 = __webpack_require__("./browsers/browsers-lib/ready-stamp.ts");
7010
- var _browsers_lib_runtime_options__rspack_import_13 = __webpack_require__("./browsers/browsers-lib/runtime-options.ts");
7011
- var _browsers_lib_version_probe__rspack_import_8 = __webpack_require__("./browsers/browsers-lib/version-probe.ts");
7012
- var _run_chromium_chromium_context__rspack_import_11 = __webpack_require__("./browsers/run-chromium/chromium-context/index.ts");
7013
- var _run_chromium_chromium_launch__rspack_import_9 = __webpack_require__("./browsers/run-chromium/chromium-launch/index.ts");
7014
- var _run_firefox_firefox_context__rspack_import_12 = __webpack_require__("./browsers/run-firefox/firefox-context/index.ts");
7015
- var _run_firefox_firefox_launch__rspack_import_10 = __webpack_require__("./browsers/run-firefox/firefox-launch/index.ts");
7174
+ var _helpers_messaging__rspack_import_1 = __webpack_require__("./helpers/messaging.ts");
7175
+ var _browsers_lib_banner__rspack_import_2 = __webpack_require__("./browsers/browsers-lib/banner.ts");
7176
+ var _browsers_lib_browser_family__rspack_import_3 = __webpack_require__("./browsers/browsers-lib/browser-family.ts");
7177
+ var _browsers_lib_messages__rspack_import_4 = __webpack_require__("./browsers/browsers-lib/messages.ts");
7178
+ var _browsers_lib_output_binaries_resolver__rspack_import_5 = __webpack_require__("./browsers/browsers-lib/output-binaries-resolver.ts");
7179
+ var _browsers_lib_ready_stamp__rspack_import_6 = __webpack_require__("./browsers/browsers-lib/ready-stamp.ts");
7180
+ var _browsers_lib_runtime_options__rspack_import_12 = __webpack_require__("./browsers/browsers-lib/runtime-options.ts");
7181
+ var _browsers_lib_version_probe__rspack_import_7 = __webpack_require__("./browsers/browsers-lib/version-probe.ts");
7182
+ var _run_chromium_chromium_context__rspack_import_10 = __webpack_require__("./browsers/run-chromium/chromium-context/index.ts");
7183
+ var _run_chromium_chromium_launch__rspack_import_8 = __webpack_require__("./browsers/run-chromium/chromium-launch/index.ts");
7184
+ var _run_firefox_firefox_context__rspack_import_11 = __webpack_require__("./browsers/run-firefox/firefox-context/index.ts");
7185
+ var _run_firefox_firefox_launch__rspack_import_9 = __webpack_require__("./browsers/run-firefox/firefox-launch/index.ts");
7016
7186
  function createPreviewCompilationLike(opts) {
7017
7187
  return {
7018
7188
  options: {
@@ -7080,6 +7250,7 @@ var __webpack_modules__ = {
7080
7250
  extension: pluginOptions.extension,
7081
7251
  browser: pluginOptions.browser,
7082
7252
  profile: pluginOptions.profile,
7253
+ profileSource: opts.profileSource,
7083
7254
  preferences: pluginOptions.preferences,
7084
7255
  browserFlags: pluginOptions.browserFlags,
7085
7256
  startingUrl: pluginOptions.startingUrl,
@@ -7097,21 +7268,23 @@ var __webpack_modules__ = {
7097
7268
  logTab: pluginOptions.logTab
7098
7269
  };
7099
7270
  }
7271
+ function pinnedBinaryPath(opts) {
7272
+ const pinned = (0, _browsers_lib_browser_family__rspack_import_3.M_)(opts.browser) ? opts.geckoBinary : opts.chromiumBinary;
7273
+ return 'string' == typeof pinned && node_fs__rspack_import_0.existsSync(pinned) ? pinned : void 0;
7274
+ }
7100
7275
  async function resolvePinnedBinaryVersionLine(opts) {
7276
+ const pinned = pinnedBinaryPath(opts);
7277
+ if (!pinned) return;
7101
7278
  try {
7102
- if ((0, _browsers_lib_browser_family__rspack_import_4.M_)(opts.browser)) {
7103
- if (!opts.geckoBinary || !node_fs__rspack_import_0.existsSync(opts.geckoBinary)) return;
7104
- return (0, firefox_location2__rspack_import_1.getFirefoxVersion)(opts.geckoBinary) || void 0;
7105
- }
7106
- if (!opts.chromiumBinary || !node_fs__rspack_import_0.existsSync(opts.chromiumBinary)) return;
7107
- return await (0, _browsers_lib_version_probe__rspack_import_8.yO)(opts.chromiumBinary, String(opts.browser)) || void 0;
7279
+ const line = (0, _browsers_lib_browser_family__rspack_import_3.M_)(opts.browser) ? await (0, _browsers_lib_version_probe__rspack_import_7.vE)(pinned) : await (0, _browsers_lib_version_probe__rspack_import_7.yO)(pinned, String(opts.browser));
7280
+ return line || void 0;
7108
7281
  } catch (error) {
7109
- if ((0, _browsers_lib_version_probe__rspack_import_8.g_)(error)) throw error;
7282
+ if ((0, _browsers_lib_version_probe__rspack_import_7.g_)(error)) throw error;
7110
7283
  return;
7111
7284
  }
7112
7285
  }
7113
7286
  async function buildPreviewBannerOptions(opts) {
7114
- const chromiumPinned = !(0, _browsers_lib_browser_family__rspack_import_4.M_)(opts.browser) && 'string' == typeof opts.chromiumBinary && node_fs__rspack_import_0.existsSync(opts.chromiumBinary);
7287
+ const pinned = pinnedBinaryPath(opts);
7115
7288
  return {
7116
7289
  browser: opts.browser,
7117
7290
  outPath: opts.outPath,
@@ -7119,17 +7292,17 @@ var __webpack_modules__ = {
7119
7292
  includeRunId: false,
7120
7293
  readyPath: opts.readyPath,
7121
7294
  browserVersionLine: await resolvePinnedBinaryVersionLine(opts),
7122
- ...chromiumPinned ? {
7123
- binaryPath: opts.chromiumBinary,
7295
+ ...pinned ? {
7296
+ binaryPath: pinned,
7124
7297
  binaryProvenance: 'pinned'
7125
7298
  } : {}
7126
7299
  };
7127
7300
  }
7128
7301
  function asLaunchFailure(error, browser, spawned) {
7129
7302
  const message = error instanceof Error ? error.message : String(error);
7130
- if (spawned || (0, _helpers_messaging__rspack_import_2.Qi)(message)) return error;
7131
- return Object.assign(new Error((0, _browsers_lib_messages__rspack_import_5.uA)(browser, (0, _browsers_lib_ready_stamp__rspack_import_7.dT)(error))), {
7132
- code: _helpers_messaging__rspack_import_2.Lp.E_BROWSER_LAUNCH,
7303
+ if (spawned || (0, _helpers_messaging__rspack_import_1.Qi)(message) || (0, _browsers_lib_ready_stamp__rspack_import_6.NE)(error)) return error;
7304
+ return Object.assign(new Error((0, _browsers_lib_messages__rspack_import_4.uA)(browser, (0, _browsers_lib_ready_stamp__rspack_import_6.dT)(error))), {
7305
+ code: _helpers_messaging__rspack_import_1.Lp.E_BROWSER_LAUNCH,
7133
7306
  cause: error
7134
7307
  });
7135
7308
  }
@@ -7143,21 +7316,21 @@ var __webpack_modules__ = {
7143
7316
  process.once('SIGINT', scheduleExitOnSignal);
7144
7317
  process.once('SIGTERM', scheduleExitOnSignal);
7145
7318
  process.once('SIGHUP', scheduleExitOnSignal);
7146
- (0, _browsers_lib_ready_stamp__rspack_import_7.Jk)(opts.outPath, opts.readyPath);
7319
+ (0, _browsers_lib_ready_stamp__rspack_import_6.Jk)(opts.outPath, opts.readyPath);
7147
7320
  const compilationLike = createPreviewCompilationLike(opts);
7148
7321
  const previewPluginOptions = buildPreviewPluginOptions(opts);
7149
7322
  let bannerOptions;
7150
7323
  try {
7151
7324
  bannerOptions = await buildPreviewBannerOptions(opts);
7152
7325
  } catch (error) {
7153
- (0, _browsers_lib_ready_stamp__rspack_import_7.dz)(opts.outPath, (0, _browsers_lib_ready_stamp__rspack_import_7.dT)(error), (0, _browsers_lib_ready_stamp__rspack_import_7.Uf)(opts.outPath), (0, _browsers_lib_ready_stamp__rspack_import_7.NE)(error));
7326
+ (0, _browsers_lib_ready_stamp__rspack_import_6.dz)(opts.outPath, (0, _browsers_lib_ready_stamp__rspack_import_6.dT)(error), (0, _browsers_lib_ready_stamp__rspack_import_6.Uf)(opts.outPath), (0, _browsers_lib_ready_stamp__rspack_import_6.NE)(error));
7154
7327
  throw error;
7155
7328
  }
7156
- (0, _browsers_lib_output_binaries_resolver__rspack_import_6.LB)(compilationLike);
7157
- if ((0, _browsers_lib_browser_family__rspack_import_4.rG)(opts.browser)) {
7158
- const ctx = (0, _run_chromium_chromium_context__rspack_import_11.g)();
7159
- const launcher = new _run_chromium_chromium_launch__rspack_import_9.f(buildPreviewChromiumOptions(opts), ctx);
7160
- await (0, _browsers_lib_banner__rspack_import_3.MK)(bannerOptions);
7329
+ (0, _browsers_lib_output_binaries_resolver__rspack_import_5.LB)(compilationLike);
7330
+ if ((0, _browsers_lib_browser_family__rspack_import_3.rG)(opts.browser)) {
7331
+ const ctx = (0, _run_chromium_chromium_context__rspack_import_10.g)();
7332
+ const launcher = new _run_chromium_chromium_launch__rspack_import_8.f(buildPreviewChromiumOptions(opts), ctx);
7333
+ await (0, _browsers_lib_banner__rspack_import_2.MK)(bannerOptions);
7161
7334
  try {
7162
7335
  await launcher.runOnce(compilationLike, {
7163
7336
  enableCdpPostLaunch: false,
@@ -7168,12 +7341,12 @@ var __webpack_modules__ = {
7168
7341
  }
7169
7342
  return;
7170
7343
  }
7171
- if ((0, _browsers_lib_browser_family__rspack_import_4.M_)(opts.browser)) {
7172
- const ctx = (0, _run_firefox_firefox_context__rspack_import_12.D)();
7173
- const launcher = new _run_firefox_firefox_launch__rspack_import_10.c(buildPreviewFirefoxOptions(opts), ctx);
7174
- await (0, _browsers_lib_banner__rspack_import_3.MK)(bannerOptions);
7344
+ if ((0, _browsers_lib_browser_family__rspack_import_3.M_)(opts.browser)) {
7345
+ const ctx = (0, _run_firefox_firefox_context__rspack_import_11.D)();
7346
+ const launcher = new _run_firefox_firefox_launch__rspack_import_9.c(buildPreviewFirefoxOptions(opts), ctx);
7347
+ await (0, _browsers_lib_banner__rspack_import_2.MK)(bannerOptions);
7175
7348
  try {
7176
- await launcher.runOnce(compilationLike, (0, _browsers_lib_runtime_options__rspack_import_13.zU)(previewPluginOptions, 'production', {
7349
+ await launcher.runOnce(compilationLike, (0, _browsers_lib_runtime_options__rspack_import_12.zU)(previewPluginOptions, 'production', {
7177
7350
  persistProfile: previewPluginOptions.persistProfile,
7178
7351
  geckoBinary: previewPluginOptions.geckoBinary
7179
7352
  }));
@@ -7272,6 +7445,61 @@ var __webpack_modules__ = {
7272
7445
  const tail = lines.slice(-TOOL_TAIL_LINES).join('\n');
7273
7446
  return tail.length > TOOL_TAIL_BYTES ? tail.slice(-TOOL_TAIL_BYTES) : tail;
7274
7447
  }
7448
+ function isAutomationSafariArgs(args) {
7449
+ const tokens = args.trim().split(/\s+/);
7450
+ const exe = tokens[0] || '';
7451
+ const name = exe.slice(exe.lastIndexOf('/') + 1);
7452
+ return 'Safari' === name && tokens.includes('--automation');
7453
+ }
7454
+ function listPidsWhere(matches) {
7455
+ return new Promise((resolve)=>{
7456
+ const child = (0, external_node_child_process_.spawn)('ps', [
7457
+ '-axww',
7458
+ '-o',
7459
+ 'pid=,args='
7460
+ ], {
7461
+ stdio: [
7462
+ 'ignore',
7463
+ 'pipe',
7464
+ 'ignore'
7465
+ ]
7466
+ });
7467
+ let out = '';
7468
+ child.stdout?.on('data', (chunk)=>out += String(chunk));
7469
+ child.on('error', ()=>resolve([]));
7470
+ child.on('close', ()=>{
7471
+ const pids = [];
7472
+ for (const line of out.split('\n')){
7473
+ const row = /^\s*(\d+)\s+(.*)$/.exec(line);
7474
+ if (row && matches(row[2])) pids.push(Number(row[1]));
7475
+ }
7476
+ resolve(pids);
7477
+ });
7478
+ });
7479
+ }
7480
+ function spawnWebDriverProcess(bin, args) {
7481
+ return new Promise((resolve)=>{
7482
+ const child = (0, external_node_child_process_.spawn)(bin, args, {
7483
+ stdio: 'ignore'
7484
+ });
7485
+ const stop = ()=>{
7486
+ try {
7487
+ child.kill('SIGTERM');
7488
+ } catch {}
7489
+ };
7490
+ child.once('error', (error)=>resolve({
7491
+ ok: false,
7492
+ output: String(error),
7493
+ stop
7494
+ }));
7495
+ child.once('spawn', ()=>resolve({
7496
+ ok: true,
7497
+ pid: child.pid,
7498
+ output: '',
7499
+ stop
7500
+ }));
7501
+ });
7502
+ }
7275
7503
  function runTool(bin, args, opts) {
7276
7504
  const streamOutput = (0, messaging._o)() && !opts?.quiet;
7277
7505
  return new Promise((resolve)=>{
@@ -7343,8 +7571,202 @@ var __webpack_modules__ = {
7343
7571
  quiet: true
7344
7572
  });
7345
7573
  return ok ? output : '';
7574
+ },
7575
+ startWebDriver: (port)=>spawnWebDriverProcess('safaridriver', [
7576
+ '-p',
7577
+ String(port)
7578
+ ]),
7579
+ listAutomationPids: ()=>listPidsWhere(isAutomationSafariArgs)
7580
+ };
7581
+ }
7582
+ var external_node_http_ = __webpack_require__("node:http");
7583
+ var external_node_net_ = __webpack_require__("node:net");
7584
+ const DRIVER_READY_MS = 5000;
7585
+ const DRIVER_POLL_MS = 100;
7586
+ const SESSION_CREATE_MS = 30000;
7587
+ const SESSION_CLOSE_MS = 5000;
7588
+ const AUTOMATION_QUIT_MS = 3000;
7589
+ const activeSessions = new Set();
7590
+ const activeDrivers = new Set();
7591
+ let handlersInstalled = false;
7592
+ function freePort() {
7593
+ return new Promise((resolve, reject)=>{
7594
+ const server = external_node_net_.createServer();
7595
+ server.unref();
7596
+ server.once('error', reject);
7597
+ server.listen(0, '127.0.0.1', ()=>{
7598
+ const address = server.address();
7599
+ const port = 'object' == typeof address && address ? address.port : 0;
7600
+ server.close(()=>resolve(port));
7601
+ });
7602
+ });
7603
+ }
7604
+ function driverRequest(port, method, pathname, body, timeoutMs) {
7605
+ return new Promise((resolve, reject)=>{
7606
+ const payload = void 0 === body ? '' : JSON.stringify(body);
7607
+ const request = external_node_http_.request({
7608
+ host: '127.0.0.1',
7609
+ port,
7610
+ method,
7611
+ path: pathname,
7612
+ headers: {
7613
+ 'Content-Type': 'application/json',
7614
+ 'Content-Length': Buffer.byteLength(payload)
7615
+ },
7616
+ timeout: timeoutMs
7617
+ }, (response)=>{
7618
+ let text = '';
7619
+ response.setEncoding('utf8');
7620
+ response.on('data', (chunk)=>text += chunk);
7621
+ response.on('end', ()=>{
7622
+ let parsed = {};
7623
+ try {
7624
+ parsed = text ? JSON.parse(text) : {};
7625
+ } catch {
7626
+ parsed = {
7627
+ value: {
7628
+ message: text.trim()
7629
+ }
7630
+ };
7631
+ }
7632
+ resolve({
7633
+ status: response.statusCode || 0,
7634
+ body: parsed
7635
+ });
7636
+ });
7637
+ });
7638
+ request.on('timeout', ()=>request.destroy(new Error('timed out')));
7639
+ request.on('error', reject);
7640
+ request.end(payload);
7641
+ });
7642
+ }
7643
+ async function waitForDriver(port) {
7644
+ const deadline = Date.now() + DRIVER_READY_MS;
7645
+ let lastError = '';
7646
+ while(Date.now() < deadline){
7647
+ try {
7648
+ const reply = await driverRequest(port, 'GET', '/status', void 0, 1000);
7649
+ if (200 === reply.status) return null;
7650
+ lastError = `HTTP ${reply.status}`;
7651
+ } catch (error) {
7652
+ lastError = String(error?.message || error);
7653
+ }
7654
+ await new Promise((resolve)=>setTimeout(resolve, DRIVER_POLL_MS));
7655
+ }
7656
+ return `safaridriver did not answer on port ${port} within ${DRIVER_READY_MS}ms (${lastError})`;
7657
+ }
7658
+ function refusalReason(reply) {
7659
+ const value = reply.body?.value;
7660
+ const message = 'string' == typeof value?.message ? value.message.trim() : '';
7661
+ if (message) return message;
7662
+ const error = 'string' == typeof value?.error ? value.error.trim() : '';
7663
+ return error || `safaridriver answered HTTP ${reply.status}`;
7664
+ }
7665
+ function stopAllDriversOnExit() {
7666
+ for (const driver of activeDrivers)driver.stop();
7667
+ }
7668
+ function closeAllOnSignal() {
7669
+ closeSafariWebDriverSessions();
7670
+ }
7671
+ function installHandlersOnce() {
7672
+ if (handlersInstalled) return;
7673
+ handlersInstalled = true;
7674
+ process.on('SIGINT', closeAllOnSignal);
7675
+ process.on('SIGTERM', closeAllOnSignal);
7676
+ process.on('SIGHUP', closeAllOnSignal);
7677
+ process.on('exit', stopAllDriversOnExit);
7678
+ }
7679
+ async function closeSafariWebDriverSessions() {
7680
+ await Promise.all([
7681
+ ...activeSessions
7682
+ ].map((session)=>session.close()));
7683
+ }
7684
+ function processAlive(pid) {
7685
+ try {
7686
+ process.kill(pid, 0);
7687
+ return true;
7688
+ } catch {
7689
+ return false;
7690
+ }
7691
+ }
7692
+ async function quitRaisedAutomation(tools, before) {
7693
+ const raised = (await tools.listAutomationPids()).filter((pid)=>!before.has(pid));
7694
+ for (const pid of raised)try {
7695
+ process.kill(pid, 'SIGTERM');
7696
+ } catch {}
7697
+ const deadline = Date.now() + AUTOMATION_QUIT_MS;
7698
+ while(Date.now() < deadline && raised.some(processAlive))await new Promise((resolve)=>setTimeout(resolve, DRIVER_POLL_MS));
7699
+ }
7700
+ async function openSafariWebDriverSession(tools) {
7701
+ let port;
7702
+ try {
7703
+ port = await freePort();
7704
+ } catch (error) {
7705
+ return {
7706
+ reason: `no free port for safaridriver: ${String(error)}`
7707
+ };
7708
+ }
7709
+ const before = new Set(await tools.listAutomationPids());
7710
+ const driver = await tools.startWebDriver(port);
7711
+ if (!driver.ok) return {
7712
+ reason: `safaridriver could not start: ${driver.output}`
7713
+ };
7714
+ activeDrivers.add(driver);
7715
+ installHandlersOnce();
7716
+ const stopDriver = async ()=>{
7717
+ driver.stop();
7718
+ activeDrivers.delete(driver);
7719
+ await quitRaisedAutomation(tools, before);
7720
+ };
7721
+ const notReady = await waitForDriver(port);
7722
+ if (notReady) {
7723
+ await stopDriver();
7724
+ return {
7725
+ reason: notReady
7726
+ };
7727
+ }
7728
+ let created;
7729
+ try {
7730
+ created = await driverRequest(port, 'POST', '/session', {
7731
+ capabilities: {
7732
+ alwaysMatch: {
7733
+ browserName: 'safari'
7734
+ }
7735
+ }
7736
+ }, SESSION_CREATE_MS);
7737
+ } catch (error) {
7738
+ await stopDriver();
7739
+ return {
7740
+ reason: `the WebDriver session request failed: ${String(error?.message || error)}`
7741
+ };
7742
+ }
7743
+ const sessionId = created.body?.value?.sessionId;
7744
+ if (200 !== created.status || 'string' != typeof sessionId || !sessionId) {
7745
+ await stopDriver();
7746
+ return {
7747
+ reason: refusalReason(created)
7748
+ };
7749
+ }
7750
+ let closing = null;
7751
+ const session = {
7752
+ port,
7753
+ sessionId,
7754
+ close: ()=>{
7755
+ if (closing) return closing;
7756
+ closing = (async ()=>{
7757
+ activeSessions.delete(session);
7758
+ try {
7759
+ await driverRequest(port, 'DELETE', `/session/${sessionId}`, void 0, SESSION_CLOSE_MS);
7760
+ } catch {}
7761
+ await stopDriver();
7762
+ })();
7763
+ return closing;
7346
7764
  }
7347
7765
  };
7766
+ activeSessions.add(session);
7767
+ return {
7768
+ session
7769
+ };
7348
7770
  }
7349
7771
  function fallbackLogger() {
7350
7772
  return {
@@ -7437,6 +7859,24 @@ var __webpack_modules__ = {
7437
7859
  (0, messaging._w)((0, ready_message.G)('development', String(host.browser)));
7438
7860
  } catch {}
7439
7861
  }
7862
+ async function holdWebDriverSession(tools, config, logger) {
7863
+ await closeSafariWebDriverSessions();
7864
+ const runId = (0, ready_stamp.Uf)(config.extensionDir);
7865
+ const outcome = await openSafariWebDriverSession(tools);
7866
+ if (outcome.session) {
7867
+ const { port, sessionId } = outcome.session;
7868
+ (0, ready_stamp.ZC)(config.extensionDir, {
7869
+ port,
7870
+ sessionId
7871
+ }, runId);
7872
+ logger.info?.(messages.Hp(port, sessionId));
7873
+ return;
7874
+ }
7875
+ (0, ready_stamp.ZC)(config.extensionDir, {
7876
+ unavailableReason: outcome.reason
7877
+ }, runId);
7878
+ logger.info?.(messages.lb(outcome.reason));
7879
+ }
7440
7880
  async function runSafariPipeline(compilation, host, logger, mode) {
7441
7881
  const tools = host.tools || createSafariTools();
7442
7882
  const config = (0, safari_config.F7)(compilation, host);
@@ -7521,7 +7961,10 @@ var __webpack_modules__ = {
7521
7961
  logger.info?.(messages.fO(config.appName, isSigned));
7522
7962
  if (await confirmRegisteredWithSafari(tools, config.bundleIdentifier)) logger.info?.(messages.fd(config.appName));
7523
7963
  else logger.info?.(messages.qY(config.appName));
7524
- if (host.announceDevReady) await announceSafariDevSession(host, config, appPath);
7964
+ if (host.announceDevReady) {
7965
+ await holdWebDriverSession(tools, config, logger);
7966
+ await announceSafariDevSession(host, config, appPath);
7967
+ }
7525
7968
  return completePackage(config, logger, mode);
7526
7969
  }
7527
7970
  async function packageSafariExtension(host, outputPath, logger, mode = 'full') {
@@ -7837,8 +8280,27 @@ var __webpack_modules__ = {
7837
8280
  });
7838
8281
  },
7839
8282
  "./helpers/messaging.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
7840
- var pintor__rspack_import_0 = __webpack_require__("pintor");
7841
- var pintor__rspack_import_0_default = /*#__PURE__*/ __webpack_require__.n(pintor__rspack_import_0);
8283
+ __webpack_require__.d(__webpack_exports__, {
8284
+ Lp: ()=>CODES,
8285
+ Pr: ()=>ENVELOPE,
8286
+ T_: ()=>artifactNoun,
8287
+ QZ: ()=>browserDisplayName,
8288
+ A6: ()=>browserRowValue,
8289
+ Nr: ()=>card,
8290
+ od: ()=>claimCardKey,
8291
+ Sc: ()=>fmt,
8292
+ Qi: ()=>hasChannelPrefix,
8293
+ Gg: ()=>humanError,
8294
+ _w: ()=>humanLine,
8295
+ mR: ()=>humanWarn,
8296
+ VR: ()=>isCardKeyClaimed,
8297
+ _o: ()=>isDebug,
8298
+ Pl: ()=>prefix,
8299
+ UT: ()=>stripChannelPrefix
8300
+ });
8301
+ const external_node_util_namespaceObject = require("node:util");
8302
+ var external_pintor_ = __webpack_require__("pintor");
8303
+ var external_pintor_default = /*#__PURE__*/ __webpack_require__.n(external_pintor_);
7842
8304
  const GLYPH = '⏵⏵⏵';
7843
8305
  const DEBUG_GLYPH = '···';
7844
8306
  const DEBUG_VALUES = new Set([
@@ -7855,11 +8317,11 @@ var __webpack_modules__ = {
7855
8317
  return DEBUG_VALUES.has(String(raw ?? '').trim().toLowerCase());
7856
8318
  }
7857
8319
  function prefix(type) {
7858
- if ('error' === type) return pintor__rspack_import_0_default().red(GLYPH);
7859
- if ('warn' === type) return pintor__rspack_import_0_default().brightYellow(GLYPH);
7860
- if ('success' === type) return pintor__rspack_import_0_default().green(GLYPH);
7861
- if ('debug' === type) return pintor__rspack_import_0_default().dim(pintor__rspack_import_0_default().gray(DEBUG_GLYPH));
7862
- return pintor__rspack_import_0_default().gray(GLYPH);
8320
+ if ('error' === type) return external_pintor_default().red(GLYPH);
8321
+ if ('warn' === type) return external_pintor_default().brightYellow(GLYPH);
8322
+ if ('success' === type) return external_pintor_default().green(GLYPH);
8323
+ if ('debug' === type) return external_pintor_default().dim(external_pintor_default().gray(DEBUG_GLYPH));
8324
+ return external_pintor_default().gray(GLYPH);
7863
8325
  }
7864
8326
  const ANSI_PATTERN = /\[[0-9;]*m/g;
7865
8327
  function hasChannelPrefix(text) {
@@ -7876,7 +8338,7 @@ var __webpack_modules__ = {
7876
8338
  return MACHINE_OUTPUT_VALUES.has(String(process.env.EXTENSION_OUTPUT || '').trim().toLowerCase());
7877
8339
  }
7878
8340
  function humanLine(...parts) {
7879
- if (isMachineOutput()) return;
8341
+ if (isMachineOutput()) return void process.stderr.write(`${(0, external_node_util_namespaceObject.format)(...parts)}\n`);
7880
8342
  console.log(...parts);
7881
8343
  }
7882
8344
  function humanWarn(...parts) {
@@ -7887,10 +8349,10 @@ var __webpack_modules__ = {
7887
8349
  console.error(...parts);
7888
8350
  }
7889
8351
  const fmt = {
7890
- heading: (title)=>pintor__rspack_import_0_default().underline(pintor__rspack_import_0_default().blue(title)),
7891
- label: (key)=>pintor__rspack_import_0_default().gray(key.toUpperCase()),
7892
- val: (value)=>pintor__rspack_import_0_default().underline(value),
7893
- code: (value)=>pintor__rspack_import_0_default().blue(value),
8352
+ heading: (title)=>external_pintor_default().underline(external_pintor_default().blue(title)),
8353
+ label: (key)=>external_pintor_default().gray(key.toUpperCase()),
8354
+ val: (value)=>external_pintor_default().underline(value),
8355
+ code: (value)=>external_pintor_default().blue(value),
7894
8356
  bullet: (value)=>`- ${value}`,
7895
8357
  block (title, rows) {
7896
8358
  const head = fmt.heading(title);
@@ -7914,10 +8376,10 @@ var __webpack_modules__ = {
7914
8376
  function card(input = {}) {
7915
8377
  const version = String(input.version || '').trim();
7916
8378
  const suffix = String(input.suffix || '').trim();
7917
- const head = ` 🧩 Extension.js` + (version ? ` ${pintor__rspack_import_0_default().gray(version)}` : '') + (suffix ? ` ${suffix}` : '');
8379
+ const head = ` 🧩 Extension.js` + (version ? ` ${external_pintor_default().gray(version)}` : '') + (suffix ? ` ${suffix}` : '');
7918
8380
  const body = (input.rows || []).filter((row)=>String(row.value || '').trim().length > 0).slice(0, MAX_CARD_ROWS).map((row)=>{
7919
8381
  const label = row.label.padEnd(CARD_LABEL_WIDTH);
7920
- return ` ${label}${pintor__rspack_import_0_default().gray(String(row.value).trim())}`;
8382
+ return ` ${label}${external_pintor_default().gray(String(row.value).trim())}`;
7921
8383
  });
7922
8384
  return [
7923
8385
  head,
@@ -8030,7 +8492,6 @@ var __webpack_modules__ = {
8030
8492
  E_CONFIG_LOAD: 'E_CONFIG_LOAD',
8031
8493
  E_MANAGED_DEP_CONFLICT: 'E_MANAGED_DEP_CONFLICT',
8032
8494
  E_TYPES_EMIT: 'E_TYPES_EMIT',
8033
- E_TSCONFIG_MISSING: 'E_TSCONFIG_MISSING',
8034
8495
  E_OPTIONAL_DEP_UNRESOLVED: 'E_OPTIONAL_DEP_UNRESOLVED',
8035
8496
  E_OPTIONAL_DEP_LOAD: 'E_OPTIONAL_DEP_LOAD',
8036
8497
  E_OPTIONAL_DEP_UNKNOWN: 'E_OPTIONAL_DEP_UNKNOWN',
@@ -8046,11 +8507,9 @@ var __webpack_modules__ = {
8046
8507
  E_CSS_PARSE: 'E_CSS_PARSE',
8047
8508
  E_CSS_PREPROCESSOR_MISSING: 'E_CSS_PREPROCESSOR_MISSING',
8048
8509
  E_CSS_DEAD_REF: 'E_CSS_DEAD_REF',
8049
- E_INTEGRATION_INSTALL: 'E_INTEGRATION_INSTALL',
8050
8510
  E_POLYFILL_NOT_FOUND: 'E_POLYFILL_NOT_FOUND',
8051
8511
  E_LOCALES_LAYOUT: 'E_LOCALES_LAYOUT',
8052
8512
  E_WAR_INVALID: 'E_WAR_INVALID',
8053
- E_MATCH_PATTERN_INVALID: 'E_MATCH_PATTERN_INVALID',
8054
8513
  E_BACKGROUND_REQUIRED: 'E_BACKGROUND_REQUIRED',
8055
8514
  E_CONTENT_SCRIPT_SYNTAX: 'E_CONTENT_SCRIPT_SYNTAX',
8056
8515
  E_NO_ENTRYPOINTS: 'E_NO_ENTRYPOINTS',
@@ -8069,7 +8528,6 @@ var __webpack_modules__ = {
8069
8528
  E_BROWSER_START_TIMEOUT: 'E_BROWSER_START_TIMEOUT',
8070
8529
  E_LAUNCH_SKIPPED_COMPILE_ERRORS: 'E_LAUNCH_SKIPPED_COMPILE_ERRORS',
8071
8530
  E_INSTANCE_AMBIGUOUS: 'E_INSTANCE_AMBIGUOUS',
8072
- E_WSL_INTEROP: 'E_WSL_INTEROP',
8073
8531
  E_EXTENSION_LOAD_REFUSED: 'E_EXTENSION_LOAD_REFUSED',
8074
8532
  E_ADDON_INSTALL: 'E_ADDON_INSTALL',
8075
8533
  E_BROWSER_CONNECT: 'E_BROWSER_CONNECT',
@@ -8081,6 +8539,7 @@ var __webpack_modules__ = {
8081
8539
  E_RDP_PROTOCOL: 'E_RDP_PROTOCOL',
8082
8540
  E_PORT_IN_USE: 'E_PORT_IN_USE',
8083
8541
  E_SESSION_STOPPED: 'E_SESSION_STOPPED',
8542
+ E_SESSION_EXISTS: 'E_SESSION_EXISTS',
8084
8543
  E_LOGS_STREAM_GAP: 'E_LOGS_STREAM_GAP',
8085
8544
  E_BROWSER_INSTALL_PRIVILEGE: 'E_BROWSER_INSTALL_PRIVILEGE',
8086
8545
  E_UNINSTALL_NOOP: 'E_UNINSTALL_NOOP'
@@ -8134,25 +8593,6 @@ var __webpack_modules__ = {
8134
8593
  }, extras);
8135
8594
  }
8136
8595
  };
8137
- __webpack_require__.d(__webpack_exports__, {
8138
- A6: ()=>browserRowValue,
8139
- Gg: ()=>humanError,
8140
- Nr: ()=>card,
8141
- Pl: ()=>prefix,
8142
- QZ: ()=>browserDisplayName,
8143
- Qi: ()=>hasChannelPrefix,
8144
- T_: ()=>artifactNoun,
8145
- UT: ()=>stripChannelPrefix,
8146
- VR: ()=>isCardKeyClaimed,
8147
- _o: ()=>isDebug,
8148
- _w: ()=>humanLine,
8149
- mR: ()=>humanWarn,
8150
- od: ()=>claimCardKey
8151
- }, {
8152
- Lp: CODES,
8153
- Pr: ENVELOPE,
8154
- Sc: fmt
8155
- });
8156
8596
  },
8157
8597
  "./helpers/vendors.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
8158
8598
  const EMULATOR_BROWSER_TARGET = 'chromium-emulator';
@@ -8283,6 +8723,8 @@ var __webpack_modules__ = {
8283
8723
  });
8284
8724
  },
8285
8725
  "./index.ts" (__unused_rspack_module, __unused_rspack___webpack_exports__, __webpack_require__) {
8726
+ var external_node_fs_ = __webpack_require__("node:fs");
8727
+ var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_);
8286
8728
  const MIN_NODE_MAJOR = 22;
8287
8729
  const MIN_NODE_MINOR = 12;
8288
8730
  const MIN_DENO_MAJOR = 2;
@@ -8326,7 +8768,42 @@ var __webpack_modules__ = {
8326
8768
  function unsupportedNodeVersionMessage(version) {
8327
8769
  return `[Extension.js] Requires Node.js >= ${MIN_NODE_MAJOR}.${MIN_NODE_MINOR} (you are on ${version}). Upgrade Node.js to run the extension CLI.`;
8328
8770
  }
8329
- function enforceSupportedNodeVersion(version = process.versions.node, bunVersion = detectBunVersion(), denoVersion = detectDenoVersion()) {
8771
+ function wantsJsonOutput(argv) {
8772
+ const inline = argv.find((arg)=>arg.startsWith('--output='));
8773
+ const index = argv.indexOf('--output');
8774
+ const spaced = index >= 0 ? argv[index + 1] : void 0;
8775
+ const value = inline ? inline.slice(9) : spaced;
8776
+ return 'json' === String(value || '').trim().toLowerCase();
8777
+ }
8778
+ function commandFromArgv(argv) {
8779
+ for(let index = 2; index < argv.length; index += 1)if ('--output' === argv[index]) index += 1;
8780
+ else if (!argv[index].startsWith('-')) return argv[index];
8781
+ return 'extension';
8782
+ }
8783
+ function unsupportedNodeVersionFrame(version, argv) {
8784
+ if (!wantsJsonOutput(argv)) return;
8785
+ return {
8786
+ schema: 1,
8787
+ ok: false,
8788
+ command: commandFromArgv(argv),
8789
+ status: 'usage',
8790
+ value: null,
8791
+ error: {
8792
+ code: 'E_NODE_VERSION',
8793
+ message: unsupportedNodeVersionMessage(version).replace('[Extension.js] ', ''),
8794
+ name: 'CliError'
8795
+ },
8796
+ warnings: []
8797
+ };
8798
+ }
8799
+ function writeFrame(frame) {
8800
+ try {
8801
+ external_node_fs_default().writeSync(1, `${JSON.stringify(frame)}\n`);
8802
+ } catch {
8803
+ console.log(JSON.stringify(frame));
8804
+ }
8805
+ }
8806
+ function enforceSupportedNodeVersion(version = process.versions.node, bunVersion = detectBunVersion(), denoVersion = detectDenoVersion(), argv = process.argv) {
8330
8807
  if (denoVersion) {
8331
8808
  if (isSupportedDenoVersion(denoVersion)) return;
8332
8809
  console.error(unsupportedDenoVersionMessage(denoVersion));
@@ -8341,20 +8818,23 @@ var __webpack_modules__ = {
8341
8818
  }
8342
8819
  if (isSupportedNodeVersion(version)) return;
8343
8820
  console.error(unsupportedNodeVersionMessage(version));
8821
+ const frame = unsupportedNodeVersionFrame(version, argv);
8822
+ if (frame) writeFrame(frame);
8344
8823
  process.exit(1);
8345
8824
  }
8346
8825
  enforceSupportedNodeVersion();
8347
8826
  const external_commander_namespaceObject = require("commander");
8348
- var external_node_fs_ = __webpack_require__("node:fs");
8349
- var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_);
8350
8827
  var external_node_path_ = __webpack_require__("node:path");
8351
8828
  var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_);
8352
8829
  var browser_family = __webpack_require__("./browsers/browsers-lib/browser-family.ts");
8830
+ var evaluate = __webpack_require__("./browsers/run-firefox/rdp/remote-firefox/evaluate.ts");
8353
8831
  var messaging_client = __webpack_require__("./browsers/run-firefox/rdp/remote-firefox/messaging-client.ts");
8354
8832
  const RESULT_SLOT = '__extjsRdpEval';
8355
8833
  const FRAME_POLL_INTERVAL_MS = 100;
8356
8834
  const RESULT_POLL_INTERVAL_MS = 50;
8357
8835
  const FRAME_WAIT_MS = 2000;
8836
+ const MAX_RESULT_BYTES = 262144;
8837
+ const TRUNCATED_PREVIEW_CHARS = 1024;
8358
8838
  const EXTENSION_DOCUMENT_CONTEXTS = [
8359
8839
  'background',
8360
8840
  'popup',
@@ -8405,17 +8885,27 @@ var __webpack_modules__ = {
8405
8885
  globalThis.${RESULT_SLOT} = slot;
8406
8886
  function settle(next) { if (globalThis.${RESULT_SLOT} === slot) globalThis.${RESULT_SLOT} = next; }
8407
8887
  function encode(value) {
8408
- if (value === undefined) return {state: "value"};
8409
- try { return {state: "value", json: JSON.stringify(value)}; }
8410
- catch (error) { return {state: "value", json: JSON.stringify(String(value))}; }
8888
+ var json;
8889
+ try { json = JSON.stringify(value); }
8890
+ catch (error) { json = JSON.stringify(String(value)); }
8891
+ if (json === undefined) return {state: "value"};
8892
+ if (json.length > ${MAX_RESULT_BYTES}) {
8893
+ return {state: "value", truncated: true, json: JSON.stringify({__type: "truncated", preview: json.slice(0, ${TRUNCATED_PREVIEW_CHARS})})};
8894
+ }
8895
+ return {state: "value", json: json};
8896
+ }
8897
+ function thrown(error) {
8898
+ var message = (error && error.message) || String(error);
8899
+ var name = error && typeof error.name === "string" ? error.name : "";
8900
+ return {state: "throw", message: name && message.indexOf(name + ":") !== 0 ? name + ": " + message : message};
8411
8901
  }
8412
8902
  try {
8413
8903
  Promise.resolve((${expression})).then(
8414
8904
  function (value) { settle(encode(value)); },
8415
- function (error) { settle({state: "throw", message: (error && error.message) || String(error)}); }
8905
+ function (error) { settle(thrown(error)); }
8416
8906
  );
8417
8907
  } catch (error) {
8418
- settle({state: "throw", message: (error && error.message) || String(error)});
8908
+ settle(thrown(error));
8419
8909
  }
8420
8910
  return "started";
8421
8911
  })()`;
@@ -8425,6 +8915,9 @@ var __webpack_modules__ = {
8425
8915
  if (slot && slot.state !== "pending") { try { delete globalThis.${RESULT_SLOT}; } catch (error) {} }
8426
8916
  return JSON.stringify(slot);
8427
8917
  })()`;
8918
+ function statementBlock(source) {
8919
+ return `{\n${source}\n}`;
8920
+ }
8428
8921
  function readSettledSlot(raw) {
8429
8922
  if ('string' != typeof raw) return;
8430
8923
  let slot;
@@ -8448,17 +8941,70 @@ var __webpack_modules__ = {
8448
8941
  ok: true,
8449
8942
  value: void 0
8450
8943
  };
8944
+ let value = slot.json;
8451
8945
  try {
8452
- return {
8453
- ok: true,
8454
- value: JSON.parse(slot.json)
8455
- };
8456
- } catch {
8457
- return {
8458
- ok: true,
8459
- value: slot.json
8460
- };
8461
- }
8946
+ value = JSON.parse(slot.json);
8947
+ } catch {}
8948
+ return true === slot.truncated ? {
8949
+ ok: true,
8950
+ value,
8951
+ truncated: true
8952
+ } : {
8953
+ ok: true,
8954
+ value
8955
+ };
8956
+ }
8957
+ async function readWholeString(client, value, limit = 1 / 0) {
8958
+ const grip = value;
8959
+ if (!grip || 'object' != typeof grip || 'longString' !== grip.type) return value;
8960
+ const length = 'number' == typeof grip.length ? grip.length : 0;
8961
+ const reply = await client.request({
8962
+ to: String(grip.actor),
8963
+ type: 'substring',
8964
+ start: 0,
8965
+ end: Math.min(length, limit)
8966
+ });
8967
+ if ('string' != typeof reply?.substring) throw new Error(`Firefox holds a ${length}-character result as a long string and did not hand it over`);
8968
+ return reply.substring;
8969
+ }
8970
+ function capped(value) {
8971
+ const json = JSON.stringify(value);
8972
+ if (void 0 !== json && json.length > MAX_RESULT_BYTES) return {
8973
+ ok: true,
8974
+ truncated: true,
8975
+ value: {
8976
+ __type: 'truncated',
8977
+ preview: json.slice(0, TRUNCATED_PREVIEW_CHARS)
8978
+ }
8979
+ };
8980
+ return {
8981
+ ok: true,
8982
+ value
8983
+ };
8984
+ }
8985
+ function readCompletionValue(grip) {
8986
+ if (null === grip || 'object' != typeof grip) return capped(grip);
8987
+ const { type, actor, text } = grip;
8988
+ if ('object' === type && 'string' == typeof actor) return {
8989
+ objectActor: actor
8990
+ };
8991
+ if ('undefined' === type || 'symbol' === type) return {
8992
+ ok: true,
8993
+ value: void 0
8994
+ };
8995
+ if ('BigInt' === type) return {
8996
+ ok: true,
8997
+ value: String(text)
8998
+ };
8999
+ if ('-0' === type) return {
9000
+ ok: true,
9001
+ value: 0
9002
+ };
9003
+ if ('null' === type || 'NaN' === type || 'Infinity' === type || '-Infinity' === type) return {
9004
+ ok: true,
9005
+ value: null
9006
+ };
9007
+ return refuse('Unsupported', `Firefox answered a value of the kind "${String(type)}", which this route cannot read back. Wrap the statements in a function that returns the value`);
8462
9008
  }
8463
9009
  const sleep = (ms)=>new Promise((resolve)=>{
8464
9010
  const timer = setTimeout(resolve, ms);
@@ -8490,6 +9036,37 @@ var __webpack_modules__ = {
8490
9036
  watcherActor: watcher.actor
8491
9037
  };
8492
9038
  }
9039
+ async function evaluateStatements(client, consoleActor, source) {
9040
+ let completion;
9041
+ try {
9042
+ completion = await client.evaluate(consoleActor, statementBlock(source));
9043
+ } catch (error) {
9044
+ if (!(error instanceof evaluate.K)) throw error;
9045
+ return refuse('EvalError', error.message);
9046
+ }
9047
+ return readCompletionValue(await readWholeString(client, completion, MAX_RESULT_BYTES + 1));
9048
+ }
9049
+ async function evaluateInConsole(options) {
9050
+ const { client, consoleActor, expression, timeoutMs, where } = options;
9051
+ try {
9052
+ await client.evaluate(consoleActor, startExpression(expression));
9053
+ } catch (error) {
9054
+ if (!(error instanceof evaluate.K)) throw error;
9055
+ if (!/^SyntaxError\b/.test(error.message)) return refuse('EvalError', error.message);
9056
+ const completion = await evaluateStatements(client, consoleActor, expression);
9057
+ if ('ok' in completion) return completion;
9058
+ await client.evaluate(consoleActor, startExpression('_self'), {
9059
+ selectedObjectActor: completion.objectActor
9060
+ });
9061
+ }
9062
+ const deadline = Date.now() + timeoutMs;
9063
+ for(;;){
9064
+ const settled = readSettledSlot(await readWholeString(client, await client.evaluate(consoleActor, POLL_EXPRESSION)));
9065
+ if (settled) return settled;
9066
+ if (Date.now() >= deadline) return refuse('Timeout', `the expression did not settle in ${where} within ${timeoutMs}ms`);
9067
+ await sleep(RESULT_POLL_INTERVAL_MS);
9068
+ }
9069
+ }
8493
9070
  async function evaluateThroughWatcher(options) {
8494
9071
  const { client, extensionId, context, pagePath, expression, timeoutMs } = options;
8495
9072
  const located = await locateAddonWatcher(client, extensionId);
@@ -8519,14 +9096,13 @@ var __webpack_modules__ = {
8519
9096
  consoleActor = pickDocumentFrame(frames, context, pagePath);
8520
9097
  }
8521
9098
  if (!consoleActor) return refuse('TargetNotFound', 'background' === context ? "the add-on's background document is not running, so there is nothing to evaluate in" : `the ${context} document is not open (open it first: extension open ${context})`);
8522
- await client.evaluate(consoleActor, startExpression(expression));
8523
- const resultDeadline = Date.now() + timeoutMs;
8524
- for(;;){
8525
- const settled = readSettledSlot(await client.evaluate(consoleActor, POLL_EXPRESSION));
8526
- if (settled) return settled;
8527
- if (Date.now() >= resultDeadline) return refuse('Timeout', `the expression did not settle in the ${context} document within ${timeoutMs}ms`);
8528
- await sleep(RESULT_POLL_INTERVAL_MS);
8529
- }
9099
+ return await evaluateInConsole({
9100
+ client,
9101
+ consoleActor,
9102
+ expression,
9103
+ timeoutMs,
9104
+ where: `the ${context} document`
9105
+ });
8530
9106
  } finally{
8531
9107
  stopListening();
8532
9108
  Promise.resolve(client.request({
@@ -8548,29 +9124,66 @@ var __webpack_modules__ = {
8548
9124
  });
8549
9125
  });
8550
9126
  }
8551
- async function evaluateExtensionDocument(options) {
9127
+ async function withDebugger(rdpPort, timeoutMs, run) {
8552
9128
  const client = new messaging_client.G();
8553
9129
  try {
8554
- const connected = await connectWithin(client, options.rdpPort, options.timeoutMs);
9130
+ const connected = await connectWithin(client, rdpPort, timeoutMs);
8555
9131
  if ('timeout' === connected) {
8556
9132
  client.disconnect();
8557
- return refuse('Timeout', `the Firefox debugger on port ${options.rdpPort} sent no RDP greeting within ${options.timeoutMs}ms`);
9133
+ return refuse('Timeout', `the Firefox debugger on port ${rdpPort} sent no RDP greeting within ${timeoutMs}ms`);
8558
9134
  }
8559
9135
  } catch (error) {
8560
9136
  client.disconnect();
8561
- return refuse('Unavailable', `could not reach the Firefox debugger on port ${options.rdpPort}: ${error?.message || 'connection refused'}`);
9137
+ return refuse('Unavailable', `could not reach the Firefox debugger on port ${rdpPort}: ${error?.message || 'connection refused'}`);
8562
9138
  }
8563
9139
  try {
8564
- return await evaluateThroughWatcher({
8565
- ...options,
8566
- client: client
8567
- });
9140
+ return await run(client);
8568
9141
  } catch (error) {
8569
9142
  return refuse('Unavailable', error?.message || 'the Firefox debugger connection failed mid-evaluation');
8570
9143
  } finally{
8571
9144
  client.disconnect();
8572
9145
  }
8573
9146
  }
9147
+ async function evaluateExtensionDocument(options) {
9148
+ return await withDebugger(options.rdpPort, options.timeoutMs, (client)=>evaluateThroughWatcher({
9149
+ ...options,
9150
+ client
9151
+ }));
9152
+ }
9153
+ function pickTabDescriptor(tabs, url) {
9154
+ const matches = tabs.filter((tab)=>'string' == typeof tab.actor && tab.actor && tab.url === url);
9155
+ return 1 === matches.length ? String(matches[0].actor) : void 0;
9156
+ }
9157
+ async function evaluateThroughTab(options) {
9158
+ const { client, url, expression, timeoutMs } = options;
9159
+ const listed = await client.request({
9160
+ to: 'root',
9161
+ type: 'listTabs'
9162
+ });
9163
+ const descriptor = pickTabDescriptor(listed?.tabs || [], url);
9164
+ if (!descriptor) return;
9165
+ const target = await client.request({
9166
+ to: descriptor,
9167
+ type: 'getTarget'
9168
+ });
9169
+ const consoleActor = target?.frame?.consoleActor;
9170
+ if ('string' != typeof consoleActor || !consoleActor) return;
9171
+ return await evaluateInConsole({
9172
+ client,
9173
+ consoleActor,
9174
+ expression,
9175
+ timeoutMs,
9176
+ where: 'the page'
9177
+ });
9178
+ }
9179
+ async function evaluateTabDocument(options) {
9180
+ const outcome = await withDebugger(options.rdpPort, options.timeoutMs, (client)=>evaluateThroughTab({
9181
+ ...options,
9182
+ client
9183
+ }));
9184
+ if (outcome && !outcome.ok && 'Unavailable' === outcome.error.name) return;
9185
+ return outcome;
9186
+ }
8574
9187
  var emulator_session = __webpack_require__("./helpers/emulator-session.ts");
8575
9188
  var external_pintor_ = __webpack_require__("pintor");
8576
9189
  var external_pintor_default = /*#__PURE__*/ __webpack_require__.n(external_pintor_);
@@ -8868,7 +9481,8 @@ var __webpack_modules__ = {
8868
9481
  ...enforcedProps,
8869
9482
  ...this.common,
8870
9483
  app: this.app,
8871
- $ip: null
9484
+ $ip: null,
9485
+ $geoip_disable: true
8872
9486
  },
8873
9487
  distinct_id: this.anonId
8874
9488
  };
@@ -9018,7 +9632,7 @@ var __webpack_modules__ = {
9018
9632
  return Math.min(Math.max(n, min), max);
9019
9633
  }
9020
9634
  const TEMPLATE_CORPUS_REPO = 'extension-js/examples';
9021
- const TEMPLATE_CORPUS_REF = '573d5d58174122606e5d6b6b0f2eafd6c02dcbf7';
9635
+ const TEMPLATE_CORPUS_REF = '2a8c4bae43ba6e883bf9ce7f6d108963ed162516';
9022
9636
  const TEMPLATE_CORPUS_SLUGS = [
9023
9637
  'action',
9024
9638
  'action-locales',
@@ -9506,6 +10120,14 @@ var __webpack_modules__ = {
9506
10120
  function parseJsonSafe(filePath) {
9507
10121
  return JSON.parse(external_node_fs_default().readFileSync(filePath, 'utf8'));
9508
10122
  }
10123
+ function runtimeNotFound(message) {
10124
+ return Object.assign(new Error(message), {
10125
+ code: messaging.Lp.E_RUNTIME_NOT_FOUND
10126
+ });
10127
+ }
10128
+ function runtimeNotBuilt(root) {
10129
+ return runtimeNotFound(`Local extension-develop runtime is not built at ${external_node_path_default().join(root, 'dist')}. Run \`pnpm --filter extension-develop compile\` before invoking the local CLI.`);
10130
+ }
9509
10131
  function resolveDevelopRootFromDir(dir) {
9510
10132
  try {
9511
10133
  const packageJsonPath = external_node_path_default().join(dir, 'package.json');
@@ -9574,7 +10196,7 @@ var __webpack_modules__ = {
9574
10196
  }
9575
10197
  function resolveExtensionDevelopRoot(startDir = __dirname) {
9576
10198
  const { root, source } = resolvePreferredDevelopRoot(startDir);
9577
- if (!root) throw new Error('Unable to locate the extension-develop runtime.');
10199
+ if (!root) throw runtimeNotFound('Unable to locate the extension-develop runtime.');
9578
10200
  process.env.EXTENSION_DEVELOP_ROOT = root;
9579
10201
  if ('workspace' === source) process.env.EXTENSION_CREATE_DEVELOP_ROOT = root;
9580
10202
  return root;
@@ -9601,7 +10223,7 @@ var __webpack_modules__ = {
9601
10223
  const { source } = resolvePreferredDevelopRoot(startDir);
9602
10224
  const distEntry = resolveDevelopDistEntry(root);
9603
10225
  if (distEntry) return importModule(distEntry);
9604
- if ('workspace' === source) throw new Error(`Local extension-develop runtime is not built at ${external_node_path_default().join(root, 'dist')}. Run \`pnpm --filter extension-develop compile\` before invoking the local CLI.`);
10226
+ if ('workspace' === source) throw runtimeNotBuilt(root);
9605
10227
  return await import("extension-develop");
9606
10228
  }
9607
10229
  async function loadExtensionDevelopPreviewModule(startDir = __dirname) {
@@ -9611,7 +10233,7 @@ var __webpack_modules__ = {
9611
10233
  if (previewEntry) return importModule(previewEntry);
9612
10234
  const fullEntry = resolveDevelopDistEntry(root);
9613
10235
  if (fullEntry) return importModule(fullEntry);
9614
- if ('workspace' === source) throw new Error(`Local extension-develop runtime is not built at ${external_node_path_default().join(root, 'dist')}. Run \`pnpm --filter extension-develop compile\` before invoking the local CLI.`);
10236
+ if ('workspace' === source) throw runtimeNotBuilt(root);
9615
10237
  return await import("extension-develop/preview");
9616
10238
  }
9617
10239
  async function loadExtensionDevelopBridgeModule(startDir = __dirname) {
@@ -9619,7 +10241,7 @@ var __webpack_modules__ = {
9619
10241
  const { source } = resolvePreferredDevelopRoot(startDir);
9620
10242
  const bridgeEntry = resolveDevelopDistEntry(root, 'bridge');
9621
10243
  if (bridgeEntry) return importModule(bridgeEntry);
9622
- if ('workspace' === source) throw new Error(`Local extension-develop runtime is not built at ${external_node_path_default().join(root, 'dist')}. Run \`pnpm --filter extension-develop compile\` before invoking the local CLI.`);
10244
+ if ('workspace' === source) throw runtimeNotBuilt(root);
9623
10245
  const bridgeSpecifier = 'extension-develop/bridge';
9624
10246
  return await import(bridgeSpecifier);
9625
10247
  }
@@ -10321,9 +10943,13 @@ Cross-browser compatibility
10321
10943
  ],
10322
10944
  notes: [
10323
10945
  'ready.json is written atomically by the build (dev/start) on each compile',
10946
+ 'start with a browser to launch stays on starting, with compiledAt set, until the launch passed its binary checks, so --wait keeps waiting and reports a refused pin as that refusal',
10324
10947
  'events.ndjson is reset at every run start and appends entries with runId, durationMs and errorCount for that run only, join on runId across runs',
10948
+ 'dev --browser safari holds one safaridriver session beside the app and stamps webdriverPort and webdriverSessionId, or webdriverUnavailableReason when Safari automation is off, attach to that session instead of opening a second',
10949
+ 'a Chromium dev session whose CDP wire failed after launch stays ready and stamps cdpFaultCode and cdpFaultMessage, the ready frame under --output json carries the same fault as a coded warning, reload and HMR cannot attach until it is fixed',
10325
10950
  '--wait requires a local project path (remote URLs are not supported)',
10326
- 'consumers should verify pid liveness and recency before trusting a contract'
10951
+ 'consumers should verify pid liveness and recency before trusting a contract',
10952
+ 'a build-failed or compile-failed frame under --output json lists each diagnostic in error.details as {code?, message, file?, line?, column?, severity, name?}, errors first, capped at twenty with truncated: true when cut'
10327
10953
  ]
10328
10954
  },
10329
10955
  dockerAndContainers: {
@@ -10705,7 +11331,7 @@ Cross-browser compatibility
10705
11331
  const rotated = file.replace(/\.ndjson$/, '.1.ndjson');
10706
11332
  console.error(external_pintor_default().dim(external_pintor_default().gray(`… earlier events of this session were rotated to ${rotated} at ${header.startedAt}`)));
10707
11333
  }
10708
- function writeFrame(frame) {
11334
+ function logs_writeFrame(frame) {
10709
11335
  try {
10710
11336
  external_node_fs_default().writeSync(1, `${JSON.stringify(frame)}\n`);
10711
11337
  } catch {
@@ -10723,7 +11349,7 @@ Cross-browser compatibility
10723
11349
  const tab = parsePositiveInt('--tab', options.tab);
10724
11350
  if (!tab.ok) {
10725
11351
  console.error(tab.message);
10726
- if ('pretty' !== format) writeFrame(messaging.Pr.fail('logs', 'usage', {
11352
+ if ('pretty' !== format) logs_writeFrame(messaging.Pr.fail('logs', 'usage', {
10727
11353
  code: messaging.Lp.E_FLAG_VALUE_INVALID,
10728
11354
  message: tab.message,
10729
11355
  name: 'CliError'
@@ -10738,7 +11364,7 @@ Cross-browser compatibility
10738
11364
  const emulatorRefusal = (0, emulator_session.MC)(bridge, projectPath, browser, 'logs');
10739
11365
  if (emulatorRefusal) {
10740
11366
  console.error(emulatorRefusal);
10741
- if ('pretty' !== format) writeFrame(messaging.Pr.fail('logs', 'failed', {
11367
+ if ('pretty' !== format) logs_writeFrame(messaging.Pr.fail('logs', 'failed', {
10742
11368
  code: messaging.Lp.E_COMMAND_UNSUPPORTED_FOR_TARGET,
10743
11369
  message: emulatorRefusal,
10744
11370
  name: 'CliError'
@@ -10752,7 +11378,7 @@ Cross-browser compatibility
10752
11378
  if (!external_node_fs_default().existsSync(file)) {
10753
11379
  const message = `No logs found at ${file}. Start a dev session (extension dev) first, or pass --browser to match it.`;
10754
11380
  console.error(message);
10755
- if ('pretty' !== format) writeFrame(messaging.Pr.fail('logs', 'not-found', {
11381
+ if ('pretty' !== format) logs_writeFrame(messaging.Pr.fail('logs', 'not-found', {
10756
11382
  code: messaging.Lp.E_LOGS_NOT_FOUND,
10757
11383
  message,
10758
11384
  name: 'CliError'
@@ -10779,7 +11405,7 @@ Cross-browser compatibility
10779
11405
  }
10780
11406
  function refuseUsage(format, message) {
10781
11407
  console.error(message);
10782
- if ('pretty' !== format) writeFrame(messaging.Pr.fail('logs', 'usage', {
11408
+ if ('pretty' !== format) logs_writeFrame(messaging.Pr.fail('logs', 'usage', {
10783
11409
  code: messaging.Lp.E_INVALID_OPTION,
10784
11410
  message,
10785
11411
  name: 'CliError'
@@ -10793,7 +11419,7 @@ Cross-browser compatibility
10793
11419
  if (!ready) {
10794
11420
  const message = `No active dev session control channel found for ${browser}. Looked at ${sessionReadyPath(bridge, projectPath, browser)}. Run \`extension dev --browser=${browser}\` first.`;
10795
11421
  console.error(message);
10796
- if ('pretty' !== format) writeFrame(messaging.Pr.fail('logs', 'not-found', {
11422
+ if ('pretty' !== format) logs_writeFrame(messaging.Pr.fail('logs', 'not-found', {
10797
11423
  code: messaging.Lp.E_SESSION_NOT_FOUND,
10798
11424
  message,
10799
11425
  name: 'CliError'
@@ -10907,6 +11533,14 @@ Cross-browser compatibility
10907
11533
  };
10908
11534
  const CSP_BLOCKED_EVAL = /\bcall to eval\(\)|\bblocked by (?:the )?csp\b|\bextension csp\b|content security policy|content_security_policy|unsafe-eval/i;
10909
11535
  const CSP_BLOCKS_EVAL_HINT = "The extension's own content_security_policy forbids eval in this document, so no expression runs there, 1 + 1 included. Read the document with extension inspect --context <context>, or evaluate in a web page with extension eval --context page --tab <id>.";
11536
+ const CSP_BLOCKS_EVAL_HINT_PAGE = "The page's own Content-Security-Policy forbids eval, so the in-page executor runs no expression in this tab. The extension's policy is not involved. Read the page with extension inspect --context page --tab <id>.";
11537
+ const CSP_BLOCKS_EVAL_HINT_PAGE_GECKO = " Firefox evaluates such a page through its debugger instead when exactly one open tab is on that url, so close the duplicate tab and run it again.";
11538
+ const CSP_BLOCKS_EVAL_HINT_CONTENT = "The extension's own content_security_policy forbids eval in the content-script world of every tab, 1 + 1 included. Evaluate in the page's own world with extension eval --context page --tab <id>, or read the DOM with extension inspect --context content --tab <id>.";
11539
+ function cspBlocksEvalHint(context, browser) {
11540
+ if ('content' === context) return CSP_BLOCKS_EVAL_HINT_CONTENT;
11541
+ if ('page' !== context) return CSP_BLOCKS_EVAL_HINT;
11542
+ return (0, browser_family.M_)(browser) ? CSP_BLOCKS_EVAL_HINT_PAGE + CSP_BLOCKS_EVAL_HINT_PAGE_GECKO : CSP_BLOCKS_EVAL_HINT_PAGE;
11543
+ }
10910
11544
  const URL_REFUSED_HINT_GECKO = "Firefox refuses privileged pages (about:newtab, about:config, about:addons, and chrome:, file:, data: and javascript: urls) from an extension's tabs API. Only web urls and about:blank open this way. Open the extension's own pages by their moz-extension:// url instead.";
10911
11545
  const URL_REFUSED_HINT_CHROMIUM = "Chromium refuses javascript: urls from an extension's tabs API. To run code in a page, use extension eval --context content --tab <id> on a session started with --allow-eval.";
10912
11546
  const URL_REFUSED_HINT_GENERIC = "The browser refuses this url from an extension's tabs API. Web urls and about:blank open on every engine.";
@@ -10917,7 +11551,11 @@ Cross-browser compatibility
10917
11551
  }
10918
11552
  const TAB_NOT_FOUND_HINT = "List the open tabs and their ids with extension inspect --list-tabs, or drop --tab to target the active tab.";
10919
11553
  const GECKO_IDLE_EVENT_PAGE_HINT = "Firefox suspends an MV3 event page when it goes idle, and a suspended page has nothing to evaluate in. Wake the extension first, by opening one of its surfaces or triggering one of its listeners, then evaluate again.";
10920
- function codeForBridgeError(name, message, refusal) {
11554
+ const BRIDGE_FAULT_NAMES = new Set([
11555
+ 'ExecutorError',
11556
+ 'TabsError'
11557
+ ]);
11558
+ function codeForBridgeError(name, message, refusal, command) {
10921
11559
  if (refusal && refusal in REFUSAL_TO_CODE) return REFUSAL_TO_CODE[refusal];
10922
11560
  if ('Timeout' === name) return messaging.Lp.E_TIMEOUT;
10923
11561
  if ('Unavailable' === name) return messaging.Lp.E_CONTROL_UNAVAILABLE;
@@ -10930,6 +11568,7 @@ Cross-browser compatibility
10930
11568
  if ('EvalError' === name) return messaging.Lp.E_EVAL;
10931
11569
  if ('InspectError' === name) return messaging.Lp.E_INSPECT;
10932
11570
  if ('StorageError' === name) return messaging.Lp.E_STORAGE;
11571
+ if ('eval' === command && !BRIDGE_FAULT_NAMES.has(name)) return messaging.Lp.E_EVAL;
10933
11572
  return messaging.Lp.E_INTERNAL;
10934
11573
  }
10935
11574
  function statusForCode(code) {
@@ -10940,7 +11579,7 @@ Cross-browser compatibility
10940
11579
  return 'failed';
10941
11580
  }
10942
11581
  function buildActEnvelope(command, result) {
10943
- const { ok, value, truncated, error, ...extras } = result;
11582
+ const { ok, value, truncated, error, type, cmdId, ...extras } = result;
10944
11583
  const wasTruncated = true === truncated;
10945
11584
  if (ok) return {
10946
11585
  ...extras,
@@ -10952,7 +11591,7 @@ Cross-browser compatibility
10952
11591
  const name = 'string' == typeof raw.name ? raw.name : 'Error';
10953
11592
  const message = 'string' == typeof raw.message ? raw.message : 'command failed';
10954
11593
  const refusal = 'string' == typeof raw.code ? raw.code : void 0;
10955
- const code = codeForBridgeError(name, message, refusal);
11594
+ const code = codeForBridgeError(name, message, refusal, 'string' == typeof raw.name ? command : void 0);
10956
11595
  const hint = 'string' == typeof raw.hint ? raw.hint : 'url_refused' === refusal ? urlRefusedHint(raw.engine) : 'tab_not_found' === refusal ? TAB_NOT_FOUND_HINT : code === messaging.Lp.E_CSP_BLOCKS_EVAL ? CSP_BLOCKS_EVAL_HINT : code === messaging.Lp.E_EVAL ? 'The expression threw inside the page. Check the expression itself.' : code === messaging.Lp.E_USER_GESTURE_REQUIRED ? "The browser opens this surface only in response to a click, and refuses to open it any other way. Click the extension in the browser toolbar to open it." : void 0;
10957
11596
  return {
10958
11597
  ...extras,
@@ -11110,6 +11749,35 @@ Cross-browser compatibility
11110
11749
  timeoutMs
11111
11750
  });
11112
11751
  }
11752
+ function pickTargetTabUrl(tabs, target) {
11753
+ const withUrl = tabs.filter((tab)=>'string' == typeof tab.url && tab.url.length > 0);
11754
+ if ('number' == typeof target.tabId) return withUrl.find((tab)=>tab.id === target.tabId)?.url;
11755
+ if (target.url) {
11756
+ const wanted = target.url;
11757
+ return (withUrl.find((tab)=>tab.url === wanted) ?? withUrl.find((tab)=>tab.url.includes(wanted)))?.url;
11758
+ }
11759
+ const active = withUrl.filter((tab)=>true === tab.active);
11760
+ return 1 === active.length ? active[0].url : void 0;
11761
+ }
11762
+ async function geckoProtocolPageEval(bridge, projectPath, browser, listTabs, target, expression, timeoutMs) {
11763
+ const ready = bridge.readReadyContractDocument(projectPath, browser);
11764
+ const rdpPort = 'number' == typeof ready?.rdpPort ? ready.rdpPort : 0;
11765
+ if (!rdpPort) return;
11766
+ let tabs;
11767
+ try {
11768
+ tabs = await listTabs();
11769
+ } catch {
11770
+ return;
11771
+ }
11772
+ const url = pickTargetTabUrl(tabs?.ok && Array.isArray(tabs.value) ? tabs.value : [], target);
11773
+ if (!url) return;
11774
+ return await evaluateTabDocument({
11775
+ rdpPort,
11776
+ url,
11777
+ expression,
11778
+ timeoutMs
11779
+ });
11780
+ }
11113
11781
  async function runCommand(input) {
11114
11782
  const bridge = await loadExtensionDevelopBridgeModule();
11115
11783
  const projectPath = resolveSessionProjectPath(bridge, input.projectPathArg);
@@ -11176,16 +11844,33 @@ Cross-browser compatibility
11176
11844
  ...outputFrame,
11177
11845
  code: /timed out/i.test(message) ? messaging.Lp.E_TIMEOUT : messaging.Lp.E_CONTROL_UNAVAILABLE
11178
11846
  });
11847
+ }
11848
+ const geckoEvalFailed = 'eval' === input.op && result?.ok !== true && (0, browser_family.M_)(browser);
11849
+ try {
11850
+ if (geckoEvalFailed && isExtensionDocumentContext(input.target.context) && (bridgeBlamedTheExtensionCsp(result) || bridgeHadNoExecutor(result))) {
11851
+ const overProtocol = await geckoProtocolEval(bridge, projectPath, browser, input.target.context, String(input.args?.expression ?? ''), timeoutMs);
11852
+ if (overProtocol) result = overProtocol;
11853
+ else if (bridgeHadNoExecutor(result)) {
11854
+ const raw = result?.error || {};
11855
+ if ('string' != typeof raw.hint) raw.hint = GECKO_IDLE_EVENT_PAGE_HINT;
11856
+ }
11857
+ } else if (geckoEvalFailed && 'page' === input.target.context && bridgeBlamedTheExtensionCsp(result)) {
11858
+ const overProtocol = await geckoProtocolPageEval(bridge, projectPath, browser, ()=>controller.command({
11859
+ op: 'tabs.query',
11860
+ target: {
11861
+ context: 'background'
11862
+ },
11863
+ args: {},
11864
+ timeoutMs
11865
+ }), input.target, String(input.args?.expression ?? ''), timeoutMs);
11866
+ if (overProtocol) result = overProtocol;
11867
+ }
11179
11868
  } finally{
11180
11869
  controller.close();
11181
11870
  }
11182
- if ('eval' === input.op && result?.ok !== true && (0, browser_family.M_)(browser) && isExtensionDocumentContext(input.target.context) && (bridgeBlamedTheExtensionCsp(result) || bridgeHadNoExecutor(result))) {
11183
- const overProtocol = await geckoProtocolEval(bridge, projectPath, browser, input.target.context, String(input.args?.expression ?? ''), timeoutMs);
11184
- if (overProtocol) result = overProtocol;
11185
- else if (bridgeHadNoExecutor(result)) {
11186
- const raw = result?.error || {};
11187
- if ('string' != typeof raw.hint) raw.hint = GECKO_IDLE_EVENT_PAGE_HINT;
11188
- }
11871
+ if ('eval' === input.op && bridgeBlamedTheExtensionCsp(result)) {
11872
+ const raw = result?.error || {};
11873
+ if ('string' != typeof raw.hint) raw.hint = cspBlocksEvalHint(input.target.context, browser);
11189
11874
  }
11190
11875
  if (result?.ok && input.augment) try {
11191
11876
  Object.assign(result, input.augment(projectPath, browser, result));
@@ -11458,7 +12143,7 @@ Cross-browser compatibility
11458
12143
  function isErrorFramed(err) {
11459
12144
  return Boolean(err && 'object' == typeof err && true === err[FRAMED_FLAG]);
11460
12145
  }
11461
- function wantsJsonOutput(argv) {
12146
+ function cli_failure_wantsJsonOutput(argv) {
11462
12147
  return 'json' === normalizeOutputFormat(scanArgvValue(argv, '--output'));
11463
12148
  }
11464
12149
  function isCommanderError(err) {
@@ -11535,7 +12220,7 @@ Cross-browser compatibility
11535
12220
  return `${(0, messaging.Pl)('error')} ${label}\n${remedy}`;
11536
12221
  }
11537
12222
  function isUsageCode(code) {
11538
- return code === messaging.Lp.E_BROWSER_BINARY_INVALID;
12223
+ return code === messaging.Lp.E_BROWSER_BINARY_INVALID || code === messaging.Lp.E_BROWSER_BINARY_REQUIRED || code === messaging.Lp.E_FLAG_NOT_SUPPORTED_HERE;
11539
12224
  }
11540
12225
  function declaredErrorCode(err) {
11541
12226
  const code = err?.code;
@@ -11797,11 +12482,16 @@ Cross-browser compatibility
11797
12482
  if (summary) summaries.push(summary);
11798
12483
  } catch (error) {
11799
12484
  if (!asJson) throw error;
12485
+ const { diagnostics, truncated } = error ?? {};
11800
12486
  console.log(JSON.stringify(messaging.Pr.fail('build', 'build-failed', {
11801
12487
  code: declaredErrorCode(error) ?? messaging.Lp.E_COMPILE,
11802
- message: error instanceof Error ? error.message : String(error)
12488
+ message: error instanceof Error ? error.message : String(error),
12489
+ ...Array.isArray(diagnostics) && diagnostics.length > 0 ? {
12490
+ details: diagnostics
12491
+ } : {}
11803
12492
  }, {
11804
- hint: "Fix the error above and run build again."
12493
+ hint: "Fix the error above and run build again.",
12494
+ truncated: true === truncated
11805
12495
  })));
11806
12496
  process.exit(1);
11807
12497
  }
@@ -11810,9 +12500,23 @@ Cross-browser compatibility
11810
12500
  browsers: built,
11811
12501
  mode: mode ?? 'production',
11812
12502
  summaries
12503
+ }, {
12504
+ warnings: codedWarningsOf(summaries)
11813
12505
  })));
11814
12506
  });
11815
12507
  }
12508
+ function codedWarningsOf(summaries) {
12509
+ const coded = [];
12510
+ for (const summary of summaries){
12511
+ const warnings = summary?.warnings;
12512
+ if (Array.isArray(warnings)) for (const line of warnings){
12513
+ if ('string' != typeof line) continue;
12514
+ const code = line.slice(0, line.indexOf(': '));
12515
+ if (Object.prototype.hasOwnProperty.call(messaging.Lp, code) && !coded.includes(line)) coded.push(line);
12516
+ }
12517
+ }
12518
+ return coded;
12519
+ }
11816
12520
  const READY_CONTRACT_SCHEMA_VERSION = 2;
11817
12521
  const RECORD_STREAM_COMMANDS = new Set([
11818
12522
  'logs'
@@ -12061,6 +12765,11 @@ Cross-browser compatibility
12061
12765
  if ('string' != typeof code) return;
12062
12766
  return READY_CONTRACT_CODES[code.trim().toLowerCase()];
12063
12767
  }
12768
+ function stampedLaunchFailureCode(ready) {
12769
+ if ('browser_launch_failed' !== ready.code) return;
12770
+ const code = ready.browserLaunchFailedCode;
12771
+ return 'string' == typeof code && Object.prototype.hasOwnProperty.call(messaging.Lp, code) ? code : void 0;
12772
+ }
12064
12773
  function dev_wait_define_property(obj, key, value) {
12065
12774
  if (key in obj) Object.defineProperty(obj, key, {
12066
12775
  value: value,
@@ -12111,7 +12820,7 @@ Cross-browser compatibility
12111
12820
  const message = error instanceof Error ? error.message : String(error);
12112
12821
  const tagged = error?.code;
12113
12822
  const code = 'string' == typeof tagged && tagged in messaging.Lp ? tagged : messaging.Lp.E_INTERNAL;
12114
- if (code === messaging.Lp.E_ARGS) return {
12823
+ if (code === messaging.Lp.E_ARGS || code === messaging.Lp.E_REMOTE_URL_UNSUPPORTED) return {
12115
12824
  code,
12116
12825
  status: 'usage',
12117
12826
  message,
@@ -12123,6 +12832,24 @@ Cross-browser compatibility
12123
12832
  message,
12124
12833
  hint: 'Pass a browser binary path that exists and runs.'
12125
12834
  };
12835
+ if (code === messaging.Lp.E_BROWSER_BINARY_REQUIRED) return {
12836
+ code,
12837
+ status: 'usage',
12838
+ message,
12839
+ hint: 'Pass --chromium-binary or --gecko-binary with the browser to run.'
12840
+ };
12841
+ if (code === messaging.Lp.E_BROWSER_NOT_FOUND) return {
12842
+ code,
12843
+ status: 'failed',
12844
+ message,
12845
+ hint: 'Install the browser, or pass its binary path to the command.'
12846
+ };
12847
+ if (code === messaging.Lp.E_FLAG_NOT_SUPPORTED_HERE) return {
12848
+ code,
12849
+ status: 'usage',
12850
+ message,
12851
+ hint: 'Let Extension.js manage the profile, or pass --profile=<path>.'
12852
+ };
12126
12853
  if (code === messaging.Lp.E_READY_TIMEOUT) return {
12127
12854
  code,
12128
12855
  status: 'timeout',
@@ -12199,8 +12926,7 @@ Cross-browser compatibility
12199
12926
  continue;
12200
12927
  }
12201
12928
  const detail = payload.message || payload.errors?.[0] || 'unknown error';
12202
- const badPin = 'browser_launch_failed' === payload.code && payload.browserLaunchFailedCode === messaging.Lp.E_BROWSER_BINARY_INVALID;
12203
- throw new WaitModeError(String(detail), badPin ? messaging.Lp.E_BROWSER_BINARY_INVALID : readyContractErrorCode(payload.code) ?? messaging.Lp.E_READY_ERROR_STATUS);
12929
+ throw new WaitModeError(String(detail), stampedLaunchFailureCode(payload) ?? readyContractErrorCode(payload.code) ?? messaging.Lp.E_READY_ERROR_STATUS);
12204
12930
  }
12205
12931
  }
12206
12932
  }
@@ -12210,7 +12936,7 @@ Cross-browser compatibility
12210
12936
  throw new WaitModeError(`Timed out waiting for ready contract at ${readyPath} (${options.timeoutMs} ms)${timeoutDetail}`, messaging.Lp.E_READY_TIMEOUT);
12211
12937
  }
12212
12938
  async function runWaitMode(options) {
12213
- if (isHttpUrl(options.pathOrRemoteUrl)) throw new WaitModeError('--wait requires a local project path (remote URLs are not supported)', messaging.Lp.E_ARGS);
12939
+ if (isHttpUrl(options.pathOrRemoteUrl)) throw new WaitModeError('--wait requires a local project path (remote URLs are not supported)', messaging.Lp.E_REMOTE_URL_UNSUPPORTED);
12214
12940
  const { projectPath, bridge } = await resolveProjectPath(options.pathOrRemoteUrl);
12215
12941
  const timeoutMs = parseWaitTimeoutMs(options.waitTimeout);
12216
12942
  const format = parseWaitFormat(options.waitFormat);
@@ -12978,7 +13704,7 @@ Cross-browser compatibility
12978
13704
  } catch (err) {
12979
13705
  const message = String(err?.message || err);
12980
13706
  if (asJson) console.log(JSON.stringify(messaging.Pr.fail('doctor', 'failed', {
12981
- code: messaging.Lp.E_INTERNAL,
13707
+ code: declaredErrorCode(err) ?? messaging.Lp.E_INTERNAL,
12982
13708
  message
12983
13709
  })));
12984
13710
  else console.error(message);
@@ -13003,6 +13729,7 @@ Cross-browser compatibility
13003
13729
  });
13004
13730
  }
13005
13731
  var output_binaries_resolver = __webpack_require__("./browsers/browsers-lib/output-binaries-resolver.ts");
13732
+ const DEFAULT_INSTALL_TARGET = 'chromium';
13006
13733
  function install_emit(frame) {
13007
13734
  console.log(JSON.stringify(frame));
13008
13735
  }
@@ -13070,10 +13797,10 @@ Cross-browser compatibility
13070
13797
  await exitAfterDrain(1);
13071
13798
  }
13072
13799
  function registerInstallCommand(program) {
13073
- program.command('install').arguments('[browser-name]').usage('[browser-name] [options]').description(commandDescriptions.install).option(`--browser <${vendors.b_}>`, '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)=>{
13800
+ program.command('install').argument('[browser-name]', `managed browser to install (default: ${DEFAULT_INSTALL_TARGET})`).usage('[browser-name] [options]').description(commandDescriptions.install).option(`--browser <${vendors.b_}>`, '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)=>{
13074
13801
  const asJson = isJsonOutput(options);
13075
13802
  const named = Boolean(options.browser || browserArg);
13076
- const selectedBrowser = options.browser || browserArg || 'chromium';
13803
+ const selectedBrowser = options.browser || browserArg || DEFAULT_INSTALL_TARGET;
13077
13804
  const browserList = (0, vendors.OB)(selectedBrowser);
13078
13805
  if (!(options.where && !named)) {
13079
13806
  if (await refuseIfNotManagedTarget('install', browserList, asJson)) return;
@@ -13100,6 +13827,7 @@ Cross-browser compatibility
13100
13827
  for (const browser of browserList)try {
13101
13828
  await extensionInstall({
13102
13829
  browser,
13830
+ defaulted: !named,
13103
13831
  locateInstalledBinary: output_binaries_resolver.AG
13104
13832
  });
13105
13833
  installed.push(browser);
@@ -13192,8 +13920,14 @@ Cross-browser compatibility
13192
13920
  var run_only = __webpack_require__("./browsers/run-only.ts");
13193
13921
  const PREVIEW_FAILED_CODES = new Set([
13194
13922
  messaging.Lp.E_BROWSER_LAUNCH,
13923
+ messaging.Lp.E_BROWSER_NOT_FOUND,
13924
+ messaging.Lp.E_BROWSER_START_TIMEOUT,
13195
13925
  messaging.Lp.E_BROWSER_CONNECT,
13926
+ messaging.Lp.E_BROWSER_CONNECTION_CLOSED,
13927
+ messaging.Lp.E_RDP_PROTOCOL,
13928
+ messaging.Lp.E_ADDON_INSTALL,
13196
13929
  messaging.Lp.E_CONFIG_LOAD,
13930
+ messaging.Lp.E_RUNTIME_NOT_FOUND,
13197
13931
  messaging.Lp.E_REMOTE_DOWNLOAD,
13198
13932
  messaging.Lp.E_REMOTE_ZIP_INVALID,
13199
13933
  messaging.Lp.E_REMOTE_FETCH_TIMEOUT
@@ -13658,6 +14392,7 @@ Cross-browser compatibility
13658
14392
  }
13659
14393
  markCommandSessionStart('start');
13660
14394
  const { extensionBuild } = await loadExtensionDevelopModule();
14395
+ const noBrowser = await resolveNoBrowser(pathOrRemoteUrl || process.cwd(), 'start');
13661
14396
  for (const vendor of list){
13662
14397
  const logsOption = startOptions.logs;
13663
14398
  const logContextOption = startOptions.logContext;
@@ -13668,6 +14403,7 @@ Cross-browser compatibility
13668
14403
  browser: vendor,
13669
14404
  exitOnError: !asJson,
13670
14405
  metadataCommand: 'start',
14406
+ launchFollows: !noBrowser,
13671
14407
  polyfill: explicitCliValue(command, 'polyfill', explicitOptionalBoolean(startOptions.polyfill)),
13672
14408
  install: startOptions.install,
13673
14409
  extensions: parseExtensionsList(startOptions.extensions),
@@ -13683,7 +14419,6 @@ Cross-browser compatibility
13683
14419
  }));
13684
14420
  process.exit(1);
13685
14421
  }
13686
- const noBrowser = await resolveNoBrowser(pathOrRemoteUrl || process.cwd(), 'start');
13687
14422
  if (noBrowser) continue;
13688
14423
  const { extensionPreview } = await loadExtensionDevelopPreviewModule();
13689
14424
  await extensionPreview(pathOrRemoteUrl, {
@@ -13717,7 +14452,7 @@ Cross-browser compatibility
13717
14452
  browsers: list,
13718
14453
  port: null,
13719
14454
  pid: process.pid,
13720
- noBrowser: await resolveNoBrowser(pathOrRemoteUrl || process.cwd(), 'start')
14455
+ noBrowser
13721
14456
  }));
13722
14457
  });
13723
14458
  }
@@ -13871,7 +14606,7 @@ Cross-browser compatibility
13871
14606
  }
13872
14607
  function failBeforeParse(argv, humanMessage, code, plainMessage, flag) {
13873
14608
  console.error(humanMessage);
13874
- if (wantsJsonOutput(argv)) writeStdoutFrame(earlyExitEnvelope(index_resolveCommandFromArgv(argv) || 'extension', code, plainMessage, {
14609
+ if (cli_failure_wantsJsonOutput(argv)) writeStdoutFrame(earlyExitEnvelope(index_resolveCommandFromArgv(argv) || 'extension', code, plainMessage, {
13875
14610
  flag
13876
14611
  }));
13877
14612
  process.exit(1);
@@ -13948,7 +14683,7 @@ Cross-browser compatibility
13948
14683
  if (process.argv.includes('--ai-help')) runAIHelp();
13949
14684
  else {
13950
14685
  const argv = applyNoBrowserArgvShim(applyOutputAliasArgvShim(process.argv));
13951
- const asJson = wantsJsonOutput(argv);
14686
+ const asJson = cli_failure_wantsJsonOutput(argv);
13952
14687
  const commandName = index_resolveCommandFromArgv(argv) || 'extension';
13953
14688
  (async ()=>{
13954
14689
  try {
@@ -13999,6 +14734,9 @@ Cross-browser compatibility
13999
14734
  "node:fs" (module) {
14000
14735
  module.exports = require("node:fs");
14001
14736
  },
14737
+ "node:http" (module) {
14738
+ module.exports = require("node:http");
14739
+ },
14002
14740
  "node:module" (module) {
14003
14741
  module.exports = require("node:module");
14004
14742
  },