@wcstack/state 1.32.0 → 2.0.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/README.ja.md +194 -37
- package/README.md +193 -37
- package/dist/auto.min.js +1 -1
- package/dist/auto.min.js.map +1 -1
- package/dist/index.d.ts +195 -26
- package/dist/index.esm.js +2711 -1323
- package/dist/index.esm.js.map +1 -1
- package/dist/manifest.d.ts +1 -2
- package/dist/manifest.esm.js +1 -3
- package/dist/parser.d.ts +0 -1
- package/dist/parser.esm.js +8 -7
- package/dist/wcs-manifest.json +0 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -98,14 +98,6 @@ interface IStateElement {
|
|
|
98
98
|
* optional なのはテスト用モック互換のため(undefined は「不明=未初期化扱い」)。
|
|
99
99
|
*/
|
|
100
100
|
readonly initialized?: boolean;
|
|
101
|
-
/**
|
|
102
|
-
* この state element が今使えるか(= 接続済みで rootNode を保持しているか)。
|
|
103
|
-
* `createState` は rootNode を要求するので、false のときに呼ぶと raiseError する。
|
|
104
|
-
* 台帳に載っていること(登録済み)と使えることは別で、要素をキーにした台帳には
|
|
105
|
-
* 切断済みの state element が残る窓がある(§1.9)。
|
|
106
|
-
* optional なのはテスト用モック互換のため(undefined は「不明=使える扱い」)。
|
|
107
|
-
*/
|
|
108
|
-
readonly hasRootNode?: boolean;
|
|
109
101
|
readonly initializePromise: Promise<void>;
|
|
110
102
|
readonly connectedCallbackPromise: Promise<void>;
|
|
111
103
|
readonly listPaths: Set<string>;
|
|
@@ -122,15 +114,34 @@ interface IStateElement {
|
|
|
122
114
|
* `bind-component` で束ねられているコンポーネント要素(親スコープ側のノード)。
|
|
123
115
|
* マッピング規則の引き当てに使う。optional なのはテスト用モック互換のため。
|
|
124
116
|
*/
|
|
125
|
-
readonly boundComponent?: Element | null;
|
|
126
117
|
/**
|
|
127
118
|
* この state の実体が innerState proxy(= 値の正本が親スコープの state にある
|
|
128
119
|
* mapped な `bind-component`)か。真のときだけ越境アドレスの受け渡しと
|
|
129
120
|
* リストパスの外向き伝播が働く(§1.8)。
|
|
130
121
|
* optional なのはテスト用モック互換のため(undefined は plain 扱い)。
|
|
131
122
|
*/
|
|
132
|
-
|
|
133
|
-
|
|
123
|
+
/**
|
|
124
|
+
* この state element にマウント(Phase 2 の単一ツリー — webComponent/mount.ts)が
|
|
125
|
+
* 1 つでも登録されているか。偽のとき getByAddress / isCacheable / `$n` 補正は
|
|
126
|
+
* boolean 判定 1 個でオーバーレイ経路を抜ける(設計書 D18)。
|
|
127
|
+
* optional なのはテスト用モック互換のため(undefined は「マウント無し」扱い)。
|
|
128
|
+
*/
|
|
129
|
+
readonly hasMounts?: boolean;
|
|
130
|
+
markHasMounts?(): void;
|
|
131
|
+
/**
|
|
132
|
+
* この state element に接ぎ木済みのボリューム(`mount=` — webComponent/volume.ts)が
|
|
133
|
+
* 1 つでもあるか。偽のとき setByAddress の D22 後段ガード(マウントポイントを含む
|
|
134
|
+
* 親の丸ごと書き検査)は boolean 判定 1 個で抜ける(設計書 D18 と同じ形)。
|
|
135
|
+
* optional なのはテスト用モック互換のため(undefined は「ボリューム無し」扱い)。
|
|
136
|
+
*/
|
|
137
|
+
readonly hasGraftedVolumes?: boolean;
|
|
138
|
+
markHasGraftedVolumes?(): void;
|
|
139
|
+
/**
|
|
140
|
+
* この state 要素に束ねられた(`setPathInfo` を通った)パスの集合。丸ごとマウント
|
|
141
|
+
* (ルート規則)の親→子通知が「登録済みパス全部を読み直せ」を組み立てるのに使う
|
|
142
|
+
* (webComponent/rootReloadPaths.ts)。
|
|
143
|
+
* optional なのはテスト用モック互換のため(undefined は「登録なし」扱い)。
|
|
144
|
+
*/
|
|
134
145
|
/**
|
|
135
146
|
* DCC の `$bindables` から生成した「パス → 変更イベント名」表。
|
|
136
147
|
* 唯一の書き手は defineDCC で、読み手は setByAddress。
|
|
@@ -184,13 +195,20 @@ interface IStateElement {
|
|
|
184
195
|
* `source` は存在検査の診断 code と適用範囲を決める(pathDiagnostics.ts)。
|
|
185
196
|
* 省略時は `"binding"`(テスト用モック互換のため optional)。
|
|
186
197
|
*/
|
|
198
|
+
/** ボリュームの宣言面の合流(webComponent/volume.ts 専用・実装は State のみ) */
|
|
199
|
+
addVolumeWatchPaths?(paths: ReadonlySet<string>): void;
|
|
200
|
+
mergeVolumeListKeys?(entries: ReadonlyMap<string, ListKeySpec>): void;
|
|
201
|
+
enableUpdatedCallback?(): void;
|
|
202
|
+
/** enable-ssr スナップショットから初期化されたか(D14)。 */
|
|
203
|
+
readonly hydratedFromSsr?: boolean;
|
|
204
|
+
/** ボリュームのアクセサ登録(webComponent/volume.ts 専用) */
|
|
205
|
+
defineTreeAccessor(path: string, descriptor: PropertyDescriptor): void;
|
|
187
206
|
setPathInfo(path: string, bindingType: BindingType, source?: PathInfoSource): void;
|
|
188
207
|
addStaticDependency(parentPath: string, childPath: string): boolean;
|
|
189
208
|
addDynamicDependency(fromPath: string, toPath: string): boolean;
|
|
190
209
|
createStateAsync(mutability: Mutability, callback: (state: IStateProxy) => Promise<void>): Promise<void>;
|
|
191
210
|
createState(mutability: Mutability, callback: (state: IStateProxy) => void): void;
|
|
192
211
|
nextVersion(): number;
|
|
193
|
-
bindProperty(prop: string, desc: PropertyDescriptor): void;
|
|
194
212
|
setInitialState(state: Record<string, any>): void;
|
|
195
213
|
}
|
|
196
214
|
|
|
@@ -225,7 +243,6 @@ interface IStateAddress {
|
|
|
225
243
|
readonly parentAddress: IStateAddress | null;
|
|
226
244
|
}
|
|
227
245
|
interface IAbsolutePathInfo {
|
|
228
|
-
readonly stateName: string;
|
|
229
246
|
readonly stateElement: IStateElement;
|
|
230
247
|
readonly pathInfo: IPathInfo;
|
|
231
248
|
readonly parentAbsolutePathInfo: IAbsolutePathInfo | null;
|
|
@@ -269,7 +286,6 @@ interface IParsedBinding {
|
|
|
269
286
|
readonly propModifiers: string[];
|
|
270
287
|
readonly statePathName: string;
|
|
271
288
|
readonly statePathInfo: IPathInfo;
|
|
272
|
-
readonly stateName: string;
|
|
273
289
|
readonly inFilters: IFilterInfo[];
|
|
274
290
|
readonly outFilters: IFilterInfo[];
|
|
275
291
|
readonly bindingType: BindingType;
|
|
@@ -364,7 +380,6 @@ declare function getBindingsReady(rootNode: Node): Promise<void>;
|
|
|
364
380
|
declare const HTMLElementBase: typeof HTMLElement;
|
|
365
381
|
|
|
366
382
|
interface ISsrElement {
|
|
367
|
-
readonly name: string;
|
|
368
383
|
readonly version: string;
|
|
369
384
|
readonly stateData: IState;
|
|
370
385
|
readonly templates: Map<string, HTMLTemplateElement>;
|
|
@@ -376,7 +391,6 @@ declare class Ssr extends HTMLElementBase implements ISsrElement {
|
|
|
376
391
|
private _stateData;
|
|
377
392
|
private _templates;
|
|
378
393
|
private _hydrateProps;
|
|
379
|
-
get name(): string;
|
|
380
394
|
get version(): string;
|
|
381
395
|
get stateData(): IState;
|
|
382
396
|
get templates(): Map<string, HTMLTemplateElement>;
|
|
@@ -393,7 +407,7 @@ declare class Ssr extends HTMLElementBase implements ISsrElement {
|
|
|
393
407
|
private _loadStateData;
|
|
394
408
|
private _loadTemplates;
|
|
395
409
|
private _loadHydrateProps;
|
|
396
|
-
static
|
|
410
|
+
static find(root: Node): ISsrElement | null;
|
|
397
411
|
/**
|
|
398
412
|
* stateData と構造テンプレート・プロパティから <wcs-ssr> の中身を構築する。
|
|
399
413
|
* server パッケージの renderToString から呼ばれる。
|
|
@@ -751,12 +765,11 @@ interface IWcsManifest {
|
|
|
751
765
|
pathDelimiter: string;
|
|
752
766
|
/** ワイルドカード(`*`) */
|
|
753
767
|
wildcard: string;
|
|
754
|
-
/** バインディング構文 `[prop][#mod]: [path][
|
|
768
|
+
/** バインディング構文 `[prop][#mod]: [path][|filter...]` の区切り文字 */
|
|
755
769
|
delimiters: {
|
|
756
770
|
binding: string;
|
|
757
771
|
propValue: string;
|
|
758
772
|
modifier: string;
|
|
759
|
-
stateName: string;
|
|
760
773
|
filter: string;
|
|
761
774
|
};
|
|
762
775
|
/** 構造ディレクティブ(`<template data-wcs="for: ...">` 等) */
|
|
@@ -821,12 +834,10 @@ declare function getWcsManifest(): IWcsManifest;
|
|
|
821
834
|
|
|
822
835
|
type DevtoolsEvent = {
|
|
823
836
|
readonly type: "state:element-registered";
|
|
824
|
-
readonly name: string;
|
|
825
837
|
readonly rootNode: Node;
|
|
826
838
|
readonly element: IStateElement;
|
|
827
839
|
} | {
|
|
828
840
|
readonly type: "state:element-unregistered";
|
|
829
|
-
readonly name: string;
|
|
830
841
|
readonly rootNode: Node;
|
|
831
842
|
readonly element: IStateElement;
|
|
832
843
|
} | {
|
|
@@ -853,7 +864,6 @@ type DevtoolsEvent = {
|
|
|
853
864
|
} | {
|
|
854
865
|
readonly type: "state:token-emit";
|
|
855
866
|
readonly kind: "command" | "event";
|
|
856
|
-
readonly stateName: string | null;
|
|
857
867
|
readonly tokenName: string;
|
|
858
868
|
readonly args: readonly unknown[];
|
|
859
869
|
readonly subscriberCount: number;
|
|
@@ -861,7 +871,6 @@ type DevtoolsEvent = {
|
|
|
861
871
|
readonly type: "state:watch-error";
|
|
862
872
|
/** throw 元。cur の評価(getter)とハンドラ本体では原因も直し方も違う */
|
|
863
873
|
readonly phase: "prime" | "evaluate" | "handler";
|
|
864
|
-
readonly stateName: string;
|
|
865
874
|
/** `$watch` の宣言キー(ワイルドカードを含む生のパス) */
|
|
866
875
|
readonly path: string;
|
|
867
876
|
readonly error: unknown;
|
|
@@ -872,21 +881,18 @@ type DevtoolsEvent = {
|
|
|
872
881
|
readonly paths: readonly string[];
|
|
873
882
|
} | {
|
|
874
883
|
readonly type: "state:watch-fired";
|
|
875
|
-
readonly stateName: string;
|
|
876
884
|
/** `$watch` の宣言キー(ワイルドカードを含む生のパス) */
|
|
877
885
|
readonly path: string;
|
|
878
886
|
} | {
|
|
879
887
|
readonly type: "state:path-unresolved";
|
|
880
888
|
/** 書き手が書いた面。診断 code が binding / watch で変わる */
|
|
881
889
|
readonly source: "binding" | "watch";
|
|
882
|
-
readonly stateName: string;
|
|
883
890
|
/** 宣言されたパス(ワイルドカードを含む生の文字列) */
|
|
884
891
|
readonly path: string;
|
|
885
892
|
/** 解決に失敗したセグメント */
|
|
886
893
|
readonly missingSegment: string;
|
|
887
894
|
} | {
|
|
888
895
|
readonly type: "state:binding-apply-error";
|
|
889
|
-
readonly stateName: string;
|
|
890
896
|
/** バインディングの state パス(ワイルドカードを含む生の文字列) */
|
|
891
897
|
readonly path: string;
|
|
892
898
|
readonly bindingType: string;
|
|
@@ -979,5 +985,168 @@ interface IContractManifest {
|
|
|
979
985
|
*/
|
|
980
986
|
declare function analyzeContract(manifest: IContractManifest): readonly ContractEvent[];
|
|
981
987
|
|
|
988
|
+
declare class State extends HTMLElementBase implements IStateElement {
|
|
989
|
+
static hasConnectedCallbackPromise: boolean;
|
|
990
|
+
static getBindingsReady(rootNode: Node): Promise<void>;
|
|
991
|
+
private __state;
|
|
992
|
+
private _hasUpdatedCallback;
|
|
993
|
+
/** enable-ssr のスナップショットから初期化された(D14: ボリュームはデータを採用する) */
|
|
994
|
+
private _hydratedFromSsr;
|
|
995
|
+
private _crossRowListPaths;
|
|
996
|
+
private _indexDependentGetterPaths;
|
|
997
|
+
private _name;
|
|
998
|
+
private _initialized;
|
|
999
|
+
private _initializePromise;
|
|
1000
|
+
private _resolveInitialize;
|
|
1001
|
+
private _connectedCallbackPromise;
|
|
1002
|
+
private _resolveConnectedCallback;
|
|
1003
|
+
private _rejectConnectedCallback;
|
|
1004
|
+
private _loadingPromise;
|
|
1005
|
+
private _resolveLoading;
|
|
1006
|
+
private _setStatePromise;
|
|
1007
|
+
private _resolveSetState;
|
|
1008
|
+
private _listPaths;
|
|
1009
|
+
private _listKeys;
|
|
1010
|
+
private _elementPaths;
|
|
1011
|
+
private _getterPaths;
|
|
1012
|
+
private _setterPaths;
|
|
1013
|
+
private _loopContextStack;
|
|
1014
|
+
private _dynamicDependency;
|
|
1015
|
+
private _staticDependency;
|
|
1016
|
+
private _pathSet;
|
|
1017
|
+
private _watchPaths;
|
|
1018
|
+
private _version;
|
|
1019
|
+
private _rootNode;
|
|
1020
|
+
private _boundComponent;
|
|
1021
|
+
private _boundComponentStateProp;
|
|
1022
|
+
private _hasMounts;
|
|
1023
|
+
private _hasGraftedVolumes;
|
|
1024
|
+
/** ボリューム(mount=): 接ぎ木済みの控え($disconnectedCallback 用) */
|
|
1025
|
+
private _volumeGraftInfo;
|
|
1026
|
+
/** ボリューム: スロット予約済み・接ぎ木進行中(ロード完了前の再接続の再入ガード) */
|
|
1027
|
+
private _volumeInitializing;
|
|
1028
|
+
/** v2 マウント(Phase 2): この bind-component 要素が構築したマウント記録 */
|
|
1029
|
+
private _mountRecord;
|
|
1030
|
+
private _bindableEventMap;
|
|
1031
|
+
private _commandTokenNames;
|
|
1032
|
+
private _eventTokenNames;
|
|
1033
|
+
private _dcc;
|
|
1034
|
+
private _connectGeneration;
|
|
1035
|
+
private _streamsStartedGeneration;
|
|
1036
|
+
constructor();
|
|
1037
|
+
private get _state();
|
|
1038
|
+
private set _state(value);
|
|
1039
|
+
get name(): string;
|
|
1040
|
+
private _loadFromSsrElement;
|
|
1041
|
+
/** state / src / json / inner <script> / API set のソース解決(_initialize とボリュームで共用)。 */
|
|
1042
|
+
private _loadStateFromSource;
|
|
1043
|
+
/**
|
|
1044
|
+
* ボリューム(`<wcs-state mount="path">`): 独立ツリーを持たず、ロード完了で
|
|
1045
|
+
* ルートに接ぎ木する(webComponent/volume.ts)。接続時にスロットを予約(D22)。
|
|
1046
|
+
* ルートより先に接続されてもよい — ルート登録が保留分を引き取る(V5)。
|
|
1047
|
+
*/
|
|
1048
|
+
private _initializeVolume;
|
|
1049
|
+
private _initialize;
|
|
1050
|
+
/**
|
|
1051
|
+
* 設定エラーでの fail-fast。initializePromise 等を解決してから raise する —
|
|
1052
|
+
* 未解決のまま投げると waitForStateInitialize(ホストの buildBindings)が
|
|
1053
|
+
* この要素を待ち続け、**ページ全体が無言でウェッジする**(1 つの設定ミスが
|
|
1054
|
+
* 無関係なバインディングまで道連れにする)。エラー自体は unhandled rejection
|
|
1055
|
+
* として loud に残る。
|
|
1056
|
+
*/
|
|
1057
|
+
private _failInitialization;
|
|
1058
|
+
private _initializeBindWebComponent;
|
|
1059
|
+
private _callStateConnectedCallback;
|
|
1060
|
+
private _initializeDCC;
|
|
1061
|
+
private _callStateDisconnectedCallback;
|
|
1062
|
+
connectedCallback(): Promise<void>;
|
|
1063
|
+
disconnectedCallback(): void;
|
|
1064
|
+
get initialized(): boolean;
|
|
1065
|
+
get initializePromise(): Promise<void>;
|
|
1066
|
+
get connectedCallbackPromise(): Promise<void>;
|
|
1067
|
+
get listPaths(): Set<string>;
|
|
1068
|
+
get listKeys(): ListKeyMap | null;
|
|
1069
|
+
get watchPaths(): ReadonlySet<string> | null;
|
|
1070
|
+
get elementPaths(): Set<string>;
|
|
1071
|
+
/**
|
|
1072
|
+
* ボリューム(webComponent/volume.ts)のアクセサ登録: ツリーパスをキーにした
|
|
1073
|
+
* quoted-path アクセサを state オブジェクトに定義し、getter / setter 台帳と
|
|
1074
|
+
* 依存グラフに載せる。ルートのワイルドカード getter(`"children.*.label"`)と
|
|
1075
|
+
* 同じ機構に乗るので、評価は pushAddress 下・依存はグラフに載る。
|
|
1076
|
+
*/
|
|
1077
|
+
/** ボリュームの watch パスをホットパス用ゲート(watchPaths)へ合流させる。 */
|
|
1078
|
+
addVolumeWatchPaths(paths: ReadonlySet<string>): void;
|
|
1079
|
+
/** ボリュームの $listKeys(接頭辞翻訳済み)をルートの表へ合流させる。衝突は設定ミス。 */
|
|
1080
|
+
mergeVolumeListKeys(entries: ReadonlyMap<string, ListKeySpec>): void;
|
|
1081
|
+
/** ボリュームが $updatedCallback を持つとき、収集ゲートを開ける(apply/applyChange.ts)。 */
|
|
1082
|
+
enableUpdatedCallback(): void;
|
|
1083
|
+
/** enable-ssr スナップショットから初期化されたか(D14 — webComponent/volume.ts が読む)。 */
|
|
1084
|
+
get hydratedFromSsr(): boolean;
|
|
1085
|
+
defineTreeAccessor(path: string, descriptor: PropertyDescriptor): void;
|
|
1086
|
+
get getterPaths(): Set<string>;
|
|
1087
|
+
get setterPaths(): Set<string>;
|
|
1088
|
+
get loopContextStack(): ILoopContextStack;
|
|
1089
|
+
get dynamicDependency(): Map<string, string[]>;
|
|
1090
|
+
get staticDependency(): Map<string, string[]>;
|
|
1091
|
+
get version(): number;
|
|
1092
|
+
get rootNode(): Node;
|
|
1093
|
+
get boundComponentStateProp(): string | null;
|
|
1094
|
+
get hasMounts(): boolean;
|
|
1095
|
+
/** 唯一の呼び手は webComponent/mount.ts の registerMountRecord(Phase 2)。 */
|
|
1096
|
+
markHasMounts(): void;
|
|
1097
|
+
get hasGraftedVolumes(): boolean;
|
|
1098
|
+
/** 唯一の呼び手は webComponent/volume.ts の graftVolume(D22 後段のガードが読む)。 */
|
|
1099
|
+
markHasGraftedVolumes(): void;
|
|
1100
|
+
get bindableEventMap(): Record<string, string>;
|
|
1101
|
+
get commandTokenNames(): ReadonlySet<string>;
|
|
1102
|
+
get eventTokenNames(): ReadonlySet<string>;
|
|
1103
|
+
setBindableEventMap(map: Record<string, string>): void;
|
|
1104
|
+
private _addDependency;
|
|
1105
|
+
/**
|
|
1106
|
+
* source, target
|
|
1107
|
+
*
|
|
1108
|
+
* products.*.price => products.*.tax
|
|
1109
|
+
* get "products.*.tax"() { return this["products.*.price"] * 0.1; }
|
|
1110
|
+
*
|
|
1111
|
+
* products.*.price => products.summary
|
|
1112
|
+
* get "products.summary"() { return this.$getAll("products.*.price", []).reduce(sum); }
|
|
1113
|
+
*
|
|
1114
|
+
* categories.*.name => categories.*.products.*.categoryName
|
|
1115
|
+
* get "categories.*.products.*.categoryName"() { return this["categories.*.name"]; }
|
|
1116
|
+
*
|
|
1117
|
+
* @param sourcePath
|
|
1118
|
+
* @param targetPath
|
|
1119
|
+
*/
|
|
1120
|
+
addDynamicDependency(sourcePath: string, targetPath: string): boolean;
|
|
1121
|
+
/**
|
|
1122
|
+
* source, target
|
|
1123
|
+
* products => products.*
|
|
1124
|
+
* products.* => products.*.price
|
|
1125
|
+
* products.* => products.*.name
|
|
1126
|
+
*
|
|
1127
|
+
* @param sourcePath
|
|
1128
|
+
* @param targetPath
|
|
1129
|
+
*/
|
|
1130
|
+
addStaticDependency(sourcePath: string, targetPath: string): boolean;
|
|
1131
|
+
setPathInfo(path: string, bindingType: BindingType, source?: PathInfoSource): void;
|
|
1132
|
+
private _createState;
|
|
1133
|
+
createStateAsync(mutability: Mutability, callback: (state: IStateProxy) => Promise<void>): Promise<void>;
|
|
1134
|
+
createState(mutability: Mutability, callback: (state: IStateProxy) => void): void;
|
|
1135
|
+
nextVersion(): number;
|
|
1136
|
+
get hasUpdatedCallback(): boolean;
|
|
1137
|
+
get crossRowListPaths(): ReadonlySet<string>;
|
|
1138
|
+
addCrossRowListPath(path: string): void;
|
|
1139
|
+
get indexDependentGetterPaths(): ReadonlySet<string>;
|
|
1140
|
+
addIndexDependentGetterPath(path: string): void;
|
|
1141
|
+
setInitialState(state: Record<string, any>): void;
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
declare global {
|
|
1145
|
+
interface HTMLElementTagNameMap {
|
|
1146
|
+
"wcs-state": State;
|
|
1147
|
+
"wcs-ssr": Ssr;
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
|
|
982
1151
|
export { Ssr, VERSION, WCS_MANIFEST_VERSION, analyzeContract, bootstrapState, buildBindings, builtinFilterMeta, defineState, getBindingsReady, getConfig, getWcsManifest };
|
|
983
1152
|
export type { ContractEvent, FilterArgType, FilterResultType, IContractManifest, IFilterMeta, ISsrElement, IWcsManifest, IWritableConfig, IWritableTagNames, WcsPathValue, WcsPaths, WcsStateApi, WcsThis };
|