@flighthq/geolocation 0.5.1-next.1295.2b6bfa3 → 0.5.1-next.1345.0995dc5

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-next.1295.2b6bfa3](https://github.com/flighthq/flight/tree/2b6bfa33110e26cbdd959441a6c36a4c78109ab8/packages/geolocation)
17
- - [License](https://github.com/flighthq/flight/blob/2b6bfa33110e26cbdd959441a6c36a4c78109ab8/LICENSE.md)
16
+ - [Source for @flighthq/geolocation@0.5.1-next.1345.0995dc5](https://github.com/flighthq/flight/tree/0995dc5f840e6b57c3e85ecd2123aa798cf60b29/packages/geolocation)
17
+ - [License](https://github.com/flighthq/flight/blob/0995dc5f840e6b57c3e85ecd2123aa798cf60b29/LICENSE.md)
@@ -1,4 +1,4 @@
1
1
  export * from './geolocation';
2
2
  export * from './geolocationAccess';
3
- export { initializeGeolocationPosition, initializeWebGeolocationBackend } from './geolocation';
3
+ export { initializeGeolocationPosition } from './geolocation';
4
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;AACpC,OAAO,EAAE,6BAA6B,EAAE,+BAA+B,EAAE,MAAM,eAAe,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,6BAA6B,EAAE,MAAM,eAAe,CAAC"}
package/dist/contract.js CHANGED
@@ -1,4 +1,4 @@
1
1
  export * from './geolocation';
2
2
  export * from './geolocationAccess';
3
- export { initializeGeolocationPosition, initializeWebGeolocationBackend } from './geolocation';
3
+ export { initializeGeolocationPosition } from './geolocation';
4
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;AACpC,OAAO,EAAE,6BAA6B,EAAE,+BAA+B,EAAE,MAAM,eAAe,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,6BAA6B,EAAE,MAAM,eAAe,CAAC"}
@@ -1,11 +1,9 @@
1
1
  import type { HostGeolocationProvider, GeolocationErrorReason, GeolocationPosition as FlightGeolocationPosition, GeolocationPositionResult, GeolocationRequestOptions, EntityConstruction } from '@flighthq/types/contract';
2
2
  export declare function clearGeolocationWatch(hostGeolocation: Readonly<HostGeolocationProvider>, id: number): void;
3
3
  export declare function createGeolocationPosition(): FlightGeolocationPosition;
4
- export declare function createWebGeolocationBackend(): HostGeolocationProvider;
5
4
  export declare function getCurrentGeolocationPosition(hostGeolocation: Readonly<HostGeolocationProvider>, options?: Readonly<GeolocationRequestOptions>): Promise<FlightGeolocationPosition | null>;
6
5
  export declare function getCurrentGeolocationPositionResult(hostGeolocation: Readonly<HostGeolocationProvider>, options?: Readonly<GeolocationRequestOptions>): Promise<GeolocationPositionResult>;
7
6
  export declare function initializeGeolocationPosition(out: EntityConstruction<FlightGeolocationPosition>): void;
8
- export declare function initializeWebGeolocationBackend(out: EntityConstruction<HostGeolocationProvider>): void;
9
7
  export declare function isGeolocationAvailable(hostGeolocation: Readonly<HostGeolocationProvider>): boolean;
10
8
  export declare function watchGeolocationPosition(hostGeolocation: Readonly<HostGeolocationProvider>, handler: (position: Readonly<FlightGeolocationPosition>) => void, options?: Readonly<GeolocationRequestOptions>, onError?: (reason: GeolocationErrorReason) => void): number;
11
9
  //# 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,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,uB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,KAAK,IAAI,EAChE,OAAO,CAAC,EAAE,QAAQ,CAAC,yBAAyB,CAAC,EAC7C,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,sBAAsB,KAAK,IAAI,GACjD,MAAM,CAER"}
@@ -7,11 +7,6 @@ export function createGeolocationPosition() {
7
7
  initializeGeolocationPosition(out);
8
8
  return finishEntity(out);
9
9
  }
10
- export function createWebGeolocationBackend() {
11
- const out = allocateEntity();
12
- initializeWebGeolocationBackend(out);
13
- return finishEntity(out);
14
- }
15
10
  export function getCurrentGeolocationPosition(hostGeolocation, options) {
16
11
  return hostGeolocation.getCurrentPosition(options ?? _emptyOptions);
17
12
  }
@@ -29,80 +24,6 @@ export function initializeGeolocationPosition(out) {
29
24
  out.speed = 0;
30
25
  out.timestamp = 0;
31
26
  }
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) => {
46
- const geo = getWebGeolocation();
47
- if (geo === null || typeof geo.getCurrentPosition !== 'function') {
48
- resolve(null);
49
- return;
50
- }
51
- try {
52
- geo.getCurrentPosition((position) => resolve(mapWebPosition(position)), () => resolve(null), toPositionOptions(options));
53
- }
54
- catch {
55
- resolve(null);
56
- }
57
- });
58
- };
59
- out.getCurrentPositionResult = (options) => {
60
- return new Promise((resolve) => {
61
- const geo = getWebGeolocation();
62
- if (geo === null || typeof geo.getCurrentPosition !== 'function') {
63
- resolve({ position: null, reason: 'unavailable' });
64
- return;
65
- }
66
- try {
67
- geo.getCurrentPosition((position) => resolve({ position: mapWebPosition(position), reason: null }), (error) => resolve({ position: null, reason: mapWebPositionError(error) }), toPositionOptions(options));
68
- }
69
- catch {
70
- resolve({ position: null, reason: 'unavailable' });
71
- }
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
- }
104
- };
105
- }
106
27
  export function isGeolocationAvailable(hostGeolocation) {
107
28
  return hostGeolocation.isAvailable();
108
29
  }
@@ -110,50 +31,4 @@ export function watchGeolocationPosition(hostGeolocation, handler, options, onEr
110
31
  return hostGeolocation.watchPosition(handler, options ?? _emptyOptions, onError);
111
32
  }
112
33
  const _emptyOptions = {};
113
- function getWebGeolocation() {
114
- if (typeof navigator === 'undefined')
115
- return null;
116
- return navigator.geolocation ?? null;
117
- }
118
- function mapWebPosition(position) {
119
- const coords = position.coords;
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);
131
- }
132
- function mapWebAccessError(error) {
133
- switch (error.code) {
134
- case 1:
135
- return 'denied';
136
- case 3:
137
- return 'timeout';
138
- default:
139
- return 'operation-failed';
140
- }
141
- }
142
- function mapWebPositionError(error) {
143
- switch (error.code) {
144
- case 1:
145
- return 'denied';
146
- case 3:
147
- return 'timeout';
148
- default:
149
- return 'unavailable';
150
- }
151
- }
152
- function toPositionOptions(options) {
153
- return {
154
- enableHighAccuracy: options.enableHighAccuracy ?? false,
155
- maximumAge: options.maximumAgeMs,
156
- timeout: options.timeoutMs,
157
- };
158
- }
159
34
  //# sourceMappingURL=geolocation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"geolocation.js","sourceRoot":"","sources":["../src/geolocation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAWzE,MAAM,UAAU,qBAAqB,CAAC,eAAkD,EAAE,EAAU;IAClG,eAAe,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,yBAAyB;IACvC,MAAM,GAAG,GAAG,cAAc,EAA6B,CAAC;IACxD,6BAA6B,CAAC,GAAG,CAAC,CAAC;IACnC,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,2BAA2B;IACzC,MAAM,GAAG,GAAG,cAAc,EAA2B,CAAC;IACtD,+BAA+B,CAAC,GAAG,CAAC,CAAC;IACrC,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,6BAA6B,CAC3C,eAAkD,EAClD,OAA6C;IAE7C,OAAO,eAAe,CAAC,kBAAkB,CAAC,OAAO,IAAI,aAAa,CAAC,CAAC;AACtE,CAAC;AAED,MAAM,UAAU,mCAAmC,CACjD,eAAkD,EAClD,OAA6C;IAE7C,OAAO,eAAe,CAAC,wBAAwB,CAAC,OAAO,IAAI,aAAa,CAAC,CAAC;AAC5E,CAAC;AAED,MAAM,UAAU,6BAA6B,CAAC,GAAkD;IAC9F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CAAC;AACtE,CAAC;AAED,MAAM,UAAU,mCAAmC,CACjD,eAAkD,EAClD,OAA6C;IAE7C,OAAO,eAAe,CAAC,wBAAwB,CAAC,OAAO,IAAI,aAAa,CAAC,CAAC;AAC5E,CAAC;AAED,MAAM,UAAU,6BAA6B,CAAC,GAAkD;IAC9F,GAAG,CAAC,QAAQ,GAAG,CAAC,CAAC;IACjB,GAAG,CAAC,QAAQ,GAAG,CAAC,CAAC;IACjB,GAAG,CAAC,gBAAgB,GAAG,CAAC,CAAC;IACzB,GAAG,CAAC,UAAU,GAAG,CAAC,CAAC;IACnB,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC;IAChB,GAAG,CAAC,QAAQ,GAAG,CAAC,CAAC;IACjB,GAAG,CAAC,SAAS,GAAG,CAAC,CAAC;IAClB,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC;IACd,GAAG,CAAC,SAAS,GAAG,CAAC,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,eAAkD;IACvF,OAAO,eAAe,CAAC,WAAW,EAAE,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,wBAAwB,CACtC,eAAkD,EAClD,OAAgE,EAChE,OAA6C,EAC7C,OAAkD;IAElD,OAAO,eAAe,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,OAAO,CAAC,CAAC;AACnF,CAAC;AAED,MAAM,aAAa,GAA8B,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flighthq/geolocation",
