sepal 0.2.0-alpha.0 → 0.3.0-alpha.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/README.md +14 -5
- package/cli.js +127 -10
- package/package.json +48 -4
- package/src/abort.js +129 -0
- package/src/app.js +13 -0
- package/src/dom.js +173 -60
- package/src/fetch.js +347 -80
- package/src/form-data.js +141 -0
- package/src/host-call.js +57 -0
- package/src/index.js +9 -11
- package/src/lru.js +45 -0
- package/src/native.js +32 -0
- package/src/notifications.js +60 -0
- package/src/os.js +35 -0
- package/src/process.js +164 -0
- package/src/protocol.js +3 -4
- package/src/renderer.js +140 -10
- package/src/secrets.js +42 -0
- package/src/settings.js +52 -0
- package/src/shims.js +30 -8
- package/src/stem.js +125 -0
- package/src/updater.js +3 -2
- package/src/url.js +65 -20
- package/src/web.js +86 -0
- package/src/window.js +6 -2
- package/types/abort.d.ts +46 -0
- package/types/app.d.ts +7 -0
- package/types/fetch.d.ts +118 -28
- package/types/form-data.d.ts +19 -0
- package/types/host-call.d.ts +18 -0
- package/types/index.d.ts +5 -2
- package/types/lru.d.ts +18 -0
- package/types/native.d.ts +22 -0
- package/types/notifications.d.ts +53 -0
- package/types/os.d.ts +53 -0
- package/types/process.d.ts +90 -0
- package/types/protocol.d.ts +0 -2
- package/types/renderer.d.ts +16 -1
- package/types/secrets.d.ts +22 -0
- package/types/settings.d.ts +29 -0
- package/types/shims.d.ts +1 -0
- package/types/stem.d.ts +21 -0
- package/types/updater.d.ts +6 -4
- package/types/url.d.ts +1 -1
- package/types/vite/adapter.d.ts +22 -0
- package/types/vite/add.d.ts +77 -0
- package/types/vite/app.d.ts +52 -1
- package/types/vite/licenses.d.ts +11 -0
- package/types/vite/native.d.ts +135 -0
- package/types/vite/page.d.ts +20 -0
- package/types/vite/permissions.d.ts +56 -0
- package/types/vite/sveltekit.d.ts +5 -42
- package/types/vite/vite.d.ts +86 -29
- package/types/web.d.ts +17 -0
- package/types/window.d.ts +5 -1
- package/vite/adapter.js +118 -0
- package/vite/add.js +254 -0
- package/vite/app.js +195 -27
- package/vite/head.js +2 -2
- package/vite/licenses.js +115 -0
- package/vite/native.js +535 -0
- package/vite/page.js +95 -0
- package/vite/permissions.d.ts +56 -0
- package/vite/sveltekit.js +11 -263
- package/vite/vite.js +378 -109
package/types/fetch.d.ts
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @param {string | Request | { url?: string, href?: string }} input
|
|
3
|
-
* @param {
|
|
3
|
+
* @param {ConstructorParameters<typeof Request>[1]} [init]
|
|
4
4
|
* @returns {Promise<Response>}
|
|
5
5
|
*/
|
|
6
6
|
export function fetch(input: string | Request | {
|
|
7
7
|
url?: string;
|
|
8
8
|
href?: string;
|
|
9
|
-
}, init?:
|
|
10
|
-
method?: string;
|
|
11
|
-
headers?: unknown;
|
|
12
|
-
body?: string | ArrayBuffer | ArrayBufferView | null;
|
|
13
|
-
}): Promise<Response>;
|
|
9
|
+
}, init?: ConstructorParameters<typeof Request>[1]): Promise<Response>;
|
|
14
10
|
/** Headers: names are case-insensitive and kept in lower case, as in the Fetch API. */
|
|
15
11
|
export class Headers {
|
|
16
12
|
/** @param {unknown} [init] a plain object, a list of pairs, or another `Headers` */
|
|
@@ -21,23 +17,26 @@ export class Headers {
|
|
|
21
17
|
set(name: string, value: string): void;
|
|
22
18
|
/** @param {string} name */
|
|
23
19
|
get(name: string): string | null;
|
|
20
|
+
/** Each `Set-Cookie` line, as the Fetch API keeps them. */
|
|
21
|
+
getSetCookie(): string[];
|
|
24
22
|
/** @param {string} name */
|
|
25
23
|
has(name: string): boolean;
|
|
26
24
|
/** @param {string} name */
|
|
27
25
|
delete(name: string): void;
|
|
28
26
|
/** @param {(value: string, name: string, headers: Headers) => void} callback */
|
|
29
27
|
forEach(callback: (value: string, name: string, headers: Headers) => void): void;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
/** In name order, with each `Set-Cookie` line on its own, as the Fetch API iterates. */
|
|
29
|
+
entries(): Generator<[string, string], void, unknown>;
|
|
30
|
+
keys(): Generator<string, void, unknown>;
|
|
31
|
+
values(): Generator<string, void, unknown>;
|
|
32
|
+
[Symbol.iterator](): Generator<[string, string], void, unknown>;
|
|
34
33
|
#private;
|
|
35
34
|
}
|
|
36
35
|
/** A request to make: what `fetch` takes, as a string, a URL or one of these. */
|
|
37
|
-
export class Request {
|
|
36
|
+
export class Request extends Body {
|
|
38
37
|
/**
|
|
39
38
|
* @param {string | Request | { url?: string, href?: string }} input
|
|
40
|
-
* @param {{ method?: string, headers?: unknown, body?:
|
|
39
|
+
* @param {{ method?: string, headers?: unknown, body?: unknown, signal?: AbortSignal | null, credentials?: string, mode?: string, cache?: string, redirect?: string, referrer?: string, integrity?: string, keepalive?: boolean, duplex?: string }} [init]
|
|
41
40
|
*/
|
|
42
41
|
constructor(input: string | Request | {
|
|
43
42
|
url?: string;
|
|
@@ -45,7 +44,16 @@ export class Request {
|
|
|
45
44
|
}, init?: {
|
|
46
45
|
method?: string;
|
|
47
46
|
headers?: unknown;
|
|
48
|
-
body?:
|
|
47
|
+
body?: unknown;
|
|
48
|
+
signal?: AbortSignal | null;
|
|
49
|
+
credentials?: string;
|
|
50
|
+
mode?: string;
|
|
51
|
+
cache?: string;
|
|
52
|
+
redirect?: string;
|
|
53
|
+
referrer?: string;
|
|
54
|
+
integrity?: string;
|
|
55
|
+
keepalive?: boolean;
|
|
56
|
+
duplex?: string;
|
|
49
57
|
});
|
|
50
58
|
/** @type {string} */
|
|
51
59
|
url: string;
|
|
@@ -53,35 +61,117 @@ export class Request {
|
|
|
53
61
|
method: string;
|
|
54
62
|
/** @type {Headers} */
|
|
55
63
|
headers: Headers;
|
|
56
|
-
/** @type {
|
|
57
|
-
|
|
64
|
+
/** @type {AbortSignal} */
|
|
65
|
+
signal: AbortSignal;
|
|
66
|
+
/** @type {string} */
|
|
67
|
+
credentials: string;
|
|
68
|
+
/** @type {string} */
|
|
69
|
+
mode: string;
|
|
70
|
+
/** @type {string} */
|
|
71
|
+
cache: string;
|
|
72
|
+
/** @type {string} */
|
|
73
|
+
redirect: string;
|
|
74
|
+
/** @type {string} */
|
|
75
|
+
referrer: string;
|
|
76
|
+
referrerPolicy: string;
|
|
77
|
+
/** @type {string} */
|
|
78
|
+
integrity: string;
|
|
79
|
+
/** @type {boolean} */
|
|
80
|
+
keepalive: boolean;
|
|
81
|
+
destination: string;
|
|
82
|
+
duplex: string;
|
|
83
|
+
clone(): Request;
|
|
58
84
|
}
|
|
59
|
-
/** A response with its body
|
|
60
|
-
export class Response {
|
|
85
|
+
/** A response with its body: what `new Response(body, init)` makes. `fetch` answers with a subclass. */
|
|
86
|
+
export class Response extends Body {
|
|
87
|
+
/** @param {unknown} data @param {{ status?: number, statusText?: string, headers?: unknown }} [init] */
|
|
88
|
+
static json(data: unknown, init?: {
|
|
89
|
+
status?: number;
|
|
90
|
+
statusText?: string;
|
|
91
|
+
headers?: unknown;
|
|
92
|
+
}): Response;
|
|
93
|
+
/** @param {string | { href: string }} url @param {number} [status] */
|
|
94
|
+
static redirect(url: string | {
|
|
95
|
+
href: string;
|
|
96
|
+
}, status?: number): Response;
|
|
97
|
+
static error(): Response;
|
|
61
98
|
/**
|
|
62
|
-
* @param {
|
|
99
|
+
* @param {unknown} [body]
|
|
63
100
|
* @param {{ status?: number, statusText?: string, headers?: unknown }} [init]
|
|
101
|
+
* @param {Source | null} [source] for `clone()` and `fetch`: the body as it is already held
|
|
64
102
|
*/
|
|
65
|
-
constructor(body?:
|
|
103
|
+
constructor(body?: unknown, init?: {
|
|
66
104
|
status?: number;
|
|
67
105
|
statusText?: string;
|
|
68
106
|
headers?: unknown;
|
|
69
|
-
});
|
|
107
|
+
}, source?: Source | null);
|
|
70
108
|
status: number;
|
|
71
109
|
statusText: string;
|
|
72
110
|
ok: boolean;
|
|
73
111
|
headers: Headers;
|
|
74
112
|
url: string;
|
|
75
113
|
redirected: boolean;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
114
|
+
/** @type {'default' | 'basic' | 'error'} */
|
|
115
|
+
type: "default" | "basic" | "error";
|
|
116
|
+
clone(): Response;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* What a body was made from, and how it is read.
|
|
120
|
+
*/
|
|
121
|
+
export type Source = {
|
|
122
|
+
text: string;
|
|
123
|
+
} | {
|
|
124
|
+
bytes: Uint8Array;
|
|
125
|
+
} | {
|
|
126
|
+
blob: Blob;
|
|
127
|
+
} | {
|
|
128
|
+
form: FormData;
|
|
129
|
+
boundary: string;
|
|
130
|
+
} | {
|
|
131
|
+
stream: ReadableStream<Uint8Array>;
|
|
132
|
+
} | {
|
|
133
|
+
host: number;
|
|
134
|
+
};
|
|
135
|
+
export type AbortSignal = import("./abort.js").AbortSignal;
|
|
136
|
+
/** What `Request` and `Response` share: a body, read once. */
|
|
137
|
+
declare class Body {
|
|
138
|
+
/** @param {Source | null} source */
|
|
139
|
+
constructor(source: Source | null);
|
|
140
|
+
/** What this body belongs to, for messages. */
|
|
141
|
+
get kind(): string;
|
|
142
|
+
/** For `clone()`: the source, turned into a stream that can be split. @returns {Source | null} */
|
|
143
|
+
split_source(): Source | null;
|
|
144
|
+
/** @returns {AbortSignal | null} */
|
|
145
|
+
body_signal(): AbortSignal | null;
|
|
146
|
+
/** @returns {ReadableStream<Uint8Array>} */
|
|
147
|
+
body_stream(): ReadableStream<Uint8Array>;
|
|
148
|
+
/** Whether there is a body, without making its stream. */
|
|
149
|
+
has_body(): boolean;
|
|
150
|
+
/** The body as a stream, or `null` for none. */
|
|
151
|
+
get body(): ReadableStream<Uint8Array<ArrayBufferLike>> | null;
|
|
152
|
+
/** Read, or its stream taken to be read. */
|
|
153
|
+
get bodyUsed(): boolean;
|
|
154
|
+
/** The source, once: reading a body uses it up. @returns {Source | null} */
|
|
155
|
+
take(): Source | null;
|
|
156
|
+
/** @returns {string | null} */
|
|
157
|
+
content_type(): string | null;
|
|
158
|
+
/** The body for the host: text as it is, anything else as base64. @returns {Promise<{ body: string } | { body_base64: string }>} */
|
|
159
|
+
for_host(): Promise<{
|
|
160
|
+
body: string;
|
|
161
|
+
} | {
|
|
162
|
+
body_base64: string;
|
|
163
|
+
}>;
|
|
84
164
|
/** @returns {Promise<Uint8Array>} */
|
|
85
165
|
bytes(): Promise<Uint8Array>;
|
|
86
166
|
arrayBuffer(): Promise<ArrayBuffer>;
|
|
167
|
+
/** @returns {Promise<string>} */
|
|
168
|
+
text(): Promise<string>;
|
|
169
|
+
json(): Promise<any>;
|
|
170
|
+
blob(): Promise<Blob>;
|
|
171
|
+
formData(): Promise<FormData>;
|
|
172
|
+
#private;
|
|
87
173
|
}
|
|
174
|
+
import { Blob } from 'formdata-node';
|
|
175
|
+
import { FormData } from 'formdata-node';
|
|
176
|
+
import { ReadableStream } from 'web-streams-polyfill';
|
|
177
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** A boundary that will not be in the content, as browsers choose them. */
|
|
2
|
+
export function make_boundary(): string;
|
|
3
|
+
/**
|
|
4
|
+
* `form` as a `multipart/form-data` body with `boundary`.
|
|
5
|
+
* @param {FormData} form
|
|
6
|
+
* @param {string} boundary
|
|
7
|
+
* @returns {Promise<Uint8Array>}
|
|
8
|
+
*/
|
|
9
|
+
export function encode_multipart(form: FormData, boundary: string): Promise<Uint8Array>;
|
|
10
|
+
/** @param {Uint8Array[]} parts */
|
|
11
|
+
export function concat(parts: Uint8Array[]): Uint8Array<ArrayBuffer>;
|
|
12
|
+
/**
|
|
13
|
+
* A body as `FormData`, by its content type, as `formData()` reads it.
|
|
14
|
+
* @param {Uint8Array} bytes
|
|
15
|
+
* @param {string | null} content_type
|
|
16
|
+
* @returns {FormData}
|
|
17
|
+
*/
|
|
18
|
+
export function parse_form(bytes: Uint8Array, content_type: string | null): FormData;
|
|
19
|
+
import { FormData } from 'formdata-node';
|
package/types/host-call.d.ts
CHANGED
|
@@ -11,3 +11,21 @@ export function host_call(name: string, args?: unknown): Promise<any>;
|
|
|
11
11
|
* @param {string} payload JSON when `ok`, an error message otherwise
|
|
12
12
|
*/
|
|
13
13
|
export function settle_call(id: number, ok: boolean, payload: string): void;
|
|
14
|
+
/**
|
|
15
|
+
* Listen for the event `name`. Listening starts with the host calls of this
|
|
16
|
+
* turn, in order, so a command called after this in the same turn cannot
|
|
17
|
+
* send one too early.
|
|
18
|
+
* @param {string} name
|
|
19
|
+
* @param {Listener} listener
|
|
20
|
+
* @returns {() => void} removes the listener
|
|
21
|
+
*/
|
|
22
|
+
export function listen(name: string, listener: Listener): () => void;
|
|
23
|
+
/**
|
|
24
|
+
* An event from the host, as JSON: `[name, value]`, or `[name, null, dropped]`
|
|
25
|
+
* where the host dropped `dropped` of them. Wired to `__sb.event`.
|
|
26
|
+
* @param {string} json
|
|
27
|
+
*/
|
|
28
|
+
export function deliver_event(json: string): void;
|
|
29
|
+
export type Listener = (value: any, cut?: {
|
|
30
|
+
dropped: number;
|
|
31
|
+
}) => void;
|
package/types/index.d.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Mount a component into the window
|
|
2
|
+
* Mount a component into the window: into the page's `<body>`, or into
|
|
3
|
+
* `target`, an element of the page (with the DOM layer,
|
|
4
|
+
* `document.getElementById('app')`).
|
|
3
5
|
*
|
|
4
6
|
* @template {Record<string, any>} Props
|
|
5
7
|
* @template {Record<string, any>} Exports
|
|
6
8
|
* @param {import('svelte').Component<Props, Exports, any>} component
|
|
7
|
-
* @param {{ props?: Props, context?: Map<any, any
|
|
9
|
+
* @param {{ props?: Props, context?: Map<any, any>, target?: object | null }} [options]
|
|
8
10
|
* @returns {Exports} the component's exports; pass it to `unmount`
|
|
9
11
|
*/
|
|
10
12
|
export function mount<Props extends Record<string, any>, Exports extends Record<string, any>>(component: import("svelte").Component<Props, Exports, any>, options?: {
|
|
11
13
|
props?: Props;
|
|
12
14
|
context?: Map<any, any>;
|
|
15
|
+
target?: object | null;
|
|
13
16
|
}): Exports;
|
|
14
17
|
import { unmount } from 'svelte';
|
|
15
18
|
import renderer from './renderer.js';
|
package/types/lru.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A least-recently-used cache of at most `limit` entries, in a Map's order:
|
|
3
|
+
* a hit moves its entry to the end, and past the limit the oldest goes.
|
|
4
|
+
* `undefined` is never stored: it is what a miss returns.
|
|
5
|
+
* @template K, V
|
|
6
|
+
* @param {string} name for `cache_sizes`
|
|
7
|
+
* @param {number} limit
|
|
8
|
+
*/
|
|
9
|
+
export function lru<K, V>(name: string, limit: number): {
|
|
10
|
+
/** @param {K} key @returns {V | undefined} */
|
|
11
|
+
get(key: K): V | undefined;
|
|
12
|
+
/** @param {K} key @param {V} value */
|
|
13
|
+
set(key: K, value: V): void;
|
|
14
|
+
};
|
|
15
|
+
/** How many entries each cache holds, by name. */
|
|
16
|
+
export function cache_sizes(): {
|
|
17
|
+
[k: string]: number;
|
|
18
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Call a command. A plugin's needs its key in `permissions`; an app's own
|
|
3
|
+
* needs none.
|
|
4
|
+
* @param {string} name e.g. `tracker.import`
|
|
5
|
+
* @param {unknown} [args] anything JSON can carry
|
|
6
|
+
* @returns {Promise<any>} the command's answer; rejects with its error
|
|
7
|
+
*/
|
|
8
|
+
export function invoke(name: string, args?: unknown): Promise<any>;
|
|
9
|
+
/**
|
|
10
|
+
* Listen for an event a command or a plugin sends from Rust. A plugin's
|
|
11
|
+
* events (`watch.change`) need its key in `permissions`, as its commands do;
|
|
12
|
+
* without it the refusal is printed and nothing arrives. Events are dropped
|
|
13
|
+
* when they come faster than the app takes them: the listener is then called
|
|
14
|
+
* once with no value and the count, `listener(undefined, { dropped })`,
|
|
15
|
+
* where they would have been.
|
|
16
|
+
* @param {string} name e.g. `watch.change`
|
|
17
|
+
* @param {(value: any, cut?: { dropped: number }) => void} listener
|
|
18
|
+
* @returns {() => void} removes the listener
|
|
19
|
+
*/
|
|
20
|
+
export function on(name: string, listener: (value: any, cut?: {
|
|
21
|
+
dropped: number;
|
|
22
|
+
}) => void): () => void;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** @typedef {'granted' | 'denied' | 'default'} Permission the web's names; `default` is not asked yet */
|
|
2
|
+
/** @typedef {{ id: string, data: any }} Click the notification that was clicked: its id, and the `data` given to `notify()` */
|
|
3
|
+
/**
|
|
4
|
+
* Whether the user lets this app show notifications. On Linux always
|
|
5
|
+
* `granted`: nothing asks there.
|
|
6
|
+
* @returns {Promise<Permission>}
|
|
7
|
+
*/
|
|
8
|
+
export function permission(): Promise<Permission>;
|
|
9
|
+
/**
|
|
10
|
+
* Ask the user, where the system asks and they have not answered yet;
|
|
11
|
+
* settles with their answer. `notify()` asks too, the first time, and
|
|
12
|
+
* does not settle while the prompt is unanswered: call this to choose the
|
|
13
|
+
* moment.
|
|
14
|
+
* @returns {Promise<Permission>}
|
|
15
|
+
*/
|
|
16
|
+
export function requestPermission(): Promise<Permission>;
|
|
17
|
+
/**
|
|
18
|
+
* Show a notification. `data` is any JSON, up to 4 KB, and comes back with
|
|
19
|
+
* a click: put in it what says which thing the notification is about
|
|
20
|
+
* (`{ issue: 12 }`), since the id is only good for this run of the app.
|
|
21
|
+
* @param {{ title: string, body?: string, data?: unknown }} notification
|
|
22
|
+
* @returns {Promise<string>} its id; rejects when the user has turned the
|
|
23
|
+
* app's notifications off, or there is nothing to show them. On macOS
|
|
24
|
+
* the first call asks the user, and waits for the answer
|
|
25
|
+
*/
|
|
26
|
+
export function notify(notification: {
|
|
27
|
+
title: string;
|
|
28
|
+
body?: string;
|
|
29
|
+
data?: unknown;
|
|
30
|
+
}): Promise<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Hear clicks on this app's notifications. A click nobody had heard yet is
|
|
33
|
+
* kept for the first listener: on macOS a click can start the app, so call
|
|
34
|
+
* this when the app starts and that click is the first one it hears, with
|
|
35
|
+
* the `data` its notification was given by the run before.
|
|
36
|
+
*
|
|
37
|
+
* A click goes to the runtime that showed the notification (the page, or
|
|
38
|
+
* the server code), or to every runtime that listens once that one has gone.
|
|
39
|
+
* @param {(click: Click) => void} listener
|
|
40
|
+
* @returns {() => void} stops listening
|
|
41
|
+
*/
|
|
42
|
+
export function onClick(listener: (click: Click) => void): () => void;
|
|
43
|
+
/**
|
|
44
|
+
* the web's names; `default` is not asked yet
|
|
45
|
+
*/
|
|
46
|
+
export type Permission = "granted" | "denied" | "default";
|
|
47
|
+
/**
|
|
48
|
+
* the notification that was clicked: its id, and the `data` given to `notify()`
|
|
49
|
+
*/
|
|
50
|
+
export type Click = {
|
|
51
|
+
id: string;
|
|
52
|
+
data: any;
|
|
53
|
+
};
|
package/types/os.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {object} Info
|
|
3
|
+
* @property {string} platform `macos`, `linux` or `windows`
|
|
4
|
+
* @property {string} arch `arm64` or `x64`, as the npm packages and the update feed name them
|
|
5
|
+
* @property {string | null} name the system's name: `macOS`, or the Linux distribution's (`Ubuntu`)
|
|
6
|
+
* @property {string | null} version the system's version: `15.3`, `24.04`
|
|
7
|
+
* @property {string} locale the user's preferred locale, `en-IN`
|
|
8
|
+
* @property {string[]} locales every locale the user prefers, in order
|
|
9
|
+
* @property {string | null} hostname
|
|
10
|
+
* @property {boolean | null} dark whether the user chose a dark appearance; null where the host cannot tell
|
|
11
|
+
*/
|
|
12
|
+
/** @returns {Promise<Info>} */
|
|
13
|
+
export function info(): Promise<Info>;
|
|
14
|
+
/**
|
|
15
|
+
* An environment variable listed in `permissions.os.env`, or null when it
|
|
16
|
+
* is not set. The app's own environment: a bundle opened from Finder does
|
|
17
|
+
* not see what a shell profile exports, so this can answer differently in
|
|
18
|
+
* dev and in the shipped app.
|
|
19
|
+
* @param {string} name
|
|
20
|
+
* @returns {Promise<string | null>}
|
|
21
|
+
*/
|
|
22
|
+
export function env(name: string): Promise<string | null>;
|
|
23
|
+
export type Info = {
|
|
24
|
+
/**
|
|
25
|
+
* `macos`, `linux` or `windows`
|
|
26
|
+
*/
|
|
27
|
+
platform: string;
|
|
28
|
+
/**
|
|
29
|
+
* `arm64` or `x64`, as the npm packages and the update feed name them
|
|
30
|
+
*/
|
|
31
|
+
arch: string;
|
|
32
|
+
/**
|
|
33
|
+
* the system's name: `macOS`, or the Linux distribution's (`Ubuntu`)
|
|
34
|
+
*/
|
|
35
|
+
name: string | null;
|
|
36
|
+
/**
|
|
37
|
+
* the system's version: `15.3`, `24.04`
|
|
38
|
+
*/
|
|
39
|
+
version: string | null;
|
|
40
|
+
/**
|
|
41
|
+
* the user's preferred locale, `en-IN`
|
|
42
|
+
*/
|
|
43
|
+
locale: string;
|
|
44
|
+
/**
|
|
45
|
+
* every locale the user prefers, in order
|
|
46
|
+
*/
|
|
47
|
+
locales: string[];
|
|
48
|
+
hostname: string | null;
|
|
49
|
+
/**
|
|
50
|
+
* whether the user chose a dark appearance; null where the host cannot tell
|
|
51
|
+
*/
|
|
52
|
+
dark: boolean | null;
|
|
53
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Start a program. `program` is a name or an absolute path, and has to be
|
|
3
|
+
* in `permissions.process` as written (unless that is `true`). A name is
|
|
4
|
+
* looked for in the app's `PATH` and then in the usual install folders
|
|
5
|
+
* (`/usr/local/bin`, Homebrew's, `~/.local/bin`, `~/.cargo/bin`, the
|
|
6
|
+
* version managers' shim folders, …), because a bundled app opened from
|
|
7
|
+
* Finder does not get the shell profile's `PATH`. nvm's folders are not
|
|
8
|
+
* among them: list the absolute path.
|
|
9
|
+
*
|
|
10
|
+
* The child belongs to this runtime: when it goes (a reload, the window
|
|
11
|
+
* closing, the app quitting), the child and what it started are killed.
|
|
12
|
+
* A child that writes more than 256 KB nobody takes waits, as it would on
|
|
13
|
+
* a terminal nobody reads.
|
|
14
|
+
*
|
|
15
|
+
* Output is text (UTF-8). A program that writes binary data to its output
|
|
16
|
+
* comes out damaged: have it write to a file, and read that.
|
|
17
|
+
*
|
|
18
|
+
* @param {string} program
|
|
19
|
+
* @param {string[]} [args]
|
|
20
|
+
* @param {Options} [options]
|
|
21
|
+
* @returns {Promise<Child>} rejects when it is not allowed, not found or cannot start
|
|
22
|
+
*/
|
|
23
|
+
export function spawn(program: string, args?: string[], options?: Options): Promise<Child>;
|
|
24
|
+
/**
|
|
25
|
+
* Run a program to its end and collect what it wrote, up to 1 MB. Its
|
|
26
|
+
* input is closed. A program that fails still resolves: look at `code`.
|
|
27
|
+
* @param {string} program
|
|
28
|
+
* @param {string[]} [args]
|
|
29
|
+
* @param {Options} [options]
|
|
30
|
+
* @returns {Promise<Exit & Output>} rejects past 1 MB of output (the program is killed)
|
|
31
|
+
*/
|
|
32
|
+
export function run(program: string, args?: string[], options?: Options): Promise<Exit & Output>;
|
|
33
|
+
/**
|
|
34
|
+
* The file that would run for a program in `permissions.process`, or null
|
|
35
|
+
* when there is none: to say so before the user needs it.
|
|
36
|
+
* @param {string} program a listed name or absolute path
|
|
37
|
+
* @returns {Promise<string | null>}
|
|
38
|
+
*/
|
|
39
|
+
export function which(program: string): Promise<string | null>;
|
|
40
|
+
/**
|
|
41
|
+
* how it ended: its exit code, or the signal that ended it
|
|
42
|
+
*/
|
|
43
|
+
export type Exit = {
|
|
44
|
+
code: number | null;
|
|
45
|
+
signal: string | null;
|
|
46
|
+
};
|
|
47
|
+
export type Output = {
|
|
48
|
+
stdout: string;
|
|
49
|
+
stderr: string;
|
|
50
|
+
};
|
|
51
|
+
export type Options = {
|
|
52
|
+
/**
|
|
53
|
+
* the folder it runs in. A bundled app's own is `/`: give one.
|
|
54
|
+
*/
|
|
55
|
+
cwd?: string | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* variables added to the app's own
|
|
58
|
+
*/
|
|
59
|
+
env?: Record<string, string> | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* hears what it writes from the first byte on; `child.onOutput` adds more
|
|
62
|
+
*/
|
|
63
|
+
onOutput?: ((output: Output) => void) | undefined;
|
|
64
|
+
};
|
|
65
|
+
export type Signal = "SIGTERM" | "SIGKILL" | "SIGINT" | "SIGHUP" | "SIGQUIT";
|
|
66
|
+
export type Child = {
|
|
67
|
+
pid: number;
|
|
68
|
+
/**
|
|
69
|
+
* hear what it writes, as text, as it comes; returns what stops it. To
|
|
70
|
+
* miss nothing, give `onOutput` to `spawn()`: what is taken while nobody
|
|
71
|
+
* listens is dropped.
|
|
72
|
+
*/
|
|
73
|
+
onOutput: (listener: (output: Output) => void) => () => void;
|
|
74
|
+
/**
|
|
75
|
+
* to its input
|
|
76
|
+
*/
|
|
77
|
+
write: (data: string) => Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* end its input
|
|
80
|
+
*/
|
|
81
|
+
close: () => Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* signal it and everything it started (its process group); SIGTERM unless said
|
|
84
|
+
*/
|
|
85
|
+
kill: (signal?: Signal) => Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* settles once, after its last output
|
|
88
|
+
*/
|
|
89
|
+
exit: Promise<Exit>;
|
|
90
|
+
};
|
package/types/protocol.d.ts
CHANGED
|
@@ -15,7 +15,5 @@ export namespace OP {
|
|
|
15
15
|
let SCROLL: number;
|
|
16
16
|
let SCROLL_INTO_VIEW: number;
|
|
17
17
|
}
|
|
18
|
-
/** Id of the mount target. The host maps it to <body>. */
|
|
19
|
-
export const ROOT_ID: 1;
|
|
20
18
|
export const DISPATCH_PREVENT_DEFAULT: 1;
|
|
21
19
|
export const DISPATCH_STOP_PROPAGATION: 2;
|
package/types/renderer.d.ts
CHANGED
|
@@ -7,6 +7,14 @@ export function take_batch(): {
|
|
|
7
7
|
ops: Int32Array;
|
|
8
8
|
strings: string[];
|
|
9
9
|
} | null;
|
|
10
|
+
/**
|
|
11
|
+
* The elements named `name` (lower case) that are alive, attached or not, in
|
|
12
|
+
* no particular order; `null` if there are more than `limit`.
|
|
13
|
+
* @param {string} name
|
|
14
|
+
* @param {number} limit
|
|
15
|
+
* @returns {BlitzNode[] | null}
|
|
16
|
+
*/
|
|
17
|
+
export function elements_named(name: string, limit: number): BlitzNode[] | null;
|
|
10
18
|
/**
|
|
11
19
|
* Ask the host to report where this node is after every layout that moves or
|
|
12
20
|
* resizes it. The answer arrives through `host_hooks.layout`; see dom.js.
|
|
@@ -27,6 +35,9 @@ export function stats(): {
|
|
|
27
35
|
created: number;
|
|
28
36
|
live_elements: number;
|
|
29
37
|
pending_ops: number;
|
|
38
|
+
caches: {
|
|
39
|
+
[k: string]: number;
|
|
40
|
+
};
|
|
30
41
|
};
|
|
31
42
|
/**
|
|
32
43
|
* @param {{ listeners: Map<string, Function[]> | null }} target a node, or anything else that holds listeners
|
|
@@ -164,7 +175,11 @@ export const keep_alive: {
|
|
|
164
175
|
finalizer: FinalizationRegistry<number> | null;
|
|
165
176
|
root: BlitzNode | null;
|
|
166
177
|
};
|
|
167
|
-
/**
|
|
178
|
+
/** `<html>`: the page's root element. The parser always makes one, with a head and a body. */
|
|
179
|
+
export const html: BlitzNode;
|
|
180
|
+
/** `<head>`. */
|
|
181
|
+
export const head: BlitzNode;
|
|
182
|
+
/** `<body>`: where `mount` puts the app unless told otherwise. */
|
|
168
183
|
export const root: BlitzNode;
|
|
169
184
|
export class BlitzEvent {
|
|
170
185
|
/**
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A secret, or null when there is none under `key`. The OS may ask the user
|
|
3
|
+
* first: to unlock the keychain, or, on macOS, to let this build of the app
|
|
4
|
+
* read what another build of it stored.
|
|
5
|
+
* @param {string} key
|
|
6
|
+
* @returns {Promise<string | null>} rejects when there is no keychain, or the user refuses
|
|
7
|
+
*/
|
|
8
|
+
export function getSecret(key: string): Promise<string | null>;
|
|
9
|
+
/**
|
|
10
|
+
* Keep a secret under `key`, in place of what was there. A string, up to
|
|
11
|
+
* 64 KB.
|
|
12
|
+
* @param {string} key
|
|
13
|
+
* @param {string} value
|
|
14
|
+
* @returns {Promise<void>}
|
|
15
|
+
*/
|
|
16
|
+
export function setSecret(key: string, value: string): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Forget a secret. Nothing under `key` is not an error.
|
|
19
|
+
* @param {string} key
|
|
20
|
+
* @returns {Promise<void>}
|
|
21
|
+
*/
|
|
22
|
+
export function deleteSecret(key: string): Promise<void>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A setting's value, or undefined when it is not set.
|
|
3
|
+
* @param {string} key
|
|
4
|
+
* @returns {Promise<any>}
|
|
5
|
+
*/
|
|
6
|
+
export function get(key: string): Promise<any>;
|
|
7
|
+
/**
|
|
8
|
+
* Set a setting to anything JSON can carry, on disk before the promise
|
|
9
|
+
* settles. Undefined removes it, as JSON drops it.
|
|
10
|
+
* Every call is a flush to the disk (milliseconds): set on a choice made,
|
|
11
|
+
* not on every key press.
|
|
12
|
+
* @param {string} key
|
|
13
|
+
* @param {unknown} value
|
|
14
|
+
* @returns {Promise<void>} rejects past 1 MB of settings
|
|
15
|
+
*/
|
|
16
|
+
export function set(key: string, value: unknown): Promise<void>;
|
|
17
|
+
/** @param {string} key @returns {Promise<void>} */
|
|
18
|
+
export function remove(key: string): Promise<void>;
|
|
19
|
+
/** Every setting. @returns {Promise<Record<string, any>>} */
|
|
20
|
+
export function all(): Promise<Record<string, any>>;
|
|
21
|
+
/**
|
|
22
|
+
* Hear the changes the rest of the app makes (the other runtime, or Rust),
|
|
23
|
+
* not this runtime's own, as the web's `storage` event. `value` is
|
|
24
|
+
* undefined for a removal. When changes came faster than the app took
|
|
25
|
+
* them and some were dropped, `key` is null: read them again with `all()`.
|
|
26
|
+
* @param {(key: string | null, value: any) => void} listener
|
|
27
|
+
* @returns {() => void} stops listening
|
|
28
|
+
*/
|
|
29
|
+
export function onChange(listener: (key: string | null, value: any) => void): () => void;
|
package/types/shims.d.ts
CHANGED
package/types/stem.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Answer the page's requests to the app's origin with `next`. Call it once,
|
|
3
|
+
* from the server code's entry module; a later call replaces the handler.
|
|
4
|
+
* A request that arrives before it is answered with a 500.
|
|
5
|
+
*
|
|
6
|
+
* Experimental: what puts an app's code on the stem is not decided yet
|
|
7
|
+
* (SvelteKit's own server, or functions of Sepal's own), and this may
|
|
8
|
+
* change shape with it.
|
|
9
|
+
* @experimental
|
|
10
|
+
* @param {Handler} next
|
|
11
|
+
*/
|
|
12
|
+
export function serve(next: Handler): void;
|
|
13
|
+
/**
|
|
14
|
+
* What `serve()` takes: a function from a `Request` to its `Response` (or a
|
|
15
|
+
* promise of one), or an object with one as `fetch`, as servers on the web
|
|
16
|
+
* platform take them. Typed loosely: the app's code knows these classes by
|
|
17
|
+
* its own (DOM) types, and this package has none to name.
|
|
18
|
+
*/
|
|
19
|
+
export type Handler = ((request: any) => unknown) | {
|
|
20
|
+
fetch(request: any): unknown;
|
|
21
|
+
};
|
package/types/updater.d.ts
CHANGED
|
@@ -12,8 +12,9 @@
|
|
|
12
12
|
*
|
|
13
13
|
* `download()` fetches the update and verifies its signature; nothing on disk
|
|
14
14
|
* changes. `install()` downloads if that has not happened yet, replaces the
|
|
15
|
-
* app and
|
|
16
|
-
*
|
|
15
|
+
* app and ends it; the new version starts once it has ended. Code after a
|
|
16
|
+
* successful `install()` may not run. It rejects when the app is not running
|
|
17
|
+
* from a bundle (in dev, for instance).
|
|
17
18
|
*/
|
|
18
19
|
/**
|
|
19
20
|
* Ask the update feed whether there is a newer version for this platform.
|
|
@@ -25,8 +26,9 @@ export function check(): Promise<Update | null>;
|
|
|
25
26
|
/**
|
|
26
27
|
* `download()` fetches the update and verifies its signature; nothing on disk
|
|
27
28
|
* changes. `install()` downloads if that has not happened yet, replaces the
|
|
28
|
-
* app and
|
|
29
|
-
*
|
|
29
|
+
* app and ends it; the new version starts once it has ended. Code after a
|
|
30
|
+
* successful `install()` may not run. It rejects when the app is not running
|
|
31
|
+
* from a bundle (in dev, for instance).
|
|
30
32
|
*/
|
|
31
33
|
export type Update = {
|
|
32
34
|
version: string;
|