@wcstack/state 4.12.0 → 4.14.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 +6 -4
- package/README.md +6 -4
- package/dist/auto.min.js +1 -1
- package/dist/auto.min.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/split/auto.js +1 -1
- package/dist/split/chunks/{chunk-AKTGQ6TC.js → chunk-5PFTBGC7.js} +2 -2
- package/dist/split/chunks/{chunk-R6RHIIR4.js → chunk-ALYYWWPL.js} +2 -2
- package/dist/split/chunks/chunk-DHV2WUX5.js +2 -0
- package/dist/split/chunks/{chunk-XEMLOHP4.js.map → chunk-DHV2WUX5.js.map} +1 -1
- package/dist/split/chunks/{chunk-JJYM4JVZ.js → chunk-I4ZP4WH2.js} +2 -2
- package/dist/split/chunks/chunk-LCNUPJVY.js +2 -0
- package/dist/split/chunks/chunk-LCNUPJVY.js.map +1 -0
- package/dist/split/chunks/chunk-RVC5OLGX.js +2 -0
- package/dist/split/chunks/{chunk-KBQKAD3I.js → chunk-RXVQOSBW.js} +2 -2
- package/dist/split/chunks/{chunk-IYPAK7PO.js → chunk-RYFDGWVL.js} +2 -2
- package/dist/split/chunks/{chunk-NAV7FBTI.js → chunk-S2WW44DA.js} +2 -2
- package/dist/split/chunks/{chunk-LPJFTEVT.js → chunk-X5LBPLRG.js} +2 -2
- package/dist/split/chunks/{chunk-E3XSBW55.js → chunk-Z3S7RWB7.js} +2 -2
- package/dist/split/core.js +1 -1
- package/dist/split/features/devtools.js +1 -1
- package/dist/split/features/diagnostics.js +1 -1
- package/dist/split/features/formats.js +1 -1
- package/dist/split/features/list-keys.js +1 -1
- package/dist/split/features/native-commands.js +1 -1
- package/dist/split/features/recursion.js +1 -1
- package/dist/split/features/scopes.js +1 -1
- package/dist/split/features/ssr.js +1 -1
- package/dist/split/features/temporal.js +1 -1
- package/package.json +1 -1
- package/dist/split/chunks/chunk-CYMUD7KV.js +0 -2
- package/dist/split/chunks/chunk-CYMUD7KV.js.map +0 -1
- package/dist/split/chunks/chunk-REB4RMZ3.js +0 -2
- package/dist/split/chunks/chunk-XEMLOHP4.js +0 -2
- /package/dist/split/chunks/{chunk-AKTGQ6TC.js.map → chunk-5PFTBGC7.js.map} +0 -0
- /package/dist/split/chunks/{chunk-R6RHIIR4.js.map → chunk-ALYYWWPL.js.map} +0 -0
- /package/dist/split/chunks/{chunk-JJYM4JVZ.js.map → chunk-I4ZP4WH2.js.map} +0 -0
- /package/dist/split/chunks/{chunk-REB4RMZ3.js.map → chunk-RVC5OLGX.js.map} +0 -0
- /package/dist/split/chunks/{chunk-KBQKAD3I.js.map → chunk-RXVQOSBW.js.map} +0 -0
- /package/dist/split/chunks/{chunk-IYPAK7PO.js.map → chunk-RYFDGWVL.js.map} +0 -0
- /package/dist/split/chunks/{chunk-NAV7FBTI.js.map → chunk-S2WW44DA.js.map} +0 -0
- /package/dist/split/chunks/{chunk-LPJFTEVT.js.map → chunk-X5LBPLRG.js.map} +0 -0
- /package/dist/split/chunks/{chunk-E3XSBW55.js.map → chunk-Z3S7RWB7.js.map} +0 -0
package/README.ja.md
CHANGED
|
@@ -193,9 +193,9 @@
|
|
|
193
193
|
<script type="importmap">
|
|
194
194
|
{
|
|
195
195
|
"imports": {
|
|
196
|
-
"@wcstack/state/core": "https://cdn.jsdelivr.net/npm/@wcstack/state@4.
|
|
197
|
-
"@wcstack/state/features/temporal": "https://cdn.jsdelivr.net/npm/@wcstack/state@4.
|
|
198
|
-
"@wcstack/state/features/scopes": "https://cdn.jsdelivr.net/npm/@wcstack/state@4.
|
|
196
|
+
"@wcstack/state/core": "https://cdn.jsdelivr.net/npm/@wcstack/state@4.14.0/dist/split/core.js",
|
|
197
|
+
"@wcstack/state/features/temporal": "https://cdn.jsdelivr.net/npm/@wcstack/state@4.14.0/dist/split/features/temporal.js",
|
|
198
|
+
"@wcstack/state/features/scopes": "https://cdn.jsdelivr.net/npm/@wcstack/state@4.14.0/dist/split/features/scopes.js"
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
</script>
|
|
@@ -269,7 +269,7 @@ already defined by another copy of @wcstack/state that does not name its version
|
|
|
269
269
|
ページが名指したアドオンを、同じビルドから読み込みます。
|
|
270
270
|
|
|
271
271
|
```html
|
|
272
|
-
<script type="module" src="https://cdn.jsdelivr.net/npm/@wcstack/state@4.
|
|
272
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/@wcstack/state@4.14.0/dist/split/auto.js"></script>
|
|
273
273
|
<wcs-state features="scopes diagnostics">
|
|
274
274
|
<script type="module">
|
|
275
275
|
export default {
|
|
@@ -814,6 +814,8 @@ export default {
|
|
|
814
814
|
|
|
815
815
|
つまり、**行オブジェクトの参照さえ保たれていれば、行の追加・削除・並べ替えに明示的なキー属性(React の `key` や Vue の `:key`)は不要です**。非破壊の配列メソッド(`toSorted` / `toReversed` / `filter` / `with` / `toSpliced`)はいずれも要素の参照を保つため、ソートやフィルタは構造的に keyed に動作し、「キーの付け方を間違える」種類のバグが原理的に発生しません。
|
|
816
816
|
|
|
817
|
+
**並べ替えで動かした行は、取り外しでリセットされるもの —— フォーカス、iframe の中のページ、実行中の CSS アニメーションやトランジション —— を保ちます**。ブラウザに [`moveBefore()`](https://developer.mozilla.org/ja/docs/Web/API/Element/moveBefore) があるとき(Chromium 133 以降、Firefox 144 以降)で、4.14 からです。差分はできるだけ少ない行だけを動かし、その場に残した行はどのブラウザでもそれを保ちます。`moveBefore()` の無いブラウザ —— Safari —— では、動かした行はそれを失います(4.13 まではどのブラウザでもそうでした)。動かした行の中のカスタム要素には、今までどおり `disconnectedCallback` と `connectedCallback` が呼ばれます。そのクラスが `connectedMoveCallback` を定義していれば、ブラウザは代わりにそれを呼びます。
|
|
818
|
+
|
|
817
819
|
例外は、**新しく生成されたオブジェクトとして届くデータ**です。`fetch(...).json()`、ストレージからの `JSON.parse`、WebSocket / SSE の全件スナップショット、Worker の `postMessage` などがこれにあたります。これらの行は参照で照合できないため、全行が破棄・再構築されます。次の [`$listKeys`](#listkeys--再取得された行の同一性) を参照してください。
|
|
818
820
|
|
|
819
821
|
**`for:` は出力フィルタを取りません。** `for: items|take(2)` は、フィルタが何であれ `[wcs/binding-syntax] #121` で初期化を失敗させます。`for: items` の行は `items.<index>` なので、フィルタ後の配列の行は別の要素を指してしまい、その行を通した書き込みが間違った要素に届きます。絞り込んだリストを返す getter を宣言し、それをループしてください:
|
package/README.md
CHANGED
|
@@ -194,9 +194,9 @@ leaves features out, it can compose them instead:
|
|
|
194
194
|
<script type="importmap">
|
|
195
195
|
{
|
|
196
196
|
"imports": {
|
|
197
|
-
"@wcstack/state/core": "https://cdn.jsdelivr.net/npm/@wcstack/state@4.
|
|
198
|
-
"@wcstack/state/features/temporal": "https://cdn.jsdelivr.net/npm/@wcstack/state@4.
|
|
199
|
-
"@wcstack/state/features/scopes": "https://cdn.jsdelivr.net/npm/@wcstack/state@4.
|
|
197
|
+
"@wcstack/state/core": "https://cdn.jsdelivr.net/npm/@wcstack/state@4.14.0/dist/split/core.js",
|
|
198
|
+
"@wcstack/state/features/temporal": "https://cdn.jsdelivr.net/npm/@wcstack/state@4.14.0/dist/split/features/temporal.js",
|
|
199
|
+
"@wcstack/state/features/scopes": "https://cdn.jsdelivr.net/npm/@wcstack/state@4.14.0/dist/split/features/scopes.js"
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
</script>
|
|
@@ -272,7 +272,7 @@ receptacle the owning add-on fills on install).
|
|
|
272
272
|
core, and the add-ons the page names from the same build.
|
|
273
273
|
|
|
274
274
|
```html
|
|
275
|
-
<script type="module" src="https://cdn.jsdelivr.net/npm/@wcstack/state@4.
|
|
275
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/@wcstack/state@4.14.0/dist/split/auto.js"></script>
|
|
276
276
|
<wcs-state features="scopes diagnostics">
|
|
277
277
|
<script type="module">
|
|
278
278
|
export default {
|
|
@@ -823,6 +823,8 @@ The `for:` directive uses a **value-based diff algorithm** — each array elemen
|
|
|
823
823
|
|
|
824
824
|
This means **no explicit `key` attribute is needed for adding, removing, or reordering rows** (like React's `key` or Vue's `:key`) — as long as row objects keep their references. Non-destructive array methods (`toSorted`, `toReversed`, `filter`, `with`, `toSpliced`) all preserve element references, so sorting and filtering are keyed by construction, and the whole class of "wrong key" bugs cannot occur.
|
|
825
825
|
|
|
826
|
+
**A row a reorder moves keeps what a removal would reset** — focus, an iframe's page, a running CSS animation or transition — where the browser has [`moveBefore()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/moveBefore) (Chromium 133+, Firefox 144+), since 4.14. The differ moves as few rows as it can, and a row it leaves in place keeps that state in any browser; in a browser without `moveBefore()` — Safari — a row it moves loses it, as every browser did up to 4.13. A custom element in a moved row still gets `disconnectedCallback` and `connectedCallback`, unless its class defines `connectedMoveCallback`, which the browser then calls instead.
|
|
827
|
+
|
|
826
828
|
The exception is data that arrives as **freshly created objects** — `fetch(...).json()`, `JSON.parse` from storage, a WebSocket/SSE full snapshot, or a Worker `postMessage`. Those rows never match by reference, so every row is torn down and rebuilt. See [`$listKeys`](#listkeys--identity-for-refetched-rows) below.
|
|
827
829
|
|
|
828
830
|
**`for:` takes no output filters.** `for: items|take(2)` fails initialization with `[wcs/binding-syntax] #121`, whatever the filter. A row of `for: items` is `items.<index>`, so the rows of a filtered array would name other elements, and writes through them would land on the wrong ones. Declare a getter that returns the filtered list, and loop over it:
|