@adea-ai/app-framework 0.34.0 → 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 (40) hide show
  1. package/README.md +10 -10
  2. package/dist/desktop/desktop-client.d.ts +5 -0
  3. package/dist/desktop/desktop-client.js +12 -3
  4. package/dist/framework-source.json +1 -1
  5. package/dist/installer/installer-upgrade-command.js +1 -1
  6. package/dist/native/app-bundle.d.ts +14 -2
  7. package/dist/native/app-bundle.js +18 -5
  8. package/dist/native/desktop-build.d.ts +63 -0
  9. package/dist/native/desktop-build.js +119 -0
  10. package/dist/native/native-utilities.d.ts +18 -0
  11. package/dist/native/native-utilities.js +22 -1
  12. package/dist/native/sidecar-services.d.ts +5 -0
  13. package/dist/native/sidecar-services.js +10 -4
  14. package/dist/release/local-release.js +1 -1
  15. package/dist/shell/app-utilities.d.ts +1 -0
  16. package/dist/shell/app-utilities.js +2 -1
  17. package/dist/shell/media-query.d.ts +8 -0
  18. package/dist/shell/media-query.js +51 -0
  19. package/dist/updates/desktop-updater.js +1 -1
  20. package/dist/updates/release-version.d.ts +11 -0
  21. package/dist/updates/release-version.js +23 -1
  22. package/dist/updates/update-adapter.d.ts +38 -1
  23. package/dist/updates/update-adapter.js +121 -1
  24. package/dist/updates/update-channel-store.js +1 -1
  25. package/dist/updates/update-discovery.js +1 -1
  26. package/dist/updates/update-handoff-plan.js +1 -1
  27. package/dist/updates/update-manager.js +1 -1
  28. package/dist/views/update-surface.js +2 -2
  29. package/package.json +27 -2
  30. package/src/native/electrobun-types.d.ts +87 -0
  31. package/src/shell/app-utilities.tsx +1 -0
  32. package/src/shell/media-query.ts +59 -0
  33. package/src/updates/release-version.ts +33 -0
  34. package/src/updates/update-adapter.ts +168 -1
  35. package/templates/application/electrobun.config.ts +6 -2
  36. package/templates/application/scripts/app-version.ts +2 -8
  37. package/templates/application/scripts/build-desktop.ts +9 -36
  38. package/templates/application/src/bun/index.ts +5 -16
  39. package/templates/application/tsconfig.json +1 -1
  40. package/templates/application/src/electrobun.d.ts +0 -27
package/README.md CHANGED
@@ -75,16 +75,16 @@ TypeScript source alone, and the rest resolve to `dist`. The package ships only
75
75
  the source those entries reach, plus the Electrobun patches in `src/native`; a
76
76
  test checks the file list against the exports.
77
77
 
