@wcstack/tilt 1.20.0 → 1.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.ja.md CHANGED
@@ -7,7 +7,7 @@
7
7
  `@wcstack/state` と組み合わせると、`<wcs-tilt>` はパス契約で直接バインドできます:
8
8
 
9
9
  - **入力サーフェス**: 無し
10
- - **出力 state サーフェス**: `alpha`、`beta`、`gamma`、`absolute`、`permissionState`、`error`
10
+ - **出力 state サーフェス**: `alpha`、`beta`、`gamma`、`absolute`、`permissionState`、`error`、`errorInfo`
11
11
 
12
12
  ## なぜ存在するか — `@wcstack/idle`の兄弟、iOSのgesture-gateを吸収する
13
13
 
@@ -65,6 +65,7 @@ npm install @wcstack/tilt
65
65
  | `absolute` | `wcs-tilt:change` | 地磁気に対する絶対方位かどうか。ブラウザにより信頼性が異なるため実機で確認してください。 |
66
66
  | `permissionState` | `wcs-tilt:permission-changed` | `"granted"` \| `"denied"` \| `"unknown"`。 |
67
67
  | `error` | `wcs-tilt:error` | 直近の`requestPermission()`の失敗(gesture文脈外呼び出しのrejectなど)、無ければ`null`。never-throw: 失敗はreject/throwせず、ここに流れます。 |
68
+ | `errorInfo` | `wcs-tilt:error-info-changed` | `error`から派生した、失敗のserializableなtaxonomy(`WcsIoErrorInfo`: 安定した`code` / `phase` / `recoverable`)、無ければ`null`。additive —— `error`の形状は不変。 |
68
69
 
69
70
  ## コマンド
70
71
 
@@ -133,6 +134,7 @@ form:has(wcs-tilt:state(error)) .banner { display: block; }
133
134
 
134
135
  - **connect時に自動startしません。**
135
136
  - **`@wcstack/permission`とは合成しません**(対応するPermissions APIエントリが存在しないため)——`permissionState`はローカルで追跡します。
137
+ - **`errorInfo` taxonomy(additive)。** `error`と並んで、`<wcs-tilt>`は*同一の*失敗を安定した`WcsIoErrorInfo`(`code` / `phase` / `recoverable`)に分類したserializableな`errorInfo`(`wcs-tilt:error-info-changed`)を公開します。`error`の形状は変えません。ここで失敗しうるのは`requestPermission()`だけで、reject理由の`Error.name`で分類されます: `NotAllowedError`(iOSのDevice Orientation権限拒否)→ `not-allowed`(phase `start`)、それ以外(user-gesture文脈外のreject、非`Error`のreason)→ `tilt-error`(phase `execute`)。どちらも`recoverable: false`です。`capability-missing`コードは**ありません**: gatingの無いプラットフォームでは未対応環境はエラーにならず`"granted"`へ倒れるため、その分岐には到達しないからです。`errorInfo`は`error`とまったく同じタイミングで遷移し(回復時に`null`へクリア)、共有の`WcsIoErrorInfo`型と`WCS_TILT_ERROR_CODE`定数はexportされています。
136
138
  - `_gen`世代ガードは無し: 購読は完全に同期的です。
137
139
  - **非secure context(素のHTTP)では`deviceorientation`は一切発火しません**——ブラウザがネイティブに抑止し、`<wcs-tilt>`自身はガードを持たない(nativeの非発火を信頼する設計)ため、傾き値は`null`のまま・`wcs-tilt:change`は飛ばず・`permissionState`も(`requestPermission()`を呼ばない限り)`"unknown"`のまま変化しません。`requestPermission()`でも検出できません: gatingの無いプラットフォームではフォールバックが何も問い合わせずに`"granted"`を返します。何も起きないときは、まず配信元(HTTPS/localhost)を確認してください。
138
140
  - **Permissions-Policyでゲートされます。** `deviceorientation`イベントは`accelerometer`と`gyroscope`のPermissions-Policyディレクティブが許可されている場合にのみ発火します(既定allowlist: `self`、Device Orientation Events仕様§4準拠)。クロスオリジンの`<iframe>`内で`<wcs-tilt>`を使うには、その`<iframe>`要素に`allow="accelerometer; gyroscope"`が必要です——無いとイベントは無音のまま一切発火しません。上記の非secure originのケースと同じ失敗モードです。
package/README.md CHANGED
@@ -8,7 +8,7 @@ It is an **async primitive node** that turns device tilt (`deviceorientation`) i
8
8
  With `@wcstack/state`, `<wcs-tilt>` can be bound directly through path contracts:
9
9
 
10
10
  - **input surface**: none
11
- - **output state surface**: `alpha`, `beta`, `gamma`, `absolute`, `permissionState`, `error`
11
+ - **output state surface**: `alpha`, `beta`, `gamma`, `absolute`, `permissionState`, `error`, `errorInfo`
12
12
 
13
13
  ## Why this exists — the iOS gesture-gate absorption sibling to `@wcstack/idle`
14
14
 
