electrobun 1.18.4-beta.6 → 2.0.1-beta.13
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/LICENSE +21 -0
- package/README.md +31 -170
- package/bin/electrobun.cjs +230 -153
- package/package.json +18 -49
- package/bun.lock +0 -119
- package/dist/api/browser/builtinrpcSchema.ts +0 -19
- package/dist/api/browser/global.d.ts +0 -36
- package/dist/api/browser/index.ts +0 -234
- package/dist/api/browser/webviewtag.ts +0 -88
- package/dist/api/browser/wgputag.ts +0 -48
- package/dist/api/bun/ElectrobunConfig.ts +0 -530
- package/dist/api/bun/__tests__/ffi-contract.test.ts +0 -105
- package/dist/api/bun/core/ApplicationMenu.ts +0 -70
- package/dist/api/bun/core/BrowserView.ts +0 -419
- package/dist/api/bun/core/BrowserWindow.ts +0 -400
- package/dist/api/bun/core/BuildConfig.ts +0 -71
- package/dist/api/bun/core/ContextMenu.ts +0 -75
- package/dist/api/bun/core/GpuWindow.ts +0 -289
- package/dist/api/bun/core/Paths.ts +0 -5
- package/dist/api/bun/core/Socket.ts +0 -22
- package/dist/api/bun/core/Tray.ts +0 -197
- package/dist/api/bun/core/Updater.ts +0 -1162
- package/dist/api/bun/core/Utils.ts +0 -487
- package/dist/api/bun/core/WGPUView.ts +0 -167
- package/dist/api/bun/core/menuRoles.ts +0 -181
- package/dist/api/bun/events/ApplicationEvents.ts +0 -22
- package/dist/api/bun/events/event.ts +0 -29
- package/dist/api/bun/events/eventEmitter.ts +0 -45
- package/dist/api/bun/events/trayEvents.ts +0 -11
- package/dist/api/bun/events/webviewEvents.ts +0 -39
- package/dist/api/bun/events/windowEvents.ts +0 -23
- package/dist/api/bun/index.ts +0 -298
- package/dist/api/bun/preload/.generated/compiled.ts +0 -8
- package/dist/api/bun/preload/build.ts +0 -65
- package/dist/api/bun/preload/dragRegions.ts +0 -41
- package/dist/api/bun/preload/encryption.ts +0 -86
- package/dist/api/bun/preload/events.ts +0 -171
- package/dist/api/bun/preload/globals.d.ts +0 -45
- package/dist/api/bun/preload/index-sandboxed.ts +0 -28
- package/dist/api/bun/preload/index.ts +0 -77
- package/dist/api/bun/preload/internalRpc.ts +0 -80
- package/dist/api/bun/preload/overlaySync.ts +0 -107
- package/dist/api/bun/preload/webviewTag.ts +0 -451
- package/dist/api/bun/preload/wgpuTag.ts +0 -246
- package/dist/api/bun/proc/linux.md +0 -43
- package/dist/api/bun/proc/native.ts +0 -3385
- package/dist/api/bun/webGPU.ts +0 -346
- package/dist/api/bun/webgpuAdapter.ts +0 -3011
- package/dist/api/shared/bun-version.ts +0 -3
- package/dist/api/shared/cef-version.ts +0 -5
- package/dist/api/shared/electrobun-version.ts +0 -2
- package/dist/api/shared/naming.test.ts +0 -327
- package/dist/api/shared/naming.ts +0 -188
- package/dist/api/shared/platform.ts +0 -48
- package/dist/api/shared/rpc.ts +0 -541
- package/dist/main.js +0 -168
- package/dist/preload-full.js +0 -913
- package/dist/preload-sandboxed.js +0 -111
- package/dist/zig-sdk/electrobun.zig +0 -1993
- package/src/cli/bun.lockb +0 -0
- package/src/cli/index.ts +0 -5689
- package/src/cli/package-lock.json +0 -81
- package/src/cli/package.json +0 -11
|
@@ -1,530 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Electrobun configuration type definitions
|
|
3
|
-
* Used in electrobun.config.ts files
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Bun.build() options that can be passed through to the bundler.
|
|
8
|
-
* Excludes options that are controlled by Electrobun (entrypoints, outdir, target).
|
|
9
|
-
* See https://bun.sh/docs/bundler for full documentation.
|
|
10
|
-
*/
|
|
11
|
-
type BunBuildOptions = Omit<
|
|
12
|
-
Parameters<typeof Bun.build>[0],
|
|
13
|
-
"entrypoints" | "outdir" | "target"
|
|
14
|
-
>;
|
|
15
|
-
|
|
16
|
-
type CarrotFileActivatorConfig = {
|
|
17
|
-
baseName?: string;
|
|
18
|
-
nodeType?: "file" | "dir" | "any";
|
|
19
|
-
slate: {
|
|
20
|
-
type: string;
|
|
21
|
-
name?: string;
|
|
22
|
-
icon?: string;
|
|
23
|
-
config?: Record<string, unknown>;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
type CarrotContributionsConfig = {
|
|
28
|
-
fileActivators?: CarrotFileActivatorConfig[];
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
type CarrotUIDefinition = {
|
|
32
|
-
name?: string;
|
|
33
|
-
entrypoint?: string;
|
|
34
|
-
path?: string;
|
|
35
|
-
[key: string]: unknown;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export interface ElectrobunConfig {
|
|
39
|
-
/**
|
|
40
|
-
* Application metadata configuration
|
|
41
|
-
*/
|
|
42
|
-
app: {
|
|
43
|
-
/**
|
|
44
|
-
* The display name of your application
|
|
45
|
-
*/
|
|
46
|
-
name: string;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Unique identifier for your application (e.g., "com.example.myapp")
|
|
50
|
-
* Used for platform-specific identifiers
|
|
51
|
-
*/
|
|
52
|
-
identifier: string;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Application version string (e.g., "1.0.0")
|
|
56
|
-
*/
|
|
57
|
-
version: string;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Optional description of the application
|
|
61
|
-
*/
|
|
62
|
-
description?: string;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Custom URL schemes to register for deep linking (e.g., ["myapp", "myapp-dev"])
|
|
66
|
-
* This allows your app to be opened via URLs like myapp://some/path
|
|
67
|
-
*
|
|
68
|
-
* Platform support:
|
|
69
|
-
* - macOS: Fully supported. App must be in /Applications folder for registration to work.
|
|
70
|
-
* - Windows: Not yet supported
|
|
71
|
-
* - Linux: Not yet supported
|
|
72
|
-
*
|
|
73
|
-
* To handle incoming URLs, listen for the "open-url" event:
|
|
74
|
-
* ```typescript
|
|
75
|
-
* Electrobun.events.on("open-url", (e) => {
|
|
76
|
-
* console.log("Opened with URL:", e.data.url);
|
|
77
|
-
* });
|
|
78
|
-
* ```
|
|
79
|
-
*/
|
|
80
|
-
urlSchemes?: string[];
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* File type associations for the application.
|
|
84
|
-
* Registers document types so the OS can open files with your app
|
|
85
|
-
* (e.g., double-click in Finder, "Open With" menu, drag-to-dock).
|
|
86
|
-
*
|
|
87
|
-
* Platform support:
|
|
88
|
-
* - macOS: Fully supported. Generates CFBundleDocumentTypes in Info.plist.
|
|
89
|
-
* - Windows/Linux: Not yet supported.
|
|
90
|
-
*
|
|
91
|
-
* Files arrive as file:// URLs via the existing "open-url" event:
|
|
92
|
-
* ```typescript
|
|
93
|
-
* Electrobun.events.on("open-url", (e) => {
|
|
94
|
-
* if (e.data.url.startsWith("file://")) {
|
|
95
|
-
* console.log("Opened file:", e.data.url);
|
|
96
|
-
* }
|
|
97
|
-
* });
|
|
98
|
-
* ```
|
|
99
|
-
*/
|
|
100
|
-
fileAssociations?: Array<{
|
|
101
|
-
/** File extensions without the leading dot (e.g., ["dotlock", "json"]) */
|
|
102
|
-
ext: string[];
|
|
103
|
-
/** Human-readable name for this file type (e.g., "DotLock Document") */
|
|
104
|
-
name: string;
|
|
105
|
-
/** The app's role for this file type. @default "Viewer" */
|
|
106
|
-
role?: "Editor" | "Viewer" | "Shell" | "None";
|
|
107
|
-
/**
|
|
108
|
-
* Path to an .icns file for this document type (macOS only).
|
|
109
|
-
* The file is automatically copied into the app bundle's Resources folder
|
|
110
|
-
* during the build. Only the filename (without path) is written to Info.plist.
|
|
111
|
-
*/
|
|
112
|
-
icon?: string;
|
|
113
|
-
}>;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Bunny Ears / Carrot packaging metadata.
|
|
118
|
-
* This lets an Electrobun app also declare how it should behave when distributed as a Carrot.
|
|
119
|
-
*/
|
|
120
|
-
bunny?: {
|
|
121
|
-
carrot?: {
|
|
122
|
-
/**
|
|
123
|
-
* Carrot dependencies keyed by carrot id.
|
|
124
|
-
* Supports npm-style specifiers such as:
|
|
125
|
-
* - `file:../foundation-carrots/pty`
|
|
126
|
-
* - `workspace:*`
|
|
127
|
-
* - `^0.1.0`
|
|
128
|
-
*/
|
|
129
|
-
dependencies?: Record<string, string>;
|
|
130
|
-
};
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Build configuration options
|
|
135
|
-
*/
|
|
136
|
-
build?: {
|
|
137
|
-
/**
|
|
138
|
-
* Main process implementation to build and package.
|
|
139
|
-
* - "bun": bundle and run the Bun main process entrypoint
|
|
140
|
-
* - "zig": compile and run the Zig main process entrypoint
|
|
141
|
-
* @default "bun"
|
|
142
|
-
*/
|
|
143
|
-
mainProcess?: "bun" | "zig";
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Bun process build configuration.
|
|
147
|
-
* Accepts all Bun.build() options (plugins, sourcemap, minify, define, etc.)
|
|
148
|
-
* in addition to the entrypoint. See https://bun.sh/docs/bundler
|
|
149
|
-
*/
|
|
150
|
-
bun?: {
|
|
151
|
-
/**
|
|
152
|
-
* Entry point for the main Bun process
|
|
153
|
-
* @default "src/bun/index.ts"
|
|
154
|
-
*/
|
|
155
|
-
entrypoint?: string;
|
|
156
|
-
} & BunBuildOptions;
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Zig main process build configuration.
|
|
160
|
-
* Used when `build.mainProcess` is set to `"zig"`.
|
|
161
|
-
*/
|
|
162
|
-
zig?: {
|
|
163
|
-
/**
|
|
164
|
-
* Entry point for the main Zig process
|
|
165
|
-
* @default "src/zig/main.zig"
|
|
166
|
-
*/
|
|
167
|
-
entrypoint?: string;
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Browser view build configurations.
|
|
172
|
-
* Each view accepts all Bun.build() options (plugins, sourcemap, minify, define, etc.)
|
|
173
|
-
* in addition to the entrypoint. See https://bun.sh/docs/bundler
|
|
174
|
-
*/
|
|
175
|
-
views?: {
|
|
176
|
-
[viewName: string]: {
|
|
177
|
-
/**
|
|
178
|
-
* Entry point for this view's TypeScript code
|
|
179
|
-
*/
|
|
180
|
-
entrypoint: string;
|
|
181
|
-
} & BunBuildOptions;
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Files to copy directly to the build output
|
|
186
|
-
* Key is source path, value is destination path
|
|
187
|
-
*/
|
|
188
|
-
copy?: {
|
|
189
|
-
[sourcePath: string]: string;
|
|
190
|
-
};
|
|
191
|
-
/**
|
|
192
|
-
* Output folder for built application
|
|
193
|
-
* @default "build"
|
|
194
|
-
*/
|
|
195
|
-
buildFolder?: string;
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Output folder for distribution artifacts
|
|
199
|
-
* @default "artifacts"
|
|
200
|
-
*/
|
|
201
|
-
artifactFolder?: string;
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Build targets to compile for
|
|
205
|
-
* Can be "current", "all", or comma-separated list like "macos-arm64,win-x64"
|
|
206
|
-
*/
|
|
207
|
-
targets?: string;
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Enable ASAR archive packaging for bundled assets
|
|
211
|
-
* When enabled, all files in the Resources folder will be packed into an app.asar archive
|
|
212
|
-
* @default false
|
|
213
|
-
*/
|
|
214
|
-
useAsar?: boolean;
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* Glob patterns for files to exclude from ASAR packing (extract to app.asar.unpacked)
|
|
218
|
-
* Useful for native modules or executables that need to be accessible as regular files
|
|
219
|
-
* @default ["*.node", "*.dll", "*.dylib", "*.so"]
|
|
220
|
-
*/
|
|
221
|
-
asarUnpack?: string[];
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* Override the CEF (Chromium Embedded Framework) version.
|
|
225
|
-
* Format: "CEF_VERSION+chromium-CHROMIUM_VERSION"
|
|
226
|
-
* Example: "144.0.11+ge135be2+chromium-144.0.7559.97"
|
|
227
|
-
*
|
|
228
|
-
* Check the electrobun-cef-compat compatibility matrix for tested combinations
|
|
229
|
-
* before overriding. Using an untested version may cause runtime issues.
|
|
230
|
-
* @default Uses the version bundled with this Electrobun release
|
|
231
|
-
*/
|
|
232
|
-
cefVersion?: string;
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Override the Dawn (WebGPU) version.
|
|
236
|
-
* Format: semver string (e.g., "0.2.3") or tag (e.g., "v0.2.3-beta.0")
|
|
237
|
-
*
|
|
238
|
-
* This downloads the specified electrobun-dawn release and uses it
|
|
239
|
-
* instead of the latest release.
|
|
240
|
-
* @default Uses the latest electrobun-dawn release
|
|
241
|
-
*/
|
|
242
|
-
wgpuVersion?: string;
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Override the Bun runtime version.
|
|
246
|
-
* Format: semver string (e.g., "1.4.2")
|
|
247
|
-
*
|
|
248
|
-
* This downloads the specified Bun version from GitHub releases and uses it
|
|
249
|
-
* instead of the version bundled with this Electrobun release.
|
|
250
|
-
* @default Uses the version bundled with this Electrobun release
|
|
251
|
-
*/
|
|
252
|
-
bunVersion?: string;
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Locales to include in the ICU data file (Linux/Windows only).
|
|
256
|
-
* Set to '*' to include all locales, or specify a subset like ['en', 'de']
|
|
257
|
-
* to reduce app size. Has no effect on macOS (uses system ICU).
|
|
258
|
-
* @default '*'
|
|
259
|
-
*/
|
|
260
|
-
locales?: string[] | "*";
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* Additional file or directory paths to watch for changes during `electrobun dev --watch`.
|
|
264
|
-
* Paths are relative to the project root.
|
|
265
|
-
* Useful for files that affect your build but aren't listed as entrypoints or copy sources.
|
|
266
|
-
*/
|
|
267
|
-
watch?: string[];
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
* Glob patterns for files that should not trigger a rebuild when changed.
|
|
271
|
-
* Patterns are matched against project-relative paths.
|
|
272
|
-
* The `build/`, `artifacts/`, and `node_modules/` directories are always ignored automatically.
|
|
273
|
-
*/
|
|
274
|
-
watchIgnore?: string[];
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* Carrot build configuration.
|
|
278
|
-
* When present, the build also produces a carrot artifact alongside the standalone app.
|
|
279
|
-
* Set `carrotOnly: true` to skip the standalone app build entirely.
|
|
280
|
-
*/
|
|
281
|
-
carrot?: {
|
|
282
|
-
id: string;
|
|
283
|
-
name: string;
|
|
284
|
-
description?: string;
|
|
285
|
-
mode?: "window" | "background";
|
|
286
|
-
carrotOnly?: boolean;
|
|
287
|
-
permissions?: Record<string, unknown>;
|
|
288
|
-
dependencies?: Record<string, string>;
|
|
289
|
-
remoteUIs?: Record<string, CarrotUIDefinition>;
|
|
290
|
-
slateUIs?: Record<string, CarrotUIDefinition>;
|
|
291
|
-
contributions?: CarrotContributionsConfig;
|
|
292
|
-
};
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* macOS-specific build configuration
|
|
296
|
-
*/
|
|
297
|
-
mac?: {
|
|
298
|
-
/**
|
|
299
|
-
* Enable code signing for macOS builds
|
|
300
|
-
* @default false
|
|
301
|
-
*/
|
|
302
|
-
codesign?: boolean;
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* Create a DMG artifact for macOS builds.
|
|
306
|
-
* Disable this for local prototype builds that only need the app bundle and update archive.
|
|
307
|
-
* @default true
|
|
308
|
-
*/
|
|
309
|
-
createDmg?: boolean;
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
* Enable notarization for macOS builds (requires codesign)
|
|
313
|
-
* @default false
|
|
314
|
-
*/
|
|
315
|
-
notarize?: boolean;
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* Bundle CEF (Chromium Embedded Framework) instead of using system WebView
|
|
319
|
-
* @default false
|
|
320
|
-
*/
|
|
321
|
-
bundleCEF?: boolean;
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* Bundle Dawn (WebGPU) for GPU-native rendering
|
|
325
|
-
* @default false
|
|
326
|
-
*/
|
|
327
|
-
bundleWGPU?: boolean;
|
|
328
|
-
|
|
329
|
-
/**
|
|
330
|
-
* Default renderer for webviews when not explicitly specified
|
|
331
|
-
* @default 'native'
|
|
332
|
-
*/
|
|
333
|
-
defaultRenderer?: "native" | "cef";
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
* Custom Chromium command-line flags to pass to CEF during initialization.
|
|
337
|
-
* Keys are flag names without the "--" prefix.
|
|
338
|
-
* - `true` — add a switch-only flag
|
|
339
|
-
* - `"value"` — add a flag with a value
|
|
340
|
-
* - `false` — remove a default flag set by Electrobun
|
|
341
|
-
*
|
|
342
|
-
* @example
|
|
343
|
-
* ```typescript
|
|
344
|
-
* chromiumFlags: {
|
|
345
|
-
* "disable-gpu": false, // remove Electrobun's default --disable-gpu
|
|
346
|
-
* "remote-debugging-port": "9333", // --remote-debugging-port=9333
|
|
347
|
-
* }
|
|
348
|
-
* ```
|
|
349
|
-
*/
|
|
350
|
-
chromiumFlags?: Record<string, string | boolean>;
|
|
351
|
-
|
|
352
|
-
/**
|
|
353
|
-
* macOS entitlements for code signing
|
|
354
|
-
*/
|
|
355
|
-
entitlements?: Record<string, boolean | string | string[]>;
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* Path to .iconset folder or .icon file (from Icon Composer)
|
|
359
|
-
* containing app icons.
|
|
360
|
-
*
|
|
361
|
-
* - `.iconset` folders are converted to .icns via iconutil
|
|
362
|
-
* (requires Command Line Tools)
|
|
363
|
-
* - `.icon` files are compiled via actool, producing Assets.car
|
|
364
|
-
* for Liquid Glass on macOS 26+ and a .icns fallback for older
|
|
365
|
-
* macOS versions (requires Xcode)
|
|
366
|
-
*
|
|
367
|
-
* @default "icon.iconset"
|
|
368
|
-
*/
|
|
369
|
-
icons?: string;
|
|
370
|
-
};
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
* Windows-specific build configuration
|
|
374
|
-
*/
|
|
375
|
-
win?: {
|
|
376
|
-
/**
|
|
377
|
-
* Bundle CEF (Chromium Embedded Framework) instead of using WebView2
|
|
378
|
-
* @default false
|
|
379
|
-
*/
|
|
380
|
-
bundleCEF?: boolean;
|
|
381
|
-
|
|
382
|
-
/**
|
|
383
|
-
* Bundle Dawn (WebGPU) for GPU-native rendering
|
|
384
|
-
* @default false
|
|
385
|
-
*/
|
|
386
|
-
bundleWGPU?: boolean;
|
|
387
|
-
|
|
388
|
-
/**
|
|
389
|
-
* Default renderer for webviews when not explicitly specified
|
|
390
|
-
* @default 'native'
|
|
391
|
-
*/
|
|
392
|
-
defaultRenderer?: "native" | "cef";
|
|
393
|
-
|
|
394
|
-
/**
|
|
395
|
-
* Custom Chromium command-line flags to pass to CEF during initialization.
|
|
396
|
-
* Keys are flag names without the "--" prefix.
|
|
397
|
-
* - `true` — add a switch-only flag
|
|
398
|
-
* - `"value"` — add a flag with a value
|
|
399
|
-
* - `false` — remove a default flag set by Electrobun
|
|
400
|
-
*
|
|
401
|
-
* @example
|
|
402
|
-
* ```typescript
|
|
403
|
-
* chromiumFlags: {
|
|
404
|
-
* "disable-gpu": false, // remove Electrobun's default --disable-gpu
|
|
405
|
-
* "remote-debugging-port": "9333", // --remote-debugging-port=9333
|
|
406
|
-
* }
|
|
407
|
-
* ```
|
|
408
|
-
*/
|
|
409
|
-
chromiumFlags?: Record<string, string | boolean>;
|
|
410
|
-
|
|
411
|
-
/**
|
|
412
|
-
* Path to application icon (.ico format)
|
|
413
|
-
* Used for the installer/extractor wrapper, desktop shortcuts, and taskbar
|
|
414
|
-
* Should include multiple sizes (16x16, 32x32, 48x48, 256x256) for best results
|
|
415
|
-
* @example "assets/icon.ico"
|
|
416
|
-
*/
|
|
417
|
-
icon?: string;
|
|
418
|
-
};
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* Linux-specific build configuration
|
|
422
|
-
*/
|
|
423
|
-
linux?: {
|
|
424
|
-
/**
|
|
425
|
-
* Bundle CEF (Chromium Embedded Framework) instead of using GTKWebKit
|
|
426
|
-
* Recommended on Linux for advanced layer compositing features
|
|
427
|
-
* @default false
|
|
428
|
-
*/
|
|
429
|
-
bundleCEF?: boolean;
|
|
430
|
-
|
|
431
|
-
/**
|
|
432
|
-
* Bundle Dawn (WebGPU) for GPU-native rendering
|
|
433
|
-
* @default false
|
|
434
|
-
*/
|
|
435
|
-
bundleWGPU?: boolean;
|
|
436
|
-
|
|
437
|
-
/**
|
|
438
|
-
* Default renderer for webviews when not explicitly specified
|
|
439
|
-
* @default 'native'
|
|
440
|
-
*/
|
|
441
|
-
defaultRenderer?: "native" | "cef";
|
|
442
|
-
|
|
443
|
-
/**
|
|
444
|
-
* Custom Chromium command-line flags to pass to CEF during initialization.
|
|
445
|
-
* Keys are flag names without the "--" prefix.
|
|
446
|
-
* - `true` — add a switch-only flag
|
|
447
|
-
* - `"value"` — add a flag with a value
|
|
448
|
-
* - `false` — remove a default flag set by Electrobun
|
|
449
|
-
*
|
|
450
|
-
* @example
|
|
451
|
-
* ```typescript
|
|
452
|
-
* chromiumFlags: {
|
|
453
|
-
* "disable-gpu": false, // remove Electrobun's default --disable-gpu
|
|
454
|
-
* "remote-debugging-port": "9333", // --remote-debugging-port=9333
|
|
455
|
-
* }
|
|
456
|
-
* ```
|
|
457
|
-
*/
|
|
458
|
-
chromiumFlags?: Record<string, string | boolean>;
|
|
459
|
-
|
|
460
|
-
/**
|
|
461
|
-
* Path to application icon (PNG format recommended)
|
|
462
|
-
* Used for desktop entries, window icons, and taskbar
|
|
463
|
-
* Should be at least 256x256 pixels for best results
|
|
464
|
-
* @example "assets/icon.png"
|
|
465
|
-
*/
|
|
466
|
-
icon?: string;
|
|
467
|
-
};
|
|
468
|
-
};
|
|
469
|
-
|
|
470
|
-
/**
|
|
471
|
-
* Runtime behaviour configuration.
|
|
472
|
-
* These values are copied into build.json and available to the Bun process at runtime.
|
|
473
|
-
* You can add arbitrary keys here and access them via BuildConfig.
|
|
474
|
-
*/
|
|
475
|
-
runtime?: {
|
|
476
|
-
/**
|
|
477
|
-
* Quit the application when the last BrowserWindow is closed.
|
|
478
|
-
* @default true
|
|
479
|
-
*/
|
|
480
|
-
exitOnLastWindowClosed?: boolean;
|
|
481
|
-
|
|
482
|
-
[key: string]: unknown;
|
|
483
|
-
};
|
|
484
|
-
|
|
485
|
-
/**
|
|
486
|
-
* Build scripts configuration
|
|
487
|
-
*/
|
|
488
|
-
scripts?: {
|
|
489
|
-
/**
|
|
490
|
-
* Script to run before the build starts
|
|
491
|
-
* Can be a path to a script file
|
|
492
|
-
*/
|
|
493
|
-
preBuild?: string;
|
|
494
|
-
|
|
495
|
-
/**
|
|
496
|
-
* Script to run after build completes
|
|
497
|
-
* Can be a path to a script file
|
|
498
|
-
*/
|
|
499
|
-
postBuild?: string;
|
|
500
|
-
|
|
501
|
-
/**
|
|
502
|
-
* Script to run after the app is wrapped (macOS .app bundle created)
|
|
503
|
-
* Can be a path to a script file
|
|
504
|
-
*/
|
|
505
|
-
postWrap?: string;
|
|
506
|
-
|
|
507
|
-
/**
|
|
508
|
-
* Script to run after packaging is complete
|
|
509
|
-
* Can be a path to a script file
|
|
510
|
-
*/
|
|
511
|
-
postPackage?: string;
|
|
512
|
-
};
|
|
513
|
-
|
|
514
|
-
/**
|
|
515
|
-
* Release and distribution configuration
|
|
516
|
-
*/
|
|
517
|
-
release?: {
|
|
518
|
-
/**
|
|
519
|
-
* Base URL for artifact distribution (e.g., S3 bucket, GitHub Releases)
|
|
520
|
-
* Used for auto-updates and patch generation
|
|
521
|
-
*/
|
|
522
|
-
baseUrl?: string;
|
|
523
|
-
/**
|
|
524
|
-
* Generate delta patch files by diffing against the previous release.
|
|
525
|
-
* Disable to skip patch generation for local canary/stable testing.
|
|
526
|
-
* @default true
|
|
527
|
-
*/
|
|
528
|
-
generatePatch?: boolean;
|
|
529
|
-
};
|
|
530
|
-
}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
// Contract tests for the bun:ffi APIs that electrobun depends on.
|
|
2
|
-
//
|
|
3
|
-
// Bun bumps don't usually break electrobun, but when they do, the breakage
|
|
4
|
-
// almost always lives in this surface — JSCallback marshaling, FFIType
|
|
5
|
-
// encoding, dlopen behavior. These tests are a tripwire: if a new Bun release
|
|
6
|
-
// breaks any of them, we want to know before cutting an electrobun release,
|
|
7
|
-
// not after a user reports a crash.
|
|
8
|
-
//
|
|
9
|
-
// Skipped on Windows for now since the bun-check workflow runs on Linux and
|
|
10
|
-
// the system library paths differ. If we add a Windows runner later, switch
|
|
11
|
-
// the libc path resolution to include msvcrt/ucrtbase.
|
|
12
|
-
|
|
13
|
-
import { describe, expect, it } from "bun:test";
|
|
14
|
-
import {
|
|
15
|
-
CString,
|
|
16
|
-
FFIType,
|
|
17
|
-
JSCallback,
|
|
18
|
-
dlopen,
|
|
19
|
-
ptr,
|
|
20
|
-
toArrayBuffer,
|
|
21
|
-
type Pointer,
|
|
22
|
-
} from "bun:ffi";
|
|
23
|
-
|
|
24
|
-
const isUnix =
|
|
25
|
-
process.platform === "darwin" || process.platform === "linux";
|
|
26
|
-
|
|
27
|
-
const libcPath =
|
|
28
|
-
process.platform === "darwin" ? "libSystem.B.dylib" : "libc.so.6";
|
|
29
|
-
|
|
30
|
-
(isUnix ? describe : describe.skip)(
|
|
31
|
-
"bun:ffi contract used by electrobun",
|
|
32
|
-
() => {
|
|
33
|
-
it("dlopen + FFIType.cstring + FFIType.u64 (strlen)", () => {
|
|
34
|
-
const lib = dlopen(libcPath, {
|
|
35
|
-
strlen: {
|
|
36
|
-
args: [FFIType.cstring],
|
|
37
|
-
returns: FFIType.u64,
|
|
38
|
-
},
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
const len = lib.symbols.strlen(
|
|
42
|
-
new TextEncoder().encode("hello\0"),
|
|
43
|
-
);
|
|
44
|
-
expect(Number(len)).toBe(5);
|
|
45
|
-
|
|
46
|
-
lib.close();
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it("ptr + toArrayBuffer round-trip", () => {
|
|
50
|
-
const src = new Uint8Array([1, 2, 3, 4, 5]);
|
|
51
|
-
const back = new Uint8Array(
|
|
52
|
-
toArrayBuffer(ptr(src), 0, src.byteLength),
|
|
53
|
-
);
|
|
54
|
-
expect(Array.from(back)).toEqual([1, 2, 3, 4, 5]);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it("CString reads null-terminated bytes", () => {
|
|
58
|
-
const buf = new Uint8Array([72, 105, 33, 0]); // "Hi!\0"
|
|
59
|
-
const s = new CString(ptr(buf));
|
|
60
|
-
expect(s.toString()).toBe("Hi!");
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("JSCallback: native invokes JS via function pointer (qsort)", () => {
|
|
64
|
-
const lib = dlopen(libcPath, {
|
|
65
|
-
qsort: {
|
|
66
|
-
args: [
|
|
67
|
-
FFIType.ptr,
|
|
68
|
-
FFIType.u64,
|
|
69
|
-
FFIType.u64,
|
|
70
|
-
FFIType.function,
|
|
71
|
-
],
|
|
72
|
-
returns: FFIType.void,
|
|
73
|
-
},
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
let comparisonCount = 0;
|
|
77
|
-
const compare = new JSCallback(
|
|
78
|
-
(aPtr: Pointer, bPtr: Pointer) => {
|
|
79
|
-
comparisonCount++;
|
|
80
|
-
const a = new Int32Array(toArrayBuffer(aPtr, 0, 4))[0]!;
|
|
81
|
-
const b = new Int32Array(toArrayBuffer(bPtr, 0, 4))[0]!;
|
|
82
|
-
return a - b;
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
args: [FFIType.ptr, FFIType.ptr],
|
|
86
|
-
returns: FFIType.i32,
|
|
87
|
-
},
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
const arr = new Int32Array([5, 2, 8, 1, 3]);
|
|
91
|
-
lib.symbols.qsort(
|
|
92
|
-
ptr(arr),
|
|
93
|
-
BigInt(arr.length),
|
|
94
|
-
4n,
|
|
95
|
-
compare.ptr,
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
expect(Array.from(arr)).toEqual([1, 2, 3, 5, 8]);
|
|
99
|
-
expect(comparisonCount).toBeGreaterThan(0);
|
|
100
|
-
|
|
101
|
-
compare.close();
|
|
102
|
-
lib.close();
|
|
103
|
-
});
|
|
104
|
-
},
|
|
105
|
-
);
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { ffi, type ApplicationMenuItemConfig } from "../proc/native";
|
|
2
|
-
import electrobunEventEmitter from "../events/eventEmitter";
|
|
3
|
-
import { roleLabelMap } from "./menuRoles";
|
|
4
|
-
|
|
5
|
-
type NonDividerMenuItem = {
|
|
6
|
-
type?: "normal";
|
|
7
|
-
label?: string;
|
|
8
|
-
tooltip?: string;
|
|
9
|
-
action?: string;
|
|
10
|
-
role?: string;
|
|
11
|
-
data?: unknown;
|
|
12
|
-
submenu?: Array<ApplicationMenuItemConfig>;
|
|
13
|
-
enabled?: boolean;
|
|
14
|
-
checked?: boolean;
|
|
15
|
-
hidden?: boolean;
|
|
16
|
-
accelerator?: string;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export const setApplicationMenu = (menu: Array<ApplicationMenuItemConfig>) => {
|
|
20
|
-
const menuWithDefaults = menuConfigWithDefaults(menu);
|
|
21
|
-
ffi.request.setApplicationMenu({
|
|
22
|
-
menuConfig: JSON.stringify(menuWithDefaults),
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export const on = (
|
|
27
|
-
name: "application-menu-clicked",
|
|
28
|
-
handler: (event: unknown) => void,
|
|
29
|
-
) => {
|
|
30
|
-
const specificName = `${name}`;
|
|
31
|
-
electrobunEventEmitter.on(specificName, handler);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const menuConfigWithDefaults = (
|
|
35
|
-
menu: Array<ApplicationMenuItemConfig>,
|
|
36
|
-
): Array<ApplicationMenuItemConfig> => {
|
|
37
|
-
return menu.map((item) => {
|
|
38
|
-
if (item.type === "divider" || item.type === "separator") {
|
|
39
|
-
return { type: "divider" } as const;
|
|
40
|
-
} else {
|
|
41
|
-
const menuItem = item as NonDividerMenuItem;
|
|
42
|
-
// Use shared serialization method
|
|
43
|
-
const actionWithDataId = ffi.internal.serializeMenuAction(
|
|
44
|
-
menuItem.action || "",
|
|
45
|
-
menuItem.data,
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
return {
|
|
49
|
-
label:
|
|
50
|
-
menuItem.label ||
|
|
51
|
-
roleLabelMap[menuItem.role as keyof typeof roleLabelMap] ||
|
|
52
|
-
"",
|
|
53
|
-
type: menuItem.type || "normal",
|
|
54
|
-
// application menus can either have an action or a role. not both.
|
|
55
|
-
...(menuItem.role
|
|
56
|
-
? { role: menuItem.role }
|
|
57
|
-
: { action: actionWithDataId }),
|
|
58
|
-
// default enabled to true unless explicitly set to false
|
|
59
|
-
enabled: menuItem.enabled === false ? false : true,
|
|
60
|
-
checked: Boolean(menuItem.checked),
|
|
61
|
-
hidden: Boolean(menuItem.hidden),
|
|
62
|
-
tooltip: menuItem.tooltip || undefined,
|
|
63
|
-
accelerator: menuItem.accelerator || undefined,
|
|
64
|
-
...(menuItem.submenu
|
|
65
|
-
? { submenu: menuConfigWithDefaults(menuItem.submenu) }
|
|
66
|
-
: {}),
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
};
|