@visactor/vrender-core 0.22.8 → 0.22.9-alpha.2
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.
- package/cjs/common/event-listener-manager.d.ts +14 -0
- package/cjs/common/event-listener-manager.js +52 -0
- package/cjs/common/event-listener-manager.js.map +1 -0
- package/cjs/common/event-transformer.d.ts +12 -0
- package/cjs/common/event-transformer.js +91 -0
- package/cjs/common/event-transformer.js.map +1 -0
- package/cjs/common/polygon.js +0 -1
- package/cjs/common/render-area.js +1 -0
- package/cjs/common/sort.js +1 -1
- package/cjs/common/split-path.js +1 -1
- package/cjs/core/global.d.ts +7 -5
- package/cjs/core/global.js +13 -13
- package/cjs/core/global.js.map +1 -1
- package/cjs/core/window.d.ts +5 -4
- package/cjs/core/window.js +14 -13
- package/cjs/core/window.js.map +1 -1
- package/cjs/event/event-system.js +11 -10
- package/cjs/event/event-system.js.map +1 -1
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +2 -1
- package/cjs/index.js.map +1 -1
- package/cjs/interface/event-listener-manager.d.ts +7 -0
- package/cjs/interface/event-listener-manager.js +6 -0
- package/cjs/interface/event-listener-manager.js.map +1 -0
- package/cjs/interface/global.d.ts +2 -1
- package/cjs/interface/global.js.map +1 -1
- package/cjs/interface/window.d.ts +1 -0
- package/cjs/interface/window.js.map +1 -1
- package/dist/index.es.js +215 -58
- package/es/common/event-listener-manager.d.ts +14 -0
- package/es/common/event-listener-manager.js +44 -0
- package/es/common/event-listener-manager.js.map +1 -0
- package/es/common/event-transformer.d.ts +12 -0
- package/es/common/event-transformer.js +81 -0
- package/es/common/event-transformer.js.map +1 -0
- package/es/common/polygon.js +1 -2
- package/es/common/render-area.js +2 -1
- package/es/common/sort.js +1 -1
- package/es/common/split-path.js +1 -1
- package/es/core/global.d.ts +7 -5
- package/es/core/global.js +14 -12
- package/es/core/global.js.map +1 -1
- package/es/core/window.d.ts +5 -4
- package/es/core/window.js +15 -12
- package/es/core/window.js.map +1 -1
- package/es/event/event-system.js +11 -10
- package/es/event/event-system.js.map +1 -1
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -0
- package/es/index.js.map +1 -1
- package/es/interface/event-listener-manager.d.ts +7 -0
- package/es/interface/event-listener-manager.js +2 -0
- package/es/interface/event-listener-manager.js.map +1 -0
- package/es/interface/global.d.ts +2 -1
- package/es/interface/global.js.map +1 -1
- package/es/interface/window.d.ts +1 -0
- package/es/interface/window.js.map +1 -1
- package/package.json +3 -3
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { tau, halfPi as halfPi$1, AABBBounds, degreeToRadian, PointService, Point, abs, max, min, atan2, epsilon, Matrix, pi2, Logger, pi, isArray, isPointInLine, isNumberClose, TextMeasure, EventEmitter, isBoolean, isObject, isFunction, isString, has, isUndefined, cos, sin, pointAt, isNumber, getDecimalPlaces, isValidNumber, clamp, getAngleByPoint, isNil, Bounds, getIntersectPoint, Color, DEFAULT_COLORS, sqrt, OBBBounds, normalTransform, isValidUrl, isBase64, acos, LRU, lowerCamelCaseToMiddle, isValid, transformBoundsWithMatrix, getContextFont, rotatePoint, clampAngleByRadian, asin, arrayEqual, getRectIntersect, isRectIntersect, merge, calculateAnchorOfBounds, styleStringToObject } from '@visactor/vutils';
|
|
1
|
+
import { tau, halfPi as halfPi$1, AABBBounds, degreeToRadian, PointService, Point, abs, max, min, atan2, epsilon, Matrix, pi2, Logger, pi, isArray, isPointInLine, isNumberClose, TextMeasure, EventEmitter, isBoolean, isObject, isFunction, isString, has, isUndefined, cos, sin, pointAt, isNumber as isNumber$1, getDecimalPlaces, isValidNumber, clamp, getAngleByPoint, isNil, Bounds, getIntersectPoint, Color, DEFAULT_COLORS, sqrt, OBBBounds, normalTransform, isValidUrl, isBase64, acos, LRU, lowerCamelCaseToMiddle, isValid, transformBoundsWithMatrix, getContextFont, rotatePoint, clampAngleByRadian, asin, arrayEqual, getRectIntersect, isRectIntersect, merge, calculateAnchorOfBounds, styleStringToObject } from '@visactor/vutils';
|
|
2
2
|
|
|
3
3
|
class Generator {
|
|
4
4
|
static GenAutoIncrementId() {
|
|
@@ -852,8 +852,71 @@ const EnvContribution = Symbol.for('EnvContribution');
|
|
|
852
852
|
const VGlobal = Symbol.for('VGlobal');
|
|
853
853
|
const DEFAULT_TEXT_FONT_FAMILY = 'PingFang SC,Helvetica Neue,Microsoft Yahei,system-ui,-apple-system,segoe ui,Roboto,Helvetica,Arial,sans-serif,apple color emoji,segoe ui emoji,segoe ui symbol';
|
|
854
854
|
|
|
855
|
+
class EventListenerManager {
|
|
856
|
+
constructor() {
|
|
857
|
+
this._listenerMap = new Map();
|
|
858
|
+
this._eventListenerTransformer = event => event;
|
|
859
|
+
}
|
|
860
|
+
setEventListenerTransformer(transformer) {
|
|
861
|
+
this._eventListenerTransformer = transformer || (event => event);
|
|
862
|
+
}
|
|
863
|
+
addEventListener(type, listener, options) {
|
|
864
|
+
if (!listener) {
|
|
865
|
+
return;
|
|
866
|
+
}
|
|
867
|
+
const wrappedListener = (event) => {
|
|
868
|
+
const transformedEvent = this._eventListenerTransformer(event);
|
|
869
|
+
if (typeof listener === 'function') {
|
|
870
|
+
listener(transformedEvent);
|
|
871
|
+
}
|
|
872
|
+
else if (listener.handleEvent) {
|
|
873
|
+
listener.handleEvent(transformedEvent);
|
|
874
|
+
}
|
|
875
|
+
};
|
|
876
|
+
if (!this._listenerMap.has(type)) {
|
|
877
|
+
this._listenerMap.set(type, new Map());
|
|
878
|
+
}
|
|
879
|
+
this._listenerMap.get(type).set(listener, wrappedListener);
|
|
880
|
+
this._nativeAddEventListener(type, wrappedListener, options);
|
|
881
|
+
}
|
|
882
|
+
removeEventListener(type, listener, options) {
|
|
883
|
+
var _a;
|
|
884
|
+
if (!listener) {
|
|
885
|
+
return;
|
|
886
|
+
}
|
|
887
|
+
const wrappedListener = (_a = this._listenerMap.get(type)) === null || _a === void 0 ? void 0 : _a.get(listener);
|
|
888
|
+
if (wrappedListener) {
|
|
889
|
+
this._nativeRemoveEventListener(type, wrappedListener, options);
|
|
890
|
+
this._listenerMap.get(type).delete(listener);
|
|
891
|
+
if (this._listenerMap.get(type).size === 0) {
|
|
892
|
+
this._listenerMap.delete(type);
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
dispatchEvent(event) {
|
|
897
|
+
return this._nativeDispatchEvent(event);
|
|
898
|
+
}
|
|
899
|
+
clearAllEventListeners() {
|
|
900
|
+
this._listenerMap.forEach((listenersMap, type) => {
|
|
901
|
+
listenersMap.forEach((wrappedListener, originalListener) => {
|
|
902
|
+
this._nativeRemoveEventListener(type, wrappedListener, undefined);
|
|
903
|
+
});
|
|
904
|
+
});
|
|
905
|
+
this._listenerMap.clear();
|
|
906
|
+
}
|
|
907
|
+
_nativeAddEventListener(type, listener, options) {
|
|
908
|
+
throw new Error('_nativeAddEventListener must be implemented by derived classes');
|
|
909
|
+
}
|
|
910
|
+
_nativeRemoveEventListener(type, listener, options) {
|
|
911
|
+
throw new Error('_nativeRemoveEventListener must be implemented by derived classes');
|
|
912
|
+
}
|
|
913
|
+
_nativeDispatchEvent(event) {
|
|
914
|
+
throw new Error('_nativeDispatchEvent must be implemented by derived classes');
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
|
|
855
918
|
const defaultEnv = 'browser';
|
|
856
|
-
let DefaultGlobal = class DefaultGlobal {
|
|
919
|
+
let DefaultGlobal = class DefaultGlobal extends EventListenerManager {
|
|
857
920
|
get env() {
|
|
858
921
|
return this._env;
|
|
859
922
|
}
|
|
@@ -930,8 +993,10 @@ let DefaultGlobal = class DefaultGlobal {
|
|
|
930
993
|
this.envContribution.applyStyles = support;
|
|
931
994
|
}
|
|
932
995
|
constructor(contributions) {
|
|
996
|
+
super();
|
|
933
997
|
this.contributions = contributions;
|
|
934
998
|
this._isImageAnonymous = true;
|
|
999
|
+
this.eventListenerTransformer = event => event;
|
|
935
1000
|
this.id = Generator.GenAutoIncrementId();
|
|
936
1001
|
this.hooks = {
|
|
937
1002
|
onSetEnv: new SyncHook(['lastEnv', 'env', 'global'])
|
|
@@ -939,6 +1004,24 @@ let DefaultGlobal = class DefaultGlobal {
|
|
|
939
1004
|
this.measureTextMethod = 'native';
|
|
940
1005
|
this.optimizeVisible = false;
|
|
941
1006
|
}
|
|
1007
|
+
_nativeAddEventListener(type, listener, options) {
|
|
1008
|
+
if (!this._env) {
|
|
1009
|
+
this.setEnv(defaultEnv);
|
|
1010
|
+
}
|
|
1011
|
+
return this.envContribution.addEventListener(type, listener, options);
|
|
1012
|
+
}
|
|
1013
|
+
_nativeRemoveEventListener(type, listener, options) {
|
|
1014
|
+
if (!this._env) {
|
|
1015
|
+
this.setEnv(defaultEnv);
|
|
1016
|
+
}
|
|
1017
|
+
return this.envContribution.removeEventListener(type, listener, options);
|
|
1018
|
+
}
|
|
1019
|
+
_nativeDispatchEvent(event) {
|
|
1020
|
+
if (!this._env) {
|
|
1021
|
+
this.setEnv(defaultEnv);
|
|
1022
|
+
}
|
|
1023
|
+
return this.envContribution.dispatchEvent(event);
|
|
1024
|
+
}
|
|
942
1025
|
bindContribution(params) {
|
|
943
1026
|
const promiseArr = [];
|
|
944
1027
|
this.contributions.getContributions().forEach(contribution => {
|
|
@@ -1007,24 +1090,6 @@ let DefaultGlobal = class DefaultGlobal {
|
|
|
1007
1090
|
}
|
|
1008
1091
|
return this.envContribution.releaseCanvas(canvas);
|
|
1009
1092
|
}
|
|
1010
|
-
addEventListener(type, listener, options) {
|
|
1011
|
-
if (!this._env) {
|
|
1012
|
-
this.setEnv(defaultEnv);
|
|
1013
|
-
}
|
|
1014
|
-
return this.envContribution.addEventListener(type, listener, options);
|
|
1015
|
-
}
|
|
1016
|
-
removeEventListener(type, listener, options) {
|
|
1017
|
-
if (!this._env) {
|
|
1018
|
-
this.setEnv(defaultEnv);
|
|
1019
|
-
}
|
|
1020
|
-
return this.envContribution.removeEventListener(type, listener, options);
|
|
1021
|
-
}
|
|
1022
|
-
dispatchEvent(event) {
|
|
1023
|
-
if (!this._env) {
|
|
1024
|
-
this.setEnv(defaultEnv);
|
|
1025
|
-
}
|
|
1026
|
-
return this.envContribution.dispatchEvent(event);
|
|
1027
|
-
}
|
|
1028
1093
|
getRequestAnimationFrame() {
|
|
1029
1094
|
if (!this._env) {
|
|
1030
1095
|
this.setEnv(defaultEnv);
|
|
@@ -4483,6 +4548,9 @@ function isAroundZero(val) {
|
|
|
4483
4548
|
function isNotAroundZero(val) {
|
|
4484
4549
|
return val > EPSILON || val < -EPSILON;
|
|
4485
4550
|
}
|
|
4551
|
+
function isNumber(data) {
|
|
4552
|
+
return typeof data === 'number' && Number.isFinite(data);
|
|
4553
|
+
}
|
|
4486
4554
|
const _v0 = [0, 0];
|
|
4487
4555
|
const _v1 = [0, 0];
|
|
4488
4556
|
const _v2 = [0, 0];
|
|
@@ -5219,7 +5287,7 @@ const canvasAllocate = new DefaultCanvasAllocate();
|
|
|
5219
5287
|
|
|
5220
5288
|
const VWindow = Symbol.for('VWindow');
|
|
5221
5289
|
const WindowHandlerContribution = Symbol.for('WindowHandlerContribution');
|
|
5222
|
-
let DefaultWindow = class DefaultWindow {
|
|
5290
|
+
let DefaultWindow = class DefaultWindow extends EventListenerManager {
|
|
5223
5291
|
get width() {
|
|
5224
5292
|
if (this._handler) {
|
|
5225
5293
|
const wh = this._handler.getWH();
|
|
@@ -5238,6 +5306,7 @@ let DefaultWindow = class DefaultWindow {
|
|
|
5238
5306
|
return this._handler.getDpr();
|
|
5239
5307
|
}
|
|
5240
5308
|
constructor() {
|
|
5309
|
+
super();
|
|
5241
5310
|
this.hooks = {
|
|
5242
5311
|
onChange: new SyncHook(['x', 'y', 'width', 'height'])
|
|
5243
5312
|
};
|
|
@@ -5254,6 +5323,15 @@ let DefaultWindow = class DefaultWindow {
|
|
|
5254
5323
|
this.global = application.global;
|
|
5255
5324
|
this.postInit();
|
|
5256
5325
|
}
|
|
5326
|
+
_nativeAddEventListener(type, listener, options) {
|
|
5327
|
+
return this._handler.addEventListener(type, listener, options);
|
|
5328
|
+
}
|
|
5329
|
+
_nativeRemoveEventListener(type, listener, options) {
|
|
5330
|
+
return this._handler.removeEventListener(type, listener, options);
|
|
5331
|
+
}
|
|
5332
|
+
_nativeDispatchEvent(event) {
|
|
5333
|
+
return this._handler.dispatchEvent(event);
|
|
5334
|
+
}
|
|
5257
5335
|
postInit() {
|
|
5258
5336
|
this.global.hooks.onSetEnv.tap('window', this.active);
|
|
5259
5337
|
this.active();
|
|
@@ -5299,6 +5377,7 @@ let DefaultWindow = class DefaultWindow {
|
|
|
5299
5377
|
}
|
|
5300
5378
|
release() {
|
|
5301
5379
|
this.global.hooks.onSetEnv.unTap('window', this.active);
|
|
5380
|
+
this.clearAllEventListeners();
|
|
5302
5381
|
return this._handler.releaseWindow();
|
|
5303
5382
|
}
|
|
5304
5383
|
getContext() {
|
|
@@ -5313,15 +5392,6 @@ let DefaultWindow = class DefaultWindow {
|
|
|
5313
5392
|
}
|
|
5314
5393
|
return this._handler.getImageBuffer(type);
|
|
5315
5394
|
}
|
|
5316
|
-
addEventListener(type, listener, options) {
|
|
5317
|
-
return this._handler.addEventListener(type, listener, options);
|
|
5318
|
-
}
|
|
5319
|
-
removeEventListener(type, listener, options) {
|
|
5320
|
-
return this._handler.removeEventListener(type, listener, options);
|
|
5321
|
-
}
|
|
5322
|
-
dispatchEvent(event) {
|
|
5323
|
-
return this._handler.dispatchEvent(event);
|
|
5324
|
-
}
|
|
5325
5395
|
getBoundingClientRect() {
|
|
5326
5396
|
return this._handler.getBoundingClientRect();
|
|
5327
5397
|
}
|
|
@@ -7381,8 +7451,8 @@ class EventSystem {
|
|
|
7381
7451
|
const { globalObj, domElement } = this;
|
|
7382
7452
|
if (this.supportsPointerEvents) {
|
|
7383
7453
|
if (globalObj.getDocument()) {
|
|
7384
|
-
globalObj.
|
|
7385
|
-
globalObj.
|
|
7454
|
+
globalObj.addEventListener('pointermove', this.onPointerMove, true);
|
|
7455
|
+
globalObj.addEventListener('pointerup', this.onPointerUp, true);
|
|
7386
7456
|
}
|
|
7387
7457
|
else {
|
|
7388
7458
|
domElement.addEventListener('pointermove', this.onPointerMove, true);
|
|
@@ -7394,8 +7464,8 @@ class EventSystem {
|
|
|
7394
7464
|
}
|
|
7395
7465
|
else {
|
|
7396
7466
|
if (globalObj.getDocument()) {
|
|
7397
|
-
globalObj.
|
|
7398
|
-
globalObj.
|
|
7467
|
+
globalObj.addEventListener('mousemove', this.onPointerMove, true);
|
|
7468
|
+
globalObj.addEventListener('mouseup', this.onPointerUp, true);
|
|
7399
7469
|
}
|
|
7400
7470
|
else {
|
|
7401
7471
|
domElement.addEventListener('mousemove', this.onPointerMove, true);
|
|
@@ -7416,22 +7486,32 @@ class EventSystem {
|
|
|
7416
7486
|
this.eventsAdded = true;
|
|
7417
7487
|
}
|
|
7418
7488
|
removeEvents() {
|
|
7419
|
-
var _a;
|
|
7420
7489
|
if (!this.eventsAdded || !this.domElement) {
|
|
7421
7490
|
return;
|
|
7422
7491
|
}
|
|
7423
7492
|
const { globalObj, domElement } = this;
|
|
7424
|
-
const globalDocument = (_a = globalObj.getDocument()) !== null && _a !== void 0 ? _a : domElement;
|
|
7425
7493
|
if (this.supportsPointerEvents) {
|
|
7426
|
-
|
|
7427
|
-
|
|
7494
|
+
if (globalObj.getDocument()) {
|
|
7495
|
+
globalObj.removeEventListener('pointermove', this.onPointerMove, true);
|
|
7496
|
+
globalObj.removeEventListener('pointerup', this.onPointerUp, true);
|
|
7497
|
+
}
|
|
7498
|
+
else {
|
|
7499
|
+
domElement.removeEventListener('pointermove', this.onPointerMove, true);
|
|
7500
|
+
domElement.removeEventListener('pointerup', this.onPointerUp, true);
|
|
7501
|
+
}
|
|
7428
7502
|
domElement.removeEventListener('pointerdown', this.onPointerDown, true);
|
|
7429
7503
|
domElement.removeEventListener('pointerleave', this.onPointerOverOut, true);
|
|
7430
7504
|
domElement.removeEventListener('pointerover', this.onPointerOverOut, true);
|
|
7431
7505
|
}
|
|
7432
7506
|
else {
|
|
7433
|
-
|
|
7434
|
-
|
|
7507
|
+
if (globalObj.getDocument()) {
|
|
7508
|
+
globalObj.removeEventListener('mousemove', this.onPointerMove, true);
|
|
7509
|
+
globalObj.removeEventListener('mouseup', this.onPointerUp, true);
|
|
7510
|
+
}
|
|
7511
|
+
else {
|
|
7512
|
+
domElement.removeEventListener('mousemove', this.onPointerMove, true);
|
|
7513
|
+
domElement.removeEventListener('mouseup', this.onPointerUp, true);
|
|
7514
|
+
}
|
|
7435
7515
|
domElement.removeEventListener('mousedown', this.onPointerDown, true);
|
|
7436
7516
|
domElement.removeEventListener('mouseout', this.onPointerOverOut, true);
|
|
7437
7517
|
domElement.removeEventListener('mouseover', this.onPointerOverOut, true);
|
|
@@ -9212,8 +9292,8 @@ class IncreaseCount extends ACustomAnimate {
|
|
|
9212
9292
|
}
|
|
9213
9293
|
onBind() {
|
|
9214
9294
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
9215
|
-
this.fromNumber = isNumber((_a = this.from) === null || _a === void 0 ? void 0 : _a.text) ? (_b = this.from) === null || _b === void 0 ? void 0 : _b.text : Number.parseFloat((_c = this.from) === null || _c === void 0 ? void 0 : _c.text);
|
|
9216
|
-
this.toNumber = isNumber((_d = this.to) === null || _d === void 0 ? void 0 : _d.text) ? (_e = this.to) === null || _e === void 0 ? void 0 : _e.text : Number.parseFloat((_f = this.to) === null || _f === void 0 ? void 0 : _f.text);
|
|
9295
|
+
this.fromNumber = isNumber$1((_a = this.from) === null || _a === void 0 ? void 0 : _a.text) ? (_b = this.from) === null || _b === void 0 ? void 0 : _b.text : Number.parseFloat((_c = this.from) === null || _c === void 0 ? void 0 : _c.text);
|
|
9296
|
+
this.toNumber = isNumber$1((_d = this.to) === null || _d === void 0 ? void 0 : _d.text) ? (_e = this.to) === null || _e === void 0 ? void 0 : _e.text : Number.parseFloat((_f = this.to) === null || _f === void 0 ? void 0 : _f.text);
|
|
9217
9297
|
if (!Number.isFinite(this.toNumber)) {
|
|
9218
9298
|
this.fromNumber = 0;
|
|
9219
9299
|
}
|
|
@@ -10781,7 +10861,7 @@ const splitCircle = (arc, count) => {
|
|
|
10781
10861
|
return res;
|
|
10782
10862
|
};
|
|
10783
10863
|
const samplingPoints = (points, count) => {
|
|
10784
|
-
const validatePoints = points.filter(point => point.defined !== false && isNumber(point.x) && isNumber(point.y));
|
|
10864
|
+
const validatePoints = points.filter(point => point.defined !== false && isNumber$1(point.x) && isNumber$1(point.y));
|
|
10785
10865
|
if (validatePoints.length === 0) {
|
|
10786
10866
|
return [];
|
|
10787
10867
|
}
|
|
@@ -10835,7 +10915,7 @@ const splitArea = (area, count) => {
|
|
|
10835
10915
|
return res.concat((_a = seg.points) !== null && _a !== void 0 ? _a : []);
|
|
10836
10916
|
}, []);
|
|
10837
10917
|
}
|
|
10838
|
-
const validatePoints = points.filter(point => point.defined !== false && isNumber(point.x) && isNumber(point.y));
|
|
10918
|
+
const validatePoints = points.filter(point => point.defined !== false && isNumber$1(point.x) && isNumber$1(point.y));
|
|
10839
10919
|
if (!validatePoints.length) {
|
|
10840
10920
|
return [];
|
|
10841
10921
|
}
|
|
@@ -11069,7 +11149,7 @@ ColorStore.store255 = {};
|
|
|
11069
11149
|
ColorStore.store1 = {};
|
|
11070
11150
|
|
|
11071
11151
|
function colorArrayToString(color, alphaChannel = false) {
|
|
11072
|
-
if (Array.isArray(color) && isNumber(color[0])) {
|
|
11152
|
+
if (Array.isArray(color) && isNumber$1(color[0])) {
|
|
11073
11153
|
return alphaChannel
|
|
11074
11154
|
? `rgb(${Math.round(color[0])},${Math.round(color[1])},${Math.round(color[2])},${color[3].toFixed(2)})`
|
|
11075
11155
|
: `rgb(${Math.round(color[0])},${Math.round(color[1])},${Math.round(color[2])})`;
|
|
@@ -11077,7 +11157,7 @@ function colorArrayToString(color, alphaChannel = false) {
|
|
|
11077
11157
|
return color;
|
|
11078
11158
|
}
|
|
11079
11159
|
function interpolateColor(from, to, ratio, alphaChannel, cb) {
|
|
11080
|
-
if ((Array.isArray(from) && !isNumber(from[0])) || (Array.isArray(to) && !isNumber(to[0]))) {
|
|
11160
|
+
if ((Array.isArray(from) && !isNumber$1(from[0])) || (Array.isArray(to) && !isNumber$1(to[0]))) {
|
|
11081
11161
|
const out = new Array(4).fill(0).map((_, index) => {
|
|
11082
11162
|
return _interpolateColor(isArray(from) ? from[index] : from, isArray(to) ? to[index] : to, ratio, alphaChannel);
|
|
11083
11163
|
});
|
|
@@ -11895,7 +11975,7 @@ function getIndex(url, arr) {
|
|
|
11895
11975
|
|
|
11896
11976
|
class BaseSymbol {
|
|
11897
11977
|
bounds(size, bounds) {
|
|
11898
|
-
if (isNumber(size)) {
|
|
11978
|
+
if (isNumber$1(size)) {
|
|
11899
11979
|
const halfS = size / 2;
|
|
11900
11980
|
bounds.x1 = -halfS;
|
|
11901
11981
|
bounds.x2 = halfS;
|
|
@@ -11910,7 +11990,7 @@ class BaseSymbol {
|
|
|
11910
11990
|
}
|
|
11911
11991
|
}
|
|
11912
11992
|
parseSize(size) {
|
|
11913
|
-
return isNumber(size) ? size : Math.min(size[0], size[1]);
|
|
11993
|
+
return isNumber$1(size) ? size : Math.min(size[0], size[1]);
|
|
11914
11994
|
}
|
|
11915
11995
|
}
|
|
11916
11996
|
|
|
@@ -12521,13 +12601,13 @@ class RectSymbol extends BaseSymbol {
|
|
|
12521
12601
|
this.pathStr = 'M -0.5,0.25 L 0.5,0.25 L 0.5,-0.25,L -0.5,-0.25 Z';
|
|
12522
12602
|
}
|
|
12523
12603
|
draw(ctx, size, x, y) {
|
|
12524
|
-
if (isNumber(size)) {
|
|
12604
|
+
if (isNumber$1(size)) {
|
|
12525
12605
|
return rectSize(ctx, size, x, y);
|
|
12526
12606
|
}
|
|
12527
12607
|
return rectSizeArray(ctx, size, x, y);
|
|
12528
12608
|
}
|
|
12529
12609
|
drawWithClipRange(ctx, size, x, y, clipRange, z, cb) {
|
|
12530
|
-
if (isNumber(size)) {
|
|
12610
|
+
if (isNumber$1(size)) {
|
|
12531
12611
|
size = [size, size / 2];
|
|
12532
12612
|
}
|
|
12533
12613
|
const totalLength = (size[0] + size[1]) * 2;
|
|
@@ -12559,7 +12639,7 @@ class RectSymbol extends BaseSymbol {
|
|
|
12559
12639
|
return false;
|
|
12560
12640
|
}
|
|
12561
12641
|
drawOffset(ctx, size, x, y, offset) {
|
|
12562
|
-
if (isNumber(size)) {
|
|
12642
|
+
if (isNumber$1(size)) {
|
|
12563
12643
|
return rectSize(ctx, size + 2 * offset, x, y);
|
|
12564
12644
|
}
|
|
12565
12645
|
return rectSizeArray(ctx, [size[0] + 2 * offset, size[1] + 2 * offset], x, y);
|
|
@@ -12601,7 +12681,7 @@ class CustomSymbolClass {
|
|
|
12601
12681
|
return this.drawOffset(ctx, size, x, y, 0, z, cb);
|
|
12602
12682
|
}
|
|
12603
12683
|
parseSize(size) {
|
|
12604
|
-
return isNumber(size) ? size : Math.min(size[0], size[1]);
|
|
12684
|
+
return isNumber$1(size) ? size : Math.min(size[0], size[1]);
|
|
12605
12685
|
}
|
|
12606
12686
|
drawWithClipRange(ctx, size, x, y, clipRange, z, cb) {
|
|
12607
12687
|
size = this.parseSize(size);
|
|
@@ -16237,12 +16317,12 @@ let DefaultGraphicService = class DefaultGraphicService {
|
|
|
16237
16317
|
updateHTMLTextAABBBounds(attribute, textTheme, aabbBounds, graphic) {
|
|
16238
16318
|
const { textAlign, textBaseline } = attribute;
|
|
16239
16319
|
if (attribute.forceBoundsHeight != null) {
|
|
16240
|
-
const h = isNumber(attribute.forceBoundsHeight) ? attribute.forceBoundsHeight : attribute.forceBoundsHeight();
|
|
16320
|
+
const h = isNumber$1(attribute.forceBoundsHeight) ? attribute.forceBoundsHeight : attribute.forceBoundsHeight();
|
|
16241
16321
|
const dy = textLayoutOffsetY(textBaseline, h, h);
|
|
16242
16322
|
aabbBounds.set(aabbBounds.x1, dy, aabbBounds.x2, dy + h);
|
|
16243
16323
|
}
|
|
16244
16324
|
if (attribute.forceBoundsWidth != null) {
|
|
16245
|
-
const w = isNumber(attribute.forceBoundsWidth) ? attribute.forceBoundsWidth : attribute.forceBoundsWidth();
|
|
16325
|
+
const w = isNumber$1(attribute.forceBoundsWidth) ? attribute.forceBoundsWidth : attribute.forceBoundsWidth();
|
|
16246
16326
|
const dx = textDrawOffsetX(textAlign, w);
|
|
16247
16327
|
aabbBounds.set(dx, aabbBounds.y1, dx + w, aabbBounds.y2);
|
|
16248
16328
|
}
|
|
@@ -19104,7 +19184,7 @@ class RichText extends Graphic {
|
|
|
19104
19184
|
}
|
|
19105
19185
|
else {
|
|
19106
19186
|
const richTextConfig = this.combinedStyleToCharacter(textConfig[i]);
|
|
19107
|
-
if (isNumber(richTextConfig.text)) {
|
|
19187
|
+
if (isNumber$1(richTextConfig.text)) {
|
|
19108
19188
|
richTextConfig.text = `${richTextConfig.text}`;
|
|
19109
19189
|
}
|
|
19110
19190
|
if (richTextConfig.text && richTextConfig.text.includes('\n')) {
|
|
@@ -19526,7 +19606,7 @@ class Arc extends Graphic {
|
|
|
19526
19606
|
}
|
|
19527
19607
|
const deltaRadius = Math.abs(outerRadius - innerRadius);
|
|
19528
19608
|
const parseCR = (cornerRadius) => {
|
|
19529
|
-
return Math.min(isNumber(cornerRadius, true)
|
|
19609
|
+
return Math.min(isNumber$1(cornerRadius, true)
|
|
19530
19610
|
? cornerRadius
|
|
19531
19611
|
: (deltaRadius * parseFloat(cornerRadius)) / 100, deltaRadius / 2);
|
|
19532
19612
|
};
|
|
@@ -20752,7 +20832,7 @@ function createRectPath(path, x, y, width, height, rectCornerRadius, roundCorner
|
|
|
20752
20832
|
height = -height;
|
|
20753
20833
|
}
|
|
20754
20834
|
let cornerRadius;
|
|
20755
|
-
if (isNumber(rectCornerRadius, true)) {
|
|
20835
|
+
if (isNumber$1(rectCornerRadius, true)) {
|
|
20756
20836
|
rectCornerRadius = abs(rectCornerRadius);
|
|
20757
20837
|
cornerRadius = [
|
|
20758
20838
|
rectCornerRadius,
|
|
@@ -27307,6 +27387,83 @@ function flatten_simplify(points, tolerance, highestQuality) {
|
|
|
27307
27387
|
return points;
|
|
27308
27388
|
}
|
|
27309
27389
|
|
|
27390
|
+
function isIdentityMatrix(matrix) {
|
|
27391
|
+
return matrix.a === 1 && matrix.b === 0 && matrix.c === 0 && matrix.d === 1 && matrix.e === 0 && matrix.f === 0;
|
|
27392
|
+
}
|
|
27393
|
+
function createEventTransformer(containerElement, getMatrix, getRect, transformPoint) {
|
|
27394
|
+
return (event) => {
|
|
27395
|
+
if (!(event instanceof MouseEvent) && !(event instanceof TouchEvent) && !(event instanceof PointerEvent)) {
|
|
27396
|
+
return event;
|
|
27397
|
+
}
|
|
27398
|
+
const transformMatrix = getMatrix();
|
|
27399
|
+
if (isIdentityMatrix(transformMatrix)) {
|
|
27400
|
+
return event;
|
|
27401
|
+
}
|
|
27402
|
+
const containerRect = getRect();
|
|
27403
|
+
const transformedEvent = new event.constructor(event.type, event);
|
|
27404
|
+
Object.defineProperties(transformedEvent, {
|
|
27405
|
+
target: { value: event.target },
|
|
27406
|
+
currentTarget: { value: event.currentTarget }
|
|
27407
|
+
});
|
|
27408
|
+
if (event instanceof MouseEvent || event instanceof PointerEvent) {
|
|
27409
|
+
transformPoint(event.clientX, event.clientY, transformMatrix, containerRect, transformedEvent);
|
|
27410
|
+
}
|
|
27411
|
+
else if (event instanceof TouchEvent) {
|
|
27412
|
+
if (event.touches.length > 0) {
|
|
27413
|
+
const touch = transformedEvent.touches[0];
|
|
27414
|
+
transformPoint(touch.clientX, touch.clientY, transformMatrix, containerRect, touch);
|
|
27415
|
+
}
|
|
27416
|
+
if (event.changedTouches.length > 0) {
|
|
27417
|
+
const touch = transformedEvent.changedTouches[0];
|
|
27418
|
+
transformPoint(touch.clientX, touch.clientY, transformMatrix, containerRect, touch);
|
|
27419
|
+
}
|
|
27420
|
+
}
|
|
27421
|
+
return transformedEvent;
|
|
27422
|
+
};
|
|
27423
|
+
}
|
|
27424
|
+
function createCanvasEventTransformer(canvasElement, getMatrix, getRect, transformPoint) {
|
|
27425
|
+
return createEventTransformer(canvasElement.parentElement || canvasElement, getMatrix, getRect, transformPoint);
|
|
27426
|
+
}
|
|
27427
|
+
function registerWindowEventTransformer(window, container, getMatrix, getRect, transformPoint) {
|
|
27428
|
+
const transformer = createEventTransformer(container, getMatrix, getRect, transformPoint);
|
|
27429
|
+
window.setEventListenerTransformer(transformer);
|
|
27430
|
+
}
|
|
27431
|
+
function registerGlobalEventTransformer(global, container, getMatrix, getRect, transformPoint) {
|
|
27432
|
+
const transformer = createEventTransformer(container, getMatrix, getRect, transformPoint);
|
|
27433
|
+
global.setEventListenerTransformer(transformer);
|
|
27434
|
+
}
|
|
27435
|
+
function transformPointForCanvas(clientX, clientY, matrix, rect, transformedEvent) {
|
|
27436
|
+
const transformedPoint = { x: clientX, y: clientY };
|
|
27437
|
+
matrix.transformPoint(transformedPoint, transformedPoint);
|
|
27438
|
+
Object.defineProperties(transformedEvent, {
|
|
27439
|
+
_canvasX: { value: transformedPoint.x },
|
|
27440
|
+
_canvasY: { value: transformedPoint.y }
|
|
27441
|
+
});
|
|
27442
|
+
return;
|
|
27443
|
+
}
|
|
27444
|
+
function mapToCanvasPointForCanvas(nativeEvent) {
|
|
27445
|
+
var _a;
|
|
27446
|
+
if (isNumber(nativeEvent._canvasX) && isNumber(nativeEvent._canvasY)) {
|
|
27447
|
+
return {
|
|
27448
|
+
x: nativeEvent._canvasX,
|
|
27449
|
+
y: nativeEvent._canvasY
|
|
27450
|
+
};
|
|
27451
|
+
}
|
|
27452
|
+
else if (nativeEvent.changedTouches) {
|
|
27453
|
+
const data = (_a = nativeEvent.changedTouches[0]) !== null && _a !== void 0 ? _a : {};
|
|
27454
|
+
return {
|
|
27455
|
+
x: data._canvasX,
|
|
27456
|
+
y: data._canvasY
|
|
27457
|
+
};
|
|
27458
|
+
}
|
|
27459
|
+
const x = nativeEvent._canvasX || 0;
|
|
27460
|
+
const y = nativeEvent._canvasY || 0;
|
|
27461
|
+
return {
|
|
27462
|
+
x,
|
|
27463
|
+
y
|
|
27464
|
+
};
|
|
27465
|
+
}
|
|
27466
|
+
|
|
27310
27467
|
function getDefaultCharacterConfig(attribute) {
|
|
27311
27468
|
const { fill = 'black', stroke = false, fontWeight = 'normal', lineHeight, fontFamily = 'Arial', textAlign } = attribute;
|
|
27312
27469
|
let { fontSize = 12 } = attribute;
|
|
@@ -30504,4 +30661,4 @@ function generatorPathEasingFunc(path) {
|
|
|
30504
30661
|
};
|
|
30505
30662
|
}
|
|
30506
30663
|
|
|
30507
|
-
export { ACustomAnimate, ARC3D_NUMBER_TYPE, ARC_NUMBER_TYPE, AREA_NUMBER_TYPE, AbstractGraphicRender, Animate, AnimateGroup, AnimateGroup1, AnimateMode, AnimateStatus, AnimateStepType, Application, Arc, Arc3d, Arc3dRender, ArcRender, ArcRenderContribution, Area, AreaRender, AreaRenderContribution, AttributeAnimate, AttributeUpdateType, AutoEnablePlugins, BaseCanvas, BaseEnvContribution, BaseRender, BaseRenderContributionTime, BaseWindowHandlerContribution, Basis, BeforeRenderConstribution, BoundsContext, BoundsPicker, CIRCLE_NUMBER_TYPE, Canvas3DDrawItemInterceptor, Canvas3DPickItemInterceptor, CanvasFactory, CanvasTextLayout, CbAnimate, Circle, CircleRender, CircleRenderContribution, ClipAngleAnimate, ClipDirectionAnimate, ClipGraphicAnimate, ClipRadiusAnimate, ColorInterpolate, ColorStore, ColorType, CommonDrawItemInterceptorContribution, CommonRenderContribution, Container, ContainerModule, Context2dFactory, ContributionProvider, CurveContext, CurveTypeEnum, CustomEvent, CustomPath2D, CustomSymbolClass, DEFAULT_TEXT_FONT_FAMILY, DebugDrawItemInterceptorContribution, DefaultArcAllocate, DefaultArcAttribute, DefaultArcRenderContribution, DefaultAreaAllocate, DefaultAreaAttribute, DefaultAreaTextureRenderContribution, DefaultAttribute, DefaultBaseBackgroundRenderContribution, DefaultBaseClipRenderAfterContribution, DefaultBaseClipRenderBeforeContribution, DefaultBaseInteractiveRenderContribution, DefaultBaseTextureRenderContribution, DefaultCanvasAllocate, DefaultCanvasArcRender, DefaultCanvasAreaRender, DefaultCanvasCircleRender, DefaultCanvasGroupRender, DefaultCanvasImageRender, DefaultCanvasLineRender, DefaultCanvasPathRender, DefaultCanvasPolygonRender, DefaultCanvasRectRender, DefaultCanvasSymbolRender, DefaultCanvasTextRender, DefaultCircleAllocate, DefaultCircleAttribute, DefaultCircleRenderContribution, DefaultConnectAttribute, DefaultDebugAttribute, DefaultFillStyle, DefaultGlobal, DefaultGlobalPickerService, DefaultGlyphAttribute, DefaultGraphicAllocate, DefaultGraphicMemoryManager, DefaultGraphicService, DefaultGraphicUtil, DefaultGroupAttribute, DefaultGroupBackgroundRenderContribution, DefaultImageAttribute, DefaultImageRenderContribution, DefaultLayerService, DefaultLayout, DefaultLineAllocate, DefaultLineAttribute, DefaultMat4Allocate, DefaultMatrixAllocate, DefaultMorphingAnimateConfig, DefaultPathAllocate, DefaultPathAttribute, DefaultPickService, DefaultPickStyle, DefaultPolygonAttribute, DefaultRect3dAttribute, DefaultRectAllocate, DefaultRectAttribute, DefaultRectRenderContribution, DefaultRenderService, DefaultRichTextAttribute, DefaultRichTextIconAttribute, DefaultStarAttribute, DefaultStateAnimateConfig, DefaultStrokeStyle, DefaultStyle, DefaultSymbolAllocate, DefaultSymbolAttribute, DefaultSymbolClipRangeStrokeRenderContribution, DefaultSymbolRenderContribution, DefaultTextAllocate, DefaultTextAttribute, DefaultTextMeasureContribution, DefaultTextStyle, DefaultTicker, DefaultTimeline, DefaultTransform, DefaultTransformUtil, DefaultWindow, Direction$1 as Direction, DirectionalLight, DrawContribution, DrawItemInterceptor, DynamicLayerHandlerContribution, Easing, Edge, EditModule, EmptyContext2d, EnvContribution, EventManager, EventSystem, EventTarget, FORMAT_ALL_TEXT_COMMAND, FORMAT_ELEMENT_COMMAND, FORMAT_TEXT_COMMAND, Factory, FadeInPlus, FederatedEvent, FederatedMouseEvent, FederatedPointerEvent, FederatedWheelEvent, FlexLayoutPlugin, GLYPH_NUMBER_TYPE, GRAPHIC_UPDATE_TAG_KEY, GROUP_NUMBER_TYPE, Generator, GlobalPickerService, Glyph, GlyphRender, Graphic, GraphicAnimate, GraphicCreator$1 as GraphicCreator, GraphicPicker, GraphicRender, GraphicService, GraphicUtil, Group, GroupFadeIn, GroupFadeOut, GroupRender, GroupRenderContribution, GroupUpdateAABBBoundsMode, HtmlAttributePlugin, IContainPointMode, IMAGE_NUMBER_TYPE, Image, ImageRender, ImageRenderContribution, IncreaseCount, IncrementalDrawContribution, InputText, InteractiveDrawItemInterceptorContribution, InteractivePickItemInterceptorContribution, InteractiveSubRenderContribution, LINE_NUMBER_TYPE, Layer, LayerService, Line$1 as Line, LineRender, Linear, LinearClosed, ManualTickHandler, ManualTicker, Mat4Allocate, MatrixAllocate, MeasureModeEnum, Meteor, MonotoneX, MonotoneY, MorphingPath, MotionPath, MultiToOneMorphingPath, NOWORK_ANIMATE_ATTR, Node, OrthoCamera, PATH_NUMBER_TYPE, POLYGON_NUMBER_TYPE, PURE_STYLE_KEY, PYRAMID3D_NUMBER_TYPE, Path, PathRender, PathRenderContribution, PickItemInterceptor, PickServiceInterceptor, PickerService, PluginService, Polygon, PolygonRender, PolygonRenderContribution, Pyramid3d, Pyramid3dRender, RAFTickHandler, RECT3D_NUMBER_TYPE, RECT_NUMBER_TYPE, RICHTEXT_NUMBER_TYPE, RafBasedSTO, ReactAttributePlugin, Rect, Rect3DRender, Rect3d, RectRender, RectRenderContribution, ReflectSegContext, RenderSelector, RenderService, ResourceLoader, RichText, RichTextEditPlugin, RichTextRender, RotateBySphereAnimate, STAR_NUMBER_TYPE, SVG_ATTRIBUTE_MAP, SVG_ATTRIBUTE_MAP_KEYS, SVG_PARSE_ATTRIBUTE_MAP, SVG_PARSE_ATTRIBUTE_MAP_KEYS, SYMBOL_NUMBER_TYPE, SegContext, ShadowPickServiceInterceptorContribution, ShadowRoot, ShadowRootDrawItemInterceptorContribution, ShadowRootPickItemInterceptorContribution, SplitRectAfterRenderContribution, SplitRectBeforeRenderContribution, Stage, Star, StarRender, StarRenderContribution, StaticLayerHandlerContribution, Step$1 as Step, StreamLight, SubAnimate, Symbol$1 as Symbol, SymbolRender, SymbolRenderContribution, TEXT_NUMBER_TYPE, TagPointsUpdate, Text, TextDirection, TextMeasureContribution, TextRender, TextRenderContribution, Theme, TimeOutTickHandler, TransformUtil, UpdateTag, VGlobal, VWindow, ViewTransform3dPlugin, VirtualLayerHandlerContribution, WILDCARD, WindowHandlerContribution, WrapText, XMLParser, _calculateLineHeight, _interpolateColor, addArcToBezierPath, addAttributeToPrototype, alignBezierCurves, alignSubpath, application, applyTransformOnBezierCurves, arc3dModule, arcModule, areaModule, bezier, bezierCurversToPath, binarySplitPolygon, bindContributionProvider, bindContributionProviderNoSingletonScope, boundStroke, builtInSymbolStrMap, builtinSymbols, builtinSymbolsMap, calcLineCache, calculateArcCornerRadius, calculateLineHeight, canvasAllocate, centroidOfSubpath, circleBounds, circleModule, clock, cloneGraphic, colorEqual, colorStringInterpolationToStr, container, cornerTangents, createArc, createArc3d, createArea, createCircle, createColor, createConicalGradient, createGlyph, createGroup, createImage, createLine, createMat4, createPath, createPolygon, createPyramid3d, createRect, createRect3d, createRectPath, createRichText, createShadowRoot, createStage, createStar, createSymbol, createText, createWrapText, cubicCalc, cubicLength, cubicPointAt, cubicSubdivide, defaultArcAllocate, defaultArcBackgroundRenderContribution, defaultArcRenderContribution, defaultArcTextureRenderContribution, defaultAreaAllocate, defaultBaseBackgroundRenderContribution, defaultBaseClipRenderAfterContribution, defaultBaseClipRenderBeforeContribution, defaultBaseTextureRenderContribution, defaultCircleAllocate, defaultCircleBackgroundRenderContribution, defaultCircleRenderContribution, defaultCircleTextureRenderContribution, defaultGraphicMemoryManager, defaultGroupBackgroundRenderContribution, defaultImageBackgroundRenderContribution, defaultImageRenderContribution, defaultLineAllocate, defaultPathAllocate, defaultRectAllocate, defaultRectBackgroundRenderContribution, defaultRectRenderContribution, defaultRectTextureRenderContribution, defaultStarBackgroundRenderContribution, defaultStarTextureRenderContribution, defaultSymbolAllocate, defaultSymbolBackgroundRenderContribution, defaultSymbolClipRangeStrokeRenderContribution, defaultSymbolRenderContribution, defaultSymbolTextureRenderContribution, defaultTextAllocate, defaultTicker, defaultTimeline, drawArc, drawArcPath$1 as drawArcPath, drawAreaSegments, drawIncrementalAreaSegments, drawIncrementalSegments, drawSegments, enumCommandMap, fillVisible, findBestMorphingRotation, findConfigIndexByCursorIdx, findCursorIdxByConfigIndex, findNextGraphic, flatten_simplify, foreach, foreachAsync, genBasisSegments, genBasisTypeSegments, genLinearClosedSegments, genLinearClosedTypeSegments, genLinearSegments, genLinearTypeSegments, genMonotoneXSegments, genMonotoneXTypeSegments, genMonotoneYSegments, genMonotoneYTypeSegments, genNumberType, genStepSegments, genStepTypeSegments, generatorPathEasingFunc, getAttributeFromDefaultAttrList, getConicGradientAt, getCurrentEnv, getDefaultCharacterConfig, getExtraModelMatrix, getModelMatrix, getRichTextBounds, getScaledStroke, getTextBounds, getTheme, getThemeFromGroup, globalTheme, glyphModule, graphicCreator, graphicService, graphicUtil, identityMat4, imageModule, incrementalAddTo, inject, injectable, interpolateColor, interpolateGradientConicalColor, interpolateGradientLinearColor, interpolateGradientRadialColor, interpolatePureColorArray, intersect, isBrowserEnv, isNodeEnv, isSvg, isTransformKey, isXML, layerService, lineModule, lookAt, mat3Tomat4, mat4Allocate, matrixAllocate, morphPath, multiInject, multiToOneMorph, multiplyMat4Mat3, multiplyMat4Mat4, named, newThemeObj, oneToMultiMorph, ortho, parsePadding, parseStroke, parseSvgPath, pathModule, pathToBezierCurves, point$3 as point, pointEqual, pointInterpolation, pointInterpolationHighPerformance, pointsEqual, pointsInterpolation, polygonModule, preLoadAllModule, pyramid3dModule, quadCalc, quadLength, quadPointAt, rafBasedSto, rect3dModule, rectFillVisible, rectModule, rectStrokeVisible, recursiveCallBinarySplit, registerArc3dGraphic, registerArcGraphic, registerAreaGraphic, registerCircleGraphic, registerDirectionalLight, registerFlexLayoutPlugin, registerGlyphGraphic, registerGroupGraphic, registerHtmlAttributePlugin, registerImageGraphic, registerLineGraphic, registerOrthoCamera, registerPathGraphic, registerPolygonGraphic, registerPyramid3dGraphic, registerReactAttributePlugin, registerRect3dGraphic, registerRectGraphic, registerRichtextGraphic, registerShadowRootGraphic, registerStarGraphic, registerSymbolGraphic, registerTextGraphic, registerViewTransform3dPlugin, registerWrapTextGraphic, renderCommandList, rewriteProto, richtextModule, rotateX, rotateY, rotateZ, runFill, runStroke, scaleMat4, segments, shouldUseMat4, snapLength, splitArc, splitArea, splitCircle, splitGraphic, splitLine, splitPath, splitPolygon, splitRect, splitToGrids, starModule, strCommandMap, strokeVisible, symbolModule, textAttributesToStyle, textDrawOffsetX, textDrawOffsetY, textLayoutOffsetY, textModule, transformKeys, transformMat4, transformUtil, translate, verticalLayout, vglobal, waitForAllSubLayers, wrapCanvas, wrapContext, xul };
|
|
30664
|
+
export { ACustomAnimate, ARC3D_NUMBER_TYPE, ARC_NUMBER_TYPE, AREA_NUMBER_TYPE, AbstractGraphicRender, Animate, AnimateGroup, AnimateGroup1, AnimateMode, AnimateStatus, AnimateStepType, Application, Arc, Arc3d, Arc3dRender, ArcRender, ArcRenderContribution, Area, AreaRender, AreaRenderContribution, AttributeAnimate, AttributeUpdateType, AutoEnablePlugins, BaseCanvas, BaseEnvContribution, BaseRender, BaseRenderContributionTime, BaseWindowHandlerContribution, Basis, BeforeRenderConstribution, BoundsContext, BoundsPicker, CIRCLE_NUMBER_TYPE, Canvas3DDrawItemInterceptor, Canvas3DPickItemInterceptor, CanvasFactory, CanvasTextLayout, CbAnimate, Circle, CircleRender, CircleRenderContribution, ClipAngleAnimate, ClipDirectionAnimate, ClipGraphicAnimate, ClipRadiusAnimate, ColorInterpolate, ColorStore, ColorType, CommonDrawItemInterceptorContribution, CommonRenderContribution, Container, ContainerModule, Context2dFactory, ContributionProvider, CurveContext, CurveTypeEnum, CustomEvent, CustomPath2D, CustomSymbolClass, DEFAULT_TEXT_FONT_FAMILY, DebugDrawItemInterceptorContribution, DefaultArcAllocate, DefaultArcAttribute, DefaultArcRenderContribution, DefaultAreaAllocate, DefaultAreaAttribute, DefaultAreaTextureRenderContribution, DefaultAttribute, DefaultBaseBackgroundRenderContribution, DefaultBaseClipRenderAfterContribution, DefaultBaseClipRenderBeforeContribution, DefaultBaseInteractiveRenderContribution, DefaultBaseTextureRenderContribution, DefaultCanvasAllocate, DefaultCanvasArcRender, DefaultCanvasAreaRender, DefaultCanvasCircleRender, DefaultCanvasGroupRender, DefaultCanvasImageRender, DefaultCanvasLineRender, DefaultCanvasPathRender, DefaultCanvasPolygonRender, DefaultCanvasRectRender, DefaultCanvasSymbolRender, DefaultCanvasTextRender, DefaultCircleAllocate, DefaultCircleAttribute, DefaultCircleRenderContribution, DefaultConnectAttribute, DefaultDebugAttribute, DefaultFillStyle, DefaultGlobal, DefaultGlobalPickerService, DefaultGlyphAttribute, DefaultGraphicAllocate, DefaultGraphicMemoryManager, DefaultGraphicService, DefaultGraphicUtil, DefaultGroupAttribute, DefaultGroupBackgroundRenderContribution, DefaultImageAttribute, DefaultImageRenderContribution, DefaultLayerService, DefaultLayout, DefaultLineAllocate, DefaultLineAttribute, DefaultMat4Allocate, DefaultMatrixAllocate, DefaultMorphingAnimateConfig, DefaultPathAllocate, DefaultPathAttribute, DefaultPickService, DefaultPickStyle, DefaultPolygonAttribute, DefaultRect3dAttribute, DefaultRectAllocate, DefaultRectAttribute, DefaultRectRenderContribution, DefaultRenderService, DefaultRichTextAttribute, DefaultRichTextIconAttribute, DefaultStarAttribute, DefaultStateAnimateConfig, DefaultStrokeStyle, DefaultStyle, DefaultSymbolAllocate, DefaultSymbolAttribute, DefaultSymbolClipRangeStrokeRenderContribution, DefaultSymbolRenderContribution, DefaultTextAllocate, DefaultTextAttribute, DefaultTextMeasureContribution, DefaultTextStyle, DefaultTicker, DefaultTimeline, DefaultTransform, DefaultTransformUtil, DefaultWindow, Direction$1 as Direction, DirectionalLight, DrawContribution, DrawItemInterceptor, DynamicLayerHandlerContribution, Easing, Edge, EditModule, EmptyContext2d, EnvContribution, EventManager, EventSystem, EventTarget, FORMAT_ALL_TEXT_COMMAND, FORMAT_ELEMENT_COMMAND, FORMAT_TEXT_COMMAND, Factory, FadeInPlus, FederatedEvent, FederatedMouseEvent, FederatedPointerEvent, FederatedWheelEvent, FlexLayoutPlugin, GLYPH_NUMBER_TYPE, GRAPHIC_UPDATE_TAG_KEY, GROUP_NUMBER_TYPE, Generator, GlobalPickerService, Glyph, GlyphRender, Graphic, GraphicAnimate, GraphicCreator$1 as GraphicCreator, GraphicPicker, GraphicRender, GraphicService, GraphicUtil, Group, GroupFadeIn, GroupFadeOut, GroupRender, GroupRenderContribution, GroupUpdateAABBBoundsMode, HtmlAttributePlugin, IContainPointMode, IMAGE_NUMBER_TYPE, Image, ImageRender, ImageRenderContribution, IncreaseCount, IncrementalDrawContribution, InputText, InteractiveDrawItemInterceptorContribution, InteractivePickItemInterceptorContribution, InteractiveSubRenderContribution, LINE_NUMBER_TYPE, Layer, LayerService, Line$1 as Line, LineRender, Linear, LinearClosed, ManualTickHandler, ManualTicker, Mat4Allocate, MatrixAllocate, MeasureModeEnum, Meteor, MonotoneX, MonotoneY, MorphingPath, MotionPath, MultiToOneMorphingPath, NOWORK_ANIMATE_ATTR, Node, OrthoCamera, PATH_NUMBER_TYPE, POLYGON_NUMBER_TYPE, PURE_STYLE_KEY, PYRAMID3D_NUMBER_TYPE, Path, PathRender, PathRenderContribution, PickItemInterceptor, PickServiceInterceptor, PickerService, PluginService, Polygon, PolygonRender, PolygonRenderContribution, Pyramid3d, Pyramid3dRender, RAFTickHandler, RECT3D_NUMBER_TYPE, RECT_NUMBER_TYPE, RICHTEXT_NUMBER_TYPE, RafBasedSTO, ReactAttributePlugin, Rect, Rect3DRender, Rect3d, RectRender, RectRenderContribution, ReflectSegContext, RenderSelector, RenderService, ResourceLoader, RichText, RichTextEditPlugin, RichTextRender, RotateBySphereAnimate, STAR_NUMBER_TYPE, SVG_ATTRIBUTE_MAP, SVG_ATTRIBUTE_MAP_KEYS, SVG_PARSE_ATTRIBUTE_MAP, SVG_PARSE_ATTRIBUTE_MAP_KEYS, SYMBOL_NUMBER_TYPE, SegContext, ShadowPickServiceInterceptorContribution, ShadowRoot, ShadowRootDrawItemInterceptorContribution, ShadowRootPickItemInterceptorContribution, SplitRectAfterRenderContribution, SplitRectBeforeRenderContribution, Stage, Star, StarRender, StarRenderContribution, StaticLayerHandlerContribution, Step$1 as Step, StreamLight, SubAnimate, Symbol$1 as Symbol, SymbolRender, SymbolRenderContribution, TEXT_NUMBER_TYPE, TagPointsUpdate, Text, TextDirection, TextMeasureContribution, TextRender, TextRenderContribution, Theme, TimeOutTickHandler, TransformUtil, UpdateTag, VGlobal, VWindow, ViewTransform3dPlugin, VirtualLayerHandlerContribution, WILDCARD, WindowHandlerContribution, WrapText, XMLParser, _calculateLineHeight, _interpolateColor, addArcToBezierPath, addAttributeToPrototype, alignBezierCurves, alignSubpath, application, applyTransformOnBezierCurves, arc3dModule, arcModule, areaModule, bezier, bezierCurversToPath, binarySplitPolygon, bindContributionProvider, bindContributionProviderNoSingletonScope, boundStroke, builtInSymbolStrMap, builtinSymbols, builtinSymbolsMap, calcLineCache, calculateArcCornerRadius, calculateLineHeight, canvasAllocate, centroidOfSubpath, circleBounds, circleModule, clock, cloneGraphic, colorEqual, colorStringInterpolationToStr, container, cornerTangents, createArc, createArc3d, createArea, createCanvasEventTransformer, createCircle, createColor, createConicalGradient, createEventTransformer, createGlyph, createGroup, createImage, createLine, createMat4, createPath, createPolygon, createPyramid3d, createRect, createRect3d, createRectPath, createRichText, createShadowRoot, createStage, createStar, createSymbol, createText, createWrapText, cubicCalc, cubicLength, cubicPointAt, cubicSubdivide, defaultArcAllocate, defaultArcBackgroundRenderContribution, defaultArcRenderContribution, defaultArcTextureRenderContribution, defaultAreaAllocate, defaultBaseBackgroundRenderContribution, defaultBaseClipRenderAfterContribution, defaultBaseClipRenderBeforeContribution, defaultBaseTextureRenderContribution, defaultCircleAllocate, defaultCircleBackgroundRenderContribution, defaultCircleRenderContribution, defaultCircleTextureRenderContribution, defaultGraphicMemoryManager, defaultGroupBackgroundRenderContribution, defaultImageBackgroundRenderContribution, defaultImageRenderContribution, defaultLineAllocate, defaultPathAllocate, defaultRectAllocate, defaultRectBackgroundRenderContribution, defaultRectRenderContribution, defaultRectTextureRenderContribution, defaultStarBackgroundRenderContribution, defaultStarTextureRenderContribution, defaultSymbolAllocate, defaultSymbolBackgroundRenderContribution, defaultSymbolClipRangeStrokeRenderContribution, defaultSymbolRenderContribution, defaultSymbolTextureRenderContribution, defaultTextAllocate, defaultTicker, defaultTimeline, drawArc, drawArcPath$1 as drawArcPath, drawAreaSegments, drawIncrementalAreaSegments, drawIncrementalSegments, drawSegments, enumCommandMap, fillVisible, findBestMorphingRotation, findConfigIndexByCursorIdx, findCursorIdxByConfigIndex, findNextGraphic, flatten_simplify, foreach, foreachAsync, genBasisSegments, genBasisTypeSegments, genLinearClosedSegments, genLinearClosedTypeSegments, genLinearSegments, genLinearTypeSegments, genMonotoneXSegments, genMonotoneXTypeSegments, genMonotoneYSegments, genMonotoneYTypeSegments, genNumberType, genStepSegments, genStepTypeSegments, generatorPathEasingFunc, getAttributeFromDefaultAttrList, getConicGradientAt, getCurrentEnv, getDefaultCharacterConfig, getExtraModelMatrix, getModelMatrix, getRichTextBounds, getScaledStroke, getTextBounds, getTheme, getThemeFromGroup, globalTheme, glyphModule, graphicCreator, graphicService, graphicUtil, identityMat4, imageModule, incrementalAddTo, inject, injectable, interpolateColor, interpolateGradientConicalColor, interpolateGradientLinearColor, interpolateGradientRadialColor, interpolatePureColorArray, intersect, isBrowserEnv, isNodeEnv, isSvg, isTransformKey, isXML, layerService, lineModule, lookAt, mapToCanvasPointForCanvas, mat3Tomat4, mat4Allocate, matrixAllocate, morphPath, multiInject, multiToOneMorph, multiplyMat4Mat3, multiplyMat4Mat4, named, newThemeObj, oneToMultiMorph, ortho, parsePadding, parseStroke, parseSvgPath, pathModule, pathToBezierCurves, point$3 as point, pointEqual, pointInterpolation, pointInterpolationHighPerformance, pointsEqual, pointsInterpolation, polygonModule, preLoadAllModule, pyramid3dModule, quadCalc, quadLength, quadPointAt, rafBasedSto, rect3dModule, rectFillVisible, rectModule, rectStrokeVisible, recursiveCallBinarySplit, registerArc3dGraphic, registerArcGraphic, registerAreaGraphic, registerCircleGraphic, registerDirectionalLight, registerFlexLayoutPlugin, registerGlobalEventTransformer, registerGlyphGraphic, registerGroupGraphic, registerHtmlAttributePlugin, registerImageGraphic, registerLineGraphic, registerOrthoCamera, registerPathGraphic, registerPolygonGraphic, registerPyramid3dGraphic, registerReactAttributePlugin, registerRect3dGraphic, registerRectGraphic, registerRichtextGraphic, registerShadowRootGraphic, registerStarGraphic, registerSymbolGraphic, registerTextGraphic, registerViewTransform3dPlugin, registerWindowEventTransformer, registerWrapTextGraphic, renderCommandList, rewriteProto, richtextModule, rotateX, rotateY, rotateZ, runFill, runStroke, scaleMat4, segments, shouldUseMat4, snapLength, splitArc, splitArea, splitCircle, splitGraphic, splitLine, splitPath, splitPolygon, splitRect, splitToGrids, starModule, strCommandMap, strokeVisible, symbolModule, textAttributesToStyle, textDrawOffsetX, textDrawOffsetY, textLayoutOffsetY, textModule, transformKeys, transformMat4, transformPointForCanvas, transformUtil, translate, verticalLayout, vglobal, waitForAllSubLayers, wrapCanvas, wrapContext, xul };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IEventListenerManager } from '../interface/event-listener-manager';
|
|
2
|
+
export declare class EventListenerManager implements IEventListenerManager {
|
|
3
|
+
protected _listenerMap: Map<string, Map<EventListenerOrEventListenerObject, EventListener>>;
|
|
4
|
+
protected _eventListenerTransformer: (event: Event) => Event;
|
|
5
|
+
constructor();
|
|
6
|
+
setEventListenerTransformer(transformer: (event: Event) => Event): void;
|
|
7
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
8
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
9
|
+
dispatchEvent(event: Event): boolean;
|
|
10
|
+
clearAllEventListeners(): void;
|
|
11
|
+
protected _nativeAddEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void;
|
|
12
|
+
protected _nativeRemoveEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void;
|
|
13
|
+
protected _nativeDispatchEvent(event: Event): boolean;
|
|
14
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export class EventListenerManager {
|
|
2
|
+
constructor() {
|
|
3
|
+
this._listenerMap = new Map, this._eventListenerTransformer = event => event;
|
|
4
|
+
}
|
|
5
|
+
setEventListenerTransformer(transformer) {
|
|
6
|
+
this._eventListenerTransformer = transformer || (event => event);
|
|
7
|
+
}
|
|
8
|
+
addEventListener(type, listener, options) {
|
|
9
|
+
if (!listener) return;
|
|
10
|
+
const wrappedListener = event => {
|
|
11
|
+
const transformedEvent = this._eventListenerTransformer(event);
|
|
12
|
+
"function" == typeof listener ? listener(transformedEvent) : listener.handleEvent && listener.handleEvent(transformedEvent);
|
|
13
|
+
};
|
|
14
|
+
this._listenerMap.has(type) || this._listenerMap.set(type, new Map), this._listenerMap.get(type).set(listener, wrappedListener),
|
|
15
|
+
this._nativeAddEventListener(type, wrappedListener, options);
|
|
16
|
+
}
|
|
17
|
+
removeEventListener(type, listener, options) {
|
|
18
|
+
var _a;
|
|
19
|
+
if (!listener) return;
|
|
20
|
+
const wrappedListener = null === (_a = this._listenerMap.get(type)) || void 0 === _a ? void 0 : _a.get(listener);
|
|
21
|
+
wrappedListener && (this._nativeRemoveEventListener(type, wrappedListener, options),
|
|
22
|
+
this._listenerMap.get(type).delete(listener), 0 === this._listenerMap.get(type).size && this._listenerMap.delete(type));
|
|
23
|
+
}
|
|
24
|
+
dispatchEvent(event) {
|
|
25
|
+
return this._nativeDispatchEvent(event);
|
|
26
|
+
}
|
|
27
|
+
clearAllEventListeners() {
|
|
28
|
+
this._listenerMap.forEach(((listenersMap, type) => {
|
|
29
|
+
listenersMap.forEach(((wrappedListener, originalListener) => {
|
|
30
|
+
this._nativeRemoveEventListener(type, wrappedListener, void 0);
|
|
31
|
+
}));
|
|
32
|
+
})), this._listenerMap.clear();
|
|
33
|
+
}
|
|
34
|
+
_nativeAddEventListener(type, listener, options) {
|
|
35
|
+
throw new Error("_nativeAddEventListener must be implemented by derived classes");
|
|
36
|
+
}
|
|
37
|
+
_nativeRemoveEventListener(type, listener, options) {
|
|
38
|
+
throw new Error("_nativeRemoveEventListener must be implemented by derived classes");
|
|
39
|
+
}
|
|
40
|
+
_nativeDispatchEvent(event) {
|
|
41
|
+
throw new Error("_nativeDispatchEvent must be implemented by derived classes");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=event-listener-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/common/event-listener-manager.ts"],"names":[],"mappings":"AAMA,MAAM,OAAO,oBAAoB;IAY/B;QACE,IAAI,CAAC,YAAY,GAAG,IAAI,GAAG,EAAE,CAAC;QAC9B,IAAI,CAAC,yBAAyB,GAAG,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC;IAClD,CAAC;IAMD,2BAA2B,CAAC,WAAoC;QAC9D,IAAI,CAAC,yBAAyB,GAAG,WAAW,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;IACnE,CAAC;IAQD,gBAAgB,CACd,IAAY,EACZ,QAA4C,EAC5C,OAA2C;QAE3C,IAAI,CAAC,QAAQ,EAAE;YACb,OAAO;SACR;QAGD,MAAM,eAAe,GAAG,CAAC,KAAY,EAAE,EAAE;YACvC,MAAM,gBAAgB,GAAG,IAAI,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC;YAC/D,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE;gBAClC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;aAC5B;iBAAM,IAAI,QAAQ,CAAC,WAAW,EAAE;gBAC/B,QAAQ,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;aACxC;QACH,CAAC,CAAC;QAGF,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YAChC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;SACxC;QACD,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,GAAG,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;QAG5D,IAAI,CAAC,uBAAuB,CAAC,IAAI,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;IAC/D,CAAC;IAQD,mBAAmB,CACjB,IAAY,EACZ,QAA4C,EAC5C,OAAwC;;QAExC,IAAI,CAAC,QAAQ,EAAE;YACb,OAAO;SACR;QAGD,MAAM,eAAe,GAAG,MAAA,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,0CAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;QACnE,IAAI,eAAe,EAAE;YAEnB,IAAI,CAAC,0BAA0B,CAAC,IAAI,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;YAGhE,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC9C,IAAI,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,IAAI,KAAK,CAAC,EAAE;gBAC3C,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;aAChC;SACF;IACH,CAAC;IAMD,aAAa,CAAC,KAAY;QACxB,OAAO,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC;IAKD,sBAAsB;QACpB,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,YAAY,EAAE,IAAI,EAAE,EAAE;YAC/C,YAAY,CAAC,OAAO,CAAC,CAAC,eAAe,EAAE,gBAAgB,EAAE,EAAE;gBACzD,IAAI,CAAC,0BAA0B,CAAC,IAAI,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;YACpE,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;IAMS,uBAAuB,CAC/B,IAAY,EACZ,QAAuB,EACvB,OAA2C;QAE3C,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;IACpF,CAAC;IAMS,0BAA0B,CAClC,IAAY,EACZ,QAAuB,EACvB,OAAwC;QAExC,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAC;IACvF,CAAC;IAMS,oBAAoB,CAAC,KAAY;QACzC,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;IACjF,CAAC;CACF","file":"event-listener-manager.js","sourcesContent":["import type { IEventListenerManager } from '../interface/event-listener-manager';\n\n/**\n * Base class to manage event listeners with support for event transformation\n * Used by DefaultGlobal and DefaultWindow to handle the transformation of event coordinates\n */\nexport class EventListenerManager implements IEventListenerManager {\n /**\n * Map that stores the mapping from original listeners to wrapped listeners\n * Structure: Map<eventType, Map<originalListener, wrappedListener>>\n */\n protected _listenerMap: Map<string, Map<EventListenerOrEventListenerObject, EventListener>>;\n\n /**\n * Transformer function that transforms the event\n */\n protected _eventListenerTransformer: (event: Event) => Event;\n\n constructor() {\n this._listenerMap = new Map();\n this._eventListenerTransformer = event => event; // Default: no transformation\n }\n\n /**\n * Set the event transformer function\n * @param transformer Function that transforms events\n */\n setEventListenerTransformer(transformer: (event: Event) => Event): void {\n this._eventListenerTransformer = transformer || (event => event);\n }\n\n /**\n * Add an event listener with event transformation\n * @param type Event type\n * @param listener Original event listener\n * @param options Event listener options\n */\n addEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | AddEventListenerOptions\n ): void {\n if (!listener) {\n return;\n }\n\n // Create a wrapped listener that applies the transformation\n const wrappedListener = (event: Event) => {\n const transformedEvent = this._eventListenerTransformer(event);\n if (typeof listener === 'function') {\n listener(transformedEvent);\n } else if (listener.handleEvent) {\n listener.handleEvent(transformedEvent);\n }\n };\n\n // Store the mapping between original and wrapped listener\n if (!this._listenerMap.has(type)) {\n this._listenerMap.set(type, new Map());\n }\n this._listenerMap.get(type)!.set(listener, wrappedListener);\n\n // Add the wrapped listener\n this._nativeAddEventListener(type, wrappedListener, options);\n }\n\n /**\n * Remove an event listener\n * @param type Event type\n * @param listener Event listener to remove\n * @param options Event listener options\n */\n removeEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | EventListenerOptions\n ): void {\n if (!listener) {\n return;\n }\n\n // Get the wrapped listener from our map\n const wrappedListener = this._listenerMap.get(type)?.get(listener);\n if (wrappedListener) {\n // Remove the wrapped listener\n this._nativeRemoveEventListener(type, wrappedListener, options);\n\n // Remove from our map\n this._listenerMap.get(type)!.delete(listener);\n if (this._listenerMap.get(type)!.size === 0) {\n this._listenerMap.delete(type);\n }\n }\n }\n\n /**\n * Dispatch an event\n * @param event Event to dispatch\n */\n dispatchEvent(event: Event): boolean {\n return this._nativeDispatchEvent(event);\n }\n\n /**\n * Clear all event listeners\n */\n clearAllEventListeners(): void {\n this._listenerMap.forEach((listenersMap, type) => {\n listenersMap.forEach((wrappedListener, originalListener) => {\n this._nativeRemoveEventListener(type, wrappedListener, undefined);\n });\n });\n this._listenerMap.clear();\n }\n\n /**\n * Native implementation of addEventListener\n * To be implemented by derived classes\n */\n protected _nativeAddEventListener(\n type: string,\n listener: EventListener,\n options?: boolean | AddEventListenerOptions\n ): void {\n throw new Error('_nativeAddEventListener must be implemented by derived classes');\n }\n\n /**\n * Native implementation of removeEventListener\n * To be implemented by derived classes\n */\n protected _nativeRemoveEventListener(\n type: string,\n listener: EventListener,\n options?: boolean | EventListenerOptions\n ): void {\n throw new Error('_nativeRemoveEventListener must be implemented by derived classes');\n }\n\n /**\n * Native implementation of dispatchEvent\n * To be implemented by derived classes\n */\n protected _nativeDispatchEvent(event: Event): boolean {\n throw new Error('_nativeDispatchEvent must be implemented by derived classes');\n }\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IAABBBounds } from '@visactor/vutils';
|
|
2
|
+
import type { Matrix } from '@visactor/vutils';
|
|
3
|
+
import type { IGlobal, IWindow } from '../interface';
|
|
4
|
+
export declare function createEventTransformer(containerElement: HTMLElement, getMatrix: () => Matrix, getRect: () => IAABBBounds, transformPoint: (clientX: number, clientY: number, matrix: Matrix, rect: IAABBBounds, transformedEvent: Event) => void): (event: Event) => Event;
|
|
5
|
+
export declare function createCanvasEventTransformer(canvasElement: HTMLCanvasElement, getMatrix: () => Matrix, getRect: () => IAABBBounds, transformPoint: (clientX: number, clientY: number, matrix: Matrix, rect: IAABBBounds, transformedEvent: Event) => void): (event: Event) => Event;
|
|
6
|
+
export declare function registerWindowEventTransformer(window: IWindow, container: HTMLElement, getMatrix: () => Matrix, getRect: () => IAABBBounds, transformPoint: (clientX: number, clientY: number, matrix: Matrix, rect: IAABBBounds, transformedEvent: Event) => void): void;
|
|
7
|
+
export declare function registerGlobalEventTransformer(global: IGlobal, container: HTMLElement, getMatrix: () => Matrix, getRect: () => IAABBBounds, transformPoint: (clientX: number, clientY: number, matrix: Matrix, rect: IAABBBounds, transformedEvent: Event) => void): void;
|
|
8
|
+
export declare function transformPointForCanvas(clientX: number, clientY: number, matrix: Matrix, rect: IAABBBounds, transformedEvent: Event): void;
|
|
9
|
+
export declare function mapToCanvasPointForCanvas(nativeEvent: any): {
|
|
10
|
+
x: any;
|
|
11
|
+
y: any;
|
|
12
|
+
};
|