@moldable-ai/ui 0.2.18 → 0.2.20

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 (587) hide show
  1. package/dist/catalog/catalog-manifest.d.ts +6 -0
  2. package/dist/catalog/catalog-manifest.d.ts.map +1 -0
  3. package/dist/catalog/catalog-manifest.js +105 -0
  4. package/dist/catalog/catalog-types.d.ts +54 -0
  5. package/dist/catalog/catalog-types.d.ts.map +1 -0
  6. package/dist/catalog/catalog-types.js +14 -0
  7. package/dist/catalog/component-catalog.d.ts +14 -0
  8. package/dist/catalog/component-catalog.d.ts.map +1 -0
  9. package/dist/catalog/component-catalog.js +39 -0
  10. package/dist/catalog/core-catalog.d.ts +6 -0
  11. package/dist/catalog/core-catalog.d.ts.map +1 -0
  12. package/dist/catalog/core-catalog.js +105 -0
  13. package/dist/catalog/index.d.ts +5 -0
  14. package/dist/catalog/index.d.ts.map +1 -0
  15. package/dist/catalog/index.js +4 -0
  16. package/dist/components/app-error-boundary.d.ts +1 -0
  17. package/dist/components/app-error-boundary.d.ts.map +1 -1
  18. package/dist/components/app-error-boundary.js +13 -0
  19. package/dist/components/chat/chat-image-lightbox.d.ts +9 -0
  20. package/dist/components/chat/chat-image-lightbox.d.ts.map +1 -0
  21. package/dist/components/chat/chat-image-lightbox.js +9 -0
  22. package/dist/components/chat/chat-message.d.ts +19 -1
  23. package/dist/components/chat/chat-message.d.ts.map +1 -1
  24. package/dist/components/chat/chat-message.js +66 -16
  25. package/dist/components/chat/chat-messages.d.ts +5 -2
  26. package/dist/components/chat/chat-messages.d.ts.map +1 -1
  27. package/dist/components/chat/chat-messages.js +61 -6
  28. package/dist/components/chat/chat-panel.d.ts +67 -17
  29. package/dist/components/chat/chat-panel.d.ts.map +1 -1
  30. package/dist/components/chat/chat-panel.js +250 -159
  31. package/dist/components/chat/conversation-history.d.ts +39 -5
  32. package/dist/components/chat/conversation-history.d.ts.map +1 -1
  33. package/dist/components/chat/conversation-history.js +192 -26
  34. package/dist/components/chat/index.d.ts +3 -2
  35. package/dist/components/chat/index.d.ts.map +1 -1
  36. package/dist/components/chat/index.js +3 -2
  37. package/dist/components/chat/model-effort-power-effects.d.ts +7 -0
  38. package/dist/components/chat/model-effort-power-effects.d.ts.map +1 -0
  39. package/dist/components/chat/model-effort-power-effects.js +54 -0
  40. package/dist/components/chat/model-effort-selector.d.ts +26 -0
  41. package/dist/components/chat/model-effort-selector.d.ts.map +1 -0
  42. package/dist/components/chat/model-effort-selector.js +179 -0
  43. package/dist/components/chat/model-effort-ultra-effects.d.ts +5 -0
  44. package/dist/components/chat/model-effort-ultra-effects.d.ts.map +1 -0
  45. package/dist/components/chat/model-effort-ultra-effects.js +56 -0
  46. package/dist/components/chat/tool-handlers.d.ts.map +1 -1
  47. package/dist/components/chat/tool-handlers.js +40 -2
  48. package/dist/components/chat/vertical-scroll-fade.d.ts +6 -0
  49. package/dist/components/chat/vertical-scroll-fade.d.ts.map +1 -0
  50. package/dist/components/chat/vertical-scroll-fade.js +12 -0
  51. package/dist/components/hardware/bluetooth-panel-helpers.d.ts +9 -0
  52. package/dist/components/hardware/bluetooth-panel-helpers.d.ts.map +1 -0
  53. package/dist/components/hardware/bluetooth-panel-helpers.js +37 -0
  54. package/dist/components/hardware/bluetooth-panel.d.ts +56 -0
  55. package/dist/components/hardware/bluetooth-panel.d.ts.map +1 -0
  56. package/dist/components/hardware/bluetooth-panel.js +470 -0
  57. package/dist/components/hardware/camera-preview.d.ts +39 -0
  58. package/dist/components/hardware/camera-preview.d.ts.map +1 -0
  59. package/dist/components/hardware/camera-preview.js +228 -0
  60. package/dist/components/hardware/capability-badge.d.ts +23 -0
  61. package/dist/components/hardware/capability-badge.d.ts.map +1 -0
  62. package/dist/components/hardware/capability-badge.js +39 -0
  63. package/dist/components/hardware/capability-matrix.d.ts +14 -0
  64. package/dist/components/hardware/capability-matrix.d.ts.map +1 -0
  65. package/dist/components/hardware/capability-matrix.js +97 -0
  66. package/dist/components/hardware/clipboard-button.d.ts +26 -0
  67. package/dist/components/hardware/clipboard-button.d.ts.map +1 -0
  68. package/dist/components/hardware/clipboard-button.js +114 -0
  69. package/dist/components/hardware/device-io-controls.d.ts +4 -0
  70. package/dist/components/hardware/device-io-controls.d.ts.map +1 -0
  71. package/dist/components/hardware/device-io-controls.js +28 -0
  72. package/dist/components/hardware/device-list.d.ts +20 -0
  73. package/dist/components/hardware/device-list.d.ts.map +1 -0
  74. package/dist/components/hardware/device-list.js +14 -0
  75. package/dist/components/hardware/display-map.d.ts +23 -0
  76. package/dist/components/hardware/display-map.d.ts.map +1 -0
  77. package/dist/components/hardware/display-map.js +114 -0
  78. package/dist/components/hardware/haptic-button.d.ts +26 -0
  79. package/dist/components/hardware/haptic-button.d.ts.map +1 -0
  80. package/dist/components/hardware/haptic-button.js +94 -0
  81. package/dist/components/hardware/hardware-panel.d.ts +11 -0
  82. package/dist/components/hardware/hardware-panel.d.ts.map +1 -0
  83. package/dist/components/hardware/hardware-panel.js +28 -0
  84. package/dist/components/hardware/hid-panel.d.ts +40 -0
  85. package/dist/components/hardware/hid-panel.d.ts.map +1 -0
  86. package/dist/components/hardware/hid-panel.js +373 -0
  87. package/dist/components/hardware/index.d.ts +27 -0
  88. package/dist/components/hardware/index.d.ts.map +1 -0
  89. package/dist/components/hardware/index.js +26 -0
  90. package/dist/components/hardware/live-indicator.d.ts +15 -0
  91. package/dist/components/hardware/live-indicator.d.ts.map +1 -0
  92. package/dist/components/hardware/live-indicator.js +26 -0
  93. package/dist/components/hardware/local-auth-button.d.ts +33 -0
  94. package/dist/components/hardware/local-auth-button.d.ts.map +1 -0
  95. package/dist/components/hardware/local-auth-button.js +115 -0
  96. package/dist/components/hardware/location-panel.d.ts +29 -0
  97. package/dist/components/hardware/location-panel.d.ts.map +1 -0
  98. package/dist/components/hardware/location-panel.js +154 -0
  99. package/dist/components/hardware/microphone-meter.d.ts +35 -0
  100. package/dist/components/hardware/microphone-meter.d.ts.map +1 -0
  101. package/dist/components/hardware/microphone-meter.js +244 -0
  102. package/dist/components/hardware/midi-monitor.d.ts +54 -0
  103. package/dist/components/hardware/midi-monitor.d.ts.map +1 -0
  104. package/dist/components/hardware/midi-monitor.js +534 -0
  105. package/dist/components/hardware/notification-panel.d.ts +24 -0
  106. package/dist/components/hardware/notification-panel.d.ts.map +1 -0
  107. package/dist/components/hardware/notification-panel.js +124 -0
  108. package/dist/components/hardware/power-blocker-controller.d.ts +19 -0
  109. package/dist/components/hardware/power-blocker-controller.d.ts.map +1 -0
  110. package/dist/components/hardware/power-blocker-controller.js +83 -0
  111. package/dist/components/hardware/power-panel.d.ts +67 -0
  112. package/dist/components/hardware/power-panel.d.ts.map +1 -0
  113. package/dist/components/hardware/power-panel.js +309 -0
  114. package/dist/components/hardware/readout.d.ts +10 -0
  115. package/dist/components/hardware/readout.d.ts.map +1 -0
  116. package/dist/components/hardware/readout.js +11 -0
  117. package/dist/components/hardware/screen-share-preview.d.ts +36 -0
  118. package/dist/components/hardware/screen-share-preview.d.ts.map +1 -0
  119. package/dist/components/hardware/screen-share-preview.js +191 -0
  120. package/dist/components/hardware/secure-storage-panel.d.ts +36 -0
  121. package/dist/components/hardware/secure-storage-panel.d.ts.map +1 -0
  122. package/dist/components/hardware/secure-storage-panel.js +193 -0
  123. package/dist/components/hardware/serial-console.d.ts +64 -0
  124. package/dist/components/hardware/serial-console.d.ts.map +1 -0
  125. package/dist/components/hardware/serial-console.js +399 -0
  126. package/dist/components/hardware/shortcut-recorder.d.ts +35 -0
  127. package/dist/components/hardware/shortcut-recorder.d.ts.map +1 -0
  128. package/dist/components/hardware/shortcut-recorder.js +217 -0
  129. package/dist/components/hardware/stream-log.d.ts +35 -0
  130. package/dist/components/hardware/stream-log.d.ts.map +1 -0
  131. package/dist/components/hardware/stream-log.js +65 -0
  132. package/dist/components/hardware/system-audio-monitor.d.ts +34 -0
  133. package/dist/components/hardware/system-audio-monitor.d.ts.map +1 -0
  134. package/dist/components/hardware/system-audio-monitor.js +275 -0
  135. package/dist/components/hardware/usb-panel.d.ts +54 -0
  136. package/dist/components/hardware/usb-panel.d.ts.map +1 -0
  137. package/dist/components/hardware/usb-panel.js +363 -0
  138. package/dist/components/hardware/use-capability.d.ts +20 -0
  139. package/dist/components/hardware/use-capability.d.ts.map +1 -0
  140. package/dist/components/hardware/use-capability.js +61 -0
  141. package/dist/components/native-capabilities/bluetooth-panel-helpers.d.ts +9 -0
  142. package/dist/components/native-capabilities/bluetooth-panel-helpers.d.ts.map +1 -0
  143. package/dist/components/native-capabilities/bluetooth-panel-helpers.js +37 -0
  144. package/dist/components/native-capabilities/bluetooth-panel.d.ts +56 -0
  145. package/dist/components/native-capabilities/bluetooth-panel.d.ts.map +1 -0
  146. package/dist/components/native-capabilities/bluetooth-panel.js +470 -0
  147. package/dist/components/native-capabilities/camera-preview.d.ts +39 -0
  148. package/dist/components/native-capabilities/camera-preview.d.ts.map +1 -0
  149. package/dist/components/native-capabilities/camera-preview.js +228 -0
  150. package/dist/components/native-capabilities/capability-badge.d.ts +23 -0
  151. package/dist/components/native-capabilities/capability-badge.d.ts.map +1 -0
  152. package/dist/components/native-capabilities/capability-badge.js +39 -0
  153. package/dist/components/native-capabilities/capability-matrix.d.ts +14 -0
  154. package/dist/components/native-capabilities/capability-matrix.d.ts.map +1 -0
  155. package/dist/components/native-capabilities/capability-matrix.js +97 -0
  156. package/dist/components/native-capabilities/clipboard-button.d.ts +26 -0
  157. package/dist/components/native-capabilities/clipboard-button.d.ts.map +1 -0
  158. package/dist/components/native-capabilities/clipboard-button.js +99 -0
  159. package/dist/components/native-capabilities/device-io-controls.d.ts +4 -0
  160. package/dist/components/native-capabilities/device-io-controls.d.ts.map +1 -0
  161. package/dist/components/native-capabilities/device-io-controls.js +28 -0
  162. package/dist/components/native-capabilities/device-list.d.ts +20 -0
  163. package/dist/components/native-capabilities/device-list.d.ts.map +1 -0
  164. package/dist/components/native-capabilities/device-list.js +14 -0
  165. package/dist/components/native-capabilities/display-map.d.ts +23 -0
  166. package/dist/components/native-capabilities/display-map.d.ts.map +1 -0
  167. package/dist/components/native-capabilities/display-map.js +114 -0
  168. package/dist/components/native-capabilities/haptic-button.d.ts +26 -0
  169. package/dist/components/native-capabilities/haptic-button.d.ts.map +1 -0
  170. package/dist/components/native-capabilities/haptic-button.js +94 -0
  171. package/dist/components/native-capabilities/hid-panel.d.ts +40 -0
  172. package/dist/components/native-capabilities/hid-panel.d.ts.map +1 -0
  173. package/dist/components/native-capabilities/hid-panel.js +373 -0
  174. package/dist/components/native-capabilities/index.d.ts +27 -0
  175. package/dist/components/native-capabilities/index.d.ts.map +1 -0
  176. package/dist/components/native-capabilities/index.js +26 -0
  177. package/dist/components/native-capabilities/live-indicator.d.ts +15 -0
  178. package/dist/components/native-capabilities/live-indicator.d.ts.map +1 -0
  179. package/dist/components/native-capabilities/live-indicator.js +26 -0
  180. package/dist/components/native-capabilities/local-auth-button.d.ts +33 -0
  181. package/dist/components/native-capabilities/local-auth-button.d.ts.map +1 -0
  182. package/dist/components/native-capabilities/local-auth-button.js +115 -0
  183. package/dist/components/native-capabilities/location-panel.d.ts +29 -0
  184. package/dist/components/native-capabilities/location-panel.d.ts.map +1 -0
  185. package/dist/components/native-capabilities/location-panel.js +146 -0
  186. package/dist/components/native-capabilities/microphone-meter.d.ts +35 -0
  187. package/dist/components/native-capabilities/microphone-meter.d.ts.map +1 -0
  188. package/dist/components/native-capabilities/microphone-meter.js +244 -0
  189. package/dist/components/native-capabilities/midi-monitor.d.ts +54 -0
  190. package/dist/components/native-capabilities/midi-monitor.d.ts.map +1 -0
  191. package/dist/components/native-capabilities/midi-monitor.js +534 -0
  192. package/dist/components/native-capabilities/native-capability-panel.d.ts +11 -0
  193. package/dist/components/native-capabilities/native-capability-panel.d.ts.map +1 -0
  194. package/dist/components/native-capabilities/native-capability-panel.js +28 -0
  195. package/dist/components/native-capabilities/notification-panel.d.ts +24 -0
  196. package/dist/components/native-capabilities/notification-panel.d.ts.map +1 -0
  197. package/dist/components/native-capabilities/notification-panel.js +124 -0
  198. package/dist/components/native-capabilities/power-blocker-controller.d.ts +19 -0
  199. package/dist/components/native-capabilities/power-blocker-controller.d.ts.map +1 -0
  200. package/dist/components/native-capabilities/power-blocker-controller.js +83 -0
  201. package/dist/components/native-capabilities/power-panel.d.ts +67 -0
  202. package/dist/components/native-capabilities/power-panel.d.ts.map +1 -0
  203. package/dist/components/native-capabilities/power-panel.js +309 -0
  204. package/dist/components/native-capabilities/readout.d.ts +10 -0
  205. package/dist/components/native-capabilities/readout.d.ts.map +1 -0
  206. package/dist/components/native-capabilities/readout.js +11 -0
  207. package/dist/components/native-capabilities/screen-share-preview.d.ts +36 -0
  208. package/dist/components/native-capabilities/screen-share-preview.d.ts.map +1 -0
  209. package/dist/components/native-capabilities/screen-share-preview.js +191 -0
  210. package/dist/components/native-capabilities/secure-storage-panel.d.ts +36 -0
  211. package/dist/components/native-capabilities/secure-storage-panel.d.ts.map +1 -0
  212. package/dist/components/native-capabilities/secure-storage-panel.js +193 -0
  213. package/dist/components/native-capabilities/serial-console.d.ts +64 -0
  214. package/dist/components/native-capabilities/serial-console.d.ts.map +1 -0
  215. package/dist/components/native-capabilities/serial-console.js +399 -0
  216. package/dist/components/native-capabilities/shortcut-recorder.d.ts +35 -0
  217. package/dist/components/native-capabilities/shortcut-recorder.d.ts.map +1 -0
  218. package/dist/components/native-capabilities/shortcut-recorder.js +217 -0
  219. package/dist/components/native-capabilities/stream-log.d.ts +35 -0
  220. package/dist/components/native-capabilities/stream-log.d.ts.map +1 -0
  221. package/dist/components/native-capabilities/stream-log.js +65 -0
  222. package/dist/components/native-capabilities/system-audio-monitor.d.ts +34 -0
  223. package/dist/components/native-capabilities/system-audio-monitor.d.ts.map +1 -0
  224. package/dist/components/native-capabilities/system-audio-monitor.js +275 -0
  225. package/dist/components/native-capabilities/usb-panel.d.ts +54 -0
  226. package/dist/components/native-capabilities/usb-panel.d.ts.map +1 -0
  227. package/dist/components/native-capabilities/usb-panel.js +363 -0
  228. package/dist/components/native-capabilities/use-capability.d.ts +20 -0
  229. package/dist/components/native-capabilities/use-capability.d.ts.map +1 -0
  230. package/dist/components/native-capabilities/use-capability.js +61 -0
  231. package/dist/components/ui/app-frame.d.ts +22 -0
  232. package/dist/components/ui/app-frame.d.ts.map +1 -0
  233. package/dist/components/ui/app-frame.js +56 -0
  234. package/dist/components/ui/button-group.d.ts +1 -1
  235. package/dist/components/ui/button.js +1 -1
  236. package/dist/components/ui/color-well.d.ts +13 -0
  237. package/dist/components/ui/color-well.d.ts.map +1 -0
  238. package/dist/components/ui/color-well.js +30 -0
  239. package/dist/components/ui/date-field.d.ts +19 -0
  240. package/dist/components/ui/date-field.d.ts.map +1 -0
  241. package/dist/components/ui/date-field.js +54 -0
  242. package/dist/components/ui/edge-fade.d.ts +11 -0
  243. package/dist/components/ui/edge-fade.d.ts.map +1 -0
  244. package/dist/components/ui/edge-fade.js +41 -0
  245. package/dist/components/ui/empty.js +1 -1
  246. package/dist/components/ui/field.d.ts +1 -1
  247. package/dist/components/ui/grid.d.ts +24 -0
  248. package/dist/components/ui/grid.d.ts.map +1 -0
  249. package/dist/components/ui/grid.js +234 -0
  250. package/dist/components/ui/icon-button.d.ts +15 -0
  251. package/dist/components/ui/icon-button.d.ts.map +1 -0
  252. package/dist/components/ui/icon-button.js +15 -0
  253. package/dist/components/ui/index.d.ts +19 -0
  254. package/dist/components/ui/index.d.ts.map +1 -1
  255. package/dist/components/ui/index.js +19 -0
  256. package/dist/components/ui/inspector.d.ts +15 -0
  257. package/dist/components/ui/inspector.d.ts.map +1 -0
  258. package/dist/components/ui/inspector.js +26 -0
  259. package/dist/components/ui/kbd.d.ts +1 -1
  260. package/dist/components/ui/list.d.ts +24 -0
  261. package/dist/components/ui/list.d.ts.map +1 -0
  262. package/dist/components/ui/list.js +224 -0
  263. package/dist/components/ui/message-scroller-layout-stability.d.ts +33 -0
  264. package/dist/components/ui/message-scroller-layout-stability.d.ts.map +1 -0
  265. package/dist/components/ui/message-scroller-layout-stability.js +153 -0
  266. package/dist/components/ui/message-scroller.d.ts +11 -0
  267. package/dist/components/ui/message-scroller.d.ts.map +1 -0
  268. package/dist/components/ui/message-scroller.js +37 -0
  269. package/dist/components/ui/notification-dot.d.ts +4 -0
  270. package/dist/components/ui/notification-dot.d.ts.map +1 -0
  271. package/dist/components/ui/notification-dot.js +7 -0
  272. package/dist/components/ui/number-input.d.ts +16 -0
  273. package/dist/components/ui/number-input.d.ts.map +1 -0
  274. package/dist/components/ui/number-input.js +56 -0
  275. package/dist/components/ui/panel.d.ts +18 -0
  276. package/dist/components/ui/panel.d.ts.map +1 -0
  277. package/dist/components/ui/panel.js +40 -0
  278. package/dist/components/ui/popover.js +1 -1
  279. package/dist/components/ui/search-field.d.ts +19 -0
  280. package/dist/components/ui/search-field.d.ts.map +1 -0
  281. package/dist/components/ui/search-field.js +64 -0
  282. package/dist/components/ui/segmented-control.d.ts +21 -0
  283. package/dist/components/ui/segmented-control.d.ts.map +1 -0
  284. package/dist/components/ui/segmented-control.js +61 -0
  285. package/dist/components/ui/sidebar.js +1 -1
  286. package/dist/components/ui/slider.d.ts +4 -1
  287. package/dist/components/ui/slider.d.ts.map +1 -1
  288. package/dist/components/ui/slider.js +2 -2
  289. package/dist/components/ui/sonner.d.ts +4 -3
  290. package/dist/components/ui/sonner.d.ts.map +1 -1
  291. package/dist/components/ui/sonner.js +7 -6
  292. package/dist/components/ui/split-view.d.ts +11 -0
  293. package/dist/components/ui/split-view.d.ts.map +1 -0
  294. package/dist/components/ui/split-view.js +13 -0
  295. package/dist/components/ui/status.d.ts +13 -0
  296. package/dist/components/ui/status.d.ts.map +1 -0
  297. package/dist/components/ui/status.js +36 -0
  298. package/dist/components/ui/table.d.ts +11 -2
  299. package/dist/components/ui/table.d.ts.map +1 -1
  300. package/dist/components/ui/table.js +28 -6
  301. package/dist/components/ui/text.d.ts +17 -0
  302. package/dist/components/ui/text.d.ts.map +1 -0
  303. package/dist/components/ui/text.js +55 -0
  304. package/dist/components/ui/toggle.js +1 -1
  305. package/dist/components/ui/toolbar.d.ts +20 -0
  306. package/dist/components/ui/toolbar.d.ts.map +1 -0
  307. package/dist/components/ui/toolbar.js +52 -0
  308. package/dist/index.d.ts +2 -0
  309. package/dist/index.d.ts.map +1 -1
  310. package/dist/index.js +4 -0
  311. package/dist/lib/frame-lifecycle.d.ts +28 -0
  312. package/dist/lib/frame-lifecycle.d.ts.map +1 -1
  313. package/dist/lib/frame-lifecycle.js +84 -0
  314. package/dist/lib/native-capabilities/access.d.ts +13 -0
  315. package/dist/lib/native-capabilities/access.d.ts.map +1 -0
  316. package/dist/lib/native-capabilities/access.js +53 -0
  317. package/dist/lib/native-capabilities/bluetooth-access.d.ts +14 -0
  318. package/dist/lib/native-capabilities/bluetooth-access.d.ts.map +1 -0
  319. package/dist/lib/native-capabilities/bluetooth-access.js +43 -0
  320. package/dist/lib/native-capabilities/bluetooth-connection.d.ts +19 -0
  321. package/dist/lib/native-capabilities/bluetooth-connection.d.ts.map +1 -0
  322. package/dist/lib/native-capabilities/bluetooth-connection.js +88 -0
  323. package/dist/lib/native-capabilities/bluetooth-gatt.d.ts +7 -0
  324. package/dist/lib/native-capabilities/bluetooth-gatt.d.ts.map +1 -0
  325. package/dist/lib/native-capabilities/bluetooth-gatt.js +77 -0
  326. package/dist/lib/native-capabilities/bluetooth-internal.d.ts +10 -0
  327. package/dist/lib/native-capabilities/bluetooth-internal.d.ts.map +1 -0
  328. package/dist/lib/native-capabilities/bluetooth-internal.js +105 -0
  329. package/dist/lib/native-capabilities/bluetooth-native-fallback.d.ts +33 -0
  330. package/dist/lib/native-capabilities/bluetooth-native-fallback.d.ts.map +1 -0
  331. package/dist/lib/native-capabilities/bluetooth-native-fallback.js +214 -0
  332. package/dist/lib/native-capabilities/bluetooth-types.d.ts +85 -0
  333. package/dist/lib/native-capabilities/bluetooth-types.d.ts.map +1 -0
  334. package/dist/lib/native-capabilities/bluetooth-types.js +2 -0
  335. package/dist/lib/native-capabilities/bluetooth.d.ts +7 -0
  336. package/dist/lib/native-capabilities/bluetooth.d.ts.map +1 -0
  337. package/dist/lib/native-capabilities/bluetooth.js +4 -0
  338. package/dist/lib/native-capabilities/bridge.d.ts +23 -0
  339. package/dist/lib/native-capabilities/bridge.d.ts.map +1 -0
  340. package/dist/lib/native-capabilities/bridge.js +266 -0
  341. package/dist/lib/native-capabilities/capabilities.d.ts +7 -0
  342. package/dist/lib/native-capabilities/capabilities.d.ts.map +1 -0
  343. package/dist/lib/native-capabilities/capabilities.js +95 -0
  344. package/dist/lib/native-capabilities/clipboard.d.ts +11 -0
  345. package/dist/lib/native-capabilities/clipboard.d.ts.map +1 -0
  346. package/dist/lib/native-capabilities/clipboard.js +58 -0
  347. package/dist/lib/native-capabilities/device-io-errors.d.ts +11 -0
  348. package/dist/lib/native-capabilities/device-io-errors.d.ts.map +1 -0
  349. package/dist/lib/native-capabilities/device-io-errors.js +82 -0
  350. package/dist/lib/native-capabilities/displays.d.ts +38 -0
  351. package/dist/lib/native-capabilities/displays.d.ts.map +1 -0
  352. package/dist/lib/native-capabilities/displays.js +12 -0
  353. package/dist/lib/native-capabilities/global-shortcuts.d.ts +86 -0
  354. package/dist/lib/native-capabilities/global-shortcuts.d.ts.map +1 -0
  355. package/dist/lib/native-capabilities/global-shortcuts.js +351 -0
  356. package/dist/lib/native-capabilities/haptics.d.ts +25 -0
  357. package/dist/lib/native-capabilities/haptics.d.ts.map +1 -0
  358. package/dist/lib/native-capabilities/haptics.js +18 -0
  359. package/dist/lib/native-capabilities/hid-native.d.ts +26 -0
  360. package/dist/lib/native-capabilities/hid-native.d.ts.map +1 -0
  361. package/dist/lib/native-capabilities/hid-native.js +229 -0
  362. package/dist/lib/native-capabilities/hid.d.ts +52 -0
  363. package/dist/lib/native-capabilities/hid.d.ts.map +1 -0
  364. package/dist/lib/native-capabilities/hid.js +163 -0
  365. package/dist/lib/native-capabilities/index.d.ts +40 -0
  366. package/dist/lib/native-capabilities/index.d.ts.map +1 -0
  367. package/dist/lib/native-capabilities/index.js +21 -0
  368. package/dist/lib/native-capabilities/local-authentication.d.ts +32 -0
  369. package/dist/lib/native-capabilities/local-authentication.d.ts.map +1 -0
  370. package/dist/lib/native-capabilities/local-authentication.js +46 -0
  371. package/dist/lib/native-capabilities/location.d.ts +49 -0
  372. package/dist/lib/native-capabilities/location.d.ts.map +1 -0
  373. package/dist/lib/native-capabilities/location.js +114 -0
  374. package/dist/lib/native-capabilities/media-permissions.d.ts +28 -0
  375. package/dist/lib/native-capabilities/media-permissions.d.ts.map +1 -0
  376. package/dist/lib/native-capabilities/media-permissions.js +37 -0
  377. package/dist/lib/native-capabilities/media.d.ts +17 -0
  378. package/dist/lib/native-capabilities/media.d.ts.map +1 -0
  379. package/dist/lib/native-capabilities/media.js +104 -0
  380. package/dist/lib/native-capabilities/midi-access.d.ts +13 -0
  381. package/dist/lib/native-capabilities/midi-access.d.ts.map +1 -0
  382. package/dist/lib/native-capabilities/midi-access.js +68 -0
  383. package/dist/lib/native-capabilities/midi-internal.d.ts +12 -0
  384. package/dist/lib/native-capabilities/midi-internal.d.ts.map +1 -0
  385. package/dist/lib/native-capabilities/midi-internal.js +88 -0
  386. package/dist/lib/native-capabilities/midi-native-fallback.d.ts +27 -0
  387. package/dist/lib/native-capabilities/midi-native-fallback.d.ts.map +1 -0
  388. package/dist/lib/native-capabilities/midi-native-fallback.js +127 -0
  389. package/dist/lib/native-capabilities/midi-ports.d.ts +6 -0
  390. package/dist/lib/native-capabilities/midi-ports.d.ts.map +1 -0
  391. package/dist/lib/native-capabilities/midi-ports.js +115 -0
  392. package/dist/lib/native-capabilities/midi-types.d.ts +25 -0
  393. package/dist/lib/native-capabilities/midi-types.d.ts.map +1 -0
  394. package/dist/lib/native-capabilities/midi-types.js +1 -0
  395. package/dist/lib/native-capabilities/midi.d.ts +6 -0
  396. package/dist/lib/native-capabilities/midi.d.ts.map +1 -0
  397. package/dist/lib/native-capabilities/midi.js +3 -0
  398. package/dist/lib/native-capabilities/native-device-io.d.ts +28 -0
  399. package/dist/lib/native-capabilities/native-device-io.d.ts.map +1 -0
  400. package/dist/lib/native-capabilities/native-device-io.js +91 -0
  401. package/dist/lib/native-capabilities/native-device-lifecycle.d.ts +13 -0
  402. package/dist/lib/native-capabilities/native-device-lifecycle.d.ts.map +1 -0
  403. package/dist/lib/native-capabilities/native-device-lifecycle.js +40 -0
  404. package/dist/lib/native-capabilities/notifications.d.ts +38 -0
  405. package/dist/lib/native-capabilities/notifications.d.ts.map +1 -0
  406. package/dist/lib/native-capabilities/notifications.js +50 -0
  407. package/dist/lib/native-capabilities/power-session.d.ts +113 -0
  408. package/dist/lib/native-capabilities/power-session.d.ts.map +1 -0
  409. package/dist/lib/native-capabilities/power-session.js +264 -0
  410. package/dist/lib/native-capabilities/secure-storage.d.ts +36 -0
  411. package/dist/lib/native-capabilities/secure-storage.d.ts.map +1 -0
  412. package/dist/lib/native-capabilities/secure-storage.js +64 -0
  413. package/dist/lib/native-capabilities/serial-native.d.ts +23 -0
  414. package/dist/lib/native-capabilities/serial-native.d.ts.map +1 -0
  415. package/dist/lib/native-capabilities/serial-native.js +181 -0
  416. package/dist/lib/native-capabilities/serial.d.ts +76 -0
  417. package/dist/lib/native-capabilities/serial.d.ts.map +1 -0
  418. package/dist/lib/native-capabilities/serial.js +215 -0
  419. package/dist/lib/native-capabilities/system-audio.d.ts +127 -0
  420. package/dist/lib/native-capabilities/system-audio.d.ts.map +1 -0
  421. package/dist/lib/native-capabilities/system-audio.js +330 -0
  422. package/dist/lib/native-capabilities/types.d.ts +62 -0
  423. package/dist/lib/native-capabilities/types.d.ts.map +1 -0
  424. package/dist/lib/native-capabilities/types.js +27 -0
  425. package/dist/lib/native-capabilities/usb-native.d.ts +39 -0
  426. package/dist/lib/native-capabilities/usb-native.d.ts.map +1 -0
  427. package/dist/lib/native-capabilities/usb-native.js +217 -0
  428. package/dist/lib/native-capabilities/usb.d.ts +85 -0
  429. package/dist/lib/native-capabilities/usb.d.ts.map +1 -0
  430. package/dist/lib/native-capabilities/usb.js +225 -0
  431. package/dist/lib/native-hardware/bluetooth-access.d.ts +14 -0
  432. package/dist/lib/native-hardware/bluetooth-access.d.ts.map +1 -0
  433. package/dist/lib/native-hardware/bluetooth-access.js +40 -0
  434. package/dist/lib/native-hardware/bluetooth-connection.d.ts +19 -0
  435. package/dist/lib/native-hardware/bluetooth-connection.d.ts.map +1 -0
  436. package/dist/lib/native-hardware/bluetooth-connection.js +88 -0
  437. package/dist/lib/native-hardware/bluetooth-gatt.d.ts +7 -0
  438. package/dist/lib/native-hardware/bluetooth-gatt.d.ts.map +1 -0
  439. package/dist/lib/native-hardware/bluetooth-gatt.js +77 -0
  440. package/dist/lib/native-hardware/bluetooth-internal.d.ts +10 -0
  441. package/dist/lib/native-hardware/bluetooth-internal.d.ts.map +1 -0
  442. package/dist/lib/native-hardware/bluetooth-internal.js +105 -0
  443. package/dist/lib/native-hardware/bluetooth-native-fallback.d.ts +33 -0
  444. package/dist/lib/native-hardware/bluetooth-native-fallback.d.ts.map +1 -0
  445. package/dist/lib/native-hardware/bluetooth-native-fallback.js +214 -0
  446. package/dist/lib/native-hardware/bluetooth-types.d.ts +85 -0
  447. package/dist/lib/native-hardware/bluetooth-types.d.ts.map +1 -0
  448. package/dist/lib/native-hardware/bluetooth-types.js +2 -0
  449. package/dist/lib/native-hardware/bluetooth.d.ts +7 -0
  450. package/dist/lib/native-hardware/bluetooth.d.ts.map +1 -0
  451. package/dist/lib/native-hardware/bluetooth.js +4 -0
  452. package/dist/lib/native-hardware/bridge.d.ts +23 -0
  453. package/dist/lib/native-hardware/bridge.d.ts.map +1 -0
  454. package/dist/lib/native-hardware/bridge.js +266 -0
  455. package/dist/lib/native-hardware/capabilities.d.ts +7 -0
  456. package/dist/lib/native-hardware/capabilities.d.ts.map +1 -0
  457. package/dist/lib/native-hardware/capabilities.js +95 -0
  458. package/dist/lib/native-hardware/clipboard.d.ts +11 -0
  459. package/dist/lib/native-hardware/clipboard.d.ts.map +1 -0
  460. package/dist/lib/native-hardware/clipboard.js +55 -0
  461. package/dist/lib/native-hardware/device-io-errors.d.ts +11 -0
  462. package/dist/lib/native-hardware/device-io-errors.d.ts.map +1 -0
  463. package/dist/lib/native-hardware/device-io-errors.js +82 -0
  464. package/dist/lib/native-hardware/displays.d.ts +38 -0
  465. package/dist/lib/native-hardware/displays.d.ts.map +1 -0
  466. package/dist/lib/native-hardware/displays.js +12 -0
  467. package/dist/lib/native-hardware/global-shortcuts.d.ts +86 -0
  468. package/dist/lib/native-hardware/global-shortcuts.d.ts.map +1 -0
  469. package/dist/lib/native-hardware/global-shortcuts.js +351 -0
  470. package/dist/lib/native-hardware/haptics.d.ts +25 -0
  471. package/dist/lib/native-hardware/haptics.d.ts.map +1 -0
  472. package/dist/lib/native-hardware/haptics.js +18 -0
  473. package/dist/lib/native-hardware/hid-native.d.ts +26 -0
  474. package/dist/lib/native-hardware/hid-native.d.ts.map +1 -0
  475. package/dist/lib/native-hardware/hid-native.js +229 -0
  476. package/dist/lib/native-hardware/hid.d.ts +52 -0
  477. package/dist/lib/native-hardware/hid.d.ts.map +1 -0
  478. package/dist/lib/native-hardware/hid.js +160 -0
  479. package/dist/lib/native-hardware/index.d.ts +38 -0
  480. package/dist/lib/native-hardware/index.d.ts.map +1 -0
  481. package/dist/lib/native-hardware/index.js +20 -0
  482. package/dist/lib/native-hardware/local-authentication.d.ts +32 -0
  483. package/dist/lib/native-hardware/local-authentication.d.ts.map +1 -0
  484. package/dist/lib/native-hardware/local-authentication.js +46 -0
  485. package/dist/lib/native-hardware/location.d.ts +49 -0
  486. package/dist/lib/native-hardware/location.d.ts.map +1 -0
  487. package/dist/lib/native-hardware/location.js +114 -0
  488. package/dist/lib/native-hardware/media-permissions.d.ts +28 -0
  489. package/dist/lib/native-hardware/media-permissions.d.ts.map +1 -0
  490. package/dist/lib/native-hardware/media-permissions.js +37 -0
  491. package/dist/lib/native-hardware/media.d.ts +17 -0
  492. package/dist/lib/native-hardware/media.d.ts.map +1 -0
  493. package/dist/lib/native-hardware/media.js +99 -0
  494. package/dist/lib/native-hardware/midi-access.d.ts +13 -0
  495. package/dist/lib/native-hardware/midi-access.d.ts.map +1 -0
  496. package/dist/lib/native-hardware/midi-access.js +66 -0
  497. package/dist/lib/native-hardware/midi-internal.d.ts +12 -0
  498. package/dist/lib/native-hardware/midi-internal.d.ts.map +1 -0
  499. package/dist/lib/native-hardware/midi-internal.js +88 -0
  500. package/dist/lib/native-hardware/midi-native-fallback.d.ts +27 -0
  501. package/dist/lib/native-hardware/midi-native-fallback.d.ts.map +1 -0
  502. package/dist/lib/native-hardware/midi-native-fallback.js +127 -0
  503. package/dist/lib/native-hardware/midi-ports.d.ts +6 -0
  504. package/dist/lib/native-hardware/midi-ports.d.ts.map +1 -0
  505. package/dist/lib/native-hardware/midi-ports.js +115 -0
  506. package/dist/lib/native-hardware/midi-types.d.ts +25 -0
  507. package/dist/lib/native-hardware/midi-types.d.ts.map +1 -0
  508. package/dist/lib/native-hardware/midi-types.js +1 -0
  509. package/dist/lib/native-hardware/midi.d.ts +6 -0
  510. package/dist/lib/native-hardware/midi.d.ts.map +1 -0
  511. package/dist/lib/native-hardware/midi.js +3 -0
  512. package/dist/lib/native-hardware/native-device-io.d.ts +28 -0
  513. package/dist/lib/native-hardware/native-device-io.d.ts.map +1 -0
  514. package/dist/lib/native-hardware/native-device-io.js +91 -0
  515. package/dist/lib/native-hardware/native-device-lifecycle.d.ts +13 -0
  516. package/dist/lib/native-hardware/native-device-lifecycle.d.ts.map +1 -0
  517. package/dist/lib/native-hardware/native-device-lifecycle.js +40 -0
  518. package/dist/lib/native-hardware/notifications.d.ts +38 -0
  519. package/dist/lib/native-hardware/notifications.d.ts.map +1 -0
  520. package/dist/lib/native-hardware/notifications.js +50 -0
  521. package/dist/lib/native-hardware/power-session.d.ts +113 -0
  522. package/dist/lib/native-hardware/power-session.d.ts.map +1 -0
  523. package/dist/lib/native-hardware/power-session.js +264 -0
  524. package/dist/lib/native-hardware/secure-storage.d.ts +36 -0
  525. package/dist/lib/native-hardware/secure-storage.d.ts.map +1 -0
  526. package/dist/lib/native-hardware/secure-storage.js +64 -0
  527. package/dist/lib/native-hardware/serial-native.d.ts +23 -0
  528. package/dist/lib/native-hardware/serial-native.d.ts.map +1 -0
  529. package/dist/lib/native-hardware/serial-native.js +181 -0
  530. package/dist/lib/native-hardware/serial.d.ts +76 -0
  531. package/dist/lib/native-hardware/serial.d.ts.map +1 -0
  532. package/dist/lib/native-hardware/serial.js +212 -0
  533. package/dist/lib/native-hardware/system-audio.d.ts +127 -0
  534. package/dist/lib/native-hardware/system-audio.d.ts.map +1 -0
  535. package/dist/lib/native-hardware/system-audio.js +330 -0
  536. package/dist/lib/native-hardware/types.d.ts +62 -0
  537. package/dist/lib/native-hardware/types.d.ts.map +1 -0
  538. package/dist/lib/native-hardware/types.js +27 -0
  539. package/dist/lib/native-hardware/usb-native.d.ts +39 -0
  540. package/dist/lib/native-hardware/usb-native.d.ts.map +1 -0
  541. package/dist/lib/native-hardware/usb-native.js +217 -0
  542. package/dist/lib/native-hardware/usb.d.ts +85 -0
  543. package/dist/lib/native-hardware/usb.d.ts.map +1 -0
  544. package/dist/lib/native-hardware/usb.js +222 -0
  545. package/docs/README.md +37 -0
  546. package/docs/accessibility.md +32 -0
  547. package/docs/app-anatomy.md +72 -0
  548. package/docs/component-catalog.md +59 -0
  549. package/docs/component-guide-template.md +37 -0
  550. package/docs/design-tokens.md +172 -0
  551. package/docs/foundations.md +56 -0
  552. package/docs/native-integration.md +33 -0
  553. package/docs/standalone-app-windows.md +128 -0
  554. package/package.json +9 -3
  555. package/src/components/ui/alert.md +55 -0
  556. package/src/components/ui/app-frame.md +33 -0
  557. package/src/components/ui/badge.md +57 -0
  558. package/src/components/ui/button.md +76 -0
  559. package/src/components/ui/color-well.md +11 -0
  560. package/src/components/ui/combobox.md +43 -0
  561. package/src/components/ui/date-field.md +32 -0
  562. package/src/components/ui/edge-fade.md +7 -0
  563. package/src/components/ui/empty.md +82 -0
  564. package/src/components/ui/field.md +77 -0
  565. package/src/components/ui/grid.md +105 -0
  566. package/src/components/ui/icon-button.md +36 -0
  567. package/src/components/ui/inspector.md +11 -0
  568. package/src/components/ui/item.md +87 -0
  569. package/src/components/ui/list.md +107 -0
  570. package/src/components/ui/notification-dot.md +7 -0
  571. package/src/components/ui/number-input.md +19 -0
  572. package/src/components/ui/panel.md +11 -0
  573. package/src/components/ui/resizable.md +66 -0
  574. package/src/components/ui/scroll-area.md +68 -0
  575. package/src/components/ui/search-field.md +33 -0
  576. package/src/components/ui/segmented-control.md +39 -0
  577. package/src/components/ui/sidebar.md +113 -0
  578. package/src/components/ui/sonner.md +37 -0
  579. package/src/components/ui/split-view.md +15 -0
  580. package/src/components/ui/status.md +12 -0
  581. package/src/components/ui/table.md +35 -0
  582. package/src/components/ui/tabs.md +66 -0
  583. package/src/components/ui/text.md +17 -0
  584. package/src/components/ui/toggle-group.md +80 -0
  585. package/src/components/ui/toggle.md +73 -0
  586. package/src/components/ui/toolbar.md +21 -0
  587. package/src/styles/index.css +868 -3
