@xterm/xterm 6.1.0-beta.16 → 6.1.0-beta.161

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 (155) hide show
  1. package/README.md +27 -28
  2. package/css/xterm.css +29 -22
  3. package/lib/xterm.js +1 -1
  4. package/lib/xterm.js.map +1 -1
  5. package/lib/xterm.mjs +8 -34
  6. package/lib/xterm.mjs.map +4 -4
  7. package/package.json +28 -17
  8. package/src/browser/AccessibilityManager.ts +6 -3
  9. package/src/browser/CoreBrowserTerminal.ts +142 -62
  10. package/src/browser/Dom.ts +178 -0
  11. package/src/browser/Linkifier.ts +3 -3
  12. package/src/browser/OscLinkProvider.ts +3 -1
  13. package/src/browser/RenderDebouncer.ts +2 -2
  14. package/src/browser/TimeBasedDebouncer.ts +2 -2
  15. package/src/browser/Types.ts +12 -11
  16. package/src/browser/Viewport.ts +40 -17
  17. package/src/browser/decorations/BufferDecorationRenderer.ts +1 -1
  18. package/src/browser/decorations/OverviewRulerRenderer.ts +15 -16
  19. package/src/browser/input/CompositionHelper.ts +10 -1
  20. package/src/browser/public/Terminal.ts +24 -27
  21. package/src/browser/renderer/dom/DomRenderer.ts +128 -8
  22. package/src/browser/renderer/dom/DomRendererRowFactory.ts +19 -13
  23. package/src/browser/renderer/dom/WidthCache.ts +54 -52
  24. package/src/browser/renderer/shared/Constants.ts +7 -0
  25. package/src/browser/renderer/shared/TextBlinkStateManager.ts +97 -0
  26. package/src/browser/renderer/shared/Types.ts +8 -2
  27. package/src/browser/scrollable/abstractScrollbar.ts +300 -0
  28. package/src/browser/scrollable/fastDomNode.ts +126 -0
  29. package/src/browser/scrollable/globalPointerMoveMonitor.ts +90 -0
  30. package/src/browser/scrollable/horizontalScrollbar.ts +85 -0
  31. package/src/browser/scrollable/mouseEvent.ts +292 -0
  32. package/src/browser/scrollable/scrollable.ts +486 -0
  33. package/src/browser/scrollable/scrollableElement.ts +579 -0
  34. package/src/browser/scrollable/scrollableElementOptions.ts +161 -0
  35. package/src/browser/scrollable/scrollbarArrow.ts +110 -0
  36. package/src/browser/scrollable/scrollbarState.ts +246 -0
  37. package/src/browser/scrollable/scrollbarVisibilityController.ts +113 -0
  38. package/src/browser/scrollable/touch.ts +481 -0
  39. package/src/browser/scrollable/verticalScrollbar.ts +143 -0
  40. package/src/browser/scrollable/widget.ts +23 -0
  41. package/src/browser/services/CharSizeService.ts +2 -2
  42. package/src/browser/services/CoreBrowserService.ts +4 -4
  43. package/src/browser/services/KeyboardService.ts +67 -0
  44. package/src/browser/services/LinkProviderService.ts +1 -1
  45. package/src/browser/services/MouseService.ts +2 -1
  46. package/src/browser/services/RenderService.ts +22 -15
  47. package/src/browser/services/SelectionService.ts +12 -4
  48. package/src/browser/services/Services.ts +24 -15
  49. package/src/browser/services/ThemeService.ts +2 -2
  50. package/src/common/Async.ts +105 -0
  51. package/src/common/CircularList.ts +2 -2
  52. package/src/common/Color.ts +8 -0
  53. package/src/common/CoreTerminal.ts +21 -11
  54. package/src/common/Event.ts +118 -0
  55. package/src/common/InputHandler.ts +244 -24
  56. package/src/common/Lifecycle.ts +113 -0
  57. package/src/common/Platform.ts +13 -3
  58. package/src/common/SortedList.ts +7 -3
  59. package/src/common/TaskQueue.ts +9 -3
  60. package/src/common/Types.ts +27 -7
  61. package/src/common/Version.ts +9 -0
  62. package/src/common/buffer/Buffer.ts +20 -14
  63. package/src/common/buffer/BufferLine.ts +4 -5
  64. package/src/common/buffer/BufferSet.ts +7 -6
  65. package/src/common/buffer/CellData.ts +57 -0
  66. package/src/common/buffer/Marker.ts +2 -2
  67. package/src/common/buffer/Types.ts +6 -2
  68. package/src/common/data/EscapeSequences.ts +71 -70
  69. package/src/common/input/Keyboard.ts +7 -6
  70. package/src/common/input/KittyKeyboard.ts +491 -0
  71. package/src/common/input/Win32InputMode.ts +297 -0
  72. package/src/common/input/WriteBuffer.ts +34 -2
  73. package/src/common/input/XParseColor.ts +2 -2
  74. package/src/common/parser/ApcParser.ts +245 -0
  75. package/src/common/parser/Constants.ts +22 -4
  76. package/src/common/parser/DcsParser.ts +5 -5
  77. package/src/common/parser/EscapeSequenceParser.ts +75 -22
  78. package/src/common/parser/OscParser.ts +5 -5
  79. package/src/common/parser/Types.ts +34 -1
  80. package/src/common/public/BufferLineApiView.ts +2 -2
  81. package/src/common/public/BufferNamespaceApi.ts +2 -2
  82. package/src/common/public/ParserApi.ts +3 -0
  83. package/src/common/services/BufferService.ts +8 -5
  84. package/src/common/services/CharsetService.ts +4 -0
  85. package/src/common/services/CoreMouseService.ts +2 -2
  86. package/src/common/services/CoreService.ts +18 -4
  87. package/src/common/services/DecorationService.ts +24 -8
  88. package/src/common/services/LogService.ts +1 -31
  89. package/src/common/services/OptionsService.ts +13 -4
  90. package/src/common/services/Services.ts +39 -16
  91. package/src/common/services/UnicodeService.ts +1 -1
  92. package/typings/xterm.d.ts +319 -35
  93. package/src/common/TypedArrayUtils.ts +0 -17
  94. package/src/vs/base/browser/browser.ts +0 -141
  95. package/src/vs/base/browser/canIUse.ts +0 -49
  96. package/src/vs/base/browser/dom.ts +0 -2369
  97. package/src/vs/base/browser/fastDomNode.ts +0 -316
  98. package/src/vs/base/browser/globalPointerMoveMonitor.ts +0 -112
  99. package/src/vs/base/browser/iframe.ts +0 -135
  100. package/src/vs/base/browser/keyboardEvent.ts +0 -213
  101. package/src/vs/base/browser/mouseEvent.ts +0 -229
  102. package/src/vs/base/browser/touch.ts +0 -372
  103. package/src/vs/base/browser/ui/scrollbar/abstractScrollbar.ts +0 -303
  104. package/src/vs/base/browser/ui/scrollbar/horizontalScrollbar.ts +0 -114
  105. package/src/vs/base/browser/ui/scrollbar/scrollableElement.ts +0 -720
  106. package/src/vs/base/browser/ui/scrollbar/scrollableElementOptions.ts +0 -165
  107. package/src/vs/base/browser/ui/scrollbar/scrollbarArrow.ts +0 -114
  108. package/src/vs/base/browser/ui/scrollbar/scrollbarState.ts +0 -243
  109. package/src/vs/base/browser/ui/scrollbar/scrollbarVisibilityController.ts +0 -118
  110. package/src/vs/base/browser/ui/scrollbar/verticalScrollbar.ts +0 -116
  111. package/src/vs/base/browser/ui/widget.ts +0 -57
  112. package/src/vs/base/browser/window.ts +0 -14
  113. package/src/vs/base/common/arrays.ts +0 -887
  114. package/src/vs/base/common/arraysFind.ts +0 -202
  115. package/src/vs/base/common/assert.ts +0 -71
  116. package/src/vs/base/common/async.ts +0 -1992
  117. package/src/vs/base/common/cancellation.ts +0 -148
  118. package/src/vs/base/common/charCode.ts +0 -450
  119. package/src/vs/base/common/collections.ts +0 -140
  120. package/src/vs/base/common/decorators.ts +0 -130
  121. package/src/vs/base/common/equals.ts +0 -146
  122. package/src/vs/base/common/errors.ts +0 -303
  123. package/src/vs/base/common/event.ts +0 -1778
  124. package/src/vs/base/common/functional.ts +0 -32
  125. package/src/vs/base/common/hash.ts +0 -316
  126. package/src/vs/base/common/iterator.ts +0 -159
  127. package/src/vs/base/common/keyCodes.ts +0 -526
  128. package/src/vs/base/common/keybindings.ts +0 -284
  129. package/src/vs/base/common/lazy.ts +0 -47
  130. package/src/vs/base/common/lifecycle.ts +0 -801
  131. package/src/vs/base/common/linkedList.ts +0 -142
  132. package/src/vs/base/common/map.ts +0 -202
  133. package/src/vs/base/common/numbers.ts +0 -98
  134. package/src/vs/base/common/observable.ts +0 -76
  135. package/src/vs/base/common/observableInternal/api.ts +0 -31
  136. package/src/vs/base/common/observableInternal/autorun.ts +0 -281
  137. package/src/vs/base/common/observableInternal/base.ts +0 -489
  138. package/src/vs/base/common/observableInternal/debugName.ts +0 -145
  139. package/src/vs/base/common/observableInternal/derived.ts +0 -428
  140. package/src/vs/base/common/observableInternal/lazyObservableValue.ts +0 -146
  141. package/src/vs/base/common/observableInternal/logging.ts +0 -328
  142. package/src/vs/base/common/observableInternal/promise.ts +0 -209
  143. package/src/vs/base/common/observableInternal/utils.ts +0 -610
  144. package/src/vs/base/common/platform.ts +0 -281
  145. package/src/vs/base/common/scrollable.ts +0 -522
  146. package/src/vs/base/common/sequence.ts +0 -34
  147. package/src/vs/base/common/stopwatch.ts +0 -43
  148. package/src/vs/base/common/strings.ts +0 -557
  149. package/src/vs/base/common/symbols.ts +0 -9
  150. package/src/vs/base/common/uint.ts +0 -59
  151. package/src/vs/patches/nls.ts +0 -90
  152. package/src/vs/typings/base-common.d.ts +0 -20
  153. package/src/vs/typings/require.d.ts +0 -42
  154. package/src/vs/typings/vscode-globals-nls.d.ts +0 -36
  155. package/src/vs/typings/vscode-globals-product.d.ts +0 -33
