@jini-ai/desktop-host 0.7.3-next.1 → 0.7.3-next.3
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/CHANGELOG.md +6 -0
- package/README.md +217 -1
- package/dist/electron/electron-shell.js +5 -7
- package/dist/electron/handoff/index.d.ts +54 -0
- package/dist/electron/handoff/index.js +32 -0
- package/dist/electron/memory-sampler.d.ts +28 -0
- package/dist/electron/memory-sampler.js +41 -0
- package/dist/electron/partitions/cache-maintenance.d.ts +280 -0
- package/dist/electron/partitions/cache-maintenance.js +239 -0
- package/dist/electron/partitions/claim-sources.d.ts +54 -0
- package/dist/electron/partitions/claim-sources.js +36 -0
- package/dist/electron/partitions/holder-registry.d.ts +116 -0
- package/dist/electron/partitions/holder-registry.js +130 -0
- package/dist/electron/partitions/index.d.ts +10 -0
- package/dist/electron/partitions/index.js +10 -0
- package/dist/electron/partitions/maintenance-marker.d.ts +61 -0
- package/dist/electron/partitions/maintenance-marker.js +85 -0
- package/dist/electron/partitions/partition-inventory.d.ts +23 -0
- package/dist/electron/partitions/partition-inventory.js +19 -0
- package/dist/electron/partitions/partition-pass.d.ts +114 -0
- package/dist/electron/partitions/partition-pass.js +414 -0
- package/dist/electron/partitions/partition-root.d.ts +42 -0
- package/dist/electron/partitions/partition-root.js +52 -0
- package/dist/electron/partitions/profile-interlock.d.ts +141 -0
- package/dist/electron/partitions/profile-interlock.js +273 -0
- package/dist/electron/partitions/retirement-ledger.d.ts +116 -0
- package/dist/electron/partitions/retirement-ledger.js +149 -0
- package/dist/electron/preferences/index.d.ts +5 -0
- package/dist/electron/preferences/index.js +5 -0
- package/dist/electron/preferences/ipc.d.ts +35 -0
- package/dist/electron/preferences/ipc.js +21 -0
- package/dist/electron/preferences/menu.d.ts +103 -0
- package/dist/electron/preferences/menu.js +67 -0
- package/dist/electron/preferences/preference-file.d.ts +63 -0
- package/dist/electron/preferences/preference-file.js +51 -0
- package/dist/electron/preferences/values.d.ts +25 -0
- package/dist/electron/preferences/values.js +18 -0
- package/dist/electron/preload/index.d.ts +3 -0
- package/dist/electron/preload/index.js +2 -0
- package/dist/electron/preload/ipc-subscribe.d.ts +34 -0
- package/dist/electron/preload/ipc-subscribe.js +18 -0
- package/dist/electron/selftest/index.d.ts +3 -0
- package/dist/electron/selftest/index.js +3 -0
- package/dist/electron/selftest/selftest-tracker.d.ts +82 -0
- package/dist/electron/selftest/selftest-tracker.js +67 -0
- package/dist/electron/session-bootstrap/exchange.d.ts +50 -0
- package/dist/electron/session-bootstrap/exchange.js +41 -0
- package/dist/electron/session-bootstrap/header-arming.d.ts +18 -0
- package/dist/electron/session-bootstrap/header-arming.js +13 -0
- package/dist/electron/session-bootstrap/index.d.ts +11 -0
- package/dist/electron/session-bootstrap/index.js +10 -0
- package/dist/electron/session-bootstrap/partition.d.ts +17 -0
- package/dist/electron/session-bootstrap/partition.js +24 -0
- package/dist/electron/session-bootstrap/probe.d.ts +40 -0
- package/dist/electron/session-bootstrap/probe.js +29 -0
- package/dist/electron/session-bootstrap/types.d.ts +62 -0
- package/dist/electron/session-bootstrap/types.js +7 -0
- package/dist/electron/updates/desktop-updater.d.ts +90 -0
- package/dist/electron/updates/desktop-updater.js +124 -0
- package/dist/electron/updates/index.d.ts +4 -0
- package/dist/electron/updates/index.js +4 -0
- package/dist/electron/updates/instance-presence-strict.d.ts +27 -0
- package/dist/electron/updates/instance-presence-strict.js +46 -0
- package/dist/electron/updates/native-notices.d.ts +89 -0
- package/dist/electron/updates/native-notices.js +41 -0
- package/dist/electron/updates/update-check-now.d.ts +117 -0
- package/dist/electron/updates/update-check-now.js +88 -0
- package/dist/electron/usability/find-in-page-ipc.d.ts +3 -6
- package/dist/electron/usability/window-bounds-store.js +14 -12
- package/dist/electron/usability/zoom-menu.d.ts +1 -1
- package/dist/electron/webview/index.d.ts +2 -0
- package/dist/electron/webview/index.js +2 -0
- package/dist/electron/webview/webview-types.d.ts +66 -0
- package/dist/electron/webview/webview-types.js +12 -0
- package/dist/electron/windows/app-window.d.ts +83 -0
- package/dist/electron/windows/app-window.js +62 -0
- package/dist/electron/windows/dock-icon.d.ts +34 -0
- package/dist/electron/windows/dock-icon.js +32 -0
- package/dist/electron/windows/index.d.ts +3 -0
- package/dist/electron/windows/index.js +3 -0
- package/dist/logging.js +3 -1
- package/dist/node-toolchain/boot-setup.d.ts +63 -0
- package/dist/node-toolchain/boot-setup.js +59 -0
- package/dist/node-toolchain/index.d.ts +2 -0
- package/dist/node-toolchain/index.js +1 -0
- package/dist/shell/auto-update-controller.d.ts +34 -0
- package/dist/shell/auto-update-controller.js +27 -0
- package/dist/shell/copied-site-databases.d.ts +71 -0
- package/dist/shell/copied-site-databases.js +60 -0
- package/dist/shell/find-in-page-verify.d.ts +33 -0
- package/dist/shell/find-in-page-verify.js +30 -0
- package/dist/shell/find-menu.d.ts +33 -0
- package/dist/shell/find-menu.js +36 -0
- package/dist/shell/guest-navigation.d.ts +47 -0
- package/dist/shell/guest-navigation.js +58 -0
- package/dist/shell/instance-presence.d.ts +20 -0
- package/dist/shell/instance-presence.js +26 -0
- package/dist/shell/js-backslide-guard.d.ts +42 -0
- package/dist/shell/js-backslide-guard.js +44 -0
- package/dist/shell/node-toolchain.d.ts +34 -0
- package/dist/shell/node-toolchain.js +50 -0
- package/dist/shell/pty-helpers.d.ts +25 -0
- package/dist/shell/pty-helpers.js +50 -0
- package/dist/shell/site-presence.d.ts +32 -0
- package/dist/shell/site-presence.js +42 -0
- package/dist/shell/speech/mac-on-device-transcriber.d.ts +24 -0
- package/dist/shell/speech/mac-on-device-transcriber.js +81 -0
- package/dist/shell/speech/speech-ipc.d.ts +52 -0
- package/dist/shell/speech/speech-ipc.js +40 -0
- package/dist/shell/spellcheck-menu.d.ts +84 -0
- package/dist/shell/spellcheck-menu.js +63 -0
- package/dist/shell/supervised-site-url.d.ts +20 -0
- package/dist/shell/supervised-site-url.js +22 -0
- package/dist/speech/macos/mac-on-device-transcriber.d.ts +2 -1
- package/dist/speech/speech-bridge.d.ts +1 -8
- package/dist/speech/transcription-port.d.ts +1 -9
- package/dist/tauri/tauri-shell.js +8 -10
- package/package.json +154 -7
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Launch-time mechanics a desktop host runs once per boot: preparing the bundled Node toolchain's
|
|
3
|
+
* child-process env without ever failing the launch, and the two cancellation lanes background site
|
|
4
|
+
* discovery runs in. The host chooses the boot mode, owns every path and env-variable name, and turns
|
|
5
|
+
* the reported setup events into its own warning copy.
|
|
6
|
+
*/
|
|
7
|
+
/** Why a launch runs without the bundled toolchain; the host words the warning. */
|
|
8
|
+
export type NodeToolchainSetupEvent = {
|
|
9
|
+
kind: 'transient-launch';
|
|
10
|
+
} | {
|
|
11
|
+
kind: 'write-failed';
|
|
12
|
+
error: unknown;
|
|
13
|
+
};
|
|
14
|
+
export interface PrepareNodeToolchainEnvBestEffortInput {
|
|
15
|
+
userDataDir: string;
|
|
16
|
+
electronPath: string;
|
|
17
|
+
npmRoot: string;
|
|
18
|
+
/** The host's bound writer; `null` from a transient (disk-image) launch. May throw. */
|
|
19
|
+
writeNodeToolchain: (input: {
|
|
20
|
+
userDataDir: string;
|
|
21
|
+
electronPath: string;
|
|
22
|
+
npmRoot: string;
|
|
23
|
+
}) => {
|
|
24
|
+
toolchainDir: string;
|
|
25
|
+
} | null;
|
|
26
|
+
/** The host's bound env builder; it carries the host's own env-variable names. */
|
|
27
|
+
buildNodeToolchainEnv: (input: {
|
|
28
|
+
toolchainDir: string;
|
|
29
|
+
npmRoot: string;
|
|
30
|
+
}) => Record<string, string>;
|
|
31
|
+
report: (event: NodeToolchainSetupEvent) => void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The bundled toolchain's env contract, or `undefined` when this launch runs without it. Run once,
|
|
35
|
+
* after the user-data directory is set (the shims live under it) and before any child is spawned.
|
|
36
|
+
*
|
|
37
|
+
* Best-effort like every other user-data write at launch: a failure here (a read-only volume, a full
|
|
38
|
+
* disk) must degrade to the old identity behaviour — no bundled toolchain — never crash the app over
|
|
39
|
+
* a feature that is itself an upgrade.
|
|
40
|
+
* @complexity O(1) beyond the writer's own I/O.
|
|
41
|
+
*/
|
|
42
|
+
export declare function prepareNodeToolchainEnvBestEffort({ userDataDir, electronPath, npmRoot, writeNodeToolchain, buildNodeToolchainEnv, report }: PrepareNodeToolchainEnvBestEffortInput, _optional?: {}): Record<string, string> | undefined;
|
|
43
|
+
export interface SiteDiscoveryLanes<T> {
|
|
44
|
+
/** A scan with `scanRoots` is a picker validation; without, a rescan. Each supersedes only its own lane. */
|
|
45
|
+
discoverSites(required: {
|
|
46
|
+
scanRoots?: string[];
|
|
47
|
+
}, optional?: Record<string, never>): Promise<T>;
|
|
48
|
+
/** Before quit: stop whatever scan of either lane is still running. */
|
|
49
|
+
abortAll(required?: Record<string, never>, optional?: Record<string, never>): void;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The `discoverSites` dependency with its two independent cancellation lanes, plus the before-quit
|
|
53
|
+
* abort of both. A new scan supersedes the previous scan of the SAME lane only.
|
|
54
|
+
* @param required.discover the host's discoverer, bound to this launch's paths.
|
|
55
|
+
* @complexity O(1) per call beyond the scan.
|
|
56
|
+
*/
|
|
57
|
+
export declare function createSiteDiscoveryLanes<T>({ discover }: {
|
|
58
|
+
discover: (required: {
|
|
59
|
+
scanRoots: string[] | undefined;
|
|
60
|
+
signal: AbortSignal;
|
|
61
|
+
}) => Promise<T>;
|
|
62
|
+
}, _optional?: {}): SiteDiscoveryLanes<T>;
|
|
63
|
+
//# sourceMappingURL=boot-setup.d.ts.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Launch-time mechanics a desktop host runs once per boot: preparing the bundled Node toolchain's
|
|
3
|
+
* child-process env without ever failing the launch, and the two cancellation lanes background site
|
|
4
|
+
* discovery runs in. The host chooses the boot mode, owns every path and env-variable name, and turns
|
|
5
|
+
* the reported setup events into its own warning copy.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* The bundled toolchain's env contract, or `undefined` when this launch runs without it. Run once,
|
|
9
|
+
* after the user-data directory is set (the shims live under it) and before any child is spawned.
|
|
10
|
+
*
|
|
11
|
+
* Best-effort like every other user-data write at launch: a failure here (a read-only volume, a full
|
|
12
|
+
* disk) must degrade to the old identity behaviour — no bundled toolchain — never crash the app over
|
|
13
|
+
* a feature that is itself an upgrade.
|
|
14
|
+
* @complexity O(1) beyond the writer's own I/O.
|
|
15
|
+
*/
|
|
16
|
+
export function prepareNodeToolchainEnvBestEffort({ userDataDir, electronPath, npmRoot, writeNodeToolchain, buildNodeToolchainEnv, report }, _optional = {}) {
|
|
17
|
+
try {
|
|
18
|
+
const toolchain = writeNodeToolchain({ userDataDir, electronPath, npmRoot });
|
|
19
|
+
if (toolchain)
|
|
20
|
+
return buildNodeToolchainEnv({ toolchainDir: toolchain.toolchainDir, npmRoot });
|
|
21
|
+
report({ kind: 'transient-launch' });
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
report({ kind: 'write-failed', error });
|
|
25
|
+
}
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The `discoverSites` dependency with its two independent cancellation lanes, plus the before-quit
|
|
30
|
+
* abort of both. A new scan supersedes the previous scan of the SAME lane only.
|
|
31
|
+
* @param required.discover the host's discoverer, bound to this launch's paths.
|
|
32
|
+
* @complexity O(1) per call beyond the scan.
|
|
33
|
+
*/
|
|
34
|
+
export function createSiteDiscoveryLanes({ discover }, _optional = {}) {
|
|
35
|
+
let siteDiscoveryAbort;
|
|
36
|
+
let siteValidationAbort;
|
|
37
|
+
return {
|
|
38
|
+
// `async`: a synchronous throw from `discover` still rejects, so a failed background discovery
|
|
39
|
+
// never throws into the boot sequence that started it without awaiting.
|
|
40
|
+
async discoverSites({ scanRoots }, _options = {}) {
|
|
41
|
+
// Picker validation must not cancel a live rescan, or be cancelled by one.
|
|
42
|
+
if (scanRoots)
|
|
43
|
+
siteValidationAbort?.abort();
|
|
44
|
+
else
|
|
45
|
+
siteDiscoveryAbort?.abort();
|
|
46
|
+
const current = new AbortController();
|
|
47
|
+
if (scanRoots)
|
|
48
|
+
siteValidationAbort = current;
|
|
49
|
+
else
|
|
50
|
+
siteDiscoveryAbort = current;
|
|
51
|
+
return discover({ scanRoots, signal: current.signal });
|
|
52
|
+
},
|
|
53
|
+
abortAll(_required = {}, _options = {}) {
|
|
54
|
+
siteDiscoveryAbort?.abort();
|
|
55
|
+
siteValidationAbort?.abort();
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=boot-setup.js.map
|
|
@@ -74,4 +74,6 @@ export declare function writeNodeToolchain(input: WriteNodeToolchainInput): Node
|
|
|
74
74
|
/** Host-named environment contract; duplicate/invalid names fail loudly. @complexity O(n) in names. */
|
|
75
75
|
export declare function buildNodeToolchainEnv({ toolchainDir, npmRoot, toolchainEnvName, npmRootEnvName }: BuildNodeToolchainEnvInput): Record<string, string>;
|
|
76
76
|
export { isReadOnlyVolumeRoot, isTransientAppPath, launcherNamesDurableInstall } from "./install-location.js";
|
|
77
|
+
export { createSiteDiscoveryLanes, prepareNodeToolchainEnvBestEffort } from "./boot-setup.js";
|
|
78
|
+
export type { NodeToolchainSetupEvent, PrepareNodeToolchainEnvBestEffortInput, SiteDiscoveryLanes } from "./boot-setup.js";
|
|
77
79
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -97,4 +97,5 @@ export function buildNodeToolchainEnv({ toolchainDir, npmRoot, toolchainEnvName,
|
|
|
97
97
|
return { [toolchainEnvName]: toolchainDir, [npmRootEnvName]: npmRoot };
|
|
98
98
|
}
|
|
99
99
|
export { isReadOnlyVolumeRoot, isTransientAppPath, launcherNamesDurableInstall } from "./install-location.js";
|
|
100
|
+
export { createSiteDiscoveryLanes, prepareNodeToolchainEnvBestEffort } from "./boot-setup.js";
|
|
100
101
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { AutoUpdateController, ElectronUpdater } from "../electron/updates/index.js";
|
|
2
|
+
interface AutoUpdateControllerDeps {
|
|
3
|
+
updater: ElectronUpdater;
|
|
4
|
+
platform: NodeJS.Platform;
|
|
5
|
+
pid: number;
|
|
6
|
+
presenceDir: string;
|
|
7
|
+
now: () => number;
|
|
8
|
+
isAlive?: (required: {
|
|
9
|
+
pid: number;
|
|
10
|
+
}) => boolean;
|
|
11
|
+
promptUpdateReady: (required: {
|
|
12
|
+
version: string;
|
|
13
|
+
}) => Promise<boolean>;
|
|
14
|
+
explainOthersOpen: (required: {
|
|
15
|
+
count: number;
|
|
16
|
+
}) => void;
|
|
17
|
+
/** Normal app.quit(), including the site drain; updater restart must use the same shutdown path. */
|
|
18
|
+
quit: () => void;
|
|
19
|
+
log: (required: {
|
|
20
|
+
message: string;
|
|
21
|
+
}) => void;
|
|
22
|
+
stageTimeoutMs?: number;
|
|
23
|
+
}
|
|
24
|
+
/** Keep host callbacks stable and inject the host's presence and clock.
|
|
25
|
+
* Jini defaults preserve the timing and log wording, including the two-minute macOS Squirrel
|
|
26
|
+
* handoff deadline: quit without the update if staging hangs. A host may override that deadline.
|
|
27
|
+
* main.ts constructs this only for eligible packaged/non-Store builds and calls beforeFinalQuit
|
|
28
|
+
* after the site drain; a true result means preventDefault while the installer takes over quitting.
|
|
29
|
+
* @complexity O(1) construction; O(n) instances per tick.
|
|
30
|
+
*/
|
|
31
|
+
declare function createAutoUpdateController(deps: AutoUpdateControllerDeps): AutoUpdateController;
|
|
32
|
+
export { createAutoUpdateController };
|
|
33
|
+
export type { AutoUpdateController, AutoUpdateControllerDeps };
|
|
34
|
+
//# sourceMappingURL=auto-update-controller.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Bind Electron/native effects and host callbacks to Jini's update coordinator. */
|
|
2
|
+
// Update lifecycle rationale: Jini/packages/desktop-host/src/electron/updates/auto-update-controller.ts.
|
|
3
|
+
import { createAutoUpdateController as createController, createElectronUpdaterAdapter, } from "../electron/updates/index.js";
|
|
4
|
+
import { createInstancePresence } from "./instance-presence.js";
|
|
5
|
+
/** Keep host callbacks stable and inject the host's presence and clock.
|
|
6
|
+
* Jini defaults preserve the timing and log wording, including the two-minute macOS Squirrel
|
|
7
|
+
* handoff deadline: quit without the update if staging hangs. A host may override that deadline.
|
|
8
|
+
* main.ts constructs this only for eligible packaged/non-Store builds and calls beforeFinalQuit
|
|
9
|
+
* after the site drain; a true result means preventDefault while the installer takes over quitting.
|
|
10
|
+
* @complexity O(1) construction; O(n) instances per tick.
|
|
11
|
+
*/
|
|
12
|
+
function createAutoUpdateController(deps) {
|
|
13
|
+
const isAlive = deps.isAlive;
|
|
14
|
+
return createController({
|
|
15
|
+
updater: createElectronUpdaterAdapter({ updater: deps.updater }),
|
|
16
|
+
platform: deps.platform,
|
|
17
|
+
pid: deps.pid,
|
|
18
|
+
presence: createInstancePresence({ directory: deps.presenceDir }, isAlive ? { isAlive } : {}),
|
|
19
|
+
clock: { nowMs: deps.now },
|
|
20
|
+
promptUpdateReady: ({ version }) => deps.promptUpdateReady({ version }),
|
|
21
|
+
explainOthersOpen: ({ count }) => deps.explainOthersOpen({ count }),
|
|
22
|
+
quit: deps.quit,
|
|
23
|
+
log: ({ message }) => deps.log({ message }),
|
|
24
|
+
}, deps.stageTimeoutMs === undefined ? {} : { timing: { stageTimeoutMs: deps.stageTimeoutMs } });
|
|
25
|
+
}
|
|
26
|
+
export { createAutoUpdateController };
|
|
27
|
+
//# sourceMappingURL=auto-update-controller.js.map
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Snapshot, commit and rollback for a copied site's externally held databases. A Finder copy of
|
|
3
|
+
* a site folder still points (by symlink) at the ORIGINAL's app-data databases; before the copy may
|
|
4
|
+
* publish its own identity it gets snapshots of them under its new id and has those pointers detached.
|
|
5
|
+
* The ordering is the reusable part: create the target folder exclusively, snapshot every database,
|
|
6
|
+
* detach each symlinked pointer reversibly (rename, never delete), run the host's commit, and on ANY
|
|
7
|
+
* failure put the pointers back and remove only the folder this call created. Backups are removed
|
|
8
|
+
* once the commit has succeeded.
|
|
9
|
+
*
|
|
10
|
+
* The host keeps what is product layout: which databases exist, where they live, which pointer paths a
|
|
11
|
+
* copy can carry, the backup naming, and what "commit" means (for a site, rewriting its marker file).
|
|
12
|
+
* Filesystem and SQLite snapshot access arrive as ports, so the orchestration is verified without a disk.
|
|
13
|
+
*/
|
|
14
|
+
/** The filesystem operations the orchestration needs. Each throws on failure. */
|
|
15
|
+
export interface CopiedDatabaseFilesystem {
|
|
16
|
+
exists: (input: {
|
|
17
|
+
path: string;
|
|
18
|
+
}) => boolean;
|
|
19
|
+
/** Creates a folder; `recursive` creates missing parents and tolerates an existing one, otherwise an existing folder throws. */
|
|
20
|
+
makeDirectory: (input: {
|
|
21
|
+
path: string;
|
|
22
|
+
recursive: boolean;
|
|
23
|
+
}) => void;
|
|
24
|
+
removeTree: (input: {
|
|
25
|
+
path: string;
|
|
26
|
+
}) => void;
|
|
27
|
+
rename: (input: {
|
|
28
|
+
from: string;
|
|
29
|
+
to: string;
|
|
30
|
+
}) => void;
|
|
31
|
+
unlink: (input: {
|
|
32
|
+
path: string;
|
|
33
|
+
}) => void;
|
|
34
|
+
/** `true` only for a symbolic link at `path`; a missing entry is `false`. */
|
|
35
|
+
isSymbolicLink: (input: {
|
|
36
|
+
path: string;
|
|
37
|
+
}) => boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface CopiedDatabaseSource {
|
|
40
|
+
/** The original's database file. */
|
|
41
|
+
readonly from: string;
|
|
42
|
+
/** Where the copy's own snapshot goes; every `to` shares one parent folder. */
|
|
43
|
+
readonly to: string;
|
|
44
|
+
}
|
|
45
|
+
export interface CopiedDatabaseRequired {
|
|
46
|
+
readonly sources: readonly CopiedDatabaseSource[];
|
|
47
|
+
/** Candidate pointer paths in the copy; only those that are symbolic links are detached. */
|
|
48
|
+
readonly pointerPaths: readonly string[];
|
|
49
|
+
/** The rename target for the `index`th detached pointer; must be unique per index and not inside a pointer. */
|
|
50
|
+
readonly backupPath: (input: {
|
|
51
|
+
index: number;
|
|
52
|
+
}) => string;
|
|
53
|
+
/** Publishes the copy's identity; a throw rolls everything back. */
|
|
54
|
+
readonly commit: () => void;
|
|
55
|
+
readonly filesystem: CopiedDatabaseFilesystem;
|
|
56
|
+
/** Writes one consistent snapshot of `from` at `to`. */
|
|
57
|
+
readonly snapshot: (input: {
|
|
58
|
+
from: string;
|
|
59
|
+
to: string;
|
|
60
|
+
}) => void;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Runs `commit` with the copy's databases snapshotted and its pointers to the original detached; with
|
|
64
|
+
* no sources it just commits. Rolls back (pointers restored newest first, created folder removed) when a
|
|
65
|
+
* snapshot, detach or the commit throws, then rethrows that error.
|
|
66
|
+
*
|
|
67
|
+
* @throws "Copied database target already exists." before touching anything when the target folder exists.
|
|
68
|
+
* @complexity O(s + p) filesystem calls for s sources and p pointer paths, plus the snapshot I/O.
|
|
69
|
+
*/
|
|
70
|
+
export declare function commitWithCopiedDatabases({ sources, pointerPaths, backupPath, commit, filesystem, snapshot }: CopiedDatabaseRequired, _optional?: {}): void;
|
|
71
|
+
//# sourceMappingURL=copied-site-databases.d.ts.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Snapshot, commit and rollback for a copied site's externally held databases. A Finder copy of
|
|
3
|
+
* a site folder still points (by symlink) at the ORIGINAL's app-data databases; before the copy may
|
|
4
|
+
* publish its own identity it gets snapshots of them under its new id and has those pointers detached.
|
|
5
|
+
* The ordering is the reusable part: create the target folder exclusively, snapshot every database,
|
|
6
|
+
* detach each symlinked pointer reversibly (rename, never delete), run the host's commit, and on ANY
|
|
7
|
+
* failure put the pointers back and remove only the folder this call created. Backups are removed
|
|
8
|
+
* once the commit has succeeded.
|
|
9
|
+
*
|
|
10
|
+
* The host keeps what is product layout: which databases exist, where they live, which pointer paths a
|
|
11
|
+
* copy can carry, the backup naming, and what "commit" means (for a site, rewriting its marker file).
|
|
12
|
+
* Filesystem and SQLite snapshot access arrive as ports, so the orchestration is verified without a disk.
|
|
13
|
+
*/
|
|
14
|
+
import path from "node:path";
|
|
15
|
+
function detachPointers({ pointerPaths, backupPath, filesystem, detached }) {
|
|
16
|
+
for (const from of pointerPaths) {
|
|
17
|
+
if (!filesystem.isSymbolicLink({ path: from }))
|
|
18
|
+
continue;
|
|
19
|
+
const backup = backupPath({ index: detached.length });
|
|
20
|
+
filesystem.rename({ from, to: backup });
|
|
21
|
+
detached.push({ from, backup });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Runs `commit` with the copy's databases snapshotted and its pointers to the original detached; with
|
|
26
|
+
* no sources it just commits. Rolls back (pointers restored newest first, created folder removed) when a
|
|
27
|
+
* snapshot, detach or the commit throws, then rethrows that error.
|
|
28
|
+
*
|
|
29
|
+
* @throws "Copied database target already exists." before touching anything when the target folder exists.
|
|
30
|
+
* @complexity O(s + p) filesystem calls for s sources and p pointer paths, plus the snapshot I/O.
|
|
31
|
+
*/
|
|
32
|
+
export function commitWithCopiedDatabases({ sources, pointerPaths, backupPath, commit, filesystem, snapshot }, _optional = {}) {
|
|
33
|
+
const [firstSource] = sources;
|
|
34
|
+
if (firstSource === undefined) {
|
|
35
|
+
commit();
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const targetDirectory = path.dirname(firstSource.to);
|
|
39
|
+
if (filesystem.exists({ path: targetDirectory }))
|
|
40
|
+
throw new Error("Copied database target already exists.");
|
|
41
|
+
const detached = [];
|
|
42
|
+
filesystem.makeDirectory({ path: path.dirname(targetDirectory), recursive: true });
|
|
43
|
+
// Exclusive creation: rollback must never erase a folder somebody else made.
|
|
44
|
+
filesystem.makeDirectory({ path: targetDirectory, recursive: false });
|
|
45
|
+
try {
|
|
46
|
+
for (const source of sources)
|
|
47
|
+
snapshot({ from: source.from, to: source.to });
|
|
48
|
+
detachPointers({ pointerPaths, backupPath, filesystem, detached });
|
|
49
|
+
commit();
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
for (const pointer of detached.reverse())
|
|
53
|
+
filesystem.rename({ from: pointer.backup, to: pointer.from });
|
|
54
|
+
filesystem.removeTree({ path: targetDirectory });
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
for (const pointer of detached)
|
|
58
|
+
filesystem.unlink({ path: pointer.backup });
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=copied-site-databases.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The counter arithmetic behind `scripts/verify-find-in-page.ts`'s live checks — parsing the
|
|
3
|
+
* find bar's `"N of M"` counter and deciding which ordinal Enter / Shift+Enter / a raw follow-up
|
|
4
|
+
* find must land on. Pure, so the expectations the live run asserts against are themselves tested
|
|
5
|
+
* here; the live run (a real Electron app driven by Playwright) is opt-in and not part of `npm test`.
|
|
6
|
+
*/
|
|
7
|
+
/** The find bar's `"N of M"` counter, parsed. */
|
|
8
|
+
interface Count {
|
|
9
|
+
ordinal: number;
|
|
10
|
+
total: number;
|
|
11
|
+
}
|
|
12
|
+
/** `"3 of 17"` -> `{ ordinal: 3, total: 17 }`; anything else -> `null` (no result, or "No results"). */
|
|
13
|
+
export declare function parseCount({ text }: {
|
|
14
|
+
text: string | null | undefined;
|
|
15
|
+
}, _optional?: {}): Count | null;
|
|
16
|
+
/** The ordinal one forward `find` should land on from `count`, wrapping `total -> 1`; `null` when
|
|
17
|
+
* there was no count to advance from. */
|
|
18
|
+
export declare function nextOrdinal({ count }: {
|
|
19
|
+
count: Count | null;
|
|
20
|
+
}, _optional?: {}): number | null;
|
|
21
|
+
/** The ordinal one backward (Shift+Enter) step should land on from `count`, wrapping `1 -> total`;
|
|
22
|
+
* `null` when there was no count to step back from. */
|
|
23
|
+
export declare function previousOrdinal({ count }: {
|
|
24
|
+
count: Count | null;
|
|
25
|
+
}, _optional?: {}): number | null;
|
|
26
|
+
/** Every step is `previous + 1`, wrapping `total -> 1`. */
|
|
27
|
+
export declare function advancesEveryStep({ start, steps, total }: {
|
|
28
|
+
start: number;
|
|
29
|
+
steps: readonly (Count | null)[];
|
|
30
|
+
total: number;
|
|
31
|
+
}, _optional?: {}): boolean;
|
|
32
|
+
export type { Count };
|
|
33
|
+
//# sourceMappingURL=find-in-page-verify.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The counter arithmetic behind `scripts/verify-find-in-page.ts`'s live checks — parsing the
|
|
3
|
+
* find bar's `"N of M"` counter and deciding which ordinal Enter / Shift+Enter / a raw follow-up
|
|
4
|
+
* find must land on. Pure, so the expectations the live run asserts against are themselves tested
|
|
5
|
+
* here; the live run (a real Electron app driven by Playwright) is opt-in and not part of `npm test`.
|
|
6
|
+
*/
|
|
7
|
+
/** `"3 of 17"` -> `{ ordinal: 3, total: 17 }`; anything else -> `null` (no result, or "No results"). */
|
|
8
|
+
export function parseCount({ text }, _optional = {}) {
|
|
9
|
+
const match = /^(\d+) of (\d+)$/.exec((text ?? "").trim());
|
|
10
|
+
return match ? { ordinal: Number(match[1]), total: Number(match[2]) } : null;
|
|
11
|
+
}
|
|
12
|
+
/** The ordinal one forward `find` should land on from `count`, wrapping `total -> 1`; `null` when
|
|
13
|
+
* there was no count to advance from. */
|
|
14
|
+
export function nextOrdinal({ count }, _optional = {}) {
|
|
15
|
+
return count === null ? null : (count.ordinal % count.total) + 1;
|
|
16
|
+
}
|
|
17
|
+
/** The ordinal one backward (Shift+Enter) step should land on from `count`, wrapping `1 -> total`;
|
|
18
|
+
* `null` when there was no count to step back from. */
|
|
19
|
+
export function previousOrdinal({ count }, _optional = {}) {
|
|
20
|
+
return count === null ? null : ((count.ordinal - 2 + count.total) % count.total) + 1;
|
|
21
|
+
}
|
|
22
|
+
/** Every step is `previous + 1`, wrapping `total -> 1`. */
|
|
23
|
+
export function advancesEveryStep({ start, steps, total }, _optional = {}) {
|
|
24
|
+
let expected = start;
|
|
25
|
+
return steps.every((step) => {
|
|
26
|
+
expected = (expected % total) + 1;
|
|
27
|
+
return step !== null && step.ordinal === expected && step.total === total;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=find-in-page-verify.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** A focused native window as Electron's menu callback supplies it (positional `send`). */
|
|
2
|
+
export interface NativeFindCommandWindow {
|
|
3
|
+
isDestroyed(): boolean;
|
|
4
|
+
webContents?: {
|
|
5
|
+
send(channel: string): void;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
/** Electron's `MenuItemConstructorOptions` click shape: `(menuItem, focusedWindow)`. */
|
|
9
|
+
export interface NativeFindMenuItem {
|
|
10
|
+
label: string;
|
|
11
|
+
accelerator: string;
|
|
12
|
+
click: (item: unknown, window: NativeFindCommandWindow | undefined) => void;
|
|
13
|
+
}
|
|
14
|
+
export interface NativeFindMenu {
|
|
15
|
+
label: string;
|
|
16
|
+
submenu: [NativeFindMenuItem];
|
|
17
|
+
}
|
|
18
|
+
/** Send the host's find toggle to a native focused window. @complexity O(1). */
|
|
19
|
+
export declare function sendNativeFindToggle({ window, channel }: {
|
|
20
|
+
window: NativeFindCommandWindow | undefined;
|
|
21
|
+
channel: string;
|
|
22
|
+
}, _optional?: Record<string, never>): boolean;
|
|
23
|
+
/** Build native menu callbacks with the host's channel and wording. @complexity O(1). */
|
|
24
|
+
export declare function nativeFindMenu({ channel, labels }: {
|
|
25
|
+
channel: string;
|
|
26
|
+
labels: {
|
|
27
|
+
menu: string;
|
|
28
|
+
item: string;
|
|
29
|
+
};
|
|
30
|
+
}, optional?: {
|
|
31
|
+
accelerator?: string;
|
|
32
|
+
}): NativeFindMenu;
|
|
33
|
+
//# sourceMappingURL=find-menu.d.ts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Electron-native binding of `../electron/usability`'s Find menu: the policy (labels, accelerator,
|
|
3
|
+
* "only a live focused window with webContents receives the toggle") has one implementation there;
|
|
4
|
+
* this module only adapts Electron's positional shapes to that package's object-argument ports.
|
|
5
|
+
*
|
|
6
|
+
* Why a menu at all: a menu accelerator is the one key binding that still fires while focus is
|
|
7
|
+
* inside a project tab's `<webview>` guest, which a key listener in the host page never sees.
|
|
8
|
+
* Everything AFTER the bar opens (typing, Enter, Shift+Enter, Escape) is an ordinary DOM keydown on
|
|
9
|
+
* the bar's own input, which lives in the host document, so only the one "open the bar" step needs
|
|
10
|
+
* main's help at all.
|
|
11
|
+
*
|
|
12
|
+
* The toggle channel and the labels are host-owned and injected; no `electron` import, so it can be
|
|
13
|
+
* tested under plain node.
|
|
14
|
+
*/
|
|
15
|
+
import { findMenu as buildFindMenu, sendFindToggle as sendToggle } from "../electron/usability/find-menu.js";
|
|
16
|
+
/** Translate a native focused window to the package send port. @complexity O(1). */
|
|
17
|
+
function windowPort({ window }) {
|
|
18
|
+
if (!window)
|
|
19
|
+
return undefined;
|
|
20
|
+
const contents = window.webContents;
|
|
21
|
+
return {
|
|
22
|
+
isDestroyed: () => window.isDestroyed(),
|
|
23
|
+
...(contents ? { webContents: { send: ({ channel }) => contents.send(channel) } } : {}),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/** Send the host's find toggle to a native focused window. @complexity O(1). */
|
|
27
|
+
export function sendNativeFindToggle({ window, channel }, _optional = {}) {
|
|
28
|
+
return sendToggle({ window: windowPort({ window }), channel });
|
|
29
|
+
}
|
|
30
|
+
/** Build native menu callbacks with the host's channel and wording. @complexity O(1). */
|
|
31
|
+
export function nativeFindMenu({ channel, labels }, optional = {}) {
|
|
32
|
+
const menu = buildFindMenu({ channel, labels }, optional);
|
|
33
|
+
const item = menu.submenu[0];
|
|
34
|
+
return { ...menu, submenu: [{ ...item, click: (_item, window) => item.click({ window: windowPort({ window }) }) }] };
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=find-menu.js.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The navigation boundary for an embedded project's `<webview>` guest, extracted from
|
|
3
|
+
* `main.ts`'s `registerGuestNavigationPolicy` so every decision — which contents it applies to,
|
|
4
|
+
* which navigations stay, which are refused, and which are handed to the OS browser — is verified
|
|
5
|
+
* without Electron. `main.ts` keeps only the `app.on("web-contents-created", ...)` line that hands
|
|
6
|
+
* each new contents to {@link installWebviewGuestPolicy}.
|
|
7
|
+
*/
|
|
8
|
+
import { type ElectronNavigableContents } from "../electron/navigation-policy/index.js";
|
|
9
|
+
/** The slice of a `WebContents` the guest policy touches. */
|
|
10
|
+
type GuestContents = ElectronNavigableContents & {
|
|
11
|
+
getType(): string;
|
|
12
|
+
getURL(): string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Answers navigation/window-open requests an embedded project's `<webview>` guest makes — the same
|
|
16
|
+
* two-part boundary the host's standalone runner enforces in its own
|
|
17
|
+
* `registerGuestNavigationPolicy`: a same-origin navigation (the site steering itself — a login
|
|
18
|
+
* redirect, an admin route that round-trips the server) is left alone, since the tab IS that
|
|
19
|
+
* project's admin and has to keep working; anything that would leave the guest's own origin is
|
|
20
|
+
* denied INSIDE the guest and, when it targets a site this launch actually supervises OR is an
|
|
21
|
+
* ordinary `isExternalBrowserUrl` (a `window.open` sign-in link, say — see
|
|
22
|
+
* `installGuestWindowOpenPolicy`), handed to the operator's own default browser instead.
|
|
23
|
+
* `allowpopups` on the tag (`App.tsx`) is the other half — without it Electron's guest-view manager
|
|
24
|
+
* never lets a `target="_blank"` request reach this process at all, so the popup handler below would
|
|
25
|
+
* never fire.
|
|
26
|
+
*
|
|
27
|
+
* Registered once, globally, from the sites-home boot branch: `web-contents-created` fires for every
|
|
28
|
+
* guest ANY window's `<webview>` ever attaches, and `contents.getType() !== "webview"` filters out
|
|
29
|
+
* everything else (the sites home window's own top-level content included).
|
|
30
|
+
*
|
|
31
|
+
* @param required.contents the newly created contents, of any type.
|
|
32
|
+
* @param required.isSupervisedGuestUrl whether a URL is one of this launch's supervised sites, read per call.
|
|
33
|
+
* @param required.openExternal hands a URL to the operator's own browser.
|
|
34
|
+
* @complexity O(1) per event, beyond `isSupervisedGuestUrl`'s own cost.
|
|
35
|
+
*/
|
|
36
|
+
declare function installWebviewGuestPolicy({ contents, isSupervisedGuestUrl, openExternal }: {
|
|
37
|
+
contents: GuestContents;
|
|
38
|
+
isSupervisedGuestUrl: (required: {
|
|
39
|
+
url: string;
|
|
40
|
+
}) => boolean;
|
|
41
|
+
openExternal: (required: {
|
|
42
|
+
url: string;
|
|
43
|
+
}) => void;
|
|
44
|
+
}, _optional?: {}): void;
|
|
45
|
+
export { installWebviewGuestPolicy };
|
|
46
|
+
export type { GuestContents };
|
|
47
|
+
//# sourceMappingURL=guest-navigation.d.ts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The navigation boundary for an embedded project's `<webview>` guest, extracted from
|
|
3
|
+
* `main.ts`'s `registerGuestNavigationPolicy` so every decision — which contents it applies to,
|
|
4
|
+
* which navigations stay, which are refused, and which are handed to the OS browser — is verified
|
|
5
|
+
* without Electron. `main.ts` keeps only the `app.on("web-contents-created", ...)` line that hands
|
|
6
|
+
* each new contents to {@link installWebviewGuestPolicy}.
|
|
7
|
+
*/
|
|
8
|
+
// Object-shaped policy API (D15): the former `shell/window-navigation-policy` adapter duplicated it.
|
|
9
|
+
import { installGuestWindowOpenPolicy, isSameOrigin } from "../electron/navigation-policy/index.js";
|
|
10
|
+
/**
|
|
11
|
+
* Answers navigation/window-open requests an embedded project's `<webview>` guest makes — the same
|
|
12
|
+
* two-part boundary the host's standalone runner enforces in its own
|
|
13
|
+
* `registerGuestNavigationPolicy`: a same-origin navigation (the site steering itself — a login
|
|
14
|
+
* redirect, an admin route that round-trips the server) is left alone, since the tab IS that
|
|
15
|
+
* project's admin and has to keep working; anything that would leave the guest's own origin is
|
|
16
|
+
* denied INSIDE the guest and, when it targets a site this launch actually supervises OR is an
|
|
17
|
+
* ordinary `isExternalBrowserUrl` (a `window.open` sign-in link, say — see
|
|
18
|
+
* `installGuestWindowOpenPolicy`), handed to the operator's own default browser instead.
|
|
19
|
+
* `allowpopups` on the tag (`App.tsx`) is the other half — without it Electron's guest-view manager
|
|
20
|
+
* never lets a `target="_blank"` request reach this process at all, so the popup handler below would
|
|
21
|
+
* never fire.
|
|
22
|
+
*
|
|
23
|
+
* Registered once, globally, from the sites-home boot branch: `web-contents-created` fires for every
|
|
24
|
+
* guest ANY window's `<webview>` ever attaches, and `contents.getType() !== "webview"` filters out
|
|
25
|
+
* everything else (the sites home window's own top-level content included).
|
|
26
|
+
*
|
|
27
|
+
* @param required.contents the newly created contents, of any type.
|
|
28
|
+
* @param required.isSupervisedGuestUrl whether a URL is one of this launch's supervised sites, read per call.
|
|
29
|
+
* @param required.openExternal hands a URL to the operator's own browser.
|
|
30
|
+
* @complexity O(1) per event, beyond `isSupervisedGuestUrl`'s own cost.
|
|
31
|
+
*/
|
|
32
|
+
function installWebviewGuestPolicy({ contents, isSupervisedGuestUrl, openExternal }, _optional = {}) {
|
|
33
|
+
if (contents.getType() !== "webview")
|
|
34
|
+
return;
|
|
35
|
+
const openExternally = ({ url }, _optional = {}) => {
|
|
36
|
+
if (isSupervisedGuestUrl({ url }))
|
|
37
|
+
openExternal({ url });
|
|
38
|
+
};
|
|
39
|
+
installGuestWindowOpenPolicy({ contents, isSupervisedGuestUrl, openExternal });
|
|
40
|
+
contents.on("will-navigate", (event, url) => {
|
|
41
|
+
if (isSameOrigin({ candidate: url, reference: contents.getURL() }))
|
|
42
|
+
return;
|
|
43
|
+
event.preventDefault();
|
|
44
|
+
openExternally({ url });
|
|
45
|
+
});
|
|
46
|
+
// A server-side 30x never fires `will-navigate`, and a site's redirect rules may name another
|
|
47
|
+
// origin. Judged against the supervised sites rather than `getURL()`, which a redirect during
|
|
48
|
+
// the guest's FIRST load has nothing committed to compare against. Main frame only: a subframe
|
|
49
|
+
// never runs the preload. Nothing is handed to the OS browser: `openExternally` only ever opens
|
|
50
|
+
// a supervised url, and a supervised url is allowed here.
|
|
51
|
+
contents.on("will-redirect", (details) => {
|
|
52
|
+
if (!details.isMainFrame || isSupervisedGuestUrl({ url: details.url }))
|
|
53
|
+
return;
|
|
54
|
+
details.preventDefault();
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
export { installWebviewGuestPolicy };
|
|
58
|
+
//# sourceMappingURL=guest-navigation.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { InstancePresencePort } from "../electron/updates/index.js";
|
|
2
|
+
/** Resolve the host's existing on-disk directory. @complexity O(n) in path length. */
|
|
3
|
+
declare function presenceDirPath({ userDataDir }: {
|
|
4
|
+
userDataDir: string;
|
|
5
|
+
}, _optional?: {}): string;
|
|
6
|
+
/** Native signal-zero probe; permission denial still counts as alive. @complexity O(1). */
|
|
7
|
+
declare function isPidAlive({ pid }: {
|
|
8
|
+
pid: number;
|
|
9
|
+
}): boolean;
|
|
10
|
+
/** Bind native I/O and liveness; callers use write/readLive/remove methods. @complexity O(1). */
|
|
11
|
+
declare function createInstancePresence({ directory }: {
|
|
12
|
+
directory: string;
|
|
13
|
+
}, { isAlive, writerPid }?: {
|
|
14
|
+
isAlive?: (args: {
|
|
15
|
+
pid: number;
|
|
16
|
+
}) => boolean;
|
|
17
|
+
writerPid?: number;
|
|
18
|
+
}): InstancePresencePort;
|
|
19
|
+
export { createInstancePresence, isPidAlive, presenceDirPath };
|
|
20
|
+
//# sourceMappingURL=instance-presence.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Native presence ports and the host's shared instances directory; records are owned by Jini. */
|
|
2
|
+
// Presence/liveness rationale: Jini/packages/desktop-host/src/electron/updates/instance-presence.ts.
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import { createFileInstancePresence, isPidAlive as probePid, presenceDirPath as resolvePresenceDirectory, } from "../electron/updates/index.js";
|
|
5
|
+
const filesystem = {
|
|
6
|
+
mkdirSync: ({ path }, options) => fs.mkdirSync(path, options),
|
|
7
|
+
writeFileSync: ({ path, data }) => fs.writeFileSync(path, data),
|
|
8
|
+
renameSync: ({ oldPath, newPath }) => fs.renameSync(oldPath, newPath),
|
|
9
|
+
unlinkSync: ({ path }) => fs.unlinkSync(path),
|
|
10
|
+
readdirSync: ({ path }) => fs.readdirSync(path),
|
|
11
|
+
readFileSync: ({ path, encoding }) => fs.readFileSync(path, encoding),
|
|
12
|
+
};
|
|
13
|
+
/** Resolve the host's existing on-disk directory. @complexity O(n) in path length. */
|
|
14
|
+
function presenceDirPath({ userDataDir }, _optional = {}) {
|
|
15
|
+
return resolvePresenceDirectory({ userDataDir, directoryName: "instances" });
|
|
16
|
+
}
|
|
17
|
+
/** Native signal-zero probe; permission denial still counts as alive. @complexity O(1). */
|
|
18
|
+
function isPidAlive({ pid }) {
|
|
19
|
+
return probePid({ pid, probe: ({ pid, signal }) => process.kill(pid, signal) });
|
|
20
|
+
}
|
|
21
|
+
/** Bind native I/O and liveness; callers use write/readLive/remove methods. @complexity O(1). */
|
|
22
|
+
function createInstancePresence({ directory }, { isAlive = isPidAlive, writerPid = process.pid } = {}) {
|
|
23
|
+
return createFileInstancePresence({ directory, filesystem, isAlive, writerPid });
|
|
24
|
+
}
|
|
25
|
+
export { createInstancePresence, isPidAlive, presenceDirPath };
|
|
26
|
+
//# sourceMappingURL=instance-presence.js.map
|