extension-develop 3.6.2 → 3.7.0-canary.169.5b5db8b

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
  }
@@ -847,18 +876,27 @@ exports.modules = {
847
876
  const { useSass = true, useLess = true } = usage;
848
877
  const isContentScript = (issuer)=>(0, is_content_script.z)(issuer, manifestPath, projectPath);
849
878
  const fileTypes = [
879
+ {
880
+ test: /\.module\.css$/,
881
+ type: 'css/module',
882
+ loader: null
883
+ },
850
884
  {
851
885
  test: /\.css$/,
886
+ exclude: /\.module\.css$/,
887
+ type: 'asset',
852
888
  loader: null
853
889
  },
854
890
  ...useSass ? [
855
891
  {
856
892
  test: /\.(sass|scss)$/,
857
893
  exclude: /\.module\.(sass|scss)$/,
894
+ type: 'asset',
858
895
  loader: 'sass-loader'
859
896
  },
860
897
  {
861
898
  test: /\.module\.(sass|scss)$/,
899
+ type: 'css/module',
862
900
  loader: 'sass-loader'
863
901
  }
864
902
  ] : [],
@@ -866,24 +904,26 @@ exports.modules = {
866
904
  {
867
905
  test: /\.less$/,
868
906
  exclude: /\.module\.less$/,
907
+ type: 'asset',
869
908
  loader: 'less-loader'
870
909
  },
871
910
  {
872
911
  test: /\.module\.less$/,
912
+ type: 'css/module',
873
913
  loader: 'less-loader'
874
914
  }
875
915
  ] : []
876
916
  ];
877
- const rules = await Promise.all(fileTypes.map(async ({ test, exclude, loader })=>{
917
+ const rules = await Promise.all(fileTypes.map(async ({ test, exclude, type = 'asset', loader })=>{
878
918
  const baseConfig = {
879
919
  test,
880
920
  exclude,
881
- type: 'asset',
882
- generator: {
883
- filename: "content_scripts/[name].[contenthash:8].css"
884
- },
921
+ type,
885
922
  issuer: isContentScript
886
923
  };
924
+ if ('asset' === type) baseConfig.generator = {
925
+ filename: "content_scripts/[name].[contenthash:8].css"
926
+ };
887
927
  if (!loader) return {
888
928
  ...baseConfig,
889
929
  use: await commonStyleLoaders(projectPath, {
@@ -908,8 +948,14 @@ exports.modules = {
908
948
  const { useSass = true, useLess = true } = usage;
909
949
  const isNotContentScript = (issuer)=>!(0, is_content_script.z)(issuer, manifestPath, projectPath);
910
950
  const fileTypes = [
951
+ {
952
+ test: /\.module\.css$/,
953
+ type: 'css/module',
954
+ loader: null
955
+ },
911
956
  {
912
957
  test: /\.css$/,
958
+ exclude: /\.module\.css$/,
913
959
  type: 'css',
914
960
  loader: null
915
961
  },
@@ -7906,15 +7952,26 @@ Set background.noDynamicEntryWarning to true to disable this warning.
7906
7952
  if ('json' === raw || 'ndjson' === raw) return raw;
7907
7953
  return 'pretty';
7908
7954
  }
7955
+ function formatPrettyClockTime(date) {
7956
+ const hh = String(date.getHours()).padStart(2, '0');
7957
+ const mm = String(date.getMinutes()).padStart(2, '0');
7958
+ const ss = String(date.getSeconds()).padStart(2, '0');
7959
+ return `${hh}:${mm}:${ss}`;
7960
+ }
7909
7961
  function emitActionEvent(action, payload = {}, format = resolveActionFormat()) {
7962
+ const eventDate = new Date();
7910
7963
  const base = {
7911
7964
  type: 'action_event',
7912
7965
  schema_version: '1.0',
7913
- timestamp: new Date().toISOString(),
7966
+ timestamp: eventDate.toISOString(),
7914
7967
  action,
7915
7968
  ...payload
7916
7969
  };
7917
- if ('pretty' === format) return void console.log(`${base.timestamp} [action] ${action} ${JSON.stringify(payload)}`);
7970
+ if ('pretty' === format) {
7971
+ const prettyTime = formatPrettyClockTime(eventDate);
7972
+ console.log(`►►► [${prettyTime}] [action] ${action} ${JSON.stringify(payload)}`);
7973
+ return;
7974
+ }
7918
7975
  console.log(JSON.stringify(base));
7919
7976
  }
7920
7977
  function buildHtmlSummary(html) {
@@ -8038,7 +8095,7 @@ Set background.noDynamicEntryWarning to true to disable this warning.
8038
8095
  const ctrl = this.ctx.getController();
8039
8096
  if (!ctrl) return;
8040
8097
  this.logger?.info?.(`[reload] reloading extension (reason:${reason})`);
8041
- emitActionEvent('extension_reload', {
8098
+ if (this.shouldEmitReloadActionEvent()) emitActionEvent('extension_reload', {
8042
8099
  reason: reason || 'unknown',
8043
8100
  browser: this.options?.browser
8044
8101
  });
@@ -8125,6 +8182,9 @@ Set background.noDynamicEntryWarning to true to disable this warning.
8125
8182
  }
8126
8183
  return collectedResourcePaths;
8127
8184
  }
8185
+ shouldEmitReloadActionEvent() {
8186
+ return Boolean(this.options?.source || this.options?.watchSource);
8187
+ }
8128
8188
  constructor(options, ctx){
8129
8189
  chromium_hard_reload_define_property(this, "options", void 0);
8130
8190
  chromium_hard_reload_define_property(this, "ctx", void 0);
@@ -9135,7 +9195,7 @@ Set background.noDynamicEntryWarning to true to disable this warning.
9135
9195
  const controller = this.host?.rdpController;
9136
9196
  if (controller && 'function' == typeof controller.hardReload) {
9137
9197
  const reason = this.ctx.getPendingReloadReason?.();
9138
- emitActionEvent('extension_reload', {
9198
+ if (this.shouldEmitReloadActionEvent()) emitActionEvent('extension_reload', {
9139
9199
  reason: reason || 'unknown',
9140
9200
  browser: this.host.browser
9141
9201
  });
@@ -9145,6 +9205,9 @@ Set background.noDynamicEntryWarning to true to disable this warning.
9145
9205
  done();
9146
9206
  });
9147
9207
  }
9208
+ shouldEmitReloadActionEvent() {
9209
+ return Boolean(this.host.source || this.host.watchSource);
9210
+ }
9148
9211
  constructor(host, ctx){
9149
9212
  firefox_hard_reload_define_property(this, "host", void 0);
9150
9213
  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
  }