@wcstack/state 1.30.0 → 1.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -42,6 +42,35 @@ interface ILoopContextStack {
42
42
  createLoopContext(elementStateAddress: IStateAddress, callback: (loopContext: ILoopContext) => void | Promise<void>): void | Promise<void>;
43
43
  }
44
44
 
45
+ /**
46
+ * pathDiagnostics.ts — バインド / `$watch` 対象パスの存在検査(silent failure の可視化)。
47
+ *
48
+ * なぜ必要か:
49
+ * `getByAddress` は「親が null / undefined のパスの読み」を undefined で返し、
50
+ * undefined はプロパティ書き込みがスキップされる値なので、`user.nmae` のような
51
+ * 打ち間違いは**エラーも警告も出さずに DOM が更新されない**だけになる。一方で
52
+ * トップレベルの打ち間違い(`cout`)は parentAddress を辿れず raiseError で落ちる。
53
+ * 同じ「パスを打ち間違えた」という 1 つの失敗が、パスの深さで silent / loud に
54
+ * 割れており、書き手からは区別がつかない。ここはその silent 側を埋める。
55
+ *
56
+ * 精度方針(過小近似):
57
+ * 「確実に存在しない」と言い切れる場合にだけ報告する。getter の戻り値の先・
58
+ * 空配列・null 親・mapped な `bind-component` など、静的に決められない形はすべて
59
+ * `"unknown"` に倒して黙る(偽陽性ゼロ優先。docs/static-wiring-dx-design.md D7 /
60
+ * [ADR-06](../../docs/architecture-hardening/06-path-type-safety.md) の精度哲学)。
61
+ *
62
+ * 診断 code はコンソール → lint → IDE の三面で共有する(errorGuidance.ts の規約)。
63
+ */
64
+
65
+ /** `setPathInfo` の呼び出し元の種別。診断 code と適用範囲がこれで変わる */
66
+ type PathInfoSource =
67
+ /** data-wcs / mustache / コメントバインディング */
68
+ "binding"
69
+ /** `$watch` の宣言キー */
70
+ | "watch"
71
+ /** ランタイム内部のパス翻訳(mapped な bind-component の外向き伝播)。検査しない */
72
+ | "internal";
73
+
45
74
  declare const setLoopContextSymbol: unique symbol;
46
75
  declare const getByAddressSymbol: unique symbol;
47
76
  declare const hasByAddressSymbol: unique symbol;
@@ -151,8 +180,11 @@ interface IStateElement {
151
180
  * パスを依存グラフへ登録する。DOM バインディング登録(BindingSession)のほか、
152
181
  * `$watch` 宣言(processWatchDeclaration)からも呼ばれる — 静的依存グラフに
153
182
  * 載るのがバインド済みパスだけだと headless 購読が成立しないため(設計書 §8)。
183
+ *
184
+ * `source` は存在検査の診断 code と適用範囲を決める(pathDiagnostics.ts)。
185
+ * 省略時は `"binding"`(テスト用モック互換のため optional)。
154
186
  */
155
- setPathInfo(path: string, bindingType: BindingType): void;
187
+ setPathInfo(path: string, bindingType: BindingType, source?: PathInfoSource): void;
156
188
  addStaticDependency(parentPath: string, childPath: string): boolean;
157
189
  addDynamicDependency(fromPath: string, toPath: string): boolean;
158
190
  createStateAsync(mutability: Mutability, callback: (state: IStateProxy) => Promise<void>): Promise<void>;
@@ -315,7 +347,7 @@ interface IWritableConfig {
315
347
  sameValueGuard?: boolean;
316
348
  }
317
349
 
318
- declare function bootstrapState(config?: IWritableConfig): void;
350
+ declare function bootstrapState(config?: IWritableConfig, registry?: CustomElementRegistry): void;
319
351
 
320
352
  declare function getConfig(): IConfig;
321
353
 
@@ -812,6 +844,22 @@ type DevtoolsEvent = {
812
844
  readonly stateName: string;
813
845
  /** `$watch` の宣言キー(ワイルドカードを含む生のパス) */
814
846
  readonly path: string;
847
+ } | {
848
+ readonly type: "state:path-unresolved";
849
+ /** 書き手が書いた面。診断 code が binding / watch で変わる */
850
+ readonly source: "binding" | "watch";
851
+ readonly stateName: string;
852
+ /** 宣言されたパス(ワイルドカードを含む生の文字列) */
853
+ readonly path: string;
854
+ /** 解決に失敗したセグメント */
855
+ readonly missingSegment: string;
856
+ } | {
857
+ readonly type: "state:binding-apply-error";
858
+ readonly stateName: string;
859
+ /** バインディングの state パス(ワイルドカードを含む生の文字列) */
860
+ readonly path: string;
861
+ readonly bindingType: string;
862
+ readonly error: unknown;
815
863
  } | {
816
864
  readonly type: "propagation:suppressed";
817
865
  readonly reason: "confirmation" | "visited-edge";