extension 3.17.0 → 3.18.0

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 (30) hide show
  1. package/dist/322.cjs +89 -11
  2. package/dist/browsers.cjs +263 -206
  3. package/dist/cli.cjs +1307 -410
  4. package/dist/extension/browsers/browsers-lib/messages.d.ts +17 -0
  5. package/dist/extension/browsers/browsers-lib/output-binaries-resolver.d.ts +1 -1
  6. package/dist/extension/browsers/browsers-lib/shared-utils.d.ts +1 -0
  7. package/dist/extension/browsers/browsers-lib/wsl-support.d.ts +3 -0
  8. package/dist/extension/browsers/browsers-types.d.ts +1 -1
  9. package/dist/extension/browsers/run-chromium/chromium-launch/process-handlers.d.ts +8 -1
  10. package/dist/extension/browsers/run-chromium/chromium-launch/wsl-support.d.ts +2 -9
  11. package/dist/extension/browsers/run-chromium/chromium-source-inspection/cdp-client.d.ts +6 -0
  12. package/dist/extension/browsers/run-chromium/chromium-source-inspection/cdp-extension-controller/logging.d.ts +0 -5
  13. package/dist/extension/browsers/run-chromium/chromium-source-inspection/index.d.ts +1 -0
  14. package/dist/extension/browsers/run-firefox/firefox-launch/binary-detector.d.ts +0 -4
  15. package/dist/extension/browsers/run-firefox/firefox-launch/process-handlers.d.ts +5 -1
  16. package/dist/extension/browsers/run-firefox/firefox-launch/wsl-support.d.ts +2 -4
  17. package/dist/extension/browsers/run-firefox/firefox-source-inspection/remote-firefox/evaluate.d.ts +1 -0
  18. package/dist/extension/browsers/run-safari/safari-launch/dry-run.d.ts +1 -0
  19. package/dist/extension/browsers/run-safari/safari-launch/index.d.ts +5 -0
  20. package/dist/extension/browsers/run-safari/safari-launch/safari-config.d.ts +16 -0
  21. package/dist/extension/browsers/run-safari/safari-launch/toolchain.d.ts +10 -0
  22. package/dist/extension/browsers/run-safari/safari-types.d.ts +18 -0
  23. package/dist/extension/commands/act.d.ts +6 -0
  24. package/dist/extension/commands/dev-wait.d.ts +2 -0
  25. package/dist/extension/commands/logs.d.ts +2 -0
  26. package/dist/extension/commands/publish.d.ts +15 -0
  27. package/dist/extension/helpers/extension-develop-runtime.d.ts +5 -0
  28. package/dist/extension/helpers/messages.d.ts +18 -1
  29. package/dist/extension/helpers/vendors.d.ts +2 -1
  30. package/package.json +5 -5
package/dist/browsers.cjs CHANGED
@@ -998,6 +998,7 @@ var __webpack_modules__ = {
998
998
  function managedBrowserCacheEnv(cacheRoot, browser) {
999
999
  const root = String(cacheRoot || '').trim();
1000
1000
  if (!root) return {};
1001
+ if ('safari' === browser || 'webkit-based' === browser) return {};
1001
1002
  if ('chrome' === browser) return {
1002
1003
  PUPPETEER_CACHE_DIR: path__rspack_import_1.join(root, 'chrome', 'chrome')
1003
1004
  };
@@ -1033,19 +1034,13 @@ var __webpack_modules__ = {
1033
1034
  const versionDirs = entries.filter((entry)=>entry.isDirectory() && versionDirPattern.test(entry.name)).map((entry)=>path__rspack_import_1.join(root, entry.name));
1034
1035
  for (const dir of versionDirs)candidateFiles.push(...buildCandidates(dir, browser));
1035
1036
  } catch {}
1036
- let matched = false;
1037
1037
  for (const candidate of candidateFiles)try {
1038
- if (candidate && fs__rspack_import_0.existsSync(candidate)) {
1039
- matched = true;
1040
- return candidate;
1041
- }
1038
+ if (candidate && fs__rspack_import_0.existsSync(candidate)) return candidate;
1042
1039
  } catch {}
1043
- if (!matched) {
1044
- const names = executableNamesFor(browser);
1045
- for (const root of scanRoots){
1046
- const found = findExecutableUnder(root, names, 6);
1047
- if (found) return found;
1048
- }
1040
+ const names = executableNamesFor(browser);
1041
+ for (const root of scanRoots){
1042
+ const found = findExecutableUnder(root, names, 6);
1043
+ if (found) return found;
1049
1044
  }
1050
1045
  return null;
1051
1046
  }
@@ -1223,7 +1218,8 @@ var __webpack_modules__ = {
1223
1218
  RE: ()=>markManagedEphemeralProfile,
1224
1219
  aY: ()=>findAvailablePortNear,
1225
1220
  jl: ()=>deriveDebugPortWithInstance,
1226
- ov: ()=>filterBrowserFlags
1221
+ ov: ()=>filterBrowserFlags,
1222
+ sW: ()=>removeManagedEphemeralProfile
1227
1223
  });
1228
1224
  var fs__rspack_import_0 = __webpack_require__("fs");
1229
1225
  var os__rspack_import_1 = __webpack_require__("os");
@@ -1341,6 +1337,18 @@ var __webpack_modules__ = {
1341
1337
  fs__rspack_import_0.writeFileSync(path__rspack_import_2.join(profilePath, MANAGED_EPHEMERAL_PROFILE_MARKER), 'managed-ephemeral-profile\n', 'utf8');
1342
1338
  } catch {}
1343
1339
  }
1340
+ function removeManagedEphemeralProfile(profilePath) {
1341
+ try {
1342
+ if (!profilePath) return;
1343
+ if ('dev' === path__rspack_import_2.basename(profilePath)) return;
1344
+ const markerPath = path__rspack_import_2.join(profilePath, MANAGED_EPHEMERAL_PROFILE_MARKER);
1345
+ if (!fs__rspack_import_0.existsSync(markerPath)) return;
1346
+ fs__rspack_import_0.rmSync(profilePath, {
1347
+ recursive: true,
1348
+ force: true
1349
+ });
1350
+ } catch {}
1351
+ }
1344
1352
  function cleanupOldTempProfiles(baseDir, excludeBasename, maxAgeHours = 12) {
1345
1353
  try {
1346
1354
  if (!fs__rspack_import_0.existsSync(baseDir)) return;
@@ -1371,6 +1379,37 @@ var __webpack_modules__ = {
1371
1379
  } catch {}
1372
1380
  }
1373
1381
  },
