@symbo.ls/utils 3.14.768 → 3.14.770

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @symbo.ls/utils
2
2
 
3
+ ## 3.14.770
4
+
5
+ ### Patch Changes
6
+
7
+ - Seed the raw design system at BOOT rather than only in the socket's `onSnapshot`, so every livesync/HMR push re-paints correctly without a manual reload (RUNTIME-LIVESYNC-STYLE-LOSS-1).
8
+
9
+ `onOps` re-inits the design system from `ctx.__rawDesignSystem`. That copy was seeded only in `onSnapshot`, so transports that echo a boot snapshot were covered while the dev-server runner — which emits ops and never a snapshot — was not. `buildReinitDesignSystem` then returned null and `onOps` fell back to `init(ctx.designSystem)`, re-feeding scratch's PROCESSED config through the token transformers: alpha was stripped (`--color-transparent` rgba(0,0,0,0) → rgba(0,0,0,1)) and new tokens never reached the sheet.
10
+
11
+ `seedRawDesignSystem` is now called in `createDomql.js` immediately before `prepareDesignSystem` — shared libraries merged, scratch processing not yet run — and re-exported from `@symbo.ls/sync`. brender's sync stub gains the same export.
12
+
13
+ `@symbo.ls/utils` is republished because its shipped dist was missing `isPolyglotWritableKey`, which exists at `packages/utils/state.js:261` and is imported by `@symbo.ls/element` and `smbls/src/prepare.js`. The published 3.14.769 tarball lacks it, so any consumer importing that symbol from the package root fails at import time.
14
+
3
15
  ## 3.14.768
4
16
 
5
17
  ### Patch Changes
package/cdn.js CHANGED
@@ -1,25 +1,48 @@
1
1
  'use strict'
2
2
 