@@ -66,6 +66,7 @@ Every path referenced by `data-wcs` (`tiltBeta`, `tiltGamma`, `tiltTransform`, `
66
66
  | `absolute` | `wcs-tilt:change` | Whether the reading is relative to the Earth's frame. Reliability varies by browser — verify on your target devices. |
67
67
  | `permissionState` | `wcs-tilt:permission-changed` | `"granted"` \| `"denied"` \| `"unknown"`. |
68
68
  | `error` | `wcs-tilt:error` | The last `requestPermission()` failure (e.g. a gesture-context rejection), or `null`. never-throw: failures never reject/throw, they land here instead. |
69
+ | `errorInfo` | `wcs-tilt:error-info-changed` | Serializable failure taxonomy (`WcsIoErrorInfo`: stable `code` / `phase` / `recoverable`) derived from `error`, or `null`. Additive — the `error` shape is unchanged. |
69
70
 
70
71
  ## Commands
71
72
 
@@ -137,6 +138,7 @@ DevTools open; it is not a supported styling hook.
137
138
 
138
139
  - **Does not auto-start on connect.**
139
140
  - **Does not compose with `@wcstack/permission`** (no matching Permissions API entry exists) — `permissionState` is tracked locally.
141
+ - **`errorInfo` taxonomy (additive).** Alongside `error`, `<wcs-tilt>` publishes a serializable `errorInfo` (`wcs-tilt:error-info-changed`) that classifies the *same* failure into a stable `WcsIoErrorInfo` (`code` / `phase` / `recoverable`), without changing the `error` shape. Only `requestPermission()` can fail here, classified by the rejection reason's `Error.name`: a `NotAllowedError` (iOS Device Orientation permission denied) → `not-allowed` (phase `start`); anything else (a rejection outside a user-gesture context, a non-`Error` reason) → `tilt-error` (phase `execute`). Both are `recoverable: false`. There is **no** `capability-missing` code: on gate-less platforms an unsupported environment resolves to `"granted"` rather than erroring, so that branch is unreachable. `errorInfo` transitions exactly when `error` does (cleared to `null` on recovery); the shared `WcsIoErrorInfo` type and the `WCS_TILT_ERROR_CODE` constants are exported.
140
142
  - No `_gen` generation guard: subscribing is fully synchronous.
141
143
  - **On a non-secure origin (plain HTTP), `deviceorientation` never fires** — the browser suppresses it natively and `<wcs-tilt>` adds no guard of its own, so tilt values stay `null`, `wcs-tilt:change` never dispatches, and `permissionState` stays `"unknown"` (until you call `requestPermission()`). Calling `requestPermission()` cannot detect this either: on gate-less platforms its fallback resolves `"granted"` without probing anything. If nothing seems to happen, check your origin first.
142
144
  - **Permissions-Policy gate.** The `deviceorientation` event is only dispatched when the `accelerometer` and `gyroscope` Permissions-Policy directives are allowed (default allowlist: `self`, per the Device Orientation Events spec §4). Using `<wcs-tilt>` inside a cross-origin `<iframe>` requires `allow="accelerometer; gyroscope"` on that `<iframe>` element — otherwise the event silently never fires, the same failure mode as the non-secure-origin case above.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,14 @@
1
+ /** operation error の phase(taxonomy)。 */
2
+ type WcsIoErrorPhase = "probe" | "start" | "execute" | "decode" | "commit" | "dispose";
3
+ /** serializable な error info(non-cloneable な cause とは分離。DevTools / remote へは info のみ)。 */
4
+ interface WcsIoErrorInfo {
5
+ readonly code: string;
6
+ readonly phase: WcsIoErrorPhase;
7
+ readonly recoverable: boolean;
8
+ readonly capabilityId?: string;
9
+ readonly message: string;
10
+ }
11
+
1
12
  interface IWcBindableProperty {
2
13
  readonly name: string;
3
14
  readonly event: string;
@@ -13,7 +24,8 @@ interface IWcBindableCommand {
13
24
  }
14
25
  interface IWcBindable {
15
26
  readonly protocol: "wc-bindable";
16
- readonly version: 1;
27
+ /** Integer protocol version. All versions >= 1 are core-compatible. */
28
+ readonly version: number;
17
29
  readonly properties: readonly IWcBindableProperty[];
18
30
  readonly inputs?: readonly IWcBindableInput[];
19
31
  readonly commands?: readonly IWcBindableCommand[];
@@ -50,6 +62,8 @@ interface WcsTiltCoreValues {
50
62
  absolute: boolean | null;
51
63
  permissionState: TiltPermissionState;
52
64
  error: any;
65
+ /** Additive failure taxonomy derived from `error` (stable code / phase / recoverable). */
66
+ errorInfo: WcsIoErrorInfo | null;
53
67
  }
54
68
  /**
55
69
  * Value types for the Shell (`<wcs-tilt>`) — identical observable surface to
@@ -88,6 +102,7 @@ declare class TiltCore extends EventTarget {
88
102
  private _snapshot;
89
103
  private _permissionState;
90
104
  private _error;
105
+ private _errorInfo;
91
106
  private _subscribed;
92
107
  private _ready;
93
108
  constructor(target?: EventTarget);
@@ -98,11 +113,19 @@ declare class TiltCore extends EventTarget {
98
113
  get absolute(): boolean | null;
99
114
  get permissionState(): TiltPermissionState;
100
115
  get error(): any;
116
+ /**
117
+ * The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /
118
+ * `recoverable`), or null. Additive wc-bindable property (event
119
+ * `wcs-tilt:error-info-changed`), derived from `error`; the existing `error`
120
+ * property/event are unchanged.
121
+ */
122
+ get errorInfo(): WcsIoErrorInfo | null;
101
123
  observe(): Promise<void>;
102
124
  dispose(): void;
103
125
  private _deviceOrientationEventCtor;
104
126
  private _setPermissionState;
105
127
  private _setError;
128
+ private _commitErrorInfo;
106
129
  /**
107
130
  * Wraps iOS 13+ Safari's static, gesture-gated
108
131
  * `DeviceOrientationEvent.requestPermission()`. On platforms without this
@@ -152,6 +175,7 @@ declare class WcsTilt extends HTMLElement {
152
175
  get absolute(): boolean | null;
153
176
  get permissionState(): TiltPermissionState;
154
177
  get error(): any;
178
+ get errorInfo(): WcsIoErrorInfo | null;
155
179
  get connectedCallbackPromise(): Promise<void>;
156
180
  requestPermission(): Promise<TiltPermissionState>;
157
181
  start(): void;
@@ -160,5 +184,37 @@ declare class WcsTilt extends HTMLElement {
160
184
  disconnectedCallback(): void;
161
185
  }
162
186
 
163
- export { TiltCore, WcsTilt, bootstrapTilt, getConfig };
164
- export type { IWritableConfig, IWritableTagNames, TiltPermissionState, WcsTiltCoreValues, WcsTiltValues };
187
+ /**
188
+ * tiltCapabilities.ts
189
+ *
190
+ * Tilt(Device Orientation)node 固有の error code(taxonomy)と derivation。汎用の
191
+ * error info 型は `./platformCapability.js`(/io-core/ から copy-distribution される
192
+ * 生成ファイル)から import する。tilt は監視系(deviceorientation の subscribe/
193
+ * unsubscribe)で競合する operation を持たないため lane は持たず、error taxonomy
194
+ * (errorInfo)のみを採用する。
195
+ *
196
+ * sensor 4 兄弟(accelerometer / gyroscope / magnetometer / ambient-light-sensor)と
197
+ * 違い、tilt の error 面は **異なる shape** を持つ:
198
+ * - sensor 族の error detail は `{ error: <Error.name>, message }`(name/message は文字列)。
199
+ * - tilt の error detail は `{ error: <生の rejection reason> }`(TiltCore._setError が
200
+ * `requestPermission()` の catch で `{ error: e }` を渡す。`e` は生の Error/reason)。
201
+ *
202
+ * したがって derive は「wrap された生の値」から name/message を取り出す。また tilt は
203
+ * "unsupported"(capability-missing)経路を **持たない**: `DeviceOrientationEvent` や
204
+ * その `requestPermission` が無い環境では error にせず `"granted"` に倒して error を
205
+ * クリアする(docs/device-orientation-tag-design.md §3)。よって capability-missing の
206
+ * code / branch は生成しない(到達不能・dead code を避ける)。error として _setError に
207
+ * 届くのは iOS の `requestPermission()` reject だけで、その name は実権限拒否なら
208
+ * `NotAllowedError`、gesture 文脈外等なら汎用 `Error` になる。
209
+ */
210
+
211
+ /** 安定した tilt error code(taxonomy)。値は公開キーとして固定。 */
212
+ declare const WCS_TILT_ERROR_CODE: {
213
+ /** `NotAllowedError` — iOS の Device Orientation 権限拒否。 */
214
+ readonly NotAllowed: "not-allowed";
215
+ /** その他の `requestPermission()` reject(gesture 文脈外 / 想定外の失敗)。 */
216
+ readonly TiltError: "tilt-error";
217
+ };
218
+
219
+ export { TiltCore, WCS_TILT_ERROR_CODE, WcsTilt, bootstrapTilt, getConfig };
220
+ export type { IWritableConfig, IWritableTagNames, TiltPermissionState, WcsIoErrorInfo, WcsIoErrorPhase, WcsTiltCoreValues, WcsTiltValues };
package/dist/index.esm.js CHANGED
@@ -36,6 +36,57 @@ function setConfig(partialConfig) {
36
36
  frozenConfig = null;
37
37
  }
38
38
 
39
+ /**
40
+ * tiltCapabilities.ts
41
+ *
42
+ * Tilt(Device Orientation)node 固有の error code(taxonomy)と derivation。汎用の
43
+ * error info 型は `./platformCapability.js`(/io-core/ から copy-distribution される
44
+ * 生成ファイル)から import する。tilt は監視系(deviceorientation の subscribe/
45
+ * unsubscribe)で競合する operation を持たないため lane は持たず、error taxonomy
46
+ * (errorInfo)のみを採用する。
47
+ *
48
+ * sensor 4 兄弟(accelerometer / gyroscope / magnetometer / ambient-light-sensor)と
49
+ * 違い、tilt の error 面は **異なる shape** を持つ:
50
+ * - sensor 族の error detail は `{ error: <Error.name>, message }`(name/message は文字列)。
51
+ * - tilt の error detail は `{ error: <生の rejection reason> }`(TiltCore._setError が
52
+ * `requestPermission()` の catch で `{ error: e }` を渡す。`e` は生の Error/reason)。
53
+ *
54
+ * したがって derive は「wrap された生の値」から name/message を取り出す。また tilt は
55
+ * "unsupported"(capability-missing)経路を **持たない**: `DeviceOrientationEvent` や
56
+ * その `requestPermission` が無い環境では error にせず `"granted"` に倒して error を
57
+ * クリアする(docs/device-orientation-tag-design.md §3)。よって capability-missing の
58
+ * code / branch は生成しない(到達不能・dead code を避ける)。error として _setError に
59
+ * 届くのは iOS の `requestPermission()` reject だけで、その name は実権限拒否なら
60
+ * `NotAllowedError`、gesture 文脈外等なら汎用 `Error` になる。
61
+ */
62
+ /** 安定した tilt error code(taxonomy)。値は公開キーとして固定。 */
63
+ const WCS_TILT_ERROR_CODE = {
64
+ /** `NotAllowedError` — iOS の Device Orientation 権限拒否。 */
65
+ NotAllowed: "not-allowed",
66
+ /** その他の `requestPermission()` reject(gesture 文脈外 / 想定外の失敗)。 */
67
+ TiltError: "tilt-error",
68
+ };
69
+ /**
70
+ * tilt の失敗(`_setError` に渡る `{ error: <生の reason> }`)を serializable な error
71
+ * taxonomy に写す。name は wrap された reason の `Error.name`、message はその `.message`
72
+ * (無ければ `String(...)`)。
73
+ *
74
+ * - `NotAllowedError` は iOS の権限拒否 → phase="start" / not-allowed。retry で回復しない。
75
+ * - それ以外(gesture 文脈外の汎用 `Error`、非 Error reason 等)→ phase="execute" /
76
+ * tilt-error。
77
+ *
78
+ * capability-missing 経路は無い(上のヘッダ参照): 非対応環境は error ではなく
79
+ * `"granted"` へ倒れるため、ここには到達しない。
80
+ */
81
+ function deriveTiltErrorInfo(detail) {
82
+ const name = detail.error?.name;
83
+ const message = detail.error?.message ?? String(detail.error);
84
+ if (name === "NotAllowedError") {
85
+ return { code: WCS_TILT_ERROR_CODE.NotAllowed, phase: "start", recoverable: false, message };
86
+ }
87
+ return { code: WCS_TILT_ERROR_CODE.TiltError, phase: "execute", recoverable: false, message };
88
+ }
89
+
39
90
  const UNSUPPORTED_SNAPSHOT = Object.freeze({
40
91
  alpha: null,
41
92
  beta: null,
@@ -77,6 +128,11 @@ class TiltCore extends EventTarget {
77
128
  // rejecting/throwing. Mirrors idle (same batch2) and the accelerometer
78
129
  // family (batch5) — see docs/io-node-batch-implementation-plan.md.
79
130
  { name: "error", event: "wcs-tilt:error" },
131
+ // Serializable failure taxonomy (stable code / phase / recoverable), or null.
132
+ // Additive bindable output derived from `error.error` (the wrapped rejection's
133
+ // Error.name); the existing `error` property/event are unchanged. Fires
134
+ // wcs-tilt:error-info-changed. No lane — this is a monitor node.
135
+ { name: "errorInfo", event: "wcs-tilt:error-info-changed" },
80
136
  ],
81
137
  commands: [
82
138
  { name: "requestPermission", async: true },
@@ -88,6 +144,7 @@ class TiltCore extends EventTarget {
88
144
  _snapshot = UNSUPPORTED_SNAPSHOT;
89
145
  _permissionState = "unknown";
90
146
  _error = null;
147
+ _errorInfo = null;
91
148
  _subscribed = false;
92
149
  // SSR (§3.8): never auto-starts on connect, so there is no probe to await —
93
150
  // readiness is always immediate.
@@ -117,6 +174,15 @@ class TiltCore extends EventTarget {
117
174
  get error() {
118
175
  return this._error;
119
176
  }
177
+ /**
178
+ * The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /
179
+ * `recoverable`), or null. Additive wc-bindable property (event
180
+ * `wcs-tilt:error-info-changed`), derived from `error`; the existing `error`
181
+ * property/event are unchanged.
182
+ */
183
+ get errorInfo() {
184
+ return this._errorInfo;
185
+ }
120
186
  // Lifecycle (§3.5). observe() is a synchronous no-op: like `<wcs-idle>`,
121
187
  // this Core deliberately does NOT auto-start on connect (§6) on platforms
122
188
  // that gate deviceorientation behind requestPermission().
@@ -143,11 +209,26 @@ class TiltCore extends EventTarget {
143
209
  if (this._error === error)
144
210
  return;
145
211
  this._error = error;
212
+ // Keep the additive `errorInfo` taxonomy in sync with `error`: derive from the
213
+ // wrapped rejection (or null on clear). Fires before the `error` event so an
214
+ // observer binding both sees the classification first, mirroring the io-node
215
+ // family.
216
+ this._commitErrorInfo(error === null ? null : deriveTiltErrorInfo(error));
146
217
  this._target.dispatchEvent(new CustomEvent("wcs-tilt:error", {
147
218
  detail: error,
148
219
  bubbles: true,
149
220
  }));
150
221
  }
222
+ // Called only from _setError (which already reference-guards on the error
223
+ // object), so errorInfo transitions exactly when error does — no separate
224
+ // guard needed here.
225
+ _commitErrorInfo(info) {
226
+ this._errorInfo = info;
227
+ this._target.dispatchEvent(new CustomEvent("wcs-tilt:error-info-changed", {
228
+ detail: info,
229
+ bubbles: true,
230
+ }));
231
+ }
151
232
  /**
152
233
  * Wraps iOS 13+ Safari's static, gesture-gated
153
234
  * `DeviceOrientationEvent.requestPermission()`. On platforms without this
@@ -318,6 +399,9 @@ class WcsTilt extends HTMLElement {
318
399
  get error() {
319
400
  return this._core.error;
320
401
  }
402
+ get errorInfo() {
403
+ return this._core.errorInfo;
404
+ }
321
405
  get connectedCallbackPromise() {
322
406
  return this._connectedCallbackPromise;
323
407
  }
@@ -354,5 +438,5 @@ function bootstrapTilt(userConfig) {
354
438
  registerComponents();
355
439
  }
356
440
 
357
- export { TiltCore, WcsTilt, bootstrapTilt, getConfig };
441
+ export { TiltCore, WCS_TILT_ERROR_CODE, WcsTilt, bootstrapTilt, getConfig };
358
442
  //# sourceMappingURL=index.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/config.ts","../src/core/TiltCore.ts","../src/components/Tilt.ts","../src/registerComponents.ts","../src/bootstrapTilt.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n tilt: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n tilt: \"wcs-tilt\",\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\nexport function setConfig(partialConfig: IWritableConfig): void {\n if (partialConfig.tagNames) {\n Object.assign(_config.tagNames, partialConfig.tagNames);\n }\n frozenConfig = null;\n}\n","import { IWcBindable, TiltPermissionState } from \"../types.js\";\n\ninterface DeviceOrientationEventCtor {\n requestPermission?: () => Promise<\"granted\" | \"denied\">;\n}\n\ninterface WcsTiltSnapshot {\n alpha: number | null;\n beta: number | null;\n gamma: number | null;\n absolute: boolean | null;\n}\n\nconst UNSUPPORTED_SNAPSHOT: WcsTiltSnapshot = Object.freeze({\n alpha: null,\n beta: null,\n gamma: null,\n absolute: null,\n});\n\n/**\n * Headless Device Orientation primitive. A thin, framework-agnostic wrapper\n * around `window`'s `deviceorientation` event exposed through the wc-bindable\n * protocol.\n *\n * The batch2 sibling of `@wcstack/idle` (docs/device-orientation-tag-design.md).\n * Unlike Idle Detection, there is no matching Permissions API entry for this\n * feature (`navigator.permissions.query` has no \"device-orientation\" name), so\n * `permissionState` must be tracked **locally** rather than composed with\n * `<wcs-permission>` — the defining asymmetry within batch2.\n *\n * No `_gen` generation guard: subscribing/unsubscribing to `deviceorientation`\n * (start/stop) is fully synchronous, so that path never needs one. This node\n * does have an async probe — `requestPermission()` awaits the static\n * `DeviceOrientationEvent.requestPermission()` — but its post-await write is\n * a benign `permissionState`/`error` value set + dispatch with no\n * subscription/resource management to race, so `_gen` is unneeded there too\n * (docs/device-orientation-tag-design.md §4, corrected after an earlier\n * revision mistakenly reused `@wcstack/network`'s \"no async probe at all\"\n * rationale).\n */\nexport class TiltCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"alpha\", event: \"wcs-tilt:change\", getter: (e: Event) => (e as CustomEvent).detail.alpha },\n { name: \"beta\", event: \"wcs-tilt:change\", getter: (e: Event) => (e as CustomEvent).detail.beta },\n { name: \"gamma\", event: \"wcs-tilt:change\", getter: (e: Event) => (e as CustomEvent).detail.gamma },\n { name: \"absolute\", event: \"wcs-tilt:change\", getter: (e: Event) => (e as CustomEvent).detail.absolute },\n { name: \"permissionState\", event: \"wcs-tilt:permission-changed\" },\n // never-throw (§3.6): requestPermission() failures land here instead of\n // rejecting/throwing. Mirrors idle (same batch2) and the accelerometer\n // family (batch5) — see docs/io-node-batch-implementation-plan.md.\n { name: \"error\", event: \"wcs-tilt:error\" },\n ],\n commands: [\n { name: \"requestPermission\", async: true },\n { name: \"start\" },\n { name: \"stop\" },\n ],\n };\n\n private _target: EventTarget;\n private _snapshot: WcsTiltSnapshot = UNSUPPORTED_SNAPSHOT;\n private _permissionState: TiltPermissionState = \"unknown\";\n private _error: any = null;\n private _subscribed = false;\n\n // SSR (§3.8): never auto-starts on connect, so there is no probe to await —\n // readiness is always immediate.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n get ready(): Promise<void> {\n return this._ready;\n }\n\n get alpha(): number | null {\n return this._snapshot.alpha;\n }\n\n get beta(): number | null {\n return this._snapshot.beta;\n }\n\n get gamma(): number | null {\n return this._snapshot.gamma;\n }\n\n get absolute(): boolean | null {\n return this._snapshot.absolute;\n }\n\n get permissionState(): TiltPermissionState {\n return this._permissionState;\n }\n\n get error(): any {\n return this._error;\n }\n\n // Lifecycle (§3.5). observe() is a synchronous no-op: like `<wcs-idle>`,\n // this Core deliberately does NOT auto-start on connect (§6) on platforms\n // that gate deviceorientation behind requestPermission().\n observe(): Promise<void> {\n return this._ready;\n }\n\n dispose(): void {\n this.stop();\n }\n\n private _deviceOrientationEventCtor(): DeviceOrientationEventCtor | undefined {\n const g = globalThis as any;\n return typeof g.DeviceOrientationEvent !== \"undefined\" ? g.DeviceOrientationEvent : undefined;\n }\n\n private _setPermissionState(state: TiltPermissionState): void {\n if (this._permissionState === state) return;\n this._permissionState = state;\n this._target.dispatchEvent(new CustomEvent(\"wcs-tilt:permission-changed\", {\n detail: state,\n bubbles: true,\n }));\n }\n\n private _setError(error: any): void {\n if (this._error === error) return;\n this._error = error;\n this._target.dispatchEvent(new CustomEvent(\"wcs-tilt:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n /**\n * Wraps iOS 13+ Safari's static, gesture-gated\n * `DeviceOrientationEvent.requestPermission()`. On platforms without this\n * gate (Android Chrome, desktop) there is nothing to ask, so this resolves\n * to `\"granted\"` immediately without querying anything — callers can write\n * one `requestPermission()` → `start()` flow that works everywhere\n * (docs/device-orientation-tag-design.md §3).\n *\n * never-throw (§3.6): a gesture-context rejection resolves to `\"denied\"`\n * and the raw error lands in `error` instead of propagating. Mirrors\n * `<wcs-idle>`'s `requestPermission()` (docs/idle-detection-tag-design.md\n * §4.1) — any settled (non-throwing) outcome supersedes a stale `error`\n * from an earlier attempt.\n */\n async requestPermission(): Promise<TiltPermissionState> {\n const Ctor = this._deviceOrientationEventCtor();\n if (typeof Ctor?.requestPermission !== \"function\") {\n this._setError(null);\n this._setPermissionState(\"granted\");\n return \"granted\";\n }\n try {\n const result = await Ctor.requestPermission();\n const state: TiltPermissionState = result === \"granted\" ? \"granted\" : \"denied\";\n this._setError(null);\n this._setPermissionState(state);\n return state;\n } catch (e) {\n // never-throw: a gesture-context rejection resolves to \"denied\".\n this._setError({ error: e });\n this._setPermissionState(\"denied\");\n return \"denied\";\n }\n }\n\n /** Subscribe to `deviceorientation`. Idempotent — a second start() while already subscribed is a no-op. */\n start(): void {\n if (this._subscribed) return;\n this._subscribed = true;\n globalThis.window?.addEventListener(\"deviceorientation\", this._onOrientation as EventListener);\n }\n\n /** Unsubscribe from `deviceorientation`. Safe to call when not started. */\n stop(): void {\n if (!this._subscribed) return;\n this._subscribed = false;\n globalThis.window?.removeEventListener(\"deviceorientation\", this._onOrientation as EventListener);\n }\n\n private _onOrientation = (event: DeviceOrientationEvent): void => {\n this._apply({\n alpha: event.alpha,\n beta: event.beta,\n gamma: event.gamma,\n absolute: event.absolute,\n });\n };\n\n // Same-value guard (§3.3 MUST).\n private _apply(next: WcsTiltSnapshot): void {\n const prev = this._snapshot;\n if (\n prev.alpha === next.alpha &&\n prev.beta === next.beta &&\n prev.gamma === next.gamma &&\n prev.absolute === next.absolute\n ) {\n return;\n }\n this._snapshot = next;\n this._target.dispatchEvent(new CustomEvent(\"wcs-tilt:change\", {\n detail: next,\n bubbles: true,\n }));\n }\n}\n","import { IWcBindable, TiltPermissionState } from \"../types.js\";\nimport { TiltCore } from \"../core/TiltCore.js\";\n\n/**\n * `<wcs-tilt>` — declarative Device Orientation API monitor.\n *\n * Named `tilt` (not `orientation`/`device-orientation`) to avoid colliding\n * with `<wcs-screen-orientation>` (docs/device-orientation-tag-design.md §9).\n *\n * Does NOT auto-start on connect, mirroring `<wcs-idle>`: on iOS, subscribing\n * before permission is granted silently receives no events. Callers drive\n * `requestPermission()` → `start()` explicitly.\n */\nexport class WcsTilt extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n\n static wcBindable: IWcBindable = {\n ...TiltCore.wcBindable,\n inputs: [],\n // Core の commands をそのまま継承(単一情報源)。\n commands: TiltCore.wcBindable.commands,\n };\n\n private _core: TiltCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new TiltCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-tilt: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 (async-io-node-guidelines.md §3.6): attachInternals is absent\n // 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 // --- Core delegated getters ---\n\n get alpha(): number | null {\n return this._core.alpha;\n }\n\n get beta(): number | null {\n return this._core.beta;\n }\n\n get gamma(): number | null {\n return this._core.gamma;\n }\n\n get absolute(): boolean | null {\n return this._core.absolute;\n }\n\n get permissionState(): TiltPermissionState {\n return this._core.permissionState;\n }\n\n get error(): any {\n return this._core.error;\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Commands (delegated to Core) ---\n\n requestPermission(): Promise<TiltPermissionState> {\n return this._core.requestPermission();\n }\n\n start(): void {\n this._core.start();\n }\n\n stop(): void {\n this._core.stop();\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n this.style.display = \"none\";\n this._connectedCallbackPromise = this._core.observe();\n }\n\n disconnectedCallback(): void {\n this._core.dispose();\n }\n}\n","import { WcsTilt } from \"./components/Tilt.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.tilt)) {\n customElements.define(config.tagNames.tilt, WcsTilt);\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapTilt(userConfig?: IWritableConfig): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents();\n}\n"],"names":[],"mappings":"AAQA,MAAM,OAAO,GAAoB;AAC/B,IAAA,QAAQ,EAAE;AACR,QAAA,IAAI,EAAE,UAAU;AACjB,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,C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CAAC;IACtD;AACF;;ACHM,SAAU,aAAa,CAAC,UAA4B,EAAA;IACxD,IAAI,UAAU,EAAE;QACd,SAAS,CAAC,UAAU,CAAC;IACvB;AACA,IAAA,kBAAkB,EAAE;AACtB;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":["../src/config.ts","../src/core/tiltCapabilities.ts","../src/core/TiltCore.ts","../src/components/Tilt.ts","../src/registerComponents.ts","../src/bootstrapTilt.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n tilt: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n tilt: \"wcs-tilt\",\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\nexport function setConfig(partialConfig: IWritableConfig): void {\n if (partialConfig.tagNames) {\n Object.assign(_config.tagNames, partialConfig.tagNames);\n }\n frozenConfig = null;\n}\n","/**\n * tiltCapabilities.ts\n *\n * Tilt(Device Orientation)node 固有の error code(taxonomy)と derivation。汎用の\n * error info 型は `./platformCapability.js`(/io-core/ から copy-distribution される\n * 生成ファイル)から import する。tilt は監視系(deviceorientation の subscribe/\n * unsubscribe)で競合する operation を持たないため lane は持たず、error taxonomy\n * (errorInfo)のみを採用する。\n *\n * sensor 4 兄弟(accelerometer / gyroscope / magnetometer / ambient-light-sensor)と\n * 違い、tilt の error 面は **異なる shape** を持つ:\n * - sensor 族の error detail は `{ error: <Error.name>, message }`(name/message は文字列)。\n * - tilt の error detail は `{ error: <生の rejection reason> }`(TiltCore._setError が\n * `requestPermission()` の catch で `{ error: e }` を渡す。`e` は生の Error/reason)。\n *\n * したがって derive は「wrap された生の値」から name/message を取り出す。また tilt は\n * \"unsupported\"(capability-missing)経路を **持たない**: `DeviceOrientationEvent` や\n * その `requestPermission` が無い環境では error にせず `\"granted\"` に倒して error を\n * クリアする(docs/device-orientation-tag-design.md §3)。よって capability-missing の\n * code / branch は生成しない(到達不能・dead code を避ける)。error として _setError に\n * 届くのは iOS の `requestPermission()` reject だけで、その name は実権限拒否なら\n * `NotAllowedError`、gesture 文脈外等なら汎用 `Error` になる。\n */\n\nimport type { WcsIoErrorInfo } from \"./platformCapability.js\";\n\n/** 安定した tilt error code(taxonomy)。値は公開キーとして固定。 */\nexport const WCS_TILT_ERROR_CODE = {\n /** `NotAllowedError` — iOS の Device Orientation 権限拒否。 */\n NotAllowed: \"not-allowed\",\n /** その他の `requestPermission()` reject(gesture 文脈外 / 想定外の失敗)。 */\n TiltError: \"tilt-error\",\n} as const;\n\n/**\n * tilt の失敗(`_setError` に渡る `{ error: <生の reason> }`)を serializable な error\n * taxonomy に写す。name は wrap された reason の `Error.name`、message はその `.message`\n * (無ければ `String(...)`)。\n *\n * - `NotAllowedError` は iOS の権限拒否 → phase=\"start\" / not-allowed。retry で回復しない。\n * - それ以外(gesture 文脈外の汎用 `Error`、非 Error reason 等)→ phase=\"execute\" /\n * tilt-error。\n *\n * capability-missing 経路は無い(上のヘッダ参照): 非対応環境は error ではなく\n * `\"granted\"` へ倒れるため、ここには到達しない。\n */\nexport function deriveTiltErrorInfo(detail: { error?: any }): WcsIoErrorInfo {\n const name: string | undefined = detail.error?.name;\n const message: string = detail.error?.message ?? String(detail.error);\n if (name === \"NotAllowedError\") {\n return { code: WCS_TILT_ERROR_CODE.NotAllowed, phase: \"start\", recoverable: false, message };\n }\n return { code: WCS_TILT_ERROR_CODE.TiltError, phase: \"execute\", recoverable: false, message };\n}\n","import { IWcBindable, TiltPermissionState } from \"../types.js\";\nimport { WcsIoErrorInfo } from \"./platformCapability.js\";\nimport { deriveTiltErrorInfo } from \"./tiltCapabilities.js\";\n\ninterface DeviceOrientationEventCtor {\n requestPermission?: () => Promise<\"granted\" | \"denied\">;\n}\n\ninterface WcsTiltSnapshot {\n alpha: number | null;\n beta: number | null;\n gamma: number | null;\n absolute: boolean | null;\n}\n\nconst UNSUPPORTED_SNAPSHOT: WcsTiltSnapshot = Object.freeze({\n alpha: null,\n beta: null,\n gamma: null,\n absolute: null,\n});\n\n/**\n * Headless Device Orientation primitive. A thin, framework-agnostic wrapper\n * around `window`'s `deviceorientation` event exposed through the wc-bindable\n * protocol.\n *\n * The batch2 sibling of `@wcstack/idle` (docs/device-orientation-tag-design.md).\n * Unlike Idle Detection, there is no matching Permissions API entry for this\n * feature (`navigator.permissions.query` has no \"device-orientation\" name), so\n * `permissionState` must be tracked **locally** rather than composed with\n * `<wcs-permission>` — the defining asymmetry within batch2.\n *\n * No `_gen` generation guard: subscribing/unsubscribing to `deviceorientation`\n * (start/stop) is fully synchronous, so that path never needs one. This node\n * does have an async probe — `requestPermission()` awaits the static\n * `DeviceOrientationEvent.requestPermission()` — but its post-await write is\n * a benign `permissionState`/`error` value set + dispatch with no\n * subscription/resource management to race, so `_gen` is unneeded there too\n * (docs/device-orientation-tag-design.md §4, corrected after an earlier\n * revision mistakenly reused `@wcstack/network`'s \"no async probe at all\"\n * rationale).\n */\nexport class TiltCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"alpha\", event: \"wcs-tilt:change\", getter: (e: Event) => (e as CustomEvent).detail.alpha },\n { name: \"beta\", event: \"wcs-tilt:change\", getter: (e: Event) => (e as CustomEvent).detail.beta },\n { name: \"gamma\", event: \"wcs-tilt:change\", getter: (e: Event) => (e as CustomEvent).detail.gamma },\n { name: \"absolute\", event: \"wcs-tilt:change\", getter: (e: Event) => (e as CustomEvent).detail.absolute },\n { name: \"permissionState\", event: \"wcs-tilt:permission-changed\" },\n // never-throw (§3.6): requestPermission() failures land here instead of\n // rejecting/throwing. Mirrors idle (same batch2) and the accelerometer\n // family (batch5) — see docs/io-node-batch-implementation-plan.md.\n { name: \"error\", event: \"wcs-tilt:error\" },\n // Serializable failure taxonomy (stable code / phase / recoverable), or null.\n // Additive bindable output derived from `error.error` (the wrapped rejection's\n // Error.name); the existing `error` property/event are unchanged. Fires\n // wcs-tilt:error-info-changed. No lane — this is a monitor node.\n { name: \"errorInfo\", event: \"wcs-tilt:error-info-changed\" },\n ],\n commands: [\n { name: \"requestPermission\", async: true },\n { name: \"start\" },\n { name: \"stop\" },\n ],\n };\n\n private _target: EventTarget;\n private _snapshot: WcsTiltSnapshot = UNSUPPORTED_SNAPSHOT;\n private _permissionState: TiltPermissionState = \"unknown\";\n private _error: any = null;\n private _errorInfo: WcsIoErrorInfo | null = null;\n private _subscribed = false;\n\n // SSR (§3.8): never auto-starts on connect, so there is no probe to await —\n // readiness is always immediate.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n get ready(): Promise<void> {\n return this._ready;\n }\n\n get alpha(): number | null {\n return this._snapshot.alpha;\n }\n\n get beta(): number | null {\n return this._snapshot.beta;\n }\n\n get gamma(): number | null {\n return this._snapshot.gamma;\n }\n\n get absolute(): boolean | null {\n return this._snapshot.absolute;\n }\n\n get permissionState(): TiltPermissionState {\n return this._permissionState;\n }\n\n get error(): any {\n return this._error;\n }\n\n /**\n * The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /\n * `recoverable`), or null. Additive wc-bindable property (event\n * `wcs-tilt:error-info-changed`), derived from `error`; the existing `error`\n * property/event are unchanged.\n */\n get errorInfo(): WcsIoErrorInfo | null {\n return this._errorInfo;\n }\n\n // Lifecycle (§3.5). observe() is a synchronous no-op: like `<wcs-idle>`,\n // this Core deliberately does NOT auto-start on connect (§6) on platforms\n // that gate deviceorientation behind requestPermission().\n observe(): Promise<void> {\n return this._ready;\n }\n\n dispose(): void {\n this.stop();\n }\n\n private _deviceOrientationEventCtor(): DeviceOrientationEventCtor | undefined {\n const g = globalThis as any;\n return typeof g.DeviceOrientationEvent !== \"undefined\" ? g.DeviceOrientationEvent : undefined;\n }\n\n private _setPermissionState(state: TiltPermissionState): void {\n if (this._permissionState === state) return;\n this._permissionState = state;\n this._target.dispatchEvent(new CustomEvent(\"wcs-tilt:permission-changed\", {\n detail: state,\n bubbles: true,\n }));\n }\n\n private _setError(error: any): void {\n if (this._error === error) return;\n this._error = error;\n // Keep the additive `errorInfo` taxonomy in sync with `error`: derive from the\n // wrapped rejection (or null on clear). Fires before the `error` event so an\n // observer binding both sees the classification first, mirroring the io-node\n // family.\n this._commitErrorInfo(error === null ? null : deriveTiltErrorInfo(error));\n this._target.dispatchEvent(new CustomEvent(\"wcs-tilt:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n // Called only from _setError (which already reference-guards on the error\n // object), 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-tilt:error-info-changed\", {\n detail: info,\n bubbles: true,\n }));\n }\n\n /**\n * Wraps iOS 13+ Safari's static, gesture-gated\n * `DeviceOrientationEvent.requestPermission()`. On platforms without this\n * gate (Android Chrome, desktop) there is nothing to ask, so this resolves\n * to `\"granted\"` immediately without querying anything — callers can write\n * one `requestPermission()` → `start()` flow that works everywhere\n * (docs/device-orientation-tag-design.md §3).\n *\n * never-throw (§3.6): a gesture-context rejection resolves to `\"denied\"`\n * and the raw error lands in `error` instead of propagating. Mirrors\n * `<wcs-idle>`'s `requestPermission()` (docs/idle-detection-tag-design.md\n * §4.1) — any settled (non-throwing) outcome supersedes a stale `error`\n * from an earlier attempt.\n */\n async requestPermission(): Promise<TiltPermissionState> {\n const Ctor = this._deviceOrientationEventCtor();\n if (typeof Ctor?.requestPermission !== \"function\") {\n this._setError(null);\n this._setPermissionState(\"granted\");\n return \"granted\";\n }\n try {\n const result = await Ctor.requestPermission();\n const state: TiltPermissionState = result === \"granted\" ? \"granted\" : \"denied\";\n this._setError(null);\n this._setPermissionState(state);\n return state;\n } catch (e) {\n // never-throw: a gesture-context rejection resolves to \"denied\".\n this._setError({ error: e });\n this._setPermissionState(\"denied\");\n return \"denied\";\n }\n }\n\n /** Subscribe to `deviceorientation`. Idempotent — a second start() while already subscribed is a no-op. */\n start(): void {\n if (this._subscribed) return;\n this._subscribed = true;\n globalThis.window?.addEventListener(\"deviceorientation\", this._onOrientation as EventListener);\n }\n\n /** Unsubscribe from `deviceorientation`. Safe to call when not started. */\n stop(): void {\n if (!this._subscribed) return;\n this._subscribed = false;\n globalThis.window?.removeEventListener(\"deviceorientation\", this._onOrientation as EventListener);\n }\n\n private _onOrientation = (event: DeviceOrientationEvent): void => {\n this._apply({\n alpha: event.alpha,\n beta: event.beta,\n gamma: event.gamma,\n absolute: event.absolute,\n });\n };\n\n // Same-value guard (§3.3 MUST).\n private _apply(next: WcsTiltSnapshot): void {\n const prev = this._snapshot;\n if (\n prev.alpha === next.alpha &&\n prev.beta === next.beta &&\n prev.gamma === next.gamma &&\n prev.absolute === next.absolute\n ) {\n return;\n }\n this._snapshot = next;\n this._target.dispatchEvent(new CustomEvent(\"wcs-tilt:change\", {\n detail: next,\n bubbles: true,\n }));\n }\n}\n","import { IWcBindable, TiltPermissionState } from \"../types.js\";\nimport { TiltCore } from \"../core/TiltCore.js\";\nimport { WcsIoErrorInfo } from \"../core/platformCapability.js\";\n\n/**\n * `<wcs-tilt>` — declarative Device Orientation API monitor.\n *\n * Named `tilt` (not `orientation`/`device-orientation`) to avoid colliding\n * with `<wcs-screen-orientation>` (docs/device-orientation-tag-design.md §9).\n *\n * Does NOT auto-start on connect, mirroring `<wcs-idle>`: on iOS, subscribing\n * before permission is granted silently receives no events. Callers drive\n * `requestPermission()` → `start()` explicitly.\n */\nexport class WcsTilt extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n\n static wcBindable: IWcBindable = {\n ...TiltCore.wcBindable,\n inputs: [],\n // Core の commands をそのまま継承(単一情報源)。\n commands: TiltCore.wcBindable.commands,\n };\n\n private _core: TiltCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new TiltCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-tilt: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 (async-io-node-guidelines.md §3.6): attachInternals is absent\n // 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 // --- Core delegated getters ---\n\n get alpha(): number | null {\n return this._core.alpha;\n }\n\n get beta(): number | null {\n return this._core.beta;\n }\n\n get gamma(): number | null {\n return this._core.gamma;\n }\n\n get absolute(): boolean | null {\n return this._core.absolute;\n }\n\n get permissionState(): TiltPermissionState {\n return this._core.permissionState;\n }\n\n get error(): any {\n return this._core.error;\n }\n\n get errorInfo(): WcsIoErrorInfo | null {\n return this._core.errorInfo;\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Commands (delegated to Core) ---\n\n requestPermission(): Promise<TiltPermissionState> {\n return this._core.requestPermission();\n }\n\n start(): void {\n this._core.start();\n }\n\n stop(): void {\n this._core.stop();\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n this.style.display = \"none\";\n this._connectedCallbackPromise = this._core.observe();\n }\n\n disconnectedCallback(): void {\n this._core.dispose();\n }\n}\n","import { WcsTilt } from \"./components/Tilt.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.tilt)) {\n customElements.define(config.tagNames.tilt, WcsTilt);\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapTilt(userConfig?: IWritableConfig): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents();\n}\n"],"names":[],"mappings":"AAQA,MAAM,OAAO,GAAoB;AAC/B,IAAA,QAAQ,EAAE;AACR,QAAA,IAAI,EAAE,UAAU;AACjB,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,CAA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;AACf,QAAA,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM;QAC3B,IAAI,CAAC,yBAAyB,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;IACvD;IAEA,oBAAoB,GAAA;AAClB,QAAA,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;IACtB;;;SCpIc,kBAAkB,GAAA;AAChC,IAAA,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;QAC7C,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACtD;AACF;;ACHM,SAAU,aAAa,CAAC,UAA4B,EAAA;IACxD,IAAI,UAAU,EAAE;QACd,SAAS,CAAC,UAAU,CAAC;IACvB;AACA,IAAA,kBAAkB,EAAE;AACtB;;;;"}
