custom-electron-titlebar 4.2.8 → 4.4.1
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/README.md +32 -12
- package/index.d.mts +684 -0
- package/index.d.ts +684 -3
- package/index.js +5207 -175
- package/index.js.map +1 -0
- package/index.mjs +5219 -0
- package/index.mjs.map +1 -0
- package/main/index.d.mts +21 -0
- package/main/index.d.ts +21 -3
- package/main/index.js +793 -175
- package/main/index.js.map +1 -0
- package/main/index.mjs +785 -0
- package/main/index.mjs.map +1 -0
- package/package.json +40 -32
- package/base/browser/browser.d.ts +0 -26
- package/base/browser/browser.js +0 -317
- package/base/browser/event.d.ts +0 -12
- package/base/browser/event.js +0 -215
- package/base/browser/keyboardEvent.d.ts +0 -38
- package/base/browser/keyboardEvent.js +0 -462
- package/base/browser/mouseEvent.d.ts +0 -61
- package/base/browser/mouseEvent.js +0 -327
- package/base/browser/touch.d.ts +0 -39
- package/base/browser/touch.js +0 -454
- package/base/common/arrays.d.ts +0 -10
- package/base/common/arrays.js +0 -210
- package/base/common/async.d.ts +0 -35
- package/base/common/async.js +0 -280
- package/base/common/charCode.d.ts +0 -405
- package/base/common/charCode.js +0 -9
- package/base/common/color.d.ts +0 -159
- package/base/common/color.js +0 -708
- package/base/common/decorators.d.ts +0 -6
- package/base/common/decorators.js +0 -300
- package/base/common/dom.d.ts +0 -221
- package/base/common/dom.js +0 -1476
- package/base/common/event.d.ts +0 -213
- package/base/common/event.js +0 -804
- package/base/common/iterator.d.ts +0 -69
- package/base/common/iterator.js +0 -380
- package/base/common/keyCodes.d.ts +0 -478
- package/base/common/keyCodes.js +0 -477
- package/base/common/lifecycle.d.ts +0 -17
- package/base/common/lifecycle.js +0 -258
- package/base/common/linkedList.d.ts +0 -17
- package/base/common/linkedList.js +0 -319
- package/base/common/platform.d.ts +0 -36
- package/base/common/platform.js +0 -314
- package/base/common/strings.d.ts +0 -23
- package/base/common/strings.js +0 -273
- package/consts.d.ts +0 -58
- package/consts.js +0 -317
- package/main/attach-titlebar-to-window.d.ts +0 -3
- package/main/attach-titlebar-to-window.js +0 -210
- package/main/setup-titlebar.d.ts +0 -2
- package/main/setup-titlebar.js +0 -255
- package/menubar/index.d.ts +0 -86
- package/menubar/index.js +0 -1119
- package/menubar/menu/index.d.ts +0 -46
- package/menubar/menu/index.js +0 -565
- package/menubar/menu/item.d.ts +0 -67
- package/menubar/menu/item.js +0 -575
- package/menubar/menu/separator.d.ts +0 -11
- package/menubar/menu/separator.js +0 -213
- package/menubar/menu/submenu.d.ts +0 -32
- package/menubar/menu/submenu.js +0 -372
- package/menubar/menubar-options.d.ts +0 -47
- package/menubar/menubar-options.js +0 -9
- package/titlebar/index.d.ts +0 -105
- package/titlebar/index.js +0 -703
- package/titlebar/options.d.ts +0 -89
- package/titlebar/options.js +0 -9
- package/titlebar/themebar.d.ts +0 -20
- package/titlebar/themebar.js +0 -267
package/main/setup-titlebar.js
DELETED
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/* ---------------------------------------------------------------------------------------------
|
|
4
|
-
* Copyright (c) AlexTorresDev. All rights reserved.
|
|
5
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
6
|
-
*-------------------------------------------------------------------------------------------- */
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports.default = () => {
|
|
11
|
-
if (process.type !== 'browser') return;
|
|
12
|
-
const {
|
|
13
|
-
BrowserWindow,
|
|
14
|
-
Menu,
|
|
15
|
-
MenuItem,
|
|
16
|
-
ipcMain
|
|
17
|
-
} = require('electron');
|
|
18
|
-
// Send menu to renderer title bar process
|
|
19
|
-
ipcMain.handle('request-application-menu', async () => JSON.parse(JSON.stringify(Menu.getApplicationMenu(), (key, value) => key !== 'commandsMap' && key !== 'menu' ? value : undefined)));
|
|
20
|
-
// Handle window events
|
|
21
|
-
ipcMain.on('window-event', (event, eventName) => {
|
|
22
|
-
const window = BrowserWindow.fromWebContents(event.sender);
|
|
23
|
-
/* eslint-disable indent */
|
|
24
|
-
if (window) {
|
|
25
|
-
switch (eventName) {
|
|
26
|
-
case 'window-minimize':
|
|
27
|
-
window?.minimize();
|
|
28
|
-
break;
|
|
29
|
-
case 'window-maximize':
|
|
30
|
-
window?.isMaximized() ? window.unmaximize() : window?.maximize();
|
|
31
|
-
break;
|
|
32
|
-
case 'window-close':
|
|
33
|
-
window?.close();
|
|
34
|
-
break;
|
|
35
|
-
case 'window-is-maximized':
|
|
36
|
-
event.returnValue = window?.isMaximized();
|
|
37
|
-
break;
|
|
38
|
-
default:
|
|
39
|
-
break;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
// Handle menu events
|
|
44
|
-
ipcMain.on('menu-event', (event, commandId) => {
|
|
45
|
-
const item = _get__("getMenuItemByCommandId")(commandId, Menu.getApplicationMenu());
|
|
46
|
-
if (item) item.click(undefined, BrowserWindow.fromWebContents(event.sender), event.sender);
|
|
47
|
-
});
|
|
48
|
-
// Handle menu item icon
|
|
49
|
-
ipcMain.on('menu-icon', (event, commandId) => {
|
|
50
|
-
const item = _get__("getMenuItemByCommandId")(commandId, Menu.getApplicationMenu());
|
|
51
|
-
if (item && item.icon && typeof item.icon !== 'string') {
|
|
52
|
-
event.returnValue = item.icon.toDataURL();
|
|
53
|
-
} else {
|
|
54
|
-
event.returnValue = null;
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
ipcMain.on('update-window-controls', (event, args) => {
|
|
58
|
-
const window = BrowserWindow.fromWebContents(event.sender);
|
|
59
|
-
try {
|
|
60
|
-
if (window) window.setTitleBarOverlay(args);
|
|
61
|
-
event.returnValue = true;
|
|
62
|
-
} catch (_) {
|
|
63
|
-
event.returnValue = false;
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
function getMenuItemByCommandId(commandId, menu) {
|
|
68
|
-
if (!menu) return undefined;
|
|
69
|
-
for (const item of menu.items) {
|
|
70
|
-
if (item.submenu) {
|
|
71
|
-
const submenuItem = _get__("getMenuItemByCommandId")(commandId, item.submenu);
|
|
72
|
-
if (submenuItem) return submenuItem;
|
|
73
|
-
} else if (item.commandId === commandId) return item;
|
|
74
|
-
}
|
|
75
|
-
return undefined;
|
|
76
|
-
}
|
|
77
|
-
function _getGlobalObject() {
|
|
78
|
-
try {
|
|
79
|
-
if (!!global) {
|
|
80
|
-
return global;
|
|
81
|
-
}
|
|
82
|
-
} catch (e) {
|
|
83
|
-
try {
|
|
84
|
-
if (!!window) {
|
|
85
|
-
return window;
|
|
86
|
-
}
|
|
87
|
-
} catch (e) {
|
|
88
|
-
return this;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
;
|
|
93
|
-
var _RewireModuleId__ = null;
|
|
94
|
-
function _getRewireModuleId__() {
|
|
95
|
-
if (_RewireModuleId__ === null) {
|
|
96
|
-
let globalVariable = _getGlobalObject();
|
|
97
|
-
if (!globalVariable.__$$GLOBAL_REWIRE_NEXT_MODULE_ID__) {
|
|
98
|
-
globalVariable.__$$GLOBAL_REWIRE_NEXT_MODULE_ID__ = 0;
|
|
99
|
-
}
|
|
100
|
-
_RewireModuleId__ = __$$GLOBAL_REWIRE_NEXT_MODULE_ID__++;
|
|
101
|
-
}
|
|
102
|
-
return _RewireModuleId__;
|
|
103
|
-
}
|
|
104
|
-
function _getRewireRegistry__() {
|
|
105
|
-
let theGlobalVariable = _getGlobalObject();
|
|
106
|
-
if (!theGlobalVariable.__$$GLOBAL_REWIRE_REGISTRY__) {
|
|
107
|
-
theGlobalVariable.__$$GLOBAL_REWIRE_REGISTRY__ = Object.create(null);
|
|
108
|
-
}
|
|
109
|
-
return theGlobalVariable.__$$GLOBAL_REWIRE_REGISTRY__;
|
|
110
|
-
}
|
|
111
|
-
function _getRewiredData__() {
|
|
112
|
-
let moduleId = _getRewireModuleId__();
|
|
113
|
-
let registry = _getRewireRegistry__();
|
|
114
|
-
let rewireData = registry[moduleId];
|
|
115
|
-
if (!rewireData) {
|
|
116
|
-
registry[moduleId] = Object.create(null);
|
|
117
|
-
rewireData = registry[moduleId];
|
|
118
|
-
}
|
|
119
|
-
return rewireData;
|
|
120
|
-
}
|
|
121
|
-
(function registerResetAll() {
|
|
122
|
-
let theGlobalVariable = _getGlobalObject();
|
|
123
|
-
if (!theGlobalVariable['__rewire_reset_all__']) {
|
|
124
|
-
theGlobalVariable['__rewire_reset_all__'] = function () {
|
|
125
|
-
theGlobalVariable.__$$GLOBAL_REWIRE_REGISTRY__ = Object.create(null);
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
})();
|
|
129
|
-
var INTENTIONAL_UNDEFINED = '__INTENTIONAL_UNDEFINED__';
|
|
130
|
-
let _RewireAPI__ = {};
|
|
131
|
-
(function () {
|
|
132
|
-
function addPropertyToAPIObject(name, value) {
|
|
133
|
-
Object.defineProperty(_RewireAPI__, name, {
|
|
134
|
-
value: value,
|
|
135
|
-
enumerable: false,
|
|
136
|
-
configurable: true
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
addPropertyToAPIObject('__get__', _get__);
|
|
140
|
-
addPropertyToAPIObject('__GetDependency__', _get__);
|
|
141
|
-
addPropertyToAPIObject('__Rewire__', _set__);
|
|
142
|
-
addPropertyToAPIObject('__set__', _set__);
|
|
143
|
-
addPropertyToAPIObject('__reset__', _reset__);
|
|
144
|
-
addPropertyToAPIObject('__ResetDependency__', _reset__);
|
|
145
|
-
addPropertyToAPIObject('__with__', _with__);
|
|
146
|
-
})();
|
|
147
|
-
function _get__(variableName) {
|
|
148
|
-
let rewireData = _getRewiredData__();
|
|
149
|
-
if (rewireData[variableName] === undefined) {
|
|
150
|
-
return _get_original__(variableName);
|
|
151
|
-
} else {
|
|
152
|
-
var value = rewireData[variableName];
|
|
153
|
-
if (value === INTENTIONAL_UNDEFINED) {
|
|
154
|
-
return undefined;
|
|
155
|
-
} else {
|
|
156
|
-
return value;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
function _get_original__(variableName) {
|
|
161
|
-
switch (variableName) {
|
|
162
|
-
case "getMenuItemByCommandId":
|
|
163
|
-
return getMenuItemByCommandId;
|
|
164
|
-
}
|
|
165
|
-
return undefined;
|
|
166
|
-
}
|
|
167
|
-
function _assign__(variableName, value) {
|
|
168
|
-
let rewireData = _getRewiredData__();
|
|
169
|
-
if (rewireData[variableName] === undefined) {
|
|
170
|
-
return _set_original__(variableName, value);
|
|
171
|
-
} else {
|
|
172
|
-
return rewireData[variableName] = value;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
function _set_original__(variableName, _value) {
|
|
176
|
-
switch (variableName) {}
|
|
177
|
-
return undefined;
|
|
178
|
-
}
|
|
179
|
-
function _update_operation__(operation, variableName, prefix) {
|
|
180
|
-
var oldValue = _get__(variableName);
|
|
181
|
-
var newValue = operation === '++' ? oldValue + 1 : oldValue - 1;
|
|
182
|
-
_assign__(variableName, newValue);
|
|
183
|
-
return prefix ? newValue : oldValue;
|
|
184
|
-
}
|
|
185
|
-
function _set__(variableName, value) {
|
|
186
|
-
let rewireData = _getRewiredData__();
|
|
187
|
-
if (typeof variableName === 'object') {
|
|
188
|
-
Object.keys(variableName).forEach(function (name) {
|
|
189
|
-
rewireData[name] = variableName[name];
|
|
190
|
-
});
|
|
191
|
-
return function () {
|
|
192
|
-
Object.keys(variableName).forEach(function (name) {
|
|
193
|
-
_reset__(variableName);
|
|
194
|
-
});
|
|
195
|
-
};
|
|
196
|
-
} else {
|
|
197
|
-
if (value === undefined) {
|
|
198
|
-
rewireData[variableName] = INTENTIONAL_UNDEFINED;
|
|
199
|
-
} else {
|
|
200
|
-
rewireData[variableName] = value;
|
|
201
|
-
}
|
|
202
|
-
return function () {
|
|
203
|
-
_reset__(variableName);
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
function _reset__(variableName) {
|
|
208
|
-
let rewireData = _getRewiredData__();
|
|
209
|
-
delete rewireData[variableName];
|
|
210
|
-
if (Object.keys(rewireData).length == 0) {
|
|
211
|
-
delete _getRewireRegistry__()[_getRewireModuleId__];
|
|
212
|
-
}
|
|
213
|
-
;
|
|
214
|
-
}
|
|
215
|
-
function _with__(object) {
|
|
216
|
-
let rewireData = _getRewiredData__();
|
|
217
|
-
var rewiredVariableNames = Object.keys(object);
|
|
218
|
-
var previousValues = {};
|
|
219
|
-
function reset() {
|
|
220
|
-
rewiredVariableNames.forEach(function (variableName) {
|
|
221
|
-
rewireData[variableName] = previousValues[variableName];
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
return function (callback) {
|
|
225
|
-
rewiredVariableNames.forEach(function (variableName) {
|
|
226
|
-
previousValues[variableName] = rewireData[variableName];
|
|
227
|
-
rewireData[variableName] = object[variableName];
|
|
228
|
-
});
|
|
229
|
-
let result = callback();
|
|
230
|
-
if (!!result && typeof result.then == 'function') {
|
|
231
|
-
result.then(reset).catch(reset);
|
|
232
|
-
} else {
|
|
233
|
-
reset();
|
|
234
|
-
}
|
|
235
|
-
return result;
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
let _typeOfOriginalExport = typeof module.exports;
|
|
239
|
-
function addNonEnumerableProperty(name, value) {
|
|
240
|
-
Object.defineProperty(module.exports, name, {
|
|
241
|
-
value: value,
|
|
242
|
-
enumerable: false,
|
|
243
|
-
configurable: true
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
if ((_typeOfOriginalExport === 'object' || _typeOfOriginalExport === 'function') && Object.isExtensible(module.exports)) {
|
|
247
|
-
addNonEnumerableProperty('__get__', _get__);
|
|
248
|
-
addNonEnumerableProperty('__GetDependency__', _get__);
|
|
249
|
-
addNonEnumerableProperty('__Rewire__', _set__);
|
|
250
|
-
addNonEnumerableProperty('__set__', _set__);
|
|
251
|
-
addNonEnumerableProperty('__reset__', _reset__);
|
|
252
|
-
addNonEnumerableProperty('__ResetDependency__', _reset__);
|
|
253
|
-
addNonEnumerableProperty('__with__', _with__);
|
|
254
|
-
addNonEnumerableProperty('__RewireAPI__', _RewireAPI__);
|
|
255
|
-
}
|
package/menubar/index.d.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { Menu } from 'electron';
|
|
2
|
-
import { Event } from '../base/common/event';
|
|
3
|
-
import { Disposable } from '../base/common/lifecycle';
|
|
4
|
-
import { MenuBarOptions } from './menubar-options';
|
|
5
|
-
import { Direction } from './menu';
|
|
6
|
-
import { IMenuStyle } from './menu/item';
|
|
7
|
-
export interface IMenuIcons {
|
|
8
|
-
readonly submenuIndicator: string;
|
|
9
|
-
readonly checkbox: string;
|
|
10
|
-
readonly radioChecked: string;
|
|
11
|
-
readonly radioUnchecked: string;
|
|
12
|
-
}
|
|
13
|
-
export interface IMenuBarOptions {
|
|
14
|
-
enableMnemonics?: boolean;
|
|
15
|
-
disableAltFocus?: boolean;
|
|
16
|
-
visibility?: string;
|
|
17
|
-
alwaysOnMnemonics?: boolean;
|
|
18
|
-
compactMode?: Direction;
|
|
19
|
-
}
|
|
20
|
-
export interface MenuBarMenu {
|
|
21
|
-
actions?: Menu;
|
|
22
|
-
label: string;
|
|
23
|
-
}
|
|
24
|
-
export declare class MenuBar extends Disposable {
|
|
25
|
-
private container;
|
|
26
|
-
private menuIcons;
|
|
27
|
-
private currentOptions;
|
|
28
|
-
private options;
|
|
29
|
-
private closeMenu;
|
|
30
|
-
static readonly OVERFLOW_INDEX: number;
|
|
31
|
-
private menus;
|
|
32
|
-
private overflowMenu;
|
|
33
|
-
private focusedMenu;
|
|
34
|
-
private focusToReturn;
|
|
35
|
-
private menuUpdater;
|
|
36
|
-
private _mnemonicsInUse;
|
|
37
|
-
private openedViaKeyboard;
|
|
38
|
-
private awaitingAltRelease;
|
|
39
|
-
private ignoreNextMouseUp;
|
|
40
|
-
private mnemonics;
|
|
41
|
-
private updatePending;
|
|
42
|
-
private _focusState;
|
|
43
|
-
private readonly _onVisibilityChange;
|
|
44
|
-
private readonly _onFocusStateChange;
|
|
45
|
-
private numMenusShown;
|
|
46
|
-
private overflowLayoutScheduled;
|
|
47
|
-
private menuStyle;
|
|
48
|
-
constructor(container: HTMLElement, menuIcons: IMenuIcons, currentOptions: MenuBarOptions, options: IMenuBarOptions, closeMenu?: () => void);
|
|
49
|
-
private registerListeners;
|
|
50
|
-
push(menu: Menu): void;
|
|
51
|
-
createOverflowMenu(): void;
|
|
52
|
-
setStyles(style: IMenuStyle): void;
|
|
53
|
-
updateMenu(menu: MenuBarMenu): void;
|
|
54
|
-
dispose(): void;
|
|
55
|
-
blur(): void;
|
|
56
|
-
getWidth(): number;
|
|
57
|
-
getHeight(): number;
|
|
58
|
-
toggleFocus(): void;
|
|
59
|
-
private updateOverflowAction;
|
|
60
|
-
private updateLabels;
|
|
61
|
-
update(options?: IMenuBarOptions): void;
|
|
62
|
-
private registerMnemonic;
|
|
63
|
-
private hideMenubar;
|
|
64
|
-
private showMenubar;
|
|
65
|
-
private get focusState();
|
|
66
|
-
private set focusState(value);
|
|
67
|
-
get isVisible(): boolean;
|
|
68
|
-
private get isFocused();
|
|
69
|
-
private get isOpen();
|
|
70
|
-
private get hasOverflow();
|
|
71
|
-
private get isCompact();
|
|
72
|
-
private setUnfocusedState;
|
|
73
|
-
private focusPrevious;
|
|
74
|
-
private focusNext;
|
|
75
|
-
private updateMnemonicVisibility;
|
|
76
|
-
private get mnemonicsInUse();
|
|
77
|
-
private set mnemonicsInUse(value);
|
|
78
|
-
private get shouldAltKeyFocus();
|
|
79
|
-
get onVisibilityChange(): Event<boolean>;
|
|
80
|
-
get onFocusStateChange(): Event<boolean>;
|
|
81
|
-
private onMenuTriggered;
|
|
82
|
-
private onModifierKeyToggled;
|
|
83
|
-
private isCurrentMenu;
|
|
84
|
-
private cleanupMenu;
|
|
85
|
-
private showMenu;
|
|
86
|
-
}
|