extension 4.1.31 → 4.1.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/597.cjs +27 -15
  2. package/dist/browsers.cjs +692 -183
  3. package/dist/cli.cjs +1075 -263
  4. package/dist/extension/__spec__/exec/gecko-system-profile.d.ts +3 -0
  5. package/dist/extension/browsers/__spec__/safari-fake-tools.d.ts +11 -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/container-app.d.ts +3 -0
  22. package/dist/extension/browsers/run-safari/safari-launch/index.d.ts +3 -1
  23. package/dist/extension/browsers/run-safari/safari-launch/tools.d.ts +14 -0
  24. package/dist/extension/browsers/run-safari/safari-launch/webdriver.d.ts +15 -0
  25. package/dist/extension/commands/act.d.ts +10 -0
  26. package/dist/extension/config-types.d.ts +15 -3
  27. package/dist/extension/helpers/messaging.d.ts +12 -4
  28. package/dist/extension/helpers/node-version-guard.d.ts +2 -1
  29. package/dist/extension/helpers/ready-contract-codes.d.ts +4 -0
  30. package/dist/extension/helpers/telemetry-cli.d.ts +1 -0
  31. package/dist/extension/helpers/template-catalog.d.ts +1 -1
  32. package/dist/extension/helpers/template-corpus.generated.d.ts +1 -1
  33. package/dist/extension/index.d.ts +1 -1
  34. 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 ▸ Settings ▸ Developer ▸ Allow remote automation (Safari ▸ Develop ▸ Allow Remote Automation on older Safari) 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
  }));
@@ -7207,6 +7380,62 @@ var __webpack_modules__ = {
7207
7380
  (0, messaging._w)(messages.Aj(xcodebuildCmd));
7208
7381
  }
7209
7382
  var safari_config = __webpack_require__("./browsers/run-safari/safari-launch/safari-config.ts");
7383
+ const RAISE_WAIT_MS = 5000;
7384
+ const QUIT_MS = 3000;
7385
+ const POLL_MS = 250;
7386
+ const raisedApps = new Set();
7387
+ let handlersInstalled = false;
7388
+ function sleep(ms) {
7389
+ return new Promise((resolve)=>setTimeout(resolve, ms));
7390
+ }
7391
+ function processAlive(pid) {
7392
+ try {
7393
+ process.kill(pid, 0);
7394
+ return true;
7395
+ } catch {
7396
+ return false;
7397
+ }
7398
+ }
7399
+ function terminate(pid) {
7400
+ try {
7401
+ process.kill(pid, 'SIGTERM');
7402
+ } catch {}
7403
+ }
7404
+ function quitAllOnExit() {
7405
+ for (const pid of raisedApps)terminate(pid);
7406
+ }
7407
+ function quitAllOnSignal() {
7408
+ closeSafariContainerApps();
7409
+ }
7410
+ function installHandlersOnce() {
7411
+ if (handlersInstalled) return;
7412
+ handlersInstalled = true;
7413
+ process.on('SIGINT', quitAllOnSignal);
7414
+ process.on('SIGTERM', quitAllOnSignal);
7415
+ process.on('SIGHUP', quitAllOnSignal);
7416
+ process.on('exit', quitAllOnExit);
7417
+ }
7418
+ async function rememberRaisedContainerApp(tools, appPath, before) {
7419
+ const deadline = Date.now() + RAISE_WAIT_MS;
7420
+ let raised = [];
7421
+ while(Date.now() < deadline){
7422
+ raised = (await tools.listAppPids(appPath)).filter((pid)=>!before.has(pid));
7423
+ if (raised.length > 0) break;
7424
+ await sleep(POLL_MS);
7425
+ }
7426
+ for (const pid of raised)raisedApps.add(pid);
7427
+ if (raised.length > 0) installHandlersOnce();
7428
+ return raised;
7429
+ }
7430
+ async function closeSafariContainerApps() {
7431
+ const pids = [
7432
+ ...raisedApps
7433
+ ];
7434
+ raisedApps.clear();
7435
+ for (const pid of pids)terminate(pid);
7436
+ const deadline = Date.now() + QUIT_MS;
7437
+ while(Date.now() < deadline && pids.some(processAlive))await sleep(POLL_MS);
7438
+ }
7210
7439
  var external_node_child_process_ = __webpack_require__("node:child_process");
