akanjs 3.4.0-rc.0 → 3.4.0-rc.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 (63) hide show
  1. package/common/pipelinePlan.ts +2 -1
  2. package/index.ts +6 -1
  3. package/package.json +1 -1
  4. package/server/console.ts +1 -1
  5. package/server/gateway/childSupervisor.ts +20 -7
  6. package/server/gateway/gatewayConfig.ts +9 -2
  7. package/server/lifecycle/unixSocketPath.ts +79 -0
  8. package/server/logging/logControlSocket.ts +6 -4
  9. package/types/common/pipelinePlan.d.ts +2 -1
  10. package/types/index.d.ts +6 -1
  11. package/types/server/gateway/gatewayConfig.d.ts +2 -0
  12. package/types/server/lifecycle/unixSocketPath.d.ts +22 -0
  13. package/types/server/logging/rotatingLogWriter.d.ts +1 -1
  14. package/types/vendor/@akanjs/native/packages/cli/src/config.d.ts +6 -2
  15. package/types/vendor/@akanjs/native/packages/cli/src/lib/permissions.d.ts +1 -1
  16. package/types/vendor/@akanjs/native/packages/cli/src/lib/updates.d.ts +6 -4
  17. package/types/vendor/@akanjs/native/packages/cli/src/platforms/desktop.d.ts +2 -0
  18. package/types/vendor/@akanjs/native/packages/cli/src/platforms/macos.d.ts +6 -1
  19. package/types/vendor/@akanjs/native/packages/cli/src/platforms/macosLaunch.d.ts +7 -0
  20. package/types/vendor/@akanjs/native/packages/desktop/src/commands.d.ts +7 -3
  21. package/types/vendor/@akanjs/native/packages/desktop/src/dispatcher.d.ts +5 -0
  22. package/types/vendor/@akanjs/native/packages/desktop/src/ffi.d.ts +9 -0
  23. package/types/vendor/@akanjs/native/packages/desktop/src/paths.d.ts +2 -1
  24. package/types/vendor/@akanjs/native/packages/desktop/src/plugin.d.ts +9 -1
  25. package/types/vendor/@akanjs/native/plugins/dock/src/index.d.ts +5 -3
  26. package/types/vendor/@akanjs/native/plugins/menu/src/index.d.ts +4 -4
  27. package/types/vendor/@akanjs/native/plugins/single-instance/src/socket.d.ts +3 -2
  28. package/types/vendor/@akanjs/native/plugins/tray/src/desktop.d.ts +2 -0
  29. package/types/vendor/@akanjs/native/plugins/window/src/desktop.d.ts +1 -0
  30. package/types/vendor/@akanjs/native/plugins/window/src/index.d.ts +8 -4
  31. package/ui/System/CSR.tsx +2 -0
  32. package/vendor/@akanjs/native/native/desktop/build.rs +2 -0
  33. package/vendor/@akanjs/native/native/desktop/src/launch_urls.rs +53 -0
  34. package/vendor/@akanjs/native/native/desktop/src/lib.rs +27 -4
  35. package/vendor/@akanjs/native/native/desktop/src/linux/dock.rs +3 -2
  36. package/vendor/@akanjs/native/native/desktop/src/linux/menu.rs +13 -10
  37. package/vendor/@akanjs/native/native/desktop/src/linux/mod.rs +5 -3
  38. package/vendor/@akanjs/native/native/desktop/src/win/dock.rs +3 -2
  39. package/vendor/@akanjs/native/native/desktop/src/win/menu.rs +80 -20
  40. package/vendor/@akanjs/native/native/desktop/src/win/mod.rs +16 -2
  41. package/vendor/@akanjs/native/packages/cli/src/config.ts +11 -3
  42. package/vendor/@akanjs/native/packages/cli/src/lib/configkeys.ts +2 -2
  43. package/vendor/@akanjs/native/packages/cli/src/lib/permissions.ts +11 -2
  44. package/vendor/@akanjs/native/packages/cli/src/lib/project.ts +1 -0
  45. package/vendor/@akanjs/native/packages/cli/src/lib/updates.ts +19 -4
  46. package/vendor/@akanjs/native/packages/cli/src/platforms/desktop.ts +23 -2
  47. package/vendor/@akanjs/native/packages/cli/src/platforms/macos.ts +41 -10
  48. package/vendor/@akanjs/native/packages/cli/src/platforms/macosLaunch.ts +100 -0
  49. package/vendor/@akanjs/native/packages/desktop/src/commands.ts +24 -11
  50. package/vendor/@akanjs/native/packages/desktop/src/dispatcher.ts +31 -21
  51. package/vendor/@akanjs/native/packages/desktop/src/ffi.ts +9 -0
  52. package/vendor/@akanjs/native/packages/desktop/src/host.ts +27 -6
  53. package/vendor/@akanjs/native/packages/desktop/src/main.ts +5 -1
  54. package/vendor/@akanjs/native/packages/desktop/src/paths.ts +3 -2
  55. package/vendor/@akanjs/native/packages/desktop/src/plugin.ts +6 -1
  56. package/vendor/@akanjs/native/plugins/dock/src/index.ts +5 -3
  57. package/vendor/@akanjs/native/plugins/menu/src/index.ts +4 -4
  58. package/vendor/@akanjs/native/plugins/single-instance/src/desktop.ts +4 -1
  59. package/vendor/@akanjs/native/plugins/single-instance/src/socket.ts +10 -5
  60. package/vendor/@akanjs/native/plugins/tray/src/desktop.ts +35 -5
  61. package/vendor/@akanjs/native/plugins/updates/src/desktop.ts +1 -1
  62. package/vendor/@akanjs/native/plugins/window/src/desktop.ts +13 -1
  63. package/vendor/@akanjs/native/plugins/window/src/index.ts +8 -4
