extension-develop 3.17.0 → 3.18.1

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 (43) hide show
  1. package/dist/0~dev-server.mjs +660 -59
  2. package/dist/0~rspack-config.mjs +867 -881
  3. package/dist/0~zip.mjs +39 -10
  4. package/dist/45.mjs +39 -0
  5. package/dist/946.mjs +142 -36
  6. package/dist/962.mjs +299 -250
  7. package/dist/bridge.mjs +228 -0
  8. package/dist/extension-js-devtools/chrome/content_scripts/content-0.js +2 -2
  9. package/dist/extension-js-devtools/chrome/pages/centralized-logger.js +1 -1
  10. package/dist/extension-js-devtools/chrome/pages/welcome.js +2 -2
  11. package/dist/extension-js-devtools/chrome/scripts/logger-client.js +1 -1
  12. package/dist/extension-js-devtools/chromium/content_scripts/content-0.js +2 -2
  13. package/dist/extension-js-devtools/chromium/pages/centralized-logger.js +1 -1
  14. package/dist/extension-js-devtools/chromium/pages/welcome.js +2 -2
  15. package/dist/extension-js-devtools/chromium/scripts/logger-client.js +1 -1
  16. package/dist/extension-js-devtools/edge/content_scripts/content-0.js +2 -2
  17. package/dist/extension-js-devtools/edge/pages/centralized-logger.js +1 -1
  18. package/dist/extension-js-devtools/edge/pages/welcome.js +2 -2
  19. package/dist/extension-js-devtools/edge/scripts/logger-client.js +1 -1
  20. package/dist/extension-js-devtools/extension-js/chrome/events.ndjson +2 -0
  21. package/dist/extension-js-devtools/extension-js/chrome/ready.json +16 -0
  22. package/dist/extension-js-devtools/extension-js/chromium/events.ndjson +2 -0
  23. package/dist/extension-js-devtools/extension-js/chromium/ready.json +16 -0
  24. package/dist/extension-js-devtools/extension-js/edge/events.ndjson +2 -0
  25. package/dist/extension-js-devtools/extension-js/edge/ready.json +16 -0
  26. package/dist/extension-js-devtools/extension-js/firefox/events.ndjson +2 -0
  27. package/dist/extension-js-devtools/extension-js/firefox/ready.json +16 -0
  28. package/dist/extension-js-devtools/firefox/content_scripts/content-0.js +2 -2
  29. package/dist/extension-js-devtools/firefox/pages/centralized-logger.js +1 -1
  30. package/dist/extension-js-devtools/firefox/pages/welcome.js +2 -2
  31. package/dist/extension-js-devtools/firefox/scripts/logger-client.js +1 -1
  32. package/dist/extension-js-theme/extension-js/chrome/events.ndjson +2 -0
  33. package/dist/extension-js-theme/extension-js/chrome/ready.json +16 -0
  34. package/dist/extension-js-theme/extension-js/chromium/events.ndjson +2 -0
  35. package/dist/extension-js-theme/extension-js/chromium/ready.json +16 -0
  36. package/dist/extension-js-theme/extension-js/edge/events.ndjson +2 -0
  37. package/dist/extension-js-theme/extension-js/edge/ready.json +16 -0
  38. package/dist/extension-js-theme/extension-js/firefox/events.ndjson +4 -0
  39. package/dist/extension-js-theme/extension-js/firefox/ready.json +16 -0
  40. package/dist/feature-scripts-content-script-wrapper.js +19 -2
  41. package/dist/feature-scripts-content-script-wrapper.mjs +19 -2
  42. package/package.json +14 -5
  43. package/runtime/process-shim.cjs +49 -0
package/dist/0~zip.mjs CHANGED
@@ -1,7 +1,27 @@
1
1
  import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
2
2
  import adm_zip from "adm-zip";
3
- import { unpackagingExtension, failedToDownloadOrExtractZIPFileError, invalidRemoteZip, unpackagedSuccessfully, downloadingText } from "./946.mjs";
3
+ import { unpackagingExtension, failedToDownloadOrExtractZIPFileError, invalidRemoteZip, notAZipArchive, unpackagedSuccessfully, localZipNotFound, downloadingText } from "./946.mjs";
4
4
  import * as __rspack_external_path from "path";
