@antv/g-lite 2.4.0 → 2.5.0

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.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /*!
2
2
  * @antv/g-lite
3
3
  * @description A core module for rendering engine implements DOM API.
4
- * @version 2.4.0
5
- * @date 10/13/2025, 7:00:43 AM
4
+ * @version 2.5.0
5
+ * @date 12/10/2025, 8:42:24 AM
6
6
  * @author AntVis
7
7
  * @docs https://g.antv.antgroup.com/
8
8
  */
@@ -21,12 +21,15 @@ require('@babel/runtime/helpers/readOnlyError');
21
21
  var util = require('@antv/util');
22
22
  var _defineProperty = require('@babel/runtime/helpers/defineProperty');
23
23
  var _superPropGet = require('@babel/runtime/helpers/superPropGet');
24
+ var _arrayLikeToArray = require('@babel/runtime/helpers/arrayLikeToArray');
24
25
  var gMath = require('@antv/g-math');
25
26
  var _regeneratorRuntime = require('@babel/runtime/helpers/regeneratorRuntime');
26
27
  var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
27
28
  var _createForOfIteratorHelper = require('@babel/runtime/helpers/createForOfIteratorHelper');
28
29
  var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
29
30
 
31
+ /// <reference types="webxr" />
32
+
30
33
  var Shape = /*#__PURE__*/function (Shape) {
31
34
  Shape["GROUP"] = "g";
32
35
  Shape["FRAGMENT"] = "fragment";
@@ -8499,6 +8502,11 @@ var CustomEvent = /*#__PURE__*/function (_FederatedEvent) {
8499
8502
  _this.type = eventName;
8500
8503
  _this.detail = options === null || options === void 0 ? void 0 : options.detail;
8501
8504
 
8505
+ // compatible
8506
+ if (options && !('detail' in options)) {
8507
+ _this.detail = options;
8508
+ }
8509
+
8502
8510
  // compatible with G 3.0
8503
8511
  Object.assign(_this, options);
8504
8512
  return _this;
@@ -8594,9 +8602,7 @@ var EventTarget = /*#__PURE__*/function () {
8594
8602
  }, {
8595
8603
  key: "emit",
8596
8604
  value: function emit(eventName, object) {
8597
- this.dispatchEvent(new CustomEvent(eventName, {
8598
- detail: object
8599
- }));
8605
+ this.dispatchEvent(new CustomEvent(eventName, object));
8600
8606
  }
8601
8607
  }, {
8602
8608
  key: "dispatchEventToSelf",
@@ -8694,6 +8700,7 @@ var Node = /*#__PURE__*/function (_EventTarget) {
8694
8700
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Node/nodeValue
8695
8701
  */
8696
8702
  _this.nodeValue = null;
8703
+ _this.mutations = undefined;
8697
8704
  /**
8698
8705
  * @see https://developer.mozilla.org/en-US/docs/Web/API/ParentNode
8699
8706
  */
@@ -10133,7 +10140,6 @@ var RenderingService = /*#__PURE__*/function () {
10133
10140
  value: function destroy() {
10134
10141
  this.inited = false;
10135
10142
  this.hooks.destroy.call();
10136
- this.globalRuntime.sceneGraphService.clearMutationObserverData();
10137
10143
  }
10138
10144
  }, {
10139
10145
  key: "dirty",
@@ -10402,7 +10408,6 @@ var $rotate_ParentInvertRotation = glMatrix.quat.create();
10402
10408
  var DefaultSceneGraphService = /*#__PURE__*/function () {
10403
10409
  function DefaultSceneGraphService(runtime) {
10404
10410
  _classCallCheck(this, DefaultSceneGraphService);
10405
- this.mutationsMap = new Map();
10406
10411
  this.displayObjectDependencyMap = new WeakMap();
10407
10412
  this.runtime = runtime;
10408
10413
  }
@@ -11091,7 +11096,6 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
11091
11096
  key: "syncHierarchy",
11092
11097
  value: function syncHierarchy(rootNode) {
11093
11098
  var _transformable, _transformable2;
11094
- // console.log('syncHierarchy');
11095
11099
  var stack = [rootNode];
11096
11100
  var ancestors = rootNode.parentNode ? [{
11097
11101
  node: rootNode.parentNode,
@@ -11174,21 +11178,25 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
11174
11178
  });
11175
11179
  }
11176
11180
  this.informDependentDisplayObjects(element);
11177
- var mutation = this.mutationsMap.get(element);
11178
- if (!mutation) {
11179
- mutation = {
11181
+ var mutations = element.mutations || [];
11182
+ var boundChangeMutation = mutations.find(function (item) {
11183
+ return item.type === 'attributes' && item._boundsChangeData;
11184
+ });
11185
+ if (!boundChangeMutation) {
11186
+ boundChangeMutation = {
11180
11187
  type: 'attributes',
11181
11188
  target: element,
11182
11189
  _boundsChangeData: {
11183
11190
  affectChildren: affectChildren
11184
11191
  }
11185
11192
  };
11186
- this.mutationsMap.set(element, mutation);
11193
+ mutations.push(boundChangeMutation);
11187
11194
  } else {
11188
- mutation._boundsChangeData = {
11189
- affectChildren: mutation._boundsChangeData.affectChildren || affectChildren
11195
+ boundChangeMutation._boundsChangeData = {
11196
+ affectChildren: boundChangeMutation._boundsChangeData.affectChildren || affectChildren
11190
11197
  };
11191
11198
  }
11199
+ element.mutations = mutations;
11192
11200
  }
11193
11201
  }, {
11194
11202
  key: "dirtyFragment",
@@ -11208,16 +11216,21 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
11208
11216
  }, {
11209
11217
  key: "notifyMutationObservers",
11210
11218
  value: function notifyMutationObservers(canvas) {
11211
- var event = new CustomEvent(ElementEvent.BOUNDS_CHANGED, {
11212
- detail: Array.from(this.mutationsMap.values())
11219
+ var mutations = [];
11220
+ canvas.getRoot().forEach(function (item) {
11221
+ (item.mutations || []).forEach(function (mutation) {
11222
+ if (mutation.type === 'attributes' && mutation._boundsChangeData) {
11223
+ mutations.push(mutation);
11224
+ }
11225
+ });
11226
+ item.mutations = undefined;
11213
11227
  });
11214
- canvas.dispatchEvent(event, true, true);
11215
- this.clearMutationObserverData();
11216
- }
11217
- }, {
11218
- key: "clearMutationObserverData",
11219
- value: function clearMutationObserverData() {
11220
- this.mutationsMap.clear();
11228
+ if (mutations.length > 0) {
11229
+ var event = new CustomEvent(ElementEvent.BOUNDS_CHANGED, {
11230
+ detail: mutations
11231
+ });
11232
+ canvas.dispatchEvent(event, true, true);
11233
+ }
11221
11234
  }
11222
11235
  }, {
11223
11236
  key: "updateDisplayObjectDependency",
@@ -12361,7 +12374,7 @@ var Element = /*#__PURE__*/function (_Node) {
12361
12374
  nodes[_key3] = arguments[_key3];
12362
12375
  }
12363
12376
  var first = nodes[0],
12364
- rest = nodes.slice(1);
12377
+ rest = _arrayLikeToArray(nodes).slice(1);
12365
12378
  this.parentNode.appendChild(first, index);
12366
12379
  (_ref = first).after.apply(_ref, _toConsumableArray(rest));
12367
12380
  }