extension-develop 4.1.15 → 4.1.16

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.
@@ -10277,6 +10277,26 @@ class AddDependencies {
10277
10277
  });
10278
10278
  }
10279
10279
  }
10280
+ const DEV_INJECTED_PERMISSIONS_MV3 = [
10281
+ "scripting",
10282
+ 'tabs',
10283
+ 'management',
10284
+ 'storage'
10285
+ ];
10286
+ const DEV_INJECTED_PERMISSIONS_MV2 = [
10287
+ 'tabs',
10288
+ 'storage'
10289
+ ];
10290
+ function devInjectedPermissions(manifestVersion) {
10291
+ return 3 === manifestVersion ? DEV_INJECTED_PERMISSIONS_MV3 : DEV_INJECTED_PERMISSIONS_MV2;
10292
+ }
10293
+ const PARTIALLY_GATED_APIS = {
10294
+ tabs: "Some chrome.tabs methods run without the permission, but the tab url, title and favIconUrl fields and the url and title query filters come back empty without it."
10295
+ };
10296
+ function partiallyGatedNote(api) {
10297
+ const note = PARTIALLY_GATED_APIS[api];
10298
+ return note ? ` ${note}` : '';
10299
+ }
10280
10300
  function persistentPatchFor(manifest) {
10281
10301
  return 3 === manifest.manifest_version ? {} : {
10282
10302
  persistent: true
@@ -10527,11 +10547,6 @@ function patchWebResourcesV3(manifest) {
10527
10547
  }
10528
10548
  ];
10529
10549
  }
10530
- const INJECTED_PERMISSION_APIS = [
10531
- 'storage',
10532
- "scripting",
10533
- 'management'
10534
- ];
10535
10550
  function findInjectedOnlyPermissionUses(compilation, declared, injected) {
10536
10551
  const firstOffenderByApi = new Map();
10537
10552
  const candidates = injected.filter((api)=>!declared.has(api));
@@ -10609,40 +10624,19 @@ class ApplyDevDefaults {
10609
10624
  ...optionalPermissions
10610
10625
  ]
10611
10626
  ]);
10612
- const devInjectedPermissions = 3 === canonicalManifest.manifest_version ? [
10613
- "scripting",
10614
- 'tabs',
10615
- 'management',
10616
- 'storage'
10617
- ] : [
10618
- 'tabs',
10619
- 'storage'
10620
- ];
10621
- for (const permission of devInjectedPermissions)if (optionalPermissions.has(permission) && !(canonicalManifest.permissions || []).includes(permission)) pushDevWarning('DevPromotedOptionalPermissionWarning', `manifest.json lists "${permission}" under optional_permissions, but the dev build needs it and lists it under permissions too. Listed in both means required, so in development it is granted at install and your runtime request flow never runs. The production build keeps it optional.`);
10622
- for (const match of contentScriptMatches)if (optionalHosts.has(match)) pushDevWarning('DevPromotedOptionalHostWarning', `manifest.json keeps "${match}" optional, but a content script matches it and the dev build grants that host at install so it can re-inject the script on save. In development the host is required; the production build keeps it optional.`);
10627
+ const injectedPermissions = devInjectedPermissions(canonicalManifest.manifest_version);
10628
+ for (const permission of injectedPermissions)if (optionalPermissions.has(permission) && !(canonicalManifest.permissions || []).includes(permission)) pushDevWarning('DevPromotedOptionalPermissionWarning', `manifest.json lists "${permission}" under optional_permissions, but the dev build needs it and lists it under permissions too. Listed in both means required, so in development it is granted at install and your runtime request flow never runs. The production build keeps it optional.`);
10629
+ for (const match of contentScriptMatches)if (optionalHosts.has(match)) pushDevWarning('DevPromotedOptionalHostWarning', `manifest.json keeps "${match}" optional, but a content script matches it and the dev build grants that host at install so it can re-inject the script on save. In development the host is required. The production build keeps it optional.`);
10623
10630
  const patchedManifest = {
10624
10631
  ...canonicalManifest,
10625
10632
  content_security_policy: 3 === canonicalManifest.manifest_version ? patchV3CSP(canonicalManifest) : patchV2CSP(canonicalManifest),
10626
- ...3 === canonicalManifest.manifest_version ? {
10627
- permissions: [
10628
- ...new Set([
10629
- "scripting",
10630
- 'tabs',
10631
- 'management',
10632
- 'storage',
10633
- ...canonicalManifest.permissions || []
10634
- ])
10635
- ]
10636
- } : {
10637
- permissions: [
10638
- ...new Set([
10639
- 'tabs',
10640
- 'storage',
10641
- ...contentScriptMatches,
10642
- ...canonicalManifest.permissions || []
10643
- ])
10644
- ]
10645
- },
10633
+ permissions: [
10634
+ ...new Set([
10635
+ ...injectedPermissions,
10636
+ ...3 === canonicalManifest.manifest_version ? [] : contentScriptMatches,
10637
+ ...canonicalManifest.permissions || []
10638
+ ])
10639
+ ],
10646
10640
  ...hostPermissionsPatch,
10647
10641
  ...patchBackground(canonicalManifest, this.browser),
10648
10642
  ...patchExternallyConnectable(canonicalManifest),
@@ -10650,14 +10644,11 @@ class ApplyDevDefaults {
10650
10644
  };
10651
10645
  try {
10652
10646
  const declared = new Set(canonicalManifest.permissions || []);
10653
- const injectedForEra = 3 === canonicalManifest.manifest_version ? INJECTED_PERMISSION_APIS : [
10654
- 'storage'
10655
- ];
10656
- const uses = findInjectedOnlyPermissionUses(compilation, declared, injectedForEra);
10647
+ const uses = findInjectedOnlyPermissionUses(compilation, declared, injectedPermissions);
10657
10648
  for (const [api, file] of uses){
10658
10649
  const relative = __rspack_external_path.relative(__rspack_external_path.dirname(this.manifestPath), file);
10659
10650
  const text = optionalPermissions.has(api) ? `manifest.json only lists the "${api}" permission under optional_permissions, but ${relative} uses chrome.${api}. It works in development only because the dev instrumentation injects "${api}" as required: the production build has it only after a runtime chrome.permissions.request, so guard the use or move "${api}" to permissions.` : `manifest.json does not declare the "${api}" permission, but ${relative} uses chrome.${api}. It works in development only because the dev instrumentation injects "${api}": the production build will fail at runtime. Add "${api}" to permissions in manifest.json.`;
10660
- pushDevWarning('DevInjectedPermissionWarning', text);
10651
+ pushDevWarning('DevInjectedPermissionWarning', text + partiallyGatedNote(api));
10661
10652
  }
10662
10653
  } catch {}
10663
10654
  const source = JSON.stringify(patchedManifest, null, 2);
package/dist/101.mjs CHANGED
@@ -352,7 +352,7 @@ async function isUsingExperimentalConfig(projectPath) {
352
352
  }
353
353
  return false;
354
354
  }
