@wcstack/state 1.24.0 → 1.26.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
@@ -1,3 +1,22 @@
1
+ /**
2
+ * list/listKeys.ts
3
+ *
4
+ * `$listKeys: { <listPath>: <fieldName | (row) => key> }` 宣言マップを解析し、
5
+ * 「リストパス → キー指定」表を構築する(docs/state-list-key-design.md §3)。
6
+ *
7
+ * この表が存在するリストパスへの配列代入は、setByAddress でキー突合され、
8
+ * 一致行は旧オブジェクトを据え置いたまま変化フィールドだけが per-path 書き込みで
9
+ * 流し込まれる(§2)。未宣言なら書き込み経路は従来と完全に同一。
10
+ *
11
+ * 「そのパスが実際にリストか」は宣言時には判定できない(listPaths は
12
+ * バインディング収集時に確定する)。実行時に配列でなければ経路に入らないだけで、
13
+ * 宣言自体はエラーにしない。
14
+ */
15
+
16
+ /** キー指定: フラットなフィールド名、または行から複合キーを作る関数 */
17
+ type ListKeySpec = string | ((row: any) => unknown);
18
+ type ListKeyMap = ReadonlyMap<string, ListKeySpec>;
19
+
1
20
  /**
2
21
  * Interface for hierarchical loop index management in nested loops.
3
22
  * Tracks parent-child relationships, versions, and provides access to index hierarchy.
@@ -44,6 +63,20 @@ type Mutability = "readonly" | "writable";
44
63
 
45
64
  interface IStateElement {
46
65
  readonly name: string;
66
+ /**
67
+ * state のロードが完了しているか。`initializePromise` の同期版で、
68
+ * DCC のアクセサが「今すぐ読み書きしてよいか」を判断するのに使う。
69
+ * optional なのはテスト用モック互換のため(undefined は「不明=未初期化扱い」)。
70
+ */
71
+ readonly initialized?: boolean;
72
+ /**
73
+ * この state element が今使えるか(= 接続済みで rootNode を保持しているか)。
74
+ * `createState` は rootNode を要求するので、false のときに呼ぶと raiseError する。
75
+ * 台帳に載っていること(登録済み)と使えることは別で、要素をキーにした台帳には
76
+ * 切断済みの state element が残る窓がある(§1.9)。
77
+ * optional なのはテスト用モック互換のため(undefined は「不明=使える扱い」)。
78
+ */
79
+ readonly hasRootNode?: boolean;
47
80
  readonly initializePromise: Promise<void>;
48
81
  readonly connectedCallbackPromise: Promise<void>;
49
82
  readonly listPaths: Set<string>;
@@ -56,7 +89,27 @@ interface IStateElement {
56
89
  readonly version: number;
57
90
  readonly rootNode: Node;
58
91
  readonly boundComponentStateProp: string | null;
92
+ /**
93
+ * `bind-component` で束ねられているコンポーネント要素(親スコープ側のノード)。
94
+ * マッピング規則の引き当てに使う。optional なのはテスト用モック互換のため。
95
+ */
96
+ readonly boundComponent?: Element | null;
97
+ /**
98
+ * この state の実体が innerState proxy(= 値の正本が親スコープの state にある
99
+ * mapped な `bind-component`)か。真のときだけ越境アドレスの受け渡しと
100
+ * リストパスの外向き伝播が働く(§1.8)。
101
+ * optional なのはテスト用モック互換のため(undefined は plain 扱い)。
102
+ */
103
+ readonly hasMappedComponentState?: boolean;
104
+ markComponentStateMapped?(): void;
105
+ /**
106
+ * DCC の `$bindables` から生成した「パス → 変更イベント名」表。
107
+ * 唯一の書き手は defineDCC で、読み手は setByAddress。
108
+ * getter だけを公開して setter をインターフェースから落としていたため
109
+ * defineDCC が具象 State に依存していた(§3.5)。
110
+ */
59
111
  readonly bindableEventMap: Record<string, string>;
112
+ setBindableEventMap(map: Record<string, string>): void;
60
113
  readonly commandTokenNames: ReadonlySet<string>;
61
114
  readonly eventTokenNames: ReadonlySet<string>;
62
115
  /**
@@ -80,6 +133,13 @@ interface IStateElement {
80
133
  */
81
134
  readonly indexDependentGetterPaths?: ReadonlySet<string>;
82
135
  addIndexDependentGetterPath?(path: string): void;
136
+ /**
137
+ * `$listKeys` 宣言から生成した「リストパス → キー指定」表。
138
+ * 宣言が無ければ null / undefined で、setByAddress のキー突合経路に一切入らない
139
+ * (docs/state-list-key-design.md §7-1 のゼロコスト契約)。
140
+ * optional なのはテスト用モック互換のため(undefined は「宣言なし」扱い)。
141
+ */
142
+ readonly listKeys?: ListKeyMap | null;
83
143
  setPathInfo(path: string, bindingType: BindingType): void;
84
144
  addStaticDependency(parentPath: string, childPath: string): boolean;
85
145
  addDynamicDependency(fromPath: string, toPath: string): boolean;