@@ -17,7 +17,8 @@ export type PipelineTrigger = (typeof pipelineTriggers)[number];
17
17
  /**
18
18
  * The executor's own operations, declared per app. Within one app each appears at most once, in this order, and
19
19
  * `docker` needs a `build` before it: the image is made from this run's `akan build` output. An action whose app's
20
- * previous action in the run was skipped or did not succeed is skipped, never run. `deploy` is the only way any part
20
+ * previous action in the run was skipped or did not succeed is skipped, never run; for `desktop-ota` that is the action
21
+ * before `ota`, since a phone bundle and a desktop app are separate releases. `deploy` is the only way any part
21
22
  * of a plan reaches the master host, and its phase runs the apps one at a time. `ota` packs an over-the-air update of
22
23
  * the app's native web bundle per target and platform (`akan pack-update`) for the executor to sign and publish; it
23
24
  * makes its own CSR build, so it needs no `build` before it. `desktop-ota` is the same for a desktop app, which is
package/index.ts CHANGED
@@ -135,7 +135,7 @@ export type LibAssetsConfig = Pick<AkanAssetsConfig, "keepFonts">;
135
135
 
136
136
  export type DatabaseMode = "single" | "multiple" | "cluster";
137
137
  export type NativeEnv = "local" | "debug" | "develop" | "main";
138
- export type NativePermission = "camera" | "contacts" | "location" | "push" | "speech";
138
+ export type NativePermission = "camera" | "contacts" | "location" | "microphone" | "push" | "speech";
139
139
 
140
140
  export type AkanNativeValue = string | number | boolean | AkanNativeValue[] | { [key: string]: AkanNativeValue };
141
141
 
@@ -307,6 +307,11 @@ export interface AkanNativeDesktopConfig {
307
307
  * for a native addon signed by another team. Read when the app is signed with a team (a Developer ID).
308
308
  */
309
309
  entitlements?: Record<string, AkanNativeValue>;
