@antv/g-lite 1.3.0-next.12 → 1.3.0-next.14

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.
@@ -1,5 +1,5 @@
1
1
  import type { CurveArray, PathArray } from '@antv/util';
2
2
  import type { ParsedPathStyleProps } from '../../display-objects';
3
3
  import type { IElement } from '../../dom';
4
- export declare function parsePath(path: string | PathArray): ParsedPathStyleProps['path'];
5
- export declare function mergePaths(left: ParsedPathStyleProps['path'], right: ParsedPathStyleProps['path'], object?: IElement): [CurveArray, CurveArray, (b: CurveArray) => CurveArray];
4
+ export declare function parsePath(path: string | PathArray): ParsedPathStyleProps['d'];
5
+ export declare function mergePaths(left: ParsedPathStyleProps['d'], right: ParsedPathStyleProps['d'], object?: IElement): [CurveArray, CurveArray, (b: CurveArray) => CurveArray];
@@ -3,13 +3,13 @@ import type { ParsedPathStyleProps } from '../../display-objects';
3
3
  import { Rectangle } from '../../shapes';
4
4
  import type { CSSProperty } from '../CSSProperty';
5
5
  import { mergePaths, parsePath } from '../parser/path';
6
- export declare class CSSPropertyPath implements Partial<CSSProperty<ParsedPathStyleProps['path'], ParsedPathStyleProps['path']>> {
6
+ export declare class CSSPropertyPath implements Partial<CSSProperty<ParsedPathStyleProps['d'], ParsedPathStyleProps['d']>> {
7
7
  /**
8
8
  * path2Curve
9
9
  */
10
10
  parser: typeof parsePath;
11
11
  parserWithCSSDisabled: typeof parsePath;
12
- calculator(name: string, oldParsed: ParsedPathStyleProps['path'], parsed: ParsedPathStyleProps['path']): {
12
+ calculator(name: string, oldParsed: ParsedPathStyleProps['d'], parsed: ParsedPathStyleProps['d']): {
13
13
  absolutePath: AbsoluteArray;
14
14
  hasArc: boolean;
15
15
  segments: import("../../display-objects").PathSegment[];
@@ -5,7 +5,6 @@ export interface ImageStyleProps extends BaseStyleProps {
5
5
  x?: number | string;
6
6
  y?: number | string;
7
7
  z?: number;
8
- img?: string | HTMLImageElement;
9
8
  src?: string | HTMLImageElement;
10
9
  width?: number | string;
11
10
  height?: number | string;
@@ -30,7 +29,6 @@ export interface ParsedImageStyleProps extends ParsedBaseStyleProps {
30
29
  x: number;
31
30
  y: number;
32
31
  z?: number;
33
- img?: string | HTMLImageElement;
34
32
  src?: string | HTMLImageElement;
35
33
  width?: number;
36
34
  height?: number;
@@ -5,7 +5,6 @@ import { Rectangle } from '../shapes/Rectangle';
5
5
  import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
6
6
  import { DisplayObject } from './DisplayObject';
7
7
  export interface PathStyleProps extends BaseStyleProps {
8
- path?: string | PathArray;
9
8
  d?: string | PathArray;
10
9
  /**
11
10
  * marker will be positioned at the first point
@@ -69,17 +68,7 @@ export interface PathArcParams {
69
68
  sweepFlag: number;
70
69
  }
71
70
  export interface ParsedPathStyleProps extends ParsedBaseStyleProps {
72
- path: {
73
- absolutePath: AbsoluteArray;
74
- hasArc: boolean;
75
- segments: PathSegment[];
76
- polygons: [number, number][][];
77
- polylines: [number, number][][];
78
- curve: CurveArray;
79
- totalLength: number;
80
- rect: Rectangle;
81
- };
82
- d?: {
71
+ d: {
83
72
  absolutePath: AbsoluteArray;
84
73
  hasArc: boolean;
85
74
  segments: PathSegment[];
package/dist/index.esm.js CHANGED
@@ -4220,10 +4220,10 @@ function mergeNumberLists(left, right) {
4220
4220
  }
4221
4221
 
4222
4222
  function getOrCalculatePathTotalLength(path) {
4223
- if (path.parsedStyle.path.totalLength === 0) {
4224
- path.parsedStyle.path.totalLength = getTotalLength(path.parsedStyle.path.absolutePath);
4223
+ if (path.parsedStyle.d.totalLength === 0) {
4224
+ path.parsedStyle.d.totalLength = getTotalLength(path.parsedStyle.d.absolutePath);
4225
4225
  }
4226
- return path.parsedStyle.path.totalLength;
4226
+ return path.parsedStyle.d.totalLength;
4227
4227
  }
4228
4228
  function removeRedundantMCommand(path) {
4229
4229
  for (var i = 0; i < path.length; i++) {
@@ -4933,7 +4933,7 @@ function convertToPath(object, transform) {
4933
4933
  }));
4934
4934
  break;
4935
4935
  case Shape.PATH:
4936
- var absolutePath = object.parsedStyle.path.absolutePath;
4936
+ var absolutePath = object.parsedStyle.d.absolutePath;
4937
4937
  commands = __spreadArray([], __read(absolutePath), false);
4938
4938
  break;
4939
4939
  }
@@ -6373,11 +6373,10 @@ var BUILT_IN_PROPERTIES = [
6373
6373
  },
6374
6374
  // Path
6375
6375
  {
6376
- n: 'path',
6376
+ n: 'd',
6377
6377
  int: true,
6378
6378
  l: true,
6379
6379
  d: '',
6380
- a: ['d'],
6381
6380
  syntax: PropertySyntax.PATH,
6382
6381
  p: 50,
6383
6382
  },
@@ -6544,7 +6543,7 @@ var BUILT_IN_PROPERTIES = [
6544
6543
  d: '0',
6545
6544
  },
6546
6545
  ];
6547
- BUILT_IN_PROPERTIES.filter(function (n) { return !!n.l; }).map(function (n) { return n.n; });
6546
+ var GEOMETRY_ATTRIBUTE_NAMES = BUILT_IN_PROPERTIES.filter(function (n) { return !!n.l; }).map(function (n) { return n.n; });
6548
6547
  var propertyMetadataCache = {};
6549
6548
  var unresolvedProperties = new WeakMap();
6550
6549
  // const uniqueAttributeSet = new Set<string>();
@@ -6607,14 +6606,14 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6607
6606
  var oldOffsetPath = object.parsedStyle.offsetPath;
6608
6607
  object.parsedStyle = Object.assign(object.parsedStyle, attributes);
6609
6608
  var needUpdateGeometry = !!options.forceUpdateGeometry;
6610
- // if (!needUpdateGeometry) {
6611
- // for (let i = 0; i < GEOMETRY_ATTRIBUTE_NAMES.length; i++) {
6612
- // if (GEOMETRY_ATTRIBUTE_NAMES[i] in attributes) {
6613
- // needUpdateGeometry = true;
6614
- // break;
6615
- // }
6616
- // }
6617
- // }
6609
+ if (!needUpdateGeometry) {
6610
+ for (var i = 0; i < GEOMETRY_ATTRIBUTE_NAMES.length; i++) {
6611
+ if (GEOMETRY_ATTRIBUTE_NAMES[i] in attributes) {
6612
+ needUpdateGeometry = true;
6613
+ break;
6614
+ }
6615
+ }
6616
+ }
6618
6617
  if (attributes.fill) {
6619
6618
  object.parsedStyle.fill = parseColor(attributes.fill);
6620
6619
  }
@@ -6646,14 +6645,14 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6646
6645
  }
6647
6646
  // Path
6648
6647
  // @ts-ignore
6649
- if (attributes.path === '') {
6650
- object.parsedStyle.path = __assign({}, EMPTY_PARSED_PATH);
6648
+ if (attributes.d === '') {
6649
+ object.parsedStyle.d = __assign({}, EMPTY_PARSED_PATH);
6651
6650
  }
6652
6651
  // @ts-ignore
6653
- if (attributes.path) {
6654
- object.parsedStyle.path = parsePath(
6652
+ if (attributes.d) {
6653
+ object.parsedStyle.d = parsePath(
6655
6654
  // @ts-ignore
6656
- attributes.path);
6655
+ attributes.d);
6657
6656
  }
6658
6657
  // Text
6659
6658
  if (attributes.textTransform) {
@@ -6705,10 +6704,16 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6705
6704
  if (attributes.transform) {
6706
6705
  this.runtime.CSSPropertySyntaxFactory['<transform>'].postProcessor(object, attributeNames);
6707
6706
  }
6707
+ if (attributes.transformOrigin) {
6708
+ this.runtime.CSSPropertySyntaxFactory['<transform-origin>'].postProcessor(object, attributeNames);
6709
+ }
6708
6710
  if (needUpdateGeometry) {
6709
6711
  object.geometry.dirty = true;
6710
- // FIXME setOrigin may have already dirtified to root.
6711
- // this.runtime.sceneGraphService.dirtifyToRoot(object);
6712
+ object.renderable.boundsDirty = true;
6713
+ object.renderable.renderBoundsDirty = true;
6714
+ if (!options.forceUpdateGeometry) {
6715
+ this.runtime.sceneGraphService.dirtifyToRoot(object);
6716
+ }
6712
6717
  }
6713
6718
  }
6714
6719
  else {
@@ -6768,8 +6773,11 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6768
6773
  // update geometry
6769
6774
  if (needUpdateGeometry_1) {
6770
6775
  object.geometry.dirty = true;
6771
- // FIXME setOrigin may have already dirtified to root.
6772
- this.runtime.sceneGraphService.dirtifyToRoot(object);
6776
+ object.renderable.boundsDirty = true;
6777
+ object.renderable.renderBoundsDirty = true;
6778
+ if (!options.forceUpdateGeometry) {
6779
+ this.runtime.sceneGraphService.dirtifyToRoot(object);
6780
+ }
6773
6781
  }
6774
6782
  attributeNames_1.forEach(function (name) {
6775
6783
  if (name in object.parsedStyle) {
@@ -6981,11 +6989,15 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6981
6989
  // depth / 2,
6982
6990
  // );
6983
6991
  // anchor is center by default, don't account for lineWidth here
6984
- var _h = parsedStyle, stroke = _h.stroke, lineWidth = _h.lineWidth,
6992
+ var _h = parsedStyle, stroke = _h.stroke, _j = _h.lineWidth, lineWidth = _j === void 0 ? 1 : _j,
6993
+ // lineCap,
6994
+ // lineJoin,
6995
+ // miterLimit,
6996
+ _k = _h.increasedLineWidthForHitTesting,
6985
6997
  // lineCap,
6986
6998
  // lineJoin,
6987
6999
  // miterLimit,
6988
- increasedLineWidthForHitTesting = _h.increasedLineWidthForHitTesting, shadowType = _h.shadowType, shadowColor = _h.shadowColor, _j = _h.filter, filter = _j === void 0 ? [] : _j, transformOrigin = _h.transformOrigin;
7000
+ increasedLineWidthForHitTesting = _k === void 0 ? 0 : _k, shadowType = _h.shadowType, shadowColor = _h.shadowColor, _l = _h.filter, filter = _l === void 0 ? [] : _l, transformOrigin = _h.transformOrigin;
6989
7001
  var center = [cx, cy, cz];
6990
7002
  // update geometry's AABB
6991
7003
  geometry_1.contentBounds.update(center, halfExtents);
@@ -7019,8 +7031,8 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
7019
7031
  geometry_1.renderBounds.update(center, halfExtents);
7020
7032
  // account for shadow, only support constant value now
7021
7033
  if (shadowColor && shadowType && shadowType !== 'inner') {
7022
- var _k = geometry_1.renderBounds, min = _k.min, max = _k.max;
7023
- var _l = parsedStyle, shadowBlur = _l.shadowBlur, shadowOffsetX = _l.shadowOffsetX, shadowOffsetY = _l.shadowOffsetY;
7034
+ var _m = geometry_1.renderBounds, min = _m.min, max = _m.max;
7035
+ var _o = parsedStyle, shadowBlur = _o.shadowBlur, shadowOffsetX = _o.shadowOffsetX, shadowOffsetY = _o.shadowOffsetY;
7024
7036
  var shadowBlurInPixels = shadowBlur || 0;
7025
7037
  var shadowOffsetXInPixels = shadowOffsetX || 0;
7026
7038
  var shadowOffsetYInPixels = shadowOffsetY || 0;
@@ -7790,7 +7802,7 @@ var genericFontFamilies = [
7790
7802
  ];
7791
7803
  var stringRegExp = /([\"\'])[^\'\"]+\1/;
7792
7804
  function toFontString(attributes) {
7793
- var fontSize = attributes.fontSize, fontFamily = attributes.fontFamily, fontStyle = attributes.fontStyle, fontVariant = attributes.fontVariant, fontWeight = attributes.fontWeight;
7805
+ var _a = attributes.fontSize, fontSize = _a === void 0 ? 16 : _a, _b = attributes.fontFamily, fontFamily = _b === void 0 ? 'sans-serif' : _b, _c = attributes.fontStyle, fontStyle = _c === void 0 ? 'normal' : _c, _d = attributes.fontVariant, fontVariant = _d === void 0 ? 'normal' : _d, _e = attributes.fontWeight, fontWeight = _e === void 0 ? 'normal' : _e;
7794
7806
  // build canvas api font setting from individual components. Convert a numeric this.fontSize to px
7795
7807
  // const fontSizeString: string = isNumber(fontSize) ? `${fontSize}px` : fontSize.toString();
7796
7808
  var fontSizeString = (isNumber(fontSize) && "".concat(fontSize, "px")) || '16px';
@@ -7818,6 +7830,7 @@ function createSkewMatrix(skewMatrix, skewX, skewY) {
7818
7830
  skewMatrix[1] = Math.tan(skewY); // Skew X axis in Y direction
7819
7831
  return skewMatrix;
7820
7832
  }
7833
+ var SCALE_EPSILON = 0.00001;
7821
7834
  var tmpMat1 = mat4.create();
7822
7835
  var tmpMat2 = mat4.create();
7823
7836
  function parsedTransformToMat4(transform, object) {
@@ -7827,23 +7840,27 @@ function parsedTransformToMat4(transform, object) {
7827
7840
  var t = parsed.t, d = parsed.d;
7828
7841
  if (t === 'scale') {
7829
7842
  // scale(1) scale(1, 1)
7830
- var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1, 1];
7843
+ var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return Math.max(s.value, SCALE_EPSILON); })) || [
7844
+ 1, 1,
7845
+ ];
7831
7846
  mat4.fromScaling(tmpMat2, [newScale[0], newScale[1], 1]);
7832
7847
  }
7833
7848
  else if (t === 'scalex') {
7834
- var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1];
7849
+ var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return Math.max(s.value, SCALE_EPSILON); })) || [1];
7835
7850
  mat4.fromScaling(tmpMat2, [newScale[0], 1, 1]);
7836
7851
  }
7837
7852
  else if (t === 'scaley') {
7838
- var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1];
7853
+ var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return Math.max(s.value, SCALE_EPSILON); })) || [1];
7839
7854
  mat4.fromScaling(tmpMat2, [1, newScale[0], 1]);
7840
7855
  }
7841
7856
  else if (t === 'scalez') {
7842
- var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1];
7857
+ var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return Math.max(s.value, SCALE_EPSILON); })) || [1];
7843
7858
  mat4.fromScaling(tmpMat2, [1, 1, newScale[0]]);
7844
7859
  }
7845
7860
  else if (t === 'scale3d') {
7846
- var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1, 1, 1];
7861
+ var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return Math.max(s.value, SCALE_EPSILON); })) || [
7862
+ 1, 1, 1,
7863
+ ];
7847
7864
  mat4.fromScaling(tmpMat2, [newScale[0], newScale[1], newScale[2]]);
7848
7865
  }
7849
7866
  else if (t === 'translate') {
@@ -8086,8 +8103,8 @@ var PathUpdater = /** @class */ (function () {
8086
8103
  function PathUpdater() {
8087
8104
  }
8088
8105
  PathUpdater.prototype.update = function (parsedStyle) {
8089
- var path = parsedStyle.path;
8090
- var _a = path.rect, x = _a.x, y = _a.y, width = _a.width, height = _a.height;
8106
+ var d = parsedStyle.d;
8107
+ var _a = d.rect, x = _a.x, y = _a.y, width = _a.width, height = _a.height;
8091
8108
  var hwidth = width / 2;
8092
8109
  var hheight = height / 2;
8093
8110
  return {
@@ -8136,17 +8153,17 @@ var RectUpdater = /** @class */ (function () {
8136
8153
  function RectUpdater() {
8137
8154
  }
8138
8155
  RectUpdater.prototype.update = function (parsedStyle, object) {
8139
- var _a = parsedStyle.x, x = _a === void 0 ? 0 : _a, _b = parsedStyle.y, y = _b === void 0 ? 0 : _b, img = parsedStyle.img, _c = parsedStyle.width, width = _c === void 0 ? 0 : _c, _d = parsedStyle.height, height = _d === void 0 ? 0 : _d;
8156
+ var _a = parsedStyle.x, x = _a === void 0 ? 0 : _a, _b = parsedStyle.y, y = _b === void 0 ? 0 : _b, src = parsedStyle.src, _c = parsedStyle.width, width = _c === void 0 ? 0 : _c, _d = parsedStyle.height, height = _d === void 0 ? 0 : _d;
8140
8157
  var contentWidth = width;
8141
8158
  var contentHeight = height;
8142
8159
  // resize with HTMLImageElement's size
8143
- if (img && !isString(img)) {
8160
+ if (src && !isString(src)) {
8144
8161
  if (!contentWidth) {
8145
- contentWidth = img.width;
8162
+ contentWidth = src.width;
8146
8163
  parsedStyle.width = contentWidth;
8147
8164
  }
8148
8165
  if (!contentHeight) {
8149
- contentHeight = img.height;
8166
+ contentHeight = src.height;
8150
8167
  parsedStyle.height = contentHeight;
8151
8168
  }
8152
8169
  }
@@ -8166,18 +8183,20 @@ var TextUpdater = /** @class */ (function () {
8166
8183
  }
8167
8184
  TextUpdater.prototype.isReadyToMeasure = function (parsedStyle, object) {
8168
8185
  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;
8169
- return (text &&
8170
- fontSize &&
8171
- fontStyle &&
8172
- fontWeight &&
8173
- fontVariant &&
8174
- textAlign &&
8175
- textBaseline &&
8176
- !isNil(lineWidth));
8186
+ return runtime.enableCSSParsing
8187
+ ? text &&
8188
+ fontSize &&
8189
+ fontStyle &&
8190
+ fontWeight &&
8191
+ fontVariant &&
8192
+ textAlign &&
8193
+ textBaseline &&
8194
+ !isNil(lineWidth)
8195
+ : text;
8177
8196
  };
8178
8197
  TextUpdater.prototype.update = function (parsedStyle, object) {
8179
8198
  var _a, _b;
8180
- var text = parsedStyle.text, textAlign = parsedStyle.textAlign, lineWidth = parsedStyle.lineWidth, textBaseline = parsedStyle.textBaseline, dx = parsedStyle.dx, dy = parsedStyle.dy, _c = parsedStyle.x, x = _c === void 0 ? 0 : _c, _d = parsedStyle.y, y = _d === void 0 ? 0 : _d;
8199
+ var text = parsedStyle.text, _c = parsedStyle.textAlign, textAlign = _c === void 0 ? 'start' : _c, _d = parsedStyle.lineWidth, lineWidth = _d === void 0 ? 1 : _d, _e = parsedStyle.textBaseline, textBaseline = _e === void 0 ? 'alphabetic' : _e, _f = parsedStyle.dx, dx = _f === void 0 ? 0 : _f, _g = parsedStyle.dy, dy = _g === void 0 ? 0 : _g, _h = parsedStyle.x, x = _h === void 0 ? 0 : _h, _j = parsedStyle.y, y = _j === void 0 ? 0 : _j;
8181
8200
  if (!this.isReadyToMeasure(parsedStyle, object)) {
8182
8201
  parsedStyle.metrics = {
8183
8202
  font: '',
@@ -11277,13 +11296,13 @@ var TextService = /** @class */ (function () {
11277
11296
  return properties;
11278
11297
  };
11279
11298
  TextService.prototype.measureText = function (text, parsedStyle, offscreenCanvas) {
11280
- var fontSize = parsedStyle.fontSize, wordWrap = parsedStyle.wordWrap, strokeHeight = parsedStyle.lineHeight, lineWidth = parsedStyle.lineWidth, textBaseline = parsedStyle.textBaseline, textAlign = parsedStyle.textAlign, letterSpacing = parsedStyle.letterSpacing, textPath = parsedStyle.textPath; parsedStyle.textPathSide; parsedStyle.textPathStartOffset;
11299
+ var _a = parsedStyle.fontSize, fontSize = _a === void 0 ? 16 : _a, _b = parsedStyle.wordWrap, wordWrap = _b === void 0 ? false : _b, strokeHeight = parsedStyle.lineHeight, _c = parsedStyle.lineWidth, lineWidth = _c === void 0 ? 1 : _c, _d = parsedStyle.textBaseline, textBaseline = _d === void 0 ? 'alphabetic' : _d, _e = parsedStyle.textAlign, textAlign = _e === void 0 ? 'start' : _e, _f = parsedStyle.letterSpacing, letterSpacing = _f === void 0 ? 0 : _f, textPath = parsedStyle.textPath; parsedStyle.textPathSide; parsedStyle.textPathStartOffset;
11281
11300
  var // dropShadow = 0,
11282
11301
  // dropShadowDistance = 0,
11283
- _a = parsedStyle.leading,
11302
+ _g = parsedStyle.leading,
11284
11303
  // dropShadow = 0,
11285
11304
  // dropShadowDistance = 0,
11286
- leading = _a === void 0 ? 0 : _a;
11305
+ leading = _g === void 0 ? 0 : _g;
11287
11306
  var font = toFontString(parsedStyle);
11288
11307
  // if (runtime.enableCSSParsing) {
11289
11308
  var fontProperties = this.measureFont(font, offscreenCanvas);
@@ -11395,7 +11414,7 @@ var TextService = /** @class */ (function () {
11395
11414
  TextService.prototype.setGraphemeOnPath = function () { };
11396
11415
  TextService.prototype.wordWrap = function (text, parsedStyle, offscreenCanvas) {
11397
11416
  var _this = this;
11398
- var _a = parsedStyle.wordWrapWidth, wordWrapWidth = _a === void 0 ? 0 : _a, letterSpacing = parsedStyle.letterSpacing, _b = parsedStyle.maxLines, maxLines = _b === void 0 ? Infinity : _b, textOverflow = parsedStyle.textOverflow;
11417
+ var _a = parsedStyle.wordWrapWidth, wordWrapWidth = _a === void 0 ? 0 : _a, _b = parsedStyle.letterSpacing, letterSpacing = _b === void 0 ? 0 : _b, _c = parsedStyle.maxLines, maxLines = _c === void 0 ? Infinity : _c, textOverflow = parsedStyle.textOverflow;
11399
11418
  var context = this.runtime.offscreenCanvasCreator.getOrCreateContext(offscreenCanvas);
11400
11419
  var maxWidth = wordWrapWidth + letterSpacing;
11401
11420
  var ellipsis = '';
@@ -11628,7 +11647,16 @@ var entityCounter = 0;
11628
11647
  function resetEntityCounter() {
11629
11648
  entityCounter = 0;
11630
11649
  }
11631
- new MutationEvent(ElementEvent.INSERTED, null, '', '', '', 0, '', '');
11650
+ // const insertedEvent = new MutationEvent(
11651
+ // ElementEvent.INSERTED,
11652
+ // null,
11653
+ // '',
11654
+ // '',
11655
+ // '',
11656
+ // 0,
11657
+ // '',
11658
+ // '',
11659
+ // );
11632
11660
  var removedEvent = new MutationEvent(ElementEvent.REMOVED, null, '', '', '', 0, '', '');
11633
11661
  var destroyEvent = new CustomEvent(ElementEvent.DESTROY);
11634
11662
  /**
@@ -12333,6 +12361,11 @@ var DisplayObject = /** @class */ (function (_super) {
12333
12361
  Object.assign(_this.attributes, DEFAULT_STYLE_PROPS);
12334
12362
  Object.assign(_this.parsedStyle, DEFAULT_PARSED_STYLE_PROPS, _this.config.initialParsedStyle);
12335
12363
  }
12364
+ else if (_this.config.initialParsedStyle) {
12365
+ Object.assign(_this.parsedStyle,
12366
+ // DEFAULT_PARSED_STYLE_PROPS_CSS_DISABLED,
12367
+ _this.config.initialParsedStyle);
12368
+ }
12336
12369
  // start to process attributes
12337
12370
  _this.initAttributes(_this.config.style);
12338
12371
  if (runtime.enableDataset) {
@@ -12974,9 +13007,7 @@ var Circle = /** @class */ (function (_super) {
12974
13007
  __extends(Circle, _super);
12975
13008
  function Circle(options) {
12976
13009
  if (options === void 0) { options = {}; }
12977
- var _this = _super.call(this, options) || this;
12978
- _this.nodeName = Shape.CIRCLE;
12979
- return _this;
13010
+ return _super.call(this, __assign({ type: Shape.CIRCLE }, options)) || this;
12980
13011
  }
12981
13012
  return Circle;
12982
13013
  }(DisplayObject));
@@ -13007,9 +13038,7 @@ var Ellipse = /** @class */ (function (_super) {
13007
13038
  __extends(Ellipse, _super);
13008
13039
  function Ellipse(options) {
13009
13040
  if (options === void 0) { options = {}; }
13010
- var _this = _super.call(this, options) || this;
13011
- _this.nodeName = Shape.ELLIPSE;
13012
- return _this;
13041
+ return _super.call(this, __assign({ type: Shape.ELLIPSE }, options)) || this;
13013
13042
  }
13014
13043
  return Ellipse;
13015
13044
  }(DisplayObject));
@@ -13028,9 +13057,7 @@ var Group = /** @class */ (function (_super) {
13028
13057
  __extends(Group, _super);
13029
13058
  function Group(options) {
13030
13059
  if (options === void 0) { options = {}; }
13031
- var _this = _super.call(this, options) || this;
13032
- _this.nodeName = Shape.GROUP;
13033
- return _this;
13060
+ return _super.call(this, __assign({ type: Shape.GROUP }, options)) || this;
13034
13061
  }
13035
13062
  return Group;
13036
13063
  }(DisplayObject));
@@ -13105,9 +13132,7 @@ var Image = /** @class */ (function (_super) {
13105
13132
  __extends(Image, _super);
13106
13133
  function Image(options) {
13107
13134
  if (options === void 0) { options = {}; }
13108
- var _this = _super.call(this, options) || this;
13109
- _this.nodeName = Shape.IMAGE;
13110
- return _this;
13135
+ return _super.call(this, __assign({ type: Shape.IMAGE }, options)) || this;
13111
13136
  }
13112
13137
  return Image;
13113
13138
  }(DisplayObject));
@@ -13236,11 +13261,11 @@ var Path = /** @class */ (function (_super) {
13236
13261
  var _this = this;
13237
13262
  var style = _a.style, rest = __rest(_a, ["style"]);
13238
13263
  _this = _super.call(this, __assign({ type: Shape.PATH, style: runtime.enableCSSParsing
13239
- ? __assign({ path: '', miterLimit: '' }, style) : __assign({}, style), initialParsedStyle: runtime.enableCSSParsing
13264
+ ? __assign({ d: '', miterLimit: '' }, style) : __assign({}, style), initialParsedStyle: runtime.enableCSSParsing
13240
13265
  ? null
13241
13266
  : {
13242
13267
  miterLimit: 4,
13243
- path: __assign({}, EMPTY_PARSED_PATH),
13268
+ d: __assign({}, EMPTY_PARSED_PATH),
13244
13269
  } }, rest)) || this;
13245
13270
  _this.markerStartAngle = 0;
13246
13271
  _this.markerEndAngle = 0;
@@ -13265,7 +13290,7 @@ var Path = /** @class */ (function (_super) {
13265
13290
  return _this;
13266
13291
  }
13267
13292
  Path.prototype.attributeChangedCallback = function (attrName, oldValue, newValue, prevParsedValue, newParsedValue) {
13268
- if (attrName === 'path') {
13293
+ if (attrName === 'd') {
13269
13294
  // recalc markers
13270
13295
  this.transformMarker(true);
13271
13296
  this.transformMarker(false);
@@ -13340,7 +13365,7 @@ var Path = /** @class */ (function (_super) {
13340
13365
  marker.setLocalPosition(ox + Math.cos(rad) * offset, oy + Math.sin(rad) * offset);
13341
13366
  };
13342
13367
  Path.prototype.placeMarkerMid = function (marker) {
13343
- var segments = this.parsedStyle.path.segments;
13368
+ var segments = this.parsedStyle.d.segments;
13344
13369
  // clear all existed markers
13345
13370
  this.markerMidList.forEach(function (marker) {
13346
13371
  marker.remove();
@@ -13369,7 +13394,7 @@ var Path = /** @class */ (function (_super) {
13369
13394
  */
13370
13395
  Path.prototype.getPointAtLength = function (distance, inWorldSpace) {
13371
13396
  if (inWorldSpace === void 0) { inWorldSpace = false; }
13372
- var absolutePath = this.parsedStyle.path.absolutePath;
13397
+ var absolutePath = this.parsedStyle.d.absolutePath;
13373
13398
  var _a = getPointAtLength(absolutePath, distance), x = _a.x, y = _a.y;
13374
13399
  var transformed = vec3.transformMat4(vec3.create(), vec3.fromValues(x, y, 0), inWorldSpace ? this.getWorldTransform() : this.getLocalTransform());
13375
13400
  // apply local transformation
@@ -13386,7 +13411,7 @@ var Path = /** @class */ (function (_super) {
13386
13411
  * Get start tangent vector
13387
13412
  */
13388
13413
  Path.prototype.getStartTangent = function () {
13389
- var segments = this.parsedStyle.path.segments;
13414
+ var segments = this.parsedStyle.d.segments;
13390
13415
  var result = [];
13391
13416
  if (segments.length > 1) {
13392
13417
  var startPoint = segments[0].currentPoint;
@@ -13408,7 +13433,7 @@ var Path = /** @class */ (function (_super) {
13408
13433
  * Get end tangent vector
13409
13434
  */
13410
13435
  Path.prototype.getEndTangent = function () {
13411
- var segments = this.parsedStyle.path.segments;
13436
+ var segments = this.parsedStyle.d.segments;
13412
13437
  var length = segments.length;
13413
13438
  var result = [];
13414
13439
  if (length > 1) {
@@ -13640,9 +13665,7 @@ var Rect = /** @class */ (function (_super) {
13640
13665
  __extends(Rect, _super);
13641
13666
  function Rect(options) {
13642
13667
  if (options === void 0) { options = {}; }
13643
- var _this = _super.call(this, options) || this;
13644
- _this.nodeName = Shape.RECT;
13645
- return _this;
13668
+ return _super.call(this, __assign({ type: Shape.RECT }, options)) || this;
13646
13669
  }
13647
13670
  return Rect;
13648
13671
  }(DisplayObject));
@@ -13664,26 +13687,7 @@ var Text = /** @class */ (function (_super) {
13664
13687
  return _super.call(this, __assign({ type: Shape.TEXT, style: runtime.enableCSSParsing
13665
13688
  ? __assign({ x: '', y: '', text: '', fontSize: '', fontFamily: '', fontStyle: '', fontWeight: '', fontVariant: '', textAlign: '', textBaseline: '', textTransform: '', fill: 'black', letterSpacing: '', lineHeight: '', miterLimit: '',
13666
13689
  // whiteSpace: 'pre',
13667
- wordWrap: false, wordWrapWidth: 0, leading: 0, dx: '', dy: '' }, style) : __assign({ fill: 'black' }, style), initialParsedStyle: runtime.enableCSSParsing
13668
- ? {}
13669
- : {
13670
- x: 0,
13671
- y: 0,
13672
- fontSize: 16,
13673
- fontFamily: 'sans-serif',
13674
- fontStyle: 'normal',
13675
- fontWeight: 'normal',
13676
- fontVariant: 'normal',
13677
- lineHeight: 0,
13678
- letterSpacing: 0,
13679
- textBaseline: 'alphabetic',
13680
- textAlign: 'start',
13681
- wordWrap: false,
13682
- wordWrapWidth: 0,
13683
- leading: 0,
13684
- dx: 0,
13685
- dy: 0,
13686
- } }, rest)) || this;
13690
+ wordWrap: false, wordWrapWidth: 0, leading: 0, dx: '', dy: '' }, style) : __assign({ fill: 'black' }, style) }, rest)) || this;
13687
13691
  }
13688
13692
  // lengthAdjust: SVGAnimatedEnumeration;
13689
13693
  // textLength: SVGAnimatedLength;
@@ -14703,7 +14707,7 @@ var PrepareRendererPlugin = /** @class */ (function () {
14703
14707
  * sync to RBush later
14704
14708
  */
14705
14709
  this.toSync = new Set();
14706
- // private isFirstTimeRendering = true;
14710
+ this.isFirstTimeRendering = true;
14707
14711
  this.syncing = false;
14708
14712
  }
14709
14713
  PrepareRendererPlugin.prototype.apply = function (context) {
@@ -14767,14 +14771,22 @@ var PrepareRendererPlugin = /** @class */ (function () {
14767
14771
  _this.toSync.clear();
14768
14772
  });
14769
14773
  renderingService.hooks.endFrame.tap(PrepareRendererPlugin.tag, function () {
14770
- requestIdleCallback(function () {
14774
+ if (_this.isFirstTimeRendering) {
14775
+ _this.isFirstTimeRendering = false;
14776
+ _this.syncing = true;
14777
+ requestIdleCallback(function () {
14778
+ _this.syncRTree(true);
14779
+ });
14780
+ }
14781
+ else {
14771
14782
  _this.syncRTree();
14772
- });
14783
+ }
14773
14784
  });
14774
14785
  };
14775
- PrepareRendererPlugin.prototype.syncRTree = function () {
14786
+ PrepareRendererPlugin.prototype.syncRTree = function (force) {
14776
14787
  var _this = this;
14777
- if (this.syncing || this.toSync.size === 0) {
14788
+ if (force === void 0) { force = false; }
14789
+ if (!force && (this.syncing || this.toSync.size === 0)) {
14778
14790
  return;
14779
14791
  }
14780
14792
  this.syncing = true;