@adea-ai/app-framework 0.33.1 → 0.35.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.
Files changed (55) hide show
  1. package/README.md +30 -12
  2. package/ci/desktop-release.sh +203 -0
  3. package/dist/app/create-application.d.ts +2 -0
  4. package/dist/app/create-application.js +19 -5
  5. package/dist/cli/create-application-cli.js +6 -4
  6. package/dist/desktop/desktop-client.d.ts +5 -0
  7. package/dist/desktop/desktop-client.js +12 -3
  8. package/dist/framework-source.json +1 -1
  9. package/dist/installer/installer-upgrade-command.js +1 -1
  10. package/dist/native/app-bundle.d.ts +14 -2
  11. package/dist/native/app-bundle.js +18 -5
  12. package/dist/native/desktop-build.d.ts +63 -0
  13. package/dist/native/desktop-build.js +119 -0
  14. package/dist/native/native-utilities.d.ts +18 -0
  15. package/dist/native/native-utilities.js +22 -1
  16. package/dist/native/sidecar-services.d.ts +5 -0
  17. package/dist/native/sidecar-services.js +10 -4
  18. package/dist/release/local-release.js +1 -1
  19. package/dist/release/release-assets-plan.js +4 -2
  20. package/dist/release/release-config.d.ts +7 -1
  21. package/dist/release/release-config.js +17 -6
  22. package/dist/release/release-cut-command.js +4 -2
  23. package/dist/release/release-finalize.js +3 -3
  24. package/dist/release/release-promotion-command.js +2 -2
  25. package/dist/release/release-publish-command.js +2 -2
  26. package/dist/release/retained-release-build.js +2 -2
  27. package/dist/shell/app-utilities.d.ts +1 -0
  28. package/dist/shell/app-utilities.js +2 -1
  29. package/dist/shell/media-query.d.ts +8 -0
  30. package/dist/shell/media-query.js +51 -0
  31. package/dist/updates/desktop-updater.js +1 -1
  32. package/dist/updates/release-version.d.ts +11 -0
  33. package/dist/updates/release-version.js +23 -1
  34. package/dist/updates/update-adapter.d.ts +38 -1
  35. package/dist/updates/update-adapter.js +121 -1
  36. package/dist/updates/update-channel-store.js +1 -1
  37. package/dist/updates/update-discovery.js +1 -1
  38. package/dist/updates/update-handoff-plan.js +1 -1
  39. package/dist/updates/update-manager.js +1 -1
  40. package/dist/views/update-surface.js +2 -2
  41. package/package.json +29 -2
  42. package/src/native/electrobun-types.d.ts +87 -0
  43. package/src/shell/app-utilities.tsx +1 -0
  44. package/src/shell/media-query.ts +59 -0
  45. package/src/updates/release-version.ts +33 -0
  46. package/src/updates/update-adapter.ts +168 -1
  47. package/templates/application/.gitlab/desktop-release.yml +42 -0
  48. package/templates/application/.gitlab-ci.yml +9 -0
  49. package/templates/application/README.md +14 -3
  50. package/templates/application/electrobun.config.ts +6 -2
  51. package/templates/application/scripts/app-version.ts +2 -8
  52. package/templates/application/scripts/build-desktop.ts +9 -36
  53. package/templates/application/src/bun/index.ts +5 -16
  54. package/templates/application/tsconfig.json +1 -1
  55. package/templates/application/src/electrobun.d.ts +0 -27
