@wcstack/picture-in-picture 4.24.1 → 4.25.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
@@ -10,7 +10,7 @@
10
10
  `@wcstack/state` と組み合わせると、`<wcs-pip>` はパス契約で直接バインドできます:
11
11
 
12
12
  - **入力サーフェス**: `target` — どの `<video>` 要素を操作するか
13
- - **出力 state サーフェス**: `active`、`error`、`errorInfo`
13
+ - **出力 state サーフェス**: `active`、`error`、`errorInfo`、`supported`
14
14
  - **コマンドサーフェス**: `requestPictureInPicture()`、`exitPictureInPicture()`
15
15
 
16
16
  これにより、`document.pictureInPictureElement` を手動でポーリングしたりレイアウトを気にしたりせずに、「ポップアウト」ボタンを HTML 上で宣言的に表現できます。
@@ -31,7 +31,7 @@
31
31
 
32
32
  「Picture-in-Picture」という名前を持つ、互いに無関係な2つのWeb Platform提案が存在します:
33
33
 
34
- - **古典的な Picture-in-Picture API**(`HTMLVideoElement.requestPictureInPicture()`)— `<video>` 限定で、広くサポートされています。**`<wcs-pip>` が包むのはこちらです。**
34
+ - **古典的な Picture-in-Picture API**(`HTMLVideoElement.requestPictureInPicture()`)— `<video>` 限定で、Chromium 系のブラウザと Safari が実装しています。**Firefox には、ページが使える Picture-in-Picture API がありません**: 動画の上に出るボタンはブラウザ自身のもので、ページからは押すことも観測することもできません。**`<wcs-pip>` が包むのはこちらです**。ページにそれがあるかは `supported` 出力が伝えます。
35
35
  - **Document Picture-in-Picture API**(`documentPictureInPicture.requestWindow()`)— 動画に限らず任意のDOMサブツリーを別の常に最前面のウィンドウに浮かせられます。API 形状(別の `Window` を取得してそこへ DOM を移動する)が、本ノードが `fullscreen`/`pointer-lock` と共有する「target を解決し、document レベルの状態を監視する」というアーキタイプと根本的に異なります。
36
36
 
37
37
  **`<wcs-pip>` は古典的な `<video>` 限定 API を対象とします。Document Picture-in-Picture API は v1 のスコープ外です**(`docs/picture-in-picture-tag-design.md` §4 参照)。将来的に別ノード(例: `<wcs-doc-pip>`)として切り出される可能性があります。