310
+ /**
311
+ * macOS: Info.plist entries of the app, merged over the usage texts the permissions put there — e.g. the camera's and
312
+ * microphone's texts in the app's own language. The bundle id, executable, name and versions cannot be set.
313
+ */
314
+ infoPlist?: Record<string, AkanNativeValue>;
310
315
  /**
311
316
  * macOS: the Finder window `build-desktop --installer` opens its dmg in — no toolbar or sidebar, the app's and the
312
317
  * Applications link's icons on a background, the app's icon on the mounted disk. Without it the window is 660×400 pt
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akanjs",
3
- "version": "3.4.0-rc.0",
3
+ "version": "3.4.0-rc.2",
4
4
  "sourceType": "module",
5
5
  "type": "module",
6
6
  "publishConfig": {
package/server/console.ts CHANGED
@@ -49,7 +49,7 @@ const createAkanConsoleLogCommands = (appName: string, runtimeDir: string): Reco
49
49
  });
50
50
  } catch (error) {
51
51
  if (error instanceof LogControlUnavailableError) {
52
- session.write(`${appName} is not running (no akan-control.sock in ${runtimeDir})\n`);
52
+ session.write(`${appName} is not running (no log control socket at ${socketPath})\n`);
53
53
  return null;
54
54
  }
55
55
  throw error;
@@ -5,6 +5,7 @@ import type { AkanChildRole, AkanIpcMessage } from "akanjs/service";
5
5
  import { RestartSchedule } from "../../common/restartSchedule";
6
6
  import { CrossSiteGuard } from "../../signal/CrossSiteGuard";
7
7
  import type { BuilderMessage } from "../artifact";
8
+ import { UnixSocketPath, UnixSocketPathTooLongError } from "../lifecycle/unixSocketPath";
8
9
  import { ChildOutputReader } from "../logging/childOutputReader";
9
10
  import type { DevHostChannel } from "./devHostChannel";
10
11
  import type { ChildState, GatewayChildren } from "./gatewayChildren";
@@ -50,14 +51,26 @@ export class ChildSupervisor {
50
51
  }
51
52
 
52
53
  async prepareRuntimeDir() {
53
- await mkdir(this.#config.runtimeDir, { recursive: true });
54
+ const { runtimeDir, childSocketDir, replica } = this.#config;
55
+ try {
56
+ await UnixSocketPath.prepare(runtimeDir, this.#config.childSocketName(replica.total - 1));
57
+ } catch (error) {
58
+ if (error instanceof UnixSocketPathTooLongError) {
59
+ this.#logger.error(error.message);
60
+ this.#host.reportBackendBuildStatus({ ok: false, message: error.message });
61
+ }
62
+ throw error;
63
+ }
64
+ await mkdir(runtimeDir, { recursive: true });
54
65
 
55
- const entries = await readdir(this.#config.runtimeDir).catch(() => []);
56
- await Promise.all(
57
- entries
58
- .filter((name) => /^akan-(child-.*|control)\.sock$/.test(name))
59
- .map((name) => rm(path.join(this.#config.runtimeDir, name), { force: true }).catch(() => undefined)),
60
- );
66
+ for (const dir of new Set([runtimeDir, childSocketDir])) {
67
+ const entries = await readdir(dir).catch(() => []);
68
+ await Promise.all(
69
+ entries
70
+ .filter((name) => /^akan-(child-.*|control)\.sock$/.test(name))
71
+ .map((name) => rm(path.join(dir, name), { force: true }).catch(() => undefined)),
72
+ );
73
+ }
61
74
  }
62
75
 
63
76
  spawn(idx: number) {
@@ -5,6 +5,7 @@ import { getApiPrefix, getWsPrefix, normalizeRoutePrefix } from "../../base/base
5
5
  import type { RestartPolicy } from "../../common/restartSchedule";
6
6
  import { ClientReportId } from "../clientReportId";
7
7
  import { resolveRuntimeDir } from "../lifecycle/runtimeDir";
8
+ import { UnixSocketPath } from "../lifecycle/unixSocketPath";
8
9
  import { getWebConfigFromEnv } from "../types";
9
10
 
10
11
  export interface AkanAppOptions {
@@ -58,7 +59,8 @@ export class GatewayConfig {
58
59
  readonly artifactDir: string;
59
60
  readonly replica: AkanReplicaConfig;
60
61
  readonly runtimeDir: string;
61
- readonly socketRunId = `${process.pid}-${Date.now().toString(36)}`;
62
+ readonly socketRunId = randomBytes(4).toString("hex");
63
+ readonly childSocketDir: string;
62
64
  readonly port: number;
63
65
  readonly wsBasePort: number;
64
66
  readonly openapi?: boolean;
@@ -86,6 +88,7 @@ export class GatewayConfig {
86
88
  this.disableModules = options.disableModules ?? [];
87
89
  this.disableLibs = options.disableLibs ?? [];
88
90
  this.solo = GatewayConfig.#resolveSolo(options, this.replica);
91
+ this.childSocketDir = UnixSocketPath.dirFor(this.runtimeDir, this.childSocketName(this.replica.total - 1));
89
92
  }
90
93
 
91
94
  static #resolveSolo(options: AkanAppOptions, replica: AkanReplicaConfig) {
@@ -174,9 +177,13 @@ export class GatewayConfig {
174
177
  return "all";
175
178
  }
176
179
 
180
+ childSocketName(idx: number) {
181
+ return `akan-child-${this.socketRunId}-${String(idx).padStart(2, "0")}.sock`;
182
+ }
183
+
177
184
  childUpstreamOf(idx: number, role: AkanChildRole): GatewayUpstream {
178
185
  return {
179
- http: { type: "unix", socketPath: path.join(this.runtimeDir, `akan-child-${this.socketRunId}-${idx}.sock`) },
186
+ http: { type: "unix", socketPath: path.join(this.childSocketDir, this.childSocketName(idx)) },
180
187
  ws: role === "batch" ? undefined : { type: "tcp", host: "127.0.0.1", port: this.wsBasePort + idx },
181
188
  };
182
189
  }
@@ -0,0 +1,79 @@
1
+ import { createHash } from "node:crypto";
2
+ import { mkdir } from "node:fs/promises";
3
+ import { tmpdir } from "node:os";
4
+ import path from "node:path";
5
+ import { AkanError } from "akanjs/base";
6
+
7
+ export interface UnixSocketSite {
8
+ platform?: NodeJS.Platform;
9
+ limit?: number | null;
10
+ tempDir?: string;
11
+ }
12
+
13
+ export class UnixSocketPathTooLongError extends AkanError<"unixSocketPathTooLong"> {
14
+ readonly socketPath: string;
15
+ readonly length: number;
16
+ readonly limit: number;
17
+
18
+ constructor(socketPath: string, limit: number, platform: NodeJS.Platform) {
19
+ const length = UnixSocketPath.lengthOf(socketPath);
20
+ const system = platform === "win32" ? "Windows" : platform;
21
+ super(
22
+ "unixSocketPathTooLong",
23
+ `The unix socket path ${socketPath} is ${length} bytes long, and ${system} allows at most ${limit}, so nothing could listen on it. Move the runtime folder (AKAN_RUNTIME_DIR) or the temp folder its sockets fall back to (TEMP on Windows) to a shorter path.`,
24
+ );
25
+ this.name = "UnixSocketPathTooLongError";
26
+ this.socketPath = socketPath;
27
+ this.length = length;
28
+ this.limit = limit;
29
+ }
30
+ }
31
+
32
+ export class UnixSocketPath {
33
+
34
+ static limitOf(platform: NodeJS.Platform = process.platform): number | null {
35
+ return platform === "win32" ? 107 : null;
36
+ }
37
+
38
+ static lengthOf(socketPath: string) {
39
+ return Buffer.byteLength(socketPath);
40
+ }
41
+
42
+ static fallbackDirOf(runtimeDir: string, { platform = process.platform, tempDir }: UnixSocketSite = {}) {
43
+
44
+ const key = platform === "win32" ? runtimeDir.toLowerCase() : runtimeDir;
45
+ const hash = createHash("sha256").update(key).digest("hex").slice(0, 12);
46
+ const temp = tempDir ?? ((platform !== "win32" && process.env.XDG_RUNTIME_DIR) || tmpdir());
47
+ return UnixSocketPath.#join(platform, temp, `akan-${hash}`);
48
+ }
49
+
50
+ static dirFor(runtimeDir: string, name: string, site: UnixSocketSite = {}) {
51
+ const fits = UnixSocketPath.#limitPassed(UnixSocketPath.#join(site.platform, runtimeDir, name), site) === null;
52
+ return fits ? runtimeDir : UnixSocketPath.fallbackDirOf(runtimeDir, site);
53
+ }
54
+
55
+ static pathFor(runtimeDir: string, name: string, site: UnixSocketSite = {}) {
56
+ return UnixSocketPath.#join(site.platform, UnixSocketPath.dirFor(runtimeDir, name, site), name);
57
+ }
58
+
59
+ static assertFits(socketPath: string, site: UnixSocketSite = {}) {
60
+ const limit = UnixSocketPath.#limitPassed(socketPath, site);
61
+ if (limit !== null) throw new UnixSocketPathTooLongError(socketPath, limit, site.platform ?? process.platform);
62
+ }
63
+
64
+ static async prepare(runtimeDir: string, name: string) {
65
+ const dir = UnixSocketPath.dirFor(runtimeDir, name);
66
+ const socketPath = path.join(dir, name);
67
+ UnixSocketPath.assertFits(socketPath);
68
+ await mkdir(dir, { recursive: true, ...(dir === runtimeDir ? {} : { mode: 0o700 }) });
69
+ return socketPath;
70
+ }
71
+
72
+ static #limitPassed(socketPath: string, { platform, limit = UnixSocketPath.limitOf(platform) }: UnixSocketSite) {
73
+ return limit !== null && UnixSocketPath.lengthOf(socketPath) > limit ? limit : null;
74
+ }
75
+
76
+ static #join(platform = process.platform, ...parts: string[]) {
77
+ return (platform === "win32" ? path.win32 : path.posix).join(...parts);
78
+ }
79
+ }
@@ -1,6 +1,6 @@
1
- import { chmod, mkdir, rm } from "node:fs/promises";
2
- import path from "node:path";
1
+ import { chmod, rm } from "node:fs/promises";
3
2
  import { Logger } from "akanjs/common";
3
+ import { UnixSocketPath } from "../lifecycle/unixSocketPath";
4
4
  import type { LogHub, LogHubCoverage, LogHubEntry } from "./logHub";
5
5
  import { type LogQuery, LogQueryMatcher } from "./logQuery";
6
6
 
@@ -34,10 +34,11 @@ export class LogControlSocket {
34
34
  static readonly #turns = new Map<string, Promise<void>>();
35
35
 
36
36
  static pathIn(runtimeDir: string) {
37
- return path.join(runtimeDir, LogControlSocket.fileName);
37
+ return UnixSocketPath.pathFor(runtimeDir, LogControlSocket.fileName);
38
38
  }
39
39
 
40
40
  readonly path: string;
41
+ readonly #runtimeDir: string;
41
42
  readonly #hub: LogHub;
42
43
  readonly #logger = new Logger("LogControlSocket");
43
44
  #server: ReturnType<typeof Bun.listen<ClientState>> | null = null;
@@ -45,6 +46,7 @@ export class LogControlSocket {
45
46
 
46
47
  constructor(hub: LogHub, runtimeDir: string) {
47
48
  this.#hub = hub;
49
+ this.#runtimeDir = runtimeDir;
48
50
  this.path = LogControlSocket.pathIn(runtimeDir);
49
51
  }
50
52
 
@@ -88,7 +90,7 @@ export class LogControlSocket {
88
90
  }
89
91
 
90
92
  async #listen(generation: number) {
91
- await mkdir(path.dirname(this.path), { recursive: true });
93
+ await UnixSocketPath.prepare(this.#runtimeDir, LogControlSocket.fileName);
92
94
 
93
95
  if (await LogControlSocket.#answers(this.path)) throw new Error("another server is listening on it");
94
96
  if (this.#abandoned(generation)) return;
@@ -12,7 +12,8 @@ export type PipelineTrigger = (typeof pipelineTriggers)[number];
12
12
  /**
13
13
  * The executor's own operations, declared per app. Within one app each appears at most once, in this order, and
14
14
  * `docker` needs a `build` before it: the image is made from this run's `akan build` output. An action whose app's
15
- * previous action in the run was skipped or did not succeed is skipped, never run. `deploy` is the only way any part
15
+ * previous action in the run was skipped or did not succeed is skipped, never run; for `desktop-ota` that is the action
16
+ * before `ota`, since a phone bundle and a desktop app are separate releases. `deploy` is the only way any part
16
17
  * of a plan reaches the master host, and its phase runs the apps one at a time. `ota` packs an over-the-air update of
17
18
  * the app's native web bundle per target and platform (`akan pack-update`) for the executor to sign and publish; it
18
19
  * makes its own CSR build, so it needs no `build` before it. `desktop-ota` is the same for a desktop app, which is
package/types/index.d.ts CHANGED
@@ -120,7 +120,7 @@ export interface AkanAssetsConfig {
120
120
  export type LibAssetsConfig = Pick<AkanAssetsConfig, "keepFonts">;
121
121
  export type DatabaseMode = "single" | "multiple" | "cluster";
122
122
  export type NativeEnv = "local" | "debug" | "develop" | "main";
123
- export type NativePermission = "camera" | "contacts" | "location" | "push" | "speech";
123
+ export type NativePermission = "camera" | "contacts" | "location" | "microphone" | "push" | "speech";
124
124
  export type AkanNativeValue = string | number | boolean | AkanNativeValue[] | {
125
125
  [key: string]: AkanNativeValue;
126
126
  };
@@ -300,6 +300,11 @@ export interface AkanNativeDesktopConfig {
300
300
  * for a native addon signed by another team. Read when the app is signed with a team (a Developer ID).
301
301
  */
