extension-develop 3.7.0 → 3.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/323.cjs CHANGED
@@ -471,6 +471,32 @@ exports.modules = {
471
471
  };
472
472
  await retryAsync(()=>cdpExtensionController.connect());
473
473
  if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(messages.M3V('127.0.0.1', chromeRemoteDebugPort));
474
+ const mode = compilation?.options?.mode || 'development';
475
+ let earlyBannerPrinted = false;
476
+ if ('development' === mode) try {
477
+ earlyBannerPrinted = await (0, banner.a)({
478
+ outPath: extensionOutputPath,
479
+ browser: plugin.browser,
480
+ hostPort: {
481
+ host: '127.0.0.1',
482
+ port: chromeRemoteDebugPort
483
+ },
484
+ getInfo: async ()=>null,
485
+ browserVersionLine: plugin.browserVersionLine
486
+ });
487
+ } catch {}
488
+ if ('development' === mode) try {
489
+ earlyBannerPrinted = await (0, banner.a)({
490
+ outPath: extensionOutputPath,
491
+ browser: plugin.browser,
492
+ hostPort: {
493
+ host: '127.0.0.1',
494
+ port: chromeRemoteDebugPort
495
+ },
496
+ getInfo: async ()=>cdpExtensionController.getInfoBestEffort(),
497
+ browserVersionLine: plugin.browserVersionLine
498
+ });
499
+ } catch {}
474
500
  let extensionControllerInfo = null;
