@wcstack/state 1.32.0 → 1.33.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 +164 -0
- package/README.md +164 -0
- package/dist/auto.min.js +1 -1
- package/dist/auto.min.js.map +1 -1
- package/dist/index.d.ts +172 -0
- package/dist/index.esm.js +508 -39
- package/dist/index.esm.js.map +1 -1
- package/dist/parser.esm.js +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -131,6 +131,13 @@ interface IStateElement {
|
|
|
131
131
|
*/
|
|
132
132
|
readonly hasMappedComponentState?: boolean;
|
|
133
133
|
markComponentStateMapped?(): void;
|
|
134
|
+
/**
|
|
135
|
+
* この state 要素に束ねられた(`setPathInfo` を通った)パスの集合。丸ごとマウント
|
|
136
|
+
* (ルート規則)の親→子通知が「登録済みパス全部を読み直せ」を組み立てるのに使う
|
|
137
|
+
* (webComponent/rootReloadPaths.ts)。
|
|
138
|
+
* optional なのはテスト用モック互換のため(undefined は「登録なし」扱い)。
|
|
139
|
+
*/
|
|
140
|
+
readonly boundPaths?: ReadonlySet<string>;
|
|
134
141
|
/**
|
|
135
142
|
* DCC の `$bindables` から生成した「パス → 変更イベント名」表。
|
|
136
143
|
* 唯一の書き手は defineDCC で、読み手は setByAddress。
|
|
@@ -979,5 +986,170 @@ interface IContractManifest {
|
|
|
979
986
|
*/
|
|
980
987
|
declare function analyzeContract(manifest: IContractManifest): readonly ContractEvent[];
|
|
981
988
|
|
|
989
|
+
declare class State extends HTMLElementBase implements IStateElement {
|
|
990
|
+
static hasConnectedCallbackPromise: boolean;
|
|
991
|
+
static getBindingsReady(rootNode: Node): Promise<void>;
|
|
992
|
+
private __state;
|
|
993
|
+
private _hasUpdatedCallback;
|
|
994
|
+
private _crossRowListPaths;
|
|
995
|
+
private _indexDependentGetterPaths;
|
|
996
|
+
private _name;
|
|
997
|
+
private _initialized;
|
|
998
|
+
private _initializePromise;
|
|
999
|
+
private _resolveInitialize;
|
|
1000
|
+
private _connectedCallbackPromise;
|
|
1001
|
+
private _resolveConnectedCallback;
|
|
1002
|
+
private _rejectConnectedCallback;
|
|
1003
|
+
private _loadingPromise;
|
|
1004
|
+
private _resolveLoading;
|
|
1005
|
+
private _setStatePromise;
|
|
1006
|
+
private _resolveSetState;
|
|
1007
|
+
private _listPaths;
|
|
1008
|
+
private _listKeys;
|
|
1009
|
+
private _elementPaths;
|
|
1010
|
+
private _getterPaths;
|
|
1011
|
+
private _setterPaths;
|
|
1012
|
+
private _loopContextStack;
|
|
1013
|
+
private _dynamicDependency;
|
|
1014
|
+
private _staticDependency;
|
|
1015
|
+
private _pathSet;
|
|
1016
|
+
private _watchPaths;
|
|
1017
|
+
private _version;
|
|
1018
|
+
private _rootNode;
|
|
1019
|
+
private _boundComponent;
|
|
1020
|
+
private _boundComponentStateProp;
|
|
1021
|
+
private _hasMappedComponentState;
|
|
1022
|
+
private _bindableEventMap;
|
|
1023
|
+
private _commandTokenNames;
|
|
1024
|
+
private _eventTokenNames;
|
|
1025
|
+
private _dcc;
|
|
1026
|
+
private _connectGeneration;
|
|
1027
|
+
private _streamsStartedGeneration;
|
|
1028
|
+
constructor();
|
|
1029
|
+
private get _state();
|
|
1030
|
+
private set _state(value);
|
|
1031
|
+
get name(): string;
|
|
1032
|
+
private _loadFromSsrElement;
|
|
1033
|
+
private _initialize;
|
|
1034
|
+
private _initializeBindWebComponent;
|
|
1035
|
+
/**
|
|
1036
|
+
* Light DOM の mapped コンポーネントが、自分のサブツリーのバインディングを張る(§1.13)。
|
|
1037
|
+
*
|
|
1038
|
+
* Shadow DOM 形では子スコープが別 rootNode にあり、`setStateElementByName` の初回登録から
|
|
1039
|
+
* その root ぶんの `buildBindings` が別パスとして起動する。Light DOM ではホストと同じ root に
|
|
1040
|
+
* いるためそのパスが存在せず、かといってホストのパスに混ぜると `@name` の解決が
|
|
1041
|
+
* この要素の名前登録より先に来てしまう。そこで `getSubscriberNodes` がホスト側の走査から
|
|
1042
|
+
* このサブツリーを外し、名前登録が済んだここで同じことを自前で行う。
|
|
1043
|
+
*
|
|
1044
|
+
* `{{ }}` の変換だけはホストのパスが root 全体に対して済ませている(純粋にテキスト操作で
|
|
1045
|
+
* state に依存しないため)。構造フラグメントの収集は fragment info を rootNode + state 名で
|
|
1046
|
+
* 登録するので state 依存であり、ホストのパスからは外してここで走らせる。
|
|
1047
|
+
*
|
|
1048
|
+
* ループ文脈を null で渡すのは Shadow DOM 形(`initializeBindings(shadowRoot, null)`)と
|
|
1049
|
+
* 揃えるため —— 子孫の `getLoopContextByNode` はコンポーネント要素まで遡って
|
|
1050
|
+
* 親スコープの行を見つける。
|
|
1051
|
+
*/
|
|
1052
|
+
private _initializeLightDomComponentScope;
|
|
1053
|
+
/**
|
|
1054
|
+
* mapped な `bind-component` が切断 → 再接続したときに、束ねているパスを読み直させる(§1.9)。
|
|
1055
|
+
*
|
|
1056
|
+
* リスト行の content は再利用されるので、行が作り直されると子はこの経路を通る
|
|
1057
|
+
* (`_initialized` が真なので `_initializeBindWebComponent` / `_initialize` は走らず、
|
|
1058
|
+
* 子のバインディングは張り直されない)。切断中に親で起きた変更の通知は
|
|
1059
|
+
* `applyChangeToWebComponent` が切断済みを理由に落としているため、ここで読み直さないと
|
|
1060
|
+
* 子のビューだけが古い値のまま取り残される。何が変わったかは分からないので、
|
|
1061
|
+
* プライマリ規則の粒度で丸ごと読み直す。
|
|
1062
|
+
*
|
|
1063
|
+
* 読み直しの前に派生規則の memo を捨てる。派生規則の購読者(親スコープに立つ
|
|
1064
|
+
* バインディング)は切断で teardown されており、memo が残っていると導出が二度と
|
|
1065
|
+
* 走らないため購読者も張り直されない = 以後この子だけがサブパスの書き込みを
|
|
1066
|
+
* 受け取れなくなる。捨てておけば、直後の読み直しで導出と購読者登録が走る。
|
|
1067
|
+
*/
|
|
1068
|
+
private _reloadMappedPathsAfterReconnect;
|
|
1069
|
+
private _callStateConnectedCallback;
|
|
1070
|
+
private _initializeDCC;
|
|
1071
|
+
private _callStateDisconnectedCallback;
|
|
1072
|
+
connectedCallback(): Promise<void>;
|
|
1073
|
+
disconnectedCallback(): void;
|
|
1074
|
+
get initialized(): boolean;
|
|
1075
|
+
get initializePromise(): Promise<void>;
|
|
1076
|
+
get connectedCallbackPromise(): Promise<void>;
|
|
1077
|
+
get listPaths(): Set<string>;
|
|
1078
|
+
get listKeys(): ListKeyMap | null;
|
|
1079
|
+
get watchPaths(): ReadonlySet<string> | null;
|
|
1080
|
+
get elementPaths(): Set<string>;
|
|
1081
|
+
get getterPaths(): Set<string>;
|
|
1082
|
+
get setterPaths(): Set<string>;
|
|
1083
|
+
get loopContextStack(): ILoopContextStack;
|
|
1084
|
+
get dynamicDependency(): Map<string, string[]>;
|
|
1085
|
+
get staticDependency(): Map<string, string[]>;
|
|
1086
|
+
get version(): number;
|
|
1087
|
+
get rootNode(): Node;
|
|
1088
|
+
/**
|
|
1089
|
+
* `rootNode` を保持しているか = `createState` を呼んでよいか(§1.9)。
|
|
1090
|
+
* disconnect で落ち、connect の冒頭で復活する。
|
|
1091
|
+
*/
|
|
1092
|
+
get hasRootNode(): boolean;
|
|
1093
|
+
get boundComponentStateProp(): string | null;
|
|
1094
|
+
get boundComponent(): Element | null;
|
|
1095
|
+
get hasMappedComponentState(): boolean;
|
|
1096
|
+
get boundPaths(): ReadonlySet<string>;
|
|
1097
|
+
/**
|
|
1098
|
+
* この state の実体が innerState proxy であることを記録する。唯一の呼び手は
|
|
1099
|
+
* `bindWebComponent` の mapped 分岐(§1.8)。
|
|
1100
|
+
*/
|
|
1101
|
+
markComponentStateMapped(): void;
|
|
1102
|
+
get bindableEventMap(): Record<string, string>;
|
|
1103
|
+
get commandTokenNames(): ReadonlySet<string>;
|
|
1104
|
+
get eventTokenNames(): ReadonlySet<string>;
|
|
1105
|
+
setBindableEventMap(map: Record<string, string>): void;
|
|
1106
|
+
private _addDependency;
|
|
1107
|
+
/**
|
|
1108
|
+
* source, target
|
|
1109
|
+
*
|
|
1110
|
+
* products.*.price => products.*.tax
|
|
1111
|
+
* get "products.*.tax"() { return this["products.*.price"] * 0.1; }
|
|
1112
|
+
*
|
|
1113
|
+
* products.*.price => products.summary
|
|
1114
|
+
* get "products.summary"() { return this.$getAll("products.*.price", []).reduce(sum); }
|
|
1115
|
+
*
|
|
1116
|
+
* categories.*.name => categories.*.products.*.categoryName
|
|
1117
|
+
* get "categories.*.products.*.categoryName"() { return this["categories.*.name"]; }
|
|
1118
|
+
*
|
|
1119
|
+
* @param sourcePath
|
|
1120
|
+
* @param targetPath
|
|
1121
|
+
*/
|
|
1122
|
+
addDynamicDependency(sourcePath: string, targetPath: string): boolean;
|
|
1123
|
+
/**
|
|
1124
|
+
* source, target
|
|
1125
|
+
* products => products.*
|
|
1126
|
+
* products.* => products.*.price
|
|
1127
|
+
* products.* => products.*.name
|
|
1128
|
+
*
|
|
1129
|
+
* @param sourcePath
|
|
1130
|
+
* @param targetPath
|
|
1131
|
+
*/
|
|
1132
|
+
addStaticDependency(sourcePath: string, targetPath: string): boolean;
|
|
1133
|
+
setPathInfo(path: string, bindingType: BindingType, source?: PathInfoSource): void;
|
|
1134
|
+
private _createState;
|
|
1135
|
+
createStateAsync(mutability: Mutability, callback: (state: IStateProxy) => Promise<void>): Promise<void>;
|
|
1136
|
+
createState(mutability: Mutability, callback: (state: IStateProxy) => void): void;
|
|
1137
|
+
nextVersion(): number;
|
|
1138
|
+
get hasUpdatedCallback(): boolean;
|
|
1139
|
+
get crossRowListPaths(): ReadonlySet<string>;
|
|
1140
|
+
addCrossRowListPath(path: string): void;
|
|
1141
|
+
get indexDependentGetterPaths(): ReadonlySet<string>;
|
|
1142
|
+
addIndexDependentGetterPath(path: string): void;
|
|
1143
|
+
bindProperty(prop: string, desc: PropertyDescriptor): void;
|
|
1144
|
+
setInitialState(state: Record<string, any>): void;
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
declare global {
|
|
1148
|
+
interface HTMLElementTagNameMap {
|
|
1149
|
+
"wcs-state": State;
|
|
1150
|
+
"wcs-ssr": Ssr;
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
|
|
982
1154
|
export { Ssr, VERSION, WCS_MANIFEST_VERSION, analyzeContract, bootstrapState, buildBindings, builtinFilterMeta, defineState, getBindingsReady, getConfig, getWcsManifest };
|
|
983
1155
|
export type { ContractEvent, FilterArgType, FilterResultType, IContractManifest, IFilterMeta, ISsrElement, IWcsManifest, IWritableConfig, IWritableTagNames, WcsPathValue, WcsPaths, WcsStateApi, WcsThis };
|