@flighthq/geolocation 0.5.1-edge.799.62ef0c7 → 0.5.1-edge.911.32a089f

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.md CHANGED
@@ -13,5 +13,5 @@ Import the supported application-facing API from `@flighthq/geolocation`. The `@
13
13
  This package is part of the locked-version Flight SDK graph. Applications may instead install and import `@flighthq/sdk` when package-level tree shaking is sufficient.
14
14
 
15
15
  - [Flight project](https://github.com/flighthq/flight)
16
- - [Source for @flighthq/geolocation@0.5.1-edge.799.62ef0c7](https://github.com/flighthq/flight/tree/62ef0c74f09f24177aac3695b2487b2d743d4fe6/packages/geolocation)
17
- - [License](https://github.com/flighthq/flight/blob/62ef0c74f09f24177aac3695b2487b2d743d4fe6/LICENSE.md)
16
+ - [Source for @flighthq/geolocation@0.5.1-edge.911.32a089f](https://github.com/flighthq/flight/tree/32a089f1342d08547fc2359dfd5e8fe9f7e3c12e/packages/geolocation)
17
+ - [License](https://github.com/flighthq/flight/blob/32a089f1342d08547fc2359dfd5e8fe9f7e3c12e/LICENSE.md)
@@ -1,3 +1,4 @@
1
1
  export * from './geolocation';
2
2
  export * from './geolocationAccess';
3
+ export { initializeGeoPosition, initializeWebGeolocationBackend } from './geolocation';
3
4
  //# sourceMappingURL=contract.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC"}
package/dist/contract.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './geolocation';
2
2
  export * from './geolocationAccess';
3
+ export { initializeGeoPosition, initializeWebGeolocationBackend } from './geolocation';
3
4
  //# sourceMappingURL=contract.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC"}
@@ -1,16 +1,11 @@
1
- import type { BackendExplanation } from '@flighthq/types/contract';
2
- import type { GeolocationBackend, GeolocationErrorReason, GeolocationRequestOptions, GeoPosition, GeoPositionResult } from '@flighthq/types/contract';
3
- export declare function clearGeolocationWatch(id: number): void;
1
+ import type { GeolocationBackend, GeolocationErrorReason, GeolocationRequestOptions, GeoPosition, GeoPositionResult, HasSystemGeolocation, EntityConstruction } from '@flighthq/types/contract';
2
+ export declare function clearGeolocationWatch(host: Readonly<HasSystemGeolocation>, id: number): void;
4
3
  export declare function createGeoPosition(): GeoPosition;
5
4
  export declare function createWebGeolocationBackend(): GeolocationBackend;
6
- export declare function explainGeolocationBackend(): BackendExplanation;
7
- export declare function getCurrentGeoPosition(options?: Readonly<GeolocationRequestOptions>): Promise<GeoPosition | null>;
8
- export declare function getCurrentGeoPositionResult(options?: Readonly<GeolocationRequestOptions>): Promise<GeoPositionResult>;
9
- export declare function getGeolocationBackend(): GeolocationBackend;
10
- export declare function installGeolocationHostBackend(backend: GeolocationBackend): void;
11
- export declare function isGeolocationAvailable(): boolean;
12
- export declare function observeGeolocationHostResult(operation: string, succeeded: boolean): void;
13
- export declare function resetGeolocationBackendForTest(): void;
14
- export declare function setGeolocationBackend(backend: GeolocationBackend | null): void;
15
- export declare function watchGeolocationPosition(handler: (position: Readonly<GeoPosition>) => void, options?: Readonly<GeolocationRequestOptions>, onError?: (reason: GeolocationErrorReason) => void): number;
5
+ export declare function getCurrentGeoPosition(host: Readonly<HasSystemGeolocation>, options?: Readonly<GeolocationRequestOptions>): Promise<GeoPosition | null>;
6
+ export declare function getCurrentGeoPositionResult(host: Readonly<HasSystemGeolocation>, options?: Readonly<GeolocationRequestOptions>): Promise<GeoPositionResult>;
7
+ export declare function initializeGeoPosition(out: EntityConstruction<GeoPosition>): void;
8
+ export declare function initializeWebGeolocationBackend(out: EntityConstruction<GeolocationBackend>): void;
9
+ export declare function isGeolocationAvailable(host: Readonly<HasSystemGeolocation>): boolean;
10
+ export declare function watchGeolocationPosition(host: Readonly<HasSystemGeolocation>, handler: (position: Readonly<GeoPosition>) => void, options?: Readonly<GeolocationRequestOptions>, onError?: (reason: GeolocationErrorReason) => void): number;
16
11
  //# sourceMappingURL=geolocation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"geolocation.d.ts","sourceRoot":"","sources":["../src/geolocation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAGV,kBAAkB,EAClB,sBAAsB,EACtB,yBAAyB,EACzB,WAAW,EACX,iBAAiB,EAClB,MAAM,0BAA0B,CAAC;AAElC,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAEtD;AAED,wBAAgB,iBAAiB,IAAI,WAAW,CAY/C;AAKD,wBAAgB,2BAA2B,IAAI,kBAAkB,CAsFhE;AAED,wBAAgB,yBAAyB,IAAI,kBAAkB,CAa9D;AAED,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,yBAAyB,CAAC,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAEhH;AAED,wBAAgB,2BAA2B,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,yBAAyB,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAErH;AAED,wBAAgB,qBAA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CAAC,EAAE,QAAQ,CAAC,yBAAyB,CAAC,GAC5C,OAAO,CAAC,iBAAiB,CAAC,CAE5B;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,kBAAkB,CAAC,WAAW,CAAC,GAAG,IAAI,CAUhF;AAED,wBAAgB,+BAA+B,CAAC,GAAG,EAAE,kBAAkB,CAAC,kBAAkB,CAAC,GAAG,IAAI,CAgFjG;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GAAG,OAAO,CAEpF;AAED,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,QAAQ,CAAC,oBAAoB,CAAC,EACpC,OAAO,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,WAAW,CAAC,KAAK,IAAI,EAClD,OAAO,CAAC,EAAE,QAAQ,CAAC,yBAAyB,CAAC,EAC7C,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,sBAAsB,KAAK,IAAI,GACjD,MAAM,CAER"}
@@ -1,178 +1,115 @@
1
- import { createEntity } from '@flighthq/entity/contract';
2
- export function clearGeolocationWatch(id) {
3
- getGeolocationBackend().clearWatch(id);
1
+ import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
2
+ export function clearGeolocationWatch(host, id) {
3
+ host.system.geolocation.clearWatch(id);
4
4
  }
5
5
  export function createGeoPosition() {
6
- return createEntity({
7
- accuracy: 0,
8
- altitude: 0,
9
- altitudeAccuracy: 0,
10
- floorLevel: 0,
11
- heading: 0,
12
- latitude: 0,
13
- longitude: 0,
14
- speed: 0,
15
- timestamp: 0,
16
- });
6
+ const out = allocateEntity();
7
+ initializeGeoPosition(out);
8
+ return finishEntity(out);
17
9
  }
18
- // Builds the default web backend over navigator.geolocation. Position reads resolve to null and
19
- // permission requests resolve to false when the API is absent (insecure context, jsdom) or the user
20
- // denies access — location access is not guaranteed.
21
10
  export function createWebGeolocationBackend() {
22
- return createEntity({
23
- clearWatch(id) {
11
+ const out = allocateEntity();
12
+ initializeWebGeolocationBackend(out);
13
+ return finishEntity(out);
14
+ }
15
+ export function getCurrentGeoPosition(host, options) {
16
+ return host.system.geolocation.getCurrentPosition(options ?? _emptyOptions);
17
+ }
18
+ export function getCurrentGeoPositionResult(host, options) {
19
+ return host.system.geolocation.getCurrentPositionResult(options ?? _emptyOptions);
20
+ }
21
+ export function initializeGeoPosition(out) {
22
+ out.accuracy = 0;
23
+ out.altitude = 0;
24
+ out.altitudeAccuracy = 0;
25
+ out.floorLevel = 0;
26
+ out.heading = 0;
27
+ out.latitude = 0;
28
+ out.longitude = 0;
29
+ out.speed = 0;
30
+ out.timestamp = 0;
31
+ }
32
+ export function initializeWebGeolocationBackend(out) {
33
+ out.clearWatch = (id) => {
34
+ const geo = getWebGeolocation();
35
+ if (geo === null || typeof geo.clearWatch !== 'function')
36
+ return;
37
+ try {
38
+ geo.clearWatch(id);
39
+ }
40
+ catch {
41
+ // Expected failure: the watch may already be gone or the host may deny access.
42
+ }
43
+ };
44
+ out.getCurrentPosition = (options) => {
45
+ return new Promise((resolve) => {
24
46
  const geo = getWebGeolocation();
25
- if (geo === null || typeof geo.clearWatch !== 'function')
47
+ if (geo === null || typeof geo.getCurrentPosition !== 'function') {
48
+ resolve(null);
26
49
  return;
50
+ }
27
51
  try {
28
- geo.clearWatch(id);
52
+ geo.getCurrentPosition((position) => resolve(mapWebPosition(position)), () => resolve(null), toPositionOptions(options));
29
53
  }
30
54
  catch {
31
- // Expected failure: the watch may already be gone or the host may deny access.
55
+ resolve(null);
32
56
  }
33
- },
34
- getCurrentPosition(options) {
35
- return new Promise((resolve) => {
36
- const geo = getWebGeolocation();
37
- if (geo === null || typeof geo.getCurrentPosition !== 'function') {
38
- resolve(null);
39
- return;
40
- }
41
- try {
42
- geo.getCurrentPosition((position) => resolve(mapWebPosition(position)), () => resolve(null), toPositionOptions(options));
43
- }
44
- catch {
45
- resolve(null);
46
- }
47
- });
48
- },
49
- getCurrentPositionResult(options) {
50
- return new Promise((resolve) => {
51
- const geo = getWebGeolocation();
52
- if (geo === null || typeof geo.getCurrentPosition !== 'function') {
53
- resolve({ position: null, reason: 'unavailable' });
54
- return;
55
- }
56
- try {
57
- geo.getCurrentPosition((position) => resolve({ position: mapWebPosition(position), reason: null }), (error) => resolve({ position: null, reason: mapWebPositionError(error) }), toPositionOptions(options));
58
- }
59
- catch {
60
- resolve({ position: null, reason: 'unavailable' });
61
- }
62
- });
63
- },
64
- isAvailable() {
65
- if (typeof window !== 'undefined' && window.isSecureContext === false)
66
- return false;
67
- return getWebGeolocation() !== null;
68
- },
69
- // The web has no permission-request API: the prompt is raised as a side effect of a position
70
- // read. Code 1 is a refusal; code 3 is an acquisition TIMEOUT and says nothing about the user, so
71
- // it is reported as such rather than guessed at. 'dismissed' is reachable only on hosts that can
72
- // actually observe a closed-undecided prompt, which the web cannot.
73
- promptForAccess() {
74
- return new Promise((resolve) => {
75
- const geo = getWebGeolocation();
76
- if (geo === null || typeof geo.getCurrentPosition !== 'function') {
77
- resolve({ reason: 'runtime-unavailable' });
78
- return;
79
- }
80
- try {
81
- geo.getCurrentPosition(() => resolve({ reason: 'granted' }), (error) => resolve({ reason: mapWebAccessError(error) }));
82
- }
83
- catch {
84
- resolve({ reason: 'operation-failed' });
85
- }
86
- });
87
- },
88
- watchPosition(listener, options, onError) {
57
+ });
58
+ };
59
+ out.getCurrentPositionResult = (options) => {
60
+ return new Promise((resolve) => {
89
61
  const geo = getWebGeolocation();
90
- if (geo === null || typeof geo.watchPosition !== 'function')
91
- return -1;
62
+ if (geo === null || typeof geo.getCurrentPosition !== 'function') {
63
+ resolve({ position: null, reason: 'unavailable' });
64
+ return;
65
+ }
92
66
  try {
93
- return geo.watchPosition((position) => listener(mapWebPosition(position)), onError !== undefined ? (error) => onError(mapWebPositionError(error)) : () => { }, toPositionOptions(options));
67
+ geo.getCurrentPosition((position) => resolve({ position: mapWebPosition(position), reason: null }), (error) => resolve({ position: null, reason: mapWebPositionError(error) }), toPositionOptions(options));
94
68
  }
95
69
  catch {
96
- return -1;
70
+ resolve({ position: null, reason: 'unavailable' });
97
71
  }
98
- },
99
- });
100
- }
101
- export function explainGeolocationBackend() {
102
- if (_custom !== null) {
103
- return { conflict: _hostConflict, layer: 'custom', operation: null, viability: 'unobserved' };
104
- }
105
- if (_host !== null) {
106
- return {
107
- conflict: _hostConflict,
108
- layer: 'host',
109
- operation: _hostObservation !== null ? _hostObservation.operation : null,
110
- viability: _hostObservation !== null ? _hostObservation.viability : 'unobserved',
111
- };
112
- }
113
- return { conflict: false, layer: 'host-not-enabled', operation: null, viability: 'unobserved' };
114
- }
115
- export function getCurrentGeoPosition(options) {
116
- return getGeolocationBackend().getCurrentPosition(options ?? _emptyOptions);
117
- }
118
- export function getCurrentGeoPositionResult(options) {
119
- return getGeolocationBackend().getCurrentPositionResult(options ?? _emptyOptions);
120
- }
121
- export function getGeolocationBackend() {
122
- return _custom ?? _host ?? _sentinel;
123
- }
124
- export function installGeolocationHostBackend(backend) {
125
- if (_host !== null) {
126
- if (_host !== backend)
127
- _hostConflict = true;
128
- return;
129
- }
130
- _host = backend;
131
- }
132
- export function isGeolocationAvailable() {
133
- return getGeolocationBackend().isAvailable();
134
- }
135
- export function observeGeolocationHostResult(operation, succeeded) {
136
- _hostObservation = {
137
- operation,
138
- viability: succeeded ? 'available' : 'runtime-api-unavailable',
72
+ });
73
+ };
74
+ out.isAvailable = () => {
75
+ if (typeof window !== 'undefined' && window.isSecureContext === false)
76
+ return false;
77
+ return getWebGeolocation() !== null;
78
+ };
79
+ out.promptForAccess = () => {
80
+ return new Promise((resolve) => {
81
+ const geo = getWebGeolocation();
82
+ if (geo === null || typeof geo.getCurrentPosition !== 'function') {
83
+ resolve({ reason: 'runtime-unavailable' });
84
+ return;
85
+ }
86
+ try {
87
+ geo.getCurrentPosition(() => resolve({ reason: 'granted' }), (error) => resolve({ reason: mapWebAccessError(error) }));
88
+ }
89
+ catch {
90
+ resolve({ reason: 'operation-failed' });
91
+ }
92
+ });
93
+ };
94
+ out.watchPosition = (listener, options, onError) => {
95
+ const geo = getWebGeolocation();
96
+ if (geo === null || typeof geo.watchPosition !== 'function')
97
+ return -1;
98
+ try {
99
+ return geo.watchPosition((position) => listener(mapWebPosition(position)), onError !== undefined ? (error) => onError(mapWebPositionError(error)) : () => { }, toPositionOptions(options));
100
+ }
101
+ catch {
102
+ return -1;
103
+ }
139
104
  };
140
105
  }
141
- export function resetGeolocationBackendForTest() {
142
- _custom = null;
143
- _host = null;
144
- _hostConflict = false;
145
- _hostObservation = null;
146
- }
147
- export function setGeolocationBackend(backend) {
148
- _custom = backend;
106
+ export function isGeolocationAvailable(host) {
107
+ return host.system.geolocation.isAvailable();
149
108
  }
150
- export function watchGeolocationPosition(handler, options, onError) {
151
- return getGeolocationBackend().watchPosition(handler, options ?? _emptyOptions, onError);
109
+ export function watchGeolocationPosition(host, handler, options, onError) {
110
+ return host.system.geolocation.watchPosition(handler, options ?? _emptyOptions, onError);
152
111
  }
153
- let _custom = null;
154
- let _host = null;
155
- let _hostConflict = false;
156
- let _hostObservation = null;
157
112
  const _emptyOptions = {};
158
- const _sentinel = createEntity({
159
- clearWatch() { },
160
- getCurrentPosition() {
161
- return Promise.resolve(null);
162
- },
163
- getCurrentPositionResult() {
164
- return Promise.resolve({ position: null, reason: 'unavailable' });
165
- },
166
- isAvailable() {
167
- return false;
168
- },
169
- promptForAccess() {
170
- return Promise.resolve({ reason: 'runtime-unavailable' });
171
- },
172
- watchPosition() {
173
- return -1;
174
- },
175
- });
176
113
  function getWebGeolocation() {
177
114
  if (typeof navigator === 'undefined')
178
115
  return null;
@@ -180,19 +117,17 @@ function getWebGeolocation() {
180
117
  }
181
118
  function mapWebPosition(position) {
182
119
  const coords = position.coords;
183
- return createEntity({
184
- accuracy: coords.accuracy,
185
- altitude: coords.altitude ?? 0,
186
- altitudeAccuracy: coords.altitudeAccuracy ?? 0,
187
- // floorLevel is non-standard: absent from the W3C GeolocationCoordinates type, but some hosts
188
- // (indoor-positioning platforms) populate it. Read it when present rather than forcing 0.
189
- floorLevel: coords.floorLevel ?? 0,
190
- heading: coords.heading ?? 0,
191
- latitude: coords.latitude,
192
- longitude: coords.longitude,
193
- speed: coords.speed ?? 0,
194
- timestamp: position.timestamp,
195
- });
120
+ const out = allocateEntity();
121
+ out.accuracy = coords.accuracy;
122
+ out.altitude = coords.altitude ?? 0;
123
+ out.altitudeAccuracy = coords.altitudeAccuracy ?? 0;
124
+ out.floorLevel = coords.floorLevel ?? 0;
125
+ out.heading = coords.heading ?? 0;
126
+ out.latitude = coords.latitude;
127
+ out.longitude = coords.longitude;
128
+ out.speed = coords.speed ?? 0;
129
+ out.timestamp = position.timestamp;
130
+ return finishEntity(out);
196
131
  }
197
132
  function mapWebAccessError(error) {
198
133
  switch (error.code) {
@@ -1 +1 @@
1
- {"version":3,"file":"geolocation.js","sourceRoot":"","sources":["../src/geolocation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAYzD,MAAM,UAAU,qBAAqB,CAAC,EAAU;IAC9C,qBAAqB,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,iBAAiB;IAC/B,OAAO,YAAY,CAAC;QAClB,QAAQ,EAAE,CAAC;QACX,QAAQ,EAAE,CAAC;QACX,gBAAgB,EAAE,CAAC;QACnB,UAAU,EAAE,CAAC;QACb,OAAO,EAAE,CAAC;QACV,QAAQ,EAAE,CAAC;QACX,SAAS,EAAE,CAAC;QACZ,KAAK,EAAE,CAAC;QACR,SAAS,EAAE,CAAC;KACb,CAAC,CAAC;AACL,CAAC;AAED,gGAAgG;AAChG,oGAAoG;AACpG,qDAAqD;AACrD,MAAM,UAAU,2BAA2B;IACzC,OAAO,YAAY,CAAyC;QAC1D,UAAU,CAAC,EAAE;YACX,MAAM,GAAG,GAAG,iBAAiB,EAAE,CAAC;YAChC,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,CAAC,U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E,OAAO;QACL,kBAAkB,EAAE,OAAO,CAAC,kBAAkB,IAAI,KAAK;QACvD,UAAU,EAAE,OAAO,CAAC,YAAY;QAChC,OAAO,EAAE,OAAO,CAAC,SAAS;KAC3B,CAAC;AACJ,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { explainGeolocationBackend, clearGeolocationWatch, createGeoPosition, getCurrentGeoPosition, getCurrentGeoPositionResult, isGeolocationAvailable, promptForGeolocationAccess, watchGeolocationPosition, } from './contract';
1
+ export { clearGeolocationWatch, createGeoPosition, getCurrentGeoPosition, getCurrentGeoPositionResult, isGeolocationAvailable, promptForGeolocationAccess, watchGeolocationPosition, } from './contract';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,EACrB,2BAA2B,EAC3B,sBAAsB,EACtB,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,EACrB,2BAA2B,EAC3B,sBAAsB,EACtB,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { explainGeolocationBackend, clearGeolocationWatch, createGeoPosition, getCurrentGeoPosition, getCurrentGeoPositionResult, isGeolocationAvailable, promptForGeolocationAccess, watchGeolocationPosition, } from './contract';
1
+ export { clearGeolocationWatch, createGeoPosition, getCurrentGeoPosition, getCurrentGeoPositionResult, isGeolocationAvailable, promptForGeolocationAccess, watchGeolocationPosition, } from './contract';
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,EACrB,2BAA2B,EAC3B,sBAAsB,EACtB,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,EACrB,2BAA2B,EAC3B,sBAAsB,EACtB,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,YAAY,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flighthq/geolocation",
3
- "version": "0.5.1-edge.799.62ef0c7",
3
+ "version": "0.5.1-edge.911.32a089f",
4
4
  "author": "Joshua Granick and other contributors",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -38,8 +38,8 @@
38
38
  "clean:dist": "tsx ../../scripts/clean-package-dist.ts"
39
39
  },
40
40
  "dependencies": {
41
- "@flighthq/entity": "0.5.1-edge.799.62ef0c7",
42
- "@flighthq/types": "0.5.1-edge.799.62ef0c7"
41
+ "@flighthq/entity": "0.5.1-edge.911.32a089f",
42
+ "@flighthq/types": "0.5.1-edge.911.32a089f"
43
43
  },
44
44
  "devDependencies": {
45
45
  "typescript": "^5.3.0"
@@ -1,5 +1,11 @@
1
- import { createEntity } from '@flighthq/entity/contract';
2
- import type { Entity, GeolocationBackend, GeolocationErrorReason, GeoPosition } from '@flighthq/types/contract';
1
+ import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
2
+ import type {
3
+ Entity,
4
+ GeolocationBackend,
5
+ GeolocationErrorReason,
6
+ GeoPosition,
7
+ HasSystemGeolocation,
8
+ } from '@flighthq/types/contract';
3
9
  import { EntityRuntimeKey } from '@flighthq/types/contract';
4
10
 
5
11
  import {
@@ -8,63 +14,57 @@ import {
8
14
  createWebGeolocationBackend,
9
15
  getCurrentGeoPosition,
10
16
  getCurrentGeoPositionResult,
11
- getGeolocationBackend,
17
+ initializeGeoPosition,
18
+ initializeWebGeolocationBackend,
12
19
  isGeolocationAvailable,
13
- setGeolocationBackend,
14
20
  watchGeolocationPosition,
15
- explainGeolocationBackend,
16
- installGeolocationHostBackend,
17
- observeGeolocationHostResult,
18
- resetGeolocationBackendForTest,
19
21
  } from './geolocation';
20
22
 
21
23
  function fakeBackend(available: boolean = true): GeolocationBackend & { cleared: number[]; lastWatch: number } {
22
- return createEntity<Omit<GeolocationBackend & { cleared: number[]; lastWatch: number }, keyof Entity>>({
23
- cleared: [],
24
- lastWatch: 0,
25
- promptForAccess: () => Promise.resolve({ reason: 'granted' as const }),
26
- clearWatch(id) {
27
- this.cleared.push(id);
28
- },
29
- async getCurrentPosition() {
30
- const position = createGeoPosition();
31
- position.latitude = 1;
32
- position.longitude = 2;
33
- return position;
34
- },
35
- async getCurrentPositionResult() {
36
- const position = createGeoPosition();
37
- position.latitude = 1;
38
- position.longitude = 2;
39
- return { position, reason: null };
40
- },
41
- isAvailable() {
42
- return available;
43
- },
44
- watchPosition(listener, _options, onError) {
45
- const position = createGeoPosition();
46
- position.latitude = 3;
47
- listener(position);
48
- if (onError) onError('denied');
49
- return ++this.lastWatch;
50
- },
51
- });
24
+ const out = allocateEntity<any>();
25
+ out.cleared = [];
26
+ out.lastWatch = 0;
27
+ out.promptForAccess = () => Promise.resolve({ reason: 'granted' as const });
28
+ out.clearWatch = (id: number) => {
29
+ out.cleared.push(id);
30
+ };
31
+ out.getCurrentPosition = async () => {
32
+ const position = createGeoPosition();
33
+ position.latitude = 1;
34
+ position.longitude = 2;
35
+ return position;
36
+ };
37
+ out.getCurrentPositionResult = async () => {
38
+ const position = createGeoPosition();
39
+ position.latitude = 1;
40
+ position.longitude = 2;
41
+ return { position, reason: null };
42
+ };
43
+ out.isAvailable = () => {
44
+ return available;
45
+ };
46
+ out.watchPosition = (
47
+ listener: (position: GeoPosition) => void,
48
+ _options: Record<string, unknown>,
49
+ onError?: (reason: GeolocationErrorReason) => void,
50
+ ) => {
51
+ const position = createGeoPosition();
52
+ position.latitude = 3;
53
+ listener(position);
54
+ if (onError) onError('denied');
55
+ return ++out.lastWatch;
56
+ };
57
+ return finishEntity(out);
52
58
  }
53
59
 
54
- afterEach(() => {
55
- resetGeolocationBackendForTest();
56
- vi.unstubAllGlobals();
57
- });
60
+ function hostWith(backend: GeolocationBackend): HasSystemGeolocation {
61
+ return { system: { geolocation: backend } } as HasSystemGeolocation;
62
+ }
58
63
 
59
64
  describe('clearGeolocationWatch', () => {
60
- it('does not throw on the web backend in jsdom', () => {
61
- expect(() => clearGeolocationWatch(0)).not.toThrow();
62
- });
63
-
64
- it('forwards the id to the active backend', () => {
65
+ it('forwards the id to the host backend', () => {
65
66
  const backend = fakeBackend();
66
- setGeolocationBackend(backend);
67
- clearGeolocationWatch(7);
67
+ clearGeolocationWatch(hostWith(backend), 7);
68
68
  expect(backend.cleared).toEqual([7]);
69
69
  });
70
70
  });
@@ -153,40 +153,13 @@ describe('createWebGeolocationBackend', () => {
153
153
  vi.stubGlobal('window', { isSecureContext: true });
154
154
  expect(backend.isAvailable()).toBe(false);
155
155
  });
156
- });
157
-
158
- describe('explainGeolocationBackend', () => {
159
- afterEach(() => resetGeolocationBackendForTest());
160
-
161
- it('reports host-not-enabled when no backend is installed', () => {
162
- resetGeolocationBackendForTest();
163
- const explanation = explainGeolocationBackend();
164
- expect(explanation.layer).toBe('host-not-enabled');
165
- expect(explanation.conflict).toBe(false);
166
- expect(explanation.viability).toBe('unobserved');
167
- });
168
-
169
- it('reports custom layer when a custom backend is set', () => {
170
- setGeolocationBackend(fakeBackend());
171
- expect(explainGeolocationBackend().layer).toBe('custom');
172
- });
173
-
174
- it('reports host layer when a host backend is installed', () => {
175
- installGeolocationHostBackend(fakeBackend());
176
- expect(explainGeolocationBackend().layer).toBe('host');
177
- });
178
156
 
179
- it('reports conflict when two different host backends are installed', () => {
180
- installGeolocationHostBackend(fakeBackend());
181
- installGeolocationHostBackend(fakeBackend());
182
- expect(explainGeolocationBackend().conflict).toBe(true);
183
- });
157
+ afterEach(() => vi.unstubAllGlobals());
184
158
  });
185
159
 
186
160
  describe('getCurrentGeoPosition', () => {
187
161
  it('returns the backend position', async () => {
188
- setGeolocationBackend(fakeBackend());
189
- const position = (await getCurrentGeoPosition()) as GeoPosition;
162
+ const position = (await getCurrentGeoPosition(hostWith(fakeBackend()))) as GeoPosition;
190
163
  expect(position.latitude).toBe(1);
191
164
  expect(position.longitude).toBe(2);
192
165
  });
@@ -194,116 +167,35 @@ describe('getCurrentGeoPosition', () => {
194
167
 
195
168
  describe('getCurrentGeoPositionResult', () => {
196
169
  it('returns position and null reason on success', async () => {
197
- setGeolocationBackend(fakeBackend());
198
- const result = await getCurrentGeoPositionResult();
170
+ const result = await getCurrentGeoPositionResult(hostWith(fakeBackend()));
199
171
  expect(result.position).not.toBeNull();
200
172
  expect(result.position!.latitude).toBe(1);
201
173
  expect(result.reason).toBeNull();
202
174
  });
203
-
204
- it('returns null position with a reason on failure (web backend in jsdom)', async () => {
205
- const result = await getCurrentGeoPositionResult();
206
- expect(result.position).toBeNull();
207
- expect(result.reason).toBe('unavailable');
208
- });
209
175
  });
210
176
 
211
- describe('getGeolocationBackend', () => {
212
- it('falls back to a web backend', () => {
213
- expect(getGeolocationBackend()).not.toBeNull();
214
- });
215
-
216
- it('returns the registered backend', () => {
217
- const backend = fakeBackend();
218
- setGeolocationBackend(backend);
219
- expect(getGeolocationBackend()).toBe(backend);
177
+ describe('initializeGeoPosition', () => {
178
+ it('is the construction initializer of createGeoPosition', () => {
179
+ expect(typeof initializeGeoPosition).toBe('function');
220
180
  });
221
181
  });
222
182
 
223
- describe('installGeolocationHostBackend', () => {
224
- afterEach(() => resetGeolocationBackendForTest());
225
-
226
- it('installs a host backend that getGeolocationBackend returns', () => {
227
- const backend = fakeBackend();
228
- installGeolocationHostBackend(backend);
229
- expect(getGeolocationBackend()).toBe(backend);
230
- });
231
-
232
- it('is first-host-wins: a second different backend sets conflict', () => {
233
- const first = fakeBackend();
234
- const second = fakeBackend();
235
- installGeolocationHostBackend(first);
236
- installGeolocationHostBackend(second);
237
- expect(getGeolocationBackend()).toBe(first);
238
- expect(explainGeolocationBackend().conflict).toBe(true);
183
+ describe('initializeWebGeolocationBackend', () => {
184
+ it('is the construction initializer of createWebGeolocationBackend', () => {
185
+ expect(typeof initializeWebGeolocationBackend).toBe('function');
239
186
  });
240
187
  });
241
-
242
188
  describe('isGeolocationAvailable', () => {
243
- it('returns the false sentinel even when browser geolocation exists', () => {
244
- vi.stubGlobal('navigator', { geolocation: {} });
245
- vi.stubGlobal('window', { isSecureContext: true });
246
- expect(isGeolocationAvailable()).toBe(false);
247
- });
248
-
249
- it('routes a custom available provider when DOM globals are absent', () => {
250
- vi.stubGlobal('navigator', undefined);
251
- vi.stubGlobal('window', undefined);
252
- setGeolocationBackend(fakeBackend(true));
253
- expect(isGeolocationAvailable()).toBe(true);
254
- });
255
-
256
- it('routes an unavailable host provider when browser geolocation exists', () => {
257
- vi.stubGlobal('navigator', { geolocation: {} });
258
- vi.stubGlobal('window', { isSecureContext: true });
259
- installGeolocationHostBackend(fakeBackend(false));
260
- expect(isGeolocationAvailable()).toBe(false);
261
- });
262
- });
263
-
264
- describe('observeGeolocationHostResult', () => {
265
- afterEach(() => resetGeolocationBackendForTest());
266
-
267
- it('records a successful observation', () => {
268
- installGeolocationHostBackend(fakeBackend());
269
- observeGeolocationHostResult('clearWatch', true);
270
- const explanation = explainGeolocationBackend();
271
- expect(explanation.operation).toBe('clearWatch');
272
- expect(explanation.viability).toBe('available');
273
- });
274
-
275
- it('records a failed observation', () => {
276
- installGeolocationHostBackend(fakeBackend());
277
- observeGeolocationHostResult('clearWatch', false);
278
- expect(explainGeolocationBackend().viability).toBe('runtime-api-unavailable');
279
- });
280
- });
281
-
282
- describe('resetGeolocationBackendForTest', () => {
283
- it('clears all backend slots', () => {
284
- setGeolocationBackend(fakeBackend());
285
- installGeolocationHostBackend(fakeBackend());
286
- observeGeolocationHostResult('clearWatch', true);
287
- resetGeolocationBackendForTest();
288
- expect(explainGeolocationBackend().layer).toBe('host-not-enabled');
289
- expect(explainGeolocationBackend().conflict).toBe(false);
290
- expect(explainGeolocationBackend().viability).toBe('unobserved');
291
- });
292
- });
293
-
294
- describe('setGeolocationBackend', () => {
295
- it('clears back to the web fallback when passed null', () => {
296
- setGeolocationBackend(fakeBackend());
297
- setGeolocationBackend(null);
298
- expect(getGeolocationBackend()).not.toBeNull();
189
+ it('routes the host backend availability', () => {
190
+ expect(isGeolocationAvailable(hostWith(fakeBackend(true)))).toBe(true);
191
+ expect(isGeolocationAvailable(hostWith(fakeBackend(false)))).toBe(false);
299
192
  });
300
193
  });
301
194
 
302
195
  describe('watchGeolocationPosition', () => {
303
196
  it('delivers positions and returns a watch id', () => {
304
- setGeolocationBackend(fakeBackend());
305
197
  let seen = 0;
306
- const id = watchGeolocationPosition((position) => {
198
+ const id = watchGeolocationPosition(hostWith(fakeBackend()), (position) => {
307
199
  seen = position.latitude;
308
200
  });
309
201
  expect(id).toBe(1);
@@ -311,17 +203,13 @@ describe('watchGeolocationPosition', () => {
311
203
  });
312
204
 
313
205
  it('delivers error reasons when onError is provided', () => {
314
- setGeolocationBackend(fakeBackend());
315
206
  const errors: GeolocationErrorReason[] = [];
316
207
  watchGeolocationPosition(
208
+ hostWith(fakeBackend()),
317
209
  () => {},
318
210
  {},
319
211
  (reason) => errors.push(reason),
320
212
  );
321
213
  expect(errors).toEqual(['denied']);
322
214
  });
323
-
324
- it('returns -1 from the web backend when watching is unavailable', () => {
325
- expect(watchGeolocationPosition(() => {})).toBe(-1);
326
- });
327
215
  });