@glassly/engine 0.3.7 → 0.3.8-dev.976

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 (176) hide show
  1. package/README.md +4 -0
  2. package/build/engine.d.ts +8 -2
  3. package/build/engine.d.ts.map +1 -1
  4. package/build/engine.js +7 -4
  5. package/build/engine.js.map +1 -1
  6. package/build/facades/backup.d.ts +14 -0
  7. package/build/facades/backup.d.ts.map +1 -0
  8. package/build/facades/backup.js +22 -0
  9. package/build/facades/backup.js.map +1 -0
  10. package/build/facades/glasses.d.ts +4 -4
  11. package/build/facades/glasses.d.ts.map +1 -1
  12. package/build/facades/glasses.js +4 -4
  13. package/build/facades/glasses.js.map +1 -1
  14. package/build/generated/releaseMetadata.js +4 -4
  15. package/build/generated/releaseMetadata.js.map +1 -1
  16. package/build/index.d.ts +1 -0
  17. package/build/index.d.ts.map +1 -1
  18. package/build/index.js.map +1 -1
  19. package/build/services/AppRegistry.d.ts +2 -1
  20. package/build/services/AppRegistry.d.ts.map +1 -1
  21. package/build/services/AppRegistry.js +38 -8
  22. package/build/services/AppRegistry.js.map +1 -1
  23. package/build/services/AppStateBackup.d.ts +98 -0
  24. package/build/services/AppStateBackup.d.ts.map +1 -0
  25. package/build/services/AppStateBackup.js +224 -0
  26. package/build/services/AppStateBackup.js.map +1 -0
  27. package/build/services/BlobStore.d.ts.map +1 -1
  28. package/build/services/BlobStore.js +5 -12
  29. package/build/services/BlobStore.js.map +1 -1
  30. package/build/services/CloudClientService.d.ts +1 -0
  31. package/build/services/CloudClientService.d.ts.map +1 -1
  32. package/build/services/CloudClientService.js +34 -2
  33. package/build/services/CloudClientService.js.map +1 -1
  34. package/build/services/DisplayProcessor.d.ts +2 -0
  35. package/build/services/DisplayProcessor.d.ts.map +1 -1
  36. package/build/services/DisplayProcessor.js +15 -1
  37. package/build/services/DisplayProcessor.js.map +1 -1
  38. package/build/services/GlassesTouchInput.d.ts.map +1 -1
  39. package/build/services/GlassesTouchInput.js +4 -2
  40. package/build/services/GlassesTouchInput.js.map +1 -1
  41. package/build/services/JSCrashloopReportService.d.ts.map +1 -1
  42. package/build/services/JSCrashloopReportService.js +5 -0
  43. package/build/services/JSCrashloopReportService.js.map +1 -1
  44. package/build/services/JSRouter.d.ts +11 -3
  45. package/build/services/JSRouter.d.ts.map +1 -1
  46. package/build/services/JSRouter.js +36 -6
  47. package/build/services/JSRouter.js.map +1 -1
  48. package/build/services/LocalMiniappRuntime.d.ts +13 -0
  49. package/build/services/LocalMiniappRuntime.d.ts.map +1 -1
  50. package/build/services/LocalMiniappRuntime.js +54 -20
  51. package/build/services/LocalMiniappRuntime.js.map +1 -1
  52. package/build/services/MiniappEngine.d.ts +9 -0
  53. package/build/services/MiniappEngine.d.ts.map +1 -1
  54. package/build/services/MiniappEngine.js +60 -27
  55. package/build/services/MiniappEngine.js.map +1 -1
  56. package/build/services/MiniappLauncher.d.ts +2 -0
  57. package/build/services/MiniappLauncher.d.ts.map +1 -1
  58. package/build/services/MiniappLauncher.js +6 -0
  59. package/build/services/MiniappLauncher.js.map +1 -1
  60. package/build/services/NavigationService.d.ts +1 -0
  61. package/build/services/NavigationService.d.ts.map +1 -1
  62. package/build/services/NavigationService.js +20 -6
  63. package/build/services/NavigationService.js.map +1 -1
  64. package/build/services/PhoneCalendarService.d.ts.map +1 -1
  65. package/build/services/PhoneCalendarService.js +8 -0
  66. package/build/services/PhoneCalendarService.js.map +1 -1
  67. package/build/services/PhoneNotificationsSync.d.ts.map +1 -1
  68. package/build/services/PhoneNotificationsSync.js +7 -3
  69. package/build/services/PhoneNotificationsSync.js.map +1 -1
  70. package/build/services/SceneRenderer.js +1 -1
  71. package/build/services/SceneRenderer.js.map +1 -1
  72. package/build/services/appStateBackupFile.d.ts +32 -0
  73. package/build/services/appStateBackupFile.d.ts.map +1 -0
  74. package/build/services/appStateBackupFile.js +135 -0
  75. package/build/services/appStateBackupFile.js.map +1 -0
  76. package/build/services/controllers.d.ts.map +1 -1
  77. package/build/services/controllers.js +11 -3
  78. package/build/services/controllers.js.map +1 -1
  79. package/build/services/effectiveCapabilities.js +3 -0
  80. package/build/services/effectiveCapabilities.js.map +1 -1
  81. package/build/services/pages/pageEligibility.d.ts.map +1 -1
  82. package/build/services/pages/pageEligibility.js +8 -1
  83. package/build/services/pages/pageEligibility.js.map +1 -1
  84. package/build/services/settingsBridge.d.ts.map +1 -1
  85. package/build/services/settingsBridge.js +1 -0
  86. package/build/services/settingsBridge.js.map +1 -1
  87. package/build/services/{appleWatch/AppleWatchLink.d.ts → watch/WatchLink.d.ts} +8 -7
  88. package/build/services/watch/WatchLink.d.ts.map +1 -0
  89. package/build/services/{appleWatch/AppleWatchLink.js → watch/WatchLink.js} +14 -15
  90. package/build/services/watch/WatchLink.js.map +1 -0
  91. package/build/stores/apps.d.ts.map +1 -1
  92. package/build/stores/apps.js +14 -2
  93. package/build/stores/apps.js.map +1 -1
  94. package/build/stores/settings.d.ts.map +1 -1
  95. package/build/stores/settings.js +45 -3
  96. package/build/stores/settings.js.map +1 -1
  97. package/build/types/capabilities/even-realities-g1.d.ts.map +1 -1
  98. package/build/types/capabilities/even-realities-g1.js +3 -0
  99. package/build/types/capabilities/even-realities-g1.js.map +1 -1
  100. package/build/types/capabilities/memomind-one.d.ts +3 -0
  101. package/build/types/capabilities/memomind-one.d.ts.map +1 -0
  102. package/build/types/capabilities/memomind-one.js +41 -0
  103. package/build/types/capabilities/memomind-one.js.map +1 -0
  104. package/build/types/enums.d.ts +6 -2
  105. package/build/types/enums.d.ts.map +1 -1
  106. package/build/types/enums.js +4 -0
  107. package/build/types/enums.js.map +1 -1
  108. package/build/types/hardware.d.ts +3 -1
  109. package/build/types/hardware.d.ts.map +1 -1
  110. package/build/types/hardware.js +3 -1
  111. package/build/types/hardware.js.map +1 -1
  112. package/build/utils/display/index.d.ts +2 -1
  113. package/build/utils/display/index.d.ts.map +1 -1
  114. package/build/utils/display/index.js +3 -2
  115. package/build/utils/display/index.js.map +1 -1
  116. package/build/utils/display/profiles/index.d.ts +2 -1
  117. package/build/utils/display/profiles/index.d.ts.map +1 -1
  118. package/build/utils/display/profiles/index.js +3 -2
  119. package/build/utils/display/profiles/index.js.map +1 -1
  120. package/build/utils/display/profiles/rayneo-io.d.ts +1 -1
  121. package/build/utils/display/profiles/rayneo-io.d.ts.map +1 -1
  122. package/build/utils/display/profiles/rayneo-io.js +1 -1
  123. package/build/utils/display/profiles/rayneo-io.js.map +1 -1
  124. package/build/utils/display/scene/index.d.ts +1 -1
  125. package/build/utils/display/scene/index.d.ts.map +1 -1
  126. package/build/utils/display/scene/index.js +1 -1
  127. package/build/utils/display/scene/index.js.map +1 -1
  128. package/build/utils/display/scene/process.d.ts +6 -0
  129. package/build/utils/display/scene/process.d.ts.map +1 -1
  130. package/build/utils/display/scene/process.js +22 -7
  131. package/build/utils/display/scene/process.js.map +1 -1
  132. package/build/utils/miniappGlobals.d.ts +13 -17
  133. package/build/utils/miniappGlobals.d.ts.map +1 -1
  134. package/build/utils/miniappGlobals.js +24 -56
  135. package/build/utils/miniappGlobals.js.map +1 -1
  136. package/package.json +7 -7
  137. package/src/engine.ts +7 -4
  138. package/src/facades/backup.ts +28 -0
  139. package/src/facades/glasses.ts +5 -5
  140. package/src/generated/releaseMetadata.ts +4 -4
  141. package/src/index.ts +1 -0
  142. package/src/services/AppRegistry.ts +36 -9
  143. package/src/services/AppStateBackup.ts +283 -0
  144. package/src/services/BlobStore.ts +5 -11
  145. package/src/services/CloudClientService.ts +35 -4
  146. package/src/services/DisplayProcessor.ts +20 -8
  147. package/src/services/GlassesTouchInput.ts +6 -2
  148. package/src/services/JSCrashloopReportService.ts +5 -0
  149. package/src/services/JSRouter.ts +37 -6
  150. package/src/services/LocalMiniappRuntime.ts +55 -20
  151. package/src/services/MiniappEngine.ts +62 -27
  152. package/src/services/MiniappLauncher.ts +7 -0
  153. package/src/services/NavigationService.ts +28 -8
  154. package/src/services/PhoneCalendarService.ts +7 -0
  155. package/src/services/PhoneNotificationsSync.ts +8 -3
  156. package/src/services/SceneRenderer.ts +1 -1
  157. package/src/services/appStateBackupFile.ts +171 -0
  158. package/src/services/controllers.ts +12 -3
  159. package/src/services/effectiveCapabilities.ts +3 -0
  160. package/src/services/pages/pageEligibility.ts +9 -1
  161. package/src/services/settingsBridge.ts +1 -0
  162. package/src/services/{appleWatch/AppleWatchLink.ts → watch/WatchLink.ts} +20 -20
  163. package/src/stores/apps.ts +13 -2
  164. package/src/stores/settings.ts +52 -7
  165. package/src/types/capabilities/even-realities-g1.ts +4 -0
  166. package/src/types/capabilities/memomind-one.ts +42 -0
  167. package/src/types/enums.ts +4 -0
  168. package/src/types/hardware.ts +14 -1
  169. package/src/utils/display/index.ts +4 -2
  170. package/src/utils/display/profiles/index.ts +9 -2
  171. package/src/utils/display/profiles/rayneo-io.ts +6 -1
  172. package/src/utils/display/scene/index.ts +1 -1
  173. package/src/utils/display/scene/process.ts +22 -7
  174. package/src/utils/miniappGlobals.ts +32 -64
  175. package/build/services/appleWatch/AppleWatchLink.d.ts.map +0 -1
  176. package/build/services/appleWatch/AppleWatchLink.js.map +0 -1
