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/url.d.ts
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The files under `src` that SvelteKit would run on a server. An app has a
|
|
3
|
+
* thread for server code (the stem), but how an app's server code gets
|
|
4
|
+
* there is not decided (HANDOVER.md, "The stem's API: open"), so these
|
|
5
|
+
* would build and then never run. Relative to `src`.
|
|
6
|
+
* @param {string} src
|
|
7
|
+
*/
|
|
8
|
+
export function server_files(src: string): string[];
|
|
9
|
+
/**
|
|
10
|
+
* What is missing from the setup, as messages saying what to add.
|
|
11
|
+
* @param {import('@sveltejs/kit').Builder['config']} config
|
|
12
|
+
* @param {string} root the project
|
|
13
|
+
* @returns {string[]}
|
|
14
|
+
*/
|
|
15
|
+
export function problems(config: import("@sveltejs/kit").Builder["config"], root: string): string[];
|
|
16
|
+
/**
|
|
17
|
+
* @param {{ out?: string }} [options] `out` is where the app is written (default `dist`).
|
|
18
|
+
* @returns {import('@sveltejs/kit').Adapter}
|
|
19
|
+
*/
|
|
20
|
+
export default function adapter({ out }?: {
|
|
21
|
+
out?: string;
|
|
22
|
+
}): import("@sveltejs/kit").Adapter;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/** @typedef {{ crate: string, init: string, permission: { key: string, default?: unknown } }} PluginInfo */
|
|
2
|
+
/** @param {string} root */
|
|
3
|
+
export function package_manager(root: string): "bun" | "pnpm" | "yarn" | "npm";
|
|
4
|
+
/**
|
|
5
|
+
* The plugin an installed package is, or null. `sepal` is its peer range
|
|
6
|
+
* on sepal, which is its crate's requirement too.
|
|
7
|
+
* @param {string} root @param {string} name
|
|
8
|
+
* @returns {{ info: PluginInfo, version: string, dir: string, sepal: string | undefined } | null}
|
|
9
|
+
*/
|
|
10
|
+
export function installed_plugin(root: string, name: string): {
|
|
11
|
+
info: PluginInfo;
|
|
12
|
+
version: string;
|
|
13
|
+
dir: string;
|
|
14
|
+
sepal: string | undefined;
|
|
15
|
+
} | null;
|
|
16
|
+
/** Every plugin the project depends on, in name order. @param {string} root */
|
|
17
|
+
export function plugins(root: string): {
|
|
18
|
+
info: PluginInfo;
|
|
19
|
+
version: string;
|
|
20
|
+
dir: string;
|
|
21
|
+
sepal: string | undefined;
|
|
22
|
+
}[];
|
|
23
|
+
/** `native/src/plugins.rs` for these plugins. @param {PluginInfo[]} infos */
|
|
24
|
+
export function plugins_rs(infos: PluginInfo[]): string;
|
|
25
|
+
/**
|
|
26
|
+
* Add `key: value` to `permissions` in a `sepal.config.ts`, in place: the
|
|
27
|
+
* file is parsed (acorn with TypeScript) and the text inserted where it
|
|
28
|
+
* goes, nothing reprinted. Null when the file is not `export default
|
|
29
|
+
* defineConfig({ … })` with an object literal, which then needs the line
|
|
30
|
+
* by hand.
|
|
31
|
+
* @param {string} code @param {string} key @param {unknown} value
|
|
32
|
+
* @returns {{ code: string, changed: boolean } | null}
|
|
33
|
+
*/
|
|
34
|
+
export function add_permission(code: string, key: string, value: unknown): {
|
|
35
|
+
code: string;
|
|
36
|
+
changed: boolean;
|
|
37
|
+
} | null;
|
|
38
|
+
/**
|
|
39
|
+
* `sepal add <names…>`.
|
|
40
|
+
* @param {string} root the project
|
|
41
|
+
* @param {string[]} names
|
|
42
|
+
* @param {{ run?: Run, view?: (name: string) => boolean, crate_name: string, log?: (line: string) => void }} options
|
|
43
|
+
* `view` says whether a package that is not one of ours is a plugin (by default, the registry's word)
|
|
44
|
+
*/
|
|
45
|
+
export function add(root: string, names: string[], { run, view, crate_name, log }: {
|
|
46
|
+
run?: Run;
|
|
47
|
+
view?: (name: string) => boolean;
|
|
48
|
+
crate_name: string;
|
|
49
|
+
log?: (line: string) => void;
|
|
50
|
+
}): void;
|
|
51
|
+
/** Write native/src/plugins.rs again from the plugins the project has. @param {string} root */
|
|
52
|
+
export function write_plugins_rs(root: string): void;
|
|
53
|
+
/**
|
|
54
|
+
* `sepal check`'s own part: what has to agree between the npm packages,
|
|
55
|
+
* native/ and the config. svelte-check runs beside it.
|
|
56
|
+
* @param {string} root @param {Record<string, unknown> | undefined} permissions the config's
|
|
57
|
+
* @param {string} [version] this sepal's
|
|
58
|
+
* @returns {string[]} the problems
|
|
59
|
+
*/
|
|
60
|
+
export function check(root: string, permissions: Record<string, unknown> | undefined, version?: string): string[];
|
|
61
|
+
/**
|
|
62
|
+
* Sepal's own plugins, by short name. `sepal add watch` means these and
|
|
63
|
+
* nothing else: never whatever `sepal-<name>` someone published, which would
|
|
64
|
+
* then be installed as if it were ours, crate and all.
|
|
65
|
+
*/
|
|
66
|
+
export const FIRST_PARTY: Record<string, string>;
|
|
67
|
+
export type PluginInfo = {
|
|
68
|
+
crate: string;
|
|
69
|
+
init: string;
|
|
70
|
+
permission: {
|
|
71
|
+
key: string;
|
|
72
|
+
default?: unknown;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
export type Run = (command: string, args: string[], cwd: string) => {
|
|
76
|
+
status: number | null;
|
|
77
|
+
};
|
package/types/vite/app.d.ts
CHANGED
|
@@ -16,15 +16,40 @@ export function load_config(project: string, env: import("vite").ConfigEnv): Pro
|
|
|
16
16
|
* @param {import('./vite.js').Config} options
|
|
17
17
|
* @param {string} root the project
|
|
18
18
|
* @param {string} static_dir where the icon is looked for; empty when there is none
|
|
19
|
-
* @returns {{ json: string, icon: string | null } | null}
|
|
19
|
+
* @returns {{ json: string, icon: string | null, warnings: string[] } | null}
|
|
20
20
|
*/
|
|
21
21
|
export function manifest(options: import("./vite.js").Config, root: string, static_dir: string): {
|
|
22
22
|
json: string;
|
|
23
23
|
icon: string | null;
|
|
24
|
+
warnings: string[];
|
|
24
25
|
} | null;
|
|
26
|
+
/**
|
|
27
|
+
* What to say about `permissions.process` when it allows running anything:
|
|
28
|
+
* `true`, or a list that names a shell or a script runner. A warning, not
|
|
29
|
+
* an error: some apps are for exactly that.
|
|
30
|
+
* @param {{ process?: unknown } | undefined} permissions
|
|
31
|
+
* @returns {string[]}
|
|
32
|
+
*/
|
|
33
|
+
export function process_warnings(permissions: {
|
|
34
|
+
process?: unknown;
|
|
35
|
+
} | undefined): string[];
|
|
36
|
+
/**
|
|
37
|
+
* The flags for dev's throwaway bundle: `--dev`, which leaves the page out
|
|
38
|
+
* of it and signs it for this Mac, with the app's identity when
|
|
39
|
+
* `SEPAL_SIGN` names one. Its signature is then the same from one build
|
|
40
|
+
* of the app to the next, and so is the program the keychain and the
|
|
41
|
+
* notification settings know.
|
|
42
|
+
*/
|
|
43
|
+
export function dev_bundle_flags(): string[];
|
|
25
44
|
/**
|
|
26
45
|
* The app's window in dev. The first call opens it; every later one reloads
|
|
27
46
|
* it in place. Returns a function to call after each successful build.
|
|
47
|
+
*
|
|
48
|
+
* An app with `native/` runs its own host: built first (the window opens
|
|
49
|
+
* when it is), built again on every change to it or to a crate it has by
|
|
50
|
+
* path, and restarted when that changes the binary. A build that fails keeps
|
|
51
|
+
* the last good host running; one that never succeeded opens nothing. Both
|
|
52
|
+
* keep dev going until the next change.
|
|
28
53
|
* @param {() => { root: string, out_dir: string, name: string | undefined }} project read at the first call
|
|
29
54
|
*/
|
|
30
55
|
export function dev_window(project: () => {
|
|
@@ -32,5 +57,31 @@ export function dev_window(project: () => {
|
|
|
32
57
|
out_dir: string;
|
|
33
58
|
name: string | undefined;
|
|
34
59
|
}): () => void;
|
|
60
|
+
/**
|
|
61
|
+
* Compile the app's modules to bytecode with this machine's calyx (`calyx
|
|
62
|
+
* --compile`), which writes `x.js.qbc` next to each `x.js`: the host then
|
|
63
|
+
* loads them without parsing them. The app folder is a new build, so every
|
|
64
|
+
* module is compiled. Without a calyx that can, the app loads its
|
|
65
|
+
* JavaScript, as it always could: the build says so, and goes on.
|
|
66
|
+
* @param {string} dir the app folder
|
|
67
|
+
* @param {(message: string) => void} warn
|
|
68
|
+
* @returns {string | null} calyx's summary, or null when nothing was compiled
|
|
69
|
+
*/
|
|
70
|
+
export function compile_bytecode(dir: string, warn: (message: string) => void): string | null;
|
|
71
|
+
/**
|
|
72
|
+
* What `sepal()` tells the SvelteKit adapter (`sepal/adapter`), which runs
|
|
73
|
+
* inside SvelteKit's build and has no other way to reach it: the project,
|
|
74
|
+
* the settings from `sepal.config.ts`, and what to do once the app is
|
|
75
|
+
* written to a directory (open or reload the dev window). `null` until
|
|
76
|
+
* `sepal()` has run.
|
|
77
|
+
* @type {{ session: { root: string, options: import('./vite.js').Config, written: (out_dir: string) => void } | null }}
|
|
78
|
+
*/
|
|
79
|
+
export const kit: {
|
|
80
|
+
session: {
|
|
81
|
+
root: string;
|
|
82
|
+
options: import("./vite.js").Config;
|
|
83
|
+
written: (out_dir: string) => void;
|
|
84
|
+
} | null;
|
|
85
|
+
};
|
|
35
86
|
/** The Sepal app icon, for an app that has none of its own. A byte copy of assets/brand/sepal-app-icon-1024.png. */
|
|
36
87
|
export const SEPAL_ICON: string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The notices for the binary `manifest` builds.
|
|
3
|
+
* @param {string} manifest the Cargo.toml the binary is built from
|
|
4
|
+
* @param {string[]} [features] the features it is built with; a superset is fine for a list of notices
|
|
5
|
+
* @returns {{ text: string, crates: number, texts: number }}
|
|
6
|
+
*/
|
|
7
|
+
export function third_party_licenses(manifest: string, features?: string[]): {
|
|
8
|
+
text: string;
|
|
9
|
+
crates: number;
|
|
10
|
+
texts: number;
|
|
11
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether `version` is in the caret range `^base`, as Cargo and npm both
|
|
3
|
+
* read one: at `base` or after it, in its 0.x line (its major from 1.0 on),
|
|
4
|
+
* and a pre-release only of `base`'s own major.minor.patch. This is how a
|
|
5
|
+
* plugin names sepal, in its crate and in its package's peer range.
|
|
6
|
+
* @param {string} base @param {string} version
|
|
7
|
+
*/
|
|
8
|
+
export function caret_accepts(base: string, version: string): boolean;
|
|
9
|
+
/** @param {string} root the project @returns {string | null} `native/Cargo.toml`, if the app has one */
|
|
10
|
+
export function native_manifest(root: string): string | null;
|
|
11
|
+
/** The build directory every app on this machine shares: one subdirectory per compiler. */
|
|
12
|
+
export function cargo_dir(env?: NodeJS.ProcessEnv): string;
|
|
13
|
+
/**
|
|
14
|
+
* The crate's name, from the app's id (`app.sepal.tracker` is
|
|
15
|
+
* `app-sepal-tracker`) or else its package name.
|
|
16
|
+
* @param {string | undefined} id @param {string | undefined} package_name
|
|
17
|
+
*/
|
|
18
|
+
export function crate_name(id: string | undefined, package_name: string | undefined): string;
|
|
19
|
+
/**
|
|
20
|
+
* What `sepal native init` writes, by path under the project.
|
|
21
|
+
* @param {{ name: string, version: string, native: string, crates?: string }} options
|
|
22
|
+
* @returns {Record<string, string>}
|
|
23
|
+
*/
|
|
24
|
+
export function init_files({ name, version, native, crates }: {
|
|
25
|
+
name: string;
|
|
26
|
+
version: string;
|
|
27
|
+
native: string;
|
|
28
|
+
crates?: string;
|
|
29
|
+
}): Record<string, string>;
|
|
30
|
+
/**
|
|
31
|
+
* Why `native/` cannot be built with this sepal, or null: its lines name
|
|
32
|
+
* another release's tag. The host and the JavaScript are released together.
|
|
33
|
+
* @param {string} manifest @param {string} version
|
|
34
|
+
*/
|
|
35
|
+
export function tag_problem(manifest: string, version: string): string | null;
|
|
36
|
+
/** Point the lines that name a release at this one. @param {string} manifest @param {string} version @returns {number} the lines changed */
|
|
37
|
+
export function update_tag(manifest: string, version: string): number;
|
|
38
|
+
/**
|
|
39
|
+
* The subdirectory for a compiler, from `rustc -vV`: `rustc-1.95.0-59807616e`.
|
|
40
|
+
* The commit tells nightlies of one release apart.
|
|
41
|
+
* @param {string} verbose
|
|
42
|
+
*/
|
|
43
|
+
export function compiler_dir(verbose: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* The build directory for `native/`: the shared one's subdirectory for the
|
|
46
|
+
* compiler cargo uses there (rustup picks it from the directory, with its
|
|
47
|
+
* rust-toolchain file).
|
|
48
|
+
* @param {string} manifest @param {NodeJS.ProcessEnv} [env]
|
|
49
|
+
*/
|
|
50
|
+
export function build_dir(manifest: string, env?: NodeJS.ProcessEnv): string;
|
|
51
|
+
/**
|
|
52
|
+
* Remove the other compilers' build directories that no build has used for
|
|
53
|
+
* 30 days. Only `rustc-*` directories: nothing else in `base` is ours.
|
|
54
|
+
* @param {string} base @param {string} keep the one in use @param {number} [now]
|
|
55
|
+
* @returns {string[]} what was removed
|
|
56
|
+
*/
|
|
57
|
+
export function prune(base: string, keep: string, now?: number): string[];
|
|
58
|
+
/** `sepal native clean`: the whole shared directory, every compiler's. @returns {string} what was removed */
|
|
59
|
+
export function clean(env?: NodeJS.ProcessEnv): string;
|
|
60
|
+
/**
|
|
61
|
+
* What this machine is missing to build `native/`, as the message to print,
|
|
62
|
+
* or null.
|
|
63
|
+
* @param {NodeJS.ProcessEnv} [env]
|
|
64
|
+
*/
|
|
65
|
+
export function toolchain_problem(env?: NodeJS.ProcessEnv): string | null;
|
|
66
|
+
/**
|
|
67
|
+
* Build `native/` with cargo, its progress on this terminal. Resolves to the
|
|
68
|
+
* binary, or to the error when cargo fails.
|
|
69
|
+
* @param {string} manifest `native/Cargo.toml`
|
|
70
|
+
* @param {'dev' | 'dist'} profile
|
|
71
|
+
* @returns {Promise<{ binary: string } | { error: string }>}
|
|
72
|
+
*/
|
|
73
|
+
export function build(manifest: string, profile: "dev" | "dist"): Promise<{
|
|
74
|
+
binary: string;
|
|
75
|
+
} | {
|
|
76
|
+
error: string;
|
|
77
|
+
}>;
|
|
78
|
+
/**
|
|
79
|
+
* Sign dev's host with the app's signing identity (`SEPAL_SIGN`), on macOS.
|
|
80
|
+
*
|
|
81
|
+
* The keychain knows a program by its code signature, and the linker signs
|
|
82
|
+
* each build ad hoc, as a hash of the binary: to the keychain every rebuild
|
|
83
|
+
* is another program, asked before it reads a secret the last one stored.
|
|
84
|
+
* Signed with one identity under one identifier, the builds are one
|
|
85
|
+
* program. Only a binary cargo just linked is signed (its signature is the
|
|
86
|
+
* linker's again), so an unchanged host is not touched and dev does not
|
|
87
|
+
* restart it.
|
|
88
|
+
* @param {string} binary @param {string | undefined} identity
|
|
89
|
+
* @param {typeof spawnSync} [run]
|
|
90
|
+
* @returns {boolean} whether it signed it
|
|
91
|
+
*/
|
|
92
|
+
export function sign_dev_host(binary: string, identity: string | undefined, run?: typeof spawnSync): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* The directories of every crate `native/` has by path, itself included:
|
|
95
|
+
* what a rebuild in dev watches.
|
|
96
|
+
* @param {string} manifest
|
|
97
|
+
* @returns {Promise<string[]>}
|
|
98
|
+
*/
|
|
99
|
+
export function path_crates(manifest: string): Promise<string[]>;
|
|
100
|
+
/**
|
|
101
|
+
* Watch `dirs` (told by the OS: FSEvents, inotify; nothing polls) and call
|
|
102
|
+
* `changed` once for every burst of changes, a burst being changes less than
|
|
103
|
+
* 100 ms apart. What is under a `target/` directory does not count.
|
|
104
|
+
* @param {string[]} dirs @param {(file: string) => void} changed
|
|
105
|
+
* @returns {() => void} stops watching
|
|
106
|
+
*/
|
|
107
|
+
export function watch_crates(dirs: string[], changed: (file: string) => void): () => void;
|
|
108
|
+
/** When the binary was last written, to tell a rebuild that changed it from one that did not. @param {string} binary */
|
|
109
|
+
export function written(binary: string): number;
|
|
110
|
+
/**
|
|
111
|
+
* Check, build and hand over: everything `sepal run`, `screenshot` and
|
|
112
|
+
* `bundle` need before they start the host. Exits with the message when the
|
|
113
|
+
* app cannot be built. Sets `SEPAL_HOST` to the binary.
|
|
114
|
+
* @param {string} manifest @param {'dev' | 'dist'} profile
|
|
115
|
+
* @returns {Promise<string>} the binary
|
|
116
|
+
*/
|
|
117
|
+
export function build_or_exit(manifest: string, profile: "dev" | "dist"): Promise<string>;
|
|
118
|
+
/** The line before a build, and what a first one costs. @param {string} manifest @param {'dev' | 'dist'} profile */
|
|
119
|
+
export function announce(manifest: string, profile: "dev" | "dist"): void;
|
|
120
|
+
/**
|
|
121
|
+
* Write `native/` for the project at `root`. Refuses if it exists.
|
|
122
|
+
* @param {string} root @param {string} name the crate's name
|
|
123
|
+
* @returns {string[]} the files written
|
|
124
|
+
*/
|
|
125
|
+
export function init(root: string, name: string): string[];
|
|
126
|
+
export const REPOSITORY: "https://github.com/etherCorps/sepal";
|
|
127
|
+
/** Sepal's patched crates, in the order `[patch.crates-io]` lists them. */
|
|
128
|
+
export const PATCHED: string[];
|
|
129
|
+
/** The version of this sepal, which `native/` has to build its host from. */
|
|
130
|
+
export const VERSION: any;
|
|
131
|
+
export type Version = {
|
|
132
|
+
numbers: number[];
|
|
133
|
+
pre: string[] | undefined;
|
|
134
|
+
};
|
|
135
|
+
import { spawnSync } from 'node:child_process';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What in a stylesheet would load from the network: `@import` of a remote
|
|
3
|
+
* stylesheet, and fonts in `@font-face`. Images are not checked: they are
|
|
4
|
+
* refused when they load, as today.
|
|
5
|
+
* @param {string} css
|
|
6
|
+
* @param {string} where the file, for the message
|
|
7
|
+
* @returns {string[]}
|
|
8
|
+
*/
|
|
9
|
+
export function check_css(css: string, where: string): string[];
|
|
10
|
+
/**
|
|
11
|
+
* Check a page. `errors` stop the build: something would load from the
|
|
12
|
+
* network. `warnings` are what the host leaves out.
|
|
13
|
+
* @param {string} html
|
|
14
|
+
* @param {string} where the file, for the messages
|
|
15
|
+
* @returns {{ errors: string[], warnings: string[] }}
|
|
16
|
+
*/
|
|
17
|
+
export function check_page(html: string, where?: string): {
|
|
18
|
+
errors: string[];
|
|
19
|
+
warnings: string[];
|
|
20
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the app may do, beyond its own page: `permissions` in
|
|
3
|
+
* `sepal.config.ts`. Each key is default-deny.
|
|
4
|
+
*
|
|
5
|
+
* A plugin's package adds its own key, which its commands need:
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* declare module 'sepal/permissions' {
|
|
9
|
+
* interface Permissions { watch?: boolean | string[] }
|
|
10
|
+
* }
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* (`sepal/vite`'s `Permissions` is this one; augment it here, where it is
|
|
14
|
+
* declared.) A key no installed package declares is an error here, as the
|
|
15
|
+
* host's own check is at launch.
|
|
16
|
+
*/
|
|
17
|
+
export interface Permissions {
|
|
18
|
+
/** Which URLs `fetch` may reach: origins, optionally with a path prefix, or a host with a wildcard. `true` allows any. */
|
|
19
|
+
http?: boolean | string[];
|
|
20
|
+
/** Which directories the file APIs may touch: `data`, `documents`, `downloads`, `desktop`, `home`, or absolute paths. `true` allows any. */
|
|
21
|
+
fs?: boolean | string[];
|
|
22
|
+
/** Open, save and message dialogs. */
|
|
23
|
+
dialog?: boolean;
|
|
24
|
+
/** Reading and writing the clipboard. */
|
|
25
|
+
clipboard?: boolean;
|
|
26
|
+
/** Opening web and mail links, and allowed files, in their default app. */
|
|
27
|
+
open?: boolean;
|
|
28
|
+
/** Changing the window: minimise, maximise, decorations, close, drag. */
|
|
29
|
+
window?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* The system's details (`info()` in `sepal/os`): platform, version, locale,
|
|
32
|
+
* host name, dark mode. Environment variables only by name, listed in
|
|
33
|
+
* `env`, which gives `info()` too.
|
|
34
|
+
*/
|
|
35
|
+
os?: boolean | { env?: string[] };
|
|
36
|
+
/** The app's settings (`sepal/settings`), shared with the app's Rust. */
|
|
37
|
+
settings?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* The programs `sepal/process` may run: names (`'git'`, found in the
|
|
40
|
+
* app's `PATH` and the usual install folders) and absolute paths. `true`
|
|
41
|
+
* allows any. The list limits which programs start, not what they do:
|
|
42
|
+
* `git` runs hooks and aliases, and a shell or `node` runs anything.
|
|
43
|
+
*/
|
|
44
|
+
process?: boolean | string[];
|
|
45
|
+
/**
|
|
46
|
+
* The OS's keychain (`sepal/secrets`): the login keychain on macOS, the
|
|
47
|
+
* Secret Service or the Secret portal on Linux. Kept under the app's id;
|
|
48
|
+
* on Linux other programs of the user's can read an unlocked keyring.
|
|
49
|
+
*/
|
|
50
|
+
secrets?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* The system's notifications (`sepal/notifications`). On macOS the user
|
|
53
|
+
* is asked as well, the first time.
|
|
54
|
+
*/
|
|
55
|
+
notifications?: boolean;
|
|
56
|
+
}
|
|
@@ -1,44 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* @param {string} src
|
|
2
|
+
* @deprecated Use SvelteKit's `sveltekit(withSepal({ adapter: adapter() }))`,
|
|
3
|
+
* with `adapter` from `sepal/adapter`, and `sepal()` from `sepal/vite`.
|
|
4
|
+
* @param {Record<string, unknown>} [_options]
|
|
5
|
+
* @returns {never}
|
|
7
6
|
*/
|
|
8
|
-
export function
|
|
9
|
-
/**
|
|
10
|
-
* Turn what SvelteKit built (an HTML page that imports one module) into what
|
|
11
|
-
* the host loads (a script, a stylesheet, and the other files as they are).
|
|
12
|
-
* @param {string} from SvelteKit's client output, with its fallback page as `index.html`
|
|
13
|
-
* @param {string} to
|
|
14
|
-
*/
|
|
15
|
-
export function convert(from: string, to: string): void;
|
|
16
|
-
/**
|
|
17
|
-
* A stylesheet moved from `dir` (relative to the build, `/`-separated) to
|
|
18
|
-
* app.css at its root. Its relative `url()`s, such as a font next to it in
|
|
19
|
-
* `_app/immutable/assets`, have to say where they now are from there.
|
|
20
|
-
* @param {string} css
|
|
21
|
-
* @param {string} dir
|
|
22
|
-
*/
|
|
23
|
-
export function rebase_css(css: string, dir: string): string;
|
|
24
|
-
/**
|
|
25
|
-
* @typedef {import('./vite.js').Config & {
|
|
26
|
-
* kit?: import('@sveltejs/kit/vite').Config,
|
|
27
|
-
* out?: string
|
|
28
|
-
* }} KitOptions
|
|
29
|
-
* `app` and `permissions` override `sepal.config.ts`, key by key. `kit` is
|
|
30
|
-
* passed on to SvelteKit. `out` is where the app is written (default `dist`).
|
|
31
|
-
*/
|
|
32
|
-
/**
|
|
33
|
-
* @param {KitOptions} [inline]
|
|
34
|
-
* @returns {Promise<import('vite').PluginOption[]>}
|
|
35
|
-
*/
|
|
36
|
-
export function sepalKit(inline?: KitOptions): Promise<import("vite").PluginOption[]>;
|
|
37
|
-
/**
|
|
38
|
-
* `app` and `permissions` override `sepal.config.ts`, key by key. `kit` is
|
|
39
|
-
* passed on to SvelteKit. `out` is where the app is written (default `dist`).
|
|
40
|
-
*/
|
|
41
|
-
export type KitOptions = import("./vite.js").Config & {
|
|
42
|
-
kit?: import("@sveltejs/kit/vite").Config;
|
|
43
|
-
out?: string;
|
|
44
|
-
};
|
|
7
|
+
export function sepalKit(_options?: Record<string, unknown>): never;
|
package/types/vite/vite.d.ts
CHANGED
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
* (square, 1024×1024 recommended) in the `static/` directory, named relative to
|
|
6
6
|
* it; `static/icon.png` is used when `icon` is left out, and the Sepal icon
|
|
7
7
|
* when there is no `static/icon.png` either. `width` and `height`
|
|
8
|
-
* are the initial window size in logical pixels
|
|
8
|
+
* are the initial window size in logical pixels, and `minWidth` and `minHeight` how
|
|
9
|
+
* small the window can be made: the size below which the app's layout cannot
|
|
10
|
+
* work. The window never opens smaller. `id` (a bundle identifier such as `com.example.counter`) and
|
|
9
11
|
* `version` are used when the app is bundled.
|
|
10
12
|
*
|
|
11
13
|
* `updater` turns on self-update: `url` is where the update feed
|
|
@@ -13,13 +15,18 @@
|
|
|
13
15
|
* updates are signed with (`sepal signer generate`). The app then
|
|
14
16
|
* updates itself through `sepal/updater`.
|
|
15
17
|
*
|
|
18
|
+
* `background: true` keeps an app with server code running when its last
|
|
19
|
+
* window closes: the server code goes on, with no window, until the app
|
|
20
|
+
* calls `quit()` from `sepal/app`. Otherwise closing the window quits the app.
|
|
21
|
+
*
|
|
16
22
|
* @typedef {{
|
|
17
23
|
* name?: string,
|
|
18
24
|
* id?: string,
|
|
19
25
|
* version?: string,
|
|
20
26
|
* icon?: string,
|
|
27
|
+
* background?: boolean,
|
|
21
28
|
* updater?: { url: string, pubkey: string },
|
|
22
|
-
* window?: { title?: string, width?: number, height?: number }
|
|
29
|
+
* window?: { title?: string, width?: number, height?: number, minWidth?: number, minHeight?: number }
|
|
23
30
|
* }} AppManifest
|
|
24
31
|
*/
|
|
25
32
|
/**
|
|
@@ -37,16 +44,26 @@
|
|
|
37
44
|
* - `dialog`: open, save and message dialogs.
|
|
38
45
|
* - `clipboard`: reading and writing the clipboard.
|
|
39
46
|
* - `open`: opening web and mail links, and allowed files, in their default app.
|
|
40
|
-
* - `window`: changing the window:
|
|
47
|
+
* - `window`: changing the window: minimise, maximise, decorations, close,
|
|
48
|
+
* drag. The title needs no permission.
|
|
49
|
+
* - `os`: the system's details (`sepal/os`'s `info()`). Environment
|
|
50
|
+
* variables only by name: `os: { env: ['EDITOR'] }`, which gives `info()`
|
|
51
|
+
* too. The locale needs none: it is `navigator.language`.
|
|
52
|
+
* - `settings`: the app's settings (`sepal/settings`), a store the page,
|
|
53
|
+
* the server code and the app's Rust share.
|
|
54
|
+
* - `process`: which programs `sepal/process` may run: names
|
|
55
|
+
* (`'git'`) and absolute paths. It limits which programs start, not what
|
|
56
|
+
* they do: `git` runs hooks and aliases, a shell runs anything. `true`
|
|
57
|
+
* allows any program.
|
|
58
|
+
* - `secrets`: the OS's keychain (`sepal/secrets`), for the app's own
|
|
59
|
+
* tokens and passwords.
|
|
60
|
+
* - `notifications`: the system's notifications (`sepal/notifications`).
|
|
41
61
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* open?: boolean,
|
|
48
|
-
* window?: boolean
|
|
49
|
-
* }} Permissions
|
|
62
|
+
* An interface (vite/permissions.d.ts, `sepal/permissions`), so that a
|
|
63
|
+
* plugin's package can add its key:
|
|
64
|
+
* `declare module 'sepal/permissions' { interface Permissions { … } }`.
|
|
65
|
+
*
|
|
66
|
+
* @typedef {import('./permissions.js').Permissions} Permissions
|
|
50
67
|
*/
|
|
51
68
|
/**
|
|
52
69
|
* The settings in `sepal.config.ts`.
|
|
@@ -56,13 +73,9 @@
|
|
|
56
73
|
* (`window`, `document`, element methods; see `sepal/dom`)
|
|
57
74
|
* before anything else, so those libraries find what they reach for.
|
|
58
75
|
*
|
|
59
|
-
* `entry` is the module the app starts from (default `src/main.js` or
|
|
60
|
-
* `src/main.ts`). It mounts the app; a router of your own goes there.
|
|
61
|
-
*
|
|
62
76
|
* @typedef {{
|
|
63
77
|
* app?: AppManifest,
|
|
64
78
|
* permissions?: Permissions,
|
|
65
|
-
* entry?: string,
|
|
66
79
|
* dom?: boolean
|
|
67
80
|
* }} Config
|
|
68
81
|
*/
|
|
@@ -83,6 +96,35 @@ export function defineConfig<T extends Config | ((env: import("vite").ConfigEnv)
|
|
|
83
96
|
export function sepal(inline?: Config & {
|
|
84
97
|
svelte?: import("@sveltejs/vite-plugin-svelte").Options;
|
|
85
98
|
}): import("vite").PluginOption[];
|
|
99
|
+
/**
|
|
100
|
+
* Sepal's rewrites of what Svelte refuses for a custom renderer (`bind:` on
|
|
101
|
+
* elements, `<svelte:head>`), as one preprocessor. `withSepal()` adds it;
|
|
102
|
+
* this is for an app that sets `sveltekit()`'s options by hand, after its
|
|
103
|
+
* own preprocessors: `preprocess: [vitePreprocess(), sepalPreprocess()]`.
|
|
104
|
+
* @returns {import('svelte/compiler').PreprocessorGroup}
|
|
105
|
+
*/
|
|
106
|
+
export function sepalPreprocess(): import("svelte/compiler").PreprocessorGroup;
|
|
107
|
+
/**
|
|
108
|
+
* SvelteKit's options for a Sepal app: `sveltekit(withSepal({ adapter: adapter() }))`,
|
|
109
|
+
* with `adapter` from `sepal/adapter`. Adds what every Sepal app needs to
|
|
110
|
+
* the app's own options: components compiled for the Sepal renderer, no
|
|
111
|
+
* version polling (apps update through `sepal/updater`), and Sepal's
|
|
112
|
+
* rewrites after the app's own preprocessors (`sepalPreprocess()`), once.
|
|
113
|
+
* Throws on options that cannot work in an app.
|
|
114
|
+
* @template {import('@sveltejs/kit/vite').Config} T
|
|
115
|
+
* @param {T} options
|
|
116
|
+
* @returns {T}
|
|
117
|
+
*/
|
|
118
|
+
export function withSepal<T extends import("@sveltejs/kit/vite").Config>(options: T): T;
|
|
119
|
+
/**
|
|
120
|
+
* What SvelteKit's options lack for a Sepal app, as messages; empty when
|
|
121
|
+
* nothing does. `sepal()` checks before the build, the adapter after it.
|
|
122
|
+
* @param {any} config SvelteKit's options, as it validated them
|
|
123
|
+
* @returns {string[]}
|
|
124
|
+
*/
|
|
125
|
+
export function kit_setup_problems(config: any): string[];
|
|
126
|
+
/** A SvelteKit app's vite.config.ts, for the messages that point to it. */
|
|
127
|
+
export const KIT_SETUP: "import { sveltekit } from '@sveltejs/kit/vite';\nimport adapter from 'sepal/adapter';\nimport { sepal, withSepal } from 'sepal/vite';\nimport { defineConfig } from 'vite';\n\nexport default defineConfig({\n\tplugins: [sveltekit(withSepal({ adapter: adapter() })), sepal()]\n});";
|
|
86
128
|
/**
|
|
87
129
|
* What the app tells the host about itself. Written to `dist/app.json`.
|
|
88
130
|
*
|
|
@@ -90,19 +132,26 @@ export function sepal(inline?: Config & {
|
|
|
90
132
|
* (square, 1024×1024 recommended) in the `static/` directory, named relative to
|
|
91
133
|
* it; `static/icon.png` is used when `icon` is left out, and the Sepal icon
|
|
92
134
|
* when there is no `static/icon.png` either. `width` and `height`
|
|
93
|
-
* are the initial window size in logical pixels
|
|
135
|
+
* are the initial window size in logical pixels, and `minWidth` and `minHeight` how
|
|
136
|
+
* small the window can be made: the size below which the app's layout cannot
|
|
137
|
+
* work. The window never opens smaller. `id` (a bundle identifier such as `com.example.counter`) and
|
|
94
138
|
* `version` are used when the app is bundled.
|
|
95
139
|
*
|
|
96
140
|
* `updater` turns on self-update: `url` is where the update feed
|
|
97
141
|
* (`latest.json`) is published, `pubkey` is the public half of the key the
|
|
98
142
|
* updates are signed with (`sepal signer generate`). The app then
|
|
99
143
|
* updates itself through `sepal/updater`.
|
|
144
|
+
*
|
|
145
|
+
* `background: true` keeps an app with server code running when its last
|
|
146
|
+
* window closes: the server code goes on, with no window, until the app
|
|
147
|
+
* calls `quit()` from `sepal/app`. Otherwise closing the window quits the app.
|
|
100
148
|
*/
|
|
101
149
|
export type AppManifest = {
|
|
102
150
|
name?: string;
|
|
103
151
|
id?: string;
|
|
104
152
|
version?: string;
|
|
105
153
|
icon?: string;
|
|
154
|
+
background?: boolean;
|
|
106
155
|
updater?: {
|
|
107
156
|
url: string;
|
|
108
157
|
pubkey: string;
|
|
@@ -111,6 +160,8 @@ export type AppManifest = {
|
|
|
111
160
|
title?: string;
|
|
112
161
|
width?: number;
|
|
113
162
|
height?: number;
|
|
163
|
+
minWidth?: number;
|
|
164
|
+
minHeight?: number;
|
|
114
165
|
};
|
|
115
166
|
};
|
|
116
167
|
/**
|
|
@@ -128,16 +179,26 @@ export type AppManifest = {
|
|
|
128
179
|
* - `dialog`: open, save and message dialogs.
|
|
129
180
|
* - `clipboard`: reading and writing the clipboard.
|
|
130
181
|
* - `open`: opening web and mail links, and allowed files, in their default app.
|
|
131
|
-
* - `window`: changing the window:
|
|
182
|
+
* - `window`: changing the window: minimise, maximise, decorations, close,
|
|
183
|
+
* drag. The title needs no permission.
|
|
184
|
+
* - `os`: the system's details (`sepal/os`'s `info()`). Environment
|
|
185
|
+
* variables only by name: `os: { env: ['EDITOR'] }`, which gives `info()`
|
|
186
|
+
* too. The locale needs none: it is `navigator.language`.
|
|
187
|
+
* - `settings`: the app's settings (`sepal/settings`), a store the page,
|
|
188
|
+
* the server code and the app's Rust share.
|
|
189
|
+
* - `process`: which programs `sepal/process` may run: names
|
|
190
|
+
* (`'git'`) and absolute paths. It limits which programs start, not what
|
|
191
|
+
* they do: `git` runs hooks and aliases, a shell runs anything. `true`
|
|
192
|
+
* allows any program.
|
|
193
|
+
* - `secrets`: the OS's keychain (`sepal/secrets`), for the app's own
|
|
194
|
+
* tokens and passwords.
|
|
195
|
+
* - `notifications`: the system's notifications (`sepal/notifications`).
|
|
196
|
+
*
|
|
197
|
+
* An interface (vite/permissions.d.ts, `sepal/permissions`), so that a
|
|
198
|
+
* plugin's package can add its key:
|
|
199
|
+
* `declare module 'sepal/permissions' { interface Permissions { … } }`.
|
|
132
200
|
*/
|
|
133
|
-
export type Permissions =
|
|
134
|
-
http?: boolean | string[];
|
|
135
|
-
fs?: boolean | string[];
|
|
136
|
-
dialog?: boolean;
|
|
137
|
-
clipboard?: boolean;
|
|
138
|
-
open?: boolean;
|
|
139
|
-
window?: boolean;
|
|
140
|
-
};
|
|
201
|
+
export type Permissions = import("./permissions.js").Permissions;
|
|
141
202
|
/**
|
|
142
203
|
* The settings in `sepal.config.ts`.
|
|
143
204
|
*
|
|
@@ -145,13 +206,9 @@ export type Permissions = {
|
|
|
145
206
|
* It builds the app as a browser bundle and loads a small DOM
|
|
146
207
|
* (`window`, `document`, element methods; see `sepal/dom`)
|
|
147
208
|
* before anything else, so those libraries find what they reach for.
|
|
148
|
-
*
|
|
149
|
-
* `entry` is the module the app starts from (default `src/main.js` or
|
|
150
|
-
* `src/main.ts`). It mounts the app; a router of your own goes there.
|
|
151
209
|
*/
|
|
152
210
|
export type Config = {
|
|
153
211
|
app?: AppManifest;
|
|
154
212
|
permissions?: Permissions;
|
|
155
|
-
entry?: string;
|
|
156
213
|
dom?: boolean;
|
|
157
214
|
};
|