@jini-ai/desktop-host 0.7.3-next.2 → 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/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 +153 -6
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** "Update ready": Restart is button 0, Escape/close lands on Later. */
|
|
2
|
+
export function updateReadyPromptOptions({ copy, version }, _optionalArgs = {}) {
|
|
3
|
+
return {
|
|
4
|
+
type: 'info',
|
|
5
|
+
buttons: [copy.restartLabel, copy.laterLabel],
|
|
6
|
+
defaultId: 0,
|
|
7
|
+
cancelId: 1,
|
|
8
|
+
message: copy.message,
|
|
9
|
+
detail: copy.detail({ version }),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
/** Restart to update was chosen while other copies of the app are open. */
|
|
13
|
+
export function othersOpenOptions({ copy, count }, _optionalArgs = {}) {
|
|
14
|
+
return { type: 'info', message: copy.message, detail: copy.detail({ count }) };
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A box as a sheet on the focused window, else the first window, else app-modal when none is open.
|
|
18
|
+
* @returns The native box's answer. @complexity O(n) open windows.
|
|
19
|
+
*/
|
|
20
|
+
export function showOnFocusedWindow({ dialog, windows, options }, _optionalArgs = {}) {
|
|
21
|
+
const parent = windows.getFocusedWindow() ?? windows.getAllWindows()[0];
|
|
22
|
+
return parent ? dialog.showMessageBox(parent, options) : dialog.showMessageBox(options);
|
|
23
|
+
}
|
|
24
|
+
/** One native message box with a single acknowledge button (`okLabel`), not awaited. */
|
|
25
|
+
export function showNativeNotice({ dialog, windows, notice, okLabel }, _optionalArgs = {}) {
|
|
26
|
+
const { type, message, detail } = notice;
|
|
27
|
+
void showOnFocusedWindow({ dialog, windows, options: { type, message, detail, buttons: [okLabel] } });
|
|
28
|
+
}
|
|
29
|
+
/** The "Update ready" prompt, as a sheet on the focused window. Resolves `true` for Restart. */
|
|
30
|
+
export async function promptUpdateReady({ dialog, windows, automaticUpdates, version, copy }, _optionalArgs = {}) {
|
|
31
|
+
// The download event may already have queued its prompt when the checkbox is turned off.
|
|
32
|
+
if (!automaticUpdates())
|
|
33
|
+
return false;
|
|
34
|
+
const { response } = await showOnFocusedWindow({ dialog, windows, options: updateReadyPromptOptions({ copy, version }) });
|
|
35
|
+
return response === 0;
|
|
36
|
+
}
|
|
37
|
+
/** Restart to update was chosen while other copies of the app are open. Never parented. */
|
|
38
|
+
export function explainOthersOpen({ dialog, count, copy }, _optionalArgs = {}) {
|
|
39
|
+
void dialog.showMessageBox(othersOpenOptions({ copy, count }));
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=native-notices.js.map
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A manual "Check for updates" from any running copy. The auto-update controller only checks from
|
|
3
|
+
* the elected owner copy on its own interval, so a copy launched later could sit on an old version
|
|
4
|
+
* for hours. This runs one check in the clicking copy, through the same native updater the
|
|
5
|
+
* controller already listens to: a download it starts ends in the controller's own "Update ready"
|
|
6
|
+
* prompt, and electron-updater reuses a download another copy already cached, so nothing downloads
|
|
7
|
+
* twice. The host supplies eligibility, the preference read, every word of copy and the error
|
|
8
|
+
* formatters (a caught updater error is handed to them raw, never turned into text here); see the
|
|
9
|
+
* electron/updates README section for wiring.
|
|
10
|
+
*/
|
|
11
|
+
/** The slice of electron-updater's `autoUpdater` a manual check needs. */
|
|
12
|
+
export interface CheckableUpdater {
|
|
13
|
+
autoDownload: boolean;
|
|
14
|
+
autoInstallOnAppQuit: boolean;
|
|
15
|
+
checkForUpdates(): Promise<{
|
|
16
|
+
isUpdateAvailable?: boolean;
|
|
17
|
+
updateInfo?: {
|
|
18
|
+
version: string;
|
|
19
|
+
};
|
|
20
|
+
downloadPromise?: Promise<unknown> | null;
|
|
21
|
+
} | null>;
|
|
22
|
+
}
|
|
23
|
+
export type UpdateCheckOutcome = {
|
|
24
|
+
kind: 'unavailable';
|
|
25
|
+
reason: string;
|
|
26
|
+
} | {
|
|
27
|
+
kind: 'ready';
|
|
28
|
+
version: string;
|
|
29
|
+
} | {
|
|
30
|
+
kind: 'up-to-date';
|
|
31
|
+
version: string;
|
|
32
|
+
} | {
|
|
33
|
+
kind: 'downloading';
|
|
34
|
+
version: string;
|
|
35
|
+
} | {
|
|
36
|
+
kind: 'available';
|
|
37
|
+
version: string;
|
|
38
|
+
} | {
|
|
39
|
+
kind: 'error';
|
|
40
|
+
};
|
|
41
|
+
/** One native message box's text. */
|
|
42
|
+
export interface UpdateNotice {
|
|
43
|
+
type: 'info' | 'error';
|
|
44
|
+
message: string;
|
|
45
|
+
detail: string;
|
|
46
|
+
}
|
|
47
|
+
/** What the host's copy sees for one outcome; `error` adds the raw message and copyable details. */
|
|
48
|
+
export interface UpdateNoticeArgs {
|
|
49
|
+
outcome: UpdateCheckOutcome;
|
|
50
|
+
currentVersion: string;
|
|
51
|
+
isPackaged: boolean;
|
|
52
|
+
automaticUpdates: boolean;
|
|
53
|
+
errorMessage?: string | undefined;
|
|
54
|
+
errorDetails?: string | undefined;
|
|
55
|
+
}
|
|
56
|
+
/** Host-owned wording for every notice a manual check can show. */
|
|
57
|
+
export interface UpdateCheckCopy {
|
|
58
|
+
/** The notice for an outcome, or null to show nothing (the `ready` prompt replaces a notice). */
|
|
59
|
+
notice: (args: UpdateNoticeArgs) => UpdateNotice | null;
|
|
60
|
+
/** The notice for a download this check started that later failed. */
|
|
61
|
+
downloadFailed: (args: {
|
|
62
|
+
version: string;
|
|
63
|
+
error: unknown;
|
|
64
|
+
}) => UpdateNotice;
|
|
65
|
+
/** Copyable, redacted diagnostics appended to a failed check's notice as `errorDetails`. */
|
|
66
|
+
checkFailedDetails: (args: {
|
|
67
|
+
error: unknown;
|
|
68
|
+
}) => string;
|
|
69
|
+
}
|
|
70
|
+
export interface UpdateCheckNowDeps {
|
|
71
|
+
isPackaged: boolean;
|
|
72
|
+
currentVersion: () => string;
|
|
73
|
+
/** The host's reason this launch runs no updater, or null. */
|
|
74
|
+
skipReason: () => string | null;
|
|
75
|
+
automaticUpdates: () => boolean;
|
|
76
|
+
/** The version this copy's controller already downloaded and prompted for, or null. */
|
|
77
|
+
readyVersion: () => string | null;
|
|
78
|
+
loadUpdater: () => Promise<CheckableUpdater>;
|
|
79
|
+
/** The existing "Update ready" prompt; restarts when the operator picks Restart. */
|
|
80
|
+
showReadyPrompt: (args: {
|
|
81
|
+
version: string;
|
|
82
|
+
}) => Promise<void>;
|
|
83
|
+
notify: (notice: UpdateNotice) => void;
|
|
84
|
+
log: (args: {
|
|
85
|
+
message: string;
|
|
86
|
+
}) => void;
|
|
87
|
+
copy: UpdateCheckCopy;
|
|
88
|
+
/** The host's redacting log formatter for an updater error. */
|
|
89
|
+
describeErrorForLog: (args: {
|
|
90
|
+
error: unknown;
|
|
91
|
+
}) => string;
|
|
92
|
+
/** The host's plain message for a failed check's error, handed to `copy.notice` as `errorMessage`. */
|
|
93
|
+
describeErrorMessage: (args: {
|
|
94
|
+
error: unknown;
|
|
95
|
+
}) => string;
|
|
96
|
+
}
|
|
97
|
+
/** True when an electron-updater error message means the update server was unreachable. O(message). */
|
|
98
|
+
export declare function isNetworkUpdateError({ message }: {
|
|
99
|
+
message: string;
|
|
100
|
+
}, _optional?: {}): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* One manual check at a time: a second click while one runs joins it, so no second dialog opens.
|
|
103
|
+
* With automatic updates off it only looks: nothing downloads, and the notice says so.
|
|
104
|
+
* @complexity O(1) per click, plus one network check.
|
|
105
|
+
*/
|
|
106
|
+
export declare function createUpdateCheckNow(deps: UpdateCheckNowDeps, _optional?: {}): {
|
|
107
|
+
checkNow: () => Promise<UpdateCheckOutcome>;
|
|
108
|
+
};
|
|
109
|
+
/** Register the check once on the host's channel. The renderer only awaits; main shows every notice. O(1). */
|
|
110
|
+
export declare function registerUpdateCheckIpc({ ipcMain, channel, checkNow }: {
|
|
111
|
+
ipcMain: {
|
|
112
|
+
handle: (channel: string, listener: () => Promise<void>) => void;
|
|
113
|
+
};
|
|
114
|
+
channel: string;
|
|
115
|
+
checkNow: () => Promise<UpdateCheckOutcome>;
|
|
116
|
+
}, _optional?: {}): void;
|
|
117
|
+
//# sourceMappingURL=update-check-now.d.ts.map
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A manual "Check for updates" from any running copy. The auto-update controller only checks from
|
|
3
|
+
* the elected owner copy on its own interval, so a copy launched later could sit on an old version
|
|
4
|
+
* for hours. This runs one check in the clicking copy, through the same native updater the
|
|
5
|
+
* controller already listens to: a download it starts ends in the controller's own "Update ready"
|
|
6
|
+
* prompt, and electron-updater reuses a download another copy already cached, so nothing downloads
|
|
7
|
+
* twice. The host supplies eligibility, the preference read, every word of copy and the error
|
|
8
|
+
* formatters (a caught updater error is handed to them raw, never turned into text here); see the
|
|
9
|
+
* electron/updates README section for wiring.
|
|
10
|
+
*/
|
|
11
|
+
const NETWORK_ERROR = /ERR_INTERNET_DISCONNECTED|ERR_NAME_NOT_RESOLVED|ERR_NETWORK|ERR_CONNECTION|ERR_TIMED_OUT|ENOTFOUND|ENETUNREACH|ECONNREFUSED|ECONNRESET|ETIMEDOUT|EAI_AGAIN/;
|
|
12
|
+
/** True when an electron-updater error message means the update server was unreachable. O(message). */
|
|
13
|
+
export function isNetworkUpdateError({ message }, _optional = {}) {
|
|
14
|
+
return NETWORK_ERROR.test(message);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* One manual check at a time: a second click while one runs joins it, so no second dialog opens.
|
|
18
|
+
* With automatic updates off it only looks: nothing downloads, and the notice says so.
|
|
19
|
+
* @complexity O(1) per click, plus one network check.
|
|
20
|
+
*/
|
|
21
|
+
export function createUpdateCheckNow(deps, _optional = {}) {
|
|
22
|
+
let inFlight = null;
|
|
23
|
+
const report = createUpdateOutcomeReporter(deps);
|
|
24
|
+
// Called by its own name: the host's redacting describer is the one thing a caught error reaches
|
|
25
|
+
// before a log line, and the log-safety gate recognises that describer by name.
|
|
26
|
+
const { describeErrorForLog } = deps;
|
|
27
|
+
function reportCheckResult({ result, automatic }) {
|
|
28
|
+
const version = result?.updateInfo?.version;
|
|
29
|
+
if (!result?.isUpdateAvailable || !version)
|
|
30
|
+
return report({ outcome: { kind: 'up-to-date', version: deps.currentVersion() } });
|
|
31
|
+
if (!automatic)
|
|
32
|
+
return report({ outcome: { kind: 'available', version } });
|
|
33
|
+
// The controller's own listener prompts when this finishes; only a failure needs saying here.
|
|
34
|
+
result.downloadPromise?.catch((error) => {
|
|
35
|
+
deps.log({ message: `update download failed: ${describeErrorForLog({ error })}` });
|
|
36
|
+
deps.notify(deps.copy.downloadFailed({ version, error }));
|
|
37
|
+
});
|
|
38
|
+
return report({ outcome: { kind: 'downloading', version } });
|
|
39
|
+
}
|
|
40
|
+
async function run() {
|
|
41
|
+
const skip = deps.skipReason();
|
|
42
|
+
if (skip !== null)
|
|
43
|
+
return report({ outcome: { kind: 'unavailable', reason: skip } });
|
|
44
|
+
const automatic = deps.automaticUpdates();
|
|
45
|
+
try {
|
|
46
|
+
const ready = automatic ? deps.readyVersion() : null;
|
|
47
|
+
if (ready !== null) {
|
|
48
|
+
await deps.showReadyPrompt({ version: ready });
|
|
49
|
+
return { kind: 'ready', version: ready };
|
|
50
|
+
}
|
|
51
|
+
const updater = await deps.loadUpdater();
|
|
52
|
+
if (!automatic) {
|
|
53
|
+
// A first import has electron-updater's defaults; the operator asked for a look only.
|
|
54
|
+
updater.autoDownload = false;
|
|
55
|
+
updater.autoInstallOnAppQuit = false;
|
|
56
|
+
}
|
|
57
|
+
return reportCheckResult({ result: await updater.checkForUpdates(), automatic });
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
deps.log({ message: `update check failed: ${describeErrorForLog({ error })}` });
|
|
61
|
+
return report({ outcome: { kind: 'error' } }, {
|
|
62
|
+
errorMessage: deps.describeErrorMessage({ error }), errorDetails: deps.copy.checkFailedDetails({ error }),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
checkNow() {
|
|
68
|
+
inFlight ??= run().finally(() => { inFlight = null; });
|
|
69
|
+
return inFlight;
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function createUpdateOutcomeReporter(deps) {
|
|
74
|
+
return function report({ outcome }, { errorMessage, errorDetails } = {}) {
|
|
75
|
+
const notice = deps.copy.notice({
|
|
76
|
+
outcome, currentVersion: deps.currentVersion(), isPackaged: deps.isPackaged,
|
|
77
|
+
automaticUpdates: deps.automaticUpdates(), errorMessage, errorDetails,
|
|
78
|
+
});
|
|
79
|
+
if (notice)
|
|
80
|
+
deps.notify(notice);
|
|
81
|
+
return outcome;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/** Register the check once on the host's channel. The renderer only awaits; main shows every notice. O(1). */
|
|
85
|
+
export function registerUpdateCheckIpc({ ipcMain, channel, checkNow }, _optional = {}) {
|
|
86
|
+
ipcMain.handle(channel, async () => { await checkNow(); });
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=update-check-now.js.map
|
|
@@ -12,12 +12,9 @@ export interface FindInPageQuery {
|
|
|
12
12
|
forward: boolean;
|
|
13
13
|
findNext: boolean;
|
|
14
14
|
}
|
|
15
|
-
/**
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
activeMatchOrdinal: number;
|
|
19
|
-
matches: number;
|
|
20
|
-
}
|
|
15
|
+
/** Wire shape owned by core (1-based ordinal + total, zero when nothing matched); see its doc. */
|
|
16
|
+
export type { FindInPageResult } from "@jini-ai/core/contracts/find-in-page";
|
|
17
|
+
import type { FindInPageResult } from "@jini-ai/core/contracts/find-in-page";
|
|
21
18
|
export interface FindWebContentsPort {
|
|
22
19
|
findInPage(args: {
|
|
23
20
|
text: string;
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
+
import { orFallbackSync } from '@jini-ai/core/errors/idioms';
|
|
1
2
|
/** Resolve a caller-owned filename without introducing a fixed persistence key. */
|
|
2
3
|
export function windowBoundsFilePath({ userDataDir, fileName, joinPath }) { return joinPath({ directory: userDataDir, filename: fileName }); }
|
|
3
4
|
/** Treat missing, unreadable or malformed persisted rectangles as absent. */
|
|
4
5
|
export function readWindowBounds({ store, key }) {
|
|
5
6
|
// Geometry is a cache: a corrupt or unreadable entry must degrade to the safe centered default,
|
|
6
7
|
// not prevent application startup.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
return orFallbackSync({
|
|
9
|
+
work: () => {
|
|
10
|
+
const parsed = store.read({ key });
|
|
11
|
+
if (parsed === null || typeof parsed !== "object")
|
|
12
|
+
return null;
|
|
13
|
+
const { x, y, width, height } = parsed;
|
|
14
|
+
if (![x, y, width, height].every((n) => typeof n === "number" && Number.isFinite(n)))
|
|
15
|
+
return null;
|
|
16
|
+
return { x: x, y: y, width: width, height: height };
|
|
17
|
+
},
|
|
18
|
+
fallback: null,
|
|
19
|
+
step: 'Read saved window bounds',
|
|
20
|
+
});
|
|
19
21
|
}
|
|
20
22
|
/** Store geometry using the host's persistence adapter. Write failures propagate. */
|
|
21
23
|
export function writeWindowBounds({ store, key, bounds }) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* zoom roles target the focused window's top-level webContents, which is wrong when a guest tab
|
|
4
4
|
* is visible. Keep native menu construction outside this module to avoid a runtime Electron dependency.
|
|
5
5
|
*/
|
|
6
|
-
type
|
|
6
|
+
import type { ZoomDirection as ZoomCommandDirection } from "@jini-ai/core/contracts/desktop-zoom";
|
|
7
7
|
interface ZoomCommandWindow {
|
|
8
8
|
isDestroyed(): boolean;
|
|
9
9
|
webContents?: {
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structural types for Electron's `<webview>` tag as a renderer sees it: the extra fields its
|
|
3
|
+
* events carry and the methods the tag element exposes directly on the DOM node.
|
|
4
|
+
*
|
|
5
|
+
* Declared here rather than imported from `electron`: a host renderer usually must not import the
|
|
6
|
+
* `electron` package at all (type-only imports included), so these carry only the fields renderer
|
|
7
|
+
* code actually reads — narrower than Electron's own `DidFailLoadEvent`/`Result`/`WebviewTag`, but
|
|
8
|
+
* costing nothing a caller needed. They are DOM-free on purpose (this package has no DOM lib and no
|
|
9
|
+
* React): the host combines them with `Event`/`HTMLElement` in its own global/JSX declarations.
|
|
10
|
+
*/
|
|
11
|
+
/** `did-fail-load`'s extra fields beyond `Event`. */
|
|
12
|
+
export interface WebviewDidFailLoadDetail {
|
|
13
|
+
readonly isMainFrame: boolean;
|
|
14
|
+
readonly errorCode: number;
|
|
15
|
+
}
|
|
16
|
+
/** `did-navigate`'s extra field beyond `Event`. */
|
|
17
|
+
export interface WebviewDidNavigateDetail {
|
|
18
|
+
readonly url: string;
|
|
19
|
+
}
|
|
20
|
+
/** `did-navigate-in-page`'s extra fields beyond `Event`. */
|
|
21
|
+
export interface WebviewDidNavigateInPageDetail {
|
|
22
|
+
readonly url: string;
|
|
23
|
+
readonly isMainFrame: boolean;
|
|
24
|
+
}
|
|
25
|
+
/** Narrowed to the two fields a find-in-page caller reads off Electron's own `Result`. */
|
|
26
|
+
export interface WebviewFoundInPageResult {
|
|
27
|
+
readonly activeMatchOrdinal: number;
|
|
28
|
+
readonly matches: number;
|
|
29
|
+
}
|
|
30
|
+
/** `found-in-page`'s extra field beyond `Event`. */
|
|
31
|
+
export interface WebviewFoundInPageDetail {
|
|
32
|
+
readonly result: WebviewFoundInPageResult;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The `<webview>` element methods a host renderer calls. Electron's `WebviewTag` exposes these on
|
|
36
|
+
* the DOM element itself, so history, reload, find and zoom on a guest need no IPC at all.
|
|
37
|
+
* Every one of these throws until the guest is attached (`dom-ready` has fired); callers catch that.
|
|
38
|
+
*/
|
|
39
|
+
export interface WebviewTagMethods {
|
|
40
|
+
canGoBack(): boolean;
|
|
41
|
+
canGoForward(): boolean;
|
|
42
|
+
goBack(): void;
|
|
43
|
+
goForward(): void;
|
|
44
|
+
/** Keeps the guest's history, which a `key` remount would not. */
|
|
45
|
+
reload(): void;
|
|
46
|
+
reloadIgnoringCache(): void;
|
|
47
|
+
getURL(): string;
|
|
48
|
+
loadURL(url: string, options?: {
|
|
49
|
+
extraHeaders?: string;
|
|
50
|
+
}): Promise<void>;
|
|
51
|
+
/** Begins (or steps through) a search; the result arrives on the `found-in-page` event,
|
|
52
|
+
* never as this call's return value in practice. */
|
|
53
|
+
findInPage(text: string, options?: {
|
|
54
|
+
forward?: boolean;
|
|
55
|
+
findNext?: boolean;
|
|
56
|
+
matchCase?: boolean;
|
|
57
|
+
}): number;
|
|
58
|
+
stopFindInPage(action: "clearSelection" | "keepSelection" | "activateSelection"): void;
|
|
59
|
+
/** 0 is 100%. */
|
|
60
|
+
getZoomLevel(): number;
|
|
61
|
+
setZoomLevel(level: number): void;
|
|
62
|
+
/** Runs a script in the guest's main frame and resolves its value (e.g. asking a hidden guest
|
|
63
|
+
* whether it may be released, or restoring a guest's scroll position). */
|
|
64
|
+
executeJavaScript(code: string, userGesture?: boolean): Promise<unknown>;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=webview-types.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structural types for Electron's `<webview>` tag as a renderer sees it: the extra fields its
|
|
3
|
+
* events carry and the methods the tag element exposes directly on the DOM node.
|
|
4
|
+
*
|
|
5
|
+
* Declared here rather than imported from `electron`: a host renderer usually must not import the
|
|
6
|
+
* `electron` package at all (type-only imports included), so these carry only the fields renderer
|
|
7
|
+
* code actually reads — narrower than Electron's own `DidFailLoadEvent`/`Result`/`WebviewTag`, but
|
|
8
|
+
* costing nothing a caller needed. They are DOM-free on purpose (this package has no DOM lib and no
|
|
9
|
+
* React): the host combines them with `Event`/`HTMLElement` in its own global/JSX declarations.
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=webview-types.js.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file A standalone sandboxed app window: its constructor options and its setup ORDER — window
|
|
3
|
+
* tracking, title pinning and the navigation boundary all before the first load — verified without
|
|
4
|
+
* Electron. The host injects the title, URL, partition, preload path, a `BrowserWindow` factory and
|
|
5
|
+
* the navigation-policy installer; nothing here imports Electron or knows the host's product copy.
|
|
6
|
+
*/
|
|
7
|
+
import type { ElectronNavigableContents } from "../navigation-policy/index.js";
|
|
8
|
+
/** The `BrowserWindow` options {@link createAppWindow} builds. */
|
|
9
|
+
interface AppWindowOptions {
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
minWidth: number;
|
|
13
|
+
minHeight: number;
|
|
14
|
+
title: string;
|
|
15
|
+
show: boolean;
|
|
16
|
+
webPreferences: {
|
|
17
|
+
contextIsolation: boolean;
|
|
18
|
+
nodeIntegration: boolean;
|
|
19
|
+
sandbox: boolean;
|
|
20
|
+
preload: string;
|
|
21
|
+
partition?: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/** The slice of a `BrowserWindow` {@link createAppWindow} touches; `C` is its `webContents`. */
|
|
25
|
+
interface AppWindow<C = ElectronNavigableContents> {
|
|
26
|
+
webContents: C;
|
|
27
|
+
on(event: "page-title-updated", listener: (event: {
|
|
28
|
+
preventDefault(): void;
|
|
29
|
+
}) => void): unknown;
|
|
30
|
+
loadURL(url: string): Promise<unknown>;
|
|
31
|
+
}
|
|
32
|
+
/** The host-supplied effects {@link createAppWindow} drives. */
|
|
33
|
+
interface AppWindowPorts<W extends AppWindow<unknown>> {
|
|
34
|
+
/** `(options) => new BrowserWindow(options)`. */
|
|
35
|
+
createBrowserWindow: (options: AppWindowOptions) => W;
|
|
36
|
+
/** Installs the host's navigation boundary on the new window's contents, pinned to `appOrigin`. */
|
|
37
|
+
installNavigationPolicy: (required: {
|
|
38
|
+
contents: W["webContents"];
|
|
39
|
+
appOrigin: string;
|
|
40
|
+
}) => void;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The constructor options for one standalone app window.
|
|
44
|
+
*
|
|
45
|
+
* @param required.preloadPath the compiled preload every app window gets.
|
|
46
|
+
* @param required.title the window title (host copy).
|
|
47
|
+
* @param optional.partition a per-site cookie partition; omitted entirely (not set to `undefined`) when absent.
|
|
48
|
+
* @param optional.selftest a self-test keeps every window hidden.
|
|
49
|
+
* @returns the constructor options.
|
|
50
|
+
* @complexity O(1).
|
|
51
|
+
*/
|
|
52
|
+
declare function appWindowOptions({ preloadPath, title }: {
|
|
53
|
+
preloadPath: string;
|
|
54
|
+
title: string;
|
|
55
|
+
}, { partition, selftest }?: {
|
|
56
|
+
partition?: string | undefined;
|
|
57
|
+
selftest?: boolean | undefined;
|
|
58
|
+
}): AppWindowOptions;
|
|
59
|
+
/**
|
|
60
|
+
* Create, guard and load one standalone app window.
|
|
61
|
+
*
|
|
62
|
+
* @param required.url the URL to load; its parsed origin is the only one the window may stay on.
|
|
63
|
+
* @param required.title see {@link appWindowOptions}.
|
|
64
|
+
* @param required.preloadPath see {@link appWindowOptions}.
|
|
65
|
+
* @param required.ports the window factory and navigation-policy installer.
|
|
66
|
+
* @param optional.trackWindow a self-test tracker's `add`, when this launch has one.
|
|
67
|
+
* @returns the window, already loading `url`.
|
|
68
|
+
* @throws TypeError when `url` does not parse — before anything loads.
|
|
69
|
+
* @complexity O(1).
|
|
70
|
+
*/
|
|
71
|
+
declare function createAppWindow<W extends AppWindow<unknown>>({ url, title, preloadPath, ports }: {
|
|
72
|
+
url: string;
|
|
73
|
+
title: string;
|
|
74
|
+
preloadPath: string;
|
|
75
|
+
ports: AppWindowPorts<W>;
|
|
76
|
+
}, { partition, selftest, trackWindow }?: {
|
|
77
|
+
partition?: string | undefined;
|
|
78
|
+
selftest?: boolean | undefined;
|
|
79
|
+
trackWindow?: ((window: W) => void) | undefined;
|
|
80
|
+
}): W;
|
|
81
|
+
export { appWindowOptions, createAppWindow };
|
|
82
|
+
export type { AppWindow, AppWindowOptions, AppWindowPorts };
|
|
83
|
+
//# sourceMappingURL=app-window.d.ts.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The constructor options for one standalone app window.
|
|
3
|
+
*
|
|
4
|
+
* @param required.preloadPath the compiled preload every app window gets.
|
|
5
|
+
* @param required.title the window title (host copy).
|
|
6
|
+
* @param optional.partition a per-site cookie partition; omitted entirely (not set to `undefined`) when absent.
|
|
7
|
+
* @param optional.selftest a self-test keeps every window hidden.
|
|
8
|
+
* @returns the constructor options.
|
|
9
|
+
* @complexity O(1).
|
|
10
|
+
*/
|
|
11
|
+
function appWindowOptions({ preloadPath, title }, { partition, selftest = false } = {}) {
|
|
12
|
+
return {
|
|
13
|
+
width: 1360,
|
|
14
|
+
height: 900,
|
|
15
|
+
// Leave room for a navigation rail plus an editor; narrower host windows set their own floor.
|
|
16
|
+
minWidth: 1024,
|
|
17
|
+
minHeight: 700,
|
|
18
|
+
title,
|
|
19
|
+
show: !selftest,
|
|
20
|
+
webPreferences: {
|
|
21
|
+
contextIsolation: true,
|
|
22
|
+
nodeIntegration: false,
|
|
23
|
+
sandbox: true,
|
|
24
|
+
preload: preloadPath,
|
|
25
|
+
// One cookie jar per site. Cookies ignore PORT, so without this every loopback site shares
|
|
26
|
+
// `127.0.0.1`'s jar: site A's session cookie would be sent to site B's server, and B's login
|
|
27
|
+
// would overwrite A's. Absent for a single-site attach, which keeps the default session.
|
|
28
|
+
...(partition ? { partition } : {}),
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Create, guard and load one standalone app window.
|
|
34
|
+
*
|
|
35
|
+
* @param required.url the URL to load; its parsed origin is the only one the window may stay on.
|
|
36
|
+
* @param required.title see {@link appWindowOptions}.
|
|
37
|
+
* @param required.preloadPath see {@link appWindowOptions}.
|
|
38
|
+
* @param required.ports the window factory and navigation-policy installer.
|
|
39
|
+
* @param optional.trackWindow a self-test tracker's `add`, when this launch has one.
|
|
40
|
+
* @returns the window, already loading `url`.
|
|
41
|
+
* @throws TypeError when `url` does not parse — before anything loads.
|
|
42
|
+
* @complexity O(1).
|
|
43
|
+
*/
|
|
44
|
+
function createAppWindow({ url, title, preloadPath, ports }, { partition, selftest = false, trackWindow } = {}) {
|
|
45
|
+
const window = ports.createBrowserWindow(appWindowOptions({ preloadPath, title }, { partition, selftest }));
|
|
46
|
+
// Registered BEFORE `loadURL` below, and before this function returns to its caller: a self-test
|
|
47
|
+
// tracker that only learns of a window after its first load can miss that load's failure.
|
|
48
|
+
trackWindow?.(window);
|
|
49
|
+
// Electron adopts the loaded page's own `document.title` by default, overwriting the `title` this
|
|
50
|
+
// constructor was given the instant the page finishes loading. When every site's page sets the
|
|
51
|
+
// SAME title, a multi-window launch ends up with indistinguishable windows, which defeats a native
|
|
52
|
+
// Window menu doubling as a site switcher. `preventDefault()` keeps each window pinned to the title
|
|
53
|
+
// it was given at creation.
|
|
54
|
+
window.on("page-title-updated", (event) => event.preventDefault());
|
|
55
|
+
// Anything that navigates away from the app's own origin belongs in the OS browser, and nothing
|
|
56
|
+
// but this origin may run with the preload. The boundary must answer before the first load starts.
|
|
57
|
+
ports.installNavigationPolicy({ contents: window.webContents, appOrigin: new URL(url).origin });
|
|
58
|
+
void window.loadURL(url);
|
|
59
|
+
return window;
|
|
60
|
+
}
|
|
61
|
+
export { appWindowOptions, createAppWindow };
|
|
62
|
+
//# sourceMappingURL=app-window.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The macOS dock tile's icon: skip where there is no dock, never fail the boot over an icon.
|
|
3
|
+
* The host injects `app.dock`, the icon path and a failure reporter, which receives the raw caught
|
|
4
|
+
* value and owns its formatting and any log copy.
|
|
5
|
+
*/
|
|
6
|
+
/** The slice of `app.dock` {@link applyDockIcon} touches. */
|
|
7
|
+
interface DockIconPort {
|
|
8
|
+
setIcon(iconPath: string): void;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Put the host's mark on the macOS dock tile.
|
|
12
|
+
*
|
|
13
|
+
* `BrowserWindow`'s own `icon` option is a no-op on macOS — the tile comes from the `.app` bundle,
|
|
14
|
+
* which an unpackaged `electron .` run does not have, so it shows Electron's own default instead.
|
|
15
|
+
* `app.dock.setIcon` is the only thing that changes it for a dev run. Guarded on the API existing
|
|
16
|
+
* rather than on the platform string alone, since `app.dock` is undefined off darwin.
|
|
17
|
+
*
|
|
18
|
+
* Best-effort: a missing or unreadable icon file must not stop the app booting.
|
|
19
|
+
*
|
|
20
|
+
* @param required.dock `app.dock`; `undefined` off macOS.
|
|
21
|
+
* @param required.iconPath the icon PNG.
|
|
22
|
+
* @param required.reportFailure receives the raw caught value when the icon could not be set.
|
|
23
|
+
* @complexity O(1).
|
|
24
|
+
*/
|
|
25
|
+
declare function applyDockIcon({ dock, iconPath, reportFailure }: {
|
|
26
|
+
dock: DockIconPort | undefined;
|
|
27
|
+
iconPath: string;
|
|
28
|
+
reportFailure: (required: {
|
|
29
|
+
error: unknown;
|
|
30
|
+
}) => void;
|
|
31
|
+
}, _optional?: {}): void;
|
|
32
|
+
export { applyDockIcon };
|
|
33
|
+
export type { DockIconPort };
|
|
34
|
+
//# sourceMappingURL=dock-icon.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The macOS dock tile's icon: skip where there is no dock, never fail the boot over an icon.
|
|
3
|
+
* The host injects `app.dock`, the icon path and a failure reporter, which receives the raw caught
|
|
4
|
+
* value and owns its formatting and any log copy.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Put the host's mark on the macOS dock tile.
|
|
8
|
+
*
|
|
9
|
+
* `BrowserWindow`'s own `icon` option is a no-op on macOS — the tile comes from the `.app` bundle,
|
|
10
|
+
* which an unpackaged `electron .` run does not have, so it shows Electron's own default instead.
|
|
11
|
+
* `app.dock.setIcon` is the only thing that changes it for a dev run. Guarded on the API existing
|
|
12
|
+
* rather than on the platform string alone, since `app.dock` is undefined off darwin.
|
|
13
|
+
*
|
|
14
|
+
* Best-effort: a missing or unreadable icon file must not stop the app booting.
|
|
15
|
+
*
|
|
16
|
+
* @param required.dock `app.dock`; `undefined` off macOS.
|
|
17
|
+
* @param required.iconPath the icon PNG.
|
|
18
|
+
* @param required.reportFailure receives the raw caught value when the icon could not be set.
|
|
19
|
+
* @complexity O(1).
|
|
20
|
+
*/
|
|
21
|
+
function applyDockIcon({ dock, iconPath, reportFailure }, _optional = {}) {
|
|
22
|
+
if (!dock)
|
|
23
|
+
return;
|
|
24
|
+
try {
|
|
25
|
+
dock.setIcon(iconPath);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
reportFailure({ error });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export { applyDockIcon };
|
|
32
|
+
//# sourceMappingURL=dock-icon.js.map
|
package/dist/logging.js
CHANGED
|
@@ -36,9 +36,11 @@ function serializeMessage({ level, message }, { safeMeta } = {}) {
|
|
|
36
36
|
}
|
|
37
37
|
catch (error) {
|
|
38
38
|
// The serializer's own error is described like any other: its text can name meta content.
|
|
39
|
+
// A non-string message may be the very value that failed (e.g. circular), so it is not
|
|
40
|
+
// re-serialized here: this fallback must not throw.
|
|
39
41
|
return `${JSON.stringify({
|
|
40
42
|
level,
|
|
41
|
-
message,
|
|
43
|
+
message: typeof message === 'string' ? message : 'Log message could not be serialized',
|
|
42
44
|
timestamp,
|
|
43
45
|
meta: { serializationError: describeErrorForLog({ err: error }) },
|
|
44
46
|
})}\n`;
|