475
501
  try {
476
502
  const ensureLoadedTimeoutMs = 10000;
@@ -484,28 +510,29 @@ exports.modules = {
484
510
  if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.warn(`[CDP] ensureLoaded failed: ${String(error?.message || error)}`);
485
511
  }
486
512
  try {
487
- const mode = compilation?.options?.mode || 'development';
488
513
  if ('development' === mode) {
489
- const bannerPrinted = await (0, banner.a)({
490
- outPath: extensionOutputPath,
491
- browser: plugin.browser,
492
- hostPort: {
493
- host: '127.0.0.1',
494
- port: chromeRemoteDebugPort
495
- },
496
- getInfo: async ()=>extensionControllerInfo,
497
- browserVersionLine: plugin.browserVersionLine
498
- });
499
- if (!bannerPrinted) await (0, banner.a)({
500
- outPath: extensionOutputPath,
501
- browser: plugin.browser,
502
- hostPort: {
503
- host: '127.0.0.1',
504
- port: chromeRemoteDebugPort
505
- },
506
- getInfo: async ()=>cdpExtensionController.getInfoBestEffort(),
507
- browserVersionLine: plugin.browserVersionLine
508
- });
514
+ if (!earlyBannerPrinted) {
515
+ const bannerPrinted = await (0, banner.a)({
516
+ outPath: extensionOutputPath,
517
+ browser: plugin.browser,
518
+ hostPort: {
519
+ host: '127.0.0.1',
520
+ port: chromeRemoteDebugPort
521
+ },
522
+ getInfo: async ()=>extensionControllerInfo,
523
+ browserVersionLine: plugin.browserVersionLine
524
+ });
525
+ if (!bannerPrinted) await (0, banner.a)({
526
+ outPath: extensionOutputPath,
527
+ browser: plugin.browser,
528
+ hostPort: {
529
+ host: '127.0.0.1',
530
+ port: chromeRemoteDebugPort
531
+ },
532
+ getInfo: async ()=>cdpExtensionController.getInfoBestEffort(),
533
+ browserVersionLine: plugin.browserVersionLine
534
+ });
535
+ }
509
536
  } else if ('production' === mode) {
510
537
  const runtime = extensionControllerInfo ? {
511
538
  extensionId: extensionControllerInfo.extensionId,
package/dist/535.cjs CHANGED
@@ -664,6 +664,7 @@ exports.modules = {
664
664
  this.zipData = this.options.zipData ?? {};
665
665
  }
666
666
  }
667
+ var shared_state = __webpack_require__("./webpack/plugin-compilation/compilation-lib/shared-state.ts");
667
668
  function boring_define_property(obj, key, value) {
668
669
  if (key in obj) Object.defineProperty(obj, key, {
669
670
  value: value,
@@ -681,12 +682,38 @@ exports.modules = {
681
682
  }
682
683
  class BoringPlugin {
683
684
  apply(compiler) {
685
+ compiler.hooks.watchClose.tap('develop:brand:watch-close', ()=>{
686
+ this.sawUserInvalidation = false;
687
+ this.printedPostBannerStartupSuccess = false;
688
+ });
684
689
  compiler.hooks.done.tap('develop:brand', (stats)=>{
690
+ const hasErrors = Boolean(stats?.hasErrors?.());
691
+ const hasWarnings = Boolean(stats?.hasWarnings?.());
692
+ const runnerEnabled = '0' !== String(process.env.EXTENSION_BROWSER_RUNNER_ENABLED || '1');
685
693
  stats.compilation.name = void 0;
686
694
  const duration = stats.compilation.endTime - stats.compilation.startTime;
687
695
  const manifestName = boring_readJsonFileSafe(this.manifestPath).name;
688
696
  const line = boring(manifestName, duration, stats);
689
697
  try {
698
+ const modifiedFiles = Array.from(stats?.compilation?.modifiedFiles || []).map((file)=>String(file).replace(/\\/g, '/'));
699
+ if (!this.sawUserInvalidation && modifiedFiles.length > 0) {
700
+ const context = String(compiler?.options?.context || '').replace(/\\/g, '/');
701
+ const hasUserFileChange = modifiedFiles.some((file)=>{
702
+ const inProject = !context || file.startsWith(`${context}/`);
703
+ const isGenerated = file.includes('/dist/') || file.includes('/extension-js/profiles/');
704
+ return inProject && !isGenerated;
705
+ });
706
+ if (hasUserFileChange) this.sawUserInvalidation = true;
707
+ }
708
+ if (runnerEnabled && !(0, shared_state.TC)() && !hasErrors && !hasWarnings) {
709
+ this.printedPostBannerStartupSuccess = true;
710
+ (0, shared_state.FF)(line);
711
+ return;
712
+ }
713
+ if (runnerEnabled && !hasErrors && !hasWarnings) {
714
+ if (!this.sawUserInvalidation) if (this.printedPostBannerStartupSuccess) return;
715
+ else this.printedPostBannerStartupSuccess = true;
716
+ }
690
717
  console.log(line);
691
718
  } catch {}
692
719
  });
@@ -694,6 +721,8 @@ exports.modules = {
694
721
  constructor(options){
695
722
  boring_define_property(this, "manifestPath", void 0);
696
723
  boring_define_property(this, "browser", void 0);
724
+ boring_define_property(this, "sawUserInvalidation", false);
725
+ boring_define_property(this, "printedPostBannerStartupSuccess", false);
697
726
  this.manifestPath = options.manifestPath;
698
727
  this.browser = options.browser || 'chrome';
699
728
  }
@@ -843,6 +872,21 @@ exports.modules = {
843
872
  return styleLoaders.filter(Boolean);
844
873
  }
845
874
  var is_content_script = __webpack_require__("./webpack/plugin-css/css-lib/is-content-script.ts");
875
+ function resolvePreprocessorLoader(loader, projectPath) {
876
+ const extensionRoot = (0, css_lib_integrations.He)();
877
+ const paths = [
878
+ projectPath,
879
+ extensionRoot || void 0,
880
+ process.cwd()
881
+ ].filter(Boolean);
882
+ try {
883
+ return require.resolve(loader, {
884
+ paths
885
+ });
886
+ } catch {
887
+ throw new Error(`[CSS] ${loader} could not be resolved for content scripts. Searched: ${paths.join(', ')}`);
888
+ }
889
+ }
846
890
  async function cssInContentScriptLoader(projectPath, manifestPath, mode, usage = {}) {
847
891
  const { useSass = true, useLess = true } = usage;
848
892
  const isContentScript = (issuer)=>(0, is_content_script.z)(issuer, manifestPath, projectPath);
@@ -908,13 +952,28 @@ exports.modules = {
908
952
  ...baseConfig,
909
953
  use: await commonStyleLoaders(projectPath, {
910
954
  mode: mode,
911
- loader: require.resolve(loader),
955
+ loader: resolvePreprocessorLoader(loader, projectPath),
912
956
  loaderOptions
913
957
  })
914
958
  };
915
959
  }));
916
960
  return rules;
917
961
  }
962
+ function css_in_html_loader_resolvePreprocessorLoader(loader, projectPath) {
963
+ const extensionRoot = (0, css_lib_integrations.He)();
964
+ const paths = [
965
+ projectPath,
966
+ extensionRoot || void 0,
967
+ process.cwd()
968
+ ].filter(Boolean);
969
+ try {
970
+ return require.resolve(loader, {
971
+ paths
972
+ });
973
+ } catch {
974
+ throw new Error(`[CSS] ${loader} could not be resolved for HTML entries. Searched: ${paths.join(', ')}`);
975
+ }
976
+ }
918
977
  async function cssInHtmlLoader(projectPath, mode, manifestPath, usage = {}) {
919
978
  const { useSass = true, useLess = true } = usage;
920
979
  const isNotContentScript = (issuer)=>!(0, is_content_script.z)(issuer, manifestPath, projectPath);
@@ -977,7 +1036,7 @@ exports.modules = {
977
1036
  ...baseConfig,
978
1037
  use: await commonStyleLoaders(projectPath, {
979
1038
  mode: mode,
980
- loader: require.resolve(loader),
1039
+ loader: css_in_html_loader_resolvePreprocessorLoader(loader, projectPath),
981
1040
  loaderOptions
982
1041
  })
983
1042
  };
@@ -7921,17 +7980,22 @@ Set background.noDynamicEntryWarning to true to disable this warning.
7921
7980
  function resolveActionFormat() {
7922
7981
  const raw = String(process.env.EXTENSION_SOURCE_FORMAT || '').trim();
7923
7982
  if ('json' === raw || 'ndjson' === raw) return raw;
7924
- return 'pretty';
7983
+ return 'json';
7984
+ }
7985
+ function isActionEventOutputEnabled() {
7986
+ const authorMode = String(process.env.EXTENSION_AUTHOR_MODE || '').trim().toLowerCase();
7987
+ return 'true' === authorMode || 'development' === authorMode;
7925
7988
  }
7926
- function emitActionEvent(action, payload = {}, format = resolveActionFormat()) {
7989
+ function emitActionEvent(action, payload = {}, _format = resolveActionFormat()) {
7990
+ if (!isActionEventOutputEnabled()) return;
7991
+ const eventDate = new Date();
7927
7992
  const base = {
7928
7993
  type: 'action_event',
7929
7994
  schema_version: '1.0',
7930
- timestamp: new Date().toISOString(),
7995
+ timestamp: eventDate.toISOString(),
7931
7996
  action,
7932
7997
  ...payload
7933
7998
  };
7934
- if ('pretty' === format) return void console.log(`${base.timestamp} [action] ${action} ${JSON.stringify(payload)}`);
7935
7999
  console.log(JSON.stringify(base));
7936
8000
  }
7937
8001
  function buildHtmlSummary(html) {
@@ -8055,7 +8119,7 @@ Set background.noDynamicEntryWarning to true to disable this warning.
8055
8119
  const ctrl = this.ctx.getController();
8056
8120
  if (!ctrl) return;
8057
8121
  this.logger?.info?.(`[reload] reloading extension (reason:${reason})`);
8058
- emitActionEvent('extension_reload', {
8122
+ if (this.shouldEmitReloadActionEvent()) emitActionEvent('extension_reload', {
8059
8123
  reason: reason || 'unknown',
8060
8124
  browser: this.options?.browser
8061
8125
  });
@@ -8142,6 +8206,9 @@ Set background.noDynamicEntryWarning to true to disable this warning.
8142
8206
  }
8143
8207
  return collectedResourcePaths;
8144
8208
  }
8209
+ shouldEmitReloadActionEvent() {
8210
+ return Boolean(this.options?.source || this.options?.watchSource);
8211
+ }
8145
8212
  constructor(options, ctx){
8146
8213
  chromium_hard_reload_define_property(this, "options", void 0);
8147
8214
  chromium_hard_reload_define_property(this, "ctx", void 0);
@@ -9152,7 +9219,7 @@ Set background.noDynamicEntryWarning to true to disable this warning.
9152
9219
  const controller = this.host?.rdpController;
9153
9220
  if (controller && 'function' == typeof controller.hardReload) {
9154
9221
  const reason = this.ctx.getPendingReloadReason?.();
9155
- emitActionEvent('extension_reload', {
9222
+ if (this.shouldEmitReloadActionEvent()) emitActionEvent('extension_reload', {
9156
9223
  reason: reason || 'unknown',
9157
9224
  browser: this.host.browser
9158
9225
  });
@@ -9162,6 +9229,9 @@ Set background.noDynamicEntryWarning to true to disable this warning.
9162
9229
  done();
9163
9230
  });
9164
9231
  }
9232
+ shouldEmitReloadActionEvent() {
9233
+ return Boolean(this.host.source || this.host.watchSource);
9234
+ }
9165
9235
  constructor(host, ctx){
9166
9236
  firefox_hard_reload_define_property(this, "host", void 0);
9167
9237
  firefox_hard_reload_define_property(this, "ctx", void 0);
package/dist/928.cjs CHANGED
@@ -325,6 +325,7 @@ exports.modules = {
325
325
  }
326
326
  var webpack_config = __webpack_require__("./webpack/webpack-config.ts");
327
327
  async function dev_server_devServer(projectStructure, devOptions) {
328
+ process.env.EXTENSION_BROWSER_RUNNER_ENABLED = devOptions.noRunner ? '0' : '1';
328
329
  const { manifestPath, packageJsonPath } = projectStructure;
329
330
  const manifestDir = external_path_.dirname(manifestPath);
330
331
  const packageJsonDir = external_path_.dirname(packageJsonPath);
@@ -388,9 +389,8 @@ exports.modules = {
388
389
  host: devServerHost,
389
390
  allowedHosts: 'all',
390
391
  static: {
391
- watch: {
392
- ignored: /\bnode_modules\b/
393
- }
392
+ directory: external_path_.join(packageJsonDir, 'public'),
393
+ watch: false
394
394
  },
395
395
  compress: false,
396
396
  devMiddleware: {
@@ -405,6 +405,10 @@ exports.modules = {
405
405
  ]
406
406
  ],
407
407
  options: {
408
+ ignored: [
409
+ external_path_.join(packageJsonDir, 'dist', '**/*')
410
+ ],
411
+ ignoreInitial: true,
408
412
  usePolling: true,
409
413
  interval: 1000
410
414
  }