@@ -0,0 +1,88 @@
1
+ import { abortableBluetooth, bluetoothAborted, bluetoothError, } from './bluetooth-internal';
2
+ export class MoldableBluetoothConnection {
3
+ device;
4
+ server;
5
+ abortSignal;
6
+ disconnectListeners = new Set();
7
+ isClosed = false;
8
+ constructor(device, server, options = {}) {
9
+ this.device = device;
10
+ this.server = server;
11
+ this.abortSignal = options.signal;
12
+ device.addEventListener('gattserverdisconnected', this.handleDisconnected);
13
+ options.signal?.addEventListener('abort', this.handleAbort, { once: true });
14
+ }
15
+ get connected() {
16
+ return !this.isClosed && this.server.connected;
17
+ }
18
+ onDisconnected(listener, signal) {
19
+ if (signal?.aborted || this.isClosed)
20
+ return () => undefined;
21
+ this.disconnectListeners.add(listener);
22
+ const cleanup = () => {
23
+ this.disconnectListeners.delete(listener);
24
+ signal?.removeEventListener('abort', cleanup);
25
+ };
26
+ signal?.addEventListener('abort', cleanup, { once: true });
27
+ return cleanup;
28
+ }
29
+ async getPrimaryService(service, options = {}) {
30
+ const operation = `get Bluetooth service ${String(service)}`;
31
+ if (!this.connected) {
32
+ throw bluetoothError(new DOMException('Bluetooth device is disconnected', 'NetworkError'), operation);
33
+ }
34
+ try {
35
+ return await abortableBluetooth(this.server.getPrimaryService(service), options.signal, operation);
36
+ }
37
+ catch (error) {
38
+ throw bluetoothError(error, operation);
39
+ }
40
+ }
41
+ disconnect() {
42
+ if (this.isClosed)
43
+ return;
44
+ this.finish(false);
45
+ if (this.server.connected)
46
+ this.server.disconnect();
47
+ }
48
+ handleAbort = () => this.disconnect();
49
+ handleDisconnected = () => this.finish(true);
50
+ finish(notify) {
51
+ if (this.isClosed)
52
+ return;
53
+ this.isClosed = true;
54
+ this.device.removeEventListener('gattserverdisconnected', this.handleDisconnected);
55
+ this.abortSignal?.removeEventListener('abort', this.handleAbort);
56
+ if (notify) {
57
+ const listeners = [...this.disconnectListeners];
58
+ this.disconnectListeners.clear();
59
+ for (const listener of listeners) {
60
+ try {
61
+ listener();
62
+ }
63
+ catch {
64
+ // A consumer callback must not prevent connection cleanup.
65
+ }
66
+ }
67
+ }
68
+ this.disconnectListeners.clear();
69
+ }
70
+ }
71
+ /** Connects a previously user-selected device and owns disconnect cleanup. */
72
+ export async function connectMoldableBluetoothDevice(device, options = {}) {
73
+ const operation = `connect to Bluetooth device ${device.id}`;
74
+ if (!device.gatt) {
75
+ throw bluetoothError(new DOMException('Device does not expose a GATT server', 'NotSupportedError'), operation);
76
+ }
77
+ try {
78
+ const server = await abortableBluetooth(device.gatt.connect(), options.signal, operation, (lateServer) => lateServer.disconnect());
79
+ if (options.signal?.aborted) {
80
+ server.disconnect();
81
+ throw bluetoothAborted(operation);
82
+ }
83
+ return new MoldableBluetoothConnection(device, server, options);
84
+ }
85
+ catch (error) {
86
+ throw bluetoothError(error, operation);
87
+ }
88
+ }
@@ -0,0 +1,7 @@
1
+ import type { MoldableBluetoothOperationOptions, MoldableBluetoothRemoteGATTCharacteristic, MoldableBluetoothRemoteGATTService, MoldableBluetoothUUID, MoldableBluetoothWriteMode } from './bluetooth-types';
2
+ export declare function getMoldableBluetoothCharacteristic(service: MoldableBluetoothRemoteGATTService, characteristic: MoldableBluetoothUUID, options?: MoldableBluetoothOperationOptions): Promise<MoldableBluetoothRemoteGATTCharacteristic>;
3
+ export declare function readMoldableBluetoothValue(characteristic: MoldableBluetoothRemoteGATTCharacteristic, options?: MoldableBluetoothOperationOptions): Promise<DataView>;
4
+ /** Starts notifications and returns async, idempotent subscription cleanup. */
5
+ export declare function observeMoldableBluetoothNotifications(characteristic: MoldableBluetoothRemoteGATTCharacteristic, listener: (event: Event) => void, options?: MoldableBluetoothOperationOptions): Promise<() => Promise<void>>;
6
+ export declare function writeMoldableBluetoothValue(characteristic: MoldableBluetoothRemoteGATTCharacteristic, value: BufferSource, mode?: MoldableBluetoothWriteMode, options?: MoldableBluetoothOperationOptions): Promise<void>;
7
+ //# sourceMappingURL=bluetooth-gatt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bluetooth-gatt.d.ts","sourceRoot":"","sources":["../../../src/lib/native-hardware/bluetooth-gatt.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,iCAAiC,EACjC,yCAAyC,EACzC,kCAAkC,EAClC,qBAAqB,EACrB,0BAA0B,EAC3B,MAAM,mBAAmB,CAAA;AAE1B,wBAAsB,kCAAkC,CACtD,OAAO,EAAE,kCAAkC,EAC3C,cAAc,EAAE,qBAAqB,EACrC,OAAO,GAAE,iCAAsC,GAC9C,OAAO,CAAC,yCAAyC,CAAC,CAWpD;AAED,wBAAsB,0BAA0B,CAC9C,cAAc,EAAE,yCAAyC,EACzD,OAAO,GAAE,iCAAsC,GAC9C,OAAO,CAAC,QAAQ,CAAC,CAWnB;AAED,+EAA+E;AAC/E,wBAAsB,qCAAqC,CACzD,cAAc,EAAE,yCAAyC,EACzD,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,EAChC,OAAO,GAAE,iCAAsC,GAC9C,OAAO,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,CAmC9B;AAED,wBAAsB,2BAA2B,CAC/C,cAAc,EAAE,yCAAyC,EACzD,KAAK,EAAE,YAAY,EACnB,IAAI,GAAE,0BAAwC,EAC9C,OAAO,GAAE,iCAAsC,GAC9C,OAAO,CAAC,IAAI,CAAC,CA0Bf"}
@@ -0,0 +1,77 @@
1
+ import { abortableBluetooth, bluetoothAborted, bluetoothError, } from './bluetooth-internal';
2
+ export async function getMoldableBluetoothCharacteristic(service, characteristic, options = {}) {
3
+ const operation = `get Bluetooth characteristic ${String(characteristic)}`;
4
+ try {
5
+ return await abortableBluetooth(service.getCharacteristic(characteristic), options.signal, operation);
6
+ }
7
+ catch (error) {
8
+ throw bluetoothError(error, operation);
9
+ }
10
+ }
11
+ export async function readMoldableBluetoothValue(characteristic, options = {}) {
12
+ const operation = `read Bluetooth characteristic ${characteristic.uuid}`;
13
+ try {
14
+ return await abortableBluetooth(characteristic.readValue(), options.signal, operation);
15
+ }
16
+ catch (error) {
17
+ throw bluetoothError(error, operation);
18
+ }
19
+ }
20
+ /** Starts notifications and returns async, idempotent subscription cleanup. */
21
+ export async function observeMoldableBluetoothNotifications(characteristic, listener, options = {}) {
22
+ const operation = `observe Bluetooth characteristic ${characteristic.uuid}`;
23
+ try {
24
+ await abortableBluetooth(characteristic.startNotifications(), options.signal, operation, (lateCharacteristic) => {
25
+ void lateCharacteristic.stopNotifications();
26
+ });
27
+ if (options.signal?.aborted) {
28
+ await characteristic.stopNotifications();
29
+ throw bluetoothAborted(operation);
30
+ }
31
+ }
32
+ catch (error) {
33
+ throw bluetoothError(error, operation);
34
+ }
35
+ let active = true;
36
+ const cleanup = async () => {
37
+ if (!active)
38
+ return;
39
+ active = false;
40
+ characteristic.removeEventListener('characteristicvaluechanged', listener);
41
+ options.signal?.removeEventListener('abort', onAbort);
42
+ try {
43
+ await characteristic.stopNotifications();
44
+ }
45
+ catch (error) {
46
+ throw bluetoothError(error, `stop ${operation}`);
47
+ }
48
+ };
49
+ const onAbort = () => void cleanup().catch(() => undefined);
50
+ characteristic.addEventListener('characteristicvaluechanged', listener);
51
+ options.signal?.addEventListener('abort', onAbort, { once: true });
52
+ return cleanup;
53
+ }
54
+ export async function writeMoldableBluetoothValue(characteristic, value, mode = 'automatic', options = {}) {
55
+ const operation = `write Bluetooth characteristic ${characteristic.uuid}`;
56
+ let write;
57
+ if (mode === 'with-response') {
58
+ write = characteristic.writeValueWithResponse?.bind(characteristic);
59
+ }
60
+ else if (mode === 'without-response') {
61
+ write = characteristic.writeValueWithoutResponse?.bind(characteristic);
62
+ }
63
+ else {
64
+ write =
65
+ characteristic.writeValueWithResponse?.bind(characteristic) ??
66
+ characteristic.writeValue.bind(characteristic);
67
+ }
68
+ if (!write) {
69
+ throw bluetoothError(new DOMException(`Bluetooth write mode ${mode} is unavailable`, 'NotSupportedError'), operation);
70
+ }
71
+ try {
72
+ await abortableBluetooth(write(value), options.signal, operation);
73
+ }
74
+ catch (error) {
75
+ throw bluetoothError(error, operation);
76
+ }
77
+ }
@@ -0,0 +1,10 @@
1
+ import type { MoldableBluetoothAPI, MoldableBluetoothNavigator, MoldableBluetoothRequestDeviceOptions } from './bluetooth-types';
2
+ import { NativeHardwareBridgeError } from './bridge';
3
+ export declare function bluetoothError(error: unknown, operation: string): NativeHardwareBridgeError;
4
+ export declare function bluetoothAborted(operation: string): NativeHardwareBridgeError;
5
+ export declare function getBluetoothNavigator(): MoldableBluetoothNavigator | undefined;
6
+ export declare function getBluetoothAPI(operation: string): MoldableBluetoothAPI;
7
+ export declare function assertBluetoothUserGesture(): void;
8
+ export declare function validateBluetoothRequestOptions(options: MoldableBluetoothRequestDeviceOptions): void;
9
+ export declare function abortableBluetooth<T>(promise: Promise<T>, signal: AbortSignal | undefined, operation: string, onLateResolution?: (value: T) => void): Promise<T>;
10
+ //# sourceMappingURL=bluetooth-internal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bluetooth-internal.d.ts","sourceRoot":"","sources":["../../../src/lib/native-hardware/bluetooth-internal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,0BAA0B,EAC1B,qCAAqC,EACtC,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACL,yBAAyB,EAE1B,MAAM,UAAU,CAAA;AAGjB,wBAAgB,cAAc,CAC5B,KAAK,EAAE,OAAO,EACd,SAAS,EAAE,MAAM,GAChB,yBAAyB,CAsC3B;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,yBAAyB,CAK7E;AAED,wBAAgB,qBAAqB,IACjC,0BAA0B,GAC1B,SAAS,CAIZ;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,oBAAoB,CASvE;AAED,wBAAgB,0BAA0B,IAAI,IAAI,CAWjD;AAED,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,qCAAqC,GAC7C,IAAI,CAiBN;AAED,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,SAAS,EAAE,MAAM,EACjB,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GACpC,OAAO,CAAC,CAAC,CAAC,CA+BZ"}
@@ -0,0 +1,105 @@
1
+ import { NativeHardwareBridgeError, toNativeHardwareBridgeError, } from './bridge';
2
+ export function bluetoothError(error, operation) {
3
+ if (error instanceof NativeHardwareBridgeError)
4
+ return error;
5
+ const name = error instanceof DOMException ? error.name : undefined;
6
+ let code = 'host_error';
7
+ let retryable = false;
8
+ if (name === 'NotSupportedError')
9
+ code = 'unsupported';
10
+ else if (name === 'NotAllowedError' || name === 'SecurityError') {
11
+ code = 'permission_denied';
12
+ }
13
+ else if (name === 'AbortError')
14
+ code = 'aborted';
15
+ else if (name === 'NotFoundError')
16
+ code = 'cancelled';
17
+ else if (name === 'NetworkError' ||
18
+ name === 'InvalidStateError' ||
19
+ name === 'OperationError') {
20
+ code = 'unavailable';
21
+ retryable = true;
22
+ }
23
+ else if (error instanceof TypeError)
24
+ code = 'invalid_request';
25
+ const fallbackMessage = `Unable to ${operation}`;
26
+ return toNativeHardwareBridgeError({
27
+ code,
28
+ message: error instanceof Error
29
+ ? error.message || fallbackMessage
30
+ : fallbackMessage,
31
+ details: {
32
+ capability: 'bluetooth',
33
+ operation,
34
+ ...(name ? { cause: name } : {}),
35
+ },
36
+ retryable,
37
+ }, fallbackMessage);
38
+ }
39
+ export function bluetoothAborted(operation) {
40
+ return bluetoothError(new DOMException(`Bluetooth ${operation} was aborted`, 'AbortError'), operation);
41
+ }
42
+ export function getBluetoothNavigator() {
43
+ return typeof navigator === 'undefined'
44
+ ? undefined
45
+ : navigator;
46
+ }
47
+ export function getBluetoothAPI(operation) {
48
+ const api = getBluetoothNavigator()?.bluetooth;
49
+ if (!api || typeof api.requestDevice !== 'function') {
50
+ throw bluetoothError(new DOMException('Web Bluetooth is unavailable', 'NotSupportedError'), operation);
51
+ }
52
+ return api;
53
+ }
54
+ export function assertBluetoothUserGesture() {
55
+ const activation = getBluetoothNavigator()?.userActivation;
56
+ if (activation && !activation.isActive) {
57
+ throw toNativeHardwareBridgeError({
58
+ code: 'invalid_request',
59
+ message: 'Bluetooth device selection must be requested from a user-initiated action.',
60
+ details: { capability: 'bluetooth', cause: 'user_gesture_required' },
61
+ retryable: true,
62
+ });
63
+ }
64
+ }
65
+ export function validateBluetoothRequestOptions(options) {
66
+ const hasFilters = 'filters' in options && options.filters !== undefined;
67
+ const acceptsAll = options.acceptAllDevices === true;
68
+ if (hasFilters === acceptsAll) {
69
+ throw bluetoothError(new TypeError('Specify either a non-empty filters array or acceptAllDevices: true'), 'request a Bluetooth device');
70
+ }
71
+ if (hasFilters && options.filters.length === 0) {
72
+ throw bluetoothError(new TypeError('Bluetooth filters must not be empty'), 'request a Bluetooth device');
73
+ }
74
+ }
75
+ export function abortableBluetooth(promise, signal, operation, onLateResolution) {
76
+ if (!signal)
77
+ return promise;
78
+ if (signal.aborted)
79
+ return Promise.reject(bluetoothAborted(operation));
80
+ return new Promise((resolve, reject) => {
81
+ let settled = false;
82
+ const onAbort = () => {
83
+ if (settled)
84
+ return;
85
+ settled = true;
86
+ reject(bluetoothAborted(operation));
87
+ };
88
+ signal.addEventListener('abort', onAbort, { once: true });
89
+ void promise.then((value) => {
90
+ signal.removeEventListener('abort', onAbort);
91
+ if (settled) {
92
+ onLateResolution?.(value);
93
+ return;
94
+ }
95
+ settled = true;
96
+ resolve(value);
97
+ }, (error) => {
98
+ signal.removeEventListener('abort', onAbort);
99
+ if (settled)
100
+ return;
101
+ settled = true;
102
+ reject(error);
103
+ });
104
+ });
105
+ }
@@ -0,0 +1,33 @@
1
+ import type { MoldableBluetoothDevice, MoldableBluetoothRequestDeviceOptions } from './bluetooth-types';
2
+ import { type NativeHardwareBridgeOptions } from './bridge';
3
+ export type MoldableBluetoothTransport = {
4
+ kind: 'web-bluetooth';
5
+ device: MoldableBluetoothDevice;
6
+ } | {
7
+ kind: 'desktop-bridge';
8
+ device: MoldableNativeBluetoothDevice;
9
+ };
10
+ export interface MoldableNativeBluetoothService {
11
+ uuid: string;
12
+ characteristicUuids: string[];
13
+ }
14
+ export interface MoldableNativeBluetoothDevice {
15
+ readonly id: string;
16
+ readonly name: string | null;
17
+ readonly connected: boolean;
18
+ addEventListener(type: 'gattserverdisconnected', listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
19
+ removeEventListener(type: 'gattserverdisconnected', listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
20
+ getServices(options?: NativeHardwareBridgeOptions): Promise<MoldableNativeBluetoothService[]>;
21
+ read(serviceUuid: string, characteristicUuid: string, options?: NativeHardwareBridgeOptions): Promise<DataView>;
22
+ write(serviceUuid: string, characteristicUuid: string, data: BufferSource, options?: NativeHardwareBridgeOptions & {
23
+ withResponse?: boolean;
24
+ }): Promise<void>;
25
+ observe(serviceUuid: string, characteristicUuid: string, listener: (value: DataView) => void, options?: NativeHardwareBridgeOptions): Promise<() => Promise<void>>;
26
+ disconnect(options?: NativeHardwareBridgeOptions): Promise<void>;
27
+ }
28
+ /**
29
+ * Uses Web Bluetooth first, with a restrictive desktop BLE chooser fallback.
30
+ * The native branch mirrors physical disconnect and adapter-loss events.
31
+ */
32
+ export declare function requestMoldableBluetoothWithFallback(options: MoldableBluetoothRequestDeviceOptions, bridgeOptions?: NativeHardwareBridgeOptions): Promise<MoldableBluetoothTransport>;
33
+ //# sourceMappingURL=bluetooth-native-fallback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bluetooth-native-fallback.d.ts","sourceRoot":"","sources":["../../../src/lib/native-hardware/bluetooth-native-fallback.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,uBAAuB,EACvB,qCAAqC,EACtC,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACL,KAAK,2BAA2B,EAEjC,MAAM,UAAU,CAAA;AAMjB,MAAM,MAAM,0BAA0B,GAClC;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,MAAM,EAAE,uBAAuB,CAAA;CAAE,GAC1D;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,6BAA6B,CAAA;CAAE,CAAA;AAErE,MAAM,WAAW,8BAA8B;IAC7C,IAAI,EAAE,MAAM,CAAA;IACZ,mBAAmB,EAAE,MAAM,EAAE,CAAA;CAC9B;AAED,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;IAC3B,gBAAgB,CACd,IAAI,EAAE,wBAAwB,EAC9B,QAAQ,EAAE,kCAAkC,EAC5C,OAAO,CAAC,EAAE,OAAO,GAAG,uBAAuB,GAC1C,IAAI,CAAA;IACP,mBAAmB,CACjB,IAAI,EAAE,wBAAwB,EAC9B,QAAQ,EAAE,kCAAkC,EAC5C,OAAO,CAAC,EAAE,OAAO,GAAG,oBAAoB,GACvC,IAAI,CAAA;IACP,WAAW,CACT,OAAO,CAAC,EAAE,2BAA2B,GACpC,OAAO,CAAC,8BAA8B,EAAE,CAAC,CAAA;IAC5C,IAAI,CACF,WAAW,EAAE,MAAM,EACnB,kBAAkB,EAAE,MAAM,EAC1B,OAAO,CAAC,EAAE,2BAA2B,GACpC,OAAO,CAAC,QAAQ,CAAC,CAAA;IACpB,KAAK,CACH,WAAW,EAAE,MAAM,EACnB,kBAAkB,EAAE,MAAM,EAC1B,IAAI,EAAE,YAAY,EAClB,OAAO,CAAC,EAAE,2BAA2B,GAAG;QAAE,YAAY,CAAC,EAAE,OAAO,CAAA;KAAE,GACjE,OAAO,CAAC,IAAI,CAAC,CAAA;IAChB,OAAO,CACL,WAAW,EAAE,MAAM,EACnB,kBAAkB,EAAE,MAAM,EAC1B,QAAQ,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,EACnC,OAAO,CAAC,EAAE,2BAA2B,GACpC,OAAO,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;IAC/B,UAAU,CAAC,OAAO,CAAC,EAAE,2BAA2B,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACjE;AA2PD;;;GAGG;AACH,wBAAsB,oCAAoC,CACxD,OAAO,EAAE,qCAAqC,EAC9C,aAAa,GAAE,2BAAgC,GAC9C,OAAO,CAAC,0BAA0B,CAAC,CAsCrC"}
@@ -0,0 +1,214 @@
1
+ import { isMoldableBluetoothSupported, requestMoldableBluetoothDevice, } from './bluetooth-access';
2
+ import { callNativeHardwareBridge, } from './bridge';
3
+ const REQUEST_TYPE = 'moldable:native-bluetooth';
4
+ const RESULT_TYPE = 'moldable:native-bluetooth-result';
5
+ const EVENT_TYPE = 'moldable:native-bluetooth-event';
6
+ function isNativeConnectionResult(value) {
7
+ if (typeof value !== 'object' || value === null)
8
+ return false;
9
+ const connection = value;
10
+ return (typeof connection.connectionId === 'string' &&
11
+ connection.connectionId.length > 0 &&
12
+ (connection.name === null || typeof connection.name === 'string'));
13
+ }
14
+ function uuid(value) {
15
+ if (typeof value === 'number' &&
16
+ Number.isInteger(value) &&
17
+ value >= 0 &&
18
+ value <= 0xffff) {
19
+ return value.toString(16).padStart(4, '0');
20
+ }
21
+ if (typeof value === 'string' && /^[0-9a-fA-F-]{4,64}$/.test(value))
22
+ return value.toLowerCase();
23
+ throw new TypeError('The native Bluetooth fallback requires numeric or UUID service identifiers.');
24
+ }
25
+ function dataBytes(source) {
26
+ const bytes = source instanceof ArrayBuffer
27
+ ? new Uint8Array(source)
28
+ : new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
29
+ if (bytes.byteLength > 512)
30
+ throw new TypeError('Bluetooth values are limited to 512 bytes.');
31
+ return Array.from(bytes);
32
+ }
33
+ function nativeRequest(connectionId, action, payload, options = {}) {
34
+ return callNativeHardwareBridge({ type: REQUEST_TYPE, action, connectionId, ...payload }, RESULT_TYPE, options);
35
+ }
36
+ function nativeDevice(connection) {
37
+ let disconnected = false;
38
+ const events = new EventTarget();
39
+ const activeSubscriptions = new Set();
40
+ const transitionDisconnected = () => {
41
+ if (disconnected)
42
+ return;
43
+ disconnected = true;
44
+ window.removeEventListener('message', onLifecycleMessage);
45
+ for (const cleanup of [...activeSubscriptions]) {
46
+ void cleanup().catch(() => undefined);
47
+ }
48
+ events.dispatchEvent(new Event('gattserverdisconnected'));
49
+ };
50
+ function onLifecycleMessage(event) {
51
+ if (event.source !== window.parent ||
52
+ typeof event.data !== 'object' ||
53
+ !event.data)
54
+ return;
55
+ const message = event.data;
56
+ if (message.type !== EVENT_TYPE ||
57
+ typeof message.event !== 'object' ||
58
+ !message.event)
59
+ return;
60
+ const value = message.event;
61
+ if (value.connectionId === connection.connectionId &&
62
+ (value.kind === 'disconnected' || value.kind === 'adapterUnavailable')) {
63
+ transitionDisconnected();
64
+ }
65
+ }
66
+ window.addEventListener('message', onLifecycleMessage);
67
+ const assertConnected = () => {
68
+ if (disconnected) {
69
+ throw new DOMException('The Bluetooth device is disconnected.', 'InvalidStateError');
70
+ }
71
+ };
72
+ return {
73
+ id: connection.connectionId,
74
+ name: connection.name,
75
+ get connected() {
76
+ return !disconnected;
77
+ },
78
+ addEventListener(type, listener, options) {
79
+ events.addEventListener(type, listener, options);
80
+ },
81
+ removeEventListener(type, listener, options) {
82
+ events.removeEventListener(type, listener, options);
83
+ },
84
+ async getServices(options) {
85
+ assertConnected();
86
+ return nativeRequest(connection.connectionId, 'getServices', {}, options);
87
+ },
88
+ async read(serviceUuid, characteristicUuid, options) {
89
+ assertConnected();
90
+ const data = await nativeRequest(connection.connectionId, 'read', {
91
+ serviceUuid: uuid(serviceUuid),
92
+ characteristicUuid: uuid(characteristicUuid),
93
+ }, options);
94
+ if (!Array.isArray(data) ||
95
+ !data.every((byte) => Number.isInteger(byte))) {
96
+ throw new TypeError('The desktop returned an invalid Bluetooth value.');
97
+ }
98
+ return new DataView(Uint8Array.from(data).buffer);
99
+ },
100
+ async write(serviceUuid, characteristicUuid, data, options) {
101
+ assertConnected();
102
+ await nativeRequest(connection.connectionId, 'write', {
103
+ serviceUuid: uuid(serviceUuid),
104
+ characteristicUuid: uuid(characteristicUuid),
105
+ data: dataBytes(data),
106
+ withResponse: options?.withResponse !== false,
107
+ }, options);
108
+ },
109
+ async observe(serviceUuid, characteristicUuid, listener, options) {
110
+ assertConnected();
111
+ const service = uuid(serviceUuid);
112
+ const characteristic = uuid(characteristicUuid);
113
+ const onMessage = (event) => {
114
+ if (event.source !== window.parent ||
115
+ typeof event.data !== 'object' ||
116
+ !event.data)
117
+ return;
118
+ const message = event.data;
119
+ if (message.type !== EVENT_TYPE ||
120
+ typeof message.event !== 'object' ||
121
+ !message.event)
122
+ return;
123
+ const value = message.event;
124
+ if (value.connectionId !== connection.connectionId ||
125
+ value.kind !== 'notification' ||
126
+ value.serviceUuid !== service ||
127
+ value.characteristicUuid !== characteristic ||
128
+ !Array.isArray(value.data))
129
+ return;
130
+ if (!value.data.every((byte) => Number.isInteger(byte) &&
131
+ Number(byte) >= 0 &&
132
+ Number(byte) <= 255)) {
133
+ return;
134
+ }
135
+ listener(new DataView(Uint8Array.from(value.data).buffer));
136
+ };
137
+ window.addEventListener('message', onMessage);
138
+ try {
139
+ await nativeRequest(connection.connectionId, 'subscribe', { serviceUuid: service, characteristicUuid: characteristic }, options);
140
+ }
141
+ catch (error) {
142
+ window.removeEventListener('message', onMessage);
143
+ throw error;
144
+ }
145
+ let cleanupPromise = null;
146
+ const cleanup = () => {
147
+ if (cleanupPromise)
148
+ return cleanupPromise;
149
+ window.removeEventListener('message', onMessage);
150
+ options?.signal?.removeEventListener('abort', handleAbort);
151
+ activeSubscriptions.delete(cleanup);
152
+ cleanupPromise = disconnected
153
+ ? Promise.resolve()
154
+ : nativeRequest(connection.connectionId, 'unsubscribe', { serviceUuid: service, characteristicUuid: characteristic }, { timeoutMs: options?.timeoutMs }).then(() => undefined);
155
+ return cleanupPromise;
156
+ };
157
+ const handleAbort = () => void cleanup().catch(() => undefined);
158
+ activeSubscriptions.add(cleanup);
159
+ options?.signal?.addEventListener('abort', handleAbort, { once: true });
160
+ if (options?.signal?.aborted)
161
+ handleAbort();
162
+ return cleanup;
163
+ },
164
+ async disconnect(options) {
165
+ if (disconnected)
166
+ return;
167
+ window.removeEventListener('message', onLifecycleMessage);
168
+ const subscriptions = [...activeSubscriptions];
169
+ disconnected = true;
170
+ await Promise.allSettled(subscriptions.map((cleanup) => cleanup()));
171
+ try {
172
+ await nativeRequest(connection.connectionId, 'disconnect', {}, options);
173
+ }
174
+ finally {
175
+ events.dispatchEvent(new Event('gattserverdisconnected'));
176
+ }
177
+ },
178
+ };
179
+ }
180
+ /**
181
+ * Uses Web Bluetooth first, with a restrictive desktop BLE chooser fallback.
182
+ * The native branch mirrors physical disconnect and adapter-loss events.
183
+ */
184
+ export async function requestMoldableBluetoothWithFallback(options, bridgeOptions = {}) {
185
+ if (isMoldableBluetoothSupported()) {
186
+ return {
187
+ kind: 'web-bluetooth',
188
+ device: await requestMoldableBluetoothDevice(options, bridgeOptions),
189
+ };
190
+ }
191
+ if (!('filters' in options) || !options.filters?.length) {
192
+ throw new TypeError('The native Bluetooth fallback does not allow acceptAllDevices.');
193
+ }
194
+ const filters = options.filters.map((filter) => {
195
+ if (filter.manufacturerData?.length || filter.serviceData?.length) {
196
+ throw new TypeError('The native Bluetooth fallback does not support data filters yet.');
197
+ }
198
+ return {
199
+ name: filter.name,
200
+ namePrefix: filter.namePrefix,
201
+ services: filter.services?.map(uuid),
202
+ };
203
+ });
204
+ const result = await callNativeHardwareBridge({
205
+ type: REQUEST_TYPE,
206
+ action: 'requestDevice',
207
+ filters,
208
+ optionalServices: options.optionalServices?.map(uuid) ?? [],
209
+ }, RESULT_TYPE, { timeoutMs: 120_000, ...bridgeOptions });
210
+ if (!isNativeConnectionResult(result)) {
211
+ throw new TypeError('The desktop returned an invalid Bluetooth device.');
212
+ }
213
+ return { kind: 'desktop-bridge', device: nativeDevice(result) };
214
+ }
@@ -0,0 +1,85 @@
1
+ /** Local structural Web Bluetooth types for runtimes whose DOM library omits them. */
2
+ export type MoldableBluetoothUUID = string | number;
3
+ export interface MoldableBluetoothDataFilter {
4
+ dataPrefix?: BufferSource;
5
+ mask?: BufferSource;
6
+ }
7
+ export interface MoldableBluetoothManufacturerDataFilter extends MoldableBluetoothDataFilter {
8
+ companyIdentifier: number;
9
+ }
10
+ export interface MoldableBluetoothServiceDataFilter extends MoldableBluetoothDataFilter {
11
+ service: MoldableBluetoothUUID;
12
+ }
13
+ export interface MoldableBluetoothLEScanFilter {
14
+ name?: string;
15
+ namePrefix?: string;
16
+ services?: MoldableBluetoothUUID[];
17
+ manufacturerData?: MoldableBluetoothManufacturerDataFilter[];
18
+ serviceData?: MoldableBluetoothServiceDataFilter[];
19
+ }
20
+ export type MoldableBluetoothRequestDeviceOptions = {
21
+ filters: MoldableBluetoothLEScanFilter[];
22
+ acceptAllDevices?: false;
23
+ optionalServices?: MoldableBluetoothUUID[];
24
+ optionalManufacturerData?: number[];
25
+ } | {
26
+ filters?: never;
27
+ acceptAllDevices: true;
28
+ optionalServices?: MoldableBluetoothUUID[];
29
+ optionalManufacturerData?: number[];
30
+ };
31
+ export interface MoldableBluetoothRemoteGATTCharacteristic extends EventTarget {
32
+ readonly service: MoldableBluetoothRemoteGATTService;
33
+ readonly uuid: string;
34
+ readonly value?: DataView;
35
+ startNotifications(): Promise<MoldableBluetoothRemoteGATTCharacteristic>;
36
+ stopNotifications(): Promise<MoldableBluetoothRemoteGATTCharacteristic>;
37
+ readValue(): Promise<DataView>;
38
+ writeValue(value: BufferSource): Promise<void>;
39
+ writeValueWithResponse?(value: BufferSource): Promise<void>;
40
+ writeValueWithoutResponse?(value: BufferSource): Promise<void>;
41
+ }
42
+ export interface MoldableBluetoothRemoteGATTService {
43
+ readonly device: MoldableBluetoothDevice;
44
+ readonly isPrimary: boolean;
45
+ readonly uuid: string;
46
+ getCharacteristic(characteristic: MoldableBluetoothUUID): Promise<MoldableBluetoothRemoteGATTCharacteristic>;
47
+ getCharacteristics(characteristic?: MoldableBluetoothUUID): Promise<MoldableBluetoothRemoteGATTCharacteristic[]>;
48
+ }
49
+ export interface MoldableBluetoothRemoteGATTServer {
50
+ readonly connected: boolean;
51
+ readonly device: MoldableBluetoothDevice;
52
+ connect(): Promise<MoldableBluetoothRemoteGATTServer>;
53
+ disconnect(): void;
54
+ getPrimaryService(service: MoldableBluetoothUUID): Promise<MoldableBluetoothRemoteGATTService>;
55
+ getPrimaryServices(service?: MoldableBluetoothUUID): Promise<MoldableBluetoothRemoteGATTService[]>;
56
+ }
57
+ export interface MoldableBluetoothDeviceEventMap {
58
+ gattserverdisconnected: Event;
59
+ }
60
+ export interface MoldableBluetoothDevice extends EventTarget {
61
+ readonly id: string;
62
+ readonly name?: string;
63
+ readonly gatt?: MoldableBluetoothRemoteGATTServer;
64
+ addEventListener<K extends keyof MoldableBluetoothDeviceEventMap>(type: K, listener: (event: MoldableBluetoothDeviceEventMap[K]) => void, options?: boolean | AddEventListenerOptions): void;
65
+ removeEventListener<K extends keyof MoldableBluetoothDeviceEventMap>(type: K, listener: (event: MoldableBluetoothDeviceEventMap[K]) => void, options?: boolean | EventListenerOptions): void;
66
+ }
67
+ export interface MoldableBluetoothAPI {
68
+ getAvailability?(): Promise<boolean>;
69
+ requestDevice(options: MoldableBluetoothRequestDeviceOptions): Promise<MoldableBluetoothDevice>;
70
+ }
71
+ export interface MoldableBluetoothNavigator extends Navigator {
72
+ bluetooth?: MoldableBluetoothAPI;
73
+ }
74
+ export type MoldableBluetoothAvailability = 'available' | 'unavailable' | 'unknown';
75
+ export interface MoldableBluetoothRequestOptions {
76
+ signal?: AbortSignal;
77
+ }
78
+ export interface MoldableBluetoothConnectionOptions {
79
+ signal?: AbortSignal;
80
+ }
81
+ export interface MoldableBluetoothOperationOptions {
82
+ signal?: AbortSignal;
83
+ }
84
+ export type MoldableBluetoothWriteMode = 'with-response' | 'without-response' | 'automatic';
85
+ //# sourceMappingURL=bluetooth-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bluetooth-types.d.ts","sourceRoot":"","sources":["../../../src/lib/native-hardware/bluetooth-types.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ /** Local structural Web Bluetooth types for runtimes whose DOM library omits them. */
2
+ export {};
@@ -0,0 +1,7 @@
1
+ export { getMoldableBluetoothAvailability, isMoldableBluetoothSupported, requestMoldableBluetoothDevice, } from './bluetooth-access';
2
+ export { connectMoldableBluetoothDevice, MoldableBluetoothConnection, } from './bluetooth-connection';
3
+ export { getMoldableBluetoothCharacteristic, observeMoldableBluetoothNotifications, readMoldableBluetoothValue, writeMoldableBluetoothValue, } from './bluetooth-gatt';
4
+ export type * from './bluetooth-types';
5
+ export { requestMoldableBluetoothWithFallback } from './bluetooth-native-fallback';
6
+ export type { MoldableBluetoothTransport, MoldableNativeBluetoothDevice, MoldableNativeBluetoothService, } from './bluetooth-native-fallback';
7
+ //# sourceMappingURL=bluetooth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bluetooth.d.ts","sourceRoot":"","sources":["../../../src/lib/native-hardware/bluetooth.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gCAAgC,EAChC,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,8BAA8B,EAC9B,2BAA2B,GAC5B,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,kCAAkC,EAClC,qCAAqC,EACrC,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,kBAAkB,CAAA;AACzB,mBAAmB,mBAAmB,CAAA;AACtC,OAAO,EAAE,oCAAoC,EAAE,MAAM,6BAA6B,CAAA;AAClF,YAAY,EACV,0BAA0B,EAC1B,6BAA6B,EAC7B,8BAA8B,GAC/B,MAAM,6BAA6B,CAAA"}