@@ -132,6 +132,17 @@ function withTimeout(promise, timeoutMs) {
132
132
  promise.then((value) => done(value), () => done(null));
133
133
  });
134
134
  }
135
+ /** Bounds the cold-GPS wait for a one-shot poll; on a stall, any older fix beats an error. */
136
+ const FRESH_LOCATION_TIMEOUT_MS = 8_000;
137
+ async function freshLocationOrStale() {
138
+ const fresh = await withTimeout(Location.getCurrentPositionAsync({ accuracy: Location.Accuracy.Low }), FRESH_LOCATION_TIMEOUT_MS);
139
+ if (fresh)
140
+ return fresh;
141
+ const stale = await Location.getLastKnownPositionAsync();
142
+ if (stale)
143
+ return stale;
144
+ throw new Error("No location fix available");
145
+ }
135
146
  const LOG_TAG = "LOCAL_MINIAPP";
136
147
  const DIAGNOSTIC_MAX_LIST_ITEMS = 100;
137
148
  const DIAGNOSTIC_MAX_STRING_LENGTH = 512;
@@ -152,6 +163,8 @@ const SYSTEM_MINIAPP_PACKAGES = new Set([
152
163
  "com.glassly.miniappdev",
153
164
  ]);
154
165
  const PING_INTERVAL_MS = 5_000;
