@glassly/miniapp 0.1.0-dev.26
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 +275 -0
- package/dist/background/index.d.ts +64 -0
- package/dist/background/index.d.ts.map +1 -0
- package/dist/background/index.js +26 -0
- package/dist/background/index.js.map +1 -0
- package/dist/background/register.d.ts +39 -0
- package/dist/background/register.d.ts.map +1 -0
- package/dist/background/register.js +72 -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 +60 -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/hardware.d.ts +24 -0
- package/dist/hardware.d.ts.map +1 -0
- package/dist/hardware.js +20 -0
- package/dist/hardware.js.map +1 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/modules/actions.d.ts +81 -0
- package/dist/modules/actions.d.ts.map +1 -0
- package/dist/modules/actions.js +137 -0
- package/dist/modules/actions.js.map +1 -0
- package/dist/modules/ai.d.ts +211 -0
- package/dist/modules/ai.d.ts.map +1 -0
- package/dist/modules/ai.js +117 -0
- package/dist/modules/ai.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 +183 -0
- package/dist/modules/camera.d.ts.map +1 -0
- package/dist/modules/camera.js +119 -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 +24 -0
- package/dist/modules/dashboard.d.ts.map +1 -0
- package/dist/modules/dashboard.js +39 -0
- package/dist/modules/dashboard.js.map +1 -0
- package/dist/modules/display.d.ts +174 -0
- package/dist/modules/display.d.ts.map +1 -0
- package/dist/modules/display.js +83 -0
- package/dist/modules/display.js.map +1 -0
- package/dist/modules/events.d.ts +178 -0
- package/dist/modules/events.d.ts.map +1 -0
- package/dist/modules/events.js +168 -0
- package/dist/modules/events.js.map +1 -0
- package/dist/modules/glasses.d.ts +36 -0
- package/dist/modules/glasses.d.ts.map +1 -0
- package/dist/modules/glasses.js +52 -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 +50 -0
- package/dist/modules/input.d.ts.map +1 -0
- package/dist/modules/input.js +70 -0
- package/dist/modules/input.js.map +1 -0
- package/dist/modules/keys.d.ts +30 -0
- package/dist/modules/keys.d.ts.map +1 -0
- package/dist/modules/keys.js +37 -0
- package/dist/modules/keys.js.map +1 -0
- package/dist/modules/languages.d.ts +42 -0
- package/dist/modules/languages.d.ts.map +1 -0
- package/dist/modules/languages.js +57 -0
- package/dist/modules/languages.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/memory.d.ts +126 -0
- package/dist/modules/memory.d.ts.map +1 -0
- package/dist/modules/memory.js +141 -0
- package/dist/modules/memory.js.map +1 -0
- package/dist/modules/mic.d.ts +61 -0
- package/dist/modules/mic.d.ts.map +1 -0
- package/dist/modules/mic.js +94 -0
- package/dist/modules/mic.js.map +1 -0
- package/dist/modules/miniapps.d.ts +82 -0
- package/dist/modules/miniapps.d.ts.map +1 -0
- package/dist/modules/miniapps.js +58 -0
- package/dist/modules/miniapps.js.map +1 -0
- package/dist/modules/navigation.d.ts +332 -0
- package/dist/modules/navigation.d.ts.map +1 -0
- package/dist/modules/navigation.js +387 -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 +95 -0
- package/dist/modules/phone.d.ts.map +1 -0
- package/dist/modules/phone.js +110 -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 +778 -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 +281 -0
- package/dist/modules/pivots/instructions.js.map +1 -0
- package/dist/modules/speaker.d.ts +175 -0
- package/dist/modules/speaker.d.ts.map +1 -0
- package/dist/modules/speaker.js +249 -0
- package/dist/modules/speaker.js.map +1 -0
- package/dist/modules/speakers.d.ts +29 -0
- package/dist/modules/speakers.d.ts.map +1 -0
- package/dist/modules/speakers.js +38 -0
- package/dist/modules/speakers.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 +133 -0
- package/dist/modules/stream.d.ts.map +1 -0
- package/dist/modules/stream.js +53 -0
- package/dist/modules/stream.js.map +1 -0
- package/dist/modules/system.d.ts +71 -0
- package/dist/modules/system.d.ts.map +1 -0
- package/dist/modules/system.js +65 -0
- package/dist/modules/system.js.map +1 -0
- package/dist/modules/transcription.d.ts +99 -0
- package/dist/modules/transcription.d.ts.map +1 -0
- package/dist/modules/transcription.js +126 -0
- package/dist/modules/transcription.js.map +1 -0
- package/dist/modules/translation.d.ts +65 -0
- package/dist/modules/translation.d.ts.map +1 -0
- package/dist/modules/translation.js +121 -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 +289 -0
- package/dist/modules/ui.js.map +1 -0
- package/dist/protocol.d.ts +390 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +419 -0
- package/dist/protocol.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/MiniappProvider.d.ts +33 -0
- package/dist/react/MiniappProvider.d.ts.map +1 -0
- package/dist/react/MiniappProvider.js +15 -0
- package/dist/react/MiniappProvider.js.map +1 -0
- package/dist/react/capsuleHeaderLayout.d.ts +3 -0
- package/dist/react/capsuleHeaderLayout.d.ts.map +1 -0
- package/dist/react/capsuleHeaderLayout.js +5 -0
- package/dist/react/capsuleHeaderLayout.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 +39 -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 +355 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +688 -0
- package/dist/session.js.map +1 -0
- package/dist/sub-path-types.test-d.d.ts +40 -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 +124 -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 +210 -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 +107 -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 +88 -0
- package/src/background/index.ts +177 -0
- package/src/background/register.ts +89 -0
- package/src/dev-reload.ts +59 -0
- package/src/envelope.ts +54 -0
- package/src/globals.ts +62 -0
- package/src/hardware.ts +25 -0
- package/src/index.ts +216 -0
- package/src/modules/actions.ts +189 -0
- package/src/modules/ai.ts +281 -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 +258 -0
- package/src/modules/cloud.ts +94 -0
- package/src/modules/dashboard.ts +51 -0
- package/src/modules/display.ts +214 -0
- package/src/modules/events.ts +318 -0
- package/src/modules/glasses.ts +58 -0
- package/src/modules/heading.ts +23 -0
- package/src/modules/imu.ts +44 -0
- package/src/modules/input.ts +87 -0
- package/src/modules/keys.ts +46 -0
- package/src/modules/languages.ts +72 -0
- package/src/modules/led.ts +61 -0
- package/src/modules/location.ts +39 -0
- package/src/modules/memory.ts +224 -0
- package/src/modules/mic.ts +103 -0
- package/src/modules/miniapps.ts +103 -0
- package/src/modules/navigation.ts +674 -0
- package/src/modules/permissions.ts +83 -0
- package/src/modules/phone.ts +155 -0
- package/src/modules/pivots/engine.ts +863 -0
- package/src/modules/pivots/geometry.ts +409 -0
- package/src/modules/pivots/instructions.ts +341 -0
- package/src/modules/speaker.ts +347 -0
- package/src/modules/speakers.ts +40 -0
- package/src/modules/storage.ts +109 -0
- package/src/modules/stream.ts +168 -0
- package/src/modules/system.ts +113 -0
- package/src/modules/transcription.ts +180 -0
- package/src/modules/translation.ts +156 -0
- package/src/modules/ui.ts +481 -0
- package/src/protocol.ts +482 -0
- package/src/react/MiniappHeader.tsx +114 -0
- package/src/react/MiniappProvider.tsx +50 -0
- package/src/react/capsuleHeaderLayout.ts +11 -0
- package/src/react/index.ts +12 -0
- package/src/react/useCapabilities.ts +29 -0
- package/src/react/useCapsuleHeaderStyle.ts +55 -0
- package/src/react/useColorScheme.ts +26 -0
- package/src/react/useConnected.ts +47 -0
- package/src/react/useRpc.ts +103 -0
- package/src/react/useSafeArea.ts +36 -0
- package/src/session.ts +969 -0
- package/src/sub-path-types.test-d.ts +60 -0
- package/src/transport/auto.ts +143 -0
- package/src/transport/dispatch.ts +106 -0
- package/src/transport/local-socket.ts +91 -0
- package/src/transport/mock.ts +255 -0
- package/src/transport/postmessage.ts +95 -0
- package/src/transport/types.ts +26 -0
- package/src/ui/index.ts +129 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview MemoryModule — the user's shared, phone-local memory timeline.
|
|
3
|
+
*
|
|
4
|
+
* One unified per-hour stream of what happened around the user — spoken
|
|
5
|
+
* transcript lines AND notes (manual, voice, auto) — plus the hourly summary
|
|
6
|
+
* that heads each session. The store lives on the phone (host-level,
|
|
7
|
+
* user-scoped), NOT in the per-miniapp storage namespace: every miniapp that
|
|
8
|
+
* declares the MEMORY manifest permission reads and writes the same timeline,
|
|
9
|
+
* and the user manages it in Settings > Memory.
|
|
10
|
+
*
|
|
11
|
+
* A "session" is one clock hour that has entries, derived from entry
|
|
12
|
+
* timestamps at read time — there is no stored session id.
|
|
13
|
+
*
|
|
14
|
+
* All calls require the MEMORY manifest permission; without it the host
|
|
15
|
+
* rejects with PERMISSION_NOT_DECLARED. Nothing here leaves the phone.
|
|
16
|
+
*/
|
|
17
|
+
import { MiniappRequestType } from "../protocol";
|
|
18
|
+
export class MemoryModule {
|
|
19
|
+
constructor(session) {
|
|
20
|
+
this.session = session;
|
|
21
|
+
}
|
|
22
|
+
/** True iff this miniapp's manifest declares the MEMORY permission. */
|
|
23
|
+
get hasPermission() {
|
|
24
|
+
return this.session._hasManifestPermission("MEMORY");
|
|
25
|
+
}
|
|
26
|
+
/** Append a spoken transcript line to the timeline. */
|
|
27
|
+
async appendLine(input) {
|
|
28
|
+
await this.session.sendRequest({
|
|
29
|
+
type: MiniappRequestType.MEMORY_APPEND_LINE,
|
|
30
|
+
...input,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Add a note. `at` targets the hour it belongs to — omit for "now" (the
|
|
35
|
+
* current session), or pass a timestamp inside a past hour to append to
|
|
36
|
+
* that session. Notes dedupe on normalized text within the same hour;
|
|
37
|
+
* resolves null when the note was a duplicate (or empty).
|
|
38
|
+
*/
|
|
39
|
+
async addNote(text, source = "ui", at) {
|
|
40
|
+
const result = await this.session.sendRequest({
|
|
41
|
+
type: MiniappRequestType.MEMORY_ADD_NOTE,
|
|
42
|
+
text,
|
|
43
|
+
source,
|
|
44
|
+
at,
|
|
45
|
+
});
|
|
46
|
+
return result?.entry ?? null;
|
|
47
|
+
}
|
|
48
|
+
/** Delete one entry (line or note) by id. Resolves false when unknown. */
|
|
49
|
+
async removeEntry(id) {
|
|
50
|
+
const result = await this.session.sendRequest({
|
|
51
|
+
type: MiniappRequestType.MEMORY_REMOVE_ENTRY,
|
|
52
|
+
id,
|
|
53
|
+
});
|
|
54
|
+
return !!result?.removed;
|
|
55
|
+
}
|
|
56
|
+
/** Delete every entry (and summary) in an hour, or a whole day of hours. */
|
|
57
|
+
async removeScope(scope, at) {
|
|
58
|
+
await this.session.sendRequest({
|
|
59
|
+
type: MiniappRequestType.MEMORY_REMOVE_SCOPE,
|
|
60
|
+
scope,
|
|
61
|
+
at,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
/** All sessions (hours with entries), newest hour first. */
|
|
65
|
+
async sessions() {
|
|
66
|
+
const result = await this.session.sendRequest({
|
|
67
|
+
type: MiniappRequestType.MEMORY_SESSION_LIST,
|
|
68
|
+
});
|
|
69
|
+
return result?.sessions ?? [];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Query the full timeline by absolute-time window and keyword — the
|
|
73
|
+
* on-device executor shape for LLM history-search tools. Newest last, so
|
|
74
|
+
* slicing keeps the most recent matches when the limit bites.
|
|
75
|
+
*/
|
|
76
|
+
async query(q = {}) {
|
|
77
|
+
return (await this.search(q)).entries;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* query() plus search diagnostics ({@link MemorySearchResult.windowCount}).
|
|
81
|
+
* Same wire request; prefer this from LLM history-search tools so an empty
|
|
82
|
+
* result can explain WHY it was empty instead of triggering a blind retry.
|
|
83
|
+
*/
|
|
84
|
+
async search(q = {}) {
|
|
85
|
+
const result = await this.session.sendRequest({
|
|
86
|
+
type: MiniappRequestType.MEMORY_QUERY,
|
|
87
|
+
...q,
|
|
88
|
+
});
|
|
89
|
+
return {
|
|
90
|
+
entries: result?.entries ?? [],
|
|
91
|
+
...(typeof result?.windowCount === "number" ? { windowCount: result.windowCount } : {}),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/** Entries in [sinceMs, untilMs), newest last. Uncapped (unlike query). */
|
|
95
|
+
async window(sinceMs, untilMs) {
|
|
96
|
+
const result = await this.session.sendRequest({
|
|
97
|
+
type: MiniappRequestType.MEMORY_WINDOW,
|
|
98
|
+
sinceMs,
|
|
99
|
+
untilMs,
|
|
100
|
+
});
|
|
101
|
+
return result?.entries ?? [];
|
|
102
|
+
}
|
|
103
|
+
/** Plain-text export of a scope, for the OS share sheet. */
|
|
104
|
+
async exportText(scope, at) {
|
|
105
|
+
const result = await this.session.sendRequest({
|
|
106
|
+
type: MiniappRequestType.MEMORY_EXPORT_TEXT,
|
|
107
|
+
scope,
|
|
108
|
+
at,
|
|
109
|
+
});
|
|
110
|
+
return result?.text ?? "";
|
|
111
|
+
}
|
|
112
|
+
/** Upsert the summary heading an hour (keyed by hourStart). */
|
|
113
|
+
async addSummary(summary) {
|
|
114
|
+
await this.session.sendRequest({
|
|
115
|
+
type: MiniappRequestType.MEMORY_SUMMARY_ADD,
|
|
116
|
+
...summary,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
/** All hourly summaries, newest hour first. */
|
|
120
|
+
async summaries() {
|
|
121
|
+
const result = await this.session.sendRequest({
|
|
122
|
+
type: MiniappRequestType.MEMORY_SUMMARY_LIST,
|
|
123
|
+
});
|
|
124
|
+
return result?.summaries ?? [];
|
|
125
|
+
}
|
|
126
|
+
/** Most recent COMPLETED hour with lines but no summary, or null. */
|
|
127
|
+
async pendingSummaryHour(nowMs) {
|
|
128
|
+
const result = await this.session.sendRequest({
|
|
129
|
+
type: MiniappRequestType.MEMORY_PENDING_SUMMARY_HOUR,
|
|
130
|
+
nowMs,
|
|
131
|
+
});
|
|
132
|
+
return result?.hourStart ?? null;
|
|
133
|
+
}
|
|
134
|
+
/** Drop the entire timeline: every entry and every summary. */
|
|
135
|
+
async clear() {
|
|
136
|
+
await this.session.sendRequest({
|
|
137
|
+
type: MiniappRequestType.MEMORY_CLEAR,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../src/modules/memory.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,61 @@
|
|
|
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 { MiniappSession } from "../session";
|
|
18
|
+
import type { AudioChunkData, UnsubscribeFn, VadData } from "./events";
|
|
19
|
+
export declare class MicModule {
|
|
20
|
+
private readonly session;
|
|
21
|
+
/** All active unsubscribe functions for stop() to tear down at once. */
|
|
22
|
+
private readonly unsubs;
|
|
23
|
+
constructor(session: MiniappSession);
|
|
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: (data: VadData) => void): UnsubscribeFn;
|
|
29
|
+
/**
|
|
30
|
+
* Subscribe to raw audio chunks. Format depends on the phone's mic mode
|
|
31
|
+
* (PCM or LC3, base64-encoded).
|
|
32
|
+
*/
|
|
33
|
+
onAudioChunk(handler: (data: AudioChunkData) => void): UnsubscribeFn;
|
|
34
|
+
/**
|
|
35
|
+
* Temporarily override glasses-side voice activity detection (GX8002) for
|
|
36
|
+
* this miniapp's lifetime. When disabled, mic gating falls back to the
|
|
37
|
+
* loudness gate only (if it is enabled). The Glassly App's configured value
|
|
38
|
+
* is restored when this miniapp disconnects.
|
|
39
|
+
*
|
|
40
|
+
* Requires `MICROPHONE` in the miniapp manifest.
|
|
41
|
+
*/
|
|
42
|
+
setVoiceActivityDetectionEnabled(enabled: boolean): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Temporarily override the center-mic loudness gate ("Barrier") for this
|
|
45
|
+
* miniapp's lifetime. It blocks quiet/self-talk audio independent of VAD.
|
|
46
|
+
* The Glassly App's configured value is restored when this miniapp disconnects.
|
|
47
|
+
*
|
|
48
|
+
* Requires `MICROPHONE` in the miniapp manifest.
|
|
49
|
+
*/
|
|
50
|
+
setLoudnessGateEnabled(enabled: boolean): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Tear down every subscription this module owns. Useful when a component
|
|
53
|
+
* is unmounting and wants to free everything at once without tracking
|
|
54
|
+
* individual unsubscribe functions.
|
|
55
|
+
*/
|
|
56
|
+
stop(): void;
|
|
57
|
+
/** True iff `MICROPHONE` is declared in the miniapp's manifest. */
|
|
58
|
+
get hasPermission(): boolean;
|
|
59
|
+
private track;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=mic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mic.d.ts","sourceRoot":"","sources":["../../src/modules/mic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAA;AACzC,OAAO,KAAK,EAAC,cAAc,EAAE,aAAa,EAAE,OAAO,EAAC,MAAM,UAAU,CAAA;AAEpE,qBAAa,SAAS;IAIR,OAAO,CAAC,QAAQ,CAAC,OAAO;IAHpC,wEAAwE;IACxE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2B;gBAErB,OAAO,EAAE,cAAc;IAEpD;;;OAGG;IACH,eAAe,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,GAAG,aAAa;IAIhE;;;OAGG;IACH,YAAY,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,GAAG,aAAa;IAIpE;;;;;;;OAOG;IACH,gCAAgC,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAOjE;;;;;;OAMG;IACH,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAOvD;;;;OAIG;IACH,IAAI,IAAI,IAAI;IAWZ,mEAAmE;IACnE,IAAI,aAAa,IAAI,OAAO,CAE3B;IAID,OAAO,CAAC,KAAK;CAOd"}
|
|
@@ -0,0 +1,94 @@
|
|
|
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 { MiniappRequestType, 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
|
+
* Temporarily override glasses-side voice activity detection (GX8002) for
|
|
40
|
+
* this miniapp's lifetime. When disabled, mic gating falls back to the
|
|
41
|
+
* loudness gate only (if it is enabled). The Glassly App's configured value
|
|
42
|
+
* is restored when this miniapp disconnects.
|
|
43
|
+
*
|
|
44
|
+
* Requires `MICROPHONE` in the miniapp manifest.
|
|
45
|
+
*/
|
|
46
|
+
setVoiceActivityDetectionEnabled(enabled) {
|
|
47
|
+
return this.session.sendRequest({
|
|
48
|
+
type: MiniappRequestType.MIC_SET_VAD_ENABLED,
|
|
49
|
+
enabled,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Temporarily override the center-mic loudness gate ("Barrier") for this
|
|
54
|
+
* miniapp's lifetime. It blocks quiet/self-talk audio independent of VAD.
|
|
55
|
+
* The Glassly App's configured value is restored when this miniapp disconnects.
|
|
56
|
+
*
|
|
57
|
+
* Requires `MICROPHONE` in the miniapp manifest.
|
|
58
|
+
*/
|
|
59
|
+
setLoudnessGateEnabled(enabled) {
|
|
60
|
+
return this.session.sendRequest({
|
|
61
|
+
type: MiniappRequestType.MIC_SET_LOUDNESS_GATE_ENABLED,
|
|
62
|
+
enabled,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Tear down every subscription this module owns. Useful when a component
|
|
67
|
+
* is unmounting and wants to free everything at once without tracking
|
|
68
|
+
* individual unsubscribe functions.
|
|
69
|
+
*/
|
|
70
|
+
stop() {
|
|
71
|
+
for (const u of this.unsubs) {
|
|
72
|
+
try {
|
|
73
|
+
u();
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
/* ignore */
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
this.unsubs.clear();
|
|
80
|
+
}
|
|
81
|
+
/** True iff `MICROPHONE` is declared in the miniapp's manifest. */
|
|
82
|
+
get hasPermission() {
|
|
83
|
+
return this.session._hasManifestPermission("MICROPHONE");
|
|
84
|
+
}
|
|
85
|
+
// ------------------------------------------------------------------------
|
|
86
|
+
track(unsub) {
|
|
87
|
+
this.unsubs.add(unsub);
|
|
88
|
+
return () => {
|
|
89
|
+
this.unsubs.delete(unsub);
|
|
90
|
+
unsub();
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
//# 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,kBAAkB,EAAE,iBAAiB,EAAC,MAAM,aAAa,CAAA;AAIjE,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;;;;;;;OAOG;IACH,gCAAgC,CAAC,OAAgB;QAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAO;YACpC,IAAI,EAAE,kBAAkB,CAAC,mBAAmB;YAC5C,OAAO;SACR,CAAC,CAAA;IACJ,CAAC;IAED;;;;;;OAMG;IACH,sBAAsB,CAAC,OAAgB;QACrC,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAO;YACpC,IAAI,EAAE,kBAAkB,CAAC,6BAA6B;YACtD,OAAO;SACR,CAAC,CAAA;IACJ,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,82 @@
|
|
|
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 (Glassly 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
|
+
/** JSON-Schema descriptor for the structured value returned by the action. */
|
|
21
|
+
outputSchema?: Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Hardware compatibility for a listed miniapp. Structurally mirrors the host's
|
|
25
|
+
* `CompatibilityResult` so the runtime can pass it straight through.
|
|
26
|
+
*/
|
|
27
|
+
export interface MiniappCompatibility {
|
|
28
|
+
isCompatible: boolean;
|
|
29
|
+
missingRequired: Array<{
|
|
30
|
+
type: string;
|
|
31
|
+
level?: string;
|
|
32
|
+
}>;
|
|
33
|
+
missingOptional: Array<{
|
|
34
|
+
type: string;
|
|
35
|
+
level?: string;
|
|
36
|
+
}>;
|
|
37
|
+
warnings: string[];
|
|
38
|
+
}
|
|
39
|
+
/** One installed miniapp, as surfaced to a system caller. */
|
|
40
|
+
export interface MiniappInfo {
|
|
41
|
+
packageName: string;
|
|
42
|
+
name: string;
|
|
43
|
+
description?: string;
|
|
44
|
+
version: string;
|
|
45
|
+
running: boolean;
|
|
46
|
+
compatibility: MiniappCompatibility;
|
|
47
|
+
/** Declared actions (empty if the miniapp declares none). */
|
|
48
|
+
actions: MiniappActionInfo[];
|
|
49
|
+
}
|
|
50
|
+
export interface ListMiniappsOptions {
|
|
51
|
+
/** Include incompatible miniapps too (default false — compatible-only). */
|
|
52
|
+
includeIncompatible?: boolean;
|
|
53
|
+
}
|
|
54
|
+
export declare class MiniappsModule {
|
|
55
|
+
private readonly session;
|
|
56
|
+
constructor(session: MiniappSession);
|
|
57
|
+
/**
|
|
58
|
+
* List installed miniapps. Compatible-only by default; pass
|
|
59
|
+
* `{includeIncompatible: true}` to include the rest (each carries a
|
|
60
|
+
* `compatibility` result with the missing hardware). SYSTEM-only.
|
|
61
|
+
*/
|
|
62
|
+
list(opts?: ListMiniappsOptions): Promise<MiniappInfo[]>;
|
|
63
|
+
/**
|
|
64
|
+
* Start another miniapp in the **background** — spawns its background JS
|
|
65
|
+
* context without changing the user's phone navigation or foregrounding
|
|
66
|
+
* anything. The app reports as running and can handle actions / drive the
|
|
67
|
+
* glasses immediately; its WebView only mounts if the user later opens it.
|
|
68
|
+
* SYSTEM-only.
|
|
69
|
+
*/
|
|
70
|
+
start(packageName: string): Promise<void>;
|
|
71
|
+
/** Stop another miniapp. SYSTEM-only. */
|
|
72
|
+
stop(packageName: string): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Stop THIS miniapp — the host tears the background context down shortly
|
|
75
|
+
* after. Not system-gated: an app may always stop itself. Fire-and-forget
|
|
76
|
+
* (no reply — the caller is going away); flush anything pending first, e.g.
|
|
77
|
+
* defer this with a short setTimeout from an action handler so the
|
|
78
|
+
* ACTION_RESULT reaches the caller before teardown.
|
|
79
|
+
*/
|
|
80
|
+
stopSelf(): void;
|
|
81
|
+
}
|
|
82
|
+
//# 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;IACpC,8EAA8E;IAC9E,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACvC;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;IAO9C;;;;;;OAMG;IACH,QAAQ,IAAI,IAAI;CAGjB"}
|
|
@@ -0,0 +1,58 @@
|
|
|
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 (Glassly 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
|
+
* Stop THIS miniapp — the host tears the background context down shortly
|
|
49
|
+
* after. Not system-gated: an app may always stop itself. Fire-and-forget
|
|
50
|
+
* (no reply — the caller is going away); flush anything pending first, e.g.
|
|
51
|
+
* defer this with a short setTimeout from an action handler so the
|
|
52
|
+
* ACTION_RESULT reaches the caller before teardown.
|
|
53
|
+
*/
|
|
54
|
+
stopSelf() {
|
|
55
|
+
this.session.sendOneShot({ type: MiniappRequestType.MINIAPPS_STOP_SELF });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# 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;AA4C9C,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;IAED;;;;;;OAMG;IACH,QAAQ;QACN,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAC,IAAI,EAAE,kBAAkB,CAAC,kBAAkB,EAAC,CAAC,CAAA;IACzE,CAAC;CACF"}
|