extension-develop 3.10.1 → 3.10.2-canary.247.0e1303f

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/270.cjs CHANGED
@@ -2662,6 +2662,14 @@ exports.modules = {
2662
2662
  } catch {}
2663
2663
  return false;
2664
2664
  }
2665
+ function isCanonicalContentScriptCss(resource) {
2666
+ return /^content_scripts\/content-\d+\.css$/.test(resource);
2667
+ }
2668
+ function toCanonicalContentScriptCss(jsFile) {
2669
+ const normalized = String(jsFile || '');
2670
+ if (!/^content_scripts\/content-\d+\.js$/.test(normalized)) return;
2671
+ return normalized.replace(/\.js$/, '.css');
2672
+ }
2665
2673
  function generateManifestPatches(compilation, manifestPath, entryImports, browser) {
2666
2674
  const canonicalManifest = getManifestContent(compilation, manifestPath);
2667
2675
  const resolved = resolveUserDeclaredWAR(compilation, manifestPath, canonicalManifest, browser);
@@ -2709,6 +2717,11 @@ exports.modules = {
2709
2717
  if (contentScript) {
2710
2718
  const matches = contentScript.matches || [];
2711
2719
  const filteredResources = resources.filter((resource)=>!resource.endsWith('.map') && !resource.endsWith('.js'));
2720
+ const importedContentCss = filteredResources.filter((resource)=>resource.endsWith('.css')).filter(isCanonicalContentScriptCss);
2721
+ if (importedContentCss.length > 0) contentScript.css = Array.from(new Set([
2722
+ ...contentScript.css || [],
2723
+ ...importedContentCss
2724
+ ])).sort();
2712
2725
  if (0 === filteredResources.length) continue;
2713
2726
  if (3 === canonicalManifest.manifest_version) {
2714
2727
  const normalizedMatches = cleanMatches(matches);
@@ -2812,6 +2825,14 @@ exports.modules = {
2812
2825
  if (3 === canonicalManifest.manifest_version) {
2813
2826
  const assetKeys = Object.keys(compilation.assets || {});
2814
2827
  const cssUnderContentScripts = assetKeys.filter((k)=>k.startsWith("content_scripts/")).filter((k)=>k.endsWith('.css')).sort();
2828
+ if (Array.isArray(canonicalManifest.content_scripts)) for (const contentScript of canonicalManifest.content_scripts){
2829
+ const jsFiles = Array.isArray(contentScript.js) ? contentScript.js : [];
2830
+ const canonicalCss = jsFiles.map(toCanonicalContentScriptCss).filter((resource)=>Boolean(resource && cssUnderContentScripts.includes(resource)));
2831
+ if (canonicalCss.length > 0) contentScript.css = Array.from(new Set([
2832
+ ...contentScript.css || [],
2833
+ ...canonicalCss
2834
+ ])).sort();
2835
+ }
2815
2836
  if (cssUnderContentScripts.length > 0) {
2816
2837
  const allMatches = Array.from(new Set((canonicalManifest.content_scripts || []).flatMap((cs)=>cs.matches || [])));
2817
2838
  const normalizedMatches = cleanMatches(allMatches);