@mentra/miniapp 0.3.0-dev.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.md +259 -0
- package/dist/background/index.d.ts +59 -0
- package/dist/background/index.d.ts.map +1 -0
- package/dist/background/index.js +25 -0
- package/dist/background/index.js.map +1 -0
- package/dist/background/register.d.ts +38 -0
- package/dist/background/register.d.ts.map +1 -0
- package/dist/background/register.js +75 -0
- package/dist/background/register.js.map +1 -0
- package/dist/dev-reload.d.ts +21 -0
- package/dist/dev-reload.d.ts.map +1 -0
- package/dist/dev-reload.js +62 -0
- package/dist/dev-reload.js.map +1 -0
- package/dist/envelope.d.ts +23 -0
- package/dist/envelope.d.ts.map +1 -0
- package/dist/envelope.js +47 -0
- package/dist/envelope.js.map +1 -0
- package/dist/globals.d.ts +54 -0
- package/dist/globals.d.ts.map +1 -0
- package/dist/globals.js +12 -0
- package/dist/globals.js.map +1 -0
- package/dist/index.d.ts +58 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/modules/actions.d.ts +54 -0
- package/dist/modules/actions.d.ts.map +1 -0
- package/dist/modules/actions.js +122 -0
- package/dist/modules/actions.js.map +1 -0
- package/dist/modules/auth.d.ts +25 -0
- package/dist/modules/auth.d.ts.map +1 -0
- package/dist/modules/auth.js +52 -0
- package/dist/modules/auth.js.map +1 -0
- package/dist/modules/base64.d.ts +16 -0
- package/dist/modules/base64.d.ts.map +1 -0
- package/dist/modules/base64.js +92 -0
- package/dist/modules/base64.js.map +1 -0
- package/dist/modules/blob.d.ts +161 -0
- package/dist/modules/blob.d.ts.map +1 -0
- package/dist/modules/blob.js +277 -0
- package/dist/modules/blob.js.map +1 -0
- package/dist/modules/camera.d.ts +137 -0
- package/dist/modules/camera.d.ts.map +1 -0
- package/dist/modules/camera.js +104 -0
- package/dist/modules/camera.js.map +1 -0
- package/dist/modules/cloud.d.ts +34 -0
- package/dist/modules/cloud.d.ts.map +1 -0
- package/dist/modules/cloud.js +70 -0
- package/dist/modules/cloud.js.map +1 -0
- package/dist/modules/dashboard.d.ts +16 -0
- package/dist/modules/dashboard.d.ts.map +1 -0
- package/dist/modules/dashboard.js +27 -0
- package/dist/modules/dashboard.js.map +1 -0
- package/dist/modules/display.d.ts +106 -0
- package/dist/modules/display.d.ts.map +1 -0
- package/dist/modules/display.js +57 -0
- package/dist/modules/display.js.map +1 -0
- package/dist/modules/events.d.ts +167 -0
- package/dist/modules/events.d.ts.map +1 -0
- package/dist/modules/events.js +123 -0
- package/dist/modules/events.js.map +1 -0
- package/dist/modules/glasses.d.ts +28 -0
- package/dist/modules/glasses.d.ts.map +1 -0
- package/dist/modules/glasses.js +39 -0
- package/dist/modules/glasses.js.map +1 -0
- package/dist/modules/heading.d.ts +16 -0
- package/dist/modules/heading.d.ts.map +1 -0
- package/dist/modules/heading.js +20 -0
- package/dist/modules/heading.js.map +1 -0
- package/dist/modules/imu.d.ts +31 -0
- package/dist/modules/imu.d.ts.map +1 -0
- package/dist/modules/imu.js +40 -0
- package/dist/modules/imu.js.map +1 -0
- package/dist/modules/input.d.ts +34 -0
- package/dist/modules/input.d.ts.map +1 -0
- package/dist/modules/input.js +50 -0
- package/dist/modules/input.js.map +1 -0
- package/dist/modules/led.d.ts +35 -0
- package/dist/modules/led.d.ts.map +1 -0
- package/dist/modules/led.js +39 -0
- package/dist/modules/led.js.map +1 -0
- package/dist/modules/location.d.ts +27 -0
- package/dist/modules/location.d.ts.map +1 -0
- package/dist/modules/location.js +35 -0
- package/dist/modules/location.js.map +1 -0
- package/dist/modules/mic.d.ts +44 -0
- package/dist/modules/mic.d.ts.map +1 -0
- package/dist/modules/mic.js +67 -0
- package/dist/modules/mic.js.map +1 -0
- package/dist/modules/miniapps.d.ts +72 -0
- package/dist/modules/miniapps.d.ts.map +1 -0
- package/dist/modules/miniapps.js +48 -0
- package/dist/modules/miniapps.js.map +1 -0
- package/dist/modules/navigation.d.ts +326 -0
- package/dist/modules/navigation.d.ts.map +1 -0
- package/dist/modules/navigation.js +386 -0
- package/dist/modules/navigation.js.map +1 -0
- package/dist/modules/permissions.d.ts +58 -0
- package/dist/modules/permissions.d.ts.map +1 -0
- package/dist/modules/permissions.js +66 -0
- package/dist/modules/permissions.js.map +1 -0
- package/dist/modules/phone.d.ts +61 -0
- package/dist/modules/phone.d.ts.map +1 -0
- package/dist/modules/phone.js +94 -0
- package/dist/modules/phone.js.map +1 -0
- package/dist/modules/pivots/engine.d.ts +169 -0
- package/dist/modules/pivots/engine.d.ts.map +1 -0
- package/dist/modules/pivots/engine.js +779 -0
- package/dist/modules/pivots/engine.js.map +1 -0
- package/dist/modules/pivots/geometry.d.ts +84 -0
- package/dist/modules/pivots/geometry.d.ts.map +1 -0
- package/dist/modules/pivots/geometry.js +371 -0
- package/dist/modules/pivots/geometry.js.map +1 -0
- package/dist/modules/pivots/instructions.d.ts +139 -0
- package/dist/modules/pivots/instructions.d.ts.map +1 -0
- package/dist/modules/pivots/instructions.js +280 -0
- package/dist/modules/pivots/instructions.js.map +1 -0
- package/dist/modules/speaker.d.ts +163 -0
- package/dist/modules/speaker.d.ts.map +1 -0
- package/dist/modules/speaker.js +250 -0
- package/dist/modules/speaker.js.map +1 -0
- package/dist/modules/storage.d.ts +50 -0
- package/dist/modules/storage.d.ts.map +1 -0
- package/dist/modules/storage.js +99 -0
- package/dist/modules/storage.js.map +1 -0
- package/dist/modules/stream.d.ts +129 -0
- package/dist/modules/stream.d.ts.map +1 -0
- package/dist/modules/stream.js +52 -0
- package/dist/modules/stream.js.map +1 -0
- package/dist/modules/system.d.ts +45 -0
- package/dist/modules/system.d.ts.map +1 -0
- package/dist/modules/system.js +42 -0
- package/dist/modules/system.js.map +1 -0
- package/dist/modules/transcription.d.ts +67 -0
- package/dist/modules/transcription.d.ts.map +1 -0
- package/dist/modules/transcription.js +106 -0
- package/dist/modules/transcription.js.map +1 -0
- package/dist/modules/translation.d.ts +59 -0
- package/dist/modules/translation.d.ts.map +1 -0
- package/dist/modules/translation.js +119 -0
- package/dist/modules/translation.js.map +1 -0
- package/dist/modules/ui.d.ts +186 -0
- package/dist/modules/ui.d.ts.map +1 -0
- package/dist/modules/ui.js +293 -0
- package/dist/modules/ui.js.map +1 -0
- package/dist/protocol.d.ts +294 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +320 -0
- package/dist/protocol.js.map +1 -0
- package/dist/react/MentraProvider.d.ts +33 -0
- package/dist/react/MentraProvider.d.ts.map +1 -0
- package/dist/react/MentraProvider.js +15 -0
- package/dist/react/MentraProvider.js.map +1 -0
- package/dist/react/MiniappHeader.d.ts +44 -0
- package/dist/react/MiniappHeader.d.ts.map +1 -0
- package/dist/react/MiniappHeader.js +32 -0
- package/dist/react/MiniappHeader.js.map +1 -0
- package/dist/react/index.d.ts +13 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +9 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/useCapabilities.d.ts +26 -0
- package/dist/react/useCapabilities.d.ts.map +1 -0
- package/dist/react/useCapabilities.js +27 -0
- package/dist/react/useCapabilities.js.map +1 -0
- package/dist/react/useCapsuleHeaderStyle.d.ts +27 -0
- package/dist/react/useCapsuleHeaderStyle.d.ts.map +1 -0
- package/dist/react/useCapsuleHeaderStyle.js +36 -0
- package/dist/react/useCapsuleHeaderStyle.js.map +1 -0
- package/dist/react/useColorScheme.d.ts +18 -0
- package/dist/react/useColorScheme.d.ts.map +1 -0
- package/dist/react/useColorScheme.js +24 -0
- package/dist/react/useColorScheme.js.map +1 -0
- package/dist/react/useConnected.d.ts +17 -0
- package/dist/react/useConnected.d.ts.map +1 -0
- package/dist/react/useConnected.js +39 -0
- package/dist/react/useConnected.js.map +1 -0
- package/dist/react/useRpc.d.ts +29 -0
- package/dist/react/useRpc.d.ts.map +1 -0
- package/dist/react/useRpc.js +82 -0
- package/dist/react/useRpc.js.map +1 -0
- package/dist/react/useSafeArea.d.ts +21 -0
- package/dist/react/useSafeArea.d.ts.map +1 -0
- package/dist/react/useSafeArea.js +22 -0
- package/dist/react/useSafeArea.js.map +1 -0
- package/dist/session.d.ts +310 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +653 -0
- package/dist/session.js.map +1 -0
- package/dist/sub-path-types.test-d.d.ts +28 -0
- package/dist/sub-path-types.test-d.d.ts.map +1 -0
- package/dist/sub-path-types.test-d.js +37 -0
- package/dist/sub-path-types.test-d.js.map +1 -0
- package/dist/transport/auto.d.ts +35 -0
- package/dist/transport/auto.d.ts.map +1 -0
- package/dist/transport/auto.js +125 -0
- package/dist/transport/auto.js.map +1 -0
- package/dist/transport/dispatch.d.ts +43 -0
- package/dist/transport/dispatch.d.ts.map +1 -0
- package/dist/transport/dispatch.js +91 -0
- package/dist/transport/dispatch.js.map +1 -0
- package/dist/transport/local-socket.d.ts +28 -0
- package/dist/transport/local-socket.d.ts.map +1 -0
- package/dist/transport/local-socket.js +80 -0
- package/dist/transport/local-socket.js.map +1 -0
- package/dist/transport/mock.d.ts +54 -0
- package/dist/transport/mock.d.ts.map +1 -0
- package/dist/transport/mock.js +205 -0
- package/dist/transport/mock.js.map +1 -0
- package/dist/transport/postmessage.d.ts +36 -0
- package/dist/transport/postmessage.d.ts.map +1 -0
- package/dist/transport/postmessage.js +78 -0
- package/dist/transport/postmessage.js.map +1 -0
- package/dist/transport/types.d.ts +25 -0
- package/dist/transport/types.d.ts.map +1 -0
- package/dist/transport/types.js +11 -0
- package/dist/transport/types.js.map +1 -0
- package/dist/ui/index.d.ts +98 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +32 -0
- package/dist/ui/index.js.map +1 -0
- package/package.json +75 -0
- package/src/background/index.ts +152 -0
- package/src/background/register.ts +85 -0
- package/src/dev-reload.ts +60 -0
- package/src/envelope.ts +54 -0
- package/src/globals.ts +62 -0
- package/src/index.ts +171 -0
- package/src/modules/actions.ts +156 -0
- package/src/modules/auth.ts +68 -0
- package/src/modules/base64.ts +87 -0
- package/src/modules/blob.ts +341 -0
- package/src/modules/camera.ts +196 -0
- package/src/modules/cloud.ts +94 -0
- package/src/modules/dashboard.ts +31 -0
- package/src/modules/display.ts +122 -0
- package/src/modules/events.ts +264 -0
- package/src/modules/glasses.ts +44 -0
- package/src/modules/heading.ts +23 -0
- package/src/modules/imu.ts +44 -0
- package/src/modules/input.ts +71 -0
- package/src/modules/led.ts +61 -0
- package/src/modules/location.ts +39 -0
- package/src/modules/mic.ts +74 -0
- package/src/modules/miniapps.ts +90 -0
- package/src/modules/navigation.ts +670 -0
- package/src/modules/permissions.ts +84 -0
- package/src/modules/phone.ts +120 -0
- package/src/modules/pivots/engine.ts +863 -0
- package/src/modules/pivots/geometry.ts +409 -0
- package/src/modules/pivots/instructions.ts +343 -0
- package/src/modules/speaker.ts +328 -0
- package/src/modules/storage.ts +109 -0
- package/src/modules/stream.ts +163 -0
- package/src/modules/system.ts +76 -0
- package/src/modules/transcription.ts +128 -0
- package/src/modules/translation.ts +149 -0
- package/src/modules/ui.ts +498 -0
- package/src/protocol.ts +371 -0
- package/src/react/MentraProvider.tsx +50 -0
- package/src/react/MiniappHeader.tsx +122 -0
- package/src/react/index.ts +12 -0
- package/src/react/useCapabilities.ts +29 -0
- package/src/react/useCapsuleHeaderStyle.ts +54 -0
- package/src/react/useColorScheme.ts +26 -0
- package/src/react/useConnected.ts +47 -0
- package/src/react/useRpc.ts +106 -0
- package/src/react/useSafeArea.ts +40 -0
- package/src/session.ts +878 -0
- package/src/sub-path-types.test-d.ts +49 -0
- package/src/transport/auto.ts +143 -0
- package/src/transport/dispatch.ts +106 -0
- package/src/transport/local-socket.ts +93 -0
- package/src/transport/mock.ts +248 -0
- package/src/transport/postmessage.ts +95 -0
- package/src/transport/types.ts +26 -0
- package/src/ui/index.ts +122 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview MicModule — low-level audio input subscriptions.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors cloud SDK v3's MicManager naming. Houses raw audio chunks + VAD;
|
|
5
|
+
* transcription and translation hoisted to top-level (`session.transcription`
|
|
6
|
+
* / `session.translation`) in the v3-alignment round so authors don't have to
|
|
7
|
+
* mentally model "transcription is a microphone thing" — it's just a
|
|
8
|
+
* top-level domain. This module was called `MicrophoneModule` /
|
|
9
|
+
* `session.microphone` before that round.
|
|
10
|
+
*
|
|
11
|
+
* Audio *output* (TTS, file playback) lives on `session.speaker`.
|
|
12
|
+
*
|
|
13
|
+
* MICROPHONE permission must be declared in miniapp.json for any of these
|
|
14
|
+
* subscriptions to succeed; the phone runtime rejects with
|
|
15
|
+
* PERMISSION_NOT_DECLARED otherwise.
|
|
16
|
+
*/
|
|
17
|
+
import { MiniappStreamType } from "../protocol";
|
|
18
|
+
export class MicModule {
|
|
19
|
+
constructor(session) {
|
|
20
|
+
this.session = session;
|
|
21
|
+
/** All active unsubscribe functions for stop() to tear down at once. */
|
|
22
|
+
this.unsubs = new Set();
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Subscribe to voice activity detection (VAD) events. `data.status` is
|
|
26
|
+
* `true` while the user is speaking, `false` when silent.
|
|
27
|
+
*/
|
|
28
|
+
onVoiceActivity(handler) {
|
|
29
|
+
return this.track(this.session._subscribe(MiniappStreamType.VAD, handler));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Subscribe to raw audio chunks. Format depends on the phone's mic mode
|
|
33
|
+
* (PCM or LC3, base64-encoded).
|
|
34
|
+
*/
|
|
35
|
+
onAudioChunk(handler) {
|
|
36
|
+
return this.track(this.session._subscribe(MiniappStreamType.AUDIO_CHUNK, handler));
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Tear down every subscription this module owns. Useful when a component
|
|
40
|
+
* is unmounting and wants to free everything at once without tracking
|
|
41
|
+
* individual unsubscribe functions.
|
|
42
|
+
*/
|
|
43
|
+
stop() {
|
|
44
|
+
for (const u of this.unsubs) {
|
|
45
|
+
try {
|
|
46
|
+
u();
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
/* ignore */
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
this.unsubs.clear();
|
|
53
|
+
}
|
|
54
|
+
/** True iff `MICROPHONE` is declared in the miniapp's manifest. */
|
|
55
|
+
get hasPermission() {
|
|
56
|
+
return this.session._hasManifestPermission("MICROPHONE");
|
|
57
|
+
}
|
|
58
|
+
// ------------------------------------------------------------------------
|
|
59
|
+
track(unsub) {
|
|
60
|
+
this.unsubs.add(unsub);
|
|
61
|
+
return () => {
|
|
62
|
+
this.unsubs.delete(unsub);
|
|
63
|
+
unsub();
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=mic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mic.js","sourceRoot":"","sources":["../../src/modules/mic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAC,iBAAiB,EAAC,MAAM,aAAa,CAAA;AAI7C,MAAM,OAAO,SAAS;IAIpB,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;QAHpD,wEAAwE;QACvD,WAAM,GAAG,IAAI,GAAG,EAAiB,CAAA;IAEK,CAAC;IAExD;;;OAGG;IACH,eAAe,CAAC,OAAgC;QAC9C,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAC,GAAG,EAAE,OAAkC,CAAC,CAAC,CAAA;IACvG,CAAC;IAED;;;OAGG;IACH,YAAY,CAAC,OAAuC;QAClD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAC,WAAW,EAAE,OAAkC,CAAC,CAAC,CAAA;IAC/G,CAAC;IAED;;;;OAIG;IACH,IAAI;QACF,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAC5B,IAAI,CAAC;gBACH,CAAC,EAAE,CAAA;YACL,CAAC;YAAC,MAAM,CAAC;gBACP,YAAY;YACd,CAAC;QACH,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAA;IACrB,CAAC;IAED,mEAAmE;IACnE,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,YAAY,CAAC,CAAA;IAC1D,CAAC;IAED,2EAA2E;IAEnE,KAAK,CAAC,KAAoB;QAChC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QACtB,OAAO,GAAG,EAAE;YACV,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;YACzB,KAAK,EAAE,CAAA;QACT,CAAC,CAAA;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview MiniappsModule — `session.miniapps`.
|
|
3
|
+
*
|
|
4
|
+
* Discover and control the lifecycle of OTHER miniapps: list, start, stop.
|
|
5
|
+
* SYSTEM-only — every call rejects with NOT_PERMITTED unless the caller is a
|
|
6
|
+
* system app (Mentra AI is the first consumer). The action *capability* layer
|
|
7
|
+
* (invoke / handle) lives on `session.actions`, not here — these three are
|
|
8
|
+
* operations on the app as a whole, not on a declared action.
|
|
9
|
+
*/
|
|
10
|
+
import { MiniappSession } from "../session";
|
|
11
|
+
/** A declared action surfaced by {@link MiniappsModule.list}. */
|
|
12
|
+
export interface MiniappActionInfo {
|
|
13
|
+
id: string;
|
|
14
|
+
description: string;
|
|
15
|
+
/**
|
|
16
|
+
* JSON-Schema input descriptor (the MCP-compatible subset). Maps verbatim
|
|
17
|
+
* to an MCP tool `inputSchema`. Undefined for actions that take no params.
|
|
18
|
+
*/
|
|
19
|
+
parameters?: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Hardware compatibility for a listed miniapp. Structurally mirrors the host's
|
|
23
|
+
* `CompatibilityResult` so the runtime can pass it straight through.
|
|
24
|
+
*/
|
|
25
|
+
export interface MiniappCompatibility {
|
|
26
|
+
isCompatible: boolean;
|
|
27
|
+
missingRequired: Array<{
|
|
28
|
+
type: string;
|
|
29
|
+
level?: string;
|
|
30
|
+
}>;
|
|
31
|
+
missingOptional: Array<{
|
|
32
|
+
type: string;
|
|
33
|
+
level?: string;
|
|
34
|
+
}>;
|
|
35
|
+
warnings: string[];
|
|
36
|
+
}
|
|
37
|
+
/** One installed miniapp, as surfaced to a system caller. */
|
|
38
|
+
export interface MiniappInfo {
|
|
39
|
+
packageName: string;
|
|
40
|
+
name: string;
|
|
41
|
+
description?: string;
|
|
42
|
+
version: string;
|
|
43
|
+
running: boolean;
|
|
44
|
+
compatibility: MiniappCompatibility;
|
|
45
|
+
/** Declared actions (empty if the miniapp declares none). */
|
|
46
|
+
actions: MiniappActionInfo[];
|
|
47
|
+
}
|
|
48
|
+
export interface ListMiniappsOptions {
|
|
49
|
+
/** Include incompatible miniapps too (default false — compatible-only). */
|
|
50
|
+
includeIncompatible?: boolean;
|
|
51
|
+
}
|
|
52
|
+
export declare class MiniappsModule {
|
|
53
|
+
private readonly session;
|
|
54
|
+
constructor(session: MiniappSession);
|
|
55
|
+
/**
|
|
56
|
+
* List installed miniapps. Compatible-only by default; pass
|
|
57
|
+
* `{includeIncompatible: true}` to include the rest (each carries a
|
|
58
|
+
* `compatibility` result with the missing hardware). SYSTEM-only.
|
|
59
|
+
*/
|
|
60
|
+
list(opts?: ListMiniappsOptions): Promise<MiniappInfo[]>;
|
|
61
|
+
/**
|
|
62
|
+
* Start another miniapp in the **background** — spawns its background JS
|
|
63
|
+
* context without changing the user's phone navigation or foregrounding
|
|
64
|
+
* anything. The app reports as running and can handle actions / drive the
|
|
65
|
+
* glasses immediately; its WebView only mounts if the user later opens it.
|
|
66
|
+
* SYSTEM-only.
|
|
67
|
+
*/
|
|
68
|
+
start(packageName: string): Promise<void>;
|
|
69
|
+
/** Stop another miniapp. SYSTEM-only. */
|
|
70
|
+
stop(packageName: string): Promise<void>;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=miniapps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"miniapps.d.ts","sourceRoot":"","sources":["../../src/modules/miniapps.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAA;AAEzC,iEAAiE;AACjE,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAA;IACV,WAAW,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACrC;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,OAAO,CAAA;IACrB,eAAe,EAAE,KAAK,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAC,CAAC,CAAA;IACtD,eAAe,EAAE,KAAK,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAC,CAAC,CAAA;IACtD,QAAQ,EAAE,MAAM,EAAE,CAAA;CACnB;AAED,6DAA6D;AAC7D,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,OAAO,CAAA;IAChB,aAAa,EAAE,oBAAoB,CAAA;IACnC,6DAA6D;IAC7D,OAAO,EAAE,iBAAiB,EAAE,CAAA;CAC7B;AAED,MAAM,WAAW,mBAAmB;IAClC,2EAA2E;IAC3E,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAC9B;AAED,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,cAAc;IAEpD;;;;OAIG;IACG,IAAI,CAAC,IAAI,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAQ9D;;;;;;OAMG;IACG,KAAK,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAO/C,yCAAyC;IACnC,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAM/C"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview MiniappsModule — `session.miniapps`.
|
|
3
|
+
*
|
|
4
|
+
* Discover and control the lifecycle of OTHER miniapps: list, start, stop.
|
|
5
|
+
* SYSTEM-only — every call rejects with NOT_PERMITTED unless the caller is a
|
|
6
|
+
* system app (Mentra AI is the first consumer). The action *capability* layer
|
|
7
|
+
* (invoke / handle) lives on `session.actions`, not here — these three are
|
|
8
|
+
* operations on the app as a whole, not on a declared action.
|
|
9
|
+
*/
|
|
10
|
+
import { MiniappRequestType } from "../protocol";
|
|
11
|
+
export class MiniappsModule {
|
|
12
|
+
constructor(session) {
|
|
13
|
+
this.session = session;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* List installed miniapps. Compatible-only by default; pass
|
|
17
|
+
* `{includeIncompatible: true}` to include the rest (each carries a
|
|
18
|
+
* `compatibility` result with the missing hardware). SYSTEM-only.
|
|
19
|
+
*/
|
|
20
|
+
async list(opts) {
|
|
21
|
+
const result = await this.session.sendRequest({
|
|
22
|
+
type: MiniappRequestType.MINIAPPS_LIST,
|
|
23
|
+
includeIncompatible: opts?.includeIncompatible ?? false,
|
|
24
|
+
});
|
|
25
|
+
return result ?? [];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Start another miniapp in the **background** — spawns its background JS
|
|
29
|
+
* context without changing the user's phone navigation or foregrounding
|
|
30
|
+
* anything. The app reports as running and can handle actions / drive the
|
|
31
|
+
* glasses immediately; its WebView only mounts if the user later opens it.
|
|
32
|
+
* SYSTEM-only.
|
|
33
|
+
*/
|
|
34
|
+
async start(packageName) {
|
|
35
|
+
await this.session.sendRequest({
|
|
36
|
+
type: MiniappRequestType.MINIAPPS_START,
|
|
37
|
+
packageName,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/** Stop another miniapp. SYSTEM-only. */
|
|
41
|
+
async stop(packageName) {
|
|
42
|
+
await this.session.sendRequest({
|
|
43
|
+
type: MiniappRequestType.MINIAPPS_STOP,
|
|
44
|
+
packageName,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=miniapps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"miniapps.js","sourceRoot":"","sources":["../../src/modules/miniapps.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAC,kBAAkB,EAAC,MAAM,aAAa,CAAA;AA0C9C,MAAM,OAAO,cAAc;IACzB,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;IAAG,CAAC;IAExD;;;;OAIG;IACH,KAAK,CAAC,IAAI,CAAC,IAA0B;QACnC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAAgB;YAC3D,IAAI,EAAE,kBAAkB,CAAC,aAAa;YACtC,mBAAmB,EAAE,IAAI,EAAE,mBAAmB,IAAI,KAAK;SACxD,CAAC,CAAA;QACF,OAAO,MAAM,IAAI,EAAE,CAAA;IACrB,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,KAAK,CAAC,WAAmB;QAC7B,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAAO;YACnC,IAAI,EAAE,kBAAkB,CAAC,cAAc;YACvC,WAAW;SACZ,CAAC,CAAA;IACJ,CAAC;IAED,yCAAyC;IACzC,KAAK,CAAC,IAAI,CAAC,WAAmB;QAC5B,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAAO;YACnC,IAAI,EAAE,kBAAkB,CAAC,aAAa;YACtC,WAAW;SACZ,CAAC,CAAA;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NavigationModule — turn-by-turn navigation for miniapps. A thin pass-through over the bridge;
|
|
3
|
+
* the phone-side daemon owns the trip lifecycle.
|
|
4
|
+
*
|
|
5
|
+
* Works on iOS and Android (both back it with the Mapbox Navigation SDK). Every Promise
|
|
6
|
+
* resolves with an `{ok, error?}` shape; nothing throws, so check `result.ok`.
|
|
7
|
+
*/
|
|
8
|
+
import { MiniappSession } from "../session";
|
|
9
|
+
import type { UnsubscribeFn } from "./events";
|
|
10
|
+
export type LatLng = {
|
|
11
|
+
lat: number;
|
|
12
|
+
lng: number;
|
|
13
|
+
};
|
|
14
|
+
export type TravelMode = "walking" | "driving" | "cycling" | "two_wheeler";
|
|
15
|
+
/**
|
|
16
|
+
* Categorical maneuver vocabulary. Most values come from the Google Nav SDK + Routes API;
|
|
17
|
+
* "CROSS_STREET" is SDK-synthesized when the pivot engine detects a crosswalk leg.
|
|
18
|
+
*/
|
|
19
|
+
export type ManeuverKind = "STRAIGHT" | "CONTINUE" | "SLIGHT_LEFT" | "SLIGHT_RIGHT" | "TURN_LEFT" | "TURN_RIGHT" | "SHARP_LEFT" | "SHARP_RIGHT" | "U_TURN" | "NAME_CHANGE" | "DEPART" | "ARRIVE" | "CROSS_STREET";
|
|
20
|
+
/** Routing preferences. All flags default to false. */
|
|
21
|
+
export type RouteAvoidances = {
|
|
22
|
+
highways?: boolean;
|
|
23
|
+
tolls?: boolean;
|
|
24
|
+
ferries?: boolean;
|
|
25
|
+
};
|
|
26
|
+
export type NavManeuver = {
|
|
27
|
+
kind: "maneuver";
|
|
28
|
+
maneuverType: ManeuverKind;
|
|
29
|
+
/** Meters to the maneuver. -1 if unknown. */
|
|
30
|
+
distanceMeters: number;
|
|
31
|
+
/** Road the user is currently on. Null when unnamed or pre-first-update. */
|
|
32
|
+
fromRoad?: string | null;
|
|
33
|
+
/** Legacy "next road" field. Prefer `nextStepRoad` for new UIs. */
|
|
34
|
+
toRoad?: string | null;
|
|
35
|
+
/** Road the user will be on AFTER the maneuver. Use as the "next street" label. */
|
|
36
|
+
nextStepRoad?: string | null;
|
|
37
|
+
/** Total meters to the destination. -1 if unknown. */
|
|
38
|
+
distanceToDestinationMeters?: number;
|
|
39
|
+
/** Remaining travel time in seconds. -1 if unknown. */
|
|
40
|
+
timeToDestinationSeconds?: number;
|
|
41
|
+
/** Current speed in m/s. Null if unavailable. */
|
|
42
|
+
currentSpeedMps?: number | null;
|
|
43
|
+
/** Speed limit in m/s. Null if unknown / not regulated. */
|
|
44
|
+
speedLimitMps?: number | null;
|
|
45
|
+
/** Route bearing at the user's position, 0–360. Null if unknown. */
|
|
46
|
+
routeHeadingDeg?: number | null;
|
|
47
|
+
/** Host engine's verbatim instruction (e.g. "Turn left onto Waller St"). Render as-is. */
|
|
48
|
+
instruction?: string | null;
|
|
49
|
+
};
|
|
50
|
+
export type NavOffRoute = {
|
|
51
|
+
kind: "off_route";
|
|
52
|
+
/** Approximate perpendicular distance from the route, in meters. */
|
|
53
|
+
offRouteDistanceMeters: number;
|
|
54
|
+
};
|
|
55
|
+
export type NavRerouting = {
|
|
56
|
+
kind: "rerouting";
|
|
57
|
+
};
|
|
58
|
+
export type NavArrived = {
|
|
59
|
+
kind: "arrived";
|
|
60
|
+
};
|
|
61
|
+
export type NavError = {
|
|
62
|
+
kind: "error";
|
|
63
|
+
message: string;
|
|
64
|
+
};
|
|
65
|
+
export type NavUpdate = NavManeuver | NavOffRoute | NavRerouting | NavArrived | NavError;
|
|
66
|
+
export type NavRoute = {
|
|
67
|
+
points: LatLng[];
|
|
68
|
+
totalDistanceMeters?: number;
|
|
69
|
+
totalDurationSeconds?: number;
|
|
70
|
+
/** Ordered navigable segments. Omitted by older hosts that don't supply step metadata. */
|
|
71
|
+
steps?: NavStep[];
|
|
72
|
+
};
|
|
73
|
+
/** Pivot-detection tuning. Omitted fields use mode-aware defaults. */
|
|
74
|
+
export type PivotOptions = {
|
|
75
|
+
/** "Turning now" radius. Defaults: walking 7, cycling 15, driving 40. */
|
|
76
|
+
radiusMeters?: number;
|
|
77
|
+
/** "Approaching" radius. Defaults: walking 100, cycling 300, driving 800. */
|
|
78
|
+
approachThresholdMeters?: number;
|
|
79
|
+
};
|
|
80
|
+
/** A real turn along the route, derived once per route build (re-derived on reroute). */
|
|
81
|
+
export type Pivot = {
|
|
82
|
+
/** 0-based ordinal; invalidated when `onRoute` fires again. */
|
|
83
|
+
index: number;
|
|
84
|
+
lat: number;
|
|
85
|
+
lng: number;
|
|
86
|
+
direction: "left" | "right";
|
|
87
|
+
/** Road approaching the pivot. Null when the engine has no name. */
|
|
88
|
+
fromRoad: string | null;
|
|
89
|
+
/** Road exiting the pivot. Same null semantics. */
|
|
90
|
+
toRoad: string | null;
|
|
91
|
+
maneuver: ManeuverKind;
|
|
92
|
+
/** Meters from trip start to this pivot, along the route. */
|
|
93
|
+
distanceAlongRouteMeters: number;
|
|
94
|
+
/** "Turning now" radius for this pivot, in meters. */
|
|
95
|
+
radiusMeters: number;
|
|
96
|
+
};
|
|
97
|
+
/** Each pivot fires `approaching` → `entered` → `exited` (once each), then the cursor advances. */
|
|
98
|
+
export type PivotEvent = {
|
|
99
|
+
kind: "approaching";
|
|
100
|
+
pivot: Pivot;
|
|
101
|
+
distanceMeters: number;
|
|
102
|
+
} | {
|
|
103
|
+
kind: "entered";
|
|
104
|
+
pivot: Pivot;
|
|
105
|
+
} | {
|
|
106
|
+
kind: "exited";
|
|
107
|
+
pivot: Pivot;
|
|
108
|
+
};
|
|
109
|
+
/** One route leg: a stretch of road ending in a maneuver. */
|
|
110
|
+
export type NavStep = {
|
|
111
|
+
/** Coordinate where this step begins (== end of the previous step). */
|
|
112
|
+
lat: number;
|
|
113
|
+
lng: number;
|
|
114
|
+
/** Index into `NavRoute.points[]` where this step starts. */
|
|
115
|
+
routeIndex: number;
|
|
116
|
+
/** Road traversed during this step. Null when unnamed. */
|
|
117
|
+
road?: string | null;
|
|
118
|
+
/** Maneuver performed at the END of this step. */
|
|
119
|
+
maneuver: ManeuverKind;
|
|
120
|
+
distanceMeters: number;
|
|
121
|
+
};
|
|
122
|
+
/** One type-ahead place suggestion from `placeAutocomplete`. */
|
|
123
|
+
export type NavPlaceSuggestion = {
|
|
124
|
+
/** Opaque id to feed into `placeDetails`. */
|
|
125
|
+
placeId: string;
|
|
126
|
+
/** Primary line, e.g. "Blue Bottle Coffee". */
|
|
127
|
+
mainText: string;
|
|
128
|
+
/** Secondary line, e.g. "66 Mint St, San Francisco". Empty when none. */
|
|
129
|
+
secondaryText: string;
|
|
130
|
+
};
|
|
131
|
+
/** A place resolved from a suggestion via `placeDetails` — has coordinates to route to. */
|
|
132
|
+
export type NavPlaceDetails = {
|
|
133
|
+
placeId: string;
|
|
134
|
+
name: string;
|
|
135
|
+
address: string;
|
|
136
|
+
lat: number;
|
|
137
|
+
lng: number;
|
|
138
|
+
};
|
|
139
|
+
export type NavigationDev = {
|
|
140
|
+
deviate(offsetMeters?: number): void;
|
|
141
|
+
setWrongSidewalkOffset(enabled: boolean): void;
|
|
142
|
+
setSkipCrossings(enabled: boolean): void;
|
|
143
|
+
};
|
|
144
|
+
export type StartNavigationOptions = {
|
|
145
|
+
/** Single-destination shorthand. Rewritten to `stops: [{lat, lng}]`. */
|
|
146
|
+
lat?: number;
|
|
147
|
+
lng?: number;
|
|
148
|
+
/** Ordered stops; last is the final destination. Must have ≥1 entry. */
|
|
149
|
+
stops?: LatLng[];
|
|
150
|
+
/** Defaults to "driving". */
|
|
151
|
+
mode?: TravelMode;
|
|
152
|
+
avoid?: RouteAvoidances;
|
|
153
|
+
/** Dev/testing only — fake walking the route at speedMultiplier×. */
|
|
154
|
+
simulate?: boolean;
|
|
155
|
+
speedMultiplier?: number;
|
|
156
|
+
/** Override the default pivot-detection knobs for this trip. */
|
|
157
|
+
pivots?: PivotOptions;
|
|
158
|
+
/** Reroute once the user is this many meters past a missed pivot. Omit / 0 to use host defaults. */
|
|
159
|
+
missedTurnRerouteMeters?: number;
|
|
160
|
+
};
|
|
161
|
+
/** Snapshot of the active trip, shaped like the streaming events so mid-trip opens render the same. */
|
|
162
|
+
export type NavState = {
|
|
163
|
+
active: boolean;
|
|
164
|
+
mode?: TravelMode;
|
|
165
|
+
stops?: LatLng[];
|
|
166
|
+
/** Index of the stop currently being navigated to (0 = first). */
|
|
167
|
+
currentStopIndex?: number;
|
|
168
|
+
route?: NavRoute;
|
|
169
|
+
maneuver?: NavManeuver;
|
|
170
|
+
distanceToDestinationMeters?: number;
|
|
171
|
+
timeToDestinationSeconds?: number;
|
|
172
|
+
currentSpeedMps?: number | null;
|
|
173
|
+
speedLimitMps?: number | null;
|
|
174
|
+
};
|
|
175
|
+
export type NavPermissionResult = {
|
|
176
|
+
/** True if the request reached the host. False e.g. when LOCATION isn't declared in the manifest. */
|
|
177
|
+
ok: boolean;
|
|
178
|
+
/** True if the user accepted the Nav SDK T&Cs (always true on platforms without a T&C gate). */
|
|
179
|
+
accepted: boolean;
|
|
180
|
+
error?: string;
|
|
181
|
+
};
|
|
182
|
+
/** Standalone route compute — does NOT start a trip. */
|
|
183
|
+
export type ComputeRouteOptions = {
|
|
184
|
+
origin: LatLng;
|
|
185
|
+
/** ≥1 entry; last is the final destination. */
|
|
186
|
+
stops: LatLng[];
|
|
187
|
+
/** Defaults to "driving". */
|
|
188
|
+
mode?: TravelMode;
|
|
189
|
+
avoid?: RouteAvoidances;
|
|
190
|
+
/** Up to N alternate routes (engine-permitting). Default 1. */
|
|
191
|
+
alternatives?: number;
|
|
192
|
+
};
|
|
193
|
+
/** One step of a previewed route, available BEFORE `start()`. Maneuver ENDS the segment. */
|
|
194
|
+
export type ComputedRouteStep = {
|
|
195
|
+
lat: number;
|
|
196
|
+
lng: number;
|
|
197
|
+
endLat: number;
|
|
198
|
+
endLng: number;
|
|
199
|
+
distanceMeters: number;
|
|
200
|
+
maneuver?: ManeuverKind;
|
|
201
|
+
/** Full instruction from the Routes API (e.g. "Turn left onto Fell St"). */
|
|
202
|
+
instruction?: string;
|
|
203
|
+
/** Resolved road name. Prefer this over parsing `instruction`. Null when none found. */
|
|
204
|
+
road?: string | null;
|
|
205
|
+
};
|
|
206
|
+
export type ComputedRoute = {
|
|
207
|
+
points: LatLng[];
|
|
208
|
+
totalDistanceMeters: number;
|
|
209
|
+
totalDurationSeconds: number;
|
|
210
|
+
summary?: string;
|
|
211
|
+
steps?: ComputedRouteStep[];
|
|
212
|
+
};
|
|
213
|
+
export type ComputeRouteResult = {
|
|
214
|
+
ok: boolean;
|
|
215
|
+
error?: string;
|
|
216
|
+
/** Primary route first, alternates after. */
|
|
217
|
+
routes?: ComputedRoute[];
|
|
218
|
+
};
|
|
219
|
+
export declare class NavigationModule {
|
|
220
|
+
private readonly session;
|
|
221
|
+
private _pivots;
|
|
222
|
+
/** Subscriptions owned while a trip is active. Released on stop(). */
|
|
223
|
+
private _tripUnsubs;
|
|
224
|
+
/** Trip params captured at start() so reroutes can re-issue computeRoute. */
|
|
225
|
+
private _tripStops;
|
|
226
|
+
private _tripMode;
|
|
227
|
+
private _tripAvoid;
|
|
228
|
+
/** Bumps per request so a stale reply from before a newer reroute is ignored. */
|
|
229
|
+
private _computeRouteSeq;
|
|
230
|
+
/** Latest GPS position, used as the origin for reroute computeRoute calls. */
|
|
231
|
+
private _lastUserPosition;
|
|
232
|
+
constructor(session: MiniappSession);
|
|
233
|
+
/** True iff `LOCATION` is declared in the miniapp's manifest. */
|
|
234
|
+
get hasPermission(): boolean;
|
|
235
|
+
/**
|
|
236
|
+
* Trigger the Nav SDK Terms & Conditions dialog up front, before the user hits "start".
|
|
237
|
+
* Idempotent. Resolves `{ok: false, accepted: false, error}` when LOCATION isn't declared.
|
|
238
|
+
*/
|
|
239
|
+
requestPermission(): Promise<NavPermissionResult>;
|
|
240
|
+
/**
|
|
241
|
+
* Start a navigation session. Pass `{lat, lng}` or `{stops: [...]}`. `{ok: true}` means the
|
|
242
|
+
* daemon accepted the request, not that a route was built — listen via `onUpdate(...)`.
|
|
243
|
+
*/
|
|
244
|
+
start(opts: StartNavigationOptions): Promise<{
|
|
245
|
+
ok: boolean;
|
|
246
|
+
error?: string;
|
|
247
|
+
}>;
|
|
248
|
+
/** Stop the active session (no-op if none). Fire-and-forget; also detaches pivot tracking. */
|
|
249
|
+
stop(): void;
|
|
250
|
+
/** Dev-only simulator helpers for testing trips. `deviate` works on both platforms;
|
|
251
|
+
* a few helpers are Android-only and return `{ok: false}` on iOS. */
|
|
252
|
+
get dev(): NavigationDev;
|
|
253
|
+
/** Subscribe to live trip events (maneuver / off_route / rerouting / arrived / error). */
|
|
254
|
+
onUpdate(handler: (update: NavUpdate) => void): UnsubscribeFn;
|
|
255
|
+
/** Subscribe to the route polyline. Fires once per route build (initial + reroute), full path. */
|
|
256
|
+
onRoute(handler: (route: NavRoute) => void): UnsubscribeFn;
|
|
257
|
+
/** Snapshot of the active trip, or `null` when none is running. Use on mount to hydrate state. */
|
|
258
|
+
getState(): Promise<NavState | null>;
|
|
259
|
+
/** Compute a route without starting a trip. Primary route first, alternates after. */
|
|
260
|
+
computeRoute(opts: ComputeRouteOptions): Promise<ComputeRouteResult>;
|
|
261
|
+
/**
|
|
262
|
+
* Reverse-geocode a coordinate into a short road name (`road`) and a full
|
|
263
|
+
* formatted street address (`address`, e.g. "369 Hayes Street, San Francisco,
|
|
264
|
+
* California 94102"). `road` backs the pivot engine's fallback; `address`
|
|
265
|
+
* backs UI labels for dropped pins / POI taps. Each is null when none of that
|
|
266
|
+
* kind is found near the coordinate; `ok: false` is an actual failure.
|
|
267
|
+
*
|
|
268
|
+
* Resolved entirely in the v2 cloud maps service (provider-abstracted, Mapbox
|
|
269
|
+
* today) via the host bridge — the miniapp never holds a maps token or calls a
|
|
270
|
+
* provider directly.
|
|
271
|
+
*/
|
|
272
|
+
reverseGeocodeRoad(coord: LatLng): Promise<{
|
|
273
|
+
ok: boolean;
|
|
274
|
+
road?: string | null;
|
|
275
|
+
address?: string | null;
|
|
276
|
+
error?: string;
|
|
277
|
+
}>;
|
|
278
|
+
/**
|
|
279
|
+
* Type-ahead place search. Returns lightweight suggestions for `query`,
|
|
280
|
+
* optionally biased toward `near`. Resolved in the v2 cloud maps service
|
|
281
|
+
* (Mapbox Search Box today) via the host bridge — no maps token in the
|
|
282
|
+
* miniapp. `sessionToken` should be a stable per-search-box-opening string,
|
|
283
|
+
* reused on the following `placeDetails` call, then rotated after a pick, so
|
|
284
|
+
* the keystrokes + the final retrieve bill as one search session.
|
|
285
|
+
*
|
|
286
|
+
* Does NOT require LOCATION permission — it's a text search; `near` is only a
|
|
287
|
+
* ranking bias. Resolves `{ok, suggestions}`; `ok: false` is an actual failure.
|
|
288
|
+
*/
|
|
289
|
+
placeAutocomplete(opts: {
|
|
290
|
+
query: string;
|
|
291
|
+
near?: LatLng;
|
|
292
|
+
sessionToken: string;
|
|
293
|
+
}): Promise<{
|
|
294
|
+
ok: boolean;
|
|
295
|
+
suggestions?: NavPlaceSuggestion[];
|
|
296
|
+
error?: string;
|
|
297
|
+
}>;
|
|
298
|
+
/**
|
|
299
|
+
* Resolve a suggestion's `placeId` (from `placeAutocomplete`) to a full place
|
|
300
|
+
* with coordinates. Pass the SAME `sessionToken` used for the autocomplete so
|
|
301
|
+
* the provider closes the billing session. Resolved in the v2 cloud maps
|
|
302
|
+
* service via the host bridge. Resolves `{ok, place}`; `ok: false` is a
|
|
303
|
+
* failure (including an unresolvable id).
|
|
304
|
+
*/
|
|
305
|
+
placeDetails(opts: {
|
|
306
|
+
placeId: string;
|
|
307
|
+
sessionToken: string;
|
|
308
|
+
}): Promise<{
|
|
309
|
+
ok: boolean;
|
|
310
|
+
place?: NavPlaceDetails;
|
|
311
|
+
error?: string;
|
|
312
|
+
}>;
|
|
313
|
+
/** Subscribe to pivot events. Each pivot fires once per kind; passed pivots aren't re-evaluated. */
|
|
314
|
+
onPivot(handler: (event: PivotEvent) => void): UnsubscribeFn;
|
|
315
|
+
/** Full pivot list for the active route. Empty before the first `onRoute`. */
|
|
316
|
+
getPivots(): Pivot[];
|
|
317
|
+
/** The pivot the user is currently inside (between `entered` and `exited`), or `null`. */
|
|
318
|
+
getActivePivot(): Pivot | null;
|
|
319
|
+
/** The next pivot ahead, or `null` once every pivot has been passed. */
|
|
320
|
+
getUpcomingPivot(): Pivot | null;
|
|
321
|
+
private _attachPivotTrackingForTrip;
|
|
322
|
+
/** computeRoute for the current trip, using the latest position (or route start) as origin. */
|
|
323
|
+
private _issueComputeRouteForTrip;
|
|
324
|
+
private _detachPivotTracking;
|
|
325
|
+
}
|
|
326
|
+
//# sourceMappingURL=navigation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../src/modules/navigation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAA;AACzC,OAAO,KAAK,EAAe,aAAa,EAAC,MAAM,UAAU,CAAA;AAGzD,MAAM,MAAM,MAAM,GAAG;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAC,CAAA;AAE/C,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,aAAa,CAAA;AAE1E;;;GAGG;AACH,MAAM,MAAM,YAAY,GACpB,UAAU,GACV,UAAU,GACV,aAAa,GACb,cAAc,GACd,WAAW,GACX,YAAY,GACZ,YAAY,GACZ,aAAa,GACb,QAAQ,GACR,aAAa,GACb,QAAQ,GACR,QAAQ,GACR,cAAc,CAAA;AAElB,uDAAuD;AACvD,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KA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