@wcstack/wakelock 1.19.1 → 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
@@ -14,7 +14,7 @@
14
14
  *「`isPlaying` が true である **間** 画面を起こし続ける」*。`navigator.wakeLock.request()` も、`visibilitychange` での再取得のグルーコードも、後始末も不要です。
15
15
 
16
16
  - **入力サーフェス**: `active`, `type`, `manual`
17
- - **出力ステートサーフェス**: `held`, `error`
17
+ - **出力ステートサーフェス**: `held`, `error`, `errorInfo`
18
18
  - **コマンド**: `request()`, `release()`
19
19
 
20
20
  `@wcstack/wakelock` は [CSBC](https://github.com/csbc-dev/arch/blob/main/README.md)(Core / Shell / Binding Contract)アーキテクチャに従います:
@@ -109,6 +109,7 @@ npm install @wcstack/wakelock
109
109
  |----------|------------------|------|
110
110
  | `held` | `boolean` | wake lock の sentinel をいま保持しているか。OS の自動解放と再取得を反映する。 |
111
111
  | `error` | `Error \| null` | 直近のリクエスト失敗(拒否、未対応など)、または `null`。 |
112
+ | `errorInfo` | `WcsIoErrorInfo \| null` | `error` から派生した、失敗の serializable な taxonomy(安定した `code` / `phase` / `recoverable`)、または `null`。additive —— `error` の形状は不変。 |
112
113
 
113
114
  > **`wcs-wakelock:error` は単なる失敗シグナルではなく、プロパティ変更通知**(wc-bindable モデル)です: 失敗時には `detail` = エラーで発火し、その後のリクエストが成功して `error` プロパティがクリアされると `detail = null` で再度発火します。`error == null` は「過去に一度もエラーがなかった」ではなく「いまエラーがない」と解釈してください。
114
115
 
@@ -182,6 +183,7 @@ WakeLockCore.wcBindable = {
182
183
  properties: [
183
184
  { name: "held", event: "wcs-wakelock:held-changed" },
184
185
  { name: "error", event: "wcs-wakelock:error" },
186
+ { name: "errorInfo", event: "wcs-wakelock:error-info-changed" },
185
187
  ],
186
188
  commands: [
187
189
  { name: "request", async: true }, { name: "release" },
@@ -217,6 +219,7 @@ Core を直接駆動する場合は、終わったら `dispose()` を呼んで `
217
219
  - **自動解放は肩代わりされます。** OS は複数の理由でロックを落とします — ページの非表示だけでなく、ページが可視のままでもバッテリー低下や省電力モードで落ちることがあります。コンポーネントはどちらの場合もリースを更新します: *可視*中の解放は即座に再取得し、*非表示*中の解放は次に可視へ戻ったときに再取得します(`active` が立っている限り)。このバインディングは「一度取得する」ではなく「active の **間** 起こし続ける」を意味します。再取得が**拒否**された場合はループせず、`error` で surface して静止します(支配的なケース: 仕様上バッテリー低下/省電力下の再リクエストは拒否されます)。再取得が**許可**された場合はリースを更新するため、OS が許可と解放を繰り返す限りコンポーネントも更新を続けます(解放1回につき request 1回、OS 駆動であり同期的なスピンではありません)。
218
220
  - **セキュアコンテキスト(HTTPS)。** Screen Wake Lock API はセキュアコンテキスト(HTTPS、または `localhost`)でのみ動作します。
219
221
  - **決して throw しない。** 未対応環境はサイレントな no-op(`held` は `false` のまま)。拒否されたリクエストは throw せず `error` プロパティで surface します。`request()` は決して reject しません。
222
+ - **`errorInfo` taxonomy(additive)。** `error` と並んで、`<wcs-wakelock>` は*同一の*失敗を安定した `WcsIoErrorInfo`(`code` / `phase` / `recoverable`)に分類した serializable な `errorInfo`(`wcs-wakelock:error-info-changed`)を公開します。`error` の形状は変えません。reject された `request()` はその `Error.name` で分類されます: `NotAllowedError`(ページ非可視、または permission / feature-policy によるブロック)→ `not-allowed`(phase `start`)、それ以外(非 `Error` の reject を正規化したものなど)→ `wakelock-error`(phase `execute`)。どちらも `recoverable: false` です。`capability-missing` コードは**ありません**: 未対応環境はサイレントな no-op(`held` は `false` のまま・`error` 未設定)で、その分岐には到達しないためです。`errorInfo` は `error` とまったく同じタイミングで遷移し(後続の成功で `null` へクリア)、共有の `WcsIoErrorInfo` 型と `WCS_WAKELOCK_ERROR_CODE` 定数は export されています。
220
223
  - **パーミッションゲートなし。** 別個のパーミッションプロンプトはありません(ページが可視でない場合はリクエストが拒否されることがあり、それは `error` として surface します)。
221
224
 
222
225
  ## ライセンス
package/README.md CHANGED
@@ -14,7 +14,7 @@ With `@wcstack/state`, `<wcs-wakelock>` reads as one declarative line:
14
14
  *"Keep the screen awake **while** `isPlaying` is true."* No `navigator.wakeLock.request()`, no `visibilitychange` re-acquire glue, no teardown.
15
15
 
16
16
  - **input surface**: `active`, `type`, `manual`
17
- - **output state surface**: `held`, `error`
17
+ - **output state surface**: `held`, `error`, `errorInfo`
18
18
  - **commands**: `request()`, `release()`
19
19
 
20
20
  `@wcstack/wakelock` follows the [CSBC](https://github.com/csbc-dev/arch/blob/main/README.md) (Core / Shell / Binding Contract) architecture:
@@ -110,6 +110,7 @@ npm install @wcstack/wakelock
110
110
  |----------|------------------|-------------|
111
111
  | `held` | `boolean` | Whether a wake lock sentinel is currently held. Reflects OS auto-release and re-acquisition. |
112
112
  | `error` | `Error \| null` | The last request failure (e.g. denied, unsupported), or `null`. |
113
+ | `errorInfo` | `WcsIoErrorInfo \| null` | Serializable failure taxonomy (stable `code` / `phase` / `recoverable`) derived from `error`, or `null`. Additive — the `error` shape is unchanged. |
113
114
 
114
115
  > **`wcs-wakelock:error` is a property-change notification** (wc-bindable model), not just a failure signal: it fires with `detail` = the Error on a failed request, and fires again with `detail = null` when a later request succeeds and the `error` property is cleared. Read `error == null` as "no error *right now*", not "an error never happened".
115
116
 
@@ -185,6 +186,7 @@ WakeLockCore.wcBindable = {
185
186
  properties: [
186
187
  { name: "held", event: "wcs-wakelock:held-changed" },
187
188
  { name: "error", event: "wcs-wakelock:error" },
189
+ { name: "errorInfo", event: "wcs-wakelock:error-info-changed" },
188
190
  ],
189
191
  commands: [
190
192
  { name: "request", async: true }, { name: "release" },
@@ -221,6 +223,7 @@ When you drive the Core directly, call `dispose()` when you are done so its
221
223
  - **Auto-release is handled for you.** The OS may drop the lock for several reasons — the page being hidden, but also battery-low or power-saver mode while the page stays visible. The component renews the lease in both cases: a release while *visible* is re-acquired immediately, and a release while *hidden* is re-acquired on the next return to visibility — as long as `active` is still set. The binding means "keep awake *while* active", not "acquire once". A **denied** re-acquire does not loop — it surfaces via `error` and stays quiet (the dominant case: the spec rejects re-requests under battery-low / power-saver). A **granted** re-acquire renews the lease, so if the OS keeps granting and releasing, the component keeps renewing (one request per release, driven by the OS, not a synchronous spin).
222
224
  - **Secure context (HTTPS).** The Screen Wake Lock API only works in a secure context (HTTPS, or `localhost`).
223
225
  - **Never throws.** An unsupported environment is a silent no-op (`held` stays `false`); a rejected request surfaces via the `error` property rather than throwing. `request()` never rejects.
226
+ - **`errorInfo` taxonomy (additive).** Alongside `error`, `<wcs-wakelock>` publishes a serializable `errorInfo` (`wcs-wakelock:error-info-changed`) that classifies the *same* failure into a stable `WcsIoErrorInfo` (`code` / `phase` / `recoverable`), without changing the `error` shape. A rejected `request()` is classified by its `Error.name`: a `NotAllowedError` (page not visible, or a permission / feature-policy block) → `not-allowed` (phase `start`); anything else (e.g. a normalized non-`Error` rejection) → `wakelock-error` (phase `execute`). Both are `recoverable: false`. There is **no** `capability-missing` code: an unsupported environment is a silent no-op (`held` stays `false`, `error` unset), so that branch is unreachable. `errorInfo` transitions exactly when `error` does (cleared to `null` on a later success); the shared `WcsIoErrorInfo` type and the `WCS_WAKELOCK_ERROR_CODE` constants are exported.
224
227
  - **No permission gate.** There is no separate permission prompt (a request may still be denied if the page is not visible — that surfaces as `error`).
225
228
 
226
229
  ## License
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[];
@@ -60,6 +72,8 @@ interface WcsWakeLockCoreValues {
60
72
  held: boolean;
61
73
  /** The last request failure, or `null` while none. */
62
74
  error: Error | null;
75
+ /** Additive failure taxonomy derived from `error` (stable code / phase / recoverable). */
76
+ errorInfo: WcsIoErrorInfo | null;
63
77
  }
64
78
  /**
65
79
  * Value types for the Shell (`<wcs-wakelock>`) — identical observable surface to
@@ -125,6 +139,7 @@ declare class WakeLockCore extends EventTarget {
125
139
  private _active;
126
140
  private _held;
127
141
  private _error;
142
+ private _errorInfo;
128
143
  private _sentinel;
129
144
  private _gen;
130
145
  private _acquiring;
@@ -135,6 +150,13 @@ declare class WakeLockCore extends EventTarget {
135
150
  observe(): Promise<void>;
136
151
  get held(): boolean;
137
152
  get error(): Error | null;
153
+ /**
154
+ * The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /
155
+ * `recoverable`), or null. Additive wc-bindable property (event
156
+ * `wcs-wakelock:error-info-changed`), derived from `error`; the existing `error`
157
+ * property/event are unchanged.
158
+ */
159
+ get errorInfo(): WcsIoErrorInfo | null;
138
160
  /** The desired intent. Read-only reflection; not a wc-bindable property (it does
139
161
  * not change on an OS auto-release, so there is nothing to observe). */
140
162
  get active(): boolean;
@@ -142,6 +164,7 @@ declare class WakeLockCore extends EventTarget {
142
164
  set type(value: WakeLockKind);
143
165
  private _setHeld;
144
166
  private _setError;
167
+ private _commitErrorInfo;
145
168
  private _sameError;
146
169
  /**
147
170
  * Mark the lock as desired and acquire it. Idempotent while already held. If the
@@ -248,6 +271,7 @@ declare class WcsWakeLock extends HTMLElement {
248
271
  set manual(value: boolean);
249
272
  get held(): boolean;
250
273
  get error(): Error | null;
274
+ get errorInfo(): WcsIoErrorInfo | null;
251
275
  /** Acquire (and keep) the wake lock. Never rejects — see the `error` property. */
252
276
  request(): Promise<void>;
253
277
  /** Release the wake lock and stop re-acquiring it. */
@@ -257,5 +281,31 @@ declare class WcsWakeLock extends HTMLElement {
257
281
  attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
258
282
  }
259
283
 
260
- export { WakeLockCore, WcsWakeLock, bootstrapWakeLock, getConfig };
261
- export type { IWritableConfig, IWritableTagNames, WakeLockKind, WcsWakeLockCommands, WcsWakeLockCoreCommands, WcsWakeLockCoreValues, WcsWakeLockInputs, WcsWakeLockValues };
284
+ /**
285
+ * wakelockCapabilities.ts
286
+ *
287
+ * Wake Lock node 固有の error code(taxonomy)と derivation。汎用の error info 型は
288
+ * `./platformCapability.js`(/io-core/ から copy-distribution される生成ファイル)から
289
+ * import する。wake lock は request / release の pure sink で競合する operation を持た
290
+ * ないため lane は持たず、error taxonomy(errorInfo)のみを採用する。
291
+ *
292
+ * error 面は sensor family(`{ error: <name>, message }`)とは異なり、`WakeLockCore._setError`
293
+ * は生の `Error`(または clear の null)を受け取る。分類は `Error.name` で行う。
294
+ *
295
+ * NOTE(未対応環境について): Screen Wake Lock API は "unsupported" を error として通知しない。
296
+ * `navigator.wakeLock` 不在時、Core の `_acquire()` は silent no-op(`held` は false のまま・
297
+ * error 未設定)で戻る。よって sensor family のような `capability-missing` / phase="probe" の
298
+ * 分岐は wake lock には存在しない(到達不能なので実装しない)。error が出るのは
299
+ * `navigator.wakeLock.request()` の reject を `_normalizeError` で正規化した場合のみ。
300
+ */
301
+
302
+ /** 安定した wake lock error code(taxonomy)。値は公開キーとして固定。 */
303
+ declare const WCS_WAKELOCK_ERROR_CODE: {
304
+ /** `NotAllowedError` — ページ非可視/非アクティブ、または permission / feature-policy による拒否。 */
305
+ readonly NotAllowed: "not-allowed";
306
+ /** その他の `request()` 失敗(非 Error reject の正規化など)。 */
307
+ readonly WakeLockError: "wakelock-error";
308
+ };
309
+
310
+ export { WCS_WAKELOCK_ERROR_CODE, WakeLockCore, WcsWakeLock, bootstrapWakeLock, getConfig };
311
+ export type { IWritableConfig, IWritableTagNames, WakeLockKind, WcsIoErrorInfo, WcsIoErrorPhase, WcsWakeLockCommands, WcsWakeLockCoreCommands, WcsWakeLockCoreValues, WcsWakeLockInputs, WcsWakeLockValues };
package/dist/index.esm.js CHANGED
@@ -43,6 +43,51 @@ function setConfig(partialConfig) {
43
43
  frozenConfig = null;
44
44
  }
45
45
 
46
+ /**
47
+ * wakelockCapabilities.ts
48
+ *
49
+ * Wake Lock node 固有の error code(taxonomy)と derivation。汎用の error info 型は
50
+ * `./platformCapability.js`(/io-core/ から copy-distribution される生成ファイル)から
51
+ * import する。wake lock は request / release の pure sink で競合する operation を持た
52
+ * ないため lane は持たず、error taxonomy(errorInfo)のみを採用する。
53
+ *
54
+ * error 面は sensor family(`{ error: <name>, message }`)とは異なり、`WakeLockCore._setError`
55
+ * は生の `Error`(または clear の null)を受け取る。分類は `Error.name` で行う。
56
+ *
57
+ * NOTE(未対応環境について): Screen Wake Lock API は "unsupported" を error として通知しない。
58
+ * `navigator.wakeLock` 不在時、Core の `_acquire()` は silent no-op(`held` は false のまま・
59
+ * error 未設定)で戻る。よって sensor family のような `capability-missing` / phase="probe" の
60
+ * 分岐は wake lock には存在しない(到達不能なので実装しない)。error が出るのは
61
+ * `navigator.wakeLock.request()` の reject を `_normalizeError` で正規化した場合のみ。
62
+ */
63
+ /** 安定した wake lock error code(taxonomy)。値は公開キーとして固定。 */
64
+ const WCS_WAKELOCK_ERROR_CODE = {
65
+ /** `NotAllowedError` — ページ非可視/非アクティブ、または permission / feature-policy による拒否。 */
66
+ NotAllowed: "not-allowed",
67
+ /** その他の `request()` 失敗(非 Error reject の正規化など)。 */
68
+ WakeLockError: "wakelock-error",
69
+ };
70
+ /**
71
+ * wake lock の失敗を serializable な error taxonomy に写す。`error` は
72
+ * `WakeLockCore._setError` に渡る生の `Error`(`navigator.wakeLock.request()` の reject を
73
+ * `_normalizeError` で正規化したもの)。
74
+ *
75
+ * - `NotAllowedError` は取得(request/acquire)時の拒否 — ページ非可視・permission /
76
+ * feature-policy ブロック → phase="start" / not-allowed。
77
+ * - それ以外(非 Error reject を正規化した `Error` name="Error" など)は phase="execute" /
78
+ * wakelock-error。
79
+ *
80
+ * いずれも retry で確実には回復しないため recoverable=false(可視復帰時の再取得は Core が
81
+ * 内部で担うが、taxonomy 上の分類としては false)。"unsupported" は error にならない
82
+ * (silent no-op)ため capability-missing の分岐は無い(ファイル冒頭 NOTE 参照)。
83
+ */
84
+ function deriveWakeLockErrorInfo(error) {
85
+ if (error.name === "NotAllowedError") {
86
+ return { code: WCS_WAKELOCK_ERROR_CODE.NotAllowed, phase: "start", recoverable: false, message: error.message };
87
+ }
88
+ return { code: WCS_WAKELOCK_ERROR_CODE.WakeLockError, phase: "execute", recoverable: false, message: error.message };
89
+ }
90
+
46
91
  /**
47
92
  * Headless screen-wake-lock primitive — a thin, framework-agnostic wrapper around
48
93
  * the Screen Wake Lock API exposed through the wc-bindable protocol.
@@ -70,6 +115,12 @@ class WakeLockCore extends EventTarget {
70
115
  properties: [
71
116
  { name: "held", event: "wcs-wakelock:held-changed" },
72
117
  { name: "error", event: "wcs-wakelock:error" },
118
+ // Serializable failure taxonomy (stable code / phase / recoverable), or null.
119
+ // Additive bindable output derived from the raw `error` (not-allowed / wakelock-error);
120
+ // the existing `error` property/event are unchanged. Fires
121
+ // wcs-wakelock:error-info-changed. No lane — the wake lock is a pure sink (request /
122
+ // release do not compete).
123
+ { name: "errorInfo", event: "wcs-wakelock:error-info-changed" },
73
124
  ],
74
125
  commands: [
75
126
  { name: "request", async: true },
@@ -83,6 +134,7 @@ class WakeLockCore extends EventTarget {
83
134
  _active = false;
84
135
  _held = false;
85
136
  _error = null;
137
+ _errorInfo = null;
86
138
  _sentinel = null;
87
139
  // Bumped on every release()/new acquire so an in-flight async request() that
88
140
  // resolves late can detect it was superseded and drop its sentinel (mirrors the
@@ -122,6 +174,15 @@ class WakeLockCore extends EventTarget {
122
174
  get error() {
123
175
  return this._error;
124
176
  }
177
+ /**
178
+ * The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /
179
+ * `recoverable`), or null. Additive wc-bindable property (event
180
+ * `wcs-wakelock:error-info-changed`), derived from `error`; the existing `error`
181
+ * property/event are unchanged.
182
+ */
183
+ get errorInfo() {
184
+ return this._errorInfo;
185
+ }
125
186
  /** The desired intent. Read-only reflection; not a wc-bindable property (it does
126
187
  * not change on an OS auto-release, so there is nothing to observe). */
127
188
  get active() {
@@ -161,11 +222,25 @@ class WakeLockCore extends EventTarget {
161
222
  if (this._sameError(this._error, error))
162
223
  return;
163
224
  this._error = error;
225
+ // Keep the additive `errorInfo` taxonomy in sync with `error`: derive from the raw
226
+ // Error (or null on clear). Fires before the `error` event so an observer binding
227
+ // both sees the classification first, mirroring the io-node family.
228
+ this._commitErrorInfo(error === null ? null : deriveWakeLockErrorInfo(error));
164
229
  this._target.dispatchEvent(new CustomEvent("wcs-wakelock:error", {
165
230
  detail: error,
166
231
  bubbles: true,
167
232
  }));
168
233
  }
234
+ // Called only from _setError (which already same-value-guards on the error name +
235
+ // message via _sameError), so errorInfo transitions exactly when error does — no
236
+ // separate guard needed here.
237
+ _commitErrorInfo(info) {
238
+ this._errorInfo = info;
239
+ this._target.dispatchEvent(new CustomEvent("wcs-wakelock:error-info-changed", {
240
+ detail: info,
241
+ bubbles: true,
242
+ }));
243
+ }
169
244
  _sameError(a, b) {
170
245
  if (a === b)
171
246
  return true;
@@ -542,6 +617,9 @@ class WcsWakeLock extends HTMLElement {
542
617
  get error() {
543
618
  return this._core.error;
544
619
  }
620
+ get errorInfo() {
621
+ return this._core.errorInfo;
622
+ }
545
623
  // --- Commands ---
546
624
  /** Acquire (and keep) the wake lock. Never rejects — see the `error` property. */
547
625
  request() {
@@ -606,5 +684,5 @@ function bootstrapWakeLock(userConfig) {
606
684
  registerComponents();
607
685
  }
608
686
 
609
- export { WakeLockCore, WcsWakeLock, bootstrapWakeLock, getConfig };
687
+ export { WCS_WAKELOCK_ERROR_CODE, WakeLockCore, WcsWakeLock, bootstrapWakeLock, getConfig };
610
688
  //# sourceMappingURL=index.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/config.ts","../src/core/WakeLockCore.ts","../src/components/WakeLock.ts","../src/registerComponents.ts","../src/bootstrapWakeLock.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n wakelock: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n wakelock: \"wcs-wakelock\",\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\n// Note: this is the live, mutable internal config. It is not part of the public\n// package exports (see exports.ts) — only `getConfig()` (a frozen snapshot) is\n// surfaced. `setConfig()` is applied internally via `bootstrapWakeLock()` and\n// is not re-exported from the package root, though a deep path import\n// (`.../src/config.js`) can still reach and mutate it. Accepted as-is for\n// cross-package consistency: every @wcstack package follows this same shape.\n// Use `getConfig()` for a frozen, safe read.\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, WakeLockKind } from \"../types.js\";\n\n/**\n * Minimal structural views of the Screen Wake Lock API. Declared locally (rather\n * than relying on `lib.dom`'s experimental `WakeLock` types) so the package type-\n * checks the same across TypeScript lib versions, and so a runtime where\n * `navigator.wakeLock` is absent is just a value check, never a type error.\n */\ninterface WakeLockSentinelLike extends EventTarget {\n readonly released: boolean;\n readonly type: string;\n release(): Promise<void>;\n}\ninterface WakeLockLike {\n request(type?: string): Promise<WakeLockSentinelLike>;\n}\n\n/**\n * Headless screen-wake-lock primitive — a thin, framework-agnostic wrapper around\n * the Screen Wake Lock API exposed through the wc-bindable protocol.\n *\n * Unlike the other @wcstack sensors (geolocation / intersection), the wake lock is\n * a pure *sink*: nothing is read from the device. A bound state drives the desired\n * intent (`request()` / `release()`), and the only observable outputs are `held`\n * (whether a sentinel is actually held) and `error`.\n *\n * The OS releases the lock whenever the page stops being visible (tab hidden,\n * window minimized). To honor the declarative intent (\"keep awake *while* active\"),\n * the Core keeps the desired flag (`_active`) and re-acquires the lock on the next\n * `visibilitychange` back to visible. So `_active` (desired) and `held` (actual)\n * diverge across an auto-release — and only `held` is published, because desired\n * does not change when the OS drops the lock.\n *\n * Never-throw: `request()` never rejects (a failure surfaces via `error`), and an\n * unsupported environment is a silent no-op (`held` stays false), consistent with\n * the other @wcstack sensors.\n */\nexport class WakeLockCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"held\", event: \"wcs-wakelock:held-changed\" },\n { name: \"error\", event: \"wcs-wakelock:error\" },\n ],\n commands: [\n { name: \"request\", async: true },\n { name: \"release\" },\n ],\n };\n\n private _target: EventTarget;\n private _type: WakeLockKind;\n\n // `_active` is the desired intent (input); `_held` is whether a sentinel is\n // actually held right now (output). They diverge across an OS auto-release.\n private _active: boolean = false;\n private _held: boolean = false;\n private _error: Error | null = null;\n private _sentinel: WakeLockSentinelLike | null = null;\n\n // Bumped on every release()/new acquire so an in-flight async request() that\n // resolves late can detect it was superseded and drop its sentinel (mirrors the\n // generation guards in GeolocationCore).\n private _gen: number = 0;\n // True while an `_acquire()` is awaiting `navigator.wakeLock.request()`. The\n // `_held` flag is only set *after* that await resolves, so it cannot guard\n // against concurrent entry: two rapid visibilitychange events (or a Shell toggle\n // overlapping an in-flight request) would both pass `!this._held` and each call\n // `request()`. This in-flight flag closes that window — a re-entrant acquire is a\n // no-op. The `_gen` guard still ensures the *final* state is correct; this just\n // avoids the redundant `request()` call (and its duplicate error path on a denied\n // environment).\n private _acquiring: boolean = false;\n private _visibilityBound: boolean = false;\n\n // SSR (§3.8): a pure sink has no asynchronous probe to await — `request()` is\n // fire-and-forget and meaningless server-side — so readiness is immediate.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget, type: WakeLockKind = \"screen\") {\n super();\n this._target = target ?? this;\n this._type = type;\n }\n\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // Lifecycle (§3.5). The wake lock is command-driven (request / release) with no\n // ambient subscription to establish on connect, so observe() is an idempotent\n // no-op that resolves once ready; dispose() (below) tears down the visibility\n // listener, releases any held sentinel, and bumps _gen via release().\n observe(): Promise<void> {\n return this._ready;\n }\n\n get held(): boolean {\n return this._held;\n }\n\n get error(): Error | null {\n return this._error;\n }\n\n /** The desired intent. Read-only reflection; not a wc-bindable property (it does\n * not change on an OS auto-release, so there is nothing to observe). */\n get active(): boolean {\n return this._active;\n }\n\n get type(): WakeLockKind {\n return this._type;\n }\n\n set type(value: WakeLockKind) {\n // Currently effectively a no-op: \"screen\" is the only standardized lock type,\n // so `WakeLockKind` is a single value and this setter never observes a real\n // change. Kept as a forward-compatible seam for when the spec adds lock types.\n //\n // Takes effect on the next acquire. Changing the type mid-hold deliberately does\n // NOT re-acquire — the live sentinel is left as is, so a type change applies only\n // from the following acquire. If multiple lock types are ever added this becomes\n // an observable behavior gap (a held lock keeps its old type until release/re-\n // acquire) and must be re-examined — likely re-acquire here when held.\n this._type = value;\n }\n\n // --- State setters with event dispatch ---\n\n private _setHeld(held: boolean): void {\n if (this._held === held) return;\n this._held = held;\n this._target.dispatchEvent(new CustomEvent(\"wcs-wakelock:held-changed\", {\n detail: held,\n bubbles: true,\n }));\n }\n\n private _setError(error: Error | null): void {\n // Value guard, not just reference: a denied request rejects with a *fresh*\n // Error on every visibility-driven retry, so a reference compare would let a\n // permanently-denied environment re-dispatch the same failure on each\n // hidden→visible toggle. Compare name+message too. Transitions through null (a\n // success clears the error) always re-fire, so a genuinely new failure is seen.\n if (this._sameError(this._error, error)) return;\n this._error = error;\n this._target.dispatchEvent(new CustomEvent(\"wcs-wakelock:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n private _sameError(a: Error | null, b: Error | null): boolean {\n if (a === b) return true;\n if (a !== null && b !== null) return a.name === b.name && a.message === b.message;\n return false;\n }\n\n // --- Public API ---\n\n /**\n * Mark the lock as desired and acquire it. Idempotent while already held. If the\n * API is unavailable or the page is currently hidden, the desired flag is still\n * set (so the lock is acquired on the next return to visibility) but nothing is\n * acquired now. Never rejects — a request failure surfaces via `error`.\n */\n async request(): Promise<void> {\n this._active = true;\n this._ensureVisibilityListener();\n await this._acquire();\n }\n\n /** Mark the lock as no longer desired and release any held sentinel. */\n release(): void {\n this._active = false;\n // Invalidate any in-flight acquire so a late-resolving request() drops its\n // sentinel instead of leaving a lock held after release.\n this._gen++;\n const sentinel = this._sentinel;\n if (sentinel) {\n this._sentinel = null;\n sentinel.removeEventListener(\"release\", this._onRelease);\n void sentinel.release().catch(() => { /* never-throw */ });\n }\n this._setHeld(false);\n }\n\n /**\n * Full teardown: remove the visibility listener and release any held sentinel.\n * Call from the Shell's `disconnectedCallback`.\n *\n * Semantics: this is a terminal teardown, not a pause. After `dispose()` the Core\n * is meant to be discarded — there is no re-arm step, and the visibility listener\n * is gone, so an OS auto-release will no longer be followed by a re-acquire. A\n * later `request()` would still work in isolation (it re-attaches the listener via\n * `_ensureVisibilityListener`), but reusing a disposed Core is not an intended path;\n * the Shell always constructs a fresh Core per element instead.\n */\n dispose(): void {\n if (this._visibilityBound) {\n // §4 deviation: document-scoped Web API; no element-free alternative — the\n // Page Visibility `visibilitychange` event is only dispatched on `document`.\n document.removeEventListener(\"visibilitychange\", this._onVisibilityChange);\n this._visibilityBound = false;\n }\n this.release();\n }\n\n // --- Internal ---\n\n private async _acquire(): Promise<void> {\n if (this._held) return; // idempotent: already holding a sentinel\n if (this._acquiring) return; // an acquire is already in flight — don't double-request\n const wakeLock = this._wakeLock();\n if (!wakeLock) return; // unsupported — stay active, never acquire (silent no-op)\n if (!this._isVisible()) return; // hidden — defer to the next visibilitychange\n const gen = ++this._gen;\n this._acquiring = true;\n // Flag management is centralized in `finally` and the coalesced retry is invoked\n // exactly once, AFTER the try/catch/finally settles. This keeps the reject and\n // resolve paths symmetric: neither calls `_retryIfStillDesired()` from inside the\n // try/catch (which would let `finally` re-clear the `_acquiring=true` the retry's\n // synchronous re-entry just set, reopening the double-request window). `superseded`\n // records that a newer release()/request() bumped `_gen` mid-flight so its still-\n // live intent — blocked by the in-flight guard at the time — gets one retry here.\n // NOTE: no early `return` inside the try/catch below — every branch must fall\n // through to the post-`finally` retry. A `return` from inside the try would run\n // `finally` and then exit the function, skipping the `if (superseded)` retry.\n let superseded = false;\n let sentinel: WakeLockSentinelLike | null = null;\n let failed: Error | null = null;\n try {\n sentinel = await wakeLock.request(this._type);\n } catch (e) {\n if (gen !== this._gen) {\n // Superseded while awaiting — drop this stale failure (do not clobber the\n // newer state) and let the post-finally retry honor the live intent.\n superseded = true;\n } else {\n failed = this._normalizeError(e);\n }\n } finally {\n // The sole owner of the flag clears it here — on every exit path. A concurrent\n // re-entrant `_acquire()` was a no-op at the `_acquiring` guard, so it never owns\n // the flag; a superseding release()/acquire only bumps `_gen` and does not start\n // its own in-flight cycle until this clears the flag. Because this runs before\n // the retry below, the retry's `_acquiring=true` is never clobbered.\n this._acquiring = false;\n }\n\n if (sentinel !== null && gen !== this._gen) {\n // release() (or a newer acquire) ran while we awaited — this sentinel is\n // unwanted; drop it so no lock lingers, and retry the newer intent below.\n void sentinel.release().catch(() => { /* never-throw */ });\n superseded = true;\n } else if (sentinel !== null) {\n this._sentinel = sentinel;\n sentinel.addEventListener(\"release\", this._onRelease);\n this._setError(null);\n this._setHeld(true);\n } else if (failed !== null) {\n // A live (non-superseded) failure: surface it. Never retried — the intent is\n // honored but the environment denied it, so looping would spin.\n this._setError(failed);\n this._setHeld(false);\n }\n\n // Coalesced retry: at most one re-attempt per supersession, after the flag is\n // clear. The `_acquiring` guard inside still protects any concurrent re-entry that\n // overlaps THIS retry's own in-flight window (reject- and resolve-retry alike).\n if (superseded) this._retryIfStillDesired();\n }\n\n /**\n * Re-attempt an acquire after an in-flight one was *superseded* (its generation no\n * longer matches), but only if the lock is still desired, not already held, and the\n * page is visible. This recovers a request() that was coalesced away by the\n * in-flight `_acquiring` guard: during a release()→request() overlap, the second\n * request() bumps `_gen` and is a no-op at the guard, so without this retry its\n * still-live intent would be lost until the next visibilitychange or manual call.\n *\n * Bounded — cannot loop forever: a retry runs ONLY on supersession, and a\n * supersession requires an external release()/request() to bump `_gen` mid-flight.\n * A retry's own `_acquire()`, if it is itself not superseded, terminates by either\n * acquiring (held=true) or recording the live failure (held=false, error set) —\n * neither path retries. So a denied environment that keeps rejecting does not\n * recurse; the retry chain length is bounded by the number of external overlaps.\n */\n private _retryIfStillDesired(): void {\n if (this._active && !this._held && this._isVisible()) {\n void this._acquire();\n }\n }\n\n // Fired for an OS release of a held sentinel — which the spec allows for several\n // reasons, NOT only a visibility change: tab hidden / window minimized, but also\n // battery-low, power-saver mode, etc. while the page stays visible. We reflect\n // held=false, then (lease renewal) re-acquire immediately IF the page is still\n // visible and the lock is still desired — because a visible-context release emits no\n // `visibilitychange`, so the visibilitychange listener (②) would never fire and the\n // lock would stay stuck at desired=true / held=false. The hidden case is the no-op\n // here: re-acquire is gated on `_isVisible()`, so a hide-driven release defers to ②\n // (re-acquire on the return to visibility), avoiding a release→acquire loop while\n // hidden.\n private _onRelease = (): void => {\n // The `if (this._sentinel)` false branch is defensive and unreachable in practice:\n // this listener is only ever attached to the live `_sentinel`, and the only paths\n // that null `_sentinel` (this handler itself, and release()) remove this listener\n // in the same step — so the listener and a non-null `_sentinel` are coupled and\n // this never fires with `_sentinel === null`. Guarded anyway in case a host\n // dispatches a spurious second \"release\". (c8 ignore the unhittable else.)\n /* c8 ignore next */\n if (this._sentinel) {\n this._sentinel.removeEventListener(\"release\", this._onRelease);\n this._sentinel = null;\n }\n this._setHeld(false);\n this._reacquireAfterRelease();\n };\n\n /**\n * Lease renewal after an OS release while the page is still visible. Honors the\n * \"keep awake *while* active\" promise for releases that do NOT coincide with a\n * visibility change (battery-low / power-saver), which otherwise leave the lock\n * stuck at desired=true / held=false until the next hide→show cycle.\n *\n * Bounded on failure: this only runs from `_onRelease`, which only fires when a\n * sentinel was genuinely acquired and then released. A re-acquire that FAILS takes\n * `_acquire()`'s live-failure path (error recorded, held=false) and attaches no\n * listener, so it cannot re-enter `_onRelease` — a denied environment records the\n * error once and stops. This is the dominant real path: per the Wake Lock spec a\n * re-request under battery-low / power-saver is rejected (`NotAllowedError`), so the\n * renewal terminates there.\n *\n * The one path NOT bounded by a counter is a pathological host that keeps GRANTING\n * the re-request and then immediately auto-releasing it (grant→release reflux). Each\n * iteration yields to the event loop and consumes a real OS grant, so it is not a\n * tight/synchronous loop, but it would churn request() calls. We deliberately do NOT\n * add a debounce or renewal cap: that reflux is not documented browser behavior\n * (real browsers reject, not grant-then-revoke), and the extra timing state would\n * complicate the pure-sink design to defend a case that does not occur in practice.\n *\n * The `_isVisible()` / `!_acquiring` guards (doubled by `_acquire()`'s own in-flight\n * and held guards) prevent re-entry during an in-flight acquire and while hidden.\n */\n private _reacquireAfterRelease(): void {\n if (this._active && this._isVisible() && !this._acquiring) {\n void this._acquire();\n }\n }\n\n // ② Re-acquire when the page becomes visible again while the lock is still\n // desired but was auto-released. This is what makes `active` a durable intent.\n private _onVisibilityChange = (): void => {\n if (this._isVisible() && this._active && !this._held) {\n void this._acquire();\n }\n };\n\n private _ensureVisibilityListener(): void {\n if (this._visibilityBound) return;\n // §4 deviation: document-scoped Web API; no element-free alternative — the\n // Page Visibility `visibilitychange` event is only dispatched on `document`.\n document.addEventListener(\"visibilitychange\", this._onVisibilityChange);\n this._visibilityBound = true;\n }\n\n private _wakeLock(): WakeLockLike | null {\n return (navigator as Navigator & { wakeLock?: WakeLockLike }).wakeLock ?? null;\n }\n\n private _isVisible(): boolean {\n // §4 deviation: document-scoped Web API; no element-free alternative —\n // `visibilityState` lives on `document`, not on any element.\n return document.visibilityState === \"visible\";\n }\n\n private _normalizeError(e: unknown): Error {\n return e instanceof Error ? e : new Error(String(e));\n }\n}\n","import { IWcBindable, WakeLockKind } from \"../types.js\";\nimport { WakeLockCore } from \"../core/WakeLockCore.js\";\n\n/**\n * `<wcs-wakelock>` — declarative Screen Wake Lock.\n *\n * The first @wcstack tag that is a pure *sink*: every other sensor is an\n * element→state producer, but the wake lock is state→element. The headline\n * binding is `active@isPlaying` — hold the screen awake while a bound boolean is\n * true. `active` is the single input knob (a mirrored attribute); `held` and\n * `error` are the observable outputs.\n *\n * The OS auto-releases the lock when the page is hidden; the Core re-acquires it\n * on the next return to visibility while `active` is still set, so the binding\n * means \"keep awake *while* active\", not just \"acquire once\".\n */\nexport class WcsWakeLock extends HTMLElement {\n // SSR contract (§4.1/@wcstack/server): the renderer awaits elements declaring\n // `hasConnectedCallbackPromise = true` before snapshotting. The wake lock has no\n // connect-time async probe to await (acquire is fire-and-forget and meaningless\n // server-side), so `connectedCallbackPromise` is backed by the Core's no-op\n // `observe()`, which resolves immediately. The flag is still declared `true` so\n // the renderer reads it via `ctor.hasConnectedCallbackPromise` and the Shell\n // participates uniformly in the SSR await protocol.\n static hasConnectedCallbackPromise = true;\n // `active` drives request/release; `type` propagates to the Core's next acquire.\n // `manual` is intentionally excluded: it is a connect-time policy (\"don't auto-\n // acquire on connect\"), not a live switch.\n static observedAttributes = [\"active\", \"type\"];\n\n static wcBindable: IWcBindable = {\n ...WakeLockCore.wcBindable,\n // Settable surface. `active` is the declarative intent; `type` selects the lock\n // kind; `manual` opts out of auto-acquire on connect. The request / release\n // commands are inherited from the Core via the spread above.\n inputs: [\n { name: \"active\", attribute: \"active\" },\n { name: \"type\", attribute: \"type\" },\n { name: \"manual\", attribute: \"manual\" },\n ],\n // Core の commands をそのまま継承(単一情報源)。<wcs-intersect>/<wcs-sse> と同型。\n // spread でも継承されるが、Core に command 追加時の追従漏れを防ぐため明示参照する。\n commands: WakeLockCore.wcBindable.commands,\n };\n\n private _core: WakeLockCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new WakeLockCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-wakelock:held-changed\": (d) => ({ held: d === true }),\n \"wcs-wakelock:error\": (d) => ({ error: d != null }),\n });\n }\n\n // SSR (§4.1): the renderer awaits this before snapshotting. Backed by the Core's\n // observe() (a no-op resolving immediately for this command-driven sink).\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\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 // The ternary expression-statement form trips ESLint no-unused-expressions.\n if (on) { states.add(name); } else { states.delete(name); }\n } catch { /* never-throw */ }\n if (debug) this.toggleAttribute(`data-wcs-state-${name}`, on);\n }\n });\n }\n }\n\n // --- Attribute accessors ---\n\n get active(): boolean {\n // Reflects the *attribute*, not the Core's desired intent (`_core.active`). These\n // can diverge: invoking the `request` / `release` commands directly (e.g. via a\n // command-token binding) flips the Core's desired flag without touching the\n // attribute, so `el.active` may read false while `el.held` is true (or vice\n // versa). The attribute is the declarative input surface; the commands are an\n // imperative side door. Bind via `active@...` for a single source of truth.\n return this.hasAttribute(\"active\");\n }\n\n set active(value: boolean) {\n if (value) {\n this.setAttribute(\"active\", \"\");\n } else {\n this.removeAttribute(\"active\");\n }\n }\n\n get type(): WakeLockKind {\n // Only \"screen\" is standardized; an absent/empty attribute defaults to it.\n return (this.getAttribute(\"type\") as WakeLockKind) || \"screen\";\n }\n\n set type(value: WakeLockKind) {\n this.setAttribute(\"type\", value);\n }\n\n get manual(): boolean {\n return this.hasAttribute(\"manual\");\n }\n\n set manual(value: boolean) {\n if (value) {\n this.setAttribute(\"manual\", \"\");\n } else {\n this.removeAttribute(\"manual\");\n }\n }\n\n // --- Core delegated getters ---\n\n get held(): boolean {\n return this._core.held;\n }\n\n get error(): Error | null {\n return this._core.error;\n }\n\n // --- Commands ---\n\n /** Acquire (and keep) the wake lock. Never rejects — see the `error` property. */\n request(): Promise<void> {\n return this._core.request();\n }\n\n /** Release the wake lock and stop re-acquiring it. */\n release(): void {\n this._core.release();\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n // Headless resource: no layout box (mirrors the @wcstack sensor convention).\n this.style.display = \"none\";\n // Propagate the requested lock type to the Core. Currently a no-op in effect:\n // \"screen\" is the only standardized type, so `type` is always \"screen\". Wired\n // up as a forward-compatible seam (observedAttributes + setter + this line) for\n // when the spec adds lock types; until then it carries a constant.\n this._core.type = this.type;\n // Establish monitoring (§3.5) and expose readiness for SSR (§4.1). observe()\n // is a no-op that resolves immediately for this command-driven sink.\n this._connectedCallbackPromise = this._core.observe();\n if (!this.manual && this.active) {\n void this._core.request();\n }\n }\n\n disconnectedCallback(): void {\n this._core.dispose();\n }\n\n attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void {\n if (oldValue === newValue) return;\n // Ignore changes applied before connect (e.g. createElement + setAttribute);\n // connectedCallback applies the initial state. Acquiring a lock for a detached\n // element would be wrong.\n if (!this.isConnected) return;\n if (name === \"type\") {\n this._core.type = this.type;\n return;\n }\n // name === \"active\": a live toggle always drives request/release. `manual` only\n // gates the connect-time auto-acquire, not an explicit author toggle.\n if (this.active) {\n void this._core.request();\n } else {\n this._core.release();\n }\n }\n}\n","import { WcsWakeLock } from \"./components/WakeLock.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.wakelock)) {\n customElements.define(config.tagNames.wakelock, WcsWakeLock);\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapWakeLock(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,QAAQ,EAAE,cAAc;AACzB,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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IACtB;AAEA,IAAA,wBAAwB,CAAC,IAAY,EAAE,QAAuB,EAAE,QAAuB,EAAA;QACrF,IAAI,QAAQ,KAAK,QAAQ;YAAE;;;;QAI3B,IAAI,CAAC,IAAI,CAAC,WAAW;YAAE;AACvB,QAAA,IAAI,IAAI,KAAK,MAAM,EAAE;YACnB,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI;YAC3B;QACF;;;AAGA,QAAA,IAAI,IAAI,CAAC,MAAM,EAAE;AACf,YAAA,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;QAC3B;aAAO;AACL,YAAA,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;QACtB;IACF;;;SC9Mc,kBAAkB,GAAA;AAChC,IAAA,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;QACjD,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAC9D;AACF;;ACHM,SAAU,iBAAiB,CAAC,UAA4B,EAAA;IAC5D,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/wakelockCapabilities.ts","../src/core/WakeLockCore.ts","../src/components/WakeLock.ts","../src/registerComponents.ts","../src/bootstrapWakeLock.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n wakelock: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n wakelock: \"wcs-wakelock\",\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\n// Note: this is the live, mutable internal config. It is not part of the public\n// package exports (see exports.ts) — only `getConfig()` (a frozen snapshot) is\n// surfaced. `setConfig()` is applied internally via `bootstrapWakeLock()` and\n// is not re-exported from the package root, though a deep path import\n// (`.../src/config.js`) can still reach and mutate it. Accepted as-is for\n// cross-package consistency: every @wcstack package follows this same shape.\n// Use `getConfig()` for a frozen, safe read.\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 * wakelockCapabilities.ts\n *\n * Wake Lock node 固有の error code(taxonomy)と derivation。汎用の error info 型は\n * `./platformCapability.js`(/io-core/ から copy-distribution される生成ファイル)から\n * import する。wake lock は request / release の pure sink で競合する operation を持た\n * ないため lane は持たず、error taxonomy(errorInfo)のみを採用する。\n *\n * error 面は sensor family(`{ error: <name>, message }`)とは異なり、`WakeLockCore._setError`\n * は生の `Error`(または clear の null)を受け取る。分類は `Error.name` で行う。\n *\n * NOTE(未対応環境について): Screen Wake Lock API は \"unsupported\" を error として通知しない。\n * `navigator.wakeLock` 不在時、Core の `_acquire()` は silent no-op(`held` は false のまま・\n * error 未設定)で戻る。よって sensor family のような `capability-missing` / phase=\"probe\" の\n * 分岐は wake lock には存在しない(到達不能なので実装しない)。error が出るのは\n * `navigator.wakeLock.request()` の reject を `_normalizeError` で正規化した場合のみ。\n */\n\nimport type { WcsIoErrorInfo } from \"./platformCapability.js\";\n\n/** 安定した wake lock error code(taxonomy)。値は公開キーとして固定。 */\nexport const WCS_WAKELOCK_ERROR_CODE = {\n /** `NotAllowedError` — ページ非可視/非アクティブ、または permission / feature-policy による拒否。 */\n NotAllowed: \"not-allowed\",\n /** その他の `request()` 失敗(非 Error reject の正規化など)。 */\n WakeLockError: \"wakelock-error\",\n} as const;\n\n/**\n * wake lock の失敗を serializable な error taxonomy に写す。`error` は\n * `WakeLockCore._setError` に渡る生の `Error`(`navigator.wakeLock.request()` の reject を\n * `_normalizeError` で正規化したもの)。\n *\n * - `NotAllowedError` は取得(request/acquire)時の拒否 — ページ非可視・permission /\n * feature-policy ブロック → phase=\"start\" / not-allowed。\n * - それ以外(非 Error reject を正規化した `Error` name=\"Error\" など)は phase=\"execute\" /\n * wakelock-error。\n *\n * いずれも retry で確実には回復しないため recoverable=false(可視復帰時の再取得は Core が\n * 内部で担うが、taxonomy 上の分類としては false)。\"unsupported\" は error にならない\n * (silent no-op)ため capability-missing の分岐は無い(ファイル冒頭 NOTE 参照)。\n */\nexport function deriveWakeLockErrorInfo(error: Error): WcsIoErrorInfo {\n if (error.name === \"NotAllowedError\") {\n return { code: WCS_WAKELOCK_ERROR_CODE.NotAllowed, phase: \"start\", recoverable: false, message: error.message };\n }\n return { code: WCS_WAKELOCK_ERROR_CODE.WakeLockError, phase: \"execute\", recoverable: false, message: error.message };\n}\n","import { IWcBindable, WakeLockKind } from \"../types.js\";\nimport { WcsIoErrorInfo } from \"./platformCapability.js\";\nimport { deriveWakeLockErrorInfo } from \"./wakelockCapabilities.js\";\n\n/**\n * Minimal structural views of the Screen Wake Lock API. Declared locally (rather\n * than relying on `lib.dom`'s experimental `WakeLock` types) so the package type-\n * checks the same across TypeScript lib versions, and so a runtime where\n * `navigator.wakeLock` is absent is just a value check, never a type error.\n */\ninterface WakeLockSentinelLike extends EventTarget {\n readonly released: boolean;\n readonly type: string;\n release(): Promise<void>;\n}\ninterface WakeLockLike {\n request(type?: string): Promise<WakeLockSentinelLike>;\n}\n\n/**\n * Headless screen-wake-lock primitive — a thin, framework-agnostic wrapper around\n * the Screen Wake Lock API exposed through the wc-bindable protocol.\n *\n * Unlike the other @wcstack sensors (geolocation / intersection), the wake lock is\n * a pure *sink*: nothing is read from the device. A bound state drives the desired\n * intent (`request()` / `release()`), and the only observable outputs are `held`\n * (whether a sentinel is actually held) and `error`.\n *\n * The OS releases the lock whenever the page stops being visible (tab hidden,\n * window minimized). To honor the declarative intent (\"keep awake *while* active\"),\n * the Core keeps the desired flag (`_active`) and re-acquires the lock on the next\n * `visibilitychange` back to visible. So `_active` (desired) and `held` (actual)\n * diverge across an auto-release — and only `held` is published, because desired\n * does not change when the OS drops the lock.\n *\n * Never-throw: `request()` never rejects (a failure surfaces via `error`), and an\n * unsupported environment is a silent no-op (`held` stays false), consistent with\n * the other @wcstack sensors.\n */\nexport class WakeLockCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"held\", event: \"wcs-wakelock:held-changed\" },\n { name: \"error\", event: \"wcs-wakelock:error\" },\n // Serializable failure taxonomy (stable code / phase / recoverable), or null.\n // Additive bindable output derived from the raw `error` (not-allowed / wakelock-error);\n // the existing `error` property/event are unchanged. Fires\n // wcs-wakelock:error-info-changed. No lane — the wake lock is a pure sink (request /\n // release do not compete).\n { name: \"errorInfo\", event: \"wcs-wakelock:error-info-changed\" },\n ],\n commands: [\n { name: \"request\", async: true },\n { name: \"release\" },\n ],\n };\n\n private _target: EventTarget;\n private _type: WakeLockKind;\n\n // `_active` is the desired intent (input); `_held` is whether a sentinel is\n // actually held right now (output). They diverge across an OS auto-release.\n private _active: boolean = false;\n private _held: boolean = false;\n private _error: Error | null = null;\n private _errorInfo: WcsIoErrorInfo | null = null;\n private _sentinel: WakeLockSentinelLike | null = null;\n\n // Bumped on every release()/new acquire so an in-flight async request() that\n // resolves late can detect it was superseded and drop its sentinel (mirrors the\n // generation guards in GeolocationCore).\n private _gen: number = 0;\n // True while an `_acquire()` is awaiting `navigator.wakeLock.request()`. The\n // `_held` flag is only set *after* that await resolves, so it cannot guard\n // against concurrent entry: two rapid visibilitychange events (or a Shell toggle\n // overlapping an in-flight request) would both pass `!this._held` and each call\n // `request()`. This in-flight flag closes that window — a re-entrant acquire is a\n // no-op. The `_gen` guard still ensures the *final* state is correct; this just\n // avoids the redundant `request()` call (and its duplicate error path on a denied\n // environment).\n private _acquiring: boolean = false;\n private _visibilityBound: boolean = false;\n\n // SSR (§3.8): a pure sink has no asynchronous probe to await — `request()` is\n // fire-and-forget and meaningless server-side — so readiness is immediate.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget, type: WakeLockKind = \"screen\") {\n super();\n this._target = target ?? this;\n this._type = type;\n }\n\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // Lifecycle (§3.5). The wake lock is command-driven (request / release) with no\n // ambient subscription to establish on connect, so observe() is an idempotent\n // no-op that resolves once ready; dispose() (below) tears down the visibility\n // listener, releases any held sentinel, and bumps _gen via release().\n observe(): Promise<void> {\n return this._ready;\n }\n\n get held(): boolean {\n return this._held;\n }\n\n get error(): Error | null {\n return this._error;\n }\n\n /**\n * The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /\n * `recoverable`), or null. Additive wc-bindable property (event\n * `wcs-wakelock: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 /** The desired intent. Read-only reflection; not a wc-bindable property (it does\n * not change on an OS auto-release, so there is nothing to observe). */\n get active(): boolean {\n return this._active;\n }\n\n get type(): WakeLockKind {\n return this._type;\n }\n\n set type(value: WakeLockKind) {\n // Currently effectively a no-op: \"screen\" is the only standardized lock type,\n // so `WakeLockKind` is a single value and this setter never observes a real\n // change. Kept as a forward-compatible seam for when the spec adds lock types.\n //\n // Takes effect on the next acquire. Changing the type mid-hold deliberately does\n // NOT re-acquire — the live sentinel is left as is, so a type change applies only\n // from the following acquire. If multiple lock types are ever added this becomes\n // an observable behavior gap (a held lock keeps its old type until release/re-\n // acquire) and must be re-examined — likely re-acquire here when held.\n this._type = value;\n }\n\n // --- State setters with event dispatch ---\n\n private _setHeld(held: boolean): void {\n if (this._held === held) return;\n this._held = held;\n this._target.dispatchEvent(new CustomEvent(\"wcs-wakelock:held-changed\", {\n detail: held,\n bubbles: true,\n }));\n }\n\n private _setError(error: Error | null): void {\n // Value guard, not just reference: a denied request rejects with a *fresh*\n // Error on every visibility-driven retry, so a reference compare would let a\n // permanently-denied environment re-dispatch the same failure on each\n // hidden→visible toggle. Compare name+message too. Transitions through null (a\n // success clears the error) always re-fire, so a genuinely new failure is seen.\n if (this._sameError(this._error, error)) return;\n this._error = error;\n // Keep the additive `errorInfo` taxonomy in sync with `error`: derive from the raw\n // Error (or null on clear). Fires before the `error` event so an observer binding\n // both sees the classification first, mirroring the io-node family.\n this._commitErrorInfo(error === null ? null : deriveWakeLockErrorInfo(error));\n this._target.dispatchEvent(new CustomEvent(\"wcs-wakelock:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n // Called only from _setError (which already same-value-guards on the error name +\n // message via _sameError), so errorInfo transitions exactly when error does — no\n // separate guard needed here.\n private _commitErrorInfo(info: WcsIoErrorInfo | null): void {\n this._errorInfo = info;\n this._target.dispatchEvent(new CustomEvent(\"wcs-wakelock:error-info-changed\", {\n detail: info,\n bubbles: true,\n }));\n }\n\n private _sameError(a: Error | null, b: Error | null): boolean {\n if (a === b) return true;\n if (a !== null && b !== null) return a.name === b.name && a.message === b.message;\n return false;\n }\n\n // --- Public API ---\n\n /**\n * Mark the lock as desired and acquire it. Idempotent while already held. If the\n * API is unavailable or the page is currently hidden, the desired flag is still\n * set (so the lock is acquired on the next return to visibility) but nothing is\n * acquired now. Never rejects — a request failure surfaces via `error`.\n */\n async request(): Promise<void> {\n this._active = true;\n this._ensureVisibilityListener();\n await this._acquire();\n }\n\n /** Mark the lock as no longer desired and release any held sentinel. */\n release(): void {\n this._active = false;\n // Invalidate any in-flight acquire so a late-resolving request() drops its\n // sentinel instead of leaving a lock held after release.\n this._gen++;\n const sentinel = this._sentinel;\n if (sentinel) {\n this._sentinel = null;\n sentinel.removeEventListener(\"release\", this._onRelease);\n void sentinel.release().catch(() => { /* never-throw */ });\n }\n this._setHeld(false);\n }\n\n /**\n * Full teardown: remove the visibility listener and release any held sentinel.\n * Call from the Shell's `disconnectedCallback`.\n *\n * Semantics: this is a terminal teardown, not a pause. After `dispose()` the Core\n * is meant to be discarded — there is no re-arm step, and the visibility listener\n * is gone, so an OS auto-release will no longer be followed by a re-acquire. A\n * later `request()` would still work in isolation (it re-attaches the listener via\n * `_ensureVisibilityListener`), but reusing a disposed Core is not an intended path;\n * the Shell always constructs a fresh Core per element instead.\n */\n dispose(): void {\n if (this._visibilityBound) {\n // §4 deviation: document-scoped Web API; no element-free alternative — the\n // Page Visibility `visibilitychange` event is only dispatched on `document`.\n document.removeEventListener(\"visibilitychange\", this._onVisibilityChange);\n this._visibilityBound = false;\n }\n this.release();\n }\n\n // --- Internal ---\n\n private async _acquire(): Promise<void> {\n if (this._held) return; // idempotent: already holding a sentinel\n if (this._acquiring) return; // an acquire is already in flight — don't double-request\n const wakeLock = this._wakeLock();\n if (!wakeLock) return; // unsupported — stay active, never acquire (silent no-op)\n if (!this._isVisible()) return; // hidden — defer to the next visibilitychange\n const gen = ++this._gen;\n this._acquiring = true;\n // Flag management is centralized in `finally` and the coalesced retry is invoked\n // exactly once, AFTER the try/catch/finally settles. This keeps the reject and\n // resolve paths symmetric: neither calls `_retryIfStillDesired()` from inside the\n // try/catch (which would let `finally` re-clear the `_acquiring=true` the retry's\n // synchronous re-entry just set, reopening the double-request window). `superseded`\n // records that a newer release()/request() bumped `_gen` mid-flight so its still-\n // live intent — blocked by the in-flight guard at the time — gets one retry here.\n // NOTE: no early `return` inside the try/catch below — every branch must fall\n // through to the post-`finally` retry. A `return` from inside the try would run\n // `finally` and then exit the function, skipping the `if (superseded)` retry.\n let superseded = false;\n let sentinel: WakeLockSentinelLike | null = null;\n let failed: Error | null = null;\n try {\n sentinel = await wakeLock.request(this._type);\n } catch (e) {\n if (gen !== this._gen) {\n // Superseded while awaiting — drop this stale failure (do not clobber the\n // newer state) and let the post-finally retry honor the live intent.\n superseded = true;\n } else {\n failed = this._normalizeError(e);\n }\n } finally {\n // The sole owner of the flag clears it here — on every exit path. A concurrent\n // re-entrant `_acquire()` was a no-op at the `_acquiring` guard, so it never owns\n // the flag; a superseding release()/acquire only bumps `_gen` and does not start\n // its own in-flight cycle until this clears the flag. Because this runs before\n // the retry below, the retry's `_acquiring=true` is never clobbered.\n this._acquiring = false;\n }\n\n if (sentinel !== null && gen !== this._gen) {\n // release() (or a newer acquire) ran while we awaited — this sentinel is\n // unwanted; drop it so no lock lingers, and retry the newer intent below.\n void sentinel.release().catch(() => { /* never-throw */ });\n superseded = true;\n } else if (sentinel !== null) {\n this._sentinel = sentinel;\n sentinel.addEventListener(\"release\", this._onRelease);\n this._setError(null);\n this._setHeld(true);\n } else if (failed !== null) {\n // A live (non-superseded) failure: surface it. Never retried — the intent is\n // honored but the environment denied it, so looping would spin.\n this._setError(failed);\n this._setHeld(false);\n }\n\n // Coalesced retry: at most one re-attempt per supersession, after the flag is\n // clear. The `_acquiring` guard inside still protects any concurrent re-entry that\n // overlaps THIS retry's own in-flight window (reject- and resolve-retry alike).\n if (superseded) this._retryIfStillDesired();\n }\n\n /**\n * Re-attempt an acquire after an in-flight one was *superseded* (its generation no\n * longer matches), but only if the lock is still desired, not already held, and the\n * page is visible. This recovers a request() that was coalesced away by the\n * in-flight `_acquiring` guard: during a release()→request() overlap, the second\n * request() bumps `_gen` and is a no-op at the guard, so without this retry its\n * still-live intent would be lost until the next visibilitychange or manual call.\n *\n * Bounded — cannot loop forever: a retry runs ONLY on supersession, and a\n * supersession requires an external release()/request() to bump `_gen` mid-flight.\n * A retry's own `_acquire()`, if it is itself not superseded, terminates by either\n * acquiring (held=true) or recording the live failure (held=false, error set) —\n * neither path retries. So a denied environment that keeps rejecting does not\n * recurse; the retry chain length is bounded by the number of external overlaps.\n */\n private _retryIfStillDesired(): void {\n if (this._active && !this._held && this._isVisible()) {\n void this._acquire();\n }\n }\n\n // Fired for an OS release of a held sentinel — which the spec allows for several\n // reasons, NOT only a visibility change: tab hidden / window minimized, but also\n // battery-low, power-saver mode, etc. while the page stays visible. We reflect\n // held=false, then (lease renewal) re-acquire immediately IF the page is still\n // visible and the lock is still desired — because a visible-context release emits no\n // `visibilitychange`, so the visibilitychange listener (②) would never fire and the\n // lock would stay stuck at desired=true / held=false. The hidden case is the no-op\n // here: re-acquire is gated on `_isVisible()`, so a hide-driven release defers to ②\n // (re-acquire on the return to visibility), avoiding a release→acquire loop while\n // hidden.\n private _onRelease = (): void => {\n // The `if (this._sentinel)` false branch is defensive and unreachable in practice:\n // this listener is only ever attached to the live `_sentinel`, and the only paths\n // that null `_sentinel` (this handler itself, and release()) remove this listener\n // in the same step — so the listener and a non-null `_sentinel` are coupled and\n // this never fires with `_sentinel === null`. Guarded anyway in case a host\n // dispatches a spurious second \"release\". (c8 ignore the unhittable else.)\n /* c8 ignore next */\n if (this._sentinel) {\n this._sentinel.removeEventListener(\"release\", this._onRelease);\n this._sentinel = null;\n }\n this._setHeld(false);\n this._reacquireAfterRelease();\n };\n\n /**\n * Lease renewal after an OS release while the page is still visible. Honors the\n * \"keep awake *while* active\" promise for releases that do NOT coincide with a\n * visibility change (battery-low / power-saver), which otherwise leave the lock\n * stuck at desired=true / held=false until the next hide→show cycle.\n *\n * Bounded on failure: this only runs from `_onRelease`, which only fires when a\n * sentinel was genuinely acquired and then released. A re-acquire that FAILS takes\n * `_acquire()`'s live-failure path (error recorded, held=false) and attaches no\n * listener, so it cannot re-enter `_onRelease` — a denied environment records the\n * error once and stops. This is the dominant real path: per the Wake Lock spec a\n * re-request under battery-low / power-saver is rejected (`NotAllowedError`), so the\n * renewal terminates there.\n *\n * The one path NOT bounded by a counter is a pathological host that keeps GRANTING\n * the re-request and then immediately auto-releasing it (grant→release reflux). Each\n * iteration yields to the event loop and consumes a real OS grant, so it is not a\n * tight/synchronous loop, but it would churn request() calls. We deliberately do NOT\n * add a debounce or renewal cap: that reflux is not documented browser behavior\n * (real browsers reject, not grant-then-revoke), and the extra timing state would\n * complicate the pure-sink design to defend a case that does not occur in practice.\n *\n * The `_isVisible()` / `!_acquiring` guards (doubled by `_acquire()`'s own in-flight\n * and held guards) prevent re-entry during an in-flight acquire and while hidden.\n */\n private _reacquireAfterRelease(): void {\n if (this._active && this._isVisible() && !this._acquiring) {\n void this._acquire();\n }\n }\n\n // ② Re-acquire when the page becomes visible again while the lock is still\n // desired but was auto-released. This is what makes `active` a durable intent.\n private _onVisibilityChange = (): void => {\n if (this._isVisible() && this._active && !this._held) {\n void this._acquire();\n }\n };\n\n private _ensureVisibilityListener(): void {\n if (this._visibilityBound) return;\n // §4 deviation: document-scoped Web API; no element-free alternative — the\n // Page Visibility `visibilitychange` event is only dispatched on `document`.\n document.addEventListener(\"visibilitychange\", this._onVisibilityChange);\n this._visibilityBound = true;\n }\n\n private _wakeLock(): WakeLockLike | null {\n return (navigator as Navigator & { wakeLock?: WakeLockLike }).wakeLock ?? null;\n }\n\n private _isVisible(): boolean {\n // §4 deviation: document-scoped Web API; no element-free alternative —\n // `visibilityState` lives on `document`, not on any element.\n return document.visibilityState === \"visible\";\n }\n\n private _normalizeError(e: unknown): Error {\n return e instanceof Error ? e : new Error(String(e));\n }\n}\n","import { IWcBindable, WakeLockKind } from \"../types.js\";\nimport { WakeLockCore } from \"../core/WakeLockCore.js\";\nimport { WcsIoErrorInfo } from \"../core/platformCapability.js\";\n\n/**\n * `<wcs-wakelock>` — declarative Screen Wake Lock.\n *\n * The first @wcstack tag that is a pure *sink*: every other sensor is an\n * element→state producer, but the wake lock is state→element. The headline\n * binding is `active@isPlaying` — hold the screen awake while a bound boolean is\n * true. `active` is the single input knob (a mirrored attribute); `held` and\n * `error` are the observable outputs.\n *\n * The OS auto-releases the lock when the page is hidden; the Core re-acquires it\n * on the next return to visibility while `active` is still set, so the binding\n * means \"keep awake *while* active\", not just \"acquire once\".\n */\nexport class WcsWakeLock extends HTMLElement {\n // SSR contract (§4.1/@wcstack/server): the renderer awaits elements declaring\n // `hasConnectedCallbackPromise = true` before snapshotting. The wake lock has no\n // connect-time async probe to await (acquire is fire-and-forget and meaningless\n // server-side), so `connectedCallbackPromise` is backed by the Core's no-op\n // `observe()`, which resolves immediately. The flag is still declared `true` so\n // the renderer reads it via `ctor.hasConnectedCallbackPromise` and the Shell\n // participates uniformly in the SSR await protocol.\n static hasConnectedCallbackPromise = true;\n // `active` drives request/release; `type` propagates to the Core's next acquire.\n // `manual` is intentionally excluded: it is a connect-time policy (\"don't auto-\n // acquire on connect\"), not a live switch.\n static observedAttributes = [\"active\", \"type\"];\n\n static wcBindable: IWcBindable = {\n ...WakeLockCore.wcBindable,\n // Settable surface. `active` is the declarative intent; `type` selects the lock\n // kind; `manual` opts out of auto-acquire on connect. The request / release\n // commands are inherited from the Core via the spread above.\n inputs: [\n { name: \"active\", attribute: \"active\" },\n { name: \"type\", attribute: \"type\" },\n { name: \"manual\", attribute: \"manual\" },\n ],\n // Core の commands をそのまま継承(単一情報源)。<wcs-intersect>/<wcs-sse> と同型。\n // spread でも継承されるが、Core に command 追加時の追従漏れを防ぐため明示参照する。\n commands: WakeLockCore.wcBindable.commands,\n };\n\n private _core: WakeLockCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new WakeLockCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-wakelock:held-changed\": (d) => ({ held: d === true }),\n \"wcs-wakelock:error\": (d) => ({ error: d != null }),\n });\n }\n\n // SSR (§4.1): the renderer awaits this before snapshotting. Backed by the Core's\n // observe() (a no-op resolving immediately for this command-driven sink).\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\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 // The ternary expression-statement form trips ESLint no-unused-expressions.\n if (on) { states.add(name); } else { states.delete(name); }\n } catch { /* never-throw */ }\n if (debug) this.toggleAttribute(`data-wcs-state-${name}`, on);\n }\n });\n }\n }\n\n // --- Attribute accessors ---\n\n get active(): boolean {\n // Reflects the *attribute*, not the Core's desired intent (`_core.active`). These\n // can diverge: invoking the `request` / `release` commands directly (e.g. via a\n // command-token binding) flips the Core's desired flag without touching the\n // attribute, so `el.active` may read false while `el.held` is true (or vice\n // versa). The attribute is the declarative input surface; the commands are an\n // imperative side door. Bind via `active@...` for a single source of truth.\n return this.hasAttribute(\"active\");\n }\n\n set active(value: boolean) {\n if (value) {\n this.setAttribute(\"active\", \"\");\n } else {\n this.removeAttribute(\"active\");\n }\n }\n\n get type(): WakeLockKind {\n // Only \"screen\" is standardized; an absent/empty attribute defaults to it.\n return (this.getAttribute(\"type\") as WakeLockKind) || \"screen\";\n }\n\n set type(value: WakeLockKind) {\n this.setAttribute(\"type\", value);\n }\n\n get manual(): boolean {\n return this.hasAttribute(\"manual\");\n }\n\n set manual(value: boolean) {\n if (value) {\n this.setAttribute(\"manual\", \"\");\n } else {\n this.removeAttribute(\"manual\");\n }\n }\n\n // --- Core delegated getters ---\n\n get held(): boolean {\n return this._core.held;\n }\n\n get error(): Error | null {\n return this._core.error;\n }\n\n get errorInfo(): WcsIoErrorInfo | null {\n return this._core.errorInfo;\n }\n\n // --- Commands ---\n\n /** Acquire (and keep) the wake lock. Never rejects — see the `error` property. */\n request(): Promise<void> {\n return this._core.request();\n }\n\n /** Release the wake lock and stop re-acquiring it. */\n release(): void {\n this._core.release();\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n // Headless resource: no layout box (mirrors the @wcstack sensor convention).\n this.style.display = \"none\";\n // Propagate the requested lock type to the Core. Currently a no-op in effect:\n // \"screen\" is the only standardized type, so `type` is always \"screen\". Wired\n // up as a forward-compatible seam (observedAttributes + setter + this line) for\n // when the spec adds lock types; until then it carries a constant.\n this._core.type = this.type;\n // Establish monitoring (§3.5) and expose readiness for SSR (§4.1). observe()\n // is a no-op that resolves immediately for this command-driven sink.\n this._connectedCallbackPromise = this._core.observe();\n if (!this.manual && this.active) {\n void this._core.request();\n }\n }\n\n disconnectedCallback(): void {\n this._core.dispose();\n }\n\n attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void {\n if (oldValue === newValue) return;\n // Ignore changes applied before connect (e.g. createElement + setAttribute);\n // connectedCallback applies the initial state. Acquiring a lock for a detached\n // element would be wrong.\n if (!this.isConnected) return;\n if (name === \"type\") {\n this._core.type = this.type;\n return;\n }\n // name === \"active\": a live toggle always drives request/release. `manual` only\n // gates the connect-time auto-acquire, not an explicit author toggle.\n if (this.active) {\n void this._core.request();\n } else {\n this._core.release();\n }\n }\n}\n","import { WcsWakeLock } from \"./components/WakeLock.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.wakelock)) {\n customElements.define(config.tagNames.wakelock, WcsWakeLock);\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapWakeLock(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,QAAQ,EAAE,cAAc;AACzB,KAAA;CACF;AAED,SAAS,UAAU,CAAI,GAAM,EAAA;AAC3B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAAG;AACvD,IAAA,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;IAClB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;AAClC,QAAA,UAAU,CAAE,GAA+B,CAAC,GAAG,CAAC,CAAC;IACnD;AACA,IAAA,OAAO,GAAG;AACZ;AAEA,SAAS,SAAS,CAAI,GAAM,EAAA;AAC1B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAAG;IACvD,MAAM,KAAK,GAA4B,EAAE;IACzC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAClC,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAAE,GAA+B,CAAC,GAAG,CAAC,CAAC;IAC/D;AACA,IAAA,OAAO,KAAU;AACnB;AAEA,IAAI,YAAY,GAAmB,IAAI;AAEvC;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,MAAM,GAAY,OAAkB;SAEjC,SAAS,GAAA;IACvB,IAAI,CAAC,YAAY,EAAE;QACjB,YAAY,GAAG,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAC/C;AACA,IAAA,OAAO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AAU,CAAC;IACvB;AACA,IAAA,kBAAkB,EAAE;AACtB;;;;"}
@@ -1,2 +1,2 @@
1
- const e={tagNames:{wakelock:"wcs-wakelock"}};function t(e){if(null===e||"object"!=typeof e)return e;Object.freeze(e);for(const s of Object.keys(e))t(e[s]);return e}function s(e){if(null===e||"object"!=typeof e)return e;const t={};for(const i of Object.keys(e))t[i]=s(e[i]);return t}let i=null;const r=e;function n(){return i||(i=t(s(e))),i}class a extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"held",event:"wcs-wakelock:held-changed"},{name:"error",event:"wcs-wakelock:error"}],commands:[{name:"request",async:!0},{name:"release"}]};_target;_type;_active=!1;_held=!1;_error=null;_sentinel=null;_gen=0;_acquiring=!1;_visibilityBound=!1;_ready=Promise.resolve();constructor(e,t="screen"){super(),this._target=e??this,this._type=t}get ready(){return this._ready}observe(){return this._ready}get held(){return this._held}get error(){return this._error}get active(){return this._active}get type(){return this._type}set type(e){this._type=e}_setHeld(e){this._held!==e&&(this._held=e,this._target.dispatchEvent(new CustomEvent("wcs-wakelock:held-changed",{detail:e,bubbles:!0})))}_setError(e){this._sameError(this._error,e)||(this._error=e,this._target.dispatchEvent(new CustomEvent("wcs-wakelock:error",{detail:e,bubbles:!0})))}_sameError(e,t){return e===t||null!==e&&null!==t&&(e.name===t.name&&e.message===t.message)}async request(){this._active=!0,this._ensureVisibilityListener(),await this._acquire()}release(){this._active=!1,this._gen++;const e=this._sentinel;e&&(this._sentinel=null,e.removeEventListener("release",this._onRelease),e.release().catch(()=>{})),this._setHeld(!1)}dispose(){this._visibilityBound&&(document.removeEventListener("visibilitychange",this._onVisibilityChange),this._visibilityBound=!1),this.release()}async _acquire(){if(this._held)return;if(this._acquiring)return;const e=this._wakeLock();if(!e)return;if(!this._isVisible())return;const t=++this._gen;this._acquiring=!0;let s=!1,i=null,r=null;try{i=await e.request(this._type)}catch(e){t!==this._gen?s=!0:r=this._normalizeError(e)}finally{this._acquiring=!1}null!==i&&t!==this._gen?(i.release().catch(()=>{}),s=!0):null!==i?(this._sentinel=i,i.addEventListener("release",this._onRelease),this._setError(null),this._setHeld(!0)):null!==r&&(this._setError(r),this._setHeld(!1)),s&&this._retryIfStillDesired()}_retryIfStillDesired(){this._active&&!this._held&&this._isVisible()&&this._acquire()}_onRelease=()=>{this._sentinel&&(this._sentinel.removeEventListener("release",this._onRelease),this._sentinel=null),this._setHeld(!1),this._reacquireAfterRelease()};_reacquireAfterRelease(){this._active&&this._isVisible()&&!this._acquiring&&this._acquire()}_onVisibilityChange=()=>{this._isVisible()&&this._active&&!this._held&&this._acquire()};_ensureVisibilityListener(){this._visibilityBound||(document.addEventListener("visibilitychange",this._onVisibilityChange),this._visibilityBound=!0)}_wakeLock(){return navigator.wakeLock??null}_isVisible(){return"visible"===document.visibilityState}_normalizeError(e){return e instanceof Error?e:new Error(String(e))}}class l extends HTMLElement{static hasConnectedCallbackPromise=!0;static observedAttributes=["active","type"];static wcBindable={...a.wcBindable,inputs:[{name:"active",attribute:"active"},{name:"type",attribute:"type"},{name:"manual",attribute:"manual"}],commands:a.wcBindable.commands};_core;_connectedCallbackPromise=Promise.resolve();_internals=null;constructor(){super(),this._core=new a(this),this._internals=this._initInternals(),this._wireStates({"wcs-wakelock:held-changed":e=>({held:!0===e}),"wcs-wakelock:error":e=>({error:null!=e})})}get connectedCallbackPromise(){return this._connectedCallbackPromise}get debugStates(){return this._internals?[...this._internals.states]:[]}_initInternals(){try{if("function"!=typeof this.attachInternals)return null;const e=this.attachInternals();return e.states.add("wcs-probe"),e.states.delete("wcs-probe"),e}catch{return null}}_wireStates(e){if(null===this._internals)return;const t=this._internals.states;for(const[s,i]of Object.entries(e))this.addEventListener(s,e=>{const s=this.hasAttribute("debug-states");for(const[r,n]of Object.entries(i(e.detail))){try{n?t.add(r):t.delete(r)}catch{}s&&this.toggleAttribute(`data-wcs-state-${r}`,n)}})}get active(){return this.hasAttribute("active")}set active(e){e?this.setAttribute("active",""):this.removeAttribute("active")}get type(){return this.getAttribute("type")||"screen"}set type(e){this.setAttribute("type",e)}get manual(){return this.hasAttribute("manual")}set manual(e){e?this.setAttribute("manual",""):this.removeAttribute("manual")}get held(){return this._core.held}get error(){return this._core.error}request(){return this._core.request()}release(){this._core.release()}connectedCallback(){this.style.display="none",this._core.type=this.type,this._connectedCallbackPromise=this._core.observe(),!this.manual&&this.active&&this._core.request()}disconnectedCallback(){this._core.dispose()}attributeChangedCallback(e,t,s){t!==s&&this.isConnected&&("type"!==e?this.active?this._core.request():this._core.release():this._core.type=this.type)}}function c(t){var s;t&&((s=t).tagNames&&Object.assign(e.tagNames,s.tagNames),i=null),customElements.get(r.tagNames.wakelock)||customElements.define(r.tagNames.wakelock,l)}export{a as WakeLockCore,l as WcsWakeLock,c as bootstrapWakeLock,n as getConfig};
1
+ const e={tagNames:{wakelock:"wcs-wakelock"}};function t(e){if(null===e||"object"!=typeof e)return e;Object.freeze(e);for(const s of Object.keys(e))t(e[s]);return e}function s(e){if(null===e||"object"!=typeof e)return e;const t={};for(const r of Object.keys(e))t[r]=s(e[r]);return t}let r=null;const i=e;function n(){return r||(r=t(s(e))),r}const a={NotAllowed:"not-allowed",WakeLockError:"wakelock-error"};class l extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"held",event:"wcs-wakelock:held-changed"},{name:"error",event:"wcs-wakelock:error"},{name:"errorInfo",event:"wcs-wakelock:error-info-changed"}],commands:[{name:"request",async:!0},{name:"release"}]};_target;_type;_active=!1;_held=!1;_error=null;_errorInfo=null;_sentinel=null;_gen=0;_acquiring=!1;_visibilityBound=!1;_ready=Promise.resolve();constructor(e,t="screen"){super(),this._target=e??this,this._type=t}get ready(){return this._ready}observe(){return this._ready}get held(){return this._held}get error(){return this._error}get errorInfo(){return this._errorInfo}get active(){return this._active}get type(){return this._type}set type(e){this._type=e}_setHeld(e){this._held!==e&&(this._held=e,this._target.dispatchEvent(new CustomEvent("wcs-wakelock:held-changed",{detail:e,bubbles:!0})))}_setError(e){this._sameError(this._error,e)||(this._error=e,this._commitErrorInfo(null===e?null:function(e){return"NotAllowedError"===e.name?{code:a.NotAllowed,phase:"start",recoverable:!1,message:e.message}:{code:a.WakeLockError,phase:"execute",recoverable:!1,message:e.message}}(e)),this._target.dispatchEvent(new CustomEvent("wcs-wakelock:error",{detail:e,bubbles:!0})))}_commitErrorInfo(e){this._errorInfo=e,this._target.dispatchEvent(new CustomEvent("wcs-wakelock:error-info-changed",{detail:e,bubbles:!0}))}_sameError(e,t){return e===t||null!==e&&null!==t&&(e.name===t.name&&e.message===t.message)}async request(){this._active=!0,this._ensureVisibilityListener(),await this._acquire()}release(){this._active=!1,this._gen++;const e=this._sentinel;e&&(this._sentinel=null,e.removeEventListener("release",this._onRelease),e.release().catch(()=>{})),this._setHeld(!1)}dispose(){this._visibilityBound&&(document.removeEventListener("visibilitychange",this._onVisibilityChange),this._visibilityBound=!1),this.release()}async _acquire(){if(this._held)return;if(this._acquiring)return;const e=this._wakeLock();if(!e)return;if(!this._isVisible())return;const t=++this._gen;this._acquiring=!0;let s=!1,r=null,i=null;try{r=await e.request(this._type)}catch(e){t!==this._gen?s=!0:i=this._normalizeError(e)}finally{this._acquiring=!1}null!==r&&t!==this._gen?(r.release().catch(()=>{}),s=!0):null!==r?(this._sentinel=r,r.addEventListener("release",this._onRelease),this._setError(null),this._setHeld(!0)):null!==i&&(this._setError(i),this._setHeld(!1)),s&&this._retryIfStillDesired()}_retryIfStillDesired(){this._active&&!this._held&&this._isVisible()&&this._acquire()}_onRelease=()=>{this._sentinel&&(this._sentinel.removeEventListener("release",this._onRelease),this._sentinel=null),this._setHeld(!1),this._reacquireAfterRelease()};_reacquireAfterRelease(){this._active&&this._isVisible()&&!this._acquiring&&this._acquire()}_onVisibilityChange=()=>{this._isVisible()&&this._active&&!this._held&&this._acquire()};_ensureVisibilityListener(){this._visibilityBound||(document.addEventListener("visibilitychange",this._onVisibilityChange),this._visibilityBound=!0)}_wakeLock(){return navigator.wakeLock??null}_isVisible(){return"visible"===document.visibilityState}_normalizeError(e){return e instanceof Error?e:new Error(String(e))}}class o extends HTMLElement{static hasConnectedCallbackPromise=!0;static observedAttributes=["active","type"];static wcBindable={...l.wcBindable,inputs:[{name:"active",attribute:"active"},{name:"type",attribute:"type"},{name:"manual",attribute:"manual"}],commands:l.wcBindable.commands};_core;_connectedCallbackPromise=Promise.resolve();_internals=null;constructor(){super(),this._core=new l(this),this._internals=this._initInternals(),this._wireStates({"wcs-wakelock:held-changed":e=>({held:!0===e}),"wcs-wakelock:error":e=>({error:null!=e})})}get connectedCallbackPromise(){return this._connectedCallbackPromise}get debugStates(){return this._internals?[...this._internals.states]:[]}_initInternals(){try{if("function"!=typeof this.attachInternals)return null;const e=this.attachInternals();return e.states.add("wcs-probe"),e.states.delete("wcs-probe"),e}catch{return null}}_wireStates(e){if(null===this._internals)return;const t=this._internals.states;for(const[s,r]of Object.entries(e))this.addEventListener(s,e=>{const s=this.hasAttribute("debug-states");for(const[i,n]of Object.entries(r(e.detail))){try{n?t.add(i):t.delete(i)}catch{}s&&this.toggleAttribute(`data-wcs-state-${i}`,n)}})}get active(){return this.hasAttribute("active")}set active(e){e?this.setAttribute("active",""):this.removeAttribute("active")}get type(){return this.getAttribute("type")||"screen"}set type(e){this.setAttribute("type",e)}get manual(){return this.hasAttribute("manual")}set manual(e){e?this.setAttribute("manual",""):this.removeAttribute("manual")}get held(){return this._core.held}get error(){return this._core.error}get errorInfo(){return this._core.errorInfo}request(){return this._core.request()}release(){this._core.release()}connectedCallback(){this.style.display="none",this._core.type=this.type,this._connectedCallbackPromise=this._core.observe(),!this.manual&&this.active&&this._core.request()}disconnectedCallback(){this._core.dispose()}attributeChangedCallback(e,t,s){t!==s&&this.isConnected&&("type"!==e?this.active?this._core.request():this._core.release():this._core.type=this.type)}}function c(t){var s;t&&((s=t).tagNames&&Object.assign(e.tagNames,s.tagNames),r=null),customElements.get(i.tagNames.wakelock)||customElements.define(i.tagNames.wakelock,o)}export{a as WCS_WAKELOCK_ERROR_CODE,l as WakeLockCore,o as WcsWakeLock,c as bootstrapWakeLock,n 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/WakeLockCore.ts","../src/components/WakeLock.ts","../src/bootstrapWakeLock.ts","../src/registerComponents.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n wakelock: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n wakelock: \"wcs-wakelock\",\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\n// Note: this is the live, mutable internal config. It is not part of the public\n// package exports (see exports.ts) — only `getConfig()` (a frozen snapshot) is\n// surfaced. `setConfig()` is applied internally via `bootstrapWakeLock()` and\n// is not re-exported from the package root, though a deep path import\n// (`.../src/config.js`) can still reach and mutate it. Accepted as-is for\n// cross-package consistency: every @wcstack package follows this same shape.\n// Use `getConfig()` for a frozen, safe read.\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, WakeLockKind } from \"../types.js\";\n\n/**\n * Minimal structural views of the Screen Wake Lock API. Declared locally (rather\n * than relying on `lib.dom`'s experimental `WakeLock` types) so the package type-\n * checks the same across TypeScript lib versions, and so a runtime where\n * `navigator.wakeLock` is absent is just a value check, never a type error.\n */\ninterface WakeLockSentinelLike extends EventTarget {\n readonly released: boolean;\n readonly type: string;\n release(): Promise<void>;\n}\ninterface WakeLockLike {\n request(type?: string): Promise<WakeLockSentinelLike>;\n}\n\n/**\n * Headless screen-wake-lock primitive — a thin, framework-agnostic wrapper around\n * the Screen Wake Lock API exposed through the wc-bindable protocol.\n *\n * Unlike the other @wcstack sensors (geolocation / intersection), the wake lock is\n * a pure *sink*: nothing is read from the device. A bound state drives the desired\n * intent (`request()` / `release()`), and the only observable outputs are `held`\n * (whether a sentinel is actually held) and `error`.\n *\n * The OS releases the lock whenever the page stops being visible (tab hidden,\n * window minimized). To honor the declarative intent (\"keep awake *while* active\"),\n * the Core keeps the desired flag (`_active`) and re-acquires the lock on the next\n * `visibilitychange` back to visible. So `_active` (desired) and `held` (actual)\n * diverge across an auto-release — and only `held` is published, because desired\n * does not change when the OS drops the lock.\n *\n * Never-throw: `request()` never rejects (a failure surfaces via `error`), and an\n * unsupported environment is a silent no-op (`held` stays false), consistent with\n * the other @wcstack sensors.\n */\nexport class WakeLockCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"held\", event: \"wcs-wakelock:held-changed\" },\n { name: \"error\", event: \"wcs-wakelock:error\" },\n ],\n commands: [\n { name: \"request\", async: true },\n { name: \"release\" },\n ],\n };\n\n private _target: EventTarget;\n private _type: WakeLockKind;\n\n // `_active` is the desired intent (input); `_held` is whether a sentinel is\n // actually held right now (output). They diverge across an OS auto-release.\n private _active: boolean = false;\n private _held: boolean = false;\n private _error: Error | null = null;\n private _sentinel: WakeLockSentinelLike | null = null;\n\n // Bumped on every release()/new acquire so an in-flight async request() that\n // resolves late can detect it was superseded and drop its sentinel (mirrors the\n // generation guards in GeolocationCore).\n private _gen: number = 0;\n // True while an `_acquire()` is awaiting `navigator.wakeLock.request()`. The\n // `_held` flag is only set *after* that await resolves, so it cannot guard\n // against concurrent entry: two rapid visibilitychange events (or a Shell toggle\n // overlapping an in-flight request) would both pass `!this._held` and each call\n // `request()`. This in-flight flag closes that window — a re-entrant acquire is a\n // no-op. The `_gen` guard still ensures the *final* state is correct; this just\n // avoids the redundant `request()` call (and its duplicate error path on a denied\n // environment).\n private _acquiring: boolean = false;\n private _visibilityBound: boolean = false;\n\n // SSR (§3.8): a pure sink has no asynchronous probe to await — `request()` is\n // fire-and-forget and meaningless server-side — so readiness is immediate.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget, type: WakeLockKind = \"screen\") {\n super();\n this._target = target ?? this;\n this._type = type;\n }\n\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // Lifecycle (§3.5). The wake lock is command-driven (request / release) with no\n // ambient subscription to establish on connect, so observe() is an idempotent\n // no-op that resolves once ready; dispose() (below) tears down the visibility\n // listener, releases any held sentinel, and bumps _gen via release().\n observe(): Promise<void> {\n return this._ready;\n }\n\n get held(): boolean {\n return this._held;\n }\n\n get error(): Error | null {\n return this._error;\n }\n\n /** The desired intent. Read-only reflection; not a wc-bindable property (it does\n * not change on an OS auto-release, so there is nothing to observe). */\n get active(): boolean {\n return this._active;\n }\n\n get type(): WakeLockKind {\n return this._type;\n }\n\n set type(value: WakeLockKind) {\n // Currently effectively a no-op: \"screen\" is the only standardized lock type,\n // so `WakeLockKind` is a single value and this setter never observes a real\n // change. Kept as a forward-compatible seam for when the spec adds lock types.\n //\n // Takes effect on the next acquire. Changing the type mid-hold deliberately does\n // NOT re-acquire — the live sentinel is left as is, so a type change applies only\n // from the following acquire. If multiple lock types are ever added this becomes\n // an observable behavior gap (a held lock keeps its old type until release/re-\n // acquire) and must be re-examined — likely re-acquire here when held.\n this._type = value;\n }\n\n // --- State setters with event dispatch ---\n\n private _setHeld(held: boolean): void {\n if (this._held === held) return;\n this._held = held;\n this._target.dispatchEvent(new CustomEvent(\"wcs-wakelock:held-changed\", {\n detail: held,\n bubbles: true,\n }));\n }\n\n private _setError(error: Error | null): void {\n // Value guard, not just reference: a denied request rejects with a *fresh*\n // Error on every visibility-driven retry, so a reference compare would let a\n // permanently-denied environment re-dispatch the same failure on each\n // hidden→visible toggle. Compare name+message too. Transitions through null (a\n // success clears the error) always re-fire, so a genuinely new failure is seen.\n if (this._sameError(this._error, error)) return;\n this._error = error;\n this._target.dispatchEvent(new CustomEvent(\"wcs-wakelock:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n private _sameError(a: Error | null, b: Error | null): boolean {\n if (a === b) return true;\n if (a !== null && b !== null) return a.name === b.name && a.message === b.message;\n return false;\n }\n\n // --- Public API ---\n\n /**\n * Mark the lock as desired and acquire it. Idempotent while already held. If the\n * API is unavailable or the page is currently hidden, the desired flag is still\n * set (so the lock is acquired on the next return to visibility) but nothing is\n * acquired now. Never rejects — a request failure surfaces via `error`.\n */\n async request(): Promise<void> {\n this._active = true;\n this._ensureVisibilityListener();\n await this._acquire();\n }\n\n /** Mark the lock as no longer desired and release any held sentinel. */\n release(): void {\n this._active = false;\n // Invalidate any in-flight acquire so a late-resolving request() drops its\n // sentinel instead of leaving a lock held after release.\n this._gen++;\n const sentinel = this._sentinel;\n if (sentinel) {\n this._sentinel = null;\n sentinel.removeEventListener(\"release\", this._onRelease);\n void sentinel.release().catch(() => { /* never-throw */ });\n }\n this._setHeld(false);\n }\n\n /**\n * Full teardown: remove the visibility listener and release any held sentinel.\n * Call from the Shell's `disconnectedCallback`.\n *\n * Semantics: this is a terminal teardown, not a pause. After `dispose()` the Core\n * is meant to be discarded — there is no re-arm step, and the visibility listener\n * is gone, so an OS auto-release will no longer be followed by a re-acquire. A\n * later `request()` would still work in isolation (it re-attaches the listener via\n * `_ensureVisibilityListener`), but reusing a disposed Core is not an intended path;\n * the Shell always constructs a fresh Core per element instead.\n */\n dispose(): void {\n if (this._visibilityBound) {\n // §4 deviation: document-scoped Web API; no element-free alternative — the\n // Page Visibility `visibilitychange` event is only dispatched on `document`.\n document.removeEventListener(\"visibilitychange\", this._onVisibilityChange);\n this._visibilityBound = false;\n }\n this.release();\n }\n\n // --- Internal ---\n\n private async _acquire(): Promise<void> {\n if (this._held) return; // idempotent: already holding a sentinel\n if (this._acquiring) return; // an acquire is already in flight — don't double-request\n const wakeLock = this._wakeLock();\n if (!wakeLock) return; // unsupported — stay active, never acquire (silent no-op)\n if (!this._isVisible()) return; // hidden — defer to the next visibilitychange\n const gen = ++this._gen;\n this._acquiring = true;\n // Flag management is centralized in `finally` and the coalesced retry is invoked\n // exactly once, AFTER the try/catch/finally settles. This keeps the reject and\n // resolve paths symmetric: neither calls `_retryIfStillDesired()` from inside the\n // try/catch (which would let `finally` re-clear the `_acquiring=true` the retry's\n // synchronous re-entry just set, reopening the double-request window). `superseded`\n // records that a newer release()/request() bumped `_gen` mid-flight so its still-\n // live intent — blocked by the in-flight guard at the time — gets one retry here.\n // NOTE: no early `return` inside the try/catch below — every branch must fall\n // through to the post-`finally` retry. A `return` from inside the try would run\n // `finally` and then exit the function, skipping the `if (superseded)` retry.\n let superseded = false;\n let sentinel: WakeLockSentinelLike | null = null;\n let failed: Error | null = null;\n try {\n sentinel = await wakeLock.request(this._type);\n } catch (e) {\n if (gen !== this._gen) {\n // Superseded while awaiting — drop this stale failure (do not clobber the\n // newer state) and let the post-finally retry honor the live intent.\n superseded = true;\n } else {\n failed = this._normalizeError(e);\n }\n } finally {\n // The sole owner of the flag clears it here — on every exit path. A concurrent\n // re-entrant `_acquire()` was a no-op at the `_acquiring` guard, so it never owns\n // the flag; a superseding release()/acquire only bumps `_gen` and does not start\n // its own in-flight cycle until this clears the flag. Because this runs before\n // the retry below, the retry's `_acquiring=true` is never clobbered.\n this._acquiring = false;\n }\n\n if (sentinel !== null && gen !== this._gen) {\n // release() (or a newer acquire) ran while we awaited — this sentinel is\n // unwanted; drop it so no lock lingers, and retry the newer intent below.\n void sentinel.release().catch(() => { /* never-throw */ });\n superseded = true;\n } else if (sentinel !== null) {\n this._sentinel = sentinel;\n sentinel.addEventListener(\"release\", this._onRelease);\n this._setError(null);\n this._setHeld(true);\n } else if (failed !== null) {\n // A live (non-superseded) failure: surface it. Never retried — the intent is\n // honored but the environment denied it, so looping would spin.\n this._setError(failed);\n this._setHeld(false);\n }\n\n // Coalesced retry: at most one re-attempt per supersession, after the flag is\n // clear. The `_acquiring` guard inside still protects any concurrent re-entry that\n // overlaps THIS retry's own in-flight window (reject- and resolve-retry alike).\n if (superseded) this._retryIfStillDesired();\n }\n\n /**\n * Re-attempt an acquire after an in-flight one was *superseded* (its generation no\n * longer matches), but only if the lock is still desired, not already held, and the\n * page is visible. This recovers a request() that was coalesced away by the\n * in-flight `_acquiring` guard: during a release()→request() overlap, the second\n * request() bumps `_gen` and is a no-op at the guard, so without this retry its\n * still-live intent would be lost until the next visibilitychange or manual call.\n *\n * Bounded — cannot loop forever: a retry runs ONLY on supersession, and a\n * supersession requires an external release()/request() to bump `_gen` mid-flight.\n * A retry's own `_acquire()`, if it is itself not superseded, terminates by either\n * acquiring (held=true) or recording the live failure (held=false, error set) —\n * neither path retries. So a denied environment that keeps rejecting does not\n * recurse; the retry chain length is bounded by the number of external overlaps.\n */\n private _retryIfStillDesired(): void {\n if (this._active && !this._held && this._isVisible()) {\n void this._acquire();\n }\n }\n\n // Fired for an OS release of a held sentinel — which the spec allows for several\n // reasons, NOT only a visibility change: tab hidden / window minimized, but also\n // battery-low, power-saver mode, etc. while the page stays visible. We reflect\n // held=false, then (lease renewal) re-acquire immediately IF the page is still\n // visible and the lock is still desired — because a visible-context release emits no\n // `visibilitychange`, so the visibilitychange listener (②) would never fire and the\n // lock would stay stuck at desired=true / held=false. The hidden case is the no-op\n // here: re-acquire is gated on `_isVisible()`, so a hide-driven release defers to ②\n // (re-acquire on the return to visibility), avoiding a release→acquire loop while\n // hidden.\n private _onRelease = (): void => {\n // The `if (this._sentinel)` false branch is defensive and unreachable in practice:\n // this listener is only ever attached to the live `_sentinel`, and the only paths\n // that null `_sentinel` (this handler itself, and release()) remove this listener\n // in the same step — so the listener and a non-null `_sentinel` are coupled and\n // this never fires with `_sentinel === null`. Guarded anyway in case a host\n // dispatches a spurious second \"release\". (c8 ignore the unhittable else.)\n /* c8 ignore next */\n if (this._sentinel) {\n this._sentinel.removeEventListener(\"release\", this._onRelease);\n this._sentinel = null;\n }\n this._setHeld(false);\n this._reacquireAfterRelease();\n };\n\n /**\n * Lease renewal after an OS release while the page is still visible. Honors the\n * \"keep awake *while* active\" promise for releases that do NOT coincide with a\n * visibility change (battery-low / power-saver), which otherwise leave the lock\n * stuck at desired=true / held=false until the next hide→show cycle.\n *\n * Bounded on failure: this only runs from `_onRelease`, which only fires when a\n * sentinel was genuinely acquired and then released. A re-acquire that FAILS takes\n * `_acquire()`'s live-failure path (error recorded, held=false) and attaches no\n * listener, so it cannot re-enter `_onRelease` — a denied environment records the\n * error once and stops. This is the dominant real path: per the Wake Lock spec a\n * re-request under battery-low / power-saver is rejected (`NotAllowedError`), so the\n * renewal terminates there.\n *\n * The one path NOT bounded by a counter is a pathological host that keeps GRANTING\n * the re-request and then immediately auto-releasing it (grant→release reflux). Each\n * iteration yields to the event loop and consumes a real OS grant, so it is not a\n * tight/synchronous loop, but it would churn request() calls. We deliberately do NOT\n * add a debounce or renewal cap: that reflux is not documented browser behavior\n * (real browsers reject, not grant-then-revoke), and the extra timing state would\n * complicate the pure-sink design to defend a case that does not occur in practice.\n *\n * The `_isVisible()` / `!_acquiring` guards (doubled by `_acquire()`'s own in-flight\n * and held guards) prevent re-entry during an in-flight acquire and while hidden.\n */\n private _reacquireAfterRelease(): void {\n if (this._active && this._isVisible() && !this._acquiring) {\n void this._acquire();\n }\n }\n\n // ② Re-acquire when the page becomes visible again while the lock is still\n // desired but was auto-released. This is what makes `active` a durable intent.\n private _onVisibilityChange = (): void => {\n if (this._isVisible() && this._active && !this._held) {\n void this._acquire();\n }\n };\n\n private _ensureVisibilityListener(): void {\n if (this._visibilityBound) return;\n // §4 deviation: document-scoped Web API; no element-free alternative — the\n // Page Visibility `visibilitychange` event is only dispatched on `document`.\n document.addEventListener(\"visibilitychange\", this._onVisibilityChange);\n this._visibilityBound = true;\n }\n\n private _wakeLock(): WakeLockLike | null {\n return (navigator as Navigator & { wakeLock?: WakeLockLike }).wakeLock ?? null;\n }\n\n private _isVisible(): boolean {\n // §4 deviation: document-scoped Web API; no element-free alternative —\n // `visibilityState` lives on `document`, not on any element.\n return document.visibilityState === \"visible\";\n }\n\n private _normalizeError(e: unknown): Error {\n return e instanceof Error ? e : new Error(String(e));\n }\n}\n","import { IWcBindable, WakeLockKind } from \"../types.js\";\nimport { WakeLockCore } from \"../core/WakeLockCore.js\";\n\n/**\n * `<wcs-wakelock>` — declarative Screen Wake Lock.\n *\n * The first @wcstack tag that is a pure *sink*: every other sensor is an\n * element→state producer, but the wake lock is state→element. The headline\n * binding is `active@isPlaying` — hold the screen awake while a bound boolean is\n * true. `active` is the single input knob (a mirrored attribute); `held` and\n * `error` are the observable outputs.\n *\n * The OS auto-releases the lock when the page is hidden; the Core re-acquires it\n * on the next return to visibility while `active` is still set, so the binding\n * means \"keep awake *while* active\", not just \"acquire once\".\n */\nexport class WcsWakeLock extends HTMLElement {\n // SSR contract (§4.1/@wcstack/server): the renderer awaits elements declaring\n // `hasConnectedCallbackPromise = true` before snapshotting. The wake lock has no\n // connect-time async probe to await (acquire is fire-and-forget and meaningless\n // server-side), so `connectedCallbackPromise` is backed by the Core's no-op\n // `observe()`, which resolves immediately. The flag is still declared `true` so\n // the renderer reads it via `ctor.hasConnectedCallbackPromise` and the Shell\n // participates uniformly in the SSR await protocol.\n static hasConnectedCallbackPromise = true;\n // `active` drives request/release; `type` propagates to the Core's next acquire.\n // `manual` is intentionally excluded: it is a connect-time policy (\"don't auto-\n // acquire on connect\"), not a live switch.\n static observedAttributes = [\"active\", \"type\"];\n\n static wcBindable: IWcBindable = {\n ...WakeLockCore.wcBindable,\n // Settable surface. `active` is the declarative intent; `type` selects the lock\n // kind; `manual` opts out of auto-acquire on connect. The request / release\n // commands are inherited from the Core via the spread above.\n inputs: [\n { name: \"active\", attribute: \"active\" },\n { name: \"type\", attribute: \"type\" },\n { name: \"manual\", attribute: \"manual\" },\n ],\n // Core の commands をそのまま継承(単一情報源)。<wcs-intersect>/<wcs-sse> と同型。\n // spread でも継承されるが、Core に command 追加時の追従漏れを防ぐため明示参照する。\n commands: WakeLockCore.wcBindable.commands,\n };\n\n private _core: WakeLockCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new WakeLockCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-wakelock:held-changed\": (d) => ({ held: d === true }),\n \"wcs-wakelock:error\": (d) => ({ error: d != null }),\n });\n }\n\n // SSR (§4.1): the renderer awaits this before snapshotting. Backed by the Core's\n // observe() (a no-op resolving immediately for this command-driven sink).\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\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 // The ternary expression-statement form trips ESLint no-unused-expressions.\n if (on) { states.add(name); } else { states.delete(name); }\n } catch { /* never-throw */ }\n if (debug) this.toggleAttribute(`data-wcs-state-${name}`, on);\n }\n });\n }\n }\n\n // --- Attribute accessors ---\n\n get active(): boolean {\n // Reflects the *attribute*, not the Core's desired intent (`_core.active`). These\n // can diverge: invoking the `request` / `release` commands directly (e.g. via a\n // command-token binding) flips the Core's desired flag without touching the\n // attribute, so `el.active` may read false while `el.held` is true (or vice\n // versa). The attribute is the declarative input surface; the commands are an\n // imperative side door. Bind via `active@...` for a single source of truth.\n return this.hasAttribute(\"active\");\n }\n\n set active(value: boolean) {\n if (value) {\n this.setAttribute(\"active\", \"\");\n } else {\n this.removeAttribute(\"active\");\n }\n }\n\n get type(): WakeLockKind {\n // Only \"screen\" is standardized; an absent/empty attribute defaults to it.\n return (this.getAttribute(\"type\") as WakeLockKind) || \"screen\";\n }\n\n set type(value: WakeLockKind) {\n this.setAttribute(\"type\", value);\n }\n\n get manual(): boolean {\n return this.hasAttribute(\"manual\");\n }\n\n set manual(value: boolean) {\n if (value) {\n this.setAttribute(\"manual\", \"\");\n } else {\n this.removeAttribute(\"manual\");\n }\n }\n\n // --- Core delegated getters ---\n\n get held(): boolean {\n return this._core.held;\n }\n\n get error(): Error | null {\n return this._core.error;\n }\n\n // --- Commands ---\n\n /** Acquire (and keep) the wake lock. Never rejects — see the `error` property. */\n request(): Promise<void> {\n return this._core.request();\n }\n\n /** Release the wake lock and stop re-acquiring it. */\n release(): void {\n this._core.release();\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n // Headless resource: no layout box (mirrors the @wcstack sensor convention).\n this.style.display = \"none\";\n // Propagate the requested lock type to the Core. Currently a no-op in effect:\n // \"screen\" is the only standardized type, so `type` is always \"screen\". Wired\n // up as a forward-compatible seam (observedAttributes + setter + this line) for\n // when the spec adds lock types; until then it carries a constant.\n this._core.type = this.type;\n // Establish monitoring (§3.5) and expose readiness for SSR (§4.1). observe()\n // is a no-op that resolves immediately for this command-driven sink.\n this._connectedCallbackPromise = this._core.observe();\n if (!this.manual && this.active) {\n void this._core.request();\n }\n }\n\n disconnectedCallback(): void {\n this._core.dispose();\n }\n\n attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void {\n if (oldValue === newValue) return;\n // Ignore changes applied before connect (e.g. createElement + setAttribute);\n // connectedCallback applies the initial state. Acquiring a lock for a detached\n // element would be wrong.\n if (!this.isConnected) return;\n if (name === \"type\") {\n this._core.type = this.type;\n return;\n }\n // name === \"active\": a live toggle always drives request/release. `manual` only\n // gates the connect-time auto-acquire, not an explicit author toggle.\n if (this.active) {\n void this._core.request();\n } else {\n this._core.release();\n }\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapWakeLock(userConfig?: IWritableConfig): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents();\n}\n","import { WcsWakeLock } from \"./components/WakeLock.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.wakelock)) {\n customElements.define(config.tagNames.wakelock, WcsWakeLock);\n }\n}\n"],"names":["_config","tagNames","wakelock","deepFreeze","obj","Object","freeze","key","keys","deepClone","clone","frozenConfig","config","getConfig","WakeLockCore","EventTarget","static","protocol","version","properties","name","event","commands","async","_target","_type","_active","_held","_error","_sentinel","_gen","_acquiring","_visibilityBound","_ready","Promise","resolve","constructor","target","type","super","this","ready","observe","held","error","active","value","_setHeld","dispatchEvent","CustomEvent","detail","bubbles","_setError","_sameError","a","b","message","request","_ensureVisibilityListener","_acquire","release","sentinel","removeEventListener","_onRelease","catch","dispose","document","_onVisibilityChange","wakeLock","_wakeLock","_isVisible","gen","superseded","failed","e","_normalizeError","addEventListener","_retryIfStillDesired","_reacquireAfterRelease","navigator","visibilityState","Error","String","WcsWakeLock","HTMLElement","wcBindable","inputs","attribute","_core","_connectedCallbackPromise","_internals","_initInternals","_wireStates","d","connectedCallbackPromise","debugStates","states","attachInternals","internals","add","delete","map","toStates","entries","debug","hasAttribute","on","toggleAttribute","setAttribute","removeAttribute","getAttribute","manual","connectedCallback","style","display","disconnectedCallback","attributeChangedCallback","oldValue","newValue","isConnected","bootstrapWakeLock","userConfig","partialConfig","assign","customElements","get","define"],"mappings":"AAQA,MAAMA,EAA2B,CAC/BC,SAAU,CACRC,SAAU,iBAId,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,GACpB,GAAY,OAARA,GAA+B,iBAARA,EAAkB,OAAOA,EACpD,MAAMM,EAAiC,CAAA,EACvC,IAAK,MAAMH,KAAOF,OAAOG,KAAKJ,GAC5BM,EAAMH,GAAOE,EAAWL,EAAgCG,IAE1D,OAAOG,CACT,CAEA,IAAIC,EAA+B,KAS5B,MAAMC,EAAkBZ,WAEfa,IAId,OAHKF,IACHA,EAAeR,EAAWM,EAAUT,KAE/BW,CACT,CCXM,MAAOG,UAAqBC,YAChCC,kBAAiC,CAC/BC,SAAU,cACVC,QAAS,EACTC,WAAY,CACV,CAAEC,KAAM,OAAQC,MAAO,6BACvB,CAAED,KAAM,QAASC,MAAO,uBAE1BC,SAAU,CACR,CAAEF,KAAM,UAAWG,OAAO,GAC1B,CAAEH,KAAM,aAIJI,QACAC,MAIAC,SAAmB,EACnBC,OAAiB,EACjBC,OAAuB,KACvBC,UAAyC,KAKzCC,KAAe,EASfC,YAAsB,EACtBC,kBAA4B,EAI5BC,OAAwBC,QAAQC,UAExC,WAAAC,CAAYC,EAAsBC,EAAqB,UACrDC,QACAC,KAAKhB,QAA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,OAAOsH,OAAO3H,EAAQC,SAAUyH,EAAczH,UAEhDU,EAAe,MIlDViH,eAAeC,IAAIjH,EAAOX,SAASC,WACtC0H,eAAeE,OAAOlH,EAAOX,SAASC,SAAUiF,EDIpD"}
1
+ {"version":3,"file":"index.esm.min.js","sources":["../src/config.ts","../src/core/wakelockCapabilities.ts","../src/core/WakeLockCore.ts","../src/components/WakeLock.ts","../src/bootstrapWakeLock.ts","../src/registerComponents.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n wakelock: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n wakelock: \"wcs-wakelock\",\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\n// Note: this is the live, mutable internal config. It is not part of the public\n// package exports (see exports.ts) — only `getConfig()` (a frozen snapshot) is\n// surfaced. `setConfig()` is applied internally via `bootstrapWakeLock()` and\n// is not re-exported from the package root, though a deep path import\n// (`.../src/config.js`) can still reach and mutate it. Accepted as-is for\n// cross-package consistency: every @wcstack package follows this same shape.\n// Use `getConfig()` for a frozen, safe read.\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 * wakelockCapabilities.ts\n *\n * Wake Lock node 固有の error code(taxonomy)と derivation。汎用の error info 型は\n * `./platformCapability.js`(/io-core/ から copy-distribution される生成ファイル)から\n * import する。wake lock は request / release の pure sink で競合する operation を持た\n * ないため lane は持たず、error taxonomy(errorInfo)のみを採用する。\n *\n * error 面は sensor family(`{ error: <name>, message }`)とは異なり、`WakeLockCore._setError`\n * は生の `Error`(または clear の null)を受け取る。分類は `Error.name` で行う。\n *\n * NOTE(未対応環境について): Screen Wake Lock API は \"unsupported\" を error として通知しない。\n * `navigator.wakeLock` 不在時、Core の `_acquire()` は silent no-op(`held` は false のまま・\n * error 未設定)で戻る。よって sensor family のような `capability-missing` / phase=\"probe\" の\n * 分岐は wake lock には存在しない(到達不能なので実装しない)。error が出るのは\n * `navigator.wakeLock.request()` の reject を `_normalizeError` で正規化した場合のみ。\n */\n\nimport type { WcsIoErrorInfo } from \"./platformCapability.js\";\n\n/** 安定した wake lock error code(taxonomy)。値は公開キーとして固定。 */\nexport const WCS_WAKELOCK_ERROR_CODE = {\n /** `NotAllowedError` — ページ非可視/非アクティブ、または permission / feature-policy による拒否。 */\n NotAllowed: \"not-allowed\",\n /** その他の `request()` 失敗(非 Error reject の正規化など)。 */\n WakeLockError: \"wakelock-error\",\n} as const;\n\n/**\n * wake lock の失敗を serializable な error taxonomy に写す。`error` は\n * `WakeLockCore._setError` に渡る生の `Error`(`navigator.wakeLock.request()` の reject を\n * `_normalizeError` で正規化したもの)。\n *\n * - `NotAllowedError` は取得(request/acquire)時の拒否 — ページ非可視・permission /\n * feature-policy ブロック → phase=\"start\" / not-allowed。\n * - それ以外(非 Error reject を正規化した `Error` name=\"Error\" など)は phase=\"execute\" /\n * wakelock-error。\n *\n * いずれも retry で確実には回復しないため recoverable=false(可視復帰時の再取得は Core が\n * 内部で担うが、taxonomy 上の分類としては false)。\"unsupported\" は error にならない\n * (silent no-op)ため capability-missing の分岐は無い(ファイル冒頭 NOTE 参照)。\n */\nexport function deriveWakeLockErrorInfo(error: Error): WcsIoErrorInfo {\n if (error.name === \"NotAllowedError\") {\n return { code: WCS_WAKELOCK_ERROR_CODE.NotAllowed, phase: \"start\", recoverable: false, message: error.message };\n }\n return { code: WCS_WAKELOCK_ERROR_CODE.WakeLockError, phase: \"execute\", recoverable: false, message: error.message };\n}\n","import { IWcBindable, WakeLockKind } from \"../types.js\";\nimport { WcsIoErrorInfo } from \"./platformCapability.js\";\nimport { deriveWakeLockErrorInfo } from \"./wakelockCapabilities.js\";\n\n/**\n * Minimal structural views of the Screen Wake Lock API. Declared locally (rather\n * than relying on `lib.dom`'s experimental `WakeLock` types) so the package type-\n * checks the same across TypeScript lib versions, and so a runtime where\n * `navigator.wakeLock` is absent is just a value check, never a type error.\n */\ninterface WakeLockSentinelLike extends EventTarget {\n readonly released: boolean;\n readonly type: string;\n release(): Promise<void>;\n}\ninterface WakeLockLike {\n request(type?: string): Promise<WakeLockSentinelLike>;\n}\n\n/**\n * Headless screen-wake-lock primitive — a thin, framework-agnostic wrapper around\n * the Screen Wake Lock API exposed through the wc-bindable protocol.\n *\n * Unlike the other @wcstack sensors (geolocation / intersection), the wake lock is\n * a pure *sink*: nothing is read from the device. A bound state drives the desired\n * intent (`request()` / `release()`), and the only observable outputs are `held`\n * (whether a sentinel is actually held) and `error`.\n *\n * The OS releases the lock whenever the page stops being visible (tab hidden,\n * window minimized). To honor the declarative intent (\"keep awake *while* active\"),\n * the Core keeps the desired flag (`_active`) and re-acquires the lock on the next\n * `visibilitychange` back to visible. So `_active` (desired) and `held` (actual)\n * diverge across an auto-release — and only `held` is published, because desired\n * does not change when the OS drops the lock.\n *\n * Never-throw: `request()` never rejects (a failure surfaces via `error`), and an\n * unsupported environment is a silent no-op (`held` stays false), consistent with\n * the other @wcstack sensors.\n */\nexport class WakeLockCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"held\", event: \"wcs-wakelock:held-changed\" },\n { name: \"error\", event: \"wcs-wakelock:error\" },\n // Serializable failure taxonomy (stable code / phase / recoverable), or null.\n // Additive bindable output derived from the raw `error` (not-allowed / wakelock-error);\n // the existing `error` property/event are unchanged. Fires\n // wcs-wakelock:error-info-changed. No lane — the wake lock is a pure sink (request /\n // release do not compete).\n { name: \"errorInfo\", event: \"wcs-wakelock:error-info-changed\" },\n ],\n commands: [\n { name: \"request\", async: true },\n { name: \"release\" },\n ],\n };\n\n private _target: EventTarget;\n private _type: WakeLockKind;\n\n // `_active` is the desired intent (input); `_held` is whether a sentinel is\n // actually held right now (output). They diverge across an OS auto-release.\n private _active: boolean = false;\n private _held: boolean = false;\n private _error: Error | null = null;\n private _errorInfo: WcsIoErrorInfo | null = null;\n private _sentinel: WakeLockSentinelLike | null = null;\n\n // Bumped on every release()/new acquire so an in-flight async request() that\n // resolves late can detect it was superseded and drop its sentinel (mirrors the\n // generation guards in GeolocationCore).\n private _gen: number = 0;\n // True while an `_acquire()` is awaiting `navigator.wakeLock.request()`. The\n // `_held` flag is only set *after* that await resolves, so it cannot guard\n // against concurrent entry: two rapid visibilitychange events (or a Shell toggle\n // overlapping an in-flight request) would both pass `!this._held` and each call\n // `request()`. This in-flight flag closes that window — a re-entrant acquire is a\n // no-op. The `_gen` guard still ensures the *final* state is correct; this just\n // avoids the redundant `request()` call (and its duplicate error path on a denied\n // environment).\n private _acquiring: boolean = false;\n private _visibilityBound: boolean = false;\n\n // SSR (§3.8): a pure sink has no asynchronous probe to await — `request()` is\n // fire-and-forget and meaningless server-side — so readiness is immediate.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget, type: WakeLockKind = \"screen\") {\n super();\n this._target = target ?? this;\n this._type = type;\n }\n\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // Lifecycle (§3.5). The wake lock is command-driven (request / release) with no\n // ambient subscription to establish on connect, so observe() is an idempotent\n // no-op that resolves once ready; dispose() (below) tears down the visibility\n // listener, releases any held sentinel, and bumps _gen via release().\n observe(): Promise<void> {\n return this._ready;\n }\n\n get held(): boolean {\n return this._held;\n }\n\n get error(): Error | null {\n return this._error;\n }\n\n /**\n * The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /\n * `recoverable`), or null. Additive wc-bindable property (event\n * `wcs-wakelock: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 /** The desired intent. Read-only reflection; not a wc-bindable property (it does\n * not change on an OS auto-release, so there is nothing to observe). */\n get active(): boolean {\n return this._active;\n }\n\n get type(): WakeLockKind {\n return this._type;\n }\n\n set type(value: WakeLockKind) {\n // Currently effectively a no-op: \"screen\" is the only standardized lock type,\n // so `WakeLockKind` is a single value and this setter never observes a real\n // change. Kept as a forward-compatible seam for when the spec adds lock types.\n //\n // Takes effect on the next acquire. Changing the type mid-hold deliberately does\n // NOT re-acquire — the live sentinel is left as is, so a type change applies only\n // from the following acquire. If multiple lock types are ever added this becomes\n // an observable behavior gap (a held lock keeps its old type until release/re-\n // acquire) and must be re-examined — likely re-acquire here when held.\n this._type = value;\n }\n\n // --- State setters with event dispatch ---\n\n private _setHeld(held: boolean): void {\n if (this._held === held) return;\n this._held = held;\n this._target.dispatchEvent(new CustomEvent(\"wcs-wakelock:held-changed\", {\n detail: held,\n bubbles: true,\n }));\n }\n\n private _setError(error: Error | null): void {\n // Value guard, not just reference: a denied request rejects with a *fresh*\n // Error on every visibility-driven retry, so a reference compare would let a\n // permanently-denied environment re-dispatch the same failure on each\n // hidden→visible toggle. Compare name+message too. Transitions through null (a\n // success clears the error) always re-fire, so a genuinely new failure is seen.\n if (this._sameError(this._error, error)) return;\n this._error = error;\n // Keep the additive `errorInfo` taxonomy in sync with `error`: derive from the raw\n // Error (or null on clear). Fires before the `error` event so an observer binding\n // both sees the classification first, mirroring the io-node family.\n this._commitErrorInfo(error === null ? null : deriveWakeLockErrorInfo(error));\n this._target.dispatchEvent(new CustomEvent(\"wcs-wakelock:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n // Called only from _setError (which already same-value-guards on the error name +\n // message via _sameError), so errorInfo transitions exactly when error does — no\n // separate guard needed here.\n private _commitErrorInfo(info: WcsIoErrorInfo | null): void {\n this._errorInfo = info;\n this._target.dispatchEvent(new CustomEvent(\"wcs-wakelock:error-info-changed\", {\n detail: info,\n bubbles: true,\n }));\n }\n\n private _sameError(a: Error | null, b: Error | null): boolean {\n if (a === b) return true;\n if (a !== null && b !== null) return a.name === b.name && a.message === b.message;\n return false;\n }\n\n // --- Public API ---\n\n /**\n * Mark the lock as desired and acquire it. Idempotent while already held. If the\n * API is unavailable or the page is currently hidden, the desired flag is still\n * set (so the lock is acquired on the next return to visibility) but nothing is\n * acquired now. Never rejects — a request failure surfaces via `error`.\n */\n async request(): Promise<void> {\n this._active = true;\n this._ensureVisibilityListener();\n await this._acquire();\n }\n\n /** Mark the lock as no longer desired and release any held sentinel. */\n release(): void {\n this._active = false;\n // Invalidate any in-flight acquire so a late-resolving request() drops its\n // sentinel instead of leaving a lock held after release.\n this._gen++;\n const sentinel = this._sentinel;\n if (sentinel) {\n this._sentinel = null;\n sentinel.removeEventListener(\"release\", this._onRelease);\n void sentinel.release().catch(() => { /* never-throw */ });\n }\n this._setHeld(false);\n }\n\n /**\n * Full teardown: remove the visibility listener and release any held sentinel.\n * Call from the Shell's `disconnectedCallback`.\n *\n * Semantics: this is a terminal teardown, not a pause. After `dispose()` the Core\n * is meant to be discarded — there is no re-arm step, and the visibility listener\n * is gone, so an OS auto-release will no longer be followed by a re-acquire. A\n * later `request()` would still work in isolation (it re-attaches the listener via\n * `_ensureVisibilityListener`), but reusing a disposed Core is not an intended path;\n * the Shell always constructs a fresh Core per element instead.\n */\n dispose(): void {\n if (this._visibilityBound) {\n // §4 deviation: document-scoped Web API; no element-free alternative — the\n // Page Visibility `visibilitychange` event is only dispatched on `document`.\n document.removeEventListener(\"visibilitychange\", this._onVisibilityChange);\n this._visibilityBound = false;\n }\n this.release();\n }\n\n // --- Internal ---\n\n private async _acquire(): Promise<void> {\n if (this._held) return; // idempotent: already holding a sentinel\n if (this._acquiring) return; // an acquire is already in flight — don't double-request\n const wakeLock = this._wakeLock();\n if (!wakeLock) return; // unsupported — stay active, never acquire (silent no-op)\n if (!this._isVisible()) return; // hidden — defer to the next visibilitychange\n const gen = ++this._gen;\n this._acquiring = true;\n // Flag management is centralized in `finally` and the coalesced retry is invoked\n // exactly once, AFTER the try/catch/finally settles. This keeps the reject and\n // resolve paths symmetric: neither calls `_retryIfStillDesired()` from inside the\n // try/catch (which would let `finally` re-clear the `_acquiring=true` the retry's\n // synchronous re-entry just set, reopening the double-request window). `superseded`\n // records that a newer release()/request() bumped `_gen` mid-flight so its still-\n // live intent — blocked by the in-flight guard at the time — gets one retry here.\n // NOTE: no early `return` inside the try/catch below — every branch must fall\n // through to the post-`finally` retry. A `return` from inside the try would run\n // `finally` and then exit the function, skipping the `if (superseded)` retry.\n let superseded = false;\n let sentinel: WakeLockSentinelLike | null = null;\n let failed: Error | null = null;\n try {\n sentinel = await wakeLock.request(this._type);\n } catch (e) {\n if (gen !== this._gen) {\n // Superseded while awaiting — drop this stale failure (do not clobber the\n // newer state) and let the post-finally retry honor the live intent.\n superseded = true;\n } else {\n failed = this._normalizeError(e);\n }\n } finally {\n // The sole owner of the flag clears it here — on every exit path. A concurrent\n // re-entrant `_acquire()` was a no-op at the `_acquiring` guard, so it never owns\n // the flag; a superseding release()/acquire only bumps `_gen` and does not start\n // its own in-flight cycle until this clears the flag. Because this runs before\n // the retry below, the retry's `_acquiring=true` is never clobbered.\n this._acquiring = false;\n }\n\n if (sentinel !== null && gen !== this._gen) {\n // release() (or a newer acquire) ran while we awaited — this sentinel is\n // unwanted; drop it so no lock lingers, and retry the newer intent below.\n void sentinel.release().catch(() => { /* never-throw */ });\n superseded = true;\n } else if (sentinel !== null) {\n this._sentinel = sentinel;\n sentinel.addEventListener(\"release\", this._onRelease);\n this._setError(null);\n this._setHeld(true);\n } else if (failed !== null) {\n // A live (non-superseded) failure: surface it. Never retried — the intent is\n // honored but the environment denied it, so looping would spin.\n this._setError(failed);\n this._setHeld(false);\n }\n\n // Coalesced retry: at most one re-attempt per supersession, after the flag is\n // clear. The `_acquiring` guard inside still protects any concurrent re-entry that\n // overlaps THIS retry's own in-flight window (reject- and resolve-retry alike).\n if (superseded) this._retryIfStillDesired();\n }\n\n /**\n * Re-attempt an acquire after an in-flight one was *superseded* (its generation no\n * longer matches), but only if the lock is still desired, not already held, and the\n * page is visible. This recovers a request() that was coalesced away by the\n * in-flight `_acquiring` guard: during a release()→request() overlap, the second\n * request() bumps `_gen` and is a no-op at the guard, so without this retry its\n * still-live intent would be lost until the next visibilitychange or manual call.\n *\n * Bounded — cannot loop forever: a retry runs ONLY on supersession, and a\n * supersession requires an external release()/request() to bump `_gen` mid-flight.\n * A retry's own `_acquire()`, if it is itself not superseded, terminates by either\n * acquiring (held=true) or recording the live failure (held=false, error set) —\n * neither path retries. So a denied environment that keeps rejecting does not\n * recurse; the retry chain length is bounded by the number of external overlaps.\n */\n private _retryIfStillDesired(): void {\n if (this._active && !this._held && this._isVisible()) {\n void this._acquire();\n }\n }\n\n // Fired for an OS release of a held sentinel — which the spec allows for several\n // reasons, NOT only a visibility change: tab hidden / window minimized, but also\n // battery-low, power-saver mode, etc. while the page stays visible. We reflect\n // held=false, then (lease renewal) re-acquire immediately IF the page is still\n // visible and the lock is still desired — because a visible-context release emits no\n // `visibilitychange`, so the visibilitychange listener (②) would never fire and the\n // lock would stay stuck at desired=true / held=false. The hidden case is the no-op\n // here: re-acquire is gated on `_isVisible()`, so a hide-driven release defers to ②\n // (re-acquire on the return to visibility), avoiding a release→acquire loop while\n // hidden.\n private _onRelease = (): void => {\n // The `if (this._sentinel)` false branch is defensive and unreachable in practice:\n // this listener is only ever attached to the live `_sentinel`, and the only paths\n // that null `_sentinel` (this handler itself, and release()) remove this listener\n // in the same step — so the listener and a non-null `_sentinel` are coupled and\n // this never fires with `_sentinel === null`. Guarded anyway in case a host\n // dispatches a spurious second \"release\". (c8 ignore the unhittable else.)\n /* c8 ignore next */\n if (this._sentinel) {\n this._sentinel.removeEventListener(\"release\", this._onRelease);\n this._sentinel = null;\n }\n this._setHeld(false);\n this._reacquireAfterRelease();\n };\n\n /**\n * Lease renewal after an OS release while the page is still visible. Honors the\n * \"keep awake *while* active\" promise for releases that do NOT coincide with a\n * visibility change (battery-low / power-saver), which otherwise leave the lock\n * stuck at desired=true / held=false until the next hide→show cycle.\n *\n * Bounded on failure: this only runs from `_onRelease`, which only fires when a\n * sentinel was genuinely acquired and then released. A re-acquire that FAILS takes\n * `_acquire()`'s live-failure path (error recorded, held=false) and attaches no\n * listener, so it cannot re-enter `_onRelease` — a denied environment records the\n * error once and stops. This is the dominant real path: per the Wake Lock spec a\n * re-request under battery-low / power-saver is rejected (`NotAllowedError`), so the\n * renewal terminates there.\n *\n * The one path NOT bounded by a counter is a pathological host that keeps GRANTING\n * the re-request and then immediately auto-releasing it (grant→release reflux). Each\n * iteration yields to the event loop and consumes a real OS grant, so it is not a\n * tight/synchronous loop, but it would churn request() calls. We deliberately do NOT\n * add a debounce or renewal cap: that reflux is not documented browser behavior\n * (real browsers reject, not grant-then-revoke), and the extra timing state would\n * complicate the pure-sink design to defend a case that does not occur in practice.\n *\n * The `_isVisible()` / `!_acquiring` guards (doubled by `_acquire()`'s own in-flight\n * and held guards) prevent re-entry during an in-flight acquire and while hidden.\n */\n private _reacquireAfterRelease(): void {\n if (this._active && this._isVisible() && !this._acquiring) {\n void this._acquire();\n }\n }\n\n // ② Re-acquire when the page becomes visible again while the lock is still\n // desired but was auto-released. This is what makes `active` a durable intent.\n private _onVisibilityChange = (): void => {\n if (this._isVisible() && this._active && !this._held) {\n void this._acquire();\n }\n };\n\n private _ensureVisibilityListener(): void {\n if (this._visibilityBound) return;\n // §4 deviation: document-scoped Web API; no element-free alternative — the\n // Page Visibility `visibilitychange` event is only dispatched on `document`.\n document.addEventListener(\"visibilitychange\", this._onVisibilityChange);\n this._visibilityBound = true;\n }\n\n private _wakeLock(): WakeLockLike | null {\n return (navigator as Navigator & { wakeLock?: WakeLockLike }).wakeLock ?? null;\n }\n\n private _isVisible(): boolean {\n // §4 deviation: document-scoped Web API; no element-free alternative —\n // `visibilityState` lives on `document`, not on any element.\n return document.visibilityState === \"visible\";\n }\n\n private _normalizeError(e: unknown): Error {\n return e instanceof Error ? e : new Error(String(e));\n }\n}\n","import { IWcBindable, WakeLockKind } from \"../types.js\";\nimport { WakeLockCore } from \"../core/WakeLockCore.js\";\nimport { WcsIoErrorInfo } from \"../core/platformCapability.js\";\n\n/**\n * `<wcs-wakelock>` — declarative Screen Wake Lock.\n *\n * The first @wcstack tag that is a pure *sink*: every other sensor is an\n * element→state producer, but the wake lock is state→element. The headline\n * binding is `active@isPlaying` — hold the screen awake while a bound boolean is\n * true. `active` is the single input knob (a mirrored attribute); `held` and\n * `error` are the observable outputs.\n *\n * The OS auto-releases the lock when the page is hidden; the Core re-acquires it\n * on the next return to visibility while `active` is still set, so the binding\n * means \"keep awake *while* active\", not just \"acquire once\".\n */\nexport class WcsWakeLock extends HTMLElement {\n // SSR contract (§4.1/@wcstack/server): the renderer awaits elements declaring\n // `hasConnectedCallbackPromise = true` before snapshotting. The wake lock has no\n // connect-time async probe to await (acquire is fire-and-forget and meaningless\n // server-side), so `connectedCallbackPromise` is backed by the Core's no-op\n // `observe()`, which resolves immediately. The flag is still declared `true` so\n // the renderer reads it via `ctor.hasConnectedCallbackPromise` and the Shell\n // participates uniformly in the SSR await protocol.\n static hasConnectedCallbackPromise = true;\n // `active` drives request/release; `type` propagates to the Core's next acquire.\n // `manual` is intentionally excluded: it is a connect-time policy (\"don't auto-\n // acquire on connect\"), not a live switch.\n static observedAttributes = [\"active\", \"type\"];\n\n static wcBindable: IWcBindable = {\n ...WakeLockCore.wcBindable,\n // Settable surface. `active` is the declarative intent; `type` selects the lock\n // kind; `manual` opts out of auto-acquire on connect. The request / release\n // commands are inherited from the Core via the spread above.\n inputs: [\n { name: \"active\", attribute: \"active\" },\n { name: \"type\", attribute: \"type\" },\n { name: \"manual\", attribute: \"manual\" },\n ],\n // Core の commands をそのまま継承(単一情報源)。<wcs-intersect>/<wcs-sse> と同型。\n // spread でも継承されるが、Core に command 追加時の追従漏れを防ぐため明示参照する。\n commands: WakeLockCore.wcBindable.commands,\n };\n\n private _core: WakeLockCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new WakeLockCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-wakelock:held-changed\": (d) => ({ held: d === true }),\n \"wcs-wakelock:error\": (d) => ({ error: d != null }),\n });\n }\n\n // SSR (§4.1): the renderer awaits this before snapshotting. Backed by the Core's\n // observe() (a no-op resolving immediately for this command-driven sink).\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\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 // The ternary expression-statement form trips ESLint no-unused-expressions.\n if (on) { states.add(name); } else { states.delete(name); }\n } catch { /* never-throw */ }\n if (debug) this.toggleAttribute(`data-wcs-state-${name}`, on);\n }\n });\n }\n }\n\n // --- Attribute accessors ---\n\n get active(): boolean {\n // Reflects the *attribute*, not the Core's desired intent (`_core.active`). These\n // can diverge: invoking the `request` / `release` commands directly (e.g. via a\n // command-token binding) flips the Core's desired flag without touching the\n // attribute, so `el.active` may read false while `el.held` is true (or vice\n // versa). The attribute is the declarative input surface; the commands are an\n // imperative side door. Bind via `active@...` for a single source of truth.\n return this.hasAttribute(\"active\");\n }\n\n set active(value: boolean) {\n if (value) {\n this.setAttribute(\"active\", \"\");\n } else {\n this.removeAttribute(\"active\");\n }\n }\n\n get type(): WakeLockKind {\n // Only \"screen\" is standardized; an absent/empty attribute defaults to it.\n return (this.getAttribute(\"type\") as WakeLockKind) || \"screen\";\n }\n\n set type(value: WakeLockKind) {\n this.setAttribute(\"type\", value);\n }\n\n get manual(): boolean {\n return this.hasAttribute(\"manual\");\n }\n\n set manual(value: boolean) {\n if (value) {\n this.setAttribute(\"manual\", \"\");\n } else {\n this.removeAttribute(\"manual\");\n }\n }\n\n // --- Core delegated getters ---\n\n get held(): boolean {\n return this._core.held;\n }\n\n get error(): Error | null {\n return this._core.error;\n }\n\n get errorInfo(): WcsIoErrorInfo | null {\n return this._core.errorInfo;\n }\n\n // --- Commands ---\n\n /** Acquire (and keep) the wake lock. Never rejects — see the `error` property. */\n request(): Promise<void> {\n return this._core.request();\n }\n\n /** Release the wake lock and stop re-acquiring it. */\n release(): void {\n this._core.release();\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n // Headless resource: no layout box (mirrors the @wcstack sensor convention).\n this.style.display = \"none\";\n // Propagate the requested lock type to the Core. Currently a no-op in effect:\n // \"screen\" is the only standardized type, so `type` is always \"screen\". Wired\n // up as a forward-compatible seam (observedAttributes + setter + this line) for\n // when the spec adds lock types; until then it carries a constant.\n this._core.type = this.type;\n // Establish monitoring (§3.5) and expose readiness for SSR (§4.1). observe()\n // is a no-op that resolves immediately for this command-driven sink.\n this._connectedCallbackPromise = this._core.observe();\n if (!this.manual && this.active) {\n void this._core.request();\n }\n }\n\n disconnectedCallback(): void {\n this._core.dispose();\n }\n\n attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void {\n if (oldValue === newValue) return;\n // Ignore changes applied before connect (e.g. createElement + setAttribute);\n // connectedCallback applies the initial state. Acquiring a lock for a detached\n // element would be wrong.\n if (!this.isConnected) return;\n if (name === \"type\") {\n this._core.type = this.type;\n return;\n }\n // name === \"active\": a live toggle always drives request/release. `manual` only\n // gates the connect-time auto-acquire, not an explicit author toggle.\n if (this.active) {\n void this._core.request();\n } else {\n this._core.release();\n }\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapWakeLock(userConfig?: IWritableConfig): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents();\n}\n","import { WcsWakeLock } from \"./components/WakeLock.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.wakelock)) {\n customElements.define(config.tagNames.wakelock, WcsWakeLock);\n }\n}\n"],"names":["_config","tagNames","wakelock","deepFreeze","obj","Object","freeze","key","keys","deepClone","clone","frozenConfig","config","getConfig","WCS_WAKELOCK_ERROR_CODE","NotAllowed","WakeLockError","WakeLockCore","EventTarget","static","protocol","version","properties","name","event","commands","async","_target","_type","_active","_held","_error","_errorInfo","_sentinel","_gen","_acquiring","_visibilityBound","_ready","Promise","resolve","constructor","target","type","super","this","ready","observe","held","error","errorInfo","active","value","_setHeld","dispatchEvent","CustomEvent","detail","bubbles","_setError","_sameError","_commitErrorInfo","code","phase","recoverable","message","deriveWakeLockErrorInfo","info","a","b","request","_ensureVisibilityListener","_acquire","release","sentinel","removeEventListener","_onRelease","catch","dispose","document","_onVisibilityChange","wakeLock","_wakeLock","_isVisible","gen","superseded","failed","e","_normalizeError","addEventListener","_retryIfStillDesired","_reacquireAfterRelease","navigator","visibilityState","Error","String","WcsWakeLock","HTMLElement","wcBindable","inputs","attribute","_core","_connectedCallbackPromise","_internals","_initInternals","_wireStates","d","connectedCallbackPromise","debugStates","states","attachInternals","internals","add","delete","map","toStates","entries","debug","hasAttribute","on","toggleAttribute","setAttribute","removeAttribute","getAttribute","manual","connectedCallback","style","display","disconnectedCallback","attributeChangedCallback","oldValue","newValue","isConnected","bootstrapWakeLock","userConfig","partialConfig","assign","customElements","get","define"],"mappings":"AAQA,MAAMA,EAA2B,CAC/BC,SAAU,CACRC,SAAU,iBAId,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,GACpB,GAAY,OAARA,GAA+B,iBAARA,EAAkB,OAAOA,EACpD,MAAMM,EAAiC,CAAA,EACvC,IAAK,MAAMH,KAAOF,OAAOG,KAAKJ,GAC5BM,EAAMH,GAAOE,EAAWL,EAAgCG,IAE1D,OAAOG,CACT,CAEA,IAAIC,EAA+B,KAS5B,MAAMC,EAAkBZ,WAEfa,IAId,OAHKF,IACHA,EAAeR,EAAWM,EAAUT,KAE/BW,CACT,CC3BO,MAAMG,EAA0B,CAErCC,WAAY,cAEZC,cAAe,kBCcX,MAAOC,UAAqBC,YAChCC,kBAAiC,CAC/BC,SAAU,cACVC,QAAS,EACTC,WAAY,CACV,CAAEC,KAAM,OAAQC,MAAO,6BACvB,CAAED,KAAM,QAASC,MAAO,sBAMxB,CAAED,KAAM,YAAaC,MAAO,oCAE9BC,SAAU,CACR,CAAEF,KAAM,UAAWG,OAAO,GAC1B,CAAEH,KAAM,aAIJI,QACAC,MAIAC,SAAmB,EACnBC,OAAiB,EACjBC,OAAu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AMnD,KACpB,CAEA,aAAIC,GACF,OAAOL,KAAKuD,MAAMlD,SACpB,CAKA,OAAAmB,GACE,OAAOxB,KAAKuD,MAAM/B,SACpB,CAGA,OAAAG,GACE3B,KAAKuD,MAAM5B,SACb,CAIA,iBAAAoD,GAEE/E,KAAKgF,MAAMC,QAAU,OAKrBjF,KAAKuD,MAAMzD,KAAOE,KAAKF,KAGvBE,KAAKwD,0BAA4BxD,KAAKuD,MAAMrD,WACvCF,KAAK8E,QAAU9E,KAAKM,QAClBN,KAAKuD,MAAM/B,SAEpB,CAEA,oBAAA0D,GACElF,KAAKuD,MAAMvB,SACb,CAEA,wBAAAmD,CAAyBxG,EAAcyG,EAAyBC,GAC1DD,IAAaC,GAIZrF,KAAKsF,cACG,SAAT3G,EAMAqB,KAAKM,OACFN,KAAKuD,MAAM/B,UAEhBxB,KAAKuD,MAAM5B,UARX3B,KAAKuD,MAAMzD,KAAOE,KAAKF,KAU3B,EClNI,SAAUyF,EAAkBC,GJ8C5B,IAAoBC,EI7CpBD,KJ6CoBC,EI5CZD,GJ6CMnI,UAChBI,OAAOiI,OAAOtI,EAAQC,SAAUoI,EAAcpI,UAEhDU,EAAe,MKlDV4H,eAAeC,IAAI5H,EAAOX,SAASC,WACtCqI,eAAeE,OAAO7H,EAAOX,SAASC,SAAU4F,EDIpD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wcstack/wakelock",
3
- "version": "1.19.1",
3
+ "version": "1.21.0",
4
4
  "description": "Declarative Screen Wake Lock component for Web Components. Framework-agnostic, holds the screen awake while a bound state is true via wc-bindable-protocol.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.esm.js",