extension-develop 3.0.0-next.6 → 3.0.0-next.7

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.
package/dist/module.js CHANGED
@@ -78,13 +78,18 @@ var __webpack_modules__ = {
78
78
  },
79
79
  "./webpack/webpack-lib/messages.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
80
80
  __webpack_require__.d(__webpack_exports__, {
81
+ $T: ()=>debugOutputPath,
82
+ KH: ()=>debugExtensionsToLoad,
81
83
  LO: ()=>buildWebpack,
82
84
  N$: ()=>manifestNotFoundError,
83
85
  Nv: ()=>installingDependencies,
86
+ OF: ()=>debugDirs,
84
87
  QC: ()=>failedToDownloadOrExtractZIPFileError,
85
88
  QR: ()=>fetchingProjectPath,
89
+ Ry: ()=>debugBrowser,
86
90
  WF: ()=>unpackagingExtension,
87
91
  WW: ()=>previewing,
92
+ ZE: ()=>debugContextPath,
88
93
  _n: ()=>writingTypeDefinitions,
89
94
  aP: ()=>unpackagedSuccessfully,
90
95
  cq: ()=>downloadingText,
@@ -96,6 +101,7 @@ var __webpack_modules__ = {
96
101
  oM: ()=>managedDependencyConflict,
97
102
  rF: ()=>configLoadingError,
98
103
  vC: ()=>installingDependenciesFailed,
104
+ vQ: ()=>debugPreviewOutput,
99
105
  vX: ()=>downloadedProjectFolderNotFound,
100
106
  wX: ()=>invalidRemoteZip,
101
107
  z$: ()=>buildSuccess,
@@ -239,6 +245,26 @@ var __webpack_modules__ = {
239
245
  function installingDependencies() {
240
246
  return `${getLoggingPrefix('info')} Installing project dependencies...`;
241
247
  }
248
+ function debugDirs(manifestDir, packageJsonDir) {
249
+ return `${getLoggingPrefix('info')} Directories\n${pintor__WEBPACK_IMPORTED_MODULE_2___default().gray('MANIFEST_DIR')} ${pintor__WEBPACK_IMPORTED_MODULE_2___default().underline(manifestDir)}\n${pintor__WEBPACK_IMPORTED_MODULE_2___default().gray('PACKAGE_JSON_DIR')} ${pintor__WEBPACK_IMPORTED_MODULE_2___default().underline(packageJsonDir)}`;
250
+ }
251
+ function debugBrowser(browser, chromiumBinary, geckoBinary) {
252
+ return `${getLoggingPrefix('info')} Browser Target\n${pintor__WEBPACK_IMPORTED_MODULE_2___default().gray('BROWSER')} ${pintor__WEBPACK_IMPORTED_MODULE_2___default().yellow(String(browser))}\n${pintor__WEBPACK_IMPORTED_MODULE_2___default().gray('CHROMIUM_BINARY')} ${pintor__WEBPACK_IMPORTED_MODULE_2___default().underline(String(chromiumBinary || 'auto'))}\n${pintor__WEBPACK_IMPORTED_MODULE_2___default().gray('GECKO_BINARY')} ${pintor__WEBPACK_IMPORTED_MODULE_2___default().underline(String(geckoBinary || 'auto'))}`;
253
+ }
254
+ function debugOutputPath(pathValue) {
255
+ return `${getLoggingPrefix('info')} Output Path\n${pintor__WEBPACK_IMPORTED_MODULE_2___default().gray('PATH')} ${pintor__WEBPACK_IMPORTED_MODULE_2___default().underline(pathValue)}`;
256
+ }
257
+ function debugPreviewOutput(outputPath, distPath) {
258
+ return `${getLoggingPrefix('info')} Preview Output\n${pintor__WEBPACK_IMPORTED_MODULE_2___default().gray('OUTPUT')} ${pintor__WEBPACK_IMPORTED_MODULE_2___default().underline(outputPath)}\n${pintor__WEBPACK_IMPORTED_MODULE_2___default().gray('DIST')} ${pintor__WEBPACK_IMPORTED_MODULE_2___default().underline(distPath)}`;
259
+ }
260
+ function debugContextPath(packageJsonDir) {
261
+ return `${getLoggingPrefix('info')} Context\n${pintor__WEBPACK_IMPORTED_MODULE_2___default().gray('CONTEXT')} ${pintor__WEBPACK_IMPORTED_MODULE_2___default().underline(packageJsonDir)}`;
262
+ }
263
+ function debugExtensionsToLoad(extensions) {
264
+ const header = `${getLoggingPrefix('info')} Extensions To Load (${extensions.length})`;
265
+ const list = extensions.map((e)=>`- ${pintor__WEBPACK_IMPORTED_MODULE_2___default().underline(e)}`).join('\n');
266
+ return `${header}\n${list}`;
267
+ }
242
268
  function installingDependenciesFailed(gitCommand, gitArgs, code) {
243
269
  return `${getLoggingPrefix('error')} Command ${pintor__WEBPACK_IMPORTED_MODULE_2___default().gray(gitCommand)} ${pintor__WEBPACK_IMPORTED_MODULE_2___default().gray(gitArgs.join(' '))} failed.\n${pintor__WEBPACK_IMPORTED_MODULE_2___default().red(`exit code ${pintor__WEBPACK_IMPORTED_MODULE_2___default().gray(String(code))}`)}`;
244
270
  }
@@ -292,7 +318,7 @@ var __webpack_modules__ = {
292
318
  });
293
319
  },
294
320
  "./package.json": function(module) {
295
- module.exports = JSON.parse('{"i8":"3.0.0-next.5","HO":{"@rspack/core":"^1.6.3","@rspack/dev-server":"^1.1.4","@swc/core":"^1.13.2","@swc/helpers":"^0.5.15","adm-zip":"^0.5.16","browser-extension-manifest-fields":"^2.2.1","case-sensitive-paths-webpack-plugin":"^2.4.0","chokidar":"^4.0.1","chrome-location2":"3.2.1","chromium-location":"1.2.3","content-security-policy-parser":"^0.6.0","cross-spawn":"^7.0.6","dotenv":"^16.4.7","edge-location":"^2.1.1","firefox-location2":"2.1.1","go-git-it":"^5.0.0","ignore":"^6.0.2","loader-utils":"^3.3.1","magic-string":"^0.30.10","package-manager-detector":"^0.2.7","parse5":"^7.2.1","parse5-utilities":"^1.0.0","pintor":"0.3.0","schema-utils":"^4.2.0","tiny-glob":"^0.2.9","unique-names-generator":"^4.7.1","webextension-polyfill":"^0.12.0","webpack-merge":"^6.0.1","webpack-target-webextension":"^2.1.3","ws":"^8.18.0"},"Lq":{"@prefresh/core":"^1.5.2","@prefresh/utils":"^1.2.0","@prefresh/webpack":"^4.0.1","@rspack/plugin-preact-refresh":"^1.1.2","@rspack/plugin-react-refresh":"^1.0.1","@vue/compiler-sfc":"^3.5.13","babel-loader":"^9.2.1","less-loader":"^12.2.0","postcss-loader":"^8.1.1","postcss-preset-env":"^10.1.1","react-refresh":"^0.14.2","sass-loader":"^16.0.4","svelte-loader":"^3.2.4","vue-loader":"^17.4.2","vue-style-loader":"^4.1.3"}}');
321
+ module.exports = JSON.parse('{"i8":"3.0.0-next.6","HO":{"@rspack/core":"^1.6.3","@rspack/dev-server":"^1.1.4","@swc/core":"^1.13.2","@swc/helpers":"^0.5.15","adm-zip":"^0.5.16","browser-extension-manifest-fields":"^2.2.1","case-sensitive-paths-webpack-plugin":"^2.4.0","chokidar":"^4.0.1","chrome-location2":"3.2.1","chromium-location":"1.2.3","content-security-policy-parser":"^0.6.0","cross-spawn":"^7.0.6","dotenv":"^16.4.7","edge-location":"^2.1.1","firefox-location2":"2.1.1","go-git-it":"^5.0.0","ignore":"^6.0.2","loader-utils":"^3.3.1","magic-string":"^0.30.10","package-manager-detector":"^0.2.7","parse5":"^7.2.1","parse5-utilities":"^1.0.0","pintor":"0.3.0","schema-utils":"^4.2.0","tiny-glob":"^0.2.9","unique-names-generator":"^4.7.1","webextension-polyfill":"^0.12.0","webpack-merge":"^6.0.1","webpack-target-webextension":"^2.1.3","ws":"^8.18.0"},"Lq":{"@prefresh/core":"^1.5.2","@prefresh/utils":"^1.2.0","@prefresh/webpack":"^4.0.1","@rspack/plugin-preact-refresh":"^1.1.2","@rspack/plugin-react-refresh":"^1.0.1","@vue/compiler-sfc":"^3.5.13","babel-loader":"^9.2.1","less-loader":"^12.2.0","postcss-loader":"^8.1.1","postcss-preset-env":"^10.1.1","react-refresh":"^0.14.2","sass-loader":"^16.0.4","svelte-loader":"^3.2.4","vue-loader":"^17.4.2","vue-style-loader":"^4.1.3"}}');
296
322
  }
297
323
  };
298
324
  var __webpack_module_cache__ = {};
@@ -369,12 +395,12 @@ var __webpack_exports__ = {};
369
395
  extensionPreview: ()=>extensionPreview,
370
396
  extensionStart: ()=>extensionStart
371
397
  });