@@ -0,0 +1,119 @@
1
+ import "./posix-launcher-build.js";
2
+ import { createMacosDmg } from "../release/macos-dmg.js";
3
+ import { join, resolve } from "node:path";
4
+ import { copyFileSync, mkdirSync } from "node:fs";
5
+ import { spawn, spawnSync } from "node:child_process";
6
+ import { fileURLToPath } from "node:url";
7
+ // src/native/desktop-build.ts
8
+ /** Validate a build script's arguments: exactly one of `dev` or `stable`. */
9
+ function parseDesktopBuildEnvironment(args) {
10
+ const [environment, ...extra] = args;
11
+ if (environment !== "dev" && environment !== "stable" || extra.length) throw new Error("Expected dev or stable build environment");
12
+ return environment;
13
+ }
14
+ /**
15
+ * The macOS signing identity for a build. Electrobun signs the whole stable payload (every
16
+ * nested Mach-O, then the bundle seal) only when it is given an identity. A stable macOS build
17
+ * with no Developer ID configured uses `-`, an ad-hoc seal, so the app never ships with a mix
18
+ * of signatures or without a bundle seal. An explicitly configured identity is kept.
19
+ */
20
+ function macosSigningEnv(env, platform, environment) {
21
+ if (platform !== "darwin" || environment !== "stable" || env.ELECTROBUN_DEVELOPER_ID?.trim()) return env;
22
+ return {
23
+ ...env,
24
+ ELECTROBUN_DEVELOPER_ID: "-"
25
+ };
26
+ }
27
+ /** Whether `electrobun.config.ts` should ask Electrobun to sign: only when an identity is set. */
28
+ var signsMacosBuild = (env) => Boolean(env.ELECTROBUN_DEVELOPER_ID?.trim());
29
+ var probeTarVersion = (env) => {
30
+ const result = spawnSync("tar", ["--version"], {
31
+ encoding: "utf8",
32
+ env,
33
+ stdio: [
34
+ "ignore",
35
+ "pipe",
36
+ "pipe"
37
+ ]
38
+ });
39
+ return result.status === 0 ? result.stdout : null;
40
+ };
41
+ /**
42
+ * The environment Electrobun's archive step needs. On Windows, GNU tar reads `C:\...` as a
43
+ * remote `host:path` unless it is given `--force-local`; bsdtar needs nothing. Other
44
+ * platforms are returned unchanged.
45
+ */
46
+ function tarEnv(env, platform = process.platform, probe = probeTarVersion) {
47
+ if (platform !== "win32") return env;
48
+ const version = probe(env);
49
+ if (version === null) throw new Error("A working tar executable is required");
50
+ return /GNU tar/i.test(version) ? {
51
+ ...env,
52
+ TAR_OPTIONS: "--force-local"
53
+ } : env;
54
+ }
55
+ /** The opt-in POSIX launch lease is built for stable macOS arm64 packages only. */
56
+ function assertPosixLaunchLeaseTarget(env, environment, platform, arch) {
57
+ if (env["ADEA_ENABLE_POSIX_LAUNCH_LEASE"] !== "1") return;
58
+ if (environment !== "stable" || platform !== "darwin" || arch !== "arm64") throw new Error("POSIX launch lease integration supports stable macOS arm64 builds only");
59
+ }
60
+ var runCommand = (command, options) => new Promise((done, reject) => {
61
+ const child = spawn(command[0], command.slice(1), {
62
+ cwd: options.cwd,
63
+ env: options.env,
64
+ stdio: "inherit"
65
+ });
66
+ child.once("error", reject);
67
+ child.once("exit", (code, signal) => done(signal ? 1 : code ?? 1));
68
+ });
69
+ /**
70
+ * Build the desktop app with Electrobun: check the launch-lease opt-in, give a stable macOS
71
+ * build its signing identity, fix tar on Windows, run `electrobun build`, then pack a stable
72
+ * macOS build into `artifacts/macos-<arch>-<App>.dmg`. Resolves the disk image path when one
73
+ * was made.
74
+ */
75
+ async function runElectrobunBuild(options) {
76
+ const { environment, appName } = options;
77
+ if (environment !== "dev" && environment !== "stable") throw new Error("Expected dev or stable build environment");
78
+ const cwd = resolve(options.cwd ?? process.cwd());
79
+ const platform = options.platform ?? process.platform;
80
+ const arch = options.arch ?? process.arch;
81
+ const base = options.env ?? process.env;
82
+ assertPosixLaunchLeaseTarget(base, environment, platform, arch);
83
+ const env = tarEnv(macosSigningEnv(base, platform, environment), platform, options.tarVersion);
84
+ if (await (options.run ?? runCommand)([
85
+ "node",
86
+ join(cwd, "node_modules", "electrobun", "bin", "electrobun.cjs"),
87
+ "build",
88
+ `--env=${environment}`
89
+ ], {
90
+ cwd,
91
+ env
92
+ }) !== 0) throw new Error("Desktop build failed");
93
+ if (environment !== "stable" || platform !== "darwin") return {};
94
+ const dmg = join(cwd, "artifacts", `macos-${arch}-${appName.replaceAll(" ", "")}.dmg`);
95
+ (options.createDmg ?? createMacosDmg)({
96
+ appName,
97
+ appPath: join(cwd, "build", `stable-macos-${arch}`, `${appName}.app`),
98
+ outputPath: dmg
99
+ });
100
+ return { dmg };
101
+ }
102
+ /** The framework's post-exit update helper, as the installed package resolves it. */
103
+ function updateHelperSource() {
104
+ return fileURLToPath(import.meta.resolve("@adea-ai/app-framework/update-helper.js"));
105
+ }
106
+ /**
107
+ * Copy the framework's update helper into `directory` (as `update-helper.js` by default) so
108
+ * Electrobun's `build.copy` can pack it. Resolves the helper through the package's exports
109
+ * rather than a `node_modules` path. Returns the staged file.
110
+ */
111
+ function stageUpdateHelper(directory, options = {}) {
112
+ const fileName = options.fileName ?? "update-helper.js";
113
+ if (!/^[A-Za-z0-9][A-Za-z0-9._-]*\.js$/.test(fileName)) throw new Error("Invalid update helper file name");
114
+ mkdirSync(directory, { recursive: true });
115
+ const destination = join(directory, fileName);
116
+ copyFileSync(options.source ?? updateHelperSource(), destination);
117
+ return destination;
118
+ }
119
+ export { assertPosixLaunchLeaseTarget, macosSigningEnv, parseDesktopBuildEnvironment, runElectrobunBuild, signsMacosBuild, stageUpdateHelper, tarEnv, updateHelperSource };
@@ -21,4 +21,22 @@ export declare function registerNativeUtilities<Principal>(options: {
21
21
  /** Optional open-file dialog, registered as `shell.pick-files` when supplied. */
22
22
  pickFiles?(request: PickFilesRequest): Promise<readonly string[]>;
23
23
  }): () => void;
