custom-electron-titlebar 3.2.5 → 3.2.9

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 (175) hide show
  1. package/.vscode/launch.json +49 -0
  2. package/.vscode/tasks.json +34 -0
  3. package/README.md +15 -24
  4. package/_config.yml +1 -0
  5. package/{lib → build}/browser/browser.d.ts +0 -0
  6. package/{lib → build}/browser/browser.js +1 -0
  7. package/build/browser/browser.js.map +1 -0
  8. package/{lib → build}/browser/event.d.ts +0 -0
  9. package/{lib → build}/browser/event.js +3 -1
  10. package/build/browser/event.js.map +1 -0
  11. package/{lib → build}/browser/iframe.d.ts +0 -0
  12. package/{lib/base → build}/browser/iframe.js +1 -0
  13. package/build/browser/iframe.js.map +1 -0
  14. package/{lib → build}/browser/keyboardEvent.d.ts +0 -0
  15. package/{lib → build}/browser/keyboardEvent.js +1 -0
  16. package/build/browser/keyboardEvent.js.map +1 -0
  17. package/{lib → build}/browser/mouseEvent.d.ts +0 -0
  18. package/{lib → build}/browser/mouseEvent.js +1 -0
  19. package/build/browser/mouseEvent.js.map +1 -0
  20. package/{lib → build}/common/arrays.d.ts +0 -0
  21. package/{lib → build}/common/arrays.js +1 -0
  22. package/build/common/arrays.js.map +1 -0
  23. package/{lib → build}/common/async.d.ts +0 -0
  24. package/{lib → build}/common/async.js +1 -0
  25. package/build/common/async.js.map +1 -0
  26. package/{lib → build}/common/charCode.d.ts +0 -0
  27. package/{lib/base → build}/common/charCode.js +1 -0
  28. package/build/common/charCode.js.map +1 -0
  29. package/{lib → build}/common/color.d.ts +0 -0
  30. package/{lib → build}/common/color.js +1 -0
  31. package/build/common/color.js.map +1 -0
  32. package/{lib → build}/common/dom.d.ts +0 -0
  33. package/{lib → build}/common/dom.js +17 -14
  34. package/build/common/dom.js.map +1 -0
  35. package/{lib → build}/common/event.d.ts +0 -0
  36. package/{lib → build}/common/event.js +2 -1
  37. package/build/common/event.js.map +1 -0
  38. package/{lib → build}/common/iterator.d.ts +0 -0
  39. package/{lib → build}/common/iterator.js +1 -0
  40. package/build/common/iterator.js.map +1 -0
  41. package/{lib → build}/common/keyCodes.d.ts +0 -0
  42. package/{lib → build}/common/keyCodes.js +1 -0
  43. package/build/common/keyCodes.js.map +1 -0
  44. package/{lib → build}/common/lifecycle.d.ts +0 -0
  45. package/{lib → build}/common/lifecycle.js +1 -0
  46. package/build/common/lifecycle.js.map +1 -0
  47. package/{lib → build}/common/linkedList.d.ts +0 -0
  48. package/{lib → build}/common/linkedList.js +1 -0
  49. package/build/common/linkedList.js.map +1 -0
  50. package/{lib → build}/common/platform.d.ts +0 -0
  51. package/{lib → build}/common/platform.js +1 -0
  52. package/build/common/platform.js.map +1 -0
  53. package/{lib → build}/index.d.ts +0 -0
  54. package/{lib → build}/index.js +1 -0
  55. package/build/index.js.map +1 -0
  56. package/{lib → build}/menu/menu.d.ts +0 -0
  57. package/{lib → build}/menu/menu.js +39 -38
  58. package/build/menu/menu.js.map +1 -0
  59. package/{lib → build}/menu/menuitem.d.ts +10 -2
  60. package/{lib → build}/menu/menuitem.js +71 -29
  61. package/build/menu/menuitem.js.map +1 -0
  62. package/{lib → build}/menubar.d.ts +0 -0
  63. package/{lib → build}/menubar.js +38 -34
  64. package/build/menubar.js.map +1 -0
  65. package/{lib → build}/themebar.d.ts +0 -0
  66. package/{lib → build}/themebar.js +31 -2
  67. package/build/themebar.js.map +1 -0
  68. package/{lib → build}/titlebar.d.ts +0 -0
  69. package/{lib → build}/titlebar.js +72 -59
  70. package/build/titlebar.js.map +1 -0
  71. package/package.json +13 -7
  72. package/lib/base/browser/browser.d.ts +0 -25
  73. package/lib/base/browser/browser.js +0 -117
  74. package/lib/base/browser/canIUse.d.ts +0 -18
  75. package/lib/base/browser/canIUse.js +0 -63
  76. package/lib/base/browser/dom.d.ts +0 -230
  77. package/lib/base/browser/dom.js +0 -1080
  78. package/lib/base/browser/event.d.ts +0 -12
  79. package/lib/base/browser/event.js +0 -28
  80. package/lib/base/browser/iframe.d.ts +0 -33
  81. package/lib/base/browser/keyboardEvent.d.ts +0 -40
  82. package/lib/base/browser/keyboardEvent.js +0 -256
  83. package/lib/base/browser/mouseEvent.d.ts +0 -69
  84. package/lib/base/browser/mouseEvent.js +0 -146
  85. package/lib/base/common/arrays.d.ts +0 -149
  86. package/lib/base/common/arrays.js +0 -549
  87. package/lib/base/common/async.d.ts +0 -259
  88. package/lib/base/common/async.js +0 -728
  89. package/lib/base/common/cancellation.d.ts +0 -29
  90. package/lib/base/common/cancellation.js +0 -114
  91. package/lib/base/common/charCode.d.ts +0 -415
  92. package/lib/base/common/color.d.ts +0 -163
  93. package/lib/base/common/color.js +0 -495
  94. package/lib/base/common/errors.d.ts +0 -65
  95. package/lib/base/common/errors.js +0 -164
  96. package/lib/base/common/event.d.ts +0 -248
  97. package/lib/base/common/event.js +0 -703
  98. package/lib/base/common/functional.d.ts +0 -1
  99. package/lib/base/common/functional.js +0 -21
  100. package/lib/base/common/iterator.d.ts +0 -16
  101. package/lib/base/common/iterator.js +0 -82
  102. package/lib/base/common/keyCodes.d.ts +0 -268
  103. package/lib/base/common/keyCodes.js +0 -292
  104. package/lib/base/common/lifecycle.d.ts +0 -67
  105. package/lib/base/common/lifecycle.js +0 -234
  106. package/lib/base/common/linkedList.d.ts +0 -16
  107. package/lib/base/common/linkedList.js +0 -128
  108. package/lib/base/common/network.d.ts +0 -65
  109. package/lib/base/common/network.js +0 -124
  110. package/lib/base/common/path.d.ts +0 -39
  111. package/lib/base/common/path.js +0 -1407
  112. package/lib/base/common/platform.d.ts +0 -53
  113. package/lib/base/common/platform.js +0 -176
  114. package/lib/base/common/process.d.ts +0 -5
  115. package/lib/base/common/process.js +0 -18
  116. package/lib/base/common/sequence.d.ts +0 -27
  117. package/lib/base/common/sequence.js +0 -32
  118. package/lib/base/common/uri.d.ts +0 -153
  119. package/lib/base/common/uri.js +0 -612
  120. package/lib/browser/iframe.js +0 -109
  121. package/lib/common/charCode.js +0 -6
  122. package/lib/menu.d.ts +0 -53
  123. package/lib/menu.js +0 -532
  124. package/lib/menuitem.d.ts +0 -46
  125. package/lib/menuitem.js +0 -295
  126. package/lib/vs/base/browser/browser.d.ts +0 -25
  127. package/lib/vs/base/browser/browser.js +0 -117
  128. package/lib/vs/base/browser/canIUse.d.ts +0 -18
  129. package/lib/vs/base/browser/canIUse.js +0 -63
  130. package/lib/vs/base/browser/dom.d.ts +0 -230
  131. package/lib/vs/base/browser/dom.js +0 -1080
  132. package/lib/vs/base/browser/event.d.ts +0 -12
  133. package/lib/vs/base/browser/event.js +0 -28
  134. package/lib/vs/base/browser/iframe.d.ts +0 -33
  135. package/lib/vs/base/browser/iframe.js +0 -109
  136. package/lib/vs/base/browser/keyboardEvent.d.ts +0 -40
  137. package/lib/vs/base/browser/keyboardEvent.js +0 -256
  138. package/lib/vs/base/browser/mouseEvent.d.ts +0 -69
  139. package/lib/vs/base/browser/mouseEvent.js +0 -146
  140. package/lib/vs/base/common/arrays.d.ts +0 -149
  141. package/lib/vs/base/common/arrays.js +0 -549
  142. package/lib/vs/base/common/async.d.ts +0 -259
  143. package/lib/vs/base/common/async.js +0 -728
  144. package/lib/vs/base/common/cancellation.d.ts +0 -29
  145. package/lib/vs/base/common/cancellation.js +0 -114
  146. package/lib/vs/base/common/charCode.d.ts +0 -415
  147. package/lib/vs/base/common/charCode.js +0 -6
  148. package/lib/vs/base/common/color.d.ts +0 -163
  149. package/lib/vs/base/common/color.js +0 -495
  150. package/lib/vs/base/common/errors.d.ts +0 -65
  151. package/lib/vs/base/common/errors.js +0 -164
  152. package/lib/vs/base/common/event.d.ts +0 -248
  153. package/lib/vs/base/common/event.js +0 -703
  154. package/lib/vs/base/common/functional.d.ts +0 -1
  155. package/lib/vs/base/common/functional.js +0 -21
  156. package/lib/vs/base/common/iterator.d.ts +0 -16
  157. package/lib/vs/base/common/iterator.js +0 -82
  158. package/lib/vs/base/common/keyCodes.d.ts +0 -268
  159. package/lib/vs/base/common/keyCodes.js +0 -292
  160. package/lib/vs/base/common/lifecycle.d.ts +0 -67
  161. package/lib/vs/base/common/lifecycle.js +0 -234
  162. package/lib/vs/base/common/linkedList.d.ts +0 -16
  163. package/lib/vs/base/common/linkedList.js +0 -128
  164. package/lib/vs/base/common/network.d.ts +0 -65
  165. package/lib/vs/base/common/network.js +0 -124
  166. package/lib/vs/base/common/path.d.ts +0 -39
  167. package/lib/vs/base/common/path.js +0 -1407
  168. package/lib/vs/base/common/platform.d.ts +0 -53
  169. package/lib/vs/base/common/platform.js +0 -176
  170. package/lib/vs/base/common/process.d.ts +0 -5
  171. package/lib/vs/base/common/process.js +0 -18
  172. package/lib/vs/base/common/sequence.d.ts +0 -27
  173. package/lib/vs/base/common/sequence.js +0 -32
  174. package/lib/vs/base/common/uri.d.ts +0 -153
  175. package/lib/vs/base/common/uri.js +0 -612