372
- var external_fs_ = __webpack_require__("fs");
373
- var external_path_ = __webpack_require__("path");
374
- var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_);
375
398
  const core_namespaceObject = require("@rspack/core");
376
399
  var core_default = /*#__PURE__*/ __webpack_require__.n(core_namespaceObject);
377
400
  const external_webpack_merge_namespaceObject = require("webpack-merge");
401
+ var external_path_ = __webpack_require__("path");
402
+ var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_);
403
+ var external_fs_ = __webpack_require__("fs");
378
404
  var webpack_lib_messages = __webpack_require__("./webpack/webpack-lib/messages.ts");
379
405
  async function findUpLocal(filename, options) {
380
406
  const root = external_path_.parse(options.cwd).root;
@@ -836,6 +862,84 @@ var __webpack_exports__ = {};
836
862
  error: (...args)=>console.error(...args.map(sanitize))
837
863
  };
838
864
  }
865
+ function asAbsolute(p) {
866
+ return external_path_.isAbsolute(p) ? p : external_path_.resolve(p);
867
+ }
868
+ function getDirs(struct) {
869
+ const manifestDir = asAbsolute(external_path_.dirname(struct.manifestPath));
870
+ const packageJsonDir = asAbsolute(struct.packageJsonPath ? external_path_.dirname(struct.packageJsonPath) : manifestDir);
871
+ return {
872
+ manifestDir,
873
+ packageJsonDir
874
+ };
875
+ }
876
+ function getNodeModulesDir(packageJsonDir) {
877
+ return asAbsolute(external_path_.join(packageJsonDir, 'node_modules'));
878
+ }
879
+ function needsInstall(packageJsonDir) {
880
+ const nm = getNodeModulesDir(packageJsonDir);
881
+ try {
882
+ return !external_fs_.existsSync(nm) || 0 === external_fs_.readdirSync(nm).length;
883
+ } catch {
884
+ return true;
885
+ }
886
+ }
887
+ function normalizeBrowser(browser, chromiumBinary, geckoBinary) {
888
+ if (chromiumBinary) return 'chromium-based';
889
+ if (geckoBinary) return 'gecko-based';
890
+ switch(String(browser || '')){
891
+ case 'chrome':
892
+ return 'chrome';
893
+ case 'edge':
894
+ return 'edge';
895
+ case 'chromium':
896
+ case 'chromium-based':
897
+ return 'chromium';
898
+ case 'firefox':
899
+ case 'firefox-based':
900
+ case 'gecko-based':
901
+ return 'firefox';
902
+ default:
903
+ return browser || 'chrome';
904
+ }
905
+ }
906
+ function getDistPath(packageJsonDir, browser) {
907
+ return asAbsolute(external_path_.join(packageJsonDir, 'dist', browser));
908
+ }
909
+ function computePreviewOutputPath(struct, browser, explicitOutputPath) {
910
+ const { manifestDir, packageJsonDir } = getDirs(struct);
911
+ if (explicitOutputPath) return asAbsolute(explicitOutputPath);
912
+ if (struct.packageJsonPath) {
913
+ const distDir = getDistPath(packageJsonDir, browser);
914
+ try {
915
+ if (external_fs_.existsSync(external_path_.join(distDir, 'manifest.json'))) return distDir;
916
+ } catch {}
917
+ }
918
+ return manifestDir;
919
+ }
920
+ function ensureDirSync(dir) {
921
+ try {
922
+ if (!external_fs_.existsSync(dir)) external_fs_.mkdirSync(dir, {
923
+ recursive: true
924
+ });
925
+ } catch {}
926
+ }
927
+ function devtoolsEngineFor(browser) {
928
+ switch(browser){
929
+ case 'chrome':
930
+ return 'chrome';
931
+ case 'edge':
932
+ return 'edge';
933
+ case 'chromium':
934
+ case 'chromium-based':
935
+ return 'chromium';
936
+ case 'firefox':
937
+ case 'gecko-based':
938
+ return 'firefox';
939
+ default:
940
+ return 'chrome';
941
+ }
942
+ }
839
943
  function filterKeysForThisBrowser(manifest, browser) {
840
944
  const CHROMIUM_BASED_BROWSERS = [
841
945
  'chrome',
@@ -863,6 +967,60 @@ var __webpack_exports__ = {};
863
967
  });
864
968
  return patchedManifest;
865
969
  }