1382
+ "./browsers/browsers-lib/wsl-support.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
1383
+ __webpack_require__.d(__webpack_exports__, {
1384
+ EV: ()=>isWslEnv,
1385
+ f7: ()=>normalizeBinaryPathForWsl,
1386
+ qc: ()=>hasGuiDisplay
1387
+ });
1388
+ var os__rspack_import_0 = __webpack_require__("os");
1389
+ function isWslEnv() {
1390
+ if ('linux' !== process.platform) return false;
1391
+ const hasWslEnv = Boolean(String(process.env.WSL_DISTRO_NAME || '').trim() || String(process.env.WSL_INTEROP || '').trim() || String(process.env.WSLENV || '').trim());
1392
+ if (hasWslEnv) return true;
1393
+ return /microsoft/i.test(os__rspack_import_0.release());
1394
+ }
1395
+ function hasGuiDisplay() {
1396
+ const display = String(process.env.DISPLAY || '').trim();
1397
+ const waylandDisplay = String(process.env.WAYLAND_DISPLAY || '').trim();
1398
+ return display.length > 0 || waylandDisplay.length > 0;
1399
+ }
1400
+ function normalizeBinaryPathForWsl(input) {
1401
+ let value = String(input || '').trim();
1402
+ if (!value) return value;
1403
+ if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) value = value.slice(1, -1);
1404
+ if (!isWslEnv()) return value;
1405
+ if (/^[a-zA-Z]:[\\/]/.test(value)) {
1406
+ const drive = value[0].toLowerCase();
1407
+ const rest = value.slice(2).replace(/\\/g, '/').replace(/^\/+/, '');
1408
+ return `/mnt/${drive}/${rest}`;
1409
+ }
1410
+ return value;
1411
+ }
1412
+ },
1374
1413
  "./browsers/index.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
1375
1414
  __webpack_require__.r(__webpack_exports__);
