@antv/g-lite 1.0.23 → 1.0.24

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/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$1(func) {
5904
+ function isFunction(func) {
5920
5905
  return typeof func === 'function';
5921
5906
  }
5922
5907
  var definedProps = function definedProps(obj) {
@@ -12204,7 +12189,7 @@
12204
12189
  _proto.addEventListener = function addEventListener(type, listener, options) {
12205
12190
  var capture = isBoolean(options) && options || isObject(options) && options.capture;
12206
12191
  var once = isObject(options) && options.once;
12207
- var context = isFunction$1(listener) ? undefined : listener;
12192
+ var context = isFunction(listener) ? undefined : listener;
12208
12193
  // compatible with G 3.0
12209
12194
  // support using delegate name in event type, eg. 'node:click'
12210
12195
  var useDelegatedName = false;
@@ -12218,7 +12203,7 @@
12218
12203
  useDelegatedName = true;
12219
12204
  }
12220
12205
  type = capture ? type + "capture" : type;
12221
- listener = isFunction$1(listener) ? listener : listener.handleEvent;
12206
+ listener = isFunction(listener) ? listener : listener.handleEvent;
12222
12207
  // compatible with G 3.0
12223
12208
  if (useDelegatedName) {
12224
12209
  var originListener = listener;
@@ -12260,9 +12245,9 @@
12260
12245
  _proto.removeEventListener = function removeEventListener(type, listener, options) {
12261
12246
  var _listener;
12262
12247
  var capture = isBoolean(options) && options || isObject(options) && options.capture;
12263
- var context = isFunction$1(listener) ? undefined : listener;
12248
+ var context = isFunction(listener) ? undefined : listener;
12264
12249
  type = capture ? type + "capture" : type;
12265
- listener = isFunction$1(listener) ? listener : (_listener = listener) === null || _listener === void 0 ? void 0 : _listener.handleEvent;
12250
+ listener = isFunction(listener) ? listener : (_listener = listener) === null || _listener === void 0 ? void 0 : _listener.handleEvent;
12266
12251
  this.emitter.off(type, listener, context);
12267
12252
  return this;
12268
12253
  }
@@ -12593,7 +12578,7 @@
12593
12578
  inh = _ref.inh,
12594
12579
  d = _ref.d;
12595
12580
  if (inh && d) {
12596
- initialStyle[n] = isFunction$1(d) ? d(exports.Shape.GROUP) : d;
12581
+ initialStyle[n] = isFunction(d) ? d(exports.Shape.GROUP) : d;
12597
12582
  }
12598
12583
  });
12599
12584
  // like <html> in DOM tree
@@ -12633,7 +12618,11 @@
12633
12618
  };
12634
12619
  _proto.destroy = function destroy() {
12635
12620
  try {
12636
- this.documentElement.destroy();
12621
+ [].concat(this.documentElement.childNodes).forEach(function (child, i) {
12622
+ child.forEach(function (object) {
12623
+ object.destroy();
12624
+ });
12625
+ });
12637
12626
  this.timeline.destroy();
12638
12627
  } catch (e) {}
12639
12628
  }
@@ -13878,6 +13867,12 @@
13878
13867
  this.getAnimations().forEach(function (animation) {
13879
13868
  animation.cancel();
13880
13869
  });
13870
+ this.renderable = null;
13871
+ this.cullable = null;
13872
+ this.transformable = null;
13873
+ this.rBushNode = null;
13874
+ this.geometry = null;
13875
+ this.sortable = null;
13881
13876
  };
13882
13877
  _proto.cloneNode = function cloneNode(deep, customCloneFunc) {
13883
13878
  var clonedStyle = _extends({}, this.attributes);
@@ -18403,12 +18398,7 @@
18403
18398
  }];
18404
18399
  var propertyMetadataCache = {};
18405
18400
  var unresolvedProperties = new WeakMap();
18406
- var priorityMap = {};
18407
- var sortAttributeNames = memoize(function (attributeNames) {
18408
- return attributeNames.sort(function (a, b) {
18409
- return priorityMap[a] - priorityMap[b];
18410
- });
18411
- });
18401
+ // const uniqueAttributeSet = new Set<string>();
18412
18402
  var tmpVec3a = create$2();
18413
18403
  var tmpVec3b = create$2();
18414
18404
  var tmpVec3c = create$2();
