@symbo.ls/utils 3.14.771 → 3.14.773
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/assets.js +35 -4
- package/dist/cjs/assets.js +1 -1
- package/dist/cjs/extends.js +1 -1
- package/dist/cjs/methods.js +3 -3
- package/dist/cjs/object.js +18 -18
- package/dist/cjs/sharedLibraries.js +1 -1
- package/dist/esm/assets.js +1 -1
- package/dist/esm/extends.js +1 -1
- package/dist/esm/methods.js +5 -5
- package/dist/esm/object.js +18 -18
- package/dist/esm/sharedLibraries.js +1 -1
- package/extends.js +93 -42
- package/methods.js +22 -2
- package/object.js +35 -28
- package/package.json +1 -1
- package/sharedLibraries.js +81 -0
package/assets.js
CHANGED
|
@@ -23,8 +23,16 @@
|
|
|
23
23
|
* (and any cloud provider that exposes variant metadata). Returned
|
|
24
24
|
* verbatim.
|
|
25
25
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
26
|
+
* - **Platform file record** — `{ content: { src, type?, variants? }, … }`.
|
|
27
|
+
* The shape a platform FILE record arrives in: its public URL lives at
|
|
28
|
+
* `content.src` and there is no top-level `src`. Returned with `src`
|
|
29
|
+
* lifted to the top level and `type`/`variants` normalized to `null`
|
|
30
|
+
* when absent, so callers see one shape whatever the source.
|
|
31
|
+
*
|
|
32
|
+
* Anything else (object with neither `.src` nor `.content.src`, missing key,
|
|
33
|
+
* non-string `el.src`) returns null. Components fall through to plain markup
|
|
34
|
+
* using `el.src` — which is exactly the path that emitted a bare key and
|
|
35
|
+
* cost 46 wasted 404s per WebKit boot before the record shape was handled.
|
|
28
36
|
*/
|
|
29
37
|
export const resolveAsset = (el) => {
|
|
30
38
|
const key = el && el.src
|
|
@@ -36,8 +44,31 @@ export const resolveAsset = (el) => {
|
|
|
36
44
|
if (typeof found === 'string') {
|
|
37
45
|
return { src: found, type: null, variants: null }
|
|
38
46
|
}
|
|
39
|
-
if (typeof found === 'object'
|
|
40
|
-
return found
|
|
47
|
+
if (typeof found === 'object') {
|
|
48
|
+
if (typeof found.src === 'string') return found
|
|
49
|
+
// Third shape: a PLATFORM FILE RECORD, which carries its public URL at
|
|
50
|
+
// `content.src` and has no top-level `src`. Without this branch the
|
|
51
|
+
// lookup returned null, the component fell through to plain markup, and
|
|
52
|
+
// the FIRST attribute write emitted the bare KEY against the origin —
|
|
53
|
+
// `src="mono-beta-1.png"`. WebKit starts that load immediately and logs a
|
|
54
|
+
// 404 per image (46 on the landing's `/` at boot, measured 2026-09-04);
|
|
55
|
+
// Chromium defers until the reactive effect replaces the attribute and
|
|
56
|
+
// logs nothing, which is why this only ever showed on one engine.
|
|
57
|
+
// The project cannot normalise the record itself: `files/index.js` and
|
|
58
|
+
// `assets/index.js` are CLI-generated and a hand edit dies on the next
|
|
59
|
+
// `smbls fetch`.
|
|
60
|
+
const content = found.content
|
|
61
|
+
const contentSrc = content && content.src
|
|
62
|
+
if (typeof contentSrc === 'string') {
|
|
63
|
+
return {
|
|
64
|
+
...found,
|
|
65
|
+
src: contentSrc,
|
|
66
|
+
// Keep the documented normalized shape: an absent variant/type is
|
|
67
|
+
// `null`, never `undefined`, so a consumer's `=== null` check holds.
|
|
68
|
+
type: found.type ?? content.type ?? null,
|
|
69
|
+
variants: found.variants ?? content.variants ?? null
|
|
70
|
+
}
|
|
71
|
+
}
|
|
41
72
|
}
|
|
42
73
|
return null
|
|
43
74
|
}
|
package/dist/cjs/assets.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var f=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var g=(t,e)=>{for(var n in e)f(t,n,{get:e[n],enumerable:!0})},m=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of p(e))!y.call(t,r)&&r!==n&&f(t,r,{get:()=>e[r],enumerable:!(s=l(e,r))||s.enumerable});return t};var h=t=>m(f({},"__esModule",{value:!0}),t);var d={};g(d,{buildImgSrcset:()=>A,buildSourcesAndImg:()=>b,resolveAsset:()=>v,srcsetFor:()=>i});module.exports=h(d);const v=t=>{const e=t&&t.src;if(!e||typeof e!="string")return null;const n=t.context;if(!n)return null;const s=n.assets&&n.assets[e]||n.files&&n.files[e];if(!s)return null;if(typeof s=="string")return{src:s,type:null,variants:null};if(typeof s=="object"){if(typeof s.src=="string")return s;const r=s.content,c=r&&r.src;if(typeof c=="string")return{...s,src:c,type:s.type??r.type??null,variants:s.variants??r.variants??null}}return null},i=(t,{keepOneX:e=!0}={})=>{if(!Array.isArray(t)||!t.length)return"";const n=t.some(r=>typeof r.width=="number"),s=[];for(const r of t)n&&typeof r.width=="number"?s.push(`${r.src} ${r.width}w`):n||(r.scale===1&&e?s.push(r.src):r.scale&&r.scale!==1&&s.push(`${r.src} ${r.scale}x`));return s.join(", ")},A=t=>{if(!t||!Array.isArray(t.variants))return"";const e=t.variants.filter(n=>n.format===t.type);return i(e,{keepOneX:!1})},b=(t,e)=>{if(!t||typeof t!="object"||typeof t.src!="string")return[];if(!Array.isArray(t.variants)||!t.variants.length)return[{tag:"img",attr:{src:t.src,alt:e||""}}];const n=new Map;for(const o of t.variants)n.has(o.format)||n.set(o.format,[]),n.get(o.format).push(o);const s=[];for(const[o,a]of n)o!==t.type&&s.push({tag:"source",attr:{type:o,srcset:i(a,{keepOneX:!0})}});const r=n.get(t.type)||[],c=i(r,{keepOneX:!1}),u={src:t.src,alt:e||""};return c&&(u.srcset=c),[...s,{tag:"img",attr:u}]};
|
package/dist/cjs/extends.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var A=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var Y=Object.prototype.hasOwnProperty;var Z=(t,r)=>{for(var n in r)A(t,n,{get:r[n],enumerable:!0})},B=(t,r,n,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of U(r))!Y.call(t,o)&&o!==n&&A(t,o,{get:()=>r[o],enumerable:!(s=Q(r,o))||s.enumerable});return t};var V=t=>B(A({},"__esModule",{value:!0}),t);var et={};Z(et,{addExtend:()=>nt,addExtends:()=>a,applyExtends:()=>ot,cloneAndMergeArrayExtend:()=>b,collectExtendsList:()=>y,concatAddExtends:()=>k,createElementExtends:()=>M,createExtends:()=>w,createExtendsFromKeys:()=>I,createExtendsStack:()=>X,deepExtend:()=>G,deepMergeExtends:()=>x,extendCachedRegistry:()=>m,extendStackRegistry:()=>P,extractArrayExtend:()=>R,finalizeExtends:()=>q,flattenExtend:()=>v,generateHash:()=>N,getExtendsInElement:()=>st,getExtendsStack:()=>j,getExtendsStackRegistry:()=>W,getHashedExtend:()=>O,inheritChildExtends:()=>F,inheritChildPropsExtends:()=>z,inheritRecursiveChildExtends:()=>L,jointStacks:()=>rt,mapStringsWithContextComponents:()=>K,setHashedExtend:()=>T,toPriorityOrder:()=>_});module.exports=V(et);var h=require("./array.js"),l=require("./component.js"),E=require("./object.js"),f=require("./types.js");const S="production",$=t=>t.sourcemap!==!1&&S!=="production",y=t=>{if(!t)return[];const r=[],n=t.extends;n&&((0,f.isArray)(n)?r.push(...n):r.push(n));const s=t.extend;return s&&((0,f.isArray)(s)?r.push(...s):r.push(s)),r},_=t=>{if(!(0,f.isArray)(t))return t;const r=[];for(let n=t.length-1;n>=0;n--){const s=t[n];r.push((0,f.isArray)(s)?_(s):s)}return r},I=t=>{if(t.includes("+"))return t.split("+").filter(l.matchesComponentNaming);if(t.includes("_")){const[r]=t.split("_");return[r]}if(t.includes(".")&&!(0,l.matchesComponentNaming)(t.split(".")[1])){const[r]=t.split(".");return[r]}return[t]},w=(t,r,n)=>{let s=[];const o=I(n);o&&(s=[...o]);const e=_(y(t));return e.length&&(s=[...s,...e]),s},a=(t,r)=>{const{__ref:n}=r;let{__extends:s}=n;if(!t)return s;const o=r.variant,e=r.context;if(o&&e?.components&&!Array.isArray(t)&&typeof t=="string"){const i=`${t}.${o}`;e.components[i]&&(t=i)}return s.includes(t)||(s=Array.isArray(t)?[...s,...t]:[...s,t],n.__extends=s),s},k=(t,r)=>{if(!t)return r;const{extends:n}=r,s=(0,f.isArray)(n)?n:[n],o=(0,f.isArray)(t)?t:[t];return{...r,extends:(0,h.joinArrays)(o,s)}},N=()=>Math.random().toString(36).substring(2),P={},m={},O=t=>P[t.__hash],T=(t,r)=>{const n=N();return(0,f.isString)(t)||(t.__hash=n),n!=="__proto__"&&n!=="constructor"&&n!=="prototype"&&(P[n]=r),r},W=(t,r)=>t.__hash?r.concat(O(t)):T(t,r),R=(t,r,n,s=new Set,o,e)=>{for(const i of t)(0,f.isArray)(i)?R(i,r,n,s,o,e):v(i,r,n,s,o,void 0,e);return r},G=(t,r,n,s=new Set,o,e,i)=>{const c=y(t),d={...t};delete d.extends,delete d.extend;let u=!1;for(const p in d){u=!0;break}return u&&(r.push(d),o&&o.push(e)),c.length&&v(_(c),r,n,s,o,e,i),r},v=(t,r,n,s=new Set,o,e,i)=>{if(!t||s.has(t))return r;if((0,f.isArray)(t))return R(t,r,n,s,o,i);let c=e;return(0,f.isString)(t)?(c=t,t=K(t,n)):i&&(0,f.isObject)(t)&&i.has(t)&&(c=i.get(t)),s.has(t)||(s.add(t),t?.extends||t?.extend?G(t,r,n,s,o,c,i):t&&(r.push(t),o&&o.push(c))),r},tt=new Set(["parent","node","__ref","__proto__","extends","extend","childExtends","childExtendsRecursive"]),x=(t,r,n,s,o)=>{r=(0,E.deepClone)(r);for(const e in r){if(tt.has(e))continue;const i=t[e],c=r[e];if(c!==void 0&&Object.prototype.hasOwnProperty.call(r,e)&&e!=="__proto__"&&e!=="constructor"&&e!=="prototype"){if(i===void 0)t[e]=c,n&&s?(0,f.isObject)(c)&&!(0,f.isArray)(c)?(n[e]=n[e]||{},H(n[e],c,s)):n[e]=s:n&&o?.[e]&&(n[e]=o[e]);else if((0,f.isObject)(i)&&(0,f.isObject)(c)){const d=n?n[e]=n[e]||{}:void 0,u=o?.[e];(0,l.matchesComponentNaming)(e)?t[e]=x(i,c,d,s,u):x(i,c,d,s,u)}if(e==="extends"||e==="childExtends"||e==="childExtendsRecursive"){if((0,f.isArray)(i)&&(0,f.isArray)(c))t[e]=i.concat(c);else if((0,f.isArray)(i)&&(0,f.isObject)(c)){const d=x({},i);t[e]=x(d,c)}}}}return t},H=(t,r,n,s)=>{if(s||(s=new WeakSet),!s.has(r)){s.add(r);for(const o in r){if(!Object.prototype.hasOwnProperty.call(r,o)||o==="__proto__"||o==="constructor"||o==="prototype")continue;const e=r[o];(0,f.isObject)(e)&&!(0,f.isArray)(e)?(t[o]=t[o]||{},H(t[o],e,n,s)):t[o]=n}}},b=(t,r,n)=>t.reduce((s,o,e)=>{const i=(0,E.deepClone)(o),c=n?n[e]:void 0;return x(s,i,r,c)},{}),K=(t,r,n={},s)=>{const o=r?.components||n.components,e=r?.pages||n.pages;if((0,f.isString)(t)){const i=o&&(o[t+"."+s]||o[t]||o["smbls."+t]),c=e&&t.charCodeAt(0)===47&&e[t];if(i)return i;if(c)return c;n.verbose&&(S==="test"||S==="development")&&console.warn("Extend is string but component was not found:",t);return}return t},rt=(t,r)=>[].concat(t.slice(0,1)).concat(r.slice(0,1)).concat(t.slice(1)).concat(r.slice(1)),j=(t,r,n,s)=>{if(!t)return[];if(t.__hash)return O(t)||[];const e=v(t,[],r,new Set,n,void 0,s);return n?e:W(t,e)},nt=(t,r)=>{if(!t)return r;const n=(0,f.isArray)(t)?t:[t];return(0,h.joinArrays)(n,r)},st=t=>{let r=[];function n(s){for(const o in s)Object.prototype.hasOwnProperty.call(s,o)&&((0,l.matchesComponentNaming)(o)&&r.push(o),o==="extends"&&(typeof s[o]=="string"?r.push(s[o]):Array.isArray(s[o])&&(r=r.concat(s[o]))),typeof s[o]=="object"&&s[o]!==null&&n(s[o]))}return n(t),r},M=(t,r,n={})=>{const{__ref:s}=t,o=t.context||r.context,e=t.variant,i=y(t);if(i.length){const c=_(i),[d,...u]=c,p=typeof d=="string"&&e&&o?.components?`${d}.${e}`:null;p&&o.components[p]?a([p,...u],t):a(c,t)}return z(t,r,n),F(t,r,n),L(t,r,n),t.component&&a(_((0,E.exec)(t.component,t)),t),o.defaultExtends&&a(_(o.defaultExtends),t),(0,h.removeDuplicatesInArray)(s.__extends)},z=(t,r,n={})=>{const{__ref:s}=t;return n.ignoreChildExtends||t.ignoreChildExtends||r.childProps?.extends&&a(_(r.childProps.extends),t),s.__extends},F=(t,r,n={})=>{const{__ref:s}=t,o=n.ignoreChildExtends||t.ignoreChildExtends,e=r.childExtends;return!o&&e&&a(_(e),t),s.__extends},L=(t,r,n={})=>{const{__ref:s}=t,o=r.childExtendsRecursive,e=n.ignoreChildExtendsRecursive||t.ignoreChildExtendsRecursive,i=t.key==="__text";return o&&!i&&!e&&a(_(o),t),s.__extends},X=(t,r,n={})=>{const{__ref:s}=t,o=t.context||r.context,e=t.variant,i=$(n),c=i?[...s.__extends]:null,d=(0,h.removeDuplicatesInArray)(s.__extends.map((u,p)=>K(u,o,n,p===0&&e)));if(i){const u=new WeakMap;for(let g=0;g<d.length;g++){const C=d[g],D=c[g];C&&(0,f.isObject)(C)&&(0,f.isString)(D)&&u.set(C,D)}const p=[],J=j(d,o,p,u);s.__extendsStack=J,s.__extendsNames=p}else{const u=j(d,o);s.__extendsStack=u}return s.__extendsStack},q=(t,r,n={})=>{const{__ref:s}=t,{__extendsStack:o}=s;if($(n)){const e={},i=s.__extendsNames||[],c=b(o,e,i),d={};x(t,c,d,void 0,e),s.__sourcemap=d}else{const e=b(o);x(t,e)}return t},ot=(t,r,n={})=>(M(t,r,n),X(t,r,n),q(t,r,n),t);
|
package/dist/cjs/methods.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";var D=Object.create;var g=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var L=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var M=(e,t)=>{for(var n in t)g(e,n,{get:t[n],enumerable:!0})},
|
|
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
|
|
1
|
+
"use strict";var D=Object.create;var g=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var L=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var M=(e,t)=>{for(var n in t)g(e,n,{get:t[n],enumerable:!0})},O=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of I(t))!F.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(L(e)):{},O(t||!e||!e.__esModule?g(n,"default",{value:e,enumerable:!0}):n,e)),J=e=>O(g({},"__esModule",{value:!0}),e);var wt={};M(wt,{call:()=>ut,defineSetter:()=>rt,error:()=>S,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:()=>w,previousElement:()=>lt,remove:()=>H,setActiveRootState:()=>X,setNodeStyles:()=>C,setProps:()=>W,spotByPath:()=>V,variables:()=>ft,verbose:()=>N,warn:()=>it});module.exports=J(wt);var v=require("./triggerEvent.js"),d=require("./keys.js"),f=require("./types.js"),E=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,v.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,v.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 R=null;const X=e=>{R=e||null},$=()=>R||null;function q(e){let t=null;const n=o=>o.__element&&o.root?.isRootState;if(!this)t=$();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=$()),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 w(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)?w.call(c,e,t):c):(0,f.isObjectLike)(i)&&(o[s]=w.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 S(...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,E.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)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 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(y(t,o),n===!0)return o;const r=yt[n];return r?r(o):o}const y=(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&&y(l,t)}const s=n.contentElementKey||"content",i=e[s];i&&i.__ref&&y(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])}},k=(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
|
${k(i,t+1)}
|
|
4
4
|
${n}}`).join(`
|
|
5
5
|
`):""},dt=e=>`{
|
|
@@ -7,4 +7,4 @@ ${k(e,1)}
|
|
|
7
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,x)=>{r.add(p),x&&o.push(`LEFT JOIN ${p} ON ${p}.${x}_id = ${x}.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
|
|
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])}
|
package/dist/cjs/object.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
|
|
3
|
-
`;for(const
|
|
4
|
-
|
|
5
|
-
`:(0,u.
|
|
6
|
-
`:n+=`${
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
`}return n+=`${
|
|
10
|
-
`,r);r=d===-1?
|
|
11
|
-
`)){p++;break}p++}n.push([d,p]),r=p;continue}r++}if(!n.length)return null;let a=e;for(let y=n.length-1;y>=0;y--)a=a.slice(0,n[y][0])+a.slice(n[y][1]);return a},
|
|
12
|
-
First 200 chars of source: `+String(e).slice(0,200)),e)}},
|
|
13
|
-
`);try{const
|
|
14
|
-
`),
|
|
15
|
-
${
|
|
16
|
-
return ${
|
|
17
|
-
`);t[
|
|
18
|
-
return (${
|
|
1
|
+
"use strict";var $=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var V=(e,t)=>{for(var o in t)$(e,o,{get:t[o],enumerable:!0})},H=(e,t,o,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of J(t))!U.call(e,n)&&n!==o&&$(e,n,{get:()=>t[n],enumerable:!(c=B(t,n))||c.enumerable});return e};var X=e=>H($({},"__esModule",{value:!0}),e);var Te={};V(Te,{clone:()=>ee,createNestedObject:()=>Se,createObjectWithoutPrototype:()=>Z,deepClone:()=>te,deepContains:()=>we,deepDestringifyFunctions:()=>ue,deepMerge:()=>j,deepStringifyFunctions:()=>E,destringifyGlobalScope:()=>le,detectInfiniteLoop:()=>Ee,excludeKeysFromObject:()=>Ae,exec:()=>x,getInObjectByPath:()=>xe,hasFunction:()=>k,hasOwnProperty:()=>pe,isCyclic:()=>Pe,isEmpty:()=>z,isEmptyObject:()=>ye,isEqualDeep:()=>Y,makeObjectWithoutPrototype:()=>he,map:()=>v,merge:()=>Q,objectToString:()=>P,overwrite:()=>de,overwriteDeep:()=>K,overwriteShallow:()=>ge,removeFromObject:()=>Oe,removeNestedKeyByPath:()=>ke,setInObjectByPath:()=>$e,stringToObject:()=>ae});module.exports=X(Te);var O=require("./globals.js"),u=require("./types.js"),F=require("./array.js"),L=require("./string.js"),_=require("./node.js"),q=require("./keys.js");const A="production",w=e=>e.charCodeAt(0)===95&&e.charCodeAt(1)===95,x=(e,t,o,c)=>{if((0,u.isFunction)(e))return t?typeof e.call!="function"?e:e.call(t,t,o||t.state,c||t.context):void 0;if(e!=null&&t?.context?.plugins&&((0,u.isArray)(e)||(0,u.isObject)(e)&&!(0,_.isDOMNode)(e))){const n=t.context.plugins;for(const r of n)if(r.resolveHandler){const i=r.resolveHandler(e,t);if(typeof i=="function")return x(i,t,o,c)}}return e},v=(e,t,o)=>{for(const c in t)e[c]=x(t[c],o)},Q=(e,t,o=[])=>{const c=o instanceof Set;for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(w(n)||(c?o.has(n):o.includes(n))||e[n]===void 0&&(e[n]=t[n]));return e},j=(e,t,o=q.METHODS_EXL)=>T(e,t,o,null),T=(e,t,o,c)=>{if(e===t)return e;if(c){for(let r=0;r<c.length;r+=2)if(c[r]===e&&c[r+1]===t)return e}const n=o instanceof Set;for(const r in t){if(!Object.prototype.hasOwnProperty.call(t,r)||w(r)||r==="constructor"||r==="prototype"||(n?o.has(r):o.includes(r)))continue;const i=e[r],s=t[r];if((0,u.isObjectLike)(i)&&(0,u.isObjectLike)(s)){const f=c||[];f.push(e,t),T(i,s,o,f),f.length-=2}else i===void 0&&(e[r]=s)}return e},ee=(e,t=[])=>{const o=t instanceof Set,c={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(w(n)||(o?t.has(n):t.includes(n))||(c[n]=e[n]));return c},te=(e,t={})=>{const{exclude:o=[],cleanUndefined:c=!1,cleanNull:n=!1,visited:r=new WeakMap,handleExtends:i=!1}=t;if(!(0,u.isObjectLike)(e)||(0,_.isDOMNode)(e))return e;if(r.has(e))return r.get(e);const s=o instanceof Set?o:o.length>3?new Set(o):null,f=y=>s?s.has(y):o.includes(y),l=(0,u.isArray)(e)?[]:{};r.set(e,l);const a=[[e,l]];for(;a.length;){const[y,d]=a.pop();for(const h in y){if(!Object.prototype.hasOwnProperty.call(y,h)||w(h)||h==="__proto__"||f(h))continue;const p=y[h];if(!(c&&p===void 0)&&!(n&&p===null)){if((0,_.isDOMNode)(p)){d[h]=p;continue}if(i&&h==="extends"&&(0,u.isArray)(p)){d[h]=(0,F.unstackArrayOfObjects)(p,o);continue}if((0,u.isFunction)(p)){d[h]=p;continue}if((0,u.isObjectLike)(p))if(r.has(p))d[h]=r.get(p);else{const g=(0,u.isArray)(p)?[]:{};r.set(p,g),d[h]=g,a.push([p,g])}else d[h]=p}}}return l},E=(e,t={})=>{(e.node||e.__ref||e.parent||e.__element||e.parse)&&((e.__element||e.parent?.__element).warn("Trying to clone element or state at",e),e=e.parse?.());for(const o in e){const c=e[o];if((0,u.isFunction)(c))t[o]=c.toString();else if((0,u.isObject)(c))t[o]={},E(c,t[o]);else if((0,u.isArray)(c)){const n=t[o]=[];for(let r=0;r<c.length;r++){const i=c[r];(0,u.isObject)(i)?(n[r]={},E(i,n[r])):(0,u.isFunction)(i)?n[r]=i.toString():n[r]=i}}else t[o]=c}return t},ne=/^[A-Za-z_$][A-Za-z0-9_$]*$/,re=e=>`'${String(e).replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\r/g,"\\r").replace(/\n/g,"\\n")}'`,N=e=>{const t=String(e);return(0,L.stringIncludesAny)(t,[`
|
|
2
|
+
`,"'"])?"`"+t.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")+"`":"'"+t.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\r/g,"\\r")+"'"},P=(e={},t=0)=>{if(e===null||typeof e!="object"||e instanceof RegExp)return String(e);let o=!1;for(const r in e){o=!0;break}if(!o)return"{}";const c=" ".repeat(t);let n=`{
|
|
3
|
+
`;for(const r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;const i=e[r],s=ne.test(r)?r:re(r);if(n+=`${c} ${s}: `,i instanceof RegExp)n+=String(i);else if((0,u.isArray)(i)){n+=`[
|
|
4
|
+
`;for(const f of i)f instanceof RegExp?n+=`${c} ${String(f)},
|
|
5
|
+
`:(0,u.isObjectLike)(f)&&f!==null?n+=`${c} ${P(f,t+2)},
|
|
6
|
+
`:(0,u.isString)(f)?n+=`${c} ${N(f)},
|
|
7
|
+
`:n+=`${c} ${f},
|
|
8
|
+
`;n+=`${c} ]`}else(0,u.isObjectLike)(i)?n+=P(i,t+1):(0,u.isString)(i)?n+=N(i):n+=i;n+=`,
|
|
9
|
+
`}return n+=`${c}}`,n},oe=[/^\(\s*\{[^}]*\}\s*\)\s*=>/,/^(\([^)]*\)|[^=]*)\s*=>/,/^function[\s(]/,/^async\s+/,/^\(\s*function/,/^[a-zA-Z_$][a-zA-Z0-9_$]*\s*=>/,/^(?:\*\s*)?[a-zA-Z_$][\w$]*\s*\((?:[^()]|\([^()]*\))*\)\s*\{[\s\S]*\}$/],ce=/^["[{]/,ie=/^(export|import)\s/,k=e=>{if(!e)return!1;const t=e.trim().replace(/\n\s*/g," ").trim();if(t===""||t==="{}"||t==="[]"||ie.test(t)||!oe.some(r=>r.test(t)))return!1;const c=t.charCodeAt(0),n=t.includes("=>");return!(c===123&&!n||c===91||ce.test(t)&&!n)},se=e=>(0,eval)(e),fe=(e,t)=>{const o=/^(\s*(?:async\s+)?function\s*[\w$]*\s*\([^)]*\)\s*)\{/.exec(e);if(!o)return null;const c=o[0].length,n=[];let r=c,i=1,s=null;const f=e.length,l=new RegExp("^(?:const|let|var)\\s+"+t+"\\b");for(;r<f&&i>0;){const y=e[r];if(y==="/"&&e[r+1]==="/"){const d=e.indexOf(`
|
|
10
|
+
`,r);r=d===-1?f:d;continue}if(y==="/"&&e[r+1]==="*"){const d=e.indexOf("*/",r+2);r=d===-1?f:d+2;continue}if(y==='"'||y==="'"||y==="`"){const d=y;for(r++;r<f;){if(e[r]==="\\"){r+=2;continue}if(e[r]===d){r++;break}if(d==="`"&&e[r]==="$"&&e[r+1]==="{"){r+=2;let h=1;for(;r<f&&h>0;)e[r]==="{"?h++:e[r]==="}"&&h--,r++;continue}r++}continue}if(y==="{"){i++,r++;continue}if(y==="}"){i--,r++;continue}if(i===1&&l.test(e.slice(r))){const d=r;let h=0,p=r;for(;p<f;){const g=e[p];if(g==='"'||g==="'"||g==="`"){const m=g;for(p++;p<f;){if(e[p]==="\\"){p+=2;continue}if(e[p]===m){p++;break}p++}continue}if(g==="("||g==="["||g==="{"){h++,p++;continue}if(g===")"||g==="]"||g==="}"){if(h===0)break;h--,p++;continue}if(h===0&&(g===";"||g===`
|
|
11
|
+
`)){p++;break}p++}n.push([d,p]),r=p;continue}r++}if(!n.length)return null;let a=e;for(let y=n.length-1;y>=0;y--)a=a.slice(0,n[y][0])+a.slice(n[y][1]);return a},R=(e,t,o)=>{const c=String(e).trimStart();if(/^(export|import)\s/.test(c))return e;try{return o.window.eval(`(${e})`)}catch(n){const r=n&&n.message?n.message:String(n),i=/await is only valid in async/.test(r),s=/Identifier '([^']+)' has already been declared/.exec(r);let f=null;if(i){const l=String(e).trim();if(/^function[\s(]/.test(l))try{f=o.window.eval("(async "+l+")")}catch{}}else if(s){let l=String(e),a=s[1];for(let y=0;y<5;y++){const d=fe(l,a);if(!d||d===l)break;l=d;try{f=o.window.eval("("+l+")");break}catch(h){const p=/Identifier '([^']+)' has already been declared/.exec(h&&h.message||String(h));if(!p||p[1]!==a)break}}}if(!f&&/Unexpected (token '\{'|identifier)/.test(r))try{const l=o.window.eval("({"+e+"})");if(l&&typeof l=="object"){const a=Object.keys(l);a.length===1&&typeof l[a[0]]=="function"&&(f=l[a[0]])}}catch{}return f||(typeof console<"u"&&console.warn&&console.warn(`[smbls] deepDestringifyFunctions: eval failed on ${t} \u2014 value will be left as a string. Reason: `+r+`.
|
|
12
|
+
First 200 chars of source: `+String(e).slice(0,200)),e)}},ue=(e,t={},o={window:{eval:se}})=>{if(!e||typeof e!="object")return t;const c=[[e,t]];for(;c.length;){const[n,r]=c.pop();for(const i in n){if(!Object.prototype.hasOwnProperty.call(n,i))continue;const s=n[i];if((0,u.isString)(s))k(s)?r[i]=R(s,`"${i}"`,o):r[i]=s;else if((0,u.isArray)(s)){const f=r[i]=[];for(let l=0;l<s.length;l++){const a=s[l];if((0,u.isString)(a))f.push(k(a)?R(a,`array index ${l} (prop "${i}")`,o):a);else if((0,u.isObject)(a)){const y=G(a);if(y)f.push(y);else{const d={};f.push(d),c.push([a,d])}}else f.push(a)}}else if((0,u.isObject)(s)){const f=G(s);if(f){r[i]=f;continue}const l=r[i]&&typeof r[i]=="object"&&!(0,u.isArray)(r[i])?r[i]:r[i]={};c.push([s,l])}else r[i]=s}}return t},D="Set",M="Map",W="RegExp",I="WeakMap",C="WeakSet",b=e=>{const t=Object.keys(e);return t.length===1&&t[0]==="__type"},S=(e,t)=>{if(!e||typeof e!="object")return e;const o=r=>S(r,t||(t=new WeakMap));if(e.__type===D&&(0,u.isArray)(e.values))return new Set(e.values.map(o));if(e.__type===M&&(0,u.isArray)(e.entries))return new Map(e.entries.map(r=>(0,u.isArray)(r)?[o(r[0]),o(r[1])]:r));if(e.__type===I&&b(e))return new WeakMap;if(e.__type===C&&b(e))return new WeakSet;if(e.__type===W&&(0,u.isString)(e.source))try{return new RegExp(e.source,(0,u.isString)(e.flags)?e.flags:"")}catch{return e}if(t||(t=new WeakMap),t.has(e))return t.get(e);let c=!1;if((0,u.isArray)(e)){const r=new Array(e.length);t.set(e,r);for(let i=0;i<e.length;i++)r[i]=S(e[i],t),r[i]!==e[i]&&(c=!0);return c||t.set(e,e),c?r:e}const n={};t.set(e,n);for(const r of Object.keys(e))n[r]=S(e[r],t),n[r]!==e[r]&&(c=!0);return c||t.set(e,e),c?n:e},G=e=>{if(!e||typeof e!="object")return null;const t=e.__type;if(t!==W&&t!==D&&t!==M&&t!==I&&t!==C)return null;const o=S(e);return o===e?null:o},le=e=>{if(!e||typeof e!="object")return e;const t={},o=[];for(const i of Object.keys(e)){const s=e[i];(0,u.isString)(s)&&k(s)?o.push([i,s]):t[i]=S(s)}if(o.length===0)return t;const c=i=>/^[A-Za-z_$][\w$]*$/.test(i),n=o.filter(([i])=>c(i)),r=Object.keys(t).filter(c).map(i=>`var ${i} = __gs__[${JSON.stringify(i)}];`).join(`
|
|
13
|
+
`);try{const i=n.map(([l,a])=>`var ${l} = (${a});`).join(`
|
|
14
|
+
`),s="{ "+n.map(([l])=>`${JSON.stringify(l)}: ${l}`).join(", ")+" }",f=O.window.eval(`(function(__gs__) { ${r}
|
|
15
|
+
${i}
|
|
16
|
+
return ${s}; })`)(t);Object.assign(t,f)}catch{for(const[s,f]of n)try{const l=Object.keys(t).filter(c).map(a=>`var ${a} = __gs__[${JSON.stringify(a)}];`).join(`
|
|
17
|
+
`);t[s]=O.window.eval(`(function(__gs__) { ${l}
|
|
18
|
+
return (${f}); })`)(t)}catch{try{t[s]=O.window.eval(`(${f})`)}catch{t[s]=f}}}for(const[i,s]of o)if(!c(i))try{t[i]=O.window.eval(`(${s})`)}catch{t[i]=s}return t},ae=(e,t={verbose:!0})=>{try{return e?O.window.eval("("+e+")"):{}}catch(o){t.verbose&&console.warn(o)}},pe=(e,...t)=>Object.prototype.hasOwnProperty.call(e,...t),z=e=>{for(const t in e)return!1;return!0},ye=e=>(0,u.isObject)(e)&&z(e),he=()=>Object.create(null),de=(e,t,o={})=>{const c=o.exclude||[],n=o.preventUnderscore;for(const r in t)c.includes(r)||!n&&w(r)||r==="constructor"||r==="prototype"||t[r]!==void 0&&(e[r]=t[r]);return e},ge=(e,t,o=[])=>{const c=o instanceof Set;for(const n in t)w(n)||n==="constructor"||n==="prototype"||(c?o.has(n):o.includes(n))||(e[n]=t[n]);return e},K=(e,t,o={},c=new WeakMap)=>{if(!(0,u.isObjectLike)(e)||!(0,u.isObjectLike)(t)||(0,_.isDOMNode)(e)||(0,_.isDOMNode)(t))return t;if(c.has(e))return c.get(e);c.set(e,e);const n=o.exclude,r=n?n instanceof Set?n:new Set(n):null,i=!o.preventForce;for(const s in t){if(!Object.prototype.hasOwnProperty.call(t,s)||r&&r.has(s)||i&&w(s)||s==="constructor"||s==="prototype")continue;const f=e[s],l=t[s];(0,_.isDOMNode)(l)?e[s]=l:(0,u.isObjectLike)(f)&&(0,u.isObjectLike)(l)?e[s]=K(f,l,o,c):l!==void 0&&(e[s]=l)}return e},Y=(e,t,o=new Set)=>{if(typeof e!="object"||typeof t!="object"||e===null||t===null)return e===t;if(o.has(e)||o.has(t))return!0;o.add(e),o.add(t);const c=Object.keys(e),n=Object.keys(t);if(c.length!==n.length)return!1;for(let r=0;r<c.length;r++){const i=c[r];if(!Object.prototype.hasOwnProperty.call(t,i)||!Y(e[i],t[i],o))return!1}return!0},_e=new Set(["node","__ref"]),we=(e,t,o=_e)=>{if(e===t)return!0;if(!(0,u.isObjectLike)(e)||!(0,u.isObjectLike)(t)||(0,_.isDOMNode)(e)||(0,_.isDOMNode)(t))return e===t;const c=o instanceof Set?o:new Set(o),n=new WeakSet;function r(i,s){if(n.has(s))return!0;n.add(s);for(const f in s){if(!Object.prototype.hasOwnProperty.call(s,f)||c.has(f))continue;if(!Object.prototype.hasOwnProperty.call(i,f))return!1;const l=s[f],a=i[f];if((0,_.isDOMNode)(l)||(0,_.isDOMNode)(a)){if(l!==a)return!1}else if((0,u.isObjectLike)(l)&&(0,u.isObjectLike)(a)){if(!r(a,l))return!1}else if(l!==a)return!1}return!0}return r(e,t)},Oe=(e,t)=>{if(t==null)return e;if((0,u.is)(t)("string","number"))delete e[t];else if((0,u.isArray)(t))for(let o=0;o<t.length;o++)delete e[t[o]];else throw new Error("Invalid input: props must be a string or an array of strings");return e},Z=e=>{if(e===null||typeof e!="object")return e;const t=Object.create(null);for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=Z(e[o]));return t},Se=(e,t)=>{if(e.length===0)return t;const o={};let c=o;for(let n=0;n<e.length;n++)n===e.length-1&&t?c[e[n]]=t:(c[e[n]]={},c=c[e[n]]);return o},ke=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let o=e;for(let n=0;n<t.length-1;n++){if(o[t[n]]===void 0)return;o=o[t[n]]}const c=t[t.length-1];o&&Object.prototype.hasOwnProperty.call(o,c)&&delete o[c]},$e=(e,t,o)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let c=e;for(let n=0;n<t.length-1;n++)(!c[t[n]]||typeof c[t[n]]!="object")&&(c[t[n]]={}),c=c[t[n]];return c[t[t.length-1]]=o,e},xe=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let o=e;for(let c=0;c<t.length;c++){if(o==null)return;o=o[t[c]]}return o},Ee=e=>{let o=[],c=0;for(let n=0;n<e.length;n++)if(o.length<2)o.push(e[n]);else if(e[n]===o[n%2]?c++:(o=[e[n-1],e[n]],c=1),c>=20)return(A==="test"||A==="development")&&console.warn("Warning: Potential infinite loop detected due to repeated sequence:",o),!0},Pe=e=>{const t=new WeakSet;function o(c){if(c&&typeof c=="object"){if(t.has(c))return!0;t.add(c);for(const n in c)if(Object.prototype.hasOwnProperty.call(c,n)&&o(c[n]))return console.log(c,"cycle at "+n),!0}return!1}return o(e)},Ae=(e,t)=>{const o=t instanceof Set?t:new Set(t),c={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&!o.has(n)&&(c[n]=e[n]);return c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var u=Object.defineProperty;var
|
|
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)}
|
package/dist/esm/assets.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a=t=>{const
|
|
1
|
+
const a=t=>{const s=t&&t.src;if(!s||typeof s!="string")return null;const n=t.context;if(!n)return null;const r=n.assets&&n.assets[s]||n.files&&n.files[s];if(!r)return null;if(typeof r=="string")return{src:r,type:null,variants:null};if(typeof r=="object"){if(typeof r.src=="string")return r;const e=r.content,c=e&&e.src;if(typeof c=="string")return{...r,src:c,type:r.type??e.type??null,variants:r.variants??e.variants??null}}return null},i=(t,{keepOneX:s=!0}={})=>{if(!Array.isArray(t)||!t.length)return"";const n=t.some(e=>typeof e.width=="number"),r=[];for(const e of t)n&&typeof e.width=="number"?r.push(`${e.src} ${e.width}w`):n||(e.scale===1&&s?r.push(e.src):e.scale&&e.scale!==1&&r.push(`${e.src} ${e.scale}x`));return r.join(", ")},l=t=>{if(!t||!Array.isArray(t.variants))return"";const s=t.variants.filter(n=>n.format===t.type);return i(s,{keepOneX:!1})},p=(t,s)=>{if(!t||typeof t!="object"||typeof t.src!="string")return[];if(!Array.isArray(t.variants)||!t.variants.length)return[{tag:"img",attr:{src:t.src,alt:s||""}}];const n=new Map;for(const o of t.variants)n.has(o.format)||n.set(o.format,[]),n.get(o.format).push(o);const r=[];for(const[o,u]of n)o!==t.type&&r.push({tag:"source",attr:{type:o,srcset:i(u,{keepOneX:!0})}});const e=n.get(t.type)||[],c=i(e,{keepOneX:!1}),f={src:t.src,alt:s||""};return c&&(f.srcset=c),[...r,{tag:"img",attr:f}]};export{l as buildImgSrcset,p as buildSourcesAndImg,a as resolveAsset,i as srcsetFor};
|
package/dist/esm/extends.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{joinArrays as
|
|
1
|
+
import{joinArrays as P,removeDuplicatesInArray as O}from"./array.js";import{matchesComponentNaming as E}from"./component.js";import{deepClone as R,exec as W}from"./object.js";import{isArray as u,isObject as a,isString as g}from"./types.js";const v="production",b=t=>t.sourcemap!==!1&&v!=="production",C=t=>{if(!t)return[];const r=[],s=t.extends;s&&(u(s)?r.push(...s):r.push(s));const n=t.extend;return n&&(u(n)?r.push(...n):r.push(n)),r},p=t=>{if(!u(t))return t;const r=[];for(let s=t.length-1;s>=0;s--){const n=t[s];r.push(u(n)?p(n):n)}return r},G=t=>{if(t.includes("+"))return t.split("+").filter(E);if(t.includes("_")){const[r]=t.split("_");return[r]}if(t.includes(".")&&!E(t.split(".")[1])){const[r]=t.split(".");return[r]}return[t]},m=(t,r,s)=>{let n=[];const o=G(s);o&&(n=[...o]);const e=p(C(t));return e.length&&(n=[...n,...e]),n},x=(t,r)=>{const{__ref:s}=r;let{__extends:n}=s;if(!t)return n;const o=r.variant,e=r.context;if(o&&e?.components&&!Array.isArray(t)&&typeof t=="string"){const i=`${t}.${o}`;e.components[i]&&(t=i)}return n.includes(t)||(n=Array.isArray(t)?[...n,...t]:[...n,t],s.__extends=n),n},tt=(t,r)=>{if(!t)return r;const{extends:s}=r,n=u(s)?s:[s],o=u(t)?t:[t];return{...r,extends:P(o,n)}},M=()=>Math.random().toString(36).substring(2),K={},rt={},j=t=>K[t.__hash],z=(t,r)=>{const s=M();return g(t)||(t.__hash=s),s!=="__proto__"&&s!=="constructor"&&s!=="prototype"&&(K[s]=r),r},F=(t,r)=>t.__hash?r.concat(j(t)):z(t,r),D=(t,r,s,n=new Set,o,e)=>{for(const i of t)u(i)?D(i,r,s,n,o,e):A(i,r,s,n,o,void 0,e);return r},L=(t,r,s,n=new Set,o,e,i)=>{const c=C(t),f={...t};delete f.extends,delete f.extend;let d=!1;for(const _ in f){d=!0;break}return d&&(r.push(f),o&&o.push(e)),c.length&&A(p(c),r,s,n,o,e,i),r},A=(t,r,s,n=new Set,o,e,i)=>{if(!t||n.has(t))return r;if(u(t))return D(t,r,s,n,o,i);let c=e;return g(t)?(c=t,t=I(t,s)):i&&a(t)&&i.has(t)&&(c=i.get(t)),n.has(t)||(n.add(t),t?.extends||t?.extend?L(t,r,s,n,o,c,i):t&&(r.push(t),o&&o.push(c))),r},X=new Set(["parent","node","__ref","__proto__","extends","extend","childExtends","childExtendsRecursive"]),h=(t,r,s,n,o)=>{r=R(r);for(const e in r){if(X.has(e))continue;const i=t[e],c=r[e];if(c!==void 0&&Object.prototype.hasOwnProperty.call(r,e)&&e!=="__proto__"&&e!=="constructor"&&e!=="prototype"){if(i===void 0)t[e]=c,s&&n?a(c)&&!u(c)?(s[e]=s[e]||{},$(s[e],c,n)):s[e]=n:s&&o?.[e]&&(s[e]=o[e]);else if(a(i)&&a(c)){const f=s?s[e]=s[e]||{}:void 0,d=o?.[e];E(e)?t[e]=h(i,c,f,n,d):h(i,c,f,n,d)}if(e==="extends"||e==="childExtends"||e==="childExtendsRecursive"){if(u(i)&&u(c))t[e]=i.concat(c);else if(u(i)&&a(c)){const f=h({},i);t[e]=h(f,c)}}}}return t},$=(t,r,s,n)=>{if(n||(n=new WeakSet),!n.has(r)){n.add(r);for(const o in r){if(!Object.prototype.hasOwnProperty.call(r,o)||o==="__proto__"||o==="constructor"||o==="prototype")continue;const e=r[o];a(e)&&!u(e)?(t[o]=t[o]||{},$(t[o],e,s,n)):t[o]=s}}},H=(t,r,s)=>t.reduce((n,o,e)=>{const i=R(o),c=s?s[e]:void 0;return h(n,i,r,c)},{}),I=(t,r,s={},n)=>{const o=r?.components||s.components,e=r?.pages||s.pages;if(g(t)){const i=o&&(o[t+"."+n]||o[t]||o["smbls."+t]),c=e&&t.charCodeAt(0)===47&&e[t];if(i)return i;if(c)return c;s.verbose&&(v==="test"||v==="development")&&console.warn("Extend is string but component was not found:",t);return}return t},nt=(t,r)=>[].concat(t.slice(0,1)).concat(r.slice(0,1)).concat(t.slice(1)).concat(r.slice(1)),N=(t,r,s,n)=>{if(!t)return[];if(t.__hash)return j(t)||[];const e=A(t,[],r,new Set,s,void 0,n);return s?e:F(t,e)},st=(t,r)=>{if(!t)return r;const s=u(t)?t:[t];return P(s,r)},ot=t=>{let r=[];function s(n){for(const o in n)Object.prototype.hasOwnProperty.call(n,o)&&(E(o)&&r.push(o),o==="extends"&&(typeof n[o]=="string"?r.push(n[o]):Array.isArray(n[o])&&(r=r.concat(n[o]))),typeof n[o]=="object"&&n[o]!==null&&s(n[o]))}return s(t),r},q=(t,r,s={})=>{const{__ref:n}=t,o=t.context||r.context,e=t.variant,i=C(t);if(i.length){const c=p(i),[f,...d]=c,_=typeof f=="string"&&e&&o?.components?`${f}.${e}`:null;_&&o.components[_]?x([_,...d],t):x(c,t)}return J(t,r,s),Q(t,r,s),U(t,r,s),t.component&&x(p(W(t.component,t)),t),o.defaultExtends&&x(p(o.defaultExtends),t),O(n.__extends)},J=(t,r,s={})=>{const{__ref:n}=t;return s.ignoreChildExtends||t.ignoreChildExtends||r.childProps?.extends&&x(p(r.childProps.extends),t),n.__extends},Q=(t,r,s={})=>{const{__ref:n}=t,o=s.ignoreChildExtends||t.ignoreChildExtends,e=r.childExtends;return!o&&e&&x(p(e),t),n.__extends},U=(t,r,s={})=>{const{__ref:n}=t,o=r.childExtendsRecursive,e=s.ignoreChildExtendsRecursive||t.ignoreChildExtendsRecursive,i=t.key==="__text";return o&&!i&&!e&&x(p(o),t),n.__extends},Y=(t,r,s={})=>{const{__ref:n}=t,o=t.context||r.context,e=t.variant,i=b(s),c=i?[...n.__extends]:null,f=O(n.__extends.map((d,_)=>I(d,o,s,_===0&&e)));if(i){const d=new WeakMap;for(let l=0;l<f.length;l++){const y=f[l],S=c[l];y&&a(y)&&g(S)&&d.set(y,S)}const _=[],T=N(f,o,_,d);n.__extendsStack=T,n.__extendsNames=_}else{const d=N(f,o);n.__extendsStack=d}return n.__extendsStack},Z=(t,r,s={})=>{const{__ref:n}=t,{__extendsStack:o}=n;if(b(s)){const e={},i=n.__extendsNames||[],c=H(o,e,i),f={};h(t,c,f,void 0,e),n.__sourcemap=f}else{const e=H(o);h(t,e)}return t},et=(t,r,s={})=>(q(t,r,s),Y(t,r,s),Z(t,r,s),t);export{st as addExtend,x as addExtends,et as applyExtends,H as cloneAndMergeArrayExtend,C as collectExtendsList,tt as concatAddExtends,q as createElementExtends,m as createExtends,G as createExtendsFromKeys,Y as createExtendsStack,L as deepExtend,h as deepMergeExtends,rt as extendCachedRegistry,K as extendStackRegistry,D as extractArrayExtend,Z as finalizeExtends,A as flattenExtend,M as generateHash,ot as getExtendsInElement,N as getExtendsStack,F as getExtendsStackRegistry,j as getHashedExtend,Q as inheritChildExtends,J as inheritChildPropsExtends,U as inheritRecursiveChildExtends,nt as jointStacks,I as mapStringsWithContextComponents,z as setHashedExtend,p as toPriorityOrder};
|
package/dist/esm/methods.js
CHANGED
|
@@ -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}from"./object.js";import{isProduction as b}from"./env.js";import{removeValueFromArray as C}from"./array.js";import{OPTIONS as j}from"./cache.js";const a="production";function K(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 X(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 q(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 tt(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 Q(e={}){const t=this;if(t.node?.style){for(const n in e){const o=e[n],r=t[n];if(P(o)&&r)Q.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 et(e){const t=this;if(m("beforeRemove",t,e)===!1)return t;p(t.node.remove)?t.node.remove():b()||(console.warn("This item cant be removed"),t.log()),delete t.parent[t.key],t.parent.__ref&&(t.parent.__ref.__children=C(t.parent.__ref.__children,t.key)),m("remove",t,e)}function nt(e){return this[e]}function ot(e,t){const n=this;if(e)return n.update(e,t),n}function rt(e){return e?this.__ref&&this.__ref[e]:this.__ref}function st(){
|
|
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 dt(...e){(a==="test"||a==="development")&&console.log(...e)}function _t(...e){(a==="test"||a==="development")&&console.warn(...e)}function
|
|
3
|
-
${
|
|
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}from"./object.js";import{isProduction as b}from"./env.js";import{removeValueFromArray as C}from"./array.js";import{OPTIONS as j}from"./cache.js";const a="production";function K(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 X(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 q(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 tt(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 Q(e={}){const t=this;if(t.node?.style){for(const n in e){const o=e[n],r=t[n];if(P(o)&&r)Q.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 et(e){const t=this;if(m("beforeRemove",t,e)===!1)return t;p(t.node.remove)?t.node.remove():b()||(console.warn("This item cant be removed"),t.log()),delete t.parent[t.key],t.parent.__ref&&(t.parent.__ref.__children=C(t.parent.__ref.__children,t.key)),m("remove",t,e)}function nt(e){return this[e]}function ot(e,t){const n=this;if(e)return n.update(e,t),n}function rt(e){return e?this.__ref&&this.__ref[e]:this.__ref}function st(){const e=this.getRef("__children");return Array.isArray(e)?e.map(t=>this[t]):[]}function it(){return this.getRef().path}let y=null;const ct=e=>{y=e||null},v=()=>y||null;function lt(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 ft(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 ut(e){return this.getRoot("data")&&Object.keys(this.getRoot("data")).length>0&&e?this.getRoot("data")[e]:this.getRoot("data")}function at(e){const t=this.getRoot()?.context;return e?t[e]:t}function ht(e){const t=this.context;return e?t[e]:t}const pt=(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)||R.has(n)&&!k.has(n)||t.push(n);return t}function D(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 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=D.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 T(...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 dt(...e){(a==="test"||a==="development")&&console.log(...e)}function _t(...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&&T.call(this),new Error(...e)}}function gt(){const e=this,{key:t,parent:n}=e,{__children:o}=n.__ref,r=o.indexOf(t),s=o[r+1];return n[s]}function mt(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 xt(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 yt(e,...t){const n=this.context,o=n.utils?.[e]||n.functions?.[e]||n.methods?.[e]||n.snippets?.[e];if(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 vt(){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 wt(e){const t=this,n=e||j.useStateQuery||t.context?.useStateQuery;if(!n)return null;const o={};if(g(t,o),n===!0)return o;const r=B[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)}
|
|
4
4
|
${n}}`).join(`
|
|
5
5
|
`):""},L=e=>`{
|
|
6
|
-
${
|
|
6
|
+
${O(e,1)}
|
|
7
7
|
}`,F=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},M=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("&")},J=(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?`
|
|
8
8
|
`+o.join(`
|
|
9
9
|
`):"";return`SELECT ${l}
|
|
10
|
-
FROM ${c}${f}`},V=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},B={graphql:L,"json-api":F,odata:M,sql:J,paths:V};function
|
|
10
|
+
FROM ${c}${f}`},V=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},B={graphql:L,"json-api":F,odata:M,sql:J,paths:V};function St(e,t){return!!($.has(e)||t?.context?.methods?.[e])}export{yt as call,pt as defineSetter,S as error,nt as get,st as getChildren,ht as getContext,vt as getDB,it as getPath,wt as getQuery,rt as getRef,ft as getRoot,at as getRootContext,ut as getRootData,lt as getRootState,St as isMethod,N as keys,dt as log,q as lookdown,tt as lookdownAll,X as lookup,gt as nextElement,D as parse,w as parseDeep,mt as previousElement,et as remove,ct as setActiveRootState,Q as setNodeStyles,ot as setProps,K as spotByPath,xt as variables,T as verbose,_t as warn};
|
package/dist/esm/object.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import{window as
|
|
2
|
-
|
|
3
|
-
`;for(const
|
|
4
|
-
|
|
5
|
-
`:
|
|
6
|
-
`:r+=`${
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
`}return r+=`${
|
|
10
|
-
`,n);n=h===-1?
|
|
11
|
-
`)){a++;break}a++}r.push([h,a]),n=a;continue}n++}if(!r.length)return null;let l=e;for(let p=r.length-1;p>=0;p--)l=l.slice(0,r[p][0])+l.slice(r[p][1]);return l},
|
|
12
|
-
First 200 chars of source: `+String(e).slice(0,200)),e)}},
|
|
13
|
-
`);try{const
|
|
14
|
-
`),
|
|
15
|
-
${
|
|
16
|
-
return ${
|
|
17
|
-
`);t[
|
|
18
|
-
return (${
|
|
1
|
+
import{window as $}from"./globals.js";import{isFunction as E,isObjectLike as g,isObject as k,isArray as _,isString as O,is as K}from"./types.js";import{unstackArrayOfObjects as Y}from"./array.js";import{stringIncludesAny as Z}from"./string.js";import{isDOMNode as w}from"./node.js";import{METHODS_EXL as m}from"./keys.js";const A="production",S=e=>e.charCodeAt(0)===95&&e.charCodeAt(1)===95,T=(e,t,o,c)=>{if(E(e))return t?typeof e.call!="function"?e:e.call(t,t,o||t.state,c||t.context):void 0;if(e!=null&&t?.context?.plugins&&(_(e)||k(e)&&!w(e))){const r=t.context.plugins;for(const n of r)if(n.resolveHandler){const i=n.resolveHandler(e,t);if(typeof i=="function")return T(i,t,o,c)}}return e},ue=(e,t,o)=>{for(const c in t)e[c]=T(t[c],o)},le=(e,t,o=[])=>{const c=o instanceof Set;for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(S(r)||(c?o.has(r):o.includes(r))||e[r]===void 0&&(e[r]=t[r]));return e},ae=(e,t,o=m)=>N(e,t,o,null),N=(e,t,o,c)=>{if(e===t)return e;if(c){for(let n=0;n<c.length;n+=2)if(c[n]===e&&c[n+1]===t)return e}const r=o instanceof Set;for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n)||S(n)||n==="constructor"||n==="prototype"||(r?o.has(n):o.includes(n)))continue;const i=e[n],s=t[n];if(g(i)&&g(s)){const f=c||[];f.push(e,t),N(i,s,o,f),f.length-=2}else i===void 0&&(e[n]=s)}return e},pe=(e,t=[])=>{const o=t instanceof Set,c={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(S(r)||(o?t.has(r):t.includes(r))||(c[r]=e[r]));return c},ye=(e,t={})=>{const{exclude:o=[],cleanUndefined:c=!1,cleanNull:r=!1,visited:n=new WeakMap,handleExtends:i=!1}=t;if(!g(e)||w(e))return e;if(n.has(e))return n.get(e);const s=o instanceof Set?o:o.length>3?new Set(o):null,f=p=>s?s.has(p):o.includes(p),u=_(e)?[]:{};n.set(e,u);const l=[[e,u]];for(;l.length;){const[p,h]=l.pop();for(const y in p){if(!Object.prototype.hasOwnProperty.call(p,y)||S(y)||y==="__proto__"||f(y))continue;const a=p[y];if(!(c&&a===void 0)&&!(r&&a===null)){if(w(a)){h[y]=a;continue}if(i&&y==="extends"&&_(a)){h[y]=Y(a,o);continue}if(E(a)){h[y]=a;continue}if(g(a))if(n.has(a))h[y]=n.get(a);else{const d=_(a)?[]:{};n.set(a,d),h[y]=d,l.push([a,d])}else h[y]=a}}}return u},R=(e,t={})=>{(e.node||e.__ref||e.parent||e.__element||e.parse)&&((e.__element||e.parent?.__element).warn("Trying to clone element or state at",e),e=e.parse?.());for(const o in e){const c=e[o];if(E(c))t[o]=c.toString();else if(k(c))t[o]={},R(c,t[o]);else if(_(c)){const r=t[o]=[];for(let n=0;n<c.length;n++){const i=c[n];k(i)?(r[n]={},R(i,r[n])):E(i)?r[n]=i.toString():r[n]=i}}else t[o]=c}return t},B=/^[A-Za-z_$][A-Za-z0-9_$]*$/,J=e=>`'${String(e).replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\r/g,"\\r").replace(/\n/g,"\\n")}'`,D=e=>{const t=String(e);return Z(t,[`
|
|
2
|
+
`,"'"])?"`"+t.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")+"`":"'"+t.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\r/g,"\\r")+"'"},M=(e={},t=0)=>{if(e===null||typeof e!="object"||e instanceof RegExp)return String(e);let o=!1;for(const n in e){o=!0;break}if(!o)return"{}";const c=" ".repeat(t);let r=`{
|
|
3
|
+
`;for(const n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;const i=e[n],s=B.test(n)?n:J(n);if(r+=`${c} ${s}: `,i instanceof RegExp)r+=String(i);else if(_(i)){r+=`[
|
|
4
|
+
`;for(const f of i)f instanceof RegExp?r+=`${c} ${String(f)},
|
|
5
|
+
`:g(f)&&f!==null?r+=`${c} ${M(f,t+2)},
|
|
6
|
+
`:O(f)?r+=`${c} ${D(f)},
|
|
7
|
+
`:r+=`${c} ${f},
|
|
8
|
+
`;r+=`${c} ]`}else g(i)?r+=M(i,t+1):O(i)?r+=D(i):r+=i;r+=`,
|
|
9
|
+
`}return r+=`${c}}`,r},U=[/^\(\s*\{[^}]*\}\s*\)\s*=>/,/^(\([^)]*\)|[^=]*)\s*=>/,/^function[\s(]/,/^async\s+/,/^\(\s*function/,/^[a-zA-Z_$][a-zA-Z0-9_$]*\s*=>/,/^(?:\*\s*)?[a-zA-Z_$][\w$]*\s*\((?:[^()]|\([^()]*\))*\)\s*\{[\s\S]*\}$/],V=/^["[{]/,H=/^(export|import)\s/,P=e=>{if(!e)return!1;const t=e.trim().replace(/\n\s*/g," ").trim();if(t===""||t==="{}"||t==="[]"||H.test(t)||!U.some(n=>n.test(t)))return!1;const c=t.charCodeAt(0),r=t.includes("=>");return!(c===123&&!r||c===91||V.test(t)&&!r)},X=e=>(0,eval)(e),v=(e,t)=>{const o=/^(\s*(?:async\s+)?function\s*[\w$]*\s*\([^)]*\)\s*)\{/.exec(e);if(!o)return null;const c=o[0].length,r=[];let n=c,i=1,s=null;const f=e.length,u=new RegExp("^(?:const|let|var)\\s+"+t+"\\b");for(;n<f&&i>0;){const p=e[n];if(p==="/"&&e[n+1]==="/"){const h=e.indexOf(`
|
|
10
|
+
`,n);n=h===-1?f:h;continue}if(p==="/"&&e[n+1]==="*"){const h=e.indexOf("*/",n+2);n=h===-1?f:h+2;continue}if(p==='"'||p==="'"||p==="`"){const h=p;for(n++;n<f;){if(e[n]==="\\"){n+=2;continue}if(e[n]===h){n++;break}if(h==="`"&&e[n]==="$"&&e[n+1]==="{"){n+=2;let y=1;for(;n<f&&y>0;)e[n]==="{"?y++:e[n]==="}"&&y--,n++;continue}n++}continue}if(p==="{"){i++,n++;continue}if(p==="}"){i--,n++;continue}if(i===1&&u.test(e.slice(n))){const h=n;let y=0,a=n;for(;a<f;){const d=e[a];if(d==='"'||d==="'"||d==="`"){const z=d;for(a++;a<f;){if(e[a]==="\\"){a+=2;continue}if(e[a]===z){a++;break}a++}continue}if(d==="("||d==="["||d==="{"){y++,a++;continue}if(d===")"||d==="]"||d==="}"){if(y===0)break;y--,a++;continue}if(y===0&&(d===";"||d===`
|
|
11
|
+
`)){a++;break}a++}r.push([h,a]),n=a;continue}n++}if(!r.length)return null;let l=e;for(let p=r.length-1;p>=0;p--)l=l.slice(0,r[p][0])+l.slice(r[p][1]);return l},W=(e,t,o)=>{const c=String(e).trimStart();if(/^(export|import)\s/.test(c))return e;try{return o.window.eval(`(${e})`)}catch(r){const n=r&&r.message?r.message:String(r),i=/await is only valid in async/.test(n),s=/Identifier '([^']+)' has already been declared/.exec(n);let f=null;if(i){const u=String(e).trim();if(/^function[\s(]/.test(u))try{f=o.window.eval("(async "+u+")")}catch{}}else if(s){let u=String(e),l=s[1];for(let p=0;p<5;p++){const h=v(u,l);if(!h||h===u)break;u=h;try{f=o.window.eval("("+u+")");break}catch(y){const a=/Identifier '([^']+)' has already been declared/.exec(y&&y.message||String(y));if(!a||a[1]!==l)break}}}if(!f&&/Unexpected (token '\{'|identifier)/.test(n))try{const u=o.window.eval("({"+e+"})");if(u&&typeof u=="object"){const l=Object.keys(u);l.length===1&&typeof u[l[0]]=="function"&&(f=u[l[0]])}}catch{}return f||(typeof console<"u"&&console.warn&&console.warn(`[smbls] deepDestringifyFunctions: eval failed on ${t} \u2014 value will be left as a string. Reason: `+n+`.
|
|
12
|
+
First 200 chars of source: `+String(e).slice(0,200)),e)}},he=(e,t={},o={window:{eval:X}})=>{if(!e||typeof e!="object")return t;const c=[[e,t]];for(;c.length;){const[r,n]=c.pop();for(const i in r){if(!Object.prototype.hasOwnProperty.call(r,i))continue;const s=r[i];if(O(s))P(s)?n[i]=W(s,`"${i}"`,o):n[i]=s;else if(_(s)){const f=n[i]=[];for(let u=0;u<s.length;u++){const l=s[u];if(O(l))f.push(P(l)?W(l,`array index ${u} (prop "${i}")`,o):l);else if(k(l)){const p=q(l);if(p)f.push(p);else{const h={};f.push(h),c.push([l,h])}}else f.push(l)}}else if(k(s)){const f=q(s);if(f){n[i]=f;continue}const u=n[i]&&typeof n[i]=="object"&&!_(n[i])?n[i]:n[i]={};c.push([s,u])}else n[i]=s}}return t},I="Set",C="Map",b="RegExp",G="WeakMap",F="WeakSet",L=e=>{const t=Object.keys(e);return t.length===1&&t[0]==="__type"},x=(e,t)=>{if(!e||typeof e!="object")return e;const o=n=>x(n,t||(t=new WeakMap));if(e.__type===I&&_(e.values))return new Set(e.values.map(o));if(e.__type===C&&_(e.entries))return new Map(e.entries.map(n=>_(n)?[o(n[0]),o(n[1])]:n));if(e.__type===G&&L(e))return new WeakMap;if(e.__type===F&&L(e))return new WeakSet;if(e.__type===b&&O(e.source))try{return new RegExp(e.source,O(e.flags)?e.flags:"")}catch{return e}if(t||(t=new WeakMap),t.has(e))return t.get(e);let c=!1;if(_(e)){const n=new Array(e.length);t.set(e,n);for(let i=0;i<e.length;i++)n[i]=x(e[i],t),n[i]!==e[i]&&(c=!0);return c||t.set(e,e),c?n:e}const r={};t.set(e,r);for(const n of Object.keys(e))r[n]=x(e[n],t),r[n]!==e[n]&&(c=!0);return c||t.set(e,e),c?r:e},q=e=>{if(!e||typeof e!="object")return null;const t=e.__type;if(t!==b&&t!==I&&t!==C&&t!==G&&t!==F)return null;const o=x(e);return o===e?null:o},de=e=>{if(!e||typeof e!="object")return e;const t={},o=[];for(const i of Object.keys(e)){const s=e[i];O(s)&&P(s)?o.push([i,s]):t[i]=x(s)}if(o.length===0)return t;const c=i=>/^[A-Za-z_$][\w$]*$/.test(i),r=o.filter(([i])=>c(i)),n=Object.keys(t).filter(c).map(i=>`var ${i} = __gs__[${JSON.stringify(i)}];`).join(`
|
|
13
|
+
`);try{const i=r.map(([u,l])=>`var ${u} = (${l});`).join(`
|
|
14
|
+
`),s="{ "+r.map(([u])=>`${JSON.stringify(u)}: ${u}`).join(", ")+" }",f=$.eval(`(function(__gs__) { ${n}
|
|
15
|
+
${i}
|
|
16
|
+
return ${s}; })`)(t);Object.assign(t,f)}catch{for(const[s,f]of r)try{const u=Object.keys(t).filter(c).map(l=>`var ${l} = __gs__[${JSON.stringify(l)}];`).join(`
|
|
17
|
+
`);t[s]=$.eval(`(function(__gs__) { ${u}
|
|
18
|
+
return (${f}); })`)(t)}catch{try{t[s]=$.eval(`(${f})`)}catch{t[s]=f}}}for(const[i,s]of o)if(!c(i))try{t[i]=$.eval(`(${s})`)}catch{t[i]=s}return t},ge=(e,t={verbose:!0})=>{try{return e?$.eval("("+e+")"):{}}catch(o){t.verbose&&console.warn(o)}},_e=(e,...t)=>Object.prototype.hasOwnProperty.call(e,...t),Q=e=>{for(const t in e)return!1;return!0},we=e=>k(e)&&Q(e),Oe=()=>Object.create(null),Se=(e,t,o={})=>{const c=o.exclude||[],r=o.preventUnderscore;for(const n in t)c.includes(n)||!r&&S(n)||n==="constructor"||n==="prototype"||t[n]!==void 0&&(e[n]=t[n]);return e},ke=(e,t,o=[])=>{const c=o instanceof Set;for(const r in t)S(r)||r==="constructor"||r==="prototype"||(c?o.has(r):o.includes(r))||(e[r]=t[r]);return e},j=(e,t,o={},c=new WeakMap)=>{if(!g(e)||!g(t)||w(e)||w(t))return t;if(c.has(e))return c.get(e);c.set(e,e);const r=o.exclude,n=r?r instanceof Set?r:new Set(r):null,i=!o.preventForce;for(const s in t){if(!Object.prototype.hasOwnProperty.call(t,s)||n&&n.has(s)||i&&S(s)||s==="constructor"||s==="prototype")continue;const f=e[s],u=t[s];w(u)?e[s]=u:g(f)&&g(u)?e[s]=j(f,u,o,c):u!==void 0&&(e[s]=u)}return e},ee=(e,t,o=new Set)=>{if(typeof e!="object"||typeof t!="object"||e===null||t===null)return e===t;if(o.has(e)||o.has(t))return!0;o.add(e),o.add(t);const c=Object.keys(e),r=Object.keys(t);if(c.length!==r.length)return!1;for(let n=0;n<c.length;n++){const i=c[n];if(!Object.prototype.hasOwnProperty.call(t,i)||!ee(e[i],t[i],o))return!1}return!0},te=new Set(["node","__ref"]),$e=(e,t,o=te)=>{if(e===t)return!0;if(!g(e)||!g(t)||w(e)||w(t))return e===t;const c=o instanceof Set?o:new Set(o),r=new WeakSet;function n(i,s){if(r.has(s))return!0;r.add(s);for(const f in s){if(!Object.prototype.hasOwnProperty.call(s,f)||c.has(f))continue;if(!Object.prototype.hasOwnProperty.call(i,f))return!1;const u=s[f],l=i[f];if(w(u)||w(l)){if(u!==l)return!1}else if(g(u)&&g(l)){if(!n(l,u))return!1}else if(u!==l)return!1}return!0}return n(e,t)},xe=(e,t)=>{if(t==null)return e;if(K(t)("string","number"))delete e[t];else if(_(t))for(let o=0;o<t.length;o++)delete e[t[o]];else throw new Error("Invalid input: props must be a string or an array of strings");return e},ne=e=>{if(e===null||typeof e!="object")return e;const t=Object.create(null);for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=ne(e[o]));return t},Ee=(e,t)=>{if(e.length===0)return t;const o={};let c=o;for(let r=0;r<e.length;r++)r===e.length-1&&t?c[e[r]]=t:(c[e[r]]={},c=c[e[r]]);return o},Pe=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let o=e;for(let r=0;r<t.length-1;r++){if(o[t[r]]===void 0)return;o=o[t[r]]}const c=t[t.length-1];o&&Object.prototype.hasOwnProperty.call(o,c)&&delete o[c]},Ae=(e,t,o)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let c=e;for(let r=0;r<t.length-1;r++)(!c[t[r]]||typeof c[t[r]]!="object")&&(c[t[r]]={}),c=c[t[r]];return c[t[t.length-1]]=o,e},Te=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let o=e;for(let c=0;c<t.length;c++){if(o==null)return;o=o[t[c]]}return o},Ne=e=>{let o=[],c=0;for(let r=0;r<e.length;r++)if(o.length<2)o.push(e[r]);else if(e[r]===o[r%2]?c++:(o=[e[r-1],e[r]],c=1),c>=20)return(A==="test"||A==="development")&&console.warn("Warning: Potential infinite loop detected due to repeated sequence:",o),!0},Re=e=>{const t=new WeakSet;function o(c){if(c&&typeof c=="object"){if(t.has(c))return!0;t.add(c);for(const r in c)if(Object.prototype.hasOwnProperty.call(c,r)&&o(c[r]))return console.log(c,"cycle at "+r),!0}return!1}return o(e)},De=(e,t)=>{const o=t instanceof Set?t:new Set(t),c={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&!o.has(r)&&(c[r]=e[r]);return c};export{pe as clone,Ee as createNestedObject,ne as createObjectWithoutPrototype,ye as deepClone,$e as deepContains,he as deepDestringifyFunctions,ae as deepMerge,R as deepStringifyFunctions,de as destringifyGlobalScope,Ne as detectInfiniteLoop,De as excludeKeysFromObject,T as exec,Te as getInObjectByPath,P as hasFunction,_e as hasOwnProperty,Re as isCyclic,Q as isEmpty,we as isEmptyObject,ee as isEqualDeep,Oe as makeObjectWithoutPrototype,ue as map,le as merge,M as objectToString,Se as overwrite,j as overwriteDeep,ke as overwriteShallow,xe as removeFromObject,Pe as removeNestedKeyByPath,Ae as setInObjectByPath,ge as stringToObject};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isObject as a,isString as y}from"./types.js";const
|
|
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};
|
package/extends.js
CHANGED
|
@@ -7,6 +7,59 @@ import { isArray, isObject, isString } from './types.js'
|
|
|
7
7
|
const ENV = process.env.NODE_ENV
|
|
8
8
|
const isSourcemapEnabled = (options) => options.sourcemap !== false && ENV !== 'production'
|
|
9
9
|
|
|
10
|
+
// ── PRECEDENCE LAW ────────────────────────────────────────────────────────
|
|
11
|
+
// FW-EXTENDS-ARRAY-TWO-RESOLVERS-OPPOSITE-PRECEDENCE-1.
|
|
12
|
+
//
|
|
13
|
+
// In an AUTHORED `extends: [A, B]` array the LAST entry is the DOMINANT
|
|
14
|
+
// base: later entries override earlier ones, exactly like later CSS
|
|
15
|
+
// declarations. That is the original DOMQL design, it is what the runtime
|
|
16
|
+
// resolver (`packages/element/src/extends.js` → `mergeBase`, "later extends
|
|
17
|
+
// override earlier") has always done, and it is the law both resolvers now
|
|
18
|
+
// implement. The shared fixture `__tests__/fixtures/extendsPrecedence.js`
|
|
19
|
+
// runs BOTH of them and fails if they ever disagree again.
|
|
20
|
+
//
|
|
21
|
+
// The stack this module builds is the OPPOSITE convention — a PRIORITY list
|
|
22
|
+
// where the earlier entry wins (`deepMergeExtends` only fills keys that are
|
|
23
|
+
// still undefined, and `deepExtend` pushes a component before its own
|
|
24
|
+
// ancestors so a descendant beats what it extends). The composed
|
|
25
|
+
// `__ref.__extends` ladder relies on it: key-derived extends outrank the
|
|
26
|
+
// element's own `extends`, which outrank `childProps.extends`, then
|
|
27
|
+
// `childExtends`, then `childExtendsRecursive`, then `component`, and
|
|
28
|
+
// `context.defaultExtends` stays last (lowest).
|
|
29
|
+
//
|
|
30
|
+
// So an authored array is REVERSED as it enters the ladder. That is the one
|
|
31
|
+
// and only place the two conventions meet — never reverse the ladder itself.
|
|
32
|
+
// ──────────────────────────────────────────────────────────────────────────
|
|
33
|
+
|
|
34
|
+
// The runtime resolver collects entries from BOTH `extends` (plural) and
|
|
35
|
+
// `extend` (singular) — see `collectExtendsList` in
|
|
36
|
+
// `packages/element/src/extends.js` (FT-FRAMEWORK-EXTEND-CUSTOM: a page that
|
|
37
|
+
// used `extends: 'Page'` for route mode and `extend: 'BlogArticle'` for the
|
|
38
|
+
// article shell resolved only one of them). This resolver used to read
|
|
39
|
+
// `extends` only, so the same definition resolved differently here.
|
|
40
|
+
// `extend` comes AFTER `extends`, so under the law above it dominates.
|
|
41
|
+
export const collectExtendsList = definition => {
|
|
42
|
+
if (!definition) return []
|
|
43
|
+
const list = []
|
|
44
|
+
const plural = definition.extends
|
|
45
|
+
if (plural) isArray(plural) ? list.push(...plural) : list.push(plural)
|
|
46
|
+
const singular = definition.extend
|
|
47
|
+
if (singular) isArray(singular) ? list.push(...singular) : list.push(singular)
|
|
48
|
+
return list
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// An authored extends value, in PRIORITY order (highest first) — see the
|
|
52
|
+
// PRECEDENCE LAW above. Non-arrays pass through untouched.
|
|
53
|
+
export const toPriorityOrder = extendsValue => {
|
|
54
|
+
if (!isArray(extendsValue)) return extendsValue
|
|
55
|
+
const ordered = []
|
|
56
|
+
for (let i = extendsValue.length - 1; i >= 0; i--) {
|
|
57
|
+
const each = extendsValue[i]
|
|
58
|
+
ordered.push(isArray(each) ? toPriorityOrder(each) : each)
|
|
59
|
+
}
|
|
60
|
+
return ordered
|
|
61
|
+
}
|
|
62
|
+
|
|
10
63
|
export const createExtendsFromKeys = key => {
|
|
11
64
|
if (key.includes('+')) {
|
|
12
65
|
return key.split('+').filter(matchesComponentNaming)
|
|
@@ -30,12 +83,8 @@ export const createExtends = (element, parent, key) => {
|
|
|
30
83
|
let __extends = []
|
|
31
84
|
const keyExtends = createExtendsFromKeys(key)
|
|
32
85
|
if (keyExtends) __extends = [...keyExtends]
|
|
33
|
-
const elementExtends = element
|
|
34
|
-
if (elementExtends)
|
|
35
|
-
__extends = isArray(elementExtends)
|
|
36
|
-
? [...__extends, ...elementExtends]
|
|
37
|
-
: [...__extends, elementExtends]
|
|
38
|
-
}
|
|
86
|
+
const elementExtends = toPriorityOrder(collectExtendsList(element))
|
|
87
|
+
if (elementExtends.length) __extends = [...__extends, ...elementExtends]
|
|
39
88
|
return __extends
|
|
40
89
|
}
|
|
41
90
|
|
|
@@ -128,17 +177,18 @@ export const extractArrayExtend = (
|
|
|
128
177
|
}
|
|
129
178
|
|
|
130
179
|
export const deepExtend = (extend, stack, context, processed = new Set(), nameStack, currentName, componentNameMap) => {
|
|
131
|
-
const extendOflattenExtend = extend
|
|
180
|
+
const extendOflattenExtend = collectExtendsList(extend)
|
|
132
181
|
const cleanExtend = { ...extend }
|
|
133
182
|
delete cleanExtend.extends
|
|
183
|
+
delete cleanExtend.extend
|
|
134
184
|
let hasKeys = false
|
|
135
185
|
for (const _k in cleanExtend) { hasKeys = true; break } // eslint-disable-line
|
|
136
186
|
if (hasKeys) {
|
|
137
187
|
stack.push(cleanExtend)
|
|
138
188
|
if (nameStack) nameStack.push(currentName)
|
|
139
189
|
}
|
|
140
|
-
if (extendOflattenExtend) {
|
|
141
|
-
flattenExtend(extendOflattenExtend, stack, context, processed, nameStack, currentName, componentNameMap)
|
|
190
|
+
if (extendOflattenExtend.length) {
|
|
191
|
+
flattenExtend(toPriorityOrder(extendOflattenExtend), stack, context, processed, nameStack, currentName, componentNameMap)
|
|
142
192
|
}
|
|
143
193
|
return stack
|
|
144
194
|
}
|
|
@@ -168,9 +218,16 @@ export const flattenExtend = (
|
|
|
168
218
|
currentName = componentNameMap.get(extend)
|
|
169
219
|
}
|
|
170
220
|
|
|
221
|
+
// A string entry is mapped to its component ABOVE, so the entry guard at
|
|
222
|
+
// the top of this function only ever saw the string. Re-check the resolved
|
|
223
|
+
// object or a same-name override (`X: { extends: 'X' }` — the documented
|
|
224
|
+
// shared-library override) recurses into itself forever. The runtime
|
|
225
|
+
// resolver has always been safe here (`mergeBase` guards on the resolved
|
|
226
|
+
// object), which is why only this path blew the stack.
|
|
227
|
+
if (processed.has(extend)) return stack
|
|
171
228
|
processed.add(extend)
|
|
172
229
|
|
|
173
|
-
if (extend?.extends) {
|
|
230
|
+
if (extend?.extends || extend?.extend) {
|
|
174
231
|
deepExtend(extend, stack, context, processed, nameStack, currentName, componentNameMap)
|
|
175
232
|
} else if (extend) {
|
|
176
233
|
stack.push(extend)
|
|
@@ -181,7 +238,7 @@ export const flattenExtend = (
|
|
|
181
238
|
}
|
|
182
239
|
|
|
183
240
|
const MERGE_EXTENDS_SKIP = new Set([
|
|
184
|
-
'parent', 'node', '__ref', '__proto__', 'extends', 'childExtends', 'childExtendsRecursive'
|
|
241
|
+
'parent', 'node', '__ref', '__proto__', 'extends', 'extend', 'childExtends', 'childExtendsRecursive'
|
|
185
242
|
])
|
|
186
243
|
|
|
187
244
|
export const deepMergeExtends = (element, extend, sourcemap, sourceName, preBuiltSourcemap) => {
|
|
@@ -314,6 +371,10 @@ export const jointStacks = (extendStack, childExtendsStack) => {
|
|
|
314
371
|
}
|
|
315
372
|
|
|
316
373
|
// init
|
|
374
|
+
// `extend` here is a PRIORITY list (earlier = higher priority), not an
|
|
375
|
+
// authored array — `createExtendsStack` passes `__ref.__extends`, which
|
|
376
|
+
// `createExtends`/`addExtends` already normalised through `toPriorityOrder`.
|
|
377
|
+
// Pass `toPriorityOrder(authoredArray)` when calling this directly.
|
|
317
378
|
export const getExtendsStack = (extend, context, nameStack, componentNameMap) => {
|
|
318
379
|
if (!extend) return []
|
|
319
380
|
if (extend.__hash) return getHashedExtend(extend) || []
|
|
@@ -367,33 +428,23 @@ export const createElementExtends = (element, parent, options = {}) => {
|
|
|
367
428
|
const context = element.context || parent.context
|
|
368
429
|
const variant = element.variant
|
|
369
430
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
typeof element.extends === 'string' &&
|
|
386
|
-
variant &&
|
|
387
|
-
context?.components
|
|
388
|
-
) {
|
|
389
|
-
const variantKey = `${element.extends}.${variant}`
|
|
390
|
-
if (context.components[variantKey]) {
|
|
391
|
-
addExtends(variantKey, element)
|
|
392
|
-
} else {
|
|
393
|
-
addExtends(element.extends, element)
|
|
394
|
-
}
|
|
431
|
+
const authoredExtends = collectExtendsList(element)
|
|
432
|
+
if (authoredExtends.length) {
|
|
433
|
+
// The authored array enters the priority ladder reversed (see the
|
|
434
|
+
// PRECEDENCE LAW at the top of this file), so `ordered[0]` is the
|
|
435
|
+
// array's LAST entry — the dominant base. A `variant` swaps THAT one for
|
|
436
|
+
// its `<Name>.<variant>` sibling; swapping the authored first entry would
|
|
437
|
+
// pin the variant on the weakest base in the array.
|
|
438
|
+
const ordered = toPriorityOrder(authoredExtends)
|
|
439
|
+
const [dominantExtend, ...restExtends] = ordered
|
|
440
|
+
const variantKey =
|
|
441
|
+
typeof dominantExtend === 'string' && variant && context?.components
|
|
442
|
+
? `${dominantExtend}.${variant}`
|
|
443
|
+
: null
|
|
444
|
+
if (variantKey && context.components[variantKey]) {
|
|
445
|
+
addExtends([variantKey, ...restExtends], element)
|
|
395
446
|
} else {
|
|
396
|
-
addExtends(
|
|
447
|
+
addExtends(ordered, element)
|
|
397
448
|
}
|
|
398
449
|
}
|
|
399
450
|
|
|
@@ -402,11 +453,11 @@ export const createElementExtends = (element, parent, options = {}) => {
|
|
|
402
453
|
inheritRecursiveChildExtends(element, parent, options)
|
|
403
454
|
|
|
404
455
|
if (element.component) {
|
|
405
|
-
addExtends(exec(element.component, element), element)
|
|
456
|
+
addExtends(toPriorityOrder(exec(element.component, element)), element)
|
|
406
457
|
}
|
|
407
458
|
|
|
408
459
|
if (context.defaultExtends) {
|
|
409
|
-
addExtends(context.defaultExtends, element)
|
|
460
|
+
addExtends(toPriorityOrder(context.defaultExtends), element)
|
|
410
461
|
}
|
|
411
462
|
|
|
412
463
|
return removeDuplicatesInArray(ref.__extends)
|
|
@@ -418,7 +469,7 @@ export const inheritChildPropsExtends = (element, parent, options = {}) => {
|
|
|
418
469
|
options.ignoreChildExtends || element.ignoreChildExtends
|
|
419
470
|
if (!ignoreChildExtends) {
|
|
420
471
|
if (parent.childProps?.extends) {
|
|
421
|
-
addExtends(parent.childProps.extends, element)
|
|
472
|
+
addExtends(toPriorityOrder(parent.childProps.extends), element)
|
|
422
473
|
}
|
|
423
474
|
}
|
|
424
475
|
return ref.__extends
|
|
@@ -431,7 +482,7 @@ export const inheritChildExtends = (element, parent, options = {}) => {
|
|
|
431
482
|
|
|
432
483
|
const childExtends = parent.childExtends
|
|
433
484
|
if (!ignoreChildExtends && childExtends) {
|
|
434
|
-
addExtends(childExtends, element)
|
|
485
|
+
addExtends(toPriorityOrder(childExtends), element)
|
|
435
486
|
}
|
|
436
487
|
return ref.__extends
|
|
437
488
|
}
|
|
@@ -443,7 +494,7 @@ export const inheritRecursiveChildExtends = (element, parent, options = {}) => {
|
|
|
443
494
|
options.ignoreChildExtendsRecursive || element.ignoreChildExtendsRecursive
|
|
444
495
|
const isText = element.key === '__text'
|
|
445
496
|
if (childExtendsRecursive && !isText && !ignoreChildExtendsRecursive) {
|
|
446
|
-
addExtends(childExtendsRecursive, element)
|
|
497
|
+
addExtends(toPriorityOrder(childExtendsRecursive), element)
|
|
447
498
|
}
|
|
448
499
|
return ref.__extends
|
|
449
500
|
}
|
package/methods.js
CHANGED
|
@@ -173,6 +173,9 @@ export function getRef (key) {
|
|
|
173
173
|
|
|
174
174
|
export function getChildren () {
|
|
175
175
|
const __children = this.getRef('__children')
|
|
176
|
+
// An element with no children array (a bare ref, a node not built by
|
|
177
|
+
// create) has no children — never a throw.
|
|
178
|
+
if (!Array.isArray(__children)) return []
|
|
176
179
|
return __children.map(k => this[k])
|
|
177
180
|
}
|
|
178
181
|
|
|
@@ -248,8 +251,25 @@ export function getRootState (param) {
|
|
|
248
251
|
}
|
|
249
252
|
|
|
250
253
|
export function getRoot (key) {
|
|
251
|
-
|
|
252
|
-
|
|
254
|
+
// `__ref.root` (element/src/create.js) is an ELEMENT pointer set
|
|
255
|
+
// unconditionally on every element at creation time — both the initial
|
|
256
|
+
// create() pass and a later `parent.update({ NewKey })` addition, since
|
|
257
|
+
// both run through the same create() and inherit `parent.__ref.root`.
|
|
258
|
+
// It never depends on the state tree's `isRootState` flag surviving the
|
|
259
|
+
// context.state -> {...ctxState} copy -> createStore() chain, so prefer
|
|
260
|
+
// it over the state-chain walk in getRootState(), which silently
|
|
261
|
+
// returns nothing whenever that flag is lost along the way
|
|
262
|
+
// (FW-GETROOT-RETURNS-UNDEFINED-ON-THE-PRODUCT-SHELL-1 — measured true
|
|
263
|
+
// on elements added via update() to a live tree, on a deployed shell).
|
|
264
|
+
const rootElem = this?.__ref?.root || this.getRootState()?.__element
|
|
265
|
+
if (!rootElem) {
|
|
266
|
+
throw new Error(
|
|
267
|
+
`[smbls] getRoot() could not resolve a root element for "${this?.key || '<unknown>'}" — ` +
|
|
268
|
+
'it has no __ref (never went through create()) and no root state is registered. ' +
|
|
269
|
+
'Answering undefined here used to no-op silently for every caller.'
|
|
270
|
+
)
|
|
271
|
+
}
|
|
272
|
+
return Object.keys(rootElem).length > 0 && key
|
|
253
273
|
? rootElem[key]
|
|
254
274
|
: rootElem
|
|
255
275
|
}
|
package/object.js
CHANGED
|
@@ -266,22 +266,38 @@ export const deepStringifyFunctions = (obj, stringified = {}) => {
|
|
|
266
266
|
return stringified
|
|
267
267
|
}
|
|
268
268
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
'/'
|
|
282
|
-
'
|
|
283
|
-
|
|
284
|
-
|
|
269
|
+
// A key is emitted BARE only when it is a valid identifier; everything else
|
|
270
|
+
// is single-quoted with escaping. The previous denylist of "special chars"
|
|
271
|
+
// let every unlisted character through bare: '[id]' became the COMPUTED
|
|
272
|
+
// property `[id]:` (ReferenceError: id is not defined at import), '1e3'
|
|
273
|
+
// silently became the key '1000', and a key containing a quote produced
|
|
274
|
+
// unparseable output (FW-FRANK-TOFS-BRACKET-KEY-EMITTED-AS-COMPUTED-1).
|
|
275
|
+
// Reserved words need no quoting in property position ({ class: 1 } is
|
|
276
|
+
// valid), so the bare test is the identifier grammar alone.
|
|
277
|
+
const OBJ_TO_STR_IDENTIFIER_KEY = /^[A-Za-z_$][A-Za-z0-9_$]*$/
|
|
278
|
+
|
|
279
|
+
const quoteObjectKey = (key) => `'${String(key)
|
|
280
|
+
.replace(/\\/g, '\\\\')
|
|
281
|
+
.replace(/'/g, "\\'")
|
|
282
|
+
.replace(/\r/g, '\\r')
|
|
283
|
+
.replace(/\n/g, '\\n')}'`
|
|
284
|
+
|
|
285
|
+
// A string VALUE printed as a JS literal that evaluates back to exactly that
|
|
286
|
+
// string. A multi-line value (or one with a single quote) stays a template
|
|
287
|
+
// literal so a markdown body reads as written — with the three sequences a
|
|
288
|
+
// template treats specially escaped: backslash, backtick and `${`. Everything
|
|
289
|
+
// else is single-quoted with backslash, quote and CR escaped. Printed raw, a
|
|
290
|
+
// body with `origin/main` in backticks broke a fetched
|
|
291
|
+
// packages/shared/functions/marketplaceCatalog.js, and a backslash silently
|
|
292
|
+
// changed meaning (`\d` → `d`) (FW-FRANK-TOFS-STRING-CONSTANT-EMITTED-RAW-AS-
|
|
293
|
+
// COMPONENT-1, second member).
|
|
294
|
+
const quoteStringValue = (value) => {
|
|
295
|
+
const s = String(value)
|
|
296
|
+
if (stringIncludesAny(s, ['\n', "'"])) {
|
|
297
|
+
return '`' + s.replace(/\\/g, '\\\\').replace(/`/g, '\\`').replace(/\$\{/g, '\\${') + '`'
|
|
298
|
+
}
|
|
299
|
+
return "'" + s.replace(/\\/g, '\\\\').replace(/'/g, "\\'").replace(/\r/g, '\\r') + "'"
|
|
300
|
+
}
|
|
285
301
|
|
|
286
302
|
export const objectToString = (obj = {}, indent = 0) => {
|
|
287
303
|
// Handle empty object case
|
|
@@ -309,14 +325,7 @@ export const objectToString = (obj = {}, indent = 0) => {
|
|
|
309
325
|
for (const key in obj) {
|
|
310
326
|
if (!Object.prototype.hasOwnProperty.call(obj, key)) continue
|
|
311
327
|
const value = obj[key]
|
|
312
|
-
|
|
313
|
-
for (let i = 0; i < key.length; i++) {
|
|
314
|
-
if (OBJ_TO_STR_SPECIAL_CHARS.has(key[i])) {
|
|
315
|
-
keyNeedsQuotes = true
|
|
316
|
-
break
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
const stringedKey = keyNeedsQuotes ? `'${key}'` : key
|
|
328
|
+
const stringedKey = OBJ_TO_STR_IDENTIFIER_KEY.test(key) ? key : quoteObjectKey(key)
|
|
320
329
|
str += `${spaces} ${stringedKey}: `
|
|
321
330
|
|
|
322
331
|
if (value instanceof RegExp) {
|
|
@@ -329,7 +338,7 @@ export const objectToString = (obj = {}, indent = 0) => {
|
|
|
329
338
|
} else if (isObjectLike(element) && element !== null) {
|
|
330
339
|
str += `${spaces} ${objectToString(element, indent + 2)},\n`
|
|
331
340
|
} else if (isString(element)) {
|
|
332
|
-
str += `${spaces}
|
|
341
|
+
str += `${spaces} ${quoteStringValue(element)},\n`
|
|
333
342
|
} else {
|
|
334
343
|
str += `${spaces} ${element},\n`
|
|
335
344
|
}
|
|
@@ -338,9 +347,7 @@ export const objectToString = (obj = {}, indent = 0) => {
|
|
|
338
347
|
} else if (isObjectLike(value)) {
|
|
339
348
|
str += objectToString(value, indent + 1)
|
|
340
349
|
} else if (isString(value)) {
|
|
341
|
-
str +=
|
|
342
|
-
? `\`${value}\``
|
|
343
|
-
: `'${value}'`
|
|
350
|
+
str += quoteStringValue(value)
|
|
344
351
|
} else {
|
|
345
352
|
str += value
|
|
346
353
|
}
|
package/package.json
CHANGED
package/sharedLibraries.js
CHANGED
|
@@ -136,6 +136,81 @@ const OBJECT_BAGS = new Set(['components', 'pages', 'functions', 'snippets', 'me
|
|
|
136
136
|
*/
|
|
137
137
|
const isStubPhantom = (bag, value) => value === '' && OBJECT_BAGS.has(bag)
|
|
138
138
|
|
|
139
|
+
/**
|
|
140
|
+
* The spellings one font-family bag goes by. Scratch folds them into ONE
|
|
141
|
+
* object before it reads a family (`aliasCaseVariants`, canonical-first), so a
|
|
142
|
+
* default claimed under any of them competes with a claim under any other.
|
|
143
|
+
*/
|
|
144
|
+
const FONT_FAMILY_BAGS = ['fontFamily', 'fontfamily', 'font_family', 'FONT_FAMILY']
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* The font families a design system itself flags `isDefault`, per bag:
|
|
148
|
+
* `Map { 'fontFamily' => Set { 'def' } }`. Empty when it claims none.
|
|
149
|
+
*/
|
|
150
|
+
const defaultFontClaims = (designSystem) => {
|
|
151
|
+
const claims = new Map()
|
|
152
|
+
if (!isObject(designSystem)) return claims
|
|
153
|
+
for (const bag of FONT_FAMILY_BAGS) {
|
|
154
|
+
const families = designSystem[bag]
|
|
155
|
+
if (!isObject(families)) continue
|
|
156
|
+
for (const k in families) {
|
|
157
|
+
if (!isObject(families[k]) || !families[k].isDefault) continue
|
|
158
|
+
if (!claims.has(bag)) claims.set(bag, new Set())
|
|
159
|
+
claims.get(bag).add(k)
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return claims
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* A consumer that names its own default font family keeps it.
|
|
167
|
+
*
|
|
168
|
+
* `isDefault` is the one design-system value the add-missing merge cannot
|
|
169
|
+
* rank. It is not a key that collides — it is a CLAIM that competes across
|
|
170
|
+
* keys: a library's `Default` and the consumer's `def` are different
|
|
171
|
+
* families, so `deepDefaults` keeps both, both flagged. Scratch then decides
|
|
172
|
+
* by read order (`setFontFamily` points `fontFamily.default` at every flagged
|
|
173
|
+
* family it reads, so the LAST one wins), and a library's families are
|
|
174
|
+
* appended after the consumer's. The consumer lost to every library that
|
|
175
|
+
* ships a default — the opposite of the precedence this merge documents.
|
|
176
|
+
*
|
|
177
|
+
* Measured 2026-09-21 on the published vault--context.at.symbo.ls (smbls
|
|
178
|
+
* 3.14.801): the deck declares `fontFamily.def` (Roboto first, isDefault) and
|
|
179
|
+
* the platform links `system/default`, whose `fontFamily.Default` (a San
|
|
180
|
+
* Francisco stack) is flagged too. `fontFamily.default` resolved to
|
|
181
|
+
* `Default`, html/body rendered in the library's stack and Roboto never set a
|
|
182
|
+
* glyph. The sibling vault--landing — the same design system, no library —
|
|
183
|
+
* renders Roboto.
|
|
184
|
+
*
|
|
185
|
+
* So once the consumer claims a default, every OTHER flagged family drops the
|
|
186
|
+
* flag: a library's own entry, or a consumer entry that only received the
|
|
187
|
+
* flag from a same-named library entry through `deepDefaults`. The family
|
|
188
|
+
* itself stays; only the claim goes. The bag is copied before it changes — a
|
|
189
|
+
* bag the consumer did not have is the LIBRARY's own object, shared with
|
|
190
|
+
* every other consumer of that library.
|
|
191
|
+
*
|
|
192
|
+
* When the consumer claims nothing, nothing changes: a library default is
|
|
193
|
+
* what such a project has always rendered, and the order between two
|
|
194
|
+
* libraries stays scratch's.
|
|
195
|
+
*/
|
|
196
|
+
const yieldLibraryDefaultFonts = (designSystem, ownClaims) => {
|
|
197
|
+
for (const bag of FONT_FAMILY_BAGS) {
|
|
198
|
+
const families = designSystem[bag]
|
|
199
|
+
if (!isObject(families)) continue
|
|
200
|
+
const own = ownClaims.get(bag)
|
|
201
|
+
let copy = null
|
|
202
|
+
for (const k in families) {
|
|
203
|
+
const entry = families[k]
|
|
204
|
+
if (!isObject(entry) || !entry.isDefault || (own && own.has(k))) continue
|
|
205
|
+
const family = { ...entry }
|
|
206
|
+
delete family.isDefault
|
|
207
|
+
if (!copy) copy = { ...families }
|
|
208
|
+
copy[k] = family
|
|
209
|
+
}
|
|
210
|
+
if (copy) designSystem[bag] = copy
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
139
214
|
const stripJsExt = (segment) => segment.replace(/\.js$/iu, '')
|
|
140
215
|
|
|
141
216
|
/**
|
|
@@ -257,6 +332,8 @@ const mergeOneLibrary = (context, sharedLib, ignore) => {
|
|
|
257
332
|
* - new top-level keys: copy from library
|
|
258
333
|
* - `app` NEVER merges — a library's root definition is not consumer
|
|
259
334
|
* content (see the unconditional exclusion in `mergeOneLibrary`)
|
|
335
|
+
* - a font family the consumer flags `isDefault` stays the default — every
|
|
336
|
+
* library's own claim yields (see `yieldLibraryDefaultFonts`)
|
|
260
337
|
*
|
|
261
338
|
* Entries may be a bare library context, or a wrapped `{ library, ignoreList }`
|
|
262
339
|
* (see `sharedLibrary`). `ignoreList` names paths to skip while merging that
|
|
@@ -264,6 +341,9 @@ const mergeOneLibrary = (context, sharedLib, ignore) => {
|
|
|
264
341
|
*/
|
|
265
342
|
export const mergeSharedLibraries = (context, libraries) => {
|
|
266
343
|
if (!libraries || !libraries.length) return
|
|
344
|
+
// Read BEFORE any library lands: afterwards a library's families sit in the
|
|
345
|
+
// consumer's own bags and the two can no longer be told apart.
|
|
346
|
+
const ownDefaultFonts = defaultFontClaims(context.designSystem)
|
|
267
347
|
for (let i = 0; i < libraries.length; i++) {
|
|
268
348
|
let sharedLib = libraries[i]
|
|
269
349
|
let ignore = EMPTY_IGNORE
|
|
@@ -274,6 +354,7 @@ export const mergeSharedLibraries = (context, libraries) => {
|
|
|
274
354
|
if (!isObject(sharedLib)) continue
|
|
275
355
|
mergeOneLibrary(context, sharedLib, ignore)
|
|
276
356
|
}
|
|
357
|
+
if (ownDefaultFonts.size) yieldLibraryDefaultFonts(context.designSystem, ownDefaultFonts)
|
|
277
358
|
}
|
|
278
359
|
|
|
279
360
|
/**
|