24
+ /** The options Electrobun 2.0.5's `Utils.openFileDialog` accepts. */
25
+ export type ElectrobunOpenFileDialogOptions = {
26
+ startingFolder?: string;
27
+ allowedFileTypes?: string;
28
+ canChooseFiles?: boolean;
29
+ canChooseDirectory?: boolean;
30
+ allowsMultipleSelection?: boolean;
31
+ };
32
+ /**
33
+ * `pickFolder` and `pickFiles` for `registerNativeUtilities`, backed by Electrobun's
34
+ * `Utils.openFileDialog`: one directory for a folder, files filtered by extension otherwise.
35
+ */
36
+ export declare function electrobunFileDialogs(utils: {
37
+ openFileDialog(options?: ElectrobunOpenFileDialogOptions): Promise<string[]>;
38
+ }): {
39
+ pickFolder(startingFolder?: string): Promise<string[]>;
40
+ pickFiles(request: PickFilesRequest): Promise<string[]>;
41
+ };
24
42
  export {};
@@ -82,4 +82,25 @@ function registerNativeUtilities(options) {
82
82
  }
83
83
  return remove;
84
84
  }
85
- export { registerNativeUtilities };
85
+ /**
86
+ * `pickFolder` and `pickFiles` for `registerNativeUtilities`, backed by Electrobun's
87
+ * `Utils.openFileDialog`: one directory for a folder, files filtered by extension otherwise.
88
+ */
89
+ function electrobunFileDialogs(utils) {
90
+ return {
91
+ pickFolder: (startingFolder) => utils.openFileDialog({
92
+ ...startingFolder === void 0 ? {} : { startingFolder },
93
+ canChooseFiles: false,
94
+ canChooseDirectory: true,
95
+ allowsMultipleSelection: false
96
+ }),
97
+ pickFiles: ({ startingFolder, extensions, multiple }) => utils.openFileDialog({
98
+ ...startingFolder === void 0 ? {} : { startingFolder },
99
+ allowedFileTypes: extensions === void 0 ? "*" : extensions.join(","),
100
+ canChooseFiles: true,
101
+ canChooseDirectory: false,
102
+ allowsMultipleSelection: multiple
103
+ })
104
+ };
105
+ }
106
+ export { electrobunFileDialogs, registerNativeUtilities };
@@ -2,6 +2,11 @@ import { type createServiceRegistry } from '../app/service-registry';
2
2
  import type { Sidecar } from './sidecar';
3
3
  /** Accept a web caller's arguments: absent, null, or a plain object. */
4
4
  export declare function parseSidecarArgs(value: unknown): Record<string, unknown>;
5
+ /**
6
+ * A sidecar reply's value; a failure becomes a `ServiceError` carrying the failure reason as
7
+ * its code and the sidecar's readable message.
8
+ */
9
+ export declare function sidecarReplyValue(reply: Awaited<ReturnType<Sidecar['call']>>): unknown;
5
10
  /**
6
11
  * Register sidecar commands as framework services so the web side calls them
7
12
  * through the desktop client. A service named `${prefix}${command}` forwards its
@@ -11,6 +11,14 @@ function parseSidecarArgs(value) {
11
11
  return value;
12
12
  }
13
13
  /**
14
+ * A sidecar reply's value; a failure becomes a `ServiceError` carrying the failure reason as
15
+ * its code and the sidecar's readable message.
16
+ */
17
+ function sidecarReplyValue(reply) {
18
+ if (reply.ok) return reply.value;
19
+ throw new ServiceError(reply.reason, reply.error);
20
+ }
21
+ /**
14
22
  * Register sidecar commands as framework services so the web side calls them
15
23
  * through the desktop client. A service named `${prefix}${command}` forwards its
16
24
  * arguments to the sidecar command and returns the reply value. A sidecar
@@ -31,9 +39,7 @@ function registerSidecarServices(options) {
31
39
  parse: (value) => parse(command, value),
32
40
  authorize: (principal) => authorize(principal, command),
33
41
  async run(_principal, args, signal) {
34
- const reply = await sidecar.call(command, args, signal ? { signal } : void 0);
35
- if (reply.ok) return reply.value;
36
- throw new ServiceError(reply.reason, reply.error);
42
+ return sidecarReplyValue(await sidecar.call(command, args, signal ? { signal } : void 0));
37
43
  },
38
44
  ...options.maxBodyBytes === void 0 ? {} : { maxBodyBytes: options.maxBodyBytes }
39
45
  }));
@@ -43,4 +49,4 @@ function registerSidecarServices(options) {
43
49
  }
44
50
  return remove;
45
51
  }
46
- export { parseSidecarArgs, registerSidecarServices };
52
+ export { parseSidecarArgs, registerSidecarServices, sidecarReplyValue };
@@ -1,3 +1,4 @@
1
+ import { versionLessThan } from "../updates/release-version.js";
1
2
  import { errorCode, isGitSha, isRecord } from "../app/value-guards.js";
2
3
  import { renameExclusive } from "../native/native-rename.js";
3
4
  import { verifyReleaseDescriptor } from "../updates/signed-release.js";
@@ -5,7 +6,6 @@ import { feedAssetKey, feedChannelKey, feedIndexKey, feedReleaseKey, feedUrl, pa
5
6
  import { discoveryPolicies, parseReleaseConfig, platformPayloads, platformTargets } from "./release-config.js";
6
7
  import { cutRelease, nextDevVersion } from "./release-cut.js";
7
8
  import { resolveLocalProvenance } from "./local-provenance.js";
8
- import { versionLessThan } from "../updates/release-version.js";
9
9
  import { createFeedReleaseCutProvider } from "./feed-release-cut.js";
10
10
  import { ReleaseFeedSnapshotChanged, readFeedLedger, readFeedRelease, verifyFeedRelease } from "./feed-state.js";
11
11
  import { fileIdentity } from "./release-publication.js";
@@ -1,7 +1,7 @@
1
1
  import { isGitSha } from "../app/value-guards.js";
2
2
  import { githubCli, verifyWorkflowAttempt } from "./github-cli.js";
3
3
  import { isRepositorySlug } from "../updates/signed-release.js";
4
- import { parseReleaseConfig } from "./release-config.js";
4
+ import { hostedReleaseWorkflows, parseReleaseConfig } from "./release-config.js";
5
5
  import { createGitHubReleaseCutProvider } from "./github-release-cut.js";
6
6
  // src/release/release-assets-plan.ts
7
7
  /** GitHub reads need credentials but must not inherit release signing keys. */
