@symbo.ls/utils 3.14.786 → 3.14.788

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/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # @symbo.ls/utils
2
2
 
3
+ ## 3.14.788
4
+
5
+ ### Patch Changes
6
+
7
+ - Server renders run one at a time per process, and a page at /<lang>/… starts in that language.
8
+
9
+ - brender: `render()` (and `renderRoute` / `renderPage`) run one at a time per process; a per-render `timeout` (default 30 s, `0`/`false` turns it off) rejects with `BRENDER_RENDER_TIMEOUT`, puts the render's globals back and lets the next render start.
10
+ - brender + mermaid: before the app starts, the render stores the address's language (the first path segment, when it is one of the project's languages) under polyglot's key, so the fetch seed is recorded in the language the browser asks in; the served page's start-up script stores the page's language. One helper in utils (`polyglotAddressLang`, `polyglotStartupScript`).
11
+ - cli: the publish pre-render passes its route limit to brender's `timeout`; `symbols.json` `brender.timeout` sets each page's render limit for `smbls build` and `smbls brender`.
12
+
13
+ ## 3.14.787
14
+
15
+ ### Patch Changes
16
+
17
+ - xma.info report round (FW-XMA-EXCEPTIONS-UPSTREAM-1), its /simplify pass and the follow-ups.
18
+
19
+ - element: optional features (view events, `always` handler chains, plain-row diff, hydration, yielding mount) are feature slots — `create.js` installs all of them, `src/lean.js` none (the smbls embed); one chunked mount driver and one meter per task; the chunked first render costs about a third of what it did (a resumed row goes after the previous row, one `__ref` shape, the budget is read once); `whenConnected`; `onWindowLoad` after load reaches an element built off-document; a null/false row item under `childExtends` builds nothing; building an n-row list no longer scans the parent's keys per row.
20
+ - smbls: the embed is back under its 72 KiB cap and the iife is 2.6 % smaller (terser renames locals after esbuild in the two classic-script builds; maps chained); kits stay lazy in `smbls/core`, fetch is one chunk; live sync loads only when `wantsLiveSync`; a URL-loaded dependency registers in parcel builds.
21
+ - router: the newest navigation wins over one waiting on an async guard; no lazy chunk rides along a resumed route.
22
+ - default-config: accessible Dropdown writes its attributes straight to the nodes, one tab stop per list, an `active` write re-runs only the rows that change, a key-opened menu focuses its item during the reveal; Dialog and Icon clean-ups.
23
+ - styling (scratch, css, css-in-props): one compound-value resolver; CSS colour functions (`oklch()`, `color()`, `color-mix()`, `light-dark()`, `lab()`, `lch()`, `hwb()`) pass through compound values; border props read the scheme only in literal mode.
24
+ - fetch / brender: every server render starts from an empty query cache (seeds carry every request a page makes); the local adapter stays lazy; shared route loop for `smbls build` and `smbls brender`, `smbls brender --strict`.
25
+ - cli: every command that writes to the platform prints its target and needs a typed "production" or `--yes` for production; `smbls deploy --save` saves the provider, `-y/--yes` is consent; `deploy --dry-run` no longer pushes.
26
+ - frank-audit: FA205 reports only factory calls that run at module load.
27
+
28
+ - Updated dependencies
29
+ - @symbo.ls/fetch@3.14.665
30
+
3
31
  ## 3.14.786
4
32
 
5
33
  ### Patch Changes
