@mentra/miniapp 3.3.0 → 3.4.0-beta.1241
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 +5 -5
- package/dist/background/index.d.ts +5 -2
- package/dist/background/index.d.ts.map +1 -1
- package/dist/background/index.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/modules/blob.d.ts +2 -1
- package/dist/modules/blob.d.ts.map +1 -1
- package/dist/modules/blob.js +2 -1
- package/dist/modules/blob.js.map +1 -1
- package/dist/modules/events.d.ts +16 -6
- package/dist/modules/events.d.ts.map +1 -1
- package/dist/modules/events.js +53 -47
- package/dist/modules/events.js.map +1 -1
- package/dist/modules/mic.d.ts +26 -4
- package/dist/modules/mic.d.ts.map +1 -1
- package/dist/modules/mic.js +13 -4
- package/dist/modules/mic.js.map +1 -1
- package/dist/modules/miniapps.d.ts +44 -57
- package/dist/modules/miniapps.d.ts.map +1 -1
- package/dist/modules/miniapps.js +21 -24
- package/dist/modules/miniapps.js.map +1 -1
- package/dist/modules/speaker.d.ts +41 -10
- package/dist/modules/speaker.d.ts.map +1 -1
- package/dist/modules/speaker.js +17 -6
- package/dist/modules/speaker.js.map +1 -1
- package/dist/modules/speechProcessing.d.ts +29 -0
- package/dist/modules/speechProcessing.d.ts.map +1 -0
- package/dist/modules/speechProcessing.js +22 -0
- package/dist/modules/speechProcessing.js.map +1 -0
- package/dist/modules/system.d.ts +8 -3
- package/dist/modules/system.d.ts.map +1 -1
- package/dist/modules/system.js +1 -1
- package/dist/modules/system.js.map +1 -1
- package/dist/modules/telemetry.d.ts +25 -0
- package/dist/modules/telemetry.d.ts.map +1 -0
- package/dist/modules/telemetry.js +61 -0
- package/dist/modules/telemetry.js.map +1 -0
- package/dist/modules/transcription.d.ts +70 -3
- package/dist/modules/transcription.d.ts.map +1 -1
- package/dist/modules/transcription.js +68 -2
- package/dist/modules/transcription.js.map +1 -1
- package/dist/protocol.d.ts +29 -15
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +30 -15
- package/dist/protocol.js.map +1 -1
- package/dist/react/MentraProvider.d.ts +13 -1
- package/dist/react/MentraProvider.d.ts.map +1 -1
- package/dist/react/MentraProvider.js +31 -1
- package/dist/react/MentraProvider.js.map +1 -1
- package/dist/session.d.ts +16 -3
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +6 -13
- package/dist/session.js.map +1 -1
- package/dist/ui/index.d.ts +7 -4
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js.map +1 -1
- package/package.json +2 -2
- package/src/background/index.ts +6 -3
- package/src/index.ts +11 -3
- package/src/modules/blob.ts +2 -1
- package/src/modules/events.ts +65 -51
- package/src/modules/mic.ts +30 -4
- package/src/modules/miniapps.ts +59 -71
- package/src/modules/speaker.ts +56 -12
- package/src/modules/speechProcessing.ts +42 -0
- package/src/modules/system.ts +8 -3
- package/src/modules/telemetry.ts +62 -0
- package/src/modules/transcription.ts +106 -9
- package/src/protocol.ts +32 -16
- package/src/react/MentraProvider.tsx +23 -2
- package/src/session.ts +20 -17
- package/src/ui/index.ts +7 -4
|
@@ -1 +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,kDAAkD;AAClD,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,OAAO,CAAA;AAElD,kFAAkF;AAClF,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG,eAAe,GAAG,iBAAiB,GAAG,YAAY,CAAA;AAEjG,kEAAkE;AAClE,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,SAAS,EA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AAa;IAIhE;;;;;;OAMG;IACH,UAAU,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,GAAG,aAAa;IAIlE,8EAA8E;IAC9E,YAAY,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,GAAG,aAAa;IAIpE;;;;;;;;OAQG;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;;;;;;;;;;;;;;;;;;;OAmBG;IACG,OAAO,CAAC,OAAO,EAAE;QAAC,MAAM,EAAE,gBAAgB,CAAC;QAAC,OAAO,EAAE,iBAAiB,CAAA;KAAC,GAAG,OAAO,CAAC,QAAQ,CAAC;IA0BjG;;;;OAIG;IACH,IAAI,IAAI,IAAI;IAWZ,mEAAmE;IACnE,IAAI,aAAa,IAAI,OAAO,CAE3B;IAID,OAAO,CAAC,KAAK;CAOd"}
|
package/dist/modules/mic.js
CHANGED
|
@@ -22,16 +22,25 @@ export class MicModule {
|
|
|
22
22
|
this.unsubs = new Set();
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
|
-
* Subscribe to voice activity detection
|
|
26
|
-
* `true`
|
|
25
|
+
* Subscribe to on-device voice activity detection. One event when the user
|
|
26
|
+
* starts speaking (`status: true`) and one when they stop (`status: false`,
|
|
27
|
+
* with `silentForMs` saying how long the audio has already been quiet). A
|
|
28
|
+
* gap in microphone audio counts as silence. Requires MICROPHONE permission.
|
|
27
29
|
*/
|
|
28
30
|
onVoiceActivity(handler) {
|
|
29
31
|
return this.track(this.session._subscribe(MiniappStreamType.VAD, handler));
|
|
30
32
|
}
|
|
31
33
|
/**
|
|
32
|
-
* Subscribe to
|
|
33
|
-
*
|
|
34
|
+
* Subscribe to the on-device "Hey Mentra" wake word. Every subscribed
|
|
35
|
+
* miniapp receives every detection. You get the detector's current state
|
|
36
|
+
* right away, then every change. The phone loads the wake-word model while
|
|
37
|
+
* any miniapp subscribes and downloads it on first use. Requires MICROPHONE
|
|
38
|
+
* permission.
|
|
34
39
|
*/
|
|
40
|
+
onWakeWord(handler) {
|
|
41
|
+
return this.track(this.session._subscribe(MiniappStreamType.WAKE_WORD, handler));
|
|
42
|
+
}
|
|
43
|
+
/** Subscribe to raw audio chunks in the phone's PCM/LC3 microphone format. */
|
|
35
44
|
onAudioChunk(handler) {
|
|
36
45
|
return this.track(this.session._subscribe(MiniappStreamType.AUDIO_CHUNK, handler));
|
|
37
46
|
}
|
package/dist/modules/mic.js.map
CHANGED
|
@@ -1 +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;
|
|
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;AAgCjE,MAAM,OAAO,SAAS;IAIpB,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;QAHpD,wEAAwE;QACvD,WAAM,GAAG,IAAI,GAAG,EAAiB,CAAA;IAEK,CAAC;IAExD;;;;;OAKG;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;;;;;;OAMG;IACH,UAAU,CAAC,OAAuC;QAChD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAC,SAA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AAO,CAAC,WAAW,CAAO;oBACnC,IAAI,EAAE,kBAAkB,CAAC,WAAW;oBACpC,SAAS;iBACV,CAAC,CAAA;YACJ,CAAC;SACF,CAAA;IACH,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"}
|
|
@@ -7,10 +7,12 @@
|
|
|
7
7
|
* layer (invoke / handle) lives on `session.actions`, not here — these are
|
|
8
8
|
* operations on the app as a whole, not on a declared action.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
* narrower still:
|
|
12
|
-
* the Mentra App
|
|
13
|
-
*
|
|
10
|
+
* Installing (`install`, `checkInstallCompatibility`, `uninstall`) is
|
|
11
|
+
* narrower still: only a miniapp on the Mentra App's system list, running the
|
|
12
|
+
* release the Mentra App installed for it, may install miniapps. Development
|
|
13
|
+
* builds, which may use the calls above, may not. The host installs from a
|
|
14
|
+
* miniapp URL through the same installer as every other way in, with no install
|
|
15
|
+
* sheet: the caller asks the person first.
|
|
14
16
|
*/
|
|
15
17
|
import { MiniappSession } from "../session";
|
|
16
18
|
/** A declared action surfaced by {@link MiniappsModule.list}. */
|
|
@@ -56,10 +58,6 @@ export interface MiniappInfo {
|
|
|
56
58
|
compatibility: MiniappCompatibility;
|
|
57
59
|
/** True when this package identity is backed by a ZIP in the Mentra App build. */
|
|
58
60
|
system: boolean;
|
|
59
|
-
/** Store package that owns updates of this active release, when it is Store-managed. */
|
|
60
|
-
storeOwnerPackageName?: string;
|
|
61
|
-
/** Store the host build assigns to update this bundled package's active release, if any. */
|
|
62
|
-
systemStoreOwnerPackageName?: string;
|
|
63
61
|
/** Declared actions (empty if the miniapp declares none). */
|
|
64
62
|
actions: MiniappActionInfo[];
|
|
65
63
|
}
|
|
@@ -72,47 +70,41 @@ export interface MiniappHardwareRequirement {
|
|
|
72
70
|
level: string;
|
|
73
71
|
description?: string;
|
|
74
72
|
}
|
|
75
|
-
/**
|
|
73
|
+
/** A miniapp to install. */
|
|
76
74
|
export interface InstallMiniappRequest {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
bundleUrl: string;
|
|
80
|
-
/** SHA-256 of the release ZIP; the host refuses any other bytes. */
|
|
81
|
-
bundleSha256: string;
|
|
82
|
-
/**
|
|
83
|
-
* Bearer for `bundleUrl`, when the Store's backend requires one. The host
|
|
84
|
-
* forwards it untouched and keeps no Store address of its own: entitlement is
|
|
85
|
-
* settled between this miniapp and its backend, integrity by the SHA-256 and
|
|
86
|
-
* the bundle's publisher signature.
|
|
87
|
-
*/
|
|
88
|
-
bundleAuthorization?: string;
|
|
75
|
+
/** The miniapp's URL: the HTTPS address that serves its `miniapp.json`. */
|
|
76
|
+
url: string;
|
|
89
77
|
/**
|
|
90
|
-
*
|
|
91
|
-
*
|
|
78
|
+
* The package the person agreed to install. When given, a URL that serves another package installs nothing and
|
|
79
|
+
* fails with `not_a_miniapp`.
|
|
92
80
|
*/
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* With `onlyIfStopped`: when the target is running, the host stages the
|
|
96
|
-
* release and asks the user whether to update now. Declining, or a prompt the
|
|
97
|
-
* host does not show (the Mentra App is in the background, another prompt is
|
|
98
|
-
* open, or this miniapp was asked within the last day), still answers
|
|
99
|
-
* `APP_RUNNING`.
|
|
100
|
-
*/
|
|
101
|
-
askIfRunning?: boolean;
|
|
102
|
-
/** Minimum Mentra App version declared by the release manifest. */
|
|
103
|
-
minHostVersion?: string;
|
|
104
|
-
/** Mentra Miniapp SDK version declared by the release manifest. */
|
|
105
|
-
sdkVersion?: string;
|
|
106
|
-
/** Glasses hardware requirements declared by the release manifest. */
|
|
107
|
-
hardwareRequirements?: MiniappHardwareRequirement[];
|
|
108
|
-
releaseId?: string;
|
|
109
|
-
channel?: string;
|
|
81
|
+
packageName?: string;
|
|
110
82
|
}
|
|
111
83
|
export interface InstallMiniappResult {
|
|
84
|
+
/**
|
|
85
|
+
* `installed`: this release installed. `opened`: nothing installed, because the miniapp is installed from this URL
|
|
86
|
+
* already, or a newer release of it is; {@link MiniappsModule.open} it to show it. `deferred`: the miniapp is
|
|
87
|
+
* running, so its update waits until it stops, or until the person answers the Mentra App's update prompt.
|
|
88
|
+
*/
|
|
89
|
+
status: "installed" | "opened" | "deferred";
|
|
112
90
|
packageName: string;
|
|
91
|
+
/** The installed version: the new release, or the one that stays. */
|
|
113
92
|
version: string;
|
|
114
|
-
installedByStore: string;
|
|
115
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* Why an install failed: the `reason` of an `INSTALL_FAILED` rejection from {@link MiniappsModule.install}.
|
|
96
|
+
* - `not_a_miniapp`: the URL serves no valid `miniapp.json` or bundle.
|
|
97
|
+
* - `domain_mismatch`: the package name doesn't belong to the URL's domain.
|
|
98
|
+
* - `archived`: Mentra archived this URL; it doesn't install.
|
|
99
|
+
* - `needs_newer_app`: the miniapp needs a newer Mentra App, or hardware the glasses lack.
|
|
100
|
+
* - `access_denied`: its server refused this account, or this deployment doesn't allow installing from a URL.
|
|
101
|
+
* - `age_restricted`: the person's declared age is below the miniapp's age rating.
|
|
102
|
+
* - `network`: the URL couldn't be reached.
|
|
103
|
+
* - `cancelled`: the Mentra App signed out or switched deployments meanwhile.
|
|
104
|
+
* - `integrity`: the bundle doesn't match what `miniapp.json` names.
|
|
105
|
+
* - `signature_invalid`: the bundle's signature doesn't match the installed miniapp's publisher.
|
|
106
|
+
*/
|
|
107
|
+
export type InstallMiniappFailureReason = "not_a_miniapp" | "domain_mismatch" | "archived" | "needs_newer_app" | "access_denied" | "age_restricted" | "network" | "cancelled" | "integrity" | "signature_invalid";
|
|
116
108
|
export interface InstallMiniappCompatibilityRequest {
|
|
117
109
|
minHostVersion?: string | null;
|
|
118
110
|
sdkVersion?: string | null;
|
|
@@ -125,15 +117,8 @@ export type InstallMiniappCompatibility = {
|
|
|
125
117
|
blocker: "host" | "sdk" | "hardware";
|
|
126
118
|
reason: string;
|
|
127
119
|
};
|
|
128
|
-
export type InstallMiniappPhase = "downloading" | "verifying" | "extracting" | "activating" | "complete";
|
|
129
|
-
export interface InstallMiniappProgress {
|
|
130
|
-
packageName: string;
|
|
131
|
-
version: string;
|
|
132
|
-
phase: InstallMiniappPhase;
|
|
133
|
-
}
|
|
134
120
|
export declare class MiniappsModule {
|
|
135
121
|
private readonly session;
|
|
136
|
-
private readonly progressHandlers;
|
|
137
122
|
constructor(session: MiniappSession);
|
|
138
123
|
/**
|
|
139
124
|
* List installed miniapps. Compatible-only by default; pass
|
|
@@ -154,18 +139,20 @@ export declare class MiniappsModule {
|
|
|
154
139
|
/** Stop another miniapp. SYSTEM-only. */
|
|
155
140
|
stop(packageName: string): Promise<void>;
|
|
156
141
|
/**
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
142
|
+
* Install the miniapp at a miniapp URL, with no install sheet: ask the person first. The host fetches its
|
|
143
|
+
* `miniapp.json`, checks the package name against the URL's domain, registers the URL with Mentra, checks the
|
|
144
|
+
* phone can run it, and downloads, verifies and installs its bundle.
|
|
145
|
+
*
|
|
146
|
+
* Only a miniapp on the Mentra App's system list may install; any other caller gets NOT_PERMITTED. A failed
|
|
147
|
+
* install rejects with INSTALL_FAILED, whose `reason` is an {@link InstallMiniappFailureReason}.
|
|
160
148
|
*/
|
|
161
149
|
install(request: InstallMiniappRequest): Promise<InstallMiniappResult>;
|
|
162
|
-
/** Check
|
|
150
|
+
/** Check a release's Mentra App, SDK and glasses requirements against this phone. System-list miniapps only. */
|
|
163
151
|
checkInstallCompatibility(request: InstallMiniappCompatibilityRequest): Promise<InstallMiniappCompatibility>;
|
|
164
|
-
/**
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
/** Uninstall a package this Store installed. Bundled Stores only. */
|
|
152
|
+
/**
|
|
153
|
+
* Uninstall a miniapp installed from a miniapp URL. A miniapp the Mentra App bundles, one a workspace manages and a
|
|
154
|
+
* development build stay, with NOT_PERMITTED. System-list miniapps only.
|
|
155
|
+
*/
|
|
169
156
|
uninstall(packageName: string): Promise<void>;
|
|
170
157
|
}
|
|
171
158
|
//# sourceMappingURL=miniapps.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"miniapps.d.ts","sourceRoot":"","sources":["../../src/modules/miniapps.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"miniapps.d.ts","sourceRoot":"","sources":["../../src/modules/miniapps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;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;IACtC;;;OAGG;IACH,SAAS,EAAE,YAAY,GAAG,WAAW,CAAA;CACtC;AAED;;;GAGG;AACH,MAAM,WAAW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7,16 +7,17 @@
|
|
|
7
7
|
* layer (invoke / handle) lives on `session.actions`, not here — these are
|
|
8
8
|
* operations on the app as a whole, not on a declared action.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
* narrower still:
|
|
12
|
-
* the Mentra App
|
|
13
|
-
*
|
|
10
|
+
* Installing (`install`, `checkInstallCompatibility`, `uninstall`) is
|
|
11
|
+
* narrower still: only a miniapp on the Mentra App's system list, running the
|
|
12
|
+
* release the Mentra App installed for it, may install miniapps. Development
|
|
13
|
+
* builds, which may use the calls above, may not. The host installs from a
|
|
14
|
+
* miniapp URL through the same installer as every other way in, with no install
|
|
15
|
+
* sheet: the caller asks the person first.
|
|
14
16
|
*/
|
|
15
17
|
import { MiniappRequestType } from "../protocol";
|
|
16
18
|
export class MiniappsModule {
|
|
17
19
|
constructor(session) {
|
|
18
20
|
this.session = session;
|
|
19
|
-
this.progressHandlers = new Set();
|
|
20
21
|
}
|
|
21
22
|
/**
|
|
22
23
|
* List installed miniapps. Compatible-only by default; pass
|
|
@@ -59,21 +60,24 @@ export class MiniappsModule {
|
|
|
59
60
|
});
|
|
60
61
|
}
|
|
61
62
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
63
|
+
* Install the miniapp at a miniapp URL, with no install sheet: ask the person first. The host fetches its
|
|
64
|
+
* `miniapp.json`, checks the package name against the URL's domain, registers the URL with Mentra, checks the
|
|
65
|
+
* phone can run it, and downloads, verifies and installs its bundle.
|
|
66
|
+
*
|
|
67
|
+
* Only a miniapp on the Mentra App's system list may install; any other caller gets NOT_PERMITTED. A failed
|
|
68
|
+
* install rejects with INSTALL_FAILED, whose `reason` is an {@link InstallMiniappFailureReason}.
|
|
65
69
|
*/
|
|
66
70
|
async install(request) {
|
|
67
71
|
return this.session.sendRequest({
|
|
68
|
-
...request,
|
|
69
72
|
type: MiniappRequestType.MINIAPPS_INSTALL,
|
|
73
|
+
url: request.url,
|
|
74
|
+
...(request.packageName !== undefined ? { packageName: request.packageName } : {}),
|
|
70
75
|
},
|
|
71
|
-
//
|
|
72
|
-
//
|
|
73
|
-
// still settles on the host response or session disconnect.
|
|
76
|
+
// Fetching, registering, downloading and installing can legitimately outlast the SDK's default request
|
|
77
|
+
// timeout. The request still settles on the host response or session disconnect.
|
|
74
78
|
{ timeoutMs: 0 });
|
|
75
79
|
}
|
|
76
|
-
/** Check
|
|
80
|
+
/** Check a release's Mentra App, SDK and glasses requirements against this phone. System-list miniapps only. */
|
|
77
81
|
async checkInstallCompatibility(request) {
|
|
78
82
|
return this.session.sendRequest({
|
|
79
83
|
type: MiniappRequestType.MINIAPPS_INSTALL_CHECK,
|
|
@@ -82,17 +86,10 @@ export class MiniappsModule {
|
|
|
82
86
|
hardwareRequirements: request.hardwareRequirements ?? [],
|
|
83
87
|
});
|
|
84
88
|
}
|
|
85
|
-
/**
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
/** @internal */
|
|
91
|
-
_deliverInstallProgress(progress) {
|
|
92
|
-
for (const handler of this.progressHandlers)
|
|
93
|
-
handler(progress);
|
|
94
|
-
}
|
|
95
|
-
/** Uninstall a package this Store installed. Bundled Stores only. */
|
|
89
|
+
/**
|
|
90
|
+
* Uninstall a miniapp installed from a miniapp URL. A miniapp the Mentra App bundles, one a workspace manages and a
|
|
91
|
+
* development build stay, with NOT_PERMITTED. System-list miniapps only.
|
|
92
|
+
*/
|
|
96
93
|
async uninstall(packageName) {
|
|
97
94
|
await this.session.sendRequest({
|
|
98
95
|
type: MiniappRequestType.MINIAPPS_UNINSTALL,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"miniapps.js","sourceRoot":"","sources":["../../src/modules/miniapps.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"miniapps.js","sourceRoot":"","sources":["../../src/modules/miniapps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAC,kBAAk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CAAC,WAAW,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SACjF;QACD,uGAAuG;QACvG,iFAAiF;QACjF,EAAC,SAAS,EAAE,CAAC,EAAC,CACf,CAAA;IACH,CAAC;IAED,gHAAgH;IAChH,KAAK,CAAC,yBAAyB,CAAC,OAA2C;QACzE,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAA8B;YAC3D,IAAI,EAAE,kBAAkB,CAAC,sBAAsB;YAC/C,cAAc,EAAE,OAAO,CAAC,cAAc,IAAI,SAAS;YACnD,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,SAAS;YAC3C,oBAAoB,EAAE,OAAO,CAAC,oBAAoB,IAAI,EAAE;SACzD,CAAC,CAAA;IACJ,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,SAAS,CAAC,WAAmB;QACjC,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAAO;YACnC,IAAI,EAAE,kBAAkB,CAAC,kBAAkB;YAC3C,WAAW;SACZ,CAAC,CAAA;IACJ,CAAC;CACF"}
|
|
@@ -5,13 +5,15 @@
|
|
|
5
5
|
* audio chunks, VAD) lives on session.mic — the split is by I/O direction.
|
|
6
6
|
*
|
|
7
7
|
* Imperative surface:
|
|
8
|
-
* speaker.play({audioUrl}) — play an
|
|
8
|
+
* speaker.play({audioUrl}) — play an http(s) or data: URL, or one of this
|
|
9
|
+
* miniapp's blobs, via the phone's
|
|
9
10
|
* AudioPlaybackService.
|
|
10
|
-
* speaker.speak(text) — send a SPEAK request.
|
|
11
|
-
* TTS when connected and falls
|
|
12
|
-
*
|
|
11
|
+
* speaker.speak(text) — send a SPEAK request. By default the phone
|
|
12
|
+
* streams cloud TTS when connected and falls
|
|
13
|
+
* back to its on-device voice; the
|
|
14
|
+
* `processing` option picks the order.
|
|
13
15
|
* Resolves when playback completes; rejects
|
|
14
|
-
* with a TTS_* error code on
|
|
16
|
+
* with a TTS_* error code on failure.
|
|
15
17
|
* speaker.createStream(opts) — open a live PCM output stream (16-bit LE).
|
|
16
18
|
* Returns a SpeakerStreamWriter: write() PCM
|
|
17
19
|
* chunks as they arrive (e.g. from a WebSocket
|
|
@@ -35,7 +37,12 @@
|
|
|
35
37
|
*/
|
|
36
38
|
import { MiniappSession } from "../session";
|
|
37
39
|
import type { UnsubscribeFn } from "./events";
|
|
40
|
+
import { type SpeechProcessing } from "./speechProcessing";
|
|
38
41
|
export interface PlayAudioOptions {
|
|
42
|
+
/**
|
|
43
|
+
* An http(s) or `data:` URL, or the `file://` uri of one of this miniapp's
|
|
44
|
+
* blobs (`session.blob`). The host refuses any other file or scheme.
|
|
45
|
+
*/
|
|
39
46
|
audioUrl: string;
|
|
40
47
|
/** Start playback at this offset in milliseconds. Defaults to zero. */
|
|
41
48
|
startPositionMs?: number;
|
|
@@ -53,10 +60,17 @@ export interface SpeakOptions {
|
|
|
53
60
|
*/
|
|
54
61
|
enableSanitization?: boolean;
|
|
55
62
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
63
|
+
* Where the speech is synthesized. Default `"preferCloud"`.
|
|
64
|
+
*
|
|
65
|
+
* - `"preferCloud"`: cloud TTS while the cloud is connected, otherwise the
|
|
66
|
+
* phone's on-device voice.
|
|
67
|
+
* - `"preferLocal"`: the on-device voice when its model is ready and can say
|
|
68
|
+
* it (an explicit cloud `voice_id` cannot), otherwise cloud TTS.
|
|
69
|
+
* - `"localOnly"`: the on-device voice only; never the cloud. Rejects with
|
|
70
|
+
* `TTS_LOCAL_UNAVAILABLE` when the on-device model isn't ready.
|
|
59
71
|
*/
|
|
72
|
+
processing?: SpeechProcessing;
|
|
73
|
+
/** @deprecated Use `processing: "localOnly"`. Removed in 4.0; ignored when `processing` is set. */
|
|
60
74
|
forceLocal?: boolean;
|
|
61
75
|
}
|
|
62
76
|
export interface SpeakResult {
|
|
@@ -69,6 +83,22 @@ export type SpeakerStreamSampleRate = 16000 | 24000 | 48000;
|
|
|
69
83
|
export interface SpeakerStreamOptions {
|
|
70
84
|
/** PCM sample rate in Hz. Default 16000. */
|
|
71
85
|
sampleRate?: SpeakerStreamSampleRate;
|
|
86
|
+
/**
|
|
87
|
+
* Open the native stream now and keep it idle until the first write, so a
|
|
88
|
+
* later sound only has to write samples. The speaker reports `idle` and other
|
|
89
|
+
* audio is left alone until then. If the audio route changes before the
|
|
90
|
+
* first write (Bluetooth or glasses connect/disconnect, a call, an audio
|
|
91
|
+
* interruption), the phone closes the stream and the next write fails with
|
|
92
|
+
* "not open"; open a fresh stream then.
|
|
93
|
+
*/
|
|
94
|
+
prewarm?: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* How much audio (80–500 ms) the phone queues before playback starts, and
|
|
97
|
+
* the cushion against gaps after that. Default 500. A sound shorter than
|
|
98
|
+
* this still plays once you close the stream. Use a small value such as 80
|
|
99
|
+
* for short cues that should start immediately.
|
|
100
|
+
*/
|
|
101
|
+
jitterMs?: number;
|
|
72
102
|
/** Channel count. v1 is mono only. Default 1. */
|
|
73
103
|
channels?: 1;
|
|
74
104
|
/** Playback volume 0..1. Default 1. */
|
|
@@ -142,8 +172,9 @@ export declare class SpeakerModule {
|
|
|
142
172
|
/** Play a URL. Resolves when playback completes on the phone. */
|
|
143
173
|
play(options: PlayAudioOptions): Promise<void>;
|
|
144
174
|
/**
|
|
145
|
-
* Speak text through the phone
|
|
146
|
-
*
|
|
175
|
+
* Speak text through the phone, in the cloud or on-device as
|
|
176
|
+
* `options.processing` says (default: cloud TTS when connected, then the
|
|
177
|
+
* on-device voice).
|
|
147
178
|
*
|
|
148
179
|
* Rejects with a MiniappRequestError containing a `code` field on cloud-side
|
|
149
180
|
* TTS failures: `TTS_TEXT_TOO_LONG`, `TTS_INVALID_VOICE`, `TTS_UPSTREAM_ERROR`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"speaker.d.ts","sourceRoot":"","sources":["../../src/modules/speaker.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"speaker.d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A;CACpB;AAED,qBAAa,aAAa;IAIZ,OAAO,CAAC,QAAQ,CAAC,OAAO;IAHpC,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,UAAU,CAAqC;gBAE1B,OAAO,EAAE,cAAc;IAEpD,sCAAsC;IACtC,IAAI,KAAK,IAAI,YAAY,CAExB;IAED,oCAAoC;IACpC,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,iEAAiE;IAC3D,IAAI,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAuBpD;;;;;;;OAOG;IACG,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;IACjE,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;IAoC9E;;;;;;;;;OASG;IACG,YAAY,CAAC,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAwBpF,wDAAwD;IACxD,IAAI,IAAI,IAAI;IAIZ;;;;OAIG;IACH,aAAa,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,GAAG,aAAa;IAIzE,+EAA+E;IAC/E,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI;IAS3C,6BAA6B;IAC7B,aAAa,IAAI,iBAAiB;CAGnC"}
|
package/dist/modules/speaker.js
CHANGED
|
@@ -5,13 +5,15 @@
|
|
|
5
5
|
* audio chunks, VAD) lives on session.mic — the split is by I/O direction.
|
|
6
6
|
*
|
|
7
7
|
* Imperative surface:
|
|
8
|
-
* speaker.play({audioUrl}) — play an
|
|
8
|
+
* speaker.play({audioUrl}) — play an http(s) or data: URL, or one of this
|
|
9
|
+
* miniapp's blobs, via the phone's
|
|
9
10
|
* AudioPlaybackService.
|
|
10
|
-
* speaker.speak(text) — send a SPEAK request.
|
|
11
|
-
* TTS when connected and falls
|
|
12
|
-
*
|
|
11
|
+
* speaker.speak(text) — send a SPEAK request. By default the phone
|
|
12
|
+
* streams cloud TTS when connected and falls
|
|
13
|
+
* back to its on-device voice; the
|
|
14
|
+
* `processing` option picks the order.
|
|
13
15
|
* Resolves when playback completes; rejects
|
|
14
|
-
* with a TTS_* error code on
|
|
16
|
+
* with a TTS_* error code on failure.
|
|
15
17
|
* speaker.createStream(opts) — open a live PCM output stream (16-bit LE).
|
|
16
18
|
* Returns a SpeakerStreamWriter: write() PCM
|
|
17
19
|
* chunks as they arrive (e.g. from a WebSocket
|
|
@@ -35,6 +37,7 @@
|
|
|
35
37
|
*/
|
|
36
38
|
import { MiniappErrorCode, MiniappRequestType } from "../protocol";
|
|
37
39
|
import { bytesToBase64, toUint8Array } from "./base64";
|
|
40
|
+
import { resolveSpeechProcessing } from "./speechProcessing";
|
|
38
41
|
/** Raw bytes per bridge write. PCM chunks are small; keep messages snappy. */
|
|
39
42
|
export const SPEAKER_WRITE_CHUNK_BYTES = 256 * 1024;
|
|
40
43
|
// Every non-final base64 slice must decode to complete 16-bit samples. Six
|
|
@@ -176,6 +179,7 @@ export class SpeakerModule {
|
|
|
176
179
|
if ((Array.isArray(normalized) && normalized.length === 0) || normalized === "") {
|
|
177
180
|
throw { code: MiniappErrorCode.INTERNAL, message: "speak requires at least one non-empty sentence" };
|
|
178
181
|
}
|
|
182
|
+
const processing = resolveSpeechProcessing(options, "speaker.speak(options)");
|
|
179
183
|
try {
|
|
180
184
|
// Like play(): resolves only when TTS playback completes, so opt out of the
|
|
181
185
|
// default request timeout (long text can outlast it). Settled by the host
|
|
@@ -188,7 +192,9 @@ export class SpeakerModule {
|
|
|
188
192
|
volume: options.volume,
|
|
189
193
|
stopOtherAudio: options.stopOtherAudio ?? false,
|
|
190
194
|
enableSanitization: options.enableSanitization ?? true,
|
|
191
|
-
|
|
195
|
+
processing,
|
|
196
|
+
// Hosts before `processing` (Mentra App 3.4.0) read only this flag.
|
|
197
|
+
forceLocal: processing === "localOnly",
|
|
192
198
|
}, { timeoutMs: 0 });
|
|
193
199
|
return result ?? { completed: true };
|
|
194
200
|
}
|
|
@@ -215,9 +221,14 @@ export class SpeakerModule {
|
|
|
215
221
|
(!Number.isFinite(options.volume) || options.volume < 0 || options.volume > 1)) {
|
|
216
222
|
throw new RangeError("speaker stream volume must be between 0 and 1");
|
|
217
223
|
}
|
|
224
|
+
if (options.jitterMs !== undefined &&
|
|
225
|
+
(!Number.isFinite(options.jitterMs) || options.jitterMs < 80 || options.jitterMs > 500))
|
|
226
|
+
throw new RangeError("speaker stream jitterMs must be between 80 and 500");
|
|
218
227
|
const res = await this.session.sendRequest({
|
|
219
228
|
type: MiniappRequestType.SPEAKER_STREAM_OPEN,
|
|
220
229
|
sampleRate: options.sampleRate ?? 16000,
|
|
230
|
+
...(options.jitterMs === undefined ? {} : { jitterMs: options.jitterMs }),
|
|
231
|
+
...(options.prewarm === undefined ? {} : { prewarm: options.prewarm }),
|
|
221
232
|
channels: options.channels ?? 1,
|
|
222
233
|
volume: options.volume,
|
|
223
234
|
stopOtherAudio: options.stopOtherAudio ?? true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"speaker.js","sourceRoot":"","sources":["../../src/modules/speaker.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"speaker.js","sourceRoot":"","sources":["../../src/modules/speaker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,EAAC,gBAAgB,EAAE,kBAAkB,EAAC,MAAM,aAAa,CAAA;AAEhE,OAAO,EAAC,aAAa,EAAE,YAAY,EAAC,MAAM,UAAU,CAAA;AAEpD,OAAO,EAAC,uBAAuB,EAAwB,MAAM,oBAAoB,CAAA;AAmFjF,8EAA8E;AAC9E,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAG,GAAG,IAAI,CAAA;AACnD,2EAA2E;AAC3E,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,mBAAmB,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAA;IAC5D,CAAC;IAED,wDAAwD;IACxD,IAAI;QACF,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAC,IAAI,EAAE,kBAAkB,CAAC,UAAU,EAAC,CAAC,CAAA;IACjE,CAAC;IAED;;;;OAIG;IACH,aAAa,CAAC,OAA2C;QACvD,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,cAAc,EAAE,OAAO,CAAC,CAAA;IACjD,CAAC;IAED,+EAA+E;IAC/E,WAAW,CAAC,KAAwB;QAClC,sEAAsE;QACtE,sEAAsE;QACtE,uDAAuD;QACvD,IAAI,KAAK,CAAC,KAAK,KAAK,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,KAAK,KAAK,OAAO;YAAE,OAAM;QAClE,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,KAAK,CAAA;QACzB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAA;IACzB,CAAC;IAED,6BAA6B;IAC7B,aAAa;QACX,OAAO,EAAC,GAAG,IAAI,CAAC,UAAU,EAAC,CAAA;IAC7B,CAAC;CACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Where speech is processed: on the phone or in the cloud.
|
|
3
|
+
*
|
|
4
|
+
* Transcription listeners (`session.transcription.on` / `forLanguage`) and
|
|
5
|
+
* speech requests (`session.speaker.speak`) take the same `processing` option.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Where speech is processed.
|
|
9
|
+
*
|
|
10
|
+
* - `"preferCloud"` (default): the cloud; the phone's on-device models only
|
|
11
|
+
* while the cloud is unreachable.
|
|
12
|
+
* - `"preferLocal"`: on-device when a model for the language is ready,
|
|
13
|
+
* otherwise the cloud.
|
|
14
|
+
* - `"localOnly"`: on-device only; never the cloud.
|
|
15
|
+
*/
|
|
16
|
+
export type SpeechProcessing = "preferCloud" | "preferLocal" | "localOnly";
|
|
17
|
+
/** The `processing` option, with the deprecated `forceLocal` it replaces. */
|
|
18
|
+
export interface SpeechProcessingOptions {
|
|
19
|
+
processing?: SpeechProcessing;
|
|
20
|
+
/** @deprecated Use `processing: "localOnly"`. Removed in 4.0. */
|
|
21
|
+
forceLocal?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @internal The processing an options object asks for. `processing` wins;
|
|
25
|
+
* without it, the deprecated `forceLocal: true` means `"localOnly"`.
|
|
26
|
+
* Throws `MiniappValidationError` for an unknown `processing` value.
|
|
27
|
+
*/
|
|
28
|
+
export declare function resolveSpeechProcessing(options: SpeechProcessingOptions, where: string): SpeechProcessing;
|
|
29
|
+
//# sourceMappingURL=speechProcessing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"speechProcessing.d.ts","sourceRoot":"","sources":["../../src/modules/speechProcessing.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;;;;;;GAQG;AACH,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG,aAAa,GAAG,WAAW,CAAA;AAI1E,6EAA6E;AAC7E,MAAM,WAAW,uBAAuB;IACtC,UAAU,CAAC,EAAE,gBAAgB,CAAA;IAC7B,iEAAiE;IACjE,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,uBAAuB,EAAE,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAOzG"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Where speech is processed: on the phone or in the cloud.
|
|
3
|
+
*
|
|
4
|
+
* Transcription listeners (`session.transcription.on` / `forLanguage`) and
|
|
5
|
+
* speech requests (`session.speaker.speak`) take the same `processing` option.
|
|
6
|
+
*/
|
|
7
|
+
import { MiniappValidationError } from "./languages";
|
|
8
|
+
const SPEECH_PROCESSING = ["preferCloud", "preferLocal", "localOnly"];
|
|
9
|
+
/**
|
|
10
|
+
* @internal The processing an options object asks for. `processing` wins;
|
|
11
|
+
* without it, the deprecated `forceLocal: true` means `"localOnly"`.
|
|
12
|
+
* Throws `MiniappValidationError` for an unknown `processing` value.
|
|
13
|
+
*/
|
|
14
|
+
export function resolveSpeechProcessing(options, where) {
|
|
15
|
+
const { processing } = options;
|
|
16
|
+
if (processing === undefined)
|
|
17
|
+
return options.forceLocal === true ? "localOnly" : "preferCloud";
|
|
18
|
+
if (SPEECH_PROCESSING.includes(processing))
|
|
19
|
+
return processing;
|
|
20
|
+
throw new MiniappValidationError(`${where}: unknown processing ${JSON.stringify(processing)}. Use ${SPEECH_PROCESSING.map((value) => `"${value}"`).join(", ")}.`);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=speechProcessing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"speechProcessing.js","sourceRoot":"","sources":["../../src/modules/speechProcessing.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,sBAAsB,EAAC,MAAM,aAAa,CAAA;AAalD,MAAM,iBAAiB,GAAgC,CAAC,aAAa,EAAE,aAAa,EAAE,WAAW,CAAC,CAAA;AASlG;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAgC,EAAE,KAAa;IACrF,MAAM,EAAC,UAAU,EAAC,GAAG,OAAO,CAAA;IAC5B,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,OAAO,CAAC,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa,CAAA;IAC9F,IAAI,iBAAiB,CAAC,QAAQ,CAAC,UAAU,CAAC;QAAE,OAAO,UAAU,CAAA;IAC7D,MAAM,IAAI,sBAAsB,CAC9B,GAAG,KAAK,wBAAwB,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,SAAS,iBAAiB,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAChI,CAAA;AACH,CAAC"}
|
package/dist/modules/system.d.ts
CHANGED
|
@@ -6,13 +6,17 @@
|
|
|
6
6
|
import { MiniappSession } from "../session";
|
|
7
7
|
export interface ShareOptions {
|
|
8
8
|
text?: string;
|
|
9
|
+
/**
|
|
10
|
+
* An http(s) link, or the `file://` uri of one of this miniapp's blobs
|
|
11
|
+
* (`session.blob`). The host refuses any other file or scheme.
|
|
12
|
+
*/
|
|
9
13
|
url?: string;
|
|
10
14
|
title?: string;
|
|
11
15
|
/** Base64-encoded file data for file sharing. */
|
|
12
16
|
base64?: string;
|
|
13
17
|
/** MIME type when sharing base64 data. */
|
|
14
18
|
mimeType?: string;
|
|
15
|
-
/**
|
|
19
|
+
/** File name when sharing base64 data: one name; path separators become `_`. */
|
|
16
20
|
filename?: string;
|
|
17
21
|
}
|
|
18
22
|
export interface ShareResult {
|
|
@@ -20,9 +24,10 @@ export interface ShareResult {
|
|
|
20
24
|
cancelled?: boolean;
|
|
21
25
|
}
|
|
22
26
|
export interface DownloadOptions {
|
|
23
|
-
/** URL to download from, OR base64 data. */
|
|
27
|
+
/** An http: or https: URL to download from, OR base64 data. */
|
|
24
28
|
url?: string;
|
|
25
29
|
base64?: string;
|
|
30
|
+
/** One file name; path separators become `_`. */
|
|
26
31
|
filename?: string;
|
|
27
32
|
mimeType?: string;
|
|
28
33
|
}
|
|
@@ -48,7 +53,7 @@ export declare class SystemModule {
|
|
|
48
53
|
constructor(session: MiniappSession);
|
|
49
54
|
/** Open the OS share sheet with the given content. */
|
|
50
55
|
share(options: ShareOptions): Promise<ShareResult>;
|
|
51
|
-
/** Open a URL in the system browser.
|
|
56
|
+
/** Open a URL in the system browser. Never opens local files or scripts (file:, content:, javascript:, data:). */
|
|
52
57
|
openUrl(url: string): void;
|
|
53
58
|
/** Copy text to the system clipboard. */
|
|
54
59
|
copyToClipboard(text: string): Promise<void>;
|