@wcstack/state 3.1.0 → 3.2.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 +25 -17
- package/README.md +25 -17
- package/dist/auto.min.js +1 -1
- package/dist/auto.min.js.map +1 -1
- package/dist/define.d.ts +11 -7
- package/dist/index.d.ts +13 -7
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/manifest.d.ts +12 -1
- package/dist/manifest.esm.js +90 -35
- package/dist/split/chunks/declarationAliases.js +2 -0
- package/dist/split/chunks/declarationAliases.js.map +1 -0
- package/dist/split/chunks/filterRegistry.js +1 -1
- package/dist/split/chunks/filterRegistry.js.map +1 -1
- package/dist/split/chunks/mount.js +1 -1
- package/dist/split/chunks/mount.js.map +1 -1
- package/dist/split/chunks/pathDiagnostics.js +1 -1
- package/dist/split/chunks/pathDiagnostics.js.map +1 -1
- package/dist/split/chunks/registerComponents.js +1 -1
- package/dist/split/chunks/registerComponents.js.map +1 -1
- package/dist/split/chunks/version.js +1 -1
- package/dist/split/core.d.ts +11 -7
- package/dist/split/core.js +1 -1
- package/dist/split/core.js.map +1 -1
- package/dist/split/features/devtools.js +1 -1
- package/dist/split/features/devtools.js.map +1 -1
- package/dist/split/features/formats.js +1 -1
- package/dist/split/features/formats.js.map +1 -1
- package/dist/split/features/scopes.js +1 -1
- package/dist/split/features/scopes.js.map +1 -1
- package/dist/split/features/ssr.js +1 -1
- package/dist/split/features/ssr.js.map +1 -1
- package/dist/split/features/temporal.js +1 -1
- package/dist/split/features/temporal.js.map +1 -1
- package/dist/wcs-manifest.json +64 -25
- package/package.json +1 -1
package/README.ja.md
CHANGED
|
@@ -186,9 +186,9 @@
|
|
|
186
186
|
<script type="importmap">
|
|
187
187
|
{
|
|
188
188
|
"imports": {
|
|
189
|
-
"@wcstack/state/core": "https://cdn.jsdelivr.net/npm/@wcstack/state@3.
|
|
190
|
-
"@wcstack/state/features/temporal": "https://cdn.jsdelivr.net/npm/@wcstack/state@3.
|
|
191
|
-
"@wcstack/state/features/scopes": "https://cdn.jsdelivr.net/npm/@wcstack/state@3.
|
|
189
|
+
"@wcstack/state/core": "https://cdn.jsdelivr.net/npm/@wcstack/state@3.2.0/dist/split/core.js",
|
|
190
|
+
"@wcstack/state/features/temporal": "https://cdn.jsdelivr.net/npm/@wcstack/state@3.2.0/dist/split/features/temporal.js",
|
|
191
|
+
"@wcstack/state/features/scopes": "https://cdn.jsdelivr.net/npm/@wcstack/state@3.2.0/dist/split/features/scopes.js"
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
</script>
|
|
@@ -1165,8 +1165,8 @@ export default {
|
|
|
1165
1165
|
| `this.$setAll(path, indexes, value, options?)` | ワイルドカードパスにマッチする全アドレスへ一括書き込み |
|
|
1166
1166
|
| `this.$resolve(path, indexes, value?)` | ワイルドカードパスを特定のインデックスで解決 |
|
|
1167
1167
|
| `this.$postUpdate(path)` | 指定パスの更新通知を手動で発行 |
|
|
1168
|
-
| `this.$
|
|
1169
|
-
| `this.$
|
|
1168
|
+
| `this.$dependOn(path)`(3.2。旧名 `$trackDependency`) | キャッシュ無効化のための依存関係を手動で登録 |
|
|
1169
|
+
| `this.$untracked(fn)`(3.2。旧名 `$untrackDependency`) | fn 実行中の依存追跡を抑止して値を読む |
|
|
1170
1170
|
| `this.$eq(path, key)` / `$eqPath(path, keyPath)` / `$eqIndex(path, level?)` | 鍵付き購読: 「`path` の値はこの行の鍵か」([鍵付き選択](#鍵付き選択eq--eqpath--eqindex)) |
|
|
1171
1171
|
| `this.$stateElement` | `IStateElement` インスタンスへのアクセス |
|
|
1172
1172
|
| `this.$1`, `this.$2`, ... | 現在のループインデックス(1始まりの命名、0始まりの値) |
|
|
@@ -1499,7 +1499,9 @@ export default {
|
|
|
1499
1499
|
|
|
1500
1500
|
## フィルタ
|
|
1501
1501
|
|
|
1502
|
-
|
|
1502
|
+
48 種類の組み込みフィルタが入力(DOM → 状態)と出力(状態 → DOM)の両方向で利用できます。
|
|
1503
|
+
|
|
1504
|
+
**3.2 で一部の名前を改めました**(要件 B12)。表は正式名で、括弧の中が旧名です。旧名は 3.x の間は同じに動き、4.0 で外れます。lint と VS Code 拡張は、旧名に正式名を提案する info(`wcs/name-alias`)を出します。3.1 以前を使うページでは旧名で書いてください。
|
|
1503
1505
|
|
|
1504
1506
|
### 比較
|
|
1505
1507
|
|
|
@@ -1517,8 +1519,8 @@ export default {
|
|
|
1517
1519
|
|
|
1518
1520
|
| フィルタ | 説明 | 例 |
|
|
1519
1521
|
|---|---|---|
|
|
1520
|
-
| `
|
|
1521
|
-
| `
|
|
1522
|
+
| `add(n)`(`inc`) | 加算 | `count\|add(1)` |
|
|
1523
|
+
| `sub(n)`(`dec`) | 減算 | `count\|sub(1)` |
|
|
1522
1524
|
| `mul(n)` | 乗算 | `price\|mul(1.1)` |
|
|
1523
1525
|
| `div(n)` | 除算 | `total\|div(100)` |
|
|
1524
1526
|
| `mod(n)` | 剰余 | `index\|mod(2)` |
|
|
@@ -1529,7 +1531,7 @@ export default {
|
|
|
1529
1531
|
|
|
1530
1532
|
| フィルタ | 説明 | 例 |
|
|
1531
1533
|
|---|---|---|
|
|
1532
|
-
| `
|
|
1534
|
+
| `toFixed(n)`(`fix`) | 固定小数点桁数 | `price\|toFixed(2)` → `"100.00"` |
|
|
1533
1535
|
| `round(n?)` | 四捨五入 | `value\|round(2)` |
|
|
1534
1536
|
| `floor(n?)` | 切り捨て | `value\|floor` |
|
|
1535
1537
|
| `ceil(n?)` | 切り上げ | `value\|ceil` |
|
|
@@ -1541,15 +1543,16 @@ export default {
|
|
|
1541
1543
|
|
|
1542
1544
|
| フィルタ | 説明 | 例 |
|
|
1543
1545
|
|---|---|---|
|
|
1544
|
-
| `uc
|
|
1545
|
-
| `lc
|
|
1546
|
-
| `cap
|
|
1546
|
+
| `upper`(`uc`) | 大文字変換 | `name\|upper` |
|
|
1547
|
+
| `lower`(`lc`) | 小文字変換 | `name\|lower` |
|
|
1548
|
+
| `capitalize`(`cap`) | 先頭大文字 | `name\|capitalize` |
|
|
1547
1549
|
| `trim` | 空白除去 | `text\|trim` |
|
|
1548
1550
|
| `slice(n)` | 文字列スライス | `text\|slice(5)` |
|
|
1549
1551
|
| `substr(start, length)` | 部分文字列 | `text\|substr(0,10)` |
|
|
1550
|
-
| `
|
|
1551
|
-
| `
|
|
1552
|
-
| `
|
|
1552
|
+
| `padStart(n, char?)`(`pad`) | 先頭を埋める(既定 `0`) | `id\|padStart(5,0)` → `"00001"` |
|
|
1553
|
+
| `padEnd(n, char?)` | 末尾を埋める(既定は空白。3.2) | `code\|padEnd(8)` |
|
|
1554
|
+
| `repeat(n)`(`rep`) | 繰り返し | `text\|repeat(3)` |
|
|
1555
|
+
| `reverse`(`rev`) | 反転 | `text\|reverse` |
|
|
1553
1556
|
| `truncate(n, suffix?)` | 切り詰めて省略記号を付加 | `title\|truncate(20)` → `"…"` 付き |
|
|
1554
1557
|
| `join(sep?)` | 配列を連結(既定 `", "`) | `tags\|join` / `tags\|join(/)` |
|
|
1555
1558
|
|
|
@@ -1562,7 +1565,7 @@ export default {
|
|
|
1562
1565
|
| `boolean` | 真偽値に変換 | `value\|boolean` |
|
|
1563
1566
|
| `number` | 数値に変換 | `value\|number` |
|
|
1564
1567
|
| `string` | 文字列に変換 | `value\|string` |
|
|
1565
|
-
| `null
|
|
1568
|
+
| `nullIfEmpty`(`null`) | 空文字を `null` にする(それ以外はそのまま) | `value\|nullIfEmpty` |
|
|
1566
1569
|
|
|
1567
1570
|
### 日付 / 時刻
|
|
1568
1571
|
|
|
@@ -1580,7 +1583,8 @@ export default {
|
|
|
1580
1583
|
|---|---|---|
|
|
1581
1584
|
| `truthy` | truthy チェック — JavaScript の真偽判定そのもので `boolean` と同じ(3.0 から `0n` は偽) | `value\|truthy` |
|
|
1582
1585
|
| `falsy` | falsy チェック(JavaScript の真偽判定。`defaults` も同じ判定を使う) | `value\|falsy` |
|
|
1583
|
-
| `defaults(v)` |
|
|
1586
|
+
| `defaults(v)` | 偽値(`0`・`false`・`""` を含む)のときのフォールバック値 | `name\|defaults(Anonymous)` |
|
|
1587
|
+
| `coalesce(v)` | `null` / `undefined` のときだけのフォールバック値(`0`・`false`・`""` は残す。3.2) | `count\|coalesce(0)` |
|
|
1584
1588
|
|
|
1585
1589
|
### フィルタチェーン
|
|
1586
1590
|
|
|
@@ -2149,6 +2153,8 @@ event token は command token と同じ `Token` pub/sub プリミティブを共
|
|
|
2149
2153
|
|
|
2150
2154
|
## Stream(`$streams`)
|
|
2151
2155
|
|
|
2156
|
+
> **3.2 から宣言キーの正式名は `$stream` です**(要件 B12 — `$watch` / `$scan` と単数で揃えた)。旧名 `$streams` は 3.x の間は同じに動き、4.0 で外れます。両方を宣言すると `[wcs/declaration-alias]` で落ちます。`$streamStatus` / `$streamError` の名前空間は変わりません。3.1 以前では `$streams` と書いてください。
|
|
2157
|
+
|
|
2152
2158
|
command token / event token が運ぶのは離散的なやり取りです。**`$streams`** は残る形 —— 連続的なフローをカバーします。非同期 producer(async iterable / async generator / `ReadableStream`)を宣言すると、フレームワークがそれを **fold して単一の reactive プロパティに畳み込みます** —— 各チャンクは通常のパス代入を通るため、バインディング・パス getter・`$updatedCallback` は自分で値を代入した場合とまったく同じように反応します。`args` 関数が読んだ state パスが変化すると、実行中の producer は abort され、新しい引数で source が張り直されます(switchMap 型の依存駆動 restart)。stream は `$connectedCallback` 完了後に eager に起動し、要素の disconnect で abort されます。
|
|
2153
2159
|
|
|
2154
2160
|
`$updatedCallback` は引き続き binding 駆動です。stream 宣言だけでは headless な購読にならず、その value/status/error の live DOM binding が実際に適用されたときだけ callback の path に現れます。描画せずに stream の値へ反応したい場合は、そのパスに [`$watch`](#watchwatch) を宣言してください。観測契約は [stream リファレンス](docs/streams.md) を参照してください。
|
|
@@ -2618,6 +2624,8 @@ export default {
|
|
|
2618
2624
|
|
|
2619
2625
|
状態オブジェクトに `$connectedCallback` / `$disconnectedCallback` / `$updatedCallback` / `$errorCallback` を定義すると、初期化・クリーンアップ・更新時・バインディング失敗時のフックとして利用できます。
|
|
2620
2626
|
|
|
2627
|
+
> **3.2 から `$updatedCallback` の正式名は `$renderedCallback` です**(要件 B12)。このフックが受けるのは**適用されたバインディング**の更新で、state の更新全体ではない(それには `$watch`)ことを名前で言うためです。旧名は 3.x の間は同じに動き、4.0 で外れます。両方を宣言すると `[wcs/declaration-alias]` で落ちます。3.1 以前では `$updatedCallback` と書いてください。
|
|
2628
|
+
|
|
2621
2629
|
```html
|
|
2622
2630
|
<wcs-state>
|
|
2623
2631
|
<script type="module">
|
package/README.md
CHANGED
|
@@ -187,9 +187,9 @@ leaves features out, it can compose them instead:
|
|
|
187
187
|
<script type="importmap">
|
|
188
188
|
{
|
|
189
189
|
"imports": {
|
|
190
|
-
"@wcstack/state/core": "https://cdn.jsdelivr.net/npm/@wcstack/state@3.
|
|
191
|
-
"@wcstack/state/features/temporal": "https://cdn.jsdelivr.net/npm/@wcstack/state@3.
|
|
192
|
-
"@wcstack/state/features/scopes": "https://cdn.jsdelivr.net/npm/@wcstack/state@3.
|
|
190
|
+
"@wcstack/state/core": "https://cdn.jsdelivr.net/npm/@wcstack/state@3.2.0/dist/split/core.js",
|
|
191
|
+
"@wcstack/state/features/temporal": "https://cdn.jsdelivr.net/npm/@wcstack/state@3.2.0/dist/split/features/temporal.js",
|
|
192
|
+
"@wcstack/state/features/scopes": "https://cdn.jsdelivr.net/npm/@wcstack/state@3.2.0/dist/split/features/scopes.js"
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
</script>
|
|
@@ -1166,8 +1166,8 @@ Inside state objects (getters / methods), the following APIs are available via `
|
|
|
1166
1166
|
| `this.$setAll(path, indexes, value, options?)` | Write to every address matching a wildcard path |
|
|
1167
1167
|
| `this.$resolve(path, indexes, value?)` | Resolve a wildcard path with specific indexes |
|
|
1168
1168
|
| `this.$postUpdate(path)` | Manually trigger update notification for a path |
|
|
1169
|
-
| `this.$
|
|
1170
|
-
| `this.$
|
|
1169
|
+
| `this.$dependOn(path)` (3.2; old name `$trackDependency`) | Manually register a dependency for cache invalidation |
|
|
1170
|
+
| `this.$untracked(fn)` (3.2; old name `$untrackDependency`) | Read values inside fn without registering dependencies |
|
|
1171
1171
|
| `this.$eq(path, key)` / `$eqPath(path, keyPath)` / `$eqIndex(path, level?)` | Keyed subscription for "is this row's key the value of `path`?" (see [Keyed selection](#keyed-selection-eq--eqpath--eqindex)) |
|
|
1172
1172
|
| `this.$command.<name>` | Access a `CommandToken` declared in `$commandTokens` (see [Command Token](#command-token-method-binding)) |
|
|
1173
1173
|
| `this.$stateElement` | Access to the `IStateElement` instance |
|
|
@@ -1501,7 +1501,9 @@ export default {
|
|
|
1501
1501
|
|
|
1502
1502
|
## Filters
|
|
1503
1503
|
|
|
1504
|
-
|
|
1504
|
+
48 built-in filters are available for both input (DOM → state) and output (state → DOM) directions.
|
|
1505
|
+
|
|
1506
|
+
**3.2 renamed some filters** (requirement B12). The tables show the canonical names, with the old name in parentheses. The old names work the same through 3.x and are removed in 4.0. Lint and the VS Code extension flag an old name with an info diagnostic (`wcs/name-alias`) that suggests the canonical one. On a page that uses 3.1 or earlier, write the old names.
|
|
1505
1507
|
|
|
1506
1508
|
### Comparison
|
|
1507
1509
|
|
|
@@ -1519,8 +1521,8 @@ export default {
|
|
|
1519
1521
|
|
|
1520
1522
|
| Filter | Description | Example |
|
|
1521
1523
|
|---|---|---|
|
|
1522
|
-
| `
|
|
1523
|
-
| `
|
|
1524
|
+
| `add(n)` (`inc`) | Add | `count\|add(1)` |
|
|
1525
|
+
| `sub(n)` (`dec`) | Subtract | `count\|sub(1)` |
|
|
1524
1526
|
| `mul(n)` | Multiply | `price\|mul(1.1)` |
|
|
1525
1527
|
| `div(n)` | Divide | `total\|div(100)` |
|
|
1526
1528
|
| `mod(n)` | Modulo | `index\|mod(2)` |
|
|
@@ -1531,7 +1533,7 @@ export default {
|
|
|
1531
1533
|
|
|
1532
1534
|
| Filter | Description | Example |
|
|
1533
1535
|
|---|---|---|
|
|
1534
|
-
| `
|
|
1536
|
+
| `toFixed(n)` (`fix`) | Fixed decimal places | `price\|toFixed(2)` → `"100.00"` |
|
|
1535
1537
|
| `round(n?)` | Round | `value\|round(2)` |
|
|
1536
1538
|
| `floor(n?)` | Floor | `value\|floor` |
|
|
1537
1539
|
| `ceil(n?)` | Ceiling | `value\|ceil` |
|
|
@@ -1543,15 +1545,16 @@ export default {
|
|
|
1543
1545
|
|
|
1544
1546
|
| Filter | Description | Example |
|
|
1545
1547
|
|---|---|---|
|
|
1546
|
-
| `uc` | Upper case | `name\|
|
|
1547
|
-
| `lc` | Lower case | `name\|
|
|
1548
|
-
| `cap` | Capitalize | `name\|
|
|
1548
|
+
| `upper` (`uc`) | Upper case | `name\|upper` |
|
|
1549
|
+
| `lower` (`lc`) | Lower case | `name\|lower` |
|
|
1550
|
+
| `capitalize` (`cap`) | Capitalize | `name\|capitalize` |
|
|
1549
1551
|
| `trim` | Trim whitespace | `text\|trim` |
|
|
1550
1552
|
| `slice(n)` | Slice string | `text\|slice(5)` |
|
|
1551
1553
|
| `substr(start, length)` | Substring | `text\|substr(0,10)` |
|
|
1552
|
-
| `
|
|
1553
|
-
| `
|
|
1554
|
-
| `
|
|
1554
|
+
| `padStart(n, char?)` (`pad`) | Pad the start (default `0`) | `id\|padStart(5,0)` → `"00001"` |
|
|
1555
|
+
| `padEnd(n, char?)` | Pad the end (default a space; 3.2) | `code\|padEnd(8)` |
|
|
1556
|
+
| `repeat(n)` (`rep`) | Repeat | `text\|repeat(3)` |
|
|
1557
|
+
| `reverse` (`rev`) | Reverse | `text\|reverse` |
|
|
1555
1558
|
| `truncate(n, suffix?)` | Shorten and append an ellipsis | `title\|truncate(20)` |
|
|
1556
1559
|
| `join(sep?)` | Join an array (default `", "`) | `tags\|join` / `tags\|join(/)` |
|
|
1557
1560
|
|
|
@@ -1564,7 +1567,7 @@ export default {
|
|
|
1564
1567
|
| `boolean` | To boolean | `value\|boolean` |
|
|
1565
1568
|
| `number` | To number | `value\|number` |
|
|
1566
1569
|
| `string` | To string | `value\|string` |
|
|
1567
|
-
| `null` |
|
|
1570
|
+
| `nullIfEmpty` (`null`) | Turn an empty string into `null` (anything else passes through) | `value\|nullIfEmpty` |
|
|
1568
1571
|
|
|
1569
1572
|
### Date / Time
|
|
1570
1573
|
|
|
@@ -1582,7 +1585,8 @@ export default {
|
|
|
1582
1585
|
|---|---|---|
|
|
1583
1586
|
| `truthy` | Truthy check — JavaScript's own truthiness, the same as `boolean` (so `0n` is falsy since 3.0) | `value\|truthy` |
|
|
1584
1587
|
| `falsy` | Falsy check (JavaScript's truthiness; `defaults` uses the same test) | `value\|falsy` |
|
|
1585
|
-
| `defaults(v)` | Fallback value | `name\|defaults(Anonymous)` |
|
|
1588
|
+
| `defaults(v)` | Fallback for any falsy value (`0`, `false` and `""` included) | `name\|defaults(Anonymous)` |
|
|
1589
|
+
| `coalesce(v)` | Fallback for `null` / `undefined` only (`0`, `false` and `""` stay; 3.2) | `count\|coalesce(0)` |
|
|
1586
1590
|
|
|
1587
1591
|
### Filter Chaining
|
|
1588
1592
|
|
|
@@ -2155,6 +2159,8 @@ Two rules cut most of the confusion:
|
|
|
2155
2159
|
|
|
2156
2160
|
## Streams (`$streams`)
|
|
2157
2161
|
|
|
2162
|
+
> **As of 3.2 the canonical declaration key is `$stream`** (requirement B12), singular like `$watch` and `$scan`. The old `$streams` works the same through 3.x and is removed in 4.0. Declaring both fails with `[wcs/declaration-alias]`. The `$streamStatus` / `$streamError` namespaces do not change. On 3.1 or earlier, write `$streams`.
|
|
2163
|
+
|
|
2158
2164
|
Command tokens and event tokens carry discrete interactions. **`$streams`** covers the remaining shape: a continuous flow. Declare an async producer (async iterable / async generator / `ReadableStream`) and the framework **folds it into a single reactive property** — each chunk goes through normal path assignment, so bindings, path getters, and `$updatedCallback` react exactly as if you had assigned the value yourself. When a state path read by the `args` function changes, the running producer is aborted and the source is restarted with the new arguments (switchMap-style dependency-driven restart). Streams start eagerly after `$connectedCallback` completes and are aborted when the element disconnects.
|
|
2159
2165
|
|
|
2160
2166
|
`$updatedCallback` remains binding-driven: a stream declaration alone is not a headless subscription. Its path appears in the callback only when a live DOM binding for that value/status/error is actually applied. To react to a stream's value without rendering it, declare [`$watch`](#watch-watch) on that path; see the [stream reference](docs/streams.md) for the observation contract.
|
|
@@ -2624,6 +2630,8 @@ All bindings work inside `<svg>` elements. Use `attr.*` for SVG attributes:
|
|
|
2624
2630
|
|
|
2625
2631
|
State objects can define `$connectedCallback`, `$disconnectedCallback`, `$updatedCallback`, and `$errorCallback` for initialization, cleanup, update, and binding-failure handling.
|
|
2626
2632
|
|
|
2633
|
+
> **As of 3.2 the canonical name of `$updatedCallback` is `$renderedCallback`** (requirement B12). The hook receives updates of **applied bindings**, not every state update (use `$watch` for those), and the new name says so. The old name works the same through 3.x and is removed in 4.0. Declaring both fails with `[wcs/declaration-alias]`. On 3.1 or earlier, write `$updatedCallback`.
|
|
2634
|
+
|
|
2627
2635
|
```html
|
|
2628
2636
|
<wcs-state>
|
|
2629
2637
|
<script type="module">
|