custom-electron-titlebar 4.2.0 → 4.2.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 (65) hide show
  1. package/dist/base/browser/browser.d.ts +26 -0
  2. package/dist/base/browser/browser.js +317 -0
  3. package/dist/base/browser/event.d.ts +12 -0
  4. package/dist/base/browser/event.js +215 -0
  5. package/dist/base/browser/keyboardEvent.d.ts +38 -0
  6. package/dist/base/browser/keyboardEvent.js +466 -0
  7. package/dist/base/browser/mouseEvent.d.ts +61 -0
  8. package/dist/base/browser/mouseEvent.js +327 -0
  9. package/dist/base/browser/touch.d.ts +39 -0
  10. package/dist/base/browser/touch.js +454 -0
  11. package/dist/base/common/arrays.d.ts +10 -0
  12. package/dist/base/common/arrays.js +210 -0
  13. package/dist/base/common/async.d.ts +35 -0
  14. package/dist/base/common/async.js +280 -0
  15. package/dist/base/common/charCode.d.ts +405 -0
  16. package/dist/base/common/charCode.js +9 -0
  17. package/dist/base/common/color.d.ts +159 -0
  18. package/dist/base/common/color.js +709 -0
  19. package/dist/base/common/decorators.d.ts +6 -0
  20. package/dist/base/common/decorators.js +300 -0
  21. package/dist/base/common/dom.d.ts +221 -0
  22. package/dist/base/common/dom.js +1478 -0
  23. package/dist/base/common/event.d.ts +213 -0
  24. package/dist/base/common/event.js +804 -0
  25. package/dist/base/common/iterator.d.ts +69 -0
  26. package/dist/base/common/iterator.js +381 -0
  27. package/dist/base/common/keyCodes.d.ts +478 -0
  28. package/dist/base/common/keyCodes.js +479 -0
  29. package/dist/base/common/lifecycle.d.ts +17 -0
  30. package/dist/base/common/lifecycle.js +258 -0
  31. package/dist/base/common/linkedList.d.ts +17 -0
  32. package/dist/base/common/linkedList.js +319 -0
  33. package/dist/base/common/platform.d.ts +33 -0
  34. package/dist/base/common/platform.js +302 -0
  35. package/dist/base/common/strings.d.ts +23 -0
  36. package/dist/base/common/strings.js +273 -0
  37. package/dist/consts.d.ts +49 -0
  38. package/dist/consts.js +303 -0
  39. package/dist/index.d.ts +3 -0
  40. package/dist/index.js +211 -0
  41. package/dist/main/attach-titlebar-to-window.d.ts +3 -0
  42. package/dist/main/attach-titlebar-to-window.js +207 -0
  43. package/dist/main/index.d.ts +3 -0
  44. package/dist/main/index.js +202 -0
  45. package/dist/main/setup-titlebar.d.ts +2 -0
  46. package/dist/main/setup-titlebar.js +242 -0
  47. package/dist/menubar/index.d.ts +86 -0
  48. package/dist/menubar/index.js +1118 -0
  49. package/dist/menubar/menu/index.d.ts +46 -0
  50. package/dist/menubar/menu/index.js +556 -0
  51. package/dist/menubar/menu/item.d.ts +67 -0
  52. package/dist/menubar/menu/item.js +575 -0
  53. package/dist/menubar/menu/separator.d.ts +11 -0
  54. package/dist/menubar/menu/separator.js +213 -0
  55. package/dist/menubar/menu/submenu.d.ts +32 -0
  56. package/dist/menubar/menu/submenu.js +372 -0
  57. package/dist/menubar/menubar-options.d.ts +55 -0
  58. package/dist/menubar/menubar-options.js +9 -0
  59. package/dist/titlebar/index.d.ts +99 -0
  60. package/dist/titlebar/index.js +663 -0
  61. package/dist/titlebar/options.d.ts +84 -0
  62. package/dist/titlebar/options.js +9 -0
  63. package/dist/titlebar/themebar.d.ts +20 -0
  64. package/dist/titlebar/themebar.js +267 -0
  65. package/package.json +1 -1
