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.
Files changed (74) hide show
  1. package/README.md +32 -12
  2. package/index.d.mts +684 -0
  3. package/index.d.ts +684 -3
  4. package/index.js +5207 -175
  5. package/index.js.map +1 -0
  6. package/index.mjs +5219 -0
  7. package/index.mjs.map +1 -0
  8. package/main/index.d.mts +21 -0
  9. package/main/index.d.ts +21 -3
  10. package/main/index.js +793 -175
  11. package/main/index.js.map +1 -0
  12. package/main/index.mjs +785 -0
  13. package/main/index.mjs.map +1 -0
  14. package/package.json +40 -32
  15. package/base/browser/browser.d.ts +0 -26
  16. package/base/browser/browser.js +0 -317
  17. package/base/browser/event.d.ts +0 -12
  18. package/base/browser/event.js +0 -215
  19. package/base/browser/keyboardEvent.d.ts +0 -38
  20. package/base/browser/keyboardEvent.js +0 -462
  21. package/base/browser/mouseEvent.d.ts +0 -61
  22. package/base/browser/mouseEvent.js +0 -327
  23. package/base/browser/touch.d.ts +0 -39
  24. package/base/browser/touch.js +0 -454
  25. package/base/common/arrays.d.ts +0 -10
  26. package/base/common/arrays.js +0 -210
  27. package/base/common/async.d.ts +0 -35
  28. package/base/common/async.js +0 -280
  29. package/base/common/charCode.d.ts +0 -405
  30. package/base/common/charCode.js +0 -9
  31. package/base/common/color.d.ts +0 -159
  32. package/base/common/color.js +0 -708
  33. package/base/common/decorators.d.ts +0 -6
  34. package/base/common/decorators.js +0 -300
  35. package/base/common/dom.d.ts +0 -221
  36. package/base/common/dom.js +0 -1476
  37. package/base/common/event.d.ts +0 -213
  38. package/base/common/event.js +0 -804
  39. package/base/common/iterator.d.ts +0 -69
  40. package/base/common/iterator.js +0 -380
  41. package/base/common/keyCodes.d.ts +0 -478
  42. package/base/common/keyCodes.js +0 -477
  43. package/base/common/lifecycle.d.ts +0 -17
  44. package/base/common/lifecycle.js +0 -258
  45. package/base/common/linkedList.d.ts +0 -17
  46. package/base/common/linkedList.js +0 -319
  47. package/base/common/platform.d.ts +0 -36
  48. package/base/common/platform.js +0 -314
  49. package/base/common/strings.d.ts +0 -23
  50. package/base/common/strings.js +0 -273
  51. package/consts.d.ts +0 -58
  52. package/consts.js +0 -317
  53. package/main/attach-titlebar-to-window.d.ts +0 -3
  54. package/main/attach-titlebar-to-window.js +0 -210
  55. package/main/setup-titlebar.d.ts +0 -2
  56. package/main/setup-titlebar.js +0 -255
  57. package/menubar/index.d.ts +0 -86
  58. package/menubar/index.js +0 -1119
  59. package/menubar/menu/index.d.ts +0 -46
  60. package/menubar/menu/index.js +0 -565
  61. package/menubar/menu/item.d.ts +0 -67
  62. package/menubar/menu/item.js +0 -575
  63. package/menubar/menu/separator.d.ts +0 -11
  64. package/menubar/menu/separator.js +0 -213
  65. package/menubar/menu/submenu.d.ts +0 -32
  66. package/menubar/menu/submenu.js +0 -372
  67. package/menubar/menubar-options.d.ts +0 -47
  68. package/menubar/menubar-options.js +0 -9
  69. package/titlebar/index.d.ts +0 -105
  70. package/titlebar/index.js +0 -703
  71. package/titlebar/options.d.ts +0 -89
  72. package/titlebar/options.js +0 -9
  73. package/titlebar/themebar.d.ts +0 -20
  74. package/titlebar/themebar.js +0 -267
