@wcstack/state 3.1.0 → 3.3.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.
Files changed (56) hide show
  1. package/README.ja.md +128 -90
  2. package/README.md +129 -91
  3. package/dist/auto.min.js +1 -1
  4. package/dist/auto.min.js.map +1 -1
  5. package/dist/define.d.ts +11 -7
  6. package/dist/index.d.ts +58 -15
  7. package/dist/index.esm.js +1 -1
  8. package/dist/index.esm.js.map +1 -1
  9. package/dist/manifest.d.ts +39 -5
  10. package/dist/manifest.esm.js +315 -253
  11. package/dist/parser.d.ts +16 -2
  12. package/dist/parser.esm.js +223 -50
  13. package/dist/split/chunks/binder.js +1 -1
  14. package/dist/split/chunks/binder.js.map +1 -1
  15. package/dist/split/chunks/checkDependency.js +1 -1
  16. package/dist/split/chunks/declarationAliases.js +2 -0
  17. package/dist/split/chunks/declarationAliases.js.map +1 -0
  18. package/dist/split/chunks/declarationHooks.js +2 -0
  19. package/dist/split/chunks/declarationHooks.js.map +1 -0
  20. package/dist/split/chunks/featureBridge.js +2 -0
  21. package/dist/split/chunks/featureBridge.js.map +1 -0
  22. package/dist/split/chunks/filterRegistry.js +1 -1
  23. package/dist/split/chunks/filterRegistry.js.map +1 -1
  24. package/dist/split/chunks/getAllPropertyDescriptors.js +1 -1
  25. package/dist/split/chunks/getAllPropertyDescriptors.js.map +1 -1
  26. package/dist/split/chunks/lifecycleHooks.js +1 -1
  27. package/dist/split/chunks/pathDiagnostics.js +1 -1
  28. package/dist/split/chunks/pathDiagnostics.js.map +1 -1
  29. package/dist/split/chunks/registerComponents.js +1 -1
  30. package/dist/split/chunks/registerComponents.js.map +1 -1
  31. package/dist/split/chunks/setAll.js +1 -1
  32. package/dist/split/chunks/setAll.js.map +1 -1
  33. package/dist/split/chunks/version.js +1 -1
  34. package/dist/split/core.d.ts +21 -9
  35. package/dist/split/core.js +1 -1
  36. package/dist/split/core.js.map +1 -1
  37. package/dist/split/features/devtools.js +1 -1
  38. package/dist/split/features/devtools.js.map +1 -1
  39. package/dist/split/features/diagnostics.js +1 -1
  40. package/dist/split/features/diagnostics.js.map +1 -1
  41. package/dist/split/features/formats.js +1 -1
  42. package/dist/split/features/formats.js.map +1 -1
  43. package/dist/split/features/recursion.js +1 -1
  44. package/dist/split/features/recursion.js.map +1 -1
  45. package/dist/split/features/scopes.js +1 -1
  46. package/dist/split/features/scopes.js.map +1 -1
  47. package/dist/split/features/ssr.js +1 -1
  48. package/dist/split/features/ssr.js.map +1 -1
  49. package/dist/split/features/temporal.js +1 -1
  50. package/dist/split/features/temporal.js.map +1 -1
  51. package/dist/wcs-manifest.json +98 -44
  52. package/package.json +1 -1
  53. package/dist/split/chunks/mount.js +0 -2
  54. package/dist/split/chunks/mount.js.map +0 -1
  55. package/dist/split/chunks/watchRuntime.js +0 -2
  56. package/dist/split/chunks/watchRuntime.js.map +0 -1