@@ -0,0 +1,1118 @@
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
+ var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = {
12
+ enumerable: true,
13
+ get: function () {
14
+ return m[k];
15
+ }
16
+ };
17
+ }
18
+ Object.defineProperty(o, k2, desc);
19
+ } : function (o, m, k, k2) {
20
+ if (k2 === undefined) k2 = k;
21
+ o[k2] = m[k];
22
+ });
23
+ var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
24
+ Object.defineProperty(o, "default", {
25
+ enumerable: true,
26
+ value: v
27
+ });
28
+ } : function (o, v) {
29
+ o["default"] = v;
30
+ });
31
+ var __importStar = this && this.__importStar || function (mod) {
32
+ if (mod && mod.__esModule) return mod;
33
+ var result = {};
34
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) _get__("__createBinding")(result, mod, k);
35
+ _get__("__setModuleDefault")(result, mod);
36
+ return result;
37
+ };
38
+ Object.defineProperty(exports, "__esModule", {
39
+ value: true
40
+ });
41
+ exports.MenuBar = void 0;
42
+ const DOM = _get__("__importStar")(require("../base/common/dom"));
43
+ const event_1 = require("../base/common/event");
44
+ const lifecycle_1 = require("../base/common/lifecycle");
45
+ const platform_1 = require("../base/common/platform");
46
+ const keyboardEvent_1 = require("../base/browser/keyboardEvent");
47
+ const keyCodes_1 = require("../base/common/keyCodes");
48
+ const consts_1 = require("../consts");
49
+ const menu_1 = require("./menu");
50
+ const async_1 = require("../base/common/async");
51
+ const mouseEvent_1 = require("../base/browser/mouseEvent");
52
+ const touch_1 = require("../base/browser/touch");
53
+ const strings = _get__("__importStar")(require("../base/common/strings"));
54
+ const $ = _get__("DOM").$;
55
+ var MenubarState;
56
+ (function (MenubarState) {
57
+ MenubarState[MenubarState["HIDDEN"] = 0] = "HIDDEN";
58
+ MenubarState[MenubarState["VISIBLE"] = 1] = "VISIBLE";
59
+ MenubarState[MenubarState["FOCUSED"] = 2] = "FOCUSED";
60
+ MenubarState[MenubarState["OPEN"] = 3] = "OPEN";
61
+ })(_get__("MenubarState") || _assign__("MenubarState", {}));
62
+ class MenuBar extends _get__("lifecycle_1").Disposable {
63
+ constructor(container, menuIcons, currentOptions, options, closeMenu = () => {}) {
64
+ super();
65
+ this.container = container;
66
+ this.menuIcons = menuIcons;
67
+ this.currentOptions = currentOptions;
68
+ this.options = options;
69
+ this.closeMenu = closeMenu;
70
+ // Input-related
71
+ this._mnemonicsInUse = false;
72
+ this.openedViaKeyboard = false;
73
+ this.awaitingAltRelease = false;
74
+ this.ignoreNextMouseUp = false;
75
+ this.updatePending = false;
76
+ this.numMenusShown = 0;
77
+ this.overflowLayoutScheduled = undefined;
78
+ this.menuStyle = {};
79
+ this.container.setAttribute('role', 'menubar');
80
+ if (this.isCompact) {
81
+ this.container.classList.add('compact');
82
+ }
83
+ this.menus = [];
84
+ this.mnemonics = new Map();
85
+ this._focusState = _get__("MenubarState").VISIBLE;
86
+ this._onVisibilityChange = this._register(new (_get__("event_1").Emitter)());
87
+ this._onFocusStateChange = this._register(new (_get__("event_1").Emitter)());
88
+ this.createOverflowMenu();
89
+ this.menuUpdater = this._register(new (_get__("async_1").RunOnceScheduler)(() => this.update(), 200));
90
+ // this.actionRunner = this.options.actionRunner ?? this._register(new ActionRunner());
91
+ this.registerListeners();
92
+ this.setUnfocusedState();
93
+ }
94
+ registerListeners() {
95
+ /* this._register(this.actionRunner.onWillRun(() => {
96
+ this.setUnfocusedState();
97
+ })); */
98
+ if (!_get__("platform_1").isMacintosh) {
99
+ this._register(_get__("DOM").addDisposableListener(window, _get__("DOM").EventType.RESIZE, () => {
100
+ this.blur();
101
+ }));
102
+ }
103
+ this._register(_get__("DOM").ModifierKeyEmitter.getInstance().event(this.onModifierKeyToggled, this));
104
+ this._register(_get__("DOM").addDisposableListener(this.container, _get__("DOM").EventType.KEY_DOWN, e => {
105
+ const event = new (_get__("keyboardEvent_1").StandardKeyboardEvent)(e);
106
+ let eventHandled = true;
107
+ const key = !!e.key ? e.key.toLocaleLowerCase() : '';
108
+ const tabNav = _get__("platform_1").isMacintosh && !this.isCompact;
109
+ if (event.equals(15 /* KeyCode.LeftArrow */) || tabNav && event.equals(2 /* KeyCode.Tab */ | 1024 /* KeyMod.Shift */)) {
110
+ this.focusPrevious();
111
+ } else if (event.equals(17 /* KeyCode.RightArrow */) || tabNav && event.equals(2 /* KeyCode.Tab */)) {
112
+ this.focusNext();
113
+ } else if (event.equals(9 /* KeyCode.Escape */) && this.isFocused && !this.isOpen) {
114
+ this.setUnfocusedState();
115
+ } else if (!this.isOpen && !event.ctrlKey && this.options.enableMnemonics && this.mnemonicsInUse && this.mnemonics.has(key)) {
116
+ const menuIndex = this.mnemonics.get(key);
117
+ this.onMenuTriggered(menuIndex, false);
118
+ } else {
119
+ eventHandled = false;
120
+ }
121
+ // Never allow default tab behavior when not compact
122
+ if (!this.isCompact && (event.equals(2 /* KeyCode.Tab */ | 1024 /* KeyMod.Shift */) || event.equals(2 /* KeyCode.Tab */))) {
123
+ event.preventDefault();
124
+ }
125
+ if (eventHandled) {
126
+ event.preventDefault();
127
+ event.stopPropagation();
128
+ }
129
+ }));
130
+ this._register(_get__("DOM").addDisposableListener(window, _get__("DOM").EventType.MOUSE_DOWN, () => {
131
+ // This mouse event is outside the menubar so it counts as a focus out
132
+ if (this.isFocused) {
133
+ this.setUnfocusedState();
134
+ }
135
+ }));
136
+ this._register(_get__("DOM").addDisposableListener(this.container, _get__("DOM").EventType.FOCUS_IN, e => {
137
+ const event = e;
138
+ if (event.relatedTarget) {
139
+ if (!this.container.contains(event.relatedTarget)) {
140
+ this.focusToReturn = event.relatedTarget;
141
+ }
142
+ }
143
+ }));
144
+ this._register(_get__("DOM").addDisposableListener(this.container, _get__("DOM").EventType.FOCUS_OUT, e => {
145
+ const event = e;
146
+ // We are losing focus and there is a target, reset focusToReturn value as not to redirect
147
+ if (event.relatedTarget && !this.container.contains(event.relatedTarget)) {
148
+ this.focusToReturn = undefined;
149
+ this.setUnfocusedState();
150
+ }
151
+ }));
152
+ this._register(_get__("DOM").addDisposableListener(window, _get__("DOM").EventType.KEY_DOWN, e => {
153
+ if (!this.options.enableMnemonics || !e.altKey || e.ctrlKey || e.defaultPrevented) {
154
+ return;
155
+ }
156
+ console.log(this.mnemonics);
157
+ const key = e.key.toLocaleLowerCase();
158
+ if (!this.mnemonics.has(key)) {
159
+ return;
160
+ }
161
+ this.mnemonicsInUse = true;
162
+ this.updateMnemonicVisibility(true);
163
+ const menuIndex = this.mnemonics.get(key);
164
+ this.onMenuTriggered(menuIndex, false);
165
+ }));
166
+ }
167
+ push(menu) {
168
+ const topLevelMenus = menu.items;
169
+ topLevelMenus.forEach(menuBarMenu => {
170
+ const menuIndex = this.menus.length;
171
+ const cleanMenuLabel = (0, _get__("consts_1").cleanMnemonic)(menuBarMenu.label);
172
+ const mnemonicMatches = _get__("consts_1").MENU_MNEMONIC_REGEX.exec(menuBarMenu.label);
173
+ // Register mnemonics
174
+ if (mnemonicMatches) {
175
+ const mnemonic = !!mnemonicMatches[1] ? mnemonicMatches[1] : mnemonicMatches[3];
176
+ this.registerMnemonic(this.menus.length, mnemonic);
177
+ }
178
+ if (this.isCompact) {
179
+ this.menus.push({
180
+ label: '',
181
+ actions: menuBarMenu.submenu
182
+ });
183
+ } else {
184
+ const buttonElement = _get__("$")('.cet-menubar-menu-button', {
185
+ role: 'menuitem',
186
+ tabindex: -1,
187
+ 'aria-label': cleanMenuLabel,
188
+ 'aria-haspopup': true
189
+ });
190
+ const titleElement = _get__("$")('.cet-menubar-menu-title', {
191
+ role: 'none',
192
+ 'aria-hidden': true
193
+ });
194
+ buttonElement.appendChild(titleElement);
195
+ this.container.insertBefore(buttonElement, this.overflowMenu.buttonElement);
196
+ this.updateLabels(titleElement, buttonElement, menuBarMenu.label);
197
+ this._register(_get__("DOM").addDisposableListener(buttonElement, _get__("DOM").EventType.KEY_UP, e => {
198
+ const event = new (_get__("keyboardEvent_1").StandardKeyboardEvent)(e);
199
+ let eventHandled = true;
200
+ if ((event.equals(18 /* KeyCode.DownArrow */) || event.equals(3 /* KeyCode.Enter */)) && !this.isOpen) {
201
+ this.focusedMenu = {
202
+ index: menuIndex
203
+ };
204
+ this.openedViaKeyboard = true;
205
+ this.focusState = _get__("MenubarState").OPEN;
206
+ } else {
207
+ eventHandled = false;
208
+ }
209
+ if (eventHandled) {
210
+ event.preventDefault();
211
+ event.stopPropagation();
212
+ }
213
+ }));
214
+ this._register(_get__("touch_1").Gesture.addTarget(buttonElement));
215
+ this._register(_get__("DOM").addDisposableListener(buttonElement, _get__("touch_1").EventType.Tap, e => {
216
+ // Ignore this touch if the menu is touched
217
+ if (this.isOpen && this.focusedMenu && this.focusedMenu.holder && _get__("DOM").isAncestor(e.initialTarget, this.focusedMenu.holder)) {
218
+ return;
219
+ }
220
+ this.ignoreNextMouseUp = false;
221
+ this.onMenuTriggered(menuIndex, true);
222
+ e.preventDefault();
223
+ e.stopPropagation();
224
+ }));
225
+ this._register(_get__("DOM").addDisposableListener(buttonElement, _get__("DOM").EventType.MOUSE_DOWN, e => {
226
+ // Ignore non-left-click
227
+ const mouseEvent = new (_get__("mouseEvent_1").StandardMouseEvent)(e);
228
+ if (!mouseEvent.leftButton) {
229
+ e.preventDefault();
230
+ return;
231
+ }
232
+ if (!this.isOpen) {
233
+ // Open the menu with mouse down and ignore the following mouse up event
234
+ this.ignoreNextMouseUp = true;
235
+ this.onMenuTriggered(menuIndex, true);
236
+ } else {
237
+ this.ignoreNextMouseUp = false;
238
+ }
239
+ e.preventDefault();
240
+ e.stopPropagation();
241
+ }));
242
+ this._register(_get__("DOM").addDisposableListener(buttonElement, _get__("DOM").EventType.MOUSE_UP, e => {
243
+ if (e.defaultPrevented) {
244
+ return;
245
+ }
246
+ if (!this.ignoreNextMouseUp) {
247
+ if (this.isFocused) {
248
+ this.onMenuTriggered(menuIndex, true);
249
+ }
250
+ } else {
251
+ this.ignoreNextMouseUp = false;
252
+ }
253
+ }));
254
+ this._register(_get__("DOM").addDisposableListener(buttonElement, _get__("DOM").EventType.MOUSE_ENTER, () => {
255
+ if (this.isOpen && !this.isCurrentMenu(menuIndex)) {
256
+ buttonElement.focus();
257
+ this.cleanupMenu();
258
+ this.showMenu(menuIndex, false);
259
+ } else if (this.isFocused && !this.isOpen) {
260
+ this.focusedMenu = {
261
+ index: menuIndex
262
+ };
263
+ buttonElement.focus();
264
+ }
265
+ }));
266
+ this.menus.push({
267
+ label: menuBarMenu.label,
268
+ actions: menuBarMenu.submenu,
269
+ buttonElement,
270
+ titleElement
271
+ });
272
+ }
273
+ });
274
+ }
275
+ createOverflowMenu() {
276
+ const label = this.isCompact ? 'Compact' : 'More';
277
+ const buttonElement = _get__("$")('.cet-menubar-menu-button', {
278
+ role: 'menuitem',
279
+ tabindex: this.isCompact ? 0 : -1,
280
+ 'aria-label': label,
281
+ 'aria-haspopup': true
282
+ });
283
+ const titleElement = _get__("$")('.cet-menubar-menu-title.cet-toggle-more', {
284
+ role: 'none',
285
+ 'aria-hidden': true
286
+ });
287
+ buttonElement.appendChild(titleElement);
288
+ this.container.appendChild(buttonElement);
289
+ buttonElement.style.visibility = 'hidden';
290
+ this._register(_get__("DOM").addDisposableListener(buttonElement, _get__("DOM").EventType.KEY_UP, e => {
291
+ const event = new (_get__("keyboardEvent_1").StandardKeyboardEvent)(e);
292
+ let eventHandled = true;
293
+ const triggerKeys = [3 /* KeyCode.Enter */];
294
+ if (!this.isCompact) {
295
+ triggerKeys.push(18 /* KeyCode.DownArrow */);
296
+ } else {
297
+ triggerKeys.push(10 /* KeyCode.Space */);
298
+ if (this.options.compactMode === _get__("menu_1").Direction.Right) {
299
+ triggerKeys.push(17 /* KeyCode.RightArrow */);
300
+ } else if (this.options.compactMode === _get__("menu_1").Direction.Left) {
301
+ triggerKeys.push(15 /* KeyCode.LeftArrow */);
302
+ }
303
+ }
304
+
305
+ if (triggerKeys.some(k => event.equals(k)) && !this.isOpen) {
306
+ this.focusedMenu = {
307
+ index: _get__("MenuBar").OVERFLOW_INDEX
308
+ };
309
+ this.openedViaKeyboard = true;
310
+ this.focusState = _get__("MenubarState").OPEN;
311
+ } else {
312
+ eventHandled = false;
313
+ }
314
+ if (eventHandled) {
315
+ event.preventDefault();
316
+ event.stopPropagation();
317
+ }
318
+ }));
319
+ this._register(_get__("touch_1").Gesture.addTarget(buttonElement));
320
+ this._register(_get__("DOM").addDisposableListener(buttonElement, _get__("touch_1").EventType.Tap, e => {
321
+ // Ignore this touch if the menu is touched
322
+ if (this.isOpen && this.focusedMenu && this.focusedMenu.holder && _get__("DOM").isAncestor(e.initialTarget, this.focusedMenu.holder)) {
323
+ return;
324
+ }
325
+ this.ignoreNextMouseUp = false;
326
+ this.onMenuTriggered(_get__("MenuBar").OVERFLOW_INDEX, true);
327
+ e.preventDefault();
328
+ e.stopPropagation();
329
+ }));
330
+ this._register(_get__("DOM").addDisposableListener(buttonElement, _get__("DOM").EventType.MOUSE_DOWN, e => {
331
+ // Ignore non-left-click
332
+ const mouseEvent = new (_get__("mouseEvent_1").StandardMouseEvent)(e);
333
+ if (!mouseEvent.leftButton) {
334
+ e.preventDefault();
335
+ return;
336
+ }
337
+ if (!this.isOpen) {
338
+ // Open the menu with mouse down and ignore the following mouse up event
339
+ this.ignoreNextMouseUp = true;
340
+ this.onMenuTriggered(_get__("MenuBar").OVERFLOW_INDEX, true);
341
+ } else {
342
+ this.ignoreNextMouseUp = false;
343
+ }
344
+ e.preventDefault();
345
+ e.stopPropagation();
346
+ }));
347
+ this._register(_get__("DOM").addDisposableListener(buttonElement, _get__("DOM").EventType.MOUSE_UP, e => {
348
+ if (e.defaultPrevented) {
349
+ return;
350
+ }
351
+ if (!this.ignoreNextMouseUp) {
352
+ if (this.isFocused) {
353
+ this.onMenuTriggered(_get__("MenuBar").OVERFLOW_INDEX, true);
354
+ }
355
+ } else {
356
+ this.ignoreNextMouseUp = false;
357
+ }
358
+ }));
359
+ this._register(_get__("DOM").addDisposableListener(buttonElement, _get__("DOM").EventType.MOUSE_ENTER, () => {
360
+ if (this.isOpen && !this.isCurrentMenu(_get__("MenuBar").OVERFLOW_INDEX)) {
361
+ this.overflowMenu.buttonElement.focus();
362
+ this.cleanupMenu();
363
+ this.showMenu(_get__("MenuBar").OVERFLOW_INDEX, false);
364
+ } else if (this.isFocused && !this.isOpen) {
365
+ this.focusedMenu = {
366
+ index: _get__("MenuBar").OVERFLOW_INDEX
367
+ };
368
+ buttonElement.focus();
369
+ }
370
+ }));
371
+ this.overflowMenu = {
372
+ buttonElement,
373
+ titleElement,
374
+ label: 'More'
375
+ };
376
+ }
377
+ setStyles(style) {
378
+ this.menuStyle = style;
379
+ }
380
+ updateMenu(menu) {
381
+ const menuToUpdate = this.menus.filter(menuBarMenu => menuBarMenu.label === menu.label);
382
+ if (menuToUpdate && menuToUpdate.length) {
383
+ // menuToUpdate[0].actions = menu.actions;
384
+ }
385
+ }
386
+ dispose() {
387
+ super.dispose();
388
+ this.menus.forEach(menuBarMenu => {
389
+ menuBarMenu.titleElement?.remove();
390
+ menuBarMenu.buttonElement?.remove();
391
+ });
392
+ this.overflowMenu.titleElement.remove();
393
+ this.overflowMenu.buttonElement.remove();
394
+ (0, _get__("lifecycle_1").dispose)(this.overflowLayoutScheduled);
395
+ this.overflowLayoutScheduled = undefined;
396
+ }
397
+ blur() {
398
+ this.setUnfocusedState();
399
+ }
400
+ getWidth() {
401
+ if (!this.isCompact && this.menus) {
402
+ const left = this.menus[0].buttonElement.getBoundingClientRect().left;
403
+ const right = this.hasOverflow ? this.overflowMenu.buttonElement.getBoundingClientRect().right : this.menus[this.menus.length - 1].buttonElement.getBoundingClientRect().right;
404
+ return right - left;
405
+ }
406
+ return 0;
407
+ }
408
+ getHeight() {
409
+ return this.container.clientHeight;
410
+ }
411
+ toggleFocus() {
412
+ if (!this.isFocused && this.options.visibility !== 'hidden') {
413
+ this.mnemonicsInUse = true;
414
+ this.focusedMenu = {
415
+ index: this.numMenusShown > 0 ? 0 : _get__("MenuBar").OVERFLOW_INDEX
416
+ };
417
+ this.focusState = _get__("MenubarState").FOCUSED;
418
+ } else if (!this.isOpen) {
419
+ this.setUnfocusedState();
420
+ }
421
+ }
422
+ updateOverflowAction() {
423
+ if (!this.menus || !this.menus.length) {
424
+ return;
425
+ }
426
+ const overflowMenuOnlyClass = 'overflow-menu-only';
427
+ // Remove overflow only restriction to allow the most space
428
+ this.container.classList.toggle(overflowMenuOnlyClass, false);
429
+ const sizeAvailable = this.container.offsetWidth;
430
+ let currentSize = 0;
431
+ let full = this.isCompact;
432
+ const prevNumMenusShown = this.numMenusShown;
433
+ this.numMenusShown = 0;
434
+ const showableMenus = this.menus.filter(menu => menu.buttonElement !== undefined && menu.titleElement !== undefined);
435
+ for (const menuBarMenu of showableMenus) {
436
+ if (!full) {
437
+ const size = menuBarMenu.buttonElement.offsetWidth;
438
+ if (currentSize + size > sizeAvailable) {
439
+ full = true;
440
+ } else {
441
+ currentSize += size;
442
+ this.numMenusShown++;
443
+ if (this.numMenusShown > prevNumMenusShown) {
444
+ menuBarMenu.buttonElement.style.visibility = 'visible';
445
+ }
446
+ }
447
+ }
448
+ if (full) {
449
+ menuBarMenu.buttonElement.style.visibility = 'hidden';
450
+ }
451
+ }
452
+ // If below minimium menu threshold, show the overflow menu only as hamburger menu
453
+ if (this.numMenusShown - 1 <= showableMenus.length / 2) {
454
+ for (const menuBarMenu of showableMenus) {
455
+ menuBarMenu.buttonElement.style.visibility = 'hidden';
456
+ }
457
+ full = true;
458
+ this.numMenusShown = 0;
459
+ currentSize = 0;
460
+ }
461
+ // Overflow
462
+ if (this.isCompact) {
463
+ // this.overflowMenu.actions = [];
464
+ for (let idx = this.numMenusShown; idx < this.menus.length; idx++) {
465
+ // this.overflowMenu.actions.push(new SubmenuAction(`menubar.submenu.${this.menus[idx].label}`, this.menus[idx].label, this.menus[idx].actions || []));
466
+ }
467
+ /* const compactMenuActions = this.options.getCompactMenuActions?.();
468
+ if (compactMenuActions && compactMenuActions.length) {
469
+ //this.overflowMenu.actions.push(new Separator());
470
+ this.overflowMenu.actions.push(...compactMenuActions);
471
+ } */
472
+ this.overflowMenu.buttonElement.style.visibility = 'visible';
473
+ } else if (full) {
474
+ // Can't fit the more button, need to remove more menus
475
+ while (currentSize + this.overflowMenu.buttonElement.offsetWidth > sizeAvailable && this.numMenusShown > 0) {
476
+ this.numMenusShown--;
477
+ const size = showableMenus[this.numMenusShown].buttonElement.offsetWidth;
478
+ showableMenus[this.numMenusShown].buttonElement.style.visibility = 'hidden';
479
+ currentSize -= size;
480
+ }
481
+ // this.overflowMenu.actions = [];
482
+ for (let idx = this.numMenusShown; idx < showableMenus.length; idx++) {
483
+ // this.overflowMenu.actions.push(new SubmenuAction(`menubar.submenu.${showableMenus[idx].label}`, showableMenus[idx].label, showableMenus[idx].actions || []));
484
+ }
485
+ if (this.overflowMenu.buttonElement.nextElementSibling !== showableMenus[this.numMenusShown].buttonElement) {
486
+ this.overflowMenu.buttonElement.remove();
487
+ this.container.insertBefore(this.overflowMenu.buttonElement, showableMenus[this.numMenusShown].buttonElement);
488
+ }
489
+ this.overflowMenu.buttonElement.style.visibility = 'visible';
490
+ } else {
491
+ this.overflowMenu.buttonElement.remove();
492
+ this.container.appendChild(this.overflowMenu.buttonElement);
493
+ this.overflowMenu.buttonElement.style.visibility = 'hidden';
494
+ }
495
+ // If we are only showing the overflow, add this class to avoid taking up space
496
+ this.container.classList.toggle(overflowMenuOnlyClass, this.numMenusShown === 0);
497
+ }
498
+ updateLabels(titleElement, buttonElement, label) {
499
+ const cleanMenuLabel = (0, _get__("consts_1").cleanMnemonic)(label);
500
+ // Update the button label to reflect mnemonics
501
+ if (this.options.enableMnemonics) {
502
+ const cleanLabel = _get__("strings").escape(label);
503
+ // This is global so reset it
504
+ _get__("consts_1").MENU_ESCAPED_MNEMONIC_REGEX.lastIndex = 0;
505
+ let escMatch = _get__("consts_1").MENU_ESCAPED_MNEMONIC_REGEX.exec(cleanLabel);
506
+ // We can't use negative lookbehind so we match our negative and skip
507
+ while (escMatch && escMatch[1]) {
508
+ escMatch = _get__("consts_1").MENU_ESCAPED_MNEMONIC_REGEX.exec(cleanLabel);
509
+ }
510
+ const replaceDoubleEscapes = str => str.replace(/&amp;&amp;/g, '&amp;');
511
+ if (escMatch) {
512
+ titleElement.innerText = '';
513
+ titleElement.append(_get__("strings").ltrim(replaceDoubleEscapes(cleanLabel.substr(0, escMatch.index)), ' '), _get__("$")('mnemonic', {
514
+ 'aria-hidden': 'true'
515
+ }, escMatch[3]), _get__("strings").rtrim(replaceDoubleEscapes(cleanLabel.substr(escMatch.index + escMatch[0].length)), ' '));
516
+ } else {
517
+ titleElement.innerText = replaceDoubleEscapes(cleanLabel).trim();
518
+ }
519
+ } else {
520
+ titleElement.innerText = cleanMenuLabel.replace(/&&/g, '&');
521
+ }
522
+ const mnemonicMatches = _get__("consts_1").MENU_MNEMONIC_REGEX.exec(label);
523
+ // Register mnemonics
524
+ if (mnemonicMatches) {
525
+ const mnemonic = !!mnemonicMatches[1] ? mnemonicMatches[1] : mnemonicMatches[3];
526
+ if (this.options.enableMnemonics) {
527
+ buttonElement.setAttribute('aria-keyshortcuts', 'Alt+' + mnemonic.toLocaleLowerCase());
528
+ } else {
529
+ buttonElement.removeAttribute('aria-keyshortcuts');
530
+ }
531
+ }
532
+ }
533
+ update(options) {
534
+ if (options) {
535
+ this.options = options;
536
+ }
537
+ // Don't update while using the menu
538
+ if (this.isFocused) {
539
+ this.updatePending = true;
540
+ return;
541
+ }
542
+ this.menus.forEach(menuBarMenu => {
543
+ if (!menuBarMenu.buttonElement || !menuBarMenu.titleElement) {
544
+ return;
545
+ }
546
+ this.updateLabels(menuBarMenu.titleElement, menuBarMenu.buttonElement, menuBarMenu.label);
547
+ });
548
+ if (!this.overflowLayoutScheduled) {
549
+ this.overflowLayoutScheduled = _get__("DOM").scheduleAtNextAnimationFrame(() => {
550
+ this.updateOverflowAction();
551
+ this.overflowLayoutScheduled = undefined;
552
+ });
553
+ }
554
+ this.setUnfocusedState();
555
+ }
556
+ registerMnemonic(menuIndex, mnemonic) {
557
+ this.mnemonics.set(mnemonic.toLocaleLowerCase(), menuIndex);
558
+ }
559
+ hideMenubar() {
560
+ if (this.container.style.display !== 'none') {
561
+ this.container.style.display = 'none';
562
+ this._onVisibilityChange.fire(false);
563
+ }
564
+ }
565
+ showMenubar() {
566
+ if (this.container.style.display !== 'flex') {
567
+ this.container.style.display = 'flex';
568
+ this._onVisibilityChange.fire(true);
569
+ this.updateOverflowAction();
570
+ }
571
+ }
572
+ get focusState() {
573
+ return this._focusState;
574
+ }
575
+ set focusState(value) {
576
+ if (this._focusState >= _get__("MenubarState").FOCUSED && value < _get__("MenubarState").FOCUSED) {
577
+ // Losing focus, update the menu if needed
578
+ if (this.updatePending) {
579
+ this.menuUpdater.schedule();
580
+ this.updatePending = false;
581
+ }
582
+ }
583
+ if (value === this._focusState) {
584
+ return;
585
+ }
586
+ const isVisible = this.isVisible;
587
+ const isOpen = this.isOpen;
588
+ const isFocused = this.isFocused;
589
+ this._focusState = value;
590
+ switch (value) {
591
+ case _get__("MenubarState").HIDDEN:
592
+ if (isVisible) {
593
+ this.hideMenubar();
594
+ }
595
+ if (isOpen) {
596
+ this.cleanupMenu();
597
+ }
598
+ if (isFocused) {
599
+ this.focusedMenu = undefined;
600
+ if (this.focusToReturn) {
601
+ this.focusToReturn.focus();
602
+ this.focusToReturn = undefined;
603
+ }
604
+ }
605
+ break;
606
+ case _get__("MenubarState").VISIBLE:
607
+ if (!isVisible) {
608
+ this.showMenubar();
609
+ }
610
+ if (isOpen) {
611
+ this.cleanupMenu();
612
+ }
613
+ if (isFocused) {
614
+ if (this.focusedMenu) {
615
+ if (this.focusedMenu.index === _get__("MenuBar").OVERFLOW_INDEX) {
616
+ this.overflowMenu.buttonElement.blur();
617
+ } else {
618
+ this.menus[this.focusedMenu.index].buttonElement?.blur();
619
+ }
620
+ }
621
+ this.focusedMenu = undefined;
622
+ if (this.focusToReturn) {
623
+ this.focusToReturn.focus();
624
+ this.focusToReturn = undefined;
625
+ }
626
+ }
627
+ break;
628
+ case _get__("MenubarState").FOCUSED:
629
+ if (!isVisible) {
630
+ this.showMenubar();
631
+ }
632
+ if (isOpen) {
633
+ this.cleanupMenu();
634
+ }
635
+ if (this.focusedMenu) {
636
+ if (this.focusedMenu.index === _get__("MenuBar").OVERFLOW_INDEX) {
637
+ this.overflowMenu.buttonElement.focus();
638
+ } else {
639
+ this.menus[this.focusedMenu.index].buttonElement?.focus();
640
+ }
641
+ }
642
+ break;
643
+ case _get__("MenubarState").OPEN:
644
+ if (!isVisible) {
645
+ this.showMenubar();
646
+ }
647
+ if (this.focusedMenu) {
648
+ this.showMenu(this.focusedMenu.index, this.openedViaKeyboard);
649
+ }
650
+ break;
651
+ }
652
+ this._focusState = value;
653
+ this._onFocusStateChange.fire(this.focusState >= _get__("MenubarState").FOCUSED);
654
+ }
655
+ get isVisible() {
656
+ return this.focusState >= _get__("MenubarState").VISIBLE;
657
+ }
658
+ get isFocused() {
659
+ return this.focusState >= _get__("MenubarState").FOCUSED;
660
+ }
661
+ get isOpen() {
662
+ return this.focusState >= _get__("MenubarState").OPEN;
663
+ }
664
+ get hasOverflow() {
665
+ return this.isCompact || this.numMenusShown < this.menus.length;
666
+ }
667
+ get isCompact() {
668
+ return this.options.compactMode !== undefined;
669
+ }
670
+ setUnfocusedState() {
671
+ if (this.options.visibility === 'toggle' || this.options.visibility === 'hidden') {
672
+ this.focusState = _get__("MenubarState").HIDDEN;
673
+ } else if (this.options.visibility === 'classic') {
674
+ this.focusState = _get__("MenubarState").HIDDEN;
675
+ } else {
676
+ this.focusState = _get__("MenubarState").VISIBLE;
677
+ }
678
+ this.ignoreNextMouseUp = false;
679
+ this.mnemonicsInUse = false;
680
+ this.updateMnemonicVisibility(false);
681
+ }
682
+ focusPrevious() {
683
+ if (!this.focusedMenu || this.numMenusShown === 0) {
684
+ return;
685
+ }
686
+ let newFocusedIndex = (this.focusedMenu.index - 1 + this.numMenusShown) % this.numMenusShown;
687
+ if (this.focusedMenu.index === _get__("MenuBar").OVERFLOW_INDEX) {
688
+ newFocusedIndex = this.numMenusShown - 1;
689
+ } else if (this.focusedMenu.index === 0 && this.hasOverflow) {
690
+ newFocusedIndex = _get__("MenuBar").OVERFLOW_INDEX;
691
+ }
692
+ if (newFocusedIndex === this.focusedMenu.index) {
693
+ return;
694
+ }
695
+ if (this.isOpen) {
696
+ this.cleanupMenu();
697
+ this.showMenu(newFocusedIndex);
698
+ } else if (this.isFocused) {
699
+ this.focusedMenu.index = newFocusedIndex;
700
+ if (newFocusedIndex === _get__("MenuBar").OVERFLOW_INDEX) {
701
+ this.overflowMenu.buttonElement.focus();
702
+ } else {
703
+ this.menus[newFocusedIndex].buttonElement?.focus();
704
+ }
705
+ }
706
+ }
707
+ focusNext() {
708
+ if (!this.focusedMenu || this.numMenusShown === 0) {
709
+ return;
710
+ }
711
+ let newFocusedIndex = (this.focusedMenu.index + 1) % this.numMenusShown;
712
+ if (this.focusedMenu.index === _get__("MenuBar").OVERFLOW_INDEX) {
713
+ newFocusedIndex = 0;
714
+ } else if (this.focusedMenu.index === this.numMenusShown - 1) {
715
+ newFocusedIndex = _get__("MenuBar").OVERFLOW_INDEX;
716
+ }
717
+ if (newFocusedIndex === this.focusedMenu.index) {
718
+ return;
719
+ }
720
+ if (this.isOpen) {
721
+ this.cleanupMenu();
722
+ this.showMenu(newFocusedIndex);
723
+ } else if (this.isFocused) {
724
+ this.focusedMenu.index = newFocusedIndex;
725
+ if (newFocusedIndex === _get__("MenuBar").OVERFLOW_INDEX) {
726
+ this.overflowMenu.buttonElement.focus();
727
+ } else {
728
+ this.menus[newFocusedIndex].buttonElement?.focus();
729
+ }
730
+ }
731
+ }
732
+ updateMnemonicVisibility(visible) {
733
+ console.log({
734
+ visible
735
+ });
736
+ if (this.menus) {
737
+ this.menus.forEach(menuBarMenu => {
738
+ if (menuBarMenu.titleElement && menuBarMenu.titleElement.children.length) {
739
+ const child = menuBarMenu.titleElement.children.item(0);
740
+ if (child) {
741
+ child.style.textDecoration = this.options.alwaysOnMnemonics || visible ? 'underline' : '';
742
+ }
743
+ }
744
+ });
745
+ }
746
+ }
747
+ get mnemonicsInUse() {
748
+ return this._mnemonicsInUse;
749
+ }
750
+ set mnemonicsInUse(value) {
751
+ this._mnemonicsInUse = value;
752
+ }
753
+ get shouldAltKeyFocus() {
754
+ if (_get__("platform_1").isMacintosh) {
755
+ return false;
756
+ }
757
+ if (!this.options.disableAltFocus) {
758
+ return true;
759
+ }
760
+ if (this.options.visibility === 'toggle') {
761
+ return true;
762
+ }
763
+ return false;
764
+ }
765
+ get onVisibilityChange() {
766
+ return this._onVisibilityChange.event;
767
+ }
768
+ get onFocusStateChange() {
769
+ return this._onFocusStateChange.event;
770
+ }
771
+ onMenuTriggered(menuIndex, clicked) {
772
+ if (this.isOpen) {
773
+ if (this.isCurrentMenu(menuIndex)) {
774
+ this.setUnfocusedState();
775
+ } else {
776
+ this.cleanupMenu();
777
+ this.showMenu(menuIndex, this.openedViaKeyboard);
778
+ }
779
+ } else {
780
+ this.focusedMenu = {
781
+ index: menuIndex
782
+ };
783
+ this.openedViaKeyboard = !clicked;
784
+ this.focusState = _get__("MenubarState").OPEN;
785
+ }
786
+ }
787
+ onModifierKeyToggled(modifierKeyStatus) {
788
+ const allModifiersReleased = !modifierKeyStatus.altKey && !modifierKeyStatus.ctrlKey && !modifierKeyStatus.shiftKey && !modifierKeyStatus.metaKey;
789
+ if (this.options.visibility === 'hidden') {
790
+ return;
791
+ }
792
+ // Prevent alt-key default if the menu is not hidden and we use alt to focus
793
+ if (modifierKeyStatus.event && this.shouldAltKeyFocus) {
794
+ if (_get__("keyCodes_1").ScanCodeUtils.toEnum(modifierKeyStatus.event.code) === 159 /* ScanCode.AltLeft */) {
795
+ modifierKeyStatus.event.preventDefault();
796
+ }
797
+ }
798
+ // Alt key pressed while menu is focused. This should return focus away from the menubar
799
+ if (this.isFocused && modifierKeyStatus.lastKeyPressed === 'alt' && modifierKeyStatus.altKey) {
800
+ this.setUnfocusedState();
801
+ this.mnemonicsInUse = false;
802
+ this.awaitingAltRelease = true;
803
+ }
804
+ // Clean alt key press and release
805
+ if (allModifiersReleased && modifierKeyStatus.lastKeyPressed === 'alt' && modifierKeyStatus.lastKeyReleased === 'alt') {
806
+ if (!this.awaitingAltRelease) {
807
+ if (!this.isFocused && this.shouldAltKeyFocus) {
808
+ this.mnemonicsInUse = true;
809
+ this.focusedMenu = {
810
+ index: this.numMenusShown > 0 ? 0 : _get__("MenuBar").OVERFLOW_INDEX
811
+ };
812
+ this.focusState = _get__("MenubarState").FOCUSED;
813
+ } else if (!this.isOpen) {
814
+ this.setUnfocusedState();
815
+ }
816
+ }
817
+ }
818
+ // Alt key released
819
+ if (!modifierKeyStatus.altKey && modifierKeyStatus.lastKeyReleased === 'alt') {
820
+ this.awaitingAltRelease = false;
821
+ }
822
+ if (this.options.enableMnemonics && this.menus && !this.isOpen) {
823
+ this.updateMnemonicVisibility(!this.awaitingAltRelease && modifierKeyStatus.altKey || this.mnemonicsInUse);
824
+ }
825
+ }
826
+ isCurrentMenu(menuIndex) {
827
+ if (!this.focusedMenu) {
828
+ return false;
829
+ }
830
+ return this.focusedMenu.index === menuIndex;
831
+ }
832
+ cleanupMenu() {
833
+ if (this.focusedMenu) {
834
+ // Remove focus from the menus first
835
+ if (this.focusedMenu.index === _get__("MenuBar").OVERFLOW_INDEX) {
836
+ this.overflowMenu.buttonElement.focus();
837
+ } else {
838
+ this.menus[this.focusedMenu.index].buttonElement?.focus();
839
+ }
840
+ if (this.focusedMenu.holder) {
841
+ this.focusedMenu.holder.parentElement?.classList.remove('open');
842
+ this.focusedMenu.holder.remove();
843
+ }
844
+ this.focusedMenu.widget?.dispose();
845
+ this.focusedMenu = {
846
+ index: this.focusedMenu.index
847
+ };
848
+ }
849
+ }
850
+ showMenu(menuIndex, selectFirst = true) {
851
+ const actualMenuIndex = menuIndex >= this.numMenusShown ? _get__("MenuBar").OVERFLOW_INDEX : menuIndex;
852
+ const customMenu = actualMenuIndex === _get__("MenuBar").OVERFLOW_INDEX ? this.overflowMenu : this.menus[actualMenuIndex];
853
+ if (!customMenu.actions || !customMenu.buttonElement || !customMenu.titleElement) {
854
+ return;
855
+ }
856
+ const menuHolder = _get__("$")('.cet-menubar-menu-container', {
857
+ title: ''
858
+ });
859
+ customMenu.buttonElement.classList.add('open');
860
+ const titleBoundingRect = customMenu.titleElement.getBoundingClientRect();
861
+ const titleBoundingRectZoom = _get__("DOM").getDomNodeZoomLevel(customMenu.titleElement);
862
+ if (this.options.compactMode === _get__("menu_1").Direction.Right) {
863
+ menuHolder.style.top = `${titleBoundingRect.top}px`;
864
+ menuHolder.style.left = `${titleBoundingRect.left + this.container.clientWidth}px`;
865
+ } else if (this.options.compactMode === _get__("menu_1").Direction.Left) {
866
+ menuHolder.style.top = `${titleBoundingRect.top}px`;
867
+ menuHolder.style.right = `${this.container.clientWidth}px`;
868
+ menuHolder.style.left = 'auto';
869
+ } else {
870
+ menuHolder.style.top = `${titleBoundingRect.bottom * titleBoundingRectZoom}px`;
871
+ menuHolder.style.left = `${titleBoundingRect.left * titleBoundingRectZoom}px`;
872
+ }
873
+ customMenu.buttonElement.appendChild(menuHolder);
874
+ const menuOptions = {
875
+ // getKeyBinding: this.options.getKeybinding,
876
+ // actionRunner: this.actionRunner,
877
+ enableMnemonics: this.options.alwaysOnMnemonics || this.mnemonicsInUse && this.options.enableMnemonics,
878
+ ariaLabel: customMenu.buttonElement.getAttribute('aria-label') ?? undefined
879
+ // expandDirection: this.isCompact ? this.options.compactMode : Direction.Right,
880
+ // useEventAsContext: true
881
+ };
882
+
883
+ const menuWidget = this._register(new (_get__("menu_1").CETMenu)(menuHolder, this.menuIcons, this.currentOptions, menuOptions, this.closeMenu));
884
+ menuWidget.createMenu(customMenu.actions?.items ?? []);
885
+ menuWidget.applyStyle(this.menuStyle);
886
+ this._register(menuWidget.onDidCancel(() => {
887
+ this.focusState = _get__("MenubarState").FOCUSED;
888
+ }));
889
+ if (actualMenuIndex !== menuIndex) {
890
+ menuWidget.trigger(menuIndex - this.numMenusShown);
891
+ } else {
892
+ menuWidget.focus(selectFirst);
893
+ }
894
+ this.focusedMenu = {
895
+ index: actualMenuIndex,
896
+ holder: menuHolder,
897
+ widget: menuWidget
898
+ };
899
+ }
900
+ }
901
+ _get__("MenuBar").OVERFLOW_INDEX = -1;
902
+ exports.MenuBar = _get__("MenuBar");
903
+ function _getGlobalObject() {
904
+ try {
905
+ if (!!global) {
906
+ return global;
907
+ }
908
+ } catch (e) {
909
+ try {
910
+ if (!!window) {
911
+ return window;
912
+ }
913
+ } catch (e) {
914
+ return this;
915
+ }
916
+ }
917
+ }
918
+ ;
919
+ var _RewireModuleId__ = null;
920
+ function _getRewireModuleId__() {
921
+ if (_RewireModuleId__ === null) {
922
+ let globalVariable = _getGlobalObject();
923
+ if (!globalVariable.__$$GLOBAL_REWIRE_NEXT_MODULE_ID__) {
924
+ globalVariable.__$$GLOBAL_REWIRE_NEXT_MODULE_ID__ = 0;
925
+ }
926
+ _RewireModuleId__ = __$$GLOBAL_REWIRE_NEXT_MODULE_ID__++;
927
+ }
928
+ return _RewireModuleId__;
929
+ }
930
+ function _getRewireRegistry__() {
931
+ let theGlobalVariable = _getGlobalObject();
932
+ if (!theGlobalVariable.__$$GLOBAL_REWIRE_REGISTRY__) {
933
+ theGlobalVariable.__$$GLOBAL_REWIRE_REGISTRY__ = Object.create(null);
934
+ }
935
+ return theGlobalVariable.__$$GLOBAL_REWIRE_REGISTRY__;
936
+ }
937
+ function _getRewiredData__() {
938
+ let moduleId = _getRewireModuleId__();
939
+ let registry = _getRewireRegistry__();
940
+ let rewireData = registry[moduleId];
941
+ if (!rewireData) {
942
+ registry[moduleId] = Object.create(null);
943
+ rewireData = registry[moduleId];
944
+ }
945
+ return rewireData;
946
+ }
947
+ (function registerResetAll() {
948
+ let theGlobalVariable = _getGlobalObject();
949
+ if (!theGlobalVariable['__rewire_reset_all__']) {
950
+ theGlobalVariable['__rewire_reset_all__'] = function () {
951
+ theGlobalVariable.__$$GLOBAL_REWIRE_REGISTRY__ = Object.create(null);
952
+ };
953
+ }
954
+ })();
955
+ var INTENTIONAL_UNDEFINED = '__INTENTIONAL_UNDEFINED__';
956
+ let _RewireAPI__ = {};
957
+ (function () {
958
+ function addPropertyToAPIObject(name, value) {
959
+ Object.defineProperty(_RewireAPI__, name, {
960
+ value: value,
961
+ enumerable: false,
962
+ configurable: true
963
+ });
964
+ }
965
+ addPropertyToAPIObject('__get__', _get__);
966
+ addPropertyToAPIObject('__GetDependency__', _get__);
967
+ addPropertyToAPIObject('__Rewire__', _set__);
968
+ addPropertyToAPIObject('__set__', _set__);
969
+ addPropertyToAPIObject('__reset__', _reset__);
970
+ addPropertyToAPIObject('__ResetDependency__', _reset__);
971
+ addPropertyToAPIObject('__with__', _with__);
972
+ })();
973
+ function _get__(variableName) {
974
+ let rewireData = _getRewiredData__();
975
+ if (rewireData[variableName] === undefined) {
976
+ return _get_original__(variableName);
977
+ } else {
978
+ var value = rewireData[variableName];
979
+ if (value === INTENTIONAL_UNDEFINED) {
980
+ return undefined;
981
+ } else {
982
+ return value;
983
+ }
984
+ }
985
+ }
986
+ function _get_original__(variableName) {
987
+ switch (variableName) {
988
+ case "__createBinding":
989
+ return __createBinding;
990
+ case "__setModuleDefault":
991
+ return __setModuleDefault;
992
+ case "__importStar":
993
+ return __importStar;
994
+ case "DOM":
995
+ return DOM;
996
+ case "MenubarState":
997
+ return MenubarState;
998
+ case "event_1":
999
+ return event_1;
1000
+ case "async_1":
1001
+ return async_1;
1002
+ case "platform_1":
1003
+ return platform_1;
1004
+ case "keyboardEvent_1":
1005
+ return keyboardEvent_1;
1006
+ case "consts_1":
1007
+ return consts_1;
1008
+ case "$":
1009
+ return $;
1010
+ case "touch_1":
1011
+ return touch_1;
1012
+ case "mouseEvent_1":
1013
+ return mouseEvent_1;
1014
+ case "menu_1":
1015
+ return menu_1;
1016
+ case "MenuBar":
1017
+ return MenuBar;
1018
+ case "lifecycle_1":
1019
+ return lifecycle_1;
1020
+ case "strings":
1021
+ return strings;
1022
+ case "keyCodes_1":
1023
+ return keyCodes_1;
1024
+ }
1025
+ return undefined;
1026
+ }
1027
+ function _assign__(variableName, value) {
1028
+ let rewireData = _getRewiredData__();
1029
+ if (rewireData[variableName] === undefined) {
1030
+ return _set_original__(variableName, value);
1031
+ } else {
1032
+ return rewireData[variableName] = value;
1033
+ }
1034
+ }
1035
+ function _set_original__(variableName, _value) {
1036
+ switch (variableName) {
1037
+ case "MenubarState":
1038
+ return MenubarState = _value;
1039
+ }
1040
+ return undefined;
1041
+ }
1042
+ function _update_operation__(operation, variableName, prefix) {
1043
+ var oldValue = _get__(variableName);
1044
+ var newValue = operation === '++' ? oldValue + 1 : oldValue - 1;
1045
+ _assign__(variableName, newValue);
1046
+ return prefix ? newValue : oldValue;
1047
+ }
1048
+ function _set__(variableName, value) {
1049
+ let rewireData = _getRewiredData__();
1050
+ if (typeof variableName === 'object') {
1051
+ Object.keys(variableName).forEach(function (name) {
1052
+ rewireData[name] = variableName[name];
1053
+ });
1054
+ return function () {
1055
+ Object.keys(variableName).forEach(function (name) {
1056
+ _reset__(variableName);
1057
+ });
1058
+ };
1059
+ } else {
1060
+ if (value === undefined) {
1061
+ rewireData[variableName] = INTENTIONAL_UNDEFINED;
1062
+ } else {
1063
+ rewireData[variableName] = value;
1064
+ }
1065
+ return function () {
1066
+ _reset__(variableName);
1067
+ };
1068
+ }
1069
+ }
1070
+ function _reset__(variableName) {
1071
+ let rewireData = _getRewiredData__();
1072
+ delete rewireData[variableName];
1073
+ if (Object.keys(rewireData).length == 0) {
1074
+ delete _getRewireRegistry__()[_getRewireModuleId__];
1075
+ }
1076
+ ;
1077
+ }
1078
+ function _with__(object) {
1079
+ let rewireData = _getRewiredData__();
1080
+ var rewiredVariableNames = Object.keys(object);
1081
+ var previousValues = {};
1082
+ function reset() {
1083
+ rewiredVariableNames.forEach(function (variableName) {
1084
+ rewireData[variableName] = previousValues[variableName];
1085
+ });
1086
+ }
1087
+ return function (callback) {
1088
+ rewiredVariableNames.forEach(function (variableName) {
1089
+ previousValues[variableName] = rewireData[variableName];
1090
+ rewireData[variableName] = object[variableName];
1091
+ });
1092
+ let result = callback();
1093
+ if (!!result && typeof result.then == 'function') {
1094
+ result.then(reset).catch(reset);
1095
+ } else {
1096
+ reset();
1097
+ }
1098
+ return result;
1099
+ };
1100
+ }
1101
+ let _typeOfOriginalExport = typeof module.exports;
1102
+ function addNonEnumerableProperty(name, value) {
1103
+ Object.defineProperty(module.exports, name, {
1104
+ value: value,
1105
+ enumerable: false,
1106
+ configurable: true
1107
+ });
1108
+ }
1109
+ if ((_typeOfOriginalExport === 'object' || _typeOfOriginalExport === 'function') && Object.isExtensible(module.exports)) {
1110
+ addNonEnumerableProperty('__get__', _get__);
1111
+ addNonEnumerableProperty('__GetDependency__', _get__);
1112
+ addNonEnumerableProperty('__Rewire__', _set__);
1113
+ addNonEnumerableProperty('__set__', _set__);
1114
+ addNonEnumerableProperty('__reset__', _reset__);
1115
+ addNonEnumerableProperty('__ResetDependency__', _reset__);
1116
+ addNonEnumerableProperty('__with__', _with__);
1117
+ addNonEnumerableProperty('__RewireAPI__', _RewireAPI__);
1118
+ }