@@ -1,2 +1,2 @@
1
- const t={tagNames:{tilt:"wcs-tilt"}};function e(t){if(null===t||"object"!=typeof t)return t;Object.freeze(t);for(const s of Object.keys(t))e(t[s]);return t}function s(t){if(null===t||"object"!=typeof t)return t;const e={};for(const r of Object.keys(t))e[r]=s(t[r]);return e}let r=null;const n=t;function a(){return r||(r=e(s(t))),r}const i=Object.freeze({alpha:null,beta:null,gamma:null,absolute:null});class o extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"alpha",event:"wcs-tilt:change",getter:t=>t.detail.alpha},{name:"beta",event:"wcs-tilt:change",getter:t=>t.detail.beta},{name:"gamma",event:"wcs-tilt:change",getter:t=>t.detail.gamma},{name:"absolute",event:"wcs-tilt:change",getter:t=>t.detail.absolute},{name:"permissionState",event:"wcs-tilt:permission-changed"},{name:"error",event:"wcs-tilt:error"}],commands:[{name:"requestPermission",async:!0},{name:"start"},{name:"stop"}]};_target;_snapshot=i;_permissionState="unknown";_error=null;_subscribed=!1;_ready=Promise.resolve();constructor(t){super(),this._target=t??this}get ready(){return this._ready}get alpha(){return this._snapshot.alpha}get beta(){return this._snapshot.beta}get gamma(){return this._snapshot.gamma}get absolute(){return this._snapshot.absolute}get permissionState(){return this._permissionState}get error(){return this._error}observe(){return this._ready}dispose(){this.stop()}_deviceOrientationEventCtor(){const t=globalThis;return void 0!==t.DeviceOrientationEvent?t.DeviceOrientationEvent:void 0}_setPermissionState(t){this._permissionState!==t&&(this._permissionState=t,this._target.dispatchEvent(new CustomEvent("wcs-tilt:permission-changed",{detail:t,bubbles:!0})))}_setError(t){this._error!==t&&(this._error=t,this._target.dispatchEvent(new CustomEvent("wcs-tilt:error",{detail:t,bubbles:!0})))}async requestPermission(){const t=this._deviceOrientationEventCtor();if("function"!=typeof t?.requestPermission)return this._setError(null),this._setPermissionState("granted"),"granted";try{const e="granted"===await t.requestPermission()?"granted":"denied";return this._setError(null),this._setPermissionState(e),e}catch(t){return this._setError({error:t}),this._setPermissionState("denied"),"denied"}}start(){this._subscribed||(this._subscribed=!0,globalThis.window?.addEventListener("deviceorientation",this._onOrientation))}stop(){this._subscribed&&(this._subscribed=!1,globalThis.window?.removeEventListener("deviceorientation",this._onOrientation))}_onOrientation=t=>{this._apply({alpha:t.alpha,beta:t.beta,gamma:t.gamma,absolute:t.absolute})};_apply(t){const e=this._snapshot;e.alpha===t.alpha&&e.beta===t.beta&&e.gamma===t.gamma&&e.absolute===t.absolute||(this._snapshot=t,this._target.dispatchEvent(new CustomEvent("wcs-tilt:change",{detail:t,bubbles:!0})))}}class l extends HTMLElement{static hasConnectedCallbackPromise=!0;static wcBindable={...o.wcBindable,inputs:[],commands:o.wcBindable.commands};_core;_connectedCallbackPromise=Promise.resolve();_internals=null;constructor(){super(),this._core=new o(this),this._internals=this._initInternals(),this._wireStates({"wcs-tilt:error":t=>({error:null!=t})})}get debugStates(){return this._internals?[...this._internals.states]:[]}_initInternals(){try{if("function"!=typeof this.attachInternals)return null;const t=this.attachInternals();return t.states.add("wcs-probe"),t.states.delete("wcs-probe"),t}catch{return null}}_wireStates(t){if(null===this._internals)return;const e=this._internals.states;for(const[s,r]of Object.entries(t))this.addEventListener(s,t=>{const s=this.hasAttribute("debug-states");for(const[n,a]of Object.entries(r(t.detail))){try{a?e.add(n):e.delete(n)}catch{}s&&this.toggleAttribute(`data-wcs-state-${n}`,a)}})}get alpha(){return this._core.alpha}get beta(){return this._core.beta}get gamma(){return this._core.gamma}get absolute(){return this._core.absolute}get permissionState(){return this._core.permissionState}get error(){return this._core.error}get connectedCallbackPromise(){return this._connectedCallbackPromise}requestPermission(){return this._core.requestPermission()}start(){this._core.start()}stop(){this._core.stop()}connectedCallback(){this.style.display="none",this._connectedCallbackPromise=this._core.observe()}disconnectedCallback(){this._core.dispose()}}function c(e){var s;e&&((s=e).tagNames&&Object.assign(t.tagNames,s.tagNames),r=null),customElements.get(n.tagNames.tilt)||customElements.define(n.tagNames.tilt,l)}export{o as TiltCore,l as WcsTilt,c as bootstrapTilt,a as getConfig};
1
+ const t={tagNames:{tilt:"wcs-tilt"}};function e(t){if(null===t||"object"!=typeof t)return t;Object.freeze(t);for(const r of Object.keys(t))e(t[r]);return t}function r(t){if(null===t||"object"!=typeof t)return t;const e={};for(const s of Object.keys(t))e[s]=r(t[s]);return e}let s=null;const n=t;function a(){return s||(s=e(r(t))),s}const i={NotAllowed:"not-allowed",TiltError:"tilt-error"};const o=Object.freeze({alpha:null,beta:null,gamma:null,absolute:null});class l extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"alpha",event:"wcs-tilt:change",getter:t=>t.detail.alpha},{name:"beta",event:"wcs-tilt:change",getter:t=>t.detail.beta},{name:"gamma",event:"wcs-tilt:change",getter:t=>t.detail.gamma},{name:"absolute",event:"wcs-tilt:change",getter:t=>t.detail.absolute},{name:"permissionState",event:"wcs-tilt:permission-changed"},{name:"error",event:"wcs-tilt:error"},{name:"errorInfo",event:"wcs-tilt:error-info-changed"}],commands:[{name:"requestPermission",async:!0},{name:"start"},{name:"stop"}]};_target;_snapshot=o;_permissionState="unknown";_error=null;_errorInfo=null;_subscribed=!1;_ready=Promise.resolve();constructor(t){super(),this._target=t??this}get ready(){return this._ready}get alpha(){return this._snapshot.alpha}get beta(){return this._snapshot.beta}get gamma(){return this._snapshot.gamma}get absolute(){return this._snapshot.absolute}get permissionState(){return this._permissionState}get error(){return this._error}get errorInfo(){return this._errorInfo}observe(){return this._ready}dispose(){this.stop()}_deviceOrientationEventCtor(){const t=globalThis;return void 0!==t.DeviceOrientationEvent?t.DeviceOrientationEvent:void 0}_setPermissionState(t){this._permissionState!==t&&(this._permissionState=t,this._target.dispatchEvent(new CustomEvent("wcs-tilt:permission-changed",{detail:t,bubbles:!0})))}_setError(t){this._error!==t&&(this._error=t,this._commitErrorInfo(null===t?null:function(t){const e=t.error?.name,r=t.error?.message??String(t.error);return"NotAllowedError"===e?{code:i.NotAllowed,phase:"start",recoverable:!1,message:r}:{code:i.TiltError,phase:"execute",recoverable:!1,message:r}}(t)),this._target.dispatchEvent(new CustomEvent("wcs-tilt:error",{detail:t,bubbles:!0})))}_commitErrorInfo(t){this._errorInfo=t,this._target.dispatchEvent(new CustomEvent("wcs-tilt:error-info-changed",{detail:t,bubbles:!0}))}async requestPermission(){const t=this._deviceOrientationEventCtor();if("function"!=typeof t?.requestPermission)return this._setError(null),this._setPermissionState("granted"),"granted";try{const e="granted"===await t.requestPermission()?"granted":"denied";return this._setError(null),this._setPermissionState(e),e}catch(t){return this._setError({error:t}),this._setPermissionState("denied"),"denied"}}start(){this._subscribed||(this._subscribed=!0,globalThis.window?.addEventListener("deviceorientation",this._onOrientation))}stop(){this._subscribed&&(this._subscribed=!1,globalThis.window?.removeEventListener("deviceorientation",this._onOrientation))}_onOrientation=t=>{this._apply({alpha:t.alpha,beta:t.beta,gamma:t.gamma,absolute:t.absolute})};_apply(t){const e=this._snapshot;e.alpha===t.alpha&&e.beta===t.beta&&e.gamma===t.gamma&&e.absolute===t.absolute||(this._snapshot=t,this._target.dispatchEvent(new CustomEvent("wcs-tilt:change",{detail:t,bubbles:!0})))}}class c extends HTMLElement{static hasConnectedCallbackPromise=!0;static wcBindable={...l.wcBindable,inputs:[],commands:l.wcBindable.commands};_core;_connectedCallbackPromise=Promise.resolve();_internals=null;constructor(){super(),this._core=new l(this),this._internals=this._initInternals(),this._wireStates({"wcs-tilt:error":t=>({error:null!=t})})}get debugStates(){return this._internals?[...this._internals.states]:[]}_initInternals(){try{if("function"!=typeof this.attachInternals)return null;const t=this.attachInternals();return t.states.add("wcs-probe"),t.states.delete("wcs-probe"),t}catch{return null}}_wireStates(t){if(null===this._internals)return;const e=this._internals.states;for(const[r,s]of Object.entries(t))this.addEventListener(r,t=>{const r=this.hasAttribute("debug-states");for(const[n,a]of Object.entries(s(t.detail))){try{a?e.add(n):e.delete(n)}catch{}r&&this.toggleAttribute(`data-wcs-state-${n}`,a)}})}get alpha(){return this._core.alpha}get beta(){return this._core.beta}get gamma(){return this._core.gamma}get absolute(){return this._core.absolute}get permissionState(){return this._core.permissionState}get error(){return this._core.error}get errorInfo(){return this._core.errorInfo}get connectedCallbackPromise(){return this._connectedCallbackPromise}requestPermission(){return this._core.requestPermission()}start(){this._core.start()}stop(){this._core.stop()}connectedCallback(){this.style.display="none",this._connectedCallbackPromise=this._core.observe()}disconnectedCallback(){this._core.dispose()}}function h(e){var r;e&&((r=e).tagNames&&Object.assign(t.tagNames,r.tagNames),s=null),customElements.get(n.tagNames.tilt)||customElements.define(n.tagNames.tilt,c)}export{l as TiltCore,i as WCS_TILT_ERROR_CODE,c as WcsTilt,h as bootstrapTilt,a as getConfig};
2
2
  //# sourceMappingURL=index.esm.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.min.js","sources":["../src/config.ts","../src/core/TiltCore.ts","../src/components/Tilt.ts","../src/bootstrapTilt.ts","../src/registerComponents.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n tilt: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n tilt: \"wcs-tilt\",\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\nexport function setConfig(partialConfig: IWritableConfig): void {\n if (partialConfig.tagNames) {\n Object.assign(_config.tagNames, partialConfig.tagNames);\n }\n frozenConfig = null;\n}\n","import { IWcBindable, TiltPermissionState } from \"../types.js\";\n\ninterface DeviceOrientationEventCtor {\n requestPermission?: () => Promise<\"granted\" | \"denied\">;\n}\n\ninterface WcsTiltSnapshot {\n alpha: number | null;\n beta: number | null;\n gamma: number | null;\n absolute: boolean | null;\n}\n\nconst UNSUPPORTED_SNAPSHOT: WcsTiltSnapshot = Object.freeze({\n alpha: null,\n beta: null,\n gamma: null,\n absolute: null,\n});\n\n/**\n * Headless Device Orientation primitive. A thin, framework-agnostic wrapper\n * around `window`'s `deviceorientation` event exposed through the wc-bindable\n * protocol.\n *\n * The batch2 sibling of `@wcstack/idle` (docs/device-orientation-tag-design.md).\n * Unlike Idle Detection, there is no matching Permissions API entry for this\n * feature (`navigator.permissions.query` has no \"device-orientation\" name), so\n * `permissionState` must be tracked **locally** rather than composed with\n * `<wcs-permission>` — the defining asymmetry within batch2.\n *\n * No `_gen` generation guard: subscribing/unsubscribing to `deviceorientation`\n * (start/stop) is fully synchronous, so that path never needs one. This node\n * does have an async probe — `requestPermission()` awaits the static\n * `DeviceOrientationEvent.requestPermission()` — but its post-await write is\n * a benign `permissionState`/`error` value set + dispatch with no\n * subscription/resource management to race, so `_gen` is unneeded there too\n * (docs/device-orientation-tag-design.md §4, corrected after an earlier\n * revision mistakenly reused `@wcstack/network`'s \"no async probe at all\"\n * rationale).\n */\nexport class TiltCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"alpha\", event: \"wcs-tilt:change\", getter: (e: Event) => (e as CustomEvent).detail.alpha },\n { name: \"beta\", event: \"wcs-tilt:change\", getter: (e: Event) => (e as CustomEvent).detail.beta },\n { name: \"gamma\", event: \"wcs-tilt:change\", getter: (e: Event) => (e as CustomEvent).detail.gamma },\n { name: \"absolute\", event: \"wcs-tilt:change\", getter: (e: Event) => (e as CustomEvent).detail.absolute },\n { name: \"permissionState\", event: \"wcs-tilt:permission-changed\" },\n // never-throw (§3.6): requestPermission() failures land here instead of\n // rejecting/throwing. Mirrors idle (same batch2) and the accelerometer\n // family (batch5) — see docs/io-node-batch-implementation-plan.md.\n { name: \"error\", event: \"wcs-tilt:error\" },\n ],\n commands: [\n { name: \"requestPermission\", async: true },\n { name: \"start\" },\n { name: \"stop\" },\n ],\n };\n\n private _target: EventTarget;\n private _snapshot: WcsTiltSnapshot = UNSUPPORTED_SNAPSHOT;\n private _permissionState: TiltPermissionState = \"unknown\";\n private _error: any = null;\n private _subscribed = false;\n\n // SSR (§3.8): never auto-starts on connect, so there is no probe to await —\n // readiness is always immediate.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n get ready(): Promise<void> {\n return this._ready;\n }\n\n get alpha(): number | null {\n return this._snapshot.alpha;\n }\n\n get beta(): number | null {\n return this._snapshot.beta;\n }\n\n get gamma(): number | null {\n return this._snapshot.gamma;\n }\n\n get absolute(): boolean | null {\n return this._snapshot.absolute;\n }\n\n get permissionState(): TiltPermissionState {\n return this._permissionState;\n }\n\n get error(): any {\n return this._error;\n }\n\n // Lifecycle (§3.5). observe() is a synchronous no-op: like `<wcs-idle>`,\n // this Core deliberately does NOT auto-start on connect (§6) on platforms\n // that gate deviceorientation behind requestPermission().\n observe(): Promise<void> {\n return this._ready;\n }\n\n dispose(): void {\n this.stop();\n }\n\n private _deviceOrientationEventCtor(): DeviceOrientationEventCtor | undefined {\n const g = globalThis as any;\n return typeof g.DeviceOrientationEvent !== \"undefined\" ? g.DeviceOrientationEvent : undefined;\n }\n\n private _setPermissionState(state: TiltPermissionState): void {\n if (this._permissionState === state) return;\n this._permissionState = state;\n this._target.dispatchEvent(new CustomEvent(\"wcs-tilt:permission-changed\", {\n detail: state,\n bubbles: true,\n }));\n }\n\n private _setError(error: any): void {\n if (this._error === error) return;\n this._error = error;\n this._target.dispatchEvent(new CustomEvent(\"wcs-tilt:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n /**\n * Wraps iOS 13+ Safari's static, gesture-gated\n * `DeviceOrientationEvent.requestPermission()`. On platforms without this\n * gate (Android Chrome, desktop) there is nothing to ask, so this resolves\n * to `\"granted\"` immediately without querying anything — callers can write\n * one `requestPermission()` → `start()` flow that works everywhere\n * (docs/device-orientation-tag-design.md §3).\n *\n * never-throw (§3.6): a gesture-context rejection resolves to `\"denied\"`\n * and the raw error lands in `error` instead of propagating. Mirrors\n * `<wcs-idle>`'s `requestPermission()` (docs/idle-detection-tag-design.md\n * §4.1) — any settled (non-throwing) outcome supersedes a stale `error`\n * from an earlier attempt.\n */\n async requestPermission(): Promise<TiltPermissionState> {\n const Ctor = this._deviceOrientationEventCtor();\n if (typeof Ctor?.requestPermission !== \"function\") {\n this._setError(null);\n this._setPermissionState(\"granted\");\n return \"granted\";\n }\n try {\n const result = await Ctor.requestPermission();\n const state: TiltPermissionState = result === \"granted\" ? \"granted\" : \"denied\";\n this._setError(null);\n this._setPermissionState(state);\n return state;\n } catch (e) {\n // never-throw: a gesture-context rejection resolves to \"denied\".\n this._setError({ error: e });\n this._setPermissionState(\"denied\");\n return \"denied\";\n }\n }\n\n /** Subscribe to `deviceorientation`. Idempotent — a second start() while already subscribed is a no-op. */\n start(): void {\n if (this._subscribed) return;\n this._subscribed = true;\n globalThis.window?.addEventListener(\"deviceorientation\", this._onOrientation as EventListener);\n }\n\n /** Unsubscribe from `deviceorientation`. Safe to call when not started. */\n stop(): void {\n if (!this._subscribed) return;\n this._subscribed = false;\n globalThis.window?.removeEventListener(\"deviceorientation\", this._onOrientation as EventListener);\n }\n\n private _onOrientation = (event: DeviceOrientationEvent): void => {\n this._apply({\n alpha: event.alpha,\n beta: event.beta,\n gamma: event.gamma,\n absolute: event.absolute,\n });\n };\n\n // Same-value guard (§3.3 MUST).\n private _apply(next: WcsTiltSnapshot): void {\n const prev = this._snapshot;\n if (\n prev.alpha === next.alpha &&\n prev.beta === next.beta &&\n prev.gamma === next.gamma &&\n prev.absolute === next.absolute\n ) {\n return;\n }\n this._snapshot = next;\n this._target.dispatchEvent(new CustomEvent(\"wcs-tilt:change\", {\n detail: next,\n bubbles: true,\n }));\n }\n}\n","import { IWcBindable, TiltPermissionState } from \"../types.js\";\nimport { TiltCore } from \"../core/TiltCore.js\";\n\n/**\n * `<wcs-tilt>` — declarative Device Orientation API monitor.\n *\n * Named `tilt` (not `orientation`/`device-orientation`) to avoid colliding\n * with `<wcs-screen-orientation>` (docs/device-orientation-tag-design.md §9).\n *\n * Does NOT auto-start on connect, mirroring `<wcs-idle>`: on iOS, subscribing\n * before permission is granted silently receives no events. Callers drive\n * `requestPermission()` → `start()` explicitly.\n */\nexport class WcsTilt extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n\n static wcBindable: IWcBindable = {\n ...TiltCore.wcBindable,\n inputs: [],\n // Core の commands をそのまま継承(単一情報源)。\n commands: TiltCore.wcBindable.commands,\n };\n\n private _core: TiltCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new TiltCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-tilt: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 (async-io-node-guidelines.md §3.6): attachInternals is absent\n // 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 // --- Core delegated getters ---\n\n get alpha(): number | null {\n return this._core.alpha;\n }\n\n get beta(): number | null {\n return this._core.beta;\n }\n\n get gamma(): number | null {\n return this._core.gamma;\n }\n\n get absolute(): boolean | null {\n return this._core.absolute;\n }\n\n get permissionState(): TiltPermissionState {\n return this._core.permissionState;\n }\n\n get error(): any {\n return this._core.error;\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Commands (delegated to Core) ---\n\n requestPermission(): Promise<TiltPermissionState> {\n return this._core.requestPermission();\n }\n\n start(): void {\n this._core.start();\n }\n\n stop(): void {\n this._core.stop();\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n this.style.display = \"none\";\n this._connectedCallbackPromise = this._core.observe();\n }\n\n disconnectedCallback(): void {\n this._core.dispose();\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapTilt(userConfig?: IWritableConfig): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents();\n}\n","import { WcsTilt } from \"./components/Tilt.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.tilt)) {\n customElements.define(config.tagNames.tilt, WcsTilt);\n }\n}\n"],"names":["_config","tagNames","tilt","deepFreeze","obj","Object","freeze","key","keys","deepClone","clone","frozenConfig","config","getConfig","UNSUPPORTED_SNAPSHOT","alpha","beta","gamma","absolute","TiltCore","EventTarget","static","protocol","version","properties","name","event","getter","e","detail","commands","async","_target","_snapshot","_permissionState","_error","_subscribed","_ready","Promise","resolve","constructor","target","super","this","ready","permissionState","error","observe","dispose","stop","_deviceOrientationEventCtor","g","globalThis","DeviceOrientationEvent","undefined","_setPermissionState","state","dispatchEvent","CustomEvent","bubbles","_setError","requestPermission","Ctor","start","window","addEventListener","_onOrientation","removeEventListener","_apply","next","prev","WcsTilt","HTMLElement","wcBindable","inputs","_core","_connectedCallbackPromise","_internals","_initInternals","_wireStates","d","debugStates","states","attachInternals","internals","add","delete","map","toStates","entries","debug","hasAttribute","on","toggleAttribute","connectedCallbackPromise","connectedCallback","style","display","disconnectedCallback","bootstrapTilt","userConfig","partialConfig","assign","customElements","get","define"],"mappings":"AAQA,MAAMA,EAA2B,CAC/BC,SAAU,CACRC,KAAM,aAIV,SAASC,EAAcC,GACrB,GAAY,OAARA,GAA+B,iBAARA,EAAkB,OAAOA,EACpDC,OAAOC,OAAOF,GACd,IAAK,MAAMG,KAAOF,OAAOG,KAAKJ,GAC5BD,EAAYC,EAAgCG,IAE9C,OAAOH,CACT,CAEA,SAASK,EAAaL,GAC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AU,CAC5E,IACM+D,EAAMV,EAAOG,IAAI5D,GAAgByD,EAAOI,OAAO7D,EACrD,CAAE,MAA0B,CACxBiE,GAAO/C,KAAKkD,gBAAgB,kBAAkBpE,IAAQmE,EAC5D,GAGN,CAIA,SAAI7E,GACF,OAAO4B,KAAKgC,MAAM5D,KACpB,CAEA,QAAIC,GACF,OAAO2B,KAAKgC,MAAM3D,IACpB,CAEA,SAAIC,GACF,OAAO0B,KAAKgC,MAAM1D,KACpB,CAEA,YAAIC,GACF,OAAOyB,KAAKgC,MAAMzD,QACpB,CAEA,mBAAI2B,GACF,OAAOF,KAAKgC,MAAM9B,eACpB,CAEA,SAAIC,GACF,OAAOH,KAAKgC,MAAM7B,KACpB,CAEA,4BAAIgD,GACF,OAAOnD,KAAKiC,yBACd,CAIA,iBAAAf,GACE,OAAOlB,KAAKgC,MAAMd,mBACpB,CAEA,KAAAE,GACEpB,KAAKgC,MAAMZ,OACb,CAEA,IAAAd,GACEN,KAAKgC,MAAM1B,MACb,CAIA,iBAAA8C,GACEpD,KAAKqD,MAAMC,QAAU,OACrBtD,KAAKiC,0BAA4BjC,KAAKgC,MAAM5B,SAC9C,CAEA,oBAAAmD,GACEvD,KAAKgC,MAAM3B,SACb,EC9HI,SAAUmD,EAAcC,GHuCxB,IAAoBC,EGtCpBD,KHsCoBC,EGrCZD,GHsCMnG,UAChBI,OAAOiG,OAAOtG,EAAQC,SAAUoG,EAAcpG,UAEhDU,EAAe,MI3CV4F,eAAeC,IAAI5F,EAAOX,SAASC,OACtCqG,eAAeE,OAAO7F,EAAOX,SAASC,KAAMqE,EDIhD"}