@@ -37,7 +37,9 @@ async function planReleaseAssets(options) {
37
37
  const { env, config, tag } = options;
38
38
  if (env.GITHUB_ACTIONS !== "true" || env.GITHUB_REF !== "refs/heads/main" || env.GITHUB_EVENT_NAME !== "workflow_dispatch" || !isRepositorySlug(env.GITHUB_REPOSITORY ?? "") || !isGitSha(env.GITHUB_SHA) || !/^[1-9]\d{0,19}$/.test(env.GITHUB_RUN_ID ?? "") || !/^[1-9]\d{0,8}$/.test(env.GITHUB_RUN_ATTEMPT ?? "") || !/^v\d+\.\d+\.\d+(?:-dev\.\d+)?$/.test(tag) || tag.length > 65) throw new Error("Asset planning requires a trusted main workflow and valid tag");
39
39
  if (typeof config !== "object" || config === null || Array.isArray(config) || typeof config.appName !== "string") throw new Error("Invalid release configuration");
40
- const { requirements, releasePleaseManifestPath, releaseWorkflows } = parseReleaseConfig(config);
40
+ const parsed = parseReleaseConfig(config);
41
+ const { requirements, releasePleaseManifestPath } = parsed;
42
+ const releaseWorkflows = hostedReleaseWorkflows(parsed.releaseWorkflows);
41
43
  requirements(tag);
42
44
  const run = options.run ?? githubCli(releasePlanGitHubEnvironment(env));
43
45
  const repository = env.GITHUB_REPOSITORY, workflowSha = env.GITHUB_SHA;
@@ -34,6 +34,11 @@ export type ReleaseWorkflows = {
34
34
  control: string;
35
35
  assets: string;
36
36
  };
37
+ /**
38
+ * The caller workflows a GitHub-hosted release step verifies its run against. An app that releases
39
+ * only with the local release mode (a GitLab tag pipeline or a machine) names none.
40
+ */
41
+ export declare function hostedReleaseWorkflows(workflows: ReleaseWorkflows | undefined): ReleaseWorkflows;
37
42
  /** The file name GitHub's workflow APIs and `gh workflow run` address a workflow by. */
38
43
  export declare const workflowFile: (path: string) => string;
39
44
  /** Validate shared daily, dev and stable asset requirements. */
@@ -47,7 +52,8 @@ export declare function parseReleaseConfig(config: unknown): {
47
52
  releasePleaseManifestPath: string;
48
53
  /** Sidecar executables every packaged payload must contain. */
49
54
  sidecars: readonly string[];
50
- releaseWorkflows: ReleaseWorkflows;
55
+ /** GitHub Actions callers, when the app releases there; see `hostedReleaseWorkflows`. */
56
+ releaseWorkflows: ReleaseWorkflows | undefined;
51
57
  /** The HTTPS feed releases are published to and discovered from. */
52
58
  feed: ReleaseFeed;
53
59
  commandArtifacts: readonly CommandArtifactPolicy[];
@@ -38,6 +38,14 @@ function parseCommandArtifacts(value, platforms) {
38
38
  });
39
39
  }
40
40
  var workflowDirectory = ".github/workflows/";
41
+ /**
42
+ * The caller workflows a GitHub-hosted release step verifies its run against. An app that releases
43
+ * only with the local release mode (a GitLab tag pipeline or a machine) names none.
44
+ */
45
+ function hostedReleaseWorkflows(workflows) {
46
+ if (!workflows) throw new Error("Release configuration names no releaseWorkflows; release with --local");
47
+ return workflows;
48
+ }
41
49
  /** The file name GitHub's workflow APIs and `gh workflow run` address a workflow by. */
42
50
  var workflowFile = (path) => path.slice(18);
43
51
  var workflowPath = (value) => typeof value === "string" && value.length <= 200 && value.startsWith(workflowDirectory) && /^[A-Za-z0-9][A-Za-z0-9._-]*\.ya?ml$/.test(workflowFile(value));
