@wcstack/state 4.7.0 → 4.8.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 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.7.0/dist/split/core.js",
197
- "@wcstack/state/features/temporal": "https://cdn.jsdelivr.net/npm/@wcstack/state@4.7.0/dist/split/features/temporal.js",
198
- "@wcstack/state/features/scopes": "https://cdn.jsdelivr.net/npm/@wcstack/state@4.7.0/dist/split/features/scopes.js"
196
+ "@wcstack/state/core": "https://cdn.jsdelivr.net/npm/@wcstack/state@4.8.0/dist/split/core.js",
197
+ "@wcstack/state/features/temporal": "https://cdn.jsdelivr.net/npm/@wcstack/state@4.8.0/dist/split/features/temporal.js",
198
+ "@wcstack/state/features/scopes": "https://cdn.jsdelivr.net/npm/@wcstack/state@4.8.0/dist/split/features/scopes.js"
199
199
  }
200
200
  }
201
201
  </script>
@@ -261,7 +261,7 @@
261
261
  ページが名指したアドオンを、同じビルドから読み込みます。
262
262
 
263
263
  ```html
264
- <script type="module" src="https://cdn.jsdelivr.net/npm/@wcstack/state@4.7.0/dist/split/auto.js"></script>
264
+ <script type="module" src="https://cdn.jsdelivr.net/npm/@wcstack/state@4.8.0/dist/split/auto.js"></script>
265
265
  <wcs-state features="scopes diagnostics">
266
266
  <script type="module">
267
267
  export default {
@@ -2862,7 +2862,7 @@ export default {
2862
2862
  `$disconnectedCallback` を除くすべてのフックで `async` を使用できます。リアクティブ Proxy はすべてのプロパティへの代入を変更として検知します。そのため、標準の `async/await` による処理とプロパティへの直接代入だけで非同期ロジックが完結します。ローディングフラグの切り替え、取得したデータの格納、エラーメッセージの更新といった処理もすべて単なるプロパティ代入で行えるため、非同期状態を管理するための複雑な抽象化機能は必要ありません。
2863
2863
 
2864
2864
  - フック内の `this` は読み書き可能な状態プロキシです。
2865
- - `$connectedCallback` は要素が接続される**たびに**呼ばれます(一度削除された後の再接続も含みます)。再確立が必要なセットアップ処理に適しています。
2865
+ - `$connectedCallback` は要素が接続される**たびに**呼ばれます(一度削除された後の再接続も含みます)。再確立が必要なセットアップ処理に適しています。これは要素の接続で、ページのものではありません: ページがスリープから復帰したとき、凍結から再開したとき、back/forward cache から戻ったとき、可視になったときには走りません — [開いたままのページ](../../docs/long-lived-pages.ja.md) を見てください。
2866
2866
  - `$disconnectedCallback` は同期的に呼び出されます。タイマーのクリア、イベントリスナーの削除、リソースの解放といったクリーンアップ処理に使用してください。
2867
2867
  - `$renderedCallback(paths, indexesListByPath)` は、その drain で live binding が適用された path の一覧を受け取ります。binding のない state 書き込みでは呼ばれず、`paths` にも現れません。ワイルドカードをもつパスが更新された場合は、`indexesListByPath` から対象のインデックス情報も取得可能です。マウントされたコンポーネントのバインディングは、したがってその私有キーも、ホストの `paths` には決して現れません。`async` を使用できますが、戻り値は await されません。throw または reject した場合は `console.error` で報告されます。
2868
2868
  - `$errorCallback(error, info)` はバインディングの**ページ内エラー境界**です。バインディングの適用が throw したとき(パス getter やフィルタが throw した、構造ディレクティブが失敗した)、その失敗は隔離され(同じバッチの残りは適用され、値も DOM も巻き戻されません)、このフックが無ければ `console.error` で報告されます。フックを宣言すると報告はそこへ届きます: `error` は throw された値、`info` はバインディングを識別する `{ path, bindingType, node }`(`path` は `data-wcs` に書いた形のまま。ワイルドカードもそのまま。`for:` で描画していないリスト —— `$getAll` か `$watch` だけが保持しているリスト —— では `node` は `null`)。`for:` / `if:` の行の中で取り付け時に拒否されたバインディング(未宣言の token、要素が宣言していないメンバ)も、そのバインディングの失敗としてここに報告され、行はそのまま構築されます。`this` は書き込み可能な state proxy なので、メッセージを state に書いて普通に描画するのが基本形です:
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.7.0/dist/split/core.js",
198
- "@wcstack/state/features/temporal": "https://cdn.jsdelivr.net/npm/@wcstack/state@4.7.0/dist/split/features/temporal.js",
199
- "@wcstack/state/features/scopes": "https://cdn.jsdelivr.net/npm/@wcstack/state@4.7.0/dist/split/features/scopes.js"
197
+ "@wcstack/state/core": "https://cdn.jsdelivr.net/npm/@wcstack/state@4.8.0/dist/split/core.js",
198
+ "@wcstack/state/features/temporal": "https://cdn.jsdelivr.net/npm/@wcstack/state@4.8.0/dist/split/features/temporal.js",
199
+ "@wcstack/state/features/scopes": "https://cdn.jsdelivr.net/npm/@wcstack/state@4.8.0/dist/split/features/scopes.js"
200
200
  }
201
201
  }
202
202
  </script>
@@ -263,7 +263,7 @@ receptacle the owning add-on fills on install).
263
263
  core, and the add-ons the page names from the same build.
264
264
 
265
265
  ```html
