@flighthq/dialog 0.5.1-next.973.788d3d7 → 0.6.0
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/README.md +2 -2
- package/dist/contract.d.ts +5 -4
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +4 -4
- package/dist/contract.js.map +1 -1
- package/dist/dialog.d.ts +8 -12
- package/dist/dialog.d.ts.map +1 -1
- package/dist/dialog.js +14 -72
- package/dist/dialog.js.map +1 -1
- package/dist/fileDialog.d.ts +5 -4
- package/dist/fileDialog.d.ts.map +1 -1
- package/dist/fileDialog.js +9 -9
- package/dist/fileDialog.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mediaDialog.d.ts +4 -4
- package/dist/mediaDialog.d.ts.map +1 -1
- package/dist/mediaDialog.js +6 -6
- package/dist/mediaDialog.js.map +1 -1
- package/dist/types.d.ts +146 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +6 -4
- package/src/dialog.test.ts +20 -49
- package/src/fileDialog.test.ts +25 -25
- package/src/mediaDialog.test.ts +22 -25
package/README.md
CHANGED
|
@@ -13,5 +13,5 @@ Import the supported application-facing API from `@flighthq/dialog`. The `@fligh
|
|
|
13
13
|
This package is part of the locked-version Flight SDK graph. Applications may instead install and import `@flighthq/sdk` when package-level tree shaking is sufficient.
|
|
14
14
|
|
|
15
15
|
- [Flight project](https://github.com/flighthq/flight)
|
|
16
|
-
- [Source for @flighthq/dialog@0.
|
|
17
|
-
- [License](https://github.com/flighthq/flight/blob/
|
|
16
|
+
- [Source for @flighthq/dialog@0.6.0](https://github.com/flighthq/flight/tree/ead804bfaef3e691a2e6e43e9711ddd3fd8a84a2/packages/dialog)
|
|
17
|
+
- [License](https://github.com/flighthq/flight/blob/ead804bfaef3e691a2e6e43e9711ddd3fd8a84a2/LICENSE.md)
|
package/dist/contract.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export * from './dialog';
|
|
2
|
-
export * from './fileDialog';
|
|
3
|
-
export * from './mediaDialog';
|
|
4
|
-
export { initializeFileDialogHandle } from './fileDialog';
|
|
1
|
+
export * from './dialog.ts';
|
|
2
|
+
export * from './fileDialog.ts';
|
|
3
|
+
export * from './mediaDialog.ts';
|
|
4
|
+
export { initializeFileDialogHandle } from './fileDialog.ts';
|
|
5
|
+
export type * from './types.ts';
|
|
5
6
|
//# sourceMappingURL=contract.d.ts.map
|
package/dist/contract.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAC7D,mBAAmB,YAAY,CAAC"}
|
package/dist/contract.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './dialog';
|
|
2
|
-
export * from './fileDialog';
|
|
3
|
-
export * from './mediaDialog';
|
|
4
|
-
export { initializeFileDialogHandle } from './fileDialog';
|
|
1
|
+
export * from './dialog.js';
|
|
2
|
+
export * from './fileDialog.js';
|
|
3
|
+
export * from './mediaDialog.js';
|
|
4
|
+
export { initializeFileDialogHandle } from './fileDialog.js';
|
|
5
5
|
//# sourceMappingURL=contract.js.map
|
package/dist/contract.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/dialog.d.ts
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare
|
|
3
|
-
export declare
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function
|
|
9
|
-
export declare function showInfoDialog(host: HasDialogMessage, options: Readonly<MessageDialogOptions>): Promise<MessageDialogResult>;
|
|
10
|
-
export declare function showMessageDialog(host: HasDialogMessage, options: Readonly<MessageDialogOptions>): Promise<MessageDialogResult>;
|
|
11
|
-
export declare function showPromptDialog(host: HasDialogPrompt, options: Readonly<PromptDialogOptions>): Promise<string | null>;
|
|
12
|
-
export declare function showWarningDialog(host: HasDialogMessage, options: Readonly<MessageDialogOptions>): Promise<MessageDialogResult>;
|
|
1
|
+
import type { HostMessageDialogCapability, HostPromptDialogCapability, MessageDialogOptions, MessageDialogResult, PromptDialogOptions } from './types.ts';
|
|
2
|
+
export declare function showConfirmDialog(hostMessageDialog: Readonly<HostMessageDialogCapability>, options: Readonly<MessageDialogOptions>): Promise<boolean>;
|
|
3
|
+
export declare function showErrorBox(hostMessageDialog: Readonly<HostMessageDialogCapability>, title: string, content: string, signal?: MessageDialogOptions['signal']): Promise<MessageDialogResult>;
|
|
4
|
+
export declare function showErrorDialog(hostMessageDialog: Readonly<HostMessageDialogCapability>, options: Readonly<MessageDialogOptions>): Promise<MessageDialogResult>;
|
|
5
|
+
export declare function showInfoDialog(hostMessageDialog: Readonly<HostMessageDialogCapability>, options: Readonly<MessageDialogOptions>): Promise<MessageDialogResult>;
|
|
6
|
+
export declare function showMessageDialog(hostMessageDialog: Readonly<HostMessageDialogCapability>, options: Readonly<MessageDialogOptions>): Promise<MessageDialogResult>;
|
|
7
|
+
export declare function showPromptDialog(hostPromptDialog: Readonly<HostPromptDialogCapability>, options: Readonly<PromptDialogOptions>): Promise<string | null>;
|
|
8
|
+
export declare function showWarningDialog(hostMessageDialog: Readonly<HostMessageDialogCapability>, options: Readonly<MessageDialogOptions>): Promise<MessageDialogResult>;
|
|
13
9
|
//# sourceMappingURL=dialog.d.ts.map
|
package/dist/dialog.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../src/dialog.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../src/dialog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAC3B,0BAA0B,EAC1B,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAEpB,wBAAgB,iBAAiB,CAC/B,iBAAiB,EAAE,QAAQ,CAAC,2BAA2B,CAAC,EACxD,OAAO,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GACtC,OAAO,CAAC,OAAO,CAAC,CAElB;AAED,wBAAgB,YAAY,CAC1B,iBAAiB,EAAE,QAAQ,CAAC,2BAA2B,CAAC,EACxD,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,oBAAoB,CAAC,QAAQ,CAAC,GACtC,OAAO,CAAC,mBAAmB,CAAC,CAM9B;AAED,wBAAgB,eAAe,CAC7B,iBAAiB,EAAE,QAAQ,CAAC,2BAA2B,CAAC,EACxD,OAAO,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GACtC,OAAO,CAAC,mBAAmB,CAAC,CAE9B;AAED,wBAAgB,cAAc,CAC5B,iBAAiB,EAAE,QAAQ,CAAC,2BAA2B,CAAC,EACxD,OAAO,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GACtC,OAAO,CAAC,mBAAmB,CAAC,CAE9B;AAED,wBAAgB,iBAAiB,CAC/B,iBAAiB,EAAE,QAAQ,CAAC,2BAA2B,CAAC,EACxD,OAAO,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GACtC,OAAO,CAAC,mBAAmB,CAAC,CAE9B;AAED,wBAAgB,gBAAgB,CAC9B,gBAAgB,EAAE,QAAQ,CAAC,0BAA0B,CAAC,EACtD,OAAO,EAAE,QAAQ,CAAC,mBAAmB,CAAC,GACrC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAExB;AAED,wBAAgB,iBAAiB,CAC/B,iBAAiB,EAAE,QAAQ,CAAC,2BAA2B,CAAC,EACxD,OAAO,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GACtC,OAAO,CAAC,mBAAmB,CAAC,CAE9B"}
|
package/dist/dialog.js
CHANGED
|
@@ -1,82 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
// them into host-web. File-picker providers live exclusively in @flighthq/host-web.
|
|
4
|
-
export const webMessageDialogBackend = createWebMessageDialogBackend();
|
|
5
|
-
export const webPromptDialogBackend = createWebPromptDialogBackend();
|
|
6
|
-
function createWebMessageDialogBackend() {
|
|
7
|
-
const out = allocateEntity();
|
|
8
|
-
initializeWebMessageDialogBackend(out);
|
|
9
|
-
return finishEntity(out);
|
|
1
|
+
export function showConfirmDialog(hostMessageDialog, options) {
|
|
2
|
+
return hostMessageDialog.confirm(options);
|
|
10
3
|
}
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
initializeWebPromptDialogBackend(out);
|
|
14
|
-
return finishEntity(out);
|
|
15
|
-
}
|
|
16
|
-
export function initializeWebMessageDialogBackend(out) {
|
|
17
|
-
out.confirm = async (options) => {
|
|
18
|
-
if (options.signal?.aborted)
|
|
19
|
-
return false;
|
|
20
|
-
if (typeof window === 'undefined' || typeof window.confirm !== 'function')
|
|
21
|
-
return false;
|
|
22
|
-
try {
|
|
23
|
-
return window.confirm(options.message) === true;
|
|
24
|
-
}
|
|
25
|
-
catch {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
out.message = async (options) => {
|
|
30
|
-
const checkboxChecked = options.checkboxChecked ?? false;
|
|
31
|
-
if (options.signal?.aborted)
|
|
32
|
-
return { buttonIndex: options.cancelId ?? 0, cancelled: true, checkboxChecked };
|
|
33
|
-
if (typeof window === 'undefined' || typeof window.alert !== 'function') {
|
|
34
|
-
return { buttonIndex: 0, cancelled: false, checkboxChecked };
|
|
35
|
-
}
|
|
36
|
-
try {
|
|
37
|
-
window.alert(options.message);
|
|
38
|
-
}
|
|
39
|
-
catch {
|
|
40
|
-
return { buttonIndex: 0, cancelled: false, checkboxChecked };
|
|
41
|
-
}
|
|
42
|
-
return { buttonIndex: 0, cancelled: false, checkboxChecked };
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
export function initializeWebPromptDialogBackend(out) {
|
|
46
|
-
out.prompt = async (options) => {
|
|
47
|
-
if (options.signal?.aborted)
|
|
48
|
-
return null;
|
|
49
|
-
if (typeof window === 'undefined' || typeof window.prompt !== 'function')
|
|
50
|
-
return null;
|
|
51
|
-
try {
|
|
52
|
-
return window.prompt(options.message, options.defaultValue ?? '');
|
|
53
|
-
}
|
|
54
|
-
catch {
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
export function showConfirmDialog(host, options) {
|
|
60
|
-
return host.dialog.message.confirm(options);
|
|
61
|
-
}
|
|
62
|
-
export function showErrorBox(host, title, content, signal) {
|
|
63
|
-
return host.dialog.message.message(signal === undefined
|
|
4
|
+
export function showErrorBox(hostMessageDialog, title, content, signal) {
|
|
5
|
+
return hostMessageDialog.message(signal === undefined
|
|
64
6
|
? { kind: 'error', message: content, title }
|
|
65
7
|
: { kind: 'error', message: content, signal, title });
|
|
66
8
|
}
|
|
67
|
-
export function showErrorDialog(
|
|
68
|
-
return
|
|
9
|
+
export function showErrorDialog(hostMessageDialog, options) {
|
|
10
|
+
return hostMessageDialog.message({ ...options, kind: 'error' });
|
|
69
11
|
}
|
|
70
|
-
export function showInfoDialog(
|
|
71
|
-
return
|
|
12
|
+
export function showInfoDialog(hostMessageDialog, options) {
|
|
13
|
+
return hostMessageDialog.message({ ...options, kind: 'info' });
|
|
72
14
|
}
|
|
73
|
-
export function showMessageDialog(
|
|
74
|
-
return
|
|
15
|
+
export function showMessageDialog(hostMessageDialog, options) {
|
|
16
|
+
return hostMessageDialog.message(options);
|
|
75
17
|
}
|
|
76
|
-
export function showPromptDialog(
|
|
77
|
-
return
|
|
18
|
+
export function showPromptDialog(hostPromptDialog, options) {
|
|
19
|
+
return hostPromptDialog.prompt(options);
|
|
78
20
|
}
|
|
79
|
-
export function showWarningDialog(
|
|
80
|
-
return
|
|
21
|
+
export function showWarningDialog(hostMessageDialog, options) {
|
|
22
|
+
return hostMessageDialog.message({ ...options, kind: 'warning' });
|
|
81
23
|
}
|
|
82
24
|
//# sourceMappingURL=dialog.js.map
|
package/dist/dialog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../src/dialog.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../src/dialog.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,iBAAiB,CAC/B,iBAAwD,EACxD,OAAuC;IAEvC,OAAO,iBAAiB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,iBAAwD,EACxD,KAAa,EACb,OAAe,EACf,MAAuC;IAEvC,OAAO,iBAAiB,CAAC,OAAO,CAC9B,MAAM,KAAK,SAAS;QAClB,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;QAC5C,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CACvD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,iBAAwD,EACxD,OAAuC;IAEvC,OAAO,iBAAiB,CAAC,OAAO,CAAC,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,iBAAwD,EACxD,OAAuC;IAEvC,OAAO,iBAAiB,CAAC,OAAO,CAAC,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,iBAAwD,EACxD,OAAuC;IAEvC,OAAO,iBAAiB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC9B,gBAAsD,EACtD,OAAsC;IAEtC,OAAO,gBAAgB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,iBAAwD,EACxD,OAAuC;IAEvC,OAAO,iBAAiB,CAAC,OAAO,CAAC,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;AACpE,CAAC"}
|
package/dist/fileDialog.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EntityConstruction } from '@flighthq/entity/contract';
|
|
2
|
+
import type { DirectoryOpenDialogResult, FileDialogHandle, FileDialogHandleOperations, FileOpenDialogResult, FileSaveDialogResult, HostDirectoryOpenDialogCapability, HostFileOpenDialogCapability, HostFileSaveDialogCapability, OpenDirectoryDialogOptions, OpenFileDialogOptions, SaveFileDialogOptions } from './types.ts';
|
|
2
3
|
export declare function createFileDialogHandle(kind: FileDialogHandle['kind'], name: string, path: string | null, operations?: FileDialogHandleOperations | null): FileDialogHandle;
|
|
3
4
|
export declare function getFileDialogHandleOperations(handle: Readonly<FileDialogHandle>): Readonly<FileDialogHandleOperations> | null;
|
|
4
5
|
export declare function initializeFileDialogHandle(handle: EntityConstruction<FileDialogHandle>, kind: FileDialogHandle['kind'], name: string, path: string | null, operations?: FileDialogHandleOperations | null): void;
|
|
5
|
-
export declare function showOpenDirectoryDialog(
|
|
6
|
-
export declare function showOpenFileDialog(
|
|
7
|
-
export declare function showSaveFileDialog(
|
|
6
|
+
export declare function showOpenDirectoryDialog(hostDirectoryOpenDialog: Readonly<HostDirectoryOpenDialogCapability>, options?: Readonly<OpenDirectoryDialogOptions>): Promise<DirectoryOpenDialogResult>;
|
|
7
|
+
export declare function showOpenFileDialog(hostFileOpenDialog: Readonly<HostFileOpenDialogCapability>, options: Readonly<OpenFileDialogOptions>): Promise<FileOpenDialogResult>;
|
|
8
|
+
export declare function showSaveFileDialog(hostFileSaveDialog: Readonly<HostFileSaveDialogCapability>, options: Readonly<SaveFileDialogOptions>): Promise<FileSaveDialogResult>;
|
|
8
9
|
//# sourceMappingURL=fileDialog.d.ts.map
|
package/dist/fileDialog.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileDialog.d.ts","sourceRoot":"","sources":["../src/fileDialog.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,yBAAyB,EACzB,gBAAgB,EAChB,0BAA0B,EAE1B,oBAAoB,EACpB,oBAAoB,EACpB,
|
|
1
|
+
{"version":3,"file":"fileDialog.d.ts","sourceRoot":"","sources":["../src/fileDialog.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAGpE,OAAO,KAAK,EACV,yBAAyB,EACzB,gBAAgB,EAChB,0BAA0B,EAE1B,oBAAoB,EACpB,oBAAoB,EACpB,iCAAiC,EACjC,4BAA4B,EAC5B,4BAA4B,EAC5B,0BAA0B,EAC1B,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAEpB,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC,EAC9B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GAAG,IAAI,EACnB,UAAU,GAAE,0BAA0B,GAAG,IAAW,GACnD,gBAAgB,CAIlB;AAID,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,QAAQ,CAAC,gBAAgB,CAAC,GACjC,QAAQ,CAAC,0BAA0B,CAAC,GAAG,IAAI,CAG7C;AAID,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,kBAAkB,CAAC,gBAAgB,CAAC,EAC5C,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC,EAC9B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GAAG,IAAI,EACnB,UAAU,GAAE,0BAA0B,GAAG,IAAW,GACnD,IAAI,CAON;AAED,wBAAgB,uBAAuB,CACrC,uBAAuB,EAAE,QAAQ,CAAC,iCAAiC,CAAC,EACpE,OAAO,CAAC,EAAE,QAAQ,CAAC,0BAA0B,CAAC,GAC7C,OAAO,CAAC,yBAAyB,CAAC,CAEpC;AAED,wBAAgB,kBAAkB,CAChC,kBAAkB,EAAE,QAAQ,CAAC,4BAA4B,CAAC,EAC1D,OAAO,EAAE,QAAQ,CAAC,qBAAqB,CAAC,GACvC,OAAO,CAAC,oBAAoB,CAAC,CAE/B;AAED,wBAAgB,kBAAkB,CAChC,kBAAkB,EAAE,QAAQ,CAAC,4BAA4B,CAAC,EAC1D,OAAO,EAAE,QAAQ,CAAC,qBAAqB,CAAC,GACvC,OAAO,CAAC,oBAAoB,CAAC,CAE/B"}
|
package/dist/fileDialog.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { allocateEntity, createEntityRuntime
|
|
2
|
-
import { EntityRuntimeKey } from '@flighthq/
|
|
1
|
+
import { allocateEntity, createEntityRuntime } from '@flighthq/entity/contract';
|
|
2
|
+
import { EntityRuntimeKey } from '@flighthq/entity/contract';
|
|
3
3
|
export function createFileDialogHandle(kind, name, path, operations = null) {
|
|
4
4
|
const handle = allocateEntity();
|
|
5
5
|
initializeFileDialogHandle(handle, kind, name, path, operations);
|
|
6
|
-
return
|
|
6
|
+
return handle;
|
|
7
7
|
}
|
|
8
8
|
// Provider-neutral access to the handle's package-crossing runtime operations. A deserialized DTO or
|
|
9
9
|
// forged object has no runtime and therefore cannot acquire authority by matching public fields.
|
|
@@ -21,13 +21,13 @@ export function initializeFileDialogHandle(handle, kind, name, path, operations
|
|
|
21
21
|
runtime.operations = operations;
|
|
22
22
|
handle[EntityRuntimeKey] = runtime;
|
|
23
23
|
}
|
|
24
|
-
export function showOpenDirectoryDialog(
|
|
25
|
-
return options === undefined ?
|
|
24
|
+
export function showOpenDirectoryDialog(hostDirectoryOpenDialog, options) {
|
|
25
|
+
return options === undefined ? hostDirectoryOpenDialog.open() : hostDirectoryOpenDialog.open(options);
|
|
26
26
|
}
|
|
27
|
-
export function showOpenFileDialog(
|
|
28
|
-
return
|
|
27
|
+
export function showOpenFileDialog(hostFileOpenDialog, options) {
|
|
28
|
+
return hostFileOpenDialog.open(options);
|
|
29
29
|
}
|
|
30
|
-
export function showSaveFileDialog(
|
|
31
|
-
return
|
|
30
|
+
export function showSaveFileDialog(hostFileSaveDialog, options) {
|
|
31
|
+
return hostFileSaveDialog.save(options);
|
|
32
32
|
}
|
|
33
33
|
//# sourceMappingURL=fileDialog.js.map
|
package/dist/fileDialog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileDialog.js","sourceRoot":"","sources":["../src/fileDialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"fileDialog.js","sourceRoot":"","sources":["../src/fileDialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhF,OAAO,EAAE,gBAAgB,EAAE,MAAM,2B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AA0D,EAC1D,OAAwC;IAExC,OAAO,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { createFileDialogHandle, getFileDialogHandleOperations, showCapturePhotoDialog, showCaptureVideoDialog, showConfirmDialog, showErrorBox, showErrorDialog, showInfoDialog, showMessageDialog, showOpenDirectoryDialog, showOpenFileDialog, showOpenImageDialog, showPromptDialog, showSaveFileDialog, showWarningDialog, } from './contract';
|
|
1
|
+
export { createFileDialogHandle, getFileDialogHandleOperations, showCapturePhotoDialog, showCaptureVideoDialog, showConfirmDialog, showErrorBox, showErrorDialog, showInfoDialog, showMessageDialog, showOpenDirectoryDialog, showOpenFileDialog, showOpenImageDialog, showPromptDialog, showSaveFileDialog, showWarningDialog, } from './contract.ts';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,6BAA6B,EAC7B,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,6BAA6B,EAC7B,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { createFileDialogHandle, getFileDialogHandleOperations, showCapturePhotoDialog, showCaptureVideoDialog, showConfirmDialog, showErrorBox, showErrorDialog, showInfoDialog, showMessageDialog, showOpenDirectoryDialog, showOpenFileDialog, showOpenImageDialog, showPromptDialog, showSaveFileDialog, showWarningDialog, } from './contract';
|
|
1
|
+
export { createFileDialogHandle, getFileDialogHandleOperations, showCapturePhotoDialog, showCaptureVideoDialog, showConfirmDialog, showErrorBox, showErrorDialog, showInfoDialog, showMessageDialog, showOpenDirectoryDialog, showOpenFileDialog, showOpenImageDialog, showPromptDialog, showSaveFileDialog, showWarningDialog, } from './contract.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,6BAA6B,EAC7B,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,6BAA6B,EAC7B,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,eAAe,CAAC"}
|
package/dist/mediaDialog.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CapturePhotoDialogOptions, CaptureVideoDialogOptions,
|
|
2
|
-
export declare function showCapturePhotoDialog(
|
|
3
|
-
export declare function showCaptureVideoDialog(
|
|
4
|
-
export declare function showOpenImageDialog(
|
|
1
|
+
import type { CapturePhotoDialogOptions, CaptureVideoDialogOptions, HostImageOpenDialogCapability, HostPhotoCaptureDialogCapability, HostVideoCaptureDialogCapability, ImageOpenDialogResult, OpenImageDialogOptions, PhotoCaptureDialogResult, VideoCaptureDialogResult } from './types.ts';
|
|
2
|
+
export declare function showCapturePhotoDialog(hostPhotoCaptureDialog: Readonly<HostPhotoCaptureDialogCapability>, options?: Readonly<CapturePhotoDialogOptions>): Promise<PhotoCaptureDialogResult>;
|
|
3
|
+
export declare function showCaptureVideoDialog(hostVideoCaptureDialog: Readonly<HostVideoCaptureDialogCapability>, options?: Readonly<CaptureVideoDialogOptions>): Promise<VideoCaptureDialogResult>;
|
|
4
|
+
export declare function showOpenImageDialog(hostImageOpenDialog: Readonly<HostImageOpenDialogCapability>, options?: Readonly<OpenImageDialogOptions>): Promise<ImageOpenDialogResult>;
|
|
5
5
|
//# sourceMappingURL=mediaDialog.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mediaDialog.d.ts","sourceRoot":"","sources":["../src/mediaDialog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,yBAAyB,EACzB,
|
|
1
|
+
{"version":3,"file":"mediaDialog.d.ts","sourceRoot":"","sources":["../src/mediaDialog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,yBAAyB,EACzB,6BAA6B,EAC7B,gCAAgC,EAChC,gCAAgC,EAChC,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,EACzB,MAAM,YAAY,CAAC;AAEpB,wBAAgB,sBAAsB,CACpC,sBAAsB,EAAE,QAAQ,CAAC,gCAAgC,CAAC,EAClE,OAAO,CAAC,EAAE,QAAQ,CAAC,yBAAyB,CAAC,GAC5C,OAAO,CAAC,wBAAwB,CAAC,CAEnC;AAED,wBAAgB,sBAAsB,CACpC,sBAAsB,EAAE,QAAQ,CAAC,gCAAgC,CAAC,EAClE,OAAO,CAAC,EAAE,QAAQ,CAAC,yBAAyB,CAAC,GAC5C,OAAO,CAAC,wBAAwB,CAAC,CAEnC;AAED,wBAAgB,mBAAmB,CACjC,mBAAmB,EAAE,QAAQ,CAAC,6BAA6B,CAAC,EAC5D,OAAO,CAAC,EAAE,QAAQ,CAAC,sBAAsB,CAAC,GACzC,OAAO,CAAC,qBAAqB,CAAC,CAEhC"}
|
package/dist/mediaDialog.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export function showCapturePhotoDialog(
|
|
2
|
-
return options === undefined ?
|
|
1
|
+
export function showCapturePhotoDialog(hostPhotoCaptureDialog, options) {
|
|
2
|
+
return options === undefined ? hostPhotoCaptureDialog.capture() : hostPhotoCaptureDialog.capture(options);
|
|
3
3
|
}
|
|
4
|
-
export function showCaptureVideoDialog(
|
|
5
|
-
return options === undefined ?
|
|
4
|
+
export function showCaptureVideoDialog(hostVideoCaptureDialog, options) {
|
|
5
|
+
return options === undefined ? hostVideoCaptureDialog.capture() : hostVideoCaptureDialog.capture(options);
|
|
6
6
|
}
|
|
7
|
-
export function showOpenImageDialog(
|
|
8
|
-
return options === undefined ?
|
|
7
|
+
export function showOpenImageDialog(hostImageOpenDialog, options) {
|
|
8
|
+
return options === undefined ? hostImageOpenDialog.open() : hostImageOpenDialog.open(options);
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=mediaDialog.js.map
|
package/dist/mediaDialog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mediaDialog.js","sourceRoot":"","sources":["../src/mediaDialog.ts"],"names":[],"mappings":"AAYA,MAAM,UAAU,sBAAsB,CACpC,
|
|
1
|
+
{"version":3,"file":"mediaDialog.js","sourceRoot":"","sources":["../src/mediaDialog.ts"],"names":[],"mappings":"AAYA,MAAM,UAAU,sBAAsB,CACpC,sBAAkE,EAClE,OAA6C;IAE7C,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,sBAAsB,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,sBAAsB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AAC5G,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,sBAAkE,EAClE,OAA6C;IAE7C,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,sBAAsB,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,sBAAsB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AAC5G,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,mBAA4D,EAC5D,OAA0C;IAE1C,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,mBAAmB,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAChG,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import type { AppWindow } from '@flighthq/app/contract';
|
|
2
|
+
import type { EntityRaw, EntityRuntime, EntityRuntimeKey } from '@flighthq/entity/contract';
|
|
3
|
+
export interface FileDialogFilter {
|
|
4
|
+
readonly accept: Readonly<Record<string, readonly string[]>>;
|
|
5
|
+
readonly name: string;
|
|
6
|
+
}
|
|
7
|
+
export interface FileDialogHandle extends EntityRaw {
|
|
8
|
+
[EntityRuntimeKey]: EntityRuntime | undefined;
|
|
9
|
+
readonly kind: 'File' | 'Directory';
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly path: string | null;
|
|
12
|
+
}
|
|
13
|
+
export interface FileDialogHandleOperations {
|
|
14
|
+
readonly readBinary?: (signal?: AbortSignal) => Promise<Uint8Array | null>;
|
|
15
|
+
readonly readText?: (signal?: AbortSignal) => Promise<string | null>;
|
|
16
|
+
readonly writeBinary?: (data: Readonly<Uint8Array>, signal?: AbortSignal) => Promise<boolean>;
|
|
17
|
+
readonly writeText?: (data: string, signal?: AbortSignal) => Promise<boolean>;
|
|
18
|
+
}
|
|
19
|
+
export interface FileDialogHandleRuntime extends EntityRuntime {
|
|
20
|
+
operations: FileDialogHandleOperations | null;
|
|
21
|
+
}
|
|
22
|
+
export interface OpenFileDialogOptions {
|
|
23
|
+
readonly filters?: readonly FileDialogFilter[];
|
|
24
|
+
readonly multiple?: boolean;
|
|
25
|
+
readonly signal?: AbortSignal;
|
|
26
|
+
}
|
|
27
|
+
export interface OpenDirectoryDialogOptions {
|
|
28
|
+
readonly signal?: AbortSignal;
|
|
29
|
+
}
|
|
30
|
+
export interface SaveFileDialogOptions {
|
|
31
|
+
readonly defaultName?: string;
|
|
32
|
+
readonly filters?: readonly FileDialogFilter[];
|
|
33
|
+
readonly signal?: AbortSignal;
|
|
34
|
+
}
|
|
35
|
+
export type FileOpenDialogResult = {
|
|
36
|
+
readonly handles: readonly [FileDialogHandle, ...FileDialogHandle[]];
|
|
37
|
+
readonly outcome: 'selected';
|
|
38
|
+
} | {
|
|
39
|
+
readonly outcome: 'cancelled' | 'runtime-unavailable' | 'security-denied' | 'file-open-failed';
|
|
40
|
+
};
|
|
41
|
+
export type DirectoryOpenDialogResult = {
|
|
42
|
+
readonly handle: FileDialogHandle;
|
|
43
|
+
readonly outcome: 'selected';
|
|
44
|
+
} | {
|
|
45
|
+
readonly outcome: 'cancelled' | 'runtime-unavailable' | 'security-denied' | 'directory-open-failed';
|
|
46
|
+
};
|
|
47
|
+
export type FileSaveDialogResult = {
|
|
48
|
+
readonly handle: FileDialogHandle;
|
|
49
|
+
readonly outcome: 'selected';
|
|
50
|
+
} | {
|
|
51
|
+
readonly outcome: 'cancelled' | 'runtime-unavailable' | 'security-denied' | 'file-save-failed';
|
|
52
|
+
};
|
|
53
|
+
export interface OpenImageDialogOptions {
|
|
54
|
+
readonly signal?: AbortSignal;
|
|
55
|
+
}
|
|
56
|
+
export type MediaCaptureDialogFacingMode = 'environment' | 'user';
|
|
57
|
+
export interface CapturePhotoDialogOptions {
|
|
58
|
+
readonly facingMode?: MediaCaptureDialogFacingMode;
|
|
59
|
+
readonly signal?: AbortSignal;
|
|
60
|
+
}
|
|
61
|
+
export interface CaptureVideoDialogOptions {
|
|
62
|
+
readonly facingMode?: MediaCaptureDialogFacingMode;
|
|
63
|
+
readonly signal?: AbortSignal;
|
|
64
|
+
}
|
|
65
|
+
export interface DialogImage {
|
|
66
|
+
readonly dataUrl: string;
|
|
67
|
+
readonly height: number;
|
|
68
|
+
readonly mimeType: string;
|
|
69
|
+
readonly width: number;
|
|
70
|
+
}
|
|
71
|
+
export interface DialogVideo {
|
|
72
|
+
readonly dataUrl: string;
|
|
73
|
+
readonly duration: number;
|
|
74
|
+
readonly mimeType: string;
|
|
75
|
+
}
|
|
76
|
+
export type ImageOpenDialogResult = {
|
|
77
|
+
readonly image: DialogImage;
|
|
78
|
+
readonly outcome: 'selected';
|
|
79
|
+
} | {
|
|
80
|
+
readonly outcome: 'cancelled' | 'runtime-unavailable' | 'security-denied' | 'image-open-failed';
|
|
81
|
+
};
|
|
82
|
+
export type PhotoCaptureDialogResult = {
|
|
83
|
+
readonly outcome: 'selected';
|
|
84
|
+
readonly photo: DialogImage;
|
|
85
|
+
} | {
|
|
86
|
+
readonly outcome: 'cancelled' | 'runtime-unavailable' | 'security-denied' | 'photo-capture-failed';
|
|
87
|
+
};
|
|
88
|
+
export type VideoCaptureDialogResult = {
|
|
89
|
+
readonly outcome: 'selected';
|
|
90
|
+
readonly video: DialogVideo;
|
|
91
|
+
} | {
|
|
92
|
+
readonly outcome: 'cancelled' | 'runtime-unavailable' | 'security-denied' | 'video-capture-failed';
|
|
93
|
+
};
|
|
94
|
+
export interface PromptDialogOptions {
|
|
95
|
+
title?: string;
|
|
96
|
+
message: string;
|
|
97
|
+
defaultValue?: string;
|
|
98
|
+
placeholder?: string;
|
|
99
|
+
parentWindow?: AppWindow;
|
|
100
|
+
signal?: AbortSignal;
|
|
101
|
+
}
|
|
102
|
+
export type MessageDialogKind = 'info' | 'warning' | 'error' | 'question';
|
|
103
|
+
export interface MessageDialogOptions {
|
|
104
|
+
title?: string;
|
|
105
|
+
message: string;
|
|
106
|
+
detail?: string;
|
|
107
|
+
buttons?: string[];
|
|
108
|
+
kind?: MessageDialogKind;
|
|
109
|
+
checkboxLabel?: string;
|
|
110
|
+
checkboxChecked?: boolean;
|
|
111
|
+
defaultId?: number;
|
|
112
|
+
cancelId?: number;
|
|
113
|
+
parentWindow?: AppWindow;
|
|
114
|
+
signal?: AbortSignal;
|
|
115
|
+
}
|
|
116
|
+
export interface MessageDialogResult {
|
|
117
|
+
buttonIndex: number;
|
|
118
|
+
cancelled: boolean;
|
|
119
|
+
checkboxChecked: boolean;
|
|
120
|
+
}
|
|
121
|
+
export interface HostDirectoryOpenDialogCapability {
|
|
122
|
+
open(options?: Readonly<OpenDirectoryDialogOptions>): Promise<DirectoryOpenDialogResult>;
|
|
123
|
+
}
|
|
124
|
+
export interface HostFileOpenDialogCapability {
|
|
125
|
+
open(options: Readonly<OpenFileDialogOptions>): Promise<FileOpenDialogResult>;
|
|
126
|
+
}
|
|
127
|
+
export interface HostFileSaveDialogCapability {
|
|
128
|
+
save(options: Readonly<SaveFileDialogOptions>): Promise<FileSaveDialogResult>;
|
|
129
|
+
}
|
|
130
|
+
export interface HostImageOpenDialogCapability {
|
|
131
|
+
open(options?: Readonly<OpenImageDialogOptions>): Promise<ImageOpenDialogResult>;
|
|
132
|
+
}
|
|
133
|
+
export interface HostMessageDialogCapability {
|
|
134
|
+
confirm(options: Readonly<MessageDialogOptions>): Promise<boolean>;
|
|
135
|
+
message(options: Readonly<MessageDialogOptions>): Promise<MessageDialogResult>;
|
|
136
|
+
}
|
|
137
|
+
export interface HostPhotoCaptureDialogCapability {
|
|
138
|
+
capture(options?: Readonly<CapturePhotoDialogOptions>): Promise<PhotoCaptureDialogResult>;
|
|
139
|
+
}
|
|
140
|
+
export interface HostPromptDialogCapability {
|
|
141
|
+
prompt(options: Readonly<PromptDialogOptions>): Promise<string | null>;
|
|
142
|
+
}
|
|
143
|
+
export interface HostVideoCaptureDialogCapability {
|
|
144
|
+
capture(options?: Readonly<CaptureVideoDialogOptions>): Promise<VideoCaptureDialogResult>;
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAI5F,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,CAAC;IAC7D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAKD,MAAM,WAAW,gBAAiB,SAAQ,SAAS;IACjD,CAAC,gBAAgB,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAID,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IAC3E,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACrE,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ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;IAC/C,OAAO,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,yBAAyB,CAAC,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;CAC3F"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/dialog",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"author": "Joshua Granick and other contributors",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -32,17 +32,19 @@
|
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "tsc -b",
|
|
34
34
|
"clean": "tsc -b --clean",
|
|
35
|
+
"generate": "tsx ../../scripts/generate-rust-package.ts --crate flight-dialog --package dialog",
|
|
36
|
+
"generate:check": "tsx ../../scripts/generate-rust-package.ts --crate flight-dialog --package dialog --check",
|
|
35
37
|
"test": "vitest run --config vitest.config.ts",
|
|
36
38
|
"test:watch": "vitest --watch --config vitest.config.ts",
|
|
37
39
|
"prepack": "npm run clean && npm run clean:dist && npm run build",
|
|
38
40
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
39
41
|
},
|
|
40
42
|
"dependencies": {
|
|
41
|
-
"@flighthq/
|
|
42
|
-
"@flighthq/
|
|
43
|
+
"@flighthq/app": "0.6.0",
|
|
44
|
+
"@flighthq/entity": "0.6.0"
|
|
43
45
|
},
|
|
44
46
|
"devDependencies": {
|
|
45
|
-
"typescript": "^
|
|
47
|
+
"typescript": "^7.0.2"
|
|
46
48
|
},
|
|
47
49
|
"description": "Host-explicit open/save file, message, confirm, and prompt dialog operations",
|
|
48
50
|
"sideEffects": false
|
package/src/dialog.test.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { allocateEntity
|
|
2
|
-
import type { EntityWithoutRuntime, MessageDialogBackend, PromptDialogBackend } from '@flighthq/types/contract';
|
|
1
|
+
import { allocateEntity } from '@flighthq/entity/contract';
|
|
3
2
|
|
|
4
3
|
import {
|
|
5
|
-
initializeWebMessageDialogBackend,
|
|
6
|
-
initializeWebPromptDialogBackend,
|
|
7
4
|
showConfirmDialog,
|
|
8
5
|
showErrorBox,
|
|
9
6
|
showErrorDialog,
|
|
@@ -11,29 +8,28 @@ import {
|
|
|
11
8
|
showMessageDialog,
|
|
12
9
|
showPromptDialog,
|
|
13
10
|
showWarningDialog,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} from './dialog';
|
|
11
|
+
} from './dialog.ts';
|
|
12
|
+
import type { HostMessageDialogCapability } from './types.ts';
|
|
17
13
|
|
|
18
14
|
function fakeHost() {
|
|
19
15
|
return {
|
|
20
16
|
dialog: {
|
|
21
17
|
message: (() => {
|
|
22
|
-
const out = allocateEntity<any>();
|
|
18
|
+
const out = allocateEntity<any>() as any;
|
|
23
19
|
out.confirm = async () => {
|
|
24
20
|
return true;
|
|
25
21
|
};
|
|
26
22
|
out.message = async () => {
|
|
27
23
|
return { buttonIndex: 2, cancelled: false, checkboxChecked: false };
|
|
28
24
|
};
|
|
29
|
-
return
|
|
25
|
+
return out;
|
|
30
26
|
})(),
|
|
31
27
|
prompt: (() => {
|
|
32
|
-
const out = allocateEntity<any>();
|
|
28
|
+
const out = allocateEntity<any>() as any;
|
|
33
29
|
out.prompt = async () => {
|
|
34
30
|
return 'typed';
|
|
35
31
|
};
|
|
36
|
-
return
|
|
32
|
+
return out;
|
|
37
33
|
})(),
|
|
38
34
|
},
|
|
39
35
|
};
|
|
@@ -43,35 +39,23 @@ function severityHost(observed: string[]) {
|
|
|
43
39
|
return {
|
|
44
40
|
dialog: {
|
|
45
41
|
message: (() => {
|
|
46
|
-
const out = allocateEntity<any>();
|
|
42
|
+
const out = allocateEntity<any>() as any;
|
|
47
43
|
out.confirm = async () => {
|
|
48
44
|
return true;
|
|
49
45
|
};
|
|
50
|
-
out.message = async (options: Parameters<
|
|
46
|
+
out.message = async (options: Parameters<HostMessageDialogCapability['message']>[0]) => {
|
|
51
47
|
observed.push(options.kind ?? 'none');
|
|
52
48
|
return { buttonIndex: 0, cancelled: false, checkboxChecked: false };
|
|
53
49
|
};
|
|
54
|
-
return
|
|
50
|
+
return out;
|
|
55
51
|
})(),
|
|
56
52
|
},
|
|
57
53
|
};
|
|
58
54
|
}
|
|
59
55
|
|
|
60
|
-
describe('initializeWebMessageDialogBackend', () => {
|
|
61
|
-
it('is the construction initializer of createWebMessageDialogBackend', () => {
|
|
62
|
-
expect(typeof initializeWebMessageDialogBackend).toBe('function');
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
describe('initializeWebPromptDialogBackend', () => {
|
|
67
|
-
it('is the construction initializer of createWebPromptDialogBackend', () => {
|
|
68
|
-
expect(typeof initializeWebPromptDialogBackend).toBe('function');
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
|
|
72
56
|
describe('showConfirmDialog', () => {
|
|
73
57
|
it('delegates confirmation through the explicit message slot', async () => {
|
|
74
|
-
expect(await showConfirmDialog(fakeHost(), { message: 'sure?' })).toBe(true);
|
|
58
|
+
expect(await showConfirmDialog(fakeHost().dialog.message, { message: 'sure?' })).toBe(true);
|
|
75
59
|
});
|
|
76
60
|
|
|
77
61
|
it('forwards a live signal through the explicit message slot', async () => {
|
|
@@ -79,15 +63,15 @@ describe('showConfirmDialog', () => {
|
|
|
79
63
|
const host = {
|
|
80
64
|
dialog: {
|
|
81
65
|
message: (() => {
|
|
82
|
-
const out = allocateEntity<any>();
|
|
66
|
+
const out = allocateEntity<any>() as any;
|
|
83
67
|
out.confirm = confirm;
|
|
84
68
|
out.message = vi.fn();
|
|
85
|
-
return
|
|
69
|
+
return out;
|
|
86
70
|
})(),
|
|
87
71
|
},
|
|
88
72
|
};
|
|
89
73
|
const signal = new AbortController().signal;
|
|
90
|
-
await showConfirmDialog(host, { message: 'sure?', signal });
|
|
74
|
+
await showConfirmDialog(host.dialog.message, { message: 'sure?', signal });
|
|
91
75
|
expect(confirm).toHaveBeenCalledWith({ message: 'sure?', signal });
|
|
92
76
|
});
|
|
93
77
|
});
|
|
@@ -95,7 +79,7 @@ describe('showConfirmDialog', () => {
|
|
|
95
79
|
describe('showErrorBox', () => {
|
|
96
80
|
it('maps the error-box convenience call to error severity', async () => {
|
|
97
81
|
const observed: string[] = [];
|
|
98
|
-
await showErrorBox(severityHost(observed), 'Fatal', 'boom');
|
|
82
|
+
await showErrorBox(severityHost(observed).dialog.message, 'Fatal', 'boom');
|
|
99
83
|
expect(observed).toEqual(['error']);
|
|
100
84
|
});
|
|
101
85
|
});
|
|
@@ -103,7 +87,7 @@ describe('showErrorBox', () => {
|
|
|
103
87
|
describe('showErrorDialog', () => {
|
|
104
88
|
it('maps the error convenience call to error severity', async () => {
|
|
105
89
|
const observed: string[] = [];
|
|
106
|
-
await showErrorDialog(severityHost(observed), { message: 'boom' });
|
|
90
|
+
await showErrorDialog(severityHost(observed).dialog.message, { message: 'boom' });
|
|
107
91
|
expect(observed).toEqual(['error']);
|
|
108
92
|
});
|
|
109
93
|
});
|
|
@@ -111,39 +95,26 @@ describe('showErrorDialog', () => {
|
|
|
111
95
|
describe('showInfoDialog', () => {
|
|
112
96
|
it('maps the info convenience call to info severity', async () => {
|
|
113
97
|
const observed: string[] = [];
|
|
114
|
-
await showInfoDialog(severityHost(observed), { message: 'note' });
|
|
98
|
+
await showInfoDialog(severityHost(observed).dialog.message, { message: 'note' });
|
|
115
99
|
expect(observed).toEqual(['info']);
|
|
116
100
|
});
|
|
117
101
|
});
|
|
118
102
|
|
|
119
103
|
describe('showMessageDialog', () => {
|
|
120
104
|
it('delegates messages through the explicit message slot', async () => {
|
|
121
|
-
expect((await showMessageDialog(fakeHost(), { message: 'hello' })).buttonIndex).toBe(2);
|
|
105
|
+
expect((await showMessageDialog(fakeHost().dialog.message, { message: 'hello' })).buttonIndex).toBe(2);
|
|
122
106
|
});
|
|
123
107
|
});
|
|
124
108
|
describe('showPromptDialog', () => {
|
|
125
109
|
it('delegates prompts through the explicit prompt slot', async () => {
|
|
126
|
-
expect(await showPromptDialog(fakeHost(), { message: 'name?' })).toBe('typed');
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
it('keeps the existing browser message and prompt providers callable', async () => {
|
|
130
|
-
expect(typeof (await webMessageDialogBackend.confirm({ message: 'sure?' }))).toBe('boolean');
|
|
131
|
-
expect(webPromptDialogBackend.prompt({ message: 'name?' })).toBeInstanceOf(Promise);
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it('does not open the synchronous browser prompt when already aborted', async () => {
|
|
135
|
-
const prompt = vi.spyOn(window, 'prompt');
|
|
136
|
-
const controller = new AbortController();
|
|
137
|
-
controller.abort();
|
|
138
|
-
await expect(webPromptDialogBackend.prompt({ message: 'name?', signal: controller.signal })).resolves.toBeNull();
|
|
139
|
-
expect(prompt).not.toHaveBeenCalled();
|
|
110
|
+
expect(await showPromptDialog(fakeHost().dialog.prompt, { message: 'name?' })).toBe('typed');
|
|
140
111
|
});
|
|
141
112
|
});
|
|
142
113
|
|
|
143
114
|
describe('showWarningDialog', () => {
|
|
144
115
|
it('maps the warning convenience call to warning severity', async () => {
|
|
145
116
|
const observed: string[] = [];
|
|
146
|
-
await showWarningDialog(severityHost(observed), { message: 'careful' });
|
|
117
|
+
await showWarningDialog(severityHost(observed).dialog.message, { message: 'careful' });
|
|
147
118
|
expect(observed).toEqual(['warning']);
|
|
148
119
|
});
|
|
149
120
|
});
|
package/src/fileDialog.test.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { allocateEntity
|
|
2
|
-
import
|
|
3
|
-
import { EntityRuntimeKey } from '@flighthq/types/contract';
|
|
1
|
+
import { allocateEntity } from '@flighthq/entity/contract';
|
|
2
|
+
import { EntityRuntimeKey } from '@flighthq/entity/contract';
|
|
4
3
|
|
|
5
4
|
import {
|
|
6
5
|
createFileDialogHandle,
|
|
@@ -9,7 +8,8 @@ import {
|
|
|
9
8
|
showOpenDirectoryDialog,
|
|
10
9
|
showOpenFileDialog,
|
|
11
10
|
showSaveFileDialog,
|
|
12
|
-
} from './fileDialog';
|
|
11
|
+
} from './fileDialog.ts';
|
|
12
|
+
import type { FileDialogHandle } from './types.ts';
|
|
13
13
|
|
|
14
14
|
function fakeHost() {
|
|
15
15
|
const directory = createFileDialogHandle('Directory', 'mydir', '/tmp/mydir');
|
|
@@ -19,25 +19,25 @@ function fakeHost() {
|
|
|
19
19
|
return {
|
|
20
20
|
dialog: {
|
|
21
21
|
directoryOpen: (() => {
|
|
22
|
-
const out = allocateEntity<any>();
|
|
22
|
+
const out = allocateEntity<any>() as any;
|
|
23
23
|
out.open = async () => {
|
|
24
24
|
return { handle: directory, outcome: 'selected' as const };
|
|
25
25
|
};
|
|
26
|
-
return
|
|
26
|
+
return out;
|
|
27
27
|
})(),
|
|
28
28
|
fileOpen: (() => {
|
|
29
|
-
const out = allocateEntity<any>();
|
|
29
|
+
const out = allocateEntity<any>() as any;
|
|
30
30
|
out.open = async () => {
|
|
31
31
|
return { handles: [first, second] as const, outcome: 'selected' as const };
|
|
32
32
|
};
|
|
33
|
-
return
|
|
33
|
+
return out;
|
|
34
34
|
})(),
|
|
35
35
|
fileSave: (() => {
|
|
36
|
-
const out = allocateEntity<any>();
|
|
36
|
+
const out = allocateEntity<any>() as any;
|
|
37
37
|
out.save = async () => {
|
|
38
38
|
return { handle: saved, outcome: 'selected' as const };
|
|
39
39
|
};
|
|
40
|
-
return
|
|
40
|
+
return out;
|
|
41
41
|
})(),
|
|
42
42
|
},
|
|
43
43
|
};
|
|
@@ -72,7 +72,7 @@ describe('initializeFileDialogHandle', () => {
|
|
|
72
72
|
|
|
73
73
|
describe('showOpenDirectoryDialog', () => {
|
|
74
74
|
it('routes the single-directory operation through its independent capability slot', async () => {
|
|
75
|
-
const result = await showOpenDirectoryDialog(fakeHost());
|
|
75
|
+
const result = await showOpenDirectoryDialog(fakeHost().dialog.directoryOpen);
|
|
76
76
|
expect(result.outcome === 'selected' ? result.handle.kind : null).toBe('Directory');
|
|
77
77
|
});
|
|
78
78
|
|
|
@@ -80,15 +80,15 @@ describe('showOpenDirectoryDialog', () => {
|
|
|
80
80
|
const host = {
|
|
81
81
|
dialog: {
|
|
82
82
|
directoryOpen: (() => {
|
|
83
|
-
const out = allocateEntity<any>();
|
|
83
|
+
const out = allocateEntity<any>() as any;
|
|
84
84
|
out.open = async () => {
|
|
85
85
|
return { outcome: 'runtime-unavailable' as const };
|
|
86
86
|
};
|
|
87
|
-
return
|
|
87
|
+
return out;
|
|
88
88
|
})(),
|
|
89
89
|
},
|
|
90
90
|
};
|
|
91
|
-
expect((await showOpenDirectoryDialog(host)).outcome).toBe('runtime-unavailable');
|
|
91
|
+
expect((await showOpenDirectoryDialog(host.dialog.directoryOpen)).outcome).toBe('runtime-unavailable');
|
|
92
92
|
});
|
|
93
93
|
|
|
94
94
|
it('forwards cancellation options through the independent capability slot', async () => {
|
|
@@ -96,14 +96,14 @@ describe('showOpenDirectoryDialog', () => {
|
|
|
96
96
|
const host = {
|
|
97
97
|
dialog: {
|
|
98
98
|
directoryOpen: (() => {
|
|
99
|
-
const out = allocateEntity<any>();
|
|
99
|
+
const out = allocateEntity<any>() as any;
|
|
100
100
|
out.open = open;
|
|
101
|
-
return
|
|
101
|
+
return out;
|
|
102
102
|
})(),
|
|
103
103
|
},
|
|
104
104
|
};
|
|
105
105
|
const signal = new AbortController().signal;
|
|
106
|
-
await showOpenDirectoryDialog(host, { signal });
|
|
106
|
+
await showOpenDirectoryDialog(host.dialog.directoryOpen, { signal });
|
|
107
107
|
expect(open).toHaveBeenCalledWith({ signal });
|
|
108
108
|
});
|
|
109
109
|
});
|
|
@@ -113,7 +113,7 @@ describe('showOpenFileDialog', () => {
|
|
|
113
113
|
const signal = new AbortController().signal;
|
|
114
114
|
const host = fakeHost();
|
|
115
115
|
const open = vi.spyOn(host.dialog.fileOpen, 'open');
|
|
116
|
-
const result = await showOpenFileDialog(host, { multiple: true, signal });
|
|
116
|
+
const result = await showOpenFileDialog(host.dialog.fileOpen, { multiple: true, signal });
|
|
117
117
|
expect(result.outcome === 'selected' ? result.handles.length : 0).toBe(2);
|
|
118
118
|
expect(open).toHaveBeenCalledWith({ multiple: true, signal });
|
|
119
119
|
});
|
|
@@ -122,20 +122,20 @@ describe('showOpenFileDialog', () => {
|
|
|
122
122
|
const host = {
|
|
123
123
|
dialog: {
|
|
124
124
|
fileOpen: (() => {
|
|
125
|
-
const out = allocateEntity<any>();
|
|
125
|
+
const out = allocateEntity<any>() as any;
|
|
126
126
|
out.open = async () => {
|
|
127
127
|
return { outcome: 'security-denied' as const };
|
|
128
128
|
};
|
|
129
|
-
return
|
|
129
|
+
return out;
|
|
130
130
|
})(),
|
|
131
131
|
},
|
|
132
132
|
};
|
|
133
|
-
expect((await showOpenFileDialog(host, {})).outcome).toBe('security-denied');
|
|
133
|
+
expect((await showOpenFileDialog(host.dialog.fileOpen, {})).outcome).toBe('security-denied');
|
|
134
134
|
});
|
|
135
135
|
});
|
|
136
136
|
describe('showSaveFileDialog', () => {
|
|
137
137
|
it('routes file save through its independent capability slot', async () => {
|
|
138
|
-
const result = await showSaveFileDialog(fakeHost(), { defaultName: 'out.txt' });
|
|
138
|
+
const result = await showSaveFileDialog(fakeHost().dialog.fileSave, { defaultName: 'out.txt' });
|
|
139
139
|
expect(result.outcome === 'selected' ? result.handle.name : null).toBe('out.txt');
|
|
140
140
|
});
|
|
141
141
|
|
|
@@ -143,14 +143,14 @@ describe('showSaveFileDialog', () => {
|
|
|
143
143
|
const host = {
|
|
144
144
|
dialog: {
|
|
145
145
|
fileSave: (() => {
|
|
146
|
-
const out = allocateEntity<any>();
|
|
146
|
+
const out = allocateEntity<any>() as any;
|
|
147
147
|
out.save = async () => {
|
|
148
148
|
return { outcome: 'file-save-failed' as const };
|
|
149
149
|
};
|
|
150
|
-
return
|
|
150
|
+
return out;
|
|
151
151
|
})(),
|
|
152
152
|
},
|
|
153
153
|
};
|
|
154
|
-
expect((await showSaveFileDialog(host, {})).outcome).toBe('file-save-failed');
|
|
154
|
+
expect((await showSaveFileDialog(host.dialog.fileSave, {})).outcome).toBe('file-save-failed');
|
|
155
155
|
});
|
|
156
156
|
});
|
package/src/mediaDialog.test.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import { allocateEntity
|
|
1
|
+
import { allocateEntity } from '@flighthq/entity/contract';
|
|
2
|
+
|
|
3
|
+
import { showCapturePhotoDialog, showCaptureVideoDialog, showOpenImageDialog } from './mediaDialog.ts';
|
|
2
4
|
import type {
|
|
3
5
|
CapturePhotoDialogOptions,
|
|
4
6
|
CaptureVideoDialogOptions,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
ImageOpenDialogBackend,
|
|
7
|
+
HostImageOpenDialogCapability,
|
|
8
|
+
HostPhotoCaptureDialogCapability,
|
|
9
|
+
HostVideoCaptureDialogCapability,
|
|
9
10
|
OpenImageDialogOptions,
|
|
10
|
-
|
|
11
|
-
VideoCaptureDialogBackend,
|
|
12
|
-
} from '@flighthq/types/contract';
|
|
13
|
-
|
|
14
|
-
import { showCapturePhotoDialog, showCaptureVideoDialog, showOpenImageDialog } from './mediaDialog';
|
|
11
|
+
} from './types.ts';
|
|
15
12
|
|
|
16
13
|
describe('showCapturePhotoDialog', () => {
|
|
17
14
|
it('routes capture through the explicit photo-capture slot and forwards options', async () => {
|
|
@@ -19,12 +16,12 @@ describe('showCapturePhotoDialog', () => {
|
|
|
19
16
|
outcome: 'selected' as const,
|
|
20
17
|
photo: { dataUrl: 'data:image/png;base64,AA==', height: 480, mimeType: 'image/png', width: 640 },
|
|
21
18
|
}));
|
|
22
|
-
const host:
|
|
19
|
+
const host: { readonly dialog: { readonly photoCapture: HostPhotoCaptureDialogCapability } } = {
|
|
23
20
|
dialog: {
|
|
24
21
|
photoCapture: (() => {
|
|
25
22
|
const out = allocateEntity<any>();
|
|
26
23
|
out.capture = capture;
|
|
27
|
-
return
|
|
24
|
+
return out as HostPhotoCaptureDialogCapability;
|
|
28
25
|
})(),
|
|
29
26
|
},
|
|
30
27
|
};
|
|
@@ -33,7 +30,7 @@ describe('showCapturePhotoDialog', () => {
|
|
|
33
30
|
signal: new AbortController().signal,
|
|
34
31
|
};
|
|
35
32
|
|
|
36
|
-
const result = await showCapturePhotoDialog(host, options);
|
|
33
|
+
const result = await showCapturePhotoDialog(host.dialog.photoCapture, options);
|
|
37
34
|
|
|
38
35
|
expect(result.outcome === 'selected' ? result.photo.width : 0).toBe(640);
|
|
39
36
|
expect(capture).toHaveBeenCalledWith(options);
|
|
@@ -41,17 +38,17 @@ describe('showCapturePhotoDialog', () => {
|
|
|
41
38
|
|
|
42
39
|
it('preserves the operation-specific failure outcome', async () => {
|
|
43
40
|
const capture = async () => ({ outcome: 'photo-capture-failed' as const });
|
|
44
|
-
const host:
|
|
41
|
+
const host: { readonly dialog: { readonly photoCapture: HostPhotoCaptureDialogCapability } } = {
|
|
45
42
|
dialog: {
|
|
46
43
|
photoCapture: (() => {
|
|
47
44
|
const out = allocateEntity<any>();
|
|
48
45
|
out.capture = capture;
|
|
49
|
-
return
|
|
46
|
+
return out as HostPhotoCaptureDialogCapability;
|
|
50
47
|
})(),
|
|
51
48
|
},
|
|
52
49
|
};
|
|
53
50
|
|
|
54
|
-
expect(await showCapturePhotoDialog(host)).toEqual({ outcome: 'photo-capture-failed' });
|
|
51
|
+
expect(await showCapturePhotoDialog(host.dialog.photoCapture)).toEqual({ outcome: 'photo-capture-failed' });
|
|
55
52
|
});
|
|
56
53
|
});
|
|
57
54
|
|
|
@@ -61,18 +58,18 @@ describe('showCaptureVideoDialog', () => {
|
|
|
61
58
|
outcome: 'selected' as const,
|
|
62
59
|
video: { dataUrl: 'data:video/mp4;base64,AA==', duration: 2.5, mimeType: 'video/mp4' },
|
|
63
60
|
}));
|
|
64
|
-
const host:
|
|
61
|
+
const host: { readonly dialog: { readonly videoCapture: HostVideoCaptureDialogCapability } } = {
|
|
65
62
|
dialog: {
|
|
66
63
|
videoCapture: (() => {
|
|
67
64
|
const out = allocateEntity<any>();
|
|
68
65
|
out.capture = capture;
|
|
69
|
-
return
|
|
66
|
+
return out as HostVideoCaptureDialogCapability;
|
|
70
67
|
})(),
|
|
71
68
|
},
|
|
72
69
|
};
|
|
73
70
|
const options: CaptureVideoDialogOptions = { facingMode: 'environment' };
|
|
74
71
|
|
|
75
|
-
const result = await showCaptureVideoDialog(host, options);
|
|
72
|
+
const result = await showCaptureVideoDialog(host.dialog.videoCapture, options);
|
|
76
73
|
|
|
77
74
|
expect(result.outcome === 'selected' ? result.video.duration : 0).toBe(2.5);
|
|
78
75
|
expect(capture).toHaveBeenCalledWith(options);
|
|
@@ -82,33 +79,33 @@ describe('showCaptureVideoDialog', () => {
|
|
|
82
79
|
describe('showOpenImageDialog', () => {
|
|
83
80
|
it('routes selection through the explicit image-open slot and forwards cancellation', async () => {
|
|
84
81
|
const open = vi.fn(async () => ({ outcome: 'cancelled' as const }));
|
|
85
|
-
const host:
|
|
82
|
+
const host: { readonly dialog: { readonly imageOpen: HostImageOpenDialogCapability } } = {
|
|
86
83
|
dialog: {
|
|
87
84
|
imageOpen: (() => {
|
|
88
85
|
const out = allocateEntity<any>();
|
|
89
86
|
out.open = open;
|
|
90
|
-
return
|
|
87
|
+
return out as HostImageOpenDialogCapability;
|
|
91
88
|
})(),
|
|
92
89
|
},
|
|
93
90
|
};
|
|
94
91
|
const options: OpenImageDialogOptions = { signal: new AbortController().signal };
|
|
95
92
|
|
|
96
|
-
await expect(showOpenImageDialog(host, options)).resolves.toEqual({ outcome: 'cancelled' });
|
|
93
|
+
await expect(showOpenImageDialog(host.dialog.imageOpen, options)).resolves.toEqual({ outcome: 'cancelled' });
|
|
97
94
|
expect(open).toHaveBeenCalledWith(options);
|
|
98
95
|
});
|
|
99
96
|
|
|
100
97
|
it('preserves the operation-specific failure outcome', async () => {
|
|
101
98
|
const open = async () => ({ outcome: 'image-open-failed' as const });
|
|
102
|
-
const host:
|
|
99
|
+
const host: { readonly dialog: { readonly imageOpen: HostImageOpenDialogCapability } } = {
|
|
103
100
|
dialog: {
|
|
104
101
|
imageOpen: (() => {
|
|
105
102
|
const out = allocateEntity<any>();
|
|
106
103
|
out.open = open;
|
|
107
|
-
return
|
|
104
|
+
return out as HostImageOpenDialogCapability;
|
|
108
105
|
})(),
|
|
109
106
|
},
|
|
110
107
|
};
|
|
111
108
|
|
|
112
|
-
expect(await showOpenImageDialog(host)).toEqual({ outcome: 'image-open-failed' });
|
|
109
|
+
expect(await showOpenImageDialog(host.dialog.imageOpen)).toEqual({ outcome: 'image-open-failed' });
|
|
113
110
|
});
|
|
114
111
|
});
|