970
+ function getDarkModeDefaults(browser) {
971
+ if ('chrome' === browser || 'edge' === browser || 'chromium' === browser || 'chromium-based' === browser) return {
972
+ browserFlags: [
973
+ '--force-dark-mode',
974
+ '--enable-features=WebUIDarkMode'
975
+ ],
976
+ preferences: {}
977
+ };
978
+ if ('firefox' === browser || 'gecko-based' === browser || 'firefox-based' === browser) return {
979
+ browserFlags: [],
980
+ preferences: {
981
+ 'ui.systemUsesDarkTheme': 1,
982
+ 'layout.css.prefers-color-scheme.content-override': 2,
983
+ 'devtools.theme': 'dark'
984
+ }
985
+ };
986
+ return {
987
+ browserFlags: [],
988
+ preferences: {}
989
+ };
990
+ }
991
+ function withDarkMode(config) {
992
+ const defaults = getDarkModeDefaults(config.browser);
993
+ const existingFlags = Array.isArray(config.browserFlags) ? [
994
+ ...config.browserFlags
995
+ ] : [];
996
+ const nextFlags = [
997
+ ...existingFlags
998
+ ];
999
+ for (const flag of defaults.browserFlags || [])if (!nextFlags.some((f)=>String(f).trim() === flag)) nextFlags.push(flag);
1000
+ const nextPreferences = {
1001
+ ...config.preferences || {},
1002
+ ...Object.fromEntries(Object.entries(defaults.preferences || {}).filter(([k])=>!(k in (config.preferences || {}))))
1003
+ };
1004
+ return {
1005
+ ...config,
1006
+ browserFlags: nextFlags,
1007
+ preferences: nextPreferences
1008
+ };
1009
+ }
1010
+ function computeExtensionsToLoad(baseDir, mode, browser, userExtensionOutputPath) {
1011
+ const list = [];
1012
+ try {
1013
+ const engine = devtoolsEngineFor(browser);
1014
+ const devtoolsRoot = external_path_.resolve(baseDir, '../dist/extension-js-devtools');
1015
+ const themeRoot = external_path_.resolve(baseDir, '../dist/extension-js-theme');
1016
+ const devtoolsForBrowser = external_path_.join(devtoolsRoot, engine);
1017
+ const themeForBrowser = external_path_.join(themeRoot, engine);
1018
+ if ('production' !== mode && external_fs_.existsSync(devtoolsForBrowser)) list.push(devtoolsForBrowser);
1019
+ if (external_fs_.existsSync(themeForBrowser)) list.push(themeForBrowser);
1020
+ } catch {}
1021
+ list.push(userExtensionOutputPath);
1022
+ return list;
1023
+ }
866
1024
  const external_case_sensitive_paths_webpack_plugin_namespaceObject = require("case-sensitive-paths-webpack-plugin");
867
1025
  var external_case_sensitive_paths_webpack_plugin_default = /*#__PURE__*/ __webpack_require__.n(external_case_sensitive_paths_webpack_plugin_namespaceObject);
868
1026
  function _define_property(obj, key, value) {
@@ -1443,11 +1601,15 @@ var __webpack_exports__ = {};
1443
1601
  }