@@ -1,1080 +0,0 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Microsoft Corporation. All rights reserved.
4
- * Licensed under the MIT License. See License.txt in the project root for license information.
5
- *--------------------------------------------------------------------------------------------*/
6
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
- if (k2 === undefined) k2 = k;
8
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.triggerDownload = exports.asCSSUrl = exports.asDomUri = exports.animate = exports.windowOpenNoOpener = exports.computeScreenAwareSize = exports.domContentLoaded = exports.finalHandler = exports.getElementsByTagName = exports.removeTabIndexAndUpdateFocus = exports.hide = exports.show = exports.join = exports.$ = exports.Namespace = exports.prepend = exports.append = exports.trackFocus = exports.restoreParentsScrollTop = exports.saveParentsScrollTop = exports.EventHelper = exports.EventType = exports.isHTMLElement = exports.removeCSSRulesContainingSelector = exports.createCSSRule = exports.createMetaElement = exports.createStyleSheet = exports.getActiveElement = exports.getShadowRoot = exports.isInShadowDOM = exports.isShadowRoot = exports.hasParentWithClass = exports.findParentWithClass = exports.isAncestor = exports.getLargestChildWidth = exports.getTotalHeight = exports.getContentHeight = exports.getTotalScrollWidth = exports.getContentWidth = exports.getTotalWidth = exports.StandardWindow = exports.getDomNodePagePosition = exports.position = exports.size = exports.getTopLeftOffset = exports.Dimension = exports.getClientArea = exports.getComputedStyle = exports.addDisposableThrottledListener = exports.modify = exports.measure = exports.scheduleAtNextAnimationFrame = exports.runAtThisOrScheduleAtNextAnimationFrame = exports.addDisposableNonBubblingPointerOutListener = exports.addDisposableNonBubblingMouseOutListener = exports.addDisposableGenericMouseUpListner = exports.addDisposableGenericMouseMoveListner = exports.addDisposableGenericMouseDownListner = exports.addStandardDisposableGenericMouseUpListner = exports.addStandardDisposableGenericMouseDownListner = exports.addStandardDisposableListener = exports.addDisposableListener = exports.toggleClass = exports.removeClasses = exports.removeClass = exports.addClasses = exports.addClass = exports.hasClass = exports.isInDOM = exports.removeNode = exports.clearNode = void 0;
27
- const browser = __importStar(require("./browser"));
28
- const event_1 = require("./event");
29
- const keyboardEvent_1 = require("./keyboardEvent");
30
- const mouseEvent_1 = require("./mouseEvent");
31
- const async_1 = require("../common/async");
32
- const errors_1 = require("../common/errors");
33
- const event_2 = require("../common/event");
34
- const lifecycle_1 = require("../common/lifecycle");
35
- const platform = __importStar(require("../common/platform"));
36
- const arrays_1 = require("../common/arrays");
37
- const uri_1 = require("../common/uri");
38
- const network_1 = require("../common/network");
39
- const canIUse_1 = require("./canIUse");
40
- function clearNode(node) {
41
- while (node.firstChild) {
42
- node.removeChild(node.firstChild);
43
- }
44
- }
45
- exports.clearNode = clearNode;
46
- /**
47
- * @deprecated use `node.remove()` instead
48
- */
49
- function removeNode(node) {
50
- if (node.parentNode) {
51
- node.parentNode.removeChild(node);
52
- }
53
- }
54
- exports.removeNode = removeNode;
55
- function isInDOM(node) {
56
- while (node) {
57
- if (node === document.body) {
58
- return true;
59
- }
60
- node = node.parentNode || node.host;
61
- }
62
- return false;
63
- }
64
- exports.isInDOM = isInDOM;
65
- const _classList = new class {
66
- hasClass(node, className) {
67
- return Boolean(className) && node.classList && node.classList.contains(className);
68
- }
69
- addClasses(node, ...classNames) {
70
- classNames.forEach(nameValue => nameValue.split(' ').forEach(name => this.addClass(node, name)));
71
- }
72
- addClass(node, className) {
73
- if (className && node.classList) {
74
- node.classList.add(className);
75
- }
76
- }
77
- removeClass(node, className) {
78
- if (className && node.classList) {
79
- node.classList.remove(className);
80
- }
81
- }
82
- removeClasses(node, ...classNames) {
83
- classNames.forEach(nameValue => nameValue.split(' ').forEach(name => this.removeClass(node, name)));
84
- }
85
- toggleClass(node, className, shouldHaveIt) {
86
- if (node.classList) {
87
- node.classList.toggle(className, shouldHaveIt);
88
- }
89
- }
90
- };
91
- /** @deprecated ES6 - use classList*/
92
- exports.hasClass = _classList.hasClass.bind(_classList);
93
- /** @deprecated ES6 - use classList*/
94
- exports.addClass = _classList.addClass.bind(_classList);
95
- /** @deprecated ES6 - use classList*/
96
- exports.addClasses = _classList.addClasses.bind(_classList);
97
- /** @deprecated ES6 - use classList*/
98
- exports.removeClass = _classList.removeClass.bind(_classList);
99
- /** @deprecated ES6 - use classList*/
100
- exports.removeClasses = _classList.removeClasses.bind(_classList);
101
- /** @deprecated ES6 - use classList*/
102
- exports.toggleClass = _classList.toggleClass.bind(_classList);
103
- class DomListener {
104
- constructor(node, type, handler, options) {
105
- this._node = node;
106
- this._type = type;
107
- this._handler = handler;
108
- this._options = (options || false);
109
- this._node.addEventListener(this._type, this._handler, this._options);
110
- }
111
- dispose() {
112
- if (!this._handler) {
113
- // Already disposed
114
- return;
115
- }
116
- this._node.removeEventListener(this._type, this._handler, this._options);
117
- // Prevent leakers from holding on to the dom or handler func
118
- this._node = null;
119
- this._handler = null;
120
- }
121
- }
122
- function addDisposableListener(node, type, handler, useCaptureOrOptions) {
123
- return new DomListener(node, type, handler, useCaptureOrOptions);
124
- }
125
- exports.addDisposableListener = addDisposableListener;
126
- function _wrapAsStandardMouseEvent(handler) {
127
- return function (e) {
128
- return handler(new mouseEvent_1.StandardMouseEvent(e));
129
- };
130
- }
131
- function _wrapAsStandardKeyboardEvent(handler) {
132
- return function (e) {
133
- return handler(new keyboardEvent_1.StandardKeyboardEvent(e));
134
- };
135
- }
136
- exports.addStandardDisposableListener = function addStandardDisposableListener(node, type, handler, useCapture) {
137
- let wrapHandler = handler;
138
- if (type === 'click' || type === 'mousedown') {
139
- wrapHandler = _wrapAsStandardMouseEvent(handler);
140
- }
141
- else if (type === 'keydown' || type === 'keypress' || type === 'keyup') {
142
- wrapHandler = _wrapAsStandardKeyboardEvent(handler);
143
- }
144
- return addDisposableListener(node, type, wrapHandler, useCapture);
145
- };
146
- exports.addStandardDisposableGenericMouseDownListner = function addStandardDisposableListener(node, handler, useCapture) {
147
- let wrapHandler = _wrapAsStandardMouseEvent(handler);
148
- return addDisposableGenericMouseDownListner(node, wrapHandler, useCapture);
149
- };
150
- exports.addStandardDisposableGenericMouseUpListner = function addStandardDisposableListener(node, handler, useCapture) {
151
- let wrapHandler = _wrapAsStandardMouseEvent(handler);
152
- return addDisposableGenericMouseUpListner(node, wrapHandler, useCapture);
153
- };
154
- function addDisposableGenericMouseDownListner(node, handler, useCapture) {
155
- return addDisposableListener(node, platform.isIOS && canIUse_1.BrowserFeatures.pointerEvents ? exports.EventType.POINTER_DOWN : exports.EventType.MOUSE_DOWN, handler, useCapture);
156
- }
157
- exports.addDisposableGenericMouseDownListner = addDisposableGenericMouseDownListner;
158
- function addDisposableGenericMouseMoveListner(node, handler, useCapture) {
159
- return addDisposableListener(node, platform.isIOS && canIUse_1.BrowserFeatures.pointerEvents ? exports.EventType.POINTER_MOVE : exports.EventType.MOUSE_MOVE, handler, useCapture);
160
- }
161
- exports.addDisposableGenericMouseMoveListner = addDisposableGenericMouseMoveListner;
162
- function addDisposableGenericMouseUpListner(node, handler, useCapture) {
163
- return addDisposableListener(node, platform.isIOS && canIUse_1.BrowserFeatures.pointerEvents ? exports.EventType.POINTER_UP : exports.EventType.MOUSE_UP, handler, useCapture);
164
- }
165
- exports.addDisposableGenericMouseUpListner = addDisposableGenericMouseUpListner;
166
- function addDisposableNonBubblingMouseOutListener(node, handler) {
167
- return addDisposableListener(node, 'mouseout', (e) => {
168
- // Mouse out bubbles, so this is an attempt to ignore faux mouse outs coming from children elements
169
- let toElement = (e.relatedTarget);
170
- while (toElement && toElement !== node) {
171
- toElement = toElement.parentNode;
172
- }
173
- if (toElement === node) {
174
- return;
175
- }
176
- handler(e);
177
- });
178
- }
179
- exports.addDisposableNonBubblingMouseOutListener = addDisposableNonBubblingMouseOutListener;
180
- function addDisposableNonBubblingPointerOutListener(node, handler) {
181
- return addDisposableListener(node, 'pointerout', (e) => {
182
- // Mouse out bubbles, so this is an attempt to ignore faux mouse outs coming from children elements
183
- let toElement = (e.relatedTarget);
184
- while (toElement && toElement !== node) {
185
- toElement = toElement.parentNode;
186
- }
187
- if (toElement === node) {
188
- return;
189
- }
190
- handler(e);
191
- });
192
- }
193
- exports.addDisposableNonBubblingPointerOutListener = addDisposableNonBubblingPointerOutListener;
194
- let _animationFrame = null;
195
- function doRequestAnimationFrame(callback) {
196
- if (!_animationFrame) {
197
- const emulatedRequestAnimationFrame = (callback) => {
198
- return setTimeout(() => callback(new Date().getTime()), 0);
199
- };
200
- _animationFrame = (self.requestAnimationFrame
201
- || self.msRequestAnimationFrame
202
- || self.webkitRequestAnimationFrame
203
- || self.mozRequestAnimationFrame
204
- || self.oRequestAnimationFrame
205
- || emulatedRequestAnimationFrame);
206
- }
207
- return _animationFrame.call(self, callback);
208
- }
209
- class AnimationFrameQueueItem {
210
- constructor(runner, priority = 0) {
211
- this._runner = runner;
212
- this.priority = priority;
213
- this._canceled = false;
214
- }
215
- dispose() {
216
- this._canceled = true;
217
- }
218
- execute() {
219
- if (this._canceled) {
220
- return;
221
- }
222
- try {
223
- this._runner();
224
- }
225
- catch (e) {
226
- errors_1.onUnexpectedError(e);
227
- }
228
- }
229
- // Sort by priority (largest to lowest)
230
- static sort(a, b) {
231
- return b.priority - a.priority;
232
- }
233
- }
234
- (function () {
235
- /**
236
- * The runners scheduled at the next animation frame
237
- */
238
- let NEXT_QUEUE = [];
239
- /**
240
- * The runners scheduled at the current animation frame
241
- */
242
- let CURRENT_QUEUE = null;
243
- /**
244
- * A flag to keep track if the native requestAnimationFrame was already called
245
- */
246
- let animFrameRequested = false;
247
- /**
248
- * A flag to indicate if currently handling a native requestAnimationFrame callback
249
- */
250
- let inAnimationFrameRunner = false;
251
- let animationFrameRunner = () => {
252
- animFrameRequested = false;
253
- CURRENT_QUEUE = NEXT_QUEUE;
254
- NEXT_QUEUE = [];
255
- inAnimationFrameRunner = true;
256
- while (CURRENT_QUEUE.length > 0) {
257
- CURRENT_QUEUE.sort(AnimationFrameQueueItem.sort);
258
- let top = CURRENT_QUEUE.shift();
259
- top.execute();
260
- }
261
- inAnimationFrameRunner = false;
262
- };
263
- exports.scheduleAtNextAnimationFrame = (runner, priority = 0) => {
264
- let item = new AnimationFrameQueueItem(runner, priority);
265
- NEXT_QUEUE.push(item);
266
- if (!animFrameRequested) {
267
- animFrameRequested = true;
268
- doRequestAnimationFrame(animationFrameRunner);
269
- }
270
- return item;
271
- };
272
- exports.runAtThisOrScheduleAtNextAnimationFrame = (runner, priority) => {
273
- if (inAnimationFrameRunner) {
274
- let item = new AnimationFrameQueueItem(runner, priority);
275
- CURRENT_QUEUE.push(item);
276
- return item;
277
- }
278
- else {
279
- return exports.scheduleAtNextAnimationFrame(runner, priority);
280
- }
281
- };
282
- })();
283
- function measure(callback) {
284
- return exports.scheduleAtNextAnimationFrame(callback, 10000 /* must be early */);
285
- }
286
- exports.measure = measure;
287
- function modify(callback) {
288
- return exports.scheduleAtNextAnimationFrame(callback, -10000 /* must be late */);
289
- }
290
- exports.modify = modify;
291
- const MINIMUM_TIME_MS = 16;
292
- const DEFAULT_EVENT_MERGER = function (lastEvent, currentEvent) {
293
- return currentEvent;
294
- };
295
- class TimeoutThrottledDomListener extends lifecycle_1.Disposable {
296
- constructor(node, type, handler, eventMerger = DEFAULT_EVENT_MERGER, minimumTimeMs = MINIMUM_TIME_MS) {
297
- super();
298
- let lastEvent = null;
299
- let lastHandlerTime = 0;
300
- let timeout = this._register(new async_1.TimeoutTimer());
301
- let invokeHandler = () => {
302
- lastHandlerTime = (new Date()).getTime();
303
- handler(lastEvent);
304
- lastEvent = null;
305
- };
306
- this._register(addDisposableListener(node, type, (e) => {
307
- lastEvent = eventMerger(lastEvent, e);
308
- let elapsedTime = (new Date()).getTime() - lastHandlerTime;
309
- if (elapsedTime >= minimumTimeMs) {
310
- timeout.cancel();
311
- invokeHandler();
312
- }
313
- else {
314
- timeout.setIfNotSet(invokeHandler, minimumTimeMs - elapsedTime);
315
- }
316
- }));
317
- }
318
- }
319
- function addDisposableThrottledListener(node, type, handler, eventMerger, minimumTimeMs) {
320
- return new TimeoutThrottledDomListener(node, type, handler, eventMerger, minimumTimeMs);
321
- }
322
- exports.addDisposableThrottledListener = addDisposableThrottledListener;
323
- function getComputedStyle(el) {
324
- return document.defaultView.getComputedStyle(el, null);
325
- }
326
- exports.getComputedStyle = getComputedStyle;
327
- function getClientArea(element) {
328
- // Try with DOM clientWidth / clientHeight
329
- if (element !== document.body) {
330
- return new Dimension(element.clientWidth, element.clientHeight);
331
- }
332
- // If visual view port exits and it's on mobile, it should be used instead of window innerWidth / innerHeight, or document.body.clientWidth / document.body.clientHeight
333
- if (platform.isIOS && window.visualViewport) {
334
- const width = window.visualViewport.width;
335
- const height = window.visualViewport.height - (browser.isStandalone
336
- // in PWA mode, the visual viewport always includes the safe-area-inset-bottom (which is for the home indicator)
337
- // even when you are using the onscreen monitor, the visual viewport will include the area between system statusbar and the onscreen keyboard
338
- // plus the area between onscreen keyboard and the bottom bezel, which is 20px on iOS.
339
- ? (20 + 4) // + 4px for body margin
340
- : 0);
341
- return new Dimension(width, height);
342
- }
343
- // Try innerWidth / innerHeight
344
- if (window.innerWidth && window.innerHeight) {
345
- return new Dimension(window.innerWidth, window.innerHeight);
346
- }
347
- // Try with document.body.clientWidth / document.body.clientHeight
348
- if (document.body && document.body.clientWidth && document.body.clientHeight) {
349
- return new Dimension(document.body.clientWidth, document.body.clientHeight);
350
- }
351
- // Try with document.documentElement.clientWidth / document.documentElement.clientHeight
352
- if (document.documentElement && document.documentElement.clientWidth && document.documentElement.clientHeight) {
353
- return new Dimension(document.documentElement.clientWidth, document.documentElement.clientHeight);
354
- }
355
- throw new Error('Unable to figure out browser width and height');
356
- }
357
- exports.getClientArea = getClientArea;
358
- class SizeUtils {
359
- // Adapted from WinJS
360
- // Converts a CSS positioning string for the specified element to pixels.
361
- static convertToPixels(element, value) {
362
- return parseFloat(value) || 0;
363
- }
364
- static getDimension(element, cssPropertyName, jsPropertyName) {
365
- let computedStyle = getComputedStyle(element);
366
- let value = '0';
367
- if (computedStyle) {
368
- if (computedStyle.getPropertyValue) {
369
- value = computedStyle.getPropertyValue(cssPropertyName);
370
- }
371
- else {
372
- // IE8
373
- value = computedStyle.getAttribute(jsPropertyName);
374
- }
375
- }
376
- return SizeUtils.convertToPixels(element, value);
377
- }
378
- static getBorderLeftWidth(element) {
379
- return SizeUtils.getDimension(element, 'border-left-width', 'borderLeftWidth');
380
- }
381
- static getBorderRightWidth(element) {
382
- return SizeUtils.getDimension(element, 'border-right-width', 'borderRightWidth');
383
- }
384
- static getBorderTopWidth(element) {
385
- return SizeUtils.getDimension(element, 'border-top-width', 'borderTopWidth');
386
- }
387
- static getBorderBottomWidth(element) {
388
- return SizeUtils.getDimension(element, 'border-bottom-width', 'borderBottomWidth');
389
- }
390
- static getPaddingLeft(element) {
391
- return SizeUtils.getDimension(element, 'padding-left', 'paddingLeft');
392
- }
393
- static getPaddingRight(element) {
394
- return SizeUtils.getDimension(element, 'padding-right', 'paddingRight');
395
- }
396
- static getPaddingTop(element) {
397
- return SizeUtils.getDimension(element, 'padding-top', 'paddingTop');
398
- }
399
- static getPaddingBottom(element) {
400
- return SizeUtils.getDimension(element, 'padding-bottom', 'paddingBottom');
401
- }
402
- static getMarginLeft(element) {
403
- return SizeUtils.getDimension(element, 'margin-left', 'marginLeft');
404
- }
405
- static getMarginTop(element) {
406
- return SizeUtils.getDimension(element, 'margin-top', 'marginTop');
407
- }
408
- static getMarginRight(element) {
409
- return SizeUtils.getDimension(element, 'margin-right', 'marginRight');
410
- }
411
- static getMarginBottom(element) {
412
- return SizeUtils.getDimension(element, 'margin-bottom', 'marginBottom');
413
- }
414
- }
415
- class Dimension {
416
- constructor(width, height) {
417
- this.width = width;
418
- this.height = height;
419
- }
420
- static equals(a, b) {
421
- if (a === b) {
422
- return true;
423
- }
424
- if (!a || !b) {
425
- return false;
426
- }
427
- return a.width === b.width && a.height === b.height;
428
- }
429
- }
430
- exports.Dimension = Dimension;
431
- function getTopLeftOffset(element) {
432
- // Adapted from WinJS.Utilities.getPosition
433
- // and added borders to the mix
434
- let offsetParent = element.offsetParent;
435
- let top = element.offsetTop;
436
- let left = element.offsetLeft;
437
- while ((element = element.parentNode) !== null
438
- && element !== document.body
439
- && element !== document.documentElement) {
440
- top -= element.scrollTop;
441
- const c = isShadowRoot(element) ? null : getComputedStyle(element);
442
- if (c) {
443
- left -= c.direction !== 'rtl' ? element.scrollLeft : -element.scrollLeft;
444
- }
445
- if (element === offsetParent) {
446
- left += SizeUtils.getBorderLeftWidth(element);
447
- top += SizeUtils.getBorderTopWidth(element);
448
- top += element.offsetTop;
449
- left += element.offsetLeft;
450
- offsetParent = element.offsetParent;
451
- }
452
- }
453
- return {
454
- left: left,
455
- top: top
456
- };
457
- }
458
- exports.getTopLeftOffset = getTopLeftOffset;
459
- function size(element, width, height) {
460
- if (typeof width === 'number') {
461
- element.style.width = `${width}px`;
462
- }
463
- if (typeof height === 'number') {
464
- element.style.height = `${height}px`;
465
- }
466
- }
467
- exports.size = size;
468
- function position(element, top, right, bottom, left, position = 'absolute') {
469
- if (typeof top === 'number') {
470
- element.style.top = `${top}px`;
471
- }
472
- if (typeof right === 'number') {
473
- element.style.right = `${right}px`;
474
- }
475
- if (typeof bottom === 'number') {
476
- element.style.bottom = `${bottom}px`;
477
- }
478
- if (typeof left === 'number') {
479
- element.style.left = `${left}px`;
480
- }
481
- element.style.position = position;
482
- }
483
- exports.position = position;
484
- /**
485
- * Returns the position of a dom node relative to the entire page.
486
- */
487
- function getDomNodePagePosition(domNode) {
488
- let bb = domNode.getBoundingClientRect();
489
- return {
490
- left: bb.left + exports.StandardWindow.scrollX,
491
- top: bb.top + exports.StandardWindow.scrollY,
492
- width: bb.width,
493
- height: bb.height
494
- };
495
- }
496
- exports.getDomNodePagePosition = getDomNodePagePosition;
497
- exports.StandardWindow = new class {
498
- get scrollX() {
499
- if (typeof window.scrollX === 'number') {
500
- // modern browsers
501
- return window.scrollX;
502
- }
503
- else {
504
- return document.body.scrollLeft + document.documentElement.scrollLeft;
505
- }
506
- }
507
- get scrollY() {
508
- if (typeof window.scrollY === 'number') {
509
- // modern browsers
510
- return window.scrollY;
511
- }
512
- else {
513
- return document.body.scrollTop + document.documentElement.scrollTop;
514
- }
515
- }
516
- };
517
- // Adapted from WinJS
518
- // Gets the width of the element, including margins.
519
- function getTotalWidth(element) {
520
- let margin = SizeUtils.getMarginLeft(element) + SizeUtils.getMarginRight(element);
521
- return element.offsetWidth + margin;
522
- }
523
- exports.getTotalWidth = getTotalWidth;
524
- function getContentWidth(element) {
525
- let border = SizeUtils.getBorderLeftWidth(element) + SizeUtils.getBorderRightWidth(element);
526
- let padding = SizeUtils.getPaddingLeft(element) + SizeUtils.getPaddingRight(element);
527
- return element.offsetWidth - border - padding;
528
- }
529
- exports.getContentWidth = getContentWidth;
530
- function getTotalScrollWidth(element) {
531
- let margin = SizeUtils.getMarginLeft(element) + SizeUtils.getMarginRight(element);
532
- return element.scrollWidth + margin;
533
- }
534
- exports.getTotalScrollWidth = getTotalScrollWidth;
535
- // Adapted from WinJS
536
- // Gets the height of the content of the specified element. The content height does not include borders or padding.
537
- function getContentHeight(element) {
538
- let border = SizeUtils.getBorderTopWidth(element) + SizeUtils.getBorderBottomWidth(element);
539
- let padding = SizeUtils.getPaddingTop(element) + SizeUtils.getPaddingBottom(element);
540
- return element.offsetHeight - border - padding;
541
- }
542
- exports.getContentHeight = getContentHeight;
543
- // Adapted from WinJS
544
- // Gets the height of the element, including its margins.
545
- function getTotalHeight(element) {
546
- let margin = SizeUtils.getMarginTop(element) + SizeUtils.getMarginBottom(element);
547
- return element.offsetHeight + margin;
548
- }
549
- exports.getTotalHeight = getTotalHeight;
550
- // Gets the left coordinate of the specified element relative to the specified parent.
551
- function getRelativeLeft(element, parent) {
552
- if (element === null) {
553
- return 0;
554
- }
555
- let elementPosition = getTopLeftOffset(element);
556
- let parentPosition = getTopLeftOffset(parent);
557
- return elementPosition.left - parentPosition.left;
558
- }
559
- function getLargestChildWidth(parent, children) {
560
- let childWidths = children.map((child) => {
561
- return Math.max(getTotalScrollWidth(child), getTotalWidth(child)) + getRelativeLeft(child, parent) || 0;
562
- });
563
- let maxWidth = Math.max(...childWidths);
564
- return maxWidth;
565
- }
566
- exports.getLargestChildWidth = getLargestChildWidth;
567
- // ----------------------------------------------------------------------------------------
568
- function isAncestor(testChild, testAncestor) {
569
- while (testChild) {
570
- if (testChild === testAncestor) {
571
- return true;
572
- }
573
- testChild = testChild.parentNode;
574
- }
575
- return false;
576
- }
577
- exports.isAncestor = isAncestor;
578
- function findParentWithClass(node, clazz, stopAtClazzOrNode) {
579
- while (node && node.nodeType === node.ELEMENT_NODE) {
580
- if (exports.hasClass(node, clazz)) {
581
- return node;
582
- }
583
- if (stopAtClazzOrNode) {
584
- if (typeof stopAtClazzOrNode === 'string') {
585
- if (exports.hasClass(node, stopAtClazzOrNode)) {
586
- return null;
587
- }
588
- }
589
- else {
590
- if (node === stopAtClazzOrNode) {
591
- return null;
592
- }
593
- }
594
- }
595
- node = node.parentNode;
596
- }
597
- return null;
598
- }
599
- exports.findParentWithClass = findParentWithClass;
600
- function hasParentWithClass(node, clazz, stopAtClazzOrNode) {
601
- return !!findParentWithClass(node, clazz, stopAtClazzOrNode);
602
- }
603
- exports.hasParentWithClass = hasParentWithClass;
604
- function isShadowRoot(node) {
605
- return (node && !!node.host && !!node.mode);
606
- }
607
- exports.isShadowRoot = isShadowRoot;
608
- function isInShadowDOM(domNode) {
609
- return !!getShadowRoot(domNode);
610
- }
611
- exports.isInShadowDOM = isInShadowDOM;
612
- function getShadowRoot(domNode) {
613
- while (domNode.parentNode) {
614
- if (domNode === document.body) {
615
- // reached the body
616
- return null;
617
- }
618
- domNode = domNode.parentNode;
619
- }
620
- return isShadowRoot(domNode) ? domNode : null;
621
- }
622
- exports.getShadowRoot = getShadowRoot;
623
- function getActiveElement() {
624
- let result = document.activeElement;
625
- while (result && result.shadowRoot) {
626
- result = result.shadowRoot.activeElement;
627
- }
628
- return result;
629
- }
630
- exports.getActiveElement = getActiveElement;
631
- function createStyleSheet(container = document.getElementsByTagName('head')[0]) {
632
- let style = document.createElement('style');
633
- style.type = 'text/css';
634
- style.media = 'screen';
635
- container.appendChild(style);
636
- return style;
637
- }
638
- exports.createStyleSheet = createStyleSheet;
639
- function createMetaElement(container = document.getElementsByTagName('head')[0]) {
640
- let meta = document.createElement('meta');
641
- container.appendChild(meta);
642
- return meta;
643
- }
644
- exports.createMetaElement = createMetaElement;
645
- let _sharedStyleSheet = null;
646
- function getSharedStyleSheet() {
647
- if (!_sharedStyleSheet) {
648
- _sharedStyleSheet = createStyleSheet();
649
- }
650
- return _sharedStyleSheet;
651
- }
652
- function getDynamicStyleSheetRules(style) {
653
- if (style && style.sheet && style.sheet.rules) {
654
- // Chrome, IE
655
- return style.sheet.rules;
656
- }
657
- if (style && style.sheet && style.sheet.cssRules) {
658
- // FF
659
- return style.sheet.cssRules;
660
- }
661
- return [];
662
- }
663
- function createCSSRule(selector, cssText, style = getSharedStyleSheet()) {
664
- if (!style || !cssText) {
665
- return;
666
- }
667
- style.sheet.insertRule(selector + '{' + cssText + '}', 0);
668
- }
669
- exports.createCSSRule = createCSSRule;
670
- function removeCSSRulesContainingSelector(ruleName, style = getSharedStyleSheet()) {
671
- if (!style) {
672
- return;
673
- }
674
- let rules = getDynamicStyleSheetRules(style);
675
- let toDelete = [];
676
- for (let i = 0; i < rules.length; i++) {
677
- let rule = rules[i];
678
- if (rule.selectorText.indexOf(ruleName) !== -1) {
679
- toDelete.push(i);
680
- }
681
- }
682
- for (let i = toDelete.length - 1; i >= 0; i--) {
683
- style.sheet.deleteRule(toDelete[i]);
684
- }
685
- }
686
- exports.removeCSSRulesContainingSelector = removeCSSRulesContainingSelector;
687
- function isHTMLElement(o) {
688
- if (typeof HTMLElement === 'object') {
689
- return o instanceof HTMLElement;
690
- }
691
- return o && typeof o === 'object' && o.nodeType === 1 && typeof o.nodeName === 'string';
692
- }
693
- exports.isHTMLElement = isHTMLElement;
694
- exports.EventType = {
695
- // Mouse
696
- CLICK: 'click',
697
- AUXCLICK: 'auxclick',
698
- DBLCLICK: 'dblclick',
699
- MOUSE_UP: 'mouseup',
700
- MOUSE_DOWN: 'mousedown',
701
- MOUSE_OVER: 'mouseover',
702
- MOUSE_MOVE: 'mousemove',
703
- MOUSE_OUT: 'mouseout',
704
- MOUSE_ENTER: 'mouseenter',
705
- MOUSE_LEAVE: 'mouseleave',
706
- MOUSE_WHEEL: browser.isEdge ? 'mousewheel' : 'wheel',
707
- POINTER_UP: 'pointerup',
708
- POINTER_DOWN: 'pointerdown',
709
- POINTER_MOVE: 'pointermove',
710
- CONTEXT_MENU: 'contextmenu',
711
- WHEEL: 'wheel',
712
- // Keyboard
713
- KEY_DOWN: 'keydown',
714
- KEY_PRESS: 'keypress',
715
- KEY_UP: 'keyup',
716
- // HTML Document
717
- LOAD: 'load',
718
- BEFORE_UNLOAD: 'beforeunload',
719
- UNLOAD: 'unload',
720
- ABORT: 'abort',
721
- ERROR: 'error',
722
- RESIZE: 'resize',
723
- SCROLL: 'scroll',
724
- FULLSCREEN_CHANGE: 'fullscreenchange',
725
- WK_FULLSCREEN_CHANGE: 'webkitfullscreenchange',
726
- // Form
727
- SELECT: 'select',
728
- CHANGE: 'change',
729
- SUBMIT: 'submit',
730
- RESET: 'reset',
731
- FOCUS: 'focus',
732
- FOCUS_IN: 'focusin',
733
- FOCUS_OUT: 'focusout',
734
- BLUR: 'blur',
735
- INPUT: 'input',
736
- // Local Storage
737
- STORAGE: 'storage',
738
- // Drag
739
- DRAG_START: 'dragstart',
740
- DRAG: 'drag',
741
- DRAG_ENTER: 'dragenter',
742
- DRAG_LEAVE: 'dragleave',
743
- DRAG_OVER: 'dragover',
744
- DROP: 'drop',
745
- DRAG_END: 'dragend',
746
- // Animation
747
- ANIMATION_START: browser.isWebKit ? 'webkitAnimationStart' : 'animationstart',
748
- ANIMATION_END: browser.isWebKit ? 'webkitAnimationEnd' : 'animationend',
749
- ANIMATION_ITERATION: browser.isWebKit ? 'webkitAnimationIteration' : 'animationiteration'
750
- };
751
- exports.EventHelper = {
752
- stop: function (e, cancelBubble) {
753
- if (e.preventDefault) {
754
- e.preventDefault();
755
- }
756
- else {
757
- // IE8
758
- e.returnValue = false;
759
- }
760
- if (cancelBubble) {
761
- if (e.stopPropagation) {
762
- e.stopPropagation();
763
- }
764
- else {
765
- // IE8
766
- e.cancelBubble = true;
767
- }
768
- }
769
- }
770
- };
771
- function saveParentsScrollTop(node) {
772
- let r = [];
773
- for (let i = 0; node && node.nodeType === node.ELEMENT_NODE; i++) {
774
- r[i] = node.scrollTop;
775
- node = node.parentNode;
776
- }
777
- return r;
778
- }
779
- exports.saveParentsScrollTop = saveParentsScrollTop;
780
- function restoreParentsScrollTop(node, state) {
781
- for (let i = 0; node && node.nodeType === node.ELEMENT_NODE; i++) {
782
- if (node.scrollTop !== state[i]) {
783
- node.scrollTop = state[i];
784
- }
785
- node = node.parentNode;
786
- }
787
- }
788
- exports.restoreParentsScrollTop = restoreParentsScrollTop;
789
- class FocusTracker extends lifecycle_1.Disposable {
790
- constructor(element) {
791
- super();
792
- this._onDidFocus = this._register(new event_2.Emitter());
793
- this.onDidFocus = this._onDidFocus.event;
794
- this._onDidBlur = this._register(new event_2.Emitter());
795
- this.onDidBlur = this._onDidBlur.event;
796
- let hasFocus = isAncestor(document.activeElement, element);
797
- let loosingFocus = false;
798
- const onFocus = () => {
799
- loosingFocus = false;
800
- if (!hasFocus) {
801
- hasFocus = true;
802
- this._onDidFocus.fire();
803
- }
804
- };
805
- const onBlur = () => {
806
- if (hasFocus) {
807
- loosingFocus = true;
808
- window.setTimeout(() => {
809
- if (loosingFocus) {
810
- loosingFocus = false;
811
- hasFocus = false;
812
- this._onDidBlur.fire();
813
- }
814
- }, 0);
815
- }
816
- };
817
- this._refreshStateHandler = () => {
818
- let currentNodeHasFocus = isAncestor(document.activeElement, element);
819
- if (currentNodeHasFocus !== hasFocus) {
820
- if (hasFocus) {
821
- onBlur();
822
- }
823
- else {
824
- onFocus();
825
- }
826
- }
827
- };
828
- this._register(event_1.domEvent(element, exports.EventType.FOCUS, true)(onFocus));
829
- this._register(event_1.domEvent(element, exports.EventType.BLUR, true)(onBlur));
830
- }
831
- refreshState() {
832
- this._refreshStateHandler();
833
- }
834
- }
835
- function trackFocus(element) {
836
- return new FocusTracker(element);
837
- }
838
- exports.trackFocus = trackFocus;
839
- function append(parent, ...children) {
840
- children.forEach(child => parent.appendChild(child));
841
- return children[children.length - 1];
842
- }
843
- exports.append = append;
844
- function prepend(parent, child) {
845
- parent.insertBefore(child, parent.firstChild);
846
- return child;
847
- }
848
- exports.prepend = prepend;
849
- const SELECTOR_REGEX = /([\w\-]+)?(#([\w\-]+))?((\.([\w\-]+))*)/;
850
- var Namespace;
851
- (function (Namespace) {
852
- Namespace["HTML"] = "http://www.w3.org/1999/xhtml";
853
- Namespace["SVG"] = "http://www.w3.org/2000/svg";
854
- })(Namespace = exports.Namespace || (exports.Namespace = {}));
855
- function _$(namespace, description, attrs, ...children) {
856
- let match = SELECTOR_REGEX.exec(description);
857
- if (!match) {
858
- throw new Error('Bad use of emmet');
859
- }
860
- attrs = { ...(attrs || {}) };
861
- let tagName = match[1] || 'div';
862
- let result;
863
- if (namespace !== Namespace.HTML) {
864
- result = document.createElementNS(namespace, tagName);
865
- }
866
- else {
867
- result = document.createElement(tagName);
868
- }
869
- if (match[3]) {
870
- result.id = match[3];
871
- }
872
- if (match[4]) {
873
- result.className = match[4].replace(/\./g, ' ').trim();
874
- }
875
- Object.keys(attrs).forEach(name => {
876
- const value = attrs[name];
877
- if (typeof value === 'undefined') {
878
- return;
879
- }
880
- if (/^on\w+$/.test(name)) {
881
- result[name] = value;
882
- }
883
- else if (name === 'selected') {
884
- if (value) {
885
- result.setAttribute(name, 'true');
886
- }
887
- }
888
- else {
889
- result.setAttribute(name, value);
890
- }
891
- });
892
- arrays_1.coalesce(children)
893
- .forEach(child => {
894
- if (child instanceof Node) {
895
- result.appendChild(child);
896
- }
897
- else {
898
- result.appendChild(document.createTextNode(child));
899
- }
900
- });
901
- return result;
902
- }
903
- function $(description, attrs, ...children) {
904
- return _$(Namespace.HTML, description, attrs, ...children);
905
- }
906
- exports.$ = $;
907
- $.SVG = function (description, attrs, ...children) {
908
- return _$(Namespace.SVG, description, attrs, ...children);
909
- };
910
- function join(nodes, separator) {
911
- const result = [];
912
- nodes.forEach((node, index) => {
913
- if (index > 0) {
914
- if (separator instanceof Node) {
915
- result.push(separator.cloneNode());
916
- }
917
- else {
918
- result.push(document.createTextNode(separator));
919
- }
920
- }
921
- result.push(node);
922
- });
923
- return result;
924
- }
925
- exports.join = join;
926
- function show(...elements) {
927
- for (let element of elements) {
928
- element.style.display = '';
929
- element.removeAttribute('aria-hidden');
930
- }
931
- }
932
- exports.show = show;
933
- function hide(...elements) {
934
- for (let element of elements) {
935
- element.style.display = 'none';
936
- element.setAttribute('aria-hidden', 'true');
937
- }
938
- }
939
- exports.hide = hide;
940
- function findParentWithAttribute(node, attribute) {
941
- while (node && node.nodeType === node.ELEMENT_NODE) {
942
- if (node instanceof HTMLElement && node.hasAttribute(attribute)) {
943
- return node;
944
- }
945
- node = node.parentNode;
946
- }
947
- return null;
948
- }
949
- function removeTabIndexAndUpdateFocus(node) {
950
- if (!node || !node.hasAttribute('tabIndex')) {
951
- return;
952
- }
953
- // If we are the currently focused element and tabIndex is removed,
954
- // standard DOM behavior is to move focus to the <body> element. We
955
- // typically never want that, rather put focus to the closest element
956
- // in the hierarchy of the parent DOM nodes.
957
- if (document.activeElement === node) {
958
- let parentFocusable = findParentWithAttribute(node.parentElement, 'tabIndex');
959
- if (parentFocusable) {
960
- parentFocusable.focus();
961
- }
962
- }
963
- node.removeAttribute('tabindex');
964
- }
965
- exports.removeTabIndexAndUpdateFocus = removeTabIndexAndUpdateFocus;
966
- function getElementsByTagName(tag) {
967
- return Array.prototype.slice.call(document.getElementsByTagName(tag), 0);
968
- }
969
- exports.getElementsByTagName = getElementsByTagName;
970
- function finalHandler(fn) {
971
- return e => {
972
- e.preventDefault();
973
- e.stopPropagation();
974
- fn(e);
975
- };
976
- }
977
- exports.finalHandler = finalHandler;
978
- function domContentLoaded() {
979
- return new Promise(resolve => {
980
- const readyState = document.readyState;
981
- if (readyState === 'complete' || (document && document.body !== null)) {
982
- platform.setImmediate(resolve);
983
- }
984
- else {
985
- window.addEventListener('DOMContentLoaded', resolve, false);
986
- }
987
- });
988
- }
989
- exports.domContentLoaded = domContentLoaded;
990
- /**
991
- * Find a value usable for a dom node size such that the likelihood that it would be
992
- * displayed with constant screen pixels size is as high as possible.
993
- *
994
- * e.g. We would desire for the cursors to be 2px (CSS px) wide. Under a devicePixelRatio
995
- * of 1.25, the cursor will be 2.5 screen pixels wide. Depending on how the dom node aligns/"snaps"
996
- * with the screen pixels, it will sometimes be rendered with 2 screen pixels, and sometimes with 3 screen pixels.
997
- */
998
- function computeScreenAwareSize(cssPx) {
999
- const screenPx = window.devicePixelRatio * cssPx;
1000
- return Math.max(1, Math.floor(screenPx)) / window.devicePixelRatio;
1001
- }
1002
- exports.computeScreenAwareSize = computeScreenAwareSize;
1003
- /**
1004
- * See https://github.com/Microsoft/monaco-editor/issues/601
1005
- * To protect against malicious code in the linked site, particularly phishing attempts,
1006
- * the window.opener should be set to null to prevent the linked site from having access
1007
- * to change the location of the current page.
1008
- * See https://mathiasbynens.github.io/rel-noopener/
1009
- */
1010
- function windowOpenNoOpener(url) {
1011
- if (platform.isNative || browser.isEdgeWebView) {
1012
- // In VSCode, window.open() always returns null...
1013
- // The same is true for a WebView (see https://github.com/Microsoft/monaco-editor/issues/628)
1014
- window.open(url);
1015
- }
1016
- else {
1017
- let newTab = window.open();
1018
- if (newTab) {
1019
- newTab.opener = null;
1020
- newTab.location.href = url;
1021
- }
1022
- }
1023
- }
1024
- exports.windowOpenNoOpener = windowOpenNoOpener;
1025
- function animate(fn) {
1026
- const step = () => {
1027
- fn();
1028
- stepDisposable = exports.scheduleAtNextAnimationFrame(step);
1029
- };
1030
- let stepDisposable = exports.scheduleAtNextAnimationFrame(step);
1031
- return lifecycle_1.toDisposable(() => stepDisposable.dispose());
1032
- }
1033
- exports.animate = animate;
1034
- network_1.RemoteAuthorities.setPreferredWebSchema(/^https:/.test(window.location.href) ? 'https' : 'http');
1035
- function asDomUri(uri) {
1036
- if (!uri) {
1037
- return uri;
1038
- }
1039
- if (network_1.Schemas.vscodeRemote === uri.scheme) {
1040
- return network_1.RemoteAuthorities.rewrite(uri);
1041
- }
1042
- return uri;
1043
- }
1044
- exports.asDomUri = asDomUri;
1045
- /**
1046
- * returns url('...')
1047
- */
1048
- function asCSSUrl(uri) {
1049
- if (!uri) {
1050
- return `url('')`;
1051
- }
1052
- return `url('${asDomUri(uri).toString(true).replace(/'/g, '%27')}')`;
1053
- }
1054
- exports.asCSSUrl = asCSSUrl;
1055
- function triggerDownload(dataOrUri, name) {
1056
- // If the data is provided as Buffer, we create a
1057
- // blog URL out of it to produce a valid link
1058
- let url;
1059
- if (uri_1.URI.isUri(dataOrUri)) {
1060
- url = dataOrUri.toString(true);
1061
- }
1062
- else {
1063
- const blob = new Blob([dataOrUri]);
1064
- url = URL.createObjectURL(blob);
1065
- // Ensure to free the data from DOM eventually
1066
- setTimeout(() => URL.revokeObjectURL(url));
1067
- }
1068
- // In order to download from the browser, the only way seems
1069
- // to be creating a <a> element with download attribute that
1070
- // points to the file to download.
1071
- // See also https://developers.google.com/web/updates/2011/08/Downloading-resources-in-HTML5-a-download
1072
- const anchor = document.createElement('a');
1073
- document.body.appendChild(anchor);
1074
- anchor.download = name;
1075
- anchor.href = url;
1076
- anchor.click();
1077
- // Ensure to remove the element from DOM eventually
1078
- setTimeout(() => document.body.removeChild(anchor));
1079
- }
1080
- exports.triggerDownload = triggerDownload;