@mentra/miniapp 0.3.0-beta.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.
Files changed (277) hide show
  1. package/README.md +259 -0
  2. package/dist/background/index.d.ts +60 -0
  3. package/dist/background/index.d.ts.map +1 -0
  4. package/dist/background/index.js +25 -0
  5. package/dist/background/index.js.map +1 -0
  6. package/dist/background/register.d.ts +38 -0
  7. package/dist/background/register.d.ts.map +1 -0
  8. package/dist/background/register.js +75 -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 +62 -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/index.d.ts +59 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +31 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/modules/actions.d.ts +54 -0
  27. package/dist/modules/actions.d.ts.map +1 -0
  28. package/dist/modules/actions.js +122 -0
  29. package/dist/modules/actions.js.map +1 -0
  30. package/dist/modules/auth.d.ts +25 -0
  31. package/dist/modules/auth.d.ts.map +1 -0
  32. package/dist/modules/auth.js +52 -0
  33. package/dist/modules/auth.js.map +1 -0
  34. package/dist/modules/base64.d.ts +16 -0
  35. package/dist/modules/base64.d.ts.map +1 -0
  36. package/dist/modules/base64.js +92 -0
  37. package/dist/modules/base64.js.map +1 -0
  38. package/dist/modules/blob.d.ts +161 -0
  39. package/dist/modules/blob.d.ts.map +1 -0
  40. package/dist/modules/blob.js +277 -0
  41. package/dist/modules/blob.js.map +1 -0
  42. package/dist/modules/camera.d.ts +170 -0
  43. package/dist/modules/camera.d.ts.map +1 -0
  44. package/dist/modules/camera.js +116 -0
  45. package/dist/modules/camera.js.map +1 -0
  46. package/dist/modules/cloud.d.ts +34 -0
  47. package/dist/modules/cloud.d.ts.map +1 -0
  48. package/dist/modules/cloud.js +70 -0
  49. package/dist/modules/cloud.js.map +1 -0
  50. package/dist/modules/dashboard.d.ts +16 -0
  51. package/dist/modules/dashboard.d.ts.map +1 -0
  52. package/dist/modules/dashboard.js +27 -0
  53. package/dist/modules/dashboard.js.map +1 -0
  54. package/dist/modules/display.d.ts +106 -0
  55. package/dist/modules/display.d.ts.map +1 -0
  56. package/dist/modules/display.js +57 -0
  57. package/dist/modules/display.js.map +1 -0
  58. package/dist/modules/events.d.ts +160 -0
  59. package/dist/modules/events.d.ts.map +1 -0
  60. package/dist/modules/events.js +168 -0
  61. package/dist/modules/events.js.map +1 -0
  62. package/dist/modules/glasses.d.ts +28 -0
  63. package/dist/modules/glasses.d.ts.map +1 -0
  64. package/dist/modules/glasses.js +39 -0
  65. package/dist/modules/glasses.js.map +1 -0
  66. package/dist/modules/heading.d.ts +16 -0
  67. package/dist/modules/heading.d.ts.map +1 -0
  68. package/dist/modules/heading.js +20 -0
  69. package/dist/modules/heading.js.map +1 -0
  70. package/dist/modules/imu.d.ts +31 -0
  71. package/dist/modules/imu.d.ts.map +1 -0
  72. package/dist/modules/imu.js +40 -0
  73. package/dist/modules/imu.js.map +1 -0
  74. package/dist/modules/input.d.ts +34 -0
  75. package/dist/modules/input.d.ts.map +1 -0
  76. package/dist/modules/input.js +50 -0
  77. package/dist/modules/input.js.map +1 -0
  78. package/dist/modules/led.d.ts +35 -0
  79. package/dist/modules/led.d.ts.map +1 -0
  80. package/dist/modules/led.js +39 -0
  81. package/dist/modules/led.js.map +1 -0
  82. package/dist/modules/location.d.ts +27 -0
  83. package/dist/modules/location.d.ts.map +1 -0
  84. package/dist/modules/location.js +35 -0
  85. package/dist/modules/location.js.map +1 -0
  86. package/dist/modules/mic.d.ts +44 -0
  87. package/dist/modules/mic.d.ts.map +1 -0
  88. package/dist/modules/mic.js +67 -0
  89. package/dist/modules/mic.js.map +1 -0
  90. package/dist/modules/miniapps.d.ts +72 -0
  91. package/dist/modules/miniapps.d.ts.map +1 -0
  92. package/dist/modules/miniapps.js +48 -0
  93. package/dist/modules/miniapps.js.map +1 -0
  94. package/dist/modules/navigation.d.ts +326 -0
  95. package/dist/modules/navigation.d.ts.map +1 -0
  96. package/dist/modules/navigation.js +386 -0
  97. package/dist/modules/navigation.js.map +1 -0
  98. package/dist/modules/permissions.d.ts +58 -0
  99. package/dist/modules/permissions.d.ts.map +1 -0
  100. package/dist/modules/permissions.js +66 -0
  101. package/dist/modules/permissions.js.map +1 -0
  102. package/dist/modules/phone.d.ts +95 -0
  103. package/dist/modules/phone.d.ts.map +1 -0
  104. package/dist/modules/phone.js +110 -0
  105. package/dist/modules/phone.js.map +1 -0
  106. package/dist/modules/pivots/engine.d.ts +169 -0
  107. package/dist/modules/pivots/engine.d.ts.map +1 -0
  108. package/dist/modules/pivots/engine.js +779 -0
  109. package/dist/modules/pivots/engine.js.map +1 -0
  110. package/dist/modules/pivots/geometry.d.ts +84 -0
  111. package/dist/modules/pivots/geometry.d.ts.map +1 -0
  112. package/dist/modules/pivots/geometry.js +371 -0
  113. package/dist/modules/pivots/geometry.js.map +1 -0
  114. package/dist/modules/pivots/instructions.d.ts +139 -0
  115. package/dist/modules/pivots/instructions.d.ts.map +1 -0
  116. package/dist/modules/pivots/instructions.js +280 -0
  117. package/dist/modules/pivots/instructions.js.map +1 -0
  118. package/dist/modules/speaker.d.ts +169 -0
  119. package/dist/modules/speaker.d.ts.map +1 -0
  120. package/dist/modules/speaker.js +251 -0
  121. package/dist/modules/speaker.js.map +1 -0
  122. package/dist/modules/storage.d.ts +50 -0
  123. package/dist/modules/storage.d.ts.map +1 -0
  124. package/dist/modules/storage.js +99 -0
  125. package/dist/modules/storage.js.map +1 -0
  126. package/dist/modules/stream.d.ts +129 -0
  127. package/dist/modules/stream.d.ts.map +1 -0
  128. package/dist/modules/stream.js +52 -0
  129. package/dist/modules/stream.js.map +1 -0
  130. package/dist/modules/system.d.ts +45 -0
  131. package/dist/modules/system.d.ts.map +1 -0
  132. package/dist/modules/system.js +42 -0
  133. package/dist/modules/system.js.map +1 -0
  134. package/dist/modules/transcription.d.ts +75 -0
  135. package/dist/modules/transcription.d.ts.map +1 -0
  136. package/dist/modules/transcription.js +106 -0
  137. package/dist/modules/transcription.js.map +1 -0
  138. package/dist/modules/translation.d.ts +59 -0
  139. package/dist/modules/translation.d.ts.map +1 -0
  140. package/dist/modules/translation.js +119 -0
  141. package/dist/modules/translation.js.map +1 -0
  142. package/dist/modules/ui.d.ts +186 -0
  143. package/dist/modules/ui.d.ts.map +1 -0
  144. package/dist/modules/ui.js +293 -0
  145. package/dist/modules/ui.js.map +1 -0
  146. package/dist/protocol.d.ts +299 -0
  147. package/dist/protocol.d.ts.map +1 -0
  148. package/dist/protocol.js +325 -0
  149. package/dist/protocol.js.map +1 -0
  150. package/dist/react/MentraProvider.d.ts +33 -0
  151. package/dist/react/MentraProvider.d.ts.map +1 -0
  152. package/dist/react/MentraProvider.js +15 -0
  153. package/dist/react/MentraProvider.js.map +1 -0
  154. package/dist/react/MiniappHeader.d.ts +44 -0
  155. package/dist/react/MiniappHeader.d.ts.map +1 -0
  156. package/dist/react/MiniappHeader.js +32 -0
  157. package/dist/react/MiniappHeader.js.map +1 -0
  158. package/dist/react/index.d.ts +13 -0
  159. package/dist/react/index.d.ts.map +1 -0
  160. package/dist/react/index.js +9 -0
  161. package/dist/react/index.js.map +1 -0
  162. package/dist/react/useCapabilities.d.ts +26 -0
  163. package/dist/react/useCapabilities.d.ts.map +1 -0
  164. package/dist/react/useCapabilities.js +27 -0
  165. package/dist/react/useCapabilities.js.map +1 -0
  166. package/dist/react/useCapsuleHeaderStyle.d.ts +27 -0
  167. package/dist/react/useCapsuleHeaderStyle.d.ts.map +1 -0
  168. package/dist/react/useCapsuleHeaderStyle.js +36 -0
  169. package/dist/react/useCapsuleHeaderStyle.js.map +1 -0
  170. package/dist/react/useColorScheme.d.ts +18 -0
  171. package/dist/react/useColorScheme.d.ts.map +1 -0
  172. package/dist/react/useColorScheme.js +24 -0
  173. package/dist/react/useColorScheme.js.map +1 -0
  174. package/dist/react/useConnected.d.ts +17 -0
  175. package/dist/react/useConnected.d.ts.map +1 -0
  176. package/dist/react/useConnected.js +39 -0
  177. package/dist/react/useConnected.js.map +1 -0
  178. package/dist/react/useRpc.d.ts +29 -0
  179. package/dist/react/useRpc.d.ts.map +1 -0
  180. package/dist/react/useRpc.js +82 -0
  181. package/dist/react/useRpc.js.map +1 -0
  182. package/dist/react/useSafeArea.d.ts +21 -0
  183. package/dist/react/useSafeArea.d.ts.map +1 -0
  184. package/dist/react/useSafeArea.js +22 -0
  185. package/dist/react/useSafeArea.js.map +1 -0
  186. package/dist/session.d.ts +312 -0
  187. package/dist/session.d.ts.map +1 -0
  188. package/dist/session.js +653 -0
  189. package/dist/session.js.map +1 -0
  190. package/dist/sub-path-types.test-d.d.ts +28 -0
  191. package/dist/sub-path-types.test-d.d.ts.map +1 -0
  192. package/dist/sub-path-types.test-d.js +37 -0
  193. package/dist/sub-path-types.test-d.js.map +1 -0
  194. package/dist/transport/auto.d.ts +35 -0
  195. package/dist/transport/auto.d.ts.map +1 -0
  196. package/dist/transport/auto.js +125 -0
  197. package/dist/transport/auto.js.map +1 -0
  198. package/dist/transport/dispatch.d.ts +43 -0
  199. package/dist/transport/dispatch.d.ts.map +1 -0
  200. package/dist/transport/dispatch.js +91 -0
  201. package/dist/transport/dispatch.js.map +1 -0
  202. package/dist/transport/local-socket.d.ts +28 -0
  203. package/dist/transport/local-socket.d.ts.map +1 -0
  204. package/dist/transport/local-socket.js +80 -0
  205. package/dist/transport/local-socket.js.map +1 -0
  206. package/dist/transport/mock.d.ts +54 -0
  207. package/dist/transport/mock.d.ts.map +1 -0
  208. package/dist/transport/mock.js +207 -0
  209. package/dist/transport/mock.js.map +1 -0
  210. package/dist/transport/postmessage.d.ts +36 -0
  211. package/dist/transport/postmessage.d.ts.map +1 -0
  212. package/dist/transport/postmessage.js +78 -0
  213. package/dist/transport/postmessage.js.map +1 -0
  214. package/dist/transport/types.d.ts +25 -0
  215. package/dist/transport/types.d.ts.map +1 -0
  216. package/dist/transport/types.js +11 -0
  217. package/dist/transport/types.js.map +1 -0
  218. package/dist/ui/index.d.ts +98 -0
  219. package/dist/ui/index.d.ts.map +1 -0
  220. package/dist/ui/index.js +32 -0
  221. package/dist/ui/index.js.map +1 -0
  222. package/package.json +84 -0
  223. package/src/background/index.ts +152 -0
  224. package/src/background/register.ts +85 -0
  225. package/src/dev-reload.ts +60 -0
  226. package/src/envelope.ts +54 -0
  227. package/src/globals.ts +62 -0
  228. package/src/index.ts +171 -0
  229. package/src/modules/actions.ts +156 -0
  230. package/src/modules/auth.ts +68 -0
  231. package/src/modules/base64.ts +87 -0
  232. package/src/modules/blob.ts +341 -0
  233. package/src/modules/camera.ts +242 -0
  234. package/src/modules/cloud.ts +94 -0
  235. package/src/modules/dashboard.ts +31 -0
  236. package/src/modules/display.ts +122 -0
  237. package/src/modules/events.ts +291 -0
  238. package/src/modules/glasses.ts +44 -0
  239. package/src/modules/heading.ts +23 -0
  240. package/src/modules/imu.ts +44 -0
  241. package/src/modules/input.ts +71 -0
  242. package/src/modules/led.ts +61 -0
  243. package/src/modules/location.ts +39 -0
  244. package/src/modules/mic.ts +74 -0
  245. package/src/modules/miniapps.ts +90 -0
  246. package/src/modules/navigation.ts +670 -0
  247. package/src/modules/permissions.ts +84 -0
  248. package/src/modules/phone.ts +155 -0
  249. package/src/modules/pivots/engine.ts +863 -0
  250. package/src/modules/pivots/geometry.ts +409 -0
  251. package/src/modules/pivots/instructions.ts +343 -0
  252. package/src/modules/speaker.ts +335 -0
  253. package/src/modules/storage.ts +109 -0
  254. package/src/modules/stream.ts +163 -0
  255. package/src/modules/system.ts +76 -0
  256. package/src/modules/transcription.ts +145 -0
  257. package/src/modules/translation.ts +149 -0
  258. package/src/modules/ui.ts +498 -0
  259. package/src/protocol.ts +378 -0
  260. package/src/react/MentraProvider.tsx +50 -0
  261. package/src/react/MiniappHeader.tsx +122 -0
  262. package/src/react/index.ts +12 -0
  263. package/src/react/useCapabilities.ts +29 -0
  264. package/src/react/useCapsuleHeaderStyle.ts +54 -0
  265. package/src/react/useColorScheme.ts +26 -0
  266. package/src/react/useConnected.ts +47 -0
  267. package/src/react/useRpc.ts +106 -0
  268. package/src/react/useSafeArea.ts +40 -0
  269. package/src/session.ts +886 -0
  270. package/src/sub-path-types.test-d.ts +49 -0
  271. package/src/transport/auto.ts +143 -0
  272. package/src/transport/dispatch.ts +106 -0
  273. package/src/transport/local-socket.ts +93 -0
  274. package/src/transport/mock.ts +251 -0
  275. package/src/transport/postmessage.ts +95 -0
  276. package/src/transport/types.ts +26 -0
  277. package/src/ui/index.ts +122 -0
