bunite-core 0.11.1 → 0.11.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bunite-core",
|
|
3
3
|
"description": "Uniting UI and Bun",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"setup:cef": "bun ../tools/bunite-dev/scripts/setup-cef.ts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"msgpackr": "^1.11.9"
|
|
25
25
|
},
|
|
26
26
|
"optionalDependencies": {
|
|
27
|
-
"bunite-native-win-x64": "0.0.
|
|
27
|
+
"bunite-native-win-x64": "0.0.6",
|
|
28
28
|
"bunite-native-mac-arm64": "0.0.1",
|
|
29
29
|
"bunite-native-linux-x64": "0.0.1"
|
|
30
30
|
}
|
|
@@ -175,6 +175,12 @@ export class BrowserWindow {
|
|
|
175
175
|
Boolean(this.frame.minimized),
|
|
176
176
|
Boolean(this.frame.maximized)
|
|
177
177
|
) ?? false;
|
|
178
|
+
if (!this.nativeAttached) {
|
|
179
|
+
console.error(
|
|
180
|
+
`[bunite] bunite_window_create returned false for window ${this.id} — ` +
|
|
181
|
+
`window will be unusable. Check native log (BUNITE_LOG_LEVEL=info).`
|
|
182
|
+
);
|
|
183
|
+
}
|
|
178
184
|
|
|
179
185
|
BrowserWindowMap[this.id] = this;
|
|
180
186
|
buniteEventEmitter.on(`focus-${this.id}`, () => { lastFocusedWindowId = this.id; });
|
package/src/native/shared/log.h
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
3
|
#include <cstdio>
|
|
4
|
+
#include <cstdlib>
|
|
5
|
+
#include <cstring>
|
|
4
6
|
#include <atomic>
|
|
5
7
|
|
|
6
8
|
enum class BuniteLogLevel : int { Debug = 0, Info = 1, Warn = 2, Error = 3, Silent = 4 };
|
|
@@ -11,6 +13,18 @@ inline void buniteSetLogLevel(BuniteLogLevel level) {
|
|
|
11
13
|
g_bunite_log_level.store(level, std::memory_order_relaxed);
|
|
12
14
|
}
|
|
13
15
|
|
|
16
|
+
/** Read BUNITE_LOG_LEVEL env once and apply it. Call early in bunite_init so
|
|
17
|
+
* init-time logs land before the TS side's setNativeLogLevel arrives. */
|
|
18
|
+
inline void buniteApplyEnvLogLevel() {
|
|
19
|
+
const char* v = std::getenv("BUNITE_LOG_LEVEL");
|
|
20
|
+
if (!v || !*v) return;
|
|
21
|
+
if (std::strcmp(v, "debug") == 0) buniteSetLogLevel(BuniteLogLevel::Debug);
|
|
22
|
+
else if (std::strcmp(v, "info") == 0) buniteSetLogLevel(BuniteLogLevel::Info);
|
|
23
|
+
else if (std::strcmp(v, "warn") == 0) buniteSetLogLevel(BuniteLogLevel::Warn);
|
|
24
|
+
else if (std::strcmp(v, "error") == 0) buniteSetLogLevel(BuniteLogLevel::Error);
|
|
25
|
+
else if (std::strcmp(v, "silent") == 0) buniteSetLogLevel(BuniteLogLevel::Silent);
|
|
26
|
+
}
|
|
27
|
+
|
|
14
28
|
inline bool buniteShouldLog(BuniteLogLevel level) {
|
|
15
29
|
return static_cast<int>(level) >= static_cast<int>(g_bunite_log_level.load(std::memory_order_relaxed));
|
|
16
30
|
}
|
|
@@ -284,6 +284,9 @@ LRESULT CALLBACK messageProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) {
|
|
|
284
284
|
|
|
285
285
|
bool initRuntime(const char* engine_dir, bool /*hide_console*/,
|
|
286
286
|
bool popup_blocking, const char* engine_config_json) {
|
|
287
|
+
buniteApplyEnvLogLevel();
|
|
288
|
+
BUNITE_INFO("webview2: bunite_init enter engine_dir=%s",
|
|
289
|
+
(engine_dir && *engine_dir) ? engine_dir : "(null)");
|
|
287
290
|
if (g_runtime.initialized.load()) return true;
|
|
288
291
|
|
|
289
292
|
HRESULT co = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
|
|
@@ -412,6 +415,8 @@ static DWORD styleForTitleBar(const std::wstring& tbs) {
|
|
|
412
415
|
bool createWindow(uint32_t window_id, double x, double y, double w, double h,
|
|
413
416
|
const char* title, const char* title_bar_style,
|
|
414
417
|
bool transparent, bool hidden, bool minimized, bool maximized) {
|
|
418
|
+
BUNITE_INFO("webview2: createWindow id=%u xy=(%g,%g) size=(%g,%g) hidden=%d trans=%d",
|
|
419
|
+
window_id, x, y, w, h, hidden, transparent);
|
|
415
420
|
WindowHost* host = new WindowHost();
|
|
416
421
|
host->id = window_id;
|
|
417
422
|
host->title = title ? utf8ToWide(title) : L"";
|
|
@@ -433,7 +438,13 @@ bool createWindow(uint32_t window_id, double x, double y, double w, double h,
|
|
|
433
438
|
HWND hwnd = CreateWindowExW(ex_style, kWindowClass, host->title.c_str(),
|
|
434
439
|
style, ix, iy, iw, ih, nullptr, nullptr,
|
|
435
440
|
getCurrentModuleHandle(), nullptr);
|
|
436
|
-
if (!hwnd) {
|
|
441
|
+
if (!hwnd) {
|
|
442
|
+
BUNITE_ERROR("webview2: CreateWindowExW failed err=%lu (class=%ls)",
|
|
443
|
+
GetLastError(), kWindowClass);
|
|
444
|
+
delete host;
|
|
445
|
+
return false;
|
|
446
|
+
}
|
|
447
|
+
BUNITE_INFO("webview2: createWindow hwnd=%p id=%u", hwnd, window_id);
|
|
437
448
|
host->hwnd = hwnd;
|
|
438
449
|
if (transparent) {
|
|
439
450
|
// Fully transparent layered window — pixels are sourced from the WebView2
|
|
@@ -538,7 +549,7 @@ static void wireView(ViewHost* view, std::function<void()> on_attached) {
|
|
|
538
549
|
view->container_hwnd,
|
|
539
550
|
Callback<ICoreWebView2CreateCoreWebView2ControllerCompletedHandler>(
|
|
540
551
|
[lifetime, view_id, on_attached](HRESULT cr, ICoreWebView2Controller* ctl) -> HRESULT {
|
|
541
|
-
|
|
552
|
+
BUNITE_INFO("webview2: controller-create completion view=%u hr=0x%08x",
|
|
542
553
|
view_id, static_cast<unsigned>(cr));
|
|
543
554
|
if (!lifetime || !lifetime->alive.load()) return S_OK;
|
|
544
555
|
ViewHost* v = getView(view_id);
|
|
@@ -632,9 +643,11 @@ bool createView(uint32_t view_id, uint32_t window_id,
|
|
|
632
643
|
double x, double y, double w, double h,
|
|
633
644
|
bool auto_resize, bool sandbox,
|
|
634
645
|
const char* preload_origins_json) {
|
|
646
|
+
BUNITE_INFO("webview2: createView view=%u window=%u url=%s",
|
|
647
|
+
view_id, window_id, url && *url ? url : "(none)");
|
|
635
648
|
WindowHost* window = getWindow(window_id);
|
|
636
649
|
if (!window) {
|
|
637
|
-
|
|
650
|
+
BUNITE_ERROR("webview2: createView for unknown window_id=%u", window_id);
|
|
638
651
|
return false;
|
|
639
652
|
}
|
|
640
653
|
|