@wcstack/state 3.0.0 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.ja.md +47 -17
  2. package/README.md +47 -17
  3. package/dist/auto.min.js +1 -1
  4. package/dist/auto.min.js.map +1 -1
  5. package/dist/define.d.ts +11 -7
  6. package/dist/index.d.ts +15 -7
  7. package/dist/index.esm.js +1 -1
  8. package/dist/index.esm.js.map +1 -1
  9. package/dist/manifest.d.ts +14 -1
  10. package/dist/manifest.esm.js +91 -35
  11. package/dist/parser.esm.js +25 -0
  12. package/dist/split/chunks/binder.js +1 -1
  13. package/dist/split/chunks/binder.js.map +1 -1
  14. package/dist/split/chunks/checkDependency.js +1 -1
  15. package/dist/split/chunks/declarationAliases.js +2 -0
  16. package/dist/split/chunks/declarationAliases.js.map +1 -0
  17. package/dist/split/chunks/filterRegistry.js +1 -1
  18. package/dist/split/chunks/filterRegistry.js.map +1 -1
  19. package/dist/split/chunks/mount.js +1 -1
  20. package/dist/split/chunks/mount.js.map +1 -1
  21. package/dist/split/chunks/pathDiagnostics.js +1 -1
  22. package/dist/split/chunks/pathDiagnostics.js.map +1 -1
  23. package/dist/split/chunks/registerComponents.js +1 -1
  24. package/dist/split/chunks/registerComponents.js.map +1 -1
  25. package/dist/split/chunks/setAll.js +1 -1
  26. package/dist/split/chunks/version.js +1 -1
  27. package/dist/split/chunks/watchRuntime.js +1 -1
  28. package/dist/split/core.d.ts +11 -7
  29. package/dist/split/core.js +1 -1
  30. package/dist/split/core.js.map +1 -1
  31. package/dist/split/features/devtools.js +1 -1
  32. package/dist/split/features/devtools.js.map +1 -1
  33. package/dist/split/features/diagnostics.js +1 -1
  34. package/dist/split/features/formats.js +1 -1
  35. package/dist/split/features/formats.js.map +1 -1
  36. package/dist/split/features/recursion.js +1 -1
  37. package/dist/split/features/scopes.js +1 -1
  38. package/dist/split/features/scopes.js.map +1 -1
  39. package/dist/split/features/ssr.js +1 -1
  40. package/dist/split/features/ssr.js.map +1 -1
  41. package/dist/split/features/temporal.js +1 -1
  42. package/dist/split/features/temporal.js.map +1 -1
  43. package/dist/wcs-manifest.json +65 -25
  44. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- import{aD as t,H as a}from"./binder.js";function n(n,l){if(!n.untracking&&n.addressStackLength>0){const d=n.lastAddressStack,o=d?.pathInfo??null,s=n.stateElement;if(null!==o&&s.getterPaths.has(o.path)&&o.path!==l.pathInfo.path&&(s.addDynamicDependency(l.pathInfo.path,o.path),l.pathInfo.wildcardCount>0&&o.wildcardCount>0)){const n=t(l.pathInfo,o);if(n>0){let t=!1;const e=l.listIndex??null,i=d.listIndex??null;for(let d=0;d<n;d++){if((null!==e?a(e,d,l.pathInfo.wildcardCount):null)!==(null!==i?a(i,d,o.wildcardCount):null)){t=!0;break}}if(t)for(let t=0;t<n;t++)s.addCrossRowListPath?.(l.pathInfo.wildcardParentPaths[t])}}}}export{n as c};
1
+ import{aD as t,I as a}from"./binder.js";function n(n,l){if(!n.untracking&&n.addressStackLength>0){const d=n.lastAddressStack,o=d?.pathInfo??null,s=n.stateElement;if(null!==o&&s.getterPaths.has(o.path)&&o.path!==l.pathInfo.path&&(s.addDynamicDependency(l.pathInfo.path,o.path),l.pathInfo.wildcardCount>0&&o.wildcardCount>0)){const n=t(l.pathInfo,o);if(n>0){let t=!1;const e=l.listIndex??null,i=d.listIndex??null;for(let d=0;d<n;d++){if((null!==e?a(e,d,l.pathInfo.wildcardCount):null)!==(null!==i?a(i,d,o.wildcardCount):null)){t=!0;break}}if(t)for(let t=0;t<n;t++)s.addCrossRowListPath?.(l.pathInfo.wildcardParentPaths[t])}}}}export{n as c};
2
2
  //# sourceMappingURL=checkDependency.js.map
@@ -0,0 +1,2 @@
1
+ import{a as e,o as t}from"./pathDiagnostics.js";import{r as o}from"./errorGuidance.js";const r={$updatedCallback:t,$streams:e},a=new WeakSet;function n(e,t){let o=e;for(;null!==o&&!Object.prototype.hasOwnProperty.call(o,t);)o=Object.getPrototypeOf(o);return o}function s(e){if(!a.has(e)){for(const t of Object.keys(r)){if(!(t in e))continue;const a=r[t];a in e&&o(`[wcs/declaration-alias] The state declares both "${t}" and "${a}". "${t}" is the old name of "${a}" (it works through 3.x) — keep "${a}".`);const s=n(e,t),c=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,a,{...c,configurable:!0}),s===e&&delete e[t]}a.add(e)}}export{s as n};
2
+ //# sourceMappingURL=declarationAliases.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declarationAliases.js","sources":["../../../../../src/declarationAliases.ts"],"sourcesContent":["/**\n * declarationAliases.ts — 宣言キーの旧名 → 正式名(要件 B12・docs/state-3x-naming.ja.md V13 / V14)。\n *\n * `$updatedCallback` → `$renderedCallback`、`$streams` → `$stream`。旧名は 3.x の間は受け、4.0 で外す(D4)。\n * state オブジェクトがランタイムに入る入口(State の `_state` と `_loadStateFromSource`、マウント記録)で\n * 1 回だけ正規化し、以降のすべての読み手は正式名だけを見る。両方の綴りを宣言したらどちらが効くのか\n * 書き手に見えないので、名指しで落とす(D38)。\n */\nimport { STATE_STREAMS_NAME, STATE_UPDATED_CALLBACK_NAME } from \"./define\";\nimport { raiseError } from \"./raiseError\";\n\nexport const DECLARATION_ALIASES: Readonly<Record<string, string>> = {\n $updatedCallback: STATE_UPDATED_CALLBACK_NAME,\n $streams: STATE_STREAMS_NAME,\n};\n\n/** 正規化済みの state オブジェクト(同じオブジェクトの再セット・ボリュームの 2 つの入口で二重に処理しない) */\nconst normalizedStates = new WeakSet<object>();\n\nfunction findOwner(value: object, key: string): object {\n let owner: object | null = value;\n while (owner !== null && !Object.prototype.hasOwnProperty.call(owner, key)) {\n owner = Object.getPrototypeOf(owner);\n }\n return owner!;\n}\n\n/**\n * 旧名で宣言されたキーを正式名へ写す。自前のプロパティなら旧名は消す。class の state でメソッドが\n * プロトタイプにある形(`$updatedCallback() {}`)は、インスタンスに正式名の定義を足すだけにする。\n */\nexport function normalizeDeclarationAliases(state: object): void {\n if (normalizedStates.has(state)) {\n return;\n }\n for (const alias of Object.keys(DECLARATION_ALIASES)) {\n if (!(alias in state)) {\n continue;\n }\n const canonical = DECLARATION_ALIASES[alias];\n if (canonical in state) {\n raiseError(\n `[wcs/declaration-alias] The state declares both \"${alias}\" and \"${canonical}\". ` +\n `\"${alias}\" is the old name of \"${canonical}\" (it works through 3.x) — keep \"${canonical}\".`,\n );\n }\n const owner = findOwner(state, alias);\n const descriptor = Object.getOwnPropertyDescriptor(owner, alias)!;\n Object.defineProperty(state, canonical, { ...descriptor, configurable: true });\n if (owner === state) {\n delete (state as Record<string, unknown>)[alias];\n }\n }\n normalizedStates.add(state);\n}\n"],"names":["DECLARATION_ALIASES","$updatedCallback","STATE_UPDATED_CALLBACK_NAME","$streams","STATE_STREAMS_NAME","normalizedStates","WeakSet","findOwner","value","key","owner","Object","prototype","hasOwnProperty","call","getPrototypeOf","normalizeDeclarationAliases","state","has","alias","keys","canonical","raiseError","descriptor","getOwnPropertyDescriptor","defineProperty","configurable","add"],"mappings":"uFAWO,MAAMA,EAAwD,CACnEC,iBAAkBC,EAClBC,SAAUC,GAINC,EAAmB,IAAIC,QAE7B,SAASC,EAAUC,EAAeC,GAChC,IAAIC,EAAuBF,EAC3B,KAAiB,OAAVE,IAAmBC,OAAOC,UAAUC,eAAeC,KAAKJ,EAAOD,IACpEC,EAAQC,OAAOI,eAAeL,GAEhC,OAAOA,CACT,CAMM,SAAUM,EAA4BC,GAC1C,IAAIZ,EAAiBa,IAAID,GAAzB,CAGA,IAAK,MAAME,KAASR,OAAOS,KAAKpB,GAAsB,CACpD,KAAMmB,KAASF,GACb,SAEF,MAAMI,EAAYrB,EAAoBmB,GAClCE,KAAaJ,GACfK,EACE,oDAAoDH,WAAeE,QAC/DF,0BAA8BE,qCAA6CA,OAGnF,MAAMX,EAAQH,EAAUU,EAAOE,GACzBI,EAAaZ,OAAOa,yBAAyBd,EAAOS,GAC1DR,OAAOc,eAAeR,EAAOI,EAAW,IAAKE,EAAYG,cAAc,IACnEhB,IAAUO,UACJA,EAAkCE,EAE9C,CACAd,EAAiBsB,IAAIV,EAnBrB,CAoBF"}
@@ -1,2 +1,2 @@
1
- import{r as e,L as t,d as n}from"./errorGuidance.js";const a=Symbol.for("wcstack.ssr.snapshotBuilder");function o(){const e=document.documentElement;return!!e&&"orchestrated"===e.getAttribute("data-wcs-server")}function r(){const e=document.documentElement;return!!e&&e.hasAttribute("data-wcs-server")}const s={bindAttributeName:"data-wcs",commentTextPrefix:"wcs-text",commentForPrefix:"wcs-for",commentIfPrefix:"wcs-if",commentElseIfPrefix:"wcs-elseif",commentElsePrefix:"wcs-else",tagNames:{state:"wcs-state",ssr:"wcs-ssr"},locale:"en",debug:!1,enableMustache:!0,enableDirectionalInitialSync:!0,enablePropagationContext:!0,enableContractAnalyzer:!1,sameValueGuard:!0},i=s;function c(){return i}function l(e){e.tagNames&&Object.assign(s.tagNames,e.tagNames),"string"==typeof e.bindAttributeName&&(s.bindAttributeName=e.bindAttributeName),"string"==typeof e.commentTextPrefix&&(s.commentTextPrefix=e.commentTextPrefix),"string"==typeof e.commentForPrefix&&(s.commentForPrefix=e.commentForPrefix),"string"==typeof e.commentIfPrefix&&(s.commentIfPrefix=e.commentIfPrefix),"string"==typeof e.commentElseIfPrefix&&(s.commentElseIfPrefix=e.commentElseIfPrefix),"string"==typeof e.commentElsePrefix&&(s.commentElsePrefix=e.commentElsePrefix),"string"==typeof e.locale&&(s.locale=e.locale),"boolean"==typeof e.debug&&(s.debug=e.debug),"boolean"==typeof e.enableMustache&&(s.enableMustache=e.enableMustache),"boolean"==typeof e.enableDirectionalInitialSync&&(s.enableDirectionalInitialSync=e.enableDirectionalInitialSync),"boolean"==typeof e.enablePropagationContext&&(s.enablePropagationContext=e.enablePropagationContext),"boolean"==typeof e.enableContractAnalyzer&&(s.enableContractAnalyzer=e.enableContractAnalyzer),"boolean"==typeof e.sameValueGuard&&(s.sameValueGuard=e.sameValueGuard)}const f={not:()=>e=>!e},m={input:new Map,output:new Map},u={input:new Map,output:new Map},b=new Map;function g(e,t,n){const a=m[e],o=u[e];for(const e of Object.keys(t)){a.set(e,t[e]);const r=n?.[e];void 0===r?o.delete(e):o.set(e,r)}b.clear()}function p(a,o,r,s=o){const i=`${a}${JSON.stringify(s)}:${r}`,c=b.get(i);if(void 0!==c)return c;const l=m[r].get(a)??f[a];void 0===l&&e(`[wcs/filter-unknown] filter not found: ${a}.${n(a,function(e){return[...new Set([...Object.keys(f),...m[e].keys()])]}(r))}${t}`);const g=u[r].get(a);void 0!==g&&(o.length<g[0]||o.length>g[1])&&e(o.length<g[0]?`[wcs/filter-arity] filter "${a}" requires at least ${g[0]} argument(s) (${o.length} given).${t}`:`[wcs/filter-arity] filter "${a}" accepts at most ${g[1]} argument(s) (${o.length} given).${t}`);const p=l(o,s);return b.set(i,p),p}export{a as S,o as a,g as b,i as c,c as g,r as i,p as r,l as s};
1
+ import{r as e,L as t,d as n}from"./errorGuidance.js";const o=Symbol.for("wcstack.ssr.snapshotBuilder");function a(){const e=document.documentElement;return!!e&&"orchestrated"===e.getAttribute("data-wcs-server")}function r(){const e=document.documentElement;return!!e&&e.hasAttribute("data-wcs-server")}const s={bindAttributeName:"data-wcs",commentTextPrefix:"wcs-text",commentForPrefix:"wcs-for",commentIfPrefix:"wcs-if",commentElseIfPrefix:"wcs-elseif",commentElsePrefix:"wcs-else",tagNames:{state:"wcs-state",ssr:"wcs-ssr"},locale:"en",debug:!1,enableMustache:!0,enableDirectionalInitialSync:!0,enablePropagationContext:!0,enableContractAnalyzer:!1,sameValueGuard:!0},i=s;function c(){return i}function l(e){e.tagNames&&Object.assign(s.tagNames,e.tagNames),"string"==typeof e.bindAttributeName&&(s.bindAttributeName=e.bindAttributeName),"string"==typeof e.commentTextPrefix&&(s.commentTextPrefix=e.commentTextPrefix),"string"==typeof e.commentForPrefix&&(s.commentForPrefix=e.commentForPrefix),"string"==typeof e.commentIfPrefix&&(s.commentIfPrefix=e.commentIfPrefix),"string"==typeof e.commentElseIfPrefix&&(s.commentElseIfPrefix=e.commentElseIfPrefix),"string"==typeof e.commentElsePrefix&&(s.commentElsePrefix=e.commentElsePrefix),"string"==typeof e.locale&&(s.locale=e.locale),"boolean"==typeof e.debug&&(s.debug=e.debug),"boolean"==typeof e.enableMustache&&(s.enableMustache=e.enableMustache),"boolean"==typeof e.enableDirectionalInitialSync&&(s.enableDirectionalInitialSync=e.enableDirectionalInitialSync),"boolean"==typeof e.enablePropagationContext&&(s.enablePropagationContext=e.enablePropagationContext),"boolean"==typeof e.enableContractAnalyzer&&(s.enableContractAnalyzer=e.enableContractAnalyzer),"boolean"==typeof e.sameValueGuard&&(s.sameValueGuard=e.sameValueGuard)}const f={not:()=>e=>!e},m={input:new Map,output:new Map},u={input:new Map,output:new Map},b={input:new Map,output:new Map},g=new Map;function p(e,t,n,o){const a=m[e],r=u[e];for(const e of Object.keys(t)){a.set(e,t[e]);const o=n?.[e];void 0===o?r.delete(e):r.set(e,o)}for(const t of Object.keys(o??{}))b[e].set(t,o[t]);g.clear()}function x(o,a,r,s=a){const i=`${o}${JSON.stringify(s)}:${r}`,c=g.get(i);if(void 0!==c)return c;const l=b[r].get(o)??o,p=m[r].get(l)??f[l];void 0===p&&e(`[wcs/filter-unknown] filter not found: ${o}.${n(o,function(e){return[...new Set([...Object.keys(f),...m[e].keys()])]}(r))}${t}`);const x=u[r].get(l);void 0!==x&&(a.length<x[0]||a.length>x[1])&&e(a.length<x[0]?`[wcs/filter-arity] filter "${o}" requires at least ${x[0]} argument(s) (${a.length} given).${t}`:`[wcs/filter-arity] filter "${o}" accepts at most ${x[1]} argument(s) (${a.length} given).${t}`);const d=p(a,s);return g.set(i,d),d}export{o as S,a,p as b,i as c,c as g,r as i,x as r,l as s};
2
2
  //# sourceMappingURL=filterRegistry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"filterRegistry.js","sources":["../../../../../src/protocol/ssrSnapshot.ts","../../../../../src/config.ts","../../../../../src/core/filterRegistry.ts"],"sourcesContent":["// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/ssr-snapshot.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// ssr-snapshot protocol — how the SSR renderer asks whoever owns reactive\n// state to build hydration snapshots (<wcs-ssr>) as a final pass, after every\n// DOM inserter (router route content, late custom elements) has settled.\n//\n// Without this, the snapshot is built inside <wcs-state>'s connectedCallback\n// and races DOM inserted by other packages: whether a route's structural\n// templates make it into the snapshot depends on document order and state's\n// load mechanism (docs/ssr-router-design.md §5).\n//\n// The provider (@wcstack/state) installs itself on a well-known global symbol\n// at bootstrap. The renderer (@wcstack/server) looks the builder up after\n// running bootstraps: if present it announces orchestration by setting\n// `data-wcs-server=\"orchestrated\"` on the document element BEFORE parsing, and\n// calls build() right before serialization. The provider keeps its inline\n// per-element fallback whenever the attribute value is anything else, so:\n// - old renderer + new provider -> inline build, yesterday's behavior\n// - new renderer + old provider -> no builder found, attribute stays \"\",\n// the old provider builds inline as before\n// - new renderer + new provider -> orchestrated: snapshots are built last\n// and therefore always see settled DOM\n//\n// The symbol (rather than a package import) also pins the builder to the state\n// copy that actually runs on the page — its module-scoped fragment registries\n// are the ones the snapshot must read.\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/ssr-snapshot.ts), then\n// run `node scripts/sync-protocol-types.mjs` to regenerate the per-package\n// copies (packages/<pkg>/src/protocol/ssrSnapshot.ts). Those copies are\n// generated — do not edit them.\n\n/**\n * Global key the snapshot builder installs itself under. `Symbol.for` so\n * independently loaded copies of this file (state's and server's) still agree.\n */\nexport const SSR_SNAPSHOT_BUILDER_KEY = Symbol.for(\"wcstack.ssr.snapshotBuilder\");\n\n/**\n * `data-wcs-server` attribute value announcing that the renderer will call the\n * builder as a final pass. Providers must skip their inline per-element build\n * when they see this value, and keep it for any other value (including \"\").\n */\nexport const SSR_ORCHESTRATED_VALUE = \"orchestrated\";\n\nexport interface IWcsSsrSnapshotBuilder {\n readonly protocol: \"wcs-ssr-snapshot\";\n /** Integer protocol version. All versions >= 1 are participant-compatible. */\n readonly version: number;\n /**\n * Build a hydration snapshot for every enable-ssr state element in `root`\n * that does not already have one. Called once per render, after all\n * waiting-protocol elements have settled and bindings are ready. Must be\n * idempotent with respect to already-snapshotted elements.\n */\n build(root: Document): void;\n}\n\n/**\n * The installed builder, or null when there is none or it speaks a shape this\n * reader does not.\n */\nexport function getSsrSnapshotBuilder(): IWcsSsrSnapshotBuilder | null {\n const candidate = (globalThis as Record<symbol, unknown>)[\n SSR_SNAPSHOT_BUILDER_KEY\n ] as IWcsSsrSnapshotBuilder | undefined;\n if (candidate === undefined || candidate === null) return null;\n if (candidate.protocol !== \"wcs-ssr-snapshot\") return null;\n if (typeof candidate.version !== \"number\" || candidate.version < 1) return null;\n if (typeof candidate.build !== \"function\") return null;\n return candidate;\n}\n","import { IConfig, IWritableConfig } from \"./types.js\";\nimport { SSR_ORCHESTRATED_VALUE } from \"./protocol/ssrSnapshot.js\";\n\n/**\n * サーバー主導スナップショット(orchestrated)の判定\n * (docs/ssr-router-design.md §5)。renderToString が snapshot builder を\n * 見つけたときだけ `data-wcs-server=\"orchestrated\"` を宣言する — 値が他の\n * もの(旧 server の \"\" を含む)なら inline 生成が従来どおり働く。\n * inSsr と同じ理由でキャッシュしない。\n */\nexport function isOrchestratedSsr(): boolean {\n const html = document.documentElement;\n return html ? html.getAttribute('data-wcs-server') === SSR_ORCHESTRATED_VALUE : false;\n}\n\nexport function inSsr(): boolean {\n // キャッシュしない: SSR モードはプロセスの属性ではなく「現在の document」の\n // 属性。@wcstack/server はグローバル document を差し替えてサーバーレンダリング\n // した後、同一プロセスでクライアント側ハイドレーションが走る(SSR→hydrate の\n // e2e が該当)。サーバーフェーズの判定をキャッシュするとクライアントフェーズが\n // SSR モード扱いになり、hydrateBindings の代わりに buildBindings が選ばれて\n // connectedCallbackPromise が永久に未解決になる。\n const html = document.documentElement;\n return html ? html.hasAttribute('data-wcs-server') : false;\n}\n\ninterface IInternalConfig {\n bindAttributeName: string;\n commentTextPrefix: string;\n commentForPrefix: string;\n commentIfPrefix: string;\n commentElseIfPrefix: string;\n commentElsePrefix: string;\n tagNames: {\n state: string;\n ssr: string;\n };\n locale: string;\n debug: boolean;\n enableMustache: boolean;\n enableDirectionalInitialSync: boolean;\n enablePropagationContext: boolean;\n enableContractAnalyzer: boolean;\n sameValueGuard: boolean;\n}\n\nconst _config: IInternalConfig = {\n bindAttributeName: 'data-wcs',\n commentTextPrefix: 'wcs-text',\n commentForPrefix: 'wcs-for',\n commentIfPrefix: 'wcs-if',\n commentElseIfPrefix: 'wcs-elseif',\n commentElsePrefix: 'wcs-else',\n tagNames: {\n state: 'wcs-state',\n ssr: 'wcs-ssr',\n },\n locale: 'en',\n debug: false,\n enableMustache: true,\n enableDirectionalInitialSync: true,\n enablePropagationContext: true,\n // Phase 5b の dev-time contract analyzer は意図的に explicit opt-in(既定 off)。\n // wcstack は buildless / zero-config で NODE_ENV 相当の確実な dev/prod 判定が無く、\n // hostname や minification の heuristic で auto-ON すると誤検出で prod にコストを\n // 乗せうるため、dev 既定 ON は採らない。利用側が setConfig で明示有効化する\n // (docs/architecture-hardening/10-defaulting-rollout-status.md §C)。\n enableContractAnalyzer: false,\n sameValueGuard: true,\n};\n\n// backward compatible export (read-only usage)\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n return config;\n}\n\nexport function setConfig(partialConfig: IWritableConfig): void {\n if (partialConfig.tagNames) {\n Object.assign(_config.tagNames, partialConfig.tagNames);\n }\n if (typeof partialConfig.bindAttributeName === \"string\") {\n _config.bindAttributeName = partialConfig.bindAttributeName;\n }\n if (typeof partialConfig.commentTextPrefix === \"string\") {\n _config.commentTextPrefix = partialConfig.commentTextPrefix;\n }\n if (typeof partialConfig.commentForPrefix === \"string\") {\n _config.commentForPrefix = partialConfig.commentForPrefix;\n }\n if (typeof partialConfig.commentIfPrefix === \"string\") {\n _config.commentIfPrefix = partialConfig.commentIfPrefix;\n }\n if (typeof partialConfig.commentElseIfPrefix === \"string\") {\n _config.commentElseIfPrefix = partialConfig.commentElseIfPrefix;\n }\n if (typeof partialConfig.commentElsePrefix === \"string\") {\n _config.commentElsePrefix = partialConfig.commentElsePrefix;\n }\n if (typeof partialConfig.locale === \"string\") {\n _config.locale = partialConfig.locale;\n }\n if (typeof partialConfig.debug === \"boolean\") {\n _config.debug = partialConfig.debug;\n }\n if (typeof partialConfig.enableMustache === \"boolean\") {\n _config.enableMustache = partialConfig.enableMustache;\n }\n if (typeof partialConfig.enableDirectionalInitialSync === \"boolean\") {\n _config.enableDirectionalInitialSync = partialConfig.enableDirectionalInitialSync;\n }\n if (typeof partialConfig.enablePropagationContext === \"boolean\") {\n _config.enablePropagationContext = partialConfig.enablePropagationContext;\n }\n if (typeof partialConfig.enableContractAnalyzer === \"boolean\") {\n _config.enableContractAnalyzer = partialConfig.enableContractAnalyzer;\n }\n if (typeof partialConfig.sameValueGuard === \"boolean\") {\n _config.sameValueGuard = partialConfig.sameValueGuard;\n }\n}\n","/**\n * core/filterRegistry.ts — フィルタ実関数の登録簿(設計案 §4、要件 D16)。\n *\n * 文法(`path|filter(args)` の解析)は core に残り、**実関数は登録簿から束縛計画の段で引く**。\n * 解析の段は名前と引数しか作らない(`bindTextParser/parseFilters.ts`)ので、パーサだけを使う\n * tooling(`@wcstack/state/parser`)はフィルタの実装を 1 バイトも引き込まない。\n *\n * 書式フィルタ群(`uc` / `date` / `round` …)は `features/formats` が install で登録する。\n * core が自前で持つのは、エンジン自身が差し込む `not` だけ(`if` / `else` の反転 —\n * structural/notFilter.ts)。未知のフィルタは束縛計画の段で名指しで落ちる(従来は解析時)。\n */\nimport { didYouMean, LINT_HINT } from \"../errorGuidance\";\nimport type { FilterFn, FilterIOType, FilterWithOptions } from \"../filters/types\";\nimport { raiseError } from \"../raiseError\";\n\n/** `options` を受け取って実関数を返す工場(`filters/types.ts` の `FilterWithOptions` の要素) */\nexport type FilterFactory = (options?: string[], literals?: readonly unknown[]) => FilterFn;\n\n/**\n * エンジン自身が差し込むフィルタ。`if` / `else` の分岐は `not` を付けた束縛として組み立てられる\n * ので、`features/formats` の無いページでも必ず要る。\n */\nconst CORE_FILTERS: Record<string, FilterFactory> = {\n not: () => (value: unknown): boolean => !value,\n};\n\nconst registries: Record<FilterIOType, Map<string, FilterFactory>> = {\n input: new Map<string, FilterFactory>(),\n output: new Map<string, FilterFactory>(),\n};\n\n/** 受け付ける引数の個数 [最少, 最多]。登録した機能が渡したものだけ(要件 B3) */\nconst aritiesByIOType: Record<FilterIOType, Map<string, readonly [number, number]>> = {\n input: new Map<string, readonly [number, number]>(),\n output: new Map<string, readonly [number, number]>(),\n};\n\n/** 名前 + 引数 + 入出力ごとに解決済みの実関数(解決は 1 回だけ) */\nconst resolvedByKey = new Map<string, FilterFn>();\n\n/** 機能の install が呼ぶ(冪等 — 同じ名前は置き換え)。hot path には触れない */\nexport function registerFilters(\n filterIOType: FilterIOType,\n filters: FilterWithOptions,\n arity?: Readonly<Record<string, readonly [number, number]>>,\n): void {\n const registry = registries[filterIOType];\n const arities = aritiesByIOType[filterIOType];\n for (const name of Object.keys(filters)) {\n registry.set(name, filters[name] as FilterFactory);\n const bounds = arity?.[name];\n if (typeof bounds === \"undefined\") {\n arities.delete(name);\n } else {\n arities.set(name, bounds);\n }\n }\n // 登録が変われば解決済みの答えも変わりうる(同じページで 2 回 install することは無いが、\n // テストと tooling は登録簿を入れ替える)\n resolvedByKey.clear();\n}\n\n/** 登録済みの名前(core のものを含む)。診断の did-you-mean が読む */\nexport function knownFilterNames(filterIOType: FilterIOType): string[] {\n return [...new Set([...Object.keys(CORE_FILTERS), ...registries[filterIOType].keys()])];\n}\n\n/** 解決済みの答えを捨てる(tooling: `@wcstack/state/parser` の clearParserCaches) */\nexport function clearFilterResolutionCache(): void {\n resolvedByKey.clear();\n}\n\n/**\n * 実関数を引く(束縛計画の段)。未知のフィルタはここで落ちる — 解析の段では落とさない。\n * 文言は lint の `wcs/filter-unknown` と同じ語彙・同じ did-you-mean 規準(三面同語彙)。\n */\nexport function resolveFilterFn(\n filterName: string,\n args: string[],\n filterIOType: FilterIOType,\n literals: readonly unknown[] = args,\n): FilterFn {\n // 引数は型付きの値の構造のまま鍵にする(`join('a,b')` と `join(a,b)` — 要件 B3、`eq(1)` と\n // `eq('1')` — 要件 B9 を取り違えない)\n const key = `${filterName}${JSON.stringify(literals)}:${filterIOType}`;\n const resolved = resolvedByKey.get(key);\n if (typeof resolved !== \"undefined\") {\n return resolved;\n }\n const factory = registries[filterIOType].get(filterName) ?? CORE_FILTERS[filterName];\n if (typeof factory === \"undefined\") {\n raiseError(`[wcs/filter-unknown] filter not found: ${filterName}.${didYouMean(filterName, knownFilterNames(filterIOType))}${LINT_HINT}`);\n }\n const bounds = aritiesByIOType[filterIOType].get(filterName);\n if (typeof bounds !== \"undefined\" && (args.length < bounds[0] || args.length > bounds[1])) {\n // lint の wcs/filter-arity と同じ語彙\n raiseError(args.length < bounds[0]\n ? `[wcs/filter-arity] filter \"${filterName}\" requires at least ${bounds[0]} argument(s) (${args.length} given).${LINT_HINT}`\n : `[wcs/filter-arity] filter \"${filterName}\" accepts at most ${bounds[1]} argument(s) (${args.length} given).${LINT_HINT}`);\n }\n const filterFn = factory(args, literals);\n resolvedByKey.set(key, filterFn);\n return filterFn;\n}\n"],"names":["SSR_SNAPSHOT_BUILDER_KEY","Symbol","for","isOrchestratedSsr","html","document","documentElement","getAttribute","inSsr","hasAttribute","_config","bindAttributeName","commentTextPrefix","commentForPrefix","commentIfPrefix","commentElseIfPrefix","commentElsePrefix","tagNames","state","ssr","locale","debug","enableMustache","enableDirectionalInitialSync","enablePropagationContext","enableContractAnalyzer","sameValueGuard","config","getConfig","setConfig","partialConfig","Object","assign","CORE_FILTERS","not","value","registries","input","Map","output","aritiesByIOType","resolvedByKey","registerFilters","filterIOType","filters","arity","registry","arities","name","keys","set","bounds","delete","clear","resolveFilterFn","filterName","args","literals","key","JSON","stringify","resolved","get","factory","raiseError","didYouMean","Set","knownFilterNames","LINT_HINT","length","filterFn"],"mappings":"qDAwCO,MAAMA,EAA2BC,OAAOC,IAAI,wCC9BnCC,IACd,MAAMC,EAAOC,SAASC,gBACtB,QAAOF,GDmC6B,iBCnCtBA,EAAKG,aAAa,kBAClC,UAEgBC,IAOd,MAAMJ,EAAOC,SAASC,gBACtB,QAAOF,GAAOA,EAAKK,aAAa,kBAClC,CAsBA,MAAMC,EAA2B,CAC/BC,kBAAmB,WACnBC,kBAAmB,WACnBC,iBAAkB,UAClBC,gBAAiB,SACjBC,oBAAqB,aACrBC,kBAAmB,WACnBC,SAAU,CACRC,MAAO,YACPC,IAAK,WAEPC,OAAQ,KACRC,OAAO,EACPC,gBAAgB,EAChBC,8BAA8B,EAC9BC,0BAA0B,EAM1BC,wBAAwB,EACxBC,gBAAgB,GAILC,EAAkBjB,WAEfkB,IACd,OAAOD,CACT,CAEM,SAAUE,EAAUC,GACpBA,EAAcb,UAChBc,OAAOC,OAAOtB,EAAQO,SAAUa,EAAcb,UAED,iBAApCa,EAAcnB,oBACvBD,EAAQC,kBAAoBmB,EAAcnB,mBAEG,iBAApCmB,EAAclB,oBACvBF,EAAQE,kBAAoBkB,EAAclB,mBAEE,iBAAnCkB,EAAcjB,mBACvBH,EAAQG,iBAAmBiB,EAAcjB,kBAEE,iBAAlCiB,EAAchB,kBACvBJ,EAAQI,gBAAkBgB,EAAchB,iBAEO,iBAAtCgB,EAAcf,sBACvBL,EAAQK,oBAAsBe,EAAcf,qBAEC,iBAApCe,EAAcd,oBACvBN,EAAQM,kBAAoBc,EAAcd,mBAER,iBAAzBc,EAAcV,SACvBV,EAAQU,OAASU,EAAcV,QAEE,kBAAxBU,EAAcT,QACvBX,EAAQW,MAAQS,EAAcT,OAEY,kBAAjCS,EAAcR,iBACvBZ,EAAQY,eAAiBQ,EAAcR,gBAEiB,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,EAAKa,OAASlB,EAAO,GAC5B,8BAA8BI,wBAAiCJ,EAAO,mBAAmBK,EAAKa,iBAAiBD,IAC/G,8BAA8Bb,sBAA+BJ,EAAO,mBAAmBK,EAAKa,iBAAiBD,KAEnH,MAAME,EAAWP,EAAQP,EAAMC,GAE/B,OADAhB,EAAcS,IAAIQ,EAAKY,GAChBA,CACT"}
