mnfst-render 0.3.5 → 0.3.7

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.
@@ -956,6 +956,21 @@ function stripRedundantImgSrcBindings(html) {
956
956
  * prerender-baked markup (stripped :style, expanded lists, etc.). Tag opens with data-pre-rendered
957
957
  * are skipped by manifest.components.processor — required for static prerender output to hydrate correctly.
958
958
  */
959
+ // Prerender inlined Iconify SVG under <i x-icon="iterator.icon">; clear x-icon value so Alpine does not evaluate
960
+ // loop/item expressions while the attribute remains for CSS (e.g. inline layout that keys off [x-icon]).
961
+ function stripResolvedXIconDirectives(html) {
962
+ return html.replace(/<i\b([^>]*)>([\s\S]*?)<\/i>/gi, (full, attrs, inner) => {
963
+ if (!/\sx-icon\s*=/i.test(attrs)) return full;
964
+ if (!/<svg\b/i.test(inner) || !/\bdata-icon\s*=/i.test(inner)) return full;
965
+ const cleaned = attrs
966
+ .replace(/\s+x-icon\s*=\s*"[^"]*"/gi, ' x-icon=""')
967
+ .replace(/\s+x-icon\s*=\s*'[^']*'/gi, ' x-icon=""')
968
+ .trim();
969
+ const sp = cleaned ? ' ' : '';
970
+ return `<i${sp}${cleaned}>${inner}</i>`;
971
+ });
972
+ }
973
+
959
974
  function markPrerenderedManifestComponents(html) {
960
975
  return html.replace(/<(x-[a-z][\w-]*)([^>]*)>/gi, (full, tag, attrs) => {
961
976
  const a = attrs || '';
@@ -1826,7 +1841,7 @@ async function runPrerender(config) {
1826
1841
  await page.evaluate(() => {
1827
1842
  const loopVarRegex = /^\s*(?:\(\s*([A-Za-z_$][\w$]*)(?:\s*,\s*([A-Za-z_$][\w$]*))?\s*\)|([A-Za-z_$][\w$]*))\s+in\s+/;
1828
1843
  // Include x-init: expanded clones still had x-init="getDescription(article)" etc.; Alpine then throws (article undefined).
1829
- const bindingAttrRegex = /^(?:x-bind:|:|x-text|x-html|x-show|x-if|x-model|x-effect|x-init|x-on:|@)/;
1844
+ const bindingAttrRegex = /^(?:x-bind:|:|x-text|x-html|x-show|x-if|x-model|x-effect|x-init|x-icon|x-on:|@)/;
1830
1845
  const hasVar = (expr, varName) => varName && new RegExp(`\\b${varName}\\b`).test(expr || '');
1831
1846
  const stripLoopBindings = (el, itemVar, indexVar) => {
1832
1847
  const nodes = [el, ...Array.from(el.querySelectorAll('*'))];
@@ -1847,6 +1862,10 @@ async function runPrerender(config) {
1847
1862
  node.removeAttribute(name);
1848
1863
  continue;
1849
1864
  }
1865
+ if (name === 'x-icon') {
1866
+ node.setAttribute('x-icon', '');
1867
+ continue;
1868
+ }
1850
1869
  let boundAttr = '';
1851
1870
  if (name.startsWith(':')) boundAttr = name.slice(1);
1852
1871
  else if (name.startsWith('x-bind:')) boundAttr = name.slice('x-bind:'.length);
@@ -1920,7 +1939,7 @@ async function runPrerender(config) {
1920
1939
  // outside their template scope. These throw Alpine errors in live static hosting.
1921
1940
  await page.evaluate(() => {
1922
1941
  const loopVarRegex = /^\s*(?:\(\s*([A-Za-z_$][\w$]*)(?:\s*,\s*([A-Za-z_$][\w$]*))?\s*\)|([A-Za-z_$][\w$]*))\s+in\s+/;
1923
- const bindingAttrRegex = /^(?:x-bind:|:|x-text|x-html|x-show|x-if|x-model|x-effect|x-init|x-on:|@)/;
1942
+ const bindingAttrRegex = /^(?:x-bind:|:|x-text|x-html|x-show|x-if|x-model|x-effect|x-init|x-icon|x-on:|@)/;
1924
1943
  const hasVar = (expr, varName) => varName && new RegExp(`\\b${varName}\\b`).test(expr || '');
1925
1944
  const elementReferencesLoopScope = (el, itemVar, indexVar) => {
1926
1945
  if (!el) return false;
@@ -2023,6 +2042,7 @@ async function runPrerender(config) {
2023
2042
  html = stripPrerenderDynamicBindings(html);
2024
2043
  html = stripRedundantImgSrcBindings(html);
2025
2044
  html = stripEmptyInlineMaskStyles(html);
2045
+ html = stripResolvedXIconDirectives(html);
2026
2046
  html = rewriteHtmlAssetPaths(html, fileSegments.length);
2027
2047
  const liveBase = config.liveUrl.replace(/\/$/, '');
2028
2048
  const canonicalHreflang = buildCanonicalAndHreflang(is404 ? '' : pathSeg, locales, defaultLocale, liveBase);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mnfst-render",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "description": "Render Manifest sites to static HTML for SEO",
5
5
  "type": "module",
6
6
  "bin": {