1376
1415
  __webpack_require__.d(__webpack_exports__, {
@@ -1898,7 +1937,9 @@ var __webpack_modules__ = {
1898
1937
  '--disable-dev-shm-usage'
1899
1938
  ];
1900
1939
  const baseFlags = [
1901
- `--load-extension=${extensionsToLoad.join()}`,
1940
+ ...extensionsToLoad.length ? [
1941
+ `--load-extension=${extensionsToLoad.join()}`
1942
+ ] : [],
1902
1943
  ...userProfilePath ? [
1903
1944
  `--user-data-dir=${userProfilePath}`
1904
1945
  ] : [],
@@ -1915,53 +1956,81 @@ var __webpack_modules__ = {
1915
1956
  return baseFlags;
1916
1957
  }
1917
1958
  var external_child_process_ = __webpack_require__("child_process");
1918
- function setupProcessSignalHandlers(browser, child, cleanupInstance) {
1919
- const cleanup = ()=>{
1920
- try {
1921
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(messages.VkK(browser));
1922
- if (child && !child.killed) {
1923
- if ('win32' === process.platform) try {
1924
- (0, external_child_process_.spawn)('taskkill', [
1925
- '/PID',
1926
- String(child.pid),
1927
- '/T',
1928
- '/F'
1929
- ], {
1930
- stdio: 'ignore',
1931
- windowsHide: true
1932
- }).on('error', ()=>{});
1933
- } catch {}
1934
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(messages.XHr(browser));
1935
- child.kill('SIGTERM');
1936
- setTimeout(()=>{
1937
- if (child && !child.killed) {
1938
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(messages.AGJ(browser));
1939
- child.kill('SIGKILL');
1940
- }
1941
- }, 5000);
1942
- }
1943
- cleanupInstance();
1944
- } catch (error) {
1945
- console.error(messages.TFX(browser, error));
1959
+ const activeInstances = new Set();
1960
+ let globalHandlersInstalled = false;
1961
+ function cleanupOne(instance) {
1962
+ if (instance.isCleaningUp) return;
1963
+ instance.isCleaningUp = true;
1964
+ const { browser, child, cleanupInstance } = instance;
1965
+ try {
1966
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(messages.VkK(browser));
1967
+ if (child && !child.killed) {
1968
+ if ('win32' === process.platform) try {
1969
+ (0, external_child_process_.spawn)('taskkill', [
1970
+ '/PID',
1971
+ String(child.pid),
1972
+ '/T',
1973
+ '/F'
1974
+ ], {
1975
+ stdio: 'ignore',
1976
+ windowsHide: true
1977
+ }).on('error', ()=>{});
1978
+ } catch {}
1979
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(messages.XHr(browser));
1980
+ child.kill('SIGTERM');
1981
+ const killTimer = setTimeout(()=>{
1982
+ if (child && !child.killed) {
1983
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(messages.AGJ(browser));
1984
+ child.kill('SIGKILL');
1985
+ }
1986
+ }, 5000);
1987
+ killTimer.unref?.();
1946
1988
  }
1947
- };
1948
- process.on('SIGINT', cleanup);
1949
- process.on('SIGTERM', cleanup);
1950
- process.on('SIGHUP', cleanup);
1951
- process.on('exit', cleanup);
1989
+ cleanupInstance();
1990
+ } catch (error) {
1991
+ console.error(messages.TFX(browser, error));
1992
+ }
1993
+ }
1994
+ function cleanupAll() {
1995
+ for (const instance of activeInstances)cleanupOne(instance);
1996
+ }
1997
+ function firstBrowserLabel() {
1998
+ for (const instance of activeInstances)return instance.browser;
1999
+ return 'chrome';
2000
+ }
2001
+ function installGlobalHandlersOnce() {
2002
+ if (globalHandlersInstalled) return;
2003
+ globalHandlersInstalled = true;
2004
+ process.on('SIGINT', cleanupAll);
2005
+ process.on('SIGTERM', cleanupAll);
2006
+ process.on('SIGHUP', cleanupAll);
2007
+ process.on('exit', cleanupAll);
1952
2008
  process.on('uncaughtException', (error)=>{
1953
2009
  if (isBenignSocketTeardown(error)) return;
1954
- console.error(messages.F41(browser, error));
1955
- cleanup();
2010
+ console.error(messages.F41(firstBrowserLabel(), error));
2011
+ cleanupAll();
1956
2012
  process.exit(1);
1957
2013
  });
1958
2014
  process.on('unhandledRejection', (reason)=>{
1959
2015
  if (isBenignSocketTeardown(reason)) return;
1960
- console.error(messages.N4O(browser, reason));
1961
- cleanup();
2016
+ console.error(messages.N4O(firstBrowserLabel(), reason));
2017
+ cleanupAll();
1962
2018
  process.exit(1);
1963
2019
  });
1964
2020
  }
2021
+ function setupProcessSignalHandlers(browser, child, cleanupInstance) {
2022
+ const instance = {
2023
+ browser,
2024
+ child,
2025
+ cleanupInstance,
2026
+ isCleaningUp: false
2027
+ };
2028
+ activeInstances.add(instance);
2029
+ installGlobalHandlersOnce();
2030
+ return ()=>{
2031
+ activeInstances.delete(instance);
2032
+ };
2033
+ }
1965
2034
  const BENIGN_SOCKET_ERROR_CODES = new Set([
1966
2035
  'ECONNRESET',
1967
2036
  'EPIPE',
@@ -1981,18 +2050,7 @@ var __webpack_modules__ = {
1981
2050
  }
1982
2051
  var extension_output_path = __webpack_require__("./browsers/run-chromium/chromium-launch/extension-output-path.ts");
1983
2052
  var manifest_readiness = __webpack_require__("./browsers/run-chromium/manifest-readiness.ts");
1984
- var external_os_ = __webpack_require__("os");
1985
- function isWslEnv() {
1986
- if ('linux' !== process.platform) return false;
1987
- const hasWslEnv = Boolean(String(process.env.WSL_DISTRO_NAME || '').trim() || String(process.env.WSL_INTEROP || '').trim() || String(process.env.WSLENV || '').trim());
1988
- if (hasWslEnv) return true;
1989
- return /microsoft/i.test(external_os_.release());
1990
- }
1991
- function hasGuiDisplay() {
1992
- const display = String(process.env.DISPLAY || '').trim();
1993
- const waylandDisplay = String(process.env.WAYLAND_DISPLAY || '').trim();
1994
- return display.length > 0 || waylandDisplay.length > 0;
1995
- }
2053
+ var wsl_support = __webpack_require__("./browsers/browsers-lib/wsl-support.ts");
1996
2054
  const LINUX_BROWSER_PATHS = {
1997
2055
  chrome: [
1998
2056
  '/opt/google/chrome/chrome',
@@ -2015,7 +2073,7 @@ var __webpack_modules__ = {
2015
2073
  ]
2016
2074
  };
2017
2075
  function resolveWslLinuxBinary(browser) {
2018
- if (!isWslEnv() || !hasGuiDisplay()) return null;
2076
+ if (!(0, wsl_support.EV)() || !(0, wsl_support.qc)()) return null;
2019
2077
  const candidates = LINUX_BROWSER_PATHS[browser] || LINUX_BROWSER_PATHS['chrome'];
2020
2078
  for (const candidate of candidates)if (external_fs_.existsSync(candidate)) return candidate;
2021
2079
  return null;
@@ -2037,26 +2095,14 @@ var __webpack_modules__ = {
2037
2095
  }
2038
2096
  function preferRealChromeBinary(binary) {
2039
2097
  if (!binary) return binary || null;
2040
- if (!isWslEnv() || !hasGuiDisplay()) return binary;
2098
+ if (!(0, wsl_support.EV)() || !(0, wsl_support.qc)()) return binary;
2041
2099
  if (!looksLikeChromeWrapperScript(binary)) return binary;
2042
2100
  const realBinary = '/opt/google/chrome/chrome';
2043
2101
  if (external_fs_.existsSync(realBinary)) return realBinary;
2044
2102
  return binary;
2045
2103
  }
2046
- function normalizeBinaryPathForWsl(input) {
2047
- let value = String(input || '').trim();
2048
- if (!value) return value;
2049
- if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) value = value.slice(1, -1);
2050
- if (!isWslEnv()) return value;
2051
- if (/^[a-zA-Z]:[\\/]/.test(value)) {
2052
- const drive = value[0].toLowerCase();
2053
- const rest = value.slice(2).replace(/\\/g, '/').replace(/^\/+/, '');
2054
- return `/mnt/${drive}/${rest}`;
2055
- }
2056
- return value;
2057
- }
2058
2104
  function resolveWslWindowsBinary(browser) {
2059
- if (!isWslEnv()) return null;
2105
+ if (!(0, wsl_support.EV)()) return null;
2060
2106
  const chromeCandidates = [
2061
2107
  '/mnt/c/Program Files/Google/Chrome/Application/chrome.exe',
2062
2108
  '/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe'
@@ -2107,7 +2153,7 @@ var __webpack_modules__ = {
2107
2153
  try {
2108
2154
  return await spawnOnce(binary);
2109
2155
  } catch (error) {
2110
- if (isWslEnv()) {
2156
+ if ((0, wsl_support.EV)()) {
2111
2157
  const fallback = resolveWslWindowsBinary(browser);
2112
2158
  if (fallback && fallback !== binary) {
2113
2159
  logger?.warn?.('[browser] WSL detected: retrying with Windows browser binary.');
@@ -2186,7 +2232,7 @@ var __webpack_modules__ = {
2186
2232
  let printedGuidance = false;
2187
2233
  const normalizePath = (p)=>{
2188
2234
  if (!p) return null;
2189
- const normalized = normalizeBinaryPathForWsl(p);
2235
+ const normalized = (0, wsl_support.f7)(p);
2190
2236
  return normalized || null;
2191
2237
  };
2192
2238
  const isUsableBinary = (p)=>Boolean(p && external_fs_.existsSync(p));
@@ -2215,7 +2261,7 @@ var __webpack_modules__ = {
2215
2261
  };
2216
2262
  browserBinaryLocation = resolveManagedBinary();
2217
2263
  let skipDetection = Boolean(browserBinaryLocation);
2218
- if (!browserBinaryLocation && isWslEnv()) {
2264
+ if (!browserBinaryLocation && (0, wsl_support.EV)()) {
2219
2265
  const linuxFallback = resolveWslLinuxBinary(browser);
2220
2266
  if (linuxFallback) {
2221
2267
  browserBinaryLocation = linuxFallback;
@@ -2263,7 +2309,7 @@ var __webpack_modules__ = {
2263
2309
  if (!located) throw new Error(getInstallGuidanceText('chrome'));
2264
2310
  const normalized = normalizePath(located || null);
2265
2311
  if (isUsableBinary(normalized)) {
2266
- if (looksOfficialChromeBinaryPath(normalized) && !isWslEnv()) {
2312
+ if (looksOfficialChromeBinaryPath(normalized) && !(0, wsl_support.EV)()) {
2267
2313
  printInstallGuidance(getInstallGuidanceText('chrome'), browser);
2268
2314
  return null;
2269
2315
  }
@@ -2277,7 +2323,7 @@ var __webpack_modules__ = {
2277
2323
  }) || null;
2278
2324
  const normalized = normalizePath(candidate || null);
2279
2325
  if (normalized) {
2280
- if (looksOfficialChromeBinaryPath(normalized) && !isWslEnv()) {
2326
+ if (looksOfficialChromeBinaryPath(normalized) && !(0, wsl_support.EV)()) {
2281
2327
  printInstallGuidance(getInstallGuidanceText('chrome'), browser);
2282
2328
  candidate = null;
2283
2329
  }
@@ -2501,7 +2547,7 @@ var __webpack_modules__ = {
2501
2547
  'pipe',
2502
2548
  'pipe'
2503
2549
  ] : 'ignore';
2504
- const normalizedBinary = normalizeBinaryPathForWsl(binary);
2550
+ const normalizedBinary = (0, wsl_support.f7)(binary);
2505
2551
  try {
2506
2552
  const child = await spawnChromiumProcess({
2507
2553
  binary: normalizedBinary,
@@ -2511,13 +2557,17 @@ var __webpack_modules__ = {
2511
2557
  logger: this.logger
2512
2558
  });
2513
2559
  if ('true' === process.env.EXTENSION_AUTHOR_MODE) this.logger.debug?.('[browser] Final Chrome flags:', launchArgs.join(' '));
2560
+ let disposeSignalHandlers;
2514
2561
  child.on('close', (code)=>{
2515
2562
  if ('true' === process.env.EXTENSION_AUTHOR_MODE) this.logger.info(messages.nnm(code || 0));
2563
+ disposeSignalHandlers?.();
2564
+ const userDataDir = launchArgs.find((arg)=>arg.startsWith('--user-data-dir='))?.slice('--user-data-dir='.length).replace(/^"|"$/g, '');
2565
+ shared_utils.sW(userDataDir);
2516
2566
  });
2517
2567
  child.on('error', (error)=>{
2518
2568
  this.logger.error(messages.Cny(error));
2519
2569
  });
2520
- setupProcessSignalHandlers(this.options?.browser, child, ()=>{});
2570
+ disposeSignalHandlers = setupProcessSignalHandlers(this.options?.browser, child, ()=>{});
2521
2571
  return child;
2522
2572
  } catch (error) {
2523
2573
  this.logger.error(messages.wk1(error));
@@ -2831,65 +2881,88 @@ var __webpack_modules__ = {
2831
2881
  var ready_message = __webpack_require__("./browsers/browsers-lib/ready-message.ts");
2832
2882
  var runtime_options = __webpack_require__("./browsers/browsers-lib/runtime-options.ts");
2833
2883
  var external_child_process_ = __webpack_require__("child_process");
2834
- function setupFirefoxProcessHandlers(browser, childRef, cleanupInstance) {
2835
- let isCleaningUp = false;
2836
- const attemptCleanup = async ()=>{
2837
- if (isCleaningUp) return;
2838
- isCleaningUp = true;
2839
- try {
2840
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(messages.VkK(browser));
2841
- const child = childRef();
2842
- if (child && !child.killed) {
2843
- if ('win32' === process.platform) try {
2844
- (0, external_child_process_.spawn)('taskkill', [
2845
- '/PID',
2846
- String(child.pid),
2847
- '/T',
2848
- '/F'
2849
- ], {
2850
- stdio: 'ignore',
2851
- windowsHide: true
2852
- }).on('error', ()=>{});
2853
- } catch {}
2854
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(messages.XHr(browser));
2855
- child.kill('SIGTERM');
2856
- setTimeout(()=>{
2857
- if (child && !child.killed) {
2858
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(messages.AGJ(browser));
2859
- child.kill('SIGKILL');
2860
- }
2861
- }, 5000);
2862
- }
2863
- await cleanupInstance();
2864
- } catch (error) {
2865
- console.error(messages.TFX(browser, error));
2884
+ const activeInstances = new Set();
2885
+ let globalHandlersInstalled = false;
2886
+ async function attemptCleanup(instance) {
2887
+ if (instance.isCleaningUp) return;
2888
+ instance.isCleaningUp = true;
2889
+ const { browser, childRef, cleanupInstance } = instance;
2890
+ try {
2891
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(messages.VkK(browser));
2892
+ const child = childRef();
2893
+ if (child && !child.killed) {
2894
+ if ('win32' === process.platform) try {
2895
+ (0, external_child_process_.spawn)('taskkill', [
2896
+ '/PID',
2897
+ String(child.pid),
2898
+ '/T',
2899
+ '/F'
2900
+ ], {
2901
+ stdio: 'ignore',
2902
+ windowsHide: true
2903
+ }).on('error', ()=>{});
2904
+ } catch {}
2905
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(messages.XHr(browser));
2906
+ child.kill('SIGTERM');
2907
+ const killTimer = setTimeout(()=>{
2908
+ if (child && !child.killed) {
2909
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(messages.AGJ(browser));
2910
+ child.kill('SIGKILL');
2911
+ }
2912
+ }, 5000);
2913
+ killTimer.unref?.();
2866
2914
  }
2867
- };
2868
- const onExit = ()=>{
2869
- attemptCleanup();
2870
- };
2871
- process.on('exit', onExit);
2872
- const onSignal = ()=>{
2873
- attemptCleanup();
2874
- };
2875
- process.on('SIGINT', onSignal);
2876
- process.on('SIGTERM', onSignal);
2877
- process.on('SIGHUP', onSignal);
2878
- process.on('SIGBREAK', onSignal);
2879
- process.on('beforeExit', onSignal);
2915
+ await cleanupInstance();
2916
+ } catch (error) {
2917
+ console.error(messages.TFX(browser, error));
2918
+ }
2919
+ }
2920
+ function cleanupAllInstances() {
2921
+ for (const instance of activeInstances)attemptCleanup(instance);
2922
+ }
2923
+ function firstBrowserLabel() {
2924
+ for (const instance of activeInstances)return instance.browser;
2925
+ return 'firefox';
2926
+ }
2927
+ function installGlobalHandlersOnce() {
2928
+ if (globalHandlersInstalled) return;
2929
+ globalHandlersInstalled = true;
2930
+ process.on('exit', cleanupAllInstances);
2931
+ process.on('SIGINT', cleanupAllInstances);
2932
+ process.on('SIGTERM', cleanupAllInstances);
2933
+ process.on('SIGHUP', cleanupAllInstances);
2934
+ process.on('SIGBREAK', cleanupAllInstances);
2935
+ process.on('beforeExit', cleanupAllInstances);
2880
2936
  process.on('uncaughtException', async (error)=>{
2881
2937
  if (isBenignSocketTeardown(error)) return;
2882
- console.error(messages.F41(browser, error));
2883
- await attemptCleanup();
2938
+ console.error(messages.F41(firstBrowserLabel(), error));
2939
+ await Promise.all([
2940
+ ...activeInstances
2941
+ ].map((i)=>attemptCleanup(i)));
2884
2942
  process.exit(1);
2885
2943
  });
2886
2944
  process.on('unhandledRejection', async (reason)=>{
2887
2945
  if (isBenignSocketTeardown(reason)) return;
2888
- console.error(messages.N4O(browser, reason));
2889
- await attemptCleanup();
2946
+ console.error(messages.N4O(firstBrowserLabel(), reason));
2947
+ await Promise.all([
2948
+ ...activeInstances
2949
+ ].map((i)=>attemptCleanup(i)));
2890
2950
  process.exit(1);
2891
2951
  });
2892
2952
  }
2953
+ function setupFirefoxProcessHandlers(browser, childRef, cleanupInstance) {
2954
+ const instance = {
2955
+ browser,
2956
+ childRef,
2957
+ cleanupInstance,
2958
+ isCleaningUp: false
2959
+ };
2960
+ activeInstances.add(instance);
2961
+ installGlobalHandlersOnce();
2962
+ return ()=>{
2963
+ activeInstances.delete(instance);
2964
+ };
2965
+ }
2893
2966
  const BENIGN_SOCKET_ERROR_CODES = new Set([
2894
2967
  'ECONNRESET',
2895
2968
  'EPIPE',
@@ -2952,6 +3025,10 @@ var __webpack_modules__ = {
2952
3025
  else obj[key] = value;
2953
3026
  return obj;
2954
3027
  }
3028
+ function rdpRequestTimeoutMs() {
3029
+ const raw = parseInt(String(process.env.EXTENSION_RDP_REQUEST_TIMEOUT_MS || ''), 10);
3030
+ return Number.isFinite(raw) && raw > 0 ? raw : 30000;
3031
+ }
2955
3032
  class RdpTransport extends external_events_default() {
2956
3033
  async connect(port, host = '127.0.0.1') {
2957
3034
  await new Promise((resolve, reject)=>{
@@ -2981,7 +3058,10 @@ var __webpack_modules__ = {
2981
3058
  this.rejectAll(err);
2982
3059
  }
2983
3060
  rejectAll(error) {
2984
- for (const d of this.active.values())d.reject(error);
3061
+ for (const entry of this.active.values()){
3062
+ if (entry.timer) clearTimeout(entry.timer);
3063
+ entry.deferred.reject(error);
3064
+ }
2985
3065
  this.active.clear();
2986
3066
  for (const { deferred } of this.pending)deferred.reject(error);
2987
3067
  this.pending = [];
@@ -3007,7 +3087,10 @@ var __webpack_modules__ = {
3007
3087
  flush() {
3008
3088
  this.pending = this.pending.filter(({ to, payload, deferred })=>{
3009
3089
  if (this.active.has(to)) return true;
3010
- if (!this.conn) throw new Error(messages.FmF('firefox'));
3090
+ if (!this.conn) {
3091
+ deferred.reject(new Error(messages.FmF('firefox')));
3092
+ return false;
3093
+ }
3011
3094
  try {
3012
3095
  this.conn.write(buildRdpFrame(payload));
3013
3096
  this.expectReply(to, deferred);
@@ -3019,7 +3102,19 @@ var __webpack_modules__ = {
3019
3102
  }
3020
3103
  expectReply(to, deferred) {
3021
3104
  if (this.active.has(to)) throw new Error(messages.cD1('firefox', to));
3022
- this.active.set(to, deferred);
3105
+ const timeoutMs = rdpRequestTimeoutMs();
3106
+ const timer = setTimeout(()=>{
3107
+ const entry = this.active.get(to);
3108
+ if (!entry) return;
3109
+ this.active.delete(to);
3110
+ entry.deferred.reject(new Error(`RDP request to "${to}" timed out after ${timeoutMs}ms`));
3111
+ this.flush();
3112
+ }, timeoutMs);
3113
+ timer.unref?.();
3114
+ this.active.set(to, {
3115
+ deferred,
3116
+ timer
3117
+ });
3023
3118
  }
3024
3119
  onData(buf) {
3025
3120
  this.incoming = Buffer.concat([
@@ -3042,17 +3137,19 @@ var __webpack_modules__ = {
3042
3137
  }
3043
3138
  handleMessage(message) {
3044
3139
  if (!message.from) return void this.emit('error', new Error(messages.HHw('firefox', message)));
3045
- const deferred = this.active.get(message.from);
3046
- if (deferred) {
3140
+ const entry = this.active.get(message.from);
3141
+ if (entry) {
3047
3142
  this.active.delete(message.from);
3048
- if (message.error) deferred.reject(message);
3049
- else deferred.resolve(message);
3143
+ if (entry.timer) clearTimeout(entry.timer);
3144
+ if (message.error) entry.deferred.reject(message);
3145
+ else entry.deferred.resolve(message);
3050
3146
  this.flush();
3051
3147
  return;
3052
3148
  }
3053
3149
  this.emit('message', message);
3054
3150
  }
3055
3151
  onEnd() {
3152
+ this.rejectAll(new Error(messages.qNy('firefox')));
3056
3153
  this.emit('end');
3057
3154
  }
3058
3155
  onTimeout() {
@@ -3474,6 +3571,7 @@ var __webpack_modules__ = {
3474
3571
  } catch {}
3475
3572
  return merged;
3476
3573
  }
3574
+ const GET_PAGE_HTML_WITH_SHADOW_EXPRESSION = "(() => { try { var selector = '#extension-root,[data-extension-root]:not([data-extension-root=\"extension-js-devtools\"])'; var serializeShadowRoot = function(shadowRoot, serializer) { if (!shadowRoot) return ''; var stylesheetCss = Array.from(shadowRoot.styleSheets || []).map(function(sheet) { try { return Array.from(sheet.cssRules || []).map(function(rule) { return String(rule.cssText || ''); }).join('\\n'); } catch (e) { return ''; } }).filter(Boolean).join('\\n'); var adoptedCss = Array.from(shadowRoot.adoptedStyleSheets || []).map(function(sheet) { try { return Array.from(sheet.cssRules || []).map(function(rule) { return String(rule.cssText || ''); }).join('\\n'); } catch (e) { return ''; } }).filter(Boolean).join('\\n'); var stylesheetMarkup = stylesheetCss ? '<style>' + stylesheetCss + '</style>' : ''; var adoptedMarkup = adoptedCss ? '<style>' + adoptedCss + '</style>' : ''; var childMarkup = Array.from(shadowRoot.childNodes || []).map(function(node) { try { if (node && node.nodeType === 1 && String(node.nodeName || '').toLowerCase() === 'style') { return '<style>' + String(node.textContent || '') + '</style>'; } return serializer.serializeToString(node); } catch (e) { return ''; } }).join(''); return stylesheetMarkup + adoptedMarkup + childMarkup; }; var cloned = document.documentElement.cloneNode(true); var clonedHosts = Array.from(cloned.querySelectorAll(selector)); var liveHosts = Array.from(document.querySelectorAll(selector)); if (!clonedHosts.length) { var body = cloned.querySelector('body') || cloned; var newRoot = document.createElement('div'); newRoot.id='extension-root'; body.appendChild(newRoot); clonedHosts = [newRoot]; } var s = new XMLSerializer(); for (var i = 0; i < clonedHosts.length; i++) { var host = clonedHosts[i]; var live = liveHosts[i]; var shadow = ''; try { if (live && live.shadowRoot) { shadow = serializeShadowRoot(live.shadowRoot, s); } } catch (e) {} try { host.innerHTML = shadow; } catch (e) {} } return String('<!DOCTYPE html>' + (cloned.outerHTML || document.documentElement.outerHTML)); } catch(e) { try { return String(document.documentElement.outerHTML); } catch(_) { return '' } } })()";
3477
3575
  function messaging_client_define_property(obj, key, value) {
3478
3576
  if (key in obj) Object.defineProperty(obj, key, {
3479
3577
  value: value,
@@ -3563,11 +3661,7 @@ var __webpack_modules__ = {
3563
3661
  }
3564
3662
  }
3565
3663
  async addTab(url) {
3566
- try {
3567
- return await addTab(this.transport, url);
3568
- } catch (e) {
3569
- throw e;
3570
- }
3664
+ return addTab(this.transport, url);
3571
3665
  }
3572
3666
  async navigateViaScript(consoleActor, url) {
3573
3667
  await navigateViaScript(this.transport, consoleActor, url);
@@ -3625,7 +3719,7 @@ var __webpack_modules__ = {
3625
3719
  const shadowContent = await this.extractShadowContent(actorToUse);
3626
3720
  if (!shadowContent) return mainHTML;
3627
3721
  try {
3628
- const mergedResp = await this.evaluateRaw(actorToUse, "(() => { try { var selector = '#extension-root,[data-extension-root]:not([data-extension-root=\"extension-js-devtools\"])'; var serializeShadowRoot = function(shadowRoot, serializer) { if (!shadowRoot) return ''; var stylesheetCss = Array.from(shadowRoot.styleSheets || []).map(function(sheet) { try { return Array.from(sheet.cssRules || []).map(function(rule) { return String(rule.cssText || ''); }).join('\\n'); } catch (e) { return ''; } }).filter(Boolean).join('\\n'); var adoptedCss = Array.from(shadowRoot.adoptedStyleSheets || []).map(function(sheet) { try { return Array.from(sheet.cssRules || []).map(function(rule) { return String(rule.cssText || ''); }).join('\\n'); } catch (e) { return ''; } }).filter(Boolean).join('\\n'); var stylesheetMarkup = stylesheetCss ? '<style>' + stylesheetCss + '</style>' : ''; var adoptedMarkup = adoptedCss ? '<style>' + adoptedCss + '</style>' : ''; var childMarkup = Array.from(shadowRoot.childNodes || []).map(function(node) { try { if (node && node.nodeType === 1 && String(node.nodeName || '').toLowerCase() === 'style') { return '<style>' + String(node.textContent || '') + '</style>'; } return serializer.serializeToString(node); } catch (e) { return ''; } }).join(''); return stylesheetMarkup + adoptedMarkup + childMarkup; }; var cloned = document.documentElement.cloneNode(true); var clonedHosts = Array.from(cloned.querySelectorAll(selector)); var liveHosts = Array.from(document.querySelectorAll(selector)); if (!clonedHosts.length) { var body = cloned.querySelector('body') || cloned; var newRoot = document.createElement('div'); newRoot.id='extension-root'; body.appendChild(newRoot); clonedHosts = [newRoot]; } var s = new XMLSerializer(); for (var i = 0; i < clonedHosts.length; i++) { var host = clonedHosts[i]; var live = liveHosts[i]; var shadow = ''; try { if (live && live.shadowRoot) { shadow = serializeShadowRoot(live.shadowRoot, s); } } catch (e) {} try { host.innerHTML = shadow; } catch (e) {} } return String('<!DOCTYPE html>' + (cloned.outerHTML || document.documentElement.outerHTML)); } catch(e) { try { return String(document.documentElement.outerHTML); } catch(_) { return '' } } })()");
3722
+ const mergedResp = await this.evaluateRaw(actorToUse, GET_PAGE_HTML_WITH_SHADOW_EXPRESSION);
3629
3723
  const mergedHtml = await this.coerceResponseToString(actorToUse, mergedResp, {
3630
3724
  fallbackToFullDocument: false
3631
3725
  });
@@ -3737,7 +3831,8 @@ var __webpack_modules__ = {
3737
3831
  console.log(JSON.stringify(event));
3738
3832
  }
3739
3833
  function resolveAddonDirectory(baseDir, inputPath) {
3740
- let candidate = inputPath.replace(/\"/g, '');
3834
+ let candidate = inputPath.trim();
3835
+ if (candidate.startsWith('"') && candidate.endsWith('"') || candidate.startsWith("'") && candidate.endsWith("'")) candidate = candidate.slice(1, -1);
3741
3836
  if (!external_path_.isAbsolute(candidate)) candidate = external_path_.resolve(baseDir, candidate);
3742
3837
  try {
3743
3838
  const stat = external_fs_.statSync(candidate);
@@ -3979,7 +4074,7 @@ var __webpack_modules__ = {
3979
4074
  const shadowContent = await client.extractShadowContent?.(descriptorActor);
3980
4075
  if (!shadowContent) return mainHTML;
3981
4076
  try {
3982
- const mergedResp = await client.evaluateRaw(descriptorActor, "(() => { try { var selector = '#extension-root,[data-extension-root]:not([data-extension-root=\"extension-js-devtools\"])'; var serializeShadowRoot = function(shadowRoot, serializer) { if (!shadowRoot) return ''; var stylesheetCss = Array.from(shadowRoot.styleSheets || []).map(function(sheet) { try { return Array.from(sheet.cssRules || []).map(function(rule) { return String(rule.cssText || ''); }).join('\\n'); } catch (e) { return ''; } }).filter(Boolean).join('\\n'); var adoptedCss = Array.from(shadowRoot.adoptedStyleSheets || []).map(function(sheet) { try { return Array.from(sheet.cssRules || []).map(function(rule) { return String(rule.cssText || ''); }).join('\\n'); } catch (e) { return ''; } }).filter(Boolean).join('\\n'); var stylesheetMarkup = stylesheetCss ? '<style>' + stylesheetCss + '</style>' : ''; var adoptedMarkup = adoptedCss ? '<style>' + adoptedCss + '</style>' : ''; var childMarkup = Array.from(shadowRoot.childNodes || []).map(function(node) { try { if (node && node.nodeType === 1 && String(node.nodeName || '').toLowerCase() === 'style') { return '<style>' + String(node.textContent || '') + '</style>'; } return serializer.serializeToString(node); } catch (e) { return ''; } }).join(''); return stylesheetMarkup + adoptedMarkup + childMarkup; }; var cloned = document.documentElement.cloneNode(true); var clonedHosts = Array.from(cloned.querySelectorAll(selector)); var liveHosts = Array.from(document.querySelectorAll(selector)); if (!clonedHosts.length) { var body = cloned.querySelector('body') || cloned; var newRoot = document.createElement('div'); newRoot.id='extension-root'; body.appendChild(newRoot); clonedHosts = [newRoot]; } var s = new XMLSerializer(); for (var i = 0; i < clonedHosts.length; i++) { var host = clonedHosts[i]; var live = liveHosts[i]; var shadow = ''; try { if (live && live.shadowRoot) { shadow = serializeShadowRoot(live.shadowRoot, s); } } catch (e) {} try { host.innerHTML = shadow; } catch (e) {} } return String('<!DOCTYPE html>' + (cloned.outerHTML || document.documentElement.outerHTML)); } catch(e) { try { return String(document.documentElement.outerHTML); } catch(_) { return '' } } })()");
4077
+ const mergedResp = await client.evaluateRaw(descriptorActor, GET_PAGE_HTML_WITH_SHADOW_EXPRESSION);
3983
4078
  const mergedHtml = await client.coerceResponseToString?.(descriptorActor, mergedResp, {
3984
4079
  fallbackToFullDocument: false
3985
4080
  });
@@ -4695,8 +4790,6 @@ var __webpack_modules__ = {
4695
4790
  if (profilePath) parts.splice(1, 0, `--profile="${profilePath}"`);
4696
4791
  return parts.join(' ');
4697
4792
  }
4698
- const external_util_namespaceObject = require("util");
4699
- const execFile = (0, external_util_namespaceObject.promisify)(external_child_process_.execFile);
4700
4793
  function parseFlatpakBinary(binary) {
4701
4794
  if (!binary || !binary.startsWith('flatpak:')) return null;
4702
4795
  const appId = binary.substring(8).trim();
@@ -4748,57 +4841,20 @@ var __webpack_modules__ = {
4748
4841
  args
4749
4842
  };
4750
4843
  }
4751
- static async validateFirefoxBinary(binaryPath) {
4752
- try {
4753
- const { stdout } = await execFile(binaryPath, [
4754
- '--version'
4755
- ]);
4756
- const version = stdout.trim();
4757
- return {
4758
- version,
4759
- path: binaryPath
4760
- };
4761
- } catch (error) {
4762
- throw new Error(`Failed to validate Firefox binary: ${error}`);
4763
- }
4764
- }
4765
- }
4766
- var external_os_ = __webpack_require__("os");
4767
- function isWslEnv() {
4768
- if ('linux' !== process.platform) return false;
4769
- const hasWslEnv = Boolean(String(process.env.WSL_DISTRO_NAME || '').trim() || String(process.env.WSL_INTEROP || '').trim() || String(process.env.WSLENV || '').trim());
4770
- if (hasWslEnv) return true;
4771
- return /microsoft/i.test(external_os_.release());
4772
- }
4773
- function hasGuiDisplay() {
4774
- const display = String(process.env.DISPLAY || '').trim();
4775
- const waylandDisplay = String(process.env.WAYLAND_DISPLAY || '').trim();
4776
- return display.length > 0 || waylandDisplay.length > 0;
4777
4844
  }
4845
+ var wsl_support = __webpack_require__("./browsers/browsers-lib/wsl-support.ts");
4778
4846
  const LINUX_FIREFOX_PATHS = [
4779
4847
  '/usr/bin/firefox',
4780
4848
  '/snap/bin/firefox',
4781
4849
  '/opt/firefox/firefox'
4782
4850
  ];
4783
4851
  function resolveWslLinuxBinary() {
4784
- if (!isWslEnv() || !hasGuiDisplay()) return null;
4852
+ if (!(0, wsl_support.EV)() || !(0, wsl_support.qc)()) return null;
4785
4853
  for (const candidate of LINUX_FIREFOX_PATHS)if (external_fs_.existsSync(candidate)) return candidate;
4786
4854
  return null;
4787
4855
  }
4788
- function normalizeBinaryPathForWsl(input) {
4789
- let value = String(input || '').trim();
4790
- if (!value) return value;
4791
- if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) value = value.slice(1, -1);
4792
- if (!isWslEnv()) return value;
4793
- if (/^[a-zA-Z]:[\\/]/.test(value)) {
4794
- const drive = value[0].toLowerCase();
4795
- const rest = value.slice(2).replace(/\\/g, '/').replace(/^\/+/, '');
4796
- return `/mnt/${drive}/${rest}`;
4797
- }
4798
- return value;
4799
- }
4800
4856
  function resolveWslWindowsBinary() {
4801
- if (!isWslEnv()) return null;
4857
+ if (!(0, wsl_support.EV)()) return null;
4802
4858
  const candidates = [
4803
4859
  '/mnt/c/Program Files/Mozilla Firefox/firefox.exe',
4804
4860
  '/mnt/c/Program Files (x86)/Mozilla Firefox/firefox.exe'
@@ -4839,7 +4895,7 @@ var __webpack_modules__ = {
4839
4895
  try {
4840
4896
  return await spawnOnce(binary);
4841
4897
  } catch (error) {
4842
- if (isWslEnv() && fallbackBinary && fallbackBinary !== binary) {
4898
+ if ((0, wsl_support.EV)() && fallbackBinary && fallbackBinary !== binary) {
4843
4899
  logger?.warn?.('[browser] WSL detected: retrying with Windows Firefox binary.');
4844
4900
  return await spawnOnce(fallbackBinary);
4845
4901
  }
@@ -4900,7 +4956,7 @@ var __webpack_modules__ = {
4900
4956
  if (compilationErrors.length > 0) return void this.ctx.logger?.info?.(messages.y7j());
4901
4957
  if ('true' === process.env.EXTENSION_AUTHOR_MODE) this.ctx.logger?.info?.(messages.A9Y());
4902
4958
  const normalizePath = (value)=>{
4903
- const normalized = value ? normalizeBinaryPathForWsl(value) : null;
4959
+ const normalized = value ? (0, wsl_support.f7)(value) : null;
4904
4960
  return normalized && external_fs_.existsSync(normalized) ? normalized : null;
4905
4961
  };
4906
4962
  const resolveManagedBinary = ()=>normalizePath((0, output_binaries_resolver.kI)(compilation, 'firefox') || null);
@@ -4931,7 +4987,7 @@ var __webpack_modules__ = {
4931
4987
  let browserBinaryLocation = resolveManagedBinary();
4932
4988
  let skipDetection = Boolean(browserBinaryLocation);
4933
4989
  const engineBased = 'gecko-based' === this.host.browser || 'firefox-based' === this.host.browser;
4934
- if (!browserBinaryLocation && !engineBased && isWslEnv()) {
4990
+ if (!browserBinaryLocation && !engineBased && (0, wsl_support.EV)()) {
4935
4991
  const linuxFallback = resolveWslLinuxBinary();
4936
4992
  if (linuxFallback) {
4937
4993
  browserBinaryLocation = linuxFallback;
@@ -4988,17 +5044,12 @@ var __webpack_modules__ = {
4988
5044
  }
4989
5045
  }
4990
5046
  const binaryPath = browserBinaryLocation;
4991
- const wslFallbackBinary = isWslEnv() && !engineBased ? resolveWslFallback() : null;
4992
- if (!isFlatpak) {
4993
- try {
4994
- this.host.browserVersionLine = (0, external_firefox_location2_.getFirefoxVersion)(binaryPath, {
4995
- allowExec: true
4996
- }) || '';
4997
- } catch {}
4998
- try {
4999
- await FirefoxBinaryDetector.validateFirefoxBinary(binaryPath);
5000
- } catch {}
5001
- }
5047
+ const wslFallbackBinary = (0, wsl_support.EV)() && !engineBased ? resolveWslFallback() : null;
5048
+ if (!isFlatpak) try {
5049
+ this.host.browserVersionLine = (0, external_firefox_location2_.getFirefoxVersion)(binaryPath, {
5050
+ allowExec: true
5051
+ }) || '';
5052
+ } catch {}
5002
5053
  const extensionsToLoad = (0, runtime_options.fT)(this.host.extension);
5003
5054
  (0, runtime_options.sl)(extensionsToLoad, 'function' == typeof this.ctx.setExtensionRoot ? this.ctx.setExtensionRoot : void 0);
5004
5055
  const desiredDebugPort = (0, shared_utils.jl)(this.host.port, this.host.instanceId);
@@ -5027,6 +5078,9 @@ var __webpack_modules__ = {
5027
5078
  const profilePath = profileMatch[1];
5028
5079
  const { binary, args } = FirefoxBinaryDetector.generateFirefoxArgs(binaryPath, profilePath, debugPort, firefoxArgs);
5029
5080
  this.child = await this.spawnFirefoxChild(binary, args, wslFallbackBinary);
5081
+ this.child.on('close', ()=>{
5082
+ (0, shared_utils.sW)(profilePath);
5083
+ });
5030
5084
  this.wireChildLifecycle();
5031
5085
  const ctrl = await setupRdpAfterLaunch(this.host, compilation, debugPort);
5032
5086
  this.host.rdpController = ctrl;
@@ -5094,6 +5148,7 @@ var __webpack_modules__ = {
5094
5148
  if (process.env.VITEST || process.env.VITEST_WORKER_ID) throw new Error('Firefox startup timed out');
5095
5149
  process.exit(1);
5096
5150
  });
5151
+ let disposeProcessHandlers;
5097
5152
  child.on('close', (_code)=>{
5098
5153
  if (this.watchTimeout) {
5099
5154
  clearTimeout(this.watchTimeout);
@@ -5103,9 +5158,10 @@ var __webpack_modules__ = {
5103
5158
  this.cleanupInstance().catch((err)=>{
5104
5159
  if ('true' === process.env.EXTENSION_AUTHOR_MODE) this.ctx.logger?.error?.(`[browser] Cleanup error on child close: ${err?.message || err}`);
5105
5160
  });
5161
+ disposeProcessHandlers?.();
5106
5162
  });
5107
5163
  this.pipeChildOutput(child);
5108
- setupFirefoxProcessHandlers(this.host.browser, ()=>this.child, ()=>this.cleanupInstance());
5164
+ disposeProcessHandlers = setupFirefoxProcessHandlers(this.host.browser, ()=>this.child, ()=>this.cleanupInstance());
5109
5165
  }
5110
5166
  async cleanupInstance() {
5111
5167
  try {
@@ -5113,11 +5169,12 @@ var __webpack_modules__ = {
5113
5169
  try {
5114
5170
  this.child.kill('SIGTERM');
5115
5171
  } catch {}
5116
- setTimeout(()=>{
5172
+ const killTimer = setTimeout(()=>{
5117
5173
  try {
5118
5174
  if (this.child && !this.child.killed) this.child.kill('SIGKILL');
5119
5175
  } catch {}
5120
5176
  }, 2000);
5177
+ killTimer.unref?.();
5121
5178
  }
5122
5179
  } catch {}
5123
5180
  }