302
302
  entitlements?: Record<string, AkanNativeValue>;
303
+ /**
304
+ * macOS: Info.plist entries of the app, merged over the usage texts the permissions put there — e.g. the camera's and
305
+ * microphone's texts in the app's own language. The bundle id, executable, name and versions cannot be set.
306
+ */
307
+ infoPlist?: Record<string, AkanNativeValue>;
303
308
  /**
304
309
  * macOS: the Finder window `build-desktop --installer` opens its dmg in — no toolbar or sidebar, the app's and the
305
310
  * Applications link's icons on a background, the app's icon on the mounted disk. Without it the window is 660×400 pt
@@ -49,6 +49,7 @@ export declare class GatewayConfig {
49
49
  readonly replica: AkanReplicaConfig;
50
50
  readonly runtimeDir: string;
51
51
  readonly socketRunId: string;
52
+ readonly childSocketDir: string;
52
53
  readonly port: number;
53
54
  readonly wsBasePort: number;
54
55
  readonly openapi?: boolean;
@@ -77,6 +78,7 @@ export declare class GatewayConfig {
77
78
  AKAN_CLIENT_REPORT_KEY: string;
78
79
  };
79
80
  roleOf(idx: number): AkanChildRole;
81
+ childSocketName(idx: number): string;
80
82
  childUpstreamOf(idx: number, role: AkanChildRole): GatewayUpstream;
81
83
  isWebSocketPath(pathname: string): boolean;
82
84
  }
@@ -0,0 +1,22 @@
1
+ import { AkanError } from "akanjs/base";
2
+ export interface UnixSocketSite {
3
+ platform?: NodeJS.Platform;
4
+ limit?: number | null;
5
+ tempDir?: string;
6
+ }
7
+ export declare class UnixSocketPathTooLongError extends AkanError<"unixSocketPathTooLong"> {
8
+ readonly socketPath: string;
9
+ readonly length: number;
10
+ readonly limit: number;
11
+ constructor(socketPath: string, limit: number, platform: NodeJS.Platform);
12
+ }
13
+ export declare class UnixSocketPath {
14
+ #private;
15
+ static limitOf(platform?: NodeJS.Platform): number | null;
16
+ static lengthOf(socketPath: string): number;
17
+ static fallbackDirOf(runtimeDir: string, { platform, tempDir }?: UnixSocketSite): string;
18
+ static dirFor(runtimeDir: string, name: string, site?: UnixSocketSite): string;
19
+ static pathFor(runtimeDir: string, name: string, site?: UnixSocketSite): string;
20
+ static assertFits(socketPath: string, site?: UnixSocketSite): void;
21
+ static prepare(runtimeDir: string, name: string): Promise<string>;
22
+ }
@@ -19,5 +19,5 @@ export declare class RotatingLogWriter {
19
19
  static sanitizeFilePart(value: string): string;
20
20
  write(processKey: string, chunk: string): void;
21
21
  close(): Promise<void>;
22
- static fileMode(value?: string | undefined, warn?: typeof RotatingLogWriter.__#181@#defaultWarn): number;
22
+ static fileMode(value?: string | undefined, warn?: typeof RotatingLogWriter.__#182@#defaultWarn): number;
23
23
  }
@@ -104,13 +104,15 @@ export interface AkanNativeConfig {
104
104
  };
105
105
  /**
106
106
  * Permissions for web APIs used without a plugin (plugins.md C8): getUserMedia needs camera or
107
- * microphone, navigator.geolocation needs location. `true` or the usage text iOS/macOS show,
108
- * e.g. { microphone: "Record voice notes." }. Adds the Info.plist texts and Android permissions.
107
+ * microphone, navigator.geolocation needs location, webkitSpeechRecognition needs speech and microphone. `true` or
108
+ * the usage text iOS/macOS show, e.g. { microphone: "Record voice notes." }. Adds the Info.plist texts and Android
109
+ * permissions.
109
110
  */
