akanjs 3.0.0-beta.27 → 3.0.0-beta.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/base/baseEnv.ts +19 -5
- package/client/device.ts +22 -6
- package/client/index.ts +1 -0
- package/client/native/accessibility.ts +1 -0
- package/client/native/app-state.ts +1 -0
- package/client/native/app.ts +1 -0
- package/client/native/appearance.ts +1 -0
- package/client/native/auth-session.ts +1 -0
- package/client/native/autostart.ts +1 -0
- package/client/native/badge.ts +1 -0
- package/client/native/biometric.ts +1 -0
- package/client/native/browser.ts +1 -0
- package/client/native/camera.ts +1 -0
- package/client/native/clipboard.ts +1 -0
- package/client/native/contacts.ts +1 -0
- package/client/native/device.ts +1 -0
- package/client/native/dialog.ts +1 -0
- package/client/native/dock.ts +1 -0
- package/client/native/file-picker.ts +1 -0
- package/client/native/filesystem.ts +1 -0
- package/client/native/geolocation.ts +1 -0
- package/client/native/global-shortcut.ts +1 -0
- package/client/native/haptics.ts +1 -0
- package/client/native/http.ts +1 -0
- package/client/native/iap.ts +1 -0
- package/client/native/keep-awake.ts +1 -0
- package/client/native/keyboard.ts +1 -0
- package/client/native/local-notifications.ts +1 -0
- package/client/native/menu.ts +1 -0
- package/client/native/network.ts +1 -0
- package/client/native/opener.ts +1 -0
- package/client/native/preferences.ts +1 -0
- package/client/native/push.ts +1 -0
- package/client/native/screen-orientation.ts +1 -0
- package/client/native/screen.ts +1 -0
- package/client/native/secure-storage.ts +1 -0
- package/client/native/share.ts +1 -0
- package/client/native/single-instance.ts +1 -0
- package/client/native/splash-screen.ts +1 -0
- package/client/native/sqlite.ts +1 -0
- package/client/native/toast.ts +1 -0
- package/client/native/tray.ts +1 -0
- package/client/native/updates.ts +1 -0
- package/client/native/volume.ts +1 -0
- package/client/native/window-state.ts +1 -0
- package/client/native/window.ts +1 -0
- package/client/native.ts +31 -1
- package/client/resolveServerUrl.ts +11 -0
- package/client/router.ts +8 -0
- package/index.ts +115 -6
- package/native/desktop.ts +5 -0
- package/package.json +11 -1
- package/server/akanApp.ts +23 -3
- package/server/akanAppHeaders.ts +4 -1
- package/server/akanServer.ts +27 -7
- package/server/index.ts +1 -0
- package/server/lifecycle/orphanGroup.ts +21 -0
- package/server/nativeFile.ts +107 -0
- package/server/ops/opsRoute.ts +3 -2
- package/server/routing/apiRouter.ts +26 -3
- package/server/routing/hostAllowlist.ts +24 -0
- package/server/selfExec.ts +25 -0
- package/server/types.tsx +3 -1
- package/server/webRouter.ts +7 -4
- package/service/ipcTypes.ts +4 -0
- package/signal/CrossSiteGuard.ts +7 -0
- package/test/signalTestRuntime.ts +8 -2
- package/types/base/baseEnv.d.ts +1 -0
- package/types/client/index.d.ts +1 -0
- package/types/client/native/accessibility.d.ts +1 -0
- package/types/client/native/app-state.d.ts +1 -0
- package/types/client/native/app.d.ts +1 -0
- package/types/client/native/appearance.d.ts +1 -0
- package/types/client/native/auth-session.d.ts +1 -0
- package/types/client/native/autostart.d.ts +1 -0
- package/types/client/native/badge.d.ts +1 -0
- package/types/client/native/biometric.d.ts +1 -0
- package/types/client/native/browser.d.ts +1 -0
- package/types/client/native/camera.d.ts +1 -0
- package/types/client/native/clipboard.d.ts +1 -0
- package/types/client/native/contacts.d.ts +1 -0
- package/types/client/native/device.d.ts +1 -0
- package/types/client/native/dialog.d.ts +1 -0
- package/types/client/native/dock.d.ts +1 -0
- package/types/client/native/file-picker.d.ts +1 -0
- package/types/client/native/filesystem.d.ts +1 -0
- package/types/client/native/geolocation.d.ts +1 -0
- package/types/client/native/global-shortcut.d.ts +1 -0
- package/types/client/native/haptics.d.ts +1 -0
- package/types/client/native/http.d.ts +1 -0
- package/types/client/native/iap.d.ts +1 -0
- package/types/client/native/keep-awake.d.ts +1 -0
- package/types/client/native/keyboard.d.ts +1 -0
- package/types/client/native/local-notifications.d.ts +1 -0
- package/types/client/native/menu.d.ts +1 -0
- package/types/client/native/network.d.ts +1 -0
- package/types/client/native/opener.d.ts +1 -0
- package/types/client/native/preferences.d.ts +1 -0
- package/types/client/native/push.d.ts +1 -0
- package/types/client/native/screen-orientation.d.ts +1 -0
- package/types/client/native/screen.d.ts +1 -0
- package/types/client/native/secure-storage.d.ts +1 -0
- package/types/client/native/share.d.ts +1 -0
- package/types/client/native/single-instance.d.ts +1 -0
- package/types/client/native/splash-screen.d.ts +1 -0
- package/types/client/native/sqlite.d.ts +1 -0
- package/types/client/native/toast.d.ts +1 -0
- package/types/client/native/tray.d.ts +1 -0
- package/types/client/native/updates.d.ts +1 -0
- package/types/client/native/volume.d.ts +1 -0
- package/types/client/native/window-state.d.ts +1 -0
- package/types/client/native/window.d.ts +1 -0
- package/types/client/native.d.ts +14 -2
- package/types/client/resolveServerUrl.d.ts +1 -0
- package/types/client/router.d.ts +3 -0
- package/types/index.d.ts +112 -6
- package/types/native/desktop.d.ts +3 -0
- package/types/server/akanAppHeaders.d.ts +2 -0
- package/types/server/index.d.ts +1 -0
- package/types/server/lifecycle/orphanGroup.d.ts +7 -0
- package/types/server/nativeFile.d.ts +10 -0
- package/types/server/routing/apiRouter.d.ts +3 -1
- package/types/server/routing/hostAllowlist.d.ts +8 -0
- package/types/server/selfExec.d.ts +8 -0
- package/types/server/types.d.ts +3 -1
- package/types/service/ipcTypes.d.ts +16 -0
- package/types/signal/CrossSiteGuard.d.ts +1 -0
- package/types/ui/recipe/buttonRecipe.d.ts +2 -2
- package/types/vendor/@akanjs/native/packages/cli/src/api.d.ts +57 -4
- package/types/vendor/@akanjs/native/packages/cli/src/config.d.ts +48 -0
- package/types/vendor/@akanjs/native/packages/cli/src/lib/desktop-server.d.ts +8 -0
- package/types/vendor/@akanjs/native/packages/cli/src/lib/prepare.d.ts +8 -2
- package/types/vendor/@akanjs/native/packages/cli/src/lib/project.d.ts +10 -0
- package/types/vendor/@akanjs/native/packages/cli/src/lib/publish.d.ts +24 -0
- package/types/vendor/@akanjs/native/packages/cli/src/lib/updates.d.ts +24 -0
- package/types/vendor/@akanjs/native/packages/cli/src/platforms/desktop-update.d.ts +4 -1
- package/types/vendor/@akanjs/native/packages/cli/src/platforms/macos.d.ts +5 -0
- package/types/vendor/@akanjs/native/packages/cli/src/platforms/windows-installer.d.ts +38 -0
- package/types/vendor/@akanjs/native/packages/desktop/src/dispatcher.d.ts +8 -1
- package/types/vendor/@akanjs/native/packages/desktop/src/grants.d.ts +11 -0
- package/types/vendor/@akanjs/native/packages/desktop/src/main.d.ts +11 -0
- package/types/vendor/@akanjs/native/packages/desktop/src/paths.d.ts +13 -2
- package/types/vendor/@akanjs/native/packages/desktop/src/plugin.d.ts +27 -0
- package/types/vendor/@akanjs/native/packages/desktop/src/relaunch.d.ts +21 -0
- package/types/vendor/@akanjs/native/packages/desktop/src/server.d.ts +79 -0
- package/types/vendor/@akanjs/native/plugins/app/src/index.d.ts +5 -0
- package/types/vendor/@akanjs/native/plugins/file-picker/src/index.d.ts +20 -1
- package/types/vendor/@akanjs/native/plugins/push/src/index.d.ts +9 -0
- package/types/vendor/@akanjs/native/plugins/updates/src/desktop.d.ts +28 -0
- package/types/vendor/@akanjs/native/plugins/volume/src/common.d.ts +10 -0
- package/types/vendor/@akanjs/native/plugins/volume/src/desktop.d.ts +18 -0
- package/types/vendor/@akanjs/native/plugins/volume/src/index.d.ts +28 -0
- package/types/vendor/@akanjs/native/plugins/volume/src.d.ts +1 -0
- package/types/webkit/csrFrameDump.d.ts +42 -0
- package/types/webkit/nativeNavigation.d.ts +1 -0
- package/types/webkit/nativePurchase.d.ts +6 -2
- package/types/webkit/nativeUpdates.d.ts +8 -0
- package/ui/Agent/Attach.tsx +6 -2
- package/ui/CsrImage.tsx +3 -2
- package/ui/System/CSR.tsx +4 -0
- package/vendor/@akanjs/native/native/android/src/com/akanjs/runtime/AkanNativeActivity.kt +2 -0
- package/vendor/@akanjs/native/native/desktop/Cargo.toml +1 -1
- package/vendor/@akanjs/native/native/desktop/src/lib.rs +161 -25
- package/vendor/@akanjs/native/native/desktop/src/volume.rs +184 -0
- package/vendor/@akanjs/native/native/desktop/src/win/mod.rs +3 -1
- package/vendor/@akanjs/native/native/desktop/src/win/volume.rs +71 -0
- package/vendor/@akanjs/native/packages/cli/src/api.ts +142 -12
- package/vendor/@akanjs/native/packages/cli/src/commands/build.ts +5 -3
- package/vendor/@akanjs/native/packages/cli/src/commands/update.ts +10 -71
- package/vendor/@akanjs/native/packages/cli/src/config.ts +41 -0
- package/vendor/@akanjs/native/packages/cli/src/lib/configkeys.ts +9 -2
- package/vendor/@akanjs/native/packages/cli/src/lib/desktop-server.ts +58 -0
- package/vendor/@akanjs/native/packages/cli/src/lib/hmr.ts +2 -0
- package/vendor/@akanjs/native/packages/cli/src/lib/prepare.ts +10 -2
- package/vendor/@akanjs/native/packages/cli/src/lib/project.ts +38 -2
- package/vendor/@akanjs/native/packages/cli/src/lib/publish.ts +104 -0
- package/vendor/@akanjs/native/packages/cli/src/lib/updates.ts +85 -5
- package/vendor/@akanjs/native/packages/cli/src/platforms/android.ts +1 -0
- package/vendor/@akanjs/native/packages/cli/src/platforms/desktop-update.ts +6 -4
- package/vendor/@akanjs/native/packages/cli/src/platforms/desktop.ts +16 -0
- package/vendor/@akanjs/native/packages/cli/src/platforms/macos.ts +44 -1
- package/vendor/@akanjs/native/packages/cli/src/platforms/windows-installer.ts +436 -0
- package/vendor/@akanjs/native/packages/cli/src/platforms/windows.ts +2 -0
- package/vendor/@akanjs/native/packages/desktop/src/dispatcher.ts +20 -0
- package/vendor/@akanjs/native/packages/desktop/src/grants.ts +47 -0
- package/vendor/@akanjs/native/packages/desktop/src/host.ts +97 -11
- package/vendor/@akanjs/native/packages/desktop/src/main.ts +59 -11
- package/vendor/@akanjs/native/packages/desktop/src/paths.ts +38 -4
- package/vendor/@akanjs/native/packages/desktop/src/plugin.ts +28 -0
- package/vendor/@akanjs/native/packages/desktop/src/relaunch.ts +159 -0
- package/vendor/@akanjs/native/packages/desktop/src/server.ts +493 -0
- package/vendor/@akanjs/native/plugins/app/android/AppPlugin.kt +14 -0
- package/vendor/@akanjs/native/plugins/app/native-plugin.json +2 -2
- package/vendor/@akanjs/native/plugins/app/src/desktop.ts +5 -0
- package/vendor/@akanjs/native/plugins/app/src/index.ts +6 -1
- package/vendor/@akanjs/native/plugins/app/src/web.ts +3 -0
- package/vendor/@akanjs/native/plugins/file-picker/src/desktop.ts +39 -2
- package/vendor/@akanjs/native/plugins/file-picker/src/index.ts +36 -1
- package/vendor/@akanjs/native/plugins/push/android/PushPlugin.kt +9 -1
- package/vendor/@akanjs/native/plugins/push/ios/PushPlugin.swift +4 -0
- package/vendor/@akanjs/native/plugins/push/src/index.ts +10 -0
- package/vendor/@akanjs/native/plugins/updates/src/desktop.ts +464 -452
- package/vendor/@akanjs/native/plugins/volume/android/VolumePlugin.kt +107 -0
- package/vendor/@akanjs/native/plugins/volume/native-plugin.json +14 -0
- package/vendor/@akanjs/native/plugins/volume/src/common.ts +28 -0
- package/vendor/@akanjs/native/plugins/volume/src/desktop.ts +185 -0
- package/vendor/@akanjs/native/plugins/volume/src/index.ts +32 -0
- package/webkit/RenderLayer.tsx +71 -6
- package/webkit/csrFrameDump.ts +67 -0
- package/webkit/nativeNavigation.ts +17 -0
- package/webkit/nativePurchase.ts +12 -2
- package/webkit/nativeUpdates.ts +55 -0
- package/webkit/useCsrValues.ts +27 -0
|
@@ -2,11 +2,12 @@ import { type DoctorCheck } from "./commands/doctor.ts";
|
|
|
2
2
|
import type { AkanNativeConfig } from "./config.ts";
|
|
3
3
|
import type { Device, DeviceSelector } from "./lib/launch.ts";
|
|
4
4
|
import { type LogEvent, type LogSink } from "./lib/log.ts";
|
|
5
|
-
import { type AndroidSigning, type BuildProfile, type IosBuild, type IosSigning, type IosSigningResult } from "./lib/prepare.ts";
|
|
5
|
+
import { type AndroidSigning, type BuildProfile, type IosBuild, type IosSigning, type IosSigningResult, type WindowsBuild } from "./lib/prepare.ts";
|
|
6
|
+
import { type UpdateManifest } from "./lib/updates.ts";
|
|
6
7
|
import { type TargetPlatform } from "./platforms/index.ts";
|
|
7
|
-
export type { AkanNativeConfig, AndroidSigning, Device, DeviceSelector, DoctorCheck, IosBuild, IosSigning, IosSigningResult, LogEvent, TargetPlatform, };
|
|
8
|
+
export type { AkanNativeConfig, AndroidSigning, Device, DeviceSelector, DoctorCheck, IosBuild, IosSigning, IosSigningResult, LogEvent, TargetPlatform, WindowsBuild, };
|
|
8
9
|
/** semver of this API. A caller checks the major before it relies on anything here. */
|
|
9
|
-
export declare const API_VERSION = "0.
|
|
10
|
+
export declare const API_VERSION = "0.8.0";
|
|
10
11
|
export type AkanNativeErrorCode = "CONFIG_INVALID" | "TOOLCHAIN_MISSING" | "WEB_INPUT_INVALID" | "WEB_BUILD_FAILED" | "NATIVE_BUILD_FAILED" | "SIGNING_FAILED" | "DEVICE_FAILED" | "CANCELLED" | "INTERNAL";
|
|
11
12
|
export declare class AkanNativeError extends Error {
|
|
12
13
|
readonly code: AkanNativeErrorCode;
|
|
@@ -50,7 +51,7 @@ export interface TaskOptions {
|
|
|
50
51
|
signal?: AbortSignal;
|
|
51
52
|
}
|
|
52
53
|
export interface Artifact {
|
|
53
|
-
kind: "app" | "apk" | "aab" | "ipa" | "folder" | "web";
|
|
54
|
+
kind: "app" | "apk" | "aab" | "ipa" | "folder" | "web" | "installer";
|
|
54
55
|
path: string;
|
|
55
56
|
signing: "none" | "adhoc" | "debug" | "development" | "distribution";
|
|
56
57
|
device?: "simulator" | "device";
|
|
@@ -87,6 +88,7 @@ export declare function validateConfig(config: AkanNativeConfig, options: {
|
|
|
87
88
|
export declare function build(options: TaskOptions & {
|
|
88
89
|
profile?: BuildProfile;
|
|
89
90
|
ios?: IosBuild;
|
|
91
|
+
windows?: WindowsBuild;
|
|
90
92
|
}): Promise<BuildResult>;
|
|
91
93
|
/**
|
|
92
94
|
* Store files: a release build signed for distribution. Android: the .aab (and, with formats, the
|
|
@@ -101,6 +103,57 @@ export declare function release(options: TaskOptions & ({
|
|
|
101
103
|
platform: "ios";
|
|
102
104
|
signing?: IosSigning;
|
|
103
105
|
})): Promise<BuildResult>;
|
|
106
|
+
/**
|
|
107
|
+
* An unsigned web bundle update (UP-2), for a signer that keeps the key off the build machine. Writes
|
|
108
|
+
* `<out>/files/<sha256>`, `<out>/manifest.template.json` (the manifest with `channel`, `sequence` and `bundle` left
|
|
109
|
+
* empty for the signer) and `<out>/bundle.json` (the native API the bundle needs, UP-3). Prepares the web bundle as a
|
|
110
|
+
* release build does, without building the native app.
|
|
111
|
+
*/
|
|
112
|
+
export declare function packUpdate(options: TaskOptions & {
|
|
113
|
+
platform: "ios" | "android";
|
|
114
|
+
out: string;
|
|
115
|
+
}): Promise<{
|
|
116
|
+
manifest: UpdateManifest;
|
|
117
|
+
out: string;
|
|
118
|
+
}>;
|
|
119
|
+
export interface PublishResult {
|
|
120
|
+
build: BuildResult;
|
|
121
|
+
/** `<out>/<os>-<arch>` (desktop) or `<out>/<platform>` (a phone's web bundle): what to upload under updates.url. */
|
|
122
|
+
dir: string;
|
|
123
|
+
bundle: string;
|
|
124
|
+
channel: string;
|
|
125
|
+
files: number;
|
|
126
|
+
/** Bytes of the files the manifest names. */
|
|
127
|
+
size: number;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* A signed release for the updates plugin (UP-1, UP-2): a release build, then `<channel>.json`, its signature and
|
|
131
|
+
* its files under `out` (default <appDir>/.akan/native/updates), signed with the key updateKeygen() made.
|
|
132
|
+
*/
|
|
133
|
+
export declare function publishUpdate(options: TaskOptions & {
|
|
134
|
+
platform: Exclude<TargetPlatform, "web">;
|
|
135
|
+
channel?: string;
|
|
136
|
+
out?: string;
|
|
137
|
+
}): Promise<PublishResult>;
|
|
138
|
+
/**
|
|
139
|
+
* Whether a web bundle can run in the binary a store release shipped (UP-3): `shipped` is that build's bundle.json,
|
|
140
|
+
* `bundle` the one `packUpdate` wrote. Anything in `problems` means a new binary.
|
|
141
|
+
*/
|
|
142
|
+
export declare function compareBundles(shipped: string, bundle: string): {
|
|
143
|
+
compatible: boolean;
|
|
144
|
+
problems: string[];
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* The app's update signing key: made once (AKAN_NATIVE_UPDATE_KEY, else ~/.akan/native/keys/<app id>.update.key),
|
|
148
|
+
* then read. `publicKey` goes into the config's `updates.publicKey`; the key file never leaves the machine.
|
|
149
|
+
*/
|
|
150
|
+
export declare function updateKeygen(options: {
|
|
151
|
+
config: AkanNativeConfig;
|
|
152
|
+
}): {
|
|
153
|
+
publicKey: string;
|
|
154
|
+
keyPath: string;
|
|
155
|
+
created: boolean;
|
|
156
|
+
};
|
|
104
157
|
/** Builds (default profile debug) and launches the app on a simulator, emulator, desktop or browser. */
|
|
105
158
|
export declare function run(options: TaskOptions & {
|
|
106
159
|
profile?: BuildProfile;
|
|
@@ -192,6 +192,11 @@ export interface AkanNativeConfig {
|
|
|
192
192
|
* or APIs the bundle uses. Android 10+ devices with Google Play update WebView themselves.
|
|
193
193
|
*/
|
|
194
194
|
minWebViewVersion?: number;
|
|
195
|
+
/**
|
|
196
|
+
* Media plays with sound without a tap first, as it does on iOS and the desktop (WebView's
|
|
197
|
+
* mediaPlaybackRequiresUserGesture off): an app nobody taps, such as a signage screen. Default false.
|
|
198
|
+
*/
|
|
199
|
+
autoplay?: boolean;
|
|
195
200
|
/**
|
|
196
201
|
* Appended to app.id in debug builds (e.g. ".debug"), so a debug build installs next to the
|
|
197
202
|
* release app. Deep links and app links must list the suffixed id for debug builds.
|
|
@@ -245,6 +250,49 @@ export interface AkanNativeConfig {
|
|
|
245
250
|
* hides the window: the app keeps running, a Dock click shows it again, Cmd+Q quits. Default true.
|
|
246
251
|
*/
|
|
247
252
|
quitOnLastWindowClosed?: boolean;
|
|
253
|
+
/**
|
|
254
|
+
* What a window does when its page's web process ends: a crash, a hang, out of memory. "errorPage"
|
|
255
|
+
* (default) loads the page again once and shows an error page when it ends again within a minute, so a
|
|
256
|
+
* page that crashes on load does not loop; the app quits when the webview's browser process ends
|
|
257
|
+
* (Windows). "reload" loads it again every time, waiting longer after each end in a row (1 s, doubling
|
|
258
|
+
* to a minute), and relaunches the app when the browser process ends: an app nobody attends, such as a
|
|
259
|
+
* kiosk or a signage screen. iOS and Android always start the page over.
|
|
260
|
+
*/
|
|
261
|
+
recovery?: "errorPage" | "reload";
|
|
262
|
+
/**
|
|
263
|
+
* The main window from its first frame: `fullscreen` (borderless, on the display the window opens on)
|
|
264
|
+
* and `skipTaskbar` (no taskbar button; Windows and Linux). A plugin's launch phase may still decide
|
|
265
|
+
* otherwise (DesktopContext.launch.setWindow). Default false for both.
|
|
266
|
+
*/
|
|
267
|
+
window?: {
|
|
268
|
+
fullscreen?: boolean;
|
|
269
|
+
skipTaskbar?: boolean;
|
|
270
|
+
};
|
|
271
|
+
/**
|
|
272
|
+
* Windows: "auto" answers the page's getDisplayMedia() with the first screen at once, without the picker or a
|
|
273
|
+
* user gesture: a remote-support session on an unattended screen. It is Chromium's switch for automated media
|
|
274
|
+
* tests (--use-fake-ui-for-media-stream), made for every media request, so keep it to an app whose pages ask
|
|
275
|
+
* for no camera or microphone. Default "picker". WebView2's choice by title follows the UI language, so none is
|
|
276
|
+
* offered. macOS and Linux ignore it.
|
|
277
|
+
*/
|
|
278
|
+
screenCapture?: "picker" | "auto";
|
|
279
|
+
/**
|
|
280
|
+
* A server the app starts beside its window (akanjs `native.desktop.server`). `dir` is copied to
|
|
281
|
+
* the app's resources (`server/`), and `entry` there runs on the app's own Bun with `env`, bound to
|
|
282
|
+
* a loopback port picked at launch; the page reads its URL as PUBLIC_AKAN_SERVER_URL. The launcher
|
|
283
|
+
* sets PORT, JWT_SECRET, the data folders (`<app local data>/server`) and the listen host itself.
|
|
284
|
+
*/
|
|
285
|
+
server?: {
|
|
286
|
+
dir: string;
|
|
287
|
+
entry: string;
|
|
288
|
+
env?: Record<string, string>;
|
|
289
|
+
};
|
|
290
|
+
/**
|
|
291
|
+
* A folder of executables the app carries (akanjs `bin`): copied to the app's resources (`bin/`) and put
|
|
292
|
+
* first on the app's PATH at launch, so its plugins and its server find them by name before the computer's.
|
|
293
|
+
* macOS builds sign every Mach-O file in it.
|
|
294
|
+
*/
|
|
295
|
+
bin?: string;
|
|
248
296
|
};
|
|
249
297
|
/**
|
|
250
298
|
* App icon for every platform, generated from one square PNG, ideally 1024×1024 (CLI-8).
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AkanNativeConfig } from "../config.ts";
|
|
2
|
+
export interface DesktopServerConfig {
|
|
3
|
+
/** Absolute. */
|
|
4
|
+
dir: string;
|
|
5
|
+
entry: string;
|
|
6
|
+
env: Record<string, string>;
|
|
7
|
+
}
|
|
8
|
+
export declare function validateDesktopServer(desktop: AkanNativeConfig["desktop"], appDir: string, problems: string[]): DesktopServerConfig | null;
|
|
@@ -7,6 +7,9 @@ import { type Project } from "./project.ts";
|
|
|
7
7
|
* picks the .env files, so a staging build is still a release build.
|
|
8
8
|
*/
|
|
9
9
|
export type BuildProfile = "debug" | "release";
|
|
10
|
+
export interface WindowsBuild {
|
|
11
|
+
installer?: boolean;
|
|
12
|
+
}
|
|
10
13
|
export interface BuildOptions {
|
|
11
14
|
mode: string;
|
|
12
15
|
profile: BuildProfile;
|
|
@@ -38,6 +41,8 @@ export interface BuildOptions {
|
|
|
38
41
|
android?: AndroidRelease;
|
|
39
42
|
/** iOS devices (akanjs readiness O1-2, O1-3). */
|
|
40
43
|
ios?: IosBuild;
|
|
44
|
+
/** Windows: an NSIS setup program next to the app folder (platforms/windows-installer.ts). */
|
|
45
|
+
windows?: WindowsBuild;
|
|
41
46
|
}
|
|
42
47
|
/** Which identity and profile an iOS device build signs with; unset: found in the keychain and Xcode's profiles. */
|
|
43
48
|
export interface IosSigning {
|
|
@@ -111,9 +116,10 @@ export interface BuildContext {
|
|
|
111
116
|
startPath?: string;
|
|
112
117
|
android?: AndroidRelease;
|
|
113
118
|
ios?: IosBuild;
|
|
114
|
-
|
|
119
|
+
windows?: WindowsBuild;
|
|
120
|
+
/** Artifacts besides the one the builder returns (an .aab next to the .apk, a Windows setup program). */
|
|
115
121
|
artifacts: {
|
|
116
|
-
kind: "aab" | "ipa";
|
|
122
|
+
kind: "aab" | "ipa" | "installer";
|
|
117
123
|
path: string;
|
|
118
124
|
}[];
|
|
119
125
|
/** What the builder signed with, when it signs (Android: the app's release key or the debug key). */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AkanNativeConfig } from "../config.ts";
|
|
2
2
|
import { type PermissionSet } from "./acl.ts";
|
|
3
|
+
import { type DesktopServerConfig } from "./desktop-server.ts";
|
|
3
4
|
import { type EnvConfig } from "./env.ts";
|
|
4
5
|
import { CliError } from "./log.ts";
|
|
5
6
|
import { type PermissionsConfig } from "./permissions.ts";
|
|
@@ -28,6 +29,15 @@ export interface ResolvedConfig extends Omit<AkanNativeConfig, "icon" | "splash"
|
|
|
28
29
|
};
|
|
29
30
|
desktop: {
|
|
30
31
|
quitOnLastWindowClosed: boolean;
|
|
32
|
+
recovery: "errorPage" | "reload";
|
|
33
|
+
window: {
|
|
34
|
+
fullscreen: boolean;
|
|
35
|
+
skipTaskbar: boolean;
|
|
36
|
+
};
|
|
37
|
+
screenCapture: "picker" | "auto";
|
|
38
|
+
server?: DesktopServerConfig;
|
|
39
|
+
/** Absolute. */
|
|
40
|
+
bin?: string;
|
|
31
41
|
};
|
|
32
42
|
updates: UpdatesConfig | null;
|
|
33
43
|
/** Absolute image path. */
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { BuildContext } from "./prepare.ts";
|
|
2
|
+
import { type UpdateManifest } from "./updates.ts";
|
|
3
|
+
export type ReleasePlatform = "macos" | "windows" | "linux" | "ios" | "android";
|
|
4
|
+
export interface PublishedRelease {
|
|
5
|
+
/** `<out>/<os>-<arch>` for a desktop app, `<out>/<platform>` for a phone's web bundle. */
|
|
6
|
+
dir: string;
|
|
7
|
+
manifest: UpdateManifest;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The publish time in seconds, and past the release `<channel>.json` in `dir` already names: apps take only a larger
|
|
11
|
+
* sequence, so a clock behind the last publisher's would make this release look older to every one of them.
|
|
12
|
+
*/
|
|
13
|
+
export declare function nextSequence(dir: string, channel: string, now?: number): number;
|
|
14
|
+
/** Refuses before the build a release that could not be signed: no key on this machine, or another app's. */
|
|
15
|
+
export declare function assertSigningKey(config: {
|
|
16
|
+
app: {
|
|
17
|
+
id: string;
|
|
18
|
+
};
|
|
19
|
+
updates?: {
|
|
20
|
+
publicKey: string;
|
|
21
|
+
} | null;
|
|
22
|
+
}): void;
|
|
23
|
+
/** Writes the release of `artifact` (the app a release build made) and its signed `<channel>.json` under `out`. */
|
|
24
|
+
export declare function publishRelease(ctx: BuildContext, platform: ReleasePlatform, artifact: string, out: string, channel: string): Promise<PublishedRelease>;
|
|
@@ -53,6 +53,28 @@ export interface UpdateManifest {
|
|
|
53
53
|
size: number;
|
|
54
54
|
}[];
|
|
55
55
|
}
|
|
56
|
+
/** Every file of a web bundle as the app serves it: index.html with the init script and CSP, public/, env.runtime.json. */
|
|
57
|
+
export declare function webFiles(webDir: string, html: string, env: Record<string, string>): {
|
|
58
|
+
path: string;
|
|
59
|
+
data: Uint8Array;
|
|
60
|
+
}[];
|
|
61
|
+
/** Writes a web bundle's files under `<out>/files/<sha256>` (content-addressed, so releases share them) and lists them. */
|
|
62
|
+
export declare function writeWebBundle(out: string, webDir: string, html: string, env: Record<string, string>): UpdateFile[];
|
|
63
|
+
/** A web bundle's manifest (UP-2), keys in the order `update publish` has always written them. */
|
|
64
|
+
export declare function webManifest(release: {
|
|
65
|
+
app: {
|
|
66
|
+
id: string;
|
|
67
|
+
version: string;
|
|
68
|
+
};
|
|
69
|
+
platform: Platform;
|
|
70
|
+
channel: string;
|
|
71
|
+
nativeApi: string;
|
|
72
|
+
sequence: number;
|
|
73
|
+
bundle: string;
|
|
74
|
+
files: UpdateFile[];
|
|
75
|
+
}): UpdateManifest;
|
|
76
|
+
/** Refuses a channel no app could be configured for: it would be written but never taken. */
|
|
77
|
+
export declare function assertChannel(channel: string): void;
|
|
56
78
|
export declare function validateUpdates(raw: unknown, problems: string[]): UpdatesConfig | null;
|
|
57
79
|
/** Where the signing key of an app lives: AKAN_NATIVE_UPDATE_KEY (a file path), else ~/.akan/native/keys/<app id>.update.key. */
|
|
58
80
|
export declare function updateKeyPath(appId: string, env?: Record<string, string | undefined>): string;
|
|
@@ -61,6 +83,8 @@ export declare function generateUpdateKey(path: string): {
|
|
|
61
83
|
publicKey: string;
|
|
62
84
|
created: boolean;
|
|
63
85
|
};
|
|
86
|
+
/** The key at `keyPath`, refused unless it is the one whose public half the apps were built with. */
|
|
87
|
+
export declare function signingKey(keyPath: string, expectedPublicKey: string): import("node:crypto").KeyObject;
|
|
64
88
|
export declare function signManifest(bytes: Uint8Array, keyPath: string, expectedPublicKey: string): string;
|
|
65
89
|
/** Verifies like the apps do: raw public key, base64 signature over the exact manifest bytes. */
|
|
66
90
|
export declare function verifyManifest(bytes: Uint8Array, signature: string, publicKey: string): boolean;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { BuildContext } from "../lib/prepare.ts";
|
|
2
2
|
import { type UpdateManifest } from "../lib/updates.ts";
|
|
3
3
|
import { type DesktopOs } from "./desktop.ts";
|
|
4
|
-
export declare function publishAppUpdate(ctx: BuildContext, os: DesktopOs, app: string, out: string, channel: string, sequence: number): Promise<
|
|
4
|
+
export declare function publishAppUpdate(ctx: BuildContext, os: DesktopOs, app: string, out: string, channel: string, sequence: number): Promise<{
|
|
5
|
+
manifest: UpdateManifest;
|
|
6
|
+
superseded: string | null;
|
|
7
|
+
}>;
|
|
@@ -3,5 +3,10 @@ import type { Launched, LaunchOptions } from "../lib/launch.ts";
|
|
|
3
3
|
import type { BuildContext } from "../lib/prepare.ts";
|
|
4
4
|
export declare const MACOS_MIN = "26.0";
|
|
5
5
|
export declare function buildMacos(ctx: BuildContext): Promise<string>;
|
|
6
|
+
/**
|
|
7
|
+
* Mach-O files the app carries in its server and its `bin`, whatever their names (native addons, executables, a
|
|
8
|
+
* package's own executable): nested code the bundle's signature does not sign.
|
|
9
|
+
*/
|
|
10
|
+
export declare function carriedNativeCode(resources: string): string[];
|
|
6
11
|
export declare function launchMacos(ctx: BuildContext, appPath: string, opts: LaunchOptions): Promise<Launched>;
|
|
7
12
|
export declare function runMacos(ctx: BuildContext, appPath: string, args: ParsedArgs): Promise<number>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { BuildContext } from "../lib/prepare.ts";
|
|
2
|
+
/** Microsoft's permanent link to the Evergreen Bootstrapper (MicrosoftEdgeWebview2Setup.exe). */
|
|
3
|
+
export declare const WEBVIEW2_BOOTSTRAPPER_URL = "https://go.microsoft.com/fwlink/p/?LinkId=2124703";
|
|
4
|
+
/** MAX_PATH less its NUL: what a PC without long paths enabled (the Windows default) can open or unpack. */
|
|
5
|
+
export declare const WINDOWS_MAX_PATH = 259;
|
|
6
|
+
export interface InstallerInput {
|
|
7
|
+
name: string;
|
|
8
|
+
id: string;
|
|
9
|
+
exe: string;
|
|
10
|
+
version: string;
|
|
11
|
+
build: number;
|
|
12
|
+
/** The built app folder, copied whole. */
|
|
13
|
+
folder: string;
|
|
14
|
+
/** Its top-level files and folders: what an update or uninstall removes. */
|
|
15
|
+
entries: {
|
|
16
|
+
name: string;
|
|
17
|
+
dir: boolean;
|
|
18
|
+
}[];
|
|
19
|
+
icon?: string;
|
|
20
|
+
bootstrapper: string;
|
|
21
|
+
stopScript: string;
|
|
22
|
+
outFile: string;
|
|
23
|
+
}
|
|
24
|
+
export declare function installerScript(input: InstallerInput): string;
|
|
25
|
+
/**
|
|
26
|
+
* Stops every process running from the install folder, and waits (up to 10 s) until they are gone. Through
|
|
27
|
+
* WMI: the installer is a 32-bit program, so its PowerShell is too, and a 32-bit process cannot read a
|
|
28
|
+
* 64-bit one's path (Get-Process's Path comes back empty).
|
|
29
|
+
*/
|
|
30
|
+
export declare const STOP_SCRIPT = "param([string]$Dir)\n$prefix = [IO.Path]::GetFullPath($Dir).TrimEnd('\\') + '\\'\n$running = { Get-CimInstance Win32_Process | Where-Object { $_.ExecutablePath -and $_.ExecutablePath.StartsWith($prefix, [StringComparison]::OrdinalIgnoreCase) } }\n& $running | ForEach-Object { Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue }\nfor ($i = 0; $i -lt 50 -and (& $running); $i++) { Start-Sleep -Milliseconds 200 }\n";
|
|
31
|
+
/** The longest path under `folder`, relative and with Windows separators. Links are not followed. */
|
|
32
|
+
export declare function deepestPath(folder: string): string;
|
|
33
|
+
/** How long `relative` gets on a typical PC while an update unpacks, the longest it ever is: root, app, staging, app. */
|
|
34
|
+
export declare function installedPathLength(appName: string, relative: string): number;
|
|
35
|
+
/** makensis: AKAN_NATIVE_MAKENSIS, PATH, then where the NSIS installer puts it. */
|
|
36
|
+
export declare function findMakensis(env?: Record<string, string | undefined>): string | null;
|
|
37
|
+
/** Writes the setup program next to the app folder and answers its path. */
|
|
38
|
+
export declare function buildWindowsInstaller(ctx: BuildContext, folder: string): Promise<string>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AppInfo, FileRef, ResolvedAcl } from "../../core/src/index.ts";
|
|
2
2
|
import { type BridgeEvent, type BridgeRequest, type BridgeResponse } from "../../core/src/protocol.ts";
|
|
3
3
|
import type { Lifecycle } from "./lifecycle.ts";
|
|
4
|
-
import type { DesktopPlugin, Launch, NativeEvent } from "./plugin.ts";
|
|
4
|
+
import type { DesktopPlugin, DesktopServerStatus, Launch, NativeEvent } from "./plugin.ts";
|
|
5
5
|
/** How long the window waits for one plugin's setup. */
|
|
6
6
|
export declare const SETUP_TIMEOUT_MS = 3000;
|
|
7
7
|
/**
|
|
@@ -11,7 +11,14 @@ export declare const SETUP_TIMEOUT_MS = 3000;
|
|
|
11
11
|
export declare const SETUP_WAIT_MS = 5000;
|
|
12
12
|
export interface HostServices {
|
|
13
13
|
app: AppInfo;
|
|
14
|
+
dev?: boolean;
|
|
14
15
|
appDataDir: string;
|
|
16
|
+
/** paths.ts appLocalDataDir; appDataDir when not given. */
|
|
17
|
+
appLocalDataDir?: string;
|
|
18
|
+
/** desktop.bin in the app's resources, or null. */
|
|
19
|
+
binDir?: string | null;
|
|
20
|
+
/** The carried server (resources/server.json), or null. */
|
|
21
|
+
server?: DesktopServerStatus | null;
|
|
15
22
|
/** Sends an event (numbered for its document) to a window's page. */
|
|
16
23
|
emit(window: number, message: BridgeEvent): void;
|
|
17
24
|
/**
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type GrantMode = "read" | "write" | "folder";
|
|
2
|
+
export interface FileGrant {
|
|
3
|
+
path: string;
|
|
4
|
+
mode: GrantMode;
|
|
5
|
+
}
|
|
6
|
+
export declare function devGrantKeyFile(home?: string): string;
|
|
7
|
+
export declare function grantFile(path: string, mode: GrantMode, { dev }?: {
|
|
8
|
+
dev?: boolean;
|
|
9
|
+
}): string;
|
|
10
|
+
export declare function resolveGrant(id: unknown): FileGrant | null;
|
|
11
|
+
export declare function devGrantKey(file?: string): Buffer;
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import type { LaunchWindow } from "./plugin.ts";
|
|
2
|
+
/**
|
|
3
|
+
* env.runtime.json, overlaid with what the launch phase learned (the carried server's URL), then with
|
|
4
|
+
* AKAN_NATIVE_PUBLIC_* process variables (ENV-1, highest precedence).
|
|
5
|
+
*/
|
|
6
|
+
export declare function runtimeEnv(file: Record<string, string>, launched?: Record<string, string>, processEnv?: Record<string, string | undefined>): Record<string, string>;
|
|
2
7
|
/** The launch phase's window bounds that akan_native_run understands (x and y only together). */
|
|
3
8
|
export declare function launchBounds(window: LaunchWindow): LaunchWindow;
|
|
9
|
+
/**
|
|
10
|
+
* Windows renames no folder that is some process's working folder: an app started from its install folder (the
|
|
11
|
+
* installer, a shortcut, Explorer) would hand it to the webview's processes, and an update could never swap it
|
|
12
|
+
* (plugins/updates). Called after the launch phase, where single-instance forwards a second launch's folder.
|
|
13
|
+
*/
|
|
14
|
+
export declare function leaveInstallFolder(appId: string, platform?: NodeJS.Platform): void;
|
|
4
15
|
export declare function startMain(workerUrl: string): Promise<never>;
|
|
@@ -6,16 +6,27 @@ type Env = Record<string, string | undefined>;
|
|
|
6
6
|
* Linux $XDG_DATA_HOME/<id> (~/.local/share/<id>)
|
|
7
7
|
*/
|
|
8
8
|
export declare function appDataDir(id: string, platform?: NodeJS.Platform, env?: Env, home?: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* What is large and belongs to this PC: the webview's storage, the carried server's databases and logs.
|
|
11
|
+
* Windows %LOCALAPPDATA%\<id> (never Roaming, which follows the user and may be a network share)
|
|
12
|
+
* macOS, Linux appDataDir
|
|
13
|
+
*/
|
|
14
|
+
export declare function appLocalDataDir(id: string, platform?: NodeJS.Platform, env?: Env, home?: string): string;
|
|
9
15
|
/**
|
|
10
16
|
* The webview's own storage and caches (Windows, Linux; WKWebView chooses its own on macOS):
|
|
11
|
-
* Windows %LOCALAPPDATA%\<id>\WebView2
|
|
17
|
+
* Windows %LOCALAPPDATA%\<id>\WebView2
|
|
12
18
|
* Linux $XDG_DATA_HOME/<id>/webview
|
|
13
19
|
* WebView2's default would be next to the .exe, which is not writable once installed.
|
|
14
20
|
*/
|
|
15
21
|
export declare function webviewDataDir(id: string, platform?: NodeJS.Platform, env?: Env, home?: string): string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* The carried server's folder (server.ts): <app local data>/server. A debug build has the release app's id, so
|
|
24
|
+
* its server keeps its own folder and never opens the databases of the release app on the same PC.
|
|
25
|
+
*/
|
|
26
|
+
export declare function serverDataDir(id: string, dev: boolean, platform?: NodeJS.Platform, env?: Env, home?: string): string;
|
|
16
27
|
/**
|
|
17
28
|
* Folders whose files no FileRef may serve (L4): the shell's and the plugins' own storage
|
|
18
|
-
* (preferences, secure storage, databases, update bundles, window state, the webview's data). Only
|
|
29
|
+
* (preferences, secure storage, databases, update bundles, window state, the webview's data, the server's). Only
|
|
19
30
|
* the filesystem plugin's `data` base (<app data>/files) is servable inside the app data folder.
|
|
20
31
|
*/
|
|
21
32
|
export declare function reservedDirs(id: string, platform?: NodeJS.Platform, env?: Env, home?: string): {
|
|
@@ -12,6 +12,8 @@ export type EmitTarget = {
|
|
|
12
12
|
} | "focused";
|
|
13
13
|
export interface DesktopContext {
|
|
14
14
|
app: AppInfo;
|
|
15
|
+
/** A dev build (boot.json `dev`): its pages come from a dev server the shell did not start. */
|
|
16
|
+
readonly dev: boolean;
|
|
15
17
|
/**
|
|
16
18
|
* The window whose page made this call (SH-6; 1 = the window the app opened). Only in method
|
|
17
19
|
* calls; undefined in setup and event sources.
|
|
@@ -36,6 +38,22 @@ export interface DesktopContext {
|
|
|
36
38
|
readonly document?: DocumentScope;
|
|
37
39
|
/** Per-app data folder, e.g. ~/Library/Application Support/<app id>. Created on first access. */
|
|
38
40
|
readonly appDataDir: string;
|
|
41
|
+
/**
|
|
42
|
+
* For what is large and belongs to this PC (caches, downloads, databases): %LOCALAPPDATA%\<app id> on Windows,
|
|
43
|
+
* where appDataDir roams with the user; appDataDir on macOS and Linux. Created on first access.
|
|
44
|
+
*/
|
|
45
|
+
readonly appLocalDataDir: string;
|
|
46
|
+
/**
|
|
47
|
+
* The executables the app carries (desktop.bin, akanjs `bin`), or null. The host puts the folder first on
|
|
48
|
+
* process.env.PATH, which node:child_process and `Bun.spawn(cmd, { env: process.env })` use; a Bun.spawn or
|
|
49
|
+
* Bun.which without `env` reads the environment the app started with, so name a file here or pass the env.
|
|
50
|
+
*/
|
|
51
|
+
readonly binDir: string | null;
|
|
52
|
+
/**
|
|
53
|
+
* The server the app carries (desktop.server), or null. `ready` settles once per session: true when the server
|
|
54
|
+
* first answered ready, false when it could not start or gave up before that.
|
|
55
|
+
*/
|
|
56
|
+
readonly server: DesktopServerStatus | null;
|
|
39
57
|
/** Pushes an event of this plugin to the pages that listen. Returns the windows reached. */
|
|
40
58
|
emit(event: string, data?: unknown, target?: EmitTarget): number[];
|
|
41
59
|
/** Serves a local file at /__akan_native/file/<id> for the rest of the session (PL-7). */
|
|
@@ -100,6 +118,9 @@ export interface DesktopContext {
|
|
|
100
118
|
exit(code?: number): void;
|
|
101
119
|
};
|
|
102
120
|
}
|
|
121
|
+
export interface DesktopServerStatus {
|
|
122
|
+
readonly ready: Promise<boolean>;
|
|
123
|
+
}
|
|
103
124
|
/** Which page load ended. `id` is "" for a page that sends no document id (v1 callers, tests). */
|
|
104
125
|
export interface DocumentInfo {
|
|
105
126
|
window: number;
|
|
@@ -126,11 +147,17 @@ export interface LaunchWindow {
|
|
|
126
147
|
width?: number;
|
|
127
148
|
height?: number;
|
|
128
149
|
maximized?: boolean;
|
|
150
|
+
/** Borderless fullscreen from the first frame, on the display x and y are on (else the primary one). */
|
|
151
|
+
fullscreen?: boolean;
|
|
152
|
+
/** No taskbar button (Windows, Linux; macOS has none). */
|
|
153
|
+
skipTaskbar?: boolean;
|
|
129
154
|
}
|
|
130
155
|
/** What the launch phase decided; sent to the main thread with "ready". */
|
|
131
156
|
export interface Launch {
|
|
132
157
|
window: LaunchWindow;
|
|
133
158
|
exit?: number;
|
|
159
|
+
/** PUBLIC_* values for the page known only at launch (the carried server's URL), under AKAN_NATIVE_PUBLIC_*. */
|
|
160
|
+
env?: Record<string, string>;
|
|
134
161
|
}
|
|
135
162
|
export interface NativeEvent {
|
|
136
163
|
type: string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface RelaunchOptions {
|
|
2
|
+
/** How long the helper waits after this process exited before it starts the app. */
|
|
3
|
+
delayMs?: number;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Once this process has exited: renames `moves` in order and starts `exe` with this environment. macOS and
|
|
7
|
+
* Linux rename a running app's folder right away, so only the start waits; Windows refuses that, so a helper
|
|
8
|
+
* does the renames too (and on a failed rename puts back what it moved, so there is always an app to start).
|
|
9
|
+
* Only the first call of a process starts a helper; later ones answer the same promise.
|
|
10
|
+
*/
|
|
11
|
+
export declare function relaunchAfterExit(exe: string, moves?: [string, string][], { delayMs }?: RelaunchOptions): Promise<void>;
|
|
12
|
+
/** Relaunches after the browser process ended, in a row: each one's app ran less than RELAUNCH_HEALTHY. */
|
|
13
|
+
export declare const RELAUNCH_LIMIT = 10;
|
|
14
|
+
export declare const RELAUNCH_HEALTHY = 60000;
|
|
15
|
+
/**
|
|
16
|
+
* desktop.recovery "reload" after the webview's browser process ended: how long the relaunched app waits, or null
|
|
17
|
+
* once RELAUNCH_LIMIT relaunches in a row did not help. The first relaunch is immediate, then 1 s doubling to a
|
|
18
|
+
* minute (lib.rs recovery_wait); an app that ran for RELAUNCH_HEALTHY starts the count again. `file` keeps the
|
|
19
|
+
* count across the processes.
|
|
20
|
+
*/
|
|
21
|
+
export declare function nextRelaunchDelay(file: string, now?: number): number | null;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export interface ServerManifest {
|
|
2
|
+
/** The file in resources/server that starts the server. */
|
|
3
|
+
entry: string;
|
|
4
|
+
env: Record<string, string>;
|
|
5
|
+
}
|
|
6
|
+
/** Set by the launcher at every start, so desktop.server.env may not name them (cli lib/desktop-server.ts). */
|
|
7
|
+
export declare const LAUNCHER_ENV_KEYS: readonly ["BUN_BE_BUN", "BUN_RUNTIME_TRANSPILER_CACHE_PATH", "PORT", "JWT_SECRET", "AKAN_LISTEN_HOST", "AKAN_ALLOWED_HOSTS", "AKAN_SQLITE_DIR", "AKAN_WORKSPACE_ROOT", "AKAN_RUNTIME_DIR"];
|
|
8
|
+
/** How long the window waits for the server; after that it opens and the first calls may fail. */
|
|
9
|
+
export declare const READY_TIMEOUT = 8000;
|
|
10
|
+
/** Within the onQuit budget (lifecycle.ts QUIT_HOOK_TIMEOUT, 2 s). */
|
|
11
|
+
export declare const STOP_GRACE = 1500;
|
|
12
|
+
export declare const MAX_FAILURES = 5;
|
|
13
|
+
/** Between restarts of a server that has not been ready yet: MAX_FAILURES of them end well within READY_TIMEOUT. */
|
|
14
|
+
export declare const BOOT_RESTART_DELAY = 250;
|
|
15
|
+
/** A run that stayed up this long was healthy: its crash starts the count again. */
|
|
16
|
+
export declare const HEALTHY_RUN = 60000;
|
|
17
|
+
export interface ServerProcess {
|
|
18
|
+
readonly exited: Promise<number | null>;
|
|
19
|
+
send(message: unknown): void;
|
|
20
|
+
kill(signal?: NodeJS.Signals): void;
|
|
21
|
+
/** Signals what is left of the server's process group (macOS, Linux). */
|
|
22
|
+
killGroup?(signal: NodeJS.Signals): void;
|
|
23
|
+
}
|
|
24
|
+
export interface SpawnOptions {
|
|
25
|
+
cwd: string;
|
|
26
|
+
env: Record<string, string>;
|
|
27
|
+
onMessage(message: unknown): void;
|
|
28
|
+
onLine(line: string, stream: "stdout" | "stderr"): void;
|
|
29
|
+
}
|
|
30
|
+
export interface DesktopServerOptions {
|
|
31
|
+
resources: string;
|
|
32
|
+
/** Where the server keeps everything: its working folder, databases, logs, secret (paths.ts serverDataDir). */
|
|
33
|
+
dataDir: string;
|
|
34
|
+
manifest: ServerManifest;
|
|
35
|
+
/** The app's executables (resources/bin), first on the server's PATH. */
|
|
36
|
+
binDir?: string | null;
|
|
37
|
+
execPath?: string;
|
|
38
|
+
env?: Record<string, string | undefined>;
|
|
39
|
+
spawn?(argv: string[], options: SpawnOptions): ServerProcess;
|
|
40
|
+
/** A free loopback port: `preferred` when it is free. */
|
|
41
|
+
freePort?(preferred?: number): Promise<number>;
|
|
42
|
+
/** The server gave up: MAX_FAILURES crashes in a row, or it could not start at all. */
|
|
43
|
+
onGiveUp?(message: string): void;
|
|
44
|
+
readyTimeout?: number;
|
|
45
|
+
stopGrace?: number;
|
|
46
|
+
restartDelay?(failures: number, everReady: boolean): number;
|
|
47
|
+
now?(): number;
|
|
48
|
+
}
|
|
49
|
+
export interface DesktopServer {
|
|
50
|
+
/**
|
|
51
|
+
* The server's URL, once it is ready or readyTimeout passed (it keeps starting then), or at once when it gave up.
|
|
52
|
+
* Never throws: a server that cannot start still has a loopback URL, so the page's calls fail on this PC.
|
|
53
|
+
*/
|
|
54
|
+
start(): Promise<{
|
|
55
|
+
url: string;
|
|
56
|
+
ready: boolean;
|
|
57
|
+
}>;
|
|
58
|
+
/** Settles once: true at the first ready, false when the server gave up or stopped before that. */
|
|
59
|
+
readonly ready: Promise<boolean>;
|
|
60
|
+
stop(): Promise<void>;
|
|
61
|
+
}
|
|
62
|
+
export declare function readServerManifest(resources: string): ServerManifest | null;
|
|
63
|
+
export declare function serverArgv(execPath: string, resources: string, entry: string): string[];
|
|
64
|
+
/** `dir` first on a PATH, once: a relaunched app inherits the PATH its predecessor already extended. */
|
|
65
|
+
export declare function pathWithFirst(dir: string, path: string | undefined, platform?: NodeJS.Platform): string;
|
|
66
|
+
export declare function serverEnv(manifest: ServerManifest, { port, secret, dataDir, env, binDir, platform, }: {
|
|
67
|
+
port: number;
|
|
68
|
+
secret: string;
|
|
69
|
+
dataDir: string;
|
|
70
|
+
env: Record<string, string | undefined>;
|
|
71
|
+
binDir?: string | null;
|
|
72
|
+
platform?: NodeJS.Platform;
|
|
73
|
+
}): Record<string, string>;
|
|
74
|
+
/** One random secret per installation, readable by its owner only: outside operationMode local akanjs derives none. */
|
|
75
|
+
export declare function jwtSecret(dataDir: string): string;
|
|
76
|
+
export declare function restartDelay(failures: number, everReady?: boolean): number;
|
|
77
|
+
/** The port the last session's server was ready on (`<server data>/port`), if any. */
|
|
78
|
+
export declare function lastPort(dataDir: string): number | undefined;
|
|
79
|
+
export declare function createDesktopServer(options: DesktopServerOptions): DesktopServer;
|
|
@@ -18,6 +18,11 @@ export interface AppApi {
|
|
|
18
18
|
}>;
|
|
19
19
|
/** Ends the app without asking onBeforeQuit handlers. Android and desktop only (iOS apps must not quit themselves). */
|
|
20
20
|
exit(): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Ends the app and starts it again in a new process, without asking onBeforeQuit handlers: after a setting
|
|
23
|
+
* that takes a restart, or to recover an app nobody attends. The web reloads the page; iOS answers UNSUPPORTED.
|
|
24
|
+
*/
|
|
25
|
+
relaunch(): Promise<void>;
|
|
21
26
|
/** Sends the app to the background (Android) or minimizes its window (desktop). */
|
|
22
27
|
minimize(): Promise<void>;
|
|
23
28
|
/** Internal: the page's answer to a beforeQuit event. Use onBeforeQuit(). */
|