package/dist/cjs/keys.js CHANGED
@@ -1 +1 @@
1
- "use strict";var a=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var E=(e,t)=>{for(var n in t)a(e,n,{get:t[n],enumerable:!0})},h=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of _(t))!i.call(e,o)&&o!==n&&a(e,o,{get:()=>t[o],enumerable:!(s=c(t,o))||s.enumerable});return e};var x=e=>h(a({},"__esModule",{value:!0}),e);var y={};E(y,{DOMQL_EVENTS:()=>g,DOMQ_PROPERTIES:()=>S,ELEMENT_METHOD_OVERRIDE_POINTS:()=>l,METHODS:()=>r,METHODS_EXL:()=>f,PARSED_DOMQ_PROPERTIES:()=>R,PROPS_METHODS:()=>d,STATE_METHODS:()=>p,STATE_PROPERTIES:()=>u,isBuiltinElementMethod:()=>m,isProtectedElementMethod:()=>P});module.exports=x(y);const S=new Set(["attr","style","text","html","content","data","classlist","state","scope","root","deps","extend","extends","$router","routes","children","childExtend","childExtends","childExtendRecursive","childExtendsRecursive","props","if","define","__name","__ref","__hash","__text","key","tag","query","parent","node","variables","on","fetch","component","context","preventContentUpdate","preventContentRecreate"]),R=new Set(["attr","style","text","html","content","data","class","state","scope","children","props","if","key","tag","query","on","context"]),u=["ref","parent","__element","__depends","__ref","__children","root"],p=new Set(["update","parse","clean","create","destroy","add","toggle","remove","apply","set","reset","replace","quietReplace","quietUpdate","applyReplace","applyFunction","keys","values","ref","rootUpdate","parentUpdate","parent","__element","__depends","__ref","__children","root","setByPath","setPathCollection","removeByPath","removePathCollection","getByPath"]),d=new Set(["update","__element"]),r=new Set(["set","reset","update","remove","updateContent","removeContent","lookup","lookdown","lookdownAll","getRef","getPath","setNodeStyles","spotByPath","keys","parse","setProps","parseDeep","variables","if","log","verbose","warn","error","call","nextElement","previousElement","getRootState","getRoot","getRootData","getRootContext","getContext","getQuery","getDB","getChildren","preventContentUpdate","preventContentRecreate"]),m=e=>r.has(e),l=new Set(["log","warn","error","verbose"]),P=e=>r.has(e)&&!l.has(e),f=new Set(["node","context","extends","__element","__ref",...r,...p,...d]),g=new Set(["init","beforeClassAssign","render","renderRouter","attachNode","stateInit","stateCreated","beforeStateUpdate","stateUpdate","beforeUpdate","done","create","complete","frame","update","fetchError","fetchComplete"]);
1
+ "use strict";var a=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var E=(e,t)=>{for(var n in t)a(e,n,{get:t[n],enumerable:!0})},h=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of _(t))!i.call(e,o)&&o!==n&&a(e,o,{get:()=>t[o],enumerable:!(s=c(t,o))||s.enumerable});return e};var x=e=>h(a({},"__esModule",{value:!0}),e);var y={};E(y,{DOMQL_EVENTS:()=>g,DOMQ_PROPERTIES:()=>S,ELEMENT_METHOD_OVERRIDE_POINTS:()=>l,METHODS:()=>r,METHODS_EXL:()=>f,PARSED_DOMQ_PROPERTIES:()=>R,PROPS_METHODS:()=>d,STATE_METHODS:()=>p,STATE_PROPERTIES:()=>u,isBuiltinElementMethod:()=>m,isProtectedElementMethod:()=>P});module.exports=x(y);const S=new Set(["attr","style","text","html","content","data","classlist","state","scope","root","deps","extend","extends","$router","routes","children","childExtend","childExtends","childExtendRecursive","childExtendsRecursive","props","if","define","__name","__ref","__hash","__text","key","tag","query","parent","node","variables","on","fetch","component","context","preventContentUpdate","preventContentRecreate"]),R=new Set(["attr","style","text","html","content","data","class","state","scope","children","props","if","key","tag","query","on","context"]),u=["ref","parent","__element","__depends","__ref","__children","root"],p=new Set(["update","parse","clean","create","destroy","add","toggle","remove","apply","set","reset","replace","quietReplace","quietUpdate","applyReplace","applyFunction","keys","values","ref","rootUpdate","parentUpdate","parent","__element","__depends","__ref","__children","root","setByPath","setPathCollection","removeByPath","removePathCollection","getByPath"]),d=new Set(["update","__element"]),r=new Set(["set","reset","update","remove","updateContent","removeContent","lookup","lookdown","lookdownAll","whenConnected","getRef","getPath","setNodeStyles","spotByPath","keys","parse","setProps","parseDeep","variables","if","log","verbose","warn","error","call","nextElement","previousElement","getRootState","getRoot","getRootData","getRootContext","getContext","getQuery","getDB","getChildren","preventContentUpdate","preventContentRecreate"]),m=e=>r.has(e),l=new Set(["log","warn","error","verbose"]),P=e=>r.has(e)&&!l.has(e),f=new Set(["node","context","extends","__element","__ref",...r,...p,...d]),g=new Set(["init","beforeClassAssign","render","renderRouter","attachNode","stateInit","stateCreated","beforeStateUpdate","stateUpdate","beforeUpdate","done","create","complete","frame","update","fetchError","fetchComplete"]);
@@ -1,2 +1,2 @@
1
- "use strict";var A=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var P=(t,n)=>{for(var e in n)A(t,e,{get:n[e],enumerable:!0})},R=(t,n,e,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of U(n))!D.call(t,i)&&i!==e&&A(t,i,{get:()=>n[i],enumerable:!(r=T(n,i))||r.enumerable});return t};var _=t=>R(A({},"__esModule",{value:!0}),t);var Q={};P(Q,{alternateLinkKey:()=>E,escapeHtml:()=>l,faviconLinkKey:()=>K,fileEntryUrl:()=>W,generateHeadArrayTags:()=>x,generateMetaTags:()=>Y,getPageMetadata:()=>I,hashContent:()=>j,jsonForScript:()=>q,resolveFileReferences:()=>F});module.exports=_(Q);var b=require("./types.js"),M=require("./function.js");const l=t=>{if(t==null)return"";const n={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};return t.toString().replace(/[&<>"']/g,e=>n[e])},q=t=>JSON.stringify(t).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029"),N=t=>Object.entries(t||{}).filter(([n,e])=>e!==void 0).map(([n,e])=>`${n}="${l(e)}"`).join(" "),j=t=>{let n=5381;const e=String(t);for(let r=0;r<e.length;r++)n=(n*33^e.charCodeAt(r))>>>0;return n.toString(36)},C=new Set(["jsonLd","styles","scripts"]),x=t=>{const n=[];if(Array.isArray(t.jsonLd))for(const e of t.jsonLd){if(e==null)continue;const r=typeof e=="string"?e:JSON.stringify(e),i=String(r).replace(/<\/script/gi,"<\\/script");n.push(`<script type="application/ld+json" data-smbls-jsonld="${j(r)}">${i}<\/script>`)}if(Array.isArray(t.styles))for(const e of t.styles){if(e==null||!String(e).trim())continue;const r=String(e).replace(/<\/style/gi,"<\\/style");n.push(`<style data-smbls-style="${j(r)}">${r}</style>`)}if(Array.isArray(t.scripts))for(const e of t.scripts){if(!e)continue;const r=typeof e=="string",i=r?e:e.src;if(!i&&!e.body)continue;const o=[];i&&o.push(`src="${l(i)}"`),r||(e.type&&o.push(`type="${l(e.type)}"`),e.async&&o.push("async"),e.defer&&o.push("defer"),e.integrity&&o.push(`integrity="${l(e.integrity)}"`),e.crossorigin&&o.push(`crossorigin="${l(e.crossorigin)}"`),e.referrerpolicy&&o.push(`referrerpolicy="${l(e.referrerpolicy)}"`),e.nomodule&&o.push("nomodule"));const p=` data-smbls-script="${l(i||j(e.body||""))}"`;if(!r&&e.body){const d=String(e.body).replace(/<\/script/gi,"<\\/script");n.push(`<script ${o.join(" ")}${p}>${d}<\/script>`)}else n.push(`<script ${o.join(" ")}${p}><\/script>`)}return n},E=t=>`${t.hreflang||""}|${t.href||""}`,K=t=>(0,b.isObject)(t)?j(JSON.stringify(t)):String(t),H=(t,n,e)=>t==="favicons"?Array.isArray(n)&&(typeof e=="string"||(0,b.isObject)(e))?` data-smbls-favicon="${l(K(e))}"`:"":(t==="icon"||t==="favicon")&&typeof n=="string"?` data-smbls-single-icon="${l(n)}"`:"",J=t=>(0,b.isObject)(t)?` data-smbls-alternate="${l(E(t))}"`:"",Y=(t,n)=>{n||(t={...t,robots:"noindex"});const e=Object.entries(t).reduce((r,[i,o])=>{if(!o&&o!==0&&o!==!1||C.has(i))return r;if(i==="title")return r.push(`<title>${l(o)}</title>`),r;if(i==="canonical")return r.push(`<link rel="canonical" href="${l(o)}">`),r;if(i==="manifest")return r.push(`<link rel="manifest" href="${l(o)}">`),r;if(i==="favicon"||i==="favicons"||i==="icon"||i==="icons")return(Array.isArray(o)?o:[o]).forEach(c=>{const u=H(i,o,c);if(typeof c=="string")r.push(`<link rel="icon" href="${l(c)}"${u}>`);else if(typeof c=="object"){const s=N(c);/rel=/.test(s)?r.push(`<link ${s}${u}>`):r.push(`<link rel="icon" ${s}${u}>`)}}),r;if(i==="alternate")return(Array.isArray(o)?o:[o]).forEach(c=>{if(c&&typeof c=="object"){const u=Object.entries(c).filter(([s,g])=>g!==void 0).map(([s,g])=>`${s}="${l(g)}"`).join(" ");r.push(`<link rel="alternate" ${u}${J(c)}>`)}}),r;const p=(f,c,u="name")=>{if(typeof c=="string"||typeof c=="number"||typeof c=="boolean")r.push(`<meta ${u}="${l(f)}" content="${l(c)}">`);else if(Array.isArray(c))c.forEach(s=>{if(typeof s=="string"||typeof s=="number"||typeof s=="boolean")r.push(`<meta ${u}="${l(f)}" content="${l(s)}">`);else if(typeof s=="object"){const g=Object.entries(s).filter(([y,$])=>$!==void 0).map(([y,$])=>`${y}="${l($)}"`).join(" ");r.push(`<meta ${g}>`)}});else if(typeof c=="object"){const s=Object.entries(c).filter(([g,y])=>y!==void 0).map(([g,y])=>`${g}="${l(y)}"`).join(" ");r.push(`<meta ${s}>`)}};if(i.startsWith("http-equiv:")){const f=i.replace("http-equiv:","");return p(f,o,"http-equiv"),r}if(i.startsWith("itemprop:")){const f=i.replace("itemprop:","");return p(f,o,"itemprop"),r}const h=["og:","twitter:","fb:","article:","profile:","book:","business:","music:","product:","video:","DC:","DCTERMS:"].find(f=>i.startsWith(f));if(h){const f=i.replace(h,"");return p(`${h.replace(":","")}:${f}`,o,h==="twitter:"||h==="DC:"||h==="DCTERMS:"?"name":"property"),r}if(i.startsWith("apple:")||i.startsWith("msapplication:")){const f=i.startsWith("apple:")?"apple-":"msapplication-",c=i.replace(/^apple:|^msapplication:/,"");return p(`${f}${c}`,o,"name"),r}return p(i,o),r},['<meta charset="UTF-8">','<meta name="viewport" content="width=device-width, initial-scale=1">']);return e.push(...x(t)),e.join(`
2
- `)},B=t=>typeof t=="string"&&t.length>0&&!t.startsWith("/")&&!t.startsWith("http"),S=t=>typeof t=="string"&&t.length>0,W=t=>{if(!t||typeof t!="object")return null;if(S(t.src))return t.src;const n=t.content;return!n||typeof n!="object"?null:S(n.src)?n.src:S(n.storageUrl)?n.storageUrl:null};function F(t,n){if(!n||typeof n!="object")return t;const e=i=>!B(i)||!Object.prototype.hasOwnProperty.call(n,i)?i:W(n[i])||i,r={...t};for(const[i,o]of Object.entries(r))typeof o=="string"?r[i]=e(o):Array.isArray(o)&&(r[i]=o.map(p=>typeof p=="string"?e(p):p));return r}function w(t,n){if(!t||!n)return;const e=n.split(".");let r=t;for(const i of e){if(r==null||typeof r!="object")return;r=r[i]}return r}function z(t,n){const e=w(t,n);if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e=="string"&&!(0,M.isStringFunction)(e))return e}function G(t,n,e){const i=(n.config||n.settings||{}).polyglot||n.polyglot,o=e?.lang||i?.defaultLang||"en",d=(i?.translations||{})[o]||{},h=[e?.state,n.state].filter(u=>u&&typeof u=="object"),f=u=>{for(const s of h){const g=z(s,u);if(g!==void 0)return g}},c={...t};for(const[u,s]of Object.entries(c))typeof s!="string"||!s.includes("{{")||(c[u]=s.replace(/\{\{\s*([^|{}]+?)\s*(?:\|\s*(\w+)\s*)?\}\}/g,(g,y,$)=>{const a=y.trim();if($==="polyglot")return d[a]??w(d,a)??g;if($==="getLocalStateLang")return f(a+o)??g;const m=f(a);return m!==void 0?m:d[a]??w(d,a)??g}));return c}function L(t){if(!(0,b.isObject)(t))return{};const n={...t};for(const[e,r]of Object.entries(n))if(typeof r=="function"){const i=r.toString(),o=i.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(o){n[e]=`{{ ${o[1]} | getLocalStateLang }}`;continue}const p=i.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(p){n[e]=`{{ ${p[1]} | polyglot }}`;continue}const d=i.match(/s\.(\w+(?:\.\w+)+)/);if(d){n[e]=`{{ ${d[1]} }}`;continue}delete n[e]}else if(typeof r=="string"){const i=r.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(i){n[e]=`{{ ${i[1]} | getLocalStateLang }}`;continue}const o=r.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(o){n[e]=`{{ ${o[1]} | polyglot }}`;continue}if(r.includes("=>")&&r.includes("s.")){const p=r.match(/s\.(\w+(?:\.\w+)+)/);if(p){n[e]=`{{ ${p[1]} }}`;continue}}(0,M.isStringFunction)(r)&&delete n[e]}return n}function I(t,n,e,{isProduction:r=!1,channel:i="production"}={}){const o=t.pages?.[n],p=(0,b.isObject)(o?.state)&&o?.state,d=o?.metadata||o?.helmet||p||{},h=L(d),f=new Set(Object.keys(h)),c=t.app?.metadata||{},u=L(c);let s={};if(t.integrations?.seo?s={...t.integrations.seo,...u,...h}:Object.keys(u).length?s={...u,...h}:s={...h},!s.title){const a=t.name||t.key;a?r?s.title=a:i==="development"?s.title=`${a} / dev:symbo.ls`:i==="staging"?s.title=`${a} / staging:symbo.ls`:s.title=`${a} / symbo.ls`:s.title="Symbols demo"}s=G(s,t,e),s.title&&(f.has("title")||!s["og:title"])&&(f.has("og:title")||(s["og:title"]=s.title)),s.description&&(f.has("description")||!s["og:description"])&&(f.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=f.has("og:url")?s["og:url"]:f.has("url")?s.url:void 0,y=e?.actualPathname||n;if(g)s["og:url"]=g;else if(s["og:url"]||s.url){const a=(s["og:url"]||s.url||"").replace(/\/$/,"");if(a&&y&&y!=="/"){const m=y.startsWith("/")?y:"/"+y;s["og:url"]=a+m}}s=F(s,t.files);const $=t.name||t.app?.metadata?.title||t.app?.name||"";for(const[a,m]of Object.entries(s))if(typeof m=="string"&&m.includes("{{")){const O=m.replace(/\{\{[^}]*\}\}/g,"").trim();O?s[a]=O:a==="title"?s[a]=$:delete s[a]}return s}
1
+ "use strict";var S=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var _=(t,r)=>{for(var e in r)S(t,e,{get:r[e],enumerable:!0})},q=(t,r,e,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of D(r))!F.call(t,s)&&s!==e&&S(t,s,{get:()=>r[s],enumerable:!(n=W(r,s))||n.enumerable});return t};var C=t=>q(S({},"__esModule",{value:!0}),t);var k={};_(k,{BRENDER_REGISTRY_BLOCK:()=>P,alternateLinkKey:()=>R,brenderRegistryBlock:()=>B,escapeHtml:()=>p,faviconLinkKey:()=>K,fileEntryUrl:()=>N,generateHeadArrayTags:()=>E,generateMetaTags:()=>I,getPageMetadata:()=>Z,hashContent:()=>j,jsonForScript:()=>x,readJsonDataBlock:()=>U,resolveFileReferences:()=>T});module.exports=C(k);var m=require("./types.js"),L=require("./function.js");const p=t=>{if(t==null)return"";const r={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};return t.toString().replace(/[&<>"']/g,e=>r[e])},x=t=>JSON.stringify(t).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029"),U=(t,r,{remove:e=!1,warn:n}={})=>{if(!t||typeof t.querySelector!="function")return null;let s=null;try{s=t.querySelector(r)}catch{return null}if(!s)return null;e&&s.parentNode&&s.parentNode.removeChild(s);let o;try{o=JSON.parse(s.textContent||"")}catch(l){n&&n(l)}return{value:o,block:s}},P='script[type="application/json"][data-brender="registry"]',B=t=>'<script type="application/json" data-brender="registry">'+x(t)+"<\/script>",J=t=>Object.entries(t||{}).filter(([r,e])=>e!==void 0).map(([r,e])=>`${r}="${p(e)}"`).join(" "),j=t=>{let r=5381;const e=String(t);for(let n=0;n<e.length;n++)r=(r*33^e.charCodeAt(n))>>>0;return r.toString(36)},H=new Set(["jsonLd","styles","scripts"]),E=t=>{const r=[];if(Array.isArray(t.jsonLd))for(const e of t.jsonLd){if(e==null)continue;const n=typeof e=="string"?e:JSON.stringify(e),s=String(n).replace(/<\/script/gi,"<\\/script");r.push(`<script type="application/ld+json" data-smbls-jsonld="${j(n)}">${s}<\/script>`)}if(Array.isArray(t.styles))for(const e of t.styles){if(e==null||!String(e).trim())continue;const n=String(e).replace(/<\/style/gi,"<\\/style");r.push(`<style data-smbls-style="${j(n)}">${n}</style>`)}if(Array.isArray(t.scripts))for(const e of t.scripts){if(!e)continue;const n=typeof e=="string",s=n?e:e.src;if(!s&&!e.body)continue;const o=[];s&&o.push(`src="${p(s)}"`),n||(e.type&&o.push(`type="${p(e.type)}"`),e.async&&o.push("async"),e.defer&&o.push("defer"),e.integrity&&o.push(`integrity="${p(e.integrity)}"`),e.crossorigin&&o.push(`crossorigin="${p(e.crossorigin)}"`),e.referrerpolicy&&o.push(`referrerpolicy="${p(e.referrerpolicy)}"`),e.nomodule&&o.push("nomodule"));const l=` data-smbls-script="${p(s||j(e.body||""))}"`;if(!n&&e.body){const d=String(e.body).replace(/<\/script/gi,"<\\/script");r.push(`<script ${o.join(" ")}${l}>${d}<\/script>`)}else r.push(`<script ${o.join(" ")}${l}><\/script>`)}return r},R=t=>`${t.hreflang||""}|${t.href||""}`,K=t=>(0,m.isObject)(t)?j(JSON.stringify(t)):String(t),Y=(t,r,e)=>t==="favicons"?Array.isArray(r)&&(typeof e=="string"||(0,m.isObject)(e))?` data-smbls-favicon="${p(K(e))}"`:"":(t==="icon"||t==="favicon")&&typeof r=="string"?` data-smbls-single-icon="${p(r)}"`:"",G=t=>(0,m.isObject)(t)?` data-smbls-alternate="${p(R(t))}"`:"",I=(t,r)=>{r||(t={...t,robots:"noindex"});const e=Object.entries(t).reduce((n,[s,o])=>{if(!o&&o!==0&&o!==!1||H.has(s))return n;if(s==="title")return n.push(`<title>${p(o)}</title>`),n;if(s==="canonical")return n.push(`<link rel="canonical" href="${p(o)}">`),n;if(s==="manifest")return n.push(`<link rel="manifest" href="${p(o)}">`),n;if(s==="favicon"||s==="favicons"||s==="icon"||s==="icons")return(Array.isArray(o)?o:[o]).forEach(c=>{const u=Y(s,o,c);if(typeof c=="string")n.push(`<link rel="icon" href="${p(c)}"${u}>`);else if(typeof c=="object"){const i=J(c);/rel=/.test(i)?n.push(`<link ${i}${u}>`):n.push(`<link rel="icon" ${i}${u}>`)}}),n;if(s==="alternate")return(Array.isArray(o)?o:[o]).forEach(c=>{if(c&&typeof c=="object"){const u=Object.entries(c).filter(([i,g])=>g!==void 0).map(([i,g])=>`${i}="${p(g)}"`).join(" ");n.push(`<link rel="alternate" ${u}${G(c)}>`)}}),n;const l=(f,c,u="name")=>{if(typeof c=="string"||typeof c=="number"||typeof c=="boolean")n.push(`<meta ${u}="${p(f)}" content="${p(c)}">`);else if(Array.isArray(c))c.forEach(i=>{if(typeof i=="string"||typeof i=="number"||typeof i=="boolean")n.push(`<meta ${u}="${p(f)}" content="${p(i)}">`);else if(typeof i=="object"){const g=Object.entries(i).filter(([y,$])=>$!==void 0).map(([y,$])=>`${y}="${p($)}"`).join(" ");n.push(`<meta ${g}>`)}});else if(typeof c=="object"){const i=Object.entries(c).filter(([g,y])=>y!==void 0).map(([g,y])=>`${g}="${p(y)}"`).join(" ");n.push(`<meta ${i}>`)}};if(s.startsWith("http-equiv:")){const f=s.replace("http-equiv:","");return l(f,o,"http-equiv"),n}if(s.startsWith("itemprop:")){const f=s.replace("itemprop:","");return l(f,o,"itemprop"),n}const h=["og:","twitter:","fb:","article:","profile:","book:","business:","music:","product:","video:","DC:","DCTERMS:"].find(f=>s.startsWith(f));if(h){const f=s.replace(h,"");return l(`${h.replace(":","")}:${f}`,o,h==="twitter:"||h==="DC:"||h==="DCTERMS:"?"name":"property"),n}if(s.startsWith("apple:")||s.startsWith("msapplication:")){const f=s.startsWith("apple:")?"apple-":"msapplication-",c=s.replace(/^apple:|^msapplication:/,"");return l(`${f}${c}`,o,"name"),n}return l(s,o),n},['<meta charset="UTF-8">','<meta name="viewport" content="width=device-width, initial-scale=1">']);return e.push(...E(t)),e.join(`
2
+ `)},z=t=>typeof t=="string"&&t.length>0&&!t.startsWith("/")&&!t.startsWith("http"),A=t=>typeof t=="string"&&t.length>0,N=t=>{if(!t||typeof t!="object")return null;if(A(t.src))return t.src;const r=t.content;return!r||typeof r!="object"?null:A(r.src)?r.src:A(r.storageUrl)?r.storageUrl:null};function T(t,r){if(!r||typeof r!="object")return t;const e=s=>!z(s)||!Object.prototype.hasOwnProperty.call(r,s)?s:N(r[s])||s,n={...t};for(const[s,o]of Object.entries(n))typeof o=="string"?n[s]=e(o):Array.isArray(o)&&(n[s]=o.map(l=>typeof l=="string"?e(l):l));return n}function O(t,r){if(!t||!r)return;const e=r.split(".");let n=t;for(const s of e){if(n==null||typeof n!="object")return;n=n[s]}return n}function Q(t,r){const e=O(t,r);if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e=="string"&&!(0,L.isStringFunction)(e))return e}function X(t,r,e){const s=(r.config||r.settings||{}).polyglot||r.polyglot,o=e?.lang||s?.defaultLang||"en",d=(s?.translations||{})[o]||{},h=[e?.state,r.state].filter(u=>u&&typeof u=="object"),f=u=>{for(const i of h){const g=Q(i,u);if(g!==void 0)return g}},c={...t};for(const[u,i]of Object.entries(c))typeof i!="string"||!i.includes("{{")||(c[u]=i.replace(/\{\{\s*([^|{}]+?)\s*(?:\|\s*(\w+)\s*)?\}\}/g,(g,y,$)=>{const a=y.trim();if($==="polyglot")return d[a]??O(d,a)??g;if($==="getLocalStateLang")return f(a+o)??g;const b=f(a);return b!==void 0?b:d[a]??O(d,a)??g}));return c}function w(t){if(!(0,m.isObject)(t))return{};const r={...t};for(const[e,n]of Object.entries(r))if(typeof n=="function"){const s=n.toString(),o=s.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(o){r[e]=`{{ ${o[1]} | getLocalStateLang }}`;continue}const l=s.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(l){r[e]=`{{ ${l[1]} | polyglot }}`;continue}const d=s.match(/s\.(\w+(?:\.\w+)+)/);if(d){r[e]=`{{ ${d[1]} }}`;continue}delete r[e]}else if(typeof n=="string"){const s=n.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(s){r[e]=`{{ ${s[1]} | getLocalStateLang }}`;continue}const o=n.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(o){r[e]=`{{ ${o[1]} | polyglot }}`;continue}if(n.includes("=>")&&n.includes("s.")){const l=n.match(/s\.(\w+(?:\.\w+)+)/);if(l){r[e]=`{{ ${l[1]} }}`;continue}}(0,L.isStringFunction)(n)&&delete r[e]}return r}function Z(t,r,e,{isProduction:n=!1,channel:s="production"}={}){const o=t.pages?.[r],l=(0,m.isObject)(o?.state)&&o?.state,d=o?.metadata||o?.helmet||l||{},h=w(d),f=new Set(Object.keys(h)),c=t.app?.metadata||{},u=w(c);let i={};if(t.integrations?.seo?i={...t.integrations.seo,...u,...h}:Object.keys(u).length?i={...u,...h}:i={...h},!i.title){const a=t.name||t.key;a?n?i.title=a:s==="development"?i.title=`${a} / dev:symbo.ls`:s==="staging"?i.title=`${a} / staging:symbo.ls`:i.title=`${a} / symbo.ls`:i.title="Symbols demo"}i=X(i,t,e),i.title&&(f.has("title")||!i["og:title"])&&(f.has("og:title")||(i["og:title"]=i.title)),i.description&&(f.has("description")||!i["og:description"])&&(f.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=f.has("og:url")?i["og:url"]:f.has("url")?i.url:void 0,y=e?.actualPathname||r;if(g)i["og:url"]=g;else if(i["og:url"]||i.url){const a=(i["og:url"]||i.url||"").replace(/\/$/,"");if(a&&y&&y!=="/"){const b=y.startsWith("/")?y:"/"+y;i["og:url"]=a+b}}i=T(i,t.files);const $=t.name||t.app?.metadata?.title||t.app?.name||"";for(const[a,b]of Object.entries(i))if(typeof b=="string"&&b.includes("{{")){const M=b.replace(/\{\{[^}]*\}\}/g,"").trim();M?i[a]=M:a==="title"?i[a]=$:delete i[a]}return i}
@@ -1 +1 @@
1
- "use strict";var o=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var r=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var l=(t,a)=>{for(var n in a)o(t,n,{get:a[n],enumerable:!0})},_=(t,a,n,s)=>{if(a&&typeof a=="object"||typeof a=="function")for(let e of r(a))!c.call(t,e)&&e!==n&&o(t,e,{get:()=>a[e],enumerable:!(s=L(a,e))||s.enumerable});return t};var p=t=>_(o({},"__esModule",{value:!0}),t);var K={};l(K,{POLYGLOT_LANG_STORAGE_KEY:()=>g,polyglotFallbackLang:()=>G,polyglotLangStorageKey:()=>x});module.exports=p(K);const g="smbls_lang",x=t=>t&&t.storageLangKey||g,G=(t,a)=>t||a&&a.defaultLang||"en";
1
+ "use strict";var f=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var l=(t,e)=>{for(var r in e)f(t,r,{get:e[r],enumerable:!0})},x=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of O(e))!p.call(t,n)&&n!==r&&f(t,n,{get:()=>e[n],enumerable:!(s=y(e,n))||s.enumerable});return t};var N=t=>x(f({},"__esModule",{value:!0}),t);var m={};l(m,{POLYGLOT_LANG_STORAGE_KEY:()=>u,polyglotAddressLang:()=>L,polyglotFallbackLang:()=>S,polyglotLangStorageKey:()=>$,polyglotStartupScript:()=>d});module.exports=N(m);const u="smbls_lang",$=t=>t&&t.storageLangKey||u,S=(t,e)=>t||e&&e.defaultLang||"en",L=(t,e)=>{if(!e)return null;const r=Array.isArray(e.languages)&&e.languages.length?e.languages:Object.keys(e.translations||{}),s=/^\/([^/?#]+)/.exec(String(t||""));if(!s)return null;const n=s[1].toLowerCase();for(const a of r)if(typeof a=="string"&&a.toLowerCase()===n)return a;return null},d=({polyglot:t,translations:e,lang:r,pathname:s,attrs:n=""}={})=>{if(!e||typeof e!="object")return"";const a=t&&t.storagePrefix||"",c=t&&t.storageLangKey||"",g=[];for(const i in e){const o=e[i];o&&typeof o=="object"&&g.push(`localStorage.setItem(${JSON.stringify(a+i)},${JSON.stringify(JSON.stringify(o))})`)}if(c){const i=r||L(s,t)||S(void 0,t);g.push(`if(!localStorage.getItem(${JSON.stringify(c)}))localStorage.setItem(${JSON.stringify(c)},${JSON.stringify(i)})`)}return g.length?`<script${n}>try{${g.join(";")}}catch(e){}<\/script>`:""};
@@ -1,3 +1,3 @@
1
- "use strict";var w=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var O=(e,n)=>{for(var t in n)w(e,t,{get:n[t],enumerable:!0})},R=(e,n,t,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let c of j(n))!N.call(e,c)&&c!==t&&w(e,c,{get:()=>n[c],enumerable:!(s=L(n,c))||s.enumerable});return e};var I=e=>R(w({},"__esModule",{value:!0}),e);var W={};O(W,{customDecodeURIComponent:()=>M,customEncodeURIComponent:()=>z,decodeNewlines:()=>P,encodeNewlines:()=>K,findKeyPosition:()=>U,lowercaseFirstLetter:()=>v,replaceLiteralsWithObjectFields:()=>T,replaceOctalEscapeSequences:()=>D,stringIncludesAny:()=>k,trimStringFromSymbols:()=>E});module.exports=I(W);const k=(e,n)=>{for(const t of n)if(e.includes(t))return!0;return!1},E=(e,n)=>{const t=new RegExp(`[${n.join("\\")}]`,"g");return e.replace(t,"")},$={2:/{{\s*((?:\.\.\/)*)([\w\d.]+)\s*(?:\|\s*([\w\d.]+))?\s*}}/g,3:/{{{(\s*(?:\.\.\/)*)([\w\d.]+)\s*(?:\|\s*([\w\d.]+))?\s*}}}/g},m=(e,n)=>n.split(".").reduce((t,s)=>t?.[s],e),F=(e,n)=>{if(!e||!e.__ref)return!0;let t=e;for(;t;){if(t.allowRuntimeTemplates===!0)return!0;const s=t.__ref&&t.__ref.__authoredTemplates;if(s&&s.has(n))return!0;t=t.parent}return!1};function T(e,n,t={}){const{bracketsLength:s=2,authored:c=!1}=t,h=s===3?"{{{":"{{";if(!e.includes(h)||c!==!0&&!F(this,e))return e;const p=$[s],f=n||this.state||{},l=this;return e.replace(p,(x,r,b,g)=>{const i=b.trim();if(g){const a=l?.context,o=a?.functions?.[g]||a?.utils?.[g]||a?.methods?.[g]||a?.snippets?.[g]||l?.[g];if(o&&typeof o=="function")try{return String(o.call(l,i)??"")}catch{return""}return""}if(r){const a=(r.match(/\.\.\//g)||[]).length;let o=f;for(let u=0;u<a;u++){if(!o||!o.parent)return"";o=o.parent}if(i==="parent")return String(o.value??"");const d=m(o,i);return d!=null&&typeof d=="object"?"":String(d??"")}else{const a=m(f,i);if(a!=null&&typeof a!="object")return String(a);const o=l?.context?.polyglot;if(o?.translations){const d=f?.root?.lang||f?.lang||l?.context?.state?.lang||o.defaultLang||"en",u=o.translations[d];if(u){const S=m(u,i);if(S!=null&&typeof S!="object")return String(S);for(const A in u){const y=u[A];if(y&&typeof y=="object"&&!Array.isArray(y)){const _=m(y,i);if(_!=null&&typeof _!="object")return String(_)}}}const C=m(o.translations,i);if(C!=null&&typeof C!="object")return String(C)}return""}})}const v=e=>`${e.charAt(0).toLowerCase()}${e.slice(1)}`,U=(e,n)=>{const t=e.split(`
2
- `);let s=-1,c=-1,h=-1,p=-1;const f=new RegExp(`\\b${n}\\b\\s*:\\s*`);let l=0,x=!1;for(let r=0;r<t.length;r++)if(f.test(t[r])&&!x){if(x=!0,s=r+1,h=t[r].indexOf(n)+1,t[r].includes("{}")){c=s,p=t[r].indexOf("{}")+3;break}const b=t[r].slice(h+n.length);if(b.includes("{")||b.includes("["))l=1;else{c=r+1,p=t[r].length+1;break}}else if(x&&(l+=(t[r].match(/{/g)||[]).length,l+=(t[r].match(/\[/g)||[]).length,l-=(t[r].match(/}/g)||[]).length,l-=(t[r].match(/]/g)||[]).length,l===0)){c=r+1,p=t[r].lastIndexOf("}")!==-1?t[r].lastIndexOf("}")+2:t[r].length+1;break}return{startColumn:h,endColumn:p,startLineNumber:s,endLineNumber:c}},V=/\\([0-7]{1,3})/g,D=e=>e.replace(V,(n,t)=>String.fromCharCode(parseInt(t,8))),K=e=>e.replace(/\n/g,"/////n").replace(/`/g,"/////tilde").replace(/\$/g,"/////dlrsgn"),P=e=>e.replace(/\/\/\/\/\/n/g,`
3
- `).replace(/\/\/\/\/\/tilde/g,"`").replace(/\/\/\/\/\/dlrsgn/g,"$"),q=/[^a-zA-Z0-9\s]/g,z=e=>e.replace(q,n=>"%"+n.charCodeAt(0).toString(16).toUpperCase()),M=e=>e.replace(/%[0-9A-Fa-f]{2}/g,n=>String.fromCharCode(parseInt(n.slice(1),16)));
1
+ "use strict";var w=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var N=(e,n)=>{for(var t in n)w(e,t,{get:n[t],enumerable:!0})},O=(e,n,t,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let c of j(n))!R.call(e,c)&&c!==t&&w(e,c,{get:()=>n[c],enumerable:!(s=L(n,c))||s.enumerable});return e};var $=e=>O(w({},"__esModule",{value:!0}),e);var Z={};N(Z,{customDecodeURIComponent:()=>W,customEncodeURIComponent:()=>M,decodeNewlines:()=>q,encodeNewlines:()=>P,escapeRegExp:()=>E,findKeyPosition:()=>V,lowercaseFirstLetter:()=>U,replaceLiteralsWithObjectFields:()=>v,replaceOctalEscapeSequences:()=>K,stringIncludesAny:()=>I,trimStringFromSymbols:()=>k});module.exports=$(Z);const E=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),I=(e,n)=>{for(const t of n)if(e.includes(t))return!0;return!1},k=(e,n)=>{const t=new RegExp(`[${n.join("\\")}]`,"g");return e.replace(t,"")},F={2:/{{\s*((?:\.\.\/)*)([\w\d.]+)\s*(?:\|\s*([\w\d.]+))?\s*}}/g,3:/{{{(\s*(?:\.\.\/)*)([\w\d.]+)\s*(?:\|\s*([\w\d.]+))?\s*}}}/g},m=(e,n)=>n.split(".").reduce((t,s)=>t?.[s],e),T=(e,n)=>{if(!e||!e.__ref)return!0;let t=e;for(;t;){if(t.allowRuntimeTemplates===!0)return!0;const s=t.__ref&&t.__ref.__authoredTemplates;if(s&&s.has(n))return!0;t=t.parent}return!1};function v(e,n,t={}){const{bracketsLength:s=2,authored:c=!1}=t,h=s===3?"{{{":"{{";if(!e.includes(h)||c!==!0&&!T(this,e))return e;const p=F[s],g=n||this.state||{},l=this;return e.replace(p,(x,r,b,f)=>{const i=b.trim();if(f){const a=l?.context,o=a?.functions?.[f]||a?.utils?.[f]||a?.methods?.[f]||a?.snippets?.[f]||l?.[f];if(o&&typeof o=="function")try{return String(o.call(l,i)??"")}catch{return""}return""}if(r){const a=(r.match(/\.\.\//g)||[]).length;let o=g;for(let u=0;u<a;u++){if(!o||!o.parent)return"";o=o.parent}if(i==="parent")return String(o.value??"");const d=m(o,i);return d!=null&&typeof d=="object"?"":String(d??"")}else{const a=m(g,i);if(a!=null&&typeof a!="object")return String(a);const o=l?.context?.polyglot;if(o?.translations){const d=g?.root?.lang||g?.lang||l?.context?.state?.lang||o.defaultLang||"en",u=o.translations[d];if(u){const S=m(u,i);if(S!=null&&typeof S!="object")return String(S);for(const A in u){const y=u[A];if(y&&typeof y=="object"&&!Array.isArray(y)){const _=m(y,i);if(_!=null&&typeof _!="object")return String(_)}}}const C=m(o.translations,i);if(C!=null&&typeof C!="object")return String(C)}return""}})}const U=e=>`${e.charAt(0).toLowerCase()}${e.slice(1)}`,V=(e,n)=>{const t=e.split(`
2
+ `);let s=-1,c=-1,h=-1,p=-1;const g=new RegExp(`\\b${n}\\b\\s*:\\s*`);let l=0,x=!1;for(let r=0;r<t.length;r++)if(g.test(t[r])&&!x){if(x=!0,s=r+1,h=t[r].indexOf(n)+1,t[r].includes("{}")){c=s,p=t[r].indexOf("{}")+3;break}const b=t[r].slice(h+n.length);if(b.includes("{")||b.includes("["))l=1;else{c=r+1,p=t[r].length+1;break}}else if(x&&(l+=(t[r].match(/{/g)||[]).length,l+=(t[r].match(/\[/g)||[]).length,l-=(t[r].match(/}/g)||[]).length,l-=(t[r].match(/]/g)||[]).length,l===0)){c=r+1,p=t[r].lastIndexOf("}")!==-1?t[r].lastIndexOf("}")+2:t[r].length+1;break}return{startColumn:h,endColumn:p,startLineNumber:s,endLineNumber:c}},D=/\\([0-7]{1,3})/g,K=e=>e.replace(D,(n,t)=>String.fromCharCode(parseInt(t,8))),P=e=>e.replace(/\n/g,"/////n").replace(/`/g,"/////tilde").replace(/\$/g,"/////dlrsgn"),q=e=>e.replace(/\/\/\/\/\/n/g,`
3
+ `).replace(/\/\/\/\/\/tilde/g,"`").replace(/\/\/\/\/\/dlrsgn/g,"$"),z=/[^a-zA-Z0-9\s]/g,M=e=>e.replace(z,n=>"%"+n.charCodeAt(0).toString(16).toUpperCase()),W=e=>e.replace(/%[0-9A-Fa-f]{2}/g,n=>String.fromCharCode(parseInt(n.slice(1),16)));
package/dist/esm/keys.js CHANGED
@@ -1 +1 @@
1
- const a=new Set(["attr","style","text","html","content","data","classlist","state","scope","root","deps","extend","extends","$router","routes","children","childExtend","childExtends","childExtendRecursive","childExtendsRecursive","props","if","define","__name","__ref","__hash","__text","key","tag","query","parent","node","variables","on","fetch","component","context","preventContentUpdate","preventContentRecreate"]),s=new Set(["attr","style","text","html","content","data","class","state","scope","children","props","if","key","tag","query","on","context"]),p=["ref","parent","__element","__depends","__ref","__children","root"],o=new Set(["update","parse","clean","create","destroy","add","toggle","remove","apply","set","reset","replace","quietReplace","quietUpdate","applyReplace","applyFunction","keys","values","ref","rootUpdate","parentUpdate","parent","__element","__depends","__ref","__children","root","setByPath","setPathCollection","removeByPath","removePathCollection","getByPath"]),n=new Set(["update","__element"]),t=new Set(["set","reset","update","remove","updateContent","removeContent","lookup","lookdown","lookdownAll","getRef","getPath","setNodeStyles","spotByPath","keys","parse","setProps","parseDeep","variables","if","log","verbose","warn","error","call","nextElement","previousElement","getRootState","getRoot","getRootData","getRootContext","getContext","getQuery","getDB","getChildren","preventContentUpdate","preventContentRecreate"]),d=e=>t.has(e),r=new Set(["log","warn","error","verbose"]),l=e=>t.has(e)&&!r.has(e),c=new Set(["node","context","extends","__element","__ref",...t,...o,...n]),_=new Set(["init","beforeClassAssign","render","renderRouter","attachNode","stateInit","stateCreated","beforeStateUpdate","stateUpdate","beforeUpdate","done","create","complete","frame","update","fetchError","fetchComplete"]);export{_ as DOMQL_EVENTS,a as DOMQ_PROPERTIES,r as ELEMENT_METHOD_OVERRIDE_POINTS,t as METHODS,c as METHODS_EXL,s as PARSED_DOMQ_PROPERTIES,n as PROPS_METHODS,o as STATE_METHODS,p as STATE_PROPERTIES,d as isBuiltinElementMethod,l as isProtectedElementMethod};
1
+ const a=new Set(["attr","style","text","html","content","data","classlist","state","scope","root","deps","extend","extends","$router","routes","children","childExtend","childExtends","childExtendRecursive","childExtendsRecursive","props","if","define","__name","__ref","__hash","__text","key","tag","query","parent","node","variables","on","fetch","component","context","preventContentUpdate","preventContentRecreate"]),s=new Set(["attr","style","text","html","content","data","class","state","scope","children","props","if","key","tag","query","on","context"]),p=["ref","parent","__element","__depends","__ref","__children","root"],o=new Set(["update","parse","clean","create","destroy","add","toggle","remove","apply","set","reset","replace","quietReplace","quietUpdate","applyReplace","applyFunction","keys","values","ref","rootUpdate","parentUpdate","parent","__element","__depends","__ref","__children","root","setByPath","setPathCollection","removeByPath","removePathCollection","getByPath"]),n=new Set(["update","__element"]),t=new Set(["set","reset","update","remove","updateContent","removeContent","lookup","lookdown","lookdownAll","whenConnected","getRef","getPath","setNodeStyles","spotByPath","keys","parse","setProps","parseDeep","variables","if","log","verbose","warn","error","call","nextElement","previousElement","getRootState","getRoot","getRootData","getRootContext","getContext","getQuery","getDB","getChildren","preventContentUpdate","preventContentRecreate"]),d=e=>t.has(e),r=new Set(["log","warn","error","verbose"]),l=e=>t.has(e)&&!r.has(e),c=new Set(["node","context","extends","__element","__ref",...t,...o,...n]),_=new Set(["init","beforeClassAssign","render","renderRouter","attachNode","stateInit","stateCreated","beforeStateUpdate","stateUpdate","beforeUpdate","done","create","complete","frame","update","fetchError","fetchComplete"]);export{_ as DOMQL_EVENTS,a as DOMQ_PROPERTIES,r as ELEMENT_METHOD_OVERRIDE_POINTS,t as METHODS,c as METHODS_EXL,s as PARSED_DOMQ_PROPERTIES,n as PROPS_METHODS,o as STATE_METHODS,p as STATE_PROPERTIES,d as isBuiltinElementMethod,l as isProtectedElementMethod};
@@ -1,2 +1,2 @@
1
- import{isObject as b}from"./types.js";import{isStringFunction as M}from"./function.js";const p=t=>{if(t==null)return"";const s={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};return t.toString().replace(/[&<>"']/g,e=>s[e])},C=t=>JSON.stringify(t).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029"),L=t=>Object.entries(t||{}).filter(([s,e])=>e!==void 0).map(([s,e])=>`${s}="${p(e)}"`).join(" "),j=t=>{let s=5381;const e=String(t);for(let r=0;r<e.length;r++)s=(s*33^e.charCodeAt(r))>>>0;return s.toString(36)},x=new Set(["jsonLd","styles","scripts"]),E=t=>{const s=[];if(Array.isArray(t.jsonLd))for(const e of t.jsonLd){if(e==null)continue;const r=typeof e=="string"?e:JSON.stringify(e),i=String(r).replace(/<\/script/gi,"<\\/script");s.push(`<script type="application/ld+json" data-smbls-jsonld="${j(r)}">${i}<\/script>`)}if(Array.isArray(t.styles))for(const e of t.styles){if(e==null||!String(e).trim())continue;const r=String(e).replace(/<\/style/gi,"<\\/style");s.push(`<style data-smbls-style="${j(r)}">${r}</style>`)}if(Array.isArray(t.scripts))for(const e of t.scripts){if(!e)continue;const r=typeof e=="string",i=r?e:e.src;if(!i&&!e.body)continue;const o=[];i&&o.push(`src="${p(i)}"`),r||(e.type&&o.push(`type="${p(e.type)}"`),e.async&&o.push("async"),e.defer&&o.push("defer"),e.integrity&&o.push(`integrity="${p(e.integrity)}"`),e.crossorigin&&o.push(`crossorigin="${p(e.crossorigin)}"`),e.referrerpolicy&&o.push(`referrerpolicy="${p(e.referrerpolicy)}"`),e.nomodule&&o.push("nomodule"));const l=` data-smbls-script="${p(i||j(e.body||""))}"`;if(!r&&e.body){const d=String(e.body).replace(/<\/script/gi,"<\\/script");s.push(`<script ${o.join(" ")}${l}>${d}<\/script>`)}else s.push(`<script ${o.join(" ")}${l}><\/script>`)}return s},K=t=>`${t.hreflang||""}|${t.href||""}`,W=t=>b(t)?j(JSON.stringify(t)):String(t),F=(t,s,e)=>t==="favicons"?Array.isArray(s)&&(typeof e=="string"||b(e))?` data-smbls-favicon="${p(W(e))}"`:"":(t==="icon"||t==="favicon")&&typeof s=="string"?` data-smbls-single-icon="${p(s)}"`:"",T=t=>b(t)?` data-smbls-alternate="${p(K(t))}"`:"",H=(t,s)=>{s||(t={...t,robots:"noindex"});const e=Object.entries(t).reduce((r,[i,o])=>{if(!o&&o!==0&&o!==!1||x.has(i))return r;if(i==="title")return r.push(`<title>${p(o)}</title>`),r;if(i==="canonical")return r.push(`<link rel="canonical" href="${p(o)}">`),r;if(i==="manifest")return r.push(`<link rel="manifest" href="${p(o)}">`),r;if(i==="favicon"||i==="favicons"||i==="icon"||i==="icons")return(Array.isArray(o)?o:[o]).forEach(c=>{const u=F(i,o,c);if(typeof c=="string")r.push(`<link rel="icon" href="${p(c)}"${u}>`);else if(typeof c=="object"){const n=L(c);/rel=/.test(n)?r.push(`<link ${n}${u}>`):r.push(`<link rel="icon" ${n}${u}>`)}}),r;if(i==="alternate")return(Array.isArray(o)?o:[o]).forEach(c=>{if(c&&typeof c=="object"){const u=Object.entries(c).filter(([n,g])=>g!==void 0).map(([n,g])=>`${n}="${p(g)}"`).join(" ");r.push(`<link rel="alternate" ${u}${T(c)}>`)}}),r;const l=(f,c,u="name")=>{if(typeof c=="string"||typeof c=="number"||typeof c=="boolean")r.push(`<meta ${u}="${p(f)}" content="${p(c)}">`);else if(Array.isArray(c))c.forEach(n=>{if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")r.push(`<meta ${u}="${p(f)}" content="${p(n)}">`);else if(typeof n=="object"){const g=Object.entries(n).filter(([y,$])=>$!==void 0).map(([y,$])=>`${y}="${p($)}"`).join(" ");r.push(`<meta ${g}>`)}});else if(typeof c=="object"){const n=Object.entries(c).filter(([g,y])=>y!==void 0).map(([g,y])=>`${g}="${p(y)}"`).join(" ");r.push(`<meta ${n}>`)}};if(i.startsWith("http-equiv:")){const f=i.replace("http-equiv:","");return l(f,o,"http-equiv"),r}if(i.startsWith("itemprop:")){const f=i.replace("itemprop:","");return l(f,o,"itemprop"),r}const h=["og:","twitter:","fb:","article:","profile:","book:","business:","music:","product:","video:","DC:","DCTERMS:"].find(f=>i.startsWith(f));if(h){const f=i.replace(h,"");return l(`${h.replace(":","")}:${f}`,o,h==="twitter:"||h==="DC:"||h==="DCTERMS:"?"name":"property"),r}if(i.startsWith("apple:")||i.startsWith("msapplication:")){const f=i.startsWith("apple:")?"apple-":"msapplication-",c=i.replace(/^apple:|^msapplication:/,"");return l(`${f}${c}`,o,"name"),r}return l(i,o),r},['<meta charset="UTF-8">','<meta name="viewport" content="width=device-width, initial-scale=1">']);return e.push(...E(t)),e.join(`
2
- `)},U=t=>typeof t=="string"&&t.length>0&&!t.startsWith("/")&&!t.startsWith("http"),A=t=>typeof t=="string"&&t.length>0,D=t=>{if(!t||typeof t!="object")return null;if(A(t.src))return t.src;const s=t.content;return!s||typeof s!="object"?null:A(s.src)?s.src:A(s.storageUrl)?s.storageUrl:null};function P(t,s){if(!s||typeof s!="object")return t;const e=i=>!U(i)||!Object.prototype.hasOwnProperty.call(s,i)?i:D(s[i])||i,r={...t};for(const[i,o]of Object.entries(r))typeof o=="string"?r[i]=e(o):Array.isArray(o)&&(r[i]=o.map(l=>typeof l=="string"?e(l):l));return r}function S(t,s){if(!t||!s)return;const e=s.split(".");let r=t;for(const i of e){if(r==null||typeof r!="object")return;r=r[i]}return r}function R(t,s){const e=S(t,s);if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e=="string"&&!M(e))return e}function _(t,s,e){const i=(s.config||s.settings||{}).polyglot||s.polyglot,o=e?.lang||i?.defaultLang||"en",d=(i?.translations||{})[o]||{},h=[e?.state,s.state].filter(u=>u&&typeof u=="object"),f=u=>{for(const n of h){const g=R(n,u);if(g!==void 0)return g}},c={...t};for(const[u,n]of Object.entries(c))typeof n!="string"||!n.includes("{{")||(c[u]=n.replace(/\{\{\s*([^|{}]+?)\s*(?:\|\s*(\w+)\s*)?\}\}/g,(g,y,$)=>{const a=y.trim();if($==="polyglot")return d[a]??S(d,a)??g;if($==="getLocalStateLang")return f(a+o)??g;const m=f(a);return m!==void 0?m:d[a]??S(d,a)??g}));return c}function O(t){if(!b(t))return{};const s={...t};for(const[e,r]of Object.entries(s))if(typeof r=="function"){const i=r.toString(),o=i.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(o){s[e]=`{{ ${o[1]} | getLocalStateLang }}`;continue}const l=i.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(l){s[e]=`{{ ${l[1]} | polyglot }}`;continue}const d=i.match(/s\.(\w+(?:\.\w+)+)/);if(d){s[e]=`{{ ${d[1]} }}`;continue}delete s[e]}else if(typeof r=="string"){const i=r.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(i){s[e]=`{{ ${i[1]} | getLocalStateLang }}`;continue}const o=r.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(o){s[e]=`{{ ${o[1]} | polyglot }}`;continue}if(r.includes("=>")&&r.includes("s.")){const l=r.match(/s\.(\w+(?:\.\w+)+)/);if(l){s[e]=`{{ ${l[1]} }}`;continue}}M(r)&&delete s[e]}return s}function J(t,s,e,{isProduction:r=!1,channel:i="production"}={}){const o=t.pages?.[s],l=b(o?.state)&&o?.state,d=o?.metadata||o?.helmet||l||{},h=O(d),f=new Set(Object.keys(h)),c=t.app?.metadata||{},u=O(c);let n={};if(t.integrations?.seo?n={...t.integrations.seo,...u,...h}:Object.keys(u).length?n={...u,...h}:n={...h},!n.title){const a=t.name||t.key;a?r?n.title=a:i==="development"?n.title=`${a} / dev:symbo.ls`:i==="staging"?n.title=`${a} / staging:symbo.ls`:n.title=`${a} / symbo.ls`:n.title="Symbols demo"}n=_(n,t,e),n.title&&(f.has("title")||!n["og:title"])&&(f.has("og:title")||(n["og:title"]=n.title)),n.description&&(f.has("description")||!n["og:description"])&&(f.has("og:description")||(n["og:description"]=n.description)),n.title&&!n["twitter:title"]&&(n["twitter:title"]=n.title),n.description&&!n["twitter:description"]&&(n["twitter:description"]=n.description);const g=f.has("og:url")?n["og:url"]:f.has("url")?n.url:void 0,y=e?.actualPathname||s;if(g)n["og:url"]=g;else if(n["og:url"]||n.url){const a=(n["og:url"]||n.url||"").replace(/\/$/,"");if(a&&y&&y!=="/"){const m=y.startsWith("/")?y:"/"+y;n["og:url"]=a+m}}n=P(n,t.files);const $=t.name||t.app?.metadata?.title||t.app?.name||"";for(const[a,m]of Object.entries(n))if(typeof m=="string"&&m.includes("{{")){const w=m.replace(/\{\{[^}]*\}\}/g,"").trim();w?n[a]=w:a==="title"?n[a]=$:delete n[a]}return n}export{K as alternateLinkKey,p as escapeHtml,W as faviconLinkKey,D as fileEntryUrl,E as generateHeadArrayTags,H as generateMetaTags,J as getPageMetadata,j as hashContent,C as jsonForScript,P as resolveFileReferences};
1
+ import{isObject as m}from"./types.js";import{isStringFunction as L}from"./function.js";const p=t=>{if(t==null)return"";const i={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};return t.toString().replace(/[&<>"']/g,e=>i[e])},w=t=>JSON.stringify(t).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029"),B=(t,i,{remove:e=!1,warn:r}={})=>{if(!t||typeof t.querySelector!="function")return null;let s=null;try{s=t.querySelector(i)}catch{return null}if(!s)return null;e&&s.parentNode&&s.parentNode.removeChild(s);let o;try{o=JSON.parse(s.textContent||"")}catch(l){r&&r(l)}return{value:o,block:s}},J='script[type="application/json"][data-brender="registry"]',H=t=>'<script type="application/json" data-brender="registry">'+w(t)+"<\/script>",x=t=>Object.entries(t||{}).filter(([i,e])=>e!==void 0).map(([i,e])=>`${i}="${p(e)}"`).join(" "),j=t=>{let i=5381;const e=String(t);for(let r=0;r<e.length;r++)i=(i*33^e.charCodeAt(r))>>>0;return i.toString(36)},E=new Set(["jsonLd","styles","scripts"]),R=t=>{const i=[];if(Array.isArray(t.jsonLd))for(const e of t.jsonLd){if(e==null)continue;const r=typeof e=="string"?e:JSON.stringify(e),s=String(r).replace(/<\/script/gi,"<\\/script");i.push(`<script type="application/ld+json" data-smbls-jsonld="${j(r)}">${s}<\/script>`)}if(Array.isArray(t.styles))for(const e of t.styles){if(e==null||!String(e).trim())continue;const r=String(e).replace(/<\/style/gi,"<\\/style");i.push(`<style data-smbls-style="${j(r)}">${r}</style>`)}if(Array.isArray(t.scripts))for(const e of t.scripts){if(!e)continue;const r=typeof e=="string",s=r?e:e.src;if(!s&&!e.body)continue;const o=[];s&&o.push(`src="${p(s)}"`),r||(e.type&&o.push(`type="${p(e.type)}"`),e.async&&o.push("async"),e.defer&&o.push("defer"),e.integrity&&o.push(`integrity="${p(e.integrity)}"`),e.crossorigin&&o.push(`crossorigin="${p(e.crossorigin)}"`),e.referrerpolicy&&o.push(`referrerpolicy="${p(e.referrerpolicy)}"`),e.nomodule&&o.push("nomodule"));const l=` data-smbls-script="${p(s||j(e.body||""))}"`;if(!r&&e.body){const d=String(e.body).replace(/<\/script/gi,"<\\/script");i.push(`<script ${o.join(" ")}${l}>${d}<\/script>`)}else i.push(`<script ${o.join(" ")}${l}><\/script>`)}return i},K=t=>`${t.hreflang||""}|${t.href||""}`,N=t=>m(t)?j(JSON.stringify(t)):String(t),T=(t,i,e)=>t==="favicons"?Array.isArray(i)&&(typeof e=="string"||m(e))?` data-smbls-favicon="${p(N(e))}"`:"":(t==="icon"||t==="favicon")&&typeof i=="string"?` data-smbls-single-icon="${p(i)}"`:"",W=t=>m(t)?` data-smbls-alternate="${p(K(t))}"`:"",Y=(t,i)=>{i||(t={...t,robots:"noindex"});const e=Object.entries(t).reduce((r,[s,o])=>{if(!o&&o!==0&&o!==!1||E.has(s))return r;if(s==="title")return r.push(`<title>${p(o)}</title>`),r;if(s==="canonical")return r.push(`<link rel="canonical" href="${p(o)}">`),r;if(s==="manifest")return r.push(`<link rel="manifest" href="${p(o)}">`),r;if(s==="favicon"||s==="favicons"||s==="icon"||s==="icons")return(Array.isArray(o)?o:[o]).forEach(c=>{const u=T(s,o,c);if(typeof c=="string")r.push(`<link rel="icon" href="${p(c)}"${u}>`);else if(typeof c=="object"){const n=x(c);/rel=/.test(n)?r.push(`<link ${n}${u}>`):r.push(`<link rel="icon" ${n}${u}>`)}}),r;if(s==="alternate")return(Array.isArray(o)?o:[o]).forEach(c=>{if(c&&typeof c=="object"){const u=Object.entries(c).filter(([n,g])=>g!==void 0).map(([n,g])=>`${n}="${p(g)}"`).join(" ");r.push(`<link rel="alternate" ${u}${W(c)}>`)}}),r;const l=(f,c,u="name")=>{if(typeof c=="string"||typeof c=="number"||typeof c=="boolean")r.push(`<meta ${u}="${p(f)}" content="${p(c)}">`);else if(Array.isArray(c))c.forEach(n=>{if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")r.push(`<meta ${u}="${p(f)}" content="${p(n)}">`);else if(typeof n=="object"){const g=Object.entries(n).filter(([y,$])=>$!==void 0).map(([y,$])=>`${y}="${p($)}"`).join(" ");r.push(`<meta ${g}>`)}});else if(typeof c=="object"){const n=Object.entries(c).filter(([g,y])=>y!==void 0).map(([g,y])=>`${g}="${p(y)}"`).join(" ");r.push(`<meta ${n}>`)}};if(s.startsWith("http-equiv:")){const f=s.replace("http-equiv:","");return l(f,o,"http-equiv"),r}if(s.startsWith("itemprop:")){const f=s.replace("itemprop:","");return l(f,o,"itemprop"),r}const h=["og:","twitter:","fb:","article:","profile:","book:","business:","music:","product:","video:","DC:","DCTERMS:"].find(f=>s.startsWith(f));if(h){const f=s.replace(h,"");return l(`${h.replace(":","")}:${f}`,o,h==="twitter:"||h==="DC:"||h==="DCTERMS:"?"name":"property"),r}if(s.startsWith("apple:")||s.startsWith("msapplication:")){const f=s.startsWith("apple:")?"apple-":"msapplication-",c=s.replace(/^apple:|^msapplication:/,"");return l(`${f}${c}`,o,"name"),r}return l(s,o),r},['<meta charset="UTF-8">','<meta name="viewport" content="width=device-width, initial-scale=1">']);return e.push(...R(t)),e.join(`
2
+ `)},D=t=>typeof t=="string"&&t.length>0&&!t.startsWith("/")&&!t.startsWith("http"),S=t=>typeof t=="string"&&t.length>0,F=t=>{if(!t||typeof t!="object")return null;if(S(t.src))return t.src;const i=t.content;return!i||typeof i!="object"?null:S(i.src)?i.src:S(i.storageUrl)?i.storageUrl:null};function _(t,i){if(!i||typeof i!="object")return t;const e=s=>!D(s)||!Object.prototype.hasOwnProperty.call(i,s)?s:F(i[s])||s,r={...t};for(const[s,o]of Object.entries(r))typeof o=="string"?r[s]=e(o):Array.isArray(o)&&(r[s]=o.map(l=>typeof l=="string"?e(l):l));return r}function A(t,i){if(!t||!i)return;const e=i.split(".");let r=t;for(const s of e){if(r==null||typeof r!="object")return;r=r[s]}return r}function q(t,i){const e=A(t,i);if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e=="string"&&!L(e))return e}function C(t,i,e){const s=(i.config||i.settings||{}).polyglot||i.polyglot,o=e?.lang||s?.defaultLang||"en",d=(s?.translations||{})[o]||{},h=[e?.state,i.state].filter(u=>u&&typeof u=="object"),f=u=>{for(const n of h){const g=q(n,u);if(g!==void 0)return g}},c={...t};for(const[u,n]of Object.entries(c))typeof n!="string"||!n.includes("{{")||(c[u]=n.replace(/\{\{\s*([^|{}]+?)\s*(?:\|\s*(\w+)\s*)?\}\}/g,(g,y,$)=>{const a=y.trim();if($==="polyglot")return d[a]??A(d,a)??g;if($==="getLocalStateLang")return f(a+o)??g;const b=f(a);return b!==void 0?b:d[a]??A(d,a)??g}));return c}function M(t){if(!m(t))return{};const i={...t};for(const[e,r]of Object.entries(i))if(typeof r=="function"){const s=r.toString(),o=s.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(o){i[e]=`{{ ${o[1]} | getLocalStateLang }}`;continue}const l=s.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(l){i[e]=`{{ ${l[1]} | polyglot }}`;continue}const d=s.match(/s\.(\w+(?:\.\w+)+)/);if(d){i[e]=`{{ ${d[1]} }}`;continue}delete i[e]}else if(typeof r=="string"){const s=r.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(s){i[e]=`{{ ${s[1]} | getLocalStateLang }}`;continue}const o=r.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(o){i[e]=`{{ ${o[1]} | polyglot }}`;continue}if(r.includes("=>")&&r.includes("s.")){const l=r.match(/s\.(\w+(?:\.\w+)+)/);if(l){i[e]=`{{ ${l[1]} }}`;continue}}L(r)&&delete i[e]}return i}function G(t,i,e,{isProduction:r=!1,channel:s="production"}={}){const o=t.pages?.[i],l=m(o?.state)&&o?.state,d=o?.metadata||o?.helmet||l||{},h=M(d),f=new Set(Object.keys(h)),c=t.app?.metadata||{},u=M(c);let n={};if(t.integrations?.seo?n={...t.integrations.seo,...u,...h}:Object.keys(u).length?n={...u,...h}:n={...h},!n.title){const a=t.name||t.key;a?r?n.title=a:s==="development"?n.title=`${a} / dev:symbo.ls`:s==="staging"?n.title=`${a} / staging:symbo.ls`:n.title=`${a} / symbo.ls`:n.title="Symbols demo"}n=C(n,t,e),n.title&&(f.has("title")||!n["og:title"])&&(f.has("og:title")||(n["og:title"]=n.title)),n.description&&(f.has("description")||!n["og:description"])&&(f.has("og:description")||(n["og:description"]=n.description)),n.title&&!n["twitter:title"]&&(n["twitter:title"]=n.title),n.description&&!n["twitter:description"]&&(n["twitter:description"]=n.description);const g=f.has("og:url")?n["og:url"]:f.has("url")?n.url:void 0,y=e?.actualPathname||i;if(g)n["og:url"]=g;else if(n["og:url"]||n.url){const a=(n["og:url"]||n.url||"").replace(/\/$/,"");if(a&&y&&y!=="/"){const b=y.startsWith("/")?y:"/"+y;n["og:url"]=a+b}}n=_(n,t.files);const $=t.name||t.app?.metadata?.title||t.app?.name||"";for(const[a,b]of Object.entries(n))if(typeof b=="string"&&b.includes("{{")){const O=b.replace(/\{\{[^}]*\}\}/g,"").trim();O?n[a]=O:a==="title"?n[a]=$:delete n[a]}return n}export{J as BRENDER_REGISTRY_BLOCK,K as alternateLinkKey,H as brenderRegistryBlock,p as escapeHtml,N as faviconLinkKey,F as fileEntryUrl,R as generateHeadArrayTags,Y as generateMetaTags,G as getPageMetadata,j as hashContent,w as jsonForScript,B as readJsonDataBlock,_ as resolveFileReferences};
@@ -1 +1 @@
1
- const e="smbls_lang",n=t=>t&&t.storageLangKey||e,o=(t,a)=>t||a&&a.defaultLang||"en";export{e as POLYGLOT_LANG_STORAGE_KEY,o as polyglotFallbackLang,n as polyglotLangStorageKey};
1
+ const f="smbls_lang",L=e=>e&&e.storageLangKey||f,u=(e,t)=>e||t&&t.defaultLang||"en",S=(e,t)=>{if(!t)return null;const g=Array.isArray(t.languages)&&t.languages.length?t.languages:Object.keys(t.translations||{}),r=/^\/([^/?#]+)/.exec(String(e||""));if(!r)return null;const i=r[1].toLowerCase();for(const n of g)if(typeof n=="string"&&n.toLowerCase()===i)return n;return null},y=({polyglot:e,translations:t,lang:g,pathname:r,attrs:i=""}={})=>{if(!t||typeof t!="object")return"";const n=e&&e.storagePrefix||"",c=e&&e.storageLangKey||"",s=[];for(const a in t){const o=t[a];o&&typeof o=="object"&&s.push(`localStorage.setItem(${JSON.stringify(n+a)},${JSON.stringify(JSON.stringify(o))})`)}if(c){const a=g||S(r,e)||u(void 0,e);s.push(`if(!localStorage.getItem(${JSON.stringify(c)}))localStorage.setItem(${JSON.stringify(c)},${JSON.stringify(a)})`)}return s.length?`<script${i}>try{${s.join(";")}}catch(e){}<\/script>`:""};export{f as POLYGLOT_LANG_STORAGE_KEY,S as polyglotAddressLang,u as polyglotFallbackLang,L as polyglotLangStorageKey,y as polyglotStartupScript};
@@ -1,3 +1,3 @@
1
- const O=(t,r)=>{for(const e of r)if(t.includes(e))return!0;return!1},R=(t,r)=>{const e=new RegExp(`[${r.join("\\")}]`,"g");return t.replace(e,"")},A={2:/{{\s*((?:\.\.\/)*)([\w\d.]+)\s*(?:\|\s*([\w\d.]+))?\s*}}/g,3:/{{{(\s*(?:\.\.\/)*)([\w\d.]+)\s*(?:\|\s*([\w\d.]+))?\s*}}}/g},m=(t,r)=>r.split(".").reduce((e,c)=>e?.[c],t),L=(t,r)=>{if(!t||!t.__ref)return!0;let e=t;for(;e;){if(e.allowRuntimeTemplates===!0)return!0;const c=e.__ref&&e.__ref.__authoredTemplates;if(c&&c.has(r))return!0;e=e.parent}return!1};function I(t,r,e={}){const{bracketsLength:c=2,authored:u=!1}=e,h=c===3?"{{{":"{{";if(!t.includes(h)||u!==!0&&!L(this,t))return t;const p=A[c],f=r||this.state||{},s=this;return t.replace(p,(x,n,b,g)=>{const a=b.trim();if(g){const l=s?.context,o=l?.functions?.[g]||l?.utils?.[g]||l?.methods?.[g]||l?.snippets?.[g]||s?.[g];if(o&&typeof o=="function")try{return String(o.call(s,a)??"")}catch{return""}return""}if(n){const l=(n.match(/\.\.\//g)||[]).length;let o=f;for(let i=0;i<l;i++){if(!o||!o.parent)return"";o=o.parent}if(a==="parent")return String(o.value??"");const d=m(o,a);return d!=null&&typeof d=="object"?"":String(d??"")}else{const l=m(f,a);if(l!=null&&typeof l!="object")return String(l);const o=s?.context?.polyglot;if(o?.translations){const d=f?.root?.lang||f?.lang||s?.context?.state?.lang||o.defaultLang||"en",i=o.translations[d];if(i){const S=m(i,a);if(S!=null&&typeof S!="object")return String(S);for(const w in i){const y=i[w];if(y&&typeof y=="object"&&!Array.isArray(y)){const _=m(y,a);if(_!=null&&typeof _!="object")return String(_)}}}const C=m(o.translations,a);if(C!=null&&typeof C!="object")return String(C)}return""}})}const k=t=>`${t.charAt(0).toLowerCase()}${t.slice(1)}`,E=(t,r)=>{const e=t.split(`
2
- `);let c=-1,u=-1,h=-1,p=-1;const f=new RegExp(`\\b${r}\\b\\s*:\\s*`);let s=0,x=!1;for(let n=0;n<e.length;n++)if(f.test(e[n])&&!x){if(x=!0,c=n+1,h=e[n].indexOf(r)+1,e[n].includes("{}")){u=c,p=e[n].indexOf("{}")+3;break}const b=e[n].slice(h+r.length);if(b.includes("{")||b.includes("["))s=1;else{u=n+1,p=e[n].length+1;break}}else if(x&&(s+=(e[n].match(/{/g)||[]).length,s+=(e[n].match(/\[/g)||[]).length,s-=(e[n].match(/}/g)||[]).length,s-=(e[n].match(/]/g)||[]).length,s===0)){u=n+1,p=e[n].lastIndexOf("}")!==-1?e[n].lastIndexOf("}")+2:e[n].length+1;break}return{startColumn:h,endColumn:p,startLineNumber:c,endLineNumber:u}},j=/\\([0-7]{1,3})/g,$=t=>t.replace(j,(r,e)=>String.fromCharCode(parseInt(e,8))),F=t=>t.replace(/\n/g,"/////n").replace(/`/g,"/////tilde").replace(/\$/g,"/////dlrsgn"),T=t=>t.replace(/\/\/\/\/\/n/g,`
3
- `).replace(/\/\/\/\/\/tilde/g,"`").replace(/\/\/\/\/\/dlrsgn/g,"$"),N=/[^a-zA-Z0-9\s]/g,v=t=>t.replace(N,r=>"%"+r.charCodeAt(0).toString(16).toUpperCase()),U=t=>t.replace(/%[0-9A-Fa-f]{2}/g,r=>String.fromCharCode(parseInt(r.slice(1),16)));export{U as customDecodeURIComponent,v as customEncodeURIComponent,T as decodeNewlines,F as encodeNewlines,E as findKeyPosition,k as lowercaseFirstLetter,I as replaceLiteralsWithObjectFields,$ as replaceOctalEscapeSequences,O as stringIncludesAny,R as trimStringFromSymbols};
1
+ const N=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),O=(e,r)=>{for(const t of r)if(e.includes(t))return!0;return!1},$=(e,r)=>{const t=new RegExp(`[${r.join("\\")}]`,"g");return e.replace(t,"")},A={2:/{{\s*((?:\.\.\/)*)([\w\d.]+)\s*(?:\|\s*([\w\d.]+))?\s*}}/g,3:/{{{(\s*(?:\.\.\/)*)([\w\d.]+)\s*(?:\|\s*([\w\d.]+))?\s*}}}/g},m=(e,r)=>r.split(".").reduce((t,c)=>t?.[c],e),L=(e,r)=>{if(!e||!e.__ref)return!0;let t=e;for(;t;){if(t.allowRuntimeTemplates===!0)return!0;const c=t.__ref&&t.__ref.__authoredTemplates;if(c&&c.has(r))return!0;t=t.parent}return!1};function E(e,r,t={}){const{bracketsLength:c=2,authored:u=!1}=t,h=c===3?"{{{":"{{";if(!e.includes(h)||u!==!0&&!L(this,e))return e;const p=A[c],g=r||this.state||{},s=this;return e.replace(p,(x,n,b,f)=>{const a=b.trim();if(f){const l=s?.context,o=l?.functions?.[f]||l?.utils?.[f]||l?.methods?.[f]||l?.snippets?.[f]||s?.[f];if(o&&typeof o=="function")try{return String(o.call(s,a)??"")}catch{return""}return""}if(n){const l=(n.match(/\.\.\//g)||[]).length;let o=g;for(let i=0;i<l;i++){if(!o||!o.parent)return"";o=o.parent}if(a==="parent")return String(o.value??"");const d=m(o,a);return d!=null&&typeof d=="object"?"":String(d??"")}else{const l=m(g,a);if(l!=null&&typeof l!="object")return String(l);const o=s?.context?.polyglot;if(o?.translations){const d=g?.root?.lang||g?.lang||s?.context?.state?.lang||o.defaultLang||"en",i=o.translations[d];if(i){const S=m(i,a);if(S!=null&&typeof S!="object")return String(S);for(const w in i){const y=i[w];if(y&&typeof y=="object"&&!Array.isArray(y)){const _=m(y,a);if(_!=null&&typeof _!="object")return String(_)}}}const C=m(o.translations,a);if(C!=null&&typeof C!="object")return String(C)}return""}})}const I=e=>`${e.charAt(0).toLowerCase()}${e.slice(1)}`,k=(e,r)=>{const t=e.split(`
2
+ `);let c=-1,u=-1,h=-1,p=-1;const g=new RegExp(`\\b${r}\\b\\s*:\\s*`);let s=0,x=!1;for(let n=0;n<t.length;n++)if(g.test(t[n])&&!x){if(x=!0,c=n+1,h=t[n].indexOf(r)+1,t[n].includes("{}")){u=c,p=t[n].indexOf("{}")+3;break}const b=t[n].slice(h+r.length);if(b.includes("{")||b.includes("["))s=1;else{u=n+1,p=t[n].length+1;break}}else if(x&&(s+=(t[n].match(/{/g)||[]).length,s+=(t[n].match(/\[/g)||[]).length,s-=(t[n].match(/}/g)||[]).length,s-=(t[n].match(/]/g)||[]).length,s===0)){u=n+1,p=t[n].lastIndexOf("}")!==-1?t[n].lastIndexOf("}")+2:t[n].length+1;break}return{startColumn:h,endColumn:p,startLineNumber:c,endLineNumber:u}},j=/\\([0-7]{1,3})/g,F=e=>e.replace(j,(r,t)=>String.fromCharCode(parseInt(t,8))),T=e=>e.replace(/\n/g,"/////n").replace(/`/g,"/////tilde").replace(/\$/g,"/////dlrsgn"),v=e=>e.replace(/\/\/\/\/\/n/g,`
3
+ `).replace(/\/\/\/\/\/tilde/g,"`").replace(/\/\/\/\/\/dlrsgn/g,"$"),R=/[^a-zA-Z0-9\s]/g,U=e=>e.replace(R,r=>"%"+r.charCodeAt(0).toString(16).toUpperCase()),V=e=>e.replace(/%[0-9A-Fa-f]{2}/g,r=>String.fromCharCode(parseInt(r.slice(1),16)));export{V as customDecodeURIComponent,U as customEncodeURIComponent,v as decodeNewlines,T as encodeNewlines,N as escapeRegExp,k as findKeyPosition,I as lowercaseFirstLetter,E as replaceLiteralsWithObjectFields,F as replaceOctalEscapeSequences,O as stringIncludesAny,$ as trimStringFromSymbols};
package/keys.js CHANGED
@@ -119,6 +119,7 @@ export const METHODS = new Set([
119
119
  'lookup',
120
120
  'lookdown',
121
121
  'lookdownAll',
122
+ 'whenConnected',
122
123
  'getRef',
123
124
  'getPath',
124
125
  'setNodeStyles',
package/metadata.js CHANGED
@@ -24,6 +24,46 @@ export const jsonForScript = (value) => JSON.stringify(value)
24
24
  .replace(/\u2028/g, '\\u2028')
25
25
  .replace(/\u2029/g, '\\u2029')
26
26
 
27
+ /**
28
+ * Read a JSON data block — `<script type="application/json" data-…>` — that a
29
+ * server render left in `doc` for the client: the brender element-path
30
+ * registry (BRENDER_REGISTRY_BLOCK), @symbo.ls/fetch's recorded answers. No
31
+ * Content-Security-Policy blocks a data block (only inline scripts do).
32
+ * @param {Document} doc
33
+ * @param {string} selector - the block's CSS selector
34
+ * @param {object} [options]
35
+ * @param {boolean} [options.remove] - take the block out of the document as
36
+ * it is read
37
+ * @param {(err: Error) => void} [options.warn] - told when the block is not
38
+ * JSON (its value is then undefined)
39
+ * @returns {{ value: *, block: Element } | null} null when the document has
40
+ * no such block
41
+ */
42
+ export const readJsonDataBlock = (doc, selector, { remove = false, warn } = {}) => {
43
+ if (!doc || typeof doc.querySelector !== 'function') return null
44
+ let block = null
45
+ try { block = doc.querySelector(selector) } catch (e) { return null }
46
+ if (!block) return null
47
+ if (remove && block.parentNode) block.parentNode.removeChild(block)
48
+ let value
49
+ try {
50
+ value = JSON.parse(block.textContent || '')
51
+ } catch (err) {
52
+ if (warn) warn(err)
53
+ }
54
+ return { value, block }
55
+ }
56
+
57
+ /** The data block that carries a pre-rendered page's element-path registry. */
58
+ export const BRENDER_REGISTRY_BLOCK = 'script[type="application/json"][data-brender="registry"]'
59
+
60
+ /**
61
+ * The element-path registry as the data block BRENDER_REGISTRY_BLOCK selects,
62
+ * its JSON embedded with jsonForScript (a key can never close the block).
63
+ */
64
+ export const brenderRegistryBlock = (registry) =>
65
+ '<script type="application/json" data-brender="registry">' + jsonForScript(registry) + '</script>'
66
+
27
67
  const buildAttrs = (obj) =>
28
68
  Object.entries(obj || {})
29
69
  .filter(([_, v]) => v !== undefined)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/utils",
3
- "version": "3.14.786",
3
+ "version": "3.14.788",
4
4
  "license": "CC-BY-NC-4.0",
5
5
  "type": "module",
6
6
  "module": "./dist/esm/index.js",
@@ -47,7 +47,7 @@
47
47
  },
48
48
  "gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681",
49
49
  "peerDependencies": {
50
- "@symbo.ls/fetch": "^3.14.664"
50
+ "@symbo.ls/fetch": "^3.14.665"
51
51
  },
52
52
  "peerDependenciesMeta": {
53
53
  "@symbo.ls/fetch": {
package/polyglotLang.js CHANGED
@@ -20,3 +20,65 @@ export const polyglotLangStorageKey = (polyglot) =>
20
20
  */
21
21
  export const polyglotFallbackLang = (stateLang, polyglot) =>
22
22
  stateLang || (polyglot && polyglot.defaultLang) || 'en'
23
+
24
+ /**
25
+ * The language an address names: its first path segment, when that is one of
26
+ * the project's languages (`polyglot.languages`, else the keys of
27
+ * `polyglot.translations`) — `/en/about` with `['ka', 'en']` gives 'en'.
28
+ * Matched without regard to case, returned as configured; null for any other
29
+ * address. A server render (@symbo.ls/brender) starts in it, the way a page's
30
+ * pre-boot script starts the browser in it: stored under
31
+ * polyglotLangStorageKey before the app starts.
32
+ */
33
+ export const polyglotAddressLang = (pathname, polyglot) => {
34
+ if (!polyglot) return null
35
+ const languages = Array.isArray(polyglot.languages) && polyglot.languages.length
36
+ ? polyglot.languages
37
+ : Object.keys(polyglot.translations || {})
38
+ const first = /^\/([^/?#]+)/.exec(String(pathname || ''))
39
+ if (!first) return null
40
+ const segment = first[1].toLowerCase()
41
+ for (const lang of languages) {
42
+ if (typeof lang === 'string' && lang.toLowerCase() === segment) return lang
43
+ }
44
+ return null
45
+ }
46
+
47
+ /**
48
+ * A pre-rendered page's polyglot start-up script, run before the app: the
49
+ * labels the server rendered with, each under `storagePrefix` + its language,
50
+ * and — for a visitor with no language stored yet (`storageLangKey`) — the
51
+ * language the page was rendered in (`lang`), else the language its address
52
+ * names (`pathname`), else the default (polyglotFallbackLang). So the client
53
+ * starts where the server did: on its markup, and on the requests the page's
54
+ * fetch seed recorded. '' without labels.
55
+ *
56
+ * Shared by every server that writes one — @symbo.ls/brender renderPage (an
57
+ * ISR page) and @symbo.ls/mermaid (a publish-time cache entry, a live render)
58
+ * — which each kept a copy that stored the default language.
59
+ *
60
+ * @param {object} options
61
+ * @param {object} [options.polyglot] - the project's polyglot config
62
+ * @param {object} [options.translations] - labels by language
63
+ * @param {string} [options.lang] - the language the page was rendered in
64
+ * @param {string} [options.pathname] - the page's address
65
+ * @param {string} [options.attrs] - attributes for the tag (` nonce="…"`)
66
+ * @returns {string}
67
+ */
68
+ export const polyglotStartupScript = ({ polyglot, translations, lang, pathname, attrs = '' } = {}) => {
69
+ if (!translations || typeof translations !== 'object') return ''
70
+ const storagePrefix = (polyglot && polyglot.storagePrefix) || ''
71
+ const storageLangKey = (polyglot && polyglot.storageLangKey) || ''
72
+ const entries = []
73
+ for (const code in translations) {
74
+ const map = translations[code]
75
+ if (map && typeof map === 'object') {
76
+ entries.push(`localStorage.setItem(${JSON.stringify(storagePrefix + code)},${JSON.stringify(JSON.stringify(map))})`)
77
+ }
78
+ }
79
+ if (storageLangKey) {
80
+ const pageLang = lang || polyglotAddressLang(pathname, polyglot) || polyglotFallbackLang(undefined, polyglot)
81
+ entries.push(`if(!localStorage.getItem(${JSON.stringify(storageLangKey)}))localStorage.setItem(${JSON.stringify(storageLangKey)},${JSON.stringify(pageLang)})`)
82
+ }
83
+ return entries.length ? `<script${attrs}>try{${entries.join(';')}}catch(e){}</script>` : ''
84
+ }
package/string.js CHANGED
@@ -1,5 +1,8 @@
1
1
  'use strict'
2
2
 
3
+ /** `str` with every RegExp special character escaped, to match it literally. */
4
+ export const escapeRegExp = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
5
+
3
6
  export const stringIncludesAny = (str, characters) => {
4
7
  for (const char of characters) {
5
8
  if (str.includes(char)) {