extension-develop 3.18.3 → 3.18.4

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 (29) hide show
  1. package/dist/0~dev-server.mjs +6 -2
  2. package/dist/0~rslib-runtime.mjs +1 -17
  3. package/dist/0~rspack-config.mjs +136 -1
  4. package/dist/946.mjs +1 -1
  5. package/dist/extension-js-devtools/chrome/content_scripts/content-0.js +2 -2
  6. package/dist/extension-js-devtools/chromium/content_scripts/content-0.js +2 -2
  7. package/dist/extension-js-devtools/edge/content_scripts/content-0.js +2 -2
  8. package/dist/extension-js-devtools/extension-js/chrome/events.ndjson +2 -2
  9. package/dist/extension-js-devtools/extension-js/chrome/ready.json +5 -5
  10. package/dist/extension-js-devtools/extension-js/chromium/events.ndjson +2 -2
  11. package/dist/extension-js-devtools/extension-js/chromium/ready.json +5 -5
  12. package/dist/extension-js-devtools/extension-js/edge/events.ndjson +2 -2
  13. package/dist/extension-js-devtools/extension-js/edge/ready.json +5 -5
  14. package/dist/extension-js-devtools/extension-js/firefox/events.ndjson +2 -2
  15. package/dist/extension-js-devtools/extension-js/firefox/ready.json +5 -5
  16. package/dist/extension-js-devtools/firefox/content_scripts/content-0.js +2 -2
  17. package/dist/extension-js-theme/extension-js/chrome/events.ndjson +2 -2
  18. package/dist/extension-js-theme/extension-js/chrome/ready.json +5 -5
  19. package/dist/extension-js-theme/extension-js/chromium/events.ndjson +2 -2
  20. package/dist/extension-js-theme/extension-js/chromium/ready.json +5 -5
  21. package/dist/extension-js-theme/extension-js/edge/events.ndjson +2 -2
  22. package/dist/extension-js-theme/extension-js/edge/ready.json +5 -5
  23. package/dist/extension-js-theme/extension-js/firefox/events.ndjson +4 -4
  24. package/dist/extension-js-theme/extension-js/firefox/ready.json +5 -5
  25. package/dist/feature-scripts-content-script-wrapper.js +5 -37
  26. package/dist/feature-scripts-content-script-wrapper.mjs +5 -37
  27. package/package.json +2 -7
  28. package/dist/resolve-paths-loader.js +0 -1300
  29. package/dist/resolve-paths-loader.mjs +0 -1300
@@ -569,11 +569,15 @@ class BridgeBroker {
569
569
  reload: this.allowControl,
570
570
  open: this.allowControl ? isFirefox ? [
571
571
  'popup',
572
- 'options'
572
+ 'options',
573
+ 'action',
574
+ 'command'
573
575
  ] : [
574
576
  'popup',
575
577
  'options',
576
- 'sidebar'
578
+ 'sidebar',
579
+ 'action',
580
+ 'command'
577
581
  ] : [],
578
582
  deepDom: 'chromium' === this.engine
579
583
  }
@@ -1,16 +1,5 @@
1
1
  import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
2
- var __webpack_modules__ = {};
3
- var __webpack_module_cache__ = {};
4
- function __webpack_require__(moduleId) {
5
- var cachedModule = __webpack_module_cache__[moduleId];
6
- if (void 0 !== cachedModule) return cachedModule.exports;
7
- var module = __webpack_module_cache__[moduleId] = {
8
- exports: {}
9
- };
10
- __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
11
- return module.exports;
12
- }
13
- __webpack_require__.m = __webpack_modules__;
2
+ var __webpack_require__ = {};
14
3
  (()=>{
15
4
  __webpack_require__.d = (exports, definition)=>{
16
5
  for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
@@ -19,11 +8,6 @@ __webpack_require__.m = __webpack_modules__;
19
8
  });
20
9
  };
21
10
  })();
22
- (()=>{
23
- __webpack_require__.add = function(modules) {
24
- Object.assign(__webpack_require__.m, modules);
25
- };
26
- })();
27
11
  (()=>{
28
12
  __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
29
13
  })();
@@ -3108,6 +3108,25 @@ function purgeStaleHashedContentScripts(compilation, currentNames) {
3108
3108
  }