@@ -18434,7 +18424,6 @@
18434
18424
  _proto.registerMetadata = function registerMetadata(metadata) {
18435
18425
  [metadata.n].concat(metadata.a || []).forEach(function (name) {
18436
18426
  propertyMetadataCache[name] = metadata;
18437
- priorityMap[name] = metadata.p || 0;
18438
18427
  });
18439
18428
  };
18440
18429
  _proto.unregisterMetadata = function unregisterMetadata(name) {
@@ -18486,8 +18475,24 @@
18486
18475
  }
18487
18476
  // let hasUnresolvedProperties = false;
18488
18477
  // parse according to priority
18489
- attributeNames = sortAttributeNames((usedAttributes === null || usedAttributes === void 0 ? void 0 : usedAttributes.length) ? Array.from(new Set(attributeNames.concat(usedAttributes))) : attributeNames);
18490
- // attributeNames.sort((a, b) => priorityMap[a] - priorityMap[b]);
18478
+ // path 50
18479
+ // points 50
18480
+ // text 50
18481
+ // textTransform 51
18482
+ // anchor 99
18483
+ // transform 100
18484
+ // transformOrigin 100
18485
+ if (usedAttributes === null || usedAttributes === void 0 ? void 0 : usedAttributes.length) {
18486
+ // uniqueAttributeSet.clear();
18487
+ attributeNames = Array.from(new Set(attributeNames.concat(usedAttributes)));
18488
+ }
18489
+ ['path', 'points', 'text', 'textTransform', 'anchor', 'transform', 'transformOrigin'].forEach(function (name) {
18490
+ var index = attributeNames.indexOf(name);
18491
+ if (index > -1) {
18492
+ attributeNames.splice(index, 1);
18493
+ attributeNames.push(name);
18494
+ }
18495
+ });
18491
18496
  attributeNames.forEach(function (name) {
18492
18497
  // some style props maybe deleted after parsing such as `anchor` in Text
18493
18498
  if (name in object.computedStyle) {
@@ -18577,7 +18582,7 @@
18577
18582
  if (value === 'initial') {
18578
18583
  // @see https://developer.mozilla.org/en-US/docs/Web/CSS/initial
18579
18584
  if (!isNil(defaultValue)) {
18580
- computed = this.parseProperty(name, isFunction$1(defaultValue) ? defaultValue(object.nodeName) : defaultValue, object);
18585
+ computed = this.parseProperty(name, isFunction(defaultValue) ? defaultValue(object.nodeName) : defaultValue, object);
18581
18586
  }
18582
18587
  } else if (value === 'inherit') {
18583
18588
  // @see https://developer.mozilla.org/en-US/docs/Web/CSS/inherit
@@ -20164,6 +20169,12 @@
20164
20169
  this.addEventMapping('pointerupoutside', this.onPointerUpOutside);
20165
20170
  this.addEventMapping('wheel', this.onWheel);
20166
20171
  };
20172
+ _proto.destroy = function destroy() {
20173
+ this.emitter.removeAllListeners();
20174
+ this.mappingTable = {};
20175
+ this.mappingState = {};
20176
+ this.eventPool.clear();
20177
+ };
20167
20178
  _proto.client2Viewport = function client2Viewport(client) {
20168
20179
  var bbox = this.context.contextService.getBoundingClientRect();
20169
20180
  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 +21962,7 @@
21951
21962
  // account for textPath
21952
21963
  if (textPath) {
21953
21964
  var totalPathLength = textPath.getTotalLength();
21954
- var startingPoint = textPath.getPoint(0);
21965
+ // const startingPoint = textPath.getPoint(0);
21955
21966
  for (var i = 0; i < lines.length; i++) {
21956
21967
  var width = context.measureText(lines[i]).width + (lines[i].length - 1) * letterSpacing;
21957
21968
  // for (
@@ -23125,6 +23136,11 @@
23125
23136
  // destroy services
23126
23137
  this.getRenderingService().destroy();
23127
23138
  this.getContextService().destroy();
23139
+ this.getEventService().destroy();
23140
+ // clear rbush
23141
+ this.context.rBushRoot.clear();
23142
+ this.context.rBushRoot = null;
23143
+ this.context.renderingContext.root = null;
23128
23144
  if (!skipTriggerEvent) {
23129
23145
  this.dispatchEvent(new CustomEvent(exports.CanvasEvent.AFTER_DESTROY));
23130
23146
  }