@flighthq/dialog 0.5.1-next.815.cc08b93 → 0.5.1-next.903.f434bc2
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 +1 -0
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +1 -0
- package/dist/contract.js.map +1 -1
- package/dist/dialog.d.ts +3 -1
- package/dist/dialog.d.ts.map +1 -1
- package/dist/dialog.js +50 -44
- package/dist/dialog.js.map +1 -1
- package/dist/fileDialog.d.ts +2 -1
- package/dist/fileDialog.d.ts.map +1 -1
- package/dist/fileDialog.js +14 -8
- package/dist/fileDialog.js.map +1 -1
- package/package.json +3 -3
- package/src/dialog.test.ts +33 -18
- package/src/fileDialog.test.ts +46 -26
- package/src/mediaDialog.test.ts +32 -6
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.903.f434bc2](https://github.com/flighthq/flight/tree/f434bc233778d75aeea61995df3a8cfaec459a85/packages/dialog)
|
|
17
|
+
- [License](https://github.com/flighthq/flight/blob/f434bc233778d75aeea61995df3a8cfaec459a85/LICENSE.md)
|
package/dist/contract.d.ts
CHANGED
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,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/contract.js
CHANGED
package/dist/contract.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/dialog.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import type { HasDialogMessage, HasDialogPrompt, MessageDialogBackend, MessageDialogOptions, MessageDialogResult, PromptDialogBackend, PromptDialogOptions } from '@flighthq/types/contract';
|
|
1
|
+
import type { EntityConstruction, HasDialogMessage, HasDialogPrompt, MessageDialogBackend, MessageDialogOptions, MessageDialogResult, PromptDialogBackend, PromptDialogOptions } from '@flighthq/types/contract';
|
|
2
2
|
export declare const webMessageDialogBackend: MessageDialogBackend;
|
|
3
3
|
export declare const webPromptDialogBackend: PromptDialogBackend;
|
|
4
|
+
export declare function initializeWebMessageDialogBackend(out: EntityConstruction<MessageDialogBackend>): void;
|
|
5
|
+
export declare function initializeWebPromptDialogBackend(out: EntityConstruction<PromptDialogBackend>): void;
|
|
4
6
|
export declare function showConfirmDialog(host: HasDialogMessage, options: Readonly<MessageDialogOptions>): Promise<boolean>;
|
|
5
7
|
export declare function showErrorBox(host: HasDialogMessage, title: string, content: string, signal?: AbortSignal): Promise<MessageDialogResult>;
|
|
6
8
|
export declare function showErrorDialog(host: HasDialogMessage, options: Readonly<MessageDialogOptions>): Promise<MessageDialogResult>;
|
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,
|
|
1
|
+
{"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../src/dialog.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,0BAA0B,CAAC;AAIlC,eAAO,MAAM,uBAAuB,sBAAkC,CAAC;AACvE,eAAO,MAAM,sBAAsB,qBAAiC,CAAC;AAcrE,wBAAgB,iCAAiC,CAAC,GAAG,EAAE,kBAAkB,CAAC,oBAAoB,CAAC,GAAG,IAAI,CAuBrG;AAED,wBAAgB,gCAAgC,CAAC,GAAG,EAAE,kBAAkB,CAAC,mBAAmB,CAAC,GAAG,IAAI,CAUnG;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAEnH;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,gBAAgB,EACtB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,mBAAmB,CAAC,CAM9B;AAED,wBAAgB,eAAe,CAC7B,IAAI,EAAE,gBAAgB,EACtB,OAAO,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GACtC,OAAO,CAAC,mBAAmB,CAAC,CAE9B;AAED,wBAAgB,cAAc,CAC5B,IAAI,EAAE,gBAAgB,EACtB,OAAO,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GACtC,OAAO,CAAC,mBAAmB,CAAC,CAE9B;AAED,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,gBAAgB,EACtB,OAAO,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GACtC,OAAO,CAAC,mBAAmB,CAAC,CAE9B;AAED,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,QAAQ,CAAC,mBAAmB,CAAC,GACrC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAExB;AAED,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,gBAAgB,EACtB,OAAO,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GACtC,OAAO,CAAC,mBAAmB,CAAC,CAE9B"}
|
package/dist/dialog.js
CHANGED
|
@@ -1,54 +1,60 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
2
|
// These two providers predate the file-dialog split and remain here until their own domain slices move
|
|
3
3
|
// them into host-web. File-picker providers live exclusively in @flighthq/host-web.
|
|
4
4
|
export const webMessageDialogBackend = createWebMessageDialogBackend();
|
|
5
5
|
export const webPromptDialogBackend = createWebPromptDialogBackend();
|
|
6
6
|
function createWebMessageDialogBackend() {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return false;
|
|
11
|
-
if (typeof window === 'undefined' || typeof window.confirm !== 'function')
|
|
12
|
-
return false;
|
|
13
|
-
try {
|
|
14
|
-
return window.confirm(options.message) === true;
|
|
15
|
-
}
|
|
16
|
-
catch {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
async message(options) {
|
|
21
|
-
const checkboxChecked = options.checkboxChecked ?? false;
|
|
22
|
-
if (options.signal?.aborted)
|
|
23
|
-
return { buttonIndex: options.cancelId ?? 0, cancelled: true, checkboxChecked };
|
|
24
|
-
if (typeof window === 'undefined' || typeof window.alert !== 'function') {
|
|
25
|
-
return { buttonIndex: 0, cancelled: false, checkboxChecked };
|
|
26
|
-
}
|
|
27
|
-
try {
|
|
28
|
-
window.alert(options.message);
|
|
29
|
-
}
|
|
30
|
-
catch {
|
|
31
|
-
return { buttonIndex: 0, cancelled: false, checkboxChecked };
|
|
32
|
-
}
|
|
33
|
-
return { buttonIndex: 0, cancelled: false, checkboxChecked };
|
|
34
|
-
},
|
|
35
|
-
});
|
|
7
|
+
const out = allocateEntity();
|
|
8
|
+
initializeWebMessageDialogBackend(out);
|
|
9
|
+
return finishEntity(out);
|
|
36
10
|
}
|
|
37
11
|
function createWebPromptDialogBackend() {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
12
|
+
const out = allocateEntity();
|
|
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
|
+
};
|
|
52
58
|
}
|
|
53
59
|
export function showConfirmDialog(host, options) {
|
|
54
60
|
return host.dialog.message.confirm(options);
|
package/dist/dialog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../src/dialog.ts"],"names":[],"mappings":"AAAA,OAAO,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;AAYzE,uGAAuG;AACvG,oFAAoF;AACpF,MAAM,CAAC,MAAM,uBAAuB,GAAG,6BAA6B,EAAE,CAAC;AACvE,MAAM,CAAC,MAAM,sBAAsB,GAAG,4BAA4B,EAAE,CAAC;AAErE,SAAS,6BAA6B;IACpC,MAAM,GAAG,GAAG,cAAc,EAAwB,CAAC;IACnD,iCAAiC,CAAC,GAAG,CAAC,CAAC;IACvC,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC;AAED,SAAS,4BAA4B;IACnC,MAAM,GAAG,GAAG,cAAc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AAO,EAAE,CAAC,CAAC;AACpE,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,IAAsB,EACtB,OAAuC;IAEvC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,IAAsB,EACtB,OAAuC;IAEvC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC9B,IAAqB,EACrB,OAAsC;IAEtC,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,IAAsB,EACtB,OAAuC;IAEvC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;AACtE,CAAC"}
|
package/dist/fileDialog.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { DirectoryOpenDialogResult, FileDialogHandle, FileDialogHandleOperations, FileOpenDialogResult, FileSaveDialogResult, HasDialogDirectoryOpen, HasDialogFileOpen, HasDialogFileSave, OpenDirectoryDialogOptions, OpenFileDialogOptions, SaveFileDialogOptions } from '@flighthq/types/contract';
|
|
1
|
+
import type { DirectoryOpenDialogResult, FileDialogHandle, FileDialogHandleOperations, FileOpenDialogResult, FileSaveDialogResult, HasDialogDirectoryOpen, HasDialogFileOpen, HasDialogFileSave, 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
|
+
export declare function initializeFileDialogHandle(handle: EntityConstruction<FileDialogHandle>, kind: FileDialogHandle['kind'], name: string, path: string | null, operations?: FileDialogHandleOperations | null): void;
|
|
4
5
|
export declare function showOpenDirectoryDialog(host: HasDialogDirectoryOpen, options?: Readonly<OpenDirectoryDialogOptions>): Promise<DirectoryOpenDialogResult>;
|
|
5
6
|
export declare function showOpenFileDialog(host: HasDialogFileOpen, options: Readonly<OpenFileDialogOptions>): Promise<FileOpenDialogResult>;
|
|
6
7
|
export declare function showSaveFileDialog(host: HasDialogFileSave, options: Readonly<SaveFileDialogOptions>): Promise<FileSaveDialogResult>;
|
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,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EACjB,0BAA0B,EAC1B,qBAAqB,EACrB,qBAAqB,
|
|
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,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EACjB,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,IAAI,EAAE,sBAAsB,EAC5B,OAAO,CAAC,EAAE,QAAQ,CAAC,0BAA0B,CAAC,GAC7C,OAAO,CAAC,yBAAyB,CAAC,CAEpC;AAED,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,QAAQ,CAAC,qBAAqB,CAAC,GACvC,OAAO,CAAC,oBAAoB,CAAC,CAE/B;AAED,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,QAAQ,CAAC,qBAAqB,CAAC,GACvC,OAAO,CAAC,oBAAoB,CAAC,CAE/B"}
|
package/dist/fileDialog.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { allocateEntity, createEntityRuntime, finishEntity } from '@flighthq/entity/contract';
|
|
2
2
|
import { EntityRuntimeKey } from '@flighthq/types/contract';
|
|
3
|
-
// Constructs the identity that crosses from a picker provider into filesystem. `operations` is an
|
|
4
|
-
// internal runtime extension point, not serialized descriptor data; native path handles use null.
|
|
5
3
|
export function createFileDialogHandle(kind, name, path, operations = null) {
|
|
6
|
-
const handle =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
handle[EntityRuntimeKey] = runtime;
|
|
10
|
-
return handle;
|
|
4
|
+
const handle = allocateEntity();
|
|
5
|
+
initializeFileDialogHandle(handle, kind, name, path, operations);
|
|
6
|
+
return finishEntity(handle);
|
|
11
7
|
}
|
|
12
8
|
// Provider-neutral access to the handle's package-crossing runtime operations. A deserialized DTO or
|
|
13
9
|
// forged object has no runtime and therefore cannot acquire authority by matching public fields.
|
|
@@ -15,6 +11,16 @@ export function getFileDialogHandleOperations(handle) {
|
|
|
15
11
|
const runtime = handle[EntityRuntimeKey];
|
|
16
12
|
return runtime?.operations ?? null;
|
|
17
13
|
}
|
|
14
|
+
// Constructs the identity that crosses from a picker provider into filesystem. `operations` is an
|
|
15
|
+
// internal runtime extension point, not serialized descriptor data; native path handles use null.
|
|
16
|
+
export function initializeFileDialogHandle(handle, kind, name, path, operations = null) {
|
|
17
|
+
handle.kind = kind;
|
|
18
|
+
handle.name = name;
|
|
19
|
+
handle.path = path;
|
|
20
|
+
const runtime = createEntityRuntime();
|
|
21
|
+
runtime.operations = operations;
|
|
22
|
+
handle[EntityRuntimeKey] = runtime;
|
|
23
|
+
}
|
|
18
24
|
export function showOpenDirectoryDialog(host, options) {
|
|
19
25
|
return options === undefined ? host.dialog.directoryOpen.open() : host.dialog.directoryOpen.open(options);
|
|
20
26
|
}
|
package/dist/fileDialog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileDialog.js","sourceRoot":"","sources":["../src/fileDialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
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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C,IAAI,CAAC,OAAO,CAAC,CAAC;AAC5C,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.903.f434bc2",
|
|
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.903.f434bc2",
|
|
42
|
+
"@flighthq/types": "0.5.1-next.903.f434bc2"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"typescript": "^5.3.0"
|
package/src/dialog.test.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
2
|
import type { EntityWithoutRuntime, MessageDialogBackend, PromptDialogBackend } from '@flighthq/types/contract';
|
|
3
3
|
|
|
4
4
|
import {
|
|
@@ -16,19 +16,23 @@ import {
|
|
|
16
16
|
function fakeHost() {
|
|
17
17
|
return {
|
|
18
18
|
dialog: {
|
|
19
|
-
message:
|
|
20
|
-
|
|
19
|
+
message: (() => {
|
|
20
|
+
const out = allocateEntity<any>();
|
|
21
|
+
out.confirm = async () => {
|
|
21
22
|
return true;
|
|
22
|
-
}
|
|
23
|
-
async
|
|
23
|
+
};
|
|
24
|
+
out.message = async () => {
|
|
24
25
|
return { buttonIndex: 2, cancelled: false, checkboxChecked: false };
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
};
|
|
27
|
+
return finishEntity(out);
|
|
28
|
+
})(),
|
|
29
|
+
prompt: (() => {
|
|
30
|
+
const out = allocateEntity<any>();
|
|
31
|
+
out.prompt = async () => {
|
|
29
32
|
return 'typed';
|
|
30
|
-
}
|
|
31
|
-
|
|
33
|
+
};
|
|
34
|
+
return finishEntity(out);
|
|
35
|
+
})(),
|
|
32
36
|
},
|
|
33
37
|
};
|
|
34
38
|
}
|
|
@@ -36,15 +40,17 @@ function fakeHost() {
|
|
|
36
40
|
function severityHost(observed: string[]) {
|
|
37
41
|
return {
|
|
38
42
|
dialog: {
|
|
39
|
-
message:
|
|
40
|
-
|
|
43
|
+
message: (() => {
|
|
44
|
+
const out = allocateEntity<any>();
|
|
45
|
+
out.confirm = async () => {
|
|
41
46
|
return true;
|
|
42
|
-
}
|
|
43
|
-
async
|
|
47
|
+
};
|
|
48
|
+
out.message = async (options: Parameters<MessageDialogBackend['message']>[0]) => {
|
|
44
49
|
observed.push(options.kind ?? 'none');
|
|
45
50
|
return { buttonIndex: 0, cancelled: false, checkboxChecked: false };
|
|
46
|
-
}
|
|
47
|
-
|
|
51
|
+
};
|
|
52
|
+
return finishEntity(out);
|
|
53
|
+
})(),
|
|
48
54
|
},
|
|
49
55
|
};
|
|
50
56
|
}
|
|
@@ -56,7 +62,16 @@ describe('showConfirmDialog', () => {
|
|
|
56
62
|
|
|
57
63
|
it('forwards a live signal through the explicit message slot', async () => {
|
|
58
64
|
const confirm = vi.fn(async () => true);
|
|
59
|
-
const host = {
|
|
65
|
+
const host = {
|
|
66
|
+
dialog: {
|
|
67
|
+
message: (() => {
|
|
68
|
+
const out = allocateEntity<any>();
|
|
69
|
+
out.confirm = confirm;
|
|
70
|
+
out.message = vi.fn();
|
|
71
|
+
return finishEntity(out);
|
|
72
|
+
})(),
|
|
73
|
+
},
|
|
74
|
+
};
|
|
60
75
|
const signal = new AbortController().signal;
|
|
61
76
|
await showConfirmDialog(host, { message: 'sure?', signal });
|
|
62
77
|
expect(confirm).toHaveBeenCalledWith({ message: 'sure?', signal });
|
package/src/fileDialog.test.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
2
|
import type { FileDialogHandle } from '@flighthq/types/contract';
|
|
3
3
|
import { EntityRuntimeKey } from '@flighthq/types/contract';
|
|
4
4
|
|
|
@@ -17,21 +17,27 @@ function fakeHost() {
|
|
|
17
17
|
const saved = createFileDialogHandle('File', 'out.txt', '/tmp/out.txt');
|
|
18
18
|
return {
|
|
19
19
|
dialog: {
|
|
20
|
-
directoryOpen:
|
|
21
|
-
|
|
20
|
+
directoryOpen: (() => {
|
|
21
|
+
const out = allocateEntity<any>();
|
|
22
|
+
out.open = async () => {
|
|
22
23
|
return { handle: directory, outcome: 'selected' as const };
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
};
|
|
25
|
+
return finishEntity(out);
|
|
26
|
+
})(),
|
|
27
|
+
fileOpen: (() => {
|
|
28
|
+
const out = allocateEntity<any>();
|
|
29
|
+
out.open = async () => {
|
|
27
30
|
return { handles: [first, second] as const, outcome: 'selected' as const };
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
};
|
|
32
|
+
return finishEntity(out);
|
|
33
|
+
})(),
|
|
34
|
+
fileSave: (() => {
|
|
35
|
+
const out = allocateEntity<any>();
|
|
36
|
+
out.save = async () => {
|
|
32
37
|
return { handle: saved, outcome: 'selected' as const };
|
|
33
|
-
}
|
|
34
|
-
|
|
38
|
+
};
|
|
39
|
+
return finishEntity(out);
|
|
40
|
+
})(),
|
|
35
41
|
},
|
|
36
42
|
};
|
|
37
43
|
}
|
|
@@ -66,11 +72,13 @@ describe('showOpenDirectoryDialog', () => {
|
|
|
66
72
|
it('preserves the directory-specific runtime-unavailable outcome', async () => {
|
|
67
73
|
const host = {
|
|
68
74
|
dialog: {
|
|
69
|
-
directoryOpen:
|
|
70
|
-
|
|
75
|
+
directoryOpen: (() => {
|
|
76
|
+
const out = allocateEntity<any>();
|
|
77
|
+
out.open = async () => {
|
|
71
78
|
return { outcome: 'runtime-unavailable' as const };
|
|
72
|
-
}
|
|
73
|
-
|
|
79
|
+
};
|
|
80
|
+
return finishEntity(out);
|
|
81
|
+
})(),
|
|
74
82
|
},
|
|
75
83
|
};
|
|
76
84
|
expect((await showOpenDirectoryDialog(host)).outcome).toBe('runtime-unavailable');
|
|
@@ -78,7 +86,15 @@ describe('showOpenDirectoryDialog', () => {
|
|
|
78
86
|
|
|
79
87
|
it('forwards cancellation options through the independent capability slot', async () => {
|
|
80
88
|
const open = vi.fn(async () => ({ outcome: 'cancelled' as const }));
|
|
81
|
-
const host = {
|
|
89
|
+
const host = {
|
|
90
|
+
dialog: {
|
|
91
|
+
directoryOpen: (() => {
|
|
92
|
+
const out = allocateEntity<any>();
|
|
93
|
+
out.open = open;
|
|
94
|
+
return finishEntity(out);
|
|
95
|
+
})(),
|
|
96
|
+
},
|
|
97
|
+
};
|
|
82
98
|
const signal = new AbortController().signal;
|
|
83
99
|
await showOpenDirectoryDialog(host, { signal });
|
|
84
100
|
expect(open).toHaveBeenCalledWith({ signal });
|
|
@@ -98,11 +114,13 @@ describe('showOpenFileDialog', () => {
|
|
|
98
114
|
it('preserves the file-open-specific security outcome', async () => {
|
|
99
115
|
const host = {
|
|
100
116
|
dialog: {
|
|
101
|
-
fileOpen:
|
|
102
|
-
|
|
117
|
+
fileOpen: (() => {
|
|
118
|
+
const out = allocateEntity<any>();
|
|
119
|
+
out.open = async () => {
|
|
103
120
|
return { outcome: 'security-denied' as const };
|
|
104
|
-
}
|
|
105
|
-
|
|
121
|
+
};
|
|
122
|
+
return finishEntity(out);
|
|
123
|
+
})(),
|
|
106
124
|
},
|
|
107
125
|
};
|
|
108
126
|
expect((await showOpenFileDialog(host, {})).outcome).toBe('security-denied');
|
|
@@ -118,11 +136,13 @@ describe('showSaveFileDialog', () => {
|
|
|
118
136
|
it('preserves the file-save-specific failure outcome', async () => {
|
|
119
137
|
const host = {
|
|
120
138
|
dialog: {
|
|
121
|
-
fileSave:
|
|
122
|
-
|
|
139
|
+
fileSave: (() => {
|
|
140
|
+
const out = allocateEntity<any>();
|
|
141
|
+
out.save = async () => {
|
|
123
142
|
return { outcome: 'file-save-failed' as const };
|
|
124
|
-
}
|
|
125
|
-
|
|
143
|
+
};
|
|
144
|
+
return finishEntity(out);
|
|
145
|
+
})(),
|
|
126
146
|
},
|
|
127
147
|
};
|
|
128
148
|
expect((await showSaveFileDialog(host, {})).outcome).toBe('file-save-failed');
|
package/src/mediaDialog.test.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
2
|
import type {
|
|
3
3
|
CapturePhotoDialogOptions,
|
|
4
4
|
CaptureVideoDialogOptions,
|
|
@@ -20,7 +20,13 @@ describe('showCapturePhotoDialog', () => {
|
|
|
20
20
|
photo: { dataUrl: 'data:image/png;base64,AA==', height: 480, mimeType: 'image/png', width: 640 },
|
|
21
21
|
}));
|
|
22
22
|
const host: HasDialogPhotoCapture = {
|
|
23
|
-
dialog: {
|
|
23
|
+
dialog: {
|
|
24
|
+
photoCapture: (() => {
|
|
25
|
+
const out = allocateEntity<any>();
|
|
26
|
+
out.capture = capture;
|
|
27
|
+
return finishEntity(out) as PhotoCaptureDialogBackend;
|
|
28
|
+
})(),
|
|
29
|
+
},
|
|
24
30
|
};
|
|
25
31
|
const options: CapturePhotoDialogOptions = {
|
|
26
32
|
facingMode: 'user',
|
|
@@ -37,7 +43,11 @@ describe('showCapturePhotoDialog', () => {
|
|
|
37
43
|
const capture = async () => ({ outcome: 'photo-capture-failed' as const });
|
|
38
44
|
const host: HasDialogPhotoCapture = {
|
|
39
45
|
dialog: {
|
|
40
|
-
photoCapture:
|
|
46
|
+
photoCapture: (() => {
|
|
47
|
+
const out = allocateEntity<any>();
|
|
48
|
+
out.capture = capture;
|
|
49
|
+
return finishEntity(out) as PhotoCaptureDialogBackend;
|
|
50
|
+
})(),
|
|
41
51
|
},
|
|
42
52
|
};
|
|
43
53
|
|
|
@@ -52,7 +62,13 @@ describe('showCaptureVideoDialog', () => {
|
|
|
52
62
|
video: { dataUrl: 'data:video/mp4;base64,AA==', duration: 2.5, mimeType: 'video/mp4' },
|
|
53
63
|
}));
|
|
54
64
|
const host: HasDialogVideoCapture = {
|
|
55
|
-
dialog: {
|
|
65
|
+
dialog: {
|
|
66
|
+
videoCapture: (() => {
|
|
67
|
+
const out = allocateEntity<any>();
|
|
68
|
+
out.capture = capture;
|
|
69
|
+
return finishEntity(out) as VideoCaptureDialogBackend;
|
|
70
|
+
})(),
|
|
71
|
+
},
|
|
56
72
|
};
|
|
57
73
|
const options: CaptureVideoDialogOptions = { facingMode: 'environment' };
|
|
58
74
|
|
|
@@ -67,7 +83,13 @@ describe('showOpenImageDialog', () => {
|
|
|
67
83
|
it('routes selection through the explicit image-open slot and forwards cancellation', async () => {
|
|
68
84
|
const open = vi.fn(async () => ({ outcome: 'cancelled' as const }));
|
|
69
85
|
const host: HasDialogImageOpen = {
|
|
70
|
-
dialog: {
|
|
86
|
+
dialog: {
|
|
87
|
+
imageOpen: (() => {
|
|
88
|
+
const out = allocateEntity<any>();
|
|
89
|
+
out.open = open;
|
|
90
|
+
return finishEntity(out) as ImageOpenDialogBackend;
|
|
91
|
+
})(),
|
|
92
|
+
},
|
|
71
93
|
};
|
|
72
94
|
const options: OpenImageDialogOptions = { signal: new AbortController().signal };
|
|
73
95
|
|
|
@@ -79,7 +101,11 @@ describe('showOpenImageDialog', () => {
|
|
|
79
101
|
const open = async () => ({ outcome: 'image-open-failed' as const });
|
|
80
102
|
const host: HasDialogImageOpen = {
|
|
81
103
|
dialog: {
|
|
82
|
-
imageOpen:
|
|
104
|
+
imageOpen: (() => {
|
|
105
|
+
const out = allocateEntity<any>();
|
|
106
|
+
out.open = open;
|
|
107
|
+
return finishEntity(out) as ImageOpenDialogBackend;
|
|
108
|
+
})(),
|
|
83
109
|
},
|
|
84
110
|
};
|
|
85
111
|
|