@glassly/miniapp 0.3.0-dev.1

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.
Files changed (312) hide show
  1. package/README.md +275 -0
  2. package/dist/background/index.d.ts +64 -0
  3. package/dist/background/index.d.ts.map +1 -0
  4. package/dist/background/index.js +26 -0
  5. package/dist/background/index.js.map +1 -0
  6. package/dist/background/register.d.ts +39 -0
  7. package/dist/background/register.d.ts.map +1 -0
  8. package/dist/background/register.js +72 -0
  9. package/dist/background/register.js.map +1 -0
  10. package/dist/dev-reload.d.ts +21 -0
  11. package/dist/dev-reload.d.ts.map +1 -0
  12. package/dist/dev-reload.js +60 -0
  13. package/dist/dev-reload.js.map +1 -0
  14. package/dist/envelope.d.ts +23 -0
  15. package/dist/envelope.d.ts.map +1 -0
  16. package/dist/envelope.js +47 -0
  17. package/dist/envelope.js.map +1 -0
  18. package/dist/globals.d.ts +54 -0
  19. package/dist/globals.d.ts.map +1 -0
  20. package/dist/globals.js +12 -0
  21. package/dist/globals.js.map +1 -0
  22. package/dist/hardware.d.ts +38 -0
  23. package/dist/hardware.d.ts.map +1 -0
  24. package/dist/hardware.js +31 -0
  25. package/dist/hardware.js.map +1 -0
  26. package/dist/index.d.ts +65 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +34 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/modules/actions.d.ts +81 -0
  31. package/dist/modules/actions.d.ts.map +1 -0
  32. package/dist/modules/actions.js +137 -0
  33. package/dist/modules/actions.js.map +1 -0
  34. package/dist/modules/ai.d.ts +211 -0
  35. package/dist/modules/ai.d.ts.map +1 -0
  36. package/dist/modules/ai.js +117 -0
  37. package/dist/modules/ai.js.map +1 -0
  38. package/dist/modules/auth.d.ts +25 -0
  39. package/dist/modules/auth.d.ts.map +1 -0
  40. package/dist/modules/auth.js +52 -0
  41. package/dist/modules/auth.js.map +1 -0
  42. package/dist/modules/base64.d.ts +16 -0
  43. package/dist/modules/base64.d.ts.map +1 -0
  44. package/dist/modules/base64.js +92 -0
  45. package/dist/modules/base64.js.map +1 -0
  46. package/dist/modules/blob.d.ts +161 -0
  47. package/dist/modules/blob.d.ts.map +1 -0
  48. package/dist/modules/blob.js +277 -0
  49. package/dist/modules/blob.js.map +1 -0
  50. package/dist/modules/camera.d.ts +183 -0
  51. package/dist/modules/camera.d.ts.map +1 -0
  52. package/dist/modules/camera.js +119 -0
  53. package/dist/modules/camera.js.map +1 -0
  54. package/dist/modules/cloud.d.ts +34 -0
  55. package/dist/modules/cloud.d.ts.map +1 -0
  56. package/dist/modules/cloud.js +70 -0
  57. package/dist/modules/cloud.js.map +1 -0
  58. package/dist/modules/dashboard.d.ts +24 -0
  59. package/dist/modules/dashboard.d.ts.map +1 -0
  60. package/dist/modules/dashboard.js +39 -0
  61. package/dist/modules/dashboard.js.map +1 -0
  62. package/dist/modules/display.d.ts +167 -0
  63. package/dist/modules/display.d.ts.map +1 -0
  64. package/dist/modules/display.js +83 -0
  65. package/dist/modules/display.js.map +1 -0
  66. package/dist/modules/events.d.ts +178 -0
  67. package/dist/modules/events.d.ts.map +1 -0
  68. package/dist/modules/events.js +168 -0
  69. package/dist/modules/events.js.map +1 -0
  70. package/dist/modules/glasses.d.ts +36 -0
  71. package/dist/modules/glasses.d.ts.map +1 -0
  72. package/dist/modules/glasses.js +52 -0
  73. package/dist/modules/glasses.js.map +1 -0
  74. package/dist/modules/heading.d.ts +16 -0
  75. package/dist/modules/heading.d.ts.map +1 -0
  76. package/dist/modules/heading.js +20 -0
  77. package/dist/modules/heading.js.map +1 -0
  78. package/dist/modules/imu.d.ts +31 -0
  79. package/dist/modules/imu.d.ts.map +1 -0
  80. package/dist/modules/imu.js +40 -0
  81. package/dist/modules/imu.js.map +1 -0
  82. package/dist/modules/input.d.ts +34 -0
  83. package/dist/modules/input.d.ts.map +1 -0
  84. package/dist/modules/input.js +50 -0
  85. package/dist/modules/input.js.map +1 -0
  86. package/dist/modules/keys.d.ts +30 -0
  87. package/dist/modules/keys.d.ts.map +1 -0
  88. package/dist/modules/keys.js +37 -0
  89. package/dist/modules/keys.js.map +1 -0
  90. package/dist/modules/languages.d.ts +42 -0
  91. package/dist/modules/languages.d.ts.map +1 -0
  92. package/dist/modules/languages.js +57 -0
  93. package/dist/modules/languages.js.map +1 -0
  94. package/dist/modules/led.d.ts +35 -0
  95. package/dist/modules/led.d.ts.map +1 -0
  96. package/dist/modules/led.js +39 -0
  97. package/dist/modules/led.js.map +1 -0
  98. package/dist/modules/location.d.ts +27 -0
  99. package/dist/modules/location.d.ts.map +1 -0
  100. package/dist/modules/location.js +35 -0
  101. package/dist/modules/location.js.map +1 -0
  102. package/dist/modules/memory.d.ts +126 -0
  103. package/dist/modules/memory.d.ts.map +1 -0
  104. package/dist/modules/memory.js +141 -0
  105. package/dist/modules/memory.js.map +1 -0
  106. package/dist/modules/mic.d.ts +61 -0
  107. package/dist/modules/mic.d.ts.map +1 -0
  108. package/dist/modules/mic.js +94 -0
  109. package/dist/modules/mic.js.map +1 -0
  110. package/dist/modules/miniapps.d.ts +82 -0
  111. package/dist/modules/miniapps.d.ts.map +1 -0
  112. package/dist/modules/miniapps.js +58 -0
  113. package/dist/modules/miniapps.js.map +1 -0
  114. package/dist/modules/navigation.d.ts +332 -0
  115. package/dist/modules/navigation.d.ts.map +1 -0
  116. package/dist/modules/navigation.js +387 -0
  117. package/dist/modules/navigation.js.map +1 -0
  118. package/dist/modules/permissions.d.ts +58 -0
  119. package/dist/modules/permissions.d.ts.map +1 -0
  120. package/dist/modules/permissions.js +66 -0
  121. package/dist/modules/permissions.js.map +1 -0
  122. package/dist/modules/phone.d.ts +95 -0
  123. package/dist/modules/phone.d.ts.map +1 -0
  124. package/dist/modules/phone.js +110 -0
  125. package/dist/modules/phone.js.map +1 -0
  126. package/dist/modules/pivots/engine.d.ts +169 -0
  127. package/dist/modules/pivots/engine.d.ts.map +1 -0
  128. package/dist/modules/pivots/engine.js +778 -0
  129. package/dist/modules/pivots/engine.js.map +1 -0
  130. package/dist/modules/pivots/geometry.d.ts +84 -0
  131. package/dist/modules/pivots/geometry.d.ts.map +1 -0
  132. package/dist/modules/pivots/geometry.js +371 -0
  133. package/dist/modules/pivots/geometry.js.map +1 -0
  134. package/dist/modules/pivots/instructions.d.ts +139 -0
  135. package/dist/modules/pivots/instructions.d.ts.map +1 -0
  136. package/dist/modules/pivots/instructions.js +281 -0
  137. package/dist/modules/pivots/instructions.js.map +1 -0
  138. package/dist/modules/speaker.d.ts +175 -0
  139. package/dist/modules/speaker.d.ts.map +1 -0
  140. package/dist/modules/speaker.js +249 -0
  141. package/dist/modules/speaker.js.map +1 -0
  142. package/dist/modules/speakers.d.ts +29 -0
  143. package/dist/modules/speakers.d.ts.map +1 -0
  144. package/dist/modules/speakers.js +38 -0
  145. package/dist/modules/speakers.js.map +1 -0
  146. package/dist/modules/storage.d.ts +50 -0
  147. package/dist/modules/storage.d.ts.map +1 -0
  148. package/dist/modules/storage.js +99 -0
  149. package/dist/modules/storage.js.map +1 -0
  150. package/dist/modules/stream.d.ts +133 -0
  151. package/dist/modules/stream.d.ts.map +1 -0
  152. package/dist/modules/stream.js +53 -0
  153. package/dist/modules/stream.js.map +1 -0
  154. package/dist/modules/system.d.ts +71 -0
  155. package/dist/modules/system.d.ts.map +1 -0
  156. package/dist/modules/system.js +65 -0
  157. package/dist/modules/system.js.map +1 -0
  158. package/dist/modules/transcription.d.ts +99 -0
  159. package/dist/modules/transcription.d.ts.map +1 -0
  160. package/dist/modules/transcription.js +126 -0
  161. package/dist/modules/transcription.js.map +1 -0
  162. package/dist/modules/translation.d.ts +65 -0
  163. package/dist/modules/translation.d.ts.map +1 -0
  164. package/dist/modules/translation.js +121 -0
  165. package/dist/modules/translation.js.map +1 -0
  166. package/dist/modules/ui.d.ts +186 -0
  167. package/dist/modules/ui.d.ts.map +1 -0
  168. package/dist/modules/ui.js +289 -0
  169. package/dist/modules/ui.js.map +1 -0
  170. package/dist/protocol.d.ts +384 -0
  171. package/dist/protocol.d.ts.map +1 -0
  172. package/dist/protocol.js +413 -0
  173. package/dist/protocol.js.map +1 -0
  174. package/dist/react/MiniappHeader.d.ts +44 -0
  175. package/dist/react/MiniappHeader.d.ts.map +1 -0
  176. package/dist/react/MiniappHeader.js +32 -0
  177. package/dist/react/MiniappHeader.js.map +1 -0
  178. package/dist/react/MiniappProvider.d.ts +33 -0
  179. package/dist/react/MiniappProvider.d.ts.map +1 -0
  180. package/dist/react/MiniappProvider.js +15 -0
  181. package/dist/react/MiniappProvider.js.map +1 -0
  182. package/dist/react/capsuleHeaderLayout.d.ts +3 -0
  183. package/dist/react/capsuleHeaderLayout.d.ts.map +1 -0
  184. package/dist/react/capsuleHeaderLayout.js +5 -0
  185. package/dist/react/capsuleHeaderLayout.js.map +1 -0
  186. package/dist/react/index.d.ts +13 -0
  187. package/dist/react/index.d.ts.map +1 -0
  188. package/dist/react/index.js +9 -0
  189. package/dist/react/index.js.map +1 -0
  190. package/dist/react/useCapabilities.d.ts +26 -0
  191. package/dist/react/useCapabilities.d.ts.map +1 -0
  192. package/dist/react/useCapabilities.js +27 -0
  193. package/dist/react/useCapabilities.js.map +1 -0
  194. package/dist/react/useCapsuleHeaderStyle.d.ts +27 -0
  195. package/dist/react/useCapsuleHeaderStyle.d.ts.map +1 -0
  196. package/dist/react/useCapsuleHeaderStyle.js +39 -0
  197. package/dist/react/useCapsuleHeaderStyle.js.map +1 -0
  198. package/dist/react/useColorScheme.d.ts +18 -0
  199. package/dist/react/useColorScheme.d.ts.map +1 -0
  200. package/dist/react/useColorScheme.js +24 -0
  201. package/dist/react/useColorScheme.js.map +1 -0
  202. package/dist/react/useConnected.d.ts +17 -0
  203. package/dist/react/useConnected.d.ts.map +1 -0
  204. package/dist/react/useConnected.js +39 -0
  205. package/dist/react/useConnected.js.map +1 -0
  206. package/dist/react/useRpc.d.ts +29 -0
  207. package/dist/react/useRpc.d.ts.map +1 -0
  208. package/dist/react/useRpc.js +82 -0
  209. package/dist/react/useRpc.js.map +1 -0
  210. package/dist/react/useSafeArea.d.ts +21 -0
  211. package/dist/react/useSafeArea.d.ts.map +1 -0
  212. package/dist/react/useSafeArea.js +22 -0
  213. package/dist/react/useSafeArea.js.map +1 -0
  214. package/dist/session.d.ts +355 -0
  215. package/dist/session.d.ts.map +1 -0
  216. package/dist/session.js +688 -0
  217. package/dist/session.js.map +1 -0
  218. package/dist/sub-path-types.test-d.d.ts +40 -0
  219. package/dist/sub-path-types.test-d.d.ts.map +1 -0
  220. package/dist/sub-path-types.test-d.js +37 -0
  221. package/dist/sub-path-types.test-d.js.map +1 -0
  222. package/dist/transport/auto.d.ts +35 -0
  223. package/dist/transport/auto.d.ts.map +1 -0
  224. package/dist/transport/auto.js +124 -0
  225. package/dist/transport/auto.js.map +1 -0
  226. package/dist/transport/dispatch.d.ts +43 -0
  227. package/dist/transport/dispatch.d.ts.map +1 -0
  228. package/dist/transport/dispatch.js +91 -0
  229. package/dist/transport/dispatch.js.map +1 -0
  230. package/dist/transport/local-socket.d.ts +28 -0
  231. package/dist/transport/local-socket.d.ts.map +1 -0
  232. package/dist/transport/local-socket.js +80 -0
  233. package/dist/transport/local-socket.js.map +1 -0
  234. package/dist/transport/mock.d.ts +54 -0
  235. package/dist/transport/mock.d.ts.map +1 -0
  236. package/dist/transport/mock.js +210 -0
  237. package/dist/transport/mock.js.map +1 -0
  238. package/dist/transport/postmessage.d.ts +36 -0
  239. package/dist/transport/postmessage.d.ts.map +1 -0
  240. package/dist/transport/postmessage.js +78 -0
  241. package/dist/transport/postmessage.js.map +1 -0
  242. package/dist/transport/types.d.ts +25 -0
  243. package/dist/transport/types.d.ts.map +1 -0
  244. package/dist/transport/types.js +11 -0
  245. package/dist/transport/types.js.map +1 -0
  246. package/dist/ui/index.d.ts +107 -0
  247. package/dist/ui/index.d.ts.map +1 -0
  248. package/dist/ui/index.js +32 -0
  249. package/dist/ui/index.js.map +1 -0
  250. package/package.json +84 -0
  251. package/src/background/index.ts +177 -0
  252. package/src/background/register.ts +89 -0
  253. package/src/dev-reload.ts +59 -0
  254. package/src/envelope.ts +54 -0
  255. package/src/globals.ts +62 -0
  256. package/src/hardware.ts +40 -0
  257. package/src/index.ts +216 -0
  258. package/src/modules/actions.ts +189 -0
  259. package/src/modules/ai.ts +281 -0
  260. package/src/modules/auth.ts +68 -0
  261. package/src/modules/base64.ts +87 -0
  262. package/src/modules/blob.ts +341 -0
  263. package/src/modules/camera.ts +258 -0
  264. package/src/modules/cloud.ts +94 -0
  265. package/src/modules/dashboard.ts +51 -0
  266. package/src/modules/display.ts +207 -0
  267. package/src/modules/events.ts +318 -0
  268. package/src/modules/glasses.ts +58 -0
  269. package/src/modules/heading.ts +23 -0
  270. package/src/modules/imu.ts +44 -0
  271. package/src/modules/input.ts +66 -0
  272. package/src/modules/keys.ts +46 -0
  273. package/src/modules/languages.ts +72 -0
  274. package/src/modules/led.ts +61 -0
  275. package/src/modules/location.ts +39 -0
  276. package/src/modules/memory.ts +224 -0
  277. package/src/modules/mic.ts +103 -0
  278. package/src/modules/miniapps.ts +103 -0
  279. package/src/modules/navigation.ts +674 -0
  280. package/src/modules/permissions.ts +83 -0
  281. package/src/modules/phone.ts +155 -0
  282. package/src/modules/pivots/engine.ts +863 -0
  283. package/src/modules/pivots/geometry.ts +409 -0
  284. package/src/modules/pivots/instructions.ts +341 -0
  285. package/src/modules/speaker.ts +347 -0
  286. package/src/modules/speakers.ts +40 -0
  287. package/src/modules/storage.ts +109 -0
  288. package/src/modules/stream.ts +168 -0
  289. package/src/modules/system.ts +113 -0
  290. package/src/modules/transcription.ts +180 -0
  291. package/src/modules/translation.ts +156 -0
  292. package/src/modules/ui.ts +481 -0
  293. package/src/protocol.ts +475 -0
  294. package/src/react/MiniappHeader.tsx +114 -0
  295. package/src/react/MiniappProvider.tsx +50 -0
  296. package/src/react/capsuleHeaderLayout.ts +11 -0
  297. package/src/react/index.ts +12 -0
  298. package/src/react/useCapabilities.ts +29 -0
  299. package/src/react/useCapsuleHeaderStyle.ts +55 -0
  300. package/src/react/useColorScheme.ts +26 -0
  301. package/src/react/useConnected.ts +47 -0
  302. package/src/react/useRpc.ts +103 -0
  303. package/src/react/useSafeArea.ts +36 -0
  304. package/src/session.ts +969 -0
  305. package/src/sub-path-types.test-d.ts +60 -0
  306. package/src/transport/auto.ts +143 -0
  307. package/src/transport/dispatch.ts +106 -0
  308. package/src/transport/local-socket.ts +91 -0
  309. package/src/transport/mock.ts +255 -0
  310. package/src/transport/postmessage.ts +95 -0
  311. package/src/transport/types.ts +26 -0
  312. package/src/ui/index.ts +129 -0