1
+ {"version":3,"file":"filterRegistry.js","sources":["../../../../../src/protocol/ssrSnapshot.ts","../../../../../src/config.ts","../../../../../src/core/filterRegistry.ts"],"sourcesContent":["// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/ssr-snapshot.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// ssr-snapshot protocol — how the SSR renderer asks whoever owns reactive\n// state to build hydration snapshots (<wcs-ssr>) as a final pass, after every\n// DOM inserter (router route content, late custom elements) has settled.\n//\n// Without this, the snapshot is built inside <wcs-state>'s connectedCallback\n// and races DOM inserted by other packages: whether a route's structural\n// templates make it into the snapshot depends on document order and state's\n// load mechanism (docs/ssr-router-design.md §5).\n//\n// The provider (@wcstack/state) installs itself on a well-known global symbol\n// at bootstrap. The renderer (@wcstack/server) looks the builder up after\n// running bootstraps: if present it announces orchestration by setting\n// `data-wcs-server=\"orchestrated\"` on the document element BEFORE parsing, and\n// calls build() right before serialization. The provider keeps its inline\n// per-element fallback whenever the attribute value is anything else, so:\n// - old renderer + new provider -> inline build, yesterday's behavior\n// - new renderer + old provider -> no builder found, attribute stays \"\",\n// the old provider builds inline as before\n// - new renderer + new provider -> orchestrated: snapshots are built last\n// and therefore always see settled DOM\n//\n// The symbol (rather than a package import) also pins the builder to the state\n// copy that actually runs on the page — its module-scoped fragment registries\n// are the ones the snapshot must read.\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/ssr-snapshot.ts), then\n// run `node scripts/sync-protocol-types.mjs` to regenerate the per-package\n// copies (packages/<pkg>/src/protocol/ssrSnapshot.ts). Those copies are\n// generated — do not edit them.\n\n/**\n * Global key the snapshot builder installs itself under. `Symbol.for` so\n * independently loaded copies of this file (state's and server's) still agree.\n */\nexport const SSR_SNAPSHOT_BUILDER_KEY = Symbol.for(\"wcstack.ssr.snapshotBuilder\");\n\n/**\n * `data-wcs-server` attribute value announcing that the renderer will call the\n * builder as a final pass. Providers must skip their inline per-element build\n * when they see this value, and keep it for any other value (including \"\").\n */\nexport const SSR_ORCHESTRATED_VALUE = \"orchestrated\";\n\nexport interface IWcsSsrSnapshotBuilder {\n readonly protocol: \"wcs-ssr-snapshot\";\n /** Integer protocol version. All versions >= 1 are participant-compatible. */\n readonly version: number;\n /**\n * Build a hydration snapshot for every enable-ssr state element in `root`\n * that does not already have one. Called once per render, after all\n * waiting-protocol elements have settled and bindings are ready. Must be\n * idempotent with respect to already-snapshotted elements.\n */\n build(root: Document): void;\n}\n\n/**\n * The installed builder, or null when there is none or it speaks a shape this\n * reader does not.\n */\nexport function getSsrSnapshotBuilder(): IWcsSsrSnapshotBuilder | null {\n const candidate = (globalThis as Record<symbol, unknown>)[\n SSR_SNAPSHOT_BUILDER_KEY\n ] as IWcsSsrSnapshotBuilder | undefined;\n if (candidate === undefined || candidate === null) return null;\n if (candidate.protocol !== \"wcs-ssr-snapshot\") return null;\n if (typeof candidate.version !== \"number\" || candidate.version < 1) return null;\n if (typeof candidate.build !== \"function\") return null;\n return candidate;\n}\n","import { IConfig, IWritableConfig } from \"./types.js\";\nimport { SSR_ORCHESTRATED_VALUE } from \"./protocol/ssrSnapshot.js\";\n\n/**\n * サーバー主導スナップショット(orchestrated)の判定\n * (docs/ssr-router-design.md §5)。renderToString が snapshot builder を\n * 見つけたときだけ `data-wcs-server=\"orchestrated\"` を宣言する — 値が他の\n * もの(旧 server の \"\" を含む)なら inline 生成が従来どおり働く。\n * inSsr と同じ理由でキャッシュしない。\n */\nexport function isOrchestratedSsr(): boolean {\n const html = document.documentElement;\n return html ? html.getAttribute('data-wcs-server') === SSR_ORCHESTRATED_VALUE : false;\n}\n\nexport function inSsr(): boolean {\n // キャッシュしない: SSR モードはプロセスの属性ではなく「現在の document」の\n // 属性。@wcstack/server はグローバル document を差し替えてサーバーレンダリング\n // した後、同一プロセスでクライアント側ハイドレーションが走る(SSR→hydrate の\n // e2e が該当)。サーバーフェーズの判定をキャッシュするとクライアントフェーズが\n // SSR モード扱いになり、hydrateBindings の代わりに buildBindings が選ばれて\n // connectedCallbackPromise が永久に未解決になる。\n const html = document.documentElement;\n return html ? html.hasAttribute('data-wcs-server') : false;\n}\n\ninterface IInternalConfig {\n bindAttributeName: string;\n commentTextPrefix: string;\n commentForPrefix: string;\n commentIfPrefix: string;\n commentElseIfPrefix: string;\n commentElsePrefix: string;\n tagNames: {\n state: string;\n ssr: string;\n };\n locale: string;\n debug: boolean;\n enableMustache: boolean;\n enableDirectionalInitialSync: boolean;\n enablePropagationContext: boolean;\n enableContractAnalyzer: boolean;\n sameValueGuard: boolean;\n}\n\nconst _config: IInternalConfig = {\n bindAttributeName: 'data-wcs',\n commentTextPrefix: 'wcs-text',\n commentForPrefix: 'wcs-for',\n commentIfPrefix: 'wcs-if',\n commentElseIfPrefix: 'wcs-elseif',\n commentElsePrefix: 'wcs-else',\n tagNames: {\n state: 'wcs-state',\n ssr: 'wcs-ssr',\n },\n locale: 'en',\n debug: false,\n enableMustache: true,\n enableDirectionalInitialSync: true,\n enablePropagationContext: true,\n // Phase 5b の dev-time contract analyzer は意図的に explicit opt-in(既定 off)。\n // wcstack は buildless / zero-config で NODE_ENV 相当の確実な dev/prod 判定が無く、\n // hostname や minification の heuristic で auto-ON すると誤検出で prod にコストを\n // 乗せうるため、dev 既定 ON は採らない。利用側が setConfig で明示有効化する\n // (docs/architecture-hardening/10-defaulting-rollout-status.md §C)。\n enableContractAnalyzer: false,\n sameValueGuard: true,\n};\n\n// backward compatible export (read-only usage)\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n return config;\n}\n\nexport function setConfig(partialConfig: IWritableConfig): void {\n if (partialConfig.tagNames) {\n Object.assign(_config.tagNames, partialConfig.tagNames);\n }\n if (typeof partialConfig.bindAttributeName === \"string\") {\n _config.bindAttributeName = partialConfig.bindAttributeName;\n }\n if (typeof partialConfig.commentTextPrefix === \"string\") {\n _config.commentTextPrefix = partialConfig.commentTextPrefix;\n }\n if (typeof partialConfig.commentForPrefix === \"string\") {\n _config.commentForPrefix = partialConfig.commentForPrefix;\n }\n if (typeof partialConfig.commentIfPrefix === \"string\") {\n _config.commentIfPrefix = partialConfig.commentIfPrefix;\n }\n if (typeof partialConfig.commentElseIfPrefix === \"string\") {\n _config.commentElseIfPrefix = partialConfig.commentElseIfPrefix;\n }\n if (typeof partialConfig.commentElsePrefix === \"string\") {\n _config.commentElsePrefix = partialConfig.commentElsePrefix;\n }\n if (typeof partialConfig.locale === \"string\") {\n _config.locale = partialConfig.locale;\n }\n if (typeof partialConfig.debug === \"boolean\") {\n _config.debug = partialConfig.debug;\n }\n if (typeof partialConfig.enableMustache === \"boolean\") {\n _config.enableMustache = partialConfig.enableMustache;\n }\n if (typeof partialConfig.enableDirectionalInitialSync === \"boolean\") {\n _config.enableDirectionalInitialSync = partialConfig.enableDirectionalInitialSync;\n }\n if (typeof partialConfig.enablePropagationContext === \"boolean\") {\n _config.enablePropagationContext = partialConfig.enablePropagationContext;\n }\n if (typeof partialConfig.enableContractAnalyzer === \"boolean\") {\n _config.enableContractAnalyzer = partialConfig.enableContractAnalyzer;\n }\n if (typeof partialConfig.sameValueGuard === \"boolean\") {\n _config.sameValueGuard = partialConfig.sameValueGuard;\n }\n}\n","/**\n * core/filterRegistry.ts — フィルタ実関数の登録簿(設計案 §4、要件 D16)。\n *\n * 文法(`path|filter(args)` の解析)は core に残り、**実関数は登録簿から束縛計画の段で引く**。\n * 解析の段は名前と引数しか作らない(`bindTextParser/parseFilters.ts`)ので、パーサだけを使う\n * tooling(`@wcstack/state/parser`)はフィルタの実装を 1 バイトも引き込まない。\n *\n * 書式フィルタ群(`uc` / `date` / `round` …)は `features/formats` が install で登録する。\n * core が自前で持つのは、エンジン自身が差し込む `not` だけ(`if` / `else` の反転 —\n * structural/notFilter.ts)。未知のフィルタは束縛計画の段で名指しで落ちる(従来は解析時)。\n */\nimport { didYouMean, LINT_HINT } from \"../errorGuidance\";\nimport type { FilterFn, FilterIOType, FilterWithOptions } from \"../filters/types\";\nimport { raiseError } from \"../raiseError\";\n\n/** `options` を受け取って実関数を返す工場(`filters/types.ts` の `FilterWithOptions` の要素) */\nexport type FilterFactory = (options?: string[], literals?: readonly unknown[]) => FilterFn;\n\n/**\n * エンジン自身が差し込むフィルタ。`if` / `else` の分岐は `not` を付けた束縛として組み立てられる\n * ので、`features/formats` の無いページでも必ず要る。\n */\nconst CORE_FILTERS: Record<string, FilterFactory> = {\n not: () => (value: unknown): boolean => !value,\n};\n\nconst registries: Record<FilterIOType, Map<string, FilterFactory>> = {\n input: new Map<string, FilterFactory>(),\n output: new Map<string, FilterFactory>(),\n};\n\n/** 受け付ける引数の個数 [最少, 最多]。登録した機能が渡したものだけ(要件 B3) */\nconst aritiesByIOType: Record<FilterIOType, Map<string, readonly [number, number]>> = {\n input: new Map<string, readonly [number, number]>(),\n output: new Map<string, readonly [number, number]>(),\n};\n\n/** 旧名 → 正式名(要件 B12)。解決・引数の個数は正式名で引く。登録した機能が渡したものだけ */\nconst aliasesByIOType: Record<FilterIOType, Map<string, string>> = {\n input: new Map<string, string>(),\n output: new Map<string, string>(),\n};\n\n/** 名前 + 引数 + 入出力ごとに解決済みの実関数(解決は 1 回だけ) */\nconst resolvedByKey = new Map<string, FilterFn>();\n\n/** 機能の install が呼ぶ(冪等 — 同じ名前は置き換え)。hot path には触れない */\nexport function registerFilters(\n filterIOType: FilterIOType,\n filters: FilterWithOptions,\n arity?: Readonly<Record<string, readonly [number, number]>>,\n aliases?: Readonly<Record<string, string>>,\n): void {\n const registry = registries[filterIOType];\n const arities = aritiesByIOType[filterIOType];\n for (const name of Object.keys(filters)) {\n registry.set(name, filters[name] as FilterFactory);\n const bounds = arity?.[name];\n if (typeof bounds === \"undefined\") {\n arities.delete(name);\n } else {\n arities.set(name, bounds);\n }\n }\n for (const alias of Object.keys(aliases ?? {})) {\n aliasesByIOType[filterIOType].set(alias, aliases![alias]);\n }\n // 登録が変われば解決済みの答えも変わりうる(同じページで 2 回 install することは無いが、\n // テストと tooling は登録簿を入れ替える)\n resolvedByKey.clear();\n}\n\n/** 登録済みの名前(core のものを含む)。診断の did-you-mean が読む */\nexport function knownFilterNames(filterIOType: FilterIOType): string[] {\n return [...new Set([...Object.keys(CORE_FILTERS), ...registries[filterIOType].keys()])];\n}\n\n/** 解決済みの答えを捨てる(tooling: `@wcstack/state/parser` の clearParserCaches) */\nexport function clearFilterResolutionCache(): void {\n resolvedByKey.clear();\n}\n\n/**\n * 実関数を引く(束縛計画の段)。未知のフィルタはここで落ちる — 解析の段では落とさない。\n * 文言は lint の `wcs/filter-unknown` と同じ語彙・同じ did-you-mean 規準(三面同語彙)。\n */\nexport function resolveFilterFn(\n filterName: string,\n args: string[],\n filterIOType: FilterIOType,\n literals: readonly unknown[] = args,\n): FilterFn {\n // 引数は型付きの値の構造のまま鍵にする(`join('a,b')` と `join(a,b)` — 要件 B3、`eq(1)` と\n // `eq('1')` — 要件 B9 を取り違えない)\n const key = `${filterName}${JSON.stringify(literals)}:${filterIOType}`;\n const resolved = resolvedByKey.get(key);\n if (typeof resolved !== \"undefined\") {\n return resolved;\n }\n // 旧名(`uc` / `fix` …)は正式名で引く — 3.x の間のエイリアス(要件 B12、4.0 で外す)\n const canonical = aliasesByIOType[filterIOType].get(filterName) ?? filterName;\n const factory = registries[filterIOType].get(canonical) ?? CORE_FILTERS[canonical];\n if (typeof factory === \"undefined\") {\n raiseError(`[wcs/filter-unknown] filter not found: ${filterName}.${didYouMean(filterName, knownFilterNames(filterIOType))}${LINT_HINT}`);\n }\n const bounds = aritiesByIOType[filterIOType].get(canonical);\n if (typeof bounds !== \"undefined\" && (args.length < bounds[0] || args.length > bounds[1])) {\n // lint の wcs/filter-arity と同じ語彙\n raiseError(args.length < bounds[0]\n ? `[wcs/filter-arity] filter \"${filterName}\" requires at least ${bounds[0]} argument(s) (${args.length} given).${LINT_HINT}`\n : `[wcs/filter-arity] filter \"${filterName}\" accepts at most ${bounds[1]} argument(s) (${args.length} given).${LINT_HINT}`);\n }\n const filterFn = factory(args, literals);\n resolvedByKey.set(key, filterFn);\n return filterFn;\n}\n"],"names":["SSR_SNAPSHOT_BUILDER_KEY","Symbol","for","isOrchestratedSsr","html","document","documentElement","getAttribute","inSsr","hasAttribute","_config","bindAttributeName","commentTextPrefix","commentForPrefix","commentIfPrefix","commentElseIfPrefix","commentElsePrefix","tagNames","state","ssr","locale","debug","enableMustache","enableDirectionalInitialSync","enablePropagationContext","enableContractAnalyzer","sameValueGuard","config","getConfig","setConfig","partialConfig","Object","assign","CORE_FILTERS","not","value","registries","input","Map","output","aritiesByIOType","aliasesByIOType","resolvedByKey","registerFilters","filterIOType","filters","arity","aliases","registry","arities","name","keys","set","bounds","delete","alias","clear","resolveFilterFn","filterName","args","literals","key","JSON","stringify","resolved","get","canonical","factory","raiseError","didYouMean","Set","knownFilterNames","LINT_HINT","length","filterFn"],"mappings":"qDAwCO,MAAMA,EAA2BC,OAAOC,IAAI,wCC9BnCC,IACd,MAAMC,EAAOC,SAASC,gBACtB,QAAOF,GDmC6B,iBCnCtBA,EAAKG,aAAa,kBAClC,UAEgBC,IAOd,MAAMJ,EAAOC,SAASC,gBACtB,QAAOF,GAAOA,EAAKK,aAAa,kBAClC,CAsBA,MAAMC,EAA2B,CAC/BC,kBAAmB,WACnBC,kBAAmB,WACnBC,iBAAkB,UAClBC,gBAAiB,SACjBC,oBAAqB,aACrBC,kBAAmB,WACnBC,SAAU,CACRC,MAAO,YACPC,IAAK,WAEPC,OAAQ,KACRC,OAAO,EACPC,gBAAgB,EAChBC,8BAA8B,EAC9BC,0BAA0B,EAM1BC,w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AAMM,KAAQnB,OAAOoB,KAAKN,GAAU,CACvCG,EAASI,IAAIF,EAAML,EAAQK,IAC3B,MAAMG,EAASP,IAAQI,QACD,IAAXG,EACTJ,EAAQK,OAAOJ,GAEfD,EAAQG,IAAIF,EAAMG,EAEtB,CACA,IAAK,MAAME,KAASxB,OAAOoB,KAAKJ,GAAW,CAAA,GACzCN,EAAgBG,GAAcQ,IAAIG,EAAOR,EAASQ,IAIpDb,EAAcc,OAChB,CAgBM,SAAUC,EACdC,EACAC,EACAf,EACAgB,EAA+BD,GAI/B,MAAME,EAAM,GAAGH,IAAaI,KAAKC,UAAUH,MAAahB,IAClDoB,EAAWtB,EAAcuB,IAAIJ,GACnC,QAAwB,IAAbG,EACT,OAAOA,EAGT,MAAME,EAAYzB,EAAgBG,GAAcqB,IAAIP,IAAeA,EAC7DS,EAAU/B,EAAWQ,GAAcqB,IAAIC,IAAcjC,EAAaiC,QACjD,IAAZC,GACTC,EAAW,0CAA0CV,KAAcW,EAAWX,EA9B5E,SAA2Bd,GAC/B,MAAO,IAAI,IAAI0B,IAAI,IAAIvC,OAAOoB,KAAKlB,MAAkBG,EAAWQ,GAAcO,SAChF,CA4B8FoB,CAAiB3B,MAAiB4B,KAE9H,MAAMnB,EAASb,EAAgBI,GAAcqB,IAAIC,QAC3B,IAAXb,IAA2BM,EAAKc,OAASpB,EAAO,IAAMM,EAAKc,OAASpB,EAAO,KAEpFe,EAAWT,EAAKc,OAASpB,EAAO,GAC5B,8BAA8BK,wBAAiCL,EAAO,mBAAmBM,EAAKc,iBAAiBD,IAC/G,8BAA8Bd,sBAA+BL,EAAO,mBAAmBM,EAAKc,iBAAiBD,KAEnH,MAAME,EAAWP,EAAQR,EAAMC,GAE/B,OADAlB,EAAcU,IAAIS,EAAKa,GAChBA,CACT"}
@@ -1,2 +1,2 @@
1
- import{D as t,L as e,g as n,W as r,R as o}from"./pathDiagnostics.js";import{aS as s}from"./binder.js";import{r as a}from"./errorGuidance.js";let i=0;const c=["$watch","$streams","$scan","$listKeys","$updatedCallback","$commandTokens","$eventTokens","$on","$recursion","$errorCallback"],l=new Set;function u(t){const e=c.filter(e=>void 0!==t.stateObject[e]);for(const n of t.getterKeys)-1!==n.indexOf(o)&&e.push(`"${n}"`);if(0===e.length)return;const n=`${t.component.tagName.toLowerCase()}|${t.stateProp}`;l.has(n)||(l.add(n),console.warn(`[@wcstack/state] [wcs/mount-dollar-declaration] <${n.split("|")[0]}>.${t.stateProp} declares ${e.join(", ")}, which mounted components do not run. Declare them on the root state instead (a volume <wcs-state mount="..."> can host $watch / $listKeys / $updatedCallback; $recursion and "**" getters expand against the root tree). See docs/state-mount-design.md §4-6.`))}function d(t,e){const n=t.stateObject[e];if("function"==typeof n)try{const r=t.component[t.stateProp],o=n.call(r);o instanceof Promise&&o.catch(n=>{console.error(`[@wcstack/state] mounted <${t.component.tagName.toLowerCase()}> ${e} failed.`,n)})}catch(n){console.error(`[@wcstack/state] mounted <${t.component.tagName.toLowerCase()}> ${e} failed.`,n)}}function f(n,r,o,s,c,l=new Set){0===o.length&&a(`Cannot build a mount record without host bindings for "${r}".`);const u=[],d=new Set;let f=null;for(const n of o){const r=n.propSegments.slice(1),o=r.join(t);d.has(o)&&a("Duplicate mapping rule for web component."),d.add(o);const s={innerSegments:r,outerPathInfo:n.statePathInfo,readonly:!0===n.propModifiers?.includes(e)};u.push(s),0===r.length&&(f=s)}u.sort((t,e)=>e.innerSegments.length-t.innerSegments.length);const h=++i,m=`#m${h}`,{getterKeys:p,setterKeys:g}=function(t){const e=new Set,n=new Set,r=Object.getOwnPropertyDescriptors(t);for(const[t,o]of Object.entries(r))"function"==typeof o.get&&e.add(t),"function"==typeof o.set&&n.add(t);return{getterKeys:e,setterKeys:n}}(c),y=new Set;for(const t of u)t.innerSegments.length>0&&y.add(t.innerSegments[0]);const w={};for(const t of Object.keys(c))t.startsWith("$")||p.has(t)||g.has(t)||"function"!=typeof c[t]&&(l.has(t)||y.has(t)||(w[t]=c[t]));return{id:h,marker:m,component:n,stateProp:r,parentStateElement:s,entries:u,rootEntry:f,delta:null===f?0:f.outerPathInfo.wildcardCount,markerBasePath:null===f?m:f.outerPathInfo.path+t+m,stateObject:c,getterKeys:p,setterKeys:g,injectedKeys:l,mappedKeys:y,privateSnapshot:w,accessorBySuffixByMarkerParent:new Map,indexShiftByLoopElementPath:new Map,addedGetterPaths:new Set,exports:new Map}}function h(e){const n=e.indexOf(t);return-1===n?e:e.slice(0,n)}function m(t,e){if(e.length>t.length)return!1;for(let n=0;n<e.length;n++)if(t[n]!==e[n])return!1;return!0}function p(e,n){for(const r of e.entries)if(m(n,r.innerSegments)){const e=n.slice(r.innerSegments.length);return 0===e.length?r.outerPathInfo.path:r.outerPathInfo.path+t+e.join(t)}return null}function g(e,n){return e.markerBasePath+t+n}function y(e,r,o,s){let a=e.accessorBySuffixByMarkerParent.get(r);void 0===a&&(a=new Map,e.accessorBySuffixByMarkerParent.set(r,a));const i=r+t+o;a.set(o,{accessorName:s,indexShift:n(i).wildcardCount-n(s).wildcardCount}),e.getterKeys.has(s)&&(e.parentStateElement.getterPaths?.add(i),e.addedGetterPaths.add(i))}function w(t,e){return!t.injectedKeys.has(e)&&!t.mappedKeys.has(e)&&("function"==typeof t.stateObject[e]&&!t.getterKeys.has(e)||Object.prototype.hasOwnProperty.call(t.stateObject,e)&&!t.getterKeys.has(e)&&!t.setterKeys.has(e))}function $(e,n){return`Path "${n}" in <${e.component.tagName.toLowerCase()}> does not resolve: it is not an own key of the component state and no mount entry covers it (mounted prefixes: ${e.entries.filter(t=>t.innerSegments.length>0).map(e=>e.innerSegments.join(t)).join(", ")}). Mount it from the host ("${e.stateProp}: path" / "${e.stateProp}.${h(n)}: path") or declare the key on the component state.`}const P=/^\$(\d+)$/;function k(e,n){const r=n[0];if("$"===r||"#"===r)return null;if(e.getterKeys.has(n)||e.setterKeys.has(n))return null;const o=h(n);if(e.getterKeys.has(o)||e.setterKeys.has(o)||w(e,o))return null;const s=function(t,e){for(const n of t.entries)if(m(e,n.innerSegments))return n;return null}(e,n.split(t));return null!==s&&s.readonly?s:null}function S(n,r){const o=k(n,r);if(null!==o){const s=0===o.innerSegments.length?"":t+o.innerSegments.join(t);a(`[wcs/mount-readonly] <${n.component.tagName.toLowerCase()}> cannot write "${r}": it is mounted read-only ("${n.stateProp}${s}#${e}: ${o.outerPathInfo.path}"). Write it on the host, or drop #${e} from the mount.`)}return v(n,r)}function v(e,n){const o=n[0];if("$"===o||"#"===o)return n;if(e.getterKeys.has(n)||e.setterKeys.has(n))return function(e,n){const o=n.split(t);let s=-1;for(let t=o.length-1;t>=0;t--)if(o[t]===r){s=t;break}if(-1===s)return y(e,e.markerBasePath,n,n),g(e,n);if(w(e,o[0]))return y(e,e.markerBasePath,n,n),g(e,n);const i=o.slice(0,s+1),c=o.slice(s+1),l=p(e,i);null===l&&a($(e,n)),0===c.length&&a(`Wildcard-terminal accessor "${n}" on mounted <${e.component.tagName.toLowerCase()}> is not supported: it translates to a marker-terminal path where the mount overlay would shadow the accessor. Declare the row value as a getter on the host tree, or back it with a component-own array (a private key makes the whole path private).`);const u=l+t+e.marker;return y(e,u,c.join(t),n),u+t+c.join(t)}(e,n);const s=h(n);if(e.getterKeys.has(s)||e.setterKeys.has(s))return g(e,n);if(w(e,s))return g(e,n);const i=p(e,n.split(t));if(null!==i)return i;a($(e,n))}function b(o,s,a){let i;const c=P.exec(s.statePathName);if(null!==c){const t=function(t,e){if(void 0===e)return t.delta;const r=v(t,e);return n(r).wildcardCount-n(e).wildcardCount}(o,a);i=0===t?s.statePathName:`$${Number(c[1])+t}`}else if(i=v(o,s.statePathName),"for"===s.bindingType){const e=n(i).wildcardCount-s.statePathInfo.wildcardCount;o.indexShiftByLoopElementPath.set(i+t+r,e)}const l=s.propModifiers,u=null===c&&Array.isArray(l)&&!l.includes(e)&&null!==k(o,s.statePathName);return i!==s.statePathName||u?{...s,statePathName:i,statePathInfo:n(i),...u?{propModifiers:[...l,e]}:{}}:s}function K(e,n){const r=n.lastIndexOf("#");if(-1===r)return e.delta;const o=n.indexOf(t,r);if((-1===o?n.slice(r):n.slice(r,o))!==e.marker)return e.delta;const s=-1===o?n:n.slice(0,o),a=-1===o?"":n.slice(o+1),i=e.accessorBySuffixByMarkerParent.get(s)?.get(a);return void 0!==i?i.indexShift:e.delta}function j(t,e,r,o,s){if(void 0===o)return;const i=n(r).wildcardCount-n(e).wildcardCount;return 0===i?o:(s.length<i&&a(`Cannot resolve "${e}" from this mount: the mounted prefix has ${i} wildcard(s) but the host context provides only ${s.length} index(es).`),[...s.slice(0,i),...o])}const x=new WeakMap,M=new WeakMap;function C(t,e){return M.get(t)?.get(e)??null}const O=new WeakMap;const N=new FinalizationRegistry(function(t){const e=t.byMarker.get(t.marker);if(void 0!==e&&void 0===e.deref()&&t.byMarker.delete(t.marker),void 0!==t.getterPaths)for(const e of t.addedGetterPaths)t.getterPaths.delete(e)}),B=new WeakMap;function I(t){return B.get(t)??null}let E=!1;function L(t,e){E||(E=!0,s(t=>x.has(t)?t.host:null)),x.set(t,e),B.set(e,t);let n=O.get(e.parentStateElement);void 0===n&&(n=new Map,O.set(e.parentStateElement,n)),n.set(e.marker,new WeakRef(e));let r=M.get(e.component);void 0===r&&(r=new Map,M.set(e.component,r));const o=r.get(e.stateProp)!==e;r.set(e.stateProp,e),o&&N.register(e,{byMarker:n,marker:e.marker,getterPaths:e.parentStateElement.getterPaths,addedGetterPaths:e.addedGetterPaths}),e.parentStateElement.markHasMounts?.()}function W(t){return x.get(t)??null}function D(t,e){let n=t;for(;null!==n&&n!==e;){const t=x.get(n);if(void 0!==t)return t;n=n.parentNode}return x.get(e)??null}function G(t){const e=O.get(t);if(void 0===e)return[];const n=[];for(const t of e.values()){const e=t.deref();void 0!==e&&n.push(e)}return n}function R(t){const e=O.get(t);return void 0!==e&&e.size>0}function T(e,n){const r=n.lastIndexOf("#");if(-1===r)return null;const o=O.get(e);if(void 0===o)return null;const s=n.indexOf(t,r),a=-1===s?n.slice(r):n.slice(r,s),i=o.get(a);if(void 0===i)return null;const c=i.deref();return void 0===c?(o.delete(a),null):c}export{S as a,I as b,j as c,W as d,b as e,D as f,G as g,T as h,K as i,d as j,C as k,f as l,L as r,R as s,v as t,u as w};
1
+ import{D as t,j as e,g as n,W as r,a as o,o as s,R as a}from"./pathDiagnostics.js";import{aS as i}from"./binder.js";import{n as c}from"./declarationAliases.js";import{r as l}from"./errorGuidance.js";function u(t,e){if(e.length>t.length)return!1;for(let n=0;n<e.length;n++)if(t[n]!==e[n])return!1;return!0}function d(t,e){for(const n of t)if(u(e,n.innerSegments))return n;return null}function f(e,n){const r=n.slice(e.innerSegments.length);return 0===r.length?e.outerPathInfo.path:e.outerPathInfo.path+t+r.join(t)}let h=0;const m=["$watch",o,"$scan","$listKeys",s,"$commandTokens","$eventTokens","$on","$recursion","$errorCallback"],p=new Set;function g(t){const e=m.filter(e=>void 0!==t.stateObject[e]);for(const n of t.getterKeys)-1!==n.indexOf(a)&&e.push(`"${n}"`);if(0===e.length)return;const n=`${t.component.tagName.toLowerCase()}|${t.stateProp}`;p.has(n)||(p.add(n),console.warn(`[@wcstack/state] [wcs/mount-dollar-declaration] <${n.split("|")[0]}>.${t.stateProp} declares ${e.join(", ")}, which mounted components do not run. Declare them on the root state instead (a volume <wcs-state mount="..."> can host $watch / $listKeys / $updatedCallback; $recursion and "**" getters expand against the root tree). See docs/state-mount-design.md §4-6.`))}function y(t,e){const n=t.stateObject[e];if("function"==typeof n)try{const r=t.component[t.stateProp],o=n.call(r);o instanceof Promise&&o.catch(n=>{console.error(`[@wcstack/state] mounted <${t.component.tagName.toLowerCase()}> ${e} failed.`,n)})}catch(n){console.error(`[@wcstack/state] mounted <${t.component.tagName.toLowerCase()}> ${e} failed.`,n)}}function w(n,r,o,s,a,i=new Set){0===o.length&&l(`Cannot build a mount record without host bindings for "${r}".`),c(a);const u=[],d=new Set;let f=null;for(const n of o){const r=n.propSegments.slice(1),o=r.join(t);d.has(o)&&l("Duplicate mapping rule for web component."),d.add(o);const s={innerSegments:r,outerPathInfo:n.statePathInfo,readonly:!0===n.propModifiers?.includes(e)};u.push(s),0===r.length&&(f=s)}u.sort((t,e)=>e.innerSegments.length-t.innerSegments.length);const m=++h,p=`#m${m}`,{getterKeys:g,setterKeys:y}=function(t){const e=new Set,n=new Set,r=Object.getOwnPropertyDescriptors(t);for(const[t,o]of Object.entries(r))"function"==typeof o.get&&e.add(t),"function"==typeof o.set&&n.add(t);return{getterKeys:e,setterKeys:n}}(a),w=new Set;for(const t of u)t.innerSegments.length>0&&w.add(t.innerSegments[0]);const $={};for(const t of Object.keys(a))t.startsWith("$")||g.has(t)||y.has(t)||"function"!=typeof a[t]&&(i.has(t)||w.has(t)||($[t]=a[t]));return{id:m,marker:p,component:n,stateProp:r,parentStateElement:s,entries:u,rootEntry:f,delta:null===f?0:f.outerPathInfo.wildcardCount,markerBasePath:null===f?p:f.outerPathInfo.path+t+p,stateObject:a,getterKeys:g,setterKeys:y,injectedKeys:i,mappedKeys:w,privateSnapshot:$,accessorBySuffixByMarkerParent:new Map,indexShiftByLoopElementPath:new Map,addedGetterPaths:new Set,exports:new Map}}function $(e){const n=e.indexOf(t);return-1===n?e:e.slice(0,n)}function P(t,e){const n=d(t.entries,e);return null===n?null:f(n,e)}function k(e,n){return e.markerBasePath+t+n}function S(e,r,o,s){let a=e.accessorBySuffixByMarkerParent.get(r);void 0===a&&(a=new Map,e.accessorBySuffixByMarkerParent.set(r,a));const i=r+t+o;a.set(o,{accessorName:s,indexShift:n(i).wildcardCount-n(s).wildcardCount}),e.getterKeys.has(s)&&(e.parentStateElement.getterPaths?.add(i),e.addedGetterPaths.add(i))}function v(t,e){return!t.injectedKeys.has(e)&&!t.mappedKeys.has(e)&&("function"==typeof t.stateObject[e]&&!t.getterKeys.has(e)||Object.prototype.hasOwnProperty.call(t.stateObject,e)&&!t.getterKeys.has(e)&&!t.setterKeys.has(e))}function j(e,n){return`Path "${n}" in <${e.component.tagName.toLowerCase()}> does not resolve: it is not an own key of the component state and no mount entry covers it (mounted prefixes: ${e.entries.filter(t=>t.innerSegments.length>0).map(e=>e.innerSegments.join(t)).join(", ")}). Mount it from the host ("${e.stateProp}: path" / "${e.stateProp}.${$(n)}: path") or declare the key on the component state.`}const K=/^\$(\d+)$/;function b(e,n){const r=n[0];if("$"===r||"#"===r)return null;if(e.getterKeys.has(n)||e.setterKeys.has(n))return null;const o=$(n);if(e.getterKeys.has(o)||e.setterKeys.has(o)||v(e,o))return null;const s=function(t,e){return d(t.entries,e)}(e,n.split(t));return null!==s&&s.readonly?s:null}function x(n,r){const o=b(n,r);if(null!==o){const s=0===o.innerSegments.length?"":t+o.innerSegments.join(t);l(`[wcs/mount-readonly] <${n.component.tagName.toLowerCase()}> cannot write "${r}": it is mounted read-only ("${n.stateProp}${s}#${e}: ${o.outerPathInfo.path}"). Write it on the host, or drop #${e} from the mount.`)}return M(n,r)}function M(e,n){const o=n[0];if("$"===o||"#"===o)return n;if(e.getterKeys.has(n)||e.setterKeys.has(n))return function(e,n){const o=n.split(t);let s=-1;for(let t=o.length-1;t>=0;t--)if(o[t]===r){s=t;break}if(-1===s)return S(e,e.markerBasePath,n,n),k(e,n);if(v(e,o[0]))return S(e,e.markerBasePath,n,n),k(e,n);const a=o.slice(0,s+1),i=o.slice(s+1),c=P(e,a);null===c&&l(j(e,n)),0===i.length&&l(`Wildcard-terminal accessor "${n}" on mounted <${e.component.tagName.toLowerCase()}> is not supported: it translates to a marker-terminal path where the mount overlay would shadow the accessor. Declare the row value as a getter on the host tree, or back it with a component-own array (a private key makes the whole path private).`);const u=c+t+e.marker;return S(e,u,i.join(t),n),u+t+i.join(t)}(e,n);const s=$(n);if(e.getterKeys.has(s)||e.setterKeys.has(s))return k(e,n);if(v(e,s))return k(e,n);const a=P(e,n.split(t));if(null!==a)return a;l(j(e,n))}function C(o,s,a){let i;const c=K.exec(s.statePathName);if(null!==c){const t=function(t,e){if(void 0===e)return t.delta;const r=M(t,e);return n(r).wildcardCount-n(e).wildcardCount}(o,a);i=0===t?s.statePathName:`$${Number(c[1])+t}`}else if(i=M(o,s.statePathName),"for"===s.bindingType){const e=n(i).wildcardCount-s.statePathInfo.wildcardCount;o.indexShiftByLoopElementPath.set(i+t+r,e)}const l=s.propModifiers,u=null===c&&Array.isArray(l)&&!l.includes(e)&&null!==b(o,s.statePathName);return i!==s.statePathName||u?{...s,statePathName:i,statePathInfo:n(i),...u?{propModifiers:[...l,e]}:{}}:s}function O(e,n){const r=n.lastIndexOf("#");if(-1===r)return e.delta;const o=n.indexOf(t,r);if((-1===o?n.slice(r):n.slice(r,o))!==e.marker)return e.delta;const s=-1===o?n:n.slice(0,o),a=-1===o?"":n.slice(o+1),i=e.accessorBySuffixByMarkerParent.get(s)?.get(a);return void 0!==i?i.indexShift:e.delta}function N(t,e,r,o,s){if(void 0===o)return;const a=n(r).wildcardCount-n(e).wildcardCount;return 0===a?o:(s.length<a&&l(`Cannot resolve "${e}" from this mount: the mounted prefix has ${a} wildcard(s) but the host context provides only ${s.length} index(es).`),[...s.slice(0,a),...o])}const B=new WeakMap,I=new WeakMap;function E(t,e){return I.get(t)?.get(e)??null}const W=new WeakMap;const L=new FinalizationRegistry(function(t){const e=t.byMarker.get(t.marker);if(void 0!==e&&void 0===e.deref()&&t.byMarker.delete(t.marker),void 0!==t.getterPaths)for(const e of t.addedGetterPaths)t.getterPaths.delete(e)}),D=new WeakMap;function G(t){return D.get(t)??null}let A=!1;function R(t,e){A||(A=!0,i(t=>B.has(t)?t.host:null)),B.set(t,e),D.set(e,t);let n=W.get(e.parentStateElement);void 0===n&&(n=new Map,W.set(e.parentStateElement,n)),n.set(e.marker,new WeakRef(e));let r=I.get(e.component);void 0===r&&(r=new Map,I.set(e.component,r));const o=r.get(e.stateProp)!==e;r.set(e.stateProp,e),o&&L.register(e,{byMarker:n,marker:e.marker,getterPaths:e.parentStateElement.getterPaths,addedGetterPaths:e.addedGetterPaths}),e.parentStateElement.markHasMounts?.()}function T(t){return B.get(t)??null}function z(t,e){let n=t;for(;null!==n&&n!==e;){const t=B.get(n);if(void 0!==t)return t;n=n.parentNode}return B.get(e)??null}function F(t){const e=W.get(t);if(void 0===e)return[];const n=[];for(const t of e.values()){const e=t.deref();void 0!==e&&n.push(e)}return n}function H(t){const e=W.get(t);return void 0!==e&&e.size>0}function q(e,n){const r=n.lastIndexOf("#");if(-1===r)return null;const o=W.get(e);if(void 0===o)return null;const s=n.indexOf(t,r),a=-1===s?n.slice(r):n.slice(r,s),i=o.get(a);if(void 0===i)return null;const c=i.deref();return void 0===c?(o.delete(a),null):c}export{M as a,x as b,N as c,G as d,T as e,d as f,F as g,C as h,z as i,q as j,O as k,y as l,E as m,w as n,R as r,H as s,f as t,g as w};
2
2
  //# sourceMappingURL=mount.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mount.js","sources":["../../../../../src/webComponent/mount.ts"],"sourcesContent":["import { getPathInfo } from \"../address/PathInfo\";\nimport { IPathInfo } from \"../address/types\";\nimport { IStateElement } from \"../components/types\";\nimport { setMountedScopeHost } from \"../list/loopContextByNode\";\nimport { DELIMITER, MODIFIER_READONLY, RECURSION_WILDCARD, WILDCARD } from \"../define\";\nimport { raiseError } from \"../raiseError\";\nimport { IBindingInfo } from \"../types\";\n\n/**\n * webComponent/mount.ts — マウント記録(Phase 2・docs/state-mount-design.md §5、impl-plan §3-0)。\n *\n * v2 の不変条件「マウントされたコンポーネントのバインディングは、その位置にテンプレートを\n * 展開してパスに接頭辞を付けたものと区別できない」を、**バインディングの変換**として実装する。\n * マウントされたスコープのバインディングは登録時にここの `translateInnerPath` で\n * 親ツリーの絶対パスへ書き換えられ、以後は台帳・依存グラフ・キャッシュ・LIS・プールの\n * どれから見ても「親スコープにインラインで書かれた binding」と同一になる。\n *\n * 例外は私有キーと getter / メソッド(展開したテンプレートには存在しないもの)で、\n * これらは **予約セグメント**(D20・`#m<id>` — `#` はパス文法で書けない)を挟んだ\n * 絶対アドレスに載る。ツリーのアドレスと構造的に衝突せず、親 handler のオーバーレイ\n * dispatch はマーカーを含む読み書きだけに掛かる。D10(スコープ外から見えない)は\n * このアドレス空間の帰結になる。\n *\n * マーカーの位置は「ワイルドカード接頭辞の直後」:\n * - 単純な getter / 私有キー(`display` / `editing`)→ `<rootOuter>.#m.display`\n * (ルートエントリが無い部分マウントのみの形では `#m.display`)\n * - ツリーのリストの上のワイルドカード getter(`get \"children.*.label\"`、`state: group`)\n * → `group.children.*.#m.label` — ワイルドカード親がツリーのリストと一致するので、\n * ループ文脈の解決(indexByWildcardPath)と listIndex の arity が素の getter と同じに保たれる\n * - 私有配列の上のワイルドカード getter(`state = { drafts: [] }` + `get \"drafts.*.title\"`)\n * → `<rootOuter>.#m.drafts.*.title` — 配列ごと私有側に閉じる\n */\n\nexport interface IMountEntry {\n /** 内側接頭辞のセグメント(ルートエントリは 0 個 — あらゆる内側パスに一致する) */\n readonly innerSegments: readonly string[];\n readonly outerPathInfo: IPathInfo;\n /**\n * ホストが `#ro` を付けたか(`state#ro: user` / `state.name#ro: user.name`、要件 B14 ①)。\n * 真なら、コンポーネント側からこのエントリを通るツリーへの書き込みは拒否される(ホスト自身の書き込みは止めない)。\n */\n readonly readonly: boolean;\n}\n\nexport interface IMountRecord {\n readonly id: number;\n /** D20 の予約セグメント(`#m<id>`) */\n readonly marker: string;\n readonly component: Element;\n readonly stateProp: string;\n readonly parentStateElement: IStateElement;\n /** マウント表(内側接頭辞の長い順 — 最長接頭辞一致は先頭ヒットで決まる) */\n readonly entries: readonly IMountEntry[];\n /** ルートエントリ(`state: path`)。無ければ null(部分マウントのみ) */\n readonly rootEntry: IMountEntry | null;\n /** Δ = ルート接頭辞のワイルドカード数(`$n` のスコープ補正が読む唯一の値) */\n readonly delta: number;\n /** 私有キー・単純 getter を載せるマーカーパス(`users.*.#m3` / `#m3`) */\n readonly markerBasePath: string;\n /** 作者の state オブジェクト(私有キー・getter・メソッドの実体) */\n readonly stateObject: Record<string, any>;\n readonly getterKeys: ReadonlySet<string>;\n readonly setterKeys: ReadonlySet<string>;\n /**\n * 完了前の親の初期適用(積み)が作者のオブジェクトに**注入した**キー\n * (webComponent/preCompletionWrites.ts)。作者のものではないので私有にしない\n * (v2 は厳格 R1: 作者が宣言した own data key は部分マウントに覆われていても私有 —\n * 設計書 §4-1 規則 2。1.x の「マッピングが勝つ」からの反転は D19 が予告済み)。\n */\n readonly injectedKeys: ReadonlySet<string>;\n /** 部分エントリが明示したキー(先頭セグメント)。同名の own data key より優先する(要件 B14 ②) */\n readonly mappedKeys: ReadonlySet<string>;\n /**\n * 私有データの初期スナップショット(own data key の浅い複製・D21)。\n * マウントインスタンス(listIndex)ごとの私有オブジェクトはここから複製される。\n */\n readonly privateSnapshot: Readonly<Record<string, unknown>>;\n /**\n * マーカーの親パス(翻訳後) → { 接尾キー → 作者のアクセサ情報 }。\n * `display` は markerBase の親に `display → display`、\n * ワイルドカード getter `\"children.*.label\"` は `group.children.*` に `label → children.*.label`。\n * `indexShift` は翻訳で増えたワイルドカード数(アクセサ内の `$n` のスコープ補正が読む)。\n * translateInnerPath のマーカー化で遅延登録され、オーバーレイの get とトラップが引く。\n */\n readonly accessorBySuffixByMarkerParent: Map<string, Map<string, IAccessorEntry>>;\n /**\n * 翻訳された `for` のループ要素パス(`groups.*.children.*`)→ 翻訳で増えた\n * ワイルドカード数。イベントハンドラの「スコープ相対の添字」(§4-4 / P2-9)が\n * 引く — 添字列の末尾から (総数 − shift) 本だけが作者の見える添字。\n * translateParsedForMount が for の翻訳時に埋める。\n */\n readonly indexShiftByLoopElementPath: Map<string, number>;\n /**\n * この記録が親の getterPaths に追加したマーカーパス(recordAccessorSuffix)。\n * 記録の恒久破棄時に cleanupCollectedMountRecord が親から回収する。\n * record の外の消費者(FinalizationRegistry の held 値)も参照するため、\n * record 本体が回収された後も held 経由で読める独立オブジェクトにしてある。\n */\n readonly addedGetterPaths: Set<string>;\n /**\n * 公開 getter(docs/state-overlay-export-design.md X2 / X3): 公開パス(マーカー無し・\n * `users.*.display`)→ マーカー親パス・接尾キー・マーカーパス。registerExports が\n * 初回登録で getter / setter キーから作る(翻訳できないアクセサは載らない)。\n */\n readonly exports: Map<string, IExportEntry>;\n}\n\nexport interface IExportEntry {\n /** マーカーで終わるパス(`users.*.#m7` — overlay.ts の「マーカー親」。accessorBySuffixByMarkerParent の鍵) */\n readonly markerTerminalPath: string;\n readonly suffix: string;\n readonly markerPath: string;\n readonly exportedPath: string;\n}\n\nexport interface IAccessorEntry {\n readonly accessorName: string;\n readonly indexShift: number;\n}\n\nlet nextMountId = 0;\n\nconst MOUNT_DOLLAR_DECLARATIONS = [\n \"$watch\", \"$streams\", \"$scan\", \"$listKeys\", \"$updatedCallback\", \"$commandTokens\", \"$eventTokens\", \"$on\",\n // $errorCallback もルート専用(要件 B11 — 以前は無言で無視していた)\n \"$recursion\", \"$errorCallback\",\n] as const;\nconst dollarDeclarationWarned = new Set<string>();\n\n/** テスト用: 宣言 warn の 1 回性台帳を空にする。 */\nexport function clearMountDollarWarnsForTesting(): void {\n dollarDeclarationWarned.clear();\n}\n\n/**\n * マウントされたコンポーネントは宣言面(`$watch` / `$streams` / `$listKeys` /\n * `$updatedCallback` / `$commandTokens` / `$eventTokens` / `$on`)を実行しない\n * (v1 の mapped も同じ — innerState が `$` を遮っていた)。無言に捨てず、\n * (tag, prop) につき 1 回だけ「ルート(または対応する宣言はボリューム)に宣言する」\n * 誘導を出す。テンプレート側の `$command.*` の**参照**(バインディングのパス)は\n * ルート宣言のトークンに解決される(`$` 頭のパスは翻訳しない — translateInnerPath)。\n * `$connectedCallback` / `$disconnectedCallback` / `$stateReadyCallback` は要素の\n * ライフサイクルとしてスコープごとに残る(設計書 §4-6)。\n */\nexport function warnMountedDollarDeclarations(record: IMountRecord): void {\n const declared: string[] = MOUNT_DOLLAR_DECLARATIONS.filter(\n (name) => typeof (record.stateObject as Record<string, unknown>)[name] !== \"undefined\",\n );\n // `**` getter(`get \"node.**.total\"()`)も同じ扱い。`markerizeAccessorPath` は `*` セグメントしか\n // 探さないので `**` を含むキーは私有アンカーに落ち、参照されないまま永久に登録されない\n // (ボリュームは接ぎ木前に拒否し、`$recursion` はこの誘導が出るのに、`**` getter だけが\n // 無言だった — 第 3 サイクルのレビューで実測)。\n for (const accessor of record.getterKeys) {\n if (accessor.indexOf(RECURSION_WILDCARD) !== -1) {\n declared.push(`\"${accessor}\"`);\n }\n }\n if (declared.length === 0) {\n return;\n }\n const key = `${record.component.tagName.toLowerCase()}|${record.stateProp}`;\n if (dollarDeclarationWarned.has(key)) {\n return;\n }\n dollarDeclarationWarned.add(key);\n console.warn(\n `[@wcstack/state] [wcs/mount-dollar-declaration] <${key.split(\"|\")[0]}>.${record.stateProp} declares ` +\n `${declared.join(\", \")}, which mounted components do not run. Declare them on the root state instead ` +\n `(a volume <wcs-state mount=\"...\"> can host $watch / $listKeys / $updatedCallback; $recursion and ` +\n `\"**\" getters expand against the root tree). See docs/state-mount-design.md §4-6.`,\n );\n}\n\n/**\n * マウントされたコンポーネントのライフサイクル呼び出し(`$connectedCallback` /\n * `$disconnectedCallback`)。`this` は公開 chroot(`element[stateProp]`)。\n * 例外・reject は 1 コンポーネントに閉じる(切断時は親も切断中でありうる)。\n */\nexport function callMountLifecycleCallback(record: IMountRecord, name: string): void {\n const callback = (record.stateObject as Record<string, unknown>)[name];\n if (typeof callback !== \"function\") {\n return;\n }\n try {\n const chroot = (record.component as unknown as Record<string, unknown>)[record.stateProp];\n const result = (callback as (this: unknown) => unknown).call(chroot);\n if (result instanceof Promise) {\n result.catch((error) => {\n console.error(`[@wcstack/state] mounted <${record.component.tagName.toLowerCase()}> ${name} failed.`, error);\n });\n }\n } catch (error) {\n console.error(`[@wcstack/state] mounted <${record.component.tagName.toLowerCase()}> ${name} failed.`, error);\n }\n}\n\n/** テスト用: マーカー id を初期化する(マーカー文字列の安定化) */\nexport function resetMountIdForTesting(): void {\n nextMountId = 0;\n}\n\nfunction collectAccessorKeys(stateObject: Record<string, any>): { getterKeys: Set<string>, setterKeys: Set<string> } {\n const getterKeys = new Set<string>();\n const setterKeys = new Set<string>();\n const descriptors = Object.getOwnPropertyDescriptors(stateObject);\n for (const [key, descriptor] of Object.entries(descriptors)) {\n if (typeof descriptor.get === \"function\") getterKeys.add(key);\n if (typeof descriptor.set === \"function\") setterKeys.add(key);\n }\n return { getterKeys, setterKeys };\n}\n\n/**\n * ホストの `state[.sub]: path` バインディング群からマウント記録を組む。\n * `bindings` は propSegments[0] === stateProp で選別済みであること\n * (bindWebComponent が v1 の buildPrimaryMappingRule に渡すものと同じ集合)。\n */\nexport function buildMountRecord(\n component: Element,\n stateProp: string,\n bindings: readonly IBindingInfo[],\n parentStateElement: IStateElement,\n stateObject: Record<string, any>,\n injectedKeys: ReadonlySet<string> = new Set<string>(),\n): IMountRecord {\n if (bindings.length === 0) {\n raiseError(`Cannot build a mount record without host bindings for \"${stateProp}\".`);\n }\n const entries: IMountEntry[] = [];\n const seenInnerPaths = new Set<string>();\n let rootEntry: IMountEntry | null = null;\n for (const binding of bindings) {\n const innerSegments = binding.propSegments.slice(1);\n const innerPath = innerSegments.join(DELIMITER);\n if (seenInnerPaths.has(innerPath)) {\n // 同じ内側パスを 2 つの規則が指す形はどちらが勝つか書き手に見えない(M6・Phase 1 と同じ)\n raiseError('Duplicate mapping rule for web component.');\n }\n seenInnerPaths.add(innerPath);\n const entry: IMountEntry = {\n innerSegments,\n outerPathInfo: binding.statePathInfo,\n readonly: binding.propModifiers?.includes(MODIFIER_READONLY) === true,\n };\n entries.push(entry);\n if (innerSegments.length === 0) {\n rootEntry = entry;\n }\n }\n entries.sort((a, b) => b.innerSegments.length - a.innerSegments.length);\n const id = ++nextMountId;\n const marker = `#m${id}`;\n const { getterKeys, setterKeys } = collectAccessorKeys(stateObject);\n // ホストが部分エントリで明示したキー(`state.theme: theme`)は、同名の own data key があっても\n // 私有にしない — 明示した配線が作者の既定値に勝つ(要件 B14 ②。以前は own key が勝ち、\n // ホストの値が届かなかった)\n const mappedKeys = new Set<string>();\n for (const entry of entries) {\n if (entry.innerSegments.length > 0) mappedKeys.add(entry.innerSegments[0]);\n }\n const privateSnapshot: Record<string, unknown> = {};\n for (const key of Object.keys(stateObject)) {\n if (key.startsWith(\"$\")) continue;\n if (getterKeys.has(key) || setterKeys.has(key)) continue;\n if (typeof stateObject[key] === \"function\") continue;\n if (injectedKeys.has(key)) continue;\n if (mappedKeys.has(key)) continue;\n privateSnapshot[key] = stateObject[key];\n }\n return {\n id,\n marker,\n component,\n stateProp,\n parentStateElement,\n entries,\n rootEntry,\n delta: rootEntry === null ? 0 : rootEntry.outerPathInfo.wildcardCount,\n markerBasePath: rootEntry === null ? marker : rootEntry.outerPathInfo.path + DELIMITER + marker,\n stateObject,\n getterKeys,\n setterKeys,\n injectedKeys,\n mappedKeys,\n privateSnapshot,\n accessorBySuffixByMarkerParent: new Map(),\n indexShiftByLoopElementPath: new Map(),\n addedGetterPaths: new Set(),\n exports: new Map(),\n };\n}\n\nfunction firstSegmentOf(path: string): string {\n const dot = path.indexOf(DELIMITER);\n return dot === -1 ? path : path.slice(0, dot);\n}\n\nfunction startsWithSegments(segments: readonly string[], prefix: readonly string[]): boolean {\n if (prefix.length > segments.length) return false;\n for (let i = 0; i < prefix.length; i++) {\n if (segments[i] !== prefix[i]) return false;\n }\n return true;\n}\n\n/** 規則 3 の一致: 最長接頭辞のエントリ(entries は長い順)。一致しなければ null。 */\nfunction findTreeEntry(record: IMountRecord, segments: readonly string[]): IMountEntry | null {\n for (const entry of record.entries) {\n if (startsWithSegments(segments, entry.innerSegments)) {\n return entry;\n }\n }\n return null;\n}\n\n/** 規則 3: 最長接頭辞一致でツリーの絶対パスへ翻訳する。一致しなければ null。 */\nfunction translateTreePath(record: IMountRecord, segments: readonly string[]): string | null {\n for (const entry of record.entries) {\n if (startsWithSegments(segments, entry.innerSegments)) {\n const rest = segments.slice(entry.innerSegments.length);\n return rest.length === 0\n ? entry.outerPathInfo.path\n : entry.outerPathInfo.path + DELIMITER + rest.join(DELIMITER);\n }\n }\n return null;\n}\n\n/** 私有アンカー: パス全体をマーカーの下に置く(`users.*.#m.editing` / `users.*.#m.drafts.*.title`) */\nfunction markerizePrivate(record: IMountRecord, innerPath: string): string {\n return record.markerBasePath + DELIMITER + innerPath;\n}\n\n/**\n * アクセサの逆引き(マーカー親 → 接尾キー → 作者のアクセサ名と $n シフト)を登録する。\n * suffix は常に非空(ワイルドカード終端アクセサは markerizeAccessorPath が raise 済み —\n * 空を許すと trailing dot の不正パスが getterPaths に載る)。\n */\nfunction recordAccessorSuffix(record: IMountRecord, markerParentPath: string, suffix: string, accessorName: string): void {\n let bySuffix = record.accessorBySuffixByMarkerParent.get(markerParentPath);\n if (typeof bySuffix === \"undefined\") {\n bySuffix = new Map();\n record.accessorBySuffixByMarkerParent.set(markerParentPath, bySuffix);\n }\n const translatedPath = markerParentPath + DELIMITER + suffix;\n bySuffix.set(suffix, {\n accessorName,\n indexShift: getPathInfo(translatedPath).wildcardCount - getPathInfo(accessorName).wildcardCount,\n });\n if (record.getterKeys.has(accessorName)) {\n // マーカーパスを親の getterPaths に載せる。checkDependency(評価中の読み →\n // このアクセサの動的エッジ登録)と isCacheable(getter 値のキャッシュ)が\n // getterPaths を正本にしているため、載せないと再評価もキャッシュも効かない。\n // モック互換のため optional に扱う。追加分は記録の恒久破棄時に回収する\n // ため addedGetterPaths にも控える(cleanupCollectedMountRecord)。\n // suffix 空を素朴に結合すると trailing dot の不正パスになる — translatedPath を使う\n (record.parentStateElement.getterPaths as Set<string> | undefined)?.add(translatedPath);\n record.addedGetterPaths.add(translatedPath);\n }\n}\n\n/**\n * ワイルドカードを含む getter / setter のマーカー位置決め。ワイルドカード接頭辞が\n * ツリーに翻訳できるなら、その直後にマーカーを挟む(ループ文脈と listIndex の arity を\n * 素の wildcard getter と同一に保つ)。先頭セグメントが私有ならパスごと私有アンカー。\n */\nfunction markerizeAccessorPath(record: IMountRecord, innerPath: string): string {\n const segments = innerPath.split(DELIMITER);\n let lastWildcard = -1;\n for (let i = segments.length - 1; i >= 0; i--) {\n if (segments[i] === WILDCARD) {\n lastWildcard = i;\n break;\n }\n }\n if (lastWildcard === -1) {\n recordAccessorSuffix(record, record.markerBasePath, innerPath, innerPath);\n return markerizePrivate(record, innerPath);\n }\n const first = segments[0];\n if (isPrivateAnchor(record, first)) {\n recordAccessorSuffix(record, record.markerBasePath, innerPath, innerPath);\n return markerizePrivate(record, innerPath);\n }\n const treeSegments = segments.slice(0, lastWildcard + 1);\n const rest = segments.slice(lastWildcard + 1);\n const translated = translateTreePath(record, treeSegments);\n if (translated === null) {\n // 部分マウントのみで、どの接頭辞にも含まれないツリー部(§4-1 の 4b)\n raiseError(noMountEntryMessage(record, innerPath));\n }\n if (rest.length === 0) {\n // ワイルドカード終端アクセサ(行 getter `get \"tags.*\"()`)がツリーのリストへ翻訳される形:\n // 翻訳結果がマーカー終端パス(`users.*.tags.*.#m`)になり、getByAddress のオーバーレイ\n // dispatch が getter 評価より先に掛かってオーバーレイ proxy が値として返る\n // (作者の getter は評価されない)。無言で壊れる形なのでサポート外として loud に落とす\n raiseError(\n `Wildcard-terminal accessor \"${innerPath}\" on mounted <${record.component.tagName.toLowerCase()}> ` +\n `is not supported: it translates to a marker-terminal path where the mount overlay would shadow ` +\n `the accessor. Declare the row value as a getter on the host tree, or back it with a ` +\n `component-own array (a private key makes the whole path private).`,\n );\n }\n const markerParent = translated + DELIMITER + record.marker;\n recordAccessorSuffix(record, markerParent, rest.join(DELIMITER), innerPath);\n return markerParent + DELIMITER + rest.join(DELIMITER);\n}\n\n/** 先頭セグメントが「作者のもの」(own data key・メソッド。積みで注入されたキーは除く)か */\nfunction isPrivateAnchor(record: IMountRecord, firstSegment: string): boolean {\n if (record.injectedKeys.has(firstSegment) || record.mappedKeys.has(firstSegment)) {\n return false;\n }\n if (typeof record.stateObject[firstSegment] === \"function\" && !record.getterKeys.has(firstSegment)) {\n return true;\n }\n return Object.prototype.hasOwnProperty.call(record.stateObject, firstSegment)\n && !record.getterKeys.has(firstSegment)\n && !record.setterKeys.has(firstSegment);\n}\n\nfunction noMountEntryMessage(record: IMountRecord, innerPath: string): string {\n return `Path \"${innerPath}\" in <${record.component.tagName.toLowerCase()}> does not resolve: ` +\n `it is not an own key of the component state and no mount entry covers it ` +\n `(mounted prefixes: ${record.entries.filter(e => e.innerSegments.length > 0).map(e => e.innerSegments.join(DELIMITER)).join(\", \")}). ` +\n `Mount it from the host (\"${record.stateProp}: path\" / \"${record.stateProp}.${firstSegmentOf(innerPath)}: path\") or declare the key on the component state.`;\n}\n\n/**\n * コンポーネントスコープの内側パスを、親ツリーの絶対パスへ翻訳する(設計書 §4-1)。\n *\n * 1. getter / setter(完全一致・またはワイルドカード getter)→ マーカーパス(chroot 評価)\n * 2. own data key(部分規則が覆わないもの)・メソッド → マーカーパス(私有)\n * 3. それ以外 → 最長接頭辞一致でツリーへ\n * 4. 一致なし: ルートエントリがあれば必ず 3 で一致する。無ければ throw(4b)\n *\n * `$`(予約名前空間・`$1` 等)と `#`(構造プレースホルダ)で始まるパスは翻訳しない。\n */\nconst INDEX_PATH_REGEX = /^\\$(\\d+)$/;\n\n/**\n * `$n` バインディングのスコープ補正量(D9・設計書 §4-4)。\n * 囲む `for` の内側なら「その for パスが翻訳で得たワイルドカード数」— 行マウント\n * (`state: .`)の `for: tags` は `users.*.tags` になり +1、部分マウント\n * `state.items: groups.*.children` の `for: items` も +1。for の外(スコープ直下)は\n * ルート接頭辞の Δ。翻訳がワイルドカードを増やさないマウント(`state: user`)は 0。\n */\nexport function getIndexShiftForScope(record: IMountRecord, forPath: string | undefined): number {\n if (typeof forPath === \"undefined\") {\n return record.delta;\n }\n const translated = translateInnerPath(record, forPath);\n return getPathInfo(translated).wildcardCount - getPathInfo(forPath).wildcardCount;\n}\n\n/**\n * `innerPath` がツリーへ翻訳され、その先のエントリが読み取り専用(`#ro`)か(要件 B14 ①)。\n * 私有キー・アクセサ・`$` / `#` で始まるパスはコンポーネント自身のものなので対象外。\n */\nfunction isReadonlyTreePath(record: IMountRecord, innerPath: string): IMountEntry | null {\n const head = innerPath[0];\n if (head === \"$\" || head === \"#\") return null;\n if (record.getterKeys.has(innerPath) || record.setterKeys.has(innerPath)) return null;\n const first = firstSegmentOf(innerPath);\n if (record.getterKeys.has(first) || record.setterKeys.has(first) || isPrivateAnchor(record, first)) return null;\n const entry = findTreeEntry(record, innerPath.split(DELIMITER));\n return entry !== null && entry.readonly ? entry : null;\n}\n\n/**\n * 書き込みの翻訳(要件 B14 ①)。`translateInnerPath` と同じ行き先を返すが、読み取り専用で\n * マウントされたエントリ(`state#ro: user`)を通るツリーへの書き込みは名指しで拒否する。\n * コンポーネント側の書き込みの入口(`element.state`・オーバーレイ・`$setAll` / `$resolve`)が呼ぶ。\n */\nexport function translateInnerWritePath(record: IMountRecord, innerPath: string): string {\n const readonlyEntry = isReadonlyTreePath(record, innerPath);\n if (readonlyEntry !== null) {\n const suffix = readonlyEntry.innerSegments.length === 0 ? \"\" : DELIMITER + readonlyEntry.innerSegments.join(DELIMITER);\n raiseError(\n `[wcs/mount-readonly] <${record.component.tagName.toLowerCase()}> cannot write \"${innerPath}\": ` +\n `it is mounted read-only (\"${record.stateProp}${suffix}#${MODIFIER_READONLY}: ${readonlyEntry.outerPathInfo.path}\"). ` +\n `Write it on the host, or drop #${MODIFIER_READONLY} from the mount.`,\n );\n }\n return translateInnerPath(record, innerPath);\n}\n\nexport function translateInnerPath(record: IMountRecord, innerPath: string): string {\n const head = innerPath[0];\n if (head === \"$\" || head === \"#\") {\n // `$` の予約名前空間はパスとしては翻訳しない(`$n` のスコープ補正は\n // translateParsedForMount が囲む for の文脈で行う。getter 内の `this.$1` は\n // 親トラップがアクセサの indexShift で補正する)\n return innerPath;\n }\n // 規則 1: 完全一致の getter / setter(`display`・`\"children.*.label\"`)\n if (record.getterKeys.has(innerPath) || record.setterKeys.has(innerPath)) {\n return markerizeAccessorPath(record, innerPath);\n }\n const first = firstSegmentOf(innerPath);\n // 規則 1'/2: 先頭セグメントが getter / setter / メソッド / own data key → マーカー配下\n if (record.getterKeys.has(first) || record.setterKeys.has(first)) {\n return markerizePrivate(record, innerPath);\n }\n if (isPrivateAnchor(record, first)) {\n return markerizePrivate(record, innerPath);\n }\n // 規則 3: ツリー\n const translated = translateTreePath(record, innerPath.split(DELIMITER));\n if (translated !== null) {\n return translated;\n }\n // 規則 4b: 部分マウントのみで一致なし\n raiseError(noMountEntryMessage(record, innerPath));\n}\n\ninterface ITranslatable {\n readonly statePathName: string;\n readonly statePathInfo: IPathInfo;\n}\n\n/**\n * パース結果 / バインディングをマウント先の形へ変換した複製を返す\n * (パース結果キャッシュは触らない)。解決サイト(applyChangeFromBindings /\n * getAbsoluteStateAddressByBinding / fragmentInfoByUUID)は rootNode で\n * state element を引く — スコープ根は台帳エイリアスで親ツリーに到達する。\n */\nexport function translateParsedForMount<T extends ITranslatable>(record: IMountRecord, parsed: T, forPath?: string): T {\n let translated: string;\n const indexMatch = INDEX_PATH_REGEX.exec(parsed.statePathName);\n if (indexMatch !== null) {\n // `$n` はスコープ相対(D9・§4-4): 囲む for の翻訳で増えたワイルドカード数だけ繰り上げる\n const shift = getIndexShiftForScope(record, forPath);\n translated = shift === 0 ? parsed.statePathName : `$${Number(indexMatch[1]) + shift}`;\n } else {\n translated = translateInnerPath(record, parsed.statePathName);\n if ((parsed as { bindingType?: string }).bindingType === \"for\") {\n // スコープ相対の添字(P2-9)用: この for の行に立つループ文脈の要素パスと、\n // 翻訳で増えたワイルドカード数を控える。shift 0(Δ=0 の丸ごとマウント\n // `state: user` や同名翻訳の部分マウント)でも必ず載せる —\n // event/handler.ts は台帳に無いループ文脈を「外側スコープの借用行=\n // 添字 0 本」と解釈するため、登録漏れは自スコープの for の添字を\n // 丸ごと落とす(§4-4 違反)\n const shift = getPathInfo(translated).wildcardCount - parsed.statePathInfo.wildcardCount;\n record.indexShiftByLoopElementPath.set(translated + DELIMITER + WILDCARD, shift);\n }\n }\n // 読み取り専用のマウント(要件 B14 ①)を通る束縛は、要素 → state の書き戻しを止める(`#ro` と同じ)\n const modifiers = (parsed as { propModifiers?: readonly string[] }).propModifiers;\n const forceReadonly = indexMatch === null && Array.isArray(modifiers)\n && !modifiers.includes(MODIFIER_READONLY)\n && isReadonlyTreePath(record, parsed.statePathName) !== null;\n if (translated === parsed.statePathName && !forceReadonly) {\n return parsed;\n }\n return {\n ...parsed,\n statePathName: translated,\n statePathInfo: getPathInfo(translated),\n ...(forceReadonly ? { propModifiers: [...modifiers!, MODIFIER_READONLY] } : {}),\n };\n}\n\nexport function translateBindingForMount(record: IMountRecord, binding: IBindingInfo, forPath?: string): IBindingInfo {\n return translateParsedForMount(record, binding, forPath);\n}\n\n/**\n * マーカーパスのアクセサ評価中の `$n` シフト(トラップの補正が引く)。\n * アクセサとして登録されたパスならその indexShift、そうでなければルートの Δ。\n */\nexport function getIndexShiftForMarkerPath(record: IMountRecord, markerPath: string): number {\n // 末尾マーカーをセグメント単位で正確に切り出す(getMountRecordByPath と同じ規則)。\n // indexOf(record.marker) の前方一致だと `#m2` が別記録の `#m21` の中に誤ヒットし、\n // 親パスをセグメント途中で切って登録簿の照会を外す(Δ への誤フォールバック)\n const hashIndex = markerPath.lastIndexOf(\"#\");\n if (hashIndex === -1) {\n return record.delta;\n }\n const end = markerPath.indexOf(DELIMITER, hashIndex);\n const marker = end === -1 ? markerPath.slice(hashIndex) : markerPath.slice(hashIndex, end);\n if (marker !== record.marker) {\n return record.delta;\n }\n const parent = end === -1 ? markerPath : markerPath.slice(0, end);\n const suffix = end === -1 ? \"\" : markerPath.slice(end + 1);\n const entry = record.accessorBySuffixByMarkerParent.get(parent)?.get(suffix);\n return typeof entry !== \"undefined\" ? entry.indexShift : record.delta;\n}\n\n/**\n * `$getAll` / `$setAll` / `$resolve` の接頭辞翻訳(§4-6 / P2-9): 作者のスコープ相対\n * indexes の先頭に、翻訳で増えたワイルドカード分の文脈添字を合成する。\n * contextIndexes はホスト要素(chroot)またはマーカーアドレス(オーバーレイ)の\n * listIndex 添字列。プレフィックスが増えないパス(Δ=0 の翻訳)は素通し。\n */\nexport function composeMountIndexes(\n record: IMountRecord,\n innerPath: string,\n translatedPath: string,\n indexes: readonly number[] | undefined,\n contextIndexes: readonly number[],\n): readonly number[] | undefined {\n if (typeof indexes === \"undefined\") {\n return undefined;\n }\n const prefixWildcards = getPathInfo(translatedPath).wildcardCount - getPathInfo(innerPath).wildcardCount;\n if (prefixWildcards === 0) {\n return indexes;\n }\n if (contextIndexes.length < prefixWildcards) {\n raiseError(\n `Cannot resolve \"${innerPath}\" from this mount: the mounted prefix has ${prefixWildcards} wildcard(s) ` +\n `but the host context provides only ${contextIndexes.length} index(es).`,\n );\n }\n return [...contextIndexes.slice(0, prefixWildcards), ...indexes];\n}\n\n// ---------------------------------------------------------------------------\n// 登録簿\n// ---------------------------------------------------------------------------\n\n/**\n * スコープ根 → マウント記録。キーは Shadow DOM 形ならコンポーネントの shadowRoot、\n * Light DOM 形ならコンポーネント要素自身(そのサブツリーがスコープ)。\n */\nconst mountRecordByScopeRoot = new WeakMap<Node, IMountRecord>();\n\n/**\n * コンポーネント要素 → stateProp → マウント記録。\n * connectedCallback で shadow の innerHTML を張り直す作りのコンポーネントでは、\n * 再接続のたびに新しい <wcs-state> が同じ shadowRoot に入り、スコープが再初期化される。\n * 記録を要素単位で再利用することでマーカーが安定し、親側の登録簿\n * (byMarker・getterPaths)が再接続のたびに増えない。stateObject はクラスフィールド\n * なので要素と同寿命 — 記録の前提(作者のオブジェクトの同一性)が保たれる。\n */\nconst mountRecordByComponent = new WeakMap<Element, Map<string, IMountRecord>>();\n\n/** 再初期化用: この要素の stateProp に対して登録済みの記録を引く。 */\nexport function getRegisteredMountRecord(component: Element, stateProp: string): IMountRecord | null {\n return mountRecordByComponent.get(component)?.get(stateProp) ?? null;\n}\n\n/**\n * 親 state element → マーカー → マウント記録(オーバーレイ dispatch と Δ 補正が引く)。\n *\n * 値は **WeakRef**(B6)。記録への強参照は要素キーの WeakMap\n * (mountRecordByComponent / mountRecordByScopeRoot)だけが持つので、記録は\n * コンポーネント要素と同寿命になる — プール返却では要素が生きているので記録も生き、\n * 恒久破棄(route swap / `if` で捨てた形)では要素ごと回収可能になる。\n * ここを強参照にすると、長寿命の親 state 要素に破棄済み要素(と Shadow サブツリー)が\n * 際限なく蓄積する。\n */\nconst mountRecordsByStateElement = new WeakMap<IStateElement, Map<string, WeakRef<IMountRecord>>>();\n\n/** FinalizationRegistry の held 値: 記録が回収された後に台帳から掃除するもの。 */\nexport interface ICollectedMountLedgers {\n readonly byMarker: Map<string, WeakRef<IMountRecord>>;\n readonly marker: string;\n readonly getterPaths: Set<string> | undefined;\n readonly addedGetterPaths: ReadonlySet<string>;\n}\n\n/**\n * 恒久破棄されたマウント記録の台帳掃除(FinalizationRegistry のコールバック本体)。\n * マーカーは記録ごとに一意(`#m<id>` 単調増加)なので、発火時点でこのマーカーの\n * エントリは死んだ WeakRef のはず — 生きていれば触らない(防御)。\n * エクスポートしているのは GC を強制できないテスト環境で直接検証するため。\n */\nexport function cleanupCollectedMountRecord(held: ICollectedMountLedgers): void {\n const ref = held.byMarker.get(held.marker);\n if (typeof ref !== \"undefined\" && typeof ref.deref() === \"undefined\") {\n held.byMarker.delete(held.marker);\n }\n if (typeof held.getterPaths !== \"undefined\") {\n for (const path of held.addedGetterPaths) {\n held.getterPaths.delete(path);\n }\n }\n}\n\nconst collectedMountRegistry = new FinalizationRegistry<ICollectedMountLedgers>(cleanupCollectedMountRecord);\n\n/** マウント記録 → スコープ根。行 content をその場で使い回したときの張り直しが引く(#4) */\nconst scopeRootByMountRecord: WeakMap<IMountRecord, Node> = new WeakMap();\n\nexport function getScopeRootByMountRecord(record: IMountRecord): Node | null {\n return scopeRootByMountRecord.get(record) ?? null;\n}\n\n// ループ文脈の探索がマウントされた ShadowRoot でホストへ抜ける受け口(list/loopContextByNode.ts)。\n// 最初の記録の登録で 1 回だけ注入する(マウントの無いページでは探索は境界で止まったまま)\nlet scopeHostInstalled = false;\nfunction installMountedScopeHost(): void {\n if (scopeHostInstalled) return;\n scopeHostInstalled = true;\n setMountedScopeHost((root) => mountRecordByScopeRoot.has(root) ? root.host : null);\n}\n\nexport function registerMountRecord(scopeRoot: Node, record: IMountRecord): void {\n installMountedScopeHost();\n mountRecordByScopeRoot.set(scopeRoot, record);\n scopeRootByMountRecord.set(record, scopeRoot);\n let byMarker = mountRecordsByStateElement.get(record.parentStateElement);\n if (typeof byMarker === \"undefined\") {\n byMarker = new Map();\n mountRecordsByStateElement.set(record.parentStateElement, byMarker);\n }\n byMarker.set(record.marker, new WeakRef(record));\n let byProp = mountRecordByComponent.get(record.component);\n if (typeof byProp === 'undefined') {\n byProp = new Map();\n mountRecordByComponent.set(record.component, byProp);\n }\n const isFirstRegistration = byProp.get(record.stateProp) !== record;\n byProp.set(record.stateProp, record);\n if (isFirstRegistration) {\n // 恒久破棄で台帳(byMarker・親 getterPaths への追加分)を回収する(B6)。\n // 再初期化(同一 record の再登録 — マーカー安定のための再利用)では二重登録しない\n collectedMountRegistry.register(record, {\n byMarker,\n marker: record.marker,\n getterPaths: record.parentStateElement.getterPaths as Set<string> | undefined,\n addedGetterPaths: record.addedGetterPaths,\n });\n }\n // D18: マウントの無い state はオーバーレイ dispatch を boolean 1 個で抜ける\n record.parentStateElement.markHasMounts?.();\n}\n\nexport function getMountRecordByScopeRoot(scopeRoot: Node): IMountRecord | null {\n return mountRecordByScopeRoot.get(scopeRoot) ?? null;\n}\n\n/**\n * ノードから最も近いマウントスコープ根の記録を引く(event/handler.ts のスコープ相対\n * 添字が使う)。Light DOM 形はスコープ根=**コンポーネント要素自身**(D7・\n * mountScope.ts)で rootNode の内側に入れ子になりうる(Shadow 形のスコープの中の\n * Light DOM マウント)ため、**祖先を先に**辿って最初のスコープ根を探す — rootNode\n * 直ヒットを先に返すと外側の記録を取り違える。祖先に無ければ rootNode 自身\n * (Shadow DOM 形のスコープ根=shadowRoot)で引く。入れ子マウントでは\n * 最も内側(=そのノードのバインディングを翻訳した記録)が返る。\n * `hasMounts` が真のときだけ呼ぶこと(無マウントの経路にこの走査を載せない — D18)。\n */\nexport function findMountRecordForNode(node: Node, rootNode: Node): IMountRecord | null {\n let current: Node | null = node;\n while (current !== null && current !== rootNode) {\n const record = mountRecordByScopeRoot.get(current);\n if (typeof record !== \"undefined\") {\n return record;\n }\n current = current.parentNode;\n }\n return mountRecordByScopeRoot.get(rootNode) ?? null;\n}\n\n/** この state element に登録済みのマウント記録を列挙する(devtools の overlays が読む)。 */\nexport function getMountRecordsForStateElement(stateElement: IStateElement): IMountRecord[] {\n const byMarker = mountRecordsByStateElement.get(stateElement);\n if (typeof byMarker === \"undefined\") {\n return [];\n }\n const records: IMountRecord[] = [];\n for (const ref of byMarker.values()) {\n const record = ref.deref();\n if (typeof record !== \"undefined\") {\n records.push(record);\n }\n }\n return records;\n}\n\n/** 親 state element がマウントを 1 つでも持つか(D18: 無ければ dispatch は分岐 1 つで抜ける) */\nexport function stateElementHasMounts(stateElement: IStateElement): boolean {\n const byMarker = mountRecordsByStateElement.get(stateElement);\n return typeof byMarker !== \"undefined\" && byMarker.size > 0;\n}\n\n/**\n * パスに含まれるマーカーからマウント記録を引く。`hasMounts` が真のときだけ呼ぶこと。\n * `#` を含まないパス(圧倒的多数)は lastIndexOf 1 回で抜ける。\n * 入れ子マウント(外側の私有キーの上に内側マウントが載る形)ではパスに複数の\n * マーカーが並ぶ(`users.*.#m1.drafts.#m2`)— オーバーレイ dispatch と $n 補正が\n * 要るのは**末尾**のマーカーの記録なので、先頭でなく最後の `#` で切る\n * (先頭で切ると外側の記録が返り誤翻訳する)。\n */\nexport function getMountRecordByPath(stateElement: IStateElement, path: string): IMountRecord | null {\n const hashIndex = path.lastIndexOf(\"#\");\n if (hashIndex === -1) {\n return null;\n }\n const byMarker = mountRecordsByStateElement.get(stateElement);\n if (typeof byMarker === \"undefined\") {\n return null;\n }\n const end = path.indexOf(DELIMITER, hashIndex);\n const marker = end === -1 ? path.slice(hashIndex) : path.slice(hashIndex, end);\n const ref = byMarker.get(marker);\n if (typeof ref === \"undefined\") {\n return null;\n }\n const record = ref.deref();\n if (typeof record === \"undefined\") {\n // 記録は回収済み(finalizer 発火前の窓)— 遅延 prune\n byMarker.delete(marker);\n return null;\n }\n return record;\n}\n\n/** テスト用: マーカー台帳の WeakRef を差し替える(GC を強制できない環境で死んだ参照を再現する)。 */\nexport function _setMountRecordRefForTesting(\n stateElement: IStateElement,\n marker: string,\n ref: WeakRef<IMountRecord>,\n): void {\n mountRecordsByStateElement.get(stateElement)?.set(marker, ref);\n}\n"],"names":["nextMountId","MOUNT_DOLLAR_DECLARATIONS","dollarDeclarationWarned","Set","warnMountedDollarDeclarations","record","declared","filter","name","stateObject","accessor","getterKeys","indexOf","RECURSION_WILDCARD","push","length","key","component","tagName","toLowerCase","stateProp","has","add","console","warn","split","join","callMountLifecycleCallback","callback","chroot","result","call","Promise","catch","error","buildMountRecord","bindings","parentStateElement","injectedKeys","raiseError","entries","seenInnerPaths","rootEntry","binding","innerSegments","propSegments","slice","innerPath","DELIMITER","entry","outerPathInfo","statePathInfo","readonly","propModifiers","includes","MODIFIER_READONLY","sort","a","b","id","marker","setterKeys","descriptors","Object","getOwnPropertyDescriptors","descriptor","get","set","collectAccessorKeys","mappedKeys","privateSnapshot","keys","startsWith","delta","wildcardCount","markerBasePath","path","accessorBySuffixByMarkerParent","Map","indexShiftByLoopElementPath","addedGetterPaths","exports","firstSegmentOf","dot","startsWithSegments","segments","prefix","i","translateTreePath","rest","markerizePrivate","recordAccessorSuffix","markerParentPath","suffix","accessorName","bySuffix","translatedPath","indexShift","getPathInfo","getterPaths","isPrivateAnchor","firstSegment","prototype","hasOwnProperty","noMountEntryMessage","e","map","INDEX_PATH_REGEX","isReadonlyTreePath","head","first","findTreeEntry","translateInnerWritePath","readonlyEntry","translateInnerPath","lastWildcard","WILDCARD","treeSegments","translated","markerParent","markerizeAccessorPath","translateParsedForMount","parsed","forPath","indexMatch","exec","statePathName","shift","getIndexShiftForScope","Number","bindingType","modifiers","forceReadonly","Array","isArray","getIndexShiftForMarkerPath","markerPath","hashIndex","lastIndexOf","end","parent","composeMountIndexes","indexes","contextIndexes","prefixWildcards","mountRecordByScopeRoot","WeakMap","mountRecordByComponent","getRegisteredMountRecord","mountRecordsByStateElement","collectedMountRegistry","FinalizationRegistry","held","ref","byMarker","deref","delete","scopeRootByMountRecord","getScopeRootByMountRecord","scopeHostInstalled","registerMountRecord","scopeRoot","setMountedScopeHost","root","host","WeakRef","byProp","isFirstRegistration","register","markHasMounts","getMountRecordByScopeRoot","findMountRecordForNode","node","rootNode","current","parentNode","getMountRecordsForStateElement","stateElement","records","values","stateElementHasMounts","size","getMountRecordByPath"],"mappings":"6IAwHA,IAAIA,EAAc,EAElB,MAAMC,EAA4B,CAChC,SAAU,WAAY,QAAS,YAAa,mBAAoB,iBAAkB,eAAgB,MAElG,aAAc,kBAEVC,EAA0B,IAAIC,IAiB9B,SAAUC,EAA8BC,GAC5C,MAAMC,EAAqBL,EAA0BM,OAClDC,QAA0E,IAAzDH,EAAOI,YAAwCD,IAMnE,IAAK,MAAME,KAAYL,EAAOM,YACiB,IAAzCD,EAASE,QAAQC,IACnBP,EAASQ,KAAK,IAAIJ,MAGtB,GAAwB,IAApBJ,EAASS,OACX,OAEF,MAAMC,EAAM,GAAGX,EAAOY,UAAUC,QAAQC,iBAAiBd,EAAOe,YAC5DlB,EAAwBmB,IAAIL,KAGhCd,EAAwBoB,IAAIN,GAC5BO,QAAQC,KACN,oDAAoDR,EAAIS,MAAM,KAAK,OAAOpB,EAAOe,sBAC9Ed,EAASoB,KAAK,wQAIrB,CAOM,SAAUC,EAA2BtB,EAAsBG,GAC/D,MAAMoB,EAAYvB,EAAOI,YAAwCD,GACjE,GAAwB,mBAAboB,EAGX,IACE,MAAMC,EAAUxB,EAAOY,UAAiDZ,EAAOe,WACzEU,EAAUF,EAAwCG,KAAKF,GACzDC,aAAkBE,SACpBF,EAAOG,MAAOC,IACZX,QAAQW,MAAM,6BAA6B7B,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AAiB,IAAR+E,EAAa/D,EAAK9B,MAAM2F,GAAa7D,EAAK9B,MAAM2F,EAAWE,GACpEc,EAAMC,EAASxF,IAAIN,GACzB,QAAmB,IAAR6F,EACT,OAAO,KAET,MAAMpJ,EAASoJ,EAAIE,QACnB,YAAsB,IAAXtJ,GAETqJ,EAASE,OAAOhG,GACT,MAEFvD,CACT"}