@@ -45,11 +53,14 @@ var workflowPath = (value) => typeof value === "string" && value.length <= 200 &
45
53
  function parseReleaseConfig(config) {
46
54
  if (!isRecord(config) || !isRecord(config.platforms) || !strings(config.releaseAssets) || !strings(config.dailyDiscoveryAssets) || !strings(config.stableDiscoveryAssets) || !strings(config.devDiscoveryAssets) || !Number.isSafeInteger(config.soakHours) || Number(config.soakHours) < 0 || Number(config.soakHours) > 8760) throw new Error("Invalid release configuration");
47
55
  const workflows = config.releaseWorkflows;
48
- if (!isRecord(workflows) || Object.keys(workflows).length !== 2 || !workflowPath(workflows.control) || !workflowPath(workflows.assets) || workflows.control === workflows.assets) throw new Error("Invalid release workflows");
49
- const releaseWorkflows = {
50
- control: workflows.control,
51
- assets: workflows.assets
52
- };
56
+ let releaseWorkflows;
57
+ if (workflows !== void 0) {
58
+ if (!isRecord(workflows) || Object.keys(workflows).length !== 2 || !workflowPath(workflows.control) || !workflowPath(workflows.assets) || workflows.control === workflows.assets) throw new Error("Invalid release workflows");
59
+ releaseWorkflows = {
60
+ control: workflows.control,
61
+ assets: workflows.assets
62
+ };
63
+ }
53
64
  const feed = parseReleaseFeed(config.releaseFeed);
54
65
  let sidecars;
55
66
  try {
@@ -195,4 +206,4 @@ function discoveryPolicies(config, tag) {
195
206
  }
196
207
  return result;
197
208
  }
198
- export { discoveryPolicies, parseHistoryRewrite, parseReleaseConfig, platformPayloads, platformTargets, releaseAssetNames, workflowFile };
209
+ export { discoveryPolicies, hostedReleaseWorkflows, parseHistoryRewrite, parseReleaseConfig, platformPayloads, platformTargets, releaseAssetNames, workflowFile };
@@ -1,6 +1,6 @@
1
1
  import { isGitSha } from "../app/value-guards.js";
2
2
  import { githubCli, verifyWorkflowAttempt } from "./github-cli.js";
3
- import { parseReleaseConfig, workflowFile } from "./release-config.js";
3
+ import { hostedReleaseWorkflows, parseReleaseConfig, workflowFile } from "./release-config.js";
4
4
  import { createGitHubReleaseCutProvider } from "./github-release-cut.js";
5
5
  import { cutRelease } from "./release-cut.js";
6
6
  import { readSourceVersion } from "./local-provenance.js";
@@ -12,7 +12,9 @@ var execute = promisify(execFile);
12
12
  async function runReleaseCutCommand(options) {
13
13
  const { env, kind } = options;
14
14
  if (env.GITHUB_ACTIONS !== "true" || env.GITHUB_REF !== "refs/heads/main" || !env.GITHUB_REPOSITORY || !isGitSha(env.GITHUB_SHA) || !/^[1-9]\d{0,19}$/.test(env.GITHUB_RUN_ID ?? "") || !/^[1-9]\d{0,8}$/.test(env.GITHUB_RUN_ATTEMPT ?? "") || (kind === "daily" ? !["schedule", "workflow_dispatch"].includes(env.GITHUB_EVENT_NAME ?? "") : kind === "dev" ? !["push", "workflow_dispatch"].includes(env.GITHUB_EVENT_NAME ?? "") : true)) throw new Error("Release cut requires a trusted main workflow");
15
- const { requirements, versionSource, releasePleaseManifestPath, releaseWorkflows } = parseReleaseConfig(options.config);
15
+ const parsed = parseReleaseConfig(options.config);
16
+ const { requirements, versionSource, releasePleaseManifestPath } = parsed;
17
+ const releaseWorkflows = hostedReleaseWorkflows(parsed.releaseWorkflows);
16
18
  const run = options.run ?? githubCli();
17
19
  const git = options.git ?? (async (args) => (await execute("git", args, { maxBuffer: 1048576 })).stdout.trim());
18
20
  const repository = env.GITHUB_REPOSITORY;
@@ -3,7 +3,7 @@ import { githubCli } from "./github-cli.js";
3
3
  import { lookupRelease } from "./github-release-lookup.js";
4
4
  import { isRepositorySlug } from "../updates/signed-release.js";
5
5
  import { qualifyGitHubRelease } from "./github-release-qualification.js";
6
- import { parseReleaseConfig } from "./release-config.js";
6
+ import { hostedReleaseWorkflows, parseReleaseConfig } from "./release-config.js";
7
7
  import { createGitHubReleaseCutProvider } from "./github-release-cut.js";
8
8
  // src/release/release-finalize.ts
9
9
  /** Treat event payloads as hints; qualification independently checks the GitHub run. */
@@ -43,7 +43,7 @@ async function finalizeReleasePleaseDraft(options) {
43
43
  repository,
44
44
  appName: config.appName,
45
45
  requirements: parsed.requirements,
46
- assetsWorkflow: parsed.releaseWorkflows.assets,
46
+ assetsWorkflow: hostedReleaseWorkflows(parsed.releaseWorkflows).assets,
47
47
  releasePleaseManifestPath: parsed.releasePleaseManifestPath,
48
48
  run
49
49
  });
@@ -62,7 +62,7 @@ async function finalizeReleasePleaseDraft(options) {
62
62
  repository,
63
63
  tag,
64
64
  requirements,
65
- assetsWorkflow: parsed.releaseWorkflows.assets,
65
+ assetsWorkflow: hostedReleaseWorkflows(parsed.releaseWorkflows).assets,
66
66
  releasePleaseManifestPath: parsed.releasePleaseManifestPath,
67
67
  allowDraft: true,
68
68
  run
@@ -1,4 +1,4 @@
1
- import { parseReleaseConfig } from "./release-config.js";
1
+ import { hostedReleaseWorkflows, parseReleaseConfig } from "./release-config.js";
2
2
  import { promoteDailyRelease } from "./release-promotion.js";
3
3
  import { createGitHubPromotionProvider } from "./github-release-promotion.js";
4
4
  // src/release/release-promotion-command.ts
@@ -14,7 +14,7 @@ async function runPromotionCommand(options) {
14
14
  const provider = createGitHubPromotionProvider({
15
15
  repository: env.GITHUB_REPOSITORY,
16
16
  requirements,
17
- assetsWorkflow: releaseWorkflows.assets,
17
+ assetsWorkflow: hostedReleaseWorkflows(releaseWorkflows).assets,
18
18
  releasePleaseManifestPath,
19
19
  run: options.run
20
20
  });
@@ -2,7 +2,7 @@ import { isGitSha, isRecord } from "../app/value-guards.js";
2
2
  import { githubCli, verifyWorkflowAttempt } from "./github-cli.js";
3
3
  import { assertRepositorySlug } from "../updates/signed-release.js";
4
4
  import { feedUrl } from "../updates/release-feed.js";
5
- import { discoveryPolicies, parseReleaseConfig } from "./release-config.js";
5
+ import { discoveryPolicies, hostedReleaseWorkflows, parseReleaseConfig } from "./release-config.js";
6
6
  import { publishQualifiedRelease } from "./release-publication.js";
7
7
  import { commandReceiptName } from "../installer/command-qualification-command.js";
8
8
  import { createGitHubReleasePublisher } from "./github-release-publisher.js";
@@ -66,7 +66,7 @@ async function runReleasePublishCommand(options) {
66
66
  expected: {
67
67
  headSha: env.GITHUB_SHA,
68
68
  event: "workflow_dispatch",
69
- path: releaseWorkflows.assets
69
+ path: hostedReleaseWorkflows(releaseWorkflows).assets
70
70
  },
71
71
  mismatch: "Release-assets workflow provenance mismatch"
72
72
  });
@@ -1,7 +1,7 @@
1
1
  import { isGitSha, isRecord } from "../app/value-guards.js";
2
2
  import { githubCli } from "./github-cli.js";
3
3
  import { lookupRelease } from "./github-release-lookup.js";
4
- import { parseReleaseConfig, platformPayloads, workflowFile } from "./release-config.js";
4
+ import { hostedReleaseWorkflows, parseReleaseConfig, platformPayloads, workflowFile } from "./release-config.js";
5
5
  import { createGitHubReleaseCutProvider } from "./github-release-cut.js";
6
6
  import { planReleaseAssets, releasePlanGitHubEnvironment } from "./release-assets-plan.js";
7
7
  // src/release/retained-release-build.ts
@@ -27,7 +27,7 @@ async function selectRetainedReleaseBuild(options) {
27
27
  run
28
28
  });
29
29
  if (env.SOURCE_SHA !== plan.sourceSha) throw new Error("Retained build source mismatch");
30
- const parsed = parseReleaseConfig(config), assetsWorkflow = parsed.releaseWorkflows.assets, requirements = parsed.requirements(tag);
30
+ const parsed = parseReleaseConfig(config), assetsWorkflow = hostedReleaseWorkflows(parsed.releaseWorkflows).assets, requirements = parsed.requirements(tag);
31
31
  if (requirements.platforms[platform]?.length !== 2) throw new Error("Invalid platform requirements");
32
32
  const expected = platformPayloads(requirements, platform);
33
33
  const repository = env.GITHUB_REPOSITORY, base = `repos/${repository}`;
@@ -7,6 +7,7 @@ import { type ApplicationSettingsSection } from './settings-sections';
7
7
  import { type ShortcutPlatform } from './shortcut-platform';
8
8
  import { type UpdateChannelSource } from '../updates/update-adapter';
9
9
  export * from './shortcut-platform';
10
+ export { createMediaQuery, DEFAULT_NARROW_QUERY } from './media-query';
10
11
  export type ApplicationIdentity = Readonly<{
11
12
  name: string;
12
13
  icon: string;
@@ -3,6 +3,7 @@ import { detectShortcutPlatform, resolveShortcutPlatform, settingsShortcutLabel,
3
3
  import { matchesSettingsKeyshortcuts, parseSettingsKeyshortcuts } from "./settings-shortcuts.js";
4
4
  import { defineSettingsSections, settingsSectionFromHash } from "./settings-sections.js";
5
5
  import { browserUpdateAdapter } from "../updates/update-adapter.js";
6
+ import { DEFAULT_NARROW_QUERY, createMediaQuery } from "./media-query.js";
6
7
  import { createComponent, memo, mergeProps, template } from "solid-js/web";
7
8
  import { Show, Suspense, createEffect, createMemo, createSignal, lazy, on, onCleanup, onMount } from "solid-js";
8
9
  import { Palette } from "lucide-solid";
@@ -339,4 +340,4 @@ function ApplicationUtilities(props) {
339
340
  }
340
341
  })];
