@mentra/engine 3.1.0-dev.10 → 3.1.0-dev.102

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 (185) hide show
  1. package/README.md +24 -6
  2. package/build/bluetooth-sdk/ota-transport.d.ts +2 -0
  3. package/build/bluetooth-sdk/ota-transport.d.ts.map +1 -0
  4. package/build/bluetooth-sdk/ota-transport.js +2 -0
  5. package/build/bluetooth-sdk/ota-transport.js.map +1 -0
  6. package/build/engine.d.ts +5 -2
  7. package/build/engine.d.ts.map +1 -1
  8. package/build/facades/ota.d.ts +12 -7
  9. package/build/facades/ota.d.ts.map +1 -1
  10. package/build/facades/ota.js +10 -6
  11. package/build/facades/ota.js.map +1 -1
  12. package/build/facades/pairing.d.ts +4 -0
  13. package/build/facades/pairing.d.ts.map +1 -1
  14. package/build/facades/pairing.js +81 -7
  15. package/build/facades/pairing.js.map +1 -1
  16. package/build/generated/releaseMetadata.js +5 -5
  17. package/build/generated/releaseMetadata.js.map +1 -1
  18. package/build/index.d.ts +3 -3
  19. package/build/index.d.ts.map +1 -1
  20. package/build/index.js +2 -2
  21. package/build/index.js.map +1 -1
  22. package/build/react/MentraLiveOtaFlow.d.ts +8 -2
  23. package/build/react/MentraLiveOtaFlow.d.ts.map +1 -1
  24. package/build/react/MentraLiveOtaFlow.js +256 -354
  25. package/build/react/MentraLiveOtaFlow.js.map +1 -1
  26. package/build/react/index.d.ts +1 -0
  27. package/build/react/index.d.ts.map +1 -1
  28. package/build/react/index.js +1 -0
  29. package/build/react/index.js.map +1 -1
  30. package/build/react/useMentraLiveOta.d.ts +84 -0
  31. package/build/react/useMentraLiveOta.d.ts.map +1 -0
  32. package/build/react/useMentraLiveOta.js +627 -0
  33. package/build/react/useMentraLiveOta.js.map +1 -0
  34. package/build/services/BlobStore.d.ts +2 -0
  35. package/build/services/BlobStore.d.ts.map +1 -1
  36. package/build/services/BlobStore.js +63 -10
  37. package/build/services/BlobStore.js.map +1 -1
  38. package/build/services/DisplayProcessor.d.ts +3 -3
  39. package/build/services/DisplayProcessor.js +3 -3
  40. package/build/services/DisplayProcessor.js.map +1 -1
  41. package/build/services/GlassesStatusProjection.d.ts +15 -2
  42. package/build/services/GlassesStatusProjection.d.ts.map +1 -1
  43. package/build/services/GlassesStatusProjection.js +3 -3
  44. package/build/services/GlassesStatusProjection.js.map +1 -1
  45. package/build/services/HotspotOtaTransport.d.ts.map +1 -1
  46. package/build/services/HotspotOtaTransport.js +8 -7
  47. package/build/services/HotspotOtaTransport.js.map +1 -1
  48. package/build/services/LocalDisplayManager.d.ts +2 -3
  49. package/build/services/LocalDisplayManager.d.ts.map +1 -1
  50. package/build/services/LocalDisplayManager.js +2 -3
  51. package/build/services/LocalDisplayManager.js.map +1 -1
  52. package/build/services/OtaAutoChain.d.ts +9 -2
  53. package/build/services/OtaAutoChain.d.ts.map +1 -1
  54. package/build/services/OtaAutoChain.js +10 -2
  55. package/build/services/OtaAutoChain.js.map +1 -1
  56. package/build/services/OtaInstallCoordinator.d.ts +26 -3
  57. package/build/services/OtaInstallCoordinator.d.ts.map +1 -1
  58. package/build/services/OtaInstallCoordinator.js +35 -13
  59. package/build/services/OtaInstallCoordinator.js.map +1 -1
  60. package/build/services/OtaService.d.ts.map +1 -1
  61. package/build/services/OtaService.js +1 -1
  62. package/build/services/OtaService.js.map +1 -1
  63. package/build/services/OtaUpdateCheckService.d.ts +4 -1
  64. package/build/services/OtaUpdateCheckService.d.ts.map +1 -1
  65. package/build/services/OtaUpdateCheckService.js +21 -5
  66. package/build/services/OtaUpdateCheckService.js.map +1 -1
  67. package/build/services/PhonePhotoCoordinator.js +1 -1
  68. package/build/services/PhonePhotoCoordinator.js.map +1 -1
  69. package/build/services/PhoneStreamCoordinator.d.ts.map +1 -1
  70. package/build/services/PhoneStreamCoordinator.js +9 -6
  71. package/build/services/PhoneStreamCoordinator.js.map +1 -1
  72. package/build/services/StreamLifecycleController.d.ts +3 -3
  73. package/build/services/StreamLifecycleController.js +3 -3
  74. package/build/services/StreamLifecycleController.js.map +1 -1
  75. package/build/services/asg/localNetworkTransport.d.ts.map +1 -1
  76. package/build/services/asg/localNetworkTransport.js +13 -12
  77. package/build/services/asg/localNetworkTransport.js.map +1 -1
  78. package/build/services/glassesClockSync.js +1 -1
  79. package/build/services/glassesClockSync.js.map +1 -1
  80. package/build/services/otaInstallPolicy.d.ts +4 -0
  81. package/build/services/otaInstallPolicy.d.ts.map +1 -1
  82. package/build/services/otaInstallPolicy.js +4 -0
  83. package/build/services/otaInstallPolicy.js.map +1 -1
  84. package/build/services/otaReleaseVersion.d.ts +10 -0
  85. package/build/services/otaReleaseVersion.d.ts.map +1 -0
  86. package/build/services/otaReleaseVersion.js +14 -0
  87. package/build/services/otaReleaseVersion.js.map +1 -0
  88. package/build/stores/appVisibility.d.ts +3 -0
  89. package/build/stores/appVisibility.d.ts.map +1 -0
  90. package/build/stores/appVisibility.js +3 -0
  91. package/build/stores/appVisibility.js.map +1 -0
  92. package/build/stores/apps.d.ts.map +1 -1
  93. package/build/stores/apps.js +7 -1
  94. package/build/stores/apps.js.map +1 -1
  95. package/build/stores/core.d.ts +3 -3
  96. package/build/stores/core.d.ts.map +1 -1
  97. package/build/stores/core.js.map +1 -1
  98. package/build/stores/glasses.d.ts +10 -4
  99. package/build/stores/glasses.d.ts.map +1 -1
  100. package/build/stores/glasses.js.map +1 -1
  101. package/build/types/applet.d.ts +1 -1
  102. package/build/types/applet.js +1 -1
  103. package/build/types/applet.js.map +1 -1
  104. package/build/types/capabilities/even-realities-g1.d.ts.map +1 -1
  105. package/build/types/capabilities/even-realities-g1.js +2 -0
  106. package/build/types/capabilities/even-realities-g1.js.map +1 -1
  107. package/build/types/capabilities/even-realities-g2.d.ts.map +1 -1
  108. package/build/types/capabilities/even-realities-g2.js +2 -0
  109. package/build/types/capabilities/even-realities-g2.js.map +1 -1
  110. package/build/types/capabilities/mentra-display.d.ts.map +1 -1
  111. package/build/types/capabilities/mentra-display.js +2 -0
  112. package/build/types/capabilities/mentra-display.js.map +1 -1
  113. package/build/types/capabilities/mentra-live.d.ts.map +1 -1
  114. package/build/types/capabilities/mentra-live.js +2 -0
  115. package/build/types/capabilities/mentra-live.js.map +1 -1
  116. package/build/types/capabilities/nimo.d.ts +9 -0
  117. package/build/types/capabilities/nimo.d.ts.map +1 -0
  118. package/build/types/capabilities/nimo.js +57 -0
  119. package/build/types/capabilities/nimo.js.map +1 -0
  120. package/build/types/capabilities/none.d.ts.map +1 -1
  121. package/build/types/capabilities/none.js +2 -0
  122. package/build/types/capabilities/none.js.map +1 -1
  123. package/build/types/capabilities/simulated-glasses.d.ts.map +1 -1
  124. package/build/types/capabilities/simulated-glasses.js +2 -0
  125. package/build/types/capabilities/simulated-glasses.js.map +1 -1
  126. package/build/types/capabilities/vuzix-z100.d.ts.map +1 -1
  127. package/build/types/capabilities/vuzix-z100.js +2 -0
  128. package/build/types/capabilities/vuzix-z100.js.map +1 -1
  129. package/build/types/enums.d.ts +2 -1
  130. package/build/types/enums.d.ts.map +1 -1
  131. package/build/types/enums.js +1 -0
  132. package/build/types/enums.js.map +1 -1
  133. package/build/types/hardware.d.ts +3 -2
  134. package/build/types/hardware.d.ts.map +1 -1
  135. package/build/types/hardware.js +3 -1
  136. package/build/types/hardware.js.map +1 -1
  137. package/build/types/index.d.ts +1 -1
  138. package/build/types/index.d.ts.map +1 -1
  139. package/build/types/index.js +1 -1
  140. package/build/types/index.js.map +1 -1
  141. package/build/utils/display/composer/ColumnComposer.d.ts +1 -1
  142. package/build/utils/display/composer/ColumnComposer.js +1 -1
  143. package/build/utils/display/composer/ColumnComposer.js.map +1 -1
  144. package/package.json +13 -6
  145. package/src/bluetooth-sdk/ota-transport.ts +1 -0
  146. package/src/facades/ota.ts +20 -7
  147. package/src/facades/pairing.ts +88 -12
  148. package/src/generated/releaseMetadata.ts +5 -5
  149. package/src/index.ts +3 -0
  150. package/src/react/MentraLiveOtaFlow.tsx +378 -480
  151. package/src/react/index.ts +14 -0
  152. package/src/react/useMentraLiveOta.ts +793 -0
  153. package/src/services/BlobStore.ts +57 -10
  154. package/src/services/DisplayProcessor.ts +3 -3
  155. package/src/services/GlassesStatusProjection.ts +7 -6
  156. package/src/services/HotspotOtaTransport.ts +8 -7
  157. package/src/services/LocalDisplayManager.ts +2 -3
  158. package/src/services/OtaAutoChain.ts +26 -2
  159. package/src/services/OtaInstallCoordinator.ts +37 -13
  160. package/src/services/OtaService.ts +1 -2
  161. package/src/services/OtaUpdateCheckService.ts +26 -8
  162. package/src/services/PhonePhotoCoordinator.ts +1 -1
  163. package/src/services/PhoneStreamCoordinator.ts +10 -6
  164. package/src/services/StreamLifecycleController.ts +3 -3
  165. package/src/services/asg/localNetworkTransport.ts +20 -19
  166. package/src/services/glassesClockSync.ts +1 -1
  167. package/src/services/otaInstallPolicy.ts +4 -0
  168. package/src/services/otaReleaseVersion.ts +22 -0
  169. package/src/stores/appVisibility.ts +3 -0
  170. package/src/stores/apps.ts +7 -1
  171. package/src/stores/core.ts +4 -4
  172. package/src/stores/glasses.ts +13 -6
  173. package/src/types/applet.ts +1 -1
  174. package/src/types/capabilities/even-realities-g1.ts +3 -0
  175. package/src/types/capabilities/even-realities-g2.ts +3 -0
  176. package/src/types/capabilities/mentra-display.ts +3 -0
  177. package/src/types/capabilities/mentra-live.ts +3 -0
  178. package/src/types/capabilities/nimo.ts +59 -0
  179. package/src/types/capabilities/none.ts +3 -0
  180. package/src/types/capabilities/simulated-glasses.ts +3 -0
  181. package/src/types/capabilities/vuzix-z100.ts +3 -0
  182. package/src/types/enums.ts +1 -0
  183. package/src/types/hardware.ts +4 -2
  184. package/src/types/index.ts +1 -0
  185. package/src/utils/display/composer/ColumnComposer.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ColumnComposer.js","sourceRoot":"","sources":["../../../../src/utils/display/composer/ColumnComposer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,YAAY,EAAE,MA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M,CAAC,YAAY,CAAC,CAAC;YACjC,IAAI,IAAI,SAAS,CAAC;YAElB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED;;;;;;OAMG;IACK,2BAA2B,CAAC,cAAsB,EAAE,gBAAwB;QAClF,MAAM,YAAY,GAAG,gBAAgB,GAAG,cAAc,CAAC;QAEvD,2CAA2C;QAC3C,IAAI,YAAY,IAAI,CAAC,EAAE,CAAC;YACtB,OAAO,CAAC,CAAC;QACX,CAAC;QAED,wEAAwE;QACxE,wEAAwE;QACxE,wEAAwE;QACxE,wEAAwE;QACxE,wBAAwB;QACxB,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;QAEzE,yDAAyD;QACzD,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACK,aAAa,CAAC,IAAY;QAChC,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IACrC,CAAC;CACF;AAED,gFAAgF;AAChF,mBAAmB;AACnB,gFAAgF;AAEhF;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAuB,EAAE,YAAuB,MAAM;IACzF,OAAO,IAAI,cAAc,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AAChD,CAAC","sourcesContent":["/**\n * ColumnComposer\n *\n * Handles composition of multi-column layouts like double_text_wall.\n * This is the single source of truth for column layout logic, replacing\n * the duplicate implementations in native iOS (G1Text.swift) and\n * Android (G1Text.kt, G1.java).\n *\n * The composer:\n * 1. Wraps each column's text to its allocated width\n * 2. Merges columns line-by-line with pixel-precise space padding\n * 3. Returns a single pre-composed string ready for native to chunk & send\n *\n * @see cloud/issues/026-mobile-display-processor for design docs\n */\n\nimport type { DisplayProfile } from \"../profiles/types\";\nimport { TextMeasurer } from \"../measurer/TextMeasurer\";\nimport { TextWrapper } from \"../wrapper/TextWrapper\";\nimport type { WrapOptions, BreakMode } from \"../wrapper/types\";\n\n// =============================================================================\n// Types\n// =============================================================================\n\n/**\n * Configuration for column layout\n */\nexport interface ColumnConfig {\n /** Width of the left column in pixels */\n leftColumnWidthPx: number;\n /** X position where the right column starts in pixels */\n rightColumnStartPx: number;\n /** Width of the right column in pixels (calculated from start position) */\n rightColumnWidthPx: number;\n /** Maximum number of lines to display */\n maxLines: number;\n /** Left margin in spaces (for indentation) */\n leftMarginSpaces?: number;\n}\n\n/**\n * Options for composing double text wall\n */\nexport interface ComposeOptions {\n /** Break mode for text wrapping */\n breakMode?: BreakMode;\n /** Custom column configuration (overrides profile defaults) */\n columnConfig?: Partial<ColumnConfig>;\n}\n\n/**\n * Result of column composition\n */\nexport interface ComposeResult {\n /** The fully composed text with both columns merged */\n composedText: string;\n /** Lines from the left column (for debugging/preview) */\n leftLines: string[];\n /** Lines from the right column (for debugging/preview) */\n rightLines: string[];\n /** The column configuration that was used */\n config: ColumnConfig;\n}\n\n// =============================================================================\n// ColumnComposer Class\n// =============================================================================\n\n/**\n * Composes multi-column layouts for smart glasses displays.\n *\n * Usage:\n * ```typescript\n * const composer = new ColumnComposer(G1_PROFILE)\n * const result = composer.composeDoubleTextWall(\"Left content\", \"Right content\")\n * // result.composedText is ready to send to native SGC\n * ```\n */\nexport class ColumnComposer {\n private profile: DisplayProfile;\n private measurer: TextMeasurer;\n private wrapper: TextWrapper;\n private spaceWidthPx: number;\n\n constructor(profile: DisplayProfile, breakMode: BreakMode = \"character-no-hyphen\") {\n this.profile = profile;\n this.measurer = new TextMeasurer(profile);\n this.wrapper = new TextWrapper(this.measurer, {\n breakMode,\n });\n\n // Cache space width for alignment calculations\n this.spaceWidthPx = this.measurer.measureText(\" \");\n }\n\n // ===========================================================================\n // Public API\n // ===========================================================================\n\n /**\n * Compose a double text wall layout.\n *\n * Takes left and right text, wraps each to their column width,\n * and merges them with pixel-precise space alignment.\n *\n * @param leftText - Text for the left column\n * @param rightText - Text for the right column\n * @param options - Optional composition settings\n * @returns Composed result with merged text and metadata\n */\n public composeDoubleTextWall(leftText: string, rightText: string, options: ComposeOptions = {}): ComposeResult {\n const config = this.getColumnConfig(options.columnConfig);\n\n // Wrap each column independently\n const leftWrapOptions: WrapOptions = {\n maxWidthPx: config.leftColumnWidthPx,\n maxLines: config.maxLines,\n };\n\n const rightWrapOptions: WrapOptions = {\n maxWidthPx: config.rightColumnWidthPx,\n maxLines: config.maxLines,\n };\n\n const leftResult = this.wrapper.wrap(leftText || \"\", leftWrapOptions);\n const rightResult = this.wrapper.wrap(rightText || \"\", rightWrapOptions);\n\n // Pad arrays to have exactly maxLines entries\n const leftLines = this.padLines(leftResult.lines, config.maxLines);\n const rightLines = this.padLines(rightResult.lines, config.maxLines);\n\n // Merge columns with space alignment\n const composedText = this.mergeColumns(leftLines, rightLines, config);\n\n return {\n composedText,\n leftLines,\n rightLines,\n config,\n };\n }\n\n /**\n * Get the default column configuration for the current profile.\n */\n public getDefaultColumnConfig(): ColumnConfig {\n return this.getColumnConfig();\n }\n\n /**\n * Update the break mode for text wrapping.\n */\n public setBreakMode(breakMode: BreakMode): void {\n this.wrapper = new TextWrapper(this.measurer, {\n breakMode,\n });\n }\n\n // ===========================================================================\n // Private Methods\n // ===========================================================================\n\n /**\n * Get column configuration, merging defaults with overrides.\n */\n private getColumnConfig(overrides?: Partial<ColumnConfig>): ColumnConfig {\n const displayWidth = this.profile.displayWidthPx;\n\n // Default layout: 50% for left column, right starts at 55%\n // This matches the native G1Text implementations\n const defaults: ColumnConfig = {\n leftColumnWidthPx: Math.floor(displayWidth * 0.5),\n rightColumnStartPx: Math.floor(displayWidth * 0.55),\n rightColumnWidthPx: displayWidth - Math.floor(displayWidth * 0.55),\n maxLines: this.profile.maxLines,\n leftMarginSpaces: 0,\n };\n\n return {\n ...defaults,\n ...overrides,\n };\n }\n\n /**\n * Pad lines array to exactly `count` entries.\n */\n private padLines(lines: string[], count: number): string[] {\n const result = [...lines];\n while (result.length < count) {\n result.push(\"\");\n }\n return result.slice(0, count);\n }\n\n /**\n * Merge left and right columns with pixel-precise space alignment.\n *\n * For each line:\n * 1. Take the left column text\n * 2. Calculate its pixel width\n * 3. Calculate how many spaces needed to reach rightColumnStartPx\n * 4. Append spaces and right column text\n */\n private mergeColumns(leftLines: string[], rightLines: string[], config: ColumnConfig): string {\n const lines: string[] = [];\n\n for (let i = 0; i < config.maxLines; i++) {\n const leftText = this.cleanEnspaces(leftLines[i] || \"\");\n const rightText = this.cleanEnspaces(rightLines[i] || \"\");\n\n // Calculate pixel width of left text\n const leftWidthPx = this.measurer.measureText(leftText);\n\n // Calculate spaces needed to reach the right column start\n const spacesNeeded = this.calculateSpacesForAlignment(leftWidthPx, config.rightColumnStartPx);\n\n // Build the merged line\n let line = \"\";\n\n // Add left margin if configured\n if (config.leftMarginSpaces && config.leftMarginSpaces > 0) {\n line += \" \".repeat(config.leftMarginSpaces);\n }\n\n line += leftText;\n line += \" \".repeat(spacesNeeded);\n line += rightText;\n\n lines.push(line);\n }\n\n return lines.join(\"\\n\");\n }\n\n /**\n * Calculate the number of spaces needed to align to a target position.\n *\n * @param currentWidthPx - Current position in pixels\n * @param targetPositionPx - Target position in pixels\n * @returns Number of space characters needed\n */\n private calculateSpacesForAlignment(currentWidthPx: number, targetPositionPx: number): number {\n const pixelsNeeded = targetPositionPx - currentWidthPx;\n\n // Ensure at least one space for separation\n if (pixelsNeeded <= 0) {\n return 1;\n }\n\n // Calculate spaces needed. Use Math.floor (not Math.ceil) to ensure the\n // right column never starts past rightColumnStartPx. Rounding up caused\n // the right column to start 1–5px further right than planned, shrinking\n // its usable width and causing the last character to wrap onto the next\n // line's left position.\n const spaces = Math.max(1, Math.floor(pixelsNeeded / this.spaceWidthPx));\n\n // Cap at a reasonable maximum to prevent runaway spacing\n return Math.min(spaces, 100);\n }\n\n /**\n * Remove en-space characters (U+2002) that may have been added during wrapping.\n * Native implementations do this cleanup before merging.\n */\n private cleanEnspaces(text: string): string {\n return text.replace(/\\u2002/g, \"\");\n }\n}\n\n// =============================================================================\n// Factory Function\n// =============================================================================\n\n/**\n * Create a ColumnComposer for a given profile.\n *\n * @param profile - Display profile to use\n * @param breakMode - Break mode for text wrapping (default: \"word\")\n * @returns Configured ColumnComposer instance\n */\nexport function createColumnComposer(profile: DisplayProfile, breakMode: BreakMode = \"word\"): ColumnComposer {\n return new ColumnComposer(profile, breakMode);\n}\n"]}