1
+ {"version":3,"file":"mount.js","sources":["../../../../../src/webComponent/mountEntries.ts","../../../../../src/webComponent/mount.ts"],"sourcesContent":["/**\n * webComponent/mountEntries.ts — マウントのエントリ表(内側接頭辞 → 外側パス)と、その一致。\n *\n * コンポーネントのマウント記録(mount.ts)とボリュームの注入口(volumeShared.ts、要件 B14③)が\n * 同じ表と同じ一致規則を使う。書き込み翻訳の単一点(要件 §3.4)はこの 2 つの関数に集まる —\n * 読み取り専用(`#ro`)の判定もエントリが持つ。\n */\nimport { IPathInfo } from \"../address/types\";\nimport { DELIMITER } from \"../define\";\n\nexport interface IMountEntry {\n /** 内側接頭辞のセグメント(ルートエントリは 0 個 — あらゆる内側パスに一致する) */\n readonly innerSegments: readonly string[];\n readonly outerPathInfo: IPathInfo;\n /**\n * `#ro` が付いたか(`state#ro: user` / `state.name#ro: user.name`、要件 B14 ①)。\n * 真なら、内側からこのエントリを通るツリーへの書き込みは拒否される(外側自身の書き込みは止めない)。\n */\n readonly readonly: boolean;\n}\n\nfunction startsWithSegments(segments: readonly string[], prefix: readonly string[]): boolean {\n if (prefix.length > segments.length) return false;\n for (let i = 0; i < prefix.length; i++) {\n if (segments[i] !== prefix[i]) return false;\n }\n return true;\n}\n\n/** 最長接頭辞のエントリ(entries は内側接頭辞の長い順に並べておくこと)。一致しなければ null。 */\nexport function findMountEntry(entries: readonly IMountEntry[], segments: readonly string[]): IMountEntry | null {\n for (const entry of entries) {\n if (startsWithSegments(segments, entry.innerSegments)) {\n return entry;\n }\n }\n return null;\n}\n\n/** 一致したエントリで内側パスを外側の絶対パスへ書き換える(`segments` は entry に一致していること)。 */\nexport function translateByMountEntry(entry: IMountEntry, segments: readonly string[]): string {\n const rest = segments.slice(entry.innerSegments.length);\n return rest.length === 0\n ? entry.outerPathInfo.path\n : entry.outerPathInfo.path + DELIMITER + rest.join(DELIMITER);\n}\n","import { getPathInfo } from \"../address/PathInfo\";\nimport { IPathInfo } from \"../address/types\";\nimport { IStateElement } from \"../components/types\";\nimport { setMountedScopeHost } from \"../list/loopContextByNode\";\nimport { DELIMITER, MODIFIER_READONLY, RECURSION_WILDCARD, STATE_STREAMS_NAME, STATE_UPDATED_CALLBACK_NAME, WILDCARD } from \"../define\";\nimport { normalizeDeclarationAliases } from \"../declarationAliases\";\nimport { raiseError } from \"../raiseError\";\nimport { IBindingInfo } from \"../types\";\nimport { findMountEntry, IMountEntry, translateByMountEntry } from \"./mountEntries\";\n\n/**\n * webComponent/mount.ts — マウント記録(Phase 2・docs/state-mount-design.md §5、impl-plan §3-0)。\n *\n * v2 の不変条件「マウントされたコンポーネントのバインディングは、その位置にテンプレートを\n * 展開してパスに接頭辞を付けたものと区別できない」を、**バインディングの変換**として実装する。\n * マウントされたスコープのバインディングは登録時にここの `translateInnerPath` で\n * 親ツリーの絶対パスへ書き換えられ、以後は台帳・依存グラフ・キャッシュ・LIS・プールの\n * どれから見ても「親スコープにインラインで書かれた binding」と同一になる。\n *\n * 例外は私有キーと getter / メソッド(展開したテンプレートには存在しないもの)で、\n * これらは **予約セグメント**(D20・`#m<id>` — `#` はパス文法で書けない)を挟んだ\n * 絶対アドレスに載る。ツリーのアドレスと構造的に衝突せず、親 handler のオーバーレイ\n * dispatch はマーカーを含む読み書きだけに掛かる。D10(スコープ外から見えない)は\n * このアドレス空間の帰結になる。\n *\n * マーカーの位置は「ワイルドカード接頭辞の直後」:\n * - 単純な getter / 私有キー(`display` / `editing`)→ `<rootOuter>.#m.display`\n * (ルートエントリが無い部分マウントのみの形では `#m.display`)\n * - ツリーのリストの上のワイルドカード getter(`get \"children.*.label\"`、`state: group`)\n * → `group.children.*.#m.label` — ワイルドカード親がツリーのリストと一致するので、\n * ループ文脈の解決(indexByWildcardPath)と listIndex の arity が素の getter と同じに保たれる\n * - 私有配列の上のワイルドカード getter(`state = { drafts: [] }` + `get \"drafts.*.title\"`)\n * → `<rootOuter>.#m.drafts.*.title` — 配列ごと私有側に閉じる\n */\n\nexport type { IMountEntry } from \"./mountEntries\";\n\nexport interface IMountRecord {\n readonly id: number;\n /** D20 の予約セグメント(`#m<id>`) */\n readonly marker: string;\n readonly component: Element;\n readonly stateProp: string;\n readonly parentStateElement: IStateElement;\n /** マウント表(内側接頭辞の長い順 — 最長接頭辞一致は先頭ヒットで決まる) */\n readonly entries: readonly IMountEntry[];\n /** ルートエントリ(`state: path`)。無ければ null(部分マウントのみ) */\n readonly rootEntry: IMountEntry | null;\n /** Δ = ルート接頭辞のワイルドカード数(`$n` のスコープ補正が読む唯一の値) */\n readonly delta: number;\n /** 私有キー・単純 getter を載せるマーカーパス(`users.*.#m3` / `#m3`) */\n readonly markerBasePath: string;\n /** 作者の state オブジェクト(私有キー・getter・メソッドの実体) */\n readonly stateObject: Record<string, any>;\n readonly getterKeys: ReadonlySet<string>;\n readonly setterKeys: ReadonlySet<string>;\n /**\n * 完了前の親の初期適用(積み)が作者のオブジェクトに**注入した**キー\n * (webComponent/preCompletionWrites.ts)。作者のものではないので私有にしない\n * (v2 は厳格 R1: 作者が宣言した own data key は部分マウントに覆われていても私有 —\n * 設計書 §4-1 規則 2。1.x の「マッピングが勝つ」からの反転は D19 が予告済み)。\n */\n readonly injectedKeys: ReadonlySet<string>;\n /** 部分エントリが明示したキー(先頭セグメント)。同名の own data key より優先する(要件 B14 ②) */\n readonly mappedKeys: ReadonlySet<string>;\n /**\n * 私有データの初期スナップショット(own data key の浅い複製・D21)。\n * マウントインスタンス(listIndex)ごとの私有オブジェクトはここから複製される。\n */\n readonly privateSnapshot: Readonly<Record<string, unknown>>;\n /**\n * マーカーの親パス(翻訳後) → { 接尾キー → 作者のアクセサ情報 }。\n * `display` は markerBase の親に `display → display`、\n * ワイルドカード getter `\"children.*.label\"` は `group.children.*` に `label → children.*.label`。\n * `indexShift` は翻訳で増えたワイルドカード数(アクセサ内の `$n` のスコープ補正が読む)。\n * translateInnerPath のマーカー化で遅延登録され、オーバーレイの get とトラップが引く。\n */\n readonly accessorBySuffixByMarkerParent: Map<string, Map<string, IAccessorEntry>>;\n /**\n * 翻訳された `for` のループ要素パス(`groups.*.children.*`)→ 翻訳で増えた\n * ワイルドカード数。イベントハンドラの「スコープ相対の添字」(§4-4 / P2-9)が\n * 引く — 添字列の末尾から (総数 − shift) 本だけが作者の見える添字。\n * translateParsedForMount が for の翻訳時に埋める。\n */\n readonly indexShiftByLoopElementPath: Map<string, number>;\n /**\n * この記録が親の getterPaths に追加したマーカーパス(recordAccessorSuffix)。\n * 記録の恒久破棄時に cleanupCollectedMountRecord が親から回収する。\n * record の外の消費者(FinalizationRegistry の held 値)も参照するため、\n * record 本体が回収された後も held 経由で読める独立オブジェクトにしてある。\n */\n readonly addedGetterPaths: Set<string>;\n /**\n * 公開 getter(docs/state-overlay-export-design.md X2 / X3): 公開パス(マーカー無し・\n * `users.*.display`)→ マーカー親パス・接尾キー・マーカーパス。registerExports が\n * 初回登録で getter / setter キーから作る(翻訳できないアクセサは載らない)。\n */\n readonly exports: Map<string, IExportEntry>;\n}\n\nexport interface IExportEntry {\n /** マーカーで終わるパス(`users.*.#m7` — overlay.ts の「マーカー親」。accessorBySuffixByMarkerParent の鍵) */\n readonly markerTerminalPath: string;\n readonly suffix: string;\n readonly markerPath: string;\n readonly exportedPath: string;\n}\n\nexport interface IAccessorEntry {\n readonly accessorName: string;\n readonly indexShift: number;\n}\n\nlet nextMountId = 0;\n\nconst MOUNT_DOLLAR_DECLARATIONS = [\n \"$watch\", STATE_STREAMS_NAME, \"$scan\", \"$listKeys\", STATE_UPDATED_CALLBACK_NAME, \"$commandTokens\", \"$eventTokens\", \"$on\",\n // $errorCallback もルート専用(要件 B11 — 以前は無言で無視していた)\n \"$recursion\", \"$errorCallback\",\n] as const;\nconst dollarDeclarationWarned = new Set<string>();\n\n/** テスト用: 宣言 warn の 1 回性台帳を空にする。 */\nexport function clearMountDollarWarnsForTesting(): void {\n dollarDeclarationWarned.clear();\n}\n\n/**\n * マウントされたコンポーネントは宣言面(`$watch` / `$streams` / `$listKeys` /\n * `$updatedCallback` / `$commandTokens` / `$eventTokens` / `$on`)を実行しない\n * (v1 の mapped も同じ — innerState が `$` を遮っていた)。無言に捨てず、\n * (tag, prop) につき 1 回だけ「ルート(または対応する宣言はボリューム)に宣言する」\n * 誘導を出す。テンプレート側の `$command.*` の**参照**(バインディングのパス)は\n * ルート宣言のトークンに解決される(`$` 頭のパスは翻訳しない — translateInnerPath)。\n * `$connectedCallback` / `$disconnectedCallback` / `$stateReadyCallback` は要素の\n * ライフサイクルとしてスコープごとに残る(設計書 §4-6)。\n */\nexport function warnMountedDollarDeclarations(record: IMountRecord): void {\n const declared: string[] = MOUNT_DOLLAR_DECLARATIONS.filter(\n (name) => typeof (record.stateObject as Record<string, unknown>)[name] !== \"undefined\",\n );\n // `**` getter(`get \"node.**.total\"()`)も同じ扱い。`markerizeAccessorPath` は `*` セグメントしか\n // 探さないので `**` を含むキーは私有アンカーに落ち、参照されないまま永久に登録されない\n // (ボリュームは接ぎ木前に拒否し、`$recursion` はこの誘導が出るのに、`**` getter だけが\n // 無言だった — 第 3 サイクルのレビューで実測)。\n for (const accessor of record.getterKeys) {\n if (accessor.indexOf(RECURSION_WILDCARD) !== -1) {\n declared.push(`\"${accessor}\"`);\n }\n }\n if (declared.length === 0) {\n return;\n }\n const key = `${record.component.tagName.toLowerCase()}|${record.stateProp}`;\n if (dollarDeclarationWarned.has(key)) {\n return;\n }\n dollarDeclarationWarned.add(key);\n console.warn(\n `[@wcstack/state] [wcs/mount-dollar-declaration] <${key.split(\"|\")[0]}>.${record.stateProp} declares ` +\n `${declared.join(\", \")}, which mounted components do not run. Declare them on the root state instead ` +\n `(a volume <wcs-state mount=\"...\"> can host $watch / $listKeys / $updatedCallback; $recursion and ` +\n `\"**\" getters expand against the root tree). See docs/state-mount-design.md §4-6.`,\n );\n}\n\n/**\n * マウントされたコンポーネントのライフサイクル呼び出し(`$connectedCallback` /\n * `$disconnectedCallback`)。`this` は公開 chroot(`element[stateProp]`)。\n * 例外・reject は 1 コンポーネントに閉じる(切断時は親も切断中でありうる)。\n */\nexport function callMountLifecycleCallback(record: IMountRecord, name: string): void {\n const callback = (record.stateObject as Record<string, unknown>)[name];\n if (typeof callback !== \"function\") {\n return;\n }\n try {\n const chroot = (record.component as unknown as Record<string, unknown>)[record.stateProp];\n const result = (callback as (this: unknown) => unknown).call(chroot);\n if (result instanceof Promise) {\n result.catch((error) => {\n console.error(`[@wcstack/state] mounted <${record.component.tagName.toLowerCase()}> ${name} failed.`, error);\n });\n }\n } catch (error) {\n console.error(`[@wcstack/state] mounted <${record.component.tagName.toLowerCase()}> ${name} failed.`, error);\n }\n}\n\n/** テスト用: マーカー id を初期化する(マーカー文字列の安定化) */\nexport function resetMountIdForTesting(): void {\n nextMountId = 0;\n}\n\nfunction collectAccessorKeys(stateObject: Record<string, any>): { getterKeys: Set<string>, setterKeys: Set<string> } {\n const getterKeys = new Set<string>();\n const setterKeys = new Set<string>();\n const descriptors = Object.getOwnPropertyDescriptors(stateObject);\n for (const [key, descriptor] of Object.entries(descriptors)) {\n if (typeof descriptor.get === \"function\") getterKeys.add(key);\n if (typeof descriptor.set === \"function\") setterKeys.add(key);\n }\n return { getterKeys, setterKeys };\n}\n\n/**\n * ホストの `state[.sub]: path` バインディング群からマウント記録を組む。\n * `bindings` は propSegments[0] === stateProp で選別済みであること\n * (bindWebComponent が v1 の buildPrimaryMappingRule に渡すものと同じ集合)。\n */\nexport function buildMountRecord(\n component: Element,\n stateProp: string,\n bindings: readonly IBindingInfo[],\n parentStateElement: IStateElement,\n stateObject: Record<string, any>,\n injectedKeys: ReadonlySet<string> = new Set<string>(),\n): IMountRecord {\n if (bindings.length === 0) {\n raiseError(`Cannot build a mount record without host bindings for \"${stateProp}\".`);\n }\n // 宣言キーの旧名を正式名へ(要件 B12)— 宣言の警告(MOUNT_DOLLAR_DECLARATIONS)は正式名で引く\n normalizeDeclarationAliases(stateObject);\n const entries: IMountEntry[] = [];\n const seenInnerPaths = new Set<string>();\n let rootEntry: IMountEntry | null = null;\n for (const binding of bindings) {\n const innerSegments = binding.propSegments.slice(1);\n const innerPath = innerSegments.join(DELIMITER);\n if (seenInnerPaths.has(innerPath)) {\n // 同じ内側パスを 2 つの規則が指す形はどちらが勝つか書き手に見えない(M6・Phase 1 と同じ)\n raiseError('Duplicate mapping rule for web component.');\n }\n seenInnerPaths.add(innerPath);\n const entry: IMountEntry = {\n innerSegments,\n outerPathInfo: binding.statePathInfo,\n readonly: binding.propModifiers?.includes(MODIFIER_READONLY) === true,\n };\n entries.push(entry);\n if (innerSegments.length === 0) {\n rootEntry = entry;\n }\n }\n entries.sort((a, b) => b.innerSegments.length - a.innerSegments.length);\n const id = ++nextMountId;\n const marker = `#m${id}`;\n const { getterKeys, setterKeys } = collectAccessorKeys(stateObject);\n // ホストが部分エントリで明示したキー(`state.theme: theme`)は、同名の own data key があっても\n // 私有にしない — 明示した配線が作者の既定値に勝つ(要件 B14 ②。以前は own key が勝ち、\n // ホストの値が届かなかった)\n const mappedKeys = new Set<string>();\n for (const entry of entries) {\n if (entry.innerSegments.length > 0) mappedKeys.add(entry.innerSegments[0]);\n }\n const privateSnapshot: Record<string, unknown> = {};\n for (const key of Object.keys(stateObject)) {\n if (key.startsWith(\"$\")) continue;\n if (getterKeys.has(key) || setterKeys.has(key)) continue;\n if (typeof stateObject[key] === \"function\") continue;\n if (injectedKeys.has(key)) continue;\n if (mappedKeys.has(key)) continue;\n privateSnapshot[key] = stateObject[key];\n }\n return {\n id,\n marker,\n component,\n stateProp,\n parentStateElement,\n entries,\n rootEntry,\n delta: rootEntry === null ? 0 : rootEntry.outerPathInfo.wildcardCount,\n markerBasePath: rootEntry === null ? marker : rootEntry.outerPathInfo.path + DELIMITER + marker,\n stateObject,\n getterKeys,\n setterKeys,\n injectedKeys,\n mappedKeys,\n privateSnapshot,\n accessorBySuffixByMarkerParent: new Map(),\n indexShiftByLoopElementPath: new Map(),\n addedGetterPaths: new Set(),\n exports: new Map(),\n };\n}\n\nfunction firstSegmentOf(path: string): string {\n const dot = path.indexOf(DELIMITER);\n return dot === -1 ? path : path.slice(0, dot);\n}\n\n/** 規則 3 の一致: 最長接頭辞のエントリ(entries は長い順)。一致しなければ null。 */\nfunction findTreeEntry(record: IMountRecord, segments: readonly string[]): IMountEntry | null {\n return findMountEntry(record.entries, segments);\n}\n\n/** 規則 3: 最長接頭辞一致でツリーの絶対パスへ翻訳する。一致しなければ null。 */\nfunction translateTreePath(record: IMountRecord, segments: readonly string[]): string | null {\n const entry = findMountEntry(record.entries, segments);\n return entry === null ? null : translateByMountEntry(entry, segments);\n}\n\n/** 私有アンカー: パス全体をマーカーの下に置く(`users.*.#m.editing` / `users.*.#m.drafts.*.title`) */\nfunction markerizePrivate(record: IMountRecord, innerPath: string): string {\n return record.markerBasePath + DELIMITER + innerPath;\n}\n\n/**\n * アクセサの逆引き(マーカー親 → 接尾キー → 作者のアクセサ名と $n シフト)を登録する。\n * suffix は常に非空(ワイルドカード終端アクセサは markerizeAccessorPath が raise 済み —\n * 空を許すと trailing dot の不正パスが getterPaths に載る)。\n */\nfunction recordAccessorSuffix(record: IMountRecord, markerParentPath: string, suffix: string, accessorName: string): void {\n let bySuffix = record.accessorBySuffixByMarkerParent.get(markerParentPath);\n if (typeof bySuffix === \"undefined\") {\n bySuffix = new Map();\n record.accessorBySuffixByMarkerParent.set(markerParentPath, bySuffix);\n }\n const translatedPath = markerParentPath + DELIMITER + suffix;\n bySuffix.set(suffix, {\n accessorName,\n indexShift: getPathInfo(translatedPath).wildcardCount - getPathInfo(accessorName).wildcardCount,\n });\n if (record.getterKeys.has(accessorName)) {\n // マーカーパスを親の getterPaths に載せる。checkDependency(評価中の読み →\n // このアクセサの動的エッジ登録)と isCacheable(getter 値のキャッシュ)が\n // getterPaths を正本にしているため、載せないと再評価もキャッシュも効かない。\n // モック互換のため optional に扱う。追加分は記録の恒久破棄時に回収する\n // ため addedGetterPaths にも控える(cleanupCollectedMountRecord)。\n // suffix 空を素朴に結合すると trailing dot の不正パスになる — translatedPath を使う\n (record.parentStateElement.getterPaths as Set<string> | undefined)?.add(translatedPath);\n record.addedGetterPaths.add(translatedPath);\n }\n}\n\n/**\n * ワイルドカードを含む getter / setter のマーカー位置決め。ワイルドカード接頭辞が\n * ツリーに翻訳できるなら、その直後にマーカーを挟む(ループ文脈と listIndex の arity を\n * 素の wildcard getter と同一に保つ)。先頭セグメントが私有ならパスごと私有アンカー。\n */\nfunction markerizeAccessorPath(record: IMountRecord, innerPath: string): string {\n const segments = innerPath.split(DELIMITER);\n let lastWildcard = -1;\n for (let i = segments.length - 1; i >= 0; i--) {\n if (segments[i] === WILDCARD) {\n lastWildcard = i;\n break;\n }\n }\n if (lastWildcard === -1) {\n recordAccessorSuffix(record, record.markerBasePath, innerPath, innerPath);\n return markerizePrivate(record, innerPath);\n }\n const first = segments[0];\n if (isPrivateAnchor(record, first)) {\n recordAccessorSuffix(record, record.markerBasePath, innerPath, innerPath);\n return markerizePrivate(record, innerPath);\n }\n const treeSegments = segments.slice(0, lastWildcard + 1);\n const rest = segments.slice(lastWildcard + 1);\n const translated = translateTreePath(record, treeSegments);\n if (translated === null) {\n // 部分マウントのみで、どの接頭辞にも含まれないツリー部(§4-1 の 4b)\n raiseError(noMountEntryMessage(record, innerPath));\n }\n if (rest.length === 0) {\n // ワイルドカード終端アクセサ(行 getter `get \"tags.*\"()`)がツリーのリストへ翻訳される形:\n // 翻訳結果がマーカー終端パス(`users.*.tags.*.#m`)になり、getByAddress のオーバーレイ\n // dispatch が getter 評価より先に掛かってオーバーレイ proxy が値として返る\n // (作者の getter は評価されない)。無言で壊れる形なのでサポート外として loud に落とす\n raiseError(\n `Wildcard-terminal accessor \"${innerPath}\" on mounted <${record.component.tagName.toLowerCase()}> ` +\n `is not supported: it translates to a marker-terminal path where the mount overlay would shadow ` +\n `the accessor. Declare the row value as a getter on the host tree, or back it with a ` +\n `component-own array (a private key makes the whole path private).`,\n );\n }\n const markerParent = translated + DELIMITER + record.marker;\n recordAccessorSuffix(record, markerParent, rest.join(DELIMITER), innerPath);\n return markerParent + DELIMITER + rest.join(DELIMITER);\n}\n\n/** 先頭セグメントが「作者のもの」(own data key・メソッド。積みで注入されたキーは除く)か */\nfunction isPrivateAnchor(record: IMountRecord, firstSegment: string): boolean {\n if (record.injectedKeys.has(firstSegment) || record.mappedKeys.has(firstSegment)) {\n return false;\n }\n if (typeof record.stateObject[firstSegment] === \"function\" && !record.getterKeys.has(firstSegment)) {\n return true;\n }\n return Object.prototype.hasOwnProperty.call(record.stateObject, firstSegment)\n && !record.getterKeys.has(firstSegment)\n && !record.setterKeys.has(firstSegment);\n}\n\nfunction noMountEntryMessage(record: IMountRecord, innerPath: string): string {\n return `Path \"${innerPath}\" in <${record.component.tagName.toLowerCase()}> does not resolve: ` +\n `it is not an own key of the component state and no mount entry covers it ` +\n `(mounted prefixes: ${record.entries.filter(e => e.innerSegments.length > 0).map(e => e.innerSegments.join(DELIMITER)).join(\", \")}). ` +\n `Mount it from the host (\"${record.stateProp}: path\" / \"${record.stateProp}.${firstSegmentOf(innerPath)}: path\") or declare the key on the component state.`;\n}\n\n/**\n * コンポーネントスコープの内側パスを、親ツリーの絶対パスへ翻訳する(設計書 §4-1)。\n *\n * 1. getter / setter(完全一致・またはワイルドカード getter)→ マーカーパス(chroot 評価)\n * 2. own data key(部分規則が覆わないもの)・メソッド → マーカーパス(私有)\n * 3. それ以外 → 最長接頭辞一致でツリーへ\n * 4. 一致なし: ルートエントリがあれば必ず 3 で一致する。無ければ throw(4b)\n *\n * `$`(予約名前空間・`$1` 等)と `#`(構造プレースホルダ)で始まるパスは翻訳しない。\n */\nconst INDEX_PATH_REGEX = /^\\$(\\d+)$/;\n\n/**\n * `$n` バインディングのスコープ補正量(D9・設計書 §4-4)。\n * 囲む `for` の内側なら「その for パスが翻訳で得たワイルドカード数」— 行マウント\n * (`state: .`)の `for: tags` は `users.*.tags` になり +1、部分マウント\n * `state.items: groups.*.children` の `for: items` も +1。for の外(スコープ直下)は\n * ルート接頭辞の Δ。翻訳がワイルドカードを増やさないマウント(`state: user`)は 0。\n */\nexport function getIndexShiftForScope(record: IMountRecord, forPath: string | undefined): number {\n if (typeof forPath === \"undefined\") {\n return record.delta;\n }\n const translated = translateInnerPath(record, forPath);\n return getPathInfo(translated).wildcardCount - getPathInfo(forPath).wildcardCount;\n}\n\n/**\n * `innerPath` がツリーへ翻訳され、その先のエントリが読み取り専用(`#ro`)か(要件 B14 ①)。\n * 私有キー・アクセサ・`$` / `#` で始まるパスはコンポーネント自身のものなので対象外。\n */\nfunction isReadonlyTreePath(record: IMountRecord, innerPath: string): IMountEntry | null {\n const head = innerPath[0];\n if (head === \"$\" || head === \"#\") return null;\n if (record.getterKeys.has(innerPath) || record.setterKeys.has(innerPath)) return null;\n const first = firstSegmentOf(innerPath);\n if (record.getterKeys.has(first) || record.setterKeys.has(first) || isPrivateAnchor(record, first)) return null;\n const entry = findTreeEntry(record, innerPath.split(DELIMITER));\n return entry !== null && entry.readonly ? entry : null;\n}\n\n/**\n * 書き込みの翻訳(要件 B14 ①)。`translateInnerPath` と同じ行き先を返すが、読み取り専用で\n * マウントされたエントリ(`state#ro: user`)を通るツリーへの書き込みは名指しで拒否する。\n * コンポーネント側の書き込みの入口(`element.state`・オーバーレイ・`$setAll` / `$resolve`)が呼ぶ。\n */\nexport function translateInnerWritePath(record: IMountRecord, innerPath: string): string {\n const readonlyEntry = isReadonlyTreePath(record, innerPath);\n if (readonlyEntry !== null) {\n const suffix = readonlyEntry.innerSegments.length === 0 ? \"\" : DELIMITER + readonlyEntry.innerSegments.join(DELIMITER);\n raiseError(\n `[wcs/mount-readonly] <${record.component.tagName.toLowerCase()}> cannot write \"${innerPath}\": ` +\n `it is mounted read-only (\"${record.stateProp}${suffix}#${MODIFIER_READONLY}: ${readonlyEntry.outerPathInfo.path}\"). ` +\n `Write it on the host, or drop #${MODIFIER_READONLY} from the mount.`,\n );\n }\n return translateInnerPath(record, innerPath);\n}\n\nexport function translateInnerPath(record: IMountRecord, innerPath: string): string {\n const head = innerPath[0];\n if (head === \"$\" || head === \"#\") {\n // `$` の予約名前空間はパスとしては翻訳しない(`$n` のスコープ補正は\n // translateParsedForMount が囲む for の文脈で行う。getter 内の `this.$1` は\n // 親トラップがアクセサの indexShift で補正する)\n return innerPath;\n }\n // 規則 1: 完全一致の getter / setter(`display`・`\"children.*.label\"`)\n if (record.getterKeys.has(innerPath) || record.setterKeys.has(innerPath)) {\n return markerizeAccessorPath(record, innerPath);\n }\n const first = firstSegmentOf(innerPath);\n // 規則 1'/2: 先頭セグメントが getter / setter / メソッド / own data key → マーカー配下\n if (record.getterKeys.has(first) || record.setterKeys.has(first)) {\n return markerizePrivate(record, innerPath);\n }\n if (isPrivateAnchor(record, first)) {\n return markerizePrivate(record, innerPath);\n }\n // 規則 3: ツリー\n const translated = translateTreePath(record, innerPath.split(DELIMITER));\n if (translated !== null) {\n return translated;\n }\n // 規則 4b: 部分マウントのみで一致なし\n raiseError(noMountEntryMessage(record, innerPath));\n}\n\ninterface ITranslatable {\n readonly statePathName: string;\n readonly statePathInfo: IPathInfo;\n}\n\n/**\n * パース結果 / バインディングをマウント先の形へ変換した複製を返す\n * (パース結果キャッシュは触らない)。解決サイト(applyChangeFromBindings /\n * getAbsoluteStateAddressByBinding / fragmentInfoByUUID)は rootNode で\n * state element を引く — スコープ根は台帳エイリアスで親ツリーに到達する。\n */\nexport function translateParsedForMount<T extends ITranslatable>(record: IMountRecord, parsed: T, forPath?: string): T {\n let translated: string;\n const indexMatch = INDEX_PATH_REGEX.exec(parsed.statePathName);\n if (indexMatch !== null) {\n // `$n` はスコープ相対(D9・§4-4): 囲む for の翻訳で増えたワイルドカード数だけ繰り上げる\n const shift = getIndexShiftForScope(record, forPath);\n translated = shift === 0 ? parsed.statePathName : `$${Number(indexMatch[1]) + shift}`;\n } else {\n translated = translateInnerPath(record, parsed.statePathName);\n if ((parsed as { bindingType?: string }).bindingType === \"for\") {\n // スコープ相対の添字(P2-9)用: この for の行に立つループ文脈の要素パスと、\n // 翻訳で増えたワイルドカード数を控える。shift 0(Δ=0 の丸ごとマウント\n // `state: user` や同名翻訳の部分マウント)でも必ず載せる —\n // event/handler.ts は台帳に無いループ文脈を「外側スコープの借用行=\n // 添字 0 本」と解釈するため、登録漏れは自スコープの for の添字を\n // 丸ごと落とす(§4-4 違反)\n const shift = getPathInfo(translated).wildcardCount - parsed.statePathInfo.wildcardCount;\n record.indexShiftByLoopElementPath.set(translated + DELIMITER + WILDCARD, shift);\n }\n }\n // 読み取り専用のマウント(要件 B14 ①)を通る束縛は、要素 → state の書き戻しを止める(`#ro` と同じ)\n const modifiers = (parsed as { propModifiers?: readonly string[] }).propModifiers;\n const forceReadonly = indexMatch === null && Array.isArray(modifiers)\n && !modifiers.includes(MODIFIER_READONLY)\n && isReadonlyTreePath(record, parsed.statePathName) !== null;\n if (translated === parsed.statePathName && !forceReadonly) {\n return parsed;\n }\n return {\n ...parsed,\n statePathName: translated,\n statePathInfo: getPathInfo(translated),\n ...(forceReadonly ? { propModifiers: [...modifiers!, MODIFIER_READONLY] } : {}),\n };\n}\n\nexport function translateBindingForMount(record: IMountRecord, binding: IBindingInfo, forPath?: string): IBindingInfo {\n return translateParsedForMount(record, binding, forPath);\n}\n\n/**\n * マーカーパスのアクセサ評価中の `$n` シフト(トラップの補正が引く)。\n * アクセサとして登録されたパスならその indexShift、そうでなければルートの Δ。\n */\nexport function getIndexShiftForMarkerPath(record: IMountRecord, markerPath: string): number {\n // 末尾マーカーをセグメント単位で正確に切り出す(getMountRecordByPath と同じ規則)。\n // indexOf(record.marker) の前方一致だと `#m2` が別記録の `#m21` の中に誤ヒットし、\n // 親パスをセグメント途中で切って登録簿の照会を外す(Δ への誤フォールバック)\n const hashIndex = markerPath.lastIndexOf(\"#\");\n if (hashIndex === -1) {\n return record.delta;\n }\n const end = markerPath.indexOf(DELIMITER, hashIndex);\n const marker = end === -1 ? markerPath.slice(hashIndex) : markerPath.slice(hashIndex, end);\n if (marker !== record.marker) {\n return record.delta;\n }\n const parent = end === -1 ? markerPath : markerPath.slice(0, end);\n const suffix = end === -1 ? \"\" : markerPath.slice(end + 1);\n const entry = record.accessorBySuffixByMarkerParent.get(parent)?.get(suffix);\n return typeof entry !== \"undefined\" ? entry.indexShift : record.delta;\n}\n\n/**\n * `$getAll` / `$setAll` / `$resolve` の接頭辞翻訳(§4-6 / P2-9): 作者のスコープ相対\n * indexes の先頭に、翻訳で増えたワイルドカード分の文脈添字を合成する。\n * contextIndexes はホスト要素(chroot)またはマーカーアドレス(オーバーレイ)の\n * listIndex 添字列。プレフィックスが増えないパス(Δ=0 の翻訳)は素通し。\n */\nexport function composeMountIndexes(\n record: IMountRecord,\n innerPath: string,\n translatedPath: string,\n indexes: readonly number[] | undefined,\n contextIndexes: readonly number[],\n): readonly number[] | undefined {\n if (typeof indexes === \"undefined\") {\n return undefined;\n }\n const prefixWildcards = getPathInfo(translatedPath).wildcardCount - getPathInfo(innerPath).wildcardCount;\n if (prefixWildcards === 0) {\n return indexes;\n }\n if (contextIndexes.length < prefixWildcards) {\n raiseError(\n `Cannot resolve \"${innerPath}\" from this mount: the mounted prefix has ${prefixWildcards} wildcard(s) ` +\n `but the host context provides only ${contextIndexes.length} index(es).`,\n );\n }\n return [...contextIndexes.slice(0, prefixWildcards), ...indexes];\n}\n\n// ---------------------------------------------------------------------------\n// 登録簿\n// ---------------------------------------------------------------------------\n\n/**\n * スコープ根 → マウント記録。キーは Shadow DOM 形ならコンポーネントの shadowRoot、\n * Light DOM 形ならコンポーネント要素自身(そのサブツリーがスコープ)。\n */\nconst mountRecordByScopeRoot = new WeakMap<Node, IMountRecord>();\n\n/**\n * コンポーネント要素 → stateProp → マウント記録。\n * connectedCallback で shadow の innerHTML を張り直す作りのコンポーネントでは、\n * 再接続のたびに新しい <wcs-state> が同じ shadowRoot に入り、スコープが再初期化される。\n * 記録を要素単位で再利用することでマーカーが安定し、親側の登録簿\n * (byMarker・getterPaths)が再接続のたびに増えない。stateObject はクラスフィールド\n * なので要素と同寿命 — 記録の前提(作者のオブジェクトの同一性)が保たれる。\n */\nconst mountRecordByComponent = new WeakMap<Element, Map<string, IMountRecord>>();\n\n/** 再初期化用: この要素の stateProp に対して登録済みの記録を引く。 */\nexport function getRegisteredMountRecord(component: Element, stateProp: string): IMountRecord | null {\n return mountRecordByComponent.get(component)?.get(stateProp) ?? null;\n}\n\n/**\n * 親 state element → マーカー → マウント記録(オーバーレイ dispatch と Δ 補正が引く)。\n *\n * 値は **WeakRef**(B6)。記録への強参照は要素キーの WeakMap\n * (mountRecordByComponent / mountRecordByScopeRoot)だけが持つので、記録は\n * コンポーネント要素と同寿命になる — プール返却では要素が生きているので記録も生き、\n * 恒久破棄(route swap / `if` で捨てた形)では要素ごと回収可能になる。\n * ここを強参照にすると、長寿命の親 state 要素に破棄済み要素(と Shadow サブツリー)が\n * 際限なく蓄積する。\n */\nconst mountRecordsByStateElement = new WeakMap<IStateElement, Map<string, WeakRef<IMountRecord>>>();\n\n/** FinalizationRegistry の held 値: 記録が回収された後に台帳から掃除するもの。 */\nexport interface ICollectedMountLedgers {\n readonly byMarker: Map<string, WeakRef<IMountRecord>>;\n readonly marker: string;\n readonly getterPaths: Set<string> | undefined;\n readonly addedGetterPaths: ReadonlySet<string>;\n}\n\n/**\n * 恒久破棄されたマウント記録の台帳掃除(FinalizationRegistry のコールバック本体)。\n * マーカーは記録ごとに一意(`#m<id>` 単調増加)なので、発火時点でこのマーカーの\n * エントリは死んだ WeakRef のはず — 生きていれば触らない(防御)。\n * エクスポートしているのは GC を強制できないテスト環境で直接検証するため。\n */\nexport function cleanupCollectedMountRecord(held: ICollectedMountLedgers): void {\n const ref = held.byMarker.get(held.marker);\n if (typeof ref !== \"undefined\" && typeof ref.deref() === \"undefined\") {\n held.byMarker.delete(held.marker);\n }\n if (typeof held.getterPaths !== \"undefined\") {\n for (const path of held.addedGetterPaths) {\n held.getterPaths.delete(path);\n }\n }\n}\n\nconst collectedMountRegistry = new FinalizationRegistry<ICollectedMountLedgers>(cleanupCollectedMountRecord);\n\n/** マウント記録 → スコープ根。行 content をその場で使い回したときの張り直しが引く(#4) */\nconst scopeRootByMountRecord: WeakMap<IMountRecord, Node> = new WeakMap();\n\nexport function getScopeRootByMountRecord(record: IMountRecord): Node | null {\n return scopeRootByMountRecord.get(record) ?? null;\n}\n\n// ループ文脈の探索がマウントされた ShadowRoot でホストへ抜ける受け口(list/loopContextByNode.ts)。\n// 最初の記録の登録で 1 回だけ注入する(マウントの無いページでは探索は境界で止まったまま)\nlet scopeHostInstalled = false;\nfunction installMountedScopeHost(): void {\n if (scopeHostInstalled) return;\n scopeHostInstalled = true;\n setMountedScopeHost((root) => mountRecordByScopeRoot.has(root) ? root.host : null);\n}\n\nexport function registerMountRecord(scopeRoot: Node, record: IMountRecord): void {\n installMountedScopeHost();\n mountRecordByScopeRoot.set(scopeRoot, record);\n scopeRootByMountRecord.set(record, scopeRoot);\n let byMarker = mountRecordsByStateElement.get(record.parentStateElement);\n if (typeof byMarker === \"undefined\") {\n byMarker = new Map();\n mountRecordsByStateElement.set(record.parentStateElement, byMarker);\n }\n byMarker.set(record.marker, new WeakRef(record));\n let byProp = mountRecordByComponent.get(record.component);\n if (typeof byProp === 'undefined') {\n byProp = new Map();\n mountRecordByComponent.set(record.component, byProp);\n }\n const isFirstRegistration = byProp.get(record.stateProp) !== record;\n byProp.set(record.stateProp, record);\n if (isFirstRegistration) {\n // 恒久破棄で台帳(byMarker・親 getterPaths への追加分)を回収する(B6)。\n // 再初期化(同一 record の再登録 — マーカー安定のための再利用)では二重登録しない\n collectedMountRegistry.register(record, {\n byMarker,\n marker: record.marker,\n getterPaths: record.parentStateElement.getterPaths as Set<string> | undefined,\n addedGetterPaths: record.addedGetterPaths,\n });\n }\n // D18: マウントの無い state はオーバーレイ dispatch を boolean 1 個で抜ける\n record.parentStateElement.markHasMounts?.();\n}\n\nexport function getMountRecordByScopeRoot(scopeRoot: Node): IMountRecord | null {\n return mountRecordByScopeRoot.get(scopeRoot) ?? null;\n}\n\n/**\n * ノードから最も近いマウントスコープ根の記録を引く(event/handler.ts のスコープ相対\n * 添字が使う)。Light DOM 形はスコープ根=**コンポーネント要素自身**(D7・\n * mountScope.ts)で rootNode の内側に入れ子になりうる(Shadow 形のスコープの中の\n * Light DOM マウント)ため、**祖先を先に**辿って最初のスコープ根を探す — rootNode\n * 直ヒットを先に返すと外側の記録を取り違える。祖先に無ければ rootNode 自身\n * (Shadow DOM 形のスコープ根=shadowRoot)で引く。入れ子マウントでは\n * 最も内側(=そのノードのバインディングを翻訳した記録)が返る。\n * `hasMounts` が真のときだけ呼ぶこと(無マウントの経路にこの走査を載せない — D18)。\n */\nexport function findMountRecordForNode(node: Node, rootNode: Node): IMountRecord | null {\n let current: Node | null = node;\n while (current !== null && current !== rootNode) {\n const record = mountRecordByScopeRoot.get(current);\n if (typeof record !== \"undefined\") {\n return record;\n }\n current = current.parentNode;\n }\n return mountRecordByScopeRoot.get(rootNode) ?? null;\n}\n\n/** この state element に登録済みのマウント記録を列挙する(devtools の overlays が読む)。 */\nexport function getMountRecordsForStateElement(stateElement: IStateElement): IMountRecord[] {\n const byMarker = mountRecordsByStateElement.get(stateElement);\n if (typeof byMarker === \"undefined\") {\n return [];\n }\n const records: IMountRecord[] = [];\n for (const ref of byMarker.values()) {\n const record = ref.deref();\n if (typeof record !== \"undefined\") {\n records.push(record);\n }\n }\n return records;\n}\n\n/** 親 state element がマウントを 1 つでも持つか(D18: 無ければ dispatch は分岐 1 つで抜ける) */\nexport function stateElementHasMounts(stateElement: IStateElement): boolean {\n const byMarker = mountRecordsByStateElement.get(stateElement);\n return typeof byMarker !== \"undefined\" && byMarker.size > 0;\n}\n\n/**\n * パスに含まれるマーカーからマウント記録を引く。`hasMounts` が真のときだけ呼ぶこと。\n * `#` を含まないパス(圧倒的多数)は lastIndexOf 1 回で抜ける。\n * 入れ子マウント(外側の私有キーの上に内側マウントが載る形)ではパスに複数の\n * マーカーが並ぶ(`users.*.#m1.drafts.#m2`)— オーバーレイ dispatch と $n 補正が\n * 要るのは**末尾**のマーカーの記録なので、先頭でなく最後の `#` で切る\n * (先頭で切ると外側の記録が返り誤翻訳する)。\n */\nexport function getMountRecordByPath(stateElement: IStateElement, path: string): IMountRecord | null {\n const hashIndex = path.lastIndexOf(\"#\");\n if (hashIndex === -1) {\n return null;\n }\n const byMarker = mountRecordsByStateElement.get(stateElement);\n if (typeof byMarker === \"undefined\") {\n return null;\n }\n const end = path.indexOf(DELIMITER, hashIndex);\n const marker = end === -1 ? path.slice(hashIndex) : path.slice(hashIndex, end);\n const ref = byMarker.get(marker);\n if (typeof ref === \"undefined\") {\n return null;\n }\n const record = ref.deref();\n if (typeof record === \"undefined\") {\n // 記録は回収済み(finalizer 発火前の窓)— 遅延 prune\n byMarker.delete(marker);\n return null;\n }\n return record;\n}\n\n/** テスト用: マーカー台帳の WeakRef を差し替える(GC を強制できない環境で死んだ参照を再現する)。 */\nexport function _setMountRecordRefForTesting(\n stateElement: IStateElement,\n marker: string,\n ref: WeakRef<IMountRecord>,\n): void {\n mountRecordsByStateElement.get(stateElement)?.set(marker, ref);\n}\n"],"names":["startsWithSegments","segments","prefix","length","i","findMountEntry","entries","entry","innerSegments","translateByMountEntry","rest","slice","outerPathInfo","path","DELIMITER","join","nextMountId","MOUNT_DOLLAR_DECLARATIONS","STATE_STREAMS_NAME","STATE_UPDATED_CALLBACK_NAME","dollarDeclarationWarned","Set","warnMountedDollarDeclarations","record","declared","filter","name","stateObject","accessor","getterKeys","indexOf","RECURSION_WILDCARD","push","key","component","tagName","toLowerCase","stateProp","has","add","console","warn","split","callMountLifecycleCallback","callback","chroot","result","call","Promise","catch","error","buildMountRecord","bindings","parentStateElement","injectedKeys","raiseError","normalizeDeclarationAliases","seenInnerPaths","rootEntry","binding","propSegments","innerPath","statePathInfo","readonly","propModifiers","includes","MODIFIER_READONLY","sort","a","b","id","marker","setterKeys","descriptors","Object","getOwnPropertyDescriptors","descriptor","get","set","collectAccessorKeys","mappedKeys","privateSnapshot","keys","startsWith","delta","wildcardCount","markerBasePath","accessorBySuffixByMarkerParent","Map","indexShiftByLoopElementPath","addedGetterPaths","exports","firstSegmentOf","dot","translateTreePath","markerizePrivate","recordAccessorSuffix","markerParentPath","suffix","accessorName","bySuffix","translatedPath","indexShift","getPathInfo","getterPaths","isPrivateAnchor","firstSegment","prototype","hasOwnProperty","noMountEntryMessage","e","map","INDEX_PATH_REGEX","isReadonlyTreePath","head","first","findTreeEntry","translateInnerWritePath","readonlyEntry","translateInnerPath","lastWildcard","WILDCARD","treeSegments","translated","markerParent","markerizeAccessorPath","translateParsedForMount","parsed","forPath","indexMatch","exec","statePathName","shift","getIndexShiftForScope","Number","bindingType","modifiers","forceReadonly","Array","isArray","getIndexShiftForMarkerPath","markerPath","hashIndex","lastIndexOf","end","parent","composeMountIndexes","indexes","contextIndexes","prefixWildcards","mountRecordByScopeRoot","WeakMap","mountRecordByComponent","getRegisteredMountRecord","mountRecordsByStateElement","collectedMountRegistry","FinalizationRegistry","held","ref","byMarker","deref","delete","scopeRootByMountRecord","getScopeRootByMountRecord","scopeHostInstalled","registerMountRecord","scopeRoot","setMountedScopeHost","root","host","WeakRef","byProp","isFirstRegistration","register","markHasMounts","getMountRecordByScopeRoot","findMountRecordForNode","node","rootNode","current","parentNode","getMountRecordsForStateElement","stateElement","records","values","stateElementHasMounts","size","getMountRecordByPath"],"mappings":"uMAqBA,SAASA,EAAmBC,EAA6BC,GACvD,GAAIA,EAAOC,OAASF,EAASE,OAAQ,OAAO,EAC5C,IAAK,IAAIC,EAAI,EAAGA,EAAIF,EAAOC,OAAQC,IACjC,GAAIH,EAASG,KAAOF,EAAOE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C1C,QAAsB,IAAX5J,EACT,OAAOA,EAET4J,EAAUA,EAAQC,UACpB,CACA,OAAO9B,EAAuBzE,IAAIqG,IAAa,IACjD,CAGM,SAAUG,EAA+BC,GAC7C,MAAMvB,EAAWL,EAA2B7E,IAAIyG,GAChD,QAAwB,IAAbvB,EACT,MAAO,GAET,MAAMwB,EAA0B,GAChC,IAAK,MAAMzB,KAAOC,EAASyB,SAAU,CACnC,MAAMjK,EAASuI,EAAIE,aACG,IAAXzI,GACTgK,EAAQvJ,KAAKT,EAEjB,CACA,OAAOgK,CACT,CAGM,SAAUE,EAAsBH,GACpC,MAAMvB,EAAWL,EAA2B7E,IAAIyG,GAChD,YAA2B,IAAbvB,GAA4BA,EAAS2B,KAAO,CAC5D,CAUM,SAAUC,EAAqBL,EAA6BzK,GAChE,MAAMiI,EAAYjI,EAAKkI,YAAY,KACnC,IAAkB,IAAdD,EACF,OAAO,KAET,MAAMiB,EAAWL,EAA2B7E,IAAIyG,GAChD,QAAwB,IAAbvB,EACT,OAAO,KAET,MAAMf,EAAMnI,EAAKiB,QAAQhB,EAAWgI,GAC9BvE,GAAiB,IAARyE,EAAanI,EAAKF,MAAMmI,GAAajI,EAAKF,MAAMmI,EAAWE,GACpEc,EAAMC,EAASlF,IAAIN,GACzB,QAAmB,IAARuF,EACT,OAAO,KAET,MAAMvI,EAASuI,EAAIE,QACnB,YAAsB,IAAXzI,GAETwI,EAASE,OAAO1F,GACT,MAEFhD,CACT"}
@@ -1,2 +1,2 @@
1
- import{r as t,L as e,d as a}from"./errorGuidance.js";const s=".",n="*",r=128,i=128,o=32,c=32,l=0,h=10,d=20,u=";",p=":",$="#",w="|",f="prevent",P="stop",m="ro",g="init",y="sync",b="else",v="...",x="on",S="eventToken",I="command",O="class",k="attr",j="style",W="$",A={};for(let t=0;t<128;t++)A[`$${t+1}`]=t;const C=Object.freeze(A),T=6e4,B="http://www.w3.org/2000/svg",q="$connectedCallback",z="$disconnectedCallback",D="$updatedCallback",E="$errorCallback",G="$stateReadyCallback",K="$bindables",L="$commands",M="$commandTokens",N="$command",R="$eventTokens",F="$on",H="$streams",J="$watch",Q="$scan",U="$recursion",V="**",X="$listKeys",Y="$streamStatus",Z="$streamError",_="data-wc-definition",tt=new Map;let et=0;function at(e){let a=tt.get(e);return void 0!==a||(-1!==e.indexOf(V)&&t(`[wcs/recursion-unsupported] "${e}" uses "${V}", which is not accepted here. 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.`),a=Object.freeze(new st(e)),tt.set(e,a)),a}class st{id=++et;path;segments;lastSegment;cumulativePaths;cumulativePathSet;cumulativePathInfos;cumulativePathInfoSet;parentPath;wildcardPaths;wildcardPathSet;indexByWildcardPath;wildcardPathInfos;wildcardPathInfoSet;wildcardParentPaths;wildcardParentPathSet;wildcardParentPathInfos;wildcardParentPathInfoSet;wildcardPositions;lastWildcardPath;lastWildcardInfo;wildcardCount;parentPathInfo;constructor(t){const e=e=>t===e?this:at(e),a=t.split("."),s=[],n=[],r=[],i={},o=[],c=[],l=[],h=[];let d="",u="",p=0;for(let t=0;t<a.length;t++)d+=a[t],"*"===a[t]&&(r.push(d),i[d]=p,o.push(e(d)),c.push(u),l.push(e(u)),h.push(t),p++),s.push(d),n.push(e(d)),u=d,d+=".";const $=r.length>0?r[r.length-1]:null,w=s.length>1?s[s.length-2]:null;this.path=t,this.segments=a,this.lastSegment=a[a.length-1],this.cumulativePaths=s,this.cumulativePathSet=new Set(s),this.cumulativePathInfos=n,this.cumulativePathInfoSet=new Set(n),this.wildcardPaths=r,this.wildcardPathSet=new Set(r),this.indexByWildcardPath=i,this.wildcardPathInfos=o,this.wildcardPathInfoSet=new Set(o),this.wildcardParentPaths=c,this.wildcardParentPathSet=new Set(c),this.wildcardParentPathInfos=l,this.wildcardParentPathInfoSet=new Set(l),this.wildcardPositions=h,this.lastWildcardPath=$,this.lastWildcardInfo=$?e($):null,this.parentPath=w,this.parentPathInfo=w?e(w):null,this.wildcardCount=p}}let nt=null;function rt(t){nt=t}function it(t,e){let a=t;for(;null!==a&&a!==Object.prototype;){const t=Object.getOwnPropertyDescriptor(a,e);if(void 0!==t)return t;a=Object.getPrototypeOf(a)}}function ot(t,e,a){const s=function(t){const e=[];let a=t;for(;null!==a&&a!==Object.prototype;){for(const t of Object.getOwnPropertyNames(a))e.push(t);a=Object.getPrototypeOf(a)}return e}(t),n=e.length>0?e+".":"";for(const t of a){if(n.length>0&&!t.startsWith(n))continue;const e=t.slice(n.length);e.length>0&&-1===e.indexOf(".")&&s.push(e)}return s}const ct={binding:"wcs/binding-path-missing",watch:"wcs/watch-path-missing",scan:"wcs/scan-path-missing"},lt={binding:"Bound path",watch:"$watch path",scan:"$scan path"};function ht(t,s,n){return`[${ct.binding}] Path "${t}" does not exist on the state tree.${a(t,ot(s,"",n))}${e}`}function dt(t,a,s,n){return`[wcs/index-arity] ${t}("${a}") requires ${"$resolve"===t?`exactly ${s}`:`at most ${s}`} index(es) ("*" appears ${s} time(s) in the path) but got ${n}.${e}`}function ut(t,e){return`[wcs/recursion-anchor] "${t}" does not match the declared recursion anchor "${e}". This version supports exactly one anchor per state, and "**" must be followed by a well-formed suffix (no second "**", no empty segment, no bare "*" right after "**").`}function pt(t,e){return`$getAll("${t}") was called without indexes inside the loop context of "${e}", but the path shares no wildcard level with that context, so the context indexes ($1..$n) do not apply. Pass indexes explicitly ([] expands every level).`}function $t(t,e,a){return`$setAll("${t}", …, { spread: true }) requires the values array to have exactly one entry per matched address (matched ${e}) but got ${a}. Did the list change between $getAll and $setAll?`}function wt(t,e){return`$setAll("${t}") ${e}`}function ft(t,a,s){return`[wcs/wildcard-rank] ${t} needs ${a} enclosing loop level(s) but the current scope provides ${s}. Wrap it in that many "for" templates, or use $resolve(path, indexes) to name the row explicitly.${e}`}export{P as $,W as A,it as B,ht as C,s as D,ft as E,dt as F,pt as G,$t as H,C as I,l as J,rt as K,m as L,r as M,T as N,B as O,$ as P,w as Q,V as R,Q as S,p as T,b as U,v as V,n as W,S as X,x as Y,u as Z,f as _,H as a,I as a0,g as a1,y as a2,o as a3,j as a4,k as a5,O as a6,ot as a7,ct as a8,lt as a9,R as b,Y as c,Z as d,d as e,K as f,at as g,L as h,_ as i,G as j,J as k,X as l,U as m,D as n,nt as o,h as p,c as q,ut as r,wt as s,i as t,M as u,N as v,F as w,q as x,z as y,E as z};
1
+ import{r as t,L as e,d as a}from"./errorGuidance.js";const s=".",n="*",r=128,i=128,o=32,c=32,l=0,h=10,d=20,u=";",p=":",$="#",w="|",f="prevent",P="stop",m="ro",g="init",y="sync",b="else",v="...",x="on",S="eventToken",I="state",O="command",k="class",j="attr",W="style",A="$",C={};for(let t=0;t<128;t++)C[`$${t+1}`]=t;const T=Object.freeze(C),B=6e4,q="http://www.w3.org/2000/svg",z="$connectedCallback",D="$disconnectedCallback",E="$renderedCallback",G="$errorCallback",K="$stateReadyCallback",L="$bindables",M="$commands",N="$commandTokens",R="$command",F="$eventTokens",H="$on",J="$stream",Q="$watch",U="$scan",V="$recursion",X="**",Y="$listKeys",Z="$streamStatus",_="$streamError",tt="data-wc-definition",et=new Map;let at=0;function st(e){let a=et.get(e);return void 0!==a||(-1!==e.indexOf(X)&&t(`[wcs/recursion-unsupported] "${e}" uses "${X}", which is not accepted here. 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.`),a=Object.freeze(new nt(e)),et.set(e,a)),a}class nt{id=++at;path;segments;lastSegment;cumulativePaths;cumulativePathSet;cumulativePathInfos;cumulativePathInfoSet;parentPath;wildcardPaths;wildcardPathSet;indexByWildcardPath;wildcardPathInfos;wildcardPathInfoSet;wildcardParentPaths;wildcardParentPathSet;wildcardParentPathInfos;wildcardParentPathInfoSet;wildcardPositions;lastWildcardPath;lastWildcardInfo;wildcardCount;parentPathInfo;constructor(t){const e=e=>t===e?this:st(e),a=t.split("."),s=[],n=[],r=[],i={},o=[],c=[],l=[],h=[];let d="",u="",p=0;for(let t=0;t<a.length;t++)d+=a[t],"*"===a[t]&&(r.push(d),i[d]=p,o.push(e(d)),c.push(u),l.push(e(u)),h.push(t),p++),s.push(d),n.push(e(d)),u=d,d+=".";const $=r.length>0?r[r.length-1]:null,w=s.length>1?s[s.length-2]:null;this.path=t,this.segments=a,this.lastSegment=a[a.length-1],this.cumulativePaths=s,this.cumulativePathSet=new Set(s),this.cumulativePathInfos=n,this.cumulativePathInfoSet=new Set(n),this.wildcardPaths=r,this.wildcardPathSet=new Set(r),this.indexByWildcardPath=i,this.wildcardPathInfos=o,this.wildcardPathInfoSet=new Set(o),this.wildcardParentPaths=c,this.wildcardParentPathSet=new Set(c),this.wildcardParentPathInfos=l,this.wildcardParentPathInfoSet=new Set(l),this.wildcardPositions=h,this.lastWildcardPath=$,this.lastWildcardInfo=$?e($):null,this.parentPath=w,this.parentPathInfo=w?e(w):null,this.wildcardCount=p}}let rt=null;function it(t){rt=t}function ot(t,e){let a=t;for(;null!==a&&a!==Object.prototype;){const t=Object.getOwnPropertyDescriptor(a,e);if(void 0!==t)return t;a=Object.getPrototypeOf(a)}}function ct(t,e,a){const s=function(t){const e=[];let a=t;for(;null!==a&&a!==Object.prototype;){for(const t of Object.getOwnPropertyNames(a))e.push(t);a=Object.getPrototypeOf(a)}return e}(t),n=e.length>0?e+".":"";for(const t of a){if(n.length>0&&!t.startsWith(n))continue;const e=t.slice(n.length);e.length>0&&-1===e.indexOf(".")&&s.push(e)}return s}const lt={binding:"wcs/binding-path-missing",watch:"wcs/watch-path-missing",scan:"wcs/scan-path-missing"},ht={binding:"Bound path",watch:"$watch path",scan:"$scan path"};function dt(t,s,n){return`[${lt.binding}] Path "${t}" does not exist on the state tree.${a(t,ct(s,"",n))}${e}`}function ut(t,a,s,n){return`[wcs/index-arity] ${t}("${a}") requires ${"$resolve"===t?`exactly ${s}`:`at most ${s}`} index(es) ("*" appears ${s} time(s) in the path) but got ${n}.${e}`}function pt(t,e){return`[wcs/recursion-anchor] "${t}" does not match the declared recursion anchor "${e}". This version supports exactly one anchor per state, and "**" must be followed by a well-formed suffix (no second "**", no empty segment, no bare "*" right after "**").`}function $t(t,e){return`$getAll("${t}") was called without indexes inside the loop context of "${e}", but the path shares no wildcard level with that context, so the context indexes ($1..$n) do not apply. Pass indexes explicitly ([] expands every level).`}function wt(t,e,a){return`$setAll("${t}", …, { spread: true }) requires the values array to have exactly one entry per matched address (matched ${e}) but got ${a}. Did the list change between $getAll and $setAll?`}function ft(t,e){return`$setAll("${t}") ${e}`}function Pt(t,a,s){return`[wcs/wildcard-rank] ${t} needs ${a} enclosing loop level(s) but the current scope provides ${s}. Wrap it in that many "for" templates, or use $resolve(path, indexes) to name the row explicitly.${e}`}export{j as $,G as A,A as B,ot as C,s as D,dt as E,Pt as F,ut as G,$t as H,T as I,wt as J,l as K,it as L,r as M,B as N,q as O,$ as P,w as Q,X as R,U as S,p as T,b as U,I as V,n as W,v as X,S as Y,x as Z,k as _,J as a,W as a0,O as a1,u as a2,f as a3,P as a4,g as a5,y as a6,o as a7,ct as a8,lt as a9,ht as aa,F as b,Z as c,_ as d,d as e,L as f,st as g,M as h,tt as i,m as j,K as k,Q as l,Y as m,V as n,E as o,rt as p,h as q,c as r,pt as s,ft as t,i as u,N as v,R as w,H as x,z as y,D as z};
2
2
  //# sourceMappingURL=pathDiagnostics.js.map