@astralyn/sash 0.1.1 → 0.1.2
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/CHANGELOG.md +25 -0
- package/README.md +17 -5
- package/THIRD_PARTY_NOTICES.md +9 -0
- package/dist/api.js +14 -45
- package/dist/app-state.js +99 -0
- package/dist/autostart/command.js +24 -0
- package/dist/autostart/context.js +43 -0
- package/dist/autostart/files.js +60 -0
- package/dist/autostart/installation.js +48 -0
- package/dist/autostart/start.js +47 -0
- package/dist/autostart/windows-registry.js +88 -0
- package/dist/autostart/windows.js +59 -0
- package/dist/autostart-contract.js +31 -0
- package/dist/autostart-entry.js +10 -0
- package/dist/autostart.js +69 -0
- package/dist/cli.js +11 -11
- package/dist/commands/auto.js +15 -0
- package/dist/commands/lifecycle.js +5 -15
- package/dist/commands/logs.js +11 -4
- package/dist/commands/shared.js +2 -4
- package/dist/commands/status.js +5 -1
- package/dist/commands/update.js +7 -3
- package/dist/commands/web.js +14 -50
- package/dist/contracts.js +168 -348
- package/dist/core-config-validation.js +22 -38
- package/dist/core-update.js +126 -762
- package/dist/core.js +20 -46
- package/dist/daemon/app.js +129 -117
- package/dist/daemon/context.js +13 -7
- package/dist/daemon/entry.js +21 -38
- package/dist/daemon/errors.js +3 -0
- package/dist/daemon/handlers/autostart.js +18 -0
- package/dist/daemon/handlers/core.js +32 -9
- package/dist/daemon/handlers/daemon.js +17 -6
- package/dist/daemon/handlers/profiles.js +12 -2
- package/dist/daemon/handlers/settings.js +9 -36
- package/dist/daemon/router.js +26 -21
- package/dist/daemon/scheduler.js +3 -1
- package/dist/daemon/server.js +5 -2
- package/dist/daemon-client.js +13 -3
- package/dist/daemon-http.js +6 -0
- package/dist/daemon-lifecycle.js +19 -196
- package/dist/github.js +7 -2
- package/dist/http.js +7 -5
- package/dist/mihomo-config.js +2 -1
- package/dist/paths.js +5 -7
- package/dist/profile-model.js +87 -0
- package/dist/profile-service.js +250 -587
- package/dist/profiles.js +43 -171
- package/dist/runtime-lifecycle.js +112 -194
- package/dist/runtime-owner.js +37 -76
- package/dist/sash-client.js +40 -19
- package/dist/settings-service.js +29 -224
- package/dist/settings.js +61 -289
- package/dist/status.js +24 -16
- package/dist/supervisor.js +1 -14
- package/dist/sysproxy/common.js +5 -45
- package/dist/sysproxy/factory.js +24 -65
- package/dist/sysproxy/snapshot.js +24 -257
- package/dist/sysproxy.js +1 -4
- package/dist/system-proxy-manager.js +37 -35
- package/dist/ui/assets/{ConnectionsView-CfaOG2JV.js → ConnectionsView-BgXQM6Z4.js} +1 -1
- package/dist/ui/assets/{LogsView-BDiRATXN.js → LogsView-2f542P8z.js} +1 -1
- package/dist/ui/assets/{PaginationFooter-DTytr1iu.js → PaginationFooter-cj1tcZej.js} +1 -1
- package/dist/ui/assets/ProfileEditorDialog-C9M8uKZC.css +1 -0
- package/dist/ui/assets/ProfileEditorDialog-DD4y4GBC.js +14 -0
- package/dist/ui/assets/ProfilesView-BXU2DOA7.css +1 -0
- package/dist/ui/assets/ProfilesView-DNnzYIEY.js +7 -0
- package/dist/ui/assets/{RulesView-CjEyCN1A.js → RulesView-CtKvlckZ.js} +1 -1
- package/dist/ui/assets/SettingsView-BaeKFF_N.js +1 -0
- package/dist/ui/assets/SettingsView-CWjIe05v.css +1 -0
- package/dist/ui/assets/index-CBInDvdJ.js +19 -0
- package/dist/ui/assets/index-mOLy7fkB.css +1 -0
- package/dist/ui/assets/{theme-BwDBMsKO.js → theme-D40MF8cQ.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/docs/architecture-proposal.md +109 -0
- package/docs/autostart.md +101 -0
- package/docs/backend.md +92 -224
- package/docs/frontend.md +60 -106
- package/docs/usage.md +92 -164
- package/package.json +3 -3
- package/dist/commands/upgrade.js +0 -43
- package/dist/core-install-transaction.js +0 -114
- package/dist/core-update-coordination.js +0 -105
- package/dist/core-update-service.js +0 -245
- package/dist/managed-state-transaction.js +0 -375
- package/dist/offline-mutation.js +0 -58
- package/dist/profile-migration.js +0 -101
- package/dist/runtime-recovery.js +0 -31
- package/dist/sysproxy/darwin.js +0 -287
- package/dist/sysproxy/gnome.js +0 -181
- package/dist/sysproxy/legacy.js +0 -58
- package/dist/ui/assets/CodeEditorModal-6m0TJWyF.css +0 -1
- package/dist/ui/assets/CodeEditorModal-D1zn-jRS.js +0 -14
- package/dist/ui/assets/ProfileEditorDialog-CyyP6OF1.js +0 -1
- package/dist/ui/assets/ProfilesView-ByqdFNHN.css +0 -1
- package/dist/ui/assets/ProfilesView-hFa7-O72.js +0 -2
- package/dist/ui/assets/SettingsFileDialog-CjBSyH4K.js +0 -1
- package/dist/ui/assets/SettingsView-D5QvJId6.css +0 -1
- package/dist/ui/assets/SettingsView-DsRntRfn.js +0 -2
- package/dist/ui/assets/index-CxQTf_P9.css +0 -1
- package/dist/ui/assets/index-_mb4OfYp.js +0 -19
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { execFile } from "node:child_process";
|
|
2
|
+
import crypto from "node:crypto";
|
|
2
3
|
import fs from "node:fs";
|
|
3
4
|
import path from "node:path";
|
|
4
5
|
import { atomicWriteFileSync } from "./fs-atomic.js";
|
|
5
6
|
import { buildSanitizedEnv } from "./process.js";
|
|
6
|
-
function defaultRunner(executable, args) {
|
|
7
|
+
function defaultRunner(executable, args, signal) {
|
|
7
8
|
return new Promise((resolve, reject) => {
|
|
8
9
|
execFile(executable, args, {
|
|
9
10
|
encoding: "utf8",
|
|
@@ -11,19 +12,19 @@ function defaultRunner(executable, args) {
|
|
|
11
12
|
maxBuffer: 1024 * 1024,
|
|
12
13
|
timeout: 20_000,
|
|
13
14
|
windowsHide: true,
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
signal,
|
|
16
|
+
}, (error, stdout, stderr) => {
|
|
17
|
+
if (error)
|
|
18
|
+
reject(Object.assign(error, { stdout, stderr }));
|
|
19
|
+
else
|
|
16
20
|
resolve();
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
reject(Object.assign(err, { stdout, stderr }));
|
|
20
21
|
});
|
|
21
22
|
});
|
|
22
23
|
}
|
|
23
|
-
function errorOutput(
|
|
24
|
-
if (typeof
|
|
25
|
-
return String(
|
|
26
|
-
const record =
|
|
24
|
+
function errorOutput(error) {
|
|
25
|
+
if (typeof error !== "object" || error === null)
|
|
26
|
+
return String(error);
|
|
27
|
+
const record = error;
|
|
27
28
|
for (const value of [record.stderr, record.stdout, record.message]) {
|
|
28
29
|
const text = Buffer.isBuffer(value)
|
|
29
30
|
? value.toString("utf8").trim()
|
|
@@ -33,40 +34,23 @@ function errorOutput(err) {
|
|
|
33
34
|
}
|
|
34
35
|
return "unknown validation error";
|
|
35
36
|
}
|
|
36
|
-
export async function
|
|
37
|
-
|
|
37
|
+
export async function validateCoreConfig(executable, yaml, layout, options = {}) {
|
|
38
|
+
options.signal?.throwIfAborted();
|
|
39
|
+
if (!fs.existsSync(executable))
|
|
38
40
|
throw new Error(`Core executable is missing: ${executable}`);
|
|
39
|
-
}
|
|
40
|
-
if (!fs.existsSync(configFile)) {
|
|
41
|
-
throw new Error(`Core configuration is missing: ${configFile}`);
|
|
42
|
-
}
|
|
43
|
-
try {
|
|
44
|
-
await runner(executable, ["-t", "-d", layout.root, "-f", configFile]);
|
|
45
|
-
}
|
|
46
|
-
catch (err) {
|
|
47
|
-
throw new Error(`Core rejected generated configuration: ${errorOutput(err)}`);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
export async function validateCoreConfigTextWithExecutable(executable, yaml, layout, runner = defaultRunner) {
|
|
51
|
-
if (!fs.existsSync(executable)) {
|
|
52
|
-
throw new Error(`Core executable is missing: ${executable}`);
|
|
53
|
-
}
|
|
54
|
-
fs.mkdirSync(layout.tempDir, { recursive: true });
|
|
55
|
-
const candidate = path.join(layout.tempDir, `config-validate-${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2)}.yaml`);
|
|
41
|
+
const candidate = path.join(layout.tempDir, `config-validate-${crypto.randomUUID()}.yaml`);
|
|
56
42
|
try {
|
|
57
43
|
atomicWriteFileSync(candidate, yaml);
|
|
58
|
-
await
|
|
44
|
+
await (options.runner ?? defaultRunner)(executable, ["-t", "-d", layout.root, "-f", candidate], options.signal);
|
|
45
|
+
options.signal?.throwIfAborted();
|
|
59
46
|
}
|
|
60
|
-
catch (
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
47
|
+
catch (error) {
|
|
48
|
+
options.signal?.throwIfAborted();
|
|
49
|
+
throw new Error(`Core rejected generated configuration: ${errorOutput(error)}`, {
|
|
50
|
+
cause: error,
|
|
51
|
+
});
|
|
65
52
|
}
|
|
66
53
|
finally {
|
|
67
54
|
fs.rmSync(candidate, { force: true });
|
|
68
55
|
}
|
|
69
56
|
}
|
|
70
|
-
export function validateCoreConfigText(yaml, layout, runner = defaultRunner) {
|
|
71
|
-
return validateCoreConfigTextWithExecutable(layout.coreExe, yaml, layout, runner);
|
|
72
|
-
}
|