110
111
  permissions?: {
111
112
  camera?: string | true;
112
113
  microphone?: string | true;
113
114
  location?: string | true;
115
+ speech?: string | true;
114
116
  };
115
117
  /**
116
118
  * Over-the-air updates (UP-2 web bundles on iOS / Android, UP-1 app updates on macOS), used by
@@ -190,6 +192,8 @@ export interface AkanNativeConfig {
190
192
  * and those the usage texts ask for (the camera's, the microphone's). Read when the app is signed with a team.
191
193
  */
192
194
  entitlements?: Record<string, NativeValue>;
195
+ /** Info.plist entries, such as usage texts in the app's language. Keys akan-native owns cannot be set. */
196
+ infoPlist?: Record<string, NativeValue>;
193
197
  };
194
198
  android?: {
195
199
  /** XML at the <manifest> level (uses-permission, queries, …). ${applicationId} is replaced. */
@@ -1,4 +1,4 @@
1
- export declare const PERMISSION_NAMES: readonly ["camera", "microphone", "location"];
1
+ export declare const PERMISSION_NAMES: readonly ["camera", "microphone", "location", "speech"];
2
2
  export type PermissionName = (typeof PERMISSION_NAMES)[number];
3
3
  /** `true` uses a generic usage text; a string is the text iOS and macOS show. */
4
4
  export type PermissionsConfig = Partial<Record<PermissionName, string | true>>;
@@ -166,17 +166,19 @@ export interface ManifestRelease {
166
166
  }
167
167
  /**
168
168
  * A pack's manifest template made the manifest of one release. Refuses what no app would take: a channel none could
169
- * be configured for, a sequence or a bundle id that is not one, a revocation list a manifest may not hold.
169
+ * be configured for, a sequence or a bundle id that is not one, a desktop sequence not past its app's build, a
170
+ * revocation list a manifest may not hold.
170
171
  */
171
172
  export declare function fillManifest(template: UpdateManifest, release: ManifestRelease): UpdateManifest;
172
173
  /** A manifest's exact bytes as `update publish` writes them: what the signature is over and the envelope holds. */
173
174
  export declare function manifestBytes(manifest: UpdateManifest): Uint8Array;
174
175
  /**
175
176
  * The envelope of manifest bytes signed elsewhere (a key service, a host that signs in process): `signature` is Ed25519
176
- * over `bytes` by the private half of `publicKey`. Verified as an app verifies it before it is returned, so another
177
- * key's signature, or one over other bytes, is refused here and not by every installed app.
177
+ * over `bytes` by the private half of `publicKey`, one of `publicKeys` (the config's `updates.publicKeys`). Verified as
178
+ * an app verifies it before it is returned, so a key the apps do not trust, another key's signature, or one over other
179
+ * bytes, is refused here and not by every installed app.
178
180
  */
179
- export declare function updateEnvelope(bytes: Uint8Array, publicKey: string, signature: string | Uint8Array): UpdateEnvelope;
181
+ export declare function updateEnvelope(bytes: Uint8Array, publicKey: string, signature: string | Uint8Array, publicKeys: readonly string[]): UpdateEnvelope;
180
182
  /** Verifies like the apps do: raw public key, base64 signature over the exact manifest bytes. */
181
183
  export declare function verifyManifest(bytes: Uint8Array, signature: string, publicKey: string): boolean;
182
184
  export declare const sha256: (data: Uint8Array | string) => string;
@@ -17,6 +17,8 @@ export declare function resourcesOf(os: DesktopOs, artifact: string): string;
17
17
  * carry along, and a read-only install could not hold).