3
+ // `<pkg>@<version>` grammar helpers shared by every provider below. The
4
+ // version ALWAYS attaches to the package NAME, never to a deep file path —
5
+ // `panzoom@9.4.4/dist/panzoom.js`, not `panzoom/dist/panzoom.js@9.4.4`
6
+ // (IMPORTMAP-SUBPATH-1 side finding: pkg.symbo.ls tolerated the latter,
7
+ // every other provider 404s on it). `splitPackageSpecifier` is what makes a
8
+ // deep specifier reach `formatUrl` as (name, version, subpath).
9
+ const versionPart = (version) => (version !== 'latest' ? `@${version}` : '')
10
+ const subpathPart = (subpath) => (subpath ? `/${subpath}` : '')
11
+
12
+ // 'panzoom/dist/panzoom.js' → { name: 'panzoom', subpath: 'dist/panzoom.js' }
13
+ // '@symbo.ls/utils/cdn.js' → { name: '@symbo.ls/utils', subpath: 'cdn.js' }
14
+ // 'smbls' → { name: 'smbls', subpath: '' }
15
+ export const splitPackageSpecifier = (specifier) => {
16
+ const spec = typeof specifier === 'string' ? specifier.replace(/\/+$/, '') : ''
17
+ if (!spec) return { name: '', subpath: '' }
18
+ const parts = spec.split('/')
19
+ const nameSegments = spec.startsWith('@') ? 2 : 1
20
+ return {
21
+ name: parts.slice(0, nameSegments).join('/'),
22
+ subpath: parts.slice(nameSegments).join('/')
23
+ }
24
+ }
25
+
3
26
  export const CDN_PROVIDERS = {
4
27
  skypack: {
5
28
  url: 'https://cdn.skypack.dev',
6
- formatUrl: (pkg, version) =>
7
- `${CDN_PROVIDERS.skypack.url}/${pkg}${version !== 'latest' ? `@${version}` : ''}`
29
+ formatUrl: (pkg, version, subpath) =>
30
+ `${CDN_PROVIDERS.skypack.url}/${pkg}${versionPart(version)}${subpathPart(subpath)}`
8
31
  },
9
32
  esmsh: {
10
33
  url: 'https://esm.sh',
11
- formatUrl: (pkg, version) =>
12
- `${CDN_PROVIDERS.esmsh.url}/${pkg}${version !== 'latest' ? `@${version}` : ''}`
34
+ formatUrl: (pkg, version, subpath) =>
35
+ `${CDN_PROVIDERS.esmsh.url}/${pkg}${versionPart(version)}${subpathPart(subpath)}`
13
36
  },
14
37
  unpkg: {
15
38
  url: 'https://unpkg.com',
16
- formatUrl: (pkg, version) =>
17
- `${CDN_PROVIDERS.unpkg.url}/${pkg}${version !== 'latest' ? `@${version}` : ''}?module`
39
+ formatUrl: (pkg, version, subpath) =>
40
+ `${CDN_PROVIDERS.unpkg.url}/${pkg}${versionPart(version)}${subpathPart(subpath)}?module`
18
41
  },
19
42
  jsdelivr: {
20
43
  url: 'https://cdn.jsdelivr.net/npm',
21
- formatUrl: (pkg, version) =>
22
- `${CDN_PROVIDERS.jsdelivr.url}/${pkg}${version !== 'latest' ? `@${version}` : ''}/+esm`
44
+ formatUrl: (pkg, version, subpath) =>
45
+ `${CDN_PROVIDERS.jsdelivr.url}/${pkg}${versionPart(version)}${subpathPart(subpath)}/+esm`
23
46
  },
24
47
  // pkg.symbo.ls — our own proxy (server/workers/packages). It is a raw file
25
48
  // PASSTHROUGH (GCS bucket → jsDelivr → unpkg), not a CJS→ESM transformer,
@@ -38,8 +61,8 @@ export const CDN_PROVIDERS = {
38
61
  // a domain we control rather than a smbls-only special case.
39
62
  symbols: {
40
63
  url: 'https://pkg.symbo.ls',
41
- formatUrl: (pkg, version) =>
42
- `${CDN_PROVIDERS.symbols.url}/${pkg}${version !== 'latest' ? `@${version}` : ''}/+esm`
64
+ formatUrl: (pkg, version, subpath) =>
65
+ `${CDN_PROVIDERS.symbols.url}/${pkg}${versionPart(version)}${subpathPart(subpath)}/+esm`
43
66
  }
44
67
  }
45
68
 
@@ -88,7 +111,33 @@ export const getCDNUrl = (
88
111
  provider = 'esmsh'
89
112
  ) => {
90
113
  const cdnConfig = CDN_PROVIDERS[provider] || CDN_PROVIDERS.esmsh
91
- return cdnConfig.formatUrl(packageName, stripVersionRangePrefix(version))
114
+ // A deep specifier ('pkg/dist/file.js') pins its version on the package
115
+ // NAME and keeps the file path after it — see splitPackageSpecifier.
116
+ const { name, subpath } = splitPackageSpecifier(packageName)
117
+ return cdnConfig.formatUrl(name || packageName, stripVersionRangePrefix(version), subpath)
118
+ }
119
+
120
+ // The package DIRECTORY on the CDN — `<cdn>/<pkg>@<version>/` — i.e. the
121
+ // exact-entry URL without its module-entry suffix (`/+esm`, `?module`) and
122
+ // WITH a trailing slash. This is the address an importmap prefix entry
123
+ // (`"pkg/": "<dir>/"`) needs so `import('pkg/<subpath>')` resolves to
124
+ // `<dir>/<subpath>` — a raw file path every provider here serves
125
+ // (pkg.symbo.ls is a raw passthrough; esm.sh / jsDelivr / unpkg / skypack
126
+ // all accept `/<pkg>@<v>/<file>`). Kept separate from `formatUrl` on purpose:
127
+ // the exact entry MUST keep its suffix (the IIFE-vs-ESM lesson above), the
128
+ // prefix entry MUST NOT have one.
129
+ export const getCDNDirUrl = (
130
+ packageName,
131
+ version = 'latest',
132
+ provider = 'esmsh'
133
+ ) => {
134
+ const cdnConfig = CDN_PROVIDERS[provider] || CDN_PROVIDERS.esmsh
135
+ const v = stripVersionRangePrefix(version)
136
+ // Same name/subpath grammar as getCDNUrl: the version pins the package
137
+ // name, a deep specifier's path follows it, and the directory URL still
138
+ // ends with the trailing slash an importmap prefix entry requires.
139
+ const { name, subpath } = splitPackageSpecifier(packageName)
140
+ return `${cdnConfig.url}/${name || packageName}${versionPart(v)}${subpathPart(subpath)}/`
92
141
  }
93
142
 
94
143
  // SMBLS-IMPORTMAP-SKIP — shared with packages/smbls/src/prepare.js's own
@@ -127,6 +176,20 @@ const MALFORMED_DEP_RE = /[<>…]/
127
176
  export const isMalformedDependency = (name) =>
128
177
  typeof name === 'string' && MALFORMED_DEP_RE.test(name)
129
178
 
179
+ // A dependency MAP is `{ [pkgName]: version }` — a plain object keyed by
180
+ // package name. Manifest v2.1's `dependencies` field (a project config.js
181
+ // app-dependency GRAPH: `[{ id, requirement, kind, provides, reason }, …]`)
182
+ // reuses the same key name for an unrelated shape, and a project's
183
+ // generated context.js spreads `...config` AFTER the real map from
184
+ // dependencies.js, so config's array can end up occupying this exact spot
185
+ // (APP-CONFIG-DEPENDENCIES-COLLIDES-WITH-PACKAGE-LOADER-1). Indexing an
186
+ // array by package name indexes it by NUMERIC POSITION instead —
187
+ // `dependencies['0']` yields the first manifest entry OBJECT, not a
188
+ // version string — so both callers below must refuse anything that isn't
189
+ // a plain object before treating a value as a package spec.
190
+ export const isValidDependencyMap = (dependencies) =>
191
+ !!dependencies && typeof dependencies === 'object' && !Array.isArray(dependencies)
192
+
130
193
  /**
131
194
  * Generate an HTML <script type="importmap"> tag from project dependencies.
132
195
  *
@@ -150,13 +213,29 @@ export const isMalformedDependency = (name) =>
150
213
  * *.at.symbo.ls pages shipped `"smbls": "latest"` against an inlined IIFE from
151
214
  * a months-old pin, and the client half moved 683 → 704 in a single evening
152
215
  * under already-published sites (tickets/smbls.md).
216
+ *
217
+ * SUBPATH TWIN (tickets/fable.md IMPORTMAP-SUBPATH-1). Browser importmap
218
+ * semantics do NOT satisfy a subpath import from a bare entry:
219
+ * `"typesense-docsearch.js": "…@3.4.1/+esm"` resolves `import('typesense-
220
+ * docsearch.js')` and NOTHING else — `import('typesense-docsearch.js/dist/
221
+ * umd/index.js')` rejects with `TypeError: Failed to resolve module
222
+ * specifier` BEFORE any network request (measured live on docs.symbols.app,
223
+ * silent unless the caller awaits). A prefix entry — a key ending in `/`
224
+ * mapped to an address ending in `/` — is how importmaps express "and every
225
+ * subpath under it". So every dependency gets a TWIN:
226
+ * "pkg": "<cdn>/pkg@X/+esm" (exact — the importable module entry)
227
+ * "pkg/": "<cdn>/pkg@X/" (prefix — `pkg/<file>` → `<cdn>/pkg@X/<file>`)
228
+ * Same pinned version on both. A key that already ends with `/` gets no twin
229
+ * (it IS one). The address MUST end with `/` — the browser silently drops a
230
+ * prefix entry whose address does not.
153
231
  */
154
232
  export const getImportMapScript = (
155
233
  data,
156
234
  defaultProvider = 'skypack',
157
235
  options = {}
158
236
  ) => {
159
- const dependencies = data.dependencies || {}
237
+ const dependencies = data.dependencies
238
+ if (!isValidDependencyMap(dependencies)) return ''
160
239
  const keys = Object.keys(dependencies)
161
240
  if (!keys.length) return ''
162
241
 
@@ -172,6 +251,10 @@ export const getImportMapScript = (
172
251
  if (isUnresolvableDependency(pkgName) || isMalformedDependency(pkgName)) continue
173
252
  const version = pin[pkgName] || dependencies[pkgName] || 'latest'
174
253
  imports[pkgName] = getCDNUrl(pkgName, version, defaultProvider)
254
+ // See SUBPATH TWIN above.
255
+ if (!pkgName.endsWith('/')) {
256
+ imports[pkgName + '/'] = getCDNDirUrl(pkgName, version, defaultProvider)
257
+ }
175
258
  }
176
259
  if (!Object.keys(imports).length) return ''
177
260
 
package/dist/cjs/cdn.js CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";var l=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var x=(t,s)=>{for(var e in s)l(t,e,{get:s[e],enumerable:!0})},D=(t,s,e,o)=>{if(s&&typeof s=="object"||typeof s=="function")for(let r of b(s))!E.call(t,r)&&r!==e&&l(t,r,{get:()=>s[r],enumerable:!(o=h(s,r))||o.enumerable});return t};var U=t=>D(l({},"__esModule",{value:!0}),t);var N={};x(N,{CDN_PROVIDERS:()=>n,PACKAGE_MANAGER_TO_CDN:()=>m,getCDNUrl:()=>i,getCdnProviderFromConfig:()=>C,getImportMapScript:()=>j,isMalformedDependency:()=>g,isUnresolvableDependency:()=>u,stripVersionRangePrefix:()=>a});module.exports=U(N);const n={skypack:{url:"https://cdn.skypack.dev",formatUrl:(t,s)=>`${n.skypack.url}/${t}${s!=="latest"?`@${s}`:""}`},esmsh:{url:"https://esm.sh",formatUrl:(t,s)=>`${n.esmsh.url}/${t}${s!=="latest"?`@${s}`:""}`},unpkg:{url:"https://unpkg.com",formatUrl:(t,s)=>`${n.unpkg.url}/${t}${s!=="latest"?`@${s}`:""}?module`},jsdelivr:{url:"https://cdn.jsdelivr.net/npm",formatUrl:(t,s)=>`${n.jsdelivr.url}/${t}${s!=="latest"?`@${s}`:""}/+esm`},symbols:{url:"https://pkg.symbo.ls",formatUrl:(t,s)=>`${n.symbols.url}/${t}${s!=="latest"?`@${s}`:""}/+esm`}},m={"esm.sh":"esmsh",unpkg:"unpkg",skypack:"skypack",jsdelivr:"jsdelivr","pkg.symbo.ls":"symbols"},C=(t={})=>{const{packageManager:s}=t;return m[s]||null},a=t=>{if(typeof t!="string")return t;const s=t.trim().match(/^[\^~](\d.*)$/);return s?s[1]:t},i=(t,s="latest",e="esmsh")=>(n[e]||n.esmsh).formatUrl(t,a(s)),R=/^node:|^@symbo-ls\//,u=t=>typeof t=="string"&&R.test(t),_=/[<>…]/,g=t=>typeof t=="string"&&_.test(t),j=(t,s="skypack",e={})=>{const o=t.dependencies||{},r=Object.keys(o);if(!r.length)return"";const $=e.pin||{},c={};for(const p of r){if(u(p)||g(p))continue;const f=$[p]||o[p]||"latest";c[p]=i(p,f,s)}if(!Object.keys(c).length)return"";const k='<script type="importmap">',d="<\/script>",y=`{
2
- "imports": ${JSON.stringify(c,null,2)}
3
- }`;return`${k}${y}${d}`};
1
+ "use strict";var m=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var A=(t,s)=>{for(var e in s)m(t,e,{get:s[e],enumerable:!0})},P=(t,s,e,r)=>{if(s&&typeof s=="object"||typeof s=="function")for(let n of U(s))!C.call(t,n)&&n!==e&&m(t,n,{get:()=>s[n],enumerable:!(r=E(s,n))||r.enumerable});return t};var R=t=>P(m({},"__esModule",{value:!0}),t);var N={};A(N,{CDN_PROVIDERS:()=>o,PACKAGE_MANAGER_TO_CDN:()=>g,getCDNDirUrl:()=>h,getCDNUrl:()=>f,getCdnProviderFromConfig:()=>_,getImportMapScript:()=>v,isMalformedDependency:()=>d,isUnresolvableDependency:()=>k,isValidDependencyMap:()=>b,splitPackageSpecifier:()=>u,stripVersionRangePrefix:()=>$});module.exports=R(N);const l=t=>t!=="latest"?`@${t}`:"",i=t=>t?`/${t}`:"",u=t=>{const s=typeof t=="string"?t.replace(/\/+$/,""):"";if(!s)return{name:"",subpath:""};const e=s.split("/"),r=s.startsWith("@")?2:1;return{name:e.slice(0,r).join("/"),subpath:e.slice(r).join("/")}},o={skypack:{url:"https://cdn.skypack.dev",formatUrl:(t,s,e)=>`${o.skypack.url}/${t}${l(s)}${i(e)}`},esmsh:{url:"https://esm.sh",formatUrl:(t,s,e)=>`${o.esmsh.url}/${t}${l(s)}${i(e)}`},unpkg:{url:"https://unpkg.com",formatUrl:(t,s,e)=>`${o.unpkg.url}/${t}${l(s)}${i(e)}?module`},jsdelivr:{url:"https://cdn.jsdelivr.net/npm",formatUrl:(t,s,e)=>`${o.jsdelivr.url}/${t}${l(s)}${i(e)}/+esm`},symbols:{url:"https://pkg.symbo.ls",formatUrl:(t,s,e)=>`${o.symbols.url}/${t}${l(s)}${i(e)}/+esm`}},g={"esm.sh":"esmsh",unpkg:"unpkg",skypack:"skypack",jsdelivr:"jsdelivr","pkg.symbo.ls":"symbols"},_=(t={})=>{const{packageManager:s}=t;return g[s]||null},$=t=>{if(typeof t!="string")return t;const s=t.trim().match(/^[\^~](\d.*)$/);return s?s[1]:t},f=(t,s="latest",e="esmsh")=>{const r=o[e]||o.esmsh,{name:n,subpath:a}=u(t);return r.formatUrl(n||t,$(s),a)},h=(t,s="latest",e="esmsh")=>{const r=o[e]||o.esmsh,n=$(s),{name:a,subpath:p}=u(t);return`${r.url}/${a||t}${l(n)}${i(p)}/`},M=/^node:|^@symbo-ls\//,k=t=>typeof t=="string"&&M.test(t),O=/[<>…]/,d=t=>typeof t=="string"&&O.test(t),b=t=>!!t&&typeof t=="object"&&!Array.isArray(t),v=(t,s="skypack",e={})=>{const r=t.dependencies;if(!b(r))return"";const n=Object.keys(r);if(!n.length)return"";const a=e.pin||{},p={};for(const c of n){if(k(c)||d(c))continue;const y=a[c]||r[c]||"latest";p[c]=f(c,y,s),c.endsWith("/")||(p[c+"/"]=h(c,y,s))}if(!Object.keys(p).length)return"";const x='<script type="importmap">',D="<\/script>",j=`{
2
+ "imports": ${JSON.stringify(p,null,2)}
3
+ }`;return`${x}${j}${D}`};
@@ -1,17 +1,18 @@
1
- "use strict";var x=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var J=(e,t)=>{for(var r in t)x(e,r,{get:t[r],enumerable:!0})},q=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of b(t))!F.call(e,n)&&n!==r&&x(e,n,{get:()=>t[n],enumerable:!(s=W(t,n))||s.enumerable});return e};var B=e=>q(x({},"__esModule",{value:!0}),e);var Se={};J(Se,{clone:()=>z,createNestedObject:()=>ye,createObjectWithoutPrototype:()=>R,deepClone:()=>U,deepContains:()=>ae,deepDestringifyFunctions:()=>j,deepMerge:()=>m,deepStringifyFunctions:()=>$,destringifyGlobalScope:()=>re,detectInfiniteLoop:()=>ge,excludeKeysFromObject:()=>_e,exec:()=>P,getInObjectByPath:()=>we,hasFunction:()=>S,hasOwnProperty:()=>se,isCyclic:()=>Oe,isEmpty:()=>C,isEmptyObject:()=>ie,isEqualDeep:()=>M,makeObjectWithoutPrototype:()=>ce,map:()=>G,merge:()=>H,objectToString:()=>k,overwrite:()=>fe,overwriteDeep:()=>I,overwriteShallow:()=>le,removeFromObject:()=>pe,removeNestedKeyByPath:()=>he,setInObjectByPath:()=>de,stringToObject:()=>oe});module.exports=B(Se);var _=require("./globals.js"),l=require("./types.js"),T=require("./array.js"),N=require("./string.js"),g=require("./node.js"),D=require("./keys.js");const E="production",O=e=>e.charCodeAt(0)===95&&e.charCodeAt(1)===95,P=(e,t,r,s)=>{if((0,l.isFunction)(e))return t?typeof e.call!="function"?e:e.call(t,t,r||t.state,s||t.context):void 0;if(e!=null&&t?.context?.plugins&&((0,l.isArray)(e)||(0,l.isObject)(e)&&!(0,g.isDOMNode)(e))){const n=t.context.plugins;for(const o of n)if(o.resolveHandler){const i=o.resolveHandler(e,t);if(typeof i=="function")return P(i,t,r,s)}}return e},G=(e,t,r)=>{for(const s in t)e[s]=P(t[s],r)},H=(e,t,r=[])=>{const s=r instanceof Set;for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(O(n)||(s?r.has(n):r.includes(n))||e[n]===void 0&&(e[n]=t[n]));return e},m=(e,t,r=D.METHODS_EXL)=>v(e,t,r,null),v=(e,t,r,s)=>{if(e===t)return e;if(s){for(let o=0;o<s.length;o+=2)if(s[o]===e&&s[o+1]===t)return e}const n=r instanceof Set;for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||O(o)||o==="constructor"||o==="prototype"||(n?r.has(o):r.includes(o)))continue;const i=e[o],c=t[o];if((0,l.isObjectLike)(i)&&(0,l.isObjectLike)(c)){const u=s||[];u.push(e,t),v(i,c,r,u),u.length-=2}else i===void 0&&(e[o]=c)}return e},z=(e,t=[])=>{const r=t instanceof Set,s={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(O(n)||(r?t.has(n):t.includes(n))||(s[n]=e[n]));return s},U=(e,t={})=>{const{exclude:r=[],cleanUndefined:s=!1,cleanNull:n=!1,visited:o=new WeakMap,handleExtends:i=!1}=t;if(!(0,l.isObjectLike)(e)||(0,g.isDOMNode)(e))return e;if(o.has(e))return o.get(e);const c=r instanceof Set?r:r.length>3?new Set(r):null,u=y=>c?c.has(y):r.includes(y),f=(0,l.isArray)(e)?[]:{};o.set(e,f);const p=[[e,f]];for(;p.length;){const[y,d]=p.pop();for(const h in y){if(!Object.prototype.hasOwnProperty.call(y,h)||O(h)||h==="__proto__"||u(h))continue;const a=y[h];if(!(s&&a===void 0)&&!(n&&a===null)){if((0,g.isDOMNode)(a)){d[h]=a;continue}if(i&&h==="extends"&&(0,l.isArray)(a)){d[h]=(0,T.unstackArrayOfObjects)(a,r);continue}if((0,l.isFunction)(a)){d[h]=a;continue}if((0,l.isObjectLike)(a))if(o.has(a))d[h]=o.get(a);else{const w=(0,l.isArray)(a)?[]:{};o.set(a,w),d[h]=w,p.push([a,w])}else d[h]=a}}}return f},$=(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 r in e){const s=e[r];if((0,l.isFunction)(s))t[r]=s.toString();else if((0,l.isObject)(s))t[r]={},$(s,t[r]);else if((0,l.isArray)(s)){const n=t[r]=[];for(let o=0;o<s.length;o++){const i=s[o];(0,l.isObject)(i)?(n[o]={},$(i,n[o])):(0,l.isFunction)(i)?n[o]=i.toString():n[o]=i}}else t[r]=s}return t},V=new Set(["&","*","-",":","%","{","}",">","<","@",".","/","!"," "]),k=(e={},t=0)=>{if(e===null||typeof e!="object")return String(e);let r=!1;for(const o in e){r=!0;break}if(!r)return"{}";const s=" ".repeat(t);let n=`{
2
- `;for(const o in e){if(!Object.prototype.hasOwnProperty.call(e,o))continue;const i=e[o];let c=!1;for(let f=0;f<o.length;f++)if(V.has(o[f])){c=!0;break}const u=c?`'${o}'`:o;if(n+=`${s} ${u}: `,(0,l.isArray)(i)){n+=`[
3
- `;for(const f of i)(0,l.isObjectLike)(f)&&f!==null?n+=`${s} ${k(f,t+2)},
4
- `:(0,l.isString)(f)?n+=`${s} '${f}',
5
- `:n+=`${s} ${f},
6
- `;n+=`${s} ]`}else(0,l.isObjectLike)(i)?n+=k(i,t+1):(0,l.isString)(i)?n+=(0,N.stringIncludesAny)(i,[`
7
- `,"'"])?`\`${i}\``:`'${i}'`:n+=i;n+=`,
8
- `}return n+=`${s}}`,n},Z=[/^\(\s*\{[^}]*\}\s*\)\s*=>/,/^(\([^)]*\)|[^=]*)\s*=>/,/^function[\s(]/,/^async\s+/,/^\(\s*function/,/^[a-zA-Z_$][a-zA-Z0-9_$]*\s*=>/],K=/^["[{]/,X=/^(export|import)\s/,S=e=>{if(!e)return!1;const t=e.trim().replace(/\n\s*/g," ").trim();if(t===""||t==="{}"||t==="[]"||X.test(t)||!Z.some(o=>o.test(t)))return!1;const s=t.charCodeAt(0),n=t.includes("=>");return!(s===123&&!n||s===91||K.test(t)&&!n)},Y=e=>(0,eval)(e),Q=(e,t)=>{const r=/^(\s*(?:async\s+)?function\s*[\w$]*\s*\([^)]*\)\s*)\{/.exec(e);if(!r)return null;const s=r[0].length,n=[];let o=s,i=1,c=null;const u=e.length,f=new RegExp("^(?:const|let|var)\\s+"+t+"\\b");for(;o<u&&i>0;){const y=e[o];if(y==="/"&&e[o+1]==="/"){const d=e.indexOf(`
9
- `,o);o=d===-1?u:d;continue}if(y==="/"&&e[o+1]==="*"){const d=e.indexOf("*/",o+2);o=d===-1?u:d+2;continue}if(y==='"'||y==="'"||y==="`"){const d=y;for(o++;o<u;){if(e[o]==="\\"){o+=2;continue}if(e[o]===d){o++;break}if(d==="`"&&e[o]==="$"&&e[o+1]==="{"){o+=2;let h=1;for(;o<u&&h>0;)e[o]==="{"?h++:e[o]==="}"&&h--,o++;continue}o++}continue}if(y==="{"){i++,o++;continue}if(y==="}"){i--,o++;continue}if(i===1&&f.test(e.slice(o))){const d=o;let h=0,a=o;for(;a<u;){const w=e[a];if(w==='"'||w==="'"||w==="`"){const L=w;for(a++;a<u;){if(e[a]==="\\"){a+=2;continue}if(e[a]===L){a++;break}a++}continue}if(w==="("||w==="["||w==="{"){h++,a++;continue}if(w===")"||w==="]"||w==="}"){if(h===0)break;h--,a++;continue}if(h===0&&(w===";"||w===`
10
- `)){a++;break}a++}n.push([d,a]),o=a;continue}o++}if(!n.length)return null;let p=e;for(let y=n.length-1;y>=0;y--)p=p.slice(0,n[y][0])+p.slice(n[y][1]);return p},A=(e,t,r)=>{const s=String(e).trimStart();if(/^(export|import)\s/.test(s))return e;try{return r.window.eval(`(${e})`)}catch(n){const o=n&&n.message?n.message:String(n),i=/await is only valid in async/.test(o),c=/Identifier '([^']+)' has already been declared/.exec(o);let u=null;if(i){const f=String(e).trim();if(/^function[\s(]/.test(f))try{u=r.window.eval("(async "+f+")")}catch{}}else if(c){let f=String(e),p=c[1];for(let y=0;y<5;y++){const d=Q(f,p);if(!d||d===f)break;f=d;try{u=r.window.eval("("+f+")");break}catch(h){const a=/Identifier '([^']+)' has already been declared/.exec(h&&h.message||String(h));if(!a||a[1]!==p)break}}}return u||(typeof console<"u"&&console.warn&&console.warn(`[smbls] deepDestringifyFunctions: eval failed on ${t} \u2014 value will be left as a string. Reason: `+o+`.
11
- First 200 chars of source: `+String(e).slice(0,200)),e)}},j=(e,t={},r={window:{eval:Y}})=>{if(!e||typeof e!="object")return t;const s=[[e,t]];for(;s.length;){const[n,o]=s.pop();for(const i in n){if(!Object.prototype.hasOwnProperty.call(n,i))continue;const c=n[i];if((0,l.isString)(c))S(c)?o[i]=A(c,`"${i}"`,r):o[i]=c;else if((0,l.isArray)(c)){const u=o[i]=[];for(let f=0;f<c.length;f++){const p=c[f];if((0,l.isString)(p))u.push(S(p)?A(p,`array index ${f} (prop "${i}")`,r):p);else if((0,l.isObject)(p)){const y={};u.push(y),s.push([p,y])}else u.push(p)}}else if((0,l.isObject)(c)){const u=o[i]&&typeof o[i]=="object"&&!(0,l.isArray)(o[i])?o[i]:o[i]={};s.push([c,u])}else o[i]=c}}return t},ee="Set",te="Map",ne=e=>!e||typeof e!="object"?e:e.__type===ee&&Array.isArray(e.values)?new Set(e.values):e.__type===te&&Array.isArray(e.entries)?new Map(e.entries):e,re=e=>{if(!e||typeof e!="object")return e;const t={},r=[];for(const i of Object.keys(e)){const c=e[i];(0,l.isString)(c)&&S(c)?r.push([i,c]):t[i]=ne(c)}if(r.length===0)return t;const s=i=>/^[A-Za-z_$][\w$]*$/.test(i),n=r.filter(([i])=>s(i)),o=Object.keys(t).filter(s).map(i=>`var ${i} = __gs__[${JSON.stringify(i)}];`).join(`
12
- `);try{const i=n.map(([f,p])=>`var ${f} = (${p});`).join(`
13
- `),c="{ "+n.map(([f])=>`${JSON.stringify(f)}: ${f}`).join(", ")+" }",u=_.window.eval(`(function(__gs__) { ${o}
14
- ${i}
15
- return ${c}; })`)(t);Object.assign(t,u)}catch{for(const[c,u]of n)try{const f=Object.keys(t).filter(s).map(p=>`var ${p} = __gs__[${JSON.stringify(p)}];`).join(`
16
- `);t[c]=_.window.eval(`(function(__gs__) { ${f}
17
- return (${u}); })`)(t)}catch{try{t[c]=_.window.eval(`(${u})`)}catch{t[c]=u}}}for(const[i,c]of r)if(!s(i))try{t[i]=_.window.eval(`(${c})`)}catch{t[i]=c}return t},oe=(e,t={verbose:!0})=>{try{return e?_.window.eval("("+e+")"):{}}catch(r){t.verbose&&console.warn(r)}},se=(e,...t)=>Object.prototype.hasOwnProperty.call(e,...t),C=e=>{for(const t in e)return!1;return!0},ie=e=>(0,l.isObject)(e)&&C(e),ce=()=>Object.create(null),fe=(e,t,r={})=>{const s=r.exclude||[],n=r.preventUnderscore;for(const o in t)s.includes(o)||!n&&O(o)||o==="constructor"||o==="prototype"||t[o]!==void 0&&(e[o]=t[o]);return e},le=(e,t,r=[])=>{const s=r instanceof Set;for(const n in t)O(n)||n==="constructor"||n==="prototype"||(s?r.has(n):r.includes(n))||(e[n]=t[n]);return e},I=(e,t,r={},s=new WeakMap)=>{if(!(0,l.isObjectLike)(e)||!(0,l.isObjectLike)(t)||(0,g.isDOMNode)(e)||(0,g.isDOMNode)(t))return t;if(s.has(e))return s.get(e);s.set(e,e);const n=r.exclude,o=n?n instanceof Set?n:new Set(n):null,i=!r.preventForce;for(const c in t){if(!Object.prototype.hasOwnProperty.call(t,c)||o&&o.has(c)||i&&O(c)||c==="constructor"||c==="prototype")continue;const u=e[c],f=t[c];(0,g.isDOMNode)(f)?e[c]=f:(0,l.isObjectLike)(u)&&(0,l.isObjectLike)(f)?e[c]=I(u,f,r,s):f!==void 0&&(e[c]=f)}return e},M=(e,t,r=new Set)=>{if(typeof e!="object"||typeof t!="object"||e===null||t===null)return e===t;if(r.has(e)||r.has(t))return!0;r.add(e),r.add(t);const s=Object.keys(e),n=Object.keys(t);if(s.length!==n.length)return!1;for(let o=0;o<s.length;o++){const i=s[o];if(!Object.prototype.hasOwnProperty.call(t,i)||!M(e[i],t[i],r))return!1}return!0},ue=new Set(["node","__ref"]),ae=(e,t,r=ue)=>{if(e===t)return!0;if(!(0,l.isObjectLike)(e)||!(0,l.isObjectLike)(t)||(0,g.isDOMNode)(e)||(0,g.isDOMNode)(t))return e===t;const s=r instanceof Set?r:new Set(r),n=new WeakSet;function o(i,c){if(n.has(c))return!0;n.add(c);for(const u in c){if(!Object.prototype.hasOwnProperty.call(c,u)||s.has(u))continue;if(!Object.prototype.hasOwnProperty.call(i,u))return!1;const f=c[u],p=i[u];if((0,g.isDOMNode)(f)||(0,g.isDOMNode)(p)){if(f!==p)return!1}else if((0,l.isObjectLike)(f)&&(0,l.isObjectLike)(p)){if(!o(p,f))return!1}else if(f!==p)return!1}return!0}return o(e,t)},pe=(e,t)=>{if(t==null)return e;if((0,l.is)(t)("string","number"))delete e[t];else if((0,l.isArray)(t))for(let r=0;r<t.length;r++)delete e[t[r]];else throw new Error("Invalid input: props must be a string or an array of strings");return e},R=e=>{if(e===null||typeof e!="object")return e;const t=Object.create(null);for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=R(e[r]));return t},ye=(e,t)=>{if(e.length===0)return t;const r={};let s=r;for(let n=0;n<e.length;n++)n===e.length-1&&t?s[e[n]]=t:(s[e[n]]={},s=s[e[n]]);return r},he=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let r=e;for(let n=0;n<t.length-1;n++){if(r[t[n]]===void 0)return;r=r[t[n]]}const s=t[t.length-1];r&&Object.prototype.hasOwnProperty.call(r,s)&&delete r[s]},de=(e,t,r)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let s=e;for(let n=0;n<t.length-1;n++)(!s[t[n]]||typeof s[t[n]]!="object")&&(s[t[n]]={}),s=s[t[n]];return s[t[t.length-1]]=r,e},we=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let r=e;for(let s=0;s<t.length;s++){if(r==null)return;r=r[t[s]]}return r},ge=e=>{let r=[],s=0;for(let n=0;n<e.length;n++)if(r.length<2)r.push(e[n]);else if(e[n]===r[n%2]?s++:(r=[e[n-1],e[n]],s=1),s>=20)return(E==="test"||E==="development")&&console.warn("Warning: Potential infinite loop detected due to repeated sequence:",r),!0},Oe=e=>{const t=new WeakSet;function r(s){if(s&&typeof s=="object"){if(t.has(s))return!0;t.add(s);for(const n in s)if(Object.prototype.hasOwnProperty.call(s,n)&&r(s[n]))return console.log(s,"cycle at "+n),!0}return!1}return r(e)},_e=(e,t)=>{const r=t instanceof Set?t:new Set(t),s={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&!r.has(n)&&(s[n]=e[n]);return s};
1
+ "use strict";var x=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var U=(e,t)=>{for(var o in t)x(e,o,{get:t[o],enumerable:!0})},Z=(e,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of H(t))!K.call(e,n)&&n!==o&&x(e,n,{get:()=>t[n],enumerable:!(i=z(t,n))||i.enumerable});return e};var V=e=>Z(x({},"__esModule",{value:!0}),e);var $e={};U($e,{clone:()=>j,createNestedObject:()=>we,createObjectWithoutPrototype:()=>Y,deepClone:()=>ee,deepContains:()=>ge,deepDestringifyFunctions:()=>ce,deepMerge:()=>Q,deepStringifyFunctions:()=>P,destringifyGlobalScope:()=>fe,detectInfiniteLoop:()=>xe,excludeKeysFromObject:()=>Pe,exec:()=>E,getInObjectByPath:()=>ke,hasFunction:()=>k,hasOwnProperty:()=>le,isCyclic:()=>Ee,isEmpty:()=>m,isEmptyObject:()=>ae,isEqualDeep:()=>J,makeObjectWithoutPrototype:()=>pe,map:()=>X,merge:()=>v,objectToString:()=>$,overwrite:()=>ye,overwriteDeep:()=>B,overwriteShallow:()=>he,removeFromObject:()=>_e,removeNestedKeyByPath:()=>Oe,setInObjectByPath:()=>Se,stringToObject:()=>ue});module.exports=V($e);var O=require("./globals.js"),u=require("./types.js"),G=require("./array.js"),L=require("./string.js"),_=require("./node.js"),F=require("./keys.js");const A="production",w=e=>e.charCodeAt(0)===95&&e.charCodeAt(1)===95,E=(e,t,o,i)=>{if((0,u.isFunction)(e))return t?typeof e.call!="function"?e:e.call(t,t,o||t.state,i||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 s=r.resolveHandler(e,t);if(typeof s=="function")return E(s,t,o,i)}}return e},X=(e,t,o)=>{for(const i in t)e[i]=E(t[i],o)},v=(e,t,o=[])=>{const i=o instanceof Set;for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(w(n)||(i?o.has(n):o.includes(n))||e[n]===void 0&&(e[n]=t[n]));return e},Q=(e,t,o=F.METHODS_EXL)=>T(e,t,o,null),T=(e,t,o,i)=>{if(e===t)return e;if(i){for(let r=0;r<i.length;r+=2)if(i[r]===e&&i[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 s=e[r],f=t[r];if((0,u.isObjectLike)(s)&&(0,u.isObjectLike)(f)){const l=i||[];l.push(e,t),T(s,f,o,l),l.length-=2}else s===void 0&&(e[r]=f)}return e},j=(e,t=[])=>{const o=t instanceof Set,i={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(w(n)||(o?t.has(n):t.includes(n))||(i[n]=e[n]));return i},ee=(e,t={})=>{const{exclude:o=[],cleanUndefined:i=!1,cleanNull:n=!1,visited:r=new WeakMap,handleExtends:s=!1}=t;if(!(0,u.isObjectLike)(e)||(0,_.isDOMNode)(e))return e;if(r.has(e))return r.get(e);const f=o instanceof Set?o:o.length>3?new Set(o):null,l=y=>f?f.has(y):o.includes(y),c=(0,u.isArray)(e)?[]:{};r.set(e,c);const a=[[e,c]];for(;a.length;){const[y,d]=a.pop();for(const h in y){if(!Object.prototype.hasOwnProperty.call(y,h)||w(h)||h==="__proto__"||l(h))continue;const p=y[h];if(!(i&&p===void 0)&&!(n&&p===null)){if((0,_.isDOMNode)(p)){d[h]=p;continue}if(s&&h==="extends"&&(0,u.isArray)(p)){d[h]=(0,G.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 c},P=(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 i=e[o];if((0,u.isFunction)(i))t[o]=i.toString();else if((0,u.isObject)(i))t[o]={},P(i,t[o]);else if((0,u.isArray)(i)){const n=t[o]=[];for(let r=0;r<i.length;r++){const s=i[r];(0,u.isObject)(s)?(n[r]={},P(s,n[r])):(0,u.isFunction)(s)?n[r]=s.toString():n[r]=s}}else t[o]=i}return t},te=new Set(["&","*","-",":","%","{","}",">","<","@",".","/","!"," "]),$=(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 i=" ".repeat(t);let n=`{
2
+ `;for(const r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;const s=e[r];let f=!1;for(let c=0;c<r.length;c++)if(te.has(r[c])){f=!0;break}const l=f?`'${r}'`:r;if(n+=`${i} ${l}: `,s instanceof RegExp)n+=String(s);else if((0,u.isArray)(s)){n+=`[
3
+ `;for(const c of s)c instanceof RegExp?n+=`${i} ${String(c)},
4
+ `:(0,u.isObjectLike)(c)&&c!==null?n+=`${i} ${$(c,t+2)},
5
+ `:(0,u.isString)(c)?n+=`${i} '${c}',
6
+ `:n+=`${i} ${c},
7
+ `;n+=`${i} ]`}else(0,u.isObjectLike)(s)?n+=$(s,t+1):(0,u.isString)(s)?n+=(0,L.stringIncludesAny)(s,[`
8
+ `,"'"])?`\`${s}\``:`'${s}'`:n+=s;n+=`,
9
+ `}return n+=`${i}}`,n},ne=[/^\(\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]*\}$/],re=/^["[{]/,oe=/^(export|import)\s/,k=e=>{if(!e)return!1;const t=e.trim().replace(/\n\s*/g," ").trim();if(t===""||t==="{}"||t==="[]"||oe.test(t)||!ne.some(r=>r.test(t)))return!1;const i=t.charCodeAt(0),n=t.includes("=>");return!(i===123&&!n||i===91||re.test(t)&&!n)},ie=e=>(0,eval)(e),se=(e,t)=>{const o=/^(\s*(?:async\s+)?function\s*[\w$]*\s*\([^)]*\)\s*)\{/.exec(e);if(!o)return null;const i=o[0].length,n=[];let r=i,s=1,f=null;const l=e.length,c=new RegExp("^(?:const|let|var)\\s+"+t+"\\b");for(;r<l&&s>0;){const y=e[r];if(y==="/"&&e[r+1]==="/"){const d=e.indexOf(`
10
+ `,r);r=d===-1?l:d;continue}if(y==="/"&&e[r+1]==="*"){const d=e.indexOf("*/",r+2);r=d===-1?l:d+2;continue}if(y==='"'||y==="'"||y==="`"){const d=y;for(r++;r<l;){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<l&&h>0;)e[r]==="{"?h++:e[r]==="}"&&h--,r++;continue}r++}continue}if(y==="{"){s++,r++;continue}if(y==="}"){s--,r++;continue}if(s===1&&c.test(e.slice(r))){const d=r;let h=0,p=r;for(;p<l;){const g=e[p];if(g==='"'||g==="'"||g==="`"){const q=g;for(p++;p<l;){if(e[p]==="\\"){p+=2;continue}if(e[p]===q){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},N=(e,t,o)=>{const i=String(e).trimStart();if(/^(export|import)\s/.test(i))return e;try{return o.window.eval(`(${e})`)}catch(n){const r=n&&n.message?n.message:String(n),s=/await is only valid in async/.test(r),f=/Identifier '([^']+)' has already been declared/.exec(r);let l=null;if(s){const c=String(e).trim();if(/^function[\s(]/.test(c))try{l=o.window.eval("(async "+c+")")}catch{}}else if(f){let c=String(e),a=f[1];for(let y=0;y<5;y++){const d=se(c,a);if(!d||d===c)break;c=d;try{l=o.window.eval("("+c+")");break}catch(h){const p=/Identifier '([^']+)' has already been declared/.exec(h&&h.message||String(h));if(!p||p[1]!==a)break}}}if(!l&&/Unexpected (token '\{'|identifier)/.test(r))try{const c=o.window.eval("({"+e+"})");if(c&&typeof c=="object"){const a=Object.keys(c);a.length===1&&typeof c[a[0]]=="function"&&(l=c[a[0]])}}catch{}return l||(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)}},ce=(e,t={},o={window:{eval:ie}})=>{if(!e||typeof e!="object")return t;const i=[[e,t]];for(;i.length;){const[n,r]=i.pop();for(const s in n){if(!Object.prototype.hasOwnProperty.call(n,s))continue;const f=n[s];if((0,u.isString)(f))k(f)?r[s]=N(f,`"${s}"`,o):r[s]=f;else if((0,u.isArray)(f)){const l=r[s]=[];for(let c=0;c<f.length;c++){const a=f[c];if((0,u.isString)(a))l.push(k(a)?N(a,`array index ${c} (prop "${s}")`,o):a);else if((0,u.isObject)(a)){const y=b(a);if(y)l.push(y);else{const d={};l.push(d),i.push([a,d])}}else l.push(a)}}else if((0,u.isObject)(f)){const l=b(f);if(l){r[s]=l;continue}const c=r[s]&&typeof r[s]=="object"&&!(0,u.isArray)(r[s])?r[s]:r[s]={};i.push([f,c])}else r[s]=f}}return t},R="Set",M="Map",D="RegExp",W="WeakMap",C="WeakSet",I=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===R&&(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===W&&I(e))return new WeakMap;if(e.__type===C&&I(e))return new WeakSet;if(e.__type===D&&(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 i=!1;if((0,u.isArray)(e)){const r=new Array(e.length);t.set(e,r);for(let s=0;s<e.length;s++)r[s]=S(e[s],t),r[s]!==e[s]&&(i=!0);return i||t.set(e,e),i?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]&&(i=!0);return i||t.set(e,e),i?n:e},b=e=>{if(!e||typeof e!="object")return null;const t=e.__type;if(t!==D&&t!==R&&t!==M&&t!==W&&t!==C)return null;const o=S(e);return o===e?null:o},fe=e=>{if(!e||typeof e!="object")return e;const t={},o=[];for(const s of Object.keys(e)){const f=e[s];(0,u.isString)(f)&&k(f)?o.push([s,f]):t[s]=S(f)}if(o.length===0)return t;const i=s=>/^[A-Za-z_$][\w$]*$/.test(s),n=o.filter(([s])=>i(s)),r=Object.keys(t).filter(i).map(s=>`var ${s} = __gs__[${JSON.stringify(s)}];`).join(`
13
+ `);try{const s=n.map(([c,a])=>`var ${c} = (${a});`).join(`
14
+ `),f="{ "+n.map(([c])=>`${JSON.stringify(c)}: ${c}`).join(", ")+" }",l=O.window.eval(`(function(__gs__) { ${r}
15
+ ${s}
16
+ return ${f}; })`)(t);Object.assign(t,l)}catch{for(const[f,l]of n)try{const c=Object.keys(t).filter(i).map(a=>`var ${a} = __gs__[${JSON.stringify(a)}];`).join(`
17
+ `);t[f]=O.window.eval(`(function(__gs__) { ${c}
18
+ return (${l}); })`)(t)}catch{try{t[f]=O.window.eval(`(${l})`)}catch{t[f]=l}}}for(const[s,f]of o)if(!i(s))try{t[s]=O.window.eval(`(${f})`)}catch{t[s]=f}return t},ue=(e,t={verbose:!0})=>{try{return e?O.window.eval("("+e+")"):{}}catch(o){t.verbose&&console.warn(o)}},le=(e,...t)=>Object.prototype.hasOwnProperty.call(e,...t),m=e=>{for(const t in e)return!1;return!0},ae=e=>(0,u.isObject)(e)&&m(e),pe=()=>Object.create(null),ye=(e,t,o={})=>{const i=o.exclude||[],n=o.preventUnderscore;for(const r in t)i.includes(r)||!n&&w(r)||r==="constructor"||r==="prototype"||t[r]!==void 0&&(e[r]=t[r]);return e},he=(e,t,o=[])=>{const i=o instanceof Set;for(const n in t)w(n)||n==="constructor"||n==="prototype"||(i?o.has(n):o.includes(n))||(e[n]=t[n]);return e},B=(e,t,o={},i=new WeakMap)=>{if(!(0,u.isObjectLike)(e)||!(0,u.isObjectLike)(t)||(0,_.isDOMNode)(e)||(0,_.isDOMNode)(t))return t;if(i.has(e))return i.get(e);i.set(e,e);const n=o.exclude,r=n?n instanceof Set?n:new Set(n):null,s=!o.preventForce;for(const f in t){if(!Object.prototype.hasOwnProperty.call(t,f)||r&&r.has(f)||s&&w(f)||f==="constructor"||f==="prototype")continue;const l=e[f],c=t[f];(0,_.isDOMNode)(c)?e[f]=c:(0,u.isObjectLike)(l)&&(0,u.isObjectLike)(c)?e[f]=B(l,c,o,i):c!==void 0&&(e[f]=c)}return e},J=(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 i=Object.keys(e),n=Object.keys(t);if(i.length!==n.length)return!1;for(let r=0;r<i.length;r++){const s=i[r];if(!Object.prototype.hasOwnProperty.call(t,s)||!J(e[s],t[s],o))return!1}return!0},de=new Set(["node","__ref"]),ge=(e,t,o=de)=>{if(e===t)return!0;if(!(0,u.isObjectLike)(e)||!(0,u.isObjectLike)(t)||(0,_.isDOMNode)(e)||(0,_.isDOMNode)(t))return e===t;const i=o instanceof Set?o:new Set(o),n=new WeakSet;function r(s,f){if(n.has(f))return!0;n.add(f);for(const l in f){if(!Object.prototype.hasOwnProperty.call(f,l)||i.has(l))continue;if(!Object.prototype.hasOwnProperty.call(s,l))return!1;const c=f[l],a=s[l];if((0,_.isDOMNode)(c)||(0,_.isDOMNode)(a)){if(c!==a)return!1}else if((0,u.isObjectLike)(c)&&(0,u.isObjectLike)(a)){if(!r(a,c))return!1}else if(c!==a)return!1}return!0}return r(e,t)},_e=(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},Y=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]=Y(e[o]));return t},we=(e,t)=>{if(e.length===0)return t;const o={};let i=o;for(let n=0;n<e.length;n++)n===e.length-1&&t?i[e[n]]=t:(i[e[n]]={},i=i[e[n]]);return o},Oe=(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 i=t[t.length-1];o&&Object.prototype.hasOwnProperty.call(o,i)&&delete o[i]},Se=(e,t,o)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let i=e;for(let n=0;n<t.length-1;n++)(!i[t[n]]||typeof i[t[n]]!="object")&&(i[t[n]]={}),i=i[t[n]];return i[t[t.length-1]]=o,e},ke=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let o=e;for(let i=0;i<t.length;i++){if(o==null)return;o=o[t[i]]}return o},xe=e=>{let o=[],i=0;for(let n=0;n<e.length;n++)if(o.length<2)o.push(e[n]);else if(e[n]===o[n%2]?i++:(o=[e[n-1],e[n]],i=1),i>=20)return(A==="test"||A==="development")&&console.warn("Warning: Potential infinite loop detected due to repeated sequence:",o),!0},Ee=e=>{const t=new WeakSet;function o(i){if(i&&typeof i=="object"){if(t.has(i))return!0;t.add(i);for(const n in i)if(Object.prototype.hasOwnProperty.call(i,n)&&o(i[n]))return console.log(i,"cycle at "+n),!0}return!1}return o(e)},Pe=(e,t)=>{const o=t instanceof Set?t:new Set(t),i={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&!o.has(n)&&(i[n]=e[n]);return i};
@@ -1 +1 @@
1
- "use strict";var u=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var S=(n,t)=>{for(var e in t)u(n,e,{get:t[e],enumerable:!0})},E=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of R(t))!U.call(n,o)&&o!==e&&u(n,o,{get:()=>t[o],enumerable:!(r=j(t,o))||r.enumerable});return n};var O=n=>E(u({},"__esModule",{value:!0}),n);var N={};S(N,{deepDefaults:()=>d,fetchLibraryData:()=>k,isWrappedLibrary:()=>y,mergeSharedLibraries:()=>F,normalizeIgnoreList:()=>p,normalizeLibraryKey:()=>l,resolveSharedLibraries:()=>K,sharedLibrary:()=>C});module.exports=O(N);var a=require("./types.js");const b="system",_="https://smbls-kv.nika-980.workers.dev",P="https://api.symbols.app";function l(n){const t=String(n||"").trim();if(!t)return{owner:b,key:"",full:""};let e=null,r=t;if(t.includes("/")){const s=t.indexOf("/");e=t.slice(0,s),r=t.slice(s+1)}r=r.replace(/\.symbo\.ls$/iu,""),e||(e=b);const o=r?`${e}/${r}`:"";return{owner:e,key:r,full:o}}const d=(n,t,e,r)=>{for(const o in t){const s=r?`${r}/${o}`:o;e&&e.has(s)||(o in n?(0,a.isObject)(n[o])&&(0,a.isObject)(t[o])&&d(n[o],t[o],e,s):n[o]=t[o])}},w=(n,t,e)=>{if(!(0,a.isObject)(n)||!t.size)return n;const r=`${e}/`;let o=!1;for(const i of t)if(i.startsWith(r)){o=!0;break}if(!o)return n;const s={};for(const i in n){if(!Object.prototype.hasOwnProperty.call(n,i))continue;const f=`${e}/${i}`;t.has(f)||(s[i]=w(n[i],t,f))}return s},B=new Set,x=n=>n.replace(/\.js$/iu,""),p=n=>{const t=new Set;if(!Array.isArray(n))return t;for(const e of n){if(!(0,a.isString)(e))continue;const r=e.split("/").map(o=>x(o.trim())).filter(Boolean).join("/");r&&t.add(r)}return t},C=(n,t={})=>({library:n,ignoreList:Array.isArray(t.ignoreList)?t.ignoreList:[]}),y=n=>(0,a.isObject)(n)&&Array.isArray(n.ignoreList)&&("library"in n||"key"in n||"name"in n),T=n=>n.library!==void 0?n.library:n.key??n.name,z=(n,t,e)=>{const r=p(t.sharedLibIgnore);t.sharePages===!1&&r.add("pages");const o=r.size?new Set([...e,...r]):e;for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)&&!(s==="sharePages"||s==="sharedLibIgnore")&&!o.has(s))if((0,a.isObject)(t[s])&&(0,a.isObject)(n[s]))if(s==="designSystem")d(n[s],t[s],o,s);else for(const i in t[s])o.has(`${s}/${i}`)||i in n[s]||(n[s][i]=t[s][i]);else s in n||(n[s]=w(t[s],o,s))},F=(n,t)=>{if(!(!t||!t.length))for(let e=0;e<t.length;e++){let r=t[e],o=B;y(r)&&(o=p(r.ignoreList),r=r.library),(0,a.isObject)(r)&&z(n,r,o)}};async function k(n,t={}){if((t.provider||"kv")==="api")return $(n,t);const r=await G(n,t);return r||$(n,t)}async function G(n,t={}){const e=t.kvBaseUrl||_,r=t.env||"production",o=`${e}/kv/${encodeURIComponent(n)}?env=${r}`;try{const s=await fetch(o,{method:"GET"});return s.ok&&(await s.json())?.value||null}catch{return null}}async function $(n,t={}){const e=t.apiBaseUrl||P,{key:r}=l(n);try{const o=`${e}/core/projects/libraries/available?search=${encodeURIComponent(r)}&limit=10`,s=await fetch(o,{method:"GET"});if(!s.ok)return null;const i=await s.json(),c=(i?.items||i?.data||(Array.isArray(i)?i:[])).find(v=>{const{key:I}=l(v?.key);return I.toLowerCase()===r.toLowerCase()});if(!c?.id&&!c?._id)return null;const L=c.id||c._id,A=`${e}/core/projects/${encodeURIComponent(L)}/data?branch=main`,h=await fetch(A,{method:"GET"});if(!h.ok)return null;const m=await h.json();return m?.data||m||null}catch{return null}}async function g(n,t={}){if((0,a.isObject)(n))return n;if((0,a.isString)(n)){const{full:e}=l(n);if(!e)return null;try{const r=await k(e,t);return r||console.warn(`[smbls] Shared library "${e}" not found`),r}catch(r){return console.warn(`[smbls] Failed to fetch shared library "${e}":`,r.message),null}}return null}async function K(n,t={}){return!n||!n.length?[]:(await Promise.all(n.map(async r=>{if(y(r)){const o=await g(T(r),t);return o?{library:o,ignoreList:r.ignoreList}:null}return g(r,t)}))).filter(Boolean)}
1
+ "use strict";var u=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var E=(n,t)=>{for(var o in t)u(n,o,{get:t[o],enumerable:!0})},O=(n,t,o,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of R(t))!U.call(n,s)&&s!==o&&u(n,s,{get:()=>t[s],enumerable:!(e=j(t,s))||e.enumerable});return n};var _=n=>O(u({},"__esModule",{value:!0}),n);var x={};E(x,{deepDefaults:()=>p,fetchLibraryData:()=>L,isWrappedLibrary:()=>d,mergeSharedLibraries:()=>K,normalizeIgnoreList:()=>y,normalizeLibraryKey:()=>l,resolveSharedLibraries:()=>W,sharedLibrary:()=>z});module.exports=_(x);var a=require("./types.js");const b="system",B="https://smbls-kv.nika-980.workers.dev",P="https://api.symbols.app";function l(n){const t=String(n||"").trim();if(!t)return{owner:b,key:"",full:""};let o=null,e=t;if(t.includes("/")){const r=t.indexOf("/");o=t.slice(0,r),e=t.slice(r+1)}e=e.replace(/\.symbo\.ls$/iu,""),o||(o=b);const s=e?`${o}/${e}`:"";return{owner:o,key:e,full:s}}const p=(n,t,o,e)=>{for(const s in t){const r=e?`${e}/${s}`:s;o&&o.has(r)||(s in n?(0,a.isObject)(n[s])&&(0,a.isObject)(t[s])&&p(n[s],t[s],o,r):n[s]=t[s])}},w=(n,t,o)=>{if(!(0,a.isObject)(n)||!t.size)return n;const e=`${o}/`;let s=!1;for(const i of t)if(i.startsWith(e)){s=!0;break}if(!s)return n;const r={};for(const i in n){if(!Object.prototype.hasOwnProperty.call(n,i))continue;const f=`${o}/${i}`;t.has(f)||(r[i]=w(n[i],t,f))}return r},C=new Set,T=new Set(["components","pages","functions","snippets","methods"]),g=(n,t)=>t===""&&T.has(n),G=n=>n.replace(/\.js$/iu,""),y=n=>{const t=new Set;if(!Array.isArray(n))return t;for(const o of n){if(!(0,a.isString)(o))continue;const e=o.split("/").map(s=>G(s.trim())).filter(Boolean).join("/");e&&t.add(e)}return t},z=(n,t={})=>({library:n,ignoreList:Array.isArray(t.ignoreList)?t.ignoreList:[]}),d=n=>(0,a.isObject)(n)&&Array.isArray(n.ignoreList)&&("library"in n||"key"in n||"name"in n),F=n=>n.library!==void 0?n.library:n.key??n.name,J=(n,t,o)=>{const e=y(t.sharedLibIgnore);t.sharePages===!1&&e.add("pages");const s=e.size?new Set([...o,...e]):o;for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&!(r==="sharePages"||r==="sharedLibIgnore")&&!s.has(r))if((0,a.isObject)(t[r])&&(0,a.isObject)(n[r]))if(r==="designSystem")p(n[r],t[r],s,r);else for(const i in t[r])s.has(`${r}/${i}`)||(i in n[r]?g(r,n[r][i])&&!g(r,t[r][i])&&(n[r][i]=t[r][i]):n[r][i]=t[r][i]);else r in n||(n[r]=w(t[r],s,r))},K=(n,t)=>{if(!(!t||!t.length))for(let o=0;o<t.length;o++){let e=t[o],s=C;d(e)&&(s=y(e.ignoreList),e=e.library),(0,a.isObject)(e)&&J(n,e,s)}};async function L(n,t={}){if((t.provider||"kv")==="api")return $(n,t);const e=await N(n,t);return e||$(n,t)}async function N(n,t={}){const o=t.kvBaseUrl||B,e=t.env||"production",s=`${o}/kv/${encodeURIComponent(n)}?env=${e}`;try{const r=await fetch(s,{method:"GET"});return r.ok&&(await r.json())?.value||null}catch{return null}}async function $(n,t={}){const o=t.apiBaseUrl||P,{key:e}=l(n);try{const s=`${o}/core/projects/libraries/available?search=${encodeURIComponent(e)}&limit=10`,r=await fetch(s,{method:"GET"});if(!r.ok)return null;const i=await r.json(),c=(i?.items||i?.data||(Array.isArray(i)?i:[])).find(v=>{const{key:I}=l(v?.key);return I.toLowerCase()===e.toLowerCase()});if(!c?.id&&!c?._id)return null;const A=c.id||c._id,S=`${o}/core/projects/${encodeURIComponent(A)}/data?branch=main`,h=await fetch(S,{method:"GET"});if(!h.ok)return null;const m=await h.json();return m?.data||m||null}catch{return null}}async function k(n,t={}){if((0,a.isObject)(n))return n;if((0,a.isString)(n)){const{full:o}=l(n);if(!o)return null;try{const e=await L(o,t);return e||console.warn(`[smbls] Shared library "${o}" not found`),e}catch(e){return console.warn(`[smbls] Failed to fetch shared library "${o}":`,e.message),null}}return null}async function W(n,t={}){return!n||!n.length?[]:(await Promise.all(n.map(async e=>{if(d(e)){const s=await k(F(e),t);return s?{library:s,ignoreList:e.ignoreList}:null}return k(e,t)}))).filter(Boolean)}
package/dist/cjs/state.js CHANGED
@@ -1 +1 @@
1
- "use strict";var a=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var w=(e,r)=>{for(var o in r)a(e,o,{get:r[o],enumerable:!0})},x=(e,r,o,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of S(r))!b.call(e,n)&&n!==o&&a(e,n,{get:()=>r[n],enumerable:!(t=P(r,n))||t.enumerable});return e};var v=e=>x(a({},"__esModule",{value:!0}),e);var B={};w(B,{applyDependentState:()=>A,checkForStateTypes:()=>O,checkIfInherits:()=>m,createInheritedState:()=>I,createNestedObjectByKeyPath:()=>k,findInheritedState:()=>y,getChildStateInKey:()=>g,getParentStateInKey:()=>h,getRootStateInKey:()=>d,isState:()=>j,overwriteState:()=>T});module.exports=v(B);var _=require("./array.js"),u=require("./keys.js"),l=require("./object.js"),s=require("./types.js");const O=e=>{const{state:r,props:o,__ref:t}=e,n=o?.state||r;return(0,s.is)(n)("string","number")?(t.__state=n,{value:n}):n===!0?(t.__state=e.key,{}):n?(t.__hasRootState=!0,n):!1},d=(e,r)=>{if(!e.includes("~/"))return;if(e.split("~/").length>1)return r.root},h=(e,r)=>{if(!e.includes("../"))return;const t=e.split("../").length-1;for(let n=0;n<t;n++){if(!r.parent)return null;r=r.parent}return r},g=(e,r,o={})=>{const t=(0,s.isString)(e)?e.split("/"):[e],n=t.length-1;for(let c=0;c<n;c++){const i=t[c],f=t[c+1];if(i==="__proto__"||f==="__proto__")return;let p=r[i];p||(p=r[i]={}),p[f]||(p[f]={}),e=f,r=p}return o.returnParent?r:r[e]},y=(e,r,o={})=>{let n=e.__ref.__state;if(!m(e))return;const c=d(n,r.state);let i=r.state;if(c)i=c,n=n.replaceAll("~/","");else{const f=h(n,r.state);f&&(i=f,n=n.replaceAll("../",""))}if(i)return g(n,i,o)},I=(e,r)=>{const o=e.__ref,t=y(e,r);if(t===void 0)return e.state;if((0,s.is)(t)("object","array"))return(0,l.deepClone)(t);if((0,s.is)(t)("string","number","boolean"))return o.__stateType=typeof t,{value:t};console.warn(o.__state,"is not present. Replacing with",{})},m=e=>{const{__ref:r}=e,o=r?.__state;return!!(o&&(0,s.is)(o)("number","string","boolean"))},j=function(e){return(0,s.isObjectLike)(e)?!!(e.update&&e.parse&&e.clean&&e.create&&e.parent&&e.destroy&&e.rootUpdate&&e.parentUpdate&&e.keys&&e.values&&e.toggle&&e.replace&&e.quietUpdate&&e.quietReplace&&e.add&&e.apply&&e.applyReplace&&e.setByPath&&e.setPathCollection&&e.removeByPath&&e.removePathCollection&&e.getByPath&&e.applyFunction&&e.__element&&e.__children):!1},k=(e,r)=>{if(!e)return r||{};const o=e.split("/"),t={};let n=t;const c=o.length-1;for(let i=0;i<=c;i++)n[o[i]]=i===c?r||{}:{},n=n[o[i]];return t},A=(e,r)=>{const{__element:o}=r,t=o?.state;if(!t)return;const n=(0,l.deepClone)(t,u.STATE_METHODS),c={[e.key]:n},i=(0,s.isObject)(t.__depends)?{...t.__depends,...c}:c;return Array.isArray(t)?(0,_.addProtoToArray)(t,{...Object.getPrototypeOf(t),__depends:i}):Object.setPrototypeOf(t,{...Object.getPrototypeOf(t),__depends:i}),n},T=(e,r,o={})=>{const{overwrite:t}=o;if(!t)return;const n=t==="shallow";if(t==="merge"){(0,l.deepMerge)(e,r,u.STATE_METHODS);return}(n?l.overwriteShallow:l.overwriteDeep)(e,r,u.STATE_METHODS)};
1
+ "use strict";var a=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var v=(e,r)=>{for(var o in r)a(e,o,{get:r[o],enumerable:!0})},O=(e,r,o,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of w(r))!x.call(e,n)&&n!==o&&a(e,n,{get:()=>r[n],enumerable:!(t=m(r,n))||t.enumerable});return e};var I=e=>O(a({},"__esModule",{value:!0}),e);var C={};v(C,{applyDependentState:()=>E,checkForStateTypes:()=>j,checkIfInherits:()=>P,createInheritedState:()=>k,createNestedObjectByKeyPath:()=>D,findInheritedState:()=>b,getChildStateInKey:()=>S,getParentStateInKey:()=>h,getRootStateInKey:()=>g,isPolyglotWritableKey:()=>T,isState:()=>A,markPolyglotSeeded:()=>B,overwriteState:()=>K,polyglotSeededKeys:()=>d});module.exports=I(C);var y=require("./array.js"),p=require("./keys.js"),l=require("./object.js"),c=require("./types.js");const j=e=>{const{state:r,props:o,__ref:t}=e,n=o?.state||r;return(0,c.is)(n)("string","number")?(t.__state=n,{value:n}):n===!0?(t.__state=e.key,{}):n?(t.__hasRootState=!0,n):!1},g=(e,r)=>{if(!e.includes("~/"))return;if(e.split("~/").length>1)return r.root},h=(e,r)=>{if(!e.includes("../"))return;const t=e.split("../").length-1;for(let n=0;n<t;n++){if(!r.parent)return null;r=r.parent}return r},S=(e,r,o={})=>{const t=(0,c.isString)(e)?e.split("/"):[e],n=t.length-1;for(let s=0;s<n;s++){const i=t[s],f=t[s+1];if(i==="__proto__"||f==="__proto__")return;let u=r[i];u||(u=r[i]={}),u[f]||(u[f]={}),e=f,r=u}return o.returnParent?r:r[e]},b=(e,r,o={})=>{let n=e.__ref.__state;if(!P(e))return;const s=g(n,r.state);let i=r.state;if(s)i=s,n=n.replaceAll("~/","");else{const f=h(n,r.state);f&&(i=f,n=n.replaceAll("../",""))}if(i)return S(n,i,o)},k=(e,r)=>{const o=e.__ref,t=b(e,r);if(t===void 0)return e.state;if((0,c.is)(t)("object","array"))return(0,l.deepClone)(t);if((0,c.is)(t)("string","number","boolean"))return o.__stateType=typeof t,{value:t};console.warn(o.__state,"is not present. Replacing with",{})},P=e=>{const{__ref:r}=e,o=r?.__state;return!!(o&&(0,c.is)(o)("number","string","boolean"))},A=function(e){return(0,c.isObjectLike)(e)?!!(e.update&&e.parse&&e.clean&&e.create&&e.parent&&e.destroy&&e.rootUpdate&&e.parentUpdate&&e.keys&&e.values&&e.toggle&&e.replace&&e.quietUpdate&&e.quietReplace&&e.add&&e.apply&&e.applyReplace&&e.setByPath&&e.setPathCollection&&e.removeByPath&&e.removePathCollection&&e.getByPath&&e.applyFunction&&e.__element&&e.__children):!1},D=(e,r)=>{if(!e)return r||{};const o=e.split("/"),t={};let n=t;const s=o.length-1;for(let i=0;i<=s;i++)n[o[i]]=i===s?r||{}:{},n=n[o[i]];return t},E=(e,r)=>{const{__element:o}=r,t=o?.state;if(!t)return;const n=(0,l.deepClone)(t,p.STATE_METHODS),s={[e.key]:n},i=(0,c.isObject)(t.__depends)?{...t.__depends,...s}:s;return Array.isArray(t)?(0,y.addProtoToArray)(t,{...Object.getPrototypeOf(t),__depends:i}):Object.setPrototypeOf(t,{...Object.getPrototypeOf(t),__depends:i}),n},K=(e,r,o={})=>{const{overwrite:t}=o;if(!t)return;const n=t==="shallow";if(t==="merge"){(0,l.deepMerge)(e,r,p.STATE_METHODS);return}(n?l.overwriteShallow:l.overwriteDeep)(e,r,p.STATE_METHODS)},_="__polyglotSeededKeys",d=e=>{if(!(0,c.isObject)(e))return new Set;let r=e[_];if(!(r instanceof Set)){r=new Set;try{Object.defineProperty(e,_,{value:r,enumerable:!1,writable:!0,configurable:!0})}catch{}}return r},T=(e,r,o)=>d(e).has(r)?!0:!(0,c.isObject)(o)||o[r]===void 0,B=(e,r)=>(d(e).add(r),r);
@@ -1,3 +1,3 @@
1
- "use strict";var w=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var j=(e,n)=>{for(var t in n)w(e,t,{get:n[t],enumerable:!0})},I=(e,n,t,c)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of N(n))!O.call(e,o)&&o!==t&&w(e,o,{get:()=>n[o],enumerable:!(c=A(n,o))||c.enumerable});return e};var R=e=>I(w({},"__esModule",{value:!0}),e);var z={};j(z,{customDecodeURIComponent:()=>q,customEncodeURIComponent:()=>T,decodeNewlines:()=>K,encodeNewlines:()=>D,findKeyPosition:()=>v,lowercaseFirstLetter:()=>_,replaceLiteralsWithObjectFields:()=>F,replaceOctalEscapeSequences:()=>V,stringIncludesAny:()=>k,trimStringFromSymbols:()=>E});module.exports=R(z);const k=(e,n)=>{for(const t of n)if(e.includes(t))return!0;return!1},E=(e,n)=>{const t=new RegExp(`[${n.join("\\")}]`,"g");return e.replace(t,"")},$={2:/{{\s*((?:\.\.\/)*)([\w\d.]+)\s*(?:\|\s*([\w\d.]+))?\s*}}/g,3:/{{{(\s*(?:\.\.\/)*)([\w\d.]+)\s*(?:\|\s*([\w\d.]+))?\s*}}}/g},m=(e,n)=>n.split(".").reduce((t,c)=>t?.[c],e);function F(e,n,t={}){const{bracketsLength:c=2}=t,o=c===3?"{{{":"{{";if(!e.includes(o))return e;const h=$[c],l=n||this.state||{},u=this;return e.replace(h,(g,d,r,a)=>{const p=r.trim();if(a){const i=u?.context,s=i?.functions?.[a]||i?.utils?.[a]||i?.methods?.[a]||i?.snippets?.[a]||u?.[a];if(s&&typeof s=="function")try{return String(s.call(u,p)??"")}catch{return""}return""}if(d){const i=(d.match(/\.\.\//g)||[]).length;let s=l;for(let f=0;f<i;f++){if(!s||!s.parent)return"";s=s.parent}if(p==="parent")return String(s.value??"");const x=m(s,p);return String(x??"")}else{const i=m(l,p);if(i!=null)return String(i);const s=u?.context?.polyglot;if(s?.translations){const x=l?.root?.lang||l?.lang||u?.context?.state?.lang||s.defaultLang||"en",f=s.translations[x];if(f){const C=m(f,p);if(C!=null&&typeof C!="object")return String(C);for(const L in f){const b=f[L];if(b&&typeof b=="object"&&!Array.isArray(b)){const S=m(b,p);if(S!=null&&typeof S!="object")return String(S)}}}const y=m(s.translations,p);if(y!=null&&typeof y!="object")return String(y)}return""}})}const _=e=>`${e.charAt(0).toLowerCase()}${e.slice(1)}`,v=(e,n)=>{const t=e.split(`
2
- `);let c=-1,o=-1,h=-1,l=-1;const u=new RegExp(`\\b${n}\\b\\s*:\\s*`);let g=0,d=!1;for(let r=0;r<t.length;r++)if(u.test(t[r])&&!d){if(d=!0,c=r+1,h=t[r].indexOf(n)+1,t[r].includes("{}")){o=c,l=t[r].indexOf("{}")+3;break}const a=t[r].slice(h+n.length);if(a.includes("{")||a.includes("["))g=1;else{o=r+1,l=t[r].length+1;break}}else if(d&&(g+=(t[r].match(/{/g)||[]).length,g+=(t[r].match(/\[/g)||[]).length,g-=(t[r].match(/}/g)||[]).length,g-=(t[r].match(/]/g)||[]).length,g===0)){o=r+1,l=t[r].lastIndexOf("}")!==-1?t[r].lastIndexOf("}")+2:t[r].length+1;break}return{startColumn:h,endColumn:l,startLineNumber:c,endLineNumber:o}},U=/\\([0-7]{1,3})/g,V=e=>e.replace(U,(n,t)=>String.fromCharCode(parseInt(t,8))),D=e=>e.replace(/\n/g,"/////n").replace(/`/g,"/////tilde").replace(/\$/g,"/////dlrsgn"),K=e=>e.replace(/\/\/\/\/\/n/g,`
1
+ "use strict";var w=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var O=(e,n)=>{for(var t in n)w(e,t,{get:n[t],enumerable:!0})},I=(e,n,t,c)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of A(n))!N.call(e,s)&&s!==t&&w(e,s,{get:()=>n[s],enumerable:!(c=j(n,s))||c.enumerable});return e};var R=e=>I(w({},"__esModule",{value:!0}),e);var z={};O(z,{customDecodeURIComponent:()=>q,customEncodeURIComponent:()=>T,decodeNewlines:()=>K,encodeNewlines:()=>D,findKeyPosition:()=>v,lowercaseFirstLetter:()=>_,replaceLiteralsWithObjectFields:()=>F,replaceOctalEscapeSequences:()=>V,stringIncludesAny:()=>k,trimStringFromSymbols:()=>E});module.exports=R(z);const k=(e,n)=>{for(const t of n)if(e.includes(t))return!0;return!1},E=(e,n)=>{const t=new RegExp(`[${n.join("\\")}]`,"g");return e.replace(t,"")},$={2:/{{\s*((?:\.\.\/)*)([\w\d.]+)\s*(?:\|\s*([\w\d.]+))?\s*}}/g,3:/{{{(\s*(?:\.\.\/)*)([\w\d.]+)\s*(?:\|\s*([\w\d.]+))?\s*}}}/g},x=(e,n)=>n.split(".").reduce((t,c)=>t?.[c],e);function F(e,n,t={}){const{bracketsLength:c=2}=t,s=c===3?"{{{":"{{";if(!e.includes(s))return e;const m=$[c],a=n||this.state||{},u=this;return e.replace(m,(g,d,r,i)=>{const p=r.trim();if(i){const l=u?.context,o=l?.functions?.[i]||l?.utils?.[i]||l?.methods?.[i]||l?.snippets?.[i]||u?.[i];if(o&&typeof o=="function")try{return String(o.call(u,p)??"")}catch{return""}return""}if(d){const l=(d.match(/\.\.\//g)||[]).length;let o=a;for(let f=0;f<l;f++){if(!o||!o.parent)return"";o=o.parent}if(p==="parent")return String(o.value??"");const h=x(o,p);return h!=null&&typeof h=="object"?"":String(h??"")}else{const l=x(a,p);if(l!=null&&typeof l!="object")return String(l);const o=u?.context?.polyglot;if(o?.translations){const h=a?.root?.lang||a?.lang||u?.context?.state?.lang||o.defaultLang||"en",f=o.translations[h];if(f){const C=x(f,p);if(C!=null&&typeof C!="object")return String(C);for(const L in f){const b=f[L];if(b&&typeof b=="object"&&!Array.isArray(b)){const S=x(b,p);if(S!=null&&typeof S!="object")return String(S)}}}const y=x(o.translations,p);if(y!=null&&typeof y!="object")return String(y)}return""}})}const _=e=>`${e.charAt(0).toLowerCase()}${e.slice(1)}`,v=(e,n)=>{const t=e.split(`
2
+ `);let c=-1,s=-1,m=-1,a=-1;const u=new RegExp(`\\b${n}\\b\\s*:\\s*`);let g=0,d=!1;for(let r=0;r<t.length;r++)if(u.test(t[r])&&!d){if(d=!0,c=r+1,m=t[r].indexOf(n)+1,t[r].includes("{}")){s=c,a=t[r].indexOf("{}")+3;break}const i=t[r].slice(m+n.length);if(i.includes("{")||i.includes("["))g=1;else{s=r+1,a=t[r].length+1;break}}else if(d&&(g+=(t[r].match(/{/g)||[]).length,g+=(t[r].match(/\[/g)||[]).length,g-=(t[r].match(/}/g)||[]).length,g-=(t[r].match(/]/g)||[]).length,g===0)){s=r+1,a=t[r].lastIndexOf("}")!==-1?t[r].lastIndexOf("}")+2:t[r].length+1;break}return{startColumn:m,endColumn:a,startLineNumber:c,endLineNumber:s}},U=/\\([0-7]{1,3})/g,V=e=>e.replace(U,(n,t)=>String.fromCharCode(parseInt(t,8))),D=e=>e.replace(/\n/g,"/////n").replace(/`/g,"/////tilde").replace(/\$/g,"/////dlrsgn"),K=e=>e.replace(/\/\/\/\/\/n/g,`
3
3
  `).replace(/\/\/\/\/\/tilde/g,"`").replace(/\/\/\/\/\/dlrsgn/g,"$"),P=/[^a-zA-Z0-9\s]/g,T=e=>e.replace(P,n=>"%"+n.charCodeAt(0).toString(16).toUpperCase()),q=e=>e.replace(/%[0-9A-Fa-f]{2}/g,n=>String.fromCharCode(parseInt(n.slice(1),16)));
