@wcstack/state 4.1.1 → 4.3.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.
Files changed (60) hide show
  1. package/README.ja.md +23 -19
  2. package/README.md +23 -19
  3. package/dist/auto.min.js +1 -1
  4. package/dist/auto.min.js.map +1 -1
  5. package/dist/index.esm.js +1 -1
  6. package/dist/index.esm.js.map +1 -1
  7. package/dist/manifest.esm.js +78 -38
  8. package/dist/parser.esm.js +10 -4
  9. package/dist/split/auto.js +1 -1
  10. package/dist/split/chunks/chunk-2RBI6DVS.js +2 -0
  11. package/dist/split/chunks/chunk-2RBI6DVS.js.map +1 -0
  12. package/dist/split/chunks/chunk-5Q4M6A3C.js +2 -0
  13. package/dist/split/chunks/{chunk-7QVEF5E3.js → chunk-6I7GGFNJ.js} +2 -2
  14. package/dist/split/chunks/{chunk-7ZU3CLEG.js → chunk-BGUJ3HF6.js} +2 -2
  15. package/dist/split/chunks/chunk-BKLFDVOP.js +2 -0
  16. package/dist/split/chunks/chunk-BKLFDVOP.js.map +1 -0
  17. package/dist/split/chunks/{chunk-R5OJ52SF.js → chunk-CIBJLAA3.js} +2 -2
  18. package/dist/split/chunks/{chunk-R5OJ52SF.js.map → chunk-CIBJLAA3.js.map} +1 -1
  19. package/dist/split/chunks/chunk-DOWWBZVS.js +2 -0
  20. package/dist/split/chunks/chunk-F3DVWVH3.js +2 -0
  21. package/dist/split/chunks/chunk-F3DVWVH3.js.map +1 -0
  22. package/dist/split/chunks/chunk-M67C46SN.js +2 -0
  23. package/dist/split/chunks/{chunk-JZW5KGXQ.js.map → chunk-M67C46SN.js.map} +1 -1
  24. package/dist/split/chunks/chunk-NMOSSDKJ.js +2 -0
  25. package/dist/split/chunks/chunk-NMOSSDKJ.js.map +1 -0
  26. package/dist/split/chunks/{chunk-GGSHXG7N.js → chunk-UBGJGMSG.js} +2 -2
  27. package/dist/split/chunks/chunk-UBGJGMSG.js.map +1 -0
  28. package/dist/split/core.js +1 -1
  29. package/dist/split/features/devtools.js +1 -1
  30. package/dist/split/features/diagnostics.js +1 -1
  31. package/dist/split/features/diagnostics.js.map +1 -1
  32. package/dist/split/features/formats.d.ts +1 -1
  33. package/dist/split/features/formats.js +1 -1
  34. package/dist/split/features/formats.js.map +1 -1
  35. package/dist/split/features/list-keys.js +1 -1
  36. package/dist/split/features/native-commands.js +1 -1
  37. package/dist/split/features/recursion.js +1 -1
  38. package/dist/split/features/scopes.js +1 -1
  39. package/dist/split/features/ssr.js +1 -1
  40. package/dist/split/features/ssr.js.map +1 -1
  41. package/dist/split/features/temporal.js +1 -1
  42. package/dist/split/features/temporal.js.map +1 -1
  43. package/dist/wcs-manifest.json +29 -15
  44. package/package.json +1 -1
  45. package/dist/split/chunks/chunk-4HLDITUB.js +0 -2
  46. package/dist/split/chunks/chunk-4HLDITUB.js.map +0 -1
  47. package/dist/split/chunks/chunk-BWGPKDHS.js +0 -2
  48. package/dist/split/chunks/chunk-BWGPKDHS.js.map +0 -1
  49. package/dist/split/chunks/chunk-GGSHXG7N.js.map +0 -1
  50. package/dist/split/chunks/chunk-JAEYZSVS.js +0 -2
  51. package/dist/split/chunks/chunk-JZW5KGXQ.js +0 -2
  52. package/dist/split/chunks/chunk-UFIDBJBP.js +0 -2
  53. package/dist/split/chunks/chunk-UFIDBJBP.js.map +0 -1
  54. package/dist/split/chunks/chunk-V3HFN3MW.js +0 -2
  55. package/dist/split/chunks/chunk-V3HFN3MW.js.map +0 -1
  56. package/dist/split/chunks/chunk-XEGL4FW5.js +0 -2
  57. /package/dist/split/chunks/{chunk-XEGL4FW5.js.map → chunk-5Q4M6A3C.js.map} +0 -0
  58. /package/dist/split/chunks/{chunk-7QVEF5E3.js.map → chunk-6I7GGFNJ.js.map} +0 -0
  59. /package/dist/split/chunks/{chunk-7ZU3CLEG.js.map → chunk-BGUJ3HF6.js.map} +0 -0
  60. /package/dist/split/chunks/{chunk-JAEYZSVS.js.map → chunk-DOWWBZVS.js.map} +0 -0
@@ -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","element","tag","at","map","join","CSP_GUIDE","SENTENCES","p","parent","name","n","MAX_DRAIN_PASSES","MAX_RENDER_CHAIN","type","src","status","detail","key","reserved","limit","fn","modifier","value","init","where","includes","l","t","keyword","prop","quote","args","f","trailing","slice","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","v","target","segs","path","findIndex","s","indexOf","get","patterns","peek","parsePath","pattern","wildcardForm","getter","last","isArray","dropped","names","g","all","push","seg","set","schedule","setTimeout","delete","done","watch","root","querySelectorAll","config","tagNames","state","find","e","getAttribute","initializePromise","then","hooks","noticed","missingSegment","w","rowGetter","loops","lists","console","warn","check","declared","Map","esc","trustedTypesReported","failed","_engine","error","binding","TypeError","isHtmlSink","globalThis","cause","getTrustedTypesPolicy","createHTML","node","property","warnedDetail","el","reason","hasOwnProperty","call","said","localName","REMOVED_DECLARATIONS","REMOVED_APIS","$trackDependency","$untrackDependency","diagnostics","install","declare","$scan","raise","removedDeclarations","decl","$recursion","entries","anchor","repeat","endsWith","list","step","head","keys","families","filter","bad","why","raiseError","RegExp","checkRecursion","recheck","dollar","first","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. */\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 [M.BindingFailed]: (type, p) => `binding \"${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) => `filter ${fn} requires a number value`,\n [M.FilterValueNotDate]: (fn) => `filter ${fn} requires a date value`,\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\";\n\n// ---------------------------------------------------------------- paths that do not resolve\n\n/** Paths bindings and `$watch` keys named, by engine: checked one macrotask later (and after a re-set). */\nconst named = new WeakMap<Engine, Map<Pattern, boolean>>();\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[] } | null {\n const chain: Pattern[] = [];\n for (let q: Pattern | null = p; q !== null; q = q.parent) chain.unshift(q);\n let v: any = engine.target;\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 for (const q of chain) {\n if (v === null || typeof v !== \"object\") return null;\n if (q.last === \"*\") {\n if (!Array.isArray(v) || v.length === 0) return null;\n v = v[0];\n continue;\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 };\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 for (const [p, watch] of map) {\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 const [code, subject] = watch ? [\"watch-path-missing\", \"$watch path\"] : [\"binding-path-missing\", \"Bound path\"];\n hooks.noticed?.(engine, { \"type\": \"state:path-unresolved\", \"source\": watch ? \"watch\" : \"binding\", \"path\": p.path, \"missingSegment\": m.seg });\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 console.warn(`[@wcstack/state] [wcs/${code}] ${subject} \"${p.path}\" does not resolve on the state tree: \"${m.seg}\" is not declared.${didYouMean(m.seg, m.names)}${rowGetter} 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 // a missing top-level key already fails the binding's read (the core's error)\n if (p.path[0] === \"$\" || p.path.includes(\"#\") || (!watch && 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, watch);\n 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 };\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,EAA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,EAAS3B,EAClC,CA8HMsG,CAAQtG,IAEV0C,EAAM6D,GAASC,EAAMC,EAAO/D,EAAM6D,GAAQ,CAAC9C,EAASjJ,IAASqD,OAAOC,OAAO8G,EAAcpK,GAAO2K,OAAoB,CAAC3K,EAAKoK,EAAapK,UAAS,EAClJ,GAEKkM,EAAQ3B","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","watch","root","querySelectorAll","config","tagNames","state","find","e","getAttribute","initializePromise","then","hooks","noticed","missingSegment","w","rowGetter","loops","lists","console","warn","check","declared","Map","esc","trustedTypesReported","failed","_engine","error","binding","TypeError","isHtmlSink","globalThis","cause","getTrustedTypesPolicy","createHTML","node","property","warnedDetail","el","reason","hasOwnProperty","call","said","localName","REMOVED_DECLARATIONS","REMOVED_APIS","$trackDependency","$untrackDependency","diagnostics","install","declare","$scan","raise","removedDeclarations","decl","$recursion","entries","anchor","repeat","endsWith","list","step","head","keys","families","filter","bad","why","raiseError","RegExp","checkRecursion","recheck","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\";\n\n// ---------------------------------------------------------------- paths that do not resolve\n\n/** Paths bindings and `$watch` keys named, by engine: checked one macrotask later (and after a re-set). */\nconst named = new WeakMap<Engine, Map<Pattern, boolean>>();\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[] } | 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[] } | 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[] } | 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 };\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 for (const [p, watch] of map) {\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 const [code, subject] = watch ? [\"watch-path-missing\", \"$watch path\"] : [\"binding-path-missing\", \"Bound path\"];\n hooks.noticed?.(engine, { \"type\": \"state:path-unresolved\", \"source\": watch ? \"watch\" : \"binding\", \"path\": p.path, \"missingSegment\": m.seg });\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 console.warn(`[@wcstack/state] [wcs/${code}] ${subject} \"${p.path}\" does not resolve on the state tree: \"${m.seg}\" is not declared.${didYouMean(m.seg, m.names)}${rowGetter} 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 // a missing top-level key already fails the binding's read (the core's error)\n if (p.path[0] === \"$\" || p.path.includes(\"#\") || (!watch && 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, watch);\n 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 };\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,EAA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M6D,GAAQ,CAAC9C,EAASjJ,IAASoD,OAAOC,OAAO+G,EAAcpK,GAAO2K,OAAoB,CAAC3K,EAAKoK,EAAapK,UAAS,EAClJ,GAEKiM,EAAQ1B","ignoreList":[]}
@@ -20,7 +20,7 @@ interface Feature {
20
20
  }
21
21
 
22
22
  /**
23
- * The formats add-on (@wcstack/state/features/formats): the 37 filters that compute and show a value
23
+ * The formats add-on (@wcstack/state/features/formats): the 38 filters that compute and show a value
24
24
  * (display, string shaping, dates — locale-aware —, arithmetic, conversions, missing values).
25
25
  */
