@wcstack/state 4.0.0 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +5 -5
- package/README.md +5 -5
- package/dist/auto.min.js +1 -1
- package/dist/auto.min.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/parser.esm.js +4 -0
- package/dist/split/auto.js +1 -1
- package/dist/split/chunks/{chunk-M5SODAAE.js → chunk-6MACFEK7.js} +2 -2
- package/dist/split/chunks/chunk-BMGEWHCR.js +2 -0
- package/dist/split/chunks/chunk-BMGEWHCR.js.map +1 -0
- package/dist/split/chunks/{chunk-UD3AYVP2.js → chunk-DFXQ7MFW.js} +2 -2
- package/dist/split/chunks/{chunk-7AYOQHZH.js → chunk-EM3Y3SJS.js} +2 -2
- package/dist/split/chunks/{chunk-EIMTT5I3.js → chunk-M656SMUU.js} +1 -1
- package/dist/split/chunks/{chunk-EIMTT5I3.js.map → chunk-M656SMUU.js.map} +1 -1
- package/dist/split/chunks/{chunk-W4KOY6GT.js → chunk-PHAN6L23.js} +2 -2
- package/dist/split/chunks/chunk-SGLI2TU4.js +2 -0
- package/dist/split/chunks/{chunk-ZQ642MBV.js.map → chunk-SGLI2TU4.js.map} +1 -1
- package/dist/split/chunks/{chunk-NOPTR2L3.js → chunk-TUQ3OPZQ.js} +2 -2
- package/dist/split/chunks/{chunk-55J45X6H.js → chunk-V6VVL4F3.js} +2 -2
- package/dist/split/core.js +1 -1
- package/dist/split/features/devtools.js +1 -1
- package/dist/split/features/diagnostics.js +1 -1
- package/dist/split/features/diagnostics.js.map +1 -1
- package/dist/split/features/formats.js +1 -1
- package/dist/split/features/native-commands.js +1 -1
- package/dist/split/features/recursion.js +1 -1
- package/dist/split/features/scopes.js +1 -1
- package/dist/split/features/ssr.js +1 -1
- package/package.json +1 -1
- package/dist/split/chunks/chunk-L3PFEJP7.js +0 -2
- package/dist/split/chunks/chunk-L3PFEJP7.js.map +0 -1
- package/dist/split/chunks/chunk-ZQ642MBV.js +0 -2
- /package/dist/split/chunks/{chunk-M5SODAAE.js.map → chunk-6MACFEK7.js.map} +0 -0
- /package/dist/split/chunks/{chunk-UD3AYVP2.js.map → chunk-DFXQ7MFW.js.map} +0 -0
- /package/dist/split/chunks/{chunk-7AYOQHZH.js.map → chunk-EM3Y3SJS.js.map} +0 -0
- /package/dist/split/chunks/{chunk-W4KOY6GT.js.map → chunk-PHAN6L23.js.map} +0 -0
- /package/dist/split/chunks/{chunk-NOPTR2L3.js.map → chunk-TUQ3OPZQ.js.map} +0 -0
- /package/dist/split/chunks/{chunk-55J45X6H.js.map → chunk-V6VVL4F3.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","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.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 for (const q of chain) {\n if (named(q)?.getter != null) return null;\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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B,EAClC,CA8HMsG,CAAQtG,IAEV0C,EAAM6D,GAASC,EAAMC,EAAO/D,EAAM6D,GAAQ,CAAC9C,EAAShJ,IAASoD,OAAOC,OAAO8G,EAAcnK,GAAO0K,OAAoB,CAAC1K,EAAKmK,EAAanK,UAAS,EAClJ,GAEKiM,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","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 for (const q of chain) {\n if (named(q)?.getter != null) return null;\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,E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,EAAQ6C,OAAO7B,GACXlB,EAAMF,IAAIoB,IAAS2B,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,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-
|
|
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-PHAN6L23.js";import{a as y,e as u}from"../chunks/chunk-6MACFEK7.js";import{a as s}from"../chunks/chunk-M656SMUU.js";import"../chunks/chunk-4NJBYXIT.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:M,gt:$,ge:k,falsy:j,truthy:F,boolean:w}=c,x={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:M,gt:$,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:F,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:w,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]}},D=!1,L={name:"formats",install:function(){D||(D=!0,u(x))}},v=L;export{v as default,L as formats};
|
|
2
2
|
//# sourceMappingURL=formats.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as e}from"../chunks/chunk-
|
|
1
|
+
import{b as e}from"../chunks/chunk-M656SMUU.js";import{a as t}from"../chunks/chunk-4NJBYXIT.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-
|
|
1
|
+
import{m as e}from"../chunks/chunk-TUQ3OPZQ.js";import{b as t}from"../chunks/chunk-M656SMUU.js";import{a as r,b as l,c as n,d as s,j as a}from"../chunks/chunk-4NJBYXIT.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.We(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.We(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.A=l.Ie++),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.je>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};
|
|
2
2
|
//# sourceMappingURL=recursion.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e,b as t,d as n}from"../chunks/chunk-55J45X6H.js";import{b as o,n as l,o as r,p as i}from"../chunks/chunk-L3PFEJP7.js";import"../chunks/chunk-W4KOY6GT.js";import{e as a,f as s}from"../chunks/chunk-7AYOQHZH.js";import{a as u}from"../chunks/chunk-M5SODAAE.js";import"../chunks/chunk-ZN52NEIB.js";import"../chunks/chunk-NOPTR2L3.js";import"../chunks/chunk-EIMTT5I3.js";import{a as c,b as d,c as f,d as h,f as p,h as m,j as g}from"../chunks/chunk-4NJBYXIT.js";var $=new WeakMap,b=new WeakMap,w="will not graft: the root state failed to initialize.",y=new WeakSet,v=new WeakMap,k=["$stream","$streams","$scan","$recursion","$watch","$listKeys","$renderedCallback","$updatedCallback","$behavior","$features"],N=["$commandTokens","$eventTokens","$on","$errorCallback"],j=e=>`[@wcstack/state] <${u.tagNames.state} mount="${e}">`,O=new Set(["$getAll","$setAll","$resolve","$postUpdate","$dependOn","$eq","$eqIndex"]),A=e=>e?.element?.isConnected?e:void 0;function C(e){let t=b.get(e);return void 0!==t&&!Array.isArray(t)&&t.isConnected}function P(e,t){let n=b.get(t);if(b.delete(t),Array.isArray(n))for(let t of n)D(t,e)}function M(e){let t=$.get(e.root);t?.get(e.t)===e&&t.delete(e.t)}function x(e,t){console.error(`${j(e.t)} ${t}`),M(e),e.Qe?.(),e.Qe=null}function S(e,t){let n=e.state?.[t];if("function"==typeof n)try{let t=n.call(e.chroot);null!==t&&"object"==typeof t&&"function"==typeof t.then&&t.then(void 0,e=>console.error(e))}catch(e){console.error(e)}}function D(e,t){if(y.has(t))return x(e,"will not graft: its component is wired to its host.");let n=e.state,o=t.target,l=e.t.split("."),r=o;for(let e of l)r=r?.[e];if(void 0!==r&&!0!==t.hydrated)return x(e,`will not graft: the root state already has "${e.t}".`);let i=function(e,t){let n=e=>`${t}.${e}`;return new Proxy({},{get(t,o){if("symbol"==typeof o)return;if(36!==o.charCodeAt(0))return e.proxy[n(o)];let l=e.proxy[o];return"$eqPath"===o?(e,t)=>l(n(e),n(t)):O.has(o)&&"function"==typeof l?(e,...t)=>l(n(e),...t):l},set:(t,o,l)=>"symbol"!=typeof o&&(e.proxy[n(o)]=l,!0)})}(t,e.t);e.chroot=i;let a={},s={},u=new Set;for(let t=n;null!==t&&t!==Object.prototype;t=Object.getPrototypeOf(t))for(let n of Object.getOwnPropertyNames(t)){if(u.has(n)||"constructor"===n)continue;u.add(n);let{get:o,set:l,value:r}=Object.getOwnPropertyDescriptor(t,n);if(void 0!==o||void 0!==l)s[`${e.t}.${n}`]={get:o&&function(){return o.call(i)},set:l&&function(e){l.call(i,e)}};else{if("$"===n[0])continue;if("function"==typeof r){let t=r.bind(i);s[`${e.t}.${n}`]={get:()=>t}}else a[n]=r}}if(void 0===r){for(let e=1;e<l.length;e++){let n=t.o(l.slice(0,e).join("."));null==t.rt(n,null)&&t.T(n,null,{})}t.T(t.o(e.t),null,a)}t.to(Object.defineProperties({},s));for(let e in s)t._e(t.o(e),null);e.engine=t;let c=v.get(t);void 0===c&&v.set(t,c=[]),c.push(e),e.el.isConnected&&S(e,"$connectedCallback"),e.Qe?.(),e.Qe=null}function W(e,t){let n=b.get(e);if(Array.isArray(n))for(let e of n)x(e,w);b.set(e,t)}var E=new WeakMap;function T(e,t){let n=e.getAttribute("mount");if(null===n)return null;let o={el:e,root:t,t:n,state:null,engine:null,chroot:null,Qe:null},r=null;if(function(e){return""!==e&&e.split(".").every(e=>""!==e&&!/[*$#@\s]/.test(e))}(n))if(e.hasAttribute(u.bindAttributeName))r='injections (data-wcs="state.<key>: …") are not supported — read the root path in a root getter.';else{let e=$.get(t);void 0===e&&$.set(t,e=new Map);let l=e.get(n);if(void 0!==l&&l!==o&&(null===l.engine?l.el.isConnected:A(l.engine)))r=`will not graft: another volume already holds "${n}".`;else{if(null===l?.engine){let e=b.get(t);Array.isArray(e)&&b.set(t,e.filter(e=>e!==l)),l.Qe?.(),l.Qe=null}e.set(n,o)}}else r='has an invalid mount path: it must be a static path (no "*", "$", "#", "@").';return{No:!0,start(e){if(null!==r)return x(o,r);if($.get(t).get(n)===o){for(let t of k)if(void 0!==e[t])return x(o,`${t} is not run in a volume — declare it on the root state.`);for(let t of N)void 0!==e[t]&&console.warn(`${j(n)} ${t} is not run in a volume (it belongs to the root).`);return o.state=e,new Promise(e=>{o.Qe=e;let n=A(l.get(t)),r=b.get(t);void 0!==n?D(o,n):C(t)?x(o,w):b.set(t,[...Array.isArray(r)?r:[],o])})}},Xe(){null!==o.engine&&S(o,"$connectedCallback")},Ln(){null!==o.engine&&S(o,"$disconnectedCallback")},reset(){g(`re-setting a volume is not supported: its data was copied into the root tree at "${n}" — write the paths under it on the root instead.`)}}}var z=new WeakMap,R=new WeakMap;function q(e,t){let n=e[t];if(void 0===n)return[];Array.isArray(n)||g(`${t} must be an array of state member names.`);let o=new Set;for(let e of n)("string"!=typeof e||""===e)&&g(`${t} entries must be non-empty strings.`),"$"===e[0]&&g(`${t} entry "${e}": internal ($) members are never exposed.`),o.has(e)&&g(`${t} entry "${e}" is duplicated.`),o.add(e);return n}function Q(e,t){let n=t.host;if(void 0===n||!n.hasAttribute("data-wc-definition"))return null;let o=document.createDocumentFragment();for(let e of[...t.childNodes])o.appendChild(e.cloneNode(!0));let l=t.mode;return{start(t){e.hasAttribute("bind-component")&&g("DCC: a <wcs-state bind-component> cannot define a component (use one mechanism)."),function(e,t,n,o){e.includes("-")||g(`DCC: <${e} data-wc-definition> is not a valid custom element name.`),void 0!==customElements.get(e)&&g(`DCC: <${e}> is already defined.`);let l=function(e){let t=new Map;for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n))for(let e of Object.getOwnPropertyNames(n))"constructor"===e||"$"===e[0]||t.has(e)||t.set(e,Object.getOwnPropertyDescriptor(n,e));let n=e.$stream;if(null!==n&&"object"==typeof n)for(let e of Object.keys(n))t.has(e)||t.set(e,{value:void 0});return t}(o),r=q(o,"$bindables"),i=q(o,"$commands");for(let e of r){let t=l.get(e);void 0===t&&g(`$bindables entry "${e}" does not exist on the state.`),"function"==typeof t.value&&g(`$bindables entry "${e}" is a method: list it in $commands.`)}for(let e of i){let t=l.get(e);void 0===t&&g(`$commands entry "${e}" does not exist on the state.`),"function"!=typeof t.value&&g(`$commands entry "${e}" is not a method: list it in $bindables.`)}let a={tag:e,bindables:r},s=new WeakMap,c=new WeakMap,d=o=>{if(s.has(o))return s.get(o);if(o.hasAttribute("data-wc-definition"))return null;let l=o.attachShadow({mode:n});l.appendChild(t.cloneNode(!0));let i=l.querySelector(u.tagNames.state);return s.set(o,i),z.set(o,a),null===i&&r.length>0&&console.warn(`[@wcstack/state] DCC: <${e}> declares $bindables but its content has no <${u.tagNames.state}>: no change events.`),i},f=e=>d(e)?.engine??null,h=e=>Promise.resolve(d(e)?.initializePromise).then(()=>{let t=c.get(e);c.delete(e);let n=f(e);if(void 0!==t&&null!==n)for(let[e,o]of t)n.proxy[e]=o});class p extends HTMLElement{static{this.wcBindable=0===r.length&&0===i.length?null:{protocol:"wc-bindable",version:1,properties:r.map(t=>({name:t,event:`${e}:${t}-changed`,getter:e=>e.target[t]})),inputs:r.map(e=>({name:e})),...0===i.length?{}:{commands:i.map(e=>({name:e,async:!0}))}}}connectedCallback(){null!==d(this)&&h(this)}get stateElement(){return d(this)}}for(let[e,t]of l)"function"==typeof t.value?Object.defineProperty(p.prototype,e,{configurable:!0,value(...t){return h(this).then(()=>{let n=f(this);return null===n?void 0:n.proxy[e].apply(n.proxy,t)})}}):Object.defineProperty(p.prototype,e,{configurable:!0,get(){return f(this)?.proxy[e]},set(t){let n=f(this);if(null!==n)n.proxy[e]=t;else{let n=c.get(this);void 0===n&&c.set(this,n=[]),n.push([e,t])}}});customElements.define(e,p)}(n.localName,o,l,t)},Xe(){},Ln(){},reset(){g("re-setting a DCC definition is not supported: each instance loads its own state.")}}}var H=new WeakMap,I=new WeakSet,L=new WeakMap,X=new WeakMap,_="data-wcs-wired",Y=new WeakMap,B=new WeakMap,F=new WeakMap,J=0,V=new Set,G={},K=["$watch","$stream","$renderedCallback"],Z=e=>e.split(".",1)[0];function U(e,t){let n=0;return e.split(".").map(e=>"*"===e?String(t[n++]):e).join(".")}function ee(e,t){let n=e.a,o=Z(e.name);if(!0!==document.documentElement?.hasAttribute("data-wcs-server"))n.removeAttribute(_);else if(!ne(n,o)){let e=n.getAttribute(_)?.split(" ")??[];e.includes(o)||n.setAttribute(_,[...e,o].join(" "))}Y.get(n)?.pe===o&&g(`<${n.localName}>.${o} has loaded its state: the wiring "${e.name}" added afterwards cannot reach it — bind the host's wiring before the component loads.`);let l=H.get(n);void 0===l&&H.set(n,l=[]),l.push(e),t&&I.add(e);let r=L.get(n);return void 0===r&&L.set(n,r=new Map),r.has(o)||r.set(o,n[o]),X.get(n)?.(),!1}function te(e){return e.localName.includes("-")&&null!==e.querySelector(`:scope > ${u.tagNames.state}[bind-component]`)}function ne(e,t){let n=e.getAttribute(u.bindAttributeName);return null!==n&&new RegExp(`(^|;)\\s*${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*[.#:]`).test(n)}function oe(t){let n=t.parentElement;for(;null!==n&&!te(n);)n=n.parentElement;let o=l.get(n??t.getRootNode()),r=o?.element;(r?.isConnected?r.V:null===n)&&(null===n?e(t):i(o,t))}var le=new Set;function re(e,t){le.has(e)||(le.add(e),console.warn(`[@wcstack/state] ${t}`))}var ie=(e,t)=>t in e.state;function ae(e,t){let n=se(e.state,t);return void 0!==n&&(void 0!==n.get||void 0!==n.set||"function"==typeof n.value)}function se(e,t){for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n)){let e=Object.getOwnPropertyDescriptor(n,t);if(void 0!==e)return e}}function ue(e,t,n){if(null!==n.getter)return;let o,l=e.host,r=l.engine,i=Z(n.t),s=l.entries.find(e=>e.$===n.t);if(void 0===s&&null!==n.d)return function(e,t){let n,o=t.d;for(;null!==o&&void 0===(n=e.dt.get(o));)o=o.d;if(null===o||void 0===n)return;let l=e.N,r=e.host.engine,i=r.o(n.p.t+t.t.slice(o.t.length));if(null===i.getter)return;let s=n,u=()=>{let n=ce(e,s.r);return 0===t.n?n:(r.resolve(U(i.t,[...r.H(n),...l.H(a(l.u,t.n))]),null),r.rr)};t.getter=()=>{let e=u();return i.n>0&&null===e?void 0:r.v(i,e)},null!==i.ie&&(t.ie=n=>{let o=u();de(e,s.e,()=>r.T(i,o,n)),e.dn=t}),t.n>0&&(t.A=l.Ie++),e.dt.set(t,{e:s.e,p:i,r:s.r})}(e,n);if(0!==n.n)return;if(void 0!==s){if(s.$!==i?ie(l,i):ae(l,i))return;o=s.me}else{if(null===t||null!==n.d||"$"===i[0]||ie(l,i))return;s=t,o=r.o(`${t.me.t}.${i}`)}let u=s.r,c=s;n.getter=()=>r.v(o,ce(e,u)),n.ie=t=>{de(e,c,()=>r.T(o,u,t)),e.dn=n},e.dt.set(n,{e:s,p:o,r:u})}function ce(e,t){return null!==t&&!t.y&&g(`The host row of <${e.host.el.localName}> was removed.`),t}function de(e,t,n){let o=V.has(e.N);V.add(e.N),e.from=t;try{n()}finally{o||V.delete(e.N),e.from=null}}var fe=(e,t)=>t||!V.has(e.m.N)||null!==e.m.from&&e.m.from!==e.e;function he(e,t){if(e.fn===t||null===e.host.engine)return;e.fn=t,J+=t?1:-1;let n=e.host.engine,o=F.get(n);void 0===o&&F.set(n,o=new Map);for(let n of e.fe){let e=o.get(n.e.me);void 0===e&&o.set(n.e.me,e=new Map);let l=e.get(n.e.r);void 0===l&&e.set(n.e.r,l=new Set),t?l.add(n):(l.delete(n),0===l.size&&e.delete(n.e.r))}let l=e.host.entries.find(e=>""===e.$);if(void 0!==l){null===e.re&&function(e,t){let n=e.host,o=n.engine;e.re=new Map;let l=new Set;for(let r=n.state;null!==r&&r!==Object.prototype;r=Object.getPrototypeOf(r))for(let i of Object.getOwnPropertyNames(r)){if(l.has(i))continue;l.add(i);let a=Object.getOwnPropertyDescriptor(r,i);if(void 0===a.get&&void 0===a.set||"$"===i[0]||i.includes("*"))continue;let s=Z(i);if(i!==s&&!ie(n,s))continue;let u=o.o(`${t.me.t}.${i}`);if(null===u.getter)ge(o,u,t.me);else if(!pe.has(u.getter))continue;e.re.set(u,e.N.o(i))}}(e,l);for(let o of e.re.keys())t&&null===o.getter&&ge(n,o,l.me),n.P.we(n,o,l.r);e.re.size>0&&n.Te(),t&&function(e,t){let n=e.host.engine;for(let[o,l]of e.re){let r=n.v(o.d,t.r);if(null===r||"object"!=typeof r||!(o.s in r))continue;let i=e.host.el.localName;re(`${i}|${o.t}`,`[wcs/mount-export-shadowed] <${i}>.${e.host.pe}.${l.t} is exported at "${o.t}" but the tree already has that key, so readers outside the component get the tree value. Remove the tree key or rename the accessor. See docs/state-overlay-export-design.md X1.`)}}(e,l)}}var pe=new WeakSet;function me(e,t,n,o){let l=F.get(e)?.get(t)?.get(n);if(void 0===l)return null;let r=null;for(let e of l)""!==e.e.$||!0!==e.m.re?.has(o)||e.m===r||(null!==r&&g(`[wcs/mount-export-ambiguous] "${o.t}" is exported by two mounted components on the same instance: <${r.host.el.localName}> and <${e.m.host.el.localName}>. Mount only one of them there, or rename one accessor. See docs/state-overlay-export-design.md X4.`),r=e.m);return r}function ge(e,t,n){let o=t.d,l=t.s,r=()=>{let t=e.read(o,e.u);return null!==t&&"object"==typeof t&&l in t?t:null};t.getter=()=>{let o=r();if(null!==o)return o[l];let i=me(e,n,e.u,t);return null===i?void 0:i.N.read(i.re.get(t),null)},pe.add(t.getter),t.ie=i=>{let a=null===r()?me(e,n,e.u,t):null;if(null===a){let t=e.read(o,e.u);return void(null!==t&&"object"==typeof t&&(t[l]=i))}let s=a.re.get(t);void 0===se(a.host.state,s.t)?.set&&g(`Cannot write to "${s.t}" on mounted <${a.host.el.localName}>: the accessor has no setter. Add a setter or write to the underlying state paths instead.`),a.N.T(s,null,i)},t.n>0&&(t.A=e.Ie++)}function $e(e,t,n,o,l,r){if(null!==t.getter)return e.P.we(e,t,n),void e.Te();if("*"===t.s){if(null===n)return;if(n.R=n.l.C[n.b],e.P.Yt(n),null!==n.c)for(let t of n.c.values())e.X(t)}else e.$n(t,n);c.be?.(e,t,n,o,l,r),e._e(t,n)}function be(e){let t=e.m.N;for(let[n,o]of e.m.dt)o.e===e.e&&(0===n.n?t.P.we(t,n,null):t.tn(n.h[n.n],e=>t.P.we(t,n,e)));t.Te()}function we(e,t,n,o,l,r,i){let s=n.t.slice(t.t.length);if(""===s)return be(e);let u,c=e.m,d=c.N;if(""===e.e.$){u=s.slice(1);let e=Z(u);if("$"===e[0]||ie(c.host,e)||c.host.entries.some(e=>""!==e.$&&(u===e.$||u.startsWith(`${e.$}.`))))return}else u=e.e.$+s;let f=[];for(let e=t.n+1;e<=n.n;e++)f.push(a(o,e).b);d.resolve(U(u,f),null);let h=d.rp,p=d.rr;h.n>0&&null===p||$e(d,h,p,l,r,i)}function ye(e,t,n,o,l,r,i){if(0===J)return;let s=V.has(e);V.add(e);try{let s=B.get(e);!i&&void 0!==s&&s.fn&&!V.has(s.host.engine)&&function(e,t,n,o,l,r){let i,a=t;for(;null!==a&&void 0===(i=e.dt.get(a));)a=a.d;if(null===a||void 0===i)return;let s=e.host.engine;if(a===t&&e.dn===t)return void(e.dn=null);if(null!==i.r&&!i.r.y)return;let u=[...s.H(i.r),...e.N.H(n)];s.resolve(U(i.p.t+t.t.slice(a.t.length),u),null);let c=s.rp,d=s.rr;c.n>0&&null===d||de(e,i.e,()=>$e(s,c,d,o,l,r))}(s,t,n,o,l,r),i&&void 0!==s&&s.fn&&null!==s.re&&function(e,t){let n=e.host.entries.find(e=>""===e.$),o=e.host.engine;for(let[l,r]of e.re)r===t&&(o.P.we(o,l,n.r),o.Te())}(s,t);let u=F.get(e);if(void 0===u)return;for(let[e,s]of u)if(t.ee(e)){let u=s.get(0===e.n?null:a(n,e.n));if(void 0!==u)for(let a of[...u])fe(a,i)&&we(a,e,t,n,o,l,r)}else if(e.ee(t))for(let[e,o]of[...s])if(0===t.n||a(e,t.n)===n)for(let e of[...o])fe(e,i)&&be(e)}finally{s||V.delete(e)}}async function ve(e,o,l,i,a){if(i===G)return;let d=m(i);d&&await d;let f=Y.get(o);f.engine&&i.$recursion&&g(`[wcs/mount-dollar-declaration] <${o.localName}>: $recursion is not run in a mounted component — declare it on the root state.`);let h=f.O;if(null!==h&&h.el!==e&&h.el.isConnected&&g(`<${o.localName}> already has a connected <${u.tagNames.state} bind-component="${f.pe}">.`),null!==h&&he(h,!1),null!==h&&function(e,t,n){let o=e.N,l=`[${u.bindAttributeName}]`,r=e=>1===e.nodeType&&(e.matches(l)||null!==e.querySelector(l)),i=new Set,a=e=>{for(;null!==e&&e.parentNode!==n;)e=e.parentNode;null!==e&&i.add(e)},s=(e,t)=>{for(let n=e.Cn(t);null!==n&&n!==t;n=n.nextSibling)a(n);a(t)};for(let e of o.ce.values())for(let t of e)if(null===t._)a(t.a);else for(let e of t._.G)s(t._,e.S);for(let e of o.oe.values())for(let t of[e.E,...e.L??[]])null!==t&&s(t,t.S);for(let t of e.D)t.parentNode===n&&r(t)&&i.add(t);if(0===i.size)return!1;let c=[...n.childNodes].filter(n=>n!==t&&!i.has(n)&&!e.D.includes(n)&&(r(n)||o.Mt&&n.textContent.includes("{{")));return c.length>0&&console.warn(`[@wcstack/state] <${e.host.el.localName}>: ${c.length} node(s) added beside the content taken over are not bound.`),!0}(h,e,l))return async function(e,t,n,o){e.el.engine=null,e.el=t,e.N.element=t,t.engine=e.N,e.D=e.D.filter(e=>e.parentNode===n),t.isConnected?await ke(e,o):o()}(h,e,l,a);let p=new s(i,new n);p.element=e,e.engine=p,function(e,t){let n=new Map;for(let e=t;null!==e&&e!==Object.prototype;e=Object.getPrototypeOf(e))for(let t of Object.getOwnPropertyNames(e)){let o=Object.getOwnPropertyDescriptor(e,t).value;"function"==typeof o&&"constructor"!==t&&n.set(o,null)}let o=(t,n,o)=>Reflect.apply(t,e.proxy,o);e.V=e=>{let t=n.get(e);return null===t&&n.set(e,t=new Proxy(e,{apply:o})),t}}(p,i);let $={el:e,D:[],N:p,host:f,fe:[],dt:new Map,fn:!1,dn:null,from:null,re:null};for(let e of f.entries)$.fe.push({m:$,e});f.O=$,B.set(p,$);let b=null===f.engine;b?c.element?.(p,"mounting"):(function(e){let t=e.N,n=e.host,o=n.engine,l=n.el.localName,r=n.entries.find(e=>""===e.$)??null;for(let e of n.entries){if(""===e.$)continue;let t=Z(e.$);ie(n,t)&&(e.$!==t||ae(n,t))&&re(`${l}.${e.$}`,`[wcs/mount-own-key-shadow] <${l}>: "${n.pe}.${e.$}" is hidden by the component's own "${t}"; rename one side.`)}if(null!==r){let e=o.v(r.me,r.r);if(null!==e&&"object"==typeof e)for(let t of Object.keys(n.state))"$"!==t[0]&&t in e&&!n.entries.some(e=>e.$===t)&&re(`${l}.${t}`,`[wcs/mount-own-key-shadow] <${l}>: its own "${t}" hides "${r.me.t}.${t}" — remove the default to read the tree, or rename it to keep it private.`)}let i=K.filter(e=>void 0!==n.state[e]);i.length>0&&re(`${l}.${n.pe}$`,`[wcs/mount-dollar-declaration] <${l}>: ${i.join(", ")} ${1===i.length?"is":"are"} not run in a mounted component — declare it on the root state.`);let a=t.nt;t.nt=n=>{ue(e,r,n),a.call(t,n)};let s=[...t.I.all()];for(let t of s)ue(e,r,t);for(let e of s)a.call(t,e);let u=t.zt;t.zt=()=>{(function(e){for(;void 0!==e;e=B.get(e.host.engine))if(e.host.entries.some(e=>null!==e.r&&!e.r.y))return!1;return!0})(e)&&u.call(t)}}($),he($,!0),y.add(p),P(p,l));let w=c.hr?.(l);r(p,l),w?.(),$.D=[...l.childNodes],t(),b&&p.En(),Object.defineProperty(o,f.pe,{configurable:!0,enumerable:!0,get:()=>p.proxy});let v=o.$stateReadyCallback;if("function"==typeof v)try{let e=v.call(o,f.pe);null!==e&&"object"==typeof e&&"function"==typeof e.then&&e.then(void 0,e=>console.error(e))}catch(e){console.error(e)}a(),e.isConnected?(await p.ke("$connectedCallback"),b&&e.isConnected&&c.element?.(p,"connected")):he($,!1)}async function ke(e,t){he(e,!0);for(let t of e.fe)be(t);t?.(),!e.broken&&(await e.N.ke("$connectedCallback"),null===e.host.engine&&e.el.isConnected&&c.element?.(e.N,"connected"))}function Ne(e,t){let n=e.getAttribute("bind-component");if(null===n)return function(e,t){return e.connectedCallbackPromise.catch(()=>{let n=l.get(t)?.element;if(!(e.V||void 0!==n&&n!==e&&n.isConnected)){W(t,e);for(let e of E.get(t)??[])e()}}),null}(e,t);let r=e.parentNode,i=r instanceof ShadowRoot,a=i?r.host:r instanceof Element?r:null,s=()=>{let t=null===a?void 0:Y.get(a)?.O;return t?.el===e?t:null},d=t=>{throw i&&W(r,e),t},f=!1;return{wt:()=>(null!==a&&a.localName.includes("-")?async function(e,t,n,l){let r=n.localName;(["state","src","json"].some(t=>e.hasAttribute(t))||null!==e.querySelector('script[type="module"]'))&&g(`<${u.tagNames.state} bind-component> takes its state from <${r}>.${t}: it cannot also load one (state / src / json / an inline script).`),await o(n).whenDefined(r);let i=Y.get(n);if(void 0!==i)return i.pe!==t&&g(`<${r}> already has a <${u.tagNames.state} bind-component="${i.pe}">.`),i.state;let a=()=>(H.get(n)??[]).filter(e=>Z(e.name)===t),s=ne(n,t);if(s&&0===a().length&&oe(n),0===a().length&&(s||((e,t)=>!0===e.getAttribute(_)?.split(" ").includes(t))(n,t))){let e;await new Promise((o,l)=>{X.set(n,o),e=function(e,t){C(e)&&t();let n=E.get(e)??new Set;return E.set(e,n.add(t)),()=>n.delete(t)}(n.getRootNode(),()=>l(new Error(`[@wcstack/state] <${r}>.${t} will not mount: the root state failed to initialize.`)))}).finally(()=>e())}X.delete(n);let c=a(),d=L.get(n),f=void 0!==d&&d.has(t)?d.get(t):n[t];if((null===f||"object"!=typeof f)&&g(`"bind-component": <${r}>.${t} must be an object (the component's state), got ${null===f?"null":typeof f}.`),0===c.length&&l){let e=new Error(`[@wcstack/state] A plain (unwired) Light DOM "bind-component" is not supported. Attach a shadow root to <${r}>, or mount it from the host (${u.bindAttributeName}="${t}: path").`);return queueMicrotask(()=>{throw e}),G}let h=[];for(let e of c){let o=e.name===t?"":e.name.slice(t.length+1);h.some(e=>e.$===o)&&g(`<${r}> maps "${e.name}" twice.`);let l=o.split(".").indexOf("*");if(l>=0){let n=o.split(".").slice(0,l).join(".");g(`<${r}> maps "${e.name}": the component-side path of a mount cannot contain "*"${""===n?"":` — map the list itself ("${t}.${n}: <the host's list>")`}.`)}h.push({$:o,me:e.o,r:e.r,ro:I.has(e)}),e.engine.Nn(e),""!==o&&delete n[e.name]}let p=0===c.length?function(e){let t=Object.getOwnPropertyDescriptors(e),n=Object.isFrozen(e);for(let e of Object.values(t))"value"in e&&!1===e.writable&&(e.writable=!0,n=!0);return n?Object.create(Object.getPrototypeOf(e),t):e}(f):f;return Y.set(n,i={el:n,pe:t,state:p,engine:0===c.length?null:c[0].engine,entries:h,O:null}),p}(e,n,a,!i):Promise.reject(new Error(`[@wcstack/state] "bind-component" requires <${u.tagNames.state}> to be a direct child of a custom element.`))).catch(d),async start(t,n){await ve(e,a,i?r:a,t,()=>{f=!0,n()}).catch(e=>{let t=s();return!f&&null!==t&&(t.broken=!0),d(e)})},Xe(){let t=s();null!==t?ke(t).catch(e=>console.error(e)):f?Promise.resolve().then(()=>{if(e.parentNode===r)return ve(e,a,i?r:a,Y.get(a).state,()=>{})}).catch(e=>console.error(e)):X.has(a)&&oe(a)},Ln(){let e=s();null!==e&&(he(e,!1),!e.broken&&(e.N.ke("$disconnectedCallback"),null===e.host.engine&&c.element?.(e.N,"disconnected")))},reset(){g(`re-setting a component's state is not supported: write <${a?.localName}>.${n} instead.`)}}}var je={name:"scopes",install(){c.at=f(p,c.at,T),c.at=f(p,c.at,Q),c.at=f(p,c.at,Ne),c.ar=ee,c.$o=te,c.element=d(c.element,(e,t)=>{if("mounting"!==t)return function(e,t){let n=v.get(e)??[];if("disconnected"===t)for(let e of n)M(e);else if("reset"!==t&&A(l.get(e.root))===e){P(e,e.root);for(let e of n)$.get(e.root).has(e.t)||$.get(e.root).set(e.t,e)}}(e,t);let n=e.element.getRootNode();P(e,n),function(e,t){let n=t.host,o=void 0===n?void 0:z.get(n);void 0!==o&&R.set(e,{host:n,def:o})}(e,n)}),c.be=d(c.be,(e,t,n,o,l,r)=>{(function(e,t,n,o){let l=R.get(e);if(void 0===l)return;let r=t.t.split(".",1)[0];if(!l.def.bindables.includes(r))return;let i=o&&t.t===r;l.host.dispatchEvent(new CustomEvent(`${l.def.tag}:${r}-changed`,{detail:i?n:void 0,bubbles:!0}))})(e,t,l,r),ye(e,t,n,o,l,r,!1)}),c.ve=d(c.ve,(e,t,n)=>ye(e,t,n,void 0,void 0,!1,!0)),c.Ae=f(h,c.Ae,(e,t,n,o,l)=>(function(e,t){let n=v.get(e);if(void 0!==n&&0===t.n)for(let{t:e}of n)e.startsWith(`${t.t}.`)&&g(`writing "${t.t}" would replace the volume grafted at "${e}"; write the paths under it instead.`)}(e,t),function(e,t,n){let o,l=B.get(e);if(void 0===l)return!1;for(let e=t;null!==e&&void 0===o;e=e.d)o=l.dt.get(e);if(void 0===o)return!1;let r=o.e;return!((null===r.r||r.r.y)&&!r.ro)&&(!!n||(ce(l,r.r),void g(`[wcs/mount-readonly] <${l.host.el.localName}> cannot write "${t.t}": it is mounted read-only ("${l.host.pe}${""===r.$?"":`.${r.$}`}#ro: ${r.me.t}"). Write it on the host, or drop #ro from the mount.`)))}(e,t,l)));let e=c.de;c.de=(t,n)=>{let o=v.get(t);void 0!==o&&o.length>0&&g(`re-setting a root state with grafted volumes (${o.map(e=>e.t).join(", ")}) is not supported: their data is part of the tree.`),function(e){let t=F.get(e);if(void 0===t)return!1;for(let e of t.values())if(e.size>0)return!0;return!1}(t)&&g("re-setting a root state with mounted components is not supported: they read its data."),e?.(t,n)}}},Oe=je;export{Oe as default,je as scopes};
|
|
1
|
+
import{a as e,b as t,d as n}from"../chunks/chunk-V6VVL4F3.js";import{b as o,n as l,o as r,p as i}from"../chunks/chunk-BMGEWHCR.js";import"../chunks/chunk-PHAN6L23.js";import{e as a,f as s}from"../chunks/chunk-EM3Y3SJS.js";import{a as u}from"../chunks/chunk-6MACFEK7.js";import"../chunks/chunk-ZN52NEIB.js";import"../chunks/chunk-TUQ3OPZQ.js";import"../chunks/chunk-M656SMUU.js";import{a as c,b as d,c as f,d as h,f as p,h as m,j as g}from"../chunks/chunk-4NJBYXIT.js";var $=new WeakMap,b=new WeakMap,w="will not graft: the root state failed to initialize.",y=new WeakSet,v=new WeakMap,k=["$stream","$streams","$scan","$recursion","$watch","$listKeys","$renderedCallback","$updatedCallback","$behavior","$features"],j=["$commandTokens","$eventTokens","$on","$errorCallback"],O=e=>`[@wcstack/state] <${u.tagNames.state} mount="${e}">`,x=new Set(["$getAll","$setAll","$resolve","$postUpdate","$dependOn","$eq","$eqIndex"]),N=e=>e?.element?.isConnected?e:void 0;function C(e){let t=b.get(e);return void 0!==t&&!Array.isArray(t)&&t.isConnected}function A(e,t){let n=b.get(t);if(b.delete(t),Array.isArray(n))for(let t of n)W(t,e)}function P(e){let t=$.get(e.root);t?.get(e.t)===e&&t.delete(e.t)}function M(e,t){console.error(`${O(e.t)} ${t}`),P(e),e.Qe?.(),e.Qe=null}function S(e,t){let n=e.state?.[t];if("function"==typeof n)try{let t=n.call(e.chroot);null!==t&&"object"==typeof t&&"function"==typeof t.then&&t.then(void 0,e=>console.error(e))}catch(e){console.error(e)}}function W(e,t){if(y.has(t))return M(e,"will not graft: its component is wired to its host.");let n=e.state,o=t.target,l=e.t.split("."),r=o;for(let e of l)r=r?.[e];if(void 0!==r&&!0!==t.hydrated)return M(e,`will not graft: the root state already has "${e.t}".`);let i=function(e,t){let n=e=>`${t}.${e}`;return new Proxy({},{get(t,o){if("symbol"==typeof o)return;if(36!==o.charCodeAt(0))return e.proxy[n(o)];let l=e.proxy[o];return"$eqPath"===o?(e,t)=>l(n(e),n(t)):x.has(o)&&"function"==typeof l?(e,...t)=>l(n(e),...t):l},set:(t,o,l)=>"symbol"!=typeof o&&(e.proxy[n(o)]=l,!0)})}(t,e.t);e.chroot=i;let a={},s={},u=new Set;for(let t=n;null!==t&&t!==Object.prototype;t=Object.getPrototypeOf(t))for(let n of Object.getOwnPropertyNames(t)){if(u.has(n)||"constructor"===n)continue;u.add(n);let{get:o,set:l,value:r}=Object.getOwnPropertyDescriptor(t,n);if(void 0!==o||void 0!==l)s[`${e.t}.${n}`]={get:o&&function(){return o.call(i)},set:l&&function(e){l.call(i,e)}};else{if("$"===n[0])continue;if("function"==typeof r){let t=r.bind(i);s[`${e.t}.${n}`]={get:()=>t}}else a[n]=r}}if(void 0===r){for(let e=1;e<l.length;e++){let n=t.o(l.slice(0,e).join("."));null==t.rt(n,null)&&t.T(n,null,{})}t.T(t.o(e.t),null,a)}t.to(Object.defineProperties({},s));for(let e in s)t._e(t.o(e),null);e.engine=t;let c=v.get(t);void 0===c&&v.set(t,c=[]),c.push(e),e.el.isConnected&&S(e,"$connectedCallback"),e.Qe?.(),e.Qe=null}function D(e,t){let n=b.get(e);if(Array.isArray(n))for(let e of n)M(e,w);b.set(e,t)}var E=new WeakMap;function T(e,t){let n=e.getAttribute("mount");if(null===n)return null;let o={el:e,root:t,t:n,state:null,engine:null,chroot:null,Qe:null},r=null;if(function(e){return""!==e&&e.split(".").every(e=>""!==e&&!/[*$#@\s]/.test(e))}(n))if(e.hasAttribute(u.bindAttributeName))r='injections (data-wcs="state.<key>: …") are not supported — read the root path in a root getter.';else{let e=$.get(t);void 0===e&&$.set(t,e=new Map);let l=e.get(n);if(void 0!==l&&l!==o&&(null===l.engine?l.el.isConnected:N(l.engine)))r=`will not graft: another volume already holds "${n}".`;else{if(null===l?.engine){let e=b.get(t);Array.isArray(e)&&b.set(t,e.filter(e=>e!==l)),l.Qe?.(),l.Qe=null}e.set(n,o)}}else r='has an invalid mount path: it must be a static path (no "*", "$", "#", "@").';return{xo:!0,start(e){if(null!==r)return M(o,r);if($.get(t).get(n)===o){for(let t of k)if(void 0!==e[t])return M(o,`${t} is not run in a volume — declare it on the root state.`);for(let t of j)void 0!==e[t]&&console.warn(`${O(n)} ${t} is not run in a volume (it belongs to the root).`);return o.state=e,new Promise(e=>{o.Qe=e;let n=N(l.get(t)),r=b.get(t);void 0!==n?W(o,n):C(t)?M(o,w):b.set(t,[...Array.isArray(r)?r:[],o])})}},Xe(){null!==o.engine&&S(o,"$connectedCallback")},Ln(){null!==o.engine&&S(o,"$disconnectedCallback")},reset(){g(`re-setting a volume is not supported: its data was copied into the root tree at "${n}" — write the paths under it on the root instead.`)}}}var z=new WeakMap,Q=new WeakMap;function R(e,t){let n=e[t];if(void 0===n)return[];Array.isArray(n)||g(`${t} must be an array of state member names.`);let o=new Set;for(let e of n)("string"!=typeof e||""===e)&&g(`${t} entries must be non-empty strings.`),"$"===e[0]&&g(`${t} entry "${e}": internal ($) members are never exposed.`),o.has(e)&&g(`${t} entry "${e}" is duplicated.`),o.add(e);return n}function q(e,t){let n=t.host;if(void 0===n||!n.hasAttribute("data-wc-definition"))return null;let o=document.createDocumentFragment();for(let e of[...t.childNodes])o.appendChild(e.cloneNode(!0));let l=t.mode;return{start(t){e.hasAttribute("bind-component")&&g("DCC: a <wcs-state bind-component> cannot define a component (use one mechanism)."),function(e,t,n,o){e.includes("-")||g(`DCC: <${e} data-wc-definition> is not a valid custom element name.`),void 0!==customElements.get(e)&&g(`DCC: <${e}> is already defined.`);let l=function(e){let t=new Map;for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n))for(let e of Object.getOwnPropertyNames(n))"constructor"===e||"$"===e[0]||t.has(e)||t.set(e,Object.getOwnPropertyDescriptor(n,e));let n=e.$stream;if(null!==n&&"object"==typeof n)for(let e of Object.keys(n))t.has(e)||t.set(e,{value:void 0});return t}(o),r=R(o,"$bindables"),i=R(o,"$commands");for(let e of r){let t=l.get(e);void 0===t&&g(`$bindables entry "${e}" does not exist on the state.`),"function"==typeof t.value&&g(`$bindables entry "${e}" is a method: list it in $commands.`)}for(let e of i){let t=l.get(e);void 0===t&&g(`$commands entry "${e}" does not exist on the state.`),"function"!=typeof t.value&&g(`$commands entry "${e}" is not a method: list it in $bindables.`)}let a={tag:e,bindables:r},s=new WeakMap,c=new WeakMap,d=o=>{if(s.has(o))return s.get(o);if(o.hasAttribute("data-wc-definition"))return null;let l=o.attachShadow({mode:n});l.appendChild(t.cloneNode(!0));let i=l.querySelector(u.tagNames.state);return s.set(o,i),z.set(o,a),null===i&&r.length>0&&console.warn(`[@wcstack/state] DCC: <${e}> declares $bindables but its content has no <${u.tagNames.state}>: no change events.`),i},f=e=>d(e)?.engine??null,h=e=>Promise.resolve(d(e)?.initializePromise).then(()=>{let t=c.get(e);c.delete(e);let n=f(e);if(void 0!==t&&null!==n)for(let[e,o]of t)n.proxy[e]=o});class p extends HTMLElement{static{this.wcBindable=0===r.length&&0===i.length?null:{protocol:"wc-bindable",version:1,properties:r.map(t=>({name:t,event:`${e}:${t}-changed`,getter:e=>e.target[t]})),inputs:r.map(e=>({name:e})),...0===i.length?{}:{commands:i.map(e=>({name:e,async:!0}))}}}connectedCallback(){null!==d(this)&&h(this)}get stateElement(){return d(this)}}for(let[e,t]of l)"function"==typeof t.value?Object.defineProperty(p.prototype,e,{configurable:!0,value(...t){return h(this).then(()=>{let n=f(this);return null===n?void 0:n.proxy[e].apply(n.proxy,t)})}}):Object.defineProperty(p.prototype,e,{configurable:!0,get(){return f(this)?.proxy[e]},set(t){let n=f(this);if(null!==n)n.proxy[e]=t;else{let n=c.get(this);void 0===n&&c.set(this,n=[]),n.push([e,t])}}});customElements.define(e,p)}(n.localName,o,l,t)},Xe(){},Ln(){},reset(){g("re-setting a DCC definition is not supported: each instance loads its own state.")}}}var L=new WeakMap,H=new WeakSet,X=new WeakMap,I=new WeakMap,V="data-wcs-wired",_=new WeakMap,B=new WeakMap,F=new WeakMap,U=0,Y=new Set,G={},J=["$watch","$stream","$renderedCallback"],K=e=>e.split(".",1)[0];function Z(e,t){let n=0;return e.split(".").map(e=>"*"===e?String(t[n++]):e).join(".")}function ee(e,t){let n=e.a,o=K(e.name);if(!0!==document.documentElement?.hasAttribute("data-wcs-server"))n.removeAttribute(V);else if(!ne(n,o)){let e=n.getAttribute(V)?.split(" ")??[];e.includes(o)||n.setAttribute(V,[...e,o].join(" "))}_.get(n)?.pe===o&&g(`<${n.localName}>.${o} has loaded its state: the wiring "${e.name}" added afterwards cannot reach it — bind the host's wiring before the component loads.`);let l=L.get(n);void 0===l&&L.set(n,l=[]),l.push(e),t&&H.add(e);let r=X.get(n);return void 0===r&&X.set(n,r=new Map),r.has(o)||r.set(o,n[o]),I.get(n)?.(),!1}function te(e){return e.localName.includes("-")&&null!==e.querySelector(`:scope > ${u.tagNames.state}[bind-component]`)}function ne(e,t){let n=e.getAttribute(u.bindAttributeName);return null!==n&&new RegExp(`(^|;)\\s*${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*[.#:]`).test(n)}function oe(t){let n=t.parentElement;for(;null!==n&&!te(n);)n=n.parentElement;let o=l.get(n??t.getRootNode()),r=o?.element;(r?.isConnected?r.V:null===n)&&(null===n?e(t):i(o,t))}var le=new Set;function re(e,t){le.has(e)||(le.add(e),console.warn(`[@wcstack/state] ${t}`))}var ie=(e,t)=>t in e.state;function ae(e,t){let n=se(e.state,t);return void 0!==n&&(void 0!==n.get||void 0!==n.set||"function"==typeof n.value)}function se(e,t){for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n)){let e=Object.getOwnPropertyDescriptor(n,t);if(void 0!==e)return e}}function ue(e,t,n){if(null!==n.getter)return;let o,l=e.host,r=l.engine,i=K(n.t),s=l.entries.find(e=>e.$===n.t);if(void 0===s&&null!==n.d)return function(e,t){let n,o=t.d;for(;null!==o&&void 0===(n=e.dt.get(o));)o=o.d;if(null===o||void 0===n)return;let l=e.x,r=e.host.engine,i=r.o(n.p.t+t.t.slice(o.t.length));if(null===i.getter)return;let s=n,u=()=>{let n=ce(e,s.r);return 0===t.n?n:(r.resolve(Z(i.t,[...r.H(n),...l.H(a(l.u,t.n))]),null),r.rr)};t.getter=()=>{let e=u();return i.n>0&&null===e?void 0:r.v(i,e)},null!==i.ie&&(t.ie=n=>{let o=u();de(e,s.e,()=>r.T(i,o,n)),e.dn=t}),t.n>0&&(t.A=l.Ie++),e.dt.set(t,{e:s.e,p:i,r:s.r})}(e,n);if(0!==n.n)return;if(void 0!==s){if(s.$!==i?ie(l,i):ae(l,i))return;o=s.me}else{if(null===t||null!==n.d||"$"===i[0]||ie(l,i))return;s=t,o=r.o(`${t.me.t}.${i}`)}let u=s.r,c=s;n.getter=()=>r.v(o,ce(e,u)),n.ie=t=>{de(e,c,()=>r.T(o,u,t)),e.dn=n},e.dt.set(n,{e:s,p:o,r:u})}function ce(e,t){return null!==t&&!t.y&&g(`The host row of <${e.host.el.localName}> was removed.`),t}function de(e,t,n){let o=Y.has(e.x);Y.add(e.x),e.from=t;try{n()}finally{o||Y.delete(e.x),e.from=null}}var fe=(e,t)=>t||!Y.has(e.m.x)||null!==e.m.from&&e.m.from!==e.e;function he(e,t){if(e.fn===t||null===e.host.engine)return;e.fn=t,U+=t?1:-1;let n=e.host.engine,o=F.get(n);void 0===o&&F.set(n,o=new Map);for(let n of e.fe){let e=o.get(n.e.me);void 0===e&&o.set(n.e.me,e=new Map);let l=e.get(n.e.r);void 0===l&&e.set(n.e.r,l=new Set),t?l.add(n):(l.delete(n),0===l.size&&e.delete(n.e.r))}let l=e.host.entries.find(e=>""===e.$);if(void 0!==l){null===e.re&&function(e,t){let n=e.host,o=n.engine;e.re=new Map;let l=new Set;for(let r=n.state;null!==r&&r!==Object.prototype;r=Object.getPrototypeOf(r))for(let i of Object.getOwnPropertyNames(r)){if(l.has(i))continue;l.add(i);let a=Object.getOwnPropertyDescriptor(r,i);if(void 0===a.get&&void 0===a.set||"$"===i[0]||i.includes("*"))continue;let s=K(i);if(i!==s&&!ie(n,s))continue;let u=o.o(`${t.me.t}.${i}`);if(null===u.getter)ge(o,u,t.me);else if(!pe.has(u.getter))continue;e.re.set(u,e.x.o(i))}}(e,l);for(let o of e.re.keys())t&&null===o.getter&&ge(n,o,l.me),n.P.we(n,o,l.r);e.re.size>0&&n.Te(),t&&function(e,t){let n=e.host.engine;for(let[o,l]of e.re){let r=n.v(o.d,t.r);if(null===r||"object"!=typeof r||!(o.s in r))continue;let i=e.host.el.localName;re(`${i}|${o.t}`,`[wcs/mount-export-shadowed] <${i}>.${e.host.pe}.${l.t} is exported at "${o.t}" but the tree already has that key, so readers outside the component get the tree value. Remove the tree key or rename the accessor. See docs/state-overlay-export-design.md X1.`)}}(e,l)}}var pe=new WeakSet;function me(e,t,n,o){let l=F.get(e)?.get(t)?.get(n);if(void 0===l)return null;let r=null;for(let e of l)""!==e.e.$||!0!==e.m.re?.has(o)||e.m===r||(null!==r&&g(`[wcs/mount-export-ambiguous] "${o.t}" is exported by two mounted components on the same instance: <${r.host.el.localName}> and <${e.m.host.el.localName}>. Mount only one of them there, or rename one accessor. See docs/state-overlay-export-design.md X4.`),r=e.m);return r}function ge(e,t,n){let o=t.d,l=t.s,r=()=>{let t=e.read(o,e.u);return null!==t&&"object"==typeof t&&l in t?t:null};t.getter=()=>{let o=r();if(null!==o)return o[l];let i=me(e,n,e.u,t);return null===i?void 0:i.x.read(i.re.get(t),null)},pe.add(t.getter),t.ie=i=>{let a=null===r()?me(e,n,e.u,t):null;if(null===a){let t=e.read(o,e.u);return void(null!==t&&"object"==typeof t&&(t[l]=i))}let s=a.re.get(t);void 0===se(a.host.state,s.t)?.set&&g(`Cannot write to "${s.t}" on mounted <${a.host.el.localName}>: the accessor has no setter. Add a setter or write to the underlying state paths instead.`),a.x.T(s,null,i)},t.n>0&&(t.A=e.Ie++)}function $e(e,t,n,o,l,r){if(null!==t.getter)return e.P.we(e,t,n),void e.Te();if("*"===t.s){if(null===n)return;if(n.R=n.l.C[n.b],e.P.Yt(n),null!==n.c)for(let t of n.c.values())e.X(t)}else e.$n(t,n);c.be?.(e,t,n,o,l,r),e._e(t,n)}function be(e){let t=e.m.x;for(let[n,o]of e.m.dt)o.e===e.e&&(0===n.n?t.P.we(t,n,null):t.tn(n.h[n.n],e=>t.P.we(t,n,e)));t.Te()}function we(e,t,n,o,l,r,i){let s=n.t.slice(t.t.length);if(""===s)return be(e);let u,c=e.m,d=c.x;if(""===e.e.$){u=s.slice(1);let e=K(u);if("$"===e[0]||ie(c.host,e)||c.host.entries.some(e=>""!==e.$&&(u===e.$||u.startsWith(`${e.$}.`))))return}else u=e.e.$+s;let f=[];for(let e=t.n+1;e<=n.n;e++)f.push(a(o,e).b);d.resolve(Z(u,f),null);let h=d.rp,p=d.rr;h.n>0&&null===p||$e(d,h,p,l,r,i)}function ye(e,t,n,o,l,r,i){if(0===U)return;let s=Y.has(e);Y.add(e);try{let s=B.get(e);!i&&void 0!==s&&s.fn&&!Y.has(s.host.engine)&&function(e,t,n,o,l,r){let i,a=t;for(;null!==a&&void 0===(i=e.dt.get(a));)a=a.d;if(null===a||void 0===i)return;let s=e.host.engine;if(a===t&&e.dn===t)return void(e.dn=null);if(null!==i.r&&!i.r.y)return;let u=[...s.H(i.r),...e.x.H(n)];s.resolve(Z(i.p.t+t.t.slice(a.t.length),u),null);let c=s.rp,d=s.rr;c.n>0&&null===d||de(e,i.e,()=>$e(s,c,d,o,l,r))}(s,t,n,o,l,r),i&&void 0!==s&&s.fn&&null!==s.re&&function(e,t){let n=e.host.entries.find(e=>""===e.$),o=e.host.engine;for(let[l,r]of e.re)r===t&&(o.P.we(o,l,n.r),o.Te())}(s,t);let u=F.get(e);if(void 0===u)return;for(let[e,s]of u)if(t.ee(e)){let u=s.get(0===e.n?null:a(n,e.n));if(void 0!==u)for(let a of[...u])fe(a,i)&&we(a,e,t,n,o,l,r)}else if(e.ee(t))for(let[e,o]of[...s])if(0===t.n||a(e,t.n)===n)for(let e of[...o])fe(e,i)&&be(e)}finally{s||Y.delete(e)}}async function ve(e,o,l,i,a){if(i===G)return;let d=m(i);d&&await d;let f=_.get(o);f.engine&&i.$recursion&&g(`[wcs/mount-dollar-declaration] <${o.localName}>: $recursion is not run in a mounted component — declare it on the root state.`);let h=f.O;if(null!==h&&h.el!==e&&h.el.isConnected&&g(`<${o.localName}> already has a connected <${u.tagNames.state} bind-component="${f.pe}">.`),null!==h&&he(h,!1),null!==h&&function(e,t,n){let o=e.x,l=`[${u.bindAttributeName}]`,r=e=>1===e.nodeType&&(e.matches(l)||null!==e.querySelector(l)),i=new Set,a=e=>{for(;null!==e&&e.parentNode!==n;)e=e.parentNode;null!==e&&i.add(e)},s=(e,t)=>{for(let n=e.Cn(t);null!==n&&n!==t;n=n.nextSibling)a(n);a(t)};for(let e of o.ce.values())for(let t of e)if(null===t._)a(t.a);else for(let e of t._.G)s(t._,e.S);for(let e of o.oe.values())for(let t of[e.E,...e.L??[]])null!==t&&s(t,t.S);for(let t of e.D)t.parentNode===n&&r(t)&&i.add(t);if(0===i.size)return!1;let c=[...n.childNodes].filter(n=>n!==t&&!i.has(n)&&!e.D.includes(n)&&(r(n)||o.Mt&&n.textContent.includes("{{")));return c.length>0&&console.warn(`[@wcstack/state] <${e.host.el.localName}>: ${c.length} node(s) added beside the content taken over are not bound.`),!0}(h,e,l))return async function(e,t,n,o){e.el.engine=null,e.el=t,e.x.element=t,t.engine=e.x,e.D=e.D.filter(e=>e.parentNode===n),t.isConnected?await ke(e,o):o()}(h,e,l,a);let p=new s(i,new n);p.element=e,e.engine=p,function(e,t){let n=new Map;for(let e=t;null!==e&&e!==Object.prototype;e=Object.getPrototypeOf(e))for(let t of Object.getOwnPropertyNames(e)){let o=Object.getOwnPropertyDescriptor(e,t).value;"function"==typeof o&&"constructor"!==t&&n.set(o,null)}let o=(t,n,o)=>Reflect.apply(t,e.proxy,o);e.V=e=>{let t=n.get(e);return null===t&&n.set(e,t=new Proxy(e,{apply:o})),t}}(p,i);let $={el:e,D:[],x:p,host:f,fe:[],dt:new Map,fn:!1,dn:null,from:null,re:null};for(let e of f.entries)$.fe.push({m:$,e});f.O=$,B.set(p,$);let b=null===f.engine;b?c.element?.(p,"mounting"):(function(e){let t=e.x,n=e.host,o=n.engine,l=n.el.localName,r=n.entries.find(e=>""===e.$)??null;for(let e of n.entries){if(""===e.$)continue;let t=K(e.$);ie(n,t)&&(e.$!==t||ae(n,t))&&re(`${l}.${e.$}`,`[wcs/mount-own-key-shadow] <${l}>: "${n.pe}.${e.$}" is hidden by the component's own "${t}"; rename one side.`)}if(null!==r){let e=o.v(r.me,r.r);if(null!==e&&"object"==typeof e)for(let t of Object.keys(n.state))"$"!==t[0]&&t in e&&!n.entries.some(e=>e.$===t)&&re(`${l}.${t}`,`[wcs/mount-own-key-shadow] <${l}>: its own "${t}" hides "${r.me.t}.${t}" — remove the default to read the tree, or rename it to keep it private.`)}let i=J.filter(e=>void 0!==n.state[e]);i.length>0&&re(`${l}.${n.pe}$`,`[wcs/mount-dollar-declaration] <${l}>: ${i.join(", ")} ${1===i.length?"is":"are"} not run in a mounted component — declare it on the root state.`);let a=t.nt;t.nt=n=>{ue(e,r,n),a.call(t,n)};let s=[...t.I.all()];for(let t of s)ue(e,r,t);for(let e of s)a.call(t,e);let u=t.zt;t.zt=()=>{(function(e){for(;void 0!==e;e=B.get(e.host.engine))if(e.host.entries.some(e=>null!==e.r&&!e.r.y))return!1;return!0})(e)&&u.call(t)}}($),he($,!0),y.add(p),A(p,l));let w=c.hr?.(l);r(p,l),w?.(),$.D=[...l.childNodes],t(),b&&p.En(),Object.defineProperty(o,f.pe,{configurable:!0,enumerable:!0,get:()=>p.proxy});let v=o.$stateReadyCallback;if("function"==typeof v)try{let e=v.call(o,f.pe);null!==e&&"object"==typeof e&&"function"==typeof e.then&&e.then(void 0,e=>console.error(e))}catch(e){console.error(e)}a(),e.isConnected?(await p.ke("$connectedCallback"),b&&e.isConnected&&c.element?.(p,"connected")):he($,!1)}async function ke(e,t){he(e,!0);for(let t of e.fe)be(t);t?.(),!e.broken&&(await e.x.ke("$connectedCallback"),null===e.host.engine&&e.el.isConnected&&c.element?.(e.x,"connected"))}function je(e,t){let n=e.getAttribute("bind-component");if(null===n)return function(e,t){return e.connectedCallbackPromise.catch(()=>{let n=l.get(t)?.element;if(!(e.V||void 0!==n&&n!==e&&n.isConnected)){D(t,e);for(let e of E.get(t)??[])e()}}),null}(e,t);let r=e.parentNode,i=r instanceof ShadowRoot,a=i?r.host:r instanceof Element?r:null,s=()=>{let t=null===a?void 0:_.get(a)?.O;return t?.el===e?t:null},d=t=>{throw i&&D(r,e),t},f=!1;return{wt:()=>(null!==a&&a.localName.includes("-")?async function(e,t,n,l){let r=n.localName;(["state","src","json"].some(t=>e.hasAttribute(t))||null!==e.querySelector('script[type="module"]'))&&g(`<${u.tagNames.state} bind-component> takes its state from <${r}>.${t}: it cannot also load one (state / src / json / an inline script).`),await o(n).whenDefined(r);let i=_.get(n);if(void 0!==i)return i.pe!==t&&g(`<${r}> already has a <${u.tagNames.state} bind-component="${i.pe}">.`),i.state;let a=()=>(L.get(n)??[]).filter(e=>K(e.name)===t),s=ne(n,t);if(s&&0===a().length&&oe(n),0===a().length&&(s||((e,t)=>!0===e.getAttribute(V)?.split(" ").includes(t))(n,t))){let e;await new Promise((o,l)=>{I.set(n,o),e=function(e,t){C(e)&&t();let n=E.get(e)??new Set;return E.set(e,n.add(t)),()=>n.delete(t)}(n.getRootNode(),()=>l(new Error(`[@wcstack/state] <${r}>.${t} will not mount: the root state failed to initialize.`)))}).finally(()=>e())}I.delete(n);let c=a(),d=X.get(n),f=void 0!==d&&d.has(t)?d.get(t):n[t];if((null===f||"object"!=typeof f)&&g(`"bind-component": <${r}>.${t} must be an object (the component's state), got ${null===f?"null":typeof f}.`),0===c.length&&l){let e=new Error(`[@wcstack/state] A plain (unwired) Light DOM "bind-component" is not supported. Attach a shadow root to <${r}>, or mount it from the host (${u.bindAttributeName}="${t}: path").`);return queueMicrotask(()=>{throw e}),G}let h=[];for(let e of c){let o=e.name===t?"":e.name.slice(t.length+1);h.some(e=>e.$===o)&&g(`<${r}> maps "${e.name}" twice.`);let l=o.split(".").indexOf("*");if(l>=0){let n=o.split(".").slice(0,l).join(".");g(`<${r}> maps "${e.name}": the component-side path of a mount cannot contain "*"${""===n?"":` — map the list itself ("${t}.${n}: <the host's list>")`}.`)}h.push({$:o,me:e.o,r:e.r,ro:H.has(e)}),e.engine.xn(e),""!==o&&delete n[e.name]}let p=0===c.length?function(e){let t=Object.getOwnPropertyDescriptors(e),n=Object.isFrozen(e);for(let e of Object.values(t))"value"in e&&!1===e.writable&&(e.writable=!0,n=!0);return n?Object.create(Object.getPrototypeOf(e),t):e}(f):f;return _.set(n,i={el:n,pe:t,state:p,engine:0===c.length?null:c[0].engine,entries:h,O:null}),p}(e,n,a,!i):Promise.reject(new Error(`[@wcstack/state] "bind-component" requires <${u.tagNames.state}> to be a direct child of a custom element.`))).catch(d),async start(t,n){await ve(e,a,i?r:a,t,()=>{f=!0,n()}).catch(e=>{let t=s();return!f&&null!==t&&(t.broken=!0),d(e)})},Xe(){let t=s();null!==t?ke(t).catch(e=>console.error(e)):f?Promise.resolve().then(()=>{if(e.parentNode===r)return ve(e,a,i?r:a,_.get(a).state,()=>{})}).catch(e=>console.error(e)):I.has(a)&&oe(a)},Ln(){let e=s();null!==e&&(he(e,!1),!e.broken&&(e.x.ke("$disconnectedCallback"),null===e.host.engine&&c.element?.(e.x,"disconnected")))},reset(){g(`re-setting a component's state is not supported: write <${a?.localName}>.${n} instead.`)}}}var Oe={name:"scopes",install(){c.at=f(p,c.at,T),c.at=f(p,c.at,q),c.at=f(p,c.at,je),c.ar=ee,c.$o=te,c.element=d(c.element,(e,t)=>{if("mounting"!==t)return function(e,t){let n=v.get(e)??[];if("disconnected"===t)for(let e of n)P(e);else if("reset"!==t&&N(l.get(e.root))===e){A(e,e.root);for(let e of n)$.get(e.root).has(e.t)||$.get(e.root).set(e.t,e)}}(e,t);let n=e.element.getRootNode();A(e,n),function(e,t){let n=t.host,o=void 0===n?void 0:z.get(n);void 0!==o&&Q.set(e,{host:n,def:o})}(e,n)}),c.be=d(c.be,(e,t,n,o,l,r)=>{(function(e,t,n,o){let l=Q.get(e);if(void 0===l)return;let r=t.t.split(".",1)[0];if(!l.def.bindables.includes(r))return;let i=o&&t.t===r;l.host.dispatchEvent(new CustomEvent(`${l.def.tag}:${r}-changed`,{detail:i?n:void 0,bubbles:!0}))})(e,t,l,r),ye(e,t,n,o,l,r,!1)}),c.ve=d(c.ve,(e,t,n)=>ye(e,t,n,void 0,void 0,!1,!0)),c.Ae=f(h,c.Ae,(e,t,n,o,l)=>(function(e,t){let n=v.get(e);if(void 0!==n&&0===t.n)for(let{t:e}of n)e.startsWith(`${t.t}.`)&&g(`writing "${t.t}" would replace the volume grafted at "${e}"; write the paths under it instead.`)}(e,t),function(e,t,n){let o,l=B.get(e);if(void 0===l)return!1;for(let e=t;null!==e&&void 0===o;e=e.d)o=l.dt.get(e);if(void 0===o)return!1;let r=o.e;return!((null===r.r||r.r.y)&&!r.ro)&&(!!n||(ce(l,r.r),void g(`[wcs/mount-readonly] <${l.host.el.localName}> cannot write "${t.t}": it is mounted read-only ("${l.host.pe}${""===r.$?"":`.${r.$}`}#ro: ${r.me.t}"). Write it on the host, or drop #ro from the mount.`)))}(e,t,l)));let e=c.de;c.de=(t,n)=>{let o=v.get(t);void 0!==o&&o.length>0&&g(`re-setting a root state with grafted volumes (${o.map(e=>e.t).join(", ")}) is not supported: their data is part of the tree.`),function(e){let t=F.get(e);if(void 0===t)return!1;for(let e of t.values())if(e.size>0)return!0;return!1}(t)&&g("re-setting a root state with mounted components is not supported: they read its data."),e?.(t,n)}}},xe=Oe;export{xe as default,Oe as scopes};
|
|
2
2
|
//# sourceMappingURL=scopes.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e}from"../chunks/chunk-ZQ642MBV.js";import{b as t,c as l}from"../chunks/chunk-UD3AYVP2.js";import"../chunks/chunk-55J45X6H.js";import{a as n,i as r,j as o,k as i,l as s,m as a}from"../chunks/chunk-L3PFEJP7.js";import"../chunks/chunk-W4KOY6GT.js";import"../chunks/chunk-7AYOQHZH.js";import{a as c}from"../chunks/chunk-M5SODAAE.js";import"../chunks/chunk-ZN52NEIB.js";import"../chunks/chunk-NOPTR2L3.js";import"../chunks/chunk-EIMTT5I3.js";import{a as u,b as f}from"../chunks/chunk-4NJBYXIT.js";var d=e=>e.split(".").slice(0,2).join("."),p=class extends t{static find(e){return e.querySelector?.(c.tagNames.ssr)??null}get version(){return this.getAttribute("version")??""}get stateData(){let e=this.querySelector('script[type="application/json"]');return null===e?{}:JSON.parse(e.textContent||"{}")}get templates(){let e=new Map;for(let t of Array.from(this.children))"template"===t.localName&&e.set(t.id,t);return e}get hydrateProps(){return{}}getTemplate(e){return this.templates.get(e)??null}verifyVersion(){return d(this.version)===d(e)}};function m(e){let t=c.tagNames.ssr;void 0===e.get(t)&&e.define(t,class extends p{})}var h=()=>c.tagNames.ssr,g=Symbol.for("wcstack.ssr.snapshotBuilder"),b=()=>!0===document.documentElement?.hasAttribute("data-wcs-server"),v=e=>document.createComment(e),y=(e,t)=>null!==e&&8===e.nodeType&&e.data===t,w=(e,t)=>null!==e&&8===e.nodeType&&e.data.startsWith(t),N=new WeakMap,S=new WeakMap,A=new WeakMap,k=new WeakSet,x=new WeakMap;function $(e,t){let l=[];for(let n=e;null!==n&&(l.push(n),n!==t);n=n.nextSibling);return l}function T(e,t,...l){for(let l of Array.from(e.attributes))t.setAttribute(l.name,l.value);return(t.content??t).append(...l),t}var j=e=>null===e.D?e.Ue:e.D[e.D.length-1];function O(e,t,l){let n=[v(null===l?"wcs-[":`wcs-[:${l}`)];for(let e of t)null===l&&n.push(v("wcs-|")),n.push(...$(e.Ue,j(e)));n.push(v("wcs-]")),e.after(...n);for(let e of n)k.add(e)}function q(e){if(e instanceof r){O(e.S,e.Ne,null);for(let t of e.Ne)E(t);return}let t=e.O;null!==t&&(O(e.G[e.G.length-1].S,[t],e.b),E(t))}function E(e){if(null!==e.c)for(let t of e.c)q(t)}var W=new Set(["script","style","template","textarea","title"]),C="data-wcs-raw",I=e=>W.has(e.localName)||e.localName===h();function M(e){for(let t of Array.from(e.childNodes))3===t.nodeType?""===t.data?t.replaceWith(v("wcs-e")):null!==t.nextSibling&&3===t.nextSibling.nodeType&&t.after(v("wcs-s")):1===t.nodeType&&!I(t)&&M(t)}var P=0;function R(t,l){let n=t.getRootNode(),r=[l];for(let e of S.get(n)??[])e!==l&&!0===e.element?.hasAttribute("bind-component")&&r.push(e);let o=new Map;for(let e of r){let t=N.get(e);if(void 0===t)continue;let l=new Map;for(let t of e.oe.values())if(null!==t.E&&l.set(t.E.S,t.E),null!==t.L)for(let e of t.L)l.set(e.S,e);for(let t of e.ce.values())for(let e of t)if(null!==e._)for(let t of e._.G)l.set(t.S,e._);let n=new Set;for(let[e,r]of t){o.set(e,r);let t=l.get(e);void 0!==t&&!n.has(t)&&e.isConnected&&(n.add(t),q(t))}}for(let e of Array.from(n.querySelectorAll("*"))){let t=A.get(e);if(void 0!==t){let l=document.createTreeWalker(e,133,{acceptNode:e=>k.has(e)||1===e.nodeType&&t.has(e)&&B(e)?2:1}),n=[];for(let e=l.nextNode();null!==e;e=l.nextNode()){let l=e.previousSibling;(3===e.nodeType?e.data.includes("{{")&&!(I(e.parentNode)?x.has(e):t.has(l)&&w(l,"wcs-t:"))&&(x.has(e)||t.get(e)!==e.data):!t.has(e))&&n.push(e)}for(let e of n)e.remove()}let l=Array.from(e.childNodes);I(e)&&l.some(e=>x.has(e))&&e.setAttribute(C,l.map(e=>x.has(e)?`{{ ${x.get(e)} }}`:8===e.nodeType?`\x3c!--${e.data}--\x3e`:e.textContent).join(""))}M(9===n.nodeType?n.body:n);let i=document.createElement(h());i.setAttribute("version",e);let s=document.createElement("script");s.type="application/json",s.textContent=function(e){return JSON.stringify(e).replace(/[<>&\u2028\u2029]/g,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,"0")}`)}(function(e){let t={};for(let l of Object.keys(e)){if("$"===l[0])continue;let n=Object.getOwnPropertyDescriptor(e,l);void 0!==n.get||void 0!==n.set||"function"==typeof n.value||(t[l]=n.value)}return t}(l.target)),i.append(s);for(let[e,t]of o){if(!e.isConnected)continue;let l=e.parentNode;for(;null!==l&&"svg"!==l.localName&&"foreignObject"!==l.localName;)l=l.parentElement;let n="svg"===l?.localName,r=`wcs-${n?"s":"t"}${P++}`;e.replaceWith(v(`wcs-p:${r}`));let o=document.importNode(a(t),!0);for(let e of Array.from(o.querySelectorAll("template")))"http://www.w3.org/2000/svg"===e.namespaceURI&&e.replaceWith(T(e,document.createElement("template"),...e.childNodes));if(n){let e=document.createElementNS(l.namespaceURI,"svg");e.append(o),o=e}let s=document.createElement("template");s.id=r,i.append(T(t,s,o))}t.before(i)}function D(e){!function(e){if(null!==e.querySelector(c.tagNames.state))for(let t of Array.from(e.querySelectorAll("input,textarea,select")))if("select"===t.localName){let e=Array.from(t.options);if(t.multiple||e.some(e=>e.hasAttribute("selected"))||e[t.selectedIndex]!==e.find(e=>!e.disabled))for(let t of e)t.toggleAttribute("selected",t.selected)}else"textarea"===t.localName?t.value!==t.defaultValue&&!t.value.includes("{{")&&!Array.from(t.childNodes).some(e=>x.has(e))&&(t.textContent=t.value):"checkbox"===t.type||"radio"===t.type?t.toggleAttribute("checked",t.checked):"password"!==t.type&&t.value!==t.defaultValue&&t.setAttribute("value",t.value)}(e);for(let t of Array.from(e.querySelectorAll(`${c.tagNames.state}[enable-ssr]`))){if(t.hasAttribute("mount")||t.hasAttribute("bind-component")||t.previousElementSibling?.localName===h())continue;let e=t.engine;null!=e&&R(t,e)}}var U=Symbol.for("wcstack.state.ssr.impl"),J=new Map,V=new WeakMap,B=e=>!0===u.$o?.(e),G=e=>1===e.nodeType&&!I(e)&&!B(e),L=e=>e.f.flat().concat(e.q??[]),Y=e=>{for(let t of L(e))t.remove()};function H(e,t,l){let n=/^wcs-\[(?::(\d+))?/.exec(e.data),r=e.previousSibling,o=e.parentNode,i=[],a=e.nextSibling;for(e.remove();null!==a&&!y(a,"wcs-]");){let e=a.nextSibling;if(y(a,"wcs-|"))i.push([]),a.remove();else{0===i.length&&i.push([]);let l=i[i.length-1];w(a,"wcs-[")?e=H(a,t,l):(l.push(a),G(a)&&Z(a,t))}a=e}let c={branch:void 0===n[1]?null:Number(n[1]),f:i,q:a??o.appendChild(v("wcs-]"))},u=L(c);a=c.q.nextSibling;for(let e of u)l?.push(e),t&&s.add(e);return t&&null!==r?J.set(r,c):Y(c),a}function Z(e,t){for(let l=e.firstChild;null!==l;)w(l,"wcs-[")?l=H(l,t):(G(l)&&Z(l,t),l=l.nextSibling)}function _(e,t,l){let n=e=>{for(let r of Array.from(e.childNodes))if(r.parentNode===e)if(8===r.nodeType){let e=r.data;try{if("wcs-s"===e)r.remove();else if("wcs-e"===e)r.replaceWith("");else if(e.startsWith("wcs-t:")){let t=v(`@@:${decodeURIComponent(e.slice(6))}`),l=r.nextSibling;for(;null!==l&&!y(l,"wcs-/t");){let e=l.nextSibling;l.remove(),l=e}l?.remove(),r.replaceWith(t)}else if(e.startsWith("wcs-p:")){let l=t.querySelector(`template[id="${e.slice(6)}"]`);if(null!==l){let t=r.parentNode,n="s"===e[10]?T(l,document.createElementNS(t.namespaceURI,"template"),...document.importNode(l.content.firstChild,!0).childNodes):document.importNode(l,!0);n.removeAttribute("id"),t.replaceChild(n,r)}}}catch{}}else 1===r.nodeType&&!I(r)&&(B(r)?V.set(r,{ssr:t,Oe:l}):n(r))};n(e),function(e){for(let t of Array.from(e.querySelectorAll("table > tbody"))){let e=[];for(let l=t.previousSibling;null!==l&&(8===l.nodeType||te(l)||"template"===l.localName);l=l.previousSibling)e.unshift(l);let l=0,n=0;if(e.forEach((e,t)=>{w(e,"wcs-[")?n++:y(e,"wcs-]")&&--n<0&&(n=0,l=t+1)}),0===n)continue;let r=0;for(let n=t.firstChild;null!==n;n=n.nextSibling)if(w(n,"wcs-["))r++;else if(y(n,"wcs-]")&&0===r--){t.prepend(...e.slice(l));break}}}(e),Z(e,l)}function z(e){let t=V.get(e);if(void 0===t||(V.delete(e),_(e,t.ssr,t.Oe),!t.Oe))return null;let l=u.Oe;return u.Oe=re,()=>{u.Oe=l,Q()}}function Q(){for(let e of J.values())Y(e);J.clear()}function X(e){let t=[];for(let l=document.createTreeWalker(e,128);l.nextNode();)t.push(l.currentNode);return t}function F(e,t,l,n){let r=null;for(let n of e){let e=n[l];null!==e&&(""===e||t===e||t.startsWith(`${e}.`))&&(null===r||e.length>r[l].length)&&(r=n)}let o=r?.[n];if(null==o)return null;let i=r[l],s=""===i?t:t.slice(i.length+1);return""===o?s:""===s?o:`${o}.${s}`}function K(e,t,l){if(b()){if(l instanceof Array){for(let e=l.length;e-- >0;)o(l[e])&&l.splice(e,1);let e=t;if(l.some(i))k.add(e);else if(e.localName.includes("-")&&!B(e)){let t=new Map;for(let l=document.createTreeWalker(e,133);l.nextNode();)t.set(l.currentNode,l.currentNode.data);A.set(e,t)}return}if("string"==typeof l){if(x.set(t,l),I(t.parentNode))return;let e=v(`wcs-t:${encodeURIComponent(l)}`),n=v("wcs-/t");return t.before(e),void t.after(n)}let n=N.get(e);void 0===n&&N.set(e,n=new Map),n.set(t,l);let r=t.getRootNode(),s=S.get(r);return void 0===s&&S.set(r,s=new Set),void s.add(e)}if("string"!=typeof l&&J.size>0){let e=J.get(l);void 0!==e&&(J.delete(l),J.set(t,e))}}var ee=e=>null!==e&&8===e.nodeType&&[c.commentIfPrefix,c.commentElseIfPrefix,c.commentElsePrefix].includes(e.data),te=e=>3===e.nodeType&&""===e.data.trim(),le=e=>(J.get(e)?.q??e).nextSibling;function ne(e,t){if(t.length!==e.sn.childNodes.length)return!1;let l=e.On;for(let n=0;n<l.length;n++){let r=l[n],o=e.sn,i=t[r[0]];for(let e=0;;){if(o=o.childNodes[r[e]],i?.nodeName!==o.nodeName)return!1;if(++e===r.length)break;i=i.firstChild;for(let t=r[e];t>0&&null!==i;t--)i=le(i)}e.ko[n]=i}return!0}function re(e,t,l){if(0===J.size)return null;let n=t,r=0;if(!l){let e=c.commentIfPrefix;if(!y(t,e))for(let l=t.previousSibling;null!==l&&1!==l.nodeType&&(ee(l)&&r++,!y(l,e));l=l.previousSibling);for(let l=t.nextSibling;!J.has(n)&&null!==l&&!y(l,e)&&1!==l.nodeType;l=l.nextSibling)ee(l)&&(n=l)}let o=J.get(n);if(void 0===o)return null;if(!l&&o.branch!==r)return J.delete(n),Y(o),null;let i=o.f.shift();if(0===o.f.length&&J.delete(n),o.q?.replaceWith(...$(t,n)),o.q=null,void 0===i)return null;let s=[];for(let e=0;e<i.length;e++){let t=J.get(i[e]);if(s.push(i[e]),void 0!==t)for(;e<i.length&&i[e]!==t.q;)e++}if(!ne(e,s)){let l=(e.In?e.root:e.sn).cloneNode(!0);s=e.In?[l]:[...l.childNodes],ne(e,s),(i[0]??o.f.find(e=>e.length>0)?.[0]??t).before(l);for(let e of i)e.remove()}return s}var oe={name:"ssr",install(){u.jn=K,u.hr=z;let t=u.element;u.element=(l,r)=>{"mounting"===r&&function(t){let l=t.element;if(!l.hasAttribute("enable-ssr")||b())return;let r=l.previousElementSibling,o=r?.localName===h(),i=o?r.getAttribute("version"):null,s=null===i||d(i)===d(e);if(s){let e=t,l=e.ke;e.ke=(e,n)=>"$connectedCallback"===e?void 0:l.call(t,e,n)}if(!o)return;let a=!s&&parseInt(i)<4,f=/^3\.(\d+)\.(\d+)$/.exec(i),p=null!==f&&(+f[1]-5||+f[2]-3)>=0;s||console.warn(`[@wcstack/state] <${h()} version="${i}"> does not match ${e}: its snapshot is discarded, and the page renders on the client from its own state.${a&&!p?" 3.x output keeps only the path of a text binding outside a template, so such a binding loses its filters: deploy @wcstack/server 4.0 with this client.":""}`);let m=s?r.querySelector('script[type="application/json"]'):null;if(null!==m){let e=JSON.parse(m.textContent||"{}"),l=t.target;for(let t of Object.keys(e)){let n=Object.getOwnPropertyDescriptor(l,t);void 0!==n&&(void 0!==n.get||void 0!==n.set||"function"==typeof n.value)||(l[t]=e[t])}t.hydrated=!0}let g=l.getRootNode();for(let e of Array.from(g.querySelectorAll(`[${C}]`)))e.textContent=e.getAttribute(C),e.removeAttribute(C);let w=9===g.nodeType?g.body:g;a?function(e,t,l){let r=new Map,o=e=>{let t=e.parentElement;for(;null!==t&&!B(t);)t=t.parentElement;if(null===t)return null;let l=r.get(t);if(void 0===l){let e=o(t),i=t.querySelector(`:scope > ${c.tagNames.state}[bind-component]`).getAttribute("bind-component");r.set(t,l=[]);for(let r of n(t.getAttribute(c.bindAttributeName)??"")){let t=r.Je;r.$e[0]===i&&l.push([e?F(e,t,1,0):t,r.$e.slice(1).join("."),e&&t])}}return l},i=(e,t,l)=>{let n=o(e);if(null===n)return t;let r=/^([^|]*)#m\d+\.([^|]*)$/.exec(t);if(null===r)return l?t:F(n,t,0,1)??t;let i=r[1].replace(/#m\d+\./g,"").slice(0,-1);return n.some(e=>""===e[1]&&(e[0]===i||e[2]===i))?r[2]:F(n,r[2],2,1)??r[2]};for(let t of X(e).reverse()){let e=/^@@wcs-(\w+)-start:([\s\S]*)/.exec(t.data);if(null===e)continue;let n=t.nextSibling;for(;null!==n&&!y(n,`@@wcs-${e[1]}-end:${e[2]}`);)n=n.nextSibling;if(null!==n){for(;t.nextSibling!==n;)t.nextSibling.remove();n.remove(),t.replaceWith(..."text"===e[1]?[v(`@@:${i(t,e[2],l)}`)]:[])}}let s=(e,l)=>{for(let n of X(e)){let e=/^@@wcs-(?:for|if|elseif|else):(\S+)$/.exec(n.data)?.[1],r=Array.from(t.querySelectorAll("template")).find(t=>t.id===e);if(void 0===r)continue;let o=document.importNode(r,!0),a=c.bindAttributeName;o.removeAttribute("id"),o.setAttribute(a,o.getAttribute(a).replace(/^(\s*\w+\s*:\s*)([^\s|]+)/,(e,t,r)=>t+i(l??n,r))),s(o.content,l??n);let u=o.content.firstChild;n.replaceWith(.../^\s*elseif\s*:/.test(u?.getAttribute?.(a)??"")?o.content.childNodes:[o])}};s(e);for(let t of Array.from(e.querySelectorAll("[data-wcs-ssr-id]")))t.removeAttribute("data-wcs-ssr-id")}(w,r,p):_(w,r,s),r.remove(),s&&(u.Oe=re,queueMicrotask(()=>{Q(),u.Oe=null}))}(l),t?.(l,r)},function(){let e=globalThis;e[U]={build:D,reset(){P=0}},void 0===e[g]&&(e[g]={protocol:"wcs-ssr-snapshot",version:1,build:t=>e[U].build(t),reset:()=>e[U].reset()})}(),u.To=f(u.To,m);for(let e of l())m(e)}},ie=oe;export{ie as default,oe as ssr};
|
|
1
|
+
import{a as e}from"../chunks/chunk-SGLI2TU4.js";import{b as t,c as l}from"../chunks/chunk-DFXQ7MFW.js";import"../chunks/chunk-V6VVL4F3.js";import{a as n,i as r,j as o,k as i,l as s,m as a}from"../chunks/chunk-BMGEWHCR.js";import"../chunks/chunk-PHAN6L23.js";import"../chunks/chunk-EM3Y3SJS.js";import{a as c}from"../chunks/chunk-6MACFEK7.js";import"../chunks/chunk-ZN52NEIB.js";import"../chunks/chunk-TUQ3OPZQ.js";import"../chunks/chunk-M656SMUU.js";import{a as u,b as f}from"../chunks/chunk-4NJBYXIT.js";var d=e=>e.split(".").slice(0,2).join("."),p=class extends t{static find(e){return e.querySelector?.(c.tagNames.ssr)??null}get version(){return this.getAttribute("version")??""}get stateData(){let e=this.querySelector('script[type="application/json"]');return null===e?{}:JSON.parse(e.textContent||"{}")}get templates(){let e=new Map;for(let t of Array.from(this.children))"template"===t.localName&&e.set(t.id,t);return e}get hydrateProps(){return{}}getTemplate(e){return this.templates.get(e)??null}verifyVersion(){return d(this.version)===d(e)}};function m(e){let t=c.tagNames.ssr;void 0===e.get(t)&&e.define(t,class extends p{})}var h=()=>c.tagNames.ssr,g=Symbol.for("wcstack.ssr.snapshotBuilder"),b=()=>!0===document.documentElement?.hasAttribute("data-wcs-server"),v=e=>document.createComment(e),y=(e,t)=>null!==e&&8===e.nodeType&&e.data===t,w=(e,t)=>null!==e&&8===e.nodeType&&e.data.startsWith(t),N=new WeakMap,S=new WeakMap,A=new WeakMap,x=new WeakSet,k=new WeakMap;function $(e,t){let l=[];for(let n=e;null!==n&&(l.push(n),n!==t);n=n.nextSibling);return l}function T(e,t,...l){for(let l of Array.from(e.attributes))t.setAttribute(l.name,l.value);return(t.content??t).append(...l),t}var j=e=>null===e.D?e.Ue:e.D[e.D.length-1];function W(e,t,l){let n=[v(null===l?"wcs-[":`wcs-[:${l}`)];for(let e of t)null===l&&n.push(v("wcs-|")),n.push(...$(e.Ue,j(e)));n.push(v("wcs-]")),e.after(...n);for(let e of n)x.add(e)}function q(e){if(e instanceof r){W(e.S,e.xe,null);for(let t of e.xe)C(t);return}let t=e.O;null!==t&&(W(e.G[e.G.length-1].S,[t],e.b),C(t))}function C(e){if(null!==e.c)for(let t of e.c)q(t)}var E=new Set(["script","style","template","textarea","title"]),O="data-wcs-raw",M=e=>E.has(e.localName)||e.localName===h();function I(e){for(let t of Array.from(e.childNodes))3===t.nodeType?""===t.data?t.replaceWith(v("wcs-e")):null!==t.nextSibling&&3===t.nextSibling.nodeType&&t.after(v("wcs-s")):1===t.nodeType&&!M(t)&&I(t)}var U=0;function P(t,l){let n=t.getRootNode(),r=[l];for(let e of S.get(n)??[])e!==l&&!0===e.element?.hasAttribute("bind-component")&&r.push(e);let o=new Map;for(let e of r){let t=N.get(e);if(void 0===t)continue;let l=new Map;for(let t of e.oe.values())if(null!==t.E&&l.set(t.E.S,t.E),null!==t.L)for(let e of t.L)l.set(e.S,e);for(let t of e.ce.values())for(let e of t)if(null!==e._)for(let t of e._.G)l.set(t.S,e._);let n=new Set;for(let[e,r]of t){o.set(e,r);let t=l.get(e);void 0!==t&&!n.has(t)&&e.isConnected&&(n.add(t),q(t))}}for(let e of Array.from(n.querySelectorAll("*"))){let t=A.get(e);if(void 0!==t){let l=document.createTreeWalker(e,133,{acceptNode:e=>x.has(e)||1===e.nodeType&&t.has(e)&&G(e)?2:1}),n=[];for(let e=l.nextNode();null!==e;e=l.nextNode()){let l=e.previousSibling;(3===e.nodeType?e.data.includes("{{")&&!(M(e.parentNode)?k.has(e):t.has(l)&&w(l,"wcs-t:"))&&(k.has(e)||t.get(e)!==e.data):!t.has(e))&&n.push(e)}for(let e of n)e.remove()}let l=Array.from(e.childNodes);M(e)&&l.some(e=>k.has(e))&&e.setAttribute(O,l.map(e=>k.has(e)?`{{ ${k.get(e)} }}`:8===e.nodeType?`\x3c!--${e.data}--\x3e`:e.textContent).join(""))}I(9===n.nodeType?n.body:n);let i=document.createElement(h());i.setAttribute("version",e);let s=document.createElement("script");s.type="application/json",s.textContent=function(e){return JSON.stringify(e).replace(/[<>&\u2028\u2029]/g,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,"0")}`)}(function(e){let t={};for(let l of Object.keys(e)){if("$"===l[0])continue;let n=Object.getOwnPropertyDescriptor(e,l);void 0!==n.get||void 0!==n.set||"function"==typeof n.value||(t[l]=n.value)}return t}(l.target)),i.append(s);for(let[e,t]of o){if(!e.isConnected)continue;let l=e.parentNode;for(;null!==l&&"svg"!==l.localName&&"foreignObject"!==l.localName;)l=l.parentElement;let n="svg"===l?.localName,r=`wcs-${n?"s":"t"}${U++}`;e.replaceWith(v(`wcs-p:${r}`));let o=document.importNode(a(t),!0);for(let e of Array.from(o.querySelectorAll("template")))"http://www.w3.org/2000/svg"===e.namespaceURI&&e.replaceWith(T(e,document.createElement("template"),...e.childNodes));if(n){let e=document.createElementNS(l.namespaceURI,"svg");e.append(o),o=e}let s=document.createElement("template");s.id=r,i.append(T(t,s,o))}t.before(i)}function R(e){!function(e){if(null!==e.querySelector(c.tagNames.state))for(let t of Array.from(e.querySelectorAll("input,textarea,select")))if("select"===t.localName){let e=Array.from(t.options);if(t.multiple||e.some(e=>e.hasAttribute("selected"))||e[t.selectedIndex]!==e.find(e=>!e.disabled))for(let t of e)t.toggleAttribute("selected",t.selected)}else"textarea"===t.localName?t.value!==t.defaultValue&&!t.value.includes("{{")&&!Array.from(t.childNodes).some(e=>k.has(e))&&(t.textContent=t.value):"checkbox"===t.type||"radio"===t.type?t.toggleAttribute("checked",t.checked):"password"!==t.type&&t.value!==t.defaultValue&&t.setAttribute("value",t.value)}(e);for(let t of Array.from(e.querySelectorAll(`${c.tagNames.state}[enable-ssr]`))){if(t.hasAttribute("mount")||t.hasAttribute("bind-component")||t.previousElementSibling?.localName===h())continue;let e=t.engine;null!=e&&P(t,e)}}var D=Symbol.for("wcstack.state.ssr.impl"),J=new Map,V=new WeakMap,G=e=>!0===u.$o?.(e),L=e=>1===e.nodeType&&!M(e)&&!G(e),B=e=>e.f.flat().concat(e.q??[]),F=e=>{for(let t of B(e))t.remove()};function Q(e,t,l){let n=/^wcs-\[(?::(\d+))?/.exec(e.data),r=e.previousSibling,o=e.parentNode,i=[],a=e.nextSibling;for(e.remove();null!==a&&!y(a,"wcs-]");){let e=a.nextSibling;if(y(a,"wcs-|"))i.push([]),a.remove();else{0===i.length&&i.push([]);let l=i[i.length-1];w(a,"wcs-[")?e=Q(a,t,l):(l.push(a),L(a)&&_(a,t))}a=e}let c={branch:void 0===n[1]?null:Number(n[1]),f:i,q:a??o.appendChild(v("wcs-]"))},u=B(c);a=c.q.nextSibling;for(let e of u)l?.push(e),t&&s.add(e);return t&&null!==r?J.set(r,c):F(c),a}function _(e,t){for(let l=e.firstChild;null!==l;)w(l,"wcs-[")?l=Q(l,t):(L(l)&&_(l,t),l=l.nextSibling)}function z(e,t,l){let n=e=>{for(let r of Array.from(e.childNodes))if(r.parentNode===e)if(8===r.nodeType){let e=r.data;try{if("wcs-s"===e)r.remove();else if("wcs-e"===e)r.replaceWith("");else if(e.startsWith("wcs-t:")){let t=v(`@@:${decodeURIComponent(e.slice(6))}`),l=r.nextSibling;for(;null!==l&&!y(l,"wcs-/t");){let e=l.nextSibling;l.remove(),l=e}l?.remove(),r.replaceWith(t)}else if(e.startsWith("wcs-p:")){let l=t.querySelector(`template[id="${e.slice(6)}"]`);if(null!==l){let t=r.parentNode,n="s"===e[10]?T(l,document.createElementNS(t.namespaceURI,"template"),...document.importNode(l.content.firstChild,!0).childNodes):document.importNode(l,!0);n.removeAttribute("id"),t.replaceChild(n,r)}}}catch{}}else 1===r.nodeType&&!M(r)&&(G(r)?V.set(r,{ssr:t,Oe:l}):n(r))};n(e),function(e){for(let t of Array.from(e.querySelectorAll("table > tbody"))){let e=[];for(let l=t.previousSibling;null!==l&&(8===l.nodeType||te(l)||"template"===l.localName);l=l.previousSibling)e.unshift(l);let l=0,n=0;if(e.forEach((e,t)=>{w(e,"wcs-[")?n++:y(e,"wcs-]")&&--n<0&&(n=0,l=t+1)}),0===n)continue;let r=0;for(let n=t.firstChild;null!==n;n=n.nextSibling)if(w(n,"wcs-["))r++;else if(y(n,"wcs-]")&&0===r--){t.prepend(...e.slice(l));break}}}(e),_(e,l)}function H(e){let t=V.get(e);if(void 0===t||(V.delete(e),z(e,t.ssr,t.Oe),!t.Oe))return null;let l=u.Oe;return u.Oe=re,()=>{u.Oe=l,X()}}function X(){for(let e of J.values())F(e);J.clear()}function Y(e){let t=[];for(let l=document.createTreeWalker(e,128);l.nextNode();)t.push(l.currentNode);return t}function Z(e,t,l,n){let r=null;for(let n of e){let e=n[l];null!==e&&(""===e||t===e||t.startsWith(`${e}.`))&&(null===r||e.length>r[l].length)&&(r=n)}let o=r?.[n];if(null==o)return null;let i=r[l],s=""===i?t:t.slice(i.length+1);return""===o?s:""===s?o:`${o}.${s}`}function K(e,t,l){if(b()){if(l instanceof Array){for(let e=l.length;e-- >0;)o(l[e])&&l.splice(e,1);let e=t;if(l.some(i))x.add(e);else if(e.localName.includes("-")&&!G(e)){let t=new Map;for(let l=document.createTreeWalker(e,133);l.nextNode();)t.set(l.currentNode,l.currentNode.data);A.set(e,t)}return}if("string"==typeof l){if(k.set(t,l),M(t.parentNode))return;let e=v(`wcs-t:${encodeURIComponent(l)}`),n=v("wcs-/t");return t.before(e),void t.after(n)}let n=N.get(e);void 0===n&&N.set(e,n=new Map),n.set(t,l);let r=t.getRootNode(),s=S.get(r);return void 0===s&&S.set(r,s=new Set),void s.add(e)}if("string"!=typeof l&&J.size>0){let e=J.get(l);void 0!==e&&(J.delete(l),J.set(t,e))}}var ee=e=>null!==e&&8===e.nodeType&&[c.commentIfPrefix,c.commentElseIfPrefix,c.commentElsePrefix].includes(e.data),te=e=>3===e.nodeType&&""===e.data.trim(),le=e=>(J.get(e)?.q??e).nextSibling;function ne(e,t){if(t.length!==e.sn.childNodes.length)return!1;let l=e.On;for(let n=0;n<l.length;n++){let r=l[n],o=e.sn,i=t[r[0]];for(let e=0;;){if(o=o.childNodes[r[e]],i?.nodeName!==o.nodeName)return!1;if(++e===r.length)break;i=i.firstChild;for(let t=r[e];t>0&&null!==i;t--)i=le(i)}e.ko[n]=i}return!0}function re(e,t,l){if(0===J.size)return null;let n=t,r=0;if(!l){let e=c.commentIfPrefix;if(!y(t,e))for(let l=t.previousSibling;null!==l&&1!==l.nodeType&&(ee(l)&&r++,!y(l,e));l=l.previousSibling);for(let l=t.nextSibling;!J.has(n)&&null!==l&&!y(l,e)&&1!==l.nodeType;l=l.nextSibling)ee(l)&&(n=l)}let o=J.get(n);if(void 0===o)return null;if(!l&&o.branch!==r)return J.delete(n),F(o),null;let i=o.f.shift();if(0===o.f.length&&J.delete(n),o.q?.replaceWith(...$(t,n)),o.q=null,void 0===i)return null;let s=[];for(let e=0;e<i.length;e++){let t=J.get(i[e]);if(s.push(i[e]),void 0!==t)for(;e<i.length&&i[e]!==t.q;)e++}if(!ne(e,s)){let l=(e.In?e.root:e.sn).cloneNode(!0);s=e.In?[l]:[...l.childNodes],ne(e,s),(i[0]??o.f.find(e=>e.length>0)?.[0]??t).before(l);for(let e of i)e.remove()}return s}var oe={name:"ssr",install(){u.jn=K,u.hr=H;let t=u.element;u.element=(l,r)=>{"mounting"===r&&function(t){let l=t.element;if(!l.hasAttribute("enable-ssr")||b())return;let r=l.previousElementSibling,o=r?.localName===h(),i=o?r.getAttribute("version"):null,s=null===i||d(i)===d(e);if(s){let e=t,l=e.ke;e.ke=(e,n)=>"$connectedCallback"===e?void 0:l.call(t,e,n)}if(!o)return;let a=!s&&parseInt(i)<4,f=/^3\.(\d+)\.(\d+)$/.exec(i),p=null!==f&&(+f[1]-5||+f[2]-3)>=0;s||console.warn(`[@wcstack/state] <${h()} version="${i}"> does not match ${e}: its snapshot is discarded, and the page renders on the client from its own state.${a&&!p?" 3.x output keeps only the path of a text binding outside a template, so such a binding loses its filters: deploy @wcstack/server 4.0 with this client.":""}`);let m=s?r.querySelector('script[type="application/json"]'):null;if(null!==m){let e=JSON.parse(m.textContent||"{}"),l=t.target;for(let t of Object.keys(e)){let n=Object.getOwnPropertyDescriptor(l,t);void 0!==n&&(void 0!==n.get||void 0!==n.set||"function"==typeof n.value)||(l[t]=e[t])}t.hydrated=!0}let g=l.getRootNode();for(let e of Array.from(g.querySelectorAll(`[${O}]`)))e.textContent=e.getAttribute(O),e.removeAttribute(O);let w=9===g.nodeType?g.body:g;a?function(e,t,l){let r=new Map,o=e=>{let t=e.parentElement;for(;null!==t&&!G(t);)t=t.parentElement;if(null===t)return null;let l=r.get(t);if(void 0===l){let e=o(t),i=t.querySelector(`:scope > ${c.tagNames.state}[bind-component]`).getAttribute("bind-component");r.set(t,l=[]);for(let r of n(t.getAttribute(c.bindAttributeName)??"")){let t=r.Je;r.$e[0]===i&&l.push([e?Z(e,t,1,0):t,r.$e.slice(1).join("."),e&&t])}}return l},i=(e,t,l)=>{let n=o(e);if(null===n)return t;let r=/^([^|]*)#m\d+\.([^|]*)$/.exec(t);if(null===r)return l?t:Z(n,t,0,1)??t;let i=r[1].replace(/#m\d+\./g,"").slice(0,-1);return n.some(e=>""===e[1]&&(e[0]===i||e[2]===i))?r[2]:Z(n,r[2],2,1)??r[2]};for(let t of Y(e).reverse()){let e=/^@@wcs-(\w+)-start:([\s\S]*)/.exec(t.data);if(null===e)continue;let n=t.nextSibling;for(;null!==n&&!y(n,`@@wcs-${e[1]}-end:${e[2]}`);)n=n.nextSibling;if(null!==n){for(;t.nextSibling!==n;)t.nextSibling.remove();n.remove(),t.replaceWith(..."text"===e[1]?[v(`@@:${i(t,e[2],l)}`)]:[])}}let s=(e,l)=>{for(let n of Y(e)){let e=/^@@wcs-(?:for|if|elseif|else):(\S+)$/.exec(n.data)?.[1],r=Array.from(t.querySelectorAll("template")).find(t=>t.id===e);if(void 0===r)continue;let o=document.importNode(r,!0),a=c.bindAttributeName;o.removeAttribute("id"),o.setAttribute(a,o.getAttribute(a).replace(/^(\s*\w+\s*:\s*)([^\s|]+)/,(e,t,r)=>t+i(l??n,r))),s(o.content,l??n);let u=o.content.firstChild;n.replaceWith(.../^\s*elseif\s*:/.test(u?.getAttribute?.(a)??"")?o.content.childNodes:[o])}};s(e);for(let t of Array.from(e.querySelectorAll("[data-wcs-ssr-id]")))t.removeAttribute("data-wcs-ssr-id")}(w,r,p):z(w,r,s),r.remove(),s&&(u.Oe=re,queueMicrotask(()=>{X(),u.Oe=null}))}(l),t?.(l,r)},function(){let e=globalThis;e[D]={build:R,reset(){U=0}},void 0===e[g]&&(e[g]={protocol:"wcs-ssr-snapshot",version:1,build:t=>e[D].build(t),reset:()=>e[D].reset()})}(),u.To=f(u.To,m);for(let e of l())m(e)}},ie=oe;export{ie as default,oe as ssr};
|
|
2
2
|
//# sourceMappingURL=ssr.js.map
|
package/package.json
CHANGED