7211
7440
  function isMacOS() {
7212
7441
  return 'darwin' === process.platform;
@@ -7272,6 +7501,70 @@ var __webpack_modules__ = {
7272
7501
  const tail = lines.slice(-TOOL_TAIL_LINES).join('\n');
7273
7502
  return tail.length > TOOL_TAIL_BYTES ? tail.slice(-TOOL_TAIL_BYTES) : tail;
7274
7503
  }
7504
+ function isAutomationSafariArgs(args) {
7505
+ const tokens = args.trim().split(/\s+/);
7506
+ const exe = tokens[0] || '';
7507
+ const name = exe.slice(exe.lastIndexOf('/') + 1);
7508
+ return 'Safari' === name && tokens.includes('--automation');
7509
+ }
7510
+ function isContainerAppArgs(appPath, args) {
7511
+ return args.trim().startsWith(`${appPath}/Contents/MacOS/`);
7512
+ }
7513
+ function openAppArgs(target) {
7514
+ return [
7515
+ '-g',
7516
+ target
7517
+ ];
7518
+ }
7519
+ function listPidsWhere(matches) {
7520
+ return new Promise((resolve)=>{
7521
+ const child = (0, external_node_child_process_.spawn)('ps', [
7522
+ '-axww',
7523
+ '-o',
7524
+ 'pid=,args='
7525
+ ], {
7526
+ stdio: [
7527
+ 'ignore',
7528
+ 'pipe',
7529
+ 'ignore'
7530
+ ]
7531
+ });
7532
+ let out = '';
7533
+ child.stdout?.on('data', (chunk)=>out += String(chunk));
7534
+ child.on('error', ()=>resolve([]));
7535
+ child.on('close', ()=>{
7536
+ const pids = [];
7537
+ for (const line of out.split('\n')){
7538
+ const row = /^\s*(\d+)\s+(.*)$/.exec(line);
7539
+ if (row && matches(row[2])) pids.push(Number(row[1]));
7540
+ }
7541
+ resolve(pids);
7542
+ });
7543
+ });
7544
+ }
7545
+ function spawnWebDriverProcess(bin, args) {
7546
+ return new Promise((resolve)=>{
7547
+ const child = (0, external_node_child_process_.spawn)(bin, args, {
7548
+ stdio: 'ignore'
7549
+ });
7550
+ const stop = ()=>{
7551
+ try {
7552
+ child.kill('SIGTERM');
7553
+ } catch {}
7554
+ };
7555
+ child.once('error', (error)=>resolve({
7556
+ ok: false,
7557
+ output: String(error),
7558
+ stop
7559
+ }));
7560
+ child.once('spawn', ()=>resolve({
7561
+ ok: true,
7562
+ pid: child.pid,
7563
+ output: '',
7564
+ stop
7565
+ }));
7566
+ });
7567
+ }
7275
7568
  function runTool(bin, args, opts) {
7276
7569
  const streamOutput = (0, messaging._o)() && !opts?.quiet;
7277
7570
  return new Promise((resolve)=>{
@@ -7328,9 +7621,7 @@ var __webpack_modules__ = {
7328
7621
  detectToolchain: ()=>detectSafariToolchain(),
7329
7622
  runConverter: (args)=>runTool('xcrun', args),
7330
7623
  runXcodebuild: (args)=>runTool('xcodebuild', args),
7331
- openApp: (target)=>runTool('open', [
7332
- target
7333
- ]),
7624
+ openApp: (target)=>runTool('open', openAppArgs(target)),
7334
7625
  openSafari: (binary)=>runTool('open', [
7335
7626
  '-a',
7336
7627
  binary
@@ -7343,7 +7634,202 @@ var __webpack_modules__ = {
7343
7634
  quiet: true
7344
7635
  });
7345
7636
  return ok ? output : '';
7637
+ },
7638
+ startWebDriver: (port)=>spawnWebDriverProcess('safaridriver', [
7639
+ '-p',
7640
+ String(port)
7641
+ ]),
7642
+ listAutomationPids: ()=>listPidsWhere(isAutomationSafariArgs),
7643
+ listAppPids: (appPath)=>listPidsWhere((args)=>isContainerAppArgs(appPath, args))
7644
+ };
7645
+ }
7646
+ var external_node_http_ = __webpack_require__("node:http");
7647
+ var external_node_net_ = __webpack_require__("node:net");
7648
+ const DRIVER_READY_MS = 5000;
7649
+ const DRIVER_POLL_MS = 100;
7650
+ const SESSION_CREATE_MS = 30000;
7651
+ const SESSION_CLOSE_MS = 5000;
7652
+ const AUTOMATION_QUIT_MS = 3000;
7653
+ const activeSessions = new Set();
7654
+ const activeDrivers = new Set();
7655
+ let webdriver_handlersInstalled = false;
7656
+ function freePort() {
7657
+ return new Promise((resolve, reject)=>{
7658
+ const server = external_node_net_.createServer();
7659
+ server.unref();
7660
+ server.once('error', reject);
7661
+ server.listen(0, '127.0.0.1', ()=>{
7662
+ const address = server.address();
7663
+ const port = 'object' == typeof address && address ? address.port : 0;
7664
+ server.close(()=>resolve(port));
7665
+ });
7666
+ });
7667
+ }
7668
+ function driverRequest(port, method, pathname, body, timeoutMs) {
7669
+ return new Promise((resolve, reject)=>{
7670
+ const payload = void 0 === body ? '' : JSON.stringify(body);
7671
+ const request = external_node_http_.request({
7672
+ host: '127.0.0.1',
7673
+ port,
7674
+ method,
7675
+ path: pathname,
7676
+ headers: {
7677
+ 'Content-Type': 'application/json',
7678
+ 'Content-Length': Buffer.byteLength(payload)
7679
+ },
7680
+ timeout: timeoutMs
7681
+ }, (response)=>{
7682
+ let text = '';
7683
+ response.setEncoding('utf8');
7684
+ response.on('data', (chunk)=>text += chunk);
7685
+ response.on('end', ()=>{
7686
+ let parsed = {};
7687
+ try {
7688
+ parsed = text ? JSON.parse(text) : {};
7689
+ } catch {
7690
+ parsed = {
7691
+ value: {
7692
+ message: text.trim()
7693
+ }
7694
+ };
7695
+ }
7696
+ resolve({
7697
+ status: response.statusCode || 0,
7698
+ body: parsed
7699
+ });
7700
+ });
7701
+ });
7702
+ request.on('timeout', ()=>request.destroy(new Error('timed out')));
7703
+ request.on('error', reject);
7704
+ request.end(payload);
7705
+ });
7706
+ }
7707
+ async function waitForDriver(port) {
7708
+ const deadline = Date.now() + DRIVER_READY_MS;
7709
+ let lastError = '';
7710
+ while(Date.now() < deadline){
7711
+ try {
7712
+ const reply = await driverRequest(port, 'GET', '/status', void 0, 1000);
7713
+ if (200 === reply.status) return null;
7714
+ lastError = `HTTP ${reply.status}`;
7715
+ } catch (error) {
7716
+ lastError = String(error?.message || error);
7346
7717
  }
7718
+ await new Promise((resolve)=>setTimeout(resolve, DRIVER_POLL_MS));
7719
+ }
7720
+ return `safaridriver did not answer on port ${port} within ${DRIVER_READY_MS}ms (${lastError})`;
7721
+ }
7722
+ function refusalReason(reply) {
7723
+ const value = reply.body?.value;
7724
+ const message = 'string' == typeof value?.message ? value.message.trim() : '';
7725
+ if (message) return message;
7726
+ const error = 'string' == typeof value?.error ? value.error.trim() : '';
7727
+ return error || `safaridriver answered HTTP ${reply.status}`;
7728
+ }
7729
+ function stopAllDriversOnExit() {
7730
+ for (const driver of activeDrivers)driver.stop();
7731
+ }
7732
+ function closeAllOnSignal() {
7733
+ closeSafariWebDriverSessions();
7734
+ }
7735
+ function webdriver_installHandlersOnce() {
7736
+ if (webdriver_handlersInstalled) return;
7737
+ webdriver_handlersInstalled = true;
7738
+ process.on('SIGINT', closeAllOnSignal);
7739
+ process.on('SIGTERM', closeAllOnSignal);
7740
+ process.on('SIGHUP', closeAllOnSignal);
7741
+ process.on('exit', stopAllDriversOnExit);
7742
+ }
7743
+ async function closeSafariWebDriverSessions() {
7744
+ await Promise.all([
7745
+ ...activeSessions
7746
+ ].map((session)=>session.close()));
7747
+ }
7748
+ function webdriver_processAlive(pid) {
7749
+ try {
7750
+ process.kill(pid, 0);
7751
+ return true;
7752
+ } catch {
7753
+ return false;
7754
+ }
7755
+ }
7756
+ async function quitRaisedAutomation(tools, before) {
7757
+ const raised = (await tools.listAutomationPids()).filter((pid)=>!before.has(pid));
7758
+ for (const pid of raised)try {
7759
+ process.kill(pid, 'SIGTERM');
7760
+ } catch {}
7761
+ const deadline = Date.now() + AUTOMATION_QUIT_MS;
7762
+ while(Date.now() < deadline && raised.some(webdriver_processAlive))await new Promise((resolve)=>setTimeout(resolve, DRIVER_POLL_MS));
7763
+ }
7764
+ async function openSafariWebDriverSession(tools) {
7765
+ let port;
7766
+ try {
7767
+ port = await freePort();
7768
+ } catch (error) {
7769
+ return {
7770
+ reason: `no free port for safaridriver: ${String(error)}`
7771
+ };
7772
+ }
7773
+ const before = new Set(await tools.listAutomationPids());
7774
+ const driver = await tools.startWebDriver(port);
7775
+ if (!driver.ok) return {
7776
+ reason: `safaridriver could not start: ${driver.output}`
7777
+ };
7778
+ activeDrivers.add(driver);
7779
+ webdriver_installHandlersOnce();
7780
+ const stopDriver = async ()=>{
7781
+ driver.stop();
7782
+ activeDrivers.delete(driver);
7783
+ await quitRaisedAutomation(tools, before);
7784
+ };
7785
+ const notReady = await waitForDriver(port);
7786
+ if (notReady) {
7787
+ await stopDriver();
7788
+ return {
7789
+ reason: notReady
7790
+ };
7791
+ }
7792
+ let created;
7793
+ try {
7794
+ created = await driverRequest(port, 'POST', '/session', {
7795
+ capabilities: {
7796
+ alwaysMatch: {
7797
+ browserName: 'safari'
7798
+ }
7799
+ }
7800
+ }, SESSION_CREATE_MS);
7801
+ } catch (error) {
7802
+ await stopDriver();
7803
+ return {
7804
+ reason: `the WebDriver session request failed: ${String(error?.message || error)}`
7805
+ };
7806
+ }
7807
+ const sessionId = created.body?.value?.sessionId;
7808
+ if (200 !== created.status || 'string' != typeof sessionId || !sessionId) {
7809
+ await stopDriver();
7810
+ return {
7811
+ reason: refusalReason(created)
7812
+ };
7813
+ }
7814
+ let closing = null;
7815
+ const session = {
7816
+ port,
7817
+ sessionId,
7818
+ close: ()=>{
7819
+ if (closing) return closing;
7820
+ closing = (async ()=>{
7821
+ activeSessions.delete(session);
7822
+ try {
7823
+ await driverRequest(port, 'DELETE', `/session/${sessionId}`, void 0, SESSION_CLOSE_MS);
7824
+ } catch {}
7825
+ await stopDriver();
7826
+ })();
7827
+ return closing;
7828
+ }
7829
+ };
7830
+ activeSessions.add(session);
7831
+ return {
7832
+ session
7347
7833
  };
7348
7834
  }
7349
7835
  function fallbackLogger() {
@@ -7437,6 +7923,24 @@ var __webpack_modules__ = {
7437
7923
  (0, messaging._w)((0, ready_message.G)('development', String(host.browser)));
7438
7924
  } catch {}
7439
7925
  }
7926
+ async function holdWebDriverSession(tools, config, logger) {
7927
+ await closeSafariWebDriverSessions();
7928
+ const runId = (0, ready_stamp.Uf)(config.extensionDir);
7929
+ const outcome = await openSafariWebDriverSession(tools);
7930
+ if (outcome.session) {
7931
+ const { port, sessionId } = outcome.session;
7932
+ (0, ready_stamp.ZC)(config.extensionDir, {
7933
+ port,
7934
+ sessionId
7935
+ }, runId);
7936
+ logger.info?.(messages.Hp(port, sessionId));
7937
+ return;
7938
+ }
7939
+ (0, ready_stamp.ZC)(config.extensionDir, {
7940
+ unavailableReason: outcome.reason
7941
+ }, runId);
7942
+ logger.info?.(messages.lb(outcome.reason));
7943
+ }
7440
7944
  async function runSafariPipeline(compilation, host, logger, mode) {
7441
7945
  const tools = host.tools || createSafariTools();
7442
7946
  const config = (0, safari_config.F7)(compilation, host);
@@ -7507,7 +8011,9 @@ var __webpack_modules__ = {
7507
8011
  }
7508
8012
  const target = external_node_fs_.existsSync(appPath) ? appPath : (0, safari_config.Gi)(config);
7509
8013
  logger.info?.(messages.fw(target));
8014
+ const appsBefore = new Set(await tools.listAppPids(appPath));
7510
8015
  await tools.openApp(target);
8016
+ if (host.announceDevReady) await rememberRaisedContainerApp(tools, appPath, appsBefore);
7511
8017
  if (config.safariBinary) await tools.openSafari(config.safariBinary);
7512
8018
  const raisedBundleId = config.safariBinary ? 'com.apple.Safari' : config.bundleIdentifier;
7513
8019
  const browserPid = await tools.resolvePid(raisedBundleId);
@@ -7521,7 +8027,10 @@ var __webpack_modules__ = {
7521
8027
  logger.info?.(messages.fO(config.appName, isSigned));
7522
8028
  if (await confirmRegisteredWithSafari(tools, config.bundleIdentifier)) logger.info?.(messages.fd(config.appName));
7523
8029
  else logger.info?.(messages.qY(config.appName));
7524
- if (host.announceDevReady) await announceSafariDevSession(host, config, appPath);
8030
+ if (host.announceDevReady) {
8031
+ await holdWebDriverSession(tools, config, logger);
8032
+ await announceSafariDevSession(host, config, appPath);
8033
+ }
7525
8034
  return completePackage(config, logger, mode);
7526
8035
  }
7527
8036
  async function packageSafariExtension(host, outputPath, logger, mode = 'full') {
@@ -7837,8 +8346,27 @@ var __webpack_modules__ = {
7837
8346
  });
7838
8347
  },
7839
8348
  "./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);
8349
+ __webpack_require__.d(__webpack_exports__, {
8350
+ Lp: ()=>CODES,
8351
+ Pr: ()=>ENVELOPE,
8352
+ T_: ()=>artifactNoun,
8353
+ QZ: ()=>browserDisplayName,
8354
+ A6: ()=>browserRowValue,
8355
+ Nr: ()=>card,
8356
+ od: ()=>claimCardKey,
8357
+ Sc: ()=>fmt,
8358
+ Qi: ()=>hasChannelPrefix,
8359
+ Gg: ()=>humanError,
8360
+ _w: ()=>humanLine,
8361
+ mR: ()=>humanWarn,
8362
+ VR: ()=>isCardKeyClaimed,
8363
+ _o: ()=>isDebug,
8364
+ Pl: ()=>prefix,
8365
+ UT: ()=>stripChannelPrefix
8366
+ });
8367
+ const external_node_util_namespaceObject = require("node:util");
8368
+ var external_pintor_ = __webpack_require__("pintor");
8369
+ var external_pintor_default = /*#__PURE__*/ __webpack_require__.n(external_pintor_);
7842
8370
  const GLYPH = '⏵⏵⏵';
7843
8371
  const DEBUG_GLYPH = '···';
7844
8372
  const DEBUG_VALUES = new Set([
@@ -7855,11 +8383,11 @@ var __webpack_modules__ = {
7855
8383
  return DEBUG_VALUES.has(String(raw ?? '').trim().toLowerCase());
7856
8384
  }
7857
8385
  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);
8386
+ if ('error' === type) return external_pintor_default().red(GLYPH);
8387
+ if ('warn' === type) return external_pintor_default().brightYellow(GLYPH);
8388
+ if ('success' === type) return external_pintor_default().green(GLYPH);
8389
+ if ('debug' === type) return external_pintor_default().dim(external_pintor_default().gray(DEBUG_GLYPH));
8390
+ return external_pintor_default().gray(GLYPH);
7863
8391
  }
7864
8392
  const ANSI_PATTERN = /\[[0-9;]*m/g;
7865
8393
  function hasChannelPrefix(text) {
@@ -7876,7 +8404,7 @@ var __webpack_modules__ = {
7876
8404
  return MACHINE_OUTPUT_VALUES.has(String(process.env.EXTENSION_OUTPUT || '').trim().toLowerCase());
7877
8405
  }
7878
8406
  function humanLine(...parts) {
7879
- if (isMachineOutput()) return;
8407
+ if (isMachineOutput()) return void process.stderr.write(`${(0, external_node_util_namespaceObject.format)(...parts)}\n`);
7880
8408
  console.log(...parts);
7881
8409
  }
7882
8410
  function humanWarn(...parts) {
@@ -7887,10 +8415,10 @@ var __webpack_modules__ = {
7887
8415
  console.error(...parts);
7888
8416
  }
7889
8417
  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),
8418
+ heading: (title)=>external_pintor_default().underline(external_pintor_default().blue(title)),
8419
+ label: (key)=>external_pintor_default().gray(key.toUpperCase()),
8420
+ val: (value)=>external_pintor_default().underline(value),
8421
+ code: (value)=>external_pintor_default().blue(value),
7894
8422
  bullet: (value)=>`- ${value}`,
7895
8423
  block (title, rows) {
7896
8424
  const head = fmt.heading(title);
@@ -7914,10 +8442,10 @@ var __webpack_modules__ = {
7914
8442
  function card(input = {}) {
7915
8443
  const version = String(input.version || '').trim();
7916
8444
  const suffix = String(input.suffix || '').trim();
7917
- const head = ` 🧩 Extension.js` + (version ? ` ${pintor__rspack_import_0_default().gray(version)}` : '') + (suffix ? ` ${suffix}` : '');
8445
+ const head = ` 🧩 Extension.js` + (version ? ` ${external_pintor_default().gray(version)}` : '') + (suffix ? ` ${suffix}` : '');
7918
8446
  const body = (input.rows || []).filter((row)=>String(row.value || '').trim().length > 0).slice(0, MAX_CARD_ROWS).map((row)=>{
7919
8447
  const label = row.label.padEnd(CARD_LABEL_WIDTH);
7920
- return ` ${label}${pintor__rspack_import_0_default().gray(String(row.value).trim())}`;
8448
+ return ` ${label}${external_pintor_default().gray(String(row.value).trim())}`;
7921
8449
  });
7922
8450
  return [
7923
8451
  head,
@@ -8030,7 +8558,6 @@ var __webpack_modules__ = {
8030
8558
  E_CONFIG_LOAD: 'E_CONFIG_LOAD',
8031
8559
  E_MANAGED_DEP_CONFLICT: 'E_MANAGED_DEP_CONFLICT',
8032
8560
  E_TYPES_EMIT: 'E_TYPES_EMIT',
8033
- E_TSCONFIG_MISSING: 'E_TSCONFIG_MISSING',
8034
8561
  E_OPTIONAL_DEP_UNRESOLVED: 'E_OPTIONAL_DEP_UNRESOLVED',
8035
8562
  E_OPTIONAL_DEP_LOAD: 'E_OPTIONAL_DEP_LOAD',
8036
8563
  E_OPTIONAL_DEP_UNKNOWN: 'E_OPTIONAL_DEP_UNKNOWN',
@@ -8046,11 +8573,9 @@ var __webpack_modules__ = {
8046
8573
  E_CSS_PARSE: 'E_CSS_PARSE',
8047
8574
  E_CSS_PREPROCESSOR_MISSING: 'E_CSS_PREPROCESSOR_MISSING',
8048
8575
  E_CSS_DEAD_REF: 'E_CSS_DEAD_REF',
8049
- E_INTEGRATION_INSTALL: 'E_INTEGRATION_INSTALL',
8050
8576
  E_POLYFILL_NOT_FOUND: 'E_POLYFILL_NOT_FOUND',
8051
8577
  E_LOCALES_LAYOUT: 'E_LOCALES_LAYOUT',
8052
8578
  E_WAR_INVALID: 'E_WAR_INVALID',
8053
- E_MATCH_PATTERN_INVALID: 'E_MATCH_PATTERN_INVALID',
8054
8579
  E_BACKGROUND_REQUIRED: 'E_BACKGROUND_REQUIRED',
8055
8580
  E_CONTENT_SCRIPT_SYNTAX: 'E_CONTENT_SCRIPT_SYNTAX',
8056
8581
  E_NO_ENTRYPOINTS: 'E_NO_ENTRYPOINTS',
@@ -8069,7 +8594,6 @@ var __webpack_modules__ = {
8069
8594
  E_BROWSER_START_TIMEOUT: 'E_BROWSER_START_TIMEOUT',
8070
8595
  E_LAUNCH_SKIPPED_COMPILE_ERRORS: 'E_LAUNCH_SKIPPED_COMPILE_ERRORS',
8071
8596
  E_INSTANCE_AMBIGUOUS: 'E_INSTANCE_AMBIGUOUS',
8072
- E_WSL_INTEROP: 'E_WSL_INTEROP',
8073
8597
  E_EXTENSION_LOAD_REFUSED: 'E_EXTENSION_LOAD_REFUSED',
8074
8598
  E_ADDON_INSTALL: 'E_ADDON_INSTALL',
8075
8599
  E_BROWSER_CONNECT: 'E_BROWSER_CONNECT',
@@ -8081,6 +8605,7 @@ var __webpack_modules__ = {
8081
8605
  E_RDP_PROTOCOL: 'E_RDP_PROTOCOL',
8082
8606
  E_PORT_IN_USE: 'E_PORT_IN_USE',
8083
8607
  E_SESSION_STOPPED: 'E_SESSION_STOPPED',
8608
+ E_SESSION_EXISTS: 'E_SESSION_EXISTS',
8084
8609
  E_LOGS_STREAM_GAP: 'E_LOGS_STREAM_GAP',
8085
8610
  E_BROWSER_INSTALL_PRIVILEGE: 'E_BROWSER_INSTALL_PRIVILEGE',
8086
8611
  E_UNINSTALL_NOOP: 'E_UNINSTALL_NOOP'
@@ -8134,25 +8659,6 @@ var __webpack_modules__ = {
8134
8659
  }, extras);
8135
8660
  }
8136
8661
  };
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
8662
  },
8157
8663
  "./helpers/vendors.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
8158
8664
  const EMULATOR_BROWSER_TARGET = 'chromium-emulator';
@@ -8283,6 +8789,8 @@ var __webpack_modules__ = {
8283
8789
  });
8284
8790
  },
8285
8791
  "./index.ts" (__unused_rspack_module, __unused_rspack___webpack_exports__, __webpack_require__) {
8792
+ var external_node_fs_ = __webpack_require__("node:fs");
8793
+ var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_);
8286
8794
  const MIN_NODE_MAJOR = 22;
8287
8795
  const MIN_NODE_MINOR = 12;
8288
8796
  const MIN_DENO_MAJOR = 2;
@@ -8326,7 +8834,42 @@ var __webpack_modules__ = {
8326
8834
  function unsupportedNodeVersionMessage(version) {
8327
8835
  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
8836
  }
8329
- function enforceSupportedNodeVersion(version = process.versions.node, bunVersion = detectBunVersion(), denoVersion = detectDenoVersion()) {
8837
+ function wantsJsonOutput(argv) {
8838
+ const inline = argv.find((arg)=>arg.startsWith('--output='));
8839
+ const index = argv.indexOf('--output');
8840
+ const spaced = index >= 0 ? argv[index + 1] : void 0;
8841
+ const value = inline ? inline.slice(9) : spaced;
8842
+ return 'json' === String(value || '').trim().toLowerCase();
8843
+ }
8844
+ function commandFromArgv(argv) {
8845
+ for(let index = 2; index < argv.length; index += 1)if ('--output' === argv[index]) index += 1;
8846
+ else if (!argv[index].startsWith('-')) return argv[index];
8847
+ return 'extension';
8848
+ }
8849
+ function unsupportedNodeVersionFrame(version, argv) {
8850
+ if (!wantsJsonOutput(argv)) return;
8851
+ return {
8852
+ schema: 1,
8853
+ ok: false,
8854
+ command: commandFromArgv(argv),
8855
+ status: 'usage',
8856
+ value: null,
8857
+ error: {
8858
+ code: 'E_NODE_VERSION',
8859
+ message: unsupportedNodeVersionMessage(version).replace('[Extension.js] ', ''),
8860
+ name: 'CliError'
8861
+ },
8862
+ warnings: []
8863
+ };
8864
+ }
8865
+ function writeFrame(frame) {
8866
+ try {
8867
+ external_node_fs_default().writeSync(1, `${JSON.stringify(frame)}\n`);
8868
+ } catch {
8869
+ console.log(JSON.stringify(frame));
8870
+ }
8871
+ }
8872
+ function enforceSupportedNodeVersion(version = process.versions.node, bunVersion = detectBunVersion(), denoVersion = detectDenoVersion(), argv = process.argv) {
8330
8873
  if (denoVersion) {
8331
8874
  if (isSupportedDenoVersion(denoVersion)) return;
8332
8875
  console.error(unsupportedDenoVersionMessage(denoVersion));
@@ -8341,20 +8884,23 @@ var __webpack_modules__ = {
8341
8884
  }
8342
8885
  if (isSupportedNodeVersion(version)) return;
8343
8886
  console.error(unsupportedNodeVersionMessage(version));
8887
+ const frame = unsupportedNodeVersionFrame(version, argv);
8888
+ if (frame) writeFrame(frame);
8344
8889
  process.exit(1);
8345
8890
  }
8346
8891
  enforceSupportedNodeVersion();
8347
8892
  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
8893
  var external_node_path_ = __webpack_require__("node:path");
8351
8894
  var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_);
8352
8895
  var browser_family = __webpack_require__("./browsers/browsers-lib/browser-family.ts");
8896
+ var evaluate = __webpack_require__("./browsers/run-firefox/rdp/remote-firefox/evaluate.ts");
8353
8897
  var messaging_client = __webpack_require__("./browsers/run-firefox/rdp/remote-firefox/messaging-client.ts");
8354
8898
  const RESULT_SLOT = '__extjsRdpEval';
8355
8899
  const FRAME_POLL_INTERVAL_MS = 100;
8356
8900
  const RESULT_POLL_INTERVAL_MS = 50;
8357
8901
  const FRAME_WAIT_MS = 2000;
8902
+ const MAX_RESULT_BYTES = 262144;
8903
+ const TRUNCATED_PREVIEW_CHARS = 1024;
8358
8904
  const EXTENSION_DOCUMENT_CONTEXTS = [
8359
8905
  'background',
8360
8906
  'popup',
@@ -8405,17 +8951,27 @@ var __webpack_modules__ = {
8405
8951
  globalThis.${RESULT_SLOT} = slot;
8406
8952
  function settle(next) { if (globalThis.${RESULT_SLOT} === slot) globalThis.${RESULT_SLOT} = next; }
8407
8953
  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))}; }
8954
+ var json;
8955
+ try { json = JSON.stringify(value); }
8956
+ catch (error) { json = JSON.stringify(String(value)); }
8957
+ if (json === undefined) return {state: "value"};
8958
+ if (json.length > ${MAX_RESULT_BYTES}) {
8959
+ return {state: "value", truncated: true, json: JSON.stringify({__type: "truncated", preview: json.slice(0, ${TRUNCATED_PREVIEW_CHARS})})};
8960
+ }
8961
+ return {state: "value", json: json};
8962
+ }
8963
+ function thrown(error) {
8964
+ var message = (error && error.message) || String(error);
8965
+ var name = error && typeof error.name === "string" ? error.name : "";
8966
+ return {state: "throw", message: name && message.indexOf(name + ":") !== 0 ? name + ": " + message : message};
8411
8967
  }
8412
8968
  try {
8413
8969
  Promise.resolve((${expression})).then(
8414
8970
  function (value) { settle(encode(value)); },
8415
- function (error) { settle({state: "throw", message: (error && error.message) || String(error)}); }
8971
+ function (error) { settle(thrown(error)); }
8416
8972
  );
8417
8973
  } catch (error) {
8418
- settle({state: "throw", message: (error && error.message) || String(error)});
8974
+ settle(thrown(error));
8419
8975
  }
8420
8976
  return "started";
8421
8977
  })()`;
@@ -8425,6 +8981,9 @@ var __webpack_modules__ = {
8425
8981
  if (slot && slot.state !== "pending") { try { delete globalThis.${RESULT_SLOT}; } catch (error) {} }
8426
8982
  return JSON.stringify(slot);
8427
8983
  })()`;
8984
+ function statementBlock(source) {
8985
+ return `{\n${source}\n}`;
8986
+ }
8428
8987
  function readSettledSlot(raw) {
8429
8988
  if ('string' != typeof raw) return;
8430
8989
  let slot;
@@ -8448,17 +9007,70 @@ var __webpack_modules__ = {
8448
9007
  ok: true,
8449
9008
  value: void 0
8450
9009
  };
9010
+ let value = slot.json;
8451
9011
  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
- }
9012
+ value = JSON.parse(slot.json);
9013
+ } catch {}
9014
+ return true === slot.truncated ? {
9015
+ ok: true,
9016
+ value,
9017
+ truncated: true
9018
+ } : {
9019
+ ok: true,
9020
+ value
9021
+ };
9022
+ }
9023
+ async function readWholeString(client, value, limit = 1 / 0) {
9024
+ const grip = value;
9025
+ if (!grip || 'object' != typeof grip || 'longString' !== grip.type) return value;
9026
+ const length = 'number' == typeof grip.length ? grip.length : 0;
9027
+ const reply = await client.request({
9028
+ to: String(grip.actor),
9029
+ type: 'substring',
9030
+ start: 0,
9031
+ end: Math.min(length, limit)
9032
+ });
9033
+ if ('string' != typeof reply?.substring) throw new Error(`Firefox holds a ${length}-character result as a long string and did not hand it over`);
9034
+ return reply.substring;
9035
+ }
9036
+ function capped(value) {
9037
+ const json = JSON.stringify(value);
9038
+ if (void 0 !== json && json.length > MAX_RESULT_BYTES) return {
9039
+ ok: true,
9040
+ truncated: true,
9041
+ value: {
9042
+ __type: 'truncated',
9043
+ preview: json.slice(0, TRUNCATED_PREVIEW_CHARS)
9044
+ }
9045
+ };
9046
+ return {
9047
+ ok: true,
9048
+ value
9049
+ };
9050
+ }
9051
+ function readCompletionValue(grip) {
9052
+ if (null === grip || 'object' != typeof grip) return capped(grip);
9053
+ const { type, actor, text } = grip;
9054
+ if ('object' === type && 'string' == typeof actor) return {
9055
+ objectActor: actor
9056
+ };
9057
+ if ('undefined' === type || 'symbol' === type) return {
9058
+ ok: true,
9059
+ value: void 0
9060
+ };
9061
+ if ('BigInt' === type) return {
9062
+ ok: true,
9063
+ value: String(text)
9064
+ };
9065
+ if ('-0' === type) return {
9066
+ ok: true,
9067
+ value: 0
9068
+ };
9069
+ if ('null' === type || 'NaN' === type || 'Infinity' === type || '-Infinity' === type) return {
9070
+ ok: true,
9071
+ value: null
9072
+ };
9073
+ 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
9074
  }
8463
9075
  const sleep = (ms)=>new Promise((resolve)=>{
8464
9076
  const timer = setTimeout(resolve, ms);
@@ -8490,6 +9102,37 @@ var __webpack_modules__ = {
8490
9102
  watcherActor: watcher.actor
8491
9103
  };
8492
9104
  }
9105
+ async function evaluateStatements(client, consoleActor, source) {
9106
+ let completion;
9107
+ try {
9108
+ completion = await client.evaluate(consoleActor, statementBlock(source));
9109
+ } catch (error) {
9110
+ if (!(error instanceof evaluate.K)) throw error;
9111
+ return refuse('EvalError', error.message);
9112
+ }
9113
+ return readCompletionValue(await readWholeString(client, completion, MAX_RESULT_BYTES + 1));
9114
+ }
9115
+ async function evaluateInConsole(options) {
9116
+ const { client, consoleActor, expression, timeoutMs, where } = options;
9117
+ try {
9118
+ await client.evaluate(consoleActor, startExpression(expression));
9119
+ } catch (error) {
9120
+ if (!(error instanceof evaluate.K)) throw error;
9121
+ if (!/^SyntaxError\b/.test(error.message)) return refuse('EvalError', error.message);
9122
+ const completion = await evaluateStatements(client, consoleActor, expression);
9123
+ if ('ok' in completion) return completion;
9124
+ await client.evaluate(consoleActor, startExpression('_self'), {
9125
+ selectedObjectActor: completion.objectActor
9126
+ });
9127
+ }
9128
+ const deadline = Date.now() + timeoutMs;
9129
+ for(;;){
9130
+ const settled = readSettledSlot(await readWholeString(client, await client.evaluate(consoleActor, POLL_EXPRESSION)));
9131
+ if (settled) return settled;
9132
+ if (Date.now() >= deadline) return refuse('Timeout', `the expression did not settle in ${where} within ${timeoutMs}ms`);
9133
+ await sleep(RESULT_POLL_INTERVAL_MS);
9134
+ }
9135
+ }
8493
9136
  async function evaluateThroughWatcher(options) {
8494
9137
  const { client, extensionId, context, pagePath, expression, timeoutMs } = options;
8495
9138
  const located = await locateAddonWatcher(client, extensionId);
@@ -8519,14 +9162,13 @@ var __webpack_modules__ = {
8519
9162
  consoleActor = pickDocumentFrame(frames, context, pagePath);
8520
9163
  }
8521
9164
  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
- }
9165
+ return await evaluateInConsole({
9166
+ client,
9167
+ consoleActor,
9168
+ expression,
9169
+ timeoutMs,
9170
+ where: `the ${context} document`
9171
+ });
8530
9172
  } finally{
8531
9173
  stopListening();
8532
9174
  Promise.resolve(client.request({
@@ -8548,29 +9190,66 @@ var __webpack_modules__ = {
8548
9190
  });
8549
9191
  });
8550
9192
  }
8551
- async function evaluateExtensionDocument(options) {
9193
+ async function withDebugger(rdpPort, timeoutMs, run) {
8552
9194
  const client = new messaging_client.G();
8553
9195
  try {
8554
- const connected = await connectWithin(client, options.rdpPort, options.timeoutMs);
9196
+ const connected = await connectWithin(client, rdpPort, timeoutMs);
8555
9197
  if ('timeout' === connected) {
8556
9198
  client.disconnect();
8557
- return refuse('Timeout', `the Firefox debugger on port ${options.rdpPort} sent no RDP greeting within ${options.timeoutMs}ms`);
9199
+ return refuse('Timeout', `the Firefox debugger on port ${rdpPort} sent no RDP greeting within ${timeoutMs}ms`);
8558
9200
  }
8559
9201
  } catch (error) {
8560
9202
  client.disconnect();
8561
- return refuse('Unavailable', `could not reach the Firefox debugger on port ${options.rdpPort}: ${error?.message || 'connection refused'}`);
9203
+ return refuse('Unavailable', `could not reach the Firefox debugger on port ${rdpPort}: ${error?.message || 'connection refused'}`);
8562
9204
  }
8563
9205
  try {
8564
- return await evaluateThroughWatcher({
8565
- ...options,
8566
- client: client
8567
- });
9206
+ return await run(client);
8568
9207
  } catch (error) {
8569
9208
  return refuse('Unavailable', error?.message || 'the Firefox debugger connection failed mid-evaluation');
8570
9209
  } finally{
8571
9210
  client.disconnect();
8572
9211
  }
8573
9212
  }
9213
+ async function evaluateExtensionDocument(options) {
9214
+ return await withDebugger(options.rdpPort, options.timeoutMs, (client)=>evaluateThroughWatcher({
9215
+ ...options,
9216
+ client
9217
+ }));
9218
+ }
9219
+ function pickTabDescriptor(tabs, url) {
9220
+ const matches = tabs.filter((tab)=>'string' == typeof tab.actor && tab.actor && tab.url === url);
9221
+ return 1 === matches.length ? String(matches[0].actor) : void 0;
9222
+ }
9223
+ async function evaluateThroughTab(options) {
9224
+ const { client, url, expression, timeoutMs } = options;
9225
+ const listed = await client.request({
9226
+ to: 'root',
9227
+ type: 'listTabs'
9228
+ });
9229
+ const descriptor = pickTabDescriptor(listed?.tabs || [], url);
9230
+ if (!descriptor) return;
9231
+ const target = await client.request({
9232
+ to: descriptor,
9233
+ type: 'getTarget'
9234
+ });
9235
+ const consoleActor = target?.frame?.consoleActor;
9236
+ if ('string' != typeof consoleActor || !consoleActor) return;
9237
+ return await evaluateInConsole({
9238
+ client,
9239
+ consoleActor,
9240
+ expression,
9241
+ timeoutMs,
9242
+ where: 'the page'
9243
+ });
9244
+ }
9245
+ async function evaluateTabDocument(options) {
9246
+ const outcome = await withDebugger(options.rdpPort, options.timeoutMs, (client)=>evaluateThroughTab({
9247
+ ...options,
9248
+ client
9249
+ }));
9250
+ if (outcome && !outcome.ok && 'Unavailable' === outcome.error.name) return;
9251
+ return outcome;
9252
+ }
8574
9253
  var emulator_session = __webpack_require__("./helpers/emulator-session.ts");
8575
9254
  var external_pintor_ = __webpack_require__("pintor");
8576
9255
  var external_pintor_default = /*#__PURE__*/ __webpack_require__.n(external_pintor_);
@@ -8868,7 +9547,8 @@ var __webpack_modules__ = {
8868
9547
  ...enforcedProps,
8869
9548
  ...this.common,
8870
9549
  app: this.app,
8871
- $ip: null
9550
+ $ip: null,
9551
+ $geoip_disable: true
8872
9552
  },
8873
9553
  distinct_id: this.anonId
8874
9554
  };
@@ -9018,7 +9698,7 @@ var __webpack_modules__ = {
9018
9698
  return Math.min(Math.max(n, min), max);
9019
9699
  }
9020
9700
  const TEMPLATE_CORPUS_REPO = 'extension-js/examples';
9021
- const TEMPLATE_CORPUS_REF = '573d5d58174122606e5d6b6b0f2eafd6c02dcbf7';
9701
+ const TEMPLATE_CORPUS_REF = 'd69e46b311c27d11a98d241494023101b337281f';
9022
9702
  const TEMPLATE_CORPUS_SLUGS = [
9023
9703
  'action',
9024
9704
  'action-locales',
@@ -9352,6 +10032,14 @@ var __webpack_modules__ = {
9352
10032
  if (listTemplates().includes(name)) return name;
9353
10033
  if (templateAliasFor(name)) return name;
9354
10034
  }
10035
+ const CREATE_SOURCES = new Set([
10036
+ 'cli',
10037
+ 'templates'
10038
+ ]);
10039
+ function createSourceTag(value) {
10040
+ const tag = String(value ?? '').trim().toLowerCase();
10041
+ return CREATE_SOURCES.has(tag) ? tag : 'cli';
10042
+ }
9355
10043
  function telemetryCommandContext(command, argv = process.argv) {
9356
10044
  const install = (0, browser_install_outcome.w6)();
9357
10045
  const installContext = install ? {
@@ -9368,9 +10056,9 @@ var __webpack_modules__ = {
9368
10056
  '--template',
9369
10057
  '-t'
9370
10058
  ])),
9371
- source: readArgValue(argv, [
10059
+ source: createSourceTag(readArgValue(argv, [
9372
10060
  '--source'
9373
- ]) || 'cli'
10061
+ ]))
9374
10062
  };
9375
10063
  }
9376
10064
  const consent = resolveTelemetryConsent(process.argv);
@@ -9506,6 +10194,14 @@ var __webpack_modules__ = {
9506
10194
  function parseJsonSafe(filePath) {
9507
10195
  return JSON.parse(external_node_fs_default().readFileSync(filePath, 'utf8'));
9508
10196
  }
10197
+ function runtimeNotFound(message) {
10198
+ return Object.assign(new Error(message), {
10199
+ code: messaging.Lp.E_RUNTIME_NOT_FOUND
10200
+ });
10201
+ }
10202
+ function runtimeNotBuilt(root) {
10203
+ 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.`);
10204
+ }
9509
10205
  function resolveDevelopRootFromDir(dir) {
9510
10206
  try {
9511
10207
  const packageJsonPath = external_node_path_default().join(dir, 'package.json');
@@ -9574,7 +10270,7 @@ var __webpack_modules__ = {
9574
10270
  }
9575
10271
  function resolveExtensionDevelopRoot(startDir = __dirname) {
9576
10272
  const { root, source } = resolvePreferredDevelopRoot(startDir);
9577
- if (!root) throw new Error('Unable to locate the extension-develop runtime.');
10273
+ if (!root) throw runtimeNotFound('Unable to locate the extension-develop runtime.');
9578
10274
  process.env.EXTENSION_DEVELOP_ROOT = root;
9579
10275
  if ('workspace' === source) process.env.EXTENSION_CREATE_DEVELOP_ROOT = root;
9580
10276
  return root;
@@ -9601,7 +10297,7 @@ var __webpack_modules__ = {
9601
10297
  const { source } = resolvePreferredDevelopRoot(startDir);
9602
10298
  const distEntry = resolveDevelopDistEntry(root);
9603
10299
  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.`);
10300
+ if ('workspace' === source) throw runtimeNotBuilt(root);
9605
10301
  return await import("extension-develop");
9606
10302
  }
9607
10303
  async function loadExtensionDevelopPreviewModule(startDir = __dirname) {
@@ -9611,7 +10307,7 @@ var __webpack_modules__ = {
9611
10307
  if (previewEntry) return importModule(previewEntry);
9612
10308
  const fullEntry = resolveDevelopDistEntry(root);
9613
10309
  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.`);
10310
+ if ('workspace' === source) throw runtimeNotBuilt(root);
9615
10311
  return await import("extension-develop/preview");
9616
10312
  }
9617
10313
  async function loadExtensionDevelopBridgeModule(startDir = __dirname) {
@@ -9619,7 +10315,7 @@ var __webpack_modules__ = {
9619
10315
  const { source } = resolvePreferredDevelopRoot(startDir);
9620
10316
  const bridgeEntry = resolveDevelopDistEntry(root, 'bridge');
9621
10317
  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.`);
10318
+ if ('workspace' === source) throw runtimeNotBuilt(root);
9623
10319
  const bridgeSpecifier = 'extension-develop/bridge';
9624
10320
  return await import(bridgeSpecifier);
9625
10321
  }
@@ -10321,9 +11017,13 @@ Cross-browser compatibility
10321
11017
  ],
