Version 1.0.2 mit node_modules Verzeichnis

This commit is contained in:
ISA
2024-10-02 07:58:24 +02:00
parent f353a06b1b
commit 62b6e55a0a
68228 changed files with 4548477 additions and 651 deletions

View File

@@ -0,0 +1,44 @@
'use strict';
var keyboard = require('./keyboard.js');
var index = require('./pointer/index.js');
function _define_property(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
/**
* @internal Do not create/alter this by yourself as this type might be subject to changes.
*/ class System {
getUIEventModifiers() {
return {
altKey: this.keyboard.modifiers.Alt,
ctrlKey: this.keyboard.modifiers.Control,
metaKey: this.keyboard.modifiers.Meta,
shiftKey: this.keyboard.modifiers.Shift,
modifierAltGraph: this.keyboard.modifiers.AltGraph,
modifierCapsLock: this.keyboard.modifiers.CapsLock,
modifierFn: this.keyboard.modifiers.Fn,
modifierFnLock: this.keyboard.modifiers.FnLock,
modifierNumLock: this.keyboard.modifiers.NumLock,
modifierScrollLock: this.keyboard.modifiers.ScrollLock,
modifierSymbol: this.keyboard.modifiers.Symbol,
modifierSymbolLock: this.keyboard.modifiers.SymbolLock
};
}
constructor(){
_define_property(this, "keyboard", new keyboard.KeyboardHost(this));
_define_property(this, "pointer", new index.PointerHost(this));
}
}
exports.System = System;

View File

@@ -0,0 +1,147 @@
'use strict';
require('../utils/click/isClickableInput.js');
require('../utils/dataTransfer/Clipboard.js');
require('../utils/edit/isEditable.js');
require('../utils/edit/maxLength.js');
var getActiveElement = require('../utils/focus/getActiveElement.js');
require('../utils/keyDef/readNextDescriptor.js');
require('../utils/misc/level.js');
require('../options.js');
function _define_property(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
exports.DOM_KEY_LOCATION = void 0;
(function(DOM_KEY_LOCATION) {
DOM_KEY_LOCATION[DOM_KEY_LOCATION["STANDARD"] = 0] = "STANDARD";
DOM_KEY_LOCATION[DOM_KEY_LOCATION["LEFT"] = 1] = "LEFT";
DOM_KEY_LOCATION[DOM_KEY_LOCATION["RIGHT"] = 2] = "RIGHT";
DOM_KEY_LOCATION[DOM_KEY_LOCATION["NUMPAD"] = 3] = "NUMPAD";
})(exports.DOM_KEY_LOCATION || (exports.DOM_KEY_LOCATION = {}));
const modifierKeys = [
'Alt',
'AltGraph',
'Control',
'Fn',
'Meta',
'Shift',
'Symbol'
];
function isModifierKey(key) {
return modifierKeys.includes(key);
}
const modifierLocks = [
'CapsLock',
'FnLock',
'NumLock',
'ScrollLock',
'SymbolLock'
];
function isModifierLock(key) {
return modifierLocks.includes(key);
}
class KeyboardHost {
isKeyPressed(keyDef) {
return !!this.pressed[String(keyDef.code)];
}
getPressedKeys() {
return Object.values(this.pressed).map((p)=>p.keyDef);
}
/** Press a key */ async keydown(instance, keyDef) {
var // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
_this_pressed, _code, _this_pressed_code;
const key = String(keyDef.key);
const code = String(keyDef.code);
const target = getActiveElement.getActiveElementOrBody(instance.config.document);
this.setKeydownTarget(target);
var _;
(_ = (_this_pressed = this.pressed)[_code = code]) !== null && _ !== void 0 ? _ : _this_pressed[_code] = {
keyDef,
unpreventedDefault: false
};
if (isModifierKey(key)) {
this.modifiers[key] = true;
}
const unprevented = instance.dispatchUIEvent(target, 'keydown', {
key,
code
});
if (isModifierLock(key) && !this.modifiers[key]) {
this.modifiers[key] = true;
this.modifierLockStart[key] = true;
}
(_this_pressed_code = this.pressed[code]).unpreventedDefault || (_this_pressed_code.unpreventedDefault = unprevented);
if (unprevented && this.hasKeyPress(key)) {
instance.dispatchUIEvent(getActiveElement.getActiveElementOrBody(instance.config.document), 'keypress', {
key,
code,
charCode: keyDef.key === 'Enter' ? 13 : String(keyDef.key).charCodeAt(0)
});
}
}
/** Release a key */ async keyup(instance, keyDef) {
const key = String(keyDef.key);
const code = String(keyDef.code);
const unprevented = this.pressed[code].unpreventedDefault;
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete this.pressed[code];
if (isModifierKey(key) && !Object.values(this.pressed).find((p)=>p.keyDef.key === key)) {
this.modifiers[key] = false;
}
instance.dispatchUIEvent(getActiveElement.getActiveElementOrBody(instance.config.document), 'keyup', {
key,
code
}, !unprevented);
if (isModifierLock(key) && this.modifiers[key]) {
if (this.modifierLockStart[key]) {
this.modifierLockStart[key] = false;
} else {
this.modifiers[key] = false;
}
}
}
setKeydownTarget(target) {
if (target !== this.lastKeydownTarget) {
this.carryChar = '';
}
this.lastKeydownTarget = target;
}
hasKeyPress(key) {
return (key.length === 1 || key === 'Enter') && !this.modifiers.Control && !this.modifiers.Alt;
}
constructor(system){
_define_property(this, "system", void 0);
_define_property(this, "modifiers", {
Alt: false,
AltGraph: false,
CapsLock: false,
Control: false,
Fn: false,
FnLock: false,
Meta: false,
NumLock: false,
ScrollLock: false,
Shift: false,
Symbol: false,
SymbolLock: false
});
_define_property(this, "pressed", {});
_define_property(this, "carryChar", '');
_define_property(this, "lastKeydownTarget", undefined);
_define_property(this, "modifierLockStart", {});
this.system = system;
}
}
exports.KeyboardHost = KeyboardHost;

View File

@@ -0,0 +1,84 @@
'use strict';
function _define_property(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
class Buttons {
getButtons() {
let v = 0;
for (const button of Object.keys(this.pressed)){
// eslint-disable-next-line no-bitwise
v |= 2 ** Number(button);
}
return v;
}
down(keyDef) {
const button = getMouseButtonId(keyDef.button);
if (button in this.pressed) {
this.pressed[button].push(keyDef);
return undefined;
}
this.pressed[button] = [
keyDef
];
return button;
}
up(keyDef) {
const button = getMouseButtonId(keyDef.button);
if (button in this.pressed) {
this.pressed[button] = this.pressed[button].filter((k)=>k.name !== keyDef.name);
if (this.pressed[button].length === 0) {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete this.pressed[button];
return button;
}
}
return undefined;
}
constructor(){
_define_property(this, "pressed", {});
}
}
const MouseButton = {
primary: 0,
secondary: 1,
auxiliary: 2,
back: 3,
X1: 3,
forward: 4,
X2: 4
};
function getMouseButtonId(button = 0) {
if (button in MouseButton) {
return MouseButton[button];
}
return Number(button);
}
// On the `MouseEvent.button` property auxiliary and secondary button are flipped compared to `MouseEvent.buttons`.
const MouseButtonFlip = {
1: 2,
2: 1
};
function getMouseEventButton(button) {
button = getMouseButtonId(button);
if (button in MouseButtonFlip) {
return MouseButtonFlip[button];
}
return button;
}
exports.Buttons = Buttons;
exports.MouseButton = MouseButton;
exports.MouseButtonFlip = MouseButtonFlip;
exports.getMouseButtonId = getMouseButtonId;
exports.getMouseEventButton = getMouseEventButton;

View File

@@ -0,0 +1,34 @@
'use strict';
function _define_property(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
class Device {
get countPressed() {
return this.pressedKeys.size;
}
isPressed(keyDef) {
return this.pressedKeys.has(keyDef.name);
}
addPressed(keyDef) {
return this.pressedKeys.add(keyDef.name);
}
removePressed(keyDef) {
return this.pressedKeys.delete(keyDef.name);
}
constructor(){
_define_property(this, "pressedKeys", new Set());
}
}
exports.Device = Device;

View File

@@ -0,0 +1,164 @@
'use strict';
var buttons = require('./buttons.js');
var device = require('./device.js');
var mouse = require('./mouse.js');
var pointer = require('./pointer.js');
function _define_property(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
class PointerHost {
isKeyPressed(keyDef) {
return this.devices.get(keyDef.pointerType).isPressed(keyDef);
}
async press(instance, keyDef, position) {
const pointerName = this.getPointerName(keyDef);
const pointer = keyDef.pointerType === 'touch' ? this.pointers.new(pointerName, keyDef).init(instance, position) : this.pointers.get(pointerName);
// TODO: deprecate the following implicit setting of position
pointer.position = position;
if (pointer.pointerType !== 'touch') {
this.mouse.position = position;
}
this.devices.get(keyDef.pointerType).addPressed(keyDef);
this.buttons.down(keyDef);
pointer.down(instance, keyDef);
if (pointer.pointerType !== 'touch' && !pointer.isPrevented) {
this.mouse.down(instance, keyDef, pointer);
}
}
async move(instance, pointerName, position) {
const pointer = this.pointers.get(pointerName);
// In (some?) browsers this order of events can be observed.
// This interweaving of events is probably unnecessary.
// While the order of mouse (or pointer) events is defined per spec,
// the order in which they interweave/follow on a user interaction depends on the implementation.
const pointermove = pointer.move(instance, position);
const mousemove = pointer.pointerType === 'touch' || pointer.isPrevented && pointer.isDown ? undefined : this.mouse.move(instance, position);
pointermove === null || pointermove === void 0 ? void 0 : pointermove.leave();
mousemove === null || mousemove === void 0 ? void 0 : mousemove.leave();
pointermove === null || pointermove === void 0 ? void 0 : pointermove.enter();
mousemove === null || mousemove === void 0 ? void 0 : mousemove.enter();
pointermove === null || pointermove === void 0 ? void 0 : pointermove.move();
mousemove === null || mousemove === void 0 ? void 0 : mousemove.move();
}
async release(instance, keyDef, position) {
const device = this.devices.get(keyDef.pointerType);
device.removePressed(keyDef);
this.buttons.up(keyDef);
const pointer = this.pointers.get(this.getPointerName(keyDef));
// TODO: deprecate the following implicit setting of position
pointer.position = position;
if (pointer.pointerType !== 'touch') {
this.mouse.position = position;
}
if (device.countPressed === 0) {
pointer.up(instance, keyDef);
}
if (pointer.pointerType === 'touch') {
pointer.release(instance);
}
if (!pointer.isPrevented) {
if (pointer.pointerType === 'touch' && !pointer.isMultitouch) {
const mousemove = this.mouse.move(instance, pointer.position);
mousemove === null || mousemove === void 0 ? void 0 : mousemove.leave();
mousemove === null || mousemove === void 0 ? void 0 : mousemove.enter();
mousemove === null || mousemove === void 0 ? void 0 : mousemove.move();
this.mouse.down(instance, keyDef, pointer);
}
if (!pointer.isMultitouch) {
const mousemove = this.mouse.move(instance, pointer.position);
mousemove === null || mousemove === void 0 ? void 0 : mousemove.leave();
mousemove === null || mousemove === void 0 ? void 0 : mousemove.enter();
mousemove === null || mousemove === void 0 ? void 0 : mousemove.move();
this.mouse.up(instance, keyDef, pointer);
}
}
}
getPointerName(keyDef) {
return keyDef.pointerType === 'touch' ? keyDef.name : keyDef.pointerType;
}
getPreviousPosition(pointerName) {
return this.pointers.has(pointerName) ? this.pointers.get(pointerName).position : undefined;
}
resetClickCount() {
this.mouse.resetClickCount();
}
getMouseTarget(instance) {
var _this_mouse_position_target;
return (_this_mouse_position_target = this.mouse.position.target) !== null && _this_mouse_position_target !== void 0 ? _this_mouse_position_target : instance.config.document.body;
}
setMousePosition(position) {
this.mouse.position = position;
this.pointers.get('mouse').position = position;
}
constructor(system){
_define_property(this, "system", void 0);
_define_property(this, "mouse", void 0);
_define_property(this, "buttons", void 0);
_define_property(this, "devices", new class {
get(k) {
var // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
_this_registry, _k;
var _;
(_ = (_this_registry = this.registry)[_k = k]) !== null && _ !== void 0 ? _ : _this_registry[_k] = new device.Device();
return this.registry[k];
}
constructor(){
_define_property(this, "registry", {});
}
}());
_define_property(this, "pointers", new class {
new(pointerName, keyDef) {
const isPrimary = keyDef.pointerType !== 'touch' || !Object.values(this.registry).some((p)=>p.pointerType === 'touch' && !p.isCancelled);
if (!isPrimary) {
Object.values(this.registry).forEach((p)=>{
if (p.pointerType === keyDef.pointerType && !p.isCancelled) {
p.isMultitouch = true;
}
});
}
this.registry[pointerName] = new pointer.Pointer({
pointerId: this.nextId++,
pointerType: keyDef.pointerType,
isPrimary
});
return this.registry[pointerName];
}
get(pointerName) {
if (!this.has(pointerName)) {
throw new Error(`Trying to access pointer "${pointerName}" which does not exist.`);
}
return this.registry[pointerName];
}
has(pointerName) {
return pointerName in this.registry;
}
constructor(){
_define_property(this, "registry", {
mouse: new pointer.Pointer({
pointerId: 1,
pointerType: 'mouse',
isPrimary: true
})
});
_define_property(this, "nextId", 2);
}
}());
this.system = system;
this.buttons = new buttons.Buttons();
this.mouse = new mouse.Mouse();
}
}
exports.PointerHost = PointerHost;

View File

@@ -0,0 +1,212 @@
'use strict';
require('../../event/behavior/click.js');
require('../../event/behavior/cut.js');
require('../../event/behavior/keydown.js');
require('../../event/behavior/keypress.js');
require('../../event/behavior/keyup.js');
require('../../event/behavior/paste.js');
require('@testing-library/dom');
require('../../utils/click/isClickableInput.js');
require('../../utils/dataTransfer/Clipboard.js');
require('../../utils/edit/isEditable.js');
require('../../utils/edit/maxLength.js');
var isDisabled = require('../../utils/misc/isDisabled.js');
require('../../utils/keyDef/readNextDescriptor.js');
var getTreeDiff = require('../../utils/misc/getTreeDiff.js');
require('../../utils/misc/level.js');
require('../../options.js');
var focus = require('../../event/focus.js');
var setSelectionPerMouse = require('../../event/selection/setSelectionPerMouse.js');
var modifySelectionPerMouse = require('../../event/selection/modifySelectionPerMouse.js');
var buttons = require('./buttons.js');
var shared = require('./shared.js');
function _define_property(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
/**
* This object is the single "virtual" mouse that might be controlled by multiple different pointer devices.
*/ class Mouse {
move(instance, position) {
const prevPosition = this.position;
const prevTarget = this.getTarget(instance);
this.position = position;
if (!shared.isDifferentPointerPosition(prevPosition, position)) {
return;
}
const nextTarget = this.getTarget(instance);
const init = this.getEventInit('mousemove');
const [leave, enter] = getTreeDiff.getTreeDiff(prevTarget, nextTarget);
return {
leave: ()=>{
if (prevTarget !== nextTarget) {
instance.dispatchUIEvent(prevTarget, 'mouseout', init);
leave.forEach((el)=>instance.dispatchUIEvent(el, 'mouseleave', init));
}
},
enter: ()=>{
if (prevTarget !== nextTarget) {
instance.dispatchUIEvent(nextTarget, 'mouseover', init);
enter.forEach((el)=>instance.dispatchUIEvent(el, 'mouseenter', init));
}
},
move: ()=>{
instance.dispatchUIEvent(nextTarget, 'mousemove', init);
this.modifySelecting(instance);
}
};
}
down(instance, keyDef, pointer) {
const button = this.buttons.down(keyDef);
if (button === undefined) {
return;
}
const target = this.getTarget(instance);
this.buttonDownTarget[button] = target;
const disabled = isDisabled.isDisabled(target);
const init = this.getEventInit('mousedown', keyDef.button);
if (disabled || instance.dispatchUIEvent(target, 'mousedown', init)) {
this.startSelecting(instance, init.detail);
focus.focusElement(target);
}
if (!disabled && buttons.getMouseEventButton(keyDef.button) === 2) {
instance.dispatchUIEvent(target, 'contextmenu', this.getEventInit('contextmenu', keyDef.button, pointer));
}
}
up(instance, keyDef, pointer) {
const button = this.buttons.up(keyDef);
if (button === undefined) {
return;
}
const target = this.getTarget(instance);
if (!isDisabled.isDisabled(target)) {
instance.dispatchUIEvent(target, 'mouseup', this.getEventInit('mouseup', keyDef.button));
this.endSelecting();
const clickTarget = getTreeDiff.getTreeDiff(this.buttonDownTarget[button], target)[2][0];
if (clickTarget) {
const init = this.getEventInit('click', keyDef.button, pointer);
if (init.detail) {
instance.dispatchUIEvent(clickTarget, init.button === 0 ? 'click' : 'auxclick', init);
if (init.button === 0 && init.detail === 2) {
instance.dispatchUIEvent(clickTarget, 'dblclick', {
...this.getEventInit('dblclick', keyDef.button),
detail: init.detail
});
}
}
}
}
}
resetClickCount() {
this.clickCount.reset();
}
getEventInit(type, button, pointer) {
const init = {
...this.position.coords
};
if (pointer) {
init.pointerId = pointer.pointerId;
init.pointerType = pointer.pointerType;
init.isPrimary = pointer.isPrimary;
}
init.button = buttons.getMouseEventButton(button);
init.buttons = this.buttons.getButtons();
if (type === 'mousedown') {
init.detail = this.clickCount.getOnDown(init.button);
} else if (type === 'mouseup') {
init.detail = this.clickCount.getOnUp(init.button);
} else if (type === 'click' || type === 'auxclick') {
init.detail = this.clickCount.incOnClick(init.button);
}
return init;
}
getTarget(instance) {
var _this_position_target;
return (_this_position_target = this.position.target) !== null && _this_position_target !== void 0 ? _this_position_target : instance.config.document.body;
}
startSelecting(instance, clickCount) {
var _this_position_caret, _this_position_caret1;
// TODO: support extending range (shift)
this.selecting = setSelectionPerMouse.setSelectionPerMouseDown({
document: instance.config.document,
target: this.getTarget(instance),
node: (_this_position_caret = this.position.caret) === null || _this_position_caret === void 0 ? void 0 : _this_position_caret.node,
offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 === void 0 ? void 0 : _this_position_caret1.offset,
clickCount
});
}
modifySelecting(instance) {
var _this_position_caret, _this_position_caret1;
if (!this.selecting) {
return;
}
modifySelectionPerMouse.modifySelectionPerMouseMove(this.selecting, {
document: instance.config.document,
target: this.getTarget(instance),
node: (_this_position_caret = this.position.caret) === null || _this_position_caret === void 0 ? void 0 : _this_position_caret.node,
offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 === void 0 ? void 0 : _this_position_caret1.offset
});
}
endSelecting() {
this.selecting = undefined;
}
constructor(){
_define_property(this, "position", {});
_define_property(this, "buttons", new buttons.Buttons());
_define_property(this, "selecting", void 0);
_define_property(this, "buttonDownTarget", {});
// According to spec the `detail` on click events should be the number
// of *consecutive* clicks with a specific button.
// On `mousedown` and `mouseup` it should be this number increased by one.
// But the browsers don't implement it this way.
// If another button is pressed,
// in Webkit: the `mouseup` on the previously pressed button has `detail: 0` and no `click`/`auxclick`.
// in Gecko: the `mouseup` and click events have the same detail as the `mousedown`.
// If there is a delay while a button is pressed,
// the `mouseup` and `click` are normal, but a following `mousedown` starts a new click count.
// We'll follow the minimal implementation of Webkit.
_define_property(this, "clickCount", new class {
incOnClick(button) {
const current = this.down[button] === undefined ? undefined : Number(this.down[button]) + 1;
this.count = this.count[button] === undefined ? {} : {
[button]: Number(this.count[button]) + 1
};
return current;
}
getOnDown(button) {
var _this_count_button;
this.down = {
[button]: (_this_count_button = this.count[button]) !== null && _this_count_button !== void 0 ? _this_count_button : 0
};
var _this_count_button1;
this.count = {
[button]: (_this_count_button1 = this.count[button]) !== null && _this_count_button1 !== void 0 ? _this_count_button1 : 0
};
return Number(this.count[button]) + 1;
}
getOnUp(button) {
return this.down[button] === undefined ? undefined : Number(this.down[button]) + 1;
}
reset() {
this.count = {};
}
constructor(){
_define_property(this, "down", {});
_define_property(this, "count", {});
}
}());
}
}
exports.Mouse = Mouse;

View File

@@ -0,0 +1,126 @@
'use strict';
require('../../utils/click/isClickableInput.js');
require('../../utils/dataTransfer/Clipboard.js');
require('../../utils/edit/isEditable.js');
require('../../utils/edit/maxLength.js');
require('../../utils/keyDef/readNextDescriptor.js');
var getTreeDiff = require('../../utils/misc/getTreeDiff.js');
require('../../utils/misc/level.js');
var cssPointerEvents = require('../../utils/pointer/cssPointerEvents.js');
var shared = require('./shared.js');
function _define_property(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
class Pointer {
init(instance, position) {
this.position = position;
const target = this.getTarget(instance);
const [, enter] = getTreeDiff.getTreeDiff(null, target);
const init = this.getEventInit();
cssPointerEvents.assertPointerEvents(instance, target);
instance.dispatchUIEvent(target, 'pointerover', init);
enter.forEach((el)=>instance.dispatchUIEvent(el, 'pointerenter', init));
return this;
}
move(instance, position) {
const prevPosition = this.position;
const prevTarget = this.getTarget(instance);
this.position = position;
if (!shared.isDifferentPointerPosition(prevPosition, position)) {
return;
}
const nextTarget = this.getTarget(instance);
const init = this.getEventInit();
const [leave, enter] = getTreeDiff.getTreeDiff(prevTarget, nextTarget);
return {
leave: ()=>{
if (cssPointerEvents.hasPointerEvents(instance, prevTarget)) {
if (prevTarget !== nextTarget) {
instance.dispatchUIEvent(prevTarget, 'pointerout', init);
leave.forEach((el)=>instance.dispatchUIEvent(el, 'pointerleave', init));
}
}
},
enter: ()=>{
cssPointerEvents.assertPointerEvents(instance, nextTarget);
if (prevTarget !== nextTarget) {
instance.dispatchUIEvent(nextTarget, 'pointerover', init);
enter.forEach((el)=>instance.dispatchUIEvent(el, 'pointerenter', init));
}
},
move: ()=>{
instance.dispatchUIEvent(nextTarget, 'pointermove', init);
}
};
}
down(instance, _keyDef) {
if (this.isDown) {
return;
}
const target = this.getTarget(instance);
cssPointerEvents.assertPointerEvents(instance, target);
this.isDown = true;
this.isPrevented = !instance.dispatchUIEvent(target, 'pointerdown', this.getEventInit());
}
up(instance, _keyDef) {
if (!this.isDown) {
return;
}
const target = this.getTarget(instance);
cssPointerEvents.assertPointerEvents(instance, target);
this.isDown = false;
instance.dispatchUIEvent(target, 'pointerup', this.getEventInit());
}
release(instance) {
const target = this.getTarget(instance);
const [leave] = getTreeDiff.getTreeDiff(target, null);
const init = this.getEventInit();
// Currently there is no PointerEventsCheckLevel that would
// make this check not use the *asserted* cached value from `up`.
/* istanbul ignore else */ if (cssPointerEvents.hasPointerEvents(instance, target)) {
instance.dispatchUIEvent(target, 'pointerout', init);
leave.forEach((el)=>instance.dispatchUIEvent(el, 'pointerleave', init));
}
this.isCancelled = true;
}
getTarget(instance) {
var _this_position_target;
return (_this_position_target = this.position.target) !== null && _this_position_target !== void 0 ? _this_position_target : instance.config.document.body;
}
getEventInit() {
return {
...this.position.coords,
pointerId: this.pointerId,
pointerType: this.pointerType,
isPrimary: this.isPrimary
};
}
constructor({ pointerId, pointerType, isPrimary }){
_define_property(this, "pointerId", void 0);
_define_property(this, "pointerType", void 0);
_define_property(this, "isPrimary", void 0);
_define_property(this, "isMultitouch", false);
_define_property(this, "isCancelled", false);
_define_property(this, "isDown", false);
_define_property(this, "isPrevented", false);
_define_property(this, "position", {});
this.pointerId = pointerId;
this.pointerType = pointerType;
this.isPrimary = isPrimary;
this.isMultitouch = !isPrimary;
}
}
exports.Pointer = Pointer;

View File

@@ -0,0 +1,8 @@
'use strict';
function isDifferentPointerPosition(positionA, positionB) {
var _positionA_coords, _positionB_coords, _positionA_coords1, _positionB_coords1, _positionA_caret, _positionB_caret, _positionA_caret1, _positionB_caret1;
return positionA.target !== positionB.target || ((_positionA_coords = positionA.coords) === null || _positionA_coords === void 0 ? void 0 : _positionA_coords.x) !== ((_positionB_coords = positionB.coords) === null || _positionB_coords === void 0 ? void 0 : _positionB_coords.y) || ((_positionA_coords1 = positionA.coords) === null || _positionA_coords1 === void 0 ? void 0 : _positionA_coords1.y) !== ((_positionB_coords1 = positionB.coords) === null || _positionB_coords1 === void 0 ? void 0 : _positionB_coords1.y) || ((_positionA_caret = positionA.caret) === null || _positionA_caret === void 0 ? void 0 : _positionA_caret.node) !== ((_positionB_caret = positionB.caret) === null || _positionB_caret === void 0 ? void 0 : _positionB_caret.node) || ((_positionA_caret1 = positionA.caret) === null || _positionA_caret1 === void 0 ? void 0 : _positionA_caret1.offset) !== ((_positionB_caret1 = positionB.caret) === null || _positionB_caret1 === void 0 ? void 0 : _positionB_caret1.offset);
}
exports.isDifferentPointerPosition = isDifferentPointerPosition;