@antv/g-lite 2.0.11-alpha.7 → 2.0.12-alpha.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.
Files changed (299) hide show
  1. package/dist/AbstractRenderer.d.ts +0 -1
  2. package/dist/Canvas.d.ts +2 -2
  3. package/dist/camera/Camera.d.ts +0 -1
  4. package/dist/camera/Landmark.d.ts +0 -1
  5. package/dist/camera/index.d.ts +0 -1
  6. package/dist/camera/interfaces.d.ts +0 -1
  7. package/dist/components/Cullable.d.ts +0 -1
  8. package/dist/components/Geometry.d.ts +0 -1
  9. package/dist/components/RBushNode.d.ts +0 -1
  10. package/dist/components/Renderable.d.ts +0 -5
  11. package/dist/components/Sortable.d.ts +0 -1
  12. package/dist/components/Transform.d.ts +0 -5
  13. package/dist/components/index.d.ts +0 -1
  14. package/dist/css/CSS.d.ts +0 -1
  15. package/dist/css/CSSProperty.d.ts +1 -10
  16. package/dist/css/CSSStyleValuePool.d.ts +0 -1
  17. package/dist/css/StyleValueRegistry.d.ts +2 -26
  18. package/dist/css/cssom/CSSColorValue.d.ts +1 -1
  19. package/dist/css/cssom/CSSGradientValue.d.ts +0 -1
  20. package/dist/css/cssom/CSSKeywordValue.d.ts +0 -1
  21. package/dist/css/cssom/CSSNumericValue.d.ts +1 -1
  22. package/dist/css/cssom/CSSRGB.d.ts +0 -1
  23. package/dist/css/cssom/CSSStyleValue.d.ts +1 -2
  24. package/dist/css/cssom/index.d.ts +0 -2
  25. package/dist/css/cssom/types.d.ts +0 -8
  26. package/dist/css/index.d.ts +0 -1
  27. package/dist/css/interfaces.d.ts +8 -8
  28. package/dist/css/parser/color.d.ts +0 -1
  29. package/dist/css/parser/dimension.d.ts +0 -1
  30. package/dist/css/parser/filter.d.ts +0 -1
  31. package/dist/css/parser/gradient.d.ts +0 -1
  32. package/dist/css/parser/index.d.ts +0 -1
  33. package/dist/css/parser/numeric.d.ts +0 -1
  34. package/dist/css/parser/path.d.ts +0 -1
  35. package/dist/css/parser/points.d.ts +0 -1
  36. package/dist/css/parser/transform-origin.d.ts +0 -3
  37. package/dist/css/parser/transform.d.ts +0 -1
  38. package/dist/css/parser/types.d.ts +0 -1
  39. package/dist/css/properties/CSSPropertyAngle.d.ts +0 -7
  40. package/dist/css/properties/CSSPropertyClipPath.d.ts +0 -1
  41. package/dist/css/properties/CSSPropertyColor.d.ts +0 -5
  42. package/dist/css/properties/CSSPropertyFilter.d.ts +0 -3
  43. package/dist/css/properties/CSSPropertyLengthOrPercentage.d.ts +0 -7
  44. package/dist/css/properties/CSSPropertyLengthOrPercentage12.d.ts +0 -2
  45. package/dist/css/properties/CSSPropertyLengthOrPercentage14.d.ts +0 -2
  46. package/dist/css/properties/CSSPropertyMarker.d.ts +0 -1
  47. package/dist/css/properties/CSSPropertyNumber.d.ts +0 -7
  48. package/dist/css/properties/CSSPropertyOffsetDistance.d.ts +0 -7
  49. package/dist/css/properties/CSSPropertyOpacity.d.ts +0 -7
  50. package/dist/css/properties/CSSPropertyPath.d.ts +0 -2
  51. package/dist/css/properties/CSSPropertyPoints.d.ts +1 -3
  52. package/dist/css/properties/CSSPropertyShadowBlur.d.ts +0 -1
  53. package/dist/css/properties/CSSPropertyText.d.ts +0 -1
  54. package/dist/css/properties/CSSPropertyTextTransform.d.ts +0 -1
  55. package/dist/css/properties/CSSPropertyTransform.d.ts +2 -5
  56. package/dist/css/properties/CSSPropertyTransformOrigin.d.ts +0 -6
  57. package/dist/css/properties/CSSPropertyZIndex.d.ts +0 -6
  58. package/dist/css/properties/index.d.ts +0 -1
  59. package/dist/display-objects/Circle.d.ts +0 -1
  60. package/dist/display-objects/CustomElement.d.ts +0 -1
  61. package/dist/display-objects/DisplayObject.d.ts +2 -10
  62. package/dist/display-objects/Ellipse.d.ts +0 -1
  63. package/dist/display-objects/Fragment.d.ts +13 -0
  64. package/dist/display-objects/Group.d.ts +0 -1
  65. package/dist/display-objects/HTML.d.ts +0 -1
  66. package/dist/display-objects/Image.d.ts +0 -1
  67. package/dist/display-objects/Line.d.ts +0 -1
  68. package/dist/display-objects/Path.d.ts +0 -1
  69. package/dist/display-objects/Polygon.d.ts +0 -1
  70. package/dist/display-objects/Polyline.d.ts +0 -1
  71. package/dist/display-objects/Rect.d.ts +0 -1
  72. package/dist/display-objects/Text.d.ts +0 -1
  73. package/dist/display-objects/constants.d.ts +0 -1
  74. package/dist/display-objects/index.d.ts +1 -1
  75. package/dist/dom/CustomElementRegistry.d.ts +0 -1
  76. package/dist/dom/CustomEvent.d.ts +0 -1
  77. package/dist/dom/Document.d.ts +1 -2
  78. package/dist/dom/Element.d.ts +3 -3
  79. package/dist/dom/EventTarget.d.ts +1 -2
  80. package/dist/dom/FederatedEvent.d.ts +1 -1
  81. package/dist/dom/FederatedMouseEvent.d.ts +0 -1
  82. package/dist/dom/FederatedPointerEvent.d.ts +0 -1
  83. package/dist/dom/FederatedWheelEvent.d.ts +0 -1
  84. package/dist/dom/MutationEvent.d.ts +0 -1
  85. package/dist/dom/Node.d.ts +7 -2
  86. package/dist/dom/index.d.ts +0 -1
  87. package/dist/dom/interfaces.d.ts +4 -8
  88. package/dist/global-runtime.d.ts +0 -13
  89. package/dist/index.d.ts +0 -2
  90. package/dist/index.esm.js +611 -1204
  91. package/dist/index.esm.js.map +1 -1
  92. package/dist/index.js +610 -1201
  93. package/dist/index.js.map +1 -1
  94. package/dist/index.umd.min.js +1 -1
  95. package/dist/index.umd.min.js.map +1 -1
  96. package/dist/plugins/CullingPlugin.d.ts +0 -1
  97. package/dist/plugins/DirtyCheckPlugin.d.ts +0 -1
  98. package/dist/plugins/EventPlugin.d.ts +0 -1
  99. package/dist/plugins/FrustumCullingStrategy.d.ts +0 -1
  100. package/dist/plugins/PrepareRendererPlugin.d.ts +3 -5
  101. package/dist/services/ContextService.d.ts +0 -1
  102. package/dist/services/EventService.d.ts +0 -1
  103. package/dist/services/OffscreenCanvasCreator.d.ts +0 -1
  104. package/dist/services/RenderingContext.d.ts +0 -1
  105. package/dist/services/RenderingService.d.ts +3 -10
  106. package/dist/services/SceneGraphSelector.d.ts +0 -1
  107. package/dist/services/SceneGraphService.d.ts +3 -12
  108. package/dist/services/TextService.d.ts +0 -1
  109. package/dist/services/aabb/CircleUpdater.d.ts +0 -1
  110. package/dist/services/aabb/EllipseUpdater.d.ts +0 -1
  111. package/dist/services/aabb/GroupUpdater.d.ts +0 -1
  112. package/dist/services/aabb/HTMLUpdater.d.ts +0 -1
  113. package/dist/services/aabb/LineUpdater.d.ts +0 -1
  114. package/dist/services/aabb/PathUpdater.d.ts +0 -1
  115. package/dist/services/aabb/PolylineUpdater.d.ts +0 -1
  116. package/dist/services/aabb/RectUpdater.d.ts +0 -1
  117. package/dist/services/aabb/TextUpdater.d.ts +0 -1
  118. package/dist/services/aabb/index.d.ts +0 -1
  119. package/dist/services/aabb/interfaces.d.ts +0 -1
  120. package/dist/services/index.d.ts +0 -1
  121. package/dist/services/interfaces.d.ts +1 -2
  122. package/dist/shapes/AABB.d.ts +0 -1
  123. package/dist/shapes/Frustum.d.ts +0 -1
  124. package/dist/shapes/Plane.d.ts +0 -1
  125. package/dist/shapes/Point.d.ts +0 -1
  126. package/dist/shapes/Rectangle.d.ts +0 -1
  127. package/dist/shapes/index.d.ts +0 -1
  128. package/dist/types.d.ts +7 -17
  129. package/dist/utils/assert.d.ts +0 -8
  130. package/dist/utils/canvas.d.ts +1 -2
  131. package/dist/utils/dom.d.ts +0 -1
  132. package/dist/utils/error.d.ts +0 -1
  133. package/dist/utils/event.d.ts +0 -1
  134. package/dist/utils/fragment.d.ts +2 -0
  135. package/dist/utils/gradient.d.ts +0 -1
  136. package/dist/utils/index.d.ts +1 -2
  137. package/dist/utils/math.d.ts +0 -1
  138. package/dist/utils/memoize.d.ts +0 -1
  139. package/dist/utils/path.d.ts +0 -1
  140. package/dist/utils/pointer-events.d.ts +0 -1
  141. package/dist/utils/raf.d.ts +0 -1
  142. package/dist/utils/tapable/AsyncParallelHook.d.ts +0 -1
  143. package/dist/utils/tapable/AsyncSeriesWaterfallHook.d.ts +0 -1
  144. package/dist/utils/tapable/Hook.d.ts +0 -1
  145. package/dist/utils/tapable/SyncHook.d.ts +0 -1
  146. package/dist/utils/tapable/SyncWaterfallHook.d.ts +0 -1
  147. package/dist/utils/tapable/index.d.ts +0 -1
  148. package/dist/utils/text.d.ts +0 -1
  149. package/dist/utils/transform-mat4.d.ts +0 -1
  150. package/package.json +2 -2
  151. package/dist/AbstractRenderer.d.ts.map +0 -1
  152. package/dist/Canvas.d.ts.map +0 -1
  153. package/dist/camera/Camera.d.ts.map +0 -1
  154. package/dist/camera/Landmark.d.ts.map +0 -1
  155. package/dist/camera/index.d.ts.map +0 -1
  156. package/dist/camera/interfaces.d.ts.map +0 -1
  157. package/dist/components/Cullable.d.ts.map +0 -1
  158. package/dist/components/Geometry.d.ts.map +0 -1
  159. package/dist/components/RBushNode.d.ts.map +0 -1
  160. package/dist/components/Renderable.d.ts.map +0 -1
  161. package/dist/components/Sortable.d.ts.map +0 -1
  162. package/dist/components/Transform.d.ts.map +0 -1
  163. package/dist/components/index.d.ts.map +0 -1
  164. package/dist/css/CSS.d.ts.map +0 -1
  165. package/dist/css/CSSProperty.d.ts.map +0 -1
  166. package/dist/css/CSSStyleValuePool.d.ts.map +0 -1
  167. package/dist/css/StyleValueRegistry.d.ts.map +0 -1
  168. package/dist/css/cssom/CSSColorValue.d.ts.map +0 -1
  169. package/dist/css/cssom/CSSGradientValue.d.ts.map +0 -1
  170. package/dist/css/cssom/CSSKeywordValue.d.ts.map +0 -1
  171. package/dist/css/cssom/CSSMathOperator.d.ts +0 -12
  172. package/dist/css/cssom/CSSMathOperator.d.ts.map +0 -1
  173. package/dist/css/cssom/CSSNumericSumValue.d.ts +0 -8
  174. package/dist/css/cssom/CSSNumericSumValue.d.ts.map +0 -1
  175. package/dist/css/cssom/CSSNumericValue.d.ts.map +0 -1
  176. package/dist/css/cssom/CSSRGB.d.ts.map +0 -1
  177. package/dist/css/cssom/CSSStyleValue.d.ts.map +0 -1
  178. package/dist/css/cssom/index.d.ts.map +0 -1
  179. package/dist/css/cssom/types.d.ts.map +0 -1
  180. package/dist/css/index.d.ts.map +0 -1
  181. package/dist/css/interfaces.d.ts.map +0 -1
  182. package/dist/css/parser/color.d.ts.map +0 -1
  183. package/dist/css/parser/dimension.d.ts.map +0 -1
  184. package/dist/css/parser/filter.d.ts.map +0 -1
  185. package/dist/css/parser/gradient.d.ts.map +0 -1
  186. package/dist/css/parser/index.d.ts.map +0 -1
  187. package/dist/css/parser/numeric.d.ts.map +0 -1
  188. package/dist/css/parser/path.d.ts.map +0 -1
  189. package/dist/css/parser/points.d.ts.map +0 -1
  190. package/dist/css/parser/transform-origin.d.ts.map +0 -1
  191. package/dist/css/parser/transform.d.ts.map +0 -1
  192. package/dist/css/parser/types.d.ts.map +0 -1
  193. package/dist/css/properties/CSSPropertyAngle.d.ts.map +0 -1
  194. package/dist/css/properties/CSSPropertyClipPath.d.ts.map +0 -1
  195. package/dist/css/properties/CSSPropertyColor.d.ts.map +0 -1
  196. package/dist/css/properties/CSSPropertyFilter.d.ts.map +0 -1
  197. package/dist/css/properties/CSSPropertyLengthOrPercentage.d.ts.map +0 -1
  198. package/dist/css/properties/CSSPropertyLengthOrPercentage12.d.ts.map +0 -1
  199. package/dist/css/properties/CSSPropertyLengthOrPercentage14.d.ts.map +0 -1
  200. package/dist/css/properties/CSSPropertyMarker.d.ts.map +0 -1
  201. package/dist/css/properties/CSSPropertyNumber.d.ts.map +0 -1
  202. package/dist/css/properties/CSSPropertyOffsetDistance.d.ts.map +0 -1
  203. package/dist/css/properties/CSSPropertyOpacity.d.ts.map +0 -1
  204. package/dist/css/properties/CSSPropertyPath.d.ts.map +0 -1
  205. package/dist/css/properties/CSSPropertyPoints.d.ts.map +0 -1
  206. package/dist/css/properties/CSSPropertyShadowBlur.d.ts.map +0 -1
  207. package/dist/css/properties/CSSPropertyText.d.ts.map +0 -1
  208. package/dist/css/properties/CSSPropertyTextTransform.d.ts.map +0 -1
  209. package/dist/css/properties/CSSPropertyTransform.d.ts.map +0 -1
  210. package/dist/css/properties/CSSPropertyTransformOrigin.d.ts.map +0 -1
  211. package/dist/css/properties/CSSPropertyZIndex.d.ts.map +0 -1
  212. package/dist/css/properties/index.d.ts.map +0 -1
  213. package/dist/display-objects/Circle.d.ts.map +0 -1
  214. package/dist/display-objects/CustomElement.d.ts.map +0 -1
  215. package/dist/display-objects/DisplayObject.d.ts.map +0 -1
  216. package/dist/display-objects/Ellipse.d.ts.map +0 -1
  217. package/dist/display-objects/Group.d.ts.map +0 -1
  218. package/dist/display-objects/HTML.d.ts.map +0 -1
  219. package/dist/display-objects/Image.d.ts.map +0 -1
  220. package/dist/display-objects/Line.d.ts.map +0 -1
  221. package/dist/display-objects/Path.d.ts.map +0 -1
  222. package/dist/display-objects/Polygon.d.ts.map +0 -1
  223. package/dist/display-objects/Polyline.d.ts.map +0 -1
  224. package/dist/display-objects/Rect.d.ts.map +0 -1
  225. package/dist/display-objects/Text.d.ts.map +0 -1
  226. package/dist/display-objects/constants.d.ts.map +0 -1
  227. package/dist/display-objects/index.d.ts.map +0 -1
  228. package/dist/dom/CustomElementRegistry.d.ts.map +0 -1
  229. package/dist/dom/CustomEvent.d.ts.map +0 -1
  230. package/dist/dom/Document.d.ts.map +0 -1
  231. package/dist/dom/Element.d.ts.map +0 -1
  232. package/dist/dom/EventTarget.d.ts.map +0 -1
  233. package/dist/dom/FederatedEvent.d.ts.map +0 -1
  234. package/dist/dom/FederatedMouseEvent.d.ts.map +0 -1
  235. package/dist/dom/FederatedPointerEvent.d.ts.map +0 -1
  236. package/dist/dom/FederatedWheelEvent.d.ts.map +0 -1
  237. package/dist/dom/MutationEvent.d.ts.map +0 -1
  238. package/dist/dom/Node.d.ts.map +0 -1
  239. package/dist/dom/index.d.ts.map +0 -1
  240. package/dist/dom/interfaces.d.ts.map +0 -1
  241. package/dist/global-runtime.d.ts.map +0 -1
  242. package/dist/index.d.ts.map +0 -1
  243. package/dist/plugins/CullingPlugin.d.ts.map +0 -1
  244. package/dist/plugins/DirtyCheckPlugin.d.ts.map +0 -1
  245. package/dist/plugins/EventPlugin.d.ts.map +0 -1
  246. package/dist/plugins/FrustumCullingStrategy.d.ts.map +0 -1
  247. package/dist/plugins/PrepareRendererPlugin.d.ts.map +0 -1
  248. package/dist/preset.d.ts +0 -2
  249. package/dist/preset.d.ts.map +0 -1
  250. package/dist/services/ContextService.d.ts.map +0 -1
  251. package/dist/services/EventService.d.ts.map +0 -1
  252. package/dist/services/OffscreenCanvasCreator.d.ts.map +0 -1
  253. package/dist/services/RenderingContext.d.ts.map +0 -1
  254. package/dist/services/RenderingService.d.ts.map +0 -1
  255. package/dist/services/SceneGraphSelector.d.ts.map +0 -1
  256. package/dist/services/SceneGraphService.d.ts.map +0 -1
  257. package/dist/services/TextService.d.ts.map +0 -1
  258. package/dist/services/aabb/CircleUpdater.d.ts.map +0 -1
  259. package/dist/services/aabb/EllipseUpdater.d.ts.map +0 -1
  260. package/dist/services/aabb/GroupUpdater.d.ts.map +0 -1
  261. package/dist/services/aabb/HTMLUpdater.d.ts.map +0 -1
  262. package/dist/services/aabb/LineUpdater.d.ts.map +0 -1
  263. package/dist/services/aabb/PathUpdater.d.ts.map +0 -1
  264. package/dist/services/aabb/PolylineUpdater.d.ts.map +0 -1
  265. package/dist/services/aabb/RectUpdater.d.ts.map +0 -1
  266. package/dist/services/aabb/TextUpdater.d.ts.map +0 -1
  267. package/dist/services/aabb/index.d.ts.map +0 -1
  268. package/dist/services/aabb/interfaces.d.ts.map +0 -1
  269. package/dist/services/index.d.ts.map +0 -1
  270. package/dist/services/interfaces.d.ts.map +0 -1
  271. package/dist/shapes/AABB.d.ts.map +0 -1
  272. package/dist/shapes/Frustum.d.ts.map +0 -1
  273. package/dist/shapes/Plane.d.ts.map +0 -1
  274. package/dist/shapes/Point.d.ts.map +0 -1
  275. package/dist/shapes/Rectangle.d.ts.map +0 -1
  276. package/dist/shapes/index.d.ts.map +0 -1
  277. package/dist/types.d.ts.map +0 -1
  278. package/dist/utils/assert.d.ts.map +0 -1
  279. package/dist/utils/canvas.d.ts.map +0 -1
  280. package/dist/utils/dom.d.ts.map +0 -1
  281. package/dist/utils/error.d.ts.map +0 -1
  282. package/dist/utils/event.d.ts.map +0 -1
  283. package/dist/utils/gradient.d.ts.map +0 -1
  284. package/dist/utils/index.d.ts.map +0 -1
  285. package/dist/utils/math.d.ts.map +0 -1
  286. package/dist/utils/memoize.d.ts.map +0 -1
  287. package/dist/utils/path.d.ts.map +0 -1
  288. package/dist/utils/pointer-events.d.ts.map +0 -1
  289. package/dist/utils/raf.d.ts.map +0 -1
  290. package/dist/utils/string.d.ts +0 -6
  291. package/dist/utils/string.d.ts.map +0 -1
  292. package/dist/utils/tapable/AsyncParallelHook.d.ts.map +0 -1
  293. package/dist/utils/tapable/AsyncSeriesWaterfallHook.d.ts.map +0 -1
  294. package/dist/utils/tapable/Hook.d.ts.map +0 -1
  295. package/dist/utils/tapable/SyncHook.d.ts.map +0 -1
  296. package/dist/utils/tapable/SyncWaterfallHook.d.ts.map +0 -1
  297. package/dist/utils/tapable/index.d.ts.map +0 -1
  298. package/dist/utils/text.d.ts.map +0 -1
  299. package/dist/utils/transform-mat4.d.ts.map +0 -1
