bunite-core 0.12.1 → 0.16.0

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.
Files changed (36) hide show
  1. package/package.json +4 -4
  2. package/src/host/core/App.ts +19 -2
  3. package/src/host/core/BrowserView.ts +515 -38
  4. package/src/host/core/SurfaceBrowserIPC.ts +53 -3
  5. package/src/host/core/SurfaceManager.ts +603 -30
  6. package/src/host/core/SurfaceRegistry.ts +9 -1
  7. package/src/host/core/inputDispatch.ts +147 -0
  8. package/src/host/events/webviewEvents.ts +25 -1
  9. package/src/host/log.ts +6 -1
  10. package/src/host/native.ts +263 -1
  11. package/src/host/preloadBundle.ts +7 -2
  12. package/src/native/linux/bunite_linux_ffi.cpp +427 -6
  13. package/src/native/linux/bunite_linux_internal.h +18 -0
  14. package/src/native/linux/bunite_linux_runtime.cpp +6 -1
  15. package/src/native/linux/bunite_linux_utils.cpp +2 -2
  16. package/src/native/linux/bunite_linux_view.cpp +296 -5
  17. package/src/native/mac/bunite_mac_ffi.mm +630 -8
  18. package/src/native/mac/bunite_mac_internal.h +19 -0
  19. package/src/native/mac/bunite_mac_utils.mm +2 -2
  20. package/src/native/mac/bunite_mac_view.mm +371 -9
  21. package/src/native/shared/ffi_exports.h +200 -2
  22. package/src/native/win/native_host_cef.cpp +186 -11
  23. package/src/native/win/native_host_ffi.cpp +1194 -1
  24. package/src/native/win/native_host_internal.h +35 -0
  25. package/src/native/win/native_host_utils.cpp +2 -1
  26. package/src/native/win/process_helper_win.cpp +54 -27
  27. package/src/native/win-webview2/bunite_webview2_ffi.cpp +1023 -12
  28. package/src/native/win-webview2/webview2_internal.h +25 -0
  29. package/src/native/win-webview2/webview2_runtime.cpp +403 -34
  30. package/src/native/win-webview2/webview2_utils.cpp +30 -12
  31. package/src/preload/runtime.built.js +1 -1
  32. package/src/preload/runtime.ts +97 -0
  33. package/src/rpc/framework.ts +340 -8
  34. package/src/rpc/index.ts +32 -0
  35. package/src/webview/native.ts +253 -51
  36. package/src/webview/polyfill.ts +283 -22
@@ -1,10 +1,60 @@
1
- import { onSurfaceInit, emitDidNavigate, emitTitleChanged } from "./SurfaceManager";
1
+ import {
2
+ onSurfaceInit, emitSurfaceEvent, emitConsole, emitDownload, emitPopupRequested,
3
+ registerDialogRequest, disposeSurfaceState, clearConsoleBuffer,
4
+ } from "./SurfaceManager";
5
+ import { log } from "../log";
2
6
 
3
7
  onSurfaceInit((surfaceId, hostViewId, view) => {
8
+ log.debug("surface/init surfaceId=" + surfaceId + " hostViewId=" + hostViewId);
4
9
  view.on("did-navigate", (event: any) => {
5
- emitDidNavigate(hostViewId, surfaceId, event.data.detail);
10
+ emitSurfaceEvent(hostViewId, surfaceId, { type: "navigate", url: event.data.detail });
6
11
  });
7
12
  view.on("title-changed", (event: any) => {
8
- emitTitleChanged(hostViewId, surfaceId, event.data.detail);
13
+ emitSurfaceEvent(hostViewId, surfaceId, { type: "title-change", title: event.data.detail });
14
+ });
15
+ view.on("load-start", (event: any) => {
16
+ // Reload / fresh nav — clear retained host buffer so consumers don't see
17
+ // stale entries from the prior document.
18
+ clearConsoleBuffer(surfaceId);
19
+ emitSurfaceEvent(hostViewId, surfaceId, { type: "load-start", url: event.data.detail });
20
+ });
21
+ view.on("load-finish", (event: any) => {
22
+ emitSurfaceEvent(hostViewId, surfaceId, { type: "load-finish", url: event.data.detail });
23
+ });
24
+ view.on("load-fail", (event: any) => {
25
+ const d = event.data;
26
+ emitSurfaceEvent(hostViewId, surfaceId, {
27
+ type: "load-fail", url: d.url ?? "", reason: d.reason,
28
+ });
29
+ });
30
+ view.on("dialog", (event: any) => {
31
+ const d = event.data as {
32
+ requestId: number;
33
+ kind: "alert" | "confirm" | "prompt" | "beforeunload";
34
+ message: string;
35
+ defaultPrompt?: string;
36
+ };
37
+ log.debug("surface/dialog-ipc surfaceId=" + surfaceId + " hostViewId=" + hostViewId + " kind=" + d.kind);
38
+ registerDialogRequest(hostViewId, surfaceId, d);
39
+ });
40
+ view.on("console-message", (event: any) => {
41
+ // PageReportingCap impl already wraps the whole batch in a single
42
+ // microtask — no extra deferral needed at the listener level.
43
+ emitConsole(hostViewId, surfaceId, event.data);
44
+ });
45
+ view.on("download-event", (event: any) => {
46
+ emitDownload(hostViewId, surfaceId, event.data);
47
+ });
48
+ view.on("popup-requested", (event: any) => {
49
+ emitPopupRequested(hostViewId, surfaceId, event.data);
9
50
  });
10
51
  });
52
+
53
+ // Surface registry's untrackSurface doesn't fire a teardown event — wire it
54
+ // at the call site if needed. For now state TTL aligns with the view lifetime
55
+ // since surfaceId is reused only after view destruction; the buffer is GC'd
56
+ // once the surface is removed via `remove()` which eventually triggers
57
+ // `disposeSurfaceState` here.
58
+ export function disposeSurface(surfaceId: number) {
59
+ disposeSurfaceState(surfaceId);
60
+ }