3109
3109
  } catch {}
3110
3110
  }
3111
+ function isGeckoBrowser(browser) {
3112
+ const b = String(browser);
3113
+ return 'firefox' === b || b.includes('firefox') || b.includes('gecko');
3114
+ }
3115
+ function patchGeckoBackground(manifest, browser) {
3116
+ if (!isGeckoBrowser(browser)) return manifest;
3117
+ const background = manifest.background;
3118
+ if (!background || !background.service_worker || background.scripts) return manifest;
3119
+ const { service_worker, type, ...rest } = background;
3120
+ return {
3121
+ ...manifest,
3122
+ background: {
3123
+ ...rest,
3124
+ scripts: [
3125
+ service_worker
3126
+ ]
3127
+ }
3128
+ };
3129
+ }
3111
3130
  class UpdateManifest {
3112
3131
  manifestPath;
3113
3132
  browser;
@@ -3133,6 +3152,7 @@ class UpdateManifest {
3133
3152
  if (compilation.errors.length > 0) return;
3134
3153
  const manifest = getManifestContent(compilation, this.manifestPath);
3135
3154
  let patchedManifest = buildCanonicalManifest(this.manifestPath, manifest, this.browser);
3155
+ patchedManifest = patchGeckoBackground(patchedManifest, this.browser);
3136
3156
  const overrides = getManifestOverrides(this.manifestPath, manifest);
3137
3157
  if ('development' === compiler.options.mode) patchedManifest = patchDevContentScriptManifestPaths(compilation, patchedManifest);
3138
3158
  if ('development' === compiler.options.mode) {
@@ -6647,6 +6667,44 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
6647
6667
  var consoleRef = g.console || {};
6648
6668
  g.__extjsBridgeProducerInstalled = true;
6649
6669
 
6670
+ // Capture extension event listeners at install time. The producer is
6671
+ // prepended to the background bundle, so these wraps run BEFORE user code
6672
+ // registers its listeners — letting the bridge replay them on demand. The
6673
+ // platform exposes no API to dispatch these events, and CDP attaches too
6674
+ // late to wrap addListener, so this is the only path. Replay invokes the
6675
+ // handler WITHOUT a user gesture, so the gesture-derived activeTab grant
6676
+ // does NOT apply (callers are told gesture:false). This is engine-agnostic:
6677
+ // it works on Chromium and Gecko because it only touches addListener.
6678
+ //
6679
+ // captureEvent transparently wraps addListener/removeListener (delegating to
6680
+ // the originals) and records callbacks into the sink array.
6681
+ function captureEvent(event, sink) {
6682
+ try {
6683
+ if (!event || typeof event.addListener !== "function") return;
6684
+ var origAdd = event.addListener.bind(event);
6685
+ event.addListener = function (cb) {
6686
+ if (typeof cb === "function" && sink.indexOf(cb) === -1) sink.push(cb);
6687
+ return origAdd(cb);
6688
+ };
6689
+ if (typeof event.removeListener === "function") {
6690
+ var origRemove = event.removeListener.bind(event);
6691
+ event.removeListener = function (cb) {
6692
+ var i = sink.indexOf(cb);
6693
+ if (i !== -1) sink.splice(i, 1);
6694
+ return origRemove(cb);
6695
+ };
6696
+ }
6697
+ } catch (e) { /* non-fatal: trigger falls back to its no-listener reply */ }
6698
+ }
6699
+
6700
+ // Use g.chrome (not the hoisted chrome var below) — this runs first.
6701
+ var actionClickedListeners = [];
6702
+ var commandListeners = [];
6703
+ if (g.chrome) {
6704
+ captureEvent(g.chrome.action && g.chrome.action.onClicked, actionClickedListeners);
6705
+ captureEvent(g.chrome.commands && g.chrome.commands.onCommand, commandListeners);
6706
+ }
6707
+
6650
6708
  var LEVELS = ["log", "info", "warn", "error", "debug", "trace"];
6651
6709
  var socket = null;
6652
6710
  var open = false;
@@ -6751,6 +6809,42 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
6751
6809
  }
6752
6810
  if (op === "open") {
6753
6811
  var surface = args.surface || ctx;
6812
+ // getPopup is promise-style on Gecko and (MV3) Chromium; fall back to
6813
+ // callback-style for older Chromium. Always resolves to a string.
6814
+ var getActionPopup = function (cb) {
6815
+ try {
6816
+ var r = chrome.action && chrome.action.getPopup && chrome.action.getPopup({});
6817
+ if (r && typeof r.then === "function") {
6818
+ r.then(function (p) { cb(p || ""); }, function () { cb(""); });
6819
+ return;
6820
+ }
6821
+ } catch (e) {}
6822
+ try { chrome.action.getPopup({}, function (p) { cb(p || ""); }); }
6823
+ catch (e) { cb(""); }
6824
+ };
6825
+ // Resolve the tab a replayed event should carry: an explicit args.tabId,
6826
+ // else the active tab of the focused window.
6827
+ var resolveActiveTab = function (a, cb) {
6828
+ if (a && typeof a.tabId === "number") {
6829
+ try { chrome.tabs.get(a.tabId, function (t) { cb(t || {id: a.tabId}); }); return; }
6830
+ catch (e) {}
6831
+ }
6832
+ try { chrome.tabs.query({active: true, lastFocusedWindow: true}, function (tabs) { cb((tabs && tabs[0]) || undefined); }); }
6833
+ catch (e) { cb(undefined); }
6834
+ };
6835
+ // Replaying a listener carries no user gesture, so activeTab is never
6836
+ // granted. Warn when the manifest declares it (handler will diverge
6837
+ // from a real click).
6838
+ var activeTabWarning = function () {
6839
+ try {
6840
+ var m = chrome.runtime.getManifest();
6841
+ var perms = (m && m.permissions) || [];
6842
+ if (perms.indexOf("activeTab") !== -1) {
6843
+ return "replayed without a user gesture: activeTab is NOT granted, so APIs that depend on it (scripting on the active tab, captureVisibleTab) behave differently than a real click";
6844
+ }
6845
+ } catch (e) {}
6846
+ return null;
6847
+ };
6754
6848
  if (surface === "popup") {
6755
6849
  if (chrome.action && chrome.action.openPopup) {
6756
6850
  chrome.action.openPopup().then(function () { replyOk(cmdId, {opened: "popup"}); }, function (e) { replyErr(cmdId, "Unsupported", "openPopup: " + e); });
@@ -6764,6 +6858,47 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
6764
6858
  chrome.sidePanel.open({windowId: w.id}).then(function () { replyOk(cmdId, {opened: "sidebar"}); }, function (e) { replyErr(cmdId, "Unsupported", "sidePanel.open: " + e); });
6765
6859
  });
6766
6860
  } else { replyErr(cmdId, "Unsupported", "sidePanel not available (engine: " + engineName() + ")"); }
6861
+ } else if (surface === "action") {
6862
+ // Trigger the toolbar action. With a default_popup, clicking the icon
6863
+ // opens it (reuse openPopup). Without a popup, clicking fires
6864
+ // chrome.action.onClicked — we replay the listeners captured at install.
6865
+ if (chrome.action) {
6866
+ getActionPopup(function (popup) {
6867
+ if (popup) {
6868
+ try {
6869
+ chrome.action.openPopup().then(function () { replyOk(cmdId, {triggered: "popup"}); }, function (e) { replyErr(cmdId, "Unsupported", "openPopup: " + e); });
6870
+ } catch (e) { replyErr(cmdId, "Unsupported", "openPopup: " + e); }
6871
+ } else if (actionClickedListeners.length) {
6872
+ resolveActiveTab(args, function (tab) {
6873
+ var fired = 0;
6874
+ for (var i = 0; i < actionClickedListeners.length; i++) {
6875
+ try { actionClickedListeners[i](tab); fired++; } catch (e) {}
6876
+ }
6877
+ var reply = {triggered: "onClicked", listeners: fired, gesture: false};
6878
+ var warning = activeTabWarning();
6879
+ if (warning) reply.warning = warning;
6880
+ replyOk(cmdId, reply);
6881
+ });
6882
+ } else {
6883
+ replyErr(cmdId, "Unsupported", "action has no popup and no onClicked listener registered");
6884
+ }
6885
+ });
6886
+ } else { replyErr(cmdId, "Unsupported", "chrome.action not available (engine: " + engineName() + ")"); }
6887
+ } else if (surface === "command") {
6888
+ // Replay a captured chrome.commands.onCommand listener (keyboard
6889
+ // shortcut). Same no-gesture caveat as onClicked.
6890
+ var commandName = (args && args.name) || undefined;
6891
+ if (!commandListeners.length) {
6892
+ replyErr(cmdId, "Unsupported", "no chrome.commands.onCommand listener registered");
6893
+ } else {
6894
+ resolveActiveTab(args, function (tab) {
6895
+ var fired = 0;
6896
+ for (var i = 0; i < commandListeners.length; i++) {
6897
+ try { commandListeners[i](commandName, tab); fired++; } catch (e) {}
6898
+ }
6899
+ replyOk(cmdId, {triggered: "command", command: commandName || null, listeners: fired, gesture: false});
6900
+ });
6901
+ }
6767
6902
  } else { replyErr(cmdId, "BadRequest", "unknown surface: " + surface); }
6768
6903
  return;
6769
6904
  }