78
- | Area | Subpaths (`@adea-ai/app-framework/<subpath>`) |
79
- | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
80
- | Application and shell | `application`, `app-shell`, `app-utilities`, `app-settings`, `app-help`, `app-about`, `update-surface` (all _solid_), `service-registry`, `application-menu`, `application-command-client` |
81
- | Appearance | `appearance-host`, `appearance-preferences`, `appearance-surface`, `custom-theme-library`, `window-surface` (all _solid_) |
82
- | Desktop host | `desktop-host`, `desktop-gateway`, `desktop-client`, `desktop-stream`, `channel-handshake`, `channel-proof`, `loopback-policy`, `open-url-channel`, `client-asset-manifest`, `client-assets` (source only) |
83
- | Native windows and OS | `renderer-profile`, `secure-window`, `partitioned-window`, `window-options` (source only), `native-utilities`, `native-secret-store`, `app-bundle`, `sidecar`, `sidecar-services`, `desktop-build-hook`, `windows-runtime-patch` |
84
- | Updates | `desktop-updater`, `update-manager`, `update-inherited-launch-lease`, `packaged-launch-admission`, `packaged-update-startup`, `update-resume`, `channel-update-manager`, `update-channel-store`, `update-discovery`, `update-download`, `update-extraction`, `signed-release`, `update-adapter` (_solid_), `update-state` and `release-version` (source only), `update-helper.js` (bundled helper) |
85
- | Release tooling | `release-config`, `release-cut`, `release-steps`, `release-staging`, `release-artifact`, `release-assets-plan`, `release-descriptor-staging`, `release-publication`, `release-publish-command`, `release-promotion`, `retained-release-build`, `github-release-publisher`, `github-release-qualification`, `github-release-promotion`, `macos-dmg` |
86
- | Installer qualification | `installer-layout`, `installer-identity`, `installer-extraction`, `installed-payload`, `installer-observation`, `installer-qualification-command`, `installer-renderer-evidence` |
87
- | CI | `toolchain-identity` |
78
+ | Area | Subpaths (`@adea-ai/app-framework/<subpath>`) |
79
+ | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
80
+ | Application and shell | `application`, `app-shell`, `app-utilities`, `app-settings`, `app-help`, `app-about`, `update-surface` (all _solid_), `service-registry`, `application-menu`, `application-command-client` |
81
+ | Appearance | `appearance-host`, `appearance-preferences`, `appearance-surface`, `custom-theme-library`, `window-surface` (all _solid_) |
82
+ | Desktop host | `desktop-host`, `desktop-gateway`, `desktop-client`, `desktop-stream`, `channel-handshake`, `channel-proof`, `loopback-policy`, `open-url-channel`, `client-asset-manifest`, `client-assets` (source only) |
83
+ | Native windows and OS | `renderer-profile`, `secure-window`, `partitioned-window`, `window-options` (source only), `native-utilities`, `native-secret-store`, `app-bundle`, `sidecar`, `sidecar-services`, `desktop-build-hook`, `desktop-build`, `windows-runtime-patch`, `electrobun-types` (ambient types only) |
84
+ | Updates | `desktop-updater`, `update-manager`, `update-inherited-launch-lease`, `packaged-launch-admission`, `packaged-update-startup`, `update-resume`, `channel-update-manager`, `update-channel-store`, `update-discovery`, `update-download`, `update-extraction`, `signed-release`, `release-feed`, `release-location`, `update-process-liveness`, `update-adapter` (_solid_), `release-version` (_solid_), `update-state` (source only), `update-helper.js` (bundled helper) |
85
+ | Release tooling | `release-config`, `release-cut`, `release-steps`, `release-staging`, `release-artifact`, `release-assets-plan`, `release-descriptor-staging`, `release-publication`, `release-publish-command`, `release-promotion`, `retained-release-build`, `github-release-publisher`, `github-release-qualification`, `github-release-promotion`, `macos-dmg` |
86
+ | Installer qualification | `installer-layout`, `installer-identity`, `installer-extraction`, `installed-payload`, `installer-observation`, `installer-qualification-command`, `installer-renderer-evidence` |
87
+ | CI | `toolchain-identity` |
88
88
 
89
89
  Commands (package `bin` entries):
90
90
 
@@ -3,6 +3,11 @@ import type { FetchFunction } from '../updates/release-location';
3
3
  type Bootstrap = (signal?: AbortSignal) => Promise<{
4
4
  bootstrap: string;
5
5
  }>;
6
+ /**
7
+ * Whether this page runs in a framework desktop window: the window preload defines the
8
+ * bootstrap acquirer before any page script. Pass another scope to probe it instead.
9
+ */
10
+ export declare function isFrameworkDesktop(scope?: object): boolean;
6
11
  declare const streamSessionBrand: unique symbol;
7
12
  /** A token tied to one successful explicit reconnect on its originating client. */