10322
11018
  notes: [
10323
11019
  'ready.json is written atomically by the build (dev/start) on each compile',
11020
+ '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
11021
  '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',
11022
+ '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',
11023
+ '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
11024
  '--wait requires a local project path (remote URLs are not supported)',
10326
- 'consumers should verify pid liveness and recency before trusting a contract'
11025
+ 'consumers should verify pid liveness and recency before trusting a contract',
11026
+ '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
11027
  ]
10328
11028
  },
10329
11029
  dockerAndContainers: {
@@ -10705,7 +11405,7 @@ Cross-browser compatibility
10705
11405
  const rotated = file.replace(/\.ndjson$/, '.1.ndjson');
10706
11406
  console.error(external_pintor_default().dim(external_pintor_default().gray(`… earlier events of this session were rotated to ${rotated} at ${header.startedAt}`)));
10707
11407
  }
10708
- function writeFrame(frame) {
11408
+ function logs_writeFrame(frame) {
10709
11409
  try {
10710
11410
  external_node_fs_default().writeSync(1, `${JSON.stringify(frame)}\n`);
10711
11411
  } catch {
@@ -10723,7 +11423,7 @@ Cross-browser compatibility
10723
11423
  const tab = parsePositiveInt('--tab', options.tab);
10724
11424
  if (!tab.ok) {
10725
11425
  console.error(tab.message);
10726
- if ('pretty' !== format) writeFrame(messaging.Pr.fail('logs', 'usage', {
11426
+ if ('pretty' !== format) logs_writeFrame(messaging.Pr.fail('logs', 'usage', {
10727
11427
  code: messaging.Lp.E_FLAG_VALUE_INVALID,
10728
11428
  message: tab.message,
10729
11429
  name: 'CliError'
@@ -10738,7 +11438,7 @@ Cross-browser compatibility
10738
11438
  const emulatorRefusal = (0, emulator_session.MC)(bridge, projectPath, browser, 'logs');
10739
11439
  if (emulatorRefusal) {
10740
11440
  console.error(emulatorRefusal);
10741
- if ('pretty' !== format) writeFrame(messaging.Pr.fail('logs', 'failed', {
11441
+ if ('pretty' !== format) logs_writeFrame(messaging.Pr.fail('logs', 'failed', {
10742
11442
  code: messaging.Lp.E_COMMAND_UNSUPPORTED_FOR_TARGET,
10743
11443
  message: emulatorRefusal,
10744
11444
  name: 'CliError'
@@ -10752,7 +11452,7 @@ Cross-browser compatibility
10752
11452
  if (!external_node_fs_default().existsSync(file)) {
10753
11453
  const message = `No logs found at ${file}. Start a dev session (extension dev) first, or pass --browser to match it.`;
10754
11454
  console.error(message);
10755
- if ('pretty' !== format) writeFrame(messaging.Pr.fail('logs', 'not-found', {
11455
+ if ('pretty' !== format) logs_writeFrame(messaging.Pr.fail('logs', 'not-found', {
10756
11456
  code: messaging.Lp.E_LOGS_NOT_FOUND,
10757
11457
  message,
10758
11458
  name: 'CliError'
@@ -10779,7 +11479,7 @@ Cross-browser compatibility
10779
11479
  }
10780
11480
  function refuseUsage(format, message) {
10781
11481
  console.error(message);
10782
- if ('pretty' !== format) writeFrame(messaging.Pr.fail('logs', 'usage', {
11482
+ if ('pretty' !== format) logs_writeFrame(messaging.Pr.fail('logs', 'usage', {
10783
11483
  code: messaging.Lp.E_INVALID_OPTION,
10784
11484
  message,
10785
11485
  name: 'CliError'
@@ -10793,7 +11493,7 @@ Cross-browser compatibility
10793
11493
  if (!ready) {
10794
11494
  const message = `No active dev session control channel found for ${browser}. Looked at ${sessionReadyPath(bridge, projectPath, browser)}. Run \`extension dev --browser=${browser}\` first.`;
10795
11495
  console.error(message);
10796
- if ('pretty' !== format) writeFrame(messaging.Pr.fail('logs', 'not-found', {
11496
+ if ('pretty' !== format) logs_writeFrame(messaging.Pr.fail('logs', 'not-found', {
10797
11497
  code: messaging.Lp.E_SESSION_NOT_FOUND,
10798
11498
  message,
10799
11499
  name: 'CliError'
@@ -10907,6 +11607,14 @@ Cross-browser compatibility
10907
11607
  };
10908
11608
  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
11609
  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>.";
11610
+ 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>.";
11611
+ 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.";
11612
+ 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>.";
11613
+ function cspBlocksEvalHint(context, browser) {
11614
+ if ('content' === context) return CSP_BLOCKS_EVAL_HINT_CONTENT;
11615
+ if ('page' !== context) return CSP_BLOCKS_EVAL_HINT;
11616
+ return (0, browser_family.M_)(browser) ? CSP_BLOCKS_EVAL_HINT_PAGE + CSP_BLOCKS_EVAL_HINT_PAGE_GECKO : CSP_BLOCKS_EVAL_HINT_PAGE;
11617
+ }
10910
11618
  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
11619
  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
11620
  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 +11625,11 @@ Cross-browser compatibility
10917
11625
  }
10918
11626
  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
11627
  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) {
11628
+ const BRIDGE_FAULT_NAMES = new Set([
11629
+ 'ExecutorError',
11630
+ 'TabsError'
11631
+ ]);
11632
+ function codeForBridgeError(name, message, refusal, command) {
10921
11633
  if (refusal && refusal in REFUSAL_TO_CODE) return REFUSAL_TO_CODE[refusal];
10922
11634
  if ('Timeout' === name) return messaging.Lp.E_TIMEOUT;
10923
11635
  if ('Unavailable' === name) return messaging.Lp.E_CONTROL_UNAVAILABLE;
@@ -10930,6 +11642,7 @@ Cross-browser compatibility
10930
11642
  if ('EvalError' === name) return messaging.Lp.E_EVAL;
10931
11643
  if ('InspectError' === name) return messaging.Lp.E_INSPECT;
10932
11644
  if ('StorageError' === name) return messaging.Lp.E_STORAGE;
11645
+ if ('eval' === command && !BRIDGE_FAULT_NAMES.has(name)) return messaging.Lp.E_EVAL;
10933
11646
  return messaging.Lp.E_INTERNAL;
10934
11647
  }
10935
11648
  function statusForCode(code) {
@@ -10940,7 +11653,7 @@ Cross-browser compatibility
10940
11653
  return 'failed';
10941
11654
  }
10942
11655
  function buildActEnvelope(command, result) {
10943
- const { ok, value, truncated, error, ...extras } = result;
11656
+ const { ok, value, truncated, error, type, cmdId, ...extras } = result;
10944
11657
  const wasTruncated = true === truncated;
10945
11658
  if (ok) return {
10946
11659
  ...extras,
@@ -10952,7 +11665,7 @@ Cross-browser compatibility
10952
11665
  const name = 'string' == typeof raw.name ? raw.name : 'Error';
10953
11666
  const message = 'string' == typeof raw.message ? raw.message : 'command failed';
10954
11667
  const refusal = 'string' == typeof raw.code ? raw.code : void 0;
10955
- const code = codeForBridgeError(name, message, refusal);
11668
+ const code = codeForBridgeError(name, message, refusal, 'string' == typeof raw.name ? command : void 0);
10956
11669
  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
11670
  return {
10958
11671
  ...extras,
@@ -11110,6 +11823,35 @@ Cross-browser compatibility
11110
11823
  timeoutMs
11111
11824
  });
11112
11825
  }
11826
+ function pickTargetTabUrl(tabs, target) {
11827
+ const withUrl = tabs.filter((tab)=>'string' == typeof tab.url && tab.url.length > 0);
11828
+ if ('number' == typeof target.tabId) return withUrl.find((tab)=>tab.id === target.tabId)?.url;
11829
+ if (target.url) {
11830
+ const wanted = target.url;
11831
+ return (withUrl.find((tab)=>tab.url === wanted) ?? withUrl.find((tab)=>tab.url.includes(wanted)))?.url;
11832
+ }
11833
+ const active = withUrl.filter((tab)=>true === tab.active);
11834
+ return 1 === active.length ? active[0].url : void 0;
11835
+ }
11836
+ async function geckoProtocolPageEval(bridge, projectPath, browser, listTabs, target, expression, timeoutMs) {
11837
+ const ready = bridge.readReadyContractDocument(projectPath, browser);
11838
+ const rdpPort = 'number' == typeof ready?.rdpPort ? ready.rdpPort : 0;
11839
+ if (!rdpPort) return;
11840
+ let tabs;
11841
+ try {
11842
+ tabs = await listTabs();
11843
+ } catch {
11844
+ return;
11845
+ }
11846
+ const url = pickTargetTabUrl(tabs?.ok && Array.isArray(tabs.value) ? tabs.value : [], target);
11847
+ if (!url) return;
11848
+ return await evaluateTabDocument({
11849
+ rdpPort,
11850
+ url,
11851
+ expression,
11852
+ timeoutMs
11853
+ });
11854
+ }
11113
11855
  async function runCommand(input) {
11114
11856
  const bridge = await loadExtensionDevelopBridgeModule();
11115
11857
  const projectPath = resolveSessionProjectPath(bridge, input.projectPathArg);
@@ -11176,16 +11918,33 @@ Cross-browser compatibility
11176
11918
  ...outputFrame,
11177
11919
  code: /timed out/i.test(message) ? messaging.Lp.E_TIMEOUT : messaging.Lp.E_CONTROL_UNAVAILABLE
11178
11920
  });
11921
+ }
11922
+ const geckoEvalFailed = 'eval' === input.op && result?.ok !== true && (0, browser_family.M_)(browser);
11923
+ try {
11924
+ if (geckoEvalFailed && isExtensionDocumentContext(input.target.context) && (bridgeBlamedTheExtensionCsp(result) || bridgeHadNoExecutor(result))) {
11925
+ const overProtocol = await geckoProtocolEval(bridge, projectPath, browser, input.target.context, String(input.args?.expression ?? ''), timeoutMs);
11926
+ if (overProtocol) result = overProtocol;
11927
+ else if (bridgeHadNoExecutor(result)) {
11928
+ const raw = result?.error || {};
11929
+ if ('string' != typeof raw.hint) raw.hint = GECKO_IDLE_EVENT_PAGE_HINT;
11930
+ }
11931
+ } else if (geckoEvalFailed && 'page' === input.target.context && bridgeBlamedTheExtensionCsp(result)) {
11932
+ const overProtocol = await geckoProtocolPageEval(bridge, projectPath, browser, ()=>controller.command({
11933
+ op: 'tabs.query',
11934
+ target: {
11935
+ context: 'background'
11936
+ },
11937
+ args: {},
11938
+ timeoutMs
11939
+ }), input.target, String(input.args?.expression ?? ''), timeoutMs);
11940
+ if (overProtocol) result = overProtocol;
11941
+ }
11179
11942
  } finally{
11180
11943
  controller.close();
11181
11944
  }
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
- }
11945
+ if ('eval' === input.op && bridgeBlamedTheExtensionCsp(result)) {
11946
+ const raw = result?.error || {};
11947
+ if ('string' != typeof raw.hint) raw.hint = cspBlocksEvalHint(input.target.context, browser);
11189
11948
  }
11190
11949
  if (result?.ok && input.augment) try {
11191
11950
  Object.assign(result, input.augment(projectPath, browser, result));
@@ -11458,7 +12217,7 @@ Cross-browser compatibility
11458
12217
  function isErrorFramed(err) {
11459
12218
  return Boolean(err && 'object' == typeof err && true === err[FRAMED_FLAG]);
11460
12219
  }
11461
- function wantsJsonOutput(argv) {
12220
+ function cli_failure_wantsJsonOutput(argv) {
11462
12221
  return 'json' === normalizeOutputFormat(scanArgvValue(argv, '--output'));
11463
12222
  }
11464
12223
  function isCommanderError(err) {
@@ -11535,7 +12294,7 @@ Cross-browser compatibility
11535
12294
  return `${(0, messaging.Pl)('error')} ${label}\n${remedy}`;
11536
12295
  }
11537
12296
  function isUsageCode(code) {
11538
- return code === messaging.Lp.E_BROWSER_BINARY_INVALID;
12297
+ return code === messaging.Lp.E_BROWSER_BINARY_INVALID || code === messaging.Lp.E_BROWSER_BINARY_REQUIRED || code === messaging.Lp.E_FLAG_NOT_SUPPORTED_HERE;
11539
12298
  }
11540
12299
  function declaredErrorCode(err) {
11541
12300
  const code = err?.code;
@@ -11797,11 +12556,16 @@ Cross-browser compatibility
11797
12556
  if (summary) summaries.push(summary);
11798
12557
  } catch (error) {
11799
12558
  if (!asJson) throw error;
12559
+ const { diagnostics, truncated } = error ?? {};
11800
12560
  console.log(JSON.stringify(messaging.Pr.fail('build', 'build-failed', {
11801
12561
  code: declaredErrorCode(error) ?? messaging.Lp.E_COMPILE,
11802
- message: error instanceof Error ? error.message : String(error)
12562
+ message: error instanceof Error ? error.message : String(error),
12563
+ ...Array.isArray(diagnostics) && diagnostics.length > 0 ? {
12564
+ details: diagnostics
12565
+ } : {}
11803
12566
  }, {
11804
- hint: "Fix the error above and run build again."
12567
+ hint: "Fix the error above and run build again.",
12568
+ truncated: true === truncated
11805
12569
  })));
11806
12570
  process.exit(1);
11807
12571
  }
@@ -11810,9 +12574,23 @@ Cross-browser compatibility
11810
12574
  browsers: built,
11811
12575
  mode: mode ?? 'production',
11812
12576
  summaries
12577
+ }, {
12578
+ warnings: codedWarningsOf(summaries)
11813
12579
  })));
11814
12580
  });
11815
12581
  }
12582
+ function codedWarningsOf(summaries) {
12583
+ const coded = [];
12584
+ for (const summary of summaries){
12585
+ const warnings = summary?.warnings;
12586
+ if (Array.isArray(warnings)) for (const line of warnings){
12587
+ if ('string' != typeof line) continue;
12588
+ const code = line.slice(0, line.indexOf(': '));
12589
+ if (Object.prototype.hasOwnProperty.call(messaging.Lp, code) && !coded.includes(line)) coded.push(line);
12590
+ }
12591
+ }
12592
+ return coded;
12593
+ }
11816
12594
  const READY_CONTRACT_SCHEMA_VERSION = 2;
11817
12595
  const RECORD_STREAM_COMMANDS = new Set([
11818
12596
  'logs'
@@ -12061,6 +12839,11 @@ Cross-browser compatibility
12061
12839
  if ('string' != typeof code) return;
12062
12840
  return READY_CONTRACT_CODES[code.trim().toLowerCase()];
12063
12841
  }
12842
+ function stampedLaunchFailureCode(ready) {
12843
+ if ('browser_launch_failed' !== ready.code) return;
12844
+ const code = ready.browserLaunchFailedCode;
12845
+ return 'string' == typeof code && Object.prototype.hasOwnProperty.call(messaging.Lp, code) ? code : void 0;
12846
+ }
12064
12847
  function dev_wait_define_property(obj, key, value) {
12065
12848
  if (key in obj) Object.defineProperty(obj, key, {
12066
12849
  value: value,
@@ -12111,7 +12894,7 @@ Cross-browser compatibility
12111
12894
  const message = error instanceof Error ? error.message : String(error);
12112
12895
  const tagged = error?.code;
12113
12896
  const code = 'string' == typeof tagged && tagged in messaging.Lp ? tagged : messaging.Lp.E_INTERNAL;
12114
- if (code === messaging.Lp.E_ARGS) return {
12897
+ if (code === messaging.Lp.E_ARGS || code === messaging.Lp.E_REMOTE_URL_UNSUPPORTED) return {
12115
12898
  code,
12116
12899
  status: 'usage',
12117
12900
  message,
@@ -12123,6 +12906,24 @@ Cross-browser compatibility
12123
12906
  message,
12124
12907
  hint: 'Pass a browser binary path that exists and runs.'
12125
12908
  };
12909
+ if (code === messaging.Lp.E_BROWSER_BINARY_REQUIRED) return {
12910
+ code,
12911
+ status: 'usage',
12912
+ message,
12913
+ hint: 'Pass --chromium-binary or --gecko-binary with the browser to run.'
12914
+ };
12915
+ if (code === messaging.Lp.E_BROWSER_NOT_FOUND) return {
12916
+ code,
12917
+ status: 'failed',
12918
+ message,
12919
+ hint: 'Install the browser, or pass its binary path to the command.'
12920
+ };
12921
+ if (code === messaging.Lp.E_FLAG_NOT_SUPPORTED_HERE) return {
12922
+ code,
12923
+ status: 'usage',
12924
+ message,
12925
+ hint: 'Let Extension.js manage the profile, or pass --profile=<path>.'
12926
+ };
12126
12927
  if (code === messaging.Lp.E_READY_TIMEOUT) return {
12127
12928
  code,
12128
12929
  status: 'timeout',
@@ -12199,8 +13000,7 @@ Cross-browser compatibility
12199
13000
  continue;
12200
13001
  }
12201
13002
  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);
13003
+ throw new WaitModeError(String(detail), stampedLaunchFailureCode(payload) ?? readyContractErrorCode(payload.code) ?? messaging.Lp.E_READY_ERROR_STATUS);
12204
13004
  }
12205
13005
  }
12206
13006
  }
@@ -12210,7 +13010,7 @@ Cross-browser compatibility
12210
13010
  throw new WaitModeError(`Timed out waiting for ready contract at ${readyPath} (${options.timeoutMs} ms)${timeoutDetail}`, messaging.Lp.E_READY_TIMEOUT);
12211
13011
  }
12212
13012
  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);
13013
+ 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
13014
  const { projectPath, bridge } = await resolveProjectPath(options.pathOrRemoteUrl);
12215
13015
  const timeoutMs = parseWaitTimeoutMs(options.waitTimeout);
12216
13016
  const format = parseWaitFormat(options.waitFormat);
@@ -12978,7 +13778,7 @@ Cross-browser compatibility
12978
13778
  } catch (err) {
12979
13779
  const message = String(err?.message || err);
12980
13780
  if (asJson) console.log(JSON.stringify(messaging.Pr.fail('doctor', 'failed', {
12981
- code: messaging.Lp.E_INTERNAL,
13781
+ code: declaredErrorCode(err) ?? messaging.Lp.E_INTERNAL,
12982
13782
  message
12983
13783
  })));
12984
13784
  else console.error(message);
@@ -13003,6 +13803,7 @@ Cross-browser compatibility
13003
13803
  });
13004
13804
  }
13005
13805
  var output_binaries_resolver = __webpack_require__("./browsers/browsers-lib/output-binaries-resolver.ts");
13806
+ const DEFAULT_INSTALL_TARGET = 'chromium';
13006
13807
  function install_emit(frame) {
13007
13808
  console.log(JSON.stringify(frame));
13008
13809
  }
@@ -13070,10 +13871,10 @@ Cross-browser compatibility
13070
13871
  await exitAfterDrain(1);
13071
13872
  }
13072
13873
  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)=>{
13874
+ 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
13875
  const asJson = isJsonOutput(options);
13075
13876
  const named = Boolean(options.browser || browserArg);
13076
- const selectedBrowser = options.browser || browserArg || 'chromium';
13877
+ const selectedBrowser = options.browser || browserArg || DEFAULT_INSTALL_TARGET;
13077
13878
  const browserList = (0, vendors.OB)(selectedBrowser);
13078
13879
  if (!(options.where && !named)) {
13079
13880
  if (await refuseIfNotManagedTarget('install', browserList, asJson)) return;
@@ -13100,6 +13901,7 @@ Cross-browser compatibility
13100
13901
  for (const browser of browserList)try {
13101
13902
  await extensionInstall({
13102
13903
  browser,
13904
+ defaulted: !named,
13103
13905
  locateInstalledBinary: output_binaries_resolver.AG
13104
13906
  });
13105
13907
  installed.push(browser);
@@ -13192,8 +13994,14 @@ Cross-browser compatibility
13192
13994
  var run_only = __webpack_require__("./browsers/run-only.ts");
13193
13995
  const PREVIEW_FAILED_CODES = new Set([
13194
13996
  messaging.Lp.E_BROWSER_LAUNCH,
13997
+ messaging.Lp.E_BROWSER_NOT_FOUND,
13998
+ messaging.Lp.E_BROWSER_START_TIMEOUT,
13195
13999
  messaging.Lp.E_BROWSER_CONNECT,
14000
+ messaging.Lp.E_BROWSER_CONNECTION_CLOSED,
14001
+ messaging.Lp.E_RDP_PROTOCOL,
14002
+ messaging.Lp.E_ADDON_INSTALL,
13196
14003
  messaging.Lp.E_CONFIG_LOAD,
14004
+ messaging.Lp.E_RUNTIME_NOT_FOUND,
13197
14005
  messaging.Lp.E_REMOTE_DOWNLOAD,
13198
14006
  messaging.Lp.E_REMOTE_ZIP_INVALID,
13199
14007
  messaging.Lp.E_REMOTE_FETCH_TIMEOUT
@@ -13658,6 +14466,7 @@ Cross-browser compatibility
13658
14466
  }
13659
14467
  markCommandSessionStart('start');
13660
14468
  const { extensionBuild } = await loadExtensionDevelopModule();
14469
+ const noBrowser = await resolveNoBrowser(pathOrRemoteUrl || process.cwd(), 'start');
13661
14470
  for (const vendor of list){
13662
14471
  const logsOption = startOptions.logs;
13663
14472
  const logContextOption = startOptions.logContext;
@@ -13668,6 +14477,7 @@ Cross-browser compatibility
13668
14477
  browser: vendor,
13669
14478
  exitOnError: !asJson,
13670
14479
  metadataCommand: 'start',
14480
+ launchFollows: !noBrowser,
13671
14481
  polyfill: explicitCliValue(command, 'polyfill', explicitOptionalBoolean(startOptions.polyfill)),
13672
14482
  install: startOptions.install,
13673
14483
  extensions: parseExtensionsList(startOptions.extensions),
@@ -13683,7 +14493,6 @@ Cross-browser compatibility
13683
14493
  }));
13684
14494
  process.exit(1);
13685
14495
  }
13686
- const noBrowser = await resolveNoBrowser(pathOrRemoteUrl || process.cwd(), 'start');
13687
14496
  if (noBrowser) continue;
13688
14497
  const { extensionPreview } = await loadExtensionDevelopPreviewModule();
13689
14498
  await extensionPreview(pathOrRemoteUrl, {
@@ -13717,7 +14526,7 @@ Cross-browser compatibility
13717
14526
  browsers: list,
13718
14527
  port: null,
13719
14528
  pid: process.pid,
13720
- noBrowser: await resolveNoBrowser(pathOrRemoteUrl || process.cwd(), 'start')
14529
+ noBrowser
13721
14530
  }));
13722
14531
  });
13723
14532
  }
@@ -13871,7 +14680,7 @@ Cross-browser compatibility
13871
14680
  }
13872
14681
  function failBeforeParse(argv, humanMessage, code, plainMessage, flag) {
13873
14682
  console.error(humanMessage);
13874
- if (wantsJsonOutput(argv)) writeStdoutFrame(earlyExitEnvelope(index_resolveCommandFromArgv(argv) || 'extension', code, plainMessage, {
14683
+ if (cli_failure_wantsJsonOutput(argv)) writeStdoutFrame(earlyExitEnvelope(index_resolveCommandFromArgv(argv) || 'extension', code, plainMessage, {
13875
14684
  flag
13876
14685
  }));
13877
14686
  process.exit(1);
@@ -13948,7 +14757,7 @@ Cross-browser compatibility
13948
14757
  if (process.argv.includes('--ai-help')) runAIHelp();
13949
14758
  else {
13950
14759
  const argv = applyNoBrowserArgvShim(applyOutputAliasArgvShim(process.argv));
13951
- const asJson = wantsJsonOutput(argv);
14760
+ const asJson = cli_failure_wantsJsonOutput(argv);
13952
14761
  const commandName = index_resolveCommandFromArgv(argv) || 'extension';
13953
14762
  (async ()=>{
13954
14763
  try {
@@ -13999,6 +14808,9 @@ Cross-browser compatibility
13999
14808
  "node:fs" (module) {
14000
14809
  module.exports = require("node:fs");
14001
14810
  },
14811
+ "node:http" (module) {
14812
+ module.exports = require("node:http");
14813
+ },
14002
14814
  "node:module" (module) {
14003
14815
  module.exports = require("node:module");
14004
14816
  },