@flighthq/geolocation 0.5.1-next.1069.554a2ac → 0.5.1-next.1201.9b49dee
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 +2 -2
- package/dist/geolocation.d.ts +8 -8
- package/dist/geolocation.d.ts.map +1 -1
- package/dist/geolocation.js +10 -10
- package/dist/geolocation.js.map +1 -1
- package/dist/geolocationAccess.d.ts +2 -2
- package/dist/geolocationAccess.d.ts.map +1 -1
- package/dist/geolocationAccess.js +3 -4
- package/dist/geolocationAccess.js.map +1 -1
- package/package.json +3 -3
- package/src/geolocation.test.ts +15 -12
- package/src/geolocationAccess.test.ts +11 -17
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-next.
|
|
17
|
-
- [License](https://github.com/flighthq/flight/blob/
|
|
16
|
+
- [Source for @flighthq/geolocation@0.5.1-next.1201.9b49dee](https://github.com/flighthq/flight/tree/9b49dee3f22f6b2838c3d237edcc77bca65734f2/packages/geolocation)
|
|
17
|
+
- [License](https://github.com/flighthq/flight/blob/9b49dee3f22f6b2838c3d237edcc77bca65734f2/LICENSE.md)
|
package/dist/geolocation.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function clearGeolocationWatch(
|
|
1
|
+
import type { HostGeolocationProvider, GeolocationErrorReason, GeolocationPosition as FlightGeolocationPosition, GeolocationPositionResult, GeolocationRequestOptions, EntityConstruction } from '@flighthq/types/contract';
|
|
2
|
+
export declare function clearGeolocationWatch(hostGeolocation: Readonly<HostGeolocationProvider>, id: number): void;
|
|
3
3
|
export declare function createGeolocationPosition(): FlightGeolocationPosition;
|
|
4
|
-
export declare function createWebGeolocationBackend():
|
|
5
|
-
export declare function getCurrentGeolocationPosition(
|
|
6
|
-
export declare function getCurrentGeolocationPositionResult(
|
|
4
|
+
export declare function createWebGeolocationBackend(): HostGeolocationProvider;
|
|
5
|
+
export declare function getCurrentGeolocationPosition(hostGeolocation: Readonly<HostGeolocationProvider>, options?: Readonly<GeolocationRequestOptions>): Promise<FlightGeolocationPosition | null>;
|
|
6
|
+
export declare function getCurrentGeolocationPositionResult(hostGeolocation: Readonly<HostGeolocationProvider>, options?: Readonly<GeolocationRequestOptions>): Promise<GeolocationPositionResult>;
|
|
7
7
|
export declare function initializeGeolocationPosition(out: EntityConstruction<FlightGeolocationPosition>): void;
|
|
8
|
-
export declare function initializeWebGeolocationBackend(out: EntityConstruction<
|
|
9
|
-
export declare function isGeolocationAvailable(
|
|
10
|
-
export declare function watchGeolocationPosition(
|
|
8
|
+
export declare function initializeWebGeolocationBackend(out: EntityConstruction<HostGeolocationProvider>): void;
|
|
9
|
+
export declare function isGeolocationAvailable(hostGeolocation: Readonly<HostGeolocationProvider>): boolean;
|
|
10
|
+
export declare function watchGeolocationPosition(hostGeolocation: Readonly<HostGeolocationProvider>, handler: (position: Readonly<FlightGeolocationPosition>) => void, options?: Readonly<GeolocationRequestOptions>, onError?: (reason: GeolocationErrorReason) => void): number;
|
|
11
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,EAEV,
|
|
1
|
+
{"version":3,"file":"geolocation.d.ts","sourceRoot":"","sources":["../src/geolocation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,IAAI,yBAAyB,EAChD,yBAAyB,EACzB,yBAAyB,EACzB,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAElC,wBAAgB,qBAAqB,CAAC,eAAe,EAAE,QAAQ,CAAC,uBAAuB,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAE1G;AAED,wBAAgB,yBAAyB,IAAI,yBAAyB,CAIrE;AAED,wBAAgB,2BAA2B,IAAI,uBAAuB,CAIrE;AAED,wBAAgB,6BAA6B,CAC3C,eAAe,EAAE,QAAQ,CAAC,uBAAuB,CAAC,EAClD,OAAO,CAAC,EAAE,QAAQ,CAAC,yBAAyB,CAAC,GAC5C,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC,CAE3C;AAED,wBAAgB,mCAAmC,CACjD,eAAe,EAAE,QAAQ,CAAC,uBAAuB,CAAC,EAClD,OAAO,CAAC,EAAE,QAAQ,CAAC,yBAAyB,CAAC,GAC5C,OAAO,CAAC,yBAAyB,CAAC,CAEpC;AAED,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,kBAAkB,CAAC,yBAAyB,CAAC,GAAG,IAAI,CAUtG;AAED,wBAAgB,+BAA+B,CAAC,GAAG,EAAE,kBAAkB,CAAC,uBAAuB,CAAC,GAAG,IAAI,CAgFtG;AAED,wBAAgB,sBAAsB,CAAC,eAAe,EAAE,QAAQ,CAAC,uBAAuB,CAAC,GAAG,OAAO,CAElG;AAED,wBAAgB,wBAAwB,CACtC,eAAe,EAAE,QAAQ,CAAC,uBAAuB,CAAC,EAClD,OAAO,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,yBAAyB,CAAC,KAAK,IAAI,EAChE,OAAO,CAAC,EAAE,QAAQ,CAAC,yBAAyB,CAAC,EAC7C,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,sBAAsB,KAAK,IAAI,GACjD,MAAM,CAER"}
|
package/dist/geolocation.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
|
-
export function clearGeolocationWatch(
|
|
3
|
-
|
|
2
|
+
export function clearGeolocationWatch(hostGeolocation, id) {
|
|
3
|
+
hostGeolocation.clearWatch(id);
|
|
4
4
|
}
|
|
5
5
|
export function createGeolocationPosition() {
|
|
6
6
|
const out = allocateEntity();
|
|
@@ -12,11 +12,11 @@ export function createWebGeolocationBackend() {
|
|
|
12
12
|
initializeWebGeolocationBackend(out);
|
|
13
13
|
return finishEntity(out);
|
|
14
14
|
}
|
|
15
|
-
export function getCurrentGeolocationPosition(
|
|
16
|
-
return
|
|
15
|
+
export function getCurrentGeolocationPosition(hostGeolocation, options) {
|
|
16
|
+
return hostGeolocation.getCurrentPosition(options ?? _emptyOptions);
|
|
17
17
|
}
|
|
18
|
-
export function getCurrentGeolocationPositionResult(
|
|
19
|
-
return
|
|
18
|
+
export function getCurrentGeolocationPositionResult(hostGeolocation, options) {
|
|
19
|
+
return hostGeolocation.getCurrentPositionResult(options ?? _emptyOptions);
|
|
20
20
|
}
|
|
21
21
|
export function initializeGeolocationPosition(out) {
|
|
22
22
|
out.accuracy = 0;
|
|
@@ -103,11 +103,11 @@ export function initializeWebGeolocationBackend(out) {
|
|
|
103
103
|
}
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
|
-
export function isGeolocationAvailable(
|
|
107
|
-
return
|
|
106
|
+
export function isGeolocationAvailable(hostGeolocation) {
|
|
107
|
+
return hostGeolocation.isAvailable();
|
|
108
108
|
}
|
|
109
|
-
export function watchGeolocationPosition(
|
|
110
|
-
return
|
|
109
|
+
export function watchGeolocationPosition(hostGeolocation, handler, options, onError) {
|
|
110
|
+
return hostGeolocation.watchPosition(handler, options ?? _emptyOptions, onError);
|
|
111
111
|
}
|
|
112
112
|
const _emptyOptions = {};
|
|
113
113
|
function getWebGeolocation() {
|
package/dist/geolocation.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geolocation.js","sourceRoot":"","sources":["../src/geolocation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAA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QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,CAAC;YACJ,OAAO,QAAQ,CAAC;QAClB,KAAK,CAAC;YACJ,OAAO,SAAS,CAAC;QACnB;YACE,OAAO,aAAa,CAAC;IACzB,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,OAA4C;IACrE,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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GeolocationAccessOutcome,
|
|
1
|
+
import type { GeolocationAccessOutcome, HostGeolocationProvider } from '@flighthq/types/contract';
|
|
2
2
|
/**
|
|
3
3
|
* Raises the platform's own location-access prompt through the host's geolocation provider.
|
|
4
4
|
*
|
|
@@ -10,5 +10,5 @@ import type { GeolocationAccessOutcome, Host } from '@flighthq/types/contract';
|
|
|
10
10
|
* Reports `runtime-unavailable` rather than throwing when no provider is installed: an absent host
|
|
11
11
|
* capability is an expected outcome, not API misuse.
|
|
12
12
|
*/
|
|
13
|
-
export declare function promptForGeolocationAccess(
|
|
13
|
+
export declare function promptForGeolocationAccess(hostGeolocation: Readonly<HostGeolocationProvider> | undefined): Promise<GeolocationAccessOutcome>;
|
|
14
14
|
//# sourceMappingURL=geolocationAccess.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geolocationAccess.d.ts","sourceRoot":"","sources":["../src/geolocationAccess.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,
|
|
1
|
+
{"version":3,"file":"geolocationAccess.d.ts","sourceRoot":"","sources":["../src/geolocationAccess.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAElG;;;;;;;;;;GAUG;AACH,wBAAsB,0BAA0B,CAC9C,eAAe,EAAE,QAAQ,CAAC,uBAAuB,CAAC,GAAG,SAAS,GAC7D,OAAO,CAAC,wBAAwB,CAAC,CASnC"}
|
|
@@ -9,13 +9,12 @@
|
|
|
9
9
|
* Reports `runtime-unavailable` rather than throwing when no provider is installed: an absent host
|
|
10
10
|
* capability is an expected outcome, not API misuse.
|
|
11
11
|
*/
|
|
12
|
-
export async function promptForGeolocationAccess(
|
|
13
|
-
|
|
14
|
-
if (backend === undefined || typeof backend.promptForAccess !== 'function') {
|
|
12
|
+
export async function promptForGeolocationAccess(hostGeolocation) {
|
|
13
|
+
if (hostGeolocation === undefined || typeof hostGeolocation.promptForAccess !== 'function') {
|
|
15
14
|
return { reason: 'runtime-unavailable' };
|
|
16
15
|
}
|
|
17
16
|
try {
|
|
18
|
-
return await
|
|
17
|
+
return await hostGeolocation.promptForAccess();
|
|
19
18
|
}
|
|
20
19
|
catch {
|
|
21
20
|
return { reason: 'operation-failed' };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geolocationAccess.js","sourceRoot":"","sources":["../src/geolocationAccess.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,
|
|
1
|
+
{"version":3,"file":"geolocationAccess.js","sourceRoot":"","sources":["../src/geolocationAccess.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,eAA8D;IAE9D,IAAI,eAAe,KAAK,SAAS,IAAI,OAAO,eAAe,CAAC,eAAe,KAAK,UAAU,EAAE,CAAC;QAC3F,OAAO,EAAE,MAAM,EAAE,qBAAqB,EAAE,CAAC;IAC3C,CAAC;IACD,IAAI,CAAC;QACH,OAAO,MAAM,eAAe,CAAC,eAAe,EAAE,CAAC;IACjD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,CAAC;IACxC,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/geolocation",
|
|
3
|
-
"version": "0.5.1-next.
|
|
3
|
+
"version": "0.5.1-next.1201.9b49dee",
|
|
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-next.
|
|
42
|
-
"@flighthq/types": "0.5.1-next.
|
|
41
|
+
"@flighthq/entity": "0.5.1-next.1201.9b49dee",
|
|
42
|
+
"@flighthq/types": "0.5.1-next.1201.9b49dee"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"typescript": "^5.3.0"
|
package/src/geolocation.test.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
2
|
import type {
|
|
3
3
|
Entity,
|
|
4
|
-
|
|
4
|
+
HostGeolocationProvider,
|
|
5
5
|
GeolocationErrorReason,
|
|
6
6
|
GeolocationPosition,
|
|
7
|
-
HasSystemGeolocation,
|
|
8
7
|
} from '@flighthq/types/contract';
|
|
9
8
|
import { EntityRuntimeKey } from '@flighthq/types/contract';
|
|
10
9
|
|
|
@@ -20,7 +19,7 @@ import {
|
|
|
20
19
|
watchGeolocationPosition,
|
|
21
20
|
} from './geolocation';
|
|
22
21
|
|
|
23
|
-
function fakeBackend(available: boolean = true):
|
|
22
|
+
function fakeBackend(available: boolean = true): HostGeolocationProvider & { cleared: number[]; lastWatch: number } {
|
|
24
23
|
const out = allocateEntity<any>();
|
|
25
24
|
out.cleared = [];
|
|
26
25
|
out.lastWatch = 0;
|
|
@@ -57,14 +56,16 @@ function fakeBackend(available: boolean = true): GeolocationBackend & { cleared:
|
|
|
57
56
|
return finishEntity(out);
|
|
58
57
|
}
|
|
59
58
|
|
|
60
|
-
function hostWith(backend:
|
|
61
|
-
|
|
59
|
+
function hostWith(backend: HostGeolocationProvider): {
|
|
60
|
+
readonly system: { readonly geolocation: HostGeolocationProvider };
|
|
61
|
+
} {
|
|
62
|
+
return { system: { geolocation: backend } } as { readonly system: { readonly geolocation: HostGeolocationProvider } };
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
describe('clearGeolocationWatch', () => {
|
|
65
66
|
it('forwards the id to the host backend', () => {
|
|
66
67
|
const backend = fakeBackend();
|
|
67
|
-
clearGeolocationWatch(hostWith(backend), 7);
|
|
68
|
+
clearGeolocationWatch(hostWith(backend).system.geolocation, 7);
|
|
68
69
|
expect(backend.cleared).toEqual([7]);
|
|
69
70
|
});
|
|
70
71
|
});
|
|
@@ -159,7 +160,9 @@ describe('createWebGeolocationBackend', () => {
|
|
|
159
160
|
|
|
160
161
|
describe('getCurrentGeolocationPosition', () => {
|
|
161
162
|
it('returns the backend position', async () => {
|
|
162
|
-
const position = (await getCurrentGeolocationPosition(
|
|
163
|
+
const position = (await getCurrentGeolocationPosition(
|
|
164
|
+
hostWith(fakeBackend()).system.geolocation,
|
|
165
|
+
)) as GeolocationPosition;
|
|
163
166
|
expect(position.latitude).toBe(1);
|
|
164
167
|
expect(position.longitude).toBe(2);
|
|
165
168
|
});
|
|
@@ -167,7 +170,7 @@ describe('getCurrentGeolocationPosition', () => {
|
|
|
167
170
|
|
|
168
171
|
describe('getCurrentGeolocationPositionResult', () => {
|
|
169
172
|
it('returns position and null reason on success', async () => {
|
|
170
|
-
const result = await getCurrentGeolocationPositionResult(hostWith(fakeBackend()));
|
|
173
|
+
const result = await getCurrentGeolocationPositionResult(hostWith(fakeBackend()).system.geolocation);
|
|
171
174
|
expect(result.position).not.toBeNull();
|
|
172
175
|
expect(result.position!.latitude).toBe(1);
|
|
173
176
|
expect(result.reason).toBeNull();
|
|
@@ -187,15 +190,15 @@ describe('initializeWebGeolocationBackend', () => {
|
|
|
187
190
|
});
|
|
188
191
|
describe('isGeolocationAvailable', () => {
|
|
189
192
|
it('routes the host backend availability', () => {
|
|
190
|
-
expect(isGeolocationAvailable(hostWith(fakeBackend(true)))).toBe(true);
|
|
191
|
-
expect(isGeolocationAvailable(hostWith(fakeBackend(false)))).toBe(false);
|
|
193
|
+
expect(isGeolocationAvailable(hostWith(fakeBackend(true)).system.geolocation)).toBe(true);
|
|
194
|
+
expect(isGeolocationAvailable(hostWith(fakeBackend(false)).system.geolocation)).toBe(false);
|
|
192
195
|
});
|
|
193
196
|
});
|
|
194
197
|
|
|
195
198
|
describe('watchGeolocationPosition', () => {
|
|
196
199
|
it('delivers positions and returns a watch id', () => {
|
|
197
200
|
let seen = 0;
|
|
198
|
-
const id = watchGeolocationPosition(hostWith(fakeBackend()), (position) => {
|
|
201
|
+
const id = watchGeolocationPosition(hostWith(fakeBackend()).system.geolocation, (position) => {
|
|
199
202
|
seen = position.latitude;
|
|
200
203
|
});
|
|
201
204
|
expect(id).toBe(1);
|
|
@@ -205,7 +208,7 @@ describe('watchGeolocationPosition', () => {
|
|
|
205
208
|
it('delivers error reasons when onError is provided', () => {
|
|
206
209
|
const errors: GeolocationErrorReason[] = [];
|
|
207
210
|
watchGeolocationPosition(
|
|
208
|
-
hostWith(fakeBackend()),
|
|
211
|
+
hostWith(fakeBackend()).system.geolocation,
|
|
209
212
|
() => {},
|
|
210
213
|
{},
|
|
211
214
|
(reason) => errors.push(reason),
|
|
@@ -1,23 +1,17 @@
|
|
|
1
|
-
import type { GeolocationAccessOutcome,
|
|
1
|
+
import type { GeolocationAccessOutcome, HostGeolocationProvider } from '@flighthq/types/contract';
|
|
2
2
|
|
|
3
3
|
import { promptForGeolocationAccess } from './geolocationAccess';
|
|
4
4
|
|
|
5
|
-
// A
|
|
6
|
-
// rest of
|
|
5
|
+
// A provider whose promptForAccess answer the test dictates. Only that member is exercised, so the
|
|
6
|
+
// rest of HostGeolocationProvider stays absent on purpose — a probe needing the whole provider would be
|
|
7
7
|
// testing the fake.
|
|
8
|
-
function
|
|
9
|
-
return { promptForAccess: () => Promise.resolve(outcome) } as unknown as
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function hostWith(backend: GeolocationBackend | undefined): Parameters<typeof promptForGeolocationAccess>[0] {
|
|
13
|
-
return { system: backend === undefined ? {} : { geolocation: backend } } as unknown as Parameters<
|
|
14
|
-
typeof promptForGeolocationAccess
|
|
15
|
-
>[0];
|
|
8
|
+
function providerAnswering(outcome: GeolocationAccessOutcome): HostGeolocationProvider {
|
|
9
|
+
return { promptForAccess: () => Promise.resolve(outcome) } as unknown as HostGeolocationProvider;
|
|
16
10
|
}
|
|
17
11
|
|
|
18
12
|
describe('promptForGeolocationAccess', () => {
|
|
19
13
|
it('reports granted when the host grants access', async () => {
|
|
20
|
-
expect(await promptForGeolocationAccess(
|
|
14
|
+
expect(await promptForGeolocationAccess(providerAnswering({ reason: 'granted' }))).toEqual({
|
|
21
15
|
reason: 'granted',
|
|
22
16
|
});
|
|
23
17
|
});
|
|
@@ -27,7 +21,7 @@ describe('promptForGeolocationAccess', () => {
|
|
|
27
21
|
it('keeps denied, dismissed and timeout as three distinct outcomes', async () => {
|
|
28
22
|
const reasons = await Promise.all(
|
|
29
23
|
(['denied', 'dismissed', 'timeout'] as const).map(
|
|
30
|
-
async (reason) => (await promptForGeolocationAccess(
|
|
24
|
+
async (reason) => (await promptForGeolocationAccess(providerAnswering({ reason }))).reason,
|
|
31
25
|
),
|
|
32
26
|
);
|
|
33
27
|
expect(reasons).toEqual(['denied', 'dismissed', 'timeout']);
|
|
@@ -35,21 +29,21 @@ describe('promptForGeolocationAccess', () => {
|
|
|
35
29
|
});
|
|
36
30
|
|
|
37
31
|
it('reports runtime-unavailable when no provider is installed', async () => {
|
|
38
|
-
expect(await promptForGeolocationAccess(
|
|
32
|
+
expect(await promptForGeolocationAccess(undefined)).toEqual({ reason: 'runtime-unavailable' });
|
|
39
33
|
});
|
|
40
34
|
|
|
41
35
|
it('reports operation-failed when the provider throws', async () => {
|
|
42
36
|
const throwing = {
|
|
43
37
|
promptForAccess: () => Promise.reject(new Error('boom')),
|
|
44
|
-
} as unknown as
|
|
45
|
-
expect(await promptForGeolocationAccess(
|
|
38
|
+
} as unknown as HostGeolocationProvider;
|
|
39
|
+
expect(await promptForGeolocationAccess(throwing)).toEqual({ reason: 'operation-failed' });
|
|
46
40
|
});
|
|
47
41
|
|
|
48
42
|
// A capability outcome, never permission vocabulary: G6 lets geolocation keep the mechanism only
|
|
49
43
|
// because what it returns is not a PermissionState. `state` must never appear on this type.
|
|
50
44
|
it('carries no permission state field on any arm', async () => {
|
|
51
45
|
for (const reason of ['granted', 'denied', 'dismissed', 'timeout', 'cleanup-failed'] as const) {
|
|
52
|
-
const outcome = await promptForGeolocationAccess(
|
|
46
|
+
const outcome = await promptForGeolocationAccess(providerAnswering({ reason }));
|
|
53
47
|
expect(Object.hasOwn(outcome, 'state')).toBe(false);
|
|
54
48
|
}
|
|
55
49
|
});
|