@@ -1,316 +0,0 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the MIT License. See License.txt in the project root for license information.
4
- *--------------------------------------------------------------------------------------------*/
5
-
6
- export class FastDomNode<T extends HTMLElement> {
7
-
8
- private _maxWidth: string = '';
9
- private _width: string = '';
10
- private _height: string = '';
11
- private _top: string = '';
12
- private _left: string = '';
13
- private _bottom: string = '';
14
- private _right: string = '';
15
- private _paddingTop: string = '';
16
- private _paddingLeft: string = '';
17
- private _paddingBottom: string = '';
18
- private _paddingRight: string = '';
19
- private _fontFamily: string = '';
20
- private _fontWeight: string = '';
21
- private _fontSize: string = '';
22
- private _fontStyle: string = '';
23
- private _fontFeatureSettings: string = '';
24
- private _fontVariationSettings: string = '';
25
- private _textDecoration: string = '';
26
- private _lineHeight: string = '';
27
- private _letterSpacing: string = '';
28
- private _className: string = '';
29
- private _display: string = '';
30
- private _position: string = '';
31
- private _visibility: string = '';
32
- private _color: string = '';
33
- private _backgroundColor: string = '';
34
- private _layerHint: boolean = false;
35
- private _contain: 'none' | 'strict' | 'content' | 'size' | 'layout' | 'style' | 'paint' = 'none';
36
- private _boxShadow: string = '';
37
-
38
- constructor(
39
- public readonly domNode: T
40
- ) { }
41
-
42
- public setMaxWidth(_maxWidth: number | string): void {
43
- const maxWidth = numberAsPixels(_maxWidth);
44
- if (this._maxWidth === maxWidth) {
45
- return;
46
- }
47
- this._maxWidth = maxWidth;
48
- this.domNode.style.maxWidth = this._maxWidth;
49
- }
50
-
51
- public setWidth(_width: number | string): void {
52
- const width = numberAsPixels(_width);
53
- if (this._width === width) {
54
- return;
55
- }
56
- this._width = width;
57
- this.domNode.style.width = this._width;
58
- }
59
-
60
- public setHeight(_height: number | string): void {
61
- const height = numberAsPixels(_height);
62
- if (this._height === height) {
63
- return;
64
- }
65
- this._height = height;
66
- this.domNode.style.height = this._height;
67
- }
68
-
69
- public setTop(_top: number | string): void {
70
- const top = numberAsPixels(_top);
71
- if (this._top === top) {
72
- return;
73
- }
74
- this._top = top;
75
- this.domNode.style.top = this._top;
76
- }
77
-
78
- public setLeft(_left: number | string): void {
79
- const left = numberAsPixels(_left);
80
- if (this._left === left) {
81
- return;
82
- }
83
- this._left = left;
84
- this.domNode.style.left = this._left;
85
- }
86
-
87
- public setBottom(_bottom: number | string): void {
88
- const bottom = numberAsPixels(_bottom);
89
- if (this._bottom === bottom) {
90
- return;
91
- }
92
- this._bottom = bottom;
93
- this.domNode.style.bottom = this._bottom;
94
- }
95
-
96
- public setRight(_right: number | string): void {
97
- const right = numberAsPixels(_right);
98
- if (this._right === right) {
99
- return;
100
- }
101
- this._right = right;
102
- this.domNode.style.right = this._right;
103
- }
104
-
105
- public setPaddingTop(_paddingTop: number | string): void {
106
- const paddingTop = numberAsPixels(_paddingTop);
107
- if (this._paddingTop === paddingTop) {
108
- return;
109
- }
110
- this._paddingTop = paddingTop;
111
- this.domNode.style.paddingTop = this._paddingTop;
112
- }
113
-
114
- public setPaddingLeft(_paddingLeft: number | string): void {
115
- const paddingLeft = numberAsPixels(_paddingLeft);
116
- if (this._paddingLeft === paddingLeft) {
117
- return;
118
- }
119
- this._paddingLeft = paddingLeft;
120
- this.domNode.style.paddingLeft = this._paddingLeft;
121
- }
122
-
123
- public setPaddingBottom(_paddingBottom: number | string): void {
124
- const paddingBottom = numberAsPixels(_paddingBottom);
125
- if (this._paddingBottom === paddingBottom) {
126
- return;
127
- }
128
- this._paddingBottom = paddingBottom;
129
- this.domNode.style.paddingBottom = this._paddingBottom;
130
- }
131
-
132
- public setPaddingRight(_paddingRight: number | string): void {
133
- const paddingRight = numberAsPixels(_paddingRight);
134
- if (this._paddingRight === paddingRight) {
135
- return;
136
- }
137
- this._paddingRight = paddingRight;
138
- this.domNode.style.paddingRight = this._paddingRight;
139
- }
140
-
141
- public setFontFamily(fontFamily: string): void {
142
- if (this._fontFamily === fontFamily) {
143
- return;
144
- }
145
- this._fontFamily = fontFamily;
146
- this.domNode.style.fontFamily = this._fontFamily;
147
- }
148
-
149
- public setFontWeight(fontWeight: string): void {
150
- if (this._fontWeight === fontWeight) {
151
- return;
152
- }
153
- this._fontWeight = fontWeight;
154
- this.domNode.style.fontWeight = this._fontWeight;
155
- }
156
-
157
- public setFontSize(_fontSize: number | string): void {
158
- const fontSize = numberAsPixels(_fontSize);
159
- if (this._fontSize === fontSize) {
160
- return;
161
- }
162
- this._fontSize = fontSize;
163
- this.domNode.style.fontSize = this._fontSize;
164
- }
165
-
166
- public setFontStyle(fontStyle: string): void {
167
- if (this._fontStyle === fontStyle) {
168
- return;
169
- }
170
- this._fontStyle = fontStyle;
171
- this.domNode.style.fontStyle = this._fontStyle;
172
- }
173
-
174
- public setFontFeatureSettings(fontFeatureSettings: string): void {
175
- if (this._fontFeatureSettings === fontFeatureSettings) {
176
- return;
177
- }
178
- this._fontFeatureSettings = fontFeatureSettings;
179
- this.domNode.style.fontFeatureSettings = this._fontFeatureSettings;
180
- }
181
-
182
- public setFontVariationSettings(fontVariationSettings: string): void {
183
- if (this._fontVariationSettings === fontVariationSettings) {
184
- return;
185
- }
186
- this._fontVariationSettings = fontVariationSettings;
187
- this.domNode.style.fontVariationSettings = this._fontVariationSettings;
188
- }
189
-
190
- public setTextDecoration(textDecoration: string): void {
191
- if (this._textDecoration === textDecoration) {
192
- return;
193
- }
194
- this._textDecoration = textDecoration;
195
- this.domNode.style.textDecoration = this._textDecoration;
196
- }
197
-
198
- public setLineHeight(_lineHeight: number | string): void {
199
- const lineHeight = numberAsPixels(_lineHeight);
200
- if (this._lineHeight === lineHeight) {
201
- return;
202
- }
203
- this._lineHeight = lineHeight;
204
- this.domNode.style.lineHeight = this._lineHeight;
205
- }
206
-
207
- public setLetterSpacing(_letterSpacing: number | string): void {
208
- const letterSpacing = numberAsPixels(_letterSpacing);
209
- if (this._letterSpacing === letterSpacing) {
210
- return;
211
- }
212
- this._letterSpacing = letterSpacing;
213
- this.domNode.style.letterSpacing = this._letterSpacing;
214
- }
215
-
216
- public setClassName(className: string): void {
217
- if (this._className === className) {
218
- return;
219
- }
220
- this._className = className;
221
- this.domNode.className = this._className;
222
- }
223
-
224
- public toggleClassName(className: string, shouldHaveIt?: boolean): void {
225
- this.domNode.classList.toggle(className, shouldHaveIt);
226
- this._className = this.domNode.className;
227
- }
228
-
229
- public setDisplay(display: string): void {
230
- if (this._display === display) {
231
- return;
232
- }
233
- this._display = display;
234
- this.domNode.style.display = this._display;
235
- }
236
-
237
- public setPosition(position: string): void {
238
- if (this._position === position) {
239
- return;
240
- }
241
- this._position = position;
242
- this.domNode.style.position = this._position;
243
- }
244
-
245
- public setVisibility(visibility: string): void {
246
- if (this._visibility === visibility) {
247
- return;
248
- }
249
- this._visibility = visibility;
250
- this.domNode.style.visibility = this._visibility;
251
- }
252
-
253
- public setColor(color: string): void {
254
- if (this._color === color) {
255
- return;
256
- }
257
- this._color = color;
258
- this.domNode.style.color = this._color;
259
- }
260
-
261
- public setBackgroundColor(backgroundColor: string): void {
262
- if (this._backgroundColor === backgroundColor) {
263
- return;
264
- }
265
- this._backgroundColor = backgroundColor;
266
- this.domNode.style.backgroundColor = this._backgroundColor;
267
- }
268
-
269
- public setLayerHinting(layerHint: boolean): void {
270
- if (this._layerHint === layerHint) {
271
- return;
272
- }
273
- this._layerHint = layerHint;
274
- this.domNode.style.transform = this._layerHint ? 'translate3d(0px, 0px, 0px)' : '';
275
- }
276
-
277
- public setBoxShadow(boxShadow: string): void {
278
- if (this._boxShadow === boxShadow) {
279
- return;
280
- }
281
- this._boxShadow = boxShadow;
282
- this.domNode.style.boxShadow = boxShadow;
283
- }
284
-
285
- public setContain(contain: 'none' | 'strict' | 'content' | 'size' | 'layout' | 'style' | 'paint'): void {
286
- if (this._contain === contain) {
287
- return;
288
- }
289
- this._contain = contain;
290
- (<any>this.domNode.style).contain = this._contain;
291
- }
292
-
293
- public setAttribute(name: string, value: string): void {
294
- this.domNode.setAttribute(name, value);
295
- }
296
-
297
- public removeAttribute(name: string): void {
298
- this.domNode.removeAttribute(name);
299
- }
300
-
301
- public appendChild(child: FastDomNode<T>): void {
302
- this.domNode.appendChild(child.domNode);
303
- }
304
-
305
- public removeChild(child: FastDomNode<T>): void {
306
- this.domNode.removeChild(child.domNode);
307
- }
308
- }
309
-
310
- function numberAsPixels(value: number | string): string {
311
- return (typeof value === 'number' ? `${value}px` : value);
312
- }
313
-
314
- export function createFastDomNode<T extends HTMLElement>(domNode: T): FastDomNode<T> {
315
- return new FastDomNode(domNode);
316
- }
@@ -1,112 +0,0 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the MIT License. See License.txt in the project root for license information.
4
- *--------------------------------------------------------------------------------------------*/
5
-
6
- import * as dom from 'vs/base/browser/dom';
7
- import { DisposableStore, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
8
-
9
- export interface IPointerMoveCallback {
10
- (event: PointerEvent): void;
11
- }
12
-
13
- export interface IOnStopCallback {
14
- (browserEvent?: PointerEvent | KeyboardEvent): void;
15
- }
16
-
17
- export class GlobalPointerMoveMonitor implements IDisposable {
18
-
19
- private readonly _hooks = new DisposableStore();
20
- private _pointerMoveCallback: IPointerMoveCallback | null = null;
21
- private _onStopCallback: IOnStopCallback | null = null;
22
-
23
- public dispose(): void {
24
- this.stopMonitoring(false);
25
- this._hooks.dispose();
26
- }
27
-
28
- public stopMonitoring(invokeStopCallback: boolean, browserEvent?: PointerEvent | KeyboardEvent): void {
29
- if (!this.isMonitoring()) {
30
- // Not monitoring
31
- return;
32
- }
33
-
34
- // Unhook
35
- this._hooks.clear();
36
- this._pointerMoveCallback = null;
37
- const onStopCallback = this._onStopCallback;
38
- this._onStopCallback = null;
39
-
40
- if (invokeStopCallback && onStopCallback) {
41
- onStopCallback(browserEvent);
42
- }
43
- }
44
-
45
- public isMonitoring(): boolean {
46
- return !!this._pointerMoveCallback;
47
- }
48
-
49
- public startMonitoring(
50
- initialElement: Element,
51
- pointerId: number,
52
- initialButtons: number,
53
- pointerMoveCallback: IPointerMoveCallback,
54
- onStopCallback: IOnStopCallback
55
- ): void {
56
- if (this.isMonitoring()) {
57
- this.stopMonitoring(false);
58
- }
59
- this._pointerMoveCallback = pointerMoveCallback;
60
- this._onStopCallback = onStopCallback;
61
-
62
- let eventSource: Element | Window = initialElement;
63
-
64
- try {
65
- initialElement.setPointerCapture(pointerId);
66
- this._hooks.add(toDisposable(() => {
67
- try {
68
- initialElement.releasePointerCapture(pointerId);
69
- } catch (err) {
70
- // See https://github.com/microsoft/vscode/issues/161731
71
- //
72
- // `releasePointerCapture` sometimes fails when being invoked with the exception:
73
- // DOMException: Failed to execute 'releasePointerCapture' on 'Element':
74
- // No active pointer with the given id is found.
75
- //
76
- // There's no need to do anything in case of failure
77
- }
78
- }));
79
- } catch (err) {
80
- // See https://github.com/microsoft/vscode/issues/144584
81
- // See https://github.com/microsoft/vscode/issues/146947
82
- // `setPointerCapture` sometimes fails when being invoked
83
- // from a `mousedown` listener on macOS and Windows
84
- // and it always fails on Linux with the exception:
85
- // DOMException: Failed to execute 'setPointerCapture' on 'Element':
86
- // No active pointer with the given id is found.
87
- // In case of failure, we bind the listeners on the window
88
- eventSource = dom.getWindow(initialElement);
89
- }
90
-
91
- this._hooks.add(dom.addDisposableListener(
92
- eventSource,
93
- dom.EventType.POINTER_MOVE,
94
- (e) => {
95
- if (e.buttons !== initialButtons) {
96
- // Buttons state has changed in the meantime
97
- this.stopMonitoring(true);
98
- return;
99
- }
100
-
101
- e.preventDefault();
102
- this._pointerMoveCallback!(e);
103
- }
104
- ));
105
-
106
- this._hooks.add(dom.addDisposableListener(
107
- eventSource,
108
- dom.EventType.POINTER_UP,
109
- (e: PointerEvent) => this.stopMonitoring(true)
110
- ));
111
- }
112
- }
@@ -1,135 +0,0 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the MIT License. See License.txt in the project root for license information.
4
- *--------------------------------------------------------------------------------------------*/
5
-
6
- /**
7
- * Represents a window in a possible chain of iframes
8
- */
9
- interface IWindowChainElement {
10
- /**
11
- * The window object for it
12
- */
13
- readonly window: WeakRef<Window>;
14
- /**
15
- * The iframe element inside the window.parent corresponding to window
16
- */
17
- readonly iframeElement: Element | null;
18
- }
19
-
20
- const sameOriginWindowChainCache = new WeakMap<Window, IWindowChainElement[] | null>();
21
-
22
- function getParentWindowIfSameOrigin(w: Window): Window | null {
23
- if (!w.parent || w.parent === w) {
24
- return null;
25
- }
26
-
27
- // Cannot really tell if we have access to the parent window unless we try to access something in it
28
- try {
29
- const location = w.location;
30
- const parentLocation = w.parent.location;
31
- if (location.origin !== 'null' && parentLocation.origin !== 'null' && location.origin !== parentLocation.origin) {
32
- return null;
33
- }
34
- } catch (e) {
35
- return null;
36
- }
37
-
38
- return w.parent;
39
- }
40
-
41
- export class IframeUtils {
42
-
43
- /**
44
- * Returns a chain of embedded windows with the same origin (which can be accessed programmatically).
45
- * Having a chain of length 1 might mean that the current execution environment is running outside of an iframe or inside an iframe embedded in a window with a different origin.
46
- */
47
- private static getSameOriginWindowChain(targetWindow: Window): IWindowChainElement[] {
48
- let windowChainCache = sameOriginWindowChainCache.get(targetWindow);
49
- if (!windowChainCache) {
50
- windowChainCache = [];
51
- sameOriginWindowChainCache.set(targetWindow, windowChainCache);
52
- let w: Window | null = targetWindow;
53
- let parent: Window | null;
54
- do {
55
- parent = getParentWindowIfSameOrigin(w);
56
- if (parent) {
57
- windowChainCache.push({
58
- window: new WeakRef(w),
59
- iframeElement: w.frameElement || null
60
- });
61
- } else {
62
- windowChainCache.push({
63
- window: new WeakRef(w),
64
- iframeElement: null
65
- });
66
- }
67
- w = parent;
68
- } while (w);
69
- }
70
- return windowChainCache.slice(0);
71
- }
72
-
73
- /**
74
- * Returns the position of `childWindow` relative to `ancestorWindow`
75
- */
76
- public static getPositionOfChildWindowRelativeToAncestorWindow(childWindow: Window, ancestorWindow: Window | null) {
77
-
78
- if (!ancestorWindow || childWindow === ancestorWindow) {
79
- return {
80
- top: 0,
81
- left: 0
82
- };
83
- }
84
-
85
- let top = 0, left = 0;
86
-
87
- const windowChain = this.getSameOriginWindowChain(childWindow);
88
-
89
- for (const windowChainEl of windowChain) {
90
- const windowInChain = windowChainEl.window.deref();
91
- top += windowInChain?.scrollY ?? 0;
92
- left += windowInChain?.scrollX ?? 0;
93
-
94
- if (windowInChain === ancestorWindow) {
95
- break;
96
- }
97
-
98
- if (!windowChainEl.iframeElement) {
99
- break;
100
- }
101
-
102
- const boundingRect = windowChainEl.iframeElement.getBoundingClientRect();
103
- top += boundingRect.top;
104
- left += boundingRect.left;
105
- }
106
-
107
- return {
108
- top: top,
109
- left: left
110
- };
111
- }
112
- }
113
-
114
- /**
115
- * Returns a sha-256 composed of `parentOrigin` and `salt` converted to base 32
116
- */
117
- export async function parentOriginHash(parentOrigin: string, salt: string): Promise<string> {
118
- // This same code is also inlined at `src/vs/workbench/services/extensions/worker/webWorkerExtensionHostIframe.html`
119
- if (!crypto.subtle) {
120
- throw new Error(`'crypto.subtle' is not available so webviews will not work. This is likely because the editor is not running in a secure context (https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts).`);
121
- }
122
-
123
- const strData = JSON.stringify({ parentOrigin, salt });
124
- const encoder = new TextEncoder();
125
- const arrData = encoder.encode(strData);
126
- const hash = await crypto.subtle.digest('sha-256', arrData);
127
- return sha256AsBase32(hash);
128
- }
129
-
130
- function sha256AsBase32(bytes: ArrayBuffer): string {
131
- const array = Array.from(new Uint8Array(bytes));
132
- const hexArray = array.map(b => b.toString(16).padStart(2, '0')).join('');
133
- // sha256 has 256 bits, so we need at most ceil(lg(2^256-1)/lg(32)) = 52 chars to represent it in base 32
134
- return BigInt(`0x${hexArray}`).toString(32).padStart(52, '0');
135
- }