@adea-ai/app-framework 0.25.1 → 0.27.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 +163 -21
- package/dist/app/application.d.ts +11 -4
- package/dist/app/application.js +24 -4
- package/dist/app/create-application.d.ts +9 -0
- package/dist/app/create-application.js +214 -143
- package/dist/app/private-group.d.ts +14 -0
- package/dist/app/private-group.js +39 -0
- package/dist/app/service-registry.d.ts +8 -4
- package/dist/app/service-registry.js +43 -6
- package/dist/appearance/custom-theme-import.d.ts +5 -7
- package/dist/appearance/custom-theme-import.js +66 -18
- package/dist/appearance/custom-theme-library.d.ts +51 -3
- package/dist/appearance/custom-theme-library.js +262 -33
- package/dist/appearance/editor.d.ts +3 -1
- package/dist/appearance/editor.js +37 -2
- package/dist/appearance/theme-file-importer.d.ts +7 -3
- package/dist/appearance/theme-file-importer.js +27 -7
- package/dist/appearance/theme-library-action-fence.d.ts +11 -0
- package/dist/appearance/theme-library-action-fence.js +29 -0
- package/dist/cli/framework-update-cli.js +16 -3
- package/dist/cli/release-step-cli.js +6 -1
- package/dist/desktop/application-command-client.d.ts +11 -1
- package/dist/desktop/application-command-client.js +66 -3
- package/dist/desktop/channel-handshake.d.ts +2 -1
- package/dist/desktop/channel-handshake.js +21 -5
- package/dist/desktop/client-asset-stream.d.ts +10 -0
- package/dist/desktop/client-asset-stream.js +97 -0
- package/dist/desktop/client-assets.d.ts +3 -1
- package/dist/desktop/client-assets.js +41 -6
- package/dist/desktop/desktop-client.d.ts +15 -1
- package/dist/desktop/desktop-client.js +235 -109
- package/dist/desktop/desktop-gateway.d.ts +2 -0
- package/dist/desktop/desktop-gateway.js +134 -22
- package/dist/desktop/desktop-host-websocket.d.ts +10 -0
- package/dist/desktop/desktop-host-websocket.js +28 -0
- package/dist/desktop/desktop-host.d.ts +9 -0
- package/dist/desktop/desktop-host.js +70 -61
- package/dist/desktop/desktop-port-file.d.ts +2 -0
- package/dist/desktop/desktop-port-file.js +23 -0
- package/dist/desktop/desktop-stream.d.ts +5 -0
- package/dist/desktop/desktop-stream.js +83 -15
- package/dist/desktop/gateway-limits.d.ts +2 -0
- package/dist/desktop/gateway-limits.js +6 -0
- package/dist/desktop/open-url-channel.d.ts +5 -3
- package/dist/desktop/open-url-channel.js +18 -5
- package/dist/desktop/typed-array-intrinsics.d.ts +6 -0
- package/dist/desktop/typed-array-intrinsics.js +19 -0
- package/dist/framework-source.json +1 -1
- package/dist/installer/installed-payload.js +1 -1
- package/dist/installer/installer-ci-bootstrap.js +2 -1
- package/dist/installer/installer-command.d.ts +13 -0
- package/dist/installer/installer-command.js +47 -0
- package/dist/installer/installer-extraction.js +27 -61
- package/dist/installer/installer-identity.d.ts +22 -3
- package/dist/installer/installer-identity.js +63 -72
- package/dist/installer/installer-image-mount.d.ts +48 -0
- package/dist/installer/installer-image-mount.js +347 -0
- package/dist/installer/installer-layout.d.ts +2 -0
- package/dist/installer/installer-layout.js +6 -2
- package/dist/installer/installer-process-cleanup.js +1 -1
- package/dist/installer/installer-renderer-evidence.js +6 -2
- package/dist/installer/upgrade-asset-download.js +30 -8
- package/dist/native/app-bundle.d.ts +2 -2
- package/dist/native/app-bundle.js +5 -4
- package/dist/native/cef-helper-download.d.ts +1 -0
- package/dist/native/cef-helper-download.js +35 -0
- package/dist/native/cef-helper.js +146 -61
- package/dist/native/exclusive-rename.d.ts +2 -0
- package/dist/native/exclusive-rename.js +52 -0
- package/dist/native/native-secret-store.js +5 -4
- package/dist/native/partitioned-window.d.ts +5 -2
- package/dist/native/partitioned-window.js +69 -9
- package/dist/native/sidecar-services.js +2 -2
- package/dist/native/sidecar.js +68 -25
- package/dist/native/window-bootstrap.js +2 -2
- package/dist/release/feed-state.js +2 -1
- package/dist/release/framework-update-lock.d.ts +2 -0
- package/dist/release/framework-update-lock.js +42 -0
- package/dist/release/framework-update.d.ts +6 -2
- package/dist/release/framework-update.js +165 -40
- package/dist/release/local-release.js +68 -39
- package/dist/release/release-config.js +1 -1
- package/dist/release/release-steps.d.ts +5 -0
- package/dist/release/release-steps.js +2 -1
- package/dist/shared/discard-stream.d.ts +4 -0
- package/dist/shared/discard-stream.js +9 -0
- package/dist/shell/app-shell.js +59 -7
- package/dist/shell/app-utilities.js +2 -2
- package/dist/shell/application-menu.d.ts +13 -0
- package/dist/shell/application-menu.js +21 -8
- package/dist/update-helper.bundle.js +40 -4
- package/dist/updates/channel-update-manager.d.ts +2 -0
- package/dist/updates/channel-update-manager.js +15 -3
- package/dist/updates/desktop-updater.d.ts +2 -0
- package/dist/updates/desktop-updater.js +36 -7
- package/dist/updates/linux-process-state.d.ts +2 -0
- package/dist/updates/linux-process-state.js +13 -0
- package/dist/updates/release-location.js +5 -4
- package/dist/updates/update-adapter.js +5 -0
- package/dist/updates/update-arm.d.ts +2 -0
- package/dist/updates/update-arm.js +58 -7
- package/dist/updates/update-discovery.js +2 -1
- package/dist/updates/update-download-cleanup.d.ts +7 -0
- package/dist/updates/update-download-cleanup.js +21 -0
- package/dist/updates/update-download.js +41 -20
- package/dist/updates/update-exclusive-rename.d.ts +3 -2
- package/dist/updates/update-exclusive-rename.js +3 -50
- package/dist/updates/update-extraction.js +1 -1
- package/dist/updates/update-manager.d.ts +17 -1
- package/dist/updates/update-manager.js +27 -8
- package/dist/updates/update-process-fence.js +18 -3
- package/dist/views/appearance-surface.js +51 -15
- package/package.json +8 -3
- package/src/app/application.tsx +49 -7
- package/src/appearance/custom-theme-import.ts +67 -7
- package/src/appearance/custom-theme-library.ts +391 -33
- package/src/appearance/editor.ts +49 -10
- package/src/appearance/theme-file-importer.ts +43 -12
- package/src/appearance/theme-library-action-fence.ts +28 -0
- package/src/desktop/client-asset-stream.ts +118 -0
- package/src/desktop/client-assets.ts +55 -5
- package/src/shell/app-shell.tsx +71 -8
- package/src/shell/app-utilities.tsx +2 -2
- package/src/updates/update-adapter.ts +5 -0
- package/src/views/appearance-surface.tsx +61 -29
- package/templates/application/README.md +5 -1
- package/templates/application/scripts/app-version.ts +7 -3
- package/templates/application/src/bun/index.ts +2 -0
|
@@ -1,11 +1,55 @@
|
|
|
1
1
|
import { createRendererProfile } from "../native/renderer-profile.js";
|
|
2
|
+
import { renameExclusive } from "../native/exclusive-rename.js";
|
|
2
3
|
import { containsAsciiControl } from "../desktop/string-policy.js";
|
|
3
4
|
import { assertPortableAppName } from "../installer/installer-layout.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
5
|
+
import { isPrivateGroup, readAccountDatabase } from "./private-group.js";
|
|
6
|
+
import { cp, lstat, mkdtemp, readFile, readdir, rm, stat, writeFile } from "node:fs/promises";
|
|
7
|
+
import { dirname, join, resolve } from "node:path";
|
|
6
8
|
// src/app/create-application.ts
|
|
9
|
+
async function exists(path) {
|
|
10
|
+
try {
|
|
11
|
+
await lstat(path);
|
|
12
|
+
return true;
|
|
13
|
+
} catch (error) {
|
|
14
|
+
if (error.code === "ENOENT") return false;
|
|
15
|
+
throw error;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Publication assumes nobody but this user (and root) can rename or remove entries in
|
|
20
|
+
* the destination's parent. That holds when the parent is owned by this user or root
|
|
21
|
+
* and is either sticky or writable only by its owner and a group private to this user.
|
|
22
|
+
* Under that assumption nobody else can swap the private staging directory between its
|
|
23
|
+
* identity check and its removal, so cleanup cannot be redirected. A parent that breaks
|
|
24
|
+
* the assumption, including a group-writable parent whose group cannot be proven
|
|
25
|
+
* private, is rejected before anything is created.
|
|
26
|
+
*/
|
|
27
|
+
async function assertTrustedParent(parent, readAccounts) {
|
|
28
|
+
const info = await stat(parent);
|
|
29
|
+
if (!info.isDirectory()) throw new Error("Application destination parent is not a directory");
|
|
30
|
+
if (process.platform === "win32") return;
|
|
31
|
+
const uid = process.getuid?.();
|
|
32
|
+
if (uid !== void 0 && info.uid !== uid && info.uid !== 0) throw new Error("Application destination parent is owned by another user");
|
|
33
|
+
if ((info.mode & 512) !== 0) return;
|
|
34
|
+
if ((info.mode & 2) !== 0) throw new Error("Application destination parent is writable by other users");
|
|
35
|
+
if ((info.mode & 16) === 0) return;
|
|
36
|
+
const accounts = await readAccounts();
|
|
37
|
+
if (uid === void 0 || !accounts || !isPrivateGroup(info.gid, uid, accounts)) throw new Error("Application destination parent is writable by a shared group");
|
|
38
|
+
}
|
|
39
|
+
/** Remove the staging directory only while it is still the one this run created. */
|
|
40
|
+
async function removeOwnedStaging(staging, identity, remove) {
|
|
41
|
+
let info;
|
|
42
|
+
try {
|
|
43
|
+
info = await lstat(staging);
|
|
44
|
+
} catch (error) {
|
|
45
|
+
if (error.code === "ENOENT") return;
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
if (!info.isDirectory() || info.dev !== identity.dev || info.ino !== identity.ino) throw new Error("Application staging directory was replaced; it was not removed");
|
|
49
|
+
await remove(staging);
|
|
50
|
+
}
|
|
7
51
|
/** Generate a new app without replacing an existing directory. */
|
|
8
|
-
async function createApplication(options) {
|
|
52
|
+
async function createApplication(options, dependencies = {}) {
|
|
9
53
|
if (typeof options.directory !== "string" || !options.directory.trim() || !/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(options.slug) || options.slug.length > 64 || typeof options.name !== "string" || !options.name.trim() || options.name.length > 80 || containsAsciiControl(options.name) || !/^[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*){1,}$/.test(options.identifier) || typeof options.frameworkSpecifier !== "string" || !options.frameworkSpecifier.trim()) throw new Error("Invalid application identity or framework dependency");
|
|
10
54
|
assertPortableAppName(options.name);
|
|
11
55
|
let source;
|
|
@@ -32,147 +76,174 @@ async function createApplication(options) {
|
|
|
32
76
|
const frameworkVersion = frameworkManifest.version;
|
|
33
77
|
if (typeof frameworkVersion !== "string" || !/^\d+\.\d+\.\d+$/.test(frameworkVersion)) throw new Error("Framework version is unavailable");
|
|
34
78
|
const directory = resolve(options.directory);
|
|
35
|
-
await
|
|
36
|
-
|
|
37
|
-
|
|
79
|
+
if (await exists(directory)) throw new Error("Application destination already exists");
|
|
80
|
+
await assertTrustedParent(dirname(directory), dependencies.readAccounts ?? readAccountDatabase);
|
|
81
|
+
const staging = await mkdtemp(join(dirname(directory), ".framework-app-"));
|
|
82
|
+
const created = await lstat(staging);
|
|
83
|
+
const identity = {
|
|
84
|
+
dev: created.dev,
|
|
85
|
+
ino: created.ino
|
|
86
|
+
};
|
|
87
|
+
const removeDirectory = dependencies.removeDirectory ?? ((path) => rm(path, {
|
|
38
88
|
recursive: true,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
89
|
+
force: true
|
|
90
|
+
}));
|
|
91
|
+
try {
|
|
92
|
+
const template = resolve(dependencies.templateDirectory ?? resolve(import.meta.dir, "../../templates/application"));
|
|
93
|
+
for (const entry of await readdir(template)) await cp(resolve(template, entry), resolve(staging, entry), {
|
|
94
|
+
recursive: true,
|
|
95
|
+
errorOnExist: true,
|
|
96
|
+
force: false
|
|
97
|
+
});
|
|
98
|
+
for (const name of [
|
|
99
|
+
"release.yml",
|
|
100
|
+
"release-assets.yml",
|
|
101
|
+
"release-finalize.yml"
|
|
102
|
+
]) {
|
|
103
|
+
const path = resolve(staging, ".github/workflows", name);
|
|
104
|
+
const workflow = await readFile(path, "utf8");
|
|
105
|
+
await writeFile(path, workflow.replaceAll("{{FRAMEWORK_REF}}", `v${frameworkVersion}`).replaceAll("{{RENDERER}}", renderer));
|
|
106
|
+
}
|
|
107
|
+
const config = {
|
|
108
|
+
slug: options.slug,
|
|
109
|
+
name: options.name,
|
|
110
|
+
identifier: options.identifier,
|
|
111
|
+
sourceUrl: source.href,
|
|
112
|
+
version: "0.1.0",
|
|
113
|
+
renderer,
|
|
114
|
+
initialPort: null,
|
|
115
|
+
urlSchemes: []
|
|
116
|
+
};
|
|
117
|
+
const configEntries = Object.entries(config).map(([key, value]) => {
|
|
118
|
+
const json = JSON.stringify(value);
|
|
119
|
+
return ` ${key}: ${typeof value !== "string" || value.includes("'") ? json : `'${json.slice(1, -1).replace(/\\"/g, "\"")}'`},`;
|
|
120
|
+
}).join("\n");
|
|
121
|
+
await writeFile(resolve(staging, "src/app-config.ts"), `export const appConfig = {\n${configEntries}\n} as const\n`);
|
|
122
|
+
const manifest = {
|
|
123
|
+
name: options.slug,
|
|
124
|
+
version: "0.1.0",
|
|
125
|
+
private: true,
|
|
126
|
+
type: "module",
|
|
127
|
+
packageManager: "bun@1.4.4",
|
|
128
|
+
scripts: {
|
|
129
|
+
format: "oxfmt src scripts tests vite.config.ts electrobun.config.ts",
|
|
130
|
+
"format:check": "oxfmt --check src scripts tests vite.config.ts electrobun.config.ts",
|
|
131
|
+
"format:write": "oxfmt --write src scripts tests vite.config.ts electrobun.config.ts",
|
|
132
|
+
lint: "oxlint src scripts tests vite.config.ts electrobun.config.ts",
|
|
133
|
+
typecheck: "bun check -p tsconfig.json",
|
|
134
|
+
test: "bun test tests",
|
|
135
|
+
"dev:web": "vp dev --host 127.0.0.1",
|
|
136
|
+
"build:web": "vp build",
|
|
137
|
+
"build:desktop": "bun run build:web && bun scripts/build-desktop.ts dev",
|
|
138
|
+
"build:release": "bun run build:web && bun scripts/build-desktop.ts stable",
|
|
139
|
+
"release:cut": "bun node_modules/@adea-ai/app-framework/dist/cli/release-cut-cli.js",
|
|
140
|
+
"release:promote": "bun node_modules/@adea-ai/app-framework/dist/cli/release-promote-cli.js",
|
|
141
|
+
"release:finalize": "bun node_modules/@adea-ai/app-framework/dist/cli/release-finalize-cli.js",
|
|
142
|
+
"release:publish": "bun node_modules/@adea-ai/app-framework/dist/cli/release-publish-cli.js",
|
|
143
|
+
"release:stage": "bun scripts/stage-release.ts",
|
|
144
|
+
"release:stage-build": "bun node_modules/@adea-ai/app-framework/dist/cli/release-step-cli.js stage-build",
|
|
145
|
+
"release:inspect": "bun node_modules/@adea-ai/app-framework/dist/cli/release-step-cli.js inspect",
|
|
146
|
+
"release:plan": "bun node_modules/@adea-ai/app-framework/dist/cli/release-assets-plan-cli.js",
|
|
147
|
+
"release:sign-descriptors": "bun node_modules/@adea-ai/app-framework/dist/cli/release-descriptor-staging-cli.js",
|
|
148
|
+
"release:qualify": "bun node_modules/@adea-ai/app-framework/dist/cli/release-step-cli.js qualify",
|
|
149
|
+
"release:qualify-upgrade": "bun node_modules/@adea-ai/app-framework/dist/cli/release-step-cli.js qualify-upgrade",
|
|
150
|
+
"release:select-retained": "bun node_modules/@adea-ai/app-framework/dist/cli/release-step-cli.js select-retained"
|
|
151
|
+
},
|
|
152
|
+
dependencies: {
|
|
153
|
+
"@adea-ai/app-framework": options.frameworkSpecifier,
|
|
154
|
+
"@adea-ai/ui": uiVersion,
|
|
155
|
+
"lucide-solid": "^1.51.0",
|
|
156
|
+
"solid-js": "1.9.15"
|
|
157
|
+
},
|
|
158
|
+
devDependencies: {
|
|
159
|
+
"@shadcn/lint": "^0.2.0",
|
|
160
|
+
oxlint: "^1.86.0",
|
|
161
|
+
oxfmt: "^0.71.0",
|
|
162
|
+
"@tailwindcss/vite": "^4.3.3",
|
|
163
|
+
tailwindcss: "^4.3.3",
|
|
164
|
+
vite: "npm:@voidzero-dev/vite-plus-core@1.4.0",
|
|
165
|
+
"vite-plus": "1.4.0",
|
|
166
|
+
"vite-plugin-solid": "2.11.14",
|
|
167
|
+
electrobun: "2.0.5",
|
|
168
|
+
typescript: "^7.0.2",
|
|
169
|
+
"@types/bun": "^1.4.4"
|
|
170
|
+
},
|
|
171
|
+
overrides: { vite: "npm:@voidzero-dev/vite-plus-core@1.4.0" }
|
|
172
|
+
};
|
|
173
|
+
await writeFile(resolve(staging, "package.json"), JSON.stringify(manifest, null, 2) + "\n");
|
|
174
|
+
const platforms = {
|
|
175
|
+
"macos-arm64": [`${options.slug}-{tag}-macos-arm64.dmg`, `${options.slug}-{tag}-macos-arm64.tar.zst`],
|
|
176
|
+
"windows-x64": [`${options.slug}-{tag}-windows-x64-Setup.zip`, `${options.slug}-{tag}-windows-x64.tar.zst`],
|
|
177
|
+
"linux-x64": [`${options.slug}-{tag}-linux-x64-Setup.tar.gz`, `${options.slug}-{tag}-linux-x64.tar.zst`]
|
|
178
|
+
};
|
|
179
|
+
const devDiscoveryAssets = Object.keys(platforms).map((platform) => `dev-${platform}.json`);
|
|
180
|
+
const dailyDiscoveryAssets = Object.keys(platforms).map((platform) => `daily-${platform}.json`);
|
|
181
|
+
const stableDiscoveryAssets = Object.keys(platforms).map((platform) => `stable-${platform}.json`);
|
|
182
|
+
const releaseAssets = [
|
|
183
|
+
...dailyDiscoveryAssets,
|
|
184
|
+
...stableDiscoveryAssets,
|
|
185
|
+
...devDiscoveryAssets
|
|
186
|
+
];
|
|
187
|
+
const targets = {
|
|
188
|
+
"macos-arm64": ["darwin", "arm64"],
|
|
189
|
+
"windows-x64": ["win32", "x64"],
|
|
190
|
+
"linux-x64": ["linux", "x64"]
|
|
191
|
+
};
|
|
192
|
+
const descriptors = Object.fromEntries([
|
|
193
|
+
"dev",
|
|
194
|
+
"daily",
|
|
195
|
+
"stable"
|
|
196
|
+
].flatMap((channel) => Object.entries(targets).map(([platform, [os, arch]]) => [`${channel}-${platform}.json`, {
|
|
197
|
+
channel,
|
|
198
|
+
platform: os,
|
|
199
|
+
arch,
|
|
200
|
+
allowedPayloads: [platforms[platform][1]]
|
|
201
|
+
}])));
|
|
202
|
+
await writeFile(resolve(staging, "release-config.json"), JSON.stringify({
|
|
203
|
+
appName: options.name,
|
|
204
|
+
appId: options.identifier,
|
|
205
|
+
soakHours: 96,
|
|
206
|
+
versionSource: {
|
|
207
|
+
kind: "source-manifest",
|
|
208
|
+
path: "package.json"
|
|
209
|
+
},
|
|
210
|
+
releaseWorkflows: {
|
|
211
|
+
control: ".github/workflows/release.yml",
|
|
212
|
+
assets: ".github/workflows/release-assets.yml"
|
|
213
|
+
},
|
|
214
|
+
releaseFeed: {
|
|
215
|
+
base: "https://adea.dev/releases/",
|
|
216
|
+
app: options.slug
|
|
217
|
+
},
|
|
218
|
+
offlinePolicy: {
|
|
219
|
+
kind: "standalone",
|
|
220
|
+
marker: `Welcome to ${options.name}.`
|
|
221
|
+
},
|
|
222
|
+
offlineExpectedReads: [],
|
|
223
|
+
platforms,
|
|
224
|
+
releaseAssets,
|
|
225
|
+
dailyDiscoveryAssets,
|
|
226
|
+
stableDiscoveryAssets,
|
|
227
|
+
devDiscoveryAssets,
|
|
228
|
+
releaseSigningKeys: {},
|
|
229
|
+
descriptors
|
|
230
|
+
}, null, 2) + "\n");
|
|
231
|
+
await writeFile(resolve(staging, ".gitignore"), "node_modules/\nbuild/\nartifacts/\n.hutch/\n.cottontail-tmp/\n.env\n.env.*\n!.env.example\n");
|
|
232
|
+
await dependencies.beforePublish?.(staging);
|
|
233
|
+
try {
|
|
234
|
+
renameExclusive(staging, directory);
|
|
235
|
+
} catch (error) {
|
|
236
|
+
if (await exists(directory)) throw new Error("Application destination already exists", { cause: error });
|
|
237
|
+
throw error;
|
|
238
|
+
}
|
|
239
|
+
return { directory };
|
|
240
|
+
} catch (error) {
|
|
241
|
+
try {
|
|
242
|
+
await removeOwnedStaging(staging, identity, removeDirectory);
|
|
243
|
+
} catch (cleanupError) {
|
|
244
|
+
throw new AggregateError([error, cleanupError], "Application generation failed and staging cleanup did not complete", { cause: error });
|
|
245
|
+
}
|
|
246
|
+
throw error;
|
|
50
247
|
}
|
|
51
|
-
const config = {
|
|
52
|
-
slug: options.slug,
|
|
53
|
-
name: options.name,
|
|
54
|
-
identifier: options.identifier,
|
|
55
|
-
sourceUrl: source.href,
|
|
56
|
-
version: "0.1.0",
|
|
57
|
-
renderer,
|
|
58
|
-
initialPort: null,
|
|
59
|
-
urlSchemes: []
|
|
60
|
-
};
|
|
61
|
-
const configEntries = Object.entries(config).map(([key, value]) => {
|
|
62
|
-
const json = JSON.stringify(value);
|
|
63
|
-
return ` ${key}: ${typeof value !== "string" || value.includes("'") ? json : `'${json.slice(1, -1).replace(/\\"/g, "\"")}'`},`;
|
|
64
|
-
}).join("\n");
|
|
65
|
-
await writeFile(resolve(directory, "src/app-config.ts"), `export const appConfig = {\n${configEntries}\n} as const\n`);
|
|
66
|
-
const manifest = {
|
|
67
|
-
name: options.slug,
|
|
68
|
-
version: "0.1.0",
|
|
69
|
-
private: true,
|
|
70
|
-
type: "module",
|
|
71
|
-
packageManager: "bun@1.4.4",
|
|
72
|
-
scripts: {
|
|
73
|
-
format: "oxfmt src scripts tests vite.config.ts electrobun.config.ts",
|
|
74
|
-
"format:check": "oxfmt --check src scripts tests vite.config.ts electrobun.config.ts",
|
|
75
|
-
"format:write": "oxfmt --write src scripts tests vite.config.ts electrobun.config.ts",
|
|
76
|
-
lint: "oxlint src scripts tests vite.config.ts electrobun.config.ts",
|
|
77
|
-
typecheck: "bun check -p tsconfig.json",
|
|
78
|
-
test: "bun test tests",
|
|
79
|
-
"dev:web": "vp dev --host 127.0.0.1",
|
|
80
|
-
"build:web": "vp build",
|
|
81
|
-
"build:desktop": "bun run build:web && bun scripts/build-desktop.ts dev",
|
|
82
|
-
"build:release": "bun run build:web && bun scripts/build-desktop.ts stable",
|
|
83
|
-
"release:cut": "bun node_modules/@adea-ai/app-framework/dist/cli/release-cut-cli.js",
|
|
84
|
-
"release:promote": "bun node_modules/@adea-ai/app-framework/dist/cli/release-promote-cli.js",
|
|
85
|
-
"release:finalize": "bun node_modules/@adea-ai/app-framework/dist/cli/release-finalize-cli.js",
|
|
86
|
-
"release:publish": "bun node_modules/@adea-ai/app-framework/dist/cli/release-publish-cli.js",
|
|
87
|
-
"release:stage": "bun scripts/stage-release.ts",
|
|
88
|
-
"release:stage-build": "bun node_modules/@adea-ai/app-framework/dist/cli/release-step-cli.js stage-build",
|
|
89
|
-
"release:inspect": "bun node_modules/@adea-ai/app-framework/dist/cli/release-step-cli.js inspect",
|
|
90
|
-
"release:plan": "bun node_modules/@adea-ai/app-framework/dist/cli/release-assets-plan-cli.js",
|
|
91
|
-
"release:sign-descriptors": "bun node_modules/@adea-ai/app-framework/dist/cli/release-descriptor-staging-cli.js",
|
|
92
|
-
"release:qualify": "bun node_modules/@adea-ai/app-framework/dist/cli/release-step-cli.js qualify",
|
|
93
|
-
"release:qualify-upgrade": "bun node_modules/@adea-ai/app-framework/dist/cli/release-step-cli.js qualify-upgrade",
|
|
94
|
-
"release:select-retained": "bun node_modules/@adea-ai/app-framework/dist/cli/release-step-cli.js select-retained"
|
|
95
|
-
},
|
|
96
|
-
dependencies: {
|
|
97
|
-
"@adea-ai/app-framework": options.frameworkSpecifier,
|
|
98
|
-
"@adea-ai/ui": uiVersion,
|
|
99
|
-
"lucide-solid": "^1.51.0",
|
|
100
|
-
"solid-js": "1.9.15"
|
|
101
|
-
},
|
|
102
|
-
devDependencies: {
|
|
103
|
-
"@shadcn/lint": "^0.2.0",
|
|
104
|
-
oxlint: "^1.86.0",
|
|
105
|
-
oxfmt: "^0.71.0",
|
|
106
|
-
"@tailwindcss/vite": "^4.3.3",
|
|
107
|
-
tailwindcss: "^4.3.3",
|
|
108
|
-
vite: "npm:@voidzero-dev/vite-plus-core@1.4.0",
|
|
109
|
-
"vite-plus": "1.4.0",
|
|
110
|
-
"vite-plugin-solid": "2.11.14",
|
|
111
|
-
electrobun: "2.0.5",
|
|
112
|
-
typescript: "^7.0.2",
|
|
113
|
-
"@types/bun": "^1.4.4"
|
|
114
|
-
},
|
|
115
|
-
overrides: { vite: "npm:@voidzero-dev/vite-plus-core@1.4.0" }
|
|
116
|
-
};
|
|
117
|
-
await writeFile(resolve(directory, "package.json"), JSON.stringify(manifest, null, 2) + "\n");
|
|
118
|
-
const platforms = {
|
|
119
|
-
"macos-arm64": [`${options.slug}-{tag}-macos-arm64.dmg`, `${options.slug}-{tag}-macos-arm64.tar.zst`],
|
|
120
|
-
"windows-x64": [`${options.slug}-{tag}-windows-x64-Setup.zip`, `${options.slug}-{tag}-windows-x64.tar.zst`],
|
|
121
|
-
"linux-x64": [`${options.slug}-{tag}-linux-x64-Setup.tar.gz`, `${options.slug}-{tag}-linux-x64.tar.zst`]
|
|
122
|
-
};
|
|
123
|
-
const devDiscoveryAssets = Object.keys(platforms).map((platform) => `dev-${platform}.json`);
|
|
124
|
-
const dailyDiscoveryAssets = Object.keys(platforms).map((platform) => `daily-${platform}.json`);
|
|
125
|
-
const stableDiscoveryAssets = Object.keys(platforms).map((platform) => `stable-${platform}.json`);
|
|
126
|
-
const releaseAssets = [
|
|
127
|
-
...dailyDiscoveryAssets,
|
|
128
|
-
...stableDiscoveryAssets,
|
|
129
|
-
...devDiscoveryAssets
|
|
130
|
-
];
|
|
131
|
-
const targets = {
|
|
132
|
-
"macos-arm64": ["darwin", "arm64"],
|
|
133
|
-
"windows-x64": ["win32", "x64"],
|
|
134
|
-
"linux-x64": ["linux", "x64"]
|
|
135
|
-
};
|
|
136
|
-
const descriptors = Object.fromEntries([
|
|
137
|
-
"dev",
|
|
138
|
-
"daily",
|
|
139
|
-
"stable"
|
|
140
|
-
].flatMap((channel) => Object.entries(targets).map(([platform, [os, arch]]) => [`${channel}-${platform}.json`, {
|
|
141
|
-
channel,
|
|
142
|
-
platform: os,
|
|
143
|
-
arch,
|
|
144
|
-
allowedPayloads: [platforms[platform][1]]
|
|
145
|
-
}])));
|
|
146
|
-
await writeFile(resolve(directory, "release-config.json"), JSON.stringify({
|
|
147
|
-
appName: options.name,
|
|
148
|
-
appId: options.identifier,
|
|
149
|
-
soakHours: 96,
|
|
150
|
-
versionSource: {
|
|
151
|
-
kind: "source-manifest",
|
|
152
|
-
path: "package.json"
|
|
153
|
-
},
|
|
154
|
-
releaseWorkflows: {
|
|
155
|
-
control: ".github/workflows/release.yml",
|
|
156
|
-
assets: ".github/workflows/release-assets.yml"
|
|
157
|
-
},
|
|
158
|
-
releaseFeed: {
|
|
159
|
-
base: "https://adea.dev/releases/",
|
|
160
|
-
app: options.slug
|
|
161
|
-
},
|
|
162
|
-
offlinePolicy: {
|
|
163
|
-
kind: "standalone",
|
|
164
|
-
marker: `Welcome to ${options.name}.`
|
|
165
|
-
},
|
|
166
|
-
offlineExpectedReads: [],
|
|
167
|
-
platforms,
|
|
168
|
-
releaseAssets,
|
|
169
|
-
dailyDiscoveryAssets,
|
|
170
|
-
stableDiscoveryAssets,
|
|
171
|
-
devDiscoveryAssets,
|
|
172
|
-
releaseSigningKeys: {},
|
|
173
|
-
descriptors
|
|
174
|
-
}, null, 2) + "\n");
|
|
175
|
-
await writeFile(resolve(directory, ".gitignore"), "node_modules/\nbuild/\nartifacts/\n.hutch/\n.cottontail-tmp/\n.env\n.env.*\n!.env.example\n");
|
|
176
|
-
return { directory };
|
|
177
248
|
}
|
|
178
249
|
export { createApplication };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Account database text used to prove that a group has no member other than one user. */
|
|
2
|
+
export interface AccountDatabase {
|
|
3
|
+
passwd: string;
|
|
4
|
+
group: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Whether `gid` is provably private to `uid`: the group is listed, no other account
|
|
8
|
+
* names it as a primary group, and its supplementary members are at most that user.
|
|
9
|
+
* Anything that cannot be proven, such as a group served only by a directory service
|
|
10
|
+
* or a database entry that does not parse, is treated as shared.
|
|
11
|
+
*/
|
|
12
|
+
export declare function isPrivateGroup(gid: number, uid: number, accounts: AccountDatabase): boolean;
|
|
13
|
+
/** Read the local account database; a platform without one proves nothing private. */
|
|
14
|
+
export declare function readAccountDatabase(): Promise<AccountDatabase | undefined>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
// src/app/private-group.ts
|
|
3
|
+
function records(text) {
|
|
4
|
+
return text.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#")).map((line) => line.split(":"));
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Whether `gid` is provably private to `uid`: the group is listed, no other account
|
|
8
|
+
* names it as a primary group, and its supplementary members are at most that user.
|
|
9
|
+
* Anything that cannot be proven, such as a group served only by a directory service
|
|
10
|
+
* or a database entry that does not parse, is treated as shared.
|
|
11
|
+
*/
|
|
12
|
+
function isPrivateGroup(gid, uid, accounts) {
|
|
13
|
+
const users = records(accounts.passwd);
|
|
14
|
+
const id = /^\d+$/;
|
|
15
|
+
if (users.some((fields) => fields.length < 7 || fields[0].startsWith("+") || !id.test(fields[2]) || !id.test(fields[3]))) return false;
|
|
16
|
+
const self = users.filter((fields) => Number(fields[2]) === uid);
|
|
17
|
+
if (self.length !== 1) return false;
|
|
18
|
+
const name = self[0][0];
|
|
19
|
+
if (users.some((fields) => Number(fields[3]) === gid && Number(fields[2]) !== uid)) return false;
|
|
20
|
+
const groups = records(accounts.group);
|
|
21
|
+
if (groups.some((fields) => fields.length < 4 || fields[0].startsWith("+") || !id.test(fields[2]))) return false;
|
|
22
|
+
const entries = groups.filter((fields) => Number(fields[2]) === gid);
|
|
23
|
+
if (entries.length !== 1) return false;
|
|
24
|
+
return entries[0][3].split(",").map((member) => member.trim()).filter(Boolean).every((member) => member === name);
|
|
25
|
+
}
|
|
26
|
+
/** Read the local account database; a platform without one proves nothing private. */
|
|
27
|
+
async function readAccountDatabase() {
|
|
28
|
+
if (process.platform !== "linux") return void 0;
|
|
29
|
+
try {
|
|
30
|
+
const [passwd, group] = await Promise.all([readFile("/etc/passwd", "utf8"), readFile("/etc/group", "utf8")]);
|
|
31
|
+
return {
|
|
32
|
+
passwd,
|
|
33
|
+
group
|
|
34
|
+
};
|
|
35
|
+
} catch {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export { isPrivateGroup, readAccountDatabase };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/** The transport supplies a verified principal; this registry does not authenticate it. */
|
|
2
2
|
export type ServiceDefinition<Principal, Input, Output> = Readonly<{
|
|
3
3
|
parse(value: unknown): Input;
|
|
4
|
-
authorize(principal: Principal, input: Input): boolean | Promise<boolean>;
|
|
5
|
-
run(principal: Principal, input: Input): Output | Promise<Output>;
|
|
4
|
+
authorize(principal: Principal, input: Input, signal?: AbortSignal): boolean | Promise<boolean>;
|
|
5
|
+
run(principal: Principal, input: Input, signal?: AbortSignal): Output | Promise<Output>;
|
|
6
6
|
/** Largest invoke body the transport accepts for this service. Default 256 KiB, at most 16 MiB. */
|
|
7
7
|
maxBodyBytes?: number;
|
|
8
8
|
}>;
|
|
@@ -39,6 +39,10 @@ export declare function createServiceRegistry<Principal>(): {
|
|
|
39
39
|
* name the largest limit any registered service accepts, for reading before the name is known.
|
|
40
40
|
*/
|
|
41
41
|
maxBodyBytes(name?: string): number;
|
|
42
|
-
/**
|
|
43
|
-
|
|
42
|
+
/**
|
|
43
|
+
* `deadlineCheck` runs after parsing and before authorization so transports can detect a
|
|
44
|
+
* synchronous parse overrun. `current` separately rechecks channel and scope immediately
|
|
45
|
+
* before the handler starts.
|
|
46
|
+
*/
|
|
47
|
+
dispatch(name: string, value: unknown, principal: Principal, current?: () => boolean, signal?: AbortSignal, deadlineCheck?: () => boolean): Promise<ServiceResult>;
|
|
44
48
|
};
|
|
@@ -25,12 +25,18 @@ function createServiceRegistry() {
|
|
|
25
25
|
if (!/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/.test(name) || name.length > 128) throw new Error("Invalid service name");
|
|
26
26
|
if (entries.has(name)) throw new Error("Service already registered");
|
|
27
27
|
const { parse, authorize, run } = definition;
|
|
28
|
+
if (entries.has(name)) throw new Error("Service already registered");
|
|
28
29
|
if (typeof parse !== "function" || typeof authorize !== "function" || typeof run !== "function") throw new Error("Invalid service definition");
|
|
29
30
|
const maxBodyBytes = definition.maxBodyBytes ?? 262144;
|
|
31
|
+
if (entries.has(name)) throw new Error("Service already registered");
|
|
30
32
|
if (!Number.isSafeInteger(maxBodyBytes) || maxBodyBytes < 1 || maxBodyBytes > 16777216) throw new Error("Invalid service body limit");
|
|
31
33
|
const entry = {
|
|
32
34
|
maxBodyBytes,
|
|
33
|
-
async invoke(value, principal, current) {
|
|
35
|
+
async invoke(value, principal, current, signal, deadlineCheck) {
|
|
36
|
+
if (signal?.aborted) return {
|
|
37
|
+
ok: false,
|
|
38
|
+
code: "unauthorized"
|
|
39
|
+
};
|
|
34
40
|
let input;
|
|
35
41
|
try {
|
|
36
42
|
input = parse(value);
|
|
@@ -40,8 +46,27 @@ function createServiceRegistry() {
|
|
|
40
46
|
code: "invalid_input"
|
|
41
47
|
};
|
|
42
48
|
}
|
|
49
|
+
if (signal?.aborted) return {
|
|
50
|
+
ok: false,
|
|
51
|
+
code: "unauthorized"
|
|
52
|
+
};
|
|
53
|
+
try {
|
|
54
|
+
if (deadlineCheck && deadlineCheck() !== true) return {
|
|
55
|
+
ok: false,
|
|
56
|
+
code: "unauthorized"
|
|
57
|
+
};
|
|
58
|
+
} catch {
|
|
59
|
+
return {
|
|
60
|
+
ok: false,
|
|
61
|
+
code: "unauthorized"
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
if (signal?.aborted) return {
|
|
65
|
+
ok: false,
|
|
66
|
+
code: "unauthorized"
|
|
67
|
+
};
|
|
43
68
|
try {
|
|
44
|
-
if (await authorize(principal, input) !== true) return {
|
|
69
|
+
if (await authorize(principal, input, signal) !== true) return {
|
|
45
70
|
ok: false,
|
|
46
71
|
code: "unauthorized"
|
|
47
72
|
};
|
|
@@ -55,6 +80,10 @@ function createServiceRegistry() {
|
|
|
55
80
|
ok: false,
|
|
56
81
|
code: "unknown_service"
|
|
57
82
|
};
|
|
83
|
+
if (signal?.aborted) return {
|
|
84
|
+
ok: false,
|
|
85
|
+
code: "unauthorized"
|
|
86
|
+
};
|
|
58
87
|
try {
|
|
59
88
|
if (current && current() !== true) return {
|
|
60
89
|
ok: false,
|
|
@@ -66,10 +95,14 @@ function createServiceRegistry() {
|
|
|
66
95
|
code: "unauthorized"
|
|
67
96
|
};
|
|
68
97
|
}
|
|
98
|
+
if (signal?.aborted) return {
|
|
99
|
+
ok: false,
|
|
100
|
+
code: "unauthorized"
|
|
101
|
+
};
|
|
69
102
|
try {
|
|
70
103
|
return {
|
|
71
104
|
ok: true,
|
|
72
|
-
value: await run(principal, input)
|
|
105
|
+
value: await run(principal, input, signal)
|
|
73
106
|
};
|
|
74
107
|
} catch (error) {
|
|
75
108
|
if (!(error instanceof ServiceError)) return {
|
|
@@ -102,14 +135,18 @@ function createServiceRegistry() {
|
|
|
102
135
|
for (const entry of entries.values()) largest = Math.max(largest, entry.maxBodyBytes);
|
|
103
136
|
return largest;
|
|
104
137
|
},
|
|
105
|
-
/**
|
|
106
|
-
|
|
138
|
+
/**
|
|
139
|
+
* `deadlineCheck` runs after parsing and before authorization so transports can detect a
|
|
140
|
+
* synchronous parse overrun. `current` separately rechecks channel and scope immediately
|
|
141
|
+
* before the handler starts.
|
|
142
|
+
*/
|
|
143
|
+
async dispatch(name, value, principal, current, signal, deadlineCheck) {
|
|
107
144
|
const entry = entries.get(name);
|
|
108
145
|
if (!entry) return {
|
|
109
146
|
ok: false,
|
|
110
147
|
code: "unknown_service"
|
|
111
148
|
};
|
|
112
|
-
return entry.invoke(value, principal, current);
|
|
149
|
+
return entry.invoke(value, principal, current, signal, deadlineCheck);
|
|
113
150
|
}
|
|
114
151
|
};
|
|
115
152
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AppearanceStorage, type CustomThemeStored } from './custom-theme-library';
|
|
1
|
+
import { type AppearanceStorage, type CustomThemeStored, type ThemeLibraryMutationOptions } from './custom-theme-library';
|
|
2
2
|
export type CustomThemeImportResult = {
|
|
3
3
|
ok: true;
|
|
4
4
|
theme: CustomThemeStored;
|
|
@@ -6,9 +6,7 @@ export type CustomThemeImportResult = {
|
|
|
6
6
|
ok: false;
|
|
7
7
|
error: string;
|
|
8
8
|
};
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
*/
|
|
14
|
-
export declare function importCustomTheme(text: string, storage: AppearanceStorage | undefined, existing: readonly CustomThemeStored[]): CustomThemeImportResult;
|
|
9
|
+
/** Parse and add a theme using the latest snapshot inside the shared mutation lock. */
|
|
10
|
+
export declare function importCustomThemeAtomically(text: string, storage: AppearanceStorage | undefined, options?: ThemeLibraryMutationOptions & {
|
|
11
|
+
canCommit?: () => boolean;
|
|
12
|
+
}): Promise<CustomThemeImportResult>;
|