@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.
- package/dist/catalog/catalog-manifest.d.ts +6 -0
- package/dist/catalog/catalog-manifest.d.ts.map +1 -0
- package/dist/catalog/catalog-manifest.js +105 -0
- package/dist/catalog/catalog-types.d.ts +54 -0
- package/dist/catalog/catalog-types.d.ts.map +1 -0
- package/dist/catalog/catalog-types.js +14 -0
- package/dist/catalog/component-catalog.d.ts +14 -0
- package/dist/catalog/component-catalog.d.ts.map +1 -0
- package/dist/catalog/component-catalog.js +39 -0
- package/dist/catalog/core-catalog.d.ts +6 -0
- package/dist/catalog/core-catalog.d.ts.map +1 -0
- package/dist/catalog/core-catalog.js +105 -0
- package/dist/catalog/index.d.ts +5 -0
- package/dist/catalog/index.d.ts.map +1 -0
- package/dist/catalog/index.js +4 -0
- package/dist/components/app-error-boundary.d.ts +1 -0
- package/dist/components/app-error-boundary.d.ts.map +1 -1
- package/dist/components/app-error-boundary.js +13 -0
- package/dist/components/chat/chat-image-lightbox.d.ts +9 -0
- package/dist/components/chat/chat-image-lightbox.d.ts.map +1 -0
- package/dist/components/chat/chat-image-lightbox.js +9 -0
- package/dist/components/chat/chat-message.d.ts +19 -1
- package/dist/components/chat/chat-message.d.ts.map +1 -1
- package/dist/components/chat/chat-message.js +66 -16
- package/dist/components/chat/chat-messages.d.ts +5 -2
- package/dist/components/chat/chat-messages.d.ts.map +1 -1
- package/dist/components/chat/chat-messages.js +61 -6
- package/dist/components/chat/chat-panel.d.ts +67 -17
- package/dist/components/chat/chat-panel.d.ts.map +1 -1
- package/dist/components/chat/chat-panel.js +250 -159
- package/dist/components/chat/conversation-history.d.ts +39 -5
- package/dist/components/chat/conversation-history.d.ts.map +1 -1
- package/dist/components/chat/conversation-history.js +192 -26
- package/dist/components/chat/index.d.ts +3 -2
- package/dist/components/chat/index.d.ts.map +1 -1
- package/dist/components/chat/index.js +3 -2
- package/dist/components/chat/model-effort-power-effects.d.ts +7 -0
- package/dist/components/chat/model-effort-power-effects.d.ts.map +1 -0
- package/dist/components/chat/model-effort-power-effects.js +54 -0
- package/dist/components/chat/model-effort-selector.d.ts +26 -0
- package/dist/components/chat/model-effort-selector.d.ts.map +1 -0
- package/dist/components/chat/model-effort-selector.js +179 -0
- package/dist/components/chat/model-effort-ultra-effects.d.ts +5 -0
- package/dist/components/chat/model-effort-ultra-effects.d.ts.map +1 -0
- package/dist/components/chat/model-effort-ultra-effects.js +56 -0
- package/dist/components/chat/tool-handlers.d.ts.map +1 -1
- package/dist/components/chat/tool-handlers.js +40 -2
- package/dist/components/chat/vertical-scroll-fade.d.ts +6 -0
- package/dist/components/chat/vertical-scroll-fade.d.ts.map +1 -0
- package/dist/components/chat/vertical-scroll-fade.js +12 -0
- package/dist/components/hardware/bluetooth-panel-helpers.d.ts +9 -0
- package/dist/components/hardware/bluetooth-panel-helpers.d.ts.map +1 -0
- package/dist/components/hardware/bluetooth-panel-helpers.js +37 -0
- package/dist/components/hardware/bluetooth-panel.d.ts +56 -0
- package/dist/components/hardware/bluetooth-panel.d.ts.map +1 -0
- package/dist/components/hardware/bluetooth-panel.js +470 -0
- package/dist/components/hardware/camera-preview.d.ts +39 -0
- package/dist/components/hardware/camera-preview.d.ts.map +1 -0
- package/dist/components/hardware/camera-preview.js +228 -0
- package/dist/components/hardware/capability-badge.d.ts +23 -0
- package/dist/components/hardware/capability-badge.d.ts.map +1 -0
- package/dist/components/hardware/capability-badge.js +39 -0
- package/dist/components/hardware/capability-matrix.d.ts +14 -0
- package/dist/components/hardware/capability-matrix.d.ts.map +1 -0
- package/dist/components/hardware/capability-matrix.js +97 -0
- package/dist/components/hardware/clipboard-button.d.ts +26 -0
- package/dist/components/hardware/clipboard-button.d.ts.map +1 -0
- package/dist/components/hardware/clipboard-button.js +114 -0
- package/dist/components/hardware/device-io-controls.d.ts +4 -0
- package/dist/components/hardware/device-io-controls.d.ts.map +1 -0
- package/dist/components/hardware/device-io-controls.js +28 -0
- package/dist/components/hardware/device-list.d.ts +20 -0
- package/dist/components/hardware/device-list.d.ts.map +1 -0
- package/dist/components/hardware/device-list.js +14 -0
- package/dist/components/hardware/display-map.d.ts +23 -0
- package/dist/components/hardware/display-map.d.ts.map +1 -0
- package/dist/components/hardware/display-map.js +114 -0
- package/dist/components/hardware/haptic-button.d.ts +26 -0
- package/dist/components/hardware/haptic-button.d.ts.map +1 -0
- package/dist/components/hardware/haptic-button.js +94 -0
- package/dist/components/hardware/hardware-panel.d.ts +11 -0
- package/dist/components/hardware/hardware-panel.d.ts.map +1 -0
- package/dist/components/hardware/hardware-panel.js +28 -0
- package/dist/components/hardware/hid-panel.d.ts +40 -0
- package/dist/components/hardware/hid-panel.d.ts.map +1 -0
- package/dist/components/hardware/hid-panel.js +373 -0
- package/dist/components/hardware/index.d.ts +27 -0
- package/dist/components/hardware/index.d.ts.map +1 -0
- package/dist/components/hardware/index.js +26 -0
- package/dist/components/hardware/live-indicator.d.ts +15 -0
- package/dist/components/hardware/live-indicator.d.ts.map +1 -0
- package/dist/components/hardware/live-indicator.js +26 -0
- package/dist/components/hardware/local-auth-button.d.ts +33 -0
- package/dist/components/hardware/local-auth-button.d.ts.map +1 -0
- package/dist/components/hardware/local-auth-button.js +115 -0
- package/dist/components/hardware/location-panel.d.ts +29 -0
- package/dist/components/hardware/location-panel.d.ts.map +1 -0
- package/dist/components/hardware/location-panel.js +154 -0
- package/dist/components/hardware/microphone-meter.d.ts +35 -0
- package/dist/components/hardware/microphone-meter.d.ts.map +1 -0
- package/dist/components/hardware/microphone-meter.js +244 -0
- package/dist/components/hardware/midi-monitor.d.ts +54 -0
- package/dist/components/hardware/midi-monitor.d.ts.map +1 -0
- package/dist/components/hardware/midi-monitor.js +534 -0
- package/dist/components/hardware/notification-panel.d.ts +24 -0
- package/dist/components/hardware/notification-panel.d.ts.map +1 -0
- package/dist/components/hardware/notification-panel.js +124 -0
- package/dist/components/hardware/power-blocker-controller.d.ts +19 -0
- package/dist/components/hardware/power-blocker-controller.d.ts.map +1 -0
- package/dist/components/hardware/power-blocker-controller.js +83 -0
- package/dist/components/hardware/power-panel.d.ts +67 -0
- package/dist/components/hardware/power-panel.d.ts.map +1 -0
- package/dist/components/hardware/power-panel.js +309 -0
- package/dist/components/hardware/readout.d.ts +10 -0
- package/dist/components/hardware/readout.d.ts.map +1 -0
- package/dist/components/hardware/readout.js +11 -0
- package/dist/components/hardware/screen-share-preview.d.ts +36 -0
- package/dist/components/hardware/screen-share-preview.d.ts.map +1 -0
- package/dist/components/hardware/screen-share-preview.js +191 -0
- package/dist/components/hardware/secure-storage-panel.d.ts +36 -0
- package/dist/components/hardware/secure-storage-panel.d.ts.map +1 -0
- package/dist/components/hardware/secure-storage-panel.js +193 -0
- package/dist/components/hardware/serial-console.d.ts +64 -0
- package/dist/components/hardware/serial-console.d.ts.map +1 -0
- package/dist/components/hardware/serial-console.js +399 -0
- package/dist/components/hardware/shortcut-recorder.d.ts +35 -0
- package/dist/components/hardware/shortcut-recorder.d.ts.map +1 -0
- package/dist/components/hardware/shortcut-recorder.js +217 -0
- package/dist/components/hardware/stream-log.d.ts +35 -0
- package/dist/components/hardware/stream-log.d.ts.map +1 -0
- package/dist/components/hardware/stream-log.js +65 -0
- package/dist/components/hardware/system-audio-monitor.d.ts +34 -0
- package/dist/components/hardware/system-audio-monitor.d.ts.map +1 -0
- package/dist/components/hardware/system-audio-monitor.js +275 -0
- package/dist/components/hardware/usb-panel.d.ts +54 -0
- package/dist/components/hardware/usb-panel.d.ts.map +1 -0
- package/dist/components/hardware/usb-panel.js +363 -0
- package/dist/components/hardware/use-capability.d.ts +20 -0
- package/dist/components/hardware/use-capability.d.ts.map +1 -0
- package/dist/components/hardware/use-capability.js +61 -0
- package/dist/components/native-capabilities/bluetooth-panel-helpers.d.ts +9 -0
- package/dist/components/native-capabilities/bluetooth-panel-helpers.d.ts.map +1 -0
- package/dist/components/native-capabilities/bluetooth-panel-helpers.js +37 -0
- package/dist/components/native-capabilities/bluetooth-panel.d.ts +56 -0
- package/dist/components/native-capabilities/bluetooth-panel.d.ts.map +1 -0
- package/dist/components/native-capabilities/bluetooth-panel.js +470 -0
- package/dist/components/native-capabilities/camera-preview.d.ts +39 -0
- package/dist/components/native-capabilities/camera-preview.d.ts.map +1 -0
- package/dist/components/native-capabilities/camera-preview.js +228 -0
- package/dist/components/native-capabilities/capability-badge.d.ts +23 -0
- package/dist/components/native-capabilities/capability-badge.d.ts.map +1 -0
- package/dist/components/native-capabilities/capability-badge.js +39 -0
- package/dist/components/native-capabilities/capability-matrix.d.ts +14 -0
- package/dist/components/native-capabilities/capability-matrix.d.ts.map +1 -0
- package/dist/components/native-capabilities/capability-matrix.js +97 -0
- package/dist/components/native-capabilities/clipboard-button.d.ts +26 -0
- package/dist/components/native-capabilities/clipboard-button.d.ts.map +1 -0
- package/dist/components/native-capabilities/clipboard-button.js +99 -0
- package/dist/components/native-capabilities/device-io-controls.d.ts +4 -0
- package/dist/components/native-capabilities/device-io-controls.d.ts.map +1 -0
- package/dist/components/native-capabilities/device-io-controls.js +28 -0
- package/dist/components/native-capabilities/device-list.d.ts +20 -0
- package/dist/components/native-capabilities/device-list.d.ts.map +1 -0
- package/dist/components/native-capabilities/device-list.js +14 -0
- package/dist/components/native-capabilities/display-map.d.ts +23 -0
- package/dist/components/native-capabilities/display-map.d.ts.map +1 -0
- package/dist/components/native-capabilities/display-map.js +114 -0
- package/dist/components/native-capabilities/haptic-button.d.ts +26 -0
- package/dist/components/native-capabilities/haptic-button.d.ts.map +1 -0
- package/dist/components/native-capabilities/haptic-button.js +94 -0
- package/dist/components/native-capabilities/hid-panel.d.ts +40 -0
- package/dist/components/native-capabilities/hid-panel.d.ts.map +1 -0
- package/dist/components/native-capabilities/hid-panel.js +373 -0
- package/dist/components/native-capabilities/index.d.ts +27 -0
- package/dist/components/native-capabilities/index.d.ts.map +1 -0
- package/dist/components/native-capabilities/index.js +26 -0
- package/dist/components/native-capabilities/live-indicator.d.ts +15 -0
- package/dist/components/native-capabilities/live-indicator.d.ts.map +1 -0
- package/dist/components/native-capabilities/live-indicator.js +26 -0
- package/dist/components/native-capabilities/local-auth-button.d.ts +33 -0
- package/dist/components/native-capabilities/local-auth-button.d.ts.map +1 -0
- package/dist/components/native-capabilities/local-auth-button.js +115 -0
- package/dist/components/native-capabilities/location-panel.d.ts +29 -0
- package/dist/components/native-capabilities/location-panel.d.ts.map +1 -0
- package/dist/components/native-capabilities/location-panel.js +146 -0
- package/dist/components/native-capabilities/microphone-meter.d.ts +35 -0
- package/dist/components/native-capabilities/microphone-meter.d.ts.map +1 -0
- package/dist/components/native-capabilities/microphone-meter.js +244 -0
- package/dist/components/native-capabilities/midi-monitor.d.ts +54 -0
- package/dist/components/native-capabilities/midi-monitor.d.ts.map +1 -0
- package/dist/components/native-capabilities/midi-monitor.js +534 -0
- package/dist/components/native-capabilities/native-capability-panel.d.ts +11 -0
- package/dist/components/native-capabilities/native-capability-panel.d.ts.map +1 -0
- package/dist/components/native-capabilities/native-capability-panel.js +28 -0
- package/dist/components/native-capabilities/notification-panel.d.ts +24 -0
- package/dist/components/native-capabilities/notification-panel.d.ts.map +1 -0
- package/dist/components/native-capabilities/notification-panel.js +124 -0
- package/dist/components/native-capabilities/power-blocker-controller.d.ts +19 -0
- package/dist/components/native-capabilities/power-blocker-controller.d.ts.map +1 -0
- package/dist/components/native-capabilities/power-blocker-controller.js +83 -0
- package/dist/components/native-capabilities/power-panel.d.ts +67 -0
- package/dist/components/native-capabilities/power-panel.d.ts.map +1 -0
- package/dist/components/native-capabilities/power-panel.js +309 -0
- package/dist/components/native-capabilities/readout.d.ts +10 -0
- package/dist/components/native-capabilities/readout.d.ts.map +1 -0
- package/dist/components/native-capabilities/readout.js +11 -0
- package/dist/components/native-capabilities/screen-share-preview.d.ts +36 -0
- package/dist/components/native-capabilities/screen-share-preview.d.ts.map +1 -0
- package/dist/components/native-capabilities/screen-share-preview.js +191 -0
- package/dist/components/native-capabilities/secure-storage-panel.d.ts +36 -0
- package/dist/components/native-capabilities/secure-storage-panel.d.ts.map +1 -0
- package/dist/components/native-capabilities/secure-storage-panel.js +193 -0
- package/dist/components/native-capabilities/serial-console.d.ts +64 -0
- package/dist/components/native-capabilities/serial-console.d.ts.map +1 -0
- package/dist/components/native-capabilities/serial-console.js +399 -0
- package/dist/components/native-capabilities/shortcut-recorder.d.ts +35 -0
- package/dist/components/native-capabilities/shortcut-recorder.d.ts.map +1 -0
- package/dist/components/native-capabilities/shortcut-recorder.js +217 -0
- package/dist/components/native-capabilities/stream-log.d.ts +35 -0
- package/dist/components/native-capabilities/stream-log.d.ts.map +1 -0
- package/dist/components/native-capabilities/stream-log.js +65 -0
- package/dist/components/native-capabilities/system-audio-monitor.d.ts +34 -0
- package/dist/components/native-capabilities/system-audio-monitor.d.ts.map +1 -0
- package/dist/components/native-capabilities/system-audio-monitor.js +275 -0
- package/dist/components/native-capabilities/usb-panel.d.ts +54 -0
- package/dist/components/native-capabilities/usb-panel.d.ts.map +1 -0
- package/dist/components/native-capabilities/usb-panel.js +363 -0
- package/dist/components/native-capabilities/use-capability.d.ts +20 -0
- package/dist/components/native-capabilities/use-capability.d.ts.map +1 -0
- package/dist/components/native-capabilities/use-capability.js +61 -0
- package/dist/components/ui/app-frame.d.ts +22 -0
- package/dist/components/ui/app-frame.d.ts.map +1 -0
- package/dist/components/ui/app-frame.js +56 -0
- package/dist/components/ui/button-group.d.ts +1 -1
- package/dist/components/ui/button.js +1 -1
- package/dist/components/ui/color-well.d.ts +13 -0
- package/dist/components/ui/color-well.d.ts.map +1 -0
- package/dist/components/ui/color-well.js +30 -0
- package/dist/components/ui/date-field.d.ts +19 -0
- package/dist/components/ui/date-field.d.ts.map +1 -0
- package/dist/components/ui/date-field.js +54 -0
- package/dist/components/ui/edge-fade.d.ts +11 -0
- package/dist/components/ui/edge-fade.d.ts.map +1 -0
- package/dist/components/ui/edge-fade.js +41 -0
- package/dist/components/ui/empty.js +1 -1
- package/dist/components/ui/field.d.ts +1 -1
- package/dist/components/ui/grid.d.ts +24 -0
- package/dist/components/ui/grid.d.ts.map +1 -0
- package/dist/components/ui/grid.js +234 -0
- package/dist/components/ui/icon-button.d.ts +15 -0
- package/dist/components/ui/icon-button.d.ts.map +1 -0
- package/dist/components/ui/icon-button.js +15 -0
- package/dist/components/ui/index.d.ts +19 -0
- package/dist/components/ui/index.d.ts.map +1 -1
- package/dist/components/ui/index.js +19 -0
- package/dist/components/ui/inspector.d.ts +15 -0
- package/dist/components/ui/inspector.d.ts.map +1 -0
- package/dist/components/ui/inspector.js +26 -0
- package/dist/components/ui/kbd.d.ts +1 -1
- package/dist/components/ui/list.d.ts +24 -0
- package/dist/components/ui/list.d.ts.map +1 -0
- package/dist/components/ui/list.js +224 -0
- package/dist/components/ui/message-scroller-layout-stability.d.ts +33 -0
- package/dist/components/ui/message-scroller-layout-stability.d.ts.map +1 -0
- package/dist/components/ui/message-scroller-layout-stability.js +153 -0
- package/dist/components/ui/message-scroller.d.ts +11 -0
- package/dist/components/ui/message-scroller.d.ts.map +1 -0
- package/dist/components/ui/message-scroller.js +37 -0
- package/dist/components/ui/notification-dot.d.ts +4 -0
- package/dist/components/ui/notification-dot.d.ts.map +1 -0
- package/dist/components/ui/notification-dot.js +7 -0
- package/dist/components/ui/number-input.d.ts +16 -0
- package/dist/components/ui/number-input.d.ts.map +1 -0
- package/dist/components/ui/number-input.js +56 -0
- package/dist/components/ui/panel.d.ts +18 -0
- package/dist/components/ui/panel.d.ts.map +1 -0
- package/dist/components/ui/panel.js +40 -0
- package/dist/components/ui/popover.js +1 -1
- package/dist/components/ui/search-field.d.ts +19 -0
- package/dist/components/ui/search-field.d.ts.map +1 -0
- package/dist/components/ui/search-field.js +64 -0
- package/dist/components/ui/segmented-control.d.ts +21 -0
- package/dist/components/ui/segmented-control.d.ts.map +1 -0
- package/dist/components/ui/segmented-control.js +61 -0
- package/dist/components/ui/sidebar.js +1 -1
- package/dist/components/ui/slider.d.ts +4 -1
- package/dist/components/ui/slider.d.ts.map +1 -1
- package/dist/components/ui/slider.js +2 -2
- package/dist/components/ui/sonner.d.ts +4 -3
- package/dist/components/ui/sonner.d.ts.map +1 -1
- package/dist/components/ui/sonner.js +7 -6
- package/dist/components/ui/split-view.d.ts +11 -0
- package/dist/components/ui/split-view.d.ts.map +1 -0
- package/dist/components/ui/split-view.js +13 -0
- package/dist/components/ui/status.d.ts +13 -0
- package/dist/components/ui/status.d.ts.map +1 -0
- package/dist/components/ui/status.js +36 -0
- package/dist/components/ui/table.d.ts +11 -2
- package/dist/components/ui/table.d.ts.map +1 -1
- package/dist/components/ui/table.js +28 -6
- package/dist/components/ui/text.d.ts +17 -0
- package/dist/components/ui/text.d.ts.map +1 -0
- package/dist/components/ui/text.js +55 -0
- package/dist/components/ui/toggle.js +1 -1
- package/dist/components/ui/toolbar.d.ts +20 -0
- package/dist/components/ui/toolbar.d.ts.map +1 -0
- package/dist/components/ui/toolbar.js +52 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/lib/frame-lifecycle.d.ts +28 -0
- package/dist/lib/frame-lifecycle.d.ts.map +1 -1
- package/dist/lib/frame-lifecycle.js +84 -0
- package/dist/lib/native-capabilities/access.d.ts +13 -0
- package/dist/lib/native-capabilities/access.d.ts.map +1 -0
- package/dist/lib/native-capabilities/access.js +53 -0
- package/dist/lib/native-capabilities/bluetooth-access.d.ts +14 -0
- package/dist/lib/native-capabilities/bluetooth-access.d.ts.map +1 -0
- package/dist/lib/native-capabilities/bluetooth-access.js +43 -0
- package/dist/lib/native-capabilities/bluetooth-connection.d.ts +19 -0
- package/dist/lib/native-capabilities/bluetooth-connection.d.ts.map +1 -0
- package/dist/lib/native-capabilities/bluetooth-connection.js +88 -0
- package/dist/lib/native-capabilities/bluetooth-gatt.d.ts +7 -0
- package/dist/lib/native-capabilities/bluetooth-gatt.d.ts.map +1 -0
- package/dist/lib/native-capabilities/bluetooth-gatt.js +77 -0
- package/dist/lib/native-capabilities/bluetooth-internal.d.ts +10 -0
- package/dist/lib/native-capabilities/bluetooth-internal.d.ts.map +1 -0
- package/dist/lib/native-capabilities/bluetooth-internal.js +105 -0
- package/dist/lib/native-capabilities/bluetooth-native-fallback.d.ts +33 -0
- package/dist/lib/native-capabilities/bluetooth-native-fallback.d.ts.map +1 -0
- package/dist/lib/native-capabilities/bluetooth-native-fallback.js +214 -0
- package/dist/lib/native-capabilities/bluetooth-types.d.ts +85 -0
- package/dist/lib/native-capabilities/bluetooth-types.d.ts.map +1 -0
- package/dist/lib/native-capabilities/bluetooth-types.js +2 -0
- package/dist/lib/native-capabilities/bluetooth.d.ts +7 -0
- package/dist/lib/native-capabilities/bluetooth.d.ts.map +1 -0
- package/dist/lib/native-capabilities/bluetooth.js +4 -0
- package/dist/lib/native-capabilities/bridge.d.ts +23 -0
- package/dist/lib/native-capabilities/bridge.d.ts.map +1 -0
- package/dist/lib/native-capabilities/bridge.js +266 -0
- package/dist/lib/native-capabilities/capabilities.d.ts +7 -0
- package/dist/lib/native-capabilities/capabilities.d.ts.map +1 -0
- package/dist/lib/native-capabilities/capabilities.js +95 -0
- package/dist/lib/native-capabilities/clipboard.d.ts +11 -0
- package/dist/lib/native-capabilities/clipboard.d.ts.map +1 -0
- package/dist/lib/native-capabilities/clipboard.js +58 -0
- package/dist/lib/native-capabilities/device-io-errors.d.ts +11 -0
- package/dist/lib/native-capabilities/device-io-errors.d.ts.map +1 -0
- package/dist/lib/native-capabilities/device-io-errors.js +82 -0
- package/dist/lib/native-capabilities/displays.d.ts +38 -0
- package/dist/lib/native-capabilities/displays.d.ts.map +1 -0
- package/dist/lib/native-capabilities/displays.js +12 -0
- package/dist/lib/native-capabilities/global-shortcuts.d.ts +86 -0
- package/dist/lib/native-capabilities/global-shortcuts.d.ts.map +1 -0
- package/dist/lib/native-capabilities/global-shortcuts.js +351 -0
- package/dist/lib/native-capabilities/haptics.d.ts +25 -0
- package/dist/lib/native-capabilities/haptics.d.ts.map +1 -0
- package/dist/lib/native-capabilities/haptics.js +18 -0
- package/dist/lib/native-capabilities/hid-native.d.ts +26 -0
- package/dist/lib/native-capabilities/hid-native.d.ts.map +1 -0
- package/dist/lib/native-capabilities/hid-native.js +229 -0
- package/dist/lib/native-capabilities/hid.d.ts +52 -0
- package/dist/lib/native-capabilities/hid.d.ts.map +1 -0
- package/dist/lib/native-capabilities/hid.js +163 -0
- package/dist/lib/native-capabilities/index.d.ts +40 -0
- package/dist/lib/native-capabilities/index.d.ts.map +1 -0
- package/dist/lib/native-capabilities/index.js +21 -0
- package/dist/lib/native-capabilities/local-authentication.d.ts +32 -0
- package/dist/lib/native-capabilities/local-authentication.d.ts.map +1 -0
- package/dist/lib/native-capabilities/local-authentication.js +46 -0
- package/dist/lib/native-capabilities/location.d.ts +49 -0
- package/dist/lib/native-capabilities/location.d.ts.map +1 -0
- package/dist/lib/native-capabilities/location.js +114 -0
- package/dist/lib/native-capabilities/media-permissions.d.ts +28 -0
- package/dist/lib/native-capabilities/media-permissions.d.ts.map +1 -0
- package/dist/lib/native-capabilities/media-permissions.js +37 -0
- package/dist/lib/native-capabilities/media.d.ts +17 -0
- package/dist/lib/native-capabilities/media.d.ts.map +1 -0
- package/dist/lib/native-capabilities/media.js +104 -0
- package/dist/lib/native-capabilities/midi-access.d.ts +13 -0
- package/dist/lib/native-capabilities/midi-access.d.ts.map +1 -0
- package/dist/lib/native-capabilities/midi-access.js +68 -0
- package/dist/lib/native-capabilities/midi-internal.d.ts +12 -0
- package/dist/lib/native-capabilities/midi-internal.d.ts.map +1 -0
- package/dist/lib/native-capabilities/midi-internal.js +88 -0
- package/dist/lib/native-capabilities/midi-native-fallback.d.ts +27 -0
- package/dist/lib/native-capabilities/midi-native-fallback.d.ts.map +1 -0
- package/dist/lib/native-capabilities/midi-native-fallback.js +127 -0
- package/dist/lib/native-capabilities/midi-ports.d.ts +6 -0
- package/dist/lib/native-capabilities/midi-ports.d.ts.map +1 -0
- package/dist/lib/native-capabilities/midi-ports.js +115 -0
- package/dist/lib/native-capabilities/midi-types.d.ts +25 -0
- package/dist/lib/native-capabilities/midi-types.d.ts.map +1 -0
- package/dist/lib/native-capabilities/midi-types.js +1 -0
- package/dist/lib/native-capabilities/midi.d.ts +6 -0
- package/dist/lib/native-capabilities/midi.d.ts.map +1 -0
- package/dist/lib/native-capabilities/midi.js +3 -0
- package/dist/lib/native-capabilities/native-device-io.d.ts +28 -0
- package/dist/lib/native-capabilities/native-device-io.d.ts.map +1 -0
- package/dist/lib/native-capabilities/native-device-io.js +91 -0
- package/dist/lib/native-capabilities/native-device-lifecycle.d.ts +13 -0
- package/dist/lib/native-capabilities/native-device-lifecycle.d.ts.map +1 -0
- package/dist/lib/native-capabilities/native-device-lifecycle.js +40 -0
- package/dist/lib/native-capabilities/notifications.d.ts +38 -0
- package/dist/lib/native-capabilities/notifications.d.ts.map +1 -0
- package/dist/lib/native-capabilities/notifications.js +50 -0
- package/dist/lib/native-capabilities/power-session.d.ts +113 -0
- package/dist/lib/native-capabilities/power-session.d.ts.map +1 -0
- package/dist/lib/native-capabilities/power-session.js +264 -0
- package/dist/lib/native-capabilities/secure-storage.d.ts +36 -0
- package/dist/lib/native-capabilities/secure-storage.d.ts.map +1 -0
- package/dist/lib/native-capabilities/secure-storage.js +64 -0
- package/dist/lib/native-capabilities/serial-native.d.ts +23 -0
- package/dist/lib/native-capabilities/serial-native.d.ts.map +1 -0
- package/dist/lib/native-capabilities/serial-native.js +181 -0
- package/dist/lib/native-capabilities/serial.d.ts +76 -0
- package/dist/lib/native-capabilities/serial.d.ts.map +1 -0
- package/dist/lib/native-capabilities/serial.js +215 -0
- package/dist/lib/native-capabilities/system-audio.d.ts +127 -0
- package/dist/lib/native-capabilities/system-audio.d.ts.map +1 -0
- package/dist/lib/native-capabilities/system-audio.js +330 -0
- package/dist/lib/native-capabilities/types.d.ts +62 -0
- package/dist/lib/native-capabilities/types.d.ts.map +1 -0
- package/dist/lib/native-capabilities/types.js +27 -0
- package/dist/lib/native-capabilities/usb-native.d.ts +39 -0
- package/dist/lib/native-capabilities/usb-native.d.ts.map +1 -0
- package/dist/lib/native-capabilities/usb-native.js +217 -0
- package/dist/lib/native-capabilities/usb.d.ts +85 -0
- package/dist/lib/native-capabilities/usb.d.ts.map +1 -0
- package/dist/lib/native-capabilities/usb.js +225 -0
- package/dist/lib/native-hardware/bluetooth-access.d.ts +14 -0
- package/dist/lib/native-hardware/bluetooth-access.d.ts.map +1 -0
- package/dist/lib/native-hardware/bluetooth-access.js +40 -0
- package/dist/lib/native-hardware/bluetooth-connection.d.ts +19 -0
- package/dist/lib/native-hardware/bluetooth-connection.d.ts.map +1 -0
- package/dist/lib/native-hardware/bluetooth-connection.js +88 -0
- package/dist/lib/native-hardware/bluetooth-gatt.d.ts +7 -0
- package/dist/lib/native-hardware/bluetooth-gatt.d.ts.map +1 -0
- package/dist/lib/native-hardware/bluetooth-gatt.js +77 -0
- package/dist/lib/native-hardware/bluetooth-internal.d.ts +10 -0
- package/dist/lib/native-hardware/bluetooth-internal.d.ts.map +1 -0
- package/dist/lib/native-hardware/bluetooth-internal.js +105 -0
- package/dist/lib/native-hardware/bluetooth-native-fallback.d.ts +33 -0
- package/dist/lib/native-hardware/bluetooth-native-fallback.d.ts.map +1 -0
- package/dist/lib/native-hardware/bluetooth-native-fallback.js +214 -0
- package/dist/lib/native-hardware/bluetooth-types.d.ts +85 -0
- package/dist/lib/native-hardware/bluetooth-types.d.ts.map +1 -0
- package/dist/lib/native-hardware/bluetooth-types.js +2 -0
- package/dist/lib/native-hardware/bluetooth.d.ts +7 -0
- package/dist/lib/native-hardware/bluetooth.d.ts.map +1 -0
- package/dist/lib/native-hardware/bluetooth.js +4 -0
- package/dist/lib/native-hardware/bridge.d.ts +23 -0
- package/dist/lib/native-hardware/bridge.d.ts.map +1 -0
- package/dist/lib/native-hardware/bridge.js +266 -0
- package/dist/lib/native-hardware/capabilities.d.ts +7 -0
- package/dist/lib/native-hardware/capabilities.d.ts.map +1 -0
- package/dist/lib/native-hardware/capabilities.js +95 -0
- package/dist/lib/native-hardware/clipboard.d.ts +11 -0
- package/dist/lib/native-hardware/clipboard.d.ts.map +1 -0
- package/dist/lib/native-hardware/clipboard.js +55 -0
- package/dist/lib/native-hardware/device-io-errors.d.ts +11 -0
- package/dist/lib/native-hardware/device-io-errors.d.ts.map +1 -0
- package/dist/lib/native-hardware/device-io-errors.js +82 -0
- package/dist/lib/native-hardware/displays.d.ts +38 -0
- package/dist/lib/native-hardware/displays.d.ts.map +1 -0
- package/dist/lib/native-hardware/displays.js +12 -0
- package/dist/lib/native-hardware/global-shortcuts.d.ts +86 -0
- package/dist/lib/native-hardware/global-shortcuts.d.ts.map +1 -0
- package/dist/lib/native-hardware/global-shortcuts.js +351 -0
- package/dist/lib/native-hardware/haptics.d.ts +25 -0
- package/dist/lib/native-hardware/haptics.d.ts.map +1 -0
- package/dist/lib/native-hardware/haptics.js +18 -0
- package/dist/lib/native-hardware/hid-native.d.ts +26 -0
- package/dist/lib/native-hardware/hid-native.d.ts.map +1 -0
- package/dist/lib/native-hardware/hid-native.js +229 -0
- package/dist/lib/native-hardware/hid.d.ts +52 -0
- package/dist/lib/native-hardware/hid.d.ts.map +1 -0
- package/dist/lib/native-hardware/hid.js +160 -0
- package/dist/lib/native-hardware/index.d.ts +38 -0
- package/dist/lib/native-hardware/index.d.ts.map +1 -0
- package/dist/lib/native-hardware/index.js +20 -0
- package/dist/lib/native-hardware/local-authentication.d.ts +32 -0
- package/dist/lib/native-hardware/local-authentication.d.ts.map +1 -0
- package/dist/lib/native-hardware/local-authentication.js +46 -0
- package/dist/lib/native-hardware/location.d.ts +49 -0
- package/dist/lib/native-hardware/location.d.ts.map +1 -0
- package/dist/lib/native-hardware/location.js +114 -0
- package/dist/lib/native-hardware/media-permissions.d.ts +28 -0
- package/dist/lib/native-hardware/media-permissions.d.ts.map +1 -0
- package/dist/lib/native-hardware/media-permissions.js +37 -0
- package/dist/lib/native-hardware/media.d.ts +17 -0
- package/dist/lib/native-hardware/media.d.ts.map +1 -0
- package/dist/lib/native-hardware/media.js +99 -0
- package/dist/lib/native-hardware/midi-access.d.ts +13 -0
- package/dist/lib/native-hardware/midi-access.d.ts.map +1 -0
- package/dist/lib/native-hardware/midi-access.js +66 -0
- package/dist/lib/native-hardware/midi-internal.d.ts +12 -0
- package/dist/lib/native-hardware/midi-internal.d.ts.map +1 -0
- package/dist/lib/native-hardware/midi-internal.js +88 -0
- package/dist/lib/native-hardware/midi-native-fallback.d.ts +27 -0
- package/dist/lib/native-hardware/midi-native-fallback.d.ts.map +1 -0
- package/dist/lib/native-hardware/midi-native-fallback.js +127 -0
- package/dist/lib/native-hardware/midi-ports.d.ts +6 -0
- package/dist/lib/native-hardware/midi-ports.d.ts.map +1 -0
- package/dist/lib/native-hardware/midi-ports.js +115 -0
- package/dist/lib/native-hardware/midi-types.d.ts +25 -0
- package/dist/lib/native-hardware/midi-types.d.ts.map +1 -0
- package/dist/lib/native-hardware/midi-types.js +1 -0
- package/dist/lib/native-hardware/midi.d.ts +6 -0
- package/dist/lib/native-hardware/midi.d.ts.map +1 -0
- package/dist/lib/native-hardware/midi.js +3 -0
- package/dist/lib/native-hardware/native-device-io.d.ts +28 -0
- package/dist/lib/native-hardware/native-device-io.d.ts.map +1 -0
- package/dist/lib/native-hardware/native-device-io.js +91 -0
- package/dist/lib/native-hardware/native-device-lifecycle.d.ts +13 -0
- package/dist/lib/native-hardware/native-device-lifecycle.d.ts.map +1 -0
- package/dist/lib/native-hardware/native-device-lifecycle.js +40 -0
- package/dist/lib/native-hardware/notifications.d.ts +38 -0
- package/dist/lib/native-hardware/notifications.d.ts.map +1 -0
- package/dist/lib/native-hardware/notifications.js +50 -0
- package/dist/lib/native-hardware/power-session.d.ts +113 -0
- package/dist/lib/native-hardware/power-session.d.ts.map +1 -0
- package/dist/lib/native-hardware/power-session.js +264 -0
- package/dist/lib/native-hardware/secure-storage.d.ts +36 -0
- package/dist/lib/native-hardware/secure-storage.d.ts.map +1 -0
- package/dist/lib/native-hardware/secure-storage.js +64 -0
- package/dist/lib/native-hardware/serial-native.d.ts +23 -0
- package/dist/lib/native-hardware/serial-native.d.ts.map +1 -0
- package/dist/lib/native-hardware/serial-native.js +181 -0
- package/dist/lib/native-hardware/serial.d.ts +76 -0
- package/dist/lib/native-hardware/serial.d.ts.map +1 -0
- package/dist/lib/native-hardware/serial.js +212 -0
- package/dist/lib/native-hardware/system-audio.d.ts +127 -0
- package/dist/lib/native-hardware/system-audio.d.ts.map +1 -0
- package/dist/lib/native-hardware/system-audio.js +330 -0
- package/dist/lib/native-hardware/types.d.ts +62 -0
- package/dist/lib/native-hardware/types.d.ts.map +1 -0
- package/dist/lib/native-hardware/types.js +27 -0
- package/dist/lib/native-hardware/usb-native.d.ts +39 -0
- package/dist/lib/native-hardware/usb-native.d.ts.map +1 -0
- package/dist/lib/native-hardware/usb-native.js +217 -0
- package/dist/lib/native-hardware/usb.d.ts +85 -0
- package/dist/lib/native-hardware/usb.d.ts.map +1 -0
- package/dist/lib/native-hardware/usb.js +222 -0
- package/docs/README.md +37 -0
- package/docs/accessibility.md +32 -0
- package/docs/app-anatomy.md +72 -0
- package/docs/component-catalog.md +59 -0
- package/docs/component-guide-template.md +37 -0
- package/docs/design-tokens.md +172 -0
- package/docs/foundations.md +56 -0
- package/docs/native-integration.md +33 -0
- package/docs/standalone-app-windows.md +128 -0
- package/package.json +9 -3
- package/src/components/ui/alert.md +55 -0
- package/src/components/ui/app-frame.md +33 -0
- package/src/components/ui/badge.md +57 -0
- package/src/components/ui/button.md +76 -0
- package/src/components/ui/color-well.md +11 -0
- package/src/components/ui/combobox.md +43 -0
- package/src/components/ui/date-field.md +32 -0
- package/src/components/ui/edge-fade.md +7 -0
- package/src/components/ui/empty.md +82 -0
- package/src/components/ui/field.md +77 -0
- package/src/components/ui/grid.md +105 -0
- package/src/components/ui/icon-button.md +36 -0
- package/src/components/ui/inspector.md +11 -0
- package/src/components/ui/item.md +87 -0
- package/src/components/ui/list.md +107 -0
- package/src/components/ui/notification-dot.md +7 -0
- package/src/components/ui/number-input.md +19 -0
- package/src/components/ui/panel.md +11 -0
- package/src/components/ui/resizable.md +66 -0
- package/src/components/ui/scroll-area.md +68 -0
- package/src/components/ui/search-field.md +33 -0
- package/src/components/ui/segmented-control.md +39 -0
- package/src/components/ui/sidebar.md +113 -0
- package/src/components/ui/sonner.md +37 -0
- package/src/components/ui/split-view.md +15 -0
- package/src/components/ui/status.md +12 -0
- package/src/components/ui/table.md +35 -0
- package/src/components/ui/tabs.md +66 -0
- package/src/components/ui/text.md +17 -0
- package/src/components/ui/toggle-group.md +80 -0
- package/src/components/ui/toggle.md +73 -0
- package/src/components/ui/toolbar.md +21 -0
- package/src/styles/index.css +868 -3
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { callNativeHardwareBridge, } from './bridge';
|
|
2
|
+
import { isMoldableMIDISupported, requestMoldableMIDIAccess, } from './midi-access';
|
|
3
|
+
const REQUEST_TYPE = 'moldable:native-midi';
|
|
4
|
+
const RESULT_TYPE = 'moldable:native-midi-result';
|
|
5
|
+
const EVENT_TYPE = 'moldable:native-midi-event';
|
|
6
|
+
const MAX_MESSAGE_BYTES = 16_384;
|
|
7
|
+
function isNativeProbeResult(value) {
|
|
8
|
+
return (typeof value === 'object' &&
|
|
9
|
+
value !== null &&
|
|
10
|
+
value.available === true &&
|
|
11
|
+
Object.keys(value).length === 1);
|
|
12
|
+
}
|
|
13
|
+
function isNativePortResult(value) {
|
|
14
|
+
if (typeof value !== 'object' || value === null)
|
|
15
|
+
return false;
|
|
16
|
+
const port = value;
|
|
17
|
+
return (typeof port.handleId === 'string' &&
|
|
18
|
+
port.handleId.length > 0 &&
|
|
19
|
+
(port.kind === 'input' || port.kind === 'output') &&
|
|
20
|
+
typeof port.name === 'string');
|
|
21
|
+
}
|
|
22
|
+
function bytes(value) {
|
|
23
|
+
const result = Array.from(value);
|
|
24
|
+
if (result.length === 0 ||
|
|
25
|
+
result.length > MAX_MESSAGE_BYTES ||
|
|
26
|
+
result.some((byte) => !Number.isInteger(byte) || byte < 0 || byte > 255)) {
|
|
27
|
+
throw new TypeError('MIDI data must contain 1 to 16384 bytes.');
|
|
28
|
+
}
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
function nativePort(port, options) {
|
|
32
|
+
let closed = false;
|
|
33
|
+
const listeners = new Set();
|
|
34
|
+
const onMessage = (event) => {
|
|
35
|
+
if (event.source !== window.parent ||
|
|
36
|
+
typeof event.data !== 'object' ||
|
|
37
|
+
!event.data)
|
|
38
|
+
return;
|
|
39
|
+
const message = event.data;
|
|
40
|
+
if (message.type !== EVENT_TYPE ||
|
|
41
|
+
typeof message.event !== 'object' ||
|
|
42
|
+
!message.event)
|
|
43
|
+
return;
|
|
44
|
+
const value = message.event;
|
|
45
|
+
if (value.handleId !== port.handleId || !Array.isArray(value.data))
|
|
46
|
+
return;
|
|
47
|
+
const data = value.data;
|
|
48
|
+
if (!data.every((byte) => Number.isInteger(byte) && Number(byte) >= 0 && Number(byte) <= 255))
|
|
49
|
+
return;
|
|
50
|
+
const timestamp = typeof value.timestamp === 'number' ? value.timestamp : 0;
|
|
51
|
+
for (const listener of listeners)
|
|
52
|
+
listener(Uint8Array.from(data), timestamp);
|
|
53
|
+
};
|
|
54
|
+
window.addEventListener('message', onMessage);
|
|
55
|
+
return {
|
|
56
|
+
id: port.handleId,
|
|
57
|
+
kind: port.kind,
|
|
58
|
+
name: port.name,
|
|
59
|
+
get closed() {
|
|
60
|
+
return closed;
|
|
61
|
+
},
|
|
62
|
+
async send(data) {
|
|
63
|
+
if (closed)
|
|
64
|
+
throw new DOMException('The MIDI port is closed.', 'InvalidStateError');
|
|
65
|
+
if (port.kind !== 'output')
|
|
66
|
+
throw new DOMException('Cannot send to a MIDI input.', 'InvalidStateError');
|
|
67
|
+
await callNativeHardwareBridge({
|
|
68
|
+
type: REQUEST_TYPE,
|
|
69
|
+
action: 'send',
|
|
70
|
+
handleId: port.handleId,
|
|
71
|
+
data: bytes(data),
|
|
72
|
+
}, RESULT_TYPE, options);
|
|
73
|
+
},
|
|
74
|
+
observeMessages(listener) {
|
|
75
|
+
if (closed)
|
|
76
|
+
throw new DOMException('The MIDI port is closed.', 'InvalidStateError');
|
|
77
|
+
if (port.kind !== 'input')
|
|
78
|
+
throw new DOMException('Only MIDI inputs receive messages.', 'InvalidStateError');
|
|
79
|
+
listeners.add(listener);
|
|
80
|
+
return () => listeners.delete(listener);
|
|
81
|
+
},
|
|
82
|
+
async close() {
|
|
83
|
+
if (closed)
|
|
84
|
+
return;
|
|
85
|
+
await callNativeHardwareBridge({ type: REQUEST_TYPE, action: 'close', handleId: port.handleId }, RESULT_TYPE, options);
|
|
86
|
+
closed = true;
|
|
87
|
+
listeners.clear();
|
|
88
|
+
window.removeEventListener('message', onMessage);
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Uses Web MIDI when the webview implements it; otherwise returns the scoped
|
|
94
|
+
* desktop fallback. Native port selection always opens the host-owned chooser.
|
|
95
|
+
*/
|
|
96
|
+
export async function requestMoldableMIDIWithFallback(options = {}) {
|
|
97
|
+
if (isMoldableMIDISupported()) {
|
|
98
|
+
return {
|
|
99
|
+
kind: 'web-midi',
|
|
100
|
+
access: await requestMoldableMIDIAccess(options),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
const bridgeOptions = { signal: options.signal };
|
|
104
|
+
const probe = await callNativeHardwareBridge({ type: REQUEST_TYPE, action: 'probe' }, RESULT_TYPE, { timeoutMs: 120_000, ...bridgeOptions });
|
|
105
|
+
if (!isNativeProbeResult(probe)) {
|
|
106
|
+
throw new TypeError('The desktop returned an invalid MIDI capability.');
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
kind: 'desktop-bridge',
|
|
110
|
+
access: {
|
|
111
|
+
async requestPort(kind) {
|
|
112
|
+
const result = await callNativeHardwareBridge({
|
|
113
|
+
type: REQUEST_TYPE,
|
|
114
|
+
action: 'requestPort',
|
|
115
|
+
kind,
|
|
116
|
+
sysex: options.sysex === true,
|
|
117
|
+
}, RESULT_TYPE, { timeoutMs: 120_000, ...bridgeOptions });
|
|
118
|
+
if (!isNativePortResult(result)) {
|
|
119
|
+
throw new TypeError('The desktop returned an invalid MIDI port.');
|
|
120
|
+
}
|
|
121
|
+
// The access request's AbortSignal must not poison later close/send
|
|
122
|
+
// operations and strand a host-owned port after access succeeds.
|
|
123
|
+
return nativePort(result, {});
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { MoldableMIDIConnectionOptions, MoldableMIDIInputConnection, MoldableMIDIOutputConnection } from './midi-types';
|
|
2
|
+
/** Opens one input port and owns its message listener until `close()` or abort. */
|
|
3
|
+
export declare function openMoldableMIDIInput(access: MIDIAccess, inputId: string, listener: (event: MIDIMessageEvent) => void, options?: MoldableMIDIConnectionOptions): Promise<MoldableMIDIInputConnection>;
|
|
4
|
+
/** Opens one output port and validates outbound MIDI bytes before sending. */
|
|
5
|
+
export declare function openMoldableMIDIOutput(access: MIDIAccess, outputId: string, options?: MoldableMIDIConnectionOptions): Promise<MoldableMIDIOutputConnection>;
|
|
6
|
+
//# sourceMappingURL=midi-ports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"midi-ports.d.ts","sourceRoot":"","sources":["../../../src/lib/native-hardware/midi-ports.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,6BAA6B,EAC7B,2BAA2B,EAC3B,4BAA4B,EAC7B,MAAM,cAAc,CAAA;AAErB,mFAAmF;AACnF,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,EAC3C,OAAO,GAAE,6BAAkC,GAC1C,OAAO,CAAC,2BAA2B,CAAC,CAwCtC;AAED,8EAA8E;AAC9E,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,6BAAkC,GAC1C,OAAO,CAAC,4BAA4B,CAAC,CA+EvC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { abortableMIDI, findMIDIPort, midiAborted, midiError, missingMIDIPort, } from './midi-internal';
|
|
2
|
+
/** Opens one input port and owns its message listener until `close()` or abort. */
|
|
3
|
+
export async function openMoldableMIDIInput(access, inputId, listener, options = {}) {
|
|
4
|
+
const input = findMIDIPort(access.inputs, inputId);
|
|
5
|
+
if (!input)
|
|
6
|
+
return missingMIDIPort('input', inputId);
|
|
7
|
+
const operation = `open MIDI input ${inputId}`;
|
|
8
|
+
try {
|
|
9
|
+
await abortableMIDI(input.open(), options.signal, operation, (port) => {
|
|
10
|
+
void port.close();
|
|
11
|
+
});
|
|
12
|
+
if (options.signal?.aborted) {
|
|
13
|
+
await input.close();
|
|
14
|
+
throw midiAborted(operation);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
throw midiError(error, operation);
|
|
19
|
+
}
|
|
20
|
+
let closed = false;
|
|
21
|
+
const close = async () => {
|
|
22
|
+
if (closed)
|
|
23
|
+
return;
|
|
24
|
+
try {
|
|
25
|
+
await input.close();
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
throw midiError(error, `close MIDI input ${inputId}`);
|
|
29
|
+
}
|
|
30
|
+
closed = true;
|
|
31
|
+
input.removeEventListener('midimessage', listener);
|
|
32
|
+
options.signal?.removeEventListener('abort', onAbort);
|
|
33
|
+
};
|
|
34
|
+
const onAbort = () => void close().catch(() => undefined);
|
|
35
|
+
input.addEventListener('midimessage', listener);
|
|
36
|
+
options.signal?.addEventListener('abort', onAbort, { once: true });
|
|
37
|
+
return {
|
|
38
|
+
input,
|
|
39
|
+
get closed() {
|
|
40
|
+
return closed;
|
|
41
|
+
},
|
|
42
|
+
close,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/** Opens one output port and validates outbound MIDI bytes before sending. */
|
|
46
|
+
export async function openMoldableMIDIOutput(access, outputId, options = {}) {
|
|
47
|
+
const output = findMIDIPort(access.outputs, outputId);
|
|
48
|
+
if (!output)
|
|
49
|
+
return missingMIDIPort('output', outputId);
|
|
50
|
+
const operation = `open MIDI output ${outputId}`;
|
|
51
|
+
try {
|
|
52
|
+
await abortableMIDI(output.open(), options.signal, operation, (port) => {
|
|
53
|
+
void port.close();
|
|
54
|
+
});
|
|
55
|
+
if (options.signal?.aborted) {
|
|
56
|
+
await output.close();
|
|
57
|
+
throw midiAborted(operation);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
throw midiError(error, operation);
|
|
62
|
+
}
|
|
63
|
+
let closed = false;
|
|
64
|
+
const close = async () => {
|
|
65
|
+
if (closed)
|
|
66
|
+
return;
|
|
67
|
+
try {
|
|
68
|
+
;
|
|
69
|
+
output.clear?.call(output);
|
|
70
|
+
await output.close();
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
throw midiError(error, `close MIDI output ${outputId}`);
|
|
74
|
+
}
|
|
75
|
+
closed = true;
|
|
76
|
+
options.signal?.removeEventListener('abort', onAbort);
|
|
77
|
+
};
|
|
78
|
+
const onAbort = () => void close().catch(() => undefined);
|
|
79
|
+
options.signal?.addEventListener('abort', onAbort, { once: true });
|
|
80
|
+
return {
|
|
81
|
+
output,
|
|
82
|
+
get closed() {
|
|
83
|
+
return closed;
|
|
84
|
+
},
|
|
85
|
+
send(data, timestamp) {
|
|
86
|
+
if (closed) {
|
|
87
|
+
throw midiError(new DOMException('MIDI output is closed', 'InvalidStateError'), `send to MIDI output ${outputId}`);
|
|
88
|
+
}
|
|
89
|
+
const bytes = Array.from(data);
|
|
90
|
+
if (bytes.length === 0 ||
|
|
91
|
+
bytes.some((byte) => !Number.isInteger(byte) || byte < 0 || byte > 255)) {
|
|
92
|
+
throw midiError(new TypeError('MIDI data must contain bytes between 0 and 255'), `send to MIDI output ${outputId}`);
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
output.send(bytes, timestamp);
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
throw midiError(error, `send to MIDI output ${outputId}`);
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
clear() {
|
|
102
|
+
const clear = output.clear;
|
|
103
|
+
if (!clear) {
|
|
104
|
+
throw midiError(new DOMException('Clearing MIDI output is unavailable', 'NotSupportedError'), `clear MIDI output ${outputId}`);
|
|
105
|
+
}
|
|
106
|
+
try {
|
|
107
|
+
clear.call(output);
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
throw midiError(error, `clear MIDI output ${outputId}`);
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
close,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface MoldableMIDIAccessOptions {
|
|
2
|
+
/**
|
|
3
|
+
* System Exclusive access is sensitive and is never enabled implicitly.
|
|
4
|
+
* Callers must set this to `true` from a user-initiated action.
|
|
5
|
+
*/
|
|
6
|
+
sysex?: boolean;
|
|
7
|
+
software?: boolean;
|
|
8
|
+
signal?: AbortSignal;
|
|
9
|
+
}
|
|
10
|
+
export interface MoldableMIDIConnectionOptions {
|
|
11
|
+
signal?: AbortSignal;
|
|
12
|
+
}
|
|
13
|
+
export interface MoldableMIDIInputConnection {
|
|
14
|
+
readonly input: MIDIInput;
|
|
15
|
+
readonly closed: boolean;
|
|
16
|
+
close(): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export interface MoldableMIDIOutputConnection {
|
|
19
|
+
readonly output: MIDIOutput;
|
|
20
|
+
readonly closed: boolean;
|
|
21
|
+
send(data: Iterable<number>, timestamp?: DOMHighResTimeStamp): void;
|
|
22
|
+
clear(): void;
|
|
23
|
+
close(): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=midi-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"midi-types.d.ts","sourceRoot":"","sources":["../../../src/lib/native-hardware/midi-types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,yBAAyB;IACxC;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB;AAED,MAAM,WAAW,6BAA6B;IAC5C,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB;AAED,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;IACxB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACvB;AAED,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAA;IAC3B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;IACxB,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,EAAE,mBAAmB,GAAG,IAAI,CAAA;IACnE,KAAK,IAAI,IAAI,CAAA;IACb,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { getMoldableMIDIInputs, getMoldableMIDIOutputs, isMoldableMIDISupported, observeMoldableMIDIState, requestMoldableMIDIAccess, } from './midi-access';
|
|
2
|
+
export { openMoldableMIDIInput, openMoldableMIDIOutput } from './midi-ports';
|
|
3
|
+
export { requestMoldableMIDIWithFallback } from './midi-native-fallback';
|
|
4
|
+
export type { MoldableMIDITransport, MoldableNativeMIDIAccess, MoldableNativeMIDIPort, } from './midi-native-fallback';
|
|
5
|
+
export type { MoldableMIDIAccessOptions, MoldableMIDIConnectionOptions, MoldableMIDIInputConnection, MoldableMIDIOutputConnection, } from './midi-types';
|
|
6
|
+
//# sourceMappingURL=midi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"midi.d.ts","sourceRoot":"","sources":["../../../src/lib/native-hardware/midi.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;AAC5E,OAAO,EAAE,+BAA+B,EAAE,MAAM,wBAAwB,CAAA;AACxE,YAAY,EACV,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,wBAAwB,CAAA;AAC/B,YAAY,EACV,yBAAyB,EACzB,6BAA6B,EAC7B,2BAA2B,EAC3B,4BAA4B,GAC7B,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { getMoldableMIDIInputs, getMoldableMIDIOutputs, isMoldableMIDISupported, observeMoldableMIDIState, requestMoldableMIDIAccess, } from './midi-access';
|
|
2
|
+
export { openMoldableMIDIInput, openMoldableMIDIOutput } from './midi-ports';
|
|
3
|
+
export { requestMoldableMIDIWithFallback } from './midi-native-fallback';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type NativeHardwareBridgeOptions } from './bridge';
|
|
2
|
+
export type MoldableNativeDeviceKind = 'usb' | 'hid' | 'serial';
|
|
3
|
+
export interface MoldableNativeDeviceDescriptor {
|
|
4
|
+
selector: string;
|
|
5
|
+
kind: MoldableNativeDeviceKind;
|
|
6
|
+
label: string;
|
|
7
|
+
vendorId?: number;
|
|
8
|
+
productId?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface MoldableNativeDeviceHandle {
|
|
11
|
+
handle: string;
|
|
12
|
+
kind: MoldableNativeDeviceKind;
|
|
13
|
+
}
|
|
14
|
+
export interface MoldableNativeDeviceFilter {
|
|
15
|
+
vendorId?: number;
|
|
16
|
+
productId?: number;
|
|
17
|
+
}
|
|
18
|
+
export interface MoldableNativeDeviceListOptions extends NativeHardwareBridgeOptions {
|
|
19
|
+
filters?: readonly MoldableNativeDeviceFilter[];
|
|
20
|
+
exclusionFilters?: readonly MoldableNativeDeviceFilter[];
|
|
21
|
+
}
|
|
22
|
+
export declare function listMoldableNativeDevices(kind: MoldableNativeDeviceKind, options?: MoldableNativeDeviceListOptions): Promise<MoldableNativeDeviceDescriptor[]>;
|
|
23
|
+
export declare function openMoldableNativeDevice(kind: MoldableNativeDeviceKind, selector: string, deviceOptions: Record<string, unknown>, options?: NativeHardwareBridgeOptions): Promise<MoldableNativeDeviceHandle>;
|
|
24
|
+
export declare function executeMoldableNativeDeviceOperation(kind: MoldableNativeDeviceKind, handle: string, operation: Record<string, unknown>, options?: NativeHardwareBridgeOptions): Promise<Record<string, unknown>>;
|
|
25
|
+
export declare function closeMoldableNativeDevice(kind: MoldableNativeDeviceKind, handle: string, options?: NativeHardwareBridgeOptions): Promise<void>;
|
|
26
|
+
export declare function bytesFromNativeDeviceResult(result: Record<string, unknown>): Uint8Array;
|
|
27
|
+
export declare function bytesWrittenFromNativeDeviceResult(result: Record<string, unknown>): number;
|
|
28
|
+
//# sourceMappingURL=native-device-io.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-device-io.d.ts","sourceRoot":"","sources":["../../../src/lib/native-hardware/native-device-io.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,2BAA2B,EAEjC,MAAM,UAAU,CAAA;AAOjB,MAAM,MAAM,wBAAwB,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,CAAA;AAE/D,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,wBAAwB,CAAA;IAC9B,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,0BAA0B;IACzC,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,wBAAwB,CAAA;CAC/B;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,+BACf,SAAQ,2BAA2B;IACnC,OAAO,CAAC,EAAE,SAAS,0BAA0B,EAAE,CAAA;IAC/C,gBAAgB,CAAC,EAAE,SAAS,0BAA0B,EAAE,CAAA;CACzD;AAkCD,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,wBAAwB,EAC9B,OAAO,GAAE,+BAAoC,GAC5C,OAAO,CAAC,8BAA8B,EAAE,CAAC,CAsB3C;AAED,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,wBAAwB,EAC9B,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACtC,OAAO,GAAE,2BAAgC,GACxC,OAAO,CAAC,0BAA0B,CAAC,CAwBrC;AAED,wBAAsB,oCAAoC,CACxD,IAAI,EAAE,wBAAwB,EAC9B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,OAAO,GAAE,2BAAgC,GACxC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAalC;AAED,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,wBAAwB,EAC9B,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,2BAAgC,GACxC,OAAO,CAAC,IAAI,CAAC,CAMf;AAED,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,UAAU,CAYZ;AAED,wBAAgB,kCAAkC,CAChD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,MAAM,CAUR"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { NativeHardwareBridgeError, callNativeHardwareBridge, } from './bridge';
|
|
2
|
+
const REQUEST_TYPE = 'moldable:native-device-io-request';
|
|
3
|
+
const RESULT_TYPE = 'moldable:native-device-io-result';
|
|
4
|
+
const OPAQUE_ID_PATTERN = /^(selector|device)-[a-f0-9]{36}$/;
|
|
5
|
+
const MAX_TRANSFER_BYTES = 65_536;
|
|
6
|
+
function isRecord(value) {
|
|
7
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
8
|
+
}
|
|
9
|
+
function invalidResponse(message, details) {
|
|
10
|
+
throw new NativeHardwareBridgeError({
|
|
11
|
+
code: 'invalid_response',
|
|
12
|
+
message,
|
|
13
|
+
details,
|
|
14
|
+
retryable: false,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function isDescriptor(value) {
|
|
18
|
+
return (isRecord(value) &&
|
|
19
|
+
typeof value.selector === 'string' &&
|
|
20
|
+
OPAQUE_ID_PATTERN.test(value.selector) &&
|
|
21
|
+
(value.kind === 'usb' || value.kind === 'hid' || value.kind === 'serial') &&
|
|
22
|
+
typeof value.label === 'string' &&
|
|
23
|
+
value.label.length <= 120 &&
|
|
24
|
+
(value.vendorId === undefined ||
|
|
25
|
+
(Number.isInteger(value.vendorId) &&
|
|
26
|
+
Number(value.vendorId) >= 0 &&
|
|
27
|
+
Number(value.vendorId) <= 0xffff)) &&
|
|
28
|
+
(value.productId === undefined ||
|
|
29
|
+
(Number.isInteger(value.productId) &&
|
|
30
|
+
Number(value.productId) >= 0 &&
|
|
31
|
+
Number(value.productId) <= 0xffff)));
|
|
32
|
+
}
|
|
33
|
+
export async function listMoldableNativeDevices(kind, options = {}) {
|
|
34
|
+
const { filters, exclusionFilters, ...bridgeOptions } = options;
|
|
35
|
+
const result = await callNativeHardwareBridge({
|
|
36
|
+
type: REQUEST_TYPE,
|
|
37
|
+
action: 'list',
|
|
38
|
+
kind,
|
|
39
|
+
...(filters ? { filters: [...filters] } : {}),
|
|
40
|
+
...(exclusionFilters ? { exclusionFilters: [...exclusionFilters] } : {}),
|
|
41
|
+
}, RESULT_TYPE, { timeoutMs: 120_000, ...bridgeOptions });
|
|
42
|
+
if (!Array.isArray(result) ||
|
|
43
|
+
!result.every((descriptor) => isDescriptor(descriptor) && descriptor.kind === kind)) {
|
|
44
|
+
invalidResponse('Moldable returned an invalid native device list.', result);
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
export async function openMoldableNativeDevice(kind, selector, deviceOptions, options = {}) {
|
|
49
|
+
const result = await callNativeHardwareBridge({
|
|
50
|
+
type: REQUEST_TYPE,
|
|
51
|
+
action: 'open',
|
|
52
|
+
kind,
|
|
53
|
+
selector,
|
|
54
|
+
options: deviceOptions,
|
|
55
|
+
}, RESULT_TYPE, { timeoutMs: 120_000, ...options });
|
|
56
|
+
if (!isRecord(result) ||
|
|
57
|
+
typeof result.handle !== 'string' ||
|
|
58
|
+
!OPAQUE_ID_PATTERN.test(result.handle) ||
|
|
59
|
+
(result.kind !== 'usb' && result.kind !== 'hid' && result.kind !== 'serial')) {
|
|
60
|
+
invalidResponse('Moldable returned an invalid native device handle.', result);
|
|
61
|
+
}
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
export async function executeMoldableNativeDeviceOperation(kind, handle, operation, options = {}) {
|
|
65
|
+
const result = await callNativeHardwareBridge({ type: REQUEST_TYPE, action: 'execute', kind, handle, operation }, RESULT_TYPE, { timeoutMs: 35_000, ...options });
|
|
66
|
+
if (!isRecord(result)) {
|
|
67
|
+
invalidResponse('Moldable returned an invalid native device result.', result);
|
|
68
|
+
}
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
export async function closeMoldableNativeDevice(kind, handle, options = {}) {
|
|
72
|
+
await callNativeHardwareBridge({ type: REQUEST_TYPE, action: 'close', kind, handle }, RESULT_TYPE, options);
|
|
73
|
+
}
|
|
74
|
+
export function bytesFromNativeDeviceResult(result) {
|
|
75
|
+
if (result.kind !== 'data' ||
|
|
76
|
+
!Array.isArray(result.data) ||
|
|
77
|
+
result.data.length > MAX_TRANSFER_BYTES ||
|
|
78
|
+
!result.data.every((value) => Number.isInteger(value) && value >= 0 && value <= 255)) {
|
|
79
|
+
invalidResponse('Moldable returned invalid device bytes.', result);
|
|
80
|
+
}
|
|
81
|
+
return Uint8Array.from(result.data);
|
|
82
|
+
}
|
|
83
|
+
export function bytesWrittenFromNativeDeviceResult(result) {
|
|
84
|
+
if (result.kind !== 'written' ||
|
|
85
|
+
!Number.isInteger(result.bytesWritten) ||
|
|
86
|
+
Number(result.bytesWritten) < 0 ||
|
|
87
|
+
Number(result.bytesWritten) > MAX_TRANSFER_BYTES) {
|
|
88
|
+
invalidResponse('Moldable returned an invalid device write result.', result);
|
|
89
|
+
}
|
|
90
|
+
return Number(result.bytesWritten);
|
|
91
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class NativeDeviceLifecycle {
|
|
2
|
+
private open;
|
|
3
|
+
private attached;
|
|
4
|
+
private disconnectDispatched;
|
|
5
|
+
get opened(): boolean;
|
|
6
|
+
get connected(): boolean;
|
|
7
|
+
get disconnected(): boolean;
|
|
8
|
+
didOpen(): void;
|
|
9
|
+
didClose(): void;
|
|
10
|
+
didDisconnect(target: EventTarget, error: unknown): void;
|
|
11
|
+
}
|
|
12
|
+
export declare function isNativeDeviceDisconnect(error: unknown): boolean;
|
|
13
|
+
//# sourceMappingURL=native-device-lifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-device-lifecycle.d.ts","sourceRoot":"","sources":["../../../src/lib/native-hardware/native-device-lifecycle.ts"],"names":[],"mappings":"AAEA,qBAAa,qBAAqB;IAChC,OAAO,CAAC,IAAI,CAAQ;IACpB,OAAO,CAAC,QAAQ,CAAO;IACvB,OAAO,CAAC,oBAAoB,CAAQ;IAEpC,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,IAAI,YAAY,IAAI,OAAO,CAE1B;IAED,OAAO,IAAI,IAAI;IAMf,QAAQ,IAAI,IAAI;IAIhB,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;CASzD;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAMhE"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { NativeHardwareBridgeError } from './bridge';
|
|
2
|
+
export class NativeDeviceLifecycle {
|
|
3
|
+
open = false;
|
|
4
|
+
attached = true;
|
|
5
|
+
disconnectDispatched = false;
|
|
6
|
+
get opened() {
|
|
7
|
+
return this.open;
|
|
8
|
+
}
|
|
9
|
+
get connected() {
|
|
10
|
+
return this.attached;
|
|
11
|
+
}
|
|
12
|
+
get disconnected() {
|
|
13
|
+
return !this.attached;
|
|
14
|
+
}
|
|
15
|
+
didOpen() {
|
|
16
|
+
this.open = true;
|
|
17
|
+
this.attached = true;
|
|
18
|
+
this.disconnectDispatched = false;
|
|
19
|
+
}
|
|
20
|
+
didClose() {
|
|
21
|
+
this.open = false;
|
|
22
|
+
}
|
|
23
|
+
didDisconnect(target, error) {
|
|
24
|
+
this.open = false;
|
|
25
|
+
this.attached = false;
|
|
26
|
+
if (this.disconnectDispatched)
|
|
27
|
+
return;
|
|
28
|
+
this.disconnectDispatched = true;
|
|
29
|
+
const event = new Event('disconnect');
|
|
30
|
+
Object.defineProperty(event, 'error', { value: error });
|
|
31
|
+
target.dispatchEvent(event);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export function isNativeDeviceDisconnect(error) {
|
|
35
|
+
if (!(error instanceof NativeHardwareBridgeError))
|
|
36
|
+
return false;
|
|
37
|
+
if (error.code !== 'unavailable')
|
|
38
|
+
return false;
|
|
39
|
+
return /\b(disconnected|no longer available|not connected)\b/i.test(error.message);
|
|
40
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type NativeHardwareBridgeOptions } from './bridge';
|
|
2
|
+
import type { NativeHardwareRequestEnvelope, NativeHardwareResultEnvelope } from './types';
|
|
3
|
+
export declare const NATIVE_NOTIFICATION_REQUEST_TYPE: "moldable:native-notifications";
|
|
4
|
+
export declare const NATIVE_NOTIFICATION_RESULT_TYPE: "moldable:native-notifications-result";
|
|
5
|
+
export declare const NATIVE_NOTIFICATION_MAX_TITLE_LENGTH = 256;
|
|
6
|
+
export declare const NATIVE_NOTIFICATION_MAX_BODY_LENGTH = 4096;
|
|
7
|
+
export declare const NATIVE_NOTIFICATION_MAX_TAG_LENGTH = 128;
|
|
8
|
+
export type MoldableNotificationPermission = 'granted' | 'denied' | 'prompt';
|
|
9
|
+
export interface MoldableNotificationOptions {
|
|
10
|
+
title: string;
|
|
11
|
+
body?: string;
|
|
12
|
+
tag?: string;
|
|
13
|
+
silent?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface MoldableNotificationPermissionResult {
|
|
16
|
+
permission: MoldableNotificationPermission;
|
|
17
|
+
}
|
|
18
|
+
export interface MoldableNotificationSendResult {
|
|
19
|
+
sent: true;
|
|
20
|
+
}
|
|
21
|
+
export type NativeNotificationAction = 'getPermission' | 'requestPermission' | 'send';
|
|
22
|
+
export type NativeNotificationRequest = NativeHardwareRequestEnvelope<typeof NATIVE_NOTIFICATION_REQUEST_TYPE, {
|
|
23
|
+
capability: 'notifications';
|
|
24
|
+
action: 'getPermission';
|
|
25
|
+
} | {
|
|
26
|
+
capability: 'notifications';
|
|
27
|
+
action: 'requestPermission';
|
|
28
|
+
} | {
|
|
29
|
+
capability: 'notifications';
|
|
30
|
+
action: 'send';
|
|
31
|
+
notification: MoldableNotificationOptions;
|
|
32
|
+
}>;
|
|
33
|
+
export type NativeNotificationResult = NativeHardwareResultEnvelope<typeof NATIVE_NOTIFICATION_RESULT_TYPE, MoldableNotificationPermissionResult | MoldableNotificationSendResult>;
|
|
34
|
+
export declare function isMoldableNotificationOptions(value: unknown): value is MoldableNotificationOptions;
|
|
35
|
+
export declare function getMoldableNotificationPermission(options?: NativeHardwareBridgeOptions): Promise<MoldableNotificationPermissionResult>;
|
|
36
|
+
export declare function requestMoldableNotificationPermission(options?: NativeHardwareBridgeOptions): Promise<MoldableNotificationPermissionResult>;
|
|
37
|
+
export declare function sendMoldableNotification(notification: MoldableNotificationOptions, options?: NativeHardwareBridgeOptions): Promise<MoldableNotificationSendResult>;
|
|
38
|
+
//# sourceMappingURL=notifications.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications.d.ts","sourceRoot":"","sources":["../../../src/lib/native-hardware/notifications.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,2BAA2B,EAEjC,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EACV,6BAA6B,EAC7B,4BAA4B,EAC7B,MAAM,SAAS,CAAA;AAEhB,eAAO,MAAM,gCAAgC,EAC3C,+BAAwC,CAAA;AAC1C,eAAO,MAAM,+BAA+B,EAC1C,sCAA+C,CAAA;AAEjD,eAAO,MAAM,oCAAoC,MAAM,CAAA;AACvD,eAAO,MAAM,mCAAmC,OAAQ,CAAA;AACxD,eAAO,MAAM,kCAAkC,MAAM,CAAA;AAErD,MAAM,MAAM,8BAA8B,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAE5E,MAAM,WAAW,2BAA2B;IAC1C,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAED,MAAM,WAAW,oCAAoC;IACnD,UAAU,EAAE,8BAA8B,CAAA;CAC3C;AAED,MAAM,WAAW,8BAA8B;IAC7C,IAAI,EAAE,IAAI,CAAA;CACX;AAED,MAAM,MAAM,wBAAwB,GAChC,eAAe,GACf,mBAAmB,GACnB,MAAM,CAAA;AAEV,MAAM,MAAM,yBAAyB,GAAG,6BAA6B,CACnE,OAAO,gCAAgC,EACrC;IACE,UAAU,EAAE,eAAe,CAAA;IAC3B,MAAM,EAAE,eAAe,CAAA;CACxB,GACD;IACE,UAAU,EAAE,eAAe,CAAA;IAC3B,MAAM,EAAE,mBAAmB,CAAA;CAC5B,GACD;IACE,UAAU,EAAE,eAAe,CAAA;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,2BAA2B,CAAA;CAC1C,CACJ,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG,4BAA4B,CACjE,OAAO,+BAA+B,EACtC,oCAAoC,GAAG,8BAA8B,CACtE,CAAA;AAED,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,2BAA2B,CA+BtC;AAED,wBAAgB,iCAAiC,CAC/C,OAAO,GAAE,2BAAgC,GACxC,OAAO,CAAC,oCAAoC,CAAC,CAU/C;AAED,wBAAgB,qCAAqC,CACnD,OAAO,GAAE,2BAAgC,GACxC,OAAO,CAAC,oCAAoC,CAAC,CAU/C;AAED,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,2BAA2B,EACzC,OAAO,GAAE,2BAAgC,GACxC,OAAO,CAAC,8BAA8B,CAAC,CAWzC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { callNativeHardwareBridge, } from './bridge';
|
|
2
|
+
export const NATIVE_NOTIFICATION_REQUEST_TYPE = 'moldable:native-notifications';
|
|
3
|
+
export const NATIVE_NOTIFICATION_RESULT_TYPE = 'moldable:native-notifications-result';
|
|
4
|
+
export const NATIVE_NOTIFICATION_MAX_TITLE_LENGTH = 256;
|
|
5
|
+
export const NATIVE_NOTIFICATION_MAX_BODY_LENGTH = 4_096;
|
|
6
|
+
export const NATIVE_NOTIFICATION_MAX_TAG_LENGTH = 128;
|
|
7
|
+
export function isMoldableNotificationOptions(value) {
|
|
8
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
9
|
+
return false;
|
|
10
|
+
const notification = value;
|
|
11
|
+
const { title, body, tag, silent } = notification;
|
|
12
|
+
if (typeof title !== 'string' ||
|
|
13
|
+
title.trim().length === 0 ||
|
|
14
|
+
title.length > NATIVE_NOTIFICATION_MAX_TITLE_LENGTH) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
if ((body !== undefined && typeof body !== 'string') ||
|
|
18
|
+
(typeof body === 'string' &&
|
|
19
|
+
body.length > NATIVE_NOTIFICATION_MAX_BODY_LENGTH)) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
if ((tag !== undefined &&
|
|
23
|
+
(typeof tag !== 'string' || tag.trim().length === 0)) ||
|
|
24
|
+
(typeof tag === 'string' && tag.length > NATIVE_NOTIFICATION_MAX_TAG_LENGTH)) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
return silent === undefined || typeof silent === 'boolean';
|
|
28
|
+
}
|
|
29
|
+
export function getMoldableNotificationPermission(options = {}) {
|
|
30
|
+
return callNativeHardwareBridge({
|
|
31
|
+
type: NATIVE_NOTIFICATION_REQUEST_TYPE,
|
|
32
|
+
capability: 'notifications',
|
|
33
|
+
action: 'getPermission',
|
|
34
|
+
}, NATIVE_NOTIFICATION_RESULT_TYPE, options);
|
|
35
|
+
}
|
|
36
|
+
export function requestMoldableNotificationPermission(options = {}) {
|
|
37
|
+
return callNativeHardwareBridge({
|
|
38
|
+
type: NATIVE_NOTIFICATION_REQUEST_TYPE,
|
|
39
|
+
capability: 'notifications',
|
|
40
|
+
action: 'requestPermission',
|
|
41
|
+
}, NATIVE_NOTIFICATION_RESULT_TYPE, options);
|
|
42
|
+
}
|
|
43
|
+
export function sendMoldableNotification(notification, options = {}) {
|
|
44
|
+
return callNativeHardwareBridge({
|
|
45
|
+
type: NATIVE_NOTIFICATION_REQUEST_TYPE,
|
|
46
|
+
capability: 'notifications',
|
|
47
|
+
action: 'send',
|
|
48
|
+
notification,
|
|
49
|
+
}, NATIVE_NOTIFICATION_RESULT_TYPE, options);
|
|
50
|
+
}
|