package/dist/define.d.ts CHANGED
@@ -145,19 +145,23 @@ interface WcsStateApi {
145
145
  * 指定パスへの依存関係を明示的に登録する。
146
146
  * computed getter 内で動的にパスを組み立てる場合に使用。
147
147
  */
148
- $trackDependency(path: string): void;
148
+ $dependOn(path: string): void;
149
149
  /**
150
150
  * コールバック実行中の依存追跡(動的依存・`$1` インデックス依存の登録)を
151
- * 抑止して fn を実行し、その戻り値を返す(`$trackDependency` と対称)。
151
+ * 抑止して fn を実行し、その戻り値を返す。
152
152
  * リスト行 getter が「行外の単一値」を読みたいが、その値の変更で全行を
153
153
  * 再評価させたくない場合に使う(該当行へ直接書き込む設計と組で用いる)。
154
154
  */
155
+ $untracked<T>(fn: () => T): T;
156
+ /** @deprecated `$dependOn` の旧名(3.x の間は動き、4.0 で外れる — 要件 B12) */
157
+ $trackDependency(path: string): void;
158
+ /** @deprecated `$untracked` の旧名(3.x の間は動き、4.0 で外れる — 要件 B12) */
155
159
  $untrackDependency<T>(fn: () => T): T;
156
160
  /**
157
161
  * 鍵付き購読: `path` の現在値が `key` に等しいかを返し、評価中のリスト行 getter を
158
162
  * その鍵で購読する。`path` への書き込みは旧値・新値の鍵の行だけを再評価する
159
163
  * (パターン依存なら全行)。`path` 自体は依存として追跡しない。
160
- * 例: `get "items.*.selected"() { return this.$eq("selectedId", this.$untrackDependency(() => this["items.*.id"])); }`
164
+ * 例: `get "items.*.selected"() { return this.$eq("selectedId", this.$untracked(() => this["items.*.id"])); }`
161
165
  */
162
166
  $eq(path: string, key: unknown): boolean;
163
167
  /**
@@ -182,9 +186,9 @@ interface WcsStateApi {
182
186
  readonly $command: Record<string, {
183
187
  emit(...args: any[]): any;
184
188
  }>;
185
- /** `$streams` 各エントリの状態("idle" | "active" | "done" | "error")を返す読み取り専用名前空間 */
189
+ /** `$stream` 各エントリの状態("idle" | "active" | "done" | "error")を返す読み取り専用名前空間 */
186
190
  readonly $streamStatus: Record<string, "idle" | "active" | "done" | "error">;
187
- /** `$streams` 各エントリの直近エラーを返す読み取り専用名前空間 */
191
+ /** `$stream` 各エントリの直近エラーを返す読み取り専用名前空間 */
188
192
  readonly $streamError: Record<string, unknown>;
189
193
  readonly [key: `$streamStatus.${string}`]: "idle" | "active" | "done" | "error";
190
194
  readonly [key: `$streamError.${string}`]: unknown;
@@ -283,8 +287,8 @@ type WcsThis<T> = T & WcsStateApi & WcsPathAccessor<T>;
283
287
  * $disconnectedCallback() {
284
288
  * // cleanup
285
289
  * },
286
- * $updatedCallback() {
287
- * // called after DOM update
290
+ * $renderedCallback() {
291
+ * // called after the bindings are applied (old name: $updatedCallback)
288
292
  * }
289
293
  * });