166
+ /** How long a stopping miniapp's `beforeDisconnect` handlers get before teardown. */
167
+ const WILL_DISCONNECT_GRACE_MS = 100;
155
168
  // Min gap between "transcription limit reached" notices on the glasses. A
156
169
  // debounce, not a cooldown: the cloud re-announces the block per refused
157
170
  // subscribe, and miniapps retry in bursts — this only coalesces those bursts
@@ -981,20 +994,26 @@ class LocalMiniappRuntime {
981
994
  * undeliverable anyway.
982
995
  */
983
996
  async gracefullyUnregisterApp(packageName, reason = "unregistering") {
984
- const app = this.connectedApps.get(packageName);
985
- if (!app)
997
+ if (!this.connectedApps.has(packageName))
986
998
  return;
987
- console.log(`${LOG_TAG}: gracefullyUnregisterApp(${packageName}) — sending WILL_DISCONNECT`);
988
- this.sendToMiniapp(packageName, {
989
- type: MiniappResponseType.WILL_DISCONNECT,
990
- reason,
991
- });
992
- // 50 ms: imperceptible to the user, plenty of time for the SDK's
993
- // synchronous `beforeDisconnect` handlers to flush a final
994
- // sendOneShot through the still-open transport.
995
- await new Promise((resolve) => BgTimer.setTimeout(resolve, 50));
999
+ await this.notifyWillDisconnect(packageName, reason);
996
1000
  this.unregisterApp(packageName);
997
1001
  }
1002
+ /**
1003
+ * Send `WILL_DISCONNECT` and wait out the grace window, so the session's
1004
+ * `beforeDisconnect` handlers run (Navigation clears its HUD and ends its
1005
+ * trip) and their last messages land before teardown. No-op unless the
1006
+ * app finished its handshake.
1007
+ */
1008
+ async notifyWillDisconnect(packageName, reason) {
1009
+ if (!this.connectedApps.has(packageName) || !this.handshookApps.has(packageName))
1010
+ return;
1011
+ console.log(`${LOG_TAG}: ${packageName} — sending WILL_DISCONNECT (${reason})`);
1012
+ this.sendToMiniapp(packageName, { type: MiniappResponseType.WILL_DISCONNECT, reason });
1013
+ // The message and the replies it triggers each cross a JSContext hop;
1014
+ // short enough not to slow an app switch noticeably.
1015
+ await new Promise((resolve) => BgTimer.setTimeout(resolve, WILL_DISCONNECT_GRACE_MS));
1016
+ }
998
1017
  unregisterApp(packageName, opts) {
999
1018
  console.log(`${LOG_TAG}: unregisterApp(${packageName})`);
1000
1019
  const releasedMicGateOverride = micStateCoordinator.clearMiniappGateOverrides(packageName);
@@ -2966,7 +2985,7 @@ class LocalMiniappRuntime {
2966
2985
  const locationStartedAt = Date.now();
2967
2986
  const cached = await Location.getLastKnownPositionAsync({ maxAge: 60_000 });
2968
2987
  console.log(`${LOG_TAG}: location poll cache hit=${cached !== null} elapsed=${Date.now() - locationStartedAt}ms`);
2969
- const location = cached ?? (await Location.getCurrentPositionAsync({ accuracy: Location.Accuracy.Low }));
2988
+ const location = cached ?? (await freshLocationOrStale());
2970
2989
  console.log(`${LOG_TAG}: location poll resolved elapsed=${Date.now() - locationStartedAt}ms`);
2971
2990
  this.sendResult(packageName, requestId, true, {
2972
2991
  lat: location.coords.latitude,
@@ -5294,14 +5313,18 @@ class LocalMiniappRuntime {
5294
5313
  const app = this.interopApps().find((a) => a.packageName === packageName);
5295
5314
  if (!app)
5296
5315
  return false;
5297
- // Running only for its widget: start() promotes it to a normal run, as opening it on the phone does.
5298
- if (app.widgetOnly)
5299
- return useAppStatusStore.getState().start(app, { skipNavigation: true });
5300
- if (app.local) {
5301
- await miniappLauncher.ensureConnected(packageName);
5302
- return true;
5303
- }
5304
- return useAppStatusStore.getState().start(app, { skipNavigation: true });
5316
+ // session.miniapps.start comes from the glasses (the dashboard's Apps menu,
5317
+ // an Assist voice command), unlike a headless action wake, which carries no source.
5318
+ // The full start, as a phone open runs it: the standard peer stops so this
5319
+ // app owns the display, and an app already running hears the new launch.
5320
+ const launchSource = "glasses";
5321
+ const started = await useAppStatusStore.getState().start(app, { skipNavigation: true, launchSource });
5322
+ if (!started)
5323
+ return false;
5324
+ // The caller may message the app next; start() resolves at spawn.
5325
+ if (app.local)
5326
+ await miniappLauncher.ensureConnected(packageName, undefined, { launchSource });
5327
+ return true;
5305
5328
  }
5306
5329
  stopInteropApp(packageName) {
5307
5330
  return useAppStatusStore.getState().stop(packageName);
@@ -5979,6 +6002,17 @@ class LocalMiniappRuntime {
5979
6002
  }
5980
6003
  this.sendToMiniapp(packageName, { type: MiniappResponseType.LINK, params });
5981
6004
  }
6005
+ /**
6006
+ * Tell a running miniapp the user opened it again and from where. The
6007
+ * CONNECT_ACK only carries the source of the spawn, which is stale for a
6008
+ * background app that keeps running between opens.
6009
+ */
6010
+ sendLaunchChange(packageName, launchSource) {
6011
+ const existing = this.connectedApps.get(packageName);
6012
+ if (existing)
6013
+ existing.launchSource = launchSource;
6014
+ this.sendToMiniapp(packageName, { type: MiniappResponseType.LAUNCH_CHANGE, launchSource });
6015
+ }
5982
6016
  /**
5983
6017
  * Send a VISIBILITY_CHANGE push to a miniapp.
5984
6018
  */