package/dist/esm/cdn.js CHANGED
@@ -1,3 +1,3 @@
1
- const e={skypack:{url:"https://cdn.skypack.dev",formatUrl:(t,s)=>`${e.skypack.url}/${t}${s!=="latest"?`@${s}`:""}`},esmsh:{url:"https://esm.sh",formatUrl:(t,s)=>`${e.esmsh.url}/${t}${s!=="latest"?`@${s}`:""}`},unpkg:{url:"https://unpkg.com",formatUrl:(t,s)=>`${e.unpkg.url}/${t}${s!=="latest"?`@${s}`:""}?module`},jsdelivr:{url:"https://cdn.jsdelivr.net/npm",formatUrl:(t,s)=>`${e.jsdelivr.url}/${t}${s!=="latest"?`@${s}`:""}/+esm`},symbols:{url:"https://pkg.symbo.ls",formatUrl:(t,s)=>`${e.symbols.url}/${t}${s!=="latest"?`@${s}`:""}/+esm`}},g={"esm.sh":"esmsh",unpkg:"unpkg",skypack:"skypack",jsdelivr:"jsdelivr","pkg.symbo.ls":"symbols"},b=(t={})=>{const{packageManager:s}=t;return g[s]||null},$=t=>{if(typeof t!="string")return t;const s=t.trim().match(/^[\^~](\d.*)$/);return s?s[1]:t},k=(t,s="latest",n="esmsh")=>(e[n]||e.esmsh).formatUrl(t,$(s)),d=/^node:|^@symbo-ls\//,y=t=>typeof t=="string"&&d.test(t),f=/[<>…]/,h=t=>typeof t=="string"&&f.test(t),E=(t,s="skypack",n={})=>{const o=t.dependencies||{},c=Object.keys(o);if(!c.length)return"";const l=n.pin||{},p={};for(const r of c){if(y(r)||h(r))continue;const u=l[r]||o[r]||"latest";p[r]=k(r,u,s)}if(!Object.keys(p).length)return"";const m='<script type="importmap">',a="<\/script>",i=`{
1
+ const l=t=>t!=="latest"?`@${t}`:"",i=t=>t?`/${t}`:"",u=t=>{const s=typeof t=="string"?t.replace(/\/+$/,""):"";if(!s)return{name:"",subpath:""};const e=s.split("/"),r=s.startsWith("@")?2:1;return{name:e.slice(0,r).join("/"),subpath:e.slice(r).join("/")}},o={skypack:{url:"https://cdn.skypack.dev",formatUrl:(t,s,e)=>`${o.skypack.url}/${t}${l(s)}${i(e)}`},esmsh:{url:"https://esm.sh",formatUrl:(t,s,e)=>`${o.esmsh.url}/${t}${l(s)}${i(e)}`},unpkg:{url:"https://unpkg.com",formatUrl:(t,s,e)=>`${o.unpkg.url}/${t}${l(s)}${i(e)}?module`},jsdelivr:{url:"https://cdn.jsdelivr.net/npm",formatUrl:(t,s,e)=>`${o.jsdelivr.url}/${t}${l(s)}${i(e)}/+esm`},symbols:{url:"https://pkg.symbo.ls",formatUrl:(t,s,e)=>`${o.symbols.url}/${t}${l(s)}${i(e)}/+esm`}},h={"esm.sh":"esmsh",unpkg:"unpkg",skypack:"skypack",jsdelivr:"jsdelivr","pkg.symbo.ls":"symbols"},U=(t={})=>{const{packageManager:s}=t;return h[s]||null},$=t=>{if(typeof t!="string")return t;const s=t.trim().match(/^[\^~](\d.*)$/);return s?s[1]:t},k=(t,s="latest",e="esmsh")=>{const r=o[e]||o.esmsh,{name:c,subpath:a}=u(t);return r.formatUrl(c||t,$(s),a)},d=(t,s="latest",e="esmsh")=>{const r=o[e]||o.esmsh,c=$(s),{name:a,subpath:p}=u(t);return`${r.url}/${a||t}${l(c)}${i(p)}/`},b=/^node:|^@symbo-ls\//,x=t=>typeof t=="string"&&b.test(t),D=/[<>…]/,j=t=>typeof t=="string"&&D.test(t),E=t=>!!t&&typeof t=="object"&&!Array.isArray(t),C=(t,s="skypack",e={})=>{const r=t.dependencies;if(!E(r))return"";const c=Object.keys(r);if(!c.length)return"";const a=e.pin||{},p={};for(const n of c){if(x(n)||j(n))continue;const m=a[n]||r[n]||"latest";p[n]=k(n,m,s),n.endsWith("/")||(p[n+"/"]=d(n,m,s))}if(!Object.keys(p).length)return"";const y='<script type="importmap">',g="<\/script>",f=`{
2
2
  "imports": ${JSON.stringify(p,null,2)}