@@ -7068,7 +7203,7 @@ function buildBridgeProducerSource(opts) {
7068
7203
  if (!opts.controlPort || opts.controlPort < 1) return '';
7069
7204
  return BRIDGE_PRODUCER_SOURCE.replace(/__EXTJS_CONTROL_PORT__/g, String(opts.controlPort)).replace(/__EXTJS_INSTANCE_ID__/g, String(opts.instanceId)).replace(/__EXTJS_CONTEXT__/g, String(opts.context || 'background'));
7070
7205
  }
7071
- const inject_bridge_producer_BACKGROUND_ASSET = /(^|\/)background\/(?:service_worker|script)\.js$/i;
7206
+ const inject_bridge_producer_BACKGROUND_ASSET = /(^|\/)background\/(?:service_worker|scripts?)\.js$/i;
7072
7207
  class InjectBridgeProducer {
7073
7208
  apply(compiler) {
7074
7209
  const controlPort = parseInt(String(process.env.EXTENSION_CONTROL_PORT || ''), 10);
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.18.3","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":"2.0.1","@rspack/plugin-react-refresh":"1.6.2","@swc/core":"^1.15.8","@swc/helpers":"^0.5.18","@vue/compiler-sfc":"3.5.26","adm-zip":"^0.5.16","browser-extension-manifest-fields":"^2.2.3","case-sensitive-paths-webpack-plugin":"^2.4.0","content-security-policy-parser":"^0.6.0","cross-spawn":"^7.0.6","dotenv":"^17.2.3","extension-from-store":"^0.1.1","go-git-it":"^5.1.5","ignore":"^7.0.5","less":"4.5.1","less-loader":"12.3.2","loader-utils":"^3.3.1","magic-string":"^0.30.21","parse5-utilities":"^1.0.0","pintor":"0.3.0","postcss":"8.5.10","postcss-loader":"8.2.1","postcss-preset-env":"11.1.1","postcss-scss":"4.0.9","preact":"10.27.3","react-refresh":"0.18.0","sass-loader":"16.0.7","schema-utils":"^4.3.3","svelte-loader":"3.2.4","tiny-glob":"^0.2.9","typescript":"5.9.3","unique-names-generator":"^4.7.1","vue":"3.5.26","vue-loader":"17.4.2","webextension-polyfill":"^0.12.0","webpack-merge":"^6.0.1","webpack-target-webextension":"^2.1.3","ws":"^8.20.1"}}');
15
+ var package_namespaceObject = JSON.parse('{"rE":"3.18.4","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":"2.0.1","@rspack/plugin-react-refresh":"1.6.2","@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","dotenv":"^17.2.3","es-module-lexer":"^1.7.0","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","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","vue":"3.5.26","vue-loader":"17.4.2","webextension-polyfill":"^0.12.0","webpack-merge":"^6.0.1","webpack-target-webextension":"^2.1.3","ws":"^8.20.1"}}');
16
16
  const fmt = {
17
17
  heading: (title)=>pintor.underline(pintor.blue(title)),
18
18
  label: (key)=>pintor.gray(key.toUpperCase()),