341
342
  }
342
- export { ApplicationThemeProvider, ApplicationUtilities, detectShortcutPlatform, resolveShortcutPlatform, settingsShortcutLabel, shortcutModifierKey };
343
+ export { ApplicationThemeProvider, ApplicationUtilities, DEFAULT_NARROW_QUERY, createMediaQuery, detectShortcutPlatform, resolveShortcutPlatform, settingsShortcutLabel, shortcutModifierKey };
@@ -0,0 +1,8 @@
1
+ /** When the application shell counts a window as narrow. */
2
+ export declare const DEFAULT_NARROW_QUERY = "(max-width: 799px)";
3
+ /**
4
+ * Reactive `matchMedia`. Components watching the same query share one listener. The query
5
+ * may be reactive and the subscription follows it; an empty or absent query, or a runtime
6
+ * without `matchMedia`, reads as not matching.
7
+ */
8
+ export declare function createMediaQuery(query: string | (() => string | undefined)): () => boolean;
@@ -0,0 +1,51 @@
1
+ import { createEffect, createSignal, onCleanup } from "solid-js";
2
+ // src/shell/media-query.ts
3
+ /** When the application shell counts a window as narrow. */
4
+ var DEFAULT_NARROW_QUERY = "(max-width: 799px)";
5
+ var shared = /* @__PURE__ */ new Map();
6
+ var supported = () => typeof window !== "undefined" && typeof window.matchMedia === "function";
7
+ function subscribe(query, subscriber) {
8
+ let entry = shared.get(query);
9
+ if (!entry) {
10
+ const list = window.matchMedia(query);
11
+ const subscribers = /* @__PURE__ */ new Set();
12
+ const notify = () => {
13
+ for (const notifySubscriber of subscribers) notifySubscriber(list.matches);
14
+ };
15
+ list.addEventListener("change", notify);
16
+ entry = {
17
+ list,
18
+ subscribers,
19
+ stop: () => list.removeEventListener("change", notify)
20
+ };
21
+ shared.set(query, entry);
22
+ }
23
+ const current = entry;
24
+ current.subscribers.add(subscriber);
25
+ subscriber(current.list.matches);
26
+ return () => {
27
+ current.subscribers.delete(subscriber);
28
+ if (current.subscribers.size > 0 || shared.get(query) !== current) return;
29
+ current.stop();
30
+ shared.delete(query);
31
+ };
32
+ }
33
+ /**
34
+ * Reactive `matchMedia`. Components watching the same query share one listener. The query
35
+ * may be reactive and the subscription follows it; an empty or absent query, or a runtime
36
+ * without `matchMedia`, reads as not matching.
37
+ */
38
+ function createMediaQuery(query) {
39
+ const text = typeof query === "function" ? query : () => query;
40
+ const [matches, setMatches] = createSignal(false);
41
+ createEffect(() => {
42
+ const value = text();
43
+ if (!value || !supported()) {
44
+ setMatches(false);
45
+ return;
46
+ }
47
+ onCleanup(subscribe(value, setMatches));
48
+ });
49
+ return matches;
50
+ }
51
+ export { DEFAULT_NARROW_QUERY, createMediaQuery };
@@ -1,8 +1,8 @@
1
+ import { isUpdateChannel } from "./release-version.js";
1
2
  import { errorCode } from "../app/value-guards.js";