3
- }`;return`${m}${i}${a}`};export{e as CDN_PROVIDERS,g as PACKAGE_MANAGER_TO_CDN,k as getCDNUrl,b as getCdnProviderFromConfig,E as getImportMapScript,h as isMalformedDependency,y as isUnresolvableDependency,$ as stripVersionRangePrefix};
3
+ }`;return`${y}${f}${g}`};export{o as CDN_PROVIDERS,h as PACKAGE_MANAGER_TO_CDN,d as getCDNDirUrl,k as getCDNUrl,U as getCdnProviderFromConfig,C as getImportMapScript,j as isMalformedDependency,x as isUnresolvableDependency,E as isValidDependencyMap,u as splitPackageSpecifier,$ as stripVersionRangePrefix};
@@ -1,17 +1,18 @@
1
- import{window as x}from"./globals.js";import{isFunction as $,isObjectLike as w,isObject as S,isArray as O,isString as P,is as I}from"./types.js";import{unstackArrayOfObjects as M}from"./array.js";import{stringIncludesAny as R}from"./string.js";import{isDOMNode as g}from"./node.js";import{METHODS_EXL as L}from"./keys.js";const E="production",_=e=>e.charCodeAt(0)===95&&e.charCodeAt(1)===95,v=(e,t,r,s)=>{if($(e))return t?typeof e.call!="function"?e:e.call(t,t,r||t.state,s||t.context):void 0;if(e!=null&&t?.context?.plugins&&(O(e)||S(e)&&!g(e))){const n=t.context.plugins;for(const o of n)if(o.resolveHandler){const i=o.resolveHandler(e,t);if(typeof i=="function")return v(i,t,r,s)}}return e},ne=(e,t,r)=>{for(const s in t)e[s]=v(t[s],r)},re=(e,t,r=[])=>{const s=r instanceof Set;for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(_(n)||(s?r.has(n):r.includes(n))||e[n]===void 0&&(e[n]=t[n]));return e},oe=(e,t,r=L)=>A(e,t,r,null),A=(e,t,r,s)=>{if(e===t)return e;if(s){for(let o=0;o<s.length;o+=2)if(s[o]===e&&s[o+1]===t)return e}const n=r instanceof Set;for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||_(o)||o==="constructor"||o==="prototype"||(n?r.has(o):r.includes(o)))continue;const i=e[o],c=t[o];if(w(i)&&w(c)){const l=s||[];l.push(e,t),A(i,c,r,l),l.length-=2}else i===void 0&&(e[o]=c)}return e},se=(e,t=[])=>{const r=t instanceof Set,s={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(_(n)||(r?t.has(n):t.includes(n))||(s[n]=e[n]));return s},ie=(e,t={})=>{const{exclude:r=[],cleanUndefined:s=!1,cleanNull:n=!1,visited:o=new WeakMap,handleExtends:i=!1}=t;if(!w(e)||g(e))return e;if(o.has(e))return o.get(e);const c=r instanceof Set?r:r.length>3?new Set(r):null,l=p=>c?c.has(p):r.includes(p),f=O(e)?[]:{};o.set(e,f);const a=[[e,f]];for(;a.length;){const[p,h]=a.pop();for(const y in p){if(!Object.prototype.hasOwnProperty.call(p,y)||_(y)||y==="__proto__"||l(y))continue;const u=p[y];if(!(s&&u===void 0)&&!(n&&u===null)){if(g(u)){h[y]=u;continue}if(i&&y==="extends"&&O(u)){h[y]=M(u,r);continue}if($(u)){h[y]=u;continue}if(w(u))if(o.has(u))h[y]=o.get(u);else{const d=O(u)?[]:{};o.set(u,d),h[y]=d,a.push([u,d])}else h[y]=u}}}return f},T=(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 r in e){const s=e[r];if($(s))t[r]=s.toString();else if(S(s))t[r]={},T(s,t[r]);else if(O(s)){const n=t[r]=[];for(let o=0;o<s.length;o++){const i=s[o];S(i)?(n[o]={},T(i,n[o])):$(i)?n[o]=i.toString():n[o]=i}}else t[r]=s}return t},W=new Set(["&","*","-",":","%","{","}",">","<","@",".","/","!"," "]),N=(e={},t=0)=>{if(e===null||typeof e!="object")return String(e);let r=!1;for(const o in e){r=!0;break}if(!r)return"{}";const s=" ".repeat(t);let n=`{
2
- `;for(const o in e){if(!Object.prototype.hasOwnProperty.call(e,o))continue;const i=e[o];let c=!1;for(let f=0;f<o.length;f++)if(W.has(o[f])){c=!0;break}const l=c?`'${o}'`:o;if(n+=`${s} ${l}: `,O(i)){n+=`[
3
- `;for(const f of i)w(f)&&f!==null?n+=`${s} ${N(f,t+2)},
4
- `:P(f)?n+=`${s} '${f}',
5
- `:n+=`${s} ${f},
6
- `;n+=`${s} ]`}else w(i)?n+=N(i,t+1):P(i)?n+=R(i,[`
7
- `,"'"])?`\`${i}\``:`'${i}'`:n+=i;n+=`,
8
- `}return n+=`${s}}`,n},b=[/^\(\s*\{[^}]*\}\s*\)\s*=>/,/^(\([^)]*\)|[^=]*)\s*=>/,/^function[\s(]/,/^async\s+/,/^\(\s*function/,/^[a-zA-Z_$][a-zA-Z0-9_$]*\s*=>/],F=/^["[{]/,J=/^(export|import)\s/,k=e=>{if(!e)return!1;const t=e.trim().replace(/\n\s*/g," ").trim();if(t===""||t==="{}"||t==="[]"||J.test(t)||!b.some(o=>o.test(t)))return!1;const s=t.charCodeAt(0),n=t.includes("=>");return!(s===123&&!n||s===91||F.test(t)&&!n)},q=e=>(0,eval)(e),B=(e,t)=>{const r=/^(\s*(?:async\s+)?function\s*[\w$]*\s*\([^)]*\)\s*)\{/.exec(e);if(!r)return null;const s=r[0].length,n=[];let o=s,i=1,c=null;const l=e.length,f=new RegExp("^(?:const|let|var)\\s+"+t+"\\b");for(;o<l&&i>0;){const p=e[o];if(p==="/"&&e[o+1]==="/"){const h=e.indexOf(`
9
- `,o);o=h===-1?l:h;continue}if(p==="/"&&e[o+1]==="*"){const h=e.indexOf("*/",o+2);o=h===-1?l:h+2;continue}if(p==='"'||p==="'"||p==="`"){const h=p;for(o++;o<l;){if(e[o]==="\\"){o+=2;continue}if(e[o]===h){o++;break}if(h==="`"&&e[o]==="$"&&e[o+1]==="{"){o+=2;let y=1;for(;o<l&&y>0;)e[o]==="{"?y++:e[o]==="}"&&y--,o++;continue}o++}continue}if(p==="{"){i++,o++;continue}if(p==="}"){i--,o++;continue}if(i===1&&f.test(e.slice(o))){const h=o;let y=0,u=o;for(;u<l;){const d=e[u];if(d==='"'||d==="'"||d==="`"){const C=d;for(u++;u<l;){if(e[u]==="\\"){u+=2;continue}if(e[u]===C){u++;break}u++}continue}if(d==="("||d==="["||d==="{"){y++,u++;continue}if(d===")"||d==="]"||d==="}"){if(y===0)break;y--,u++;continue}if(y===0&&(d===";"||d===`
10
- `)){u++;break}u++}n.push([h,u]),o=u;continue}o++}if(!n.length)return null;let a=e;for(let p=n.length-1;p>=0;p--)a=a.slice(0,n[p][0])+a.slice(n[p][1]);return a},D=(e,t,r)=>{const s=String(e).trimStart();if(/^(export|import)\s/.test(s))return e;try{return r.window.eval(`(${e})`)}catch(n){const o=n&&n.message?n.message:String(n),i=/await is only valid in async/.test(o),c=/Identifier '([^']+)' has already been declared/.exec(o);let l=null;if(i){const f=String(e).trim();if(/^function[\s(]/.test(f))try{l=r.window.eval("(async "+f+")")}catch{}}else if(c){let f=String(e),a=c[1];for(let p=0;p<5;p++){const h=B(f,a);if(!h||h===f)break;f=h;try{l=r.window.eval("("+f+")");break}catch(y){const u=/Identifier '([^']+)' has already been declared/.exec(y&&y.message||String(y));if(!u||u[1]!==a)break}}}return l||(typeof console<"u"&&console.warn&&console.warn(`[smbls] deepDestringifyFunctions: eval failed on ${t} \u2014 value will be left as a string. Reason: `+o+`.
11
- First 200 chars of source: `+String(e).slice(0,200)),e)}},ce=(e,t={},r={window:{eval:q}})=>{if(!e||typeof e!="object")return t;const s=[[e,t]];for(;s.length;){const[n,o]=s.pop();for(const i in n){if(!Object.prototype.hasOwnProperty.call(n,i))continue;const c=n[i];if(P(c))k(c)?o[i]=D(c,`"${i}"`,r):o[i]=c;else if(O(c)){const l=o[i]=[];for(let f=0;f<c.length;f++){const a=c[f];if(P(a))l.push(k(a)?D(a,`array index ${f} (prop "${i}")`,r):a);else if(S(a)){const p={};l.push(p),s.push([a,p])}else l.push(a)}}else if(S(c)){const l=o[i]&&typeof o[i]=="object"&&!O(o[i])?o[i]:o[i]={};s.push([c,l])}else o[i]=c}}return t},G="Set",H="Map",m=e=>!e||typeof e!="object"?e:e.__type===G&&Array.isArray(e.values)?new Set(e.values):e.__type===H&&Array.isArray(e.entries)?new Map(e.entries):e,fe=e=>{if(!e||typeof e!="object")return e;const t={},r=[];for(const i of Object.keys(e)){const c=e[i];P(c)&&k(c)?r.push([i,c]):t[i]=m(c)}if(r.length===0)return t;const s=i=>/^[A-Za-z_$][\w$]*$/.test(i),n=r.filter(([i])=>s(i)),o=Object.keys(t).filter(s).map(i=>`var ${i} = __gs__[${JSON.stringify(i)}];`).join(`
12
- `);try{const i=n.map(([f,a])=>`var ${f} = (${a});`).join(`
13
- `),c="{ "+n.map(([f])=>`${JSON.stringify(f)}: ${f}`).join(", ")+" }",l=x.eval(`(function(__gs__) { ${o}
14
- ${i}
15
- return ${c}; })`)(t);Object.assign(t,l)}catch{for(const[c,l]of n)try{const f=Object.keys(t).filter(s).map(a=>`var ${a} = __gs__[${JSON.stringify(a)}];`).join(`
16
- `);t[c]=x.eval(`(function(__gs__) { ${f}
17
- return (${l}); })`)(t)}catch{try{t[c]=x.eval(`(${l})`)}catch{t[c]=l}}}for(const[i,c]of r)if(!s(i))try{t[i]=x.eval(`(${c})`)}catch{t[i]=c}return t},le=(e,t={verbose:!0})=>{try{return e?x.eval("("+e+")"):{}}catch(r){t.verbose&&console.warn(r)}},ue=(e,...t)=>Object.prototype.hasOwnProperty.call(e,...t),z=e=>{for(const t in e)return!1;return!0},ae=e=>S(e)&&z(e),pe=()=>Object.create(null),ye=(e,t,r={})=>{const s=r.exclude||[],n=r.preventUnderscore;for(const o in t)s.includes(o)||!n&&_(o)||o==="constructor"||o==="prototype"||t[o]!==void 0&&(e[o]=t[o]);return e},he=(e,t,r=[])=>{const s=r instanceof Set;for(const n in t)_(n)||n==="constructor"||n==="prototype"||(s?r.has(n):r.includes(n))||(e[n]=t[n]);return e},U=(e,t,r={},s=new WeakMap)=>{if(!w(e)||!w(t)||g(e)||g(t))return t;if(s.has(e))return s.get(e);s.set(e,e);const n=r.exclude,o=n?n instanceof Set?n:new Set(n):null,i=!r.preventForce;for(const c in t){if(!Object.prototype.hasOwnProperty.call(t,c)||o&&o.has(c)||i&&_(c)||c==="constructor"||c==="prototype")continue;const l=e[c],f=t[c];g(f)?e[c]=f:w(l)&&w(f)?e[c]=U(l,f,r,s):f!==void 0&&(e[c]=f)}return e},V=(e,t,r=new Set)=>{if(typeof e!="object"||typeof t!="object"||e===null||t===null)return e===t;if(r.has(e)||r.has(t))return!0;r.add(e),r.add(t);const s=Object.keys(e),n=Object.keys(t);if(s.length!==n.length)return!1;for(let o=0;o<s.length;o++){const i=s[o];if(!Object.prototype.hasOwnProperty.call(t,i)||!V(e[i],t[i],r))return!1}return!0},Z=new Set(["node","__ref"]),de=(e,t,r=Z)=>{if(e===t)return!0;if(!w(e)||!w(t)||g(e)||g(t))return e===t;const s=r instanceof Set?r:new Set(r),n=new WeakSet;function o(i,c){if(n.has(c))return!0;n.add(c);for(const l in c){if(!Object.prototype.hasOwnProperty.call(c,l)||s.has(l))continue;if(!Object.prototype.hasOwnProperty.call(i,l))return!1;const f=c[l],a=i[l];if(g(f)||g(a)){if(f!==a)return!1}else if(w(f)&&w(a)){if(!o(a,f))return!1}else if(f!==a)return!1}return!0}return o(e,t)},we=(e,t)=>{if(t==null)return e;if(I(t)("string","number"))delete e[t];else if(O(t))for(let r=0;r<t.length;r++)delete e[t[r]];else throw new Error("Invalid input: props must be a string or an array of strings");return e},K=e=>{if(e===null||typeof e!="object")return e;const t=Object.create(null);for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=K(e[r]));return t},ge=(e,t)=>{if(e.length===0)return t;const r={};let s=r;for(let n=0;n<e.length;n++)n===e.length-1&&t?s[e[n]]=t:(s[e[n]]={},s=s[e[n]]);return r},Oe=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let r=e;for(let n=0;n<t.length-1;n++){if(r[t[n]]===void 0)return;r=r[t[n]]}const s=t[t.length-1];r&&Object.prototype.hasOwnProperty.call(r,s)&&delete r[s]},_e=(e,t,r)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let s=e;for(let n=0;n<t.length-1;n++)(!s[t[n]]||typeof s[t[n]]!="object")&&(s[t[n]]={}),s=s[t[n]];return s[t[t.length-1]]=r,e},Se=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let r=e;for(let s=0;s<t.length;s++){if(r==null)return;r=r[t[s]]}return r},xe=e=>{let r=[],s=0;for(let n=0;n<e.length;n++)if(r.length<2)r.push(e[n]);else if(e[n]===r[n%2]?s++:(r=[e[n-1],e[n]],s=1),s>=20)return(E==="test"||E==="development")&&console.warn("Warning: Potential infinite loop detected due to repeated sequence:",r),!0},Pe=e=>{const t=new WeakSet;function r(s){if(s&&typeof s=="object"){if(t.has(s))return!0;t.add(s);for(const n in s)if(Object.prototype.hasOwnProperty.call(s,n)&&r(s[n]))return console.log(s,"cycle at "+n),!0}return!1}return r(e)},$e=(e,t)=>{const r=t instanceof Set?t:new Set(t),s={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&!r.has(n)&&(s[n]=e[n]);return s};export{se as clone,ge as createNestedObject,K as createObjectWithoutPrototype,ie as deepClone,de as deepContains,ce as deepDestringifyFunctions,oe as deepMerge,T as deepStringifyFunctions,fe as destringifyGlobalScope,xe as detectInfiniteLoop,$e as excludeKeysFromObject,v as exec,Se as getInObjectByPath,k as hasFunction,ue as hasOwnProperty,Pe as isCyclic,z as isEmpty,ae as isEmptyObject,V as isEqualDeep,pe as makeObjectWithoutPrototype,ne as map,re as merge,N as objectToString,ye as overwrite,U as overwriteDeep,he as overwriteShallow,we as removeFromObject,Oe as removeNestedKeyByPath,_e as setInObjectByPath,le as stringToObject};
1
+ import{window as x}from"./globals.js";import{isFunction as P,isObjectLike as g,isObject as k,isArray as _,isString as O,is as B}from"./types.js";import{unstackArrayOfObjects as J}from"./array.js";import{stringIncludesAny as Y}from"./string.js";import{isDOMNode as w}from"./node.js";import{METHODS_EXL as q}from"./keys.js";const A="production",S=e=>e.charCodeAt(0)===95&&e.charCodeAt(1)===95,T=(e,t,o,i)=>{if(P(e))return t?typeof e.call!="function"?e:e.call(t,t,o||t.state,i||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 s=n.resolveHandler(e,t);if(typeof s=="function")return T(s,t,o,i)}}return e},ce=(e,t,o)=>{for(const i in t)e[i]=T(t[i],o)},fe=(e,t,o=[])=>{const i=o instanceof Set;for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(S(r)||(i?o.has(r):o.includes(r))||e[r]===void 0&&(e[r]=t[r]));return e},ue=(e,t,o=q)=>N(e,t,o,null),N=(e,t,o,i)=>{if(e===t)return e;if(i){for(let n=0;n<i.length;n+=2)if(i[n]===e&&i[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 s=e[n],f=t[n];if(g(s)&&g(f)){const u=i||[];u.push(e,t),N(s,f,o,u),u.length-=2}else s===void 0&&(e[n]=f)}return e},le=(e,t=[])=>{const o=t instanceof Set,i={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(S(r)||(o?t.has(r):t.includes(r))||(i[r]=e[r]));return i},ae=(e,t={})=>{const{exclude:o=[],cleanUndefined:i=!1,cleanNull:r=!1,visited:n=new WeakMap,handleExtends:s=!1}=t;if(!g(e)||w(e))return e;if(n.has(e))return n.get(e);const f=o instanceof Set?o:o.length>3?new Set(o):null,u=p=>f?f.has(p):o.includes(p),c=_(e)?[]:{};n.set(e,c);const l=[[e,c]];for(;l.length;){const[p,h]=l.pop();for(const y in p){if(!Object.prototype.hasOwnProperty.call(p,y)||S(y)||y==="__proto__"||u(y))continue;const a=p[y];if(!(i&&a===void 0)&&!(r&&a===null)){if(w(a)){h[y]=a;continue}if(s&&y==="extends"&&_(a)){h[y]=J(a,o);continue}if(P(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 c},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 i=e[o];if(P(i))t[o]=i.toString();else if(k(i))t[o]={},R(i,t[o]);else if(_(i)){const r=t[o]=[];for(let n=0;n<i.length;n++){const s=i[n];k(s)?(r[n]={},R(s,r[n])):P(s)?r[n]=s.toString():r[n]=s}}else t[o]=i}return t},z=new Set(["&","*","-",":","%","{","}",">","<","@",".","/","!"," "]),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 i=" ".repeat(t);let r=`{
2
+ `;for(const n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;const s=e[n];let f=!1;for(let c=0;c<n.length;c++)if(z.has(n[c])){f=!0;break}const u=f?`'${n}'`:n;if(r+=`${i} ${u}: `,s instanceof RegExp)r+=String(s);else if(_(s)){r+=`[
3
+ `;for(const c of s)c instanceof RegExp?r+=`${i} ${String(c)},
4
+ `:g(c)&&c!==null?r+=`${i} ${M(c,t+2)},
5
+ `:O(c)?r+=`${i} '${c}',
6
+ `:r+=`${i} ${c},
7
+ `;r+=`${i} ]`}else g(s)?r+=M(s,t+1):O(s)?r+=Y(s,[`
8
+ `,"'"])?`\`${s}\``:`'${s}'`:r+=s;r+=`,
9
+ `}return r+=`${i}}`,r},H=[/^\(\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]*\}$/],K=/^["[{]/,U=/^(export|import)\s/,$=e=>{if(!e)return!1;const t=e.trim().replace(/\n\s*/g," ").trim();if(t===""||t==="{}"||t==="[]"||U.test(t)||!H.some(n=>n.test(t)))return!1;const i=t.charCodeAt(0),r=t.includes("=>");return!(i===123&&!r||i===91||K.test(t)&&!r)},Z=e=>(0,eval)(e),V=(e,t)=>{const o=/^(\s*(?:async\s+)?function\s*[\w$]*\s*\([^)]*\)\s*)\{/.exec(e);if(!o)return null;const i=o[0].length,r=[];let n=i,s=1,f=null;const u=e.length,c=new RegExp("^(?:const|let|var)\\s+"+t+"\\b");for(;n<u&&s>0;){const p=e[n];if(p==="/"&&e[n+1]==="/"){const h=e.indexOf(`
10
+ `,n);n=h===-1?u:h;continue}if(p==="/"&&e[n+1]==="*"){const h=e.indexOf("*/",n+2);n=h===-1?u:h+2;continue}if(p==='"'||p==="'"||p==="`"){const h=p;for(n++;n<u;){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<u&&y>0;)e[n]==="{"?y++:e[n]==="}"&&y--,n++;continue}n++}continue}if(p==="{"){s++,n++;continue}if(p==="}"){s--,n++;continue}if(s===1&&c.test(e.slice(n))){const h=n;let y=0,a=n;for(;a<u;){const d=e[a];if(d==='"'||d==="'"||d==="`"){const m=d;for(a++;a<u;){if(e[a]==="\\"){a+=2;continue}if(e[a]===m){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},D=(e,t,o)=>{const i=String(e).trimStart();if(/^(export|import)\s/.test(i))return e;try{return o.window.eval(`(${e})`)}catch(r){const n=r&&r.message?r.message:String(r),s=/await is only valid in async/.test(n),f=/Identifier '([^']+)' has already been declared/.exec(n);let u=null;if(s){const c=String(e).trim();if(/^function[\s(]/.test(c))try{u=o.window.eval("(async "+c+")")}catch{}}else if(f){let c=String(e),l=f[1];for(let p=0;p<5;p++){const h=V(c,l);if(!h||h===c)break;c=h;try{u=o.window.eval("("+c+")");break}catch(y){const a=/Identifier '([^']+)' has already been declared/.exec(y&&y.message||String(y));if(!a||a[1]!==l)break}}}if(!u&&/Unexpected (token '\{'|identifier)/.test(n))try{const c=o.window.eval("({"+e+"})");if(c&&typeof c=="object"){const l=Object.keys(c);l.length===1&&typeof c[l[0]]=="function"&&(u=c[l[0]])}}catch{}return u||(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)}},pe=(e,t={},o={window:{eval:Z}})=>{if(!e||typeof e!="object")return t;const i=[[e,t]];for(;i.length;){const[r,n]=i.pop();for(const s in r){if(!Object.prototype.hasOwnProperty.call(r,s))continue;const f=r[s];if(O(f))$(f)?n[s]=D(f,`"${s}"`,o):n[s]=f;else if(_(f)){const u=n[s]=[];for(let c=0;c<f.length;c++){const l=f[c];if(O(l))u.push($(l)?D(l,`array index ${c} (prop "${s}")`,o):l);else if(k(l)){const p=F(l);if(p)u.push(p);else{const h={};u.push(h),i.push([l,h])}}else u.push(l)}}else if(k(f)){const u=F(f);if(u){n[s]=u;continue}const c=n[s]&&typeof n[s]=="object"&&!_(n[s])?n[s]:n[s]={};i.push([f,c])}else n[s]=f}}return t},W="Set",C="Map",I="RegExp",b="WeakMap",G="WeakSet",L=e=>{const t=Object.keys(e);return t.length===1&&t[0]==="__type"},E=(e,t)=>{if(!e||typeof e!="object")return e;const o=n=>E(n,t||(t=new WeakMap));if(e.__type===W&&_(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===b&&L(e))return new WeakMap;if(e.__type===G&&L(e))return new WeakSet;if(e.__type===I&&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 i=!1;if(_(e)){const n=new Array(e.length);t.set(e,n);for(let s=0;s<e.length;s++)n[s]=E(e[s],t),n[s]!==e[s]&&(i=!0);return i||t.set(e,e),i?n:e}const r={};t.set(e,r);for(const n of Object.keys(e))r[n]=E(e[n],t),r[n]!==e[n]&&(i=!0);return i||t.set(e,e),i?r:e},F=e=>{if(!e||typeof e!="object")return null;const t=e.__type;if(t!==I&&t!==W&&t!==C&&t!==b&&t!==G)return null;const o=E(e);return o===e?null:o},ye=e=>{if(!e||typeof e!="object")return e;const t={},o=[];for(const s of Object.keys(e)){const f=e[s];O(f)&&$(f)?o.push([s,f]):t[s]=E(f)}if(o.length===0)return t;const i=s=>/^[A-Za-z_$][\w$]*$/.test(s),r=o.filter(([s])=>i(s)),n=Object.keys(t).filter(i).map(s=>`var ${s} = __gs__[${JSON.stringify(s)}];`).join(`
13
+ `);try{const s=r.map(([c,l])=>`var ${c} = (${l});`).join(`
14
+ `),f="{ "+r.map(([c])=>`${JSON.stringify(c)}: ${c}`).join(", ")+" }",u=x.eval(`(function(__gs__) { ${n}
15
+ ${s}
16
+ return ${f}; })`)(t);Object.assign(t,u)}catch{for(const[f,u]of r)try{const c=Object.keys(t).filter(i).map(l=>`var ${l} = __gs__[${JSON.stringify(l)}];`).join(`
17
+ `);t[f]=x.eval(`(function(__gs__) { ${c}
18
+ return (${u}); })`)(t)}catch{try{t[f]=x.eval(`(${u})`)}catch{t[f]=u}}}for(const[s,f]of o)if(!i(s))try{t[s]=x.eval(`(${f})`)}catch{t[s]=f}return t},he=(e,t={verbose:!0})=>{try{return e?x.eval("("+e+")"):{}}catch(o){t.verbose&&console.warn(o)}},de=(e,...t)=>Object.prototype.hasOwnProperty.call(e,...t),X=e=>{for(const t in e)return!1;return!0},ge=e=>k(e)&&X(e),_e=()=>Object.create(null),we=(e,t,o={})=>{const i=o.exclude||[],r=o.preventUnderscore;for(const n in t)i.includes(n)||!r&&S(n)||n==="constructor"||n==="prototype"||t[n]!==void 0&&(e[n]=t[n]);return e},Oe=(e,t,o=[])=>{const i=o instanceof Set;for(const r in t)S(r)||r==="constructor"||r==="prototype"||(i?o.has(r):o.includes(r))||(e[r]=t[r]);return e},v=(e,t,o={},i=new WeakMap)=>{if(!g(e)||!g(t)||w(e)||w(t))return t;if(i.has(e))return i.get(e);i.set(e,e);const r=o.exclude,n=r?r instanceof Set?r:new Set(r):null,s=!o.preventForce;for(const f in t){if(!Object.prototype.hasOwnProperty.call(t,f)||n&&n.has(f)||s&&S(f)||f==="constructor"||f==="prototype")continue;const u=e[f],c=t[f];w(c)?e[f]=c:g(u)&&g(c)?e[f]=v(u,c,o,i):c!==void 0&&(e[f]=c)}return e},Q=(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 i=Object.keys(e),r=Object.keys(t);if(i.length!==r.length)return!1;for(let n=0;n<i.length;n++){const s=i[n];if(!Object.prototype.hasOwnProperty.call(t,s)||!Q(e[s],t[s],o))return!1}return!0},j=new Set(["node","__ref"]),Se=(e,t,o=j)=>{if(e===t)return!0;if(!g(e)||!g(t)||w(e)||w(t))return e===t;const i=o instanceof Set?o:new Set(o),r=new WeakSet;function n(s,f){if(r.has(f))return!0;r.add(f);for(const u in f){if(!Object.prototype.hasOwnProperty.call(f,u)||i.has(u))continue;if(!Object.prototype.hasOwnProperty.call(s,u))return!1;const c=f[u],l=s[u];if(w(c)||w(l)){if(c!==l)return!1}else if(g(c)&&g(l)){if(!n(l,c))return!1}else if(c!==l)return!1}return!0}return n(e,t)},ke=(e,t)=>{if(t==null)return e;if(B(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},ee=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]=ee(e[o]));return t},xe=(e,t)=>{if(e.length===0)return t;const o={};let i=o;for(let r=0;r<e.length;r++)r===e.length-1&&t?i[e[r]]=t:(i[e[r]]={},i=i[e[r]]);return o},Ee=(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 i=t[t.length-1];o&&Object.prototype.hasOwnProperty.call(o,i)&&delete o[i]},Pe=(e,t,o)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let i=e;for(let r=0;r<t.length-1;r++)(!i[t[r]]||typeof i[t[r]]!="object")&&(i[t[r]]={}),i=i[t[r]];return i[t[t.length-1]]=o,e},$e=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let o=e;for(let i=0;i<t.length;i++){if(o==null)return;o=o[t[i]]}return o},Ae=e=>{let o=[],i=0;for(let r=0;r<e.length;r++)if(o.length<2)o.push(e[r]);else if(e[r]===o[r%2]?i++:(o=[e[r-1],e[r]],i=1),i>=20)return(A==="test"||A==="development")&&console.warn("Warning: Potential infinite loop detected due to repeated sequence:",o),!0},Te=e=>{const t=new WeakSet;function o(i){if(i&&typeof i=="object"){if(t.has(i))return!0;t.add(i);for(const r in i)if(Object.prototype.hasOwnProperty.call(i,r)&&o(i[r]))return console.log(i,"cycle at "+r),!0}return!1}return o(e)},Ne=(e,t)=>{const o=t instanceof Set?t:new Set(t),i={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&!o.has(r)&&(i[r]=e[r]);return i};export{le as clone,xe as createNestedObject,ee as createObjectWithoutPrototype,ae as deepClone,Se as deepContains,pe as deepDestringifyFunctions,ue as deepMerge,R as deepStringifyFunctions,ye as destringifyGlobalScope,Ae as detectInfiniteLoop,Ne as excludeKeysFromObject,T as exec,$e as getInObjectByPath,$ as hasFunction,de as hasOwnProperty,Te as isCyclic,X as isEmpty,ge as isEmptyObject,Q as isEqualDeep,_e as makeObjectWithoutPrototype,ce as map,fe as merge,M as objectToString,we as overwrite,v as overwriteDeep,Oe as overwriteShallow,ke as removeFromObject,Ee as removeNestedKeyByPath,Pe as setInObjectByPath,he as stringToObject};
@@ -1 +1 @@
1
- import{isObject as a,isString as p}from"./types.js";const y="system",I="https://smbls-kv.nika-980.workers.dev",j="https://api.symbols.app";function f(n){const t=String(n||"").trim();if(!t)return{owner:y,key:"",full:""};let e=null,r=t;if(t.includes("/")){const o=t.indexOf("/");e=t.slice(0,o),r=t.slice(o+1)}r=r.replace(/\.symbo\.ls$/iu,""),e||(e=y);const s=r?`${e}/${r}`:"";return{owner:e,key:r,full:s}}const h=(n,t,e,r)=>{for(const s in t){const o=r?`${r}/${s}`:s;e&&e.has(o)||(s in n?a(n[s])&&a(t[s])&&h(n[s],t[s],e,o):n[s]=t[s])}},m=(n,t,e)=>{if(!a(n)||!t.size)return n;const r=`${e}/`;let s=!1;for(const i of t)if(i.startsWith(r)){s=!0;break}if(!s)return n;const o={};for(const i in n){if(!Object.prototype.hasOwnProperty.call(n,i))continue;const l=`${e}/${i}`;t.has(l)||(o[i]=m(n[i],t,l))}return o},R=new Set,U=n=>n.replace(/\.js$/iu,""),b=n=>{const t=new Set;if(!Array.isArray(n))return t;for(const e of n){if(!p(e))continue;const r=e.split("/").map(s=>U(s.trim())).filter(Boolean).join("/");r&&t.add(r)}return t},B=(n,t={})=>({library:n,ignoreList:Array.isArray(t.ignoreList)?t.ignoreList:[]}),w=n=>a(n)&&Array.isArray(n.ignoreList)&&("library"in n||"key"in n||"name"in n),S=n=>n.library!==void 0?n.library:n.key??n.name,E=(n,t,e)=>{const r=b(t.sharedLibIgnore);t.sharePages===!1&&r.add("pages");const s=r.size?new Set([...e,...r]):e;for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&!(o==="sharePages"||o==="sharedLibIgnore")&&!s.has(o))if(a(t[o])&&a(n[o]))if(o==="designSystem")h(n[o],t[o],s,o);else for(const i in t[o])s.has(`${o}/${i}`)||i in n[o]||(n[o][i]=t[o][i]);else o in n||(n[o]=m(t[o],s,o))},x=(n,t)=>{if(!(!t||!t.length))for(let e=0;e<t.length;e++){let r=t[e],s=R;w(r)&&(s=b(r.ignoreList),r=r.library),a(r)&&E(n,r,s)}};async function O(n,t={}){if((t.provider||"kv")==="api")return $(n,t);const r=await _(n,t);return r||$(n,t)}async function _(n,t={}){const e=t.kvBaseUrl||I,r=t.env||"production",s=`${e}/kv/${encodeURIComponent(n)}?env=${r}`;try{const o=await fetch(s,{method:"GET"});return o.ok&&(await o.json())?.value||null}catch{return null}}async function $(n,t={}){const e=t.apiBaseUrl||j,{key:r}=f(n);try{const s=`${e}/core/projects/libraries/available?search=${encodeURIComponent(r)}&limit=10`,o=await fetch(s,{method:"GET"});if(!o.ok)return null;const i=await o.json(),c=(i?.items||i?.data||(Array.isArray(i)?i:[])).find(A=>{const{key:v}=f(A?.key);return v.toLowerCase()===r.toLowerCase()});if(!c?.id&&!c?._id)return null;const k=c.id||c._id,L=`${e}/core/projects/${encodeURIComponent(k)}/data?branch=main`,u=await fetch(L,{method:"GET"});if(!u.ok)return null;const d=await u.json();return d?.data||d||null}catch{return null}}async function g(n,t={}){if(a(n))return n;if(p(n)){const{full:e}=f(n);if(!e)return null;try{const r=await O(e,t);return r||console.warn(`[smbls] Shared library "${e}" not found`),r}catch(r){return console.warn(`[smbls] Failed to fetch shared library "${e}":`,r.message),null}}return null}async function C(n,t={}){return!n||!n.length?[]:(await Promise.all(n.map(async r=>{if(w(r)){const s=await g(S(r),t);return s?{library:s,ignoreList:r.ignoreList}:null}return g(r,t)}))).filter(Boolean)}export{h as deepDefaults,O as fetchLibraryData,w as isWrappedLibrary,x as mergeSharedLibraries,b as normalizeIgnoreList,f as normalizeLibraryKey,C as resolveSharedLibraries,B as sharedLibrary};
1
+ import{isObject as a,isString as y}from"./types.js";const d="system",I="https://smbls-kv.nika-980.workers.dev",j="https://api.symbols.app";function f(n){const t=String(n||"").trim();if(!t)return{owner:d,key:"",full:""};let o=null,e=t;if(t.includes("/")){const r=t.indexOf("/");o=t.slice(0,r),e=t.slice(r+1)}e=e.replace(/\.symbo\.ls$/iu,""),o||(o=d);const s=e?`${o}/${e}`:"";return{owner:o,key:e,full:s}}const h=(n,t,o,e)=>{for(const s in t){const r=e?`${e}/${s}`:s;o&&o.has(r)||(s in n?a(n[s])&&a(t[s])&&h(n[s],t[s],o,r):n[s]=t[s])}},m=(n,t,o)=>{if(!a(n)||!t.size)return n;const e=`${o}/`;let s=!1;for(const i of t)if(i.startsWith(e)){s=!0;break}if(!s)return n;const r={};for(const i in n){if(!Object.prototype.hasOwnProperty.call(n,i))continue;const l=`${o}/${i}`;t.has(l)||(r[i]=m(n[i],t,l))}return r},R=new Set,U=new Set(["components","pages","functions","snippets","methods"]),b=(n,t)=>t===""&&U.has(n),E=n=>n.replace(/\.js$/iu,""),w=n=>{const t=new Set;if(!Array.isArray(n))return t;for(const o of n){if(!y(o))continue;const e=o.split("/").map(s=>E(s.trim())).filter(Boolean).join("/");e&&t.add(e)}return t},T=(n,t={})=>({library:n,ignoreList:Array.isArray(t.ignoreList)?t.ignoreList:[]}),g=n=>a(n)&&Array.isArray(n.ignoreList)&&("library"in n||"key"in n||"name"in n),O=n=>n.library!==void 0?n.library:n.key??n.name,_=(n,t,o)=>{const e=w(t.sharedLibIgnore);t.sharePages===!1&&e.add("pages");const s=e.size?new Set([...o,...e]):o;for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&!(r==="sharePages"||r==="sharedLibIgnore")&&!s.has(r))if(a(t[r])&&a(n[r]))if(r==="designSystem")h(n[r],t[r],s,r);else for(const i in t[r])s.has(`${r}/${i}`)||(i in n[r]?b(r,n[r][i])&&!b(r,t[r][i])&&(n[r][i]=t[r][i]):n[r][i]=t[r][i]);else r in n||(n[r]=m(t[r],s,r))},G=(n,t)=>{if(!(!t||!t.length))for(let o=0;o<t.length;o++){let e=t[o],s=R;g(e)&&(s=w(e.ignoreList),e=e.library),a(e)&&_(n,e,s)}};async function B(n,t={}){if((t.provider||"kv")==="api")return $(n,t);const e=await P(n,t);return e||$(n,t)}async function P(n,t={}){const o=t.kvBaseUrl||I,e=t.env||"production",s=`${o}/kv/${encodeURIComponent(n)}?env=${e}`;try{const r=await fetch(s,{method:"GET"});return r.ok&&(await r.json())?.value||null}catch{return null}}async function $(n,t={}){const o=t.apiBaseUrl||j,{key:e}=f(n);try{const s=`${o}/core/projects/libraries/available?search=${encodeURIComponent(e)}&limit=10`,r=await fetch(s,{method:"GET"});if(!r.ok)return null;const i=await r.json(),c=(i?.items||i?.data||(Array.isArray(i)?i:[])).find(S=>{const{key:v}=f(S?.key);return v.toLowerCase()===e.toLowerCase()});if(!c?.id&&!c?._id)return null;const L=c.id||c._id,A=`${o}/core/projects/${encodeURIComponent(L)}/data?branch=main`,u=await fetch(A,{method:"GET"});if(!u.ok)return null;const p=await u.json();return p?.data||p||null}catch{return null}}async function k(n,t={}){if(a(n))return n;if(y(n)){const{full:o}=f(n);if(!o)return null;try{const e=await B(o,t);return e||console.warn(`[smbls] Shared library "${o}" not found`),e}catch(e){return console.warn(`[smbls] Failed to fetch shared library "${o}":`,e.message),null}}return null}async function z(n,t={}){return!n||!n.length?[]:(await Promise.all(n.map(async e=>{if(g(e)){const s=await k(O(e),t);return s?{library:s,ignoreList:e.ignoreList}:null}return k(e,t)}))).filter(Boolean)}export{h as deepDefaults,B as fetchLibraryData,g as isWrappedLibrary,G as mergeSharedLibraries,w as normalizeIgnoreList,f as normalizeLibraryKey,z as resolveSharedLibraries,T as sharedLibrary};
package/dist/esm/state.js CHANGED
@@ -1 +1 @@
1
- import{addProtoToArray as a}from"./array.js";import{STATE_METHODS as p}from"./keys.js";import{deepClone as u,deepMerge as _,overwriteDeep as d,overwriteShallow as h}from"./object.js";import{is as f,isObject as g,isObjectLike as y,isString as m}from"./types.js";const k=e=>{const{state:t,props:o,__ref:r}=e,n=o?.state||t;return f(n)("string","number")?(r.__state=n,{value:n}):n===!0?(r.__state=e.key,{}):n?(r.__hasRootState=!0,n):!1},P=(e,t)=>{if(!e.includes("~/"))return;if(e.split("~/").length>1)return t.root},S=(e,t)=>{if(!e.includes("../"))return;const r=e.split("../").length-1;for(let n=0;n<r;n++){if(!t.parent)return null;t=t.parent}return t},b=(e,t,o={})=>{const r=m(e)?e.split("/"):[e],n=r.length-1;for(let c=0;c<n;c++){const i=r[c],s=r[c+1];if(i==="__proto__"||s==="__proto__")return;let l=t[i];l||(l=t[i]={}),l[s]||(l[s]={}),e=s,t=l}return o.returnParent?t:t[e]},w=(e,t,o={})=>{let n=e.__ref.__state;if(!x(e))return;const c=P(n,t.state);let i=t.state;if(c)i=c,n=n.replaceAll("~/","");else{const s=S(n,t.state);s&&(i=s,n=n.replaceAll("../",""))}if(i)return b(n,i,o)},A=(e,t)=>{const o=e.__ref,r=w(e,t);if(r===void 0)return e.state;if(f(r)("object","array"))return u(r);if(f(r)("string","number","boolean"))return o.__stateType=typeof r,{value:r};console.warn(o.__state,"is not present. Replacing with",{})},x=e=>{const{__ref:t}=e,o=t?.__state;return!!(o&&f(o)("number","string","boolean"))},T=function(e){return y(e)?!!(e.update&&e.parse&&e.clean&&e.create&&e.parent&&e.destroy&&e.rootUpdate&&e.parentUpdate&&e.keys&&e.values&&e.toggle&&e.replace&&e.quietUpdate&&e.quietReplace&&e.add&&e.apply&&e.applyReplace&&e.setByPath&&e.setPathCollection&&e.removeByPath&&e.removePathCollection&&e.getByPath&&e.applyFunction&&e.__element&&e.__children):!1},B=(e,t)=>{if(!e)return t||{};const o=e.split("/"),r={};let n=r;const c=o.length-1;for(let i=0;i<=c;i++)n[o[i]]=i===c?t||{}:{},n=n[o[i]];return r},C=(e,t)=>{const{__element:o}=t,r=o?.state;if(!r)return;const n=u(r,p),c={[e.key]:n},i=g(r.__depends)?{...r.__depends,...c}:c;return Array.isArray(r)?a(r,{...Object.getPrototypeOf(r),__depends:i}):Object.setPrototypeOf(r,{...Object.getPrototypeOf(r),__depends:i}),n},R=(e,t,o={})=>{const{overwrite:r}=o;if(!r)return;const n=r==="shallow";if(r==="merge"){_(e,t,p);return}(n?h:d)(e,t,p)};export{C as applyDependentState,k as checkForStateTypes,x as checkIfInherits,A as createInheritedState,B as createNestedObjectByKeyPath,w as findInheritedState,b as getChildStateInKey,S as getParentStateInKey,P as getRootStateInKey,T as isState,R as overwriteState};
1
+ import{addProtoToArray as y}from"./array.js";import{STATE_METHODS as u}from"./keys.js";import{deepClone as a,deepMerge as g,overwriteDeep as h,overwriteShallow as S}from"./object.js";import{is as f,isObject as p,isObjectLike as b,isString as P}from"./types.js";const D=e=>{const{state:r,props:o,__ref:t}=e,n=o?.state||r;return f(n)("string","number")?(t.__state=n,{value:n}):n===!0?(t.__state=e.key,{}):n?(t.__hasRootState=!0,n):!1},m=(e,r)=>{if(!e.includes("~/"))return;if(e.split("~/").length>1)return r.root},w=(e,r)=>{if(!e.includes("../"))return;const t=e.split("../").length-1;for(let n=0;n<t;n++){if(!r.parent)return null;r=r.parent}return r},x=(e,r,o={})=>{const t=P(e)?e.split("/"):[e],n=t.length-1;for(let s=0;s<n;s++){const i=t[s],c=t[s+1];if(i==="__proto__"||c==="__proto__")return;let l=r[i];l||(l=r[i]={}),l[c]||(l[c]={}),e=c,r=l}return o.returnParent?r:r[e]},v=(e,r,o={})=>{let n=e.__ref.__state;if(!O(e))return;const s=m(n,r.state);let i=r.state;if(s)i=s,n=n.replaceAll("~/","");else{const c=w(n,r.state);c&&(i=c,n=n.replaceAll("../",""))}if(i)return x(n,i,o)},E=(e,r)=>{const o=e.__ref,t=v(e,r);if(t===void 0)return e.state;if(f(t)("object","array"))return a(t);if(f(t)("string","number","boolean"))return o.__stateType=typeof t,{value:t};console.warn(o.__state,"is not present. Replacing with",{})},O=e=>{const{__ref:r}=e,o=r?.__state;return!!(o&&f(o)("number","string","boolean"))},K=function(e){return b(e)?!!(e.update&&e.parse&&e.clean&&e.create&&e.parent&&e.destroy&&e.rootUpdate&&e.parentUpdate&&e.keys&&e.values&&e.toggle&&e.replace&&e.quietUpdate&&e.quietReplace&&e.add&&e.apply&&e.applyReplace&&e.setByPath&&e.setPathCollection&&e.removeByPath&&e.removePathCollection&&e.getByPath&&e.applyFunction&&e.__element&&e.__children):!1},T=(e,r)=>{if(!e)return r||{};const o=e.split("/"),t={};let n=t;const s=o.length-1;for(let i=0;i<=s;i++)n[o[i]]=i===s?r||{}:{},n=n[o[i]];return t},B=(e,r)=>{const{__element:o}=r,t=o?.state;if(!t)return;const n=a(t,u),s={[e.key]:n},i=p(t.__depends)?{...t.__depends,...s}:s;return Array.isArray(t)?y(t,{...Object.getPrototypeOf(t),__depends:i}):Object.setPrototypeOf(t,{...Object.getPrototypeOf(t),__depends:i}),n},C=(e,r,o={})=>{const{overwrite:t}=o;if(!t)return;const n=t==="shallow";if(t==="merge"){g(e,r,u);return}(n?S:h)(e,r,u)},d="__polyglotSeededKeys",_=e=>{if(!p(e))return new Set;let r=e[d];if(!(r instanceof Set)){r=new Set;try{Object.defineProperty(e,d,{value:r,enumerable:!1,writable:!0,configurable:!0})}catch{}}return r},R=(e,r,o)=>_(e).has(r)?!0:!p(o)||o[r]===void 0,F=(e,r)=>(_(e).add(r),r);export{B as applyDependentState,D as checkForStateTypes,O as checkIfInherits,E as createInheritedState,T as createNestedObjectByKeyPath,v as findInheritedState,x as getChildStateInKey,w as getParentStateInKey,m as getRootStateInKey,R as isPolyglotWritableKey,K as isState,F as markPolyglotSeeded,C as overwriteState,_ as polyglotSeededKeys};
@@ -1,3 +1,3 @@
1
- const O=(e,r)=>{for(const t of r)if(e.includes(t))return!0;return!1},j=(e,r)=>{const t=new RegExp(`[${r.join("\\")}]`,"g");return e.replace(t,"")},L={2:/{{\s*((?:\.\.\/)*)([\w\d.]+)\s*(?:\|\s*([\w\d.]+))?\s*}}/g,3:/{{{(\s*(?:\.\.\/)*)([\w\d.]+)\s*(?:\|\s*([\w\d.]+))?\s*}}}/g},m=(e,r)=>r.split(".").reduce((t,a)=>t?.[a],e);function I(e,r,t={}){const{bracketsLength:a=2}=t,f=a===3?"{{{":"{{";if(!e.includes(f))return e;const h=L[a],o=r||this.state||{},i=this;return e.replace(h,(u,d,n,c)=>{const g=n.trim();if(c){const l=i?.context,s=l?.functions?.[c]||l?.utils?.[c]||l?.methods?.[c]||l?.snippets?.[c]||i?.[c];if(s&&typeof s=="function")try{return String(s.call(i,g)??"")}catch{return""}return""}if(d){const l=(d.match(/\.\.\//g)||[]).length;let s=o;for(let p=0;p<l;p++){if(!s||!s.parent)return"";s=s.parent}if(g==="parent")return String(s.value??"");const x=m(s,g);return String(x??"")}else{const l=m(o,g);if(l!=null)return String(l);const s=i?.context?.polyglot;if(s?.translations){const x=o?.root?.lang||o?.lang||i?.context?.state?.lang||s.defaultLang||"en",p=s.translations[x];if(p){const C=m(p,g);if(C!=null&&typeof C!="object")return String(C);for(const w in p){const b=p[w];if(b&&typeof b=="object"&&!Array.isArray(b)){const S=m(b,g);if(S!=null&&typeof S!="object")return String(S)}}}const y=m(s.translations,g);if(y!=null&&typeof y!="object")return String(y)}return""}})}const R=e=>`${e.charAt(0).toLowerCase()}${e.slice(1)}`,k=(e,r)=>{const t=e.split(`
2
- `);let a=-1,f=-1,h=-1,o=-1;const i=new RegExp(`\\b${r}\\b\\s*:\\s*`);let u=0,d=!1;for(let n=0;n<t.length;n++)if(i.test(t[n])&&!d){if(d=!0,a=n+1,h=t[n].indexOf(r)+1,t[n].includes("{}")){f=a,o=t[n].indexOf("{}")+3;break}const c=t[n].slice(h+r.length);if(c.includes("{")||c.includes("["))u=1;else{f=n+1,o=t[n].length+1;break}}else if(d&&(u+=(t[n].match(/{/g)||[]).length,u+=(t[n].match(/\[/g)||[]).length,u-=(t[n].match(/}/g)||[]).length,u-=(t[n].match(/]/g)||[]).length,u===0)){f=n+1,o=t[n].lastIndexOf("}")!==-1?t[n].lastIndexOf("}")+2:t[n].length+1;break}return{startColumn:h,endColumn:o,startLineNumber:a,endLineNumber:f}},A=/\\([0-7]{1,3})/g,E=e=>e.replace(A,(r,t)=>String.fromCharCode(parseInt(t,8))),$=e=>e.replace(/\n/g,"/////n").replace(/`/g,"/////tilde").replace(/\$/g,"/////dlrsgn"),F=e=>e.replace(/\/\/\/\/\/n/g,`
3
- `).replace(/\/\/\/\/\/tilde/g,"`").replace(/\/\/\/\/\/dlrsgn/g,"$"),N=/[^a-zA-Z0-9\s]/g,_=e=>e.replace(N,r=>"%"+r.charCodeAt(0).toString(16).toUpperCase()),v=e=>e.replace(/%[0-9A-Fa-f]{2}/g,r=>String.fromCharCode(parseInt(r.slice(1),16)));export{v as customDecodeURIComponent,_ as customEncodeURIComponent,F as decodeNewlines,$ as encodeNewlines,k as findKeyPosition,R as lowercaseFirstLetter,I as replaceLiteralsWithObjectFields,E as replaceOctalEscapeSequences,O as stringIncludesAny,j as trimStringFromSymbols};
1
+ const N=(e,r)=>{for(const t of r)if(e.includes(t))return!0;return!1},O=(e,r)=>{const t=new RegExp(`[${r.join("\\")}]`,"g");return e.replace(t,"")},L={2:/{{\s*((?:\.\.\/)*)([\w\d.]+)\s*(?:\|\s*([\w\d.]+))?\s*}}/g,3:/{{{(\s*(?:\.\.\/)*)([\w\d.]+)\s*(?:\|\s*([\w\d.]+))?\s*}}}/g},x=(e,r)=>r.split(".").reduce((t,a)=>t?.[a],e);function I(e,r,t={}){const{bracketsLength:a=2}=t,f=a===3?"{{{":"{{";if(!e.includes(f))return e;const m=L[a],c=r||this.state||{},i=this;return e.replace(m,(u,d,n,l)=>{const g=n.trim();if(l){const s=i?.context,o=s?.functions?.[l]||s?.utils?.[l]||s?.methods?.[l]||s?.snippets?.[l]||i?.[l];if(o&&typeof o=="function")try{return String(o.call(i,g)??"")}catch{return""}return""}if(d){const s=(d.match(/\.\.\//g)||[]).length;let o=c;for(let p=0;p<s;p++){if(!o||!o.parent)return"";o=o.parent}if(g==="parent")return String(o.value??"");const h=x(o,g);return h!=null&&typeof h=="object"?"":String(h??"")}else{const s=x(c,g);if(s!=null&&typeof s!="object")return String(s);const o=i?.context?.polyglot;if(o?.translations){const h=c?.root?.lang||c?.lang||i?.context?.state?.lang||o.defaultLang||"en",p=o.translations[h];if(p){const C=x(p,g);if(C!=null&&typeof C!="object")return String(C);for(const w in p){const b=p[w];if(b&&typeof b=="object"&&!Array.isArray(b)){const S=x(b,g);if(S!=null&&typeof S!="object")return String(S)}}}const y=x(o.translations,g);if(y!=null&&typeof y!="object")return String(y)}return""}})}const R=e=>`${e.charAt(0).toLowerCase()}${e.slice(1)}`,k=(e,r)=>{const t=e.split(`
2
+ `);let a=-1,f=-1,m=-1,c=-1;const i=new RegExp(`\\b${r}\\b\\s*:\\s*`);let u=0,d=!1;for(let n=0;n<t.length;n++)if(i.test(t[n])&&!d){if(d=!0,a=n+1,m=t[n].indexOf(r)+1,t[n].includes("{}")){f=a,c=t[n].indexOf("{}")+3;break}const l=t[n].slice(m+r.length);if(l.includes("{")||l.includes("["))u=1;else{f=n+1,c=t[n].length+1;break}}else if(d&&(u+=(t[n].match(/{/g)||[]).length,u+=(t[n].match(/\[/g)||[]).length,u-=(t[n].match(/}/g)||[]).length,u-=(t[n].match(/]/g)||[]).length,u===0)){f=n+1,c=t[n].lastIndexOf("}")!==-1?t[n].lastIndexOf("}")+2:t[n].length+1;break}return{startColumn:m,endColumn:c,startLineNumber:a,endLineNumber:f}},j=/\\([0-7]{1,3})/g,E=e=>e.replace(j,(r,t)=>String.fromCharCode(parseInt(t,8))),$=e=>e.replace(/\n/g,"/////n").replace(/`/g,"/////tilde").replace(/\$/g,"/////dlrsgn"),F=e=>e.replace(/\/\/\/\/\/n/g,`
3
+ `).replace(/\/\/\/\/\/tilde/g,"`").replace(/\/\/\/\/\/dlrsgn/g,"$"),A=/[^a-zA-Z0-9\s]/g,_=e=>e.replace(A,r=>"%"+r.charCodeAt(0).toString(16).toUpperCase()),v=e=>e.replace(/%[0-9A-Fa-f]{2}/g,r=>String.fromCharCode(parseInt(r.slice(1),16)));export{v as customDecodeURIComponent,_ as customEncodeURIComponent,F as decodeNewlines,$ as encodeNewlines,k as findKeyPosition,R as lowercaseFirstLetter,I as replaceLiteralsWithObjectFields,E as replaceOctalEscapeSequences,N as stringIncludesAny,O as trimStringFromSymbols};
package/object.js CHANGED
@@ -289,6 +289,12 @@ export const objectToString = (obj = {}, indent = 0) => {
289
289
  return String(obj)
290
290
  }
291
291
 
292
+ // A RegExp has no own enumerable keys, so the generic walk below would
293
+ // print `{}`. `String(/foo/g)` is the valid source literal `/foo/g` —
294
+ // exactly what a written-back .js file needs
295
+ // (FRANK-EMIT-REGEXP-SCOPE-VALUE-DIES-TO-EMPTY-OBJECT-1).
296
+ if (obj instanceof RegExp) return String(obj)
297
+
292
298
  // Handle empty object case - avoid Object.keys allocation
293
299
  let hasKeys = false
294
300
  for (const _k in obj) {
@@ -313,10 +319,14 @@ export const objectToString = (obj = {}, indent = 0) => {
313
319
  const stringedKey = keyNeedsQuotes ? `'${key}'` : key
314
320
  str += `${spaces} ${stringedKey}: `
315
321
 
316
- if (isArray(value)) {
322
+ if (value instanceof RegExp) {
323
+ str += String(value)
324
+ } else if (isArray(value)) {
317
325
  str += '[\n'
318
326
  for (const element of value) {
319
- if (isObjectLike(element) && element !== null) {
327
+ if (element instanceof RegExp) {
328
+ str += `${spaces} ${String(element)},\n`
329
+ } else if (isObjectLike(element) && element !== null) {
320
330
  str += `${spaces} ${objectToString(element, indent + 2)},\n`
321
331
  } else if (isString(element)) {
322
332
  str += `${spaces} '${element}',\n`
@@ -348,7 +358,16 @@ const FN_PATTERNS = [
348
358
  /^function[\s(]/,
349
359
  /^async\s+/,
350
360
  /^\(\s*function/,
351
- /^[a-zA-Z_$][a-zA-Z0-9_$]*\s*=>/
361
+ /^[a-zA-Z_$][a-zA-Z0-9_$]*\s*=>/,
362
+ // OBJECT-METHOD-SHORTHAND toString: `stopTracks(v4) { … }`, `*walk() { … }`.
363
+ // frank emissions predating plugins/frank/fnString.js normalization stored
364
+ // these verbatim; without this pattern the PLAIN (non-async) shape was
365
+ // never even recognized as a function string, so the shorthand recovery in
366
+ // _destringifyFnString could not run and the value stayed a string
367
+ // (silent dead handler). Anchored to a `{…}`-terminated body so ordinary
368
+ // prose containing `word(…)` never matches; params allow one nesting level
369
+ // for parenthesized defaults.
370
+ /^(?:\*\s*)?[a-zA-Z_$][\w$]*\s*\((?:[^()]|\([^()]*\))*\)\s*\{[\s\S]*\}$/
352
371
  ]
353
372
  const RE_JSON_LIKE = /^["[{]/
354
373
  // Module-source prefixes. A string starting with `export ` or `import ` is a
@@ -542,6 +561,25 @@ const _destringifyFnString = (str, label, opts) => {
542
561
  }
543
562
  }
544
563
  }
564
+ // OBJECT-METHOD-SHORTHAND recovery: `refresh() {…}` / `async mic() {…}`
565
+ // (a Function.prototype.toString of a shorthand method, stored by frank
566
+ // emissions predating plugins/frank/fnString.js normalization) is not a
567
+ // standalone expression — `('(' + str + ')')` throws
568
+ // "Unexpected token '{'" (plain) or "Unexpected identifier" (async) —
569
+ // but it IS valid inside an object literal. Wrap, eval, pluck the single
570
+ // method. This also faithfully revives `super`-using and quoted-name
571
+ // methods, which no standalone rewrite can.
572
+ if (!recovered && /Unexpected (token '\{'|identifier)/.test(msg)) {
573
+ try {
574
+ const wrapped = opts.window.eval('({' + str + '})')
575
+ if (wrapped && typeof wrapped === 'object') {
576
+ const wkeys = Object.keys(wrapped)
577
+ if (wkeys.length === 1 && typeof wrapped[wkeys[0]] === 'function') {
578
+ recovered = wrapped[wkeys[0]]
579
+ }
580
+ }
581
+ } catch (_) { /* fall through to the warning below */ }
582
+ }
545
583
  if (recovered) return recovered
546
584
  // FR-1 (FRANK-RUNNER.md): make the silent fallback loud so consumers
547
585
  // notice when a handler ends up stored as a string instead of a
@@ -591,14 +629,29 @@ export const deepDestringifyFunctions = (
591
629
  ? _destringifyFnString(arrProp, `array index ${i} (prop "${prop}")`, opts)
592
630
  : arrProp)
593
631
  } else if (isObject(arrProp)) {
594
- const child = {}
595
- arr.push(child)
596
- stack.push([arrProp, child])
632
+ const tagged = _rehydrateTagged(arrProp)
633
+ if (tagged) {
634
+ arr.push(tagged)
635
+ } else {
636
+ const child = {}
637
+ arr.push(child)
638
+ stack.push([arrProp, child])
639
+ }
597
640
  } else {
598
641
  arr.push(arrProp)
599
642
  }
600
643
  }
601
644
  } else if (isObject(objProp)) {
645
+ // `{__type:'RegExp'|'Set'|'Map', …}` (frank's stringifyFunctions
646
+ // tagged forms) revive to real instances instead of being walked —
647
+ // the walk would clone each to a dead plain object
648
+ // (FRANK-EMIT-REGEXP-SCOPE-VALUE-DIES-TO-EMPTY-OBJECT-1,
649
+ // FRANK-GLOBALSCOPE-CONST-PROTOTYPE-LOSS-1).
650
+ const tagged = _rehydrateTagged(objProp)
651
+ if (tagged) {
652
+ dest[prop] = tagged
653
+ continue
654
+ }
602
655
  // Preserve any pre-existing container the caller passed in for this
603
656
  // key (matches the legacy `destringified[prop]` argument); otherwise
604
657
  // allocate one.
@@ -619,18 +672,100 @@ export const deepDestringifyFunctions = (
619
672
  // destringifyGlobalScope-set-map.test.js.
620
673
  const TYPE_TAG_SET = 'Set'
621
674
  const TYPE_TAG_MAP = 'Map'
675
+ const TYPE_TAG_REGEXP = 'RegExp'
676
+ const TYPE_TAG_WEAKMAP = 'WeakMap'
677
+ const TYPE_TAG_WEAKSET = 'WeakSet'
678
+
679
+ // A weak tag carries NO payload (frank cannot read one out of a WeakMap, and no
680
+ // consumer could use one — the keys are object identities the transport drops),
681
+ // so the shape guard the other three use on their payload key is not available
682
+ // here. The discriminator instead is "the tag IS the whole object": exactly one
683
+ // own key, `__type`. A user object that carries data beside such a field is the
684
+ // user's own object and passes through with its contents intact
685
+ // (FRANK-WEAKMAP-CONST-STILL-DIES-TO-EMPTY-OBJECT-1).
686
+ const _isBareTag = (val) => {
687
+ const keys = Object.keys(val)
688
+ return keys.length === 1 && keys[0] === '__type'
689
+ }
622
690
 
623
691
  /**
624
- * Rehydrate Set / Map tagged forms back into real Set / Map instances.
625
- * Pass-through for any other value (including user objects that
626
- * happen to carry an unrelated `__type` field — only `'Set'` / `'Map'`
627
- * rehydrate).
692
+ * Rehydrate Set / Map / RegExp / WeakMap / WeakSet tagged forms back into real
693
+ * instances, at ANY DEPTH. Pass-through for any other value (including user
694
+ * objects that happen to carry an unrelated `__type` field — only the five tags
695
+ * above rehydrate).
696
+ *
697
+ * A revived WeakMap / WeakSet is EMPTY by construction, and that is the whole
698
+ * contract: what a consumer needs back from one is its PROTOTYPE, and the shape
699
+ * both types are authored in — a memo cache — starts empty on every page load
700
+ * anyway.
701
+ *
702
+ * The walk into plain objects and arrays is what
703
+ * FRANK-GLOBALSCOPE-CONST-PROTOTYPE-LOSS-1 added: frank tags a nested
704
+ * `{ re: /x/g }` / `[new Set([1])]` too, and a top-level-only revive would
705
+ * hand those back as the dead tagged shell — the same
706
+ * `TypeError: … is not a function` one level down. A container is rebuilt
707
+ * ONLY when a descendant actually revived, so ordinary data keeps its
708
+ * identity.
709
+ *
710
+ * Function STRINGS inside a revived Set or Map stay strings: a member of a
711
+ * Set was `{}` before this existed, so there is no prior contract that
712
+ * destringified one.
628
713
  */
629
- const _rehydrateTaggedValue = (val) => {
714
+ const _rehydrateTaggedValue = (val, seen) => {
630
715
  if (!val || typeof val !== 'object') return val
631
- if (val.__type === TYPE_TAG_SET && Array.isArray(val.values)) return new Set(val.values)
632
- if (val.__type === TYPE_TAG_MAP && Array.isArray(val.entries)) return new Map(val.entries)
633
- return val
716
+ const walk = (v) => _rehydrateTaggedValue(v, seen || (seen = new WeakMap()))
717
+ if (val.__type === TYPE_TAG_SET && isArray(val.values)) return new Set(val.values.map(walk))
718
+ if (val.__type === TYPE_TAG_MAP && isArray(val.entries)) {
719
+ return new Map(val.entries.map((e) => (isArray(e) ? [walk(e[0]), walk(e[1])] : e)))
720
+ }
721
+ if (val.__type === TYPE_TAG_WEAKMAP && _isBareTag(val)) return new WeakMap()
722
+ if (val.__type === TYPE_TAG_WEAKSET && _isBareTag(val)) return new WeakSet()
723
+ if (val.__type === TYPE_TAG_REGEXP && isString(val.source)) {
724
+ // Guard: a corrupt flags string must not take down the whole
725
+ // destringify pass — leave the tagged object as-is instead.
726
+ try { return new RegExp(val.source, isString(val.flags) ? val.flags : '') } catch (e) { return val }
727
+ }
728
+ if (!seen) seen = new WeakMap()
729
+ if (seen.has(val)) return seen.get(val)
730
+ let changed = false
731
+ if (isArray(val)) {
732
+ const out = new Array(val.length)
733
+ seen.set(val, out)
734
+ for (let i = 0; i < val.length; i++) {
735
+ out[i] = _rehydrateTaggedValue(val[i], seen)
736
+ if (out[i] !== val[i]) changed = true
737
+ }
738
+ if (!changed) seen.set(val, val)
739
+ return changed ? out : val
740
+ }
741
+ const out = {}
742
+ seen.set(val, out)
743
+ for (const key of Object.keys(val)) {
744
+ out[key] = _rehydrateTaggedValue(val[key], seen)
745
+ if (out[key] !== val[key]) changed = true
746
+ }
747
+ if (!changed) seen.set(val, val)
748
+ return changed ? out : val
749
+ }
750
+
751
+ // deepDestringifyFunctions rehydrates every tagged form frank's
752
+ // `stringifyFunctions` can emit for an element-scope value: RegExp
753
+ // (FRANK-EMIT-REGEXP-SCOPE-VALUE-DIES-TO-EMPTY-OBJECT-1) and, since
754
+ // FRANK-GLOBALSCOPE-CONST-PROTOTYPE-LOSS-1, Set and Map — which used to be
755
+ // tagged on the globalScope channel only, so the same const worked in
756
+ // globalScope and threw in an element-scope method. WeakMap and WeakSet joined
757
+ // them in FRANK-WEAKMAP-CONST-STILL-DIES-TO-EMPTY-OBJECT-1: `const
758
+ // _columnIndexCache = new WeakMap()` read from an element-scope method threw
759
+ // `this._columnIndexCache.get is not a function` on a live board. Returns null
760
+ // (never a revived value) when `val` is not a tagged form; all five revive to
761
+ // objects, so null is unambiguous.
762
+ const _rehydrateTagged = (val) => {
763
+ if (!val || typeof val !== 'object') return null
764
+ const tag = val.__type
765
+ if (tag !== TYPE_TAG_REGEXP && tag !== TYPE_TAG_SET && tag !== TYPE_TAG_MAP &&
766
+ tag !== TYPE_TAG_WEAKMAP && tag !== TYPE_TAG_WEAKSET) return null
767
+ const revived = _rehydrateTaggedValue(val)
768
+ return revived === val ? null : revived
634
769
  }
635
770
 
636
771
  /**
@@ -639,7 +774,10 @@ const _rehydrateTaggedValue = (val) => {
639
774
  * function, so helpers can reference constants and other helpers naturally.
640
775
  *
641
776
  * Also rehydrates Set/Map tagged forms (FT-FRANK-1) so `globalScope.X.has(y)`
642
- * works for the original Set/Map constructors authors put on globalScope.js.
777
+ * works for the original Set/Map constructors authors put on globalScope.js,
778
+ * and the contentless WeakMap/WeakSet tags
779
+ * (FRANK-WEAKMAP-CONST-STILL-DIES-TO-EMPTY-OBJECT-1) so `globalScope.X.get(o)`
780
+ * works for a weak memo cache.
643
781
  */
644
782
  export const destringifyGlobalScope = (gs) => {
645
783
  if (!gs || typeof gs !== 'object') return gs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/utils",
3
- "version": "3.14.768",
3
+ "version": "3.14.770",
4
4
  "license": "CC-BY-NC-4.0",
5
5
  "type": "module",
6
6
  "module": "./dist/esm/index.js",
@@ -60,6 +60,6 @@
60
60
  "browser": "./dist/esm/index.js",
61
61
  "sideEffects": false,
62
62
  "publishConfig": {
63
- "access": "restricted"
63
+ "access": "public"
64
64
  }
65
65
  }
@@ -105,6 +105,37 @@ const copyWithNestedIgnores = (value, skip, prefix) => {
105
105
 
106
106
  const EMPTY_IGNORE = new Set()
107
107
 
108
+ /**
109
+ * The section bags whose values are always objects or functions, never text.
110
+ * Same list frank's stub-phantom sweep walks (`plugins/frank/toJSON.js`), for
111
+ * the same reason: these are the bags a stubbed external import can land in.
112
+ */
113
+ const OBJECT_BAGS = new Set(['components', 'pages', 'functions', 'snippets', 'methods'])
114
+
115
+ /**
116
+ * Is the value sitting at `bag[key]` a STUB PHANTOM rather than a real value?
117
+ *
118
+ * When frank bundles a project, `stubExternalsPlugin` replaces an import it
119
+ * cannot resolve with a no-op proxy; `stringifyFunctions` then reduces that
120
+ * proxy to the empty string, so the published payload carries `""` where a
121
+ * component/page/function should be. In `OBJECT_BAGS` an empty string is never
122
+ * a value a library can legitimately mean — it is only ever that signature.
123
+ *
124
+ * This matters because the merge below is FIRST-WINS, which is correct for
125
+ * real values (an earlier declaration outranks a later one, and the consumer
126
+ * outranks every library) but wrong for a phantom: an earlier library's `""`
127
+ * would permanently shadow the real object a LATER declared library carries
128
+ * under the same name, and the consumer that declared the good library would
129
+ * still get `""`. Measured live 2026-08-21 on the published `workspace-ui`
130
+ * payload: 25 names held a real object in a later library and every one was
131
+ * thrown away (FRANK-STUB-PHANTOM-SHADOWS-REAL-LIB-VALUE-1).
132
+ *
133
+ * So a phantom does not occupy its slot. Precedence is untouched everywhere
134
+ * else — `designSystem`, `state` and every other key keep empty strings,
135
+ * because there `''` is a legal value.
136
+ */
137
+ const isStubPhantom = (bag, value) => value === '' && OBJECT_BAGS.has(bag)
138
+
108
139
  const stripJsExt = (segment) => segment.replace(/\.js$/iu, '')
109
140
 
110
141
  /**
@@ -190,7 +221,14 @@ const mergeOneLibrary = (context, sharedLib, ignore) => {
190
221
  } else {
191
222
  for (const k in sharedLib[key]) {
192
223
  if (skip.has(`${key}/${k}`)) continue // nested skip: 'components/Header'
193
- if (!(k in context[key])) context[key][k] = sharedLib[key][k]
224
+ if (!(k in context[key])) {
225
+ context[key][k] = sharedLib[key][k]
226
+ } else if (isStubPhantom(key, context[key][k]) && !isStubPhantom(key, sharedLib[key][k])) {
227
+ // The slot holds a stub phantom, not a value — a real value fills it.
228
+ // Order-independent: a real value already in the slot is never a
229
+ // phantom, so a later library's `''` can never overwrite it.
230
+ context[key][k] = sharedLib[key][k]
231
+ }
194
232
  }
195
233
  }
196
234
  } else if (!(key in context)) {
@@ -202,7 +240,9 @@ const mergeOneLibrary = (context, sharedLib, ignore) => {
202
240
  /**
203
241
  * Merge an array of shared library objects into a context.
204
242
  * - designSystem: deep defaults (non-destructive recursive)
205
- * - other object keys (components, pages, etc.): shallow add missing
243
+ * - other object keys (components, pages, etc.): shallow add missing. A slot
244
+ * holding a STUB PHANTOM counts as missing in the object bags — see
245
+ * `isStubPhantom`.
206
246
  * - new top-level keys: copy from library
207
247
  *
208
248
  * Entries may be a bare library context, or a wrapped `{ library, ignoreList }`
package/state.js CHANGED
@@ -201,3 +201,73 @@ export const overwriteState = (state, obj, options = {}) => {
201
201
  const overwriteFunc = shallow ? overwriteShallow : overwriteDeep
202
202
  overwriteFunc(state, obj, STATE_METHODS)
203
203
  }
204
+
205
+ // ── Polyglot key ownership ───────────────────────────────────────────────
206
+ //
207
+ // `prepareState` seeds the active language's translation map into the ROOT
208
+ // STATE so a bare `{{ key }}` resolves without the `| polyglot` filter. That
209
+ // seeding shares ONE namespace with every declared state key — the project's
210
+ // `state.js`, an app-level `state`, and every shared library's state — and a
211
+ // library author cannot see a consumer's translations (nor the consumer the
212
+ // library's state keys), so neither side can avoid a collision by review.
213
+ //
214
+ // The runtime holds the precedence instead:
215
+ //
216
+ // project state.js > shared library state.js > translations[lang]
217
+ //
218
+ // Polyglot owns ONLY the keys it seeded itself. `SEEDED_KEYS` records them on
219
+ // the context, non-enumerable so no `for…in`, serializer or JSON.stringify
220
+ // ever sees it, and both the boot seeding and a later `setLang` ask this
221
+ // before they write (RUNTIME-POLYGLOT-SEED-CLOBBERS-LIBRARY-STATE-1: gita
222
+ // booted with `a11yContrast` holding a Georgian panel label instead of
223
+ // `false`, so every a11y gate read truthy on first paint).
224
+ const SEEDED_KEYS = '__polyglotSeededKeys'
225
+
226
+ /**
227
+ * The set of root-state keys polyglot seeded on this context. Created on
228
+ * first use; always a Set, never null, for any object context.
229
+ */
230
+ export const polyglotSeededKeys = (context) => {
231
+ if (!isObject(context)) return new Set()
232
+ let keys = context[SEEDED_KEYS]
233
+ if (!(keys instanceof Set)) {
234
+ keys = new Set()
235
+ try {
236
+ Object.defineProperty(context, SEEDED_KEYS, {
237
+ value: keys,
238
+ enumerable: false,
239
+ writable: true,
240
+ configurable: true
241
+ })
242
+ } catch (e) {
243
+ // A frozen or trapped context keeps no record. Seeding still runs and
244
+ // still refuses to overwrite a declared key — only the language switch
245
+ // loses the memory of what it seeded, and falls back to "fill what is
246
+ // undefined". Never let bookkeeping break boot.
247
+ }
248
+ }
249
+ return keys
250
+ }
251
+
252
+ /**
253
+ * May polyglot write `key` into the root state? Only when polyglot seeded it
254
+ * before, or when nothing declares it yet. A key a project, an app or a
255
+ * shared library declares is never polyglot's to overwrite.
256
+ *
257
+ * @param {object} context - the app context carrying the seeded-key record
258
+ * @param {string} key - the translation key about to be written
259
+ * @param {object} [declared] - the state to test the key against
260
+ */
261
+ export const isPolyglotWritableKey = (context, key, declared) => {
262
+ if (polyglotSeededKeys(context).has(key)) return true
263
+ return !isObject(declared) || declared[key] === undefined
264
+ }
265
+
266
+ /**
267
+ * Record that polyglot seeded `key`, so a later language switch may retranslate
268
+ * it. Returns the key, for use inline.
269
+ */
270
+ export const markPolyglotSeeded = (context, key) => {
271
+ polyglotSeededKeys(context).add(key)
272
+ return key
273
+ }
package/string.js CHANGED
@@ -76,11 +76,15 @@ export function replaceLiteralsWithObjectFields (str, state, options = {}) {
76
76
  }
77
77
 
78
78
  const value = getNestedValue(parentState, key)
79
+ // `String()` on an object/array falls back to `Object.prototype.toString`
80
+ // (each array element joins in as literal "[object Object]"). A `{{ }}`
81
+ // template interpolates a scalar; render nothing rather than that.
82
+ if (value != null && typeof value === 'object') return ''
79
83
  return String(value ?? '')
80
84
  } else {
81
85
  // Check state value first
82
86
  const value = getNestedValue(obj, key)
83
- if (value != null) return String(value)
87
+ if (value != null && typeof value !== 'object') return String(value)
84
88
 
85
89
  // Fall back to polyglot translations for current language
86
90
  const poly = element?.context?.polyglot