@@ -0,0 +1,53 @@
1
+ /**
2
+ * @fileoverview StreamModule -- video streaming from glasses.
3
+ *
4
+ * Wires to cloud streaming extensions via the __phone__ subscriber path.
5
+ *
6
+ * One entry point: `startStream`. By default it provisions a Glassly-hosted
7
+ * stream and returns playback URLs (managed). Pass `direct` to publish straight
8
+ * to your own ingest URL with no relay.
9
+ */
10
+ import { MiniappRequestType } from "../protocol";
11
+ export class StreamModule {
12
+ constructor(session) {
13
+ this.session = session;
14
+ }
15
+ /**
16
+ * Start a live video stream from the glasses camera.
17
+ *
18
+ * Managed (default) -- Glassly hosts the stream and the result carries
19
+ * `hlsUrl`/`dashUrl`/`webrtcUrl` for playback. Optionally fan out to your own
20
+ * `destinations`.
21
+ *
22
+ * Direct -- pass `direct` with your own ingest URL; the glasses publish to it
23
+ * and no playback URLs are returned.
24
+ */
25
+ async startStream(options = {}) {
26
+ if (options.direct !== undefined) {
27
+ return this.session.sendRequest({
28
+ type: MiniappRequestType.STREAM_START,
29
+ streamUrl: options.direct,
30
+ video: options.video,
31
+ audio: options.audio,
32
+ sound: options.sound ?? true,
33
+ ...(options.authToken ? { authToken: options.authToken } : {}),
34
+ });
35
+ }
36
+ return this.session.sendRequest({
37
+ type: MiniappRequestType.MANAGED_STREAM_START,
38
+ restreamDestinations: options.destinations,
39
+ video: options.video,
40
+ audio: options.audio,
41
+ sound: options.sound ?? true,
42
+ ingest: options.ingest,
43
+ });
44
+ }
45
+ /** Stop the active stream, or a specific one by `streamId`. */
46
+ async stop(streamId) {
47
+ await this.session.sendRequest({
48
+ type: MiniappRequestType.STREAM_STOP,
49
+ streamId,
50
+ });
51
+ }
52
+ }
53
+ //# sourceMappingURL=stream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/modules/stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAC,kBAAkB,EAAC,MAAM,aAAa,CAAA;AAoH9C,MAAM,OAAO,YAAY;IACvB,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;IAAG,CAAC;IAExD;;;;;;;;;OASG;IACH,KAAK,CAAC,WAAW,CAAC,UAA8B,EAAE;QAChD,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YACjC,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAe;gBAC5C,IAAI,EAAE,kBAAkB,CAAC,YAAY;gBACrC,SAAS,EAAE,OAAO,CAAC,MAAM;gBACzB,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,IAAI;gBAC5B,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAC,SAAS,EAAE,OAAO,CAAC,SAAS,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC;aAC7D,CAAC,CAAA;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAe;YAC5C,IAAI,EAAE,kBAAkB,CAAC,oBAAoB;YAC7C,oBAAoB,EAAE,OAAO,CAAC,YAAY;YAC1C,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,IAAI;YAC5B,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CAAA;IACJ,CAAC;IAED,+DAA+D;IAC/D,KAAK,CAAC,IAAI,CAAC,QAAiB;QAC1B,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAAO;YACnC,IAAI,EAAE,kBAAkB,CAAC,WAAW;YACpC,QAAQ;SACT,CAAC,CAAA;IACJ,CAAC;CACF"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * @fileoverview SystemModule — OS-level utilities (share, open URL, clipboard, download, QR scan).
3
+ *
4
+ * These bridge to native phone capabilities via LocalMiniappRuntime.
5
+ */
6
+ import { MiniappSession } from "../session";
7
+ export interface ShareOptions {
8
+ text?: string;
9
+ url?: string;
10
+ title?: string;
11
+ /** Base64-encoded file data for file sharing. */
12
+ base64?: string;
13
+ /** MIME type when sharing base64 data. */
14
+ mimeType?: string;
15
+ /** Filename when sharing base64 data. */
16
+ filename?: string;
17
+ }
18
+ export interface ShareResult {
19
+ success: boolean;
20
+ cancelled?: boolean;
21
+ }
22
+ export interface DownloadOptions {
23
+ /** URL to download from, OR base64 data. */
24
+ url?: string;
25
+ base64?: string;
26
+ filename?: string;
27
+ mimeType?: string;
28
+ }
29
+ export interface DownloadResult {
30
+ success: boolean;
31
+ cancelled?: boolean;
32
+ }
33
+ export interface ScanQrOptions {
34
+ /** Header title on the phone scanner overlay. */
35
+ title?: string;
36
+ /** Hint shown over the camera viewfinder. */
37
+ hint?: string;
38
+ }
39
+ export type ScanQrResult = {
40
+ data: string;
41
+ cancelled?: false;
42
+ } | {
43
+ cancelled: true;
44
+ data?: undefined;
45
+ };
46
+ export declare class SystemModule {
47
+ private readonly session;
48
+ constructor(session: MiniappSession);
49
+ /** Open the OS share sheet with the given content. */
50
+ share(options: ShareOptions): Promise<ShareResult>;
51
+ /** Open a URL in the system browser. Blocks dangerous schemes (javascript:, file:). */
52
+ openUrl(url: string): void;
53
+ /** Copy text to the system clipboard. */
54
+ copyToClipboard(text: string): Promise<void>;
55
+ /** Download a file. Opens the OS share sheet so user can choose save location. */
56
+ download(options: DownloadOptions): Promise<DownloadResult>;
57
+ /**
58
+ * Ask the host to stop this miniapp. Use after finishing one-shot work —
59
+ * e.g. an action handler that woke the app headlessly and has nothing more
60
+ * to do (return the action's result first; exit tears the context down).
61
+ * Fire-and-forget: the JS context dies shortly after the host accepts.
62
+ */
63
+ exit(): void;
64
+ /**
65
+ * Open the phone camera QR scanner as a host overlay. Does not unmount the
66
+ * miniapp (so live sessions survive the scan). Resolves with the raw QR
67
+ * payload, or `{cancelled: true}` if the user dismisses the scanner.
68
+ */
69
+ scanQr(options?: ScanQrOptions): Promise<ScanQrResult>;
70
+ }
71
+ //# sourceMappingURL=system.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../src/modules/system.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAA;AAEzC,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,iDAAiD;IACjD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,yCAAyC;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,4CAA4C;IAC5C,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,iDAAiD;IACjD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,6CAA6C;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,MAAM,MAAM,YAAY,GAAG;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,KAAK,CAAA;CAAC,GAAG;IAAC,SAAS,EAAE,IAAI,CAAC;IAAC,IAAI,CAAC,EAAE,SAAS,CAAA;CAAC,CAAA;AAElG,qBAAa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,cAAc;IAEpD,sDAAsD;IAChD,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;IAQxD,uFAAuF;IACvF,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAO1B,yCAAyC;IACnC,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOlD,kFAAkF;IAC5E,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC;IAQjE;;;;;OAKG;IACH,IAAI,IAAI,IAAI;IAMZ;;;;OAIG;IACG,MAAM,CAAC,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,YAAY,CAAC;CAUjE"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @fileoverview SystemModule — OS-level utilities (share, open URL, clipboard, download, QR scan).
3
+ *
4
+ * These bridge to native phone capabilities via LocalMiniappRuntime.
5
+ */
6
+ import { MiniappRequestType } from "../protocol";
7
+ export class SystemModule {
8
+ constructor(session) {
9
+ this.session = session;
10
+ }
11
+ /** Open the OS share sheet with the given content. */
12
+ async share(options) {
13
+ const result = await this.session.sendRequest({
14
+ type: MiniappRequestType.SHARE,
15
+ ...options,
16
+ });
17
+ return result ?? { success: false };
18
+ }
19
+ /** Open a URL in the system browser. Blocks dangerous schemes (javascript:, file:). */
20
+ openUrl(url) {
21
+ this.session.sendOneShot({
22
+ type: MiniappRequestType.OPEN_URL,
23
+ url,
24
+ });
25
+ }
26
+ /** Copy text to the system clipboard. */
27
+ async copyToClipboard(text) {
28
+ await this.session.sendRequest({
29
+ type: MiniappRequestType.COPY_CLIPBOARD,
30
+ text,
31
+ });
32
+ }
33
+ /** Download a file. Opens the OS share sheet so user can choose save location. */
34
+ async download(options) {
35
+ const result = await this.session.sendRequest({
36
+ type: MiniappRequestType.DOWNLOAD,
37
+ ...options,
38
+ });
39
+ return result ?? { success: false };
40
+ }
41
+ /**
42
+ * Ask the host to stop this miniapp. Use after finishing one-shot work —
43
+ * e.g. an action handler that woke the app headlessly and has nothing more
44
+ * to do (return the action's result first; exit tears the context down).
45
+ * Fire-and-forget: the JS context dies shortly after the host accepts.
46
+ */
47
+ exit() {
48
+ this.session.sendOneShot({
49
+ type: MiniappRequestType.SYSTEM_EXIT,
50
+ });
51
+ }
52
+ /**
53
+ * Open the phone camera QR scanner as a host overlay. Does not unmount the
54
+ * miniapp (so live sessions survive the scan). Resolves with the raw QR
55
+ * payload, or `{cancelled: true}` if the user dismisses the scanner.
56
+ */
57
+ async scanQr(options = {}) {
58
+ const result = await this.session.sendRequest({
59
+ type: MiniappRequestType.SCAN_QR,
60
+ ...options,
61
+ }, { timeoutMs: 0 });
62
+ return result ?? { cancelled: true };
63
+ }
64
+ }
65
+ //# sourceMappingURL=system.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system.js","sourceRoot":"","sources":["../../src/modules/system.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,kBAAkB,EAAC,MAAM,aAAa,CAAA;AA0C9C,MAAM,OAAO,YAAY;IACvB,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;IAAG,CAAC;IAExD,sDAAsD;IACtD,KAAK,CAAC,KAAK,CAAC,OAAqB;QAC/B,MAAM,MAAM,GAAG,MAAM,I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-0,0 +1,99 @@
1
+ /**
2
+ * @fileoverview TranscriptionModule — top-level transcription API.
3
+ *
4
+ * Mirrors cloud SDK v3's TranscriptionManager:
5
+ *
6
+ * session.transcription.on(handler) // auto-detect
7
+ * session.transcription.forLanguage("en-US", handler) // single language
8
+ * session.transcription.forLanguage(["en-US", "es-ES"], handler) // multi-language
9
+ * session.transcription.configure({languageHints, vocabulary, diarization})
10
+ * session.transcription.stop() // tear down all
11
+ *
12
+ * Hoisted to top-level (vs. nested under `session.mic`) because transcription
13
+ * is a domain in its own right, not a microphone-input event. The `mic`
14
+ * module still exposes lower-level audio chunks + VAD; this module is for
15
+ * "give me text from speech."
16
+ *
17
+ * MICROPHONE permission must be declared in miniapp.json. The phone runtime
18
+ * rejects with PERMISSION_NOT_DECLARED otherwise.
19
+ */
20
+ import { MiniappSession } from "../session";
21
+ import type { TranscriptionData, UnsubscribeFn } from "./events";
22
+ import type { LanguageHint, TranscriptionLanguage } from "./languages";
23
+ /** Configuration for cloud-side transcription behavior. */
24
+ export interface TranscriptionConfig {
25
+ /**
26
+ * Language hints to improve auto-detection accuracy. Bare ISO 639-1 codes
27
+ * from the registry (e.g. ["en", "ja"]); registry BCP-47 tags are accepted
28
+ * and normalized ("en-US" -> "en"). Anything else throws
29
+ * `MiniappValidationError`.
30
+ */
31
+ languageHints?: LanguageHint[];
32
+ /** Custom vocabulary / boosted terms (e.g. ["Glassly", "HIPAA"]). */
33
+ vocabulary?: string[];
34
+ /**
35
+ * Enable speaker diarisation. Currently always on for cloud transcription
36
+ * (the platform's provider runs diarization unconditionally and events
37
+ * carry `speakerId` when detected); the flag is accepted for
38
+ * forward-compatibility with providers where it is optional.
39
+ */
40
+ diarization?: boolean;
41
+ }
42
+ export interface TranscriptionOptions {
43
+ /**
44
+ * Use only on-device STT for this listener; never deliver cloud transcripts.
45
+ * Other listeners on the same stream keep their own routing choice. Requires
46
+ * a downloaded local STT model.
47
+ */
48
+ forceLocal?: boolean;
49
+ }
50
+ export declare class TranscriptionModule {
51
+ private readonly session;
52
+ private readonly unsubs;
53
+ private currentConfig;
54
+ constructor(session: MiniappSession);
55
+ /**
56
+ * Subscribe to all transcription events (auto-detect language). The
57
+ * detected language is in `data.language`.
58
+ *
59
+ * Wire-level: subscribes to `transcription:auto`. Today's wildcard fan-out
60
+ * (handlers on `transcription:auto` receive any `transcription:<lang>`
61
+ * event) preserves existing semantics.
62
+ */
63
+ on(handler: (data: TranscriptionData) => void, options?: TranscriptionOptions): UnsubscribeFn;
64
+ /**
65
+ * Subscribe to transcription for one or more specific languages. Each call
66
+ * is independent; multiple can be active simultaneously.
67
+ *
68
+ * Languages are validated against the platform registry
69
+ * (`SUPPORTED_TRANSCRIPTION_LANGUAGES`): registry BCP-47 tags pass through,
70
+ * bare registry codes canonicalize ("fr" -> "fr-FR"), anything else throws
71
+ * `MiniappValidationError` immediately — an invalid language must never
72
+ * become a subscription that silently transcribes the wrong thing
73
+ * (OS-1746 / issue 021).
74
+ *
75
+ * @param language - Registry tag(s), e.g. `"en-US"` or `["en-US", "es-ES"]`.
76
+ * @param handler - Called for every event in any of the listed languages.
77
+ */
78
+ forLanguage(language: TranscriptionLanguage | TranscriptionLanguage[], handler: (data: TranscriptionData) => void, options?: TranscriptionOptions): UnsubscribeFn;
79
+ /**
80
+ * Apply transcription configuration (language hints, custom vocabulary,
81
+ * diarisation toggle). Hints are validated against the registry and
82
+ * normalized to bare codes ("en-US" -> "en"); unknown values throw
83
+ * `MiniappValidationError` synchronously.
84
+ *
85
+ * Sent to the phone runtime as a REQUEST (not a one-shot) so the returned
86
+ * promise rejects if the runtime cannot apply it — a config that the
87
+ * platform ignores must be loud, not silent (issue 021 S3). Cached locally
88
+ * so the runtime can re-apply on reconnect.
89
+ */
90
+ configure(config: TranscriptionConfig): Promise<void>;
91
+ /** Tear down every transcription subscription this module owns. */
92
+ stop(): void;
93
+ /** True iff `MICROPHONE` is declared in the miniapp's manifest. */
94
+ get hasPermission(): boolean;
95
+ /** @internal — current config, read by tests / future reconnect logic. */
96
+ _getConfig(): TranscriptionConfig | null;
97
+ private track;
98
+ }
99
+ //# sourceMappingURL=transcription.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transcription.d.ts","sourceRoot":"","sources":["../../src/modules/transcription.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAA;AACzC,OAAO,KAAK,EAAC,iBAAiB,EAAE,aAAa,EAAC,MAAM,UAAU,CAAA;AAE9D,OAAO,KAAK,EAAC,YAAY,EAAE,qBAAqB,EAAC,MAAM,aAAa,CAAA;AAEpE,2DAA2D;AAC3D,MAAM,WAAW,mBAAmB;IAClC;;;;;OAKG;IACH,aAAa,CAAC,EAAE,YAAY,EAAE,CAAA;IAC9B,qEAAqE;IACrE,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;AAED,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED,qBAAa,mBAAmB;IAIlB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAHpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2B;IAClD,OAAO,CAAC,aAAa,CAAmC;gBAE3B,OAAO,EAAE,cAAc;IAEpD;;;;;;;OAOG;IACH,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,EAAE,OAAO,GAAE,oBAAyB,GAAG,aAAa;IAMjG;;;;;;;;;;;;;OAaG;IACH,WAAW,CACT,QAAQ,EAAE,qBAAqB,GAAG,qBAAqB,EAAE,EACzD,OAAO,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,EAC1C,OAAO,GAAE,oBAAyB,GACjC,aAAa;IA4BhB;;;;;;;;;;OAUG;IACH,SAAS,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBrD,mEAAmE;IACnE,IAAI,IAAI,IAAI;IAWZ,mEAAmE;IACnE,IAAI,aAAa,IAAI,OAAO,CAE3B;IAED,0EAA0E;IAC1E,UAAU,IAAI,mBAAmB,GAAG,IAAI;IAMxC,OAAO,CAAC,KAAK;CAOd"}
@@ -0,0 +1,126 @@
1
+ /**
2
+ * @fileoverview TranscriptionModule — top-level transcription API.
3
+ *
4
+ * Mirrors cloud SDK v3's TranscriptionManager:
5
+ *
6
+ * session.transcription.on(handler) // auto-detect
7
+ * session.transcription.forLanguage("en-US", handler) // single language
8
+ * session.transcription.forLanguage(["en-US", "es-ES"], handler) // multi-language
9
+ * session.transcription.configure({languageHints, vocabulary, diarization})
10
+ * session.transcription.stop() // tear down all
11
+ *
12
+ * Hoisted to top-level (vs. nested under `session.mic`) because transcription
13
+ * is a domain in its own right, not a microphone-input event. The `mic`
14
+ * module still exposes lower-level audio chunks + VAD; this module is for
15
+ * "give me text from speech."
16
+ *
17
+ * MICROPHONE permission must be declared in miniapp.json. The phone runtime
18
+ * rejects with PERMISSION_NOT_DECLARED otherwise.
19
+ */
20
+ import { MiniappRequestType, MiniappStreamType } from "../protocol";
21
+ import { requireLanguageHint, requireTranscriptionLanguage } from "./languages";
22
+ export class TranscriptionModule {
23
+ constructor(session) {
24
+ this.session = session;
25
+ this.unsubs = new Set();
26
+ this.currentConfig = null;
27
+ }
28
+ /**
29
+ * Subscribe to all transcription events (auto-detect language). The
30
+ * detected language is in `data.language`.
31
+ *
32
+ * Wire-level: subscribes to `transcription:auto`. Today's wildcard fan-out
33
+ * (handlers on `transcription:auto` receive any `transcription:<lang>`
34
+ * event) preserves existing semantics.
35
+ */
36
+ on(handler, options = {}) {
37
+ return this.track(this.session._subscribe(`${MiniappStreamType.TRANSCRIPTION}:auto`, handler, options));
38
+ }
39
+ /**
40
+ * Subscribe to transcription for one or more specific languages. Each call
41
+ * is independent; multiple can be active simultaneously.
42
+ *
43
+ * Languages are validated against the platform registry
44
+ * (`SUPPORTED_TRANSCRIPTION_LANGUAGES`): registry BCP-47 tags pass through,
45
+ * bare registry codes canonicalize ("fr" -> "fr-FR"), anything else throws
46
+ * `MiniappValidationError` immediately — an invalid language must never
47
+ * become a subscription that silently transcribes the wrong thing
48
+ * (OS-1746 / issue 021).
49
+ *
50
+ * @param language - Registry tag(s), e.g. `"en-US"` or `["en-US", "es-ES"]`.
51
+ * @param handler - Called for every event in any of the listed languages.
52
+ */
53
+ forLanguage(language, handler, options = {}) {
54
+ const langs = (Array.isArray(language) ? language : [language]).map((lang) => requireTranscriptionLanguage(lang, "transcription.forLanguage(language)"));
55
+ if (langs.length === 0)
56
+ return () => { };
57
+ const unsubs = [];
58
+ for (const lang of langs) {
59
+ unsubs.push(this.session._subscribe(`${MiniappStreamType.TRANSCRIPTION}:${lang}`, handler, options));
60
+ }
61
+ const combined = () => {
62
+ for (const u of unsubs) {
63
+ try {
64
+ u();
65
+ }
66
+ catch {
67
+ /* ignore */
68
+ }
69
+ }
70
+ };
71
+ return this.track(combined);
72
+ }
73
+ /**
74
+ * Apply transcription configuration (language hints, custom vocabulary,
75
+ * diarisation toggle). Hints are validated against the registry and
76
+ * normalized to bare codes ("en-US" -> "en"); unknown values throw
77
+ * `MiniappValidationError` synchronously.
78
+ *
79
+ * Sent to the phone runtime as a REQUEST (not a one-shot) so the returned
80
+ * promise rejects if the runtime cannot apply it — a config that the
81
+ * platform ignores must be loud, not silent (issue 021 S3). Cached locally
82
+ * so the runtime can re-apply on reconnect.
83
+ */
84
+ configure(config) {
85
+ const normalized = {
86
+ ...config,
87
+ languageHints: config.languageHints?.map((hint) => requireLanguageHint(hint, "transcription.configure(languageHints)")),
88
+ };
89
+ this.currentConfig = { ...normalized };
90
+ return this.session
91
+ .sendRequest({
92
+ type: MiniappRequestType.TRANSCRIPTION_CONFIG,
93
+ config: { ...normalized },
94
+ })
95
+ .then(() => undefined);
96
+ }
97
+ /** Tear down every transcription subscription this module owns. */
98
+ stop() {
99
+ for (const u of this.unsubs) {
100
+ try {
101
+ u();
102
+ }
103
+ catch {
104
+ /* ignore */
105
+ }
106
+ }
107
+ this.unsubs.clear();
108
+ }
109
+ /** True iff `MICROPHONE` is declared in the miniapp's manifest. */
110
+ get hasPermission() {
111
+ return this.session._hasManifestPermission("MICROPHONE");
112
+ }
113
+ /** @internal — current config, read by tests / future reconnect logic. */
114
+ _getConfig() {
115
+ return this.currentConfig ? { ...this.currentConfig } : null;
116
+ }
117
+ // ------------------------------------------------------------------------
118
+ track(unsub) {
119
+ this.unsubs.add(unsub);
120
+ return () => {
121
+ this.unsubs.delete(unsub);
122
+ unsub();
123
+ };
124
+ }
125
+ }
126
+ //# sourceMappingURL=transcription.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transcription.js","sourceRoot":"","sources":["../../src/modules/transcription.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAC,kBAAkB,EAAE,iBAAiB,EAAC,MAAM,aAAa,CAAA;AAGjE,OAAO,EAAC,mBAAmB,EAAE,4BAA4B,EAAC,MAAM,aAAa,CAAA;AAgC7E,MAAM,OAAO,mBAAmB;IAI9B,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;QAHnC,WAAM,GAAG,IAAI,GAAG,EAAiB,CAAA;QAC1C,kBAAa,GAA+B,IAAI,CAAA;IAED,CAAC;IAExD;;;;;;;OAOG;IACH,EAAE,CAAC,OAA0C,EAAE,UAAgC,EAAE;QAC/E,OAAO,IAAI,CAAC,KAAK,CACf,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,iBAAiB,CAAC,aAAa,OAAO,EAAE,OAAkC,EAAE,OAAO,CAAC,CAChH,CAAA;IACH,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,WAAW,CACT,QAAyD,EACzD,OAA0C,EAC1C,UAAgC,EAAE;QAElC,MAAM,KAAK,GAAG,CAAC,KAAK,CAAC,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xB,CAAC;aACD,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;IAC1B,CAAC;IAED,mEAAmE;IACnE,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,0EAA0E;IAC1E,UAAU;QACR,OAAO,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,EAAC,GAAG,IAAI,CAAC,aAAa,EAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IAC5D,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,65 @@
1
+ /**
2
+ * @fileoverview TranslationModule — top-level translation API.
3
+ *
4
+ * Mirrors cloud SDK v3's TranslationManager surface:
5
+ *
6
+ * session.translation.on(handler) // any pair
7
+ * session.translation.to(target, handler) // any-source → target
8
+ * session.translation.to([targets], handler) // any-source → many
9
+ * session.translation.fromTo(source, target, handler) // specific pair
10
+ * session.translation.fromTo(source, [targets], handler) // source → many
11
+ * session.translation.stop() // tear down all
12
+ *
13
+ * Internally each subscribe registers against a `translation:<source>:<target>`
14
+ * stream pattern; LocalMiniappRuntime's wildcard matcher routes incoming
15
+ * `translation:<src>:<dst>` events to any matching `*` patterns.
16
+ *
17
+ * MICROPHONE permission required.
18
+ */
19
+ import { MiniappSession } from "../session";
20
+ import type { TranslationData, UnsubscribeFn } from "./events";
21
+ import type { TranscriptionLanguage } from "./languages";
22
+ export type TranslationHandler = (data: TranslationData) => void;
23
+ /**
24
+ * Translation source: a registry language, or "auto" to let the cloud detect
25
+ * the spoken language.
26
+ */
27
+ export type TranslationSource = TranscriptionLanguage | "auto";
28
+ export declare class TranslationModule {
29
+ private readonly session;
30
+ private readonly unsubs;
31
+ constructor(session: MiniappSession);
32
+ /**
33
+ * Subscribe to every translation event from the cloud, regardless of
34
+ * source or target language.
35
+ *
36
+ * Uses the wildcard stream `translation:*:*` — cheap to register on the
37
+ * client, expensive on the cloud side (cloud fans every active pair out
38
+ * to this subscriber). Prefer `to` or `fromTo` when you know the
39
+ * language(s) you care about.
40
+ */
41
+ on(handler: TranslationHandler): UnsubscribeFn;
42
+ /**
43
+ * Subscribe to any translation that lands at the given target language(s),
44
+ * regardless of source. Useful for "I'm a Spanish speaker, translate
45
+ * whatever I hear to Spanish."
46
+ */
47
+ to(target: TranscriptionLanguage | TranscriptionLanguage[], handler: TranslationHandler): UnsubscribeFn;
48
+ /**
49
+ * Subscribe to a specific source → target translation pair. Pass an
50
+ * array for `target` to fan a single handler across multiple targets
51
+ * from the same source.
52
+ */
53
+ fromTo(source: TranslationSource, target: TranscriptionLanguage | TranscriptionLanguage[], handler: TranslationHandler): UnsubscribeFn;
54
+ /**
55
+ * @deprecated Renamed to `fromTo(source, target, handler)` for cloud
56
+ * SDK v3 parity. This alias will be removed in a future release.
57
+ */
58
+ forLanguagePair(fromLang: TranslationSource, toLang: TranscriptionLanguage, handler: TranslationHandler): UnsubscribeFn;
59
+ /** Tear down every translation subscription this module owns. */
60
+ stop(): void;
61
+ /** True iff `MICROPHONE` is declared in the miniapp's manifest. */
62
+ get hasPermission(): boolean;
63
+ private track;
64
+ }
65
+ //# sourceMappingURL=translation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translation.d.ts","sourceRoot":"","sources":["../../src/modules/translation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAA;AACzC,OAAO,KAAK,EAAC,eAAe,EAAE,aAAa,EAAC,MAAM,UAAU,CAAA;AAE5D,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,aAAa,CAAA;AAEtD,MAAM,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE,eAAe,KAAK,IAAI,CAAA;AAEhE;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,qBAAqB,GAAG,MAAM,CAAA;AAE9D,qBAAa,iBAAiB;IAGhB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAFpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2B;gBAErB,OAAO,EAAE,cAAc;IAEpD;;;;;;;;OAQG;IACH,EAAE,CAAC,OAAO,EAAE,kBAAkB,GAAG,aAAa;IAM9C;;;;OAIG;IACH,EAAE,CAAC,MAAM,EAAE,qBAAqB,GAAG,qBAAqB,EAAE,EAAE,OAAO,EAAE,kBAAkB,GAAG,aAAa;IAuBvG;;;;OAIG;IACH,MAAM,CACJ,MAAM,EAAE,iBAAiB,EACzB,MAAM,EAAE,qBAAqB,GAAG,qBAAqB,EAAE,EACvD,OAAO,EAAE,kBAAkB,GAC1B,aAAa;IA2BhB;;;OAGG;IACH,eAAe,CACb,QAAQ,EAAE,iBAAiB,EAC3B,MAAM,EAAE,qBAAqB,EAC7B,OAAO,EAAE,kBAAkB,GAC1B,aAAa;IAIhB,iEAAiE;IACjE,IAAI,IAAI,IAAI;IAWZ,mEAAmE;IACnE,IAAI,aAAa,IAAI,OAAO,CAE3B;IAID,OAAO,CAAC,KAAK;CAOd"}
@@ -0,0 +1,121 @@
1
+ /**
2
+ * @fileoverview TranslationModule — top-level translation API.
3
+ *
4
+ * Mirrors cloud SDK v3's TranslationManager surface:
5
+ *
6
+ * session.translation.on(handler) // any pair
7
+ * session.translation.to(target, handler) // any-source → target
8
+ * session.translation.to([targets], handler) // any-source → many
9
+ * session.translation.fromTo(source, target, handler) // specific pair
10
+ * session.translation.fromTo(source, [targets], handler) // source → many
11
+ * session.translation.stop() // tear down all
12
+ *
13
+ * Internally each subscribe registers against a `translation:<source>:<target>`
14
+ * stream pattern; LocalMiniappRuntime's wildcard matcher routes incoming
15
+ * `translation:<src>:<dst>` events to any matching `*` patterns.
16
+ *
17
+ * MICROPHONE permission required.
18
+ */
19
+ import { MiniappStreamType } from "../protocol";
20
+ import { requireTranscriptionLanguage } from "./languages";
21
+ export class TranslationModule {
22
+ constructor(session) {
23
+ this.session = session;
24
+ this.unsubs = new Set();
25
+ }
26
+ /**
27
+ * Subscribe to every translation event from the cloud, regardless of
28
+ * source or target language.
29
+ *
30
+ * Uses the wildcard stream `translation:*:*` — cheap to register on the
31
+ * client, expensive on the cloud side (cloud fans every active pair out
32
+ * to this subscriber). Prefer `to` or `fromTo` when you know the
33
+ * language(s) you care about.
34
+ */
35
+ on(handler) {
36
+ return this.track(this.session._subscribe(`${MiniappStreamType.TRANSLATION}:*:*`, handler));
37
+ }
38
+ /**
39
+ * Subscribe to any translation that lands at the given target language(s),
40
+ * regardless of source. Useful for "I'm a Spanish speaker, translate
41
+ * whatever I hear to Spanish."
42
+ */
43
+ to(target, handler) {
44
+ const targets = (Array.isArray(target) ? target : [target]).map((t) => requireTranscriptionLanguage(t, "translation.to(target)"));
45
+ if (targets.length === 0)
46
+ return () => { };
47
+ const unsubs = [];
48
+ for (const t of targets) {
49
+ unsubs.push(this.session._subscribe(`${MiniappStreamType.TRANSLATION}:*:${t}`, handler));
50
+ }
51
+ const composite = () => {
52
+ for (const u of unsubs) {
53
+ try {
54
+ u();
55
+ }
56
+ catch {
57
+ /* ignore */
58
+ }
59
+ }
60
+ };
61
+ return this.track(composite);
62
+ }
63
+ /**
64
+ * Subscribe to a specific source → target translation pair. Pass an
65
+ * array for `target` to fan a single handler across multiple targets
66
+ * from the same source.
67
+ */
68
+ fromTo(source, target, handler) {
69
+ const validSource = source === "auto" ? "auto" : requireTranscriptionLanguage(source, "translation.fromTo(source)");
70
+ const targets = (Array.isArray(target) ? target : [target]).map((t) => requireTranscriptionLanguage(t, "translation.fromTo(target)"));
71
+ if (targets.length === 0)
72
+ return () => { };
73
+ const unsubs = [];
74
+ for (const t of targets) {
75
+ unsubs.push(this.session._subscribe(`${MiniappStreamType.TRANSLATION}:${validSource}:${t}`, handler));
76
+ }
77
+ const composite = () => {
78
+ for (const u of unsubs) {
79
+ try {
80
+ u();
81
+ }
82
+ catch {
83
+ /* ignore */
84
+ }
85
+ }
86
+ };
87
+ return this.track(composite);
88
+ }
89
+ /**
90
+ * @deprecated Renamed to `fromTo(source, target, handler)` for cloud
91
+ * SDK v3 parity. This alias will be removed in a future release.
92
+ */
93
+ forLanguagePair(fromLang, toLang, handler) {
94
+ return this.fromTo(fromLang, toLang, handler);
95
+ }
96
+ /** Tear down every translation subscription this module owns. */
97
+ stop() {
98
+ for (const u of this.unsubs) {
99
+ try {
100
+ u();
101
+ }
102
+ catch {
103
+ /* ignore */
104
+ }
105
+ }
106
+ this.unsubs.clear();
107
+ }
108
+ /** True iff `MICROPHONE` is declared in the miniapp's manifest. */
109
+ get hasPermission() {
110
+ return this.session._hasManifestPermission("MICROPHONE");
111
+ }
112
+ // ------------------------------------------------------------------------
113
+ track(unsub) {
114
+ this.unsubs.add(unsub);
115
+ return () => {
116
+ this.unsubs.delete(unsub);
117
+ unsub();
118
+ };
119
+ }
120
+ }
121
+ //# sourceMappingURL=translation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translation.js","sourceRoot":"","sources":["../../src/modules/translation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAC,iBAAiB,EAAC,MAAM,aAAa,CAAA;AAG7C,OAAO,EAAC,4BAA4B,EAAC,MAAM,aAAa,CAAA;AAWx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