1
+ {"version":3,"file":"index.esm.min.js","sources":["../src/config.ts","../src/core/tiltCapabilities.ts","../src/core/TiltCore.ts","../src/components/Tilt.ts","../src/bootstrapTilt.ts","../src/registerComponents.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n tilt: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n tilt: \"wcs-tilt\",\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\nexport function setConfig(partialConfig: IWritableConfig): void {\n if (partialConfig.tagNames) {\n Object.assign(_config.tagNames, partialConfig.tagNames);\n }\n frozenConfig = null;\n}\n","/**\n * tiltCapabilities.ts\n *\n * Tilt(Device Orientation)node 固有の error code(taxonomy)と derivation。汎用の\n * error info 型は `./platformCapability.js`(/io-core/ から copy-distribution される\n * 生成ファイル)から import する。tilt は監視系(deviceorientation の subscribe/\n * unsubscribe)で競合する operation を持たないため lane は持たず、error taxonomy\n * (errorInfo)のみを採用する。\n *\n * sensor 4 兄弟(accelerometer / gyroscope / magnetometer / ambient-light-sensor)と\n * 違い、tilt の error 面は **異なる shape** を持つ:\n * - sensor 族の error detail は `{ error: <Error.name>, message }`(name/message は文字列)。\n * - tilt の error detail は `{ error: <生の rejection reason> }`(TiltCore._setError が\n * `requestPermission()` の catch で `{ error: e }` を渡す。`e` は生の Error/reason)。\n *\n * したがって derive は「wrap された生の値」から name/message を取り出す。また tilt は\n * \"unsupported\"(capability-missing)経路を **持たない**: `DeviceOrientationEvent` や\n * その `requestPermission` が無い環境では error にせず `\"granted\"` に倒して error を\n * クリアする(docs/device-orientation-tag-design.md §3)。よって capability-missing の\n * code / branch は生成しない(到達不能・dead code を避ける)。error として _setError に\n * 届くのは iOS の `requestPermission()` reject だけで、その name は実権限拒否なら\n * `NotAllowedError`、gesture 文脈外等なら汎用 `Error` になる。\n */\n\nimport type { WcsIoErrorInfo } from \"./platformCapability.js\";\n\n/** 安定した tilt error code(taxonomy)。値は公開キーとして固定。 */\nexport const WCS_TILT_ERROR_CODE = {\n /** `NotAllowedError` — iOS の Device Orientation 権限拒否。 */\n NotAllowed: \"not-allowed\",\n /** その他の `requestPermission()` reject(gesture 文脈外 / 想定外の失敗)。 */\n TiltError: \"tilt-error\",\n} as const;\n\n/**\n * tilt の失敗(`_setError` に渡る `{ error: <生の reason> }`)を serializable な error\n * taxonomy に写す。name は wrap された reason の `Error.name`、message はその `.message`\n * (無ければ `String(...)`)。\n *\n * - `NotAllowedError` は iOS の権限拒否 → phase=\"start\" / not-allowed。retry で回復しない。\n * - それ以外(gesture 文脈外の汎用 `Error`、非 Error reason 等)→ phase=\"execute\" /\n * tilt-error。\n *\n * capability-missing 経路は無い(上のヘッダ参照): 非対応環境は error ではなく\n * `\"granted\"` へ倒れるため、ここには到達しない。\n */\nexport function deriveTiltErrorInfo(detail: { error?: any }): WcsIoErrorInfo {\n const name: string | undefined = detail.error?.name;\n const message: string = detail.error?.message ?? String(detail.error);\n if (name === \"NotAllowedError\") {\n return { code: WCS_TILT_ERROR_CODE.NotAllowed, phase: \"start\", recoverable: false, message };\n }\n return { code: WCS_TILT_ERROR_CODE.TiltError, phase: \"execute\", recoverable: false, message };\n}\n","import { IWcBindable, TiltPermissionState } from \"../types.js\";\nimport { WcsIoErrorInfo } from \"./platformCapability.js\";\nimport { deriveTiltErrorInfo } from \"./tiltCapabilities.js\";\n\ninterface DeviceOrientationEventCtor {\n requestPermission?: () => Promise<\"granted\" | \"denied\">;\n}\n\ninterface WcsTiltSnapshot {\n alpha: number | null;\n beta: number | null;\n gamma: number | null;\n absolute: boolean | null;\n}\n\nconst UNSUPPORTED_SNAPSHOT: WcsTiltSnapshot = Object.freeze({\n alpha: null,\n beta: null,\n gamma: null,\n absolute: null,\n});\n\n/**\n * Headless Device Orientation primitive. A thin, framework-agnostic wrapper\n * around `window`'s `deviceorientation` event exposed through the wc-bindable\n * protocol.\n *\n * The batch2 sibling of `@wcstack/idle` (docs/device-orientation-tag-design.md).\n * Unlike Idle Detection, there is no matching Permissions API entry for this\n * feature (`navigator.permissions.query` has no \"device-orientation\" name), so\n * `permissionState` must be tracked **locally** rather than composed with\n * `<wcs-permission>` — the defining asymmetry within batch2.\n *\n * No `_gen` generation guard: subscribing/unsubscribing to `deviceorientation`\n * (start/stop) is fully synchronous, so that path never needs one. This node\n * does have an async probe — `requestPermission()` awaits the static\n * `DeviceOrientationEvent.requestPermission()` — but its post-await write is\n * a benign `permissionState`/`error` value set + dispatch with no\n * subscription/resource management to race, so `_gen` is unneeded there too\n * (docs/device-orientation-tag-design.md §4, corrected after an earlier\n * revision mistakenly reused `@wcstack/network`'s \"no async probe at all\"\n * rationale).\n */\nexport class TiltCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"alpha\", event: \"wcs-tilt:change\", getter: (e: Event) => (e as CustomEvent).detail.alpha },\n { name: \"beta\", event: \"wcs-tilt:change\", getter: (e: Event) => (e as CustomEvent).detail.beta },\n { name: \"gamma\", event: \"wcs-tilt:change\", getter: (e: Event) => (e as CustomEvent).detail.gamma },\n { name: \"absolute\", event: \"wcs-tilt:change\", getter: (e: Event) => (e as CustomEvent).detail.absolute },\n { name: \"permissionState\", event: \"wcs-tilt:permission-changed\" },\n // never-throw (§3.6): requestPermission() failures land here instead of\n // rejecting/throwing. Mirrors idle (same batch2) and the accelerometer\n // family (batch5) — see docs/io-node-batch-implementation-plan.md.\n { name: \"error\", event: \"wcs-tilt:error\" },\n // Serializable failure taxonomy (stable code / phase / recoverable), or null.\n // Additive bindable output derived from `error.error` (the wrapped rejection's\n // Error.name); the existing `error` property/event are unchanged. Fires\n // wcs-tilt:error-info-changed. No lane — this is a monitor node.\n { name: \"errorInfo\", event: \"wcs-tilt:error-info-changed\" },\n ],\n commands: [\n { name: \"requestPermission\", async: true },\n { name: \"start\" },\n { name: \"stop\" },\n ],\n };\n\n private _target: EventTarget;\n private _snapshot: WcsTiltSnapshot = UNSUPPORTED_SNAPSHOT;\n private _permissionState: TiltPermissionState = \"unknown\";\n private _error: any = null;\n private _errorInfo: WcsIoErrorInfo | null = null;\n private _subscribed = false;\n\n // SSR (§3.8): never auto-starts on connect, so there is no probe to await —\n // readiness is always immediate.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n get ready(): Promise<void> {\n return this._ready;\n }\n\n get alpha(): number | null {\n return this._snapshot.alpha;\n }\n\n get beta(): number | null {\n return this._snapshot.beta;\n }\n\n get gamma(): number | null {\n return this._snapshot.gamma;\n }\n\n get absolute(): boolean | null {\n return this._snapshot.absolute;\n }\n\n get permissionState(): TiltPermissionState {\n return this._permissionState;\n }\n\n get error(): any {\n return this._error;\n }\n\n /**\n * The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /\n * `recoverable`), or null. Additive wc-bindable property (event\n * `wcs-tilt:error-info-changed`), derived from `error`; the existing `error`\n * property/event are unchanged.\n */\n get errorInfo(): WcsIoErrorInfo | null {\n return this._errorInfo;\n }\n\n // Lifecycle (§3.5). observe() is a synchronous no-op: like `<wcs-idle>`,\n // this Core deliberately does NOT auto-start on connect (§6) on platforms\n // that gate deviceorientation behind requestPermission().\n observe(): Promise<void> {\n return this._ready;\n }\n\n dispose(): void {\n this.stop();\n }\n\n private _deviceOrientationEventCtor(): DeviceOrientationEventCtor | undefined {\n const g = globalThis as any;\n return typeof g.DeviceOrientationEvent !== \"undefined\" ? g.DeviceOrientationEvent : undefined;\n }\n\n private _setPermissionState(state: TiltPermissionState): void {\n if (this._permissionState === state) return;\n this._permissionState = state;\n this._target.dispatchEvent(new CustomEvent(\"wcs-tilt:permission-changed\", {\n detail: state,\n bubbles: true,\n }));\n }\n\n private _setError(error: any): void {\n if (this._error === error) return;\n this._error = error;\n // Keep the additive `errorInfo` taxonomy in sync with `error`: derive from the\n // wrapped rejection (or null on clear). Fires before the `error` event so an\n // observer binding both sees the classification first, mirroring the io-node\n // family.\n this._commitErrorInfo(error === null ? null : deriveTiltErrorInfo(error));\n this._target.dispatchEvent(new CustomEvent(\"wcs-tilt:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n // Called only from _setError (which already reference-guards on the error\n // object), 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-tilt:error-info-changed\", {\n detail: info,\n bubbles: true,\n }));\n }\n\n /**\n * Wraps iOS 13+ Safari's static, gesture-gated\n * `DeviceOrientationEvent.requestPermission()`. On platforms without this\n * gate (Android Chrome, desktop) there is nothing to ask, so this resolves\n * to `\"granted\"` immediately without querying anything — callers can write\n * one `requestPermission()` → `start()` flow that works everywhere\n * (docs/device-orientation-tag-design.md §3).\n *\n * never-throw (§3.6): a gesture-context rejection resolves to `\"denied\"`\n * and the raw error lands in `error` instead of propagating. Mirrors\n * `<wcs-idle>`'s `requestPermission()` (docs/idle-detection-tag-design.md\n * §4.1) — any settled (non-throwing) outcome supersedes a stale `error`\n * from an earlier attempt.\n */\n async requestPermission(): Promise<TiltPermissionState> {\n const Ctor = this._deviceOrientationEventCtor();\n if (typeof Ctor?.requestPermission !== \"function\") {\n this._setError(null);\n this._setPermissionState(\"granted\");\n return \"granted\";\n }\n try {\n const result = await Ctor.requestPermission();\n const state: TiltPermissionState = result === \"granted\" ? \"granted\" : \"denied\";\n this._setError(null);\n this._setPermissionState(state);\n return state;\n } catch (e) {\n // never-throw: a gesture-context rejection resolves to \"denied\".\n this._setError({ error: e });\n this._setPermissionState(\"denied\");\n return \"denied\";\n }\n }\n\n /** Subscribe to `deviceorientation`. Idempotent — a second start() while already subscribed is a no-op. */\n start(): void {\n if (this._subscribed) return;\n this._subscribed = true;\n globalThis.window?.addEventListener(\"deviceorientation\", this._onOrientation as EventListener);\n }\n\n /** Unsubscribe from `deviceorientation`. Safe to call when not started. */\n stop(): void {\n if (!this._subscribed) return;\n this._subscribed = false;\n globalThis.window?.removeEventListener(\"deviceorientation\", this._onOrientation as EventListener);\n }\n\n private _onOrientation = (event: DeviceOrientationEvent): void => {\n this._apply({\n alpha: event.alpha,\n beta: event.beta,\n gamma: event.gamma,\n absolute: event.absolute,\n });\n };\n\n // Same-value guard (§3.3 MUST).\n private _apply(next: WcsTiltSnapshot): void {\n const prev = this._snapshot;\n if (\n prev.alpha === next.alpha &&\n prev.beta === next.beta &&\n prev.gamma === next.gamma &&\n prev.absolute === next.absolute\n ) {\n return;\n }\n this._snapshot = next;\n this._target.dispatchEvent(new CustomEvent(\"wcs-tilt:change\", {\n detail: next,\n bubbles: true,\n }));\n }\n}\n","import { IWcBindable, TiltPermissionState } from \"../types.js\";\nimport { TiltCore } from \"../core/TiltCore.js\";\nimport { WcsIoErrorInfo } from \"../core/platformCapability.js\";\n\n/**\n * `<wcs-tilt>` — declarative Device Orientation API monitor.\n *\n * Named `tilt` (not `orientation`/`device-orientation`) to avoid colliding\n * with `<wcs-screen-orientation>` (docs/device-orientation-tag-design.md §9).\n *\n * Does NOT auto-start on connect, mirroring `<wcs-idle>`: on iOS, subscribing\n * before permission is granted silently receives no events. Callers drive\n * `requestPermission()` → `start()` explicitly.\n */\nexport class WcsTilt extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n\n static wcBindable: IWcBindable = {\n ...TiltCore.wcBindable,\n inputs: [],\n // Core の commands をそのまま継承(単一情報源)。\n commands: TiltCore.wcBindable.commands,\n };\n\n private _core: TiltCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new TiltCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-tilt: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 (async-io-node-guidelines.md §3.6): attachInternals is absent\n // 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 // --- Core delegated getters ---\n\n get alpha(): number | null {\n return this._core.alpha;\n }\n\n get beta(): number | null {\n return this._core.beta;\n }\n\n get gamma(): number | null {\n return this._core.gamma;\n }\n\n get absolute(): boolean | null {\n return this._core.absolute;\n }\n\n get permissionState(): TiltPermissionState {\n return this._core.permissionState;\n }\n\n get error(): any {\n return this._core.error;\n }\n\n get errorInfo(): WcsIoErrorInfo | null {\n return this._core.errorInfo;\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Commands (delegated to Core) ---\n\n requestPermission(): Promise<TiltPermissionState> {\n return this._core.requestPermission();\n }\n\n start(): void {\n this._core.start();\n }\n\n stop(): void {\n this._core.stop();\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n this.style.display = \"none\";\n this._connectedCallbackPromise = this._core.observe();\n }\n\n disconnectedCallback(): void {\n this._core.dispose();\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapTilt(userConfig?: IWritableConfig): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents();\n}\n","import { WcsTilt } from \"./components/Tilt.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.tilt)) {\n customElements.define(config.tagNames.tilt, WcsTilt);\n }\n}\n"],"names":["_config","tagNames","tilt","deepFreeze","obj","Object","freeze","key","keys","deepClone","clone","frozenConfig","config","getConfig","WCS_TILT_ERROR_CODE","NotAllowed","TiltError","UNSUPPORTED_SNAPSHOT","alpha","beta","gamma","absolute","TiltCore","EventTarget","static","protocol","version","properties","name","event","getter","e","detail","commands","async","_target","_snapshot","_permissionState","_error","_errorInfo","_subscribed","_ready","Promise","resolve","constructor","target","super","this","ready","permissionState","error","errorInfo","observe","dispose","stop","_deviceOrientationEventCtor","g","globalThis","DeviceOrientationEvent","undefined","_setPermissionState","state","dispatchEvent","CustomEvent","bubbles","_setError","_commitErrorInfo","message","String","code","phase","recoverable","deriveTiltErrorInfo","info","requestPermission","Ctor","start","window","addEventListener","_onOrientation","removeEventListener","_apply","next","prev","WcsTilt","HTMLElement","wcBindable","inputs","_core","_connectedCallbackPromise","_internals","_initInternals","_wireStates","d","debugStates","states","attachInternals","internals","add","delete","map","toStates","entries","debug","hasAttribute","on","toggleAttribute","connectedCallbackPromise","connectedCallback","style","display","disconnectedCallback","bootstrapTilt","userConfig","partialConfig","assign","customElements","get","define"],"mappings":"AAQA,MAAMA,EAA2B,CAC/BC,SAAU,CACRC,KAAM,aAIV,SAASC,EAAcC,GACrB,GAAY,OAARA,GAA+B,iBAARA,EA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C,GACF,OAAOJ,KAAKyC,MAAMrC,SACpB,CAEA,4BAAIwD,GACF,OAAO5D,KAAK0C,yBACd,CAIA,iBAAAf,GACE,OAAO3B,KAAKyC,MAAMd,mBACpB,CAEA,KAAAE,GACE7B,KAAKyC,MAAMZ,OACb,CAEA,IAAAtB,GACEP,KAAKyC,MAAMlC,MACb,CAIA,iBAAAsD,GACE7D,KAAK8D,MAAMC,QAAU,OACrB/D,KAAK0C,0BAA4B1C,KAAKyC,MAAMpC,SAC9C,CAEA,oBAAA2D,GACEhE,KAAKyC,MAAMnC,SACb,ECnII,SAAU2D,EAAcC,GJuCxB,IAAoBC,EItCpBD,KJsCoBC,EIrCZD,GJsCMhH,UAChBI,OAAO8G,OAAOnH,EAAQC,SAAUiH,EAAcjH,UAEhDU,EAAe,MK3CVyG,eAAeC,IAAIzG,EAAOX,SAASC,OACtCkH,eAAeE,OAAO1G,EAAOX,SAASC,KAAMkF,EDIhD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wcstack/tilt",
3
- "version": "1.20.0",
3
+ "version": "1.21.0",
4
4
  "description": "Declarative Device Orientation component for Web Components. Framework-agnostic deviceorientation wrapper via wc-bindable-protocol.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.esm.js",