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,181 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared menu role definitions used by ApplicationMenu, ContextMenu, and Tray menus.
|
|
3
|
-
* These map to macOS NSResponder selectors for native text editing support.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export const roleLabelMap: Record<string, string> = {
|
|
7
|
-
// Application roles
|
|
8
|
-
about: "About",
|
|
9
|
-
quit: "Quit",
|
|
10
|
-
hide: "Hide",
|
|
11
|
-
hideOthers: "Hide Others",
|
|
12
|
-
showAll: "Show All",
|
|
13
|
-
|
|
14
|
-
// Window roles
|
|
15
|
-
minimize: "Minimize",
|
|
16
|
-
zoom: "Zoom",
|
|
17
|
-
close: "Close",
|
|
18
|
-
bringAllToFront: "Bring All To Front",
|
|
19
|
-
cycleThroughWindows: "Cycle Through Windows",
|
|
20
|
-
enterFullScreen: "Enter Full Screen",
|
|
21
|
-
exitFullScreen: "Exit Full Screen",
|
|
22
|
-
toggleFullScreen: "Toggle Full Screen",
|
|
23
|
-
|
|
24
|
-
// Standard edit roles
|
|
25
|
-
undo: "Undo",
|
|
26
|
-
redo: "Redo",
|
|
27
|
-
cut: "Cut",
|
|
28
|
-
copy: "Copy",
|
|
29
|
-
paste: "Paste",
|
|
30
|
-
pasteAndMatchStyle: "Paste and Match Style",
|
|
31
|
-
delete: "Delete",
|
|
32
|
-
selectAll: "Select All",
|
|
33
|
-
|
|
34
|
-
// Speech roles
|
|
35
|
-
startSpeaking: "Start Speaking",
|
|
36
|
-
stopSpeaking: "Stop Speaking",
|
|
37
|
-
|
|
38
|
-
// Help
|
|
39
|
-
showHelp: "Show Help",
|
|
40
|
-
|
|
41
|
-
// Movement - basic
|
|
42
|
-
moveForward: "Move Forward",
|
|
43
|
-
moveBackward: "Move Backward",
|
|
44
|
-
moveLeft: "Move Left",
|
|
45
|
-
moveRight: "Move Right",
|
|
46
|
-
moveUp: "Move Up",
|
|
47
|
-
moveDown: "Move Down",
|
|
48
|
-
|
|
49
|
-
// Movement - by word
|
|
50
|
-
moveWordForward: "Move Word Forward",
|
|
51
|
-
moveWordBackward: "Move Word Backward",
|
|
52
|
-
moveWordLeft: "Move Word Left",
|
|
53
|
-
moveWordRight: "Move Word Right",
|
|
54
|
-
|
|
55
|
-
// Movement - by line
|
|
56
|
-
moveToBeginningOfLine: "Move to Beginning of Line",
|
|
57
|
-
moveToEndOfLine: "Move to End of Line",
|
|
58
|
-
moveToLeftEndOfLine: "Move to Left End of Line",
|
|
59
|
-
moveToRightEndOfLine: "Move to Right End of Line",
|
|
60
|
-
|
|
61
|
-
// Movement - by paragraph
|
|
62
|
-
moveToBeginningOfParagraph: "Move to Beginning of Paragraph",
|
|
63
|
-
moveToEndOfParagraph: "Move to End of Paragraph",
|
|
64
|
-
moveParagraphForward: "Move Paragraph Forward",
|
|
65
|
-
moveParagraphBackward: "Move Paragraph Backward",
|
|
66
|
-
|
|
67
|
-
// Movement - by document
|
|
68
|
-
moveToBeginningOfDocument: "Move to Beginning of Document",
|
|
69
|
-
moveToEndOfDocument: "Move to End of Document",
|
|
70
|
-
|
|
71
|
-
// Movement with selection - basic
|
|
72
|
-
moveForwardAndModifySelection: "Move Forward and Modify Selection",
|
|
73
|
-
moveBackwardAndModifySelection: "Move Backward and Modify Selection",
|
|
74
|
-
moveLeftAndModifySelection: "Move Left and Modify Selection",
|
|
75
|
-
moveRightAndModifySelection: "Move Right and Modify Selection",
|
|
76
|
-
moveUpAndModifySelection: "Move Up and Modify Selection",
|
|
77
|
-
moveDownAndModifySelection: "Move Down and Modify Selection",
|
|
78
|
-
|
|
79
|
-
// Movement with selection - by word
|
|
80
|
-
moveWordForwardAndModifySelection: "Move Word Forward and Modify Selection",
|
|
81
|
-
moveWordBackwardAndModifySelection: "Move Word Backward and Modify Selection",
|
|
82
|
-
moveWordLeftAndModifySelection: "Move Word Left and Modify Selection",
|
|
83
|
-
moveWordRightAndModifySelection: "Move Word Right and Modify Selection",
|
|
84
|
-
|
|
85
|
-
// Movement with selection - by line
|
|
86
|
-
moveToBeginningOfLineAndModifySelection:
|
|
87
|
-
"Move to Beginning of Line and Modify Selection",
|
|
88
|
-
moveToEndOfLineAndModifySelection:
|
|
89
|
-
"Move to End of Line and Modify Selection",
|
|
90
|
-
moveToLeftEndOfLineAndModifySelection:
|
|
91
|
-
"Move to Left End of Line and Modify Selection",
|
|
92
|
-
moveToRightEndOfLineAndModifySelection:
|
|
93
|
-
"Move to Right End of Line and Modify Selection",
|
|
94
|
-
|
|
95
|
-
// Movement with selection - by paragraph
|
|
96
|
-
moveToBeginningOfParagraphAndModifySelection:
|
|
97
|
-
"Move to Beginning of Paragraph and Modify Selection",
|
|
98
|
-
moveToEndOfParagraphAndModifySelection:
|
|
99
|
-
"Move to End of Paragraph and Modify Selection",
|
|
100
|
-
moveParagraphForwardAndModifySelection:
|
|
101
|
-
"Move Paragraph Forward and Modify Selection",
|
|
102
|
-
moveParagraphBackwardAndModifySelection:
|
|
103
|
-
"Move Paragraph Backward and Modify Selection",
|
|
104
|
-
|
|
105
|
-
// Movement with selection - by document
|
|
106
|
-
moveToBeginningOfDocumentAndModifySelection:
|
|
107
|
-
"Move to Beginning of Document and Modify Selection",
|
|
108
|
-
moveToEndOfDocumentAndModifySelection:
|
|
109
|
-
"Move to End of Document and Modify Selection",
|
|
110
|
-
|
|
111
|
-
// Page movement
|
|
112
|
-
pageUp: "Page Up",
|
|
113
|
-
pageDown: "Page Down",
|
|
114
|
-
pageUpAndModifySelection: "Page Up and Modify Selection",
|
|
115
|
-
pageDownAndModifySelection: "Page Down and Modify Selection",
|
|
116
|
-
|
|
117
|
-
// Scrolling
|
|
118
|
-
scrollLineUp: "Scroll Line Up",
|
|
119
|
-
scrollLineDown: "Scroll Line Down",
|
|
120
|
-
scrollPageUp: "Scroll Page Up",
|
|
121
|
-
scrollPageDown: "Scroll Page Down",
|
|
122
|
-
scrollToBeginningOfDocument: "Scroll to Beginning of Document",
|
|
123
|
-
scrollToEndOfDocument: "Scroll to End of Document",
|
|
124
|
-
centerSelectionInVisibleArea: "Center Selection in Visible Area",
|
|
125
|
-
|
|
126
|
-
// Deletion - character
|
|
127
|
-
deleteBackward: "Delete Backward",
|
|
128
|
-
deleteForward: "Delete Forward",
|
|
129
|
-
deleteBackwardByDecomposingPreviousCharacter:
|
|
130
|
-
"Delete Backward by Decomposing Previous Character",
|
|
131
|
-
|
|
132
|
-
// Deletion - word
|
|
133
|
-
deleteWordBackward: "Delete Word Backward",
|
|
134
|
-
deleteWordForward: "Delete Word Forward",
|
|
135
|
-
|
|
136
|
-
// Deletion - line
|
|
137
|
-
deleteToBeginningOfLine: "Delete to Beginning of Line",
|
|
138
|
-
deleteToEndOfLine: "Delete to End of Line",
|
|
139
|
-
|
|
140
|
-
// Deletion - paragraph
|
|
141
|
-
deleteToBeginningOfParagraph: "Delete to Beginning of Paragraph",
|
|
142
|
-
deleteToEndOfParagraph: "Delete to End of Paragraph",
|
|
143
|
-
|
|
144
|
-
// Selection
|
|
145
|
-
selectWord: "Select Word",
|
|
146
|
-
selectLine: "Select Line",
|
|
147
|
-
selectParagraph: "Select Paragraph",
|
|
148
|
-
selectToMark: "Select to Mark",
|
|
149
|
-
setMark: "Set Mark",
|
|
150
|
-
swapWithMark: "Swap with Mark",
|
|
151
|
-
deleteToMark: "Delete to Mark",
|
|
152
|
-
|
|
153
|
-
// Text transformation
|
|
154
|
-
capitalizeWord: "Capitalize Word",
|
|
155
|
-
uppercaseWord: "Uppercase Word",
|
|
156
|
-
lowercaseWord: "Lowercase Word",
|
|
157
|
-
transpose: "Transpose",
|
|
158
|
-
transposeWords: "Transpose Words",
|
|
159
|
-
|
|
160
|
-
// Insertion
|
|
161
|
-
insertNewline: "Insert Newline",
|
|
162
|
-
insertLineBreak: "Insert Line Break",
|
|
163
|
-
insertParagraphSeparator: "Insert Paragraph Separator",
|
|
164
|
-
insertTab: "Insert Tab",
|
|
165
|
-
insertBacktab: "Insert Backtab",
|
|
166
|
-
insertTabIgnoringFieldEditor: "Insert Tab Ignoring Field Editor",
|
|
167
|
-
insertNewlineIgnoringFieldEditor: "Insert Newline Ignoring Field Editor",
|
|
168
|
-
|
|
169
|
-
// Kill ring (Emacs-style)
|
|
170
|
-
yank: "Yank",
|
|
171
|
-
yankAndSelect: "Yank and Select",
|
|
172
|
-
|
|
173
|
-
// Completion
|
|
174
|
-
complete: "Complete",
|
|
175
|
-
cancelOperation: "Cancel Operation",
|
|
176
|
-
|
|
177
|
-
// Indentation
|
|
178
|
-
indent: "Indent",
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
export type MenuRole = keyof typeof roleLabelMap;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import ElectrobunEvent from "./event";
|
|
2
|
-
|
|
3
|
-
type MenuClickedData = { id?: number; action: string; data?: unknown };
|
|
4
|
-
type OpenUrlData = { url: string };
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
applicationMenuClicked: (data: MenuClickedData) =>
|
|
8
|
-
new ElectrobunEvent<MenuClickedData, { allow: boolean }>(
|
|
9
|
-
"application-menu-clicked",
|
|
10
|
-
data,
|
|
11
|
-
),
|
|
12
|
-
contextMenuClicked: (data: MenuClickedData) =>
|
|
13
|
-
new ElectrobunEvent<MenuClickedData, { allow: boolean }>(
|
|
14
|
-
"context-menu-clicked",
|
|
15
|
-
data,
|
|
16
|
-
),
|
|
17
|
-
openUrl: (data: OpenUrlData) =>
|
|
18
|
-
new ElectrobunEvent<OpenUrlData, void>("open-url", data),
|
|
19
|
-
reopen: (data: {}) => new ElectrobunEvent<{}, void>("reopen", data),
|
|
20
|
-
beforeQuit: (data: {}) =>
|
|
21
|
-
new ElectrobunEvent<{}, { allow: boolean }>("before-quit", data),
|
|
22
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export default class ElectrobunEvent<DataType, ResponseType> {
|
|
2
|
-
// todo (yoav): make most of these readonly except for response
|
|
3
|
-
name: string;
|
|
4
|
-
data: DataType;
|
|
5
|
-
// todo (yoav): define getters and setters for response
|
|
6
|
-
_response: ResponseType | undefined;
|
|
7
|
-
responseWasSet: boolean = false;
|
|
8
|
-
|
|
9
|
-
constructor(name: string, data: DataType) {
|
|
10
|
-
this.name = name;
|
|
11
|
-
this.data = data;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// Getter for response
|
|
15
|
-
get response(): ResponseType | undefined {
|
|
16
|
-
return this._response;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Setter for response
|
|
20
|
-
set response(value: ResponseType) {
|
|
21
|
-
this._response = value;
|
|
22
|
-
this.responseWasSet = true; // Update flag when response is set
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
clearResponse() {
|
|
26
|
-
this._response = undefined;
|
|
27
|
-
this.responseWasSet = false;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import EventEmitter from "events";
|
|
2
|
-
import windowEvents from "./windowEvents";
|
|
3
|
-
import webviewEvents from "./webviewEvents";
|
|
4
|
-
import trayEvents from "./trayEvents";
|
|
5
|
-
import applicationEvents from "./ApplicationEvents";
|
|
6
|
-
import ElectrobunEvent from "./event";
|
|
7
|
-
|
|
8
|
-
class ElectrobunEventEmitter extends EventEmitter {
|
|
9
|
-
constructor() {
|
|
10
|
-
super();
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// optionally pass in a specifier to make the event name specific.
|
|
14
|
-
// eg: will-navigate is listened to globally for all webviews, but
|
|
15
|
-
// will-navigate-1 is listened to for a specific webview with id 1
|
|
16
|
-
emitEvent(
|
|
17
|
-
ElectrobunEvent: ElectrobunEvent<any, any>,
|
|
18
|
-
specifier?: number | string,
|
|
19
|
-
) {
|
|
20
|
-
if (specifier) {
|
|
21
|
-
this.emit(`${ElectrobunEvent.name}-${specifier}`, ElectrobunEvent);
|
|
22
|
-
} else {
|
|
23
|
-
this.emit(ElectrobunEvent.name, ElectrobunEvent);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
events = {
|
|
28
|
-
window: {
|
|
29
|
-
...windowEvents,
|
|
30
|
-
},
|
|
31
|
-
webview: {
|
|
32
|
-
...webviewEvents,
|
|
33
|
-
},
|
|
34
|
-
tray: {
|
|
35
|
-
...trayEvents,
|
|
36
|
-
},
|
|
37
|
-
app: {
|
|
38
|
-
...applicationEvents,
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export const electrobunEventEmitter = new ElectrobunEventEmitter();
|
|
44
|
-
|
|
45
|
-
export default electrobunEventEmitter;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import ElectrobunEvent from "./event";
|
|
2
|
-
|
|
3
|
-
type TrayClickedData = { id: number; action: string; data?: unknown };
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
trayClicked: (data: TrayClickedData) =>
|
|
7
|
-
new ElectrobunEvent<TrayClickedData, { allow: boolean }>(
|
|
8
|
-
"tray-clicked",
|
|
9
|
-
data,
|
|
10
|
-
),
|
|
11
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import ElectrobunEvent from "./event";
|
|
2
|
-
|
|
3
|
-
type DetailData = { detail: string };
|
|
4
|
-
type NewWindowOpenData = {
|
|
5
|
-
detail:
|
|
6
|
-
| string
|
|
7
|
-
| {
|
|
8
|
-
url: string;
|
|
9
|
-
isCmdClick: boolean;
|
|
10
|
-
modifierFlags?: number;
|
|
11
|
-
targetDisposition?: number;
|
|
12
|
-
userGesture?: boolean;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export default {
|
|
17
|
-
willNavigate: (data: DetailData) =>
|
|
18
|
-
new ElectrobunEvent<DetailData, {}>("will-navigate", data),
|
|
19
|
-
didNavigate: (data: DetailData) =>
|
|
20
|
-
new ElectrobunEvent<DetailData, {}>("did-navigate", data),
|
|
21
|
-
didNavigateInPage: (data: DetailData) =>
|
|
22
|
-
new ElectrobunEvent<DetailData, {}>("did-navigate-in-page", data),
|
|
23
|
-
didCommitNavigation: (data: DetailData) =>
|
|
24
|
-
new ElectrobunEvent<DetailData, {}>("did-commit-navigation", data),
|
|
25
|
-
domReady: (data: DetailData) =>
|
|
26
|
-
new ElectrobunEvent<DetailData, {}>("dom-ready", data),
|
|
27
|
-
newWindowOpen: (data: NewWindowOpenData) =>
|
|
28
|
-
new ElectrobunEvent<NewWindowOpenData, {}>("new-window-open", data),
|
|
29
|
-
hostMessage: (data: DetailData) =>
|
|
30
|
-
new ElectrobunEvent<DetailData, {}>("host-message", data),
|
|
31
|
-
downloadStarted: (data: DetailData) =>
|
|
32
|
-
new ElectrobunEvent<DetailData, {}>("download-started", data),
|
|
33
|
-
downloadProgress: (data: DetailData) =>
|
|
34
|
-
new ElectrobunEvent<DetailData, {}>("download-progress", data),
|
|
35
|
-
downloadCompleted: (data: DetailData) =>
|
|
36
|
-
new ElectrobunEvent<DetailData, {}>("download-completed", data),
|
|
37
|
-
downloadFailed: (data: DetailData) =>
|
|
38
|
-
new ElectrobunEvent<DetailData, {}>("download-failed", data),
|
|
39
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import ElectrobunEvent from "./event";
|
|
2
|
-
|
|
3
|
-
type IdData = { id: number };
|
|
4
|
-
type ResizeData = {
|
|
5
|
-
id: number;
|
|
6
|
-
x: number;
|
|
7
|
-
y: number;
|
|
8
|
-
width: number;
|
|
9
|
-
height: number;
|
|
10
|
-
};
|
|
11
|
-
type MoveData = { id: number; x: number; y: number };
|
|
12
|
-
type KeyData = { id: number; keyCode: number; modifiers: number; isRepeat: boolean };
|
|
13
|
-
|
|
14
|
-
export default {
|
|
15
|
-
close: (data: IdData) => new ElectrobunEvent<IdData, {}>("close", data),
|
|
16
|
-
resize: (data: ResizeData) =>
|
|
17
|
-
new ElectrobunEvent<ResizeData, {}>("resize", data),
|
|
18
|
-
move: (data: MoveData) => new ElectrobunEvent<MoveData, {}>("move", data),
|
|
19
|
-
focus: (data: IdData) => new ElectrobunEvent<IdData, {}>("focus", data),
|
|
20
|
-
blur: (data: IdData) => new ElectrobunEvent<IdData, {}>("blur", data),
|
|
21
|
-
keyDown: (data: KeyData) => new ElectrobunEvent<KeyData, {}>("keyDown", data),
|
|
22
|
-
keyUp: (data: KeyData) => new ElectrobunEvent<KeyData, {}>("keyUp", data),
|
|
23
|
-
};
|
package/dist/api/bun/index.ts
DELETED
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
import electobunEventEmmitter from "./events/eventEmitter";
|
|
2
|
-
import { BrowserWindow, type WindowOptionsType } from "./core/BrowserWindow";
|
|
3
|
-
import { BrowserView, type BrowserViewOptions } from "./core/BrowserView";
|
|
4
|
-
import { GpuWindow, type GpuWindowOptionsType } from "./core/GpuWindow";
|
|
5
|
-
import { WGPUView, type WGPUViewOptions } from "./core/WGPUView";
|
|
6
|
-
import { Tray, type TrayOptions } from "./core/Tray";
|
|
7
|
-
import * as ApplicationMenu from "./core/ApplicationMenu";
|
|
8
|
-
import * as ContextMenu from "./core/ContextMenu";
|
|
9
|
-
import {
|
|
10
|
-
Updater,
|
|
11
|
-
type UpdateStatusType,
|
|
12
|
-
type UpdateStatusEntry,
|
|
13
|
-
type UpdateStatusDetails,
|
|
14
|
-
} from "./core/Updater";
|
|
15
|
-
import * as Utils from "./core/Utils";
|
|
16
|
-
import type {
|
|
17
|
-
MessageBoxOptions,
|
|
18
|
-
MessageBoxResponse,
|
|
19
|
-
NotificationOptions,
|
|
20
|
-
} from "./core/Utils";
|
|
21
|
-
import {
|
|
22
|
-
type RPCSchema,
|
|
23
|
-
type ElectrobunRPCSchema,
|
|
24
|
-
createRPC,
|
|
25
|
-
defineElectrobunRPC,
|
|
26
|
-
} from "../shared/rpc.js";
|
|
27
|
-
import type ElectrobunEvent from "./events/event";
|
|
28
|
-
import * as PATHS from "./core/Paths";
|
|
29
|
-
import * as Socket from "./core/Socket";
|
|
30
|
-
import WGPU from "./webGPU";
|
|
31
|
-
import webgpu from "./webgpuAdapter";
|
|
32
|
-
import * as three from "three";
|
|
33
|
-
import * as babylon from "@babylonjs/core";
|
|
34
|
-
import type { ElectrobunConfig } from "./ElectrobunConfig";
|
|
35
|
-
import { GlobalShortcut, Screen, Session, WGPUBridge } from "./proc/native";
|
|
36
|
-
import type {
|
|
37
|
-
Display,
|
|
38
|
-
Rectangle,
|
|
39
|
-
Point,
|
|
40
|
-
Cookie,
|
|
41
|
-
CookieFilter,
|
|
42
|
-
StorageType,
|
|
43
|
-
MenuItemConfig,
|
|
44
|
-
ApplicationMenuItemConfig,
|
|
45
|
-
} from "./proc/native";
|
|
46
|
-
import { BuildConfig, type BuildConfigType } from "./core/BuildConfig";
|
|
47
|
-
import { bridge, hasFFI } from "./proc/native";
|
|
48
|
-
|
|
49
|
-
// Carrot boot state — populated from __bunnyCarrotBootstrap injected by Bunny Ears
|
|
50
|
-
let _carrotManifest: Record<string, unknown> | null = null;
|
|
51
|
-
let _carrotContext: { currentDir?: string; statePath?: string; logsPath?: string; permissions?: string[]; grantedPermissions?: Record<string, unknown>; authToken?: string | null; channel?: string } | null = null;
|
|
52
|
-
|
|
53
|
-
const _bootstrap = (globalThis as any).__bunnyCarrotBootstrap as { manifest?: any; context?: any } | undefined;
|
|
54
|
-
if (_bootstrap) {
|
|
55
|
-
_carrotManifest = _bootstrap.manifest ?? null;
|
|
56
|
-
_carrotContext = _bootstrap.context ?? null;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (bridge) {
|
|
60
|
-
bridge.on("init", (payload: any) => {
|
|
61
|
-
if (payload?.manifest) _carrotManifest = payload.manifest;
|
|
62
|
-
if (payload?.context) _carrotContext = payload.context;
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
// Forward host events to the local event emitter so ApplicationMenu.on(),
|
|
66
|
-
// ContextMenu.on(), etc. work in carrot workers
|
|
67
|
-
for (const eventName of ["application-menu-clicked", "context-menu-clicked"]) {
|
|
68
|
-
bridge.on(eventName, (payload: unknown) => {
|
|
69
|
-
electobunEventEmmitter.emitEvent({ type: eventName, data: payload } as any);
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Update local auth token when the host notifies of a change (e.g., Farm login)
|
|
74
|
-
bridge.on("auth-token-changed", (payload: unknown) => {
|
|
75
|
-
const token = (payload as any)?.token;
|
|
76
|
-
if (token && _carrotContext) {
|
|
77
|
-
_carrotContext.authToken = token;
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
// Clear local auth token on logout
|
|
82
|
-
bridge.on("auth-token-cleared", () => {
|
|
83
|
-
if (_carrotContext) {
|
|
84
|
-
_carrotContext.authToken = null;
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export const Carrots = {
|
|
90
|
-
async invoke<T = unknown>(
|
|
91
|
-
carrotId: string,
|
|
92
|
-
method: string,
|
|
93
|
-
params?: unknown,
|
|
94
|
-
options?: { windowId?: string },
|
|
95
|
-
): Promise<T> {
|
|
96
|
-
if (!bridge) throw new Error("Carrots.invoke() is only available when running as a carrot inside Bunny Ears");
|
|
97
|
-
return bridge.requestHost<T>("invoke-carrot", { carrotId, method, params, windowId: options?.windowId });
|
|
98
|
-
},
|
|
99
|
-
emit(carrotId: string, name: string, payload?: unknown) {
|
|
100
|
-
if (!bridge) throw new Error("Carrots.emit() is only available when running as a carrot inside Bunny Ears");
|
|
101
|
-
bridge.sendAction("emit-carrot-event", { carrotId, name, payload });
|
|
102
|
-
},
|
|
103
|
-
async list() {
|
|
104
|
-
if (!bridge) throw new Error("Carrots.list() is only available when running as a carrot inside Bunny Ears");
|
|
105
|
-
return bridge.requestHost<Array<{
|
|
106
|
-
id: string; name: string; description: string; version: string;
|
|
107
|
-
mode: string; permissions: string[]; status: string; devMode: boolean;
|
|
108
|
-
remoteUIs?: Array<{ id: string; name: string; path: string }>;
|
|
109
|
-
slateUIs?: Array<{ id: string; name: string; path: string }>;
|
|
110
|
-
contributions?: {
|
|
111
|
-
fileActivators?: Array<{
|
|
112
|
-
baseName?: string;
|
|
113
|
-
nodeType?: "file" | "dir" | "any";
|
|
114
|
-
slate: {
|
|
115
|
-
type: string;
|
|
116
|
-
name?: string;
|
|
117
|
-
icon?: string;
|
|
118
|
-
config?: Record<string, unknown>;
|
|
119
|
-
};
|
|
120
|
-
}>;
|
|
121
|
-
};
|
|
122
|
-
}>>("list-carrots");
|
|
123
|
-
},
|
|
124
|
-
async start(carrotId: string) {
|
|
125
|
-
if (!bridge) throw new Error("Carrots.start() is only available when running as a carrot inside Bunny Ears");
|
|
126
|
-
return bridge.requestHost<{ ok: boolean }>("start-carrot", { id: carrotId });
|
|
127
|
-
},
|
|
128
|
-
async stop(carrotId: string) {
|
|
129
|
-
if (!bridge) throw new Error("Carrots.stop() is only available when running as a carrot inside Bunny Ears");
|
|
130
|
-
return bridge.requestHost<{ ok: boolean }>("stop-carrot", { id: carrotId });
|
|
131
|
-
},
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
export const app = {
|
|
135
|
-
on(name: string, handler: (payload: unknown) => void) {
|
|
136
|
-
if (bridge) {
|
|
137
|
-
return bridge.on(name, handler);
|
|
138
|
-
}
|
|
139
|
-
electobunEventEmmitter.on(name, (e: { data: unknown }) => handler(e.data));
|
|
140
|
-
return () => {};
|
|
141
|
-
},
|
|
142
|
-
quit() {
|
|
143
|
-
Utils.quit();
|
|
144
|
-
},
|
|
145
|
-
get isCarrotMode() {
|
|
146
|
-
return !hasFFI;
|
|
147
|
-
},
|
|
148
|
-
get manifest() {
|
|
149
|
-
return _carrotManifest;
|
|
150
|
-
},
|
|
151
|
-
get permissions() {
|
|
152
|
-
return _carrotContext?.permissions ?? [];
|
|
153
|
-
},
|
|
154
|
-
get grantedPermissions() {
|
|
155
|
-
return _carrotContext?.grantedPermissions ?? {};
|
|
156
|
-
},
|
|
157
|
-
get currentDir() {
|
|
158
|
-
return _carrotContext?.currentDir ?? "";
|
|
159
|
-
},
|
|
160
|
-
get statePath() {
|
|
161
|
-
return _carrotContext?.statePath ?? "";
|
|
162
|
-
},
|
|
163
|
-
get logsPath() {
|
|
164
|
-
return _carrotContext?.logsPath ?? "";
|
|
165
|
-
},
|
|
166
|
-
get authToken() {
|
|
167
|
-
return _carrotContext?.authToken ?? null;
|
|
168
|
-
},
|
|
169
|
-
async fetchAuthToken(): Promise<string | null> {
|
|
170
|
-
if (!bridge) return null;
|
|
171
|
-
const result = await bridge.requestHost<{ token: string | null }>("get-auth-token");
|
|
172
|
-
if (result?.token && _carrotContext) {
|
|
173
|
-
_carrotContext.authToken = result.token;
|
|
174
|
-
}
|
|
175
|
-
return result?.token ?? null;
|
|
176
|
-
},
|
|
177
|
-
async setAuthToken(token: string): Promise<void> {
|
|
178
|
-
if (!bridge) return;
|
|
179
|
-
await bridge.requestHost("set-auth-token", { token });
|
|
180
|
-
if (_carrotContext) {
|
|
181
|
-
_carrotContext.authToken = token;
|
|
182
|
-
}
|
|
183
|
-
},
|
|
184
|
-
async setDeviceToken(token: string, tokenId?: string): Promise<void> {
|
|
185
|
-
if (!bridge) return;
|
|
186
|
-
await bridge.requestHost("set-device-token", { token, tokenId });
|
|
187
|
-
},
|
|
188
|
-
async getMachineInfo(): Promise<{ machineId: string; hostname: string; platform: string }> {
|
|
189
|
-
if (!bridge) {
|
|
190
|
-
return { machineId: "", hostname: "", platform: "" };
|
|
191
|
-
}
|
|
192
|
-
return bridge.requestHost<{ machineId: string; hostname: string; platform: string }>(
|
|
193
|
-
"get-machine-info",
|
|
194
|
-
);
|
|
195
|
-
},
|
|
196
|
-
async updateCarrots(): Promise<void> {
|
|
197
|
-
if (!bridge) return;
|
|
198
|
-
await bridge.requestHost("update-carrots");
|
|
199
|
-
},
|
|
200
|
-
async getWebBridgePort(): Promise<number | null> {
|
|
201
|
-
if (!bridge) return null;
|
|
202
|
-
const result = await bridge.requestHost<{ port: number | null }>("get-web-bridge-port");
|
|
203
|
-
return typeof result?.port === "number" ? result.port : null;
|
|
204
|
-
},
|
|
205
|
-
get channel() {
|
|
206
|
-
return _carrotContext?.channel ?? "";
|
|
207
|
-
},
|
|
208
|
-
openManager() {
|
|
209
|
-
if (bridge) bridge.sendAction("open-manager");
|
|
210
|
-
},
|
|
211
|
-
openBunnyWindow(payload?: { screenX?: number; screenY?: number }) {
|
|
212
|
-
if (bridge) bridge.sendAction("open-bunny-window", payload);
|
|
213
|
-
},
|
|
214
|
-
async getWindowFrame(windowId?: string) {
|
|
215
|
-
if (!bridge) return null;
|
|
216
|
-
return bridge.requestHost<{ x: number; y: number; width: number; height: number } | null>("window-get-frame", { windowId });
|
|
217
|
-
},
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
// Named Exports
|
|
221
|
-
export {
|
|
222
|
-
type RPCSchema,
|
|
223
|
-
type ElectrobunRPCSchema,
|
|
224
|
-
type ElectrobunEvent,
|
|
225
|
-
type ElectrobunConfig,
|
|
226
|
-
type BuildConfigType,
|
|
227
|
-
type WindowOptionsType,
|
|
228
|
-
type BrowserViewOptions,
|
|
229
|
-
type GpuWindowOptionsType,
|
|
230
|
-
type WGPUViewOptions,
|
|
231
|
-
type TrayOptions,
|
|
232
|
-
type MessageBoxOptions,
|
|
233
|
-
type MessageBoxResponse,
|
|
234
|
-
type NotificationOptions,
|
|
235
|
-
type MenuItemConfig,
|
|
236
|
-
type ApplicationMenuItemConfig,
|
|
237
|
-
type Display,
|
|
238
|
-
type Rectangle,
|
|
239
|
-
type Point,
|
|
240
|
-
type Cookie,
|
|
241
|
-
type CookieFilter,
|
|
242
|
-
type StorageType,
|
|
243
|
-
type UpdateStatusType,
|
|
244
|
-
type UpdateStatusEntry,
|
|
245
|
-
type UpdateStatusDetails,
|
|
246
|
-
createRPC,
|
|
247
|
-
defineElectrobunRPC,
|
|
248
|
-
BrowserWindow,
|
|
249
|
-
BrowserView,
|
|
250
|
-
GpuWindow,
|
|
251
|
-
WGPUView,
|
|
252
|
-
Tray,
|
|
253
|
-
Updater,
|
|
254
|
-
Utils,
|
|
255
|
-
ApplicationMenu,
|
|
256
|
-
ContextMenu,
|
|
257
|
-
PATHS,
|
|
258
|
-
Socket,
|
|
259
|
-
WGPU,
|
|
260
|
-
webgpu,
|
|
261
|
-
three,
|
|
262
|
-
babylon,
|
|
263
|
-
GlobalShortcut,
|
|
264
|
-
Screen,
|
|
265
|
-
Session,
|
|
266
|
-
WGPUBridge,
|
|
267
|
-
|
|
268
|
-
BuildConfig,
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
// Default Export
|
|
272
|
-
const Electrobun = {
|
|
273
|
-
BrowserWindow,
|
|
274
|
-
BrowserView,
|
|
275
|
-
GpuWindow,
|
|
276
|
-
WGPUView,
|
|
277
|
-
Tray,
|
|
278
|
-
Updater,
|
|
279
|
-
Utils,
|
|
280
|
-
ApplicationMenu,
|
|
281
|
-
ContextMenu,
|
|
282
|
-
GlobalShortcut,
|
|
283
|
-
Screen,
|
|
284
|
-
Session,
|
|
285
|
-
WGPUBridge,
|
|
286
|
-
|
|
287
|
-
BuildConfig,
|
|
288
|
-
events: electobunEventEmmitter,
|
|
289
|
-
PATHS,
|
|
290
|
-
Socket,
|
|
291
|
-
WGPU,
|
|
292
|
-
webgpu,
|
|
293
|
-
three,
|
|
294
|
-
babylon,
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
// Electrobun
|
|
298
|
-
export default Electrobun;
|