1
+ {"version":3,"file":"ColumnComposer.js","sourceRoot":"","sources":["../../../../src/utils/display/composer/ColumnComposer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AA+CrD,gFAAgF;AAChF,uBAAuB;AACvB,gFAAgF;AAEhF;;;;;;;;;GASG;AACH,MAAM,OAAO,cAAc;IACjB,OAAO,CAAiB;IACxB,QAAQ,CAAe;IACvB,OAAO,CAAc;IACrB,YAAY,CAAS;IAE7B,YAAY,OAAuB,EAAE,YAAuB,qBAAqB;QAC/E,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;QAC1C,IAAI,CAAC,OAAO,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,QAAQ,EAAE;YAC5C,SAAS;SACV,CAAC,CAAC;QAEH,+CAA+C;QAC/C,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACrD,CAAC;IAED,8EAA8E;IAC9E,aAAa;IACb,8EAA8E;IAE9E;;;;;;;;;;OAUG;IACI,qBAAqB,CAAC,Q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;;OAGG;IACK,aAAa,CAAC,IAAY;QAChC,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IACrC,CAAC;CACF;AAED,gFAAgF;AAChF,mBAAmB;AACnB,gFAAgF;AAEhF;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAuB,EAAE,YAAuB,MAAM;IACzF,OAAO,IAAI,cAAc,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AAChD,CAAC","sourcesContent":["/**\n * ColumnComposer\n *\n * Handles composition of multi-column layouts like double_text_wall.\n * This is the single source of truth for column layout logic, replacing\n * the duplicate implementations in native iOS (G1Text.swift) and\n * Android (G1Text.kt, G1.java).\n *\n * The composer:\n * 1. Wraps each column's text to its allocated width\n * 2. Merges columns line-by-line with pixel-precise space padding\n * 3. Returns a single pre-composed string ready for native to chunk & send\n *\n * @see notes/miniapp-display-api-redesign.md for the current display design\n */\n\nimport type { DisplayProfile } from \"../profiles/types\";\nimport { TextMeasurer } from \"../measurer/TextMeasurer\";\nimport { TextWrapper } from \"../wrapper/TextWrapper\";\nimport type { WrapOptions, BreakMode } from \"../wrapper/types\";\n\n// =============================================================================\n// Types\n// =============================================================================\n\n/**\n * Configuration for column layout\n */\nexport interface ColumnConfig {\n /** Width of the left column in pixels */\n leftColumnWidthPx: number;\n /** X position where the right column starts in pixels */\n rightColumnStartPx: number;\n /** Width of the right column in pixels (calculated from start position) */\n rightColumnWidthPx: number;\n /** Maximum number of lines to display */\n maxLines: number;\n /** Left margin in spaces (for indentation) */\n leftMarginSpaces?: number;\n}\n\n/**\n * Options for composing double text wall\n */\nexport interface ComposeOptions {\n /** Break mode for text wrapping */\n breakMode?: BreakMode;\n /** Custom column configuration (overrides profile defaults) */\n columnConfig?: Partial<ColumnConfig>;\n}\n\n/**\n * Result of column composition\n */\nexport interface ComposeResult {\n /** The fully composed text with both columns merged */\n composedText: string;\n /** Lines from the left column (for debugging/preview) */\n leftLines: string[];\n /** Lines from the right column (for debugging/preview) */\n rightLines: string[];\n /** The column configuration that was used */\n config: ColumnConfig;\n}\n\n// =============================================================================\n// ColumnComposer Class\n// =============================================================================\n\n/**\n * Composes multi-column layouts for smart glasses displays.\n *\n * Usage:\n * ```typescript\n * const composer = new ColumnComposer(G1_PROFILE)\n * const result = composer.composeDoubleTextWall(\"Left content\", \"Right content\")\n * // result.composedText is ready to send to native SGC\n * ```\n */\nexport class ColumnComposer {\n private profile: DisplayProfile;\n private measurer: TextMeasurer;\n private wrapper: TextWrapper;\n private spaceWidthPx: number;\n\n constructor(profile: DisplayProfile, breakMode: BreakMode = \"character-no-hyphen\") {\n this.profile = profile;\n this.measurer = new TextMeasurer(profile);\n this.wrapper = new TextWrapper(this.measurer, {\n breakMode,\n });\n\n // Cache space width for alignment calculations\n this.spaceWidthPx = this.measurer.measureText(\" \");\n }\n\n // ===========================================================================\n // Public API\n // ===========================================================================\n\n /**\n * Compose a double text wall layout.\n *\n * Takes left and right text, wraps each to their column width,\n * and merges them with pixel-precise space alignment.\n *\n * @param leftText - Text for the left column\n * @param rightText - Text for the right column\n * @param options - Optional composition settings\n * @returns Composed result with merged text and metadata\n */\n public composeDoubleTextWall(leftText: string, rightText: string, options: ComposeOptions = {}): ComposeResult {\n const config = this.getColumnConfig(options.columnConfig);\n\n // Wrap each column independently\n const leftWrapOptions: WrapOptions = {\n maxWidthPx: config.leftColumnWidthPx,\n maxLines: config.maxLines,\n };\n\n const rightWrapOptions: WrapOptions = {\n maxWidthPx: config.rightColumnWidthPx,\n maxLines: config.maxLines,\n };\n\n const leftResult = this.wrapper.wrap(leftText || \"\", leftWrapOptions);\n const rightResult = this.wrapper.wrap(rightText || \"\", rightWrapOptions);\n\n // Pad arrays to have exactly maxLines entries\n const leftLines = this.padLines(leftResult.lines, config.maxLines);\n const rightLines = this.padLines(rightResult.lines, config.maxLines);\n\n // Merge columns with space alignment\n const composedText = this.mergeColumns(leftLines, rightLines, config);\n\n return {\n composedText,\n leftLines,\n rightLines,\n config,\n };\n }\n\n /**\n * Get the default column configuration for the current profile.\n */\n public getDefaultColumnConfig(): ColumnConfig {\n return this.getColumnConfig();\n }\n\n /**\n * Update the break mode for text wrapping.\n */\n public setBreakMode(breakMode: BreakMode): void {\n this.wrapper = new TextWrapper(this.measurer, {\n breakMode,\n });\n }\n\n // ===========================================================================\n // Private Methods\n // ===========================================================================\n\n /**\n * Get column configuration, merging defaults with overrides.\n */\n private getColumnConfig(overrides?: Partial<ColumnConfig>): ColumnConfig {\n const displayWidth = this.profile.displayWidthPx;\n\n // Default layout: 50% for left column, right starts at 55%\n // This matches the native G1Text implementations\n const defaults: ColumnConfig = {\n leftColumnWidthPx: Math.floor(displayWidth * 0.5),\n rightColumnStartPx: Math.floor(displayWidth * 0.55),\n rightColumnWidthPx: displayWidth - Math.floor(displayWidth * 0.55),\n maxLines: this.profile.maxLines,\n leftMarginSpaces: 0,\n };\n\n return {\n ...defaults,\n ...overrides,\n };\n }\n\n /**\n * Pad lines array to exactly `count` entries.\n */\n private padLines(lines: string[], count: number): string[] {\n const result = [...lines];\n while (result.length < count) {\n result.push(\"\");\n }\n return result.slice(0, count);\n }\n\n /**\n * Merge left and right columns with pixel-precise space alignment.\n *\n * For each line:\n * 1. Take the left column text\n * 2. Calculate its pixel width\n * 3. Calculate how many spaces needed to reach rightColumnStartPx\n * 4. Append spaces and right column text\n */\n private mergeColumns(leftLines: string[], rightLines: string[], config: ColumnConfig): string {\n const lines: string[] = [];\n\n for (let i = 0; i < config.maxLines; i++) {\n const leftText = this.cleanEnspaces(leftLines[i] || \"\");\n const rightText = this.cleanEnspaces(rightLines[i] || \"\");\n\n // Calculate pixel width of left text\n const leftWidthPx = this.measurer.measureText(leftText);\n\n // Calculate spaces needed to reach the right column start\n const spacesNeeded = this.calculateSpacesForAlignment(leftWidthPx, config.rightColumnStartPx);\n\n // Build the merged line\n let line = \"\";\n\n // Add left margin if configured\n if (config.leftMarginSpaces && config.leftMarginSpaces > 0) {\n line += \" \".repeat(config.leftMarginSpaces);\n }\n\n line += leftText;\n line += \" \".repeat(spacesNeeded);\n line += rightText;\n\n lines.push(line);\n }\n\n return lines.join(\"\\n\");\n }\n\n /**\n * Calculate the number of spaces needed to align to a target position.\n *\n * @param currentWidthPx - Current position in pixels\n * @param targetPositionPx - Target position in pixels\n * @returns Number of space characters needed\n */\n private calculateSpacesForAlignment(currentWidthPx: number, targetPositionPx: number): number {\n const pixelsNeeded = targetPositionPx - currentWidthPx;\n\n // Ensure at least one space for separation\n if (pixelsNeeded <= 0) {\n return 1;\n }\n\n // Calculate spaces needed. Use Math.floor (not Math.ceil) to ensure the\n // right column never starts past rightColumnStartPx. Rounding up caused\n // the right column to start 1–5px further right than planned, shrinking\n // its usable width and causing the last character to wrap onto the next\n // line's left position.\n const spaces = Math.max(1, Math.floor(pixelsNeeded / this.spaceWidthPx));\n\n // Cap at a reasonable maximum to prevent runaway spacing\n return Math.min(spaces, 100);\n }\n\n /**\n * Remove en-space characters (U+2002) that may have been added during wrapping.\n * Native implementations do this cleanup before merging.\n */\n private cleanEnspaces(text: string): string {\n return text.replace(/\\u2002/g, \"\");\n }\n}\n\n// =============================================================================\n// Factory Function\n// =============================================================================\n\n/**\n * Create a ColumnComposer for a given profile.\n *\n * @param profile - Display profile to use\n * @param breakMode - Break mode for text wrapping (default: \"word\")\n * @returns Configured ColumnComposer instance\n */\nexport function createColumnComposer(profile: DisplayProfile, breakMode: BreakMode = \"word\"): ColumnComposer {\n return new ColumnComposer(profile, breakMode);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mentra/engine",
3
- "version": "3.1.0-dev.10",
3
+ "version": "3.1.0-dev.102",
4
4
  "description": "Mentra Engine — miniapp registry, WebView bridge, and miniapp store",
5
5
  "main": "build/index.js",
6
6
  "react-native": "src/index.ts",
@@ -36,6 +36,11 @@
36
36
  "react-native": "./src/bluetooth-sdk/photo-receiver.ts",
37
37
  "default": "./build/bluetooth-sdk/photo-receiver.js"
38
38
  },
39
+ "./bluetooth-sdk/ota-transport": {
40
+ "types": "./build/bluetooth-sdk/ota-transport.d.ts",
41
+ "react-native": "./src/bluetooth-sdk/ota-transport.ts",
42
+ "default": "./build/bluetooth-sdk/ota-transport.js"
43
+ },
39
44
  "./bluetooth-sdk/debug": {
40
45
  "types": "./build/bluetooth-sdk/debug.d.ts",
41
46
  "react-native": "./src/bluetooth-sdk/debug.ts",
@@ -64,6 +69,7 @@
64
69
  "write:release-metadata": "node scripts/write-release-metadata.mjs",
65
70
  "verify:release-package": "node scripts/verify-release-package.mjs",
66
71
  "test:public-api": "bun test src/bluetooth-sdk/__tests__/publicApi.test.ts",
72
+ "test:public-ota-consumer": "tsc --noEmit --strict --skipLibCheck --jsx react-jsx --moduleResolution bundler --module esnext --target es2022 scripts/fixtures/public-ota-consumer.tsx",
67
73
  "build:module": "expo-module prepare",
68
74
  "prepublishOnly": "expo-module prepublishOnly",
69
75
  "expo-module": "expo-module"
@@ -91,13 +97,14 @@
91
97
  "registry": "https://registry.npmjs.org/"
92
98
  },
93
99
  "dependencies": {
94
- "@mentra/bluetooth-sdk": "3.1.0-dev.10",
95
- "@mentra/cloud-client": "3.1.0-dev.10",
96
- "@mentra/cloud-protocol": "3.1.0-dev.10",
97
- "@mentra/crust": "3.1.0-dev.10",
98
- "@mentra/miniapp": "3.1.0-dev.10",
100
+ "@mentra/bluetooth-sdk": "3.1.0-dev.102",
101
+ "@mentra/cloud-client": "3.1.0-dev.102",
102
+ "@mentra/cloud-protocol": "3.1.0-dev.102",
103
+ "@mentra/crust": "3.1.0-dev.102",
104
+ "@mentra/miniapp": "3.1.0-dev.102",
99
105
  "buffer": "^6.0.3",
100
106
  "events": "^3.3.0",
107
+ "react-native-marked": "8.1.1",
101
108
  "semver": "^7.7.4",
102
109
  "typesafe-ts": "^1.7.1"
103
110
  },
@@ -0,0 +1 @@
1
+ export * from "@mentra/bluetooth-sdk/ota-transport"
@@ -8,9 +8,16 @@
8
8
  * `installSession` fronts the OtaInstallCoordinator state machine (WP 8B) — the host
9
9
  * progress screen is a pure renderer over its snapshot + attach/detach/retry/finish.
10
10
  */
11
- import BluetoothSdk from "@mentra/bluetooth-sdk/internal"
12
- import type {OtaProgress, OtaProgressStatus, OtaStartAckEvent, OtaStatus, OtaUpdateInfo} from "@mentra/bluetooth-sdk"
13
- import {isGlassesConnected, useGlassesStore} from "../stores/glasses"
11
+ import BluetoothSdk from "@mentra/bluetooth-sdk"
12
+ import type {
13
+ OtaProgress,
14
+ OtaProgressStatus,
15
+ OtaStartAckEvent,
16
+ OtaStatus,
17
+ OtaUpdateInfo,
18
+ ReleaseChangelog,
19
+ } from "@mentra/bluetooth-sdk"
20
+ import {isGlassesConnected, isGlassesReady, useGlassesStore} from "../stores/glasses"
14
21
  import {resolveOtaManifestUrl} from "../services/otaManifestUrl"
15
22
  import {otaInstallCoordinator, type OtaInstallSnapshot} from "../services/OtaInstallCoordinator"
16
23
  import {startGlassesStatusProjection} from "../services/GlassesStatusProjection"
@@ -25,9 +32,12 @@ function projectSnapshot() {
25
32
  const s = useGlassesStore.getState()
26
33
  return {
27
34
  connected: isGlassesConnected(s.connection),
35
+ ready: isGlassesReady(s.connection),
28
36
  buildNumber: s.buildNumber || null,
37
+ appVersion: s.appVersion || null,
29
38
  mtkFirmwareVersion: s.mtkFirmwareVersion || null,
30
39
  besFirmwareVersion: s.besFirmwareVersion || null,
40
+ batteryLevel: s.batteryLevel >= 0 ? s.batteryLevel : null,
31
41
  hotspotOtaVersion: s.hotspotOtaVersion ?? 0,
32
42
  wifiConnected: s.wifi.state === "connected",
33
43
  wifiStatusKnown: s.wifiStatusKnown,
@@ -46,6 +56,7 @@ export type {
46
56
  OtaProgressStatus,
47
57
  OtaStatus,
48
58
  OtaUpdateInfo,
59
+ ReleaseChangelog,
49
60
  OtaInstallSnapshot,
50
61
  OtaCheckCurrentGlassesOptions,
51
62
  OtaCheckCurrentGlassesResult,
@@ -55,7 +66,7 @@ export const ota = {
55
66
  // --- actions ---
56
67
  /**
57
68
  * Start the device-status and OTA projections without starting the authenticated
58
- * cloud/miniapp runtime. This is the explicit entry point for Bluetooth-only hosts.
69
+ * cloud connection or miniapp runtime. This is the explicit entry point for Bluetooth-only hosts.
59
70
  * Idempotent and safe when the full engine runtime is already running.
60
71
  */
61
72
  initialize: async () => {
@@ -84,6 +95,9 @@ export const ota = {
84
95
  ping: () => BluetoothSdk.ping(),
85
96
  /** Resolve and compare the current glasses against the OTA manifest, then update the OTA snapshot. */
86
97
  checkForUpdates: (options?: OtaCheckCurrentGlassesOptions) => checkCurrentGlassesForUpdate(options),
98
+ /** Return bundled release changelogs crossed between two coordinated product versions, newest first. */
99
+ getReleaseChangelogs: (fromVersion?: string | null, toVersion?: string | null): ReleaseChangelog[] =>
100
+ BluetoothSdk.getReleaseChangelogs(fromVersion, toVersion),
87
101
  /** Clear the available-update prompt state. */
88
102
  clearUpdateAvailable: () => useGlassesStore.getState().setOtaUpdateAvailable(null),
89
103
  /** Clear active progress/status before entering a fresh install flow. */
@@ -113,7 +127,6 @@ export const ota = {
113
127
  * @deprecated Legacy progress route (build < 37) only — removed with WP 8D.
114
128
  */
115
129
  clearBuildNumberForNextCheck: () => {
116
- BluetoothSdk.updateGlasses({buildNumber: ""})
117
130
  useGlassesStore.getState().setGlassesInfo({buildNumber: ""})
118
131
  },
119
132
  /**
@@ -136,9 +149,9 @@ export const ota = {
136
149
  detach: () => otaInstallCoordinator.detach(),
137
150
  /** Retry after a failure: clear state and re-send ota_start (if connected). */
138
151
  retry: () => otaInstallCoordinator.retry(),
139
- /** Terminal cleanup for Continue/Done (navigation stays in the screen). */
152
+ /** Terminal cleanup for Continue/Done, including hotspot route teardown. */
140
153
  finish: () => otaInstallCoordinator.finish(),
141
- /** Abandon an interrupted session (super-mode skip): finish() + drop the session's status/progress. */
154
+ /** Abandon an interrupted session: await finish() then drop the session's status/progress. */
142
155
  discard: () => otaInstallCoordinator.discard(),
143
156
  /** Current install read model (displayState/errorMsg/lockout + glasses OTA data). */
144
157
  snapshot: (): OtaInstallSnapshot => otaInstallCoordinator.snapshot(),
@@ -13,6 +13,7 @@ import BluetoothSdk from "@mentra/bluetooth-sdk/internal"
13
13
  import type {ConnectOptions, Device, DeviceModel, PairFailureEvent, GlassesNotReadyEvent} from "@mentra/bluetooth-sdk"
14
14
  import {useCoreStore} from "../stores/core"
15
15
  import {useGlassesStore} from "../stores/glasses"
16
+ import {SETTINGS, useSettingsStore} from "../stores/settings"
16
17
  import {hasDefaultDevice} from "../services/DeviceStoreHydration"
17
18
  import {
18
19
  markPendingSelection,
@@ -20,18 +21,14 @@ import {
20
21
  subscribePairingIdentity,
21
22
  type IdentitySnapshot,
22
23
  } from "../services/PairingIdentity"
23
- import {
24
- isGlassesConnected,
25
- isGlassesLinkLayerBusy,
26
- isGlassesReady,
27
- waitForGlassesReady,
28
- } from "../services/GlassesReadiness"
24
+ import {isGlassesConnected, isGlassesLinkLayerBusy, isGlassesReady} from "../services/GlassesReadiness"
29
25
  import {
30
26
  logAutomaticReportSubmissionStatus,
31
27
  toAutomaticReportSubmissionStatus,
32
28
  type AutomaticReportSubmissionStatus,
33
29
  } from "../services/AutomaticReportResult"
34
30
  import {pushAllBluetoothSettings} from "../services/GlassesSettingsSync"
31
+ import {ControllerTypes} from "../types"
35
32
  import {submitAutomaticReport} from "./reports"
36
33
 
37
34
  export type {IdentitySnapshot} from "../services/PairingIdentity"
@@ -60,6 +57,82 @@ function projectReadiness() {
60
57
  }
61
58
  }
62
59
 
60
+ function projectTargetReady(options: Pick<PairingReadyWaitOptions, "deviceModel" | "deviceName">): boolean {
61
+ const {deviceModel, deviceName} = options
62
+ const glasses = useGlassesStore.getState()
63
+
64
+ if (deviceModel === ControllerTypes.R1) {
65
+ if (!glasses.controllerConnected || !glasses.controllerFullyBooted) return false
66
+ const settings = useSettingsStore.getState()
67
+ const pairedModel = settings.getSetting(SETTINGS.default_controller.key)
68
+ const pairedName = settings.getSetting(SETTINGS.controller_device_name.key)
69
+ return (!deviceModel || pairedModel === deviceModel) && (!deviceName || pairedName === deviceName)
70
+ }
71
+
72
+ if (!isGlassesReady(glasses.connection)) return false
73
+ const identity = projectPairingIdentity()
74
+ if (!deviceModel && !deviceName) return true
75
+ return (
76
+ identity.kind === "paired" &&
77
+ (!deviceModel || identity.model === deviceModel) &&
78
+ (!deviceName || identity.name === deviceName)
79
+ )
80
+ }
81
+
82
+ function subscribeTargetReady(
83
+ options: Pick<PairingReadyWaitOptions, "deviceModel" | "deviceName">,
84
+ cb: (ready: boolean) => void,
85
+ ): () => void {
86
+ let last = projectTargetReady(options)
87
+ const notify = () => {
88
+ const ready = projectTargetReady(options)
89
+ if (ready === last) return
90
+ last = ready
91
+ cb(ready)
92
+ }
93
+ const unsubscribeGlasses = useGlassesStore.subscribe(notify)
94
+ const unsubscribeSettings = useSettingsStore.subscribe(notify)
95
+ return () => {
96
+ unsubscribeGlasses()
97
+ unsubscribeSettings()
98
+ }
99
+ }
100
+
101
+ async function waitForTargetReady(options: PairingReadyWaitOptions, timeoutMs: number): Promise<boolean> {
102
+ return new Promise((resolve) => {
103
+ if (options.signal?.aborted) {
104
+ resolve(false)
105
+ return
106
+ }
107
+ if (projectTargetReady(options)) {
108
+ resolve(true)
109
+ return
110
+ }
111
+
112
+ let settled = false
113
+ let timeout: ReturnType<typeof setTimeout> | null = null
114
+ let unsubscribe: (() => void) | null = null
115
+ let onAbort: (() => void) | null = null
116
+ const finish = (ready: boolean) => {
117
+ if (settled) return
118
+ settled = true
119
+ if (timeout) clearTimeout(timeout)
120
+ if (unsubscribe) unsubscribe()
121
+ if (onAbort && options.signal) options.signal.removeEventListener("abort", onAbort)
122
+ resolve(ready)
123
+ }
124
+
125
+ unsubscribe = subscribeTargetReady(options, (ready) => {
126
+ if (ready) finish(true)
127
+ })
128
+ if (options.signal) {
129
+ onAbort = () => finish(false)
130
+ options.signal.addEventListener("abort", onAbort)
131
+ }
132
+ timeout = setTimeout(() => finish(projectTargetReady(options)), timeoutMs)
133
+ })
134
+ }
135
+
63
136
  export type PairingReadinessSnapshot = ReturnType<typeof projectReadiness>
64
137
 
65
138
  export async function submitPairingBootTimeoutReport(params: {
@@ -108,12 +181,7 @@ async function waitForReadyDuringPairing(options: PairingReadyWaitOptions = {}):
108
181
  })
109
182
 
110
183
  try {
111
- const ready = await waitForGlassesReady({
112
- getConnection: () => useGlassesStore.getState().connection,
113
- subscribe: (listener) => useGlassesStore.subscribe((state) => state.connection, listener),
114
- timeoutMs,
115
- signal: options.signal,
116
- })
184
+ const ready = await waitForTargetReady(options, timeoutMs)
117
185
 
118
186
  if (!ready && !options.signal?.aborted) {
119
187
  void submitPairingBootTimeoutReport({
@@ -193,6 +261,14 @@ export const pairing = {
193
261
  cb(snap)
194
262
  })
195
263
  },
264
+ /** Whether the exact wearable or controller selected on the scan screen is ready. */
265
+ targetReady: (options: Pick<PairingReadyWaitOptions, "deviceModel" | "deviceName">): boolean =>
266
+ projectTargetReady(options),
267
+ /** Subscribe to readiness for the exact selected target, excluding stale devices. */
268
+ onTargetReady: (
269
+ options: Pick<PairingReadyWaitOptions, "deviceModel" | "deviceName">,
270
+ cb: (ready: boolean) => void,
271
+ ): (() => void) => subscribeTargetReady(options, cb),
196
272
 
197
273
  // --- pairing-identity lifecycle (the PairingIdentity read-model + the JS-owned
198
274
  // identity writes; promotion to `paired` only ever happens natively) ---
@@ -12,9 +12,9 @@ export interface EngineReleaseMetadata {
12
12
  export const ENGINE_RELEASE_METADATA: Readonly<EngineReleaseMetadata> = Object.freeze({
13
13
  "schemaVersion": 1,
14
14
  "familyBaseVersion": "3.1.0",
15
- "releaseIdentity": "3.1.0-dev.10",
16
- "releaseSetId": "mentra-3.1.0-dev.10",
17
- "sourceCommit": "64cf83b23a71e70261571a5f4401d1a7538f1852",
18
- "otaManifestUrl": "https://github.com/Mentra-Community/MentraOS/releases/download/mentra-v3.1.0-dev.10/mentra-live-ota-3.1.0-dev.10.json",
19
- "otaManifestSha256": "214d92c8894033eaab276e668cb553c79990005d3330d23aaf499a514dc08cff"
15
+ "releaseIdentity": "3.1.0-dev.102",
16
+ "releaseSetId": "mentra-3.1.0-dev.102",
17
+ "sourceCommit": "1e5cd9f88a6a43db2f51f4ddd3c6a4b8f15d0fed",
18
+ "otaManifestUrl": "https://github.com/Mentra-Community/MentraOS/releases/download/mentra-builds-v3.1.0/mentra-live-ota-3.1.0-dev.102.json",
19
+ "otaManifestSha256": "5ff3b609846566abecea90ce5fed4a8d281db2dee82a728b7d80a97beedc4f13"
20
20
  })
package/src/index.ts CHANGED
@@ -89,6 +89,7 @@ export {
89
89
  GLOBAL_OTA_TIMEOUT_MS,
90
90
  PING_INTERVAL_MS,
91
91
  QUERY_REPLY_TIMEOUT_MS,
92
+ BES_RESTART_TIMEOUT_MS,
92
93
  OtaProgressMessages,
93
94
  } from "./services/otaInstallPolicy"
94
95
  export {deriveDisplayState} from "./services/otaDisplayState"
@@ -98,6 +99,7 @@ export type {
98
99
  OtaProgressStatus,
99
100
  OtaStatus,
100
101
  OtaUpdateInfo,
102
+ ReleaseChangelog,
101
103
  OtaSnapshot,
102
104
  OtaInstallSnapshot,
103
105
  } from "./facades/ota"
@@ -195,6 +197,7 @@ export {
195
197
  evenRealitiesG1,
196
198
  evenRealitiesG2,
197
199
  mentraLive,
200
+ nimo,
198
201
  vuzixZ100,
199
202
  mentraDisplay,
200
203
  } from "./types"