bun-plugin-stx 0.2.332 → 0.2.334

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.
@@ -1663,6 +1663,16 @@ else {
1663
1663
  }
1664
1664
  return '';
1665
1665
  });
1666
+ // A <style> inside a script is a string the script owns \u2014 a web
1667
+ // component's shadow-DOM CSS, typically \u2014 not a page style. Lifted into
1668
+ // <head> it restyles the whole document (its bare button rule shrank
1669
+ // every button on the page) and the component loses it. Hold scripts
1670
+ // aside while the fragment's own styles are collected.
1671
+ var heldScripts=[];
1672
+ cleanFrag=cleanFrag.replace(new RegExp('<scr'+'ipt\\\\b[^>]*>[\\\\s\\\\S]*?<\\\\/scr'+'ipt>','gi'),function(m){
1673
+ heldScripts.push(m);
1674
+ return '<!--stx-held-script-'+(heldScripts.length-1)+'-->';
1675
+ });
1666
1676
  cleanFrag=cleanFrag.replace(new RegExp('<sty'+'le\\\\b([^>]*)>([\\\\s\\\\S]*?)<\\\\/sty'+'le>','gi'),function(m,attrs,css){
1667
1677
  if(attrs.indexOf('data-css')!==-1){
1668
1678
  fragCss=css;
@@ -1677,6 +1687,7 @@ else {
1677
1687
  if(hrefMatch&&hrefMatch[2])fragCssHrefs.push(hrefMatch[2]);
1678
1688
  return '';
1679
1689
  });
1690
+ cleanFrag=cleanFrag.replace(new RegExp('<!--stx-held-script-(\\\\d+)-->','g'),function(m,i){return heldScripts[Number(i)]});
1680
1691
  // Remove old page styles (not css \u2014 that gets merged)
1681
1692
  document.querySelectorAll('style[data-stx-page]').forEach(function(s){s.remove()});
1682
1693
  // Merge css CSS from fragment into existing css style
package/dist/serve.js CHANGED
@@ -9791,7 +9791,7 @@ function __stxOverlay(errs){
9791
9791
  rebuildDiscoveredPagePaths(kept);
9792
9792
  await indexPageMiddleware(kept);
9793
9793
  try {
9794
- const { Router } = await import("./chunk-q16hhp48.js");
9794
+ const { Router } = await import("./chunk-pg39gv16.js");
9795
9795
  const pagesDirs = patterns.map((p) => p.replace(/\/$/, "")).filter(Boolean);
9796
9796
  const router = new Router(process19.cwd(), { pagesDirs, stateDir: stateDirName(), exclude: options.exclude });
9797
9797
  if (!options.quiet)
@@ -10821,8 +10821,9 @@ ${block}`;
10821
10821
  let mainContentEnd = -1;
10822
10822
  const headStyles = [];
10823
10823
  const headMatch = content.match(/<head\b[^>]*>([\s\S]*?)<\/head>/i);
10824
+ const withoutScripts = (html) => html.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi, "");
10824
10825
  if (headMatch) {
10825
- const headContent = headMatch[1];
10826
+ const headContent = withoutScripts(headMatch[1]);
10826
10827
  let styleMatch;
10827
10828
  const styleRe = /<style\b[^>]*>[\s\S]*?<\/style>/gi;
10828
10829
  while ((styleMatch = styleRe.exec(headContent)) !== null) {
@@ -10858,7 +10859,7 @@ ${block}`;
10858
10859
  if (bodyMatch) {
10859
10860
  const bodyStart = bodyMatch.index + bodyMatch[0].length;
10860
10861
  const mainIdx = mainOpenMatch.index;
10861
- const beforeMain = content.slice(bodyStart, mainIdx);
10862
+ const beforeMain = withoutScripts(content.slice(bodyStart, mainIdx));
10862
10863
  let bodyStyleMatch;
10863
10864
  const bodyStyleRe = /<style\b[^>]*>[\s\S]*?<\/style>/gi;
10864
10865
  while ((bodyStyleMatch = bodyStyleRe.exec(beforeMain)) !== null) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bun-plugin-stx",
3
3
  "type": "module",
4
- "version": "0.2.332",
4
+ "version": "0.2.334",
5
5
  "description": "A Bun plugin that allows for using Laravel Blade-like syntax.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -74,7 +74,7 @@
74
74
  "typecheck": "bun tsc --noEmit"
75
75
  },
76
76
  "dependencies": {
77
- "@stacksjs/stx": "0.2.332",
78
- "stx-router": "0.2.332"
77
+ "@stacksjs/stx": "0.2.334",
78
+ "stx-router": "0.2.334"
79
79
  }
80
80
  }