bunite-core 0.14.0 → 0.17.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 (33) hide show
  1. package/package.json +4 -4
  2. package/src/host/core/App.ts +6 -3
  3. package/src/host/core/BrowserView.ts +345 -24
  4. package/src/host/core/BrowserWindow.ts +52 -6
  5. package/src/host/core/SurfaceBrowserIPC.ts +10 -1
  6. package/src/host/core/SurfaceManager.ts +357 -16
  7. package/src/host/core/windowCap.ts +69 -0
  8. package/src/host/events/webviewEvents.ts +18 -1
  9. package/src/host/log.ts +6 -1
  10. package/src/host/native.ts +145 -1
  11. package/src/host/preloadBundle.ts +7 -2
  12. package/src/native/linux/bunite_linux_ffi.cpp +225 -1
  13. package/src/native/linux/bunite_linux_internal.h +12 -0
  14. package/src/native/linux/bunite_linux_runtime.cpp +6 -1
  15. package/src/native/linux/bunite_linux_view.cpp +211 -5
  16. package/src/native/mac/bunite_mac_ffi.mm +293 -4
  17. package/src/native/mac/bunite_mac_internal.h +13 -0
  18. package/src/native/mac/bunite_mac_view.mm +227 -7
  19. package/src/native/shared/ffi_exports.h +97 -30
  20. package/src/native/win/native_host_cef.cpp +107 -13
  21. package/src/native/win/native_host_ffi.cpp +831 -2
  22. package/src/native/win/native_host_internal.h +22 -0
  23. package/src/native/win/native_host_runtime.cpp +34 -0
  24. package/src/native/win-webview2/bunite_webview2_ffi.cpp +827 -5
  25. package/src/native/win-webview2/webview2_internal.h +19 -0
  26. package/src/native/win-webview2/webview2_runtime.cpp +383 -31
  27. package/src/preload/runtime.built.js +1 -1
  28. package/src/preload/runtime.ts +39 -0
  29. package/src/rpc/framework.ts +194 -12
  30. package/src/rpc/index.ts +12 -0
  31. package/src/rpc/peer.ts +1 -1
  32. package/src/webview/native.ts +142 -32
  33. package/src/webview/polyfill.ts +91 -14
@@ -108,12 +108,31 @@ struct ViewHost {
108
108
  std::unordered_map<uint32_t, CefRefPtr<CefJSDialogCallback>> pending_dialogs;
109
109
  uint32_t next_dialog_request_id = 1;
110
110
 
111
+ // Download policy: 0=auto, 1=ask, 2=block. Default block.
112
+ std::atomic<int32_t> download_policy{2};
113
+ std::string download_dir;
114
+
115
+ // True for ViewHosts minted by OnBeforePopup; popup_accept binds them to a
116
+ // user window, popup_dismiss destroys them.
117
+ bool is_popup_pending = false;
118
+ // If popup_accept arrives before OnAfterCreated, stash parameters; the
119
+ // browser-create completion applies them.
120
+ struct PendingPopupAccept { uint32_t host_window_id; double x, y, w, h; };
121
+ std::optional<PendingPopupAccept> pending_popup_accept;
122
+ bool popup_dismiss_requested = false;
123
+
111
124
  // Pending state: applied in OnAfterCreated when browser HWND becomes available.
112
125
  bool pending_visible = true;
113
126
  bool pending_bring_to_front = false;
114
127
  bool pending_passthrough = false;
115
128
  bool has_pending_bounds = false;
116
129
  RECT pending_bounds{0, 0, 0, 0};
130
+
131
+ // OOPIF input dispatch — populated by Target.attachedToTarget events after
132
+ // lazy Target.setAutoAttach. frameId → sessionId for flatten:true routing.
133
+ std::atomic<bool> oopif_autoattach_armed = false;
134
+ std::mutex oopif_sessions_mutex;
135
+ std::unordered_map<std::string, std::string> oopif_sessions; // frameId → sessionId
117
136
  };
118
137
 
119
138
  struct WindowHost {
@@ -208,6 +227,9 @@ bool shouldAllowNavigation(const ViewHost* view, const std::string& url);
208
227
  void emitWindowEvent(uint32_t window_id, const char* event_name, const std::string& payload = {});
209
228
  void emitWebviewEvent(uint32_t view_id, const char* event_name, const std::string& payload = {});
210
229
 
230
+ // Bind a popup ViewHost (created by OnBeforePopup) to a user window + bounds.
231
+ void applyPopupAccept(ViewHost* view, uint32_t host_window_id, double x, double y, double w, double h);
232
+
211
233
  std::string normalizeAppResPath(const std::string& url);
212
234
  std::string getMimeType(const std::filesystem::path& file_path);
213
235
  std::string getAppResRootForView(uint32_t view_id);
@@ -81,7 +81,23 @@ static LRESULT CALLBACK buniteWindowProc(HWND hwnd, UINT message, WPARAM w_param
81
81
  return DefWindowProcW(hwnd, message, w_param, l_param);
82
82
  }
83
83
 
84
+ const bool frameless = window &&
85
+ (window->title_bar_style == L"hidden" || window->title_bar_style == L"hiddenInset");
86
+
84
87
  switch (message) {
88
+ case WM_NCCALCSIZE: {
89
+ // Reclaim the WS_THICKFRAME edge so the frameless webview fills the window
90
+ // (else a DWM frame band shows). Maximized (work-area clamped) reclaims all
91
+ // edges; restored reclaims only the top, keeping L/R/B resize borders.
92
+ if (w_param != TRUE || !frameless) break;
93
+ auto* p = reinterpret_cast<NCCALCSIZE_PARAMS*>(l_param);
94
+ if (IsZoomed(hwnd)) return 0;
95
+ LONG top = p->rgrc[0].top;
96
+ LRESULT r = DefWindowProcW(hwnd, message, w_param, l_param);
97
+ p->rgrc[0].top = top;
98
+ return r;
99
+ }
100
+
85
101
  case WM_SETFOCUS:
86
102
  if (window) {
87
103
  emitWindowEvent(window->id, "focus");
@@ -111,6 +127,24 @@ static LRESULT CALLBACK buniteWindowProc(HWND hwnd, UINT message, WPARAM w_param
111
127
  case WM_ERASEBKGND:
112
128
  return 1;
113
129
 
130
+ case WM_GETMINMAXINFO:
131
+ // Frameless (WS_POPUP) maximize clamps to the monitor work area (else
132
+ // covers the taskbar).
133
+ if (window && (window->title_bar_style == L"hidden" || window->title_bar_style == L"hiddenInset")) {
134
+ HMONITOR mon = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
135
+ MONITORINFO mi{ sizeof(mi) };
136
+ if (GetMonitorInfoW(mon, &mi)) {
137
+ auto* mmi = reinterpret_cast<MINMAXINFO*>(l_param);
138
+ mmi->ptMaxPosition.x = mi.rcWork.left - mi.rcMonitor.left;
139
+ mmi->ptMaxPosition.y = mi.rcWork.top - mi.rcMonitor.top;
140
+ mmi->ptMaxSize.x = mi.rcWork.right - mi.rcWork.left;
141
+ mmi->ptMaxSize.y = mi.rcWork.bottom - mi.rcWork.top;
142
+ mmi->ptMaxTrackSize = mmi->ptMaxSize;
143
+ return 0;
144
+ }
145
+ }
146
+ break;
147
+
114
148
  case WM_SIZE:
115
149
  if (window) {
116
150
  syncWindowFrame(window);