@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,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview BlobModule — phone-local persistent BINARY storage, keyed and
|
|
3
|
+
* scoped to (userId, packageName). The binary sibling of `session.storage`:
|
|
4
|
+
* where storage holds small strings, blob holds arbitrary bytes (PDFs, EPUBs,
|
|
5
|
+
* audio, video, model files, caches) as files on the phone.
|
|
6
|
+
*
|
|
7
|
+
* It deliberately mirrors `session.storage`'s shape — `set` / `get` / `delete` /
|
|
8
|
+
* `keys` / `has` / `clear` — so it's instantly familiar, plus the things files
|
|
9
|
+
* (and not strings) need:
|
|
10
|
+
* - `setFromUrl(key, url)` — the host downloads a URL straight to disk
|
|
11
|
+
* (like the web Cache API's `cache.add`, iOS `URLSession` download task, or
|
|
12
|
+
* Android `DownloadManager`). Bytes never cross the bridge.
|
|
13
|
+
* - `importFile()` — opens the OS file picker and stores the chosen file.
|
|
14
|
+
* Bytes never cross the bridge.
|
|
15
|
+
* - `share(key)` — hands the file to the OS share sheet.
|
|
16
|
+
* - `createWriteStream` / `createReadStream` — for streaming huge payloads
|
|
17
|
+
* (named like Node's `fs.createWriteStream`).
|
|
18
|
+
*
|
|
19
|
+
* BACKGROUND-ONLY. Binary doesn't belong in the WebView. A blob's `uri` is a
|
|
20
|
+
* `file://` path in the app's private storage — fine for `session.speaker.play`,
|
|
21
|
+
* `blob.share`, or another host capability, but a WebView generally can't load
|
|
22
|
+
* it directly (route rendering through a host viewer for now).
|
|
23
|
+
*
|
|
24
|
+
* Transfer model: the bridge moves JSON strings through a per-miniapp JS engine
|
|
25
|
+
* (JSC/QuickJS) with a watchdog, so in-JS writes/reads are CHUNKED (≤ ~1 MB raw
|
|
26
|
+
* per call). Prefer `setFromUrl` / `importFile` when you can — they keep the
|
|
27
|
+
* bytes entirely host-side.
|
|
28
|
+
*/
|
|
29
|
+
import { MiniappSession } from "../session";
|
|
30
|
+
/** Metadata for one stored blob. `uri` is a `file://` path. */
|
|
31
|
+
export interface BlobMeta {
|
|
32
|
+
/** The key it's stored under (caller-chosen). */
|
|
33
|
+
key: string;
|
|
34
|
+
/** Optional display/file name (e.g. the original filename for an import). */
|
|
35
|
+
name?: string;
|
|
36
|
+
/** MIME type, e.g. "application/pdf". */
|
|
37
|
+
mimeType: string;
|
|
38
|
+
/** Size on disk in bytes. */
|
|
39
|
+
bytes: number;
|
|
40
|
+
/** Epoch ms first written. */
|
|
41
|
+
createdAt: number;
|
|
42
|
+
/** Epoch ms last written. */
|
|
43
|
+
updatedAt: number;
|
|
44
|
+
/** Content md5 (lowercase hex), computed host-side (skipped for very large blobs). */
|
|
45
|
+
md5?: string;
|
|
46
|
+
/** `file://` URI. Feed to `session.speaker.play`, `blob.share`, etc. */
|
|
47
|
+
uri: string;
|
|
48
|
+
/** App-defined metadata persisted with the blob. */
|
|
49
|
+
meta?: Record<string, string | number | boolean>;
|
|
50
|
+
}
|
|
51
|
+
export interface BlobSetOptions {
|
|
52
|
+
/** Default "application/octet-stream". */
|
|
53
|
+
mimeType?: string;
|
|
54
|
+
name?: string;
|
|
55
|
+
meta?: Record<string, string | number | boolean>;
|
|
56
|
+
}
|
|
57
|
+
export interface BlobSetFromUrlOptions extends BlobSetOptions {
|
|
58
|
+
/** Request headers (e.g. an Authorization token) for the download. */
|
|
59
|
+
headers?: Record<string, string>;
|
|
60
|
+
}
|
|
61
|
+
export interface BlobImportOptions {
|
|
62
|
+
/** Key to store under. Default: a generated key. */
|
|
63
|
+
key?: string;
|
|
64
|
+
/** Restrict the picker to a MIME type, e.g. "application/pdf". */
|
|
65
|
+
mimeType?: string;
|
|
66
|
+
meta?: Record<string, string | number | boolean>;
|
|
67
|
+
}
|
|
68
|
+
/** Raw bytes per chunked write. ~1 MB raw → ~1.34 MB base64, under the watchdog. */
|
|
69
|
+
export declare const BLOB_WRITE_CHUNK_BYTES: number;
|
|
70
|
+
/** Max bytes `bytes()` will buffer before throwing — read large blobs as a stream. */
|
|
71
|
+
export declare const BLOB_READ_ALL_MAX_BYTES: number;
|
|
72
|
+
/**
|
|
73
|
+
* Streaming writer (`fs.createWriteStream`-like). Call `write`/`writeBase64` as
|
|
74
|
+
* many times as you like (each is auto-split into bridge-safe chunks), then
|
|
75
|
+
* `close()` to publish, or `abort()` to discard the partial blob.
|
|
76
|
+
*/
|
|
77
|
+
export declare class BlobWriter {
|
|
78
|
+
private readonly session;
|
|
79
|
+
readonly key: string;
|
|
80
|
+
private settled;
|
|
81
|
+
constructor(session: MiniappSession, key: string);
|
|
82
|
+
/** Append raw bytes. Auto-chunked. */
|
|
83
|
+
write(chunk: Uint8Array | ArrayBuffer): Promise<void>;
|
|
84
|
+
/** Append already-base64-encoded bytes (e.g. straight from `mic.onAudioChunk`). */
|
|
85
|
+
writeBase64(b64: string): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Overwrite bytes at a fixed offset within the not-yet-closed blob (a seek
|
|
88
|
+
* write). Must stay within already-written bytes; does not grow the blob.
|
|
89
|
+
* Advanced — used e.g. to patch a container header on finalize.
|
|
90
|
+
*/
|
|
91
|
+
writeAt(offset: number, chunk: Uint8Array | ArrayBuffer): Promise<void>;
|
|
92
|
+
/** Finalize and return the blob's metadata. Optional `meta` merges into the record. */
|
|
93
|
+
close(meta?: Record<string, string | number | boolean>): Promise<BlobMeta>;
|
|
94
|
+
/** Discard the partial blob. Idempotent. */
|
|
95
|
+
abort(): Promise<void>;
|
|
96
|
+
private assertOpen;
|
|
97
|
+
private send;
|
|
98
|
+
}
|
|
99
|
+
/** Streaming reader (`fs.createReadStream`-like). */
|
|
100
|
+
export declare class BlobReader {
|
|
101
|
+
private readonly session;
|
|
102
|
+
readonly handle: string;
|
|
103
|
+
readonly meta: BlobMeta;
|
|
104
|
+
private closed;
|
|
105
|
+
constructor(session: MiniappSession, handle: string, meta: BlobMeta);
|
|
106
|
+
/** Read up to `maxBytes` (default one chunk). `done` is true at end of file. */
|
|
107
|
+
read(maxBytes?: number): Promise<{
|
|
108
|
+
bytes: Uint8Array;
|
|
109
|
+
done: boolean;
|
|
110
|
+
}>;
|
|
111
|
+
close(): Promise<void>;
|
|
112
|
+
}
|
|
113
|
+
export declare class BlobModule {
|
|
114
|
+
private readonly session;
|
|
115
|
+
constructor(session: MiniappSession);
|
|
116
|
+
/** Store bytes under `key`. `data` may be a Uint8Array/ArrayBuffer or a base64 string. */
|
|
117
|
+
set(key: string, data: Uint8Array | ArrayBuffer | string, opts?: BlobSetOptions): Promise<BlobMeta>;
|
|
118
|
+
/**
|
|
119
|
+
* Download `url` straight into a blob under `key`, host-side. The bytes never
|
|
120
|
+
* cross the bridge (like the web Cache API's `cache.add`). `opts.headers` lets
|
|
121
|
+
* you pass auth. Resolves to the stored blob's metadata.
|
|
122
|
+
*/
|
|
123
|
+
setFromUrl(key: string, url: string, opts?: BlobSetFromUrlOptions): Promise<BlobMeta>;
|
|
124
|
+
/**
|
|
125
|
+
* Open the OS file picker and store the chosen file as a blob, host-side.
|
|
126
|
+
* Resolves to the blob's metadata, or `null` if the user cancelled.
|
|
127
|
+
*/
|
|
128
|
+
importFile(opts?: BlobImportOptions): Promise<BlobMeta | null>;
|
|
129
|
+
/** Open a streaming writer for `key` (for large/streamed payloads). */
|
|
130
|
+
createWriteStream(key: string, opts?: BlobSetOptions): Promise<BlobWriter>;
|
|
131
|
+
/** Metadata (incl. the `file://` uri) for `key`, or null if absent. */
|
|
132
|
+
get(key: string): Promise<BlobMeta | null>;
|
|
133
|
+
/** Alias of `get` — the file-stat verb. */
|
|
134
|
+
stat(key: string): Promise<BlobMeta | null>;
|
|
135
|
+
/** True iff a blob is stored under `key`. */
|
|
136
|
+
has(key: string): Promise<boolean>;
|
|
137
|
+
/** Every key this miniapp has stored, newest first. */
|
|
138
|
+
keys(): Promise<string[]>;
|
|
139
|
+
/** Every blob this miniapp owns, newest first. */
|
|
140
|
+
list(): Promise<BlobMeta[]>;
|
|
141
|
+
/** Open a streaming reader. Prefer `get(key).uri` when you just need to play/share it. */
|
|
142
|
+
createReadStream(key: string): Promise<BlobReader>;
|
|
143
|
+
/** Read a whole blob into memory as bytes, or null if absent. Throws past the cap — stream big ones. */
|
|
144
|
+
bytes(key: string): Promise<Uint8Array | null>;
|
|
145
|
+
/** Per-app usage + the quota ceiling, in bytes. */
|
|
146
|
+
usage(): Promise<{
|
|
147
|
+
bytes: number;
|
|
148
|
+
count: number;
|
|
149
|
+
quotaBytes: number;
|
|
150
|
+
}>;
|
|
151
|
+
/** Delete the blob under `key`. No-op if absent. */
|
|
152
|
+
delete(key: string): Promise<void>;
|
|
153
|
+
/** Delete every blob this miniapp owns. */
|
|
154
|
+
clear(): Promise<void>;
|
|
155
|
+
/** Share the blob via the OS share sheet (host shares from disk — no bytes cross the bridge). */
|
|
156
|
+
share(key: string): Promise<{
|
|
157
|
+
success: boolean;
|
|
158
|
+
cancelled?: boolean;
|
|
159
|
+
}>;
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=blob.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blob.d.ts","sourceRoot":"","sources":["../../src/modules/blob.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAA;AAGzC,+DAA+D;AAC/D,MAAM,WAAW,QAAQ;IACvB,iDAAiD;IACjD,GAAG,EAAE,MAAM,CAAA;IACX,6EAA6E;IAC7E,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAA;IAChB,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,8BAA8B;IAC9B,SAAS,EAAE,MAAM,CAAA;IACjB,6BAA6B;IAC7B,SAAS,EAAE,MAAM,CAAA;IACjB,sFAAsF;IACtF,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,wEAAwE;IACxE,GAAG,EAAE,MAAM,CAAA;IACX,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAA;CACjD;AAED,MAAM,WAAW,cAAc;IAC7B,0CAA0C;IAC1C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G,IAAI,CAAC;IAI1C,2CAA2C;IAC3C,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAI3C,6CAA6C;IACvC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIxC,uDAAuD;IACjD,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAI/B,kDAAkD;IAC5C,IAAI,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IAKjC,0FAA0F;IACpF,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAQxD,wGAAwG;IAClG,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAmCpD,mDAAmD;IACnD,KAAK,IAAI,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAC,CAAC;IAMpE,oDAAoD;IAC9C,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxC,2CAA2C;IACrC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,iGAAiG;IAC3F,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAC,CAAC;CAO3E"}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview BlobModule — phone-local persistent BINARY storage, keyed and
|
|
3
|
+
* scoped to (userId, packageName). The binary sibling of `session.storage`:
|
|
4
|
+
* where storage holds small strings, blob holds arbitrary bytes (PDFs, EPUBs,
|
|
5
|
+
* audio, video, model files, caches) as files on the phone.
|
|
6
|
+
*
|
|
7
|
+
* It deliberately mirrors `session.storage`'s shape — `set` / `get` / `delete` /
|
|
8
|
+
* `keys` / `has` / `clear` — so it's instantly familiar, plus the things files
|
|
9
|
+
* (and not strings) need:
|
|
10
|
+
* - `setFromUrl(key, url)` — the host downloads a URL straight to disk
|
|
11
|
+
* (like the web Cache API's `cache.add`, iOS `URLSession` download task, or
|
|
12
|
+
* Android `DownloadManager`). Bytes never cross the bridge.
|
|
13
|
+
* - `importFile()` — opens the OS file picker and stores the chosen file.
|
|
14
|
+
* Bytes never cross the bridge.
|
|
15
|
+
* - `share(key)` — hands the file to the OS share sheet.
|
|
16
|
+
* - `createWriteStream` / `createReadStream` — for streaming huge payloads
|
|
17
|
+
* (named like Node's `fs.createWriteStream`).
|
|
18
|
+
*
|
|
19
|
+
* BACKGROUND-ONLY. Binary doesn't belong in the WebView. A blob's `uri` is a
|
|
20
|
+
* `file://` path in the app's private storage — fine for `session.speaker.play`,
|
|
21
|
+
* `blob.share`, or another host capability, but a WebView generally can't load
|
|
22
|
+
* it directly (route rendering through a host viewer for now).
|
|
23
|
+
*
|
|
24
|
+
* Transfer model: the bridge moves JSON strings through a per-miniapp JS engine
|
|
25
|
+
* (JSC/QuickJS) with a watchdog, so in-JS writes/reads are CHUNKED (≤ ~1 MB raw
|
|
26
|
+
* per call). Prefer `setFromUrl` / `importFile` when you can — they keep the
|
|
27
|
+
* bytes entirely host-side.
|
|
28
|
+
*/
|
|
29
|
+
import { MiniappRequestType } from "../protocol";
|
|
30
|
+
import { base64ToBytes, bytesToBase64, toUint8Array } from "./base64";
|
|
31
|
+
/** Raw bytes per chunked write. ~1 MB raw → ~1.34 MB base64, under the watchdog. */
|
|
32
|
+
export const BLOB_WRITE_CHUNK_BYTES = 1024 * 1024;
|
|
33
|
+
const BLOB_WRITE_CHUNK_B64 = Math.floor(BLOB_WRITE_CHUNK_BYTES / 3) * 4;
|
|
34
|
+
/** Max bytes `bytes()` will buffer before throwing — read large blobs as a stream. */
|
|
35
|
+
export const BLOB_READ_ALL_MAX_BYTES = 32 * 1024 * 1024;
|
|
36
|
+
/**
|
|
37
|
+
* Streaming writer (`fs.createWriteStream`-like). Call `write`/`writeBase64` as
|
|
38
|
+
* many times as you like (each is auto-split into bridge-safe chunks), then
|
|
39
|
+
* `close()` to publish, or `abort()` to discard the partial blob.
|
|
40
|
+
*/
|
|
41
|
+
export class BlobWriter {
|
|
42
|
+
constructor(session, key) {
|
|
43
|
+
this.session = session;
|
|
44
|
+
this.key = key;
|
|
45
|
+
this.settled = false;
|
|
46
|
+
}
|
|
47
|
+
/** Append raw bytes. Auto-chunked. */
|
|
48
|
+
async write(chunk) {
|
|
49
|
+
this.assertOpen();
|
|
50
|
+
const bytes = toUint8Array(chunk);
|
|
51
|
+
for (let off = 0; off < bytes.length; off += BLOB_WRITE_CHUNK_BYTES) {
|
|
52
|
+
await this.send(bytesToBase64(bytes.subarray(off, off + BLOB_WRITE_CHUNK_BYTES)));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** Append already-base64-encoded bytes (e.g. straight from `mic.onAudioChunk`). */
|
|
56
|
+
async writeBase64(b64) {
|
|
57
|
+
this.assertOpen();
|
|
58
|
+
// Slice on 4-char boundaries so each chunk is whole base64 groups.
|
|
59
|
+
for (let off = 0; off < b64.length; off += BLOB_WRITE_CHUNK_B64) {
|
|
60
|
+
await this.send(b64.slice(off, off + BLOB_WRITE_CHUNK_B64));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Overwrite bytes at a fixed offset within the not-yet-closed blob (a seek
|
|
65
|
+
* write). Must stay within already-written bytes; does not grow the blob.
|
|
66
|
+
* Advanced — used e.g. to patch a container header on finalize.
|
|
67
|
+
*/
|
|
68
|
+
async writeAt(offset, chunk) {
|
|
69
|
+
this.assertOpen();
|
|
70
|
+
await this.session.sendRequest({
|
|
71
|
+
type: MiniappRequestType.BLOB_WRITE,
|
|
72
|
+
key: this.key,
|
|
73
|
+
offset,
|
|
74
|
+
base64: bytesToBase64(toUint8Array(chunk)),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/** Finalize and return the blob's metadata. Optional `meta` merges into the record. */
|
|
78
|
+
async close(meta) {
|
|
79
|
+
this.assertOpen();
|
|
80
|
+
this.settled = true;
|
|
81
|
+
return this.session.sendRequest({ type: MiniappRequestType.BLOB_COMMIT, key: this.key, meta });
|
|
82
|
+
}
|
|
83
|
+
/** Discard the partial blob. Idempotent. */
|
|
84
|
+
async abort() {
|
|
85
|
+
if (this.settled)
|
|
86
|
+
return;
|
|
87
|
+
this.settled = true;
|
|
88
|
+
await this.session.sendRequest({ type: MiniappRequestType.BLOB_ABORT, key: this.key });
|
|
89
|
+
}
|
|
90
|
+
assertOpen() {
|
|
91
|
+
if (this.settled)
|
|
92
|
+
throw new Error("BlobWriter is already closed/aborted");
|
|
93
|
+
}
|
|
94
|
+
send(base64) {
|
|
95
|
+
return this.session.sendRequest({
|
|
96
|
+
type: MiniappRequestType.BLOB_WRITE,
|
|
97
|
+
key: this.key,
|
|
98
|
+
base64,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/** Streaming reader (`fs.createReadStream`-like). */
|
|
103
|
+
export class BlobReader {
|
|
104
|
+
constructor(session, handle, meta) {
|
|
105
|
+
this.session = session;
|
|
106
|
+
this.handle = handle;
|
|
107
|
+
this.meta = meta;
|
|
108
|
+
this.closed = false;
|
|
109
|
+
}
|
|
110
|
+
/** Read up to `maxBytes` (default one chunk). `done` is true at end of file. */
|
|
111
|
+
async read(maxBytes = BLOB_WRITE_CHUNK_BYTES) {
|
|
112
|
+
if (this.closed)
|
|
113
|
+
throw new Error("BlobReader is closed");
|
|
114
|
+
const res = await this.session.sendRequest({
|
|
115
|
+
type: MiniappRequestType.BLOB_READ,
|
|
116
|
+
handle: this.handle,
|
|
117
|
+
maxBytes,
|
|
118
|
+
});
|
|
119
|
+
return { bytes: base64ToBytes(res?.base64 ?? ""), done: !!res?.done };
|
|
120
|
+
}
|
|
121
|
+
async close() {
|
|
122
|
+
if (this.closed)
|
|
123
|
+
return;
|
|
124
|
+
this.closed = true;
|
|
125
|
+
await this.session.sendRequest({ type: MiniappRequestType.BLOB_CLOSE_READ, handle: this.handle });
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
export class BlobModule {
|
|
129
|
+
constructor(session) {
|
|
130
|
+
this.session = session;
|
|
131
|
+
}
|
|
132
|
+
// ── write ────────────────────────────────────────────────────────────────
|
|
133
|
+
/** Store bytes under `key`. `data` may be a Uint8Array/ArrayBuffer or a base64 string. */
|
|
134
|
+
async set(key, data, opts = {}) {
|
|
135
|
+
const writer = await this.createWriteStream(key, opts);
|
|
136
|
+
try {
|
|
137
|
+
if (typeof data === "string")
|
|
138
|
+
await writer.writeBase64(data);
|
|
139
|
+
else
|
|
140
|
+
await writer.write(data);
|
|
141
|
+
return await writer.close();
|
|
142
|
+
}
|
|
143
|
+
catch (err) {
|
|
144
|
+
await writer.abort().catch(() => { });
|
|
145
|
+
throw err;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Download `url` straight into a blob under `key`, host-side. The bytes never
|
|
150
|
+
* cross the bridge (like the web Cache API's `cache.add`). `opts.headers` lets
|
|
151
|
+
* you pass auth. Resolves to the stored blob's metadata.
|
|
152
|
+
*/
|
|
153
|
+
setFromUrl(key, url, opts = {}) {
|
|
154
|
+
return this.session.sendRequest({
|
|
155
|
+
type: MiniappRequestType.BLOB_SET_FROM_URL,
|
|
156
|
+
key,
|
|
157
|
+
url,
|
|
158
|
+
mimeType: opts.mimeType,
|
|
159
|
+
name: opts.name,
|
|
160
|
+
headers: opts.headers,
|
|
161
|
+
meta: opts.meta,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Open the OS file picker and store the chosen file as a blob, host-side.
|
|
166
|
+
* Resolves to the blob's metadata, or `null` if the user cancelled.
|
|
167
|
+
*/
|
|
168
|
+
importFile(opts = {}) {
|
|
169
|
+
return this.session.sendRequest({
|
|
170
|
+
type: MiniappRequestType.BLOB_IMPORT,
|
|
171
|
+
key: opts.key,
|
|
172
|
+
mimeType: opts.mimeType,
|
|
173
|
+
meta: opts.meta,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
/** Open a streaming writer for `key` (for large/streamed payloads). */
|
|
177
|
+
async createWriteStream(key, opts = {}) {
|
|
178
|
+
const res = await this.session.sendRequest({
|
|
179
|
+
type: MiniappRequestType.BLOB_CREATE,
|
|
180
|
+
key,
|
|
181
|
+
mimeType: opts.mimeType,
|
|
182
|
+
name: opts.name,
|
|
183
|
+
meta: opts.meta,
|
|
184
|
+
});
|
|
185
|
+
return new BlobWriter(this.session, res.key);
|
|
186
|
+
}
|
|
187
|
+
// ── read ─────────────────────────────────────────────────────────────────
|
|
188
|
+
/** Metadata (incl. the `file://` uri) for `key`, or null if absent. */
|
|
189
|
+
get(key) {
|
|
190
|
+
return this.session.sendRequest({ type: MiniappRequestType.BLOB_GET, key });
|
|
191
|
+
}
|
|
192
|
+
/** Alias of `get` — the file-stat verb. */
|
|
193
|
+
stat(key) {
|
|
194
|
+
return this.get(key);
|
|
195
|
+
}
|
|
196
|
+
/** True iff a blob is stored under `key`. */
|
|
197
|
+
async has(key) {
|
|
198
|
+
return (await this.get(key)) !== null;
|
|
199
|
+
}
|
|
200
|
+
/** Every key this miniapp has stored, newest first. */
|
|
201
|
+
async keys() {
|
|
202
|
+
return (await this.list()).map((m) => m.key);
|
|
203
|
+
}
|
|
204
|
+
/** Every blob this miniapp owns, newest first. */
|
|
205
|
+
async list() {
|
|
206
|
+
const res = await this.session.sendRequest({ type: MiniappRequestType.BLOB_LIST });
|
|
207
|
+
return res?.blobs ?? [];
|
|
208
|
+
}
|
|
209
|
+
/** Open a streaming reader. Prefer `get(key).uri` when you just need to play/share it. */
|
|
210
|
+
async createReadStream(key) {
|
|
211
|
+
const res = await this.session.sendRequest({
|
|
212
|
+
type: MiniappRequestType.BLOB_OPEN_READ,
|
|
213
|
+
key,
|
|
214
|
+
});
|
|
215
|
+
return new BlobReader(this.session, res.handle, res.meta);
|
|
216
|
+
}
|
|
217
|
+
/** Read a whole blob into memory as bytes, or null if absent. Throws past the cap — stream big ones. */
|
|
218
|
+
async bytes(key) {
|
|
219
|
+
let reader;
|
|
220
|
+
try {
|
|
221
|
+
reader = await this.createReadStream(key);
|
|
222
|
+
}
|
|
223
|
+
catch {
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
const parts = [];
|
|
227
|
+
let total = 0;
|
|
228
|
+
try {
|
|
229
|
+
for (;;) {
|
|
230
|
+
const { bytes, done } = await reader.read();
|
|
231
|
+
if (bytes.length) {
|
|
232
|
+
total += bytes.length;
|
|
233
|
+
if (total > BLOB_READ_ALL_MAX_BYTES) {
|
|
234
|
+
throw new Error(`Blob "${key}" exceeds the in-memory read cap — stream it with createReadStream()`);
|
|
235
|
+
}
|
|
236
|
+
parts.push(bytes);
|
|
237
|
+
}
|
|
238
|
+
if (done)
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
finally {
|
|
243
|
+
await reader.close().catch(() => { });
|
|
244
|
+
}
|
|
245
|
+
const out = new Uint8Array(total);
|
|
246
|
+
let at = 0;
|
|
247
|
+
for (const p of parts) {
|
|
248
|
+
out.set(p, at);
|
|
249
|
+
at += p.length;
|
|
250
|
+
}
|
|
251
|
+
return out;
|
|
252
|
+
}
|
|
253
|
+
// ── manage ───────────────────────────────────────────────────────────────
|
|
254
|
+
/** Per-app usage + the quota ceiling, in bytes. */
|
|
255
|
+
usage() {
|
|
256
|
+
return this.session.sendRequest({
|
|
257
|
+
type: MiniappRequestType.BLOB_USAGE,
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
/** Delete the blob under `key`. No-op if absent. */
|
|
261
|
+
async delete(key) {
|
|
262
|
+
await this.session.sendRequest({ type: MiniappRequestType.BLOB_DELETE, key });
|
|
263
|
+
}
|
|
264
|
+
/** Delete every blob this miniapp owns. */
|
|
265
|
+
async clear() {
|
|
266
|
+
await this.session.sendRequest({ type: MiniappRequestType.BLOB_CLEAR });
|
|
267
|
+
}
|
|
268
|
+
/** Share the blob via the OS share sheet (host shares from disk — no bytes cross the bridge). */
|
|
269
|
+
async share(key) {
|
|
270
|
+
const res = await this.session.sendRequest({
|
|
271
|
+
type: MiniappRequestType.BLOB_SHARE,
|
|
272
|
+
key,
|
|
273
|
+
});
|
|
274
|
+
return res ?? { success: false };
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
//# sourceMappingURL=blob.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blob.js","sourceRoot":"","sources":["../../src/modules/blob.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAC,kBAAkB,EAAC,MAAM,aAAa,CAAA;AAE9C,OAAO,EAAC,aAAa,EAAE,aAAa,EAAE,YAAY,EAAC,MAAM,UAAU,CAAA;AA4CnE,oFAAoF;AACpF,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,GAAG,IAAI,CAAA;AACjD,MAAM,oBAAoB,GAAG,IAAI,CAAC,KAAK,CAAC,sBAAsB,GAAG,CAAC,CAAC,GAAG,CAAC,CAAA;AACvE,sFAAsF;AACtF,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAA;AAEvD;;;;GAIG;AACH,MAAM,OAAO,UAAU;IAGrB,YACmB,OAAuB,EAC/B,GAAW;QADH,YAAO,GAAP,OAAO,CAAgB;QAC/B,QAAG,GAAH,GAAG,CAAQ;QAJd,YAAO,GAAG,KAAK,CAAA;IAKpB,CAAC;IAEJ,sCAAsC;IACtC,KAAK,CAAC,KAAK,CAAC,KAA+B;QACzC,IAAI,CAAC,UAAU,EAAE,CAAA;QACjB,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,CAAA;QACjC,KAAK,IA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nC,GAAG;SACJ,CAAC,CAAA;QACF,OAAO,GAAG,IAAI,EAAC,OAAO,EAAE,KAAK,EAAC,CAAA;IAChC,CAAC;CACF"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview CameraModule — glasses camera control and photo capture.
|
|
3
|
+
*/
|
|
4
|
+
import { MiniappSession } from "../session";
|
|
5
|
+
export type CameraRoiPosition = "center" | "bottom" | "top";
|
|
6
|
+
export type CameraFovPreset = "narrow" | "standard" | "wide";
|
|
7
|
+
export type CameraFovRequest = {
|
|
8
|
+
/** Horizontal FOV, degrees. */
|
|
9
|
+
fov: number;
|
|
10
|
+
/** Crop/region position: center, bottom, or top. Defaults to center. */
|
|
11
|
+
roiPosition?: CameraRoiPosition;
|
|
12
|
+
} | {
|
|
13
|
+
/** Named FOV preset. Presets use center ROI. */
|
|
14
|
+
preset: CameraFovPreset;
|
|
15
|
+
};
|
|
16
|
+
export type SetCameraFovOptions = CameraFovRequest;
|
|
17
|
+
export interface CameraFovResult {
|
|
18
|
+
requestId: string;
|
|
19
|
+
fov: number;
|
|
20
|
+
roiPosition: CameraRoiPosition;
|
|
21
|
+
timestamp: number;
|
|
22
|
+
}
|
|
23
|
+
export interface TakePhotoOptions {
|
|
24
|
+
size?: "low" | "medium" | "high" | "max";
|
|
25
|
+
/** Capture at maximum source quality and optimize BLE delivery for readable text. */
|
|
26
|
+
mode?: "photo" | "text";
|
|
27
|
+
compress?: "none" | "low" | "medium" | "high";
|
|
28
|
+
sound?: boolean;
|
|
29
|
+
saveToGallery?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Manual shutter / exposure time in nanoseconds. Omit (or pass undefined)
|
|
32
|
+
* to let the glasses auto-expose. Honored only on cameras that support
|
|
33
|
+
* manual exposure; ignored otherwise.
|
|
34
|
+
*/
|
|
35
|
+
exposureTimeNs?: number;
|
|
36
|
+
}
|
|
37
|
+
export interface PhotoTaken {
|
|
38
|
+
/** Request id that correlates ASG status, upload, and phone/cloud logs. */
|
|
39
|
+
requestId: string;
|
|
40
|
+
photoUrl: string;
|
|
41
|
+
mimeType: string;
|
|
42
|
+
size: number;
|
|
43
|
+
}
|
|
44
|
+
export interface WarmUpCameraOptions {
|
|
45
|
+
size?: "low" | "medium" | "high" | "max";
|
|
46
|
+
exposureTimeNs?: number;
|
|
47
|
+
durationMs?: number;
|
|
48
|
+
}
|
|
49
|
+
export interface StartVideoRecordingOptions {
|
|
50
|
+
/** Video width in pixels. Omit to use the device's saved button-video default. */
|
|
51
|
+
width?: number;
|
|
52
|
+
/** Video height in pixels. Omit to use the device's saved button-video default. */
|
|
53
|
+
height?: number;
|
|
54
|
+
/**
|
|
55
|
+
* Frames per second. Lower frame rates keep the glasses cooler and produce
|
|
56
|
+
* smaller files — useful for long recordings where smooth motion isn't needed.
|
|
57
|
+
* Omit to use the device default.
|
|
58
|
+
*/
|
|
59
|
+
fps?: number;
|
|
60
|
+
/** Play start/stop capture sounds. Defaults to true. */
|
|
61
|
+
sound?: boolean;
|
|
62
|
+
/** Keep the recording on the glasses after it finishes. Defaults to false. */
|
|
63
|
+
save?: boolean;
|
|
64
|
+
}
|
|
65
|
+
export interface VideoRecordingStarted {
|
|
66
|
+
/** Identifier for this recording session; pass to {@link stopVideoRecording}. */
|
|
67
|
+
recordingId: string;
|
|
68
|
+
}
|
|
69
|
+
export interface StopVideoRecordingOptions {
|
|
70
|
+
/**
|
|
71
|
+
* Upload the finished recording to this URL with a multipart POST (the file is
|
|
72
|
+
* the `video` part). The glasses upload it directly. Omit to keep the recording
|
|
73
|
+
* on the glasses instead.
|
|
74
|
+
*/
|
|
75
|
+
uploadUrl?: string;
|
|
76
|
+
/** Bearer token sent as the `Authorization` header on the upload, if your endpoint needs one. */
|
|
77
|
+
uploadAuthToken?: string;
|
|
78
|
+
}
|
|
79
|
+
export declare class CameraModule {
|
|
80
|
+
private readonly session;
|
|
81
|
+
constructor(session: MiniappSession);
|
|
82
|
+
/** True iff `CAMERA` is declared in the miniapp's manifest. */
|
|
83
|
+
get hasPermission(): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Apply camera FOV/ROI settings on the glasses.
|
|
86
|
+
*
|
|
87
|
+
* Resolves after the ASG client reports that the setting was applied to camera
|
|
88
|
+
* hardware after the restart cooldown. Requires CAMERA permission declared in miniapp.json.
|
|
89
|
+
*/
|
|
90
|
+
setFov(request: CameraFovRequest): Promise<CameraFovResult>;
|
|
91
|
+
/**
|
|
92
|
+
* Take a photo via the glasses camera. Returns a URL to the captured image.
|
|
93
|
+
* Requires CAMERA permission declared in miniapp.json.
|
|
94
|
+
*
|
|
95
|
+
* The photo is uploaded to cloud storage; the returned URL is a short-TTL
|
|
96
|
+
* (~30 minute) signed download URL. If the glasses don't have a camera,
|
|
97
|
+
* the phone-side handler rejects with an error. Check
|
|
98
|
+
* `session.capabilities.hasCamera` before calling.
|
|
99
|
+
*/
|
|
100
|
+
takePhoto(options?: TakePhotoOptions): Promise<PhotoTaken>;
|
|
101
|
+
/**
|
|
102
|
+
* Pre-warm the glasses camera so the next takePhoto() is near-instant.
|
|
103
|
+
* The camera stays warm for ~durationMs (default 15s); call warmUp() again to
|
|
104
|
+
* extend it. Warm with the same `size` you'll capture with — a mismatched size
|
|
105
|
+
* forces the camera to reconfigure and loses the speedup. Requires CAMERA
|
|
106
|
+
* permission in miniapp.json. Resolves once the camera reports ready.
|
|
107
|
+
*
|
|
108
|
+
* Warm-ups are serialized: only one runs at a time and none may start while a
|
|
109
|
+
* photo is being captured. If the camera is busy (a capture is in flight, or
|
|
110
|
+
* another warm-up is still opening) this rejects with `camera_busy` — retry
|
|
111
|
+
* shortly, or just call takePhoto() (it works regardless, only slower). The
|
|
112
|
+
* normal warmUp() → takePhoto() sequence never hits this.
|
|
113
|
+
*/
|
|
114
|
+
warmUp(options?: WarmUpCameraOptions): Promise<void>;
|
|
115
|
+
/**
|
|
116
|
+
* Start recording video on the glasses camera. Returns a `recordingId` to pass
|
|
117
|
+
* to {@link stopVideoRecording} after the glasses report that recording
|
|
118
|
+
* started. Requires CAMERA permission declared in miniapp.json. Check
|
|
119
|
+
* `session.capabilities.hasCamera` before calling.
|
|
120
|
+
*
|
|
121
|
+
* Resolution and frame rate are optional — omit them to use the device's saved
|
|
122
|
+
* button-video settings. Lowering `fps` (e.g. to 5) keeps the glasses cooler
|
|
123
|
+
* during long recordings.
|
|
124
|
+
*/
|
|
125
|
+
startVideoRecording(options?: StartVideoRecordingOptions): Promise<VideoRecordingStarted>;
|
|
126
|
+
/**
|
|
127
|
+
* Stop an in-progress video recording started with {@link startVideoRecording}.
|
|
128
|
+
*
|
|
129
|
+
* By default the recording stays on the glasses. Pass `uploadUrl` to have the
|
|
130
|
+
* glasses upload the finished clip to your own endpoint.
|
|
131
|
+
*
|
|
132
|
+
* @param recordingId The id returned from `startVideoRecording`.
|
|
133
|
+
* @param options Optional upload destination for the finished recording.
|
|
134
|
+
*/
|
|
135
|
+
stopVideoRecording(recordingId: string, options?: StopVideoRecordingOptions): Promise<void>;
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=camera.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"camera.d.ts","sourceRoot":"","sources":["../../src/modules/camera.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAA;AAEzC,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,QAAQ,GAAG,KAAK,CAAA;AAC3D,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,CAAA;AAE5D,MAAM,MAAM,gBAAgB,GACxB;IACE,+BAA+B;IAC/B,GAAG,EAAE,MAAM,CAAA;IACX,wEAAwE;IACxE,WAAW,CAAC,EAAE,iBAAiB,CAAA;CAChC,GACD;IACE,gDAAgD;IAChD,MAAM,EAAE,eAAe,CAAA;CACxB,CAAA;AAEL,MAAM,MAAM,mBAAmB,GAAG,gBAAgB,CAAA;AA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