@wcstack/state 4.6.1 → 4.6.2

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.
@@ -0,0 +1,2 @@
1
+ var a="4.6.2";export{a};
2
+ //# sourceMappingURL=chunk-AAEFSJ6G.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["VERSION","r"],"sources":["../../../package.json","../../../src/version.ts"],"sourcesContent":["{\n \"name\": \"@wcstack/state\",\n \"version\": \"4.6.1\",\n \"description\": \"Reactive state management with declarative data binding for Web Components. Zero dependencies, buildless.\",\n \"type\": \"module\",\n \"main\": \"./dist/index.esm.js\",\n \"module\": \"./dist/index.esm.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.esm.js\"\n },\n \"./auto\": {\n \"types\": \"./dist/auto.d.ts\",\n \"import\": \"./dist/auto.min.js\"\n },\n \"./core\": {\n \"types\": \"./dist/split/core.d.ts\",\n \"import\": \"./dist/split/core.js\"\n },\n \"./features/*\": {\n \"types\": \"./dist/split/features/*.d.ts\",\n \"import\": \"./dist/split/features/*.js\"\n },\n \"./define\": {\n \"types\": \"./dist/define.d.ts\",\n \"import\": \"./dist/define.js\"\n },\n \"./manifest\": {\n \"types\": \"./dist/manifest.d.ts\",\n \"import\": \"./dist/manifest.esm.js\"\n },\n \"./parser\": {\n \"types\": \"./dist/parser.d.ts\",\n \"import\": \"./dist/parser.esm.js\"\n },\n \"./wcs-manifest.json\": \"./dist/wcs-manifest.json\"\n },\n \"files\": [\n \"dist\",\n \"!dist/core.min.js\"\n ],\n \"scripts\": {\n \"clean\": \"node -e \\\"require('node:fs').rmSync('dist', { recursive: true, force: true })\\\"\",\n \"build\": \"node build.mjs\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"test:coverage\": \"vitest run --coverage\",\n \"lint\": \"eslint src\",\n \"typecheck\": \"tsc --noEmit\",\n \"golden\": \"node scripts/golden.mjs\",\n \"version:patch\": \"npm version patch\",\n \"version:minor\": \"npm version minor\",\n \"version:major\": \"npm version major\",\n \"prepublishOnly\": \"npm run build && npm run test:coverage\"\n },\n \"keywords\": [\n \"web-components\",\n \"state-management\",\n \"reactive\",\n \"data-binding\",\n \"proxy\",\n \"custom-elements\",\n \"shadow-dom\",\n \"buildless\",\n \"zero-dependencies\",\n \"declarative\"\n ],\n \"author\": \"mogera551\",\n \"homepage\": \"https://wcstack.github.io\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/wcstack/wcstack.git\",\n \"directory\": \"packages/state\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/wcstack/wcstack/issues\"\n },\n \"license\": \"MIT\",\n \"devDependencies\": {\n \"@eslint/js\": \"^9.39.5\",\n \"@vitest/coverage-v8\": \"^4.1.11\",\n \"esbuild\": \"0.27.2\",\n \"eslint\": \"^9.39.5\",\n \"globals\": \"^16.5.0\",\n \"happy-dom\": \"^20.0.11\",\n \"rollup\": \"^4.63.5\",\n \"rollup-plugin-dts\": \"^6.5.1\",\n \"terser\": \"^5.51.2\",\n \"typescript\": \"^5.9.3\",\n \"typescript-eslint\": \"^8.70.1\",\n \"vitest\": \"^4.0.15\"\n }\n}\n","import pkg from \"../package.json\" with { type: \"json\" };\n\n/** The package version: stamped into `<wcs-ssr>`, compared on hydration (major.minor), shown by DevTools. */\nexport const VERSION: string = pkg.version;\n"],"mappings":"AAAA,ICGaA,EDDA,eCCsBC","ignoreList":[]}
1
+ {"version":3,"names":["VERSION","r"],"sources":["../../../package.json","../../../src/version.ts"],"sourcesContent":["{\n \"name\": \"@wcstack/state\",\n \"version\": \"4.6.2\",\n \"description\": \"Reactive state management with declarative data binding for Web Components. Zero dependencies, buildless.\",\n \"type\": \"module\",\n \"main\": \"./dist/index.esm.js\",\n \"module\": \"./dist/index.esm.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.esm.js\"\n },\n \"./auto\": {\n \"types\": \"./dist/auto.d.ts\",\n \"import\": \"./dist/auto.min.js\"\n },\n \"./core\": {\n \"types\": \"./dist/split/core.d.ts\",\n \"import\": \"./dist/split/core.js\"\n },\n \"./features/*\": {\n \"types\": \"./dist/split/features/*.d.ts\",\n \"import\": \"./dist/split/features/*.js\"\n },\n \"./define\": {\n \"types\": \"./dist/define.d.ts\",\n \"import\": \"./dist/define.js\"\n },\n \"./manifest\": {\n \"types\": \"./dist/manifest.d.ts\",\n \"import\": \"./dist/manifest.esm.js\"\n },\n \"./parser\": {\n \"types\": \"./dist/parser.d.ts\",\n \"import\": \"./dist/parser.esm.js\"\n },\n \"./wcs-manifest.json\": \"./dist/wcs-manifest.json\"\n },\n \"files\": [\n \"dist\",\n \"!dist/core.min.js\"\n ],\n \"scripts\": {\n \"clean\": \"node -e \\\"require('node:fs').rmSync('dist', { recursive: true, force: true })\\\"\",\n \"build\": \"node build.mjs\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"test:coverage\": \"vitest run --coverage\",\n \"lint\": \"eslint src\",\n \"typecheck\": \"tsc --noEmit\",\n \"golden\": \"node scripts/golden.mjs\",\n \"version:patch\": \"npm version patch\",\n \"version:minor\": \"npm version minor\",\n \"version:major\": \"npm version major\",\n \"prepublishOnly\": \"npm run build && npm run test:coverage\"\n },\n \"keywords\": [\n \"web-components\",\n \"state-management\",\n \"reactive\",\n \"data-binding\",\n \"proxy\",\n \"custom-elements\",\n \"shadow-dom\",\n \"buildless\",\n \"zero-dependencies\",\n \"declarative\"\n ],\n \"author\": \"mogera551\",\n \"homepage\": \"https://wcstack.github.io\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/wcstack/wcstack.git\",\n \"directory\": \"packages/state\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/wcstack/wcstack/issues\"\n },\n \"license\": \"MIT\",\n \"devDependencies\": {\n \"@eslint/js\": \"^9.39.5\",\n \"@vitest/coverage-v8\": \"^4.1.11\",\n \"esbuild\": \"0.27.2\",\n \"eslint\": \"^9.39.5\",\n \"globals\": \"^16.5.0\",\n \"happy-dom\": \"^20.0.11\",\n \"rollup\": \"^4.63.5\",\n \"rollup-plugin-dts\": \"^6.5.1\",\n \"terser\": \"^5.51.2\",\n \"typescript\": \"^5.9.3\",\n \"typescript-eslint\": \"^8.70.1\",\n \"vitest\": \"^4.0.15\"\n }\n}\n","import pkg from \"../package.json\" with { type: \"json\" };\n\n/** The package version: stamped into `<wcs-ssr>`, compared on hydration (major.minor), shown by DevTools. */\nexport const VERSION: string = pkg.version;\n"],"mappings":"AAAA,ICGaA,EDDA,eCCsBC","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import{a as s}from"./chunks/chunk-RIZH2AQE.js";import{a as n,d as t,e as u}from"./chunks/chunk-ULMHOGJ2.js";import"./chunks/chunk-GBBBRPZR.js";import"./chunks/chunk-467LYA2V.js";import"./chunks/chunk-FBBHQU7S.js";import{g as a,h as c,i as h}from"./chunks/chunk-ZJYPRSTO.js";import{c as i}from"./chunks/chunk-T3FN37DU.js";import"./chunks/chunk-NITPUCPA.js";import"./chunks/chunk-CBMAVRYG.js";import"./chunks/chunk-JWRQLKOQ.js";import{g as o}from"./chunks/chunk-TNYNJXEC.js";function r(s){return s}export{a as TRUSTED_TYPES_POLICY_SLOT,s as VERSION,t as bootstrapState,u as buildBindings,r as defineState,n as getBindingsReady,i as getConfig,c as getTrustedTypesPolicy,o as installFeatures,h as setTrustedTypesPolicy};
1
+ import{a as s}from"./chunks/chunk-AAEFSJ6G.js";import{a as n,d as t,e as u}from"./chunks/chunk-ULMHOGJ2.js";import"./chunks/chunk-GBBBRPZR.js";import"./chunks/chunk-467LYA2V.js";import"./chunks/chunk-FBBHQU7S.js";import{g as a,h as c,i as h}from"./chunks/chunk-ZJYPRSTO.js";import{c as i}from"./chunks/chunk-T3FN37DU.js";import"./chunks/chunk-NITPUCPA.js";import"./chunks/chunk-CBMAVRYG.js";import"./chunks/chunk-JWRQLKOQ.js";import{g as o}from"./chunks/chunk-TNYNJXEC.js";function r(s){return s}export{a as TRUSTED_TYPES_POLICY_SLOT,s as VERSION,t as bootstrapState,u as buildBindings,r as defineState,n as getBindingsReady,i as getConfig,c as getTrustedTypesPolicy,o as installFeatures,h as setTrustedTypesPolicy};
2
2
  //# sourceMappingURL=core.js.map
@@ -1,2 +1,2 @@
1
- import{a as e}from"../chunks/chunk-RIZH2AQE.js";import{c as t,d as n,e as l,f as o,g as s,h as r,i as a,p as i}from"../chunks/chunk-467LYA2V.js";import"../chunks/chunk-FBBHQU7S.js";import"../chunks/chunk-ZJYPRSTO.js";import"../chunks/chunk-T3FN37DU.js";import"../chunks/chunk-NITPUCPA.js";import"../chunks/chunk-CBMAVRYG.js";import"../chunks/chunk-JWRQLKOQ.js";import{a as u,b as d}from"../chunks/chunk-TNYNJXEC.js";var f="__WCSTACK_DEVTOOLS_HOOK__",c=null,m=new Set,p=(e,t,n)=>({absolutePathInfo:{pathInfo:{path:t.t},stateElement:e.element},listIndex:null===n?null:{indexes:e.H(n)}}),h=new WeakMap,k=0;var v=new WeakMap;function g(e){if(null===c)return;let i=v.get(e),u=m.has(e)?function(e,i){let u=new Map,d=new Set,f=(r,a,d,f,c,m)=>{if(r===s)return;let v=function(e,s){return e===t?"textContent":e===n?`class.${s}`:e===l?`attr.${s}`:e===o?`style.${s}`:s}(r,a),g=0===f.n?null:c,w=`${(e=>{let t=h.get(e);return void 0===t&&h.set(e,t=++k),t})(d)}|${v}|${f.t}|${null===g?"":e.H(g).join(",")}`;if(u.has(w))return;let y=i?.get(w);u.set(w,y??{binding:{propName:v,statePathName:f.t,bindingType:m,node:d,replaceNode:d},absoluteAddress:p(e,f,g)})},c=e=>f(e.i,e.name,e.a,e.o,e.r,e.on()),m=e=>{if(!d.has(e)){if(d.add(e),null!==e.we)for(let t of e.we)c(t);if(e instanceof r&&null!==e.pe){let n=e.C.Xe;for(let l=0;l<n.length;l++){let o=e.V?.[l];void 0!==o?c(o):f(n[l].i,n[l].name,e.pe[2*l],n[l].o,e.r,n[l].i===t?"text":"prop")}}if(null!==e.u)for(let t of e.u)v(t)}},v=e=>{if(!d.has(e))if(d.add(e),e instanceof a){f(-1,"for",e.S,e.l.o,e.l.ce,"for");for(let t of e.Ae)m(t)}else null!==e.I&&m(e.I)};for(let t of e.ue.values())for(let e of t)c(e),null!==e.D&&v(e.D);for(let t of e.oe.values())if(null!==t.N&&v(t.N),null!==t.M)for(let e of t.M)v(e);return u}(e,i):new Map;if(void 0!==i)for(let[e,t]of i)u.has(e)||c({type:"state:binding-removed",...t});for(let[e,t]of u)(void 0===i||!i.has(e))&&c({type:"state:binding-added",...t});v.set(e,u)}function w(e){let t=i.get(e);if(void 0===t)throw new Error("[@wcstack/state] devtools: no state tree on this root");return t}function y(e){let t=new Set,n=new Set,l=new Set,o=new Set;for(let s of e.O.all()){for(let e=1;e<=s.n;e++)t.add(s.h[e].t);"*"===s.s&&n.add(s.t),null!==s.getter&&l.add(s.t),null!==s.se&&o.add(s.t)}let s=e.target;return{rootNode:e.root,element:e.element,paths:{list:t,element:n,getter:l,setter:o},commandTokenNames:new Set(Object.keys(e.commands)),eventTokenNames:new Set(e.Oe.keys()),staticDependency:new Map,dynamicDependency:new Map,watchPaths:null!==s.$watch&&"object"==typeof s.$watch?new Set(Object.keys(s.$watch)):null,keyedListPaths:null!==s.$listKeys&&"object"==typeof s.$listKeys?new Set(Object.keys(s.$listKeys)):null}}var S=new WeakSet,b=new WeakMap;function j(e,t){if(("mounting"===t||"reset"===t)&&function(e){let t=(t,n)=>{if(S.has(t))return;S.add(t);let l=t.emit;t.emit=(...o)=>(null!==c&&c({type:"state:token-emit",kind:n,tokenName:t.name,args:o,subscriberCount:t.size,stateElement:e.element}),l.apply(t,o))};for(let n of Object.values(e.commands))t(n,"command");for(let n of e.Oe.values())t(n,"event")}(e),"connected"===t){if(m.has(e))return;m.add(e),c?.({type:"state:element-registered",rootNode:e.root,element:e.element}),g(e)}else"disconnected"===t&&(m.delete(e),g(e),c?.({type:"state:element-unregistered",rootNode:e.root,element:e.element}))}function O(e,t,n,l,o,s){if(null===c)return;let r=p(e,t,0===t.n?null:n),a=b.get(e);void 0===a&&b.set(e,a=new Set),a.add(r),s&&c({type:"state:write",absoluteAddress:r,value:o,oldValue:l,hasOldValue:!0})}function $(e){if(null===c)return;let t=b.get(e);b.delete(e),void 0!==t&&c({type:"state:update-batch",addresses:t}),g(e)}function N(e,t,n){c?.({type:"state:binding-apply-error",path:n.o.t,bindingType:n.on(),error:t})}var M={name:"devtools",install(){u.element=d(u.element,j),u.re=d(u.re,O),u.me=d(u.me,$),u.Ye=d(u.Ye,N),function(){if(typeof document>"u"||document.documentElement?.hasAttribute("data-wcs-server"))return;let t=globalThis,n=t[f]??(t[f]=function(){let e=new Map,t=new Set,n=e=>{0===t.size?e._setSink(null):e._setSink(n=>{for(let l of t)l.onEvent?.(e.id,n)})};return{version:2,sources:e,register(l){if(!e.has(l.id)){e.set(l.id,l),n(l);for(let e of t)e.onSourceRegistered?.(l)}},unregister(n){let l=e.get(n);if(void 0!==l){l._setSink(null),e.delete(n);for(let e of t)e.onSourceUnregistered?.(n)}},addListener(l){t.add(l);for(let t of e.values())n(t),l.onSourceRegistered?.(t);return()=>{if(t.delete(l))for(let t of e.values())n(t)}}}}());2!==n.version&&console.warn(`[@wcstack/state] devtools hook registry version ${n.version}, expected 2: keeping the existing one.`),n.register({id:`state:${Math.random().toString(36).slice(2,10)}`,kind:"state",packageVersion:e,getStateElements:()=>[...m].map(y),overlays:()=>[],keyedSubscriptions:e=>function(e){let t=[];for(let n of e.O.all()){let l=n._,o=n.je?.length??0;if((null===l||0===l.size)&&0===o)continue;let s,r=0;if(null!==l)for(let e of l.values())r+=e.size;try{s=0===n.n?e.v(n,null):void 0}catch{s=void 0}t.push({path:n.t,tracked:!1,rows:r,keys:null===l?0:l.size,lists:o,lastValue:s})}return t}(w(e)),keys(e){let t=w(e).target;return Object.keys(t).filter(e=>{if(e.includes("*")||"$"===e[0])return!1;let n=Object.getOwnPropertyDescriptor(t,e);return void 0!==n.get||"function"!=typeof n.value})},read(e,t,n){let l;return w(e).element.createState("readonly",e=>{l=e.$resolve(t,n??[])}),l},write(e,t,n,l){w(e).element.createState("writable",e=>{e.$resolve(t,l??[],n)})},_setSink(e){let t=null===c&&null!==e;c=e,null===e&&(v=new WeakMap),u.at=e&&((e,t)=>c?.({...t,stateElement:e.element})),t&&queueMicrotask(()=>{for(let e of m)g(e)})}})}()}},T=M;export{T as default,M as devtools};
1
+ import{a as e}from"../chunks/chunk-AAEFSJ6G.js";import{c as t,d as n,e as l,f as o,g as s,h as r,i as a,p as i}from"../chunks/chunk-467LYA2V.js";import"../chunks/chunk-FBBHQU7S.js";import"../chunks/chunk-ZJYPRSTO.js";import"../chunks/chunk-T3FN37DU.js";import"../chunks/chunk-NITPUCPA.js";import"../chunks/chunk-CBMAVRYG.js";import"../chunks/chunk-JWRQLKOQ.js";import{a as u,b as d}from"../chunks/chunk-TNYNJXEC.js";var f="__WCSTACK_DEVTOOLS_HOOK__",c=null,m=new Set,p=(e,t,n)=>({absolutePathInfo:{pathInfo:{path:t.t},stateElement:e.element},listIndex:null===n?null:{indexes:e.H(n)}}),h=new WeakMap,k=0;var v=new WeakMap;function g(e){if(null===c)return;let i=v.get(e),u=m.has(e)?function(e,i){let u=new Map,d=new Set,f=(r,a,d,f,c,m)=>{if(r===s)return;let v=function(e,s){return e===t?"textContent":e===n?`class.${s}`:e===l?`attr.${s}`:e===o?`style.${s}`:s}(r,a),g=0===f.n?null:c,w=`${(e=>{let t=h.get(e);return void 0===t&&h.set(e,t=++k),t})(d)}|${v}|${f.t}|${null===g?"":e.H(g).join(",")}`;if(u.has(w))return;let y=i?.get(w);u.set(w,y??{binding:{propName:v,statePathName:f.t,bindingType:m,node:d,replaceNode:d},absoluteAddress:p(e,f,g)})},c=e=>f(e.i,e.name,e.a,e.o,e.r,e.on()),m=e=>{if(!d.has(e)){if(d.add(e),null!==e.we)for(let t of e.we)c(t);if(e instanceof r&&null!==e.pe){let n=e.C.Xe;for(let l=0;l<n.length;l++){let o=e.V?.[l];void 0!==o?c(o):f(n[l].i,n[l].name,e.pe[2*l],n[l].o,e.r,n[l].i===t?"text":"prop")}}if(null!==e.u)for(let t of e.u)v(t)}},v=e=>{if(!d.has(e))if(d.add(e),e instanceof a){f(-1,"for",e.S,e.l.o,e.l.ce,"for");for(let t of e.Ae)m(t)}else null!==e.I&&m(e.I)};for(let t of e.ue.values())for(let e of t)c(e),null!==e.D&&v(e.D);for(let t of e.oe.values())if(null!==t.N&&v(t.N),null!==t.M)for(let e of t.M)v(e);return u}(e,i):new Map;if(void 0!==i)for(let[e,t]of i)u.has(e)||c({type:"state:binding-removed",...t});for(let[e,t]of u)(void 0===i||!i.has(e))&&c({type:"state:binding-added",...t});v.set(e,u)}function w(e){let t=i.get(e);if(void 0===t)throw new Error("[@wcstack/state] devtools: no state tree on this root");return t}function y(e){let t=new Set,n=new Set,l=new Set,o=new Set;for(let s of e.O.all()){for(let e=1;e<=s.n;e++)t.add(s.h[e].t);"*"===s.s&&n.add(s.t),null!==s.getter&&l.add(s.t),null!==s.se&&o.add(s.t)}let s=e.target;return{rootNode:e.root,element:e.element,paths:{list:t,element:n,getter:l,setter:o},commandTokenNames:new Set(Object.keys(e.commands)),eventTokenNames:new Set(e.Oe.keys()),staticDependency:new Map,dynamicDependency:new Map,watchPaths:null!==s.$watch&&"object"==typeof s.$watch?new Set(Object.keys(s.$watch)):null,keyedListPaths:null!==s.$listKeys&&"object"==typeof s.$listKeys?new Set(Object.keys(s.$listKeys)):null}}var S=new WeakSet,b=new WeakMap;function j(e,t){if(("mounting"===t||"reset"===t)&&function(e){let t=(t,n)=>{if(S.has(t))return;S.add(t);let l=t.emit;t.emit=(...o)=>(null!==c&&c({type:"state:token-emit",kind:n,tokenName:t.name,args:o,subscriberCount:t.size,stateElement:e.element}),l.apply(t,o))};for(let n of Object.values(e.commands))t(n,"command");for(let n of e.Oe.values())t(n,"event")}(e),"connected"===t){if(m.has(e))return;m.add(e),c?.({type:"state:element-registered",rootNode:e.root,element:e.element}),g(e)}else"disconnected"===t&&(m.delete(e),g(e),c?.({type:"state:element-unregistered",rootNode:e.root,element:e.element}))}function O(e,t,n,l,o,s){if(null===c)return;let r=p(e,t,0===t.n?null:n),a=b.get(e);void 0===a&&b.set(e,a=new Set),a.add(r),s&&c({type:"state:write",absoluteAddress:r,value:o,oldValue:l,hasOldValue:!0})}function $(e){if(null===c)return;let t=b.get(e);b.delete(e),void 0!==t&&c({type:"state:update-batch",addresses:t}),g(e)}function N(e,t,n){c?.({type:"state:binding-apply-error",path:n.o.t,bindingType:n.on(),error:t})}var M={name:"devtools",install(){u.element=d(u.element,j),u.re=d(u.re,O),u.me=d(u.me,$),u.Ye=d(u.Ye,N),function(){if(typeof document>"u"||document.documentElement?.hasAttribute("data-wcs-server"))return;let t=globalThis,n=t[f]??(t[f]=function(){let e=new Map,t=new Set,n=e=>{0===t.size?e._setSink(null):e._setSink(n=>{for(let l of t)l.onEvent?.(e.id,n)})};return{version:2,sources:e,register(l){if(!e.has(l.id)){e.set(l.id,l),n(l);for(let e of t)e.onSourceRegistered?.(l)}},unregister(n){let l=e.get(n);if(void 0!==l){l._setSink(null),e.delete(n);for(let e of t)e.onSourceUnregistered?.(n)}},addListener(l){t.add(l);for(let t of e.values())n(t),l.onSourceRegistered?.(t);return()=>{if(t.delete(l))for(let t of e.values())n(t)}}}}());2!==n.version&&console.warn(`[@wcstack/state] devtools hook registry version ${n.version}, expected 2: keeping the existing one.`),n.register({id:`state:${Math.random().toString(36).slice(2,10)}`,kind:"state",packageVersion:e,getStateElements:()=>[...m].map(y),overlays:()=>[],keyedSubscriptions:e=>function(e){let t=[];for(let n of e.O.all()){let l=n._,o=n.je?.length??0;if((null===l||0===l.size)&&0===o)continue;let s,r=0;if(null!==l)for(let e of l.values())r+=e.size;try{s=0===n.n?e.v(n,null):void 0}catch{s=void 0}t.push({path:n.t,tracked:!1,rows:r,keys:null===l?0:l.size,lists:o,lastValue:s})}return t}(w(e)),keys(e){let t=w(e).target;return Object.keys(t).filter(e=>{if(e.includes("*")||"$"===e[0])return!1;let n=Object.getOwnPropertyDescriptor(t,e);return void 0!==n.get||"function"!=typeof n.value})},read(e,t,n){let l;return w(e).element.createState("readonly",e=>{l=e.$resolve(t,n??[])}),l},write(e,t,n,l){w(e).element.createState("writable",e=>{e.$resolve(t,l??[],n)})},_setSink(e){let t=null===c&&null!==e;c=e,null===e&&(v=new WeakMap),u.at=e&&((e,t)=>c?.({...t,stateElement:e.element})),t&&queueMicrotask(()=>{for(let e of m)g(e)})}})}()}},T=M;export{T as default,M as devtools};
2
2
  //# sourceMappingURL=devtools.js.map
@@ -1,2 +1,2 @@
1
- import{a as e}from"../chunks/chunk-RIZH2AQE.js";import{b as t,c as l}from"../chunks/chunk-ULMHOGJ2.js";import"../chunks/chunk-GBBBRPZR.js";import{a as n,i as r,j as o,k as i,l as s,m as a,n as c,o as u}from"../chunks/chunk-467LYA2V.js";import"../chunks/chunk-FBBHQU7S.js";import"../chunks/chunk-ZJYPRSTO.js";import{a as f}from"../chunks/chunk-T3FN37DU.js";import"../chunks/chunk-NITPUCPA.js";import"../chunks/chunk-CBMAVRYG.js";import"../chunks/chunk-JWRQLKOQ.js";import{a as d,b as p}from"../chunks/chunk-TNYNJXEC.js";var m=e=>e.split(".").slice(0,2).join("."),h=class extends t{static find(e){return e.querySelector?.(f.tagNames.ssr)??null}get version(){return this.getAttribute("version")??""}get stateData(){let e=this.querySelector('script[type="application/json"]');return null===e?{}:JSON.parse(e.textContent||"{}")}get templates(){let e=new Map;for(let t of Array.from(this.children))"template"===t.localName&&e.set(t.id,t);return e}get hydrateProps(){return{}}getTemplate(e){return this.templates.get(e)??null}verifyVersion(){return m(this.version)===m(e)}};function g(e){let t=f.tagNames.ssr;void 0===e.get(t)&&e.define(t,class extends h{})}var b=()=>f.tagNames.ssr,v=Symbol.for("wcstack.ssr.snapshotBuilder"),y=()=>!0===document.documentElement?.hasAttribute("data-wcs-server"),N=e=>document.createComment(e),w=(e,t)=>null!==e&&8===e.nodeType&&e.data===t,S=(e,t)=>null!==e&&8===e.nodeType&&e.data.startsWith(t),A=new WeakMap,x=new WeakMap,k=new WeakMap,T=new WeakSet,$=new WeakMap;function C(e,t){let l=[];for(let n=e;null!==n&&(l.push(n),n!==t);n=n.nextSibling);return l}function E(e,t,...l){for(let l of Array.from(e.attributes))t.setAttribute(l.name,l.value);return(t.content??t).append(...l),t}var j=e=>{let t=e.nextSibling;return 1!==e.nodeType||"a"!==t?.localName||!t.hasAttribute("data-wcs-ssr-link")&&e.anchorElement!==t?null:t};function W(e,t,l,n){let r=N(null===n?"wcs-[":`wcs-[:${n}`),o=N("wcs-]");l.length>0&&l[0].Pe().before(...C(e,t)),t.after(r);for(let e of l)null===n&&e.Pe().before(N("wcs-|"));let i=l.length>0?(e=>null===e.L?e.ct:e.L[e.L.length-1])(l[l.length-1]):r;(j(i)??i).after(o);for(let e of C(r,o))T.add(e)}function q(e){if(e instanceof r){W(e.S,e.S,e.Ae,null);for(let t of e.Ae)M(t);return}let t=e.I;null!==t&&(W(e.q[e.y].S,e.q[e.q.length-1].S,[t],e.y),M(t))}function M(e){if(null!==e.u)for(let t of e.u)q(t)}var I=new Set(["script","style","template","textarea","title"]),O="data-wcs-raw",R=e=>I.has(e.localName)||e.localName===b();function P(e){for(let t of Array.from(e.childNodes))3===t.nodeType?""===t.data?t.replaceWith(N("wcs-e")):null!==t.nextSibling&&3===t.nextSibling.nodeType&&t.after(N("wcs-s")):1===t.nodeType&&!R(t)&&P(t)}var D=0;function z(t,l){let n=t.getRootNode(),r=[l];for(let e of x.get(n)??[])e!==l&&!0===e.element?.hasAttribute("bind-component")&&r.push(e);let o=new Map;for(let e of r){let t=A.get(e);if(void 0===t)continue;let l=new Map;for(let t of e.oe.values())if(null!==t.N&&l.set(t.N.S,t.N),null!==t.M)for(let e of t.M)l.set(e.S,e);for(let t of e.ue.values())for(let e of t)if(null!==e.D)for(let t of e.D.q)l.set(t.S,e.D);let n=new Set;for(let[e,r]of t){o.set(e,r);let t=l.get(e);void 0!==t&&!n.has(t)&&e.isConnected&&(n.add(t),q(t))}}for(let e of Array.from(n.querySelectorAll("*"))){let t=k.get(e);if(void 0!==t){let l=document.createTreeWalker(e,133,{acceptNode:e=>T.has(e)||1===e.nodeType&&t.has(e)&&V(e)?2:1}),n=[];for(let e=l.nextNode();null!==e;e=l.nextNode()){let l=e.previousSibling;(3===e.nodeType?e.data.includes("{{")&&!(R(e.parentNode)?$.has(e):t.has(l)&&S(l,"wcs-t:"))&&($.has(e)||t.get(e)!==e.data):!t.has(e))&&n.push(e)}for(let e of n)e.remove()}let l=Array.from(e.childNodes);R(e)&&l.some(e=>$.has(e))&&e.setAttribute(O,l.map(e=>$.has(e)?`{{ ${$.get(e)} }}`:8===e.nodeType?`\x3c!--${e.data}--\x3e`:e.textContent).join(""))}P(9===n.nodeType?n.body:n);let i=document.createElement(b());i.setAttribute("version",e);let s=document.createElement("script");s.type="application/json",s.textContent=function(e){return JSON.stringify(e).replace(/[<>&\u2028\u2029]/g,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,"0")}`)}(function(e){let t={};for(let l of Object.keys(e)){if("$"===l[0])continue;let n=Object.getOwnPropertyDescriptor(e,l);void 0!==n.get||void 0!==n.set||"function"==typeof n.value||(t[l]=n.value)}return t}(l.target)),i.append(s);for(let[e,t]of o){if(!e.isConnected)continue;let l=e.parentNode;for(;null!==l&&"svg"!==l.localName&&"foreignObject"!==l.localName;)l=l.parentElement;let n="svg"===l?.localName,r=`wcs-${n?"s":"t"}${D++}`;e.replaceWith(N(`wcs-p:${r}`));let o=document.importNode(u(t),!0);for(let e of Array.from(o.querySelectorAll("template")))"http://www.w3.org/2000/svg"===e.namespaceURI&&e.replaceWith(E(e,document.createElement("template"),...e.childNodes));if(n){let e=document.createElementNS(l.namespaceURI,"svg");e.append(o),o=e}let s=document.createElement("template");s.id=r,i.append(E(t,s,o))}t.before(i)}function U(e){!function(e){if(null!==e.querySelector(f.tagNames.state))for(let t of Array.from(e.querySelectorAll("input,textarea,select")))if("select"===t.localName){let e=Array.from(t.options);if(t.multiple||e.some(e=>e.hasAttribute("selected"))||e[t.selectedIndex]!==e.find(e=>!e.disabled))for(let t of e)t.toggleAttribute("selected",t.selected)}else"textarea"===t.localName?t.value!==t.defaultValue&&!t.value.includes("{{")&&!Array.from(t.childNodes).some(e=>$.has(e))&&(t.textContent=t.value):"checkbox"===t.type||"radio"===t.type?t.toggleAttribute("checked",t.checked):"password"!==t.type&&t.value!==t.defaultValue&&t.setAttribute("value",t.value)}(e);for(let t of Array.from(e.querySelectorAll(`${f.tagNames.state}[enable-ssr]`))){if(t.hasAttribute("mount")||t.hasAttribute("bind-component")||t.previousElementSibling?.localName===b())continue;let e=t.engine;null!=e&&z(t,e)}}var B=Symbol.for("wcstack.state.ssr.impl"),J=new Map,L=new WeakMap,V=e=>!0===d.Eo?.(e),Q=e=>1===e.nodeType&&!R(e)&&!V(e),Y=e=>e.f.flat().concat(e.z??[]),Z=e=>{for(let t of Y(e))t.remove()};function G(e,t,l){let n=/^wcs-\[(?::(\d+))?/.exec(e.data),r=e.previousSibling,o=e.parentNode,i=[],s=e.nextSibling;for(e.remove();null!==s&&!w(s,"wcs-]");){let e=s.nextSibling;if(w(s,"wcs-|"))i.push([]),s.remove();else{0===i.length&&i.push([]);let l=i[i.length-1];S(s,"wcs-[")?e=G(s,t,l):(l.push(s),Q(s)&&H(s,t))}s=e}let c={branch:void 0===n[1]?null:Number(n[1]),f:i,z:s??o.appendChild(N("wcs-]"))},u=Y(c);s=c.z.nextSibling;for(let e of u)l?.push(e),t&&a.add(e);return t&&null!==r?J.set(r,c):Z(c),s}function H(e,t){for(let l=e.firstChild;null!==l;)S(l,"wcs-[")?l=G(l,t):(Q(l)&&H(l,t),l=l.nextSibling)}function F(e,t,l){let n=e=>{for(let r of Array.from(e.childNodes))if(r.parentNode===e)if(8===r.nodeType){let e=r.data;try{if("wcs-s"===e)r.remove();else if("wcs-e"===e)r.replaceWith("");else if(e.startsWith("wcs-t:")){let t=N(`@@:${decodeURIComponent(e.slice(6))}`),l=r.nextSibling;for(;null!==l&&!w(l,"wcs-/t");){let e=l.nextSibling;l.remove(),l=e}l?.remove(),r.replaceWith(t)}else if(e.startsWith("wcs-p:")){let l=t.querySelector(`template[id="${e.slice(6)}"]`);if(null!==l){let t=r.parentNode,n="s"===e[10]?E(l,document.createElementNS(t.namespaceURI,"template"),...document.importNode(l.content.firstChild,!0).childNodes):document.importNode(l,!0);n.removeAttribute("id"),t.replaceChild(n,r)}}}catch{}}else 1===r.nodeType&&!R(r)&&(V(r)?L.set(r,{ssr:t,Te:l}):n(r))};n(e),function(e){for(let t of Array.from(e.querySelectorAll("table > tbody"))){let e=[];for(let l=t.previousSibling;null!==l&&(8===l.nodeType||re(l)||"template"===l.localName);l=l.previousSibling)e.unshift(l);let l=0,n=0;if(e.forEach((e,t)=>{S(e,"wcs-[")?n++:w(e,"wcs-]")&&--n<0&&(n=0,l=t+1)}),0===n)continue;let r=0;for(let n=t.firstChild;null!==n;n=n.nextSibling)if(S(n,"wcs-["))r++;else if(w(n,"wcs-]")&&0===r--){t.prepend(...e.slice(l));break}}}(e),H(e,l)}function K(e,t){let l=L.get(e);if(void 0===l)return null;L.delete(e);let n=e=>F(e,l.ssr,l.Te);if(l.Te||te(t,e,e,n),n(e),!l.Te)return null;let r=d.Te;return d.Te=se,()=>{d.Te=r,X()}}function X(){for(let e of J.values())Z(e);J.clear()}function _(e){let t=[];for(let l=document.createTreeWalker(e,128);l.nextNode();)t.push(l.currentNode);return t}function ee(e,t,l,n){let r=null;for(let n of e){let e=n[l];null!==e&&(""===e||t===e||t.startsWith(`${e}.`))&&(null===r||e.length>r[l].length)&&(r=n)}let o=r?.[n];if(null==o)return null;let i=r[l],s=""===i?t:t.slice(i.length+1);return""===o?s:""===s?o:`${o}.${s}`}function te(e,t,l,n){let r=document.createElement("template").content;for(let e of l.childNodes)r.appendChild(r.ownerDocument.importNode(e,!0));n(r),e.root=t;let o=()=>{};c(e,[...r.childNodes],null,!0,o,o,o,(t,l)=>s(e,l,null,0))}function le(e,t,l){if(y()){if(l instanceof Array){for(let e=l.length;e-- >0;)o(l[e])&&l.splice(e,1);let e=t;if(l.some(i))T.add(e);else if(e.localName.includes("-")&&!V(e)){let t=new Map;for(let l=document.createTreeWalker(e,133);l.nextNode();)t.set(l.currentNode,l.currentNode.data);k.set(e,t)}return}if("string"==typeof l){if($.set(t,l),R(t.parentNode))return;let e=N(`wcs-t:${encodeURIComponent(l)}`),n=N("wcs-/t");return t.before(e),void t.after(n)}let n=A.get(e);void 0===n&&A.set(e,n=new Map),n.set(t,l);let r=t.getRootNode(),s=x.get(r);return void 0===s&&x.set(r,s=new Set),void s.add(e)}if("string"!=typeof l&&J.size>0){let e=J.get(l);void 0!==e&&(J.delete(l),J.set(t,e))}}var ne=e=>null!==e&&8===e.nodeType&&[f.commentIfPrefix,f.commentElseIfPrefix,f.commentElsePrefix].includes(e.data),re=e=>3===e.nodeType&&""===e.data.trim(),oe=e=>{let t=J.get(e)?.z??e;return(j(t)??t).nextSibling};function ie(e,t){if(t.length!==e.ln.childNodes.length)return!1;let l=e.Cn;for(let n=0;n<l.length;n++){let r=l[n],o=e.ln,i=t[r[0]];for(let e=0;;){if(o=o.childNodes[r[e]],i?.nodeName!==o.nodeName)return!1;if(++e===r.length)break;i=(j(i)??i).firstChild;for(let t=r[e];t>0&&null!==i;t--)i=oe(i)}e.So[n]=i}return!0}function se(e,t,l){if(0===J.size)return null;let n=t,r=0;if(!l){let e=f.commentIfPrefix;if(!w(t,e))for(let l=t.previousSibling;null!==l&&1!==l.nodeType&&(ne(l)&&r++,!w(l,e));l=l.previousSibling);for(let l=t.nextSibling;!J.has(n)&&null!==l&&!w(l,e)&&1!==l.nodeType;l=l.nextSibling)ne(l)&&(n=l)}let o=J.get(n);if(void 0===o)return null;if(!l&&o.branch!==r)return J.delete(n),Z(o),null;let i=o.f.shift();if(0===o.f.length&&J.delete(n),o.z?.replaceWith(...C(t,n)),o.z=null,void 0===i)return null;let s=[];for(let e=0;e<i.length;e++){let t=J.get(i[e]);if(s.push(i[e]),void 0!==t)for(;e<i.length&&i[e]!==t.z;)e++;else j(i[e])===i[e+1]&&e++}if(!ie(e,s)){let l=(e.Dn?e.root:e.ln).cloneNode(!0);s=e.Dn?[l]:[...l.childNodes],ie(e,s),(i[0]??o.f.find(e=>e.length>0)?.[0]??t).before(l);for(let e of i)e.remove()}return s}var ae={name:"ssr",install(){d.jn=le,d.hr=K;let t=d.element;d.element=(l,r)=>{"mounting"===r&&function(t){let l=t.element;if(!l.hasAttribute("enable-ssr")||y())return;let r=l.previousElementSibling,o=r?.localName===b(),i=o?r.getAttribute("version"):null,s=null===i||m(i)===m(e);if(s){let e=t,l=e.$e;e.$e=(e,n)=>"$connectedCallback"===e?void 0:l.call(t,e,n)}if(!o)return;let a=!s&&parseInt(i)<4,c=/^3\.(\d+)\.(\d+)$/.exec(i),u=null!==c&&(+c[1]-5||+c[2]-3)>=0;s||console.warn(`[@wcstack/state] <${b()} version="${i}"> does not match ${e}: its snapshot is discarded, and the page renders on the client from its own state.${a&&!u?" 3.x output keeps only the path of a text binding outside a template, so such a binding loses its filters: deploy @wcstack/server 4.0 with this client.":""}`);let p=s?r.querySelector('script[type="application/json"]'):null;if(null!==p){let e=JSON.parse(p.textContent||"{}"),l=t.target;for(let t of Object.keys(e)){let n=Object.getOwnPropertyDescriptor(l,t);void 0!==n&&(void 0!==n.get||void 0!==n.set||"function"==typeof n.value)||(l[t]=e[t])}t.hydrated=!0}let h=l.getRootNode();for(let e of Array.from(h.querySelectorAll(`[${O}]`)))e.textContent=e.getAttribute(O),e.removeAttribute(O);let g=9===h.nodeType?h.body:h;r.remove();let v=e=>a?function(e,t,l){let r=new Map,o=e=>{let t=e.parentElement;for(;null!==t&&!V(t);)t=t.parentElement;if(null===t)return null;let l=r.get(t);if(void 0===l){let e=o(t),i=t.querySelector(`:scope > ${f.tagNames.state}[bind-component]`).getAttribute("bind-component");r.set(t,l=[]);for(let r of n(t.getAttribute(f.bindAttributeName)??"")){let t=r.Ze;r.Ne[0]===i&&l.push([e?ee(e,t,1,0):t,r.Ne.slice(1).join("."),e&&t])}}return l},i=(e,t,l)=>{let n=o(e);if(null===n)return t;let r=/^([^|]*)#m\d+\.([^|]*)$/.exec(t);if(null===r)return l?t:ee(n,t,0,1)??t;let i=r[1].replace(/#m\d+\./g,"").slice(0,-1);return n.some(e=>""===e[1]&&(e[0]===i||e[2]===i))?r[2]:ee(n,r[2],2,1)??r[2]};for(let t of _(e).reverse()){let e=/^@@wcs-(\w+)-start:([\s\S]*)/.exec(t.data);if(null===e)continue;let n=t.nextSibling;for(;null!==n&&!w(n,`@@wcs-${e[1]}-end:${e[2]}`);)n=n.nextSibling;if(null!==n){for(;t.nextSibling!==n;)t.nextSibling.remove();n.remove(),t.replaceWith(..."text"===e[1]?[N(`@@:${i(t,e[2],l)}`)]:[])}}let s=(e,l)=>{for(let n of _(e)){let e=/^@@wcs-(?:for|if|elseif|else):(\S+)$/.exec(n.data)?.[1],r=Array.from(t.querySelectorAll("template")).find(t=>t.id===e);if(void 0===r)continue;let o=document.importNode(r,!0),a=f.bindAttributeName;o.removeAttribute("id"),o.setAttribute(a,o.getAttribute(a).replace(/^(\s*\w+\s*:\s*)([^\s|]+)/,(e,t,r)=>t+i(l??n,r))),s(o.content,l??n);let c=o.content.firstChild;n.replaceWith(.../^\s*elseif\s*:/.test(c?.getAttribute?.(a)??"")?o.content.childNodes:[o])}};s(e);for(let t of Array.from(e.querySelectorAll("[data-wcs-ssr-id]")))t.removeAttribute("data-wcs-ssr-id")}(e,r,u):F(e,r,s);s||te(t,h,g,v),queueMicrotask(function(e){let t=[];for(let l of Array.from(e.querySelectorAll("input,textarea,select")))if("select"===l.localName){let e=Array.from(l.options),n=e.map(e=>e.selected),r=e.map(e=>e.hasAttribute("selected")),o=r.lastIndexOf(!0);o<0&&(o=e.findIndex(e=>!e.disabled)),(l.multiple?e.some((e,t)=>n[t]!==r[t]):l.selectedIndex!==o)&&t.push([l,()=>e.forEach((e,t)=>e.selected=n[t])])}else if("checkbox"===l.type||"radio"===l.type){let e=l.checked;e!==l.defaultChecked&&(e||"checkbox"===l.type)&&t.push([l,()=>l.checked=e])}else if("file"!==l.type&&l.value!==l.defaultValue){let e=l.value;t.push([l,()=>l.value=e])}return()=>{for(let[e,l]of t)e.isConnected&&(l(),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})))}}(g)),v(g),s&&(d.Te=se,queueMicrotask(()=>{X(),d.Te=null}))}(l),t?.(l,r)},function(){let e=globalThis;e[B]={build:U,reset(){D=0}},void 0===e[v]&&(e[v]={protocol:"wcs-ssr-snapshot",version:1,build:t=>e[B].build(t),reset:()=>e[B].reset()})}(),d.Ao=p(d.Ao,g);for(let e of l())g(e)}},ce=ae;export{ce as default,ae as ssr};
1
+ import{a as e}from"../chunks/chunk-AAEFSJ6G.js";import{b as t,c as l}from"../chunks/chunk-ULMHOGJ2.js";import"../chunks/chunk-GBBBRPZR.js";import{a as n,i as r,j as o,k as i,l as s,m as a,n as c,o as u}from"../chunks/chunk-467LYA2V.js";import"../chunks/chunk-FBBHQU7S.js";import"../chunks/chunk-ZJYPRSTO.js";import{a as f}from"../chunks/chunk-T3FN37DU.js";import"../chunks/chunk-NITPUCPA.js";import"../chunks/chunk-CBMAVRYG.js";import"../chunks/chunk-JWRQLKOQ.js";import{a as d,b as p}from"../chunks/chunk-TNYNJXEC.js";var m=e=>e.split(".").slice(0,2).join("."),h=class extends t{static find(e){return e.querySelector?.(f.tagNames.ssr)??null}get version(){return this.getAttribute("version")??""}get stateData(){let e=this.querySelector('script[type="application/json"]');return null===e?{}:JSON.parse(e.textContent||"{}")}get templates(){let e=new Map;for(let t of Array.from(this.children))"template"===t.localName&&e.set(t.id,t);return e}get hydrateProps(){return{}}getTemplate(e){return this.templates.get(e)??null}verifyVersion(){return m(this.version)===m(e)}};function g(e){let t=f.tagNames.ssr;void 0===e.get(t)&&e.define(t,class extends h{})}var b=()=>f.tagNames.ssr,v=Symbol.for("wcstack.ssr.snapshotBuilder"),y=()=>!0===document.documentElement?.hasAttribute("data-wcs-server"),N=e=>document.createComment(e),w=(e,t)=>null!==e&&8===e.nodeType&&e.data===t,S=(e,t)=>null!==e&&8===e.nodeType&&e.data.startsWith(t),A=new WeakMap,x=new WeakMap,k=new WeakMap,T=new WeakSet,$=new WeakMap;function C(e,t){let l=[];for(let n=e;null!==n&&(l.push(n),n!==t);n=n.nextSibling);return l}function E(e,t,...l){for(let l of Array.from(e.attributes))t.setAttribute(l.name,l.value);return(t.content??t).append(...l),t}var j=e=>{let t=e.nextSibling;return 1!==e.nodeType||"a"!==t?.localName||!t.hasAttribute("data-wcs-ssr-link")&&e.anchorElement!==t?null:t};function W(e,t,l,n){let r=N(null===n?"wcs-[":`wcs-[:${n}`),o=N("wcs-]");l.length>0&&l[0].Pe().before(...C(e,t)),t.after(r);for(let e of l)null===n&&e.Pe().before(N("wcs-|"));let i=l.length>0?(e=>null===e.L?e.ct:e.L[e.L.length-1])(l[l.length-1]):r;(j(i)??i).after(o);for(let e of C(r,o))T.add(e)}function q(e){if(e instanceof r){W(e.S,e.S,e.Ae,null);for(let t of e.Ae)M(t);return}let t=e.I;null!==t&&(W(e.q[e.y].S,e.q[e.q.length-1].S,[t],e.y),M(t))}function M(e){if(null!==e.u)for(let t of e.u)q(t)}var I=new Set(["script","style","template","textarea","title"]),O="data-wcs-raw",P=e=>I.has(e.localName)||e.localName===b();function R(e){for(let t of Array.from(e.childNodes))3===t.nodeType?""===t.data?t.replaceWith(N("wcs-e")):null!==t.nextSibling&&3===t.nextSibling.nodeType&&t.after(N("wcs-s")):1===t.nodeType&&!P(t)&&R(t)}var D=0;function z(t,l){let n=t.getRootNode(),r=[l];for(let e of x.get(n)??[])e!==l&&!0===e.element?.hasAttribute("bind-component")&&r.push(e);let o=new Map;for(let e of r){let t=A.get(e);if(void 0===t)continue;let l=new Map;for(let t of e.oe.values())if(null!==t.N&&l.set(t.N.S,t.N),null!==t.M)for(let e of t.M)l.set(e.S,e);for(let t of e.ue.values())for(let e of t)if(null!==e.D)for(let t of e.D.q)l.set(t.S,e.D);let n=new Set;for(let[e,r]of t){o.set(e,r);let t=l.get(e);void 0!==t&&!n.has(t)&&e.isConnected&&(n.add(t),q(t))}}for(let e of Array.from(n.querySelectorAll("*"))){let t=k.get(e);if(void 0!==t){let l=document.createTreeWalker(e,133,{acceptNode:e=>T.has(e)||1===e.nodeType&&t.has(e)&&V(e)?2:1}),n=[];for(let e=l.nextNode();null!==e;e=l.nextNode()){let l=e.previousSibling;(3===e.nodeType?e.data.includes("{{")&&!(P(e.parentNode)?$.has(e):t.has(l)&&S(l,"wcs-t:"))&&($.has(e)||t.get(e)!==e.data):!t.has(e))&&n.push(e)}for(let e of n)e.remove()}let l=Array.from(e.childNodes);P(e)&&l.some(e=>$.has(e))&&e.setAttribute(O,l.map(e=>$.has(e)?`{{ ${$.get(e)} }}`:8===e.nodeType?`\x3c!--${e.data}--\x3e`:e.textContent).join(""))}R(9===n.nodeType?n.body:n);let i=document.createElement(b());i.setAttribute("version",e);let s=document.createElement("script");s.type="application/json",s.textContent=function(e){return JSON.stringify(e).replace(/[<>&\u2028\u2029]/g,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,"0")}`)}(function(e){let t={};for(let l of Object.keys(e)){if("$"===l[0])continue;let n=Object.getOwnPropertyDescriptor(e,l);void 0!==n.get||void 0!==n.set||"function"==typeof n.value||(t[l]=n.value)}return t}(l.target)),i.append(s);for(let[e,t]of o){if(!e.isConnected)continue;let l=e.parentNode;for(;null!==l&&"svg"!==l.localName&&"foreignObject"!==l.localName;)l=l.parentElement;let n="svg"===l?.localName,r=`wcs-${n?"s":"t"}${D++}`;e.replaceWith(N(`wcs-p:${r}`));let o=document.importNode(u(t),!0);for(let e of Array.from(o.querySelectorAll("template")))"http://www.w3.org/2000/svg"===e.namespaceURI&&e.replaceWith(E(e,document.createElement("template"),...e.childNodes));if(n){let e=document.createElementNS(l.namespaceURI,"svg");e.append(o),o=e}let s=document.createElement("template");s.id=r,i.append(E(t,s,o))}t.before(i)}function U(e){!function(e){if(null!==e.querySelector(f.tagNames.state))for(let t of Array.from(e.querySelectorAll("input,textarea,select")))if("select"===t.localName){let e=Array.from(t.options);if(t.multiple||e.some(e=>e.hasAttribute("selected"))||e[t.selectedIndex]!==e.find(e=>!e.disabled))for(let t of e)t.toggleAttribute("selected",t.selected)}else"textarea"===t.localName?t.value!==t.defaultValue&&!t.value.includes("{{")&&!Array.from(t.childNodes).some(e=>$.has(e))&&(t.textContent=t.value):"checkbox"===t.type||"radio"===t.type?t.toggleAttribute("checked",t.checked):"password"!==t.type&&t.value!==t.defaultValue&&t.setAttribute("value",t.value)}(e);for(let t of Array.from(e.querySelectorAll(`${f.tagNames.state}[enable-ssr]`))){if(t.hasAttribute("mount")||t.hasAttribute("bind-component")||t.previousElementSibling?.localName===b())continue;let e=t.engine;null!=e&&z(t,e)}}var J=Symbol.for("wcstack.state.ssr.impl"),B=new Map,L=new WeakMap,V=e=>!0===d.Eo?.(e),G=e=>1===e.nodeType&&!P(e)&&!V(e),Y=e=>e.f.flat().concat(e.z??[]),F=e=>{for(let t of Y(e))t.remove()};function Q(e,t,l){let n=/^wcs-\[(?::(\d+))?/.exec(e.data),r=e.previousSibling,o=e.parentNode,i=[],s=e.nextSibling;for(e.remove();null!==s&&!w(s,"wcs-]");){let e=s.nextSibling;if(w(s,"wcs-|"))i.push([]),s.remove();else{0===i.length&&i.push([]);let l=i[i.length-1];S(s,"wcs-[")?e=Q(s,t,l):(l.push(s),G(s)&&Z(s,t))}s=e}let c={branch:void 0===n[1]?null:Number(n[1]),f:i,z:s??o.appendChild(N("wcs-]"))},u=Y(c);s=c.z.nextSibling;for(let e of u)l?.push(e),t&&a.add(e);return t&&null!==r?B.set(r,c):F(c),s}function Z(e,t){for(let l=e.firstChild;null!==l;)S(l,"wcs-[")?l=Q(l,t):(G(l)&&Z(l,t),l=l.nextSibling)}function H(e,t,l){let n=e=>{for(let r of Array.from(e.childNodes))if(r.parentNode===e)if(8===r.nodeType){let e=r.data;try{if("wcs-s"===e)r.remove();else if("wcs-e"===e)r.replaceWith("");else if(e.startsWith("wcs-t:")){let t=N(`@@:${decodeURIComponent(e.slice(6))}`),l=r.nextSibling;for(;null!==l&&!w(l,"wcs-/t");){let e=l.nextSibling;l.remove(),l=e}l?.remove(),r.replaceWith(t)}else if(e.startsWith("wcs-p:")){let l=t.querySelector(`template[id="${e.slice(6)}"]`);if(null!==l){let t=r.parentNode,n="s"===e[10]?E(l,document.createElementNS(t.namespaceURI,"template"),...document.importNode(l.content.firstChild,!0).childNodes):document.importNode(l,!0);n.removeAttribute("id"),t.replaceChild(n,r)}}}catch{}}else 1===r.nodeType&&!P(r)&&(V(r)?L.set(r,{ssr:t,Te:l}):n(r))};n(e),function(e){for(let t of Array.from(e.querySelectorAll("table > tbody"))){let e=[];for(let l=t.previousSibling;null!==l&&(8===l.nodeType||re(l)||"template"===l.localName);l=l.previousSibling)e.unshift(l);let l=0,n=0;if(e.forEach((e,t)=>{S(e,"wcs-[")?n++:w(e,"wcs-]")&&--n<0&&(n=0,l=t+1)}),0===n)continue;let r=0;for(let n=t.firstChild;null!==n;n=n.nextSibling)if(S(n,"wcs-["))r++;else if(w(n,"wcs-]")&&0===r--){t.prepend(...e.slice(l));break}}}(e),Z(e,l)}function K(e,t){let l=L.get(e);if(void 0===l)return null;L.delete(e);let n=e=>H(e,l.ssr,l.Te);if(l.Te||te(t,e,e,n),n(e),!l.Te)return null;let r=d.Te;return d.Te=se,()=>{d.Te=r,X()}}function X(){for(let e of B.values())F(e);B.clear()}function _(e){let t=[];for(let l=document.createTreeWalker(e,128);l.nextNode();)t.push(l.currentNode);return t}function ee(e,t,l,n){let r=null;for(let n of e){let e=n[l];null!==e&&(""===e||t===e||t.startsWith(`${e}.`))&&(null===r||e.length>r[l].length)&&(r=n)}let o=r?.[n];if(null==o)return null;let i=r[l],s=""===i?t:t.slice(i.length+1);return""===o?s:""===s?o:`${o}.${s}`}function te(e,t,l,n){let r=document.createElement("template").content;for(let e of l.childNodes)r.appendChild(r.ownerDocument.importNode(e,!0));n(r),e.root=t;let o=()=>{};c(e,[...r.childNodes],null,!0,o,o,o,(t,l)=>s(e,l,null,0))}function le(e,t,l){if(y()){if(l instanceof Array){for(let e=l.length;e-- >0;)o(l[e])&&l.splice(e,1);let e=t;if(l.some(i))T.add(e);else if(e.localName.includes("-")&&!V(e)){let t=new Map;for(let l=document.createTreeWalker(e,133);l.nextNode();)t.set(l.currentNode,l.currentNode.data);k.set(e,t)}return}if("string"==typeof l){if($.set(t,l),P(t.parentNode))return;let e=N(`wcs-t:${encodeURIComponent(l)}`),n=N("wcs-/t");return t.before(e),void t.after(n)}let n=A.get(e);void 0===n&&A.set(e,n=new Map),n.set(t,l);let r=t.getRootNode(),s=x.get(r);return void 0===s&&x.set(r,s=new Set),void s.add(e)}if("string"!=typeof l&&B.size>0){let e=B.get(l);void 0!==e&&(B.delete(l),B.set(t,e))}}var ne=e=>null!==e&&8===e.nodeType&&[f.commentIfPrefix,f.commentElseIfPrefix,f.commentElsePrefix].includes(e.data),re=e=>3===e.nodeType&&""===e.data.trim(),oe=e=>{let t=B.get(e)?.z??e;return(j(t)??t).nextSibling};function ie(e,t){if(t.length!==e.ln.childNodes.length)return!1;let l=e.Cn;for(let n=0;n<l.length;n++){let r=l[n],o=e.ln,i=t[r[0]];for(let e=0;;){if(o=o.childNodes[r[e]],i?.nodeName!==o.nodeName)return!1;if(++e===r.length)break;i=(j(i)??i).firstChild;for(let t=r[e];t>0&&null!==i;t--)i=oe(i)}e.So[n]=i}return!0}function se(e,t,l){if(0===B.size)return null;let n=t,r=0;if(!l){let e=f.commentIfPrefix;if(!w(t,e))for(let l=t.previousSibling;null!==l&&1!==l.nodeType&&(ne(l)&&r++,!w(l,e));l=l.previousSibling);for(let l=t.nextSibling;!B.has(n)&&null!==l&&!w(l,e)&&1!==l.nodeType;l=l.nextSibling)ne(l)&&(n=l)}let o=B.get(n);if(void 0===o)return null;if(!l&&o.branch!==r)return B.delete(n),F(o),null;let i=o.f.shift();if(0===o.f.length&&B.delete(n),o.z?.replaceWith(...C(t,n)),o.z=null,void 0===i)return null;let s=[];for(let e=0;e<i.length;e++){let t=B.get(i[e]);if(s.push(i[e]),void 0!==t)for(;e<i.length&&i[e]!==t.z;)e++;else j(i[e])===i[e+1]&&e++}if(!ie(e,s)){let l=(e.Dn?e.root:e.ln).cloneNode(!0);s=e.Dn?[l]:[...l.childNodes],ie(e,s),(i[0]??o.f.find(e=>e.length>0)?.[0]??t).before(l);for(let e of i)e.remove()}return s}var ae={name:"ssr",install(){d.jn=le,d.hr=K;let t=d.element;d.element=(l,r)=>{"mounting"===r&&function(t){let l=t.element;if(!l.hasAttribute("enable-ssr")||y())return;let r=l.previousElementSibling,o=r?.localName===b(),i=o?r.getAttribute("version"):null,s=null===i||m(i)===m(e);if(s){let e=t,l=e.$e;e.$e=(e,n)=>"$connectedCallback"===e?void 0:l.call(t,e,n)}if(!o)return;let a=!s&&parseInt(i)<4,c=/^3\.(\d+)\.(\d+)$/.exec(i),u=null!==c&&(+c[1]-5||+c[2]-3)>=0;s||console.warn(`[@wcstack/state] <${b()} version="${i}"> does not match ${e}: its snapshot is discarded, and the page renders on the client from its own state.${a&&!u?" 3.x output keeps only the path of a text binding outside a template, so such a binding loses its filters: deploy @wcstack/server 4.0 with this client.":""}`);let p=s?r.querySelector('script[type="application/json"]'):null;if(null!==p){let e=JSON.parse(p.textContent||"{}"),l=t.target;for(let t of Object.keys(e)){let n=Object.getOwnPropertyDescriptor(l,t);void 0!==n&&(void 0!==n.get||void 0!==n.set||"function"==typeof n.value)||(l[t]=e[t])}t.hydrated=!0}let h=l.getRootNode();for(let e of Array.from(h.querySelectorAll(`[${O}]`)))e.textContent=e.getAttribute(O),e.removeAttribute(O);let g=9===h.nodeType?h.body:h;r.remove();let v=e=>a?function(e,t,l){let r=new Map,o=e=>{let t=e.parentElement;for(;null!==t&&!V(t);)t=t.parentElement;if(null===t)return null;let l=r.get(t);if(void 0===l){let e=o(t),i=t.querySelector(`:scope > ${f.tagNames.state}[bind-component]`).getAttribute("bind-component");r.set(t,l=[]);for(let r of n(t.getAttribute(f.bindAttributeName)??"")){let t=r.Ze;r.Ne[0]===i&&l.push([e?ee(e,t,1,0):t,r.Ne.slice(1).join("."),e&&t])}}return l},i=(e,t,l)=>{let n=o(e);if(null===n)return t;let r=/^([^|]*)#m\d+\.([^|]*)$/.exec(t);if(null===r)return l?t:ee(n,t,0,1)??t;let i=r[1].replace(/#m\d+\./g,"").slice(0,-1);return n.some(e=>""===e[1]&&(e[0]===i||e[2]===i))?r[2]:ee(n,r[2],2,1)??r[2]};for(let t of _(e).reverse()){let e=/^@@wcs-(\w+)-start:([\s\S]*)/.exec(t.data);if(null===e)continue;let n=t.nextSibling;for(;null!==n&&!w(n,`@@wcs-${e[1]}-end:${e[2]}`);)n=n.nextSibling;if(null!==n){for(;t.nextSibling!==n;)t.nextSibling.remove();n.remove(),t.replaceWith(..."text"===e[1]?[N(`@@:${i(t,e[2],l)}`)]:[])}}let s=(e,l)=>{for(let n of _(e)){let e=/^@@wcs-(?:for|if|elseif|else):(\S+)$/.exec(n.data)?.[1],r=Array.from(t.querySelectorAll("template")).find(t=>t.id===e);if(void 0===r)continue;let o=document.importNode(r,!0),a=f.bindAttributeName;o.removeAttribute("id"),o.setAttribute(a,o.getAttribute(a).replace(/^(\s*\w+\s*:\s*)([^\s|]+)/,(e,t,r)=>t+i(l??n,r))),s(o.content,l??n);let c=o.content.firstChild;n.replaceWith(.../^\s*elseif\s*:/.test(c?.getAttribute?.(a)??"")?o.content.childNodes:[o])}};s(e);for(let t of Array.from(e.querySelectorAll("[data-wcs-ssr-id]")))t.removeAttribute("data-wcs-ssr-id")}(e,r,u):H(e,r,s);s||te(t,h,g,v),queueMicrotask(function(e){let t=[];for(let l of Array.from(e.querySelectorAll("input,textarea,select")))if("select"===l.localName){let e=Array.from(l.options),n=e.map(e=>e.selected),r=e.map(e=>e.hasAttribute("selected")),o=r.lastIndexOf(!0);o<0&&(o=e.findIndex(e=>!e.disabled)),(l.multiple?e.some((e,t)=>n[t]!==r[t]):l.selectedIndex!==o)&&t.push([l,()=>e.forEach((e,t)=>e.selected=n[t])])}else if("checkbox"===l.type||"radio"===l.type){let e=l.checked;e!==l.defaultChecked&&(e||"checkbox"===l.type)&&t.push([l,()=>l.checked=e])}else if("file"!==l.type&&l.value!==l.defaultValue){let e=l.value;t.push([l,()=>l.value=e])}return()=>{for(let[e,l]of t)e.isConnected&&(l(),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})))}}(g)),v(g),s&&(d.Te=se,queueMicrotask(()=>{X(),d.Te=null}))}(l),t?.(l,r)},function(){let e=globalThis;e[J]={build:U,reset(){D=0}},void 0===e[v]&&(e[v]={protocol:"wcs-ssr-snapshot",version:1,build:t=>e[J].build(t),reset:()=>e[J].reset()})}(),d.Ao=p(d.Ao,g);for(let e of l())g(e)}},ce=ae;export{ce as default,ae as ssr};
2
2
  //# sourceMappingURL=ssr.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wcstack/state",
3
- "version": "4.6.1",
3
+ "version": "4.6.2",
4
4
  "description": "Reactive state management with declarative data binding for Web Components. Zero dependencies, buildless.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.esm.js",
@@ -1,2 +0,0 @@
1
- var a="4.6.1";export{a};
2
- //# sourceMappingURL=chunk-RIZH2AQE.js.map