5
+ import * as __rspack_external_fs from "fs";
6
+ function isZipBuffer(buffer) {
7
+ if (buffer.length < 4) return false;
8
+ if (0x50 !== buffer[0] || 0x4b !== buffer[1]) return false;
9
+ const third = buffer[2];
10
+ const fourth = buffer[3];
11
+ return 0x03 === third && 0x04 === fourth || 0x05 === third && 0x06 === fourth || 0x07 === third && 0x08 === fourth;
12
+ }
13
+ function extractBuffer(zipBuffer, destinationPath) {
14
+ console.log(unpackagingExtension(destinationPath));
15
+ const zip = new adm_zip(zipBuffer);
16
+ zip.extractAllTo(destinationPath, true);
17
+ console.log(unpackagedSuccessfully());
18
+ }
19
+ function asZipError(error) {
20
+ console.error(failedToDownloadOrExtractZIPFileError(error));
21
+ const err = new Error(`${failedToDownloadOrExtractZIPFileError(error)}`);
22
+ err.code = 'EZIP';
23
+ return err;
24
+ }
5
25
  async function downloadAndExtractZip(url, targetPath) {
6
26
  const urlNoSearchParams = url.split('?')[0];
7
27
  try {
@@ -17,18 +37,27 @@ async function downloadAndExtractZip(url, targetPath) {
17
37
  const extname = __rspack_external_path.extname(urlNoSearchParams);
18
38
  const basename = __rspack_external_path.basename(urlNoSearchParams, extname);
19
39
  const destinationPath = __rspack_external_path.join(targetPath, basename);
20
- console.log(unpackagingExtension(destinationPath));
21
40
  const arrayBuffer = await res.arrayBuffer();
22
41
  const zipBuffer = Buffer.from(arrayBuffer);
23
- const zip = new adm_zip(zipBuffer);
24
- zip.extractAllTo(destinationPath, true);
25
- console.log(unpackagedSuccessfully());
42
+ if (!isZipBuffer(zipBuffer)) throw new Error(`${notAZipArchive(urlNoSearchParams, contentType)}`);
43
+ extractBuffer(zipBuffer, destinationPath);
44
+ return destinationPath;
45
+ } catch (error) {
46
+ throw asZipError(error);
47
+ }
48
+ }
49
+ async function extractLocalZip(zipFilePath, targetPath) {
50
+ try {
51
+ if (!__rspack_external_fs.existsSync(zipFilePath) || !__rspack_external_fs.statSync(zipFilePath).isFile()) throw new Error(`${localZipNotFound(zipFilePath)}`);
52
+ const extname = __rspack_external_path.extname(zipFilePath);
53
+ const basename = __rspack_external_path.basename(zipFilePath, extname);
54
+ const destinationPath = __rspack_external_path.join(targetPath, basename);
55
+ const zipBuffer = __rspack_external_fs.readFileSync(zipFilePath);
56
+ if (!isZipBuffer(zipBuffer)) throw new Error(`${notAZipArchive(zipFilePath)}`);
57
+ extractBuffer(zipBuffer, destinationPath);
26
58
  return destinationPath;
27
59
  } catch (error) {
28
- console.error(failedToDownloadOrExtractZIPFileError(error));
29
- const err = new Error(`${failedToDownloadOrExtractZIPFileError(error)}`);
30
- err.code = 'EZIP';
31
- throw err;
60
+ throw asZipError(error);
32
61
  }
33
62
  }
34
- export { downloadAndExtractZip };
63
+ export { downloadAndExtractZip, extractLocalZip };
package/dist/45.mjs ADDED
@@ -0,0 +1,39 @@
1
+ import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
2
+ import * as __rspack_external_fs from "fs";
3
+ import * as __rspack_external_path from "path";
4
+ import * as __rspack_external_crypto from "crypto";
5
+ const CONTROL_WS_PATH = '/extjs-control';
6
+ function controlTokenPath(projectPath) {
7
+ return __rspack_external_path.resolve(projectPath, '.extension-js', 'control.token');
8
+ }
9
+ function writeControlToken(projectPath) {
10
+ const token = __rspack_external_crypto.randomBytes(32).toString('hex');
11
+ const file = controlTokenPath(projectPath);
12
+ __rspack_external_fs.mkdirSync(__rspack_external_path.dirname(file), {
13
+ recursive: true
14
+ });
15
+ __rspack_external_fs.writeFileSync(file, token, {
16
+ encoding: 'utf-8',
17
+ mode: 384
18
+ });
19
+ try {
20
+ __rspack_external_fs.chmodSync(file, 384);
21
+ } catch {}
22
+ return token;
23
+ }
24
+ function readControlToken(projectPath) {
25
+ try {
26
+ const token = __rspack_external_fs.readFileSync(controlTokenPath(projectPath), 'utf-8').trim();
27
+ return token.length ? token : null;
28
+ } catch {
29
+ return null;
30
+ }
31
+ }
32
+ function clearControlToken(projectPath) {
33
+ try {
34
+ __rspack_external_fs.rmSync(controlTokenPath(projectPath), {
35
+ force: true
36
+ });
37
+ } catch {}
38
+ }
39
+ export { CONTROL_WS_PATH, clearControlToken, controlTokenPath, readControlToken, writeControlToken };
package/dist/946.mjs CHANGED
@@ -12,7 +12,7 @@ import * as __rspack_external_path from "path";
12
12
  import * as __rspack_external_fs from "fs";
13
13
  import * as __rspack_external_os from "os";
14
14
  import * as __rspack_external_vm from "vm";
15
- var package_namespaceObject = JSON.parse('{"rE":"3.17.0","El":{"@prefresh/core":"1.5.9","@prefresh/utils":"1.2.1","@rspack/core":"^2.0.1","@rspack/dev-server":"^2.0.1","@rspack/plugin-preact-refresh":"1.1.5","@rspack/plugin-react-refresh":"1.6.2","@swc/core":"^1.15.8","@swc/helpers":"^0.5.18","@vue/compiler-sfc":"3.5.26","adm-zip":"^0.5.16","browser-extension-manifest-fields":"^2.2.3","case-sensitive-paths-webpack-plugin":"^2.4.0","content-security-policy-parser":"^0.6.0","cross-spawn":"^7.0.6","dotenv":"^17.2.3","extension-from-store":"^0.1.1","go-git-it":"^5.1.5","ignore":"^7.0.5","less":"4.5.1","less-loader":"12.3.2","loader-utils":"^3.3.1","magic-string":"^0.30.21","parse5-utilities":"^1.0.0","pintor":"0.3.0","postcss":"8.5.10","postcss-loader":"8.2.1","postcss-preset-env":"11.1.1","postcss-scss":"4.0.9","preact":"10.27.3","react-refresh":"0.18.0","sass-loader":"16.0.7","schema-utils":"^4.3.3","svelte-loader":"3.2.4","tiny-glob":"^0.2.9","typescript":"5.9.3","unique-names-generator":"^4.7.1","vue":"3.5.26","vue-loader":"17.4.2","webextension-polyfill":"^0.12.0","webpack-merge":"^6.0.1","webpack-target-webextension":"^2.1.3"}}');
15
+ var package_namespaceObject = JSON.parse('{"rE":"3.18.1","El":{"@prefresh/core":"1.5.9","@prefresh/utils":"1.2.1","@rspack/core":"^2.0.1","@rspack/dev-server":"2.0.1","@rspack/plugin-preact-refresh":"1.1.5","@rspack/plugin-react-refresh":"1.6.2","@swc/core":"^1.15.8","@swc/helpers":"^0.5.18","@vue/compiler-sfc":"3.5.26","adm-zip":"^0.5.16","browser-extension-manifest-fields":"^2.2.3","case-sensitive-paths-webpack-plugin":"^2.4.0","content-security-policy-parser":"^0.6.0","cross-spawn":"^7.0.6","dotenv":"^17.2.3","extension-from-store":"^0.1.1","go-git-it":"^5.1.5","ignore":"^7.0.5","less":"4.5.1","less-loader":"12.3.2","loader-utils":"^3.3.1","magic-string":"^0.30.21","parse5-utilities":"^1.0.0","pintor":"0.3.0","postcss":"8.5.10","postcss-loader":"8.2.1","postcss-preset-env":"11.1.1","postcss-scss":"4.0.9","preact":"10.27.3","react-refresh":"0.18.0","sass-loader":"16.0.7","schema-utils":"^4.3.3","svelte-loader":"3.2.4","tiny-glob":"^0.2.9","typescript":"5.9.3","unique-names-generator":"^4.7.1","vue":"3.5.26","vue-loader":"17.4.2","webextension-polyfill":"^0.12.0","webpack-merge":"^6.0.1","webpack-target-webextension":"^2.1.3","ws":"^8.20.1"}}');
16
16
  const fmt = {
17
17
  heading: (title)=>pintor.underline(pintor.blue(title)),
18
18
  label: (key)=>pintor.gray(key.toUpperCase()),
@@ -55,6 +55,13 @@ function resolvedWorkspaceManifest(projectPath, manifestPath) {
55
55
  const display = __rspack_external_path.relative(projectPath, packageDir) || packageDir;
56
56
  return `${getLoggingPrefix('info')} ${pintor.gray('Workspace root detected — resolved extension package:')} ${pintor.brightBlue(display)}`;
57
57
  }
58
+ function remoteFetchTimedOut(target, ms) {
59
+ return `${getLoggingPrefix('error')} Timed out after ${pintor.yellow(`${Math.round(ms / 1000)}s`)} fetching ${pintor.underline(target)}.\n${pintor.red('Check your network, or set EXTENSION_FETCH_TIMEOUT_MS to allow more time.')}`;
60
+ }
61
+ function manifestInvalidJson(manifestPath, error) {
62
+ const detail = error instanceof Error ? error.message : String(error);
63
+ return `${getLoggingPrefix('error')} Could not parse manifest.json — it is not valid JSON.\n${pintor.red('Fix the syntax error and try again.')}\n${pintor.gray('PATH')} ${pintor.underline(manifestPath)}\n${pintor.red(detail)}`;
64
+ }
58
65
  function manifestNotFoundError(manifestPath, candidates = []) {
59
66
  const base = `${getLoggingPrefix('error')} Manifest file not found.\n${pintor.red('Ensure the path to your extension exists and try again.')}\n${pintor.red('NOT FOUND')}\n${pintor.gray('PATH')} ${pintor.underline(manifestPath)}`;
60
67
  if (!candidates.length) return base;
@@ -237,6 +244,12 @@ function failedToDownloadOrExtractZIPFileError(error) {
237
244
  function invalidRemoteZip(url, contentType) {
238
245
  return `${getLoggingPrefix('error')} Remote URL does not appear to be a ZIP archive.\n${pintor.gray('URL')} ${pintor.underline(url)}\n${pintor.gray('Content-Type')} ${pintor.underline(contentType || 'unknown')}`;
239
246
  }
247
+ function notAZipArchive(source, contentType) {
248
+ return `${getLoggingPrefix('error')} The downloaded content is not a ZIP archive.\n${pintor.gray('SOURCE')} ${pintor.underline(source)}\n` + (contentType ? `${pintor.gray('Content-Type')} ${pintor.underline(contentType)}\n` : '') + "This usually means the URL requires authentication (for example a Slack, Google Drive, or Dropbox file page) and returned an HTML login page instead of the file. Download the ZIP through the browser and pass the local path instead, or use a direct-download URL.";
249
+ }
250
+ function localZipNotFound(zipFilePath) {
251
+ return `${getLoggingPrefix('error')} ZIP file not found.\n${pintor.gray('PATH')} ${pintor.underline(zipFilePath)}`;
252
+ }
240
253
  function capitalizedBrowserName(browser) {
241
254
  const b = String(browser || '');
242
255
  const cap = b.charAt(0).toUpperCase() + b.slice(1);
@@ -405,6 +418,22 @@ const isUrl = (url)=>{
405
418
  return false;
406
419
  }
407
420
  };
421
+ const REMOTE_FETCH_TIMEOUT_MS = (()=>{
422
+ const raw = parseInt(String(process.env.EXTENSION_FETCH_TIMEOUT_MS || ''), 10);
423
+ return Number.isFinite(raw) && raw > 0 ? raw : 60000;
424
+ })();
425
+ function withTimeout(task, ms, label) {
426
+ let timer;
427
+ const timeout = new Promise((_, reject)=>{
428
+ timer = setTimeout(()=>reject(new Error(remoteFetchTimedOut(label, ms))), ms);
429
+ });
430
+ return Promise.race([
431
+ task,
432
+ timeout
433
+ ]).finally(()=>{
434
+ if (timer) clearTimeout(timer);
435
+ });
436
+ }
408
437
  async function importUrlSourceFromGithub(pathOrRemoteUrl, text) {
409
438
  const cwd = process.cwd();
410
439
  const url = new URL(pathOrRemoteUrl);
@@ -445,7 +474,7 @@ async function importUrlSourceFromGithub(pathOrRemoteUrl, text) {
445
474
  } catch {}
446
475
  async function tryGitClone() {
447
476
  const { default: goGitIt } = await import("go-git-it");
448
- await goGitIt(pathOrRemoteUrl, cwd, text);
477
+ await withTimeout(goGitIt(pathOrRemoteUrl, cwd, text), REMOTE_FETCH_TIMEOUT_MS, pathOrRemoteUrl);
449
478
  }
450
479
  async function tryZipFallback() {
451
480
  const branch = -1 !== treeIndex && segments.length > treeIndex + 1 ? segments[treeIndex + 1] : 'main';
@@ -492,9 +521,14 @@ async function importUrlSourceFromGithub(pathOrRemoteUrl, text) {
492
521
  async function importUrlSourceFromZip(pathOrRemoteUrl) {
493
522
  const cwd = process.cwd();
494
523
  const { downloadAndExtractZip } = await import("./0~zip.mjs");
495
- const extractedPath = await downloadAndExtractZip(pathOrRemoteUrl, cwd);
524
+ const extractedPath = await withTimeout(downloadAndExtractZip(pathOrRemoteUrl, cwd), REMOTE_FETCH_TIMEOUT_MS, pathOrRemoteUrl);
496
525
  return extractedPath;
497
526
  }
527
+ async function importLocalSourceFromZip(zipFilePath) {
528
+ const cwd = process.cwd();
529
+ const { extractLocalZip } = await import("./0~zip.mjs");
530
+ return await extractLocalZip(zipFilePath, cwd);
531
+ }
498
532
  async function getProjectPath(pathOrRemoteUrl) {
499
533
  if (!pathOrRemoteUrl) return process.cwd();
500
534
  if (isUrl(pathOrRemoteUrl)) {
@@ -516,7 +550,9 @@ async function getProjectPath(pathOrRemoteUrl) {
516
550
  return urlSource;
517
551
  }
518
552
  }
519
- return __rspack_external_path.resolve(process.cwd(), pathOrRemoteUrl);
553
+ const resolvedPath = __rspack_external_path.resolve(process.cwd(), pathOrRemoteUrl);
554
+ if ('.zip' === __rspack_external_path.extname(resolvedPath).toLowerCase() && __rspack_external_fs.existsSync(resolvedPath) && __rspack_external_fs.statSync(resolvedPath).isFile()) return await importLocalSourceFromZip(resolvedPath);
555
+ return resolvedPath;
520
556
  }
521
557
  function collectManifestCandidates(rootDir, maxDepth) {
522
558
  const SKIP_DIRS = new Set([
@@ -572,20 +608,27 @@ async function getProjectStructure(pathOrRemoteUrl) {
572
608
  console.log(resolvedWorkspaceManifest(projectPath, manifestPath));
573
609
  } else throw new Error(manifestNotFoundError(manifestPath, relativeCandidates));
574
610
  } else {
575
- const findManifest = (dir)=>{
576
- const files = __rspack_external_fs.readdirSync(dir, {
577
- withFileTypes: true
578
- });
611
+ const MAX_DEPTH = 5;
612
+ const findManifest = (dir, depth)=>{
613
+ if (depth > MAX_DEPTH) return null;
614
+ let files;
615
+ try {
616
+ files = __rspack_external_fs.readdirSync(dir, {
617
+ withFileTypes: true
618
+ });
619
+ } catch {
620
+ return null;
621
+ }
579
622
  for (const file of files){
580
623
  if (file.isFile() && 'manifest.json' === file.name) return __rspack_external_path.join(dir, file.name);
581
624
  if (file.isDirectory() && !file.name.startsWith('.') && 'node_modules' !== file.name && 'dist' !== file.name && 'public' !== file.name) {
582
- const found = findManifest(__rspack_external_path.join(dir, file.name));
625
+ const found = findManifest(__rspack_external_path.join(dir, file.name), depth + 1);
583
626
  if (found) return found;
584
627
  }
585
628
  }
586
629
  return null;
587
630
  };
588
- const foundManifest = findManifest(projectPath);
631
+ const foundManifest = findManifest(projectPath, 0);
589
632
  if (foundManifest) manifestPath = foundManifest;
590
633
  else throw new Error(manifestNotFoundError(manifestPath));
591
634
  }
@@ -683,8 +726,21 @@ function preloadEnvFiles(projectDir) {
683
726
  if (workspaceRoot && workspaceRoot !== projectDir) return preloadEnvFilesFromDir(workspaceRoot);
684
727
  return local;
685
728
  }
729
+ const loadedConfigCache = new Map();
686
730
  async function loadConfigFile(configPath) {
687
731
  const absolutePath = __rspack_external_path.resolve(configPath);
732
+ const cached = loadedConfigCache.get(absolutePath);
733
+ if (cached) return cached;
734
+ const loading = loadConfigFileUncached(absolutePath);
735
+ loadedConfigCache.set(absolutePath, loading);
736
+ try {
737
+ return await loading;
738
+ } catch (error) {
739
+ loadedConfigCache.delete(absolutePath);
740
+ throw error;
741
+ }
742
+ }
743
+ async function loadConfigFileUncached(absolutePath) {
688
744
  const projectDir = __rspack_external_path.dirname(absolutePath);
689
745
  preloadEnvFiles(projectDir);
690
746
  try {
@@ -694,11 +750,12 @@ async function loadConfigFile(configPath) {
694
750
  return required?.default || required;
695
751
  }
696
752
  let esmImportPath = absolutePath;
753
+ let shimTmpDir;
697
754
  try {
698
755
  const originalContent = __rspack_external_fs.readFileSync(absolutePath, 'utf-8');
699
756
  if (originalContent.includes('import.meta.env')) {
700
- const tmpDir = __rspack_external_fs.mkdtempSync(__rspack_external_path.join(__rspack_external_os.tmpdir(), 'extension-config-esm-'));
701
- const tmpPath = __rspack_external_path.join(tmpDir, __rspack_external_path.basename(absolutePath));
757
+ shimTmpDir = __rspack_external_fs.mkdtempSync(__rspack_external_path.join(__rspack_external_os.tmpdir(), 'extension-config-esm-'));
758
+ const tmpPath = __rspack_external_path.join(shimTmpDir, __rspack_external_path.basename(absolutePath));
702
759
  const envObjectLiteral = JSON.stringify(Object.fromEntries(Object.entries(process.env).map(([k, v])=>[
703
760
  k,
704
761
  v
@@ -709,8 +766,17 @@ async function loadConfigFile(configPath) {
709
766
  esmImportPath = tmpPath;
710
767
  }
711
768
  } catch {}
712
- const module = await import(pathToFileURL(esmImportPath).href);
713
- return module.default || module;
769
+ try {
770
+ const module = await import(pathToFileURL(esmImportPath).href);
771
+ return module.default || module;
772
+ } finally{
773
+ if (shimTmpDir) try {
774
+ __rspack_external_fs.rmSync(shimTmpDir, {
775
+ recursive: true,
776
+ force: true
777
+ });
778
+ } catch {}
779
+ }
714
780
  } catch (err) {
715
781
  const error = err;
716
782
  try {
@@ -726,9 +792,18 @@ async function loadConfigFile(configPath) {
726
792
  required = loadCommonJsConfigWithStableDirname(absolutePath);
727
793
  } catch {
728
794
  const tmpDir = __rspack_external_fs.mkdtempSync(__rspack_external_path.join(__rspack_external_os.tmpdir(), 'extension-config-'));
729
- const tmpCjsPath = __rspack_external_path.join(tmpDir, __rspack_external_path.basename(absolutePath, __rspack_external_path.extname(absolutePath)) + '.cjs');
730
- __rspack_external_fs.copyFileSync(absolutePath, tmpCjsPath);
731
- required = requireFn(tmpCjsPath);
795
+ try {
796
+ const tmpCjsPath = __rspack_external_path.join(tmpDir, __rspack_external_path.basename(absolutePath, __rspack_external_path.extname(absolutePath)) + '.cjs');
797
+ __rspack_external_fs.copyFileSync(absolutePath, tmpCjsPath);
798
+ required = requireFn(tmpCjsPath);
799
+ } finally{
800
+ try {
801
+ __rspack_external_fs.rmSync(tmpDir, {
802
+ recursive: true,
803
+ force: true
804
+ });
805
+ } catch {}
806
+ }
732
807
  }
733
808
  else throw requireErr;
734
809
  }
@@ -739,7 +814,7 @@ async function loadConfigFile(configPath) {
739
814
  const content = __rspack_external_fs.readFileSync(absolutePath, 'utf-8');
740
815
  return JSON.parse(content);
741
816
  } catch (jsonErr) {
742
- throw new Error(`Failed to load config file: ${configPath}\nError: ${error.message || error}`);
817
+ throw new Error(`Failed to load config file: ${absolutePath}\nError: ${error.message || error}`);
743
818
  }
744
819
  }
745
820
  }
@@ -776,10 +851,14 @@ async function loadCommandConfig(projectPath, command) {
776
851
  const baseTranspilePackages = userConfig && Array.isArray(userConfig.transpilePackages) ? {
777
852
  transpilePackages: userConfig.transpilePackages
778
853
  } : {};
854
+ const basePerfBudgets = userConfig && userConfig.perfBudgets && 'object' == typeof userConfig.perfBudgets ? {
855
+ perfBudgets: userConfig.perfBudgets
856
+ } : {};
779
857
  const perCommand = userConfig && userConfig.commands && userConfig.commands[command] ? userConfig.commands[command] : {};
780
858
  return {
781
859
  ...baseExtensions,
782
860
  ...baseTranspilePackages,
861
+ ...basePerfBudgets,
783
862
  ...perCommand
784
863
  };
785
864
  } catch (err) {
@@ -830,6 +909,11 @@ async function config_loader_isUsingExperimentalConfig(projectPath) {
830
909
  }
831
910
  return false;
832
911
  }
912
+ function isReferencedAsModuleSpecifier(configSource, dep) {
913
+ const escaped = dep.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
914
+ const specifierRe = new RegExp(`['"\`]${escaped}(?:/[^'"\`]*)?['"\`]`);
915
+ return specifierRe.test(configSource);
916
+ }
833
917
  function assertNoManagedDependencyConflicts(userPackageJsonPath, projectPath) {
834
918
  try {
835
919
  const raw = __rspack_external_fs.readFileSync(userPackageJsonPath, 'utf-8');
@@ -851,7 +935,7 @@ function assertNoManagedDependencyConflicts(userPackageJsonPath, projectPath) {
851
935
  if (!hasConfig) return;
852
936
  const configPath = __rspack_external_fs.existsSync(userConfigJs) ? userConfigJs : userConfigMjs;
853
937
  const configSource = __rspack_external_fs.readFileSync(configPath, 'utf-8');
854
- const duplicates = userDeps.filter((d)=>managedDeps.has(d)).filter((d)=>configSource.includes(d)).sort();
938
+ const duplicates = userDeps.filter((d)=>managedDeps.has(d)).filter((d)=>isReferencedAsModuleSpecifier(configSource, d)).sort();
855
939
  if (duplicates.length > 0) {
856
940
  console.error(managedDependencyConflict(duplicates, userPackageJsonPath));
857
941
  process.exit(1);
@@ -898,7 +982,7 @@ function needsInstall(packageJsonDir) {
898
982
  return true;
899
983
  }
900
984
  }
901
- function normalizeBrowser(browser, chromiumBinary, geckoBinary) {
985
+ function normalizeBrowser(browser, chromiumBinary, geckoBinary, safariBinary) {
902
986
  const requested = String(browser || '');
903
987
  if (chromiumBinary) {
904
988
  if (!requested || 'chromium-based' === requested) return 'chromium-based';
@@ -910,6 +994,10 @@ function normalizeBrowser(browser, chromiumBinary, geckoBinary) {
910
994
  if (!requested || 'gecko-based' === requested || 'firefox-based' === requested) return 'gecko-based';
911
995
  if ('firefox' === requested) return 'firefox';
912
996
  }
997
+ if (safariBinary) {
998
+ if (!requested || 'webkit-based' === requested) return 'webkit-based';
999
+ if ('safari' === requested) return 'safari';
1000
+ }
913
1001
  switch(requested){
914
1002
  case 'chrome':
915
1003
  return 'chrome';
@@ -924,8 +1012,12 @@ function normalizeBrowser(browser, chromiumBinary, geckoBinary) {
924
1012
  case 'gecko-based':
925
1013
  case 'firefox-based':
926
1014
  return 'gecko-based';
1015
+ case 'safari':
1016
+ return 'safari';
1017
+ case 'webkit-based':
1018
+ return 'webkit-based';
927
1019
  default:
928
- return browser || 'chrome';
1020
+ return 'chrome';
929
1021
  }
930
1022
  }
931
1023
  function getDistPath(packageJsonDir, browser) {
@@ -1222,21 +1314,27 @@ function createPlaywrightMetadataWriter(options) {
1222
1314
  const metadataDir = getPlaywrightMetadataDir(options.packageJsonDir, options.browser);
1223
1315
  const readyPath = asAbsolute(__rspack_external_path.join(metadataDir, 'ready.json'));
1224
1316
  const eventsPath = asAbsolute(__rspack_external_path.join(metadataDir, 'events.ndjson'));
1317
+ const toPort = (value)=>{
1318
+ if ('number' == typeof value && Number.isFinite(value)) return value;
1319
+ if ('string' == typeof value) {
1320
+ const parsed = parseInt(value, 10);
1321
+ return Number.isFinite(parsed) ? parsed : null;
1322
+ }
1323
+ return null;
1324
+ };
1225
1325
  const base = {
1326
+ schemaVersion: 2,
1226
1327
  command: options.command,
1227
1328
  browser: options.browser,
1228
1329
  runId: createRunId(),
1229
1330
  startedAt: nowISO(),
1230
1331
  distPath: options.distPath,
1231
1332
  manifestPath: options.manifestPath,
1232
- port: (()=>{
1233
- if ('number' == typeof options.port && Number.isFinite(options.port)) return options.port;
1234
- if ('string' == typeof options.port) {
1235
- const parsed = parseInt(options.port, 10);
1236
- return Number.isFinite(parsed) ? parsed : null;
1237
- }
1238
- return null;
1239
- })()
1333
+ port: toPort(options.port),
1334
+ instanceId: options.instanceId,
1335
+ controlPort: toPort(options.controlPort),
1336
+ controlPath: options.controlPath,
1337
+ logsPath: options.logsPath
1240
1338
  };
1241
1339
  function writeReady(status, extra) {
1242
1340
  plugin_playwright_ensureDirSync(metadataDir);
@@ -1250,6 +1348,12 @@ function createPlaywrightMetadataWriter(options) {
1250
1348
  };
1251
1349
  if (extra?.code) payload.code = extra.code;
1252
1350
  if (extra?.message) payload.message = extra.message;
1351
+ try {
1352
+ if (__rspack_external_fs.existsSync(readyPath)) {
1353
+ const prev = JSON.parse(__rspack_external_fs.readFileSync(readyPath, 'utf-8'));
1354
+ if ('number' == typeof prev.cdpPort) payload.cdpPort = prev.cdpPort;
1355
+ }
1356
+ } catch {}
1253
1357
  writeJsonAtomic(readyPath, payload);
1254
1358
  }
1255
1359
  function appendEvent(event) {
@@ -1295,7 +1399,11 @@ class PlaywrightPlugin {
1295
1399
  command: this.command,
1296
1400
  distPath: options.outputPath,
1297
1401
  manifestPath: options.manifestPath,
1298
- port: options.port
1402
+ port: options.port,
1403
+ instanceId: options.instanceId,
1404
+ controlPort: options.controlPort,
1405
+ controlPath: options.controlPath,
1406
+ logsPath: options.logsPath
1299
1407
  });
1300
1408
  }
1301
1409
  apply(compiler) {
@@ -1311,13 +1419,11 @@ class PlaywrightPlugin {
1311
1419
  compiler.hooks.done.tap(PlaywrightPlugin.name, (stats)=>{
1312
1420
  const durationMs = Number((stats?.compilation?.endTime || 0) - (stats?.compilation?.startTime || 0));
1313
1421
  const hasErrors = Boolean(stats?.hasErrors?.());
1314
- const errorsCount = Number(Array.isArray(stats?.toJson?.({
1315
- all: false,
1316
- errors: true
1317
- })?.errors) ? stats.toJson({
1422
+ const errorsJson = stats?.toJson?.({
1318
1423
  all: false,
1319
1424
  errors: true
1320
- }).errors.length : 0);
1425
+ });
1426
+ const errorsCount = Array.isArray(errorsJson?.errors) ? errorsJson.errors.length : 0;
1321
1427
  if (hasErrors) {
1322
1428
  this.writer.appendEvent({
1323
1429
  type: 'compile_error',
@@ -1724,4 +1830,4 @@ async function extensionPreview(pathOrRemoteUrl, previewOptions, browserLauncher
1724
1830
  await browserLauncher(resolvedOpts);
1725
1831
  metadata.writeReady();
1726
1832
  }
1727
- export { PlaywrightPlugin, asAbsolute, assertNoManagedDependencyConflicts, authorInstallNotice, autoExitForceKill, autoExitModeEnabled, autoExitTriggered, browserRunnerDisabled, buildCommandFailed, buildSuccess, buildSuccessWithWarnings, buildWarningsDetails, buildWebpack, bundlerFatalError, bundlerRecompiling, computeExtensionsToLoad, createPlaywrightMetadataWriter, debugBrowser, debugContextPath, debugDirs, debugExtensionsToLoad, debugOutputPath, devServerStartTimeout, downloadingText, extensionJsRunnerError, extensionPreview, failedToDownloadOrExtractZIPFileError, getDirs, getDistPath, getProjectStructure, getSpecialFoldersDataForCompiler, getSpecialFoldersDataForProjectRoot, invalidRemoteZip, loadBrowserConfig, loadCommandConfig, loadCustomConfig, messages_ready, needsInstall, noCompanionExtensionsResolved, noEntrypointsDetected, normalizeBrowser, package_namespaceObject, packagingDistributionFiles, packagingSourceFiles, portInUse, resolveCompanionExtensionsConfig, sanitize, spacerLine, treeWithDistFilesbrowser, treeWithSourceAndDistFiles, treeWithSourceFiles, unpackagedSuccessfully, unpackagingExtension, writingTypeDefinitions, writingTypeDefinitionsError };
1833
+ export { PlaywrightPlugin, asAbsolute, assertNoManagedDependencyConflicts, authorInstallNotice, autoExitForceKill, autoExitModeEnabled, autoExitTriggered, browserRunnerDisabled, buildCommandFailed, buildSuccess, buildSuccessWithWarnings, buildWarningsDetails, buildWebpack, bundlerFatalError, bundlerRecompiling, computeExtensionsToLoad, createPlaywrightMetadataWriter, debugBrowser, debugContextPath, debugDirs, debugExtensionsToLoad, debugOutputPath, devServerStartTimeout, downloadingText, extensionJsRunnerError, extensionPreview, failedToDownloadOrExtractZIPFileError, getDirs, getDistPath, getProjectStructure, getSpecialFoldersDataForCompiler, getSpecialFoldersDataForProjectRoot, invalidRemoteZip, loadBrowserConfig, loadCommandConfig, loadCustomConfig, localZipNotFound, manifestInvalidJson, messages_ready, needsInstall, noCompanionExtensionsResolved, noEntrypointsDetected, normalizeBrowser, notAZipArchive, package_namespaceObject, packagingDistributionFiles, packagingSourceFiles, portInUse, resolveCompanionExtensionDirs, resolveCompanionExtensionsConfig, sanitize, spacerLine, treeWithDistFilesbrowser, treeWithSourceAndDistFiles, treeWithSourceFiles, unpackagedSuccessfully, unpackagingExtension, writingTypeDefinitions, writingTypeDefinitionsError };