@flighthq/dialog 0.5.1-next.1069.554a2ac → 0.5.1-next.1197.6a425ce
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/dialog.d.ts +12 -12
- package/dist/dialog.d.ts.map +1 -1
- package/dist/dialog.js +18 -18
- package/dist/dialog.js.map +1 -1
- package/dist/fileDialog.d.ts +4 -4
- package/dist/fileDialog.d.ts.map +1 -1
- package/dist/fileDialog.js +6 -6
- package/dist/fileDialog.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/package.json +3 -3
- package/src/dialog.test.ts +15 -15
- package/src/fileDialog.test.ts +7 -7
- package/src/mediaDialog.test.ts +18 -21
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.5.1-next.
|
|
17
|
-
- [License](https://github.com/flighthq/flight/blob/
|
|
16
|
+
- [Source for @flighthq/dialog@0.5.1-next.1197.6a425ce](https://github.com/flighthq/flight/tree/6a425ce64e6d501dac8218fe625e73d58da88639/packages/dialog)
|
|
17
|
+
- [License](https://github.com/flighthq/flight/blob/6a425ce64e6d501dac8218fe625e73d58da88639/LICENSE.md)
|
package/dist/dialog.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type { EntityConstruction,
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
4
|
-
export declare function initializeWebMessageDialogBackend(out: EntityConstruction<
|
|
5
|
-
export declare function initializeWebPromptDialogBackend(out: EntityConstruction<
|
|
6
|
-
export declare function showConfirmDialog(
|
|
7
|
-
export declare function showErrorBox(
|
|
8
|
-
export declare function showErrorDialog(
|
|
9
|
-
export declare function showInfoDialog(
|
|
10
|
-
export declare function showMessageDialog(
|
|
11
|
-
export declare function showPromptDialog(
|
|
12
|
-
export declare function showWarningDialog(
|
|
1
|
+
import type { EntityConstruction, HostMessageDialogProvider, HostPromptDialogProvider, MessageDialogOptions, MessageDialogResult, PromptDialogOptions } from '@flighthq/types/contract';
|
|
2
|
+
export declare const webHostMessageDialog: HostMessageDialogProvider;
|
|
3
|
+
export declare const webHostPromptDialog: HostPromptDialogProvider;
|
|
4
|
+
export declare function initializeWebMessageDialogBackend(out: EntityConstruction<HostMessageDialogProvider>): void;
|
|
5
|
+
export declare function initializeWebPromptDialogBackend(out: EntityConstruction<HostPromptDialogProvider>): void;
|
|
6
|
+
export declare function showConfirmDialog(hostMessageDialog: Readonly<HostMessageDialogProvider>, options: Readonly<MessageDialogOptions>): Promise<boolean>;
|
|
7
|
+
export declare function showErrorBox(hostMessageDialog: Readonly<HostMessageDialogProvider>, title: string, content: string, signal?: AbortSignal): Promise<MessageDialogResult>;
|
|
8
|
+
export declare function showErrorDialog(hostMessageDialog: Readonly<HostMessageDialogProvider>, options: Readonly<MessageDialogOptions>): Promise<MessageDialogResult>;
|
|
9
|
+
export declare function showInfoDialog(hostMessageDialog: Readonly<HostMessageDialogProvider>, options: Readonly<MessageDialogOptions>): Promise<MessageDialogResult>;
|
|
10
|
+
export declare function showMessageDialog(hostMessageDialog: Readonly<HostMessageDialogProvider>, options: Readonly<MessageDialogOptions>): Promise<MessageDialogResult>;
|
|
11
|
+
export declare function showPromptDialog(hostPromptDialog: Readonly<HostPromptDialogProvider>, options: Readonly<PromptDialogOptions>): Promise<string | null>;
|
|
12
|
+
export declare function showWarningDialog(hostMessageDialog: Readonly<HostMessageDialogProvider>, options: Readonly<MessageDialogOptions>): Promise<MessageDialogResult>;
|
|
13
13
|
//# 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":"AACA,OAAO,KAAK,EACV,kBAAkB,EAClB,
|
|
1
|
+
{"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../src/dialog.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,kBAAkB,EAClB,yBAAyB,EACzB,wBAAwB,EACxB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,0BAA0B,CAAC;AAIlC,eAAO,MAAM,oBAAoB,2BAAkC,CAAC;AACpE,eAAO,MAAM,mBAAmB,0BAAiC,CAAC;AAclE,wBAAgB,iCAAiC,CAAC,GAAG,EAAE,kBAAkB,CAAC,yBAAyB,CAAC,GAAG,IAAI,CAuB1G;AAED,wBAAgB,gCAAgC,CAAC,GAAG,EAAE,kBAAkB,CAAC,wBAAwB,CAAC,GAAG,IAAI,CAUxG;AAED,wBAAgB,iBAAiB,CAC/B,iBAAiB,EAAE,QAAQ,CAAC,yBAAyB,CAAC,EACtD,OAAO,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GACtC,OAAO,CAAC,OAAO,CAAC,CAElB;AAED,wBAAgB,YAAY,CAC1B,iBAAiB,EAAE,QAAQ,CAAC,yBAAyB,CAAC,EACtD,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,mBAAmB,CAAC,CAM9B;AAED,wBAAgB,eAAe,CAC7B,iBAAiB,EAAE,QAAQ,CAAC,yBAAyB,CAAC,EACtD,OAAO,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GACtC,OAAO,CAAC,mBAAmB,CAAC,CAE9B;AAED,wBAAgB,cAAc,CAC5B,iBAAiB,EAAE,QAAQ,CAAC,yBAAyB,CAAC,EACtD,OAAO,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GACtC,OAAO,CAAC,mBAAmB,CAAC,CAE9B;AAED,wBAAgB,iBAAiB,CAC/B,iBAAiB,EAAE,QAAQ,CAAC,yBAAyB,CAAC,EACtD,OAAO,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GACtC,OAAO,CAAC,mBAAmB,CAAC,CAE9B;AAED,wBAAgB,gBAAgB,CAC9B,gBAAgB,EAAE,QAAQ,CAAC,wBAAwB,CAAC,EACpD,OAAO,EAAE,QAAQ,CAAC,mBAAmB,CAAC,GACrC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAExB;AAED,wBAAgB,iBAAiB,CAC/B,iBAAiB,EAAE,QAAQ,CAAC,yBAAyB,CAAC,EACtD,OAAO,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GACtC,OAAO,CAAC,mBAAmB,CAAC,CAE9B"}
|
package/dist/dialog.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
export const
|
|
5
|
-
export const
|
|
2
|
+
// Message and prompt providers stay with their dialog operations; host-web re-exports these canonical
|
|
3
|
+
// identities alongside the file-picker providers it owns.
|
|
4
|
+
export const webHostMessageDialog = createWebMessageDialogBackend();
|
|
5
|
+
export const webHostPromptDialog = createWebPromptDialogBackend();
|
|
6
6
|
function createWebMessageDialogBackend() {
|
|
7
7
|
const out = allocateEntity();
|
|
8
8
|
initializeWebMessageDialogBackend(out);
|
|
@@ -56,27 +56,27 @@ export function initializeWebPromptDialogBackend(out) {
|
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
-
export function showConfirmDialog(
|
|
60
|
-
return
|
|
59
|
+
export function showConfirmDialog(hostMessageDialog, options) {
|
|
60
|
+
return hostMessageDialog.confirm(options);
|
|
61
61
|
}
|
|
62
|
-
export function showErrorBox(
|
|
63
|
-
return
|
|
62
|
+
export function showErrorBox(hostMessageDialog, title, content, signal) {
|
|
63
|
+
return hostMessageDialog.message(signal === undefined
|
|
64
64
|
? { kind: 'error', message: content, title }
|
|
65
65
|
: { kind: 'error', message: content, signal, title });
|
|
66
66
|
}
|
|
67
|
-
export function showErrorDialog(
|
|
68
|
-
return
|
|
67
|
+
export function showErrorDialog(hostMessageDialog, options) {
|
|
68
|
+
return hostMessageDialog.message({ ...options, kind: 'error' });
|
|
69
69
|
}
|
|
70
|
-
export function showInfoDialog(
|
|
71
|
-
return
|
|
70
|
+
export function showInfoDialog(hostMessageDialog, options) {
|
|
71
|
+
return hostMessageDialog.message({ ...options, kind: 'info' });
|
|
72
72
|
}
|
|
73
|
-
export function showMessageDialog(
|
|
74
|
-
return
|
|
73
|
+
export function showMessageDialog(hostMessageDialog, options) {
|
|
74
|
+
return hostMessageDialog.message(options);
|
|
75
75
|
}
|
|
76
|
-
export function showPromptDialog(
|
|
77
|
-
return
|
|
76
|
+
export function showPromptDialog(hostPromptDialog, options) {
|
|
77
|
+
return hostPromptDialog.prompt(options);
|
|
78
78
|
}
|
|
79
|
-
export function showWarningDialog(
|
|
80
|
-
return
|
|
79
|
+
export function showWarningDialog(hostMessageDialog, options) {
|
|
80
|
+
return hostMessageDialog.message({ ...options, kind: 'warning' });
|
|
81
81
|
}
|
|
82
82
|
//# 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":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../src/dialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAUzE,sGAAsG;AACtG,0DAA0D;AAC1D,MAAM,CAAC,MAAM,oBAAoB,GAAG,6BAA6B,EAAE,CA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EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CACvD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,iBAAsD,EACtD,OAAuC;IAEvC,OAAO,iBAAiB,CAAC,OAAO,CAAC,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,iBAAsD,EACtD,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,iBAAsD,EACtD,OAAuC;IAEvC,OAAO,iBAAiB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC9B,gBAAoD,EACpD,OAAsC;IAEtC,OAAO,gBAAgB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,iBAAsD,EACtD,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,8 @@
|
|
|
1
|
-
import type { DirectoryOpenDialogResult, FileDialogHandle, FileDialogHandleOperations, FileOpenDialogResult, FileSaveDialogResult,
|
|
1
|
+
import type { DirectoryOpenDialogResult, FileDialogHandle, FileDialogHandleOperations, FileOpenDialogResult, FileSaveDialogResult, HostDirectoryOpenDialogProvider, HostFileOpenDialogProvider, HostFileSaveDialogProvider, OpenDirectoryDialogOptions, OpenFileDialogOptions, SaveFileDialogOptions, EntityConstruction } from '@flighthq/types/contract';
|
|
2
2
|
export declare function createFileDialogHandle(kind: FileDialogHandle['kind'], name: string, path: string | null, operations?: FileDialogHandleOperations | null): FileDialogHandle;
|
|
3
3
|
export declare function getFileDialogHandleOperations(handle: Readonly<FileDialogHandle>): Readonly<FileDialogHandleOperations> | null;
|
|
4
4
|
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(
|
|
5
|
+
export declare function showOpenDirectoryDialog(hostDirectoryOpenDialog: Readonly<HostDirectoryOpenDialogProvider>, options?: Readonly<OpenDirectoryDialogOptions>): Promise<DirectoryOpenDialogResult>;
|
|
6
|
+
export declare function showOpenFileDialog(hostFileOpenDialog: Readonly<HostFileOpenDialogProvider>, options: Readonly<OpenFileDialogOptions>): Promise<FileOpenDialogResult>;
|
|
7
|
+
export declare function showSaveFileDialog(hostFileSaveDialog: Readonly<HostFileSaveDialogProvider>, options: Readonly<SaveFileDialogOptions>): Promise<FileSaveDialogResult>;
|
|
8
8
|
//# 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,EACV,yBAAyB,EACzB,gBAAgB,EAChB,0BAA0B,EAE1B,oBAAoB,EACpB,oBAAoB,EACpB,+BAA+B,EAC/B,0BAA0B,EAC1B,0BAA0B,EAC1B,0BAA0B,EAC1B,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAGlC,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,+BAA+B,CAAC,EAClE,OAAO,CAAC,EAAE,QAAQ,CAAC,0BAA0B,CAAC,GAC7C,OAAO,CAAC,yBAAyB,CAAC,CAEpC;AAED,wBAAgB,kBAAkB,CAChC,kBAAkB,EAAE,QAAQ,CAAC,0BAA0B,CAAC,EACxD,OAAO,EAAE,QAAQ,CAAC,qBAAqB,CAAC,GACvC,OAAO,CAAC,oBAAoB,CAAC,CAE/B;AAED,wBAAgB,kBAAkB,CAChC,kBAAkB,EAAE,QAAQ,CAAC,0BAA0B,CAAC,EACxD,OAAO,EAAE,QAAQ,CAAC,qBAAqB,CAAC,GACvC,OAAO,CAAC,oBAAoB,CAAC,CAE/B"}
|
package/dist/fileDialog.js
CHANGED
|
@@ -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,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAgB9F,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,MAAM,UAAU,sBAAsB,CACpC,IAA8B,EAC9B,IAAY,EACZ,IAAmB,EACnB,aAAgD,IAAI;IAEpD,MAAM,MAAM,GAAG,cAAc,EAAoB,CAAC;IAClD,0BAA0B,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;IACjE,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC;AAC9B,CAAC;AAED,qGAAqG;AACrG,iGAAiG;AACjG,MAAM,UAAU,6BAA6B,CAC3C,MAAkC;IAElC,MAAM,OAAO,GAAG,MAAM,CAAC,gBAAgB,CAAwC,CAAC;IAChF,OAAO,OAAO,EAAE,UAAU,IAAI,IAAI,CAAC;AACrC,CAAC;AAED,kGAAkG;AAClG,kGAAkG;AAClG,MAAM,UAAU,0BAA0B,CACxC,MAA4C,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AI,GAAG,IAAI,CAAC;IACnB,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,MAAM,OAAO,GAAG,mBAAmB,EAA6B,CAAC;IACjE,OAAO,CAAC,UAAU,GAAG,UAAU,CAAC;IAChC,MAAM,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,uBAAuB,CACrC,uBAAkE,EAClE,OAA8C;IAE9C,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,uBAAuB,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,uBAAuB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACxG,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,kBAAwD,EACxD,OAAwC;IAExC,OAAO,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,kBAAwD,EACxD,OAAwC;IAExC,OAAO,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC1C,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, HostImageOpenDialogProvider, HostPhotoCaptureDialogProvider, HostVideoCaptureDialogProvider, ImageOpenDialogResult, OpenImageDialogOptions, PhotoCaptureDialogResult, VideoCaptureDialogResult } from '@flighthq/types/contract';
|
|
2
|
+
export declare function showCapturePhotoDialog(hostPhotoCaptureDialog: Readonly<HostPhotoCaptureDialogProvider>, options?: Readonly<CapturePhotoDialogOptions>): Promise<PhotoCaptureDialogResult>;
|
|
3
|
+
export declare function showCaptureVideoDialog(hostVideoCaptureDialog: Readonly<HostVideoCaptureDialogProvider>, options?: Readonly<CaptureVideoDialogOptions>): Promise<VideoCaptureDialogResult>;
|
|
4
|
+
export declare function showOpenImageDialog(hostImageOpenDialog: Readonly<HostImageOpenDialogProvider>, 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,2BAA2B,EAC3B,8BAA8B,EAC9B,8BAA8B,EAC9B,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,EACzB,MAAM,0BAA0B,CAAC;AAElC,wBAAgB,sBAAsB,CACpC,sBAAsB,EAAE,QAAQ,CAAC,8BAA8B,CAAC,EAChE,OAAO,CAAC,EAAE,QAAQ,CAAC,yBAAyB,CAAC,GAC5C,OAAO,CAAC,wBAAwB,CAAC,CAEnC;AAED,wBAAgB,sBAAsB,CACpC,sBAAsB,EAAE,QAAQ,CAAC,8BAA8B,CAAC,EAChE,OAAO,CAAC,EAAE,QAAQ,CAAC,yBAAyB,CAAC,GAC5C,OAAO,CAAC,wBAAwB,CAAC,CAEnC;AAED,wBAAgB,mBAAmB,CACjC,mBAAmB,EAAE,QAAQ,CAAC,2BAA2B,CAAC,EAC1D,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,sBAAgE,EAChE,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,sBAAgE,EAChE,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,mBAA0D,EAC1D,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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/dialog",
|
|
3
|
-
"version": "0.5.1-next.
|
|
3
|
+
"version": "0.5.1-next.1197.6a425ce",
|
|
4
4
|
"author": "Joshua Granick and other contributors",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@flighthq/entity": "0.5.1-next.
|
|
42
|
-
"@flighthq/types": "0.5.1-next.
|
|
41
|
+
"@flighthq/entity": "0.5.1-next.1197.6a425ce",
|
|
42
|
+
"@flighthq/types": "0.5.1-next.1197.6a425ce"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"typescript": "^5.3.0"
|
package/src/dialog.test.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
|
-
import type {
|
|
2
|
+
import type { HostMessageDialogProvider } from '@flighthq/types/contract';
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
initializeWebMessageDialogBackend,
|
|
@@ -11,8 +11,8 @@ import {
|
|
|
11
11
|
showMessageDialog,
|
|
12
12
|
showPromptDialog,
|
|
13
13
|
showWarningDialog,
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
webHostMessageDialog,
|
|
15
|
+
webHostPromptDialog,
|
|
16
16
|
} from './dialog';
|
|
17
17
|
|
|
18
18
|
function fakeHost() {
|
|
@@ -47,7 +47,7 @@ function severityHost(observed: string[]) {
|
|
|
47
47
|
out.confirm = async () => {
|
|
48
48
|
return true;
|
|
49
49
|
};
|
|
50
|
-
out.message = async (options: Parameters<
|
|
50
|
+
out.message = async (options: Parameters<HostMessageDialogProvider['message']>[0]) => {
|
|
51
51
|
observed.push(options.kind ?? 'none');
|
|
52
52
|
return { buttonIndex: 0, cancelled: false, checkboxChecked: false };
|
|
53
53
|
};
|
|
@@ -71,7 +71,7 @@ describe('initializeWebPromptDialogBackend', () => {
|
|
|
71
71
|
|
|
72
72
|
describe('showConfirmDialog', () => {
|
|
73
73
|
it('delegates confirmation through the explicit message slot', async () => {
|
|
74
|
-
expect(await showConfirmDialog(fakeHost(), { message: 'sure?' })).toBe(true);
|
|
74
|
+
expect(await showConfirmDialog(fakeHost().dialog.message, { message: 'sure?' })).toBe(true);
|
|
75
75
|
});
|
|
76
76
|
|
|
77
77
|
it('forwards a live signal through the explicit message slot', async () => {
|
|
@@ -87,7 +87,7 @@ describe('showConfirmDialog', () => {
|
|
|
87
87
|
},
|
|
88
88
|
};
|
|
89
89
|
const signal = new AbortController().signal;
|
|
90
|
-
await showConfirmDialog(host, { message: 'sure?', signal });
|
|
90
|
+
await showConfirmDialog(host.dialog.message, { message: 'sure?', signal });
|
|
91
91
|
expect(confirm).toHaveBeenCalledWith({ message: 'sure?', signal });
|
|
92
92
|
});
|
|
93
93
|
});
|
|
@@ -95,7 +95,7 @@ describe('showConfirmDialog', () => {
|
|
|
95
95
|
describe('showErrorBox', () => {
|
|
96
96
|
it('maps the error-box convenience call to error severity', async () => {
|
|
97
97
|
const observed: string[] = [];
|
|
98
|
-
await showErrorBox(severityHost(observed), 'Fatal', 'boom');
|
|
98
|
+
await showErrorBox(severityHost(observed).dialog.message, 'Fatal', 'boom');
|
|
99
99
|
expect(observed).toEqual(['error']);
|
|
100
100
|
});
|
|
101
101
|
});
|
|
@@ -103,7 +103,7 @@ describe('showErrorBox', () => {
|
|
|
103
103
|
describe('showErrorDialog', () => {
|
|
104
104
|
it('maps the error convenience call to error severity', async () => {
|
|
105
105
|
const observed: string[] = [];
|
|
106
|
-
await showErrorDialog(severityHost(observed), { message: 'boom' });
|
|
106
|
+
await showErrorDialog(severityHost(observed).dialog.message, { message: 'boom' });
|
|
107
107
|
expect(observed).toEqual(['error']);
|
|
108
108
|
});
|
|
109
109
|
});
|
|
@@ -111,31 +111,31 @@ describe('showErrorDialog', () => {
|
|
|
111
111
|
describe('showInfoDialog', () => {
|
|
112
112
|
it('maps the info convenience call to info severity', async () => {
|
|
113
113
|
const observed: string[] = [];
|
|
114
|
-
await showInfoDialog(severityHost(observed), { message: 'note' });
|
|
114
|
+
await showInfoDialog(severityHost(observed).dialog.message, { message: 'note' });
|
|
115
115
|
expect(observed).toEqual(['info']);
|
|
116
116
|
});
|
|
117
117
|
});
|
|
118
118
|
|
|
119
119
|
describe('showMessageDialog', () => {
|
|
120
120
|
it('delegates messages through the explicit message slot', async () => {
|
|
121
|
-
expect((await showMessageDialog(fakeHost(), { message: 'hello' })).buttonIndex).toBe(2);
|
|
121
|
+
expect((await showMessageDialog(fakeHost().dialog.message, { message: 'hello' })).buttonIndex).toBe(2);
|
|
122
122
|
});
|
|
123
123
|
});
|
|
124
124
|
describe('showPromptDialog', () => {
|
|
125
125
|
it('delegates prompts through the explicit prompt slot', async () => {
|
|
126
|
-
expect(await showPromptDialog(fakeHost(), { message: 'name?' })).toBe('typed');
|
|
126
|
+
expect(await showPromptDialog(fakeHost().dialog.prompt, { message: 'name?' })).toBe('typed');
|
|
127
127
|
});
|
|
128
128
|
|
|
129
129
|
it('keeps the existing browser message and prompt providers callable', async () => {
|
|
130
|
-
expect(typeof (await
|
|
131
|
-
expect(
|
|
130
|
+
expect(typeof (await webHostMessageDialog.confirm({ message: 'sure?' }))).toBe('boolean');
|
|
131
|
+
expect(webHostPromptDialog.prompt({ message: 'name?' })).toBeInstanceOf(Promise);
|
|
132
132
|
});
|
|
133
133
|
|
|
134
134
|
it('does not open the synchronous browser prompt when already aborted', async () => {
|
|
135
135
|
const prompt = vi.spyOn(window, 'prompt');
|
|
136
136
|
const controller = new AbortController();
|
|
137
137
|
controller.abort();
|
|
138
|
-
await expect(
|
|
138
|
+
await expect(webHostPromptDialog.prompt({ message: 'name?', signal: controller.signal })).resolves.toBeNull();
|
|
139
139
|
expect(prompt).not.toHaveBeenCalled();
|
|
140
140
|
});
|
|
141
141
|
});
|
|
@@ -143,7 +143,7 @@ describe('showPromptDialog', () => {
|
|
|
143
143
|
describe('showWarningDialog', () => {
|
|
144
144
|
it('maps the warning convenience call to warning severity', async () => {
|
|
145
145
|
const observed: string[] = [];
|
|
146
|
-
await showWarningDialog(severityHost(observed), { message: 'careful' });
|
|
146
|
+
await showWarningDialog(severityHost(observed).dialog.message, { message: 'careful' });
|
|
147
147
|
expect(observed).toEqual(['warning']);
|
|
148
148
|
});
|
|
149
149
|
});
|
package/src/fileDialog.test.ts
CHANGED
|
@@ -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
|
|
|
@@ -88,7 +88,7 @@ describe('showOpenDirectoryDialog', () => {
|
|
|
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 () => {
|
|
@@ -103,7 +103,7 @@ describe('showOpenDirectoryDialog', () => {
|
|
|
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
|
});
|
|
@@ -130,12 +130,12 @@ describe('showOpenFileDialog', () => {
|
|
|
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
|
|
|
@@ -151,6 +151,6 @@ describe('showSaveFileDialog', () => {
|
|
|
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
|
@@ -2,13 +2,10 @@ import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
|
2
2
|
import type {
|
|
3
3
|
CapturePhotoDialogOptions,
|
|
4
4
|
CaptureVideoDialogOptions,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
ImageOpenDialogBackend,
|
|
5
|
+
HostImageOpenDialogProvider,
|
|
6
|
+
HostPhotoCaptureDialogProvider,
|
|
7
|
+
HostVideoCaptureDialogProvider,
|
|
9
8
|
OpenImageDialogOptions,
|
|
10
|
-
PhotoCaptureDialogBackend,
|
|
11
|
-
VideoCaptureDialogBackend,
|
|
12
9
|
} from '@flighthq/types/contract';
|
|
13
10
|
|
|
14
11
|
import { showCapturePhotoDialog, showCaptureVideoDialog, showOpenImageDialog } from './mediaDialog';
|
|
@@ -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: HostPhotoCaptureDialogProvider } } = {
|
|
23
20
|
dialog: {
|
|
24
21
|
photoCapture: (() => {
|
|
25
22
|
const out = allocateEntity<any>();
|
|
26
23
|
out.capture = capture;
|
|
27
|
-
return finishEntity(out) as
|
|
24
|
+
return finishEntity(out) as HostPhotoCaptureDialogProvider;
|
|
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: HostPhotoCaptureDialogProvider } } = {
|
|
45
42
|
dialog: {
|
|
46
43
|
photoCapture: (() => {
|
|
47
44
|
const out = allocateEntity<any>();
|
|
48
45
|
out.capture = capture;
|
|
49
|
-
return finishEntity(out) as
|
|
46
|
+
return finishEntity(out) as HostPhotoCaptureDialogProvider;
|
|
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: HostVideoCaptureDialogProvider } } = {
|
|
65
62
|
dialog: {
|
|
66
63
|
videoCapture: (() => {
|
|
67
64
|
const out = allocateEntity<any>();
|
|
68
65
|
out.capture = capture;
|
|
69
|
-
return finishEntity(out) as
|
|
66
|
+
return finishEntity(out) as HostVideoCaptureDialogProvider;
|
|
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: HostImageOpenDialogProvider } } = {
|
|
86
83
|
dialog: {
|
|
87
84
|
imageOpen: (() => {
|
|
88
85
|
const out = allocateEntity<any>();
|
|
89
86
|
out.open = open;
|
|
90
|
-
return finishEntity(out) as
|
|
87
|
+
return finishEntity(out) as HostImageOpenDialogProvider;
|
|
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: HostImageOpenDialogProvider } } = {
|
|
103
100
|
dialog: {
|
|
104
101
|
imageOpen: (() => {
|
|
105
102
|
const out = allocateEntity<any>();
|
|
106
103
|
out.open = open;
|
|
107
|
-
return finishEntity(out) as
|
|
104
|
+
return finishEntity(out) as HostImageOpenDialogProvider;
|
|
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
|
});
|