8
13
  export type DesktopStreamSession = Readonly<{
@@ -52,6 +52,15 @@ function base64UrlToBytes(value) {
52
52
  const text = value.replace(/-/g, "+").replace(/_/g, "/");
53
53
  return Uint8Array.from(atob(text + "=".repeat((4 - text.length % 4) % 4)), (c) => c.charCodeAt(0));
54
54
  }
55
+ /** The global the framework window preload defines before any page script runs. */
56
+ var BOOTSTRAP_GLOBAL = "__frameworkAcquireBootstrap";
57
+ /**
58
+ * Whether this page runs in a framework desktop window: the window preload defines the
59
+ * bootstrap acquirer before any page script. Pass another scope to probe it instead.
60
+ */
61
+ function isFrameworkDesktop(scope = globalThis) {
62
+ return typeof scope[BOOTSTRAP_GLOBAL] === "function";
63
+ }
55
64
  /** Browser-side client for the authenticated desktop gateway. Share one client per window: acquiring a new bootstrap revokes the window's previous channel. */
56
65
  function createDesktopClient(options = {}) {
57
66
  const origin = createLoopbackPolicy(options.origin ?? globalThis.location.origin).origin;
@@ -59,8 +68,8 @@ function createDesktopClient(options = {}) {
59
68
  const crypto = options.crypto ?? globalThis.crypto;
60
69
  const now = options.now ?? Date.now;
61
70
  const bootstrap = options.bootstrap ?? ((signal) => {
62
- const acquire = globalThis.__frameworkAcquireBootstrap;
63
- if (!acquire) throw new Error("Desktop window bootstrap is unavailable");
71
+ const acquire = globalThis[BOOTSTRAP_GLOBAL];
72
+ if (typeof acquire !== "function") throw new Error("Desktop window bootstrap is unavailable");
64
73
  return acquire(signal);
65
74
  });
66
75
  let session;
@@ -354,4 +363,4 @@ function createDesktopClient(options = {}) {
354
363
  }
355
364
  };
356
365
  }
357
- export { createDesktopClient };
366
+ export { createDesktopClient, isFrameworkDesktop };
@@ -1 +1 @@
1
- {"version":"0.34.0","commit":"11d5efa8628889b5266a4283e754bb7641d3114f"}
1
+ {"version":"0.35.0","commit":"8584e127ca89c019a50661b52da2a052dafba921"}
@@ -1,9 +1,9 @@
1
+ import { versionLessThan } from "../updates/release-version.js";
1
2
  import { errorCode, isRecord } from "../app/value-guards.js";
2
3
  import { verifyReleaseDescriptor } from "../updates/signed-release.js";
3
4
  import { feedUrl } from "../updates/release-feed.js";
4
5
  import { parseReleaseConfig } from "../release/release-config.js";
5
6
  import { planReleaseAssets } from "../release/release-assets-plan.js";
6
- import { versionLessThan } from "../updates/release-version.js";
7
7
  import { observeInstalledApp } from "./installer-observation.js";
8
8
  import { downloadAsset } from "./upgrade-asset-download.js";
9
9
  import { discoverSignedRelease } from "../updates/update-discovery.js";
@@ -24,5 +24,17 @@ export declare function sidecarFileName(name: string, platform: string): string;
24
24
  * root (`<App>.app/Contents` on macOS, the app directory on Windows and Linux).
25
25
  */
26
26
  export declare function sidecarBundlePath(name: string, platform: string): string;
27
- /** Absolute path of a bundled sidecar for the running host; pass the entry's `import.meta.dir`. */
28
- export declare function packagedSidecarPath(entryDirectory: string, name: string, platform?: string): string;
27
+ /**
28
+ * Absolute path of a bundled sidecar for the running host; pass the entry's `import.meta.dir`.
29
+ * A non-empty `override` (for example an environment variable pointing at a development
30
+ * build) wins over the bundled copy.
31
+ */
32
+ export declare function packagedSidecarPath(entryDirectory: string, name: string, platform?: string, options?: Readonly<{
33
+ override?: string | undefined;
34
+ }>): string;
35
+ /**
36
+ * Electrobun's launcher for the running app, beside the bundled Bun that runs the host
37
+ * (`Contents/MacOS` on macOS, `bin` elsewhere). Pass `process.execPath`. This is what a login
38
+ * item or a relaunch should start.
39
+ */
40
+ export declare function packagedLauncherPath(execPath?: string, platform?: string): string;
@@ -1,5 +1,5 @@
1
1
  import { containsAsciiControl } from "../desktop/string-policy.js";
2
- import { join } from "node:path";
2
+ import { dirname, join } from "node:path";
3
3
  import { readFileSync, statSync } from "node:fs";
4
4
  // src/native/app-bundle.ts
5
5
  /**
@@ -54,8 +54,21 @@ function sidecarFileName(name, platform) {
54
54
  function sidecarBundlePath(name, platform) {
55
55
  return `Resources/app/${SIDECAR_DIRECTORY}/${sidecarFileName(name, platform)}`;
56
56
  }
57
- /** Absolute path of a bundled sidecar for the running host; pass the entry's `import.meta.dir`. */
58
- function packagedSidecarPath(entryDirectory, name, platform = process.platform) {
59
- return join(entryDirectory, "..", SIDECAR_DIRECTORY, sidecarFileName(name, platform));
57
+ /**
58
+ * Absolute path of a bundled sidecar for the running host; pass the entry's `import.meta.dir`.
59
+ * A non-empty `override` (for example an environment variable pointing at a development
60
+ * build) wins over the bundled copy.
61
+ */
62
+ function packagedSidecarPath(entryDirectory, name, platform = process.platform, options = {}) {
63
+ const executable = join(entryDirectory, "..", SIDECAR_DIRECTORY, sidecarFileName(name, platform));
64
+ return options.override ? options.override : executable;
65
+ }
66
+ /**
67
+ * Electrobun's launcher for the running app, beside the bundled Bun that runs the host
68
+ * (`Contents/MacOS` on macOS, `bin` elsewhere). Pass `process.execPath`. This is what a login
69
+ * item or a relaunch should start.
70
+ */
71
+ function packagedLauncherPath(execPath = process.execPath, platform = process.platform) {
72
+ return join(dirname(execPath), platform === "win32" ? "launcher.exe" : "launcher");
60
73
  }
61
- export { SIDECAR_DIRECTORY, assertSidecarNames, bundleResourcesDirectory, packagedSidecarPath, readPackagedVersion, sidecarBundlePath, sidecarFileName };
74
+ export { SIDECAR_DIRECTORY, assertSidecarNames, bundleResourcesDirectory, packagedLauncherPath, packagedSidecarPath, readPackagedVersion, sidecarBundlePath, sidecarFileName };
@@ -0,0 +1,63 @@
1
+ import { createMacosDmg } from '../release/macos-dmg';
2
+ /** The Electrobun build environments an application script may request. */
3
+ export type DesktopBuildEnvironment = 'dev' | 'stable';
4
+ /** A process environment as the build reads it. */
5
+ export type BuildEnv = Readonly<Record<string, string | undefined>>;
6
+ type Env = BuildEnv;
7
+ /** Validate a build script's arguments: exactly one of `dev` or `stable`. */
8
+ export declare function parseDesktopBuildEnvironment(args: readonly string[]): DesktopBuildEnvironment;
9
+ /**
10
+ * The macOS signing identity for a build. Electrobun signs the whole stable payload (every
11
+ * nested Mach-O, then the bundle seal) only when it is given an identity. A stable macOS build
12
+ * with no Developer ID configured uses `-`, an ad-hoc seal, so the app never ships with a mix
13
+ * of signatures or without a bundle seal. An explicitly configured identity is kept.
14
+ */
15
+ export declare function macosSigningEnv(env: Env, platform: string, environment: string): Env;
16
+ /** Whether `electrobun.config.ts` should ask Electrobun to sign: only when an identity is set. */
17
+ export declare const signsMacosBuild: (env: Env) => boolean;
18
+ /** Report the `tar --version` banner, or null when no working tar runs. */
19
+ export type TarVersionProbe = (env: Env) => string | null;
20
+ /**
21
+ * The environment Electrobun's archive step needs. On Windows, GNU tar reads `C:\...` as a
22
+ * remote `host:path` unless it is given `--force-local`; bsdtar needs nothing. Other
23
+ * platforms are returned unchanged.
24
+ */
25
+ export declare function tarEnv(env: Env, platform?: string, probe?: TarVersionProbe): Env;
26
+ /** The opt-in POSIX launch lease is built for stable macOS arm64 packages only. */
27
+ export declare function assertPosixLaunchLeaseTarget(env: Env, environment: DesktopBuildEnvironment, platform: string, arch: string): void;
28
+ /** Run a command with inherited stdio; resolve its exit code. */
29
+ export type BuildCommandRunner = (command: readonly string[], options: {
30
+ cwd: string;
31
+ env: Env;
32
+ }) => Promise<number>;
33
+ /**
34
+ * Build the desktop app with Electrobun: check the launch-lease opt-in, give a stable macOS
35
+ * build its signing identity, fix tar on Windows, run `electrobun build`, then pack a stable
36
+ * macOS build into `artifacts/macos-<arch>-<App>.dmg`. Resolves the disk image path when one
37
+ * was made.
38
+ */
39
+ export declare function runElectrobunBuild(options: {
40
+ environment: DesktopBuildEnvironment;
41
+ appName: string;
42
+ cwd?: string;
43
+ env?: Env;
44
+ platform?: string;
45
+ arch?: string;
46
+ run?: BuildCommandRunner;
47
+ createDmg?: typeof createMacosDmg;
48
+ tarVersion?: TarVersionProbe;
49
+ }): Promise<{
50
+ dmg?: string;
51
+ }>;
52
+ /** The framework's post-exit update helper, as the installed package resolves it. */
53
+ export declare function updateHelperSource(): string;
54
+ /**
55
+ * Copy the framework's update helper into `directory` (as `update-helper.js` by default) so
56
+ * Electrobun's `build.copy` can pack it. Resolves the helper through the package's exports
57
+ * rather than a `node_modules` path. Returns the staged file.
58
+ */
59
+ export declare function stageUpdateHelper(directory: string, options?: {
60
+ fileName?: string;
61
+ source?: string;
62
+ }): string;
63
+ export {};
@@ -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";
@@ -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 };