290
294
  * ```
package/dist/index.d.ts CHANGED
@@ -45,7 +45,6 @@ interface ILoopContextStack {
45
45
  declare const setLoopContextSymbol: unique symbol;
46
46
  declare const getByAddressSymbol: unique symbol;
47
47
  declare const hasByAddressSymbol: unique symbol;
48
- declare const setByAddressSymbol: unique symbol;
49
48
  declare const connectedCallbackSymbol: unique symbol;
50
49
  declare const disconnectedCallbackSymbol: unique symbol;
51
50
  declare const updatedCallbackSymbol: unique symbol;
@@ -84,7 +83,6 @@ interface IStateProxy extends IState {
84
83
  [setLoopContextSymbol](loopContext: ILoopContext | null, callback: () => any): any;
85
84
  [getByAddressSymbol](address: IStateAddress): any;
86
85
  [hasByAddressSymbol](address: IStateAddress): boolean;
87
- [setByAddressSymbol](address: IStateAddress, value: any): void;
88
86
  [connectedCallbackSymbol](): Promise<void>;
89
87
  [disconnectedCallbackSymbol](): void;
90
88
  [updatedCallbackSymbol](updatedAbsAddressList: IAbsoluteStateAddress[]): void;
@@ -165,6 +163,16 @@ type WrittenHook = (stateElement: IStateElement, pathInfo: IPathInfo, detail?: {
165
163
  type SwappedHook = (stateElement: IStateElement, elementAbsAddress: IAbsoluteStateAddress, displacedAbsAddress: IAbsoluteStateAddress) => void;
166
164
  type GetHook = (handler: IStateHandler, prop: string, receiver: any, target: object) => unknown;
167
165
  type IndexShiftHook = (handler: IStateHandler, lastAddress: IStateAddress) => number;
166
+ /**
167
+ * ハンドラが受け取る添字の段数を決める(`event/handler.ts`)。
168
+ *
169
+ * **合成は未定義** — この hook は畳み込み(前の hook の結果が次の `wildcardCount` になる)で
170
+ * 呼ばれるが、現行唯一の実装(`webComponent/addressHooks.ts` の scopes)は「記録が引けて
171
+ * shift が無ければ 0」を返す**吸収型**で、可換でも結合的でもない。2 つ目の実装が足されると
172
+ * `0 - shift` のような負値になりうる。**実装は 1 つに保つこと**。2 つ目が要るなら、先に
173
+ * 「答えを持たない hook は次へ渡す」規約(`NOT_HANDLED` を返す形。`read` / `write` と同じ)
174
+ * へ寄せてから足す。
175
+ */
168
176
  type HandlerScopeHook = (stateElement: IStateElement, node: Node, rootNode: Node, loopContext: ILoopContext, wildcardCount: number) => number;
169
177
  type UpdatedHook = (stateElement: IStateElement, refs: IAbsoluteStateAddress[], receiver: any) => void;
170
178
  type SuppressPathDiagnosticHook = (stateElement: IStateElement, path: string) => boolean;
@@ -874,7 +882,12 @@ declare class Ssr extends HTMLElementBase implements ISsrElement {
874
882
  * wcs-state 要素から $ プレフィックスや関数を除いたデータを抽出する。
875
883
  */
876
884
  static extractStateData(stateEl: Element): Record<string, any>;
877
- static buildContent(ssrEl: Element, stateData: Record<string, any>): void;
885
+ /**
886
+ * @param scanRoot このスナップショットが属するツリー(既定は `ssrEl` の document)。
887
+ * テンプレートと props はここから到達できるものだけを載せる — モジュール寿命の台帳に
888
+ * 残った**別のレンダリング**の分を混ぜないため(リクエスト間のデータ漏れ)。
889
+ */
890
+ static buildContent(ssrEl: Element, stateData: Record<string, any>, scanRoot?: Node): void;
878
891
  /**
879
892
  * SSR ブロック境界コメント (@@wcs-*-start/end) を除去する
880
893
  */
@@ -1051,19 +1064,23 @@ interface WcsStateApi {
1051
1064
  * 指定パスへの依存関係を明示的に登録する。
1052
1065
  * computed getter 内で動的にパスを組み立てる場合に使用。
1053
1066
  */
1054
- $trackDependency(path: string): void;
1067
+ $dependOn(path: string): void;
1055
1068
  /**
1056
1069
  * コールバック実行中の依存追跡(動的依存・`$1` インデックス依存の登録)を
1057
- * 抑止して fn を実行し、その戻り値を返す(`$trackDependency` と対称)。
1070
+ * 抑止して fn を実行し、その戻り値を返す。
1058
1071
  * リスト行 getter が「行外の単一値」を読みたいが、その値の変更で全行を
1059
1072
  * 再評価させたくない場合に使う(該当行へ直接書き込む設計と組で用いる)。
1060
1073
  */
1074
+ $untracked<T>(fn: () => T): T;
1075
+ /** @deprecated `$dependOn` の旧名(3.x の間は動き、4.0 で外れる — 要件 B12) */
1076
+ $trackDependency(path: string): void;
1077
+ /** @deprecated `$untracked` の旧名(3.x の間は動き、4.0 で外れる — 要件 B12) */
1061
1078
  $untrackDependency<T>(fn: () => T): T;
1062
1079
  /**
1063
1080
  * 鍵付き購読: `path` の現在値が `key` に等しいかを返し、評価中のリスト行 getter を
1064
1081
  * その鍵で購読する。`path` への書き込みは旧値・新値の鍵の行だけを再評価する
1065
1082
  * (パターン依存なら全行)。`path` 自体は依存として追跡しない。
1066
- * 例: `get "items.*.selected"() { return this.$eq("selectedId", this.$untrackDependency(() => this["items.*.id"])); }`
1083
+ * 例: `get "items.*.selected"() { return this.$eq("selectedId", this.$untracked(() => this["items.*.id"])); }`
1067
1084
  */
1068
1085
  $eq(path: string, key: unknown): boolean;
1069
1086
  /**
@@ -1088,9 +1105,9 @@ interface WcsStateApi {
1088
1105
  readonly $command: Record<string, {
1089
1106
  emit(...args: any[]): any;
1090
1107
  }>;
1091
- /** `$streams` 各エントリの状態("idle" | "active" | "done" | "error")を返す読み取り専用名前空間 */
1108
+ /** `$stream` 各エントリの状態("idle" | "active" | "done" | "error")を返す読み取り専用名前空間 */
1092
1109
  readonly $streamStatus: Record<string, "idle" | "active" | "done" | "error">;
1093
- /** `$streams` 各エントリの直近エラーを返す読み取り専用名前空間 */
1110
+ /** `$stream` 各エントリの直近エラーを返す読み取り専用名前空間 */
1094
1111
  readonly $streamError: Record<string, unknown>;
1095
1112
  readonly [key: `$streamStatus.${string}`]: "idle" | "active" | "done" | "error";
1096
1113
  readonly [key: `$streamError.${string}`]: unknown;
@@ -1189,8 +1206,8 @@ type WcsThis<T> = T & WcsStateApi & WcsPathAccessor<T>;
1189
1206
  * $disconnectedCallback() {
1190
1207
  * // cleanup
1191
1208
  * },
1192
- * $updatedCallback() {
1193
- * // called after DOM update
1209
+ * $renderedCallback() {
1210
+ * // called after the bindings are applied (old name: $updatedCallback)
1194
1211
  * }
1195
1212
  * });
1196
1213
  * ```
