mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Remove vs/, fix lint and build
This commit is contained in:
@@ -15,7 +15,6 @@
|
||||
"paths": {
|
||||
"browser/*": [ "../../../src/browser/*" ],
|
||||
"common/*": [ "../../../src/common/*" ],
|
||||
"vs/*": [ "../../../src/vs/*" ],
|
||||
"@xterm/addon-image": [ "../typings/addon-image.d.ts" ]
|
||||
}
|
||||
},
|
||||
@@ -25,7 +24,6 @@
|
||||
],
|
||||
"references": [
|
||||
{ "path": "../../../src/browser" },
|
||||
{ "path": "../../../src/common" },
|
||||
{ "path": "../../../src/vs" }
|
||||
{ "path": "../../../src/common" }
|
||||
]
|
||||
}
|
||||
|
||||
@@ -21,9 +21,6 @@
|
||||
"browser/*": [
|
||||
"../../../src/browser/*"
|
||||
],
|
||||
"vs/*": [
|
||||
"../../../src/vs/*"
|
||||
],
|
||||
"@xterm/addon-progress": [
|
||||
"../typings/addon-progress.d.ts"
|
||||
]
|
||||
@@ -39,9 +36,6 @@
|
||||
},
|
||||
{
|
||||
"path": "../../../src/common"
|
||||
},
|
||||
{
|
||||
"path": "../../../src/vs"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -21,9 +21,6 @@
|
||||
"browser/*": [
|
||||
"../../../src/browser/*"
|
||||
],
|
||||
"vs/*": [
|
||||
"../../../src/vs/*"
|
||||
],
|
||||
"@xterm/addon-search" : [
|
||||
"../typings/addon-search.d.ts"
|
||||
]
|
||||
@@ -39,9 +36,6 @@
|
||||
},
|
||||
{
|
||||
"path": "../../../src/browser"
|
||||
},
|
||||
{
|
||||
"path": "../../../src/vs"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -18,9 +18,6 @@
|
||||
"browser/*": [
|
||||
"../../../src/browser/*"
|
||||
],
|
||||
"vs/*": [
|
||||
"../../../src/vs/*"
|
||||
],
|
||||
"@xterm/addon-webgl": [
|
||||
"../typings/addon-webgl.d.ts"
|
||||
]
|
||||
@@ -42,9 +39,6 @@
|
||||
},
|
||||
{
|
||||
"path": "../../../src/browser"
|
||||
},
|
||||
{
|
||||
"path": "../../../src/vs"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
+1
-3
@@ -191,9 +191,7 @@ if (config.addon) {
|
||||
entryPoints: [
|
||||
'src/browser/**/*.ts',
|
||||
'src/common/**/*.ts',
|
||||
'src/headless/**/*.ts',
|
||||
'src/vs/base/**/*.ts',
|
||||
'src/vs/patches/**/*.ts'
|
||||
'src/headless/**/*.ts'
|
||||
],
|
||||
outdir: 'out-esbuild/'
|
||||
};
|
||||
|
||||
@@ -10,7 +10,6 @@ export default tseslint.config(
|
||||
{
|
||||
ignores: [
|
||||
'addons/*/src/third-party/*.ts',
|
||||
'src/vs/*',
|
||||
'**/out/*',
|
||||
'**/out-test/*',
|
||||
'**/out-esbuild/*',
|
||||
|
||||
@@ -13,7 +13,7 @@ import { SmoothScrollableElement } from 'browser/scrollable/scrollableElement';
|
||||
import type { IScrollableElementChangeOptions } from 'browser/scrollable/scrollableElementOptions';
|
||||
import { Emitter, EventUtils } from 'common/Event';
|
||||
import { Scrollable, ScrollbarVisibility, type IScrollEvent } from 'browser/scrollable/scrollable';
|
||||
import { Gesture, EventType as GestureEventType, type GestureEvent } from 'browser/scrollable/touch';
|
||||
import { Gesture, EventType as GestureEventType, type IGestureEvent } from 'browser/scrollable/touch';
|
||||
|
||||
export class Viewport extends Disposable {
|
||||
|
||||
@@ -108,7 +108,7 @@ export class Viewport extends Disposable {
|
||||
|
||||
// Touch/gesture scrolling support
|
||||
this._register(Gesture.addTarget(screenElement));
|
||||
this._register(addDisposableListener(screenElement, GestureEventType.Change, (e: GestureEvent) => this._handleGestureChange(e)));
|
||||
this._register(addDisposableListener(screenElement, GestureEventType.CHANGE, (e: IGestureEvent) => this._handleGestureChange(e)));
|
||||
}
|
||||
|
||||
public scrollLines(disp: number): void {
|
||||
@@ -196,7 +196,7 @@ export class Viewport extends Disposable {
|
||||
this._isHandlingScroll = false;
|
||||
}
|
||||
|
||||
private _handleGestureChange(e: GestureEvent): void {
|
||||
private _handleGestureChange(e: IGestureEvent): void {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
const pos = this._scrollableElement.getScrollPosition();
|
||||
|
||||
@@ -88,7 +88,6 @@ export const eventType = {
|
||||
WHEEL: 'wheel'
|
||||
} as const;
|
||||
|
||||
export const EventType = eventType;
|
||||
|
||||
export function getDomNodePagePosition(domNode: HTMLElement): { left: number, top: number, width: number, height: number } {
|
||||
const bb = domNode.getBoundingClientRect();
|
||||
|
||||
@@ -69,7 +69,7 @@ export class GlobalPointerMoveMonitor implements IDisposable {
|
||||
|
||||
this._hooks.add(dom.addDisposableListener(
|
||||
eventSource,
|
||||
dom.EventType.POINTER_MOVE,
|
||||
dom.eventType.POINTER_MOVE,
|
||||
(e) => {
|
||||
if (e.buttons !== initialButtons) {
|
||||
this.stopMonitoring(true);
|
||||
@@ -83,7 +83,7 @@ export class GlobalPointerMoveMonitor implements IDisposable {
|
||||
|
||||
this._hooks.add(dom.addDisposableListener(
|
||||
eventSource,
|
||||
dom.EventType.POINTER_UP,
|
||||
dom.eventType.POINTER_UP,
|
||||
(e: PointerEvent) => this.stopMonitoring(true)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -24,14 +24,15 @@ function getParentWindowIfSameOrigin(w: Window): Window | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Cannot really tell if we have access to the parent window unless we try to access something in it
|
||||
// Cannot really tell if we have access to the parent window unless we try
|
||||
// to access something in it.
|
||||
try {
|
||||
const location = w.location;
|
||||
const parentLocation = w.parent.location;
|
||||
if (location.origin !== 'null' && parentLocation.origin !== 'null' && location.origin !== parentLocation.origin) {
|
||||
return null;
|
||||
}
|
||||
} catch (e) {
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -41,10 +42,12 @@ function getParentWindowIfSameOrigin(w: Window): Window | null {
|
||||
export class IframeUtils {
|
||||
|
||||
/**
|
||||
* Returns a chain of embedded windows with the same origin (which can be accessed programmatically).
|
||||
* 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.
|
||||
* Returns a chain of embedded windows with the same origin.
|
||||
* The chain can be accessed programmatically.
|
||||
* 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.
|
||||
*/
|
||||
private static getSameOriginWindowChain(targetWindow: Window): IWindowChainElement[] {
|
||||
private static _getSameOriginWindowChain(targetWindow: Window): IWindowChainElement[] {
|
||||
let windowChainCache = sameOriginWindowChainCache.get(targetWindow);
|
||||
if (!windowChainCache) {
|
||||
windowChainCache = [];
|
||||
@@ -56,7 +59,7 @@ export class IframeUtils {
|
||||
if (parent) {
|
||||
windowChainCache.push({
|
||||
window: new WeakRef(w),
|
||||
iframeElement: w.frameElement || null
|
||||
iframeElement: w.frameElement ?? null
|
||||
});
|
||||
} else {
|
||||
windowChainCache.push({
|
||||
@@ -73,7 +76,7 @@ export class IframeUtils {
|
||||
/**
|
||||
* Returns the position of `childWindow` relative to `ancestorWindow`
|
||||
*/
|
||||
public static getPositionOfChildWindowRelativeToAncestorWindow(childWindow: Window, ancestorWindow: Window | null) {
|
||||
public static getPositionOfChildWindowRelativeToAncestorWindow(childWindow: Window, ancestorWindow: Window | null): { top: number, left: number } {
|
||||
|
||||
if (!ancestorWindow || childWindow === ancestorWindow) {
|
||||
return {
|
||||
@@ -84,7 +87,7 @@ export class IframeUtils {
|
||||
|
||||
let top = 0; let left = 0;
|
||||
|
||||
const windowChain = this.getSameOriginWindowChain(childWindow);
|
||||
const windowChain = this._getSameOriginWindowChain(childWindow);
|
||||
|
||||
for (const windowChainEl of windowChain) {
|
||||
const windowInChain = windowChainEl.window.deref();
|
||||
|
||||
@@ -118,8 +118,8 @@ export class StandardWheelEvent {
|
||||
|
||||
constructor(e: IMouseWheelEvent | null, deltaX: number = 0, deltaY: number = 0) {
|
||||
|
||||
this.browserEvent = e || null;
|
||||
this.target = e ? (e.target || (e as any).targetNode || e.srcElement) : null;
|
||||
this.browserEvent = e ?? null;
|
||||
this.target = e ? (e.target ?? (e as any).targetNode ?? e.srcElement ?? null) : null;
|
||||
|
||||
this.deltaY = deltaY;
|
||||
this.deltaX = deltaX;
|
||||
|
||||
@@ -189,7 +189,7 @@ export abstract class AbstractScrollableElement extends Widget {
|
||||
return this._options;
|
||||
}
|
||||
|
||||
protected constructor(element: HTMLElement, options: IScrollableElementCreationOptions, scrollable: Scrollable) {
|
||||
public constructor(element: HTMLElement, options: IScrollableElementCreationOptions, scrollable: Scrollable) {
|
||||
super();
|
||||
this._options = resolveOptions(options);
|
||||
this._scrollable = scrollable;
|
||||
@@ -234,7 +234,7 @@ export abstract class AbstractScrollableElement extends Widget {
|
||||
this._topLeftShadowDomNode = null;
|
||||
}
|
||||
|
||||
this._listenOnDomNode = this._options.listenOnDomNode || this._domNode;
|
||||
this._listenOnDomNode = this._options.listenOnDomNode ?? this._domNode;
|
||||
|
||||
this._mouseWheelToDispose = [];
|
||||
this._setListeningToMouseWheel(this._options.handleMouseWheel);
|
||||
@@ -344,7 +344,7 @@ export abstract class AbstractScrollableElement extends Widget {
|
||||
this._mouseWheelToDispose = dispose(this._mouseWheelToDispose);
|
||||
|
||||
if (shouldListen) {
|
||||
const onMouseWheel = (browserEvent: IMouseWheelEvent) => {
|
||||
const onMouseWheel = (browserEvent: IMouseWheelEvent): void => {
|
||||
this._handleMouseWheel(new StandardWheelEvent(browserEvent));
|
||||
};
|
||||
|
||||
@@ -557,10 +557,6 @@ export class ScrollableElement extends AbstractScrollableElement {
|
||||
|
||||
export class SmoothScrollableElement extends AbstractScrollableElement {
|
||||
|
||||
constructor(element: HTMLElement, options: IScrollableElementCreationOptions, scrollable: Scrollable) {
|
||||
super(element, options, scrollable);
|
||||
}
|
||||
|
||||
public setScrollPosition(update: INewScrollPosition & { reuseAnimation?: boolean }): void {
|
||||
if (update.reuseAnimation) {
|
||||
this._scrollable.setScrollPositionSmooth(update, update.reuseAnimation);
|
||||
|
||||
@@ -73,8 +73,8 @@ export interface IScrollableElementCreationOptions {
|
||||
*/
|
||||
arrowSize?: number;
|
||||
/**
|
||||
* The dom node events should be bound to.
|
||||
* If no listenOnDomNode is provided, the constructor dom node is used.
|
||||
* The dom node events should be bound to.
|
||||
* If no listenOnDomNode is provided, the constructor dom node is used.
|
||||
*/
|
||||
listenOnDomNode?: HTMLElement;
|
||||
/**
|
||||
|
||||
@@ -12,14 +12,14 @@ import { Disposable, IDisposable, toDisposable } from 'common/Lifecycle';
|
||||
import { LinkedList } from './linkedList';
|
||||
|
||||
export namespace EventType {
|
||||
export const Tap = '-xterm-gesturetap';
|
||||
export const Change = '-xterm-gesturechange';
|
||||
export const Start = '-xterm-gesturestart';
|
||||
export const End = '-xterm-gesturesend';
|
||||
export const Contextmenu = '-xterm-gesturecontextmenu';
|
||||
export const TAP = '-xterm-gesturetap';
|
||||
export const CHANGE = '-xterm-gesturechange';
|
||||
export const START = '-xterm-gesturestart';
|
||||
export const END = '-xterm-gesturesend';
|
||||
export const CONTEXT_MENU = '-xterm-gesturecontextmenu';
|
||||
}
|
||||
|
||||
interface TouchData {
|
||||
interface ITouchData {
|
||||
id: number;
|
||||
initialTarget: EventTarget;
|
||||
initialTimeStamp: number;
|
||||
@@ -30,7 +30,7 @@ interface TouchData {
|
||||
rollingPageY: number[];
|
||||
}
|
||||
|
||||
export interface GestureEvent extends MouseEvent {
|
||||
export interface IGestureEvent extends MouseEvent {
|
||||
initialTarget: EventTarget | undefined;
|
||||
translationX: number;
|
||||
translationY: number;
|
||||
@@ -39,7 +39,7 @@ export interface GestureEvent extends MouseEvent {
|
||||
tapCount: number;
|
||||
}
|
||||
|
||||
interface Touch {
|
||||
interface ITouch {
|
||||
identifier: number;
|
||||
screenX: number;
|
||||
screenY: number;
|
||||
@@ -54,48 +54,48 @@ interface Touch {
|
||||
target: Element;
|
||||
}
|
||||
|
||||
interface TouchList {
|
||||
[i: number]: Touch;
|
||||
interface ITouchList {
|
||||
[i: number]: ITouch;
|
||||
length: number;
|
||||
item(index: number): Touch;
|
||||
identifiedTouch(id: number): Touch;
|
||||
item(index: number): ITouch;
|
||||
identifiedTouch(id: number): ITouch;
|
||||
}
|
||||
|
||||
interface TouchEvent extends Event {
|
||||
touches: TouchList;
|
||||
targetTouches: TouchList;
|
||||
changedTouches: TouchList;
|
||||
interface ITouchEvent extends Event {
|
||||
touches: ITouchList;
|
||||
targetTouches: ITouchList;
|
||||
changedTouches: ITouchList;
|
||||
}
|
||||
|
||||
export class Gesture extends Disposable {
|
||||
|
||||
private static readonly SCROLL_FRICTION = -0.005;
|
||||
private static INSTANCE: Gesture;
|
||||
private static readonly HOLD_DELAY = 700;
|
||||
private static readonly _scrollFriction = -0.005;
|
||||
private static _instance: Gesture;
|
||||
private static readonly _holdDelay = 700;
|
||||
|
||||
private dispatched = false;
|
||||
private readonly targets = new LinkedList<HTMLElement>();
|
||||
private readonly ignoreTargets = new LinkedList<HTMLElement>();
|
||||
private handle: IDisposable | null;
|
||||
private _dispatched = false;
|
||||
private readonly _targets = new LinkedList<HTMLElement>();
|
||||
private readonly _ignoreTargets = new LinkedList<HTMLElement>();
|
||||
private _handle: IDisposable | null;
|
||||
|
||||
private readonly activeTouches: { [id: number]: TouchData };
|
||||
private readonly _activeTouches: { [id: number]: ITouchData };
|
||||
|
||||
private _lastSetTapCountTime: number;
|
||||
|
||||
private static readonly CLEAR_TAP_COUNT_TIME = 400; // ms
|
||||
private static readonly _clearTapCountTime = 400; // ms
|
||||
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
|
||||
this.activeTouches = {};
|
||||
this.handle = null;
|
||||
this._activeTouches = {};
|
||||
this._handle = null;
|
||||
this._lastSetTapCountTime = 0;
|
||||
|
||||
this._register(EventUtils.runAndSubscribe(DomUtils.onDidRegisterWindow, ({ window, disposables }) => {
|
||||
disposables.add(DomUtils.addDisposableListener(window.document, 'touchstart', (e: TouchEvent) => this.onTouchStart(e), { passive: false }));
|
||||
disposables.add(DomUtils.addDisposableListener(window.document, 'touchend', (e: TouchEvent) => this.onTouchEnd(window, e)));
|
||||
disposables.add(DomUtils.addDisposableListener(window.document, 'touchmove', (e: TouchEvent) => this.onTouchMove(e), { passive: false }));
|
||||
disposables.add(DomUtils.addDisposableListener(window.document, 'touchstart', (e: ITouchEvent) => this._handleTouchStart(e), { passive: false }));
|
||||
disposables.add(DomUtils.addDisposableListener(window.document, 'touchend', (e: ITouchEvent) => this._handleTouchEnd(window, e)));
|
||||
disposables.add(DomUtils.addDisposableListener(window.document, 'touchmove', (e: ITouchEvent) => this._handleTouchMove(e), { passive: false }));
|
||||
}, { window: mainWindow, disposables: this._store }));
|
||||
}
|
||||
|
||||
@@ -103,11 +103,11 @@ export class Gesture extends Disposable {
|
||||
if (!Gesture.isTouchDevice()) {
|
||||
return Disposable.None;
|
||||
}
|
||||
if (!Gesture.INSTANCE) {
|
||||
Gesture.INSTANCE = new Gesture();
|
||||
if (!Gesture._instance) {
|
||||
Gesture._instance = new Gesture();
|
||||
}
|
||||
|
||||
const remove = Gesture.INSTANCE.targets.push(element);
|
||||
const remove = Gesture._instance._targets.push(element);
|
||||
return toDisposable(remove);
|
||||
}
|
||||
|
||||
@@ -115,40 +115,40 @@ export class Gesture extends Disposable {
|
||||
if (!Gesture.isTouchDevice()) {
|
||||
return Disposable.None;
|
||||
}
|
||||
if (!Gesture.INSTANCE) {
|
||||
Gesture.INSTANCE = new Gesture();
|
||||
if (!Gesture._instance) {
|
||||
Gesture._instance = new Gesture();
|
||||
}
|
||||
|
||||
const remove = Gesture.INSTANCE.ignoreTargets.push(element);
|
||||
const remove = Gesture._instance._ignoreTargets.push(element);
|
||||
return toDisposable(remove);
|
||||
}
|
||||
|
||||
@memoize
|
||||
static isTouchDevice(): boolean {
|
||||
public static isTouchDevice(): boolean {
|
||||
return 'ontouchstart' in mainWindow || navigator.maxTouchPoints > 0;
|
||||
}
|
||||
|
||||
public override dispose(): void {
|
||||
if (this.handle) {
|
||||
this.handle.dispose();
|
||||
this.handle = null;
|
||||
if (this._handle) {
|
||||
this._handle.dispose();
|
||||
this._handle = null;
|
||||
}
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
private onTouchStart(e: TouchEvent): void {
|
||||
private _handleTouchStart(e: ITouchEvent): void {
|
||||
const timestamp = Date.now();
|
||||
|
||||
if (this.handle) {
|
||||
this.handle.dispose();
|
||||
this.handle = null;
|
||||
if (this._handle) {
|
||||
this._handle.dispose();
|
||||
this._handle = null;
|
||||
}
|
||||
|
||||
for (let i = 0, len = e.targetTouches.length; i < len; i++) {
|
||||
const touch = e.targetTouches.item(i);
|
||||
|
||||
this.activeTouches[touch.identifier] = {
|
||||
this._activeTouches[touch.identifier] = {
|
||||
id: touch.identifier,
|
||||
initialTarget: touch.target,
|
||||
initialTimeStamp: timestamp,
|
||||
@@ -159,53 +159,53 @@ export class Gesture extends Disposable {
|
||||
rollingPageY: [touch.pageY]
|
||||
};
|
||||
|
||||
const evt = this.newGestureEvent(EventType.Start, touch.target);
|
||||
const evt = this._newGestureEvent(EventType.START, touch.target);
|
||||
evt.pageX = touch.pageX;
|
||||
evt.pageY = touch.pageY;
|
||||
this.dispatchEvent(evt);
|
||||
this._dispatchEvent(evt);
|
||||
}
|
||||
|
||||
if (this.dispatched) {
|
||||
if (this._dispatched) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.dispatched = false;
|
||||
this._dispatched = false;
|
||||
}
|
||||
}
|
||||
|
||||
private onTouchEnd(targetWindow: Window, e: TouchEvent): void {
|
||||
private _handleTouchEnd(targetWindow: Window, e: ITouchEvent): void {
|
||||
const timestamp = Date.now();
|
||||
|
||||
const activeTouchCount = Object.keys(this.activeTouches).length;
|
||||
const activeTouchCount = Object.keys(this._activeTouches).length;
|
||||
|
||||
for (let i = 0, len = e.changedTouches.length; i < len; i++) {
|
||||
|
||||
const touch = e.changedTouches.item(i);
|
||||
|
||||
if (!this.activeTouches.hasOwnProperty(String(touch.identifier))) {
|
||||
if (!this._activeTouches.hasOwnProperty(String(touch.identifier))) {
|
||||
console.warn('move of an UNKNOWN touch', touch);
|
||||
continue;
|
||||
}
|
||||
|
||||
const data = this.activeTouches[touch.identifier];
|
||||
const data = this._activeTouches[touch.identifier];
|
||||
const holdTime = Date.now() - data.initialTimeStamp;
|
||||
|
||||
if (holdTime < Gesture.HOLD_DELAY
|
||||
if (holdTime < Gesture._holdDelay
|
||||
&& Math.abs(data.initialPageX - arrays.tail(data.rollingPageX)!) < 30
|
||||
&& Math.abs(data.initialPageY - arrays.tail(data.rollingPageY)!) < 30) {
|
||||
|
||||
const evt = this.newGestureEvent(EventType.Tap, data.initialTarget);
|
||||
const evt = this._newGestureEvent(EventType.TAP, data.initialTarget);
|
||||
evt.pageX = arrays.tail(data.rollingPageX)!;
|
||||
evt.pageY = arrays.tail(data.rollingPageY)!;
|
||||
this.dispatchEvent(evt);
|
||||
this._dispatchEvent(evt);
|
||||
|
||||
} else if (holdTime >= Gesture.HOLD_DELAY
|
||||
} else if (holdTime >= Gesture._holdDelay
|
||||
&& Math.abs(data.initialPageX - arrays.tail(data.rollingPageX)!) < 30
|
||||
&& Math.abs(data.initialPageY - arrays.tail(data.rollingPageY)!) < 30) {
|
||||
|
||||
const evt = this.newGestureEvent(EventType.Contextmenu, data.initialTarget);
|
||||
const evt = this._newGestureEvent(EventType.CONTEXT_MENU, data.initialTarget);
|
||||
evt.pageX = arrays.tail(data.rollingPageX)!;
|
||||
evt.pageY = arrays.tail(data.rollingPageY)!;
|
||||
this.dispatchEvent(evt);
|
||||
this._dispatchEvent(evt);
|
||||
|
||||
} else if (activeTouchCount === 1) {
|
||||
const finalX = arrays.tail(data.rollingPageX)!;
|
||||
@@ -215,8 +215,8 @@ export class Gesture extends Disposable {
|
||||
const deltaX = finalX - data.rollingPageX[0];
|
||||
const deltaY = finalY - data.rollingPageY[0];
|
||||
|
||||
const dispatchTo = [...this.targets].filter(t => data.initialTarget instanceof Node && t.contains(data.initialTarget));
|
||||
this.inertia(targetWindow, dispatchTo, timestamp,
|
||||
const dispatchTo = [...this._targets].filter(t => data.initialTarget instanceof Node && t.contains(data.initialTarget));
|
||||
this._inertia(targetWindow, dispatchTo, timestamp,
|
||||
Math.abs(deltaX) / deltaT,
|
||||
deltaX > 0 ? 1 : -1,
|
||||
finalX,
|
||||
@@ -227,30 +227,30 @@ export class Gesture extends Disposable {
|
||||
}
|
||||
|
||||
|
||||
this.dispatchEvent(this.newGestureEvent(EventType.End, data.initialTarget));
|
||||
delete this.activeTouches[touch.identifier];
|
||||
this._dispatchEvent(this._newGestureEvent(EventType.END, data.initialTarget));
|
||||
delete this._activeTouches[touch.identifier];
|
||||
}
|
||||
|
||||
if (this.dispatched) {
|
||||
if (this._dispatched) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.dispatched = false;
|
||||
this._dispatched = false;
|
||||
}
|
||||
}
|
||||
|
||||
private newGestureEvent(type: string, initialTarget?: EventTarget): GestureEvent {
|
||||
const event = document.createEvent('CustomEvent') as unknown as GestureEvent;
|
||||
private _newGestureEvent(type: string, initialTarget?: EventTarget): IGestureEvent {
|
||||
const event = document.createEvent('CustomEvent') as unknown as IGestureEvent;
|
||||
event.initEvent(type, false, true);
|
||||
event.initialTarget = initialTarget;
|
||||
event.tapCount = 0;
|
||||
return event;
|
||||
}
|
||||
|
||||
private dispatchEvent(event: GestureEvent): void {
|
||||
if (event.type === EventType.Tap) {
|
||||
private _dispatchEvent(event: IGestureEvent): void {
|
||||
if (event.type === EventType.TAP) {
|
||||
const currentTime = (new Date()).getTime();
|
||||
let setTapCount = 0;
|
||||
if (currentTime - this._lastSetTapCountTime > Gesture.CLEAR_TAP_COUNT_TIME) {
|
||||
if (currentTime - this._lastSetTapCountTime > Gesture._clearTapCountTime) {
|
||||
setTapCount = 1;
|
||||
} else {
|
||||
setTapCount = 2;
|
||||
@@ -258,19 +258,19 @@ export class Gesture extends Disposable {
|
||||
|
||||
this._lastSetTapCountTime = currentTime;
|
||||
event.tapCount = setTapCount;
|
||||
} else if (event.type === EventType.Change || event.type === EventType.Contextmenu) {
|
||||
} else if (event.type === EventType.CHANGE || event.type === EventType.CONTEXT_MENU) {
|
||||
this._lastSetTapCountTime = 0;
|
||||
}
|
||||
|
||||
if (event.initialTarget instanceof Node) {
|
||||
for (const ignoreTarget of this.ignoreTargets) {
|
||||
for (const ignoreTarget of this._ignoreTargets) {
|
||||
if (ignoreTarget.contains(event.initialTarget)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const targets: [number, HTMLElement][] = [];
|
||||
for (const target of this.targets) {
|
||||
for (const target of this._targets) {
|
||||
if (target.contains(event.initialTarget)) {
|
||||
let depth = 0;
|
||||
let now: Node | null = event.initialTarget;
|
||||
@@ -284,65 +284,66 @@ export class Gesture extends Disposable {
|
||||
|
||||
targets.sort((a, b) => a[0] - b[0]);
|
||||
|
||||
for (const [_, target] of targets) {
|
||||
for (const [, target] of targets) {
|
||||
target.dispatchEvent(event);
|
||||
this.dispatched = true;
|
||||
this._dispatched = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private inertia(targetWindow: Window, dispatchTo: ReadonlyArray<EventTarget>, t1: number, vX: number, dirX: number, x: number, vY: number, dirY: number, y: number): void {
|
||||
this.handle = DomUtils.scheduleAtNextAnimationFrame(targetWindow, () => {
|
||||
private _inertia(targetWindow: Window, dispatchTo: ReadonlyArray<EventTarget>, t1: number, vX: number, dirX: number, x: number, vY: number, dirY: number, y: number): void {
|
||||
this._handle = DomUtils.scheduleAtNextAnimationFrame(targetWindow, () => {
|
||||
const now = Date.now();
|
||||
|
||||
const deltaT = now - t1;
|
||||
let delta_pos_x = 0; let delta_pos_y = 0;
|
||||
let deltaPosX = 0;
|
||||
let deltaPosY = 0;
|
||||
let stopped = true;
|
||||
|
||||
vX += Gesture.SCROLL_FRICTION * deltaT;
|
||||
vY += Gesture.SCROLL_FRICTION * deltaT;
|
||||
vX += Gesture._scrollFriction * deltaT;
|
||||
vY += Gesture._scrollFriction * deltaT;
|
||||
|
||||
if (vX > 0) {
|
||||
stopped = false;
|
||||
delta_pos_x = dirX * vX * deltaT;
|
||||
deltaPosX = dirX * vX * deltaT;
|
||||
}
|
||||
|
||||
if (vY > 0) {
|
||||
stopped = false;
|
||||
delta_pos_y = dirY * vY * deltaT;
|
||||
deltaPosY = dirY * vY * deltaT;
|
||||
}
|
||||
|
||||
const evt = this.newGestureEvent(EventType.Change);
|
||||
evt.translationX = delta_pos_x;
|
||||
evt.translationY = delta_pos_y;
|
||||
const evt = this._newGestureEvent(EventType.CHANGE);
|
||||
evt.translationX = deltaPosX;
|
||||
evt.translationY = deltaPosY;
|
||||
dispatchTo.forEach(d => d.dispatchEvent(evt));
|
||||
|
||||
if (!stopped) {
|
||||
this.inertia(targetWindow, dispatchTo, now, vX, dirX, x + delta_pos_x, vY, dirY, y + delta_pos_y);
|
||||
this._inertia(targetWindow, dispatchTo, now, vX, dirX, x + deltaPosX, vY, dirY, y + deltaPosY);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private onTouchMove(e: TouchEvent): void {
|
||||
private _handleTouchMove(e: ITouchEvent): void {
|
||||
const timestamp = Date.now();
|
||||
|
||||
for (let i = 0, len = e.changedTouches.length; i < len; i++) {
|
||||
|
||||
const touch = e.changedTouches.item(i);
|
||||
|
||||
if (!this.activeTouches.hasOwnProperty(String(touch.identifier))) {
|
||||
if (!this._activeTouches.hasOwnProperty(String(touch.identifier))) {
|
||||
console.warn('end of an UNKNOWN touch', touch);
|
||||
continue;
|
||||
}
|
||||
|
||||
const data = this.activeTouches[touch.identifier];
|
||||
const data = this._activeTouches[touch.identifier];
|
||||
|
||||
const evt = this.newGestureEvent(EventType.Change, data.initialTarget);
|
||||
const evt = this._newGestureEvent(EventType.CHANGE, data.initialTarget);
|
||||
evt.translationX = touch.pageX - arrays.tail(data.rollingPageX)!;
|
||||
evt.translationY = touch.pageY - arrays.tail(data.rollingPageY)!;
|
||||
evt.pageX = touch.pageX;
|
||||
evt.pageY = touch.pageY;
|
||||
this.dispatchEvent(evt);
|
||||
this._dispatchEvent(evt);
|
||||
|
||||
if (data.rollingPageX.length > 3) {
|
||||
data.rollingPageX.shift();
|
||||
@@ -355,10 +356,10 @@ export class Gesture extends Disposable {
|
||||
data.rollingTimestamps.push(timestamp);
|
||||
}
|
||||
|
||||
if (this.dispatched) {
|
||||
if (this._dispatched) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.dispatched = false;
|
||||
this._dispatched = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,43 +12,43 @@ import { Disposable, IDisposable } from 'common/Lifecycle';
|
||||
export abstract class Widget extends Disposable {
|
||||
|
||||
protected _onclick(domNode: HTMLElement, listener: (e: IMouseEvent) => void): void {
|
||||
this._register(dom.addDisposableListener(domNode, dom.EventType.CLICK, (e: MouseEvent) => listener(new StandardMouseEvent(dom.getWindow(domNode), e))));
|
||||
this._register(dom.addDisposableListener(domNode, dom.eventType.CLICK, (e: MouseEvent) => listener(new StandardMouseEvent(dom.getWindow(domNode), e))));
|
||||
}
|
||||
|
||||
protected _onmousedown(domNode: HTMLElement, listener: (e: IMouseEvent) => void): void {
|
||||
this._register(dom.addDisposableListener(domNode, dom.EventType.MOUSE_DOWN, (e: MouseEvent) => listener(new StandardMouseEvent(dom.getWindow(domNode), e))));
|
||||
this._register(dom.addDisposableListener(domNode, dom.eventType.MOUSE_DOWN, (e: MouseEvent) => listener(new StandardMouseEvent(dom.getWindow(domNode), e))));
|
||||
}
|
||||
|
||||
protected _onmouseover(domNode: HTMLElement, listener: (e: IMouseEvent) => void): void {
|
||||
this._register(dom.addDisposableListener(domNode, dom.EventType.MOUSE_OVER, (e: MouseEvent) => listener(new StandardMouseEvent(dom.getWindow(domNode), e))));
|
||||
this._register(dom.addDisposableListener(domNode, dom.eventType.MOUSE_OVER, (e: MouseEvent) => listener(new StandardMouseEvent(dom.getWindow(domNode), e))));
|
||||
}
|
||||
|
||||
protected _onmouseleave(domNode: HTMLElement, listener: (e: IMouseEvent) => void): void {
|
||||
this._register(dom.addDisposableListener(domNode, dom.EventType.MOUSE_LEAVE, (e: MouseEvent) => listener(new StandardMouseEvent(dom.getWindow(domNode), e))));
|
||||
this._register(dom.addDisposableListener(domNode, dom.eventType.MOUSE_LEAVE, (e: MouseEvent) => listener(new StandardMouseEvent(dom.getWindow(domNode), e))));
|
||||
}
|
||||
|
||||
protected _onkeydown(domNode: HTMLElement, listener: (e: IKeyboardEvent) => void): void {
|
||||
this._register(dom.addDisposableListener(domNode, dom.EventType.KEY_DOWN, (e: KeyboardEvent) => listener(new StandardKeyboardEvent(e))));
|
||||
this._register(dom.addDisposableListener(domNode, dom.eventType.KEY_DOWN, (e: KeyboardEvent) => listener(new StandardKeyboardEvent(e))));
|
||||
}
|
||||
|
||||
protected _onkeyup(domNode: HTMLElement, listener: (e: IKeyboardEvent) => void): void {
|
||||
this._register(dom.addDisposableListener(domNode, dom.EventType.KEY_UP, (e: KeyboardEvent) => listener(new StandardKeyboardEvent(e))));
|
||||
this._register(dom.addDisposableListener(domNode, dom.eventType.KEY_UP, (e: KeyboardEvent) => listener(new StandardKeyboardEvent(e))));
|
||||
}
|
||||
|
||||
protected _oninput(domNode: HTMLElement, listener: (e: Event) => void): void {
|
||||
this._register(dom.addDisposableListener(domNode, dom.EventType.INPUT, listener));
|
||||
this._register(dom.addDisposableListener(domNode, dom.eventType.INPUT, listener));
|
||||
}
|
||||
|
||||
protected _onblur(domNode: HTMLElement, listener: (e: Event) => void): void {
|
||||
this._register(dom.addDisposableListener(domNode, dom.EventType.BLUR, listener));
|
||||
this._register(dom.addDisposableListener(domNode, dom.eventType.BLUR, listener));
|
||||
}
|
||||
|
||||
protected _onfocus(domNode: HTMLElement, listener: (e: Event) => void): void {
|
||||
this._register(dom.addDisposableListener(domNode, dom.EventType.FOCUS, listener));
|
||||
this._register(dom.addDisposableListener(domNode, dom.eventType.FOCUS, listener));
|
||||
}
|
||||
|
||||
protected _onchange(domNode: HTMLElement, listener: (e: Event) => void): void {
|
||||
this._register(dom.addDisposableListener(domNode, dom.EventType.CHANGE, listener));
|
||||
this._register(dom.addDisposableListener(domNode, dom.eventType.CHANGE, listener));
|
||||
}
|
||||
|
||||
protected _ignoreGesture(domNode: HTMLElement): IDisposable {
|
||||
|
||||
@@ -11,8 +11,7 @@
|
||||
],
|
||||
"baseUrl": "..",
|
||||
"paths": {
|
||||
"common/*": [ "./common/*" ],
|
||||
"vs/*": [ "./vs/*" ]
|
||||
"common/*": [ "./common/*" ]
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
@@ -20,7 +19,6 @@
|
||||
"../../typings/xterm.d.ts"
|
||||
],
|
||||
"references": [
|
||||
{ "path": "../common" },
|
||||
{ "path": "../vs" }
|
||||
{ "path": "../common" }
|
||||
]
|
||||
}
|
||||
|
||||
+7
-7
@@ -36,19 +36,19 @@ export class TimeoutTimer implements IDisposable {
|
||||
private _token: any = -1;
|
||||
private _isDisposed = false;
|
||||
|
||||
dispose(): void {
|
||||
public dispose(): void {
|
||||
this.cancel();
|
||||
this._isDisposed = true;
|
||||
}
|
||||
|
||||
cancel(): void {
|
||||
public cancel(): void {
|
||||
if (this._token !== -1) {
|
||||
clearTimeout(this._token);
|
||||
this._token = -1;
|
||||
}
|
||||
}
|
||||
|
||||
cancelAndSet(runner: () => void, timeout: number): void {
|
||||
public cancelAndSet(runner: () => void, timeout: number): void {
|
||||
if (this._isDisposed) {
|
||||
throw new Error('Calling cancelAndSet on a disposed TimeoutTimer');
|
||||
}
|
||||
@@ -59,7 +59,7 @@ export class TimeoutTimer implements IDisposable {
|
||||
}, timeout);
|
||||
}
|
||||
|
||||
setIfNotSet(runner: () => void, timeout: number): void {
|
||||
public setIfNotSet(runner: () => void, timeout: number): void {
|
||||
if (this._isDisposed) {
|
||||
throw new Error('Calling setIfNotSet on a disposed TimeoutTimer');
|
||||
}
|
||||
@@ -77,12 +77,12 @@ export class IntervalTimer implements IDisposable {
|
||||
private _disposable: IDisposable | undefined;
|
||||
private _isDisposed = false;
|
||||
|
||||
cancel(): void {
|
||||
public cancel(): void {
|
||||
this._disposable?.dispose();
|
||||
this._disposable = undefined;
|
||||
}
|
||||
|
||||
cancelAndSet(runner: () => void, interval: number, context: Window | typeof globalThis = globalThis): void {
|
||||
public cancelAndSet(runner: () => void, interval: number, context: Window | typeof globalThis = globalThis): void {
|
||||
if (this._isDisposed) {
|
||||
throw new Error('Calling cancelAndSet on a disposed IntervalTimer');
|
||||
}
|
||||
@@ -98,7 +98,7 @@ export class IntervalTimer implements IDisposable {
|
||||
};
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
public dispose(): void {
|
||||
this.cancel();
|
||||
this._isDisposed = true;
|
||||
}
|
||||
|
||||
@@ -12,8 +12,7 @@
|
||||
],
|
||||
"baseUrl": "../",
|
||||
"paths": {
|
||||
"common/*": [ "./common/*" ],
|
||||
"vs/*": [ "./vs/*" ]
|
||||
"common/*": [ "./common/*" ]
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
@@ -22,7 +21,6 @@
|
||||
"../../typings/xterm-headless.d.ts"
|
||||
],
|
||||
"references": [
|
||||
{ "path": "../common" },
|
||||
{ "path": "../vs" }
|
||||
{ "path": "../common" }
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
temp/
|
||||
|
||||
# Tests
|
||||
base/test/
|
||||
base/**/test/
|
||||
|
||||
# Unwanted modules
|
||||
base/node/
|
||||
base/parts/
|
||||
base/worker/
|
||||
|
||||
# Binary files
|
||||
base/browser/ui/codicons/codicon/codicon.ttf
|
||||
@@ -1,23 +0,0 @@
|
||||
This folder contains the `base/` module from the [Visual Studio Code repository](https://github.com/microsoft/vscode) which has many helpers that are useful to xterm.js.
|
||||
|
||||
Rarely we want to update these sources when an important bug is fixed upstream or when there is a new feature we want to leverage. To update against upstream:
|
||||
|
||||
```
|
||||
./bin/vs_base_update.ps1
|
||||
```
|
||||
|
||||
If new functions are being used from the project then import them from another project.
|
||||
|
||||
Before committing we need to clean up the diff so that files that aren't being used are not inlcuded. The following script uses the typescript compiler to find any files that are not being imported into the project:
|
||||
|
||||
```
|
||||
node ./bin/vs_base_find_unused.js
|
||||
```
|
||||
|
||||
The last step is to do a once over of the resulting bundled xterm.js file to ensure it isn't too large:
|
||||
|
||||
1. Run `npm run esbuild`
|
||||
2. Open up `xterm.mjs`
|
||||
3. Search for `src/vs/base/`
|
||||
|
||||
This will show you all the parts of base that will be included in the final minified bundle. Unfortunately tree shaking doesn't find everything, be on the lookout for large arrays or classes that aren't being used. If your editor has find decorations in the scroll bar it's easy to find which parts of base are consuming a lot of lines.
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user