2
3
  import { isCanonicalPath } from "../native/canonical-path.js";
3
4
  import { ServiceError } from "../app/service-registry.js";
4
5
  import { feedUrl, parseReleaseFeed } from "./release-feed.js";
5
- import { isUpdateChannel } from "./release-version.js";
6
6
  import { acknowledgeRetiredUpdateHealthy, acquireRetainedUpdateTrees, findPendingUpdateHealthAcknowledgement } from "./update-retirement.js";
7
7
  import { stageUpdateSwap } from "./update-swap-stage.js";
8
8
  import { downloadVerifiedRelease } from "./update-download.js";
@@ -10,3 +10,14 @@ export declare function isUpdateChannel(value: unknown): value is UpdateChannel;
10
10
  * comparison — a malformed version must never wedge the state machine.
11
11
  */
12
12
  export declare function versionLessThan(a: string, b: string): boolean;
13
+ /** A release version in the update grammar: `x.y.z` or the dev build `x.y.z-dev.N`. */
14
+ export declare function isReleaseVersion(value: unknown): value is string;
15
+ /** A release tag: `v` followed by a release version. */
16
+ export declare function isReleaseTag(value: unknown): value is string;
17
+ /**
18
+ * The version a build stamps on the shell and its client: the release workflow's
19
+ * `ADEA_APP_RELEASE_VERSION`, otherwise `fallback` (usually the package version).
20
+ * Anything outside the release grammar throws, so a build never ships a version the
21
+ * updater cannot order.
22
+ */
23
+ export declare function applicationVersion(env: Readonly<Record<string, string | undefined>>, fallback: unknown): string;
@@ -40,4 +40,26 @@ function versionLessThan(a, b) {
40
40
  for (let i = 0; i < 3; i++) if ((fallbackB[i] ?? 0) !== (fallbackA[i] ?? 0)) return (fallbackB[i] ?? 0) > (fallbackA[i] ?? 0);
41
41
  return false;
42
42
  }
