@symbo.ls/utils 3.14.775 → 3.14.777

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/keys.js CHANGED
@@ -1 +1 @@
1
- "use strict";var r=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var i=(t,e)=>{for(var n in e)r(t,n,{get:e[n],enumerable:!0})},h=(t,e,n,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of c(e))!_.call(t,o)&&o!==n&&r(t,o,{get:()=>e[o],enumerable:!(a=l(e,o))||a.enumerable});return t};var x=t=>h(r({},"__esModule",{value:!0}),t);var m={};i(m,{DOMQL_EVENTS:()=>f,DOMQ_PROPERTIES:()=>E,METHODS:()=>d,METHODS_EXL:()=>R,PARSED_DOMQ_PROPERTIES:()=>S,PROPS_METHODS:()=>p,STATE_METHODS:()=>s,STATE_PROPERTIES:()=>u});module.exports=x(m);const E=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"]),u=["ref","parent","__element","__depends","__ref","__children","root"],s=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"]),p=new Set(["update","__element"]),d=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"]),R=new Set(["node","context","extends","__element","__ref",...d,...s,...p]),f=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","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,10 +1,10 @@
1
- "use strict";var D=Object.create;var g=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var I=Object.getPrototypeOf,L=Object.prototype.hasOwnProperty;var M=(e,t)=>{for(var n in t)g(e,n,{get:t[n],enumerable:!0})},R=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of F(t))!L.call(e,r)&&r!==n&&g(e,r,{get:()=>t[r],enumerable:!(o=T(t,r))||o.enumerable});return e};var m=(e,t,n)=>(n=e!=null?D(I(e)):{},R(t||!e||!e.__esModule?g(n,"default",{value:e,enumerable:!0}):n,e)),J=e=>R(g({},"__esModule",{value:!0}),e);var wt={};M(wt,{call:()=>ut,defineSetter:()=>rt,error:()=>O,get:()=>U,getChildren:()=>Z,getContext:()=>ot,getDB:()=>at,getPath:()=>K,getQuery:()=>ht,getRef:()=>Y,getRoot:()=>tt,getRootContext:()=>nt,getRootData:()=>et,getRootState:()=>q,isMethod:()=>vt,keys:()=>j,log:()=>st,lookdown:()=>z,lookdownAll:()=>G,lookup:()=>B,nextElement:()=>ct,parse:()=>Q,parseDeep:()=>S,previousElement:()=>lt,remove:()=>H,setActiveRootState:()=>X,setNodeStyles:()=>C,setProps:()=>W,spotByPath:()=>V,variables:()=>ft,verbose:()=>N,warn:()=>it});module.exports=J(wt);var w=require("./triggerEvent.js"),d=require("./keys.js"),f=require("./types.js"),x=require("./object.js"),P=require("./env.js"),A=require("./array.js"),b=require("./cache.js");const h="production";function V(e){const t=this,{__ref:n}=t,o=[].concat(e);let r=n.root[o[0]];if(!o||!o.length)return console.log(o,"on",t.key,"is undefined");for(;r.key===o[0]&&(o.shift(),!!o.length);)if(r=r[o[0]],!r)return;return r}function B(e){const t=this;let{parent:n}=t;if((0,f.isFunction)(e))return n.state&&e(n,n.state,n.context)?n:n.parent?n.lookup(e):void 0;if(t[e])return t[e];for(;n.param!==e;){if(n[e])return n[e];if(n=n.parent,!n)return}return n}function z(e){const t=this,{__ref:n}=t,o=n?.__children;if(o)for(let r=0;r<o.length;r++){const s=o[r],i=t[s];if(s===e)return i;if((0,f.isFunction)(e)){const l=e(i,i.state,i.context);if(i.state&&l)return i}const c=i?.lookdown?.(e);if(c)return c}}function G(e,t=[]){const n=this,{__ref:o}=n,r=o?.__children;if(r){for(let s=0;s<r.length;s++){const i=r[s],c=n[i];if(i===e)t.push(c);else if((0,f.isFunction)(e)){const l=e(c,c.state,c.context);c.state&&l&&t.push(c)}c?.lookdownAll?.(e,t)}return t.length?t:void 0}}function C(e={}){const t=this;if(t.node?.style){for(const n in e){const o=e[n],r=t[n];if((0,f.isObject)(o)&&r)C.call(r,o);else if(o!=null){const s=n.replace(/[A-Z]/g,c=>"-"+c.toLowerCase()),i=String(o).replace(/\s*!important\s*$/,"");t.node.style.setProperty(s,i,"important")}}return t}}function H(e){const t=this;if((0,w.triggerEventOn)("beforeRemove",t,e)===!1)return t;(0,f.isFunction)(t.node.remove)?t.node.remove():(0,P.isProduction)()||(console.warn("This item cant be removed"),t.log()),delete t.parent[t.key],t.parent.__ref&&(t.parent.__ref.__children=(0,A.removeValueFromArray)(t.parent.__ref.__children,t.key)),(0,w.triggerEventOn)("remove",t,e)}function U(e){return this[e]}function W(e,t){const n=this;if(e)return n.update(e,t),n}function Y(e){return e?this.__ref&&this.__ref[e]:this.__ref}function Z(){const e=this.getRef("__children");return Array.isArray(e)?e.map(t=>this[t]):[]}function K(){return this.getRef().path}let $=null;const X=e=>{$=e||null},k=()=>$||null;function q(e){let t=null;const n=o=>o.__element&&o.root?.isRootState;if(!this)t=k();else if(n(this))t=this.root;else if(this.__ref&&this.__ref.path){const o=this.state&&n(this.state),r=(0,f.isFunction)(this.state)&&this.parent.state&&n(this.parent.state);(o||r)&&(t=this.state.root||this.parent.state.root)}return t||(t=k()),e?t?.[e]:t}function tt(e){const t=this?.__ref?.root||this.getRootState()?.__element;if(!t)throw new Error(`[smbls] getRoot() could not resolve a root element for "${this?.key||"<unknown>"}" \u2014 it has no __ref (never went through create()) and no root state is registered. Answering undefined here used to no-op silently for every caller.`);return Object.keys(t).length>0&&e?t[e]:t}function et(e){return this.getRoot("data")&&Object.keys(this.getRoot("data")).length>0&&e?this.getRoot("data")[e]:this.getRoot("data")}function nt(e){const t=this.getRoot()?.context;return e?t[e]:t}function ot(e){const t=this.context;return e?t[e]:t}const rt=(e,t,n,o)=>Object.defineProperty(e,t,{get:n,set:o});function j(){const e=this,t=[];for(const n in e)!Object.prototype.hasOwnProperty.call(e,n)||d.DOMQ_PROPERTIES.has(n)&&!d.PARSED_DOMQ_PROPERTIES.has(n)||t.push(n);return t}function Q(e=[]){const t=this,n={},o=j.call(t),r=o.includes("children"),s=e.length?new Set(e):null;for(let i=0;i<o.length;i++){const c=o[i];if(s&&s.has(c)||!Object.prototype.hasOwnProperty.call(t,c)||r&&c==="content")continue;const l=t[c];if(c==="state"){if(t.__ref&&!t.__ref.__hasRootState)continue;const u=(0,f.isFunction)(l&&l.parse)?l.parse():l;n[c]=(0,f.isFunction)(u)?u:JSON.parse(JSON.stringify(u||{}))}else if(c==="scope"){if(t.__ref&&!t.__ref.__hasRootScope)continue;n[c]=JSON.parse(JSON.stringify(l||{}))}else if(c==="props"){const{__element:u,update:a,...p}=t[c];n[c]=p}else(0,f.isDefined)(l)&&Object.prototype.hasOwnProperty.call(t,c)&&(n[c]=l)}return n}function S(e=[],t=new WeakSet){const n=this;if(t.has(n))return;t.add(n);const o=Q.call(n,e),r=e.length?new Set(e):null;for(const s in o){if(r&&r.has(s)||!Object.prototype.hasOwnProperty.call(n,s))continue;const i=o[s];Array.isArray(i)?o[s]=i.map(c=>(0,f.isObjectLike)(c)?S.call(c,e,t):c):(0,f.isObjectLike)(i)&&(o[s]=S.call(i,e,t))}return o}function N(...e){if(h!=="test"&&h!=="development")return;const t=this,{__ref:n}=t;return console.groupCollapsed(t.key),e.length?e.forEach(o=>console.log(`%c${o}:
2
- `,"font-weight: bold",t[o])):(console.log(n.path),t.keys().forEach(r=>console.log(`%c${r}:`,"font-weight: bold",t[r]))),console.log(t),console.groupEnd(t.key),t}function st(...e){(h==="test"||h==="development")&&console.log(...e)}function it(...e){(h==="test"||h==="development")&&console.warn(...e)}function O(...e){if(h==="test"||h==="development"){if(e[e.length-1]?.debugger)debugger;throw e[e.length-1]?.verbose&&N.call(this),new Error(...e)}}function ct(){const e=this,{key:t,parent:n}=e,{__children:o}=n.__ref,r=o.indexOf(t),s=o[r+1];return n[s]}function lt(e){const t=e||this,{key:n,parent:o}=t,{__children:r}=o.__ref;if(!r)return;const s=r.indexOf(n);return o[r[s-1]]}function ft(e={}){const t=this;t.data||(t.data={}),t.data.varCaches||(t.data.varCaches={});const n=t.data.varCaches,o={};let r;for(const s in e)e[s]!==n[s]&&(r=!0,o[s]=e[s]);return{changed:s=>{if(!r)return;const i=s(o,(0,x.deepClone)(n));for(const c in o)n[c]=o[c];return i},timeout:(s,i)=>{if(!r)return;const c=setTimeout(()=>{s(o),clearTimeout(c)},i)}}}function ut(e,...t){const n=this.context,o=n.utils?.[e]||n.functions?.[e]||n.methods?.[e]||n.snippets?.[e];if(o&&!(0,x.isFailedRevival)(o))try{const r=o.call(this,...t);return r&&typeof r.then=="function"&&r.catch(s=>{O.call(this,s)}),r}catch(r){if(O.call(this,r),n?.strictMode)throw r}}async function at(){const e=this,t=e.context?.fetch;if(!t)return null;if(typeof t.select=="function"){if(!t.__authInitialized&&t.getSession){const{initAdapterAuth:r}=await import("@symbo.ls/fetch");await r(t,e.context)}return t}if(t.__resolved){if(!t.__resolved.__authInitialized&&t.__resolved.getSession){const{initAdapterAuth:r}=await import("@symbo.ls/fetch");await r(t.__resolved,e.context)}return t.__resolved}if(t.__resolving)return t.__resolving;const n=import("@symbo.ls/fetch").then(({resolveDb:r})=>r(t));t.__resolving=n;const o=await n;if(t.__resolved=o,e.context.fetch=o,delete t.__resolving,o?.getSession){const{initAdapterAuth:r}=await import("@symbo.ls/fetch");await r(o,e.context)}return o}function ht(e){const t=this,n=e||b.OPTIONS.useStateQuery||t.context?.useStateQuery;if(!n)return null;const o={};if(v(t,o),n===!0)return o;const r=yt[n];return r?r(o):o}const v=(e,t)=>{const n=e.__ref;if(!n)return;const o=n.__state;o&&typeof o=="string"&&pt(t,o);const r=n.__children;if(r)for(let c=0;c<r.length;c++){const l=e[r[c]];l&&l.__ref&&v(l,t)}const s=n.contentElementKey||"content",i=e[s];i&&i.__ref&&v(i,t)},pt=(e,t)=>{const o=t.replaceAll("../","").replaceAll("~/","").split("/");let r=e;for(let s=0;s<o.length;s++){const i=o[s];s===o.length-1?r[i]||(r[i]=!0):(r[i]===!0&&(r[i]={}),r[i]||(r[i]={}),r=r[i])}},E=(e,t=0)=>{const n=" ".repeat(t),o=Object.entries(e);return o.length?o.map(([s,i])=>i===!0?`${n}${s}`:`${n}${s} {
1
+ "use strict";var D=Object.create;var g=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var F=Object.getPrototypeOf,L=Object.prototype.hasOwnProperty;var M=(e,t)=>{for(var n in t)g(e,n,{get:t[n],enumerable:!0})},$=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of T(t))!L.call(e,r)&&r!==n&&g(e,r,{get:()=>t[r],enumerable:!(o=I(t,r))||o.enumerable});return e};var J=(e,t,n)=>(n=e!=null?D(F(e)):{},$(t||!e||!e.__esModule?g(n,"default",{value:e,enumerable:!0}):n,e)),G=e=>$(g({},"__esModule",{value:!0}),e);var Rt={};M(Rt,{call:()=>ht,defineSetter:()=>it,error:()=>R,get:()=>W,getChildren:()=>K,getContext:()=>st,getDB:()=>dt,getPath:()=>X,getQuery:()=>_t,getRef:()=>Z,getRoot:()=>nt,getRootContext:()=>rt,getRootData:()=>ot,getRootState:()=>et,isMethod:()=>Ot,keys:()=>N,log:()=>ct,lookdown:()=>z,lookdownAll:()=>H,lookup:()=>V,nextElement:()=>ft,parse:()=>j,parseDeep:()=>O,previousElement:()=>ut,promoteActiveRootState:()=>tt,remove:()=>U,setActiveRootState:()=>q,setNodeStyles:()=>C,setProps:()=>Y,spotByPath:()=>B,variables:()=>at,verbose:()=>Q,warn:()=>lt});module.exports=G(Rt);var w=require("./triggerEvent.js"),d=require("./keys.js"),f=require("./types.js"),y=require("./object.js"),P=require("./env.js"),A=require("./array.js"),b=require("./cache.js");const h="production";function B(e){const t=this,{__ref:n}=t,o=[].concat(e);let r=n.root[o[0]];if(!o||!o.length)return console.log(o,"on",t.key,"is undefined");for(;r.key===o[0]&&(o.shift(),!!o.length);)if(r=r[o[0]],!r)return;return r}function V(e){const t=this;let{parent:n}=t;if((0,f.isFunction)(e))return n.state&&e(n,n.state,n.context)?n:n.parent?n.lookup(e):void 0;if(t[e])return t[e];for(;n.param!==e;){if(n[e])return n[e];if(n=n.parent,!n)return}return n}function z(e){const t=this,{__ref:n}=t,o=n?.__children;if(o)for(let r=0;r<o.length;r++){const s=o[r],i=t[s];if(s===e)return i;if((0,f.isFunction)(e)){const l=e(i,i.state,i.context);if(i.state&&l)return i}const c=i?.lookdown?.(e);if(c)return c}}function H(e,t=[]){const n=this,{__ref:o}=n,r=o?.__children;if(r){for(let s=0;s<r.length;s++){const i=r[s],c=n[i];if(i===e)t.push(c);else if((0,f.isFunction)(e)){const l=e(c,c.state,c.context);c.state&&l&&t.push(c)}c?.lookdownAll?.(e,t)}return t.length?t:void 0}}function C(e={}){const t=this;if(t.node?.style){for(const n in e){const o=e[n],r=t[n];if((0,f.isObject)(o)&&r)C.call(r,o);else if(o!=null){const s=n.replace(/[A-Z]/g,c=>"-"+c.toLowerCase()),i=String(o).replace(/\s*!important\s*$/,"");t.node.style.setProperty(s,i,"important")}}return t}}function U(e){const t=this;if((0,w.triggerEventOn)("beforeRemove",t,e)===!1)return t;(0,f.isFunction)(t.node.remove)?t.node.remove():(0,P.isProduction)()||(console.warn("This item cant be removed"),t.log()),delete t.parent[t.key],t.parent.__ref&&(t.parent.__ref.__children=(0,A.removeValueFromArray)(t.parent.__ref.__children,t.key)),(0,w.triggerEventOn)("remove",t,e)}function W(e){return this[e]}function Y(e,t){const n=this;if(e)return n.update(e,t),n}function Z(e){return e?this.__ref&&this.__ref[e]:this.__ref}function K(){const e=this.getRef("__children");return Array.isArray(e)?e.map(t=>this[t]):[]}function X(){return this.getRef().path}let m=null;const q=e=>{m=e||null},tt=(e,t)=>{e&&t&&m===e&&(m=t)},k=()=>m||null;function et(e){let t=null;const n=o=>o.__element&&o.root?.isRootState;if(!this)t=k();else if(n(this))t=this.root;else if(this.__ref&&this.__ref.path){const o=this.state&&n(this.state),r=(0,f.isFunction)(this.state)&&this.parent.state&&n(this.parent.state);(o||r)&&(t=this.state.root||this.parent.state.root)}return t||(t=k()),e?t?.[e]:t}function nt(e){const t=this?.__ref?.root||this.getRootState()?.__element;if(!t)throw new Error(`[smbls] getRoot() could not resolve a root element for "${this?.key||"<unknown>"}" \u2014 it has no __ref (never went through create()) and no root state is registered. Answering undefined here used to no-op silently for every caller.`);return Object.keys(t).length>0&&e?t[e]:t}function ot(e){return this.getRoot("data")&&Object.keys(this.getRoot("data")).length>0&&e?this.getRoot("data")[e]:this.getRoot("data")}function rt(e){const t=this.getRoot()?.context;return e?t[e]:t}function st(e){const t=this.context;return e?t[e]:t}const it=(e,t,n,o)=>Object.defineProperty(e,t,{get:n,set:o});function N(){const e=this,t=[];for(const n in e)!Object.prototype.hasOwnProperty.call(e,n)||d.DOMQ_PROPERTIES.has(n)&&!d.PARSED_DOMQ_PROPERTIES.has(n)||t.push(n);return t}function j(e=[]){const t=this,n={},o=N.call(t),r=o.includes("children"),s=e.length?new Set(e):null;for(let i=0;i<o.length;i++){const c=o[i];if(s&&s.has(c)||!Object.prototype.hasOwnProperty.call(t,c)||r&&c==="content")continue;const l=t[c];if(c==="state"){if(t.__ref&&!t.__ref.__hasRootState)continue;const u=(0,f.isFunction)(l&&l.parse)?l.parse():l;n[c]=(0,f.isFunction)(u)?u:JSON.parse(JSON.stringify(u||{}))}else if(c==="scope"){if(t.__ref&&!t.__ref.__hasRootScope)continue;n[c]=JSON.parse(JSON.stringify(l||{}))}else if(c==="props"){const{__element:u,update:a,...p}=t[c];n[c]=p}else(0,f.isDefined)(l)&&Object.prototype.hasOwnProperty.call(t,c)&&(n[c]=l)}return n}function O(e=[],t=new WeakSet){const n=this;if(t.has(n))return;t.add(n);const o=j.call(n,e),r=e.length?new Set(e):null;for(const s in o){if(r&&r.has(s)||!Object.prototype.hasOwnProperty.call(n,s))continue;const i=o[s];Array.isArray(i)?o[s]=i.map(c=>(0,f.isObjectLike)(c)?O.call(c,e,t):c):(0,f.isObjectLike)(i)&&(o[s]=O.call(i,e,t))}return o}function Q(...e){if(h!=="test"&&h!=="development")return;const t=this,{__ref:n}=t;return console.groupCollapsed(t.key),e.length?e.forEach(o=>console.log(`%c${o}:
2
+ `,"font-weight: bold",t[o])):(console.log(n.path),t.keys().forEach(r=>console.log(`%c${r}:`,"font-weight: bold",t[r]))),console.log(t),console.groupEnd(t.key),t}function ct(...e){(h==="test"||h==="development")&&console.log(...e)}function lt(...e){(h==="test"||h==="development")&&console.warn(...e)}function R(...e){if(h==="test"||h==="development"){if(e[e.length-1]?.debugger)debugger;throw e[e.length-1]?.verbose&&Q.call(this),new Error(...e)}}function ft(){const e=this,{key:t,parent:n}=e,{__children:o}=n.__ref,r=o.indexOf(t),s=o[r+1];return n[s]}function ut(e){const t=e||this,{key:n,parent:o}=t,{__children:r}=o.__ref;if(!r)return;const s=r.indexOf(n);return o[r[s-1]]}function at(e={}){const t=this;t.data||(t.data={}),t.data.varCaches||(t.data.varCaches={});const n=t.data.varCaches,o={};let r;for(const s in e)e[s]!==n[s]&&(r=!0,o[s]=e[s]);return{changed:s=>{if(!r)return;const i=s(o,(0,y.deepClone)(n));for(const c in o)n[c]=o[c];return i},timeout:(s,i)=>{if(!r)return;const c=setTimeout(()=>{s(o),clearTimeout(c)},i)}}}function ht(e,...t){const n=this.context,o=n.utils?.[e]||n.functions?.[e]||n.methods?.[e]||n.snippets?.[e];if(o&&!(0,y.isFailedRevival)(o))try{const r=o.call(this,...t);return r&&typeof r.then=="function"&&r.catch(s=>{R.call(this,s)}),r}catch(r){if(R.call(this,r),n?.strictMode)throw r}}const pt="[smbls] getDB needs @symbo.ls/fetch, which the smbls embed bundle does not include: add @symbo.ls/fetch to the page's importmap (the runtime import then resolves) or use the full smbls bundle.",x=()=>import("@symbo.ls/fetch").catch(e=>{throw new Error(pt,{cause:e})});async function dt(){const e=this,t=e.context?.fetch;if(!t)return null;if(typeof t.select=="function"){if(!t.__authInitialized&&t.getSession){const{initAdapterAuth:r}=await x();await r(t,e.context)}return t}if(t.__resolved){if(!t.__resolved.__authInitialized&&t.__resolved.getSession){const{initAdapterAuth:r}=await x();await r(t.__resolved,e.context)}return t.__resolved}if(t.__resolving)return t.__resolving;const n=x().then(({resolveDb:r})=>r(t));t.__resolving=n;const o=await n;if(t.__resolved=o,e.context.fetch=o,delete t.__resolving,o?.getSession){const{initAdapterAuth:r}=await x();await r(o,e.context)}return o}function _t(e){const t=this,n=e||b.OPTIONS.useStateQuery||t.context?.useStateQuery;if(!n)return null;const o={};if(S(t,o),n===!0)return o;const r=wt[n];return r?r(o):o}const S=(e,t)=>{const n=e.__ref;if(!n)return;const o=n.__state;o&&typeof o=="string"&&gt(t,o);const r=n.__children;if(r)for(let c=0;c<r.length;c++){const l=e[r[c]];l&&l.__ref&&S(l,t)}const s=n.contentElementKey||"content",i=e[s];i&&i.__ref&&S(i,t)},gt=(e,t)=>{const o=t.replaceAll("../","").replaceAll("~/","").split("/");let r=e;for(let s=0;s<o.length;s++){const i=o[s];s===o.length-1?r[i]||(r[i]=!0):(r[i]===!0&&(r[i]={}),r[i]||(r[i]={}),r=r[i])}},E=(e,t=0)=>{const n=" ".repeat(t),o=Object.entries(e);return o.length?o.map(([s,i])=>i===!0?`${n}${s}`:`${n}${s} {
3
3
  ${E(i,t+1)}
4
4
  ${n}}`).join(`
5
- `):""},dt=e=>`{
5
+ `):""},mt=e=>`{
6
6
  ${E(e,1)}
7
- }`,_t=e=>{const t={fields:{},include:[]},n=(o,r)=>{const s=[];for(const i in o)if(o[i]===!0)s.push(i);else{const c=r?`${r}.${i}`:i;t.include.push(c),n(o[i],c)}s.length&&(t.fields[r||"_root"]=s)};return n(e,""),t},gt=e=>{const t=s=>{const i=[],c=[];for(const l in s)if(s[l]===!0)i.push(l);else{const u=t(s[l]),a=[];u.select&&a.push(`$select=${u.select}`),u.expand&&a.push(`$expand=${u.expand}`),c.push(a.length?`${l}(${a.join(";")})`:l)}return{select:i.length?i.join(","):"",expand:c.length?c.join(","):""}},{select:n,expand:o}=t(e),r=[];return n&&r.push(`$select=${n}`),o&&r.push(`$expand=${o}`),r.join("&")},mt=(e,t)=>{const n=[],o=[],r=new Set,s=(a,p,y)=>{r.add(p),y&&o.push(`LEFT JOIN ${p} ON ${p}.${y}_id = ${y}.id`);for(const _ in a)a[_]===!0?n.push(`${p}.${_}`):s(a[_],_,p)},i=Object.keys(e);i.length===1&&e[i[0]]!==!0?s(e[i[0]],i[0],null):s(e,"_root",null);const c=[...r][0]||"_root",l=n.length?n.join(", "):"*",u=o.length?`
7
+ }`,xt=e=>{const t={fields:{},include:[]},n=(o,r)=>{const s=[];for(const i in o)if(o[i]===!0)s.push(i);else{const c=r?`${r}.${i}`:i;t.include.push(c),n(o[i],c)}s.length&&(t.fields[r||"_root"]=s)};return n(e,""),t},yt=e=>{const t=s=>{const i=[],c=[];for(const l in s)if(s[l]===!0)i.push(l);else{const u=t(s[l]),a=[];u.select&&a.push(`$select=${u.select}`),u.expand&&a.push(`$expand=${u.expand}`),c.push(a.length?`${l}(${a.join(";")})`:l)}return{select:i.length?i.join(","):"",expand:c.length?c.join(","):""}},{select:n,expand:o}=t(e),r=[];return n&&r.push(`$select=${n}`),o&&r.push(`$expand=${o}`),r.join("&")},vt=(e,t)=>{const n=[],o=[],r=new Set,s=(a,p,v)=>{r.add(p),v&&o.push(`LEFT JOIN ${p} ON ${p}.${v}_id = ${v}.id`);for(const _ in a)a[_]===!0?n.push(`${p}.${_}`):s(a[_],_,p)},i=Object.keys(e);i.length===1&&e[i[0]]!==!0?s(e[i[0]],i[0],null):s(e,"_root",null);const c=[...r][0]||"_root",l=n.length?n.join(", "):"*",u=o.length?`
8
8
  `+o.join(`
9
9
  `):"";return`SELECT ${l}
10
- FROM ${c}${u}`},xt=e=>{const t=[],n=(o,r)=>{for(const s in o){const i=r?`${r}/${s}`:s;o[s]===!0?t.push(i):n(o[s],i)}};return n(e,""),t},yt={graphql:dt,"json-api":_t,odata:gt,sql:mt,paths:xt};function vt(e,t){return!!(d.METHODS.has(e)||t?.context?.methods?.[e])}
10
+ FROM ${c}${u}`},St=e=>{const t=[],n=(o,r)=>{for(const s in o){const i=r?`${r}/${s}`:s;o[s]===!0?t.push(i):n(o[s],i)}};return n(e,""),t},wt={graphql:mt,"json-api":xt,odata:yt,sql:vt,paths:St};function Ot(e,t){return!!(d.METHODS.has(e)||t?.context?.methods?.[e])}
@@ -1 +1 @@
1
- "use strict";var u=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var R=(n,t)=>{for(var s in t)u(n,s,{get:t[s],enumerable:!0})},U=(n,t,s,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of j(t))!F.call(n,r)&&r!==s&&u(n,r,{get:()=>t[r],enumerable:!(e=O(t,r))||e.enumerable});return n};var E=n=>U(u({},"__esModule",{value:!0}),n);var x={};R(x,{deepDefaults:()=>p,fetchLibraryData:()=>A,isWrappedLibrary:()=>m,mergeSharedLibraries:()=>M,normalizeIgnoreList:()=>y,normalizeLibraryKey:()=>f,resolveSharedLibraries:()=>Y,sharedLibrary:()=>z});module.exports=E(x);var a=require("./types.js");const b="system",B="https://smbls-kv.nika-980.workers.dev",P="https://api.symbols.app";function f(n){const t=String(n||"").trim();if(!t)return{owner:b,key:"",full:""};let s=null,e=t;if(t.includes("/")){const o=t.indexOf("/");s=t.slice(0,o),e=t.slice(o+1)}e=e.replace(/\.symbo\.ls$/iu,""),s||(s=b);const r=e?`${s}/${e}`:"";return{owner:s,key:e,full:r}}const p=(n,t,s,e)=>{for(const r in t){const o=e?`${e}/${r}`:r;s&&s.has(o)||(r in n?(0,a.isObject)(n[r])&&(0,a.isObject)(t[r])&&p(n[r],t[r],s,o):n[r]=t[r])}},w=(n,t,s)=>{if(!(0,a.isObject)(n)||!t.size)return n;const e=`${s}/`;let r=!1;for(const i of t)if(i.startsWith(e)){r=!0;break}if(!r)return n;const o={};for(const i in n){if(!Object.prototype.hasOwnProperty.call(n,i))continue;const c=`${s}/${i}`;t.has(c)||(o[i]=w(n[i],t,c))}return o},D=new Set,T=new Set(["components","pages","functions","snippets","methods"]),g=(n,t)=>t===""&&T.has(n),k=["fontFamily","fontfamily","font_family","FONT_FAMILY"],C=n=>{const t=new Map;if(!(0,a.isObject)(n))return t;for(const s of k){const e=n[s];if((0,a.isObject)(e))for(const r in e)!(0,a.isObject)(e[r])||!e[r].isDefault||(t.has(s)||t.set(s,new Set),t.get(s).add(r))}return t},G=(n,t)=>{for(const s of k){const e=n[s];if(!(0,a.isObject)(e))continue;const r=t.get(s);let o=null;for(const i in e){const c=e[i];if(!(0,a.isObject)(c)||!c.isDefault||r&&r.has(i))continue;const l={...c};delete l.isDefault,o||(o={...e}),o[i]=l}o&&(n[s]=o)}},N=n=>n.replace(/\.js$/iu,""),y=n=>{const t=new Set;if(!Array.isArray(n))return t;for(const s of n){if(!(0,a.isString)(s))continue;const e=s.split("/").map(r=>N(r.trim())).filter(Boolean).join("/");e&&t.add(e)}return t},z=(n,t={})=>({library:n,ignoreList:Array.isArray(t.ignoreList)?t.ignoreList:[]}),m=n=>(0,a.isObject)(n)&&Array.isArray(n.ignoreList)&&("library"in n||"key"in n||"name"in n),J=n=>n.library!==void 0?n.library:n.key??n.name,K=(n,t,s)=>{const e=y(t.sharedLibIgnore);t.sharePages===!1&&e.add("pages");const r=e.size?new Set([...s,...e]):s;for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&!(o==="sharePages"||o==="sharedLibIgnore")&&o!=="app"&&!r.has(o))if((0,a.isObject)(t[o])&&(0,a.isObject)(n[o]))if(o==="designSystem")p(n[o],t[o],r,o);else for(const i in t[o])r.has(`${o}/${i}`)||(i in n[o]?g(o,n[o][i])&&!g(o,t[o][i])&&(n[o][i]=t[o][i]):n[o][i]=t[o][i]);else o in n||(n[o]=w(t[o],r,o))},M=(n,t)=>{if(!t||!t.length)return;const s=C(n.designSystem);for(let e=0;e<t.length;e++){let r=t[e],o=D;m(r)&&(o=y(r.ignoreList),r=r.library),(0,a.isObject)(r)&&K(n,r,o)}s.size&&G(n.designSystem,s)};async function A(n,t={}){if((t.provider||"kv")==="api")return L(n,t);const e=await W(n,t);return e||L(n,t)}async function W(n,t={}){const s=t.kvBaseUrl||B,e=t.env||"production",r=`${s}/kv/${encodeURIComponent(n)}?env=${e}`;try{const o=await fetch(r,{method:"GET"});return o.ok&&(await o.json())?.value||null}catch{return null}}async function L(n,t={}){const s=t.apiBaseUrl||P,{key:e}=f(n);try{const r=`${s}/core/projects/libraries/available?search=${encodeURIComponent(e)}&limit=10`,o=await fetch(r,{method:"GET"});if(!o.ok)return null;const i=await o.json(),l=(i?.items||i?.data||(Array.isArray(i)?i:[])).find(_=>{const{key:v}=f(_?.key);return v.toLowerCase()===e.toLowerCase()});if(!l?.id&&!l?._id)return null;const S=l.id||l._id,I=`${s}/core/projects/${encodeURIComponent(S)}/data?branch=main`,d=await fetch(I,{method:"GET"});if(!d.ok)return null;const h=await d.json();return h?.data||h||null}catch{return null}}async function $(n,t={}){if((0,a.isObject)(n))return n;if((0,a.isString)(n)){const{full:s}=f(n);if(!s)return null;try{const e=await A(s,t);return e||console.warn(`[smbls] Shared library "${s}" not found`),e}catch(e){return console.warn(`[smbls] Failed to fetch shared library "${s}":`,e.message),null}}return null}async function Y(n,t={}){return!n||!n.length?[]:(await Promise.all(n.map(async e=>{if(m(e)){const r=await $(J(e),t);return r?{library:r,ignoreList:e.ignoreList}:null}return $(e,t)}))).filter(Boolean)}
1
+ "use strict";var h=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var P=(n,t)=>{for(var o in t)h(n,o,{get:t[o],enumerable:!0})},M=(n,t,o,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of F(t))!U.call(n,s)&&s!==o&&h(n,s,{get:()=>t[s],enumerable:!(e=E(t,s))||e.enumerable});return n};var D=n=>M(h({},"__esModule",{value:!0}),n);var nn={};P(nn,{__resetBuiltinMethodWarnings:()=>Y,deepDefaults:()=>p,fetchLibraryData:()=>j,isWrappedLibrary:()=>w,mergeSharedLibraries:()=>Q,normalizeIgnoreList:()=>y,normalizeLibraryKey:()=>u,resolveSharedLibraries:()=>Z,sharedLibrary:()=>K});module.exports=D(nn);var l=require("./types.js"),f=require("./keys.js"),I=require("./env.js");const k="system",T="https://smbls-kv.nika-980.workers.dev",C="https://api.symbols.app";function u(n){const t=String(n||"").trim();if(!t)return{owner:k,key:"",full:""};let o=null,e=t;if(t.includes("/")){const r=t.indexOf("/");o=t.slice(0,r),e=t.slice(r+1)}e=e.replace(/\.symbo\.ls$/iu,""),o||(o=k);const s=e?`${o}/${e}`:"";return{owner:o,key:e,full:s}}const p=(n,t,o,e)=>{for(const s in t){const r=e?`${e}/${s}`:s;o&&o.has(r)||(s in n?(0,l.isObject)(n[s])&&(0,l.isObject)(t[s])&&p(n[s],t[s],o,r):n[s]=t[s])}},$=(n,t,o)=>{if(!(0,l.isObject)(n)||!t.size)return n;const e=`${o}/`;let s=!1;for(const a of t)if(a.startsWith(e)){s=!0;break}if(!s)return n;const r={};for(const a in n){if(!Object.prototype.hasOwnProperty.call(n,a))continue;const i=`${o}/${a}`;t.has(i)||(r[a]=$(n[a],t,i))}return r},N=new Set,G=new Set(["components","pages","functions","snippets","methods"]),L=(n,t)=>t===""&&G.has(n),A=["fontFamily","fontfamily","font_family","FONT_FAMILY"],W=n=>{const t=new Map;if(!(0,l.isObject)(n))return t;for(const o of A){const e=n[o];if((0,l.isObject)(e))for(const s in e)!(0,l.isObject)(e[s])||!e[s].isDefault||(t.has(o)||t.set(o,new Set),t.get(o).add(s))}return t},z=(n,t)=>{for(const o of A){const e=n[o];if(!(0,l.isObject)(e))continue;const s=t.get(o);let r=null;for(const a in e){const i=e[a];if(!(0,l.isObject)(i)||!i.isDefault||s&&s.has(a))continue;const c={...i};delete c.isDefault,r||(r={...e}),r[a]=c}r&&(n[o]=r)}},J=n=>n.replace(/\.js$/iu,""),y=n=>{const t=new Set;if(!Array.isArray(n))return t;for(const o of n){if(!(0,l.isString)(o))continue;const e=o.split("/").map(s=>J(s.trim())).filter(Boolean).join("/");e&&t.add(e)}return t},K=(n,t={})=>({library:n,ignoreList:Array.isArray(t.ignoreList)?t.ignoreList:[]}),w=n=>(0,l.isObject)(n)&&Array.isArray(n.ignoreList)&&("library"in n||"key"in n||"name"in n),S=n=>n.library!==void 0?n.library:n.key??n.name,m=new Set,Y=()=>{m.clear()},x=(n,t)=>{const o=t.filter(e=>!m.has(e));if(o.length){for(const e of o)m.add(e);(0,I.isLoudDevRuntime)()&&console.warn(`[smbls] shared library "${n}" ships ${o.map(e=>`methods.${e}`).join(", ")} \u2014 named like a built-in element method. Refused: the built-in wins; a library cannot replace an element method on the consuming app. If the app wants this version, declare it in the app's OWN methods.`)}},V=(n,t,o)=>{let e=null;for(const s in n)if((0,f.isProtectedElementMethod)(s)&&(t.has(`methods/${s}`)||o.push(s),!e)){e={};for(const r in n)(0,f.isProtectedElementMethod)(r)||(e[r]=n[r])}return e||n},q=(n,t,o,e="library")=>{const s=y(t.sharedLibIgnore);t.sharePages===!1&&s.add("pages");const r=s.size?new Set([...o,...s]):o,a=[];for(const i in t)if(Object.prototype.hasOwnProperty.call(t,i)&&!(i==="sharePages"||i==="sharedLibIgnore")&&i!=="app"&&!r.has(i)){if((0,l.isObject)(t[i])&&(0,l.isObject)(n[i])){if(i==="designSystem")p(n[i],t[i],r,i);else for(const c in t[i])if(!r.has(`${i}/${c}`)){if(i==="methods"&&(0,f.isProtectedElementMethod)(c)){c in n[i]||a.push(c);continue}c in n[i]?L(i,n[i][c])&&!L(i,t[i][c])&&(n[i][c]=t[i][c]):n[i][c]=t[i][c]}}else if(!(i in n)){const c=t[i],d=i==="methods"&&c&&typeof c=="object"?V(c,r,a):c;n[i]=$(d,r,i)}}a.length&&x(e,a)},H=(n,t,o)=>{if(n!==t){const e=S(n);if((0,l.isString)(e)&&e)return e;if(n.key||n.name)return n.key||n.name}return t&&(t.key||t.name)||`sharedLibraries[${o}]`},Q=(n,t)=>{if(!t||!t.length)return;const o=W(n.designSystem);for(let e=0;e<t.length;e++){const s=t[e];let r=s,a=N;w(r)&&(a=y(r.ignoreList),r=r.library),(0,l.isObject)(r)&&q(n,r,a,H(s,r,e))}o.size&&z(n.designSystem,o)};async function j(n,t={}){if((t.provider||"kv")==="api")return _(n,t);const e=await X(n,t);return e||_(n,t)}async function X(n,t={}){const o=t.kvBaseUrl||T,e=t.env||"production",s=`${o}/kv/${encodeURIComponent(n)}?env=${e}`;try{const r=await fetch(s,{method:"GET"});return r.ok&&(await r.json())?.value||null}catch{return null}}async function _(n,t={}){const o=t.apiBaseUrl||C,{key:e}=u(n);try{const s=`${o}/core/projects/libraries/available?search=${encodeURIComponent(e)}&limit=10`,r=await fetch(s,{method:"GET"});if(!r.ok)return null;const a=await r.json(),c=(a?.items||a?.data||(Array.isArray(a)?a:[])).find(O=>{const{key:B}=u(O?.key);return B.toLowerCase()===e.toLowerCase()});if(!c?.id&&!c?._id)return null;const d=c.id||c._id,R=`${o}/core/projects/${encodeURIComponent(d)}/data?branch=main`,b=await fetch(R,{method:"GET"});if(!b.ok)return null;const g=await b.json();return g?.data||g||null}catch{return null}}async function v(n,t={}){if((0,l.isObject)(n))return n;if((0,l.isString)(n)){const{full:o}=u(n);if(!o)return null;try{const e=await j(o,t);return e||console.warn(`[smbls] Shared library "${o}" not found`),e}catch(e){return console.warn(`[smbls] Failed to fetch shared library "${o}":`,e.message),null}}return null}async function Z(n,t={}){return!n||!n.length?[]:(await Promise.all(n.map(async e=>{if(w(e)){const s=await v(S(e),t);return s?{library:s,ignoreList:e.ignoreList}:null}return v(e,t)}))).filter(Boolean)}
@@ -1,3 +1,3 @@
1
- "use strict";var w=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var O=(e,n)=>{for(var t in n)w(e,t,{get:n[t],enumerable:!0})},I=(e,n,t,c)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of A(n))!N.call(e,s)&&s!==t&&w(e,s,{get:()=>n[s],enumerable:!(c=j(n,s))||c.enumerable});return e};var R=e=>I(w({},"__esModule",{value:!0}),e);var z={};O(z,{customDecodeURIComponent:()=>q,customEncodeURIComponent:()=>T,decodeNewlines:()=>K,encodeNewlines:()=>D,findKeyPosition:()=>v,lowercaseFirstLetter:()=>_,replaceLiteralsWithObjectFields:()=>F,replaceOctalEscapeSequences:()=>V,stringIncludesAny:()=>k,trimStringFromSymbols:()=>E});module.exports=R(z);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},x=(e,n)=>n.split(".").reduce((t,c)=>t?.[c],e);function F(e,n,t={}){const{bracketsLength:c=2}=t,s=c===3?"{{{":"{{";if(!e.includes(s))return e;const m=$[c],a=n||this.state||{},u=this;return e.replace(m,(g,d,r,i)=>{const p=r.trim();if(i){const l=u?.context,o=l?.functions?.[i]||l?.utils?.[i]||l?.methods?.[i]||l?.snippets?.[i]||u?.[i];if(o&&typeof o=="function")try{return String(o.call(u,p)??"")}catch{return""}return""}if(d){const l=(d.match(/\.\.\//g)||[]).length;let o=a;for(let f=0;f<l;f++){if(!o||!o.parent)return"";o=o.parent}if(p==="parent")return String(o.value??"");const h=x(o,p);return h!=null&&typeof h=="object"?"":String(h??"")}else{const l=x(a,p);if(l!=null&&typeof l!="object")return String(l);const o=u?.context?.polyglot;if(o?.translations){const h=a?.root?.lang||a?.lang||u?.context?.state?.lang||o.defaultLang||"en",f=o.translations[h];if(f){const C=x(f,p);if(C!=null&&typeof C!="object")return String(C);for(const L in f){const b=f[L];if(b&&typeof b=="object"&&!Array.isArray(b)){const S=x(b,p);if(S!=null&&typeof S!="object")return String(S)}}}const y=x(o.translations,p);if(y!=null&&typeof y!="object")return String(y)}return""}})}const _=e=>`${e.charAt(0).toLowerCase()}${e.slice(1)}`,v=(e,n)=>{const t=e.split(`
2
- `);let c=-1,s=-1,m=-1,a=-1;const u=new RegExp(`\\b${n}\\b\\s*:\\s*`);let g=0,d=!1;for(let r=0;r<t.length;r++)if(u.test(t[r])&&!d){if(d=!0,c=r+1,m=t[r].indexOf(n)+1,t[r].includes("{}")){s=c,a=t[r].indexOf("{}")+3;break}const i=t[r].slice(m+n.length);if(i.includes("{")||i.includes("["))g=1;else{s=r+1,a=t[r].length+1;break}}else if(d&&(g+=(t[r].match(/{/g)||[]).length,g+=(t[r].match(/\[/g)||[]).length,g-=(t[r].match(/}/g)||[]).length,g-=(t[r].match(/]/g)||[]).length,g===0)){s=r+1,a=t[r].lastIndexOf("}")!==-1?t[r].lastIndexOf("}")+2:t[r].length+1;break}return{startColumn:m,endColumn:a,startLineNumber:c,endLineNumber:s}},U=/\\([0-7]{1,3})/g,V=e=>e.replace(U,(n,t)=>String.fromCharCode(parseInt(t,8))),D=e=>e.replace(/\n/g,"/////n").replace(/`/g,"/////tilde").replace(/\$/g,"/////dlrsgn"),K=e=>e.replace(/\/\/\/\/\/n/g,`
3
- `).replace(/\/\/\/\/\/tilde/g,"`").replace(/\/\/\/\/\/dlrsgn/g,"$"),P=/[^a-zA-Z0-9\s]/g,T=e=>e.replace(P,n=>"%"+n.charCodeAt(0).toString(16).toUpperCase()),q=e=>e.replace(/%[0-9A-Fa-f]{2}/g,n=>String.fromCharCode(parseInt(n.slice(1),16)));
1
+ "use strict";var _=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var j=Object.prototype.hasOwnProperty;var N=(e,n)=>{for(var t in n)_(e,t,{get:n[t],enumerable:!0})},O=(e,n,t,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let c of L(n))!j.call(e,c)&&c!==t&&_(e,c,{get:()=>n[c],enumerable:!(s=A(n,c))||s.enumerable});return e};var R=e=>O(_({},"__esModule",{value:!0}),e);var M={};N(M,{customDecodeURIComponent:()=>z,customEncodeURIComponent:()=>q,decodeNewlines:()=>K,encodeNewlines:()=>D,findKeyPosition:()=>v,lowercaseFirstLetter:()=>T,replaceLiteralsWithObjectFields:()=>F,replaceOctalEscapeSequences:()=>V,stringIncludesAny:()=>I,trimStringFromSymbols:()=>k});module.exports=R(M);const 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,"")},E={2:/{{\s*((?:\.\.\/)*)([\w\d.]+)\s*(?:\|\s*([\w\d.]+))?\s*}}/g,3:/{{{(\s*(?:\.\.\/)*)([\w\d.]+)\s*(?:\|\s*([\w\d.]+))?\s*}}}/g},x=(e,n)=>n.split(".").reduce((t,s)=>t?.[s],e),$=(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 F(e,n,t={}){const{bracketsLength:s=2}=t,c=s===3?"{{{":"{{";if(!e.includes(c)||!$(this,e))return e;const m=E[s],a=n||this.state||{},u=this;return e.replace(m,(p,d,r,i)=>{const g=r.trim();if(i){const l=u?.context,o=l?.functions?.[i]||l?.utils?.[i]||l?.methods?.[i]||l?.snippets?.[i]||u?.[i];if(o&&typeof o=="function")try{return String(o.call(u,g)??"")}catch{return""}return""}if(d){const l=(d.match(/\.\.\//g)||[]).length;let o=a;for(let f=0;f<l;f++){if(!o||!o.parent)return"";o=o.parent}if(g==="parent")return String(o.value??"");const h=x(o,g);return h!=null&&typeof h=="object"?"":String(h??"")}else{const l=x(a,g);if(l!=null&&typeof l!="object")return String(l);const o=u?.context?.polyglot;if(o?.translations){const h=a?.root?.lang||a?.lang||u?.context?.state?.lang||o.defaultLang||"en",f=o.translations[h];if(f){const C=x(f,g);if(C!=null&&typeof C!="object")return String(C);for(const w in f){const b=f[w];if(b&&typeof b=="object"&&!Array.isArray(b)){const S=x(b,g);if(S!=null&&typeof S!="object")return String(S)}}}const y=x(o.translations,g);if(y!=null&&typeof y!="object")return String(y)}return""}})}const T=e=>`${e.charAt(0).toLowerCase()}${e.slice(1)}`,v=(e,n)=>{const t=e.split(`
2
+ `);let s=-1,c=-1,m=-1,a=-1;const u=new RegExp(`\\b${n}\\b\\s*:\\s*`);let p=0,d=!1;for(let r=0;r<t.length;r++)if(u.test(t[r])&&!d){if(d=!0,s=r+1,m=t[r].indexOf(n)+1,t[r].includes("{}")){c=s,a=t[r].indexOf("{}")+3;break}const i=t[r].slice(m+n.length);if(i.includes("{")||i.includes("["))p=1;else{c=r+1,a=t[r].length+1;break}}else if(d&&(p+=(t[r].match(/{/g)||[]).length,p+=(t[r].match(/\[/g)||[]).length,p-=(t[r].match(/}/g)||[]).length,p-=(t[r].match(/]/g)||[]).length,p===0)){c=r+1,a=t[r].lastIndexOf("}")!==-1?t[r].lastIndexOf("}")+2:t[r].length+1;break}return{startColumn:m,endColumn:a,startLineNumber:s,endLineNumber:c}},U=/\\([0-7]{1,3})/g,V=e=>e.replace(U,(n,t)=>String.fromCharCode(parseInt(t,8))),D=e=>e.replace(/\n/g,"/////n").replace(/`/g,"/////tilde").replace(/\$/g,"/////dlrsgn"),K=e=>e.replace(/\/\/\/\/\/n/g,`
3
+ `).replace(/\/\/\/\/\/tilde/g,"`").replace(/\/\/\/\/\/dlrsgn/g,"$"),P=/[^a-zA-Z0-9\s]/g,q=e=>e.replace(P,n=>"%"+n.charCodeAt(0).toString(16).toUpperCase()),z=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 n=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"]),a=["ref","parent","__element","__depends","__ref","__children","root"],e=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"]),t=new Set(["update","__element"]),o=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"]),s=new Set(["node","context","extends","__element","__ref",...o,...e,...t]),p=new Set(["init","beforeClassAssign","render","renderRouter","attachNode","stateInit","stateCreated","beforeStateUpdate","stateUpdate","beforeUpdate","done","create","complete","frame","update","fetchError","fetchComplete"]);export{p as DOMQL_EVENTS,n as DOMQ_PROPERTIES,o as METHODS,s as METHODS_EXL,r as PARSED_DOMQ_PROPERTIES,t as PROPS_METHODS,e as STATE_METHODS,a as STATE_PROPERTIES};
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,10 +1,10 @@
1
- import{triggerEventOn as m}from"./triggerEvent.js";import{DOMQ_PROPERTIES as R,METHODS as $,PARSED_DOMQ_PROPERTIES as k}from"./keys.js";import{isDefined as E,isFunction as p,isObject as P,isObjectLike as x}from"./types.js";import{deepClone as A,isFailedRevival as b}from"./object.js";import{isProduction as C}from"./env.js";import{removeValueFromArray as j}from"./array.js";import{OPTIONS as Q}from"./cache.js";const a="production";function X(e){const t=this,{__ref:n}=t,o=[].concat(e);let r=n.root[o[0]];if(!o||!o.length)return console.log(o,"on",t.key,"is undefined");for(;r.key===o[0]&&(o.shift(),!!o.length);)if(r=r[o[0]],!r)return;return r}function q(e){const t=this;let{parent:n}=t;if(p(e))return n.state&&e(n,n.state,n.context)?n:n.parent?n.lookup(e):void 0;if(t[e])return t[e];for(;n.param!==e;){if(n[e])return n[e];if(n=n.parent,!n)return}return n}function tt(e){const t=this,{__ref:n}=t,o=n?.__children;if(o)for(let r=0;r<o.length;r++){const s=o[r],i=t[s];if(s===e)return i;if(p(e)){const l=e(i,i.state,i.context);if(i.state&&l)return i}const c=i?.lookdown?.(e);if(c)return c}}function et(e,t=[]){const n=this,{__ref:o}=n,r=o?.__children;if(r){for(let s=0;s<r.length;s++){const i=r[s],c=n[i];if(i===e)t.push(c);else if(p(e)){const l=e(c,c.state,c.context);c.state&&l&&t.push(c)}c?.lookdownAll?.(e,t)}return t.length?t:void 0}}function N(e={}){const t=this;if(t.node?.style){for(const n in e){const o=e[n],r=t[n];if(P(o)&&r)N.call(r,o);else if(o!=null){const s=n.replace(/[A-Z]/g,c=>"-"+c.toLowerCase()),i=String(o).replace(/\s*!important\s*$/,"");t.node.style.setProperty(s,i,"important")}}return t}}function nt(e){const t=this;if(m("beforeRemove",t,e)===!1)return t;p(t.node.remove)?t.node.remove():C()||(console.warn("This item cant be removed"),t.log()),delete t.parent[t.key],t.parent.__ref&&(t.parent.__ref.__children=j(t.parent.__ref.__children,t.key)),m("remove",t,e)}function ot(e){return this[e]}function rt(e,t){const n=this;if(e)return n.update(e,t),n}function st(e){return e?this.__ref&&this.__ref[e]:this.__ref}function it(){const e=this.getRef("__children");return Array.isArray(e)?e.map(t=>this[t]):[]}function ct(){return this.getRef().path}let y=null;const lt=e=>{y=e||null},v=()=>y||null;function ft(e){let t=null;const n=o=>o.__element&&o.root?.isRootState;if(!this)t=v();else if(n(this))t=this.root;else if(this.__ref&&this.__ref.path){const o=this.state&&n(this.state),r=p(this.state)&&this.parent.state&&n(this.parent.state);(o||r)&&(t=this.state.root||this.parent.state.root)}return t||(t=v()),e?t?.[e]:t}function ut(e){const t=this?.__ref?.root||this.getRootState()?.__element;if(!t)throw new Error(`[smbls] getRoot() could not resolve a root element for "${this?.key||"<unknown>"}" \u2014 it has no __ref (never went through create()) and no root state is registered. Answering undefined here used to no-op silently for every caller.`);return Object.keys(t).length>0&&e?t[e]:t}function at(e){return this.getRoot("data")&&Object.keys(this.getRoot("data")).length>0&&e?this.getRoot("data")[e]:this.getRoot("data")}function ht(e){const t=this.getRoot()?.context;return e?t[e]:t}function pt(e){const t=this.context;return e?t[e]:t}const dt=(e,t,n,o)=>Object.defineProperty(e,t,{get:n,set:o});function D(){const e=this,t=[];for(const n in e)!Object.prototype.hasOwnProperty.call(e,n)||R.has(n)&&!k.has(n)||t.push(n);return t}function T(e=[]){const t=this,n={},o=D.call(t),r=o.includes("children"),s=e.length?new Set(e):null;for(let i=0;i<o.length;i++){const c=o[i];if(s&&s.has(c)||!Object.prototype.hasOwnProperty.call(t,c)||r&&c==="content")continue;const l=t[c];if(c==="state"){if(t.__ref&&!t.__ref.__hasRootState)continue;const f=p(l&&l.parse)?l.parse():l;n[c]=p(f)?f:JSON.parse(JSON.stringify(f||{}))}else if(c==="scope"){if(t.__ref&&!t.__ref.__hasRootScope)continue;n[c]=JSON.parse(JSON.stringify(l||{}))}else if(c==="props"){const{__element:f,update:u,...h}=t[c];n[c]=h}else E(l)&&Object.prototype.hasOwnProperty.call(t,c)&&(n[c]=l)}return n}function w(e=[],t=new WeakSet){const n=this;if(t.has(n))return;t.add(n);const o=T.call(n,e),r=e.length?new Set(e):null;for(const s in o){if(r&&r.has(s)||!Object.prototype.hasOwnProperty.call(n,s))continue;const i=o[s];Array.isArray(i)?o[s]=i.map(c=>x(c)?w.call(c,e,t):c):x(i)&&(o[s]=w.call(i,e,t))}return o}function F(...e){if(a!=="test"&&a!=="development")return;const t=this,{__ref:n}=t;return console.groupCollapsed(t.key),e.length?e.forEach(o=>console.log(`%c${o}:
2
- `,"font-weight: bold",t[o])):(console.log(n.path),t.keys().forEach(r=>console.log(`%c${r}:`,"font-weight: bold",t[r]))),console.log(t),console.groupEnd(t.key),t}function _t(...e){(a==="test"||a==="development")&&console.log(...e)}function gt(...e){(a==="test"||a==="development")&&console.warn(...e)}function S(...e){if(a==="test"||a==="development"){if(e[e.length-1]?.debugger)debugger;throw e[e.length-1]?.verbose&&F.call(this),new Error(...e)}}function mt(){const e=this,{key:t,parent:n}=e,{__children:o}=n.__ref,r=o.indexOf(t),s=o[r+1];return n[s]}function xt(e){const t=e||this,{key:n,parent:o}=t,{__children:r}=o.__ref;if(!r)return;const s=r.indexOf(n);return o[r[s-1]]}function yt(e={}){const t=this;t.data||(t.data={}),t.data.varCaches||(t.data.varCaches={});const n=t.data.varCaches,o={};let r;for(const s in e)e[s]!==n[s]&&(r=!0,o[s]=e[s]);return{changed:s=>{if(!r)return;const i=s(o,A(n));for(const c in o)n[c]=o[c];return i},timeout:(s,i)=>{if(!r)return;const c=setTimeout(()=>{s(o),clearTimeout(c)},i)}}}function vt(e,...t){const n=this.context,o=n.utils?.[e]||n.functions?.[e]||n.methods?.[e]||n.snippets?.[e];if(o&&!b(o))try{const r=o.call(this,...t);return r&&typeof r.then=="function"&&r.catch(s=>{S.call(this,s)}),r}catch(r){if(S.call(this,r),n?.strictMode)throw r}}async function wt(){const e=this,t=e.context?.fetch;if(!t)return null;if(typeof t.select=="function"){if(!t.__authInitialized&&t.getSession){const{initAdapterAuth:r}=await import("@symbo.ls/fetch");await r(t,e.context)}return t}if(t.__resolved){if(!t.__resolved.__authInitialized&&t.__resolved.getSession){const{initAdapterAuth:r}=await import("@symbo.ls/fetch");await r(t.__resolved,e.context)}return t.__resolved}if(t.__resolving)return t.__resolving;const n=import("@symbo.ls/fetch").then(({resolveDb:r})=>r(t));t.__resolving=n;const o=await n;if(t.__resolved=o,e.context.fetch=o,delete t.__resolving,o?.getSession){const{initAdapterAuth:r}=await import("@symbo.ls/fetch");await r(o,e.context)}return o}function St(e){const t=this,n=e||Q.useStateQuery||t.context?.useStateQuery;if(!n)return null;const o={};if(g(t,o),n===!0)return o;const r=z[n];return r?r(o):o}const g=(e,t)=>{const n=e.__ref;if(!n)return;const o=n.__state;o&&typeof o=="string"&&I(t,o);const r=n.__children;if(r)for(let c=0;c<r.length;c++){const l=e[r[c]];l&&l.__ref&&g(l,t)}const s=n.contentElementKey||"content",i=e[s];i&&i.__ref&&g(i,t)},I=(e,t)=>{const o=t.replaceAll("../","").replaceAll("~/","").split("/");let r=e;for(let s=0;s<o.length;s++){const i=o[s];s===o.length-1?r[i]||(r[i]=!0):(r[i]===!0&&(r[i]={}),r[i]||(r[i]={}),r=r[i])}},O=(e,t=0)=>{const n=" ".repeat(t),o=Object.entries(e);return o.length?o.map(([s,i])=>i===!0?`${n}${s}`:`${n}${s} {
3
- ${O(i,t+1)}
1
+ import{triggerEventOn as y}from"./triggerEvent.js";import{DOMQ_PROPERTIES as $,METHODS as k,PARSED_DOMQ_PROPERTIES as E}from"./keys.js";import{isDefined as P,isFunction as p,isObject as A,isObjectLike as v}from"./types.js";import{deepClone as b,isFailedRevival as C}from"./object.js";import{isProduction as N}from"./env.js";import{removeValueFromArray as j}from"./array.js";import{OPTIONS as Q}from"./cache.js";const a="production";function tt(e){const t=this,{__ref:n}=t,o=[].concat(e);let r=n.root[o[0]];if(!o||!o.length)return console.log(o,"on",t.key,"is undefined");for(;r.key===o[0]&&(o.shift(),!!o.length);)if(r=r[o[0]],!r)return;return r}function et(e){const t=this;let{parent:n}=t;if(p(e))return n.state&&e(n,n.state,n.context)?n:n.parent?n.lookup(e):void 0;if(t[e])return t[e];for(;n.param!==e;){if(n[e])return n[e];if(n=n.parent,!n)return}return n}function nt(e){const t=this,{__ref:n}=t,o=n?.__children;if(o)for(let r=0;r<o.length;r++){const s=o[r],i=t[s];if(s===e)return i;if(p(e)){const l=e(i,i.state,i.context);if(i.state&&l)return i}const c=i?.lookdown?.(e);if(c)return c}}function ot(e,t=[]){const n=this,{__ref:o}=n,r=o?.__children;if(r){for(let s=0;s<r.length;s++){const i=r[s],c=n[i];if(i===e)t.push(c);else if(p(e)){const l=e(c,c.state,c.context);c.state&&l&&t.push(c)}c?.lookdownAll?.(e,t)}return t.length?t:void 0}}function D(e={}){const t=this;if(t.node?.style){for(const n in e){const o=e[n],r=t[n];if(A(o)&&r)D.call(r,o);else if(o!=null){const s=n.replace(/[A-Z]/g,c=>"-"+c.toLowerCase()),i=String(o).replace(/\s*!important\s*$/,"");t.node.style.setProperty(s,i,"important")}}return t}}function rt(e){const t=this;if(y("beforeRemove",t,e)===!1)return t;p(t.node.remove)?t.node.remove():N()||(console.warn("This item cant be removed"),t.log()),delete t.parent[t.key],t.parent.__ref&&(t.parent.__ref.__children=j(t.parent.__ref.__children,t.key)),y("remove",t,e)}function st(e){return this[e]}function it(e,t){const n=this;if(e)return n.update(e,t),n}function ct(e){return e?this.__ref&&this.__ref[e]:this.__ref}function lt(){const e=this.getRef("__children");return Array.isArray(e)?e.map(t=>this[t]):[]}function ft(){return this.getRef().path}let _=null;const ut=e=>{_=e||null},at=(e,t)=>{e&&t&&_===e&&(_=t)},S=()=>_||null;function ht(e){let t=null;const n=o=>o.__element&&o.root?.isRootState;if(!this)t=S();else if(n(this))t=this.root;else if(this.__ref&&this.__ref.path){const o=this.state&&n(this.state),r=p(this.state)&&this.parent.state&&n(this.parent.state);(o||r)&&(t=this.state.root||this.parent.state.root)}return t||(t=S()),e?t?.[e]:t}function pt(e){const t=this?.__ref?.root||this.getRootState()?.__element;if(!t)throw new Error(`[smbls] getRoot() could not resolve a root element for "${this?.key||"<unknown>"}" \u2014 it has no __ref (never went through create()) and no root state is registered. Answering undefined here used to no-op silently for every caller.`);return Object.keys(t).length>0&&e?t[e]:t}function dt(e){return this.getRoot("data")&&Object.keys(this.getRoot("data")).length>0&&e?this.getRoot("data")[e]:this.getRoot("data")}function _t(e){const t=this.getRoot()?.context;return e?t[e]:t}function gt(e){const t=this.context;return e?t[e]:t}const mt=(e,t,n,o)=>Object.defineProperty(e,t,{get:n,set:o});function I(){const e=this,t=[];for(const n in e)!Object.prototype.hasOwnProperty.call(e,n)||$.has(n)&&!E.has(n)||t.push(n);return t}function T(e=[]){const t=this,n={},o=I.call(t),r=o.includes("children"),s=e.length?new Set(e):null;for(let i=0;i<o.length;i++){const c=o[i];if(s&&s.has(c)||!Object.prototype.hasOwnProperty.call(t,c)||r&&c==="content")continue;const l=t[c];if(c==="state"){if(t.__ref&&!t.__ref.__hasRootState)continue;const f=p(l&&l.parse)?l.parse():l;n[c]=p(f)?f:JSON.parse(JSON.stringify(f||{}))}else if(c==="scope"){if(t.__ref&&!t.__ref.__hasRootScope)continue;n[c]=JSON.parse(JSON.stringify(l||{}))}else if(c==="props"){const{__element:f,update:u,...h}=t[c];n[c]=h}else P(l)&&Object.prototype.hasOwnProperty.call(t,c)&&(n[c]=l)}return n}function w(e=[],t=new WeakSet){const n=this;if(t.has(n))return;t.add(n);const o=T.call(n,e),r=e.length?new Set(e):null;for(const s in o){if(r&&r.has(s)||!Object.prototype.hasOwnProperty.call(n,s))continue;const i=o[s];Array.isArray(i)?o[s]=i.map(c=>v(c)?w.call(c,e,t):c):v(i)&&(o[s]=w.call(i,e,t))}return o}function F(...e){if(a!=="test"&&a!=="development")return;const t=this,{__ref:n}=t;return console.groupCollapsed(t.key),e.length?e.forEach(o=>console.log(`%c${o}:
2
+ `,"font-weight: bold",t[o])):(console.log(n.path),t.keys().forEach(r=>console.log(`%c${r}:`,"font-weight: bold",t[r]))),console.log(t),console.groupEnd(t.key),t}function xt(...e){(a==="test"||a==="development")&&console.log(...e)}function yt(...e){(a==="test"||a==="development")&&console.warn(...e)}function O(...e){if(a==="test"||a==="development"){if(e[e.length-1]?.debugger)debugger;throw e[e.length-1]?.verbose&&F.call(this),new Error(...e)}}function vt(){const e=this,{key:t,parent:n}=e,{__children:o}=n.__ref,r=o.indexOf(t),s=o[r+1];return n[s]}function St(e){const t=e||this,{key:n,parent:o}=t,{__children:r}=o.__ref;if(!r)return;const s=r.indexOf(n);return o[r[s-1]]}function wt(e={}){const t=this;t.data||(t.data={}),t.data.varCaches||(t.data.varCaches={});const n=t.data.varCaches,o={};let r;for(const s in e)e[s]!==n[s]&&(r=!0,o[s]=e[s]);return{changed:s=>{if(!r)return;const i=s(o,b(n));for(const c in o)n[c]=o[c];return i},timeout:(s,i)=>{if(!r)return;const c=setTimeout(()=>{s(o),clearTimeout(c)},i)}}}function Ot(e,...t){const n=this.context,o=n.utils?.[e]||n.functions?.[e]||n.methods?.[e]||n.snippets?.[e];if(o&&!C(o))try{const r=o.call(this,...t);return r&&typeof r.then=="function"&&r.catch(s=>{O.call(this,s)}),r}catch(r){if(O.call(this,r),n?.strictMode)throw r}}const L="[smbls] getDB needs @symbo.ls/fetch, which the smbls embed bundle does not include: add @symbo.ls/fetch to the page's importmap (the runtime import then resolves) or use the full smbls bundle.",g=()=>import("@symbo.ls/fetch").catch(e=>{throw new Error(L,{cause:e})});async function Rt(){const e=this,t=e.context?.fetch;if(!t)return null;if(typeof t.select=="function"){if(!t.__authInitialized&&t.getSession){const{initAdapterAuth:r}=await g();await r(t,e.context)}return t}if(t.__resolved){if(!t.__resolved.__authInitialized&&t.__resolved.getSession){const{initAdapterAuth:r}=await g();await r(t.__resolved,e.context)}return t.__resolved}if(t.__resolving)return t.__resolving;const n=g().then(({resolveDb:r})=>r(t));t.__resolving=n;const o=await n;if(t.__resolved=o,e.context.fetch=o,delete t.__resolving,o?.getSession){const{initAdapterAuth:r}=await g();await r(o,e.context)}return o}function $t(e){const t=this,n=e||Q.useStateQuery||t.context?.useStateQuery;if(!n)return null;const o={};if(x(t,o),n===!0)return o;const r=H[n];return r?r(o):o}const x=(e,t)=>{const n=e.__ref;if(!n)return;const o=n.__state;o&&typeof o=="string"&&M(t,o);const r=n.__children;if(r)for(let c=0;c<r.length;c++){const l=e[r[c]];l&&l.__ref&&x(l,t)}const s=n.contentElementKey||"content",i=e[s];i&&i.__ref&&x(i,t)},M=(e,t)=>{const o=t.replaceAll("../","").replaceAll("~/","").split("/");let r=e;for(let s=0;s<o.length;s++){const i=o[s];s===o.length-1?r[i]||(r[i]=!0):(r[i]===!0&&(r[i]={}),r[i]||(r[i]={}),r=r[i])}},R=(e,t=0)=>{const n=" ".repeat(t),o=Object.entries(e);return o.length?o.map(([s,i])=>i===!0?`${n}${s}`:`${n}${s} {
3
+ ${R(i,t+1)}
4
4
  ${n}}`).join(`
5
- `):""},L=e=>`{
6
- ${O(e,1)}
7
- }`,M=e=>{const t={fields:{},include:[]},n=(o,r)=>{const s=[];for(const i in o)if(o[i]===!0)s.push(i);else{const c=r?`${r}.${i}`:i;t.include.push(c),n(o[i],c)}s.length&&(t.fields[r||"_root"]=s)};return n(e,""),t},J=e=>{const t=s=>{const i=[],c=[];for(const l in s)if(s[l]===!0)i.push(l);else{const f=t(s[l]),u=[];f.select&&u.push(`$select=${f.select}`),f.expand&&u.push(`$expand=${f.expand}`),c.push(u.length?`${l}(${u.join(";")})`:l)}return{select:i.length?i.join(","):"",expand:c.length?c.join(","):""}},{select:n,expand:o}=t(e),r=[];return n&&r.push(`$select=${n}`),o&&r.push(`$expand=${o}`),r.join("&")},V=(e,t)=>{const n=[],o=[],r=new Set,s=(u,h,_)=>{r.add(h),_&&o.push(`LEFT JOIN ${h} ON ${h}.${_}_id = ${_}.id`);for(const d in u)u[d]===!0?n.push(`${h}.${d}`):s(u[d],d,h)},i=Object.keys(e);i.length===1&&e[i[0]]!==!0?s(e[i[0]],i[0],null):s(e,"_root",null);const c=[...r][0]||"_root",l=n.length?n.join(", "):"*",f=o.length?`
5
+ `):""},J=e=>`{
6
+ ${R(e,1)}
7
+ }`,G=e=>{const t={fields:{},include:[]},n=(o,r)=>{const s=[];for(const i in o)if(o[i]===!0)s.push(i);else{const c=r?`${r}.${i}`:i;t.include.push(c),n(o[i],c)}s.length&&(t.fields[r||"_root"]=s)};return n(e,""),t},B=e=>{const t=s=>{const i=[],c=[];for(const l in s)if(s[l]===!0)i.push(l);else{const f=t(s[l]),u=[];f.select&&u.push(`$select=${f.select}`),f.expand&&u.push(`$expand=${f.expand}`),c.push(u.length?`${l}(${u.join(";")})`:l)}return{select:i.length?i.join(","):"",expand:c.length?c.join(","):""}},{select:n,expand:o}=t(e),r=[];return n&&r.push(`$select=${n}`),o&&r.push(`$expand=${o}`),r.join("&")},V=(e,t)=>{const n=[],o=[],r=new Set,s=(u,h,m)=>{r.add(h),m&&o.push(`LEFT JOIN ${h} ON ${h}.${m}_id = ${m}.id`);for(const d in u)u[d]===!0?n.push(`${h}.${d}`):s(u[d],d,h)},i=Object.keys(e);i.length===1&&e[i[0]]!==!0?s(e[i[0]],i[0],null):s(e,"_root",null);const c=[...r][0]||"_root",l=n.length?n.join(", "):"*",f=o.length?`
8
8
  `+o.join(`
9
9
  `):"";return`SELECT ${l}
10
- FROM ${c}${f}`},B=e=>{const t=[],n=(o,r)=>{for(const s in o){const i=r?`${r}/${s}`:s;o[s]===!0?t.push(i):n(o[s],i)}};return n(e,""),t},z={graphql:L,"json-api":M,odata:J,sql:V,paths:B};function Ot(e,t){return!!($.has(e)||t?.context?.methods?.[e])}export{vt as call,dt as defineSetter,S as error,ot as get,it as getChildren,pt as getContext,wt as getDB,ct as getPath,St as getQuery,st as getRef,ut as getRoot,ht as getRootContext,at as getRootData,ft as getRootState,Ot as isMethod,D as keys,_t as log,tt as lookdown,et as lookdownAll,q as lookup,mt as nextElement,T as parse,w as parseDeep,xt as previousElement,nt as remove,lt as setActiveRootState,N as setNodeStyles,rt as setProps,X as spotByPath,yt as variables,F as verbose,gt as warn};
10
+ FROM ${c}${f}`},z=e=>{const t=[],n=(o,r)=>{for(const s in o){const i=r?`${r}/${s}`:s;o[s]===!0?t.push(i):n(o[s],i)}};return n(e,""),t},H={graphql:J,"json-api":G,odata:B,sql:V,paths:z};function kt(e,t){return!!(k.has(e)||t?.context?.methods?.[e])}export{Ot as call,mt as defineSetter,O as error,st as get,lt as getChildren,gt as getContext,Rt as getDB,ft as getPath,$t as getQuery,ct as getRef,pt as getRoot,_t as getRootContext,dt as getRootData,ht as getRootState,kt as isMethod,I as keys,xt as log,nt as lookdown,ot as lookdownAll,et as lookup,vt as nextElement,T as parse,w as parseDeep,St as previousElement,at as promoteActiveRootState,rt as remove,ut as setActiveRootState,D as setNodeStyles,it as setProps,tt as spotByPath,wt as variables,F as verbose,yt as warn};
@@ -1 +1 @@
1
- import{isObject as a,isString as y}from"./types.js";const m="system",v="https://smbls-kv.nika-980.workers.dev",O="https://api.symbols.app";function f(n){const t=String(n||"").trim();if(!t)return{owner:m,key:"",full:""};let r=null,e=t;if(t.includes("/")){const o=t.indexOf("/");r=t.slice(0,o),e=t.slice(o+1)}e=e.replace(/\.symbo\.ls$/iu,""),r||(r=m);const s=e?`${r}/${e}`:"";return{owner:r,key:e,full:s}}const d=(n,t,r,e)=>{for(const s in t){const o=e?`${e}/${s}`:s;r&&r.has(o)||(s in n?a(n[s])&&a(t[s])&&d(n[s],t[s],r,o):n[s]=t[s])}},h=(n,t,r)=>{if(!a(n)||!t.size)return n;const e=`${r}/`;let s=!1;for(const i of t)if(i.startsWith(e)){s=!0;break}if(!s)return n;const o={};for(const i in n){if(!Object.prototype.hasOwnProperty.call(n,i))continue;const c=`${r}/${i}`;t.has(c)||(o[i]=h(n[i],t,c))}return o},j=new Set,F=new Set(["components","pages","functions","snippets","methods"]),b=(n,t)=>t===""&&F.has(n),w=["fontFamily","fontfamily","font_family","FONT_FAMILY"],R=n=>{const t=new Map;if(!a(n))return t;for(const r of w){const e=n[r];if(a(e))for(const s in e)!a(e[s])||!e[s].isDefault||(t.has(r)||t.set(r,new Set),t.get(r).add(s))}return t},U=(n,t)=>{for(const r of w){const e=n[r];if(!a(e))continue;const s=t.get(r);let o=null;for(const i in e){const c=e[i];if(!a(c)||!c.isDefault||s&&s.has(i))continue;const l={...c};delete l.isDefault,o||(o={...e}),o[i]=l}o&&(n[r]=o)}},E=n=>n.replace(/\.js$/iu,""),g=n=>{const t=new Set;if(!Array.isArray(n))return t;for(const r of n){if(!y(r))continue;const e=r.split("/").map(s=>E(s.trim())).filter(Boolean).join("/");e&&t.add(e)}return t},G=(n,t={})=>({library:n,ignoreList:Array.isArray(t.ignoreList)?t.ignoreList:[]}),k=n=>a(n)&&Array.isArray(n.ignoreList)&&("library"in n||"key"in n||"name"in n),B=n=>n.library!==void 0?n.library:n.key??n.name,P=(n,t,r)=>{const e=g(t.sharedLibIgnore);t.sharePages===!1&&e.add("pages");const s=e.size?new Set([...r,...e]):r;for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&!(o==="sharePages"||o==="sharedLibIgnore")&&o!=="app"&&!s.has(o))if(a(t[o])&&a(n[o]))if(o==="designSystem")d(n[o],t[o],s,o);else for(const i in t[o])s.has(`${o}/${i}`)||(i in n[o]?b(o,n[o][i])&&!b(o,t[o][i])&&(n[o][i]=t[o][i]):n[o][i]=t[o][i]);else o in n||(n[o]=h(t[o],s,o))},N=(n,t)=>{if(!t||!t.length)return;const r=R(n.designSystem);for(let e=0;e<t.length;e++){let s=t[e],o=j;k(s)&&(o=g(s.ignoreList),s=s.library),a(s)&&P(n,s,o)}r.size&&U(n.designSystem,r)};async function D(n,t={}){if((t.provider||"kv")==="api")return L(n,t);const e=await T(n,t);return e||L(n,t)}async function T(n,t={}){const r=t.kvBaseUrl||v,e=t.env||"production",s=`${r}/kv/${encodeURIComponent(n)}?env=${e}`;try{const o=await fetch(s,{method:"GET"});return o.ok&&(await o.json())?.value||null}catch{return null}}async function L(n,t={}){const r=t.apiBaseUrl||O,{key:e}=f(n);try{const s=`${r}/core/projects/libraries/available?search=${encodeURIComponent(e)}&limit=10`,o=await fetch(s,{method:"GET"});if(!o.ok)return null;const i=await o.json(),l=(i?.items||i?.data||(Array.isArray(i)?i:[])).find(I=>{const{key:_}=f(I?.key);return _.toLowerCase()===e.toLowerCase()});if(!l?.id&&!l?._id)return null;const A=l.id||l._id,S=`${r}/core/projects/${encodeURIComponent(A)}/data?branch=main`,u=await fetch(S,{method:"GET"});if(!u.ok)return null;const p=await u.json();return p?.data||p||null}catch{return null}}async function $(n,t={}){if(a(n))return n;if(y(n)){const{full:r}=f(n);if(!r)return null;try{const e=await D(r,t);return e||console.warn(`[smbls] Shared library "${r}" not found`),e}catch(e){return console.warn(`[smbls] Failed to fetch shared library "${r}":`,e.message),null}}return null}async function z(n,t={}){return!n||!n.length?[]:(await Promise.all(n.map(async e=>{if(k(e)){const s=await $(B(e),t);return s?{library:s,ignoreList:e.ignoreList}:null}return $(e,t)}))).filter(Boolean)}export{d as deepDefaults,D as fetchLibraryData,k as isWrappedLibrary,N as mergeSharedLibraries,g as normalizeIgnoreList,f as normalizeLibraryKey,z as resolveSharedLibraries,G as sharedLibrary};
1
+ import{isObject as l,isString as u}from"./types.js";import{isProtectedElementMethod as d}from"./keys.js";import{isLoudDevRuntime as O}from"./env.js";const w="system",B="https://smbls-kv.nika-980.workers.dev",E="https://api.symbols.app";function h(n){const t=String(n||"").trim();if(!t)return{owner:w,key:"",full:""};let o=null,e=t;if(t.includes("/")){const r=t.indexOf("/");o=t.slice(0,r),e=t.slice(r+1)}e=e.replace(/\.symbo\.ls$/iu,""),o||(o=w);const s=e?`${o}/${e}`:"";return{owner:o,key:e,full:s}}const b=(n,t,o,e)=>{for(const s in t){const r=e?`${e}/${s}`:s;o&&o.has(r)||(s in n?l(n[s])&&l(t[s])&&b(n[s],t[s],o,r):n[s]=t[s])}},g=(n,t,o)=>{if(!l(n)||!t.size)return n;const e=`${o}/`;let s=!1;for(const a of t)if(a.startsWith(e)){s=!0;break}if(!s)return n;const r={};for(const a in n){if(!Object.prototype.hasOwnProperty.call(n,a))continue;const i=`${o}/${a}`;t.has(i)||(r[a]=g(n[a],t,i))}return r},F=new Set,U=new Set(["components","pages","functions","snippets","methods"]),k=(n,t)=>t===""&&U.has(n),$=["fontFamily","fontfamily","font_family","FONT_FAMILY"],P=n=>{const t=new Map;if(!l(n))return t;for(const o of $){const e=n[o];if(l(e))for(const s in e)!l(e[s])||!e[s].isDefault||(t.has(o)||t.set(o,new Set),t.get(o).add(s))}return t},M=(n,t)=>{for(const o of $){const e=n[o];if(!l(e))continue;const s=t.get(o);let r=null;for(const a in e){const i=e[a];if(!l(i)||!i.isDefault||s&&s.has(a))continue;const c={...i};delete c.isDefault,r||(r={...e}),r[a]=c}r&&(n[o]=r)}},D=n=>n.replace(/\.js$/iu,""),L=n=>{const t=new Set;if(!Array.isArray(n))return t;for(const o of n){if(!u(o))continue;const e=o.split("/").map(s=>D(s.trim())).filter(Boolean).join("/");e&&t.add(e)}return t},x=(n,t={})=>({library:n,ignoreList:Array.isArray(t.ignoreList)?t.ignoreList:[]}),A=n=>l(n)&&Array.isArray(n.ignoreList)&&("library"in n||"key"in n||"name"in n),S=n=>n.library!==void 0?n.library:n.key??n.name,m=new Set,V=()=>{m.clear()},T=(n,t)=>{const o=t.filter(e=>!m.has(e));if(o.length){for(const e of o)m.add(e);O()&&console.warn(`[smbls] shared library "${n}" ships ${o.map(e=>`methods.${e}`).join(", ")} \u2014 named like a built-in element method. Refused: the built-in wins; a library cannot replace an element method on the consuming app. If the app wants this version, declare it in the app's OWN methods.`)}},C=(n,t,o)=>{let e=null;for(const s in n)if(d(s)&&(t.has(`methods/${s}`)||o.push(s),!e)){e={};for(const r in n)d(r)||(e[r]=n[r])}return e||n},N=(n,t,o,e="library")=>{const s=L(t.sharedLibIgnore);t.sharePages===!1&&s.add("pages");const r=s.size?new Set([...o,...s]):o,a=[];for(const i in t)if(Object.prototype.hasOwnProperty.call(t,i)&&!(i==="sharePages"||i==="sharedLibIgnore")&&i!=="app"&&!r.has(i)){if(l(t[i])&&l(n[i])){if(i==="designSystem")b(n[i],t[i],r,i);else for(const c in t[i])if(!r.has(`${i}/${c}`)){if(i==="methods"&&d(c)){c in n[i]||a.push(c);continue}c in n[i]?k(i,n[i][c])&&!k(i,t[i][c])&&(n[i][c]=t[i][c]):n[i][c]=t[i][c]}}else if(!(i in n)){const c=t[i],f=i==="methods"&&c&&typeof c=="object"?C(c,r,a):c;n[i]=g(f,r,i)}}a.length&&T(e,a)},G=(n,t,o)=>{if(n!==t){const e=S(n);if(u(e)&&e)return e;if(n.key||n.name)return n.key||n.name}return t&&(t.key||t.name)||`sharedLibraries[${o}]`},q=(n,t)=>{if(!t||!t.length)return;const o=P(n.designSystem);for(let e=0;e<t.length;e++){const s=t[e];let r=s,a=F;A(r)&&(a=L(r.ignoreList),r=r.library),l(r)&&N(n,r,a,G(s,r,e))}o.size&&M(n.designSystem,o)};async function W(n,t={}){if((t.provider||"kv")==="api")return _(n,t);const e=await z(n,t);return e||_(n,t)}async function z(n,t={}){const o=t.kvBaseUrl||B,e=t.env||"production",s=`${o}/kv/${encodeURIComponent(n)}?env=${e}`;try{const r=await fetch(s,{method:"GET"});return r.ok&&(await r.json())?.value||null}catch{return null}}async function _(n,t={}){const o=t.apiBaseUrl||E,{key:e}=h(n);try{const s=`${o}/core/projects/libraries/available?search=${encodeURIComponent(e)}&limit=10`,r=await fetch(s,{method:"GET"});if(!r.ok)return null;const a=await r.json(),c=(a?.items||a?.data||(Array.isArray(a)?a:[])).find(j=>{const{key:R}=h(j?.key);return R.toLowerCase()===e.toLowerCase()});if(!c?.id&&!c?._id)return null;const f=c.id||c._id,I=`${o}/core/projects/${encodeURIComponent(f)}/data?branch=main`,p=await fetch(I,{method:"GET"});if(!p.ok)return null;const y=await p.json();return y?.data||y||null}catch{return null}}async function v(n,t={}){if(l(n))return n;if(u(n)){const{full:o}=h(n);if(!o)return null;try{const e=await W(o,t);return e||console.warn(`[smbls] Shared library "${o}" not found`),e}catch(e){return console.warn(`[smbls] Failed to fetch shared library "${o}":`,e.message),null}}return null}async function H(n,t={}){return!n||!n.length?[]:(await Promise.all(n.map(async e=>{if(A(e)){const s=await v(S(e),t);return s?{library:s,ignoreList:e.ignoreList}:null}return v(e,t)}))).filter(Boolean)}export{V as __resetBuiltinMethodWarnings,b as deepDefaults,W as fetchLibraryData,A as isWrappedLibrary,q as mergeSharedLibraries,L as normalizeIgnoreList,h as normalizeLibraryKey,H as resolveSharedLibraries,x as sharedLibrary};
@@ -1,3 +1,3 @@
1
- const N=(e,r)=>{for(const t of r)if(e.includes(t))return!0;return!1},O=(e,r)=>{const t=new RegExp(`[${r.join("\\")}]`,"g");return e.replace(t,"")},L={2:/{{\s*((?:\.\.\/)*)([\w\d.]+)\s*(?:\|\s*([\w\d.]+))?\s*}}/g,3:/{{{(\s*(?:\.\.\/)*)([\w\d.]+)\s*(?:\|\s*([\w\d.]+))?\s*}}}/g},x=(e,r)=>r.split(".").reduce((t,a)=>t?.[a],e);function I(e,r,t={}){const{bracketsLength:a=2}=t,f=a===3?"{{{":"{{";if(!e.includes(f))return e;const m=L[a],c=r||this.state||{},i=this;return e.replace(m,(u,d,n,l)=>{const g=n.trim();if(l){const s=i?.context,o=s?.functions?.[l]||s?.utils?.[l]||s?.methods?.[l]||s?.snippets?.[l]||i?.[l];if(o&&typeof o=="function")try{return String(o.call(i,g)??"")}catch{return""}return""}if(d){const s=(d.match(/\.\.\//g)||[]).length;let o=c;for(let p=0;p<s;p++){if(!o||!o.parent)return"";o=o.parent}if(g==="parent")return String(o.value??"");const h=x(o,g);return h!=null&&typeof h=="object"?"":String(h??"")}else{const s=x(c,g);if(s!=null&&typeof s!="object")return String(s);const o=i?.context?.polyglot;if(o?.translations){const h=c?.root?.lang||c?.lang||i?.context?.state?.lang||o.defaultLang||"en",p=o.translations[h];if(p){const C=x(p,g);if(C!=null&&typeof C!="object")return String(C);for(const w in p){const b=p[w];if(b&&typeof b=="object"&&!Array.isArray(b)){const S=x(b,g);if(S!=null&&typeof S!="object")return String(S)}}}const y=x(o.translations,g);if(y!=null&&typeof y!="object")return String(y)}return""}})}const R=e=>`${e.charAt(0).toLowerCase()}${e.slice(1)}`,k=(e,r)=>{const t=e.split(`
2
- `);let a=-1,f=-1,m=-1,c=-1;const i=new RegExp(`\\b${r}\\b\\s*:\\s*`);let u=0,d=!1;for(let n=0;n<t.length;n++)if(i.test(t[n])&&!d){if(d=!0,a=n+1,m=t[n].indexOf(r)+1,t[n].includes("{}")){f=a,c=t[n].indexOf("{}")+3;break}const l=t[n].slice(m+r.length);if(l.includes("{")||l.includes("["))u=1;else{f=n+1,c=t[n].length+1;break}}else if(d&&(u+=(t[n].match(/{/g)||[]).length,u+=(t[n].match(/\[/g)||[]).length,u-=(t[n].match(/}/g)||[]).length,u-=(t[n].match(/]/g)||[]).length,u===0)){f=n+1,c=t[n].lastIndexOf("}")!==-1?t[n].lastIndexOf("}")+2:t[n].length+1;break}return{startColumn:m,endColumn:c,startLineNumber:a,endLineNumber:f}},j=/\\([0-7]{1,3})/g,E=e=>e.replace(j,(r,t)=>String.fromCharCode(parseInt(t,8))),$=e=>e.replace(/\n/g,"/////n").replace(/`/g,"/////tilde").replace(/\$/g,"/////dlrsgn"),F=e=>e.replace(/\/\/\/\/\/n/g,`
3
- `).replace(/\/\/\/\/\/tilde/g,"`").replace(/\/\/\/\/\/dlrsgn/g,"$"),A=/[^a-zA-Z0-9\s]/g,_=e=>e.replace(A,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,_ as customEncodeURIComponent,F as decodeNewlines,$ as encodeNewlines,k as findKeyPosition,R as lowercaseFirstLetter,I as replaceLiteralsWithObjectFields,E as replaceOctalEscapeSequences,N as stringIncludesAny,O as trimStringFromSymbols};
1
+ const N=(t,r)=>{for(const e of r)if(t.includes(e))return!0;return!1},O=(t,r)=>{const e=new RegExp(`[${r.join("\\")}]`,"g");return t.replace(e,"")},w={2:/{{\s*((?:\.\.\/)*)([\w\d.]+)\s*(?:\|\s*([\w\d.]+))?\s*}}/g,3:/{{{(\s*(?:\.\.\/)*)([\w\d.]+)\s*(?:\|\s*([\w\d.]+))?\s*}}}/g},x=(t,r)=>r.split(".").reduce((e,s)=>e?.[s],t),A=(t,r)=>{if(!t||!t.__ref)return!0;let e=t;for(;e;){if(e.allowRuntimeTemplates===!0)return!0;const s=e.__ref&&e.__ref.__authoredTemplates;if(s&&s.has(r))return!0;e=e.parent}return!1};function R(t,r,e={}){const{bracketsLength:s=2}=e,f=s===3?"{{{":"{{";if(!t.includes(f)||!A(this,t))return t;const m=w[s],l=r||this.state||{},i=this;return t.replace(m,(u,d,n,a)=>{const p=n.trim();if(a){const c=i?.context,o=c?.functions?.[a]||c?.utils?.[a]||c?.methods?.[a]||c?.snippets?.[a]||i?.[a];if(o&&typeof o=="function")try{return String(o.call(i,p)??"")}catch{return""}return""}if(d){const c=(d.match(/\.\.\//g)||[]).length;let o=l;for(let g=0;g<c;g++){if(!o||!o.parent)return"";o=o.parent}if(p==="parent")return String(o.value??"");const h=x(o,p);return h!=null&&typeof h=="object"?"":String(h??"")}else{const c=x(l,p);if(c!=null&&typeof c!="object")return String(c);const o=i?.context?.polyglot;if(o?.translations){const h=l?.root?.lang||l?.lang||i?.context?.state?.lang||o.defaultLang||"en",g=o.translations[h];if(g){const C=x(g,p);if(C!=null&&typeof C!="object")return String(C);for(const _ in g){const b=g[_];if(b&&typeof b=="object"&&!Array.isArray(b)){const S=x(b,p);if(S!=null&&typeof S!="object")return String(S)}}}const y=x(o.translations,p);if(y!=null&&typeof y!="object")return String(y)}return""}})}const I=t=>`${t.charAt(0).toLowerCase()}${t.slice(1)}`,k=(t,r)=>{const e=t.split(`
2
+ `);let s=-1,f=-1,m=-1,l=-1;const i=new RegExp(`\\b${r}\\b\\s*:\\s*`);let u=0,d=!1;for(let n=0;n<e.length;n++)if(i.test(e[n])&&!d){if(d=!0,s=n+1,m=e[n].indexOf(r)+1,e[n].includes("{}")){f=s,l=e[n].indexOf("{}")+3;break}const a=e[n].slice(m+r.length);if(a.includes("{")||a.includes("["))u=1;else{f=n+1,l=e[n].length+1;break}}else if(d&&(u+=(e[n].match(/{/g)||[]).length,u+=(e[n].match(/\[/g)||[]).length,u-=(e[n].match(/}/g)||[]).length,u-=(e[n].match(/]/g)||[]).length,u===0)){f=n+1,l=e[n].lastIndexOf("}")!==-1?e[n].lastIndexOf("}")+2:e[n].length+1;break}return{startColumn:m,endColumn:l,startLineNumber:s,endLineNumber:f}},L=/\\([0-7]{1,3})/g,E=t=>t.replace(L,(r,e)=>String.fromCharCode(parseInt(e,8))),$=t=>t.replace(/\n/g,"/////n").replace(/`/g,"/////tilde").replace(/\$/g,"/////dlrsgn"),F=t=>t.replace(/\/\/\/\/\/n/g,`
3
+ `).replace(/\/\/\/\/\/tilde/g,"`").replace(/\/\/\/\/\/dlrsgn/g,"$"),j=/[^a-zA-Z0-9\s]/g,T=t=>t.replace(j,r=>"%"+r.charCodeAt(0).toString(16).toUpperCase()),v=t=>t.replace(/%[0-9A-Fa-f]{2}/g,r=>String.fromCharCode(parseInt(r.slice(1),16)));export{v as customDecodeURIComponent,T as customEncodeURIComponent,F as decodeNewlines,$ as encodeNewlines,k as findKeyPosition,I as lowercaseFirstLetter,R as replaceLiteralsWithObjectFields,E as replaceOctalEscapeSequences,N as stringIncludesAny,O as trimStringFromSymbols};
package/keys.js CHANGED
@@ -148,6 +148,43 @@ export const METHODS = new Set([
148
148
  'preventContentRecreate'
149
149
  ])
150
150
 
151
+ // Is `name` a built-in element method (or a reserved element key)? Every method
152
+ // on @symbo.ls/element's prototype is in METHODS — locked by
153
+ // element/__tests__/libraryMethodsCannotShadowBuiltins.test.js.
154
+ export const isBuiltinElementMethod = (name) => METHODS.has(name)
155
+
156
+ // The built-in element methods a SHARED LIBRARY may replace — the OVERRIDE
157
+ // POINTS (FW-LIBRARY-METHODS-CANNOT-SHADOW-BUILTIN-ELEMENT-METHODS-1). They are
158
+ // observability hooks, not element semantics: the element's own tree, state
159
+ // and rendering never depend on what they do, so a library's version cannot
160
+ // break the element the way a stale getRoot / getRootState copy did — and
161
+ // apps link libraries precisely to route these outputs. Every other built-in
162
+ // is protected: a library copy is refused, the built-in wins. The app's OWN
163
+ // methods win over both, as for any method.
164
+ export const ELEMENT_METHOD_OVERRIDE_POINTS = new Set([
165
+ // Message logging. The built-in is a debug dump — element `log(...keys)`
166
+ // prints `{ key: el[key] }`; a library's `log(...params)` prints its
167
+ // messages, which is what its own methods call it for.
168
+ 'log',
169
+ // Warning channel. The built-in prints only in test/development; a library
170
+ // routes warnings in every environment (console, telemetry) and continues.
171
+ 'warn',
172
+ // Error channel. The built-in THROWS in test/development and is silent in
173
+ // production; a library reports and continues (`return this.error('…')` is
174
+ // an early exit that must not become an exception), with its own hooks
175
+ // (`onError`, `verbose`, `debugger` options).
176
+ 'error',
177
+ // Debug inspector for an element — a development aid a library may style
178
+ // or redirect.
179
+ 'verbose'
180
+ ])
181
+
182
+ // A built-in element method that a library can NOT replace: METHODS minus the
183
+ // override points. The single test the shared-library merge and the element's
184
+ // fold / `el.call` paths use.
185
+ export const isProtectedElementMethod = (name) =>
186
+ METHODS.has(name) && !ELEMENT_METHOD_OVERRIDE_POINTS.has(name)
187
+
151
188
  export const METHODS_EXL = new Set([
152
189
  'node', 'context', 'extends', '__element', '__ref',
153
190
  ...METHODS,
package/methods.js CHANGED
@@ -214,6 +214,25 @@ export const setActiveRootState = (state) => {
214
214
  _activeRootState = state || null
215
215
  }
216
216
 
217
+ /**
218
+ * `prepareContext` registers the PREPARED root state — a plain object — before
219
+ * the app root element exists. The root element then builds its OWN reactive
220
+ * store from that object (@symbo.ls/element createElementState), so the
221
+ * registered object is only a boot-time copy: it names no element, never sees
222
+ * a write and has no store methods. Every `getRootState()` fallback read went
223
+ * stale, and `getRoot()`'s fallback (`getRootState()?.__element`) could never
224
+ * resolve the app for an element whose `__ref` was cleared by `remove()`
225
+ * (FW-ROOT-STATE-REGISTERED-AS-A-DETACHED-PLAIN-COPY-1).
226
+ *
227
+ * @symbo.ls/element calls this when it builds a store from `source`: if the
228
+ * registry holds exactly `source`, it now holds the live `store`. Gated on
229
+ * identity, so an unrelated element tree created later can never take the
230
+ * registry over.
231
+ */
232
+ export const promoteActiveRootState = (source, store) => {
233
+ if (source && store && _activeRootState === source) _activeRootState = store
234
+ }
235
+
217
236
  const readFallbackState = () => {
218
237
  // The framework-managed registry (set by prepareContext during
219
238
  // create(...)) is the single source of truth for the active root
@@ -490,20 +509,32 @@ export function call (fnKey, ...args) {
490
509
  }
491
510
  }
492
511
 
512
+ // The fetch plugin, loaded on demand — getDB needs it only when the context
513
+ // configures a database (`context.fetch`). A bundle that ships without
514
+ // plugins (the smbls embed IIFE keeps `@symbo.ls/fetch` external,
515
+ // FW-EMBED-BUNDLE-UNDER-64K-OR-JUSTIFY-72K-1) cannot resolve it, so the
516
+ // failure names the cause instead of a bare module-specifier error.
517
+ const FETCH_PLUGIN_MISSING_MESSAGE =
518
+ "[smbls] getDB needs @symbo.ls/fetch, which the smbls embed bundle does not include: " +
519
+ "add @symbo.ls/fetch to the page's importmap (the runtime import then resolves) or use the full smbls bundle."
520
+ const loadFetchPlugin = () => import('@symbo.ls/fetch').catch((err) => {
521
+ throw new Error(FETCH_PLUGIN_MISSING_MESSAGE, { cause: err })
522
+ })
523
+
493
524
  export async function getDB () {
494
525
  const element = this
495
526
  const db = element.context?.fetch
496
527
  if (!db) return null
497
528
  if (typeof db.select === 'function') {
498
529
  if (!db.__authInitialized && db.getSession) {
499
- const { initAdapterAuth } = await import('@symbo.ls/fetch')
530
+ const { initAdapterAuth } = await loadFetchPlugin()
500
531
  await initAdapterAuth(db, element.context)
501
532
  }
502
533
  return db
503
534
  }
504
535
  if (db.__resolved) {
505
536
  if (!db.__resolved.__authInitialized && db.__resolved.getSession) {
506
- const { initAdapterAuth } = await import('@symbo.ls/fetch')
537
+ const { initAdapterAuth } = await loadFetchPlugin()
507
538
  await initAdapterAuth(db.__resolved, element.context)
508
539
  }
509
540
  return db.__resolved
@@ -511,7 +542,7 @@ export async function getDB () {
511
542
  if (db.__resolving) return db.__resolving
512
543
  // Set __resolving synchronously BEFORE the async import to prevent
513
544
  // resolveAdapter() from starting a parallel resolveDb() during the yield
514
- const resolvePromise = import('@symbo.ls/fetch').then(({ resolveDb }) => resolveDb(db))
545
+ const resolvePromise = loadFetchPlugin().then(({ resolveDb }) => resolveDb(db))
515
546
  db.__resolving = resolvePromise
516
547
  const resolved = await resolvePromise
517
548
  db.__resolved = resolved
@@ -526,7 +557,7 @@ export async function getDB () {
526
557
  // unwinds the entire fetch boot — silently breaking every consumer
527
558
  // that depended on the adapter.
528
559
  if (resolved?.getSession) {
529
- const { initAdapterAuth } = await import('@symbo.ls/fetch')
560
+ const { initAdapterAuth } = await loadFetchPlugin()
530
561
  await initAdapterAuth(resolved, element.context)
531
562
  }
532
563
  return resolved
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/utils",
3
- "version": "3.14.775",
3
+ "version": "3.14.777",
4
4
  "license": "CC-BY-NC-4.0",
5
5
  "type": "module",
6
6
  "module": "./dist/esm/index.js",
@@ -1,6 +1,8 @@
1
1
  'use strict'
2
2
 
3
3
  import { isObject, isString } from './types.js'
4
+ import { isProtectedElementMethod } from './keys.js'
5
+ import { isLoudDevRuntime } from './env.js'
4
6
 
5
7
  const DEFAULT_LIBRARY_OWNER = 'system'
6
8
 
@@ -271,7 +273,68 @@ export const isWrappedLibrary = (entry) =>
271
273
  const wrappedLibraryRef = (entry) =>
272
274
  entry.library !== undefined ? entry.library : (entry.key ?? entry.name)
273
275
 
274
- const mergeOneLibrary = (context, sharedLib, ignore) => {
276
+ /**
277
+ * A library's `methods` never replace a PROTECTED built-in element method
278
+ * (FW-LIBRARY-METHODS-CANNOT-SHADOW-BUILTIN-ELEMENT-METHODS-1).
279
+ *
280
+ * `@symbo.ls/element` layers `context.methods` over its built-in element methods
281
+ * (getContextProto) and `el.call(name)` reads `context.methods` first, so a
282
+ * library key named `getRoot` / `getRootState` / … used to replace the built-in
283
+ * on every element of the consuming app, silently — and kept replacing it after
284
+ * the framework fixed the built-in. Measured on a live app: a library's
285
+ * pre-FW-GETROOT `getRoot` copy answered undefined inside installed modules and
286
+ * every module popover was dead with no error.
287
+ *
288
+ * So the merge refuses such a key on both branches and the built-in wins —
289
+ * except for the OVERRIDE POINTS (keys.js ELEMENT_METHOD_OVERRIDE_POINTS: the
290
+ * logging hooks log / warn / error / verbose), which merge like any library
291
+ * method: a library's "log and continue" versions are what its consumers rely
292
+ * on, and no element semantics depend on them. The APP's OWN `methods` are
293
+ * untouched (they were in the bag before any library merged) and win over
294
+ * both. One dev warning per refused name for the page.
295
+ */
296
+ const _warnedBuiltinMethods = new Set()
297
+
298
+ // Test-only: forget which names already warned.
299
+ export const __resetBuiltinMethodWarnings = () => {
300
+ _warnedBuiltinMethods.clear()
301
+ }
302
+
303
+ const warnRefusedBuiltinMethods = (label, names) => {
304
+ const fresh = names.filter((n) => !_warnedBuiltinMethods.has(n))
305
+ if (!fresh.length) return
306
+ for (const n of fresh) _warnedBuiltinMethods.add(n)
307
+ if (!isLoudDevRuntime()) return
308
+ console.warn(
309
+ `[smbls] shared library "${label}" ships ${fresh.map((n) => `methods.${n}`).join(', ')} — ` +
310
+ `named like a built-in element method. Refused: the built-in wins; a library cannot ` +
311
+ `replace an element method on the consuming app. If the app wants this version, ` +
312
+ `declare it in the app's OWN methods.`
313
+ )
314
+ }
315
+
316
+ // The library's `methods` bag without protected built-in names, for the
317
+ // wholesale-copy branch. Same reference when there is nothing to drop (the
318
+ // common case — no allocation, exactly as before); otherwise a copy, because
319
+ // the library's own bag is shared by every consumer and is never edited.
320
+ // A name the consumer ignores (`methods/<name>` in skip) is dropped by
321
+ // copyWithNestedIgnores anyway and is not reported as refused.
322
+ const withoutProtectedMethods = (bag, skip, refused) => {
323
+ let copy = null
324
+ for (const k in bag) {
325
+ if (!isProtectedElementMethod(k)) continue
326
+ if (!skip.has(`methods/${k}`)) refused.push(k)
327
+ if (!copy) {
328
+ copy = {}
329
+ for (const j in bag) {
330
+ if (!isProtectedElementMethod(j)) copy[j] = bag[j]
331
+ }
332
+ }
333
+ }
334
+ return copy || bag
335
+ }
336
+
337
+ const mergeOneLibrary = (context, sharedLib, ignore, label = 'library') => {
275
338
  // A library can declare parts of itself private via `sharedLibIgnore` on
276
339
  // its own context — same path grammar as the consumer-side `ignoreList`
277
340
  // (top-level keys or nested 'components/Header'). A library serving its
@@ -285,6 +348,7 @@ const mergeOneLibrary = (context, sharedLib, ignore) => {
285
348
  const skip = libIgnore.size
286
349
  ? new Set([...ignore, ...libIgnore])
287
350
  : ignore
351
+ const refusedMethods = []
288
352
  for (const key in sharedLib) {
289
353
  if (!Object.prototype.hasOwnProperty.call(sharedLib, key)) continue
290
354
  // merge directives, not library content
@@ -307,6 +371,14 @@ const mergeOneLibrary = (context, sharedLib, ignore) => {
307
371
  } else {
308
372
  for (const k in sharedLib[key]) {
309
373
  if (skip.has(`${key}/${k}`)) continue // nested skip: 'components/Header'
374
+ if (key === 'methods' && isProtectedElementMethod(k)) {
375
+ // The built-in wins. An app-own key of that name is the app's
376
+ // declared override and stays — nothing to report for it. The
377
+ // override points (log / warn / error / verbose) are not protected
378
+ // and fall through to the normal add-missing merge below.
379
+ if (!(k in context[key])) refusedMethods.push(k)
380
+ continue
381
+ }
310
382
  if (!(k in context[key])) {
311
383
  context[key][k] = sharedLib[key][k]
312
384
  } else if (isStubPhantom(key, context[key][k]) && !isStubPhantom(key, sharedLib[key][k])) {
@@ -318,9 +390,28 @@ const mergeOneLibrary = (context, sharedLib, ignore) => {
318
390
  }
319
391
  }
320
392
  } else if (!(key in context)) {
321
- context[key] = copyWithNestedIgnores(sharedLib[key], skip, key)
393
+ // Any object bag, not only a plain one: a native-ESM module namespace
394
+ // (`import * as methods` outside a bundler) has a null prototype and
395
+ // fails isObject, yet lands here and becomes `context.methods` as is.
396
+ const bag = sharedLib[key]
397
+ const value = key === 'methods' && bag && typeof bag === 'object'
398
+ ? withoutProtectedMethods(bag, skip, refusedMethods)
399
+ : bag
400
+ context[key] = copyWithNestedIgnores(value, skip, key)
322
401
  }
323
402
  }
403
+ if (refusedMethods.length) warnRefusedBuiltinMethods(label, refusedMethods)
404
+ }
405
+
406
+ // A readable name for a library in the refusal warning: the wrapped entry's
407
+ // identifier, else the library context's own key/name, else its position.
408
+ const libraryLabel = (entry, lib, index) => {
409
+ if (entry !== lib) {
410
+ const ref = wrappedLibraryRef(entry)
411
+ if (isString(ref) && ref) return ref
412
+ if (entry.key || entry.name) return entry.key || entry.name
413
+ }
414
+ return (lib && (lib.key || lib.name)) || `sharedLibraries[${index}]`
324
415
  }
325
416
 
326
417
  /**
@@ -345,14 +436,15 @@ export const mergeSharedLibraries = (context, libraries) => {
345
436
  // consumer's own bags and the two can no longer be told apart.
346
437
  const ownDefaultFonts = defaultFontClaims(context.designSystem)
347
438
  for (let i = 0; i < libraries.length; i++) {
348
- let sharedLib = libraries[i]
439
+ const entry = libraries[i]
440
+ let sharedLib = entry
349
441
  let ignore = EMPTY_IGNORE
350
442
  if (isWrappedLibrary(sharedLib)) {
351
443
  ignore = normalizeIgnoreList(sharedLib.ignoreList)
352
444
  sharedLib = sharedLib.library
353
445
  }
354
446
  if (!isObject(sharedLib)) continue
355
- mergeOneLibrary(context, sharedLib, ignore)
447
+ mergeOneLibrary(context, sharedLib, ignore, libraryLabel(entry, sharedLib, i))
356
448
  }
357
449
  if (ownDefaultFonts.size) yieldLibraryDefaultFonts(context.designSystem, ownDefaultFonts)
358
450
  }
package/string.js CHANGED
@@ -35,10 +35,53 @@ const getNestedValue = (obj, path) => {
35
35
  }, obj)
36
36
  }
37
37
 
38
+ /**
39
+ * Is this exact string a template the AUTHOR wrote?
40
+ *
41
+ * FW-ELEMENT-TEMPLATES-RESOLVED-IN-RUNTIME-TEXT-FUNCTION-INJECTION-1.
42
+ * A `{{ key | fn }}` template invokes a project function, so resolving one
43
+ * inside a string that CAME FROM DATA turns content into code: a customer
44
+ * typing `{{ x | nkTheme }}` into a chat box flipped the theme, and
45
+ * `nkToast('info', 'literal test {{ demoShort | polyglot }} end')` rendered
46
+ * the translation. Every function on `context.functions` was reachable from
47
+ * user text, an AI reply or an API response.
48
+ *
49
+ * The contract: a template is an author-time literal. `create()` records
50
+ * every `{{ }}` string a definition declares (`__ref.__authoredTemplates`,
51
+ * see registerEffects), and only those strings resolve. A factory may
52
+ * FORWARD an authored template — the framework `Input` atom does exactly
53
+ * that with `attr.placeholder: el => el.placeholder` — but it may never
54
+ * introduce one. The parent chain counts, so a template declared on an
55
+ * ancestor and forwarded down still resolves; every entry in every set is a
56
+ * source literal, so no state-derived string is ever in one.
57
+ *
58
+ * `allowRuntimeTemplates: true` on an element is the explicit opt-out, for
59
+ * the rare surface that really does build templates at runtime. It re-opens
60
+ * function invocation from that element's content — never set it on an
61
+ * element that renders text a user or a model produced.
62
+ *
63
+ * This reads `this` by duck-typing (`__ref`, `parent`), exactly as the state
64
+ * and polyglot lookups below already do — `utils` never imports `element`.
65
+ * A caller with no `__ref` is not an element (a bare util call, a test) and
66
+ * keeps the old unconditional behaviour.
67
+ */
68
+ const isAuthoredTemplate = (element, str) => {
69
+ if (!element || !element.__ref) return true
70
+ let el = element
71
+ while (el) {
72
+ if (el.allowRuntimeTemplates === true) return true
73
+ const authored = el.__ref && el.__ref.__authoredTemplates
74
+ if (authored && authored.has(str)) return true
75
+ el = el.parent
76
+ }
77
+ return false
78
+ }
79
+
38
80
  export function replaceLiteralsWithObjectFields (str, state, options = {}) {
39
81
  const { bracketsLength = 2 } = options
40
82
  const bracketPattern = bracketsLength === 3 ? '{{{' : '{{'
41
83
  if (!str.includes(bracketPattern)) return str
84
+ if (!isAuthoredTemplate(this, str)) return str
42
85
 
43
86
  const reg = brackRegex[bracketsLength]
44
87
  const obj = state || this.state || {}