@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
package/dist/menu.d.ts ADDED
@@ -0,0 +1,83 @@
1
+ /** A menu entry. `type` defaults to `normal`. */
2
+ export type MenuItem = {
3
+ type?: "normal";
4
+ id: string;
5
+ label: string;
6
+ enabled?: boolean;
7
+ /** e.g. `CmdOrCtrl+S`, `Alt+Shift+F4`. */
8
+ accelerator?: string;
9
+ } | {
10
+ type: "checkbox";
11
+ id: string;
12
+ label: string;
13
+ checked?: boolean;
14
+ enabled?: boolean;
15
+ accelerator?: string;
16
+ } | {
17
+ type: "submenu";
18
+ label: string;
19
+ items: MenuItem[];
20
+ enabled?: boolean;
21
+ } | {
22
+ type: "separator";
23
+ } | {
24
+ type: "predefined";
25
+ item: PredefinedMenuItem;
26
+ label?: string;
27
+ };
28
+ export type PredefinedMenuItem = "separator" | "copy" | "cut" | "paste" | "selectAll" | "undo" | "redo" | "minimize" | "maximize" | "fullscreen" | "hide" | "hideOthers" | "showAll" | "closeWindow" | "quit" | "about" | "services" | "bringAllToFront";
29
+ /**
30
+ * The application menu.
31
+ *
32
+ * On macOS this is the menu bar, and it is not optional decoration: the
33
+ * predefined `copy`, `paste`, `undo` and `selectAll` items are what make
34
+ * those keyboard shortcuts work at all. An app that sets no menu has no
35
+ * working Cmd-C.
36
+ *
37
+ * ```ts
38
+ * await menu.set([
39
+ * { type: "submenu", label: "File", items: [
40
+ * { id: "new", label: "New", accelerator: "CmdOrCtrl+N" },
41
+ * { type: "separator" },
42
+ * { type: "predefined", item: "quit" },
43
+ * ]},
44
+ * { type: "submenu", label: "Edit", items: [
45
+ * { type: "predefined", item: "undo" },
46
+ * { type: "predefined", item: "copy" },
47
+ * { type: "predefined", item: "paste" },
48
+ * ]},
49
+ * ]);
50
+ *
51
+ * menu.onClick(({ id }) => { if (id === "new") newDocument(); });
52
+ * ```
53
+ */
54
+ export declare const menu: {
55
+ set: (items: MenuItem[]) => Promise<null>;
56
+ remove: () => Promise<null>;
57
+ setEnabled: (id: string, enabled: boolean) => Promise<null>;
58
+ setLabel: (id: string, label: string) => Promise<null>;
59
+ setChecked: (id: string, checked: boolean) => Promise<null>;
60
+ isChecked: (id: string) => Promise<boolean>;
61
+ /**
62
+ * Show a context menu. Position is in logical pixels relative to the
63
+ * window; the cursor is used when it is omitted.
64
+ */
65
+ popup: (items: MenuItem[], options?: {
66
+ x?: number;
67
+ y?: number;
68
+ label?: string;
69
+ }) => Promise<null>;
70
+ /** Fires for any item with an `id`, in the app menu, a tray menu or a popup. */
71
+ onClick: (handler: (event: {
72
+ id: string;
73
+ }) => void) => () => void;
74
+ };
75
+ /**
76
+ * Fill in the `type` the runtime insists on.
77
+ *
78
+ * `{ id, label }` is the item people write nine times out of ten, and the
79
+ * runtime's parser is a tagged union with no default - which is exactly what
80
+ * makes a misspelled `type` an error instead of a silent normal item.
81
+ */
82
+ export declare function normalize(items: MenuItem[]): MenuItem[];
83
+ //# sourceMappingURL=menu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"menu.d.ts","sourceRoot":"","sources":["../src/menu.ts"],"names":[],"mappings":"AAEA,iDAAiD;AACjD,MAAM,MAAM,QAAQ,GAChB;IACE,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GACD;IACE,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AAK,IAAI;CAEnD,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,QAAQ,EAAE,CAOvD"}
package/dist/menu.js ADDED
@@ -0,0 +1,55 @@
1
+ import { invoke, listen } from "./transport.js";
2
+ /**
3
+ * The application menu.
4
+ *
5
+ * On macOS this is the menu bar, and it is not optional decoration: the
6
+ * predefined `copy`, `paste`, `undo` and `selectAll` items are what make
7
+ * those keyboard shortcuts work at all. An app that sets no menu has no
8
+ * working Cmd-C.
9
+ *
10
+ * ```ts
11
+ * await menu.set([
12
+ * { type: "submenu", label: "File", items: [
13
+ * { id: "new", label: "New", accelerator: "CmdOrCtrl+N" },
14
+ * { type: "separator" },
15
+ * { type: "predefined", item: "quit" },
16
+ * ]},
17
+ * { type: "submenu", label: "Edit", items: [
18
+ * { type: "predefined", item: "undo" },
19
+ * { type: "predefined", item: "copy" },
20
+ * { type: "predefined", item: "paste" },
21
+ * ]},
22
+ * ]);
23
+ *
24
+ * menu.onClick(({ id }) => { if (id === "new") newDocument(); });
25
+ * ```
26
+ */
27
+ export const menu = {
28
+ set: (items) => invoke("menu.set", { items: normalize(items) }),
29
+ remove: () => invoke("menu.remove"),
30
+ setEnabled: (id, enabled) => invoke("menu.setEnabled", { id, enabled }),
31
+ setLabel: (id, label) => invoke("menu.setLabel", { id, label }),
32
+ setChecked: (id, checked) => invoke("menu.setChecked", { id, checked }),
33
+ isChecked: (id) => invoke("menu.isChecked", { id }),
34
+ /**
35
+ * Show a context menu. Position is in logical pixels relative to the
36
+ * window; the cursor is used when it is omitted.
37
+ */
38
+ popup: (items, options = {}) => invoke("menu.popup", { ...options, items: normalize(items) }),
39
+ /** Fires for any item with an `id`, in the app menu, a tray menu or a popup. */
40
+ onClick: (handler) => listen("menu.click", handler),
41
+ };
42
+ /**
43
+ * Fill in the `type` the runtime insists on.
44
+ *
45
+ * `{ id, label }` is the item people write nine times out of ten, and the
46
+ * runtime's parser is a tagged union with no default - which is exactly what
47
+ * makes a misspelled `type` an error instead of a silent normal item.
48
+ */
49
+ export function normalize(items) {
50
+ return items.map((item) => {
51
+ const entry = { type: "normal", ...item };
52
+ return entry.items ? { ...entry, items: normalize(entry.items) } : entry;
53
+ });
54
+ }
55
+ //# sourceMappingURL=menu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"menu.js","sourceRoot":"","sources":["../src/menu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AA4ChD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,GAAG,EAAE,CAAC,KAAiB,EAAE,EAAE,CACzB,MAAM,CAAO,UAAU,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;IACvD,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAO,aAAa,CAAC;IAEzC,UAAU,EAAE,CAAC,EAAU,EAAE,OAAgB,EAAE,EAAE,CAC3C,MAAM,CAAO,iBAAiB,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC;IAClD,QAAQ,EAAE,CAAC,EAAU,EAAE,KAAa,EAAE,EAAE,CACtC,MAAM,CAAO,eAAe,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC;IAC9C,UAAU,EAAE,CAAC,EAAU,EAAE,OAAgB,EAAE,EAAE,CAC3C,MAAM,CAAO,iBAAiB,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC;IAClD,SAAS,EAAE,CAAC,EAAU,EAAE,EAAE,CAAC,MAAM,CAAU,gBAAgB,EAAE,EAAE,EAAE,EAAE,CAAC;IAEpE;;;OAGG;IACH,KAAK,EAAE,CACL,KAAiB,EACjB,OAAO,GAA+C,EAAE,EACxD,EAAE,CAAC,MAAM,CAAO,YAAY,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;IAExE,gFAAgF;IAChF,OAAO,EAAE,CAAC,OAAwC,EAAE,EAAE,CACpD,MAAM,CAAiB,YAAY,EAAE,OAAO,CAAC;CAChD,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,KAAiB;IACzC,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACxB,MAAM,KAAK,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,IAAI,EAEtC,CAAC;QACF,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IAC3E,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,61 @@
1
+ import { type BinaryInput } from "./binary.js";
2
+ export interface NetworkRequestOptions {
3
+ /** An absolute URL. Checked against `permissions.network` before it is sent. */
4
+ url: string;
5
+ /** Default `GET`. Any method the server understands. */
6
+ method?: string;
7
+ headers?: Record<string, string>;
8
+ /** Sent as UTF-8. Ignored when `bytes` is given. */
9
+ body?: string;
10
+ /** Sent as raw bytes. */
11
+ bytes?: BinaryInput;
12
+ /** Default 30000. */
13
+ timeoutMs?: number;
14
+ /** Default 5. Every hop is permission-checked. */
15
+ maxRedirects?: number;
16
+ }
17
+ export interface NetworkResponse<Body = string> {
18
+ /** The URL that actually answered, after any redirects. */
19
+ url: string;
20
+ status: number;
21
+ statusText: string;
22
+ /** `true` for 2xx. */
23
+ ok: boolean;
24
+ /** Lower-cased names. Repeated headers are joined with `, `. */
25
+ headers: Record<string, string>;
26
+ body: Body;
27
+ }
28
+ /**
29
+ * HTTP from the runtime rather than the webview.
30
+ *
31
+ * Use the ordinary `fetch` for the internet - it works, it streams, and it is
32
+ * the thing you already know. Reach for this when `fetch` cannot do the job,
33
+ * which on a desktop app means talking to hardware on the user's own network:
34
+ *
35
+ * - a smart-home hub serves HTTPS with a self-signed certificate, which
36
+ * `fetch` refuses outright;
37
+ * - a smart light, a desk display or a single-board computer sends no CORS
38
+ * headers, so `fetch` makes the request and then refuses to let you read
39
+ * the answer.
40
+ *
41
+ * Neither is something an application can work around, which is exactly what
42
+ * makes this a platform capability rather than a convenience.
43
+ *
44
+ * ```ts
45
+ * const { body } = await network.request({
46
+ * url: `http://${light.host}:9123/api/lights`,
47
+ * method: "PUT",
48
+ * headers: { "content-type": "application/json" },
49
+ * body: JSON.stringify({ lights: [{ on: 1, brightness: 80 }] }),
50
+ * });
51
+ * ```
52
+ */
53
+ export declare const network: {
54
+ /** Send a request and read the response as text. */
55
+ request: (options: NetworkRequestOptions) => Promise<NetworkResponse<string>>;
56
+ /** The same, parsed as JSON. Throws if the body is not JSON. */
57
+ json: <T = unknown>(options: NetworkRequestOptions) => Promise<NetworkResponse<T>>;
58
+ /** The same, with the body as bytes. */
59
+ binary: (options: NetworkRequestOptions) => Promise<NetworkResponse<Uint8Array>>;
60
+ };
61
+ //# sourceMappingURL=network.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../src/network.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/D,MAAM,WAAW,qBAAqB;IACpC,gFAAgF;IAChF,GAAG,EAAE,MAAM,CAAC;IACZ,wDAAwD;IACxD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yBAAyB;IACzB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,qBAAqB;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kDAAkD;IAClD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,eAAe,CAAC,IAAI,GAAG,MAAM;IAC5C,2DAA2D;IAC3D,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,sBAAsB;IACtB,EAAE,EAAE,OAAO,CAAC;IACZ,gEAAgE;IAChE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,EAAE,IAAI,CAAC;CACZ;AAYD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,OAAO;IAClB,oDAAoD;IACpD,OAAO,YACI,qBAAqB,KAC7B,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IAKnC,gEAAgE;IAChE,IAAI,GAAS,CAAC,GAAG,OAAO,WACb,qBAAqB,KAC7B,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAW9B,wCAAwC;IACxC,MAAM,YACK,qBAAqB,KAC7B,OAAO,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;CAIxC,CAAC"}
@@ -0,0 +1,59 @@
1
+ import { decode, encode } from "./binary.js";
2
+ import { invoke } from "./transport.js";
3
+ /**
4
+ * HTTP from the runtime rather than the webview.
5
+ *
6
+ * Use the ordinary `fetch` for the internet - it works, it streams, and it is
7
+ * the thing you already know. Reach for this when `fetch` cannot do the job,
8
+ * which on a desktop app means talking to hardware on the user's own network:
9
+ *
10
+ * - a smart-home hub serves HTTPS with a self-signed certificate, which
11
+ * `fetch` refuses outright;
12
+ * - a smart light, a desk display or a single-board computer sends no CORS
13
+ * headers, so `fetch` makes the request and then refuses to let you read
14
+ * the answer.
15
+ *
16
+ * Neither is something an application can work around, which is exactly what
17
+ * makes this a platform capability rather than a convenience.
18
+ *
19
+ * ```ts
20
+ * const { body } = await network.request({
21
+ * url: `http://${light.host}:9123/api/lights`,
22
+ * method: "PUT",
23
+ * headers: { "content-type": "application/json" },
24
+ * body: JSON.stringify({ lights: [{ on: 1, brightness: 80 }] }),
25
+ * });
26
+ * ```
27
+ */
28
+ export const network = {
29
+ /** Send a request and read the response as text. */
30
+ request: async (options) => {
31
+ const response = await send(options, "text");
32
+ return { ...response, body: response.body };
33
+ },
34
+ /** The same, parsed as JSON. Throws if the body is not JSON. */
35
+ json: async (options) => {
36
+ const response = await send(options, "text");
37
+ try {
38
+ return { ...response, body: JSON.parse(response.body) };
39
+ }
40
+ catch (cause) {
41
+ throw new SyntaxError(`${response.url} did not return JSON (${response.status}): ${String(cause)}`);
42
+ }
43
+ },
44
+ /** The same, with the body as bytes. */
45
+ binary: async (options) => {
46
+ const response = await send(options, "base64");
47
+ return { ...response, body: decode(response.body) };
48
+ },
49
+ };
50
+ async function send(options, responseType) {
51
+ const { bytes, body, ...rest } = options;
52
+ return invoke("network.request", {
53
+ ...rest,
54
+ responseType,
55
+ ...(bytes === undefined ? {} : { bodyBase64: encode(bytes) }),
56
+ ...(bytes === undefined && body !== undefined ? { body } : {}),
57
+ });
58
+ }
59
+ //# sourceMappingURL=network.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network.js","sourceRoot":"","sources":["../src/network.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAoB,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAwCxC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,oDAAoD;IACpD,OAAO,EAAE,KAAK,EACZ,OAA8B,EACI,EAAE;QACpC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC7C,OAAO,EAAE,GAAG,QAAQ,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC9C,CAAC;IAED,gEAAgE;IAChE,IAAI,EAAE,KAAK,EACT,OAA8B,EACD,EAAE;QAC/B,MAAM,QAAQ,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or path. Ignored where unsupported. */
6
+ icon?: string;
7
+ }
8
+ /**
9
+ * Desktop notifications.
10
+ *
11
+ * On macOS these are delivered through the bundle identifier, so they only
12
+ * work from a packaged app - `vantail dev` will report `UNSUPPORTED`.
13
+ */
14
+ export declare const notification: {
15
+ show: (options: NotificationOptions | string) => Promise<null>;
16
+ };
17
+ //# sourceMappingURL=notification.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification.d.ts","sourceRoot":"","sources":["../src/notification.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,mBAAmB;IAClC,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,sEAAsE;IACtE,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY;IACvB,IAAI,YAAY,mBAAmB,GAAG,MAAM;CAO7C,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { invoke } from "./transport.js";
2
+ /**
3
+ * Desktop notifications.
4
+ *
5
+ * On macOS these are delivered through the bundle identifier, so they only
6
+ * work from a packaged app - `vantail dev` will report `UNSUPPORTED`.
7
+ */
8
+ export const notification = {
9
+ show: (options) => invoke("notification.show", typeof options === "string"
10
+ ? { title: "", body: options }
11
+ : { title: "", body: "", ...options }),
12
+ };
13
+ //# sourceMappingURL=notification.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification.js","sourceRoot":"","sources":["../src/notification.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAUxC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,CAAC,OAAqC,EAAE,EAAE,CAC9C,MAAM,CACJ,mBAAmB,EACnB,OAAO,OAAO,KAAK,QAAQ;QACzB,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;QAC9B,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,EAAE,CACxC;CACJ,CAAC"}
package/dist/os.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ export type Platform = "macos" | "windows" | "linux" | (string & {});
2
+ export interface OsInfo {
3
+ platform: Platform;
4
+ arch: string;
5
+ family: string;
6
+ }
7
+ /** Read-only facts about the machine, and the directories an app may use. */
8
+ export declare const os: {
9
+ platform: () => Promise<Platform>;
10
+ arch: () => Promise<string>;
11
+ info: () => Promise<OsInfo>;
12
+ homeDir: () => Promise<string>;
13
+ tempDir: () => Promise<string>;
14
+ /** Per-application data directory, named after `app.identifier`. */
15
+ appDataDir: () => Promise<string>;
16
+ appConfigDir: () => Promise<string>;
17
+ /** Where the app's own bundled assets live. */
18
+ resourceDir: () => Promise<string>;
19
+ /** Platform and architecture without awaiting; `undefined` in a browser. */
20
+ infoSync: () => Pick<OsInfo, "platform" | "arch"> | undefined;
21
+ };
22
+ //# sourceMappingURL=os.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"os.d.ts","sourceRoot":"","sources":["../src/os.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAErE,MAAM,WAAW,MAAM;IACrB,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,6EAA6E;AAC7E,eAAO,MAAM,EAAE;IACb,QAAQ;IACR,IAAI;IACJ,IAAI;IAEJ,OAAO;IACP,OAAO;IAEP,oEAAoE;IACpE,UAAU;IACV,YAAY;IAEZ,+CAA+C;IAC/C,WAAW;IAEX,4EAA4E;IAC5E,QAAQ,QAAM,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,GAAG,SAAS;CAI5D,CAAC"}
package/dist/os.js ADDED
@@ -0,0 +1,20 @@
1
+ import { bridgeInfo, invoke } from "./transport.js";
2
+ /** Read-only facts about the machine, and the directories an app may use. */
3
+ export const os = {
4
+ platform: () => invoke("os.platform"),
5
+ arch: () => invoke("os.arch"),
6
+ info: () => invoke("os.info"),
7
+ homeDir: () => invoke("os.homeDir"),
8
+ tempDir: () => invoke("os.tempDir"),
9
+ /** Per-application data directory, named after `app.identifier`. */
10
+ appDataDir: () => invoke("os.appDataDir"),
11
+ appConfigDir: () => invoke("os.appConfigDir"),
12
+ /** Where the app's own bundled assets live. */
13
+ resourceDir: () => invoke("os.resourceDir"),
14
+ /** Platform and architecture without awaiting; `undefined` in a browser. */
15
+ infoSync: () => {
16
+ const info = bridgeInfo();
17
+ return info ? { platform: info.platform, arch: info.arch } : undefined;
18
+ },
19
+ };
20
+ //# sourceMappingURL=os.js.map
package/dist/os.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"os.js","sourceRoot":"","sources":["../src/os.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAUpD,6EAA6E;AAC7E,MAAM,CAAC,MAAM,EAAE,GAAG;IAChB,QAAQ,EAAE,GAAG,EAAE,CAAC,MAAM,CAAW,aAAa,CAAC;IAC/C,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,CAAS,SAAS,CAAC;IACrC,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,CAAS,SAAS,CAAC;IAErC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAS,YAAY,CAAC;IAC3C,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAS,YAAY,CAAC;IAE3C,oEAAoE;IACpE,UAAU,EAAE,GAAG,EAAE,CAAC,MAAM,CAAS,eAAe,CAAC;IACjD,YAAY,EAAE,GAAG,EAAE,CAAC,MAAM,CAAS,iBAAiB,CAAC;IAErD,+CAA+C;IAC/C,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAS,gBAAgB,CAAC;IAEnD,4EAA4E;IAC5E,QAAQ,EAAE,GAAkD,EAAE;QAC5D,MAAM,IAAI,GAAG,UAAU,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACzE,CAAC;CACF,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The machine going to sleep, and coming back.
3
+ *
4
+ * A page cannot notice this on its own. There is no browser API for it, and
5
+ * nothing executes while the machine is asleep, so a timer cannot tell either
6
+ * - all it can observe afterwards is that time jumped.
7
+ *
8
+ * What it is usually for is a connection that will not survive a lid closing:
9
+ * drop it on the way down, open it again on the way back, rather than waiting
10
+ * for a socket to notice it is dead.
11
+ *
12
+ * ```ts
13
+ * power.onSuspend(() => bot.disconnect());
14
+ * power.onResume(() => bot.connect());
15
+ * ```
16
+ *
17
+ * **macOS only for now.** Elsewhere these simply never fire, rather than
18
+ * firing at the wrong moment. Ask {@link power.supported} and keep your own
19
+ * reconnect timer where the answer is `false`.
20
+ */
21
+ export declare const power: {
22
+ /** The machine is about to sleep. There is very little time here. */
23
+ onSuspend: (handler: () => void) => () => void;
24
+ /** It woke up. */
25
+ onResume: (handler: () => void) => () => void;
26
+ /** Whether this platform reports either of the above. */
27
+ supported: () => Promise<boolean>;
28
+ };
29
+ //# sourceMappingURL=power.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"power.d.ts","sourceRoot":"","sources":["../src/power.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,KAAK;IAChB,qEAAqE;IACrE,SAAS,YAAY,MAAM,IAAI;IAG/B,kBAAkB;IAClB,QAAQ,YAAY,MAAM,IAAI;IAG9B,yDAAyD;IACzD,SAAS;CACV,CAAC"}
package/dist/power.js ADDED
@@ -0,0 +1,30 @@
1
+ import { invoke, listen } from "./transport.js";
2
+ /**
3
+ * The machine going to sleep, and coming back.
4
+ *
5
+ * A page cannot notice this on its own. There is no browser API for it, and
6
+ * nothing executes while the machine is asleep, so a timer cannot tell either
7
+ * - all it can observe afterwards is that time jumped.
8
+ *
9
+ * What it is usually for is a connection that will not survive a lid closing:
10
+ * drop it on the way down, open it again on the way back, rather than waiting
11
+ * for a socket to notice it is dead.
12
+ *
13
+ * ```ts
14
+ * power.onSuspend(() => bot.disconnect());
15
+ * power.onResume(() => bot.connect());
16
+ * ```
17
+ *
18
+ * **macOS only for now.** Elsewhere these simply never fire, rather than
19
+ * firing at the wrong moment. Ask {@link power.supported} and keep your own
20
+ * reconnect timer where the answer is `false`.
21
+ */
22
+ export const power = {
23
+ /** The machine is about to sleep. There is very little time here. */
24
+ onSuspend: (handler) => listen("power.suspending", handler),
25
+ /** It woke up. */
26
+ onResume: (handler) => listen("power.resumed", handler),
27
+ /** Whether this platform reports either of the above. */
28
+ supported: () => invoke("os.powerEvents"),
29
+ };
30
+ //# sourceMappingURL=power.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"power.js","sourceRoot":"","sources":["../src/power.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,qEAAqE;IACrE,SAAS,EAAE,CAAC,OAAmB,EAAE,EAAE,CACjC,MAAM,CAAwB,kBAAkB,EAAE,OAAO,CAAC;IAE5D,kBAAkB;IAClB,QAAQ,EAAE,CAAC,OAAmB,EAAE,EAAE,CAChC,MAAM,CAAwB,eAAe,EAAE,OAAO,CAAC;IAEzD,yDAAyD;IACzD,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM,CAAU,gBAAgB,CAAC;CACnD,CAAC"}
@@ -0,0 +1,69 @@
1
+ export interface RunOptions {
2
+ /** Working directory. Must be inside the `cwd` scope of the matching rule. */
3
+ cwd?: string;
4
+ env?: Record<string, string>;
5
+ /** Start from an empty environment instead of inheriting this process's. */
6
+ clearEnv?: boolean;
7
+ }
8
+ export interface ExecuteOptions extends RunOptions {
9
+ /** Written to the child's stdin, which is then closed. */
10
+ stdin?: string;
11
+ /** Kill the child after this long. */
12
+ timeoutMs?: number;
13
+ }
14
+ export interface ExecuteResult {
15
+ /** `null` when the process was killed by a signal. */
16
+ code: number | null;
17
+ /** Unix only. */
18
+ signal: number | null;
19
+ success: boolean;
20
+ stdout: string;
21
+ stderr: string;
22
+ }
23
+ export interface ExitEvent {
24
+ code: number | null;
25
+ signal: number | null;
26
+ success: boolean;
27
+ }
28
+ /** A running process started with {@link process.spawn}. */
29
+ export interface Child {
30
+ /** The handle used by every call below. Not the OS pid. */
31
+ readonly id: number;
32
+ /** The operating system's process id, for display and for `ps`. */
33
+ readonly pid: number;
34
+ write(data: string): Promise<null>;
35
+ closeStdin(): Promise<null>;
36
+ kill(): Promise<null>;
37
+ /**
38
+ * Output as it arrives, in chunks rather than lines - a program drawing a
39
+ * progress bar with `\r` never emits a newline, and buffering for one would
40
+ * make it look hung. Split on newlines yourself if that is what you want.
41
+ */
42
+ onStdout(handler: (data: string) => void): () => void;
43
+ onStderr(handler: (data: string) => void): () => void;
44
+ onExit(handler: (event: ExitEvent) => void): () => void;
45
+ }
46
+ /**
47
+ * Running other programs.
48
+ *
49
+ * Every program must be named in `permissions.shell.allow`, and arguments are
50
+ * passed as a vector rather than a command line - there is no shell anywhere
51
+ * in this path, so there is nothing for an argument to inject into.
52
+ *
53
+ * ```ts
54
+ * const { stdout } = await process.execute("git", ["status", "--porcelain"]);
55
+ * ```
56
+ */
57
+ export declare const process: {
58
+ /** Run a program to completion and collect its output. */
59
+ execute: (program: string, args?: string[], options?: ExecuteOptions) => Promise<ExecuteResult>;
60
+ /** Start a program and stream its output. */
61
+ spawn: (program: string, args?: string[], options?: RunOptions) => Promise<Child>;
62
+ /** Everything this application has started and not yet seen exit. */
63
+ list: () => Promise<{
64
+ id: number;
65
+ pid: number;
66
+ program: string;
67
+ }[]>;
68
+ };
69
+ //# sourceMappingURL=process.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../src/process.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,UAAU;IACzB,8EAA8E;IAC9E,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,cAAe,SAAQ,UAAU;IAChD,0DAA0D;IAC1D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sCAAsC;IACtC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,sDAAsD;IACtD,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,iBAAiB;IACjB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,4DAA4D;AAC5D,MAAM,WAAW,KAAK;IACpB,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,mEAAmE;IACnE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtB;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IACtD,QAAQ,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IACtD,MAAM,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CACzD;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,OAAO;IAClB,0DAA0D;IAC1D,OAAO,YACI,MAAM,SACT,MAAM,EAAE,YACL,cAAc;IAGzB,6CAA6C;IAC7C,KAAK,YACM,MAAM,SACT,MAAM,EAAE,YACL,UAAU,KAClB,OAAO,CAAC,KAAK,CAAC;IAYjB,qEAAqE;IACrE,IAAI;YACW,MAAM;aAAO,MAAM;iBAAW,MAAM;;CACpD,CAAC"}
@@ -0,0 +1,44 @@
1
+ import { invoke, listen } from "./transport.js";
2
+ /**
3
+ * Running other programs.
4
+ *
5
+ * Every program must be named in `permissions.shell.allow`, and arguments are
6
+ * passed as a vector rather than a command line - there is no shell anywhere
7
+ * in this path, so there is nothing for an argument to inject into.
8
+ *
9
+ * ```ts
10
+ * const { stdout } = await process.execute("git", ["status", "--porcelain"]);
11
+ * ```
12
+ */
13
+ export const process = {
14
+ /** Run a program to completion and collect its output. */
15
+ execute: (program, args = [], options = {}) => invoke("process.execute", { program, args, ...options }),
16
+ /** Start a program and stream its output. */
17
+ spawn: async (program, args = [], options = {}) => {
18
+ const { id, pid } = await invoke("process.spawn", {
19
+ program,
20
+ args,
21
+ ...options,
22
+ });
23
+ return child(id, pid);
24
+ },
25
+ /** Everything this application has started and not yet seen exit. */
26
+ list: () => invoke("process.list"),
27
+ };
28
+ function child(id, pid) {
29
+ const forId = (event, handler) => listen(event, (payload) => {
30
+ if (payload.id === id)
31
+ handler(payload);
32
+ });
33
+ return {
34
+ id,
35
+ pid,
36
+ write: (data) => invoke("process.write", { id, data }),
37
+ closeStdin: () => invoke("process.closeStdin", { id }),
38
+ kill: () => invoke("process.kill", { id }),
39
+ onStdout: (handler) => forId("process.stdout", ({ data }) => handler(data)),
40
+ onStderr: (handler) => forId("process.stderr", ({ data }) => handler(data)),
41
+ onExit: (handler) => forId("process.exit", handler),
42
+ };
43
+ }
44
+ //# sourceMappingURL=process.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process.js","sourceRoot":"","sources":["../src/process.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAsDhD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,0DAA0D;IAC1D,OAAO,EAAE,CACP,OAAe,EACf,IAAI,GAAa,EAAE,EACnB,OAAO,GAAmB,EAAE,EAC5B,EAAE,CAAC,MAAM,CAAgB,iBAAiB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC;IAE5E,6CAA6C;IAC7C,KAAK,EAAE,KAAK,EACV,OAAe,EACf,IAAI,GAAa,EAAE,EACnB,OAAO,GAAe,EAAE,EACR,EAAE;QAClB,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,MAAM,MAAM,CAC9B,eAAe,EACf;YACE,OAAO;YACP,IAAI;YACJ,GAAG,OAAO;SACX,CACF,CAAC;QACF,OAAO,KAAK,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IACxB,CAAC;IAED,qEAAqE;IACrE,IAAI,EAAE,GAAG,EAAE,CACT,MAAM,CAAiD,cAAc,CAAC;CACzE,CAAC;AAEF,SAAS,KAAK,CAAC,EAAU,EAAE,GAAW;IACpC,MAAM,KAAK,GAAG,CACZ,KAAa,EACb,OAA6B,EAC7B,EAAE,CACF,MAAM,CAAI,KAAK,EAAE,CAAC,OAAO,EAAE,EAAE;QAC3B,IAAI,OAAO,CAAC,EAAE,KAAK,EAAE;YAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEL,OAAO;QACL,EAAE;QACF,GAAG;QAEH,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAO,eAAe,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;QAC5D,UAAU,EAAE,GAAG,EAAE,CAAC,MAAM,CAAO,oBAAoB,EAAE,EAAE,EAAE,EAAE,CAAC;QAC5D,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,CAAO,cAAc,EAAE,EAAE,EAAE,EAAE,CAAC;QAEhD,QAAQ,EAAE,CAAC,OAAO,EAAE,EAAE,CACpB,KAAK,CAA+B,gBAAgB,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CACjE,OAAO,CAAC,IAAI,CAAC,CACd;QACH,QAAQ,EAAE,CAAC,OAAO,EAAE,EAAE,CACpB,KAAK,CAA+B,gBAAgB,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CACjE,OAAO,CAAC,IAAI,CAAC,CACd;QACH,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,CAClB,KAAK,CAA6B,cAAc,EAAE,OAAO,CAAC;KAC7D,CAAC;AACJ,CAAC"}
@@ -0,0 +1,66 @@
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 interface VantailRequest {
11
+ id: string;
12
+ method: string;
13
+ params?: unknown;
14
+ }
15
+ export interface VantailErrorPayload {
16
+ code: string;
17
+ message: string;
18
+ data?: unknown;
19
+ }
20
+ export interface VantailResponse {
21
+ id: string;
22
+ result?: unknown;
23
+ error?: VantailErrorPayload;
24
+ }
25
+ export interface VantailEventMessage {
26
+ event: string;
27
+ payload: unknown;
28
+ }
29
+ export type VantailIncoming = VantailResponse | VantailEventMessage;
30
+ export declare function isEventMessage(message: VantailIncoming): message is VantailEventMessage;
31
+ /** Stable error codes. `NO_RUNTIME` is the only one the SDK raises itself. */
32
+ export declare const ErrorCode: {
33
+ readonly NO_RUNTIME: "NO_RUNTIME";
34
+ readonly UNKNOWN_METHOD: "UNKNOWN_METHOD";
35
+ readonly INVALID_PARAMS: "INVALID_PARAMS";
36
+ readonly PERMISSION_DENIED: "PERMISSION_DENIED";
37
+ readonly NOT_FOUND: "NOT_FOUND";
38
+ readonly ALREADY_EXISTS: "ALREADY_EXISTS";
39
+ readonly IO_ERROR: "IO_ERROR";
40
+ readonly INVALID_UTF8: "INVALID_UTF8";
41
+ readonly UNSUPPORTED: "UNSUPPORTED";
42
+ readonly INTERNAL: "INTERNAL";
43
+ };
44
+ export type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];
45
+ /** The object the runtime injects before any page script runs. */
46
+ export interface VantailBridge {
47
+ version: string;
48
+ /** The label of the window this page is running in. */
49
+ label: string;
50
+ app: {
51
+ name: string;
52
+ version: string;
53
+ identifier: string;
54
+ isDev: boolean;
55
+ platform: string;
56
+ arch: string;
57
+ };
58
+ postMessage(message: VantailRequest): void;
59
+ subscribe(listener: (message: VantailIncoming) => void): () => void;
60
+ }
61
+ declare global {
62
+ interface Window {
63
+ __VANTAIL__?: VantailBridge;
64
+ }
65
+ }
66
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,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