package/dist/index.esm.js CHANGED
@@ -1,12 +1,10 @@
1
- import { glMatrix, vec3, vec4, mat4, mat3, quat as quat$1, vec2 } from 'gl-matrix';
2
- import { __assign, __read, __extends, __values, __spreadArray, __awaiter, __generator, __rest } from 'tslib';
1
+ import { __assign, __read, __extends, __spreadArray, __awaiter, __generator, __values, __rest } from 'tslib';
3
2
  import EventEmitter from 'eventemitter3';
4
- import { isNumber, distanceSquareRoot, isString, isNil, clamp, getTotalLength, min, max, isNumberEqual, mod, normalizePath, path2Curve, equalizeSegments, getDrawDirection, reverseCurve, clonePath, getRotatedCurve, isUndefined, isFunction, isArray, isBoolean, isObject, getPointAtLength } from '@antv/util';
3
+ import { vec3, vec4, mat4, mat3, quat as quat$1, vec2 } from 'gl-matrix';
4
+ import { isNumber, distanceSquareRoot, isString, isNil, clamp, getTotalLength, min, max, isNumberEqual, mod, normalizePath, path2Curve, equalizeSegments, getDrawDirection, reverseCurve, clonePath, getRotatedCurve, isUndefined, isArray, isBoolean, isFunction, isObject, getPointAtLength } from '@antv/util';
5
5
  import * as d3 from 'd3-color';
6
6
  import { polylineLength, arcBox, cubicBox, quadBox, linePointAt, lineLength } from '@antv/g-math';
7
7
 
8
- glMatrix.setMatrixArrayType(Array);
9
-
10
8
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
11
9
 
12
10
  var rbush = {exports: {}};
@@ -590,6 +588,7 @@ var RBush = rbush.exports;
590
588
  var Shape;
591
589
  (function (Shape) {
592
590
  Shape["GROUP"] = "g";
591
+ Shape["FRAGMENT"] = "fragment";
593
592
  Shape["CIRCLE"] = "circle";
594
593
  Shape["ELLIPSE"] = "ellipse";
595
594
  Shape["IMAGE"] = "image";
@@ -643,7 +642,7 @@ var AbstractRenderer = /** @class */ (function () {
643
642
  /**
644
643
  * enable dirty rectangle rendering by default
645
644
  */
646
- enableDirtyRectangleRendering: true, enableSizeAttenuation: true, imageSmoothingEnabled: true, imageSmoothingQuality: 'high' }, config);
645
+ enableDirtyRectangleRendering: true, enableDirtyRectangleRenderingDebug: false, enableSizeAttenuation: true }, config);
647
646
  }