43
- export { isUpdateChannel, versionLessThan };
43
+ /** The longest release version a build, tag or feed may carry. */
44
+ var MAX_RELEASE_VERSION_LENGTH = 64;
45
+ var RELEASE_VERSION = /^\d+\.\d+\.\d+(?:-dev\.\d+)?$/;
46
+ /** A release version in the update grammar: `x.y.z` or the dev build `x.y.z-dev.N`. */
47
+ function isReleaseVersion(value) {
48
+ return typeof value === "string" && value.length <= MAX_RELEASE_VERSION_LENGTH && RELEASE_VERSION.test(value);
49
+ }
50
+ /** A release tag: `v` followed by a release version. */
51
+ function isReleaseTag(value) {
52
+ return typeof value === "string" && value.startsWith("v") && isReleaseVersion(value.slice(1));
53
+ }
54
+ /**
55
+ * The version a build stamps on the shell and its client: the release workflow's
56
+ * `ADEA_APP_RELEASE_VERSION`, otherwise `fallback` (usually the package version).
57
+ * Anything outside the release grammar throws, so a build never ships a version the
58
+ * updater cannot order.
59
+ */
60
+ function applicationVersion(env, fallback) {
61
+ const version = env.ADEA_APP_RELEASE_VERSION ?? fallback;
62
+ if (!isReleaseVersion(version)) throw new Error("Invalid application release version");
63
+ return version;
64
+ }
65
+ export { applicationVersion, isReleaseTag, isReleaseVersion, isUpdateChannel, versionLessThan };
@@ -1,5 +1,5 @@
1
1
  import type { UpdateAdapter, UpdateChannel, UpdateState } from '@adea-ai/ui/components/composites/update-dialog';
2
- import { type NativeUpdateSnapshotOf } from './update-state';
2
+ import { type NativeUpdateSnapshotOf, type NativeUpdateState } from './update-state';
3
3
  export type { UpdateAdapter, UpdateChannel, UpdateState };
4
4
  /** Channel persistence as a `read`/`persist` pair. */
5
5
  export type UpdateChannelStore = Readonly<{
@@ -46,3 +46,40 @@ export declare function nativeUpdateAdapter(native: NativeUpdateAdapter | (() =>
46
46
  }): UpdateAdapter;
47
47
  /** The adapter for a build with no installer: the dialog explains updates are desktop-only. */
48
48
  export declare function browserUpdateAdapter(currentVersion?: string): UpdateAdapter;
49
+ /** Every phase the shared update dialog understands, in state-machine order. */
50
+ export declare const UPDATE_PHASES: readonly ["idle", "checking", "current", "unavailable", "available", "downloading", "installing", "cancelling", "cancelled", "installed", "failed"];
51
+ export declare function isUpdatePhase(value: unknown): value is UpdateState['phase'];
52
+ /** Phases in which an update occupies the app: offered, in flight, or awaiting the restart. */
53
+ export declare const UPDATE_PENDING_PHASES: readonly ["available", "downloading", "installing", "installed"];
54
+ /** Whether a phase should raise a pending-update badge. */
55
+ export declare function isUpdatePending(phase: string | null | undefined): boolean;
56
+ /** The snapshot the `desktop_update_*` services answer with. */
57
+ export type DesktopUpdateStatus = NativeUpdateState<UpdateState['phase']>;
58
+ /**
59
+ * Check a `desktop_update_*` answer at the boundary, so a malformed reply fails here instead of
60
+ * inside the dialog. `release_notes` may be absent (older hosts), and reads as null.
61
+ */
62
+ export declare function parseDesktopUpdateStatus(value: unknown): DesktopUpdateStatus;
63
+ /** Call a desktop service by name, as the app's desktop client does. */
64
+ export type DesktopServiceInvoke = (command: string, args?: Record<string, unknown>) => Promise<unknown>;
65
+ /**
66
+ * The shared dialog's adapter for the framework desktop updater (`registerUpdateServices`).
67
+ * Every answer is checked with `parseDesktopUpdateStatus` and reported to `onStatus`, so a
68
+ * pending-update badge can follow the same updater. `confirmInstall` may decline an install.
69
+ * Because the dialog keeps polling while that question is open, an install runs only if the
70
+ * updater still offers the version; otherwise the current state is returned so the user can
71
+ * decide again. A rejected install re-reads the status before rethrowing, since the updater
72
+ * may have dropped its offer.
73
+ */
74
+ export declare function desktopUpdateAdapter(invoke: DesktopServiceInvoke, options?: {
75
+ confirmInstall?(version: string): boolean | Promise<boolean>;
76
+ openExternal?(url: string): Promise<void>;
77
+ onStatus?(status: DesktopUpdateStatus): void;
78
+ isDesktopRuntime?(): boolean;
79
+ /** Polling interval during native work; default 500 ms. */
80
+ pollIntervalMs?: number;
81
+ /** Show the available release's notes; default true. */
82
+ releaseNotes?: boolean;
83
+ }): UpdateAdapter;
84
+ /** The `desktop_update_channel*` services as the update surface's channel service. */
85
+ export declare function desktopUpdateChannelService(invoke: DesktopServiceInvoke): UpdateChannelService;