18
18
  */
19
19
  export declare function cargoTargetDir(): string;
20
+ /** The paths and contents of the shell's sources. */
21
+ export declare function shellSourceDigest(dir?: string): string;
20
22
  /** Builds (incrementally) the Rust cdylib and returns its path. */
21
23
  export declare function buildNativeLibrary(os: DesktopOs, release: boolean, arch?: DesktopArch): Promise<string>;
22
24
  /**
@@ -1,8 +1,13 @@
1
1
  import type { ParsedArgs } from "../lib/args.ts";
2
- import type { Launched, LaunchOptions } from "../lib/launch.ts";
2
+ import { type Launched, type LaunchOptions } from "../lib/launch.ts";
3
+ import { type PlistValue } from "../lib/plist.ts";
3
4
  import type { BuildContext } from "../lib/prepare.ts";
5
+ import type { Project } from "../lib/project.ts";
4
6
  export declare const MACOS_MIN = "26.0";
5
7
  export declare function buildMacos(ctx: BuildContext): Promise<string>;
8
+ /** shell.json `signing`: secure-storage keeps its items in-process only under a team's signature. */
9
+ /** The usage texts of the plugins and app permissions, with usageDescriptions' texts, then native.macos.infoPlist. */
10
+ export declare function macosInfoPlistEntries({ config, plugins, }: Pick<Project, "config" | "plugins">): Record<string, PlistValue>;
6
11
  /**
7
12
  * Mach-O files the app carries in its server and its `bin`, whatever their names (native addons, executables, a
8
13
  * package's own executable): nested code the bundle's signature does not sign.
@@ -0,0 +1,7 @@
1
+ import { type Launched, type LaunchOptions } from "../lib/launch.ts";
2
+ export declare function finderEnv(extra: Record<string, string>, from?: NodeJS.ProcessEnv): Record<string, string>;
3
+ export declare function pidsOf(psOutput: string, exe: string): number[];
4
+ export declare function tailLines(path: string, onLine: (line: string) => void, intervalMs?: number): {
5
+ stop(): void;
6
+ };
7
+ export declare function launchThroughLaunchServices(appPath: string, exe: string, opts: LaunchOptions): Launched;
@@ -55,11 +55,12 @@ export declare const REAP_GRACE = 2000;
55
55
  export declare function appBinFirst(resources: string): string | null;
56
56
  /**
57
57
  * `name` in `dirs`, the first hit. Windows tries each PATHEXT ending unless the name already has one of them. A name
58
- * with a folder in it is looked up as that path alone.
58
+ * with a folder in it is looked up as that path alone, from `cwd` (this process's by default).
59
59
  */