@@ -0,0 +1,168 @@
1
+ /**
2
+ * @fileoverview EventManager — internal subscription registry + escape hatch.
3
+ *
4
+ * Most miniapp authors should NOT touch this directly. Use the typed methods
5
+ * on domain modules instead:
6
+ * - session.transcription.on(...)
7
+ * - session.mic.onAudioChunk(...) / onVoiceActivity(...)
8
+ * - session.input.onButtonPress(...)
9
+ * - session.imu.onHeadPosition(...)
10
+ * - session.location.onUpdate(...)
11
+ * - session.glasses.onBattery(...) / onConnection(...)
12
+ * - session.phone.notifications.on(...) / session.phone.onBattery(...)
13
+ *
14
+ * This module's only public method is `subscribe(rawStreamType, handler)` —
15
+ * a forward-compat escape hatch for new event types not yet wrapped on a
16
+ * domain module. Officially undocumented; the typed methods on domain
17
+ * modules are the canonical surface.
18
+ *
19
+ * Internally, EventManager owns:
20
+ * 1. The ref-count map. Outbound SUBSCRIBE is only sent when a stream's
21
+ * ref count transitions 0↔1, so multiple components listening for the
22
+ * same stream issue one wire-level subscribe.
23
+ * 2. Inbound event fan-out via `_forwardEvent(streamType, data)`, called
24
+ * by MiniappSession.handleIncoming when an EVENT envelope arrives.
25
+ *
26
+ * Domain modules call back into the session via session._subscribe(...) which
27
+ * in turn delegates to this class — the session is the integration point;
28
+ * domain modules don't see this class directly.
29
+ */
30
+ import { EventEmitter } from "eventemitter3";
31
+ import { MiniappRequestType, MiniappStreamType } from "../protocol";
32
+ // ---------------------------------------------------------------------------
33
+ // Registry
34
+ // ---------------------------------------------------------------------------
35
+ export class EventManager {
36
+ constructor(session) {
37
+ this.session = session;
38
+ this.emitter = new EventEmitter();
39
+ /** Stream -> ref count. Outbound SUBSCRIBE tracks active streams and routing changes. */
40
+ this.refCounts = new Map();
41
+ /** Transcription stream -> refs that require on-device-only processing. */
42
+ this.forceLocalRefCounts = new Map();
43
+ }
44
+ /**
45
+ * Generic subscribe. `stream` is the raw wire value, including any language
46
+ * suffix like `"transcription:en-US"`. Forward-compat escape hatch for new
47
+ * event types not yet wrapped on a domain module. Most authors should use
48
+ * typed methods on domain modules instead.
49
+ *
50
+ * Stream names beginning with `_` (e.g. `_ui` for the session.ui bus) are
51
+ * INTERNAL — they ride the local _forwardEvent fan-out and never appear in
52
+ * the outbound SUBSCRIBE list. Native already knows to deliver UI envelopes
53
+ * via a separate envelope `type`; the EventManager only routes them
54
+ * locally.
55
+ */
56
+ subscribe(stream, handler, options = {}) {
57
+ const isInternal = stream.startsWith("_");
58
+ const forceLocal = options.forceLocal === true && stream.startsWith(`${MiniappStreamType.TRANSCRIPTION}:`);
59
+ const listener = (data, route) => {
60
+ if (stream.startsWith(`${MiniappStreamType.TRANSCRIPTION}:`)) {
61
+ // Hosts that predate routed transcription events omit `route`. Treat
62
+ // those events as the default/cloud path so a forceLocal listener can
63
+ // never accidentally receive cloud text.
64
+ if (forceLocal ? route !== "forceLocal" && route !== "all" : route === "forceLocal")
65
+ return;
66
+ }
67
+ handler(data);
68
+ };
69
+ this.emitter.on(stream, listener);
70
+ if (!isInternal) {
71
+ const before = this.refCounts.get(stream) ?? 0;
72
+ this.refCounts.set(stream, before + 1);
73
+ const forceLocalBefore = this.forceLocalRefCounts.get(stream) ?? 0;
74
+ const defaultBefore = before - forceLocalBefore;
75
+ if (forceLocal)
76
+ this.forceLocalRefCounts.set(stream, forceLocalBefore + 1);
77
+ if (before === 0 || (forceLocal && forceLocalBefore === 0) || (!forceLocal && defaultBefore === 0)) {
78
+ this.sendSubscriptionUpdate();
79
+ }
80
+ }
81
+ return () => {
82
+ this.emitter.off(stream, listener);
83
+ if (isInternal)
84
+ return;
85
+ const current = this.refCounts.get(stream) ?? 0;
86
+ const forceLocalCurrent = this.forceLocalRefCounts.get(stream) ?? 0;
87
+ let subscriptionChanged = current <= 1;
88
+ if (current <= 1) {
89
+ this.refCounts.delete(stream);
90
+ }
91
+ else {
92
+ this.refCounts.set(stream, current - 1);
93
+ }
94
+ if (forceLocal) {
95
+ if (forceLocalCurrent <= 1) {
96
+ this.forceLocalRefCounts.delete(stream);
97
+ subscriptionChanged = true;
98
+ }
99
+ else {
100
+ this.forceLocalRefCounts.set(stream, forceLocalCurrent - 1);
101
+ }
102
+ }
103
+ else if (current - forceLocalCurrent <= 1) {
104
+ subscriptionChanged = true;
105
+ }
106
+ if (subscriptionChanged)
107
+ this.sendSubscriptionUpdate();
108
+ };
109
+ }
110
+ /** Unsubscribe every handler on every stream this EventManager owns. */
111
+ unsubscribeAll() {
112
+ this.emitter.removeAllListeners();
113
+ this.refCounts.clear();
114
+ this.forceLocalRefCounts.clear();
115
+ this.sendSubscriptionUpdate();
116
+ }
117
+ // -------------------------------------------------------------------------
118
+ // Internal — called by MiniappSession when EVENT arrives from phone
119
+ // -------------------------------------------------------------------------
120
+ /** @internal */
121
+ _forwardEvent(stream, data, transcriptionRoute) {
122
+ this.emitter.emit(stream, data, transcriptionRoute);
123
+ // Wildcard fan-out: handlers register under wildcard patterns
124
+ // ("transcription:auto", "translation:*:<target>", …) but the host
125
+ // delivers events under the CONCRETE stream key
126
+ // ("transcription:en-US", "translation:en:es"). Re-emit on every
127
+ // pattern the concrete key satisfies — the same pattern set
128
+ // LocalMiniappRuntime.forwardEvent matches on the host side —
129
+ // otherwise a wildcard subscriber never fires.
130
+ if (stream.startsWith("transcription:") && stream !== "transcription:auto") {
131
+ this.emitter.emit("transcription:auto", data, transcriptionRoute);
132
+ }
133
+ else if (stream.startsWith("translation:")) {
134
+ const parts = stream.split(":");
135
+ const patterns = new Set(["translation:auto"]);
136
+ if (parts.length === 3) {
137
+ const [, source, target] = parts;
138
+ patterns.add("translation:*:*");
139
+ patterns.add(`translation:*:${target}`);
140
+ patterns.add(`translation:${source}:*`);
141
+ }
142
+ patterns.delete(stream); // exact key already emitted above
143
+ for (const pattern of patterns) {
144
+ this.emitter.emit(pattern, data);
145
+ }
146
+ }
147
+ }
148
+ sendSubscriptionUpdate() {
149
+ const subscriptions = Array.from(this.refCounts.keys()).map((stream) => {
150
+ if (stream === MiniappStreamType.LOCATION_UPDATE)
151
+ return { stream: "location_stream", rate: "realtime" };
152
+ const forceLocalRefs = this.forceLocalRefCounts.get(stream) ?? 0;
153
+ if (forceLocalRefs === 0)
154
+ return stream;
155
+ const totalRefs = this.refCounts.get(stream) ?? 0;
156
+ return {
157
+ stream,
158
+ forceLocal: true,
159
+ ...(totalRefs > forceLocalRefs ? { includeCloud: true } : {}),
160
+ };
161
+ });
162
+ this.session.sendOneShot({
163
+ type: MiniappRequestType.SUBSCRIBE,
164
+ subscriptions,
165
+ });
166
+ }
167
+ }
168
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/modules/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAC,YAAY,EAAC,MAAM,eAAe,CAAA;AAE1C,OAAO,EAAC,kBAAkB,EAAE,iBAAiB,EAAC,MAAM,aAAa,CAAA;AA6HjE,8EAA8E;AAC9E,WAAW;AACX,8EAA8E;AAE9E,MAAM,OAAO,YAAY;IAOvB,YAA6B,OA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AW,CAAC;YACvB,IAAI,EAAE,kBAAkB,CAAC,SAAS;YAClC,aAAa;SACd,CAAC,CAAA;IACJ,CAAC;CACF"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @fileoverview GlassesModule — device-state events for the glasses themselves.
3
+ *
4
+ * Reports on the glasses hardware: battery level + charging state, connection
5
+ * status (connected/disconnected, model name). The phone has its own battery
6
+ * + connection events on `session.phone`.
7
+ */
8
+ import { MiniappSession } from "../session";
9
+ import type { BatteryData, ConnectionData, UnsubscribeFn, WifiData } from "./events";
10
+ export declare class GlassesModule {
11
+ private readonly session;
12
+ constructor(session: MiniappSession);
13
+ onBattery(handler: (data: BatteryData) => void): UnsubscribeFn;
14
+ onConnection(handler: (data: ConnectionData) => void): UnsubscribeFn;
15
+ /**
16
+ * Subscribe to glasses Wi-Fi state. Fires the current state on subscribe and
17
+ * on every change. `connected` is false on glasses without Wi-Fi. Streaming
18
+ * requires Wi-Fi — pair this with {@link requestWifiSetup} to prompt the user.
19
+ */
20
+ onWifi(handler: (data: WifiData) => void): UnsubscribeFn;
21
+ /**
22
+ * Ask the host to open the glasses Wi-Fi setup flow on the phone. Mirrors the
23
+ * cloud SDK's `session.requestWifiSetup(reason)`. `reason` is a user-facing
24
+ * line shown in the setup prompt (e.g. "Streaming needs your glasses on Wi-Fi").
25
+ */
26
+ requestWifiSetup(reason?: string): Promise<void>;
27
+ }
28
+ //# sourceMappingURL=glasses.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glasses.d.ts","sourceRoot":"","sources":["../../src/modules/glasses.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAA;AACzC,OAAO,KAAK,EAAC,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,QAAQ,EAAC,MAAM,UAAU,CAAA;AAElF,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,cAAc;IAEpD,SAAS,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,GAAG,aAAa;IAI9D,YAAY,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,GAAG,aAAa;IAIpE;;;;OAIG;IACH,MAAM,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,GAAG,aAAa;IAIxD;;;;OAIG;IACG,gBAAgB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAMvD"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @fileoverview GlassesModule — device-state events for the glasses themselves.
3
+ *
4
+ * Reports on the glasses hardware: battery level + charging state, connection
5
+ * status (connected/disconnected, model name). The phone has its own battery
6
+ * + connection events on `session.phone`.
7
+ */
8
+ import { MiniappRequestType, MiniappStreamType } from "../protocol";
9
+ export class GlassesModule {
10
+ constructor(session) {
11
+ this.session = session;
12
+ }
13
+ onBattery(handler) {
14
+ return this.session._subscribe(MiniappStreamType.GLASSES_BATTERY, handler);
15
+ }
16
+ onConnection(handler) {
17
+ return this.session._subscribe(MiniappStreamType.GLASSES_CONNECTION, handler);
18
+ }
19
+ /**
20
+ * Subscribe to glasses Wi-Fi state. Fires the current state on subscribe and
21
+ * on every change. `connected` is false on glasses without Wi-Fi. Streaming
22
+ * requires Wi-Fi — pair this with {@link requestWifiSetup} to prompt the user.
23
+ */
24
+ onWifi(handler) {
25
+ return this.session._subscribe(MiniappStreamType.GLASSES_WIFI, handler);
26
+ }
27
+ /**
28
+ * Ask the host to open the glasses Wi-Fi setup flow on the phone. Mirrors the
29
+ * cloud SDK's `session.requestWifiSetup(reason)`. `reason` is a user-facing
30
+ * line shown in the setup prompt (e.g. "Streaming needs your glasses on Wi-Fi").
31
+ */
32
+ async requestWifiSetup(reason) {
33
+ await this.session.sendRequest({
34
+ type: MiniappRequestType.REQUEST_WIFI_SETUP,
35
+ reason,
36
+ });
37
+ }
38
+ }
39
+ //# sourceMappingURL=glasses.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glasses.js","sourceRoot":"","sources":["../../src/modules/glasses.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAC,kBAAkB,EAAE,iBAAiB,EAAC,MAAM,aAAa,CAAA;AAIjE,MAAM,OAAO,aAAa;IACxB,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;IAAG,CAAC;IAExD,SAAS,CAAC,OAAoC;QAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAC,eAAe,EAAE,OAAkC,CAAC,CAAA;IACvG,CAAC;IAED,YAAY,CAAC,OAAuC;QAClD,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAC,kBAAkB,EAAE,OAAkC,CAAC,CAAA;IAC1G,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,OAAiC;QACtC,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAC,YAAY,EAAE,OAAkC,CAAC,CAAA;IACpG,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,gBAAgB,CAAC,MAAe;QACpC,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAAO;YACnC,IAAI,EAAE,kBAAkB,CAAC,kBAAkB;YAC3C,MAAM;SACP,CAAC,CAAA;IACJ,CAAC;CACF"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @fileoverview HeadingModule — phone compass heading events.
3
+ *
4
+ * Works on both Android and iOS. LOCATION permission must be declared in miniapp.json.
5
+ */
6
+ import { MiniappSession } from "../session";
7
+ import type { HeadingData, UnsubscribeFn } from "./events";
8
+ export declare class HeadingModule {
9
+ private readonly session;
10
+ constructor(session: MiniappSession);
11
+ /** True iff `LOCATION` is declared in the miniapp's manifest. */
12
+ get hasPermission(): boolean;
13
+ /** Subscribe to continuous compass heading updates. */
14
+ onUpdate(handler: (data: HeadingData) => void): UnsubscribeFn;
15
+ }
16
+ //# sourceMappingURL=heading.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"heading.d.ts","sourceRoot":"","sources":["../../src/modules/heading.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAA;AACzC,OAAO,KAAK,EAAC,WAAW,EAAE,aAAa,EAAC,MAAM,UAAU,CAAA;AAExD,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,cAAc;IAEpD,iEAAiE;IACjE,IAAI,aAAa,IAAI,OAAO,CAE3B;IAED,uDAAuD;IACvD,QAAQ,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,GAAG,aAAa;CAG9D"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @fileoverview HeadingModule — phone compass heading events.
3
+ *
4
+ * Works on both Android and iOS. LOCATION permission must be declared in miniapp.json.
5
+ */
6
+ import { MiniappStreamType } from "../protocol";
7
+ export class HeadingModule {
8
+ constructor(session) {
9
+ this.session = session;
10
+ }
11
+ /** True iff `LOCATION` is declared in the miniapp's manifest. */
12
+ get hasPermission() {
13
+ return this.session._hasManifestPermission("LOCATION");
14
+ }
15
+ /** Subscribe to continuous compass heading updates. */
16
+ onUpdate(handler) {
17
+ return this.session._subscribe(MiniappStreamType.HEADING_UPDATE, handler);
18
+ }
19
+ }
20
+ //# sourceMappingURL=heading.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"heading.js","sourceRoot":"","sources":["../../src/modules/heading.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,iBAAiB,EAAC,MAAM,aAAa,CAAA;AAI7C,MAAM,OAAO,aAAa;IACxB,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;IAAG,CAAC;IAExD,iEAAiE;IACjE,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,UAAU,CAAC,CAAA;IACxD,CAAC;IAED,uDAAuD;IACvD,QAAQ,CAAC,OAAoC;QAC3C,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAC,cAAc,EAAE,OAAkC,CAAC,CAAA;IACtG,CAAC;CACF"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @fileoverview ImuModule — head position + motion events.
3
+ *
4
+ * Glasses' inertial measurement unit. Exposes head-up/down position and a
5
+ * raw accelerometer stream (`onAccel`). Gyroscope / magnetometer / fused
6
+ * orientation are future work — when added they'll surface as a combined IMU
7
+ * event rather than extending this single-sensor accel stream.
8
+ */
9
+ import { MiniappSession } from "../session";
10
+ import type { AccelData, HeadPositionData, UnsubscribeFn } from "./events";
11
+ export declare class ImuModule {
12
+ private readonly session;
13
+ constructor(session: MiniappSession);
14
+ onHeadPosition(handler: (data: HeadPositionData) => void): UnsubscribeFn;
15
+ /**
16
+ * Subscribe to raw accelerometer readings (`{x, y, z}` in g) from the
17
+ * glasses IMU. G2 only today; on glasses without an exposed IMU stream the
18
+ * subscription succeeds but no events fire.
19
+ */
20
+ onAccel(handler: (data: AccelData) => void): UnsubscribeFn;
21
+ /**
22
+ * Explicitly enable or disable raw accelerometer streaming on the glasses.
23
+ *
24
+ * Subscribing via `onAccel` already auto-enables the sensor and unsubscribing
25
+ * disables it, so most callers don't need this. Use it when you want to drive
26
+ * the IMU directly — e.g. a diagnostic toggle. G2 only today; a no-op on
27
+ * glasses without an exposed IMU stream.
28
+ */
29
+ setEnabled(enabled: boolean): Promise<void>;
30
+ }
31
+ //# sourceMappingURL=imu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imu.d.ts","sourceRoot":"","sources":["../../src/modules/imu.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAA;AACzC,OAAO,KAAK,EAAC,SAAS,EAAE,gBAAgB,EAAE,aAAa,EAAC,MAAM,UAAU,CAAA;AAExE,qBAAa,SAAS;IACR,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,cAAc;IAEpD,cAAc,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,GAAG,aAAa;IAIxE;;;;OAIG;IACH,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,GAAG,aAAa;IAI1D;;;;;;;OAOG;IACH,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAM5C"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @fileoverview ImuModule — head position + motion events.
3
+ *
4
+ * Glasses' inertial measurement unit. Exposes head-up/down position and a
5
+ * raw accelerometer stream (`onAccel`). Gyroscope / magnetometer / fused
6
+ * orientation are future work — when added they'll surface as a combined IMU
7
+ * event rather than extending this single-sensor accel stream.
8
+ */
9
+ import { MiniappRequestType, MiniappStreamType } from "../protocol";
10
+ export class ImuModule {
11
+ constructor(session) {
12
+ this.session = session;
13
+ }
14
+ onHeadPosition(handler) {
15
+ return this.session._subscribe(MiniappStreamType.HEAD_POSITION, handler);
16
+ }
17
+ /**
18
+ * Subscribe to raw accelerometer readings (`{x, y, z}` in g) from the
19
+ * glasses IMU. G2 only today; on glasses without an exposed IMU stream the
20
+ * subscription succeeds but no events fire.
21
+ */
22
+ onAccel(handler) {
23
+ return this.session._subscribe(MiniappStreamType.ACCEL_DATA, handler);
24
+ }
25
+ /**
26
+ * Explicitly enable or disable raw accelerometer streaming on the glasses.
27
+ *
28
+ * Subscribing via `onAccel` already auto-enables the sensor and unsubscribing
29
+ * disables it, so most callers don't need this. Use it when you want to drive
30
+ * the IMU directly — e.g. a diagnostic toggle. G2 only today; a no-op on
31
+ * glasses without an exposed IMU stream.
32
+ */
33
+ setEnabled(enabled) {
34
+ return this.session.sendRequest({
35
+ type: MiniappRequestType.IMU_SET_ENABLED,
36
+ enabled,
37
+ });
38
+ }
39
+ }
40
+ //# sourceMappingURL=imu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imu.js","sourceRoot":"","sources":["../../src/modules/imu.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAC,kBAAkB,EAAE,iBAAiB,EAAC,MAAM,aAAa,CAAA;AAIjE,MAAM,OAAO,SAAS;IACpB,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;IAAG,CAAC;IAExD,cAAc,CAAC,OAAyC;QACtD,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAC,aAAa,EAAE,OAAkC,CAAC,CAAA;IACrG,CAAC;IAED;;;;OAIG;IACH,OAAO,CAAC,OAAkC;QACxC,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAC,UAAU,EAAE,OAAkC,CAAC,CAAA;IAClG,CAAC;IAED;;;;;;;OAOG;IACH,UAAU,CAAC,OAAgB;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAO;YACpC,IAAI,EAAE,kBAAkB,CAAC,eAAe;YACxC,OAAO;SACR,CAAC,CAAA;IACJ,CAAC;CACF"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @fileoverview InputModule — physical control events on the glasses.
3
+ *
4
+ * Combines button + touch surfaces. Future input modes (gesture, voice
5
+ * command, eye tracking) will extend this module rather than spawning new
6
+ * top-level modules.
7
+ *
8
+ * Touch overloads:
9
+ *
10
+ * session.input.onTouch(handler)
11
+ * session.input.onTouch("single_tap", handler)
12
+ * session.input.onTouch(["swipe_up", "swipe_down"], handler)
13
+ *
14
+ * Per-gesture filtering rides on `touch_event:<gesture>` stream variants
15
+ * the phone runtime fans out alongside the bare `touch_event` stream.
16
+ */
17
+ import { MiniappSession } from "../session";
18
+ import type { ButtonPressData, TouchData, UnsubscribeFn } from "./events";
19
+ export declare class InputModule {
20
+ private readonly session;
21
+ constructor(session: MiniappSession);
22
+ onButtonPress(handler: (data: ButtonPressData) => void): UnsubscribeFn;
23
+ /**
24
+ * Subscribe to touch events.
25
+ *
26
+ * onTouch(handler) — all touch events
27
+ * onTouch("single_tap", handler) — only single taps
28
+ * onTouch(["a","b"], handler) — multiple gestures, single subscription
29
+ */
30
+ onTouch(handler: (data: TouchData) => void): UnsubscribeFn;
31
+ onTouch(gesture: string, handler: (data: TouchData) => void): UnsubscribeFn;
32
+ onTouch(gestures: string[], handler: (data: TouchData) => void): UnsubscribeFn;
33
+ }
34
+ //# sourceMappingURL=input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/modules/input.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAA;AACzC,OAAO,KAAK,EAAC,eAAe,EAAE,SAAS,EAAE,aAAa,EAAC,MAAM,UAAU,CAAA;AAEvE,qBAAa,WAAW;IACV,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,cAAc;IAEpD,aAAa,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,IAAI,GAAG,aAAa;IAItE;;;;;;OAMG;IACH,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,GAAG,aAAa;IAC1D,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,GAAG,aAAa;IAC3E,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,GAAG,aAAa;CAiC/E"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * @fileoverview InputModule — physical control events on the glasses.
3
+ *
4
+ * Combines button + touch surfaces. Future input modes (gesture, voice
5
+ * command, eye tracking) will extend this module rather than spawning new
6
+ * top-level modules.
7
+ *
8
+ * Touch overloads:
9
+ *
10
+ * session.input.onTouch(handler)
11
+ * session.input.onTouch("single_tap", handler)
12
+ * session.input.onTouch(["swipe_up", "swipe_down"], handler)
13
+ *
14
+ * Per-gesture filtering rides on `touch_event:<gesture>` stream variants
15
+ * the phone runtime fans out alongside the bare `touch_event` stream.
16
+ */
17
+ import { MiniappStreamType } from "../protocol";
18
+ export class InputModule {
19
+ constructor(session) {
20
+ this.session = session;
21
+ }
22
+ onButtonPress(handler) {
23
+ return this.session._subscribe(MiniappStreamType.BUTTON_PRESS, handler);
24
+ }
25
+ onTouch(gestureOrHandler, maybeHandler) {
26
+ // Plain handler — subscribe to all touches.
27
+ if (typeof gestureOrHandler === "function") {
28
+ return this.session._subscribe(MiniappStreamType.TOUCH_EVENT, gestureOrHandler);
29
+ }
30
+ const handler = maybeHandler;
31
+ const gestures = Array.isArray(gestureOrHandler) ? gestureOrHandler : [gestureOrHandler];
32
+ if (gestures.length === 0)
33
+ return () => { };
34
+ const unsubs = [];
35
+ for (const g of gestures) {
36
+ unsubs.push(this.session._subscribe(`${MiniappStreamType.TOUCH_EVENT}:${g}`, handler));
37
+ }
38
+ return () => {
39
+ for (const u of unsubs) {
40
+ try {
41
+ u();
42
+ }
43
+ catch {
44
+ /* ignore */
45
+ }
46
+ }
47
+ };
48
+ }
49
+ }
50
+ //# sourceMappingURL=input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input.js","sourceRoot":"","sources":["../../src/modules/input.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAC,iBAAiB,EAAC,MAAM,aAAa,CAAA;AAI7C,MAAM,OAAO,WAAW;IACtB,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;IAAG,CAAC;IAExD,aAAa,CAAC,OAAwC;QACpD,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAC,YAAY,EAAE,OAAkC,CAAC,CAAA;IACpG,CAAC;IAYD,OAAO,CACL,gBAAiE,EACjE,YAAwC;QAExC,4CAA4C;QAC5C,IAAI,OAAO,gBAAgB,KAAK,UAAU,EAAE,CAAC;YAC3C,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAC5B,iBAAiB,CAAC,WAAW,EAC7B,gBAA2C,CAC5C,CAAA;QACH,CAAC;QAED,MAAM,OAAO,GAAG,YAAa,CAAA;QAC7B,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAA;QACxF,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,GAAG,EAAE,GAAE,CAAC,CAAA;QAE1C,MAAM,MAAM,GAAoB,EAAE,CAAA;QAClC,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;YACzB,MAAM,CAAC,IAAI,CACT,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,iBAAiB,CAAC,WAAW,IAAI,CAAC,EAAE,EAAE,OAAkC,CAAC,CACrG,CAAA;QACH,CAAC;QACD,OAAO,GAAG,EAAE;YACV,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;gBACvB,IAAI,CAAC;oBACH,CAAC,EAAE,CAAA;gBACL,CAAC;gBAAC,MAAM,CAAC;oBACP,YAAY;gBACd,CAAC;YACH,CAAC;QACH,CAAC,CAAA;IACH,CAAC;CACF"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @fileoverview LedModule — glasses RGB LED control.
3
+ *
4
+ * API mirrors the cloud SDK's LED module. Colors are named strings
5
+ * (the phone maps them to per-device LED indices). Actions are "on" / "off".
6
+ */
7
+ import { MiniappSession } from "../session";
8
+ export type LedColor = "red" | "green" | "blue" | "orange" | "white";
9
+ export type LedControlResult = {
10
+ type?: "rgb_led_control_response";
11
+ state: "success";
12
+ requestId: string;
13
+ };
14
+ export interface LedControlOptions {
15
+ color?: LedColor;
16
+ /** LED on duration in ms. */
17
+ ontime?: number;
18
+ /** LED off duration in ms. */
19
+ offtime?: number;
20
+ /** Number of on/off cycles. */
21
+ count?: number;
22
+ }
23
+ export declare class LedModule {
24
+ private readonly session;
25
+ constructor(session: MiniappSession);
26
+ /** Turn an LED on with the given pattern. Resolves after the glasses acknowledge the command. */
27
+ turnOn(options?: LedControlOptions): Promise<LedControlResult>;
28
+ /** Turn all LEDs off. Resolves after the glasses acknowledge the command. */
29
+ turnOff(): Promise<LedControlResult>;
30
+ /** Blink pattern — repeats `count` times with ontime/offtime. */
31
+ blink(color: LedColor, ontime: number, offtime: number, count: number): Promise<LedControlResult>;
32
+ /** Solid LED for a fixed duration. */
33
+ solid(color: LedColor, duration: number): Promise<LedControlResult>;
34
+ }
35
+ //# sourceMappingURL=led.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"led.d.ts","sourceRoot":"","sources":["../../src/modules/led.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAA;AAEzC,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAA;AAEpE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,CAAC,EAAE,0BAA0B,CAAA;IACjC,KAAK,EAAE,SAAS,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,QAAQ,CAAA;IAChB,6BAA6B;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,8BAA8B;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,+BAA+B;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,qBAAa,SAAS;IACR,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,cAAc;IAEpD,iGAAiG;IAC3F,MAAM,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAWxE,6EAA6E;IACvE,OAAO,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAO1C,iEAAiE;IAC3D,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAIvG,sCAAsC;IAChC,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAG1E"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @fileoverview LedModule — glasses RGB LED control.
3
+ *
4
+ * API mirrors the cloud SDK's LED module. Colors are named strings
5
+ * (the phone maps them to per-device LED indices). Actions are "on" / "off".
6
+ */
7
+ import { MiniappRequestType } from "../protocol";
8
+ export class LedModule {
9
+ constructor(session) {
10
+ this.session = session;
11
+ }
12
+ /** Turn an LED on with the given pattern. Resolves after the glasses acknowledge the command. */
13
+ async turnOn(options = {}) {
14
+ return this.session.sendRequest({
15
+ type: MiniappRequestType.RGB_LED,
16
+ action: "on",
17
+ color: options.color ?? "red",
18
+ ontime: options.ontime ?? 1000,
19
+ offtime: options.offtime ?? 0,
20
+ count: options.count ?? 1,
21
+ });
22
+ }
23
+ /** Turn all LEDs off. Resolves after the glasses acknowledge the command. */
24
+ async turnOff() {
25
+ return this.session.sendRequest({
26
+ type: MiniappRequestType.RGB_LED,
27
+ action: "off",
28
+ });
29
+ }
30
+ /** Blink pattern — repeats `count` times with ontime/offtime. */
31
+ async blink(color, ontime, offtime, count) {
32
+ return this.turnOn({ color, ontime, offtime, count });
33
+ }
34
+ /** Solid LED for a fixed duration. */
35
+ async solid(color, duration) {
36
+ return this.turnOn({ color, ontime: duration, offtime: 0, count: 1 });
37
+ }
38
+ }
39
+ //#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,CAAA;IACrE,CAAC;CACF"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @fileoverview LocationModule — phone location events.
3
+ *
4
+ * Exposes both a continuous `onUpdate` subscription and a one-shot
5
+ * `getOnce()` poll over `MiniappRequestType.LOCATION_POLL`.
6
+ *
7
+ * LOCATION permission must be declared in miniapp.json for either path to
8
+ * succeed; the phone runtime rejects with PERMISSION_NOT_DECLARED
9
+ * otherwise.
10
+ */
11
+ import { MiniappSession } from "../session";
12
+ import type { LocationData, UnsubscribeFn } from "./events";
13
+ export declare class LocationModule {
14
+ private readonly session;
15
+ constructor(session: MiniappSession);
16
+ /** True iff `LOCATION` is declared in the miniapp's manifest. */
17
+ get hasPermission(): boolean;
18
+ /** Subscribe to continuous location updates. */
19
+ onUpdate(handler: (data: LocationData) => void): UnsubscribeFn;
20
+ /**
21
+ * Request a single location fix. Resolves with the next available
22
+ * reading from the phone. Useful at app load to seed UI before a
23
+ * continuous stream of updates begins.
24
+ */
25
+ getOnce(): Promise<LocationData>;
26
+ }
27
+ //# sourceMappingURL=location.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"location.d.ts","sourceRoot":"","sources":["../../src/modules/location.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAA;AACzC,OAAO,KAAK,EAAC,YAAY,EAAE,aAAa,EAAC,MAAM,UAAU,CAAA;AAEzD,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,cAAc;IAEpD,iEAAiE;IACjE,IAAI,aAAa,IAAI,OAAO,CAE3B;IAED,gDAAgD;IAChD,QAAQ,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,GAAG,aAAa;IAI9D;;;;OAIG;IACH,OAAO,IAAI,OAAO,CAAC,YAAY,CAAC;CAKjC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @fileoverview LocationModule — phone location events.
3
+ *
4
+ * Exposes both a continuous `onUpdate` subscription and a one-shot
5
+ * `getOnce()` poll over `MiniappRequestType.LOCATION_POLL`.
6
+ *
7
+ * LOCATION permission must be declared in miniapp.json for either path to
8
+ * succeed; the phone runtime rejects with PERMISSION_NOT_DECLARED
9
+ * otherwise.
10
+ */
11
+ import { MiniappRequestType, MiniappStreamType } from "../protocol";
12
+ export class LocationModule {
13
+ constructor(session) {
14
+ this.session = session;
15
+ }
16
+ /** True iff `LOCATION` is declared in the miniapp's manifest. */
17
+ get hasPermission() {
18
+ return this.session._hasManifestPermission("LOCATION");
19
+ }
20
+ /** Subscribe to continuous location updates. */
21
+ onUpdate(handler) {
22
+ return this.session._subscribe(MiniappStreamType.LOCATION_UPDATE, handler);
23
+ }
24
+ /**
25
+ * Request a single location fix. Resolves with the next available
26
+ * reading from the phone. Useful at app load to seed UI before a
27
+ * continuous stream of updates begins.
28
+ */
29
+ getOnce() {
30
+ return this.session.sendRequest({
31
+ type: MiniappRequestType.LOCATION_POLL,
32
+ });
33
+ }
34
+ }
35
+ //# sourceMappingURL=location.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"location.js","sourceRoot":"","sources":["../../src/modules/location.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAC,kBAAkB,EAAE,iBAAiB,EAAC,MAAM,aAAa,CAAA;AAIjE,MAAM,OAAO,cAAc;IACzB,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;IAAG,CAAC;IAExD,iEAAiE;IACjE,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,UAAU,CAAC,CAAA;IACxD,CAAC;IAED,gDAAgD;IAChD,QAAQ,CAAC,OAAqC;QAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAC,eAAe,EAAE,OAAkC,CAAC,CAAA;IACvG,CAAC;IAED;;;;OAIG;IACH,OAAO;QACL,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAe;YAC5C,IAAI,EAAE,kBAAkB,CAAC,aAAa;SACvC,CAAC,CAAA;IACJ,CAAC;CACF"}