@vantail/api 0.1.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/dist/app.d.ts +87 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +79 -0
- package/dist/app.js.map +1 -0
- package/dist/autostart.d.ts +21 -0
- package/dist/autostart.d.ts.map +1 -0
- package/dist/autostart.js +28 -0
- package/dist/autostart.js.map +1 -0
- package/dist/binary.d.ts +13 -0
- package/dist/binary.d.ts.map +1 -0
- package/dist/binary.js +41 -0
- package/dist/binary.js.map +1 -0
- package/dist/clipboard.d.ts +36 -0
- package/dist/clipboard.d.ts.map +1 -0
- package/dist/clipboard.js +34 -0
- package/dist/clipboard.js.map +1 -0
- package/dist/deeplink.d.ts +36 -0
- package/dist/deeplink.d.ts.map +1 -0
- package/dist/deeplink.js +61 -0
- package/dist/deeplink.js.map +1 -0
- package/dist/dialog.d.ts +48 -0
- package/dist/dialog.d.ts.map +1 -0
- package/dist/dialog.js +25 -0
- package/dist/dialog.js.map +1 -0
- package/dist/drop.d.ts +37 -0
- package/dist/drop.d.ts.map +1 -0
- package/dist/drop.js +29 -0
- package/dist/drop.js.map +1 -0
- package/dist/error.d.ts +27 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +39 -0
- package/dist/error.js.map +1 -0
- package/dist/filesystem.d.ts +99 -0
- package/dist/filesystem.d.ts.map +1 -0
- package/dist/filesystem.js +75 -0
- package/dist/filesystem.js.map +1 -0
- package/dist/hid.d.ts +69 -0
- package/dist/hid.d.ts.map +1 -0
- package/dist/hid.js +54 -0
- package/dist/hid.js.map +1 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/mdns.d.ts +65 -0
- package/dist/mdns.d.ts.map +1 -0
- package/dist/mdns.js +42 -0
- package/dist/mdns.js.map +1 -0
- package/dist/menu.d.ts +83 -0
- package/dist/menu.d.ts.map +1 -0
- package/dist/menu.js +55 -0
- package/dist/menu.js.map +1 -0
- package/dist/network.d.ts +61 -0
- package/dist/network.d.ts.map +1 -0
- package/dist/network.js +59 -0
- package/dist/network.js.map +1 -0
- package/dist/notification.d.ts +17 -0
- package/dist/notification.d.ts.map +1 -0
- package/dist/notification.js +13 -0
- package/dist/notification.js.map +1 -0
- package/dist/os.d.ts +22 -0
- package/dist/os.d.ts.map +1 -0
- package/dist/os.js +20 -0
- package/dist/os.js.map +1 -0
- package/dist/power.d.ts +29 -0
- package/dist/power.d.ts.map +1 -0
- package/dist/power.js +30 -0
- package/dist/power.js.map +1 -0
- package/dist/process.d.ts +69 -0
- package/dist/process.d.ts.map +1 -0
- package/dist/process.js +44 -0
- package/dist/process.js.map +1 -0
- package/dist/protocol.d.ts +66 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +26 -0
- package/dist/protocol.js.map +1 -0
- package/dist/screen.d.ts +49 -0
- package/dist/screen.d.ts.map +1 -0
- package/dist/screen.js +38 -0
- package/dist/screen.js.map +1 -0
- package/dist/secrets.d.ts +31 -0
- package/dist/secrets.d.ts.map +1 -0
- package/dist/secrets.js +32 -0
- package/dist/secrets.js.map +1 -0
- package/dist/shell.d.ts +14 -0
- package/dist/shell.d.ts.map +1 -0
- package/dist/shell.js +13 -0
- package/dist/shell.js.map +1 -0
- package/dist/shortcut.d.ts +45 -0
- package/dist/shortcut.d.ts.map +1 -0
- package/dist/shortcut.js +45 -0
- package/dist/shortcut.js.map +1 -0
- package/dist/transport.d.ts +36 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +141 -0
- package/dist/transport.js.map +1 -0
- package/dist/tray.d.ts +59 -0
- package/dist/tray.d.ts.map +1 -0
- package/dist/tray.js +30 -0
- package/dist/tray.js.map +1 -0
- package/dist/updater.d.ts +65 -0
- package/dist/updater.d.ts.map +1 -0
- package/dist/updater.js +48 -0
- package/dist/updater.js.map +1 -0
- package/dist/window.d.ts +156 -0
- package/dist/window.d.ts.map +1 -0
- package/dist/window.js +141 -0
- package/dist/window.js.map +1 -0
- package/package.json +27 -0
package/dist/error.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type VantailErrorPayload } from "./protocol.js";
|
|
2
|
+
/**
|
|
3
|
+
* Every failure from the native side arrives as one of these.
|
|
4
|
+
*
|
|
5
|
+
* `code` is the part worth branching on - the message is for humans and may
|
|
6
|
+
* change between releases.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* try {
|
|
10
|
+
* await filesystem.readText(path);
|
|
11
|
+
* } catch (error) {
|
|
12
|
+
* if (VantailError.is(error, "PERMISSION_DENIED")) {
|
|
13
|
+
* // ask the user to pick the file instead
|
|
14
|
+
* }
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare class VantailError extends Error {
|
|
19
|
+
readonly code: string;
|
|
20
|
+
readonly data: unknown;
|
|
21
|
+
constructor(code: string, message: string, data?: unknown);
|
|
22
|
+
static from(payload: VantailErrorPayload): VantailError;
|
|
23
|
+
/** Type guard, optionally narrowing to a specific code. */
|
|
24
|
+
static is(error: unknown, code?: string): error is VantailError;
|
|
25
|
+
}
|
|
26
|
+
export declare const noRuntime: () => VantailError;
|
|
27
|
+
//# sourceMappingURL=error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEpE;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,YAAa,SAAQ,KAAK;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAEvB,YAAY,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAKxD;IAED,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY,CAEtD;IAED,2DAA2D;IAC3D,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,KAAK,IAAI,YAAY,CAG9D;CACF;AAED,eAAO,MAAM,SAAS,QAAO,YAK1B,CAAC"}
|
package/dist/error.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ErrorCode } from "./protocol.js";
|
|
2
|
+
/**
|
|
3
|
+
* Every failure from the native side arrives as one of these.
|
|
4
|
+
*
|
|
5
|
+
* `code` is the part worth branching on - the message is for humans and may
|
|
6
|
+
* change between releases.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* try {
|
|
10
|
+
* await filesystem.readText(path);
|
|
11
|
+
* } catch (error) {
|
|
12
|
+
* if (VantailError.is(error, "PERMISSION_DENIED")) {
|
|
13
|
+
* // ask the user to pick the file instead
|
|
14
|
+
* }
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export class VantailError extends Error {
|
|
19
|
+
code;
|
|
20
|
+
data;
|
|
21
|
+
constructor(code, message, data) {
|
|
22
|
+
super(message);
|
|
23
|
+
this.name = "VantailError";
|
|
24
|
+
this.code = code;
|
|
25
|
+
this.data = data;
|
|
26
|
+
}
|
|
27
|
+
static from(payload) {
|
|
28
|
+
return new VantailError(payload.code, payload.message, payload.data);
|
|
29
|
+
}
|
|
30
|
+
/** Type guard, optionally narrowing to a specific code. */
|
|
31
|
+
static is(error, code) {
|
|
32
|
+
if (!(error instanceof VantailError))
|
|
33
|
+
return false;
|
|
34
|
+
return code === undefined || error.code === code;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export const noRuntime = () => new VantailError(ErrorCode.NO_RUNTIME, "No Vantail runtime found. `@vantail/api` only works inside a Vantail window - " +
|
|
38
|
+
"run your app with `vantail dev` instead of opening it in a browser.");
|
|
39
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA4B,MAAM,eAAe,CAAC;AAEpE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK;IAC5B,IAAI,CAAS;IACb,IAAI,CAAU;IAEvB,YAAY,IAAY,EAAE,OAAe,EAAE,IAAc;QACvD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,OAA4B;QACtC,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACvE,CAAC;IAED,2DAA2D;IAC3D,MAAM,CAAC,EAAE,CAAC,KAAc,EAAE,IAAa;QACrC,IAAI,CAAC,CAAC,KAAK,YAAY,YAAY,CAAC;YAAE,OAAO,KAAK,CAAC;QACnD,OAAO,IAAI,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;IACnD,CAAC;CACF;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,GAAiB,EAAE,CAC1C,IAAI,YAAY,CACd,SAAS,CAAC,UAAU,EACpB,gFAAgF;IAC9E,qEAAqE,CACxE,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { type BinaryInput } from "./binary.js";
|
|
2
|
+
export interface FileChange {
|
|
3
|
+
/** The watch that reported it, as returned by {@link filesystem.watch}. */
|
|
4
|
+
id: string;
|
|
5
|
+
kind: "created" | "modified" | "removed" | "renamed";
|
|
6
|
+
/** What changed. For a recursive watch this is below the watched path. */
|
|
7
|
+
path: string;
|
|
8
|
+
/** The path the watch was placed on. */
|
|
9
|
+
watching: string;
|
|
10
|
+
}
|
|
11
|
+
export interface Watch {
|
|
12
|
+
id: string;
|
|
13
|
+
path: string;
|
|
14
|
+
recursive: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface DirEntry {
|
|
17
|
+
name: string;
|
|
18
|
+
path: string;
|
|
19
|
+
isDirectory: boolean;
|
|
20
|
+
isFile: boolean;
|
|
21
|
+
isSymlink: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface FileInfo {
|
|
24
|
+
path: string;
|
|
25
|
+
isDirectory: boolean;
|
|
26
|
+
isFile: boolean;
|
|
27
|
+
isSymlink: boolean;
|
|
28
|
+
size: number;
|
|
29
|
+
readonly: boolean;
|
|
30
|
+
/** Milliseconds since the epoch, or `null` where the platform has none. */
|
|
31
|
+
modifiedAt: number | null;
|
|
32
|
+
createdAt: number | null;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Scoped file access.
|
|
36
|
+
*
|
|
37
|
+
* Every call is checked against the `permissions.filesystem` scopes in
|
|
38
|
+
* `vantail.config.ts`, plus anything the user has picked in a native dialog
|
|
39
|
+
* during this session. A refusal throws a `VantailError` with code
|
|
40
|
+
* `PERMISSION_DENIED`.
|
|
41
|
+
*/
|
|
42
|
+
export declare const filesystem: {
|
|
43
|
+
readText: (path: string) => Promise<string>;
|
|
44
|
+
writeText: (path: string, contents: string, options?: {
|
|
45
|
+
createDirs?: boolean;
|
|
46
|
+
}) => Promise<null>;
|
|
47
|
+
appendText: (path: string, contents: string) => Promise<null>;
|
|
48
|
+
/**
|
|
49
|
+
* Read a file as bytes.
|
|
50
|
+
*
|
|
51
|
+
* Limited to 64 MB: the data crosses the IPC boundary as base64 inside a
|
|
52
|
+
* JSON string, which is fine for icons and documents and wrong for video.
|
|
53
|
+
*/
|
|
54
|
+
readBinary: (path: string) => Promise<Uint8Array>;
|
|
55
|
+
writeBinary: (path: string, data: BinaryInput, options?: {
|
|
56
|
+
createDirs?: boolean;
|
|
57
|
+
}) => Promise<null>;
|
|
58
|
+
/** Directories first, then files, both case-insensitively by name. */
|
|
59
|
+
readDir: (path: string) => Promise<DirEntry[]>;
|
|
60
|
+
exists: (path: string) => Promise<boolean>;
|
|
61
|
+
stat: (path: string) => Promise<FileInfo>;
|
|
62
|
+
mkdir: (path: string, options?: {
|
|
63
|
+
recursive?: boolean;
|
|
64
|
+
}) => Promise<null>;
|
|
65
|
+
/** Removing a non-empty directory needs `{ recursive: true }`. */
|
|
66
|
+
remove: (path: string, options?: {
|
|
67
|
+
recursive?: boolean;
|
|
68
|
+
}) => Promise<null>;
|
|
69
|
+
copy: (from: string, to: string) => Promise<null>;
|
|
70
|
+
rename: (from: string, to: string) => Promise<null>;
|
|
71
|
+
/**
|
|
72
|
+
* Be told when a path changes, instead of polling it.
|
|
73
|
+
*
|
|
74
|
+
* Scoped exactly like a read: watching a path you cannot read is denied.
|
|
75
|
+
* A directory reports its own children; pass `{ recursive: true }` for
|
|
76
|
+
* everything below it.
|
|
77
|
+
*
|
|
78
|
+
* ```ts
|
|
79
|
+
* const { id } = await filesystem.watch(dir, { recursive: true });
|
|
80
|
+
* filesystem.onChange((change) => console.log(change.kind, change.path));
|
|
81
|
+
* // later
|
|
82
|
+
* await filesystem.unwatch(id);
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
watch: (path: string, options?: {
|
|
86
|
+
recursive?: boolean;
|
|
87
|
+
}) => Promise<Watch>;
|
|
88
|
+
/** Stop a watch. Throws `NOT_FOUND` if it is not running. */
|
|
89
|
+
unwatch: (id: string) => Promise<null>;
|
|
90
|
+
/** The ids of every watch this application has running. */
|
|
91
|
+
watches: () => Promise<string[]>;
|
|
92
|
+
/**
|
|
93
|
+
* Every watch reports here. Filter on `id` if you have more than one.
|
|
94
|
+
*
|
|
95
|
+
* Returns an unsubscribe function.
|
|
96
|
+
*/
|
|
97
|
+
onChange: (handler: (change: FileChange) => void) => () => void;
|
|
98
|
+
};
|
|
99
|
+
//# sourceMappingURL=filesystem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filesystem.d.ts","sourceRoot":"","sources":["../src/filesystem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/D,MAAM,WAAW,UAAU;IACzB,2EAA2E;IAC3E,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;IACrD,0EAA0E;IAC1E,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,2EAA2E;IAC3E,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU;IACrB,QAAQ,SAAS,MAAM;IAEvB,SAAS,SACD,MAAM,YACF,MAAM,YACN;QAAE,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE;IAQpC,UAAU,SAAS,MAAM,YAAY,MAAM;IAG3C;;;;;OAKG;IACH,UAAU,SAAe,MAAM,KAAG,OAAO,CAAC,UAAU,CAAC;IAGrD,WAAW,SACH,MAAM,QACN,WAAW,YACP;QAAE,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE;IAQpC,sEAAsE;IACtE,OAAO,SAAS,MAAM;IAEtB,MAAM,SAAS,MAAM;IAErB,IAAI,SAAS,MAAM;IAEnB,KAAK,SAAS,MAAM,YAAY;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE;IAMvD,kEAAkE;IAClE,MAAM,SAAS,MAAM,YAAY;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE;IAMxD,IAAI,SAAS,MAAM,MAAM,MAAM;IAG/B,MAAM,SAAS,MAAM,MAAM,MAAM;IAGjC;;;;;;;;;;;;;OAaG;IACH,KAAK,SAAS,MAAM,YAAY;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE;IAMvD,6DAA6D;IAC7D,OAAO,OAAO,MAAM;IAEpB,2DAA2D;IAC3D,OAAO;IAEP;;;;OAIG;IACH,QAAQ,YAAY,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI;CAEjD,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { decode, encode } from "./binary.js";
|
|
2
|
+
import { invoke, listen } from "./transport.js";
|
|
3
|
+
/**
|
|
4
|
+
* Scoped file access.
|
|
5
|
+
*
|
|
6
|
+
* Every call is checked against the `permissions.filesystem` scopes in
|
|
7
|
+
* `vantail.config.ts`, plus anything the user has picked in a native dialog
|
|
8
|
+
* during this session. A refusal throws a `VantailError` with code
|
|
9
|
+
* `PERMISSION_DENIED`.
|
|
10
|
+
*/
|
|
11
|
+
export const filesystem = {
|
|
12
|
+
readText: (path) => invoke("filesystem.readText", { path }),
|
|
13
|
+
writeText: (path, contents, options) => invoke("filesystem.writeText", {
|
|
14
|
+
path,
|
|
15
|
+
contents,
|
|
16
|
+
createDirs: options?.createDirs ?? false,
|
|
17
|
+
}),
|
|
18
|
+
appendText: (path, contents) => invoke("filesystem.appendText", { path, contents }),
|
|
19
|
+
/**
|
|
20
|
+
* Read a file as bytes.
|
|
21
|
+
*
|
|
22
|
+
* Limited to 64 MB: the data crosses the IPC boundary as base64 inside a
|
|
23
|
+
* JSON string, which is fine for icons and documents and wrong for video.
|
|
24
|
+
*/
|
|
25
|
+
readBinary: async (path) => decode(await invoke("filesystem.readBinary", { path })),
|
|
26
|
+
writeBinary: (path, data, options) => invoke("filesystem.writeBinary", {
|
|
27
|
+
path,
|
|
28
|
+
data: encode(data),
|
|
29
|
+
createDirs: options?.createDirs ?? false,
|
|
30
|
+
}),
|
|
31
|
+
/** Directories first, then files, both case-insensitively by name. */
|
|
32
|
+
readDir: (path) => invoke("filesystem.readDir", { path }),
|
|
33
|
+
exists: (path) => invoke("filesystem.exists", { path }),
|
|
34
|
+
stat: (path) => invoke("filesystem.stat", { path }),
|
|
35
|
+
mkdir: (path, options) => invoke("filesystem.mkdir", {
|
|
36
|
+
path,
|
|
37
|
+
recursive: options?.recursive ?? false,
|
|
38
|
+
}),
|
|
39
|
+
/** Removing a non-empty directory needs `{ recursive: true }`. */
|
|
40
|
+
remove: (path, options) => invoke("filesystem.remove", {
|
|
41
|
+
path,
|
|
42
|
+
recursive: options?.recursive ?? false,
|
|
43
|
+
}),
|
|
44
|
+
copy: (from, to) => invoke("filesystem.copy", { from, to }),
|
|
45
|
+
rename: (from, to) => invoke("filesystem.rename", { from, to }),
|
|
46
|
+
/**
|
|
47
|
+
* Be told when a path changes, instead of polling it.
|
|
48
|
+
*
|
|
49
|
+
* Scoped exactly like a read: watching a path you cannot read is denied.
|
|
50
|
+
* A directory reports its own children; pass `{ recursive: true }` for
|
|
51
|
+
* everything below it.
|
|
52
|
+
*
|
|
53
|
+
* ```ts
|
|
54
|
+
* const { id } = await filesystem.watch(dir, { recursive: true });
|
|
55
|
+
* filesystem.onChange((change) => console.log(change.kind, change.path));
|
|
56
|
+
* // later
|
|
57
|
+
* await filesystem.unwatch(id);
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
watch: (path, options) => invoke("filesystem.watch", {
|
|
61
|
+
path,
|
|
62
|
+
recursive: options?.recursive ?? false,
|
|
63
|
+
}),
|
|
64
|
+
/** Stop a watch. Throws `NOT_FOUND` if it is not running. */
|
|
65
|
+
unwatch: (id) => invoke("filesystem.unwatch", { id }),
|
|
66
|
+
/** The ids of every watch this application has running. */
|
|
67
|
+
watches: () => invoke("filesystem.watches"),
|
|
68
|
+
/**
|
|
69
|
+
* Every watch reports here. Filter on `id` if you have more than one.
|
|
70
|
+
*
|
|
71
|
+
* Returns an unsubscribe function.
|
|
72
|
+
*/
|
|
73
|
+
onChange: (handler) => listen("filesystem.changed", handler),
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=filesystem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filesystem.js","sourceRoot":"","sources":["../src/filesystem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAoB,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAsChD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,QAAQ,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,MAAM,CAAS,qBAAqB,EAAE,EAAE,IAAI,EAAE,CAAC;IAE3E,SAAS,EAAE,CACT,IAAY,EACZ,QAAgB,EAChB,OAAkC,EAClC,EAAE,CACF,MAAM,CAAO,sBAAsB,EAAE;QACnC,IAAI;QACJ,QAAQ;QACR,UAAU,EAAE,OAAO,EAAE,UAAU,IAAI,KAAK;KACzC,CAAC;IAEJ,UAAU,EAAE,CAAC,IAAY,EAAE,QAAgB,EAAE,EAAE,CAC7C,MAAM,CAAO,uBAAuB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;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AI,EAAE,EAAE,EAAE,CAAC;IAEjD;;;;;;;;;;;;;OAaG;IACH,KAAK,EAAE,CAAC,IAAY,EAAE,OAAiC,EAAE,EAAE,CACzD,MAAM,CAAQ,kBAAkB,EAAE;QAChC,IAAI;QACJ,SAAS,EAAE,OAAO,EAAE,SAAS,IAAI,KAAK;KACvC,CAAC;IAEJ,6DAA6D;IAC7D,OAAO,EAAE,CAAC,EAAU,EAAE,EAAE,CAAC,MAAM,CAAO,oBAAoB,EAAE,EAAE,EAAE,EAAE,CAAC;IAEnE,2DAA2D;IAC3D,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAW,oBAAoB,CAAC;IAErD;;;;OAIG;IACH,QAAQ,EAAE,CAAC,OAAqC,EAAE,EAAE,CAClD,MAAM,CAAa,oBAAoB,EAAE,OAAO,CAAC;CACpD,CAAC"}
|
package/dist/hid.d.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { type BinaryInput } from "./binary.js";
|
|
2
|
+
export interface HidDeviceInfo {
|
|
3
|
+
/** Opaque, platform-specific, and what `open` takes. */
|
|
4
|
+
id: string;
|
|
5
|
+
vendorId: number;
|
|
6
|
+
productId: number;
|
|
7
|
+
manufacturer: string | null;
|
|
8
|
+
product: string | null;
|
|
9
|
+
serialNumber: string | null;
|
|
10
|
+
usagePage: number;
|
|
11
|
+
usage: number;
|
|
12
|
+
interface: number;
|
|
13
|
+
}
|
|
14
|
+
export interface HidConnection {
|
|
15
|
+
/** The handle every call below takes. Not an OS handle. */
|
|
16
|
+
readonly handle: number;
|
|
17
|
+
readonly vendorId: number;
|
|
18
|
+
readonly productId: number;
|
|
19
|
+
/**
|
|
20
|
+
* Send an output report. The **first byte is the report id** - use `0` for
|
|
21
|
+
* devices that do not use numbered reports. Resolves with the byte count
|
|
22
|
+
* the device accepted.
|
|
23
|
+
*/
|
|
24
|
+
write(data: BinaryInput): Promise<number>;
|
|
25
|
+
/** Send a feature report. Same report-id convention as `write`. */
|
|
26
|
+
sendFeatureReport(data: BinaryInput): Promise<null>;
|
|
27
|
+
/** Read a feature report. `length` excludes the report id. */
|
|
28
|
+
getFeatureReport(reportId: number, length: number): Promise<Uint8Array>;
|
|
29
|
+
close(): Promise<boolean>;
|
|
30
|
+
/** Input reports as they arrive, including the report id byte. */
|
|
31
|
+
onInput(handler: (data: Uint8Array) => void): () => void;
|
|
32
|
+
/** The device closed - because you asked, or because it was unplugged. */
|
|
33
|
+
onClosed(handler: (event: {
|
|
34
|
+
reason: "closed" | "disconnected";
|
|
35
|
+
}) => void): () => void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Raw access to USB HID devices.
|
|
39
|
+
*
|
|
40
|
+
* WebHID does not exist in the webviews Vantail runs on, so a control pad, a
|
|
41
|
+
* foot pedal or a macro pad is simply unreachable from a page. This is the
|
|
42
|
+
* one capability that is device-shaped, which is exactly why it stays generic:
|
|
43
|
+
* Vantail knows what a HID report is and has never heard of any particular device. Your
|
|
44
|
+
* application implements the protocol; the platform hands it bytes.
|
|
45
|
+
*
|
|
46
|
+
* ```ts
|
|
47
|
+
* const [deck] = await hid.list(); // already filtered by permission
|
|
48
|
+
* const connection = await hid.open(deck.id);
|
|
49
|
+
*
|
|
50
|
+
* connection.onInput((report) => decodeButtons(report));
|
|
51
|
+
* await connection.write(new Uint8Array([0x02, 0x0b, 0x01]));
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* `list()` returns only devices `permissions.hid` allows - an application
|
|
55
|
+
* permitted to talk to one vendor's hardware has no business learning what
|
|
56
|
+
* else is plugged in.
|
|
57
|
+
*/
|
|
58
|
+
export declare const hid: {
|
|
59
|
+
list: () => Promise<HidDeviceInfo[]>;
|
|
60
|
+
open: (id: string) => Promise<HidConnection>;
|
|
61
|
+
/** Everything this application currently has open. */
|
|
62
|
+
opened: () => Promise<{
|
|
63
|
+
handle: number;
|
|
64
|
+
id: string;
|
|
65
|
+
vendorId: number;
|
|
66
|
+
productId: number;
|
|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OAAO,EAAE,CAAC,KAAK,EAAE;QAAE,MAAM,EAAE,QAAQ,GAAG,cAAc,CAAA;KAAE,KAAK,IAAI,GAC9D,MAAM,IAAI,CAAC;CACf;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,GAAG;IACd,IAAI;IAEJ,IAAI,OAAa,MAAM,KAAG,OAAO,CAAC,aAAa,CAAC;IAShD,sDAAsD;IACtD,MAAM;gBAEQ,MAAM;YAAM,MAAM;kBAAY,MAAM;mBAAa,MAAM;;CAEtE,CAAC"}
|
package/dist/hid.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { decode, encode } from "./binary.js";
|
|
2
|
+
import { invoke, listen } from "./transport.js";
|
|
3
|
+
/**
|
|
4
|
+
* Raw access to USB HID devices.
|
|
5
|
+
*
|
|
6
|
+
* WebHID does not exist in the webviews Vantail runs on, so a control pad, a
|
|
7
|
+
* foot pedal or a macro pad is simply unreachable from a page. This is the
|
|
8
|
+
* one capability that is device-shaped, which is exactly why it stays generic:
|
|
9
|
+
* Vantail knows what a HID report is and has never heard of any particular device. Your
|
|
10
|
+
* application implements the protocol; the platform hands it bytes.
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* const [deck] = await hid.list(); // already filtered by permission
|
|
14
|
+
* const connection = await hid.open(deck.id);
|
|
15
|
+
*
|
|
16
|
+
* connection.onInput((report) => decodeButtons(report));
|
|
17
|
+
* await connection.write(new Uint8Array([0x02, 0x0b, 0x01]));
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* `list()` returns only devices `permissions.hid` allows - an application
|
|
21
|
+
* permitted to talk to one vendor's hardware has no business learning what
|
|
22
|
+
* else is plugged in.
|
|
23
|
+
*/
|
|
24
|
+
export const hid = {
|
|
25
|
+
list: () => invoke("hid.list"),
|
|
26
|
+
open: async (id) => {
|
|
27
|
+
const opened = await invoke("hid.open", { id });
|
|
28
|
+
return connection(opened.handle, opened.vendorId, opened.productId);
|
|
29
|
+
},
|
|
30
|
+
/** Everything this application currently has open. */
|
|
31
|
+
opened: () => invoke("hid.opened"),
|
|
32
|
+
};
|
|
33
|
+
function connection(handle, vendorId, productId) {
|
|
34
|
+
const forHandle = (event, fn) => listen(event, (payload) => {
|
|
35
|
+
if (payload.handle === handle)
|
|
36
|
+
fn(payload);
|
|
37
|
+
});
|
|
38
|
+
return {
|
|
39
|
+
handle,
|
|
40
|
+
vendorId,
|
|
41
|
+
productId,
|
|
42
|
+
write: (data) => invoke("hid.write", { handle, data: encode(data) }),
|
|
43
|
+
sendFeatureReport: (data) => invoke("hid.sendFeatureReport", { handle, data: encode(data) }),
|
|
44
|
+
getFeatureReport: async (reportId, length) => decode(await invoke("hid.getFeatureReport", {
|
|
45
|
+
handle,
|
|
46
|
+
reportId,
|
|
47
|
+
length,
|
|
48
|
+
})),
|
|
49
|
+
close: () => invoke("hid.close", { handle }),
|
|
50
|
+
onInput: (fn) => forHandle("hid.input", ({ data }) => fn(decode(data))),
|
|
51
|
+
onClosed: (fn) => forHandle("hid.closed", ({ reason }) => fn({ reason })),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=hid.js.map
|
package/dist/hid.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hid.js","sourceRoot":"","sources":["../src/hid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAoB,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AA6ChD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG;IACjB,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,CAAkB,UAAU,CAAC;IAE/C,IAAI,EAAE,KAAK,EAAE,EAAU,EAA0B,EAAE;QACjD,MAAM,MAAM,GAAG,MAAM,MAAM,CAIxB,UAAU,EAAE,EAAE,EA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ACjB;QACH,QAAQ,EAAE,CAAC,EAAE,EAAE,EAAE,CACf,SAAS,CACP,YAAY,EACZ,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,CAC/B;KACJ,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@vantail/api` - the native surface of a Vantail application.
|
|
3
|
+
*
|
|
4
|
+
* ```ts
|
|
5
|
+
* import { dialog, filesystem } from "@vantail/api";
|
|
6
|
+
*
|
|
7
|
+
* const path = await dialog.openFile();
|
|
8
|
+
* if (path) console.log(await filesystem.readText(path));
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* There is no Node.js here: no `node:fs`, no `require`, no npm package with a
|
|
12
|
+
* native addon. Just the browser you already know, plus these calls.
|
|
13
|
+
*/
|
|
14
|
+
export { app, type AppInfo, type ProgressOptions, type ProgressState, } from "./app.js";
|
|
15
|
+
export { autostart } from "./autostart.js";
|
|
16
|
+
export { clipboard, type ClipboardImage } from "./clipboard.js";
|
|
17
|
+
export { deepLink } from "./deeplink.js";
|
|
18
|
+
export { fileDrop, type DropEvent } from "./drop.js";
|
|
19
|
+
export { dialog, type ConfirmOptions, type FileFilter, type MessageOptions, type OpenOptions, type SaveOptions, } from "./dialog.js";
|
|
20
|
+
export { filesystem, type DirEntry, type FileChange, type FileInfo, type Watch, } from "./filesystem.js";
|
|
21
|
+
export { hid, type HidConnection, type HidDeviceInfo } from "./hid.js";
|
|
22
|
+
export { mdns, type DiscoveredService, type DiscoverOptions } from "./mdns.js";
|
|
23
|
+
export { menu, type MenuItem, type PredefinedMenuItem } from "./menu.js";
|
|
24
|
+
export { network, type NetworkRequestOptions, type NetworkResponse, } from "./network.js";
|
|
25
|
+
export { notification, type NotificationOptions } from "./notification.js";
|
|
26
|
+
export { os, type OsInfo, type Platform } from "./os.js";
|
|
27
|
+
export { process, type Child, type ExecuteOptions, type ExecuteResult, type ExitEvent, type RunOptions, } from "./process.js";
|
|
28
|
+
export { screen, type Screen } from "./screen.js";
|
|
29
|
+
export { power } from "./power.js";
|
|
30
|
+
export { secrets } from "./secrets.js";
|
|
31
|
+
export { shell } from "./shell.js";
|
|
32
|
+
export { shortcut, type RegisterOptions, type Shortcut } from "./shortcut.js";
|
|
33
|
+
export { tray, type TrayClick, type TrayOptions } from "./tray.js";
|
|
34
|
+
export { updater, type DownloadProgress, type DownloadResult, type NoUpdate, type UpdateAvailable, type UpdateCheck, } from "./updater.js";
|
|
35
|
+
export { appWindow, appWindow as window, createWindow, currentWindow, getWindow, listWindows, onWindowClosed, onWindowCreated, onWindowReady, type CloseBehavior, type Position, type Size, type WindowHandle, type WindowOptions, } from "./window.js";
|
|
36
|
+
export { type BinaryInput } from "./binary.js";
|
|
37
|
+
export { VantailError } from "./error.js";
|
|
38
|
+
export { invoke, isVantail, listen, runtimeVersion, windowLabel, } from "./transport.js";
|
|
39
|
+
export { ErrorCode } from "./protocol.js";
|
|
40
|
+
export type { VantailBridge, VantailErrorPayload, VantailIncoming, VantailRequest, VantailResponse, } from "./protocol.js";
|
|
41
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,GAAG,EACH,KAAK,OAAO,EACZ,KAAK,eAAe,EACpB,KAAK,aAAa,GACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AACrD,OAA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WAAW,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EACL,OAAO,EACP,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,WAAW,GACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,SAAS,EACT,SAAS,IAAI,MAAM,EACnB,YAAY,EACZ,aAAa,EACb,SAAS,EACT,WAAW,EACX,cAAc,EACd,eAAe,EACf,aAAa,EACb,KAAK,aAAa,EAClB,KAAK,QAAQ,EACb,KAAK,IAAI,EACT,KAAK,YAAY,EACjB,KAAK,aAAa,GACnB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EACL,MAAM,EACN,SAAS,EACT,MAAM,EACN,cAAc,EACd,WAAW,GACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,YAAY,EACV,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,eAAe,GAChB,MAAM,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@vantail/api` - the native surface of a Vantail application.
|
|
3
|
+
*
|
|
4
|
+
* ```ts
|
|
5
|
+
* import { dialog, filesystem } from "@vantail/api";
|
|
6
|
+
*
|
|
7
|
+
* const path = await dialog.openFile();
|
|
8
|
+
* if (path) console.log(await filesystem.readText(path));
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* There is no Node.js here: no `node:fs`, no `require`, no npm package with a
|
|
12
|
+
* native addon. Just the browser you already know, plus these calls.
|
|
13
|
+
*/
|
|
14
|
+
export { app, } from "./app.js";
|
|
15
|
+
export { autostart } from "./autostart.js";
|
|
16
|
+
export { clipboard } from "./clipboard.js";
|
|
17
|
+
export { deepLink } from "./deeplink.js";
|
|
18
|
+
export { fileDrop } from "./drop.js";
|
|
19
|
+
export { dialog, } from "./dialog.js";
|
|
20
|
+
export { filesystem, } from "./filesystem.js";
|
|
21
|
+
export { hid } from "./hid.js";
|
|
22
|
+
export { mdns } from "./mdns.js";
|
|
23
|
+
export { menu } from "./menu.js";
|
|
24
|
+
export { network, } from "./network.js";
|
|
25
|
+
export { notification } from "./notification.js";
|
|
26
|
+
export { os } from "./os.js";
|
|
27
|
+
export { process, } from "./process.js";
|
|
28
|
+
export { screen } from "./screen.js";
|
|
29
|
+
export { power } from "./power.js";
|
|
30
|
+
export { secrets } from "./secrets.js";
|
|
31
|
+
export { shell } from "./shell.js";
|
|
32
|
+
export { shortcut } from "./shortcut.js";
|
|
33
|
+
export { tray } from "./tray.js";
|
|
34
|
+
export { updater, } from "./updater.js";
|
|
35
|
+
export { appWindow, appWindow as window, createWindow, currentWindow, getWindow, listWindows, onWindowClosed, onWindowCreated, onWindowReady, } from "./window.js";
|
|
36
|
+
export {} from "./binary.js";
|
|
37
|
+
export { VantailError } from "./error.js";
|
|
38
|
+
export { invoke, isVantail, listen, runtimeVersion, windowLabel, } from "./transport.js";
|
|
39
|
+
export { ErrorCode } from "./protocol.js";
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,GAAG,GAIJ,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAuB,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAkB,MAAM,WAAW,CAAC;AACrD,OAAO,EACL,MAAM,GAMP,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,UAAU,GAKX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,GAAG,EAA0C,MAAM,UAAU,CAAC;AACvE,OAAO,EAAE,IAAI,EAAgD,MAAM,WAAW,CAAC;AAC/E,OAAO,EAAE,IAAI,EAA0C,MAAM,WAAW,CAAC;AACzE,OAAO,EACL,OAAO,GAGR,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAA4B,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,EAAE,EAA8B,MAAM,SAAS,CAAC;AACzD,OAAO,EACL,OAAO,GAMR,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,MAAM,EAAe,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAuC,MAAM,eAAe,CAAC;AAC9E,OAAO,EAAE,IAAI,EAAoC,MAAM,WAAW,CAAC;AACnE,OAAO,EACL,OAAO,GAMR,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,SAAS,EACT,SAAS,IAAI,MAAM,EACnB,YAAY,EACZ,aAAa,EACb,SAAS,EACT,WAAW,EACX,cAAc,EACd,eAAe,EACf,aAAa,GAMd,MAAM,aAAa,CAAC;AAErB,OAAO,EAAoB,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EACL,MAAM,EACN,SAAS,EACT,MAAM,EACN,cAAc,EACd,WAAW,GACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/mdns.d.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export interface DiscoveredService {
|
|
2
|
+
/** The service type that was searched for, e.g. `_hub._tcp.local.` */
|
|
3
|
+
service: string;
|
|
4
|
+
/** The instance name, with the service type stripped: `Living Room Hub`. */
|
|
5
|
+
name: string;
|
|
6
|
+
/** The full record name, which is what identifies it uniquely. */
|
|
7
|
+
fullname: string;
|
|
8
|
+
/** The advertised host, e.g. `hub.local.` */
|
|
9
|
+
host: string;
|
|
10
|
+
port: number;
|
|
11
|
+
/** Every address the device answers on, sorted. IPv4 and IPv6. */
|
|
12
|
+
addresses: string[];
|
|
13
|
+
/** TXT record properties, which is where devices put their model and id. */
|
|
14
|
+
txt: Record<string, string>;
|
|
15
|
+
}
|
|
16
|
+
export interface DiscoverOptions {
|
|
17
|
+
/** A service type such as `_hub._tcp.local`. The trailing dot is optional. */
|
|
18
|
+
service: string;
|
|
19
|
+
/** How long to listen. Default 3000, capped at 60000. */
|
|
20
|
+
timeoutMs?: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Finding devices on the local network.
|
|
24
|
+
*
|
|
25
|
+
* Every device worth talking to announces itself over multicast DNS, and no
|
|
26
|
+
* browser can hear it. The alternative is asking your user to type in an IP
|
|
27
|
+
* address, which is why this is a platform capability.
|
|
28
|
+
*
|
|
29
|
+
* Vantail knows what a service type is and nothing about what answers to it -
|
|
30
|
+
* discovering `_hub._tcp.local` is generic; knowing the result speaks CLIP v2
|
|
31
|
+
* is your application's business.
|
|
32
|
+
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* const bridges = await mdns.discover({ service: "_hub._tcp.local" });
|
|
35
|
+
* for (const bridge of bridges) {
|
|
36
|
+
* console.log(bridge.name, bridge.addresses[0], bridge.txt["bridgeid"]);
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare const mdns: {
|
|
41
|
+
/**
|
|
42
|
+
* Listen for a fixed period and return everything that answered, deduplicated
|
|
43
|
+
* by full name. Resolves when the time is up, not when the first device
|
|
44
|
+
* replies - devices answer at their own pace.
|
|
45
|
+
*/
|
|
46
|
+
discover: (options: DiscoverOptions) => Promise<DiscoveredService[]>;
|
|
47
|
+
/**
|
|
48
|
+
* Keep watching, and report devices as they appear and disappear.
|
|
49
|
+
*
|
|
50
|
+
* Use this when the list is on screen; use {@link mdns.discover} when you
|
|
51
|
+
* just need the answer once. Resolves `{ started: false }` if that service
|
|
52
|
+
* type is already being watched.
|
|
53
|
+
*/
|
|
54
|
+
browse: (service: string) => Promise<{
|
|
55
|
+
service: string;
|
|
56
|
+
started: boolean;
|
|
57
|
+
}>;
|
|
58
|
+
/** Stop watching. `false` if it was not being watched. */
|
|
59
|
+
stop: (service: string) => Promise<boolean>;
|
|
60
|
+
/** Service types currently being watched. */
|
|
61
|
+
browsing: () => Promise<string[]>;
|
|
62
|
+
onFound: (handler: (service: DiscoveredService) => void) => () => void;
|
|
63
|
+
onLost: (handler: (service: Pick<DiscoveredService, "service" | "name" | "fullname">) => void) => () => void;
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=mdns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mdns.d.ts","sourceRoot":"","sources":["../src/mdns.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,iBAAiB;IAChC,sEAAsE;IACtE,OAAO,EAAE,MAAM,CAAC;IAChB,4EAA4E;IAC5E,IAAI,EAAE,MAAM,CAAC;IACb,kEAAkE;IAClE,QAAQ,EAAE,MAAM,CAAC;IACjB,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,kEAAkE;IAClE,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,4EAA4E;IAC5E,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7B;AAED,MAAM,WAAW,eAAe;IAC9B,8EAA8E;IAC9E,OAAO,EAAE,MAAM,CAAC;IAChB,yDAAyD;IACzD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,IAAI;IACf;;;;OAIG;IACH,QAAQ,YAAY,eAAe;IAGnC;;;;;;OAMG;IACH,MAAM,YAAY,MAAM;iBACJ,MAAM;iBAAW,OAAO;;IAE5C,0DAA0D;IAC1D,IAAI,YAAY,MAAM;IAEtB,6CAA6C;IAC7C,QAAQ;IAER,OAAO,YAAY,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI;IAGvD,MAAM,YACK,CACP,OAAO,EAAE,IAAI,CAAC,iBAAiB,EAAE,SAAS,GAAG,MAAM,GAAG,UAAU,CAAC,KAC9D,IAAI;CAMZ,CAAC"}
|
package/dist/mdns.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { invoke, listen } from "./transport.js";
|
|
2
|
+
/**
|
|
3
|
+
* Finding devices on the local network.
|
|
4
|
+
*
|
|
5
|
+
* Every device worth talking to announces itself over multicast DNS, and no
|
|
6
|
+
* browser can hear it. The alternative is asking your user to type in an IP
|
|
7
|
+
* address, which is why this is a platform capability.
|
|
8
|
+
*
|
|
9
|
+
* Vantail knows what a service type is and nothing about what answers to it -
|
|
10
|
+
* discovering `_hub._tcp.local` is generic; knowing the result speaks CLIP v2
|
|
11
|
+
* is your application's business.
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* const bridges = await mdns.discover({ service: "_hub._tcp.local" });
|
|
15
|
+
* for (const bridge of bridges) {
|
|
16
|
+
* console.log(bridge.name, bridge.addresses[0], bridge.txt["bridgeid"]);
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export const mdns = {
|
|
21
|
+
/**
|
|
22
|
+
* Listen for a fixed period and return everything that answered, deduplicated
|
|
23
|
+
* by full name. Resolves when the time is up, not when the first device
|
|
24
|
+
* replies - devices answer at their own pace.
|
|
25
|
+
*/
|
|
26
|
+
discover: (options) => invoke("mdns.discover", options),
|
|
27
|
+
/**
|
|
28
|
+
* Keep watching, and report devices as they appear and disappear.
|
|
29
|
+
*
|
|
30
|
+
* Use this when the list is on screen; use {@link mdns.discover} when you
|
|
31
|
+
* just need the answer once. Resolves `{ started: false }` if that service
|
|
32
|
+
* type is already being watched.
|
|
33
|
+
*/
|
|
34
|
+
browse: (service) => invoke("mdns.browse", { service }),
|
|
35
|
+
/** Stop watching. `false` if it was not being watched. */
|
|
36
|
+
stop: (service) => invoke("mdns.stop", { service }),
|
|
37
|
+
/** Service types currently being watched. */
|
|
38
|
+
browsing: () => invoke("mdns.browsing"),
|
|
39
|
+
onFound: (handler) => listen("mdns.found", handler),
|
|
40
|
+
onLost: (handler) => listen("mdns.lost", handler),
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=mdns.js.map
|
package/dist/mdns.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mdns.js","sourceRoot":"","sources":["../src/mdns.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAyBhD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB;;;;OAIG;IACH,QAAQ,EAAE,CAAC,OAAwB,EAAE,EAAE,CACrC,MAAM,CAAsB,eAAe,EAAE,OAAO,CAAC;IAEvD;;;;;;OAMG;IACH,MAAM,EAAE,CAAC,OAAe,EAAE,EAAE,CAC1B,MAAM,CAAwC,aAAa,EAAE,EAAE,OAAO,EAAE,CAAC;IAE3E,0DAA0D;IAC1D,IAAI,EAAE,CAAC,OAAe,EAAE,EAAE,CAAC,MAAM,CAAU,WAAW,EAAE,EAAE,OAAO,EAAE,CAAC;IAEpE,6CAA6C;IAC7C,QAAQ,EAAE,GAAG,EAAE,CAAC,MAAM,CAAW,eAAe,CAAC;IAEjD,OAAO,EAAE,CAAC,OAA6C,EAAE,EAAE,CACzD,MAAM,CAAoB,YAAY,EAAE,OAAO,CAAC;IAElD,MAAM,EAAE,CACN,OAES,EACT,EAAE,CACF,MAAM,CACJ,WAAW,EACX,OAAO,CACR;CACJ,CAAC"}
|