60
- export declare function findCommand(name: string, dirs: readonly string[], { platform, pathExt }?: {
60
+ export declare function findCommand(name: string, dirs: readonly string[], { platform, pathExt, cwd }?: {
61
61
  platform?: NodeJS.Platform;
62
62
  pathExt?: string;
63
+ cwd?: string;
63
64
  }): ResolvedCommand | null;
64
65
  /**
65
66
  * A command line cmd.exe hands to a batch file unchanged: each argument quoted as CommandLineToArgvW reads it, then
@@ -67,7 +68,10 @@ export declare function findCommand(name: string, dirs: readonly string[], { pla
67
68
  * (`node "%~dp0\…" %*`) puts through cmd.exe again.
68
69
  */
69
70
  export declare function batchCommandLine(file: string, args: readonly string[]): string;
70
- /** The user's shell's PATH: as an interactive login shell first, then as a login shell only; null when neither told. */
71
+ /**
72
+ * The user's shell's PATH: as an interactive login shell first, then as a login shell only, both within one `timeout`;
73
+ * null when neither told.
74
+ */
71
75
  export declare function loginShellPath(env: Record<string, string | undefined>, { shell, timeout }?: {
72
76
  shell?: string;
73
77
  timeout?: number;
@@ -18,6 +18,10 @@ export declare const SETUP_WAIT_MS = 5000;
18
18
  export interface HostServices {
19
19
  app: AppInfo;
20
20
  dev?: boolean;
21
+ devServer?: {
22
+ url: string;
23
+ startPath: string;
24
+ } | null;
21
25
  appDataDir: string;
22
26
  /** paths.ts appLocalDataDir; appDataDir when not given. */
23
27
  appLocalDataDir?: string;
@@ -45,6 +49,7 @@ export interface HostServices {
45
49
  /** security.shell.externalSchemes from shell.json (L0). */
46
50
  externalSchemes?: readonly string[];
47
51
  openLinks?(args: readonly string[]): void;
52
+ openedUrls?(): Promise<string[]>;
48
53
  quit?(code: number): void;
49
54
  /** Quit and close sequence (lifecycle.ts). Without it, quit() ends the app at once and nothing can veto. */
50
55
  lifecycle?: Lifecycle;
@@ -74,6 +74,10 @@ export declare const SYMBOLS: {
74
74
  readonly args: readonly ["u64", "ptr"];
75
75
  readonly returns: "void";
76
76
  };
77
+ readonly akan_native_launch_urls: {
78
+ readonly args: readonly ["u32", "ptr", "u64"];
79
+ readonly returns: "u64";
80
+ };
77
81
  };
78
82
  export declare function openNative(libPath: string): import("bun:ffi").Library<{
79
83
  readonly akan_native_abi: {
@@ -132,9 +136,14 @@ export declare function openNative(libPath: string): import("bun:ffi").Library<{
132
136
  readonly args: readonly ["u64", "ptr"];
133
137
  readonly returns: "void";
134
138
  };
139
+ readonly akan_native_launch_urls: {
140
+ readonly args: readonly ["u32", "ptr", "u64"];
141
+ readonly returns: "u64";
142
+ };
135
143
  }>;
136
144
  /** The native library's last error (akan_native_last_error), or "". */
137
145
  export declare function lastError(lib: NativeLib): string;
146
+ export declare function launchUrls(lib: NativeLib, timeoutMs: number): string[];
138
147
  export type NativeLib = ReturnType<typeof openNative>;
139
148
  /** NUL-terminated UTF-8. Native code copies it during the call, so it may be collected afterwards. */
140
149
  export declare const cstr: (text: string) => Uint8Array<ArrayBuffer>;
@@ -34,7 +34,8 @@ export declare function serverDataDir(id: string, dev: boolean, platform?: NodeJ
34
34
  /**
35
35
  * Folders whose files no FileRef may serve (L4): the shell's and the plugins' own storage
36
36
  * (preferences, secure storage, databases, update bundles, window state, the webview's data, the server's). Only
37
- * the filesystem plugin's `data` base (<app data>/files) is servable inside the app data folder.
37
+ * the filesystem plugin's bases are servable inside them: `data` (<app data>/files) and, on Windows, `cache`
38
+ * (<local app data>/files).
38
39
  */
39
40
  export declare function reservedDirs(id: string, platform?: NodeJS.Platform, env?: Env, home?: string): {
40
41
  root: string;
@@ -19,6 +19,11 @@ export interface DesktopContext {
19
19
  * start). It has the release app's id, so what it keeps apart goes in folders of its own.
20
20
  */
21
21
  readonly dev: boolean;
22
+ /** A dev build's bundle holds only index.html: pages and public/ files come from this server, asked with startPath's query. */
23
+ readonly devServer: {
24
+ url: string;
25
+ startPath: string;
26
+ } | null;
22
27
  /**
23
28
  * The window whose page made this call (SH-6; 1 = the window the app opened). Only in method
24
29
  * calls; undefined in setup and event sources.
@@ -70,7 +75,8 @@ export interface DesktopContext {
70
75
  /**
71
76
  * Starts a program the user installed (or one in binDir) as a child that ends with the app however the app ends, a
72
77
  * crash or a kill included; with `document: ctx.document`, also when the calling page does. A bare name is looked up
73
- * as resolveCommand does, on the PATH the child gets. Rejects NOT_FOUND when there is no such program.
78
+ * as resolveCommand does, on the PATH the child gets, and a relative path (`./tool`) from `options.cwd`. Rejects
79
+ * NOT_FOUND when there is no such program.
74
80
  */
75
81
  spawn(cmd: string[], options?: DesktopSpawnOptions): Promise<DesktopProcess>;
76
82
  /**
@@ -143,6 +149,8 @@ export interface DesktopContext {
143
149
  * time quits the app instead, since its window exists by then.
144
150
  */
145
151
  exit(code?: number): void;
152
+ /** macOS delivers a launch's links as events, never arguments, so a launch that exits before its window waits for them. */
153
+ openedUrls(): Promise<string[]>;
146
154
  };
147
155
  }
148
156
  /**
@@ -12,12 +12,14 @@
12
12
  * - Windows: every window's taskbar button. setBadge draws the label on a red disc as the overlay
13
13
  * icon (counts over 99 as "99+", other labels longer than 2 characters as a plain disc),
14
14
  * setProgress is the button's progress bar in the same three colors, setVisible(false) takes
15
- * the buttons away (policy "accessory"; the windows stay in Alt+Tab).
15
+ * the buttons away (policy "accessory"; the windows stay in Alt+Tab), and setVisible(true)
16
+ * gives none to a window created with skipTaskbar.
16
17
  * - Linux: the launcher entry of the desktop file "<app id>.desktop" (the Unity LauncherEntry
17
18
  * API, which Ubuntu's dock, Dash to Dock and KDE Plasma show): setBadge takes whole numbers
18
19
  * only (other labels reject UNSUPPORTED), setProgress draws paused and error like normal, and
19
- * setVisible(false) sets the windows' skip-taskbar hint. Nothing shows until the app is
20
- * installed with a desktop file of that name; the state is kept meanwhile.
20
+ * setVisible(false) sets the windows' skip-taskbar hint (setVisible(true) leaves it on a window
21
+ * created with skipTaskbar). Nothing shows until the app is installed with a desktop file of
22
+ * that name; the state is kept meanwhile.
21
23
  * - Web, iOS and Android: UNSUPPORTED.
22
24
  */
23
25
  export type DockProgressState = "normal" | "paused" | "error";
@@ -5,10 +5,10 @@
5
5
  * with the app's name). Until setAppMenu is called the app has the default menu: App, Edit and
6
6
  * Window (D1). Keep an Edit menu (role "editMenu" or its items): without it Cmd+C/V/X/A do
7
7
  * nothing in the page.
8
- * - Windows and Linux: a menu bar in every window, from the same item tree (the bar holds only
9
- * submenus there too, so one tree fits every OS). No menu bar until setAppMenu, and
10
- * getAppMenu() is [] then: the webview handles Ctrl+C/V itself. CmdOrCtrl is Ctrl; Cmd is the
11
- * Windows (Super) key, which Windows menus show but cannot fire.
8
+ * - Windows and Linux: a menu bar in every window but an auxiliary one, from the same item
9
+ * tree (the bar holds only submenus there too, so one tree fits every OS). No menu bar until
10
+ * setAppMenu, and getAppMenu() is [] then: the webview handles Ctrl+C/V itself.
11
+ * CmdOrCtrl is Ctrl; Cmd is the Windows (Super) key, which Windows menus show but cannot fire.
12
12
  * Roles: appMenu is a "File" menu with About and Exit (Windows) or Quit (Linux); editMenu,
13
13
  * windowMenu (Minimize, Maximize, Full Screen, Close) and helpMenu (only with items) are the
14
14
  * usual menus. about shows a small About box, quit asks the app to quit as Cmd+Q does, the
@@ -53,13 +53,14 @@ type Lock = {
53
53
  * and every later launch would hand its message to nobody and exit.
54
54
  */
55
55
  export declare function lockFile(path: string): Lock;
56
+ export type Handover = SecondInstance | (() => Promise<SecondInstance>);
56
57
  /**
57
58
  * Becomes the running instance, or hands `message` to the one that is.
58
59
  * A running instance that does not acknowledge within `timeoutMs` (hung) still counts:
59
60
  * starting a second window next to it is what the plugin exists to prevent.
60
61
  */
61
- export declare function claim(path: string, message: SecondInstance, onMessage: (m: SecondInstance) => void, timeoutMs?: number): Promise<Claim>;
62
- export declare function claimPipe(path: string, message: SecondInstance, onMessage: (m: SecondInstance) => void, timeoutMs: number, hold?: (path: string) => HeldPipe | null, account?: () => string | null): Promise<Claim>;
62
+ export declare function claim(path: string, message: Handover, onMessage: (m: SecondInstance) => void, timeoutMs?: number): Promise<Claim>;
63
+ export declare function claimPipe(path: string, message: Handover, onMessage: (m: SecondInstance) => void, timeoutMs: number, hold?: (path: string) => HeldPipe | null, account?: () => string | null): Promise<Claim>;
63
64
  /** The lock and socket need a folder of this user's alone: another user's could block the app or read its arguments. */
64
65
  export declare function privateFolder(dir: string, uid?: number): string | Error;
65
66
  export {};
@@ -1,3 +1,5 @@
1
+ import { type DesktopContext } from "../../../packages/desktop/src/plugin.ts";
1
2
  import type { TrayApi, TrayEvents } from "./index.ts";
3
+ export declare function devIcon(icon: unknown, ctx: Pick<DesktopContext, "devServer" | "registerFile" | "onQuit">): Promise<unknown>;
2
4
  declare const _default: import("../../../packages/desktop/src/plugin.ts").DesktopPlugin<TrayApi, TrayEvents>;
3
5
  export default _default;
@@ -5,5 +5,6 @@ import type { DragDropEvent, PlaceOnDisplayOptions, WindowApi, WindowEvents } fr
5
5
  export declare function droppedFiles(ctx: Pick<DesktopContext, "registerFile">, paths: string[]): NonNullable<DragDropEvent["files"]>;
6
6
  export declare function displayOf(displays: Display[], args: PlaceOnDisplayOptions | undefined): Display;
7
7
  export declare function placement(display: Display, args: PlaceOnDisplayOptions | undefined): Record<string, unknown>;
8
+ export declare function devPath(path: string, devServer: DesktopContext["devServer"]): string;
8
9
  declare const _default: import("../../../packages/desktop/src/plugin.ts").DesktopPlugin<WindowApi, WindowEvents>;
9
10
  export default _default;