@jini-ai/desktop-host 0.1.2 → 0.4.1
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 +113 -0
- package/README.md +194 -0
- package/dist/bridge-testing.d.ts +2 -2
- package/dist/bridge-testing.js +3 -3
- package/dist/bridge.d.ts +33 -9
- package/dist/bridge.js +18 -17
- package/dist/config.d.ts +1 -1
- package/dist/config.js +2 -1
- package/dist/electron/create-electron-desktop-host.js +5 -5
- package/dist/electron/electron-protocol.d.ts +3 -1
- package/dist/electron/electron-protocol.js +7 -7
- package/dist/electron/electron-render-service.d.ts +3 -1
- package/dist/electron/electron-render-service.js +21 -20
- package/dist/electron/electron-shell.js +8 -8
- package/dist/electron/electron-single-instance.d.ts +3 -1
- package/dist/electron/electron-single-instance.js +3 -3
- package/dist/electron/electron-surfaces.d.ts +71 -32
- package/dist/electron/electron-surfaces.js +3 -10
- package/dist/electron/electron-window-lifecycle.d.ts +3 -1
- package/dist/electron/electron-window-lifecycle.js +17 -16
- package/dist/electron/index.d.ts +17 -0
- package/dist/electron/index.js +17 -0
- package/dist/electron/navigation-policy/index.d.ts +3 -0
- package/dist/electron/navigation-policy/index.js +3 -0
- package/dist/electron/navigation-policy/webview-guest-policy.d.ts +32 -0
- package/dist/electron/navigation-policy/webview-guest-policy.js +31 -0
- package/dist/electron/navigation-policy/window-navigation-policy.d.ts +125 -0
- package/dist/electron/navigation-policy/window-navigation-policy.js +138 -0
- package/dist/electron/testing.d.ts +8 -6
- package/dist/electron/testing.js +22 -22
- package/dist/electron/updates/auto-update-controller.d.ts +146 -0
- package/dist/electron/updates/auto-update-controller.js +222 -0
- package/dist/electron/updates/index.d.ts +4 -0
- package/dist/electron/updates/index.js +4 -0
- package/dist/electron/updates/instance-presence.d.ts +68 -0
- package/dist/electron/updates/instance-presence.js +79 -0
- package/dist/electron/updates/update-policy.d.ts +66 -0
- package/dist/electron/updates/update-policy.js +65 -0
- package/dist/electron/usability/find-in-page-ipc.d.ts +88 -0
- package/dist/electron/usability/find-in-page-ipc.js +22 -0
- package/dist/electron/usability/find-menu.d.ts +43 -0
- package/dist/electron/usability/find-menu.js +22 -0
- package/dist/electron/usability/index.d.ts +6 -0
- package/dist/electron/usability/index.js +6 -0
- package/dist/electron/usability/spellcheck-menu.d.ts +92 -0
- package/dist/electron/usability/spellcheck-menu.js +52 -0
- package/dist/electron/usability/window-bounds-store.d.ts +76 -0
- package/dist/electron/usability/window-bounds-store.js +44 -0
- package/dist/electron/usability/zoom-menu.d.ts +41 -0
- package/dist/electron/usability/zoom-menu.js +19 -0
- package/dist/index.d.ts +8 -16
- package/dist/index.js +8 -16
- package/dist/logging.d.ts +26 -12
- package/dist/logging.js +21 -21
- package/dist/node-toolchain/index.d.ts +76 -0
- package/dist/node-toolchain/index.js +96 -0
- package/dist/paths.d.ts +4 -2
- package/dist/paths.js +5 -4
- package/dist/protocol.d.ts +20 -5
- package/dist/protocol.js +5 -5
- package/dist/render-service.d.ts +31 -7
- package/dist/render-service.js +10 -10
- package/dist/shell.d.ts +15 -7
- package/dist/shell.js +3 -3
- package/dist/shutdown/index.d.ts +4 -0
- package/dist/shutdown/index.js +4 -0
- package/dist/shutdown/quit-drain-gate.d.ts +19 -0
- package/dist/shutdown/quit-drain-gate.js +15 -0
- package/dist/shutdown/quit-signals.d.ts +36 -0
- package/dist/shutdown/quit-signals.js +27 -0
- package/dist/shutdown/shutdown-tracker.d.ts +19 -0
- package/dist/shutdown/shutdown-tracker.js +26 -0
- package/dist/sidecar.d.ts +20 -8
- package/dist/sidecar.js +39 -22
- package/dist/single-instance.d.ts +13 -4
- package/dist/single-instance.js +4 -4
- package/dist/speech/channels.d.ts +8 -0
- package/dist/speech/channels.js +5 -0
- package/dist/speech/index.d.ts +5 -0
- package/dist/speech/index.js +5 -0
- package/dist/speech/macos/index.d.ts +2 -0
- package/dist/speech/macos/index.js +2 -0
- package/dist/speech/macos/mac-on-device-transcriber.d.ts +98 -0
- package/dist/speech/macos/mac-on-device-transcriber.js +127 -0
- package/dist/speech/macos/speech-helper.swift +157 -0
- package/dist/speech/pcm-wav-encoder.d.ts +22 -0
- package/dist/speech/pcm-wav-encoder.js +50 -0
- package/dist/speech/speech-bridge.d.ts +33 -0
- package/dist/speech/speech-bridge.js +14 -0
- package/dist/speech/speech-ipc.d.ts +44 -0
- package/dist/speech/speech-ipc.js +50 -0
- package/dist/speech/transcription-port.d.ts +42 -0
- package/dist/speech/transcription-port.js +14 -0
- package/dist/tauri/create-tauri-desktop-host.js +5 -5
- package/dist/tauri/index.d.ts +19 -0
- package/dist/tauri/index.js +19 -0
- package/dist/tauri/not-implemented.d.ts +3 -1
- package/dist/tauri/not-implemented.js +1 -1
- package/dist/tauri/tauri-protocol.d.ts +1 -1
- package/dist/tauri/tauri-protocol.js +2 -2
- package/dist/tauri/tauri-render-service.d.ts +1 -1
- package/dist/tauri/tauri-render-service.js +2 -2
- package/dist/tauri/tauri-shell.js +8 -8
- package/dist/tauri/tauri-sidecar.d.ts +3 -1
- package/dist/tauri/tauri-sidecar.js +17 -16
- package/dist/tauri/tauri-single-instance.d.ts +3 -1
- package/dist/tauri/tauri-single-instance.js +3 -3
- package/dist/tauri/tauri-surfaces.d.ts +50 -14
- package/dist/tauri/tauri-surfaces.js +2 -1
- package/dist/tauri/tauri-window-lifecycle.d.ts +3 -1
- package/dist/tauri/tauri-window-lifecycle.js +33 -20
- package/dist/tauri/testing.d.ts +10 -7
- package/dist/tauri/testing.js +30 -23
- package/dist/tokens.js +6 -6
- package/dist/window-lifecycle.d.ts +10 -4
- package/dist/window-lifecycle.js +7 -7
- package/dist/windows-registry.d.ts +16 -6
- package/dist/windows-registry.js +8 -7
- package/package.json +71 -6
- package/dist/bridge-testing.d.ts.map +0 -1
- package/dist/bridge-testing.js.map +0 -1
- package/dist/bridge.d.ts.map +0 -1
- package/dist/bridge.js.map +0 -1
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js.map +0 -1
- package/dist/electron/create-electron-desktop-host.d.ts.map +0 -1
- package/dist/electron/create-electron-desktop-host.js.map +0 -1
- package/dist/electron/electron-protocol.d.ts.map +0 -1
- package/dist/electron/electron-protocol.js.map +0 -1
- package/dist/electron/electron-render-service.d.ts.map +0 -1
- package/dist/electron/electron-render-service.js.map +0 -1
- package/dist/electron/electron-shell.d.ts.map +0 -1
- package/dist/electron/electron-shell.js.map +0 -1
- package/dist/electron/electron-single-instance.d.ts.map +0 -1
- package/dist/electron/electron-single-instance.js.map +0 -1
- package/dist/electron/electron-surfaces.d.ts.map +0 -1
- package/dist/electron/electron-surfaces.js.map +0 -1
- package/dist/electron/electron-window-lifecycle.d.ts.map +0 -1
- package/dist/electron/electron-window-lifecycle.js.map +0 -1
- package/dist/electron/testing.d.ts.map +0 -1
- package/dist/electron/testing.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/logging.d.ts.map +0 -1
- package/dist/logging.js.map +0 -1
- package/dist/paths.d.ts.map +0 -1
- package/dist/paths.js.map +0 -1
- package/dist/ports.d.ts.map +0 -1
- package/dist/ports.js.map +0 -1
- package/dist/protocol.d.ts.map +0 -1
- package/dist/protocol.js.map +0 -1
- package/dist/render-service.d.ts.map +0 -1
- package/dist/render-service.js.map +0 -1
- package/dist/shell.d.ts.map +0 -1
- package/dist/shell.js.map +0 -1
- package/dist/sidecar.d.ts.map +0 -1
- package/dist/sidecar.js.map +0 -1
- package/dist/single-instance.d.ts.map +0 -1
- package/dist/single-instance.js.map +0 -1
- package/dist/tauri/create-tauri-desktop-host.d.ts.map +0 -1
- package/dist/tauri/create-tauri-desktop-host.js.map +0 -1
- package/dist/tauri/not-implemented.d.ts.map +0 -1
- package/dist/tauri/not-implemented.js.map +0 -1
- package/dist/tauri/tauri-protocol.d.ts.map +0 -1
- package/dist/tauri/tauri-protocol.js.map +0 -1
- package/dist/tauri/tauri-render-service.d.ts.map +0 -1
- package/dist/tauri/tauri-render-service.js.map +0 -1
- package/dist/tauri/tauri-shell.d.ts.map +0 -1
- package/dist/tauri/tauri-shell.js.map +0 -1
- package/dist/tauri/tauri-sidecar.d.ts.map +0 -1
- package/dist/tauri/tauri-sidecar.js.map +0 -1
- package/dist/tauri/tauri-single-instance.d.ts.map +0 -1
- package/dist/tauri/tauri-single-instance.js.map +0 -1
- package/dist/tauri/tauri-surfaces.d.ts.map +0 -1
- package/dist/tauri/tauri-surfaces.js.map +0 -1
- package/dist/tauri/tauri-window-lifecycle.d.ts.map +0 -1
- package/dist/tauri/tauri-window-lifecycle.js.map +0 -1
- package/dist/tauri/testing.d.ts.map +0 -1
- package/dist/tauri/testing.js.map +0 -1
- package/dist/tokens.d.ts.map +0 -1
- package/dist/tokens.js.map +0 -1
- package/dist/window-lifecycle.d.ts.map +0 -1
- package/dist/window-lifecycle.js.map +0 -1
- package/dist/windows-registry.d.ts.map +0 -1
- package/dist/windows-registry.js.map +0 -1
|
@@ -2,18 +2,18 @@ import { stat } from 'node:fs/promises';
|
|
|
2
2
|
import { ShellError } from '../shell.js';
|
|
3
3
|
export function createElectronShellPort(surfaces) {
|
|
4
4
|
return {
|
|
5
|
-
async openExternal(url) {
|
|
6
|
-
await surfaces.shell.openExternal(url);
|
|
5
|
+
async openExternal({ url }) {
|
|
6
|
+
await surfaces.shell.openExternal({ url });
|
|
7
7
|
},
|
|
8
|
-
async openPath(path) {
|
|
9
|
-
const errorMessage = await surfaces.shell.openPath(path);
|
|
8
|
+
async openPath({ path }) {
|
|
9
|
+
const errorMessage = await surfaces.shell.openPath({ path });
|
|
10
10
|
if (errorMessage.length > 0)
|
|
11
|
-
throw new ShellError(errorMessage);
|
|
11
|
+
throw new ShellError({ message: errorMessage });
|
|
12
12
|
},
|
|
13
13
|
// Electron main has full `node:fs` access — this matches `sidecar.ts`'s own precedent of
|
|
14
14
|
// calling `node:fs/promises` directly rather than adding a new structural Electron surface
|
|
15
15
|
// for a capability Electron's own main process didn't need mediating in the first place.
|
|
16
|
-
async dirExists(path) {
|
|
16
|
+
async dirExists({ path }) {
|
|
17
17
|
try {
|
|
18
18
|
const info = await stat(path);
|
|
19
19
|
return info.isDirectory();
|
|
@@ -25,8 +25,8 @@ export function createElectronShellPort(surfaces) {
|
|
|
25
25
|
async recentDirs() {
|
|
26
26
|
return surfaces.app.getRecentDocuments();
|
|
27
27
|
},
|
|
28
|
-
async openFolderDialog(options) {
|
|
29
|
-
const result = await surfaces.dialog.showOpenDialog({
|
|
28
|
+
async openFolderDialog(_requiredArgs, options) {
|
|
29
|
+
const result = await surfaces.dialog.showOpenDialog({}, {
|
|
30
30
|
properties: ['openDirectory'],
|
|
31
31
|
...(options?.defaultPath !== undefined ? { defaultPath: options.defaultPath } : {}),
|
|
32
32
|
});
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type SingleInstanceLockPort } from '../single-instance.js';
|
|
2
2
|
import type { ElectronAppLike } from './electron-surfaces.js';
|
|
3
|
-
export declare function createElectronSingleInstanceLockPort(app
|
|
3
|
+
export declare function createElectronSingleInstanceLockPort({ app }: {
|
|
4
|
+
app: ElectronAppLike;
|
|
5
|
+
}): SingleInstanceLockPort;
|
|
4
6
|
//# sourceMappingURL=electron-single-instance.d.ts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createSingleInstanceLockPort } from '../single-instance.js';
|
|
2
|
-
export function createElectronSingleInstanceLockPort(app) {
|
|
2
|
+
export function createElectronSingleInstanceLockPort({ app }) {
|
|
3
3
|
const adapted = {
|
|
4
4
|
requestSingleInstanceLock: () => app.requestSingleInstanceLock(),
|
|
5
5
|
quit: () => app.quit(),
|
|
6
|
-
onSecondInstance: (listener) => app.on('second-instance', listener),
|
|
6
|
+
onSecondInstance: ({ listener }) => app.on({ event: 'second-instance', listener }),
|
|
7
7
|
};
|
|
8
|
-
return createSingleInstanceLockPort(adapted);
|
|
8
|
+
return createSingleInstanceLockPort({ app: adapted });
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=electron-single-instance.js.map
|
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* package
|
|
4
|
-
* package — this package stays free of the Electron binary/native
|
|
5
|
-
* dependency, matching the VALIDATION brief's expectation that adapters
|
|
6
|
-
* are proven against "a fake/mock Electron webContents/BrowserWindow
|
|
7
|
-
* surface", not a real Electron runtime. A consumer running inside a real
|
|
8
|
-
* Electron main process passes the real `app`/`BrowserWindow`/`protocol`
|
|
9
|
-
* modules, which structurally satisfy these interfaces (Electron's real
|
|
10
|
-
* types are a superset of what's declared here).
|
|
1
|
+
/** Host-supplied Electron ports. Bind native SDK operations to the object-argument
|
|
2
|
+
* contracts below; native modules no longer structurally satisfy these interfaces.
|
|
3
|
+
* This package imports no Electron runtime and tests the bindings using its fakes.
|
|
11
4
|
*/
|
|
12
5
|
export interface ElectronAppLike {
|
|
13
6
|
requestSingleInstanceLock(): boolean;
|
|
14
7
|
quit(): void;
|
|
15
|
-
on(event
|
|
8
|
+
on({ event, listener }: {
|
|
9
|
+
event: 'second-instance';
|
|
10
|
+
listener: () => void;
|
|
11
|
+
}): void;
|
|
16
12
|
/** Real Electron: `app.getRecentDocuments()` — the OS-tracked recently-opened list (macOS Dock menu / Windows Jump List). Backs `ShellPort.recentDirs`. */
|
|
17
13
|
getRecentDocuments(): string[];
|
|
18
14
|
/** Real Electron: `app.addRecentDocument(path)`. Not called by anything in this package yet — declared alongside `getRecentDocuments` for interface symmetry with Electron's real API (a host wiring its own "open recent" UI can call it directly against the real `app` module without needing a port method here). */
|
|
19
|
-
addRecentDocument(path
|
|
15
|
+
addRecentDocument({ path }: {
|
|
16
|
+
path: string;
|
|
17
|
+
}): void;
|
|
20
18
|
}
|
|
21
19
|
export interface ElectronNavigationEvent {
|
|
22
20
|
preventDefault(): void;
|
|
@@ -28,37 +26,67 @@ export type ElectronBeforeRequestCallback = (response: {
|
|
|
28
26
|
cancel: boolean;
|
|
29
27
|
}) => void;
|
|
30
28
|
export interface ElectronWebRequestLike {
|
|
31
|
-
onBeforeRequest(listener
|
|
29
|
+
onBeforeRequest({ listener }: {
|
|
30
|
+
listener: ((args: {
|
|
31
|
+
details: ElectronBeforeRequestDetails;
|
|
32
|
+
callback: ElectronBeforeRequestCallback;
|
|
33
|
+
}) => void) | null;
|
|
34
|
+
}): void;
|
|
32
35
|
}
|
|
33
36
|
export interface ElectronSessionLike {
|
|
34
37
|
webRequest: ElectronWebRequestLike;
|
|
35
38
|
}
|
|
36
39
|
export interface ElectronWebContentsLike {
|
|
37
40
|
session: ElectronSessionLike;
|
|
38
|
-
loadURL(url
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
loadURL({ url }: {
|
|
42
|
+
url: string;
|
|
43
|
+
}): Promise<void>;
|
|
44
|
+
once({ event, listener }: {
|
|
45
|
+
event: 'did-finish-load';
|
|
46
|
+
listener: () => void;
|
|
47
|
+
}): void;
|
|
48
|
+
once({ event, listener }: {
|
|
49
|
+
event: 'did-fail-load';
|
|
50
|
+
listener: (args: {
|
|
51
|
+
event: unknown;
|
|
52
|
+
errorCode: number;
|
|
53
|
+
errorDescription: string;
|
|
54
|
+
}) => void;
|
|
55
|
+
}): void;
|
|
56
|
+
on({ event, listener }: {
|
|
57
|
+
event: 'will-navigate';
|
|
58
|
+
listener: (args: {
|
|
59
|
+
event: ElectronNavigationEvent;
|
|
60
|
+
url: string;
|
|
61
|
+
}) => void;
|
|
62
|
+
}): void;
|
|
42
63
|
printToPDF(options: Record<string, unknown>): Promise<Buffer>;
|
|
43
|
-
capturePage(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
64
|
+
capturePage(requiredArgs: Record<string, never>, optionalArgs?: {
|
|
65
|
+
rect?: {
|
|
66
|
+
x: number;
|
|
67
|
+
y: number;
|
|
68
|
+
width: number;
|
|
69
|
+
height: number;
|
|
70
|
+
} | undefined;
|
|
48
71
|
}): Promise<{
|
|
49
72
|
toPNG(): Buffer;
|
|
50
73
|
}>;
|
|
51
74
|
}
|
|
52
75
|
export interface ElectronBrowserWindowLike {
|
|
53
76
|
readonly webContents: ElectronWebContentsLike;
|
|
54
|
-
loadURL(url
|
|
77
|
+
loadURL({ url }: {
|
|
78
|
+
url: string;
|
|
79
|
+
}): Promise<void>;
|
|
55
80
|
show(): void;
|
|
56
81
|
hide(): void;
|
|
57
82
|
focus(): void;
|
|
58
83
|
close(): void;
|
|
59
84
|
destroy(): void;
|
|
60
85
|
isDestroyed(): boolean;
|
|
61
|
-
on(event
|
|
86
|
+
on({ event, listener }: {
|
|
87
|
+
event: 'closed';
|
|
88
|
+
listener: () => void;
|
|
89
|
+
}): void;
|
|
62
90
|
}
|
|
63
91
|
export interface ElectronBrowserWindowOptions {
|
|
64
92
|
show?: boolean;
|
|
@@ -70,7 +98,7 @@ export interface ElectronBrowserWindowOptions {
|
|
|
70
98
|
[key: string]: unknown;
|
|
71
99
|
};
|
|
72
100
|
}
|
|
73
|
-
export type ElectronBrowserWindowFactory = (
|
|
101
|
+
export type ElectronBrowserWindowFactory = (requiredArgs: Record<string, never>, optionalArgs?: ElectronBrowserWindowOptions) => ElectronBrowserWindowLike;
|
|
74
102
|
export interface ElectronProtocolPrivileges {
|
|
75
103
|
standard?: boolean;
|
|
76
104
|
secure?: boolean;
|
|
@@ -79,16 +107,27 @@ export interface ElectronProtocolPrivileges {
|
|
|
79
107
|
stream?: boolean;
|
|
80
108
|
}
|
|
81
109
|
export interface ElectronProtocolLike {
|
|
82
|
-
registerSchemesAsPrivileged(schemes:
|
|
110
|
+
registerSchemesAsPrivileged({ schemes }: {
|
|
111
|
+
schemes: Array<{
|
|
112
|
+
scheme: string;
|
|
113
|
+
privileges: ElectronProtocolPrivileges;
|
|
114
|
+
}>;
|
|
115
|
+
}): void;
|
|
116
|
+
handle({ scheme, handler }: {
|
|
83
117
|
scheme: string;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
118
|
+
handler: (args: {
|
|
119
|
+
request: Request;
|
|
120
|
+
}) => Promise<Response>;
|
|
121
|
+
}): void;
|
|
87
122
|
}
|
|
88
123
|
export interface ElectronShellLike {
|
|
89
124
|
/** Resolves to the empty string on success, an error message otherwise — matches Electron's real `shell.openPath` contract. */
|
|
90
|
-
openPath(path
|
|
91
|
-
|
|
125
|
+
openPath({ path }: {
|
|
126
|
+
path: string;
|
|
127
|
+
}): Promise<string>;
|
|
128
|
+
openExternal({ url }: {
|
|
129
|
+
url: string;
|
|
130
|
+
}): Promise<void>;
|
|
92
131
|
}
|
|
93
132
|
export interface ElectronOpenDialogOptions {
|
|
94
133
|
readonly properties?: readonly string[];
|
|
@@ -100,6 +139,6 @@ export interface ElectronOpenDialogResult {
|
|
|
100
139
|
}
|
|
101
140
|
/** Structural subset of Electron's real `dialog` module this package's Tauri-sibling `ShellPort.openFolderDialog` backs. Matches `dialog.showOpenDialog`'s real documented contract (`canceled`/`filePaths`). */
|
|
102
141
|
export interface ElectronDialogLike {
|
|
103
|
-
showOpenDialog(
|
|
142
|
+
showOpenDialog(requiredArgs: Record<string, never>, optionalArgs?: ElectronOpenDialogOptions): Promise<ElectronOpenDialogResult>;
|
|
104
143
|
}
|
|
105
144
|
//# sourceMappingURL=electron-surfaces.d.ts.map
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* package
|
|
4
|
-
* package — this package stays free of the Electron binary/native
|
|
5
|
-
* dependency, matching the VALIDATION brief's expectation that adapters
|
|
6
|
-
* are proven against "a fake/mock Electron webContents/BrowserWindow
|
|
7
|
-
* surface", not a real Electron runtime. A consumer running inside a real
|
|
8
|
-
* Electron main process passes the real `app`/`BrowserWindow`/`protocol`
|
|
9
|
-
* modules, which structurally satisfy these interfaces (Electron's real
|
|
10
|
-
* types are a superset of what's declared here).
|
|
1
|
+
/** Host-supplied Electron ports. Bind native SDK operations to the object-argument
|
|
2
|
+
* contracts below; native modules no longer structurally satisfy these interfaces.
|
|
3
|
+
* This package imports no Electron runtime and tests the bindings using its fakes.
|
|
11
4
|
*/
|
|
12
5
|
export {};
|
|
13
6
|
//# sourceMappingURL=electron-surfaces.js.map
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type WindowLifecyclePort } from '../window-lifecycle.js';
|
|
2
2
|
import type { ElectronBrowserWindowFactory } from './electron-surfaces.js';
|
|
3
|
-
export declare function createElectronWindowLifecyclePort(createBrowserWindow
|
|
3
|
+
export declare function createElectronWindowLifecyclePort({ createBrowserWindow }: {
|
|
4
|
+
createBrowserWindow: ElectronBrowserWindowFactory;
|
|
5
|
+
}): WindowLifecyclePort;
|
|
4
6
|
//# sourceMappingURL=electron-window-lifecycle.d.ts.map
|
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
import { withMainWindowTracking } from '../window-lifecycle.js';
|
|
2
2
|
function toWindowHandle(win) {
|
|
3
3
|
return {
|
|
4
|
-
async loadUrl(url) {
|
|
5
|
-
await win.loadURL(url);
|
|
4
|
+
async loadUrl({ url }) {
|
|
5
|
+
await win.loadURL({ url });
|
|
6
6
|
},
|
|
7
7
|
show: () => win.show(),
|
|
8
8
|
hide: () => win.hide(),
|
|
9
9
|
focus: () => win.focus(),
|
|
10
10
|
close: () => win.close(),
|
|
11
11
|
isDestroyed: () => win.isDestroyed(),
|
|
12
|
-
onClosed: (listener) => win.on('closed', listener),
|
|
12
|
+
onClosed: ({ listener }) => win.on({ event: 'closed', listener }),
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
export function createElectronWindowLifecyclePort(createBrowserWindow) {
|
|
16
|
-
return withMainWindowTracking(async (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
15
|
+
export function createElectronWindowLifecyclePort({ createBrowserWindow }) {
|
|
16
|
+
return withMainWindowTracking({ createWindowImpl: async (requiredArgs, optionalArgs = {}) => {
|
|
17
|
+
const options = { ...optionalArgs, ...requiredArgs };
|
|
18
|
+
const win = createBrowserWindow({}, {
|
|
19
|
+
show: options.show ?? false,
|
|
20
|
+
...(options.width == null ? {} : { width: options.width }),
|
|
21
|
+
...(options.height == null ? {} : { height: options.height }),
|
|
22
|
+
});
|
|
23
|
+
const handle = toWindowHandle(win);
|
|
24
|
+
await handle.loadUrl({ url: options.url });
|
|
25
|
+
if (options.show ?? true)
|
|
26
|
+
handle.show();
|
|
27
|
+
return handle;
|
|
28
|
+
} });
|
|
28
29
|
}
|
|
29
30
|
//# sourceMappingURL=electron-window-lifecycle.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@jini-ai/desktop-host/electron` — the full Electron shell assembly. Split from the package's
|
|
3
|
+
* main `.` entry point (2026-07-29) so an Electron app doesn't statically import the equally-full
|
|
4
|
+
* Tauri assembly it will never call, and vice versa — mirrors `@jini-ai/agentic`'s `.`/`./dom`
|
|
5
|
+
* subpath precedent. The shared, shell-agnostic port types/utilities
|
|
6
|
+
* (`single-instance.ts`/`window-lifecycle.ts`/`protocol.ts`/`sidecar.ts`/`shell.ts`/`ports.ts`/etc.)
|
|
7
|
+
* stay at the package's main entry point; only the concrete Electron implementation lives here.
|
|
8
|
+
*/
|
|
9
|
+
export * from './electron-surfaces.js';
|
|
10
|
+
export * from './electron-single-instance.js';
|
|
11
|
+
export * from './electron-window-lifecycle.js';
|
|
12
|
+
export * from './electron-protocol.js';
|
|
13
|
+
export * from './electron-render-service.js';
|
|
14
|
+
export * from './electron-shell.js';
|
|
15
|
+
export * from './create-electron-desktop-host.js';
|
|
16
|
+
export * from './testing.js';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@jini-ai/desktop-host/electron` — the full Electron shell assembly. Split from the package's
|
|
3
|
+
* main `.` entry point (2026-07-29) so an Electron app doesn't statically import the equally-full
|
|
4
|
+
* Tauri assembly it will never call, and vice versa — mirrors `@jini-ai/agentic`'s `.`/`./dom`
|
|
5
|
+
* subpath precedent. The shared, shell-agnostic port types/utilities
|
|
6
|
+
* (`single-instance.ts`/`window-lifecycle.ts`/`protocol.ts`/`sidecar.ts`/`shell.ts`/`ports.ts`/etc.)
|
|
7
|
+
* stay at the package's main entry point; only the concrete Electron implementation lives here.
|
|
8
|
+
*/
|
|
9
|
+
export * from './electron-surfaces.js';
|
|
10
|
+
export * from './electron-single-instance.js';
|
|
11
|
+
export * from './electron-window-lifecycle.js';
|
|
12
|
+
export * from './electron-protocol.js';
|
|
13
|
+
export * from './electron-render-service.js';
|
|
14
|
+
export * from './electron-shell.js';
|
|
15
|
+
export * from './create-electron-desktop-host.js';
|
|
16
|
+
export * from './testing.js';
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Main-process guest admission and unconditional preload/isolation preferences. */
|
|
2
|
+
interface GuestWebPreferences {
|
|
3
|
+
preload?: string;
|
|
4
|
+
nodeIntegration?: boolean;
|
|
5
|
+
contextIsolation?: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface GuestPolicyOptions {
|
|
8
|
+
preloadPath: string;
|
|
9
|
+
}
|
|
10
|
+
/** Overwrite the supplied guest preferences with the required preload, disabled Node and enabled isolation. Mutates the event object; throws for an empty preload. @complexity O(1). */
|
|
11
|
+
declare function applyGuestWebPreferences({ webPreferences, ...options }: GuestPolicyOptions & {
|
|
12
|
+
webPreferences: GuestWebPreferences;
|
|
13
|
+
}): void;
|
|
14
|
+
interface GuestAttachEvent {
|
|
15
|
+
preventDefault(): void;
|
|
16
|
+
}
|
|
17
|
+
interface GuestAttachParams {
|
|
18
|
+
src?: unknown;
|
|
19
|
+
}
|
|
20
|
+
interface GuestSourceOptions {
|
|
21
|
+
isAllowedSource: (args: {
|
|
22
|
+
src: string;
|
|
23
|
+
}) => boolean;
|
|
24
|
+
}
|
|
25
|
+
/** Admit only string sources approved by the host predicate. Missing sources and predicate failures prevent attachment. @complexity O(1) beyond the predicate. */
|
|
26
|
+
declare function admitGuestSource({ event, params, ...options }: GuestSourceOptions & {
|
|
27
|
+
event: GuestAttachEvent;
|
|
28
|
+
params: GuestAttachParams;
|
|
29
|
+
}): boolean;
|
|
30
|
+
export { applyGuestWebPreferences, admitGuestSource };
|
|
31
|
+
export type { GuestPolicyOptions, GuestWebPreferences, GuestSourceOptions };
|
|
32
|
+
//# sourceMappingURL=webview-guest-policy.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** Overwrite the supplied guest preferences with the required preload, disabled Node and enabled isolation. Mutates the event object; throws for an empty preload. @complexity O(1). */
|
|
2
|
+
function applyGuestWebPreferences({ webPreferences, ...options }) {
|
|
3
|
+
// The page chooses webview attributes before this main-process callback. Unconditionally replace
|
|
4
|
+
// its preferences; merging its requested values would let the page choose its own privilege grant.
|
|
5
|
+
// Assign a trusted preload rather than deleting it: embedded admin guests need the same narrow
|
|
6
|
+
// bridge as standalone windows. Mutate this object because Electron ignores a returned replacement.
|
|
7
|
+
if (typeof options?.preloadPath !== "string" || options.preloadPath.length === 0) {
|
|
8
|
+
throw new Error("applyGuestWebPreferences: options.preloadPath is required — a guest with no preload has no voice API.");
|
|
9
|
+
}
|
|
10
|
+
webPreferences.preload = options.preloadPath;
|
|
11
|
+
webPreferences.nodeIntegration = false;
|
|
12
|
+
webPreferences.contextIsolation = true;
|
|
13
|
+
}
|
|
14
|
+
/** Admit only string sources approved by the host predicate. Missing sources and predicate failures prevent attachment. @complexity O(1) beyond the predicate. */
|
|
15
|
+
function admitGuestSource({ event, params, ...options }) {
|
|
16
|
+
// Navigation confinement protects an attached guest, not its initial origin. Refuse the source
|
|
17
|
+
// before attach or an arbitrary page gets the trusted preload. Predicate errors become refusals:
|
|
18
|
+
// throwing out of the Electron callback can blank the host window instead of safely denying it.
|
|
19
|
+
let admitted = false;
|
|
20
|
+
try {
|
|
21
|
+
admitted = typeof params?.src === "string" && options.isAllowedSource({ src: params.src });
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
admitted = false;
|
|
25
|
+
}
|
|
26
|
+
if (!admitted)
|
|
27
|
+
event.preventDefault();
|
|
28
|
+
return admitted;
|
|
29
|
+
}
|
|
30
|
+
export { applyGuestWebPreferences, admitGuestSource };
|
|
31
|
+
//# sourceMappingURL=webview-guest-policy.js.map
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Windows and their popups can inherit privileged preloads, so only the original trusted
|
|
3
|
+
* page may load in-app. Compare complete parsed origins: a string prefix also admits
|
|
4
|
+
* http://127.0.0.1:4567@evil.example/ and http://127.0.0.1:45670/.
|
|
5
|
+
* Only HTTP(S) links reach the OS, because openExternal dispatches file, smb and custom
|
|
6
|
+
* schemes to whichever application claims them. Malformed URLs fail closed rather than
|
|
7
|
+
* throwing out of a navigation callback, where an exception would not constitute denial.
|
|
8
|
+
* The structural ports keep this boundary testable without importing Electron.
|
|
9
|
+
*/
|
|
10
|
+
/** Parsed URL boundaries for windows, renderer files and guest popups. Opaque origins fail closed. */
|
|
11
|
+
interface WindowOpenDetails {
|
|
12
|
+
url: string;
|
|
13
|
+
}
|
|
14
|
+
type WindowOpenResponse = {
|
|
15
|
+
action: "allow";
|
|
16
|
+
} | {
|
|
17
|
+
action: "deny";
|
|
18
|
+
};
|
|
19
|
+
interface NavigationEvent {
|
|
20
|
+
preventDefault(): void;
|
|
21
|
+
}
|
|
22
|
+
interface RedirectEvent extends NavigationEvent {
|
|
23
|
+
url: string;
|
|
24
|
+
isMainFrame: boolean;
|
|
25
|
+
}
|
|
26
|
+
/** Native WebContents methods keep Electron's positional callback registration ABI. */
|
|
27
|
+
interface ElectronNavigableContents {
|
|
28
|
+
setWindowOpenHandler(handler: (details: WindowOpenDetails) => WindowOpenResponse): void;
|
|
29
|
+
on(event: "will-navigate", listener: (event: NavigationEvent, url: string) => void): unknown;
|
|
30
|
+
on(event: "will-redirect", listener: (details: RedirectEvent) => void): unknown;
|
|
31
|
+
}
|
|
32
|
+
/** Object-shaped registration remains accepted until existing host glue is removed. */
|
|
33
|
+
interface LegacyNavigableContents {
|
|
34
|
+
setWindowOpenHandler({ handler }: {
|
|
35
|
+
handler: (details: WindowOpenDetails) => WindowOpenResponse;
|
|
36
|
+
}): void;
|
|
37
|
+
on({ event, listener }: {
|
|
38
|
+
event: "will-navigate";
|
|
39
|
+
listener: (args: {
|
|
40
|
+
event: NavigationEvent;
|
|
41
|
+
url: string;
|
|
42
|
+
}) => void;
|
|
43
|
+
}): unknown;
|
|
44
|
+
on({ event, listener }: {
|
|
45
|
+
event: "will-redirect";
|
|
46
|
+
listener: (details: RedirectEvent) => void;
|
|
47
|
+
}): unknown;
|
|
48
|
+
}
|
|
49
|
+
type NavigableContents = ElectronNavigableContents | LegacyNavigableContents;
|
|
50
|
+
type WindowOpenContents = Pick<ElectronNavigableContents, "setWindowOpenHandler"> | Pick<LegacyNavigableContents, "setWindowOpenHandler">;
|
|
51
|
+
interface AppWindowPolicyOptions {
|
|
52
|
+
appOrigin: string;
|
|
53
|
+
openExternal: (args: {
|
|
54
|
+
url: string;
|
|
55
|
+
}) => void;
|
|
56
|
+
}
|
|
57
|
+
/** Compare parsed, non-opaque origins; malformed URLs fail closed. @complexity O(n) in URL lengths. */
|
|
58
|
+
declare function isSameOrigin({ candidate, reference }: {
|
|
59
|
+
candidate: string;
|
|
60
|
+
reference: string;
|
|
61
|
+
}): boolean;
|
|
62
|
+
/** Admit only parseable HTTP and HTTPS browser URLs. @complexity O(n) in URL length. */
|
|
63
|
+
declare function isExternalBrowserUrl({ raw }: {
|
|
64
|
+
raw: string;
|
|
65
|
+
}): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Pin checks to the window creation origin, never its current location. Server-side 30x
|
|
68
|
+
* redirects do not emit will-navigate, so will-redirect closes that bypass too. Only main
|
|
69
|
+
* frames inherit the window preload; a cross-origin subframe is outside this boundary.
|
|
70
|
+
*/
|
|
71
|
+
/** Register popup, navigation and main-frame redirect boundaries against the initial app origin. @complexity O(1) registration; O(n) per URL. */
|
|
72
|
+
declare function installAppWindowNavigationPolicy({ contents, ...options }: AppWindowPolicyOptions & {
|
|
73
|
+
contents: NavigableContents;
|
|
74
|
+
}): void;
|
|
75
|
+
/**
|
|
76
|
+
* A renderer page CSP belongs to that document; replacing it with another local or remote
|
|
77
|
+
* page does not carry the CSP along, but can retain the privileged preload. file: origins
|
|
78
|
+
* are opaque, so this boundary compares the complete renderer URL rather than its origin.
|
|
79
|
+
*/
|
|
80
|
+
/** Allow only the renderer file itself, ignoring query and fragment. Foreign web URLs open externally. @complexity O(1) registration; O(n) per URL. */
|
|
81
|
+
declare function installRendererNavigationPolicy({ contents, ...options }: {
|
|
82
|
+
contents: NavigableContents;
|
|
83
|
+
rendererFileUrl: string;
|
|
84
|
+
openExternal: (args: {
|
|
85
|
+
url: string;
|
|
86
|
+
}) => void;
|
|
87
|
+
}): void;
|
|
88
|
+
interface GuestWindowOpenOptions {
|
|
89
|
+
isSupervisedGuestUrl: (args: {
|
|
90
|
+
url: string;
|
|
91
|
+
}) => boolean;
|
|
92
|
+
openExternal: (args: {
|
|
93
|
+
url: string;
|
|
94
|
+
}) => void;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* There is no second guest in which to open a popup. Forwarding only supervised URLs
|
|
98
|
+
* previously swallowed external sign-in links, so other HTTP(S) links also go to the OS.
|
|
99
|
+
* A thrown handoff can blank the guest window; failure must still return a denial.
|
|
100
|
+
*/
|
|
101
|
+
/** Deny every in-guest popup; forward permitted browser links through the supplied host port. Failed handoffs still deny. @complexity O(1) registration. */
|
|
102
|
+
declare function installGuestWindowOpenPolicy({ contents, ...options }: GuestWindowOpenOptions & {
|
|
103
|
+
contents: WindowOpenContents;
|
|
104
|
+
}): void;
|
|
105
|
+
interface ShellPages {
|
|
106
|
+
isSupervisedSite: (args: {
|
|
107
|
+
url: string;
|
|
108
|
+
}) => boolean;
|
|
109
|
+
rendererFileUrl: string;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* This is the sender boundary for privileged host IPC. Exact renderer matching keeps
|
|
113
|
+
* opaque file origins from trusting unrelated local pages; attach URLs use parsed origins.
|
|
114
|
+
* Malformed URL comparisons return false instead of throwing from the sender check.
|
|
115
|
+
*/
|
|
116
|
+
/** Trust supervised pages, the optional attach origin or the exact renderer file for host IPC. @complexity O(n) in URL length. */
|
|
117
|
+
declare function isShellPageUrl({ raw, pages }: {
|
|
118
|
+
raw: string;
|
|
119
|
+
pages: Omit<ShellPages, "attachUrl">;
|
|
120
|
+
}, { attachUrl }?: {
|
|
121
|
+
attachUrl?: string | undefined;
|
|
122
|
+
}): boolean;
|
|
123
|
+
export { isSameOrigin, isExternalBrowserUrl, installAppWindowNavigationPolicy, installGuestWindowOpenPolicy, installRendererNavigationPolicy, isShellPageUrl, };
|
|
124
|
+
export type { NavigableContents, ElectronNavigableContents, LegacyNavigableContents, AppWindowPolicyOptions, GuestWindowOpenOptions, WindowOpenResponse, ShellPages };
|
|
125
|
+
//# sourceMappingURL=window-navigation-policy.d.ts.map
|