266
- <script type="module" src="https://cdn.jsdelivr.net/npm/@wcstack/state@4.7.0/dist/split/auto.js"></script>
266
+ <script type="module" src="https://cdn.jsdelivr.net/npm/@wcstack/state@4.8.0/dist/split/auto.js"></script>
267
267
  <wcs-state features="scopes diagnostics">
268
268
  <script type="module">
269
269
  export default {
@@ -2874,7 +2874,7 @@ State objects can define `$connectedCallback`, `$disconnectedCallback`, `$render
2874
2874
  All hooks except `$disconnectedCallback` support `async` — you can use `async/await` in any of them. Since the reactive proxy detects every property assignment as a change, standard `async/await` with direct property updates is sufficient for asynchronous operations — loading flags, fetched data, and error messages are all just property assignments, without requiring additional abstractions for async state management.
2875
2875
 
2876
2876
  - `this` inside hooks is the state proxy with full read/write access
2877
- - `$connectedCallback` is called **every time** the element is connected (including re-insertion after removal), making it suitable for setup that should be re-established
2877
+ - `$connectedCallback` is called **every time** the element is connected (including re-insertion after removal), making it suitable for setup that should be re-established. It is the element's connection, not the page's: it does not run when the page wakes from sleep, resumes from a freeze, comes back from the back/forward cache or becomes visible — see [Pages that stay open](../../docs/long-lived-pages.md)
2878
2878
  - `$disconnectedCallback` is called synchronously — use it for cleanup such as clearing timers, removing event listeners, or releasing resources
2879
2879
  - `$renderedCallback(paths, indexesListByPath)` receives the paths whose live bindings were applied in that drain. Unbound state writes do not invoke it or appear in `paths`. For wildcard updates, `indexesListByPath` contains the updated index sets. A mounted component's bindings, and so its private keys, never appear in the host's `paths`. Can be `async`, but the return value is not awaited; one that throws or rejects is reported with `console.error`
2880
2880
  - `$errorCallback(error, info)` is the in-page **error boundary** for bindings. When applying a binding throws — a path getter or filter threw, a structural directive failed — the failure is isolated (the rest of the batch still applies, and neither the value nor the DOM is rolled back) and, without this hook, reported with `console.error`. Declare the hook and the report comes to you instead: `error` is what was thrown, `info` is `{ path, bindingType, node }` identifying the binding (`path` as written in `data-wcs`, wildcards intact; `node` is `null` for a list that no `for:` renders — one only `$getAll` or `$watch` keeps). A binding refused as it is attached inside a `for:` / `if:` row (an undeclared token, a member the element does not declare) is reported here too, as that binding's failure, and the row is still built. `this` is the writable state proxy, so the usual shape is to write the message into state and render it like anything else: