bunite-core 0.17.1 → 0.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/host/core/App.ts +28 -18
- package/src/host/core/BrowserView.ts +333 -116
- package/src/host/core/BrowserWindow.ts +44 -22
- package/src/host/core/Socket.ts +26 -9
- package/src/host/core/SurfaceBrowserIPC.ts +15 -5
- package/src/host/core/SurfaceManager.ts +345 -158
- package/src/host/core/SurfaceRegistry.ts +1 -1
- package/src/host/core/inputDispatch.ts +71 -42
- package/src/host/core/singleInstanceLock.ts +10 -2
- package/src/host/core/windowCap.ts +42 -23
- package/src/host/encryptedPipe.ts +12 -3
- package/src/host/events/appEvents.ts +1 -1
- package/src/host/events/eventEmitter.ts +6 -6
- package/src/host/events/webviewEvents.ts +11 -4
- package/src/host/events/windowEvents.ts +1 -2
- package/src/host/index.ts +9 -17
- package/src/host/log.ts +6 -4
- package/src/host/native.ts +271 -163
- package/src/host/paths.ts +18 -15
- package/src/host/platform.ts +2 -4
- package/src/host/preloadBundle.ts +1 -1
- package/src/host/serveWeb.ts +18 -11
- package/src/preload/runtime.built.js +1 -1
- package/src/preload/runtime.ts +61 -24
- package/src/rpc/encrypt.ts +15 -4
- package/src/rpc/error.ts +2 -7
- package/src/rpc/framework.ts +105 -35
- package/src/rpc/index.ts +129 -140
- package/src/rpc/peer.ts +430 -159
- package/src/rpc/renderer.ts +15 -9
- package/src/rpc/schema.ts +86 -61
- package/src/rpc/stream.ts +12 -3
- package/src/rpc/transport.ts +28 -9
- package/src/rpc/wire.ts +23 -10
- package/src/webview/native.ts +150 -73
- package/src/webview/polyfill.ts +184 -48
package/package.json
CHANGED
package/src/host/core/App.ts
CHANGED
|
@@ -1,27 +1,33 @@
|
|
|
1
|
-
import { isAbsolute, join, resolve } from "node:path";
|
|
2
1
|
import { existsSync } from "node:fs";
|
|
3
|
-
import {
|
|
2
|
+
import { isAbsolute, join, resolve } from "node:path";
|
|
4
3
|
import { buniteEventEmitter } from "../events/eventEmitter";
|
|
5
4
|
import {
|
|
6
5
|
getNativeEngineName,
|
|
7
6
|
getNativeEngineVersion,
|
|
8
7
|
getNativeLibrary,
|
|
9
|
-
initNativeRuntime,
|
|
10
8
|
getNativeRuntimeState,
|
|
11
|
-
|
|
9
|
+
initNativeRuntime,
|
|
10
|
+
type NativeBootstrapOptions,
|
|
12
11
|
setNativeLogLevel,
|
|
12
|
+
setRouteRequestHandler,
|
|
13
13
|
toCString,
|
|
14
|
-
type NativeBootstrapOptions
|
|
15
14
|
} from "../native";
|
|
16
|
-
import {
|
|
15
|
+
import { getBaseDir } from "../paths";
|
|
17
16
|
import { BrowserWindow } from "./BrowserWindow";
|
|
17
|
+
import { ensureRpcServer } from "./Socket";
|
|
18
18
|
import { createSurfaceCapImpl, getPopupMetricsSnapshot } from "./SurfaceManager";
|
|
19
19
|
import { createWindowCapImpl } from "./windowCap";
|
|
20
20
|
import "./SurfaceBrowserIPC";
|
|
21
|
-
import {
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
import {
|
|
22
|
+
type ImplOf,
|
|
23
|
+
IpcError,
|
|
24
|
+
PageReportingCap,
|
|
25
|
+
type RuntimeCap,
|
|
26
|
+
SurfaceCap,
|
|
27
|
+
WindowCap,
|
|
28
|
+
} from "../../rpc/index";
|
|
24
29
|
import type { LogLevel } from "../log";
|
|
30
|
+
import { log, logLevelToInt } from "../log";
|
|
25
31
|
|
|
26
32
|
type AppOptions = NativeBootstrapOptions & {
|
|
27
33
|
userDataDir?: string;
|
|
@@ -51,7 +57,9 @@ export class AppRuntime {
|
|
|
51
57
|
_instance = this;
|
|
52
58
|
ensureRpcServer();
|
|
53
59
|
this.ready = this.bootstrap(options);
|
|
54
|
-
this.ready.catch(() => {
|
|
60
|
+
this.ready.catch(() => {
|
|
61
|
+
if (_instance === this) _instance = null;
|
|
62
|
+
});
|
|
55
63
|
}
|
|
56
64
|
|
|
57
65
|
private async bootstrap(options: AppOptions) {
|
|
@@ -66,8 +74,9 @@ export class AppRuntime {
|
|
|
66
74
|
if (options.userDataDir) {
|
|
67
75
|
process.env.BUNITE_USER_DATA_DIR = options.userDataDir;
|
|
68
76
|
} else if (!process.env.BUNITE_USER_DATA_DIR) {
|
|
69
|
-
const appDataDir =
|
|
70
|
-
|
|
77
|
+
const appDataDir =
|
|
78
|
+
process.env.XDG_DATA_HOME ??
|
|
79
|
+
(process.platform === "win32"
|
|
71
80
|
? (process.env.APPDATA ?? join(process.env.USERPROFILE ?? "", "AppData", "Roaming"))
|
|
72
81
|
: process.platform === "darwin"
|
|
73
82
|
? join(process.env.HOME ?? "", "Library", "Application Support")
|
|
@@ -90,15 +99,13 @@ export class AppRuntime {
|
|
|
90
99
|
}
|
|
91
100
|
|
|
92
101
|
const envEngine = process.env.BUNITE_ENGINE;
|
|
93
|
-
const engineFromEnv = envEngine === "cef" || envEngine === "webview2"
|
|
94
|
-
? envEngine
|
|
95
|
-
: undefined;
|
|
102
|
+
const engineFromEnv = envEngine === "cef" || envEngine === "webview2" ? envEngine : undefined;
|
|
96
103
|
|
|
97
104
|
await initNativeRuntime({
|
|
98
105
|
hideConsole: options.hideConsole,
|
|
99
106
|
popupBlocking: options.popupBlocking,
|
|
100
107
|
engine: options.engine ?? engineFromEnv,
|
|
101
|
-
engineFlags: options.engineFlags
|
|
108
|
+
engineFlags: options.engineFlags,
|
|
102
109
|
});
|
|
103
110
|
|
|
104
111
|
if (options.logLevel) {
|
|
@@ -201,7 +208,7 @@ export class AppRuntime {
|
|
|
201
208
|
for (const entry of entries) {
|
|
202
209
|
buniteEventEmitter.emitEvent(
|
|
203
210
|
buniteEventEmitter.events.webview.consoleMessage(entry),
|
|
204
|
-
viewId
|
|
211
|
+
viewId,
|
|
205
212
|
);
|
|
206
213
|
}
|
|
207
214
|
});
|
|
@@ -233,7 +240,10 @@ export class AppRuntime {
|
|
|
233
240
|
const handler = this.appresHandlers.get(path);
|
|
234
241
|
html = handler ? handler() : "<html><body>No handler for: " + path + "</body></html>";
|
|
235
242
|
} catch (error) {
|
|
236
|
-
html =
|
|
243
|
+
html =
|
|
244
|
+
"<html><body>Route handler error: " +
|
|
245
|
+
(error instanceof Error ? error.message : String(error)) +
|
|
246
|
+
"</body></html>";
|
|
237
247
|
}
|
|
238
248
|
getNativeLibrary()?.symbols.bunite_complete_route_request(requestId, toCString(html));
|
|
239
249
|
}
|