@mentra/crust 3.3.0-dev.698 → 3.3.0-dev.709

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.
@@ -61,6 +61,13 @@ private struct PhotoLibrarySaveResult {
61
61
  let timedOut: Bool
62
62
  }
63
63
 
64
+ /// MentraJS calls get their own serial queue. Expo runs every module's default-queue
65
+ /// AsyncFunction on one shared serial queue, so a blocking call in another module held every
66
+ /// host→miniapp message behind it: the ~25s offline STT model extraction after login kept
67
+ /// miniapps from spawning and starved running ones of PINGs until the host respawned them.
68
+ /// Serial, so spawn, dispatch and kill still run in the order JS issued them.
69
+ private let mentraJsQueue = DispatchQueue(label: "com.mentra.mentrajs-bridge", qos: .userInitiated)
70
+
64
71
  public class CrustModule: Module {
65
72
  public func definition() -> ModuleDefinition {
66
73
  Name("Crust")
@@ -282,7 +289,7 @@ public class CrustModule: Module {
282
289
  polyfillBundle: polyfillBundle,
283
290
  miniappJs: miniappJs
284
291
  )
285
- }
292
+ }.runOnQueue(mentraJsQueue)
286
293
 
287
294
  /// Evaluate an arbitrary script inside the named context. Returns
288
295
  /// the JS return value bridged to a JSON-friendly Swift type, or
@@ -290,19 +297,19 @@ public class CrustModule: Module {
290
297
  /// + tests; production code paths use mentraJsDispatchToJs.
291
298
  AsyncFunction("mentraJsEvaluate") { (packageName: String, source: String) -> Any? in
292
299
  return JSCRuntime.shared.evaluate(packageName: packageName, source: source)
293
- }
300
+ }.runOnQueue(mentraJsQueue)
294
301
 
295
302
  /// Tear down a JS context. Cancels timers, drops refs, forces GC.
296
303
  AsyncFunction("mentraJsKill") { (packageName: String) -> Void in
297
304
  JSCRuntime.shared.kill(packageName: packageName)
298
- }
305
+ }.runOnQueue(mentraJsQueue)
299
306
 
300
307
  /// Push an event / response envelope into the named context's
301
308
  /// globalThis.__deliver. Used by MentraJSRouter for
302
309
  /// glasses-status broadcasts and request/response correlation.
303
310
  AsyncFunction("mentraJsDispatchToJs") { (packageName: String, envelope: [String: Any]) -> Void in
304
311
  JSCRuntime.shared.dispatchToJs(packageName: packageName, envelope: envelope)
305
- }
312
+ }.runOnQueue(mentraJsQueue)
306
313
 
307
314
  /// Set the installed manifest for a miniapp so the dispatcher's
308
315
  /// permission gate can authorize sensitive `__dispatch` calls.
@@ -311,7 +318,7 @@ public class CrustModule: Module {
311
318
  packageName: packageName,
312
319
  manifest: InstalledMiniappManifest(permissions: Set(permissions))
313
320
  )
314
- }
321
+ }.runOnQueue(mentraJsQueue)
315
322
 
316
323
  /// Diagnostic: list all live packageNames.
317
324
  Function("mentraJsAlivePackages") { () -> [String] in
@@ -323,7 +330,7 @@ public class CrustModule: Module {
323
330
  /// the context is dead.
324
331
  AsyncFunction("mentraJsDebugForceGC") { (packageName: String) -> Bool in
325
332
  return JSCRuntime.shared.debugForceGC(packageName: packageName)
326
- }
333
+ }.runOnQueue(mentraJsQueue)
327
334
 
328
335
  /// Read the bundled MentraJS polyfill (startup.js) from the iOS
329
336
  /// pod's resource bundle. The host calls this once on app boot,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mentra/crust",
3
- "version": "3.3.0-dev.698",
3
+ "version": "3.3.0-dev.709",
4
4
  "description": "Mentra Native Module",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -35,7 +35,7 @@
35
35
  "license": "Apache-2.0",
36
36
  "homepage": "https://github.com/Mentra-Community/MentraOS/tree/dev/mobile/modules/crust#readme",
37
37
  "dependencies": {
38
- "@mentra/jspolyfill": "3.3.0-dev.698"
38
+ "@mentra/jspolyfill": "3.3.0-dev.709"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@expo/config-plugins": ">=8.0.0",