@moldable-ai/ui 0.2.17 → 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/chat/tool-handlers.d.ts.map +1 -1
- 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 +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/lib/commands.d.ts +59 -0
- package/dist/lib/commands.d.ts.map +1 -1
- package/dist/lib/commands.js +97 -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,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,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,2BAA4B,SAAQ,KAAK;IACxD,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;IACvB,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAA;IAClC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAC1B;AAED,iFAAiF;AACjF,MAAM,WAAW,iBAAkB,SAAQ,WAAW;IACpD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACrB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACtB,MAAM,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACxB,UAAU,CAAC,QAAQ,EAAE,MAAM,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f;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":["../../../src/lib/native-hardware/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,6BAA6B,EAC7B,2BAA2B,GAC5B,MAAM,UAAU,CAAA;AACjB,YAAY,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAA;AAE3D,OAAO,EACL,2BAA2B,EAC3B,oCAAoC,EACpC,4BAA4B,EAC5B,kCAAkC,EAClC,gCAAgC,GACjC,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EACL,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,2BAA2B,EAC3B,8BAA8B,EAC9B,gCAAgC,EAChC,kCAAkC,EAClC,4BAA4B,EAC5B,qCAAqC,EACrC,0BAA0B,EAC1B,8BAA8B,EAC9B,oCAAoC,EACpC,2BAA2B,GAC5B,MAAM,aAAa,CAAA;AACpB,YAAY,EACV,oBAAoB,EACpB,6BAA6B,EAC7B,kCAAkC,EAClC,2BAA2B,EAC3B,uBAAuB,EACvB,+BAA+B,EAC/B,6BAA6B,EAC7B,uCAAuC,EACvC,0BAA0B,EAC1B,iC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B,4BAA4B,GAC7B,MAAM,UAAU,CAAA;AAEjB,OAAO,EACL,8BAA8B,EAC9B,uCAAuC,GACxC,MAAM,SAAS,CAAA;AAChB,YAAY,EACV,kCAAkC,EAClC,0BAA0B,EAC1B,gCAAgC,EAChC,uBAAuB,EACvB,0BAA0B,EAC1B,iCAAiC,EACjC,gCAAgC,EAChC,4BAA4B,EAC5B,+BAA+B,EAC/B,sBAAsB,EACtB,qBAAqB,EACrB,2BAA2B,EAC3B,+BAA+B,GAChC,MAAM,SAAS,CAAA;AAEhB,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,8BAA8B,EAC9B,uBAAuB,EACvB,wBAAwB,EACxB,sBAAsB,EACtB,+BAA+B,EAC/B,wBAAwB,GACzB,MAAM,OAAO,CAAA;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
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export declare const MOLDABLE_LOCATION_MIN_TIMEOUT_MS = 1;
|
|
2
|
+
export declare const MOLDABLE_LOCATION_MAX_TIMEOUT_MS = 60000;
|
|
3
|
+
export declare const MOLDABLE_LOCATION_MAX_CACHE_AGE_MS = 86400000;
|
|
4
|
+
/**
|
|
5
|
+
* Options accepted by the native one-shot location bridge.
|
|
6
|
+
*
|
|
7
|
+
* Unlike the browser's unrestricted `PositionOptions`, the native bridge
|
|
8
|
+
* requires integer millisecond values, a 1-60,000 ms timeout, and a
|
|
9
|
+
* 0-86,400,000 ms maximum cache age.
|
|
10
|
+
*/
|
|
11
|
+
export interface MoldableLocationOptions {
|
|
12
|
+
enableHighAccuracy?: boolean;
|
|
13
|
+
timeout?: number;
|
|
14
|
+
maximumAge?: number;
|
|
15
|
+
}
|
|
16
|
+
export type MoldableLocationAuthorization = 'granted' | 'denied' | 'restricted' | 'not-determined' | 'unknown' | 'unsupported';
|
|
17
|
+
export interface MoldableLocationAuthorizationState {
|
|
18
|
+
authorization: MoldableLocationAuthorization;
|
|
19
|
+
servicesEnabled: boolean;
|
|
20
|
+
canRequest: boolean;
|
|
21
|
+
settingsRequired: boolean;
|
|
22
|
+
detail?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface MoldableLocationCoordinates {
|
|
25
|
+
latitude: number;
|
|
26
|
+
longitude: number;
|
|
27
|
+
accuracy: number;
|
|
28
|
+
altitude: number | null;
|
|
29
|
+
altitudeAccuracy: number | null;
|
|
30
|
+
heading: number | null;
|
|
31
|
+
speed: number | null;
|
|
32
|
+
}
|
|
33
|
+
export interface MoldableLocationResult {
|
|
34
|
+
coords: MoldableLocationCoordinates;
|
|
35
|
+
timestamp: number;
|
|
36
|
+
}
|
|
37
|
+
export declare const NATIVE_LOCATION_REQUEST_TYPE: "moldable:native-location-request";
|
|
38
|
+
export declare const NATIVE_LOCATION_RESULT_TYPE: "moldable:native-location-result";
|
|
39
|
+
/** Reads macOS location authorization without requesting a position or prompting. */
|
|
40
|
+
export declare function getMoldableLocationAuthorizationStatus(): Promise<MoldableLocationAuthorizationState>;
|
|
41
|
+
/**
|
|
42
|
+
* Gets one browser-shaped location fix.
|
|
43
|
+
*
|
|
44
|
+
* Packaged macOS apps use Moldable's native Core Location bridge. Other
|
|
45
|
+
* runtimes fall back to navigator.geolocation only when the host explicitly
|
|
46
|
+
* reports that native location is unsupported.
|
|
47
|
+
*/
|
|
48
|
+
export declare function getMoldableCurrentPosition(options?: MoldableLocationOptions): Promise<MoldableLocationResult>;
|
|
49
|
+
//# sourceMappingURL=location.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"location.d.ts","sourceRoot":"","sources":["../../../src/lib/native-hardware/location.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,gCAAgC,IAAI,CAAA;AACjD,eAAO,MAAM,gCAAgC,QAAS,CAAA;AACtD,eAAO,MAAM,kCAAkC,WAAa,CAAA;AAE5D;;;;;;GAMG;AACH,MAAM,WAAW,uBAAuB;IACtC,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,MAAM,6BAA6B,GACrC,SAAS,GACT,QAAQ,GACR,YAAY,GACZ,gBAAgB,GAChB,SAAS,GACT,aAAa,CAAA;AAEjB,MAAM,WAAW,kCAAkC;IACjD,aAAa,EAAE,6BAA6B,CAAA;IAC5C,eAAe,EAAE,OAAO,CAAA;IACxB,UAAU,EAAE,OAAO,CAAA;IACnB,gBAAgB,EAAE,OAAO,CAAA;IACzB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CACrB;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,2BAA2B,CAAA;IACnC,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,eAAO,MAAM,4BAA4B,EACvC,kCAA2C,CAAA;AAC7C,eAAO,MAAM,2BAA2B,EACtC,iCAA0C,CAAA;AAE5C,qFAAqF;AACrF,wBAAgB,sCAAsC,IAAI,OAAO,CAAC,kCAAkC,CAAC,CAQpG;AAoGD;;;;;;GAMG;AACH,wBAAsB,0BAA0B,CAC9C,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,sBAAsB,CAAC,CAqBjC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { NativeHardwareBridgeError, callNativeHardwareBridge, toNativeHardwareBridgeError, } from './bridge';
|
|
2
|
+
export const MOLDABLE_LOCATION_MIN_TIMEOUT_MS = 1;
|
|
3
|
+
export const MOLDABLE_LOCATION_MAX_TIMEOUT_MS = 60_000;
|
|
4
|
+
export const MOLDABLE_LOCATION_MAX_CACHE_AGE_MS = 86_400_000;
|
|
5
|
+
export const NATIVE_LOCATION_REQUEST_TYPE = 'moldable:native-location-request';
|
|
6
|
+
export const NATIVE_LOCATION_RESULT_TYPE = 'moldable:native-location-result';
|
|
7
|
+
/** Reads macOS location authorization without requesting a position or prompting. */
|
|
8
|
+
export function getMoldableLocationAuthorizationStatus() {
|
|
9
|
+
return callNativeHardwareBridge({
|
|
10
|
+
type: NATIVE_LOCATION_REQUEST_TYPE,
|
|
11
|
+
action: 'getStatus',
|
|
12
|
+
}, NATIVE_LOCATION_RESULT_TYPE);
|
|
13
|
+
}
|
|
14
|
+
function locationError(error) {
|
|
15
|
+
if (error instanceof NativeHardwareBridgeError)
|
|
16
|
+
return error;
|
|
17
|
+
let code = 'host_error';
|
|
18
|
+
let retryable = false;
|
|
19
|
+
let cause;
|
|
20
|
+
if (isGeolocationError(error)) {
|
|
21
|
+
cause = error.code;
|
|
22
|
+
if (error.code === 1)
|
|
23
|
+
code = 'permission_denied';
|
|
24
|
+
else if (error.code === 2) {
|
|
25
|
+
code = 'unavailable';
|
|
26
|
+
retryable = true;
|
|
27
|
+
}
|
|
28
|
+
else if (error.code === 3) {
|
|
29
|
+
code = 'timeout';
|
|
30
|
+
retryable = true;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else if (error instanceof DOMException) {
|
|
34
|
+
cause = error.name;
|
|
35
|
+
if (error.name === 'NotSupportedError')
|
|
36
|
+
code = 'unsupported';
|
|
37
|
+
else if (error.name === 'NotAllowedError' ||
|
|
38
|
+
error.name === 'SecurityError') {
|
|
39
|
+
code = 'permission_denied';
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const fallbackMessage = 'Unable to get current location';
|
|
43
|
+
return toNativeHardwareBridgeError({
|
|
44
|
+
code,
|
|
45
|
+
message: error instanceof Error || isGeolocationError(error)
|
|
46
|
+
? error.message || fallbackMessage
|
|
47
|
+
: fallbackMessage,
|
|
48
|
+
details: {
|
|
49
|
+
capability: 'location',
|
|
50
|
+
...(cause !== undefined ? { cause } : {}),
|
|
51
|
+
},
|
|
52
|
+
retryable,
|
|
53
|
+
}, fallbackMessage);
|
|
54
|
+
}
|
|
55
|
+
function isGeolocationError(error) {
|
|
56
|
+
return (typeof error === 'object' &&
|
|
57
|
+
error !== null &&
|
|
58
|
+
'code' in error &&
|
|
59
|
+
typeof error.code === 'number' &&
|
|
60
|
+
'message' in error &&
|
|
61
|
+
typeof error.message === 'string');
|
|
62
|
+
}
|
|
63
|
+
function getBrowserCurrentPosition(options = {}) {
|
|
64
|
+
if (typeof navigator === 'undefined' ||
|
|
65
|
+
!navigator.geolocation ||
|
|
66
|
+
typeof navigator.geolocation.getCurrentPosition !== 'function') {
|
|
67
|
+
return Promise.reject(locationError(new DOMException('Geolocation API unavailable', 'NotSupportedError')));
|
|
68
|
+
}
|
|
69
|
+
return new Promise((resolve, reject) => {
|
|
70
|
+
navigator.geolocation.getCurrentPosition((position) => {
|
|
71
|
+
resolve({
|
|
72
|
+
coords: {
|
|
73
|
+
latitude: position.coords.latitude,
|
|
74
|
+
longitude: position.coords.longitude,
|
|
75
|
+
accuracy: position.coords.accuracy,
|
|
76
|
+
altitude: position.coords.altitude,
|
|
77
|
+
altitudeAccuracy: position.coords.altitudeAccuracy,
|
|
78
|
+
heading: position.coords.heading,
|
|
79
|
+
speed: position.coords.speed,
|
|
80
|
+
},
|
|
81
|
+
timestamp: position.timestamp,
|
|
82
|
+
});
|
|
83
|
+
}, (error) => reject(locationError(error)), options);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function isEmbeddedInMoldable() {
|
|
87
|
+
return typeof window !== 'undefined' && window.parent !== window;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Gets one browser-shaped location fix.
|
|
91
|
+
*
|
|
92
|
+
* Packaged macOS apps use Moldable's native Core Location bridge. Other
|
|
93
|
+
* runtimes fall back to navigator.geolocation only when the host explicitly
|
|
94
|
+
* reports that native location is unsupported.
|
|
95
|
+
*/
|
|
96
|
+
export async function getMoldableCurrentPosition(options = {}) {
|
|
97
|
+
if (!isEmbeddedInMoldable())
|
|
98
|
+
return getBrowserCurrentPosition(options);
|
|
99
|
+
try {
|
|
100
|
+
const nativeTimeout = options.timeout ?? 10_000;
|
|
101
|
+
return await callNativeHardwareBridge({
|
|
102
|
+
type: NATIVE_LOCATION_REQUEST_TYPE,
|
|
103
|
+
action: 'getCurrentPosition',
|
|
104
|
+
options,
|
|
105
|
+
}, NATIVE_LOCATION_RESULT_TYPE, { timeoutMs: Math.max(nativeTimeout + 2_000, 12_000) });
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
const mapped = locationError(error);
|
|
109
|
+
if (mapped.code === 'unsupported' || mapped.code === 'not_in_moldable') {
|
|
110
|
+
return getBrowserCurrentPosition(options);
|
|
111
|
+
}
|
|
112
|
+
throw mapped;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type NativeHardwareBridgeOptions } from './bridge';
|
|
2
|
+
export declare const NATIVE_MEDIA_PERMISSION_REQUEST_TIMEOUT_MS = 125000;
|
|
3
|
+
export type MoldableMediaPermission = 'camera' | 'microphone' | 'screen-recording';
|
|
4
|
+
export type MoldableMediaPermissionStatus = 'granted' | 'denied' | 'restricted' | 'not-determined' | 'unknown' | 'unsupported';
|
|
5
|
+
export interface MoldableMediaPermissionState {
|
|
6
|
+
permission: MoldableMediaPermission;
|
|
7
|
+
status: MoldableMediaPermissionStatus;
|
|
8
|
+
canRequest: boolean;
|
|
9
|
+
settingsRequired: boolean;
|
|
10
|
+
detail?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface MoldableMediaPermissionDiagnostics {
|
|
13
|
+
platform: string;
|
|
14
|
+
capturedAtMs: number;
|
|
15
|
+
/** Capture source choice remains owned by the OS/webview picker. */
|
|
16
|
+
captureSourceBoundary: 'system-picker';
|
|
17
|
+
permissions: MoldableMediaPermissionState[];
|
|
18
|
+
}
|
|
19
|
+
/** Reads native OS authorization without opening hardware or showing a prompt. */
|
|
20
|
+
export declare function getMoldableMediaPermissionStatus(permission: MoldableMediaPermission, options?: NativeHardwareBridgeOptions): Promise<MoldableMediaPermissionState>;
|
|
21
|
+
/**
|
|
22
|
+
* Requests OS permission from a direct user action. This never selects or
|
|
23
|
+
* enumerates a display source; display capture still uses the system picker.
|
|
24
|
+
*/
|
|
25
|
+
export declare function requestMoldableMediaPermission(permission: MoldableMediaPermission, options?: NativeHardwareBridgeOptions): Promise<MoldableMediaPermissionState>;
|
|
26
|
+
/** Returns a current, non-capturing diagnostic snapshot for all media permissions. */
|
|
27
|
+
export declare function getMoldableMediaPermissionDiagnostics(options?: NativeHardwareBridgeOptions): Promise<MoldableMediaPermissionDiagnostics>;
|
|
28
|
+
//# sourceMappingURL=media-permissions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media-permissions.d.ts","sourceRoot":"","sources":["../../../src/lib/native-hardware/media-permissions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,2BAA2B,EAEjC,MAAM,UAAU,CAAA;AAOjB,eAAO,MAAM,0CAA0C,SAAU,CAAA;AAEjE,MAAM,MAAM,uBAAuB,GAC/B,QAAQ,GACR,YAAY,GACZ,kBAAkB,CAAA;AACtB,MAAM,MAAM,6BAA6B,GACrC,SAAS,GACT,QAAQ,GACR,YAAY,GACZ,gBAAgB,GAChB,SAAS,GACT,aAAa,CAAA;AAEjB,MAAM,WAAW,4BAA4B;IAC3C,UAAU,EAAE,uBAAuB,CAAA;IACnC,MAAM,EAAE,6BAA6B,CAAA;IACrC,UAAU,EAAE,OAAO,CAAA;IACnB,gBAAgB,EAAE,OAAO,CAAA;IACzB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,kCAAkC;IACjD,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,MAAM,CAAA;IACpB,oEAAoE;IACpE,qBAAqB,EAAE,eAAe,CAAA;IACtC,WAAW,EAAE,4BAA4B,EAAE,CAAA;CAC5C;AAQD,kFAAkF;AAClF,wBAAgB,gCAAgC,CAC9C,UAAU,EAAE,uBAAuB,EACnC,OAAO,GAAE,2BAAgC,GACxC,OAAO,CAAC,4BAA4B,CAAC,CAUvC;AAED;;;GAGG;AACH,wBAAgB,8BAA8B,CAC5C,UAAU,EAAE,uBAAuB,EACnC,OAAO,GAAE,2BAAgC,GACxC,OAAO,CAAC,4BAA4B,CAAC,CAevC;AAED,sFAAsF;AACtF,wBAAgB,qCAAqC,CACnD,OAAO,GAAE,2BAAgC,GACxC,OAAO,CAAC,kCAAkC,CAAC,CAS7C"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { callNativeHardwareBridge, } from './bridge';
|
|
2
|
+
const NATIVE_MEDIA_PERMISSION_REQUEST_TYPE = 'moldable:native-media-permission';
|
|
3
|
+
const NATIVE_MEDIA_PERMISSION_RESULT_TYPE = 'moldable:native-media-permission-result';
|
|
4
|
+
export const NATIVE_MEDIA_PERMISSION_REQUEST_TIMEOUT_MS = 125_000;
|
|
5
|
+
function capabilityFor(permission) {
|
|
6
|
+
return permission === 'screen-recording' ? 'screen-capture' : permission;
|
|
7
|
+
}
|
|
8
|
+
/** Reads native OS authorization without opening hardware or showing a prompt. */
|
|
9
|
+
export function getMoldableMediaPermissionStatus(permission, options = {}) {
|
|
10
|
+
return callNativeHardwareBridge({
|
|
11
|
+
type: NATIVE_MEDIA_PERMISSION_REQUEST_TYPE,
|
|
12
|
+
action: 'getStatus',
|
|
13
|
+
permission,
|
|
14
|
+
}, NATIVE_MEDIA_PERMISSION_RESULT_TYPE, options);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Requests OS permission from a direct user action. This never selects or
|
|
18
|
+
* enumerates a display source; display capture still uses the system picker.
|
|
19
|
+
*/
|
|
20
|
+
export function requestMoldableMediaPermission(permission, options = {}) {
|
|
21
|
+
return callNativeHardwareBridge({
|
|
22
|
+
type: NATIVE_MEDIA_PERMISSION_REQUEST_TYPE,
|
|
23
|
+
action: 'request',
|
|
24
|
+
permission,
|
|
25
|
+
capability: capabilityFor(permission),
|
|
26
|
+
}, NATIVE_MEDIA_PERMISSION_RESULT_TYPE, {
|
|
27
|
+
...options,
|
|
28
|
+
timeoutMs: options.timeoutMs ?? NATIVE_MEDIA_PERMISSION_REQUEST_TIMEOUT_MS,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/** Returns a current, non-capturing diagnostic snapshot for all media permissions. */
|
|
32
|
+
export function getMoldableMediaPermissionDiagnostics(options = {}) {
|
|
33
|
+
return callNativeHardwareBridge({
|
|
34
|
+
type: NATIVE_MEDIA_PERMISSION_REQUEST_TYPE,
|
|
35
|
+
action: 'getDiagnostics',
|
|
36
|
+
}, NATIVE_MEDIA_PERMISSION_RESULT_TYPE, options);
|
|
37
|
+
}
|