@wcstack/wakelock 1.25.0 → 1.26.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/dist/auto.min.js CHANGED
@@ -1 +1,2 @@
1
- import{bootstrapWakeLock as o}from"./index.esm.min.js";o();
1
+ const e={tagNames:{wakelock:"wcs-wakelock"}},t="not-allowed",s="wakelock-error";class i extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"held",event:"wcs-wakelock:held-changed",semantics:"state"},{name:"error",event:"wcs-wakelock:error",semantics:"state"},{name:"errorInfo",event:"wcs-wakelock:error-info-changed",semantics:"state"}],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:t,phase:"start",recoverable:!1,message:e.message}:{code:s,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,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))}}function r(e,t){let s=Object.getPrototypeOf(e);for(;null!==s;){const e=Object.getOwnPropertyDescriptor(s,t);if(void 0!==e)return"function"==typeof e.get||"function"==typeof e.set;s=Object.getPrototypeOf(s)}return!1}class n extends HTMLElement{static hasConnectedCallbackPromise=!0;static observedAttributes=["active","type"];static wcBindable={...i.wcBindable,inputs:[{name:"active",attribute:"active"},{name:"type",attribute:"type"},{name:"manual",attribute:"manual"}],commands:i.wcBindable.commands};_core;_connectedCallbackPromise=Promise.resolve();_internals=null;constructor(){super(),this._core=new i(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}get errorInfo(){return this._core.errorInfo}request(){return this._core.request()}release(){this._core.release()}connectedCallback(){!function(e){const t=e.constructor?.wcBindable,s=t?.inputs;if(void 0!==s)for(const t of s){const s=t.name;if(!Object.prototype.hasOwnProperty.call(e,s))continue;if(!r(e,s))continue;const i=e,n=i[s];delete i[s],i[s]=n}}(this),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)}}customElements.get(e.tagNames.wakelock)||customElements.define(e.tagNames.wakelock,n);
2
+ //# sourceMappingURL=auto.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto.min.js","sources":["../src/config.ts","../src/core/wakelockCapabilities.ts","../src/core/WakeLockCore.ts","../src/protocol/upgradeProperties.ts","../src/components/WakeLock.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\", semantics: \"state\" },\n { name: \"error\", event: \"wcs-wakelock:error\", semantics: \"state\" },\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\", semantics: \"state\" },\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","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/upgrade-properties.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// custom element の property upgrade — `static wcBindable.inputs` に宣言した入力のうち、\n// 要素が upgrade される前に代入された own データプロパティを取り込み直す。\n//\n// なぜ必要か:\n// 未定義タグの要素は素の HTMLElement なので、`el.url = \"...\"` は own データプロパティを作る。\n// upgrade 後にクラスの accessor が prototype へ入っても own プロパティが優先されるため、\n// setter は二度と呼ばれず、値は要素へ届かないまま消える(エラーも警告も出ない)。\n// 常にプロパティ代入を行う framework(Angular の `[prop]`、Lit の `.prop=`、\n// Solid の `prop:`、Vue の `.prop` 修飾子)× 遅延定義(autoloader / CDN / code-split)で\n// 常態的に起きる。docs/architecture-hardening/13-framework-adapter-binding-constraints.md §1.2。\n//\n// 安全側の判定:\n// own プロパティがあっても、prototype チェーンに accessor が無ければ「シャドウ」ではなく\n// その own プロパティ自体が正規の格納先なので触らない(public class field を壊さない)。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/upgrade-properties.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/upgradeProperties.ts). Those copies are generated — do not edit them.\nimport { IWcBindable } from \"./wcBindable.js\";\n\nfunction hasAccessorOnPrototype(target: object, name: string): boolean {\n let proto = Object.getPrototypeOf(target);\n while (proto !== null) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n if (descriptor !== undefined) {\n return typeof descriptor.get === \"function\" || typeof descriptor.set === \"function\";\n }\n proto = Object.getPrototypeOf(proto);\n }\n return false;\n}\n\n/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\n */\nexport function upgradeProperties(element: object): void {\n const declaration = (element as { constructor?: { wcBindable?: IWcBindable } }).constructor?.wcBindable;\n const inputs = declaration?.inputs;\n if (inputs === undefined) return;\n for (const input of inputs) {\n const name = input.name;\n if (!Object.prototype.hasOwnProperty.call(element, name)) continue;\n if (!hasAccessorOnPrototype(element, name)) continue;\n const record = element as Record<string, unknown>;\n const value = record[name];\n delete record[name];\n record[name] = value;\n }\n}\n","import { IWcBindable, WakeLockKind } from \"../types.js\";\nimport { WakeLockCore } from \"../core/WakeLockCore.js\";\nimport { WcsIoErrorInfo } from \"../core/platformCapability.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.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 // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\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"],"names":["config","tagNames","wakelock","WCS_WAKELOCK_ERROR_CODE","WakeLockCore","EventTarget","static","protocol","version","properties","name","event","semantics","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","hasAccessorOnPrototype","proto","Object","getPrototypeOf","descriptor","getOwnPropertyDescriptor","undefined","get","set","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","element","declaration","input","prototype","hasOwnProperty","call","record","upgradeProperties","style","display","disconnectedCallback","attributeChangedCallback","oldValue","newValue","isConnected","customElements","define"],"mappings":"AAQA,MAiCaA,EAjCoB,CAC/BC,SAAU,CACRC,SAAU,iBCWDC,EAEC,cAFDA,EAII,iBCcX,MAAOC,UAAqBC,YAChCC,kBAAiC,CAC/BC,SAAU,cACVC,QAAS,EACTC,WAAY,CACV,CAAEC,KAAM,OAAQC,MAAO,4BAA6BC,UAAW,SAC/D,CAAEF,KAAM,QAASC,MAAO,qBAAsBC,UAAW,SAMzD,CAAEF,KAAM,YAAaC,MAAO,kCAAmCC,UAAW,UAE5EC,SAAU,CACR,CAAEH,KAAM,UAAWI,OAAO,GAC1B,CAAEJ,KAAM,aAIJK,QACAC,MAIAC,SAAmB,EACnBC,OAAiB,EACjBC,OAAuB,KACvBC,WAAoC,KACpCC,UAAyC,KAKzCC,KAAe,EASfC,YAAsB,EACtBC,kBAA4B,EAI5BC,OAAwBC,QAAQC,UAExC,WAAAC,CAAYC,EAAsBC,EAAqB,UACrDC,QACAC,KAAKjB,QAAUc,GAAUG,KACzBA,KAAKhB,MAAQc,CACf,CAEA,SAAIG,GACF,OAAOD,KAAKP,MACd,CAMA,OAAAS,GACE,OAAOF,KAAKP,MACd,CAEA,QAAIU,GACF,OAAOH,KAAKd,KACd,CAEA,SAAIkB,GACF,OAAOJ,KAAKb,MACd,CAQA,aAAIkB,GACF,OAAOL,KAAKZ,UACd,CAIA,UAAIkB,GACF,OAAON,KAAKf,OACd,CAEA,QAAIa,GACF,OAAOE,KAAKhB,KACd,CAEA,QAAIc,CAAKS,GAUPP,KAAKhB,MAA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,QAAeN,IAAXM,EACJ,IAAK,MAAM6B,KAAS7B,EAAQ,CAC1B,MAAMpF,EAAOiH,EAAMjH,KACnB,IAAK0E,OAAOwC,UAAUC,eAAeC,KAAKL,EAAS/G,GAAO,SAC1D,IAAKwE,EAAuBuC,EAAS/G,GAAO,SAC5C,MAAMqH,EAASN,EACTlF,EAAQwF,EAAOrH,UACdqH,EAAOrH,GACdqH,EAAOrH,GAAQ6B,CACjB,CACF,CCyHIyF,CAAkBhG,MAElBA,KAAKiG,MAAMC,QAAU,OAKrBlG,KAAKgE,MAAMlE,KAAOE,KAAKF,KAGvBE,KAAKiE,0BAA4BjE,KAAKgE,MAAM9D,WACvCF,KAAKuF,QAAUvF,KAAKM,QAClBN,KAAKgE,MAAMxC,SAEpB,CAEA,oBAAA2E,GACEnG,KAAKgE,MAAMhC,SACb,CAEA,wBAAAoE,CAAyB1H,EAAc2H,EAAyBC,GAC1DD,IAAaC,GAIZtG,KAAKuG,cACG,SAAT7H,EAMAsB,KAAKM,OACFN,KAAKgE,MAAMxC,UAEhBxB,KAAKgE,MAAMrC,UARX3B,KAAKgE,MAAMlE,KAAOE,KAAKF,KAU3B,ECrNK0G,eAAe/C,IAAIzF,EAAOC,SAASC,WACtCsI,eAAeC,OAAOzI,EAAOC,SAASC,SAAUyF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wcstack/wakelock",
3
- "version": "1.25.0",
3
+ "version": "1.26.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",
package/dist/auto.js DELETED
@@ -1,3 +0,0 @@
1
- import { bootstrapWakeLock } from "./index.esm.js";
2
-
3
- bootstrapWakeLock();
@@ -1,2 +0,0 @@
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}const a={NotAllowed:"not-allowed",WakeLockError:"wakelock-error"};class o extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"held",event:"wcs-wakelock:held-changed",semantics:"state"},{name:"error",event:"wcs-wakelock:error",semantics:"state"},{name:"errorInfo",event:"wcs-wakelock:error-info-changed",semantics:"state"}],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,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))}}function l(e,t){let s=Object.getPrototypeOf(e);for(;null!==s;){const e=Object.getOwnPropertyDescriptor(s,t);if(void 0!==e)return"function"==typeof e.get||"function"==typeof e.set;s=Object.getPrototypeOf(s)}return!1}class c extends HTMLElement{static hasConnectedCallbackPromise=!0;static observedAttributes=["active","type"];static wcBindable={...o.wcBindable,inputs:[{name:"active",attribute:"active"},{name:"type",attribute:"type"},{name:"manual",attribute:"manual"}],commands:o.wcBindable.commands};_core;_connectedCallbackPromise=Promise.resolve();_internals=null;constructor(){super(),this._core=new o(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}get errorInfo(){return this._core.errorInfo}request(){return this._core.request()}release(){this._core.release()}connectedCallback(){!function(e){const t=e.constructor?.wcBindable,s=t?.inputs;if(void 0!==s)for(const t of s){const s=t.name;if(!Object.prototype.hasOwnProperty.call(e,s))continue;if(!l(e,s))continue;const i=e,r=i[s];delete i[s],i[s]=r}}(this),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 h(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,c)}export{a as WCS_WAKELOCK_ERROR_CODE,o as WakeLockCore,c as WcsWakeLock,h as bootstrapWakeLock,n as getConfig};
2
- //# sourceMappingURL=index.esm.min.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.esm.min.js","sources":["../src/config.ts","../src/core/wakelockCapabilities.ts","../src/core/WakeLockCore.ts","../src/protocol/upgradeProperties.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\", semantics: \"state\" },\n { name: \"error\", event: \"wcs-wakelock:error\", semantics: \"state\" },\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\", semantics: \"state\" },\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","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/upgrade-properties.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// custom element の property upgrade — `static wcBindable.inputs` に宣言した入力のうち、\n// 要素が upgrade される前に代入された own データプロパティを取り込み直す。\n//\n// なぜ必要か:\n// 未定義タグの要素は素の HTMLElement なので、`el.url = \"...\"` は own データプロパティを作る。\n// upgrade 後にクラスの accessor が prototype へ入っても own プロパティが優先されるため、\n// setter は二度と呼ばれず、値は要素へ届かないまま消える(エラーも警告も出ない)。\n// 常にプロパティ代入を行う framework(Angular の `[prop]`、Lit の `.prop=`、\n// Solid の `prop:`、Vue の `.prop` 修飾子)× 遅延定義(autoloader / CDN / code-split)で\n// 常態的に起きる。docs/architecture-hardening/13-framework-adapter-binding-constraints.md §1.2。\n//\n// 安全側の判定:\n// own プロパティがあっても、prototype チェーンに accessor が無ければ「シャドウ」ではなく\n// その own プロパティ自体が正規の格納先なので触らない(public class field を壊さない)。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/upgrade-properties.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/upgradeProperties.ts). Those copies are generated — do not edit them.\nimport { IWcBindable } from \"./wcBindable.js\";\n\nfunction hasAccessorOnPrototype(target: object, name: string): boolean {\n let proto = Object.getPrototypeOf(target);\n while (proto !== null) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n if (descriptor !== undefined) {\n return typeof descriptor.get === \"function\" || typeof descriptor.set === \"function\";\n }\n proto = Object.getPrototypeOf(proto);\n }\n return false;\n}\n\n/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\n */\nexport function upgradeProperties(element: object): void {\n const declaration = (element as { constructor?: { wcBindable?: IWcBindable } }).constructor?.wcBindable;\n const inputs = declaration?.inputs;\n if (inputs === undefined) return;\n for (const input of inputs) {\n const name = input.name;\n if (!Object.prototype.hasOwnProperty.call(element, name)) continue;\n if (!hasAccessorOnPrototype(element, name)) continue;\n const record = element as Record<string, unknown>;\n const value = record[name];\n delete record[name];\n record[name] = value;\n }\n}\n","import { IWcBindable, WakeLockKind } from \"../types.js\";\nimport { WakeLockCore } from \"../core/WakeLockCore.js\";\nimport { WcsIoErrorInfo } from \"../core/platformCapability.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.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 // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\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","semantics","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","hasAccessorOnPrototype","proto","getPrototypeOf","descriptor","getOwnPropertyDescriptor","undefined","get","set","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","element","declaration","input","prototype","hasOwnProperty","call","record","upgradeProperties","style","display","disconnectedCallback","attributeChangedCallback","oldValue","newValue","isConnected","bootstrapWakeLock","userConfig","partialConfig","assign","customElements","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,UAAqB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