@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.
Files changed (109) hide show
  1. package/dist/app.d.ts +87 -0
  2. package/dist/app.d.ts.map +1 -0
  3. package/dist/app.js +79 -0
  4. package/dist/app.js.map +1 -0
  5. package/dist/autostart.d.ts +21 -0
  6. package/dist/autostart.d.ts.map +1 -0
  7. package/dist/autostart.js +28 -0
  8. package/dist/autostart.js.map +1 -0
  9. package/dist/binary.d.ts +13 -0
  10. package/dist/binary.d.ts.map +1 -0
  11. package/dist/binary.js +41 -0
  12. package/dist/binary.js.map +1 -0
  13. package/dist/clipboard.d.ts +36 -0
  14. package/dist/clipboard.d.ts.map +1 -0
  15. package/dist/clipboard.js +34 -0
  16. package/dist/clipboard.js.map +1 -0
  17. package/dist/deeplink.d.ts +36 -0
  18. package/dist/deeplink.d.ts.map +1 -0
  19. package/dist/deeplink.js +61 -0
  20. package/dist/deeplink.js.map +1 -0
  21. package/dist/dialog.d.ts +48 -0
  22. package/dist/dialog.d.ts.map +1 -0
  23. package/dist/dialog.js +25 -0
  24. package/dist/dialog.js.map +1 -0
  25. package/dist/drop.d.ts +37 -0
  26. package/dist/drop.d.ts.map +1 -0
  27. package/dist/drop.js +29 -0
  28. package/dist/drop.js.map +1 -0
  29. package/dist/error.d.ts +27 -0
  30. package/dist/error.d.ts.map +1 -0
  31. package/dist/error.js +39 -0
  32. package/dist/error.js.map +1 -0
  33. package/dist/filesystem.d.ts +99 -0
  34. package/dist/filesystem.d.ts.map +1 -0
  35. package/dist/filesystem.js +75 -0
  36. package/dist/filesystem.js.map +1 -0
  37. package/dist/hid.d.ts +69 -0
  38. package/dist/hid.d.ts.map +1 -0
  39. package/dist/hid.js +54 -0
  40. package/dist/hid.js.map +1 -0
  41. package/dist/index.d.ts +41 -0
  42. package/dist/index.d.ts.map +1 -0
  43. package/dist/index.js +40 -0
  44. package/dist/index.js.map +1 -0
  45. package/dist/mdns.d.ts +65 -0
  46. package/dist/mdns.d.ts.map +1 -0
  47. package/dist/mdns.js +42 -0
  48. package/dist/mdns.js.map +1 -0
  49. package/dist/menu.d.ts +83 -0
  50. package/dist/menu.d.ts.map +1 -0
  51. package/dist/menu.js +55 -0
  52. package/dist/menu.js.map +1 -0
  53. package/dist/network.d.ts +61 -0
  54. package/dist/network.d.ts.map +1 -0
  55. package/dist/network.js +59 -0
  56. package/dist/network.js.map +1 -0
  57. package/dist/notification.d.ts +17 -0
  58. package/dist/notification.d.ts.map +1 -0
  59. package/dist/notification.js +13 -0
  60. package/dist/notification.js.map +1 -0
  61. package/dist/os.d.ts +22 -0
  62. package/dist/os.d.ts.map +1 -0
  63. package/dist/os.js +20 -0
  64. package/dist/os.js.map +1 -0
  65. package/dist/power.d.ts +29 -0
  66. package/dist/power.d.ts.map +1 -0
  67. package/dist/power.js +30 -0
  68. package/dist/power.js.map +1 -0
  69. package/dist/process.d.ts +69 -0
  70. package/dist/process.d.ts.map +1 -0
  71. package/dist/process.js +44 -0
  72. package/dist/process.js.map +1 -0
  73. package/dist/protocol.d.ts +66 -0
  74. package/dist/protocol.d.ts.map +1 -0
  75. package/dist/protocol.js +26 -0
  76. package/dist/protocol.js.map +1 -0
  77. package/dist/screen.d.ts +49 -0
  78. package/dist/screen.d.ts.map +1 -0
  79. package/dist/screen.js +38 -0
  80. package/dist/screen.js.map +1 -0
  81. package/dist/secrets.d.ts +31 -0
  82. package/dist/secrets.d.ts.map +1 -0
  83. package/dist/secrets.js +32 -0
  84. package/dist/secrets.js.map +1 -0
  85. package/dist/shell.d.ts +14 -0
  86. package/dist/shell.d.ts.map +1 -0
  87. package/dist/shell.js +13 -0
  88. package/dist/shell.js.map +1 -0
  89. package/dist/shortcut.d.ts +45 -0
  90. package/dist/shortcut.d.ts.map +1 -0
  91. package/dist/shortcut.js +45 -0
  92. package/dist/shortcut.js.map +1 -0
  93. package/dist/transport.d.ts +36 -0
  94. package/dist/transport.d.ts.map +1 -0
  95. package/dist/transport.js +141 -0
  96. package/dist/transport.js.map +1 -0
  97. package/dist/tray.d.ts +59 -0
  98. package/dist/tray.d.ts.map +1 -0
  99. package/dist/tray.js +30 -0
  100. package/dist/tray.js.map +1 -0
  101. package/dist/updater.d.ts +65 -0
  102. package/dist/updater.d.ts.map +1 -0
  103. package/dist/updater.js +48 -0
  104. package/dist/updater.js.map +1 -0
  105. package/dist/window.d.ts +156 -0
  106. package/dist/window.d.ts.map +1 -0
  107. package/dist/window.js +141 -0
  108. package/dist/window.js.map +1 -0
  109. package/package.json +27 -0
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The wire protocol, as the browser side sees it.
3
+ *
4
+ * Intentionally duplicated from `@vantail/shared` rather than imported:
5
+ * `@vantail/api` ships into application bundles, and a UI package with zero
6
+ * dependencies is worth more than one shared file. `packages/shared` holds
7
+ * the same shapes for the tooling side, and `runtime/src/ipc` for the native
8
+ * side; all three are checked against each other by the protocol tests.
9
+ */
10
+ export function isEventMessage(message) {
11
+ return typeof message.event === "string";
12
+ }
13
+ /** Stable error codes. `NO_RUNTIME` is the only one the SDK raises itself. */
14
+ export const ErrorCode = {
15
+ NO_RUNTIME: "NO_RUNTIME",
16
+ UNKNOWN_METHOD: "UNKNOWN_METHOD",
17
+ INVALID_PARAMS: "INVALID_PARAMS",
18
+ PERMISSION_DENIED: "PERMISSION_DENIED",
19
+ NOT_FOUND: "NOT_FOUND",
20
+ ALREADY_EXISTS: "ALREADY_EXISTS",
21
+ IO_ERROR: "IO_ERROR",
22
+ INVALID_UTF8: "INVALID_UTF8",
23
+ UNSUPPORTED: "UNSUPPORTED",
24
+ INTERNAL: "INTERNAL",
25
+ };
26
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA2BH,MAAM,UAAU,cAAc,CAC5B,OAAwB;IAExB,OAAO,OAAQ,OAA+B,CAAC,KAAK,KAAK,QAAQ,CAAC;AACpE,CAAC;AAED,8EAA8E;AAC9E,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,UAAU,EAAE,YAAY;IACxB,cAAc,EAAE,gBAAgB;IAChC,cAAc,EAAE,gBAAgB;IAChC,iBAAiB,EAAE,mBAAmB;IACtC,SAAS,EAAE,WAAW;IACtB,cAAc,EAAE,gBAAgB;IAChC,QAAQ,EAAE,UAAU;IACpB,YAAY,EAAE,cAAc;IAC5B,WAAW,EAAE,aAAa;IAC1B,QAAQ,EAAE,UAAU;CACZ,CAAC"}
@@ -0,0 +1,49 @@
1
+ export interface Screen {
2
+ /** What the operating system calls it, when it says anything. */
3
+ name: string | null;
4
+ /**
5
+ * Where its top-left corner sits in the desktop coordinate space, in
6
+ * logical pixels. A screen left of the primary one has a negative `x`.
7
+ */
8
+ position: {
9
+ x: number;
10
+ y: number;
11
+ };
12
+ /** Its size in logical pixels - the same units window methods take. */
13
+ size: {
14
+ width: number;
15
+ height: number;
16
+ };
17
+ /** 2 on a Retina display, 1 on most others. */
18
+ scaleFactor: number;
19
+ primary: boolean;
20
+ }
21
+ /**
22
+ * The displays a window can be put on.
23
+ *
24
+ * A page can see the screen it is on through `window.screen`, but not the
25
+ * others, and not where they sit relative to each other - so
26
+ * {@link appWindow.setPosition} is guesswork on a machine with two monitors
27
+ * without this.
28
+ *
29
+ * Everything is in logical pixels, matching the window methods.
30
+ *
31
+ * ```ts
32
+ * const { position, size } = await screen.current();
33
+ * await appWindow.setPosition(
34
+ * position.x + (size.width - 900) / 2,
35
+ * position.y + (size.height - 640) / 2,
36
+ * );
37
+ * ```
38
+ */
39
+ export declare const screen: {
40
+ /** Every connected display. */
41
+ list(): Promise<Screen[]>;
42
+ /** The one the system considers primary, if it names one. */
43
+ primary(): Promise<Screen | null>;
44
+ /** The one this window is currently on. */
45
+ current(): Promise<Screen | null>;
46
+ /** Whichever display contains a desktop coordinate, if any does. */
47
+ fromPoint(x: number, y: number): Promise<Screen | null>;
48
+ };
49
+ //# sourceMappingURL=screen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"screen.d.ts","sourceRoot":"","sources":["../src/screen.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,MAAM;IACrB,iEAAiE;IACjE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB;;;OAGG;IACH,QAAQ,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACnC,uEAAuE;IACvE,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACxC,+CAA+C;IAC/C,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,MAAM;IACjB,+BAA+B;IAC/B,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAIzB,6DAA6D;IAC7D,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAIjC,2CAA2C;IAC3C,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAIjC,oEAAoE;IACpE,SAAS,IAAI,MAAM,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAGxD,CAAC"}
package/dist/screen.js ADDED
@@ -0,0 +1,38 @@
1
+ import { invoke } from "./transport.js";
2
+ /**
3
+ * The displays a window can be put on.
4
+ *
5
+ * A page can see the screen it is on through `window.screen`, but not the
6
+ * others, and not where they sit relative to each other - so
7
+ * {@link appWindow.setPosition} is guesswork on a machine with two monitors
8
+ * without this.
9
+ *
10
+ * Everything is in logical pixels, matching the window methods.
11
+ *
12
+ * ```ts
13
+ * const { position, size } = await screen.current();
14
+ * await appWindow.setPosition(
15
+ * position.x + (size.width - 900) / 2,
16
+ * position.y + (size.height - 640) / 2,
17
+ * );
18
+ * ```
19
+ */
20
+ export const screen = {
21
+ /** Every connected display. */
22
+ list() {
23
+ return invoke("screen.list");
24
+ },
25
+ /** The one the system considers primary, if it names one. */
26
+ primary() {
27
+ return invoke("screen.primary");
28
+ },
29
+ /** The one this window is currently on. */
30
+ current() {
31
+ return invoke("screen.current");
32
+ },
33
+ /** Whichever display contains a desktop coordinate, if any does. */
34
+ fromPoint(x, y) {
35
+ return invoke("screen.fromPoint", { x, y });
36
+ },
37
+ };
38
+ //# sourceMappingURL=screen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"screen.js","sourceRoot":"","sources":["../src/screen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAiBxC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,+BAA+B;IAC/B,IAAI;QACF,OAAO,MAAM,CAAW,aAAa,CAAC,CAAC;IACzC,CAAC;IAED,6DAA6D;IAC7D,OAAO;QACL,OAAO,MAAM,CAAgB,gBAAgB,CAAC,CAAC;IACjD,CAAC;IAED,2CAA2C;IAC3C,OAAO;QACL,OAAO,MAAM,CAAgB,gBAAgB,CAAC,CAAC;IACjD,CAAC;IAED,oEAAoE;IACpE,SAAS,CAAC,CAAS,EAAE,CAAS;QAC5B,OAAO,MAAM,CAAgB,kBAAkB,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAC7D,CAAC;CACF,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * The operating system's credential store.
3
+ *
4
+ * An application that holds an OAuth refresh token has to put it somewhere.
5
+ * `localStorage` is a plaintext file in the application's data directory,
6
+ * readable by anything running as the user. This is the Keychain on macOS,
7
+ * the Credential Manager on Windows, and the Secret Service on Linux.
8
+ *
9
+ * Entries are filed under the application's `identifier`, so two Vantail
10
+ * applications on the same machine cannot read each other's.
11
+ *
12
+ * ```ts
13
+ * await secrets.set("service.refreshToken", token);
14
+ *
15
+ * const token = await secrets.get("service.refreshToken");
16
+ * if (token === null) await signIn();
17
+ * ```
18
+ *
19
+ * There is no `list()`: the platforms disagree about whether enumerating a
20
+ * store is even possible, and an API that works on one of three is worse than
21
+ * none. Keep your own index if you need one.
22
+ */
23
+ export declare const secrets: {
24
+ set: (key: string, value: string) => Promise<null>;
25
+ /** `null` when there is nothing stored - a missing secret is an answer. */
26
+ get: (key: string) => Promise<string | null>;
27
+ has: (key: string) => Promise<boolean>;
28
+ /** `true` if something was removed, `false` if there was nothing there. */
29
+ delete: (key: string) => Promise<boolean>;
30
+ };
31
+ //# sourceMappingURL=secrets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../src/secrets.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,OAAO;IAClB,GAAG,QAAQ,MAAM,SAAS,MAAM;IAGhC,2EAA2E;IAC3E,GAAG,QAAQ,MAAM;IAEjB,GAAG,QAAQ,MAAM;IAEjB,2EAA2E;IAC3E,MAAM,QAAQ,MAAM;CACrB,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { invoke } from "./transport.js";
2
+ /**
3
+ * The operating system's credential store.
4
+ *
5
+ * An application that holds an OAuth refresh token has to put it somewhere.
6
+ * `localStorage` is a plaintext file in the application's data directory,
7
+ * readable by anything running as the user. This is the Keychain on macOS,
8
+ * the Credential Manager on Windows, and the Secret Service on Linux.
9
+ *
10
+ * Entries are filed under the application's `identifier`, so two Vantail
11
+ * applications on the same machine cannot read each other's.
12
+ *
13
+ * ```ts
14
+ * await secrets.set("service.refreshToken", token);
15
+ *
16
+ * const token = await secrets.get("service.refreshToken");
17
+ * if (token === null) await signIn();
18
+ * ```
19
+ *
20
+ * There is no `list()`: the platforms disagree about whether enumerating a
21
+ * store is even possible, and an API that works on one of three is worse than
22
+ * none. Keep your own index if you need one.
23
+ */
24
+ export const secrets = {
25
+ set: (key, value) => invoke("secrets.set", { key, value }),
26
+ /** `null` when there is nothing stored - a missing secret is an answer. */
27
+ get: (key) => invoke("secrets.get", { key }),
28
+ has: (key) => invoke("secrets.has", { key }),
29
+ /** `true` if something was removed, `false` if there was nothing there. */
30
+ delete: (key) => invoke("secrets.delete", { key }),
31
+ };
32
+ //# sourceMappingURL=secrets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secrets.js","sourceRoot":"","sources":["../src/secrets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,GAAG,EAAE,CAAC,GAAW,EAAE,KAAa,EAAE,EAAE,CAClC,MAAM,CAAO,aAAa,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;IAE7C,2EAA2E;IAC3E,GAAG,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,MAAM,CAAgB,aAAa,EAAE,EAAE,GAAG,EAAE,CAAC;IAEnE,GAAG,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,MAAM,CAAU,aAAa,EAAE,EAAE,GAAG,EAAE,CAAC;IAE7D,2EAA2E;IAC3E,MAAM,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,MAAM,CAAU,gBAAgB,EAAE,EAAE,GAAG,EAAE,CAAC;CACpE,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Handing something to the system's default application.
3
+ *
4
+ * Small API, large blast radius: on every platform "open this path" can mean
5
+ * "run this program". It is denied unless `permissions.shell.open` says
6
+ * otherwise, and the pattern is matched against the exact string you pass.
7
+ */
8
+ export declare const shell: {
9
+ /** A URL, or a path to a file or directory. */
10
+ open: (target: string, options?: {
11
+ with?: string;
12
+ }) => Promise<null>;
13
+ };
14
+ //# sourceMappingURL=shell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../src/shell.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,eAAO,MAAM,KAAK;IAChB,+CAA+C;IAC/C,IAAI,WAAW,MAAM,YAAW;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE;CAElD,CAAC"}
package/dist/shell.js ADDED
@@ -0,0 +1,13 @@
1
+ import { invoke } from "./transport.js";
2
+ /**
3
+ * Handing something to the system's default application.
4
+ *
5
+ * Small API, large blast radius: on every platform "open this path" can mean
6
+ * "run this program". It is denied unless `permissions.shell.open` says
7
+ * otherwise, and the pattern is matched against the exact string you pass.
8
+ */
9
+ export const shell = {
10
+ /** A URL, or a path to a file or directory. */
11
+ open: (target, options = {}) => invoke("shell.open", { target, ...options }),
12
+ };
13
+ //# sourceMappingURL=shell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell.js","sourceRoot":"","sources":["../src/shell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,+CAA+C;IAC/C,IAAI,EAAE,CAAC,MAAc,EAAE,OAAO,GAAsB,EAAE,EAAE,EAAE,CACxD,MAAM,CAAO,YAAY,EAAE,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,CAAC;CACrD,CAAC"}
@@ -0,0 +1,45 @@
1
+ export interface Shortcut {
2
+ /** What {@link shortcut.onPressed} reports. The accelerator, unless given. */
3
+ id: string;
4
+ /** The combination itself, e.g. `CmdOrCtrl+Shift+K`. */
5
+ accelerator: string;
6
+ }
7
+ export interface RegisterOptions {
8
+ /**
9
+ * A name for this shortcut, if the accelerator is not one you want to
10
+ * switch on. Handy when the combination is configurable.
11
+ */
12
+ id?: string;
13
+ }
14
+ /**
15
+ * Key combinations that fire while your application is in the background.
16
+ *
17
+ * A page only sees keys while it has focus, which is exactly what a global
18
+ * shortcut is not for - so this is native.
19
+ *
20
+ * Registration is system-wide, so it can fail because another application
21
+ * already owns the combination. That throws `ALREADY_EXISTS`, and it is worth
22
+ * handling: it is an ordinary thing to happen, not a bug.
23
+ *
24
+ * ```ts
25
+ * await shortcut.register("CmdOrCtrl+Shift+K", { id: "toggle" });
26
+ * shortcut.onPressed(({ id }) => {
27
+ * if (id === "toggle") void appWindow.show();
28
+ * });
29
+ * ```
30
+ */
31
+ export declare const shortcut: {
32
+ /** Claim a combination system-wide. */
33
+ register(accelerator: string, options?: RegisterOptions): Promise<Shortcut>;
34
+ /** Give one back. Throws `NOT_FOUND` if it was never registered. */
35
+ unregister(accelerator: string): Promise<void>;
36
+ /** Give all of them back. */
37
+ unregisterAll(): Promise<void>;
38
+ /** Whether *this application* holds it. Another one might. */
39
+ isRegistered(accelerator: string): Promise<boolean>;
40
+ /** Everything this application currently holds. */
41
+ list(): Promise<Shortcut[]>;
42
+ /** Fires on press, wherever the user happens to be. */
43
+ onPressed(handler: (shortcut: Shortcut) => void): () => void;
44
+ };
45
+ //# sourceMappingURL=shortcut.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shortcut.d.ts","sourceRoot":"","sources":["../src/shortcut.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,QAAQ;IACvB,8EAA8E;IAC9E,EAAE,EAAE,MAAM,CAAC;IACX,wDAAwD;IACxD,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,QAAQ;IACnB,uCAAuC;IACvC,QAAQ,cACO,MAAM,YACV,eAAe,GACvB,OAAO,CAAC,QAAQ,CAAC;IAIpB,oEAAoE;IACpE,UAAU,cAAc,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9C,6BAA6B;IAC7B,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B,8DAA8D;IAC9D,YAAY,cAAc,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAInD,mDAAmD;IACnD,IAAI,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IAI3B,uDAAuD;IACvD,SAAS,UAAU,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,GAAG,MAAM,IAAI;CAG7D,CAAC"}
@@ -0,0 +1,45 @@
1
+ import { invoke, listen } from "./transport.js";
2
+ /**
3
+ * Key combinations that fire while your application is in the background.
4
+ *
5
+ * A page only sees keys while it has focus, which is exactly what a global
6
+ * shortcut is not for - so this is native.
7
+ *
8
+ * Registration is system-wide, so it can fail because another application
9
+ * already owns the combination. That throws `ALREADY_EXISTS`, and it is worth
10
+ * handling: it is an ordinary thing to happen, not a bug.
11
+ *
12
+ * ```ts
13
+ * await shortcut.register("CmdOrCtrl+Shift+K", { id: "toggle" });
14
+ * shortcut.onPressed(({ id }) => {
15
+ * if (id === "toggle") void appWindow.show();
16
+ * });
17
+ * ```
18
+ */
19
+ export const shortcut = {
20
+ /** Claim a combination system-wide. */
21
+ register(accelerator, options = {}) {
22
+ return invoke("shortcut.register", { accelerator, ...options });
23
+ },
24
+ /** Give one back. Throws `NOT_FOUND` if it was never registered. */
25
+ unregister(accelerator) {
26
+ return invoke("shortcut.unregister", { accelerator });
27
+ },
28
+ /** Give all of them back. */
29
+ unregisterAll() {
30
+ return invoke("shortcut.unregisterAll");
31
+ },
32
+ /** Whether *this application* holds it. Another one might. */
33
+ isRegistered(accelerator) {
34
+ return invoke("shortcut.isRegistered", { accelerator });
35
+ },
36
+ /** Everything this application currently holds. */
37
+ list() {
38
+ return invoke("shortcut.list");
39
+ },
40
+ /** Fires on press, wherever the user happens to be. */
41
+ onPressed(handler) {
42
+ return listen("shortcut.pressed", handler);
43
+ },
44
+ };
45
+ //# sourceMappingURL=shortcut.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shortcut.js","sourceRoot":"","sources":["../src/shortcut.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAiBhD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,uCAAuC;IACvC,QAAQ,CACN,WAAmB,EACnB,OAAO,GAAoB,EAAE;QAE7B,OAAO,MAAM,CAAW,mBAAmB,EAAE,EAAE,WAAW,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED,oEAAoE;IACpE,UAAU,CAAC,WAAmB;QAC5B,OAAO,MAAM,CAAO,qBAAqB,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,6BAA6B;IAC7B,aAAa;QACX,OAAO,MAAM,CAAO,wBAAwB,CAAC,CAAC;IAChD,CAAC;IAED,8DAA8D;IAC9D,YAAY,CAAC,WAAmB;QAC9B,OAAO,MAAM,CAAU,uBAAuB,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;IACnE,CAAC;IAED,mDAAmD;IACnD,IAAI;QACF,OAAO,MAAM,CAAa,eAAe,CAAC,CAAC;IAC7C,CAAC;IAED,uDAAuD;IACvD,SAAS,CAAC,OAAqC;QAC7C,OAAO,MAAM,CAAW,kBAAkB,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;CACF,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * The one place that talks to the runtime.
3
+ *
4
+ * Requests go out through the injected bridge and come back matched by id.
5
+ * Everything else in this package is a typed wrapper around `invoke`.
6
+ */
7
+ import { type VantailBridge } from "./protocol.js";
8
+ /** Whether this page is running inside a Vantail window. */
9
+ export declare function isVantail(): boolean;
10
+ /**
11
+ * Static application facts the runtime injected, available synchronously.
12
+ * Returns `undefined` in a plain browser.
13
+ */
14
+ export declare function bridgeInfo(): VantailBridge["app"] | undefined;
15
+ /** Version of the native runtime, or `undefined` outside one. */
16
+ export declare function runtimeVersion(): string | undefined;
17
+ /**
18
+ * The label of the window this code is running in, without awaiting.
19
+ * `undefined` in a plain browser.
20
+ */
21
+ export declare function windowLabel(): string | undefined;
22
+ /**
23
+ * Call a native method.
24
+ *
25
+ * Prefer the typed modules (`filesystem`, `dialog`, ...); this is the escape
26
+ * hatch for methods the SDK does not wrap yet.
27
+ */
28
+ export declare function invoke<T = unknown>(method: string, params?: unknown): Promise<T>;
29
+ /**
30
+ * Listen for a runtime event. Returns an unsubscribe function.
31
+ *
32
+ * Listening does not require the runtime to be present - outside a Vantail
33
+ * window the returned function is simply never called.
34
+ */
35
+ export declare function listen<T = unknown>(event: string, handler: (payload: T) => void): () => void;
36
+ //# sourceMappingURL=transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAEL,KAAK,aAAa,EAEnB,MAAM,eAAe,CAAC;AAmBvB,4DAA4D;AAC5D,wBAAgB,SAAS,IAAI,OAAO,CAEnC;AAED;;;GAGG;AACH,wBAAgB,UAAU,IAAI,aAAa,CAAC,KAAK,CAAC,GAAG,SAAS,CAE7D;AAED,iEAAiE;AACjE,wBAAgB,cAAc,IAAI,MAAM,GAAG,SAAS,CAEnD;AAED;;;GAGG;AACH,wBAAgB,WAAW,IAAI,MAAM,GAAG,SAAS,CAEhD;AAwCD;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,CAAC,GAAG,OAAO,EAChC,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,OAAO,GACf,OAAO,CAAC,CAAC,CAAC,CAwBZ;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,CAAC,GAAG,OAAO,EAChC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI,GAC5B,MAAM,IAAI,CAoBZ"}
@@ -0,0 +1,141 @@
1
+ /**
2
+ * The one place that talks to the runtime.
3
+ *
4
+ * Requests go out through the injected bridge and come back matched by id.
5
+ * Everything else in this package is a typed wrapper around `invoke`.
6
+ */
7
+ import { isEventMessage, } from "./protocol.js";
8
+ import { noRuntime, VantailError } from "./error.js";
9
+ const pending = new Map();
10
+ const listeners = new Map();
11
+ let subscription = null;
12
+ let counter = 0;
13
+ function getBridge() {
14
+ return globalThis.__VANTAIL__;
15
+ }
16
+ /** Whether this page is running inside a Vantail window. */
17
+ export function isVantail() {
18
+ return getBridge() !== undefined;
19
+ }
20
+ /**
21
+ * Static application facts the runtime injected, available synchronously.
22
+ * Returns `undefined` in a plain browser.
23
+ */
24
+ export function bridgeInfo() {
25
+ return getBridge()?.app;
26
+ }
27
+ /** Version of the native runtime, or `undefined` outside one. */
28
+ export function runtimeVersion() {
29
+ return getBridge()?.version;
30
+ }
31
+ /**
32
+ * The label of the window this code is running in, without awaiting.
33
+ * `undefined` in a plain browser.
34
+ */
35
+ export function windowLabel() {
36
+ return getBridge()?.label;
37
+ }
38
+ function requireBridge() {
39
+ const bridge = getBridge();
40
+ if (!bridge)
41
+ throw noRuntime();
42
+ subscribe(bridge);
43
+ return bridge;
44
+ }
45
+ function subscribe(bridge) {
46
+ if (subscription)
47
+ return;
48
+ subscription = bridge.subscribe(receive);
49
+ }
50
+ function receive(message) {
51
+ if (isEventMessage(message)) {
52
+ const handlers = listeners.get(message.event);
53
+ if (!handlers)
54
+ return;
55
+ // Copy first: a handler is allowed to unsubscribe itself.
56
+ for (const handler of [...handlers]) {
57
+ try {
58
+ handler(message.payload);
59
+ }
60
+ catch (error) {
61
+ console.error(`[vantail] a "${message.event}" listener threw`, error);
62
+ }
63
+ }
64
+ return;
65
+ }
66
+ const entry = pending.get(message.id);
67
+ if (!entry)
68
+ return;
69
+ pending.delete(message.id);
70
+ if (message.error) {
71
+ entry.reject(VantailError.from(message.error));
72
+ }
73
+ else {
74
+ entry.resolve(message.result ?? null);
75
+ }
76
+ }
77
+ /**
78
+ * Call a native method.
79
+ *
80
+ * Prefer the typed modules (`filesystem`, `dialog`, ...); this is the escape
81
+ * hatch for methods the SDK does not wrap yet.
82
+ */
83
+ export function invoke(method, params) {
84
+ let bridge;
85
+ try {
86
+ bridge = requireBridge();
87
+ }
88
+ catch (error) {
89
+ return Promise.reject(error);
90
+ }
91
+ const id = nextId();
92
+ return new Promise((resolve, reject) => {
93
+ pending.set(id, { resolve: resolve, reject });
94
+ try {
95
+ bridge.postMessage({ id, method, params });
96
+ }
97
+ catch (error) {
98
+ pending.delete(id);
99
+ reject(new VantailError("INTERNAL", `Could not send \`${method}\` to the runtime: ${String(error)}`));
100
+ }
101
+ });
102
+ }
103
+ /**
104
+ * Listen for a runtime event. Returns an unsubscribe function.
105
+ *
106
+ * Listening does not require the runtime to be present - outside a Vantail
107
+ * window the returned function is simply never called.
108
+ */
109
+ export function listen(event, handler) {
110
+ let handlers = listeners.get(event);
111
+ if (!handlers) {
112
+ handlers = new Set();
113
+ listeners.set(event, handlers);
114
+ }
115
+ handlers.add(handler);
116
+ // Registered before subscribing: subscribing hands over anything that
117
+ // arrived before this page's script ran, and a handler added afterwards
118
+ // would miss exactly the message it was written for.
119
+ const bridge = getBridge();
120
+ if (bridge)
121
+ subscribe(bridge);
122
+ return () => {
123
+ const current = listeners.get(event);
124
+ if (!current)
125
+ return;
126
+ current.delete(handler);
127
+ if (current.size === 0)
128
+ listeners.delete(event);
129
+ };
130
+ }
131
+ function nextId() {
132
+ const crypto = globalThis.crypto;
133
+ if (crypto && typeof crypto.randomUUID === "function") {
134
+ return crypto.randomUUID();
135
+ }
136
+ // Only needs to be unique within this page, not unguessable: the channel is
137
+ // the platform's own IPC, not a network socket.
138
+ counter += 1;
139
+ return `vantail-${Date.now().toString(36)}-${counter}`;
140
+ }
141
+ //# sourceMappingURL=transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.js","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,cAAc,GAGf,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,SAAS,EAAE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4EAA4E;IAC5E,gDAAgD;IAChD,OAAO,IAAI,CAAC,CAAC;IACb,OAAO,WAAW,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,OAAO,EAAE,CAAC;AACzD,CAAC"}
package/dist/tray.d.ts ADDED
@@ -0,0 +1,59 @@
1
+ import { type MenuItem } from "./menu.js";
2
+ export interface TrayOptions {
3
+ /** PNG path. Relative paths resolve inside the application's resources. */
4
+ icon?: string;
5
+ tooltip?: string;
6
+ /** Text beside the icon. macOS only. */
7
+ title?: string;
8
+ /**
9
+ * Render the icon as a monochrome template. On macOS this is what makes it
10
+ * invert correctly against a dark menu bar - usually what you want.
11
+ */
12
+ iconAsTemplate?: boolean;
13
+ menu?: MenuItem[];
14
+ /**
15
+ * What a left click on the icon does. A right click always opens the menu.
16
+ *
17
+ * - `showWindow` (default) - bring the window back if it is hidden, focus
18
+ * it if it is behind something, and open the menu if it is already in
19
+ * front. Which is what a tray icon is usually for.
20
+ * - `menu` - always open the menu, the older macOS convention.
21
+ * - `event` - do nothing but fire {@link tray.onClick}.
22
+ */
23
+ leftClick?: "showWindow" | "menu" | "event";
24
+ /** Which window `showWindow` brings back. `main` by default. */
25
+ window?: string;
26
+ }
27
+ export interface TrayClick {
28
+ button: string;
29
+ /** Screen coordinates, in physical pixels. */
30
+ x: number;
31
+ y: number;
32
+ }
33
+ /**
34
+ * The menu bar / system tray icon.
35
+ *
36
+ * An application that wants to keep running with no window open should also
37
+ * set `quitOnLastWindowClosed: false` in its config - otherwise closing the
38
+ * window takes the tray icon with it.
39
+ */
40
+ export declare const tray: {
41
+ /** Create the tray icon, or replace the one that is there. */
42
+ set: (options: TrayOptions) => Promise<null>;
43
+ remove: () => Promise<null>;
44
+ exists: () => Promise<boolean>;
45
+ setIcon: (icon: string, options?: {
46
+ template?: boolean;
47
+ }) => Promise<null>;
48
+ setTooltip: (tooltip: string | null) => Promise<null>;
49
+ /** macOS only; ignored elsewhere. */
50
+ setTitle: (title: string | null) => Promise<null>;
51
+ setVisible: (visible: boolean) => Promise<null>;
52
+ setMenu: (items: MenuItem[]) => Promise<null>;
53
+ /** Open the tray menu without waiting for a click on the icon. */
54
+ showMenu: () => Promise<null>;
55
+ onClick: (handler: (event: TrayClick) => void) => () => void;
56
+ /** Windows only. */
57
+ onDoubleClick: (handler: (event: TrayClick) => void) => () => void;
58
+ };
59
+ //# sourceMappingURL=tray.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tray.d.ts","sourceRoot":"","sources":["../src/tray.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;AAGrD,MAAM,WAAW,WAAW;IAC1B,2EAA2E;IAC3E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC;IAClB;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,YAAY,GAAG,MAAM,GAAG,OAAO,CAAC;IAC5C,gEAAgE;IAChE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED;;;;;;GAMG;AACH,eAAO,MAAM,IAAI;IACf,8DAA8D;IAC9D,GAAG,YAAY,WAAW;IAM1B,MAAM;IACN,MAAM;IAEN,OAAO,SAAS,MAAM,YAAW;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE;IAEvD,UAAU,YAAY,MAAM,GAAG,IAAI;IAEnC,qCAAqC;IACrC,QAAQ,UAAU,MAAM,GAAG,IAAI;IAC/B,UAAU,YAAY,OAAO;IAE7B,OAAO,UAAU,QAAQ,EAAE;IAG3B,kEAAkE;IAClE,QAAQ;IAER,OAAO,YAAY,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI;IAE7C,oBAAoB;IACpB,aAAa,YAAY,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI;CAEpD,CAAC"}
package/dist/tray.js ADDED
@@ -0,0 +1,30 @@
1
+ import { normalize } from "./menu.js";
2
+ import { invoke, listen } from "./transport.js";
3
+ /**
4
+ * The menu bar / system tray icon.
5
+ *
6
+ * An application that wants to keep running with no window open should also
7
+ * set `quitOnLastWindowClosed: false` in its config - otherwise closing the
8
+ * window takes the tray icon with it.
9
+ */
10
+ export const tray = {
11
+ /** Create the tray icon, or replace the one that is there. */
12
+ set: (options) => invoke("tray.set", {
13
+ ...options,
14
+ ...(options.menu ? { menu: normalize(options.menu) } : {}),
15
+ }),
16
+ remove: () => invoke("tray.remove"),
17
+ exists: () => invoke("tray.exists"),
18
+ setIcon: (icon, options = {}) => invoke("tray.setIcon", { icon, ...options }),
19
+ setTooltip: (tooltip) => invoke("tray.setTooltip", { tooltip }),
20
+ /** macOS only; ignored elsewhere. */
21
+ setTitle: (title) => invoke("tray.setTitle", { title }),
22
+ setVisible: (visible) => invoke("tray.setVisible", { visible }),
23
+ setMenu: (items) => invoke("tray.setMenu", { items: normalize(items) }),
24
+ /** Open the tray menu without waiting for a click on the icon. */
25
+ showMenu: () => invoke("tray.showMenu"),
26
+ onClick: (handler) => listen("tray.click", handler),
27
+ /** Windows only. */
28
+ onDoubleClick: (handler) => listen("tray.doubleClick", handler),
29
+ };
30
+ //# sourceMappingURL=tray.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tray.js","sourceRoot":"","sources":["../src/tray.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAiB,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAmChD;;;;;;GAMG;AACH,MAAM,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