@@ -143,9 +143,10 @@ if (pip.error) {
143
143
 
144
144
  | プロパティ | 型 | イベント | 説明 |
145
145
  |-------------|--------------------------|------------------------------|------|
146
- | `active` | `boolean` | `wcs-pip:change` | 解決済みの `<video>` target が現在 document の Picture-in-Picture 要素かどうか。 |
146
+ | `active` | `boolean` | `wcs-pip:change` | 解決済みの `<video>` target が現在 document の Picture-in-Picture 要素かどうか。4.25 から、`<wcs-pip>` が文書の外にある間は `false`([要素が文書を離れるとき](#要素が文書を離れるとき)参照)。 |
147
147
  | `error` | `any` | `wcs-pip:error` | 直近のコマンド失敗(不正なタグ・非対応API・gesture 制約による reject)、または直近が成功/未失敗なら `null`。observable 化しても `error` の値の形自体は不変。 |
148
148
  | `errorInfo` | `WcsIoErrorInfo \| null` | `wcs-pip:error-info-changed` | `error` から導出される追加的でシリアライズ可能な失敗 **taxonomy**: 安定した `{ code, phase, recoverable, message }`。`error` と歩調を合わせて `null` になる。下の taxonomy 表参照。 |
149
+ | `supported` | `boolean` | `wcs-pip:supported-changed` | 4.25 から。このページで Picture-in-Picture を使えるなら `true`、使えないなら `false`(Firefox、Permissions-Policy が禁じた文書)。イベントの `detail` は boolean そのもの。下記参照。 |
149
150
 
150
151
  `active` は、`enterpictureinpicture`/`leavepictureinpicture` が**その対象要素自身に**発火するたびに、`document.pictureInPictureElement` と解決済み `<video>` target を比較して導出されます(`document` レベルのイベントではありません — 詳細は下記「イベント購読」参照)。
151
152
 
@@ -160,6 +161,29 @@ if (pip.error) {
160
161
  | `not-allowed` | `execute` | `true` | `NotAllowedError` / `TypeError` で reject(例: ユーザージェスチャー外での呼び出し)— 本物のジェスチャー内で再試行すれば成功しうる。 |
161
162
  | `pip-error` | `execute` | `false` | プラットフォーム呼び出しからのその他の caught 例外。 |
162
163
 
164
+ ### `supported` — このページで Picture-in-Picture を使えるか
165
+
166
+ 4.25 から。`supported` は、このページで Picture-in-Picture を使えるときに `true` です: 文書が有効と答え(`document.pictureInPictureEnabled`)、`<video>` に `requestPictureInPicture()` があり、Permissions-Policy が切っていない — サーバーの `Permissions-Policy: picture-in-picture=()` ヘッダーも、`allow` 属性で止めている `<iframe>` も無い(fullscreen と違い、フレームはポリシーが止めない限り Picture-in-Picture を使えます)— 場合です。それ以外は、理由が何であれ `false` です。**Firefox には、ページが使える Picture-in-Picture API が無いので、そこでは `supported` は `false` です。**
167
+
168
+ 要求が通ることまでは言いません。要求には user gesture と、映すもののある動画が要り、`<video disablepictureinpicture>` は断ります。Picture-in-Picture は安全なコンテキストを要らないので、素の `http:` のページであることだけでは `false` になりません。
169
+
170
+ 値は聞かれるたびにブラウザから読みます(キャッシュしません)。だからバインディングは、付いた時点で正しい値を得ます。要素は接続されたとき、最後に発火した値と違えば `wcs-pip:supported-changed` も発火します(最初は `false` なので、Picture-in-Picture を使えるページでは `true` が 1 回届きます)。ボタンは、使えるところでだけ出します:
171
+
172
+ ```html
173
+ <wcs-state>
174
+ <script type="module">
175
+ export default {
176
+ $commandTokens: ["popOut"],
177
+ pipSupported: false,
178
+ };
179
+ </script>
180
+ </wcs-state>
181
+
182
+ <video id="player" src="/movie.mp4" controls></video>
183
+ <wcs-pip target="#player" data-wcs="supported: pipSupported; command.requestPictureInPicture: $command.popOut"></wcs-pip>
184
+ <button data-wcs="hidden: pipSupported|not; onclick: $command.popOut">ポップアウト</button>
185
+ ```
186
+
163
187
  ## コマンド
164
188
 
165
189
  | コマンド | 説明 |
@@ -179,6 +203,26 @@ Fullscreen の `fullscreenchange`(`document` に発火)と異なり、Pictur
179
203
 
180
204
  これにより、複数の `<wcs-pip>` インスタンスは自然に自己フィルタされます。各インスタンスは自分の `<video>` target のイベントのみを受け取るため、あるインスタンスが Picture-in-Picture に入っても他のインスタンスの `active` が誤って `true` になることはありません(`docs/picture-in-picture-tag-design.md` §5 参照)。
181
205
 
206
+ ## 要素が文書を離れるとき
207
+
208
+ 4.25 から。`<wcs-pip>` が自分の `<video>` を聞いているのは、接続されている間だけです。`active` が `true` の間に切断されると — `if:` の枝が消える、`@wcstack/router` がルートの本文を取り外す — `active: false` を `wcs-pip:change` イベントとともに公開します。バインドした state のパスも `:state(active)` もそれに従います。文書の外にある要素は、その値をもう保証できないからです。小窓は**閉じません**。再び接続されると本当の値を読み直し、`<video>` がまだ document の Picture-in-Picture 要素なら `active` はイベントとともに `true` に戻ります。そのため、移動された(取り外して入れ直された)要素は `false`、`true` の順に報告します。4.24 までは切断しても `active` がそのまま残り、小窓が閉じられた後も state は `true` を示し続けていました。
209
+
210
+ 小窓をどうするかはブラウザが決めます。**ナビゲーションをまたいで小窓を続けるには、`<video>` が文書に残っていなければなりません。** ルートの本文の中にある `<video>` は、ルートを離れると取り外されます。Chromium は取り外された動画を小窓で再生し続けますが、ほかのブラウザはそうとは限りません — そして `<wcs-pip>` も一緒に去っているので、どちらの場合も `active` はルートが戻るまで `false` です。動画とその `<wcs-pip>` はルーターの外、残り続けるレイアウトの側に置いてください([router README — ルートの本文はどこに置くか](../router/README.ja.md#ルートの本文はどこに置くか))。動画は再生を続け、小窓は残り、`active` はどのルートでも本当の値を伝え続けます。
211
+
212
+ ```html
213
+ <wcs-router>
214
+ <template>
215
+ <wcs-route path="/">…</wcs-route>
216
+ <wcs-route path="/schedule">…</wcs-route>
217
+ </template>
218
+ </wcs-router>
219
+ <wcs-outlet></wcs-outlet>
220
+
221
+ <!-- ルートの外: どのページでも文書の中にある。state はクイックスタート 1 のもの。 -->
222
+ <video id="player" src="/movie.mp4" controls></video>
223
+ <wcs-pip target="#player" data-wcs="active: pipActive; command.requestPictureInPicture: $command.popOut; command.exitPictureInPicture: $command.backToPage"></wcs-pip>
224
+ ```
225
+
182
226
  ## `:state()` による CSS スタイリング
183
227
 
184
228
  `<wcs-pip>` は 1 つの boolean 出力ステートを
@@ -199,7 +243,8 @@ wcs-pip:state(active) ~ .back-to-page-button { display: none; } /* デフォル
199
243
  入力と混同される心配がありません。`error`/`errorInfo` はあえて `:state()` に反映して
200
244
  いません — presence/absence 疑似クラスに素直に対応するのは boolean の `active` のみだから
201
245
  です。(`error`/`errorInfo` は各自のイベントで観測可能であり `data-wcs` でバインドできます
202
- — 上記「出力 state」参照。)
246
+ — 上記「出力 state」参照。)`supported` も反映しません。バインドしてください
247
+ (`supported: pipSupported`)。
203
248
 
204
249
  **対応ブラウザ**(新構文 `:state(x)`): Chrome/Edge 125+、Safari 17.4+、Firefox 126+。
205
250
  非対応の環境ではステートが一切 set されないだけです — `:state()` セレクタがマッチしなく
@@ -243,6 +288,7 @@ PipCore.wcBindable = {
243
288
  { name: "active", event: "wcs-pip:change", getter: (e) => e.detail.active },
244
289
  { name: "error", event: "wcs-pip:error" },
245
290
  { name: "errorInfo", event: "wcs-pip:error-info-changed" },
291
+ { name: "supported", event: "wcs-pip:supported-changed" }, // 4.25
246
292
  ],
247
293
  commands: [
248
294
  { name: "requestPictureInPicture", async: true },
@@ -274,10 +320,14 @@ await core.exitPictureInPicture();
274
320
  core.dispose(); // リスナーを外す
275
321
  ```
276
322
 
323
+ 4.25 から、`dispose()` は `active` が `true` だったとき `active: false` を公開し(dispose した Core はもう video を聞いていません)、次の `observe(video)` が読み直します。`core.supported` と、`observe()` が発火する `wcs-pip:supported-changed` イベントは、このページで Picture-in-Picture を使えるかを伝えます。
324
+
277
325
  Core の構造サーフェスは wcstack I/O ノード横断の規範です([async-io-node-guidelines §3.9](../../docs/async-io-node-guidelines.ja.md))。要素なしで signals に束縛するには [@wcstack/signals — Core を直接束縛する](../signals/README.ja.md#core-を直接束縛する要素なし) を参照。
278
326
 
279
327
  ## 注意・制限
280
328
 
329
+ - **Firefox には、ページが使える Picture-in-Picture API が無い。** そこでは `supported` は `false` で、要求は `error`(`{ message: "Picture-in-Picture API is not supported." }`、`capability-missing`)で終わります。ボタンは `supported` で隠してください。動画に付くブラウザ自身の Picture-in-Picture のボタンは、利用者にはそのまま使えます。
330
+ - **小窓がナビゲーションをまたぐには、`<video>` が文書に残っていなければならない。** 動画とその `<wcs-pip>` はルーターの外に置いてください — 上記「要素が文書を離れるとき」参照。
281
331
  - **`<video>` 限定。** `target` は `HTMLVideoElement` に解決される必要があります。それ以外の要素は未解決扱いになり、`error` に `{ message: "target must be a <video> element." }` がセットされます(例外は投げません)。
282
332
  - **Document Picture-in-Picture API はスコープ外。** 上記「スコープ」参照。
283
333
  - **例外を投げない。** 非対応環境・不正なタグの target・gesture 制約による reject は全て `error` に集約されます。
package/README.md CHANGED
@@ -10,7 +10,7 @@ It is an **async primitive node** that turns a `<video>` element's Picture-in-Pi
10
10
  With `@wcstack/state`, `<wcs-pip>` can be bound directly through path contracts:
11
11
 
12
12
  - **input surface**: `target` — which `<video>` element to control
13
- - **output state surface**: `active`, `error`, `errorInfo`
13
+ - **output state surface**: `active`, `error`, `errorInfo`, `supported`
14
14
  - **command surface**: `requestPictureInPicture()`, `exitPictureInPicture()`
15
15
 
16
16
  This means a "pop out" video button — with no live-region layout thrashing, no manual `document.pictureInPictureElement` polling — can be expressed declaratively in HTML.
@@ -31,7 +31,7 @@ Like `@wcstack/fullscreen`, this Shell is a non-visible **control tag**: it does
31
31
 
32
32
  There are two unrelated web platform proposals under the "Picture-in-Picture" name:
33
33
 
34
- - **The classic Picture-in-Picture API** (`HTMLVideoElement.requestPictureInPicture()`) — `<video>`-only, broadly supported. **This is what `<wcs-pip>` wraps.**
34
+ - **The classic Picture-in-Picture API** (`HTMLVideoElement.requestPictureInPicture()`) — `<video>`-only, implemented by Chromium-based browsers and Safari. **Firefox has no Picture-in-Picture API for pages**: the button it shows over a video is the browser's own, and a page can neither press it nor observe it. **This is what `<wcs-pip>` wraps**; the `supported` output says whether the page has it.
35
35
  - **The Document Picture-in-Picture API** (`documentPictureInPicture.requestWindow()`) — lets you float an arbitrary DOM subtree in a separate always-on-top window, not limited to video. Its API shape (acquiring a separate `Window` and moving DOM into it) is fundamentally different from the "resolve a target, watch a document-level state" archetype this node shares with `fullscreen`/`pointer-lock`.
36
36
 
37
37
  **`<wcs-pip>` targets the classic, `<video>`-only API. The Document Picture-in-Picture API is out of scope for v1** — see `docs/picture-in-picture-tag-design.md` §4. It may become a separate node (e.g. `<wcs-doc-pip>`) in the future.
@@ -143,9 +143,10 @@ Unlike `@wcstack/fullscreen` (where `target="self"` is a legitimate way to fulls
143
143
 
144
144
  | Property | Type | Event | Description |
145
145
  |-------------|--------------------------|------------------------------|--------------|
146
- | `active` | `boolean` | `wcs-pip:change` | Whether the resolved `<video>` target is currently the document's Picture-in-Picture element. |
146
+ | `active` | `boolean` | `wcs-pip:change` | Whether the resolved `<video>` target is currently the document's Picture-in-Picture element. Since 4.25, `false` while `<wcs-pip>` is out of the document (see [When the element leaves the document](#when-the-element-leaves-the-document)). |
147
147
  | `error` | `any` | `wcs-pip:error` | The most recent command failure (wrong tag, unsupported API, gesture-context rejection), or `null` if the last attempt succeeded / nothing has failed yet. Value shape unchanged from before it became observable. |
148
148
  | `errorInfo` | `WcsIoErrorInfo \| null` | `wcs-pip:error-info-changed` | Additive serializable failure **taxonomy** derived from `error`: a stable `{ code, phase, recoverable, message }`. `null` in lockstep with `error`. See the taxonomy table below. |
149
+ | `supported` | `boolean` | `wcs-pip:supported-changed` | Since 4.25. `true` when this page can use Picture-in-Picture; `false` otherwise (Firefox, a document the Permissions-Policy forbids). The event's `detail` is the boolean. See below. |
149
150
 
150
151
  `active` is derived from comparing `document.pictureInPictureElement` against the resolved `<video>` target whenever `enterpictureinpicture`/`leavepictureinpicture` fires **on that target element** — not from a `document`-level event (see "Event subscription" below).
151
152
 
@@ -160,6 +161,29 @@ Unlike `@wcstack/fullscreen` (where `target="self"` is a legitimate way to fulls
160
161
  | `not-allowed` | `execute` | `true` | The request was rejected with `NotAllowedError` / `TypeError` (e.g. called outside a user gesture) — retrying from within a genuine gesture may succeed. |
161
162
  | `pip-error` | `execute` | `false` | Any other caught exception from the platform call. |
162
163
 
164
+ ### `supported` — can this page use Picture-in-Picture?
165
+
166
+ Since 4.25. `supported` is `true` when this page can use Picture-in-Picture: the document reports it enabled (`document.pictureInPictureEnabled`), a `<video>` has `requestPictureInPicture()`, and no Permissions-Policy turns it off — the server's `Permissions-Policy: picture-in-picture=()` header, or an `<iframe>` whose `allow` attribute withholds it (unlike fullscreen, a frame has Picture-in-Picture unless a policy says otherwise). Otherwise it is `false`, whatever the reason. **Firefox has no Picture-in-Picture API for pages, so `supported` is `false` there.**
167
+
168
+ It does not say that a request will succeed: that still needs a user gesture and a video with something to show, and a `<video disablepictureinpicture>` refuses. Picture-in-Picture does not need a secure context, so a plain `http:` page is not `false` for that reason.
169
+
170
+ The value is read from the browser each time it is asked for (never cached), so a binding gets the right value when it attaches. The element also dispatches `wcs-pip:supported-changed` when it is connected, if the value differs from the last one it dispatched (it starts at `false`, so a page that can use Picture-in-Picture hears `true` once). Offer the button only where it can work:
171
+
172
+ ```html
173
+ <wcs-state>
174
+ <script type="module">
175
+ export default {
176
+ $commandTokens: ["popOut"],
177
+ pipSupported: false,
178
+ };
179
+ </script>
180
+ </wcs-state>
181
+
182
+ <video id="player" src="/movie.mp4" controls></video>
183
+ <wcs-pip target="#player" data-wcs="supported: pipSupported; command.requestPictureInPicture: $command.popOut"></wcs-pip>
184
+ <button data-wcs="hidden: pipSupported|not; onclick: $command.popOut">Pop out</button>
185
+ ```
186
+
163
187
  ## Commands
164
188
 
165
189
  | Command | Description |
@@ -179,6 +203,26 @@ Unlike Fullscreen's `fullscreenchange` (which fires on `document`), Picture-in-P
179
203
 
180
204
  This also means multiple `<wcs-pip>` instances naturally self-filter: each instance only hears events from its own `<video>` target, so one instance entering Picture-in-Picture never flips another instance's `active` to `true` (see `docs/picture-in-picture-tag-design.md` §5).
181
205
 
206
+ ## When the element leaves the document
207
+
208
+ Since 4.25. `<wcs-pip>` listens to its `<video>` only while it is connected. When it is disconnected while `active` is `true` — an `if:` branch that goes away, a route's content that `@wcstack/router` takes out — it publishes `active: false`, with its `wcs-pip:change` event, so a bound state path and `:state(active)` follow: an element that is out of the document can no longer vouch for the value. It does **not** close the small window. When it is connected again it reads the truth: if its `<video>` is still the document's Picture-in-Picture element, `active` goes back to `true`, with the event. An element that is moved (taken out and put back) therefore reports `false`, then `true`. Up to 4.24 a disconnect left `active` as it was, and state kept showing `true` after the small window had been closed.
209
+
210
+ What the browser does with the small window is its own. **For it to go on across a navigation, the `<video>` must stay in the document.** A `<video>` inside a route's content is taken out when the route is left: Chromium keeps a removed video playing in the small window, other browsers may not — and with its `<wcs-pip>` gone too, `active` reads `false` either way until the route comes back. Keep the video and its `<wcs-pip>` outside the router, next to the layout that stays ([router README — Where route content lives](../router/README.md#where-route-content-lives)): the video keeps playing, the small window stays, and `active` keeps telling the truth on every route.
211
+
212
+ ```html
213
+ <wcs-router>
214
+ <template>
215
+ <wcs-route path="/">…</wcs-route>
216
+ <wcs-route path="/schedule">…</wcs-route>
217
+ </template>
218
+ </wcs-router>
219
+ <wcs-outlet></wcs-outlet>
220
+
221
+ <!-- Outside the routes: in the document on every page. The state is Quick Start 1's. -->
222
+ <video id="player" src="/movie.mp4" controls></video>
223
+ <wcs-pip target="#player" data-wcs="active: pipActive; command.requestPictureInPicture: $command.popOut; command.exitPictureInPicture: $command.backToPage"></wcs-pip>
224
+ ```
225
+
182
226
  ## CSS styling with `:state()`
183
227
 
184
228
  `<wcs-pip>` reflects one boolean output state onto its
@@ -200,7 +244,7 @@ element, so there is no risk of confusing this output state with an input.
200
244
  `error`/`errorInfo` are intentionally **not** reflected as `:state()` — only the
201
245
  boolean `active` maps cleanly to a presence/absence pseudo-class. (They *are*
202
246
  observable via their own events for `data-wcs` binding — see "Output state"
203
- above.)
247
+ above.) `supported` is not reflected either: bind it (`supported: pipSupported`).
204
248
 
205
249
  **Browser support** (`:state(x)` syntax): Chrome/Edge 125+, Safari 17.4+,
206
250
  Firefox 126+. In older browsers the states are simply never set — `:state()`
@@ -246,6 +290,7 @@ PipCore.wcBindable = {
246
290
  { name: "active", event: "wcs-pip:change", getter: (e) => e.detail.active },
247
291
  { name: "error", event: "wcs-pip:error" },
248
292
  { name: "errorInfo", event: "wcs-pip:error-info-changed" },
293
+ { name: "supported", event: "wcs-pip:supported-changed" }, // 4.25
249
294
  ],
250
295
  commands: [
251
296
  { name: "requestPictureInPicture", async: true },
@@ -277,10 +322,14 @@ await core.exitPictureInPicture();
277
322
  core.dispose(); // detach listeners
278
323
  ```
279
324
 
325
+ Since 4.25, `dispose()` publishes `active: false` when it was `true` (a disposed Core no longer hears the video) and the next `observe(video)` reads it again. `core.supported`, and the `wcs-pip:supported-changed` event `observe()` dispatches, say whether the page can use Picture-in-Picture.
326
+
280
327
  The structural Core surface is normative across wcstack IO nodes ([async-io-node-guidelines §3.9](../../docs/async-io-node-guidelines.md)); to bind it into signals with no element at all, see [@wcstack/signals — Binding a Core directly](../signals/README.md#binding-a-core-directly-no-element).
281
328
 
282
329
  ## Notes & limitations
283
330
 
331
+ - **Firefox has no Picture-in-Picture API for pages.** `supported` is `false` there and a request ends in `error` (`{ message: "Picture-in-Picture API is not supported." }`, `capability-missing`). Hide the button with `supported`; the browser's own picture-in-picture control on the video still works for the user.
332
+ - **The `<video>` must stay in the document for the small window to survive a navigation.** Keep it and its `<wcs-pip>` outside the router — see "When the element leaves the document" above.
284
333
  - **`<video>`-only.** `target` must resolve to an `HTMLVideoElement`. Any other element is treated as unresolved: `error` is set to `{ message: "target must be a <video> element." }`, never throws.
285
334
  - **Document Picture-in-Picture API is out of scope.** See "Scope" above.
286
335
  - **Never throws.** Unsupported environments, wrong-tag targets, and gesture-context rejections are all funneled into `error`.
package/dist/auto.min.js CHANGED
@@ -1,2 +1,2 @@
1
- const e={tagNames:{pip:"wcs-pip"}};var t="@wcstack/picture-in-picture",r="4.24.1";const n="capability-missing",i="invalid-argument",s="not-allowed",c="pip-error";function o(e,t){const r=function(e){return"string"==typeof e?.message?e.message:String(e)}(e);if("capability-missing"===t)return{code:n,phase:"probe",recoverable:!1,message:r};if("invalid-argument"===t)return{code:i,phase:"start",recoverable:!1,message:r};const o=e?.name;return"NotAllowedError"===o||"TypeError"===o?{code:s,phase:"execute",recoverable:!0,message:r}:{code:c,phase:"execute",recoverable:!1,message:r}}class a extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"active",event:"wcs-pip:change",semantics:"state",getter:e=>e.detail.active},{name:"error",event:"wcs-pip:error",semantics:"state"},{name:"errorInfo",event:"wcs-pip:error-info-changed",semantics:"state"}],commands:[{name:"requestPictureInPicture",async:!0},{name:"exitPictureInPicture",async:!0}]};_target;_active=!1;_error=null;_errorInfo=null;_video=null;_gen=0;_ready=Promise.resolve();constructor(e){super(),this._target=e??this}get ready(){return this._ready}get active(){return this._active}get error(){return this._error}get errorInfo(){return this._errorInfo}observe(e){return this._video===e||(this._detach(),this._video=e,e&&(e.addEventListener("enterpictureinpicture",this._onEnter),e.addEventListener("leavepictureinpicture",this._onLeave)),this._syncActive()),this._ready}dispose(){this._gen++,this._detach(),this._video=null}async requestPictureInPicture(e){const t=++this._gen;if(!e||"VIDEO"!==e.tagName)return void this._setError({message:"target must be a <video> element."},"invalid-argument");this.observe(e);const r=this._requestPictureInPictureFn(e);if(r)try{if(await r.call(e),t!==this._gen)return;this._setError(null),this._syncActive()}catch(e){if(t!==this._gen)return;this._setError(e)}else this._setError({message:"Picture-in-Picture API is not supported."},"capability-missing")}async exitPictureInPicture(){if(null===this._pictureInPictureElement())return;const e=this._exitPictureInPictureFn();if(!e)return;const t=++this._gen;try{if(await e(),t!==this._gen)return;this._setError(null),this._syncActive()}catch(e){if(t!==this._gen)return;this._setError(e)}}_requestPictureInPictureFn(e){const t=e;return"function"==typeof t.requestPictureInPicture?t.requestPictureInPicture:void 0}_exitPictureInPictureFn(){const e=document;return"function"==typeof e.exitPictureInPicture?e.exitPictureInPicture.bind(document):void 0}_pictureInPictureElement(){return document.pictureInPictureElement??null}_onEnter=()=>{this._syncActive()};_onLeave=()=>{this._syncActive()};_syncActive(){const e=null!==this._video&&this._pictureInPictureElement()===this._video;this._setActive(e)}_detach(){this._video&&(this._video.removeEventListener("enterpictureinpicture",this._onEnter),this._video.removeEventListener("leavepictureinpicture",this._onLeave))}_setActive(e){this._active!==e&&(this._active=e,this._target.dispatchEvent(new CustomEvent("wcs-pip:change",{detail:{active:e},bubbles:!0})))}_setError(e,t){this._error!==e&&(this._error=e,this._commitErrorInfo(null===e?null:o(e,t)),this._target.dispatchEvent(new CustomEvent("wcs-pip:error",{detail:e,bubbles:!0})))}_commitErrorInfo(e){this._errorInfo=e,this._target.dispatchEvent(new CustomEvent("wcs-pip:error-info-changed",{detail:e,bubbles:!0}))}}function u(e,t){let r=Object.getPrototypeOf(e);for(;null!==r;){const e=Object.getOwnPropertyDescriptor(r,t);if(void 0!==e)return"function"==typeof e.get||"function"==typeof e.set;r=Object.getPrototypeOf(r)}return!1}const l=new WeakSet;function h(e,t,r){if(l.has(e))return;l.add(e);const n=e.localName??"element";console.warn(`[wcs/input-as-attribute] <${n}> has the attribute ${t}="${r}": an object was written as an attribute, so the element did not receive it. A framework does that when the property is set before the element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, or assign the property through a ref (Vue: .prop). (Said once per element.)`,e)}const d=new WeakMap;function p(e,t,r){const n=function(e,t){let r=d.get(e);return void 0===r&&(r=new Map,d.set(e,r)),r.has(t)||r.set(t,e.getAttribute(t)),r.get(t)}(e,t);!function(e,t,r){null===r?e.removeAttribute(t):e.setAttribute(t,r)}(e,t,void 0===r?n:null===r?null:String(r))}class _ extends HTMLElement{static hasConnectedCallbackPromise=!0;static observedAttributes=["target"];static wcBindable={...a.wcBindable,inputs:[{name:"target",attribute:"target"}],commands:a.wcBindable.commands};_core;_connectedCallbackPromise=Promise.resolve();_internals=null;constructor(){super(),this._core=new a(this),this._internals=this._initInternals(),this._wireStates({"wcs-pip:change":e=>({active:!0===e?.active})})}get debugStates(){return this._internals?[...this._internals.states]:[]}_initInternals(){try{if("function"!=typeof this.attachInternals)return null;const e=this.attachInternals();return e.states.add("wcs-probe"),e.states.delete("wcs-probe"),e}catch{return null}}_wireStates(e){if(null===this._internals)return;const t=this._internals.states;for(const[r,n]of Object.entries(e))this.addEventListener(r,e=>{const r=this.hasAttribute("debug-states");for(const[i,s]of Object.entries(n(e.detail))){try{s?t.add(i):t.delete(i)}catch{}r&&this.toggleAttribute(`data-wcs-state-${i}`,s)}})}get connectedCallbackPromise(){return this._connectedCallbackPromise}get target(){return this.getAttribute("target")??""}set target(e){p(this,"target",e)}get active(){return this._core.active}get error(){return this._core.error}get errorInfo(){return this._core.errorInfo}async requestPictureInPicture(){const{element:e}=this._resolveVideoTarget();return this._core.requestPictureInPicture(e)}async exitPictureInPicture(){return this._core.exitPictureInPicture()}_resolveTarget(){const e=this.target;if("self"===e)return{element:this,display:"block"};if(""!==e){const t=this.getRootNode();return{element:this._safeQuery(t,e),display:"none"}}const t=this.firstElementChild;return t?{element:t,display:"contents"}:{element:this,display:"block"}}_safeQuery(e,t){try{return e.querySelector(t)}catch{return null}}_resolveVideoTarget(){const{element:e,display:t}=this._resolveTarget();return null!==e&&"VIDEO"!==e.tagName?{element:null,display:t}:{element:e,display:t}}_observe(){const{element:e,display:t}=this._resolveVideoTarget();this.style.display=t,this._connectedCallbackPromise=this._core.observe(e)}connectedCallback(){!function(e){const t=e.constructor?.wcBindable,r=t?.inputs;if(void 0===r)return;const n=e.getAttribute;for(const t of r){const r=t.name,i="function"==typeof n?n.call(e,r.toLowerCase()):null;if(null!==i&&i.startsWith("[object ")&&h(e,r,i),!Object.prototype.hasOwnProperty.call(e,r))continue;if(!u(e,r))continue;const s=e,c=s[r];delete s[r],s[r]=c}}(this),this._observe()}disconnectedCallback(){this._core.dispose()}attributeChangedCallback(e,t,r){t!==r&&this.isConnected&&this._observe()}}const g=Symbol.for("wcstack.package"),v=new WeakSet;function f(e,t){Object.defineProperty(e,g,{value:t,configurable:!0})}function m(e,t,r,n,i){if(void 0!==n&&(r===n||r.prototype instanceof n))return;const s=r[g];if(s===i||v.has(e))return;v.add(e);const c=i.slice(0,i.lastIndexOf("@"));console.warn(`[${c}] [wcs/package-twice] <${t}> is already defined by ${s??`another copy of ${c} that does not name its version`}; this copy, ${i}, does nothing. Load each package once.`)}function b(n=customElements){!function(e,t,r){for(const[n,i]of r){const r=e.get(n);void 0===r?(f(i,t),e.define(n,i)):m(e,n,r,i,t)}}(n,`${t}@${r}`,[[e.tagNames.pip,_]])}var y;b(y);
1
+ const e={tagNames:{pip:"wcs-pip"}};var t="@wcstack/picture-in-picture",r="4.25.0";const n=new Set(["camera","microphone","geolocation","midi","clipboard-read","clipboard-write","screen-wake-lock","idle-detection","accelerometer","gyroscope","magnetometer","ambient-light-sensor","display-capture","fullscreen","picture-in-picture","web-share"]);const i="capability-missing",s="invalid-argument",o="not-allowed",c="pip-error";function a(e,t){const r=function(e){return"string"==typeof e?.message?e.message:String(e)}(e);if("capability-missing"===t)return{code:i,phase:"probe",recoverable:!1,message:r};if("invalid-argument"===t)return{code:s,phase:"start",recoverable:!1,message:r};const n=e?.name;return"NotAllowedError"===n||"TypeError"===n?{code:o,phase:"execute",recoverable:!0,message:r}:{code:c,phase:"execute",recoverable:!1,message:r}}class u extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"active",event:"wcs-pip:change",semantics:"state",getter:e=>e.detail.active},{name:"error",event:"wcs-pip:error",semantics:"state"},{name:"errorInfo",event:"wcs-pip:error-info-changed",semantics:"state"},{name:"supported",event:"wcs-pip:supported-changed",semantics:"state"}],commands:[{name:"requestPictureInPicture",async:!0},{name:"exitPictureInPicture",async:!0}]};_target;_active=!1;_error=null;_errorInfo=null;_video=null;_gen=0;_supportedPublished=!1;_ready=Promise.resolve();constructor(e){super(),this._target=e??this}get ready(){return this._ready}get active(){return this._active}get error(){return this._error}get errorInfo(){return this._errorInfo}get supported(){return"policy-blocked"!==function(e){const t=globalThis;if(!1===t.isSecureContext)return"insecure-context";if(!n.has(e))return null;const r=t.document?.permissionsPolicy??t.document?.featurePolicy;if(void 0===r||"function"!=typeof r.allowsFeature)return null;try{return"function"!=typeof r.features||r.features().includes(e)?r.allowsFeature(e)?null:"policy-blocked":null}catch{return null}}("picture-in-picture")&&(!0===document.pictureInPictureEnabled&&"function"==typeof HTMLVideoElement.prototype.requestPictureInPicture)}observe(e){return this._publishSupported(),this._video===e||(this._detach(),this._video=e,e&&(e.addEventListener("enterpictureinpicture",this._onEnter),e.addEventListener("leavepictureinpicture",this._onLeave)),this._syncActive()),this._ready}dispose(){this._gen++,this._detach(),this._video=null,this._setActive(!1)}async requestPictureInPicture(e){const t=++this._gen;if(!e||"VIDEO"!==e.tagName)return void this._setError({message:"target must be a <video> element."},"invalid-argument");this.observe(e);const r=this._requestPictureInPictureFn(e);if(r)try{if(await r.call(e),t!==this._gen)return;this._setError(null),this._syncActive()}catch(e){if(t!==this._gen)return;this._setError(e)}else this._setError({message:"Picture-in-Picture API is not supported."},"capability-missing")}async exitPictureInPicture(){if(null===this._pictureInPictureElement())return;const e=this._exitPictureInPictureFn();if(!e)return;const t=++this._gen;try{if(await e(),t!==this._gen)return;this._setError(null),this._syncActive()}catch(e){if(t!==this._gen)return;this._setError(e)}}_requestPictureInPictureFn(e){const t=e;return"function"==typeof t.requestPictureInPicture?t.requestPictureInPicture:void 0}_exitPictureInPictureFn(){const e=document;return"function"==typeof e.exitPictureInPicture?e.exitPictureInPicture.bind(document):void 0}_pictureInPictureElement(){return document.pictureInPictureElement??null}_onEnter=()=>{this._syncActive()};_onLeave=()=>{this._syncActive()};_syncActive(){const e=null!==this._video&&this._pictureInPictureElement()===this._video;this._setActive(e)}_detach(){this._video&&(this._video.removeEventListener("enterpictureinpicture",this._onEnter),this._video.removeEventListener("leavepictureinpicture",this._onLeave))}_publishSupported(){const e=this.supported;this._supportedPublished!==e&&(this._supportedPublished=e,this._target.dispatchEvent(new CustomEvent("wcs-pip:supported-changed",{detail:e,bubbles:!0})))}_setActive(e){this._active!==e&&(this._active=e,this._target.dispatchEvent(new CustomEvent("wcs-pip:change",{detail:{active:e},bubbles:!0})))}_setError(e,t){this._error!==e&&(this._error=e,this._commitErrorInfo(null===e?null:a(e,t)),this._target.dispatchEvent(new CustomEvent("wcs-pip:error",{detail:e,bubbles:!0})))}_commitErrorInfo(e){this._errorInfo=e,this._target.dispatchEvent(new CustomEvent("wcs-pip:error-info-changed",{detail:e,bubbles:!0}))}}function l(e,t){let r=Object.getPrototypeOf(e);for(;null!==r;){const e=Object.getOwnPropertyDescriptor(r,t);if(void 0!==e)return"function"==typeof e.get||"function"==typeof e.set;r=Object.getPrototypeOf(r)}return!1}const d=new WeakSet;function h(e,t,r){if(d.has(e))return;d.add(e);const n=e.localName??"element";console.warn(`[wcs/input-as-attribute] <${n}> has the attribute ${t}="${r}": an object was written as an attribute, so the element did not receive it. A framework does that when the property is set before the element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, or assign the property through a ref (Vue: .prop). (Said once per element.)`,e)}const p=new WeakMap;function _(e,t,r){const n=function(e,t){let r=p.get(e);return void 0===r&&(r=new Map,p.set(e,r)),r.has(t)||r.set(t,e.getAttribute(t)),r.get(t)}(e,t);!function(e,t,r){null===r?e.removeAttribute(t):e.setAttribute(t,r)}(e,t,void 0===r?n:null===r?null:String(r))}class f extends HTMLElement{static hasConnectedCallbackPromise=!0;static observedAttributes=["target"];static wcBindable={...u.wcBindable,inputs:[{name:"target",attribute:"target"}],commands:u.wcBindable.commands};_core;_connectedCallbackPromise=Promise.resolve();_internals=null;constructor(){super(),this._core=new u(this),this._internals=this._initInternals(),this._wireStates({"wcs-pip:change":e=>({active:!0===e?.active})})}get debugStates(){return this._internals?[...this._internals.states]:[]}_initInternals(){try{if("function"!=typeof this.attachInternals)return null;const e=this.attachInternals();return e.states.add("wcs-probe"),e.states.delete("wcs-probe"),e}catch{return null}}_wireStates(e){if(null===this._internals)return;const t=this._internals.states;for(const[r,n]of Object.entries(e))this.addEventListener(r,e=>{const r=this.hasAttribute("debug-states");for(const[i,s]of Object.entries(n(e.detail))){try{s?t.add(i):t.delete(i)}catch{}r&&this.toggleAttribute(`data-wcs-state-${i}`,s)}})}get connectedCallbackPromise(){return this._connectedCallbackPromise}get target(){return this.getAttribute("target")??""}set target(e){_(this,"target",e)}get active(){return this._core.active}get error(){return this._core.error}get errorInfo(){return this._core.errorInfo}get supported(){return this._core.supported}async requestPictureInPicture(){const{element:e}=this._resolveVideoTarget();return this._core.requestPictureInPicture(e)}async exitPictureInPicture(){return this._core.exitPictureInPicture()}_resolveTarget(){const e=this.target;if("self"===e)return{element:this,display:"block"};if(""!==e){const t=this.getRootNode();return{element:this._safeQuery(t,e),display:"none"}}const t=this.firstElementChild;return t?{element:t,display:"contents"}:{element:this,display:"block"}}_safeQuery(e,t){try{return e.querySelector(t)}catch{return null}}_resolveVideoTarget(){const{element:e,display:t}=this._resolveTarget();return null!==e&&"VIDEO"!==e.tagName?{element:null,display:t}:{element:e,display:t}}_observe(){const{element:e,display:t}=this._resolveVideoTarget();this.style.display=t,this._connectedCallbackPromise=this._core.observe(e)}connectedCallback(){!function(e){const t=e.constructor?.wcBindable,r=t?.inputs;if(void 0===r)return;const n=e.getAttribute;for(const t of r){const r=t.name,i="function"==typeof n?n.call(e,r.toLowerCase()):null;if(null!==i&&i.startsWith("[object ")&&h(e,r,i),!Object.prototype.hasOwnProperty.call(e,r))continue;if(!l(e,r))continue;const s=e,o=s[r];delete s[r],s[r]=o}}(this),this._observe()}disconnectedCallback(){this._core.dispose()}attributeChangedCallback(e,t,r){t!==r&&this.isConnected&&this._observe()}}const g=Symbol.for("wcstack.package"),m=new WeakSet;function v(e,t){Object.defineProperty(e,g,{value:t,configurable:!0})}function b(e,t,r,n,i){if(void 0!==n&&(r===n||r.prototype instanceof n))return;const s=r[g];if(s===i||m.has(e))return;m.add(e);const o=i.slice(0,i.lastIndexOf("@"));console.warn(`[${o}] [wcs/package-twice] <${t}> is already defined by ${s??`another copy of ${o} that does not name its version`}; this copy, ${i}, does nothing. Load each package once.`)}function y(n=customElements){!function(e,t,r){for(const[n,i]of r){const r=e.get(n);void 0===r?(v(i,t),e.define(n,i)):b(e,n,r,i,t)}}(n,`${t}@${r}`,[[e.tagNames.pip,f]])}var P;y(P);
2
2
  //# sourceMappingURL=auto.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"auto.min.js","sources":["../../src/config.ts","../../src/core/pictureInPictureCapabilities.ts","../../src/core/PipCore.ts","../../src/protocol/upgradeProperties.ts","../../src/protocol/inputAttribute.ts","../../src/components/Pip.ts","../../src/protocol/defineElement.ts","../../src/registerComponents.ts","../../src/bootstrapPip.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n pip: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n pip: \"wcs-pip\",\n },\n};\n\nfunction deepFreeze<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n Object.freeze(obj);\n for (const key of Object.keys(obj)) {\n deepFreeze((obj as Record<string, unknown>)[key]);\n }\n return obj;\n}\n\nfunction deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n const clone: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n clone[key] = deepClone((obj as Record<string, unknown>)[key]);\n }\n return clone as T;\n}\n\nlet frozenConfig: IConfig | null = null;\n\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\n/** A misspelt option would otherwise do nothing: `bootstrapPip` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/picture-in-picture] bootstrapPip: \"${key}\" is not one of its options, or not of the option's type.`);\n}\n\n/**\n * Applies the options given; an undefined value is left out. An option this package does not\n * have, a value of another type than its default (null, or an array for an object, included) or\n * a tag name it does not define throws, and then nothing is applied.\n */\nexport function setConfig(partialConfig: IWritableConfig): void {\n const options = _config as unknown as Record<string, unknown>;\n const tags = _config.tagNames as Record<string, string>;\n const given = Object.entries(partialConfig).filter(([, value]) => value !== undefined);\n const givenTags = Object.entries(partialConfig.tagNames ?? {}).filter(([, tag]) => tag !== undefined);\n for (const [key, value] of given) {\n const current = options[key];\n if (!Object.hasOwn(options, key) || value === null || typeof value !== typeof current || Array.isArray(value) !== Array.isArray(current)) {\n invalid(key);\n }\n }\n for (const [name, tag] of givenTags) {\n if (!Object.hasOwn(tags, name) || typeof tag !== \"string\") invalid(`tagNames.${name}`);\n }\n for (const [name, tag] of givenTags) tags[name] = tag as string;\n frozenConfig = null;\n}\n","/**\n * pictureInPictureCapabilities.ts\n *\n * Picture-in-Picture node 固有の error code(taxonomy)と derivation。汎用の error\n * info 型は `./platformCapability.js`(/io-core/ から copy-distribution される生成\n * ファイル)から import する。Picture-in-Picture は referenced `<video>` を操作する\n * ノードで競合 operation を持たないため lane は無く、error taxonomy(errorInfo)のみを\n * 採用する(fullscreen と同型)。\n *\n * `_setError` は合成 `{ message }`(target が `<video>` に解決しない / API 非対応)と\n * caught 例外(`NotAllowedError` = user gesture 外の requestPictureInPicture 拒否等)を\n * 混在受理する。呼出側が明示 `kind` を渡して合成側を曖昧さ無く分類し、caught は `.name`\n * で分類する(fullscreen / storage / screen-orientation と同じ discriminator 方式)。\n */\n\nimport type { WcsIoErrorInfo } from \"./platformCapability.js\";\n\n/** 明示 kind discriminator(合成エラーの呼出側が渡す)。 */\nexport type PictureInPictureErrorKind = \"capability-missing\" | \"invalid-argument\";\n\n/** 安定した Picture-in-Picture error code(taxonomy)。値は公開キーとして固定。 */\nexport const WCS_PICTURE_IN_PICTURE_ERROR_CODE = {\n /** Picture-in-Picture API 非対応。 */\n CapabilityMissing: \"capability-missing\",\n /** target が `<video>` に解決しない等の入力不備。 */\n InvalidArgument: \"invalid-argument\",\n /** `NotAllowedError` / `TypeError` — user gesture 外での要求拒否。 */\n NotAllowed: \"not-allowed\",\n /** その他の caught 例外。 */\n PipError: \"pip-error\",\n} as const;\n\nfunction messageOf(error: unknown): string {\n return typeof (error as { message?: unknown } | null)?.message === \"string\"\n ? (error as { message: string }).message\n : String(error);\n}\n\n/**\n * Picture-in-Picture の失敗を serializable な error taxonomy に写す。`kind` は合成\n * エラーの呼出側が渡す明示 discriminator(`capability-missing` / `invalid-argument`)。\n * 未指定は caught 例外を意味し、`.name` で分類する。`NotAllowedError` / `TypeError` は\n * user gesture 内で再試行すれば成功しうるため recoverable=true。\n */\nexport function derivePictureInPictureErrorInfo(error: unknown, kind?: PictureInPictureErrorKind): WcsIoErrorInfo {\n const message = messageOf(error);\n if (kind === \"capability-missing\") {\n return { code: WCS_PICTURE_IN_PICTURE_ERROR_CODE.CapabilityMissing, phase: \"probe\", recoverable: false, message };\n }\n if (kind === \"invalid-argument\") {\n return { code: WCS_PICTURE_IN_PICTURE_ERROR_CODE.InvalidArgument, phase: \"start\", recoverable: false, message };\n }\n const name = (error as { name?: unknown } | null)?.name;\n if (name === \"NotAllowedError\" || name === \"TypeError\") {\n return { code: WCS_PICTURE_IN_PICTURE_ERROR_CODE.NotAllowed, phase: \"execute\", recoverable: true, message };\n }\n return { code: WCS_PICTURE_IN_PICTURE_ERROR_CODE.PipError, phase: \"execute\", recoverable: false, message };\n}\n","import { IWcBindable } from \"../types.js\";\nimport { WcsIoErrorInfo } from \"./platformCapability.js\";\nimport { derivePictureInPictureErrorInfo, PictureInPictureErrorKind } from \"./pictureInPictureCapabilities.js\";\n\n/**\n * Headless Picture-in-Picture primitive. A thin, framework-agnostic wrapper\n * around the classic Picture-in-Picture API\n * (`HTMLVideoElement.requestPictureInPicture()` / `document.exitPictureInPicture()` /\n * `document.pictureInPictureElement`) exposed through the wc-bindable protocol.\n *\n * This Core follows the same basic pattern as `@wcstack/fullscreen`'s\n * `FullscreenCore` (docs/fullscreen-tag-design.md): target resolution is done\n * by the Shell (this Core receives the resolved element at call time), API\n * resolution is call-time/non-cached, `_gen` is a single Core-level generation\n * guard, and `error` is a simple single field (no permission-style 4-value\n * state). See docs/picture-in-picture-tag-design.md for the differences from\n * Fullscreen:\n *\n * - **§2 target constraint**: the resolved target MUST be a `<video>` element.\n * Picture-in-Picture is only defined as an instance method of\n * `HTMLVideoElement` — unlike Fullscreen, which any `Element` supports. A\n * non-`<video>` target is a never-throw failure: it is treated the same as\n * an unresolved target and reported via `error`.\n * - **§3 event subscription target**: `enterpictureinpicture` /\n * `leavepictureinpicture` fire on the `<video>` element itself, not on\n * `document` (the reverse of Fullscreen's `document`-level\n * `fullscreenchange`). The Core attaches/detaches these listeners directly\n * on the resolved `<video>` element, re-wiring them whenever the target is\n * re-resolved (e.g. the Shell's `target` attribute changes).\n */\nexport class PipCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"active\", event: \"wcs-pip:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.active },\n // `error` / `errorInfo` are observable failure outputs. Historically `error`\n // was an imperative getter with no event; both are now bindable (event-backed)\n // so `data-wcs` / bind() can observe a request/exit failure. `errorInfo` is the\n // additive serializable taxonomy (stable code / phase / recoverable) derived\n // from `error`; the `error` value shape is unchanged. No lane — Picture-in-Picture\n // drives a referenced `<video>`, not a competing operation (fullscreen と同型)。\n { name: \"error\", event: \"wcs-pip:error\", semantics: \"state\" },\n { name: \"errorInfo\", event: \"wcs-pip:error-info-changed\", semantics: \"state\" },\n ],\n commands: [\n { name: \"requestPictureInPicture\", async: true },\n { name: \"exitPictureInPicture\", async: true },\n ],\n };\n\n private _target: EventTarget;\n private _active: boolean = false;\n private _error: any = null;\n private _errorInfo: WcsIoErrorInfo | null = null;\n\n // The <video> element the Core currently subscribes to for\n // enterpictureinpicture/leavepictureinpicture (null when unresolved/torn down).\n private _video: HTMLVideoElement | null = null;\n\n // Generation guard (§3.4 / fullscreen-tag-design.md §6): bumped on dispose()\n // and each async command start. A completion that lands after dispose() (or\n // after a superseding call) is stale and MUST NOT write state.\n private _gen = 0;\n\n // SSR (§3.8): no asynchronous probe to await, so readiness is immediate.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n get ready(): Promise<void> {\n return this._ready;\n }\n\n get active(): boolean {\n return this._active;\n }\n\n get error(): any {\n return this._error;\n }\n\n /**\n * The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /\n * `recoverable`), or null. Additive wc-bindable property (event\n * `wcs-pip:error-info-changed`), derived from `error`; the existing `error`\n * value shape is unchanged.\n */\n get errorInfo(): WcsIoErrorInfo | null {\n return this._errorInfo;\n }\n\n // --- Lifecycle (§3.5) ---\n\n /**\n * (Re-)subscribe to `enterpictureinpicture`/`leavepictureinpicture` on\n * `element` (the Shell's resolved `<video>` target). Idempotent when called\n * again with the same element; re-wires the listeners when the element\n * changes (e.g. the `target` attribute was changed), detaching from the\n * previous element first so no stale listener lingers.\n */\n observe(element: HTMLVideoElement | null): Promise<void> {\n if (this._video === element) {\n return this._ready;\n }\n this._detach();\n this._video = element;\n if (element) {\n element.addEventListener(\"enterpictureinpicture\", this._onEnter);\n element.addEventListener(\"leavepictureinpicture\", this._onLeave);\n }\n this._syncActive();\n return this._ready;\n }\n\n dispose(): void {\n this._gen++;\n this._detach();\n this._video = null;\n }\n\n // --- Commands (§3.6 never-throw) ---\n\n /**\n * Request Picture-in-Picture for `element`. `element` must be a `<video>`\n * (checked before the gesture-context failure path, since a type mismatch is\n * an environment-independent, permanent error — docs/picture-in-picture-tag-design.md §2).\n * Never throws: all failures (wrong tag, unsupported API, gesture-context\n * rejection) are funneled into `error` and the returned promise resolves.\n */\n async requestPictureInPicture(element: HTMLVideoElement | null): Promise<void> {\n const gen = ++this._gen;\n if (!element || element.tagName !== \"VIDEO\") {\n // Distinct from \"API is not supported\" (below): the resolved target did\n // not satisfy the `<video>`-only constraint (wrong tag / unresolved).\n this._setError({ message: \"target must be a <video> element.\" }, \"invalid-argument\");\n return;\n }\n // Re-wire to `element` before issuing the platform call: a caller may\n // request a <video> different from the one last passed to observe() (e.g.\n // the Shell's target attribute pointed at nothing at connect time and the\n // matching <video> was only inserted later, so no attributeChangedCallback\n // ever re-resolved it). Without this, `_video` stays stale and\n // `_syncActive()` below (and future enter/leave events) would never\n // recognize `element` as this Core's target, leaving `active` permanently\n // wrong even though the request succeeded (mirrors\n // FullscreenCore.requestFullscreen()'s unconditional `this._resolvedTarget\n // = element` assignment — docs/fullscreen-tag-design.md §6).\n this.observe(element);\n const fn = this._requestPictureInPictureFn(element);\n if (!fn) {\n this._setError({ message: \"Picture-in-Picture API is not supported.\" }, \"capability-missing\");\n return;\n }\n try {\n await fn.call(element);\n if (gen !== this._gen) return; // stale\n this._setError(null);\n this._syncActive(); // belt-and-suspenders (mirrors FullscreenCore's _applyActive() on success)\n } catch (e: any) {\n if (gen !== this._gen) return; // stale\n this._setError(e); // e.g. NotAllowedError (gesture-context rejection)\n }\n }\n\n /**\n * Exit Picture-in-Picture. Mirrors FullscreenCore.exitFullscreen(): a\n * silent no-op (resolve, no error) when nothing is currently in\n * Picture-in-Picture — see fullscreen-tag-design.md §7.\n */\n async exitPictureInPicture(): Promise<void> {\n // no-op checks come BEFORE the generation bump: a call that does nothing\n // must not supersede an in-flight requestPictureInPicture() — bumping\n // first would make the pending request's settle handling stale and\n // silently swallow its error update (mirrors\n // FullscreenCore.exitFullscreen()).\n if (this._pictureInPictureElement() === null) return; // already not in PiP: silent no-op\n const fn = this._exitPictureInPictureFn();\n if (!fn) return; // unsupported: silent no-op (semantically already \"not in PiP\")\n const gen = ++this._gen;\n try {\n await fn();\n if (gen !== this._gen) return;\n this._setError(null);\n this._syncActive(); // belt-and-suspenders (mirrors FullscreenCore.exitFullscreen()'s success-path _applyActive()); covers a delayed/dropped leavepictureinpicture\n } catch (e: any) {\n if (gen !== this._gen) return;\n this._setError(e);\n }\n }\n\n // --- Internal: API resolution (call-time, never cached — §3.7) ---\n\n // Unlike FullscreenCore's _elementFullscreenFn(), a naive direct property\n // lookup (`e.requestPictureInPicture`, walking the prototype chain) here is\n // safe: it cannot recurse into the Shell's own command method,\n // because the resolved target is validated to be a <video> element (§2)\n // before this is called, and <wcs-pip> (the Shell) is never itself a\n // <video>. Fullscreen's own→Element.prototype two-step resolution guards\n // against `target=\"self\"`/no-target resolving to the Shell element, which\n // cannot happen here.\n private _requestPictureInPictureFn(el: HTMLVideoElement): (() => Promise<PictureInPictureWindow>) | undefined {\n const e = el as any;\n return typeof e.requestPictureInPicture === \"function\" ? e.requestPictureInPicture : undefined;\n }\n\n private _exitPictureInPictureFn(): (() => Promise<void>) | undefined {\n const d = document as any;\n return typeof d.exitPictureInPicture === \"function\" ? d.exitPictureInPicture.bind(document) : undefined;\n }\n\n private _pictureInPictureElement(): Element | null {\n const d = document as any;\n return d.pictureInPictureElement ?? null;\n }\n\n // --- Internal: event wiring ---\n\n private _onEnter = (): void => {\n this._syncActive();\n };\n\n private _onLeave = (): void => {\n this._syncActive();\n };\n\n private _syncActive(): void {\n const isActive = this._video !== null && this._pictureInPictureElement() === this._video;\n this._setActive(isActive);\n }\n\n private _detach(): void {\n if (this._video) {\n this._video.removeEventListener(\"enterpictureinpicture\", this._onEnter);\n this._video.removeEventListener(\"leavepictureinpicture\", this._onLeave);\n }\n }\n\n // --- State setters with event dispatch (§3.3 same-value guard) ---\n\n private _setActive(active: boolean): void {\n if (this._active === active) return;\n this._active = active;\n this._target.dispatchEvent(new CustomEvent(\"wcs-pip:change\", {\n detail: { active },\n bubbles: true,\n }));\n }\n\n // `kind` is an explicit taxonomy discriminator passed only from the synthetic\n // error sites (unsupported / non-<video> target); caught exceptions pass no kind\n // and are classified by their `.name`. Both `error` and the additive `errorInfo`\n // are now event-backed so a request/exit failure is observable via bind().\n private _setError(error: any, kind?: PictureInPictureErrorKind): void {\n // Same-value guard on reference: each failure builds a fresh object and the\n // clear path passes the literal null, so this only suppresses redundant\n // null→null (a successful request/exit clearing an already-null error).\n if (this._error === error) return;\n this._error = error;\n // Keep the additive errorInfo taxonomy in sync; fire it before the `error`\n // event so an observer of both sees the classification first (io-node family).\n this._commitErrorInfo(error === null ? null : derivePictureInPictureErrorInfo(error, kind));\n this._target.dispatchEvent(new CustomEvent(\"wcs-pip:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n // Called only from _setError (already reference-guarded), so errorInfo\n // transitions exactly when error does — no separate guard needed here.\n private _commitErrorInfo(info: WcsIoErrorInfo | null): void {\n this._errorInfo = info;\n this._target.dispatchEvent(new CustomEvent(\"wcs-pip:error-info-changed\", {\n detail: info,\n bubbles: true,\n }));\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/upgrade-properties.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// custom element の property upgrade — `static wcBindable.inputs` に宣言した入力のうち、\n// 要素が upgrade される前に代入された own データプロパティを取り込み直す。\n//\n// なぜ必要か:\n// 未定義タグの要素は素の HTMLElement なので、`el.url = \"...\"` は own データプロパティを作る。\n// upgrade 後にクラスの accessor が prototype へ入っても own プロパティが優先されるため、\n// setter は二度と呼ばれず、値は要素へ届かないまま消える(エラーも警告も出ない)。\n// 常にプロパティ代入を行う framework(Angular の `[prop]`、Lit の `.prop=`、\n// Solid の `prop:`、Vue の `.prop` 修飾子)× 遅延定義(autoloader / CDN / code-split)で\n// 常態的に起きる。docs/architecture-hardening/13-framework-adapter-binding-constraints.md §1.2。\n//\n// 安全側の判定:\n// own プロパティがあっても、prototype チェーンに accessor が無ければ「シャドウ」ではなく\n// その own プロパティ自体が正規の格納先なので触らない(public class field を壊さない)。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/upgrade-properties.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/upgradeProperties.ts). Those copies are generated — do not edit them.\nimport { IWcBindable } from \"./wcBindable.js\";\n\nfunction hasAccessorOnPrototype(target: object, name: string): boolean {\n let proto = Object.getPrototypeOf(target);\n while (proto !== null) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n if (descriptor !== undefined) {\n return typeof descriptor.get === \"function\" || typeof descriptor.set === \"function\";\n }\n proto = Object.getPrototypeOf(proto);\n }\n return false;\n}\n\n// 属性になってしまったオブジェクトの入力(`files=\"[object File]\"`)を、要素ごとに 1 回だけ言う。\n// React 19 は定義前の要素にプロパティが無いのでオブジェクトを属性に書き、Vue の `.attr` も\n// 書く。要素はその入力をプロパティでしか読まないので、何も受け取らず、何も言わなかった\n// (docs/seam-apps.md、fw-inventory)。\nconst toldObjectAttribute = new WeakSet<object>();\n\nfunction warnObjectAttribute(element: object, name: string, value: string): void {\n if (toldObjectAttribute.has(element)) return;\n toldObjectAttribute.add(element);\n const tag = (element as { localName?: string }).localName ?? \"element\";\n console.warn(\n `[wcs/input-as-attribute] <${tag}> has the attribute ${name}=\"${value}\": an object was written as an ` +\n `attribute, so the element did not receive it. A framework does that when the property is set before the ` +\n `element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, ` +\n `or assign the property through a ref (Vue: .prop). (Said once per element.)`,\n element,\n );\n}\n\n/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\n * - 値が `[object …]` の属性(属性に書かれてしまったオブジェクトの入力)は、要素ごとに 1 回警告する。\n */\nexport function upgradeProperties(element: object): void {\n const declaration = (element as { constructor?: { wcBindable?: IWcBindable } }).constructor?.wcBindable;\n const inputs = declaration?.inputs;\n if (inputs === undefined) return;\n const getAttribute = (element as { getAttribute?: (name: string) => string | null }).getAttribute;\n for (const input of inputs) {\n const name = input.name;\n const attribute = typeof getAttribute === \"function\" ? getAttribute.call(element, name.toLowerCase()) : null;\n if (attribute !== null && attribute.startsWith(\"[object \")) warnObjectAttribute(element, name, attribute);\n if (!Object.prototype.hasOwnProperty.call(element, name)) continue;\n if (!hasAccessorOnPrototype(element, name)) continue;\n const record = element as Record<string, unknown>;\n const value = record[name];\n delete record[name];\n record[name] = value;\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/input-attribute.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// 属性へ反映する wc-bindable 入力の producer 側(SPEC-extensions § Producer guidance for inputs の P1〜P3)。\n// 入力の setter は属性をこの 2 関数で書く。それで次が揃う:\n// - `undefined` は「値が無い」(P1): 属性を、この関数で最初に書く前の状態 — マークアップに書かれた値、\n// 無ければ属性なし(= その入力の文書化した既定値)— へ戻す。applier プロファイルを宣言する binder は\n// 値の後の `undefined` を書き(A2)、React 19 も書き、直接の代入でも届く。\n// - `null` はクリア(P2): 属性なし、つまり文書化した既定値。\n// - どちらも文字列 \"undefined\" / \"null\" として属性に入らない。\n//\n// 「最初に書く前」は、その最初の書き込みのときに読む(遅延)。upgrade 前に代入されたプロパティは\n// connectedCallback の upgradeProperties() が通し直すので、そのときにはパーサが書いた属性が揃っている。\n// 要素自身が setter を通さずに書いた属性は、最初の書き込みより前なら「最初の状態」に含まれる。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/input-attribute.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/inputAttribute.ts). Those copies are generated — do not edit them.\n\nconst initialAttributes = new WeakMap<Element, Map<string, string | null>>();\n\n/** The attribute as it stood before the first write through these helpers. */\nfunction initialAttribute(el: Element, name: string): string | null {\n let byName = initialAttributes.get(el);\n if (byName === undefined) {\n byName = new Map();\n initialAttributes.set(el, byName);\n }\n if (!byName.has(name)) byName.set(name, el.getAttribute(name));\n return byName.get(name) as string | null;\n}\n\nfunction writeAttribute(el: Element, name: string, value: string | null): void {\n if (value === null) el.removeAttribute(name);\n else el.setAttribute(name, value);\n}\n\n/**\n * A value attribute. `value` is written as `String(value)`; `null` removes the attribute;\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value === null ? null : String(value));\n}\n\n/**\n * A boolean attribute, present while `value` is truthy (`null` and `false` remove it);\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectBooleanAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value ? \"\" : null);\n}\n","import { IWcBindable } from \"../types.js\";\nimport { PipCore } from \"../core/PipCore.js\";\nimport { WcsIoErrorInfo } from \"../core/platformCapability.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute } from \"../protocol/inputAttribute.js\";\n\n/**\n * `<wcs-pip target=\"...\">` — declarative Picture-in-Picture control.\n *\n * Like `<wcs-fullscreen>` (docs/fullscreen-tag-design.md §0/§1), this Shell\n * does not operate on itself: it is a non-visible control tag that resolves a\n * `target` element and invokes Picture-in-Picture commands against it. The\n * `target` attribute resolves in the same 3 modes as `intersection`/`fullscreen`\n * (`self` / a selector / the first element child), reused verbatim from\n * `@wcstack/intersection`'s `_resolveTarget()`/`_safeQuery()`\n * (packages/intersection/src/components/Intersect.ts).\n *\n * Picture-in-Picture-specific difference (docs/picture-in-picture-tag-design.md\n * §2): the resolved target must be a `<video>` element. This Shell resolves the\n * DOM element and hands it to the Core; the Core performs the `tagName ===\n * \"VIDEO\"` validation (never-throw — a mismatch is treated as an unresolved\n * target and reported via `error`, not thrown).\n */\nexport class WcsPip extends HTMLElement {\n // SSR (§4.4): observe() completes synchronously, but the Shell still exposes\n // connectedCallbackPromise so the state binder can await it uniformly across\n // all IO nodes before snapshotting.\n static hasConnectedCallbackPromise = true;\n\n static observedAttributes = [\"target\"];\n\n static wcBindable: IWcBindable = {\n ...PipCore.wcBindable,\n inputs: [{ name: \"target\", attribute: \"target\" }],\n // Core の commands をそのまま継承(単一情報源)。fullscreen/intersection と同型。\n commands: PipCore.wcBindable.commands,\n };\n\n private _core: PipCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new PipCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-pip:change\": (d) => ({ active: d?.active === true }),\n });\n }\n\n // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of\n // wc-bindable (not a bind target); see README \"CSS styling with :state()\".\n // MUST NOT return the live CustomStateSet (that would let callers write\n // states from outside, defeating the point of :state() being read-only).\n get debugStates(): string[] {\n return this._internals ? [...this._internals.states] : [];\n }\n\n private _initInternals(): ElementInternals | null {\n // never-throw (docs/custom-state-reflection-design.md §3.1): attachInternals\n // is absent in happy-dom / older environments, and pre-125 Chromium rejects\n // non-dashed state names from states.add() (probed and discarded here).\n // Either case silently disables reflection — the component still works,\n // it just doesn't expose :state() selectors.\n try {\n if (typeof this.attachInternals !== \"function\") return null;\n const internals = this.attachInternals();\n internals.states.add(\"wcs-probe\");\n internals.states.delete(\"wcs-probe\");\n return internals;\n } catch {\n return null;\n }\n }\n\n private _wireStates(map: Record<string, (detail: any) => Record<string, boolean>>): void {\n if (this._internals === null) return;\n const states = this._internals.states;\n for (const [event, toStates] of Object.entries(map)) {\n this.addEventListener(event, (e) => {\n const debug = this.hasAttribute(\"debug-states\");\n for (const [name, on] of Object.entries(toStates((e as CustomEvent).detail))) {\n try {\n if (on) { states.add(name); } else { states.delete(name); }\n } catch { /* never-throw */ }\n if (debug) this.toggleAttribute(`data-wcs-state-${name}`, on);\n }\n });\n }\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Attribute accessors ---\n\n get target(): string {\n return this.getAttribute(\"target\") ?? \"\";\n }\n\n // Never lets setAttribute stringify null / undefined (an \"undefined\" selector\n // resolves nothing): `null` removes the attribute (the first-child default),\n // `undefined` restores the attribute the element started with (wc-bindable\n // producer guidance P1; React 19 and a direct assignment deliver it,\n // @wcstack/state does not).\n set target(value: string | null | undefined) {\n reflectAttribute(this, \"target\", value);\n }\n\n // --- Core delegated getters ---\n\n get active(): boolean {\n return this._core.active;\n }\n\n get error(): any {\n return this._core.error;\n }\n\n get errorInfo(): WcsIoErrorInfo | null {\n return this._core.errorInfo;\n }\n\n // --- Commands ---\n\n async requestPictureInPicture(): Promise<void> {\n const { element } = this._resolveVideoTarget();\n return this._core.requestPictureInPicture(element);\n }\n\n async exitPictureInPicture(): Promise<void> {\n return this._core.exitPictureInPicture();\n }\n\n // --- Internal ---\n\n /**\n * `_resolveTarget()`/`_safeQuery()` copied verbatim from `@wcstack/intersection`\n * (packages/intersection/src/components/Intersect.ts:243-267, 281-287) per the\n * fullscreen/picture-in-picture batch's shared target-resolution archetype\n * (docs/fullscreen-tag-design.md §1).\n */\n private _resolveTarget(): { element: Element | null; display: string } {\n const target = this.target;\n if (target === \"self\") {\n return { element: this, display: \"block\" };\n }\n if (target !== \"\") {\n const scope = this.getRootNode() as Document | ShadowRoot;\n return { element: this._safeQuery(scope, target), display: \"none\" };\n }\n const child = this.firstElementChild;\n if (child) {\n return { element: child, display: \"contents\" };\n }\n return { element: this, display: \"block\" };\n }\n\n private _safeQuery(scope: Document | ShadowRoot, selector: string): Element | null {\n try {\n return scope.querySelector(selector);\n } catch {\n return null;\n }\n }\n\n /**\n * Layers the Picture-in-Picture-specific `tagName === \"VIDEO\"` check on top\n * of `_resolveTarget()` (docs/picture-in-picture-tag-design.md §2). A\n * resolved-but-wrong-tag element is treated as unresolved (`element: null`)\n * so it flows into the same \"target not found\" failure path as Fullscreen's\n * missing-target case — never-throw, no exception escapes.\n */\n private _resolveVideoTarget(): { element: HTMLVideoElement | null; display: string } {\n const { element, display } = this._resolveTarget();\n if (element !== null && element.tagName !== \"VIDEO\") {\n return { element: null, display };\n }\n return { element: element as HTMLVideoElement | null, display };\n }\n\n private _observe(): void {\n const { element, display } = this._resolveVideoTarget();\n this.style.display = display;\n this._connectedCallbackPromise = this._core.observe(element);\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\n this._observe();\n }\n\n disconnectedCallback(): void {\n this._core.dispose();\n }\n\n attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void {\n if (oldValue === newValue) return;\n if (!this.isConnected) return;\n this._observe();\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/define-element.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n/**\n * One copy of each package on a page (docs/timing-and-firing-contract.md §24). The first copy the\n * page evaluates defines the tags and a second one does nothing, so a copy that finds its tag defined\n * by another copy of the package — not its class, not a subclass of it, not the same version — warns\n * `[wcs/package-twice]` once per registry, naming both versions. The classes it defines carry\n * `\"<package>@<version>\"` under `Symbol.for(\"wcstack.package\")`; a class without it is named\n * \"another copy of <package> that does not name its version\" (an older copy, or one loaded through\n * an entry that does not stamp).\n */\n\n/** The static a class defined through this helper carries: `\"@wcstack/fetch@<version>\"`. */\nexport const PACKAGE_STAMP: unique symbol = Symbol.for(\"wcstack.package\");\n\ntype Stamped = { [PACKAGE_STAMP]?: string };\n\n/** The registries this copy warned about: one warning per package per registry. */\nconst warned = new WeakSet<CustomElementRegistry>();\n\n/**\n * Marks `cls` as defined by `pkg` (`\"@wcstack/fetch@<version>\"`). A subclass inherits the mark, and\n * `defineProperty` writes it even where a parent's mark is read-only.\n */\nexport function stampPackage(cls: CustomElementConstructor, pkg: string): void {\n Object.defineProperty(cls, PACKAGE_STAMP, { value: pkg, configurable: true });\n}\n\n/**\n * Warns when `tag` is defined as `existing` by another copy of the package `pkg` names: `existing`\n * is neither `own` nor a subclass of it (omit `own` when the copy has no class to compare with), and\n * carries another version or none. Once per registry.\n */\nexport function warnIfAnotherCopy(\n registry: CustomElementRegistry,\n tag: string,\n existing: CustomElementConstructor,\n own: CustomElementConstructor | undefined,\n pkg: string,\n): void {\n if (own !== undefined && (existing === own || existing.prototype instanceof own)) return;\n const theirs = (existing as Stamped)[PACKAGE_STAMP];\n if (theirs === pkg || warned.has(registry)) return;\n warned.add(registry);\n const name = pkg.slice(0, pkg.lastIndexOf(\"@\"));\n console.warn(\n `[${name}] [wcs/package-twice] <${tag}> is already defined by ` +\n `${theirs ?? `another copy of ${name} that does not name its version`}; ` +\n `this copy, ${pkg}, does nothing. Load each package once.`,\n );\n}\n\n/**\n * Defines each `[tag, class]` in `registry` unless the tag is already defined, stamping the class\n * with `pkg` (`\"@wcstack/fetch@<version>\"`). A tag another copy of the package defined first is left\n * as it is, with the warning above.\n */\nexport function defineElements(\n registry: CustomElementRegistry,\n pkg: string,\n definitions: readonly (readonly [tag: string, cls: CustomElementConstructor])[],\n): void {\n for (const [tag, cls] of definitions) {\n const existing = registry.get(tag);\n if (existing === undefined) {\n stampPackage(cls, pkg);\n registry.define(tag, cls);\n } else {\n warnIfAnotherCopy(registry, tag, existing, cls, pkg);\n }\n }\n}\n","import pkg from \"../package.json\" with { type: \"json\" };\nimport { WcsPip } from \"./components/Pip.js\";\nimport { config } from \"./config.js\";\nimport { defineElements } from \"./protocol/defineElement.js\";\n\n/**\n * Register this package's tags. Pass a scoped `CustomElementRegistry` to define\n * them for a single shadow tree -- scoped registries do not inherit the global\n * one, so a tree using one needs its own definitions.\n */\nexport function registerComponents(registry: CustomElementRegistry = customElements): void {\n defineElements(registry, `${pkg.name}@${pkg.version}`, [\n [config.tagNames.pip, WcsPip],\n ]);\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapPip(userConfig?: IWritableConfig, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n"],"names":["config","tagNames","pip","WCS_PICTURE_IN_PICTURE_ERROR_CODE","derivePictureInPictureErrorInfo","error","kind","message","String","messageOf","code","phase","recoverable","name","PipCore","EventTarget","static","protocol","version","properties","event","semantics","getter","e","detail","active","commands","async","_target","_active","_error","_errorInfo","_video","_gen","_ready","Promise","resolve","constructor","target","super","this","ready","errorInfo","observe","element","_detach","addEventListener","_onEnter","_onLeave","_syncActive","dispose","requestPictureInPicture","gen","tagName","_setError","fn","_requestPictureInPictureFn","call","exitPictureInPicture","_pictureInPictureElement","_exitPictureInPictureFn","el","undefined","d","document","bind","pictureInPictureElement","isActive","_setActive","removeEventListener","dispatchEvent","CustomEvent","bubbles","_commitErrorInfo","info","hasAccessorOnPrototype","proto","Object","getPrototypeOf","descriptor","getOwnPropertyDescriptor","get","set","toldObjectAttribute","WeakSet","warnObjectAttribute","value","has","add","tag","localName","console","warn","initialAttributes","WeakMap","reflectAttribute","initial","byName","Map","getAttribute","initialAttribute","removeAttribute","setAttribute","writeAttribute","WcsPip","HTMLElement","wcBindable","inputs","attribute","_core","_connectedCallbackPromise","_internals","_initInternals","_wireStates","debugStates","states","attachInternals","internals","delete","map","toStates","entries","debug","hasAttribute","on","toggleAttribute","connectedCallbackPromise","_resolveVideoTarget","_resolveTarget","display","scope","getRootNode","_safeQuery","child","firstElementChild","selector","querySelector","_observe","style","connectedCallback","declaration","input","toLowerCase","startsWith","prototype","hasOwnProperty","record","upgradeProperties","disconnectedCallback","attributeChangedCallback","_name","oldValue","newValue","isConnected","PACKAGE_STAMP","Symbol","for","warned","stampPackage","cls","pkg","defineProperty","configurable","warnIfAnotherCopy","registry","existing","own","theirs","slice","lastIndexOf","registerComponents","customElements","definitions","define","defineElements"],"mappings":"AAQA,MA0BaA,EA1BoB,CAC/BC,SAAU,CACRC,IAAK,2DCWF,MAAMC,EAEQ,qBAFRA,EAIM,mBAJNA,EAMC,cANDA,EAQD,YAeN,SAA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C,EAAyBC,GAC3DD,IAAaC,GACZhH,KAAKiH,aACVjH,KAAKiG,UACP,EC5LK,MAAMiB,EAA+BC,OAAOC,IAAI,mBAKjDC,EAAS,IAAIzE,QAMb,SAAU0E,EAAaC,EAA+BC,GAC1DnF,OAAOoF,eAAeF,EAAKL,EAAe,CAAEpE,MAAO0E,EAAKE,cAAc,GACxE,CAOM,SAAUC,EACdC,EACA3E,EACA4E,EACAC,EACAN,GAEA,QAAYlG,IAARwG,IAAsBD,IAAaC,GAAOD,EAASrB,qBAAqBsB,GAAM,OAClF,MAAMC,EAAUF,EAAqBX,GACrC,GAAIa,IAAWP,GAAOH,EAAOtE,IAAI6E,GAAW,OAC5CP,EAAOrE,IAAI4E,GACX,MAAMvJ,EAAOmJ,EAAIQ,MAAM,EAAGR,EAAIS,YAAY,MAC1C9E,QAAQC,KACN,IAAI/E,2BAA8B4E,4BAC/B8E,GAAU,mBAAmB1J,kDAClBmJ,2CAElB,CC5CM,SAAUU,EAAmBN,EAAkCO,0BDoDnEP,EACAJ,EACAY,GAEA,IAAK,MAAOnF,EAAKsE,KAAQa,EAAa,CACpC,MAAMP,EAAWD,EAASnF,IAAIQ,QACb3B,IAAbuG,GACFP,EAAaC,EAAKC,GAClBI,EAASS,OAAOpF,EAAKsE,IAErBI,EAAkBC,EAAU3E,EAAK4E,EAAUN,EAAKC,EAEpD,CACF,CChEEc,CAAeV,EAAU,GAAGJ,KAAYA,IAAe,CACrD,CAAChK,EAAOC,SAASC,IAAKsG,IAE1B,CCVM,IAAqD4D,EAIzDM,EAAmBN"}
1
+ {"version":3,"file":"auto.min.js","sources":["../../src/config.ts","../../src/core/platformCapability.ts","../../src/core/pictureInPictureCapabilities.ts","../../src/core/PipCore.ts","../../src/protocol/upgradeProperties.ts","../../src/protocol/inputAttribute.ts","../../src/components/Pip.ts","../../src/protocol/defineElement.ts","../../src/registerComponents.ts","../../src/bootstrapPip.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n pip: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n pip: \"wcs-pip\",\n },\n};\n\nfunction deepFreeze<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n Object.freeze(obj);\n for (const key of Object.keys(obj)) {\n deepFreeze((obj as Record<string, unknown>)[key]);\n }\n return obj;\n}\n\nfunction deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n const clone: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n clone[key] = deepClone((obj as Record<string, unknown>)[key]);\n }\n return clone as T;\n}\n\nlet frozenConfig: IConfig | null = null;\n\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\n/** A misspelt option would otherwise do nothing: `bootstrapPip` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/picture-in-picture] bootstrapPip: \"${key}\" is not one of its options, or not of the option's type.`);\n}\n\n/**\n * Applies the options given; an undefined value is left out. An option this package does not\n * have, a value of another type than its default (null, or an array for an object, included) or\n * a tag name it does not define throws, and then nothing is applied.\n */\nexport function setConfig(partialConfig: IWritableConfig): void {\n const options = _config as unknown as Record<string, unknown>;\n const tags = _config.tagNames as Record<string, string>;\n const given = Object.entries(partialConfig).filter(([, value]) => value !== undefined);\n const givenTags = Object.entries(partialConfig.tagNames ?? {}).filter(([, tag]) => tag !== undefined);\n for (const [key, value] of given) {\n const current = options[key];\n if (!Object.hasOwn(options, key) || value === null || typeof value !== typeof current || Array.isArray(value) !== Array.isArray(current)) {\n invalid(key);\n }\n }\n for (const [name, tag] of givenTags) {\n if (!Object.hasOwn(tags, name) || typeof tag !== \"string\") invalid(`tagNames.${name}`);\n }\n for (const [name, tag] of givenTags) tags[name] = tag as string;\n frozenConfig = null;\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /io-core/platform-capability.ts by scripts/sync-io-core.mjs.\n// Run `node scripts/sync-io-core.mjs` after editing the source.\n// ===========================================================================\n\n/**\n * platform-capability.ts\n *\n * Phase 6(docs/architecture-hardening/09-remediation-design.md §7.2 /\n * 07-browser-capability-variance.md)の browser capability 判定と error taxonomy の\n * 汎用プリミティブ。node 固有の capability registry / error code は各パッケージが\n * 別ファイルで宣言し、この汎用層(型 + assess 機構)を import する。\n *\n * 原則:\n * - feature detection は境界(利用直前)で行う。module 評価時に browser global を\n * 参照しない(SSR / worker で import が失敗しない)。\n * - capability ID(`web.fetch` 等)は文字列を global property path として eval せず、\n * registry が ID ごとに副作用のない presence probe を対応付ける。\n * - availability / permission / readiness / activity / operation error を 1 つの\n * `ready / unsupported / error` enum に畳まない。required 欠如は開始しない、\n * optional 欠如は宣言済み fallback で readiness を `degraded` にする。\n *\n * 配置: 本ファイルは /io-core/ の単一正典であり、scripts/sync-io-core.mjs が\n * 各 IO ノードの src/core/ へ生成コピー (AUTO-GENERATED, 編集禁止) を配布する。\n * `protocol/wcBindable.ts` と同じ copy-distribution 方式で、ランタイム依存を導入せず\n * 各パッケージのバンドルへ inline される (zero-runtime-dep / 自己完結 CDN を維持)。\n * 編集はこの正典に対して行い、`node scripts/sync-io-core.mjs` で再配布する。\n *\n * pure(module 評価時に browser global 非参照)。\n */\n\nexport type Availability = \"available\" | \"missing\" | \"unknown\";\nexport type PermissionState = \"granted\" | \"denied\" | \"prompt\" | \"not-applicable\" | \"unknown\";\nexport type Readiness = \"idle\" | \"ready\" | \"degraded\";\nexport type Activity = \"inactive\" | \"active\";\nexport type PreconditionState = \"satisfied\" | \"required\" | \"not-applicable\";\n\n/** operation error の phase(taxonomy)。 */\nexport type WcsIoErrorPhase = \"probe\" | \"start\" | \"execute\" | \"decode\" | \"commit\" | \"dispose\";\n\n/** serializable な error info(non-cloneable な cause とは分離。DevTools / remote へは info のみ)。 */\nexport interface WcsIoErrorInfo {\n readonly code: string;\n readonly phase: WcsIoErrorPhase;\n readonly recoverable: boolean;\n readonly capabilityId?: string;\n readonly message: string;\n}\n\nexport interface PlatformAssessment {\n readonly availability: ReadonlyMap<string, Availability>;\n readonly permission: PermissionState;\n readonly readiness: Readiness;\n readonly activity: Activity;\n readonly preconditions: {\n readonly secureContext: PreconditionState;\n readonly userActivation: PreconditionState;\n };\n readonly epoch: number;\n readonly lastError?: WcsIoErrorInfo;\n}\n\n/** capability 1 件の仕様。probe は副作用なく presence を返す(利用直前に呼ぶ)。 */\nexport interface CapabilitySpec {\n readonly probe: () => boolean;\n readonly requiresSecureContext?: boolean;\n readonly requiresUserActivation?: boolean;\n /** browser compatibility dataset のキー(任意・診断用)。 */\n readonly compatKey?: string;\n}\n\nexport type CapabilityRegistry = ReadonlyMap<string, CapabilitySpec>;\n\nexport interface AssessOptions {\n readonly required: readonly string[];\n readonly optional?: readonly string[];\n readonly permission?: PermissionState;\n readonly activity?: Activity;\n readonly epoch?: number;\n readonly lastError?: WcsIoErrorInfo;\n}\n\nfunction isSecureContext(): boolean {\n return (globalThis as { isSecureContext?: unknown }).isSecureContext === true;\n}\n\n/**\n * capability を利用直前に評価して PlatformAssessment を作る。\n * required が 1 つでも欠ければ readiness は \"idle\"(開始不可)、\n * required 揃い + optional 欠けは \"degraded\"、全揃いは \"ready\"。\n */\nexport function assessCapabilities(registry: CapabilityRegistry, options: AssessOptions): PlatformAssessment {\n const availability = new Map<string, Availability>();\n const evaluate = (id: string): Availability => {\n const spec = registry.get(id);\n if (spec === undefined) return \"unknown\";\n return spec.probe() ? \"available\" : \"missing\";\n };\n\n let requiredAllAvailable = true;\n for (const id of options.required) {\n const a = evaluate(id);\n availability.set(id, a);\n if (a !== \"available\") requiredAllAvailable = false;\n }\n let optionalAllAvailable = true;\n for (const id of options.optional ?? []) {\n const a = evaluate(id);\n availability.set(id, a);\n if (a !== \"available\") optionalAllAvailable = false;\n }\n\n const readiness: Readiness = !requiredAllAvailable ? \"idle\" : (optionalAllAvailable ? \"ready\" : \"degraded\");\n\n // preconditions: 対象 capability のいずれかが要求する場合だけ評価する。\n const allIds = [...options.required, ...(options.optional ?? [])];\n const needsSecure = allIds.some((id) => registry.get(id)?.requiresSecureContext === true);\n const needsActivation = allIds.some((id) => registry.get(id)?.requiresUserActivation === true);\n const secureContext: PreconditionState = needsSecure ? (isSecureContext() ? \"satisfied\" : \"required\") : \"not-applicable\";\n const userActivation: PreconditionState = needsActivation ? \"required\" : \"not-applicable\";\n\n return {\n availability,\n permission: options.permission ?? \"not-applicable\",\n readiness,\n activity: options.activity ?? \"inactive\",\n preconditions: { secureContext, userActivation },\n epoch: options.epoch ?? 0,\n lastError: options.lastError,\n };\n}\n\n/** availability から「required がすべて available か」を判定するヘルパ(supported の最低条件)。 */\nexport function requiredCapabilitiesAvailable(assessment: PlatformAssessment, required: readonly string[]): boolean {\n return required.every((id) => assessment.availability.get(id) === \"available\");\n}\n\n/**\n * このページで機能が使えない理由(使える、または分からないなら null)。利用直前に読む。\n *\n * - `\"insecure-context\"`: 安全なコンテキストではない(`isSecureContext === false`)。\n * Permissions API が扱う機能はどれも安全なコンテキストを要る。\n * - `\"policy-blocked\"`: Permissions-Policy(サーバーのヘッダ、または `allow` の無い\n * `<iframe>`)がその機能を切っている。\n *\n * どちらも Permissions API は教えない: Chromium はポリシーで切られた文書でも\n * `granted` を、安全でない origin では `denied` を返す。利用者の拒否と区別するため、\n * 見張り役(`<wcs-permission>`)も取りに行く側も `unsupported` を報告する\n * (docs/v4-direction-2026-10.md の決定、state-field-report)。\n * `isSecureContext` が無い環境(SSR・テスト)は判断しない。\n */\nexport type FeatureUnavailableReason = \"insecure-context\" | \"policy-blocked\";\n\n/**\n * Permissions-Policy が制御する機能。permission 名と同じ文字列と、permission の無い機能\n * (`fullscreen`・`picture-in-picture`・`web-share`: 要素が「このページで使えるか」を言うために聞く)。\n */\nconst POLICY_CONTROLLED = new Set([\n \"camera\", \"microphone\", \"geolocation\", \"midi\", \"clipboard-read\", \"clipboard-write\",\n \"screen-wake-lock\", \"idle-detection\", \"accelerometer\", \"gyroscope\", \"magnetometer\",\n \"ambient-light-sensor\", \"display-capture\", \"fullscreen\", \"picture-in-picture\", \"web-share\",\n]);\n\ninterface PolicyLike { allowsFeature(feature: string): boolean; features?(): string[] }\n\nexport function featureUnavailable(feature: string): FeatureUnavailableReason | null {\n const g = globalThis as { isSecureContext?: unknown; document?: { permissionsPolicy?: PolicyLike; featurePolicy?: PolicyLike } };\n if (g.isSecureContext === false) return \"insecure-context\";\n if (!POLICY_CONTROLLED.has(feature)) return null;\n const policy = g.document?.permissionsPolicy ?? g.document?.featurePolicy;\n if (policy === undefined || typeof policy.allowsFeature !== \"function\") return null;\n try {\n // このブラウザのポリシーが知らない名前は聞かない: Chromium は知らない名前の allowsFeature に\n // false を返したうえでコンソールに「Unrecognized feature」を出す(フラグの無い\n // `ambient-light-sensor`、デスクトップの `web-share`)。知らない機能は切られてもいない。\n if (typeof policy.features === \"function\" && !policy.features().includes(feature)) return null;\n return policy.allowsFeature(feature) ? null : \"policy-blocked\";\n } catch {\n return null;\n }\n}\n\n/** `featureUnavailable` の理由を、作者が直し方を読める文にする。`what` は文頭(「The camera」など)。 */\nexport function featureUnavailableMessage(what: string, feature: string, reason: FeatureUnavailableReason): string {\n return reason === \"insecure-context\"\n ? `${what} needs a secure context (https:, or http://localhost), and this page is not one.`\n : `${what} is turned off for this page by a Permissions-Policy: the server's Permissions-Policy header, ` +\n `or an <iframe> without allow=\"${feature}\". The browser's site settings cannot change that.`;\n}\n","/**\n * pictureInPictureCapabilities.ts\n *\n * Picture-in-Picture node 固有の error code(taxonomy)と derivation。汎用の error\n * info 型は `./platformCapability.js`(/io-core/ から copy-distribution される生成\n * ファイル)から import する。Picture-in-Picture は referenced `<video>` を操作する\n * ノードで競合 operation を持たないため lane は無く、error taxonomy(errorInfo)のみを\n * 採用する(fullscreen と同型)。\n *\n * `_setError` は合成 `{ message }`(target が `<video>` に解決しない / API 非対応)と\n * caught 例外(`NotAllowedError` = user gesture 外の requestPictureInPicture 拒否等)を\n * 混在受理する。呼出側が明示 `kind` を渡して合成側を曖昧さ無く分類し、caught は `.name`\n * で分類する(fullscreen / storage / screen-orientation と同じ discriminator 方式)。\n */\n\nimport type { WcsIoErrorInfo } from \"./platformCapability.js\";\n\n/** 明示 kind discriminator(合成エラーの呼出側が渡す)。 */\nexport type PictureInPictureErrorKind = \"capability-missing\" | \"invalid-argument\";\n\n/** 安定した Picture-in-Picture error code(taxonomy)。値は公開キーとして固定。 */\nexport const WCS_PICTURE_IN_PICTURE_ERROR_CODE = {\n /** Picture-in-Picture API 非対応。 */\n CapabilityMissing: \"capability-missing\",\n /** target が `<video>` に解決しない等の入力不備。 */\n InvalidArgument: \"invalid-argument\",\n /** `NotAllowedError` / `TypeError` — user gesture 外での要求拒否。 */\n NotAllowed: \"not-allowed\",\n /** その他の caught 例外。 */\n PipError: \"pip-error\",\n} as const;\n\nfunction messageOf(error: unknown): string {\n return typeof (error as { message?: unknown } | null)?.message === \"string\"\n ? (error as { message: string }).message\n : String(error);\n}\n\n/**\n * Picture-in-Picture の失敗を serializable な error taxonomy に写す。`kind` は合成\n * エラーの呼出側が渡す明示 discriminator(`capability-missing` / `invalid-argument`)。\n * 未指定は caught 例外を意味し、`.name` で分類する。`NotAllowedError` / `TypeError` は\n * user gesture 内で再試行すれば成功しうるため recoverable=true。\n */\nexport function derivePictureInPictureErrorInfo(error: unknown, kind?: PictureInPictureErrorKind): WcsIoErrorInfo {\n const message = messageOf(error);\n if (kind === \"capability-missing\") {\n return { code: WCS_PICTURE_IN_PICTURE_ERROR_CODE.CapabilityMissing, phase: \"probe\", recoverable: false, message };\n }\n if (kind === \"invalid-argument\") {\n return { code: WCS_PICTURE_IN_PICTURE_ERROR_CODE.InvalidArgument, phase: \"start\", recoverable: false, message };\n }\n const name = (error as { name?: unknown } | null)?.name;\n if (name === \"NotAllowedError\" || name === \"TypeError\") {\n return { code: WCS_PICTURE_IN_PICTURE_ERROR_CODE.NotAllowed, phase: \"execute\", recoverable: true, message };\n }\n return { code: WCS_PICTURE_IN_PICTURE_ERROR_CODE.PipError, phase: \"execute\", recoverable: false, message };\n}\n","import { IWcBindable } from \"../types.js\";\nimport { WcsIoErrorInfo, featureUnavailable } from \"./platformCapability.js\";\nimport { derivePictureInPictureErrorInfo, PictureInPictureErrorKind } from \"./pictureInPictureCapabilities.js\";\n\n/**\n * Headless Picture-in-Picture primitive. A thin, framework-agnostic wrapper\n * around the classic Picture-in-Picture API\n * (`HTMLVideoElement.requestPictureInPicture()` / `document.exitPictureInPicture()` /\n * `document.pictureInPictureElement`) exposed through the wc-bindable protocol.\n *\n * This Core follows the same basic pattern as `@wcstack/fullscreen`'s\n * `FullscreenCore` (docs/fullscreen-tag-design.md): target resolution is done\n * by the Shell (this Core receives the resolved element at call time), API\n * resolution is call-time/non-cached, `_gen` is a single Core-level generation\n * guard, and `error` is a simple single field (no permission-style 4-value\n * state). See docs/picture-in-picture-tag-design.md for the differences from\n * Fullscreen:\n *\n * - **§2 target constraint**: the resolved target MUST be a `<video>` element.\n * Picture-in-Picture is only defined as an instance method of\n * `HTMLVideoElement` — unlike Fullscreen, which any `Element` supports. A\n * non-`<video>` target is a never-throw failure: it is treated the same as\n * an unresolved target and reported via `error`.\n * - **§3 event subscription target**: `enterpictureinpicture` /\n * `leavepictureinpicture` fire on the `<video>` element itself, not on\n * `document` (the reverse of Fullscreen's `document`-level\n * `fullscreenchange`). The Core attaches/detaches these listeners directly\n * on the resolved `<video>` element, re-wiring them whenever the target is\n * re-resolved (e.g. the Shell's `target` attribute changes).\n */\nexport class PipCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"active\", event: \"wcs-pip:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.active },\n // `error` / `errorInfo` are observable failure outputs. Historically `error`\n // was an imperative getter with no event; both are now bindable (event-backed)\n // so `data-wcs` / bind() can observe a request/exit failure. `errorInfo` is the\n // additive serializable taxonomy (stable code / phase / recoverable) derived\n // from `error`; the `error` value shape is unchanged. No lane — Picture-in-Picture\n // drives a referenced `<video>`, not a competing operation (fullscreen と同型)。\n { name: \"error\", event: \"wcs-pip:error\", semantics: \"state\" },\n { name: \"errorInfo\", event: \"wcs-pip:error-info-changed\", semantics: \"state\" },\n // Whether this page can use Picture-in-Picture (the API is there and no\n // Permissions-Policy forbids it). Computed at call time; the event carries\n // the boolean and fires from observe() when it differs from the last value\n // dispatched.\n { name: \"supported\", event: \"wcs-pip:supported-changed\", semantics: \"state\" },\n ],\n commands: [\n { name: \"requestPictureInPicture\", async: true },\n { name: \"exitPictureInPicture\", async: true },\n ],\n };\n\n private _target: EventTarget;\n private _active: boolean = false;\n private _error: any = null;\n private _errorInfo: WcsIoErrorInfo | null = null;\n\n // The <video> element the Core currently subscribes to for\n // enterpictureinpicture/leavepictureinpicture (null when unresolved/torn down).\n private _video: HTMLVideoElement | null = null;\n\n // Generation guard (§3.4 / fullscreen-tag-design.md §6): bumped on dispose()\n // and each async command start. A completion that lands after dispose() (or\n // after a superseding call) is stale and MUST NOT write state.\n private _gen = 0;\n\n // `supported` as last dispatched (never the value itself — the getter probes at\n // call time). Starts at false, so observe() announces a page that can use it.\n private _supportedPublished = false;\n\n // SSR (§3.8): no asynchronous probe to await, so readiness is immediate.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n get ready(): Promise<void> {\n return this._ready;\n }\n\n get active(): boolean {\n return this._active;\n }\n\n get error(): any {\n return this._error;\n }\n\n /**\n * The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /\n * `recoverable`), or null. Additive wc-bindable property (event\n * `wcs-pip:error-info-changed`), derived from `error`; the existing `error`\n * value shape is unchanged.\n */\n get errorInfo(): WcsIoErrorInfo | null {\n return this._errorInfo;\n }\n\n /**\n * Whether this page can use Picture-in-Picture right now: the document says it\n * is enabled, a `<video>` has `requestPictureInPicture()`, and no\n * Permissions-Policy (`picture-in-picture`: the server's header, an `<iframe>`\n * whose `allow` turns it off) forbids it. Probed at call time, never cached.\n * It does not say that a request will succeed (that still needs a user gesture\n * and a video that can be shown, and a `<video disablepictureinpicture>`\n * refuses). Firefox has no Picture-in-Picture API for pages, so this is\n * `false` there. A wc-bindable output (event `wcs-pip:supported-changed`).\n */\n get supported(): boolean {\n // The policy is asked first, and `pictureInPictureEnabled` is read only when\n // it did not forbid: Chromium logs a console error for merely reading it in a\n // document the policy forbids. Only \"policy-blocked\" decides here:\n // Picture-in-Picture does not need a secure context (a plain http: page can\n // use it), so \"insecure-context\" is not a reason — `pictureInPictureEnabled`,\n // which follows the policy itself, gives the answer there.\n if (featureUnavailable(\"picture-in-picture\") === \"policy-blocked\") return false;\n return (document as any).pictureInPictureEnabled === true\n && typeof (HTMLVideoElement.prototype as any).requestPictureInPicture === \"function\";\n }\n\n // --- Lifecycle (§3.5) ---\n\n /**\n * (Re-)subscribe to `enterpictureinpicture`/`leavepictureinpicture` on\n * `element` (the Shell's resolved `<video>` target). Idempotent when called\n * again with the same element; re-wires the listeners when the element\n * changes (e.g. the `target` attribute was changed), detaching from the\n * previous element first so no stale listener lingers. Also publishes\n * `supported` when it differs from the last value dispatched.\n */\n observe(element: HTMLVideoElement | null): Promise<void> {\n this._publishSupported();\n if (this._video === element) {\n return this._ready;\n }\n this._detach();\n this._video = element;\n if (element) {\n element.addEventListener(\"enterpictureinpicture\", this._onEnter);\n element.addEventListener(\"leavepictureinpicture\", this._onLeave);\n }\n this._syncActive();\n return this._ready;\n }\n\n dispose(): void {\n this._gen++;\n this._detach();\n this._video = null;\n // A disposed Core hears no leavepictureinpicture, so it can no longer vouch\n // for `active`: publish false through the normal setter (timing contract §22\n // — a disconnect publishes what it changes). The small window is not closed\n // here; observe() re-reads the truth — publishing true again — on the next\n // connect.\n this._setActive(false);\n }\n\n // --- Commands (§3.6 never-throw) ---\n\n /**\n * Request Picture-in-Picture for `element`. `element` must be a `<video>`\n * (checked before the gesture-context failure path, since a type mismatch is\n * an environment-independent, permanent error — docs/picture-in-picture-tag-design.md §2).\n * Never throws: all failures (wrong tag, unsupported API, gesture-context\n * rejection) are funneled into `error` and the returned promise resolves.\n */\n async requestPictureInPicture(element: HTMLVideoElement | null): Promise<void> {\n const gen = ++this._gen;\n if (!element || element.tagName !== \"VIDEO\") {\n // Distinct from \"API is not supported\" (below): the resolved target did\n // not satisfy the `<video>`-only constraint (wrong tag / unresolved).\n this._setError({ message: \"target must be a <video> element.\" }, \"invalid-argument\");\n return;\n }\n // Re-wire to `element` before issuing the platform call: a caller may\n // request a <video> different from the one last passed to observe() (e.g.\n // the Shell's target attribute pointed at nothing at connect time and the\n // matching <video> was only inserted later, so no attributeChangedCallback\n // ever re-resolved it). Without this, `_video` stays stale and\n // `_syncActive()` below (and future enter/leave events) would never\n // recognize `element` as this Core's target, leaving `active` permanently\n // wrong even though the request succeeded (mirrors\n // FullscreenCore.requestFullscreen()'s unconditional `this._resolvedTarget\n // = element` assignment — docs/fullscreen-tag-design.md §6).\n this.observe(element);\n const fn = this._requestPictureInPictureFn(element);\n if (!fn) {\n this._setError({ message: \"Picture-in-Picture API is not supported.\" }, \"capability-missing\");\n return;\n }\n try {\n await fn.call(element);\n if (gen !== this._gen) return; // stale\n this._setError(null);\n this._syncActive(); // belt-and-suspenders (mirrors FullscreenCore's _applyActive() on success)\n } catch (e: any) {\n if (gen !== this._gen) return; // stale\n this._setError(e); // e.g. NotAllowedError (gesture-context rejection)\n }\n }\n\n /**\n * Exit Picture-in-Picture. Mirrors FullscreenCore.exitFullscreen(): a\n * silent no-op (resolve, no error) when nothing is currently in\n * Picture-in-Picture — see fullscreen-tag-design.md §7.\n */\n async exitPictureInPicture(): Promise<void> {\n // no-op checks come BEFORE the generation bump: a call that does nothing\n // must not supersede an in-flight requestPictureInPicture() — bumping\n // first would make the pending request's settle handling stale and\n // silently swallow its error update (mirrors\n // FullscreenCore.exitFullscreen()).\n if (this._pictureInPictureElement() === null) return; // already not in PiP: silent no-op\n const fn = this._exitPictureInPictureFn();\n if (!fn) return; // unsupported: silent no-op (semantically already \"not in PiP\")\n const gen = ++this._gen;\n try {\n await fn();\n if (gen !== this._gen) return;\n this._setError(null);\n this._syncActive(); // belt-and-suspenders (mirrors FullscreenCore.exitFullscreen()'s success-path _applyActive()); covers a delayed/dropped leavepictureinpicture\n } catch (e: any) {\n if (gen !== this._gen) return;\n this._setError(e);\n }\n }\n\n // --- Internal: API resolution (call-time, never cached — §3.7) ---\n\n // Unlike FullscreenCore's _elementFullscreenFn(), a naive direct property\n // lookup (`e.requestPictureInPicture`, walking the prototype chain) here is\n // safe: it cannot recurse into the Shell's own command method,\n // because the resolved target is validated to be a <video> element (§2)\n // before this is called, and <wcs-pip> (the Shell) is never itself a\n // <video>. Fullscreen's own→Element.prototype two-step resolution guards\n // against `target=\"self\"`/no-target resolving to the Shell element, which\n // cannot happen here.\n private _requestPictureInPictureFn(el: HTMLVideoElement): (() => Promise<PictureInPictureWindow>) | undefined {\n const e = el as any;\n return typeof e.requestPictureInPicture === \"function\" ? e.requestPictureInPicture : undefined;\n }\n\n private _exitPictureInPictureFn(): (() => Promise<void>) | undefined {\n const d = document as any;\n return typeof d.exitPictureInPicture === \"function\" ? d.exitPictureInPicture.bind(document) : undefined;\n }\n\n private _pictureInPictureElement(): Element | null {\n const d = document as any;\n return d.pictureInPictureElement ?? null;\n }\n\n // --- Internal: event wiring ---\n\n private _onEnter = (): void => {\n this._syncActive();\n };\n\n private _onLeave = (): void => {\n this._syncActive();\n };\n\n private _syncActive(): void {\n const isActive = this._video !== null && this._pictureInPictureElement() === this._video;\n this._setActive(isActive);\n }\n\n private _detach(): void {\n if (this._video) {\n this._video.removeEventListener(\"enterpictureinpicture\", this._onEnter);\n this._video.removeEventListener(\"leavepictureinpicture\", this._onLeave);\n }\n }\n\n // --- State setters with event dispatch (§3.3 same-value guard) ---\n\n // `supported` is probed at call time, so there is no stored value to set: this\n // dispatches the current one when it differs from the last one dispatched\n // (same-value guard). A state binding reads the property when it attaches; the\n // event is for every other listener.\n private _publishSupported(): void {\n const supported = this.supported;\n if (this._supportedPublished === supported) return;\n this._supportedPublished = supported;\n this._target.dispatchEvent(new CustomEvent(\"wcs-pip:supported-changed\", {\n detail: supported,\n bubbles: true,\n }));\n }\n\n private _setActive(active: boolean): void {\n if (this._active === active) return;\n this._active = active;\n this._target.dispatchEvent(new CustomEvent(\"wcs-pip:change\", {\n detail: { active },\n bubbles: true,\n }));\n }\n\n // `kind` is an explicit taxonomy discriminator passed only from the synthetic\n // error sites (unsupported / non-<video> target); caught exceptions pass no kind\n // and are classified by their `.name`. Both `error` and the additive `errorInfo`\n // are now event-backed so a request/exit failure is observable via bind().\n private _setError(error: any, kind?: PictureInPictureErrorKind): void {\n // Same-value guard on reference: each failure builds a fresh object and the\n // clear path passes the literal null, so this only suppresses redundant\n // null→null (a successful request/exit clearing an already-null error).\n if (this._error === error) return;\n this._error = error;\n // Keep the additive errorInfo taxonomy in sync; fire it before the `error`\n // event so an observer of both sees the classification first (io-node family).\n this._commitErrorInfo(error === null ? null : derivePictureInPictureErrorInfo(error, kind));\n this._target.dispatchEvent(new CustomEvent(\"wcs-pip:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n // Called only from _setError (already reference-guarded), so errorInfo\n // transitions exactly when error does — no separate guard needed here.\n private _commitErrorInfo(info: WcsIoErrorInfo | null): void {\n this._errorInfo = info;\n this._target.dispatchEvent(new CustomEvent(\"wcs-pip:error-info-changed\", {\n detail: info,\n bubbles: true,\n }));\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/upgrade-properties.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// custom element の property upgrade — `static wcBindable.inputs` に宣言した入力のうち、\n// 要素が upgrade される前に代入された own データプロパティを取り込み直す。\n//\n// なぜ必要か:\n// 未定義タグの要素は素の HTMLElement なので、`el.url = \"...\"` は own データプロパティを作る。\n// upgrade 後にクラスの accessor が prototype へ入っても own プロパティが優先されるため、\n// setter は二度と呼ばれず、値は要素へ届かないまま消える(エラーも警告も出ない)。\n// 常にプロパティ代入を行う framework(Angular の `[prop]`、Lit の `.prop=`、\n// Solid の `prop:`、Vue の `.prop` 修飾子)× 遅延定義(autoloader / CDN / code-split)で\n// 常態的に起きる。docs/architecture-hardening/13-framework-adapter-binding-constraints.md §1.2。\n//\n// 安全側の判定:\n// own プロパティがあっても、prototype チェーンに accessor が無ければ「シャドウ」ではなく\n// その own プロパティ自体が正規の格納先なので触らない(public class field を壊さない)。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/upgrade-properties.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/upgradeProperties.ts). Those copies are generated — do not edit them.\nimport { IWcBindable } from \"./wcBindable.js\";\n\nfunction hasAccessorOnPrototype(target: object, name: string): boolean {\n let proto = Object.getPrototypeOf(target);\n while (proto !== null) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n if (descriptor !== undefined) {\n return typeof descriptor.get === \"function\" || typeof descriptor.set === \"function\";\n }\n proto = Object.getPrototypeOf(proto);\n }\n return false;\n}\n\n// 属性になってしまったオブジェクトの入力(`files=\"[object File]\"`)を、要素ごとに 1 回だけ言う。\n// React 19 は定義前の要素にプロパティが無いのでオブジェクトを属性に書き、Vue の `.attr` も\n// 書く。要素はその入力をプロパティでしか読まないので、何も受け取らず、何も言わなかった\n// (docs/seam-apps.md、fw-inventory)。\nconst toldObjectAttribute = new WeakSet<object>();\n\nfunction warnObjectAttribute(element: object, name: string, value: string): void {\n if (toldObjectAttribute.has(element)) return;\n toldObjectAttribute.add(element);\n const tag = (element as { localName?: string }).localName ?? \"element\";\n console.warn(\n `[wcs/input-as-attribute] <${tag}> has the attribute ${name}=\"${value}\": an object was written as an ` +\n `attribute, so the element did not receive it. A framework does that when the property is set before the ` +\n `element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, ` +\n `or assign the property through a ref (Vue: .prop). (Said once per element.)`,\n element,\n );\n}\n\n/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\n * - 値が `[object …]` の属性(属性に書かれてしまったオブジェクトの入力)は、要素ごとに 1 回警告する。\n */\nexport function upgradeProperties(element: object): void {\n const declaration = (element as { constructor?: { wcBindable?: IWcBindable } }).constructor?.wcBindable;\n const inputs = declaration?.inputs;\n if (inputs === undefined) return;\n const getAttribute = (element as { getAttribute?: (name: string) => string | null }).getAttribute;\n for (const input of inputs) {\n const name = input.name;\n const attribute = typeof getAttribute === \"function\" ? getAttribute.call(element, name.toLowerCase()) : null;\n if (attribute !== null && attribute.startsWith(\"[object \")) warnObjectAttribute(element, name, attribute);\n if (!Object.prototype.hasOwnProperty.call(element, name)) continue;\n if (!hasAccessorOnPrototype(element, name)) continue;\n const record = element as Record<string, unknown>;\n const value = record[name];\n delete record[name];\n record[name] = value;\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/input-attribute.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// 属性へ反映する wc-bindable 入力の producer 側(SPEC-extensions § Producer guidance for inputs の P1〜P3)。\n// 入力の setter は属性をこの 2 関数で書く。それで次が揃う:\n// - `undefined` は「値が無い」(P1): 属性を、この関数で最初に書く前の状態 — マークアップに書かれた値、\n// 無ければ属性なし(= その入力の文書化した既定値)— へ戻す。applier プロファイルを宣言する binder は\n// 値の後の `undefined` を書き(A2)、React 19 も書き、直接の代入でも届く。\n// - `null` はクリア(P2): 属性なし、つまり文書化した既定値。\n// - どちらも文字列 \"undefined\" / \"null\" として属性に入らない。\n//\n// 「最初に書く前」は、その最初の書き込みのときに読む(遅延)。upgrade 前に代入されたプロパティは\n// connectedCallback の upgradeProperties() が通し直すので、そのときにはパーサが書いた属性が揃っている。\n// 要素自身が setter を通さずに書いた属性は、最初の書き込みより前なら「最初の状態」に含まれる。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/input-attribute.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/inputAttribute.ts). Those copies are generated — do not edit them.\n\nconst initialAttributes = new WeakMap<Element, Map<string, string | null>>();\n\n/** The attribute as it stood before the first write through these helpers. */\nfunction initialAttribute(el: Element, name: string): string | null {\n let byName = initialAttributes.get(el);\n if (byName === undefined) {\n byName = new Map();\n initialAttributes.set(el, byName);\n }\n if (!byName.has(name)) byName.set(name, el.getAttribute(name));\n return byName.get(name) as string | null;\n}\n\nfunction writeAttribute(el: Element, name: string, value: string | null): void {\n if (value === null) el.removeAttribute(name);\n else el.setAttribute(name, value);\n}\n\n/**\n * A value attribute. `value` is written as `String(value)`; `null` removes the attribute;\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value === null ? null : String(value));\n}\n\n/**\n * A boolean attribute, present while `value` is truthy (`null` and `false` remove it);\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectBooleanAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value ? \"\" : null);\n}\n","import { IWcBindable } from \"../types.js\";\nimport { PipCore } from \"../core/PipCore.js\";\nimport { WcsIoErrorInfo } from \"../core/platformCapability.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute } from \"../protocol/inputAttribute.js\";\n\n/**\n * `<wcs-pip target=\"...\">` — declarative Picture-in-Picture control.\n *\n * Like `<wcs-fullscreen>` (docs/fullscreen-tag-design.md §0/§1), this Shell\n * does not operate on itself: it is a non-visible control tag that resolves a\n * `target` element and invokes Picture-in-Picture commands against it. The\n * `target` attribute resolves in the same 3 modes as `intersection`/`fullscreen`\n * (`self` / a selector / the first element child), reused verbatim from\n * `@wcstack/intersection`'s `_resolveTarget()`/`_safeQuery()`\n * (packages/intersection/src/components/Intersect.ts).\n *\n * Picture-in-Picture-specific difference (docs/picture-in-picture-tag-design.md\n * §2): the resolved target must be a `<video>` element. This Shell resolves the\n * DOM element and hands it to the Core; the Core performs the `tagName ===\n * \"VIDEO\"` validation (never-throw — a mismatch is treated as an unresolved\n * target and reported via `error`, not thrown).\n */\nexport class WcsPip extends HTMLElement {\n // SSR (§4.4): observe() completes synchronously, but the Shell still exposes\n // connectedCallbackPromise so the state binder can await it uniformly across\n // all IO nodes before snapshotting.\n static hasConnectedCallbackPromise = true;\n\n static observedAttributes = [\"target\"];\n\n static wcBindable: IWcBindable = {\n ...PipCore.wcBindable,\n inputs: [{ name: \"target\", attribute: \"target\" }],\n // Core の commands をそのまま継承(単一情報源)。fullscreen/intersection と同型。\n commands: PipCore.wcBindable.commands,\n };\n\n private _core: PipCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new PipCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-pip:change\": (d) => ({ active: d?.active === true }),\n });\n }\n\n // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of\n // wc-bindable (not a bind target); see README \"CSS styling with :state()\".\n // MUST NOT return the live CustomStateSet (that would let callers write\n // states from outside, defeating the point of :state() being read-only).\n get debugStates(): string[] {\n return this._internals ? [...this._internals.states] : [];\n }\n\n private _initInternals(): ElementInternals | null {\n // never-throw (docs/custom-state-reflection-design.md §3.1): attachInternals\n // is absent in happy-dom / older environments, and pre-125 Chromium rejects\n // non-dashed state names from states.add() (probed and discarded here).\n // Either case silently disables reflection — the component still works,\n // it just doesn't expose :state() selectors.\n try {\n if (typeof this.attachInternals !== \"function\") return null;\n const internals = this.attachInternals();\n internals.states.add(\"wcs-probe\");\n internals.states.delete(\"wcs-probe\");\n return internals;\n } catch {\n return null;\n }\n }\n\n private _wireStates(map: Record<string, (detail: any) => Record<string, boolean>>): void {\n if (this._internals === null) return;\n const states = this._internals.states;\n for (const [event, toStates] of Object.entries(map)) {\n this.addEventListener(event, (e) => {\n const debug = this.hasAttribute(\"debug-states\");\n for (const [name, on] of Object.entries(toStates((e as CustomEvent).detail))) {\n try {\n if (on) { states.add(name); } else { states.delete(name); }\n } catch { /* never-throw */ }\n if (debug) this.toggleAttribute(`data-wcs-state-${name}`, on);\n }\n });\n }\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Attribute accessors ---\n\n get target(): string {\n return this.getAttribute(\"target\") ?? \"\";\n }\n\n // Never lets setAttribute stringify null / undefined (an \"undefined\" selector\n // resolves nothing): `null` removes the attribute (the first-child default),\n // `undefined` restores the attribute the element started with (wc-bindable\n // producer guidance P1; React 19 and a direct assignment deliver it,\n // @wcstack/state does not).\n set target(value: string | null | undefined) {\n reflectAttribute(this, \"target\", value);\n }\n\n // --- Core delegated getters ---\n\n get active(): boolean {\n return this._core.active;\n }\n\n get error(): any {\n return this._core.error;\n }\n\n get errorInfo(): WcsIoErrorInfo | null {\n return this._core.errorInfo;\n }\n\n // Whether this page can use Picture-in-Picture — probed at call time by the\n // Core (never cached), so a state binding that reads it when it attaches gets\n // the right value without waiting for `wcs-pip:supported-changed`.\n get supported(): boolean {\n return this._core.supported;\n }\n\n // --- Commands ---\n\n async requestPictureInPicture(): Promise<void> {\n const { element } = this._resolveVideoTarget();\n return this._core.requestPictureInPicture(element);\n }\n\n async exitPictureInPicture(): Promise<void> {\n return this._core.exitPictureInPicture();\n }\n\n // --- Internal ---\n\n /**\n * `_resolveTarget()`/`_safeQuery()` copied verbatim from `@wcstack/intersection`\n * (packages/intersection/src/components/Intersect.ts:243-267, 281-287) per the\n * fullscreen/picture-in-picture batch's shared target-resolution archetype\n * (docs/fullscreen-tag-design.md §1).\n */\n private _resolveTarget(): { element: Element | null; display: string } {\n const target = this.target;\n if (target === \"self\") {\n return { element: this, display: \"block\" };\n }\n if (target !== \"\") {\n const scope = this.getRootNode() as Document | ShadowRoot;\n return { element: this._safeQuery(scope, target), display: \"none\" };\n }\n const child = this.firstElementChild;\n if (child) {\n return { element: child, display: \"contents\" };\n }\n return { element: this, display: \"block\" };\n }\n\n private _safeQuery(scope: Document | ShadowRoot, selector: string): Element | null {\n try {\n return scope.querySelector(selector);\n } catch {\n return null;\n }\n }\n\n /**\n * Layers the Picture-in-Picture-specific `tagName === \"VIDEO\"` check on top\n * of `_resolveTarget()` (docs/picture-in-picture-tag-design.md §2). A\n * resolved-but-wrong-tag element is treated as unresolved (`element: null`)\n * so it flows into the same \"target not found\" failure path as Fullscreen's\n * missing-target case — never-throw, no exception escapes.\n */\n private _resolveVideoTarget(): { element: HTMLVideoElement | null; display: string } {\n const { element, display } = this._resolveTarget();\n if (element !== null && element.tagName !== \"VIDEO\") {\n return { element: null, display };\n }\n return { element: element as HTMLVideoElement | null, display };\n }\n\n private _observe(): void {\n const { element, display } = this._resolveVideoTarget();\n this.style.display = display;\n this._connectedCallbackPromise = this._core.observe(element);\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\n this._observe();\n }\n\n // dispose() publishes `active: false` when it was true (timing contract §22):\n // out of the document this element hears no leavepictureinpicture. The small\n // window is not closed here; the next connectedCallback re-reads the truth\n // through _observe().\n disconnectedCallback(): void {\n this._core.dispose();\n }\n\n attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void {\n if (oldValue === newValue) return;\n if (!this.isConnected) return;\n this._observe();\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/define-element.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n/**\n * One copy of each package on a page (docs/timing-and-firing-contract.md §24). The first copy the\n * page evaluates defines the tags and a second one does nothing, so a copy that finds its tag defined\n * by another copy of the package — not its class, not a subclass of it, not the same version — warns\n * `[wcs/package-twice]` once per registry, naming both versions. The classes it defines carry\n * `\"<package>@<version>\"` under `Symbol.for(\"wcstack.package\")`; a class without it is named\n * \"another copy of <package> that does not name its version\" (an older copy, or one loaded through\n * an entry that does not stamp).\n */\n\n/** The static a class defined through this helper carries: `\"@wcstack/fetch@<version>\"`. */\nexport const PACKAGE_STAMP: unique symbol = Symbol.for(\"wcstack.package\");\n\ntype Stamped = { [PACKAGE_STAMP]?: string };\n\n/** The registries this copy warned about: one warning per package per registry. */\nconst warned = new WeakSet<CustomElementRegistry>();\n\n/**\n * Marks `cls` as defined by `pkg` (`\"@wcstack/fetch@<version>\"`). A subclass inherits the mark, and\n * `defineProperty` writes it even where a parent's mark is read-only.\n */\nexport function stampPackage(cls: CustomElementConstructor, pkg: string): void {\n Object.defineProperty(cls, PACKAGE_STAMP, { value: pkg, configurable: true });\n}\n\n/**\n * Warns when `tag` is defined as `existing` by another copy of the package `pkg` names: `existing`\n * is neither `own` nor a subclass of it (omit `own` when the copy has no class to compare with), and\n * carries another version or none. Once per registry.\n */\nexport function warnIfAnotherCopy(\n registry: CustomElementRegistry,\n tag: string,\n existing: CustomElementConstructor,\n own: CustomElementConstructor | undefined,\n pkg: string,\n): void {\n if (own !== undefined && (existing === own || existing.prototype instanceof own)) return;\n const theirs = (existing as Stamped)[PACKAGE_STAMP];\n if (theirs === pkg || warned.has(registry)) return;\n warned.add(registry);\n const name = pkg.slice(0, pkg.lastIndexOf(\"@\"));\n console.warn(\n `[${name}] [wcs/package-twice] <${tag}> is already defined by ` +\n `${theirs ?? `another copy of ${name} that does not name its version`}; ` +\n `this copy, ${pkg}, does nothing. Load each package once.`,\n );\n}\n\n/**\n * Defines each `[tag, class]` in `registry` unless the tag is already defined, stamping the class\n * with `pkg` (`\"@wcstack/fetch@<version>\"`). A tag another copy of the package defined first is left\n * as it is, with the warning above.\n */\nexport function defineElements(\n registry: CustomElementRegistry,\n pkg: string,\n definitions: readonly (readonly [tag: string, cls: CustomElementConstructor])[],\n): void {\n for (const [tag, cls] of definitions) {\n const existing = registry.get(tag);\n if (existing === undefined) {\n stampPackage(cls, pkg);\n registry.define(tag, cls);\n } else {\n warnIfAnotherCopy(registry, tag, existing, cls, pkg);\n }\n }\n}\n","import pkg from \"../package.json\" with { type: \"json\" };\nimport { WcsPip } from \"./components/Pip.js\";\nimport { config } from \"./config.js\";\nimport { defineElements } from \"./protocol/defineElement.js\";\n\n/**\n * Register this package's tags. Pass a scoped `CustomElementRegistry` to define\n * them for a single shadow tree -- scoped registries do not inherit the global\n * one, so a tree using one needs its own definitions.\n */\nexport function registerComponents(registry: CustomElementRegistry = customElements): void {\n defineElements(registry, `${pkg.name}@${pkg.version}`, [\n [config.tagNames.pip, WcsPip],\n ]);\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapPip(userConfig?: IWritableConfig, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n"],"names":["config","tagNames","pip","POLICY_CONTROLLED","Set","WCS_PICTURE_IN_PICTURE_ERROR_CODE","derivePictureInPictureErrorInfo","error","kind","message","String","messageOf","code","phase","recoverable","name","PipCore","EventTarget","static","protocol","version","properties","event","semantics","getter","e","detail","active","commands","async","_target","_active","_error","_errorInfo","_video","_gen","_supportedPublished","_ready","Promise","resolve","constructor","target","super","this","ready","errorInfo","supported","feature","g","globalThis","isSecureContext","has","policy","document","permissionsPolicy","featurePolicy","undefined","allowsFeature","features","includes","featureUnavailable","pictureInPictureEnabled","HTMLVideoElement","prototype","requestPictureInPicture","observe","element","_publishSupported","_detach","addEventListener","_onEnter","_onLeave","_syncActive","dispose","_setActive","gen","tagName","_setError","fn","_requestPictureInPictureFn","call","exitPictureInPicture","_pictureInPictureElement","_exitPictureInPictureFn","el","d","bind","pictureInPictureElement","isActive","removeEventListener","dispatchEvent","CustomEvent","bubbles","_commitErrorInfo","info","hasAccessorOnPrototype","proto","Object","getPrototypeOf","descriptor","getOwnPropertyDescriptor","get","set","toldObjectAttribute","WeakSet","warnObjectAttribute","value","add","tag","localName","console","warn","initialAttributes","WeakMap","reflectAttribute","initial","byName","Map","getAttribute","initialAttribute","removeAttribute","setAttribute","writeAttribute","WcsPip","HTMLElement","wcBindable","inputs","attribute","_core","_connectedCallbackPromise","_internals","_initInternals","_wireStates","debugStates","states","attachInternals","internals","delete","map","toStates","entries","debug","hasAttribute","on","toggleAttribute","connectedCallbackPromise","_resolveVideoTarget","_resolveTarget","display","scope","getRootNode","_safeQuery","child","firstElementChild","selector","querySelector","_observe","style","connectedCallback","declaration","input","toLowerCase","startsWith","hasOwnProperty","record","upgradeProperties","disconnectedCallback","attributeChangedCallback","_name","oldValue","newValue","isConnected","PACKAGE_STAMP","Symbol","for","warned","stampPackage","cls","pkg","defineProperty","configurable","warnIfAnotherCopy","registry","existing","own","theirs","slice","lastIndexOf","registerComponents","customElements","definitions","define","defineElements"],"mappings":"AAQA,MA0BaA,EA1BoB,CAC/BC,SAAU,CACRC,IAAK,2DCoJT,MAAMC,EAAoB,IAAIC,IAAI,CAChC,SAAU,aAAc,cAAe,OAAQ,iBAAkB,kBACjE,mBAAoB,iBAAkB,gBAAiB,YAAa,eACpE,uBAAwB,kBAAmB,aAAc,qBAAsB,cC5I1E,MAAMC,EAEQ,qBAFRA,EAIM,mBAJNA,EAMC,cANDA,EAQD,YAeN,SAAUC,EAAgCC,EAAgBC,GAC9D,MAAMC,EAbR,S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,IAAWP,GAAOH,EAAO5H,IAAImI,GAAW,OAC5CP,EAAOpE,IAAI2E,GACX,MAAMvK,EAAOmK,EAAIQ,MAAM,EAAGR,EAAIS,YAAY,MAC1C7E,QAAQC,KACN,IAAIhG,2BAA8B6F,4BAC/B6E,GAAU,mBAAmB1K,kDAClBmK,2CAElB,CC5CM,SAAUU,EAAmBN,EAAkCO,0BDoDnEP,EACAJ,EACAY,GAEA,IAAK,MAAOlF,EAAKqE,KAAQa,EAAa,CACpC,MAAMP,EAAWD,EAASjF,IAAIO,QACbpD,IAAb+H,GACFP,EAAaC,EAAKC,GAClBI,EAASS,OAAOnF,EAAKqE,IAErBI,EAAkBC,EAAU1E,EAAK2E,EAAUN,EAAKC,EAEpD,CACF,CChEEc,CAAeV,EAAU,GAAGJ,KAAYA,IAAe,CACrD,CAAClL,EAAOC,SAASC,IAAKyH,IAE1B,CCVM,IAAqD2D,EAIzDM,EAAmBN"}
package/dist/index.d.ts CHANGED
@@ -67,7 +67,9 @@ interface IWritableConfig {
67
67
  * `wcBindable.properties` with change events: `wcs-pip:change` / `:error` /
68
68
  * `:error-info-changed`), so a wc-bindable binding core delivers a request/exit
69
69
  * failure. `errorInfo` is the additive serializable failure taxonomy derived
70
- * from `error` (README "Output state").
70
+ * from `error` (README "Output state"). `supported`
71
+ * (`wcs-pip:supported-changed`) says whether this page can use
72
+ * Picture-in-Picture at all.
71
73
  *
72
74
  * @example
73
75
  * ```typescript
@@ -80,10 +82,12 @@ interface WcsPipCoreValues {
80
82
  error: any;
81
83
  /** Additive failure taxonomy derived from `error` (stable code / phase / recoverable). */
82
84
  errorInfo: WcsIoErrorInfo | null;
85
+ /** Whether this page can use Picture-in-Picture (API present, not forbidden by a policy). */
86
+ supported: boolean;
83
87
  }
84
88
  /**
85
89
  * Value types for the Shell (`<wcs-pip>`) — identical value surface to the
86
- * Core (`active` / `error` / `errorInfo` all observable). The Shell adds the
90
+ * Core (`active` / `error` / `errorInfo` / `supported` all observable). The Shell adds the
87
91
  * `target` input (attribute-mirrored) and no additional observable
88
92
  * properties.
89
93
  */
@@ -127,6 +131,7 @@ declare class PipCore extends EventTarget {
127
131
  private _errorInfo;
128
132
  private _video;
129
133
  private _gen;
134
+ private _supportedPublished;
130
135
  private _ready;
131
136
  constructor(target?: EventTarget);
132
137
  get ready(): Promise<void>;
@@ -139,12 +144,24 @@ declare class PipCore extends EventTarget {
139
144
  * value shape is unchanged.
140
145
  */
141
146
  get errorInfo(): WcsIoErrorInfo | null;
147
+ /**
148
+ * Whether this page can use Picture-in-Picture right now: the document says it
149
+ * is enabled, a `<video>` has `requestPictureInPicture()`, and no
150
+ * Permissions-Policy (`picture-in-picture`: the server's header, an `<iframe>`
151
+ * whose `allow` turns it off) forbids it. Probed at call time, never cached.
152
+ * It does not say that a request will succeed (that still needs a user gesture
153
+ * and a video that can be shown, and a `<video disablepictureinpicture>`
154
+ * refuses). Firefox has no Picture-in-Picture API for pages, so this is
155
+ * `false` there. A wc-bindable output (event `wcs-pip:supported-changed`).
156
+ */
157
+ get supported(): boolean;
142
158
  /**
143
159
  * (Re-)subscribe to `enterpictureinpicture`/`leavepictureinpicture` on
144
160
  * `element` (the Shell's resolved `<video>` target). Idempotent when called
145
161
  * again with the same element; re-wires the listeners when the element
146
162
  * changes (e.g. the `target` attribute was changed), detaching from the
147
- * previous element first so no stale listener lingers.
163
+ * previous element first so no stale listener lingers. Also publishes
164
+ * `supported` when it differs from the last value dispatched.
148
165
  */
149
166
  observe(element: HTMLVideoElement | null): Promise<void>;
150
167
  dispose(): void;
@@ -169,6 +186,7 @@ declare class PipCore extends EventTarget {
169
186
  private _onLeave;
170
187
  private _syncActive;
171
188
  private _detach;
189
+ private _publishSupported;
172
190
  private _setActive;
173
191
  private _setError;
174
192
  private _commitErrorInfo;
@@ -208,6 +226,7 @@ declare class WcsPip extends HTMLElement {
208
226
  get active(): boolean;
209
227
  get error(): any;
210
228
  get errorInfo(): WcsIoErrorInfo | null;
229
+ get supported(): boolean;
211
230
  requestPictureInPicture(): Promise<void>;
212
231
  exitPictureInPicture(): Promise<void>;
213
232
  /**
package/dist/index.esm.js CHANGED
@@ -58,7 +58,43 @@ function setConfig(partialConfig) {
58
58
  frozenConfig = null;
59
59
  }
60
60
 
61
- var pkg = {"name":"@wcstack/picture-in-picture","version":"4.24.1"};
61
+ var pkg = {"name":"@wcstack/picture-in-picture","version":"4.25.0"};
62
+
63
+ // ===========================================================================
64
+ // AUTO-GENERATED FILE - DO NOT EDIT.
65
+ // Generated from /io-core/platform-capability.ts by scripts/sync-io-core.mjs.
66
+ // Run `node scripts/sync-io-core.mjs` after editing the source.
67
+ // ===========================================================================
68
+ /**
69
+ * Permissions-Policy が制御する機能。permission 名と同じ文字列と、permission の無い機能
70
+ * (`fullscreen`・`picture-in-picture`・`web-share`: 要素が「このページで使えるか」を言うために聞く)。
71
+ */
72
+ const POLICY_CONTROLLED = new Set([
73
+ "camera", "microphone", "geolocation", "midi", "clipboard-read", "clipboard-write",
74
+ "screen-wake-lock", "idle-detection", "accelerometer", "gyroscope", "magnetometer",
75
+ "ambient-light-sensor", "display-capture", "fullscreen", "picture-in-picture", "web-share",
76
+ ]);
77
+ function featureUnavailable(feature) {
78
+ const g = globalThis;
79
+ if (g.isSecureContext === false)
80
+ return "insecure-context";
81
+ if (!POLICY_CONTROLLED.has(feature))
82
+ return null;
83
+ const policy = g.document?.permissionsPolicy ?? g.document?.featurePolicy;
84
+ if (policy === undefined || typeof policy.allowsFeature !== "function")
85
+ return null;
86
+ try {
87
+ // このブラウザのポリシーが知らない名前は聞かない: Chromium は知らない名前の allowsFeature に
88
+ // false を返したうえでコンソールに「Unrecognized feature」を出す(フラグの無い
89
+ // `ambient-light-sensor`、デスクトップの `web-share`)。知らない機能は切られてもいない。
90
+ if (typeof policy.features === "function" && !policy.features().includes(feature))
91
+ return null;
92
+ return policy.allowsFeature(feature) ? null : "policy-blocked";
93
+ }
94
+ catch {
95
+ return null;
96
+ }
97
+ }
62
98
 
63
99
  /**
64
100
  * pictureInPictureCapabilities.ts
@@ -151,6 +187,11 @@ class PipCore extends EventTarget {
151
187
  // drives a referenced `<video>`, not a competing operation (fullscreen と同型)。
152
188
  { name: "error", event: "wcs-pip:error", semantics: "state" },
153
189
  { name: "errorInfo", event: "wcs-pip:error-info-changed", semantics: "state" },
190
+ // Whether this page can use Picture-in-Picture (the API is there and no
191
+ // Permissions-Policy forbids it). Computed at call time; the event carries
192
+ // the boolean and fires from observe() when it differs from the last value
193
+ // dispatched.
194
+ { name: "supported", event: "wcs-pip:supported-changed", semantics: "state" },
154
195
  ],
155
196
  commands: [
156
197
  { name: "requestPictureInPicture", async: true },
@@ -168,6 +209,9 @@ class PipCore extends EventTarget {
168
209
  // and each async command start. A completion that lands after dispose() (or
169
210
  // after a superseding call) is stale and MUST NOT write state.
170
211
  _gen = 0;
212
+ // `supported` as last dispatched (never the value itself — the getter probes at
213
+ // call time). Starts at false, so observe() announces a page that can use it.
214
+ _supportedPublished = false;
171
215
  // SSR (§3.8): no asynchronous probe to await, so readiness is immediate.
172
216
  _ready = Promise.resolve();
173
217
  constructor(target) {
@@ -192,15 +236,39 @@ class PipCore extends EventTarget {
192
236
  get errorInfo() {
193
237
  return this._errorInfo;
194
238
  }
239
+ /**
240
+ * Whether this page can use Picture-in-Picture right now: the document says it
241
+ * is enabled, a `<video>` has `requestPictureInPicture()`, and no
242
+ * Permissions-Policy (`picture-in-picture`: the server's header, an `<iframe>`
243
+ * whose `allow` turns it off) forbids it. Probed at call time, never cached.
244
+ * It does not say that a request will succeed (that still needs a user gesture
245
+ * and a video that can be shown, and a `<video disablepictureinpicture>`
246
+ * refuses). Firefox has no Picture-in-Picture API for pages, so this is
247
+ * `false` there. A wc-bindable output (event `wcs-pip:supported-changed`).
248
+ */
249
+ get supported() {
250
+ // The policy is asked first, and `pictureInPictureEnabled` is read only when
251
+ // it did not forbid: Chromium logs a console error for merely reading it in a
252
+ // document the policy forbids. Only "policy-blocked" decides here:
253
+ // Picture-in-Picture does not need a secure context (a plain http: page can
254
+ // use it), so "insecure-context" is not a reason — `pictureInPictureEnabled`,
255
+ // which follows the policy itself, gives the answer there.
256
+ if (featureUnavailable("picture-in-picture") === "policy-blocked")
257
+ return false;
258
+ return document.pictureInPictureEnabled === true
259
+ && typeof HTMLVideoElement.prototype.requestPictureInPicture === "function";
260
+ }
195
261
  // --- Lifecycle (§3.5) ---
196
262
  /**
197
263
  * (Re-)subscribe to `enterpictureinpicture`/`leavepictureinpicture` on
198
264
  * `element` (the Shell's resolved `<video>` target). Idempotent when called
199
265
  * again with the same element; re-wires the listeners when the element
200
266
  * changes (e.g. the `target` attribute was changed), detaching from the
201
- * previous element first so no stale listener lingers.
267
+ * previous element first so no stale listener lingers. Also publishes
268
+ * `supported` when it differs from the last value dispatched.
202
269
  */
203
270
  observe(element) {
271
+ this._publishSupported();
204
272
  if (this._video === element) {
205
273
  return this._ready;
206
274
  }
@@ -217,6 +285,12 @@ class PipCore extends EventTarget {
217
285
  this._gen++;
218
286
  this._detach();
219
287
  this._video = null;
288
+ // A disposed Core hears no leavepictureinpicture, so it can no longer vouch
289
+ // for `active`: publish false through the normal setter (timing contract §22
290
+ // — a disconnect publishes what it changes). The small window is not closed
291
+ // here; observe() re-reads the truth — publishing true again — on the next
292
+ // connect.
293
+ this._setActive(false);
220
294
  }
221
295
  // --- Commands (§3.6 never-throw) ---
222
296
  /**
@@ -332,6 +406,20 @@ class PipCore extends EventTarget {
332
406
  }
333
407
  }
334
408
  // --- State setters with event dispatch (§3.3 same-value guard) ---
409
+ // `supported` is probed at call time, so there is no stored value to set: this
410
+ // dispatches the current one when it differs from the last one dispatched
411
+ // (same-value guard). A state binding reads the property when it attaches; the
412
+ // event is for every other listener.
413
+ _publishSupported() {
414
+ const supported = this.supported;
415
+ if (this._supportedPublished === supported)
416
+ return;
417
+ this._supportedPublished = supported;
418
+ this._target.dispatchEvent(new CustomEvent("wcs-pip:supported-changed", {
419
+ detail: supported,
420
+ bubbles: true,
421
+ }));
422
+ }
335
423
  _setActive(active) {
336
424
  if (this._active === active)
337
425
  return;
@@ -593,6 +681,12 @@ class WcsPip extends HTMLElement {
593
681
  get errorInfo() {
594
682
  return this._core.errorInfo;
595
683
  }
684
+ // Whether this page can use Picture-in-Picture — probed at call time by the
685
+ // Core (never cached), so a state binding that reads it when it attaches gets
686
+ // the right value without waiting for `wcs-pip:supported-changed`.
687
+ get supported() {
688
+ return this._core.supported;
689
+ }
596
690
  // --- Commands ---
597
691
  async requestPictureInPicture() {
598
692
  const { element } = this._resolveVideoTarget();
@@ -656,6 +750,10 @@ class WcsPip extends HTMLElement {
656
750
  upgradeProperties(this);
657
751
  this._observe();
658
752
  }
753
+ // dispose() publishes `active: false` when it was true (timing contract §22):
754
+ // out of the document this element hears no leavepictureinpicture. The small
755
+ // window is not closed here; the next connectedCallback re-reads the truth
756
+ // through _observe().
659
757
  disconnectedCallback() {
660
758
  this._core.dispose();
661
759
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../../src/config.ts","../../src/core/pictureInPictureCapabilities.ts","../../src/core/PipCore.ts","../../src/protocol/upgradeProperties.ts","../../src/protocol/inputAttribute.ts","../../src/components/Pip.ts","../../src/protocol/defineElement.ts","../../src/registerComponents.ts","../../src/bootstrapPip.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n pip: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n pip: \"wcs-pip\",\n },\n};\n\nfunction deepFreeze<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n Object.freeze(obj);\n for (const key of Object.keys(obj)) {\n deepFreeze((obj as Record<string, unknown>)[key]);\n }\n return obj;\n}\n\nfunction deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n const clone: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n clone[key] = deepClone((obj as Record<string, unknown>)[key]);\n }\n return clone as T;\n}\n\nlet frozenConfig: IConfig | null = null;\n\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\n/** A misspelt option would otherwise do nothing: `bootstrapPip` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/picture-in-picture] bootstrapPip: \"${key}\" is not one of its options, or not of the option's type.`);\n}\n\n/**\n * Applies the options given; an undefined value is left out. An option this package does not\n * have, a value of another type than its default (null, or an array for an object, included) or\n * a tag name it does not define throws, and then nothing is applied.\n */\nexport function setConfig(partialConfig: IWritableConfig): void {\n const options = _config as unknown as Record<string, unknown>;\n const tags = _config.tagNames as Record<string, string>;\n const given = Object.entries(partialConfig).filter(([, value]) => value !== undefined);\n const givenTags = Object.entries(partialConfig.tagNames ?? {}).filter(([, tag]) => tag !== undefined);\n for (const [key, value] of given) {\n const current = options[key];\n if (!Object.hasOwn(options, key) || value === null || typeof value !== typeof current || Array.isArray(value) !== Array.isArray(current)) {\n invalid(key);\n }\n }\n for (const [name, tag] of givenTags) {\n if (!Object.hasOwn(tags, name) || typeof tag !== \"string\") invalid(`tagNames.${name}`);\n }\n for (const [name, tag] of givenTags) tags[name] = tag as string;\n frozenConfig = null;\n}\n","/**\n * pictureInPictureCapabilities.ts\n *\n * Picture-in-Picture node 固有の error code(taxonomy)と derivation。汎用の error\n * info 型は `./platformCapability.js`(/io-core/ から copy-distribution される生成\n * ファイル)から import する。Picture-in-Picture は referenced `<video>` を操作する\n * ノードで競合 operation を持たないため lane は無く、error taxonomy(errorInfo)のみを\n * 採用する(fullscreen と同型)。\n *\n * `_setError` は合成 `{ message }`(target が `<video>` に解決しない / API 非対応)と\n * caught 例外(`NotAllowedError` = user gesture 外の requestPictureInPicture 拒否等)を\n * 混在受理する。呼出側が明示 `kind` を渡して合成側を曖昧さ無く分類し、caught は `.name`\n * で分類する(fullscreen / storage / screen-orientation と同じ discriminator 方式)。\n */\n\nimport type { WcsIoErrorInfo } from \"./platformCapability.js\";\n\n/** 明示 kind discriminator(合成エラーの呼出側が渡す)。 */\nexport type PictureInPictureErrorKind = \"capability-missing\" | \"invalid-argument\";\n\n/** 安定した Picture-in-Picture error code(taxonomy)。値は公開キーとして固定。 */\nexport const WCS_PICTURE_IN_PICTURE_ERROR_CODE = {\n /** Picture-in-Picture API 非対応。 */\n CapabilityMissing: \"capability-missing\",\n /** target が `<video>` に解決しない等の入力不備。 */\n InvalidArgument: \"invalid-argument\",\n /** `NotAllowedError` / `TypeError` — user gesture 外での要求拒否。 */\n NotAllowed: \"not-allowed\",\n /** その他の caught 例外。 */\n PipError: \"pip-error\",\n} as const;\n\nfunction messageOf(error: unknown): string {\n return typeof (error as { message?: unknown } | null)?.message === \"string\"\n ? (error as { message: string }).message\n : String(error);\n}\n\n/**\n * Picture-in-Picture の失敗を serializable な error taxonomy に写す。`kind` は合成\n * エラーの呼出側が渡す明示 discriminator(`capability-missing` / `invalid-argument`)。\n * 未指定は caught 例外を意味し、`.name` で分類する。`NotAllowedError` / `TypeError` は\n * user gesture 内で再試行すれば成功しうるため recoverable=true。\n */\nexport function derivePictureInPictureErrorInfo(error: unknown, kind?: PictureInPictureErrorKind): WcsIoErrorInfo {\n const message = messageOf(error);\n if (kind === \"capability-missing\") {\n return { code: WCS_PICTURE_IN_PICTURE_ERROR_CODE.CapabilityMissing, phase: \"probe\", recoverable: false, message };\n }\n if (kind === \"invalid-argument\") {\n return { code: WCS_PICTURE_IN_PICTURE_ERROR_CODE.InvalidArgument, phase: \"start\", recoverable: false, message };\n }\n const name = (error as { name?: unknown } | null)?.name;\n if (name === \"NotAllowedError\" || name === \"TypeError\") {\n return { code: WCS_PICTURE_IN_PICTURE_ERROR_CODE.NotAllowed, phase: \"execute\", recoverable: true, message };\n }\n return { code: WCS_PICTURE_IN_PICTURE_ERROR_CODE.PipError, phase: \"execute\", recoverable: false, message };\n}\n","import { IWcBindable } from \"../types.js\";\nimport { WcsIoErrorInfo } from \"./platformCapability.js\";\nimport { derivePictureInPictureErrorInfo, PictureInPictureErrorKind } from \"./pictureInPictureCapabilities.js\";\n\n/**\n * Headless Picture-in-Picture primitive. A thin, framework-agnostic wrapper\n * around the classic Picture-in-Picture API\n * (`HTMLVideoElement.requestPictureInPicture()` / `document.exitPictureInPicture()` /\n * `document.pictureInPictureElement`) exposed through the wc-bindable protocol.\n *\n * This Core follows the same basic pattern as `@wcstack/fullscreen`'s\n * `FullscreenCore` (docs/fullscreen-tag-design.md): target resolution is done\n * by the Shell (this Core receives the resolved element at call time), API\n * resolution is call-time/non-cached, `_gen` is a single Core-level generation\n * guard, and `error` is a simple single field (no permission-style 4-value\n * state). See docs/picture-in-picture-tag-design.md for the differences from\n * Fullscreen:\n *\n * - **§2 target constraint**: the resolved target MUST be a `<video>` element.\n * Picture-in-Picture is only defined as an instance method of\n * `HTMLVideoElement` — unlike Fullscreen, which any `Element` supports. A\n * non-`<video>` target is a never-throw failure: it is treated the same as\n * an unresolved target and reported via `error`.\n * - **§3 event subscription target**: `enterpictureinpicture` /\n * `leavepictureinpicture` fire on the `<video>` element itself, not on\n * `document` (the reverse of Fullscreen's `document`-level\n * `fullscreenchange`). The Core attaches/detaches these listeners directly\n * on the resolved `<video>` element, re-wiring them whenever the target is\n * re-resolved (e.g. the Shell's `target` attribute changes).\n */\nexport class PipCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"active\", event: \"wcs-pip:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.active },\n // `error` / `errorInfo` are observable failure outputs. Historically `error`\n // was an imperative getter with no event; both are now bindable (event-backed)\n // so `data-wcs` / bind() can observe a request/exit failure. `errorInfo` is the\n // additive serializable taxonomy (stable code / phase / recoverable) derived\n // from `error`; the `error` value shape is unchanged. No lane — Picture-in-Picture\n // drives a referenced `<video>`, not a competing operation (fullscreen と同型)。\n { name: \"error\", event: \"wcs-pip:error\", semantics: \"state\" },\n { name: \"errorInfo\", event: \"wcs-pip:error-info-changed\", semantics: \"state\" },\n ],\n commands: [\n { name: \"requestPictureInPicture\", async: true },\n { name: \"exitPictureInPicture\", async: true },\n ],\n };\n\n private _target: EventTarget;\n private _active: boolean = false;\n private _error: any = null;\n private _errorInfo: WcsIoErrorInfo | null = null;\n\n // The <video> element the Core currently subscribes to for\n // enterpictureinpicture/leavepictureinpicture (null when unresolved/torn down).\n private _video: HTMLVideoElement | null = null;\n\n // Generation guard (§3.4 / fullscreen-tag-design.md §6): bumped on dispose()\n // and each async command start. A completion that lands after dispose() (or\n // after a superseding call) is stale and MUST NOT write state.\n private _gen = 0;\n\n // SSR (§3.8): no asynchronous probe to await, so readiness is immediate.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n get ready(): Promise<void> {\n return this._ready;\n }\n\n get active(): boolean {\n return this._active;\n }\n\n get error(): any {\n return this._error;\n }\n\n /**\n * The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /\n * `recoverable`), or null. Additive wc-bindable property (event\n * `wcs-pip:error-info-changed`), derived from `error`; the existing `error`\n * value shape is unchanged.\n */\n get errorInfo(): WcsIoErrorInfo | null {\n return this._errorInfo;\n }\n\n // --- Lifecycle (§3.5) ---\n\n /**\n * (Re-)subscribe to `enterpictureinpicture`/`leavepictureinpicture` on\n * `element` (the Shell's resolved `<video>` target). Idempotent when called\n * again with the same element; re-wires the listeners when the element\n * changes (e.g. the `target` attribute was changed), detaching from the\n * previous element first so no stale listener lingers.\n */\n observe(element: HTMLVideoElement | null): Promise<void> {\n if (this._video === element) {\n return this._ready;\n }\n this._detach();\n this._video = element;\n if (element) {\n element.addEventListener(\"enterpictureinpicture\", this._onEnter);\n element.addEventListener(\"leavepictureinpicture\", this._onLeave);\n }\n this._syncActive();\n return this._ready;\n }\n\n dispose(): void {\n this._gen++;\n this._detach();\n this._video = null;\n }\n\n // --- Commands (§3.6 never-throw) ---\n\n /**\n * Request Picture-in-Picture for `element`. `element` must be a `<video>`\n * (checked before the gesture-context failure path, since a type mismatch is\n * an environment-independent, permanent error — docs/picture-in-picture-tag-design.md §2).\n * Never throws: all failures (wrong tag, unsupported API, gesture-context\n * rejection) are funneled into `error` and the returned promise resolves.\n */\n async requestPictureInPicture(element: HTMLVideoElement | null): Promise<void> {\n const gen = ++this._gen;\n if (!element || element.tagName !== \"VIDEO\") {\n // Distinct from \"API is not supported\" (below): the resolved target did\n // not satisfy the `<video>`-only constraint (wrong tag / unresolved).\n this._setError({ message: \"target must be a <video> element.\" }, \"invalid-argument\");\n return;\n }\n // Re-wire to `element` before issuing the platform call: a caller may\n // request a <video> different from the one last passed to observe() (e.g.\n // the Shell's target attribute pointed at nothing at connect time and the\n // matching <video> was only inserted later, so no attributeChangedCallback\n // ever re-resolved it). Without this, `_video` stays stale and\n // `_syncActive()` below (and future enter/leave events) would never\n // recognize `element` as this Core's target, leaving `active` permanently\n // wrong even though the request succeeded (mirrors\n // FullscreenCore.requestFullscreen()'s unconditional `this._resolvedTarget\n // = element` assignment — docs/fullscreen-tag-design.md §6).\n this.observe(element);\n const fn = this._requestPictureInPictureFn(element);\n if (!fn) {\n this._setError({ message: \"Picture-in-Picture API is not supported.\" }, \"capability-missing\");\n return;\n }\n try {\n await fn.call(element);\n if (gen !== this._gen) return; // stale\n this._setError(null);\n this._syncActive(); // belt-and-suspenders (mirrors FullscreenCore's _applyActive() on success)\n } catch (e: any) {\n if (gen !== this._gen) return; // stale\n this._setError(e); // e.g. NotAllowedError (gesture-context rejection)\n }\n }\n\n /**\n * Exit Picture-in-Picture. Mirrors FullscreenCore.exitFullscreen(): a\n * silent no-op (resolve, no error) when nothing is currently in\n * Picture-in-Picture — see fullscreen-tag-design.md §7.\n */\n async exitPictureInPicture(): Promise<void> {\n // no-op checks come BEFORE the generation bump: a call that does nothing\n // must not supersede an in-flight requestPictureInPicture() — bumping\n // first would make the pending request's settle handling stale and\n // silently swallow its error update (mirrors\n // FullscreenCore.exitFullscreen()).\n if (this._pictureInPictureElement() === null) return; // already not in PiP: silent no-op\n const fn = this._exitPictureInPictureFn();\n if (!fn) return; // unsupported: silent no-op (semantically already \"not in PiP\")\n const gen = ++this._gen;\n try {\n await fn();\n if (gen !== this._gen) return;\n this._setError(null);\n this._syncActive(); // belt-and-suspenders (mirrors FullscreenCore.exitFullscreen()'s success-path _applyActive()); covers a delayed/dropped leavepictureinpicture\n } catch (e: any) {\n if (gen !== this._gen) return;\n this._setError(e);\n }\n }\n\n // --- Internal: API resolution (call-time, never cached — §3.7) ---\n\n // Unlike FullscreenCore's _elementFullscreenFn(), a naive direct property\n // lookup (`e.requestPictureInPicture`, walking the prototype chain) here is\n // safe: it cannot recurse into the Shell's own command method,\n // because the resolved target is validated to be a <video> element (§2)\n // before this is called, and <wcs-pip> (the Shell) is never itself a\n // <video>. Fullscreen's own→Element.prototype two-step resolution guards\n // against `target=\"self\"`/no-target resolving to the Shell element, which\n // cannot happen here.\n private _requestPictureInPictureFn(el: HTMLVideoElement): (() => Promise<PictureInPictureWindow>) | undefined {\n const e = el as any;\n return typeof e.requestPictureInPicture === \"function\" ? e.requestPictureInPicture : undefined;\n }\n\n private _exitPictureInPictureFn(): (() => Promise<void>) | undefined {\n const d = document as any;\n return typeof d.exitPictureInPicture === \"function\" ? d.exitPictureInPicture.bind(document) : undefined;\n }\n\n private _pictureInPictureElement(): Element | null {\n const d = document as any;\n return d.pictureInPictureElement ?? null;\n }\n\n // --- Internal: event wiring ---\n\n private _onEnter = (): void => {\n this._syncActive();\n };\n\n private _onLeave = (): void => {\n this._syncActive();\n };\n\n private _syncActive(): void {\n const isActive = this._video !== null && this._pictureInPictureElement() === this._video;\n this._setActive(isActive);\n }\n\n private _detach(): void {\n if (this._video) {\n this._video.removeEventListener(\"enterpictureinpicture\", this._onEnter);\n this._video.removeEventListener(\"leavepictureinpicture\", this._onLeave);\n }\n }\n\n // --- State setters with event dispatch (§3.3 same-value guard) ---\n\n private _setActive(active: boolean): void {\n if (this._active === active) return;\n this._active = active;\n this._target.dispatchEvent(new CustomEvent(\"wcs-pip:change\", {\n detail: { active },\n bubbles: true,\n }));\n }\n\n // `kind` is an explicit taxonomy discriminator passed only from the synthetic\n // error sites (unsupported / non-<video> target); caught exceptions pass no kind\n // and are classified by their `.name`. Both `error` and the additive `errorInfo`\n // are now event-backed so a request/exit failure is observable via bind().\n private _setError(error: any, kind?: PictureInPictureErrorKind): void {\n // Same-value guard on reference: each failure builds a fresh object and the\n // clear path passes the literal null, so this only suppresses redundant\n // null→null (a successful request/exit clearing an already-null error).\n if (this._error === error) return;\n this._error = error;\n // Keep the additive errorInfo taxonomy in sync; fire it before the `error`\n // event so an observer of both sees the classification first (io-node family).\n this._commitErrorInfo(error === null ? null : derivePictureInPictureErrorInfo(error, kind));\n this._target.dispatchEvent(new CustomEvent(\"wcs-pip:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n // Called only from _setError (already reference-guarded), so errorInfo\n // transitions exactly when error does — no separate guard needed here.\n private _commitErrorInfo(info: WcsIoErrorInfo | null): void {\n this._errorInfo = info;\n this._target.dispatchEvent(new CustomEvent(\"wcs-pip:error-info-changed\", {\n detail: info,\n bubbles: true,\n }));\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/upgrade-properties.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// custom element の property upgrade — `static wcBindable.inputs` に宣言した入力のうち、\n// 要素が upgrade される前に代入された own データプロパティを取り込み直す。\n//\n// なぜ必要か:\n// 未定義タグの要素は素の HTMLElement なので、`el.url = \"...\"` は own データプロパティを作る。\n// upgrade 後にクラスの accessor が prototype へ入っても own プロパティが優先されるため、\n// setter は二度と呼ばれず、値は要素へ届かないまま消える(エラーも警告も出ない)。\n// 常にプロパティ代入を行う framework(Angular の `[prop]`、Lit の `.prop=`、\n// Solid の `prop:`、Vue の `.prop` 修飾子)× 遅延定義(autoloader / CDN / code-split)で\n// 常態的に起きる。docs/architecture-hardening/13-framework-adapter-binding-constraints.md §1.2。\n//\n// 安全側の判定:\n// own プロパティがあっても、prototype チェーンに accessor が無ければ「シャドウ」ではなく\n// その own プロパティ自体が正規の格納先なので触らない(public class field を壊さない)。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/upgrade-properties.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/upgradeProperties.ts). Those copies are generated — do not edit them.\nimport { IWcBindable } from \"./wcBindable.js\";\n\nfunction hasAccessorOnPrototype(target: object, name: string): boolean {\n let proto = Object.getPrototypeOf(target);\n while (proto !== null) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n if (descriptor !== undefined) {\n return typeof descriptor.get === \"function\" || typeof descriptor.set === \"function\";\n }\n proto = Object.getPrototypeOf(proto);\n }\n return false;\n}\n\n// 属性になってしまったオブジェクトの入力(`files=\"[object File]\"`)を、要素ごとに 1 回だけ言う。\n// React 19 は定義前の要素にプロパティが無いのでオブジェクトを属性に書き、Vue の `.attr` も\n// 書く。要素はその入力をプロパティでしか読まないので、何も受け取らず、何も言わなかった\n// (docs/seam-apps.md、fw-inventory)。\nconst toldObjectAttribute = new WeakSet<object>();\n\nfunction warnObjectAttribute(element: object, name: string, value: string): void {\n if (toldObjectAttribute.has(element)) return;\n toldObjectAttribute.add(element);\n const tag = (element as { localName?: string }).localName ?? \"element\";\n console.warn(\n `[wcs/input-as-attribute] <${tag}> has the attribute ${name}=\"${value}\": an object was written as an ` +\n `attribute, so the element did not receive it. A framework does that when the property is set before the ` +\n `element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, ` +\n `or assign the property through a ref (Vue: .prop). (Said once per element.)`,\n element,\n );\n}\n\n/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\n * - 値が `[object …]` の属性(属性に書かれてしまったオブジェクトの入力)は、要素ごとに 1 回警告する。\n */\nexport function upgradeProperties(element: object): void {\n const declaration = (element as { constructor?: { wcBindable?: IWcBindable } }).constructor?.wcBindable;\n const inputs = declaration?.inputs;\n if (inputs === undefined) return;\n const getAttribute = (element as { getAttribute?: (name: string) => string | null }).getAttribute;\n for (const input of inputs) {\n const name = input.name;\n const attribute = typeof getAttribute === \"function\" ? getAttribute.call(element, name.toLowerCase()) : null;\n if (attribute !== null && attribute.startsWith(\"[object \")) warnObjectAttribute(element, name, attribute);\n if (!Object.prototype.hasOwnProperty.call(element, name)) continue;\n if (!hasAccessorOnPrototype(element, name)) continue;\n const record = element as Record<string, unknown>;\n const value = record[name];\n delete record[name];\n record[name] = value;\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/input-attribute.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// 属性へ反映する wc-bindable 入力の producer 側(SPEC-extensions § Producer guidance for inputs の P1〜P3)。\n// 入力の setter は属性をこの 2 関数で書く。それで次が揃う:\n// - `undefined` は「値が無い」(P1): 属性を、この関数で最初に書く前の状態 — マークアップに書かれた値、\n// 無ければ属性なし(= その入力の文書化した既定値)— へ戻す。applier プロファイルを宣言する binder は\n// 値の後の `undefined` を書き(A2)、React 19 も書き、直接の代入でも届く。\n// - `null` はクリア(P2): 属性なし、つまり文書化した既定値。\n// - どちらも文字列 \"undefined\" / \"null\" として属性に入らない。\n//\n// 「最初に書く前」は、その最初の書き込みのときに読む(遅延)。upgrade 前に代入されたプロパティは\n// connectedCallback の upgradeProperties() が通し直すので、そのときにはパーサが書いた属性が揃っている。\n// 要素自身が setter を通さずに書いた属性は、最初の書き込みより前なら「最初の状態」に含まれる。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/input-attribute.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/inputAttribute.ts). Those copies are generated — do not edit them.\n\nconst initialAttributes = new WeakMap<Element, Map<string, string | null>>();\n\n/** The attribute as it stood before the first write through these helpers. */\nfunction initialAttribute(el: Element, name: string): string | null {\n let byName = initialAttributes.get(el);\n if (byName === undefined) {\n byName = new Map();\n initialAttributes.set(el, byName);\n }\n if (!byName.has(name)) byName.set(name, el.getAttribute(name));\n return byName.get(name) as string | null;\n}\n\nfunction writeAttribute(el: Element, name: string, value: string | null): void {\n if (value === null) el.removeAttribute(name);\n else el.setAttribute(name, value);\n}\n\n/**\n * A value attribute. `value` is written as `String(value)`; `null` removes the attribute;\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value === null ? null : String(value));\n}\n\n/**\n * A boolean attribute, present while `value` is truthy (`null` and `false` remove it);\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectBooleanAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value ? \"\" : null);\n}\n","import { IWcBindable } from \"../types.js\";\nimport { PipCore } from \"../core/PipCore.js\";\nimport { WcsIoErrorInfo } from \"../core/platformCapability.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute } from \"../protocol/inputAttribute.js\";\n\n/**\n * `<wcs-pip target=\"...\">` — declarative Picture-in-Picture control.\n *\n * Like `<wcs-fullscreen>` (docs/fullscreen-tag-design.md §0/§1), this Shell\n * does not operate on itself: it is a non-visible control tag that resolves a\n * `target` element and invokes Picture-in-Picture commands against it. The\n * `target` attribute resolves in the same 3 modes as `intersection`/`fullscreen`\n * (`self` / a selector / the first element child), reused verbatim from\n * `@wcstack/intersection`'s `_resolveTarget()`/`_safeQuery()`\n * (packages/intersection/src/components/Intersect.ts).\n *\n * Picture-in-Picture-specific difference (docs/picture-in-picture-tag-design.md\n * §2): the resolved target must be a `<video>` element. This Shell resolves the\n * DOM element and hands it to the Core; the Core performs the `tagName ===\n * \"VIDEO\"` validation (never-throw — a mismatch is treated as an unresolved\n * target and reported via `error`, not thrown).\n */\nexport class WcsPip extends HTMLElement {\n // SSR (§4.4): observe() completes synchronously, but the Shell still exposes\n // connectedCallbackPromise so the state binder can await it uniformly across\n // all IO nodes before snapshotting.\n static hasConnectedCallbackPromise = true;\n\n static observedAttributes = [\"target\"];\n\n static wcBindable: IWcBindable = {\n ...PipCore.wcBindable,\n inputs: [{ name: \"target\", attribute: \"target\" }],\n // Core の commands をそのまま継承(単一情報源)。fullscreen/intersection と同型。\n commands: PipCore.wcBindable.commands,\n };\n\n private _core: PipCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new PipCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-pip:change\": (d) => ({ active: d?.active === true }),\n });\n }\n\n // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of\n // wc-bindable (not a bind target); see README \"CSS styling with :state()\".\n // MUST NOT return the live CustomStateSet (that would let callers write\n // states from outside, defeating the point of :state() being read-only).\n get debugStates(): string[] {\n return this._internals ? [...this._internals.states] : [];\n }\n\n private _initInternals(): ElementInternals | null {\n // never-throw (docs/custom-state-reflection-design.md §3.1): attachInternals\n // is absent in happy-dom / older environments, and pre-125 Chromium rejects\n // non-dashed state names from states.add() (probed and discarded here).\n // Either case silently disables reflection — the component still works,\n // it just doesn't expose :state() selectors.\n try {\n if (typeof this.attachInternals !== \"function\") return null;\n const internals = this.attachInternals();\n internals.states.add(\"wcs-probe\");\n internals.states.delete(\"wcs-probe\");\n return internals;\n } catch {\n return null;\n }\n }\n\n private _wireStates(map: Record<string, (detail: any) => Record<string, boolean>>): void {\n if (this._internals === null) return;\n const states = this._internals.states;\n for (const [event, toStates] of Object.entries(map)) {\n this.addEventListener(event, (e) => {\n const debug = this.hasAttribute(\"debug-states\");\n for (const [name, on] of Object.entries(toStates((e as CustomEvent).detail))) {\n try {\n if (on) { states.add(name); } else { states.delete(name); }\n } catch { /* never-throw */ }\n if (debug) this.toggleAttribute(`data-wcs-state-${name}`, on);\n }\n });\n }\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Attribute accessors ---\n\n get target(): string {\n return this.getAttribute(\"target\") ?? \"\";\n }\n\n // Never lets setAttribute stringify null / undefined (an \"undefined\" selector\n // resolves nothing): `null` removes the attribute (the first-child default),\n // `undefined` restores the attribute the element started with (wc-bindable\n // producer guidance P1; React 19 and a direct assignment deliver it,\n // @wcstack/state does not).\n set target(value: string | null | undefined) {\n reflectAttribute(this, \"target\", value);\n }\n\n // --- Core delegated getters ---\n\n get active(): boolean {\n return this._core.active;\n }\n\n get error(): any {\n return this._core.error;\n }\n\n get errorInfo(): WcsIoErrorInfo | null {\n return this._core.errorInfo;\n }\n\n // --- Commands ---\n\n async requestPictureInPicture(): Promise<void> {\n const { element } = this._resolveVideoTarget();\n return this._core.requestPictureInPicture(element);\n }\n\n async exitPictureInPicture(): Promise<void> {\n return this._core.exitPictureInPicture();\n }\n\n // --- Internal ---\n\n /**\n * `_resolveTarget()`/`_safeQuery()` copied verbatim from `@wcstack/intersection`\n * (packages/intersection/src/components/Intersect.ts:243-267, 281-287) per the\n * fullscreen/picture-in-picture batch's shared target-resolution archetype\n * (docs/fullscreen-tag-design.md §1).\n */\n private _resolveTarget(): { element: Element | null; display: string } {\n const target = this.target;\n if (target === \"self\") {\n return { element: this, display: \"block\" };\n }\n if (target !== \"\") {\n const scope = this.getRootNode() as Document | ShadowRoot;\n return { element: this._safeQuery(scope, target), display: \"none\" };\n }\n const child = this.firstElementChild;\n if (child) {\n return { element: child, display: \"contents\" };\n }\n return { element: this, display: \"block\" };\n }\n\n private _safeQuery(scope: Document | ShadowRoot, selector: string): Element | null {\n try {\n return scope.querySelector(selector);\n } catch {\n return null;\n }\n }\n\n /**\n * Layers the Picture-in-Picture-specific `tagName === \"VIDEO\"` check on top\n * of `_resolveTarget()` (docs/picture-in-picture-tag-design.md §2). A\n * resolved-but-wrong-tag element is treated as unresolved (`element: null`)\n * so it flows into the same \"target not found\" failure path as Fullscreen's\n * missing-target case — never-throw, no exception escapes.\n */\n private _resolveVideoTarget(): { element: HTMLVideoElement | null; display: string } {\n const { element, display } = this._resolveTarget();\n if (element !== null && element.tagName !== \"VIDEO\") {\n return { element: null, display };\n }\n return { element: element as HTMLVideoElement | null, display };\n }\n\n private _observe(): void {\n const { element, display } = this._resolveVideoTarget();\n this.style.display = display;\n this._connectedCallbackPromise = this._core.observe(element);\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\n this._observe();\n }\n\n disconnectedCallback(): void {\n this._core.dispose();\n }\n\n attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void {\n if (oldValue === newValue) return;\n if (!this.isConnected) return;\n this._observe();\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/define-element.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n/**\n * One copy of each package on a page (docs/timing-and-firing-contract.md §24). The first copy the\n * page evaluates defines the tags and a second one does nothing, so a copy that finds its tag defined\n * by another copy of the package — not its class, not a subclass of it, not the same version — warns\n * `[wcs/package-twice]` once per registry, naming both versions. The classes it defines carry\n * `\"<package>@<version>\"` under `Symbol.for(\"wcstack.package\")`; a class without it is named\n * \"another copy of <package> that does not name its version\" (an older copy, or one loaded through\n * an entry that does not stamp).\n */\n\n/** The static a class defined through this helper carries: `\"@wcstack/fetch@<version>\"`. */\nexport const PACKAGE_STAMP: unique symbol = Symbol.for(\"wcstack.package\");\n\ntype Stamped = { [PACKAGE_STAMP]?: string };\n\n/** The registries this copy warned about: one warning per package per registry. */\nconst warned = new WeakSet<CustomElementRegistry>();\n\n/**\n * Marks `cls` as defined by `pkg` (`\"@wcstack/fetch@<version>\"`). A subclass inherits the mark, and\n * `defineProperty` writes it even where a parent's mark is read-only.\n */\nexport function stampPackage(cls: CustomElementConstructor, pkg: string): void {\n Object.defineProperty(cls, PACKAGE_STAMP, { value: pkg, configurable: true });\n}\n\n/**\n * Warns when `tag` is defined as `existing` by another copy of the package `pkg` names: `existing`\n * is neither `own` nor a subclass of it (omit `own` when the copy has no class to compare with), and\n * carries another version or none. Once per registry.\n */\nexport function warnIfAnotherCopy(\n registry: CustomElementRegistry,\n tag: string,\n existing: CustomElementConstructor,\n own: CustomElementConstructor | undefined,\n pkg: string,\n): void {\n if (own !== undefined && (existing === own || existing.prototype instanceof own)) return;\n const theirs = (existing as Stamped)[PACKAGE_STAMP];\n if (theirs === pkg || warned.has(registry)) return;\n warned.add(registry);\n const name = pkg.slice(0, pkg.lastIndexOf(\"@\"));\n console.warn(\n `[${name}] [wcs/package-twice] <${tag}> is already defined by ` +\n `${theirs ?? `another copy of ${name} that does not name its version`}; ` +\n `this copy, ${pkg}, does nothing. Load each package once.`,\n );\n}\n\n/**\n * Defines each `[tag, class]` in `registry` unless the tag is already defined, stamping the class\n * with `pkg` (`\"@wcstack/fetch@<version>\"`). A tag another copy of the package defined first is left\n * as it is, with the warning above.\n */\nexport function defineElements(\n registry: CustomElementRegistry,\n pkg: string,\n definitions: readonly (readonly [tag: string, cls: CustomElementConstructor])[],\n): void {\n for (const [tag, cls] of definitions) {\n const existing = registry.get(tag);\n if (existing === undefined) {\n stampPackage(cls, pkg);\n registry.define(tag, cls);\n } else {\n warnIfAnotherCopy(registry, tag, existing, cls, pkg);\n }\n }\n}\n","import pkg from \"../package.json\" with { type: \"json\" };\nimport { WcsPip } from \"./components/Pip.js\";\nimport { config } from \"./config.js\";\nimport { defineElements } from \"./protocol/defineElement.js\";\n\n/**\n * Register this package's tags. Pass a scoped `CustomElementRegistry` to define\n * them for a single shadow tree -- scoped registries do not inherit the global\n * one, so a tree using one needs its own definitions.\n */\nexport function registerComponents(registry: CustomElementRegistry = customElements): void {\n defineElements(registry, `${pkg.name}@${pkg.version}`, [\n [config.tagNames.pip, WcsPip],\n ]);\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapPip(userConfig?: IWritableConfig, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n"],"names":[],"mappings":"AAQA,MAAM,OAAO,GAAoB;AAC/B,IAAA,QAAQ,EAAE;AACR,QAAA,GAAG,EAAE,SAAS;AACf,KAAA;CACF;AAED,SAAS,UAAU,CAAI,GAAM,EAAA;AAC3B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAAG;AACvD,IAAA,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;IAClB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;AAClC,QAAA,UAAU,CAAE,GAA+B,CAAC,GAAG,CAAC,CAAC;IACnD;AACA,IAAA,OAAO,GAAG;AACZ;AAEA,SAAS,SAAS,CAAI,GAAM,EAAA;AAC1B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAAG;IACvD,MAAM,KAAK,GAA4B,EAAE;IACzC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAClC,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAAE,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B,QAA+B,EAC/B,GAAW,EACX,WAA+E,EAAA;IAE/E,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,WAAW,EAAE;QACpC,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC;AAClC,QAAA,IAAI,QAAQ,KAAK,SAAS,EAAE;AAC1B,YAAA,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC;AACtB,YAAA,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC;QAC3B;aAAO;YACL,iBAAiB,CAAC,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,CAAC;QACtD;IACF;AACF;;ACtEA;;;;AAIG;AACG,SAAU,kBAAkB,CAAC,QAAA,GAAkC,cAAc,EAAA;AACjF,IAAA,cAAc,CAAC,QAAQ,EAAE,CAAA,EAAG,GAAG,CAAC,IAAI,CAAA,CAAA,EAAI,GAAG,CAAC,OAAO,CAAA,CAAE,EAAE;AACrD,QAAA,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;AAC9B,KAAA,CAAC;AACJ;;ACVM,SAAU,YAAY,CAAC,UAA4B,EAAE,QAAgC,EAAA;IACzF,IAAI,UAAU,EAAE;QACd,SAAS,CAAC,UAAU,CAAC;IACvB;IACA,kBAAkB,CAAC,QAAQ,CAAC;AAC9B;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":["../../src/config.ts","../../src/core/platformCapability.ts","../../src/core/pictureInPictureCapabilities.ts","../../src/core/PipCore.ts","../../src/protocol/upgradeProperties.ts","../../src/protocol/inputAttribute.ts","../../src/components/Pip.ts","../../src/protocol/defineElement.ts","../../src/registerComponents.ts","../../src/bootstrapPip.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n pip: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n pip: \"wcs-pip\",\n },\n};\n\nfunction deepFreeze<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n Object.freeze(obj);\n for (const key of Object.keys(obj)) {\n deepFreeze((obj as Record<string, unknown>)[key]);\n }\n return obj;\n}\n\nfunction deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n const clone: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n clone[key] = deepClone((obj as Record<string, unknown>)[key]);\n }\n return clone as T;\n}\n\nlet frozenConfig: IConfig | null = null;\n\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\n/** A misspelt option would otherwise do nothing: `bootstrapPip` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/picture-in-picture] bootstrapPip: \"${key}\" is not one of its options, or not of the option's type.`);\n}\n\n/**\n * Applies the options given; an undefined value is left out. An option this package does not\n * have, a value of another type than its default (null, or an array for an object, included) or\n * a tag name it does not define throws, and then nothing is applied.\n */\nexport function setConfig(partialConfig: IWritableConfig): void {\n const options = _config as unknown as Record<string, unknown>;\n const tags = _config.tagNames as Record<string, string>;\n const given = Object.entries(partialConfig).filter(([, value]) => value !== undefined);\n const givenTags = Object.entries(partialConfig.tagNames ?? {}).filter(([, tag]) => tag !== undefined);\n for (const [key, value] of given) {\n const current = options[key];\n if (!Object.hasOwn(options, key) || value === null || typeof value !== typeof current || Array.isArray(value) !== Array.isArray(current)) {\n invalid(key);\n }\n }\n for (const [name, tag] of givenTags) {\n if (!Object.hasOwn(tags, name) || typeof tag !== \"string\") invalid(`tagNames.${name}`);\n }\n for (const [name, tag] of givenTags) tags[name] = tag as string;\n frozenConfig = null;\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /io-core/platform-capability.ts by scripts/sync-io-core.mjs.\n// Run `node scripts/sync-io-core.mjs` after editing the source.\n// ===========================================================================\n\n/**\n * platform-capability.ts\n *\n * Phase 6(docs/architecture-hardening/09-remediation-design.md §7.2 /\n * 07-browser-capability-variance.md)の browser capability 判定と error taxonomy の\n * 汎用プリミティブ。node 固有の capability registry / error code は各パッケージが\n * 別ファイルで宣言し、この汎用層(型 + assess 機構)を import する。\n *\n * 原則:\n * - feature detection は境界(利用直前)で行う。module 評価時に browser global を\n * 参照しない(SSR / worker で import が失敗しない)。\n * - capability ID(`web.fetch` 等)は文字列を global property path として eval せず、\n * registry が ID ごとに副作用のない presence probe を対応付ける。\n * - availability / permission / readiness / activity / operation error を 1 つの\n * `ready / unsupported / error` enum に畳まない。required 欠如は開始しない、\n * optional 欠如は宣言済み fallback で readiness を `degraded` にする。\n *\n * 配置: 本ファイルは /io-core/ の単一正典であり、scripts/sync-io-core.mjs が\n * 各 IO ノードの src/core/ へ生成コピー (AUTO-GENERATED, 編集禁止) を配布する。\n * `protocol/wcBindable.ts` と同じ copy-distribution 方式で、ランタイム依存を導入せず\n * 各パッケージのバンドルへ inline される (zero-runtime-dep / 自己完結 CDN を維持)。\n * 編集はこの正典に対して行い、`node scripts/sync-io-core.mjs` で再配布する。\n *\n * pure(module 評価時に browser global 非参照)。\n */\n\nexport type Availability = \"available\" | \"missing\" | \"unknown\";\nexport type PermissionState = \"granted\" | \"denied\" | \"prompt\" | \"not-applicable\" | \"unknown\";\nexport type Readiness = \"idle\" | \"ready\" | \"degraded\";\nexport type Activity = \"inactive\" | \"active\";\nexport type PreconditionState = \"satisfied\" | \"required\" | \"not-applicable\";\n\n/** operation error の phase(taxonomy)。 */\nexport type WcsIoErrorPhase = \"probe\" | \"start\" | \"execute\" | \"decode\" | \"commit\" | \"dispose\";\n\n/** serializable な error info(non-cloneable な cause とは分離。DevTools / remote へは info のみ)。 */\nexport interface WcsIoErrorInfo {\n readonly code: string;\n readonly phase: WcsIoErrorPhase;\n readonly recoverable: boolean;\n readonly capabilityId?: string;\n readonly message: string;\n}\n\nexport interface PlatformAssessment {\n readonly availability: ReadonlyMap<string, Availability>;\n readonly permission: PermissionState;\n readonly readiness: Readiness;\n readonly activity: Activity;\n readonly preconditions: {\n readonly secureContext: PreconditionState;\n readonly userActivation: PreconditionState;\n };\n readonly epoch: number;\n readonly lastError?: WcsIoErrorInfo;\n}\n\n/** capability 1 件の仕様。probe は副作用なく presence を返す(利用直前に呼ぶ)。 */\nexport interface CapabilitySpec {\n readonly probe: () => boolean;\n readonly requiresSecureContext?: boolean;\n readonly requiresUserActivation?: boolean;\n /** browser compatibility dataset のキー(任意・診断用)。 */\n readonly compatKey?: string;\n}\n\nexport type CapabilityRegistry = ReadonlyMap<string, CapabilitySpec>;\n\nexport interface AssessOptions {\n readonly required: readonly string[];\n readonly optional?: readonly string[];\n readonly permission?: PermissionState;\n readonly activity?: Activity;\n readonly epoch?: number;\n readonly lastError?: WcsIoErrorInfo;\n}\n\nfunction isSecureContext(): boolean {\n return (globalThis as { isSecureContext?: unknown }).isSecureContext === true;\n}\n\n/**\n * capability を利用直前に評価して PlatformAssessment を作る。\n * required が 1 つでも欠ければ readiness は \"idle\"(開始不可)、\n * required 揃い + optional 欠けは \"degraded\"、全揃いは \"ready\"。\n */\nexport function assessCapabilities(registry: CapabilityRegistry, options: AssessOptions): PlatformAssessment {\n const availability = new Map<string, Availability>();\n const evaluate = (id: string): Availability => {\n const spec = registry.get(id);\n if (spec === undefined) return \"unknown\";\n return spec.probe() ? \"available\" : \"missing\";\n };\n\n let requiredAllAvailable = true;\n for (const id of options.required) {\n const a = evaluate(id);\n availability.set(id, a);\n if (a !== \"available\") requiredAllAvailable = false;\n }\n let optionalAllAvailable = true;\n for (const id of options.optional ?? []) {\n const a = evaluate(id);\n availability.set(id, a);\n if (a !== \"available\") optionalAllAvailable = false;\n }\n\n const readiness: Readiness = !requiredAllAvailable ? \"idle\" : (optionalAllAvailable ? \"ready\" : \"degraded\");\n\n // preconditions: 対象 capability のいずれかが要求する場合だけ評価する。\n const allIds = [...options.required, ...(options.optional ?? [])];\n const needsSecure = allIds.some((id) => registry.get(id)?.requiresSecureContext === true);\n const needsActivation = allIds.some((id) => registry.get(id)?.requiresUserActivation === true);\n const secureContext: PreconditionState = needsSecure ? (isSecureContext() ? \"satisfied\" : \"required\") : \"not-applicable\";\n const userActivation: PreconditionState = needsActivation ? \"required\" : \"not-applicable\";\n\n return {\n availability,\n permission: options.permission ?? \"not-applicable\",\n readiness,\n activity: options.activity ?? \"inactive\",\n preconditions: { secureContext, userActivation },\n epoch: options.epoch ?? 0,\n lastError: options.lastError,\n };\n}\n\n/** availability から「required がすべて available か」を判定するヘルパ(supported の最低条件)。 */\nexport function requiredCapabilitiesAvailable(assessment: PlatformAssessment, required: readonly string[]): boolean {\n return required.every((id) => assessment.availability.get(id) === \"available\");\n}\n\n/**\n * このページで機能が使えない理由(使える、または分からないなら null)。利用直前に読む。\n *\n * - `\"insecure-context\"`: 安全なコンテキストではない(`isSecureContext === false`)。\n * Permissions API が扱う機能はどれも安全なコンテキストを要る。\n * - `\"policy-blocked\"`: Permissions-Policy(サーバーのヘッダ、または `allow` の無い\n * `<iframe>`)がその機能を切っている。\n *\n * どちらも Permissions API は教えない: Chromium はポリシーで切られた文書でも\n * `granted` を、安全でない origin では `denied` を返す。利用者の拒否と区別するため、\n * 見張り役(`<wcs-permission>`)も取りに行く側も `unsupported` を報告する\n * (docs/v4-direction-2026-10.md の決定、state-field-report)。\n * `isSecureContext` が無い環境(SSR・テスト)は判断しない。\n */\nexport type FeatureUnavailableReason = \"insecure-context\" | \"policy-blocked\";\n\n/**\n * Permissions-Policy が制御する機能。permission 名と同じ文字列と、permission の無い機能\n * (`fullscreen`・`picture-in-picture`・`web-share`: 要素が「このページで使えるか」を言うために聞く)。\n */\nconst POLICY_CONTROLLED = new Set([\n \"camera\", \"microphone\", \"geolocation\", \"midi\", \"clipboard-read\", \"clipboard-write\",\n \"screen-wake-lock\", \"idle-detection\", \"accelerometer\", \"gyroscope\", \"magnetometer\",\n \"ambient-light-sensor\", \"display-capture\", \"fullscreen\", \"picture-in-picture\", \"web-share\",\n]);\n\ninterface PolicyLike { allowsFeature(feature: string): boolean; features?(): string[] }\n\nexport function featureUnavailable(feature: string): FeatureUnavailableReason | null {\n const g = globalThis as { isSecureContext?: unknown; document?: { permissionsPolicy?: PolicyLike; featurePolicy?: PolicyLike } };\n if (g.isSecureContext === false) return \"insecure-context\";\n if (!POLICY_CONTROLLED.has(feature)) return null;\n const policy = g.document?.permissionsPolicy ?? g.document?.featurePolicy;\n if (policy === undefined || typeof policy.allowsFeature !== \"function\") return null;\n try {\n // このブラウザのポリシーが知らない名前は聞かない: Chromium は知らない名前の allowsFeature に\n // false を返したうえでコンソールに「Unrecognized feature」を出す(フラグの無い\n // `ambient-light-sensor`、デスクトップの `web-share`)。知らない機能は切られてもいない。\n if (typeof policy.features === \"function\" && !policy.features().includes(feature)) return null;\n return policy.allowsFeature(feature) ? null : \"policy-blocked\";\n } catch {\n return null;\n }\n}\n\n/** `featureUnavailable` の理由を、作者が直し方を読める文にする。`what` は文頭(「The camera」など)。 */\nexport function featureUnavailableMessage(what: string, feature: string, reason: FeatureUnavailableReason): string {\n return reason === \"insecure-context\"\n ? `${what} needs a secure context (https:, or http://localhost), and this page is not one.`\n : `${what} is turned off for this page by a Permissions-Policy: the server's Permissions-Policy header, ` +\n `or an <iframe> without allow=\"${feature}\". The browser's site settings cannot change that.`;\n}\n","/**\n * pictureInPictureCapabilities.ts\n *\n * Picture-in-Picture node 固有の error code(taxonomy)と derivation。汎用の error\n * info 型は `./platformCapability.js`(/io-core/ から copy-distribution される生成\n * ファイル)から import する。Picture-in-Picture は referenced `<video>` を操作する\n * ノードで競合 operation を持たないため lane は無く、error taxonomy(errorInfo)のみを\n * 採用する(fullscreen と同型)。\n *\n * `_setError` は合成 `{ message }`(target が `<video>` に解決しない / API 非対応)と\n * caught 例外(`NotAllowedError` = user gesture 外の requestPictureInPicture 拒否等)を\n * 混在受理する。呼出側が明示 `kind` を渡して合成側を曖昧さ無く分類し、caught は `.name`\n * で分類する(fullscreen / storage / screen-orientation と同じ discriminator 方式)。\n */\n\nimport type { WcsIoErrorInfo } from \"./platformCapability.js\";\n\n/** 明示 kind discriminator(合成エラーの呼出側が渡す)。 */\nexport type PictureInPictureErrorKind = \"capability-missing\" | \"invalid-argument\";\n\n/** 安定した Picture-in-Picture error code(taxonomy)。値は公開キーとして固定。 */\nexport const WCS_PICTURE_IN_PICTURE_ERROR_CODE = {\n /** Picture-in-Picture API 非対応。 */\n CapabilityMissing: \"capability-missing\",\n /** target が `<video>` に解決しない等の入力不備。 */\n InvalidArgument: \"invalid-argument\",\n /** `NotAllowedError` / `TypeError` — user gesture 外での要求拒否。 */\n NotAllowed: \"not-allowed\",\n /** その他の caught 例外。 */\n PipError: \"pip-error\",\n} as const;\n\nfunction messageOf(error: unknown): string {\n return typeof (error as { message?: unknown } | null)?.message === \"string\"\n ? (error as { message: string }).message\n : String(error);\n}\n\n/**\n * Picture-in-Picture の失敗を serializable な error taxonomy に写す。`kind` は合成\n * エラーの呼出側が渡す明示 discriminator(`capability-missing` / `invalid-argument`)。\n * 未指定は caught 例外を意味し、`.name` で分類する。`NotAllowedError` / `TypeError` は\n * user gesture 内で再試行すれば成功しうるため recoverable=true。\n */\nexport function derivePictureInPictureErrorInfo(error: unknown, kind?: PictureInPictureErrorKind): WcsIoErrorInfo {\n const message = messageOf(error);\n if (kind === \"capability-missing\") {\n return { code: WCS_PICTURE_IN_PICTURE_ERROR_CODE.CapabilityMissing, phase: \"probe\", recoverable: false, message };\n }\n if (kind === \"invalid-argument\") {\n return { code: WCS_PICTURE_IN_PICTURE_ERROR_CODE.InvalidArgument, phase: \"start\", recoverable: false, message };\n }\n const name = (error as { name?: unknown } | null)?.name;\n if (name === \"NotAllowedError\" || name === \"TypeError\") {\n return { code: WCS_PICTURE_IN_PICTURE_ERROR_CODE.NotAllowed, phase: \"execute\", recoverable: true, message };\n }\n return { code: WCS_PICTURE_IN_PICTURE_ERROR_CODE.PipError, phase: \"execute\", recoverable: false, message };\n}\n","import { IWcBindable } from \"../types.js\";\nimport { WcsIoErrorInfo, featureUnavailable } from \"./platformCapability.js\";\nimport { derivePictureInPictureErrorInfo, PictureInPictureErrorKind } from \"./pictureInPictureCapabilities.js\";\n\n/**\n * Headless Picture-in-Picture primitive. A thin, framework-agnostic wrapper\n * around the classic Picture-in-Picture API\n * (`HTMLVideoElement.requestPictureInPicture()` / `document.exitPictureInPicture()` /\n * `document.pictureInPictureElement`) exposed through the wc-bindable protocol.\n *\n * This Core follows the same basic pattern as `@wcstack/fullscreen`'s\n * `FullscreenCore` (docs/fullscreen-tag-design.md): target resolution is done\n * by the Shell (this Core receives the resolved element at call time), API\n * resolution is call-time/non-cached, `_gen` is a single Core-level generation\n * guard, and `error` is a simple single field (no permission-style 4-value\n * state). See docs/picture-in-picture-tag-design.md for the differences from\n * Fullscreen:\n *\n * - **§2 target constraint**: the resolved target MUST be a `<video>` element.\n * Picture-in-Picture is only defined as an instance method of\n * `HTMLVideoElement` — unlike Fullscreen, which any `Element` supports. A\n * non-`<video>` target is a never-throw failure: it is treated the same as\n * an unresolved target and reported via `error`.\n * - **§3 event subscription target**: `enterpictureinpicture` /\n * `leavepictureinpicture` fire on the `<video>` element itself, not on\n * `document` (the reverse of Fullscreen's `document`-level\n * `fullscreenchange`). The Core attaches/detaches these listeners directly\n * on the resolved `<video>` element, re-wiring them whenever the target is\n * re-resolved (e.g. the Shell's `target` attribute changes).\n */\nexport class PipCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"active\", event: \"wcs-pip:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.active },\n // `error` / `errorInfo` are observable failure outputs. Historically `error`\n // was an imperative getter with no event; both are now bindable (event-backed)\n // so `data-wcs` / bind() can observe a request/exit failure. `errorInfo` is the\n // additive serializable taxonomy (stable code / phase / recoverable) derived\n // from `error`; the `error` value shape is unchanged. No lane — Picture-in-Picture\n // drives a referenced `<video>`, not a competing operation (fullscreen と同型)。\n { name: \"error\", event: \"wcs-pip:error\", semantics: \"state\" },\n { name: \"errorInfo\", event: \"wcs-pip:error-info-changed\", semantics: \"state\" },\n // Whether this page can use Picture-in-Picture (the API is there and no\n // Permissions-Policy forbids it). Computed at call time; the event carries\n // the boolean and fires from observe() when it differs from the last value\n // dispatched.\n { name: \"supported\", event: \"wcs-pip:supported-changed\", semantics: \"state\" },\n ],\n commands: [\n { name: \"requestPictureInPicture\", async: true },\n { name: \"exitPictureInPicture\", async: true },\n ],\n };\n\n private _target: EventTarget;\n private _active: boolean = false;\n private _error: any = null;\n private _errorInfo: WcsIoErrorInfo | null = null;\n\n // The <video> element the Core currently subscribes to for\n // enterpictureinpicture/leavepictureinpicture (null when unresolved/torn down).\n private _video: HTMLVideoElement | null = null;\n\n // Generation guard (§3.4 / fullscreen-tag-design.md §6): bumped on dispose()\n // and each async command start. A completion that lands after dispose() (or\n // after a superseding call) is stale and MUST NOT write state.\n private _gen = 0;\n\n // `supported` as last dispatched (never the value itself — the getter probes at\n // call time). Starts at false, so observe() announces a page that can use it.\n private _supportedPublished = false;\n\n // SSR (§3.8): no asynchronous probe to await, so readiness is immediate.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n get ready(): Promise<void> {\n return this._ready;\n }\n\n get active(): boolean {\n return this._active;\n }\n\n get error(): any {\n return this._error;\n }\n\n /**\n * The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /\n * `recoverable`), or null. Additive wc-bindable property (event\n * `wcs-pip:error-info-changed`), derived from `error`; the existing `error`\n * value shape is unchanged.\n */\n get errorInfo(): WcsIoErrorInfo | null {\n return this._errorInfo;\n }\n\n /**\n * Whether this page can use Picture-in-Picture right now: the document says it\n * is enabled, a `<video>` has `requestPictureInPicture()`, and no\n * Permissions-Policy (`picture-in-picture`: the server's header, an `<iframe>`\n * whose `allow` turns it off) forbids it. Probed at call time, never cached.\n * It does not say that a request will succeed (that still needs a user gesture\n * and a video that can be shown, and a `<video disablepictureinpicture>`\n * refuses). Firefox has no Picture-in-Picture API for pages, so this is\n * `false` there. A wc-bindable output (event `wcs-pip:supported-changed`).\n */\n get supported(): boolean {\n // The policy is asked first, and `pictureInPictureEnabled` is read only when\n // it did not forbid: Chromium logs a console error for merely reading it in a\n // document the policy forbids. Only \"policy-blocked\" decides here:\n // Picture-in-Picture does not need a secure context (a plain http: page can\n // use it), so \"insecure-context\" is not a reason — `pictureInPictureEnabled`,\n // which follows the policy itself, gives the answer there.\n if (featureUnavailable(\"picture-in-picture\") === \"policy-blocked\") return false;\n return (document as any).pictureInPictureEnabled === true\n && typeof (HTMLVideoElement.prototype as any).requestPictureInPicture === \"function\";\n }\n\n // --- Lifecycle (§3.5) ---\n\n /**\n * (Re-)subscribe to `enterpictureinpicture`/`leavepictureinpicture` on\n * `element` (the Shell's resolved `<video>` target). Idempotent when called\n * again with the same element; re-wires the listeners when the element\n * changes (e.g. the `target` attribute was changed), detaching from the\n * previous element first so no stale listener lingers. Also publishes\n * `supported` when it differs from the last value dispatched.\n */\n observe(element: HTMLVideoElement | null): Promise<void> {\n this._publishSupported();\n if (this._video === element) {\n return this._ready;\n }\n this._detach();\n this._video = element;\n if (element) {\n element.addEventListener(\"enterpictureinpicture\", this._onEnter);\n element.addEventListener(\"leavepictureinpicture\", this._onLeave);\n }\n this._syncActive();\n return this._ready;\n }\n\n dispose(): void {\n this._gen++;\n this._detach();\n this._video = null;\n // A disposed Core hears no leavepictureinpicture, so it can no longer vouch\n // for `active`: publish false through the normal setter (timing contract §22\n // — a disconnect publishes what it changes). The small window is not closed\n // here; observe() re-reads the truth — publishing true again — on the next\n // connect.\n this._setActive(false);\n }\n\n // --- Commands (§3.6 never-throw) ---\n\n /**\n * Request Picture-in-Picture for `element`. `element` must be a `<video>`\n * (checked before the gesture-context failure path, since a type mismatch is\n * an environment-independent, permanent error — docs/picture-in-picture-tag-design.md §2).\n * Never throws: all failures (wrong tag, unsupported API, gesture-context\n * rejection) are funneled into `error` and the returned promise resolves.\n */\n async requestPictureInPicture(element: HTMLVideoElement | null): Promise<void> {\n const gen = ++this._gen;\n if (!element || element.tagName !== \"VIDEO\") {\n // Distinct from \"API is not supported\" (below): the resolved target did\n // not satisfy the `<video>`-only constraint (wrong tag / unresolved).\n this._setError({ message: \"target must be a <video> element.\" }, \"invalid-argument\");\n return;\n }\n // Re-wire to `element` before issuing the platform call: a caller may\n // request a <video> different from the one last passed to observe() (e.g.\n // the Shell's target attribute pointed at nothing at connect time and the\n // matching <video> was only inserted later, so no attributeChangedCallback\n // ever re-resolved it). Without this, `_video` stays stale and\n // `_syncActive()` below (and future enter/leave events) would never\n // recognize `element` as this Core's target, leaving `active` permanently\n // wrong even though the request succeeded (mirrors\n // FullscreenCore.requestFullscreen()'s unconditional `this._resolvedTarget\n // = element` assignment — docs/fullscreen-tag-design.md §6).\n this.observe(element);\n const fn = this._requestPictureInPictureFn(element);\n if (!fn) {\n this._setError({ message: \"Picture-in-Picture API is not supported.\" }, \"capability-missing\");\n return;\n }\n try {\n await fn.call(element);\n if (gen !== this._gen) return; // stale\n this._setError(null);\n this._syncActive(); // belt-and-suspenders (mirrors FullscreenCore's _applyActive() on success)\n } catch (e: any) {\n if (gen !== this._gen) return; // stale\n this._setError(e); // e.g. NotAllowedError (gesture-context rejection)\n }\n }\n\n /**\n * Exit Picture-in-Picture. Mirrors FullscreenCore.exitFullscreen(): a\n * silent no-op (resolve, no error) when nothing is currently in\n * Picture-in-Picture — see fullscreen-tag-design.md §7.\n */\n async exitPictureInPicture(): Promise<void> {\n // no-op checks come BEFORE the generation bump: a call that does nothing\n // must not supersede an in-flight requestPictureInPicture() — bumping\n // first would make the pending request's settle handling stale and\n // silently swallow its error update (mirrors\n // FullscreenCore.exitFullscreen()).\n if (this._pictureInPictureElement() === null) return; // already not in PiP: silent no-op\n const fn = this._exitPictureInPictureFn();\n if (!fn) return; // unsupported: silent no-op (semantically already \"not in PiP\")\n const gen = ++this._gen;\n try {\n await fn();\n if (gen !== this._gen) return;\n this._setError(null);\n this._syncActive(); // belt-and-suspenders (mirrors FullscreenCore.exitFullscreen()'s success-path _applyActive()); covers a delayed/dropped leavepictureinpicture\n } catch (e: any) {\n if (gen !== this._gen) return;\n this._setError(e);\n }\n }\n\n // --- Internal: API resolution (call-time, never cached — §3.7) ---\n\n // Unlike FullscreenCore's _elementFullscreenFn(), a naive direct property\n // lookup (`e.requestPictureInPicture`, walking the prototype chain) here is\n // safe: it cannot recurse into the Shell's own command method,\n // because the resolved target is validated to be a <video> element (§2)\n // before this is called, and <wcs-pip> (the Shell) is never itself a\n // <video>. Fullscreen's own→Element.prototype two-step resolution guards\n // against `target=\"self\"`/no-target resolving to the Shell element, which\n // cannot happen here.\n private _requestPictureInPictureFn(el: HTMLVideoElement): (() => Promise<PictureInPictureWindow>) | undefined {\n const e = el as any;\n return typeof e.requestPictureInPicture === \"function\" ? e.requestPictureInPicture : undefined;\n }\n\n private _exitPictureInPictureFn(): (() => Promise<void>) | undefined {\n const d = document as any;\n return typeof d.exitPictureInPicture === \"function\" ? d.exitPictureInPicture.bind(document) : undefined;\n }\n\n private _pictureInPictureElement(): Element | null {\n const d = document as any;\n return d.pictureInPictureElement ?? null;\n }\n\n // --- Internal: event wiring ---\n\n private _onEnter = (): void => {\n this._syncActive();\n };\n\n private _onLeave = (): void => {\n this._syncActive();\n };\n\n private _syncActive(): void {\n const isActive = this._video !== null && this._pictureInPictureElement() === this._video;\n this._setActive(isActive);\n }\n\n private _detach(): void {\n if (this._video) {\n this._video.removeEventListener(\"enterpictureinpicture\", this._onEnter);\n this._video.removeEventListener(\"leavepictureinpicture\", this._onLeave);\n }\n }\n\n // --- State setters with event dispatch (§3.3 same-value guard) ---\n\n // `supported` is probed at call time, so there is no stored value to set: this\n // dispatches the current one when it differs from the last one dispatched\n // (same-value guard). A state binding reads the property when it attaches; the\n // event is for every other listener.\n private _publishSupported(): void {\n const supported = this.supported;\n if (this._supportedPublished === supported) return;\n this._supportedPublished = supported;\n this._target.dispatchEvent(new CustomEvent(\"wcs-pip:supported-changed\", {\n detail: supported,\n bubbles: true,\n }));\n }\n\n private _setActive(active: boolean): void {\n if (this._active === active) return;\n this._active = active;\n this._target.dispatchEvent(new CustomEvent(\"wcs-pip:change\", {\n detail: { active },\n bubbles: true,\n }));\n }\n\n // `kind` is an explicit taxonomy discriminator passed only from the synthetic\n // error sites (unsupported / non-<video> target); caught exceptions pass no kind\n // and are classified by their `.name`. Both `error` and the additive `errorInfo`\n // are now event-backed so a request/exit failure is observable via bind().\n private _setError(error: any, kind?: PictureInPictureErrorKind): void {\n // Same-value guard on reference: each failure builds a fresh object and the\n // clear path passes the literal null, so this only suppresses redundant\n // null→null (a successful request/exit clearing an already-null error).\n if (this._error === error) return;\n this._error = error;\n // Keep the additive errorInfo taxonomy in sync; fire it before the `error`\n // event so an observer of both sees the classification first (io-node family).\n this._commitErrorInfo(error === null ? null : derivePictureInPictureErrorInfo(error, kind));\n this._target.dispatchEvent(new CustomEvent(\"wcs-pip:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n // Called only from _setError (already reference-guarded), so errorInfo\n // transitions exactly when error does — no separate guard needed here.\n private _commitErrorInfo(info: WcsIoErrorInfo | null): void {\n this._errorInfo = info;\n this._target.dispatchEvent(new CustomEvent(\"wcs-pip:error-info-changed\", {\n detail: info,\n bubbles: true,\n }));\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/upgrade-properties.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// custom element の property upgrade — `static wcBindable.inputs` に宣言した入力のうち、\n// 要素が upgrade される前に代入された own データプロパティを取り込み直す。\n//\n// なぜ必要か:\n// 未定義タグの要素は素の HTMLElement なので、`el.url = \"...\"` は own データプロパティを作る。\n// upgrade 後にクラスの accessor が prototype へ入っても own プロパティが優先されるため、\n// setter は二度と呼ばれず、値は要素へ届かないまま消える(エラーも警告も出ない)。\n// 常にプロパティ代入を行う framework(Angular の `[prop]`、Lit の `.prop=`、\n// Solid の `prop:`、Vue の `.prop` 修飾子)× 遅延定義(autoloader / CDN / code-split)で\n// 常態的に起きる。docs/architecture-hardening/13-framework-adapter-binding-constraints.md §1.2。\n//\n// 安全側の判定:\n// own プロパティがあっても、prototype チェーンに accessor が無ければ「シャドウ」ではなく\n// その own プロパティ自体が正規の格納先なので触らない(public class field を壊さない)。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/upgrade-properties.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/upgradeProperties.ts). Those copies are generated — do not edit them.\nimport { IWcBindable } from \"./wcBindable.js\";\n\nfunction hasAccessorOnPrototype(target: object, name: string): boolean {\n let proto = Object.getPrototypeOf(target);\n while (proto !== null) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n if (descriptor !== undefined) {\n return typeof descriptor.get === \"function\" || typeof descriptor.set === \"function\";\n }\n proto = Object.getPrototypeOf(proto);\n }\n return false;\n}\n\n// 属性になってしまったオブジェクトの入力(`files=\"[object File]\"`)を、要素ごとに 1 回だけ言う。\n// React 19 は定義前の要素にプロパティが無いのでオブジェクトを属性に書き、Vue の `.attr` も\n// 書く。要素はその入力をプロパティでしか読まないので、何も受け取らず、何も言わなかった\n// (docs/seam-apps.md、fw-inventory)。\nconst toldObjectAttribute = new WeakSet<object>();\n\nfunction warnObjectAttribute(element: object, name: string, value: string): void {\n if (toldObjectAttribute.has(element)) return;\n toldObjectAttribute.add(element);\n const tag = (element as { localName?: string }).localName ?? \"element\";\n console.warn(\n `[wcs/input-as-attribute] <${tag}> has the attribute ${name}=\"${value}\": an object was written as an ` +\n `attribute, so the element did not receive it. A framework does that when the property is set before the ` +\n `element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, ` +\n `or assign the property through a ref (Vue: .prop). (Said once per element.)`,\n element,\n );\n}\n\n/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\n * - 値が `[object …]` の属性(属性に書かれてしまったオブジェクトの入力)は、要素ごとに 1 回警告する。\n */\nexport function upgradeProperties(element: object): void {\n const declaration = (element as { constructor?: { wcBindable?: IWcBindable } }).constructor?.wcBindable;\n const inputs = declaration?.inputs;\n if (inputs === undefined) return;\n const getAttribute = (element as { getAttribute?: (name: string) => string | null }).getAttribute;\n for (const input of inputs) {\n const name = input.name;\n const attribute = typeof getAttribute === \"function\" ? getAttribute.call(element, name.toLowerCase()) : null;\n if (attribute !== null && attribute.startsWith(\"[object \")) warnObjectAttribute(element, name, attribute);\n if (!Object.prototype.hasOwnProperty.call(element, name)) continue;\n if (!hasAccessorOnPrototype(element, name)) continue;\n const record = element as Record<string, unknown>;\n const value = record[name];\n delete record[name];\n record[name] = value;\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/input-attribute.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// 属性へ反映する wc-bindable 入力の producer 側(SPEC-extensions § Producer guidance for inputs の P1〜P3)。\n// 入力の setter は属性をこの 2 関数で書く。それで次が揃う:\n// - `undefined` は「値が無い」(P1): 属性を、この関数で最初に書く前の状態 — マークアップに書かれた値、\n// 無ければ属性なし(= その入力の文書化した既定値)— へ戻す。applier プロファイルを宣言する binder は\n// 値の後の `undefined` を書き(A2)、React 19 も書き、直接の代入でも届く。\n// - `null` はクリア(P2): 属性なし、つまり文書化した既定値。\n// - どちらも文字列 \"undefined\" / \"null\" として属性に入らない。\n//\n// 「最初に書く前」は、その最初の書き込みのときに読む(遅延)。upgrade 前に代入されたプロパティは\n// connectedCallback の upgradeProperties() が通し直すので、そのときにはパーサが書いた属性が揃っている。\n// 要素自身が setter を通さずに書いた属性は、最初の書き込みより前なら「最初の状態」に含まれる。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/input-attribute.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/inputAttribute.ts). Those copies are generated — do not edit them.\n\nconst initialAttributes = new WeakMap<Element, Map<string, string | null>>();\n\n/** The attribute as it stood before the first write through these helpers. */\nfunction initialAttribute(el: Element, name: string): string | null {\n let byName = initialAttributes.get(el);\n if (byName === undefined) {\n byName = new Map();\n initialAttributes.set(el, byName);\n }\n if (!byName.has(name)) byName.set(name, el.getAttribute(name));\n return byName.get(name) as string | null;\n}\n\nfunction writeAttribute(el: Element, name: string, value: string | null): void {\n if (value === null) el.removeAttribute(name);\n else el.setAttribute(name, value);\n}\n\n/**\n * A value attribute. `value` is written as `String(value)`; `null` removes the attribute;\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value === null ? null : String(value));\n}\n\n/**\n * A boolean attribute, present while `value` is truthy (`null` and `false` remove it);\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectBooleanAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value ? \"\" : null);\n}\n","import { IWcBindable } from \"../types.js\";\nimport { PipCore } from \"../core/PipCore.js\";\nimport { WcsIoErrorInfo } from \"../core/platformCapability.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute } from \"../protocol/inputAttribute.js\";\n\n/**\n * `<wcs-pip target=\"...\">` — declarative Picture-in-Picture control.\n *\n * Like `<wcs-fullscreen>` (docs/fullscreen-tag-design.md §0/§1), this Shell\n * does not operate on itself: it is a non-visible control tag that resolves a\n * `target` element and invokes Picture-in-Picture commands against it. The\n * `target` attribute resolves in the same 3 modes as `intersection`/`fullscreen`\n * (`self` / a selector / the first element child), reused verbatim from\n * `@wcstack/intersection`'s `_resolveTarget()`/`_safeQuery()`\n * (packages/intersection/src/components/Intersect.ts).\n *\n * Picture-in-Picture-specific difference (docs/picture-in-picture-tag-design.md\n * §2): the resolved target must be a `<video>` element. This Shell resolves the\n * DOM element and hands it to the Core; the Core performs the `tagName ===\n * \"VIDEO\"` validation (never-throw — a mismatch is treated as an unresolved\n * target and reported via `error`, not thrown).\n */\nexport class WcsPip extends HTMLElement {\n // SSR (§4.4): observe() completes synchronously, but the Shell still exposes\n // connectedCallbackPromise so the state binder can await it uniformly across\n // all IO nodes before snapshotting.\n static hasConnectedCallbackPromise = true;\n\n static observedAttributes = [\"target\"];\n\n static wcBindable: IWcBindable = {\n ...PipCore.wcBindable,\n inputs: [{ name: \"target\", attribute: \"target\" }],\n // Core の commands をそのまま継承(単一情報源)。fullscreen/intersection と同型。\n commands: PipCore.wcBindable.commands,\n };\n\n private _core: PipCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new PipCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-pip:change\": (d) => ({ active: d?.active === true }),\n });\n }\n\n // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of\n // wc-bindable (not a bind target); see README \"CSS styling with :state()\".\n // MUST NOT return the live CustomStateSet (that would let callers write\n // states from outside, defeating the point of :state() being read-only).\n get debugStates(): string[] {\n return this._internals ? [...this._internals.states] : [];\n }\n\n private _initInternals(): ElementInternals | null {\n // never-throw (docs/custom-state-reflection-design.md §3.1): attachInternals\n // is absent in happy-dom / older environments, and pre-125 Chromium rejects\n // non-dashed state names from states.add() (probed and discarded here).\n // Either case silently disables reflection — the component still works,\n // it just doesn't expose :state() selectors.\n try {\n if (typeof this.attachInternals !== \"function\") return null;\n const internals = this.attachInternals();\n internals.states.add(\"wcs-probe\");\n internals.states.delete(\"wcs-probe\");\n return internals;\n } catch {\n return null;\n }\n }\n\n private _wireStates(map: Record<string, (detail: any) => Record<string, boolean>>): void {\n if (this._internals === null) return;\n const states = this._internals.states;\n for (const [event, toStates] of Object.entries(map)) {\n this.addEventListener(event, (e) => {\n const debug = this.hasAttribute(\"debug-states\");\n for (const [name, on] of Object.entries(toStates((e as CustomEvent).detail))) {\n try {\n if (on) { states.add(name); } else { states.delete(name); }\n } catch { /* never-throw */ }\n if (debug) this.toggleAttribute(`data-wcs-state-${name}`, on);\n }\n });\n }\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Attribute accessors ---\n\n get target(): string {\n return this.getAttribute(\"target\") ?? \"\";\n }\n\n // Never lets setAttribute stringify null / undefined (an \"undefined\" selector\n // resolves nothing): `null` removes the attribute (the first-child default),\n // `undefined` restores the attribute the element started with (wc-bindable\n // producer guidance P1; React 19 and a direct assignment deliver it,\n // @wcstack/state does not).\n set target(value: string | null | undefined) {\n reflectAttribute(this, \"target\", value);\n }\n\n // --- Core delegated getters ---\n\n get active(): boolean {\n return this._core.active;\n }\n\n get error(): any {\n return this._core.error;\n }\n\n get errorInfo(): WcsIoErrorInfo | null {\n return this._core.errorInfo;\n }\n\n // Whether this page can use Picture-in-Picture — probed at call time by the\n // Core (never cached), so a state binding that reads it when it attaches gets\n // the right value without waiting for `wcs-pip:supported-changed`.\n get supported(): boolean {\n return this._core.supported;\n }\n\n // --- Commands ---\n\n async requestPictureInPicture(): Promise<void> {\n const { element } = this._resolveVideoTarget();\n return this._core.requestPictureInPicture(element);\n }\n\n async exitPictureInPicture(): Promise<void> {\n return this._core.exitPictureInPicture();\n }\n\n // --- Internal ---\n\n /**\n * `_resolveTarget()`/`_safeQuery()` copied verbatim from `@wcstack/intersection`\n * (packages/intersection/src/components/Intersect.ts:243-267, 281-287) per the\n * fullscreen/picture-in-picture batch's shared target-resolution archetype\n * (docs/fullscreen-tag-design.md §1).\n */\n private _resolveTarget(): { element: Element | null; display: string } {\n const target = this.target;\n if (target === \"self\") {\n return { element: this, display: \"block\" };\n }\n if (target !== \"\") {\n const scope = this.getRootNode() as Document | ShadowRoot;\n return { element: this._safeQuery(scope, target), display: \"none\" };\n }\n const child = this.firstElementChild;\n if (child) {\n return { element: child, display: \"contents\" };\n }\n return { element: this, display: \"block\" };\n }\n\n private _safeQuery(scope: Document | ShadowRoot, selector: string): Element | null {\n try {\n return scope.querySelector(selector);\n } catch {\n return null;\n }\n }\n\n /**\n * Layers the Picture-in-Picture-specific `tagName === \"VIDEO\"` check on top\n * of `_resolveTarget()` (docs/picture-in-picture-tag-design.md §2). A\n * resolved-but-wrong-tag element is treated as unresolved (`element: null`)\n * so it flows into the same \"target not found\" failure path as Fullscreen's\n * missing-target case — never-throw, no exception escapes.\n */\n private _resolveVideoTarget(): { element: HTMLVideoElement | null; display: string } {\n const { element, display } = this._resolveTarget();\n if (element !== null && element.tagName !== \"VIDEO\") {\n return { element: null, display };\n }\n return { element: element as HTMLVideoElement | null, display };\n }\n\n private _observe(): void {\n const { element, display } = this._resolveVideoTarget();\n this.style.display = display;\n this._connectedCallbackPromise = this._core.observe(element);\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\n this._observe();\n }\n\n // dispose() publishes `active: false` when it was true (timing contract §22):\n // out of the document this element hears no leavepictureinpicture. The small\n // window is not closed here; the next connectedCallback re-reads the truth\n // through _observe().\n disconnectedCallback(): void {\n this._core.dispose();\n }\n\n attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void {\n if (oldValue === newValue) return;\n if (!this.isConnected) return;\n this._observe();\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/define-element.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n/**\n * One copy of each package on a page (docs/timing-and-firing-contract.md §24). The first copy the\n * page evaluates defines the tags and a second one does nothing, so a copy that finds its tag defined\n * by another copy of the package — not its class, not a subclass of it, not the same version — warns\n * `[wcs/package-twice]` once per registry, naming both versions. The classes it defines carry\n * `\"<package>@<version>\"` under `Symbol.for(\"wcstack.package\")`; a class without it is named\n * \"another copy of <package> that does not name its version\" (an older copy, or one loaded through\n * an entry that does not stamp).\n */\n\n/** The static a class defined through this helper carries: `\"@wcstack/fetch@<version>\"`. */\nexport const PACKAGE_STAMP: unique symbol = Symbol.for(\"wcstack.package\");\n\ntype Stamped = { [PACKAGE_STAMP]?: string };\n\n/** The registries this copy warned about: one warning per package per registry. */\nconst warned = new WeakSet<CustomElementRegistry>();\n\n/**\n * Marks `cls` as defined by `pkg` (`\"@wcstack/fetch@<version>\"`). A subclass inherits the mark, and\n * `defineProperty` writes it even where a parent's mark is read-only.\n */\nexport function stampPackage(cls: CustomElementConstructor, pkg: string): void {\n Object.defineProperty(cls, PACKAGE_STAMP, { value: pkg, configurable: true });\n}\n\n/**\n * Warns when `tag` is defined as `existing` by another copy of the package `pkg` names: `existing`\n * is neither `own` nor a subclass of it (omit `own` when the copy has no class to compare with), and\n * carries another version or none. Once per registry.\n */\nexport function warnIfAnotherCopy(\n registry: CustomElementRegistry,\n tag: string,\n existing: CustomElementConstructor,\n own: CustomElementConstructor | undefined,\n pkg: string,\n): void {\n if (own !== undefined && (existing === own || existing.prototype instanceof own)) return;\n const theirs = (existing as Stamped)[PACKAGE_STAMP];\n if (theirs === pkg || warned.has(registry)) return;\n warned.add(registry);\n const name = pkg.slice(0, pkg.lastIndexOf(\"@\"));\n console.warn(\n `[${name}] [wcs/package-twice] <${tag}> is already defined by ` +\n `${theirs ?? `another copy of ${name} that does not name its version`}; ` +\n `this copy, ${pkg}, does nothing. Load each package once.`,\n );\n}\n\n/**\n * Defines each `[tag, class]` in `registry` unless the tag is already defined, stamping the class\n * with `pkg` (`\"@wcstack/fetch@<version>\"`). A tag another copy of the package defined first is left\n * as it is, with the warning above.\n */\nexport function defineElements(\n registry: CustomElementRegistry,\n pkg: string,\n definitions: readonly (readonly [tag: string, cls: CustomElementConstructor])[],\n): void {\n for (const [tag, cls] of definitions) {\n const existing = registry.get(tag);\n if (existing === undefined) {\n stampPackage(cls, pkg);\n registry.define(tag, cls);\n } else {\n warnIfAnotherCopy(registry, tag, existing, cls, pkg);\n }\n }\n}\n","import pkg from \"../package.json\" with { type: \"json\" };\nimport { WcsPip } from \"./components/Pip.js\";\nimport { config } from \"./config.js\";\nimport { defineElements } from \"./protocol/defineElement.js\";\n\n/**\n * Register this package's tags. Pass a scoped `CustomElementRegistry` to define\n * them for a single shadow tree -- scoped registries do not inherit the global\n * one, so a tree using one needs its own definitions.\n */\nexport function registerComponents(registry: CustomElementRegistry = customElements): void {\n defineElements(registry, `${pkg.name}@${pkg.version}`, [\n [config.tagNames.pip, WcsPip],\n ]);\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapPip(userConfig?: IWritableConfig, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n"],"names":[],"mappings":"AAQA,MAAM,OAAO,GAAoB;AAC/B,IAAA,QAAQ,EAAE;AACR,QAAA,GAAG,EAAE,SAAS;AACf,KAAA;CACF;AAED,SAAS,UAAU,CAAI,GAAM,EAAA;AAC3B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAAG;AACvD,IAAA,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;IAClB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;AAClC,QAAA,UAAU,CAAE,G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GAAG,CAAC,GAAG,CAAC;AAClC,QAAA,IAAI,QAAQ,KAAK,SAAS,EAAE;AAC1B,YAAA,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC;AACtB,YAAA,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC;QAC3B;aAAO;YACL,iBAAiB,CAAC,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,CAAC;QACtD;IACF;AACF;;ACtEA;;;;AAIG;AACG,SAAU,kBAAkB,CAAC,QAAA,GAAkC,cAAc,EAAA;AACjF,IAAA,cAAc,CAAC,QAAQ,EAAE,CAAA,EAAG,GAAG,CAAC,IAAI,CAAA,CAAA,EAAI,GAAG,CAAC,OAAO,CAAA,CAAE,EAAE;AACrD,QAAA,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;AAC9B,KAAA,CAAC;AACJ;;ACVM,SAAU,YAAY,CAAC,UAA4B,EAAE,QAAgC,EAAA;IACzF,IAAI,UAAU,EAAE;QACd,SAAS,CAAC,UAAU,CAAC;IACvB;IACA,kBAAkB,CAAC,QAAQ,CAAC;AAC9B;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wcstack/picture-in-picture",
3
- "version": "4.24.1",
3
+ "version": "4.25.0",
4
4
  "description": "Declarative Picture-in-Picture component for Web Components. Framework-agnostic <video> Picture-in-Picture control via wc-bindable-protocol.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.esm.js",