355
- var package_namespaceObject = /*#__PURE__*/ JSON.parse('{"rE":"4.1.15","El":{"@prefresh/core":"1.5.9","@prefresh/utils":"1.2.1","@rspack/core":"^2.1.1","@rspack/dev-server":"2.1.0","@rspack/plugin-preact-refresh":"2.0.1","@rspack/plugin-react-refresh":"2.0.2","@vue/compiler-sfc":"3.5.26","acorn":"^8.16.0","browser-extension-manifest-fields":"^2.3.1","case-sensitive-paths-webpack-plugin":"^2.4.0","content-security-policy-parser":"^0.6.0","dotenv":"^17.2.3","es-module-lexer":"^2.1.0","extension-from-store":"^0.2.5","fflate":"^0.8.3","go-git-it":"^5.1.5","ignore":"^7.0.5","less":"4.6.7","less-loader":"13.0.0","parse5-utilities":"^1.0.0","pintor":"0.3.0","postcss":"8.5.23","postcss-loader":"8.2.1","postcss-preset-env":"11.1.1","postcss-scss":"4.0.9","preact":"10.27.3","prefers-yarn":"2.0.1","react-refresh":"0.18.0","sass-loader":"17.0.0","schema-utils":"^4.3.3","svelte-loader":"3.2.4","tiny-glob":"^0.2.9","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"}}');
355
+ var package_namespaceObject = /*#__PURE__*/ JSON.parse('{"rE":"4.1.16","El":{"@prefresh/core":"1.5.9","@prefresh/utils":"1.2.1","@rspack/core":"^2.1.1","@rspack/dev-server":"2.1.0","@rspack/plugin-preact-refresh":"2.0.1","@rspack/plugin-react-refresh":"2.0.2","@vue/compiler-sfc":"3.5.26","acorn":"^8.16.0","browser-extension-manifest-fields":"^2.3.1","case-sensitive-paths-webpack-plugin":"^2.4.0","content-security-policy-parser":"^0.6.0","dotenv":"^17.2.3","es-module-lexer":"^2.1.0","extension-from-store":"^0.2.5","fflate":"^0.8.3","go-git-it":"^5.1.5","ignore":"^7.0.5","less":"4.6.7","less-loader":"13.0.0","parse5-utilities":"^1.0.0","pintor":"0.3.0","postcss":"8.5.23","postcss-loader":"8.2.1","postcss-preset-env":"11.1.1","postcss-scss":"4.0.9","preact":"10.27.3","prefers-yarn":"2.0.1","react-refresh":"0.18.0","sass-loader":"17.0.0","schema-utils":"^4.3.3","svelte-loader":"3.2.4","tiny-glob":"^0.2.9","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"}}');
356
356
  function sanitize(obj) {
357
357
  return Object.fromEntries(Object.entries(obj || {}).filter(([, value])=>void 0 !== value));
358
358
  }
@@ -0,0 +1,2 @@
1
+ export declare function devInjectedPermissions(manifestVersion: unknown): readonly string[];
2
+ export declare function partiallyGatedNote(api: string): string;
package/package.json CHANGED
@@ -43,7 +43,7 @@
43
43
  "runtime"
44
44
  ],
45
45
  "name": "extension-develop",
46
- "version": "4.1.15",
46
+ "version": "4.1.16",
47
47
  "description": "Develop, build, preview, and package Extension.js projects.",
48
48
  "author": {
49
49
  "name": "Cezar Augusto",