@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,217 @@
1
+ import { NativeCapabilityBridgeError } from './bridge';
2
+ import { bytesFromNativeDeviceResult, bytesWrittenFromNativeDeviceResult, closeMoldableNativeDevice, executeMoldableNativeDeviceOperation, openMoldableNativeDevice, } from './native-device-io';
3
+ import { NativeDeviceLifecycle, isNativeDeviceDisconnect, } from './native-device-lifecycle';
4
+ const DEFAULT_TIMEOUT_MS = 10_000;
5
+ export class NativeMoldableUsbDevice extends EventTarget {
6
+ descriptor;
7
+ vendorId;
8
+ productId;
9
+ productName;
10
+ manufacturerName = null;
11
+ serialNumber = null;
12
+ configuration = null;
13
+ handle;
14
+ closing;
15
+ lifecycle = new NativeDeviceLifecycle();
16
+ constructor(descriptor) {
17
+ super();
18
+ this.descriptor = descriptor;
19
+ this.vendorId = descriptor.vendorId ?? 0;
20
+ this.productId = descriptor.productId ?? 0;
21
+ this.productName = descriptor.label;
22
+ }
23
+ get opened() {
24
+ return this.lifecycle.opened;
25
+ }
26
+ async openWithOptions(options) {
27
+ if (this.closing)
28
+ await this.closing;
29
+ if (this.handle && this.lifecycle.disconnected)
30
+ await this.close();
31
+ if (this.opened)
32
+ return;
33
+ const opened = await openMoldableNativeDevice('usb', this.descriptor.selector, {
34
+ ...(options.configurationValue === undefined
35
+ ? {}
36
+ : { usbConfiguration: options.configurationValue }),
37
+ usbInterfaces: [...(options.claimInterfaces ?? [])],
38
+ });
39
+ if (opened.kind !== 'usb')
40
+ throw new Error('Native device kind mismatch.');
41
+ this.handle = opened.handle;
42
+ this.lifecycle.didOpen();
43
+ if (options.configurationValue !== undefined) {
44
+ this.configuration = { configurationValue: options.configurationValue };
45
+ }
46
+ }
47
+ async open() {
48
+ await this.openWithOptions({});
49
+ }
50
+ async close() {
51
+ if (this.closing)
52
+ return this.closing;
53
+ if (!this.handle)
54
+ return;
55
+ const handle = this.handle;
56
+ const closing = closeMoldableNativeDevice('usb', handle)
57
+ .then(() => {
58
+ if (this.handle === handle) {
59
+ this.handle = undefined;
60
+ this.configuration = null;
61
+ this.lifecycle.didClose();
62
+ }
63
+ })
64
+ .finally(() => {
65
+ if (this.closing === closing)
66
+ this.closing = undefined;
67
+ });
68
+ this.closing = closing;
69
+ return closing;
70
+ }
71
+ async forget() {
72
+ await this.close();
73
+ }
74
+ async selectConfiguration() {
75
+ throw this.reopenRequired('select a USB configuration');
76
+ }
77
+ async claimInterface() {
78
+ throw this.reopenRequired('claim a USB interface');
79
+ }
80
+ async releaseInterface() {
81
+ throw this.reopenRequired('release a USB interface');
82
+ }
83
+ async transferIn(endpointNumber, length) {
84
+ return this.transferInWithOptions(endpointNumber, length);
85
+ }
86
+ async transferInWithOptions(endpointNumber, length, options = {}) {
87
+ const result = await this.execute({
88
+ action: 'read',
89
+ endpoint: nativeUsbEndpointAddress(endpointNumber, 'in'),
90
+ length,
91
+ timeoutMs: options.timeoutMs ?? DEFAULT_TIMEOUT_MS,
92
+ bulk: options.transferType === 'bulk',
93
+ }, options.signal);
94
+ const bytes = bytesFromNativeDeviceResult(result);
95
+ return {
96
+ status: 'ok',
97
+ data: new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength),
98
+ };
99
+ }
100
+ async transferOut(endpointNumber, data) {
101
+ return this.transferOutWithOptions(endpointNumber, data);
102
+ }
103
+ async transferOutWithOptions(endpointNumber, data, options = {}) {
104
+ const result = await this.execute({
105
+ action: 'write',
106
+ endpoint: nativeUsbEndpointAddress(endpointNumber, 'out'),
107
+ data: [...asBytes(data)],
108
+ timeoutMs: options.timeoutMs ?? DEFAULT_TIMEOUT_MS,
109
+ bulk: options.transferType === 'bulk',
110
+ }, options.signal);
111
+ return {
112
+ status: 'ok',
113
+ bytesWritten: bytesWrittenFromNativeDeviceResult(result),
114
+ };
115
+ }
116
+ async controlTransferIn(setup, length) {
117
+ return this.controlTransferInWithOptions(setup, length);
118
+ }
119
+ async controlTransferInWithOptions(setup, length, options = {}) {
120
+ const result = await this.execute({
121
+ action: 'usbControlIn',
122
+ requestType: controlRequestType(setup, true),
123
+ request: setup.request,
124
+ value: setup.value,
125
+ index: setup.index,
126
+ length,
127
+ timeoutMs: options.timeoutMs ?? DEFAULT_TIMEOUT_MS,
128
+ }, options.signal);
129
+ const bytes = bytesFromNativeDeviceResult(result);
130
+ return {
131
+ status: 'ok',
132
+ data: new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength),
133
+ };
134
+ }
135
+ async controlTransferOut(setup, data = new Uint8Array()) {
136
+ return this.controlTransferOutWithOptions(setup, data);
137
+ }
138
+ async controlTransferOutWithOptions(setup, data = new Uint8Array(), options = {}) {
139
+ const result = await this.execute({
140
+ action: 'usbControlOut',
141
+ requestType: controlRequestType(setup, false),
142
+ request: setup.request,
143
+ value: setup.value,
144
+ index: setup.index,
145
+ data: [...asBytes(data)],
146
+ timeoutMs: options.timeoutMs ?? DEFAULT_TIMEOUT_MS,
147
+ }, options.signal);
148
+ return {
149
+ status: 'ok',
150
+ bytesWritten: bytesWrittenFromNativeDeviceResult(result),
151
+ };
152
+ }
153
+ async clearHalt(direction, endpointNumber) {
154
+ await this.execute({
155
+ action: 'clearUsbHalt',
156
+ endpoint: nativeUsbEndpointAddress(endpointNumber, direction),
157
+ });
158
+ }
159
+ async reset() {
160
+ await this.execute({ action: 'resetUsb' });
161
+ }
162
+ async execute(operation, signal) {
163
+ if (!this.handle) {
164
+ throw new NativeCapabilityBridgeError({
165
+ code: 'invalid_request',
166
+ message: 'USB device is not open.',
167
+ });
168
+ }
169
+ if (this.lifecycle.disconnected) {
170
+ throw new NativeCapabilityBridgeError({
171
+ code: 'unavailable',
172
+ message: 'USB device is disconnected.',
173
+ retryable: true,
174
+ });
175
+ }
176
+ try {
177
+ return await executeMoldableNativeDeviceOperation('usb', this.handle, operation, { signal });
178
+ }
179
+ catch (error) {
180
+ if (isNativeDeviceDisconnect(error)) {
181
+ this.lifecycle.didDisconnect(this, error);
182
+ }
183
+ throw error;
184
+ }
185
+ }
186
+ reopenRequired(action) {
187
+ return new NativeCapabilityBridgeError({
188
+ code: 'invalid_request',
189
+ message: `Close and reopen the native USB device to ${action}.`,
190
+ });
191
+ }
192
+ }
193
+ export function isNativeMoldableUsbDevice(device) {
194
+ return device instanceof NativeMoldableUsbDevice;
195
+ }
196
+ function asBytes(data) {
197
+ return data instanceof ArrayBuffer
198
+ ? new Uint8Array(data)
199
+ : new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
200
+ }
201
+ function nativeUsbEndpointAddress(endpointNumber, direction) {
202
+ if (!Number.isInteger(endpointNumber) ||
203
+ endpointNumber < 1 ||
204
+ endpointNumber > 15) {
205
+ throw new NativeCapabilityBridgeError({
206
+ code: 'invalid_request',
207
+ message: 'USB endpointNumber must be an integer between 1 and 15.',
208
+ retryable: false,
209
+ });
210
+ }
211
+ return direction === 'in' ? endpointNumber | 0x80 : endpointNumber;
212
+ }
213
+ function controlRequestType(setup, input) {
214
+ const type = { standard: 0, class: 1, vendor: 2 }[setup.requestType] << 5;
215
+ const recipient = { device: 0, interface: 1, endpoint: 2, other: 3 }[setup.recipient];
216
+ return (input ? 0x80 : 0) | type | recipient;
217
+ }
@@ -0,0 +1,85 @@
1
+ export interface MoldableUsbOperationOptions {
2
+ signal?: AbortSignal;
3
+ timeoutMs?: number;
4
+ transferType?: 'interrupt' | 'bulk';
5
+ }
6
+ export interface MoldableUsbDeviceFilter {
7
+ vendorId?: number;
8
+ productId?: number;
9
+ classCode?: number;
10
+ subclassCode?: number;
11
+ protocolCode?: number;
12
+ serialNumber?: string;
13
+ }
14
+ export interface MoldableUsbConfiguration {
15
+ configurationValue: number;
16
+ }
17
+ export interface MoldableUsbInTransferResult {
18
+ data?: DataView | null;
19
+ status: 'ok' | 'stall' | 'babble';
20
+ }
21
+ export interface MoldableUsbOutTransferResult {
22
+ bytesWritten?: number;
23
+ status: 'ok' | 'stall' | 'babble';
24
+ }
25
+ export interface MoldableUsbControlTransferParameters {
26
+ requestType: 'standard' | 'class' | 'vendor';
27
+ recipient: 'device' | 'interface' | 'endpoint' | 'other';
28
+ request: number;
29
+ value: number;
30
+ index: number;
31
+ }
32
+ /** Structural subset of the standard USBDevice interface used by the helpers. */
33
+ export interface MoldableUsbDevice extends EventTarget {
34
+ readonly opened: boolean;
35
+ readonly vendorId: number;
36
+ readonly productId: number;
37
+ readonly productName?: string | null;
38
+ readonly manufacturerName?: string | null;
39
+ readonly serialNumber?: string | null;
40
+ readonly configuration?: MoldableUsbConfiguration | null;
41
+ open(): Promise<void>;
42
+ close(): Promise<void>;
43
+ forget?(): Promise<void>;
44
+ selectConfiguration(configurationValue: number): Promise<void>;
45
+ claimInterface(interfaceNumber: number): Promise<void>;
46
+ releaseInterface(interfaceNumber: number): Promise<void>;
47
+ transferIn(endpointNumber: number, length: number): Promise<MoldableUsbInTransferResult>;
48
+ transferOut(endpointNumber: number, data: BufferSource): Promise<MoldableUsbOutTransferResult>;
49
+ controlTransferIn(setup: MoldableUsbControlTransferParameters, length: number): Promise<MoldableUsbInTransferResult>;
50
+ controlTransferOut(setup: MoldableUsbControlTransferParameters, data?: BufferSource): Promise<MoldableUsbOutTransferResult>;
51
+ clearHalt(direction: 'in' | 'out', endpointNumber: number): Promise<void>;
52
+ reset(): Promise<void>;
53
+ }
54
+ export interface MoldableUsbRequestOptions extends MoldableUsbOperationOptions {
55
+ filters: readonly MoldableUsbDeviceFilter[];
56
+ exclusionFilters?: readonly MoldableUsbDeviceFilter[];
57
+ /** Required when multiple native fallback devices match. Render a user choice. */
58
+ selectNativeDevice?: (devices: readonly MoldableUsbDevice[]) => MoldableUsbDevice | Promise<MoldableUsbDevice>;
59
+ }
60
+ export interface MoldableUsbOpenOptions {
61
+ configurationValue?: number;
62
+ claimInterfaces?: readonly number[];
63
+ }
64
+ /** Returns true only when this WebView exposes the WebUSB entry point. */
65
+ export declare function isMoldableUsbSupported(): boolean;
66
+ /** Lists devices previously authorized through WebUSB. */
67
+ export declare function getMoldableUsbDevices(): Promise<MoldableUsbDevice[]>;
68
+ /**
69
+ * Shows the browser's USB chooser. Call this directly from a user gesture.
70
+ * Aborting stops awaiting the result but cannot dismiss every browser chooser.
71
+ */
72
+ export declare function requestMoldableUsbDevice(options: MoldableUsbRequestOptions): Promise<MoldableUsbDevice>;
73
+ /** Opens, optionally configures, and claims interfaces on a USB device. */
74
+ export declare function openMoldableUsbDevice(device: MoldableUsbDevice, options?: MoldableUsbOpenOptions): Promise<void>;
75
+ /** Releases the selected interfaces and closes an open USB device. */
76
+ export declare function closeMoldableUsbDevice(device: MoldableUsbDevice, releaseInterfaces?: readonly number[]): Promise<void>;
77
+ /** Revokes the saved permission when the runtime supports USBDevice.forget(). */
78
+ export declare function forgetMoldableUsbDevice(device: MoldableUsbDevice): Promise<void>;
79
+ export declare function readMoldableUsbEndpoint(device: MoldableUsbDevice, endpointNumber: number, length: number, options?: MoldableUsbOperationOptions): Promise<MoldableUsbInTransferResult>;
80
+ export declare function writeMoldableUsbEndpoint(device: MoldableUsbDevice, endpointNumber: number, data: BufferSource, options?: MoldableUsbOperationOptions): Promise<MoldableUsbOutTransferResult>;
81
+ export declare function readMoldableUsbControlTransfer(device: MoldableUsbDevice, setup: MoldableUsbControlTransferParameters, length: number, options?: MoldableUsbOperationOptions): Promise<MoldableUsbInTransferResult>;
82
+ export declare function writeMoldableUsbControlTransfer(device: MoldableUsbDevice, setup: MoldableUsbControlTransferParameters, data?: BufferSource, options?: MoldableUsbOperationOptions): Promise<MoldableUsbOutTransferResult>;
83
+ export declare function clearMoldableUsbHalt(device: MoldableUsbDevice, direction: 'in' | 'out', endpointNumber: number): Promise<void>;
84
+ export declare function resetMoldableUsbDevice(device: MoldableUsbDevice): Promise<void>;
85
+ //# sourceMappingURL=usb.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usb.d.ts","sourceRoot":"","sources":["../../../src/lib/native-capabilities/usb.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,225 @@
1
+ import { assertMoldableNativeCapabilityAccess, requireMoldableNativeCapabilityAccess, } from './access';
2
+ import { NativeCapabilityBridgeError } from './bridge';
3
+ import { awaitDeviceIoWithAbort, deviceIoError, unsupportedDeviceIoError, } from './device-io-errors';
4
+ import { listMoldableNativeDevices } from './native-device-io';
5
+ import { NativeMoldableUsbDevice, isNativeMoldableUsbDevice, } from './usb-native';
6
+ function assertNativeUsbFiltersSupported(filters) {
7
+ if (filters?.some((filter) => filter.classCode !== undefined ||
8
+ filter.subclassCode !== undefined ||
9
+ filter.protocolCode !== undefined ||
10
+ filter.serialNumber !== undefined)) {
11
+ throw new NativeCapabilityBridgeError({
12
+ code: 'unsupported',
13
+ message: 'The native USB fallback can only match vendorId and productId filters on this platform.',
14
+ retryable: false,
15
+ });
16
+ }
17
+ }
18
+ function usbApi() {
19
+ const api = typeof navigator === 'undefined'
20
+ ? undefined
21
+ : navigator.usb;
22
+ if (!api)
23
+ throw unsupportedDeviceIoError('usb');
24
+ return api;
25
+ }
26
+ /** Returns true only when this WebView exposes the WebUSB entry point. */
27
+ export function isMoldableUsbSupported() {
28
+ return (typeof navigator !== 'undefined' && !!navigator.usb);
29
+ }
30
+ /** Lists devices previously authorized through WebUSB. */
31
+ export async function getMoldableUsbDevices() {
32
+ await assertMoldableNativeCapabilityAccess('usb');
33
+ if (!isMoldableUsbSupported()) {
34
+ throw unsupportedDeviceIoError('usb');
35
+ }
36
+ try {
37
+ return await usbApi().getDevices();
38
+ }
39
+ catch (error) {
40
+ throw deviceIoError('usb', 'enumerate', error);
41
+ }
42
+ }
43
+ /**
44
+ * Shows the browser's USB chooser. Call this directly from a user gesture.
45
+ * Aborting stops awaiting the result but cannot dismiss every browser chooser.
46
+ */
47
+ export async function requestMoldableUsbDevice(options) {
48
+ await requireMoldableNativeCapabilityAccess('usb', options);
49
+ if (!isMoldableUsbSupported()) {
50
+ assertNativeUsbFiltersSupported(options.filters);
51
+ assertNativeUsbFiltersSupported(options.exclusionFilters);
52
+ const descriptors = await listMoldableNativeDevices('usb', {
53
+ signal: options.signal,
54
+ filters: options.filters.map(({ vendorId, productId }) => ({
55
+ vendorId,
56
+ productId,
57
+ })),
58
+ ...(options.exclusionFilters
59
+ ? {
60
+ exclusionFilters: options.exclusionFilters.map(({ vendorId, productId }) => ({ vendorId, productId })),
61
+ }
62
+ : {}),
63
+ });
64
+ const devices = descriptors
65
+ .filter((descriptor) => options.filters.length === 0
66
+ ? true
67
+ : options.filters.some((filter) => (filter.vendorId === undefined ||
68
+ filter.vendorId === descriptor.vendorId) &&
69
+ (filter.productId === undefined ||
70
+ filter.productId === descriptor.productId)))
71
+ .filter((descriptor) => !options.exclusionFilters?.some((filter) => (filter.vendorId === undefined ||
72
+ filter.vendorId === descriptor.vendorId) &&
73
+ (filter.productId === undefined ||
74
+ filter.productId === descriptor.productId)))
75
+ .map((descriptor) => new NativeMoldableUsbDevice(descriptor));
76
+ if (devices.length === 0) {
77
+ throw deviceIoError('usb', 'request', new DOMException('No matching USB device is available.', 'NotFoundError'));
78
+ }
79
+ if (devices.length === 1)
80
+ return devices[0];
81
+ if (!options.selectNativeDevice) {
82
+ throw deviceIoError('usb', 'request', new TypeError('A native device selector is required when multiple USB devices match.'));
83
+ }
84
+ const selected = await options.selectNativeDevice(devices);
85
+ if (!devices.includes(selected)) {
86
+ throw deviceIoError('usb', 'request', new TypeError('Invalid native USB selection.'));
87
+ }
88
+ return selected;
89
+ }
90
+ try {
91
+ return await awaitDeviceIoWithAbort(usbApi().requestDevice({
92
+ filters: [...options.filters],
93
+ ...(options.exclusionFilters
94
+ ? { exclusionFilters: [...options.exclusionFilters] }
95
+ : {}),
96
+ }), 'usb', 'request', options.signal);
97
+ }
98
+ catch (error) {
99
+ throw deviceIoError('usb', 'request', error);
100
+ }
101
+ }
102
+ /** Opens, optionally configures, and claims interfaces on a USB device. */
103
+ export async function openMoldableUsbDevice(device, options = {}) {
104
+ if (isNativeMoldableUsbDevice(device)) {
105
+ await device.openWithOptions(options);
106
+ return;
107
+ }
108
+ const openedHere = !device.opened;
109
+ const claimed = [];
110
+ try {
111
+ if (openedHere)
112
+ await device.open();
113
+ if (options.configurationValue !== undefined &&
114
+ device.configuration?.configurationValue !== options.configurationValue) {
115
+ await device.selectConfiguration(options.configurationValue);
116
+ }
117
+ for (const interfaceNumber of options.claimInterfaces ?? []) {
118
+ await device.claimInterface(interfaceNumber);
119
+ claimed.push(interfaceNumber);
120
+ }
121
+ }
122
+ catch (error) {
123
+ await Promise.allSettled(claimed.map((interfaceNumber) => device.releaseInterface(interfaceNumber)));
124
+ if (openedHere)
125
+ await device.close().catch(() => undefined);
126
+ throw deviceIoError('usb', 'open', error);
127
+ }
128
+ }
129
+ /** Releases the selected interfaces and closes an open USB device. */
130
+ export async function closeMoldableUsbDevice(device, releaseInterfaces = []) {
131
+ if (isNativeMoldableUsbDevice(device)) {
132
+ await device.close();
133
+ return;
134
+ }
135
+ let firstError;
136
+ for (const interfaceNumber of releaseInterfaces) {
137
+ try {
138
+ await device.releaseInterface(interfaceNumber);
139
+ }
140
+ catch (error) {
141
+ firstError ??= error;
142
+ }
143
+ }
144
+ try {
145
+ if (device.opened)
146
+ await device.close();
147
+ }
148
+ catch (error) {
149
+ firstError ??= error;
150
+ }
151
+ if (firstError)
152
+ throw deviceIoError('usb', 'close', firstError);
153
+ }
154
+ /** Revokes the saved permission when the runtime supports USBDevice.forget(). */
155
+ export async function forgetMoldableUsbDevice(device) {
156
+ if (typeof device.forget !== 'function') {
157
+ throw unsupportedDeviceIoError('usb');
158
+ }
159
+ try {
160
+ await device.forget();
161
+ }
162
+ catch (error) {
163
+ throw deviceIoError('usb', 'close', error);
164
+ }
165
+ }
166
+ export async function readMoldableUsbEndpoint(device, endpointNumber, length, options = {}) {
167
+ if (isNativeMoldableUsbDevice(device)) {
168
+ return device.transferInWithOptions(endpointNumber, length, options);
169
+ }
170
+ try {
171
+ return await awaitDeviceIoWithAbort(device.transferIn(endpointNumber, length), 'usb', 'read', options.signal);
172
+ }
173
+ catch (error) {
174
+ throw deviceIoError('usb', 'read', error);
175
+ }
176
+ }
177
+ export async function writeMoldableUsbEndpoint(device, endpointNumber, data, options = {}) {
178
+ if (isNativeMoldableUsbDevice(device)) {
179
+ return device.transferOutWithOptions(endpointNumber, data, options);
180
+ }
181
+ try {
182
+ return await awaitDeviceIoWithAbort(device.transferOut(endpointNumber, data), 'usb', 'write', options.signal);
183
+ }
184
+ catch (error) {
185
+ throw deviceIoError('usb', 'write', error);
186
+ }
187
+ }
188
+ export async function readMoldableUsbControlTransfer(device, setup, length, options = {}) {
189
+ if (isNativeMoldableUsbDevice(device)) {
190
+ return device.controlTransferInWithOptions(setup, length, options);
191
+ }
192
+ try {
193
+ return await awaitDeviceIoWithAbort(device.controlTransferIn(setup, length), 'usb', 'read', options.signal);
194
+ }
195
+ catch (error) {
196
+ throw deviceIoError('usb', 'read', error);
197
+ }
198
+ }
199
+ export async function writeMoldableUsbControlTransfer(device, setup, data, options = {}) {
200
+ if (isNativeMoldableUsbDevice(device)) {
201
+ return device.controlTransferOutWithOptions(setup, data, options);
202
+ }
203
+ try {
204
+ return await awaitDeviceIoWithAbort(device.controlTransferOut(setup, data), 'usb', 'write', options.signal);
205
+ }
206
+ catch (error) {
207
+ throw deviceIoError('usb', 'write', error);
208
+ }
209
+ }
210
+ export async function clearMoldableUsbHalt(device, direction, endpointNumber) {
211
+ try {
212
+ await device.clearHalt(direction, endpointNumber);
213
+ }
214
+ catch (error) {
215
+ throw deviceIoError('usb', 'write', error);
216
+ }
217
+ }
218
+ export async function resetMoldableUsbDevice(device) {
219
+ try {
220
+ await device.reset();
221
+ }
222
+ catch (error) {
223
+ throw deviceIoError('usb', 'close', error);
224
+ }
225
+ }
@@ -0,0 +1,14 @@
1
+ import type { MoldableBluetoothAvailability, MoldableBluetoothDevice, MoldableBluetoothOperationOptions, MoldableBluetoothRequestDeviceOptions, MoldableBluetoothRequestOptions } from './bluetooth-types';
2
+ /** Checks only for the standards-based Web Bluetooth entry point. */
3
+ export declare function isMoldableBluetoothSupported(): boolean;
4
+ /**
5
+ * Returns adapter availability when the runtime exposes it. `unknown` means the
6
+ * API exists but cannot report adapter state, not that Bluetooth is available.
7
+ */
8
+ export declare function getMoldableBluetoothAvailability(options?: MoldableBluetoothOperationOptions): Promise<MoldableBluetoothAvailability>;
9
+ /**
10
+ * Opens the browser's device chooser. This must be called directly from a
11
+ * trusted user action; it never silently scans for or selects devices.
12
+ */
13
+ export declare function requestMoldableBluetoothDevice(deviceOptions: MoldableBluetoothRequestDeviceOptions, options?: MoldableBluetoothRequestOptions): Promise<MoldableBluetoothDevice>;
14
+ //# sourceMappingURL=bluetooth-access.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bluetooth-access.d.ts","sourceRoot":"","sources":["../../../src/lib/native-hardware/bluetooth-access.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,6BAA6B,EAC7B,uBAAuB,EACvB,iCAAiC,EACjC,qCAAqC,EACrC,+BAA+B,EAChC,MAAM,mBAAmB,CAAA;AAE1B,qEAAqE;AACrE,wBAAgB,4BAA4B,IAAI,OAAO,CAGtD;AAED;;;GAGG;AACH,wBAAsB,gCAAgC,CACpD,OAAO,GAAE,iCAAsC,GAC9C,OAAO,CAAC,6BAA6B,CAAC,CAexC;AAED;;;GAGG;AACH,wBAAsB,8BAA8B,CAClD,aAAa,EAAE,qCAAqC,EACpD,OAAO,GAAE,+BAAoC,GAC5C,OAAO,CAAC,uBAAuB,CAAC,CAelC"}
@@ -0,0 +1,40 @@
1
+ import { abortableBluetooth, assertBluetoothUserGesture, bluetoothError, getBluetoothAPI, getBluetoothNavigator, validateBluetoothRequestOptions, } from './bluetooth-internal';
2
+ /** Checks only for the standards-based Web Bluetooth entry point. */
3
+ export function isMoldableBluetoothSupported() {
4
+ const api = getBluetoothNavigator()?.bluetooth;
5
+ return Boolean(api && typeof api.requestDevice === 'function');
6
+ }
7
+ /**
8
+ * Returns adapter availability when the runtime exposes it. `unknown` means the
9
+ * API exists but cannot report adapter state, not that Bluetooth is available.
10
+ */
11
+ export async function getMoldableBluetoothAvailability(options = {}) {
12
+ const operation = 'check Bluetooth availability';
13
+ const api = getBluetoothAPI(operation);
14
+ if (typeof api.getAvailability !== 'function')
15
+ return 'unknown';
16
+ try {
17
+ return (await abortableBluetooth(api.getAvailability(), options.signal, operation))
18
+ ? 'available'
19
+ : 'unavailable';
20
+ }
21
+ catch (error) {
22
+ throw bluetoothError(error, operation);
23
+ }
24
+ }
25
+ /**
26
+ * Opens the browser's device chooser. This must be called directly from a
27
+ * trusted user action; it never silently scans for or selects devices.
28
+ */
29
+ export async function requestMoldableBluetoothDevice(deviceOptions, options = {}) {
30
+ const operation = 'request a Bluetooth device';
31
+ const api = getBluetoothAPI(operation);
32
+ validateBluetoothRequestOptions(deviceOptions);
33
+ assertBluetoothUserGesture();
34
+ try {
35
+ return await abortableBluetooth(api.requestDevice(deviceOptions), options.signal, operation, (device) => device.gatt?.disconnect());
36
+ }
37
+ catch (error) {
38
+ throw bluetoothError(error, operation);
39
+ }
40
+ }
@@ -0,0 +1,19 @@
1
+ import type { MoldableBluetoothConnectionOptions, MoldableBluetoothDevice, MoldableBluetoothOperationOptions, MoldableBluetoothRemoteGATTServer, MoldableBluetoothRemoteGATTService, MoldableBluetoothUUID } from './bluetooth-types';
2
+ export declare class MoldableBluetoothConnection {
3
+ readonly device: MoldableBluetoothDevice;
4
+ readonly server: MoldableBluetoothRemoteGATTServer;
5
+ private readonly abortSignal?;
6
+ private readonly disconnectListeners;
7
+ private isClosed;
8
+ constructor(device: MoldableBluetoothDevice, server: MoldableBluetoothRemoteGATTServer, options?: MoldableBluetoothConnectionOptions);
9
+ get connected(): boolean;
10
+ onDisconnected(listener: () => void, signal?: AbortSignal): () => void;
11
+ getPrimaryService(service: MoldableBluetoothUUID, options?: MoldableBluetoothOperationOptions): Promise<MoldableBluetoothRemoteGATTService>;
12
+ disconnect(): void;
13
+ private readonly handleAbort;
14
+ private readonly handleDisconnected;
15
+ private finish;
16
+ }
17
+ /** Connects a previously user-selected device and owns disconnect cleanup. */
18
+ export declare function connectMoldableBluetoothDevice(device: MoldableBluetoothDevice, options?: MoldableBluetoothConnectionOptions): Promise<MoldableBluetoothConnection>;
19
+ //# sourceMappingURL=bluetooth-connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bluetooth-connection.d.ts","sourceRoot":"","sources":["../../../src/lib/native-hardware/bluetooth-connection.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,kCAAkC,EAClC,uBAAuB,EACvB,iCAAiC,EACjC,iCAAiC,EACjC,kCAAkC,EAClC,qBAAqB,EACtB,MAAM,mBAAmB,CAAA;AAE1B,qBAAa,2BAA2B;IACtC,QAAQ,CAAC,MAAM,EAAE,uBAAuB,CAAA;IACxC,QAAQ,CAAC,MAAM,EAAE,iCAAiC,CAAA;IAClD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAa;IAC1C,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAwB;IAC5D,OAAO,CAAC,QAAQ,CAAQ;gBAGtB,MAAM,EAAE,uBAAuB,EAC/B,MAAM,EAAE,iCAAiC,EACzC,OAAO,GAAE,kCAAuC;IASlD,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,cAAc,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,MAAM,IAAI;IAWhE,iBAAiB,CACrB,OAAO,EAAE,qBAAqB,EAC9B,OAAO,GAAE,iCAAsC,GAC9C,OAAO,CAAC,kCAAkC,CAAC;IAmB9C,UAAU,IAAI,IAAI;IAMlB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA0B;IACtD,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAA0B;IAE7D,OAAO,CAAC,MAAM;CAqBf;AAED,8EAA8E;AAC9E,wBAAsB,8BAA8B,CAClD,MAAM,EAAE,uBAAuB,EAC/B,OAAO,GAAE,kCAAuC,GAC/C,OAAO,CAAC,2BAA2B,CAAC,CA0BtC"}