3
- "version": "0.5.1-next.1295.2b6bfa3",
3
+ "version": "0.5.1-next.1345.0995dc5",
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.1295.2b6bfa3",
42
- "@flighthq/types": "0.5.1-next.1295.2b6bfa3"
41
+ "@flighthq/entity": "0.5.1-next.1345.0995dc5",
42
+ "@flighthq/types": "0.5.1-next.1345.0995dc5"
43
43
  },
44
44
  "devDependencies": {
45
45
  "typescript": "^5.3.0"
@@ -10,11 +10,9 @@ import { EntityRuntimeKey } from '@flighthq/types/contract';
10
10
  import {
11
11
  clearGeolocationWatch,
12
12
  createGeolocationPosition,
13
- createWebGeolocationBackend,
14
13
  getCurrentGeolocationPosition,
15
14
  getCurrentGeolocationPositionResult,
16
15
  initializeGeolocationPosition,
17
- initializeWebGeolocationBackend,
18
16
  isGeolocationAvailable,
19
17
  watchGeolocationPosition,
20
18
  } from './geolocation';
@@ -88,76 +86,6 @@ describe('createGeolocationPosition', () => {
88
86
  });
89
87
  });
90
88
 
91
- describe('createWebGeolocationBackend', () => {
92
- it('resolves null and does not throw when geolocation is absent', async () => {
93
- const backend = createWebGeolocationBackend();
94
- expect(await backend.getCurrentPosition({})).toBeNull();
95
- expect(typeof backend.watchPosition(() => {}, {})).toBe('number');
96
- expect(() => backend.clearWatch(-1)).not.toThrow();
97
- });
98
-
99
- it('getCurrentPositionResult returns unavailable reason when geolocation is absent', async () => {
100
- const backend = createWebGeolocationBackend();
101
- const result = await backend.getCurrentPositionResult({});
102
- expect(result.position).toBeNull();
103
- expect(result.reason).toBe('unavailable');
104
- });
105
-
106
- it('reads a host-provided floorLevel from coords', async () => {
107
- const hadOwn = Object.prototype.hasOwnProperty.call(navigator, 'geolocation');
108
- const original =
109
- Object.getOwnPropertyDescriptor(navigator, 'geolocation') ??
110
- Object.getOwnPropertyDescriptor(Object.getPrototypeOf(navigator), 'geolocation');
111
- Object.defineProperty(navigator, 'geolocation', {
112
- configurable: true,
113
- value: {
114
- getCurrentPosition(success: (position: unknown) => void) {
115
- success({
116
- coords: {
117
- accuracy: 5,
118
- altitude: null,
119
- altitudeAccuracy: null,
120
- floorLevel: 3,
121
- heading: null,
122
- latitude: 1,
123
- longitude: 2,
124
- speed: null,
125
- },
126
- timestamp: 123,
127
- });
128
- },
129
- },
130
- });
131
- try {
132
- const backend = createWebGeolocationBackend();
133
- const position = await backend.getCurrentPosition({});
134
- expect(position?.floorLevel).toBe(3);
135
- } finally {
136
- if (hadOwn && original !== undefined) {
137
- Object.defineProperty(navigator, 'geolocation', original);
138
- } else {
139
- delete (navigator as { geolocation?: unknown }).geolocation;
140
- }
141
- }
142
- });
143
-
144
- it('reports availability only when geolocation exists in a secure context', () => {
145
- const backend = createWebGeolocationBackend();
146
- vi.stubGlobal('navigator', { geolocation: {} });
147
- vi.stubGlobal('window', { isSecureContext: true });
148
- expect(backend.isAvailable()).toBe(true);
149
-
150
- vi.stubGlobal('window', { isSecureContext: false });
151
- expect(backend.isAvailable()).toBe(false);
152
-
153
- vi.stubGlobal('navigator', {});
154
- vi.stubGlobal('window', { isSecureContext: true });
155
- expect(backend.isAvailable()).toBe(false);
156
- });
157
-
158
- afterEach(() => vi.unstubAllGlobals());
159
- });
160
-
161
89
  describe('getCurrentGeolocationPosition', () => {
162
90
  it('returns the backend position', async () => {
163
91
  const position = (await getCurrentGeolocationPosition(
@@ -183,11 +111,6 @@ describe('initializeGeolocationPosition', () => {
183
111
  });
184
112
  });
185
113
 
186
- describe('initializeWebGeolocationBackend', () => {
187
- it('is the construction initializer of createWebGeolocationBackend', () => {
188
- expect(typeof initializeWebGeolocationBackend).toBe('function');
189
- });
190
- });
191
114
  describe('isGeolocationAvailable', () => {
192
115
  it('routes the host backend availability', () => {
193
116
  expect(isGeolocationAvailable(hostWith(fakeBackend(true)).system.geolocation)).toBe(true);