1444
1602
  async function maybeUsePostCss(projectPath, opts) {
1445
1603
  if (!isUsingPostCss(projectPath)) return {};
1604
+ const userPostCssConfig = findPostCssConfig(projectPath);
1446
1605
  try {
1447
1606
  require.resolve('postcss-loader');
1448
1607
  } catch (e) {
1449
1608
  if (!isUsingSass(projectPath) && !isUsingLess(projectPath)) {
1450
- const postCssDependencies = [
1609
+ const postCssDependencies = userPostCssConfig ? [
1610
+ 'postcss',
1611
+ 'postcss-loader'
1612
+ ] : [
1451
1613
  'postcss',
1452
1614
  'postcss-loader',
1453
1615
  'postcss-preset-env'
@@ -1464,8 +1626,8 @@ var __webpack_exports__ = {};
1464
1626
  options: {
1465
1627
  postcssOptions: {
1466
1628
  ident: 'postcss',
1467
- config: findPostCssConfig(projectPath),
1468
- plugins: [
1629
+ config: userPostCssConfig,
1630
+ plugins: userPostCssConfig ? [] : [
1469
1631
  [
1470
1632
  'postcss-preset-env',
1471
1633
  {
@@ -7229,28 +7391,25 @@ var __webpack_exports__ = {};
7229
7391
  } catch {}
7230
7392
  }
7231
7393
  } catch {}
7394
+ let browserNorm = 'chromium';
7395
+ if ('chromium-based' === browser) browserNorm = 'chromium';
7396
+ else if ('gecko-based' === browser) browserNorm = 'firefox';
7397
+ else if ('chrome' === browser || 'chromium' === browser || 'firefox' === browser || 'edge' === browser) browserNorm = browser;
7398
+ const finalCachePath = browserNorm && cacheDir ? external_path_.join(cacheDir, browserNorm) : cacheDir;
7232
7399
  try {
7233
- if (cacheDir && cacheDir.trim().length > 0) {
7400
+ if (finalCachePath && finalCachePath.trim().length > 0) {
7234
7401
  const lines = cleaned.split(/\r?\n/);
7235
7402
  const idx = lines.findIndex((l)=>/npx\s+@puppeteer\/browsers\s+install\s+/i.test(l));
7236
7403
  if (-1 !== idx && !/--path\s+/i.test(lines[idx])) {
7237
- lines[idx] = `${lines[idx].trim()} --path "${cacheDir}"`;
7404
+ lines[idx] = `${lines[idx].trim()} --path "${finalCachePath}"`;
7238
7405
  cleaned = lines.join('\n');
7239
7406
  }
7240
7407
  try {
7241
7408
  const pwIdx = lines.findIndex((l)=>/npx\s+playwright\s+install(\s+.+)?/i.test(l));
7242
7409
  if (-1 !== pwIdx) {
7243
- const browserNorm = (()=>{
7244
- const b = String(browser || '').toLowerCase();
7245
- if ('chromium-based' === b) return 'chromium';
7246
- if ('gecko-based' === b) return 'firefox';
7247
- if ('chrome' === b || 'chromium' === b || 'firefox' === b || 'edge' === b) return b;
7248
- return 'chrome';
7249
- })();
7250
- const finalPath = browserNorm && cacheDir ? external_path_.join(cacheDir, browserNorm) : cacheDir;
7251
- if (finalPath && finalPath.trim().length > 0) {
7410
+ if (finalCachePath && finalCachePath.trim().length > 0) {
7252
7411
  const cmd = lines[pwIdx].trim();
7253
- const withEnv = 'win32' === process.platform ? `set PLAYWRIGHT_BROWSERS_PATH="${finalPath}" && ${cmd}` : `PLAYWRIGHT_BROWSERS_PATH="${finalPath}" ${cmd}`;
7412
+ const withEnv = 'win32' === process.platform ? `set PLAYWRIGHT_BROWSERS_PATH="${finalCachePath}" && ${cmd}` : `PLAYWRIGHT_BROWSERS_PATH="${finalCachePath}" ${cmd}`;
7254
7413
  lines[pwIdx] = withEnv;
7255
7414
  cleaned = lines.join('\n');
7256
7415
  }
@@ -7259,7 +7418,7 @@ var __webpack_exports__ = {};
7259
7418
  }
7260
7419
  } catch {}
7261
7420
  body.push(cleaned);
7262
- if (cacheDir) body.push(`${dim('INSTALL PATH')} ${external_pintor_default().underline(cacheDir)}`);
7421
+ if (finalCachePath) body.push(`${dim('INSTALL PATH')} ${external_pintor_default().underline(finalCachePath)}`);
7263
7422
  return body.join('\n') + '\n';
7264
7423
  }
7265
7424
  function firefoxLaunchCalled() {
@@ -7649,6 +7808,29 @@ var __webpack_exports__ = {};
7649
7808
  function getLastCDPPort() {
7650
7809
  return lastCDPPort;
7651
7810
  }
7811
+ function computeSharedCacheRoot() {
7812
+ const explicit = String(process.env.EXT_BROWSERS_CACHE_DIR || '').trim();
7813
+ if (explicit) return external_path_.resolve(explicit);
7814
+ const isWin = 'win32' === process.platform;
7815
+ const isMac = 'darwin' === process.platform;
7816
+ if (isWin) {
7817
+ const local = String(process.env.LOCALAPPDATA || '').trim();
7818
+ if (local) return external_path_.join(local, 'extension.js', 'browsers');
7819
+ const userProfile = String(process.env.USERPROFILE || '').trim();
7820
+ if (userProfile) return external_path_.join(userProfile, 'AppData', 'Local', 'extension.js', 'browsers');
7821
+ return external_path_.resolve(process.cwd(), '.cache', 'extension.js', 'browsers');
7822
+ }
7823
+ if (isMac) {
7824
+ const home = String(process.env.HOME || '').trim();
7825
+ if (home) return external_path_.join(home, 'Library', 'Caches', 'extension.js', 'browsers');
7826
+ return external_path_.resolve(process.cwd(), '.cache', 'extension.js', 'browsers');
7827
+ }
7828
+ const xdg = String(process.env.XDG_CACHE_HOME || '').trim();
7829
+ if (xdg) return external_path_.join(xdg, 'extension.js', 'browsers');
7830
+ const home = String(process.env.HOME || '').trim();
7831
+ if (home) return external_path_.join(home, '.cache', 'extension.js', 'browsers');
7832
+ return external_path_.resolve(process.cwd(), '.cache', 'extension.js', 'browsers');
7833
+ }
7652
7834
  function getCompilationOutputPath(compilation) {
7653
7835
  try {
7654
7836
  var _compilation_options_output, _compilation_options, _compilation_outputOptions;
@@ -7658,6 +7840,7 @@ var __webpack_exports__ = {};
7658
7840
  }
7659
7841
  }
7660
7842
  function computeBinariesBaseDir(compilation) {
7843
+ if ('1' !== process.env.EXTENSIONJS_BINARIES_IN_DIST) return computeSharedCacheRoot();
7661
7844
  const outputDir = getCompilationOutputPath(compilation);
7662
7845
  if (outputDir) {
7663
7846
  const last = external_path_.basename(outputDir);
@@ -7973,6 +8156,17 @@ var __webpack_exports__ = {};
7973
8156
  try {
7974
8157
  if ('development' === process.env.EXTENSION_ENV) console.log(enhancedProcessManagementCleanup(browser));
7975
8158
  if (child && !child.killed) {
8159
+ if ('win32' === process.platform) try {
8160
+ (0, external_child_process_.spawn)('taskkill', [
8161
+ '/PID',
8162
+ String(child.pid),
8163
+ '/T',
8164
+ '/F'
8165
+ ], {
8166
+ stdio: 'ignore',
8167
+ windowsHide: true
8168
+ }).on('error', ()=>{});
8169
+ } catch {}
7976
8170
  if ('development' === process.env.EXTENSION_ENV) console.log(enhancedProcessManagementTerminating(browser));
7977
8171
  child.kill('SIGTERM');
7978
8172
  setTimeout(()=>{
@@ -8912,10 +9106,19 @@ var __webpack_exports__ = {};
8912
9106
  this.cdpPort = args.cdpPort;
8913
9107
  }
8914
9108
  }
9109
+ function getExtensionOutputPath(compilation, loadExtensionFlag) {
9110
+ if (!loadExtensionFlag) {
9111
+ var _compilation_options_output, _compilation_options;
9112
+ return (null == compilation ? void 0 : null == (_compilation_options = compilation.options) ? void 0 : null == (_compilation_options_output = _compilation_options.output) ? void 0 : _compilation_options_output.path) || external_path_.join(process.cwd(), 'dist');
9113
+ }
9114
+ const entries = loadExtensionFlag.replace('--load-extension=', '').split(',').map((s)=>s.trim()).filter(Boolean);
9115
+ const userCandidates = entries.filter((p)=>!/[\\\/]extension-js-devtools[\\\/]/.test(p) && !/[\\\/]extension-js-theme[\\\/]/.test(p));
9116
+ return (userCandidates.length ? userCandidates : entries).slice(-1)[0];
9117
+ }
8915
9118
  async function setupCdpAfterLaunch(compilation, plugin, chromiumArgs) {
8916
- var _compilation_options_output, _compilation_options, _compilation_options1;
9119
+ var _compilation_options;
8917
9120
  const loadExtensionFlag = chromiumArgs.find((flag)=>flag.startsWith('--load-extension='));
8918
- const extensionOutputPath = loadExtensionFlag ? loadExtensionFlag.replace('--load-extension=', '').split(',')[0] : (null == compilation ? void 0 : null == (_compilation_options = compilation.options) ? void 0 : null == (_compilation_options_output = _compilation_options.output) ? void 0 : _compilation_options_output.path) || external_path_.join(process.cwd(), 'dist');
9121
+ const extensionOutputPath = getExtensionOutputPath(compilation, loadExtensionFlag);
8919
9122
  const remoteDebugPortFlag = chromiumArgs.find((flag)=>flag.startsWith('--remote-debugging-port='));
8920
9123
  const chromeRemoteDebugPort = remoteDebugPortFlag ? parseInt(remoteDebugPortFlag.split('=')[1], 10) : deriveDebugPortWithInstance(plugin.port, plugin.instanceId);
8921
9124
  if ('development' === process.env.EXTENSION_ENV) {
@@ -8945,7 +9148,7 @@ var __webpack_exports__ = {};
8945
9148
  await retryAsync(()=>cdpExtensionController.connect());
8946
9149
  if ('development' === process.env.EXTENSION_ENV) console.log(cdpClientConnected('127.0.0.1', chromeRemoteDebugPort));
8947
9150
  const extensionControllerInfo = await cdpExtensionController.ensureLoaded();
8948
- if ((null == compilation ? void 0 : null == (_compilation_options1 = compilation.options) ? void 0 : _compilation_options1.mode) !== 'production') try {
9151
+ if ((null == compilation ? void 0 : null == (_compilation_options = compilation.options) ? void 0 : _compilation_options.mode) !== 'production') try {
8949
9152
  const bannerPrinted = await printDevBannerOnce({
8950
9153
  outPath: extensionOutputPath,
8951
9154
  browser: plugin.browser,
@@ -10154,6 +10357,8 @@ var __webpack_exports__ = {};
10154
10357
  process.on('SIGINT', onSignal);
10155
10358
  process.on('SIGTERM', onSignal);
10156
10359
  process.on('SIGHUP', onSignal);
10360
+ process.on('SIGBREAK', onSignal);
10361
+ process.on('beforeExit', onSignal);
10157
10362
  process.on('uncaughtException', async (error)=>{
10158
10363
  console.error(enhancedProcessManagementUncaughtException(browser, error));
10159
10364
  await attemptCleanup();
@@ -11322,6 +11527,15 @@ var __webpack_exports__ = {};
11322
11527
  console.log(firefoxDryRunConfig(firefoxConfig));
11323
11528
  }
11324
11529
  const masterPreferences = {
11530
+ 'browser.aboutwelcome.enabled': false,
11531
+ 'browser.startup.homepage_override.mstone': 'ignore',
11532
+ 'browser.shell.didSkipDefaultBrowserCheckOnFirstRun': true,
11533
+ 'datareporting.policy.dataSubmissionPolicyBypassNotification': true,
11534
+ 'browser.startup.upgradeDialog.enabled': false,
11535
+ 'browser.messaging-system.whatsNewPanel.enabled': false,
11536
+ 'browser.newtabpage.activity-stream.asrouter.userprefs.cfr.addons': false,
11537
+ 'browser.newtabpage.activity-stream.asrouter.userprefs.cfr.features': false,
11538
+ 'browser.startup.homepage_override_url': '',
11325
11539
  'app.update.enabled': false,
11326
11540
  'browser.dom.window.dump.enabled': true,
11327
11541
  'browser.formfill.enable': false,
@@ -11646,13 +11860,18 @@ var __webpack_exports__ = {};
11646
11860
  if (profileMatch) {
11647
11861
  const profilePath = profileMatch[1];
11648
11862
  const { binary, args } = FirefoxBinaryDetector.generateFirefoxArgs(binaryPath, profilePath, debugPort, firefoxArgs);
11863
+ const isWin = 'win32' === process.platform;
11864
+ const stdio = isWin ? 'ignore' : [
11865
+ 'pipe',
11866
+ 'pipe',
11867
+ 'pipe'
11868
+ ];
11649
11869
  this.child = (0, external_child_process_.spawn)(binary, args, {
11650
- stdio: [
11651
- 'pipe',
11652
- 'pipe',
11653
- 'pipe'
11654
- ],
11655
- detached: false
11870
+ stdio,
11871
+ detached: false,
11872
+ ...isWin ? {
11873
+ windowsHide: true
11874
+ } : {}
11656
11875
  });
11657
11876
  this.wireChildLifecycle(compilation, debugPort, desiredDebugPort);
11658
11877
  const ctrl = await setupRdpAfterLaunch({
@@ -11680,13 +11899,18 @@ var __webpack_exports__ = {};
11680
11899
  '--disable-renderer-backgrounding',
11681
11900
  ...firefoxArgs
11682
11901
  ];
11902
+ const isWin = 'win32' === process.platform;
11903
+ const stdio = isWin ? 'ignore' : [
11904
+ 'pipe',
11905
+ 'pipe',
11906
+ 'pipe'
11907
+ ];
11683
11908
  this.child = (0, external_child_process_.spawn)(binaryPath, args, {
11684
- stdio: [
11685
- 'pipe',
11686
- 'pipe',
11687
- 'pipe'
11688
- ],
11689
- detached: false
11909
+ stdio,
11910
+ detached: false,
11911
+ ...isWin ? {
11912
+ windowsHide: true
11913
+ } : {}
11690
11914
  });
11691
11915
  this.wireChildLifecycle(compilation, debugPort, desiredDebugPort);
11692
11916
  }
@@ -12278,47 +12502,32 @@ var __webpack_exports__ = {};
12278
12502
  }
12279
12503
  plugin_browsers_define_property(BrowsersPlugin, "name", 'plugin-browsers');
12280
12504
  function webpackConfig(projectStructure, devOptions) {
12281
- var _devOptions_output, _devOptions_output1;
12282
- const { manifestPath, packageJsonPath } = projectStructure;
12283
- const manifestDir = external_path_.dirname(manifestPath);
12284
- const packageJsonDir = packageJsonPath ? external_path_.dirname(packageJsonPath) : manifestDir;
12285
- const geckoBinaryAlias = devOptions.geckoBinary || devOptions.firefoxBinary;
12286
- const browser = devOptions.chromiumBinary ? 'chromium-based' : geckoBinaryAlias ? 'gecko-based' : devOptions.browser;
12287
- const manifest = filterKeysForThisBrowser(JSON.parse(external_fs_.readFileSync(manifestPath, 'utf-8')), browser);
12288
- const userExtensionOutputPath = external_path_.isAbsolute(devOptions.output.path) ? devOptions.output.path : external_path_.resolve(packageJsonDir, devOptions.output.path);
12289
- const extensionsToLoad = [];
12290
- if ('production' !== devOptions.mode) {
12291
- const devtoolsRoot = external_path_.resolve(__dirname, '../dist/extension-js-devtools');
12292
- const devtoolsEngine = (()=>{
12293
- const b = String(browser || '');
12294
- switch(b){
12295
- case 'chrome':
12296
- return 'chrome';
12297
- case 'edge':
12298
- return 'edge';
12299
- case 'chromium':
12300
- case 'chromium-based':
12301
- return 'chromium';
12302
- case 'firefox':
12303
- case 'gecko-based':
12304
- case 'firefox-based':
12305
- return 'firefox';
12306
- default:
12307
- return b;
12308
- }
12309
- })();
12310
- const devtoolsForBrowser = external_path_.join(devtoolsRoot, devtoolsEngine);
12311
- if (external_fs_.existsSync(devtoolsForBrowser)) extensionsToLoad.push(devtoolsForBrowser);
12312
- }
12313
- extensionsToLoad.push(userExtensionOutputPath);
12505
+ const { manifestPath } = projectStructure;
12506
+ const { packageJsonDir } = getDirs(projectStructure);
12507
+ const manifest = filterKeysForThisBrowser(JSON.parse(external_fs_.readFileSync(manifestPath, 'utf-8')), devOptions.browser);
12508
+ const userExtensionOutputPath = asAbsolute(external_path_.isAbsolute(devOptions.output.path) ? devOptions.output.path : external_path_.resolve(packageJsonDir, devOptions.output.path));
12509
+ const extensionsToLoad = computeExtensionsToLoad(__dirname, devOptions.mode, devOptions.browser, userExtensionOutputPath);
12510
+ const debug = 'development' === process.env.EXTENSION_ENV;
12511
+ if (debug) {
12512
+ console.log(webpack_lib_messages.Ry(devOptions.browser, devOptions.chromiumBinary, devOptions.geckoBinary));
12513
+ console.log(webpack_lib_messages.ZE(packageJsonDir));
12514
+ console.log(webpack_lib_messages.$T(userExtensionOutputPath));
12515
+ console.log(webpack_lib_messages.KH(extensionsToLoad));
12516
+ }
12517
+ const darkDefaults = withDarkMode({
12518
+ browser: devOptions.browser,
12519
+ browserFlags: devOptions.browserFlags,
12520
+ preferences: devOptions.preferences
12521
+ });
12314
12522
  return {
12315
12523
  mode: devOptions.mode || 'development',
12316
12524
  entry: {},
12317
12525
  target: 'web',
12318
12526
  context: packageJsonDir,
12527
+ cache: false,
12319
12528
  devtool: 'production' === (devOptions.mode || 'development') ? false : 3 === manifest.manifest_version ? 'cheap-source-map' : 'eval-cheap-source-map',
12320
12529
  output: {
12321
- clean: null == (_devOptions_output = devOptions.output) ? void 0 : _devOptions_output.clean,
12530
+ clean: devOptions.output.clean,
12322
12531
  path: userExtensionOutputPath,
12323
12532
  publicPath: '/',
12324
12533
  hotUpdateChunkFilename: 'hot/[id].[fullhash].hot-update.js',
@@ -12328,8 +12537,27 @@ var __webpack_exports__ = {};
12328
12537
  dynamicImport: true
12329
12538
  }
12330
12539
  },
12540
+ watchOptions: {
12541
+ ignored: /node_modules|dist|extension-js\/profiles/,
12542
+ poll: 1000,
12543
+ aggregateTimeout: 200
12544
+ },
12331
12545
  resolve: {
12332
- modules: packageJsonPath ? [
12546
+ mainFields: [
12547
+ 'browser',
12548
+ 'module',
12549
+ 'main'
12550
+ ],
12551
+ conditionNames: [
12552
+ 'browser',
12553
+ 'import',
12554
+ 'module',
12555
+ 'default'
12556
+ ],
12557
+ aliasFields: [
12558
+ 'browser'
12559
+ ],
12560
+ modules: projectStructure.packageJsonPath ? [
12333
12561
  'node_modules',
12334
12562
  external_path_.join(packageJsonDir, 'node_modules'),
12335
12563
  external_path_.join(process.cwd(), 'node_modules')
@@ -12347,27 +12575,8 @@ var __webpack_exports__ = {};
12347
12575
  '.json',
12348
12576
  '.wasm',
12349
12577
  '.svelte'
12350
- ],
12351
- mainFields: [
12352
- 'browser',
12353
- 'module',
12354
- 'main'
12355
- ],
12356
- conditionNames: [
12357
- 'browser',
12358
- 'import',
12359
- 'module',
12360
- 'default'
12361
- ],
12362
- aliasFields: [
12363
- 'browser'
12364
12578
  ]
12365
12579
  },
12366
- watchOptions: {
12367
- ignored: /node_modules|dist|extension-js\/profiles/,
12368
- poll: 1000,
12369
- aggregateTimeout: 200
12370
- },
12371
12580
  module: {
12372
12581
  rules: [],
12373
12582
  parser: {
@@ -12376,12 +12585,11 @@ var __webpack_exports__ = {};
12376
12585
  }
12377
12586
  }
12378
12587
  },
12379
- cache: false,
12380
12588
  plugins: [
12381
12589
  new CompilationPlugin({
12382
12590
  manifestPath,
12383
- browser,
12384
- clean: null == (_devOptions_output1 = devOptions.output) ? void 0 : _devOptions_output1.clean,
12591
+ browser: devOptions.browser,
12592
+ clean: devOptions.output.clean,
12385
12593
  zip: true === devOptions.zip,
12386
12594
  zipSource: true === devOptions.zipSource,
12387
12595
  zipFilename: devOptions.zipFilename
@@ -12399,24 +12607,24 @@ var __webpack_exports__ = {};
12399
12607
  }),
12400
12608
  new CompatibilityPlugin({
12401
12609
  manifestPath,
12402
- browser,
12610
+ browser: devOptions.browser,
12403
12611
  polyfill: devOptions.polyfill
12404
12612
  }),
12405
12613
  new ExtensionPlugin({
12406
12614
  manifestPath,
12407
- browser
12615
+ browser: devOptions.browser
12408
12616
  }),
12409
12617
  new BrowsersPlugin({
12410
12618
  extension: extensionsToLoad,
12411
- browser,
12619
+ browser: devOptions.browser,
12412
12620
  noOpen: devOptions.noOpen,
12413
12621
  startingUrl: devOptions.startingUrl,
12414
12622
  profile: devOptions.profile,
12415
12623
  persistProfile: devOptions.persistProfile,
12416
- preferences: devOptions.preferences,
12417
- browserFlags: devOptions.browserFlags,
12624
+ preferences: darkDefaults.preferences,
12625
+ browserFlags: darkDefaults.browserFlags,
12418
12626
  chromiumBinary: devOptions.chromiumBinary,
12419
- geckoBinary: geckoBinaryAlias,
12627
+ geckoBinary: devOptions.geckoBinary,
12420
12628
  instanceId: devOptions.instanceId,
12421
12629
  port: devOptions.port,
12422
12630
  source: devOptions.source,
@@ -12441,7 +12649,7 @@ var __webpack_exports__ = {};
12441
12649
  logging: 'none'
12442
12650
  },
12443
12651
  infrastructureLogging: {
12444
- level: 'development' === devOptions.mode && '1' === String(process.env.EXTENSION_VERBOSE || '').trim() ? 'info' : 'error',
12652
+ level: 'development' === String(devOptions.mode) && '1' === String(process.env.EXTENSION_VERBOSE || '').trim() ? 'info' : 'error',
12445
12653
  console: makeSanitizedConsole('Extension.js')
12446
12654
  },
12447
12655
  ignoreWarnings: [
@@ -12489,13 +12697,19 @@ var __webpack_exports__ = {};
12489
12697
  const projectStructure = await getProjectStructure(pathOrRemoteUrl);
12490
12698
  const isVitest = 'true' === process.env.VITEST;
12491
12699
  const shouldExitOnError = ((null == buildOptions ? void 0 : buildOptions.exitOnError) ?? true) && !isVitest;
12492
- const browser = (null == buildOptions ? void 0 : buildOptions.browser) || 'chrome';
12700
+ const browser = normalizeBrowser((null == buildOptions ? void 0 : buildOptions.browser) || 'chrome', null == buildOptions ? void 0 : buildOptions.chromiumBinary, (null == buildOptions ? void 0 : buildOptions.geckoBinary) || (null == buildOptions ? void 0 : buildOptions.firefoxBinary));
12493
12701
  try {
12494
12702
  var _baseConfig_plugins;
12495
- const manifestDir = external_path_.dirname(projectStructure.manifestPath);
12496
- const packageJsonDir = projectStructure.packageJsonPath ? external_path_.dirname(projectStructure.packageJsonPath) : manifestDir;
12497
- if (projectStructure.packageJsonPath) assertNoManagedDependencyConflicts(projectStructure.packageJsonPath, external_path_.dirname(projectStructure.manifestPath));
12703
+ const debug = 'development' === process.env.EXTENSION_ENV;
12704
+ const { manifestDir, packageJsonDir } = getDirs(projectStructure);
12705
+ if (projectStructure.packageJsonPath) assertNoManagedDependencyConflicts(projectStructure.packageJsonPath, manifestDir);
12498
12706
  const commandConfig = await loadCommandConfig(manifestDir, 'build');
12707
+ const distPath = getDistPath(packageJsonDir, browser);
12708
+ if (debug) {
12709
+ console.log(webpack_lib_messages.OF(manifestDir, packageJsonDir));
12710
+ console.log(webpack_lib_messages.Ry(browser, null == buildOptions ? void 0 : buildOptions.chromiumBinary, (null == buildOptions ? void 0 : buildOptions.geckoBinary) || (null == buildOptions ? void 0 : buildOptions.firefoxBinary)));
12711
+ console.log(webpack_lib_messages.$T(distPath));
12712
+ }
12499
12713
  const baseConfig = webpackConfig(projectStructure, {
12500
12714
  ...commandConfig,
12501
12715
  ...buildOptions,
@@ -12503,7 +12717,7 @@ var __webpack_exports__ = {};
12503
12717
  mode: 'production',
12504
12718
  output: {
12505
12719
  clean: true,
12506
- path: external_path_.join(packageJsonDir, 'dist', browser)
12720
+ path: distPath
12507
12721
  }
12508
12722
  });
12509
12723
  const allPluginsButBrowserRunners = null == (_baseConfig_plugins = baseConfig.plugins) ? void 0 : _baseConfig_plugins.filter((plugin)=>(null == plugin ? void 0 : plugin.constructor.name) !== 'plugin-browsers');
@@ -12515,9 +12729,7 @@ var __webpack_exports__ = {};
12515
12729
  const compilerConfig = (0, external_webpack_merge_namespaceObject.merge)(userConfig);
12516
12730
  const compiler = (0, core_namespaceObject.rspack)(compilerConfig);
12517
12731
  if (projectStructure.packageJsonPath) {
12518
- const nodeModulesPath = external_path_.join(packageJsonDir, 'node_modules');
12519
- const needsInstall = !external_fs_.existsSync(nodeModulesPath) || external_fs_.existsSync(nodeModulesPath) && 0 === external_fs_.readdirSync(nodeModulesPath).length;
12520
- if (needsInstall) {
12732
+ if (needsInstall(packageJsonDir)) {
12521
12733
  console.log(webpack_lib_messages.Nv());
12522
12734
  if ('true' !== process.env.VITEST) await installDependencies(packageJsonDir);
12523
12735
  }
@@ -12778,15 +12990,14 @@ var __webpack_exports__ = {};
12778
12990
  function closeAll(devServer, portManager) {
12779
12991
  devServer.stop().then(async ()=>{
12780
12992
  await portManager.terminateCurrentInstance();
12781
- process.exit();
12993
+ setTimeout(()=>process.exit(), 500);
12782
12994
  }).catch(async (error)=>{
12783
12995
  console.log(messages_extensionJsRunnerError(error));
12784
12996
  await portManager.terminateCurrentInstance();
12785
- process.exit(1);
12997
+ setTimeout(()=>process.exit(1), 500);
12786
12998
  });
12787
12999
  }
12788
13000
  async function dev_server_devServer(projectStructure, devOptions) {
12789
- var _process_removeAllListeners, _process, _process_removeAllListeners1, _process1, _process_removeAllListeners2, _process2, _process_removeAllListeners3, _process3;
12790
13001
  const { manifestPath, packageJsonPath } = projectStructure;
12791
13002
  const manifestDir = external_path_.dirname(manifestPath);
12792
13003
  const packageJsonDir = external_path_.dirname(packageJsonPath);
@@ -12958,10 +13169,6 @@ var __webpack_exports__ = {};
12958
13169
  } catch {}
12959
13170
  await cleanup();
12960
13171
  };
12961
- null == (_process_removeAllListeners = (_process = process).removeAllListeners) || _process_removeAllListeners.call(_process, 'SIGINT');
12962
- null == (_process_removeAllListeners1 = (_process1 = process).removeAllListeners) || _process_removeAllListeners1.call(_process1, 'SIGTERM');
12963
- null == (_process_removeAllListeners2 = (_process2 = process).removeAllListeners) || _process_removeAllListeners2.call(_process2, 'SIGHUP');
12964
- null == (_process_removeAllListeners3 = (_process3 = process).removeAllListeners) || _process_removeAllListeners3.call(_process3, 'ERROR');
12965
13172
  process.on('ERROR', cancelAndCleanup);
12966
13173
  process.on('SIGINT', cancelAndCleanup);
12967
13174
  process.on('SIGTERM', cancelAndCleanup);
@@ -13000,22 +13207,27 @@ var __webpack_exports__ = {};
13000
13207
  async function extensionDev(pathOrRemoteUrl, devOptions) {
13001
13208
  const projectStructure = await getProjectStructure(pathOrRemoteUrl);
13002
13209
  try {
13003
- const manifestDir = external_path_.dirname(projectStructure.manifestPath);
13004
- const packageJsonDir = external_path_.dirname(projectStructure.packageJsonPath);
13210
+ const debug = 'development' === process.env.EXTENSION_ENV;
13211
+ const { manifestDir, packageJsonDir } = getDirs(projectStructure);
13005
13212
  if (isUsingTypeScript(manifestDir)) await generateExtensionTypes(manifestDir, packageJsonDir);
13006
- if (projectStructure.packageJsonPath) assertNoManagedDependencyConflicts(projectStructure.packageJsonPath, external_path_.dirname(projectStructure.manifestPath));
13213
+ if (projectStructure.packageJsonPath) assertNoManagedDependencyConflicts(projectStructure.packageJsonPath, manifestDir);
13007
13214
  if (projectStructure.packageJsonPath) {
13008
- const nodeModulesPath = external_path_.join(packageJsonDir, 'node_modules');
13009
- const needsInstall = !external_fs_.existsSync(nodeModulesPath) || external_fs_.existsSync(nodeModulesPath) && 0 === external_fs_.readdirSync(nodeModulesPath).length;
13010
- if (needsInstall) {
13215
+ if (needsInstall(packageJsonDir)) {
13011
13216
  console.log(webpack_lib_messages.Nv());
13012
13217
  await installDependencies(packageJsonDir);
13013
13218
  }
13014
13219
  }
13220
+ const browser = normalizeBrowser(devOptions.browser || 'chrome', devOptions.chromiumBinary, devOptions.geckoBinary || devOptions.firefoxBinary);
13221
+ const geckoBinary = devOptions.geckoBinary || devOptions.firefoxBinary;
13222
+ if (debug) {
13223
+ console.log(webpack_lib_messages.OF(manifestDir, packageJsonDir));
13224
+ console.log(webpack_lib_messages.Ry(browser, devOptions.chromiumBinary, geckoBinary));
13225
+ }
13015
13226
  await dev_server_devServer(projectStructure, {
13016
13227
  ...devOptions,
13017
13228
  mode: 'development',
13018
- browser: devOptions.browser || 'chrome'
13229
+ browser,
13230
+ geckoBinary
13019
13231
  });
13020
13232
  } catch (error) {
13021
13233
  console.error(error);
@@ -13024,19 +13236,22 @@ var __webpack_exports__ = {};
13024
13236
  }
13025
13237
  async function extensionPreview(pathOrRemoteUrl, previewOptions) {
13026
13238
  const projectStructure = await getProjectStructure(pathOrRemoteUrl);
13239
+ const debug = 'development' === process.env.EXTENSION_ENV;
13027
13240
  if (projectStructure.packageJsonPath) assertNoManagedDependencyConflicts(projectStructure.packageJsonPath, external_path_.dirname(projectStructure.manifestPath));
13028
- const manifestDir = external_path_.dirname(projectStructure.manifestPath);
13029
- const packageJsonDir = projectStructure.packageJsonPath ? external_path_.dirname(projectStructure.packageJsonPath) : manifestDir;
13030
- const distPath = external_path_.join(packageJsonDir, 'dist', previewOptions.browser);
13031
- const outputPath = previewOptions.outputPath || distPath;
13241
+ const { manifestDir, packageJsonDir } = getDirs(projectStructure);
13242
+ const browser = normalizeBrowser(previewOptions.browser || 'chrome', previewOptions.chromiumBinary, previewOptions.geckoBinary || previewOptions.firefoxBinary);
13243
+ const outputPath = computePreviewOutputPath(projectStructure, browser, previewOptions.outputPath);
13244
+ const distPath = getDistPath(packageJsonDir, browser);
13245
+ if (debug) {
13246
+ console.log(webpack_lib_messages.OF(manifestDir, packageJsonDir));
13247
+ console.log(webpack_lib_messages.Ry(browser, previewOptions.chromiumBinary, previewOptions.geckoBinary || previewOptions.firefoxBinary));
13248
+ console.log(webpack_lib_messages.vQ(outputPath, distPath));
13249
+ }
13032
13250
  try {
13033
- if (!external_fs_.existsSync(outputPath)) external_fs_.mkdirSync(outputPath, {
13034
- recursive: true
13035
- });
13251
+ if (outputPath === distPath) ensureDirSync(outputPath);
13036
13252
  } catch {}
13037
13253
  try {
13038
13254
  var _baseConfig_plugins;
13039
- const browser = previewOptions.browser || 'chrome';
13040
13255
  const commandConfig = await loadCommandConfig(manifestDir, 'preview');
13041
13256
  const browserConfig = await loadBrowserConfig(manifestDir, browser);
13042
13257
  console.log(webpack_lib_messages.WW(browser));
@@ -13047,7 +13262,7 @@ var __webpack_exports__ = {};
13047
13262
  profile: previewOptions.profile,
13048
13263
  browser,
13049
13264
  chromiumBinary: previewOptions.chromiumBinary,
13050
- geckoBinary: previewOptions.geckoBinary,
13265
+ geckoBinary: previewOptions.geckoBinary || previewOptions.firefoxBinary,
13051
13266
  startingUrl: previewOptions.startingUrl,
13052
13267
  port: previewOptions.port,
13053
13268
  source: previewOptions.source,
@@ -13130,10 +13345,17 @@ var __webpack_exports__ = {};
13130
13345
  async function extensionStart(pathOrRemoteUrl, startOptions) {
13131
13346
  const projectStructure = await getProjectStructure(pathOrRemoteUrl);
13132
13347
  try {
13133
- const browser = startOptions.browser || 'chrome';
13134
- const manifestDir = external_path_.dirname(projectStructure.manifestPath);
13348
+ const debug = 'development' === process.env.EXTENSION_ENV;
13349
+ const browser = normalizeBrowser(startOptions.browser || 'chrome', startOptions.chromiumBinary, startOptions.geckoBinary || startOptions.firefoxBinary);
13350
+ const { manifestDir, packageJsonDir } = getDirs(projectStructure);
13135
13351
  const commandConfig = await loadCommandConfig(manifestDir, 'start');
13136
13352
  const browserConfig = await loadBrowserConfig(manifestDir, browser);
13353
+ const distPath = getDistPath(packageJsonDir, browser);
13354
+ if (debug) {
13355
+ console.log(webpack_lib_messages.OF(manifestDir, packageJsonDir));
13356
+ console.log(webpack_lib_messages.Ry(browser, startOptions.chromiumBinary, startOptions.geckoBinary || startOptions.firefoxBinary));
13357
+ console.log(webpack_lib_messages.$T(distPath));
13358
+ }
13137
13359
  await extensionBuild(pathOrRemoteUrl, {
13138
13360
  ...browserConfig,
13139
13361
  ...commandConfig,
@@ -13141,13 +13363,13 @@ var __webpack_exports__ = {};
13141
13363
  browser,
13142
13364
  silent: true
13143
13365
  });
13144
- const packageJsonDir = projectStructure.packageJsonPath ? external_path_.dirname(projectStructure.packageJsonPath) : manifestDir;
13145
13366
  await extensionPreview(pathOrRemoteUrl, {
13146
13367
  ...browserConfig,
13147
13368
  ...commandConfig,
13148
13369
  ...startOptions,
13149
13370
  browser,
13150
- outputPath: external_path_.join(packageJsonDir, 'dist', browser)
13371
+ geckoBinary: startOptions.geckoBinary || startOptions.firefoxBinary,
13372
+ outputPath: distPath
13151
13373
  });
13152
13374
  } catch (error) {
13153
13375
  if ('development' === process.env.EXTENSION_ENV) console.error(error);
@@ -1328,8 +1328,12 @@ var __webpack_exports__ = {};
1328
1328
  let start = span.start - 1;
1329
1329
  let end = span.end + 1;
1330
1330
  const q = before;
1331
- const escaped = "'" === q ? String(computed).replace(/'/g, "\\'") : String(computed).replace(/"/g, '\\"');
1332
- ms.overwrite(start, end, `${q}${escaped}${q}`);
1331
+ const json = JSON.stringify(String(computed));
1332
+ if ('"' === q) ms.overwrite(start, end, json);
1333
+ else {
1334
+ const inner = json.slice(1, -1).replace(/'/g, "\\'");
1335
+ ms.overwrite(start, end, `'${inner}'`);
1336
+ }
1333
1337
  } else ms.overwrite(span.start, span.end, JSON.stringify(computed));
1334
1338
  edited = true;
1335
1339
  }
package/package.json CHANGED
@@ -21,7 +21,7 @@
21
21
  "dist"
22
22
  ],
23
23
  "name": "extension-develop",
24
- "version": "3.0.0-next.6",
24
+ "version": "3.0.0-next.7",
25
25
  "description": "The develop step of Extension.js",
26
26
  "author": {
27
27
  "name": "Cezar Augusto",