@astralyn/sash 0.1.0 → 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.
Files changed (108) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +22 -7
  3. package/THIRD_PARTY_NOTICES.md +9 -0
  4. package/dist/api.js +14 -45
  5. package/dist/app-state.js +99 -0
  6. package/dist/autostart/command.js +24 -0
  7. package/dist/autostart/context.js +43 -0
  8. package/dist/autostart/files.js +60 -0
  9. package/dist/autostart/installation.js +48 -0
  10. package/dist/autostart/start.js +47 -0
  11. package/dist/autostart/windows-registry.js +88 -0
  12. package/dist/autostart/windows.js +59 -0
  13. package/dist/autostart-contract.js +31 -0
  14. package/dist/autostart-entry.js +10 -0
  15. package/dist/autostart.js +69 -0
  16. package/dist/cli.js +11 -11
  17. package/dist/commands/auto.js +15 -0
  18. package/dist/commands/lifecycle.js +5 -31
  19. package/dist/commands/logs.js +11 -4
  20. package/dist/commands/shared.js +2 -4
  21. package/dist/commands/status.js +6 -7
  22. package/dist/commands/update.js +7 -3
  23. package/dist/commands/web.js +19 -27
  24. package/dist/contracts.js +171 -335
  25. package/dist/core-config-validation.js +22 -38
  26. package/dist/core-update.js +126 -762
  27. package/dist/core.js +20 -46
  28. package/dist/daemon/app.js +132 -113
  29. package/dist/daemon/context.js +13 -7
  30. package/dist/daemon/entry.js +21 -38
  31. package/dist/daemon/errors.js +6 -1
  32. package/dist/daemon/handlers/autostart.js +18 -0
  33. package/dist/daemon/handlers/core.js +32 -9
  34. package/dist/daemon/handlers/daemon.js +32 -6
  35. package/dist/daemon/handlers/profiles.js +12 -2
  36. package/dist/daemon/handlers/settings.js +9 -36
  37. package/dist/daemon/router.js +40 -27
  38. package/dist/daemon/scheduler.js +3 -1
  39. package/dist/daemon/server.js +6 -3
  40. package/dist/daemon/web-auth.js +52 -0
  41. package/dist/daemon-auth.js +2 -2
  42. package/dist/daemon-client.js +18 -2
  43. package/dist/daemon-http.js +7 -0
  44. package/dist/daemon-lifecycle.js +19 -196
  45. package/dist/github.js +7 -2
  46. package/dist/http.js +7 -5
  47. package/dist/log-follow.js +2 -1
  48. package/dist/mihomo-config.js +7 -9
  49. package/dist/paths.js +5 -7
  50. package/dist/profile-model.js +87 -0
  51. package/dist/profile-service.js +250 -587
  52. package/dist/profiles.js +43 -171
  53. package/dist/runtime-lifecycle.js +112 -194
  54. package/dist/runtime-owner.js +37 -76
  55. package/dist/sash-client.js +63 -21
  56. package/dist/settings-service.js +29 -228
  57. package/dist/settings.js +61 -285
  58. package/dist/status.js +24 -40
  59. package/dist/supervisor.js +1 -14
  60. package/dist/sysproxy/common.js +5 -45
  61. package/dist/sysproxy/factory.js +24 -65
  62. package/dist/sysproxy/snapshot.js +24 -257
  63. package/dist/sysproxy.js +1 -4
  64. package/dist/system-proxy-manager.js +37 -35
  65. package/dist/ui/assets/{ConnectionsView-DNGmZBSU.js → ConnectionsView-BgXQM6Z4.js} +1 -1
  66. package/dist/ui/assets/{LogsView-fSiaxQ13.js → LogsView-2f542P8z.js} +1 -1
  67. package/dist/ui/assets/{PaginationFooter-B3kHzRfB.js → PaginationFooter-cj1tcZej.js} +1 -1
  68. package/dist/ui/assets/ProfileEditorDialog-C9M8uKZC.css +1 -0
  69. package/dist/ui/assets/ProfileEditorDialog-DD4y4GBC.js +14 -0
  70. package/dist/ui/assets/ProfilesView-BXU2DOA7.css +1 -0
  71. package/dist/ui/assets/ProfilesView-DNnzYIEY.js +7 -0
  72. package/dist/ui/assets/{RulesView-D9vZBiJ1.js → RulesView-CtKvlckZ.js} +1 -1
  73. package/dist/ui/assets/SettingsView-BaeKFF_N.js +1 -0
  74. package/dist/ui/assets/SettingsView-CWjIe05v.css +1 -0
  75. package/dist/ui/assets/{0be242294f7d791af850c6df38ac78a0-2cL6Ntwf.woff2 → e2a57555d97d0b02b45d9418eb6ee295-D9nhF3rM.woff2} +0 -0
  76. package/dist/ui/assets/index-CBInDvdJ.js +19 -0
  77. package/dist/ui/assets/index-mOLy7fkB.css +1 -0
  78. package/dist/ui/assets/{theme-BNq4FkXS.js → theme-D40MF8cQ.js} +1 -1
  79. package/dist/ui/index.html +2 -2
  80. package/dist/web-bootstrap.js +113 -0
  81. package/docs/architecture-proposal.md +109 -0
  82. package/docs/autostart.md +101 -0
  83. package/docs/backend.md +92 -216
  84. package/docs/frontend.md +61 -97
  85. package/docs/usage.md +88 -186
  86. package/package.json +10 -6
  87. package/dist/commands/upgrade.js +0 -43
  88. package/dist/core-install-transaction.js +0 -114
  89. package/dist/core-update-coordination.js +0 -105
  90. package/dist/core-update-service.js +0 -245
  91. package/dist/managed-state-transaction.js +0 -377
  92. package/dist/offline-mutation.js +0 -58
  93. package/dist/profile-migration.js +0 -101
  94. package/dist/runtime-recovery.js +0 -31
  95. package/dist/sysproxy/darwin.js +0 -287
  96. package/dist/sysproxy/gnome.js +0 -181
  97. package/dist/sysproxy/legacy.js +0 -58
  98. package/dist/tun-guidance.js +0 -11
  99. package/dist/ui/assets/CodeEditorModal-6m0TJWyF.css +0 -1
  100. package/dist/ui/assets/CodeEditorModal-CFEnWsyh.js +0 -14
  101. package/dist/ui/assets/ProfileEditorDialog-BydoZthX.js +0 -1
  102. package/dist/ui/assets/ProfilesView-Btc1DOxE.js +0 -2
  103. package/dist/ui/assets/ProfilesView-ByqdFNHN.css +0 -1
  104. package/dist/ui/assets/SettingsFileDialog-CNFEAVs4.js +0 -1
  105. package/dist/ui/assets/SettingsView-BlDhZkXQ.js +0 -2
  106. package/dist/ui/assets/SettingsView-CngS3vBM.css +0 -1
  107. package/dist/ui/assets/index-B61V60w_.js +0 -19
  108. package/dist/ui/assets/index-bkyxJG8J.css +0 -1
@@ -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
- }, (err, stdout, stderr) => {
15
- if (!err) {
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(err) {
24
- if (typeof err !== "object" || err === null)
25
- return String(err);
26
- const record = err;
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 validateCoreConfigFile(executable, configFile, layout, runner = defaultRunner) {
37
- if (!fs.existsSync(executable)) {
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 validateCoreConfigFile(executable, candidate, layout, runner);
44
+ await (options.runner ?? defaultRunner)(executable, ["-t", "-d", layout.root, "-f", candidate], options.signal);
45
+ options.signal?.throwIfAborted();
59
46
  }
60
- catch (err) {
61
- if (err instanceof Error && err.message.startsWith("Core rejected generated configuration:")) {
62
- throw err;
63
- }
64
- throw new Error(`Core rejected generated configuration: ${errorOutput(err)}`);
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
- }