@wcstack/geolocation 1.15.0 → 1.17.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 +56 -0
- package/README.md +59 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.esm.js +55 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/package.json +1 -1
package/README.ja.md
CHANGED
|
@@ -126,6 +126,62 @@ npm install @wcstack/geolocation
|
|
|
126
126
|
<wcs-geo manual data-wcs="command.getCurrentPosition: $command.locate"></wcs-geo>
|
|
127
127
|
```
|
|
128
128
|
|
|
129
|
+
## `:state()` による CSS スタイリング
|
|
130
|
+
|
|
131
|
+
`<wcs-geo>` は 3 つの boolean 出力ステートを
|
|
132
|
+
[`ElementInternals` の `CustomStateSet`](https://developer.mozilla.org/ja/docs/Web/API/CustomStateSet)
|
|
133
|
+
に反映します。そのため `data-wcs` バインディングやクラスの手動トグルなしに、CSS の
|
|
134
|
+
`:state()` 疑似クラスで直接スタイリングできます。
|
|
135
|
+
|
|
136
|
+
| ステート | on になる条件 |
|
|
137
|
+
|----------|----------------|
|
|
138
|
+
| `watching` | `wcs-geo:watching-changed` が `true` で発火(`false` でクリア) |
|
|
139
|
+
| `loading` | `wcs-geo:loading-changed` が `true` で発火(`false` でクリア) |
|
|
140
|
+
| `error` | `wcs-geo:error` が非 `null` の detail で発火(`null` でクリア) |
|
|
141
|
+
|
|
142
|
+
`permission` は反映されません。`granted` / `denied` のような派生 boolean getter
|
|
143
|
+
が存在せず(v1 のスコープ外)、ステートを立てる先がないためです — 代わりに
|
|
144
|
+
`permission` を直接バインドしてください。
|
|
145
|
+
|
|
146
|
+
```css
|
|
147
|
+
wcs-geo:state(loading) ~ .spinner { display: block; }
|
|
148
|
+
wcs-geo:state(watching) ~ .stop-button { display: inline-block; }
|
|
149
|
+
|
|
150
|
+
form:has(wcs-geo:state(error)) .banner { display: block; }
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
属性やクラスと異なり `:state()` は要素の外部から書き込めないため、この出力ステートが
|
|
154
|
+
入力と混同される心配がありません。
|
|
155
|
+
|
|
156
|
+
**対応ブラウザ**(新構文 `:state(x)`): Chrome/Edge 125+、Safari 17.4+、Firefox 126+。
|
|
157
|
+
非対応の環境ではステートが一切 set されないだけです — `:state()` セレクタがマッチしなく
|
|
158
|
+
なりますが、`<wcs-geo>` 自体は通常どおり動作し続けます(graceful degradation・never-throw)。
|
|
159
|
+
|
|
160
|
+
**SSR:** `:state()` は HTML にシリアライズできないため、サーバーレンダリングされた
|
|
161
|
+
マークアップの初期ペイントにはこれらのステートは乗りません(`@wcstack/server` は無改変)。
|
|
162
|
+
ハイドレーション前の見た目を制御したい場合は、代わりに `wcs-geo:not(:defined)` と組み合わせてください。
|
|
163
|
+
|
|
164
|
+
### デバッグ
|
|
165
|
+
|
|
166
|
+
カスタムステートは DevTools の Elements パネルには表示されず、`attachInternals()`
|
|
167
|
+
は同一要素に 2 回呼べないため、コンソールから直接覗く手段がありません。そのための
|
|
168
|
+
デバッグ専用の補助を 2 つ用意しています:
|
|
169
|
+
|
|
170
|
+
- `el.debugStates` — 現在 on になっているステート名の**スナップショット**配列
|
|
171
|
+
(例: `["loading"]`)。`wc-bindable` の一部ではなく(バインド対象ではない)、
|
|
172
|
+
形状も契約として保証されません — デバッグ用途にのみ使ってください。
|
|
173
|
+
- `debug-states` 属性(opt-in・既定 OFF)は、ステート変化を要素の
|
|
174
|
+
`data-wcs-state-watching` / `data-wcs-state-loading` / `data-wcs-state-error`
|
|
175
|
+
属性にミラーします。Elements パネルを開いておけば、トグルのたびにハイライトされます:
|
|
176
|
+
|
|
177
|
+
```html
|
|
178
|
+
<wcs-geo watch debug-states></wcs-geo>
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**CSS は `data-wcs-state-*` ではなく `:state()` に書いてください。** ミラーされた
|
|
182
|
+
属性は、DevTools を開いた状態でステート変化を可視化するためだけのものであり、
|
|
183
|
+
スタイリング用の正式なフックではありません。
|
|
184
|
+
|
|
129
185
|
## 注意点と制約
|
|
130
186
|
|
|
131
187
|
- **属性は接続時に読み取られ、監視されない。** `<wcs-geo>` は `observedAttributes` / `attributeChangedCallback` を実装していません。オプション属性(`high-accuracy`, `timeout`, `maximum-age`, `watch`, `manual`)は要素の接続時とコマンド実行のたびに読み取られます。接続*後*に命令的に変更しても、それだけでは再取得・再監視は行われません。新しいオプションを反映するには、`getCurrentPosition()` / `clearWatch()` + `watchPosition()` を再度呼ぶか、要素を再接続してください。
|
package/README.md
CHANGED
|
@@ -126,6 +126,65 @@ State-driven invocation uses the command-token protocol:
|
|
|
126
126
|
<wcs-geo manual data-wcs="command.getCurrentPosition: $command.locate"></wcs-geo>
|
|
127
127
|
```
|
|
128
128
|
|
|
129
|
+
## CSS styling with `:state()`
|
|
130
|
+
|
|
131
|
+
`<wcs-geo>` reflects three boolean output states onto its
|
|
132
|
+
[`ElementInternals` `CustomStateSet`](https://developer.mozilla.org/en-US/docs/Web/API/CustomStateSet),
|
|
133
|
+
so you can style it directly from CSS with the `:state()` pseudo-class — no
|
|
134
|
+
`data-wcs` binding or extra class toggling required.
|
|
135
|
+
|
|
136
|
+
| State | On when |
|
|
137
|
+
|-------|---------|
|
|
138
|
+
| `watching` | `wcs-geo:watching-changed` fires with `true` (cleared on `false`) |
|
|
139
|
+
| `loading` | `wcs-geo:loading-changed` fires with `true` (cleared on `false`) |
|
|
140
|
+
| `error` | `wcs-geo:error` fires with a non-`null` detail (cleared on `null`) |
|
|
141
|
+
|
|
142
|
+
`permission` is not reflected: it has no derived boolean getter (e.g. `granted` /
|
|
143
|
+
`denied`) to hang a state on, which is out of scope for v1 — bind `permission`
|
|
144
|
+
directly instead.
|
|
145
|
+
|
|
146
|
+
```css
|
|
147
|
+
wcs-geo:state(loading) ~ .spinner { display: block; }
|
|
148
|
+
wcs-geo:state(watching) ~ .stop-button { display: inline-block; }
|
|
149
|
+
|
|
150
|
+
form:has(wcs-geo:state(error)) .banner { display: block; }
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Unlike attributes or classes, `:state()` cannot be written from outside the
|
|
154
|
+
element, so there is no risk of confusing this output state with an input.
|
|
155
|
+
|
|
156
|
+
**Browser support** (`:state(x)` syntax): Chrome/Edge 125+, Safari 17.4+,
|
|
157
|
+
Firefox 126+. In older browsers the states are simply never set — `:state()`
|
|
158
|
+
selectors never match, but `<wcs-geo>` itself keeps working normally
|
|
159
|
+
(graceful degradation, never-throw).
|
|
160
|
+
|
|
161
|
+
**SSR**: `:state()` cannot be serialized into HTML, so server-rendered markup
|
|
162
|
+
never carries these states on first paint (`@wcstack/server` is unaffected).
|
|
163
|
+
If you need to style the pre-hydration gap, pair your rule with
|
|
164
|
+
`wcs-geo:not(:defined)` instead.
|
|
165
|
+
|
|
166
|
+
### Debugging
|
|
167
|
+
|
|
168
|
+
Custom states are invisible in DevTools' Elements panel and `attachInternals()`
|
|
169
|
+
cannot be called twice, so there is no console way to inspect them directly.
|
|
170
|
+
Two debug-only aids are provided for that:
|
|
171
|
+
|
|
172
|
+
- `el.debugStates` — a **snapshot** array of the currently-on state names
|
|
173
|
+
(e.g. `["loading"]`). It is not part of `wc-bindable` (not a bind target)
|
|
174
|
+
and its shape is not a guaranteed contract — use it for debugging only.
|
|
175
|
+
- The `debug-states` attribute (opt-in, default off) mirrors state changes
|
|
176
|
+
onto `data-wcs-state-watching` / `data-wcs-state-loading` /
|
|
177
|
+
`data-wcs-state-error` attributes on the element, so the Elements panel
|
|
178
|
+
highlights them as they toggle:
|
|
179
|
+
|
|
180
|
+
```html
|
|
181
|
+
<wcs-geo watch debug-states></wcs-geo>
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**Write your CSS against `:state()`, not `data-wcs-state-*`.** The mirrored
|
|
185
|
+
attributes exist purely to make state changes visible while debugging with
|
|
186
|
+
DevTools open; they are not a supported styling hook.
|
|
187
|
+
|
|
129
188
|
## Notes & limitations
|
|
130
189
|
|
|
131
190
|
- **Attributes are read at connect time, not observed.** `<wcs-geo>` does not implement `observedAttributes` / `attributeChangedCallback`. Option attributes (`high-accuracy`, `timeout`, `maximum-age`, `watch`, `manual`) are read when the element connects and each time a command runs — changing them imperatively *after* connect does not by itself re-acquire or re-watch. To apply new options, call `getCurrentPosition()` / `clearWatch()` + `watchPosition()` again, or re-connect the element.
|
package/dist/index.d.ts
CHANGED
|
@@ -263,7 +263,11 @@ declare class WcsGeolocation extends HTMLElement {
|
|
|
263
263
|
private _core;
|
|
264
264
|
private _trigger;
|
|
265
265
|
private _connectedCallbackPromise;
|
|
266
|
+
private _internals;
|
|
266
267
|
constructor();
|
|
268
|
+
get debugStates(): string[];
|
|
269
|
+
private _initInternals;
|
|
270
|
+
private _wireStates;
|
|
267
271
|
get highAccuracy(): boolean;
|
|
268
272
|
set highAccuracy(value: boolean);
|
|
269
273
|
get timeout(): number;
|
package/dist/index.esm.js
CHANGED
|
@@ -539,9 +539,64 @@ class WcsGeolocation extends HTMLElement {
|
|
|
539
539
|
_core;
|
|
540
540
|
_trigger = false;
|
|
541
541
|
_connectedCallbackPromise = Promise.resolve();
|
|
542
|
+
_internals = null;
|
|
542
543
|
constructor() {
|
|
543
544
|
super();
|
|
544
545
|
this._core = new GeolocationCore(this);
|
|
546
|
+
this._internals = this._initInternals();
|
|
547
|
+
this._wireStates({
|
|
548
|
+
"wcs-geo:watching-changed": (d) => ({ watching: d === true }),
|
|
549
|
+
"wcs-geo:loading-changed": (d) => ({ loading: d === true }),
|
|
550
|
+
"wcs-geo:error": (d) => ({ error: d != null }),
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
// CSS state reflection (:state()) — debug-only snapshot getter. NOT part of
|
|
554
|
+
// wc-bindable (not a bind target); see README "CSS styling with :state()".
|
|
555
|
+
// MUST NOT return the live CustomStateSet (that would let callers write
|
|
556
|
+
// states from outside, defeating the point of :state() being read-only).
|
|
557
|
+
get debugStates() {
|
|
558
|
+
return this._internals ? [...this._internals.states] : [];
|
|
559
|
+
}
|
|
560
|
+
_initInternals() {
|
|
561
|
+
// never-throw (docs/custom-state-reflection-design.md §3.4): attachInternals
|
|
562
|
+
// is absent in happy-dom / older environments, and pre-125 Chromium rejects
|
|
563
|
+
// non-dashed state names from states.add() (probed and discarded here).
|
|
564
|
+
// Either case silently disables reflection — the component still works, it
|
|
565
|
+
// just doesn't expose :state() selectors.
|
|
566
|
+
try {
|
|
567
|
+
if (typeof this.attachInternals !== "function")
|
|
568
|
+
return null;
|
|
569
|
+
const internals = this.attachInternals();
|
|
570
|
+
internals.states.add("wcs-probe");
|
|
571
|
+
internals.states.delete("wcs-probe");
|
|
572
|
+
return internals;
|
|
573
|
+
}
|
|
574
|
+
catch {
|
|
575
|
+
return null;
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
_wireStates(map) {
|
|
579
|
+
if (this._internals === null)
|
|
580
|
+
return;
|
|
581
|
+
const states = this._internals.states;
|
|
582
|
+
for (const [event, toStates] of Object.entries(map)) {
|
|
583
|
+
this.addEventListener(event, (e) => {
|
|
584
|
+
const debug = this.hasAttribute("debug-states");
|
|
585
|
+
for (const [name, on] of Object.entries(toStates(e.detail))) {
|
|
586
|
+
try {
|
|
587
|
+
if (on) {
|
|
588
|
+
states.add(name);
|
|
589
|
+
}
|
|
590
|
+
else {
|
|
591
|
+
states.delete(name);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
catch { /* never-throw */ }
|
|
595
|
+
if (debug)
|
|
596
|
+
this.toggleAttribute(`data-wcs-state-${name}`, on);
|
|
597
|
+
}
|
|
598
|
+
});
|
|
599
|
+
}
|
|
545
600
|
}
|
|
546
601
|
// --- Attribute accessors ---
|
|
547
602
|
get highAccuracy() {
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/config.ts","../src/core/GeolocationCore.ts","../src/autoTrigger.ts","../src/components/Geolocation.ts","../src/registerComponents.ts","../src/bootstrapGeolocation.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n autoTrigger: boolean;\n triggerAttribute: string;\n tagNames: {\n geo: string;\n };\n}\n\nconst _config: IInternalConfig = {\n autoTrigger: true,\n triggerAttribute: \"data-geotarget\",\n tagNames: {\n geo: \"wcs-geo\",\n },\n};\n\nfunction deepFreeze<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n Object.freeze(obj);\n for (const key of Object.keys(obj)) {\n deepFreeze((obj as Record<string, unknown>)[key]);\n }\n return obj;\n}\n\nfunction deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n const clone: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n clone[key] = deepClone((obj as Record<string, unknown>)[key]);\n }\n return clone as T;\n}\n\nlet frozenConfig: IConfig | null = null;\n\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\nexport function setConfig(partialConfig: IWritableConfig): void {\n if (typeof partialConfig.autoTrigger === \"boolean\") {\n _config.autoTrigger = partialConfig.autoTrigger;\n }\n if (typeof partialConfig.triggerAttribute === \"string\") {\n _config.triggerAttribute = partialConfig.triggerAttribute;\n }\n if (partialConfig.tagNames) {\n Object.assign(_config.tagNames, partialConfig.tagNames);\n }\n frozenConfig = null;\n}\n","import {\n IWcBindable, GeoOptions, GeoPermissionState,\n WcsGeoPositionDetail, WcsGeoCoords, WcsGeoErrorDetail,\n} from \"../types.js\";\n\n/**\n * Headless geolocation primitive. A thin, framework-agnostic wrapper around the\n * Geolocation API exposed through the wc-bindable protocol.\n *\n * It has two phases, mirroring the two distinct shapes of the underlying API:\n * - **one-shot** — `getCurrentPosition()` resolves a single fix (like FetchCore's\n * one-shot `fetch()`), toggling `loading` around the async call.\n * - **continuous** — `watch()` / `clearWatch()` stream fixes (like TimerCore's\n * `start()` / `stop()`), toggling the `watching` flag.\n *\n * Every successful fix is published via the single `wcs-geo:position` event;\n * `latitude` / `longitude` / `accuracy` / `coords` / `timestamp` are read from\n * it through getters (mirroring how TimerCore exposes count/elapsed from one\n * `wcs-timer:tick` event), so an observer that binds any of them is notified on\n * every fix.\n *\n * Geolocation also has a permission gate absent from timer/websocket: the\n * `permission` property reflects `navigator.permissions.query({name:\n * \"geolocation\"})` (`prompt` / `granted` / `denied`, or `unsupported`) and\n * tracks its live `change` event. It is a read-only sensor — there is no\n * element-bound \"send\" path; element → state only.\n */\nexport class GeolocationCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"position\", event: \"wcs-geo:position\" },\n { name: \"latitude\", event: \"wcs-geo:position\", getter: (e: Event) => (e as CustomEvent).detail.latitude },\n { name: \"longitude\", event: \"wcs-geo:position\", getter: (e: Event) => (e as CustomEvent).detail.longitude },\n { name: \"accuracy\", event: \"wcs-geo:position\", getter: (e: Event) => (e as CustomEvent).detail.accuracy },\n { name: \"coords\", event: \"wcs-geo:position\", getter: (e: Event) => (e as CustomEvent).detail.coords },\n { name: \"timestamp\", event: \"wcs-geo:position\", getter: (e: Event) => (e as CustomEvent).detail.timestamp },\n { name: \"watching\", event: \"wcs-geo:watching-changed\" },\n { name: \"loading\", event: \"wcs-geo:loading-changed\" },\n { name: \"error\", event: \"wcs-geo:error\" },\n { name: \"permission\", event: \"wcs-geo:permission-changed\" },\n ],\n commands: [\n { name: \"getCurrentPosition\", async: true },\n { name: \"watch\" },\n { name: \"clearWatch\" },\n ],\n };\n\n private _target: EventTarget;\n private _watchId: number | null = null;\n\n private _position: WcsGeoPositionDetail | null = null;\n private _watching: boolean = false;\n private _loading: boolean = false;\n private _error: WcsGeoErrorDetail | null = null;\n private _permission: GeoPermissionState = \"prompt\";\n\n // Live PermissionStatus handle (when the Permissions API is available), kept\n // so the `change` listener can be removed on dispose().\n private _permissionStatus: PermissionStatus | null = null;\n\n // True once a permission subscription has been (or is being) established, and\n // reset by dispose(). Guards reinitPermission() so the first connect after\n // construction does not double-subscribe, while a reconnect after dispose()\n // does re-subscribe.\n private _permissionSubscribed: boolean = false;\n\n // Monotonic id of the current permission query. Bumped by every _initPermission()\n // and by dispose(). Each in-flight query captures its id and, on resolve, bails\n // unless it is still current — so a query superseded by a rapid (synchronous)\n // disconnect→reconnect, or one that resolves after dispose(), never attaches a\n // listener. A plain boolean cannot cover this: dispose()→reinit() flips it\n // false→true again, reopening the window for the stale query to slip through.\n private _permGen: number = 0;\n\n // Monotonic id of the current acquisition lifecycle, bumped only by dispose().\n // Each getCurrentPosition() captures it at start; the async success/error\n // callback bails (no setters, no resolve-side effects) if it is stale, so a\n // one-shot fix that resolves after the element was disconnected does not\n // dispatch wcs-geo:* on a torn-down element. Unlike FetchCore, the Geolocation\n // API has no AbortController, so a generation guard is the only way to neutralize\n // an in-flight one-shot. (watch is already stopped by clearWatch on disconnect.)\n private _acqGen: number = 0;\n\n // Monotonic id of the current watch lifecycle, bumped by watch(), clearWatch(),\n // and dispose(). Each watch() captures it; both watch callbacks bail if it is\n // stale. Unlike a live `_watchId === null` check, this distinguishes the current\n // watch from a superseded one: a clearWatch()→watch() restart installs a new\n // watchId (non-null), so a queued callback from the previous watch would pass a\n // null-check but fails the generation compare. (The README recommends exactly\n // this restart sequence to reconfigure a watch.)\n private _watchGen: number = 0;\n\n // Resolves once the most recent permission probe settles (or immediately when\n // the Permissions API is unsupported). The Shell exposes this as\n // connectedCallbackPromise so SSR can await the first probe before snapshotting\n // the HTML. Mirrors PermissionCore._ready.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n // Probe the permission state up front so observers see the real value\n // (granted/denied/prompt) before the first read, then keep it live.\n this._ready = this._initPermission();\n }\n\n get position(): WcsGeoPositionDetail | null {\n return this._position;\n }\n\n get latitude(): number | null {\n return this._position ? this._position.latitude : null;\n }\n\n get longitude(): number | null {\n return this._position ? this._position.longitude : null;\n }\n\n get accuracy(): number | null {\n return this._position ? this._position.accuracy : null;\n }\n\n get coords(): WcsGeoCoords | null {\n return this._position ? this._position.coords : null;\n }\n\n get timestamp(): number | null {\n return this._position ? this._position.timestamp : null;\n }\n\n get watching(): boolean {\n return this._watching;\n }\n\n get loading(): boolean {\n return this._loading;\n }\n\n get error(): WcsGeoErrorDetail | null {\n return this._error;\n }\n\n get permission(): GeoPermissionState {\n return this._permission;\n }\n\n /** Resolves once the first (or most recent) permission probe settles (§3.8). */\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // --- State setters with event dispatch ---\n\n private _setPosition(position: WcsGeoPositionDetail): void {\n this._position = position;\n this._target.dispatchEvent(new CustomEvent(\"wcs-geo:position\", {\n detail: position,\n bubbles: true,\n }));\n }\n\n private _setWatching(watching: boolean): void {\n if (this._watching === watching) return;\n this._watching = watching;\n this._target.dispatchEvent(new CustomEvent(\"wcs-geo:watching-changed\", {\n detail: watching,\n bubbles: true,\n }));\n }\n\n private _setLoading(loading: boolean): void {\n if (this._loading === loading) return;\n this._loading = loading;\n this._target.dispatchEvent(new CustomEvent(\"wcs-geo:loading-changed\", {\n detail: loading,\n bubbles: true,\n }));\n }\n\n private _setError(error: WcsGeoErrorDetail | null): void {\n // Same-value guard, like the other setters. Unlike `position` (which has\n // derived getters and so must re-fire even on an identical reference), `error`\n // has no derived state — so suppressing redundant null→null dispatches (e.g.\n // a successful fix clearing an already-null error) avoids spurious events.\n if (this._error === error) return;\n this._error = error;\n this._target.dispatchEvent(new CustomEvent(\"wcs-geo:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n private _setPermission(permission: GeoPermissionState): void {\n if (this._permission === permission) return;\n this._permission = permission;\n this._target.dispatchEvent(new CustomEvent(\"wcs-geo:permission-changed\", {\n detail: permission,\n bubbles: true,\n }));\n }\n\n // --- Public API ---\n\n /**\n * Acquire a single position fix. Resolves once the fix arrives or the request\n * fails — never rejects: failures are surfaced through the `error` property so\n * they flow into the declarative state, symmetrical with FetchCore.\n */\n getCurrentPosition(options: GeoOptions = {}): Promise<void> {\n return new Promise<void>((resolve) => {\n if (!this._hasGeolocation()) {\n this._setError(this._unsupportedError());\n resolve();\n return;\n }\n\n const gen = this._acqGen;\n this._setLoading(true);\n this._setError(null);\n navigator.geolocation.getCurrentPosition(\n (pos) => {\n // Stale: the element was disposed (disconnected) while this fix was in\n // flight. Drop it so a torn-down element never dispatches wcs-geo:*.\n // Still resolve() so any awaiter (e.g. connectedCallbackPromise) settles.\n if (gen !== this._acqGen) {\n resolve();\n return;\n }\n // Guard normalization/dispatch so a throw never escapes this browser\n // callback as an unhandled rejection, leaves the promise pending (which\n // would hang SSR's connectedCallbackPromise), or leaves `loading` stuck\n // true. Loading is cleared first so it holds even if a later step throws.\n try {\n this._setLoading(false);\n this._setPosition(this._normalizePosition(pos));\n } catch {\n // Surface the unexpected failure as an error so observers are not left\n // silently stale, then resolve below.\n this._setError(this._unexpectedError());\n }\n resolve();\n },\n (err) => {\n if (gen !== this._acqGen) {\n resolve();\n return;\n }\n try {\n this._setLoading(false);\n this._setError(this._normalizeError(err));\n } catch {\n this._setError(this._unexpectedError());\n }\n resolve();\n },\n options,\n );\n });\n }\n\n /**\n * Begin continuously watching the position. Idempotent while already\n * watching: a redundant watch() must not register a second `watchPosition`\n * (which would leak the handle and double the fix rate). Reconfiguring is done\n * via clearWatch() + watch().\n */\n watch(options: GeoOptions = {}): void {\n if (!this._hasGeolocation()) {\n this._setError(this._unsupportedError());\n return;\n }\n if (this._watching) return;\n\n this._setError(null);\n this._setWatching(true);\n // Open a new watch generation so any queued callback from a prior watch\n // (cleared then restarted) is recognized as stale below.\n const wgen = ++this._watchGen;\n this._watchId = navigator.geolocation.watchPosition(\n (pos) => {\n // Stale: this callback belongs to a watch that was cleared (or the element\n // disposed), possibly already superseded by a restart. A live\n // `_watchId === null` check cannot catch the restart case (the new watch\n // re-populates _watchId), so compare the captured generation instead.\n if (wgen !== this._watchGen) return;\n // Guard normalization/dispatch so an unexpected throw never escapes this\n // browser callback as an unhandled rejection — symmetric with the one-shot\n // path.\n try {\n // A recovered fix clears any prior transient error (e.g. a one-off\n // TIMEOUT) so `error` reflects the current state, not a stale failure.\n // The _setError same-value guard makes this free when error is already\n // null.\n this._setError(null);\n this._setPosition(this._normalizePosition(pos));\n } catch {\n this._setError(this._unexpectedError());\n }\n },\n (err) => {\n if (wgen !== this._watchGen) return;\n // An error does not implicitly release the watch — the watchId stays\n // valid and clearWatch() remains the teardown path — so `watching` is\n // left true to reflect \"watch still registered\". A terminal error (e.g.\n // PERMISSION_DENIED) is surfaced via the `error` property; callers that\n // want to stop on error can call clearWatch() in response.\n try {\n this._setError(this._normalizeError(err));\n } catch {\n this._setError(this._unexpectedError());\n }\n },\n options,\n );\n }\n\n clearWatch(): void {\n if (this._watchId !== null) {\n navigator.geolocation.clearWatch(this._watchId);\n this._watchId = null;\n }\n // Invalidate the current watch generation so any callback the browser may\n // still deliver after teardown bails.\n this._watchGen++;\n this._setWatching(false);\n }\n\n /**\n * Establish permission monitoring (§3.5). Idempotent: a no-op while a\n * subscription is already live (so the first connect after construction does\n * not double-subscribe), and re-subscribes after a dispose() — e.g. the Shell\n * element was disconnected and then reconnected (reparented). Returns the\n * `ready` promise, which resolves once the (re)established probe settles, so\n * the Shell can expose it as connectedCallbackPromise for SSR. Position\n * acquisition (one-shot / watch) is command-driven and the Shell drives it\n * separately from connectedCallback.\n */\n observe(): Promise<void> {\n if (!this._permissionSubscribed) {\n this._ready = this._initPermission();\n }\n return this._ready;\n }\n\n /**\n * Re-establish the permission `change` subscription after a dispose() — e.g.\n * the Shell element was disconnected and then reconnected (reparented). No-op\n * while a subscription is already live, so the first connect after\n * construction does not double-subscribe. This keeps permission tracking\n * symmetric with position acquisition, which the Shell also revives on\n * reconnect.\n *\n * Retained as a thin alias of observe() for the Shell's existing reconnect\n * path; observe() is the canonical §3.5 lifecycle entry point.\n */\n reinitPermission(): void {\n void this.observe();\n }\n\n /**\n * Detach the live permission `change` listener. Call from the Shell's\n * `disconnectedCallback` so a removed element does not leak the subscription.\n * A later reconnect can re-subscribe via reinitPermission().\n */\n dispose(): void {\n this._permissionSubscribed = false;\n // Invalidate any in-flight query so its .then() bails instead of attaching a\n // listener after teardown.\n this._permGen++;\n // Invalidate any in-flight one-shot acquisition so its success/error callback\n // bails instead of dispatching on a disconnected element.\n this._acqGen++;\n // Likewise invalidate the watch generation. The Shell already calls\n // clearWatch() before dispose(), but a direct headless dispose() (without a\n // preceding clearWatch) still neutralizes any queued watch callback.\n this._watchGen++;\n // Reset the loading shadow silently (no dispatch on a disposed element). The\n // bailed callback above will not clear it, and leaving it true would let the\n // same-value guard swallow the loading=true edge of the next acquisition after\n // a reconnect.\n this._loading = false;\n if (this._permissionStatus) {\n this._permissionStatus.removeEventListener(\"change\", this._onPermissionChange);\n this._permissionStatus = null;\n }\n }\n\n // --- Internal ---\n\n private _hasGeolocation(): boolean {\n return typeof navigator !== \"undefined\" && !!navigator.geolocation;\n }\n\n private _initPermission(): Promise<void> {\n // The Permissions API is optional. When absent (or it rejects, e.g. some\n // browsers don't accept the \"geolocation\" name), report \"unsupported\" and\n // leave acquisition to fail loudly via the error property if attempted.\n if (typeof navigator === \"undefined\" || !navigator.permissions || typeof navigator.permissions.query !== \"function\") {\n // Route through _setPermission (not a bare assignment) so observers stay in\n // sync with the public state. The same-value guard means no redundant\n // dispatch when the state does not actually change; it does mean a\n // previously-observed \"granted\"/\"denied\" being reinit'd into an environment\n // that lost the Permissions API now correctly notifies observers of the\n // unsupported transition instead of silently overwriting the shadow value.\n this._setPermission(\"unsupported\");\n // No asynchronous probe to await: readiness is immediate.\n return Promise.resolve();\n }\n this._permissionSubscribed = true;\n const gen = ++this._permGen;\n return navigator.permissions.query({ name: \"geolocation\" as PermissionName }).then(\n (status) => {\n // Stale resolution: this query was superseded (rapid reconnect) or the\n // element was disposed while it was in flight. Drop it so only the current\n // subscription attaches a listener.\n if (gen !== this._permGen) return;\n this._permissionStatus = status;\n this._setPermission(status.state as GeoPermissionState);\n status.addEventListener(\"change\", this._onPermissionChange);\n },\n () => {\n if (gen !== this._permGen) return;\n this._setPermission(\"unsupported\");\n },\n );\n }\n\n private _onPermissionChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setPermission(status.state as GeoPermissionState);\n };\n\n private _normalizePosition(pos: GeolocationPosition): WcsGeoPositionDetail {\n const c = pos.coords;\n const coords: WcsGeoCoords = {\n latitude: c.latitude,\n longitude: c.longitude,\n accuracy: c.accuracy,\n altitude: c.altitude,\n altitudeAccuracy: c.altitudeAccuracy,\n heading: c.heading,\n speed: c.speed,\n };\n return { ...coords, timestamp: pos.timestamp, coords };\n }\n\n private _normalizeError(err: GeolocationPositionError): WcsGeoErrorDetail {\n return { code: err.code, message: err.message };\n }\n\n private _unsupportedError(): WcsGeoErrorDetail {\n // Geolocation API absent: surface it as POSITION_UNAVAILABLE (2) so consumers\n // that switch on the spec error codes treat it like any other unavailable fix.\n return { code: 2, message: \"Geolocation API is not available in this environment.\" };\n }\n\n private _unexpectedError(): WcsGeoErrorDetail {\n // An unexpected throw while normalizing/dispatching a fix. Surface it as\n // POSITION_UNAVAILABLE (2) so it flows into `error` like any other failure\n // instead of escaping the browser callback as an unhandled rejection.\n return { code: 2, message: \"Unexpected error while processing the position fix.\" };\n }\n}\n","import { config } from \"./config.js\";\nimport type { WcsGeolocation } from \"./components/Geolocation.js\";\n\nlet registered = false;\n\nfunction handleClick(event: Event): void {\n const target = event.target;\n if (!(target instanceof Element)) return;\n\n const triggerElement = target.closest<Element>(`[${config.triggerAttribute}]`);\n if (!triggerElement) return;\n\n const geoId = triggerElement.getAttribute(config.triggerAttribute);\n if (!geoId) return;\n\n // Resolve the registered constructor at call time instead of importing\n // Geolocation as a value. The value import created a components/Geolocation.ts\n // ⇄ autoTrigger.ts cycle (Geolocation.connectedCallback() calls\n // registerAutoTrigger()). instanceof against the customElements registry keeps\n // the exact same identity guarantee — only the registered <wcs-geo> class\n // matches — without the import cycle.\n const GeoCtor = customElements.get(config.tagNames.geo);\n const geoElement = document.getElementById(geoId);\n if (!GeoCtor || !(geoElement instanceof GeoCtor)) return;\n\n // Suppress the element's default action so a fix can be requested without\n // navigating. Intentional: do not attach data-geotarget to an element whose\n // default action you also want (real <a href> link, form-submit button) — it\n // will be cancelled. See README \"Optional DOM Triggering\".\n event.preventDefault();\n (geoElement as WcsGeolocation).getCurrentPosition();\n}\n\nexport function registerAutoTrigger(): void {\n if (registered) return;\n registered = true;\n document.addEventListener(\"click\", handleClick);\n}\n\nexport function unregisterAutoTrigger(): void {\n if (!registered) return;\n registered = false;\n document.removeEventListener(\"click\", handleClick);\n}\n","import { config } from \"../config.js\";\nimport { IWcBindable, GeoOptions, GeoPermissionState, WcsGeoPositionDetail, WcsGeoCoords, WcsGeoErrorDetail } from \"../types.js\";\nimport { GeolocationCore } from \"../core/GeolocationCore.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\n\n// Named WcsGeolocation (not `Geolocation`) so the class does not shadow the\n// global DOM `Geolocation` interface (the type of `navigator.geolocation`), and\n// to match the <wcs-ws> convention (WcsWebSocket). The public export keeps the\n// `WcsGeolocation` name unchanged, so this rename is non-breaking.\nexport class WcsGeolocation extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...GeolocationCore.wcBindable,\n properties: [\n ...GeolocationCore.wcBindable.properties,\n { name: \"trigger\", event: \"wcs-geo:trigger-changed\" },\n ],\n // Shell-level settable surface. Each input carries its mirrored `attribute`\n // hint (boolean flags reflect idempotently, so a binding system that writes\n // through inputs[].attribute is safe), following the <wcs-ws> convention.\n // `trigger` has no attribute — it is a momentary command-property, not a\n // declarative attribute. The `getCurrentPosition` / `watchPosition` /\n // `clearWatch` commands are declared below.\n inputs: [\n { name: \"highAccuracy\", attribute: \"high-accuracy\" },\n { name: \"timeout\", attribute: \"timeout\" },\n { name: \"maximumAge\", attribute: \"maximum-age\" },\n { name: \"watch\", attribute: \"watch\" },\n { name: \"manual\", attribute: \"manual\" },\n { name: \"trigger\" },\n ],\n // The Core's `watch` command is renamed to `watchPosition` on the Shell so it\n // does not collide with the `watch` boolean attribute accessor (same pattern\n // as <wcs-ws>, where the `send` command becomes `sendMessage` to free the\n // `send` setter). `getCurrentPosition` / `clearWatch` are unchanged.\n commands: [\n { name: \"getCurrentPosition\", async: true },\n { name: \"watchPosition\" },\n { name: \"clearWatch\" },\n ],\n };\n\n private _core: GeolocationCore;\n private _trigger: boolean = false;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n\n constructor() {\n super();\n this._core = new GeolocationCore(this);\n }\n\n // --- Attribute accessors ---\n\n get highAccuracy(): boolean {\n return this.hasAttribute(\"high-accuracy\");\n }\n\n set highAccuracy(value: boolean) {\n if (value) {\n this.setAttribute(\"high-accuracy\", \"\");\n } else {\n this.removeAttribute(\"high-accuracy\");\n }\n }\n\n get timeout(): number {\n const attr = this.getAttribute(\"timeout\");\n if (attr === null || attr.trim() === \"\") return Infinity;\n // Strict parse via Number() (unlike parseInt, \"10px\" -> NaN, not 10). Fall\n // back to the API default (Infinity = no timeout) for any non-finite or\n // negative value, matching the README \"invalid values fall back to default\".\n const parsed = Number(attr);\n return Number.isFinite(parsed) && parsed >= 0 ? parsed : Infinity;\n }\n\n set timeout(value: number) {\n this.setAttribute(\"timeout\", String(value));\n }\n\n get maximumAge(): number {\n const attr = this.getAttribute(\"maximum-age\");\n if (attr === null || attr.trim() === \"\") return 0;\n // Strict parse via Number() (unlike parseInt, \"10px\" -> NaN, not 10). Fall\n // back to the API default (0 = never use a cached fix) for any non-finite or\n // negative value, matching the README \"invalid values fall back to default\".\n const parsed = Number(attr);\n return Number.isFinite(parsed) && parsed >= 0 ? parsed : 0;\n }\n\n set maximumAge(value: number) {\n this.setAttribute(\"maximum-age\", String(value));\n }\n\n get watch(): boolean {\n return this.hasAttribute(\"watch\");\n }\n\n set watch(value: boolean) {\n if (value) {\n this.setAttribute(\"watch\", \"\");\n } else {\n this.removeAttribute(\"watch\");\n }\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 position(): WcsGeoPositionDetail | null {\n return this._core.position;\n }\n\n get latitude(): number | null {\n return this._core.latitude;\n }\n\n get longitude(): number | null {\n return this._core.longitude;\n }\n\n get accuracy(): number | null {\n return this._core.accuracy;\n }\n\n get coords(): WcsGeoCoords | null {\n return this._core.coords;\n }\n\n get timestamp(): number | null {\n return this._core.timestamp;\n }\n\n get watching(): boolean {\n return this._core.watching;\n }\n\n get loading(): boolean {\n return this._core.loading;\n }\n\n get error(): WcsGeoErrorDetail | null {\n return this._core.error;\n }\n\n get permission(): GeoPermissionState {\n return this._core.permission;\n }\n\n // wc-bindable connectedCallbackPromise protocol: resolves once the connect-time\n // acquisition settles, so SSR (@wcstack/server render.ts) waits for the first\n // fix before snapshotting the HTML. Mirrors Fetch.connectedCallbackPromise. In\n // `watch` / `manual` modes there is no one-shot connect-time fix to await, so it\n // stays the default resolved promise.\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Command property ---\n\n get trigger(): boolean {\n return this._trigger;\n }\n\n set trigger(value: boolean) {\n // Momentary command-property: a false→true write requests a single fix.\n // Mirrors the trigger flag on <wcs-timer> / <wcs-ws>. Prefer the\n // command-token protocol (`command.getCurrentPosition: $command.locate`) for\n // state-driven acquisition; this exists mainly for the DOM click trigger and\n // simple boolean bindings.\n const v = !!value;\n if (v) {\n this._trigger = true;\n // Fire-and-forget: getCurrentPosition() never rejects (failures surface via\n // the `error` property), so the returned promise is intentionally dropped.\n void this.getCurrentPosition();\n this._trigger = false;\n this.dispatchEvent(new CustomEvent(\"wcs-geo:trigger-changed\", {\n detail: false,\n bubbles: true,\n }));\n }\n }\n\n // --- Commands ---\n\n getCurrentPosition(): Promise<void> {\n return this._core.getCurrentPosition(this._options());\n }\n\n watchPosition(): void {\n this._core.watch(this._options());\n }\n\n clearWatch(): void {\n this._core.clearWatch();\n }\n\n // --- Internal ---\n\n private _options(): GeoOptions {\n return {\n enableHighAccuracy: this.highAccuracy,\n timeout: this.timeout,\n maximumAge: this.maximumAge,\n };\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n this.style.display = \"none\";\n if (config.autoTrigger) {\n registerAutoTrigger();\n }\n // Revive permission tracking after a reconnect (reparenting). No-op on the\n // first connect since the constructor already subscribed; only re-subscribes\n // when disconnectedCallback's dispose() tore the subscription down.\n this._core.reinitPermission();\n if (!this.manual) {\n // `watch` attribute selects the default phase: continuous monitoring vs a\n // single fix on connect.\n if (this.watch) {\n this.watchPosition();\n } else {\n // Track only the one-shot connect-time fix so SSR can await it. watch /\n // manual leave the promise at its resolved default. getCurrentPosition()\n // never rejects (failures surface via `error`), so no .catch() is needed.\n this._connectedCallbackPromise = this.getCurrentPosition();\n }\n }\n }\n\n disconnectedCallback(): void {\n this._core.clearWatch();\n this._core.dispose();\n }\n}\n","import { WcsGeolocation } from \"./components/Geolocation.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.geo)) {\n customElements.define(config.tagNames.geo, WcsGeolocation);\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapGeolocation(userConfig?: IWritableConfig): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents();\n}\n"],"names":[],"mappings":"AAUA,MAAM,OAAO,GAAoB;AAC/B,IAAA,WAAW,EAAE,IAAI;AACjB,IAAA,gBAAgB,EAAE,gBAAgB;AAClC,IAAA,QAAQ,EAAE;AACR,QAAA,GAAG,EAAE,SAAS;AACf,KAAA;CACF;AAED,SAAS,UAAU,C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tB;;;SCnPc,kBAAkB,GAAA;AAChC,IAAA,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QAC5C,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,cAAc,CAAC;IAC5D;AACF;;ACHM,SAAU,oBAAoB,CAAC,UAA4B,EAAA;IAC/D,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/GeolocationCore.ts","../src/autoTrigger.ts","../src/components/Geolocation.ts","../src/registerComponents.ts","../src/bootstrapGeolocation.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n autoTrigger: boolean;\n triggerAttribute: string;\n tagNames: {\n geo: string;\n };\n}\n\nconst _config: IInternalConfig = {\n autoTrigger: true,\n triggerAttribute: \"data-geotarget\",\n tagNames: {\n geo: \"wcs-geo\",\n },\n};\n\nfunction deepFreeze<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n Object.freeze(obj);\n for (const key of Object.keys(obj)) {\n deepFreeze((obj as Record<string, unknown>)[key]);\n }\n return obj;\n}\n\nfunction deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n const clone: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n clone[key] = deepClone((obj as Record<string, unknown>)[key]);\n }\n return clone as T;\n}\n\nlet frozenConfig: IConfig | null = null;\n\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\nexport function setConfig(partialConfig: IWritableConfig): void {\n if (typeof partialConfig.autoTrigger === \"boolean\") {\n _config.autoTrigger = partialConfig.autoTrigger;\n }\n if (typeof partialConfig.triggerAttribute === \"string\") {\n _config.triggerAttribute = partialConfig.triggerAttribute;\n }\n if (partialConfig.tagNames) {\n Object.assign(_config.tagNames, partialConfig.tagNames);\n }\n frozenConfig = null;\n}\n","import {\n IWcBindable, GeoOptions, GeoPermissionState,\n WcsGeoPositionDetail, WcsGeoCoords, WcsGeoErrorDetail,\n} from \"../types.js\";\n\n/**\n * Headless geolocation primitive. A thin, framework-agnostic wrapper around the\n * Geolocation API exposed through the wc-bindable protocol.\n *\n * It has two phases, mirroring the two distinct shapes of the underlying API:\n * - **one-shot** — `getCurrentPosition()` resolves a single fix (like FetchCore's\n * one-shot `fetch()`), toggling `loading` around the async call.\n * - **continuous** — `watch()` / `clearWatch()` stream fixes (like TimerCore's\n * `start()` / `stop()`), toggling the `watching` flag.\n *\n * Every successful fix is published via the single `wcs-geo:position` event;\n * `latitude` / `longitude` / `accuracy` / `coords` / `timestamp` are read from\n * it through getters (mirroring how TimerCore exposes count/elapsed from one\n * `wcs-timer:tick` event), so an observer that binds any of them is notified on\n * every fix.\n *\n * Geolocation also has a permission gate absent from timer/websocket: the\n * `permission` property reflects `navigator.permissions.query({name:\n * \"geolocation\"})` (`prompt` / `granted` / `denied`, or `unsupported`) and\n * tracks its live `change` event. It is a read-only sensor — there is no\n * element-bound \"send\" path; element → state only.\n */\nexport class GeolocationCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"position\", event: \"wcs-geo:position\" },\n { name: \"latitude\", event: \"wcs-geo:position\", getter: (e: Event) => (e as CustomEvent).detail.latitude },\n { name: \"longitude\", event: \"wcs-geo:position\", getter: (e: Event) => (e as CustomEvent).detail.longitude },\n { name: \"accuracy\", event: \"wcs-geo:position\", getter: (e: Event) => (e as CustomEvent).detail.accuracy },\n { name: \"coords\", event: \"wcs-geo:position\", getter: (e: Event) => (e as CustomEvent).detail.coords },\n { name: \"timestamp\", event: \"wcs-geo:position\", getter: (e: Event) => (e as CustomEvent).detail.timestamp },\n { name: \"watching\", event: \"wcs-geo:watching-changed\" },\n { name: \"loading\", event: \"wcs-geo:loading-changed\" },\n { name: \"error\", event: \"wcs-geo:error\" },\n { name: \"permission\", event: \"wcs-geo:permission-changed\" },\n ],\n commands: [\n { name: \"getCurrentPosition\", async: true },\n { name: \"watch\" },\n { name: \"clearWatch\" },\n ],\n };\n\n private _target: EventTarget;\n private _watchId: number | null = null;\n\n private _position: WcsGeoPositionDetail | null = null;\n private _watching: boolean = false;\n private _loading: boolean = false;\n private _error: WcsGeoErrorDetail | null = null;\n private _permission: GeoPermissionState = \"prompt\";\n\n // Live PermissionStatus handle (when the Permissions API is available), kept\n // so the `change` listener can be removed on dispose().\n private _permissionStatus: PermissionStatus | null = null;\n\n // True once a permission subscription has been (or is being) established, and\n // reset by dispose(). Guards reinitPermission() so the first connect after\n // construction does not double-subscribe, while a reconnect after dispose()\n // does re-subscribe.\n private _permissionSubscribed: boolean = false;\n\n // Monotonic id of the current permission query. Bumped by every _initPermission()\n // and by dispose(). Each in-flight query captures its id and, on resolve, bails\n // unless it is still current — so a query superseded by a rapid (synchronous)\n // disconnect→reconnect, or one that resolves after dispose(), never attaches a\n // listener. A plain boolean cannot cover this: dispose()→reinit() flips it\n // false→true again, reopening the window for the stale query to slip through.\n private _permGen: number = 0;\n\n // Monotonic id of the current acquisition lifecycle, bumped only by dispose().\n // Each getCurrentPosition() captures it at start; the async success/error\n // callback bails (no setters, no resolve-side effects) if it is stale, so a\n // one-shot fix that resolves after the element was disconnected does not\n // dispatch wcs-geo:* on a torn-down element. Unlike FetchCore, the Geolocation\n // API has no AbortController, so a generation guard is the only way to neutralize\n // an in-flight one-shot. (watch is already stopped by clearWatch on disconnect.)\n private _acqGen: number = 0;\n\n // Monotonic id of the current watch lifecycle, bumped by watch(), clearWatch(),\n // and dispose(). Each watch() captures it; both watch callbacks bail if it is\n // stale. Unlike a live `_watchId === null` check, this distinguishes the current\n // watch from a superseded one: a clearWatch()→watch() restart installs a new\n // watchId (non-null), so a queued callback from the previous watch would pass a\n // null-check but fails the generation compare. (The README recommends exactly\n // this restart sequence to reconfigure a watch.)\n private _watchGen: number = 0;\n\n // Resolves once the most recent permission probe settles (or immediately when\n // the Permissions API is unsupported). The Shell exposes this as\n // connectedCallbackPromise so SSR can await the first probe before snapshotting\n // the HTML. Mirrors PermissionCore._ready.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n // Probe the permission state up front so observers see the real value\n // (granted/denied/prompt) before the first read, then keep it live.\n this._ready = this._initPermission();\n }\n\n get position(): WcsGeoPositionDetail | null {\n return this._position;\n }\n\n get latitude(): number | null {\n return this._position ? this._position.latitude : null;\n }\n\n get longitude(): number | null {\n return this._position ? this._position.longitude : null;\n }\n\n get accuracy(): number | null {\n return this._position ? this._position.accuracy : null;\n }\n\n get coords(): WcsGeoCoords | null {\n return this._position ? this._position.coords : null;\n }\n\n get timestamp(): number | null {\n return this._position ? this._position.timestamp : null;\n }\n\n get watching(): boolean {\n return this._watching;\n }\n\n get loading(): boolean {\n return this._loading;\n }\n\n get error(): WcsGeoErrorDetail | null {\n return this._error;\n }\n\n get permission(): GeoPermissionState {\n return this._permission;\n }\n\n /** Resolves once the first (or most recent) permission probe settles (§3.8). */\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // --- State setters with event dispatch ---\n\n private _setPosition(position: WcsGeoPositionDetail): void {\n this._position = position;\n this._target.dispatchEvent(new CustomEvent(\"wcs-geo:position\", {\n detail: position,\n bubbles: true,\n }));\n }\n\n private _setWatching(watching: boolean): void {\n if (this._watching === watching) return;\n this._watching = watching;\n this._target.dispatchEvent(new CustomEvent(\"wcs-geo:watching-changed\", {\n detail: watching,\n bubbles: true,\n }));\n }\n\n private _setLoading(loading: boolean): void {\n if (this._loading === loading) return;\n this._loading = loading;\n this._target.dispatchEvent(new CustomEvent(\"wcs-geo:loading-changed\", {\n detail: loading,\n bubbles: true,\n }));\n }\n\n private _setError(error: WcsGeoErrorDetail | null): void {\n // Same-value guard, like the other setters. Unlike `position` (which has\n // derived getters and so must re-fire even on an identical reference), `error`\n // has no derived state — so suppressing redundant null→null dispatches (e.g.\n // a successful fix clearing an already-null error) avoids spurious events.\n if (this._error === error) return;\n this._error = error;\n this._target.dispatchEvent(new CustomEvent(\"wcs-geo:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n private _setPermission(permission: GeoPermissionState): void {\n if (this._permission === permission) return;\n this._permission = permission;\n this._target.dispatchEvent(new CustomEvent(\"wcs-geo:permission-changed\", {\n detail: permission,\n bubbles: true,\n }));\n }\n\n // --- Public API ---\n\n /**\n * Acquire a single position fix. Resolves once the fix arrives or the request\n * fails — never rejects: failures are surfaced through the `error` property so\n * they flow into the declarative state, symmetrical with FetchCore.\n */\n getCurrentPosition(options: GeoOptions = {}): Promise<void> {\n return new Promise<void>((resolve) => {\n if (!this._hasGeolocation()) {\n this._setError(this._unsupportedError());\n resolve();\n return;\n }\n\n const gen = this._acqGen;\n this._setLoading(true);\n this._setError(null);\n navigator.geolocation.getCurrentPosition(\n (pos) => {\n // Stale: the element was disposed (disconnected) while this fix was in\n // flight. Drop it so a torn-down element never dispatches wcs-geo:*.\n // Still resolve() so any awaiter (e.g. connectedCallbackPromise) settles.\n if (gen !== this._acqGen) {\n resolve();\n return;\n }\n // Guard normalization/dispatch so a throw never escapes this browser\n // callback as an unhandled rejection, leaves the promise pending (which\n // would hang SSR's connectedCallbackPromise), or leaves `loading` stuck\n // true. Loading is cleared first so it holds even if a later step throws.\n try {\n this._setLoading(false);\n this._setPosition(this._normalizePosition(pos));\n } catch {\n // Surface the unexpected failure as an error so observers are not left\n // silently stale, then resolve below.\n this._setError(this._unexpectedError());\n }\n resolve();\n },\n (err) => {\n if (gen !== this._acqGen) {\n resolve();\n return;\n }\n try {\n this._setLoading(false);\n this._setError(this._normalizeError(err));\n } catch {\n this._setError(this._unexpectedError());\n }\n resolve();\n },\n options,\n );\n });\n }\n\n /**\n * Begin continuously watching the position. Idempotent while already\n * watching: a redundant watch() must not register a second `watchPosition`\n * (which would leak the handle and double the fix rate). Reconfiguring is done\n * via clearWatch() + watch().\n */\n watch(options: GeoOptions = {}): void {\n if (!this._hasGeolocation()) {\n this._setError(this._unsupportedError());\n return;\n }\n if (this._watching) return;\n\n this._setError(null);\n this._setWatching(true);\n // Open a new watch generation so any queued callback from a prior watch\n // (cleared then restarted) is recognized as stale below.\n const wgen = ++this._watchGen;\n this._watchId = navigator.geolocation.watchPosition(\n (pos) => {\n // Stale: this callback belongs to a watch that was cleared (or the element\n // disposed), possibly already superseded by a restart. A live\n // `_watchId === null` check cannot catch the restart case (the new watch\n // re-populates _watchId), so compare the captured generation instead.\n if (wgen !== this._watchGen) return;\n // Guard normalization/dispatch so an unexpected throw never escapes this\n // browser callback as an unhandled rejection — symmetric with the one-shot\n // path.\n try {\n // A recovered fix clears any prior transient error (e.g. a one-off\n // TIMEOUT) so `error` reflects the current state, not a stale failure.\n // The _setError same-value guard makes this free when error is already\n // null.\n this._setError(null);\n this._setPosition(this._normalizePosition(pos));\n } catch {\n this._setError(this._unexpectedError());\n }\n },\n (err) => {\n if (wgen !== this._watchGen) return;\n // An error does not implicitly release the watch — the watchId stays\n // valid and clearWatch() remains the teardown path — so `watching` is\n // left true to reflect \"watch still registered\". A terminal error (e.g.\n // PERMISSION_DENIED) is surfaced via the `error` property; callers that\n // want to stop on error can call clearWatch() in response.\n try {\n this._setError(this._normalizeError(err));\n } catch {\n this._setError(this._unexpectedError());\n }\n },\n options,\n );\n }\n\n clearWatch(): void {\n if (this._watchId !== null) {\n navigator.geolocation.clearWatch(this._watchId);\n this._watchId = null;\n }\n // Invalidate the current watch generation so any callback the browser may\n // still deliver after teardown bails.\n this._watchGen++;\n this._setWatching(false);\n }\n\n /**\n * Establish permission monitoring (§3.5). Idempotent: a no-op while a\n * subscription is already live (so the first connect after construction does\n * not double-subscribe), and re-subscribes after a dispose() — e.g. the Shell\n * element was disconnected and then reconnected (reparented). Returns the\n * `ready` promise, which resolves once the (re)established probe settles, so\n * the Shell can expose it as connectedCallbackPromise for SSR. Position\n * acquisition (one-shot / watch) is command-driven and the Shell drives it\n * separately from connectedCallback.\n */\n observe(): Promise<void> {\n if (!this._permissionSubscribed) {\n this._ready = this._initPermission();\n }\n return this._ready;\n }\n\n /**\n * Re-establish the permission `change` subscription after a dispose() — e.g.\n * the Shell element was disconnected and then reconnected (reparented). No-op\n * while a subscription is already live, so the first connect after\n * construction does not double-subscribe. This keeps permission tracking\n * symmetric with position acquisition, which the Shell also revives on\n * reconnect.\n *\n * Retained as a thin alias of observe() for the Shell's existing reconnect\n * path; observe() is the canonical §3.5 lifecycle entry point.\n */\n reinitPermission(): void {\n void this.observe();\n }\n\n /**\n * Detach the live permission `change` listener. Call from the Shell's\n * `disconnectedCallback` so a removed element does not leak the subscription.\n * A later reconnect can re-subscribe via reinitPermission().\n */\n dispose(): void {\n this._permissionSubscribed = false;\n // Invalidate any in-flight query so its .then() bails instead of attaching a\n // listener after teardown.\n this._permGen++;\n // Invalidate any in-flight one-shot acquisition so its success/error callback\n // bails instead of dispatching on a disconnected element.\n this._acqGen++;\n // Likewise invalidate the watch generation. The Shell already calls\n // clearWatch() before dispose(), but a direct headless dispose() (without a\n // preceding clearWatch) still neutralizes any queued watch callback.\n this._watchGen++;\n // Reset the loading shadow silently (no dispatch on a disposed element). The\n // bailed callback above will not clear it, and leaving it true would let the\n // same-value guard swallow the loading=true edge of the next acquisition after\n // a reconnect.\n this._loading = false;\n if (this._permissionStatus) {\n this._permissionStatus.removeEventListener(\"change\", this._onPermissionChange);\n this._permissionStatus = null;\n }\n }\n\n // --- Internal ---\n\n private _hasGeolocation(): boolean {\n return typeof navigator !== \"undefined\" && !!navigator.geolocation;\n }\n\n private _initPermission(): Promise<void> {\n // The Permissions API is optional. When absent (or it rejects, e.g. some\n // browsers don't accept the \"geolocation\" name), report \"unsupported\" and\n // leave acquisition to fail loudly via the error property if attempted.\n if (typeof navigator === \"undefined\" || !navigator.permissions || typeof navigator.permissions.query !== \"function\") {\n // Route through _setPermission (not a bare assignment) so observers stay in\n // sync with the public state. The same-value guard means no redundant\n // dispatch when the state does not actually change; it does mean a\n // previously-observed \"granted\"/\"denied\" being reinit'd into an environment\n // that lost the Permissions API now correctly notifies observers of the\n // unsupported transition instead of silently overwriting the shadow value.\n this._setPermission(\"unsupported\");\n // No asynchronous probe to await: readiness is immediate.\n return Promise.resolve();\n }\n this._permissionSubscribed = true;\n const gen = ++this._permGen;\n return navigator.permissions.query({ name: \"geolocation\" as PermissionName }).then(\n (status) => {\n // Stale resolution: this query was superseded (rapid reconnect) or the\n // element was disposed while it was in flight. Drop it so only the current\n // subscription attaches a listener.\n if (gen !== this._permGen) return;\n this._permissionStatus = status;\n this._setPermission(status.state as GeoPermissionState);\n status.addEventListener(\"change\", this._onPermissionChange);\n },\n () => {\n if (gen !== this._permGen) return;\n this._setPermission(\"unsupported\");\n },\n );\n }\n\n private _onPermissionChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setPermission(status.state as GeoPermissionState);\n };\n\n private _normalizePosition(pos: GeolocationPosition): WcsGeoPositionDetail {\n const c = pos.coords;\n const coords: WcsGeoCoords = {\n latitude: c.latitude,\n longitude: c.longitude,\n accuracy: c.accuracy,\n altitude: c.altitude,\n altitudeAccuracy: c.altitudeAccuracy,\n heading: c.heading,\n speed: c.speed,\n };\n return { ...coords, timestamp: pos.timestamp, coords };\n }\n\n private _normalizeError(err: GeolocationPositionError): WcsGeoErrorDetail {\n return { code: err.code, message: err.message };\n }\n\n private _unsupportedError(): WcsGeoErrorDetail {\n // Geolocation API absent: surface it as POSITION_UNAVAILABLE (2) so consumers\n // that switch on the spec error codes treat it like any other unavailable fix.\n return { code: 2, message: \"Geolocation API is not available in this environment.\" };\n }\n\n private _unexpectedError(): WcsGeoErrorDetail {\n // An unexpected throw while normalizing/dispatching a fix. Surface it as\n // POSITION_UNAVAILABLE (2) so it flows into `error` like any other failure\n // instead of escaping the browser callback as an unhandled rejection.\n return { code: 2, message: \"Unexpected error while processing the position fix.\" };\n }\n}\n","import { config } from \"./config.js\";\nimport type { WcsGeolocation } from \"./components/Geolocation.js\";\n\nlet registered = false;\n\nfunction handleClick(event: Event): void {\n const target = event.target;\n if (!(target instanceof Element)) return;\n\n const triggerElement = target.closest<Element>(`[${config.triggerAttribute}]`);\n if (!triggerElement) return;\n\n const geoId = triggerElement.getAttribute(config.triggerAttribute);\n if (!geoId) return;\n\n // Resolve the registered constructor at call time instead of importing\n // Geolocation as a value. The value import created a components/Geolocation.ts\n // ⇄ autoTrigger.ts cycle (Geolocation.connectedCallback() calls\n // registerAutoTrigger()). instanceof against the customElements registry keeps\n // the exact same identity guarantee — only the registered <wcs-geo> class\n // matches — without the import cycle.\n const GeoCtor = customElements.get(config.tagNames.geo);\n const geoElement = document.getElementById(geoId);\n if (!GeoCtor || !(geoElement instanceof GeoCtor)) return;\n\n // Suppress the element's default action so a fix can be requested without\n // navigating. Intentional: do not attach data-geotarget to an element whose\n // default action you also want (real <a href> link, form-submit button) — it\n // will be cancelled. See README \"Optional DOM Triggering\".\n event.preventDefault();\n (geoElement as WcsGeolocation).getCurrentPosition();\n}\n\nexport function registerAutoTrigger(): void {\n if (registered) return;\n registered = true;\n document.addEventListener(\"click\", handleClick);\n}\n\nexport function unregisterAutoTrigger(): void {\n if (!registered) return;\n registered = false;\n document.removeEventListener(\"click\", handleClick);\n}\n","import { config } from \"../config.js\";\nimport { IWcBindable, GeoOptions, GeoPermissionState, WcsGeoPositionDetail, WcsGeoCoords, WcsGeoErrorDetail } from \"../types.js\";\nimport { GeolocationCore } from \"../core/GeolocationCore.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\n\n// Named WcsGeolocation (not `Geolocation`) so the class does not shadow the\n// global DOM `Geolocation` interface (the type of `navigator.geolocation`), and\n// to match the <wcs-ws> convention (WcsWebSocket). The public export keeps the\n// `WcsGeolocation` name unchanged, so this rename is non-breaking.\nexport class WcsGeolocation extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...GeolocationCore.wcBindable,\n properties: [\n ...GeolocationCore.wcBindable.properties,\n { name: \"trigger\", event: \"wcs-geo:trigger-changed\" },\n ],\n // Shell-level settable surface. Each input carries its mirrored `attribute`\n // hint (boolean flags reflect idempotently, so a binding system that writes\n // through inputs[].attribute is safe), following the <wcs-ws> convention.\n // `trigger` has no attribute — it is a momentary command-property, not a\n // declarative attribute. The `getCurrentPosition` / `watchPosition` /\n // `clearWatch` commands are declared below.\n inputs: [\n { name: \"highAccuracy\", attribute: \"high-accuracy\" },\n { name: \"timeout\", attribute: \"timeout\" },\n { name: \"maximumAge\", attribute: \"maximum-age\" },\n { name: \"watch\", attribute: \"watch\" },\n { name: \"manual\", attribute: \"manual\" },\n { name: \"trigger\" },\n ],\n // The Core's `watch` command is renamed to `watchPosition` on the Shell so it\n // does not collide with the `watch` boolean attribute accessor (same pattern\n // as <wcs-ws>, where the `send` command becomes `sendMessage` to free the\n // `send` setter). `getCurrentPosition` / `clearWatch` are unchanged.\n commands: [\n { name: \"getCurrentPosition\", async: true },\n { name: \"watchPosition\" },\n { name: \"clearWatch\" },\n ],\n };\n\n private _core: GeolocationCore;\n private _trigger: boolean = false;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new GeolocationCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-geo:watching-changed\": (d) => ({ watching: d === true }),\n \"wcs-geo:loading-changed\": (d) => ({ loading: d === true }),\n \"wcs-geo:error\": (d) => ({ error: d != null }),\n });\n }\n\n // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of\n // wc-bindable (not a bind target); see README \"CSS styling with :state()\".\n // MUST NOT return the live CustomStateSet (that would let callers write\n // states from outside, defeating the point of :state() being read-only).\n get debugStates(): string[] {\n return this._internals ? [...this._internals.states] : [];\n }\n\n private _initInternals(): ElementInternals | null {\n // never-throw (docs/custom-state-reflection-design.md §3.4): attachInternals\n // is absent in happy-dom / older environments, and pre-125 Chromium rejects\n // non-dashed state names from states.add() (probed and discarded here).\n // Either case silently disables reflection — the component still works, it\n // just doesn't expose :state() selectors.\n try {\n if (typeof this.attachInternals !== \"function\") return null;\n const internals = this.attachInternals();\n internals.states.add(\"wcs-probe\");\n internals.states.delete(\"wcs-probe\");\n return internals;\n } catch {\n return null;\n }\n }\n\n private _wireStates(map: Record<string, (detail: any) => Record<string, boolean>>): void {\n if (this._internals === null) return;\n const states = this._internals.states;\n for (const [event, toStates] of Object.entries(map)) {\n this.addEventListener(event, (e) => {\n const debug = this.hasAttribute(\"debug-states\");\n for (const [name, on] of Object.entries(toStates((e as CustomEvent).detail))) {\n try {\n if (on) { states.add(name); } else { states.delete(name); }\n } catch { /* never-throw */ }\n if (debug) this.toggleAttribute(`data-wcs-state-${name}`, on);\n }\n });\n }\n }\n\n // --- Attribute accessors ---\n\n get highAccuracy(): boolean {\n return this.hasAttribute(\"high-accuracy\");\n }\n\n set highAccuracy(value: boolean) {\n if (value) {\n this.setAttribute(\"high-accuracy\", \"\");\n } else {\n this.removeAttribute(\"high-accuracy\");\n }\n }\n\n get timeout(): number {\n const attr = this.getAttribute(\"timeout\");\n if (attr === null || attr.trim() === \"\") return Infinity;\n // Strict parse via Number() (unlike parseInt, \"10px\" -> NaN, not 10). Fall\n // back to the API default (Infinity = no timeout) for any non-finite or\n // negative value, matching the README \"invalid values fall back to default\".\n const parsed = Number(attr);\n return Number.isFinite(parsed) && parsed >= 0 ? parsed : Infinity;\n }\n\n set timeout(value: number) {\n this.setAttribute(\"timeout\", String(value));\n }\n\n get maximumAge(): number {\n const attr = this.getAttribute(\"maximum-age\");\n if (attr === null || attr.trim() === \"\") return 0;\n // Strict parse via Number() (unlike parseInt, \"10px\" -> NaN, not 10). Fall\n // back to the API default (0 = never use a cached fix) for any non-finite or\n // negative value, matching the README \"invalid values fall back to default\".\n const parsed = Number(attr);\n return Number.isFinite(parsed) && parsed >= 0 ? parsed : 0;\n }\n\n set maximumAge(value: number) {\n this.setAttribute(\"maximum-age\", String(value));\n }\n\n get watch(): boolean {\n return this.hasAttribute(\"watch\");\n }\n\n set watch(value: boolean) {\n if (value) {\n this.setAttribute(\"watch\", \"\");\n } else {\n this.removeAttribute(\"watch\");\n }\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 position(): WcsGeoPositionDetail | null {\n return this._core.position;\n }\n\n get latitude(): number | null {\n return this._core.latitude;\n }\n\n get longitude(): number | null {\n return this._core.longitude;\n }\n\n get accuracy(): number | null {\n return this._core.accuracy;\n }\n\n get coords(): WcsGeoCoords | null {\n return this._core.coords;\n }\n\n get timestamp(): number | null {\n return this._core.timestamp;\n }\n\n get watching(): boolean {\n return this._core.watching;\n }\n\n get loading(): boolean {\n return this._core.loading;\n }\n\n get error(): WcsGeoErrorDetail | null {\n return this._core.error;\n }\n\n get permission(): GeoPermissionState {\n return this._core.permission;\n }\n\n // wc-bindable connectedCallbackPromise protocol: resolves once the connect-time\n // acquisition settles, so SSR (@wcstack/server render.ts) waits for the first\n // fix before snapshotting the HTML. Mirrors Fetch.connectedCallbackPromise. In\n // `watch` / `manual` modes there is no one-shot connect-time fix to await, so it\n // stays the default resolved promise.\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Command property ---\n\n get trigger(): boolean {\n return this._trigger;\n }\n\n set trigger(value: boolean) {\n // Momentary command-property: a false→true write requests a single fix.\n // Mirrors the trigger flag on <wcs-timer> / <wcs-ws>. Prefer the\n // command-token protocol (`command.getCurrentPosition: $command.locate`) for\n // state-driven acquisition; this exists mainly for the DOM click trigger and\n // simple boolean bindings.\n const v = !!value;\n if (v) {\n this._trigger = true;\n // Fire-and-forget: getCurrentPosition() never rejects (failures surface via\n // the `error` property), so the returned promise is intentionally dropped.\n void this.getCurrentPosition();\n this._trigger = false;\n this.dispatchEvent(new CustomEvent(\"wcs-geo:trigger-changed\", {\n detail: false,\n bubbles: true,\n }));\n }\n }\n\n // --- Commands ---\n\n getCurrentPosition(): Promise<void> {\n return this._core.getCurrentPosition(this._options());\n }\n\n watchPosition(): void {\n this._core.watch(this._options());\n }\n\n clearWatch(): void {\n this._core.clearWatch();\n }\n\n // --- Internal ---\n\n private _options(): GeoOptions {\n return {\n enableHighAccuracy: this.highAccuracy,\n timeout: this.timeout,\n maximumAge: this.maximumAge,\n };\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n this.style.display = \"none\";\n if (config.autoTrigger) {\n registerAutoTrigger();\n }\n // Revive permission tracking after a reconnect (reparenting). No-op on the\n // first connect since the constructor already subscribed; only re-subscribes\n // when disconnectedCallback's dispose() tore the subscription down.\n this._core.reinitPermission();\n if (!this.manual) {\n // `watch` attribute selects the default phase: continuous monitoring vs a\n // single fix on connect.\n if (this.watch) {\n this.watchPosition();\n } else {\n // Track only the one-shot connect-time fix so SSR can await it. watch /\n // manual leave the promise at its resolved default. getCurrentPosition()\n // never rejects (failures surface via `error`), so no .catch() is needed.\n this._connectedCallbackPromise = this.getCurrentPosition();\n }\n }\n }\n\n disconnectedCallback(): void {\n this._core.clearWatch();\n this._core.dispose();\n }\n}\n","import { WcsGeolocation } from \"./components/Geolocation.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.geo)) {\n customElements.define(config.tagNames.geo, WcsGeolocation);\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapGeolocation(userConfig?: IWritableConfig): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents();\n}\n"],"names":[],"mappings":"AAUA,MAAM,OAAO,GAAoB;AAC/B,IAA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,UAAU,EAAE;IACzB;;IAIQ,QAAQ,GAAA;QACd,OAAO;YACL,kBAAkB,EAAE,IAAI,CAAC,YAAY;YACrC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,UAAU,EAAE,IAAI,CAAC,UAAU;SAC5B;IACH;;IAIA,iBAAiB,GAAA;AACf,QAAA,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM;AAC3B,QAAA,IAAI,MAAM,CAAC,WAAW,EAAE;AACtB,YAAA,mBAAmB,EAAE;QACvB;;;;AAIA,QAAA,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE;AAC7B,QAAA,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;;;AAGhB,YAAA,IAAI,IAAI,CAAC,KAAK,EAAE;gBACd,IAAI,CAAC,aAAa,EAAE;YACtB;iBAAO;;;;AAIL,gBAAA,IAAI,CAAC,yBAAyB,GAAG,IAAI,CAAC,kBAAkB,EAAE;YAC5D;QACF;IACF;IAEA,oBAAoB,GAAA;AAClB,QAAA,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE;AACvB,QAAA,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;IACtB;;;SCnSc,kBAAkB,GAAA;AAChC,IAAA,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QAC5C,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,cAAc,CAAC;IAC5D;AACF;;ACHM,SAAU,oBAAoB,CAAC,UAA4B,EAAA;IAC/D,IAAI,UAAU,EAAE;QACd,SAAS,CAAC,UAAU,CAAC;IACvB;AACA,IAAA,kBAAkB,EAAE;AACtB;;;;"}
|
package/dist/index.esm.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const t={autoTrigger:!0,triggerAttribute:"data-geotarget",tagNames:{geo:"wcs-geo"}};function e(t){if(null===t||"object"!=typeof t)return t;Object.freeze(t);for(const i of Object.keys(t))e(t[i]);return t}function i(t){if(null===t||"object"!=typeof t)return t;const e={};for(const
|
|
1
|
+
const t={autoTrigger:!0,triggerAttribute:"data-geotarget",tagNames:{geo:"wcs-geo"}};function e(t){if(null===t||"object"!=typeof t)return t;Object.freeze(t);for(const i of Object.keys(t))e(t[i]);return t}function i(t){if(null===t||"object"!=typeof t)return t;const e={};for(const s of Object.keys(t))e[s]=i(t[s]);return e}let s=null;const r=t;function n(){return s||(s=e(i(t))),s}class o extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"position",event:"wcs-geo:position"},{name:"latitude",event:"wcs-geo:position",getter:t=>t.detail.latitude},{name:"longitude",event:"wcs-geo:position",getter:t=>t.detail.longitude},{name:"accuracy",event:"wcs-geo:position",getter:t=>t.detail.accuracy},{name:"coords",event:"wcs-geo:position",getter:t=>t.detail.coords},{name:"timestamp",event:"wcs-geo:position",getter:t=>t.detail.timestamp},{name:"watching",event:"wcs-geo:watching-changed"},{name:"loading",event:"wcs-geo:loading-changed"},{name:"error",event:"wcs-geo:error"},{name:"permission",event:"wcs-geo:permission-changed"}],commands:[{name:"getCurrentPosition",async:!0},{name:"watch"},{name:"clearWatch"}]};_target;_watchId=null;_position=null;_watching=!1;_loading=!1;_error=null;_permission="prompt";_permissionStatus=null;_permissionSubscribed=!1;_permGen=0;_acqGen=0;_watchGen=0;_ready=Promise.resolve();constructor(t){super(),this._target=t??this,this._ready=this._initPermission()}get position(){return this._position}get latitude(){return this._position?this._position.latitude:null}get longitude(){return this._position?this._position.longitude:null}get accuracy(){return this._position?this._position.accuracy:null}get coords(){return this._position?this._position.coords:null}get timestamp(){return this._position?this._position.timestamp:null}get watching(){return this._watching}get loading(){return this._loading}get error(){return this._error}get permission(){return this._permission}get ready(){return this._ready}_setPosition(t){this._position=t,this._target.dispatchEvent(new CustomEvent("wcs-geo:position",{detail:t,bubbles:!0}))}_setWatching(t){this._watching!==t&&(this._watching=t,this._target.dispatchEvent(new CustomEvent("wcs-geo:watching-changed",{detail:t,bubbles:!0})))}_setLoading(t){this._loading!==t&&(this._loading=t,this._target.dispatchEvent(new CustomEvent("wcs-geo:loading-changed",{detail:t,bubbles:!0})))}_setError(t){this._error!==t&&(this._error=t,this._target.dispatchEvent(new CustomEvent("wcs-geo:error",{detail:t,bubbles:!0})))}_setPermission(t){this._permission!==t&&(this._permission=t,this._target.dispatchEvent(new CustomEvent("wcs-geo:permission-changed",{detail:t,bubbles:!0})))}getCurrentPosition(t={}){return new Promise(e=>{if(!this._hasGeolocation())return this._setError(this._unsupportedError()),void e();const i=this._acqGen;this._setLoading(!0),this._setError(null),navigator.geolocation.getCurrentPosition(t=>{if(i===this._acqGen){try{this._setLoading(!1),this._setPosition(this._normalizePosition(t))}catch{this._setError(this._unexpectedError())}e()}else e()},t=>{if(i===this._acqGen){try{this._setLoading(!1),this._setError(this._normalizeError(t))}catch{this._setError(this._unexpectedError())}e()}else e()},t)})}watch(t={}){if(!this._hasGeolocation())return void this._setError(this._unsupportedError());if(this._watching)return;this._setError(null),this._setWatching(!0);const e=++this._watchGen;this._watchId=navigator.geolocation.watchPosition(t=>{if(e===this._watchGen)try{this._setError(null),this._setPosition(this._normalizePosition(t))}catch{this._setError(this._unexpectedError())}},t=>{if(e===this._watchGen)try{this._setError(this._normalizeError(t))}catch{this._setError(this._unexpectedError())}},t)}clearWatch(){null!==this._watchId&&(navigator.geolocation.clearWatch(this._watchId),this._watchId=null),this._watchGen++,this._setWatching(!1)}observe(){return this._permissionSubscribed||(this._ready=this._initPermission()),this._ready}reinitPermission(){this.observe()}dispose(){this._permissionSubscribed=!1,this._permGen++,this._acqGen++,this._watchGen++,this._loading=!1,this._permissionStatus&&(this._permissionStatus.removeEventListener("change",this._onPermissionChange),this._permissionStatus=null)}_hasGeolocation(){return"undefined"!=typeof navigator&&!!navigator.geolocation}_initPermission(){if("undefined"==typeof navigator||!navigator.permissions||"function"!=typeof navigator.permissions.query)return this._setPermission("unsupported"),Promise.resolve();this._permissionSubscribed=!0;const t=++this._permGen;return navigator.permissions.query({name:"geolocation"}).then(e=>{t===this._permGen&&(this._permissionStatus=e,this._setPermission(e.state),e.addEventListener("change",this._onPermissionChange))},()=>{t===this._permGen&&this._setPermission("unsupported")})}_onPermissionChange=t=>{const e=t.target;this._setPermission(e.state)};_normalizePosition(t){const e=t.coords,i={latitude:e.latitude,longitude:e.longitude,accuracy:e.accuracy,altitude:e.altitude,altitudeAccuracy:e.altitudeAccuracy,heading:e.heading,speed:e.speed};return{...i,timestamp:t.timestamp,coords:i}}_normalizeError(t){return{code:t.code,message:t.message}}_unsupportedError(){return{code:2,message:"Geolocation API is not available in this environment."}}_unexpectedError(){return{code:2,message:"Unexpected error while processing the position fix."}}}let a=!1;function c(t){const e=t.target;if(!(e instanceof Element))return;const i=e.closest(`[${r.triggerAttribute}]`);if(!i)return;const s=i.getAttribute(r.triggerAttribute);if(!s)return;const n=customElements.get(r.tagNames.geo),o=document.getElementById(s);n&&o instanceof n&&(t.preventDefault(),o.getCurrentPosition())}class h extends HTMLElement{static hasConnectedCallbackPromise=!0;static wcBindable={...o.wcBindable,properties:[...o.wcBindable.properties,{name:"trigger",event:"wcs-geo:trigger-changed"}],inputs:[{name:"highAccuracy",attribute:"high-accuracy"},{name:"timeout",attribute:"timeout"},{name:"maximumAge",attribute:"maximum-age"},{name:"watch",attribute:"watch"},{name:"manual",attribute:"manual"},{name:"trigger"}],commands:[{name:"getCurrentPosition",async:!0},{name:"watchPosition"},{name:"clearWatch"}]};_core;_trigger=!1;_connectedCallbackPromise=Promise.resolve();_internals=null;constructor(){super(),this._core=new o(this),this._internals=this._initInternals(),this._wireStates({"wcs-geo:watching-changed":t=>({watching:!0===t}),"wcs-geo:loading-changed":t=>({loading:!0===t}),"wcs-geo:error":t=>({error:null!=t})})}get debugStates(){return this._internals?[...this._internals.states]:[]}_initInternals(){try{if("function"!=typeof this.attachInternals)return null;const t=this.attachInternals();return t.states.add("wcs-probe"),t.states.delete("wcs-probe"),t}catch{return null}}_wireStates(t){if(null===this._internals)return;const e=this._internals.states;for(const[i,s]of Object.entries(t))this.addEventListener(i,t=>{const i=this.hasAttribute("debug-states");for(const[r,n]of Object.entries(s(t.detail))){try{n?e.add(r):e.delete(r)}catch{}i&&this.toggleAttribute(`data-wcs-state-${r}`,n)}})}get highAccuracy(){return this.hasAttribute("high-accuracy")}set highAccuracy(t){t?this.setAttribute("high-accuracy",""):this.removeAttribute("high-accuracy")}get timeout(){const t=this.getAttribute("timeout");if(null===t||""===t.trim())return 1/0;const e=Number(t);return Number.isFinite(e)&&e>=0?e:1/0}set timeout(t){this.setAttribute("timeout",String(t))}get maximumAge(){const t=this.getAttribute("maximum-age");if(null===t||""===t.trim())return 0;const e=Number(t);return Number.isFinite(e)&&e>=0?e:0}set maximumAge(t){this.setAttribute("maximum-age",String(t))}get watch(){return this.hasAttribute("watch")}set watch(t){t?this.setAttribute("watch",""):this.removeAttribute("watch")}get manual(){return this.hasAttribute("manual")}set manual(t){t?this.setAttribute("manual",""):this.removeAttribute("manual")}get position(){return this._core.position}get latitude(){return this._core.latitude}get longitude(){return this._core.longitude}get accuracy(){return this._core.accuracy}get coords(){return this._core.coords}get timestamp(){return this._core.timestamp}get watching(){return this._core.watching}get loading(){return this._core.loading}get error(){return this._core.error}get permission(){return this._core.permission}get connectedCallbackPromise(){return this._connectedCallbackPromise}get trigger(){return this._trigger}set trigger(t){!!t&&(this._trigger=!0,this.getCurrentPosition(),this._trigger=!1,this.dispatchEvent(new CustomEvent("wcs-geo:trigger-changed",{detail:!1,bubbles:!0})))}getCurrentPosition(){return this._core.getCurrentPosition(this._options())}watchPosition(){this._core.watch(this._options())}clearWatch(){this._core.clearWatch()}_options(){return{enableHighAccuracy:this.highAccuracy,timeout:this.timeout,maximumAge:this.maximumAge}}connectedCallback(){this.style.display="none",r.autoTrigger&&(a||(a=!0,document.addEventListener("click",c))),this._core.reinitPermission(),this.manual||(this.watch?this.watchPosition():this._connectedCallbackPromise=this.getCurrentPosition())}disconnectedCallback(){this._core.clearWatch(),this._core.dispose()}}function u(e){var i;e&&("boolean"==typeof(i=e).autoTrigger&&(t.autoTrigger=i.autoTrigger),"string"==typeof i.triggerAttribute&&(t.triggerAttribute=i.triggerAttribute),i.tagNames&&Object.assign(t.tagNames,i.tagNames),s=null),customElements.get(r.tagNames.geo)||customElements.define(r.tagNames.geo,h)}export{o as GeolocationCore,h as WcsGeolocation,u as bootstrapGeolocation,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/GeolocationCore.ts","../src/autoTrigger.ts","../src/components/Geolocation.ts","../src/bootstrapGeolocation.ts","../src/registerComponents.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n autoTrigger: boolean;\n triggerAttribute: string;\n tagNames: {\n geo: string;\n };\n}\n\nconst _config: IInternalConfig = {\n autoTrigger: true,\n triggerAttribute: \"data-geotarget\",\n tagNames: {\n geo: \"wcs-geo\",\n },\n};\n\nfunction deepFreeze<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n Object.freeze(obj);\n for (const key of Object.keys(obj)) {\n deepFreeze((obj as Record<string, unknown>)[key]);\n }\n return obj;\n}\n\nfunction deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n const clone: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n clone[key] = deepClone((obj as Record<string, unknown>)[key]);\n }\n return clone as T;\n}\n\nlet frozenConfig: IConfig | null = null;\n\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\nexport function setConfig(partialConfig: IWritableConfig): void {\n if (typeof partialConfig.autoTrigger === \"boolean\") {\n _config.autoTrigger = partialConfig.autoTrigger;\n }\n if (typeof partialConfig.triggerAttribute === \"string\") {\n _config.triggerAttribute = partialConfig.triggerAttribute;\n }\n if (partialConfig.tagNames) {\n Object.assign(_config.tagNames, partialConfig.tagNames);\n }\n frozenConfig = null;\n}\n","import {\n IWcBindable, GeoOptions, GeoPermissionState,\n WcsGeoPositionDetail, WcsGeoCoords, WcsGeoErrorDetail,\n} from \"../types.js\";\n\n/**\n * Headless geolocation primitive. A thin, framework-agnostic wrapper around the\n * Geolocation API exposed through the wc-bindable protocol.\n *\n * It has two phases, mirroring the two distinct shapes of the underlying API:\n * - **one-shot** — `getCurrentPosition()` resolves a single fix (like FetchCore's\n * one-shot `fetch()`), toggling `loading` around the async call.\n * - **continuous** — `watch()` / `clearWatch()` stream fixes (like TimerCore's\n * `start()` / `stop()`), toggling the `watching` flag.\n *\n * Every successful fix is published via the single `wcs-geo:position` event;\n * `latitude` / `longitude` / `accuracy` / `coords` / `timestamp` are read from\n * it through getters (mirroring how TimerCore exposes count/elapsed from one\n * `wcs-timer:tick` event), so an observer that binds any of them is notified on\n * every fix.\n *\n * Geolocation also has a permission gate absent from timer/websocket: the\n * `permission` property reflects `navigator.permissions.query({name:\n * \"geolocation\"})` (`prompt` / `granted` / `denied`, or `unsupported`) and\n * tracks its live `change` event. It is a read-only sensor — there is no\n * element-bound \"send\" path; element → state only.\n */\nexport class GeolocationCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"position\", event: \"wcs-geo:position\" },\n { name: \"latitude\", event: \"wcs-geo:position\", getter: (e: Event) => (e as CustomEvent).detail.latitude },\n { name: \"longitude\", event: \"wcs-geo:position\", getter: (e: Event) => (e as CustomEvent).detail.longitude },\n { name: \"accuracy\", event: \"wcs-geo:position\", getter: (e: Event) => (e as CustomEvent).detail.accuracy },\n { name: \"coords\", event: \"wcs-geo:position\", getter: (e: Event) => (e as CustomEvent).detail.coords },\n { name: \"timestamp\", event: \"wcs-geo:position\", getter: (e: Event) => (e as CustomEvent).detail.timestamp },\n { name: \"watching\", event: \"wcs-geo:watching-changed\" },\n { name: \"loading\", event: \"wcs-geo:loading-changed\" },\n { name: \"error\", event: \"wcs-geo:error\" },\n { name: \"permission\", event: \"wcs-geo:permission-changed\" },\n ],\n commands: [\n { name: \"getCurrentPosition\", async: true },\n { name: \"watch\" },\n { name: \"clearWatch\" },\n ],\n };\n\n private _target: EventTarget;\n private _watchId: number | null = null;\n\n private _position: WcsGeoPositionDetail | null = null;\n private _watching: boolean = false;\n private _loading: boolean = false;\n private _error: WcsGeoErrorDetail | null = null;\n private _permission: GeoPermissionState = \"prompt\";\n\n // Live PermissionStatus handle (when the Permissions API is available), kept\n // so the `change` listener can be removed on dispose().\n private _permissionStatus: PermissionStatus | null = null;\n\n // True once a permission subscription has been (or is being) established, and\n // reset by dispose(). Guards reinitPermission() so the first connect after\n // construction does not double-subscribe, while a reconnect after dispose()\n // does re-subscribe.\n private _permissionSubscribed: boolean = false;\n\n // Monotonic id of the current permission query. Bumped by every _initPermission()\n // and by dispose(). Each in-flight query captures its id and, on resolve, bails\n // unless it is still current — so a query superseded by a rapid (synchronous)\n // disconnect→reconnect, or one that resolves after dispose(), never attaches a\n // listener. A plain boolean cannot cover this: dispose()→reinit() flips it\n // false→true again, reopening the window for the stale query to slip through.\n private _permGen: number = 0;\n\n // Monotonic id of the current acquisition lifecycle, bumped only by dispose().\n // Each getCurrentPosition() captures it at start; the async success/error\n // callback bails (no setters, no resolve-side effects) if it is stale, so a\n // one-shot fix that resolves after the element was disconnected does not\n // dispatch wcs-geo:* on a torn-down element. Unlike FetchCore, the Geolocation\n // API has no AbortController, so a generation guard is the only way to neutralize\n // an in-flight one-shot. (watch is already stopped by clearWatch on disconnect.)\n private _acqGen: number = 0;\n\n // Monotonic id of the current watch lifecycle, bumped by watch(), clearWatch(),\n // and dispose(). Each watch() captures it; both watch callbacks bail if it is\n // stale. Unlike a live `_watchId === null` check, this distinguishes the current\n // watch from a superseded one: a clearWatch()→watch() restart installs a new\n // watchId (non-null), so a queued callback from the previous watch would pass a\n // null-check but fails the generation compare. (The README recommends exactly\n // this restart sequence to reconfigure a watch.)\n private _watchGen: number = 0;\n\n // Resolves once the most recent permission probe settles (or immediately when\n // the Permissions API is unsupported). The Shell exposes this as\n // connectedCallbackPromise so SSR can await the first probe before snapshotting\n // the HTML. Mirrors PermissionCore._ready.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n // Probe the permission state up front so observers see the real value\n // (granted/denied/prompt) before the first read, then keep it live.\n this._ready = this._initPermission();\n }\n\n get position(): WcsGeoPositionDetail | null {\n return this._position;\n }\n\n get latitude(): number | null {\n return this._position ? this._position.latitude : null;\n }\n\n get longitude(): number | null {\n return this._position ? this._position.longitude : null;\n }\n\n get accuracy(): number | null {\n return this._position ? this._position.accuracy : null;\n }\n\n get coords(): WcsGeoCoords | null {\n return this._position ? this._position.coords : null;\n }\n\n get timestamp(): number | null {\n return this._position ? this._position.timestamp : null;\n }\n\n get watching(): boolean {\n return this._watching;\n }\n\n get loading(): boolean {\n return this._loading;\n }\n\n get error(): WcsGeoErrorDetail | null {\n return this._error;\n }\n\n get permission(): GeoPermissionState {\n return this._permission;\n }\n\n /** Resolves once the first (or most recent) permission probe settles (§3.8). */\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // --- State setters with event dispatch ---\n\n private _setPosition(position: WcsGeoPositionDetail): void {\n this._position = position;\n this._target.dispatchEvent(new CustomEvent(\"wcs-geo:position\", {\n detail: position,\n bubbles: true,\n }));\n }\n\n private _setWatching(watching: boolean): void {\n if (this._watching === watching) return;\n this._watching = watching;\n this._target.dispatchEvent(new CustomEvent(\"wcs-geo:watching-changed\", {\n detail: watching,\n bubbles: true,\n }));\n }\n\n private _setLoading(loading: boolean): void {\n if (this._loading === loading) return;\n this._loading = loading;\n this._target.dispatchEvent(new CustomEvent(\"wcs-geo:loading-changed\", {\n detail: loading,\n bubbles: true,\n }));\n }\n\n private _setError(error: WcsGeoErrorDetail | null): void {\n // Same-value guard, like the other setters. Unlike `position` (which has\n // derived getters and so must re-fire even on an identical reference), `error`\n // has no derived state — so suppressing redundant null→null dispatches (e.g.\n // a successful fix clearing an already-null error) avoids spurious events.\n if (this._error === error) return;\n this._error = error;\n this._target.dispatchEvent(new CustomEvent(\"wcs-geo:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n private _setPermission(permission: GeoPermissionState): void {\n if (this._permission === permission) return;\n this._permission = permission;\n this._target.dispatchEvent(new CustomEvent(\"wcs-geo:permission-changed\", {\n detail: permission,\n bubbles: true,\n }));\n }\n\n // --- Public API ---\n\n /**\n * Acquire a single position fix. Resolves once the fix arrives or the request\n * fails — never rejects: failures are surfaced through the `error` property so\n * they flow into the declarative state, symmetrical with FetchCore.\n */\n getCurrentPosition(options: GeoOptions = {}): Promise<void> {\n return new Promise<void>((resolve) => {\n if (!this._hasGeolocation()) {\n this._setError(this._unsupportedError());\n resolve();\n return;\n }\n\n const gen = this._acqGen;\n this._setLoading(true);\n this._setError(null);\n navigator.geolocation.getCurrentPosition(\n (pos) => {\n // Stale: the element was disposed (disconnected) while this fix was in\n // flight. Drop it so a torn-down element never dispatches wcs-geo:*.\n // Still resolve() so any awaiter (e.g. connectedCallbackPromise) settles.\n if (gen !== this._acqGen) {\n resolve();\n return;\n }\n // Guard normalization/dispatch so a throw never escapes this browser\n // callback as an unhandled rejection, leaves the promise pending (which\n // would hang SSR's connectedCallbackPromise), or leaves `loading` stuck\n // true. Loading is cleared first so it holds even if a later step throws.\n try {\n this._setLoading(false);\n this._setPosition(this._normalizePosition(pos));\n } catch {\n // Surface the unexpected failure as an error so observers are not left\n // silently stale, then resolve below.\n this._setError(this._unexpectedError());\n }\n resolve();\n },\n (err) => {\n if (gen !== this._acqGen) {\n resolve();\n return;\n }\n try {\n this._setLoading(false);\n this._setError(this._normalizeError(err));\n } catch {\n this._setError(this._unexpectedError());\n }\n resolve();\n },\n options,\n );\n });\n }\n\n /**\n * Begin continuously watching the position. Idempotent while already\n * watching: a redundant watch() must not register a second `watchPosition`\n * (which would leak the handle and double the fix rate). Reconfiguring is done\n * via clearWatch() + watch().\n */\n watch(options: GeoOptions = {}): void {\n if (!this._hasGeolocation()) {\n this._setError(this._unsupportedError());\n return;\n }\n if (this._watching) return;\n\n this._setError(null);\n this._setWatching(true);\n // Open a new watch generation so any queued callback from a prior watch\n // (cleared then restarted) is recognized as stale below.\n const wgen = ++this._watchGen;\n this._watchId = navigator.geolocation.watchPosition(\n (pos) => {\n // Stale: this callback belongs to a watch that was cleared (or the element\n // disposed), possibly already superseded by a restart. A live\n // `_watchId === null` check cannot catch the restart case (the new watch\n // re-populates _watchId), so compare the captured generation instead.\n if (wgen !== this._watchGen) return;\n // Guard normalization/dispatch so an unexpected throw never escapes this\n // browser callback as an unhandled rejection — symmetric with the one-shot\n // path.\n try {\n // A recovered fix clears any prior transient error (e.g. a one-off\n // TIMEOUT) so `error` reflects the current state, not a stale failure.\n // The _setError same-value guard makes this free when error is already\n // null.\n this._setError(null);\n this._setPosition(this._normalizePosition(pos));\n } catch {\n this._setError(this._unexpectedError());\n }\n },\n (err) => {\n if (wgen !== this._watchGen) return;\n // An error does not implicitly release the watch — the watchId stays\n // valid and clearWatch() remains the teardown path — so `watching` is\n // left true to reflect \"watch still registered\". A terminal error (e.g.\n // PERMISSION_DENIED) is surfaced via the `error` property; callers that\n // want to stop on error can call clearWatch() in response.\n try {\n this._setError(this._normalizeError(err));\n } catch {\n this._setError(this._unexpectedError());\n }\n },\n options,\n );\n }\n\n clearWatch(): void {\n if (this._watchId !== null) {\n navigator.geolocation.clearWatch(this._watchId);\n this._watchId = null;\n }\n // Invalidate the current watch generation so any callback the browser may\n // still deliver after teardown bails.\n this._watchGen++;\n this._setWatching(false);\n }\n\n /**\n * Establish permission monitoring (§3.5). Idempotent: a no-op while a\n * subscription is already live (so the first connect after construction does\n * not double-subscribe), and re-subscribes after a dispose() — e.g. the Shell\n * element was disconnected and then reconnected (reparented). Returns the\n * `ready` promise, which resolves once the (re)established probe settles, so\n * the Shell can expose it as connectedCallbackPromise for SSR. Position\n * acquisition (one-shot / watch) is command-driven and the Shell drives it\n * separately from connectedCallback.\n */\n observe(): Promise<void> {\n if (!this._permissionSubscribed) {\n this._ready = this._initPermission();\n }\n return this._ready;\n }\n\n /**\n * Re-establish the permission `change` subscription after a dispose() — e.g.\n * the Shell element was disconnected and then reconnected (reparented). No-op\n * while a subscription is already live, so the first connect after\n * construction does not double-subscribe. This keeps permission tracking\n * symmetric with position acquisition, which the Shell also revives on\n * reconnect.\n *\n * Retained as a thin alias of observe() for the Shell's existing reconnect\n * path; observe() is the canonical §3.5 lifecycle entry point.\n */\n reinitPermission(): void {\n void this.observe();\n }\n\n /**\n * Detach the live permission `change` listener. Call from the Shell's\n * `disconnectedCallback` so a removed element does not leak the subscription.\n * A later reconnect can re-subscribe via reinitPermission().\n */\n dispose(): void {\n this._permissionSubscribed = false;\n // Invalidate any in-flight query so its .then() bails instead of attaching a\n // listener after teardown.\n this._permGen++;\n // Invalidate any in-flight one-shot acquisition so its success/error callback\n // bails instead of dispatching on a disconnected element.\n this._acqGen++;\n // Likewise invalidate the watch generation. The Shell already calls\n // clearWatch() before dispose(), but a direct headless dispose() (without a\n // preceding clearWatch) still neutralizes any queued watch callback.\n this._watchGen++;\n // Reset the loading shadow silently (no dispatch on a disposed element). The\n // bailed callback above will not clear it, and leaving it true would let the\n // same-value guard swallow the loading=true edge of the next acquisition after\n // a reconnect.\n this._loading = false;\n if (this._permissionStatus) {\n this._permissionStatus.removeEventListener(\"change\", this._onPermissionChange);\n this._permissionStatus = null;\n }\n }\n\n // --- Internal ---\n\n private _hasGeolocation(): boolean {\n return typeof navigator !== \"undefined\" && !!navigator.geolocation;\n }\n\n private _initPermission(): Promise<void> {\n // The Permissions API is optional. When absent (or it rejects, e.g. some\n // browsers don't accept the \"geolocation\" name), report \"unsupported\" and\n // leave acquisition to fail loudly via the error property if attempted.\n if (typeof navigator === \"undefined\" || !navigator.permissions || typeof navigator.permissions.query !== \"function\") {\n // Route through _setPermission (not a bare assignment) so observers stay in\n // sync with the public state. The same-value guard means no redundant\n // dispatch when the state does not actually change; it does mean a\n // previously-observed \"granted\"/\"denied\" being reinit'd into an environment\n // that lost the Permissions API now correctly notifies observers of the\n // unsupported transition instead of silently overwriting the shadow value.\n this._setPermission(\"unsupported\");\n // No asynchronous probe to await: readiness is immediate.\n return Promise.resolve();\n }\n this._permissionSubscribed = true;\n const gen = ++this._permGen;\n return navigator.permissions.query({ name: \"geolocation\" as PermissionName }).then(\n (status) => {\n // Stale resolution: this query was superseded (rapid reconnect) or the\n // element was disposed while it was in flight. Drop it so only the current\n // subscription attaches a listener.\n if (gen !== this._permGen) return;\n this._permissionStatus = status;\n this._setPermission(status.state as GeoPermissionState);\n status.addEventListener(\"change\", this._onPermissionChange);\n },\n () => {\n if (gen !== this._permGen) return;\n this._setPermission(\"unsupported\");\n },\n );\n }\n\n private _onPermissionChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setPermission(status.state as GeoPermissionState);\n };\n\n private _normalizePosition(pos: GeolocationPosition): WcsGeoPositionDetail {\n const c = pos.coords;\n const coords: WcsGeoCoords = {\n latitude: c.latitude,\n longitude: c.longitude,\n accuracy: c.accuracy,\n altitude: c.altitude,\n altitudeAccuracy: c.altitudeAccuracy,\n heading: c.heading,\n speed: c.speed,\n };\n return { ...coords, timestamp: pos.timestamp, coords };\n }\n\n private _normalizeError(err: GeolocationPositionError): WcsGeoErrorDetail {\n return { code: err.code, message: err.message };\n }\n\n private _unsupportedError(): WcsGeoErrorDetail {\n // Geolocation API absent: surface it as POSITION_UNAVAILABLE (2) so consumers\n // that switch on the spec error codes treat it like any other unavailable fix.\n return { code: 2, message: \"Geolocation API is not available in this environment.\" };\n }\n\n private _unexpectedError(): WcsGeoErrorDetail {\n // An unexpected throw while normalizing/dispatching a fix. Surface it as\n // POSITION_UNAVAILABLE (2) so it flows into `error` like any other failure\n // instead of escaping the browser callback as an unhandled rejection.\n return { code: 2, message: \"Unexpected error while processing the position fix.\" };\n }\n}\n","import { config } from \"./config.js\";\nimport type { WcsGeolocation } from \"./components/Geolocation.js\";\n\nlet registered = false;\n\nfunction handleClick(event: Event): void {\n const target = event.target;\n if (!(target instanceof Element)) return;\n\n const triggerElement = target.closest<Element>(`[${config.triggerAttribute}]`);\n if (!triggerElement) return;\n\n const geoId = triggerElement.getAttribute(config.triggerAttribute);\n if (!geoId) return;\n\n // Resolve the registered constructor at call time instead of importing\n // Geolocation as a value. The value import created a components/Geolocation.ts\n // ⇄ autoTrigger.ts cycle (Geolocation.connectedCallback() calls\n // registerAutoTrigger()). instanceof against the customElements registry keeps\n // the exact same identity guarantee — only the registered <wcs-geo> class\n // matches — without the import cycle.\n const GeoCtor = customElements.get(config.tagNames.geo);\n const geoElement = document.getElementById(geoId);\n if (!GeoCtor || !(geoElement instanceof GeoCtor)) return;\n\n // Suppress the element's default action so a fix can be requested without\n // navigating. Intentional: do not attach data-geotarget to an element whose\n // default action you also want (real <a href> link, form-submit button) — it\n // will be cancelled. See README \"Optional DOM Triggering\".\n event.preventDefault();\n (geoElement as WcsGeolocation).getCurrentPosition();\n}\n\nexport function registerAutoTrigger(): void {\n if (registered) return;\n registered = true;\n document.addEventListener(\"click\", handleClick);\n}\n\nexport function unregisterAutoTrigger(): void {\n if (!registered) return;\n registered = false;\n document.removeEventListener(\"click\", handleClick);\n}\n","import { config } from \"../config.js\";\nimport { IWcBindable, GeoOptions, GeoPermissionState, WcsGeoPositionDetail, WcsGeoCoords, WcsGeoErrorDetail } from \"../types.js\";\nimport { GeolocationCore } from \"../core/GeolocationCore.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\n\n// Named WcsGeolocation (not `Geolocation`) so the class does not shadow the\n// global DOM `Geolocation` interface (the type of `navigator.geolocation`), and\n// to match the <wcs-ws> convention (WcsWebSocket). The public export keeps the\n// `WcsGeolocation` name unchanged, so this rename is non-breaking.\nexport class WcsGeolocation extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...GeolocationCore.wcBindable,\n properties: [\n ...GeolocationCore.wcBindable.properties,\n { name: \"trigger\", event: \"wcs-geo:trigger-changed\" },\n ],\n // Shell-level settable surface. Each input carries its mirrored `attribute`\n // hint (boolean flags reflect idempotently, so a binding system that writes\n // through inputs[].attribute is safe), following the <wcs-ws> convention.\n // `trigger` has no attribute — it is a momentary command-property, not a\n // declarative attribute. The `getCurrentPosition` / `watchPosition` /\n // `clearWatch` commands are declared below.\n inputs: [\n { name: \"highAccuracy\", attribute: \"high-accuracy\" },\n { name: \"timeout\", attribute: \"timeout\" },\n { name: \"maximumAge\", attribute: \"maximum-age\" },\n { name: \"watch\", attribute: \"watch\" },\n { name: \"manual\", attribute: \"manual\" },\n { name: \"trigger\" },\n ],\n // The Core's `watch` command is renamed to `watchPosition` on the Shell so it\n // does not collide with the `watch` boolean attribute accessor (same pattern\n // as <wcs-ws>, where the `send` command becomes `sendMessage` to free the\n // `send` setter). `getCurrentPosition` / `clearWatch` are unchanged.\n commands: [\n { name: \"getCurrentPosition\", async: true },\n { name: \"watchPosition\" },\n { name: \"clearWatch\" },\n ],\n };\n\n private _core: GeolocationCore;\n private _trigger: boolean = false;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n\n constructor() {\n super();\n this._core = new GeolocationCore(this);\n }\n\n // --- Attribute accessors ---\n\n get highAccuracy(): boolean {\n return this.hasAttribute(\"high-accuracy\");\n }\n\n set highAccuracy(value: boolean) {\n if (value) {\n this.setAttribute(\"high-accuracy\", \"\");\n } else {\n this.removeAttribute(\"high-accuracy\");\n }\n }\n\n get timeout(): number {\n const attr = this.getAttribute(\"timeout\");\n if (attr === null || attr.trim() === \"\") return Infinity;\n // Strict parse via Number() (unlike parseInt, \"10px\" -> NaN, not 10). Fall\n // back to the API default (Infinity = no timeout) for any non-finite or\n // negative value, matching the README \"invalid values fall back to default\".\n const parsed = Number(attr);\n return Number.isFinite(parsed) && parsed >= 0 ? parsed : Infinity;\n }\n\n set timeout(value: number) {\n this.setAttribute(\"timeout\", String(value));\n }\n\n get maximumAge(): number {\n const attr = this.getAttribute(\"maximum-age\");\n if (attr === null || attr.trim() === \"\") return 0;\n // Strict parse via Number() (unlike parseInt, \"10px\" -> NaN, not 10). Fall\n // back to the API default (0 = never use a cached fix) for any non-finite or\n // negative value, matching the README \"invalid values fall back to default\".\n const parsed = Number(attr);\n return Number.isFinite(parsed) && parsed >= 0 ? parsed : 0;\n }\n\n set maximumAge(value: number) {\n this.setAttribute(\"maximum-age\", String(value));\n }\n\n get watch(): boolean {\n return this.hasAttribute(\"watch\");\n }\n\n set watch(value: boolean) {\n if (value) {\n this.setAttribute(\"watch\", \"\");\n } else {\n this.removeAttribute(\"watch\");\n }\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 position(): WcsGeoPositionDetail | null {\n return this._core.position;\n }\n\n get latitude(): number | null {\n return this._core.latitude;\n }\n\n get longitude(): number | null {\n return this._core.longitude;\n }\n\n get accuracy(): number | null {\n return this._core.accuracy;\n }\n\n get coords(): WcsGeoCoords | null {\n return this._core.coords;\n }\n\n get timestamp(): number | null {\n return this._core.timestamp;\n }\n\n get watching(): boolean {\n return this._core.watching;\n }\n\n get loading(): boolean {\n return this._core.loading;\n }\n\n get error(): WcsGeoErrorDetail | null {\n return this._core.error;\n }\n\n get permission(): GeoPermissionState {\n return this._core.permission;\n }\n\n // wc-bindable connectedCallbackPromise protocol: resolves once the connect-time\n // acquisition settles, so SSR (@wcstack/server render.ts) waits for the first\n // fix before snapshotting the HTML. Mirrors Fetch.connectedCallbackPromise. In\n // `watch` / `manual` modes there is no one-shot connect-time fix to await, so it\n // stays the default resolved promise.\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Command property ---\n\n get trigger(): boolean {\n return this._trigger;\n }\n\n set trigger(value: boolean) {\n // Momentary command-property: a false→true write requests a single fix.\n // Mirrors the trigger flag on <wcs-timer> / <wcs-ws>. Prefer the\n // command-token protocol (`command.getCurrentPosition: $command.locate`) for\n // state-driven acquisition; this exists mainly for the DOM click trigger and\n // simple boolean bindings.\n const v = !!value;\n if (v) {\n this._trigger = true;\n // Fire-and-forget: getCurrentPosition() never rejects (failures surface via\n // the `error` property), so the returned promise is intentionally dropped.\n void this.getCurrentPosition();\n this._trigger = false;\n this.dispatchEvent(new CustomEvent(\"wcs-geo:trigger-changed\", {\n detail: false,\n bubbles: true,\n }));\n }\n }\n\n // --- Commands ---\n\n getCurrentPosition(): Promise<void> {\n return this._core.getCurrentPosition(this._options());\n }\n\n watchPosition(): void {\n this._core.watch(this._options());\n }\n\n clearWatch(): void {\n this._core.clearWatch();\n }\n\n // --- Internal ---\n\n private _options(): GeoOptions {\n return {\n enableHighAccuracy: this.highAccuracy,\n timeout: this.timeout,\n maximumAge: this.maximumAge,\n };\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n this.style.display = \"none\";\n if (config.autoTrigger) {\n registerAutoTrigger();\n }\n // Revive permission tracking after a reconnect (reparenting). No-op on the\n // first connect since the constructor already subscribed; only re-subscribes\n // when disconnectedCallback's dispose() tore the subscription down.\n this._core.reinitPermission();\n if (!this.manual) {\n // `watch` attribute selects the default phase: continuous monitoring vs a\n // single fix on connect.\n if (this.watch) {\n this.watchPosition();\n } else {\n // Track only the one-shot connect-time fix so SSR can await it. watch /\n // manual leave the promise at its resolved default. getCurrentPosition()\n // never rejects (failures surface via `error`), so no .catch() is needed.\n this._connectedCallbackPromise = this.getCurrentPosition();\n }\n }\n }\n\n disconnectedCallback(): void {\n this._core.clearWatch();\n this._core.dispose();\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapGeolocation(userConfig?: IWritableConfig): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents();\n}\n","import { WcsGeolocation } from \"./components/Geolocation.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.geo)) {\n customElements.define(config.tagNames.geo, WcsGeolocation);\n }\n}\n"],"names":["_config","autoTrigger","triggerAttribute","tagNames","geo","deepFreeze","obj","Object","freeze","key","keys","deepClone","clone","frozenConfig","config","getConfig","GeolocationCore","EventTarget","static","protocol","version","properties","name","event","getter","e","detail","latitude","longitude","accuracy","coords","timestamp","commands","async","_target","_watchId","_position","_watching","_loading","_error","_permission","_permissionStatus","_permissionSubscribed","_permGen","_acqGen","_watchGen","_ready","Promise","resolve","constructor","target","super","this","_initPermission","position","watching","loading","error","permission","ready","_setPosition","dispatchEvent","CustomEvent","bubbles","_setWatching","_setLoading","_setError","_setPermission","getCurrentPosition","options","_hasGeolocation","_unsupportedError","gen","navigator","geolocation","pos","_normalizePosition","_unexpectedError","err","_normalizeError","watch","wgen","watchPosition","clearWatch","observe","reinitPermission","dispose","removeEventListener","_onPermissionChange","permissions","query","then","status","state","addEventListener","c","altitude","altitudeAccuracy","heading","speed","code","message","registered","handleClick","Element","triggerElement","closest","geoId","getAttribute","GeoCtor","customElements","get","geoElement","document","getElementById","preventDefault","WcsGeolocation","HTMLElement","wcBindable","inputs","attribute","_core","_trigger","_connectedCallbackPromise","highAccuracy","hasAttribute","value","setAttribute","removeAttribute","timeout","attr","trim","Infinity","parsed","Number","isFinite","String","maximumAge","manual","connectedCallbackPromise","trigger","_options","enableHighAccuracy","connectedCallback","style","display","disconnectedCallback","bootstrapGeolocation","userConfig","partialConfig","assign","define"],"mappings":"AAUA,MAAMA,EAA2B,CAC/BC,aAAa,EACbC,iBAAkB,iBAClBC,SAAU,CACRC,IAAK,YAIT,SAASC,EAAcC,GACrB,GAAY,OAARA,GAA+B,iBAARA,EAAkB,OAAOA,E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oBC,EI1CpBD,IJ2CqC,kBADjBC,EIzCZD,GJ0CanJ,cACvBD,EAAQC,YAAcoJ,EAAcpJ,aAEQ,iBAAnCoJ,EAAcnJ,mBACvBF,EAAQE,iBAAmBmJ,EAAcnJ,kBAEvCmJ,EAAclJ,UAChBI,OAAO+I,OAAOtJ,EAAQG,SAAUkJ,EAAclJ,UAEhDU,EAAe,MKrDViG,eAAeC,IAAIjG,EAAOX,SAASC,MACtC0G,eAAeyC,OAAOzI,EAAOX,SAASC,IAAKgH,EDI/C"}
|
|
1
|
+
{"version":3,"file":"index.esm.min.js","sources":["../src/config.ts","../src/core/GeolocationCore.ts","../src/autoTrigger.ts","../src/components/Geolocation.ts","../src/bootstrapGeolocation.ts","../src/registerComponents.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n autoTrigger: boolean;\n triggerAttribute: string;\n tagNames: {\n geo: string;\n };\n}\n\nconst _config: IInternalConfig = {\n autoTrigger: true,\n triggerAttribute: \"data-geotarget\",\n tagNames: {\n geo: \"wcs-geo\",\n },\n};\n\nfunction deepFreeze<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n Object.freeze(obj);\n for (const key of Object.keys(obj)) {\n deepFreeze((obj as Record<string, unknown>)[key]);\n }\n return obj;\n}\n\nfunction deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n const clone: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n clone[key] = deepClone((obj as Record<string, unknown>)[key]);\n }\n return clone as T;\n}\n\nlet frozenConfig: IConfig | null = null;\n\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\nexport function setConfig(partialConfig: IWritableConfig): void {\n if (typeof partialConfig.autoTrigger === \"boolean\") {\n _config.autoTrigger = partialConfig.autoTrigger;\n }\n if (typeof partialConfig.triggerAttribute === \"string\") {\n _config.triggerAttribute = partialConfig.triggerAttribute;\n }\n if (partialConfig.tagNames) {\n Object.assign(_config.tagNames, partialConfig.tagNames);\n }\n frozenConfig = null;\n}\n","import {\n IWcBindable, GeoOptions, GeoPermissionState,\n WcsGeoPositionDetail, WcsGeoCoords, WcsGeoErrorDetail,\n} from \"../types.js\";\n\n/**\n * Headless geolocation primitive. A thin, framework-agnostic wrapper around the\n * Geolocation API exposed through the wc-bindable protocol.\n *\n * It has two phases, mirroring the two distinct shapes of the underlying API:\n * - **one-shot** — `getCurrentPosition()` resolves a single fix (like FetchCore's\n * one-shot `fetch()`), toggling `loading` around the async call.\n * - **continuous** — `watch()` / `clearWatch()` stream fixes (like TimerCore's\n * `start()` / `stop()`), toggling the `watching` flag.\n *\n * Every successful fix is published via the single `wcs-geo:position` event;\n * `latitude` / `longitude` / `accuracy` / `coords` / `timestamp` are read from\n * it through getters (mirroring how TimerCore exposes count/elapsed from one\n * `wcs-timer:tick` event), so an observer that binds any of them is notified on\n * every fix.\n *\n * Geolocation also has a permission gate absent from timer/websocket: the\n * `permission` property reflects `navigator.permissions.query({name:\n * \"geolocation\"})` (`prompt` / `granted` / `denied`, or `unsupported`) and\n * tracks its live `change` event. It is a read-only sensor — there is no\n * element-bound \"send\" path; element → state only.\n */\nexport class GeolocationCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"position\", event: \"wcs-geo:position\" },\n { name: \"latitude\", event: \"wcs-geo:position\", getter: (e: Event) => (e as CustomEvent).detail.latitude },\n { name: \"longitude\", event: \"wcs-geo:position\", getter: (e: Event) => (e as CustomEvent).detail.longitude },\n { name: \"accuracy\", event: \"wcs-geo:position\", getter: (e: Event) => (e as CustomEvent).detail.accuracy },\n { name: \"coords\", event: \"wcs-geo:position\", getter: (e: Event) => (e as CustomEvent).detail.coords },\n { name: \"timestamp\", event: \"wcs-geo:position\", getter: (e: Event) => (e as CustomEvent).detail.timestamp },\n { name: \"watching\", event: \"wcs-geo:watching-changed\" },\n { name: \"loading\", event: \"wcs-geo:loading-changed\" },\n { name: \"error\", event: \"wcs-geo:error\" },\n { name: \"permission\", event: \"wcs-geo:permission-changed\" },\n ],\n commands: [\n { name: \"getCurrentPosition\", async: true },\n { name: \"watch\" },\n { name: \"clearWatch\" },\n ],\n };\n\n private _target: EventTarget;\n private _watchId: number | null = null;\n\n private _position: WcsGeoPositionDetail | null = null;\n private _watching: boolean = false;\n private _loading: boolean = false;\n private _error: WcsGeoErrorDetail | null = null;\n private _permission: GeoPermissionState = \"prompt\";\n\n // Live PermissionStatus handle (when the Permissions API is available), kept\n // so the `change` listener can be removed on dispose().\n private _permissionStatus: PermissionStatus | null = null;\n\n // True once a permission subscription has been (or is being) established, and\n // reset by dispose(). Guards reinitPermission() so the first connect after\n // construction does not double-subscribe, while a reconnect after dispose()\n // does re-subscribe.\n private _permissionSubscribed: boolean = false;\n\n // Monotonic id of the current permission query. Bumped by every _initPermission()\n // and by dispose(). Each in-flight query captures its id and, on resolve, bails\n // unless it is still current — so a query superseded by a rapid (synchronous)\n // disconnect→reconnect, or one that resolves after dispose(), never attaches a\n // listener. A plain boolean cannot cover this: dispose()→reinit() flips it\n // false→true again, reopening the window for the stale query to slip through.\n private _permGen: number = 0;\n\n // Monotonic id of the current acquisition lifecycle, bumped only by dispose().\n // Each getCurrentPosition() captures it at start; the async success/error\n // callback bails (no setters, no resolve-side effects) if it is stale, so a\n // one-shot fix that resolves after the element was disconnected does not\n // dispatch wcs-geo:* on a torn-down element. Unlike FetchCore, the Geolocation\n // API has no AbortController, so a generation guard is the only way to neutralize\n // an in-flight one-shot. (watch is already stopped by clearWatch on disconnect.)\n private _acqGen: number = 0;\n\n // Monotonic id of the current watch lifecycle, bumped by watch(), clearWatch(),\n // and dispose(). Each watch() captures it; both watch callbacks bail if it is\n // stale. Unlike a live `_watchId === null` check, this distinguishes the current\n // watch from a superseded one: a clearWatch()→watch() restart installs a new\n // watchId (non-null), so a queued callback from the previous watch would pass a\n // null-check but fails the generation compare. (The README recommends exactly\n // this restart sequence to reconfigure a watch.)\n private _watchGen: number = 0;\n\n // Resolves once the most recent permission probe settles (or immediately when\n // the Permissions API is unsupported). The Shell exposes this as\n // connectedCallbackPromise so SSR can await the first probe before snapshotting\n // the HTML. Mirrors PermissionCore._ready.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n // Probe the permission state up front so observers see the real value\n // (granted/denied/prompt) before the first read, then keep it live.\n this._ready = this._initPermission();\n }\n\n get position(): WcsGeoPositionDetail | null {\n return this._position;\n }\n\n get latitude(): number | null {\n return this._position ? this._position.latitude : null;\n }\n\n get longitude(): number | null {\n return this._position ? this._position.longitude : null;\n }\n\n get accuracy(): number | null {\n return this._position ? this._position.accuracy : null;\n }\n\n get coords(): WcsGeoCoords | null {\n return this._position ? this._position.coords : null;\n }\n\n get timestamp(): number | null {\n return this._position ? this._position.timestamp : null;\n }\n\n get watching(): boolean {\n return this._watching;\n }\n\n get loading(): boolean {\n return this._loading;\n }\n\n get error(): WcsGeoErrorDetail | null {\n return this._error;\n }\n\n get permission(): GeoPermissionState {\n return this._permission;\n }\n\n /** Resolves once the first (or most recent) permission probe settles (§3.8). */\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // --- State setters with event dispatch ---\n\n private _setPosition(position: WcsGeoPositionDetail): void {\n this._position = position;\n this._target.dispatchEvent(new CustomEvent(\"wcs-geo:position\", {\n detail: position,\n bubbles: true,\n }));\n }\n\n private _setWatching(watching: boolean): void {\n if (this._watching === watching) return;\n this._watching = watching;\n this._target.dispatchEvent(new CustomEvent(\"wcs-geo:watching-changed\", {\n detail: watching,\n bubbles: true,\n }));\n }\n\n private _setLoading(loading: boolean): void {\n if (this._loading === loading) return;\n this._loading = loading;\n this._target.dispatchEvent(new CustomEvent(\"wcs-geo:loading-changed\", {\n detail: loading,\n bubbles: true,\n }));\n }\n\n private _setError(error: WcsGeoErrorDetail | null): void {\n // Same-value guard, like the other setters. Unlike `position` (which has\n // derived getters and so must re-fire even on an identical reference), `error`\n // has no derived state — so suppressing redundant null→null dispatches (e.g.\n // a successful fix clearing an already-null error) avoids spurious events.\n if (this._error === error) return;\n this._error = error;\n this._target.dispatchEvent(new CustomEvent(\"wcs-geo:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n private _setPermission(permission: GeoPermissionState): void {\n if (this._permission === permission) return;\n this._permission = permission;\n this._target.dispatchEvent(new CustomEvent(\"wcs-geo:permission-changed\", {\n detail: permission,\n bubbles: true,\n }));\n }\n\n // --- Public API ---\n\n /**\n * Acquire a single position fix. Resolves once the fix arrives or the request\n * fails — never rejects: failures are surfaced through the `error` property so\n * they flow into the declarative state, symmetrical with FetchCore.\n */\n getCurrentPosition(options: GeoOptions = {}): Promise<void> {\n return new Promise<void>((resolve) => {\n if (!this._hasGeolocation()) {\n this._setError(this._unsupportedError());\n resolve();\n return;\n }\n\n const gen = this._acqGen;\n this._setLoading(true);\n this._setError(null);\n navigator.geolocation.getCurrentPosition(\n (pos) => {\n // Stale: the element was disposed (disconnected) while this fix was in\n // flight. Drop it so a torn-down element never dispatches wcs-geo:*.\n // Still resolve() so any awaiter (e.g. connectedCallbackPromise) settles.\n if (gen !== this._acqGen) {\n resolve();\n return;\n }\n // Guard normalization/dispatch so a throw never escapes this browser\n // callback as an unhandled rejection, leaves the promise pending (which\n // would hang SSR's connectedCallbackPromise), or leaves `loading` stuck\n // true. Loading is cleared first so it holds even if a later step throws.\n try {\n this._setLoading(false);\n this._setPosition(this._normalizePosition(pos));\n } catch {\n // Surface the unexpected failure as an error so observers are not left\n // silently stale, then resolve below.\n this._setError(this._unexpectedError());\n }\n resolve();\n },\n (err) => {\n if (gen !== this._acqGen) {\n resolve();\n return;\n }\n try {\n this._setLoading(false);\n this._setError(this._normalizeError(err));\n } catch {\n this._setError(this._unexpectedError());\n }\n resolve();\n },\n options,\n );\n });\n }\n\n /**\n * Begin continuously watching the position. Idempotent while already\n * watching: a redundant watch() must not register a second `watchPosition`\n * (which would leak the handle and double the fix rate). Reconfiguring is done\n * via clearWatch() + watch().\n */\n watch(options: GeoOptions = {}): void {\n if (!this._hasGeolocation()) {\n this._setError(this._unsupportedError());\n return;\n }\n if (this._watching) return;\n\n this._setError(null);\n this._setWatching(true);\n // Open a new watch generation so any queued callback from a prior watch\n // (cleared then restarted) is recognized as stale below.\n const wgen = ++this._watchGen;\n this._watchId = navigator.geolocation.watchPosition(\n (pos) => {\n // Stale: this callback belongs to a watch that was cleared (or the element\n // disposed), possibly already superseded by a restart. A live\n // `_watchId === null` check cannot catch the restart case (the new watch\n // re-populates _watchId), so compare the captured generation instead.\n if (wgen !== this._watchGen) return;\n // Guard normalization/dispatch so an unexpected throw never escapes this\n // browser callback as an unhandled rejection — symmetric with the one-shot\n // path.\n try {\n // A recovered fix clears any prior transient error (e.g. a one-off\n // TIMEOUT) so `error` reflects the current state, not a stale failure.\n // The _setError same-value guard makes this free when error is already\n // null.\n this._setError(null);\n this._setPosition(this._normalizePosition(pos));\n } catch {\n this._setError(this._unexpectedError());\n }\n },\n (err) => {\n if (wgen !== this._watchGen) return;\n // An error does not implicitly release the watch — the watchId stays\n // valid and clearWatch() remains the teardown path — so `watching` is\n // left true to reflect \"watch still registered\". A terminal error (e.g.\n // PERMISSION_DENIED) is surfaced via the `error` property; callers that\n // want to stop on error can call clearWatch() in response.\n try {\n this._setError(this._normalizeError(err));\n } catch {\n this._setError(this._unexpectedError());\n }\n },\n options,\n );\n }\n\n clearWatch(): void {\n if (this._watchId !== null) {\n navigator.geolocation.clearWatch(this._watchId);\n this._watchId = null;\n }\n // Invalidate the current watch generation so any callback the browser may\n // still deliver after teardown bails.\n this._watchGen++;\n this._setWatching(false);\n }\n\n /**\n * Establish permission monitoring (§3.5). Idempotent: a no-op while a\n * subscription is already live (so the first connect after construction does\n * not double-subscribe), and re-subscribes after a dispose() — e.g. the Shell\n * element was disconnected and then reconnected (reparented). Returns the\n * `ready` promise, which resolves once the (re)established probe settles, so\n * the Shell can expose it as connectedCallbackPromise for SSR. Position\n * acquisition (one-shot / watch) is command-driven and the Shell drives it\n * separately from connectedCallback.\n */\n observe(): Promise<void> {\n if (!this._permissionSubscribed) {\n this._ready = this._initPermission();\n }\n return this._ready;\n }\n\n /**\n * Re-establish the permission `change` subscription after a dispose() — e.g.\n * the Shell element was disconnected and then reconnected (reparented). No-op\n * while a subscription is already live, so the first connect after\n * construction does not double-subscribe. This keeps permission tracking\n * symmetric with position acquisition, which the Shell also revives on\n * reconnect.\n *\n * Retained as a thin alias of observe() for the Shell's existing reconnect\n * path; observe() is the canonical §3.5 lifecycle entry point.\n */\n reinitPermission(): void {\n void this.observe();\n }\n\n /**\n * Detach the live permission `change` listener. Call from the Shell's\n * `disconnectedCallback` so a removed element does not leak the subscription.\n * A later reconnect can re-subscribe via reinitPermission().\n */\n dispose(): void {\n this._permissionSubscribed = false;\n // Invalidate any in-flight query so its .then() bails instead of attaching a\n // listener after teardown.\n this._permGen++;\n // Invalidate any in-flight one-shot acquisition so its success/error callback\n // bails instead of dispatching on a disconnected element.\n this._acqGen++;\n // Likewise invalidate the watch generation. The Shell already calls\n // clearWatch() before dispose(), but a direct headless dispose() (without a\n // preceding clearWatch) still neutralizes any queued watch callback.\n this._watchGen++;\n // Reset the loading shadow silently (no dispatch on a disposed element). The\n // bailed callback above will not clear it, and leaving it true would let the\n // same-value guard swallow the loading=true edge of the next acquisition after\n // a reconnect.\n this._loading = false;\n if (this._permissionStatus) {\n this._permissionStatus.removeEventListener(\"change\", this._onPermissionChange);\n this._permissionStatus = null;\n }\n }\n\n // --- Internal ---\n\n private _hasGeolocation(): boolean {\n return typeof navigator !== \"undefined\" && !!navigator.geolocation;\n }\n\n private _initPermission(): Promise<void> {\n // The Permissions API is optional. When absent (or it rejects, e.g. some\n // browsers don't accept the \"geolocation\" name), report \"unsupported\" and\n // leave acquisition to fail loudly via the error property if attempted.\n if (typeof navigator === \"undefined\" || !navigator.permissions || typeof navigator.permissions.query !== \"function\") {\n // Route through _setPermission (not a bare assignment) so observers stay in\n // sync with the public state. The same-value guard means no redundant\n // dispatch when the state does not actually change; it does mean a\n // previously-observed \"granted\"/\"denied\" being reinit'd into an environment\n // that lost the Permissions API now correctly notifies observers of the\n // unsupported transition instead of silently overwriting the shadow value.\n this._setPermission(\"unsupported\");\n // No asynchronous probe to await: readiness is immediate.\n return Promise.resolve();\n }\n this._permissionSubscribed = true;\n const gen = ++this._permGen;\n return navigator.permissions.query({ name: \"geolocation\" as PermissionName }).then(\n (status) => {\n // Stale resolution: this query was superseded (rapid reconnect) or the\n // element was disposed while it was in flight. Drop it so only the current\n // subscription attaches a listener.\n if (gen !== this._permGen) return;\n this._permissionStatus = status;\n this._setPermission(status.state as GeoPermissionState);\n status.addEventListener(\"change\", this._onPermissionChange);\n },\n () => {\n if (gen !== this._permGen) return;\n this._setPermission(\"unsupported\");\n },\n );\n }\n\n private _onPermissionChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setPermission(status.state as GeoPermissionState);\n };\n\n private _normalizePosition(pos: GeolocationPosition): WcsGeoPositionDetail {\n const c = pos.coords;\n const coords: WcsGeoCoords = {\n latitude: c.latitude,\n longitude: c.longitude,\n accuracy: c.accuracy,\n altitude: c.altitude,\n altitudeAccuracy: c.altitudeAccuracy,\n heading: c.heading,\n speed: c.speed,\n };\n return { ...coords, timestamp: pos.timestamp, coords };\n }\n\n private _normalizeError(err: GeolocationPositionError): WcsGeoErrorDetail {\n return { code: err.code, message: err.message };\n }\n\n private _unsupportedError(): WcsGeoErrorDetail {\n // Geolocation API absent: surface it as POSITION_UNAVAILABLE (2) so consumers\n // that switch on the spec error codes treat it like any other unavailable fix.\n return { code: 2, message: \"Geolocation API is not available in this environment.\" };\n }\n\n private _unexpectedError(): WcsGeoErrorDetail {\n // An unexpected throw while normalizing/dispatching a fix. Surface it as\n // POSITION_UNAVAILABLE (2) so it flows into `error` like any other failure\n // instead of escaping the browser callback as an unhandled rejection.\n return { code: 2, message: \"Unexpected error while processing the position fix.\" };\n }\n}\n","import { config } from \"./config.js\";\nimport type { WcsGeolocation } from \"./components/Geolocation.js\";\n\nlet registered = false;\n\nfunction handleClick(event: Event): void {\n const target = event.target;\n if (!(target instanceof Element)) return;\n\n const triggerElement = target.closest<Element>(`[${config.triggerAttribute}]`);\n if (!triggerElement) return;\n\n const geoId = triggerElement.getAttribute(config.triggerAttribute);\n if (!geoId) return;\n\n // Resolve the registered constructor at call time instead of importing\n // Geolocation as a value. The value import created a components/Geolocation.ts\n // ⇄ autoTrigger.ts cycle (Geolocation.connectedCallback() calls\n // registerAutoTrigger()). instanceof against the customElements registry keeps\n // the exact same identity guarantee — only the registered <wcs-geo> class\n // matches — without the import cycle.\n const GeoCtor = customElements.get(config.tagNames.geo);\n const geoElement = document.getElementById(geoId);\n if (!GeoCtor || !(geoElement instanceof GeoCtor)) return;\n\n // Suppress the element's default action so a fix can be requested without\n // navigating. Intentional: do not attach data-geotarget to an element whose\n // default action you also want (real <a href> link, form-submit button) — it\n // will be cancelled. See README \"Optional DOM Triggering\".\n event.preventDefault();\n (geoElement as WcsGeolocation).getCurrentPosition();\n}\n\nexport function registerAutoTrigger(): void {\n if (registered) return;\n registered = true;\n document.addEventListener(\"click\", handleClick);\n}\n\nexport function unregisterAutoTrigger(): void {\n if (!registered) return;\n registered = false;\n document.removeEventListener(\"click\", handleClick);\n}\n","import { config } from \"../config.js\";\nimport { IWcBindable, GeoOptions, GeoPermissionState, WcsGeoPositionDetail, WcsGeoCoords, WcsGeoErrorDetail } from \"../types.js\";\nimport { GeolocationCore } from \"../core/GeolocationCore.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\n\n// Named WcsGeolocation (not `Geolocation`) so the class does not shadow the\n// global DOM `Geolocation` interface (the type of `navigator.geolocation`), and\n// to match the <wcs-ws> convention (WcsWebSocket). The public export keeps the\n// `WcsGeolocation` name unchanged, so this rename is non-breaking.\nexport class WcsGeolocation extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...GeolocationCore.wcBindable,\n properties: [\n ...GeolocationCore.wcBindable.properties,\n { name: \"trigger\", event: \"wcs-geo:trigger-changed\" },\n ],\n // Shell-level settable surface. Each input carries its mirrored `attribute`\n // hint (boolean flags reflect idempotently, so a binding system that writes\n // through inputs[].attribute is safe), following the <wcs-ws> convention.\n // `trigger` has no attribute — it is a momentary command-property, not a\n // declarative attribute. The `getCurrentPosition` / `watchPosition` /\n // `clearWatch` commands are declared below.\n inputs: [\n { name: \"highAccuracy\", attribute: \"high-accuracy\" },\n { name: \"timeout\", attribute: \"timeout\" },\n { name: \"maximumAge\", attribute: \"maximum-age\" },\n { name: \"watch\", attribute: \"watch\" },\n { name: \"manual\", attribute: \"manual\" },\n { name: \"trigger\" },\n ],\n // The Core's `watch` command is renamed to `watchPosition` on the Shell so it\n // does not collide with the `watch` boolean attribute accessor (same pattern\n // as <wcs-ws>, where the `send` command becomes `sendMessage` to free the\n // `send` setter). `getCurrentPosition` / `clearWatch` are unchanged.\n commands: [\n { name: \"getCurrentPosition\", async: true },\n { name: \"watchPosition\" },\n { name: \"clearWatch\" },\n ],\n };\n\n private _core: GeolocationCore;\n private _trigger: boolean = false;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new GeolocationCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-geo:watching-changed\": (d) => ({ watching: d === true }),\n \"wcs-geo:loading-changed\": (d) => ({ loading: d === true }),\n \"wcs-geo:error\": (d) => ({ error: d != null }),\n });\n }\n\n // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of\n // wc-bindable (not a bind target); see README \"CSS styling with :state()\".\n // MUST NOT return the live CustomStateSet (that would let callers write\n // states from outside, defeating the point of :state() being read-only).\n get debugStates(): string[] {\n return this._internals ? [...this._internals.states] : [];\n }\n\n private _initInternals(): ElementInternals | null {\n // never-throw (docs/custom-state-reflection-design.md §3.4): attachInternals\n // is absent in happy-dom / older environments, and pre-125 Chromium rejects\n // non-dashed state names from states.add() (probed and discarded here).\n // Either case silently disables reflection — the component still works, it\n // just doesn't expose :state() selectors.\n try {\n if (typeof this.attachInternals !== \"function\") return null;\n const internals = this.attachInternals();\n internals.states.add(\"wcs-probe\");\n internals.states.delete(\"wcs-probe\");\n return internals;\n } catch {\n return null;\n }\n }\n\n private _wireStates(map: Record<string, (detail: any) => Record<string, boolean>>): void {\n if (this._internals === null) return;\n const states = this._internals.states;\n for (const [event, toStates] of Object.entries(map)) {\n this.addEventListener(event, (e) => {\n const debug = this.hasAttribute(\"debug-states\");\n for (const [name, on] of Object.entries(toStates((e as CustomEvent).detail))) {\n try {\n if (on) { states.add(name); } else { states.delete(name); }\n } catch { /* never-throw */ }\n if (debug) this.toggleAttribute(`data-wcs-state-${name}`, on);\n }\n });\n }\n }\n\n // --- Attribute accessors ---\n\n get highAccuracy(): boolean {\n return this.hasAttribute(\"high-accuracy\");\n }\n\n set highAccuracy(value: boolean) {\n if (value) {\n this.setAttribute(\"high-accuracy\", \"\");\n } else {\n this.removeAttribute(\"high-accuracy\");\n }\n }\n\n get timeout(): number {\n const attr = this.getAttribute(\"timeout\");\n if (attr === null || attr.trim() === \"\") return Infinity;\n // Strict parse via Number() (unlike parseInt, \"10px\" -> NaN, not 10). Fall\n // back to the API default (Infinity = no timeout) for any non-finite or\n // negative value, matching the README \"invalid values fall back to default\".\n const parsed = Number(attr);\n return Number.isFinite(parsed) && parsed >= 0 ? parsed : Infinity;\n }\n\n set timeout(value: number) {\n this.setAttribute(\"timeout\", String(value));\n }\n\n get maximumAge(): number {\n const attr = this.getAttribute(\"maximum-age\");\n if (attr === null || attr.trim() === \"\") return 0;\n // Strict parse via Number() (unlike parseInt, \"10px\" -> NaN, not 10). Fall\n // back to the API default (0 = never use a cached fix) for any non-finite or\n // negative value, matching the README \"invalid values fall back to default\".\n const parsed = Number(attr);\n return Number.isFinite(parsed) && parsed >= 0 ? parsed : 0;\n }\n\n set maximumAge(value: number) {\n this.setAttribute(\"maximum-age\", String(value));\n }\n\n get watch(): boolean {\n return this.hasAttribute(\"watch\");\n }\n\n set watch(value: boolean) {\n if (value) {\n this.setAttribute(\"watch\", \"\");\n } else {\n this.removeAttribute(\"watch\");\n }\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 position(): WcsGeoPositionDetail | null {\n return this._core.position;\n }\n\n get latitude(): number | null {\n return this._core.latitude;\n }\n\n get longitude(): number | null {\n return this._core.longitude;\n }\n\n get accuracy(): number | null {\n return this._core.accuracy;\n }\n\n get coords(): WcsGeoCoords | null {\n return this._core.coords;\n }\n\n get timestamp(): number | null {\n return this._core.timestamp;\n }\n\n get watching(): boolean {\n return this._core.watching;\n }\n\n get loading(): boolean {\n return this._core.loading;\n }\n\n get error(): WcsGeoErrorDetail | null {\n return this._core.error;\n }\n\n get permission(): GeoPermissionState {\n return this._core.permission;\n }\n\n // wc-bindable connectedCallbackPromise protocol: resolves once the connect-time\n // acquisition settles, so SSR (@wcstack/server render.ts) waits for the first\n // fix before snapshotting the HTML. Mirrors Fetch.connectedCallbackPromise. In\n // `watch` / `manual` modes there is no one-shot connect-time fix to await, so it\n // stays the default resolved promise.\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Command property ---\n\n get trigger(): boolean {\n return this._trigger;\n }\n\n set trigger(value: boolean) {\n // Momentary command-property: a false→true write requests a single fix.\n // Mirrors the trigger flag on <wcs-timer> / <wcs-ws>. Prefer the\n // command-token protocol (`command.getCurrentPosition: $command.locate`) for\n // state-driven acquisition; this exists mainly for the DOM click trigger and\n // simple boolean bindings.\n const v = !!value;\n if (v) {\n this._trigger = true;\n // Fire-and-forget: getCurrentPosition() never rejects (failures surface via\n // the `error` property), so the returned promise is intentionally dropped.\n void this.getCurrentPosition();\n this._trigger = false;\n this.dispatchEvent(new CustomEvent(\"wcs-geo:trigger-changed\", {\n detail: false,\n bubbles: true,\n }));\n }\n }\n\n // --- Commands ---\n\n getCurrentPosition(): Promise<void> {\n return this._core.getCurrentPosition(this._options());\n }\n\n watchPosition(): void {\n this._core.watch(this._options());\n }\n\n clearWatch(): void {\n this._core.clearWatch();\n }\n\n // --- Internal ---\n\n private _options(): GeoOptions {\n return {\n enableHighAccuracy: this.highAccuracy,\n timeout: this.timeout,\n maximumAge: this.maximumAge,\n };\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n this.style.display = \"none\";\n if (config.autoTrigger) {\n registerAutoTrigger();\n }\n // Revive permission tracking after a reconnect (reparenting). No-op on the\n // first connect since the constructor already subscribed; only re-subscribes\n // when disconnectedCallback's dispose() tore the subscription down.\n this._core.reinitPermission();\n if (!this.manual) {\n // `watch` attribute selects the default phase: continuous monitoring vs a\n // single fix on connect.\n if (this.watch) {\n this.watchPosition();\n } else {\n // Track only the one-shot connect-time fix so SSR can await it. watch /\n // manual leave the promise at its resolved default. getCurrentPosition()\n // never rejects (failures surface via `error`), so no .catch() is needed.\n this._connectedCallbackPromise = this.getCurrentPosition();\n }\n }\n }\n\n disconnectedCallback(): void {\n this._core.clearWatch();\n this._core.dispose();\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapGeolocation(userConfig?: IWritableConfig): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents();\n}\n","import { WcsGeolocation } from \"./components/Geolocation.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.geo)) {\n customElements.define(config.tagNames.geo, WcsGeolocation);\n }\n}\n"],"names":["_config","autoTrigger","triggerAttribute","tagNames","geo","deepFreeze","obj","Object","freeze","key","keys","deepClone","clone","frozenConfig","config","getConfig","GeolocationCore","EventTarget","static","protocol","version","properties","name","event","getter","e","detail","latitude","longitude","accuracy","coords","timestamp","commands","async","_target","_watchId","_position","_watching","_loading","_error","_permission","_permissionStatus","_permissionSubscribed","_permGen","_acqGen","_watchGen","_ready","Promise","resolve","constructor","target","super","this","_initPermission","position","watching","loading","error","permission","ready","_setPosition","dispatchEvent","CustomEvent","bubbles","_setWatching","_setLoading","_setError","_setPermission","getCurrentPosition","options","_hasGeolocation","_unsupportedError","gen","navigator","geolocation","pos","_normalizePosition","_unexpectedError","err","_normalizeError","watch","wgen","watchPosition","clearWatch","observe","reinitPermission","dispose","removeEventListener","_onPermissionChange","permissions","query","then","status","state","addEventListener","c","altitude","altitudeAccuracy","heading","speed","code","message","registered","handleClick","Element","triggerElement","closest","geoId","getAttribute","GeoCtor","customElements","get","geoElement","document","getElementById","preventDefault","WcsGeolocation","HTMLElement","wcBindable","inputs","attribute","_core","_trigger","_connectedCallbackPromise","_internals","_initInternals","_wireStates","d","debugStates","states","attachInternals","internals","add","delete","map","toStates","entries","debug","hasAttribute","on","toggleAttribute","highAccuracy","value","setAttribute","removeAttribute","timeout","attr","trim","Infinity","parsed","Number","isFinite","String","maximumAge","manual","connectedCallbackPromise","trigger","_options","enableHighAccuracy","connectedCallback","style","display","disconnectedCallback","bootstrapGeolocation","userConfig","partialConfig","assign","define"],"mappings":"AAUA,MAAMA,EAA2B,CAC/BC,aAAa,EACbC,iBAAkB,iBAClBC,SAAU,CACRC,IAAK,YAIT,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,OAA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KsE,UAAW,EAChBtE,KAAKS,cAAc,IAAIC,YAAY,0BAA2B,CAC5DpC,QAAQ,EACRqC,SAAS,KAGf,CAIA,kBAAAK,GACE,OAAOhB,KAAKqE,MAAMrD,mBAAmBhB,KAAKyG,WAC5C,CAEA,aAAA3E,GACE9B,KAAKqE,MAAMzC,MAAM5B,KAAKyG,WACxB,CAEA,UAAA1E,GACE/B,KAAKqE,MAAMtC,YACb,CAIQ,QAAA0E,GACN,MAAO,CACLC,mBAAoB1G,KAAKyF,aACzBI,QAAS7F,KAAK6F,QACdQ,WAAYrG,KAAKqG,WAErB,CAIA,iBAAAM,GACE3G,KAAK4G,MAAMC,QAAU,OACjBnJ,EAAOb,cD5OTqG,IACJA,GAAa,EACbW,SAASnB,iBAAiB,QAASS,KCgPjCnD,KAAKqE,MAAMpC,mBACNjC,KAAKsG,SAGJtG,KAAK4B,MACP5B,KAAK8B,gBAKL9B,KAAKuE,0BAA4BvE,KAAKgB,qBAG5C,CAEA,oBAAA8F,GACE9G,KAAKqE,MAAMtC,aACX/B,KAAKqE,MAAMnC,SACb,EClSI,SAAU6E,EAAqBC,GJ2C/B,IAAoBC,EI1CpBD,IJ2CqC,kBADjBC,EIzCZD,GJ0CanK,cACvBD,EAAQC,YAAcoK,EAAcpK,aAEQ,iBAAnCoK,EAAcnK,mBACvBF,EAAQE,iBAAmBmK,EAAcnK,kBAEvCmK,EAAclK,UAChBI,OAAO+J,OAAOtK,EAAQG,SAAUkK,EAAclK,UAEhDU,EAAe,MKrDViG,eAAeC,IAAIjG,EAAOX,SAASC,MACtC0G,eAAeyD,OAAOzJ,EAAOX,SAASC,IAAKgH,EDI/C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wcstack/geolocation",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.0",
|
|
4
4
|
"description": "Declarative geolocation component for Web Components. Framework-agnostic Geolocation API primitive via wc-bindable-protocol.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.esm.js",
|