26
26
 
@@ -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}from"../chunks/chunk-BWGPKDHS.js";import{a as y,e as u}from"../chunks/chunk-R5OJ52SF.js";import{a as s}from"../chunks/chunk-GGSHXG7N.js";import"../chunks/chunk-7ZU3CLEG.js";var f,p=t=>r=>{let e=t(r);return t=>null==t?t:e(t)},d="en";function m(){if(y.locale!==f){f=y.locale;try{d=Intl.getCanonicalLocales(f)[0]}catch{console.warn(`[@wcstack/state] ${s(48,[f])}`),d="en"}}return d}var{eq:g,ne:S,not:h,lt:b,le:$,gt:M,ge:k,falsy:j,truthy:D,boolean:F}=c,w={toFixed:{factory:t=>{let e=n(t?.[0]??"0","toFixed");return t=>("number"!=typeof t&&r("toFixed"),t.toFixed(e))},arity:[0,1]},locale:{factory:t=>{let e=t?.[0];return t=>("number"!=typeof t&&r("locale"),t.toLocaleString(e??m()))},arity:[0,1]},upper:{factory:p(()=>t=>String(t).toUpperCase()),arity:[0,0]},lower:{factory:p(()=>t=>String(t).toLowerCase()),arity:[0,0]},capitalize:{factory:p(()=>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:p(()=>t=>String(t).trim()),arity:[0,0]},slice:{factory:p(t=>{let r=[o(t,0,"slice")],e=t?.[1];return typeof e<"u"&&r.push(n(e,"slice")),t=>String(t).slice(...r)}),arity:[1,2]},padStart:{factory:p(t=>{let r=o(t,0,"padStart"),e=t?.[1]??"0";return t=>String(t).padStart(r,e)}),arity:[1,2]},padEnd:{factory:p(t=>{let r=o(t,0,"padEnd"),e=t?.[1]??" ";return t=>String(t).padEnd(r,e)}),arity:[1,2]},repeat:{factory:p(t=>{let r=o(t,0,"repeat");return t=>String(t).repeat(r)}),arity:[1,1]},reverse:{factory:p(()=>t=>String(t).split("").reverse().join("")),arity:[0,0]},truncate:{factory:p(t=>{let r=o(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)||a("join"),t.join(r))},arity:[0,1]},round:{factory:t=>{let e=Math.pow(10,n(t?.[0]??"0","round"));return t=>("number"!=typeof t&&r("round"),Math.round(t*e)/e)},arity:[0,1]},floor:{factory:t=>{let e=Math.pow(10,n(t?.[0]??"0","floor"));return t=>("number"!=typeof t&&r("floor"),Math.floor(t*e)/e)},arity:[0,1]},ceil:{factory:t=>{let e=Math.pow(10,n(t?.[0]??"0","ceil"));return t=>("number"!=typeof t&&r("ceil"),Math.ceil(t*e)/e)},arity:[0,1]},percent:{factory:t=>{let e=n(t?.[0]??"0","percent");return t=>("number"!=typeof t&&r("percent"),`${(100*t).toFixed(e)}%`)},arity:[0,1]},unit:{factory:p(r=>{let e=r?.[0]??t("unit");return t=>String(t)+e}),arity:[1,1]},date:{factory:t=>{let r=t?.[0];return t=>(t instanceof Date||e("date"),t.toLocaleDateString(r??m()))},arity:[0,1]},time:{factory:t=>{let r=t?.[0];return t=>(t instanceof Date||e("time"),t.toLocaleTimeString(r??m()))},arity:[0,1]},datetime:{factory:t=>{let r=t?.[0];return t=>(t instanceof Date||e("datetime"),t.toLocaleString(r??m()))},arity:[0,1]},ymd:{factory:t=>{let r=t?.[0]??"-";return t=>{t instanceof Date||e("ymd");let a=t.getFullYear().toString(),n=(t.getMonth()+1).toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0");return`${a}${r}${n}${r}${o}`}},arity:[0,1]},hms:{factory:t=>{let r=t?.[0]??":";return t=>{t instanceof Date||e("hms");let a=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=t.getSeconds().toString().padStart(2,"0");return`${a}${r}${n}${r}${o}`}},arity:[0,1]},eq:g,ne:S,not:h,lt:b,le:$,gt:M,ge:k,add:l("add",(t,r)=>t+r),sub:l("sub",(t,r)=>t-r),mul:l("mul",(t,r)=>t*r),div:l("div",(t,r)=>t/r),mod:l("mod",(t,r)=>t%r),abs:{factory:()=>t=>("number"!=typeof t&&r("abs"),Math.abs(t)),arity:[0,0]},clamp:{factory:t=>{let e=o(t,0,"clamp"),a=o(t,1,"clamp");return t=>("number"!=typeof t&&r("clamp"),Math.min(Math.max(t,e),a))},arity:[2,2]},int:{factory:()=>t=>parseInt(String(t),10),arity:[0,0]},float:{factory:()=>t=>parseFloat(String(t)),arity:[0,0]},falsy:j,truthy:D,defaults:{factory:(r,e)=>{let a=r?.[0]??t("defaults"),n=i(a,e);return t=>t||n},arity:[1,1]},coalesce:{factory:(r,e)=>{let a=r?.[0]??t("coalesce"),n=i(a,e);return t=>t??n},arity:[1,1]},boolean:F,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]}},x=!1,L={name:"formats",install:function(){x||(x=!0,u(w))}},v=L;export{v as default,L as formats};
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-2RBI6DVS.js";import{a as s,e as f}from"../chunks/chunk-CIBJLAA3.js";import{a as p}from"../chunks/chunk-UBGJGMSG.js";import"../chunks/chunk-BGUJ3HF6.js";var d,m=t=>r=>{let e=t(r);return t=>null==t?t:e(t)},g="en";function S(){if(s.locale!==d){d=s.locale;try{g=Intl.getCanonicalLocales(d)[0]}catch{console.warn(`[@wcstack/state] ${p(48,[d])}`),g="en"}}return g}var h=["full","long","medium","short"];function b(t,e){let[a,n]=t??[];return void 0===n&&void 0!==a&&h.includes(a)&&([a,n]=[void 0,a]),void 0!==n&&!h.includes(n)&&r(e,n),[a,n]}var{eq:M,ne:$,not:v,lt:k,le:j,gt:w,ge:F,falsy:D,truthy:L,boolean:x}=u,C={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??S()))},arity:[0,1]},upper:{factory:m(()=>t=>String(t).toUpperCase()),arity:[0,0]},lower:{factory:m(()=>t=>String(t).toLowerCase()),arity:[0,0]},capitalize:{factory:m(()=>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:m(()=>t=>String(t).trim()),arity:[0,0]},slice:{factory:m(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:m(t=>{let r=l(t,0,"padStart"),e=t?.[1]??"0";return t=>String(t).padStart(r,e)}),arity:[1,2]},padEnd:{factory:m(t=>{let r=l(t,0,"padEnd"),e=t?.[1]??" ";return t=>String(t).padEnd(r,e)}),arity:[1,2]},repeat:{factory:m(t=>{let r=l(t,0,"repeat");return t=>String(t).repeat(r)}),arity:[1,1]},reverse:{factory:m(()=>t=>String(t).split("").reverse().join("")),arity:[0,0]},truncate:{factory:m(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:m(r=>{let e=r?.[0]??t("unit");return t=>String(t)+e}),arity:[1,1]},date:{factory:t=>{let[r,e]=b(t,"date"),a=e&&{dateStyle:e};return t=>(t instanceof Date||n("date",t),t.toLocaleDateString(r??S(),a))},arity:[0,2]},time:{factory:t=>{let[r,e]=b(t,"time"),a=e&&{timeStyle:e};return t=>(t instanceof Date||n("time",t),t.toLocaleTimeString(r??S(),a))},arity:[0,2]},datetime:{factory:t=>{let[r,e]=b(t,"datetime"),a=e&&{dateStyle:e,timeStyle:e};return t=>(t instanceof Date||n("datetime",t),t.toLocaleString(r??S(),a))},arity:[0,2]},ymd:{factory: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: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:M,ne:$,not:v,lt:k,le:j,gt:w,ge:F,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??S(),i))},arity:[1,2]}},I=!1,U={name:"formats",install:function(){I||(I=!0,f(C))}},A=U;export{A as default,U as formats};
2
2
  //# sourceMappingURL=formats.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["seen","nullishPassthrough","factory","options","filterFn","value","valid","defaultLocale","config","locale","Intl","getCanonicalLocales","console","warn","text","eq","ne","not","lt","le","gt","ge","falsy","truthy","boolean","coreFilters","registered","toFixed","opt","numberOption","valueMustBeNumber","arity","explicit","toLocaleString","upper","String","toUpperCase","lower","toLowerCase","capitalize","v","length","charAt","slice","trim","numberedOpts","requiredNumberOption","opt2","push","padStart","opt1","padEnd","repeat","reverse","split","join","truncate","maxLength","suffix","Array","isArray","valueMustBeArray","round","optValue","Math","pow","floor","ceil","percent","unit","optionsRequired","date","Date","valueMustBeDate","toLocaleDateString","time","toLocaleTimeString","datetime","ymd","year","getFullYear","toString","month","getMonth","day","getDate","hms","hours","getHours","minutes","getMinutes","seconds","getSeconds","add","numeric","sub","mul","div","mod","abs","clamp","min","max","int","parseInt","float","parseFloat","defaults","literals","fallback","firstLiteral","coalesce","number","Number","string","nullIfEmpty","installed","formats","name","install","registerFilters","formats_default"],"sources":["../../../src/filters/formats.ts","../../../src/features/formats.ts"],"sourcesContent":["/**\n * filters/formats.ts — the formats add-on (37 filters): the values a binding computes and shows, as\n * opposed to the conditions the core set (`./core`) tests. Ported from `@wcstack/state`\n * (`formats/builtinFilters.ts`) with the semantics unchanged.\n *\n * - number display: `toFixed round floor ceil percent unit locale`\n * - string shaping: `upper lower capitalize trim slice padStart padEnd repeat reverse truncate join`\n * (`substr` was removed in 4.0: `slice(start, start + length)`)\n * - date and time: `date time datetime ymd hms`\n * - arithmetic: `add sub mul div mod abs clamp`\n * - conversions: `number string int float`\n * - missing values: `defaults coalesce nullIfEmpty`\n *\n * (The last three groups were the core's up to 4.0.0-rc.3.)\n *\n * `installFormats()` puts them in the registry. Without it, one of these filters fails when the\n * bindings are planned with `[wcs/filter-unknown]` naming this add-on (never passes silently).\n * The locale-dependent four (`locale date time datetime`) read `config.locale` as their default.\n */\nimport { config } from \"../config\";\nimport { optionsRequired, valueMustBeArray, valueMustBeDate, valueMustBeNumber } from \"./errorMessages\";\nimport { firstLiteral, numberOption, requiredNumberOption } from \"./options\";\nimport { registerFilters, type FilterDefinition, type FilterFactory, type FilterFn } from \"./registry\";\nimport { coreFilters, numeric } from \"./core\";\nimport { M, text } from \"../messages\";\n\n/**\n * Extends the display-side empty-value contract (requirement B8) to the filters that build their\n * result with `String(value)`: those turn `undefined` / `null` into the *characters* \"undefined\" /\n * \"null\", so `attr.title: x|trim` wrote `title=\"undefined\"` where `attr.title: x` removes the\n * attribute. This family passes an absent value straight through and leaves the decision to the\n * apply side (attribute removed, class cleared, style cleared, text emptied).\n *\n * Deliberately **not** wrapped: the filters that reject a value of the wrong type (the number, date\n * and array families) — their throw is confined to the one binding and reported, a different\n * quality of failure from painting the word \"undefined\" into the page.\n */\nconst nullishPassthrough = (factory: (options: string[]) => FilterFn): FilterFactory =>\n (options: string[]): FilterFn => {\n const filterFn = factory(options);\n // `== null` matches both null and undefined (deliberately loose)\n return (value: unknown): unknown => (value == null ? value : filterFn(value));\n };\n\n/** Fixed decimals (default 0). */\nconst toFixed = (options: string[]): FilterFn => {\n const opt = numberOption(options?.[0] ?? \"0\", 'toFixed');\n return (value: unknown): string => {\n if (typeof value !== 'number') {valueMustBeNumber('toFixed');}\n return value.toFixed(opt);\n };\n};\n\n/** Rounds to the given decimals (default 0). */\nconst round = (options: string[]): FilterFn => {\n const optValue = Math.pow(10, numberOption(options?.[0] ?? '0', 'round'));\n return (value: unknown): number => {\n if (typeof value !== 'number') {valueMustBeNumber('round');}\n return Math.round(value * optValue) / optValue;\n };\n};\n\n/** Rounds down to the given decimals (default 0). */\nconst floor = (options: string[]): FilterFn => {\n const optValue = Math.pow(10, numberOption(options?.[0] ?? '0', 'floor'));\n return (value: unknown): number => {\n if (typeof value !== 'number') {valueMustBeNumber('floor');}\n return Math.floor(value * optValue) / optValue;\n };\n};\n\n/** Rounds up to the given decimals (default 0). */\nconst ceil = (options: string[]): FilterFn => {\n const optValue = Math.pow(10, numberOption(options?.[0] ?? '0', 'ceil'));\n return (value: unknown): number => {\n if (typeof value !== 'number') {valueMustBeNumber('ceil');}\n return Math.ceil(value * optValue) / optValue;\n };\n};\n\n/** `0.123` → `\"12%\"` with the given decimals (default 0). */\nconst percent = (options: string[]): FilterFn => {\n const opt = numberOption(options?.[0] ?? '0', 'percent');\n return (value: unknown): string => {\n if (typeof value !== 'number') {valueMustBeNumber('percent');}\n return `${(value * 100).toFixed(opt)}%`;\n };\n};\n\n/**\n * Appends a CSS unit (or any suffix). Accepts strings as well as numbers **on purpose**: the useful\n * chains run through `toFixed` / `percent`, which already return strings\n * (`style.height: cpu|clamp(0,100)|toFixed(0)|unit(%)`). null / undefined pass through\n * (`nullishPassthrough`) rather than becoming \"undefinedpx\".\n */\nconst unit = (options: string[]): FilterFn => {\n const opt = options?.[0] ?? optionsRequired('unit');\n return (value: unknown): string => String(value) + opt;\n};\n\nlet seen: string | undefined;\nlet valid = \"en\";\n\n/**\n * The default locale (`config.locale`) as Intl takes it, checked when it changes (an identity\n * compare per apply): one it does not (`<html lang=\"en_US\">`) is \"en\" (as 3.x), with a warning.\n */\nfunction defaultLocale(): string {\n if (config.locale !== seen) {\n seen = config.locale;\n try {\n valid = Intl.getCanonicalLocales(seen)[0];\n } catch {\n console.warn(`[@wcstack/state] ${text(M.LocaleInvalid, [seen])}`);\n valid = \"en\";\n }\n }\n return valid;\n}\n\n/**\n * Locale-formatted number. The locale-dependent filters (`locale date time datetime`) fix an\n * **explicit** locale at construction but read the default `config.locale` **on every apply**: a\n * default baked into the closure at binding time would make an ordering accident (locale settled\n * after the bindings) permanent, since `config.locale` is not in the dependency graph. Read per\n * apply, a re-applied binding at least recovers.\n */\nconst locale = (options: string[]): FilterFn => {\n const explicit = options?.[0];\n return (value: unknown): string => {\n if (typeof value !== 'number') {valueMustBeNumber('locale');}\n return value.toLocaleString(explicit ?? defaultLocale());\n };\n};\n\nconst upper = (): FilterFn => (value: unknown): string => String(value).toUpperCase();\n\nconst lower = (): FilterFn => (value: unknown): string => String(value).toLowerCase();\n\nconst capitalize = (): FilterFn => (value: unknown): string => {\n const v = String(value);\n if (v.length === 0) {return v;}\n if (v.length === 1) {return v.toUpperCase();}\n return v.charAt(0).toUpperCase() + v.slice(1);\n};\n\nconst trim = (): FilterFn => (value: unknown): string => String(value).trim();\n\n/** `slice(start[, end])`. */\nconst slice = (options: string[]): FilterFn => {\n const numberedOpts: number[] = [requiredNumberOption(options, 0, 'slice')];\n const opt2 = options?.[1];\n if (typeof opt2 !== 'undefined') {\n numberedOpts.push(numberOption(opt2, 'slice'));\n }\n return (value: unknown): string => String(value).slice(...numberedOpts);\n};\n\n/** Pads the start to a length; the pad string defaults to '0' (JavaScript's default is a space). */\nconst padStart = (options: string[]): FilterFn => {\n const opt1 = requiredNumberOption(options, 0, 'padStart');\n const opt2 = options?.[1] ?? '0';\n return (value: unknown): string => String(value).padStart(opt1, opt2);\n};\n\n/** Pads the end to a length; the pad string defaults to ' ' (as in JavaScript). */\nconst padEnd = (options: string[]): FilterFn => {\n const opt1 = requiredNumberOption(options, 0, 'padEnd');\n const opt2 = options?.[1] ?? ' ';\n return (value: unknown): string => String(value).padEnd(opt1, opt2);\n};\n\nconst repeat = (options: string[]): FilterFn => {\n const opt = requiredNumberOption(options, 0, 'repeat');\n return (value: unknown): string => String(value).repeat(opt);\n};\n\nconst reverse = (): FilterFn => (value: unknown): string => String(value).split('').reverse().join('');\n\n/**\n * Shortens a string and appends a suffix (default '…', U+2026). The length counts **kept\n * characters**; a string at or below it is returned untouched (no suffix).\n */\nconst truncate = (options: string[]): FilterFn => {\n const maxLength = requiredNumberOption(options, 0, 'truncate');\n const suffix = options?.[1] ?? '…';\n return (value: unknown): string => {\n const v = String(value);\n if (v.length <= maxLength) {return v;}\n return v.slice(0, maxLength) + suffix;\n };\n};\n\n/**\n * Joins an array. The default separator is \", \" rather than \",\": a bare comma is what `String()`\n * already produces, so defaulting to it would make `|join` a no-op.\n */\nconst join = (options: string[]): FilterFn => {\n const opt = options?.[0] ?? ', ';\n return (value: unknown): string => {\n if (!Array.isArray(value)) {valueMustBeArray('join');}\n return value.join(opt);\n };\n};\n\n/** Locale-formatted date (the default locale is read per apply — see `locale`). */\nconst date = (options: string[]): FilterFn => {\n const explicit = options?.[0];\n return (value: unknown): string => {\n if (!(value instanceof Date)) {valueMustBeDate('date');}\n return value.toLocaleDateString(explicit ?? defaultLocale());\n };\n};\n\n/** Locale-formatted time (the default locale is read per apply — see `locale`). */\nconst time = (options: string[]): FilterFn => {\n const explicit = options?.[0];\n return (value: unknown): string => {\n if (!(value instanceof Date)) {valueMustBeDate('time');}\n return value.toLocaleTimeString(explicit ?? defaultLocale());\n };\n};\n\n/** Locale-formatted date and time (the default locale is read per apply — see `locale`). */\nconst datetime = (options: string[]): FilterFn => {\n const explicit = options?.[0];\n return (value: unknown): string => {\n if (!(value instanceof Date)) {valueMustBeDate('datetime');}\n return value.toLocaleString(explicit ?? defaultLocale());\n };\n};\n\n/** YYYY-MM-DD with a configurable separator (default '-'), locale-independent. */\nconst ymd = (options: string[]): FilterFn => {\n const opt = options?.[0] ?? '-';\n return (value: unknown): string => {\n if (!(value instanceof Date)) {valueMustBeDate('ymd');}\n const year = value.getFullYear().toString();\n const month = (value.getMonth() + 1).toString().padStart(2, '0');\n const day = value.getDate().toString().padStart(2, '0');\n return `${year}${opt}${month}${opt}${day}`;\n };\n};\n\n/** HH:MM:SS with a configurable separator (default ':'), zero-padded and locale-independent. */\nconst hms = (options: string[]): FilterFn => {\n const opt = options?.[0] ?? ':';\n return (value: unknown): string => {\n if (!(value instanceof Date)) {valueMustBeDate('hms');}\n const hours = value.getHours().toString().padStart(2, '0');\n const minutes = value.getMinutes().toString().padStart(2, '0');\n const seconds = value.getSeconds().toString().padStart(2, '0');\n return `${hours}${opt}${minutes}${opt}${seconds}`;\n };\n};\n\nconst abs = (): FilterFn => (value: unknown): number => {\n if (typeof value !== 'number') {valueMustBeNumber('abs');}\n return Math.abs(value);\n};\n\n/** Constrains a number to the inclusive range [min, max] (`style.width: ratio|clamp(0,1)|percent(0)`). */\nconst clamp = (options: string[]): FilterFn => {\n const min = requiredNumberOption(options, 0, 'clamp');\n const max = requiredNumberOption(options, 1, 'clamp');\n return (value: unknown): number => {\n if (typeof value !== 'number') {valueMustBeNumber('clamp');}\n return Math.min(Math.max(value, min), max);\n };\n};\n\n// The conversions convert — an absent value is converted too (`string` gives \"undefined\");\n// put `coalesce` in front when a missing value should not be converted.\nconst number = (): FilterFn => (value: unknown): number => Number(value);\n\nconst string = (): FilterFn => (value: unknown): string => String(value);\n\nconst int = (): FilterFn => (value: unknown): number => parseInt(String(value), 10);\n\nconst float = (): FilterFn => (value: unknown): number => parseFloat(String(value));\n\n/** Replaces a falsy value (JavaScript's truthiness) with the typed literal: defaults(0) gives 0, defaults('0') \"0\" (B9). */\nconst defaults = (options: string[], literals?: readonly unknown[]): FilterFn => {\n const opt = options?.[0] ?? optionsRequired('defaults');\n const fallback = firstLiteral(opt, literals);\n return (value: unknown): unknown => {\n if (!value) {return fallback;}\n return value;\n };\n};\n\n/** Replaces only null / undefined (`defaults` also replaces 0, false and \"\") — SQL's COALESCE. */\nconst coalesce = (options: string[], literals?: readonly unknown[]): FilterFn => {\n const opt = options?.[0] ?? optionsRequired('coalesce');\n const fallback = firstLiteral(opt, literals);\n return (value: unknown): unknown => value ?? fallback;\n};\n\n/** \"\" → null, anything else unchanged. */\nconst nullIfEmpty = (): FilterFn => (value: unknown): unknown => (value === \"\") ? null : value;\n\nconst { eq, ne, not, lt, le, gt, ge, falsy, truthy, boolean } = coreFilters;\n\n/**\n * What `installFormats()` registers: factory and [min, max] argument count (B3 — the same bounds\n * lint uses), in the order the registry keeps them. The did-you-mean suggestion gives a tie to the\n * first registered, so the order is the one the full build registered up to 4.0.0-rc.3, when this\n * add-on had the 23 display filters and the core 24: the display filters, then that core set, each\n * in the source's (lint's) relative order. The core's 10 are registered here too, in their place\n * (the core registers them again when it first plans a binding, and a name registered again keeps\n * its place).\n */\nconst registered: Readonly<Record<string, FilterDefinition>> = {\n toFixed: { factory: toFixed, arity: [0, 1] },\n locale: { factory: locale, arity: [0, 1] },\n\n // The `String(value)` family passes an absent value through (B8 — see nullishPassthrough)\n upper: { factory: nullishPassthrough(upper), arity: [0, 0] },\n lower: { factory: nullishPassthrough(lower), arity: [0, 0] },\n capitalize: { factory: nullishPassthrough(capitalize), arity: [0, 0] },\n trim: { factory: nullishPassthrough(trim), arity: [0, 0] },\n slice: { factory: nullishPassthrough(slice), arity: [1, 2] },\n // The length is required too (the implementation reads both)\n padStart: { factory: nullishPassthrough(padStart), arity: [1, 2] },\n padEnd: { factory: nullishPassthrough(padEnd), arity: [1, 2] },\n repeat: { factory: nullishPassthrough(repeat), arity: [1, 1] },\n reverse: { factory: nullishPassthrough(reverse), arity: [0, 0] },\n truncate: { factory: nullishPassthrough(truncate), arity: [1, 2] },\n join: { factory: join, arity: [0, 1] },\n\n round: { factory: round, arity: [0, 1] },\n floor: { factory: floor, arity: [0, 1] },\n ceil: { factory: ceil, arity: [0, 1] },\n percent: { factory: percent, arity: [0, 1] },\n unit: { factory: nullishPassthrough(unit), arity: [1, 1] },\n\n // The locale-dependent three take a locale like `locale` does (`date(ja-JP)`)\n date: { factory: date, arity: [0, 1] },\n time: { factory: time, arity: [0, 1] },\n datetime: { factory: datetime, arity: [0, 1] },\n ymd: { factory: ymd, arity: [0, 1] },\n hms: { factory: hms, arity: [0, 1] },\n\n // the core set of 4.0.0-rc.3 (the core's own: eq ne not lt le gt ge falsy truthy boolean)\n eq, ne, not, lt, le, gt, ge,\n add: numeric('add', (value, opt) => value + opt),\n sub: numeric('sub', (value, opt) => value - opt),\n mul: numeric('mul', (value, opt) => value * opt),\n div: numeric('div', (value, opt) => value / opt),\n mod: numeric('mod', (value, opt) => value % opt),\n abs: { factory: abs, arity: [0, 0] },\n clamp: { factory: clamp, arity: [2, 2] },\n int: { factory: int, arity: [0, 0] },\n float: { factory: float, arity: [0, 0] },\n falsy, truthy,\n defaults: { factory: defaults, arity: [1, 1] },\n coalesce: { factory: coalesce, arity: [1, 1] },\n boolean,\n number: { factory: number, arity: [0, 0] },\n string: { factory: string, arity: [0, 0] },\n nullIfEmpty: { factory: nullIfEmpty, arity: [0, 0] },\n};\n\n/** The formats add-on's own filters (what `registered` holds beyond the core set), in that order. */\nexport const formatFilters: Readonly<Record<string, FilterDefinition>> = /*#__PURE__*/ Object.fromEntries(\n /*#__PURE__*/ Object.entries(registered).filter(([name]) => !(name in coreFilters)),\n);\n\nlet installed = false;\n\n/** Puts the formats add-on in the registry. Idempotent. */\nexport function installFormats(): void {\n if (installed) return;\n installed = true;\n registerFilters(registered);\n}\n","/**\n * The formats add-on (@wcstack/state/features/formats): the 37 filters that compute and show a value\n * (display, string shaping, dates — locale-aware —, arithmetic, conversions, missing values).\n */\nimport type { Feature } from \"../hooks\";\nimport { installFormats } from \"../filters/formats\";\n\nexport const formats: Feature = { name: \"formats\", install: installFormats };\nexport default formats;\n"],"mappings":"mPAqCA,IA+DIA,EA/DEC,EAAsBC,GACzBC,IACC,IAAMC,EAAWF,EAAQC,GAEzB,OAAQE,GAAsC,MAATA,EAAgBA,EAAQD,EAASC,IA4DtEC,EAAQ,KAMZ,SAASC,IACP,GAAIC,EAAOC,SAAWT,EAAM,CAC1BA,EAAOQ,EAAOC,OACd,IACEH,EAAQI,KAAKC,oBAAoBX,GAAM,EACzC,OACEY,QAAQC,KAAK,oBAAoBC,KAAsB,CAACd,OACxDM,EAAQ,IACV,CACF,CACA,OAAOA,CACT,CASA,IA8KQS,KAAIC,KAAIC,MAAKC,KAAIC,KAAIC,KAAIC,KAAIC,QAAOC,SAAQC,WAAYC,EAW1DC,EAAyD,CAC7DC,QAAS,CAAEzB,QA5QIC,IACf,IAAMyB,EAAMC,EAAa1B,IAAU,IAAM,IAAK,WAC9C,OAAQE,IACe,iBAAVA,GAAqByB,EAAkB,WAC3CzB,EAAMsB,QAAQC,KAwQMG,MAAO,CAAC,EAAG,IACxCtB,OAAQ,CAAEP,QA3LIC,IACd,IAAM6B,EAAW7B,IAAU,GAC3B,OAAQE,IACe,iBAAVA,GAAqByB,EAAkB,UAC3CzB,EAAM4B,eAAeD,GAAYzB,OAuLfwB,MAAO,CAAC,EAAG,IAGtCG,MAAO,CAAEhC,QAASD,EAtLN,IAAiBI,GAA2B8B,OAAO9B,GAAO+B,eAsLzBL,MAAO,CAAC,EAAG,IACxDM,MAAO,CAAEnC,QAASD,EArLN,IAAiBI,GAA2B8B,OAAO9B,GAAOiC,eAqLzBP,MAAO,CAAC,EAAG,IACxDQ,WAAY,CAAErC,QAASD,EApLN,IAAiBI,IAClC,IAAMmC,EAAIL,OAAO9B,GACjB,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AU,IAAMmE,EAAgB,YACtCuC,EAAWC,EAAalF,EAAKgF,GACnC,OAAQvG,GAA4BA,GAASwG,GA6Dd9E,MAAO,CAAC,EAAG,IAC1CP,UACAwF,OAAQ,CAAE9G,QArFG,IAAiBG,GAA2B4G,OAAO5G,GAqFrC0B,MAAO,CAAC,EAAG,IACtCmF,OAAQ,CAAEhH,QApFG,IAAiBG,GAA2B8B,OAAO9B,GAoFrC0B,MAAO,CAAC,EAAG,IACtCoF,YAAa,CAAEjH,QA7DG,IAAiBG,GAAuC,KAAVA,EAAgB,KAAOA,EA6DlD0B,MAAO,CAAC,EAAG,KAQ9CqF,GAAY,ECzWHC,EAAmB,CAAEC,KAAM,UAAWC,QD4W5C,WACDH,IACJA,GAAY,EACZI,EAAgB9F,GAClB,GC/WO+F,EAAQJ","ignoreList":[]}
1
+ {"version":3,"names":["seen","nullishPassthrough","factory","options","filterFn","value","valid","defaultLocale","config","locale","Intl","getCanonicalLocales","console","warn","text","STYLES","dateOptions","fn","loc","style","includes","styleInvalid","eq","ne","not","lt","le","gt","ge","falsy","truthy","boolean","coreFilters","registered","toFixed","opt","numberOption","valueMustBeNumber","arity","explicit","toLocaleString","upper","String","toUpperCase","lower","toLowerCase","capitalize","v","length","charAt","slice","trim","numberedOpts","requiredNumberOption","opt2","push","padStart","opt1","padEnd","repeat","reverse","split","join","truncate","maxLength","suffix","Array","isArray","valueMustBeArray","round","optValue","Math","pow","floor","ceil","percent","unit","optionsRequired","date","format","dateStyle","Date","valueMustBeDate","toLocaleDateString","time","timeStyle","toLocaleTimeString","datetime","ymd","year","getFullYear","toString","month","getMonth","day","getDate","hms","hours","getHours","minutes","getMinutes","seconds","getSeconds","add","numeric","sub","mul","div","mod","abs","clamp","min","max","int","parseInt","float","parseFloat","defaults","literals","fallback","firstLiteral","coalesce","number","Number","string","nullIfEmpty","currency","code","NumberFormat","known","supportedValuesOf","currencyInvalid","installed","formats","name","install","registerFilters","formats_default"],"sources":["../../../src/filters/formats.ts","../../../src/features/formats.ts"],"sourcesContent":["/**\n * filters/formats.ts — the formats add-on (38 filters): the values a binding computes and shows, as\n * opposed to the conditions the core set (`./core`) tests. Ported from `@wcstack/state`\n * (`formats/builtinFilters.ts`) with the semantics unchanged.\n *\n * - number display: `toFixed round floor ceil percent unit locale currency`\n * - string shaping: `upper lower capitalize trim slice padStart padEnd repeat reverse truncate join`\n * (`substr` was removed in 4.0: `slice(start, start + length)`)\n * - date and time: `date time datetime ymd hms`\n * - arithmetic: `add sub mul div mod abs clamp`\n * - conversions: `number string int float`\n * - missing values: `defaults coalesce nullIfEmpty`\n *\n * (The last three groups were the core's up to 4.0.0-rc.3.)\n *\n * `installFormats()` puts them in the registry. Without it, one of these filters fails when the\n * bindings are planned with `[wcs/filter-unknown]` naming this add-on (never passes silently).\n * The locale-dependent five (`locale currency date time datetime`) read `config.locale` as their default.\n */\nimport { config } from \"../config\";\nimport { currencyInvalid, optionsRequired, styleInvalid, valueMustBeArray, valueMustBeDate, valueMustBeNumber } from \"./errorMessages\";\nimport { firstLiteral, numberOption, requiredNumberOption } from \"./options\";\nimport { registerFilters, type FilterDefinition, type FilterFactory, type FilterFn } from \"./registry\";\nimport { coreFilters, numeric } from \"./core\";\nimport { M, text } from \"../messages\";\n\n/**\n * Extends the display-side empty-value contract (requirement B8) to the filters that build their\n * result with `String(value)`: those turn `undefined` / `null` into the *characters* \"undefined\" /\n * \"null\", so `attr.title: x|trim` wrote `title=\"undefined\"` where `attr.title: x` removes the\n * attribute. This family passes an absent value straight through and leaves the decision to the\n * apply side (attribute removed, class cleared, style cleared, text emptied).\n *\n * Deliberately **not** wrapped: the filters that reject a value of the wrong type (the number, date\n * and array families) — their throw is confined to the one binding and reported, a different\n * quality of failure from painting the word \"undefined\" into the page.\n */\nconst nullishPassthrough = (factory: (options: string[]) => FilterFn): FilterFactory =>\n (options: string[]): FilterFn => {\n const filterFn = factory(options);\n // `== null` matches both null and undefined (deliberately loose)\n return (value: unknown): unknown => (value == null ? value : filterFn(value));\n };\n\n/** Fixed decimals (default 0). */\nconst toFixed = (options: string[]): FilterFn => {\n const opt = numberOption(options?.[0] ?? \"0\", 'toFixed');\n return (value: unknown): string => {\n if (typeof value !== 'number') {valueMustBeNumber('toFixed', value);}\n return value.toFixed(opt);\n };\n};\n\n/** Rounds to the given decimals (default 0). */\nconst round = (options: string[]): FilterFn => {\n const optValue = Math.pow(10, numberOption(options?.[0] ?? '0', 'round'));\n return (value: unknown): number => {\n if (typeof value !== 'number') {valueMustBeNumber('round', value);}\n return Math.round(value * optValue) / optValue;\n };\n};\n\n/** Rounds down to the given decimals (default 0). */\nconst floor = (options: string[]): FilterFn => {\n const optValue = Math.pow(10, numberOption(options?.[0] ?? '0', 'floor'));\n return (value: unknown): number => {\n if (typeof value !== 'number') {valueMustBeNumber('floor', value);}\n return Math.floor(value * optValue) / optValue;\n };\n};\n\n/** Rounds up to the given decimals (default 0). */\nconst ceil = (options: string[]): FilterFn => {\n const optValue = Math.pow(10, numberOption(options?.[0] ?? '0', 'ceil'));\n return (value: unknown): number => {\n if (typeof value !== 'number') {valueMustBeNumber('ceil', value);}\n return Math.ceil(value * optValue) / optValue;\n };\n};\n\n/** `0.123` → `\"12%\"` with the given decimals (default 0). */\nconst percent = (options: string[]): FilterFn => {\n const opt = numberOption(options?.[0] ?? '0', 'percent');\n return (value: unknown): string => {\n if (typeof value !== 'number') {valueMustBeNumber('percent', value);}\n return `${(value * 100).toFixed(opt)}%`;\n };\n};\n\n/**\n * Appends a CSS unit (or any suffix). Accepts strings as well as numbers **on purpose**: the useful\n * chains run through `toFixed` / `percent`, which already return strings\n * (`style.height: cpu|clamp(0,100)|toFixed(0)|unit(%)`). null / undefined pass through\n * (`nullishPassthrough`) rather than becoming \"undefinedpx\".\n */\nconst unit = (options: string[]): FilterFn => {\n const opt = options?.[0] ?? optionsRequired('unit');\n return (value: unknown): string => String(value) + opt;\n};\n\nlet seen: string | undefined;\nlet valid = \"en\";\n\n/**\n * The default locale (`config.locale`) as Intl takes it, checked when it changes (an identity\n * compare per apply): one it does not (`<html lang=\"en_US\">`) is \"en\" (as 3.x), with a warning.\n */\nfunction defaultLocale(): string {\n if (config.locale !== seen) {\n seen = config.locale;\n try {\n valid = Intl.getCanonicalLocales(seen)[0];\n } catch {\n console.warn(`[@wcstack/state] ${text(M.LocaleInvalid, [seen])}`);\n valid = \"en\";\n }\n }\n return valid;\n}\n\n/**\n * Locale-formatted number. The locale-dependent filters (`locale date time datetime`) fix an\n * **explicit** locale at construction but read the default `config.locale` **on every apply**: a\n * default baked into the closure at binding time would make an ordering accident (locale settled\n * after the bindings) permanent, since `config.locale` is not in the dependency graph. Read per\n * apply, a re-applied binding at least recovers.\n */\nconst locale = (options: string[]): FilterFn => {\n const explicit = options?.[0];\n return (value: unknown): string => {\n if (typeof value !== 'number') {valueMustBeNumber('locale', value);}\n return value.toLocaleString(explicit ?? defaultLocale());\n };\n};\n\n/**\n * A number as money: `currency(code[, locale])`, the code ISO 4217 (`price|currency(JPY)` → \"¥1,800\",\n * `currency(EUR,de-DE)` → \"1.800,00 €\"). A code Intl does not take fails when the bindings are planned.\n * (docs/seam-apps.md, router-admin: the page built an `Intl.NumberFormat` per currency in getters.)\n */\nconst currency = (options: string[]): FilterFn => {\n const code = options?.[0] ?? optionsRequired('currency');\n const explicit = options?.[1];\n const format = { style: \"currency\", currency: code } as const;\n try {\n new Intl.NumberFormat(\"en\", format);\n // (Intl takes any three letters: the list of the ones it knows, where there is one)\n const known = (Intl as { supportedValuesOf?: (key: string) => string[] }).supportedValuesOf?.(\"currency\");\n if (known && !known.includes(code.toUpperCase())) throw 0;\n } catch {\n currencyInvalid(code);\n }\n return (value: unknown): string => {\n if (typeof value !== 'number') {valueMustBeNumber('currency', value);}\n return value.toLocaleString(explicit ?? defaultLocale(), format);\n };\n};\n\nconst upper = (): FilterFn => (value: unknown): string => String(value).toUpperCase();\n\nconst lower = (): FilterFn => (value: unknown): string => String(value).toLowerCase();\n\nconst capitalize = (): FilterFn => (value: unknown): string => {\n const v = String(value);\n if (v.length === 0) {return v;}\n if (v.length === 1) {return v.toUpperCase();}\n return v.charAt(0).toUpperCase() + v.slice(1);\n};\n\nconst trim = (): FilterFn => (value: unknown): string => String(value).trim();\n\n/** `slice(start[, end])`. */\nconst slice = (options: string[]): FilterFn => {\n const numberedOpts: number[] = [requiredNumberOption(options, 0, 'slice')];\n const opt2 = options?.[1];\n if (typeof opt2 !== 'undefined') {\n numberedOpts.push(numberOption(opt2, 'slice'));\n }\n return (value: unknown): string => String(value).slice(...numberedOpts);\n};\n\n/** Pads the start to a length; the pad string defaults to '0' (JavaScript's default is a space). */\nconst padStart = (options: string[]): FilterFn => {\n const opt1 = requiredNumberOption(options, 0, 'padStart');\n const opt2 = options?.[1] ?? '0';\n return (value: unknown): string => String(value).padStart(opt1, opt2);\n};\n\n/** Pads the end to a length; the pad string defaults to ' ' (as in JavaScript). */\nconst padEnd = (options: string[]): FilterFn => {\n const opt1 = requiredNumberOption(options, 0, 'padEnd');\n const opt2 = options?.[1] ?? ' ';\n return (value: unknown): string => String(value).padEnd(opt1, opt2);\n};\n\nconst repeat = (options: string[]): FilterFn => {\n const opt = requiredNumberOption(options, 0, 'repeat');\n return (value: unknown): string => String(value).repeat(opt);\n};\n\nconst reverse = (): FilterFn => (value: unknown): string => String(value).split('').reverse().join('');\n\n/**\n * Shortens a string and appends a suffix (default '…', U+2026). The length counts **kept\n * characters**; a string at or below it is returned untouched (no suffix).\n */\nconst truncate = (options: string[]): FilterFn => {\n const maxLength = requiredNumberOption(options, 0, 'truncate');\n const suffix = options?.[1] ?? '…';\n return (value: unknown): string => {\n const v = String(value);\n if (v.length <= maxLength) {return v;}\n return v.slice(0, maxLength) + suffix;\n };\n};\n\n/**\n * Joins an array. The default separator is \", \" rather than \",\": a bare comma is what `String()`\n * already produces, so defaulting to it would make `|join` a no-op.\n */\nconst join = (options: string[]): FilterFn => {\n const opt = options?.[0] ?? ', ';\n return (value: unknown): string => {\n if (!Array.isArray(value)) {valueMustBeArray('join');}\n return value.join(opt);\n };\n};\n\nconst STYLES = [\"full\", \"long\", \"medium\", \"short\"];\n\n/**\n * The options of `date time datetime`: `(locale?, style?)`, the style Intl's `dateStyle` / `timeStyle`\n * (`date(en-US,medium)` → \"Oct 13, 2026\"). A style alone keeps the default locale (`date(long)`).\n * Without a style the format is the locale's numeric one, as before.\n */\nfunction dateOptions(options: string[], fn: string): [string | undefined, Intl.DateTimeFormatOptions[\"dateStyle\"]] {\n let [loc, style]: (string | undefined)[] = options ?? [];\n if (style === undefined && loc !== undefined && STYLES.includes(loc)) [loc, style] = [undefined, loc];\n if (style !== undefined && !STYLES.includes(style)) styleInvalid(fn, style);\n return [loc, style as Intl.DateTimeFormatOptions[\"dateStyle\"]];\n}\n\n/** Locale-formatted date (the default locale is read per apply — see `locale`). */\nconst date = (options: string[]): FilterFn => {\n const [explicit, style] = dateOptions(options, 'date');\n const format: Intl.DateTimeFormatOptions | undefined = style && { dateStyle: style };\n return (value: unknown): string => {\n if (!(value instanceof Date)) {valueMustBeDate('date', value);}\n return value.toLocaleDateString(explicit ?? defaultLocale(), format);\n };\n};\n\n/** Locale-formatted time (the default locale is read per apply — see `locale`). */\nconst time = (options: string[]): FilterFn => {\n const [explicit, style] = dateOptions(options, 'time');\n const format: Intl.DateTimeFormatOptions | undefined = style && { timeStyle: style };\n return (value: unknown): string => {\n if (!(value instanceof Date)) {valueMustBeDate('time', value);}\n return value.toLocaleTimeString(explicit ?? defaultLocale(), format);\n };\n};\n\n/** Locale-formatted date and time (the default locale is read per apply — see `locale`). */\nconst datetime = (options: string[]): FilterFn => {\n const [explicit, style] = dateOptions(options, 'datetime');\n const format: Intl.DateTimeFormatOptions | undefined = style && { dateStyle: style, timeStyle: style };\n return (value: unknown): string => {\n if (!(value instanceof Date)) {valueMustBeDate('datetime', value);}\n return value.toLocaleString(explicit ?? defaultLocale(), format);\n };\n};\n\n/** YYYY-MM-DD with a configurable separator (default '-'), locale-independent. */\nconst ymd = (options: string[]): FilterFn => {\n const opt = options?.[0] ?? '-';\n return (value: unknown): string => {\n if (!(value instanceof Date)) {valueMustBeDate('ymd', value);}\n const year = value.getFullYear().toString();\n const month = (value.getMonth() + 1).toString().padStart(2, '0');\n const day = value.getDate().toString().padStart(2, '0');\n return `${year}${opt}${month}${opt}${day}`;\n };\n};\n\n/** HH:MM:SS with a configurable separator (default ':'), zero-padded and locale-independent. */\nconst hms = (options: string[]): FilterFn => {\n const opt = options?.[0] ?? ':';\n return (value: unknown): string => {\n if (!(value instanceof Date)) {valueMustBeDate('hms', value);}\n const hours = value.getHours().toString().padStart(2, '0');\n const minutes = value.getMinutes().toString().padStart(2, '0');\n const seconds = value.getSeconds().toString().padStart(2, '0');\n return `${hours}${opt}${minutes}${opt}${seconds}`;\n };\n};\n\nconst abs = (): FilterFn => (value: unknown): number => {\n if (typeof value !== 'number') {valueMustBeNumber('abs', value);}\n return Math.abs(value);\n};\n\n/** Constrains a number to the inclusive range [min, max] (`style.width: ratio|clamp(0,1)|percent(0)`). */\nconst clamp = (options: string[]): FilterFn => {\n const min = requiredNumberOption(options, 0, 'clamp');\n const max = requiredNumberOption(options, 1, 'clamp');\n return (value: unknown): number => {\n if (typeof value !== 'number') {valueMustBeNumber('clamp', value);}\n return Math.min(Math.max(value, min), max);\n };\n};\n\n// The conversions convert — an absent value is converted too (`string` gives \"undefined\");\n// put `coalesce` in front when a missing value should not be converted.\nconst number = (): FilterFn => (value: unknown): number => Number(value);\n\nconst string = (): FilterFn => (value: unknown): string => String(value);\n\nconst int = (): FilterFn => (value: unknown): number => parseInt(String(value), 10);\n\nconst float = (): FilterFn => (value: unknown): number => parseFloat(String(value));\n\n/** Replaces a falsy value (JavaScript's truthiness) with the typed literal: defaults(0) gives 0, defaults('0') \"0\" (B9). */\nconst defaults = (options: string[], literals?: readonly unknown[]): FilterFn => {\n const opt = options?.[0] ?? optionsRequired('defaults');\n const fallback = firstLiteral(opt, literals);\n return (value: unknown): unknown => {\n if (!value) {return fallback;}\n return value;\n };\n};\n\n/** Replaces only null / undefined (`defaults` also replaces 0, false and \"\") — SQL's COALESCE. */\nconst coalesce = (options: string[], literals?: readonly unknown[]): FilterFn => {\n const opt = options?.[0] ?? optionsRequired('coalesce');\n const fallback = firstLiteral(opt, literals);\n return (value: unknown): unknown => value ?? fallback;\n};\n\n/** \"\" → null, anything else unchanged. */\nconst nullIfEmpty = (): FilterFn => (value: unknown): unknown => (value === \"\") ? null : value;\n\nconst { eq, ne, not, lt, le, gt, ge, falsy, truthy, boolean } = coreFilters;\n\n/**\n * What `installFormats()` registers: factory and [min, max] argument count (B3 — the same bounds\n * lint uses), in the order the registry keeps them. The did-you-mean suggestion gives a tie to the\n * first registered, so the order is the one the full build registered up to 4.0.0-rc.3, when this\n * add-on had the 23 display filters and the core 24: the display filters, then that core set, each\n * in the source's (lint's) relative order. The core's 10 are registered here too, in their place\n * (the core registers them again when it first plans a binding, and a name registered again keeps\n * its place).\n */\nconst registered: Readonly<Record<string, FilterDefinition>> = {\n toFixed: { factory: toFixed, arity: [0, 1] },\n locale: { factory: locale, arity: [0, 1] },\n\n // The `String(value)` family passes an absent value through (B8 — see nullishPassthrough)\n upper: { factory: nullishPassthrough(upper), arity: [0, 0] },\n lower: { factory: nullishPassthrough(lower), arity: [0, 0] },\n capitalize: { factory: nullishPassthrough(capitalize), arity: [0, 0] },\n trim: { factory: nullishPassthrough(trim), arity: [0, 0] },\n slice: { factory: nullishPassthrough(slice), arity: [1, 2] },\n // The length is required too (the implementation reads both)\n padStart: { factory: nullishPassthrough(padStart), arity: [1, 2] },\n padEnd: { factory: nullishPassthrough(padEnd), arity: [1, 2] },\n repeat: { factory: nullishPassthrough(repeat), arity: [1, 1] },\n reverse: { factory: nullishPassthrough(reverse), arity: [0, 0] },\n truncate: { factory: nullishPassthrough(truncate), arity: [1, 2] },\n join: { factory: join, arity: [0, 1] },\n\n round: { factory: round, arity: [0, 1] },\n floor: { factory: floor, arity: [0, 1] },\n ceil: { factory: ceil, arity: [0, 1] },\n percent: { factory: percent, arity: [0, 1] },\n unit: { factory: nullishPassthrough(unit), arity: [1, 1] },\n\n // The locale-dependent three take a locale like `locale` does (`date(ja-JP)`), and a style (`date(ja-JP,long)`)\n date: { factory: date, arity: [0, 2] },\n time: { factory: time, arity: [0, 2] },\n datetime: { factory: datetime, arity: [0, 2] },\n ymd: { factory: ymd, arity: [0, 1] },\n hms: { factory: hms, arity: [0, 1] },\n\n // the core set of 4.0.0-rc.3 (the core's own: eq ne not lt le gt ge falsy truthy boolean)\n eq, ne, not, lt, le, gt, ge,\n add: numeric('add', (value, opt) => value + opt),\n sub: numeric('sub', (value, opt) => value - opt),\n mul: numeric('mul', (value, opt) => value * opt),\n div: numeric('div', (value, opt) => value / opt),\n mod: numeric('mod', (value, opt) => value % opt),\n abs: { factory: abs, arity: [0, 0] },\n clamp: { factory: clamp, arity: [2, 2] },\n int: { factory: int, arity: [0, 0] },\n float: { factory: float, arity: [0, 0] },\n falsy, truthy,\n defaults: { factory: defaults, arity: [1, 1] },\n coalesce: { factory: coalesce, arity: [1, 1] },\n boolean,\n number: { factory: number, arity: [0, 0] },\n string: { factory: string, arity: [0, 0] },\n nullIfEmpty: { factory: nullIfEmpty, arity: [0, 0] },\n // (added in 4.2: last, so the order of the others is unchanged)\n currency: { factory: currency, arity: [1, 2] },\n};\n\n/** The formats add-on's own filters (what `registered` holds beyond the core set), in that order. */\nexport const formatFilters: Readonly<Record<string, FilterDefinition>> = /*#__PURE__*/ Object.fromEntries(\n /*#__PURE__*/ Object.entries(registered).filter(([name]) => !(name in coreFilters)),\n);\n\nlet installed = false;\n\n/** Puts the formats add-on in the registry. Idempotent. */\nexport function installFormats(): void {\n if (installed) return;\n installed = true;\n registerFilters(registered);\n}\n","/**\n * The formats add-on (@wcstack/state/features/formats): the 38 filters that compute and show a value\n * (display, string shaping, dates — locale-aware —, arithmetic, conversions, missing values).\n */\nimport type { Feature } from \"../hooks\";\nimport { installFormats } from \"../filters/formats\";\n\nexport const formats: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,eAAeD,GAAYhC,IAAiBwE,KAwP5BzC,MAAO,CAAC,EAAG,KAQxC8F,GAAY,ECnZHC,EAAmB,CAAEC,KAAM,UAAWC,QDsZ5C,WACDH,IACJA,GAAY,EACZI,EAAgBvG,GAClB,GCzZOwG,EAAQJ","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import{a as t,b as e,c as l,d as n,j as o}from"../chunks/chunk-7ZU3CLEG.js";var s=new WeakMap,r=!1,i=/^(?!prototype$)[^\d.*$][^.*]*$/;function f(t,e){let l=e.$listKeys,n=new Map;if(void 0!==l){(null===l||"object"!=typeof l)&&o("$listKeys must be an object mapping list paths to a key field or function.");for(let e of Object.keys(l)){let s=l[e];"string"==typeof s?n.set(t.o(e),t=>t[s]):"function"==typeof s?n.set(t.o(e),s):o(`$listKeys "${e}" must be a field name or a function.`)}}s.set(e,n)}function u(t){if(null===t||"object"!=typeof t)return!1;let e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}function a(t,e,l){let n=new Map;for(let s of e){u(s)||o(`$listKeys "${t}": rows must be plain objects.`);let e=l(s);null==e&&o(`$listKeys "${t}": a row has no key.`),n.has(e)&&o(`$listKeys "${t}": duplicate key ${JSON.stringify(e)}.`),n.set(e,s)}return n}function y(t,e,l,n){if(r||!Array.isArray(n))return!1;let o=s.get(t.target)?.get(e);if(void 0===o)return!1;let f=t.it(e,l);if(!Array.isArray(f)||f===n)return!1;let u=a(e.t,f,o);a(e.t,n,o);let y=[],p=[],c=f.length===n.length;for(let t=0;t<n.length;t++){let e=n[t],l=u.get(o(e));y.push(l??e),void 0!==l&&p.push([t,l,e]),y[t]!==f[t]&&(c=!1)}let $=[];for(let[t,e,l]of p){for(let n of Object.keys(l))Object.is(e[n],l[n])||$.push([t,n,l[n]]);for(let n of Object.keys(e))!(n in l)&&null!==e[n]&&$.push([t,n,null])}if(c&&0===$.length)return!0;if(!c){r=!0;try{t.T(e,l,y)}finally{r=!1}}if($.length>0){let n=t._e(0===e.n?null:l,e);for(let[l,o,s]of $){if("__proto__"===o)continue;let r=n.f[l],f=i.test(o)?t.o(`${e.t}.*.${o}`):null;null===f?.getter?t.T(f,r,s):(r.R[o]=s,t.T(t.o(`${e.t}.*`),r,r.R,!0))}}return!0}var p={name:"list-keys",install(){t.de=e(t.de,f),t.Ae=l(n,t.Ae,y)}},c=p;export{c as default,p as listKeys};
1
+ import{a as t,b as e,c as l,d as n,j as o}from"../chunks/chunk-BGUJ3HF6.js";var s=new WeakMap,r=!1,i=/^(?!prototype$)[^\d.*$][^.*]*$/;function f(t,e){let l=e.$listKeys,n=new Map;if(void 0!==l){(null===l||"object"!=typeof l)&&o("$listKeys must be an object mapping list paths to a key field or function.");for(let e of Object.keys(l)){let s=l[e];"string"==typeof s?n.set(t.o(e),t=>t[s]):"function"==typeof s?n.set(t.o(e),s):o(`$listKeys "${e}" must be a field name or a function.`)}}s.set(e,n)}function u(t){if(null===t||"object"!=typeof t)return!1;let e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}function a(t,e,l){let n=new Map;for(let s of e){u(s)||o(`$listKeys "${t}": rows must be plain objects.`);let e=l(s);null==e&&o(`$listKeys "${t}": a row has no key.`),n.has(e)&&o(`$listKeys "${t}": duplicate key ${JSON.stringify(e)}.`),n.set(e,s)}return n}function y(t,e,l,n){if(r||!Array.isArray(n))return!1;let o=s.get(t.target)?.get(e);if(void 0===o)return!1;let f=t.rt(e,l);if(!Array.isArray(f)||f===n)return!1;let u=a(e.t,f,o);a(e.t,n,o);let y=[],p=[],c=f.length===n.length;for(let t=0;t<n.length;t++){let e=n[t],l=u.get(o(e));y.push(l??e),void 0!==l&&p.push([t,l,e]),y[t]!==f[t]&&(c=!1)}let $=[];for(let[t,e,l]of p){for(let n of Object.keys(l))Object.is(e[n],l[n])||$.push([t,n,l[n]]);for(let n of Object.keys(e))!(n in l)&&null!==e[n]&&$.push([t,n,null])}if(c&&0===$.length)return!0;if(!c){r=!0;try{t.A(e,l,y)}finally{r=!1}}if($.length>0){let n=t.He(0===e.n?null:l,e);for(let[l,o,s]of $){if("__proto__"===o)continue;let r=n.f[l],f=i.test(o)?t.o(`${e.t}.*.${o}`):null;null===f?.getter?t.A(f,r,s):(r.E[o]=s,t.A(t.o(`${e.t}.*`),r,r.E,!0))}}return!0}var p={name:"list-keys",install(){t.de=e(t.de,f),t.Oe=l(n,t.Oe,y)}},c=p;export{c as default,p as listKeys};
2
2
  //# sourceMappingURL=list-keys.js.map
@@ -1,2 +1,2 @@
1
- import{b as e}from"../chunks/chunk-GGSHXG7N.js";import{a as t}from"../chunks/chunk-7ZU3CLEG.js";var i={"*":["focus","blur","click","scrollIntoView","showPopover","hidePopover","togglePopover"],dialog:["show","showModal","close","requestClose"],form:["requestSubmit","checkValidity","reportValidity"],input:["select","setSelectionRange","showPicker","setCustomValidity","checkValidity","reportValidity"],textarea:["select","setSelectionRange","setCustomValidity","checkValidity","reportValidity"],select:["showPicker","setCustomValidity","checkValidity","reportValidity"],audio:["play","pause","load"],video:["play","pause","load"]};function o(t,o){let a=t.localName;if(a.includes("-"))return null;let l=(e=>[...i["*"],...Object.hasOwn(i,e)?i[e]:[]])(a);return l.includes(o)||e(1205,[a,o,l.join(", ")],o,l),(e,t)=>e[o](...t[0]instanceof Event?[]:t)}var a={name:"native-commands",install(){t.or=o}},l=a;export{l as default,a as nativeCommands};
1
+ import{b as e}from"../chunks/chunk-UBGJGMSG.js";import{a as t}from"../chunks/chunk-BGUJ3HF6.js";var i={"*":["focus","blur","click","scrollIntoView","showPopover","hidePopover","togglePopover"],dialog:["show","showModal","close","requestClose"],form:["requestSubmit","checkValidity","reportValidity"],input:["select","setSelectionRange","showPicker","setCustomValidity","checkValidity","reportValidity"],textarea:["select","setSelectionRange","setCustomValidity","checkValidity","reportValidity"],select:["showPicker","setCustomValidity","checkValidity","reportValidity"],audio:["play","pause","load"],video:["play","pause","load"]};function o(t,o){let a=t.localName;if(a.includes("-"))return null;let l=(e=>[...i["*"],...Object.hasOwn(i,e)?i[e]:[]])(a);return l.includes(o)||e(1205,[a,o,l.join(", ")],o,l),(e,t)=>e[o](...t[0]instanceof Event?[]:t)}var a={name:"native-commands",install(){t.or=o}},l=a;export{l as default,a as nativeCommands};
2
2
  //# sourceMappingURL=native-commands.js.map
@@ -1,2 +1,2 @@
1
- import{m as e}from"../chunks/chunk-7QVEF5E3.js";import{b as t}from"../chunks/chunk-GGSHXG7N.js";import{a as r,b as l,c as n,d as s,j as a}from"../chunks/chunk-7ZU3CLEG.js";var i="$recursion",o=new WeakMap,c=new WeakSet,u=new WeakSet,h=0,d=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),$=e=>`[wcs/recursion-${e}]`;function f(e,t){let r=r=>a(`${$("declaration-invalid")} ${i} ${e} "${String(t)}" ${r}`);("string"!=typeof t||""===t)&&a(`${$("declaration-invalid")} ${i} ${e} must be a non-empty string.`);let l=t.split(".");(l.length<2||"*"!==l[l.length-1])&&r('must end with ".*" (a list element).');for(let e=0;e<l.length-1;e++){let t=l[e];""===t&&r("must not contain empty path segments."),("*"===t||"**"===t||/^\d/.test(t))&&r('must have exactly one "*", at the end.'),t.includes("#")&&r('must not contain "#".')}return"$"===t[0]&&r('must not start with "$".'),t}var p=(e,t)=>`${e.l}.*${e.step.repeat(t)}`;function g(e,t){let r=`${e.l}.**`,l=t.slice(r.length);return(!t.startsWith(r)||""!==l&&"."!==l[0]||l.includes("**"))&&a(`[wcs/recursion-anchor] "${t}" does not start at the recursion anchor "${e.l}.*".`),l}function m(e,t,r){let l=g(e,t),n=function(e,t){for(let r=t;null!==r;r=r.l.ae){let t=e.nodeList.exec(r.l.o.t);if(null!==t)return{k:t[1].length/(e.key.length+3),r}}return null}(e,r);return null===n&&a(`[wcs/recursion-context] "${t}" uses "**", which is bound to the depth of the row it is evaluated in; there is none here — use $getAll("${t}", []) for every depth.`),p(e,n.k)+l}function y(e,t,r){let l=new Set,n=new Set,s=(e,r,s)=>!(!Array.isArray(e)||0===e.length||(l.has(e)&&a(`${$("cycle")} "${r}" is reachable from itself: the data under "${t.l}" must be a tree.`),n.has(e)&&a(`${$("shared-list")} "${r}" is the same array instance as a list reached before: the data under "${t.l}" must be a tree.`),s+1>128&&a(`${$("depth-exceeded")} Recursion on "${t.l}.*" reached depth ${s+1} (the limit is 128).`),n.add(e),0)),i=(n,a)=>{for(let o of n){r(a,o);let n=e.o(`${p(t,a)}.${t.key}`),c=e.read(n,o);s(c,n.t,a+1)&&(l.add(c),i(e._e(o,n).f,a+1),l.delete(c))}},o=e.o(t.l),c=e.read(o,null);s(c,t.l,0)&&(l.add(c),i(e._e(null,o).f,0))}function w(r,l){let n=function(t){let r=t[i],l=[],n=new Set;for(let e=t;null!==e&&e!==Object.prototype;e=Object.getPrototypeOf(e))for(let t of Object.getOwnPropertyNames(e))!n.has(t)&&t.includes("**")&&l.push([t,Object.getOwnPropertyDescriptor(e,t)]),n.add(t);if(void 0===r)return l.length>0&&e(l[0][0]),null;(null===r||"object"!=typeof r||Array.isArray(r))&&a(`${$("declaration-invalid")} ${i} must be an object mapping one anchor path to its repeating sub-path.`);let s=Object.entries(r);1!==s.length&&a(`${$("declaration-invalid")} ${i} must declare exactly one anchor (it declares ${s.length}).`);let o=f("anchor",s[0][0]),c=f("repeat",s[0][1]),u=o.slice(0,-2),h=c.slice(0,-2),p=`.${c}`,g=new Map,m=[],y=`${u}.**`;for(let[e,t]of l){let r=e.slice(y.length);(!e.startsWith(y)||""!==r&&"."!==r[0]||r.includes("**"))&&a(`[wcs/recursion-anchor] "${e}": a recursive key is "${y}" followed by a path (the anchor is "${o}").`),(""===r||r.split(".").slice(1).some(e=>""===e))&&a(`[wcs/recursion-anchor] "${e}" needs a path after "**".`),(void 0===t.get||void 0!==t.set)&&a(`${$("declaration-invalid")} "${e}": a recursive key is a getter without a setter.`),g.set(r,t.get),m.push([new RegExp(`^${d(o)}((?:${d(p)})*)${d(r)}$`),r])}return{l:u,step:p,key:h,families:g,matchers:m,owners:new Map,nodeList:new RegExp(`^${d(u)}((?:${d(`.*.${h}`)})*)$`)}}(l),s=o.has(r);null!==n?(s||h++,o.set(r,n),u.add(r),c.has(r)||function(r){c.add(r);let l=r,n=l.ot;l.ot=t=>{let s=o.get(r);if(t.t.includes("**")){let l=r.I.Dt(t.t)===t;return void(u.has(r)||void 0===s&&l?t.getter=()=>e(t.t):l||n.call(r,t))}if(void 0!==s&&null===t.getter)for(let[e,r]of s.matchers)if(e.test(t.t)){t.getter=s.families.get(r),t.n>0&&(t.A=l.je++),s.owners.set(t,s.l+".**"+r);break}n.call(r,t)};let s=l.resolve;l.resolve=(e,t)=>{let l=o.get(r);return s.call(r,void 0!==l&&e.includes("**")?m(l,e,t):e,t)};let i=l.getAll;l.getAll=(e,t)=>{let n=o.get(r);if(void 0===n||!e.includes("**"))return i.call(r,e,t);if(void 0===t)return i.call(r,m(n,e,l.u));(!Array.isArray(t)||t.length>0)&&a(`${$("getall-form")} $getAll("${e}", indexes) with "**" takes either no indexes (this depth) or [] (every depth).`);let s=g(n,e),c=[];return y(r,n,(e,t)=>{for(let l of i.call(r,p(n,e)+s,r.H(t)))c.push(l)}),c};let h=l.yn;l.yn=(e,n,s,i)=>{let c=o.get(r);if(void 0===c||!e.includes("**"))return h.call(r,e,n,s,i);Array.isArray(n)||t(9,[e]),n.length>0&&a(`${$("setall-form")} $setAll("${e}", indexes, …) with "**" takes no partial prefix: pass [] to write every node.`),("function"==typeof s||!0===i?.spread)&&a(`${$("setall-form")} $setAll("${e}", [], value) with "**" takes a plain value (no mapper, no spread).`),l.De>0&&t(8);let u=g(c,e),d=u.replace(/\.\d+(?=\.|$)/g,".*");for(;d.startsWith(c.step);)d=d.slice(c.step.length);let f=c.key.split(".");(""===d||d===`.${c.key}.length`||f.some((e,t)=>d===`.${f.slice(0,t+1).join(".")}`))&&a(`${$("structural-write")} "${e}" writes the recursion structure itself (a node, its "${c.key}" list or that list's length, or an object on the way to it).`);for(let t of c.families.keys()){let r=t;for(;r.startsWith(c.step);)r=r.slice(c.step.length);(d===r||d.startsWith(`${r}.`))&&a(`${$("readonly")} "${e}" writes into the recursive getter "${c.l}.**${t}".`)}let m=[];y(r,c,(e,t)=>m.push([e,t]));let w=0;for(let[e,t]of m)w+=h.call(r,p(c,e)+u,r.H(t),s);return w}}(r)):s&&(o.delete(r),h--)}function v(e,t){if(0===h)return!1;let r=o.get(e);if(void 0===r)return!1;for(let e=t;null!==e;e=e.d){let l=r.owners.get(e);void 0!==l&&a(`${$("readonly")} "${t.t}" writes into the recursive getter "${l}".`)}return!1}var k={name:"recursion",install(){r.de=l(r.de,w),r.element=l(r.element,(e,t)=>{("mounting"===t||"reset"===t)&&function(e){u.delete(e)}(e)}),r.Ae=n(s,r.Ae,v)}},b=k;export{b as default,k as recursion};
1
+ import{m as e}from"../chunks/chunk-6I7GGFNJ.js";import{b as t}from"../chunks/chunk-UBGJGMSG.js";import{a as r,b as l,c as n,d as s,j as a}from"../chunks/chunk-BGUJ3HF6.js";var i="$recursion",o=new WeakMap,c=new WeakSet,u=new WeakSet,h=0,d=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),$=e=>`[wcs/recursion-${e}]`;function f(e,t){let r=r=>a(`${$("declaration-invalid")} ${i} ${e} "${String(t)}" ${r}`);("string"!=typeof t||""===t)&&a(`${$("declaration-invalid")} ${i} ${e} must be a non-empty string.`);let l=t.split(".");(l.length<2||"*"!==l[l.length-1])&&r('must end with ".*" (a list element).');for(let e=0;e<l.length-1;e++){let t=l[e];""===t&&r("must not contain empty path segments."),("*"===t||"**"===t||/^\d/.test(t))&&r('must have exactly one "*", at the end.'),t.includes("#")&&r('must not contain "#".')}return"$"===t[0]&&r('must not start with "$".'),t}var p=(e,t)=>`${e.l}.*${e.step.repeat(t)}`;function g(e,t){let r=`${e.l}.**`,l=t.slice(r.length);return(!t.startsWith(r)||""!==l&&"."!==l[0]||l.includes("**"))&&a(`[wcs/recursion-anchor] "${t}" does not start at the recursion anchor "${e.l}.*".`),l}function m(e,t,r){let l=g(e,t),n=function(e,t){for(let r=t;null!==r;r=r.l.ae){let t=e.nodeList.exec(r.l.o.t);if(null!==t)return{k:t[1].length/(e.key.length+3),r}}return null}(e,r);return null===n&&a(`[wcs/recursion-context] "${t}" uses "**", which is bound to the depth of the row it is evaluated in; there is none here — use $getAll("${t}", []) for every depth.`),p(e,n.k)+l}function y(e,t,r){let l=new Set,n=new Set,s=(e,r,s)=>!(!Array.isArray(e)||0===e.length||(l.has(e)&&a(`${$("cycle")} "${r}" is reachable from itself: the data under "${t.l}" must be a tree.`),n.has(e)&&a(`${$("shared-list")} "${r}" is the same array instance as a list reached before: the data under "${t.l}" must be a tree.`),s+1>128&&a(`${$("depth-exceeded")} Recursion on "${t.l}.*" reached depth ${s+1} (the limit is 128).`),n.add(e),0)),i=(n,a)=>{for(let o of n){r(a,o);let n=e.o(`${p(t,a)}.${t.key}`),c=e.read(n,o);s(c,n.t,a+1)&&(l.add(c),i(e.He(o,n).f,a+1),l.delete(c))}},o=e.o(t.l),c=e.read(o,null);s(c,t.l,0)&&(l.add(c),i(e.He(null,o).f,0))}function w(r,l){let n=function(t){let r=t[i],l=[],n=new Set;for(let e=t;null!==e&&e!==Object.prototype;e=Object.getPrototypeOf(e))for(let t of Object.getOwnPropertyNames(e))!n.has(t)&&t.includes("**")&&l.push([t,Object.getOwnPropertyDescriptor(e,t)]),n.add(t);if(void 0===r)return l.length>0&&e(l[0][0]),null;(null===r||"object"!=typeof r||Array.isArray(r))&&a(`${$("declaration-invalid")} ${i} must be an object mapping one anchor path to its repeating sub-path.`);let s=Object.entries(r);1!==s.length&&a(`${$("declaration-invalid")} ${i} must declare exactly one anchor (it declares ${s.length}).`);let o=f("anchor",s[0][0]),c=f("repeat",s[0][1]),u=o.slice(0,-2),h=c.slice(0,-2),p=`.${c}`,g=new Map,m=[],y=`${u}.**`;for(let[e,t]of l){let r=e.slice(y.length);(!e.startsWith(y)||""!==r&&"."!==r[0]||r.includes("**"))&&a(`[wcs/recursion-anchor] "${e}": a recursive key is "${y}" followed by a path (the anchor is "${o}").`),(""===r||r.split(".").slice(1).some(e=>""===e))&&a(`[wcs/recursion-anchor] "${e}" needs a path after "**".`),(void 0===t.get||void 0!==t.set)&&a(`${$("declaration-invalid")} "${e}": a recursive key is a getter without a setter.`),g.set(r,t.get),m.push([new RegExp(`^${d(o)}((?:${d(p)})*)${d(r)}$`),r])}return{l:u,step:p,key:h,families:g,matchers:m,owners:new Map,nodeList:new RegExp(`^${d(u)}((?:${d(`.*.${h}`)})*)$`)}}(l),s=o.has(r);null!==n?(s||h++,o.set(r,n),u.add(r),c.has(r)||function(r){c.add(r);let l=r,n=l.nt;l.nt=t=>{let s=o.get(r);if(t.t.includes("**")){let l=r.I.jt(t.t)===t;return void(u.has(r)||void 0===s&&l?t.getter=()=>e(t.t):l||n.call(r,t))}if(void 0!==s&&null===t.getter)for(let[e,r]of s.matchers)if(e.test(t.t)){t.getter=s.families.get(r),t.n>0&&(t.F=l.Le++),s.owners.set(t,s.l+".**"+r);break}n.call(r,t)};let s=l.resolve;l.resolve=(e,t)=>{let l=o.get(r);return s.call(r,void 0!==l&&e.includes("**")?m(l,e,t):e,t)};let i=l.getAll;l.getAll=(e,t)=>{let n=o.get(r);if(void 0===n||!e.includes("**"))return i.call(r,e,t);if(void 0===t)return i.call(r,m(n,e,l.u));(!Array.isArray(t)||t.length>0)&&a(`${$("getall-form")} $getAll("${e}", indexes) with "**" takes either no indexes (this depth) or [] (every depth).`);let s=g(n,e),c=[];return y(r,n,(e,t)=>{for(let l of i.call(r,p(n,e)+s,r.H(t)))c.push(l)}),c};let h=l.yn;l.yn=(e,n,s,i)=>{let c=o.get(r);if(void 0===c||!e.includes("**"))return h.call(r,e,n,s,i);Array.isArray(n)||t(9,[e]),n.length>0&&a(`${$("setall-form")} $setAll("${e}", indexes, …) with "**" takes no partial prefix: pass [] to write every node.`),("function"==typeof s||!0===i?.spread)&&a(`${$("setall-form")} $setAll("${e}", [], value) with "**" takes a plain value (no mapper, no spread).`),l.Be>0&&t(8);let u=g(c,e),d=u.replace(/\.\d+(?=\.|$)/g,".*");for(;d.startsWith(c.step);)d=d.slice(c.step.length);let f=c.key.split(".");(""===d||d===`.${c.key}.length`||f.some((e,t)=>d===`.${f.slice(0,t+1).join(".")}`))&&a(`${$("structural-write")} "${e}" writes the recursion structure itself (a node, its "${c.key}" list or that list's length, or an object on the way to it).`);for(let t of c.families.keys()){let r=t;for(;r.startsWith(c.step);)r=r.slice(c.step.length);(d===r||d.startsWith(`${r}.`))&&a(`${$("readonly")} "${e}" writes into the recursive getter "${c.l}.**${t}".`)}let m=[];y(r,c,(e,t)=>m.push([e,t]));let w=0;for(let[e,t]of m)w+=h.call(r,p(c,e)+u,r.H(t),s);return w}}(r)):s&&(o.delete(r),h--)}function v(e,t){if(0===h)return!1;let r=o.get(e);if(void 0===r)return!1;for(let e=t;null!==e;e=e.d){let l=r.owners.get(e);void 0!==l&&a(`${$("readonly")} "${t.t}" writes into the recursive getter "${l}".`)}return!1}var k={name:"recursion",install(){r.de=l(r.de,w),r.element=l(r.element,(e,t)=>{("mounting"===t||"reset"===t)&&function(e){u.delete(e)}(e)}),r.Oe=n(s,r.Oe,v)}},b=k;export{b as default,k as recursion};
2
2
  //# sourceMappingURL=recursion.js.map