@moldable-ai/ui 0.2.18 → 0.2.19
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/components/chat/chat-panel.d.ts +18 -12
- package/dist/components/chat/chat-panel.d.ts.map +1 -1
- package/dist/components/chat/chat-panel.js +73 -19
- package/dist/components/chat/index.d.ts +2 -1
- package/dist/components/chat/index.d.ts.map +1 -1
- package/dist/components/chat/index.js +2 -1
- 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/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/ui/input-group.d.ts +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/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -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/package.json +1 -1
- package/src/styles/index.css +377 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { NativeHardwareBridgeError } from './bridge';
|
|
2
|
+
import { bytesFromNativeDeviceResult, bytesWrittenFromNativeDeviceResult, closeMoldableNativeDevice, executeMoldableNativeDeviceOperation, openMoldableNativeDevice, } from './native-device-io';
|
|
3
|
+
import { NativeDeviceLifecycle, isNativeDeviceDisconnect, } from './native-device-lifecycle';
|
|
4
|
+
export class NativeMoldableHidDevice extends EventTarget {
|
|
5
|
+
descriptor;
|
|
6
|
+
vendorId;
|
|
7
|
+
productId;
|
|
8
|
+
productName;
|
|
9
|
+
handle;
|
|
10
|
+
closing;
|
|
11
|
+
inputPump;
|
|
12
|
+
lifecycle = new NativeDeviceLifecycle();
|
|
13
|
+
constructor(descriptor) {
|
|
14
|
+
super();
|
|
15
|
+
this.descriptor = descriptor;
|
|
16
|
+
this.vendorId = descriptor.vendorId ?? 0;
|
|
17
|
+
this.productId = descriptor.productId ?? 0;
|
|
18
|
+
this.productName = descriptor.label;
|
|
19
|
+
}
|
|
20
|
+
get opened() {
|
|
21
|
+
return this.lifecycle.opened;
|
|
22
|
+
}
|
|
23
|
+
async open() {
|
|
24
|
+
if (this.closing)
|
|
25
|
+
await this.closing;
|
|
26
|
+
if (this.handle && this.lifecycle.disconnected)
|
|
27
|
+
await this.close();
|
|
28
|
+
if (this.opened)
|
|
29
|
+
return;
|
|
30
|
+
const result = await openMoldableNativeDevice('hid', this.descriptor.selector, {});
|
|
31
|
+
if (result.kind !== 'hid')
|
|
32
|
+
throw new Error('Native device kind mismatch.');
|
|
33
|
+
this.handle = result.handle;
|
|
34
|
+
this.lifecycle.didOpen();
|
|
35
|
+
this.startInputPump();
|
|
36
|
+
}
|
|
37
|
+
async close() {
|
|
38
|
+
if (this.closing)
|
|
39
|
+
return this.closing;
|
|
40
|
+
if (!this.handle)
|
|
41
|
+
return;
|
|
42
|
+
const handle = this.handle;
|
|
43
|
+
this.inputPump?.abort();
|
|
44
|
+
this.inputPump = undefined;
|
|
45
|
+
const closing = closeMoldableNativeDevice('hid', handle)
|
|
46
|
+
.then(() => {
|
|
47
|
+
if (this.handle === handle) {
|
|
48
|
+
this.handle = undefined;
|
|
49
|
+
this.lifecycle.didClose();
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
.catch((error) => {
|
|
53
|
+
if (this.handle === handle && !this.lifecycle.disconnected) {
|
|
54
|
+
this.startInputPump();
|
|
55
|
+
}
|
|
56
|
+
throw error;
|
|
57
|
+
})
|
|
58
|
+
.finally(() => {
|
|
59
|
+
if (this.closing === closing)
|
|
60
|
+
this.closing = undefined;
|
|
61
|
+
});
|
|
62
|
+
this.closing = closing;
|
|
63
|
+
return closing;
|
|
64
|
+
}
|
|
65
|
+
async forget() {
|
|
66
|
+
await this.close();
|
|
67
|
+
}
|
|
68
|
+
async sendReport(reportId, data) {
|
|
69
|
+
assertReportId(reportId);
|
|
70
|
+
const payload = asBytes(data);
|
|
71
|
+
const bytes = new Uint8Array(payload.byteLength + 1);
|
|
72
|
+
bytes[0] = reportId;
|
|
73
|
+
bytes.set(payload, 1);
|
|
74
|
+
const result = await this.execute({
|
|
75
|
+
action: 'write',
|
|
76
|
+
endpoint: null,
|
|
77
|
+
data: [...bytes],
|
|
78
|
+
timeoutMs: 10_000,
|
|
79
|
+
bulk: false,
|
|
80
|
+
});
|
|
81
|
+
if (bytesWrittenFromNativeDeviceResult(result) !== bytes.byteLength) {
|
|
82
|
+
throw new NativeHardwareBridgeError({
|
|
83
|
+
code: 'host_error',
|
|
84
|
+
message: 'The HID device accepted only part of the output report.',
|
|
85
|
+
retryable: true,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async sendFeatureReport(reportId, data) {
|
|
90
|
+
assertReportId(reportId);
|
|
91
|
+
await this.execute({
|
|
92
|
+
action: 'hidSendFeature',
|
|
93
|
+
reportId,
|
|
94
|
+
data: [...asBytes(data)],
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
async receiveFeatureReport(reportId) {
|
|
98
|
+
assertReportId(reportId);
|
|
99
|
+
const result = await this.execute({
|
|
100
|
+
action: 'hidReceiveFeature',
|
|
101
|
+
reportId,
|
|
102
|
+
length: 4096,
|
|
103
|
+
});
|
|
104
|
+
const bytes = bytesFromNativeDeviceResult(result);
|
|
105
|
+
return new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
106
|
+
}
|
|
107
|
+
listen(listener, signal) {
|
|
108
|
+
if (signal?.aborted)
|
|
109
|
+
return () => undefined;
|
|
110
|
+
let active = true;
|
|
111
|
+
const handleReport = (event) => {
|
|
112
|
+
listener(event);
|
|
113
|
+
};
|
|
114
|
+
const stop = () => {
|
|
115
|
+
if (!active)
|
|
116
|
+
return;
|
|
117
|
+
active = false;
|
|
118
|
+
this.removeEventListener('inputreport', handleReport);
|
|
119
|
+
signal?.removeEventListener('abort', stop);
|
|
120
|
+
};
|
|
121
|
+
this.addEventListener('inputreport', handleReport);
|
|
122
|
+
signal?.addEventListener('abort', stop, { once: true });
|
|
123
|
+
return stop;
|
|
124
|
+
}
|
|
125
|
+
startInputPump() {
|
|
126
|
+
if (!this.handle || this.inputPump || this.lifecycle.disconnected)
|
|
127
|
+
return;
|
|
128
|
+
const controller = new AbortController();
|
|
129
|
+
this.inputPump = controller;
|
|
130
|
+
void this.readLoop(controller.signal).finally(() => {
|
|
131
|
+
if (this.inputPump === controller)
|
|
132
|
+
this.inputPump = undefined;
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
async readLoop(signal) {
|
|
136
|
+
while (!signal.aborted && this.handle) {
|
|
137
|
+
try {
|
|
138
|
+
const result = await this.execute({
|
|
139
|
+
action: 'hidReadInput',
|
|
140
|
+
length: 4096,
|
|
141
|
+
timeoutMs: 500,
|
|
142
|
+
}, signal);
|
|
143
|
+
if (result.kind !== 'hidInput' ||
|
|
144
|
+
!Number.isInteger(result.reportId) ||
|
|
145
|
+
Number(result.reportId) < 0 ||
|
|
146
|
+
Number(result.reportId) > 255) {
|
|
147
|
+
throw new NativeHardwareBridgeError({
|
|
148
|
+
code: 'invalid_response',
|
|
149
|
+
message: 'Moldable returned an invalid HID input report.',
|
|
150
|
+
details: result,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
const bytes = bytesFromNativeDeviceResult({
|
|
154
|
+
kind: 'data',
|
|
155
|
+
data: result.data,
|
|
156
|
+
});
|
|
157
|
+
if (bytes.length === 0)
|
|
158
|
+
continue;
|
|
159
|
+
const event = new Event('inputreport');
|
|
160
|
+
Object.defineProperties(event, {
|
|
161
|
+
device: { value: this },
|
|
162
|
+
reportId: { value: Number(result.reportId) },
|
|
163
|
+
data: {
|
|
164
|
+
value: new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength),
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
this.dispatchEvent(event);
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
if (signal.aborted || !this.handle)
|
|
171
|
+
return;
|
|
172
|
+
if (error instanceof NativeHardwareBridgeError &&
|
|
173
|
+
error.code === 'timeout') {
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
if (isNativeDeviceDisconnect(error)) {
|
|
177
|
+
this.lifecycle.didDisconnect(this, error);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
const event = new Event('error');
|
|
181
|
+
Object.defineProperty(event, 'error', { value: error });
|
|
182
|
+
this.dispatchEvent(event);
|
|
183
|
+
}
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
async execute(operation, signal) {
|
|
189
|
+
if (!this.handle) {
|
|
190
|
+
throw new NativeHardwareBridgeError({
|
|
191
|
+
code: 'invalid_request',
|
|
192
|
+
message: 'HID device is not open.',
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
if (this.lifecycle.disconnected) {
|
|
196
|
+
throw new NativeHardwareBridgeError({
|
|
197
|
+
code: 'unavailable',
|
|
198
|
+
message: 'HID device is disconnected.',
|
|
199
|
+
retryable: true,
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
try {
|
|
203
|
+
return await executeMoldableNativeDeviceOperation('hid', this.handle, operation, { signal });
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
if (isNativeDeviceDisconnect(error)) {
|
|
207
|
+
this.lifecycle.didDisconnect(this, error);
|
|
208
|
+
}
|
|
209
|
+
throw error;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
export function isNativeMoldableHidDevice(device) {
|
|
214
|
+
return device instanceof NativeMoldableHidDevice;
|
|
215
|
+
}
|
|
216
|
+
function asBytes(data) {
|
|
217
|
+
return data instanceof ArrayBuffer
|
|
218
|
+
? new Uint8Array(data)
|
|
219
|
+
: new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
220
|
+
}
|
|
221
|
+
function assertReportId(reportId) {
|
|
222
|
+
if (!Number.isInteger(reportId) || reportId < 0 || reportId > 0xff) {
|
|
223
|
+
throw new NativeHardwareBridgeError({
|
|
224
|
+
code: 'invalid_request',
|
|
225
|
+
message: 'HID reportId must be an integer between 0 and 255.',
|
|
226
|
+
retryable: false,
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export interface MoldableHidOperationOptions {
|
|
2
|
+
signal?: AbortSignal;
|
|
3
|
+
}
|
|
4
|
+
export interface MoldableHidDeviceFilter {
|
|
5
|
+
vendorId?: number;
|
|
6
|
+
productId?: number;
|
|
7
|
+
usagePage?: number;
|
|
8
|
+
usage?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface MoldableHidInputReportEvent extends Event {
|
|
11
|
+
readonly data: DataView;
|
|
12
|
+
readonly device: MoldableHidDevice;
|
|
13
|
+
readonly reportId: number;
|
|
14
|
+
}
|
|
15
|
+
/** Structural subset of the standard HIDDevice interface used by the helpers. */
|
|
16
|
+
export interface MoldableHidDevice extends EventTarget {
|
|
17
|
+
readonly opened: boolean;
|
|
18
|
+
readonly vendorId: number;
|
|
19
|
+
readonly productId: number;
|
|
20
|
+
readonly productName: string;
|
|
21
|
+
open(): Promise<void>;
|
|
22
|
+
close(): Promise<void>;
|
|
23
|
+
forget?(): Promise<void>;
|
|
24
|
+
sendReport(reportId: number, data: BufferSource): Promise<void>;
|
|
25
|
+
sendFeatureReport(reportId: number, data: BufferSource): Promise<void>;
|
|
26
|
+
receiveFeatureReport(reportId: number): Promise<DataView>;
|
|
27
|
+
}
|
|
28
|
+
export interface MoldableHidRequestOptions extends MoldableHidOperationOptions {
|
|
29
|
+
filters: readonly MoldableHidDeviceFilter[];
|
|
30
|
+
exclusionFilters?: readonly MoldableHidDeviceFilter[];
|
|
31
|
+
}
|
|
32
|
+
/** Returns true only when this WebView exposes the WebHID entry point. */
|
|
33
|
+
export declare function isMoldableHidSupported(): boolean;
|
|
34
|
+
/** Lists devices previously authorized through WebHID. */
|
|
35
|
+
export declare function getMoldableHidDevices(): Promise<MoldableHidDevice[]>;
|
|
36
|
+
/**
|
|
37
|
+
* Shows the browser's HID chooser. Call this directly from a user gesture.
|
|
38
|
+
* Aborting stops awaiting the result but cannot dismiss every browser chooser.
|
|
39
|
+
*/
|
|
40
|
+
export declare function requestMoldableHidDevices(options: MoldableHidRequestOptions): Promise<MoldableHidDevice[]>;
|
|
41
|
+
export declare function openMoldableHidDevice(device: MoldableHidDevice): Promise<void>;
|
|
42
|
+
export declare function closeMoldableHidDevice(device: MoldableHidDevice): Promise<void>;
|
|
43
|
+
/** Revokes the saved permission when the runtime supports HIDDevice.forget(). */
|
|
44
|
+
export declare function forgetMoldableHidDevice(device: MoldableHidDevice): Promise<void>;
|
|
45
|
+
export declare function sendMoldableHidReport(device: MoldableHidDevice, reportId: number, data: BufferSource, options?: MoldableHidOperationOptions): Promise<void>;
|
|
46
|
+
export declare function sendMoldableHidFeatureReport(device: MoldableHidDevice, reportId: number, data: BufferSource, options?: MoldableHidOperationOptions): Promise<void>;
|
|
47
|
+
export declare function receiveMoldableHidFeatureReport(device: MoldableHidDevice, reportId: number, options?: MoldableHidOperationOptions): Promise<DataView>;
|
|
48
|
+
/** Registers an input-report listener and returns an idempotent cleanup handle. */
|
|
49
|
+
export declare function listenForMoldableHidInputReports(device: MoldableHidDevice, listener: (event: MoldableHidInputReportEvent) => void, options?: {
|
|
50
|
+
signal?: AbortSignal;
|
|
51
|
+
}): () => void;
|
|
52
|
+
//# sourceMappingURL=hid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hid.d.ts","sourceRoot":"","sources":["../../../src/lib/native-hardware/hid.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,2BAA2B;IAC1C,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EA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;GAGG;AACH,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAyD9B;AAED,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,IAAI,CAAC,CAQf;AAED,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,IAAI,CAAC,CAQf;AAED,iFAAiF;AACjF,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,IAAI,CAAC,CAUf;AAED,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,iBAAiB,EACzB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,YAAY,EAClB,OAAO,GAAE,2BAAgC,GACxC,OAAO,CAAC,IAAI,CAAC,CAWf;AAED,wBAAsB,4BAA4B,CAChD,MAAM,EAAE,iBAAiB,EACzB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,YAAY,EAClB,OAAO,GAAE,2BAAgC,GACxC,OAAO,CAAC,IAAI,CAAC,CAWf;AAED,wBAAsB,+BAA+B,CACnD,MAAM,EAAE,iBAAiB,EACzB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,2BAAgC,GACxC,OAAO,CAAC,QAAQ,CAAC,CAWnB;AAED,mFAAmF;AACnF,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,iBAAiB,EACzB,QAAQ,EAAE,CAAC,KAAK,EAAE,2BAA2B,KAAK,IAAI,EACtD,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,WAAW,CAAA;CAAO,GACrC,MAAM,IAAI,CAqBZ"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { NativeHardwareBridgeError } from './bridge';
|
|
2
|
+
import { awaitDeviceIoWithAbort, deviceIoError, unsupportedDeviceIoError, } from './device-io-errors';
|
|
3
|
+
import { NativeMoldableHidDevice, isNativeMoldableHidDevice, } from './hid-native';
|
|
4
|
+
import { listMoldableNativeDevices } from './native-device-io';
|
|
5
|
+
function assertNativeHidFiltersSupported(filters) {
|
|
6
|
+
if (filters?.some((filter) => filter.usagePage !== undefined || filter.usage !== undefined)) {
|
|
7
|
+
throw new NativeHardwareBridgeError({
|
|
8
|
+
code: 'unsupported',
|
|
9
|
+
message: 'The native HID fallback cannot match usagePage or usage filters on this platform.',
|
|
10
|
+
retryable: false,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function hidApi() {
|
|
15
|
+
const api = typeof navigator === 'undefined'
|
|
16
|
+
? undefined
|
|
17
|
+
: navigator.hid;
|
|
18
|
+
if (!api)
|
|
19
|
+
throw unsupportedDeviceIoError('hid');
|
|
20
|
+
return api;
|
|
21
|
+
}
|
|
22
|
+
/** Returns true only when this WebView exposes the WebHID entry point. */
|
|
23
|
+
export function isMoldableHidSupported() {
|
|
24
|
+
return (typeof navigator !== 'undefined' && !!navigator.hid);
|
|
25
|
+
}
|
|
26
|
+
/** Lists devices previously authorized through WebHID. */
|
|
27
|
+
export async function getMoldableHidDevices() {
|
|
28
|
+
if (!isMoldableHidSupported()) {
|
|
29
|
+
throw unsupportedDeviceIoError('hid');
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
return await hidApi().getDevices();
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
throw deviceIoError('hid', 'enumerate', error);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Shows the browser's HID chooser. Call this directly from a user gesture.
|
|
40
|
+
* Aborting stops awaiting the result but cannot dismiss every browser chooser.
|
|
41
|
+
*/
|
|
42
|
+
export async function requestMoldableHidDevices(options) {
|
|
43
|
+
if (!isMoldableHidSupported()) {
|
|
44
|
+
assertNativeHidFiltersSupported(options.filters);
|
|
45
|
+
assertNativeHidFiltersSupported(options.exclusionFilters);
|
|
46
|
+
const descriptors = await listMoldableNativeDevices('hid', {
|
|
47
|
+
signal: options.signal,
|
|
48
|
+
filters: options.filters.map(({ vendorId, productId }) => ({
|
|
49
|
+
vendorId,
|
|
50
|
+
productId,
|
|
51
|
+
})),
|
|
52
|
+
...(options.exclusionFilters
|
|
53
|
+
? {
|
|
54
|
+
exclusionFilters: options.exclusionFilters.map(({ vendorId, productId }) => ({ vendorId, productId })),
|
|
55
|
+
}
|
|
56
|
+
: {}),
|
|
57
|
+
});
|
|
58
|
+
return descriptors
|
|
59
|
+
.filter((descriptor) => options.filters.length === 0
|
|
60
|
+
? true
|
|
61
|
+
: options.filters.some((filter) => (filter.vendorId === undefined ||
|
|
62
|
+
filter.vendorId === descriptor.vendorId) &&
|
|
63
|
+
(filter.productId === undefined ||
|
|
64
|
+
filter.productId === descriptor.productId)))
|
|
65
|
+
.filter((descriptor) => !options.exclusionFilters?.some((filter) => (filter.vendorId === undefined ||
|
|
66
|
+
filter.vendorId === descriptor.vendorId) &&
|
|
67
|
+
(filter.productId === undefined ||
|
|
68
|
+
filter.productId === descriptor.productId)))
|
|
69
|
+
.map((descriptor) => new NativeMoldableHidDevice(descriptor));
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
return await awaitDeviceIoWithAbort(hidApi().requestDevice({
|
|
73
|
+
filters: [...options.filters],
|
|
74
|
+
...(options.exclusionFilters
|
|
75
|
+
? { exclusionFilters: [...options.exclusionFilters] }
|
|
76
|
+
: {}),
|
|
77
|
+
}), 'hid', 'request', options.signal);
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
throw deviceIoError('hid', 'request', error);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
export async function openMoldableHidDevice(device) {
|
|
84
|
+
if (device.opened)
|
|
85
|
+
return;
|
|
86
|
+
try {
|
|
87
|
+
await device.open();
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
throw deviceIoError('hid', 'open', error);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export async function closeMoldableHidDevice(device) {
|
|
94
|
+
if (!device.opened && !isNativeMoldableHidDevice(device))
|
|
95
|
+
return;
|
|
96
|
+
try {
|
|
97
|
+
await device.close();
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
throw deviceIoError('hid', 'close', error);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/** Revokes the saved permission when the runtime supports HIDDevice.forget(). */
|
|
104
|
+
export async function forgetMoldableHidDevice(device) {
|
|
105
|
+
if (typeof device.forget !== 'function') {
|
|
106
|
+
throw unsupportedDeviceIoError('hid');
|
|
107
|
+
}
|
|
108
|
+
try {
|
|
109
|
+
await device.forget();
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
throw deviceIoError('hid', 'close', error);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
export async function sendMoldableHidReport(device, reportId, data, options = {}) {
|
|
116
|
+
try {
|
|
117
|
+
await awaitDeviceIoWithAbort(device.sendReport(reportId, data), 'hid', 'write', options.signal);
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
throw deviceIoError('hid', 'write', error);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
export async function sendMoldableHidFeatureReport(device, reportId, data, options = {}) {
|
|
124
|
+
try {
|
|
125
|
+
await awaitDeviceIoWithAbort(device.sendFeatureReport(reportId, data), 'hid', 'write', options.signal);
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
throw deviceIoError('hid', 'write', error);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
export async function receiveMoldableHidFeatureReport(device, reportId, options = {}) {
|
|
132
|
+
try {
|
|
133
|
+
return await awaitDeviceIoWithAbort(device.receiveFeatureReport(reportId), 'hid', 'read', options.signal);
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
throw deviceIoError('hid', 'read', error);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/** Registers an input-report listener and returns an idempotent cleanup handle. */
|
|
140
|
+
export function listenForMoldableHidInputReports(device, listener, options = {}) {
|
|
141
|
+
if (isNativeMoldableHidDevice(device)) {
|
|
142
|
+
return device.listen(listener, options.signal);
|
|
143
|
+
}
|
|
144
|
+
if (options.signal?.aborted)
|
|
145
|
+
return () => undefined;
|
|
146
|
+
const handleReport = (event) => {
|
|
147
|
+
listener(event);
|
|
148
|
+
};
|
|
149
|
+
let active = true;
|
|
150
|
+
const cleanup = () => {
|
|
151
|
+
if (!active)
|
|
152
|
+
return;
|
|
153
|
+
active = false;
|
|
154
|
+
device.removeEventListener('inputreport', handleReport);
|
|
155
|
+
options.signal?.removeEventListener('abort', cleanup);
|
|
156
|
+
};
|
|
157
|
+
device.addEventListener('inputreport', handleReport);
|
|
158
|
+
options.signal?.addEventListener('abort', cleanup, { once: true });
|
|
159
|
+
return cleanup;
|
|
160
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export { NativeHardwareBridgeError, getMoldableNativeCapabilities, toNativeHardwareBridgeError, } from './bridge';
|
|
2
|
+
export type { NativeHardwareBridgeOptions } from './bridge';
|
|
3
|
+
export { getNativeHardwareCapability, isNativeHardwareCapabilityDescriptor, isNativeHardwareCapabilityId, isNativeHardwareCapabilityManifest, supportsNativeHardwareCapability, } from './capabilities';
|
|
4
|
+
export { readMoldableClipboardText, writeMoldableClipboardText, } from './clipboard';
|
|
5
|
+
export { MoldableBluetoothConnection, connectMoldableBluetoothDevice, getMoldableBluetoothAvailability, getMoldableBluetoothCharacteristic, isMoldableBluetoothSupported, observeMoldableBluetoothNotifications, readMoldableBluetoothValue, requestMoldableBluetoothDevice, requestMoldableBluetoothWithFallback, writeMoldableBluetoothValue, } from './bluetooth';
|
|
6
|
+
export type { MoldableBluetoothAPI, MoldableBluetoothAvailability, MoldableBluetoothConnectionOptions, MoldableBluetoothDataFilter, MoldableBluetoothDevice, MoldableBluetoothDeviceEventMap, MoldableBluetoothLEScanFilter, MoldableBluetoothManufacturerDataFilter, MoldableBluetoothNavigator, MoldableBluetoothOperationOptions, MoldableBluetoothRemoteGATTCharacteristic, MoldableBluetoothRemoteGATTServer, MoldableBluetoothRemoteGATTService, MoldableBluetoothRequestDeviceOptions, MoldableBluetoothRequestOptions, MoldableBluetoothServiceDataFilter, MoldableBluetoothTransport, MoldableBluetoothUUID, MoldableBluetoothWriteMode, MoldableNativeBluetoothDevice, MoldableNativeBluetoothService, } from './bluetooth';
|
|
7
|
+
export { getMoldableDisplays } from './displays';
|
|
8
|
+
export type { GetMoldableDisplaysOptions, MoldableDisplay, MoldableDisplayPosition, MoldableDisplaySize, MoldableDisplaysResult, } from './displays';
|
|
9
|
+
export { areMoldableGlobalShortcutsSuspended, isMoldableGlobalShortcutRegistered, isMoldableGlobalShortcut, registerAllMoldableGlobalShortcuts, registerMoldableGlobalShortcut, setMoldableGlobalShortcutsSuspended, unregisterAllMoldableGlobalShortcuts, unregisterMoldableGlobalShortcut, } from './global-shortcuts';
|
|
10
|
+
export type { MoldableGlobalShortcutEvent, MoldableGlobalShortcutHandler, MoldableGlobalShortcutRegistration, MoldableGlobalShortcutState, } from './global-shortcuts';
|
|
11
|
+
export { getMoldableHapticAvailability, performMoldableHapticFeedback, } from './haptics';
|
|
12
|
+
export type { MoldableHapticAvailability, MoldableHapticPattern, MoldableHapticResult, } from './haptics';
|
|
13
|
+
export { closeMoldableHidDevice, forgetMoldableHidDevice, getMoldableHidDevices, isMoldableHidSupported, listenForMoldableHidInputReports, openMoldableHidDevice, receiveMoldableHidFeatureReport, requestMoldableHidDevices, sendMoldableHidFeatureReport, sendMoldableHidReport, } from './hid';
|
|
14
|
+
export type { MoldableHidDevice, MoldableHidDeviceFilter, MoldableHidInputReportEvent, MoldableHidOperationOptions, MoldableHidRequestOptions, } from './hid';
|
|
15
|
+
export { MOLDABLE_LOCATION_MAX_CACHE_AGE_MS, MOLDABLE_LOCATION_MAX_TIMEOUT_MS, MOLDABLE_LOCATION_MIN_TIMEOUT_MS, getMoldableCurrentPosition, getMoldableLocationAuthorizationStatus, } from './location';
|
|
16
|
+
export type { MoldableLocationAuthorization, MoldableLocationAuthorizationState, MoldableLocationCoordinates, MoldableLocationOptions, MoldableLocationResult, } from './location';
|
|
17
|
+
export { LOCAL_AUTHENTICATION_MAX_REASON_BYTES, authenticateMoldableLocalUser, getMoldableLocalAuthenticationAvailability, } from './local-authentication';
|
|
18
|
+
export type { MoldableLocalAuthenticationAvailability, MoldableLocalAuthenticationMethod, MoldableLocalAuthenticationOptions, MoldableLocalAuthenticationOutcome, MoldableLocalAuthenticationPolicy, MoldableLocalAuthenticationResult, } from './local-authentication';
|
|
19
|
+
export { enumerateMoldableMediaDevices, getMoldableCameraStream, getMoldableDisplayStream, getMoldableMicrophoneStream, stopMoldableMediaStream, } from './media';
|
|
20
|
+
export { NATIVE_SYSTEM_AUDIO_MAX_REPLAY_FRAMES, NATIVE_SYSTEM_AUDIO_PERMISSION_REQUEST_TIMEOUT_MS, getMoldableSystemAudioCapabilities, getMoldableSystemAudioStatus, replayMoldableSystemAudioFrames, requestMoldableSystemAudioPermission, startMoldableSystemAudioCapture, stopMoldableSystemAudioCapture, subscribeMoldableSystemAudioEvents, } from './system-audio';
|
|
21
|
+
export type { MoldableSystemAudioCapabilities, MoldableSystemAudioCapabilityResult, MoldableSystemAudioCaptureMode, MoldableSystemAudioEvent, MoldableSystemAudioEventListener, MoldableSystemAudioReplayOptions, MoldableSystemAudioSource, MoldableSystemAudioSourceState, MoldableSystemAudioStartOptions, MoldableSystemAudioStartResult, MoldableSystemAudioStatus, MoldableSystemAudioStopOptions, SubscribeMoldableSystemAudioEventsOptions, UnsubscribeMoldableSystemAudioEvents, } from './system-audio';
|
|
22
|
+
export { NATIVE_MEDIA_PERMISSION_REQUEST_TIMEOUT_MS, getMoldableMediaPermissionDiagnostics, getMoldableMediaPermissionStatus, requestMoldableMediaPermission, } from './media-permissions';
|
|
23
|
+
export type { MoldableMediaPermission, MoldableMediaPermissionDiagnostics, MoldableMediaPermissionState, MoldableMediaPermissionStatus, } from './media-permissions';
|
|
24
|
+
export { getMoldableMIDIInputs, getMoldableMIDIOutputs, isMoldableMIDISupported, observeMoldableMIDIState, openMoldableMIDIInput, openMoldableMIDIOutput, requestMoldableMIDIAccess, requestMoldableMIDIWithFallback, } from './midi';
|
|
25
|
+
export type { MoldableMIDIAccessOptions, MoldableMIDIConnectionOptions, MoldableMIDIInputConnection, MoldableMIDIOutputConnection, MoldableMIDITransport, MoldableNativeMIDIAccess, MoldableNativeMIDIPort, } from './midi';
|
|
26
|
+
export { NATIVE_NOTIFICATION_MAX_BODY_LENGTH, NATIVE_NOTIFICATION_MAX_TAG_LENGTH, NATIVE_NOTIFICATION_MAX_TITLE_LENGTH, getMoldableNotificationPermission, requestMoldableNotificationPermission, sendMoldableNotification, } from './notifications';
|
|
27
|
+
export type { MoldableNotificationOptions, MoldableNotificationPermission, MoldableNotificationPermissionResult, MoldableNotificationSendResult, } from './notifications';
|
|
28
|
+
export { getMoldableCurrentThermalState, getMoldablePowerState, getMoldableSystemIdleState, getMoldableSystemIdleTime, isMoldableSleepBlockerStarted, isMoldablePowerSessionEvent, startMoldableSleepBlocker, stopMoldableSleepBlocker, watchMoldablePowerSession, } from './power-session';
|
|
29
|
+
export type { MoldableBatteryState, MoldableBatteryStatus, MoldablePowerSessionEvent, MoldablePowerSource, MoldablePowerState, MoldableSleepBlocker, MoldableSleepBlockerType, MoldableSystemIdleResult, MoldableSystemIdleState, MoldableThermalState, StopWatchingMoldablePowerSession, WatchMoldablePowerSessionOptions, } from './power-session';
|
|
30
|
+
export { SECURE_STORAGE_MAX_KEY_LENGTH, SECURE_STORAGE_MAX_VALUE_BYTES, deleteMoldableSecureValue, getMoldableSecureStorageDiagnostics, getMoldableSecureValue, listMoldableSecureValues, setMoldableSecureValue, } from './secure-storage';
|
|
31
|
+
export type { MoldableSecureStorageDeleteResult, MoldableSecureStorageBackend, MoldableSecureStorageDiagnostics, MoldableSecureStorageEntryMetadata, MoldableSecureStorageListResult, MoldableSecureStorageSetResult, MoldableSecureStorageValueResult, } from './secure-storage';
|
|
32
|
+
export { closeMoldableSerialPort, forgetMoldableSerialPort, getMoldableSerialPorts, getMoldableSerialSignals, isMoldableSerialSupported, openMoldableSerialPort, readMoldableSerialPort, requestMoldableSerialPort, setMoldableSerialSignals, writeMoldableSerialPort, } from './serial';
|
|
33
|
+
export type { MoldableBluetoothServiceUuid, MoldableSerialInputSignals, MoldableSerialOpenOptions, MoldableSerialOperationOptions, MoldableSerialOutputSignals, MoldableSerialPort, MoldableSerialPortFilter, MoldableSerialPortInfo, MoldableSerialRequestOptions, } from './serial';
|
|
34
|
+
export { NATIVE_HARDWARE_CAPABILITY_IDS, NATIVE_HARDWARE_MANIFEST_SCHEMA_VERSION, } from './types';
|
|
35
|
+
export type { NativeHardwareCapabilityDescriptor, NativeHardwareCapabilityId, NativeHardwareCapabilityManifest, NativeHardwareErrorCode, NativeHardwareErrorPayload, NativeHardwarePermissionAuthority, NativeHardwarePermissionMetadata, NativeHardwarePermissionName, NativeHardwarePermissionRequest, NativeHardwarePlatform, NativeHardwareSupport, NativeHardwareTransportKind, NativeHardwareTransportMetadata, } from './types';
|
|
36
|
+
export { clearMoldableUsbHalt, closeMoldableUsbDevice, forgetMoldableUsbDevice, getMoldableUsbDevices, isMoldableUsbSupported, openMoldableUsbDevice, readMoldableUsbControlTransfer, readMoldableUsbEndpoint, requestMoldableUsbDevice, resetMoldableUsbDevice, writeMoldableUsbControlTransfer, writeMoldableUsbEndpoint, } from './usb';
|
|
37
|
+
export type { MoldableUsbConfiguration, MoldableUsbControlTransferParameters, MoldableUsbDevice, MoldableUsbDeviceFilter, MoldableUsbInTransferResult, MoldableUsbOpenOptions, MoldableUsbOperationOptions, MoldableUsbOutTransferResult, MoldableUsbRequestOptions, } from './usb';
|
|
38
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["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;AACd,YAAY,EACV,wBAAwB,EACxB,oCAAoC,EACpC,iBAAiB,EACjB,uBAAuB,EACvB,2BAA2B,EAC3B,sBAAsB,EACtB,2BAA2B,EAC3B,4BAA4B,EAC5B,yBAAyB,GAC1B,MAAM,OAAO,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { NativeHardwareBridgeError, getMoldableNativeCapabilities, toNativeHardwareBridgeError, } from './bridge';
|
|
2
|
+
export { getNativeHardwareCapability, isNativeHardwareCapabilityDescriptor, isNativeHardwareCapabilityId, isNativeHardwareCapabilityManifest, supportsNativeHardwareCapability, } from './capabilities';
|
|
3
|
+
export { readMoldableClipboardText, writeMoldableClipboardText, } from './clipboard';
|
|
4
|
+
export { MoldableBluetoothConnection, connectMoldableBluetoothDevice, getMoldableBluetoothAvailability, getMoldableBluetoothCharacteristic, isMoldableBluetoothSupported, observeMoldableBluetoothNotifications, readMoldableBluetoothValue, requestMoldableBluetoothDevice, requestMoldableBluetoothWithFallback, writeMoldableBluetoothValue, } from './bluetooth';
|
|
5
|
+
export { getMoldableDisplays } from './displays';
|
|
6
|
+
export { areMoldableGlobalShortcutsSuspended, isMoldableGlobalShortcutRegistered, isMoldableGlobalShortcut, registerAllMoldableGlobalShortcuts, registerMoldableGlobalShortcut, setMoldableGlobalShortcutsSuspended, unregisterAllMoldableGlobalShortcuts, unregisterMoldableGlobalShortcut, } from './global-shortcuts';
|
|
7
|
+
export { getMoldableHapticAvailability, performMoldableHapticFeedback, } from './haptics';
|
|
8
|
+
export { closeMoldableHidDevice, forgetMoldableHidDevice, getMoldableHidDevices, isMoldableHidSupported, listenForMoldableHidInputReports, openMoldableHidDevice, receiveMoldableHidFeatureReport, requestMoldableHidDevices, sendMoldableHidFeatureReport, sendMoldableHidReport, } from './hid';
|
|
9
|
+
export { MOLDABLE_LOCATION_MAX_CACHE_AGE_MS, MOLDABLE_LOCATION_MAX_TIMEOUT_MS, MOLDABLE_LOCATION_MIN_TIMEOUT_MS, getMoldableCurrentPosition, getMoldableLocationAuthorizationStatus, } from './location';
|
|
10
|
+
export { LOCAL_AUTHENTICATION_MAX_REASON_BYTES, authenticateMoldableLocalUser, getMoldableLocalAuthenticationAvailability, } from './local-authentication';
|
|
11
|
+
export { enumerateMoldableMediaDevices, getMoldableCameraStream, getMoldableDisplayStream, getMoldableMicrophoneStream, stopMoldableMediaStream, } from './media';
|
|
12
|
+
export { NATIVE_SYSTEM_AUDIO_MAX_REPLAY_FRAMES, NATIVE_SYSTEM_AUDIO_PERMISSION_REQUEST_TIMEOUT_MS, getMoldableSystemAudioCapabilities, getMoldableSystemAudioStatus, replayMoldableSystemAudioFrames, requestMoldableSystemAudioPermission, startMoldableSystemAudioCapture, stopMoldableSystemAudioCapture, subscribeMoldableSystemAudioEvents, } from './system-audio';
|
|
13
|
+
export { NATIVE_MEDIA_PERMISSION_REQUEST_TIMEOUT_MS, getMoldableMediaPermissionDiagnostics, getMoldableMediaPermissionStatus, requestMoldableMediaPermission, } from './media-permissions';
|
|
14
|
+
export { getMoldableMIDIInputs, getMoldableMIDIOutputs, isMoldableMIDISupported, observeMoldableMIDIState, openMoldableMIDIInput, openMoldableMIDIOutput, requestMoldableMIDIAccess, requestMoldableMIDIWithFallback, } from './midi';
|
|
15
|
+
export { NATIVE_NOTIFICATION_MAX_BODY_LENGTH, NATIVE_NOTIFICATION_MAX_TAG_LENGTH, NATIVE_NOTIFICATION_MAX_TITLE_LENGTH, getMoldableNotificationPermission, requestMoldableNotificationPermission, sendMoldableNotification, } from './notifications';
|
|
16
|
+
export { getMoldableCurrentThermalState, getMoldablePowerState, getMoldableSystemIdleState, getMoldableSystemIdleTime, isMoldableSleepBlockerStarted, isMoldablePowerSessionEvent, startMoldableSleepBlocker, stopMoldableSleepBlocker, watchMoldablePowerSession, } from './power-session';
|
|
17
|
+
export { SECURE_STORAGE_MAX_KEY_LENGTH, SECURE_STORAGE_MAX_VALUE_BYTES, deleteMoldableSecureValue, getMoldableSecureStorageDiagnostics, getMoldableSecureValue, listMoldableSecureValues, setMoldableSecureValue, } from './secure-storage';
|
|
18
|
+
export { closeMoldableSerialPort, forgetMoldableSerialPort, getMoldableSerialPorts, getMoldableSerialSignals, isMoldableSerialSupported, openMoldableSerialPort, readMoldableSerialPort, requestMoldableSerialPort, setMoldableSerialSignals, writeMoldableSerialPort, } from './serial';
|
|
19
|
+
export { NATIVE_HARDWARE_CAPABILITY_IDS, NATIVE_HARDWARE_MANIFEST_SCHEMA_VERSION, } from './types';
|
|
20
|
+
export { clearMoldableUsbHalt, closeMoldableUsbDevice, forgetMoldableUsbDevice, getMoldableUsbDevices, isMoldableUsbSupported, openMoldableUsbDevice, readMoldableUsbControlTransfer, readMoldableUsbEndpoint, requestMoldableUsbDevice, resetMoldableUsbDevice, writeMoldableUsbControlTransfer, writeMoldableUsbEndpoint, } from './usb';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type NativeHardwareBridgeOptions } from './bridge';
|
|
2
|
+
export declare const NATIVE_LOCAL_AUTHENTICATION_REQUEST_TYPE: "moldable:native-local-authentication";
|
|
3
|
+
export declare const NATIVE_LOCAL_AUTHENTICATION_RESULT_TYPE: "moldable:native-local-authentication-result";
|
|
4
|
+
export declare const LOCAL_AUTHENTICATION_MAX_REASON_BYTES = 160;
|
|
5
|
+
export declare const LOCAL_AUTHENTICATION_TIMEOUT_MS = 125000;
|
|
6
|
+
export type MoldableLocalAuthenticationMethod = 'biometric' | 'device-owner' | 'device-credential' | 'unknown';
|
|
7
|
+
export type MoldableLocalAuthenticationPolicy = 'biometric-only' | 'device-owner';
|
|
8
|
+
export interface MoldableLocalAuthenticationOptions extends NativeHardwareBridgeOptions {
|
|
9
|
+
/** Defaults to device-owner for compatibility with earlier releases. */
|
|
10
|
+
policy?: MoldableLocalAuthenticationPolicy;
|
|
11
|
+
}
|
|
12
|
+
export type MoldableLocalAuthenticationOutcome = 'authenticated' | 'cancelled' | 'failed' | 'locked-out' | 'unavailable';
|
|
13
|
+
export interface MoldableLocalAuthenticationAvailability {
|
|
14
|
+
available: boolean;
|
|
15
|
+
method: MoldableLocalAuthenticationMethod;
|
|
16
|
+
reason?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface MoldableLocalAuthenticationResult {
|
|
19
|
+
outcome: MoldableLocalAuthenticationOutcome;
|
|
20
|
+
method: MoldableLocalAuthenticationMethod;
|
|
21
|
+
message?: string;
|
|
22
|
+
retryable: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare function getMoldableLocalAuthenticationAvailability(options?: NativeHardwareBridgeOptions): Promise<MoldableLocalAuthenticationAvailability>;
|
|
25
|
+
/**
|
|
26
|
+
* Ask the operating system to verify the current device user.
|
|
27
|
+
*
|
|
28
|
+
* Authentication failures and user cancellation are returned as reasoned
|
|
29
|
+
* outcomes. Bridge failures still reject with NativeHardwareBridgeError.
|
|
30
|
+
*/
|
|
31
|
+
export declare function authenticateMoldableLocalUser(reason: string, options?: MoldableLocalAuthenticationOptions): Promise<MoldableLocalAuthenticationResult>;
|
|
32
|
+
//# sourceMappingURL=local-authentication.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-authentication.d.ts","sourceRoot":"","sources":["../../../src/lib/native-hardware/local-authentication.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,2BAA2B,EAEjC,MAAM,UAAU,CAAA;AAEjB,eAAO,MAAM,wCAAwC,EACnD,sCAA+C,CAAA;AACjD,eAAO,MAAM,uCAAuC,EAClD,6CAAsD,CAAA;AAExD,eAAO,MAAM,qCAAqC,MAAM,CAAA;AACxD,eAAO,MAAM,+BAA+B,SAAU,CAAA;AAEtD,MAAM,MAAM,iCAAiC,GACzC,WAAW,GACX,cAAc,GACd,mBAAmB,GACnB,SAAS,CAAA;AAEb,MAAM,MAAM,iCAAiC,GACzC,gBAAgB,GAChB,cAAc,CAAA;AAElB,MAAM,WAAW,kCACf,SAAQ,2BAA2B;IACnC,wEAAwE;IACxE,MAAM,CAAC,EAAE,iCAAiC,CAAA;CAC3C;AAED,MAAM,MAAM,kCAAkC,GAC1C,eAAe,GACf,WAAW,GACX,QAAQ,GACR,YAAY,GACZ,aAAa,CAAA;AAEjB,MAAM,WAAW,uCAAuC;IACtD,SAAS,EAAE,OAAO,CAAA;IAClB,MAAM,EAAE,iCAAiC,CAAA;IACzC,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,iCAAiC;IAChD,OAAO,EAAE,kCAAkC,CAAA;IAC3C,MAAM,EAAE,iCAAiC,CAAA;IACzC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,OAAO,CAAA;CACnB;AASD,wBAAgB,0CAA0C,CACxD,OAAO,GAAE,2BAAgC,GACxC,OAAO,CAAC,uCAAuC,CAAC,CAUlD;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,kCAAuC,GAC/C,OAAO,CAAC,iCAAiC,CAAC,CAiC5C"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { callNativeHardwareBridge, } from './bridge';
|
|
2
|
+
export const NATIVE_LOCAL_AUTHENTICATION_REQUEST_TYPE = 'moldable:native-local-authentication';
|
|
3
|
+
export const NATIVE_LOCAL_AUTHENTICATION_RESULT_TYPE = 'moldable:native-local-authentication-result';
|
|
4
|
+
export const LOCAL_AUTHENTICATION_MAX_REASON_BYTES = 160;
|
|
5
|
+
export const LOCAL_AUTHENTICATION_TIMEOUT_MS = 125_000;
|
|
6
|
+
function hasControlCharacters(value) {
|
|
7
|
+
return Array.from(value).some((character) => {
|
|
8
|
+
const codePoint = character.codePointAt(0) ?? 0;
|
|
9
|
+
return codePoint <= 0x1f || (codePoint >= 0x7f && codePoint <= 0x9f);
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export function getMoldableLocalAuthenticationAvailability(options = {}) {
|
|
13
|
+
return callNativeHardwareBridge({
|
|
14
|
+
type: NATIVE_LOCAL_AUTHENTICATION_REQUEST_TYPE,
|
|
15
|
+
capability: 'local-authentication',
|
|
16
|
+
action: 'getAvailability',
|
|
17
|
+
}, NATIVE_LOCAL_AUTHENTICATION_RESULT_TYPE, options);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Ask the operating system to verify the current device user.
|
|
21
|
+
*
|
|
22
|
+
* Authentication failures and user cancellation are returned as reasoned
|
|
23
|
+
* outcomes. Bridge failures still reject with NativeHardwareBridgeError.
|
|
24
|
+
*/
|
|
25
|
+
export function authenticateMoldableLocalUser(reason, options = {}) {
|
|
26
|
+
if (reason.trim().length === 0 ||
|
|
27
|
+
hasControlCharacters(reason) ||
|
|
28
|
+
new TextEncoder().encode(reason).byteLength >
|
|
29
|
+
LOCAL_AUTHENTICATION_MAX_REASON_BYTES) {
|
|
30
|
+
return Promise.reject(new TypeError(`Authentication reason must contain 1-${LOCAL_AUTHENTICATION_MAX_REASON_BYTES} UTF-8 bytes and no control characters.`));
|
|
31
|
+
}
|
|
32
|
+
const { policy = 'device-owner', ...bridgeOptions } = options;
|
|
33
|
+
if (policy !== 'biometric-only' && policy !== 'device-owner') {
|
|
34
|
+
return Promise.reject(new TypeError('Invalid local authentication policy.'));
|
|
35
|
+
}
|
|
36
|
+
return callNativeHardwareBridge({
|
|
37
|
+
type: NATIVE_LOCAL_AUTHENTICATION_REQUEST_TYPE,
|
|
38
|
+
capability: 'local-authentication',
|
|
39
|
+
action: 'authenticate',
|
|
40
|
+
reason,
|
|
41
|
+
policy,
|
|
42
|
+
}, NATIVE_LOCAL_AUTHENTICATION_RESULT_TYPE, {
|
|
43
|
+
...bridgeOptions,
|
|
44
|
+
timeoutMs: bridgeOptions.timeoutMs ?? LOCAL_AUTHENTICATION_TIMEOUT_MS,
|
|
45
|
+
});
|
|
46
|
+
}
|