@wcstack/state 4.6.2 → 4.8.0
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/README.ja.md +40 -13
- package/README.md +42 -13
- package/dist/auto.min.js +1 -1
- package/dist/auto.min.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/manifest.esm.js +5 -5
- package/dist/split/auto.js +1 -1
- package/dist/split/chunks/chunk-BCL75PFH.js +2 -0
- package/dist/split/chunks/chunk-BCL75PFH.js.map +1 -0
- package/dist/split/chunks/{chunk-JWRQLKOQ.js → chunk-DRSAQE4E.js} +2 -2
- package/dist/split/chunks/{chunk-GBBBRPZR.js → chunk-GQTEYSRZ.js} +2 -2
- package/dist/split/chunks/{chunk-FBBHQU7S.js → chunk-IBGHHABS.js} +2 -2
- package/dist/split/chunks/chunk-M3BJN6SQ.js +2 -0
- package/dist/split/chunks/{chunk-AAEFSJ6G.js.map → chunk-M3BJN6SQ.js.map} +1 -1
- package/dist/split/chunks/{chunk-T3FN37DU.js → chunk-P3EXTBXC.js} +2 -2
- package/dist/split/chunks/{chunk-CBMAVRYG.js → chunk-PKEAYPFR.js} +2 -2
- package/dist/split/chunks/chunk-QMOIMPIJ.js +2 -0
- package/dist/split/chunks/chunk-QMOIMPIJ.js.map +1 -0
- package/dist/split/chunks/chunk-T3KW5DZD.js +2 -0
- package/dist/split/chunks/chunk-T3KW5DZD.js.map +1 -0
- package/dist/split/chunks/chunk-XXVJ6J2N.js +2 -0
- package/dist/split/chunks/chunk-XXVJ6J2N.js.map +1 -0
- package/dist/split/core.d.ts +2 -0
- package/dist/split/core.js +1 -1
- package/dist/split/features/devtools.d.ts +2 -0
- package/dist/split/features/devtools.js +1 -1
- package/dist/split/features/devtools.js.map +1 -1
- package/dist/split/features/diagnostics.d.ts +2 -0
- package/dist/split/features/diagnostics.js +1 -1
- package/dist/split/features/diagnostics.js.map +1 -1
- package/dist/split/features/formats.d.ts +2 -0
- package/dist/split/features/formats.js +1 -1
- package/dist/split/features/formats.js.map +1 -1
- package/dist/split/features/list-keys.d.ts +2 -0
- package/dist/split/features/list-keys.js +1 -1
- package/dist/split/features/list-keys.js.map +1 -1
- package/dist/split/features/native-commands.d.ts +2 -0
- package/dist/split/features/native-commands.js +1 -1
- package/dist/split/features/native-commands.js.map +1 -1
- package/dist/split/features/recursion.d.ts +2 -0
- package/dist/split/features/recursion.js +1 -1
- package/dist/split/features/recursion.js.map +1 -1
- package/dist/split/features/scopes.d.ts +2 -0
- package/dist/split/features/scopes.js +1 -1
- package/dist/split/features/scopes.js.map +1 -1
- package/dist/split/features/ssr.d.ts +2 -0
- package/dist/split/features/ssr.js +1 -1
- package/dist/split/features/ssr.js.map +1 -1
- package/dist/split/features/temporal.d.ts +2 -0
- package/dist/split/features/temporal.js +1 -1
- package/dist/split/features/temporal.js.map +1 -1
- package/package.json +1 -1
- package/dist/split/chunks/chunk-467LYA2V.js +0 -2
- package/dist/split/chunks/chunk-467LYA2V.js.map +0 -1
- package/dist/split/chunks/chunk-AAEFSJ6G.js +0 -2
- package/dist/split/chunks/chunk-TNYNJXEC.js +0 -2
- package/dist/split/chunks/chunk-TNYNJXEC.js.map +0 -1
- package/dist/split/chunks/chunk-ULMHOGJ2.js +0 -2
- package/dist/split/chunks/chunk-ULMHOGJ2.js.map +0 -1
- package/dist/split/chunks/chunk-ZJYPRSTO.js +0 -2
- package/dist/split/chunks/chunk-ZJYPRSTO.js.map +0 -1
- /package/dist/split/chunks/{chunk-JWRQLKOQ.js.map → chunk-DRSAQE4E.js.map} +0 -0
- /package/dist/split/chunks/{chunk-GBBBRPZR.js.map → chunk-GQTEYSRZ.js.map} +0 -0
- /package/dist/split/chunks/{chunk-FBBHQU7S.js.map → chunk-IBGHHABS.js.map} +0 -0
- /package/dist/split/chunks/{chunk-T3FN37DU.js.map → chunk-P3EXTBXC.js.map} +0 -0
- /package/dist/split/chunks/{chunk-CBMAVRYG.js.map → chunk-PKEAYPFR.js.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as e,c as t,h as n,j as a}from"../chunks/chunk-ZJYPRSTO.js";import{a as i,d as s,f as r}from"../chunks/chunk-T3FN37DU.js";import{e as o}from"../chunks/chunk-NITPUCPA.js";import"../chunks/chunk-CBMAVRYG.js";import{b as l}from"../chunks/chunk-JWRQLKOQ.js";import{a as d,b as c,c as u,e as f,j as h}from"../chunks/chunk-TNYNJXEC.js";function p(e,t,n){if(Math.abs(e.length-t.length)>n)return n+1;let a=new Array(t.length+1),i=new Array(t.length+1);for(let e=0;e<=t.length;e++)a[e]=e;for(let n=1;n<=e.length;n++){i[0]=n;for(let s=1;s<=t.length;s++){let r=e[n-1]===t[s-1]?0:1;i[s]=Math.min(a[s]+1,i[s-1]+1,a[s-1]+r)}for(let e=0;e<=t.length;e++)a[e]=i[e]}return a[t.length]}function $(e,t){if(0===e.length)return"";let n=e.toLowerCase(),a=null,i=3;for(let e of t){let t=p(n,e.toLowerCase(),2);t<i&&(a=e,i=t)}return null!==a?` Did you mean "${a}"?`:""}var m=" Validate statically: npx @wcstack/lint <file>.",g=["","binding-syntax","template-syntax","binding-path-missing","binding-type-expectation","filter-unknown","filter-arity","getter-cycle","getter-depth-exceeded","index-arity","index-param-range","recursion-unsupported","token-misconfigured","token-undeclared","wildcard-rank","spread-no-bindable","declaration-alias","name-alias"],w=e=>{let t=g[e/100|0];return t?`[wcs/${t}] `:""},b=["enableMustache","sameValueGuard","enableDirectionalInitialSync"],y=e=>null==e?String(e):e instanceof Date?"a Date":Array.isArray(e)?"an array":"string"==typeof e?`a string (${JSON.stringify(e.length>32?e.slice(0,32)+"…":e)})`:"object"==typeof e?"an object":`a ${typeof e} (${String(e)})`,v=["","","class.","attr.","style."],k=(e,t)=>`<${e}${t.map((e,t)=>t%2?`="${e}"`:` ${e}`).join("")}>`,x="https://github.com/wcstack/wcstack/blob/main/docs/csp.md",T={1:()=>"$scan was removed (use $watch or $on)",2:e=>`"${e}" is a getter without a setter`,3:e=>`no row for "${e}"`,4:(e,t)=>`cannot write "${e}": its parent is ${t}`,5:e=>`"${e}" is not a method`,6:e=>`$getAll("${e}"): no loop level in common with the context`,7:e=>`$eqIndex("${e}") needs a list row scope.`,8:()=>"This state is readonly.",9:e=>`$setAll("${e}") needs indexes ([] for every match)`,10:(e,t)=>`$setAll("${e}", …, { spread: true }) needs an array of ${t} values`,11:()=>`updates did not settle after ${e} passes`,41:()=>`render chain depth limit exceeded (${t} drains that rendering itself started); bindings for this batch were not applied.`,12:(e,t,n,a)=>`binding "${n?(v[a]??"")+n:e}: ${t}" failed to apply.`,13:(e,t)=>`failed to load "${e}": ${t}`,14:()=>"this <wcs-state> failed to initialize; create a new one",15:()=>"state is not initialized",16:e=>`no <script> with id "${e}"`,42:()=>`The inline <script> of <wcs-state> was blocked by Content-Security-Policy. Inline state is evaluated through a blob: URL: give the page's nonce to the <script> that loads @wcstack/state, or allow blob: in script-src. Moving the state into an external file (src="./state.js") needs neither. See ${x}`,43:e=>`Failed to evaluate the inline <script> of <wcs-state>: ${e}. If this page sets a Content-Security-Policy, see ${x}`,17:e=>`a subscriber of token "${e}" threw.`,18:e=>`${e} must be an array of strings.`,19:e=>`${e} entries must be non-empty strings.`,20:(e,t,n)=>`${e} entry "${t}" conflicts with the reserved namespace name "${n}".`,21:(e,t)=>`${e} entry "${t}" is duplicated.`,22:()=>"$on must be an object of handlers.",23:e=>`$on entry "${e}" is not declared in $eventTokens.`,24:e=>`$on entry "${e}" must be a function.`,25:e=>`view-transition naming-limit (${e}) reached.`,26:e=>`filter ${e} requires at least one option`,27:e=>`filter ${e} requires a number as option`,28:(e,t)=>`filter ${e} requires a number value, not ${y(t)}${"string"==typeof t?` — put |number before |${e}, or convert it where it is read`:""}`,29:(e,t)=>`filter ${e} requires a date value (a Date), not ${y(t)}${"string"==typeof t||"number"==typeof t?" — make the Date where it is read: a getter returning new Date(…)":""}`,52:(e,t)=>`filter ${e} takes a style of full, long, medium or short, not "${t}"`,53:e=>`filter currency takes an ISO 4217 currency code (JPY, USD, EUR), not "${e}"`,30:e=>`filter ${e} requires an array value`,31:()=>"init=/sync= modifiers require enableDirectionalInitialSync.",33:(e,t)=>`Unknown binding modifier "${e}" in "${t}".`,34:e=>`Binding modifier "${e}" may only be specified once.`,35:(e,t)=>`Invalid ${e} modifier value "${t}".`,36:()=>"Event bindings only allow init=none.",37:(e,t)=>`Binding type "${e}" does not support init=${t}.`,38:e=>`Property "${e}" is not declared by wcBindable.`,39:(e,t)=>`init=${e} is incompatible with wcBindable member "${t}".`,40:e=>`sync=connect requires observable property "${e}".`,44:(e,t)=>`${e}: "${t}" is not one of its options, or not of the option's type.${"bootstrapState"===e&&b.includes(t)?" 4.0 moved it to the state's $behavior.":""}`,45:()=>"a re-set state may not change $behavior: create the element again.",47:()=>'a second <wcs-state> on the same root: there is one state tree per root — graft a subtree with <wcs-state mount="path"> (v1\'s name="…" is gone: read the mounted state by its path).',48:e=>`the locale "${e}" (<html lang> or bootstrapState's locale) is not a language tag Intl takes (en-US, not en_US): the locale filters use "en".`,46:()=>'$features must be an array of add-on names (["temporal", "formats"]).',49:(e,...t)=>`${k(e,t)} failed to initialize.`,50:(e,...t)=>`${k(e,t)} $connectedCallback failed.`,51:(e,...t)=>`${k(e,t)} $disconnectedCallback failed.`,101:e=>`Invalid bindText: "${e}". Missing ':' separator between propPart and statePart.`,102:(e,t)=>`"${e}": "${t}" takes no modifiers or filters on its left side — write "${t}:".`,103:e=>`"${e}": "else" takes no value — write "else:".`,104:e=>`Invalid spread binding "${e}": spread target path is required.`,105:e=>`Invalid spread binding "${e}": filters are not allowed on spread targets.`,106:e=>`"${e}": a leading "." binds an element property by name — write a non-empty property that is not a namespace (class, attr, style, command, eventToken, state).`,107:(e,t)=>`unterminated ${e} quote in the filter arguments "(${t})". Close the quote.`,108:e=>`Invalid filter format: missing closing parenthesis in "${e}".`,109:e=>`Invalid filter format: missing opening parenthesis in "${e}".`,110:e=>`Invalid filter format: ")" comes before "(" in "${e}".`,111:(e,t)=>`"${e}": unexpected "${t}" after the filter's closing ")" — separate filters with "|" (write "${e.slice(0,e.lastIndexOf(")")+1)}|${t}").`,112:e=>`an empty filter in "${e}" — remove the extra "|" or name the filter.`,113:(e,t)=>`"${e}" is not a filter name: a modifier list "#${t}" comes before the input filters, not inside one`,114:e=>`"${e}" is not a filter name: "#" cannot appear in one.`,115:e=>`"${e}": a binding takes one modifier list after a single "#"`,116:e=>`"${e}": the left side of a binding must name a property — write "<property>: <path>" (modifiers and input filters come after the name).`,117:(e,t)=>`"${e}" has ${t} path segments — the limit is 512.`,32:e=>`"${e}": the "@name" selector was removed in v2 — there is a single state tree. Mount the named state onto the tree (<wcs-state mount="...">) and read it by its path prefix instead.`,120:e=>`"${e}": a state path cannot go through "__proto__" or "prototype" (it would reach every object's prototype).`,121:e=>`"${e}": "for:" takes no filters — a row is "<path>.<index>", so the rows of a filtered list would name other elements. Declare a getter that returns the filtered list and loop over it ("for: <getter>").`,122:(e,t)=>"class"===t?`"${e}": "class:" needs a class name — "class.NAME:" toggles one class (a bare "class:" would set an element property named "class", which does nothing). To set the whole class attribute, bind "className:".`:`"${e}": "attr:" needs an attribute name — "attr.NAME:" sets one attribute (a bare "attr:" would set an element property named "attr", which does nothing).`,119:e=>`"${e}": the right side of a binding must name a state path — write "<property>: <path>" (a path segment cannot be empty; "." alone and a leading "." are the loop-relative shorthand).`,201:e=>`Invalid bindText: "${e}". 'if', 'elseif', 'else', and 'for' bindings must be single binding.`,202:e=>`"${e}:" must follow an "if:" template`,204:e=>`a "${e}:" template at the top of inserted content was not rendered, as it would render beside itself out of the inserter's reach: wrap it in an element.`,203:e=>`"${e}:" replaces its element, so it cannot be used inside a "for" / "if" template (a row or branch keeps its nodes by position): bind innerHTML: on a wrapper element instead.`,301:e=>`Path "${e}" does not exist on the state tree.`,401:(e,t)=>`class.${e} needs a boolean, got ${t}.`,501:e=>`filter not found: ${e}.`,601:(e,t,n)=>`filter "${e}" requires at least ${t} argument(s) (${n} given).`,602:(e,t,n)=>`filter "${e}" accepts at most ${t} argument(s) (${n} given).`,701:e=>`"${e}" depends on itself`,801:e=>`"${e}"`,901:(e,t,n,a)=>`${e}("${t}") takes ${n} index(es), got ${a}.`,902:(e,t,n,a)=>`${e}("${t}") takes at most ${n} index(es), got ${a}.`,1001:e=>`"${e}": list index parameters run from $1 to $128.`,1101:e=>`"${e}" uses "**", which is not accepted here.`,1201:(e,t)=>`"${e}: ${t}": the right-hand side must be $command.<name>`,1202:(e,t)=>`<${e}> declares no static wcBindable (${t}).${!e.includes("-")&&t.startsWith("command.")?" A native element's command needs the add-on @wcstack/state/features/native-commands.":""}`,1203:(e,t)=>`<${e}> declares no command "${t}".`,1204:(e,t)=>`<${e}> declares no property "${t}".`,1205:(e,t,n)=>`<${e}> has no command "${t}" (a native <${e}>'s commands: ${n}).`,1301:e=>`eventToken "${e}" is not declared in $eventTokens.`,1302:e=>`"$command.${e}" is not declared in $commandTokens.`,1401:(e,t,n=0)=>`"${e}" needs ${t} enclosing loop level(s); the scope provides ${n}.`,1402:e=>`"${e}" is relative: it needs an enclosing "for" template`,1403:(e,t,n)=>`"${e}" ranges over the rows of "${t}", but the enclosing "for" template at that level renders "${n}".`,1501:(e,t)=>`<${e}> declares no static wcBindable (${t}).`,1601:(e,t)=>`${e} was removed: write ${t}.`,1701:(e,t)=>`${e} was removed: write ${t}.`};function j(e,t){let n=T[e];return void 0===n?`${w(e)}#${e} ${t.join(" ")}`:w(e)+n(...t)}var O=new Set(["binding-syntax","template-syntax","filter-unknown","filter-arity","index-arity","wildcard-rank","token-undeclared","binding-path-missing","index-param-range"]),S=[[/no loop level in common with the context/,"; pass indexes ([] for all)."],[/"([^"#]+)#([^"]*)" is not a filter name: a modifier list .* comes before the input filters/,' — write "<property>#$2|$1".'],[/\[wcs\/recursion-unsupported\]/," It is only meaningful in a $recursion declaration, in a recursive getter key, and in the path argument of $getAll / $setAll — and only when the state declares a $recursion anchor."],[/must be single binding/,' Put the structural binding alone in its own data-wcs (e.g. <template data-wcs="for: items">).'],[/\[wcs\/wildcard-rank\] .* needs \d+ enclosing/,' Wrap it in that many "for" templates, or use $resolve(path, indexes) to name the row explicitly.'],[/\[wcs\/wildcard-rank\] .* ranges over the rows of/,' A "*" in a binding is the row of the loop around it: read a row of another list in a getter, with $resolve(path, indexes).'],[/\[wcs\/binding-type-expectation\] class\.([^ ]+)/,' Write "class.$1: path|truthy" to toggle on truthiness.'],[/path segments — the limit/," Every prefix of a path is interned, so the cost grows with the square of the depth."],[/\[wcs\/index-arity\] \$resolve/,' $resolve takes one index per "*"; $getAll / $setAll take at most that many (fewer expands the rest).'],[/"([^"#]+)#[^"]*" is not a filter name: "#" cannot appear in one/,' Modifiers belong on the left side of the binding, before the ":" — write "$1" here.']],M={inc:"add",dec:"sub",fix:"toFixed",uc:"upper",lc:"lower",cap:"capitalize",rep:"repeat",rev:"reverse",pad:"padStart",null:"nullIfEmpty"};function A(e,t,n){let a=(void 0!==t&&e.includes("[wcs/filter-unknown]")?function(e){if("substr"===e)return' "substr" was removed in 4.0 — write slice(start, start + length): slice takes the end index, not a length.';let t=Object.hasOwn(M,e)?M[e]:null;return null===t?null:` "${e}" was renamed "${t}" in 3.2 and removed in 4.0 — write "${t}".`}(t):null)??(void 0!==t&&void 0!==n?$(t,n):"");for(let[t,n]of S){let i=t.exec(e);null!==i&&(a+=n.replace(/\$(\d)/g,(e,t)=>i[Number(t)]))}let i=/"([^"#]+)#([^"]+)": a binding takes one modifier list/.exec(e);null!==i&&(a+=` — write "${i[1]}#${i[2].split("#").join(",")}".`),e.includes("[wcs/filter-unknown]")&&(e.includes("formats add-on")?a+=' On a split auto page: features="formats" on the root, or "$features": ["formats"].':s.some(r)||(a+=' No formatting filters are installed — add the formats add-on: installFeatures([formats]) from "@wcstack/state/features/formats" (a split auto page: features="formats", or "$features").'));let o=/\[wcs\/([\w-]+)\]/.exec(e);return null!==o&&O.has(o[1])&&!/ path segments — the limit is |inserted content was not rendered|formats add-on/.test(e)&&(a+=m),a}var P=new WeakMap,W=new WeakMap,I=new WeakSet,D=new WeakSet;function N(e,t){for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n)){let e=Object.getOwnPropertyDescriptor(n,t);if(void 0!==e)return e}}function q(e){let t=new Set;for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n))for(let e of Object.getOwnPropertyNames(n))"$"!==e[0]&&"constructor"!==e&&t.add(e);return[...t]}function C(e,t){let n=[];for(let e=t;null!==e;e=e.c)n.unshift(e);let a=t=>null===t?null:function(e,t){let n=t.t.split("."),a=n.findIndex((e,t)=>t>0&&/^\d/.test(e));return a<0||n.indexOf("*",a)>=0||void 0!==N(e.target,t.t)?.get?t:e.O.wt(o(t.t).o)}(e,t);return n.some(e=>null!=a(e)?.getter)?null:U(e,n,0,e.target,a)}function U(e,t,n,a,i){for(;n<t.length;n++){let s=t[n];if(null===a||"object"!=typeof a)return null;if("*"===s.s){if(!Array.isArray(a)||0===a.length)return null;let s=null;for(let r of a){let a=U(e,t,n+1,r,i);if(null===a)return null;if(null===s)s=a;else if(a.seg===s.seg)for(let e of a.names)s.names.includes(e)||s.names.push(e)}return s}if(Array.isArray(a)&&/^\d+$/.test(s.s)){if(Number(s.s)>=a.length)return null;a=a[Number(s.s)];continue}let r=N(a,s.s);if(void 0===r&&null===s.c&&e.tt.has(s.s))return null;if(void 0===r){let r=q(a),o=i(s.c);for(let t of e.O.all())t.c===o&&null!==t.getter&&r.push(t.s);return{seg:s.s,names:r,r:t.slice(0,n).some(e=>"*"===e.s)}}if(void 0!==r.get||void 0!==r.set)return null;a=r.value}return null}function B(e){I.has(e)||(I.add(e),setTimeout(()=>function(e){I.delete(e);let t=P.get(e);if(void 0===t)return;let n=W.get(e);void 0===n&&W.set(e,n=new Set);let a=new Map(t),s=new Map;for(let i of e.O.all()){let e=null===i.c||n.has(i)||t.has(i)?void 0:i.B.find(e=>!e.hn);void 0!==e&&(s.set(i,e),a.set(i,3))}for(let[t,r]of a){if(n.has(t))continue;n.add(t);let a=C(e,t);if(null===a)continue;let l=[...e.root?.querySelectorAll(`${i.tagNames.state}[mount]`)??[]].find(e=>!D.has(e)&&(t.t+".").startsWith(e.getAttribute("mount")+"."));if(void 0!==l){n.delete(t),l.initializePromise.then(()=>{D.add(l),B(e)});continue}let c=e.O.wt(o(t.t).o),u="";if(void 0!==c&&c!==t&&null!==c.getter){let e=c.h.slice(1).map((e,t)=>`for: ${0===t?e.t:e.t.slice(c.h[t].t.length+2)}`);u=` The getter "${c.t}" is declared for the rows of ${e.join(" → ")}; a list named by an index has rows of its own.`}let f=$(a.seg,a.names);if((a.r||3===r)&&""===f&&""===u)continue;let[h,p,g]=1===r?["watch-path-missing","$watch path","watch"]:2===r?["post-update-path-missing","$postUpdate path","postUpdate"]:3===r?["read-path-missing","Path","getter"]:["binding-path-missing","Bound path","binding"];d.at?.(e,{type:"state:path-unresolved",source:g,path:t.t,missingSegment:a.seg}),console.warn(`[@wcstack/state] [wcs/${h}] ${p} "${t.t}"${3===r?` read by the getter "${s.get(t).t}"`:""} does not resolve on the state tree: "${a.seg}" is not declared.${f}${u} ${2===r?"The call updates nothing.":3===r?"The getter reads undefined.":"Updates to this path will be silently dropped."}${m}`)}}(e),0))}function L(e,t,n=!1){E(e,t,n?1:0)}function E(e,t,n){if("$"===t.t[0]||t.t.includes("#")||0===n&&null===t.c)return;let a=P.get(e);void 0===a&&P.set(e,a=new Map),a.has(t)||a.set(t,n),B(e)}var z=new WeakSet,H=!1,R=new WeakMap;function Y(e,t){let n=R.get(e),a=t.s;if(null!==t.c||H||void 0===n||n.has(a)||"$"===a[0]||e.tt.has(a))return;let s=$(a,[...n]);n.add(a),""!==s&&![...e.root?.querySelectorAll(`${i.tagNames.state}[mount]`)??[]].some(e=>`${e.getAttribute("mount")}.`.startsWith(`${a}.`))&&console.warn(`[@wcstack/state] [wcs/write-path-missing] "${a}" is not declared: writing it creates a new key.${s}${m}`)}var J=new WeakSet;function _(e){if(J.has(e))return;J.add(e);let t=e.emit,n=!1;e.emit=(...a)=>(0===e.size&&!n&&(n=!0,console.warn(`[@wcstack/state] [wcs/command-token-unbound] "$command.${e.name}" was emitted with no subscriber and is lost: its element is not defined or rendered yet (emit from $renderedCallback), or no command. binding takes it.${m}`)),t.apply(e,a))}var F=new WeakMap;function V(e,t,n){let a=e.target;for(let e of t.split("."))a=null==a?void 0:N(a,e)?.value;if("function"!=typeof a||!String(a).includes("currentTarget"))return;let i=F.get(e);void 0===i&&F.set(e,i=new Set),!i.has(t)&&(i.add(t),console.warn(`[@wcstack/state] [wcs/delegated-current-target] "${t}" reads event.currentTarget, the root for a delegated on${n}:. Write on${n}#direct:, or use event.target.closest(…).${m}`))}function G(e){P.has(e)&&e.He.length>0&&B(e)}var Q=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),X=!1;function K(e,t,i){let s="html"===i.name?"innerHTML":i.name;if(X||!(t instanceof TypeError)||!a(s)||!("trustedTypes"in globalThis))return;X=!0;let r="function"==typeof n()?.createHTML?"The injected policy's createHTML() did not return a TrustedHTML.":"No sanitizing policy is installed, and @wcstack/state deliberately does not pass state values through an identity policy — that would defeat the CSP.";console.error(`[@wcstack/state] Writing to "${s}" was blocked by Trusted Types (require-trusted-types-for 'script'). ${r}\nInstall a sanitizing policy before the first binding is applied:\n globalThis[Symbol.for("wcstack.trustedTypes.policy")] =\n trustedTypes.createPolicy("my-app", { createHTML: (s) => DOMPurify.sanitize(s) });\nOr bind the value as text instead of HTML. See docs/csp.md section 7.`,{element:i.a,property:s})}var Z=new WeakMap;function ee(e,t,n){let a=e[t],i=void 0===n?void 0===a?null:`the event carried no detail (undefined) while element.${t} is ${typeof a}`:null===n||"object"!=typeof n||!Object.prototype.hasOwnProperty.call(n,t)||null!==a&&"object"==typeof a?null:`the event's detail is an object with a "${t}" key while element.${t} is ${typeof a}`;if(null===i)return;let s=Z.get(e);void 0===s&&Z.set(e,s=new Set),!s.has(t)&&(s.add(t),console.warn(`[@wcstack/state] [wcs/default-getter-mismatch] <${e.localName}> "${t}": ${i}. With no getter, state receives e.detail as-is. Dispatch the value itself as detail, or declare getter (e.g. (e) => e.detail.${t}, or (e) => e.target.${t}) on that wcBindable property.`))}var te=[["$streams","$stream"],["$updatedCallback","$renderedCallback"]],ne={$trackDependency:"$dependOn",$untrackDependency:"$untracked"},ae={name:"diagnostics",install(){d.Bo=A,d.Mo=j,d.$o=L,d.detail=ee,d.Ye=c(d.Ye,K);let e=d.fe;d.fe=(t,n)=>{(function(e){void 0!==e.$scan&&l(1);for(let[t,n]of te)void 0!==e[t]&&l(1601,[t,n])})(n),e?.(t,n),function(e){let t=e.$recursion;if(null===t||"object"!=typeof t)return;let n=Object.entries(t);if(1!==n.length||"string"!=typeof n[0][1])return;let[a,i]=n[0];if(!a.endsWith(".*")||!i.endsWith(".*"))return;let s=a.slice(0,-2),r=i.slice(0,-2),o=`.${i}`,l=`${s}.**`,d=q(e),c=d.filter(e=>e.startsWith(l)).map(e=>e.slice(l.length)),u=e=>h(`[wcs/recursion-declaration-invalid] ${e}`);for(let e of c){(e===`.${r}`||e.startsWith(`.${r}.`))&&u(`"${l}${e}" names the recursion structure itself (the "${r}" lists): recursive getters compute values over the nodes.`);for(let t of c)t.length>e.length&&t.endsWith(e)&&new RegExp(`^(?:${Q(o)})+$`).test(t.slice(0,t.length-e.length))&&u(`"${l}${e}" and "${l}${t}" expand to the same concrete path at different depths (they differ by whole repetitions of "${i}"). Rename one of them.`);let t=new RegExp(`^${Q(a)}(?:${Q(o)})*${Q(e)}$`);for(let n of d)!n.includes("**")&&t.test(n)&&u(`"${n}" is already defined on the state, so the recursive getter "${l}${e}" cannot expand to it.`)}}(n),function(e){W.delete(e),P.has(e)&&B(e)}(t),function(e){if(z.has(e))return;z.add(e);let t=e.Xn,n=t.$postUpdate;t.$postUpdate=t=>{H=!0;try{n(t)}finally{H=!1}let a=e.O.wt(o(t).o);void 0!==a&&E(e,a,2)}}(t),function(e){if(void 0!==Object.getOwnPropertyDescriptor(e,"commands")?.set)return;let t=e.commands;Object.defineProperty(e,"commands",{configurable:!0,get:()=>t,set:e=>{t=e;for(let t of Object.values(e))_(t)}})}(t),R.set(t,new Set(q(n)))},d.handlerThrew=V,d.re=c(d.re,Y),d.me=c(d.me,G),d.rt=u(f,d.rt,(e,t)=>Object.hasOwn(ne,t)?l(1701,[t,ne[t]]):void 0)}},ie=ae;export{ie as default,ae as diagnostics};
|
|
1
|
+
import{b as e,c as t,h as n,j as a}from"../chunks/chunk-T3KW5DZD.js";import{a as i,d as s,f as r}from"../chunks/chunk-P3EXTBXC.js";import{e as o}from"../chunks/chunk-NITPUCPA.js";import"../chunks/chunk-PKEAYPFR.js";import{b as l}from"../chunks/chunk-DRSAQE4E.js";import{a as d,b as c,c as u,e as f,j as h}from"../chunks/chunk-BCL75PFH.js";function p(e,t,n){if(Math.abs(e.length-t.length)>n)return n+1;let a=new Array(t.length+1),i=new Array(t.length+1);for(let e=0;e<=t.length;e++)a[e]=e;for(let n=1;n<=e.length;n++){i[0]=n;for(let s=1;s<=t.length;s++){let r=e[n-1]===t[s-1]?0:1;i[s]=Math.min(a[s]+1,i[s-1]+1,a[s-1]+r)}for(let e=0;e<=t.length;e++)a[e]=i[e]}return a[t.length]}function $(e,t){if(0===e.length)return"";let n=e.toLowerCase(),a=null,i=3;for(let e of t){let t=p(n,e.toLowerCase(),2);t<i&&(a=e,i=t)}return null!==a?` Did you mean "${a}"?`:""}var m=" Validate statically: npx @wcstack/lint <file>.",g=["","binding-syntax","template-syntax","binding-path-missing","binding-type-expectation","filter-unknown","filter-arity","getter-cycle","getter-depth-exceeded","index-arity","index-param-range","recursion-unsupported","token-misconfigured","token-undeclared","wildcard-rank","spread-no-bindable","declaration-alias","name-alias"],w=e=>{let t=g[e/100|0];return t?`[wcs/${t}] `:""},b=["enableMustache","sameValueGuard","enableDirectionalInitialSync"],y=e=>null==e?String(e):e instanceof Date?"a Date":Array.isArray(e)?"an array":"string"==typeof e?`a string (${JSON.stringify(e.length>32?e.slice(0,32)+"…":e)})`:"object"==typeof e?"an object":`a ${typeof e} (${String(e)})`,v=["","","class.","attr.","style."],k=(e,t)=>`<${e}${t.map((e,t)=>t%2?`="${e}"`:` ${e}`).join("")}>`,x="https://github.com/wcstack/wcstack/blob/main/docs/csp.md",T={1:()=>"$scan was removed (use $watch or $on)",2:e=>`"${e}" is a getter without a setter`,3:e=>`no row for "${e}"`,4:(e,t)=>`cannot write "${e}": its parent is ${t}`,5:e=>`"${e}" is not a method`,6:e=>`$getAll("${e}"): no loop level in common with the context`,7:e=>`$eqIndex("${e}") needs a list row scope.`,8:()=>"This state is readonly.",9:e=>`$setAll("${e}") needs indexes ([] for every match)`,10:(e,t)=>`$setAll("${e}", …, { spread: true }) needs an array of ${t} values`,11:()=>`updates did not settle after ${e} passes`,41:()=>`render chain depth limit exceeded (${t} drains that rendering itself started); bindings for this batch were not applied.`,12:(e,t,n,a)=>`binding "${n?(v[a]??"")+n:e}: ${t}" failed to apply.`,13:(e,t)=>`failed to load "${e}": ${t}`,14:()=>"this <wcs-state> failed to initialize; create a new one",15:()=>"state is not initialized",16:e=>`no <script> with id "${e}"`,42:()=>`The inline <script> of <wcs-state> was blocked by Content-Security-Policy. Inline state is evaluated through a blob: URL: give the page's nonce to the <script> that loads @wcstack/state, or allow blob: in script-src. Moving the state into an external file (src="./state.js") needs neither. See ${x}`,43:e=>`Failed to evaluate the inline <script> of <wcs-state>: ${e}. If this page sets a Content-Security-Policy, see ${x}`,17:e=>`a subscriber of token "${e}" threw.`,18:e=>`${e} must be an array of strings.`,19:e=>`${e} entries must be non-empty strings.`,20:(e,t,n)=>`${e} entry "${t}" conflicts with the reserved namespace name "${n}".`,21:(e,t)=>`${e} entry "${t}" is duplicated.`,22:()=>"$on must be an object of handlers.",23:e=>`$on entry "${e}" is not declared in $eventTokens.`,24:e=>`$on entry "${e}" must be a function.`,25:e=>`view-transition naming-limit (${e}) reached.`,26:e=>`filter ${e} requires at least one option`,27:e=>`filter ${e} requires a number as option`,28:(e,t)=>`filter ${e} requires a number value, not ${y(t)}${"string"==typeof t?` — put |number before |${e}, or convert it where it is read`:""}`,29:(e,t)=>`filter ${e} requires a date value (a Date), not ${y(t)}${"string"==typeof t||"number"==typeof t?" — make the Date where it is read: a getter returning new Date(…)":""}`,52:(e,t)=>`filter ${e} takes a style of full, long, medium or short, not "${t}"`,53:e=>`filter currency takes an ISO 4217 currency code (JPY, USD, EUR), not "${e}"`,30:e=>`filter ${e} requires an array value`,31:()=>"init=/sync= modifiers require enableDirectionalInitialSync.",33:(e,t)=>`Unknown binding modifier "${e}" in "${t}".`,34:e=>`Binding modifier "${e}" may only be specified once.`,35:(e,t)=>`Invalid ${e} modifier value "${t}".`,36:()=>"Event bindings only allow init=none.",37:(e,t)=>`Binding type "${e}" does not support init=${t}.`,38:e=>`Property "${e}" is not declared by wcBindable.`,39:(e,t)=>`init=${e} is incompatible with wcBindable member "${t}".`,40:e=>`sync=connect requires observable property "${e}".`,44:(e,t)=>`${e}: "${t}" is not one of its options, or not of the option's type.${"bootstrapState"===e&&b.includes(t)?" 4.0 moved it to the state's $behavior.":""}`,45:()=>"a re-set state may not change $behavior: create the element again.",47:()=>'a second <wcs-state> on the same root: there is one state tree per root — graft a subtree with <wcs-state mount="path"> (v1\'s name="…" is gone: read the mounted state by its path).',48:e=>`the locale "${e}" (<html lang> or bootstrapState's locale) is not a language tag Intl takes (en-US, not en_US): the locale filters use "en".`,46:()=>'$features must be an array of add-on names (["temporal", "formats"]).',49:(e,...t)=>`${k(e,t)} failed to initialize.`,50:(e,...t)=>`${k(e,t)} $connectedCallback failed.`,51:(e,...t)=>`${k(e,t)} $disconnectedCallback failed.`,101:e=>`Invalid bindText: "${e}". Missing ':' separator between propPart and statePart.`,102:(e,t)=>`"${e}": "${t}" takes no modifiers or filters on its left side — write "${t}:".`,103:e=>`"${e}": "else" takes no value — write "else:".`,104:e=>`Invalid spread binding "${e}": spread target path is required.`,105:e=>`Invalid spread binding "${e}": filters are not allowed on spread targets.`,106:e=>`"${e}": a leading "." binds an element property by name — write a non-empty property that is not a namespace (class, attr, style, command, eventToken, state).`,107:(e,t)=>`unterminated ${e} quote in the filter arguments "(${t})". Close the quote.`,108:e=>`Invalid filter format: missing closing parenthesis in "${e}".`,109:e=>`Invalid filter format: missing opening parenthesis in "${e}".`,110:e=>`Invalid filter format: ")" comes before "(" in "${e}".`,111:(e,t)=>`"${e}": unexpected "${t}" after the filter's closing ")" — separate filters with "|" (write "${e.slice(0,e.lastIndexOf(")")+1)}|${t}").`,112:e=>`an empty filter in "${e}" — remove the extra "|" or name the filter.`,113:(e,t)=>`"${e}" is not a filter name: a modifier list "#${t}" comes before the input filters, not inside one`,114:e=>`"${e}" is not a filter name: "#" cannot appear in one.`,115:e=>`"${e}": a binding takes one modifier list after a single "#"`,116:e=>`"${e}": the left side of a binding must name a property — write "<property>: <path>" (modifiers and input filters come after the name).`,117:(e,t)=>`"${e}" has ${t} path segments — the limit is 512.`,32:e=>`"${e}": the "@name" selector was removed in v2 — there is a single state tree. Mount the named state onto the tree (<wcs-state mount="...">) and read it by its path prefix instead.`,120:e=>`"${e}": a state path cannot go through "__proto__" or "prototype" (it would reach every object's prototype).`,121:e=>`"${e}": "for:" takes no filters — a row is "<path>.<index>", so the rows of a filtered list would name other elements. Declare a getter that returns the filtered list and loop over it ("for: <getter>").`,122:(e,t)=>"class"===t?`"${e}": "class:" needs a class name — "class.NAME:" toggles one class (a bare "class:" would set an element property named "class", which does nothing). To set the whole class attribute, bind "className:".`:`"${e}": "attr:" needs an attribute name — "attr.NAME:" sets one attribute (a bare "attr:" would set an element property named "attr", which does nothing).`,119:e=>`"${e}": the right side of a binding must name a state path — write "<property>: <path>" (a path segment cannot be empty; "." alone and a leading "." are the loop-relative shorthand).`,201:e=>`Invalid bindText: "${e}". 'if', 'elseif', 'else', and 'for' bindings must be single binding.`,202:e=>`"${e}:" must follow an "if:" template`,204:e=>`a "${e}:" template at the top of inserted content was not rendered, as it would render beside itself out of the inserter's reach: wrap it in an element.`,203:e=>`"${e}:" replaces its element, so it cannot be used inside a "for" / "if" template (a row or branch keeps its nodes by position): bind innerHTML: on a wrapper element instead.`,301:e=>`Path "${e}" does not exist on the state tree.`,401:(e,t)=>`class.${e} needs a boolean, got ${t}.`,501:e=>`filter not found: ${e}.`,601:(e,t,n)=>`filter "${e}" requires at least ${t} argument(s) (${n} given).`,602:(e,t,n)=>`filter "${e}" accepts at most ${t} argument(s) (${n} given).`,701:e=>`"${e}" depends on itself`,801:e=>`"${e}"`,901:(e,t,n,a)=>`${e}("${t}") takes ${n} index(es), got ${a}.`,902:(e,t,n,a)=>`${e}("${t}") takes at most ${n} index(es), got ${a}.`,1001:e=>`"${e}": list index parameters run from $1 to $128.`,1101:e=>`"${e}" uses "**", which is not accepted here.`,1201:(e,t)=>`"${e}: ${t}": the right-hand side must be $command.<name>`,1202:(e,t)=>`<${e}> declares no static wcBindable (${t}).${!e.includes("-")&&t.startsWith("command.")?" A native element's command needs the add-on @wcstack/state/features/native-commands.":""}`,1203:(e,t)=>`<${e}> declares no command "${t}".`,1204:(e,t)=>`<${e}> declares no property "${t}".`,1205:(e,t,n)=>`<${e}> has no command "${t}" (a native <${e}>'s commands: ${n}).`,1301:e=>`eventToken "${e}" is not declared in $eventTokens.`,1302:e=>`"$command.${e}" is not declared in $commandTokens.`,1401:(e,t,n=0)=>`"${e}" needs ${t} enclosing loop level(s); the scope provides ${n}.`,1402:e=>`"${e}" is relative: it needs an enclosing "for" template`,1403:(e,t,n)=>`"${e}" ranges over the rows of "${t}", but the enclosing "for" template at that level renders "${n}".`,1501:(e,t)=>`<${e}> declares no static wcBindable (${t}).`,1601:(e,t)=>`${e} was removed: write ${t}.`,1701:(e,t)=>`${e} was removed: write ${t}.`};function j(e,t){let n=T[e];return void 0===n?`${w(e)}#${e} ${t.join(" ")}`:w(e)+n(...t)}var O=new Set(["binding-syntax","template-syntax","filter-unknown","filter-arity","index-arity","wildcard-rank","token-undeclared","binding-path-missing","index-param-range"]),S=[[/no loop level in common with the context/,"; pass indexes ([] for all)."],[/"([^"#]+)#([^"]*)" is not a filter name: a modifier list .* comes before the input filters/,' — write "<property>#$2|$1".'],[/\[wcs\/recursion-unsupported\]/," It is only meaningful in a $recursion declaration, in a recursive getter key, and in the path argument of $getAll / $setAll — and only when the state declares a $recursion anchor."],[/must be single binding/,' Put the structural binding alone in its own data-wcs (e.g. <template data-wcs="for: items">).'],[/\[wcs\/wildcard-rank\] .* needs \d+ enclosing/,' Wrap it in that many "for" templates, or use $resolve(path, indexes) to name the row explicitly.'],[/\[wcs\/wildcard-rank\] .* ranges over the rows of/,' A "*" in a binding is the row of the loop around it: read a row of another list in a getter, with $resolve(path, indexes).'],[/\[wcs\/binding-type-expectation\] class\.([^ ]+)/,' Write "class.$1: path|truthy" to toggle on truthiness.'],[/path segments — the limit/," Every prefix of a path is interned, so the cost grows with the square of the depth."],[/\[wcs\/index-arity\] \$resolve/,' $resolve takes one index per "*"; $getAll / $setAll take at most that many (fewer expands the rest).'],[/"([^"#]+)#[^"]*" is not a filter name: "#" cannot appear in one/,' Modifiers belong on the left side of the binding, before the ":" — write "$1" here.']],A={inc:"add",dec:"sub",fix:"toFixed",uc:"upper",lc:"lower",cap:"capitalize",rep:"repeat",rev:"reverse",pad:"padStart",null:"nullIfEmpty"};function M(e,t,n){let a=(void 0!==t&&e.includes("[wcs/filter-unknown]")?function(e){if("substr"===e)return' "substr" was removed in 4.0 — write slice(start, start + length): slice takes the end index, not a length.';let t=Object.hasOwn(A,e)?A[e]:null;return null===t?null:` "${e}" was renamed "${t}" in 3.2 and removed in 4.0 — write "${t}".`}(t):null)??(void 0!==t&&void 0!==n?$(t,n):"");for(let[t,n]of S){let i=t.exec(e);null!==i&&(a+=n.replace(/\$(\d)/g,(e,t)=>i[Number(t)]))}let i=/"([^"#]+)#([^"]+)": a binding takes one modifier list/.exec(e);null!==i&&(a+=` — write "${i[1]}#${i[2].split("#").join(",")}".`),e.includes("[wcs/filter-unknown]")&&(e.includes("formats add-on")?a+=' On a split auto page: features="formats" on the root, or "$features": ["formats"].':s.some(r)||(a+=' No formatting filters are installed — add the formats add-on: installFeatures([formats]) from "@wcstack/state/features/formats" (a split auto page: features="formats", or "$features").'));let o=/\[wcs\/([\w-]+)\]/.exec(e);return null!==o&&O.has(o[1])&&!/ path segments — the limit is |inserted content was not rendered|formats add-on/.test(e)&&(a+=m),a}var P=new WeakMap,W=new WeakMap,I=new WeakSet,D=new WeakSet;function q(e,t){for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n)){let e=Object.getOwnPropertyDescriptor(n,t);if(void 0!==e)return e}}function C(e){let t=new Set;for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n))for(let e of Object.getOwnPropertyNames(n))"$"!==e[0]&&"constructor"!==e&&t.add(e);return[...t]}function N(e,t){let n=[];for(let e=t;null!==e;e=e.c)n.unshift(e);let a=t=>null===t?null:function(e,t){let n=t.t.split("."),a=n.findIndex((e,t)=>t>0&&/^\d/.test(e));return a<0||n.indexOf("*",a)>=0||void 0!==q(e.target,t.t)?.get?t:e.O.wt(o(t.t).o)}(e,t);return n.some(e=>null!=a(e)?.getter)?null:E(e,n,0,e.target,a)}function E(e,t,n,a,i){for(;n<t.length;n++){let s=t[n];if(null===a||"object"!=typeof a)return null;if("*"===s.s){if(!Array.isArray(a)||0===a.length)return null;let s=null;for(let r of a){let a=E(e,t,n+1,r,i);if(null===a)return null;if(null===s)s=a;else if(a.seg===s.seg)for(let e of a.names)s.names.includes(e)||s.names.push(e)}return s}if(Array.isArray(a)&&/^\d+$/.test(s.s)){if(Number(s.s)>=a.length)return null;a=a[Number(s.s)];continue}let r=q(a,s.s);if(void 0===r&&null===s.c&&e.tt.has(s.s))return null;if(void 0===r){let r=C(a),o=i(s.c);for(let t of e.O.all())t.c===o&&null!==t.getter&&r.push(t.s);return{seg:s.s,names:r,r:t.slice(0,n).some(e=>"*"===e.s)}}if(void 0!==r.get||void 0!==r.set)return null;a=r.value}return null}function B(e){I.has(e)||(I.add(e),setTimeout(()=>function(e){I.delete(e);let t=P.get(e);if(void 0===t)return;let n=W.get(e);void 0===n&&W.set(e,n=new Set);let a=new Map(t),s=new Map;for(let i of e.O.all()){let e=null===i.c||n.has(i)||t.has(i)?void 0:i.B.find(e=>!e.hn);void 0!==e&&(s.set(i,e),a.set(i,3))}for(let[t,r]of a){if(n.has(t))continue;n.add(t);let a=N(e,t);if(null===a)continue;let l=[...e.root?.querySelectorAll(`${i.tagNames.state}[mount]`)??[]].find(e=>!D.has(e)&&(t.t+".").startsWith(e.getAttribute("mount")+"."));if(void 0!==l){n.delete(t),l.initializePromise.then(()=>{D.add(l),B(e)});continue}let c=e.O.wt(o(t.t).o),u="";if(void 0!==c&&c!==t&&null!==c.getter){let e=c.h.slice(1).map((e,t)=>`for: ${0===t?e.t:e.t.slice(c.h[t].t.length+2)}`);u=` The getter "${c.t}" is declared for the rows of ${e.join(" → ")}; a list named by an index has rows of its own.`}let f=$(a.seg,a.names);if((a.r||3===r)&&""===f&&""===u)continue;let[h,p,g]=1===r?["watch-path-missing","$watch path","watch"]:2===r?["post-update-path-missing","$postUpdate path","postUpdate"]:3===r?["read-path-missing","Path","getter"]:["binding-path-missing","Bound path","binding"];d.at?.(e,{type:"state:path-unresolved",source:g,path:t.t,missingSegment:a.seg}),console.warn(`[@wcstack/state] [wcs/${h}] ${p} "${t.t}"${3===r?` read by the getter "${s.get(t).t}"`:""} does not resolve on the state tree: "${a.seg}" is not declared.${f}${u} ${2===r?"The call updates nothing.":3===r?"The getter reads undefined.":"Updates to this path will be silently dropped."}${m}`)}}(e),0))}function U(e,t,n=!1){L(e,t,n?1:0)}function L(e,t,n){if("$"===t.t[0]||t.t.includes("#")||0===n&&null===t.c)return;let a=P.get(e);void 0===a&&P.set(e,a=new Map),a.has(t)||a.set(t,n),B(e)}var z=new WeakSet,H=!1,R=new WeakMap;function F(e,t){let n=R.get(e),a=t.s;if(null!==t.c||H||void 0===n||n.has(a)||"$"===a[0]||e.tt.has(a))return;let s=$(a,[...n]);n.add(a),""!==s&&![...e.root?.querySelectorAll(`${i.tagNames.state}[mount]`)??[]].some(e=>`${e.getAttribute("mount")}.`.startsWith(`${a}.`))&&console.warn(`[@wcstack/state] [wcs/write-path-missing] "${a}" is not declared: writing it creates a new key.${s}${m}`)}var _=new WeakSet;function Y(e){if(_.has(e))return;_.add(e);let t=e.emit,n=!1;e.emit=(...a)=>(0===e.size&&!n&&(n=!0,console.warn(`[@wcstack/state] [wcs/command-token-unbound] "$command.${e.name}" was emitted with no subscriber and is lost: its element is not defined or rendered yet (emit from $renderedCallback), or no command. binding takes it.${m}`)),t.apply(e,a))}var X=new WeakMap;function J(e,t,n){let a=e.target;for(let e of t.split("."))a=null==a?void 0:q(a,e)?.value;if("function"!=typeof a||!String(a).includes("currentTarget"))return;let i=X.get(e);void 0===i&&X.set(e,i=new Set),!i.has(t)&&(i.add(t),console.warn(`[@wcstack/state] [wcs/delegated-current-target] "${t}" reads event.currentTarget, the root for a delegated on${n}:. Write on${n}#direct:, or use event.target.closest(…).${m}`))}function K(e){P.has(e)&&e.He.length>0&&B(e)}var V=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),G=!1;function Q(e,t,i){let s="html"===i.name?"innerHTML":i.name;if(G||!(t instanceof TypeError)||!a(s)||!("trustedTypes"in globalThis))return;G=!0;let r="function"==typeof n()?.createHTML?"The injected policy's createHTML() did not return a TrustedHTML.":"No sanitizing policy is installed, and @wcstack/state deliberately does not pass state values through an identity policy — that would defeat the CSP.";console.error(`[@wcstack/state] Writing to "${s}" was blocked by Trusted Types (require-trusted-types-for 'script'). ${r}\nInstall a sanitizing policy before the first binding is applied:\n globalThis[Symbol.for("wcstack.trustedTypes.policy")] =\n trustedTypes.createPolicy("my-app", { createHTML: (s) => DOMPurify.sanitize(s) });\nOr bind the value as text instead of HTML. See docs/csp.md section 7.`,{element:i.a,property:s})}var Z=new WeakMap;function ee(e,t,n){let a=e[t],i=void 0===n?void 0===a?null:`the event carried no detail (undefined) while element.${t} is ${typeof a}`:null===n||"object"!=typeof n||!Object.prototype.hasOwnProperty.call(n,t)||null!==a&&"object"==typeof a?null:`the event's detail is an object with a "${t}" key while element.${t} is ${typeof a}`;if(null===i)return;let s=Z.get(e);void 0===s&&Z.set(e,s=new Set),!s.has(t)&&(s.add(t),console.warn(`[@wcstack/state] [wcs/default-getter-mismatch] <${e.localName}> "${t}": ${i}. With no getter, state receives e.detail as-is. Dispatch the value itself as detail, or declare getter (e.g. (e) => e.detail.${t}, or (e) => e.target.${t}) on that wcBindable property.`))}var te=[["$streams","$stream"],["$updatedCallback","$renderedCallback"]],ne={$trackDependency:"$dependOn",$untrackDependency:"$untracked"},ae={name:"diagnostics",hooks:d,install(){d.Bo=M,d.Mo=j,d.$o=U,d.detail=ee,d.Ye=c(d.Ye,Q);let e=d.fe;d.fe=(t,n)=>{(function(e){void 0!==e.$scan&&l(1);for(let[t,n]of te)void 0!==e[t]&&l(1601,[t,n])})(n),e?.(t,n),function(e){let t=e.$recursion;if(null===t||"object"!=typeof t)return;let n=Object.entries(t);if(1!==n.length||"string"!=typeof n[0][1])return;let[a,i]=n[0];if(!a.endsWith(".*")||!i.endsWith(".*"))return;let s=a.slice(0,-2),r=i.slice(0,-2),o=`.${i}`,l=`${s}.**`,d=C(e),c=d.filter(e=>e.startsWith(l)).map(e=>e.slice(l.length)),u=e=>h(`[wcs/recursion-declaration-invalid] ${e}`);for(let e of c){(e===`.${r}`||e.startsWith(`.${r}.`))&&u(`"${l}${e}" names the recursion structure itself (the "${r}" lists): recursive getters compute values over the nodes.`);for(let t of c)t.length>e.length&&t.endsWith(e)&&new RegExp(`^(?:${V(o)})+$`).test(t.slice(0,t.length-e.length))&&u(`"${l}${e}" and "${l}${t}" expand to the same concrete path at different depths (they differ by whole repetitions of "${i}"). Rename one of them.`);let t=new RegExp(`^${V(a)}(?:${V(o)})*${V(e)}$`);for(let n of d)!n.includes("**")&&t.test(n)&&u(`"${n}" is already defined on the state, so the recursive getter "${l}${e}" cannot expand to it.`)}}(n),function(e){W.delete(e),P.has(e)&&B(e)}(t),function(e){if(z.has(e))return;z.add(e);let t=e.Xn,n=t.$postUpdate;t.$postUpdate=t=>{H=!0;try{n(t)}finally{H=!1}let a=e.O.wt(o(t).o);void 0!==a&&L(e,a,2)}}(t),function(e){if(void 0!==Object.getOwnPropertyDescriptor(e,"commands")?.set)return;let t=e.commands;Object.defineProperty(e,"commands",{configurable:!0,get:()=>t,set:e=>{t=e;for(let t of Object.values(e))Y(t)}})}(t),R.set(t,new Set(C(n)))},d.handlerThrew=J,d.re=c(d.re,F),d.me=c(d.me,K),d.rt=u(f,d.rt,(e,t)=>Object.hasOwn(ne,t)?l(1701,[t,ne[t]]):void 0)}},ie=ae;export{ie as default,ae as diagnostics};
|
|
2
2
|
//# sourceMappingURL=diagnostics.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["editDistance","a","b","max","Math","abs","length","prev","Array","curr","j","i","cost","min","didYouMean","input","candidates","folded","toLowerCase","best","bestDistance","candidate","distance","LINT_HINT","CODES","codeOf","id","c","MOVED","was","v","String","Date","isArray","JSON","stringify","slice","NAMESPACES","element","tag","at","map","join","CSP_GUIDE","SENTENCES","p","parent","name","n","MAX_DRAIN_PASSES","MAX_RENDER_CHAIN","type","kind","src","status","detail","key","reserved","limit","fn","modifier","value","init","where","includes","l","t","keyword","prop","quote","args","f","trailing","lastIndexOf","source","mods","ns","given","api","depth","what","startsWith","method","allowed","over","loop","old","render","sentence","LINT_CODES","Set","GUIDES","RENAMED_FILTERS","inc","dec","fix","uc","lc","cap","rep","rev","pad","null","explain","message","subject","out","to","Object","hasOwn","removedFilter","re","text","m","exec","replace","_","Number","split","FORMATS_FILTER_NAMES","some","hasFilter","code","has","test","named","WeakMap","checked","due","WeakSet","settled","findDescriptor","o","x","prototype","getPrototypeOf","d","getOwnPropertyDescriptor","keysOf","k","getOwnPropertyNames","add","missing","engine","chain","q","unshift","segs","path","findIndex","s","indexOf","target","get","patterns","peek","parsePath","pattern","wildcardForm","getter","under","last","first","row","seg","names","push","dropped","g","all","set","schedule","setTimeout","delete","done","todo","Map","readers","dependents","find","markup","root","querySelectorAll","config","tagNames","state","e","getAttribute","initializePromise","then","w","rowGetter","loops","lists","near","hooks","noticed","missingSegment","console","warn","check","declared","watch","note","wrapped","posting","declaredKeys","written","keys","wrappedTokens","loud","emit","said","size","apply","explained","handlerThrew","drained","loose","esc","trustedTypesReported","failed","_engine","error","binding","TypeError","isHtmlSink","globalThis","cause","getTrustedTypesPolicy","createHTML","node","property","warnedDetail","el","reason","hasOwnProperty","call","localName","REMOVED_DECLARATIONS","REMOVED_APIS","$trackDependency","$untrackDependency","diagnostics","install","declare","$scan","raise","removedDeclarations","decl","$recursion","entries","anchor","repeat","endsWith","list","step","head","families","filter","bad","why","raiseError","RegExp","checkRecursion","recheck","post","$postUpdate","watchPostUpdate","commands","defineProperty","configurable","values","watchCommands","dollar","known","diagnostics_default"],"sources":["../../../src/diagnostics/guidance.ts","../../../src/diagnostics/messages.ts","../../../src/diagnostics/explain.ts","../../../src/features/diagnostics.ts"],"sourcesContent":["/**\n * diagnostics/guidance.ts — self-fix guidance for error messages, ported verbatim from\n * `@wcstack/state` (`errorGuidance.ts`). Only the diagnostics add-on uses it: the core's\n * messages state the fact, and the add-on appends this.\n *\n * The did-you-mean criteria (edit distance 2, ties go to the first candidate, case folded) are the\n * same as lint's suggestion, so the console, lint and the IDE never propose different names.\n */\n\n/** Insert / delete / substitute edit distance. Returns max + 1 early when the lengths differ by more than max. */\nfunction editDistance(a: string, b: string, max: number): number {\n if (Math.abs(a.length - b.length) > max) {\n return max + 1;\n }\n const prev: number[] = new Array(b.length + 1);\n const curr: number[] = new Array(b.length + 1);\n for (let j = 0; j <= b.length; j++) {\n prev[j] = j;\n }\n for (let i = 1; i <= a.length; i++) {\n curr[0] = i;\n for (let j = 1; j <= b.length; j++) {\n const cost = a[i - 1] === b[j - 1] ? 0 : 1;\n curr[j] = Math.min(prev[j] + 1, curr[j - 1] + 1, prev[j - 1] + cost);\n }\n for (let j = 0; j <= b.length; j++) {\n prev[j] = curr[j];\n }\n }\n return prev[b.length];\n}\n\n/**\n * The nearest candidate within edit distance 2 as ` Did you mean \"<best>\"?`, or `\"\"` when there is\n * none. An empty input (a trailing `a|` pipe) gets no suggestion.\n */\nexport function didYouMean(input: string, candidates: Iterable<string>): string {\n if (input.length === 0) {\n return \"\";\n }\n const folded = input.toLowerCase();\n let best: string | null = null;\n let bestDistance = 3;\n for (const candidate of candidates) {\n const distance = editDistance(folded, candidate.toLowerCase(), 2);\n if (distance < bestDistance) {\n best = candidate;\n bestDistance = distance;\n }\n }\n return best !== null ? ` Did you mean \"${best}\"?` : \"\";\n}\n\n/**\n * The pointer to lint. Attach it **only where lint actually detects the case** — a hint that sends\n * the author to a lint run that comes back clean costs the loop its credibility.\n */\nexport const LINT_HINT = \" Validate statically: npx @wcstack/lint <file>.\";\n","/**\n * The sentences of the core's numbered messages (src/messages.ts), in the diagnostics add-on:\n * the core carries the number and the values, this renders what the core used to say. Each\n * sentence follows its `[wcs/<code>] ` (`codeOf`: the code the hundreds of the number name).\n * `Record<M, …>` makes a number without a sentence a type error.\n */\nimport { M } from \"../messages\";\nimport { MAX_DRAIN_PASSES, MAX_INDEX_PARAM, MAX_RENDER_CHAIN } from \"../engine\";\nimport { MAX_PATH_SEGMENTS, MODIFIER_SEPARATOR, RECURSION_WILDCARD } from \"../parser/define\";\n\ntype Sentence = (...a: any[]) => string;\n\n/**\n * The code of each hundred of message numbers (\"\" = none): the code lint and the VS Code extension\n * report for the same case. The core carried this up to 4.0.0-rc.3; without this add-on a message\n * now reads as its number and values alone.\n */\nexport const CODES = [\n \"\", \"binding-syntax\", \"template-syntax\", \"binding-path-missing\", \"binding-type-expectation\",\n \"filter-unknown\", \"filter-arity\", \"getter-cycle\", \"getter-depth-exceeded\", \"index-arity\",\n \"index-param-range\", \"recursion-unsupported\", \"token-misconfigured\", \"token-undeclared\",\n \"wildcard-rank\", \"spread-no-bindable\", \"declaration-alias\", \"name-alias\",\n];\n\n/** `[wcs/<code>] ` for a message number, or \"\" when it has none. */\nexport const codeOf = (id: M): string => {\n const c = CODES[(id / 100) | 0];\n return c ? `[wcs/${c}] ` : \"\";\n};\n\n/** The options 4.0 moved from `bootstrapState` to the state's `$behavior`. */\nconst MOVED = [\"enableMustache\", \"sameValueGuard\", \"enableDirectionalInitialSync\"];\n\n/** `<tag a=\"v\" …>` from the tag and its attributes' names and values. */\n/** What a value given to a filter was (`a string (\"2026-10-13T…\")`), for the type messages. */\nconst was = (v: unknown): string =>\n v == null ? String(v)\n : v instanceof Date ? \"a Date\"\n : Array.isArray(v) ? \"an array\"\n : typeof v === \"string\" ? `a string (${JSON.stringify(v.length > 32 ? v.slice(0, 32) + \"…\" : v)})`\n : typeof v === \"object\" ? \"an object\" : `a ${typeof v} (${String(v)})`;\n/** The namespace a binding of kind 2–4 (dom/view.ts: K_CLASS, K_ATTR, K_STYLE) names its member under. */\nconst NAMESPACES = [\"\", \"\", \"class.\", \"attr.\", \"style.\"];\n\nconst element = (tag: string, at: string[]): string => `<${tag}${at.map((a, i) => (i % 2 ? `=\"${a}\"` : ` ${a}`)).join(\"\")}>`;\n\nconst CSP_GUIDE = \"https://github.com/wcstack/wcstack/blob/main/docs/csp.md\";\n\nexport const SENTENCES: Record<M, Sentence> = {\n [M.ScanRemoved]: () => \"$scan was removed (use $watch or $on)\",\n [M.GetterWithoutSetter]: (p) => `\"${p}\" is a getter without a setter`,\n [M.NoRow]: (p) => `no row for \"${p}\"`,\n [M.ParentNotObject]: (p, parent) => `cannot write \"${p}\": its parent is ${parent}`,\n [M.NotAMethod]: (name) => `\"${name}\" is not a method`,\n [M.GetAllNoCommonLevel]: (p) => `$getAll(\"${p}\"): no loop level in common with the context`,\n [M.EqIndexNoRow]: (p) => `$eqIndex(\"${p}\") needs a list row scope.`,\n [M.Readonly]: () => \"This state is readonly.\",\n [M.SetAllNeedsIndexes]: (p) => `$setAll(\"${p}\") needs indexes ([] for every match)`,\n [M.SetAllSpreadLength]: (p, n) => `$setAll(\"${p}\", …, { spread: true }) needs an array of ${n} values`,\n [M.DrainNotSettled]: () => `updates did not settle after ${MAX_DRAIN_PASSES} passes`,\n [M.RenderChain]: () => `render chain depth limit exceeded (${MAX_RENDER_CHAIN} drains that rendering itself started); bindings for this batch were not applied.`,\n // (named as written — `textContent: iso`, `class.active: x` — when the binding has a member; else its type)\n [M.BindingFailed]: (type, p, name, kind) => `binding \"${name ? (NAMESPACES[kind] ?? \"\") + name : type}: ${p}\" failed to apply.`,\n [M.LoadFailed]: (src, status) => `failed to load \"${src}\": ${status}`,\n [M.ElementFailed]: () => \"this <wcs-state> failed to initialize; create a new one\",\n [M.NotInitialized]: () => \"state is not initialized\",\n [M.NoScript]: (id) => `no <script> with id \"${id}\"`,\n [M.InlineBlocked]: () => `The inline <script> of <wcs-state> was blocked by Content-Security-Policy. Inline state is evaluated through a blob: URL: give the page's nonce to the <script> that loads @wcstack/state, or allow blob: in script-src. Moving the state into an external file (src=\"./state.js\") needs neither. See ${CSP_GUIDE}`,\n [M.InlineFailed]: (detail) => `Failed to evaluate the inline <script> of <wcs-state>: ${detail}. If this page sets a Content-Security-Policy, see ${CSP_GUIDE}`,\n [M.TokenSubscriberThrew]: (name) => `a subscriber of token \"${name}\" threw.`,\n [M.TokenListNotArray]: (key) => `${key} must be an array of strings.`,\n [M.TokenEntryEmpty]: (key) => `${key} entries must be non-empty strings.`,\n [M.TokenEntryReserved]: (key, name, reserved) => `${key} entry \"${name}\" conflicts with the reserved namespace name \"${reserved}\".`,\n [M.TokenEntryDuplicated]: (key, name) => `${key} entry \"${name}\" is duplicated.`,\n [M.OnNotObject]: () => \"$on must be an object of handlers.\",\n [M.OnEntryUndeclared]: (name) => `$on entry \"${name}\" is not declared in $eventTokens.`,\n [M.OnEntryNotFunction]: (name) => `$on entry \"${name}\" must be a function.`,\n [M.NamingLimit]: (limit) => `view-transition naming-limit (${limit}) reached.`,\n [M.FilterOptionsRequired]: (fn) => `filter ${fn} requires at least one option`,\n [M.FilterOptionNotNumber]: (fn) => `filter ${fn} requires a number as option`,\n [M.FilterValueNotNumber]: (fn, v) => `filter ${fn} requires a number value, not ${was(v)}${typeof v === \"string\" ? ` — put |number before |${fn}, or convert it where it is read` : \"\"}`,\n [M.FilterValueNotDate]: (fn, v) => `filter ${fn} requires a date value (a Date), not ${was(v)}${typeof v === \"string\" || typeof v === \"number\" ? \" — make the Date where it is read: a getter returning new Date(…)\" : \"\"}`,\n [M.FilterStyleInvalid]: (fn, v) => `filter ${fn} takes a style of full, long, medium or short, not \"${v}\"`,\n [M.FilterCurrencyInvalid]: (v) => `filter currency takes an ISO 4217 currency code (JPY, USD, EUR), not \"${v}\"`,\n [M.FilterValueNotArray]: (fn) => `filter ${fn} requires an array value`,\n [M.DirectionalSyncDisabled]: () => \"init=/sync= modifiers require enableDirectionalInitialSync.\",\n [M.ModifierUnknown]: (key, modifier) => `Unknown binding modifier \"${key}\" in \"${modifier}\".`,\n [M.ModifierTwice]: (key) => `Binding modifier \"${key}\" may only be specified once.`,\n [M.ModifierValue]: (key, value) => `Invalid ${key} modifier value \"${value}\".`,\n [M.EventInitNone]: () => \"Event bindings only allow init=none.\",\n [M.InitUnsupported]: (type, init) => `Binding type \"${type}\" does not support init=${init}.`,\n [M.MemberUndeclared]: (name) => `Property \"${name}\" is not declared by wcBindable.`,\n [M.InitIncompatible]: (init, name) => `init=${init} is incompatible with wcBindable member \"${name}\".`,\n [M.SyncConnectNeedsOutput]: (name) => `sync=connect requires observable property \"${name}\".`,\n [M.OptionInvalid]: (where, key) => `${where}: \"${key}\" is not one of its options, or not of the option's type.${where === \"bootstrapState\" && MOVED.includes(key) ? \" 4.0 moved it to the state's $behavior.\" : \"\"}`,\n [M.BehaviorChanged]: () => \"a re-set state may not change $behavior: create the element again.\",\n [M.SecondRoot]: () => \"a second <wcs-state> on the same root: there is one state tree per root — graft a subtree with <wcs-state mount=\\\"path\\\"> (v1's name=\\\"…\\\" is gone: read the mounted state by its path).\",\n [M.LocaleInvalid]: (l) => `the locale \"${l}\" (<html lang> or bootstrapState's locale) is not a language tag Intl takes (en-US, not en_US): the locale filters use \"en\".`,\n [M.FeaturesNotArray]: () => '$features must be an array of add-on names ([\"temporal\", \"formats\"]).',\n [M.InitFailed]: (tag, ...at) => `${element(tag, at)} failed to initialize.`,\n [M.ConnectedFailed]: (tag, ...at) => `${element(tag, at)} $connectedCallback failed.`,\n [M.DisconnectedFailed]: (tag, ...at) => `${element(tag, at)} $disconnectedCallback failed.`,\n\n [M.BindTextNoColon]: (t) => `Invalid bindText: \"${t}\". Missing ':' separator between propPart and statePart.`,\n [M.StructuralTakesNoModifiers]: (t, keyword) => `\"${t}\": \"${keyword}\" takes no modifiers or filters on its left side — write \"${keyword}:\".`,\n [M.ElseTakesNoValue]: (t) => `\"${t}\": \"else\" takes no value — write \"else:\".`,\n [M.SpreadNoPath]: (t) => `Invalid spread binding \"${t}\": spread target path is required.`,\n [M.SpreadNoFilters]: (t) => `Invalid spread binding \"${t}\": filters are not allowed on spread targets.`,\n [M.LeadingDotNamespace]: (prop) => `\"${prop}\": a leading \".\" binds an element property by name — write a non-empty property that is not a namespace (class, attr, style, command, eventToken, state).`,\n [M.UnterminatedQuote]: (quote, args) => `unterminated ${quote} quote in the filter arguments \"(${args})\". Close the quote.`,\n [M.FilterUnclosed]: (f) => `Invalid filter format: missing closing parenthesis in \"${f}\".`,\n [M.FilterUnopened]: (f) => `Invalid filter format: missing opening parenthesis in \"${f}\".`,\n [M.FilterParenOrder]: (f) => `Invalid filter format: \")\" comes before \"(\" in \"${f}\".`,\n [M.FilterTrailing]: (f, trailing) => `\"${f}\": unexpected \"${trailing}\" after the filter's closing \")\" — separate filters with \"|\" (write \"${f.slice(0, f.lastIndexOf(\")\") + 1)}|${trailing}\").`,\n [M.FilterEmpty]: (source) => `an empty filter in \"${source}\" — remove the extra \"|\" or name the filter.`,\n [M.FilterNameHasModifiersInput]: (name, mods) => `\"${name}\" is not a filter name: a modifier list \"${MODIFIER_SEPARATOR}${mods}\" comes before the input filters, not inside one`,\n [M.FilterNameHasModifiersOutput]: (name) => `\"${name}\" is not a filter name: \"${MODIFIER_SEPARATOR}\" cannot appear in one.`,\n [M.OneModifierList]: (prop) => `\"${prop}\": a binding takes one modifier list after a single \"#\"`,\n [M.NoPropertyName]: (prop) => `\"${prop}\": the left side of a binding must name a property — write \"<property>: <path>\" (modifiers and input filters come after the name).`,\n [M.TooManySegments]: (p, n) => `\"${p}\" has ${n} path segments — the limit is ${MAX_PATH_SEGMENTS}.`,\n [M.SelectorRemoved]: (t) => `\"${t}\": the \"@name\" selector was removed in v2 — there is a single state tree. Mount the named state onto the tree (<wcs-state mount=\"...\">) and read it by its path prefix instead.`,\n [M.UnsafeSegment]: (p) => `\"${p}\": a state path cannot go through \"__proto__\" or \"prototype\" (it would reach every object's prototype).`,\n [M.ForNoFilters]: (t) => `\"${t}\": \"for:\" takes no filters — a row is \"<path>.<index>\", so the rows of a filtered list would name other elements. Declare a getter that returns the filtered list and loop over it (\"for: <getter>\").`,\n [M.NamespaceNeedsName]: (t, ns) => ns === \"class\"\n ? `\"${t}\": \"class:\" needs a class name — \"class.NAME:\" toggles one class (a bare \"class:\" would set an element property named \"class\", which does nothing). To set the whole class attribute, bind \"className:\".`\n : `\"${t}\": \"attr:\" needs an attribute name — \"attr.NAME:\" sets one attribute (a bare \"attr:\" would set an element property named \"attr\", which does nothing).`,\n [M.EmptySegment]: (t) => `\"${t}\": the right side of a binding must name a state path — write \"<property>: <path>\" (a path segment cannot be empty; \".\" alone and a leading \".\" are the loop-relative shorthand).`,\n\n [M.StructuralNotSingle]: (t) => `Invalid bindText: \"${t}\". 'if', 'elseif', 'else', and 'for' bindings must be single binding.`,\n [M.ElseWithoutIf]: (type) => `\"${type}:\" must follow an \"if:\" template`,\n [M.TemplateHandedOver]: (type) => `a \"${type}:\" template at the top of inserted content was not rendered, as it would render beside itself out of the inserter's reach: wrap it in an element.`,\n [M.OuterInTemplate]: (name) => `\"${name}:\" replaces its element, so it cannot be used inside a \"for\" / \"if\" template (a row or branch keeps its nodes by position): bind innerHTML: on a wrapper element instead.`,\n\n [M.PathMissing]: (p) => `Path \"${p}\" does not exist on the state tree.`,\n\n [M.ClassNeedsBoolean]: (name, type) => `class.${name} needs a boolean, got ${type}.`,\n\n [M.FilterUnknown]: (name) => `filter not found: ${name}.`,\n\n [M.FilterTooFewArgs]: (name, min, given) => `filter \"${name}\" requires at least ${min} argument(s) (${given} given).`,\n [M.FilterTooManyArgs]: (name, max, given) => `filter \"${name}\" accepts at most ${max} argument(s) (${given} given).`,\n\n [M.GetterCycle]: (p) => `\"${p}\" depends on itself`,\n\n [M.GetterDepth]: (p) => `\"${p}\"`,\n\n [M.IndexArityExact]: (api, p, depth, n) => `${api}(\"${p}\") takes ${depth} index(es), got ${n}.`,\n [M.IndexArityAtMost]: (api, p, depth, n) => `${api}(\"${p}\") takes at most ${depth} index(es), got ${n}.`,\n\n [M.IndexParamRange]: (key) => `\"${key}\": list index parameters run from $1 to $${MAX_INDEX_PARAM}.`,\n\n [M.RecursionUnsupported]: (p) => `\"${p}\" uses \"${RECURSION_WILDCARD}\", which is not accepted here.`,\n\n [M.CommandRightSide]: (prop, p) => `\"${prop}: ${p}\": the right-hand side must be $command.<name>`,\n // a native element's command (no hyphen: never a custom element) is the native-commands add-on's\n [M.NoBindable]: (tag, what) => `<${tag}> declares no static wcBindable (${what}).${\n !tag.includes(\"-\") && what.startsWith(\"command.\") ? \" A native element's command needs the add-on @wcstack/state/features/native-commands.\" : \"\"}`,\n [M.NoCommand]: (tag, method) => `<${tag}> declares no command \"${method}\".`,\n [M.NoProperty]: (tag, prop) => `<${tag}> declares no property \"${prop}\".`,\n [M.NativeNoCommand]: (tag, method, allowed) => `<${tag}> has no command \"${method}\" (a native <${tag}>'s commands: ${allowed}).`,\n\n [M.EventTokenUndeclared]: (name) => `eventToken \"${name}\" is not declared in $eventTokens.`,\n [M.CommandTokenUndeclared]: (name) => `\"$command.${name}\" is not declared in $commandTokens.`,\n\n [M.WildcardNoLoop]: (p, depth, n = 0) => `\"${p}\" needs ${depth} enclosing loop level(s); the scope provides ${n}.`,\n [M.WildcardRelative]: (p) => `\"${p}\" is relative: it needs an enclosing \"for\" template`,\n [M.WildcardOtherList]: (p, over, loop) => `\"${p}\" ranges over the rows of \"${over}\", but the enclosing \"for\" template at that level renders \"${loop}\".`,\n\n [M.SpreadNoBindable]: (tag, what) => `<${tag}> declares no static wcBindable (${what}).`,\n\n [M.DeclarationRemoved]: (old, name) => `${old} was removed: write ${name}.`,\n\n [M.ApiRemoved]: (old, name) => `${old} was removed: write ${name}.`,\n};\n","/**\n * The diagnostics add-on's sentences and guidance: a numbered core message rendered as its\n * sentence (src/diagnostics/messages.ts), then how to fix it, the nearest name and the lint\n * pointer. The add-on installs these; so does `@wcstack/state/parser`, a bundle of its own.\n */\nimport { didYouMean, LINT_HINT } from \"./guidance\";\nimport { FORMATS_FILTER_NAMES, hasFilter } from \"../filters/registry\";\nimport type { M } from \"../messages\";\nimport { codeOf, SENTENCES } from \"./messages\";\n\n/** A numbered core message as its sentence (the number and the values if it is not known here). */\nexport function render(id: number, args: readonly unknown[]): string {\n const sentence = SENTENCES[id as M];\n return sentence === undefined ? `${codeOf(id)}#${id} ${args.join(\" \")}` : codeOf(id) + sentence(...args);\n}\n\n/** Codes lint detects statically: only these point the author to a lint run. */\nconst LINT_CODES = new Set([\n \"binding-syntax\", \"template-syntax\", \"filter-unknown\", \"filter-arity\", \"index-arity\",\n \"wildcard-rank\", \"token-undeclared\", \"binding-path-missing\", \"index-param-range\",\n]);\n\n/** How to fix it, by what the message says. */\nconst GUIDES: [RegExp, string][] = [\n [/no loop level in common with the context/, \"; pass indexes ([] for all).\"],\n [/\"([^\"#]+)#([^\"]*)\" is not a filter name: a modifier list .* comes before the input filters/, ' — write \"<property>#$2|$1\".'],\n [/\\[wcs\\/recursion-unsupported\\]/, \" It is only meaningful in a $recursion declaration, in a recursive getter key, and in the path argument of $getAll / $setAll — and only when the state declares a $recursion anchor.\"],\n [/must be single binding/, ' Put the structural binding alone in its own data-wcs (e.g. <template data-wcs=\"for: items\">).'],\n [/\\[wcs\\/wildcard-rank\\] .* needs \\d+ enclosing/, ' Wrap it in that many \"for\" templates, or use $resolve(path, indexes) to name the row explicitly.'],\n [/\\[wcs\\/wildcard-rank\\] .* ranges over the rows of/, ' A \"*\" in a binding is the row of the loop around it: read a row of another list in a getter, with $resolve(path, indexes).'],\n [/\\[wcs\\/binding-type-expectation\\] class\\.([^ ]+)/, ' Write \"class.$1: path|truthy\" to toggle on truthiness.'],\n [/path segments — the limit/, \" Every prefix of a path is interned, so the cost grows with the square of the depth.\"],\n [/\\[wcs\\/index-arity\\] \\$resolve/, \" $resolve takes one index per \\\"*\\\"; $getAll / $setAll take at most that many (fewer expands the rest).\"],\n [/\"([^\"#]+)#[^\"]*\" is not a filter name: \"#\" cannot appear in one/, ' Modifiers belong on the left side of the binding, before the \":\" — write \"$1\" here.'],\n];\n\n/**\n * The filter names 3.2 renamed, which 3.x kept as aliases and 4.0 removed (3.x's `filterAliases`;\n * lint has the same table). Their message names the replacement, not the nearest name: for these\n * that is an unrelated filter (`dec` → `eq`, `fix` → `div`), and following it changes the meaning.\n */\nexport const RENAMED_FILTERS: Readonly<Record<string, string>> = {\n inc: \"add\", dec: \"sub\", fix: \"toFixed\", uc: \"upper\", lc: \"lower\", cap: \"capitalize\", rep: \"repeat\", rev: \"reverse\", pad: \"padStart\", null: \"nullIfEmpty\",\n};\n\n/** How to write a filter 4.0 removed, or null. */\nfunction removedFilter(name: string): string | null {\n // 4.0 folded substr(start, length) into slice(start, end): the second argument changes meaning\n if (name === \"substr\") return ' \"substr\" was removed in 4.0 — write slice(start, start + length): slice takes the end index, not a length.';\n const to = Object.hasOwn(RENAMED_FILTERS, name) ? RENAMED_FILTERS[name] : null;\n return to === null ? null : ` \"${name}\" was renamed \"${to}\" in 3.2 and removed in 4.0 — write \"${to}\".`;\n}\n\nexport function explain(message: string, subject?: string, candidates?: Iterable<string>): string {\n const removed = subject !== undefined && message.includes(\"[wcs/filter-unknown]\") ? removedFilter(subject) : null;\n let out = removed ?? (subject !== undefined && candidates !== undefined ? didYouMean(subject, candidates) : \"\");\n for (const [re, text] of GUIDES) {\n const m = re.exec(message);\n if (m !== null) out += text.replace(/\\$(\\d)/g, (_, i: string) => m[Number(i)]);\n }\n // \"value#ro#wo\": one modifier list — the fix joins them\n const mods = /\"([^\"#]+)#([^\"]+)\": a binding takes one modifier list/.exec(message);\n if (mods !== null) out += ` — write \"${mods[1]}#${mods[2].split(\"#\").join(\",\")}\".`;\n // a formatting filter on a page without the formats add-on (the core names installFeatures), or a\n // typo on a page with no formatting filters at all: the formats add-on may be what is missing\n if (message.includes(\"[wcs/filter-unknown]\")) {\n if (message.includes(\"formats add-on\")) out += ` On a split auto page: features=\"formats\" on the root, or \"$features\": [\"formats\"].`;\n else if (!FORMATS_FILTER_NAMES.some(hasFilter)) {\n out += ` No formatting filters are installed — add the formats add-on: installFeatures([formats]) from \"@wcstack/state/features/formats\" (a split auto page: features=\"formats\", or \"$features\").`;\n }\n }\n const code = /\\[wcs\\/([\\w-]+)\\]/.exec(message);\n // (not something lint reports: the path-length limit is a runtime cost, a template handed over at\n // the top of inserted content (#204) is the page's order of loading, not its markup, and lint's\n // manifest knows the formatting filters — one missing because the formats add-on is not installed\n // is the page's. A row of another list (#1403) and an `outerHTML:` in a template (#203) lint does\n // report, as of its 4.0 parser)\n if (code !== null && LINT_CODES.has(code[1]) && !/ path segments — the limit is |inserted content was not rendered|formats add-on/.test(message)) out += LINT_HINT;\n return out;\n}\n","/**\n * The diagnostics add-on (@wcstack/state/features/diagnostics): the sentences and the self-fix\n * guidance of error messages. The core states the message number and the values\n * (`#901 \"$resolve\" \"m.*.*\" 2 1`); with this installed, the message is the code shared with lint\n * and the sentence (`[wcs/index-arity] $resolve(\"m.*.*\") takes 2 index(es), got 1.`), followed by the\n * nearest name (did-you-mean, the same rule as lint), how to fix it, and a pointer to lint where\n * lint really detects the case. The full `auto` bundle installs it.\n */\nimport { chain, first, hooks, known, type Feature } from \"../hooks\";\nimport type { Engine } from \"../engine\";\nimport { parsePath, type Pattern } from \"../pattern\";\nimport { raiseError } from \"../parser/raiseError\";\nimport { config } from \"../config\";\nimport type { WcsState } from \"../element\";\nimport type { Binding } from \"../dom/view\";\nimport { getTrustedTypesPolicy, isHtmlSink } from \"../trustedTypes\";\nimport { didYouMean, LINT_HINT } from \"../diagnostics/guidance\";\nimport { explain, render } from \"../diagnostics/explain\";\nimport { raise, M } from \"../messages\";\nimport type { Token } from \"../token\";\n\n// ---------------------------------------------------------------- paths that do not resolve\n\n/** What named a path: a binding, a `$watch` key, a `$postUpdate` call, a getter's read. */\nconst BINDING = 0;\nconst WATCH = 1;\nconst POST = 2;\nconst READ = 3;\n/** Paths bindings, `$watch` keys and `$postUpdate` named, by engine: checked one macrotask later (and after a re-set). */\nconst named = new WeakMap<Engine, Map<Pattern, number>>();\nconst checked = new WeakMap<Engine, Set<Pattern>>();\nconst due = new WeakSet<Engine>();\n/** Volumes (`<wcs-state mount>`) whose loading settled: the paths under them are checked from then on. */\nconst settled = new WeakSet<Element>();\n\nfunction findDescriptor(o: object, key: string): PropertyDescriptor | undefined {\n for (let x: object | null = o; x !== null && x !== Object.prototype; x = Object.getPrototypeOf(x)) {\n const d = Object.getOwnPropertyDescriptor(x, key);\n if (d !== undefined) return d;\n }\n return undefined;\n}\n\nfunction keysOf(o: object): string[] {\n const out = new Set<string>();\n for (let x: object | null = o; x !== null && x !== Object.prototype; x = Object.getPrototypeOf(x)) {\n for (const k of Object.getOwnPropertyNames(x)) if (k[0] !== \"$\" && k !== \"constructor\") out.add(k);\n }\n return [...out];\n}\n\n/**\n * The pattern a path with an explicit index reads through: an index with no `*` after it\n * (`items.0.x`) has an accessor of its own (Engine.markupAccessor), so whether it reads a getter\n * is the question of the pattern it names (`items.*.x`). A `*` after the index (`groups.0.items.*.x`,\n * a row of `for: groups.0.items`) reads its row's own item: the pattern itself. So does a path the\n * author declared a getter under (`get \"groups.0.items\"()`): that getter is what it reads (#388).\n */\nfunction wildcardForm(engine: Engine, q: Pattern): Pattern | undefined {\n const segs = q.path.split(\".\");\n // (a leading numeric segment is a root key, not an index: parsePath)\n const i = segs.findIndex((s, j) => j > 0 && /^\\d/.test(s));\n return i < 0 || segs.indexOf(\"*\", i) >= 0 || findDescriptor(engine.target, q.path)?.get !== undefined\n ? q : engine.patterns.peek(parsePath(q.path).pattern);\n}\n\n/**\n * The segment of `p` that certainly does not exist, with the names that do at its level; null\n * when the path exists or it cannot be told without evaluating a getter (a getter on the way, a\n * null or primitive on the way, a list with no row to look into).\n */\nfunction missing(engine: Engine, p: Pattern): { seg: string; names: string[]; row: boolean } | null {\n const chain: Pattern[] = [];\n for (let q: Pattern | null = p; q !== null; q = q.parent) chain.unshift(q);\n const named = (q: Pattern | null): Pattern | null | undefined => (q === null ? null : wildcardForm(engine, q));\n // a getter anywhere on the path answers it — also one declared deeper than a segment the data\n // lacks (\\`get \"box.label\"()\\` with no \\`box\\` key: it renders and updates — docs/seam-apps.md)\n if (chain.some((q) => named(q)?.getter != null)) return null;\n return under(engine, chain, 0, engine.target, named);\n}\n\n/** `missing` from `chain[k]` on, in `v`. */\nfunction under(engine: Engine, chain: Pattern[], k: number, v: any, named: (q: Pattern | null) => Pattern | null | undefined): { seg: string; names: string[]; row: boolean } | null {\n for (; k < chain.length; k++) {\n const q = chain[k];\n if (v === null || typeof v !== \"object\") return null;\n if (q.last === \"*\") {\n if (!Array.isArray(v) || v.length === 0) return null;\n // a row field is declared when any row has it — an optional one (`pending` on the rows a page\n // added itself) is not missing because the first row lacks it (docs/seam-apps.md, ssr-news)\n // (missing in every row: the names any row has are the candidates)\n let first: { seg: string; names: string[]; row: boolean } | null = null;\n for (const row of v) {\n const m = under(engine, chain, k + 1, row, named);\n if (m === null) return null;\n if (first === null) first = m;\n else if (m.seg === first.seg) for (const n of m.names) if (!first.names.includes(n)) first.names.push(n);\n }\n return first;\n }\n if (Array.isArray(v) && /^\\d+$/.test(q.last)) {\n // an explicit index: only a row that is there can be looked into\n if (Number(q.last) >= v.length) return null;\n v = v[Number(q.last)];\n continue;\n }\n const d = findDescriptor(v, q.last);\n // a top-level key a re-set dropped is declared: it reads undefined, and a write fills it\n if (d === undefined && q.parent === null && engine.dropped.has(q.last)) return null;\n if (d === undefined) {\n const names = keysOf(v);\n // getters declared one level under the same parent (`items.*.subtotal`)\n const parent = named(q.parent);\n for (const g of engine.patterns.all()) if (g.parent === parent && g.getter !== null) names.push(g.last);\n return { seg: q.last, names, row: chain.slice(0, k).some((x) => x.last === \"*\") };\n }\n if (d.get !== undefined || d.set !== undefined) return null;\n v = d.value;\n }\n return null;\n}\n\nfunction check(engine: Engine): void {\n due.delete(engine);\n const map = named.get(engine);\n if (map === undefined) return;\n let done = checked.get(engine);\n if (done === undefined) checked.set(engine, (done = new Set()));\n // The paths named, and those a getter read (`this[\"items.*.pirce\"]`, `$getAll(\"items.*.pirce\")`): such a read\n // gets undefined, and what is computed from it is wrong without a word (an outside evaluation, a tax return\n // draft). A top-level key the state lacks already fails the read (the core's error); a named path is reported\n // as named; the engine's own accessor of an index path (`items.0.x`) reads for the binding that named it\n const todo = new Map(map);\n const readers = new Map<Pattern, Pattern>();\n for (const p of engine.patterns.all()) {\n const g = p.parent === null || done.has(p) || map.has(p) ? undefined : p.dependents.find((d) => !d.markup);\n if (g === undefined) continue;\n readers.set(p, g);\n todo.set(p, READ);\n }\n for (const [p, kind] of todo) {\n if (done.has(p)) continue;\n done.add(p);\n const m = missing(engine, p);\n if (m === null) continue;\n // under the mount path of a volume on the page still loading: checked again once it settles (3.x D22)\n const v = [...((engine.root as ParentNode | null)?.querySelectorAll(`${config.tagNames.state}[mount]`) ?? [])]\n .find((e) => !settled.has(e) && (p.path + \".\").startsWith(e.getAttribute(\"mount\") + \".\"));\n if (v !== undefined) {\n done.delete(p);\n void (v as WcsState).initializePromise.then(() => {\n settled.add(v);\n schedule(engine);\n });\n continue;\n }\n // a row of `for: groups.0.items` with a row getter declared on `groups.*.items.*` (#388)\n const w = engine.patterns.peek(parsePath(p.path).pattern);\n let rowGetter = \"\";\n if (w !== undefined && w !== p && w.getter !== null) {\n const loops = w.lists.slice(1).map((l, k) => `for: ${k === 0 ? l!.path : l!.path.slice(w.lists[k]!.path.length + 2)}`);\n rowGetter = ` The getter \"${w.path}\" is declared for the rows of ${loops.join(\" → \")}; a list named by an index has rows of its own.`;\n }\n const near = didYouMean(m.seg, m.names);\n // A row field no row has is not a sign of a mistake: rows are data, and an optional field (the\n // `pending` a page puts on its own rows) is absent from the server's (docs/seam-apps.md, ssr-news).\n // Reported only with a near name — a likely typo (`.nmae` beside `name`) — or a row getter of\n // another list form. So is a getter's read: `this[\"opts.flag\"] ?? false` reads an optional key on purpose\n if ((m.row || kind === READ) && near === \"\" && rowGetter === \"\") continue;\n const [code, subject, source] = kind === WATCH ? [\"watch-path-missing\", \"$watch path\", \"watch\"]\n : kind === POST ? [\"post-update-path-missing\", \"$postUpdate path\", \"postUpdate\"]\n : kind === READ ? [\"read-path-missing\", \"Path\", \"getter\"]\n : [\"binding-path-missing\", \"Bound path\", \"binding\"];\n hooks.noticed?.(engine, { \"type\": \"state:path-unresolved\", \"source\": source, \"path\": p.path, \"missingSegment\": m.seg });\n console.warn(`[@wcstack/state] [wcs/${code}] ${subject} \"${p.path}\"${kind === READ ? ` read by the getter \"${readers.get(p)!.path}\"` : \"\"} does not resolve on the state tree: \"${m.seg}\" is not declared.${near}${rowGetter} ${kind === POST ? \"The call updates nothing.\" : kind === READ ? \"The getter reads undefined.\" : \"Updates to this path will be silently dropped.\"}${LINT_HINT}`);\n }\n}\n\nfunction schedule(engine: Engine): void {\n if (due.has(engine)) return;\n due.add(engine);\n setTimeout(() => check(engine), 0);\n}\n\n/** The `declared` hook: a path a binding or a `$watch` key names. */\nfunction declared(engine: Engine, p: Pattern, watch = false): void {\n note(engine, p, watch ? WATCH : BINDING);\n}\n\nfunction note(engine: Engine, p: Pattern, kind: number): void {\n // a missing top-level key already fails the binding's read (the core's error)\n if (p.path[0] === \"$\" || p.path.includes(\"#\") || (kind === BINDING && p.parent === null)) return;\n let map = named.get(engine);\n if (map === undefined) named.set(engine, (map = new Map()));\n if (!map.has(p)) map.set(p, kind);\n schedule(engine);\n}\n\nconst wrapped = new WeakSet<Engine>();\n/** A `$postUpdate` is running: what it lands is not a write (see written). */\nlet posting = false;\n\n/**\n * `$postUpdate(path)` says what at a path changed in place; a path that does not resolve updates nothing,\n * and said nothing (`rows.${r}.cell.${c}.text` for `cells` — a 7GUIs evaluation's Cells). Its pattern is\n * checked as a binding's is, the top-level key too (no read fails for it).\n */\nfunction watchPostUpdate(engine: Engine): void {\n if (wrapped.has(engine)) return;\n wrapped.add(engine);\n const api = (engine as any).api as Record<string, (path: string) => void>;\n const post = api.$postUpdate;\n api.$postUpdate = (path: string) => {\n posting = true;\n try {\n post(path);\n } finally {\n posting = false;\n }\n const p = engine.patterns.peek(parsePath(path).pattern);\n if (p !== undefined) note(engine, p, POST);\n };\n}\n\n/** The top-level keys a state declared (its own and its prototypes'), and those written since, by engine. */\nconst declaredKeys = new WeakMap<Engine, Set<string>>();\n\n/**\n * A write of a top-level key the state did not declare, beside a near one it did (`this.selectedID` and\n * `selectedId`): 4.0 creates the key, and nothing bound to the declared one changes (a 7GUIs evaluation's\n * CRUD). Warned once per key; a key with no near name is one the state adds on purpose.\n */\nfunction written(engine: Engine, p: Pattern): void {\n const keys = declaredKeys.get(engine);\n const key = p.last;\n if (p.parent !== null || posting || keys === undefined || keys.has(key) || key[0] === \"$\" || engine.dropped.has(key)) return;\n const near = didYouMean(key, [...keys]);\n keys.add(key);\n // (a volume grafts its state at its mount path, and the keys on the way to it: those keys are the page's)\n if (near !== \"\" && ![...((engine.root as ParentNode | undefined)?.querySelectorAll(`${config.tagNames.state}[mount]`) ?? [])]\n .some((e) => `${e.getAttribute(\"mount\")}.`.startsWith(`${key}.`))) {\n console.warn(`[@wcstack/state] [wcs/write-path-missing] \"${key}\" is not declared: writing it creates a new key.${near}${LINT_HINT}`);\n }\n}\n\n// ---------------------------------------------------------------- commands that reach nothing\n\n/**\n * A command token emitted while nothing subscribes to it: the call is lost, and tokens keep nothing to replay.\n * Its `command.` binding may not be attached yet — the element is defined later (an autoloader, a slow CDN),\n * or it is in an `if:` branch the same update renders (emit from `$renderedCallback`) — or there is none.\n * Warned once per token (the author's decision, docs/v4-direction-2026-10.md §5.2 — a 7GUIs evaluation's Timer\n * and Cells). The engine's `commands` is watched from its first declaration on, so the tokens of a re-set\n * are wrapped too.\n */\nfunction watchCommands(engine: Engine): void {\n if (Object.getOwnPropertyDescriptor(engine, \"commands\")?.set !== undefined) return;\n let ns = engine.commands;\n Object.defineProperty(engine, \"commands\", {\n configurable: true,\n get: () => ns,\n set: (v: Readonly<Record<string, Token>>) => {\n ns = v;\n for (const t of Object.values(v)) loud(t);\n },\n });\n}\n\nconst wrappedTokens = new WeakSet<Token>();\n\nfunction loud(t: Token): void {\n if (wrappedTokens.has(t)) return;\n wrappedTokens.add(t);\n const emit = t.emit;\n let said = false;\n (t as any).emit = (...args: unknown[]): unknown[] => {\n if (t.size === 0 && !said) {\n said = true;\n console.warn(`[@wcstack/state] [wcs/command-token-unbound] \"$command.${t.name}\" was emitted with no subscriber and is lost: its element is not defined or rendered yet (emit from $renderedCallback), or no command. binding takes it.${LINT_HINT}`);\n }\n return emit.apply(t, args);\n };\n}\n\n/** The handlers whose failure was explained, by engine. */\nconst explained = new WeakMap<Engine, Set<string>>();\n\n/**\n * The handler of a delegated `on<type>:` threw, and it reads `event.currentTarget`: that is the root there,\n * not the element (`getBoundingClientRect` is not a function, a `.value` is undefined). Said once per handler,\n * after the error (the author's decision, docs/v4-direction-2026-10.md §5.2 — a 7GUIs evaluation).\n */\nfunction handlerThrew(engine: Engine, path: string, type: string): void {\n let v: any = engine.target;\n for (const seg of path.split(\".\")) v = v == null ? undefined : findDescriptor(v, seg)?.value;\n if (typeof v !== \"function\" || !String(v).includes(\"currentTarget\")) return;\n let said = explained.get(engine);\n if (said === undefined) explained.set(engine, (said = new Set()));\n if (said.has(path)) return;\n said.add(path);\n console.warn(`[@wcstack/state] [wcs/delegated-current-target] \"${path}\" reads event.currentTarget, the root for a delegated on${type}:. Write on${type}#direct:, or use event.target.closest(…).${LINT_HINT}`);\n}\n\n/**\n * A drain made patterns (`loose`, before its sweep): a getter may have read a path for the first time — in a\n * row added since, or down a branch of its own code. Checked as the bindings' are; a drain that read no new\n * path schedules nothing.\n */\nfunction drained(engine: Engine): void {\n if (named.has(engine) && ((engine as any).loose as Pattern[]).length > 0) schedule(engine);\n}\n\n/** A re-set: every path is checked again against the new state. */\nfunction recheck(engine: Engine): void {\n checked.delete(engine);\n if (named.has(engine)) schedule(engine);\n}\n\n// ---------------------------------------------------------------- recursion's static checks\n\n/**\n * `$recursion` families that can never work (approved simplification: these checks moved out of\n * the core): a suffix naming the recursion structure itself, two families one of which is the\n * other a few repeats deeper, and a concrete key that one of the families expands to.\n */\nfunction checkRecursion(target: Record<string, any>): void {\n const decl = target.$recursion;\n if (decl === null || typeof decl !== \"object\") return;\n const entries = Object.entries(decl);\n if (entries.length !== 1 || typeof entries[0][1] !== \"string\") return;\n const [anchor, repeat] = entries[0] as [string, string];\n if (!anchor.endsWith(\".*\") || !repeat.endsWith(\".*\")) return;\n const list = anchor.slice(0, -2);\n const key = repeat.slice(0, -2);\n const step = `.${repeat}`;\n const head = `${list}.**`;\n const keys = keysOf(target);\n const families = keys.filter((k) => k.startsWith(head)).map((k) => k.slice(head.length));\n const bad = (why: string): never => raiseError(`[wcs/recursion-declaration-invalid] ${why}`);\n for (const s of families) {\n if (s === `.${key}` || s.startsWith(`.${key}.`)) {\n bad(`\"${head}${s}\" names the recursion structure itself (the \"${key}\" lists): recursive getters compute values over the nodes.`);\n }\n for (const t of families) {\n if (t.length > s.length && t.endsWith(s) && new RegExp(`^(?:${esc(step)})+$`).test(t.slice(0, t.length - s.length))) {\n bad(`\"${head}${s}\" and \"${head}${t}\" expand to the same concrete path at different depths (they differ by whole repetitions of \"${repeat}\"). Rename one of them.`);\n }\n }\n const re = new RegExp(`^${esc(anchor)}(?:${esc(step)})*${esc(s)}$`);\n for (const k of keys) {\n if (!k.includes(\"**\") && re.test(k)) bad(`\"${k}\" is already defined on the state, so the recursive getter \"${head}${s}\" cannot expand to it.`);\n }\n }\n}\n\nconst esc = (s: string): string => s.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\nlet trustedTypesReported = false;\n\n/**\n * An HTML sink write Trusted Types blocked: the browser's message names no fix, so say once\n * per page what to install (the same report as @wcstack/state 3.3).\n */\nfunction failed(_engine: Engine, error: unknown, binding: Binding): void {\n const prop = binding.name === \"html\" ? \"innerHTML\" : binding.name;\n if (trustedTypesReported || !(error instanceof TypeError) || !isHtmlSink(prop) || !(\"trustedTypes\" in globalThis)) return;\n trustedTypesReported = true;\n const cause = typeof getTrustedTypesPolicy()?.createHTML === \"function\"\n ? \"The injected policy's createHTML() did not return a TrustedHTML.\"\n : \"No sanitizing policy is installed, and @wcstack/state deliberately does not pass state values through an identity policy — that would defeat the CSP.\";\n console.error(\n `[@wcstack/state] Writing to \"${prop}\" was blocked by Trusted Types (require-trusted-types-for 'script'). ${cause}\\n`\n + `Install a sanitizing policy before the first binding is applied:\\n`\n + ` globalThis[Symbol.for(\"wcstack.trustedTypes.policy\")] =\\n`\n + ` trustedTypes.createPolicy(\"my-app\", { createHTML: (s) => DOMPurify.sanitize(s) });\\n`\n + `Or bind the value as text instead of HTML. See docs/csp.md section 7.`,\n { element: binding.node, property: prop },\n );\n}\n\n// ---------------------------------------------------------------- the default getter\n\nconst warnedDetail = new WeakMap<Element, Set<string>>();\n\n/**\n * A wc-bindable property's event read with the default getter (`e.detail`): warns once per\n * element and property about the two shapes that cannot be what the element meant (README\n * \"What the element writes back\", as @wcstack/state 3.3). The write is applied as it is.\n * (a) no detail while the element's property has a value — a plain Event, or a forgotten detail;\n * (b) a detail object with a `<name>` key while the property is not an object — a wrapper.\n */\nfunction detail(el: Element, name: string, v: unknown): void {\n const prop = (el as any)[name];\n const reason = v === undefined\n ? prop === undefined ? null : `the event carried no detail (undefined) while element.${name} is ${typeof prop}`\n : v !== null && typeof v === \"object\" && Object.prototype.hasOwnProperty.call(v, name) && (prop === null || typeof prop !== \"object\")\n ? `the event's detail is an object with a \"${name}\" key while element.${name} is ${typeof prop}`\n : null;\n if (reason === null) return;\n let said = warnedDetail.get(el);\n if (said === undefined) warnedDetail.set(el, (said = new Set()));\n if (said.has(name)) return;\n said.add(name);\n console.warn(\n `[@wcstack/state] [wcs/default-getter-mismatch] <${el.localName}> \"${name}\": ${reason}. `\n + \"With no getter, state receives e.detail as-is. Dispatch the value itself as detail, or declare \"\n + `getter (e.g. (e) => e.detail.${name}, or (e) => e.target.${name}) on that wcBindable property.`,\n );\n}\n\n// ---------------------------------------------------------------- 3.x names 4.0 removed\n\n/**\n * Declarations 3.2 renamed, whose old names 4.0 removed: a declaration under one would do nothing.\n * (The core detected these and the two APIs below up to 4.0.0-rc.3; without this add-on they are\n * ignored like any other unknown `$` key.)\n */\nconst REMOVED_DECLARATIONS: [string, string][] = [[\"$streams\", \"$stream\"], [\"$updatedCallback\", \"$renderedCallback\"]];\n/** APIs 3.2 renamed, whose old names 4.0 removed: reading one fails with the name to write. */\nconst REMOVED_APIS: Readonly<Record<string, string>> = { \"$trackDependency\": \"$dependOn\", \"$untrackDependency\": \"$untracked\" };\n\n/** A state that declares a 3.x name 4.0 removed (`$scan` has no successor: $watch or $on). */\nfunction removedDeclarations(target: Record<string, any>): void {\n if (target.$scan !== undefined) raise(M.ScanRemoved);\n for (const [old, name] of REMOVED_DECLARATIONS) if (target[old] !== undefined) raise(M.DeclarationRemoved, [old, name]);\n}\n\nexport const diagnostics: Feature = {\n name: \"diagnostics\",\n install(): void {\n hooks.explain = explain;\n hooks.render = render;\n hooks.declared = declared;\n hooks.detail = detail;\n hooks.failed = chain(hooks.failed, failed);\n // the removed names first, before what is installed (the core checked them before it took the\n // state in): a refused state never reaches the other add-ons' runtimes\n const prev = hooks.declare;\n hooks.declare = (engine, target) => {\n removedDeclarations(target);\n prev?.(engine, target);\n checkRecursion(target);\n recheck(engine);\n watchPostUpdate(engine);\n watchCommands(engine);\n declaredKeys.set(engine, new Set(keysOf(target)));\n };\n hooks.handlerThrew = handlerThrew;\n hooks.written = chain(hooks.written, written);\n hooks.drained = chain(hooks.drained, drained);\n hooks.dollar = first(known, hooks.dollar, (_engine, key) => (Object.hasOwn(REMOVED_APIS, key) ? raise(M.ApiRemoved, [key, REMOVED_APIS[key]]) : undefined));\n },\n};\nexport default diagnostics;\n"],"mappings":"mVAUA,SAASA,EAAaC,EAAWC,EAAWC,GAC1C,GAAIC,KAAKC,IAAIJ,EAAEK,OAASJ,EAAEI,QAAUH,EAClC,OAAOA,EAAM,EAEf,IAAMI,EAAiB,IAAIC,MAAMN,EAAEI,OAAS,GACtCG,EAAiB,IAAID,MAAMN,EAAEI,OAAS,GAC5C,QAASI,EAAI,EAAGA,GAAKR,EAAEI,OAAQI,IAC7BH,EAAKG,GAAKA,EAEZ,QAASC,EAAI,EAAGA,GAAKV,EAAEK,OAAQK,IAAK,CAClCF,EAAK,GAAKE,EACV,QAASD,EAAI,EAAGA,GAAKR,EAAEI,OAAQI,IAAK,CAClC,IAAME,EAAOX,EAAEU,EAAI,KAAOT,EAAEQ,EAAI,GAAK,EAAI,EACzCD,EAAKC,GAAKN,KAAKS,IAAIN,EAAKG,GAAK,EAAGD,EAAKC,EAAI,GAAK,EAAGH,EAAKG,EAAI,GAAKE,EACjE,CACA,QAASF,EAAI,EAAGA,GAAKR,EAAEI,OAAQI,IAC7BH,EAAKG,GAAKD,EAAKC,EAEnB,CACA,OAAOH,EAAK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EAAMY,GAAU/D,EAAMmD,EAAMY,GAASA,GACrCZ,EAAMsB,GAAUzE,EAAMmD,EAAMsB,GAASA,GACrCtB,EAAM+E,GAAShH,EAAMiH,EAAOhF,EAAM+E,GAAQ,CAACpD,EAAStK,IAASoD,OAAOC,OAAOmI,GAAcxL,GAAO+L,OAAoB,CAAC/L,EAAKwL,GAAaxL,UAAS,EAClJ,GAEK4N,GAAQjC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["editDistance","a","b","max","Math","abs","length","prev","Array","curr","j","i","cost","min","didYouMean","input","candidates","folded","toLowerCase","best","bestDistance","candidate","distance","LINT_HINT","CODES","codeOf","id","c","MOVED","was","v","String","Date","isArray","JSON","stringify","slice","NAMESPACES","element","tag","at","map","join","CSP_GUIDE","SENTENCES","p","parent","name","n","MAX_DRAIN_PASSES","MAX_RENDER_CHAIN","type","kind","src","status","detail","key","reserved","limit","fn","modifier","value","init","where","includes","l","t","keyword","prop","quote","args","f","trailing","lastIndexOf","source","mods","ns","given","api","depth","what","startsWith","method","allowed","over","loop","old","render","sentence","LINT_CODES","Set","GUIDES","RENAMED_FILTERS","inc","dec","fix","uc","lc","cap","rep","rev","pad","null","explain","message","subject","out","to","Object","hasOwn","removedFilter","re","text","m","exec","replace","_","Number","split","FORMATS_FILTER_NAMES","some","hasFilter","code","has","test","named","WeakMap","checked","due","WeakSet","settled","findDescriptor","o","x","prototype","getPrototypeOf","d","getOwnPropertyDescriptor","keysOf","k","getOwnPropertyNames","add","missing","engine","chain","q","unshift","segs","path","findIndex","s","indexOf","target","get","patterns","peek","parsePath","pattern","wildcardForm","getter","under","last","first","row","seg","names","push","dropped","g","all","set","schedule","setTimeout","delete","done","todo","Map","readers","dependents","find","markup","root","querySelectorAll","config","tagNames","state","e","getAttribute","initializePromise","then","w","rowGetter","loops","lists","near","hooks","noticed","missingSegment","console","warn","check","declared","watch","note","wrapped","posting","declaredKeys","written","keys","wrappedTokens","loud","emit","said","size","apply","explained","handlerThrew","drained","loose","esc","trustedTypesReported","failed","_engine","error","binding","TypeError","isHtmlSink","globalThis","cause","getTrustedTypesPolicy","createHTML","node","property","warnedDetail","el","reason","hasOwnProperty","call","localName","REMOVED_DECLARATIONS","REMOVED_APIS","$trackDependency","$untrackDependency","diagnostics","install","declare","$scan","raise","removedDeclarations","decl","$recursion","entries","anchor","repeat","endsWith","list","step","head","families","filter","bad","why","raiseError","RegExp","checkRecursion","recheck","post","$postUpdate","watchPostUpdate","commands","defineProperty","configurable","values","watchCommands","dollar","known","diagnostics_default"],"sources":["../../../src/diagnostics/guidance.ts","../../../src/diagnostics/messages.ts","../../../src/diagnostics/explain.ts","../../../src/features/diagnostics.ts"],"sourcesContent":["/**\n * diagnostics/guidance.ts — self-fix guidance for error messages, ported verbatim from\n * `@wcstack/state` (`errorGuidance.ts`). Only the diagnostics add-on uses it: the core's\n * messages state the fact, and the add-on appends this.\n *\n * The did-you-mean criteria (edit distance 2, ties go to the first candidate, case folded) are the\n * same as lint's suggestion, so the console, lint and the IDE never propose different names.\n */\n\n/** Insert / delete / substitute edit distance. Returns max + 1 early when the lengths differ by more than max. */\nfunction editDistance(a: string, b: string, max: number): number {\n if (Math.abs(a.length - b.length) > max) {\n return max + 1;\n }\n const prev: number[] = new Array(b.length + 1);\n const curr: number[] = new Array(b.length + 1);\n for (let j = 0; j <= b.length; j++) {\n prev[j] = j;\n }\n for (let i = 1; i <= a.length; i++) {\n curr[0] = i;\n for (let j = 1; j <= b.length; j++) {\n const cost = a[i - 1] === b[j - 1] ? 0 : 1;\n curr[j] = Math.min(prev[j] + 1, curr[j - 1] + 1, prev[j - 1] + cost);\n }\n for (let j = 0; j <= b.length; j++) {\n prev[j] = curr[j];\n }\n }\n return prev[b.length];\n}\n\n/**\n * The nearest candidate within edit distance 2 as ` Did you mean \"<best>\"?`, or `\"\"` when there is\n * none. An empty input (a trailing `a|` pipe) gets no suggestion.\n */\nexport function didYouMean(input: string, candidates: Iterable<string>): string {\n if (input.length === 0) {\n return \"\";\n }\n const folded = input.toLowerCase();\n let best: string | null = null;\n let bestDistance = 3;\n for (const candidate of candidates) {\n const distance = editDistance(folded, candidate.toLowerCase(), 2);\n if (distance < bestDistance) {\n best = candidate;\n bestDistance = distance;\n }\n }\n return best !== null ? ` Did you mean \"${best}\"?` : \"\";\n}\n\n/**\n * The pointer to lint. Attach it **only where lint actually detects the case** — a hint that sends\n * the author to a lint run that comes back clean costs the loop its credibility.\n */\nexport const LINT_HINT = \" Validate statically: npx @wcstack/lint <file>.\";\n","/**\n * The sentences of the core's numbered messages (src/messages.ts), in the diagnostics add-on:\n * the core carries the number and the values, this renders what the core used to say. Each\n * sentence follows its `[wcs/<code>] ` (`codeOf`: the code the hundreds of the number name).\n * `Record<M, …>` makes a number without a sentence a type error.\n */\nimport { M } from \"../messages\";\nimport { MAX_DRAIN_PASSES, MAX_INDEX_PARAM, MAX_RENDER_CHAIN } from \"../engine\";\nimport { MAX_PATH_SEGMENTS, MODIFIER_SEPARATOR, RECURSION_WILDCARD } from \"../parser/define\";\n\ntype Sentence = (...a: any[]) => string;\n\n/**\n * The code of each hundred of message numbers (\"\" = none): the code lint and the VS Code extension\n * report for the same case. The core carried this up to 4.0.0-rc.3; without this add-on a message\n * now reads as its number and values alone.\n */\nexport const CODES = [\n \"\", \"binding-syntax\", \"template-syntax\", \"binding-path-missing\", \"binding-type-expectation\",\n \"filter-unknown\", \"filter-arity\", \"getter-cycle\", \"getter-depth-exceeded\", \"index-arity\",\n \"index-param-range\", \"recursion-unsupported\", \"token-misconfigured\", \"token-undeclared\",\n \"wildcard-rank\", \"spread-no-bindable\", \"declaration-alias\", \"name-alias\",\n];\n\n/** `[wcs/<code>] ` for a message number, or \"\" when it has none. */\nexport const codeOf = (id: M): string => {\n const c = CODES[(id / 100) | 0];\n return c ? `[wcs/${c}] ` : \"\";\n};\n\n/** The options 4.0 moved from `bootstrapState` to the state's `$behavior`. */\nconst MOVED = [\"enableMustache\", \"sameValueGuard\", \"enableDirectionalInitialSync\"];\n\n/** `<tag a=\"v\" …>` from the tag and its attributes' names and values. */\n/** What a value given to a filter was (`a string (\"2026-10-13T…\")`), for the type messages. */\nconst was = (v: unknown): string =>\n v == null ? String(v)\n : v instanceof Date ? \"a Date\"\n : Array.isArray(v) ? \"an array\"\n : typeof v === \"string\" ? `a string (${JSON.stringify(v.length > 32 ? v.slice(0, 32) + \"…\" : v)})`\n : typeof v === \"object\" ? \"an object\" : `a ${typeof v} (${String(v)})`;\n/** The namespace a binding of kind 2–4 (dom/view.ts: K_CLASS, K_ATTR, K_STYLE) names its member under. */\nconst NAMESPACES = [\"\", \"\", \"class.\", \"attr.\", \"style.\"];\n\nconst element = (tag: string, at: string[]): string => `<${tag}${at.map((a, i) => (i % 2 ? `=\"${a}\"` : ` ${a}`)).join(\"\")}>`;\n\nconst CSP_GUIDE = \"https://github.com/wcstack/wcstack/blob/main/docs/csp.md\";\n\nexport const SENTENCES: Record<M, Sentence> = {\n [M.ScanRemoved]: () => \"$scan was removed (use $watch or $on)\",\n [M.GetterWithoutSetter]: (p) => `\"${p}\" is a getter without a setter`,\n [M.NoRow]: (p) => `no row for \"${p}\"`,\n [M.ParentNotObject]: (p, parent) => `cannot write \"${p}\": its parent is ${parent}`,\n [M.NotAMethod]: (name) => `\"${name}\" is not a method`,\n [M.GetAllNoCommonLevel]: (p) => `$getAll(\"${p}\"): no loop level in common with the context`,\n [M.EqIndexNoRow]: (p) => `$eqIndex(\"${p}\") needs a list row scope.`,\n [M.Readonly]: () => \"This state is readonly.\",\n [M.SetAllNeedsIndexes]: (p) => `$setAll(\"${p}\") needs indexes ([] for every match)`,\n [M.SetAllSpreadLength]: (p, n) => `$setAll(\"${p}\", …, { spread: true }) needs an array of ${n} values`,\n [M.DrainNotSettled]: () => `updates did not settle after ${MAX_DRAIN_PASSES} passes`,\n [M.RenderChain]: () => `render chain depth limit exceeded (${MAX_RENDER_CHAIN} drains that rendering itself started); bindings for this batch were not applied.`,\n // (named as written — `textContent: iso`, `class.active: x` — when the binding has a member; else its type)\n [M.BindingFailed]: (type, p, name, kind) => `binding \"${name ? (NAMESPACES[kind] ?? \"\") + name : type}: ${p}\" failed to apply.`,\n [M.LoadFailed]: (src, status) => `failed to load \"${src}\": ${status}`,\n [M.ElementFailed]: () => \"this <wcs-state> failed to initialize; create a new one\",\n [M.NotInitialized]: () => \"state is not initialized\",\n [M.NoScript]: (id) => `no <script> with id \"${id}\"`,\n [M.InlineBlocked]: () => `The inline <script> of <wcs-state> was blocked by Content-Security-Policy. Inline state is evaluated through a blob: URL: give the page's nonce to the <script> that loads @wcstack/state, or allow blob: in script-src. Moving the state into an external file (src=\"./state.js\") needs neither. See ${CSP_GUIDE}`,\n [M.InlineFailed]: (detail) => `Failed to evaluate the inline <script> of <wcs-state>: ${detail}. If this page sets a Content-Security-Policy, see ${CSP_GUIDE}`,\n [M.TokenSubscriberThrew]: (name) => `a subscriber of token \"${name}\" threw.`,\n [M.TokenListNotArray]: (key) => `${key} must be an array of strings.`,\n [M.TokenEntryEmpty]: (key) => `${key} entries must be non-empty strings.`,\n [M.TokenEntryReserved]: (key, name, reserved) => `${key} entry \"${name}\" conflicts with the reserved namespace name \"${reserved}\".`,\n [M.TokenEntryDuplicated]: (key, name) => `${key} entry \"${name}\" is duplicated.`,\n [M.OnNotObject]: () => \"$on must be an object of handlers.\",\n [M.OnEntryUndeclared]: (name) => `$on entry \"${name}\" is not declared in $eventTokens.`,\n [M.OnEntryNotFunction]: (name) => `$on entry \"${name}\" must be a function.`,\n [M.NamingLimit]: (limit) => `view-transition naming-limit (${limit}) reached.`,\n [M.FilterOptionsRequired]: (fn) => `filter ${fn} requires at least one option`,\n [M.FilterOptionNotNumber]: (fn) => `filter ${fn} requires a number as option`,\n [M.FilterValueNotNumber]: (fn, v) => `filter ${fn} requires a number value, not ${was(v)}${typeof v === \"string\" ? ` — put |number before |${fn}, or convert it where it is read` : \"\"}`,\n [M.FilterValueNotDate]: (fn, v) => `filter ${fn} requires a date value (a Date), not ${was(v)}${typeof v === \"string\" || typeof v === \"number\" ? \" — make the Date where it is read: a getter returning new Date(…)\" : \"\"}`,\n [M.FilterStyleInvalid]: (fn, v) => `filter ${fn} takes a style of full, long, medium or short, not \"${v}\"`,\n [M.FilterCurrencyInvalid]: (v) => `filter currency takes an ISO 4217 currency code (JPY, USD, EUR), not \"${v}\"`,\n [M.FilterValueNotArray]: (fn) => `filter ${fn} requires an array value`,\n [M.DirectionalSyncDisabled]: () => \"init=/sync= modifiers require enableDirectionalInitialSync.\",\n [M.ModifierUnknown]: (key, modifier) => `Unknown binding modifier \"${key}\" in \"${modifier}\".`,\n [M.ModifierTwice]: (key) => `Binding modifier \"${key}\" may only be specified once.`,\n [M.ModifierValue]: (key, value) => `Invalid ${key} modifier value \"${value}\".`,\n [M.EventInitNone]: () => \"Event bindings only allow init=none.\",\n [M.InitUnsupported]: (type, init) => `Binding type \"${type}\" does not support init=${init}.`,\n [M.MemberUndeclared]: (name) => `Property \"${name}\" is not declared by wcBindable.`,\n [M.InitIncompatible]: (init, name) => `init=${init} is incompatible with wcBindable member \"${name}\".`,\n [M.SyncConnectNeedsOutput]: (name) => `sync=connect requires observable property \"${name}\".`,\n [M.OptionInvalid]: (where, key) => `${where}: \"${key}\" is not one of its options, or not of the option's type.${where === \"bootstrapState\" && MOVED.includes(key) ? \" 4.0 moved it to the state's $behavior.\" : \"\"}`,\n [M.BehaviorChanged]: () => \"a re-set state may not change $behavior: create the element again.\",\n [M.SecondRoot]: () => \"a second <wcs-state> on the same root: there is one state tree per root — graft a subtree with <wcs-state mount=\\\"path\\\"> (v1's name=\\\"…\\\" is gone: read the mounted state by its path).\",\n [M.LocaleInvalid]: (l) => `the locale \"${l}\" (<html lang> or bootstrapState's locale) is not a language tag Intl takes (en-US, not en_US): the locale filters use \"en\".`,\n [M.FeaturesNotArray]: () => '$features must be an array of add-on names ([\"temporal\", \"formats\"]).',\n [M.InitFailed]: (tag, ...at) => `${element(tag, at)} failed to initialize.`,\n [M.ConnectedFailed]: (tag, ...at) => `${element(tag, at)} $connectedCallback failed.`,\n [M.DisconnectedFailed]: (tag, ...at) => `${element(tag, at)} $disconnectedCallback failed.`,\n\n [M.BindTextNoColon]: (t) => `Invalid bindText: \"${t}\". Missing ':' separator between propPart and statePart.`,\n [M.StructuralTakesNoModifiers]: (t, keyword) => `\"${t}\": \"${keyword}\" takes no modifiers or filters on its left side — write \"${keyword}:\".`,\n [M.ElseTakesNoValue]: (t) => `\"${t}\": \"else\" takes no value — write \"else:\".`,\n [M.SpreadNoPath]: (t) => `Invalid spread binding \"${t}\": spread target path is required.`,\n [M.SpreadNoFilters]: (t) => `Invalid spread binding \"${t}\": filters are not allowed on spread targets.`,\n [M.LeadingDotNamespace]: (prop) => `\"${prop}\": a leading \".\" binds an element property by name — write a non-empty property that is not a namespace (class, attr, style, command, eventToken, state).`,\n [M.UnterminatedQuote]: (quote, args) => `unterminated ${quote} quote in the filter arguments \"(${args})\". Close the quote.`,\n [M.FilterUnclosed]: (f) => `Invalid filter format: missing closing parenthesis in \"${f}\".`,\n [M.FilterUnopened]: (f) => `Invalid filter format: missing opening parenthesis in \"${f}\".`,\n [M.FilterParenOrder]: (f) => `Invalid filter format: \")\" comes before \"(\" in \"${f}\".`,\n [M.FilterTrailing]: (f, trailing) => `\"${f}\": unexpected \"${trailing}\" after the filter's closing \")\" — separate filters with \"|\" (write \"${f.slice(0, f.lastIndexOf(\")\") + 1)}|${trailing}\").`,\n [M.FilterEmpty]: (source) => `an empty filter in \"${source}\" — remove the extra \"|\" or name the filter.`,\n [M.FilterNameHasModifiersInput]: (name, mods) => `\"${name}\" is not a filter name: a modifier list \"${MODIFIER_SEPARATOR}${mods}\" comes before the input filters, not inside one`,\n [M.FilterNameHasModifiersOutput]: (name) => `\"${name}\" is not a filter name: \"${MODIFIER_SEPARATOR}\" cannot appear in one.`,\n [M.OneModifierList]: (prop) => `\"${prop}\": a binding takes one modifier list after a single \"#\"`,\n [M.NoPropertyName]: (prop) => `\"${prop}\": the left side of a binding must name a property — write \"<property>: <path>\" (modifiers and input filters come after the name).`,\n [M.TooManySegments]: (p, n) => `\"${p}\" has ${n} path segments — the limit is ${MAX_PATH_SEGMENTS}.`,\n [M.SelectorRemoved]: (t) => `\"${t}\": the \"@name\" selector was removed in v2 — there is a single state tree. Mount the named state onto the tree (<wcs-state mount=\"...\">) and read it by its path prefix instead.`,\n [M.UnsafeSegment]: (p) => `\"${p}\": a state path cannot go through \"__proto__\" or \"prototype\" (it would reach every object's prototype).`,\n [M.ForNoFilters]: (t) => `\"${t}\": \"for:\" takes no filters — a row is \"<path>.<index>\", so the rows of a filtered list would name other elements. Declare a getter that returns the filtered list and loop over it (\"for: <getter>\").`,\n [M.NamespaceNeedsName]: (t, ns) => ns === \"class\"\n ? `\"${t}\": \"class:\" needs a class name — \"class.NAME:\" toggles one class (a bare \"class:\" would set an element property named \"class\", which does nothing). To set the whole class attribute, bind \"className:\".`\n : `\"${t}\": \"attr:\" needs an attribute name — \"attr.NAME:\" sets one attribute (a bare \"attr:\" would set an element property named \"attr\", which does nothing).`,\n [M.EmptySegment]: (t) => `\"${t}\": the right side of a binding must name a state path — write \"<property>: <path>\" (a path segment cannot be empty; \".\" alone and a leading \".\" are the loop-relative shorthand).`,\n\n [M.StructuralNotSingle]: (t) => `Invalid bindText: \"${t}\". 'if', 'elseif', 'else', and 'for' bindings must be single binding.`,\n [M.ElseWithoutIf]: (type) => `\"${type}:\" must follow an \"if:\" template`,\n [M.TemplateHandedOver]: (type) => `a \"${type}:\" template at the top of inserted content was not rendered, as it would render beside itself out of the inserter's reach: wrap it in an element.`,\n [M.OuterInTemplate]: (name) => `\"${name}:\" replaces its element, so it cannot be used inside a \"for\" / \"if\" template (a row or branch keeps its nodes by position): bind innerHTML: on a wrapper element instead.`,\n\n [M.PathMissing]: (p) => `Path \"${p}\" does not exist on the state tree.`,\n\n [M.ClassNeedsBoolean]: (name, type) => `class.${name} needs a boolean, got ${type}.`,\n\n [M.FilterUnknown]: (name) => `filter not found: ${name}.`,\n\n [M.FilterTooFewArgs]: (name, min, given) => `filter \"${name}\" requires at least ${min} argument(s) (${given} given).`,\n [M.FilterTooManyArgs]: (name, max, given) => `filter \"${name}\" accepts at most ${max} argument(s) (${given} given).`,\n\n [M.GetterCycle]: (p) => `\"${p}\" depends on itself`,\n\n [M.GetterDepth]: (p) => `\"${p}\"`,\n\n [M.IndexArityExact]: (api, p, depth, n) => `${api}(\"${p}\") takes ${depth} index(es), got ${n}.`,\n [M.IndexArityAtMost]: (api, p, depth, n) => `${api}(\"${p}\") takes at most ${depth} index(es), got ${n}.`,\n\n [M.IndexParamRange]: (key) => `\"${key}\": list index parameters run from $1 to $${MAX_INDEX_PARAM}.`,\n\n [M.RecursionUnsupported]: (p) => `\"${p}\" uses \"${RECURSION_WILDCARD}\", which is not accepted here.`,\n\n [M.CommandRightSide]: (prop, p) => `\"${prop}: ${p}\": the right-hand side must be $command.<name>`,\n // a native element's command (no hyphen: never a custom element) is the native-commands add-on's\n [M.NoBindable]: (tag, what) => `<${tag}> declares no static wcBindable (${what}).${\n !tag.includes(\"-\") && what.startsWith(\"command.\") ? \" A native element's command needs the add-on @wcstack/state/features/native-commands.\" : \"\"}`,\n [M.NoCommand]: (tag, method) => `<${tag}> declares no command \"${method}\".`,\n [M.NoProperty]: (tag, prop) => `<${tag}> declares no property \"${prop}\".`,\n [M.NativeNoCommand]: (tag, method, allowed) => `<${tag}> has no command \"${method}\" (a native <${tag}>'s commands: ${allowed}).`,\n\n [M.EventTokenUndeclared]: (name) => `eventToken \"${name}\" is not declared in $eventTokens.`,\n [M.CommandTokenUndeclared]: (name) => `\"$command.${name}\" is not declared in $commandTokens.`,\n\n [M.WildcardNoLoop]: (p, depth, n = 0) => `\"${p}\" needs ${depth} enclosing loop level(s); the scope provides ${n}.`,\n [M.WildcardRelative]: (p) => `\"${p}\" is relative: it needs an enclosing \"for\" template`,\n [M.WildcardOtherList]: (p, over, loop) => `\"${p}\" ranges over the rows of \"${over}\", but the enclosing \"for\" template at that level renders \"${loop}\".`,\n\n [M.SpreadNoBindable]: (tag, what) => `<${tag}> declares no static wcBindable (${what}).`,\n\n [M.DeclarationRemoved]: (old, name) => `${old} was removed: write ${name}.`,\n\n [M.ApiRemoved]: (old, name) => `${old} was removed: write ${name}.`,\n};\n","/**\n * The diagnostics add-on's sentences and guidance: a numbered core message rendered as its\n * sentence (src/diagnostics/messages.ts), then how to fix it, the nearest name and the lint\n * pointer. The add-on installs these; so does `@wcstack/state/parser`, a bundle of its own.\n */\nimport { didYouMean, LINT_HINT } from \"./guidance\";\nimport { FORMATS_FILTER_NAMES, hasFilter } from \"../filters/registry\";\nimport type { M } from \"../messages\";\nimport { codeOf, SENTENCES } from \"./messages\";\n\n/** A numbered core message as its sentence (the number and the values if it is not known here). */\nexport function render(id: number, args: readonly unknown[]): string {\n const sentence = SENTENCES[id as M];\n return sentence === undefined ? `${codeOf(id)}#${id} ${args.join(\" \")}` : codeOf(id) + sentence(...args);\n}\n\n/** Codes lint detects statically: only these point the author to a lint run. */\nconst LINT_CODES = new Set([\n \"binding-syntax\", \"template-syntax\", \"filter-unknown\", \"filter-arity\", \"index-arity\",\n \"wildcard-rank\", \"token-undeclared\", \"binding-path-missing\", \"index-param-range\",\n]);\n\n/** How to fix it, by what the message says. */\nconst GUIDES: [RegExp, string][] = [\n [/no loop level in common with the context/, \"; pass indexes ([] for all).\"],\n [/\"([^\"#]+)#([^\"]*)\" is not a filter name: a modifier list .* comes before the input filters/, ' — write \"<property>#$2|$1\".'],\n [/\\[wcs\\/recursion-unsupported\\]/, \" It is only meaningful in a $recursion declaration, in a recursive getter key, and in the path argument of $getAll / $setAll — and only when the state declares a $recursion anchor.\"],\n [/must be single binding/, ' Put the structural binding alone in its own data-wcs (e.g. <template data-wcs=\"for: items\">).'],\n [/\\[wcs\\/wildcard-rank\\] .* needs \\d+ enclosing/, ' Wrap it in that many \"for\" templates, or use $resolve(path, indexes) to name the row explicitly.'],\n [/\\[wcs\\/wildcard-rank\\] .* ranges over the rows of/, ' A \"*\" in a binding is the row of the loop around it: read a row of another list in a getter, with $resolve(path, indexes).'],\n [/\\[wcs\\/binding-type-expectation\\] class\\.([^ ]+)/, ' Write \"class.$1: path|truthy\" to toggle on truthiness.'],\n [/path segments — the limit/, \" Every prefix of a path is interned, so the cost grows with the square of the depth.\"],\n [/\\[wcs\\/index-arity\\] \\$resolve/, \" $resolve takes one index per \\\"*\\\"; $getAll / $setAll take at most that many (fewer expands the rest).\"],\n [/\"([^\"#]+)#[^\"]*\" is not a filter name: \"#\" cannot appear in one/, ' Modifiers belong on the left side of the binding, before the \":\" — write \"$1\" here.'],\n];\n\n/**\n * The filter names 3.2 renamed, which 3.x kept as aliases and 4.0 removed (3.x's `filterAliases`;\n * lint has the same table). Their message names the replacement, not the nearest name: for these\n * that is an unrelated filter (`dec` → `eq`, `fix` → `div`), and following it changes the meaning.\n */\nexport const RENAMED_FILTERS: Readonly<Record<string, string>> = {\n inc: \"add\", dec: \"sub\", fix: \"toFixed\", uc: \"upper\", lc: \"lower\", cap: \"capitalize\", rep: \"repeat\", rev: \"reverse\", pad: \"padStart\", null: \"nullIfEmpty\",\n};\n\n/** How to write a filter 4.0 removed, or null. */\nfunction removedFilter(name: string): string | null {\n // 4.0 folded substr(start, length) into slice(start, end): the second argument changes meaning\n if (name === \"substr\") return ' \"substr\" was removed in 4.0 — write slice(start, start + length): slice takes the end index, not a length.';\n const to = Object.hasOwn(RENAMED_FILTERS, name) ? RENAMED_FILTERS[name] : null;\n return to === null ? null : ` \"${name}\" was renamed \"${to}\" in 3.2 and removed in 4.0 — write \"${to}\".`;\n}\n\nexport function explain(message: string, subject?: string, candidates?: Iterable<string>): string {\n const removed = subject !== undefined && message.includes(\"[wcs/filter-unknown]\") ? removedFilter(subject) : null;\n let out = removed ?? (subject !== undefined && candidates !== undefined ? didYouMean(subject, candidates) : \"\");\n for (const [re, text] of GUIDES) {\n const m = re.exec(message);\n if (m !== null) out += text.replace(/\\$(\\d)/g, (_, i: string) => m[Number(i)]);\n }\n // \"value#ro#wo\": one modifier list — the fix joins them\n const mods = /\"([^\"#]+)#([^\"]+)\": a binding takes one modifier list/.exec(message);\n if (mods !== null) out += ` — write \"${mods[1]}#${mods[2].split(\"#\").join(\",\")}\".`;\n // a formatting filter on a page without the formats add-on (the core names installFeatures), or a\n // typo on a page with no formatting filters at all: the formats add-on may be what is missing\n if (message.includes(\"[wcs/filter-unknown]\")) {\n if (message.includes(\"formats add-on\")) out += ` On a split auto page: features=\"formats\" on the root, or \"$features\": [\"formats\"].`;\n else if (!FORMATS_FILTER_NAMES.some(hasFilter)) {\n out += ` No formatting filters are installed — add the formats add-on: installFeatures([formats]) from \"@wcstack/state/features/formats\" (a split auto page: features=\"formats\", or \"$features\").`;\n }\n }\n const code = /\\[wcs\\/([\\w-]+)\\]/.exec(message);\n // (not something lint reports: the path-length limit is a runtime cost, a template handed over at\n // the top of inserted content (#204) is the page's order of loading, not its markup, and lint's\n // manifest knows the formatting filters — one missing because the formats add-on is not installed\n // is the page's. A row of another list (#1403) and an `outerHTML:` in a template (#203) lint does\n // report, as of its 4.0 parser)\n if (code !== null && LINT_CODES.has(code[1]) && !/ path segments — the limit is |inserted content was not rendered|formats add-on/.test(message)) out += LINT_HINT;\n return out;\n}\n","/**\n * The diagnostics add-on (@wcstack/state/features/diagnostics): the sentences and the self-fix\n * guidance of error messages. The core states the message number and the values\n * (`#901 \"$resolve\" \"m.*.*\" 2 1`); with this installed, the message is the code shared with lint\n * and the sentence (`[wcs/index-arity] $resolve(\"m.*.*\") takes 2 index(es), got 1.`), followed by the\n * nearest name (did-you-mean, the same rule as lint), how to fix it, and a pointer to lint where\n * lint really detects the case. The full `auto` bundle installs it.\n */\nimport { chain, first, hooks, known, type Feature } from \"../hooks\";\nimport type { Engine } from \"../engine\";\nimport { parsePath, type Pattern } from \"../pattern\";\nimport { raiseError } from \"../parser/raiseError\";\nimport { config } from \"../config\";\nimport type { WcsState } from \"../element\";\nimport type { Binding } from \"../dom/view\";\nimport { getTrustedTypesPolicy, isHtmlSink } from \"../trustedTypes\";\nimport { didYouMean, LINT_HINT } from \"../diagnostics/guidance\";\nimport { explain, render } from \"../diagnostics/explain\";\nimport { raise, M } from \"../messages\";\nimport type { Token } from \"../token\";\n\n// ---------------------------------------------------------------- paths that do not resolve\n\n/** What named a path: a binding, a `$watch` key, a `$postUpdate` call, a getter's read. */\nconst BINDING = 0;\nconst WATCH = 1;\nconst POST = 2;\nconst READ = 3;\n/** Paths bindings, `$watch` keys and `$postUpdate` named, by engine: checked one macrotask later (and after a re-set). */\nconst named = new WeakMap<Engine, Map<Pattern, number>>();\nconst checked = new WeakMap<Engine, Set<Pattern>>();\nconst due = new WeakSet<Engine>();\n/** Volumes (`<wcs-state mount>`) whose loading settled: the paths under them are checked from then on. */\nconst settled = new WeakSet<Element>();\n\nfunction findDescriptor(o: object, key: string): PropertyDescriptor | undefined {\n for (let x: object | null = o; x !== null && x !== Object.prototype; x = Object.getPrototypeOf(x)) {\n const d = Object.getOwnPropertyDescriptor(x, key);\n if (d !== undefined) return d;\n }\n return undefined;\n}\n\nfunction keysOf(o: object): string[] {\n const out = new Set<string>();\n for (let x: object | null = o; x !== null && x !== Object.prototype; x = Object.getPrototypeOf(x)) {\n for (const k of Object.getOwnPropertyNames(x)) if (k[0] !== \"$\" && k !== \"constructor\") out.add(k);\n }\n return [...out];\n}\n\n/**\n * The pattern a path with an explicit index reads through: an index with no `*` after it\n * (`items.0.x`) has an accessor of its own (Engine.markupAccessor), so whether it reads a getter\n * is the question of the pattern it names (`items.*.x`). A `*` after the index (`groups.0.items.*.x`,\n * a row of `for: groups.0.items`) reads its row's own item: the pattern itself. So does a path the\n * author declared a getter under (`get \"groups.0.items\"()`): that getter is what it reads (#388).\n */\nfunction wildcardForm(engine: Engine, q: Pattern): Pattern | undefined {\n const segs = q.path.split(\".\");\n // (a leading numeric segment is a root key, not an index: parsePath)\n const i = segs.findIndex((s, j) => j > 0 && /^\\d/.test(s));\n return i < 0 || segs.indexOf(\"*\", i) >= 0 || findDescriptor(engine.target, q.path)?.get !== undefined\n ? q : engine.patterns.peek(parsePath(q.path).pattern);\n}\n\n/**\n * The segment of `p` that certainly does not exist, with the names that do at its level; null\n * when the path exists or it cannot be told without evaluating a getter (a getter on the way, a\n * null or primitive on the way, a list with no row to look into).\n */\nfunction missing(engine: Engine, p: Pattern): { seg: string; names: string[]; row: boolean } | null {\n const chain: Pattern[] = [];\n for (let q: Pattern | null = p; q !== null; q = q.parent) chain.unshift(q);\n const named = (q: Pattern | null): Pattern | null | undefined => (q === null ? null : wildcardForm(engine, q));\n // a getter anywhere on the path answers it — also one declared deeper than a segment the data\n // lacks (\\`get \"box.label\"()\\` with no \\`box\\` key: it renders and updates — docs/seam-apps.md)\n if (chain.some((q) => named(q)?.getter != null)) return null;\n return under(engine, chain, 0, engine.target, named);\n}\n\n/** `missing` from `chain[k]` on, in `v`. */\nfunction under(engine: Engine, chain: Pattern[], k: number, v: any, named: (q: Pattern | null) => Pattern | null | undefined): { seg: string; names: string[]; row: boolean } | null {\n for (; k < chain.length; k++) {\n const q = chain[k];\n if (v === null || typeof v !== \"object\") return null;\n if (q.last === \"*\") {\n if (!Array.isArray(v) || v.length === 0) return null;\n // a row field is declared when any row has it — an optional one (`pending` on the rows a page\n // added itself) is not missing because the first row lacks it (docs/seam-apps.md, ssr-news)\n // (missing in every row: the names any row has are the candidates)\n let first: { seg: string; names: string[]; row: boolean } | null = null;\n for (const row of v) {\n const m = under(engine, chain, k + 1, row, named);\n if (m === null) return null;\n if (first === null) first = m;\n else if (m.seg === first.seg) for (const n of m.names) if (!first.names.includes(n)) first.names.push(n);\n }\n return first;\n }\n if (Array.isArray(v) && /^\\d+$/.test(q.last)) {\n // an explicit index: only a row that is there can be looked into\n if (Number(q.last) >= v.length) return null;\n v = v[Number(q.last)];\n continue;\n }\n const d = findDescriptor(v, q.last);\n // a top-level key a re-set dropped is declared: it reads undefined, and a write fills it\n if (d === undefined && q.parent === null && engine.dropped.has(q.last)) return null;\n if (d === undefined) {\n const names = keysOf(v);\n // getters declared one level under the same parent (`items.*.subtotal`)\n const parent = named(q.parent);\n for (const g of engine.patterns.all()) if (g.parent === parent && g.getter !== null) names.push(g.last);\n return { seg: q.last, names, row: chain.slice(0, k).some((x) => x.last === \"*\") };\n }\n if (d.get !== undefined || d.set !== undefined) return null;\n v = d.value;\n }\n return null;\n}\n\nfunction check(engine: Engine): void {\n due.delete(engine);\n const map = named.get(engine);\n if (map === undefined) return;\n let done = checked.get(engine);\n if (done === undefined) checked.set(engine, (done = new Set()));\n // The paths named, and those a getter read (`this[\"items.*.pirce\"]`, `$getAll(\"items.*.pirce\")`): such a read\n // gets undefined, and what is computed from it is wrong without a word (an outside evaluation, a tax return\n // draft). A top-level key the state lacks already fails the read (the core's error); a named path is reported\n // as named; the engine's own accessor of an index path (`items.0.x`) reads for the binding that named it\n const todo = new Map(map);\n const readers = new Map<Pattern, Pattern>();\n for (const p of engine.patterns.all()) {\n const g = p.parent === null || done.has(p) || map.has(p) ? undefined : p.dependents.find((d) => !d.markup);\n if (g === undefined) continue;\n readers.set(p, g);\n todo.set(p, READ);\n }\n for (const [p, kind] of todo) {\n if (done.has(p)) continue;\n done.add(p);\n const m = missing(engine, p);\n if (m === null) continue;\n // under the mount path of a volume on the page still loading: checked again once it settles (3.x D22)\n const v = [...((engine.root as ParentNode | null)?.querySelectorAll(`${config.tagNames.state}[mount]`) ?? [])]\n .find((e) => !settled.has(e) && (p.path + \".\").startsWith(e.getAttribute(\"mount\") + \".\"));\n if (v !== undefined) {\n done.delete(p);\n void (v as WcsState).initializePromise.then(() => {\n settled.add(v);\n schedule(engine);\n });\n continue;\n }\n // a row of `for: groups.0.items` with a row getter declared on `groups.*.items.*` (#388)\n const w = engine.patterns.peek(parsePath(p.path).pattern);\n let rowGetter = \"\";\n if (w !== undefined && w !== p && w.getter !== null) {\n const loops = w.lists.slice(1).map((l, k) => `for: ${k === 0 ? l!.path : l!.path.slice(w.lists[k]!.path.length + 2)}`);\n rowGetter = ` The getter \"${w.path}\" is declared for the rows of ${loops.join(\" → \")}; a list named by an index has rows of its own.`;\n }\n const near = didYouMean(m.seg, m.names);\n // A row field no row has is not a sign of a mistake: rows are data, and an optional field (the\n // `pending` a page puts on its own rows) is absent from the server's (docs/seam-apps.md, ssr-news).\n // Reported only with a near name — a likely typo (`.nmae` beside `name`) — or a row getter of\n // another list form. So is a getter's read: `this[\"opts.flag\"] ?? false` reads an optional key on purpose\n if ((m.row || kind === READ) && near === \"\" && rowGetter === \"\") continue;\n const [code, subject, source] = kind === WATCH ? [\"watch-path-missing\", \"$watch path\", \"watch\"]\n : kind === POST ? [\"post-update-path-missing\", \"$postUpdate path\", \"postUpdate\"]\n : kind === READ ? [\"read-path-missing\", \"Path\", \"getter\"]\n : [\"binding-path-missing\", \"Bound path\", \"binding\"];\n hooks.noticed?.(engine, { \"type\": \"state:path-unresolved\", \"source\": source, \"path\": p.path, \"missingSegment\": m.seg });\n console.warn(`[@wcstack/state] [wcs/${code}] ${subject} \"${p.path}\"${kind === READ ? ` read by the getter \"${readers.get(p)!.path}\"` : \"\"} does not resolve on the state tree: \"${m.seg}\" is not declared.${near}${rowGetter} ${kind === POST ? \"The call updates nothing.\" : kind === READ ? \"The getter reads undefined.\" : \"Updates to this path will be silently dropped.\"}${LINT_HINT}`);\n }\n}\n\nfunction schedule(engine: Engine): void {\n if (due.has(engine)) return;\n due.add(engine);\n setTimeout(() => check(engine), 0);\n}\n\n/** The `declared` hook: a path a binding or a `$watch` key names. */\nfunction declared(engine: Engine, p: Pattern, watch = false): void {\n note(engine, p, watch ? WATCH : BINDING);\n}\n\nfunction note(engine: Engine, p: Pattern, kind: number): void {\n // a missing top-level key already fails the binding's read (the core's error)\n if (p.path[0] === \"$\" || p.path.includes(\"#\") || (kind === BINDING && p.parent === null)) return;\n let map = named.get(engine);\n if (map === undefined) named.set(engine, (map = new Map()));\n if (!map.has(p)) map.set(p, kind);\n schedule(engine);\n}\n\nconst wrapped = new WeakSet<Engine>();\n/** A `$postUpdate` is running: what it lands is not a write (see written). */\nlet posting = false;\n\n/**\n * `$postUpdate(path)` says what at a path changed in place; a path that does not resolve updates nothing,\n * and said nothing (`rows.${r}.cell.${c}.text` for `cells` — a 7GUIs evaluation's Cells). Its pattern is\n * checked as a binding's is, the top-level key too (no read fails for it).\n */\nfunction watchPostUpdate(engine: Engine): void {\n if (wrapped.has(engine)) return;\n wrapped.add(engine);\n const api = (engine as any).api as Record<string, (path: string) => void>;\n const post = api.$postUpdate;\n api.$postUpdate = (path: string) => {\n posting = true;\n try {\n post(path);\n } finally {\n posting = false;\n }\n const p = engine.patterns.peek(parsePath(path).pattern);\n if (p !== undefined) note(engine, p, POST);\n };\n}\n\n/** The top-level keys a state declared (its own and its prototypes'), and those written since, by engine. */\nconst declaredKeys = new WeakMap<Engine, Set<string>>();\n\n/**\n * A write of a top-level key the state did not declare, beside a near one it did (`this.selectedID` and\n * `selectedId`): 4.0 creates the key, and nothing bound to the declared one changes (a 7GUIs evaluation's\n * CRUD). Warned once per key; a key with no near name is one the state adds on purpose.\n */\nfunction written(engine: Engine, p: Pattern): void {\n const keys = declaredKeys.get(engine);\n const key = p.last;\n if (p.parent !== null || posting || keys === undefined || keys.has(key) || key[0] === \"$\" || engine.dropped.has(key)) return;\n const near = didYouMean(key, [...keys]);\n keys.add(key);\n // (a volume grafts its state at its mount path, and the keys on the way to it: those keys are the page's)\n if (near !== \"\" && ![...((engine.root as ParentNode | undefined)?.querySelectorAll(`${config.tagNames.state}[mount]`) ?? [])]\n .some((e) => `${e.getAttribute(\"mount\")}.`.startsWith(`${key}.`))) {\n console.warn(`[@wcstack/state] [wcs/write-path-missing] \"${key}\" is not declared: writing it creates a new key.${near}${LINT_HINT}`);\n }\n}\n\n// ---------------------------------------------------------------- commands that reach nothing\n\n/**\n * A command token emitted while nothing subscribes to it: the call is lost, and tokens keep nothing to replay.\n * Its `command.` binding may not be attached yet — the element is defined later (an autoloader, a slow CDN),\n * or it is in an `if:` branch the same update renders (emit from `$renderedCallback`) — or there is none.\n * Warned once per token (the author's decision, docs/v4-direction-2026-10.md §5.2 — a 7GUIs evaluation's Timer\n * and Cells). The engine's `commands` is watched from its first declaration on, so the tokens of a re-set\n * are wrapped too.\n */\nfunction watchCommands(engine: Engine): void {\n if (Object.getOwnPropertyDescriptor(engine, \"commands\")?.set !== undefined) return;\n let ns = engine.commands;\n Object.defineProperty(engine, \"commands\", {\n configurable: true,\n get: () => ns,\n set: (v: Readonly<Record<string, Token>>) => {\n ns = v;\n for (const t of Object.values(v)) loud(t);\n },\n });\n}\n\nconst wrappedTokens = new WeakSet<Token>();\n\nfunction loud(t: Token): void {\n if (wrappedTokens.has(t)) return;\n wrappedTokens.add(t);\n const emit = t.emit;\n let said = false;\n (t as any).emit = (...args: unknown[]): unknown[] => {\n if (t.size === 0 && !said) {\n said = true;\n console.warn(`[@wcstack/state] [wcs/command-token-unbound] \"$command.${t.name}\" was emitted with no subscriber and is lost: its element is not defined or rendered yet (emit from $renderedCallback), or no command. binding takes it.${LINT_HINT}`);\n }\n return emit.apply(t, args);\n };\n}\n\n/** The handlers whose failure was explained, by engine. */\nconst explained = new WeakMap<Engine, Set<string>>();\n\n/**\n * The handler of a delegated `on<type>:` threw, and it reads `event.currentTarget`: that is the root there,\n * not the element (`getBoundingClientRect` is not a function, a `.value` is undefined). Said once per handler,\n * after the error (the author's decision, docs/v4-direction-2026-10.md §5.2 — a 7GUIs evaluation).\n */\nfunction handlerThrew(engine: Engine, path: string, type: string): void {\n let v: any = engine.target;\n for (const seg of path.split(\".\")) v = v == null ? undefined : findDescriptor(v, seg)?.value;\n if (typeof v !== \"function\" || !String(v).includes(\"currentTarget\")) return;\n let said = explained.get(engine);\n if (said === undefined) explained.set(engine, (said = new Set()));\n if (said.has(path)) return;\n said.add(path);\n console.warn(`[@wcstack/state] [wcs/delegated-current-target] \"${path}\" reads event.currentTarget, the root for a delegated on${type}:. Write on${type}#direct:, or use event.target.closest(…).${LINT_HINT}`);\n}\n\n/**\n * A drain made patterns (`loose`, before its sweep): a getter may have read a path for the first time — in a\n * row added since, or down a branch of its own code. Checked as the bindings' are; a drain that read no new\n * path schedules nothing.\n */\nfunction drained(engine: Engine): void {\n if (named.has(engine) && ((engine as any).loose as Pattern[]).length > 0) schedule(engine);\n}\n\n/** A re-set: every path is checked again against the new state. */\nfunction recheck(engine: Engine): void {\n checked.delete(engine);\n if (named.has(engine)) schedule(engine);\n}\n\n// ---------------------------------------------------------------- recursion's static checks\n\n/**\n * `$recursion` families that can never work (approved simplification: these checks moved out of\n * the core): a suffix naming the recursion structure itself, two families one of which is the\n * other a few repeats deeper, and a concrete key that one of the families expands to.\n */\nfunction checkRecursion(target: Record<string, any>): void {\n const decl = target.$recursion;\n if (decl === null || typeof decl !== \"object\") return;\n const entries = Object.entries(decl);\n if (entries.length !== 1 || typeof entries[0][1] !== \"string\") return;\n const [anchor, repeat] = entries[0] as [string, string];\n if (!anchor.endsWith(\".*\") || !repeat.endsWith(\".*\")) return;\n const list = anchor.slice(0, -2);\n const key = repeat.slice(0, -2);\n const step = `.${repeat}`;\n const head = `${list}.**`;\n const keys = keysOf(target);\n const families = keys.filter((k) => k.startsWith(head)).map((k) => k.slice(head.length));\n const bad = (why: string): never => raiseError(`[wcs/recursion-declaration-invalid] ${why}`);\n for (const s of families) {\n if (s === `.${key}` || s.startsWith(`.${key}.`)) {\n bad(`\"${head}${s}\" names the recursion structure itself (the \"${key}\" lists): recursive getters compute values over the nodes.`);\n }\n for (const t of families) {\n if (t.length > s.length && t.endsWith(s) && new RegExp(`^(?:${esc(step)})+$`).test(t.slice(0, t.length - s.length))) {\n bad(`\"${head}${s}\" and \"${head}${t}\" expand to the same concrete path at different depths (they differ by whole repetitions of \"${repeat}\"). Rename one of them.`);\n }\n }\n const re = new RegExp(`^${esc(anchor)}(?:${esc(step)})*${esc(s)}$`);\n for (const k of keys) {\n if (!k.includes(\"**\") && re.test(k)) bad(`\"${k}\" is already defined on the state, so the recursive getter \"${head}${s}\" cannot expand to it.`);\n }\n }\n}\n\nconst esc = (s: string): string => s.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\nlet trustedTypesReported = false;\n\n/**\n * An HTML sink write Trusted Types blocked: the browser's message names no fix, so say once\n * per page what to install (the same report as @wcstack/state 3.3).\n */\nfunction failed(_engine: Engine, error: unknown, binding: Binding): void {\n const prop = binding.name === \"html\" ? \"innerHTML\" : binding.name;\n if (trustedTypesReported || !(error instanceof TypeError) || !isHtmlSink(prop) || !(\"trustedTypes\" in globalThis)) return;\n trustedTypesReported = true;\n const cause = typeof getTrustedTypesPolicy()?.createHTML === \"function\"\n ? \"The injected policy's createHTML() did not return a TrustedHTML.\"\n : \"No sanitizing policy is installed, and @wcstack/state deliberately does not pass state values through an identity policy — that would defeat the CSP.\";\n console.error(\n `[@wcstack/state] Writing to \"${prop}\" was blocked by Trusted Types (require-trusted-types-for 'script'). ${cause}\\n`\n + `Install a sanitizing policy before the first binding is applied:\\n`\n + ` globalThis[Symbol.for(\"wcstack.trustedTypes.policy\")] =\\n`\n + ` trustedTypes.createPolicy(\"my-app\", { createHTML: (s) => DOMPurify.sanitize(s) });\\n`\n + `Or bind the value as text instead of HTML. See docs/csp.md section 7.`,\n { element: binding.node, property: prop },\n );\n}\n\n// ---------------------------------------------------------------- the default getter\n\nconst warnedDetail = new WeakMap<Element, Set<string>>();\n\n/**\n * A wc-bindable property's event read with the default getter (`e.detail`): warns once per\n * element and property about the two shapes that cannot be what the element meant (README\n * \"What the element writes back\", as @wcstack/state 3.3). The write is applied as it is.\n * (a) no detail while the element's property has a value — a plain Event, or a forgotten detail;\n * (b) a detail object with a `<name>` key while the property is not an object — a wrapper.\n */\nfunction detail(el: Element, name: string, v: unknown): void {\n const prop = (el as any)[name];\n const reason = v === undefined\n ? prop === undefined ? null : `the event carried no detail (undefined) while element.${name} is ${typeof prop}`\n : v !== null && typeof v === \"object\" && Object.prototype.hasOwnProperty.call(v, name) && (prop === null || typeof prop !== \"object\")\n ? `the event's detail is an object with a \"${name}\" key while element.${name} is ${typeof prop}`\n : null;\n if (reason === null) return;\n let said = warnedDetail.get(el);\n if (said === undefined) warnedDetail.set(el, (said = new Set()));\n if (said.has(name)) return;\n said.add(name);\n console.warn(\n `[@wcstack/state] [wcs/default-getter-mismatch] <${el.localName}> \"${name}\": ${reason}. `\n + \"With no getter, state receives e.detail as-is. Dispatch the value itself as detail, or declare \"\n + `getter (e.g. (e) => e.detail.${name}, or (e) => e.target.${name}) on that wcBindable property.`,\n );\n}\n\n// ---------------------------------------------------------------- 3.x names 4.0 removed\n\n/**\n * Declarations 3.2 renamed, whose old names 4.0 removed: a declaration under one would do nothing.\n * (The core detected these and the two APIs below up to 4.0.0-rc.3; without this add-on they are\n * ignored like any other unknown `$` key.)\n */\nconst REMOVED_DECLARATIONS: [string, string][] = [[\"$streams\", \"$stream\"], [\"$updatedCallback\", \"$renderedCallback\"]];\n/** APIs 3.2 renamed, whose old names 4.0 removed: reading one fails with the name to write. */\nconst REMOVED_APIS: Readonly<Record<string, string>> = { \"$trackDependency\": \"$dependOn\", \"$untrackDependency\": \"$untracked\" };\n\n/** A state that declares a 3.x name 4.0 removed (`$scan` has no successor: $watch or $on). */\nfunction removedDeclarations(target: Record<string, any>): void {\n if (target.$scan !== undefined) raise(M.ScanRemoved);\n for (const [old, name] of REMOVED_DECLARATIONS) if (target[old] !== undefined) raise(M.DeclarationRemoved, [old, name]);\n}\n\nexport const diagnostics: Feature = {\n name: \"diagnostics\",\n hooks,\n install(): void {\n hooks.explain = explain;\n hooks.render = render;\n hooks.declared = declared;\n hooks.detail = detail;\n hooks.failed = chain(hooks.failed, failed);\n // the removed names first, before what is installed (the core checked them before it took the\n // state in): a refused state never reaches the other add-ons' runtimes\n const prev = hooks.declare;\n hooks.declare = (engine, target) => {\n removedDeclarations(target);\n prev?.(engine, target);\n checkRecursion(target);\n recheck(engine);\n watchPostUpdate(engine);\n watchCommands(engine);\n declaredKeys.set(engine, new Set(keysOf(target)));\n };\n hooks.handlerThrew = handlerThrew;\n hooks.written = chain(hooks.written, written);\n hooks.drained = chain(hooks.drained, drained);\n hooks.dollar = first(known, hooks.dollar, (_engine, key) => (Object.hasOwn(REMOVED_APIS, key) ? raise(M.ApiRemoved, [key, REMOVED_APIS[key]]) : undefined));\n },\n};\nexport default diagnostics;\n"],"mappings":"mVAUA,SAASA,EAAaC,EAAWC,EAAWC,GAC1C,GAAIC,KAAKC,IAAIJ,EAAEK,OAASJ,EAAEI,QAAUH,EAClC,OAAOA,EAAM,EAEf,IAAMI,EAAiB,IAAIC,MAAMN,EAAEI,OAAS,GACtCG,EAAiB,IAAID,MAAMN,EAAEI,OAAS,GAC5C,QAASI,EAAI,EAAGA,GAAKR,EAAEI,OAAQI,IAC7BH,EAAKG,GAAKA,EAEZ,QAASC,EAAI,EAAGA,GAAKV,EAAEK,OAAQK,IAAK,CAClCF,EAAK,GAAKE,EACV,QAASD,EAAI,EAAGA,GAAKR,EAAEI,OAAQI,IAAK,CAClC,IAAME,EAAOX,EAAEU,EAAI,KAAOT,EAAEQ,EAAI,GAAK,EAAI,EACzCD,EAAKC,GAAKN,KAAKS,IAAIN,EAAKG,GAAK,EAAGD,EAAKC,EAAI,GAAK,EAAGH,EAAKG,EAAI,GAAKE,EACjE,CACA,QAASF,EAAI,EAAGA,GAAKR,EAAEI,OAAQI,IAC7BH,EAAKG,GAAKD,EAAKC,EAEnB,CACA,OAAOH,EAAKL,EAAEI,OAChB,CAMO,SAASQ,EAAWC,EAAeC,GACxC,GAAqB,IAAjBD,EAAMT,OACR,MAAO,GAET,IAAMW,EAASF,EAAMG,cACjBC,EAAsB,KACtBC,EAAe,EACnB,QAAWC,KAAaL,EAAY,CAClC,IAAMM,EAAWtB,EAAaiB,EAAQI,EAAUH,cAAe,GAC3DI,EAAWF,IACbD,EAAOE,EACPD,EAAeE,EAEnB,CACA,OAAgB,OAATH,EAAgB,kBAAkBA,MAAW,EACtD,CAMO,IAAMI,EAAY,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installFeatures([temporal, diagnostics])` before the state is defined. */
|
|
17
17
|
interface Feature {
|
|
18
18
|
readonly name: string;
|
|
19
|
+
/** The slots of the build it comes from: it fills only those (the core checks they are its own). */
|
|
20
|
+
readonly hooks: object;
|
|
19
21
|
install(): void;
|
|
20
22
|
}
|
|
21
23
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as t,b as r,c as e,d as a,e as n,f as o,g as i,h as l,i as c,j as y,k as u}from"../chunks/chunk-
|
|
1
|
+
import{a as t,b as r,c as e,d as a,e as n,f as o,g as i,h as l,i as c,j as y,k as u}from"../chunks/chunk-IBGHHABS.js";import{a as s,e as f}from"../chunks/chunk-P3EXTBXC.js";import{a as p}from"../chunks/chunk-DRSAQE4E.js";import{a as d}from"../chunks/chunk-BCL75PFH.js";var m,g=t=>r=>{let e=t(r);return t=>null==t?t:e(t)},S="en";function h(){if(s.locale!==m){m=s.locale;try{S=Intl.getCanonicalLocales(m)[0]}catch{console.warn(`[@wcstack/state] ${p(48,[m])}`),S="en"}}return S}var b=["full","long","medium","short"];function $(t,e){let[a,n]=t??[];return void 0===n&&void 0!==a&&b.includes(a)&&([a,n]=[void 0,a]),void 0!==n&&!b.includes(n)&&r(e,n),[a,n]}var{eq:k,ne:v,not:M,lt:j,le:w,gt:F,ge:C,falsy:D,truthy:L,boolean:x}=u,E={toFixed:{factory:t=>{let r=i(t?.[0]??"0","toFixed");return t=>("number"!=typeof t&&a("toFixed",t),t.toFixed(r))},arity:[0,1]},locale:{factory:t=>{let r=t?.[0];return t=>("number"!=typeof t&&a("locale",t),t.toLocaleString(r??h()))},arity:[0,1]},upper:{factory:g(()=>t=>String(t).toUpperCase()),arity:[0,0]},lower:{factory:g(()=>t=>String(t).toLowerCase()),arity:[0,0]},capitalize:{factory:g(()=>t=>{let r=String(t);return 0===r.length?r:1===r.length?r.toUpperCase():r.charAt(0).toUpperCase()+r.slice(1)}),arity:[0,0]},trim:{factory:g(()=>t=>String(t).trim()),arity:[0,0]},slice:{factory:g(t=>{let r=[l(t,0,"slice")],e=t?.[1];return typeof e<"u"&&r.push(i(e,"slice")),t=>String(t).slice(...r)}),arity:[1,2]},padStart:{factory:g(t=>{let r=l(t,0,"padStart"),e=t?.[1]??"0";return t=>String(t).padStart(r,e)}),arity:[1,2]},padEnd:{factory:g(t=>{let r=l(t,0,"padEnd"),e=t?.[1]??" ";return t=>String(t).padEnd(r,e)}),arity:[1,2]},repeat:{factory:g(t=>{let r=l(t,0,"repeat");return t=>String(t).repeat(r)}),arity:[1,1]},reverse:{factory:g(()=>t=>String(t).split("").reverse().join("")),arity:[0,0]},truncate:{factory:g(t=>{let r=l(t,0,"truncate"),e=t?.[1]??"…";return t=>{let a=String(t);return a.length<=r?a:a.slice(0,r)+e}}),arity:[1,2]},join:{factory:t=>{let r=t?.[0]??", ";return t=>(Array.isArray(t)||o("join"),t.join(r))},arity:[0,1]},round:{factory:t=>{let r=Math.pow(10,i(t?.[0]??"0","round"));return t=>("number"!=typeof t&&a("round",t),Math.round(t*r)/r)},arity:[0,1]},floor:{factory:t=>{let r=Math.pow(10,i(t?.[0]??"0","floor"));return t=>("number"!=typeof t&&a("floor",t),Math.floor(t*r)/r)},arity:[0,1]},ceil:{factory:t=>{let r=Math.pow(10,i(t?.[0]??"0","ceil"));return t=>("number"!=typeof t&&a("ceil",t),Math.ceil(t*r)/r)},arity:[0,1]},percent:{factory:t=>{let r=i(t?.[0]??"0","percent");return t=>("number"!=typeof t&&a("percent",t),`${(100*t).toFixed(r)}%`)},arity:[0,1]},unit:{factory:g(r=>{let e=r?.[0]??t("unit");return t=>String(t)+e}),arity:[1,1]},date:{factory:g(t=>{let[r,e]=$(t,"date"),a=e&&{dateStyle:e};return t=>(t instanceof Date||n("date",t),t.toLocaleDateString(r??h(),a))}),arity:[0,2]},time:{factory:g(t=>{let[r,e]=$(t,"time"),a=e&&{timeStyle:e};return t=>(t instanceof Date||n("time",t),t.toLocaleTimeString(r??h(),a))}),arity:[0,2]},datetime:{factory:g(t=>{let[r,e]=$(t,"datetime"),a=e&&{dateStyle:e,timeStyle:e};return t=>(t instanceof Date||n("datetime",t),t.toLocaleString(r??h(),a))}),arity:[0,2]},ymd:{factory:g(t=>{let r=t?.[0]??"-";return t=>{t instanceof Date||n("ymd",t);let e=t.getFullYear().toString(),a=(t.getMonth()+1).toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0");return`${e}${r}${a}${r}${o}`}}),arity:[0,1]},hms:{factory:g(t=>{let r=t?.[0]??":";return t=>{t instanceof Date||n("hms",t);let e=t.getHours().toString().padStart(2,"0"),a=t.getMinutes().toString().padStart(2,"0"),o=t.getSeconds().toString().padStart(2,"0");return`${e}${r}${a}${r}${o}`}}),arity:[0,1]},eq:k,ne:v,not:M,lt:j,le:w,gt:F,ge:C,add:y("add",(t,r)=>t+r),sub:y("sub",(t,r)=>t-r),mul:y("mul",(t,r)=>t*r),div:y("div",(t,r)=>t/r),mod:y("mod",(t,r)=>t%r),abs:{factory:()=>t=>("number"!=typeof t&&a("abs",t),Math.abs(t)),arity:[0,0]},clamp:{factory:t=>{let r=l(t,0,"clamp"),e=l(t,1,"clamp");return t=>("number"!=typeof t&&a("clamp",t),Math.min(Math.max(t,r),e))},arity:[2,2]},int:{factory:()=>t=>parseInt(String(t),10),arity:[0,0]},float:{factory:()=>t=>parseFloat(String(t)),arity:[0,0]},falsy:D,truthy:L,defaults:{factory:(r,e)=>{let a=r?.[0]??t("defaults"),n=c(a,e);return t=>t||n},arity:[1,1]},coalesce:{factory:(r,e)=>{let a=r?.[0]??t("coalesce"),n=c(a,e);return t=>t??n},arity:[1,1]},boolean:x,number:{factory:()=>t=>Number(t),arity:[0,0]},string:{factory:()=>t=>String(t),arity:[0,0]},nullIfEmpty:{factory:()=>t=>""===t?null:t,arity:[0,0]},currency:{factory:r=>{let n=r?.[0]??t("currency"),o=r?.[1],i={style:"currency",currency:n};try{new Intl.NumberFormat("en",i);let t=Intl.supportedValuesOf?.("currency");if(t&&!t.includes(n.toUpperCase()))throw 0}catch{e(n)}return t=>("number"!=typeof t&&a("currency",t),t.toLocaleString(o??h(),i))},arity:[1,2]}},I=!1,A={name:"formats",hooks:d,install:function(){I||(I=!0,f(E))}},B=A;export{B as default,A as formats};
|
|
2
2
|
//# sourceMappingURL=formats.js.map
|