package/index.d.mts ADDED
@@ -0,0 +1,684 @@
1
+ import { Menu, MenuItem, NativeImage } from 'electron';
2
+
3
+ declare class RGBA {
4
+ /**
5
+ * Red: integer in [0-255]
6
+ */
7
+ readonly r: number;
8
+ /**
9
+ * Green: integer in [0-255]
10
+ */
11
+ readonly g: number;
12
+ /**
13
+ * Blue: integer in [0-255]
14
+ */
15
+ readonly b: number;
16
+ /**
17
+ * Alpha: float in [0-1]
18
+ */
19
+ readonly a: number;
20
+ constructor(r: number, g: number, b: number, a?: number);
21
+ static equals(a: RGBA, b: RGBA): boolean;
22
+ }
23
+ declare class HSLA {
24
+ /**
25
+ * Hue: integer in [0, 360]
26
+ */
27
+ readonly h: number;
28
+ /**
29
+ * Saturation: float in [0, 1]
30
+ */
31
+ readonly s: number;
32
+ /**
33
+ * Luminosity: float in [0, 1]
34
+ */
35
+ readonly l: number;
36
+ /**
37
+ * Alpha: float in [0, 1]
38
+ */
39
+ readonly a: number;
40
+ constructor(h: number, s: number, l: number, a: number);
41
+ static equals(a: HSLA, b: HSLA): boolean;
42
+ /**
43
+ * Converts an RGB color value to HSL. Conversion formula
44
+ * adapted from http://en.wikipedia.org/wiki/HSL_color_space.
45
+ * Assumes r, g, and b are contained in the set [0, 255] and
46
+ * returns h in the set [0, 360], s, and l in the set [0, 1].
47
+ */
48
+ static fromRGBA(rgba: RGBA): HSLA;
49
+ private static _hue2rgb;
50
+ /**
51
+ * Converts an HSL color value to RGB. Conversion formula
52
+ * adapted from http://en.wikipedia.org/wiki/HSL_color_space.
53
+ * Assumes h in the set [0, 360] s, and l are contained in the set [0, 1] and
54
+ * returns r, g, and b in the set [0, 255].
55
+ */
56
+ static toRGBA(hsla: HSLA): RGBA;
57
+ }
58
+ declare class HSVA {
59
+ /**
60
+ * Hue: integer in [0, 360]
61
+ */
62
+ readonly h: number;
63
+ /**
64
+ * Saturation: float in [0, 1]
65
+ */
66
+ readonly s: number;
67
+ /**
68
+ * Value: float in [0, 1]
69
+ */
70
+ readonly v: number;
71
+ /**
72
+ * Alpha: float in [0, 1]
73
+ */
74
+ readonly a: number;
75
+ constructor(h: number, s: number, v: number, a: number);
76
+ static equals(a: HSVA, b: HSVA): boolean;
77
+ static fromRGBA(rgba: RGBA): HSVA;
78
+ static toRGBA(hsva: HSVA): RGBA;
79
+ }
80
+ declare class Color {
81
+ static fromHex(hex: string): Color;
82
+ readonly rgba: RGBA;
83
+ private _hsla?;
84
+ get hsla(): HSLA;
85
+ private _hsva?;
86
+ get hsva(): HSVA;
87
+ constructor(arg: RGBA | HSLA | HSVA);
88
+ equals(other: Color): boolean;
89
+ /**
90
+ * http://www.w3.org/TR/WCAG20/#relativeluminancedef
91
+ * Returns the number in the set [0, 1]. O => Darkest Black. 1 => Lightest white.
92
+ */
93
+ getRelativeLuminance(): number;
94
+ private static _relativeLuminanceForComponent;
95
+ /**
96
+ * http://www.w3.org/TR/WCAG20/#contrast-ratiodef
97
+ * Returns the contrast ration number in the set [1, 21].
98
+ */
99
+ getContrastRatio(another: Color): number;
100
+ /**
101
+ * http://24ways.org/2010/calculating-color-contrast
102
+ * Return 'true' if darker color otherwise 'false'
103
+ */
104
+ isDarker(): boolean;
105
+ /**
106
+ * http://24ways.org/2010/calculating-color-contrast
107
+ * Return 'true' if lighter color otherwise 'false'
108
+ */
109
+ isLighter(): boolean;
110
+ isLighterThan(another: Color): boolean;
111
+ isDarkerThan(another: Color): boolean;
112
+ lighten(factor: number): Color;
113
+ darken(factor: number): Color;
114
+ transparent(factor: number): Color;
115
+ isTransparent(): boolean;
116
+ isOpaque(): boolean;
117
+ opposite(): Color;
118
+ blend(c: Color): Color;
119
+ flatten(...backgrounds: Color[]): Color;
120
+ private static _flatten;
121
+ toString(): string;
122
+ static getLighterColor(of: Color, relative: Color, factor?: number): Color;
123
+ static getDarkerColor(of: Color, relative: Color, factor?: number): Color;
124
+ static readonly WHITE: Color;
125
+ static readonly BLACK: Color;
126
+ static readonly RED: Color;
127
+ static readonly BLUE: Color;
128
+ static readonly GREEN: Color;
129
+ static readonly CYAN: Color;
130
+ static readonly LIGHTGREY: Color;
131
+ static readonly TRANSPARENT: Color;
132
+ }
133
+ declare namespace Color {
134
+ namespace Format {
135
+ namespace CSS {
136
+ function formatRGB(color: Color): string;
137
+ function formatRGBA(color: Color): string;
138
+ function formatHSL(color: Color): string;
139
+ function formatHSLA(color: Color): string;
140
+ /**
141
+ * Formats the color as #RRGGBB
142
+ */
143
+ function formatHex(color: Color): string;
144
+ /**
145
+ * Formats the color as #RRGGBBAA
146
+ * If 'compact' is set, colors without transparancy will be printed as #RRGGBB
147
+ */
148
+ function formatHexA(color: Color, compact?: boolean): string;
149
+ /**
150
+ * The default format will use HEX if opaque and RGBA otherwise.
151
+ */
152
+ function format(color: Color): string | null;
153
+ /**
154
+ * Converts an Hex color value to a Color.
155
+ * returns r, g, and b are contained in the set [0, 255]
156
+ * @param hex string (#RGB, #RGBA, #RRGGBB or #RRGGBBAA).
157
+ */
158
+ function parseHex(hex: string): Color | null;
159
+ }
160
+ }
161
+ }
162
+
163
+ interface IDisposable {
164
+ dispose(): void;
165
+ }
166
+ declare abstract class Disposable implements IDisposable {
167
+ static None: Readonly<IDisposable>;
168
+ protected _toDispose: IDisposable[];
169
+ protected get toDispose(): IDisposable[];
170
+ private _lifecycle_disposable_isDisposed;
171
+ dispose(): void;
172
+ protected _register<T extends IDisposable>(t: T): T;
173
+ }
174
+
175
+ /**
176
+ * To an event a function with one or zero parameters
177
+ * can be subscribed. The event is the subscriber function itself.
178
+ */
179
+ interface Event<T> {
180
+ (listener: (e: T) => any, thisArgs?: any, disposables?: IDisposable[]): IDisposable;
181
+ }
182
+ declare namespace Event {
183
+ const None: Event<any>;
184
+ /**
185
+ * Given an event, returns another event which only fires once.
186
+ */
187
+ function once<T>(event: Event<T>): Event<T>;
188
+ /**
189
+ * Given an event and a `map` function, returns another event which maps each element
190
+ * throught the mapping function.
191
+ */
192
+ function map<I, O>(event: Event<I>, map: (i: I) => O): Event<O>;
193
+ /**
194
+ * Given an event and an `each` function, returns another identical event and calls
195
+ * the `each` function per each element.
196
+ */
197
+ function forEach<I>(event: Event<I>, each: (i: I) => void): Event<I>;
198
+ /**
199
+ * Given an event and a `filter` function, returns another event which emits those
200
+ * elements for which the `filter` function returns `true`.
201
+ */
202
+ function filter<T>(event: Event<T>, filter: (e: T) => boolean): Event<T>;
203
+ function filter<T, R>(event: Event<T | R>, filter: (e: T | R) => e is R): Event<R>;
204
+ /**
205
+ * Given an event, returns the same event but typed as `Event<void>`.
206
+ */
207
+ function signal<T>(event: Event<T>): Event<void>;
208
+ /**
209
+ * Given a collection of events, returns a single event which emits
210
+ * whenever any of the provided events emit.
211
+ */
212
+ function any<T>(...events: Event<T>[]): Event<T>;
213
+ /**
214
+ * Given an event and a `merge` function, returns another event which maps each element
215
+ * and the cummulative result throught the `merge` function. Similar to `map`, but with memory.
216
+ */
217
+ function reduce<I, O>(event: Event<I>, merge: (last: O | undefined, event: I) => O, initial?: O): Event<O>;
218
+ /**
219
+ * Debounces the provided event, given a `merge` function.
220
+ *
221
+ * @param event The input event.
222
+ * @param merge The reducing function.
223
+ * @param delay The debouncing delay in millis.
224
+ * @param leading Whether the event should fire in the leading phase of the timeout.
225
+ * @param leakWarningThreshold The leak warning threshold override.
226
+ */
227
+ function debounce<T>(event: Event<T>, merge: (last: T, event: T) => T, delay?: number, leading?: boolean, leakWarningThreshold?: number): Event<T>;
228
+ function debounce<I, O>(event: Event<I>, merge: (last: O | undefined, event: I) => O, delay?: number, leading?: boolean, leakWarningThreshold?: number): Event<O>;
229
+ /**
230
+ * Given an event, it returns another event which fires only once and as soon as
231
+ * the input event emits. The event data is the number of millis it took for the
232
+ * event to fire.
233
+ */
234
+ function stopwatch<T>(event: Event<T>): Event<number>;
235
+ /**
236
+ * Given an event, it returns another event which fires only when the event
237
+ * element changes.
238
+ */
239
+ function latch<T>(event: Event<T>): Event<T>;
240
+ /**
241
+ * Buffers the provided event until a first listener comes
242
+ * along, at which point fire all the events at once and
243
+ * pipe the event from then on.
244
+ *
245
+ * ```typescript
246
+ * const emitter = new Emitter<number>();
247
+ * const event = emitter.event;
248
+ * const bufferedEvent = buffer(event);
249
+ *
250
+ * emitter.fire(1);
251
+ * emitter.fire(2);
252
+ * emitter.fire(3);
253
+ * // nothing...
254
+ *
255
+ * const listener = bufferedEvent(num => console.log(num));
256
+ * // 1, 2, 3
257
+ *
258
+ * emitter.fire(4);
259
+ * // 4
260
+ * ```
261
+ */
262
+ function buffer<T>(event: Event<T>, nextTick?: boolean, _buffer?: T[]): Event<T>;
263
+ /**
264
+ * Similar to `buffer` but it buffers indefinitely and repeats
265
+ * the buffered events to every new listener.
266
+ */
267
+ function echo<T>(event: Event<T>, nextTick?: boolean, buffer?: T[]): Event<T>;
268
+ interface IChainableEvent<T> {
269
+ event: Event<T>;
270
+ map<O>(fn: (i: T) => O): IChainableEvent<O>;
271
+ forEach(fn: (i: T) => void): IChainableEvent<T>;
272
+ filter(fn: (e: T) => boolean): IChainableEvent<T>;
273
+ reduce<R>(merge: (last: R | undefined, event: T) => R, initial?: R): IChainableEvent<R>;
274
+ latch(): IChainableEvent<T>;
275
+ on(listener: (e: T) => any, thisArgs?: any, disposables?: IDisposable[]): IDisposable;
276
+ once(listener: (e: T) => any, thisArgs?: any, disposables?: IDisposable[]): IDisposable;
277
+ }
278
+ function chain<T>(event: Event<T>): IChainableEvent<T>;
279
+ interface NodeEventEmitter {
280
+ on(event: string | symbol, listener: Function): this;
281
+ removeListener(event: string | symbol, listener: Function): this;
282
+ }
283
+ function fromNodeEventEmitter<T>(emitter: NodeEventEmitter, eventName: string, map?: (...args: any[]) => T): Event<T>;
284
+ function fromPromise<T = any>(promise: Promise<T>): Event<undefined>;
285
+ function toPromise<T>(event: Event<T>): Promise<T>;
286
+ }
287
+
288
+ interface MenuBarOptions {
289
+ /**
290
+ * Enable the mnemonics on menubar and menu items
291
+ * **The default is true**
292
+ */
293
+ enableMnemonics?: boolean;
294
+ /**
295
+ * The path of the icons of menubar.
296
+ */
297
+ icons?: string;
298
+ /**
299
+ * The background color when the mouse is over the item.
300
+ * **The default is undefined**
301
+ */
302
+ itemBackgroundColor?: Color;
303
+ /**
304
+ * The background color of the menu.
305
+ * **The default is automatic**
306
+ */
307
+ menuBarBackgroundColor?: Color;
308
+ /**
309
+ * The position of menubar on titlebar.
310
+ * **The default is left**
311
+ */
312
+ menuPosition?: 'left' | 'bottom';
313
+ /**
314
+ * The color of the menu separator.
315
+ * **The default is automatic**
316
+ */
317
+ menuSeparatorColor?: Color;
318
+ /**
319
+ * The menu container transparency
320
+ * **The default is 0 (not apply transparency)*
321
+ */
322
+ menuTransparency?: number;
323
+ /**
324
+ * Define if is only rendering the menubar without the titlebar.
325
+ * **The default is false**
326
+ */
327
+ onlyShowMenuBar?: boolean;
328
+ /**
329
+ * Define if MenuBar exists on TitleBar or not.
330
+ * **The default is false**
331
+ */
332
+ removeMenuBar?: boolean;
333
+ /**
334
+ * The color of the svg icons in the menu
335
+ * **The default is automatic**
336
+ */
337
+ svgColor?: Color;
338
+ }
339
+
340
+ interface IMenuStyle {
341
+ foregroundColor?: Color;
342
+ backgroundColor?: Color;
343
+ selectionForegroundColor?: Color;
344
+ selectionBackgroundColor?: Color;
345
+ separatorColor?: Color;
346
+ svgColor?: Color;
347
+ }
348
+
349
+ declare enum Direction {
350
+ Right = 0,
351
+ Left = 1
352
+ }
353
+
354
+ interface IMenuIcons {
355
+ readonly submenuIndicator: string;
356
+ readonly checkbox: string;
357
+ readonly radioChecked: string;
358
+ readonly radioUnchecked: string;
359
+ }
360
+ interface IMenuBarOptions {
361
+ enableMnemonics?: boolean;
362
+ disableAltFocus?: boolean;
363
+ visibility?: string;
364
+ alwaysOnMnemonics?: boolean;
365
+ compactMode?: Direction;
366
+ }
367
+ declare class MenuBar extends Disposable {
368
+ private container;
369
+ private menuIcons;
370
+ private currentOptions;
371
+ private options;
372
+ private closeMenu;
373
+ static readonly OVERFLOW_INDEX: number;
374
+ private menus;
375
+ private overflowMenu;
376
+ private focusedMenu;
377
+ private focusToReturn;
378
+ private menuUpdater;
379
+ private _mnemonicsInUse;
380
+ private openedViaKeyboard;
381
+ private awaitingAltRelease;
382
+ private ignoreNextMouseUp;
383
+ private mnemonics;
384
+ private updatePending;
385
+ private _focusState;
386
+ private readonly _onVisibilityChange;
387
+ private readonly _onFocusStateChange;
388
+ private numMenusShown;
389
+ private overflowLayoutScheduled;
390
+ private overflowLayoutPasses;
391
+ private menuStyle;
392
+ constructor(container: HTMLElement, menuIcons: IMenuIcons, currentOptions: MenuBarOptions, options: IMenuBarOptions, closeMenu?: () => void);
393
+ private registerListeners;
394
+ push(menu: Menu): void;
395
+ createOverflowMenu(): void;
396
+ setStyles(style: IMenuStyle): void;
397
+ updateMenu(menu: MenuItem): void;
398
+ dispose(): void;
399
+ blur(): void;
400
+ getWidth(): number;
401
+ getHeight(): number;
402
+ toggleFocus(): void;
403
+ private updateOverflowAction;
404
+ private updateLabels;
405
+ update(options?: IMenuBarOptions): void;
406
+ private registerMnemonic;
407
+ private hideMenubar;
408
+ private showMenubar;
409
+ private get focusState();
410
+ private set focusState(value);
411
+ get isVisible(): boolean;
412
+ private get isFocused();
413
+ private get isOpen();
414
+ private get hasOverflow();
415
+ private get isCompact();
416
+ private setUnfocusedState;
417
+ private focusPrevious;
418
+ private focusNext;
419
+ private updateMnemonicVisibility;
420
+ private get mnemonicsInUse();
421
+ private set mnemonicsInUse(value);
422
+ private get shouldAltKeyFocus();
423
+ get onVisibilityChange(): Event<boolean>;
424
+ get onFocusStateChange(): Event<boolean>;
425
+ private onMenuTriggered;
426
+ private onModifierKeyToggled;
427
+ private isCurrentMenu;
428
+ private cleanupMenu;
429
+ private showMenu;
430
+ private rebuildOverflowMenu;
431
+ }
432
+
433
+ interface TitlebarThemeColors {
434
+ titlebar?: string;
435
+ titlebarForeground?: string;
436
+ menuBar?: string;
437
+ menuItemSelection?: string;
438
+ menuSeparator?: string;
439
+ svg?: string;
440
+ }
441
+ interface TitlebarThemeConfig {
442
+ /**
443
+ * Theme schema version. Current supported version is 1.
444
+ */
445
+ version?: number;
446
+ fontFamily?: string;
447
+ fontSize?: number;
448
+ colors?: TitlebarThemeColors;
449
+ }
450
+ interface TitleBarOptions extends MenuBarOptions {
451
+ /**
452
+ * The background color of titlebar.
453
+ * **The default is `#ffffff`**
454
+ */
455
+ backgroundColor?: Color;
456
+ /**
457
+ * Sets the value for the overflow of the container after title bar.
458
+ * **The default value is auto**
459
+ */
460
+ containerOverflow?: 'auto' | 'hidden' | 'visible';
461
+ /**
462
+ * Define if the close button is enabled.
463
+ * **The default is true**
464
+ */
465
+ closeable?: boolean;
466
+ /**
467
+ * When the close button is clicked, the window is hidden instead of closed.
468
+ * **The default is false**
469
+ */
470
+ /**
471
+ * The icon shown on the left side of titlebar.
472
+ * **The default is the favicon of the index.html**
473
+ */
474
+ icon?: NativeImage | string;
475
+ /**
476
+ * The icon size of titlebar. Value between 16 and 24.
477
+ * **The default is 16**
478
+ */
479
+ iconSize?: number;
480
+ /**
481
+ * Define if the maximize and restore buttons are enabled.
482
+ * **The default is true**
483
+ */
484
+ maximizable?: boolean;
485
+ /**
486
+ * Define if the minimize button is enabled.
487
+ * **The default is true**
488
+ */
489
+ minimizable?: boolean;
490
+ /**
491
+ * Set the order of the elements on the title bar. You can use `inverted`, `first-buttons` or don't add for.
492
+ * **The default is undefined**
493
+ */
494
+ order?: 'inverted' | 'first-buttons';
495
+ /**
496
+ * Show shadow of titlebar.
497
+ * **The default is false*
498
+ */
499
+ shadow?: boolean;
500
+ /**
501
+ * Set horizontal alignment of the window title.
502
+ * **The default value is center**
503
+ */
504
+ titleHorizontalAlignment?: 'left' | 'center' | 'right';
505
+ /**
506
+ * Set the titles of controls of the window.
507
+ */
508
+ tooltips?: {
509
+ /**
510
+ * The tooltip of minimize button.
511
+ * **The default is "Minimize"**
512
+ */
513
+ minimize?: string;
514
+ /**
515
+ * The tooltip of maximize button.
516
+ * **The default is "Maximize"**
517
+ */
518
+ maximize?: string;
519
+ /**
520
+ * The tooltip of restore button.
521
+ * **The default is "Restore Down"**
522
+ */
523
+ restoreDown?: string;
524
+ /**
525
+ * The tooltip of close button.
526
+ * **The default is "Close"**
527
+ */
528
+ close?: string;
529
+ };
530
+ /**
531
+ * Enables or disables the blur option in titlebar.
532
+ * *The default is true*
533
+ */
534
+ unfocusEffect?: boolean;
535
+ /**
536
+ * Controls the Minimum Width the user is allowed to resize the window to.
537
+ * **The default is 400*
538
+ */
539
+ minWidth?: number;
540
+ /**
541
+ * Controls the Minimum Height the user is allowed to resize the window to.
542
+ * **The default is 270*
543
+ */
544
+ minHeight?: number;
545
+ /**
546
+ * In-memory theme configuration for titlebar and menubar (optional, for backwards compatibility).
547
+ * Note: Prefer using themeConfigPath in setupTitlebarAndAttachToWindow() in main process instead.
548
+ */
549
+ themeConfig?: TitlebarThemeConfig;
550
+ }
551
+
552
+ interface CssStyle {
553
+ addRule(rule: string): void;
554
+ }
555
+ interface Theme {
556
+ (collector: CssStyle): void;
557
+ }
558
+ declare class ThemingRegistry extends Disposable {
559
+ private readonly theming;
560
+ constructor();
561
+ protected onThemeChange(theme: Theme): IDisposable;
562
+ protected getTheming(): Theme[];
563
+ }
564
+ declare class ThemeBar extends ThemingRegistry {
565
+ constructor();
566
+ protected registerTheme(theme: Theme): void;
567
+ static get win(): Theme;
568
+ static get mac(): Theme;
569
+ }
570
+
571
+ declare class CustomTitlebar extends ThemeBar {
572
+ private titlebar;
573
+ private dragRegion;
574
+ private icon;
575
+ private menuBarContainer;
576
+ private title;
577
+ private controlsContainer;
578
+ private container;
579
+ private menuBar?;
580
+ private titleResizeListener?;
581
+ private forcedForegroundColor?;
582
+ private isInactive;
583
+ private controls;
584
+ private resizer;
585
+ private currentOptions;
586
+ private platformIcons;
587
+ private readonly onWindowMaximizeEvent;
588
+ private readonly onWindowFullscreenEvent;
589
+ private readonly onWindowFocusEvent;
590
+ /**
591
+ * Create a new TitleBar instance
592
+ * @param options The options for the title bar
593
+ */
594
+ constructor(options?: TitleBarOptions);
595
+ private loadIcons;
596
+ /**
597
+ * Setup the background color of the title bar
598
+ * By default, it will use the meta theme-color or msapplication-TileColor and if it doesn't exist, it will use white
599
+ */
600
+ private setupBackgroundColor;
601
+ /**
602
+ * Render the icon of the title bar, if is mac, it will not render
603
+ * By default, it will use the first icon found in the head of the document
604
+ */
605
+ private createIcon;
606
+ private setIconSize;
607
+ private setupMenubar;
608
+ private setupTitle;
609
+ private createControlButton;
610
+ private setupWindowControls;
611
+ private setupContainer;
612
+ private setupTitleBar;
613
+ private loadEvents;
614
+ private closeMenu;
615
+ private onBlur;
616
+ private onFocus;
617
+ private onMenuBarVisibilityChanged;
618
+ private onMenuBarFocusChanged;
619
+ private onDidChangeMaximized;
620
+ private updateMenu;
621
+ private applyThemeConfigFromSource;
622
+ private applyThemeConfig;
623
+ private parseThemeColor;
624
+ private updateStyles;
625
+ private canCenterTitle;
626
+ /**
627
+ * Update title bar styles based on focus state.
628
+ * @param hasFocus focus state of the window
629
+ */
630
+ onWindowFocus(focus: boolean): void;
631
+ /**
632
+ * Update the full screen state and hide or show the title bar.
633
+ * @param fullscreen Fullscreen state of the window
634
+ */
635
+ onWindowFullScreen(fullscreen: boolean): void;
636
+ /**
637
+ * Update the title of the title bar.
638
+ * You can use this method if change the content of `<title>` tag on your html.
639
+ * @param title The title of the title bar and document.
640
+ */
641
+ updateTitle(title: string): this;
642
+ /**
643
+ * It method set new icon to title-bar-icon of title-bar.
644
+ * @param path path to icon
645
+ */
646
+ updateIcon(path: string): this;
647
+ /**
648
+ * Horizontal alignment of the title.
649
+ * @param side `left`, `center` or `right`.
650
+ */
651
+ updateTitleAlignment(side: 'left' | 'center' | 'right'): this;
652
+ /**
653
+ * Update the background color of the title bar
654
+ * @param backgroundColor The color for the background
655
+ */
656
+ updateBackground(backgroundColor: Color): this;
657
+ /**
658
+ * Update the item background color of the menubar
659
+ * @param itemBGColor The color for the item background
660
+ */
661
+ updateItemBGColor(itemBGColor: Color): this;
662
+ /**
663
+ * Update the menu from Menu.getApplicationMenu()
664
+ */
665
+ refreshMenu(): Promise<this>;
666
+ /**
667
+ * Update the position of menubar.
668
+ * @param menuPosition The position of the menu `left` or `bottom`.
669
+ */
670
+ updateMenuPosition(menuPosition: 'left' | 'bottom'): this;
671
+ /**
672
+ * Remove the titlebar, menubar and all methods.
673
+ */
674
+ dispose(): void;
675
+ get titlebarElement(): HTMLElement;
676
+ get menubarElement(): MenuBar | undefined;
677
+ get containerElement(): HTMLElement;
678
+ get titleElement(): HTMLElement;
679
+ }
680
+
681
+ declare const createTitlebar: (options?: TitleBarOptions) => CustomTitlebar;
682
+ declare const createTitlebarOnDOMContentLoaded: (options?: TitleBarOptions) => Promise<CustomTitlebar>;
683
+
684
+ export { CustomTitlebar, type TitleBarOptions, CustomTitlebar as Titlebar, Color as TitlebarColor, type TitlebarThemeConfig, createTitlebar, createTitlebarOnDOMContentLoaded };