sparkbun 0.1.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.
- package/bin/sparkbun.cjs +18 -0
- package/dist-linux-arm64/bsdiff +0 -0
- package/dist-linux-arm64/bspatch +0 -0
- package/dist-linux-arm64/libElectrobunCore.so +0 -0
- package/dist-linux-arm64/libNativeWrapper.so +0 -0
- package/dist-linux-arm64/libasar.so +0 -0
- package/dist-linux-x64/bsdiff +0 -0
- package/dist-linux-x64/bspatch +0 -0
- package/dist-linux-x64/libElectrobunCore.so +0 -0
- package/dist-linux-x64/libNativeWrapper.so +0 -0
- package/dist-linux-x64/libasar.so +0 -0
- package/dist-macos-arm64/bsdiff +0 -0
- package/dist-macos-arm64/bspatch +0 -0
- package/dist-macos-arm64/libElectrobunCore.dylib +0 -0
- package/dist-macos-arm64/libNativeWrapper.dylib +0 -0
- package/dist-macos-arm64/libasar.dylib +0 -0
- package/dist-macos-arm64/libwebgpu_dawn.dylib +0 -0
- package/dist-macos-arm64/preload-full.js +885 -0
- package/dist-macos-arm64/preload-sandboxed.js +111 -0
- package/dist-macos-arm64/process_helper +0 -0
- package/dist-win-x64/ElectrobunCore.dll +0 -0
- package/dist-win-x64/WebView2Loader.dll +0 -0
- package/dist-win-x64/bsdiff.exe +0 -0
- package/dist-win-x64/bspatch.exe +0 -0
- package/dist-win-x64/libNativeWrapper.dll +0 -0
- package/dist-win-x64/zig-asar/arm64/libasar.dll +0 -0
- package/dist-win-x64/zig-asar/x64/libasar.dll +0 -0
- package/package.json +47 -0
- package/scripts/build-and-upload-artifacts.js +207 -0
- package/scripts/gen-webgpu-ffi.mjs +162 -0
- package/scripts/install-windows-deps.ps1 +80 -0
- package/scripts/package-release.js +237 -0
- package/scripts/push-version.js +84 -0
- package/scripts/update-bun-version.ts +122 -0
- package/scripts/update-cef-version.ts +145 -0
- package/src/browser/builtinrpcSchema.ts +19 -0
- package/src/browser/global.d.ts +36 -0
- package/src/browser/index.ts +234 -0
- package/src/browser/webviewtag.ts +88 -0
- package/src/browser/wgputag.ts +48 -0
- package/src/bun/SparkBunConfig.ts +497 -0
- package/src/bun/__tests__/ffi-contract.test.ts +105 -0
- package/src/bun/core/ApplicationMenu.ts +70 -0
- package/src/bun/core/BrowserView.ts +416 -0
- package/src/bun/core/BrowserWindow.ts +396 -0
- package/src/bun/core/BuildConfig.ts +71 -0
- package/src/bun/core/ContextMenu.ts +75 -0
- package/src/bun/core/GpuWindow.ts +289 -0
- package/src/bun/core/Paths.ts +5 -0
- package/src/bun/core/Socket.ts +22 -0
- package/src/bun/core/Tray.ts +197 -0
- package/src/bun/core/Updater.ts +1131 -0
- package/src/bun/core/Utils.ts +487 -0
- package/src/bun/core/WGPUView.ts +167 -0
- package/src/bun/core/menuRoles.ts +181 -0
- package/src/bun/events/ApplicationEvents.ts +22 -0
- package/src/bun/events/event.ts +27 -0
- package/src/bun/events/eventEmitter.ts +45 -0
- package/src/bun/events/trayEvents.ts +11 -0
- package/src/bun/events/webviewEvents.ts +39 -0
- package/src/bun/events/windowEvents.ts +23 -0
- package/src/bun/index.ts +120 -0
- package/src/bun/preload/.generated/compiled.ts +2 -0
- package/src/bun/preload/build.ts +65 -0
- package/src/bun/preload/dragRegions.ts +41 -0
- package/src/bun/preload/encryption.ts +86 -0
- package/src/bun/preload/events.ts +171 -0
- package/src/bun/preload/globals.d.ts +45 -0
- package/src/bun/preload/index-sandboxed.ts +28 -0
- package/src/bun/preload/index.ts +77 -0
- package/src/bun/preload/internalRpc.ts +80 -0
- package/src/bun/preload/overlaySync.ts +107 -0
- package/src/bun/preload/webviewTag.ts +451 -0
- package/src/bun/preload/wgpuTag.ts +246 -0
- package/src/bun/proc/linux.md +43 -0
- package/src/bun/proc/native.ts +3253 -0
- package/src/bun/webGPU.ts +346 -0
- package/src/bun/webgpuAdapter.ts +3011 -0
- package/src/cli/bun.lockb +0 -0
- package/src/cli/index.ts +4653 -0
- package/src/cli/package-lock.json +81 -0
- package/src/cli/package.json +11 -0
- package/src/cli/templates/embedded.ts +2 -0
- package/src/core/build.zig +16 -0
- package/src/core/main.zig +3378 -0
- package/src/extractor/build.zig +22 -0
- package/src/installer/installer-template.ts +216 -0
- package/src/launcher/main.ts +221 -0
- package/src/native/build/libNativeWrapper.so +0 -0
- package/src/native/linux/build/nativeWrapper.o +0 -0
- package/src/native/linux/cef_loader.cpp +110 -0
- package/src/native/linux/cef_loader.h +28 -0
- package/src/native/linux/cef_process_helper_linux.cpp +160 -0
- package/src/native/linux/nativeWrapper.cpp +11768 -0
- package/src/native/macos/cef_process_helper_mac.cc +160 -0
- package/src/native/macos/nativeWrapper.mm +9172 -0
- package/src/native/shared/accelerator_parser.h +72 -0
- package/src/native/shared/app_paths.h +110 -0
- package/src/native/shared/asar.h +35 -0
- package/src/native/shared/cache_migration.h +244 -0
- package/src/native/shared/callbacks.h +57 -0
- package/src/native/shared/cef_response_filter.h +189 -0
- package/src/native/shared/chromium_flags.h +181 -0
- package/src/native/shared/config.h +66 -0
- package/src/native/shared/download_event.h +197 -0
- package/src/native/shared/ffi_helpers.h +139 -0
- package/src/native/shared/glob_match.h +59 -0
- package/src/native/shared/json_menu_parser.h +223 -0
- package/src/native/shared/mime_types.h +101 -0
- package/src/native/shared/navigation_rules.h +98 -0
- package/src/native/shared/partition_context.h +137 -0
- package/src/native/shared/pending_resize_queue.h +45 -0
- package/src/native/shared/permissions.h +118 -0
- package/src/native/shared/permissions_cef.h +74 -0
- package/src/native/shared/preload_script.h +71 -0
- package/src/native/shared/shutdown_guard.h +134 -0
- package/src/native/shared/thread_safe_map.h +138 -0
- package/src/native/shared/webview_storage.h +91 -0
- package/src/native/win/cef_process_helper_win.cpp +143 -0
- package/src/native/win/dcomp_compositor.h +352 -0
- package/src/native/win/nativeWrapper.cpp +12434 -0
- package/src/npmbin/index.js +34 -0
- package/src/shared/bun-version.ts +3 -0
- package/src/shared/cef-version.ts +5 -0
- package/src/shared/naming.test.ts +327 -0
- package/src/shared/naming.ts +188 -0
- package/src/shared/platform.ts +48 -0
- package/src/shared/rpc.ts +541 -0
- package/src/shared/sparkbun-version.ts +2 -0
- package/src/types/three.d.ts +1 -0
- package/tsconfig.json +31 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
#include "include/cef_app.h"
|
|
2
|
+
#include "include/cef_v8.h"
|
|
3
|
+
#include "include/wrapper/cef_library_loader.h"
|
|
4
|
+
#include <map>
|
|
5
|
+
#include <mutex>
|
|
6
|
+
|
|
7
|
+
#if defined(CEF_USE_SANDBOX)
|
|
8
|
+
#include "include/cef_sandbox_mac.h"
|
|
9
|
+
#endif
|
|
10
|
+
|
|
11
|
+
class HelperApp : public CefApp, public CefRenderProcessHandler {
|
|
12
|
+
public:
|
|
13
|
+
// CefApp methods:
|
|
14
|
+
virtual void OnRegisterCustomSchemes(CefRawPtr<CefSchemeRegistrar> registrar) override {
|
|
15
|
+
registrar->AddCustomScheme("views",
|
|
16
|
+
CEF_SCHEME_OPTION_STANDARD |
|
|
17
|
+
CEF_SCHEME_OPTION_CORS_ENABLED |
|
|
18
|
+
CEF_SCHEME_OPTION_SECURE | // treat it like https
|
|
19
|
+
CEF_SCHEME_OPTION_CSP_BYPASSING | // allow things like crypto.subtle
|
|
20
|
+
CEF_SCHEME_OPTION_FETCH_ENABLED);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() override {
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// CefRenderProcessHandler methods:
|
|
28
|
+
|
|
29
|
+
// Called when a browser is created - receive sandbox flag via extra_info
|
|
30
|
+
virtual void OnBrowserCreated(CefRefPtr<CefBrowser> browser,
|
|
31
|
+
CefRefPtr<CefDictionaryValue> extra_info) override {
|
|
32
|
+
if (extra_info && extra_info->HasKey("sandbox")) {
|
|
33
|
+
bool sandbox = extra_info->GetBool("sandbox");
|
|
34
|
+
std::lock_guard<std::mutex> lock(sandbox_map_mutex_);
|
|
35
|
+
sandbox_map_[browser->GetIdentifier()] = sandbox;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Called when a browser is destroyed - cleanup sandbox flag
|
|
40
|
+
virtual void OnBrowserDestroyed(CefRefPtr<CefBrowser> browser) override {
|
|
41
|
+
std::lock_guard<std::mutex> lock(sandbox_map_mutex_);
|
|
42
|
+
sandbox_map_.erase(browser->GetIdentifier());
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
virtual void OnContextCreated(CefRefPtr<CefBrowser> browser,
|
|
46
|
+
CefRefPtr<CefFrame> frame,
|
|
47
|
+
CefRefPtr<CefV8Context> context) override {
|
|
48
|
+
// Check if this browser is sandboxed
|
|
49
|
+
bool is_sandboxed = false;
|
|
50
|
+
{
|
|
51
|
+
std::lock_guard<std::mutex> lock(sandbox_map_mutex_);
|
|
52
|
+
auto it = sandbox_map_.find(browser->GetIdentifier());
|
|
53
|
+
if (it != sandbox_map_.end()) {
|
|
54
|
+
is_sandboxed = it->second;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Get the global window object
|
|
59
|
+
CefRefPtr<CefV8Context> v8Context = frame->GetV8Context();
|
|
60
|
+
v8Context->Enter();
|
|
61
|
+
|
|
62
|
+
CefRefPtr<CefV8Value> window = context->GetGlobal();
|
|
63
|
+
|
|
64
|
+
// Create eventBridge - event-only bridge (always available for all webviews, including sandboxed)
|
|
65
|
+
CefRefPtr<CefV8Value> eventBridge = CefV8Value::CreateObject(nullptr, nullptr);
|
|
66
|
+
CefRefPtr<CefV8Value> eventPostMessage = CreatePostMessageFunction(browser, "EventBridgeMessage");
|
|
67
|
+
eventBridge->SetValue("postMessage", eventPostMessage, V8_PROPERTY_ATTRIBUTE_NONE);
|
|
68
|
+
window->SetValue("__electrobunEventBridge", eventBridge, V8_PROPERTY_ATTRIBUTE_NONE);
|
|
69
|
+
|
|
70
|
+
// Only create hostBridge/bunBridge aliases and internalBridge for non-sandboxed webviews
|
|
71
|
+
if (!is_sandboxed) {
|
|
72
|
+
// Create hostBridge - user RPC bridge
|
|
73
|
+
CefRefPtr<CefV8Value> bunBridge = CefV8Value::CreateObject(nullptr, nullptr);
|
|
74
|
+
CefRefPtr<CefV8Value> bunPostMessage = CreatePostMessageFunction(browser, "BunBridgeMessage");
|
|
75
|
+
bunBridge->SetValue("postMessage", bunPostMessage, V8_PROPERTY_ATTRIBUTE_NONE);
|
|
76
|
+
window->SetValue("__electrobunHostBridge", bunBridge, V8_PROPERTY_ATTRIBUTE_NONE);
|
|
77
|
+
window->SetValue("__electrobunBunBridge", bunBridge, V8_PROPERTY_ATTRIBUTE_NONE);
|
|
78
|
+
|
|
79
|
+
// Create internalBridge - internal RPC bridge
|
|
80
|
+
CefRefPtr<CefV8Value> internalBridge = CefV8Value::CreateObject(nullptr, nullptr);
|
|
81
|
+
CefRefPtr<CefV8Value> internalPostMessage = CreatePostMessageFunction(browser, "internalMessage");
|
|
82
|
+
internalBridge->SetValue("postMessage", internalPostMessage, V8_PROPERTY_ATTRIBUTE_NONE);
|
|
83
|
+
window->SetValue("__electrobunInternalBridge", internalBridge, V8_PROPERTY_ATTRIBUTE_NONE);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
v8Context->Exit();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
private:
|
|
90
|
+
// Map of browser ID to sandbox flag
|
|
91
|
+
std::map<int, bool> sandbox_map_;
|
|
92
|
+
std::mutex sandbox_map_mutex_;
|
|
93
|
+
|
|
94
|
+
private:
|
|
95
|
+
// Helper class to handle V8 function calls
|
|
96
|
+
class V8Handler : public CefV8Handler {
|
|
97
|
+
public:
|
|
98
|
+
V8Handler(CefRefPtr<CefBrowser> browser, const CefString& messageName)
|
|
99
|
+
: browser_(browser), message_name_(messageName) {}
|
|
100
|
+
|
|
101
|
+
virtual bool Execute(const CefString& name,
|
|
102
|
+
CefRefPtr<CefV8Value> object,
|
|
103
|
+
const CefV8ValueList& arguments,
|
|
104
|
+
CefRefPtr<CefV8Value>& retval,
|
|
105
|
+
CefString& exception) override {
|
|
106
|
+
if (arguments.size() > 0 && arguments[0]->IsString()) {
|
|
107
|
+
// Create and send process message to the main process
|
|
108
|
+
CefRefPtr<CefFrame> mainFrame = browser_->GetMainFrame();
|
|
109
|
+
if (mainFrame) {
|
|
110
|
+
CefRefPtr<CefProcessMessage> message = CefProcessMessage::Create(message_name_);
|
|
111
|
+
message->GetArgumentList()->SetString(0, arguments[0]->GetStringValue());
|
|
112
|
+
mainFrame->SendProcessMessage(PID_BROWSER, message);
|
|
113
|
+
}
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
private:
|
|
120
|
+
CefRefPtr<CefBrowser> browser_;
|
|
121
|
+
CefString message_name_;
|
|
122
|
+
IMPLEMENT_REFCOUNTING(V8Handler);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
CefRefPtr<CefV8Value> CreatePostMessageFunction(CefRefPtr<CefBrowser> browser,
|
|
126
|
+
const CefString& messageName) {
|
|
127
|
+
return CefV8Value::CreateFunction(
|
|
128
|
+
"postMessage",
|
|
129
|
+
new V8Handler(browser, messageName)
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
IMPLEMENT_REFCOUNTING(HelperApp);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
// Entry point function for sub-processes.
|
|
137
|
+
int main(int argc, char* argv[]) {
|
|
138
|
+
#if defined(CEF_USE_SANDBOX)
|
|
139
|
+
// Initialize the macOS sandbox for this helper process.
|
|
140
|
+
CefScopedSandboxContext sandbox_context;
|
|
141
|
+
if (!sandbox_context.Initialize(argc, argv)) {
|
|
142
|
+
return 1;
|
|
143
|
+
}
|
|
144
|
+
#endif
|
|
145
|
+
|
|
146
|
+
// Load the CEF framework library at runtime instead of linking directly
|
|
147
|
+
// as required by the macOS sandbox implementation.
|
|
148
|
+
CefScopedLibraryLoader library_loader;
|
|
149
|
+
if (!library_loader.LoadInHelper()) {
|
|
150
|
+
return 1;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Provide CEF with command-line arguments.
|
|
154
|
+
CefMainArgs main_args(argc, argv);
|
|
155
|
+
|
|
156
|
+
CefRefPtr<CefApp> app(new HelperApp);
|
|
157
|
+
|
|
158
|
+
// Execute the sub-process.
|
|
159
|
+
return CefExecuteProcess(main_args, app, nullptr);
|
|
160
|
+
}
|