extension-develop 3.16.1 → 3.17.0-canary.312.672c4f2

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 (25) hide show
  1. package/dist/0~dev-server.mjs +21 -57
  2. package/dist/0~rspack-config.mjs +399 -909
  3. package/dist/0~zip.mjs +39 -10
  4. package/dist/946.mjs +117 -27
  5. package/dist/962.mjs +65 -18
  6. package/dist/extension-js-devtools/chrome/content_scripts/content-0.js +2 -2
  7. package/dist/extension-js-devtools/chrome/pages/centralized-logger.js +1 -1
  8. package/dist/extension-js-devtools/chrome/pages/welcome.js +2 -2
  9. package/dist/extension-js-devtools/chrome/scripts/logger-client.js +1 -1
  10. package/dist/extension-js-devtools/chromium/content_scripts/content-0.js +2 -2
  11. package/dist/extension-js-devtools/chromium/pages/centralized-logger.js +1 -1
  12. package/dist/extension-js-devtools/chromium/pages/welcome.js +2 -2
  13. package/dist/extension-js-devtools/chromium/scripts/logger-client.js +1 -1
  14. package/dist/extension-js-devtools/edge/content_scripts/content-0.js +2 -2
  15. package/dist/extension-js-devtools/edge/pages/centralized-logger.js +1 -1
  16. package/dist/extension-js-devtools/edge/pages/welcome.js +2 -2
  17. package/dist/extension-js-devtools/edge/scripts/logger-client.js +1 -1
  18. package/dist/extension-js-devtools/firefox/content_scripts/content-0.js +2 -2
  19. package/dist/extension-js-devtools/firefox/pages/centralized-logger.js +1 -1
  20. package/dist/extension-js-devtools/firefox/pages/welcome.js +2 -2
  21. package/dist/extension-js-devtools/firefox/scripts/logger-client.js +1 -1
  22. package/dist/feature-scripts-content-script-wrapper.js +19 -2
  23. package/dist/feature-scripts-content-script-wrapper.mjs +19 -2
  24. package/package.json +6 -4
  25. 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/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.16.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"}}');
15
+ var package_namespaceObject = JSON.parse('{"rE":"3.17.0-canary.312.672c4f2","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"}}');
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) {
@@ -1311,13 +1403,11 @@ class PlaywrightPlugin {
1311
1403
  compiler.hooks.done.tap(PlaywrightPlugin.name, (stats)=>{
1312
1404
  const durationMs = Number((stats?.compilation?.endTime || 0) - (stats?.compilation?.startTime || 0));
1313
1405
  const hasErrors = Boolean(stats?.hasErrors?.());
1314
- const errorsCount = Number(Array.isArray(stats?.toJson?.({
1406
+ const errorsJson = stats?.toJson?.({
1315
1407
  all: false,
1316
1408
  errors: true
1317
- })?.errors) ? stats.toJson({
1318
- all: false,
1319
- errors: true
1320
- }).errors.length : 0);
1409
+ });
1410
+ const errorsCount = Array.isArray(errorsJson?.errors) ? errorsJson.errors.length : 0;
1321
1411
  if (hasErrors) {
1322
1412
  this.writer.appendEvent({
1323
1413
  type: 'compile_error',
@@ -1724,4 +1814,4 @@ async function extensionPreview(pathOrRemoteUrl, previewOptions, browserLauncher
1724
1814
  await browserLauncher(resolvedOpts);
1725
1815
  metadata.writeReady();
1726
1816
  }
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 };
1817
+ 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 };
package/dist/962.mjs CHANGED
@@ -523,6 +523,7 @@ async function extensionBuild(pathOrRemoteUrl, buildOptions) {
523
523
  }
524
524
  });
525
525
  });
526
+ if (('safari' === browser || 'webkit-based' === browser) && buildOptions?.safariPackager) await buildOptions.safariPackager(distPath, 'full');
526
527
  return summary;
527
528
  } catch (error) {
528
529
  const isAuthor = 'true' === process.env.EXTENSION_AUTHOR_MODE;
@@ -687,6 +688,44 @@ function readContentScriptCount(compilation, outputPath) {
687
688
  } catch {}
688
689
  return 0;
689
690
  }
