mnfst-render 0.3.5 → 0.3.6

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,20 @@ 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">; drop x-icon so Alpine does not evaluate module/item.
960
+ function stripResolvedXIconDirectives(html) {
961
+ return html.replace(/<i\b([^>]*)>([\s\S]*?)<\/i>/gi, (full, attrs, inner) => {
962
+ if (!/\sx-icon\s*=/i.test(attrs)) return full;
963
+ if (!/<svg\b/i.test(inner) || !/\bdata-icon\s*=/i.test(inner)) return full;
964
+ const cleaned = attrs
965
+ .replace(/\s+x-icon\s*=\s*"[^"]*"/gi, '')
966
+ .replace(/\s+x-icon\s*=\s*'[^']*'/gi, '')
967
+ .trim();
968
+ const sp = cleaned ? ' ' : '';
969
+ return `<i${sp}${cleaned}>${inner}</i>`;
970
+ });
971
+ }
972
+
959
973
  function markPrerenderedManifestComponents(html) {
960
974
  return html.replace(/<(x-[a-z][\w-]*)([^>]*)>/gi, (full, tag, attrs) => {
961
975
  const a = attrs || '';
@@ -1826,7 +1840,7 @@ async function runPrerender(config) {
1826
1840
  await page.evaluate(() => {
1827
1841
  const loopVarRegex = /^\s*(?:\(\s*([A-Za-z_$][\w$]*)(?:\s*,\s*([A-Za-z_$][\w$]*))?\s*\)|([A-Za-z_$][\w$]*))\s+in\s+/;
1828
1842
  // 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:|@)/;
1843
+ const bindingAttrRegex = /^(?:x-bind:|:|x-text|x-html|x-show|x-if|x-model|x-effect|x-init|x-icon|x-on:|@)/;
1830
1844
  const hasVar = (expr, varName) => varName && new RegExp(`\\b${varName}\\b`).test(expr || '');
1831
1845
  const stripLoopBindings = (el, itemVar, indexVar) => {
1832
1846
  const nodes = [el, ...Array.from(el.querySelectorAll('*'))];
@@ -1920,7 +1934,7 @@ async function runPrerender(config) {
1920
1934
  // outside their template scope. These throw Alpine errors in live static hosting.
1921
1935
  await page.evaluate(() => {
1922
1936
  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:|@)/;
1937
+ const bindingAttrRegex = /^(?:x-bind:|:|x-text|x-html|x-show|x-if|x-model|x-effect|x-init|x-icon|x-on:|@)/;
1924
1938
  const hasVar = (expr, varName) => varName && new RegExp(`\\b${varName}\\b`).test(expr || '');
1925
1939
  const elementReferencesLoopScope = (el, itemVar, indexVar) => {
1926
1940
  if (!el) return false;
@@ -2023,6 +2037,7 @@ async function runPrerender(config) {
2023
2037
  html = stripPrerenderDynamicBindings(html);
2024
2038
  html = stripRedundantImgSrcBindings(html);
2025
2039
  html = stripEmptyInlineMaskStyles(html);
2040
+ html = stripResolvedXIconDirectives(html);
2026
2041
  html = rewriteHtmlAssetPaths(html, fileSegments.length);
2027
2042
  const liveBase = config.liveUrl.replace(/\/$/, '');
2028
2043
  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.6",
4
4
  "description": "Render Manifest sites to static HTML for SEO",
5
5
  "type": "module",
6
6
  "bin": {