@wcstack/broadcast 1.15.0 → 1.16.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 +1 -1
- package/README.md +1 -1
- package/package.json +1 -1
package/README.ja.md
CHANGED
|
@@ -151,7 +151,7 @@ post は DOM クリック(autoTrigger)または command-token から起動
|
|
|
151
151
|
- **自己除外は意図的。** あるコンテキストは自分自身の post を決して受信しません — これは BroadcastChannel の契約であり、バグではありません。往復を見るには、第 2 のコンテキスト(タブ/iframe/worker、または同じチャンネル名の第 2 の `<wcs-broadcast>`)を listen させてください。*同じ*タブ内の 2 つの `<wcs-broadcast name="x">` 要素は互いに受信します(別々のチャンネルオブジェクトだから)。単一の要素が自分自身に話しかける場合だけは受信しません。
|
|
152
152
|
- **`name` は監視される。** `<wcs-clipboard>` と異なり、`<wcs-broadcast>` は `name` に対して `observedAttributes` を実装します。接続中(かつ非 `manual`)に `name` 属性を変更すると、古いチャンネルを閉じて新しいチャンネルを開きます。`name` をクリアする(空文字列にする、または属性を削除する)のは close *ではありません*。別の `name` に切り替えるか、明示的に `close()` を呼ぶまで、以前開いたチャンネルは維持されます。空でない新しい値だけが切り替えをトリガします。
|
|
153
153
|
- **ワイヤエンコーディングは無い。** ペイロードは structured clone を使うため、JSON の stringify/parse ステップはありません(テキストワイヤで送る `<wcs-ws>` と異なります)。オブジェクトを直接 post すると、受信側はディープコピーを得ます。クローン不可能な値は `error` 経由で `DataCloneError` として失敗します。
|
|
154
|
-
- **接続状態は無い。** BroadcastChannel は構築された瞬間に「開いて」います — connecting/ハンドシェイク段階も、`readyState` も、再接続もありません(必要ないため)。Shell
|
|
154
|
+
- **接続状態は無い。** BroadcastChannel は構築された瞬間に「開いて」います — connecting/ハンドシェイク段階も、`readyState` も、再接続もありません(必要ないため)。Shell は接続時に同期的に開くので `connectedCallbackPromise` は即座に resolve する(解決済み promise)が、`hasConnectedCallbackPromise = true` として公開されており、state バインダ / SSR がスナップショット前に一様に readiness を await できます。
|
|
155
155
|
- **再接続で開き直す。** 要素を削除して再挿入すると `connectedCallback` が再度実行され、`name` 属性(真実の源)からチャンネルを開き直します。`disconnectedCallback` がそれを閉じます。
|
|
156
156
|
- **無言のエラー処理(ゼロログ)。** wcstack 全体のゼロ依存主義に従い、`<wcs-broadcast>` は実行時の失敗に対して一切ログ出力も throw もしません。BroadcastChannel コンストラクタの欠如、クローン不可能な post、デシリアライズ失敗は `error` プロパティ / `wcs-broadcast:error` イベントを通じてのみ表面化します — `post()` は resolve し、決して reject しません。観測・対処するには `error` をバインドしてください。
|
|
157
157
|
|
package/README.md
CHANGED
|
@@ -151,7 +151,7 @@ State-driven invocation uses the command-token protocol:
|
|
|
151
151
|
- **Self-exclusion is intentional.** A context never receives its own posts — this is the BroadcastChannel contract, not a bug. To see a round trip, have a second context (tab/iframe/worker, or a second `<wcs-broadcast>` on the same channel name) listening. Two `<wcs-broadcast name="x">` elements in the *same* tab do hear each other (they are distinct channel objects); only a single element talking to itself does not.
|
|
152
152
|
- **`name` is observed.** Unlike `<wcs-clipboard>`, `<wcs-broadcast>` implements `observedAttributes` for `name`: changing the `name` attribute while connected (and not `manual`) closes the old channel and opens the new one. Clearing the `name` (setting it to an empty string or removing the attribute) is *not* a close: the previously-open channel is kept until you switch to another `name` or call `close()` explicitly. Only a non-empty new value triggers the switch.
|
|
153
153
|
- **No wire encoding.** Payloads use structured clone, so there is no JSON stringify/parse step (unlike `<wcs-ws>`, which sends over a text wire). Post objects directly; receivers get a deep copy. Non-cloneable values fail with `DataCloneError` via `error`.
|
|
154
|
-
- **No connection state.** A BroadcastChannel is "open" the moment it is constructed — there is no connecting/handshake phase, no `readyState`, and no reconnect (none is needed). The Shell opens synchronously on connect, so
|
|
154
|
+
- **No connection state.** A BroadcastChannel is "open" the moment it is constructed — there is no connecting/handshake phase, no `readyState`, and no reconnect (none is needed). The Shell opens synchronously on connect, so its `connectedCallbackPromise` resolves immediately (an already-resolved promise). It is still exposed (`hasConnectedCallbackPromise = true`) so a state binder / SSR can uniformly await readiness before snapshotting.
|
|
155
155
|
- **Reconnect re-opens.** Removing and re-inserting the element runs `connectedCallback` again, re-opening the channel from the `name` attribute (the source of truth), and `disconnectedCallback` closes it.
|
|
156
156
|
- **Silent failure handling (zero-log).** Consistent with the rest of wcstack's zero-dependency philosophy, `<wcs-broadcast>` never logs or throws for runtime failures. A missing BroadcastChannel constructor, a non-cloneable post, or a deserialization failure are surfaced only through the `error` property / `wcs-broadcast:error` event — `post()` resolves and never rejects. Bind `error` to observe and react.
|
|
157
157
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wcstack/broadcast",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.0",
|
|
4
4
|
"description": "Declarative cross-tab messaging component for Web Components. Framework-agnostic BroadcastChannel primitive via wc-bindable-protocol.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.esm.js",
|