691
+ class SafariDevPlugin {
692
+ packager;
693
+ static name = 'safari-dev';
694
+ emitter = new BuildEmitter();
695
+ extensionsToLoad = [];
696
+ firstRun = true;
697
+ constructor(packager){
698
+ this.packager = packager;
699
+ }
700
+ apply(compiler) {
701
+ compiler.hooks.done.tapPromise(SafariDevPlugin.name, async (stats)=>{
702
+ const compilation = stats.compilation;
703
+ const hasErrors = compilation.errors && compilation.errors.length > 0;
704
+ if (hasErrors) return void this.emitter.emit('error', {
705
+ errors: compilation.errors.map((e)=>'string' == typeof e ? e : e.message || String(e))
706
+ });
707
+ const outputPath = String(compilation.options?.output?.path || '');
708
+ const contextDir = String(compilation.options?.context || '');
709
+ const wasFirstRun = this.firstRun;
710
+ try {
711
+ await this.packager(outputPath, wasFirstRun ? 'full' : 'resync');
712
+ } catch (error) {
713
+ this.emitter.emit('error', {
714
+ errors: [
715
+ error instanceof Error ? error.message : String(error)
716
+ ]
717
+ });
718
+ return;
719
+ }
720
+ this.firstRun = false;
721
+ this.emitter.emit('compiled', {
722
+ outputPath,
723
+ contextDir,
724
+ isFirstCompile: wasFirstRun
725
+ });
726
+ });
727
+ }
728
+ }
690
729
  function isUsingIntegration(name) {
691
730
  return `${pintor.gray('⏵⏵⏵')} Using ${pintor.brightBlue(name)}...`;
692
731
  }
@@ -1245,26 +1284,30 @@ function hasTypeScriptSourceFiles(projectPath) {
1245
1284
  return false;
1246
1285
  }
1247
1286
  }
1248
- function isUsingTypeScript(projectPath) {
1287
+ function hasTypeScriptDependency(projectPath) {
1249
1288
  const packageJsonDirectory = findNearestPackageJsonDirectory(projectPath);
1289
+ if (!packageJsonDirectory) return false;
1290
+ const packageJson = parseJsonSafe(__rspack_external_fs.readFileSync(__rspack_external_path.join(packageJsonDirectory, 'package.json'), 'utf8'));
1291
+ return !!(packageJson?.devDependencies?.typescript || packageJson?.dependencies?.typescript);
1292
+ }
1293
+ function isUsingTypeScript(projectPath) {
1250
1294
  const tsConfigFilePath = getUserTypeScriptConfigFile(projectPath);
1251
- const packageJson = packageJsonDirectory ? parseJsonSafe(__rspack_external_fs.readFileSync(__rspack_external_path.join(packageJsonDirectory, 'package.json'), 'utf8')) : void 0;
1252
- const TypeScriptAsDevDep = packageJson?.devDependencies?.typescript;
1253
- const TypeScriptAsDep = packageJson?.dependencies?.typescript;
1295
+ if (!tsConfigFilePath) return false;
1296
+ return hasTypeScriptDependency(projectPath) || hasTypeScriptSourceFiles(projectPath);
1297
+ }
1298
+ function ensureTypeScriptConfig(projectPath) {
1299
+ if (hasShownUserMessage) return;
1300
+ const tsConfigFilePath = getUserTypeScriptConfigFile(projectPath);
1301
+ const hasDep = hasTypeScriptDependency(projectPath);
1254
1302
  const hasTsFiles = hasTypeScriptSourceFiles(projectPath);
1255
- if (!hasShownUserMessage) {
1256
- if (TypeScriptAsDevDep || TypeScriptAsDep || hasTsFiles) if (tsConfigFilePath) {
1257
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(`${pintor.brightMagenta('⏵⏵⏵ Author says')} ${isUsingIntegration('TypeScript')}`);
1258
- } else if (hasTsFiles) {
1259
- const errorMessage = '[Extension.js] Missing tsconfig.json next to package.json. Create one to use TypeScript.';
1260
- throw new Error(errorMessage);
1261
- } else {
1262
- console.log(creatingTSConfig());
1263
- writeTsConfig(projectPath);
1264
- }
1265
- hasShownUserMessage = true;
1303
+ if (hasDep || hasTsFiles) if (tsConfigFilePath) {
1304
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(`${pintor.brightMagenta('⏵⏵⏵ Author says')} ${isUsingIntegration('TypeScript')}`);
1305
+ } else if (hasTsFiles) throw new Error('[Extension.js] Missing tsconfig.json next to package.json. Create one to use TypeScript.');
1306
+ else {
1307
+ console.log(creatingTSConfig());
1308
+ writeTsConfig(projectPath);
1266
1309
  }
1267
- return !!tsConfigFilePath && !!(TypeScriptAsDevDep || TypeScriptAsDep || hasTsFiles);
1310
+ hasShownUserMessage = true;
1268
1311
  }
1269
1312
  function defaultTypeScriptConfig(projectPath, _opts) {
1270
1313
  return {
@@ -1315,6 +1358,7 @@ async function extensionDev(pathOrRemoteUrl, devOptions) {
1315
1358
  const { manifestDir, packageJsonDir } = getDirs(projectStructure);
1316
1359
  await ensureDevelopArtifacts();
1317
1360
  if (false !== devOptions.install) await ensureUserProjectDependencies(packageJsonDir);
1361
+ ensureTypeScriptConfig(manifestDir);
1318
1362
  if (isUsingTypeScript(manifestDir)) await generateExtensionTypes(manifestDir, packageJsonDir);
1319
1363
  if (projectStructure.packageJsonPath) assertNoManagedDependencyConflicts(projectStructure.packageJsonPath, manifestDir);
1320
1364
  const browser = normalizeBrowser(devOptions.browser || 'chrome', devOptions.chromiumBinary, devOptions.geckoBinary || devOptions.firefoxBinary);
@@ -1330,7 +1374,10 @@ async function extensionDev(pathOrRemoteUrl, devOptions) {
1330
1374
  ...sanitize(commandConfig),
1331
1375
  ...sanitize(devOptions)
1332
1376
  };
1333
- if (devOptions.launcher && !devOptions.noBrowser) {
1377
+ if (('safari' === browser || 'webkit-based' === browser) && !devOptions.noBrowser && devOptions.safariPackager) {
1378
+ browsersPlugin = new SafariDevPlugin(devOptions.safariPackager);
1379
+ emitter = browsersPlugin.emitter;
1380
+ } else if (devOptions.launcher && !devOptions.noBrowser) {
1334
1381
  browsersPlugin = new BrowsersPlugin({
1335
1382
  launcher: devOptions.launcher,
1336
1383
  browserOptions: {
@@ -1386,4 +1433,4 @@ async function extensionDev(pathOrRemoteUrl, devOptions) {
1386
1433
  process.exit(1);
1387
1434
  }
1388
1435
  }
1389
- export { BuildEmitter, ensureOptionalContractModuleLoaded, extensionBuild, extensionDev, getUserTypeScriptConfigFile, hasDependency, isUsingCustomLoader, isUsingIntegration, isUsingTypeScript, jsFrameworksConfigsDetected, jsFrameworksHmrSummary, jsFrameworksIntegrationsEnabled, loadOptionalContractModuleWithoutInstall, optional_deps_resolver_ensureOptionalContractPackageResolved, parseJsonSafe, resolveDevelopDistFile, resolveDevelopInstallRoot, resolveOptionalContractPackageWithoutInstall, resolveOptionalDependencySync };
1436
+ export { BuildEmitter, ensureOptionalContractModuleLoaded, ensureTypeScriptConfig, extensionBuild, extensionDev, getUserTypeScriptConfigFile, hasDependency, isUsingCustomLoader, isUsingIntegration, isUsingTypeScript, jsFrameworksConfigsDetected, jsFrameworksHmrSummary, jsFrameworksIntegrationsEnabled, loadOptionalContractModuleWithoutInstall, optional_deps_resolver_ensureOptionalContractPackageResolved, parseJsonSafe, resolveDevelopDistFile, resolveDevelopInstallRoot, resolveOptionalContractPackageWithoutInstall, resolveOptionalDependencySync };