@wcstack/state 1.19.0 → 1.20.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 +22 -4
- package/dist/index.esm.js +1220 -839
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/manifest.esm.js +6 -0
- package/dist/wcs-manifest.json +4 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -146,10 +146,11 @@ type IsPlainObject<T> = IsAny<T> extends true ? false : T extends string | numbe
|
|
|
146
146
|
/**
|
|
147
147
|
* T のキーのうち、関数でないもの(データプロパティ・computed getter)を抽出する。
|
|
148
148
|
* メソッド(イベントハンドラ等)はドットパスの対象外。
|
|
149
|
+
* `$` プレフィックスキー($streams / $commandTokens / $on 等の予約宣言)もドットパスにならない。
|
|
149
150
|
* any 型のプロパティは除外せず保持する。
|
|
150
151
|
*/
|
|
151
152
|
type DataKeys<T> = {
|
|
152
|
-
[K in keyof T & string]: IsAny<T[K]> extends true ? K : T[K] extends (...args: any[]) => any ? never : K;
|
|
153
|
+
[K in keyof T & string]: K extends `$${string}` ? never : IsAny<T[K]> extends true ? K : T[K] extends (...args: any[]) => any ? never : K;
|
|
153
154
|
}[keyof T & string];
|
|
154
155
|
/**
|
|
155
156
|
* 型 T から生成される全てのドットパスの union。
|
|
@@ -208,14 +209,17 @@ interface WcsStateApi {
|
|
|
208
209
|
/**
|
|
209
210
|
* ワイルドカードを含むパスにマッチする全要素を配列で取得する。
|
|
210
211
|
*
|
|
212
|
+
* @param path - ワイルドカードを含むパス
|
|
213
|
+
* @param indexes - 各ワイルドカード階層のインデックス(省略時はループコンテキストから解決)
|
|
214
|
+
*
|
|
211
215
|
* @example
|
|
212
216
|
* ```ts
|
|
213
217
|
* get "cart.totalPrice"() {
|
|
214
|
-
* return this.$getAll("cart.items.*.price"
|
|
218
|
+
* return this.$getAll("cart.items.*.price").reduce((sum, v) => sum + v, 0);
|
|
215
219
|
* }
|
|
216
220
|
* ```
|
|
217
221
|
*/
|
|
218
|
-
$getAll<V = any>(path: string,
|
|
222
|
+
$getAll<V = any>(path: string, indexes?: number[]): V[];
|
|
219
223
|
/**
|
|
220
224
|
* 指定パスの更新を手動でトリガーする。
|
|
221
225
|
* Proxy の set トラップを経由せずに内部状態を変更した場合に使用。
|
|
@@ -236,6 +240,20 @@ interface WcsStateApi {
|
|
|
236
240
|
$trackDependency(path: string): void;
|
|
237
241
|
/** `<wcs-state>` 要素への参照 */
|
|
238
242
|
readonly $stateElement: HTMLElement;
|
|
243
|
+
/**
|
|
244
|
+
* `$commandTokens` で宣言した command token の名前空間。
|
|
245
|
+
* `this.$command.<name>` で token を解決できる(バインディングでは
|
|
246
|
+
* `onclick: $command.<name>` / `command.<method>: $command.<name>`)。
|
|
247
|
+
*/
|
|
248
|
+
readonly $command: Record<string, {
|
|
249
|
+
emit(...args: any[]): any;
|
|
250
|
+
}>;
|
|
251
|
+
/** `$streams` 各エントリの状態("idle" | "active" | "done" | "error")を返す読み取り専用名前空間 */
|
|
252
|
+
readonly $streamStatus: Record<string, "idle" | "active" | "done" | "error">;
|
|
253
|
+
/** `$streams` 各エントリの直近エラーを返す読み取り専用名前空間 */
|
|
254
|
+
readonly $streamError: Record<string, unknown>;
|
|
255
|
+
readonly [key: `$streamStatus.${string}`]: "idle" | "active" | "done" | "error";
|
|
256
|
+
readonly [key: `$streamError.${string}`]: unknown;
|
|
239
257
|
readonly $1: number;
|
|
240
258
|
readonly $2: number;
|
|
241
259
|
readonly $3: number;
|
|
@@ -262,7 +280,7 @@ interface WcsStateApi {
|
|
|
262
280
|
* increment() {
|
|
263
281
|
* this.count++; // number
|
|
264
282
|
* this["users.*.name"]; // string (パス型解決)
|
|
265
|
-
* this.$getAll("
|
|
283
|
+
* this.$getAll("users.*.age"); // API
|
|
266
284
|
* }
|
|
267
285
|
* });
|
|
268
286
|
* ```
|