648
647
  AbstractRenderer.prototype.registerPlugin = function (plugin) {
649
648
  var index = this.plugins.findIndex(function (p) { return p === plugin; });
@@ -680,10 +679,10 @@ var addVec3 = vec3.add, copyVec3 = vec3.copy, maxVec3 = vec3.max, minVec3 = vec3
680
679
  */
681
680
  var AABB = /** @class */ (function () {
682
681
  function AABB() {
683
- this.center = vec3.create();
684
- this.halfExtents = vec3.create();
685
- this.min = vec3.create();
686
- this.max = vec3.create();
682
+ this.center = [0, 0, 0];
683
+ this.halfExtents = [0, 0, 0];
684
+ this.min = [0, 0, 0];
685
+ this.max = [0, 0, 0];
687
686
  }
688
687
  AABB.isEmpty = function (aabb) {
689
688
  return (!aabb ||
@@ -2168,6 +2167,99 @@ var Camera = /** @class */ (function () {
2168
2167
  return Camera;
2169
2168
  }());
2170
2169
 
2170
+ /**
2171
+ * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#changing-mesh-culling-strategy
2172
+ */
2173
+ var Strategy;
2174
+ (function (Strategy) {
2175
+ Strategy[Strategy["Standard"] = 0] = "Standard";
2176
+ })(Strategy || (Strategy = {}));
2177
+
2178
+ var SortReason;
2179
+ (function (SortReason) {
2180
+ SortReason[SortReason["ADDED"] = 0] = "ADDED";
2181
+ SortReason[SortReason["REMOVED"] = 1] = "REMOVED";
2182
+ SortReason[SortReason["Z_INDEX_CHANGED"] = 2] = "Z_INDEX_CHANGED";
2183
+ })(SortReason || (SortReason = {}));
2184
+
2185
+ var EMPTY_PARSED_PATH = {
2186
+ absolutePath: [],
2187
+ hasArc: false,
2188
+ segments: [],
2189
+ polygons: [],
2190
+ polylines: [],
2191
+ curve: null,
2192
+ totalLength: 0,
2193
+ rect: new Rectangle(0, 0, 0, 0),
2194
+ };
2195
+
2196
+ /**
2197
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type
2198
+ */
2199
+ var PropertySyntax;
2200
+ (function (PropertySyntax) {
2201
+ /**
2202
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#coordinate
2203
+ */
2204
+ PropertySyntax["COORDINATE"] = "<coordinate>";
2205
+ /**
2206
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#color
2207
+ */
2208
+ PropertySyntax["COLOR"] = "<color>";
2209
+ /**
2210
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#paint
2211
+ */
2212
+ PropertySyntax["PAINT"] = "<paint>";
2213
+ /**
2214
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#number
2215
+ */
2216
+ PropertySyntax["NUMBER"] = "<number>";
2217
+ /**
2218
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/angle
2219
+ */
2220
+ PropertySyntax["ANGLE"] = "<angle>";
2221
+ /**
2222
+ * <number> with range 0..1
2223
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#opacity_value
2224
+ */
2225
+ PropertySyntax["OPACITY_VALUE"] = "<opacity-value>";
2226
+ /**
2227
+ * <number> with range 0..Infinity
2228
+ */
2229
+ PropertySyntax["SHADOW_BLUR"] = "<shadow-blur>";
2230
+ /**
2231
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#length
2232
+ */
2233
+ PropertySyntax["LENGTH"] = "<length>";
2234
+ /**
2235
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#percentage
2236
+ */
2237
+ PropertySyntax["PERCENTAGE"] = "<percentage>";
2238
+ PropertySyntax["LENGTH_PERCENTAGE"] = "<length> | <percentage>";
2239
+ PropertySyntax["LENGTH_PERCENTAGE_12"] = "[<length> | <percentage>]{1,2}";
2240
+ /**
2241
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/margin#formal_syntax
2242
+ */
2243
+ PropertySyntax["LENGTH_PERCENTAGE_14"] = "[<length> | <percentage>]{1,4}";
2244
+ /**
2245
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#list-of-ts
2246
+ */
2247
+ PropertySyntax["LIST_OF_POINTS"] = "<list-of-points>";
2248
+ PropertySyntax["PATH"] = "<path>";
2249
+ /**
2250
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/filter#formal_syntax
2251
+ */
2252
+ PropertySyntax["FILTER"] = "<filter>";
2253
+ PropertySyntax["Z_INDEX"] = "<z-index>";
2254
+ PropertySyntax["OFFSET_DISTANCE"] = "<offset-distance>";
2255
+ PropertySyntax["DEFINED_PATH"] = "<defined-path>";
2256
+ PropertySyntax["MARKER"] = "<marker>";
2257
+ PropertySyntax["TRANSFORM"] = "<transform>";
2258
+ PropertySyntax["TRANSFORM_ORIGIN"] = "<transform-origin>";
2259
+ PropertySyntax["TEXT"] = "<text>";
2260
+ PropertySyntax["TEXT_TRANSFORM"] = "<text-transform>";
2261
+ })(PropertySyntax || (PropertySyntax = {}));
2262
+
2171
2263
  function memoize(func, resolver) {
2172
2264
  if (typeof func !== 'function' ||
2173
2265
  (resolver != null && typeof resolver !== 'function')) {
@@ -2284,14 +2376,6 @@ var UnitCategory;
2284
2376
  // kUResolution,
2285
2377
  UnitCategory[UnitCategory["kUOther"] = 5] = "kUOther";
2286
2378
  })(UnitCategory || (UnitCategory = {}));
2287
- var ValueRange;
2288
- (function (ValueRange) {
2289
- ValueRange[ValueRange["kAll"] = 0] = "kAll";
2290
- ValueRange[ValueRange["kNonNegative"] = 1] = "kNonNegative";
2291
- ValueRange[ValueRange["kInteger"] = 2] = "kInteger";
2292
- ValueRange[ValueRange["kNonNegativeInteger"] = 3] = "kNonNegativeInteger";
2293
- ValueRange[ValueRange["kPositiveInteger"] = 4] = "kPositiveInteger";
2294
- })(ValueRange || (ValueRange = {}));
2295
2379
  var Nested;
2296
2380
  (function (Nested) {
2297
2381
  Nested[Nested["kYes"] = 0] = "kYes";
@@ -2810,13 +2894,6 @@ var CSSColorValue = /** @class */ (function (_super) {
2810
2894
  CSSColorValue.prototype.getType = function () {
2811
2895
  return CSSStyleValueType.kColorType;
2812
2896
  };
2813
- // buildCSSText(n: Nested, p: ParenLess, result: string): string {
2814
- // let text = '';
2815
- // if (this.colorSpace === 'rgb') {
2816
- // text = `rgba(${this.channels.join(',')},${this.alpha})`;
2817
- // }
2818
- // return (result += text);
2819
- // }
2820
2897
  /**
2821
2898
  * @see https://drafts.css-houdini.org/css-typed-om-1/#dom-csscolorvalue-to
2822
2899
  */
@@ -2877,99 +2954,6 @@ var CSSKeywordValue = /** @class */ (function (_super) {
2877
2954
  return CSSKeywordValue;
2878
2955
  }(CSSStyleValue));
2879
2956
 
2880
- var regexp = /-([a-z])/g;
2881
- var camelCase = memoize(function (str) {
2882
- if (str === void 0) { str = ''; }
2883
- return str.replace(regexp, function (g) { return g[1].toUpperCase(); });
2884
- });
2885
- var kebabize = function (str) {
2886
- return str
2887
- .split('')
2888
- .map(function (letter, idx) {
2889
- return letter.toUpperCase() === letter
2890
- ? "".concat(idx !== 0 ? '-' : '').concat(letter.toLowerCase())
2891
- : letter;
2892
- })
2893
- .join('');
2894
- };
2895
-
2896
- function DCHECK(bool) {
2897
- if (!bool) {
2898
- throw new Error();
2899
- }
2900
- }
2901
- function isSymbol(value) {
2902
- // @see https://github.com/lodash/lodash/blob/master/isSymbol.js
2903
- return typeof value === 'symbol';
2904
- }
2905
- var definedProps = function (obj) {
2906
- return Object.fromEntries(Object.entries(obj).filter(function (_a) {
2907
- var _b = __read(_a, 2), v = _b[1];
2908
- return v !== undefined;
2909
- }));
2910
- };
2911
- var FORMAT_ATTR_MAP = {
2912
- d: {
2913
- alias: 'path',
2914
- },
2915
- strokeDasharray: {
2916
- alias: 'lineDash',
2917
- },
2918
- strokeWidth: {
2919
- alias: 'lineWidth',
2920
- },
2921
- textAnchor: {
2922
- alias: 'textAlign',
2923
- },
2924
- src: {
2925
- alias: 'img',
2926
- },
2927
- };
2928
- var formatAttributeName = memoize(function (name) {
2929
- var attributeName = camelCase(name);
2930
- var map = FORMAT_ATTR_MAP[attributeName];
2931
- attributeName = (map === null || map === void 0 ? void 0 : map.alias) || attributeName;
2932
- return attributeName;
2933
- });
2934
- function formatAttributes(attributes) {
2935
- var e_1, _a;
2936
- var formattedAttributes = {};
2937
- try {
2938
- for (var _b = __values(Object.entries(attributes)), _c = _b.next(); !_c.done; _c = _b.next()) {
2939
- var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
2940
- var formattedKey = formatAttributeName(key);
2941
- formattedAttributes[formattedKey] = value;
2942
- }
2943
- }
2944
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
2945
- finally {
2946
- try {
2947
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
2948
- }
2949
- finally { if (e_1) throw e_1.error; }
2950
- }
2951
- return formattedAttributes;
2952
- }
2953
-
2954
- // type CSSNumericBaseType =
2955
- // | 'length'
2956
- // | 'angle'
2957
- // | 'time'
2958
- // | 'frequency'
2959
- // | 'resolution'
2960
- // | 'flex'
2961
- // | 'percent';
2962
- // https://drafts.css-houdini.org/css-typed-om/#dictdef-cssnumerictype
2963
- // interface CSSNumericType {
2964
- // length: number;
2965
- // angle: number;
2966
- // time: number;
2967
- // frequency: number;
2968
- // resolution: number;
2969
- // flex: number;
2970
- // percent: number;
2971
- // percentHint: CSSNumericBaseType;
2972
- // }
2973
2957
  var formatInfinityOrNaN = function (number, suffix) {
2974
2958
  if (suffix === void 0) { suffix = ''; }
2975
2959
  var result = '';
@@ -2980,7 +2964,6 @@ var formatInfinityOrNaN = function (number, suffix) {
2980
2964
  result = '-infinity';
2981
2965
  }
2982
2966
  else {
2983
- DCHECK(Number.isNaN(number));
2984
2967
  result = 'NaN';
2985
2968
  }
2986
2969
  return (result += suffix);
@@ -3076,8 +3059,8 @@ var CSSUnitValue = /** @class */ (function (_super) {
3076
3059
  case UnitType.kSeconds:
3077
3060
  // case UnitType.kHertz:
3078
3061
  // case UnitType.kKilohertz:
3079
- // case UnitType.kContainerMax: { // case UnitType.kContainerMin: // case UnitType.kContainerBlockSize: // case UnitType.kContainerInlineSize: // case UnitType.kContainerHeight: // case UnitType.kContainerWidth: // case UnitType.kDynamicViewportMax: // case UnitType.kDynamicViewportMin: // case UnitType.kDynamicViewportBlockSize: // case UnitType.kDynamicViewportInlineSize: // case UnitType.kDynamicViewportHeight: // case UnitType.kDynamicViewportWidth: // case UnitType.kLargeViewportMax: // case UnitType.kLargeViewportMin: // case UnitType.kLargeViewportBlockSize: // case UnitType.kLargeViewportInlineSize: // case UnitType.kLargeViewportHeight: // case UnitType.kLargeViewportWidth: // case UnitType.kSmallViewportMax: // case UnitType.kSmallViewportMin: // case UnitType.kSmallViewportBlockSize: // case UnitType.kSmallViewportInlineSize: // case UnitType.kSmallViewportHeight: // case UnitType.kSmallViewportWidth: // case UnitType.kViewportMax: // case UnitType.kViewportMin: // case UnitType.kViewportBlockSize: // case UnitType.kViewportInlineSize: // case UnitType.kViewportHeight: // case UnitType.kViewportWidth: // case UnitType.kFraction:
3080
3062
  case UnitType.kTurns: {
3063
+ // case UnitType.kContainerMax: { // case UnitType.kContainerMin: // case UnitType.kContainerBlockSize: // case UnitType.kContainerInlineSize: // case UnitType.kContainerHeight: // case UnitType.kContainerWidth: // case UnitType.kDynamicViewportMax: // case UnitType.kDynamicViewportMin: // case UnitType.kDynamicViewportBlockSize: // case UnitType.kDynamicViewportInlineSize: // case UnitType.kDynamicViewportHeight: // case UnitType.kDynamicViewportWidth: // case UnitType.kLargeViewportMax: // case UnitType.kLargeViewportMin: // case UnitType.kLargeViewportBlockSize: // case UnitType.kLargeViewportInlineSize: // case UnitType.kLargeViewportHeight: // case UnitType.kLargeViewportWidth: // case UnitType.kSmallViewportMax: // case UnitType.kSmallViewportMin: // case UnitType.kSmallViewportBlockSize: // case UnitType.kSmallViewportInlineSize: // case UnitType.kSmallViewportHeight: // case UnitType.kSmallViewportWidth: // case UnitType.kViewportMax: // case UnitType.kViewportMin: // case UnitType.kViewportBlockSize: // case UnitType.kViewportInlineSize: // case UnitType.kViewportHeight: // case UnitType.kViewportWidth: // case UnitType.kFraction:
3081
3064
  var kMinInteger = -999999;
3082
3065
  var kMaxInteger = 999999;
3083
3066
  var value = this.value;
@@ -3102,6 +3085,7 @@ var CSSUnitValue = /** @class */ (function (_super) {
3102
3085
  return CSSUnitValue;
3103
3086
  }(CSSStyleValue));
3104
3087
  var Opx = new CSSUnitValue(0, 'px');
3088
+ new CSSUnitValue(1, 'px');
3105
3089
  var Odeg = new CSSUnitValue(0, 'deg');
3106
3090
 
3107
3091
  /**
@@ -3177,99 +3161,6 @@ var getOrCreateUnitValue = function (value, unitOrName) {
3177
3161
  };
3178
3162
  new CSSUnitValue(50, '%');
3179
3163
 
3180
- /**
3181
- * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#changing-mesh-culling-strategy
3182
- */
3183
- var Strategy;
3184
- (function (Strategy) {
3185
- Strategy[Strategy["Standard"] = 0] = "Standard";
3186
- })(Strategy || (Strategy = {}));
3187
-
3188
- var SortReason;
3189
- (function (SortReason) {
3190
- SortReason[SortReason["ADDED"] = 0] = "ADDED";
3191
- SortReason[SortReason["REMOVED"] = 1] = "REMOVED";
3192
- SortReason[SortReason["Z_INDEX_CHANGED"] = 2] = "Z_INDEX_CHANGED";
3193
- })(SortReason || (SortReason = {}));
3194
-
3195
- var EMPTY_PARSED_PATH = {
3196
- absolutePath: [],
3197
- hasArc: false,
3198
- segments: [],
3199
- polygons: [],
3200
- polylines: [],
3201
- curve: null,
3202
- totalLength: 0,
3203
- rect: new Rectangle(0, 0, 0, 0),
3204
- };
3205
-
3206
- /**
3207
- * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type
3208
- */
3209
- var PropertySyntax;
3210
- (function (PropertySyntax) {
3211
- /**
3212
- * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#coordinate
3213
- */
3214
- PropertySyntax["COORDINATE"] = "<coordinate>";
3215
- /**
3216
- * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#color
3217
- */
3218
- PropertySyntax["COLOR"] = "<color>";
3219
- /**
3220
- * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#paint
3221
- */
3222
- PropertySyntax["PAINT"] = "<paint>";
3223
- /**
3224
- * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#number
3225
- */
3226
- PropertySyntax["NUMBER"] = "<number>";
3227
- /**
3228
- * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/angle
3229
- */
3230
- PropertySyntax["ANGLE"] = "<angle>";
3231
- /**
3232
- * <number> with range 0..1
3233
- * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#opacity_value
3234
- */
3235
- PropertySyntax["OPACITY_VALUE"] = "<opacity-value>";
3236
- /**
3237
- * <number> with range 0..Infinity
3238
- */
3239
- PropertySyntax["SHADOW_BLUR"] = "<shadow-blur>";
3240
- /**
3241
- * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#length
3242
- */
3243
- PropertySyntax["LENGTH"] = "<length>";
3244
- /**
3245
- * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#percentage
3246
- */
3247
- PropertySyntax["PERCENTAGE"] = "<percentage>";
3248
- PropertySyntax["LENGTH_PERCENTAGE"] = "<length> | <percentage>";
3249
- PropertySyntax["LENGTH_PERCENTAGE_12"] = "[<length> | <percentage>]{1,2}";
3250
- /**
3251
- * @see https://developer.mozilla.org/en-US/docs/Web/CSS/margin#formal_syntax
3252
- */
3253
- PropertySyntax["LENGTH_PERCENTAGE_14"] = "[<length> | <percentage>]{1,4}";
3254
- /**
3255
- * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#list-of-ts
3256
- */
3257
- PropertySyntax["LIST_OF_POINTS"] = "<list-of-points>";
3258
- PropertySyntax["PATH"] = "<path>";
3259
- /**
3260
- * @see https://developer.mozilla.org/en-US/docs/Web/CSS/filter#formal_syntax
3261
- */
3262
- PropertySyntax["FILTER"] = "<filter>";
3263
- PropertySyntax["Z_INDEX"] = "<z-index>";
3264
- PropertySyntax["OFFSET_DISTANCE"] = "<offset-distance>";
3265
- PropertySyntax["DEFINED_PATH"] = "<defined-path>";
3266
- PropertySyntax["MARKER"] = "<marker>";
3267
- PropertySyntax["TRANSFORM"] = "<transform>";
3268
- PropertySyntax["TRANSFORM_ORIGIN"] = "<transform-origin>";
3269
- PropertySyntax["TEXT"] = "<text>";
3270
- PropertySyntax["TEXT_TRANSFORM"] = "<text-transform>";
3271
- })(PropertySyntax || (PropertySyntax = {}));
3272
-
3273
3164
  /**
3274
3165
  * borrow from gradient-parser, but we delete some browser compatible prefix such as `-webkit-`
3275
3166
  * @see https://github.com/rafaelcaricio/gradient-parser
@@ -4093,16 +3984,6 @@ function parseDimensionArrayFormat(string, size) {
4093
3984
  }
4094
3985
  }
4095
3986
  }
4096
- function parseDimensionArray(string) {
4097
- if (isString(string)) {
4098
- // "1px 2px 3px"
4099
- return string.split(' ').map(function (segment) { return parseLengthOrPercentage(segment); });
4100
- }
4101
- else {
4102
- // [1, '2px', 3]
4103
- return string.map(function (segment) { return parseLengthOrPercentage(segment.toString()); });
4104
- }
4105
- }
4106
3987
  // export function mergeDimensionList(
4107
3988
  // left: CSSUnitValue[],
4108
3989
  // right: CSSUnitValue[],
@@ -5951,39 +5832,6 @@ var parseTransformOrigin = memoize(function (value) {
5951
5832
  ];
5952
5833
  }
5953
5834
  });
5954
- var parseTransformOriginUnmemoize = function (value) {
5955
- if (isString(value)) {
5956
- if (value === 'text-anchor') {
5957
- return [getOrCreateUnitValue(0, 'px'), getOrCreateUnitValue(0, 'px')];
5958
- }
5959
- var values = value.split(' ');
5960
- if (values.length === 1) {
5961
- if (values[0] === 'top' || values[0] === 'bottom') {
5962
- // 'top' -> 'center top'
5963
- values[1] = values[0];
5964
- values[0] = 'center';
5965
- }
5966
- else {
5967
- // '50px' -> '50px center'
5968
- values[1] = 'center';
5969
- }
5970
- }
5971
- if (values.length !== 2) {
5972
- return null;
5973
- }
5974
- // eg. center bottom
5975
- return [
5976
- parseLengthOrPercentageUnmemoize(convertKeyword2Percent(values[0])),
5977
- parseLengthOrPercentageUnmemoize(convertKeyword2Percent(values[1])),
5978
- ];
5979
- }
5980
- else {
5981
- return [
5982
- getOrCreateUnitValue(value[0] || 0, 'px'),
5983
- getOrCreateUnitValue(value[1] || 0, 'px'),
5984
- ];
5985
- }
5986
- };
5987
5835
  function convertKeyword2Percent(keyword) {
5988
5836
  if (keyword === 'center') {
5989
5837
  return '50%';
@@ -6578,19 +6426,7 @@ var BUILT_IN_PROPERTIES = [
6578
6426
  ];
6579
6427
  var GEOMETRY_ATTRIBUTE_NAMES = BUILT_IN_PROPERTIES.filter(function (n) { return !!n.l; }).map(function (n) { return n.n; });
6580
6428
  var propertyMetadataCache = {};
6581
- var unresolvedProperties = new WeakMap();
6582
- var isPropertyResolved = function (object, name) {
6583
- var properties = unresolvedProperties.get(object);
6584
- if (!properties || properties.length === 0) {
6585
- return true;
6586
- }
6587
- return properties.includes(name);
6588
- };
6589
6429
  var DefaultStyleValueRegistry = /** @class */ (function () {
6590
- /**
6591
- * need recalc later
6592
- */
6593
- // dirty = false;
6594
6430
  function DefaultStyleValueRegistry(runtime) {
6595
6431
  var _this = this;
6596
6432
  this.runtime = runtime;
@@ -6603,9 +6439,6 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6603
6439
  propertyMetadataCache[name] = metadata;
6604
6440
  });
6605
6441
  };
6606
- DefaultStyleValueRegistry.prototype.unregisterMetadata = function (name) {
6607
- delete propertyMetadataCache[name];
6608
- };
6609
6442
  DefaultStyleValueRegistry.prototype.getPropertySyntax = function (syntax) {
6610
6443
  return this.runtime.CSSPropertySyntaxFactory[syntax];
6611
6444
  };
@@ -6618,344 +6451,124 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6618
6451
  * * calculate used value
6619
6452
  * * post process
6620
6453
  */
6621
- DefaultStyleValueRegistry.prototype.processProperties = function (object, attributes, skipUpdateAttribute, skipParse, forceUpdateGeometry, usedAttributes, memoize) {
6622
- var _this = this;
6623
- if (skipUpdateAttribute === void 0) { skipUpdateAttribute = false; }
6624
- if (skipParse === void 0) { skipParse = false; }
6625
- if (forceUpdateGeometry === void 0) { forceUpdateGeometry = false; }
6626
- if (usedAttributes === void 0) { usedAttributes = undefined; }
6627
- if (memoize === void 0) { memoize = true; }
6628
- var needParseStyle = object.nodeName !== Shape.GROUP;
6629
- if (!this.runtime.enableCSSParsing) {
6630
- Object.assign(object.attributes, attributes);
6631
- // clipPath
6632
- var oldClipPath = object.parsedStyle.clipPath;
6633
- var oldOffsetPath = object.parsedStyle.offsetPath;
6634
- Object.assign(object.parsedStyle, attributes);
6635
- var needUpdateGeometry = !!forceUpdateGeometry;
6636
- if (!needUpdateGeometry) {
6637
- if (GEOMETRY_ATTRIBUTE_NAMES.some(function (name) { return name in attributes; })) {
6638
- needUpdateGeometry = true;
6639
- }
6640
- }
6641
- if (needParseStyle) {
6642
- if (attributes.fill) {
6643
- object.parsedStyle.fill = parseColor(attributes.fill);
6644
- }
6645
- if (attributes.stroke) {
6646
- object.parsedStyle.stroke = parseColor(attributes.stroke);
6647
- }
6648
- if (attributes.shadowColor) {
6649
- object.parsedStyle.shadowColor = parseColor(attributes.shadowColor);
6650
- }
6651
- if (attributes.filter) {
6652
- object.parsedStyle.filter = parseFilter(attributes.filter);
6653
- }
6654
- // Rect
6655
- // @ts-ignore
6656
- if (!isNil(attributes.radius)) {
6657
- // @ts-ignore
6658
- object.parsedStyle.radius = parseDimensionArrayFormat(
6659
- // @ts-ignore
6660
- attributes.radius, 4);
6661
- }
6662
- // Polyline
6663
- if (!isNil(attributes.lineDash)) {
6664
- object.parsedStyle.lineDash = parseDimensionArrayFormat(attributes.lineDash, 2);
6665
- }
6666
- // @ts-ignore
6667
- if (attributes.points) {
6668
- // @ts-ignore
6669
- object.parsedStyle.points = parsePoints(attributes.points);
6670
- }
6671
- // Path
6672
- // @ts-ignore
6673
- if (attributes.d === '') {
6674
- object.parsedStyle.d = __assign({}, EMPTY_PARSED_PATH);
6675
- }
6676
- // @ts-ignore
6677
- if (attributes.d) {
6678
- object.parsedStyle.d = parsePath(
6679
- // @ts-ignore
6680
- attributes.d);
6681
- }
6682
- // Text
6683
- if (attributes.textTransform) {
6684
- this.runtime.CSSPropertySyntaxFactory[PropertySyntax.TEXT_TRANSFORM].calculator(null, null, { value: attributes.textTransform }, object, null);
6685
- }
6686
- }
6687
- if (!isUndefined(attributes.clipPath)) {
6688
- this.runtime.CSSPropertySyntaxFactory[PropertySyntax.DEFINED_PATH].calculator('clipPath', oldClipPath, attributes.clipPath, object, this.runtime);
6689
- }
6690
- if (needParseStyle && attributes.offsetPath) {
6691
- this.runtime.CSSPropertySyntaxFactory[PropertySyntax.DEFINED_PATH].calculator('offsetPath', oldOffsetPath, attributes.offsetPath, object, this.runtime);
6692
- }
6693
- if (attributes.transform) {
6694
- object.parsedStyle.transform = parseTransform(attributes.transform);
6695
- }
6696
- if (attributes.transformOrigin) {
6697
- object.parsedStyle.transformOrigin = parseTransformOrigin(attributes.transformOrigin);
6698
- }
6699
- if (isNumber(attributes.zIndex)) {
6700
- this.runtime.CSSPropertySyntaxFactory[PropertySyntax.Z_INDEX].postProcessor(object);
6701
- }
6702
- if (needParseStyle) {
6703
- // Marker
6704
- // @ts-ignore
6705
- if (attributes.markerStart) {
6706
- object.parsedStyle.markerStart =
6707
- this.runtime.CSSPropertySyntaxFactory[PropertySyntax.MARKER].calculator(null,
6708
- // @ts-ignore
6709
- attributes.markerStart,
6710
- // @ts-ignore
6711
- attributes.markerStart, null, null);
6712
- }
6713
- // @ts-ignore
6714
- if (attributes.markerEnd) {
6715
- object.parsedStyle.markerEnd = this.runtime.CSSPropertySyntaxFactory[PropertySyntax.MARKER].calculator(null,
6716
- // @ts-ignore
6717
- attributes.markerEnd,
6718
- // @ts-ignore
6719
- attributes.markerEnd, null, null);
6720
- }
6721
- // @ts-ignore
6722
- if (attributes.markerMid) {
6723
- object.parsedStyle.markerMid = this.runtime.CSSPropertySyntaxFactory[PropertySyntax.MARKER].calculator('',
6724
- // @ts-ignore
6725
- attributes.markerMid,
6726
- // @ts-ignore
6727
- attributes.markerMid, null, null);
6728
- }
6729
- if (isNumber(attributes.offsetDistance)) {
6730
- this.runtime.CSSPropertySyntaxFactory[PropertySyntax.OFFSET_DISTANCE].postProcessor(object);
6731
- }
6732
- }
6733
- if (attributes.transform) {
6734
- this.runtime.CSSPropertySyntaxFactory[PropertySyntax.TRANSFORM].postProcessor(object);
6735
- }
6736
- if (attributes.transformOrigin) {
6737
- this.runtime.CSSPropertySyntaxFactory[PropertySyntax.TRANSFORM_ORIGIN].postProcessor(object);
6738
- }
6739
- if (needUpdateGeometry) {
6740
- object.geometry.dirty = true;
6741
- object.renderable.boundsDirty = true;
6742
- object.renderable.renderBoundsDirty = true;
6743
- if (!forceUpdateGeometry) {
6744
- this.runtime.sceneGraphService.dirtifyToRoot(object);
6745
- }
6746
- }
6454
+ DefaultStyleValueRegistry.prototype.processProperties = function (object, attributes, options) {
6455
+ if (options === void 0) { options = {
6456
+ skipUpdateAttribute: false,
6457
+ skipParse: false,
6458
+ forceUpdateGeometry: false,
6459
+ usedAttributes: [],
6460
+ memoize: true,
6461
+ }; }
6462
+ Object.assign(object.attributes, attributes);
6463
+ // clipPath
6464
+ var oldClipPath = object.parsedStyle.clipPath;
6465
+ var oldOffsetPath = object.parsedStyle.offsetPath;
6466
+ Object.assign(object.parsedStyle, attributes);
6467
+ var needUpdateGeometry = !!options.forceUpdateGeometry;
6468
+ if (!needUpdateGeometry &&
6469
+ GEOMETRY_ATTRIBUTE_NAMES.some(function (name) { return name in attributes; })) {
6470
+ needUpdateGeometry = true;
6471
+ }
6472
+ if (attributes.fill) {
6473
+ object.parsedStyle.fill = parseColor(attributes.fill);
6474
+ }
6475
+ if (attributes.stroke) {
6476
+ object.parsedStyle.stroke = parseColor(attributes.stroke);
6477
+ }
6478
+ if (attributes.shadowColor) {
6479
+ object.parsedStyle.shadowColor = parseColor(attributes.shadowColor);
6480
+ }
6481
+ if (attributes.filter) {
6482
+ object.parsedStyle.filter = parseFilter(attributes.filter);
6483
+ }
6484
+ // Rect
6485
+ // @ts-ignore
6486
+ if (!isNil(attributes.radius)) {
6487
+ // @ts-ignore
6488
+ object.parsedStyle.radius = parseDimensionArrayFormat(
6489
+ // @ts-ignore
6490
+ attributes.radius, 4);
6747
6491
  }
6748
- else {
6749
- var needUpdateGeometry_1 = forceUpdateGeometry;
6750
- var attributeNames_1 = Object.keys(attributes);
6751
- attributeNames_1.forEach(function (attributeName) {
6752
- var _a;
6753
- if (!skipUpdateAttribute) {
6754
- object.attributes[attributeName] = attributes[attributeName];
6755
- }
6756
- if (!needUpdateGeometry_1 && ((_a = propertyMetadataCache[attributeName]) === null || _a === void 0 ? void 0 : _a.l)) {
6757
- needUpdateGeometry_1 = true;
6758
- }
6759
- });
6760
- if (!skipParse) {
6761
- attributeNames_1.forEach(function (name) {
6762
- object.computedStyle[name] = _this.parseProperty(name, object.attributes[name], object, memoize);
6763
- });
6764
- }
6765
- // let hasUnresolvedProperties = false;
6766
- // parse according to priority
6767
- // path 50
6768
- // points 50
6769
- // text 50
6770
- // textTransform 51
6771
- // transform 100
6772
- // transformOrigin 100
6773
- if (usedAttributes === null || usedAttributes === void 0 ? void 0 : usedAttributes.length) {
6774
- // uniqueAttributeSet.clear();
6775
- attributeNames_1 = Array.from(new Set(attributeNames_1.concat(usedAttributes)));
6776
- }
6777
- attributeNames_1.forEach(function (name) {
6778
- // some style props maybe deleted after parsing such as `anchor` in Text
6779
- if (name in object.computedStyle) {
6780
- object.parsedStyle[name] = _this.computeProperty(name, object.computedStyle[name], object, memoize);
6781
- }
6782
- });
6783
- // update geometry
6784
- if (needUpdateGeometry_1) {
6785
- object.geometry.dirty = true;
6786
- object.renderable.boundsDirty = true;
6787
- object.renderable.renderBoundsDirty = true;
6788
- if (!forceUpdateGeometry) {
6789
- this.runtime.sceneGraphService.dirtifyToRoot(object);
6790
- }
6791
- }
6792
- attributeNames_1.forEach(function (name) {
6793
- if (name in object.parsedStyle) {
6794
- _this.postProcessProperty(name, object, attributeNames_1);
6795
- }
6796
- });
6797
- if (this.runtime.enableCSSParsing && object.children.length) {
6798
- attributeNames_1.forEach(function (name) {
6799
- if (name in object.parsedStyle && _this.isPropertyInheritable(name)) {
6800
- // update children's inheritable
6801
- object.children.forEach(function (child) {
6802
- child.internalSetAttribute(name, null, true, true, undefined, undefined, undefined);
6803
- });
6804
- }
6805
- });
6806
- }
6492
+ // Polyline
6493
+ if (!isNil(attributes.lineDash)) {
6494
+ object.parsedStyle.lineDash = parseDimensionArrayFormat(attributes.lineDash, 2);
6807
6495
  }
6808
- };
6809
- /**
6810
- * string -> parsed value
6811
- */
6812
- DefaultStyleValueRegistry.prototype.parseProperty = function (name, value, object, memoized) {
6813
- var metadata = propertyMetadataCache[name];
6814
- var computed = value;
6815
- if (value === '' || isNil(value)) {
6816
- value = 'unset';
6496
+ // @ts-ignore
6497
+ if (attributes.points) {
6498
+ // @ts-ignore
6499
+ object.parsedStyle.points = parsePoints(attributes.points);
6817
6500
  }
6818
- if (value === 'unset' || value === 'initial' || value === 'inherit') {
6819
- // computed = new CSSKeywordValue(value);
6820
- computed = getOrCreateKeyword(value);
6501
+ // Path
6502
+ // @ts-ignore
6503
+ if (attributes.d === '') {
6504
+ object.parsedStyle.d = __assign({}, EMPTY_PARSED_PATH);
6821
6505
  }
6822
- else {
6823
- if (metadata) {
6824
- var keywords = metadata.k, syntax = metadata.syntax;
6825
- var handler = syntax && this.getPropertySyntax(syntax);
6826
- // use keywords
6827
- if (keywords && keywords.indexOf(value) > -1) {
6828
- // computed = new CSSKeywordValue(value);
6829
- computed = getOrCreateKeyword(value);
6830
- }
6831
- else if (handler) {
6832
- if (!memoized && handler.parserUnmemoize) {
6833
- computed = handler.parserUnmemoize(value, object);
6834
- }
6835
- else if (handler.parser) {
6836
- // try to parse it to CSSStyleValue, eg. '10px' -> CSS.px(10)
6837
- computed = handler.parser(value, object);
6838
- }
6839
- }
6840
- }
6506
+ // @ts-ignore
6507
+ if (attributes.d) {
6508
+ object.parsedStyle.d = parsePath(
6509
+ // @ts-ignore
6510
+ attributes.d);
6841
6511
  }
6842
- return computed;
6843
- };
6844
- /**
6845
- * computed value -> used value
6846
- */
6847
- DefaultStyleValueRegistry.prototype.computeProperty = function (name, computed, object, memoized) {
6848
- var metadata = propertyMetadataCache[name];
6849
- var isDocumentElement = object.id === 'g-root';
6850
- // let used: CSSStyleValue = computed instanceof CSSStyleValue ? computed.clone() : computed;
6851
- var used = computed;
6852
- if (metadata) {
6853
- var syntax = metadata.syntax, inherited = metadata.inh, defaultValue = metadata.d;
6854
- if (computed instanceof CSSKeywordValue) {
6855
- var value = computed.value;
6856
- /**
6857
- * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/unset
6858
- */
6859
- if (value === 'unset') {
6860
- if (inherited && !isDocumentElement) {
6861
- value = 'inherit';
6862
- }
6863
- else {
6864
- value = 'initial';
6865
- }
6866
- }
6867
- if (value === 'initial') {
6868
- // @see https://developer.mozilla.org/en-US/docs/Web/CSS/initial
6869
- if (!isNil(defaultValue)) {
6870
- computed = this.parseProperty(name, isFunction(defaultValue)
6871
- ? defaultValue(object.nodeName)
6872
- : defaultValue, object, memoized);
6873
- }
6874
- }
6875
- else if (value === 'inherit') {
6876
- // @see https://developer.mozilla.org/en-US/docs/Web/CSS/inherit
6877
- // behave like `inherit`
6878
- var resolved = this.tryToResolveProperty(object, name, {
6879
- inherited: true,
6880
- });
6881
- if (!isNil(resolved)) {
6882
- // object.parsedStyle[name] = resolved;
6883
- // return false;
6884
- return resolved;
6885
- }
6886
- else {
6887
- this.addUnresolveProperty(object, name);
6888
- return;
6889
- }
6890
- }
6891
- }
6892
- var handler = syntax && this.getPropertySyntax(syntax);
6893
- if (handler && handler.calculator) {
6894
- // convert computed value to used value
6895
- var oldParsedValue = object.parsedStyle[name];
6896
- used = handler.calculator(name, oldParsedValue, computed, object, this.runtime);
6897
- }
6898
- else if (computed instanceof CSSKeywordValue) {
6899
- used = computed.value;
6900
- }
6901
- else {
6902
- used = computed;
6903
- }
6512
+ // Text
6513
+ if (attributes.textTransform) {
6514
+ this.runtime.CSSPropertySyntaxFactory[PropertySyntax.TEXT_TRANSFORM].calculator(null, null, { value: attributes.textTransform }, object, null);
6904
6515
  }
6905
- return used;
6906
- };
6907
- DefaultStyleValueRegistry.prototype.postProcessProperty = function (name, object, attributes) {
6908
- var metadata = propertyMetadataCache[name];
6909
- if (metadata && metadata.syntax) {
6910
- var handler = metadata.syntax && this.getPropertySyntax(metadata.syntax);
6911
- var propertyHandler = handler;
6912
- if (propertyHandler && propertyHandler.postProcessor) {
6913
- propertyHandler.postProcessor(object, attributes);
6914
- }
6516
+ if (!isUndefined(attributes.clipPath)) {
6517
+ this.runtime.CSSPropertySyntaxFactory[PropertySyntax.DEFINED_PATH].calculator('clipPath', oldClipPath, attributes.clipPath, object, this.runtime);
6915
6518
  }
6916
- };
6917
- /**
6918
- * resolve later
6919
- */
6920
- DefaultStyleValueRegistry.prototype.addUnresolveProperty = function (object, name) {
6921
- var properties = unresolvedProperties.get(object);
6922
- if (!properties) {
6923
- unresolvedProperties.set(object, []);
6924
- properties = unresolvedProperties.get(object);
6519
+ if (attributes.offsetPath) {
6520
+ this.runtime.CSSPropertySyntaxFactory[PropertySyntax.DEFINED_PATH].calculator('offsetPath', oldOffsetPath, attributes.offsetPath, object, this.runtime);
6925
6521
  }
6926
- if (properties.indexOf(name) === -1) {
6927
- properties.push(name);
6522
+ if (attributes.transform) {
6523
+ object.parsedStyle.transform = parseTransform(attributes.transform);
6928
6524
  }
6929
- };
6930
- DefaultStyleValueRegistry.prototype.tryToResolveProperty = function (object, name, options) {
6931
- if (options === void 0) { options = {}; }
6932
- var inherited = options.inherited;
6933
- if (inherited) {
6934
- if (object.parentElement &&
6935
- isPropertyResolved(object.parentElement, name)) {
6936
- // const computedValue = object.parentElement.computedStyle[name];
6937
- var usedValue = object.parentElement.parsedStyle[name];
6938
- if (
6939
- // usedValue instanceof CSSKeywordValue &&
6940
- usedValue === 'unset' ||
6941
- usedValue === 'initial' ||
6942
- usedValue === 'inherit') {
6943
- return;
6944
- }
6945
- return usedValue;
6946
- }
6525
+ if (attributes.transformOrigin) {
6526
+ object.parsedStyle.transformOrigin = parseTransformOrigin(attributes.transformOrigin);
6947
6527
  }
6948
- return;
6949
- };
6950
- DefaultStyleValueRegistry.prototype.recalc = function (object) {
6951
- var properties = unresolvedProperties.get(object);
6952
- if (properties && properties.length) {
6953
- var attributes_1 = {};
6954
- properties.forEach(function (property) {
6955
- attributes_1[property] = object.attributes[property];
6956
- });
6957
- this.processProperties(object, attributes_1);
6958
- unresolvedProperties.delete(object);
6528
+ // Marker
6529
+ // @ts-ignore
6530
+ if (attributes.markerStart) {
6531
+ object.parsedStyle.markerStart = this.runtime.CSSPropertySyntaxFactory[PropertySyntax.MARKER].calculator(null,
6532
+ // @ts-ignore
6533
+ attributes.markerStart,
6534
+ // @ts-ignore
6535
+ attributes.markerStart, null, null);
6536
+ }
6537
+ // @ts-ignore
6538
+ if (attributes.markerEnd) {
6539
+ object.parsedStyle.markerEnd = this.runtime.CSSPropertySyntaxFactory[PropertySyntax.MARKER].calculator(null,
6540
+ // @ts-ignore
6541
+ attributes.markerEnd,
6542
+ // @ts-ignore
6543
+ attributes.markerEnd, null, null);
6544
+ }
6545
+ // @ts-ignore
6546
+ if (attributes.markerMid) {
6547
+ object.parsedStyle.markerMid = this.runtime.CSSPropertySyntaxFactory[PropertySyntax.MARKER].calculator('',
6548
+ // @ts-ignore
6549
+ attributes.markerMid,
6550
+ // @ts-ignore
6551
+ attributes.markerMid, null, null);
6552
+ }
6553
+ if (!isNil(attributes.zIndex)) {
6554
+ this.runtime.CSSPropertySyntaxFactory[PropertySyntax.Z_INDEX].postProcessor(object);
6555
+ }
6556
+ if (!isNil(attributes.offsetDistance)) {
6557
+ this.runtime.CSSPropertySyntaxFactory[PropertySyntax.OFFSET_DISTANCE].postProcessor(object);
6558
+ }
6559
+ if (attributes.transform) {
6560
+ this.runtime.CSSPropertySyntaxFactory[PropertySyntax.TRANSFORM].postProcessor(object);
6561
+ }
6562
+ if (attributes.transformOrigin) {
6563
+ this.runtime.CSSPropertySyntaxFactory[PropertySyntax.TRANSFORM_ORIGIN].postProcessor(object);
6564
+ }
6565
+ if (needUpdateGeometry) {
6566
+ object.geometry.dirty = true;
6567
+ object.renderable.boundsDirty = true;
6568
+ object.renderable.renderBoundsDirty = true;
6569
+ if (!options.forceUpdateGeometry) {
6570
+ this.runtime.sceneGraphService.dirtifyToRoot(object);
6571
+ }
6959
6572
  }
6960
6573
  };
6961
6574
  /**
@@ -7093,21 +6706,11 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
7093
6706
  }
7094
6707
  }
7095
6708
  };
7096
- DefaultStyleValueRegistry.prototype.isPropertyInheritable = function (name) {
7097
- var metadata = propertyMetadataCache[name];
7098
- if (!metadata) {
7099
- return false;
7100
- }
7101
- return metadata.inh;
7102
- };
7103
6709
  return DefaultStyleValueRegistry;
7104
6710
  }());
7105
6711
 
7106
6712
  var CSSPropertyAngle = /** @class */ (function () {
7107
6713
  function CSSPropertyAngle() {
7108
- this.parser = parseAngle;
7109
- this.parserUnmemoize = parseAngleUnmemoize;
7110
- this.parserWithCSSDisabled = null;
7111
6714
  this.mixer = mergeNumbers;
7112
6715
  }
7113
6716
  CSSPropertyAngle.prototype.calculator = function (name, oldParsed, parsed, object) {
@@ -7144,7 +6747,6 @@ var CSSPropertyClipPath = /** @class */ (function () {
7144
6747
  var CSSPropertyColor = /** @class */ (function () {
7145
6748
  function CSSPropertyColor() {
7146
6749
  this.parser = parseColor;
7147
- this.parserWithCSSDisabled = parseColor;
7148
6750
  this.mixer = mergeColors;
7149
6751
  }
7150
6752
  CSSPropertyColor.prototype.calculator = function (name, oldParsed, parsed, object) {
@@ -7159,7 +6761,6 @@ var CSSPropertyColor = /** @class */ (function () {
7159
6761
 
7160
6762
  var CSSPropertyFilter = /** @class */ (function () {
7161
6763
  function CSSPropertyFilter() {
7162
- this.parser = parseFilter;
7163
6764
  }
7164
6765
  CSSPropertyFilter.prototype.calculator = function (name, oldParsed, parsed) {
7165
6766
  // unset or none
@@ -7180,9 +6781,6 @@ function getFontSize(object) {
7180
6781
  */
7181
6782
  var CSSPropertyLengthOrPercentage = /** @class */ (function () {
7182
6783
  function CSSPropertyLengthOrPercentage() {
7183
- this.parser = parseLengthOrPercentage;
7184
- this.parserUnmemoize = parseLengthOrPercentageUnmemoize;
7185
- this.parserWithCSSDisabled = null;
7186
6784
  this.mixer = mergeNumbers;
7187
6785
  }
7188
6786
  /**
@@ -7197,7 +6795,6 @@ var CSSPropertyLengthOrPercentage = /** @class */ (function () {
7197
6795
  return computed;
7198
6796
  }
7199
6797
  if (CSSUnitValue.isRelativeUnit(computed.unit)) {
7200
- var registry = runtime.styleValueRegistry;
7201
6798
  if (computed.unit === UnitType.kPercentage) {
7202
6799
  // TODO: merge dimensions
7203
6800
  return 0;
@@ -7209,12 +6806,6 @@ var CSSPropertyLengthOrPercentage = /** @class */ (function () {
7209
6806
  fontSize *= computed.value;
7210
6807
  return fontSize;
7211
6808
  }
7212
- else {
7213
- registry.addUnresolveProperty(object, name);
7214
- }
7215
- }
7216
- else {
7217
- registry.addUnresolveProperty(object, name);
7218
6809
  }
7219
6810
  return 0;
7220
6811
  }
@@ -7225,12 +6816,6 @@ var CSSPropertyLengthOrPercentage = /** @class */ (function () {
7225
6816
  fontSize *= computed.value;
7226
6817
  return fontSize;
7227
6818
  }
7228
- else {
7229
- registry.addUnresolveProperty(object, name);
7230
- }
7231
- }
7232
- else {
7233
- registry.addUnresolveProperty(object, name);
7234
6819
  }
7235
6820
  return 0;
7236
6821
  }
@@ -7253,21 +6838,10 @@ var CSSPropertyLengthOrPercentage = /** @class */ (function () {
7253
6838
  * rect.style.lineDash = [10, 10];
7254
6839
  * rect.style.lineDash = '10 10';
7255
6840
  */
7256
- var CSSPropertyLengthOrPercentage12 = /** @class */ (function () {
7257
- function CSSPropertyLengthOrPercentage12() {
7258
- this.mixer = mergeNumberLists;
7259
- }
7260
- CSSPropertyLengthOrPercentage12.prototype.parser = function (radius) {
7261
- var parsed = parseDimensionArray(isNumber(radius) ? [radius] : radius);
7262
- var formatted;
7263
- if (parsed.length === 1) {
7264
- formatted = [parsed[0], parsed[0]];
7265
- }
7266
- else {
7267
- formatted = [parsed[0], parsed[1]];
7268
- }
7269
- return formatted;
7270
- };
6841
+ var CSSPropertyLengthOrPercentage12 = /** @class */ (function () {
6842
+ function CSSPropertyLengthOrPercentage12() {
6843
+ this.mixer = mergeNumberLists;
6844
+ }
7271
6845
  CSSPropertyLengthOrPercentage12.prototype.calculator = function (name, oldParsed, computed) {
7272
6846
  return computed.map(function (c) { return c.value; });
7273
6847
  };
@@ -7286,24 +6860,6 @@ var CSSPropertyLengthOrPercentage14 = /** @class */ (function () {
7286
6860
  function CSSPropertyLengthOrPercentage14() {
7287
6861
  this.mixer = mergeNumberLists;
7288
6862
  }
7289
- CSSPropertyLengthOrPercentage14.prototype.parser = function (radius) {
7290
- var parsed = parseDimensionArray(isNumber(radius) ? [radius] : radius);
7291
- var formatted;
7292
- // format to Tuple<CSSUnitValue>
7293
- if (parsed.length === 1) {
7294
- formatted = [parsed[0], parsed[0], parsed[0], parsed[0]];
7295
- }
7296
- else if (parsed.length === 2) {
7297
- formatted = [parsed[0], parsed[1], parsed[0], parsed[1]];
7298
- }
7299
- else if (parsed.length === 3) {
7300
- formatted = [parsed[0], parsed[1], parsed[2], parsed[1]];
7301
- }
7302
- else {
7303
- formatted = [parsed[0], parsed[1], parsed[2], parsed[3]];
7304
- }
7305
- return formatted;
7306
- };
7307
6863
  CSSPropertyLengthOrPercentage14.prototype.calculator = function (name, oldParsed, computed) {
7308
6864
  return computed.map(function (c) { return c.value; });
7309
6865
  };
@@ -7331,9 +6887,6 @@ var CSSPropertyMarker = /** @class */ (function () {
7331
6887
  var CSSPropertyNumber = /** @class */ (function () {
7332
6888
  function CSSPropertyNumber() {
7333
6889
  this.mixer = mergeNumbers;
7334
- this.parser = parseNumber;
7335
- this.parserUnmemoize = parseNumberUnmemoize;
7336
- this.parserWithCSSDisabled = null;
7337
6890
  }
7338
6891
  CSSPropertyNumber.prototype.calculator = function (name, oldParsed, computed) {
7339
6892
  return computed.value;
@@ -7343,9 +6896,6 @@ var CSSPropertyNumber = /** @class */ (function () {
7343
6896
 
7344
6897
  var CSSPropertyOffsetDistance = /** @class */ (function () {
7345
6898
  function CSSPropertyOffsetDistance() {
7346
- this.parser = parseNumber;
7347
- this.parserUnmemoize = parseNumberUnmemoize;
7348
- this.parserWithCSSDisabled = null;
7349
6899
  this.mixer = clampedMergeNumbers(0, 1);
7350
6900
  }
7351
6901
  CSSPropertyOffsetDistance.prototype.calculator = function (name, oldParsed, computed) {
@@ -7375,9 +6925,6 @@ var CSSPropertyOffsetDistance = /** @class */ (function () {
7375
6925
  */
7376
6926
  var CSSPropertyOpacity = /** @class */ (function () {
7377
6927
  function CSSPropertyOpacity() {
7378
- this.parser = parseNumber;
7379
- this.parserUnmemoize = parseNumberUnmemoize;
7380
- this.parserWithCSSDisabled = null;
7381
6928
  this.mixer = clampedMergeNumbers(0, 1);
7382
6929
  }
7383
6930
  CSSPropertyOpacity.prototype.calculator = function (name, oldParsed, computed) {
@@ -7392,7 +6939,6 @@ var CSSPropertyPath = /** @class */ (function () {
7392
6939
  * path2Curve
7393
6940
  */
7394
6941
  this.parser = parsePath;
7395
- this.parserWithCSSDisabled = parsePath;
7396
6942
  this.mixer = mergePaths;
7397
6943
  }
7398
6944
  CSSPropertyPath.prototype.calculator = function (name, oldParsed, parsed) {
@@ -7416,7 +6962,6 @@ var CSSPropertyPath = /** @class */ (function () {
7416
6962
 
7417
6963
  var CSSPropertyPoints = /** @class */ (function () {
7418
6964
  function CSSPropertyPoints() {
7419
- this.parser = parsePoints;
7420
6965
  this.mixer = mergePoints;
7421
6966
  }
7422
6967
  return CSSPropertyPoints;
@@ -7480,17 +7025,24 @@ var CSSPropertyTextTransform = /** @class */ (function () {
7480
7025
  return CSSPropertyTextTransform;
7481
7026
  }());
7482
7027
 
7028
+ var definedProps = function (obj) {
7029
+ return Object.fromEntries(Object.entries(obj).filter(function (_a) {
7030
+ var _b = __read(_a, 2), v = _b[1];
7031
+ return v !== undefined;
7032
+ }));
7033
+ };
7034
+
7483
7035
  var CANVAS_Map = new WeakMap();
7484
7036
  /**
7485
7037
  * destroy existed canvas with the same id
7486
7038
  */
7487
- function cleanExistedCanvas(container, canvas, fast) {
7039
+ function cleanExistedCanvas(container, canvas, cleanUp) {
7488
7040
  if (container) {
7489
7041
  var $dom = typeof container === 'string'
7490
7042
  ? document.getElementById(container)
7491
7043
  : container;
7492
7044
  if (CANVAS_Map.has($dom))
7493
- CANVAS_Map.get($dom).destroy(true, !!fast);
7045
+ CANVAS_Map.get($dom).destroy(cleanUp);
7494
7046
  else
7495
7047
  CANVAS_Map.set($dom, canvas);
7496
7048
  }
@@ -7577,6 +7129,12 @@ var TOUCH_TO_POINTER = {
7577
7129
  };
7578
7130
  var clock = typeof performance === 'object' && performance.now ? performance : Date;
7579
7131
 
7132
+ function isInFragment(node) {
7133
+ if (node.nodeName === Shape.FRAGMENT)
7134
+ return true;
7135
+ return node.getRootNode().nodeName === Shape.FRAGMENT;
7136
+ }
7137
+
7580
7138
  function isFillOrStrokeAffected(pointerEvents, fill, stroke) {
7581
7139
  // account for pointerEvents
7582
7140
  // @see https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events
@@ -7968,9 +7526,7 @@ function parsedTransformToMat4(transform, object) {
7968
7526
  */
7969
7527
  var CSSPropertyTransform = /** @class */ (function () {
7970
7528
  function CSSPropertyTransform() {
7971
- this.parser = parseTransform;
7972
- this.parserUnmemoize = parseTransformUnmemoize;
7973
- this.parserWithCSSDisabled = parseTransformUnmemoize;
7529
+ this.parser = parseTransformUnmemoize;
7974
7530
  this.mixer = mergeTransforms;
7975
7531
  }
7976
7532
  CSSPropertyTransform.prototype.calculator = function (name, oldParsed, parsed, object) {
@@ -7993,8 +7549,6 @@ var CSSPropertyTransform = /** @class */ (function () {
7993
7549
  */
7994
7550
  var CSSPropertyTransformOrigin = /** @class */ (function () {
7995
7551
  function CSSPropertyTransformOrigin() {
7996
- this.parser = parseTransformOrigin;
7997
- this.parserUnmemoize = parseTransformOriginUnmemoize;
7998
7552
  }
7999
7553
  CSSPropertyTransformOrigin.prototype.postProcessor = function (object) {
8000
7554
  var transformOrigin = object.parsedStyle.transformOrigin;
@@ -8012,8 +7566,6 @@ var CSSPropertyTransformOrigin = /** @class */ (function () {
8012
7566
 
8013
7567
  var CSSPropertyZIndex = /** @class */ (function () {
8014
7568
  function CSSPropertyZIndex() {
8015
- this.parser = parseNumber;
8016
- this.parserUnmemoize = parseNumberUnmemoize;
8017
7569
  }
8018
7570
  CSSPropertyZIndex.prototype.calculator = function (name, oldParsed, computed, object) {
8019
7571
  return computed.value;
@@ -8172,17 +7724,8 @@ var TextUpdater = /** @class */ (function () {
8172
7724
  this.globalRuntime = globalRuntime;
8173
7725
  }
8174
7726
  TextUpdater.prototype.isReadyToMeasure = function (parsedStyle, object) {
8175
- var text = parsedStyle.text, textAlign = parsedStyle.textAlign, textBaseline = parsedStyle.textBaseline, fontSize = parsedStyle.fontSize, fontStyle = parsedStyle.fontStyle, fontWeight = parsedStyle.fontWeight, fontVariant = parsedStyle.fontVariant, lineWidth = parsedStyle.lineWidth;
8176
- return runtime.enableCSSParsing
8177
- ? text &&
8178
- fontSize &&
8179
- fontStyle &&
8180
- fontWeight &&
8181
- fontVariant &&
8182
- textAlign &&
8183
- textBaseline &&
8184
- !isNil(lineWidth)
8185
- : text;
7727
+ var text = parsedStyle.text;
7728
+ return text;
8186
7729
  };
8187
7730
  TextUpdater.prototype.update = function (parsedStyle, object) {
8188
7731
  var _a, _b;
@@ -8213,7 +7756,7 @@ var TextUpdater = /** @class */ (function () {
8213
7756
  var offscreenCanvas = (((_b = (_a = object === null || object === void 0 ? void 0 : object.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) === null || _b === void 0 ? void 0 : _b.getConfig()) || {}).offscreenCanvas;
8214
7757
  var metrics = this.globalRuntime.textService.measureText(text, parsedStyle, offscreenCanvas);
8215
7758
  parsedStyle.metrics = metrics;
8216
- var width = metrics.width, height = metrics.height, lineHeight = metrics.lineHeight, fontProperties = metrics.fontProperties;
7759
+ var width = metrics.width, height = metrics.height;
8217
7760
  var hwidth = width / 2;
8218
7761
  var hheight = height / 2;
8219
7762
  // default 'left'
@@ -8226,18 +7769,12 @@ var TextUpdater = /** @class */ (function () {
8226
7769
  }
8227
7770
  var lineYOffset = y - hheight;
8228
7771
  if (textBaseline === 'middle') {
8229
- // eslint-disable-next-line prefer-destructuring
8230
7772
  lineYOffset += hheight;
8231
7773
  }
8232
7774
  else if (textBaseline === 'top' || textBaseline === 'hanging') {
8233
7775
  lineYOffset += hheight * 2;
8234
7776
  }
8235
- else if (textBaseline === 'alphabetic') {
8236
- // prevent calling getImageData for ascent metrics
8237
- lineYOffset += this.globalRuntime.enableCSSParsing
8238
- ? lineHeight - fontProperties.ascent
8239
- : 0;
8240
- }
7777
+ else if (textBaseline === 'alphabetic') ;
8241
7778
  else if (textBaseline === 'bottom' || textBaseline === 'ideographic') {
8242
7779
  lineYOffset += 0;
8243
7780
  }
@@ -8287,6 +7824,9 @@ var HTMLUpdater = /** @class */ (function () {
8287
7824
  return HTMLUpdater;
8288
7825
  }());
8289
7826
 
7827
+ function isFederatedEvent(value) {
7828
+ return !!value.type;
7829
+ }
8290
7830
  /**
8291
7831
  * An DOM-compatible synthetic event implementation that is "forwarded" on behalf of an original
8292
7832
  * FederatedEvent or native Event.
@@ -8698,6 +8238,10 @@ var CANVAS_CACHE = new WeakMap();
8698
8238
  */
8699
8239
  var EventTarget = /** @class */ (function () {
8700
8240
  function EventTarget() {
8241
+ /**
8242
+ * event emitter
8243
+ */
8244
+ this.emitter = new EventEmitter();
8701
8245
  }
8702
8246
  /**
8703
8247
  * @deprecated
@@ -8713,9 +8257,8 @@ var EventTarget = /** @class */ (function () {
8713
8257
  */
8714
8258
  EventTarget.prototype.addEventListener = function (type, listener, options) {
8715
8259
  var _a, _b;
8716
- if (!this.emitter)
8717
- this.emitter = new EventEmitter();
8718
- var capture = false, once = false;
8260
+ var capture = false;
8261
+ var once = false;
8719
8262
  if (isBoolean(options))
8720
8263
  capture = options;
8721
8264
  else if (options)
@@ -8811,7 +8354,7 @@ var EventTarget = /** @class */ (function () {
8811
8354
  var Node = /** @class */ (function (_super) {
8812
8355
  __extends(Node, _super);
8813
8356
  function Node() {
8814
- var _this = _super.apply(this, __spreadArray([], __read(arguments), false)) || this;
8357
+ var _this = _super.call(this) || this;
8815
8358
  _this.shadow = false;
8816
8359
  /**
8817
8360
  * points to canvas.document
@@ -9096,12 +8639,19 @@ var Node = /** @class */ (function (_super) {
9096
8639
  }
9097
8640
  return temp;
9098
8641
  };
9099
- Node.prototype.forEach = function (callback, assigned) {
9100
- if (assigned === void 0) { assigned = false; }
9101
- if (!callback(this)) {
9102
- (assigned ? this.childNodes.slice() : this.childNodes).forEach(function (child) {
9103
- child.forEach(callback);
9104
- });
8642
+ /**
8643
+ * iterate current node and its descendants
8644
+ * @param callback - callback to execute for each node, return false to break
8645
+ * @param assigned - whether to iterate assigned nodes
8646
+ */
8647
+ Node.prototype.forEach = function (callback) {
8648
+ var result = callback(this);
8649
+ if (result !== false) {
8650
+ var nodes = this.childNodes;
8651
+ var length_1 = nodes.length;
8652
+ for (var i = 0; i < length_1; i++) {
8653
+ nodes[i].forEach(callback);
8654
+ }
9105
8655
  }
9106
8656
  };
9107
8657
  /**
@@ -9840,8 +9390,6 @@ var EventService = /** @class */ (function () {
9840
9390
  // hack EventEmitter, stops if the `propagationImmediatelyStopped` flag is set
9841
9391
  // @ts-ignore
9842
9392
  var emitter = e.currentTarget.emitter;
9843
- if (!emitter)
9844
- return;
9845
9393
  // @ts-ignore
9846
9394
  var listeners = emitter._events[type];
9847
9395
  if (!listeners)
@@ -9979,12 +9527,6 @@ var RenderingService = /** @class */ (function () {
9979
9527
  */
9980
9528
  rendered: 0,
9981
9529
  };
9982
- /**
9983
- * frame counter
9984
- * - 1 - init root container
9985
- * - 2 - user first frame
9986
- */
9987
- this.frame = 0;
9988
9530
  this.zIndexCounter = 0;
9989
9531
  this.hooks = {
9990
9532
  /**
@@ -10073,19 +9615,13 @@ var RenderingService = /** @class */ (function () {
10073
9615
  this.context.renderingContext.renderReasons.has(RenderReason.CAMERA_CHANGED));
10074
9616
  };
10075
9617
  RenderingService.prototype.render = function (canvasConfig, frame, rerenderCallback) {
9618
+ var _this = this;
10076
9619
  this.stats.total = 0;
10077
9620
  this.stats.rendered = 0;
10078
9621
  this.zIndexCounter = 0;
10079
- this.frame++;
10080
9622
  var renderingContext = this.context.renderingContext;
10081
- if (this.frame === 2) {
10082
- // @ts-expect-error private method
10083
- this.globalRuntime.sceneGraphService.dirtifyEntireSceneGraph(renderingContext.root);
10084
- }
10085
9623
  this.globalRuntime.sceneGraphService.syncHierarchy(renderingContext.root);
10086
- if (this.frame > 2) {
10087
- this.globalRuntime.sceneGraphService.triggerPendingEvents(this.frame === 3 ? renderingContext.root : undefined);
10088
- }
9624
+ this.globalRuntime.sceneGraphService.triggerPendingEvents();
10089
9625
  if (renderingContext.renderReasons.size && this.inited) {
10090
9626
  // @ts-ignore
10091
9627
  renderingContext.dirtyRectangleRenderingDisabled =
@@ -10099,23 +9635,22 @@ var RenderingService = /** @class */ (function () {
10099
9635
  }
10100
9636
  this.hooks.beginFrame.call(frame);
10101
9637
  if (shouldTriggerRenderHooks) {
10102
- var objects = renderingContext.renderListCurrentFrame;
10103
- this.hooks.beforeRender.call(objects);
10104
- this.hooks.render.call(objects);
10105
- this.hooks.afterRender.call(objects);
9638
+ renderingContext.renderListCurrentFrame.forEach(function (object) {
9639
+ _this.hooks.beforeRender.call(object);
9640
+ _this.hooks.render.call(object);
9641
+ _this.hooks.afterRender.call(object);
9642
+ });
10106
9643
  }
10107
9644
  this.hooks.endFrame.call(frame);
10108
- renderingContext.renderListCurrentFrame.length = 0;
9645
+ renderingContext.renderListCurrentFrame = [];
10109
9646
  renderingContext.renderReasons.clear();
10110
9647
  rerenderCallback();
10111
9648
  }
9649
+ // console.log('stats', this.stats);
10112
9650
  };
10113
9651
  RenderingService.prototype.renderDisplayObject = function (displayObject, canvasConfig, renderingContext) {
9652
+ var _this = this;
10114
9653
  var _a = canvasConfig.renderer.getConfig(), enableDirtyCheck = _a.enableDirtyCheck, enableCulling = _a.enableCulling;
10115
- // recalc style values
10116
- if (this.globalRuntime.enableCSSParsing) {
10117
- this.globalRuntime.styleValueRegistry.recalc(displayObject);
10118
- }
10119
9654
  // TODO: relayout
10120
9655
  // dirtycheck first
10121
9656
  var renderable = displayObject.renderable;
@@ -10146,11 +9681,9 @@ var RenderingService = /** @class */ (function () {
10146
9681
  sortable.dirtyReason = undefined;
10147
9682
  }
10148
9683
  // recursive rendering its children
10149
- var nodes = sortable.sorted || displayObject.childNodes;
10150
- var length = nodes.length;
10151
- for (var i = 0; i < length; i++) {
10152
- this.renderDisplayObject(nodes[i], canvasConfig, renderingContext);
10153
- }
9684
+ (sortable.sorted || displayObject.childNodes).forEach(function (child) {
9685
+ _this.renderDisplayObject(child, canvasConfig, renderingContext);
9686
+ });
10154
9687
  };
10155
9688
  RenderingService.prototype.sort = function (displayObject, sortable) {
10156
9689
  if (sortable.sorted &&
@@ -10324,26 +9857,6 @@ var DefaultSceneGraphSelector = /** @class */ (function () {
10324
9857
  return DefaultSceneGraphSelector;
10325
9858
  }());
10326
9859
 
10327
- var MutationEvent = /** @class */ (function (_super) {
10328
- __extends(MutationEvent, _super);
10329
- function MutationEvent(typeArg, relatedNode, prevValue, newValue, attrName, attrChange, prevParsedValue, newParsedValue) {
10330
- var _this = _super.call(this, null) || this;
10331
- _this.relatedNode = relatedNode;
10332
- _this.prevValue = prevValue;
10333
- _this.newValue = newValue;
10334
- _this.attrName = attrName;
10335
- _this.attrChange = attrChange;
10336
- _this.prevParsedValue = prevParsedValue;
10337
- _this.newParsedValue = newParsedValue;
10338
- _this.type = typeArg;
10339
- return _this;
10340
- }
10341
- MutationEvent.ADDITION = 2;
10342
- MutationEvent.MODIFICATION = 1;
10343
- MutationEvent.REMOVAL = 3;
10344
- return MutationEvent;
10345
- }(FederatedEvent));
10346
-
10347
9860
  /**
10348
9861
  * built-in events for element
10349
9862
  * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationEvent
@@ -10381,6 +9894,26 @@ var ElementEvent;
10381
9894
  ElementEvent["CULLED"] = "culled";
10382
9895
  })(ElementEvent || (ElementEvent = {}));
10383
9896
 
9897
+ var MutationEvent = /** @class */ (function (_super) {
9898
+ __extends(MutationEvent, _super);
9899
+ function MutationEvent(typeArg, relatedNode, prevValue, newValue, attrName, attrChange, prevParsedValue, newParsedValue) {
9900
+ var _this = _super.call(this, null) || this;
9901
+ _this.relatedNode = relatedNode;
9902
+ _this.prevValue = prevValue;
9903
+ _this.newValue = newValue;
9904
+ _this.attrName = attrName;
9905
+ _this.attrChange = attrChange;
9906
+ _this.prevParsedValue = prevParsedValue;
9907
+ _this.newParsedValue = newParsedValue;
9908
+ _this.type = typeArg;
9909
+ return _this;
9910
+ }
9911
+ MutationEvent.ADDITION = 2;
9912
+ MutationEvent.MODIFICATION = 1;
9913
+ MutationEvent.REMOVAL = 3;
9914
+ return MutationEvent;
9915
+ }(FederatedEvent));
9916
+
10384
9917
  function markRenderableDirty(e) {
10385
9918
  var renderable = e.renderable;
10386
9919
  if (renderable) {
@@ -10389,19 +9922,6 @@ function markRenderableDirty(e) {
10389
9922
  }
10390
9923
  }
10391
9924
  var reparentEvent = new MutationEvent(ElementEvent.REPARENT, null, '', '', '', 0, '', '');
10392
- var EPSILON = 0.000001;
10393
- /**
10394
- * an optimized version of gl-matrix's equals
10395
- */
10396
- function equals(a, b) {
10397
- var a0 = a[0], a1 = a[1], a2 = a[2];
10398
- var b0 = b[0], b1 = b[1], b2 = b[2];
10399
- if (a0 === b0 && a1 === b1 && a2 === b2)
10400
- return true;
10401
- return (Math.abs(a0 - b0) <= EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) &&
10402
- Math.abs(a1 - b1) <= EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) &&
10403
- Math.abs(a2 - b2) <= EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)));
10404
- }
10405
9925
  // Object pooling
10406
9926
  /** do not modify this objects */
10407
9927
  var $vec2Zero = vec2.create();
@@ -10437,9 +9957,9 @@ var $triggerPendingEvents_detail = { affectChildren: true };
10437
9957
  var DefaultSceneGraphService = /** @class */ (function () {
10438
9958
  function DefaultSceneGraphService(runtime) {
10439
9959
  this.runtime = runtime;
9960
+ // target -> affectChildren
10440
9961
  this.pendingEvents = new Map();
10441
9962
  this.boundsChangedEvent = new CustomEvent(ElementEvent.BOUNDS_CHANGED);
10442
- this.eventEntitySet = new Set();
10443
9963
  this.displayObjectDependencyMap = new WeakMap();
10444
9964
  }
10445
9965
  DefaultSceneGraphService.prototype.matches = function (query, root) {
@@ -10459,12 +9979,23 @@ var DefaultSceneGraphService = /** @class */ (function () {
10459
9979
  detached = child.parentNode !== parent;
10460
9980
  this.detach(child);
10461
9981
  }
9982
+ var isChildFragment = child.nodeName === Shape.FRAGMENT;
9983
+ var isAttachToFragment = isInFragment(parent);
10462
9984
  child.parentNode = parent;
9985
+ var nodes = isChildFragment
9986
+ ? child.childNodes
9987
+ : [child];
10463
9988
  if (isNumber(index)) {
10464
- parent.childNodes.splice(index, 0, child);
9989
+ nodes.forEach(function (node) {
9990
+ parent.childNodes.splice(index, 0, node);
9991
+ node.parentNode = parent;
9992
+ });
10465
9993
  }
10466
9994
  else {
10467
- parent.childNodes.push(child);
9995
+ nodes.forEach(function (node) {
9996
+ parent.childNodes.push(node);
9997
+ node.parentNode = parent;
9998
+ });
10468
9999
  }
10469
10000
  // parent needs re-sort
10470
10001
  var sortable = parent.sortable;
@@ -10473,17 +10004,20 @@ var DefaultSceneGraphService = /** @class */ (function () {
10473
10004
  if (sortable.dirtyChildren.indexOf(child) === -1) {
10474
10005
  sortable.dirtyChildren.push(child);
10475
10006
  }
10007
+ // if (sortable) {
10476
10008
  // only child has z-Index
10477
10009
  sortable.dirty = true;
10478
10010
  sortable.dirtyReason = SortReason.ADDED;
10479
10011
  }
10480
- var transform = child.transformable;
10481
- // @ts-ignore
10482
- if ((child === null || child === void 0 ? void 0 : child.renderable.rendered) && transform) {
10483
- this.dirtifyWorld(child, transform);
10484
- }
10485
- if (transform.frozen) {
10486
- this.unfreezeParentToRoot(child);
10012
+ if (isAttachToFragment)
10013
+ return;
10014
+ if (isChildFragment)
10015
+ this.dirtifyFragment(child);
10016
+ else {
10017
+ var transform = child.transformable;
10018
+ if (transform) {
10019
+ this.dirtifyWorld(child, transform);
10020
+ }
10487
10021
  }
10488
10022
  if (detached) {
10489
10023
  child.dispatchEvent(reparentEvent);
@@ -10493,8 +10027,16 @@ var DefaultSceneGraphService = /** @class */ (function () {
10493
10027
  var _a, _b;
10494
10028
  if (child.parentNode) {
10495
10029
  var transform = child.transformable;
10030
+ // if (transform) {
10031
+ // const worldTransform = this.getWorldTransform(child, transform);
10032
+ // mat4.getScaling(transform.localScale, worldTransform);
10033
+ // mat4.getTranslation(transform.localPosition, worldTransform);
10034
+ // mat4.getRotation(transform.localRotation, worldTransform);
10035
+ // transform.localDirtyFlag = true;
10036
+ // }
10496
10037
  // parent needs re-sort
10497
10038
  var sortable = child.parentNode.sortable;
10039
+ // if (sortable) {
10498
10040
  if (((_a = sortable === null || sortable === void 0 ? void 0 : sortable.sorted) === null || _a === void 0 ? void 0 : _a.length) ||
10499
10041
  ((_b = child.style) === null || _b === void 0 ? void 0 : _b.zIndex)) {
10500
10042
  if (sortable.dirtyChildren.indexOf(child) === -1) {
@@ -10535,6 +10077,8 @@ var DefaultSceneGraphService = /** @class */ (function () {
10535
10077
  return;
10536
10078
  }
10537
10079
  var originVec = transform.origin;
10080
+ // const delta = vec3.subtract(vec3.create(), origin, originVec);
10081
+ // vec3.add(transform.localPosition, transform.localPosition, delta);
10538
10082
  // update origin
10539
10083
  originVec[0] = origin[0];
10540
10084
  originVec[1] = origin[1];
@@ -10637,7 +10181,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
10637
10181
  translation = vec3.fromValues(translation, y, z);
10638
10182
  }
10639
10183
  var transform = element.transformable;
10640
- if (equals(translation, $vec3Zero))
10184
+ if (vec3.equals(translation, $vec3Zero))
10641
10185
  return;
10642
10186
  vec3.transformQuat(translation, translation, transform.localRotation);
10643
10187
  vec3.add(transform.localPosition, transform.localPosition, translation);
@@ -10655,7 +10199,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
10655
10199
  $setPosition_1[0] = position[0];
10656
10200
  $setPosition_1[1] = position[1];
10657
10201
  $setPosition_1[2] = (_a = position[2]) !== null && _a !== void 0 ? _a : 0;
10658
- if (equals(this.getPosition(element), $setPosition_1)) {
10202
+ if (vec3.equals(this.getPosition(element), $setPosition_1)) {
10659
10203
  return;
10660
10204
  }
10661
10205
  vec3.copy(transform.position, $setPosition_1);
@@ -10681,7 +10225,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
10681
10225
  $setLocalPosition[0] = position[0];
10682
10226
  $setLocalPosition[1] = position[1];
10683
10227
  $setLocalPosition[2] = (_a = position[2]) !== null && _a !== void 0 ? _a : 0;
10684
- if (equals(transform.localPosition, $setLocalPosition)) {
10228
+ if (vec3.equals(transform.localPosition, $setLocalPosition)) {
10685
10229
  return;
10686
10230
  }
10687
10231
  vec3.copy(transform.localPosition, $setLocalPosition);
@@ -10703,7 +10247,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
10703
10247
  if (dirtify === void 0) { dirtify = true; }
10704
10248
  var transform = element.transformable;
10705
10249
  vec3.set($vec3$1, scaling[0], scaling[1], (_a = scaling[2]) !== null && _a !== void 0 ? _a : transform.localScale[2]);
10706
- if (equals($vec3$1, transform.localScale)) {
10250
+ if (vec3.equals($vec3$1, transform.localScale)) {
10707
10251
  return;
10708
10252
  }
10709
10253
  vec3.copy(transform.localScale, $vec3$1);
@@ -10729,7 +10273,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
10729
10273
  if (typeof translation === 'number') {
10730
10274
  translation = vec3.set($vec3$1, translation, y, z);
10731
10275
  }
10732
- if (equals(translation, $vec3Zero))
10276
+ if (vec3.equals(translation, $vec3Zero))
10733
10277
  return;
10734
10278
  vec3.add($vec3$1, this.getPosition(element), translation);
10735
10279
  this.setPosition(element, $vec3$1);
@@ -10775,9 +10319,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
10775
10319
  }
10776
10320
  };
10777
10321
  DefaultSceneGraphService.prototype.dirtifyLocal = function (element, transform) {
10778
- // 会在首屏渲染前统一标记
10779
- // 或者在调用 API 获取属性时标记
10780
- if (element.renderable.rendered)
10322
+ if (isInFragment(element))
10781
10323
  return;
10782
10324
  if (!transform.localDirtyFlag) {
10783
10325
  transform.localDirtyFlag = true;
@@ -10786,10 +10328,14 @@ var DefaultSceneGraphService = /** @class */ (function () {
10786
10328
  }
10787
10329
  }
10788
10330
  };
10789
- /**
10790
- * 将个场景图标记为 dirty。用于优化首屏性能,首屏渲染前的 appendChild 操作不会单独标记 dirty,而是等到首屏渲染时一次性标记
10791
- */
10792
- DefaultSceneGraphService.prototype.dirtifyEntireSceneGraph = function (element) {
10331
+ DefaultSceneGraphService.prototype.dirtifyWorld = function (element, transform) {
10332
+ if (!transform.dirtyFlag) {
10333
+ this.unfreezeParentToRoot(element);
10334
+ }
10335
+ this.dirtifyWorldInternal(element, transform);
10336
+ this.dirtifyToRoot(element, true);
10337
+ };
10338
+ DefaultSceneGraphService.prototype.dirtifyFragment = function (element) {
10793
10339
  var transform = element.transformable;
10794
10340
  if (transform) {
10795
10341
  transform.frozen = false;
@@ -10802,55 +10348,53 @@ var DefaultSceneGraphService = /** @class */ (function () {
10802
10348
  renderable.boundsDirty = true;
10803
10349
  renderable.dirty = true;
10804
10350
  }
10805
- if (!this.pendingEvents.has(element))
10806
- this.pendingEvents.set(element, true);
10807
10351
  var length = element.childNodes.length;
10808
10352
  for (var i = 0; i < length; i++) {
10809
- this.dirtifyEntireSceneGraph(element.childNodes[i]);
10810
- }
10811
- };
10812
- DefaultSceneGraphService.prototype.dirtifyWorld = function (element, transform) {
10813
- if (!transform.dirtyFlag) {
10814
- this.unfreezeParentToRoot(element);
10353
+ this.dirtifyFragment(element.childNodes[i]);
10815
10354
  }
10816
- this.dirtifyWorldInternal(element, transform);
10817
- this.dirtifyToRoot(element, true);
10818
- };
10819
- DefaultSceneGraphService.prototype.triggerEvent = function (element, detail) {
10820
- if (element.isConnected && !this.eventEntitySet.has(element.entity)) {
10821
- this.boundsChangedEvent.detail = detail;
10822
- this.boundsChangedEvent.target = element;
10823
- if (element.isMutationObserved) {
10824
- element.dispatchEvent(this.boundsChangedEvent);
10825
- }
10826
- else {
10827
- element.ownerDocument.defaultView.dispatchEvent(this.boundsChangedEvent, true);
10828
- }
10829
- this.eventEntitySet.add(element.entity);
10355
+ if (element.nodeName === Shape.FRAGMENT) {
10356
+ this.pendingEvents.set(element, false);
10830
10357
  }
10831
10358
  };
10832
- DefaultSceneGraphService.prototype.triggerPendingEvents = function (root) {
10359
+ DefaultSceneGraphService.prototype.triggerPendingEvents = function () {
10833
10360
  var _this = this;
10834
- if (root) {
10835
- $triggerPendingEvents_detail.affectChildren = true;
10836
- root.forEach(function (e) {
10837
- _this.triggerEvent(e, $triggerPendingEvents_detail);
10838
- });
10839
- }
10840
- else {
10841
- this.pendingEvents.forEach(function (affectChildren, element) {
10842
- $triggerPendingEvents_detail.affectChildren = affectChildren;
10843
- if (affectChildren) {
10844
- element.forEach(function (e) {
10845
- _this.triggerEvent(e, $triggerPendingEvents_detail);
10846
- });
10361
+ var triggered = new Set();
10362
+ var skipped = new Set();
10363
+ this.pendingEvents.forEach(function (_, element) {
10364
+ if (element.nodeName === Shape.FRAGMENT) {
10365
+ element.forEach(function (e) {
10366
+ if (e !== element)
10367
+ skipped.add(e);
10368
+ });
10369
+ }
10370
+ });
10371
+ var trigger = function (element, detail) {
10372
+ if (element.isConnected &&
10373
+ !triggered.has(element) &&
10374
+ !skipped.has(element)) {
10375
+ _this.boundsChangedEvent.detail = detail;
10376
+ _this.boundsChangedEvent.target = element;
10377
+ if (element.isMutationObserved) {
10378
+ element.dispatchEvent(_this.boundsChangedEvent);
10847
10379
  }
10848
10380
  else {
10849
- _this.triggerEvent(element, $triggerPendingEvents_detail);
10381
+ element.ownerDocument.defaultView.dispatchEvent(_this.boundsChangedEvent, true);
10850
10382
  }
10851
- });
10852
- }
10853
- this.eventEntitySet.clear();
10383
+ triggered.add(element);
10384
+ }
10385
+ };
10386
+ this.pendingEvents.forEach(function (affectChildren, element) {
10387
+ $triggerPendingEvents_detail.affectChildren = affectChildren;
10388
+ if (affectChildren) {
10389
+ element.forEach(function (e) {
10390
+ trigger(e, $triggerPendingEvents_detail);
10391
+ });
10392
+ }
10393
+ else
10394
+ trigger(element, $triggerPendingEvents_detail);
10395
+ });
10396
+ triggered.clear();
10397
+ skipped.clear();
10854
10398
  this.clearPendingEvents();
10855
10399
  };
10856
10400
  DefaultSceneGraphService.prototype.clearPendingEvents = function () {
@@ -10861,8 +10405,6 @@ var DefaultSceneGraphService = /** @class */ (function () {
10861
10405
  var p = element;
10862
10406
  // only need to re-render itself
10863
10407
  if (p.renderable) {
10864
- if (!p.renderable.rendered)
10865
- return;
10866
10408
  p.renderable.dirty = true;
10867
10409
  }
10868
10410
  while (p) {
@@ -10874,11 +10416,8 @@ var DefaultSceneGraphService = /** @class */ (function () {
10874
10416
  markRenderableDirty(e);
10875
10417
  });
10876
10418
  }
10877
- // inform dependencies
10878
10419
  this.informDependentDisplayObjects(element);
10879
- if (affectChildren || !this.pendingEvents.has(element)) {
10880
- this.pendingEvents.set(element, affectChildren);
10881
- }
10420
+ this.pendingEvents.set(element, affectChildren);
10882
10421
  };
10883
10422
  DefaultSceneGraphService.prototype.updateDisplayObjectDependency = function (name, oldPath, newPath, object) {
10884
10423
  // clear ref to old clip path
@@ -10932,20 +10471,14 @@ var DefaultSceneGraphService = /** @class */ (function () {
10932
10471
  };
10933
10472
  DefaultSceneGraphService.prototype.getWorldTransform = function (element, transform) {
10934
10473
  if (transform === void 0) { transform = element.transformable; }
10935
- var rendered = element.renderable.rendered;
10936
- var computed = transform.computed, localDirtyFlag = transform.localDirtyFlag, dirtyFlag = transform.dirtyFlag, worldTransform = transform.worldTransform;
10937
- if (!localDirtyFlag && !dirtyFlag) {
10938
- if (rendered || computed)
10939
- return worldTransform;
10474
+ if (!transform.localDirtyFlag && !transform.dirtyFlag) {
10475
+ return transform.worldTransform;
10940
10476
  }
10941
10477
  if (element.parentNode && element.parentNode.transformable) {
10942
- var _a = element.parentNode
10943
- .transformable, dirtyFlag_1 = _a.dirtyFlag, localDirtyFlag_1 = _a.localDirtyFlag;
10944
- if (dirtyFlag_1 || localDirtyFlag_1)
10945
- this.getWorldTransform(element.parentNode);
10478
+ this.getWorldTransform(element.parentNode);
10946
10479
  }
10947
10480
  this.sync(element, transform);
10948
- return worldTransform;
10481
+ return transform.worldTransform;
10949
10482
  };
10950
10483
  DefaultSceneGraphService.prototype.getLocalPosition = function (element) {
10951
10484
  return element.transformable.localPosition;
@@ -11056,12 +10589,11 @@ var DefaultSceneGraphService = /** @class */ (function () {
11056
10589
  var _this = this;
11057
10590
  if (render === void 0) { render = false; }
11058
10591
  var renderable = element.renderable;
11059
- var _a = renderable || {}, boundsDirty = _a.boundsDirty, bounds = _a.bounds, renderBoundsDirty = _a.renderBoundsDirty, renderBounds = _a.renderBounds, rendered = _a.rendered;
11060
- if (rendered && !boundsDirty && !render && bounds) {
11061
- return bounds;
10592
+ if (!renderable.boundsDirty && !render && renderable.bounds) {
10593
+ return renderable.bounds;
11062
10594
  }
11063
- if (rendered && !renderBoundsDirty && render && renderBounds) {
11064
- return renderBounds;
10595
+ if (!renderable.renderBoundsDirty && render && renderable.renderBounds) {
10596
+ return renderable.renderBounds;
11065
10597
  }
11066
10598
  // reuse existed if possible
11067
10599
  var existedAABB = render ? renderable.renderBounds : renderable.bounds;
@@ -11178,12 +10710,11 @@ var DefaultSceneGraphService = /** @class */ (function () {
11178
10710
  }
11179
10711
  };
11180
10712
  DefaultSceneGraphService.prototype.sync = function (element, transform) {
11181
- var force = !element.renderable.rendered;
11182
- if (force || transform.localDirtyFlag) {
10713
+ if (transform.localDirtyFlag) {
11183
10714
  this.calcLocalTransform(transform);
11184
10715
  transform.localDirtyFlag = false;
11185
10716
  }
11186
- if (force || transform.dirtyFlag) {
10717
+ if (transform.dirtyFlag) {
11187
10718
  var parent_1 = element.parentNode;
11188
10719
  var parentTransform = parent_1 && parent_1.transformable;
11189
10720
  if (parent_1 === null || !parentTransform) {
@@ -11196,11 +10727,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
11196
10727
  }
11197
10728
  transform.dirtyFlag = false;
11198
10729
  }
11199
- transform.computed = true;
11200
10730
  };
11201
- /**
11202
- * 解冻所有父节点,在下次关键帧时重新计算变换矩阵
11203
- */
11204
10731
  DefaultSceneGraphService.prototype.unfreezeParentToRoot = function (child) {
11205
10732
  var p = child.parentNode;
11206
10733
  while (p) {
@@ -11373,19 +10900,12 @@ var TextService = /** @class */ (function () {
11373
10900
  // dropShadowDistance = 0,
11374
10901
  leading = _g === void 0 ? 0 : _g;
11375
10902
  var font = toFontString(parsedStyle);
11376
- // if (runtime.enableCSSParsing) {
11377
10903
  var fontProperties = this.measureFont(font, offscreenCanvas);
11378
10904
  // fallback in case UA disallow canvas data extraction
11379
- // (toDataURI, getImageData functions)
11380
10905
  if (fontProperties.fontSize === 0) {
11381
10906
  fontProperties.fontSize = fontSize;
11382
10907
  fontProperties.ascent = fontSize;
11383
10908
  }
11384
- // } else {
11385
- // fontProperties = {
11386
- // fontSize,
11387
- // };
11388
- // }
11389
10909
  var context = this.runtime.offscreenCanvasCreator.getOrCreateContext(offscreenCanvas);
11390
10910
  context.font = font;
11391
10911
  // no overflowing by default
@@ -11707,10 +11227,7 @@ runtime.CSSPropertySyntaxFactory = CSSPropertySyntaxFactory;
11707
11227
  runtime.styleValueRegistry = new DefaultStyleValueRegistry(runtime);
11708
11228
  runtime.layoutRegistry = null;
11709
11229
  runtime.globalThis = getGlobalThis();
11710
- runtime.enableCSSParsing = false;
11711
- runtime.enableDataset = false;
11712
11230
  runtime.enableStyleSyntax = true;
11713
- runtime.enableAttributeDashCased = false;
11714
11231
  runtime.enableSizeAttenuation = false;
11715
11232
 
11716
11233
  var entityCounter = 0;
@@ -11729,7 +11246,7 @@ var destroyEvent = new CustomEvent(ElementEvent.DESTROY);
11729
11246
  var Element = /** @class */ (function (_super) {
11730
11247
  __extends(Element, _super);
11731
11248
  function Element() {
11732
- var _this = _super.apply(this, __spreadArray([], __read(arguments), false)) || this;
11249
+ var _this = _super.call(this) || this;
11733
11250
  /**
11734
11251
  * Unique id.
11735
11252
  */
@@ -11741,7 +11258,6 @@ var Element = /** @class */ (function (_super) {
11741
11258
  renderBoundsDirty: true,
11742
11259
  dirtyRenderBounds: undefined,
11743
11260
  dirty: false,
11744
- rendered: false,
11745
11261
  };
11746
11262
  _this.cullable = {
11747
11263
  strategy: Strategy.Standard,
@@ -11753,7 +11269,6 @@ var Element = /** @class */ (function (_super) {
11753
11269
  dirtyFlag: false,
11754
11270
  localDirtyFlag: false,
11755
11271
  frozen: false,
11756
- computed: false,
11757
11272
  localPosition: [0, 0, 0],
11758
11273
  localRotation: [0, 0, 0, 1],
11759
11274
  localScale: [1, 1, 1],
@@ -11801,38 +11316,30 @@ var Element = /** @class */ (function (_super) {
11801
11316
  * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style
11802
11317
  */
11803
11318
  _this.style = {};
11804
- _this.computedStyle = runtime.enableCSSParsing
11805
- ? {
11806
- opacity: unsetKeywordValue,
11807
- fillOpacity: unsetKeywordValue,
11808
- strokeOpacity: unsetKeywordValue,
11809
- fill: unsetKeywordValue,
11810
- stroke: unsetKeywordValue,
11811
- transform: unsetKeywordValue,
11812
- transformOrigin: unsetKeywordValue,
11813
- visibility: unsetKeywordValue,
11814
- pointerEvents: unsetKeywordValue,
11815
- lineWidth: unsetKeywordValue,
11816
- lineCap: unsetKeywordValue,
11817
- lineJoin: unsetKeywordValue,
11818
- increasedLineWidthForHitTesting: unsetKeywordValue,
11819
- fontSize: unsetKeywordValue,
11820
- fontFamily: unsetKeywordValue,
11821
- fontStyle: unsetKeywordValue,
11822
- fontWeight: unsetKeywordValue,
11823
- fontVariant: unsetKeywordValue,
11824
- textAlign: unsetKeywordValue,
11825
- textBaseline: unsetKeywordValue,
11826
- textTransform: unsetKeywordValue,
11827
- zIndex: unsetKeywordValue,
11828
- filter: unsetKeywordValue,
11829
- shadowType: unsetKeywordValue,
11830
- }
11831
- : {};
11319
+ _this.computedStyle = {};
11832
11320
  /**
11833
11321
  * Renderers will use these used values.
11834
11322
  */
11835
- _this.parsedStyle = {};
11323
+ _this.parsedStyle = {
11324
+ // opacity: '',
11325
+ // fillOpacity: '',
11326
+ // strokeOpacity: '',
11327
+ // transformOrigin: '',
11328
+ // visibility: '',
11329
+ // pointerEvents: '',
11330
+ // lineWidth: '',
11331
+ // lineCap: '',
11332
+ // lineJoin: '',
11333
+ // increasedLineWidthForHitTesting: '',
11334
+ // fontSize: '',
11335
+ // fontFamily: '',
11336
+ // fontStyle: '',
11337
+ // fontWeight: '',
11338
+ // fontVariant: '',
11339
+ // textAlign: '',
11340
+ // textBaseline: '',
11341
+ // textTransform: '',
11342
+ };
11836
11343
  /**
11837
11344
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/attributes
11838
11345
  */
@@ -11938,7 +11445,12 @@ var Element = /** @class */ (function (_super) {
11938
11445
  }
11939
11446
  runtime.sceneGraphService.attach(child, this, index);
11940
11447
  if ((_a = this.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) {
11941
- this.ownerDocument.defaultView.mountChildren(child);
11448
+ if (!isInFragment(this) && child.nodeName === Shape.FRAGMENT) {
11449
+ this.ownerDocument.defaultView.mountFragment(child);
11450
+ }
11451
+ else {
11452
+ this.ownerDocument.defaultView.mountChildren(child);
11453
+ }
11942
11454
  }
11943
11455
  // @ts-ignore
11944
11456
  if (this.isMutationObserved) {
@@ -12052,9 +11564,9 @@ var Element = /** @class */ (function (_super) {
12052
11564
  this.forEach(function (object) {
12053
11565
  if (object !== _this && filter(object)) {
12054
11566
  target = object;
12055
- return true;
11567
+ return false;
12056
11568
  }
12057
- return false;
11569
+ return true;
12058
11570
  });
12059
11571
  return target;
12060
11572
  };
@@ -12154,13 +11666,12 @@ var Element = /** @class */ (function (_super) {
12154
11666
  return this;
12155
11667
  };
12156
11668
  Element.prototype.destroy = function () {
12157
- var _a;
12158
11669
  // destroy itself before remove
12159
11670
  this.dispatchEvent(destroyEvent);
12160
11671
  // remove from scenegraph first
12161
11672
  this.remove();
12162
11673
  // remove event listeners
12163
- (_a = this.emitter) === null || _a === void 0 ? void 0 : _a.removeAllListeners();
11674
+ this.emitter.removeAllListeners();
12164
11675
  this.destroyed = true;
12165
11676
  };
12166
11677
  Element.prototype.getGeometryBounds = function () {
@@ -12213,17 +11724,13 @@ var Element = /** @class */ (function (_super) {
12213
11724
  */
12214
11725
  Element.prototype.getAttribute = function (name) {
12215
11726
  // @see https://github.com/antvis/G/issues/1267
12216
- if (isSymbol(name)) {
12217
- return runtime.enableCSSParsing ? null : undefined;
11727
+ if (typeof name === 'symbol') {
11728
+ return undefined;
12218
11729
  }
12219
11730
  var value = this.attributes[name];
12220
11731
  if (value === undefined) {
12221
- if (runtime.enableAttributeDashCased) {
12222
- var attributeName = formatAttributeName(name);
12223
- value = this.attributes[attributeName];
12224
- }
12225
11732
  // if the given attribute does not exist, the value returned will either be null or ""
12226
- return runtime.enableCSSParsing ? (isNil(value) ? null : value) : value;
11733
+ return value;
12227
11734
  }
12228
11735
  else {
12229
11736
  return value;
@@ -12295,64 +11802,6 @@ var Proxy = runtime.globalThis.Proxy
12295
11802
  ? runtime.globalThis.Proxy
12296
11803
  : function () { };
12297
11804
  var mutationEvent = new MutationEvent(ElementEvent.ATTR_MODIFIED, null, null, null, null, MutationEvent.MODIFICATION, null, null);
12298
- var DEFAULT_STYLE_PROPS = {
12299
- opacity: '',
12300
- fillOpacity: '',
12301
- strokeOpacity: '',
12302
- fill: '',
12303
- stroke: '',
12304
- transform: '',
12305
- transformOrigin: '',
12306
- visibility: '',
12307
- pointerEvents: '',
12308
- lineWidth: '',
12309
- lineCap: '',
12310
- lineJoin: '',
12311
- increasedLineWidthForHitTesting: '',
12312
- fontSize: '',
12313
- fontFamily: '',
12314
- fontStyle: '',
12315
- fontWeight: '',
12316
- fontVariant: '',
12317
- textAlign: '',
12318
- textBaseline: '',
12319
- textTransform: '',
12320
- zIndex: '',
12321
- filter: '',
12322
- shadowType: '',
12323
- };
12324
- var DEFAULT_PARSED_STYLE_PROPS = {
12325
- fill: noneColor,
12326
- stroke: noneColor,
12327
- transform: [],
12328
- zIndex: 0,
12329
- filter: [],
12330
- shadowType: 'outer',
12331
- miterLimit: 10,
12332
- };
12333
- var INHERITABLE_BASE_STYLE_PROPS = [
12334
- 'opacity',
12335
- 'fillOpacity',
12336
- 'strokeOpacity',
12337
- 'transformOrigin',
12338
- 'visibility',
12339
- 'pointerEvents',
12340
- 'lineWidth',
12341
- 'lineCap',
12342
- 'lineJoin',
12343
- 'increasedLineWidthForHitTesting',
12344
- ];
12345
- var INHERITABLE_STYLE_PROPS = __spreadArray(__spreadArray([], __read(INHERITABLE_BASE_STYLE_PROPS), false), [
12346
- 'fontSize',
12347
- 'fontFamily',
12348
- 'fontStyle',
12349
- 'fontWeight',
12350
- 'fontVariant',
12351
- 'textAlign',
12352
- 'textBaseline',
12353
- 'textTransform',
12354
- ], false);
12355
- var DATASET_PREFIX = 'data-';
12356
11805
  var $vec3 = vec3.create();
12357
11806
  var $quat = quat$1.create();
12358
11807
  /**
@@ -12393,30 +11842,11 @@ var DisplayObject = /** @class */ (function (_super) {
12393
11842
  _this.className = config.className || config.class;
12394
11843
  }
12395
11844
  _this.nodeName = config.type || Shape.GROUP;
12396
- if (runtime.enableCSSParsing) {
12397
- Object.assign(_this.attributes, DEFAULT_STYLE_PROPS);
12398
- Object.assign(_this.parsedStyle, DEFAULT_PARSED_STYLE_PROPS, _this.config.initialParsedStyle);
12399
- }
12400
- else if (config.initialParsedStyle) {
11845
+ if (config.initialParsedStyle) {
12401
11846
  Object.assign(_this.parsedStyle, config.initialParsedStyle);
12402
11847
  }
12403
11848
  // start to process attributes
12404
11849
  _this.initAttributes(config.style);
12405
- if (runtime.enableDataset) {
12406
- _this.dataset = new Proxy({}, {
12407
- get: function (target, name) {
12408
- var formattedName = "".concat(DATASET_PREFIX).concat(kebabize(name));
12409
- if (target[formattedName] !== undefined) {
12410
- return target[formattedName];
12411
- }
12412
- return _this.getAttribute(formattedName);
12413
- },
12414
- set: function (_, prop, value) {
12415
- _this.setAttribute("".concat(DATASET_PREFIX).concat(kebabize(prop)), value);
12416
- return true;
12417
- },
12418
- });
12419
- }
12420
11850
  if (runtime.enableStyleSyntax) {
12421
11851
  _this.style = new Proxy(
12422
11852
  // @ts-ignore
@@ -12456,13 +11886,6 @@ var DisplayObject = /** @class */ (function (_super) {
12456
11886
  this.getAnimations().forEach(function (animation) {
12457
11887
  animation.cancel();
12458
11888
  });
12459
- // FIXME
12460
- // this.renderable = null;
12461
- // this.cullable = null;
12462
- // this.transformable = null;
12463
- // this.rBushNode = null;
12464
- // this.geometry = null;
12465
- // this.sortable = null;
12466
11889
  };
12467
11890
  DisplayObject.prototype.cloneNode = function (deep, customCloneFunc) {
12468
11891
  var clonedStyle = __assign({}, this.attributes);
@@ -12505,39 +11928,37 @@ var DisplayObject = /** @class */ (function (_super) {
12505
11928
  };
12506
11929
  DisplayObject.prototype.initAttributes = function (attributes) {
12507
11930
  if (attributes === void 0) { attributes = {}; }
12508
- // account for FCP, process properties as less as possible
12509
- runtime.styleValueRegistry.processProperties(this, runtime.enableAttributeDashCased
12510
- ? formatAttributes(attributes)
12511
- : attributes, undefined, undefined, true, runtime.enableCSSParsing ? INHERITABLE_STYLE_PROPS : undefined, undefined);
11931
+ var options = {
11932
+ forceUpdateGeometry: true,
11933
+ };
11934
+ runtime.styleValueRegistry.processProperties(this, attributes, options);
12512
11935
  // redraw at next frame
12513
11936
  this.renderable.dirty = true;
12514
11937
  };
12515
11938
  DisplayObject.prototype.setAttribute = function (name, value, force, memoize) {
12516
11939
  if (force === void 0) { force = false; }
12517
11940
  if (memoize === void 0) { memoize = true; }
12518
- if (runtime.enableAttributeDashCased) {
12519
- name = formatAttributeName(name);
12520
- }
12521
11941
  // ignore undefined value
12522
11942
  if (isUndefined(value)) {
12523
11943
  return;
12524
11944
  }
12525
11945
  if (force || value !== this.attributes[name]) {
12526
- this.internalSetAttribute(name, value, undefined, undefined, undefined, undefined, memoize);
11946
+ this.internalSetAttribute(name, value, { memoize: memoize });
12527
11947
  _super.prototype.setAttribute.call(this, name, value);
12528
11948
  }
12529
11949
  };
12530
11950
  /**
12531
11951
  * called when attributes get changed or initialized
12532
11952
  */
12533
- DisplayObject.prototype.internalSetAttribute = function (name, value, skipUpdateAttribute, skipParse, forceUpdateGeometry, usedAttributes, memoize) {
11953
+ DisplayObject.prototype.internalSetAttribute = function (name, value, parseOptions) {
12534
11954
  var _a;
11955
+ if (parseOptions === void 0) { parseOptions = {}; }
12535
11956
  var renderable = this.renderable;
12536
11957
  var oldValue = this.attributes[name];
12537
11958
  var oldParsedValue = this.parsedStyle[name];
12538
11959
  runtime.styleValueRegistry.processProperties(this, (_a = {},
12539
11960
  _a[name] = value,
12540
- _a), skipUpdateAttribute, skipParse, forceUpdateGeometry, usedAttributes, memoize);
11961
+ _a), parseOptions);
12541
11962
  // redraw at next frame
12542
11963
  renderable.dirty = true;
12543
11964
  var newParsedValue = this.parsedStyle[name];
@@ -12777,10 +12198,8 @@ var DisplayObject = /** @class */ (function (_super) {
12777
12198
  * shortcut for Used value of `visibility`
12778
12199
  */
12779
12200
  DisplayObject.prototype.isVisible = function () {
12780
- var _a, _b;
12781
- return runtime.enableCSSParsing
12782
- ? ((_a = this.parsedStyle) === null || _a === void 0 ? void 0 : _a.visibility) === 'visible'
12783
- : ((_b = this.parsedStyle) === null || _b === void 0 ? void 0 : _b.visibility) !== 'hidden';
12201
+ var _a;
12202
+ return ((_a = this.parsedStyle) === null || _a === void 0 ? void 0 : _a.visibility) !== 'hidden';
12784
12203
  };
12785
12204
  Object.defineProperty(DisplayObject.prototype, "interactive", {
12786
12205
  get: function () {
@@ -12900,28 +12319,18 @@ var DisplayObject = /** @class */ (function (_super) {
12900
12319
  * @deprecated
12901
12320
  */
12902
12321
  DisplayObject.prototype.show = function () {
12903
- if (runtime.enableCSSParsing) {
12904
- this.style.visibility = 'visible';
12905
- }
12906
- else {
12907
- this.forEach(function (object) {
12908
- object.style.visibility = 'visible';
12909
- });
12910
- }
12322
+ this.forEach(function (object) {
12323
+ object.style.visibility = 'visible';
12324
+ });
12911
12325
  };
12912
12326
  /**
12913
12327
  * Use `visibility: hidden` instead.
12914
12328
  * @deprecated
12915
12329
  */
12916
12330
  DisplayObject.prototype.hide = function () {
12917
- if (runtime.enableCSSParsing) {
12918
- this.style.visibility = 'hidden';
12919
- }
12920
- else {
12921
- this.forEach(function (object) {
12922
- object.style.visibility = 'hidden';
12923
- });
12924
- }
12331
+ this.forEach(function (object) {
12332
+ object.style.visibility = 'hidden';
12333
+ });
12925
12334
  };
12926
12335
  /**
12927
12336
  * Use `childElementCount` instead.
@@ -13031,12 +12440,15 @@ var Circle = /** @class */ (function (_super) {
13031
12440
  */
13032
12441
  var CustomElement = /** @class */ (function (_super) {
13033
12442
  __extends(CustomElement, _super);
12443
+ // private shadowNodes: DisplayObject[] = [];
13034
12444
  function CustomElement(_a) {
13035
12445
  if (_a === void 0) { _a = {}; }
13036
12446
  var _this = this;
13037
12447
  var style = _a.style, rest = __rest(_a, ["style"]);
13038
- _this = _super.call(this, __assign({ style: runtime.enableCSSParsing
13039
- ? __assign({}, style) : __assign({}, style) }, rest)) || this;
12448
+ _this = _super.call(this, __assign({ style: style }, rest)) || this;
12449
+ // static get observedAttributes(): string[] {
12450
+ // return [];
12451
+ // }
13040
12452
  _this.isCustomElement = true;
13041
12453
  return _this;
13042
12454
  }
@@ -13052,6 +12464,23 @@ var Ellipse = /** @class */ (function (_super) {
13052
12464
  return Ellipse;
13053
12465
  }(DisplayObject));
13054
12466
 
12467
+ /**
12468
+ * 节点片段,用于包裹多个节点并批量操作
12469
+ *
12470
+ * 向 Fragment 或者根节点为 Fragment 的节点添加子节点时,不会触发渲染和事件。
12471
+ *
12472
+ * 当 Fragment 被挂载到 Canvas 中的节点时,其子节点会一次性被渲染,并触发合并事件。
12473
+ *
12474
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment
12475
+ */
12476
+ var Fragment = /** @class */ (function (_super) {
12477
+ __extends(Fragment, _super);
12478
+ function Fragment() {
12479
+ return _super.call(this, { type: Shape.FRAGMENT }) || this;
12480
+ }
12481
+ return Fragment;
12482
+ }(DisplayObject));
12483
+
13055
12484
  /**
13056
12485
  * its attributes are inherited by its children.
13057
12486
  * @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/g
@@ -13081,8 +12510,7 @@ var HTML = /** @class */ (function (_super) {
13081
12510
  if (_a === void 0) { _a = {}; }
13082
12511
  var _this = this;
13083
12512
  var style = _a.style, rest = __rest(_a, ["style"]);
13084
- _this = _super.call(this, __assign({ type: Shape.HTML, style: runtime.enableCSSParsing
13085
- ? __assign({ x: '', y: '', width: 'auto', height: 'auto', innerHTML: '' }, style) : __assign({}, style) }, rest)) || this;
12513
+ _this = _super.call(this, __assign({ type: Shape.HTML, style: style }, rest)) || this;
13086
12514
  _this.cullable.enable = false;
13087
12515
  return _this;
13088
12516
  }
@@ -13274,13 +12702,10 @@ var Path = /** @class */ (function (_super) {
13274
12702
  if (_a === void 0) { _a = {}; }
13275
12703
  var _this = this;
13276
12704
  var style = _a.style, rest = __rest(_a, ["style"]);
13277
- _this = _super.call(this, __assign({ type: Shape.PATH, style: runtime.enableCSSParsing
13278
- ? __assign({ d: '', miterLimit: '' }, style) : __assign({}, style), initialParsedStyle: runtime.enableCSSParsing
13279
- ? null
13280
- : {
13281
- miterLimit: 4,
13282
- d: __assign({}, EMPTY_PARSED_PATH),
13283
- } }, rest)) || this;
12705
+ _this = _super.call(this, __assign({ type: Shape.PATH, style: style, initialParsedStyle: {
12706
+ miterLimit: 4,
12707
+ d: __assign({}, EMPTY_PARSED_PATH),
12708
+ } }, rest)) || this;
13284
12709
  _this.markerStartAngle = 0;
13285
12710
  _this.markerEndAngle = 0;
13286
12711
  /**
@@ -13475,18 +12900,15 @@ var Polygon = /** @class */ (function (_super) {
13475
12900
  if (_a === void 0) { _a = {}; }
13476
12901
  var _this = this;
13477
12902
  var style = _a.style, rest = __rest(_a, ["style"]);
13478
- _this = _super.call(this, __assign({ type: Shape.POLYGON, style: runtime.enableCSSParsing
13479
- ? __assign({ points: '', miterLimit: '', isClosed: true }, style) : __assign({}, style), initialParsedStyle: runtime.enableCSSParsing
13480
- ? null
13481
- : {
13482
- points: {
13483
- points: [],
13484
- totalLength: 0,
13485
- segments: [],
13486
- },
13487
- miterLimit: 4,
13488
- isClosed: true,
13489
- } }, rest)) || this;
12903
+ _this = _super.call(this, __assign({ type: Shape.POLYGON, style: style, initialParsedStyle: {
12904
+ points: {
12905
+ points: [],
12906
+ totalLength: 0,
12907
+ segments: [],
12908
+ },
12909
+ miterLimit: 4,
12910
+ isClosed: true,
12911
+ } }, rest)) || this;
13490
12912
  _this.markerStartAngle = 0;
13491
12913
  _this.markerEndAngle = 0;
13492
12914
  /**
@@ -13621,18 +13043,15 @@ var Polyline = /** @class */ (function (_super) {
13621
13043
  function Polyline(_a) {
13622
13044
  if (_a === void 0) { _a = {}; }
13623
13045
  var style = _a.style, rest = __rest(_a, ["style"]);
13624
- return _super.call(this, __assign({ type: Shape.POLYLINE, style: runtime.enableCSSParsing
13625
- ? __assign({ points: '', miterLimit: '', isClosed: false }, style) : __assign({}, style), initialParsedStyle: runtime.enableCSSParsing
13626
- ? null
13627
- : {
13628
- points: {
13629
- points: [],
13630
- totalLength: 0,
13631
- segments: [],
13632
- },
13633
- miterLimit: 4,
13634
- isClosed: false,
13635
- } }, rest)) || this;
13046
+ return _super.call(this, __assign({ type: Shape.POLYLINE, style: style, initialParsedStyle: {
13047
+ points: {
13048
+ points: [],
13049
+ totalLength: 0,
13050
+ segments: [],
13051
+ },
13052
+ miterLimit: 4,
13053
+ isClosed: false,
13054
+ } }, rest)) || this;
13636
13055
  }
13637
13056
  Polyline.prototype.getTotalLength = function () {
13638
13057
  return getOrCalculatePolylineTotalLength(this);
@@ -13716,16 +13135,8 @@ var Text = /** @class */ (function (_super) {
13716
13135
  function Text(_a) {
13717
13136
  if (_a === void 0) { _a = {}; }
13718
13137
  var style = _a.style, rest = __rest(_a, ["style"]);
13719
- return _super.call(this, __assign({ type: Shape.TEXT, style: runtime.enableCSSParsing
13720
- ? __assign({ x: '', y: '', text: '', fontSize: '', fontFamily: '', fontStyle: '', fontWeight: '', fontVariant: '', textAlign: '', textBaseline: '', textTransform: '', fill: 'black', letterSpacing: '', lineHeight: '', miterLimit: '',
13721
- // whiteSpace: 'pre',
13722
- wordWrap: false, wordWrapWidth: 0, leading: 0, dx: '', dy: '' }, style) : __assign({ fill: 'black' }, style) }, rest)) || this;
13723
- }
13724
- // lengthAdjust: SVGAnimatedEnumeration;
13725
- // textLength: SVGAnimatedLength;
13726
- // getCharNumAtPosition(point?: DOMPointInit): number {
13727
- // throw new Error('Method not implemented.');
13728
- // }
13138
+ return _super.call(this, __assign({ type: Shape.TEXT, style: __assign({ fill: 'black' }, style) }, rest)) || this;
13139
+ }
13729
13140
  /**
13730
13141
  * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextContentElement
13731
13142
  */
@@ -13734,27 +13145,6 @@ var Text = /** @class */ (function (_super) {
13734
13145
  this.getGeometryBounds();
13735
13146
  return ((_a = this.parsedStyle.metrics) === null || _a === void 0 ? void 0 : _a.maxLineWidth) || 0;
13736
13147
  };
13737
- // getEndPositionOfChar(charnum: number): DOMPoint {
13738
- // throw new Error('Method not implemented.');
13739
- // }
13740
- // getExtentOfChar(charnum: number): DOMRect {
13741
- // throw new Error('Method not implemented.');
13742
- // }
13743
- // getNumberOfChars(): number {
13744
- // throw new Error('Method not implemented.');
13745
- // }
13746
- // getRotationOfChar(charnum: number): number {
13747
- // throw new Error('Method not implemented.');
13748
- // }
13749
- // getStartPositionOfChar(charnum: number): DOMPoint {
13750
- // throw new Error('Method not implemented.');
13751
- // }
13752
- // getSubStringLength(charnum: number, nchars: number): number {
13753
- // throw new Error('Method not implemented.');
13754
- // }
13755
- // selectSubString(charnum: number, nchars: number): void {
13756
- // throw new Error('Method not implemented.');
13757
- // }
13758
13148
  Text.prototype.getLineBoundingRects = function () {
13759
13149
  var _a;
13760
13150
  this.getGeometryBounds();
@@ -14268,30 +13658,37 @@ var CullingPlugin = /** @class */ (function () {
14268
13658
  renderingService.hooks.cull.tap(CullingPlugin.tag, function (object) {
14269
13659
  if (object) {
14270
13660
  var cullable = object.cullable;
13661
+ // cullable.visible = true;
13662
+ // const renderBounds = object.getRenderBounds();
13663
+ // if (AABB.isEmpty(renderBounds)) {
13664
+ // cullable.visible = false;
13665
+ // } else {
13666
+ // const isShape2D = shape2D.indexOf(object.nodeName as Shape) > -1;
13667
+ // const [p0, p1, p2, p3] = camera.getFrustum().planes;
13668
+ // tmpAABB.setMinMax([-p1.distance, -p3.distance, 0], [p0.distance, p2.distance, 0]);
13669
+ // cullable.visible = isShape2D ? renderBounds.intersects(tmpAABB) : true;
13670
+ // }
14271
13671
  if (strategies.length === 0) {
14272
- cullable.visible =
14273
- renderingContext.unculledEntities.indexOf(object.entity) > -1;
13672
+ cullable.visible = renderingContext.unculledEntities.indexOf(object.entity) > -1;
14274
13673
  }
14275
13674
  else {
14276
13675
  // eg. implemented by g-webgl(frustum culling)
14277
- cullable.visible = strategies.every(function (strategy) {
14278
- return strategy.isVisible(camera, object);
14279
- });
13676
+ cullable.visible = strategies.every(function (strategy) { return strategy.isVisible(camera, object); });
14280
13677
  }
14281
13678
  if (!object.isCulled() && object.isVisible()) {
14282
13679
  return object;
14283
13680
  }
14284
13681
  else {
13682
+ // if (this.renderingContext.renderListLastFrame.indexOf(object) > -1) {
14285
13683
  object.dispatchEvent(new CustomEvent(ElementEvent.CULLED));
13684
+ // }
14286
13685
  }
14287
13686
  return null;
14288
13687
  }
14289
13688
  return object;
14290
13689
  });
14291
- renderingService.hooks.afterRender.tap(CullingPlugin.tag, function (objects) {
14292
- objects.forEach(function (object) {
14293
- object.cullable.visibilityPlaneMask = -1;
14294
- });
13690
+ renderingService.hooks.afterRender.tap(CullingPlugin.tag, function (object) {
13691
+ object.cullable.visibilityPlaneMask = -1;
14295
13692
  });
14296
13693
  };
14297
13694
  CullingPlugin.tag = 'Culling';
@@ -14702,10 +14099,8 @@ var FrustumCullingStrategy = /** @class */ (function () {
14702
14099
 
14703
14100
  var PrepareRendererPlugin = /** @class */ (function () {
14704
14101
  function PrepareRendererPlugin() {
14705
- /**
14706
- * sync to RBush later
14707
- */
14708
- this.toSync = new Set();
14102
+ this.syncTasks = new Map();
14103
+ this.isFirstTimeRendering = true;
14709
14104
  this.syncing = false;
14710
14105
  this.isFirstTimeRenderingFinished = false;
14711
14106
  }
@@ -14721,20 +14116,7 @@ var PrepareRendererPlugin = /** @class */ (function () {
14721
14116
  renderingService.dirtify();
14722
14117
  };
14723
14118
  var handleBoundsChanged = function (e) {
14724
- var affectChildren = e.detail.affectChildren;
14725
- var object = e.target;
14726
- if (affectChildren) {
14727
- object.forEach(function (node) {
14728
- _this.toSync.add(node);
14729
- });
14730
- }
14731
- var p = object;
14732
- while (p) {
14733
- if (p.renderable) {
14734
- _this.toSync.add(p);
14735
- }
14736
- p = p.parentElement;
14737
- }
14119
+ _this.syncTasks.set(e.target, e.detail.affectChildren);
14738
14120
  renderingService.dirtify();
14739
14121
  };
14740
14122
  var handleMounted = function (e) {
@@ -14742,13 +14124,6 @@ var PrepareRendererPlugin = /** @class */ (function () {
14742
14124
  if (runtime.enableSizeAttenuation) {
14743
14125
  runtime.styleValueRegistry.updateSizeAttenuation(object, canvas.getCamera().getZoom());
14744
14126
  }
14745
- if (runtime.enableCSSParsing) {
14746
- // recalc style values
14747
- runtime.styleValueRegistry.recalc(object);
14748
- }
14749
- if (object.renderable.rendered)
14750
- runtime.sceneGraphService.dirtifyToRoot(object);
14751
- renderingService.dirtify();
14752
14127
  };
14753
14128
  var handleUnmounted = function (e) {
14754
14129
  var object = e.target;
@@ -14756,7 +14131,7 @@ var PrepareRendererPlugin = /** @class */ (function () {
14756
14131
  if (rBushNode.aabb) {
14757
14132
  _this.rBush.remove(rBushNode.aabb);
14758
14133
  }
14759
- _this.toSync.delete(object);
14134
+ _this.syncTasks.delete(object);
14760
14135
  runtime.sceneGraphService.dirtifyToRoot(object);
14761
14136
  renderingService.dirtify();
14762
14137
  };
@@ -14771,77 +14146,95 @@ var PrepareRendererPlugin = /** @class */ (function () {
14771
14146
  canvas.removeEventListener(ElementEvent.UNMOUNTED, handleUnmounted);
14772
14147
  canvas.removeEventListener(ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
14773
14148
  canvas.removeEventListener(ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
14774
- _this.toSync.clear();
14149
+ _this.syncTasks.clear();
14775
14150
  });
14776
14151
  var ric = (_a = runtime.globalThis.requestIdleCallback) !== null && _a !== void 0 ? _a : raf.bind(runtime.globalThis);
14777
14152
  renderingService.hooks.endFrame.tap(PrepareRendererPlugin.tag, function () {
14778
- var frame = context.renderingService.frame;
14779
- if (frame === 2) {
14153
+ if (_this.isFirstTimeRendering) {
14154
+ _this.isFirstTimeRendering = false;
14780
14155
  _this.syncing = true;
14781
14156
  ric(function () {
14782
14157
  _this.syncRTree(true);
14783
14158
  _this.isFirstTimeRenderingFinished = true;
14784
14159
  });
14785
14160
  }
14786
- else if (frame > 2) {
14161
+ else {
14787
14162
  _this.syncRTree();
14788
14163
  }
14789
- _this.toSync.forEach(function (node) { return (node.renderable.rendered = true); });
14790
14164
  });
14791
14165
  };
14166
+ PrepareRendererPlugin.prototype.syncNode = function (node, force) {
14167
+ if (force === void 0) { force = false; }
14168
+ if (!node.isConnected)
14169
+ return;
14170
+ var rBushNode = node.rBushNode;
14171
+ // clear dirty node
14172
+ if (rBushNode.aabb)
14173
+ this.rBush.remove(rBushNode.aabb);
14174
+ var renderBounds = node.getRenderBounds();
14175
+ if (renderBounds) {
14176
+ var renderable = node.renderable;
14177
+ if (force) {
14178
+ if (!renderable.dirtyRenderBounds) {
14179
+ renderable.dirtyRenderBounds = new AABB();
14180
+ }
14181
+ // save last dirty aabb
14182
+ renderable.dirtyRenderBounds.update(renderBounds.center, renderBounds.halfExtents);
14183
+ }
14184
+ var _a = __read(renderBounds.getMin(), 2), minX = _a[0], minY = _a[1];
14185
+ var _b = __read(renderBounds.getMax(), 2), maxX = _b[0], maxY = _b[1];
14186
+ if (!rBushNode.aabb) {
14187
+ rBushNode.aabb = {};
14188
+ }
14189
+ rBushNode.aabb.displayObject = node;
14190
+ rBushNode.aabb.minX = minX;
14191
+ rBushNode.aabb.minY = minY;
14192
+ rBushNode.aabb.maxX = maxX;
14193
+ rBushNode.aabb.maxY = maxY;
14194
+ }
14195
+ if (rBushNode.aabb) {
14196
+ // TODO: NaN occurs when width/height of Rect is 0
14197
+ if (!isNaN(rBushNode.aabb.maxX) &&
14198
+ !isNaN(rBushNode.aabb.maxX) &&
14199
+ !isNaN(rBushNode.aabb.minX) &&
14200
+ !isNaN(rBushNode.aabb.minY)) {
14201
+ return rBushNode.aabb;
14202
+ }
14203
+ }
14204
+ };
14792
14205
  PrepareRendererPlugin.prototype.syncRTree = function (force) {
14793
14206
  var _this = this;
14794
14207
  if (force === void 0) { force = false; }
14795
- if (!force && (this.syncing || this.toSync.size === 0)) {
14208
+ if (!force && (this.syncing || this.syncTasks.size === 0)) {
14796
14209
  return;
14797
14210
  }
14798
14211
  this.syncing = true;
14799
14212
  // bounds changed, need re-inserting its children
14800
14213
  var bulk = [];
14801
- this.toSync.forEach(function (node) {
14802
- if (!node.isConnected)
14803
- return;
14804
- var rBushNode = node.rBushNode;
14805
- // clear dirty node
14806
- if (rBushNode.aabb) {
14807
- _this.rBush.remove(rBushNode.aabb);
14808
- }
14809
- var renderBounds = node.getRenderBounds();
14810
- if (renderBounds) {
14811
- var renderable = node.renderable;
14812
- if (force) {
14813
- if (!renderable.dirtyRenderBounds) {
14814
- renderable.dirtyRenderBounds = new AABB();
14815
- }
14816
- // save last dirty aabb
14817
- renderable.dirtyRenderBounds.update(renderBounds.center, renderBounds.halfExtents);
14818
- }
14819
- var _a = __read(renderBounds.getMin(), 2), minX = _a[0], minY = _a[1];
14820
- var _b = __read(renderBounds.getMax(), 2), maxX = _b[0], maxY = _b[1];
14821
- if (!rBushNode.aabb) {
14822
- rBushNode.aabb = {};
14214
+ var synced = new Set();
14215
+ var sync = function (node) {
14216
+ if (!synced.has(node) && node.renderable) {
14217
+ var aabb = _this.syncNode(node, force);
14218
+ if (aabb) {
14219
+ bulk.push(aabb);
14220
+ synced.add(node);
14823
14221
  }
14824
- rBushNode.aabb.displayObject = node;
14825
- rBushNode.aabb.minX = minX;
14826
- rBushNode.aabb.minY = minY;
14827
- rBushNode.aabb.maxX = maxX;
14828
- rBushNode.aabb.maxY = maxY;
14829
14222
  }
14830
- if (rBushNode.aabb) {
14831
- // TODO: NaN occurs when width/height of Rect is 0
14832
- if (!isNaN(rBushNode.aabb.maxX) &&
14833
- !isNaN(rBushNode.aabb.maxX) &&
14834
- !isNaN(rBushNode.aabb.minX) &&
14835
- !isNaN(rBushNode.aabb.minY)) {
14836
- bulk.push(rBushNode.aabb);
14837
- }
14223
+ };
14224
+ this.syncTasks.forEach(function (affectChildren, node) {
14225
+ if (affectChildren) {
14226
+ node.forEach(sync);
14227
+ }
14228
+ var parent = node;
14229
+ while (parent) {
14230
+ sync(parent);
14231
+ parent = parent.parentElement;
14838
14232
  }
14839
14233
  });
14840
14234
  // use bulk inserting, which is ~2-3 times faster
14841
14235
  // @see https://github.com/mourner/rbush#bulk-inserting-data
14842
14236
  this.rBush.load(bulk);
14843
14237
  bulk.length = 0;
14844
- this.toSync.clear();
14845
14238
  this.syncing = false;
14846
14239
  };
14847
14240
  PrepareRendererPlugin.tag = 'Prepare';
@@ -14898,9 +14291,9 @@ var Canvas = /** @class */ (function (_super) {
14898
14291
  _this.document.defaultView = _this;
14899
14292
  // create registry of custom elements
14900
14293
  _this.customElements = new CustomElementRegistry();
14901
- var container = config.container, canvas = config.canvas, offscreenCanvas = config.offscreenCanvas, width = config.width, height = config.height, devicePixelRatio = config.devicePixelRatio, renderer = config.renderer, background = config.background, cursor = config.cursor, document = config.document, requestAnimationFrame = config.requestAnimationFrame, cancelAnimationFrame = config.cancelAnimationFrame, createImage = config.createImage, supportsPointerEvents = config.supportsPointerEvents, supportsTouchEvents = config.supportsTouchEvents, supportsCSSTransform = config.supportsCSSTransform, fastCleanExistingCanvas = config.fastCleanExistingCanvas, supportsMutipleCanvasesInOneContainer = config.supportsMutipleCanvasesInOneContainer, useNativeClickEvent = config.useNativeClickEvent, alwaysTriggerPointerEventOnCanvas = config.alwaysTriggerPointerEventOnCanvas, isTouchEvent = config.isTouchEvent, isMouseEvent = config.isMouseEvent, dblClickSpeed = config.dblClickSpeed;
14294
+ var container = config.container, canvas = config.canvas, offscreenCanvas = config.offscreenCanvas, width = config.width, height = config.height, devicePixelRatio = config.devicePixelRatio, renderer = config.renderer, background = config.background, cursor = config.cursor, document = config.document, requestAnimationFrame = config.requestAnimationFrame, cancelAnimationFrame = config.cancelAnimationFrame, createImage = config.createImage, supportsPointerEvents = config.supportsPointerEvents, supportsTouchEvents = config.supportsTouchEvents, supportsCSSTransform = config.supportsCSSTransform, _a = config.cleanUpOnDestroy, cleanUpOnDestroy = _a === void 0 ? true : _a, supportsMutipleCanvasesInOneContainer = config.supportsMutipleCanvasesInOneContainer, useNativeClickEvent = config.useNativeClickEvent, alwaysTriggerPointerEventOnCanvas = config.alwaysTriggerPointerEventOnCanvas, isTouchEvent = config.isTouchEvent, isMouseEvent = config.isMouseEvent, dblClickSpeed = config.dblClickSpeed;
14902
14295
  if (!supportsMutipleCanvasesInOneContainer) {
14903
- cleanExistedCanvas(container, _this, fastCleanExistingCanvas);
14296
+ cleanExistedCanvas(container, _this, cleanUpOnDestroy);
14904
14297
  }
14905
14298
  var canvasWidth = width;
14906
14299
  var canvasHeight = height;
@@ -14961,8 +14354,8 @@ var Canvas = /** @class */ (function (_super) {
14961
14354
  document: document,
14962
14355
  supportsCSSTransform: supportsCSSTransform,
14963
14356
  useNativeClickEvent: useNativeClickEvent,
14357
+ cleanUpOnDestroy: cleanUpOnDestroy,
14964
14358
  alwaysTriggerPointerEventOnCanvas: alwaysTriggerPointerEventOnCanvas,
14965
- fastCleanExistingCanvas: fastCleanExistingCanvas,
14966
14359
  });
14967
14360
  _this.initDefaultCamera(canvasWidth, canvasHeight, renderer.clipSpaceNearZ);
14968
14361
  _this.initRenderer(renderer, true);
@@ -15072,9 +14465,8 @@ var Canvas = /** @class */ (function (_super) {
15072
14465
  */
15073
14466
  Canvas.prototype.destroy = function (cleanUp, skipTriggerEvent) {
15074
14467
  if (cleanUp === void 0) { cleanUp = true; }
15075
- var fastCleanExistingCanvas = this.getConfig().fastCleanExistingCanvas;
15076
14468
  if (skipTriggerEvent === undefined)
15077
- skipTriggerEvent = fastCleanExistingCanvas;
14469
+ skipTriggerEvent = this.getConfig().fastCleanExistingCanvas;
15078
14470
  if (!skipTriggerEvent) {
15079
14471
  this.dispatchEvent(new CustomEvent(CanvasEvent.BEFORE_DESTROY));
15080
14472
  }
@@ -15087,8 +14479,7 @@ var Canvas = /** @class */ (function (_super) {
15087
14479
  this.unmountChildren(root);
15088
14480
  if (cleanUp) {
15089
14481
  // destroy Document
15090
- if (!fastCleanExistingCanvas)
15091
- this.document.destroy();
14482
+ this.document.destroy();
15092
14483
  this.getEventService().destroy();
15093
14484
  }
15094
14485
  // destroy services
@@ -15101,10 +14492,20 @@ var Canvas = /** @class */ (function (_super) {
15101
14492
  this.context.rBushRoot = null;
15102
14493
  this.context.renderingContext.root = null;
15103
14494
  }
15104
- this.destroyed = true;
15105
14495
  if (!skipTriggerEvent) {
15106
14496
  this.dispatchEvent(new CustomEvent(CanvasEvent.AFTER_DESTROY));
15107
14497
  }
14498
+ var clearEventRetain = function (event) {
14499
+ event.currentTarget = null;
14500
+ event.manager = null;
14501
+ event.target = null;
14502
+ };
14503
+ clearEventRetain(mountedEvent);
14504
+ clearEventRetain(unmountedEvent);
14505
+ clearEventRetain(beforeRenderEvent);
14506
+ clearEventRetain(rerenderEvent);
14507
+ clearEventRetain(afterRenderEvent);
14508
+ this.destroyed = true;
15108
14509
  };
15109
14510
  /**
15110
14511
  * compatible with G 3.0
@@ -15218,13 +14619,13 @@ var Canvas = /** @class */ (function (_super) {
15218
14619
  });
15219
14620
  }
15220
14621
  };
15221
- Canvas.prototype.initRenderingService = function (renderer, firstContentfulPaint, async) {
14622
+ Canvas.prototype.initRenderingService = function (renderer, firstContentfullPaint, async) {
15222
14623
  var _this = this;
15223
- if (firstContentfulPaint === void 0) { firstContentfulPaint = false; }
14624
+ if (firstContentfullPaint === void 0) { firstContentfullPaint = false; }
15224
14625
  if (async === void 0) { async = false; }
15225
14626
  this.context.renderingService.init(function () {
15226
14627
  _this.inited = true;
15227
- if (firstContentfulPaint) {
14628
+ if (firstContentfullPaint) {
15228
14629
  if (async) {
15229
14630
  _this.requestAnimationFrame(function () {
15230
14631
  _this.dispatchEvent(new CustomEvent(CanvasEvent.READY));
@@ -15240,7 +14641,7 @@ var Canvas = /** @class */ (function (_super) {
15240
14641
  if (_this.readyPromise) {
15241
14642
  _this.resolveReadyPromise();
15242
14643
  }
15243
- if (!firstContentfulPaint) {
14644
+ if (!firstContentfullPaint) {
15244
14645
  _this.getRoot().forEach(function (node) {
15245
14646
  var renderable = node.renderable;
15246
14647
  if (renderable) {
@@ -15294,7 +14695,7 @@ var Canvas = /** @class */ (function (_super) {
15294
14695
  _this.unmountChildren(child);
15295
14696
  });
15296
14697
  if (this.inited) {
15297
- if (!this.getConfig().fastCleanExistingCanvas) {
14698
+ if (!this.getConfig().cleanUpOnDestroy) {
15298
14699
  if (parent.isMutationObserved) {
15299
14700
  parent.dispatchEvent(unmountedEvent);
15300
14701
  }
@@ -15316,35 +14717,41 @@ var Canvas = /** @class */ (function (_super) {
15316
14717
  }
15317
14718
  }
15318
14719
  };
15319
- Canvas.prototype.mountChildren = function (parent) {
14720
+ Canvas.prototype.mountChildren = function (child, skipTriggerEvent) {
15320
14721
  var _this = this;
14722
+ if (skipTriggerEvent === void 0) { skipTriggerEvent = isInFragment(child); }
15321
14723
  if (this.inited) {
15322
- if (!parent.isConnected) {
15323
- parent.ownerDocument = this.document;
15324
- parent.isConnected = true;
15325
- if (parent.isMutationObserved) {
15326
- parent.dispatchEvent(mountedEvent);
15327
- }
15328
- else {
15329
- mountedEvent.target = parent;
15330
- this.dispatchEvent(mountedEvent, true);
14724
+ if (!child.isConnected) {
14725
+ child.ownerDocument = this.document;
14726
+ child.isConnected = true;
14727
+ if (!skipTriggerEvent) {
14728
+ if (child.isMutationObserved) {
14729
+ child.dispatchEvent(mountedEvent);
14730
+ }
14731
+ else {
14732
+ mountedEvent.target = child;
14733
+ this.dispatchEvent(mountedEvent, true);
14734
+ }
15331
14735
  }
15332
14736
  }
15333
14737
  }
15334
14738
  else {
15335
- console.warn("[g]: You are trying to call `canvas.appendChild` before canvas' initialization finished. You can either await `canvas.ready` or listen to `CanvasEvent.READY` manually.", 'appended child: ', parent.nodeName);
14739
+ console.warn("[g]: You are trying to call `canvas.appendChild` before canvas' initialization finished. You can either await `canvas.ready` or listen to `CanvasEvent.READY` manually.", 'appended child: ', child.nodeName);
15336
14740
  }
15337
14741
  // recursively mount children
15338
- parent.childNodes.forEach(function (child) {
15339
- _this.mountChildren(child);
14742
+ child.childNodes.forEach(function (c) {
14743
+ _this.mountChildren(c, skipTriggerEvent);
15340
14744
  });
15341
14745
  // trigger after mounted
15342
- if (parent.isCustomElement) {
15343
- if (parent.connectedCallback) {
15344
- parent.connectedCallback();
14746
+ if (child.isCustomElement) {
14747
+ if (child.connectedCallback) {
14748
+ child.connectedCallback();
15345
14749
  }
15346
14750
  }
15347
14751
  };
14752
+ Canvas.prototype.mountFragment = function (child) {
14753
+ this.mountChildren(child, false);
14754
+ };
15348
14755
  Canvas.prototype.client2Viewport = function (client) {
15349
14756
  return this.getEventService().client2Viewport(client);
15350
14757
  };
@@ -15374,5 +14781,5 @@ var Canvas = /** @class */ (function (_super) {
15374
14781
  return Canvas;
15375
14782
  }(EventTarget));
15376
14783
 
15377
- export { AABB, AbstractRenderer, AbstractRendererPlugin, BUILT_IN_PROPERTIES, CSS, CSSGradientValue, CSSKeywordValue, CSSRGB, CSSStyleValue, CSSUnitValue, Camera, CameraEvent, CameraProjectionMode, CameraTrackingMode, CameraType, Canvas, CanvasEvent, Circle, CircleUpdater, ClipSpaceNearZ, CustomElement, CustomElementRegistry, CustomEvent, DefaultSceneGraphSelector, DefaultSceneGraphService, DisplayObject, Document, ERROR_MSG_METHOD_NOT_IMPLEMENTED, Element, ElementEvent, Ellipse, EllipseUpdater, EventService, EventTarget, FederatedEvent, FederatedMouseEvent, FederatedPointerEvent, FederatedWheelEvent, Frustum, GradientType, Group, GroupUpdater, HTML, HTMLUpdater, Image, Line, LineUpdater, Mask, MutationEvent, Node, OffscreenCanvasCreator, Path, PathUpdater, Plane, Point, Polygon, Polyline, PolylineUpdater, PropertySyntax, RBush, Rect, RectUpdater, Rectangle, RenderReason, RenderingService, Shape, SortReason, Strategy, Text, TextService, TextUpdater, UnitType, computeLinearGradient, computeRadialGradient, convertToPath, createVec3, decompose, definedProps, deg2rad, deg2turn, findClosestClipPathTarget, fromRotationTranslationScale, getAngle, getEuler, getOrCalculatePathTotalLength, grad2deg, isBrowser, isCSSGradientValue, isCSSRGB, isCanvas, isDisplayObject, isFillOrStrokeAffected, isPattern, mergeColors, parseColor, parseLength, parsePath, parseTransform, parsedTransformToMat4, propertyMetadataCache, rad2deg, resetEntityCounter, runtime, setDOMSize, translatePathToString, turn2deg };
14784
+ export { AABB, AbstractRenderer, AbstractRendererPlugin, BUILT_IN_PROPERTIES, CSS, CSSGradientValue, CSSKeywordValue, CSSRGB, CSSStyleValue, CSSUnitValue, Camera, CameraEvent, CameraProjectionMode, CameraTrackingMode, CameraType, Canvas, CanvasEvent, Circle, CircleUpdater, ClipSpaceNearZ, CustomElement, CustomElementRegistry, CustomEvent, DefaultSceneGraphSelector, DefaultSceneGraphService, DisplayObject, Document, ERROR_MSG_METHOD_NOT_IMPLEMENTED, Element, ElementEvent, Ellipse, EllipseUpdater, EventService, EventTarget, FederatedEvent, FederatedMouseEvent, FederatedPointerEvent, FederatedWheelEvent, Fragment, Frustum, GradientType, Group, GroupUpdater, HTML, HTMLUpdater, Image, Line, LineUpdater, Mask, MutationEvent, Node, OffscreenCanvasCreator, Path, PathUpdater, Plane, Point, Polygon, Polyline, PolylineUpdater, PropertySyntax, RBush, Rect, RectUpdater, Rectangle, RenderReason, RenderingService, Shape, SortReason, Strategy, Text, TextService, TextUpdater, UnitType, computeLinearGradient, computeRadialGradient, convertToPath, createVec3, decompose, definedProps, deg2rad, deg2turn, findClosestClipPathTarget, fromRotationTranslationScale, getAngle, getEuler, getOrCalculatePathTotalLength, grad2deg, isBrowser, isCSSGradientValue, isCSSRGB, isCanvas, isDisplayObject, isFederatedEvent, isFillOrStrokeAffected, isPattern, mergeColors, parseColor, parseLength, parsePath, parseTransform, parsedTransformToMat4, propertyMetadataCache, rad2deg, resetEntityCounter, runtime, setDOMSize, translatePathToString, turn2deg };
15378
14785
  //# sourceMappingURL=index.esm.js.map