@wcstack/magnetometer 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 +28 -4
- package/README.md +28 -4
- package/dist/auto.min.js +1 -1
- package/dist/auto.min.js.map +1 -1
- package/dist/index.d.ts +24 -3
- package/dist/index.esm.js +113 -14
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/README.ja.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
`@wcstack/state` と組み合わせると、`<wcs-magnetometer>` はパス契約で直接バインドできます:
|
|
10
10
|
|
|
11
11
|
- **入力サーフェス**: `frequency`(サンプリングレート、Hz)
|
|
12
|
-
- **出力 state サーフェス**: `x`、`y`、`z`、`error`、`errorInfo`
|
|
12
|
+
- **出力 state サーフェス**: `x`、`y`、`z`、`error`、`errorInfo`、そして 4.25 から `supported`
|
|
13
13
|
|
|
14
14
|
`@wcstack/magnetometer` は [CSBC](https://github.com/csbc-dev/arch/blob/main/README.md)(Core / Shell / Binding Contract)アーキテクチャに従います:
|
|
15
15
|
|
|
@@ -23,7 +23,7 @@ Generic Sensor API の`Accelerometer`/`Gyroscope`/`Magnetometer`/`AmbientLightSe
|
|
|
23
23
|
|
|
24
24
|
> **`@wcstack/permission`との合成を推奨。** `navigator.permissions.query({name:"magnetometer"})`が既に存在するため、`<wcs-magnetometer>`は`<wcs-permission name="magnetometer">`と併置して`granted`/`denied`/`prompt`状態を得てください(権限状態はこのノード自身では重複実装しません、`docs/sensor-tag-design.md`参照)。
|
|
25
25
|
|
|
26
|
-
> **Chromium/Android中心の対応。** デスクトップでは`Magnetometer`クラスが存在しても`SecurityError`になりがちです。unsupported/deniedを既定状態として設計してください。
|
|
26
|
+
> **Chromium/Android中心の対応。** デスクトップでは`Magnetometer`クラスが存在しても`SecurityError`になりがちです。unsupported/deniedを既定状態として設計してください。iPhone / iPad の Safari には`Magnetometer`クラスが無く、代わりになるものもありません: [iPhone では](#iphone-では)を参照。
|
|
27
27
|
|
|
28
28
|
## インストール
|
|
29
29
|
|
|
@@ -92,7 +92,7 @@ npm install @wcstack/magnetometer
|
|
|
92
92
|
|
|
93
93
|
| 属性 | 型 | 既定値 | 説明 |
|
|
94
94
|
| ----------- | ------ | ------ | ---- |
|
|
95
|
-
| `frequency` | number | — | サンプリングレート(Hz)。`Magnetometer`コンストラクタへそのまま渡る。読み取られるのは`start()`実行時のみ — 稼働中に変更しても`stop()`+`start()`し直すまで反映されない(注意・制限を参照)。 |
|
|
95
|
+
| `frequency` | number | — | サンプリングレート(Hz)。`Magnetometer`コンストラクタへそのまま渡る。読み取られるのは`start()`実行時のみ — 稼働中に変更しても`stop()`+`start()`し直すまで反映されない(注意・制限を参照)。4.25 から: 正の数でない値は `start()` のときにコンソールへ 1 回言います(`[wcs/frequency-invalid]`、注意・制限を参照)。 |
|
|
96
96
|
|
|
97
97
|
**`null` と `undefined`。** 属性に対応する入力(`frequency`)は、`null` を「クリア」として扱います。属性を外し、入力は既定値(プラットフォームのサンプリングレート)に戻ります。`undefined` は「値が無い」で、属性を最初の書き込みの前の状態 — マークアップに書かれた値、無ければ属性なし — に戻します。どちらも文字列 `"null"` / `"undefined"` として書くことはありません(`@wcstack/state` は `undefined` を書きませんが、React 19 は値のあった prop を外したときに書き、直接の代入でも届きます)。
|
|
98
98
|
|
|
@@ -105,6 +105,7 @@ npm install @wcstack/magnetometer
|
|
|
105
105
|
| `z` | `wcs-magnetometer:reading` | z軸方向の磁束密度。 |
|
|
106
106
|
| `error` | `wcs-magnetometer:error` | 正規化された`{ error, message }`、無ければ`null`。 |
|
|
107
107
|
| `errorInfo` | `wcs-magnetometer:error-info-changed` | シリアライズ可能な失敗分類(`WcsIoErrorInfo` — 安定した `code` / `phase` / `recoverable`)、無ければ`null`。`error`から派生する追加的な出力で、既存の`error`の形状は不変。 |
|
|
108
|
+
| `supported` | `wcs-magnetometer:supported-changed` | 4.25 から。このページでセンサーを使えるなら`true`。[`supported`](#supported--このページで使えるか)を参照。 |
|
|
108
109
|
|
|
109
110
|
`x`/`y`/`z`は単一の`wcs-magnetometer:reading`イベントから派生します(ネイティブの1回の`reading`イベントで3軸が同時に更新される)。
|
|
110
111
|
|
|
@@ -112,9 +113,28 @@ npm install @wcstack/magnetometer
|
|
|
112
113
|
|
|
113
114
|
| コマンド | 非同期 | 説明 |
|
|
114
115
|
| -------- | ------ | ---- |
|
|
115
|
-
| `start` | いいえ | センサーを構築(never-throw: コンストラクタの同期例外はキャッチし`error`へ)し読み取りを開始する。開始済みの間は冪等(再度呼んでも何もしない)。 |
|
|
116
|
+
| `start` | いいえ | センサーを構築(never-throw: コンストラクタの同期例外はキャッチし`error`へ)し読み取りを開始する。開始済みの間は冪等(再度呼んでも何もしない)。4.25 から: センサー自身の`error`イベントの後は次の`start()`が新しいセンサーを作る。 |
|
|
116
117
|
| `stop` | いいえ | センサーを停止しリスナーを解除する。未開始でも安全に呼べる。 |
|
|
117
118
|
|
|
119
|
+
## `supported` — このページで使えるか
|
|
120
|
+
|
|
121
|
+
4.25 から。`supported` は、このページでセンサーを使えるときに `true` です: ブラウザに `Magnetometer` クラスがあり、ページが secure context で、Permissions-Policy が `magnetometer` を切っていない(サーバーのヘッダ、または `allow="magnetometer"` の無い `<iframe>`——ページが自分のポリシーを読めるブラウザ、つまり Chromium で分かります)。`false` のところでは `start()` は動かず、タップしても変わりません: 機能を出さないでください。
|
|
122
|
+
|
|
123
|
+
利用者が許可するかどうかは**言いません**(それは `<wcs-permission name="magnetometer">` が見ます)。そして**端末にセンサーがあるかどうかは言えません**: PC には API があってセンサーがありません。そこでは読み取りが来ないだけか、センサーが `error` で知らせます。
|
|
124
|
+
|
|
125
|
+
値は聞かれるたびにブラウザから読むので、バインドは張られた時点で正しい値を受け取ります。要素は接続されたときにも、最後に dispatch した値(初めは `false`)と違っていれば `wcs-magnetometer:supported-changed`(`detail` はその boolean)を dispatch します。
|
|
126
|
+
|
|
127
|
+
```html
|
|
128
|
+
<wcs-magnetometer data-wcs="supported: sensorSupported; command.start: $command.startSensor"></wcs-magnetometer>
|
|
129
|
+
<button data-wcs="hidden: sensorSupported|not; onclick: $command.startSensor">開始</button>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
(state に `sensorSupported: false` と `$commandTokens: ["startSensor"]`。)
|
|
133
|
+
|
|
134
|
+
## iPhone では
|
|
135
|
+
|
|
136
|
+
iPhone / iPad の Safari には `Magnetometer` クラスが無く、この読み取りを運ぶほかのイベントもないので、`<wcs-magnetometer>` にはフォールバックがありません。4.25 から、iPhone では `supported` が `false` になり、ページは何かを出す前にそれを読めます。`start()` はこれまでどおり `unsupported`(`errorInfo.code: "capability-missing"`)で終わります。`<wcs-accelerometer>` と `<wcs-gyroscope>` は 4.25 から `devicemotion` を通して iPhone でも動きます。方角が欲しいなら `<wcs-tilt>` の `heading` を使ってください。
|
|
137
|
+
|
|
118
138
|
## `:state()` による CSS スタイリング
|
|
119
139
|
|
|
120
140
|
`<wcs-magnetometer>` は 1 つの boolean 出力ステートを
|
|
@@ -166,7 +186,9 @@ wcs-magnetometer:state(error) ~ .fallback { display: block; }
|
|
|
166
186
|
|
|
167
187
|
- **`_gen`世代ガードは無し。** `start()`/`stop()`は同期的な購読/購読解除のトグルであり、`dispose()`とレースしうる非同期probeが存在しません(`docs/sensor-tag-design.md` §1.5)。
|
|
168
188
|
- **`error`は sticky(据え置き)です。** 最後に観測した失敗(`unsupported`、`SecurityError`等)を保持し、その後の`start()`成功や`reading`受信では自動クリアされません。`stop()`+`start()`でリトライが成功しても直前の`error`は残り続けます。必要なら利用側の state でクリア/再解釈してください。
|
|
189
|
+
- **`error`イベントの後、`start()`はまた動きます。** 4.25 から、センサーが自分の`error`イベント(たとえば`NotReadableError`)を出すと、失敗したセンサーは片付けられ、次の`start()`が新しいセンサーを作ります。4.24までは、そのエラーの後の`start()`は`stop()`を呼ぶまで何もせず、それを知らせるものもありませんでした。`error`そのものは上記のとおり残ります。
|
|
169
190
|
- **`errorInfo` 分類(taxonomy)。** 同じ失敗をシリアライズ可能な `WcsIoErrorInfo`(安定した `code` / `phase` / `recoverable`)に分類する**追加的な**バインド可能出力(`wcs-magnetometer:error-info-changed`)で、`error`の形状は変更しません。正規化された error 名に応じて対応づけます: `unsupported` → `capability-missing`(phase `probe`)、`SecurityError` / `NotAllowedError` → `not-allowed`(phase `start`)、`NotReadableError` → `not-readable`(phase `execute`)、その他のセンサー失敗 → `sensor-error`(phase `execute`)。いずれも `recoverable: false` です。`errorInfo` は `error` と完全に同じタイミングで遷移するため、同様に **sticky** で、`error` が `null` に戻るときにのみ `null` に戻ります。共有の `WcsIoErrorInfo` 型と `WCS_MAGNETOMETER_ERROR_CODE` 定数はエクスポートされます。
|
|
191
|
+
- **使えない`frequency`は知らせます。** 4.25 から、空でなく正の数でもない`frequency`属性(`frequency="60hz"`、`frequency="0"`)で`start()`が走ると、コンソールに要素ごとに 1 回警告が出ます: `[@wcstack/magnetometer] [wcs/frequency-invalid] <wcs-magnetometer> frequency="60hz" is not a positive number of Hz: the sensor runs at the browser's default rate. Write a number, e.g. frequency="30".` センサーは既定の頻度で開始します——これまでも同じでしたが、何も言いませんでした。ブラウザが許す上限を超える頻度はブラウザが丸め、それを知らせるものはありません。
|
|
170
192
|
- **`frequency`は`start()`時にのみ読み取られます。** `attributeChangedCallback`は無く、`start()`は既に開始済みの間は冪等(再度呼んでも何もしない、上記コマンド参照)であるため、稼働中に`frequency`(属性またはプロパティ)を変更しても反映されません。新しいサンプリングレートを適用するには`stop()`してから`start()`し直してください。
|
|
171
193
|
- **再親付け(別の親要素への移動)はセンサーを停止し、自動再開しません。** 接続中の`<wcs-magnetometer>`要素を別の親へ移動すると`disconnectedCallback`→`connectedCallback`が発火します。Shellは接続時に自動開始しないため(上記クイックスタート参照)、これは実質的な停止であり自動再開はされません。`x`/`y`/`z`は最後のサンプル値のまま凍結され、`error`も発生しません — `start`を再度発行するまでセンサーは inert のままです。
|
|
172
194
|
- **生の`new Magnetometer(...)`は唯一のガード付き構築ヘルパー以外では呼ばない。** 権限拒否・Permissions-Policyブロックは同期的に例外を投げます。
|
|
@@ -187,6 +209,8 @@ core.start();
|
|
|
187
209
|
core.dispose();
|
|
188
210
|
```
|
|
189
211
|
|
|
212
|
+
4.25 から、`core.supported` はいつでも読め、`core.publishSupported()` は最後に dispatch した値と違うときに `wcs-magnetometer:supported-changed` を dispatch します。
|
|
213
|
+
|
|
190
214
|
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-を直接束縛する要素なし) を参照。
|
|
191
215
|
|
|
192
216
|
## アクセシビリティ
|
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ It is an **async primitive node** that turns device magnetic field readings into
|
|
|
10
10
|
With `@wcstack/state`, `<wcs-magnetometer>` can be bound directly through path contracts:
|
|
11
11
|
|
|
12
12
|
- **input surface**: `frequency` (sampling rate in Hz)
|
|
13
|
-
- **output state surface**: `x`, `y`, `z`, `error`, `errorInfo`
|
|
13
|
+
- **output state surface**: `x`, `y`, `z`, `error`, `errorInfo`, and — since 4.25 — `supported`
|
|
14
14
|
|
|
15
15
|
This means compass/magnetic-field-driven UI can be expressed declaratively in HTML, without writing `Magnetometer`/`reading`/`error`-listener glue in your UI layer.
|
|
16
16
|
|
|
@@ -26,7 +26,7 @@ The Generic Sensor API's `Accelerometer`/`Gyroscope`/`Magnetometer`/`AmbientLigh
|
|
|
26
26
|
|
|
27
27
|
> **Compose with `@wcstack/permission`.** `navigator.permissions.query({name:"magnetometer"})` already exists — pair `<wcs-magnetometer>` with `<wcs-permission name="magnetometer">` for `granted`/`denied`/`prompt` status rather than duplicating that state here (see `docs/sensor-tag-design.md`).
|
|
28
28
|
|
|
29
|
-
> **Chromium/Android-centric support.** Desktop browsers commonly reject with `SecurityError` even when the `Magnetometer` class exists. Design any UI around `unsupported`/denied being the common case, not the exception.
|
|
29
|
+
> **Chromium/Android-centric support.** Desktop browsers commonly reject with `SecurityError` even when the `Magnetometer` class exists. Design any UI around `unsupported`/denied being the common case, not the exception. Safari on an iPhone or iPad has no `Magnetometer` class and nothing to fall back on: see [On an iPhone](#on-an-iphone).
|
|
30
30
|
|
|
31
31
|
## Install
|
|
32
32
|
|
|
@@ -95,7 +95,7 @@ Every bound state path must be declared up front — binding an undeclared path
|
|
|
95
95
|
|
|
96
96
|
| Attribute | Type | Default | Description |
|
|
97
97
|
| ----------- | ------ | ------- | ------------ |
|
|
98
|
-
| `frequency` | number | — | Sampling rate in Hz, forwarded to the `Magnetometer` constructor. Read only when `start()` runs — changing it while already started has no effect until `stop()` + `start()` (see Notes). |
|
|
98
|
+
| `frequency` | number | — | Sampling rate in Hz, forwarded to the `Magnetometer` constructor. Read only when `start()` runs — changing it while already started has no effect until `stop()` + `start()` (see Notes). Since 4.25: a value that is not a positive number is said once in the console when `start()` runs (`[wcs/frequency-invalid]`, see Notes). |
|
|
99
99
|
|
|
100
100
|
**`null` and `undefined`.** The input backed by an attribute (`frequency`) takes `null` as "clear": the attribute is removed and the input falls back to its default (the platform's sampling rate). `undefined` means "no value supplied": the attribute goes back to what it was before the first write — the value written in the markup, or none. Neither is ever written as the string `"null"` / `"undefined"`. (`@wcstack/state` never writes `undefined`; React 19 does when a prop that had a value is removed, and so can a direct assignment.)
|
|
101
101
|
|
|
@@ -108,6 +108,7 @@ Every bound state path must be declared up front — binding an undeclared path
|
|
|
108
108
|
| `z` | `wcs-magnetometer:reading` | Magnetic flux density along the z-axis. |
|
|
109
109
|
| `error` | `wcs-magnetometer:error` | Normalized `{ error, message }`, or `null`. |
|
|
110
110
|
| `errorInfo` | `wcs-magnetometer:error-info-changed` | Serializable failure taxonomy (`WcsIoErrorInfo` — stable `code` / `phase` / `recoverable`), or `null`. Additive, derived from `error`; the existing `error` shape is unchanged. |
|
|
111
|
+
| `supported` | `wcs-magnetometer:supported-changed` | Since 4.25. `true` when this page can use the sensor. See [`supported`](#supported--can-this-page-use-it). |
|
|
111
112
|
|
|
112
113
|
`x`/`y`/`z` all derive from the single `wcs-magnetometer:reading` event (one native `reading` event updates all three axes together).
|
|
113
114
|
|
|
@@ -115,9 +116,28 @@ Every bound state path must be declared up front — binding an undeclared path
|
|
|
115
116
|
|
|
116
117
|
| Command | Async | Description |
|
|
117
118
|
| ------- | ----- | ------------ |
|
|
118
|
-
| `start` | no | Construct the sensor (never-throw: a synchronous constructor exception is caught and surfaced via `error`) and begin reading. Idempotent while already started (a redundant call is a no-op). |
|
|
119
|
+
| `start` | no | Construct the sensor (never-throw: a synchronous constructor exception is caught and surfaced via `error`) and begin reading. Idempotent while already started (a redundant call is a no-op). Since 4.25: after the sensor's own `error` event the next `start()` builds a fresh sensor. |
|
|
119
120
|
| `stop` | no | Stop the sensor and detach its listeners. Safe to call when not started. |
|
|
120
121
|
|
|
122
|
+
## `supported` — can this page use it
|
|
123
|
+
|
|
124
|
+
Since 4.25. `supported` is `true` when this page can use the sensor: the browser has the `Magnetometer` class, the page is a secure context, and no Permissions-Policy turns `magnetometer` off for it (the server's header, or an `<iframe>` without `allow="magnetometer"` — read where the browser lets a page see its policy, which is Chromium). Where it is `false`, `start()` cannot work and no tap changes that: do not offer the feature.
|
|
125
|
+
|
|
126
|
+
It does **not** say that the user will allow it (`<wcs-permission name="magnetometer">` watches that), and it **cannot say whether the device has the sensor**: a PC has the API and no sensor. There the readings simply never come, or the sensor reports it through `error`.
|
|
127
|
+
|
|
128
|
+
The value is read from the browser each time it is asked for, so a binding gets the right value when it attaches; the element also dispatches `wcs-magnetometer:supported-changed` (the boolean as `detail`) when it is connected, if the value differs from the last one it dispatched (it starts at `false`).
|
|
129
|
+
|
|
130
|
+
```html
|
|
131
|
+
<wcs-magnetometer data-wcs="supported: sensorSupported; command.start: $command.startSensor"></wcs-magnetometer>
|
|
132
|
+
<button data-wcs="hidden: sensorSupported|not; onclick: $command.startSensor">Start</button>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
(`sensorSupported: false` and `$commandTokens: ["startSensor"]` on the state.)
|
|
136
|
+
|
|
137
|
+
## On an iPhone
|
|
138
|
+
|
|
139
|
+
Safari on an iPhone or iPad has no `Magnetometer` class, and no other event carries these readings, so `<wcs-magnetometer>` has no fallback there. Since 4.25, `supported` is `false` on an iPhone, which a page can read before it offers anything; `start()` ends as `unsupported` (`errorInfo.code: "capability-missing"`), as before. `<wcs-accelerometer>` and `<wcs-gyroscope>` do work on an iPhone since 4.25, through `devicemotion`; for a compass direction, use `<wcs-tilt>`'s `heading`.
|
|
140
|
+
|
|
121
141
|
## CSS styling with `:state()`
|
|
122
142
|
|
|
123
143
|
`<wcs-magnetometer>` reflects one boolean output state onto its
|
|
@@ -171,7 +191,9 @@ DevTools open; it is not a supported styling hook.
|
|
|
171
191
|
|
|
172
192
|
- **No `_gen` generation guard.** `start()`/`stop()` are a synchronous subscribe/unsubscribe toggle with no asynchronous probe to race against a `dispose()` — see `docs/sensor-tag-design.md` §1.5.
|
|
173
193
|
- **`error` is sticky.** It holds the last observed failure (e.g. `unsupported`, `SecurityError`) and is **not** auto-cleared by a later successful `start()` or by incoming `reading`s. A `stop()` + `start()` retry that succeeds still leaves the previous `error` in place — clear or reinterpret it in your own state if needed.
|
|
194
|
+
- **After an `error` event, `start()` works again.** Since 4.25, when the sensor reports its own `error` event (a `NotReadableError`, say), the failed sensor is torn down, so the next `start()` builds a fresh one. Up to 4.24 `start()` did nothing after such an error until `stop()` had been called, and nothing said so. `error` itself stays, as above.
|
|
174
195
|
- **`errorInfo` taxonomy.** An **additive** bindable output (`wcs-magnetometer:error-info-changed`) that classifies the same failure into a serializable `WcsIoErrorInfo` with a stable `code` / `phase` / `recoverable`, without changing the `error` shape. The mapping keys off the normalized error name: `unsupported` → `capability-missing` (phase `probe`); `SecurityError` / `NotAllowedError` → `not-allowed` (phase `start`); `NotReadableError` → `not-readable` (phase `execute`); any other sensor failure → `sensor-error` (phase `execute`). All are `recoverable: false`. `errorInfo` transitions exactly when `error` does, so it is **sticky** in the same way and only returns to `null` when `error` does. The shared `WcsIoErrorInfo` type and the `WCS_MAGNETOMETER_ERROR_CODE` constants are exported.
|
|
196
|
+
- **An unusable `frequency` is said.** Since 4.25, when `start()` runs with a `frequency` attribute that is not empty and is not a positive number (`frequency="60hz"`, `frequency="0"`), the console gets one warning per element: `[@wcstack/magnetometer] [wcs/frequency-invalid] <wcs-magnetometer> frequency="60hz" is not a positive number of Hz: the sensor runs at the browser's default rate. Write a number, e.g. frequency="30".` The sensor still starts, at the default rate — as it did before, without a word. A rate above what the browser allows is capped by the browser, and nothing says so.
|
|
175
197
|
- **`frequency` is read only at `start()`.** There is no `attributeChangedCallback`, and `start()` is idempotent while already started (a redundant call is a no-op — see Commands above), so changing the `frequency` attribute/property on a running sensor has no effect. To apply a new sampling rate, `stop()` then `start()` again.
|
|
176
198
|
- **Reparenting stops the sensor and does not resume it.** Moving a connected `<wcs-magnetometer>` element to a different parent runs `disconnectedCallback` → `connectedCallback`; since the Shell does not auto-start on connect (see Quick Start above), this is effectively a stop with no automatic restart. `x`/`y`/`z` freeze at their last sample, and no `error` is raised — the sensor stays inert until `start` is invoked again.
|
|
177
199
|
- **Never call the raw `new Magnetometer(...)` anywhere but the one guarded construction helper** — permission denial and Permissions-Policy blocks throw synchronously.
|
|
@@ -192,6 +214,8 @@ core.start();
|
|
|
192
214
|
core.dispose();
|
|
193
215
|
```
|
|
194
216
|
|
|
217
|
+
Since 4.25, `core.supported` can be read at any time, and `core.publishSupported()` dispatches `wcs-magnetometer:supported-changed` when the value differs from the last one dispatched.
|
|
218
|
+
|
|
195
219
|
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).
|
|
196
220
|
|
|
197
221
|
## Accessibility
|
package/dist/auto.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e={tagNames:{magnetometer:"wcs-magnetometer"}};var t="@wcstack/magnetometer",r="4.
|
|
1
|
+
const e={tagNames:{magnetometer:"wcs-magnetometer"}};var t="@wcstack/magnetometer",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 s="capability-missing",o="not-allowed",a="not-readable",i="sensor-error";const c=Object.freeze({x:null,y:null,z:null});class l extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"x",event:"wcs-magnetometer:reading",semantics:"state",getter:e=>e.detail.x},{name:"y",event:"wcs-magnetometer:reading",semantics:"state",getter:e=>e.detail.y},{name:"z",event:"wcs-magnetometer:reading",semantics:"state",getter:e=>e.detail.z},{name:"error",event:"wcs-magnetometer:error",semantics:"state"},{name:"errorInfo",event:"wcs-magnetometer:error-info-changed",semantics:"state"},{name:"supported",event:"wcs-magnetometer:supported-changed",semantics:"state"}],commands:[{name:"start"},{name:"stop"}]};_target;_reading=c;_error=null;_errorInfo=null;_supportedPublished=!1;_sensor=null;constructor(e){super(),this._target=e??this}get x(){return this._reading.x}get y(){return this._reading.y}get z(){return this._reading.z}get error(){return this._error}get errorInfo(){return this._errorInfo}get supported(){return"function"==typeof globalThis.Magnetometer&&null===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}}("magnetometer")}get ready(){return Promise.resolve()}_setReading(e){this._reading=e,this._target.dispatchEvent(new CustomEvent("wcs-magnetometer:reading",{detail:e,bubbles:!0}))}_setError(e){var t,r;this._error?.error===e?.error&&this._error?.message===e?.message||(this._error=e,this._commitErrorInfo(null===e?null:(t=e.error,r=e.message,"unsupported"===t?{code:s,phase:"probe",recoverable:!1,message:r}:"SecurityError"===t||"NotAllowedError"===t?{code:o,phase:"start",recoverable:!1,message:r}:"NotReadableError"===t?{code:a,phase:"execute",recoverable:!1,message:r}:{code:i,phase:"execute",recoverable:!1,message:r})),this._target.dispatchEvent(new CustomEvent("wcs-magnetometer:error",{detail:e,bubbles:!0})))}_commitErrorInfo(e){this._errorInfo=e,this._target.dispatchEvent(new CustomEvent("wcs-magnetometer:error-info-changed",{detail:e,bubbles:!0}))}publishSupported(){const e=this.supported;this._supportedPublished!==e&&(this._supportedPublished=e,this._target.dispatchEvent(new CustomEvent("wcs-magnetometer:supported-changed",{detail:e,bubbles:!0})))}start(e){if(this._sensor)return;const t=this._createSensor(e);if(t){t.addEventListener("reading",this._onReading),t.addEventListener("error",this._onError),this._sensor=t;try{t.start()}catch(e){this._teardownSensor(t),this._setError({error:e?.name??"error",message:e?.message??String(e)})}}}stop(){if(!this._sensor)return;const e=this._sensor;try{e.stop()}catch{}this._teardownSensor(e)}observe(e){return this.start(e),this.ready}dispose(){this.stop()}_teardownSensor(e){e?.removeEventListener("reading",this._onReading),e?.removeEventListener("error",this._onError),this._sensor===e&&(this._sensor=null)}_createSensor(e){const t=globalThis.Magnetometer;if("function"!=typeof t)return this._setError({error:"unsupported",message:"Magnetometer is not supported"}),null;try{return new t(void 0!==e?{frequency:e}:void 0)}catch(e){return this._setError({error:e?.name??"error",message:e?.message??String(e)}),null}}_onReading=e=>{const t=e.target;this._setReading({x:t.x,y:t.y,z:t.z})};_onError=e=>{const t=e.error;this._teardownSensor(this._sensor),this._setError({error:t?.name??"error",message:t?.message??"Sensor error"})}}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 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 m=new WeakMap;function g(e,t,r){const n=function(e,t){let r=m.get(e);return void 0===r&&(r=new Map,m.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 p extends HTMLElement{static hasConnectedCallbackPromise=!0;static wcBindable={...l.wcBindable,inputs:[{name:"frequency"}],commands:l.wcBindable.commands};_core;_connectedCallbackPromise=Promise.resolve();_internals=null;_frequencyWarned=!1;constructor(){super(),this._core=new l(this),this._internals=this._initInternals(),this._wireStates({"wcs-magnetometer:error":e=>({error:null!=e})})}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[s,o]of Object.entries(n(e.detail))){try{o?t.add(s):t.delete(s)}catch{}r&&this.toggleAttribute(`data-wcs-state-${s}`,o)}})}get frequency(){const e=this.getAttribute("frequency");if(null===e||""===e.trim())return null;const t=Number(e);return Number.isFinite(t)&&t>0?t:null}set frequency(e){g(this,"frequency",e)}get x(){return this._core.x}get y(){return this._core.y}get z(){return this._core.z}get error(){return this._core.error}get errorInfo(){return this._core.errorInfo}get supported(){return this._core.supported}get connectedCallbackPromise(){return this._connectedCallbackPromise}start(){this._warnUnusableFrequency(),this._core.start(this.frequency??void 0)}stop(){this._core.stop()}_warnUnusableFrequency(){if(this._frequencyWarned)return;const e=this.getAttribute("frequency");null!==e&&""!==e.trim()&&null===this.frequency&&(this._frequencyWarned=!0,console.warn(`[@wcstack/magnetometer] [wcs/frequency-invalid] <${this.localName}> frequency="${e}" is not a positive number of Hz: the sensor runs at the browser's default rate. Write a number, e.g. frequency="30".`,this))}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,s="function"==typeof n?n.call(e,r.toLowerCase()):null;if(null!==s&&s.startsWith("[object ")&&h(e,r,s),!Object.prototype.hasOwnProperty.call(e,r))continue;if(!u(e,r))continue;const o=e,a=o[r];delete o[r],o[r]=a}}(this),this.style.display="none",this._connectedCallbackPromise=this._core.ready,this._core.publishSupported()}connectedMoveCallback(){}disconnectedCallback(){this._core.dispose()}}const f=Symbol.for("wcstack.package"),b=new WeakSet;function _(e,t){Object.defineProperty(e,f,{value:t,configurable:!0})}function w(e,t,r,n,s){if(void 0!==n&&(r===n||r.prototype instanceof n))return;const o=r[f];if(o===s||b.has(e))return;b.add(e);const a=s.slice(0,s.lastIndexOf("@"));console.warn(`[${a}] [wcs/package-twice] <${t}> is already defined by ${o??`another copy of ${a} that does not name its version`}; this copy, ${s}, does nothing. Load each package once.`)}function y(n=customElements){!function(e,t,r){for(const[n,s]of r){const r=e.get(n);void 0===r?(_(s,t),e.define(n,s)):w(e,n,r,s,t)}}(n,`${t}@${r}`,[[e.tagNames.magnetometer,p]])}var v;y(v);
|
|
2
2
|
//# sourceMappingURL=auto.min.js.map
|
package/dist/auto.min.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto.min.js","sources":["../../src/config.ts","../../src/core/magnetometerCapabilities.ts","../../src/core/MagnetometerCore.ts","../../src/protocol/upgradeProperties.ts","../../src/protocol/inputAttribute.ts","../../src/components/Magnetometer.ts","../../src/protocol/defineElement.ts","../../src/registerComponents.ts","../../src/bootstrapMagnetometer.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n magnetometer: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n magnetometer: \"wcs-magnetometer\",\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: `bootstrapMagnetometer` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/magnetometer] bootstrapMagnetometer: \"${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 * magnetometerCapabilities.ts\n *\n * Magnetometer node 固有の error code(taxonomy)と derivation。汎用の error info 型は\n * `./platformCapability.js`(/io-core/ から copy-distribution される生成ファイル)から\n * import する。sensor は監視系(継続 subscribe/unsubscribe)で競合する operation を持た\n * ないため lane は持たず、error taxonomy(errorInfo)のみを採用する。\n *\n * sensor family(accelerometer / gyroscope / magnetometer / ambient-light-sensor)は\n * error 面が構造同一(`{ error: <name>, message }`、`.error` が Error.name / \"unsupported\"\n * / \"error\" fallback)なので、taxonomy も 4 兄弟で一致させる。\n */\n\nimport type { WcsIoErrorInfo } from \"./platformCapability.js\";\n\n/** 安定した magnetometer error code(taxonomy)。値は公開キーとして固定。 */\nexport const WCS_MAGNETOMETER_ERROR_CODE = {\n /** Sensor API 非対応(`globalThis.Magnetometer` 不在)。 */\n CapabilityMissing: \"capability-missing\",\n /** `SecurityError` / `NotAllowedError` — 権限拒否・feature-policy ブロック。 */\n NotAllowed: \"not-allowed\",\n /** `NotReadableError` — センサーハードウェアを読めない。 */\n NotReadable: \"not-readable\",\n /** その他の SensorErrorEvent / 想定外の失敗。 */\n SensorError: \"sensor-error\",\n} as const;\n\n/**\n * sensor の失敗を serializable な error taxonomy に写す。`name` は error detail の\n * `.error`(`Error.name` / \"unsupported\" / \"error\" fallback)。\n *\n * - \"unsupported\" は開始前の能力欠如 → phase=\"probe\" / capability-missing。\n * - `SecurityError` / `NotAllowedError` は sensor 構築時の権限拒否 → phase=\"start\" /\n * not-allowed。いずれも retry で回復しない(recoverable=false)。\n * - `NotReadableError` は稼働中のハードウェア読取失敗 → phase=\"execute\" / not-readable。\n * - それ以外(SensorErrorEvent の他 name / \"error\" fallback)は phase=\"execute\" /\n * sensor-error。\n */\nexport function deriveMagnetometerErrorInfo(name: string, message: string): WcsIoErrorInfo {\n if (name === \"unsupported\") {\n return { code: WCS_MAGNETOMETER_ERROR_CODE.CapabilityMissing, phase: \"probe\", recoverable: false, message };\n }\n if (name === \"SecurityError\" || name === \"NotAllowedError\") {\n return { code: WCS_MAGNETOMETER_ERROR_CODE.NotAllowed, phase: \"start\", recoverable: false, message };\n }\n if (name === \"NotReadableError\") {\n return { code: WCS_MAGNETOMETER_ERROR_CODE.NotReadable, phase: \"execute\", recoverable: false, message };\n }\n return { code: WCS_MAGNETOMETER_ERROR_CODE.SensorError, phase: \"execute\", recoverable: false, message };\n}\n","import { IWcBindable, WcsMagnetometerReading, WcsMagnetometerErrorDetail } from \"../types.js\";\nimport { WcsIoErrorInfo } from \"./platformCapability.js\";\nimport { deriveMagnetometerErrorInfo } from \"./magnetometerCapabilities.js\";\n\nconst NULL_READING: WcsMagnetometerReading = Object.freeze({ x: null, y: null, z: null });\n\n/**\n * Headless Magnetometer primitive. A thin, framework-agnostic wrapper around\n * the Generic Sensor API's `Magnetometer` class exposed through the\n * wc-bindable protocol.\n *\n * The platform `Sensor` base class (shared by `Accelerometer` / `Gyroscope` /\n * `Magnetometer` / `AmbientLightSensor`) reports failure through an `'error'`\n * event rather than a rejected promise, so this Core can satisfy never-throw\n * (docs/async-io-node-guidelines.md §3.6) by simply forwarding that event —\n * see docs/sensor-tag-design.md §0. The one place a synchronous\n * exception *can* still escape the platform API is the `Magnetometer`\n * constructor itself (e.g. `SecurityError` on permission denial or a\n * feature-policy block); `_createSensor()` wraps that single call in\n * try/catch, mirroring FetchCore's `_doFetch` try/catch around\n * `globalThis.fetch` (packages/fetch/src/core/FetchCore.ts).\n *\n * `x`/`y`/`z` are three getters derived from the single `wcs-magnetometer:reading`\n * event (mirroring how NetworkCore exposes effectiveType/downlink/… from one\n * `wcs-network:change` event): the native `reading` event already reports all\n * three axes together, so they are not split into independent events. `reading`\n * is an event-like signal (a fresh sample every time, not a settled state) and\n * is therefore deliberately NOT same-value guarded — every sample dispatches.\n * `error` is state-like (denial / unsupported does not change from tick to\n * tick) and IS same-value guarded, and is published on its own\n * `wcs-magnetometer:error` event, independent of `reading`.\n *\n * No `_gen` generation guard: start()/stop() are a synchronous\n * subscribe/unsubscribe toggle with no asynchronous probe whose stale\n * resolution could race a dispose() — see docs/sensor-tag-design.md §1.5\n * (the same reasoning as NetworkCore, docs/network-tag-design.md §5).\n *\n * Permissions: this Core does not query `navigator.permissions` itself.\n * Compose with `<wcs-permission name=\"magnetometer\">` instead — see\n * docs/sensor-tag-design.md §\"2番目の決定: Permissions APIとの合成\".\n */\nexport class MagnetometerCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"x\", event: \"wcs-magnetometer:reading\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.x },\n { name: \"y\", event: \"wcs-magnetometer:reading\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.y },\n { name: \"z\", event: \"wcs-magnetometer:reading\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.z },\n { name: \"error\", event: \"wcs-magnetometer:error\", semantics: \"state\" },\n // Serializable failure taxonomy (stable code / phase / recoverable), or null.\n // Additive bindable output derived from `error.error` (the Error.name /\n // \"unsupported\"); the existing `error` property/event are unchanged. Fires\n // wcs-magnetometer:error-info-changed. No lane — the sensor is a monitor.\n { name: \"errorInfo\", event: \"wcs-magnetometer:error-info-changed\", semantics: \"state\" },\n ],\n commands: [{ name: \"start\" }, { name: \"stop\" }],\n };\n\n private _target: EventTarget;\n private _reading: WcsMagnetometerReading = NULL_READING;\n private _error: WcsMagnetometerErrorDetail | null = null;\n private _errorInfo: WcsIoErrorInfo | null = null;\n\n // The live sensor instance while started (null otherwise), kept so stop()\n // can remove its listeners precisely and so start() can detect \"already\n // started\" without a separate boolean (docs/async-io-node-guidelines.md\n // §3.5 idempotency).\n private _sensor: (EventTarget & { start(): void; stop(): void }) | null = null;\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n get x(): number | null {\n return this._reading.x;\n }\n\n get y(): number | null {\n return this._reading.y;\n }\n\n get z(): number | null {\n return this._reading.z;\n }\n\n get error(): WcsMagnetometerErrorDetail | null {\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-magnetometer:error-info-changed`), derived from `error`; the existing\n * `error` property/event are unchanged.\n */\n get errorInfo(): WcsIoErrorInfo | null {\n return this._errorInfo;\n }\n\n /** No asynchronous probe to await: start()/stop() are synchronous\n * (docs/async-io-node-guidelines.md §3.8 is satisfied trivially, mirroring\n * NetworkCore). */\n get ready(): Promise<void> {\n return Promise.resolve();\n }\n\n // --- State setters ---\n\n // Deliberately NOT same-value guarded: a `reading` is a fresh sample, not a\n // settled state, so it must dispatch every time even when the values happen\n // to repeat (docs/sensor-tag-design.md §1.1).\n private _setReading(reading: WcsMagnetometerReading): void {\n this._reading = reading;\n this._target.dispatchEvent(new CustomEvent(\"wcs-magnetometer:reading\", {\n detail: reading,\n bubbles: true,\n }));\n }\n\n private _setError(error: WcsMagnetometerErrorDetail | null): void {\n // Same-value guard (by error name + message): error is state-like, unlike\n // reading — a repeated identical error (same name and message) must not\n // redispatch. Note `error` is also STICKY: nothing calls _setError(null),\n // so a successful (re)start does not clear a prior failure — the monitoring\n // sensor family deliberately keeps the last observed error (docs/sensor-tag-design.md §1.5).\n if (this._error?.error === error?.error && this._error?.message === error?.message) return;\n this._error = error;\n // Keep the additive `errorInfo` taxonomy in sync with `error`: derive from the\n // error name (or null on clear). Fires before the `error` event so an observer\n // binding both sees the classification first, mirroring the io-node family.\n this._commitErrorInfo(error === null ? null : deriveMagnetometerErrorInfo(error.error, error.message));\n this._target.dispatchEvent(new CustomEvent(\"wcs-magnetometer:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n // Called only from _setError (which already same-value-guards on the error name\n // + message), so errorInfo transitions exactly when error does — no separate\n // guard needed here.\n private _commitErrorInfo(info: WcsIoErrorInfo | null): void {\n this._errorInfo = info;\n this._target.dispatchEvent(new CustomEvent(\"wcs-magnetometer:error-info-changed\", {\n detail: info,\n bubbles: true,\n }));\n }\n\n // --- Public API ---\n\n /**\n * Start the sensor at the given `frequency` (Hz), or the platform default\n * when omitted. Idempotent while already started: a redundant start() does\n * not construct a second sensor instance (which would leak the first).\n * Restart with a different frequency via stop() + start().\n *\n * Synchronous, mirroring the native `Sensor.start()` — never throws\n * (docs/async-io-node-guidelines.md §3.6): both \"unsupported\" and a\n * synchronous constructor exception (permission denial, feature-policy\n * block) are converted to the `error` property instead of propagating.\n */\n start(frequency?: number): void {\n if (this._sensor) return;\n const sensor = this._createSensor(frequency);\n if (!sensor) return;\n sensor.addEventListener(\"reading\", this._onReading as EventListener);\n sensor.addEventListener(\"error\", this._onError as EventListener);\n this._sensor = sensor;\n try {\n sensor.start();\n } catch (e: any) {\n // Defensive: the platform contract says start()/stop() do not throw\n // (failures surface via the 'error' event), but never-throw is a hard\n // requirement here, so guard against a non-conformant implementation\n // too.\n this._teardownSensor();\n this._setError({ error: e?.name ?? \"error\", message: e?.message ?? String(e) });\n }\n }\n\n /** Stop the sensor and detach its listeners. Safe to call when not started. */\n stop(): void {\n if (!this._sensor) return;\n try {\n this._sensor.stop();\n } catch {\n // Never-throw defensive guard, symmetric with start(). Teardown below\n // still runs so listeners are detached regardless.\n }\n this._teardownSensor();\n }\n\n /** Lifecycle alias for start(), so the Shell's connectedCallback can drive\n * this Core the same way as other IO nodes' observe()/dispose() pair. No\n * asynchronous probe, so the returned promise always resolves immediately. */\n observe(frequency?: number): Promise<void> {\n this.start(frequency);\n return this.ready;\n }\n\n /** Lifecycle alias for stop(), invoked from the Shell's disconnectedCallback. */\n dispose(): void {\n this.stop();\n }\n\n // --- Internal ---\n\n // Both call sites (start()'s catch, stop()) only ever invoke this once\n // `this._sensor` is already known non-null, so there is no null-guard here\n // (nothing to defend against).\n private _teardownSensor(): void {\n this._sensor!.removeEventListener(\"reading\", this._onReading as EventListener);\n this._sensor!.removeEventListener(\"error\", this._onError as EventListener);\n this._sensor = null;\n }\n\n /**\n * Construct the platform `Magnetometer`, guarding both non-support and a\n * synchronous constructor exception. Never calls the raw `new Magnetometer(...)`\n * anywhere else in this class — see docs/sensor-tag-design.md §1.5.\n *\n * API resolution is call-time (docs/async-io-node-guidelines.md §3.7):\n * re-checked on every start(), never cached, so tests can install/remove\n * the global freely and an unsupported environment is always reported\n * correctly.\n */\n private _createSensor(frequency?: number): (EventTarget & { start(): void; stop(): void }) | null {\n const Ctor = (globalThis as any).Magnetometer;\n if (typeof Ctor !== \"function\") {\n this._setError({ error: \"unsupported\", message: \"Magnetometer is not supported\" });\n return null;\n }\n try {\n return new Ctor(frequency !== undefined ? { frequency } : undefined);\n } catch (e: any) {\n // SecurityError (permission denial, feature-policy block) or any other\n // synchronous construction failure. Mirrors the FetchCore._doFetch\n // try/catch structure (packages/fetch/src/core/FetchCore.ts) — a\n // synchronous constructor call here instead of an awaited fetch().\n this._setError({ error: e?.name ?? \"error\", message: e?.message ?? String(e) });\n return null;\n }\n }\n\n private _onReading = (event: Event): void => {\n const sensor = event.target as unknown as { x: number | null; y: number | null; z: number | null };\n this._setReading({ x: sensor.x, y: sensor.y, z: sensor.z });\n };\n\n private _onError = (event: Event): void => {\n const err = (event as any).error as { name?: string; message?: string } | undefined;\n // Fallback is a meaningful constant, NOT String(err): a SensorErrorEvent\n // without an `error` field would otherwise stringify `undefined` into the\n // literal message \"undefined\" (aligned across the sensor family).\n this._setError({ error: err?.name ?? \"error\", message: err?.message ?? \"Sensor error\" });\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, WcsMagnetometerErrorDetail } from \"../types.js\";\nimport { MagnetometerCore } from \"../core/MagnetometerCore.js\";\nimport { WcsIoErrorInfo } from \"../core/platformCapability.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute } from \"../protocol/inputAttribute.js\";\n\n/**\n * `<wcs-magnetometer>` — declarative Generic Sensor API (`Magnetometer`)\n * monitor + start/stop control.\n *\n * Unlike `<wcs-network>` / `<wcs-permission>` (pure monitors), this Shell is a\n * bidirectional node: `start`/`stop` commands (command-token: state → element)\n * alongside the `x`/`y`/`z`/`error` observable surface (event-token: element →\n * state). The `frequency` attribute is the sole configuration input, forwarded\n * to the platform `Magnetometer` constructor's `{ frequency }` option\n * (docs/sensor-tag-design.md §1.2). The getter normalizes it: a non-finite or\n * non-positive value (NaN, 0, negative) reads back as `null` — meaning \"no\n * frequency specified\" — so start() falls back to the platform default rather\n * than forwarding a value the sensor would reject. Any positive finite value is\n * passed through verbatim (no upper-bound clamping — an out-of-range-but-positive\n * rate is still left to the browser/sensor to reject via `error`).\n *\n * Permission handling is intentionally NOT implemented here. Compose with\n * `<wcs-permission name=\"magnetometer\">` instead (see the README's permission\n * example, \"Gate on permission, then start\", and docs/sensor-tag-design.md).\n */\nexport class WcsMagnetometer extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n\n static wcBindable: IWcBindable = {\n ...MagnetometerCore.wcBindable,\n inputs: [{ name: \"frequency\" }],\n // Core の commands をそのまま継承(単一情報源)。\n commands: MagnetometerCore.wcBindable.commands,\n };\n\n private _core: MagnetometerCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new MagnetometerCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-magnetometer:error\": (d) => ({ error: d != null }),\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/async-io-node-guidelines.md §3.6): attachInternals is\n // 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 // --- Attribute accessors ---\n\n /**\n * Sampling frequency in Hz. Reads back `null` when unset, blank, or when the\n * attribute does not parse to a positive finite number (NaN, `\"0\"`, negative)\n * — in every such \"no usable value\" case the platform default applies.\n *\n * Note the deliberate set/get asymmetry: `set frequency(0)` (or any\n * non-positive/non-finite value) still writes the attribute verbatim for\n * transparency/inspectability, but the getter normalizes it back to `null`.\n * A round-trip through a non-positive value therefore does NOT preserve it —\n * that value carries no valid sampling meaning, so it is treated as \"unset\"\n * on read. Only positive finite frequencies survive a set→get round-trip.\n *\n * This value is read only at `start()` time. There is no\n * `attributeChangedCallback`, and `MagnetometerCore.start()` is idempotent\n * while already started (a redundant call is a no-op), so setting\n * `frequency` (attribute or property) on an already-running sensor has no\n * effect until the caller `stop()`s and `start()`s again (see the README's\n * \"Notes & limitations\").\n */\n get frequency(): number | null {\n const attr = this.getAttribute(\"frequency\");\n if (attr === null || attr.trim() === \"\") return null;\n const parsed = Number(attr);\n return Number.isFinite(parsed) && parsed > 0 ? parsed : null;\n }\n\n set frequency(value: number | null | undefined) {\n // `null` removes the attribute (the platform default); `undefined` restores\n // the attribute the element started with — the authored frequency, or none\n // (wc-bindable producer guidance P1; React 19 and a direct assignment\n // deliver it, @wcstack/state does not).\n reflectAttribute(this, \"frequency\", value);\n }\n\n // --- Core delegated getters ---\n\n get x(): number | null {\n return this._core.x;\n }\n\n get y(): number | null {\n return this._core.y;\n }\n\n get z(): number | null {\n return this._core.z;\n }\n\n get error(): WcsMagnetometerErrorDetail | null {\n return this._core.error;\n }\n\n get errorInfo(): WcsIoErrorInfo | null {\n return this._core.errorInfo;\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Commands ---\n\n start(): void {\n this._core.start(this.frequency ?? undefined);\n }\n\n stop(): void {\n this._core.stop();\n }\n\n // --- Lifecycle ---\n\n // Deliberately does NOT auto-start the sensor on connect. Unlike\n // Geolocation (whose default phase acquires a fix immediately unless\n // `manual` is set), Magnetometer has no such \"connect implies observing\"\n // precedent in the design doc (docs/sensor-tag-design.md §1.3):\n // start/stop are the only commands, so connecting the element merely makes\n // it inert until a command-token `start` (or the `start()` method) is\n // invoked. This also keeps behavior predictable when composed with\n // `<wcs-permission name=\"magnetometer\">`: the caller decides when to start,\n // typically gated on `granted`.\n connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\n this.style.display = \"none\";\n // No asynchronous probe to await (docs/async-io-node-guidelines.md §3.8);\n // kept for SSR uniformity with other IO nodes.\n this._connectedCallbackPromise = this._core.ready;\n }\n\n // Moved by moveBefore() (a list row a reorder moves): where this element is changes nothing of what it\n // does, so nothing stops and nothing starts again. With no connectedMoveCallback the browser calls\n // disconnectedCallback and connectedCallback instead (docs/timing-and-firing-contract.md §25)\n connectedMoveCallback(): void {}\n\n disconnectedCallback(): void {\n this._core.dispose();\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 { WcsMagnetometer } from \"./components/Magnetometer.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.magnetometer, WcsMagnetometer],\n ]);\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapMagnetometer(userConfig?: IWritableConfig, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n"],"names":["config","tagNames","magnetometer","WCS_MAGNETOMETER_ERROR_CODE","NULL_READING","Object","freeze","x","y","z","MagnetometerCore","EventTarget","static","protocol","version","properties","name","event","semantics","getter","e","detail","commands","_target","_reading","_error","_errorInfo","_sensor","constructor","target","super","this","error","errorInfo","ready","Promise","resolve","_setReading","reading","dispatchEvent","CustomEvent","bubbles","_setError","message","_commitErrorInfo","code","phase","recoverable","info","start","frequency","sensor","_createSensor","addEventListener","_onReading","_onError","_teardownSensor","String","stop","observe","dispose","removeEventListener","Ctor","globalThis","Magnetometer","undefined","err","hasAccessorOnPrototype","proto","getPrototypeOf","descriptor","getOwnPropertyDescriptor","get","set","toldObjectAttribute","WeakSet","warnObjectAttribute","element","value","has","add","tag","localName","console","warn","initialAttributes","WeakMap","reflectAttribute","el","initial","byName","Map","getAttribute","initialAttribute","removeAttribute","setAttribute","writeAttribute","WcsMagnetometer","HTMLElement","wcBindable","inputs","_core","_connectedCallbackPromise","_internals","_initInternals","_wireStates","d","debugStates","states","attachInternals","internals","delete","map","toStates","entries","debug","hasAttribute","on","toggleAttribute","attr","trim","parsed","Number","isFinite","connectedCallbackPromise","connectedCallback","declaration","input","attribute","call","toLowerCase","startsWith","prototype","hasOwnProperty","record","upgradeProperties","style","display","connectedMoveCallback","disconnectedCallback","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,aAAc,8DCMX,MAAMC,EAEQ,qBAFRA,EAIC,cAJDA,EAME,eANFA,EAQE,eCpBf,MAAMC,EAAuCC,OAAOC,OAAO,CAAEC,EAAG,KAAMC,EAAG,KAAMC,EAAG,OAqC5E,MAAOC,UAAyBC,YACpCC,kBAAiC,CAC/BC,SAAU,cACVC,QAAS,EACTC,WAAY,CACV,CAAEC,KAAM,IAAKC,MAAO,2BAA4BC,UAAW,QAASC,OAASC,GAAcA,EAAkBC,OAAOd,GACpH,CAAES,KAAM,IAAKC,MAAO,2BAA4BC,UAAW,QAASC,OAASC,GAAcA,EAAkBC,OAAOb,GACpH,CAAEQ,KAAM,IAAKC,MAAO,2BAA4BC,UAAW,QAASC,OAASC,GAAcA,EAAkBC,OAAOZ,GACpH,CAAEO,KAAM,QAASC,MAAO,yBAA0BC,UAAW,SAK7D,CAAEF,KAAM,YAAaC,MAAO,sCAAuCC,UAAW,UAEhFI,SAAU,CAAC,CAAEN,KAAM,SAAW,CAAEA,KAAM,UAGhCO,QACAC,SAAmCpB,EACnCqB,OAA4C,KAC5CC,WAAoC,KAMpCC,QAAkE,KAE1E,WAAAC,CAAYC,GACVC,QACAC,KAAKR,QAAUM,GAAUE,IAC3B,CAEA,KAAIxB,GACF,OAAOwB,KAAKP,S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C,EACArE,EACAsE,EACAC,EACAN,GAEA,QAAYjF,IAARuF,IAAsBD,IAAaC,GAAOD,EAASnB,qBAAqBoB,GAAM,OAClF,MAAMC,EAAUF,EAAqBX,GACrC,GAAIa,IAAWP,GAAOH,EAAOhE,IAAIuE,GAAW,OAC5CP,EAAO/D,IAAIsE,GACX,MAAMtI,EAAOkI,EAAIQ,MAAM,EAAGR,EAAIS,YAAY,MAC1CxE,QAAQC,KACN,IAAIpE,2BAA8BiE,4BAC/BwE,GAAU,mBAAmBzI,kDAClBkI,2CAElB,CC5CM,SAAUU,EAAmBN,EAAkCO,0BDoDnEP,EACAJ,EACAY,GAEA,IAAK,MAAO7E,EAAKgE,KAAQa,EAAa,CACpC,MAAMP,EAAWD,EAAS9E,IAAIS,QACbhB,IAAbsF,GACFP,EAAaC,EAAKC,GAClBI,EAASS,OAAO9E,EAAKgE,IAErBI,EAAkBC,EAAUrE,EAAKsE,EAAUN,EAAKC,EAEpD,CACF,CChEEc,CAAeV,EAAU,GAAGJ,KAAYA,IAAe,CACrD,CAAClJ,EAAOC,SAASC,aAAc+F,IAEnC,CCVM,IAA8DqD,EAIlEM,EAAmBN"}
|
|
1
|
+
{"version":3,"file":"auto.min.js","sources":["../../src/config.ts","../../src/core/platformCapability.ts","../../src/core/magnetometerCapabilities.ts","../../src/core/MagnetometerCore.ts","../../src/protocol/upgradeProperties.ts","../../src/protocol/inputAttribute.ts","../../src/components/Magnetometer.ts","../../src/protocol/defineElement.ts","../../src/registerComponents.ts","../../src/bootstrapMagnetometer.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n magnetometer: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n magnetometer: \"wcs-magnetometer\",\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: `bootstrapMagnetometer` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/magnetometer] bootstrapMagnetometer: \"${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 * magnetometerCapabilities.ts\n *\n * Magnetometer node 固有の error code(taxonomy)と derivation。汎用の error info 型は\n * `./platformCapability.js`(/io-core/ から copy-distribution される生成ファイル)から\n * import する。sensor は監視系(継続 subscribe/unsubscribe)で競合する operation を持た\n * ないため lane は持たず、error taxonomy(errorInfo)のみを採用する。\n *\n * sensor family(accelerometer / gyroscope / magnetometer / ambient-light-sensor)は\n * error 面が構造同一(`{ error: <name>, message }`、`.error` が Error.name / \"unsupported\"\n * / \"error\" fallback)なので、taxonomy も 4 兄弟で一致させる。\n */\n\nimport type { WcsIoErrorInfo } from \"./platformCapability.js\";\n\n/** 安定した magnetometer error code(taxonomy)。値は公開キーとして固定。 */\nexport const WCS_MAGNETOMETER_ERROR_CODE = {\n /** Sensor API 非対応(`globalThis.Magnetometer` 不在)。 */\n CapabilityMissing: \"capability-missing\",\n /** `SecurityError` / `NotAllowedError` — 権限拒否・feature-policy ブロック。 */\n NotAllowed: \"not-allowed\",\n /** `NotReadableError` — センサーハードウェアを読めない。 */\n NotReadable: \"not-readable\",\n /** その他の SensorErrorEvent / 想定外の失敗。 */\n SensorError: \"sensor-error\",\n} as const;\n\n/**\n * sensor の失敗を serializable な error taxonomy に写す。`name` は error detail の\n * `.error`(`Error.name` / \"unsupported\" / \"error\" fallback)。\n *\n * - \"unsupported\" は開始前の能力欠如 → phase=\"probe\" / capability-missing。\n * - `SecurityError` / `NotAllowedError` は sensor 構築時の権限拒否 → phase=\"start\" /\n * not-allowed。いずれも retry で回復しない(recoverable=false)。\n * - `NotReadableError` は稼働中のハードウェア読取失敗 → phase=\"execute\" / not-readable。\n * - それ以外(SensorErrorEvent の他 name / \"error\" fallback)は phase=\"execute\" /\n * sensor-error。\n */\nexport function deriveMagnetometerErrorInfo(name: string, message: string): WcsIoErrorInfo {\n if (name === \"unsupported\") {\n return { code: WCS_MAGNETOMETER_ERROR_CODE.CapabilityMissing, phase: \"probe\", recoverable: false, message };\n }\n if (name === \"SecurityError\" || name === \"NotAllowedError\") {\n return { code: WCS_MAGNETOMETER_ERROR_CODE.NotAllowed, phase: \"start\", recoverable: false, message };\n }\n if (name === \"NotReadableError\") {\n return { code: WCS_MAGNETOMETER_ERROR_CODE.NotReadable, phase: \"execute\", recoverable: false, message };\n }\n return { code: WCS_MAGNETOMETER_ERROR_CODE.SensorError, phase: \"execute\", recoverable: false, message };\n}\n","import { IWcBindable, WcsMagnetometerReading, WcsMagnetometerErrorDetail } from \"../types.js\";\nimport { WcsIoErrorInfo, featureUnavailable } from \"./platformCapability.js\";\nimport { deriveMagnetometerErrorInfo } from \"./magnetometerCapabilities.js\";\n\nconst NULL_READING: WcsMagnetometerReading = Object.freeze({ x: null, y: null, z: null });\n\ntype SensorLike = EventTarget & { start(): void; stop(): void };\n\n/**\n * Headless Magnetometer primitive. A thin, framework-agnostic wrapper around\n * the Generic Sensor API's `Magnetometer` class exposed through the\n * wc-bindable protocol.\n *\n * The platform `Sensor` base class (shared by `Accelerometer` / `Gyroscope` /\n * `Magnetometer` / `AmbientLightSensor`) reports failure through an `'error'`\n * event rather than a rejected promise, so this Core can satisfy never-throw\n * (docs/async-io-node-guidelines.md §3.6) by simply forwarding that event —\n * see docs/sensor-tag-design.md §0. The one place a synchronous\n * exception *can* still escape the platform API is the `Magnetometer`\n * constructor itself (e.g. `SecurityError` on permission denial or a\n * feature-policy block); `_createSensor()` wraps that single call in\n * try/catch, mirroring FetchCore's `_doFetch` try/catch around\n * `globalThis.fetch` (packages/fetch/src/core/FetchCore.ts).\n *\n * `x`/`y`/`z` are three getters derived from the single `wcs-magnetometer:reading`\n * event (mirroring how NetworkCore exposes effectiveType/downlink/… from one\n * `wcs-network:change` event): the native `reading` event already reports all\n * three axes together, so they are not split into independent events. `reading`\n * is an event-like signal (a fresh sample every time, not a settled state) and\n * is therefore deliberately NOT same-value guarded — every sample dispatches.\n * `error` is state-like (denial / unsupported does not change from tick to\n * tick) and IS same-value guarded, and is published on its own\n * `wcs-magnetometer:error` event, independent of `reading`.\n *\n * No `_gen` generation guard: start()/stop() are a synchronous\n * subscribe/unsubscribe toggle with no asynchronous probe whose stale\n * resolution could race a dispose() — see docs/sensor-tag-design.md §1.5\n * (the same reasoning as NetworkCore, docs/network-tag-design.md §5).\n *\n * Permissions: this Core does not query `navigator.permissions` itself.\n * Compose with `<wcs-permission name=\"magnetometer\">` instead — see\n * docs/sensor-tag-design.md §\"2番目の決定: Permissions APIとの合成\".\n */\nexport class MagnetometerCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"x\", event: \"wcs-magnetometer:reading\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.x },\n { name: \"y\", event: \"wcs-magnetometer:reading\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.y },\n { name: \"z\", event: \"wcs-magnetometer:reading\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.z },\n { name: \"error\", event: \"wcs-magnetometer:error\", semantics: \"state\" },\n // Serializable failure taxonomy (stable code / phase / recoverable), or null.\n // Additive bindable output derived from `error.error` (the Error.name /\n // \"unsupported\"); the existing `error` property/event are unchanged. Fires\n // wcs-magnetometer:error-info-changed. No lane — the sensor is a monitor.\n { name: \"errorInfo\", event: \"wcs-magnetometer:error-info-changed\", semantics: \"state\" },\n // This page can use the sensor: the `Magnetometer` class is there and neither a\n // Permissions-Policy nor an insecure context forbids it. Not whether the\n // device has a sensor, and not whether the user will allow it.\n { name: \"supported\", event: \"wcs-magnetometer:supported-changed\", semantics: \"state\" },\n ],\n commands: [{ name: \"start\" }, { name: \"stop\" }],\n };\n\n private _target: EventTarget;\n private _reading: WcsMagnetometerReading = NULL_READING;\n private _error: WcsMagnetometerErrorDetail | null = null;\n private _errorInfo: WcsIoErrorInfo | null = null;\n // The value the last wcs-magnetometer:supported-changed carried (none yet: false).\n private _supportedPublished = false;\n\n // The live sensor instance while started (null otherwise), kept so stop()\n // can remove its listeners precisely and so start() can detect \"already\n // started\" without a separate boolean (docs/async-io-node-guidelines.md\n // §3.5 idempotency).\n private _sensor: SensorLike | null = null;\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n get x(): number | null {\n return this._reading.x;\n }\n\n get y(): number | null {\n return this._reading.y;\n }\n\n get z(): number | null {\n return this._reading.z;\n }\n\n get error(): WcsMagnetometerErrorDetail | null {\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-magnetometer:error-info-changed`), derived from `error`; the existing\n * `error` property/event are unchanged.\n */\n get errorInfo(): WcsIoErrorInfo | null {\n return this._errorInfo;\n }\n\n /**\n * Whether this page can use the sensor: the `Magnetometer` class is there, and\n * neither an insecure context nor a Permissions-Policy that forbids\n * `magnetometer` is in the way. Read at call time, never cached. It cannot\n * say whether the device has a sensor.\n */\n get supported(): boolean {\n return typeof (globalThis as any).Magnetometer === \"function\" && featureUnavailable(\"magnetometer\") === null;\n }\n\n /** No asynchronous probe to await: start()/stop() are synchronous\n * (docs/async-io-node-guidelines.md §3.8 is satisfied trivially, mirroring\n * NetworkCore). */\n get ready(): Promise<void> {\n return Promise.resolve();\n }\n\n // --- State setters ---\n\n // Deliberately NOT same-value guarded: a `reading` is a fresh sample, not a\n // settled state, so it must dispatch every time even when the values happen\n // to repeat (docs/sensor-tag-design.md §1.1).\n private _setReading(reading: WcsMagnetometerReading): void {\n this._reading = reading;\n this._target.dispatchEvent(new CustomEvent(\"wcs-magnetometer:reading\", {\n detail: reading,\n bubbles: true,\n }));\n }\n\n private _setError(error: WcsMagnetometerErrorDetail | null): void {\n // Same-value guard (by error name + message): error is state-like, unlike\n // reading — a repeated identical error (same name and message) must not\n // redispatch. Note `error` is also STICKY: nothing calls _setError(null),\n // so a successful (re)start does not clear a prior failure — the monitoring\n // sensor family deliberately keeps the last observed error (docs/sensor-tag-design.md §1.5).\n if (this._error?.error === error?.error && this._error?.message === error?.message) return;\n this._error = error;\n // Keep the additive `errorInfo` taxonomy in sync with `error`: derive from the\n // error name (or null on clear). Fires before the `error` event so an observer\n // binding both sees the classification first, mirroring the io-node family.\n this._commitErrorInfo(error === null ? null : deriveMagnetometerErrorInfo(error.error, error.message));\n this._target.dispatchEvent(new CustomEvent(\"wcs-magnetometer:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n // Called only from _setError (which already same-value-guards on the error name\n // + message), so errorInfo transitions exactly when error does — no separate\n // guard needed here.\n private _commitErrorInfo(info: WcsIoErrorInfo | null): void {\n this._errorInfo = info;\n this._target.dispatchEvent(new CustomEvent(\"wcs-magnetometer:error-info-changed\", {\n detail: info,\n bubbles: true,\n }));\n }\n\n // --- Public API ---\n\n /**\n * Dispatch `wcs-magnetometer:supported-changed` when `supported` differs\n * from the value last dispatched (false before the first). The Shell calls it\n * on connect, so a listener other than a binding — which reads the property\n * when it binds — learns the value too.\n */\n publishSupported(): void {\n const supported = this.supported;\n if (this._supportedPublished === supported) return;\n this._supportedPublished = supported;\n this._target.dispatchEvent(new CustomEvent(\"wcs-magnetometer:supported-changed\", {\n detail: supported,\n bubbles: true,\n }));\n }\n\n /**\n * Start the sensor at the given `frequency` (Hz), or the platform default\n * when omitted. Idempotent while already started: a redundant start() does\n * not construct a second sensor instance (which would leak the first).\n * Restart with a different frequency via stop() + start().\n *\n * Synchronous, mirroring the native `Sensor.start()` — never throws\n * (docs/async-io-node-guidelines.md §3.6): both \"unsupported\" and a\n * synchronous constructor exception (permission denial, feature-policy\n * block) are converted to the `error` property instead of propagating.\n */\n start(frequency?: number): void {\n if (this._sensor) return;\n const sensor = this._createSensor(frequency);\n if (!sensor) return;\n sensor.addEventListener(\"reading\", this._onReading as EventListener);\n sensor.addEventListener(\"error\", this._onError as EventListener);\n this._sensor = sensor;\n try {\n sensor.start();\n } catch (e: any) {\n // Defensive: the platform contract says start()/stop() do not throw\n // (failures surface via the 'error' event), but never-throw is a hard\n // requirement here, so guard against a non-conformant implementation\n // too.\n this._teardownSensor(sensor);\n this._setError({ error: e?.name ?? \"error\", message: e?.message ?? String(e) });\n }\n }\n\n /** Stop the sensor and detach its listeners. Safe to call when not started. */\n stop(): void {\n if (!this._sensor) return;\n const sensor = this._sensor;\n try {\n sensor.stop();\n } catch {\n // Never-throw defensive guard, symmetric with start(). Teardown below\n // still runs so listeners are detached regardless.\n }\n this._teardownSensor(sensor);\n }\n\n /** Lifecycle alias for start(), so the Shell's connectedCallback can drive\n * this Core the same way as other IO nodes' observe()/dispose() pair. No\n * asynchronous probe, so the returned promise always resolves immediately. */\n observe(frequency?: number): Promise<void> {\n this.start(frequency);\n return this.ready;\n }\n\n /** Lifecycle alias for stop(), invoked from the Shell's disconnectedCallback. */\n dispose(): void {\n this.stop();\n }\n\n // --- Internal ---\n\n // Detach a sensor that is finished: stopped, failed in start(), or reported\n // an `error` event. A sensor whose `error` event arrives while its start()\n // is still running, and whose start() then throws, is torn down twice: the\n // second time its listeners are already off, which removeEventListener\n // takes — and a start() from an `error` listener may have put a newer\n // sensor in its place by then, which stays.\n private _teardownSensor(sensor: SensorLike | null): void {\n sensor?.removeEventListener(\"reading\", this._onReading as EventListener);\n sensor?.removeEventListener(\"error\", this._onError as EventListener);\n if (this._sensor === sensor) this._sensor = null;\n }\n\n /**\n * Construct the platform `Magnetometer`, guarding both non-support and a\n * synchronous constructor exception. Never calls the raw `new Magnetometer(...)`\n * anywhere else in this class — see docs/sensor-tag-design.md §1.5.\n *\n * API resolution is call-time (docs/async-io-node-guidelines.md §3.7):\n * re-checked on every start(), never cached, so tests can install/remove\n * the global freely and an unsupported environment is always reported\n * correctly.\n */\n private _createSensor(frequency?: number): SensorLike | null {\n const Ctor = (globalThis as any).Magnetometer;\n if (typeof Ctor !== \"function\") {\n this._setError({ error: \"unsupported\", message: \"Magnetometer is not supported\" });\n return null;\n }\n try {\n return new Ctor(frequency !== undefined ? { frequency } : undefined);\n } catch (e: any) {\n // SecurityError (permission denial, feature-policy block) or any other\n // synchronous construction failure. Mirrors the FetchCore._doFetch\n // try/catch structure (packages/fetch/src/core/FetchCore.ts) — a\n // synchronous constructor call here instead of an awaited fetch().\n this._setError({ error: e?.name ?? \"error\", message: e?.message ?? String(e) });\n return null;\n }\n }\n\n private _onReading = (event: Event): void => {\n const sensor = event.target as unknown as { x: number | null; y: number | null; z: number | null };\n this._setReading({ x: sensor.x, y: sensor.y, z: sensor.z });\n };\n\n private _onError = (event: Event): void => {\n const err = (event as any).error as { name?: string; message?: string } | undefined;\n // The sensor that reported the error is finished (the platform deactivates\n // it): detach it before publishing, so the next start() builds a fresh one\n // instead of taking this one for \"already started\". It is `_sensor`: this\n // listener is on a sensor only while that sensor is the current one.\n this._teardownSensor(this._sensor);\n // Fallback is a meaningful constant, NOT String(err): a SensorErrorEvent\n // without an `error` field would otherwise stringify `undefined` into the\n // literal message \"undefined\" (aligned across the sensor family).\n this._setError({ error: err?.name ?? \"error\", message: err?.message ?? \"Sensor error\" });\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, WcsMagnetometerErrorDetail } from \"../types.js\";\nimport { MagnetometerCore } from \"../core/MagnetometerCore.js\";\nimport { WcsIoErrorInfo } from \"../core/platformCapability.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute } from \"../protocol/inputAttribute.js\";\n\n/**\n * `<wcs-magnetometer>` — declarative Generic Sensor API (`Magnetometer`)\n * monitor + start/stop control.\n *\n * Unlike `<wcs-network>` / `<wcs-permission>` (pure monitors), this Shell is a\n * bidirectional node: `start`/`stop` commands (command-token: state → element)\n * alongside the `x`/`y`/`z`/`error` observable surface (event-token: element →\n * state). The `frequency` attribute is the sole configuration input, forwarded\n * to the platform `Magnetometer` constructor's `{ frequency }` option\n * (docs/sensor-tag-design.md §1.2). The getter normalizes it: a non-finite or\n * non-positive value (NaN, 0, negative) reads back as `null` — meaning \"no\n * frequency specified\" — so start() falls back to the platform default rather\n * than forwarding a value the sensor would reject, and says so once\n * (`[wcs/frequency-invalid]`). Any positive finite value is passed through\n * verbatim (no upper-bound clamping — the browser caps a rate above what it\n * allows).\n *\n * Permission handling is intentionally NOT implemented here. Compose with\n * `<wcs-permission name=\"magnetometer\">` instead (see the README's permission\n * example, \"Gate on permission, then start\", and docs/sensor-tag-design.md).\n */\nexport class WcsMagnetometer extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n\n static wcBindable: IWcBindable = {\n ...MagnetometerCore.wcBindable,\n inputs: [{ name: \"frequency\" }],\n // Core の commands をそのまま継承(単一情報源)。\n commands: MagnetometerCore.wcBindable.commands,\n };\n\n private _core: MagnetometerCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n private _frequencyWarned = false;\n\n constructor() {\n super();\n this._core = new MagnetometerCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-magnetometer:error\": (d) => ({ error: d != null }),\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/async-io-node-guidelines.md §3.6): attachInternals is\n // 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 // --- Attribute accessors ---\n\n /**\n * Sampling frequency in Hz. Reads back `null` when unset, blank, or when the\n * attribute does not parse to a positive finite number (NaN, `\"0\"`, negative)\n * — in every such \"no usable value\" case the platform default applies.\n *\n * Note the deliberate set/get asymmetry: `set frequency(0)` (or any\n * non-positive/non-finite value) still writes the attribute verbatim for\n * transparency/inspectability, but the getter normalizes it back to `null`.\n * A round-trip through a non-positive value therefore does NOT preserve it —\n * that value carries no valid sampling meaning, so it is treated as \"unset\"\n * on read. Only positive finite frequencies survive a set→get round-trip.\n *\n * This value is read only at `start()` time. There is no\n * `attributeChangedCallback`, and `MagnetometerCore.start()` is idempotent\n * while already started (a redundant call is a no-op), so setting\n * `frequency` (attribute or property) on an already-running sensor has no\n * effect until the caller `stop()`s and `start()`s again (see the README's\n * \"Notes & limitations\").\n */\n get frequency(): number | null {\n const attr = this.getAttribute(\"frequency\");\n if (attr === null || attr.trim() === \"\") return null;\n const parsed = Number(attr);\n return Number.isFinite(parsed) && parsed > 0 ? parsed : null;\n }\n\n set frequency(value: number | null | undefined) {\n // `null` removes the attribute (the platform default); `undefined` restores\n // the attribute the element started with — the authored frequency, or none\n // (wc-bindable producer guidance P1; React 19 and a direct assignment\n // deliver it, @wcstack/state does not).\n reflectAttribute(this, \"frequency\", value);\n }\n\n // --- Core delegated getters ---\n\n get x(): number | null {\n return this._core.x;\n }\n\n get y(): number | null {\n return this._core.y;\n }\n\n get z(): number | null {\n return this._core.z;\n }\n\n get error(): WcsMagnetometerErrorDetail | null {\n return this._core.error;\n }\n\n get errorInfo(): WcsIoErrorInfo | null {\n return this._core.errorInfo;\n }\n\n // Computed at call time: a binding reads it when it binds, with no event.\n get supported(): boolean {\n return this._core.supported;\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Commands ---\n\n start(): void {\n this._warnUnusableFrequency();\n this._core.start(this.frequency ?? undefined);\n }\n\n stop(): void {\n this._core.stop();\n }\n\n // A `frequency` that is written but is not a positive number (\"60hz\", \"0\")\n // reads back as null, and the sensor then runs at the browser's default rate\n // with nothing else saying so. Said once per element.\n private _warnUnusableFrequency(): void {\n if (this._frequencyWarned) return;\n const attr = this.getAttribute(\"frequency\");\n if (attr === null || attr.trim() === \"\" || this.frequency !== null) return;\n this._frequencyWarned = true;\n console.warn(\n `[@wcstack/magnetometer] [wcs/frequency-invalid] <${this.localName}> frequency=\"${attr}\" is not a ` +\n `positive number of Hz: the sensor runs at the browser's default rate. Write a number, e.g. frequency=\"30\".`,\n this,\n );\n }\n\n // --- Lifecycle ---\n\n // Deliberately does NOT auto-start the sensor on connect. Unlike\n // Geolocation (whose default phase acquires a fix immediately unless\n // `manual` is set), Magnetometer has no such \"connect implies observing\"\n // precedent in the design doc (docs/sensor-tag-design.md §1.3):\n // start/stop are the only commands, so connecting the element merely makes\n // it inert until a command-token `start` (or the `start()` method) is\n // invoked. This also keeps behavior predictable when composed with\n // `<wcs-permission name=\"magnetometer\">`: the caller decides when to start,\n // typically gated on `granted`.\n connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\n this.style.display = \"none\";\n // No asynchronous probe to await (docs/async-io-node-guidelines.md §3.8);\n // kept for SSR uniformity with other IO nodes.\n this._connectedCallbackPromise = this._core.ready;\n // Starts nothing: publishes `supported` when it differs from the value last dispatched.\n this._core.publishSupported();\n }\n\n // Moved by moveBefore() (a list row a reorder moves): where this element is changes nothing of what it\n // does, so nothing stops and nothing starts again. With no connectedMoveCallback the browser calls\n // disconnectedCallback and connectedCallback instead (docs/timing-and-firing-contract.md §25)\n connectedMoveCallback(): void {}\n\n disconnectedCallback(): void {\n this._core.dispose();\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 { WcsMagnetometer } from \"./components/Magnetometer.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.magnetometer, WcsMagnetometer],\n ]);\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapMagnetometer(userConfig?: IWritableConfig, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n"],"names":["config","tagNames","magnetometer","POLICY_CONTROLLED","Set","WCS_MAGNETOMETER_ERROR_CODE","NULL_READING","Object","freeze","x","y","z","MagnetometerCore","EventTarget","static","protocol","version","properties","name","event","semantics","getter","e","detail","commands","_target","_reading","_error","_errorInfo","_supportedPublished","_sensor","constructor","target","super","this","error","errorInfo","supported","globalThis","Magnetometer","feature","g","isSecureContext","has","policy","document","permissionsPolicy","featurePolicy","undefined","allowsFeature","features","includes","featureUnavailable","ready","Promise","resolve","_setReading","reading","dispatchEvent","CustomEvent","bubbles","_setError","message","_commitErrorInfo","code","phase","recoverable","info","publishSupported","start","frequency","sensor","_createSensor","addEventListener","_onReading","_onError","_teardownSensor","String","stop","observe","dispose","removeEventListener","Ctor","err","hasAccessorOnPrototype","proto","getPrototypeOf","descriptor","getOwnPropertyDescriptor","get","set","toldObjectAttribute","WeakSet","warnObjectAttribute","element","value","add","tag","localName","console","warn","initialAttributes","WeakMap","reflectAttribute","el","initial","byName","Map","getAttribute","initialAttribute","removeAttribute","setAttribute","writeAttribute","WcsMagnetometer","HTMLElement","wcBindable","inputs","_core","_connectedCallbackPromise","_internals","_frequencyWarned","_initInternals","_wireStates","d","debugStates","states","attachInternals","internals","delete","map","toStates","entries","debug","hasAttribute","on","toggleAttribute","attr","trim","parsed","Number","isFinite","connectedCallbackPromise","_warnUnusableFrequency","connectedCallback","declaration","input","attribute","call","toLowerCase","startsWith","prototype","hasOwnProperty","record","upgradeProperties","style","display","connectedMoveCallback","disconnectedCallback","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,aAAc,8DCoJlB,MAAMC,EAAoB,IAAIC,IAAI,CAChC,SAAU,aAAc,cAAe,OAAQ,iBAAkB,kBACjE,mBAAoB,iBAAkB,gBAAiB,YAAa,eACpE,uBAAwB,kBAAmB,aAAc,qBAAsB,cCjJ1E,MAAMC,EAEQ,qBAFRA,EAIC,cAJDA,EAME,eANFA,EAQE,eCpBf,MAAMC,EAAuCC,OAAOC,OAAO,CAAEC,EAAG,KAAMC,EAAG,KAAMC,EAAG,OAuC5E,MAAOC,UAAyBC,YACpCC,kBAAiC,CAC/BC,SAAU,cACVC,QAAS,EACTC,WAAY,CACV,CAAEC,KAAM,IAAKC,MAAO,2BAA4BC,UAAW,QAASC,OAASC,GAAcA,EAAkBC,OAAOd,GACpH,CAAES,KAAM,IAAKC,MAAO,2BAA4BC,UAAW,QAASC,OAASC,GAAcA,EAAkBC,OAAOb,GACpH,CAAEQ,KAAM,IAAKC,MAAO,2BAA4BC,UAAW,QAASC,OAASC,GAAcA,EAAkBC,OAAOZ,GACpH,CAAEO,KAAM,QAASC,MAAO,yBAA0BC,UAAW,SAK7D,CAAEF,KAAM,YAAaC,MAAO,sCAAuCC,UAAW,SAI9E,CAAEF,KAAM,YAAaC,MAAO,qCAAsCC,UAAW,UAE/EI,SAAU,CAAC,CAAEN,KAAM,SAAW,CAAEA,KAAM,UAGhCO,QACAC,SAAmCpB,EACnCqB,OAA4C,KAC5CC,WAAoC,KAEpCC,qBAAsB,EAMtBC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EACAC,EACAN,GAEA,QAAYpH,IAAR0H,IAAsBD,IAAaC,GAAOD,EAASnB,qBAAqBoB,GAAM,OAClF,MAAMC,EAAUF,EAAqBX,GACrC,GAAIa,IAAWP,GAAOH,EAAOtH,IAAI6H,GAAW,OAC5CP,EAAOjE,IAAIwE,GACX,MAAMtJ,EAAOkJ,EAAIQ,MAAM,EAAGR,EAAIS,YAAY,MAC1C1E,QAAQC,KACN,IAAIlF,2BAA8B+E,4BAC/B0E,GAAU,mBAAmBzJ,kDAClBkJ,2CAElB,CC5CM,SAAUU,EAAmBN,EAAkCO,0BDoDnEP,EACAJ,EACAY,GAEA,IAAK,MAAO/E,EAAKkE,KAAQa,EAAa,CACpC,MAAMP,EAAWD,EAAS/E,IAAIQ,QACbjD,IAAbyH,GACFP,EAAaC,EAAKC,GAClBI,EAASS,OAAOhF,EAAKkE,IAErBI,EAAkBC,EAAUvE,EAAKwE,EAAUN,EAAKC,EAEpD,CACF,CChEEc,CAAeV,EAAU,GAAGJ,KAAYA,IAAe,CACrD,CAACpK,EAAOC,SAASC,aAAc+G,IAEnC,CCVM,IAA8DuD,EAIlEM,EAAmBN"}
|
package/dist/index.d.ts
CHANGED
|
@@ -95,6 +95,8 @@ interface WcsMagnetometerCoreValues extends WcsMagnetometerReading {
|
|
|
95
95
|
error: WcsMagnetometerErrorDetail | null;
|
|
96
96
|
/** Additive failure taxonomy derived from `error` (stable code / phase / recoverable). */
|
|
97
97
|
errorInfo: WcsIoErrorInfo | null;
|
|
98
|
+
/** This page can use the sensor (the API is there and the page is not forbidden to use it). */
|
|
99
|
+
supported: boolean;
|
|
98
100
|
}
|
|
99
101
|
/**
|
|
100
102
|
* Value types for the Shell (`<wcs-magnetometer>`) — identical observable
|
|
@@ -147,6 +149,7 @@ declare class MagnetometerCore extends EventTarget {
|
|
|
147
149
|
private _reading;
|
|
148
150
|
private _error;
|
|
149
151
|
private _errorInfo;
|
|
152
|
+
private _supportedPublished;
|
|
150
153
|
private _sensor;
|
|
151
154
|
constructor(target?: EventTarget);
|
|
152
155
|
get x(): number | null;
|
|
@@ -160,6 +163,13 @@ declare class MagnetometerCore extends EventTarget {
|
|
|
160
163
|
* `error` property/event are unchanged.
|
|
161
164
|
*/
|
|
162
165
|
get errorInfo(): WcsIoErrorInfo | null;
|
|
166
|
+
/**
|
|
167
|
+
* Whether this page can use the sensor: the `Magnetometer` class is there, and
|
|
168
|
+
* neither an insecure context nor a Permissions-Policy that forbids
|
|
169
|
+
* `magnetometer` is in the way. Read at call time, never cached. It cannot
|
|
170
|
+
* say whether the device has a sensor.
|
|
171
|
+
*/
|
|
172
|
+
get supported(): boolean;
|
|
163
173
|
/** No asynchronous probe to await: start()/stop() are synchronous
|
|
164
174
|
* (docs/async-io-node-guidelines.md §3.8 is satisfied trivially, mirroring
|
|
165
175
|
* NetworkCore). */
|
|
@@ -167,6 +177,13 @@ declare class MagnetometerCore extends EventTarget {
|
|
|
167
177
|
private _setReading;
|
|
168
178
|
private _setError;
|
|
169
179
|
private _commitErrorInfo;
|
|
180
|
+
/**
|
|
181
|
+
* Dispatch `wcs-magnetometer:supported-changed` when `supported` differs
|
|
182
|
+
* from the value last dispatched (false before the first). The Shell calls it
|
|
183
|
+
* on connect, so a listener other than a binding — which reads the property
|
|
184
|
+
* when it binds — learns the value too.
|
|
185
|
+
*/
|
|
186
|
+
publishSupported(): void;
|
|
170
187
|
/**
|
|
171
188
|
* Start the sensor at the given `frequency` (Hz), or the platform default
|
|
172
189
|
* when omitted. Idempotent while already started: a redundant start() does
|
|
@@ -215,9 +232,10 @@ declare class MagnetometerCore extends EventTarget {
|
|
|
215
232
|
* (docs/sensor-tag-design.md §1.2). The getter normalizes it: a non-finite or
|
|
216
233
|
* non-positive value (NaN, 0, negative) reads back as `null` — meaning "no
|
|
217
234
|
* frequency specified" — so start() falls back to the platform default rather
|
|
218
|
-
* than forwarding a value the sensor would reject
|
|
219
|
-
*
|
|
220
|
-
*
|
|
235
|
+
* than forwarding a value the sensor would reject, and says so once
|
|
236
|
+
* (`[wcs/frequency-invalid]`). Any positive finite value is passed through
|
|
237
|
+
* verbatim (no upper-bound clamping — the browser caps a rate above what it
|
|
238
|
+
* allows).
|
|
221
239
|
*
|
|
222
240
|
* Permission handling is intentionally NOT implemented here. Compose with
|
|
223
241
|
* `<wcs-permission name="magnetometer">` instead (see the README's permission
|
|
@@ -229,6 +247,7 @@ declare class WcsMagnetometer extends HTMLElement {
|
|
|
229
247
|
private _core;
|
|
230
248
|
private _connectedCallbackPromise;
|
|
231
249
|
private _internals;
|
|
250
|
+
private _frequencyWarned;
|
|
232
251
|
constructor();
|
|
233
252
|
get debugStates(): string[];
|
|
234
253
|
private _initInternals;
|
|
@@ -259,9 +278,11 @@ declare class WcsMagnetometer extends HTMLElement {
|
|
|
259
278
|
get z(): number | null;
|
|
260
279
|
get error(): WcsMagnetometerErrorDetail | null;
|
|
261
280
|
get errorInfo(): WcsIoErrorInfo | null;
|
|
281
|
+
get supported(): boolean;
|
|
262
282
|
get connectedCallbackPromise(): Promise<void>;
|
|
263
283
|
start(): void;
|
|
264
284
|
stop(): void;
|
|
285
|
+
private _warnUnusableFrequency;
|
|
265
286
|
connectedCallback(): void;
|
|
266
287
|
connectedMoveCallback(): void;
|
|
267
288
|
disconnectedCallback(): void;
|
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/magnetometer","version":"4.
|
|
61
|
+
var pkg = {"name":"@wcstack/magnetometer","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
|
* magnetometerCapabilities.ts
|
|
@@ -157,6 +193,10 @@ class MagnetometerCore extends EventTarget {
|
|
|
157
193
|
// "unsupported"); the existing `error` property/event are unchanged. Fires
|
|
158
194
|
// wcs-magnetometer:error-info-changed. No lane — the sensor is a monitor.
|
|
159
195
|
{ name: "errorInfo", event: "wcs-magnetometer:error-info-changed", semantics: "state" },
|
|
196
|
+
// This page can use the sensor: the `Magnetometer` class is there and neither a
|
|
197
|
+
// Permissions-Policy nor an insecure context forbids it. Not whether the
|
|
198
|
+
// device has a sensor, and not whether the user will allow it.
|
|
199
|
+
{ name: "supported", event: "wcs-magnetometer:supported-changed", semantics: "state" },
|
|
160
200
|
],
|
|
161
201
|
commands: [{ name: "start" }, { name: "stop" }],
|
|
162
202
|
};
|
|
@@ -164,6 +204,8 @@ class MagnetometerCore extends EventTarget {
|
|
|
164
204
|
_reading = NULL_READING;
|
|
165
205
|
_error = null;
|
|
166
206
|
_errorInfo = null;
|
|
207
|
+
// The value the last wcs-magnetometer:supported-changed carried (none yet: false).
|
|
208
|
+
_supportedPublished = false;
|
|
167
209
|
// The live sensor instance while started (null otherwise), kept so stop()
|
|
168
210
|
// can remove its listeners precisely and so start() can detect "already
|
|
169
211
|
// started" without a separate boolean (docs/async-io-node-guidelines.md
|
|
@@ -194,6 +236,15 @@ class MagnetometerCore extends EventTarget {
|
|
|
194
236
|
get errorInfo() {
|
|
195
237
|
return this._errorInfo;
|
|
196
238
|
}
|
|
239
|
+
/**
|
|
240
|
+
* Whether this page can use the sensor: the `Magnetometer` class is there, and
|
|
241
|
+
* neither an insecure context nor a Permissions-Policy that forbids
|
|
242
|
+
* `magnetometer` is in the way. Read at call time, never cached. It cannot
|
|
243
|
+
* say whether the device has a sensor.
|
|
244
|
+
*/
|
|
245
|
+
get supported() {
|
|
246
|
+
return typeof globalThis.Magnetometer === "function" && featureUnavailable("magnetometer") === null;
|
|
247
|
+
}
|
|
197
248
|
/** No asynchronous probe to await: start()/stop() are synchronous
|
|
198
249
|
* (docs/async-io-node-guidelines.md §3.8 is satisfied trivially, mirroring
|
|
199
250
|
* NetworkCore). */
|
|
@@ -240,6 +291,22 @@ class MagnetometerCore extends EventTarget {
|
|
|
240
291
|
}));
|
|
241
292
|
}
|
|
242
293
|
// --- Public API ---
|
|
294
|
+
/**
|
|
295
|
+
* Dispatch `wcs-magnetometer:supported-changed` when `supported` differs
|
|
296
|
+
* from the value last dispatched (false before the first). The Shell calls it
|
|
297
|
+
* on connect, so a listener other than a binding — which reads the property
|
|
298
|
+
* when it binds — learns the value too.
|
|
299
|
+
*/
|
|
300
|
+
publishSupported() {
|
|
301
|
+
const supported = this.supported;
|
|
302
|
+
if (this._supportedPublished === supported)
|
|
303
|
+
return;
|
|
304
|
+
this._supportedPublished = supported;
|
|
305
|
+
this._target.dispatchEvent(new CustomEvent("wcs-magnetometer:supported-changed", {
|
|
306
|
+
detail: supported,
|
|
307
|
+
bubbles: true,
|
|
308
|
+
}));
|
|
309
|
+
}
|
|
243
310
|
/**
|
|
244
311
|
* Start the sensor at the given `frequency` (Hz), or the platform default
|
|
245
312
|
* when omitted. Idempotent while already started: a redundant start() does
|
|
@@ -268,7 +335,7 @@ class MagnetometerCore extends EventTarget {
|
|
|
268
335
|
// (failures surface via the 'error' event), but never-throw is a hard
|
|
269
336
|
// requirement here, so guard against a non-conformant implementation
|
|
270
337
|
// too.
|
|
271
|
-
this._teardownSensor();
|
|
338
|
+
this._teardownSensor(sensor);
|
|
272
339
|
this._setError({ error: e?.name ?? "error", message: e?.message ?? String(e) });
|
|
273
340
|
}
|
|
274
341
|
}
|
|
@@ -276,14 +343,15 @@ class MagnetometerCore extends EventTarget {
|
|
|
276
343
|
stop() {
|
|
277
344
|
if (!this._sensor)
|
|
278
345
|
return;
|
|
346
|
+
const sensor = this._sensor;
|
|
279
347
|
try {
|
|
280
|
-
|
|
348
|
+
sensor.stop();
|
|
281
349
|
}
|
|
282
350
|
catch {
|
|
283
351
|
// Never-throw defensive guard, symmetric with start(). Teardown below
|
|
284
352
|
// still runs so listeners are detached regardless.
|
|
285
353
|
}
|
|
286
|
-
this._teardownSensor();
|
|
354
|
+
this._teardownSensor(sensor);
|
|
287
355
|
}
|
|
288
356
|
/** Lifecycle alias for start(), so the Shell's connectedCallback can drive
|
|
289
357
|
* this Core the same way as other IO nodes' observe()/dispose() pair. No
|
|
@@ -297,13 +365,17 @@ class MagnetometerCore extends EventTarget {
|
|
|
297
365
|
this.stop();
|
|
298
366
|
}
|
|
299
367
|
// --- Internal ---
|
|
300
|
-
//
|
|
301
|
-
// `
|
|
302
|
-
// (
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
368
|
+
// Detach a sensor that is finished: stopped, failed in start(), or reported
|
|
369
|
+
// an `error` event. A sensor whose `error` event arrives while its start()
|
|
370
|
+
// is still running, and whose start() then throws, is torn down twice: the
|
|
371
|
+
// second time its listeners are already off, which removeEventListener
|
|
372
|
+
// takes — and a start() from an `error` listener may have put a newer
|
|
373
|
+
// sensor in its place by then, which stays.
|
|
374
|
+
_teardownSensor(sensor) {
|
|
375
|
+
sensor?.removeEventListener("reading", this._onReading);
|
|
376
|
+
sensor?.removeEventListener("error", this._onError);
|
|
377
|
+
if (this._sensor === sensor)
|
|
378
|
+
this._sensor = null;
|
|
307
379
|
}
|
|
308
380
|
/**
|
|
309
381
|
* Construct the platform `Magnetometer`, guarding both non-support and a
|
|
@@ -339,6 +411,11 @@ class MagnetometerCore extends EventTarget {
|
|
|
339
411
|
};
|
|
340
412
|
_onError = (event) => {
|
|
341
413
|
const err = event.error;
|
|
414
|
+
// The sensor that reported the error is finished (the platform deactivates
|
|
415
|
+
// it): detach it before publishing, so the next start() builds a fresh one
|
|
416
|
+
// instead of taking this one for "already started". It is `_sensor`: this
|
|
417
|
+
// listener is on a sensor only while that sensor is the current one.
|
|
418
|
+
this._teardownSensor(this._sensor);
|
|
342
419
|
// Fallback is a meaningful constant, NOT String(err): a SensorErrorEvent
|
|
343
420
|
// without an `error` field would otherwise stringify `undefined` into the
|
|
344
421
|
// literal message "undefined" (aligned across the sensor family).
|
|
@@ -467,9 +544,10 @@ function reflectAttribute(el, name, value) {
|
|
|
467
544
|
* (docs/sensor-tag-design.md §1.2). The getter normalizes it: a non-finite or
|
|
468
545
|
* non-positive value (NaN, 0, negative) reads back as `null` — meaning "no
|
|
469
546
|
* frequency specified" — so start() falls back to the platform default rather
|
|
470
|
-
* than forwarding a value the sensor would reject
|
|
471
|
-
*
|
|
472
|
-
*
|
|
547
|
+
* than forwarding a value the sensor would reject, and says so once
|
|
548
|
+
* (`[wcs/frequency-invalid]`). Any positive finite value is passed through
|
|
549
|
+
* verbatim (no upper-bound clamping — the browser caps a rate above what it
|
|
550
|
+
* allows).
|
|
473
551
|
*
|
|
474
552
|
* Permission handling is intentionally NOT implemented here. Compose with
|
|
475
553
|
* `<wcs-permission name="magnetometer">` instead (see the README's permission
|
|
@@ -486,6 +564,7 @@ class WcsMagnetometer extends HTMLElement {
|
|
|
486
564
|
_core;
|
|
487
565
|
_connectedCallbackPromise = Promise.resolve();
|
|
488
566
|
_internals = null;
|
|
567
|
+
_frequencyWarned = false;
|
|
489
568
|
constructor() {
|
|
490
569
|
super();
|
|
491
570
|
this._core = new MagnetometerCore(this);
|
|
@@ -592,16 +671,34 @@ class WcsMagnetometer extends HTMLElement {
|
|
|
592
671
|
get errorInfo() {
|
|
593
672
|
return this._core.errorInfo;
|
|
594
673
|
}
|
|
674
|
+
// Computed at call time: a binding reads it when it binds, with no event.
|
|
675
|
+
get supported() {
|
|
676
|
+
return this._core.supported;
|
|
677
|
+
}
|
|
595
678
|
get connectedCallbackPromise() {
|
|
596
679
|
return this._connectedCallbackPromise;
|
|
597
680
|
}
|
|
598
681
|
// --- Commands ---
|
|
599
682
|
start() {
|
|
683
|
+
this._warnUnusableFrequency();
|
|
600
684
|
this._core.start(this.frequency ?? undefined);
|
|
601
685
|
}
|
|
602
686
|
stop() {
|
|
603
687
|
this._core.stop();
|
|
604
688
|
}
|
|
689
|
+
// A `frequency` that is written but is not a positive number ("60hz", "0")
|
|
690
|
+
// reads back as null, and the sensor then runs at the browser's default rate
|
|
691
|
+
// with nothing else saying so. Said once per element.
|
|
692
|
+
_warnUnusableFrequency() {
|
|
693
|
+
if (this._frequencyWarned)
|
|
694
|
+
return;
|
|
695
|
+
const attr = this.getAttribute("frequency");
|
|
696
|
+
if (attr === null || attr.trim() === "" || this.frequency !== null)
|
|
697
|
+
return;
|
|
698
|
+
this._frequencyWarned = true;
|
|
699
|
+
console.warn(`[@wcstack/magnetometer] [wcs/frequency-invalid] <${this.localName}> frequency="${attr}" is not a ` +
|
|
700
|
+
`positive number of Hz: the sensor runs at the browser's default rate. Write a number, e.g. frequency="30".`, this);
|
|
701
|
+
}
|
|
605
702
|
// --- Lifecycle ---
|
|
606
703
|
// Deliberately does NOT auto-start the sensor on connect. Unlike
|
|
607
704
|
// Geolocation (whose default phase acquires a fix immediately unless
|
|
@@ -619,6 +716,8 @@ class WcsMagnetometer extends HTMLElement {
|
|
|
619
716
|
// No asynchronous probe to await (docs/async-io-node-guidelines.md §3.8);
|
|
620
717
|
// kept for SSR uniformity with other IO nodes.
|
|
621
718
|
this._connectedCallbackPromise = this._core.ready;
|
|
719
|
+
// Starts nothing: publishes `supported` when it differs from the value last dispatched.
|
|
720
|
+
this._core.publishSupported();
|
|
622
721
|
}
|
|
623
722
|
// Moved by moveBefore() (a list row a reorder moves): where this element is changes nothing of what it
|
|
624
723
|
// does, so nothing stops and nothing starts again. With no connectedMoveCallback the browser calls
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../../src/config.ts","../../src/core/magnetometerCapabilities.ts","../../src/core/MagnetometerCore.ts","../../src/protocol/upgradeProperties.ts","../../src/protocol/inputAttribute.ts","../../src/components/Magnetometer.ts","../../src/protocol/defineElement.ts","../../src/registerComponents.ts","../../src/bootstrapMagnetometer.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n magnetometer: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n magnetometer: \"wcs-magnetometer\",\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: `bootstrapMagnetometer` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/magnetometer] bootstrapMagnetometer: \"${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 * magnetometerCapabilities.ts\n *\n * Magnetometer node 固有の error code(taxonomy)と derivation。汎用の error info 型は\n * `./platformCapability.js`(/io-core/ から copy-distribution される生成ファイル)から\n * import する。sensor は監視系(継続 subscribe/unsubscribe)で競合する operation を持た\n * ないため lane は持たず、error taxonomy(errorInfo)のみを採用する。\n *\n * sensor family(accelerometer / gyroscope / magnetometer / ambient-light-sensor)は\n * error 面が構造同一(`{ error: <name>, message }`、`.error` が Error.name / \"unsupported\"\n * / \"error\" fallback)なので、taxonomy も 4 兄弟で一致させる。\n */\n\nimport type { WcsIoErrorInfo } from \"./platformCapability.js\";\n\n/** 安定した magnetometer error code(taxonomy)。値は公開キーとして固定。 */\nexport const WCS_MAGNETOMETER_ERROR_CODE = {\n /** Sensor API 非対応(`globalThis.Magnetometer` 不在)。 */\n CapabilityMissing: \"capability-missing\",\n /** `SecurityError` / `NotAllowedError` — 権限拒否・feature-policy ブロック。 */\n NotAllowed: \"not-allowed\",\n /** `NotReadableError` — センサーハードウェアを読めない。 */\n NotReadable: \"not-readable\",\n /** その他の SensorErrorEvent / 想定外の失敗。 */\n SensorError: \"sensor-error\",\n} as const;\n\n/**\n * sensor の失敗を serializable な error taxonomy に写す。`name` は error detail の\n * `.error`(`Error.name` / \"unsupported\" / \"error\" fallback)。\n *\n * - \"unsupported\" は開始前の能力欠如 → phase=\"probe\" / capability-missing。\n * - `SecurityError` / `NotAllowedError` は sensor 構築時の権限拒否 → phase=\"start\" /\n * not-allowed。いずれも retry で回復しない(recoverable=false)。\n * - `NotReadableError` は稼働中のハードウェア読取失敗 → phase=\"execute\" / not-readable。\n * - それ以外(SensorErrorEvent の他 name / \"error\" fallback)は phase=\"execute\" /\n * sensor-error。\n */\nexport function deriveMagnetometerErrorInfo(name: string, message: string): WcsIoErrorInfo {\n if (name === \"unsupported\") {\n return { code: WCS_MAGNETOMETER_ERROR_CODE.CapabilityMissing, phase: \"probe\", recoverable: false, message };\n }\n if (name === \"SecurityError\" || name === \"NotAllowedError\") {\n return { code: WCS_MAGNETOMETER_ERROR_CODE.NotAllowed, phase: \"start\", recoverable: false, message };\n }\n if (name === \"NotReadableError\") {\n return { code: WCS_MAGNETOMETER_ERROR_CODE.NotReadable, phase: \"execute\", recoverable: false, message };\n }\n return { code: WCS_MAGNETOMETER_ERROR_CODE.SensorError, phase: \"execute\", recoverable: false, message };\n}\n","import { IWcBindable, WcsMagnetometerReading, WcsMagnetometerErrorDetail } from \"../types.js\";\nimport { WcsIoErrorInfo } from \"./platformCapability.js\";\nimport { deriveMagnetometerErrorInfo } from \"./magnetometerCapabilities.js\";\n\nconst NULL_READING: WcsMagnetometerReading = Object.freeze({ x: null, y: null, z: null });\n\n/**\n * Headless Magnetometer primitive. A thin, framework-agnostic wrapper around\n * the Generic Sensor API's `Magnetometer` class exposed through the\n * wc-bindable protocol.\n *\n * The platform `Sensor` base class (shared by `Accelerometer` / `Gyroscope` /\n * `Magnetometer` / `AmbientLightSensor`) reports failure through an `'error'`\n * event rather than a rejected promise, so this Core can satisfy never-throw\n * (docs/async-io-node-guidelines.md §3.6) by simply forwarding that event —\n * see docs/sensor-tag-design.md §0. The one place a synchronous\n * exception *can* still escape the platform API is the `Magnetometer`\n * constructor itself (e.g. `SecurityError` on permission denial or a\n * feature-policy block); `_createSensor()` wraps that single call in\n * try/catch, mirroring FetchCore's `_doFetch` try/catch around\n * `globalThis.fetch` (packages/fetch/src/core/FetchCore.ts).\n *\n * `x`/`y`/`z` are three getters derived from the single `wcs-magnetometer:reading`\n * event (mirroring how NetworkCore exposes effectiveType/downlink/… from one\n * `wcs-network:change` event): the native `reading` event already reports all\n * three axes together, so they are not split into independent events. `reading`\n * is an event-like signal (a fresh sample every time, not a settled state) and\n * is therefore deliberately NOT same-value guarded — every sample dispatches.\n * `error` is state-like (denial / unsupported does not change from tick to\n * tick) and IS same-value guarded, and is published on its own\n * `wcs-magnetometer:error` event, independent of `reading`.\n *\n * No `_gen` generation guard: start()/stop() are a synchronous\n * subscribe/unsubscribe toggle with no asynchronous probe whose stale\n * resolution could race a dispose() — see docs/sensor-tag-design.md §1.5\n * (the same reasoning as NetworkCore, docs/network-tag-design.md §5).\n *\n * Permissions: this Core does not query `navigator.permissions` itself.\n * Compose with `<wcs-permission name=\"magnetometer\">` instead — see\n * docs/sensor-tag-design.md §\"2番目の決定: Permissions APIとの合成\".\n */\nexport class MagnetometerCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"x\", event: \"wcs-magnetometer:reading\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.x },\n { name: \"y\", event: \"wcs-magnetometer:reading\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.y },\n { name: \"z\", event: \"wcs-magnetometer:reading\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.z },\n { name: \"error\", event: \"wcs-magnetometer:error\", semantics: \"state\" },\n // Serializable failure taxonomy (stable code / phase / recoverable), or null.\n // Additive bindable output derived from `error.error` (the Error.name /\n // \"unsupported\"); the existing `error` property/event are unchanged. Fires\n // wcs-magnetometer:error-info-changed. No lane — the sensor is a monitor.\n { name: \"errorInfo\", event: \"wcs-magnetometer:error-info-changed\", semantics: \"state\" },\n ],\n commands: [{ name: \"start\" }, { name: \"stop\" }],\n };\n\n private _target: EventTarget;\n private _reading: WcsMagnetometerReading = NULL_READING;\n private _error: WcsMagnetometerErrorDetail | null = null;\n private _errorInfo: WcsIoErrorInfo | null = null;\n\n // The live sensor instance while started (null otherwise), kept so stop()\n // can remove its listeners precisely and so start() can detect \"already\n // started\" without a separate boolean (docs/async-io-node-guidelines.md\n // §3.5 idempotency).\n private _sensor: (EventTarget & { start(): void; stop(): void }) | null = null;\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n get x(): number | null {\n return this._reading.x;\n }\n\n get y(): number | null {\n return this._reading.y;\n }\n\n get z(): number | null {\n return this._reading.z;\n }\n\n get error(): WcsMagnetometerErrorDetail | null {\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-magnetometer:error-info-changed`), derived from `error`; the existing\n * `error` property/event are unchanged.\n */\n get errorInfo(): WcsIoErrorInfo | null {\n return this._errorInfo;\n }\n\n /** No asynchronous probe to await: start()/stop() are synchronous\n * (docs/async-io-node-guidelines.md §3.8 is satisfied trivially, mirroring\n * NetworkCore). */\n get ready(): Promise<void> {\n return Promise.resolve();\n }\n\n // --- State setters ---\n\n // Deliberately NOT same-value guarded: a `reading` is a fresh sample, not a\n // settled state, so it must dispatch every time even when the values happen\n // to repeat (docs/sensor-tag-design.md §1.1).\n private _setReading(reading: WcsMagnetometerReading): void {\n this._reading = reading;\n this._target.dispatchEvent(new CustomEvent(\"wcs-magnetometer:reading\", {\n detail: reading,\n bubbles: true,\n }));\n }\n\n private _setError(error: WcsMagnetometerErrorDetail | null): void {\n // Same-value guard (by error name + message): error is state-like, unlike\n // reading — a repeated identical error (same name and message) must not\n // redispatch. Note `error` is also STICKY: nothing calls _setError(null),\n // so a successful (re)start does not clear a prior failure — the monitoring\n // sensor family deliberately keeps the last observed error (docs/sensor-tag-design.md §1.5).\n if (this._error?.error === error?.error && this._error?.message === error?.message) return;\n this._error = error;\n // Keep the additive `errorInfo` taxonomy in sync with `error`: derive from the\n // error name (or null on clear). Fires before the `error` event so an observer\n // binding both sees the classification first, mirroring the io-node family.\n this._commitErrorInfo(error === null ? null : deriveMagnetometerErrorInfo(error.error, error.message));\n this._target.dispatchEvent(new CustomEvent(\"wcs-magnetometer:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n // Called only from _setError (which already same-value-guards on the error name\n // + message), so errorInfo transitions exactly when error does — no separate\n // guard needed here.\n private _commitErrorInfo(info: WcsIoErrorInfo | null): void {\n this._errorInfo = info;\n this._target.dispatchEvent(new CustomEvent(\"wcs-magnetometer:error-info-changed\", {\n detail: info,\n bubbles: true,\n }));\n }\n\n // --- Public API ---\n\n /**\n * Start the sensor at the given `frequency` (Hz), or the platform default\n * when omitted. Idempotent while already started: a redundant start() does\n * not construct a second sensor instance (which would leak the first).\n * Restart with a different frequency via stop() + start().\n *\n * Synchronous, mirroring the native `Sensor.start()` — never throws\n * (docs/async-io-node-guidelines.md §3.6): both \"unsupported\" and a\n * synchronous constructor exception (permission denial, feature-policy\n * block) are converted to the `error` property instead of propagating.\n */\n start(frequency?: number): void {\n if (this._sensor) return;\n const sensor = this._createSensor(frequency);\n if (!sensor) return;\n sensor.addEventListener(\"reading\", this._onReading as EventListener);\n sensor.addEventListener(\"error\", this._onError as EventListener);\n this._sensor = sensor;\n try {\n sensor.start();\n } catch (e: any) {\n // Defensive: the platform contract says start()/stop() do not throw\n // (failures surface via the 'error' event), but never-throw is a hard\n // requirement here, so guard against a non-conformant implementation\n // too.\n this._teardownSensor();\n this._setError({ error: e?.name ?? \"error\", message: e?.message ?? String(e) });\n }\n }\n\n /** Stop the sensor and detach its listeners. Safe to call when not started. */\n stop(): void {\n if (!this._sensor) return;\n try {\n this._sensor.stop();\n } catch {\n // Never-throw defensive guard, symmetric with start(). Teardown below\n // still runs so listeners are detached regardless.\n }\n this._teardownSensor();\n }\n\n /** Lifecycle alias for start(), so the Shell's connectedCallback can drive\n * this Core the same way as other IO nodes' observe()/dispose() pair. No\n * asynchronous probe, so the returned promise always resolves immediately. */\n observe(frequency?: number): Promise<void> {\n this.start(frequency);\n return this.ready;\n }\n\n /** Lifecycle alias for stop(), invoked from the Shell's disconnectedCallback. */\n dispose(): void {\n this.stop();\n }\n\n // --- Internal ---\n\n // Both call sites (start()'s catch, stop()) only ever invoke this once\n // `this._sensor` is already known non-null, so there is no null-guard here\n // (nothing to defend against).\n private _teardownSensor(): void {\n this._sensor!.removeEventListener(\"reading\", this._onReading as EventListener);\n this._sensor!.removeEventListener(\"error\", this._onError as EventListener);\n this._sensor = null;\n }\n\n /**\n * Construct the platform `Magnetometer`, guarding both non-support and a\n * synchronous constructor exception. Never calls the raw `new Magnetometer(...)`\n * anywhere else in this class — see docs/sensor-tag-design.md §1.5.\n *\n * API resolution is call-time (docs/async-io-node-guidelines.md §3.7):\n * re-checked on every start(), never cached, so tests can install/remove\n * the global freely and an unsupported environment is always reported\n * correctly.\n */\n private _createSensor(frequency?: number): (EventTarget & { start(): void; stop(): void }) | null {\n const Ctor = (globalThis as any).Magnetometer;\n if (typeof Ctor !== \"function\") {\n this._setError({ error: \"unsupported\", message: \"Magnetometer is not supported\" });\n return null;\n }\n try {\n return new Ctor(frequency !== undefined ? { frequency } : undefined);\n } catch (e: any) {\n // SecurityError (permission denial, feature-policy block) or any other\n // synchronous construction failure. Mirrors the FetchCore._doFetch\n // try/catch structure (packages/fetch/src/core/FetchCore.ts) — a\n // synchronous constructor call here instead of an awaited fetch().\n this._setError({ error: e?.name ?? \"error\", message: e?.message ?? String(e) });\n return null;\n }\n }\n\n private _onReading = (event: Event): void => {\n const sensor = event.target as unknown as { x: number | null; y: number | null; z: number | null };\n this._setReading({ x: sensor.x, y: sensor.y, z: sensor.z });\n };\n\n private _onError = (event: Event): void => {\n const err = (event as any).error as { name?: string; message?: string } | undefined;\n // Fallback is a meaningful constant, NOT String(err): a SensorErrorEvent\n // without an `error` field would otherwise stringify `undefined` into the\n // literal message \"undefined\" (aligned across the sensor family).\n this._setError({ error: err?.name ?? \"error\", message: err?.message ?? \"Sensor error\" });\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, WcsMagnetometerErrorDetail } from \"../types.js\";\nimport { MagnetometerCore } from \"../core/MagnetometerCore.js\";\nimport { WcsIoErrorInfo } from \"../core/platformCapability.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute } from \"../protocol/inputAttribute.js\";\n\n/**\n * `<wcs-magnetometer>` — declarative Generic Sensor API (`Magnetometer`)\n * monitor + start/stop control.\n *\n * Unlike `<wcs-network>` / `<wcs-permission>` (pure monitors), this Shell is a\n * bidirectional node: `start`/`stop` commands (command-token: state → element)\n * alongside the `x`/`y`/`z`/`error` observable surface (event-token: element →\n * state). The `frequency` attribute is the sole configuration input, forwarded\n * to the platform `Magnetometer` constructor's `{ frequency }` option\n * (docs/sensor-tag-design.md §1.2). The getter normalizes it: a non-finite or\n * non-positive value (NaN, 0, negative) reads back as `null` — meaning \"no\n * frequency specified\" — so start() falls back to the platform default rather\n * than forwarding a value the sensor would reject. Any positive finite value is\n * passed through verbatim (no upper-bound clamping — an out-of-range-but-positive\n * rate is still left to the browser/sensor to reject via `error`).\n *\n * Permission handling is intentionally NOT implemented here. Compose with\n * `<wcs-permission name=\"magnetometer\">` instead (see the README's permission\n * example, \"Gate on permission, then start\", and docs/sensor-tag-design.md).\n */\nexport class WcsMagnetometer extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n\n static wcBindable: IWcBindable = {\n ...MagnetometerCore.wcBindable,\n inputs: [{ name: \"frequency\" }],\n // Core の commands をそのまま継承(単一情報源)。\n commands: MagnetometerCore.wcBindable.commands,\n };\n\n private _core: MagnetometerCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new MagnetometerCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-magnetometer:error\": (d) => ({ error: d != null }),\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/async-io-node-guidelines.md §3.6): attachInternals is\n // 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 // --- Attribute accessors ---\n\n /**\n * Sampling frequency in Hz. Reads back `null` when unset, blank, or when the\n * attribute does not parse to a positive finite number (NaN, `\"0\"`, negative)\n * — in every such \"no usable value\" case the platform default applies.\n *\n * Note the deliberate set/get asymmetry: `set frequency(0)` (or any\n * non-positive/non-finite value) still writes the attribute verbatim for\n * transparency/inspectability, but the getter normalizes it back to `null`.\n * A round-trip through a non-positive value therefore does NOT preserve it —\n * that value carries no valid sampling meaning, so it is treated as \"unset\"\n * on read. Only positive finite frequencies survive a set→get round-trip.\n *\n * This value is read only at `start()` time. There is no\n * `attributeChangedCallback`, and `MagnetometerCore.start()` is idempotent\n * while already started (a redundant call is a no-op), so setting\n * `frequency` (attribute or property) on an already-running sensor has no\n * effect until the caller `stop()`s and `start()`s again (see the README's\n * \"Notes & limitations\").\n */\n get frequency(): number | null {\n const attr = this.getAttribute(\"frequency\");\n if (attr === null || attr.trim() === \"\") return null;\n const parsed = Number(attr);\n return Number.isFinite(parsed) && parsed > 0 ? parsed : null;\n }\n\n set frequency(value: number | null | undefined) {\n // `null` removes the attribute (the platform default); `undefined` restores\n // the attribute the element started with — the authored frequency, or none\n // (wc-bindable producer guidance P1; React 19 and a direct assignment\n // deliver it, @wcstack/state does not).\n reflectAttribute(this, \"frequency\", value);\n }\n\n // --- Core delegated getters ---\n\n get x(): number | null {\n return this._core.x;\n }\n\n get y(): number | null {\n return this._core.y;\n }\n\n get z(): number | null {\n return this._core.z;\n }\n\n get error(): WcsMagnetometerErrorDetail | null {\n return this._core.error;\n }\n\n get errorInfo(): WcsIoErrorInfo | null {\n return this._core.errorInfo;\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Commands ---\n\n start(): void {\n this._core.start(this.frequency ?? undefined);\n }\n\n stop(): void {\n this._core.stop();\n }\n\n // --- Lifecycle ---\n\n // Deliberately does NOT auto-start the sensor on connect. Unlike\n // Geolocation (whose default phase acquires a fix immediately unless\n // `manual` is set), Magnetometer has no such \"connect implies observing\"\n // precedent in the design doc (docs/sensor-tag-design.md §1.3):\n // start/stop are the only commands, so connecting the element merely makes\n // it inert until a command-token `start` (or the `start()` method) is\n // invoked. This also keeps behavior predictable when composed with\n // `<wcs-permission name=\"magnetometer\">`: the caller decides when to start,\n // typically gated on `granted`.\n connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\n this.style.display = \"none\";\n // No asynchronous probe to await (docs/async-io-node-guidelines.md §3.8);\n // kept for SSR uniformity with other IO nodes.\n this._connectedCallbackPromise = this._core.ready;\n }\n\n // Moved by moveBefore() (a list row a reorder moves): where this element is changes nothing of what it\n // does, so nothing stops and nothing starts again. With no connectedMoveCallback the browser calls\n // disconnectedCallback and connectedCallback instead (docs/timing-and-firing-contract.md §25)\n connectedMoveCallback(): void {}\n\n disconnectedCallback(): void {\n this._core.dispose();\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 { WcsMagnetometer } from \"./components/Magnetometer.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.magnetometer, WcsMagnetometer],\n ]);\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapMagnetometer(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,YAAY,EAAE,kBAAkB;AACjC,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,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AAQ,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,YAAY,EAAE,eAAe,CAAC;AAChD,KAAA,CAAC;AACJ;;ACVM,SAAU,qBAAqB,CAAC,UAA4B,EAAE,QAAgC,EAAA;IAClG,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/magnetometerCapabilities.ts","../../src/core/MagnetometerCore.ts","../../src/protocol/upgradeProperties.ts","../../src/protocol/inputAttribute.ts","../../src/components/Magnetometer.ts","../../src/protocol/defineElement.ts","../../src/registerComponents.ts","../../src/bootstrapMagnetometer.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n magnetometer: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n magnetometer: \"wcs-magnetometer\",\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: `bootstrapMagnetometer` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/magnetometer] bootstrapMagnetometer: \"${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 * magnetometerCapabilities.ts\n *\n * Magnetometer node 固有の error code(taxonomy)と derivation。汎用の error info 型は\n * `./platformCapability.js`(/io-core/ から copy-distribution される生成ファイル)から\n * import する。sensor は監視系(継続 subscribe/unsubscribe)で競合する operation を持た\n * ないため lane は持たず、error taxonomy(errorInfo)のみを採用する。\n *\n * sensor family(accelerometer / gyroscope / magnetometer / ambient-light-sensor)は\n * error 面が構造同一(`{ error: <name>, message }`、`.error` が Error.name / \"unsupported\"\n * / \"error\" fallback)なので、taxonomy も 4 兄弟で一致させる。\n */\n\nimport type { WcsIoErrorInfo } from \"./platformCapability.js\";\n\n/** 安定した magnetometer error code(taxonomy)。値は公開キーとして固定。 */\nexport const WCS_MAGNETOMETER_ERROR_CODE = {\n /** Sensor API 非対応(`globalThis.Magnetometer` 不在)。 */\n CapabilityMissing: \"capability-missing\",\n /** `SecurityError` / `NotAllowedError` — 権限拒否・feature-policy ブロック。 */\n NotAllowed: \"not-allowed\",\n /** `NotReadableError` — センサーハードウェアを読めない。 */\n NotReadable: \"not-readable\",\n /** その他の SensorErrorEvent / 想定外の失敗。 */\n SensorError: \"sensor-error\",\n} as const;\n\n/**\n * sensor の失敗を serializable な error taxonomy に写す。`name` は error detail の\n * `.error`(`Error.name` / \"unsupported\" / \"error\" fallback)。\n *\n * - \"unsupported\" は開始前の能力欠如 → phase=\"probe\" / capability-missing。\n * - `SecurityError` / `NotAllowedError` は sensor 構築時の権限拒否 → phase=\"start\" /\n * not-allowed。いずれも retry で回復しない(recoverable=false)。\n * - `NotReadableError` は稼働中のハードウェア読取失敗 → phase=\"execute\" / not-readable。\n * - それ以外(SensorErrorEvent の他 name / \"error\" fallback)は phase=\"execute\" /\n * sensor-error。\n */\nexport function deriveMagnetometerErrorInfo(name: string, message: string): WcsIoErrorInfo {\n if (name === \"unsupported\") {\n return { code: WCS_MAGNETOMETER_ERROR_CODE.CapabilityMissing, phase: \"probe\", recoverable: false, message };\n }\n if (name === \"SecurityError\" || name === \"NotAllowedError\") {\n return { code: WCS_MAGNETOMETER_ERROR_CODE.NotAllowed, phase: \"start\", recoverable: false, message };\n }\n if (name === \"NotReadableError\") {\n return { code: WCS_MAGNETOMETER_ERROR_CODE.NotReadable, phase: \"execute\", recoverable: false, message };\n }\n return { code: WCS_MAGNETOMETER_ERROR_CODE.SensorError, phase: \"execute\", recoverable: false, message };\n}\n","import { IWcBindable, WcsMagnetometerReading, WcsMagnetometerErrorDetail } from \"../types.js\";\nimport { WcsIoErrorInfo, featureUnavailable } from \"./platformCapability.js\";\nimport { deriveMagnetometerErrorInfo } from \"./magnetometerCapabilities.js\";\n\nconst NULL_READING: WcsMagnetometerReading = Object.freeze({ x: null, y: null, z: null });\n\ntype SensorLike = EventTarget & { start(): void; stop(): void };\n\n/**\n * Headless Magnetometer primitive. A thin, framework-agnostic wrapper around\n * the Generic Sensor API's `Magnetometer` class exposed through the\n * wc-bindable protocol.\n *\n * The platform `Sensor` base class (shared by `Accelerometer` / `Gyroscope` /\n * `Magnetometer` / `AmbientLightSensor`) reports failure through an `'error'`\n * event rather than a rejected promise, so this Core can satisfy never-throw\n * (docs/async-io-node-guidelines.md §3.6) by simply forwarding that event —\n * see docs/sensor-tag-design.md §0. The one place a synchronous\n * exception *can* still escape the platform API is the `Magnetometer`\n * constructor itself (e.g. `SecurityError` on permission denial or a\n * feature-policy block); `_createSensor()` wraps that single call in\n * try/catch, mirroring FetchCore's `_doFetch` try/catch around\n * `globalThis.fetch` (packages/fetch/src/core/FetchCore.ts).\n *\n * `x`/`y`/`z` are three getters derived from the single `wcs-magnetometer:reading`\n * event (mirroring how NetworkCore exposes effectiveType/downlink/… from one\n * `wcs-network:change` event): the native `reading` event already reports all\n * three axes together, so they are not split into independent events. `reading`\n * is an event-like signal (a fresh sample every time, not a settled state) and\n * is therefore deliberately NOT same-value guarded — every sample dispatches.\n * `error` is state-like (denial / unsupported does not change from tick to\n * tick) and IS same-value guarded, and is published on its own\n * `wcs-magnetometer:error` event, independent of `reading`.\n *\n * No `_gen` generation guard: start()/stop() are a synchronous\n * subscribe/unsubscribe toggle with no asynchronous probe whose stale\n * resolution could race a dispose() — see docs/sensor-tag-design.md §1.5\n * (the same reasoning as NetworkCore, docs/network-tag-design.md §5).\n *\n * Permissions: this Core does not query `navigator.permissions` itself.\n * Compose with `<wcs-permission name=\"magnetometer\">` instead — see\n * docs/sensor-tag-design.md §\"2番目の決定: Permissions APIとの合成\".\n */\nexport class MagnetometerCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"x\", event: \"wcs-magnetometer:reading\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.x },\n { name: \"y\", event: \"wcs-magnetometer:reading\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.y },\n { name: \"z\", event: \"wcs-magnetometer:reading\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.z },\n { name: \"error\", event: \"wcs-magnetometer:error\", semantics: \"state\" },\n // Serializable failure taxonomy (stable code / phase / recoverable), or null.\n // Additive bindable output derived from `error.error` (the Error.name /\n // \"unsupported\"); the existing `error` property/event are unchanged. Fires\n // wcs-magnetometer:error-info-changed. No lane — the sensor is a monitor.\n { name: \"errorInfo\", event: \"wcs-magnetometer:error-info-changed\", semantics: \"state\" },\n // This page can use the sensor: the `Magnetometer` class is there and neither a\n // Permissions-Policy nor an insecure context forbids it. Not whether the\n // device has a sensor, and not whether the user will allow it.\n { name: \"supported\", event: \"wcs-magnetometer:supported-changed\", semantics: \"state\" },\n ],\n commands: [{ name: \"start\" }, { name: \"stop\" }],\n };\n\n private _target: EventTarget;\n private _reading: WcsMagnetometerReading = NULL_READING;\n private _error: WcsMagnetometerErrorDetail | null = null;\n private _errorInfo: WcsIoErrorInfo | null = null;\n // The value the last wcs-magnetometer:supported-changed carried (none yet: false).\n private _supportedPublished = false;\n\n // The live sensor instance while started (null otherwise), kept so stop()\n // can remove its listeners precisely and so start() can detect \"already\n // started\" without a separate boolean (docs/async-io-node-guidelines.md\n // §3.5 idempotency).\n private _sensor: SensorLike | null = null;\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n get x(): number | null {\n return this._reading.x;\n }\n\n get y(): number | null {\n return this._reading.y;\n }\n\n get z(): number | null {\n return this._reading.z;\n }\n\n get error(): WcsMagnetometerErrorDetail | null {\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-magnetometer:error-info-changed`), derived from `error`; the existing\n * `error` property/event are unchanged.\n */\n get errorInfo(): WcsIoErrorInfo | null {\n return this._errorInfo;\n }\n\n /**\n * Whether this page can use the sensor: the `Magnetometer` class is there, and\n * neither an insecure context nor a Permissions-Policy that forbids\n * `magnetometer` is in the way. Read at call time, never cached. It cannot\n * say whether the device has a sensor.\n */\n get supported(): boolean {\n return typeof (globalThis as any).Magnetometer === \"function\" && featureUnavailable(\"magnetometer\") === null;\n }\n\n /** No asynchronous probe to await: start()/stop() are synchronous\n * (docs/async-io-node-guidelines.md §3.8 is satisfied trivially, mirroring\n * NetworkCore). */\n get ready(): Promise<void> {\n return Promise.resolve();\n }\n\n // --- State setters ---\n\n // Deliberately NOT same-value guarded: a `reading` is a fresh sample, not a\n // settled state, so it must dispatch every time even when the values happen\n // to repeat (docs/sensor-tag-design.md §1.1).\n private _setReading(reading: WcsMagnetometerReading): void {\n this._reading = reading;\n this._target.dispatchEvent(new CustomEvent(\"wcs-magnetometer:reading\", {\n detail: reading,\n bubbles: true,\n }));\n }\n\n private _setError(error: WcsMagnetometerErrorDetail | null): void {\n // Same-value guard (by error name + message): error is state-like, unlike\n // reading — a repeated identical error (same name and message) must not\n // redispatch. Note `error` is also STICKY: nothing calls _setError(null),\n // so a successful (re)start does not clear a prior failure — the monitoring\n // sensor family deliberately keeps the last observed error (docs/sensor-tag-design.md §1.5).\n if (this._error?.error === error?.error && this._error?.message === error?.message) return;\n this._error = error;\n // Keep the additive `errorInfo` taxonomy in sync with `error`: derive from the\n // error name (or null on clear). Fires before the `error` event so an observer\n // binding both sees the classification first, mirroring the io-node family.\n this._commitErrorInfo(error === null ? null : deriveMagnetometerErrorInfo(error.error, error.message));\n this._target.dispatchEvent(new CustomEvent(\"wcs-magnetometer:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n // Called only from _setError (which already same-value-guards on the error name\n // + message), so errorInfo transitions exactly when error does — no separate\n // guard needed here.\n private _commitErrorInfo(info: WcsIoErrorInfo | null): void {\n this._errorInfo = info;\n this._target.dispatchEvent(new CustomEvent(\"wcs-magnetometer:error-info-changed\", {\n detail: info,\n bubbles: true,\n }));\n }\n\n // --- Public API ---\n\n /**\n * Dispatch `wcs-magnetometer:supported-changed` when `supported` differs\n * from the value last dispatched (false before the first). The Shell calls it\n * on connect, so a listener other than a binding — which reads the property\n * when it binds — learns the value too.\n */\n publishSupported(): void {\n const supported = this.supported;\n if (this._supportedPublished === supported) return;\n this._supportedPublished = supported;\n this._target.dispatchEvent(new CustomEvent(\"wcs-magnetometer:supported-changed\", {\n detail: supported,\n bubbles: true,\n }));\n }\n\n /**\n * Start the sensor at the given `frequency` (Hz), or the platform default\n * when omitted. Idempotent while already started: a redundant start() does\n * not construct a second sensor instance (which would leak the first).\n * Restart with a different frequency via stop() + start().\n *\n * Synchronous, mirroring the native `Sensor.start()` — never throws\n * (docs/async-io-node-guidelines.md §3.6): both \"unsupported\" and a\n * synchronous constructor exception (permission denial, feature-policy\n * block) are converted to the `error` property instead of propagating.\n */\n start(frequency?: number): void {\n if (this._sensor) return;\n const sensor = this._createSensor(frequency);\n if (!sensor) return;\n sensor.addEventListener(\"reading\", this._onReading as EventListener);\n sensor.addEventListener(\"error\", this._onError as EventListener);\n this._sensor = sensor;\n try {\n sensor.start();\n } catch (e: any) {\n // Defensive: the platform contract says start()/stop() do not throw\n // (failures surface via the 'error' event), but never-throw is a hard\n // requirement here, so guard against a non-conformant implementation\n // too.\n this._teardownSensor(sensor);\n this._setError({ error: e?.name ?? \"error\", message: e?.message ?? String(e) });\n }\n }\n\n /** Stop the sensor and detach its listeners. Safe to call when not started. */\n stop(): void {\n if (!this._sensor) return;\n const sensor = this._sensor;\n try {\n sensor.stop();\n } catch {\n // Never-throw defensive guard, symmetric with start(). Teardown below\n // still runs so listeners are detached regardless.\n }\n this._teardownSensor(sensor);\n }\n\n /** Lifecycle alias for start(), so the Shell's connectedCallback can drive\n * this Core the same way as other IO nodes' observe()/dispose() pair. No\n * asynchronous probe, so the returned promise always resolves immediately. */\n observe(frequency?: number): Promise<void> {\n this.start(frequency);\n return this.ready;\n }\n\n /** Lifecycle alias for stop(), invoked from the Shell's disconnectedCallback. */\n dispose(): void {\n this.stop();\n }\n\n // --- Internal ---\n\n // Detach a sensor that is finished: stopped, failed in start(), or reported\n // an `error` event. A sensor whose `error` event arrives while its start()\n // is still running, and whose start() then throws, is torn down twice: the\n // second time its listeners are already off, which removeEventListener\n // takes — and a start() from an `error` listener may have put a newer\n // sensor in its place by then, which stays.\n private _teardownSensor(sensor: SensorLike | null): void {\n sensor?.removeEventListener(\"reading\", this._onReading as EventListener);\n sensor?.removeEventListener(\"error\", this._onError as EventListener);\n if (this._sensor === sensor) this._sensor = null;\n }\n\n /**\n * Construct the platform `Magnetometer`, guarding both non-support and a\n * synchronous constructor exception. Never calls the raw `new Magnetometer(...)`\n * anywhere else in this class — see docs/sensor-tag-design.md §1.5.\n *\n * API resolution is call-time (docs/async-io-node-guidelines.md §3.7):\n * re-checked on every start(), never cached, so tests can install/remove\n * the global freely and an unsupported environment is always reported\n * correctly.\n */\n private _createSensor(frequency?: number): SensorLike | null {\n const Ctor = (globalThis as any).Magnetometer;\n if (typeof Ctor !== \"function\") {\n this._setError({ error: \"unsupported\", message: \"Magnetometer is not supported\" });\n return null;\n }\n try {\n return new Ctor(frequency !== undefined ? { frequency } : undefined);\n } catch (e: any) {\n // SecurityError (permission denial, feature-policy block) or any other\n // synchronous construction failure. Mirrors the FetchCore._doFetch\n // try/catch structure (packages/fetch/src/core/FetchCore.ts) — a\n // synchronous constructor call here instead of an awaited fetch().\n this._setError({ error: e?.name ?? \"error\", message: e?.message ?? String(e) });\n return null;\n }\n }\n\n private _onReading = (event: Event): void => {\n const sensor = event.target as unknown as { x: number | null; y: number | null; z: number | null };\n this._setReading({ x: sensor.x, y: sensor.y, z: sensor.z });\n };\n\n private _onError = (event: Event): void => {\n const err = (event as any).error as { name?: string; message?: string } | undefined;\n // The sensor that reported the error is finished (the platform deactivates\n // it): detach it before publishing, so the next start() builds a fresh one\n // instead of taking this one for \"already started\". It is `_sensor`: this\n // listener is on a sensor only while that sensor is the current one.\n this._teardownSensor(this._sensor);\n // Fallback is a meaningful constant, NOT String(err): a SensorErrorEvent\n // without an `error` field would otherwise stringify `undefined` into the\n // literal message \"undefined\" (aligned across the sensor family).\n this._setError({ error: err?.name ?? \"error\", message: err?.message ?? \"Sensor error\" });\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, WcsMagnetometerErrorDetail } from \"../types.js\";\nimport { MagnetometerCore } from \"../core/MagnetometerCore.js\";\nimport { WcsIoErrorInfo } from \"../core/platformCapability.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute } from \"../protocol/inputAttribute.js\";\n\n/**\n * `<wcs-magnetometer>` — declarative Generic Sensor API (`Magnetometer`)\n * monitor + start/stop control.\n *\n * Unlike `<wcs-network>` / `<wcs-permission>` (pure monitors), this Shell is a\n * bidirectional node: `start`/`stop` commands (command-token: state → element)\n * alongside the `x`/`y`/`z`/`error` observable surface (event-token: element →\n * state). The `frequency` attribute is the sole configuration input, forwarded\n * to the platform `Magnetometer` constructor's `{ frequency }` option\n * (docs/sensor-tag-design.md §1.2). The getter normalizes it: a non-finite or\n * non-positive value (NaN, 0, negative) reads back as `null` — meaning \"no\n * frequency specified\" — so start() falls back to the platform default rather\n * than forwarding a value the sensor would reject, and says so once\n * (`[wcs/frequency-invalid]`). Any positive finite value is passed through\n * verbatim (no upper-bound clamping — the browser caps a rate above what it\n * allows).\n *\n * Permission handling is intentionally NOT implemented here. Compose with\n * `<wcs-permission name=\"magnetometer\">` instead (see the README's permission\n * example, \"Gate on permission, then start\", and docs/sensor-tag-design.md).\n */\nexport class WcsMagnetometer extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n\n static wcBindable: IWcBindable = {\n ...MagnetometerCore.wcBindable,\n inputs: [{ name: \"frequency\" }],\n // Core の commands をそのまま継承(単一情報源)。\n commands: MagnetometerCore.wcBindable.commands,\n };\n\n private _core: MagnetometerCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n private _frequencyWarned = false;\n\n constructor() {\n super();\n this._core = new MagnetometerCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-magnetometer:error\": (d) => ({ error: d != null }),\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/async-io-node-guidelines.md §3.6): attachInternals is\n // 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 // --- Attribute accessors ---\n\n /**\n * Sampling frequency in Hz. Reads back `null` when unset, blank, or when the\n * attribute does not parse to a positive finite number (NaN, `\"0\"`, negative)\n * — in every such \"no usable value\" case the platform default applies.\n *\n * Note the deliberate set/get asymmetry: `set frequency(0)` (or any\n * non-positive/non-finite value) still writes the attribute verbatim for\n * transparency/inspectability, but the getter normalizes it back to `null`.\n * A round-trip through a non-positive value therefore does NOT preserve it —\n * that value carries no valid sampling meaning, so it is treated as \"unset\"\n * on read. Only positive finite frequencies survive a set→get round-trip.\n *\n * This value is read only at `start()` time. There is no\n * `attributeChangedCallback`, and `MagnetometerCore.start()` is idempotent\n * while already started (a redundant call is a no-op), so setting\n * `frequency` (attribute or property) on an already-running sensor has no\n * effect until the caller `stop()`s and `start()`s again (see the README's\n * \"Notes & limitations\").\n */\n get frequency(): number | null {\n const attr = this.getAttribute(\"frequency\");\n if (attr === null || attr.trim() === \"\") return null;\n const parsed = Number(attr);\n return Number.isFinite(parsed) && parsed > 0 ? parsed : null;\n }\n\n set frequency(value: number | null | undefined) {\n // `null` removes the attribute (the platform default); `undefined` restores\n // the attribute the element started with — the authored frequency, or none\n // (wc-bindable producer guidance P1; React 19 and a direct assignment\n // deliver it, @wcstack/state does not).\n reflectAttribute(this, \"frequency\", value);\n }\n\n // --- Core delegated getters ---\n\n get x(): number | null {\n return this._core.x;\n }\n\n get y(): number | null {\n return this._core.y;\n }\n\n get z(): number | null {\n return this._core.z;\n }\n\n get error(): WcsMagnetometerErrorDetail | null {\n return this._core.error;\n }\n\n get errorInfo(): WcsIoErrorInfo | null {\n return this._core.errorInfo;\n }\n\n // Computed at call time: a binding reads it when it binds, with no event.\n get supported(): boolean {\n return this._core.supported;\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Commands ---\n\n start(): void {\n this._warnUnusableFrequency();\n this._core.start(this.frequency ?? undefined);\n }\n\n stop(): void {\n this._core.stop();\n }\n\n // A `frequency` that is written but is not a positive number (\"60hz\", \"0\")\n // reads back as null, and the sensor then runs at the browser's default rate\n // with nothing else saying so. Said once per element.\n private _warnUnusableFrequency(): void {\n if (this._frequencyWarned) return;\n const attr = this.getAttribute(\"frequency\");\n if (attr === null || attr.trim() === \"\" || this.frequency !== null) return;\n this._frequencyWarned = true;\n console.warn(\n `[@wcstack/magnetometer] [wcs/frequency-invalid] <${this.localName}> frequency=\"${attr}\" is not a ` +\n `positive number of Hz: the sensor runs at the browser's default rate. Write a number, e.g. frequency=\"30\".`,\n this,\n );\n }\n\n // --- Lifecycle ---\n\n // Deliberately does NOT auto-start the sensor on connect. Unlike\n // Geolocation (whose default phase acquires a fix immediately unless\n // `manual` is set), Magnetometer has no such \"connect implies observing\"\n // precedent in the design doc (docs/sensor-tag-design.md §1.3):\n // start/stop are the only commands, so connecting the element merely makes\n // it inert until a command-token `start` (or the `start()` method) is\n // invoked. This also keeps behavior predictable when composed with\n // `<wcs-permission name=\"magnetometer\">`: the caller decides when to start,\n // typically gated on `granted`.\n connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\n this.style.display = \"none\";\n // No asynchronous probe to await (docs/async-io-node-guidelines.md §3.8);\n // kept for SSR uniformity with other IO nodes.\n this._connectedCallbackPromise = this._core.ready;\n // Starts nothing: publishes `supported` when it differs from the value last dispatched.\n this._core.publishSupported();\n }\n\n // Moved by moveBefore() (a list row a reorder moves): where this element is changes nothing of what it\n // does, so nothing stops and nothing starts again. With no connectedMoveCallback the browser calls\n // disconnectedCallback and connectedCallback instead (docs/timing-and-firing-contract.md §25)\n connectedMoveCallback(): void {}\n\n disconnectedCallback(): void {\n this._core.dispose();\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 { WcsMagnetometer } from \"./components/Magnetometer.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.magnetometer, WcsMagnetometer],\n ]);\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapMagnetometer(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,YAAY,EAAE,kBAAkB;AACjC,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,GAA+B,CAAC,GAAG,CAAC,CAAC;IAC/D;AACA,IAAA,OAAO,KAAU;AACnB;AAEA,IAAI,YAAY,GAAmB,IAAI;AAEhC,MAAM,MAAM,GAAY,OAAkB;SAEjC,SAAS,GAAA;IACvB,IAAI,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;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,YAAY,EAAE,eAAe,CAAC;AAChD,KAAA,CAAC;AACJ;;ACVM,SAAU,qBAAqB,CAAC,UAA4B,EAAE,QAAgC,EAAA;IAClG,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/magnetometer",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.25.0",
|
|
4
4
|
"description": "Declarative Magnetometer component for Web Components. Framework-agnostic Generic Sensor API (Magnetometer) monitor via wc-bindable-protocol.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.esm.js",
|