@antv/g-lite 1.0.23 → 1.0.25
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/dist/Canvas.d.ts.map +1 -1
- package/dist/css/StyleValueRegistry.d.ts.map +1 -1
- package/dist/css/parser/color.d.ts.map +1 -1
- package/dist/css/parser/dimension.d.ts.map +1 -1
- package/dist/css/parser/gradient.d.ts.map +1 -1
- package/dist/css/parser/numeric.d.ts.map +1 -1
- package/dist/css/parser/path.d.ts.map +1 -1
- package/dist/css/parser/transform-origin.d.ts.map +1 -1
- package/dist/css/properties/CSSPropertyLengthOrPercentage.d.ts +3 -0
- package/dist/css/properties/CSSPropertyLengthOrPercentage.d.ts.map +1 -1
- package/dist/display-objects/DisplayObject.d.ts.map +1 -1
- package/dist/dom/Document.d.ts.map +1 -1
- package/dist/index.esm.js +71 -15
- package/dist/index.js +86 -30
- package/dist/index.umd.js +82 -58
- package/dist/index.umd.min.js +1 -1
- package/dist/services/EventService.d.ts +1 -0
- package/dist/services/EventService.d.ts.map +1 -1
- package/dist/services/TextService.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/memoize.d.ts +8 -0
- package/dist/utils/memoize.d.ts.map +1 -0
- package/dist/utils/text.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.umd.js
CHANGED
|
@@ -5355,13 +5355,6 @@
|
|
|
5355
5355
|
return result[0].length === result[1].length ? result : equalizeSegments(result[0], result[1], tl);
|
|
5356
5356
|
}
|
|
5357
5357
|
|
|
5358
|
-
/**
|
|
5359
|
-
* @see https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_isfunction
|
|
5360
|
-
*/
|
|
5361
|
-
var isFunction = (function (value) {
|
|
5362
|
-
return typeof value === 'function';
|
|
5363
|
-
});
|
|
5364
|
-
|
|
5365
5358
|
// isFinite,
|
|
5366
5359
|
var isNil = function (value) {
|
|
5367
5360
|
/**
|
|
@@ -5487,36 +5480,6 @@
|
|
|
5487
5480
|
return value === undefined;
|
|
5488
5481
|
};
|
|
5489
5482
|
|
|
5490
|
-
/**
|
|
5491
|
-
* _.memoize(calColor);
|
|
5492
|
-
* _.memoize(calColor, (...args) => args[0]);
|
|
5493
|
-
* @param f
|
|
5494
|
-
* @param resolver
|
|
5495
|
-
*/
|
|
5496
|
-
var memoize = (function (f, resolver) {
|
|
5497
|
-
if (!isFunction(f)) {
|
|
5498
|
-
throw new TypeError('Expected a function');
|
|
5499
|
-
}
|
|
5500
|
-
var memoized = function () {
|
|
5501
|
-
var args = [];
|
|
5502
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
5503
|
-
args[_i] = arguments[_i];
|
|
5504
|
-
}
|
|
5505
|
-
// 使用方法构造 key,如果不存在 resolver,则直接取第一个参数作为 key
|
|
5506
|
-
var key = resolver ? resolver.apply(this, args) : args[0];
|
|
5507
|
-
var cache = memoized.cache;
|
|
5508
|
-
if (cache.has(key)) {
|
|
5509
|
-
return cache.get(key);
|
|
5510
|
-
}
|
|
5511
|
-
var result = f.apply(this, args);
|
|
5512
|
-
// 缓存起来
|
|
5513
|
-
cache.set(key, result);
|
|
5514
|
-
return result;
|
|
5515
|
-
};
|
|
5516
|
-
memoized.cache = new Map();
|
|
5517
|
-
return memoized;
|
|
5518
|
-
});
|
|
5519
|
-
|
|
5520
5483
|
/**
|
|
5521
5484
|
* Axis-Aligned Bounding Box
|
|
5522
5485
|
* 为了便于后续 Frustum Culling,通过查找表定义 p-vertex 和 n-vertex
|
|
@@ -5892,6 +5855,28 @@
|
|
|
5892
5855
|
Shape["MESH"] = "mesh";
|
|
5893
5856
|
})(exports.Shape || (exports.Shape = {}));
|
|
5894
5857
|
|
|
5858
|
+
function memoize(func, resolver) {
|
|
5859
|
+
if (typeof func !== 'function' || resolver != null && typeof resolver !== 'function') {
|
|
5860
|
+
throw new TypeError('Expected a function');
|
|
5861
|
+
}
|
|
5862
|
+
var memoized = function memoized() {
|
|
5863
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
5864
|
+
args[_key] = arguments[_key];
|
|
5865
|
+
}
|
|
5866
|
+
var key = resolver ? resolver.apply(this, args) : args[0];
|
|
5867
|
+
var cache = memoized.cache;
|
|
5868
|
+
if (cache.has(key)) {
|
|
5869
|
+
return cache.get(key);
|
|
5870
|
+
}
|
|
5871
|
+
var result = func.apply(this, args);
|
|
5872
|
+
memoized.cache = cache.set(key, result) || cache;
|
|
5873
|
+
return result;
|
|
5874
|
+
};
|
|
5875
|
+
memoized.cache = new (memoize.Cache || Map)();
|
|
5876
|
+
return memoized;
|
|
5877
|
+
}
|
|
5878
|
+
memoize.Cache = Map;
|
|
5879
|
+
|
|
5895
5880
|
var camelCase = memoize(function (str) {
|
|
5896
5881
|
if (str === void 0) {
|
|
5897
5882
|
str = '';
|
|
@@ -5916,7 +5901,7 @@
|
|
|
5916
5901
|
throw new Error();
|
|
5917
5902
|
}
|
|
5918
5903
|
}
|
|
5919
|
-
function isFunction
|
|
5904
|
+
function isFunction(func) {
|
|
5920
5905
|
return typeof func === 'function';
|
|
5921
5906
|
}
|
|
5922
5907
|
var definedProps = function definedProps(obj) {
|
|
@@ -9627,6 +9612,7 @@
|
|
|
9627
9612
|
function piMod(angle) {
|
|
9628
9613
|
return (angle + Math.PI * 2) % (Math.PI * 2);
|
|
9629
9614
|
}
|
|
9615
|
+
|
|
9630
9616
|
var line = {
|
|
9631
9617
|
/**
|
|
9632
9618
|
* 计算线段的包围盒
|
|
@@ -9721,6 +9707,7 @@
|
|
|
9721
9707
|
return Math.atan2(y2 - y1, x2 - x1);
|
|
9722
9708
|
}
|
|
9723
9709
|
};
|
|
9710
|
+
|
|
9724
9711
|
var EPSILON$1 = 0.0001;
|
|
9725
9712
|
/**
|
|
9726
9713
|
* 使用牛顿切割法求最近的点
|
|
@@ -9890,6 +9877,7 @@
|
|
|
9890
9877
|
return piMod(angle);
|
|
9891
9878
|
}
|
|
9892
9879
|
};
|
|
9880
|
+
|
|
9893
9881
|
function cubicAt(p0, p1, p2, p3, t) {
|
|
9894
9882
|
var onet = 1 - t; // t * t * t 的性能大概是 Math.pow(t, 3) 的三倍
|
|
9895
9883
|
return onet * onet * onet * p0 + 3 * p1 * t * onet * onet + 3 * p2 * t * t * onet + p3 * t * t * t;
|
|
@@ -10321,6 +10309,7 @@
|
|
|
10321
10309
|
return piMod(Math.atan2(dy, dx));
|
|
10322
10310
|
}
|
|
10323
10311
|
};
|
|
10312
|
+
|
|
10324
10313
|
function analyzePoints(points) {
|
|
10325
10314
|
// 计算每段的长度和总的长度
|
|
10326
10315
|
var totalLength = 0;
|
|
@@ -10433,6 +10422,7 @@
|
|
|
10433
10422
|
}
|
|
10434
10423
|
return minDistance;
|
|
10435
10424
|
}
|
|
10425
|
+
|
|
10436
10426
|
var polyline = {
|
|
10437
10427
|
/**
|
|
10438
10428
|
* 计算多折线的包围盒
|
|
@@ -12204,7 +12194,7 @@
|
|
|
12204
12194
|
_proto.addEventListener = function addEventListener(type, listener, options) {
|
|
12205
12195
|
var capture = isBoolean(options) && options || isObject(options) && options.capture;
|
|
12206
12196
|
var once = isObject(options) && options.once;
|
|
12207
|
-
var context = isFunction
|
|
12197
|
+
var context = isFunction(listener) ? undefined : listener;
|
|
12208
12198
|
// compatible with G 3.0
|
|
12209
12199
|
// support using delegate name in event type, eg. 'node:click'
|
|
12210
12200
|
var useDelegatedName = false;
|
|
@@ -12218,7 +12208,7 @@
|
|
|
12218
12208
|
useDelegatedName = true;
|
|
12219
12209
|
}
|
|
12220
12210
|
type = capture ? type + "capture" : type;
|
|
12221
|
-
listener = isFunction
|
|
12211
|
+
listener = isFunction(listener) ? listener : listener.handleEvent;
|
|
12222
12212
|
// compatible with G 3.0
|
|
12223
12213
|
if (useDelegatedName) {
|
|
12224
12214
|
var originListener = listener;
|
|
@@ -12260,9 +12250,9 @@
|
|
|
12260
12250
|
_proto.removeEventListener = function removeEventListener(type, listener, options) {
|
|
12261
12251
|
var _listener;
|
|
12262
12252
|
var capture = isBoolean(options) && options || isObject(options) && options.capture;
|
|
12263
|
-
var context = isFunction
|
|
12253
|
+
var context = isFunction(listener) ? undefined : listener;
|
|
12264
12254
|
type = capture ? type + "capture" : type;
|
|
12265
|
-
listener = isFunction
|
|
12255
|
+
listener = isFunction(listener) ? listener : (_listener = listener) === null || _listener === void 0 ? void 0 : _listener.handleEvent;
|
|
12266
12256
|
this.emitter.off(type, listener, context);
|
|
12267
12257
|
return this;
|
|
12268
12258
|
}
|
|
@@ -12593,7 +12583,7 @@
|
|
|
12593
12583
|
inh = _ref.inh,
|
|
12594
12584
|
d = _ref.d;
|
|
12595
12585
|
if (inh && d) {
|
|
12596
|
-
initialStyle[n] = isFunction
|
|
12586
|
+
initialStyle[n] = isFunction(d) ? d(exports.Shape.GROUP) : d;
|
|
12597
12587
|
}
|
|
12598
12588
|
});
|
|
12599
12589
|
// like <html> in DOM tree
|
|
@@ -12633,7 +12623,11 @@
|
|
|
12633
12623
|
};
|
|
12634
12624
|
_proto.destroy = function destroy() {
|
|
12635
12625
|
try {
|
|
12636
|
-
this.documentElement.
|
|
12626
|
+
[].concat(this.documentElement.childNodes).forEach(function (child, i) {
|
|
12627
|
+
child.forEach(function (object) {
|
|
12628
|
+
object.destroy();
|
|
12629
|
+
});
|
|
12630
|
+
});
|
|
12637
12631
|
this.timeline.destroy();
|
|
12638
12632
|
} catch (e) {}
|
|
12639
12633
|
}
|
|
@@ -13878,6 +13872,12 @@
|
|
|
13878
13872
|
this.getAnimations().forEach(function (animation) {
|
|
13879
13873
|
animation.cancel();
|
|
13880
13874
|
});
|
|
13875
|
+
this.renderable = null;
|
|
13876
|
+
this.cullable = null;
|
|
13877
|
+
this.transformable = null;
|
|
13878
|
+
this.rBushNode = null;
|
|
13879
|
+
this.geometry = null;
|
|
13880
|
+
this.sortable = null;
|
|
13881
13881
|
};
|
|
13882
13882
|
_proto.cloneNode = function cloneNode(deep, customCloneFunc) {
|
|
13883
13883
|
var clonedStyle = _extends({}, this.attributes);
|
|
@@ -13924,9 +13924,12 @@
|
|
|
13924
13924
|
// account for FCP, process properties as less as possible
|
|
13925
13925
|
runtime.styleValueRegistry.processProperties(this, attributes, {
|
|
13926
13926
|
forceUpdateGeometry: true,
|
|
13927
|
-
usedAttributes:
|
|
13928
|
-
//
|
|
13929
|
-
|
|
13927
|
+
usedAttributes: INHERITABLE_STYLE_PROPS
|
|
13928
|
+
// usedAttributes:
|
|
13929
|
+
// // only Group / Text should account for text relative props
|
|
13930
|
+
// this.tagName === Shape.GROUP || this.tagName === Shape.TEXT
|
|
13931
|
+
// ? INHERITABLE_STYLE_PROPS
|
|
13932
|
+
// : INHERITABLE_BASE_STYLE_PROPS,
|
|
13930
13933
|
});
|
|
13931
13934
|
// redraw at next frame
|
|
13932
13935
|
renderable.dirty = true;
|
|
@@ -18403,12 +18406,7 @@
|
|
|
18403
18406
|
}];
|
|
18404
18407
|
var propertyMetadataCache = {};
|
|
18405
18408
|
var unresolvedProperties = new WeakMap();
|
|
18406
|
-
|
|
18407
|
-
var sortAttributeNames = memoize(function (attributeNames) {
|
|
18408
|
-
return attributeNames.sort(function (a, b) {
|
|
18409
|
-
return priorityMap[a] - priorityMap[b];
|
|
18410
|
-
});
|
|
18411
|
-
});
|
|
18409
|
+
// const uniqueAttributeSet = new Set<string>();
|
|
18412
18410
|
var tmpVec3a = create$2();
|
|
18413
18411
|
var tmpVec3b = create$2();
|
|
18414
18412
|
var tmpVec3c = create$2();
|
|
@@ -18434,7 +18432,6 @@
|
|
|
18434
18432
|
_proto.registerMetadata = function registerMetadata(metadata) {
|
|
18435
18433
|
[metadata.n].concat(metadata.a || []).forEach(function (name) {
|
|
18436
18434
|
propertyMetadataCache[name] = metadata;
|
|
18437
|
-
priorityMap[name] = metadata.p || 0;
|
|
18438
18435
|
});
|
|
18439
18436
|
};
|
|
18440
18437
|
_proto.unregisterMetadata = function unregisterMetadata(name) {
|
|
@@ -18486,8 +18483,24 @@
|
|
|
18486
18483
|
}
|
|
18487
18484
|
// let hasUnresolvedProperties = false;
|
|
18488
18485
|
// parse according to priority
|
|
18489
|
-
|
|
18490
|
-
//
|
|
18486
|
+
// path 50
|
|
18487
|
+
// points 50
|
|
18488
|
+
// text 50
|
|
18489
|
+
// textTransform 51
|
|
18490
|
+
// anchor 99
|
|
18491
|
+
// transform 100
|
|
18492
|
+
// transformOrigin 100
|
|
18493
|
+
if (usedAttributes === null || usedAttributes === void 0 ? void 0 : usedAttributes.length) {
|
|
18494
|
+
// uniqueAttributeSet.clear();
|
|
18495
|
+
attributeNames = Array.from(new Set(attributeNames.concat(usedAttributes)));
|
|
18496
|
+
}
|
|
18497
|
+
['path', 'points', 'text', 'textTransform', 'anchor', 'transform', 'transformOrigin'].forEach(function (name) {
|
|
18498
|
+
var index = attributeNames.indexOf(name);
|
|
18499
|
+
if (index > -1) {
|
|
18500
|
+
attributeNames.splice(index, 1);
|
|
18501
|
+
attributeNames.push(name);
|
|
18502
|
+
}
|
|
18503
|
+
});
|
|
18491
18504
|
attributeNames.forEach(function (name) {
|
|
18492
18505
|
// some style props maybe deleted after parsing such as `anchor` in Text
|
|
18493
18506
|
if (name in object.computedStyle) {
|
|
@@ -18577,7 +18590,7 @@
|
|
|
18577
18590
|
if (value === 'initial') {
|
|
18578
18591
|
// @see https://developer.mozilla.org/en-US/docs/Web/CSS/initial
|
|
18579
18592
|
if (!isNil(defaultValue)) {
|
|
18580
|
-
computed = this.parseProperty(name, isFunction
|
|
18593
|
+
computed = this.parseProperty(name, isFunction(defaultValue) ? defaultValue(object.nodeName) : defaultValue, object);
|
|
18581
18594
|
}
|
|
18582
18595
|
} else if (value === 'inherit') {
|
|
18583
18596
|
// @see https://developer.mozilla.org/en-US/docs/Web/CSS/inherit
|
|
@@ -20164,6 +20177,12 @@
|
|
|
20164
20177
|
this.addEventMapping('pointerupoutside', this.onPointerUpOutside);
|
|
20165
20178
|
this.addEventMapping('wheel', this.onWheel);
|
|
20166
20179
|
};
|
|
20180
|
+
_proto.destroy = function destroy() {
|
|
20181
|
+
this.emitter.removeAllListeners();
|
|
20182
|
+
this.mappingTable = {};
|
|
20183
|
+
this.mappingState = {};
|
|
20184
|
+
this.eventPool.clear();
|
|
20185
|
+
};
|
|
20167
20186
|
_proto.client2Viewport = function client2Viewport(client) {
|
|
20168
20187
|
var bbox = this.context.contextService.getBoundingClientRect();
|
|
20169
20188
|
return new Point(client.x - ((bbox === null || bbox === void 0 ? void 0 : bbox.left) || 0), client.y - ((bbox === null || bbox === void 0 ? void 0 : bbox.top) || 0));
|
|
@@ -21951,7 +21970,7 @@
|
|
|
21951
21970
|
// account for textPath
|
|
21952
21971
|
if (textPath) {
|
|
21953
21972
|
var totalPathLength = textPath.getTotalLength();
|
|
21954
|
-
|
|
21973
|
+
// const startingPoint = textPath.getPoint(0);
|
|
21955
21974
|
for (var i = 0; i < lines.length; i++) {
|
|
21956
21975
|
var width = context.measureText(lines[i]).width + (lines[i].length - 1) * letterSpacing;
|
|
21957
21976
|
// for (
|
|
@@ -23121,6 +23140,11 @@
|
|
|
23121
23140
|
if (destroyScenegraph) {
|
|
23122
23141
|
// destroy Document
|
|
23123
23142
|
this.document.destroy();
|
|
23143
|
+
this.getEventService().destroy();
|
|
23144
|
+
// clear rbush
|
|
23145
|
+
this.context.rBushRoot.clear();
|
|
23146
|
+
this.context.rBushRoot = null;
|
|
23147
|
+
this.context.renderingContext.root = null;
|
|
23124
23148
|
}
|
|
23125
23149
|
// destroy services
|
|
23126
23150
|
this.getRenderingService().destroy();
|