@symbo.ls/utils 3.14.773 → 3.14.774
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/cjs/function.js +1 -1
- package/dist/cjs/metadata.js +2 -2
- package/dist/esm/function.js +1 -1
- package/dist/esm/metadata.js +2 -2
- package/function.js +4 -1
- package/metadata.js +14 -0
- package/package.json +1 -1
package/dist/cjs/function.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var u=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var a=(t,n)=>{for(var o in n)u(t,o,{get:n[o],enumerable:!0})},g=(t,n,o,e)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of p(n))!f.call(t,r)&&r!==o&&u(t,r,{get:()=>n[r],enumerable:!(e=l(n,r))||e.enumerable});return t};var x=t=>g(u({},"__esModule",{value:!0}),t);var F={};a(F,{cloneFunction:()=>
|
|
1
|
+
"use strict";var u=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var a=(t,n)=>{for(var o in n)u(t,o,{get:n[o],enumerable:!0})},g=(t,n,o,e)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of p(n))!f.call(t,r)&&r!==o&&u(t,r,{get:()=>n[r],enumerable:!(e=l(n,r))||e.enumerable});return t};var x=t=>g(u({},"__esModule",{value:!0}),t);var F={};a(F,{cloneFunction:()=>O,debounce:()=>y,debounceOnContext:()=>d,hasHandlerPlugin:()=>v,isStringFunction:()=>T,memoize:()=>m,resolveHandler:()=>w,runPluginHook:()=>b});module.exports=x(F);function y(t,n,o){let e;return function(){const r=this,s=arguments,c=function(){e=null,o||t.apply(r,s)},i=o&&!e;clearTimeout(e),e=setTimeout(c,n),i&&t.apply(r,s)}}const d=(t,n,o=300)=>{let e;return(...r)=>{clearTimeout(e),e=setTimeout(()=>{n.apply(t,r)},o)}},m=t=>{const n={};return(...o)=>{const e=o[0];if(e in n)return n[e];{const r=t(e);return n[e]=r,r}}},H=/^\s*(?:async\s+)?(?:function\b|\([^)]*\)\s*=>|[a-zA-Z_$][\w$]*\s*=>)/,T=t=>H.test(t),v=t=>{const n=t?.plugins;if(!n||!n.length)return!1;for(const o of n)if(o.resolveHandler)return!0;return!1},w=(t,n)=>{if(typeof t=="function")return t;const o=n?.context?.plugins;if(!o)return t;for(const e of o)if(e.resolveHandler){const r=e.resolveHandler(t,n);if(typeof r=="function")return r}return t},b=(t,n,...o)=>{const e=n?.context?.plugins;if(!e)return!1;let r=!1;for(const s of e)typeof s[t]=="function"&&(s[t](n,...o),r=!0);return r};function O(t,n=window){const o=function(){return t.apply(n,arguments)};for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&(o[e]=t[e]);return o}
|
package/dist/cjs/metadata.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`)},q=
|
|
1
|
+
"use strict";var S=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var W=Object.prototype.hasOwnProperty;var T=(n,r)=>{for(var t in r)S(n,t,{get:r[t],enumerable:!0})},x=(n,r,t,e)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of E(r))!W.call(n,s)&&s!==t&&S(n,s,{get:()=>r[s],enumerable:!(e=O(r,s))||e.enumerable});return n};var D=n=>x(S({},"__esModule",{value:!0}),n);var H={};T(H,{generateHeadArrayTags:()=>L,generateMetaTags:()=>_,getPageMetadata:()=>C,hashContent:()=>b});module.exports=D(H);var A=require("./types.js"),w=require("./function.js");const a=n=>{if(n==null)return"";const r={"&":"&","<":"<",">":">",'"':""","'":"'"};return n.toString().replace(/[&<>"']/g,t=>r[t])},F=n=>Object.entries(n||{}).filter(([r,t])=>t!==void 0).map(([r,t])=>`${r}="${a(t)}"`).join(" "),b=n=>{let r=5381;const t=String(n);for(let e=0;e<t.length;e++)r=(r*33^t.charCodeAt(e))>>>0;return r.toString(36)},R=new Set(["jsonLd","styles","scripts"]),L=n=>{const r=[];if(Array.isArray(n.jsonLd))for(const t of n.jsonLd){if(t==null)continue;const e=typeof t=="string"?t:JSON.stringify(t),s=String(e).replace(/<\/script/gi,"<\\/script");r.push(`<script type="application/ld+json" data-smbls-jsonld="${b(e)}">${s}<\/script>`)}if(Array.isArray(n.styles))for(const t of n.styles){if(t==null||!String(t).trim())continue;const e=String(t).replace(/<\/style/gi,"<\\/style");r.push(`<style data-smbls-style="${b(e)}">${e}</style>`)}if(Array.isArray(n.scripts))for(const t of n.scripts){if(!t)continue;const e=typeof t=="string",s=e?t:t.src;if(!s&&!t.body)continue;const o=[];s&&o.push(`src="${a(s)}"`),e||(t.type&&o.push(`type="${a(t.type)}"`),t.async&&o.push("async"),t.defer&&o.push("defer"),t.integrity&&o.push(`integrity="${a(t.integrity)}"`),t.crossorigin&&o.push(`crossorigin="${a(t.crossorigin)}"`),t.referrerpolicy&&o.push(`referrerpolicy="${a(t.referrerpolicy)}"`),t.nomodule&&o.push("nomodule"));const f=` data-smbls-script="${a(s||b(t.body||""))}"`;if(!e&&t.body){const h=String(t.body).replace(/<\/script/gi,"<\\/script");r.push(`<script ${o.join(" ")}${f}>${h}<\/script>`)}else r.push(`<script ${o.join(" ")}${f}><\/script>`)}return r},_=(n,r)=>{r||(n={...n,robots:"noindex"});const t=Object.entries(n).reduce((e,[s,o])=>{if(!o&&o!==0&&o!==!1||R.has(s))return e;if(s==="title")return e.push(`<title>${a(o)}</title>`),e;if(s==="canonical")return e.push(`<link rel="canonical" href="${a(o)}">`),e;if(s==="manifest")return e.push(`<link rel="manifest" href="${a(o)}">`),e;if(s==="favicon"||s==="favicons"||s==="icon"||s==="icons")return(Array.isArray(o)?o:[o]).forEach(p=>{if(typeof p=="string")e.push(`<link rel="icon" href="${a(p)}">`);else if(typeof p=="object"){const u=F(p);/rel=/.test(u)?e.push(`<link ${u}>`):e.push(`<link rel="icon" ${u}>`)}}),e;if(s==="alternate")return(Array.isArray(o)?o:[o]).forEach(p=>{if(typeof p=="object"){const u=Object.entries(p).filter(([i,g])=>g!==void 0).map(([i,g])=>`${i}="${a(g)}"`).join(" ");e.push(`<link rel="alternate" ${u}>`)}}),e;const f=(l,p,u="name")=>{if(typeof p=="string"||typeof p=="number"||typeof p=="boolean")e.push(`<meta ${u}="${a(l)}" content="${a(p)}">`);else if(Array.isArray(p))p.forEach(i=>{if(typeof i=="string"||typeof i=="number"||typeof i=="boolean")e.push(`<meta ${u}="${a(l)}" content="${a(i)}">`);else if(typeof i=="object"){const g=Object.entries(i).filter(([d,c])=>c!==void 0).map(([d,c])=>`${d}="${a(c)}"`).join(" ");e.push(`<meta ${g}>`)}});else if(typeof p=="object"){const i=Object.entries(p).filter(([g,d])=>d!==void 0).map(([g,d])=>`${g}="${a(d)}"`).join(" ");e.push(`<meta ${i}>`)}};if(s.startsWith("http-equiv:")){const l=s.replace("http-equiv:","");return f(l,o,"http-equiv"),e}if(s.startsWith("itemprop:")){const l=s.replace("itemprop:","");return f(l,o,"itemprop"),e}const y=["og:","twitter:","fb:","article:","profile:","book:","business:","music:","product:","video:","DC:","DCTERMS:"].find(l=>s.startsWith(l));if(y){const l=s.replace(y,"");return f(`${y.replace(":","")}:${l}`,o,y==="twitter:"||y==="DC:"||y==="DCTERMS:"?"name":"property"),e}if(s.startsWith("apple:")||s.startsWith("msapplication:")){const l=s.startsWith("apple:")?"apple-":"msapplication-",p=s.replace(/^apple:|^msapplication:/,"");return f(`${l}${p}`,o,"name"),e}return f(s,o),e},['<meta charset="UTF-8">','<meta name="viewport" content="width=device-width, initial-scale=1">']);return t.push(...L(n)),t.join(`
|
|
2
|
+
`)},q=n=>typeof n=="string"&&n.length>0&&!n.startsWith("/")&&!n.startsWith("http");function K(n,r){if(!r||typeof r!="object")return n;const t=s=>{if(!q(s))return s;const o=r[s];return o?.src?o.src:s},e={...n};for(const[s,o]of Object.entries(e))typeof o=="string"?e[s]=t(o):Array.isArray(o)&&(e[s]=o.map(f=>typeof f=="string"?t(f):f));return e}function m(n,r){if(!n||!r)return;const t=r.split(".");let e=n;for(const s of t){if(e==null||typeof e!="object")return;e=e[s]}return e}function P(n,r,t){const s=(r.config||r.settings||{}).polyglot||r.polyglot,o=t?.lang||s?.defaultLang||"en",h=(s?.translations||{})[o]||{},y=t?.state||{},l={...n};for(const[p,u]of Object.entries(l))typeof u!="string"||!u.includes("{{")||(l[p]=u.replace(/\{\{\s*([^|{}]+?)\s*(?:\|\s*(\w+)\s*)?\}\}/g,(i,g,d)=>{const c=g.trim();if(d==="polyglot")return h[c]??m(h,c)??i;if(d==="getLocalStateLang")return m(y,c+o)??i;const $=m(y,c);return $!==void 0?$:h[c]??m(h,c)??i}));return l}function M(n){if(!(0,A.isObject)(n))return{};const r={...n};for(const[t,e]of Object.entries(r))if(typeof e=="function"){const s=e.toString(),o=s.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(o){r[t]=`{{ ${o[1]} | getLocalStateLang }}`;continue}const f=s.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(f){r[t]=`{{ ${f[1]} | polyglot }}`;continue}const h=s.match(/s\.(\w+(?:\.\w+)+)/);if(h){r[t]=`{{ ${h[1]} }}`;continue}delete r[t]}else if(typeof e=="string"){const s=e.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(s){r[t]=`{{ ${s[1]} | getLocalStateLang }}`;continue}const o=e.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(o){r[t]=`{{ ${o[1]} | polyglot }}`;continue}if(e.includes("=>")&&e.includes("s.")){const f=e.match(/s\.(\w+(?:\.\w+)+)/);if(f){r[t]=`{{ ${f[1]} }}`;continue}}(0,w.isStringFunction)(e)&&delete r[t]}return r}function C(n,r,t,{isProduction:e=!1,channel:s="production"}={}){const o=n.pages?.[r],f=(0,A.isObject)(o?.state)&&o?.state,h=o?.metadata||o?.helmet||f||{},y=M(h),l=new Set(Object.keys(y)),p=n.app?.metadata||{},u=M(p);let i={};if(n.integrations?.seo?i={...n.integrations.seo,...u,...y}:Object.keys(u).length?i={...u,...y}:i={...y},!i.title){const c=n.name||n.key;c?e?i.title=c:s==="development"?i.title=`${c} / dev:symbo.ls`:s==="staging"?i.title=`${c} / staging:symbo.ls`:i.title=`${c} / symbo.ls`:i.title="Symbols demo"}i=P(i,n,t),i.title&&(l.has("title")||!i["og:title"])&&(l.has("og:title")||(i["og:title"]=i.title)),i.description&&(l.has("description")||!i["og:description"])&&(l.has("og:description")||(i["og:description"]=i.description)),i.title&&!i["twitter:title"]&&(i["twitter:title"]=i.title),i.description&&!i["twitter:description"]&&(i["twitter:description"]=i.description);const g=t?.actualPathname||r;if(i["og:url"]||i.url){const c=(i["og:url"]||i.url||"").replace(/\/$/,"");if(c&&g&&g!=="/"){const $=g.startsWith("/")?g:"/"+g;i["og:url"]=c+$}}i=K(i,n.files);const d=n.name||n.app?.metadata?.title||n.app?.name||"";for(const[c,$]of Object.entries(i))if(typeof $=="string"&&$.includes("{{")){const j=$.replace(/\{\{[^}]*\}\}/g,"").trim();j?i[c]=j:c==="title"?i[c]=d:delete i[c]}return i}
|
package/dist/esm/function.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function l(t,e,o){let n;return function(){const r=this,s=arguments,u=function(){n=null,o||t.apply(r,s)},c=o&&!n;clearTimeout(n),n=setTimeout(u,e),c&&t.apply(r,s)}}const p=(t,e,o=300)=>{let n;return(...r)=>{clearTimeout(n),n=setTimeout(()=>{e.apply(t,r)},o)}},f=t=>{const e={};return(...o)=>{const n=o[0];if(n in e)return e[n];{const r=t(n);return e[n]=r,r}}},i
|
|
1
|
+
function l(t,e,o){let n;return function(){const r=this,s=arguments,u=function(){n=null,o||t.apply(r,s)},c=o&&!n;clearTimeout(n),n=setTimeout(u,e),c&&t.apply(r,s)}}const p=(t,e,o=300)=>{let n;return(...r)=>{clearTimeout(n),n=setTimeout(()=>{e.apply(t,r)},o)}},f=t=>{const e={};return(...o)=>{const n=o[0];if(n in e)return e[n];{const r=t(n);return e[n]=r,r}}},i=/^\s*(?:async\s+)?(?:function\b|\([^)]*\)\s*=>|[a-zA-Z_$][\w$]*\s*=>)/,a=t=>i.test(t),g=t=>{const e=t?.plugins;if(!e||!e.length)return!1;for(const o of e)if(o.resolveHandler)return!0;return!1},x=(t,e)=>{if(typeof t=="function")return t;const o=e?.context?.plugins;if(!o)return t;for(const n of o)if(n.resolveHandler){const r=n.resolveHandler(t,e);if(typeof r=="function")return r}return t},y=(t,e,...o)=>{const n=e?.context?.plugins;if(!n)return!1;let r=!1;for(const s of n)typeof s[t]=="function"&&(s[t](e,...o),r=!0);return r};function d(t,e=window){const o=function(){return t.apply(e,arguments)};for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(o[n]=t[n]);return o}export{d as cloneFunction,l as debounce,p as debounceOnContext,g as hasHandlerPlugin,a as isStringFunction,f as memoize,x as resolveHandler,y as runPluginHook};
|
package/dist/esm/metadata.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{isObject as S}from"./types.js";const a=r=>{if(r==null)return"";const o={"&":"&","<":"<",">":">",'"':""","'":"'"};return r.toString().replace(/[&<>"']/g,e=>o[e])},
|
|
2
|
-
`)},
|
|
1
|
+
import{isObject as S}from"./types.js";import{isStringFunction as M}from"./function.js";const a=r=>{if(r==null)return"";const o={"&":"&","<":"<",">":">",'"':""","'":"'"};return r.toString().replace(/[&<>"']/g,e=>o[e])},w=r=>Object.entries(r||{}).filter(([o,e])=>e!==void 0).map(([o,e])=>`${o}="${a(e)}"`).join(" "),j=r=>{let o=5381;const e=String(r);for(let t=0;t<e.length;t++)o=(o*33^e.charCodeAt(t))>>>0;return o.toString(36)},L=new Set(["jsonLd","styles","scripts"]),O=r=>{const o=[];if(Array.isArray(r.jsonLd))for(const e of r.jsonLd){if(e==null)continue;const t=typeof e=="string"?e:JSON.stringify(e),n=String(t).replace(/<\/script/gi,"<\\/script");o.push(`<script type="application/ld+json" data-smbls-jsonld="${j(t)}">${n}<\/script>`)}if(Array.isArray(r.styles))for(const e of r.styles){if(e==null||!String(e).trim())continue;const t=String(e).replace(/<\/style/gi,"<\\/style");o.push(`<style data-smbls-style="${j(t)}">${t}</style>`)}if(Array.isArray(r.scripts))for(const e of r.scripts){if(!e)continue;const t=typeof e=="string",n=t?e:e.src;if(!n&&!e.body)continue;const i=[];n&&i.push(`src="${a(n)}"`),t||(e.type&&i.push(`type="${a(e.type)}"`),e.async&&i.push("async"),e.defer&&i.push("defer"),e.integrity&&i.push(`integrity="${a(e.integrity)}"`),e.crossorigin&&i.push(`crossorigin="${a(e.crossorigin)}"`),e.referrerpolicy&&i.push(`referrerpolicy="${a(e.referrerpolicy)}"`),e.nomodule&&i.push("nomodule"));const f=` data-smbls-script="${a(n||j(e.body||""))}"`;if(!t&&e.body){const h=String(e.body).replace(/<\/script/gi,"<\\/script");o.push(`<script ${i.join(" ")}${f}>${h}<\/script>`)}else o.push(`<script ${i.join(" ")}${f}><\/script>`)}return o},F=(r,o)=>{o||(r={...r,robots:"noindex"});const e=Object.entries(r).reduce((t,[n,i])=>{if(!i&&i!==0&&i!==!1||L.has(n))return t;if(n==="title")return t.push(`<title>${a(i)}</title>`),t;if(n==="canonical")return t.push(`<link rel="canonical" href="${a(i)}">`),t;if(n==="manifest")return t.push(`<link rel="manifest" href="${a(i)}">`),t;if(n==="favicon"||n==="favicons"||n==="icon"||n==="icons")return(Array.isArray(i)?i:[i]).forEach(p=>{if(typeof p=="string")t.push(`<link rel="icon" href="${a(p)}">`);else if(typeof p=="object"){const u=w(p);/rel=/.test(u)?t.push(`<link ${u}>`):t.push(`<link rel="icon" ${u}>`)}}),t;if(n==="alternate")return(Array.isArray(i)?i:[i]).forEach(p=>{if(typeof p=="object"){const u=Object.entries(p).filter(([s,g])=>g!==void 0).map(([s,g])=>`${s}="${a(g)}"`).join(" ");t.push(`<link rel="alternate" ${u}>`)}}),t;const f=(l,p,u="name")=>{if(typeof p=="string"||typeof p=="number"||typeof p=="boolean")t.push(`<meta ${u}="${a(l)}" content="${a(p)}">`);else if(Array.isArray(p))p.forEach(s=>{if(typeof s=="string"||typeof s=="number"||typeof s=="boolean")t.push(`<meta ${u}="${a(l)}" content="${a(s)}">`);else if(typeof s=="object"){const g=Object.entries(s).filter(([d,c])=>c!==void 0).map(([d,c])=>`${d}="${a(c)}"`).join(" ");t.push(`<meta ${g}>`)}});else if(typeof p=="object"){const s=Object.entries(p).filter(([g,d])=>d!==void 0).map(([g,d])=>`${g}="${a(d)}"`).join(" ");t.push(`<meta ${s}>`)}};if(n.startsWith("http-equiv:")){const l=n.replace("http-equiv:","");return f(l,i,"http-equiv"),t}if(n.startsWith("itemprop:")){const l=n.replace("itemprop:","");return f(l,i,"itemprop"),t}const y=["og:","twitter:","fb:","article:","profile:","book:","business:","music:","product:","video:","DC:","DCTERMS:"].find(l=>n.startsWith(l));if(y){const l=n.replace(y,"");return f(`${y.replace(":","")}:${l}`,i,y==="twitter:"||y==="DC:"||y==="DCTERMS:"?"name":"property"),t}if(n.startsWith("apple:")||n.startsWith("msapplication:")){const l=n.startsWith("apple:")?"apple-":"msapplication-",p=n.replace(/^apple:|^msapplication:/,"");return f(`${l}${p}`,i,"name"),t}return f(n,i),t},['<meta charset="UTF-8">','<meta name="viewport" content="width=device-width, initial-scale=1">']);return e.push(...O(r)),e.join(`
|
|
2
|
+
`)},E=r=>typeof r=="string"&&r.length>0&&!r.startsWith("/")&&!r.startsWith("http");function W(r,o){if(!o||typeof o!="object")return r;const e=n=>{if(!E(n))return n;const i=o[n];return i?.src?i.src:n},t={...r};for(const[n,i]of Object.entries(t))typeof i=="string"?t[n]=e(i):Array.isArray(i)&&(t[n]=i.map(f=>typeof f=="string"?e(f):f));return t}function m(r,o){if(!r||!o)return;const e=o.split(".");let t=r;for(const n of e){if(t==null||typeof t!="object")return;t=t[n]}return t}function T(r,o,e){const n=(o.config||o.settings||{}).polyglot||o.polyglot,i=e?.lang||n?.defaultLang||"en",h=(n?.translations||{})[i]||{},y=e?.state||{},l={...r};for(const[p,u]of Object.entries(l))typeof u!="string"||!u.includes("{{")||(l[p]=u.replace(/\{\{\s*([^|{}]+?)\s*(?:\|\s*(\w+)\s*)?\}\}/g,(s,g,d)=>{const c=g.trim();if(d==="polyglot")return h[c]??m(h,c)??s;if(d==="getLocalStateLang")return m(y,c+i)??s;const $=m(y,c);return $!==void 0?$:h[c]??m(h,c)??s}));return l}function A(r){if(!S(r))return{};const o={...r};for(const[e,t]of Object.entries(o))if(typeof t=="function"){const n=t.toString(),i=n.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(i){o[e]=`{{ ${i[1]} | getLocalStateLang }}`;continue}const f=n.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(f){o[e]=`{{ ${f[1]} | polyglot }}`;continue}const h=n.match(/s\.(\w+(?:\.\w+)+)/);if(h){o[e]=`{{ ${h[1]} }}`;continue}delete o[e]}else if(typeof t=="string"){const n=t.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(n){o[e]=`{{ ${n[1]} | getLocalStateLang }}`;continue}const i=t.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(i){o[e]=`{{ ${i[1]} | polyglot }}`;continue}if(t.includes("=>")&&t.includes("s.")){const f=t.match(/s\.(\w+(?:\.\w+)+)/);if(f){o[e]=`{{ ${f[1]} }}`;continue}}M(t)&&delete o[e]}return o}function R(r,o,e,{isProduction:t=!1,channel:n="production"}={}){const i=r.pages?.[o],f=S(i?.state)&&i?.state,h=i?.metadata||i?.helmet||f||{},y=A(h),l=new Set(Object.keys(y)),p=r.app?.metadata||{},u=A(p);let s={};if(r.integrations?.seo?s={...r.integrations.seo,...u,...y}:Object.keys(u).length?s={...u,...y}:s={...y},!s.title){const c=r.name||r.key;c?t?s.title=c:n==="development"?s.title=`${c} / dev:symbo.ls`:n==="staging"?s.title=`${c} / staging:symbo.ls`:s.title=`${c} / symbo.ls`:s.title="Symbols demo"}s=T(s,r,e),s.title&&(l.has("title")||!s["og:title"])&&(l.has("og:title")||(s["og:title"]=s.title)),s.description&&(l.has("description")||!s["og:description"])&&(l.has("og:description")||(s["og:description"]=s.description)),s.title&&!s["twitter:title"]&&(s["twitter:title"]=s.title),s.description&&!s["twitter:description"]&&(s["twitter:description"]=s.description);const g=e?.actualPathname||o;if(s["og:url"]||s.url){const c=(s["og:url"]||s.url||"").replace(/\/$/,"");if(c&&g&&g!=="/"){const $=g.startsWith("/")?g:"/"+g;s["og:url"]=c+$}}s=W(s,r.files);const d=r.name||r.app?.metadata?.title||r.app?.name||"";for(const[c,$]of Object.entries(s))if(typeof $=="string"&&$.includes("{{")){const b=$.replace(/\{\{[^}]*\}\}/g,"").trim();b?s[c]=b:c==="title"?s[c]=d:delete s[c]}return s}export{O as generateHeadArrayTags,F as generateMetaTags,R as getPageMetadata,j as hashContent};
|
package/function.js
CHANGED
|
@@ -67,7 +67,10 @@ export const memoize = fn => {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
// A function's source, however it was written: `function (…) {…}` (a method
|
|
71
|
+
// shorthand's `name (…) {` is NOT one — that is how object literals read),
|
|
72
|
+
// `(…) =>`, `x =>`, each with an optional `async`.
|
|
73
|
+
const RE_STRING_FUNCTION = /^\s*(?:async\s+)?(?:function\b|\([^)]*\)\s*=>|[a-zA-Z_$][\w$]*\s*=>)/
|
|
71
74
|
|
|
72
75
|
export const isStringFunction = inputString => {
|
|
73
76
|
return RE_STRING_FUNCTION.test(inputString)
|
package/metadata.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
import { isObject } from './types.js'
|
|
4
|
+
import { isStringFunction } from './function.js'
|
|
4
5
|
|
|
5
6
|
const escapeHtml = (text) => {
|
|
6
7
|
if (text === null || text === undefined) return ''
|
|
@@ -357,6 +358,13 @@ function resolveMetadataTemplates (metadata, data, ssrContext) {
|
|
|
357
358
|
* (el, s) => s.item ? s.item.image_url : ""
|
|
358
359
|
*/
|
|
359
360
|
function convertFunctionMetaToTemplates (metadata) {
|
|
361
|
+
// A page may set `metadata` itself to a function ((el, s) => ({ title… })):
|
|
362
|
+
// the runtime helmet resolves that against live state, the publish
|
|
363
|
+
// pipeline cannot. In the project JSON it is a string — spreading it made
|
|
364
|
+
// one <meta> per CHARACTER of its source (`<meta name="0" content="(">`,
|
|
365
|
+
// 137 of them on aihouse's home page, 2026-09-24). Nothing to read here;
|
|
366
|
+
// the app-level metadata is what the static head gets.
|
|
367
|
+
if (!isObject(metadata)) return {}
|
|
360
368
|
const result = { ...metadata }
|
|
361
369
|
for (const [key, value] of Object.entries(result)) {
|
|
362
370
|
if (typeof value === 'function') {
|
|
@@ -401,6 +409,12 @@ function convertFunctionMetaToTemplates (metadata) {
|
|
|
401
409
|
continue
|
|
402
410
|
}
|
|
403
411
|
}
|
|
412
|
+
// Still a function's source — `(el, s) => el.call('propertyMetadata').title`
|
|
413
|
+
// — that none of the patterns read: the runtime resolves it, the static
|
|
414
|
+
// head must not print code into a <meta content>.
|
|
415
|
+
if (isStringFunction(value)) {
|
|
416
|
+
delete result[key]
|
|
417
|
+
}
|
|
404
418
|
}
|
|
405
419
|
}
|
|
406
420
|
return result
|