bunite-core 0.17.1 → 0.17.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bunite-core",
3
3
  "description": "Uniting UI and Bun",
4
- "version": "0.17.1",
4
+ "version": "0.17.3",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "setup:cef": "bun ../tools/bunite-dev/scripts/setup-cef.ts",
@@ -1,27 +1,33 @@
1
- import { isAbsolute, join, resolve } from "node:path";
2
1
  import { existsSync } from "node:fs";
3
- import { getBaseDir } from "../paths";
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
- setRouteRequestHandler,
9
+ initNativeRuntime,
10
+ type NativeBootstrapOptions,
12
11
  setNativeLogLevel,
12
+ setRouteRequestHandler,
13
13
  toCString,
14
- type NativeBootstrapOptions
15
14
  } from "../native";
16
- import { ensureRpcServer } from "./Socket";
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 { log, logLevelToInt } from "../log";
22
- import { RuntimeCap, WindowCap, SurfaceCap, PageReportingCap, IpcError, type ImplOf } from "../../rpc/index";
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(() => { if (_instance === this) _instance = null; });
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 = process.env.XDG_DATA_HOME
70
- ?? (process.platform === "win32"
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 = "<html><body>Route handler error: " + (error instanceof Error ? error.message : String(error)) + "</body></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
  }