@@ -1231,8 +1248,23 @@ interface IFilterMeta {
1231
1248
  /** 組み込みフィルタ名 → 構造化メタデータ。キー集合は builtinFilters と一致しなければならない。 */
1232
1249
  declare const builtinFilterMeta: Record<string, IFilterMeta>;
1233
1250
 
1234
- /** マニフェストのバージョン(構造を変えたら上げる)。 */
1235
- declare const WCS_MANIFEST_VERSION = 1;
1251
+ /**
1252
+ * filters/filterAliases.ts — 組み込みフィルタの旧名 → 正式名(要件 B12・docs/state-3x-naming.ja.md V1〜V9)。
1253
+ *
1254
+ * 旧名は 3.x の間エイリアスとして残り、4.0 で外す(D4)。解決は登録簿(core/filterRegistry)が行い、
1255
+ * 実装・引数の個数・メタデータは正式名だけが持つ。formats の install と manifest(tooling)の両方が読むので、
1256
+ * 実装にもメタデータにも依存しない小さな表として独立させている。
1257
+ */
1258
+ declare const builtinFilterAliases: Readonly<Record<string, string>>;
1259
+
1260
+ /**
1261
+ * マニフェストのバージョン(構造を変えたら上げる)。
1262
+ *
1263
+ * 3.1 で `syntax.bindingTypes.explicitPropertyPrefix`、3.2 で `filterAliases`、
1264
+ * 3.x の次で `declarationAliases` / `apiAliases` を足したので 2。
1265
+ * 消費側(vscode-wcs)はまだこの定数を参照していないが、公開している以上ドリフトさせない。
1266
+ */
1267
+ declare const WCS_MANIFEST_VERSION = 2;
1236
1268
  interface IWcsManifest {
1237
1269
  version: number;
1238
1270
  syntax: {
@@ -1295,9 +1327,20 @@ interface IWcsManifest {
1295
1327
  filters: string[];
1296
1328
  /** 組み込みフィルタの構造化メタデータ(説明・引数仕様・型)。vscode-wcs の手リスト撤去用。 */
1297
1329
  filterMeta: Record<string, IFilterMeta>;
1298
- /** 予約ライフサイクルフック名 */
1330
+ /** 組み込みフィルタの旧名 → 正式名(要件 B12)。旧名も解決するが、ツールは正式名を提案する */
1331
+ filterAliases: Readonly<Record<string, string>>;
1332
+ /**
1333
+ * 宣言キーの旧名 → 正式名(要件 B12。`$updatedCallback` → `$renderedCallback`、
1334
+ * `$streams` → `$stream`)。ランタイムは旧名も受けるが、ツールは正式名を提案する。
1335
+ * `reservedLifecycle` / `reservedStateApi` は**正式名だけ**なので、旧名が予約かどうかは
1336
+ * この表と併せて判断する
1337
+ */
1338
+ declarationAliases: Readonly<Record<string, string>>;
1339
+ /** state API の旧名 → 正式名(`$trackDependency` → `$dependOn` 等、要件 B12) */
1340
+ apiAliases: Readonly<Record<string, string>>;
1341
+ /** 予約ライフサイクルフック名(正式名のみ。旧名は `declarationAliases` を見る) */
1299
1342
  reservedLifecycle: readonly string[];
1300
- /** 予約 state API(プロトコル系の `$` 名前空間) */
1343
+ /** 予約 state API(プロトコル系の `$` 名前空間。正式名のみ) */
1301
1344
  reservedStateApi: readonly string[];
1302
1345
  }
1303
1346
  /** 機械可読な単一正本を返す。vscode-wcs はこれを消費する想定。 */
@@ -1818,5 +1861,5 @@ declare global {
1818
1861
  }
1819
1862
  }
1820
1863
 
1821
- export { Ssr, TRUSTED_TYPES_POLICY_SLOT, VERSION, WCS_MANIFEST_VERSION, analyzeContract, bootstrapState, buildBindings, builtinFilterMeta, defineState, getBindingsReady, getConfig, getTrustedTypesPolicy, getWcsManifest, setTrustedTypesPolicy };
1864
+ export { Ssr, TRUSTED_TYPES_POLICY_SLOT, VERSION, WCS_MANIFEST_VERSION, analyzeContract, bootstrapState, buildBindings, builtinFilterAliases, builtinFilterMeta, defineState, getBindingsReady, getConfig, getTrustedTypesPolicy, getWcsManifest, setTrustedTypesPolicy };
1822
1865
  export type { ContractEvent, FilterArgType, FilterResultType, IBindingErrorInfo, IContractManifest, IFilterMeta, ISsrElement, IWcsManifest, IWcsTrustedTypesPolicy, IWritableConfig, IWritableTagNames, WcsPathValue, WcsPaths, WcsStateApi, WcsThis };