@antv/g-lite 1.3.0-next.11 → 1.3.0-next.13

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[];
@@ -237,16 +237,6 @@ export declare class DisplayObject<StyleProps extends BaseStyleProps = any, Pars
237
237
  * @deprecated
238
238
  */
239
239
  add<T extends IChildNode>(child: T, index?: number): T;
240
- /**
241
- * Use `this.style.clipPath` instead.
242
- * @deprecated
243
- */
244
- setClip(clipPath: DisplayObject | null): void;
245
- /**
246
- * Use `this.style.clipPath` instead.
247
- * @deprecated
248
- */
249
- getClip: () => any;
250
240
  /**
251
241
  * @deprecated
252
242
  */
@@ -21,5 +21,5 @@ export interface ParsedGroupStyleProps extends ParsedBaseStyleProps {
21
21
  </g>
22
22
  */
23
23
  export declare class Group extends DisplayObject {
24
- constructor({ style, ...rest }?: DisplayObjectConfig<GroupStyleProps>);
24
+ constructor(options?: DisplayObjectConfig<GroupStyleProps>);
25
25
  }
@@ -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;
@@ -40,5 +38,5 @@ export interface ParsedImageStyleProps extends ParsedBaseStyleProps {
40
38
  keepAspectRatio?: boolean;
41
39
  }
42
40
  export declare class Image extends DisplayObject<ImageStyleProps, ParsedImageStyleProps> {
43
- constructor({ style, ...rest }?: DisplayObjectConfig<ImageStyleProps>);
41
+ constructor(options?: DisplayObjectConfig<ImageStyleProps>);
44
42
  }
@@ -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[];
@@ -23,5 +23,5 @@ export interface ParsedRectStyleProps extends ParsedBaseStyleProps {
23
23
  radius?: [number, number, number, number];
24
24
  }
25
25
  export declare class Rect extends DisplayObject<RectStyleProps, ParsedRectStyleProps> {
26
- constructor({ style, ...rest }?: DisplayObjectConfig<RectStyleProps>);
26
+ constructor(options?: DisplayObjectConfig<RectStyleProps>);
27
27
  }
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,13 @@ 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;
6712
6714
  }
6713
6715
  }
6714
6716
  else {
@@ -6768,8 +6770,8 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6768
6770
  // update geometry
6769
6771
  if (needUpdateGeometry_1) {
6770
6772
  object.geometry.dirty = true;
6771
- // FIXME setOrigin may have already dirtified to root.
6772
- this.runtime.sceneGraphService.dirtifyToRoot(object);
6773
+ object.renderable.boundsDirty = true;
6774
+ object.renderable.renderBoundsDirty = true;
6773
6775
  }
6774
6776
  attributeNames_1.forEach(function (name) {
6775
6777
  if (name in object.parsedStyle) {
@@ -6981,11 +6983,15 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6981
6983
  // depth / 2,
6982
6984
  // );
6983
6985
  // anchor is center by default, don't account for lineWidth here
6984
- var _h = parsedStyle, stroke = _h.stroke, lineWidth = _h.lineWidth,
6986
+ var _h = parsedStyle, stroke = _h.stroke, _j = _h.lineWidth, lineWidth = _j === void 0 ? 1 : _j,
6987
+ // lineCap,
6988
+ // lineJoin,
6989
+ // miterLimit,
6990
+ _k = _h.increasedLineWidthForHitTesting,
6985
6991
  // lineCap,
6986
6992
  // lineJoin,
6987
6993
  // miterLimit,
6988
- increasedLineWidthForHitTesting = _h.increasedLineWidthForHitTesting, shadowType = _h.shadowType, shadowColor = _h.shadowColor, _j = _h.filter, filter = _j === void 0 ? [] : _j, transformOrigin = _h.transformOrigin;
6994
+ increasedLineWidthForHitTesting = _k === void 0 ? 0 : _k, shadowType = _h.shadowType, shadowColor = _h.shadowColor, _l = _h.filter, filter = _l === void 0 ? [] : _l, transformOrigin = _h.transformOrigin;
6989
6995
  var center = [cx, cy, cz];
6990
6996
  // update geometry's AABB
6991
6997
  geometry_1.contentBounds.update(center, halfExtents);
@@ -7019,8 +7025,8 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
7019
7025
  geometry_1.renderBounds.update(center, halfExtents);
7020
7026
  // account for shadow, only support constant value now
7021
7027
  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;
7028
+ var _m = geometry_1.renderBounds, min = _m.min, max = _m.max;
7029
+ var _o = parsedStyle, shadowBlur = _o.shadowBlur, shadowOffsetX = _o.shadowOffsetX, shadowOffsetY = _o.shadowOffsetY;
7024
7030
  var shadowBlurInPixels = shadowBlur || 0;
7025
7031
  var shadowOffsetXInPixels = shadowOffsetX || 0;
7026
7032
  var shadowOffsetYInPixels = shadowOffsetY || 0;
@@ -7391,6 +7397,7 @@ var CSSPropertyPath = /** @class */ (function () {
7391
7397
  rect: new Rectangle(0, 0, 0, 0),
7392
7398
  };
7393
7399
  }
7400
+ console.log('parsed', parsed);
7394
7401
  return parsed;
7395
7402
  };
7396
7403
  return CSSPropertyPath;
@@ -7790,7 +7797,7 @@ var genericFontFamilies = [
7790
7797
  ];
7791
7798
  var stringRegExp = /([\"\'])[^\'\"]+\1/;
7792
7799
  function toFontString(attributes) {
7793
- var fontSize = attributes.fontSize, fontFamily = attributes.fontFamily, fontStyle = attributes.fontStyle, fontVariant = attributes.fontVariant, fontWeight = attributes.fontWeight;
7800
+ 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
7801
  // build canvas api font setting from individual components. Convert a numeric this.fontSize to px
7795
7802
  // const fontSizeString: string = isNumber(fontSize) ? `${fontSize}px` : fontSize.toString();
7796
7803
  var fontSizeString = (isNumber(fontSize) && "".concat(fontSize, "px")) || '16px';
@@ -8086,8 +8093,8 @@ var PathUpdater = /** @class */ (function () {
8086
8093
  function PathUpdater() {
8087
8094
  }
8088
8095
  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;
8096
+ var d = parsedStyle.d;
8097
+ var _a = d.rect, x = _a.x, y = _a.y, width = _a.width, height = _a.height;
8091
8098
  var hwidth = width / 2;
8092
8099
  var hheight = height / 2;
8093
8100
  return {
@@ -8136,17 +8143,17 @@ var RectUpdater = /** @class */ (function () {
8136
8143
  function RectUpdater() {
8137
8144
  }
8138
8145
  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;
8146
+ 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
8147
  var contentWidth = width;
8141
8148
  var contentHeight = height;
8142
8149
  // resize with HTMLImageElement's size
8143
- if (img && !isString(img)) {
8150
+ if (src && !isString(src)) {
8144
8151
  if (!contentWidth) {
8145
- contentWidth = img.width;
8152
+ contentWidth = src.width;
8146
8153
  parsedStyle.width = contentWidth;
8147
8154
  }
8148
8155
  if (!contentHeight) {
8149
- contentHeight = img.height;
8156
+ contentHeight = src.height;
8150
8157
  parsedStyle.height = contentHeight;
8151
8158
  }
8152
8159
  }
@@ -8166,18 +8173,20 @@ var TextUpdater = /** @class */ (function () {
8166
8173
  }
8167
8174
  TextUpdater.prototype.isReadyToMeasure = function (parsedStyle, object) {
8168
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;
8169
- return (text &&
8170
- fontSize &&
8171
- fontStyle &&
8172
- fontWeight &&
8173
- fontVariant &&
8174
- textAlign &&
8175
- textBaseline &&
8176
- !isNil(lineWidth));
8176
+ return runtime.enableCSSParsing
8177
+ ? text &&
8178
+ fontSize &&
8179
+ fontStyle &&
8180
+ fontWeight &&
8181
+ fontVariant &&
8182
+ textAlign &&
8183
+ textBaseline &&
8184
+ !isNil(lineWidth)
8185
+ : text;
8177
8186
  };
8178
8187
  TextUpdater.prototype.update = function (parsedStyle, object) {
8179
8188
  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;
8189
+ 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
8190
  if (!this.isReadyToMeasure(parsedStyle, object)) {
8182
8191
  parsedStyle.metrics = {
8183
8192
  font: '',
@@ -10041,7 +10050,7 @@ var RenderingService = /** @class */ (function () {
10041
10050
  this.zIndexCounter = 0;
10042
10051
  var renderingContext = this.context.renderingContext;
10043
10052
  this.globalRuntime.sceneGraphService.syncHierarchy(renderingContext.root);
10044
- // this.globalRuntime.sceneGraphService.triggerPendingEvents();
10053
+ this.globalRuntime.sceneGraphService.triggerPendingEvents();
10045
10054
  if (renderingContext.renderReasons.size && this.inited) {
10046
10055
  // @ts-ignore
10047
10056
  renderingContext.dirtyRectangleRenderingDisabled =
@@ -11277,13 +11286,13 @@ var TextService = /** @class */ (function () {
11277
11286
  return properties;
11278
11287
  };
11279
11288
  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;
11289
+ 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
11290
  var // dropShadow = 0,
11282
11291
  // dropShadowDistance = 0,
11283
- _a = parsedStyle.leading,
11292
+ _g = parsedStyle.leading,
11284
11293
  // dropShadow = 0,
11285
11294
  // dropShadowDistance = 0,
11286
- leading = _a === void 0 ? 0 : _a;
11295
+ leading = _g === void 0 ? 0 : _g;
11287
11296
  var font = toFontString(parsedStyle);
11288
11297
  // if (runtime.enableCSSParsing) {
11289
11298
  var fontProperties = this.measureFont(font, offscreenCanvas);
@@ -11395,7 +11404,7 @@ var TextService = /** @class */ (function () {
11395
11404
  TextService.prototype.setGraphemeOnPath = function () { };
11396
11405
  TextService.prototype.wordWrap = function (text, parsedStyle, offscreenCanvas) {
11397
11406
  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;
11407
+ 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
11408
  var context = this.runtime.offscreenCanvasCreator.getOrCreateContext(offscreenCanvas);
11400
11409
  var maxWidth = wordWrapWidth + letterSpacing;
11401
11410
  var ellipsis = '';
@@ -12215,6 +12224,9 @@ var Element = /** @class */ (function (_super) {
12215
12224
  function isDisplayObject(value) {
12216
12225
  return !!(value === null || value === void 0 ? void 0 : value.nodeName);
12217
12226
  }
12227
+ var Proxy = runtime.globalThis.Proxy
12228
+ ? runtime.globalThis.Proxy
12229
+ : function () { };
12218
12230
  var mutationEvent = new MutationEvent(ElementEvent.ATTR_MODIFIED, null, null, null, null, MutationEvent.MODIFICATION, null, null);
12219
12231
  var DEFAULT_STYLE_PROPS = {
12220
12232
  opacity: '',
@@ -12251,20 +12263,7 @@ var DEFAULT_PARSED_STYLE_PROPS = {
12251
12263
  shadowType: 'outer',
12252
12264
  miterLimit: 10,
12253
12265
  };
12254
- // const DEFAULT_PARSED_STYLE_PROPS_CSS_DISABLED = {
12255
- // ...DEFAULT_PARSED_STYLE_PROPS,
12256
- // opacity: 1,
12257
- // fillOpacity: 1,
12258
- // strokeOpacity: 1,
12259
- // visibility: 'visible',
12260
- // pointerEvents: 'auto',
12261
- // lineWidth: 1,
12262
- // lineCap: 'butt',
12263
- // lineJoin: 'miter',
12264
- // increasedLineWidthForHitTesting: 0,
12265
- // fillRule: 'nonzero',
12266
- // // TODO: transformOrigin
12267
- // };
12266
+ __assign(__assign({}, DEFAULT_PARSED_STYLE_PROPS), { opacity: 1, fillOpacity: 1, strokeOpacity: 1, visibility: 'visible', pointerEvents: 'auto', lineWidth: 1, lineCap: 'butt', lineJoin: 'miter', increasedLineWidthForHitTesting: 0, fillRule: 'nonzero' });
12268
12267
  var INHERITABLE_BASE_STYLE_PROPS = [
12269
12268
  'opacity',
12270
12269
  'fillOpacity',
@@ -12316,13 +12315,6 @@ var DisplayObject = /** @class */ (function (_super) {
12316
12315
  * push to active animations after calling `animate()`
12317
12316
  */
12318
12317
  _this.activeAnimations = [];
12319
- /**
12320
- * Use `this.style.clipPath` instead.
12321
- * @deprecated
12322
- */
12323
- _this.getClip = function () {
12324
- return this.style.clipPath || null;
12325
- };
12326
12318
  // assign name, id to config
12327
12319
  // eg. group.get('name')
12328
12320
  _this.config = config;
@@ -12337,11 +12329,13 @@ var DisplayObject = /** @class */ (function (_super) {
12337
12329
  Object.assign(_this.attributes, DEFAULT_STYLE_PROPS);
12338
12330
  Object.assign(_this.parsedStyle, DEFAULT_PARSED_STYLE_PROPS, _this.config.initialParsedStyle);
12339
12331
  }
12332
+ else if (_this.config.initialParsedStyle) {
12333
+ Object.assign(_this.parsedStyle,
12334
+ // DEFAULT_PARSED_STYLE_PROPS_CSS_DISABLED,
12335
+ _this.config.initialParsedStyle);
12336
+ }
12340
12337
  // start to process attributes
12341
12338
  _this.initAttributes(_this.config.style);
12342
- var Proxy = runtime.globalThis.Proxy
12343
- ? runtime.globalThis.Proxy
12344
- : function () { };
12345
12339
  if (runtime.enableDataset) {
12346
12340
  _this.dataset = new Proxy({}, {
12347
12341
  get: function (target, name) {
@@ -12933,13 +12927,6 @@ var DisplayObject = /** @class */ (function (_super) {
12933
12927
  DisplayObject.prototype.add = function (child, index) {
12934
12928
  return this.appendChild(child, index);
12935
12929
  };
12936
- /**
12937
- * Use `this.style.clipPath` instead.
12938
- * @deprecated
12939
- */
12940
- DisplayObject.prototype.setClip = function (clipPath) {
12941
- this.style.clipPath = clipPath;
12942
- };
12943
12930
  /**
12944
12931
  * @deprecated
12945
12932
  */
@@ -13040,11 +13027,11 @@ var Ellipse = /** @class */ (function (_super) {
13040
13027
  */
13041
13028
  var Group = /** @class */ (function (_super) {
13042
13029
  __extends(Group, _super);
13043
- function Group(_a) {
13044
- if (_a === void 0) { _a = {}; }
13045
- var style = _a.style, rest = __rest(_a, ["style"]);
13046
- return _super.call(this, __assign({ type: Shape.GROUP, style: runtime.enableCSSParsing
13047
- ? __assign({ width: '', height: '' }, style) : __assign({}, style) }, rest)) || this;
13030
+ function Group(options) {
13031
+ if (options === void 0) { options = {}; }
13032
+ var _this = _super.call(this, options) || this;
13033
+ _this.nodeName = Shape.GROUP;
13034
+ return _this;
13048
13035
  }
13049
13036
  return Group;
13050
13037
  }(DisplayObject));
@@ -13117,11 +13104,11 @@ var HTML = /** @class */ (function (_super) {
13117
13104
 
13118
13105
  var Image = /** @class */ (function (_super) {
13119
13106
  __extends(Image, _super);
13120
- function Image(_a) {
13121
- if (_a === void 0) { _a = {}; }
13122
- var style = _a.style, rest = __rest(_a, ["style"]);
13123
- return _super.call(this, __assign({ type: Shape.IMAGE, style: runtime.enableCSSParsing
13124
- ? __assign({ x: '', y: '', img: '', width: '', height: '' }, style) : __assign({}, style) }, rest)) || this;
13107
+ function Image(options) {
13108
+ if (options === void 0) { options = {}; }
13109
+ var _this = _super.call(this, options) || this;
13110
+ _this.nodeName = Shape.IMAGE;
13111
+ return _this;
13125
13112
  }
13126
13113
  return Image;
13127
13114
  }(DisplayObject));
@@ -13250,11 +13237,11 @@ var Path = /** @class */ (function (_super) {
13250
13237
  var _this = this;
13251
13238
  var style = _a.style, rest = __rest(_a, ["style"]);
13252
13239
  _this = _super.call(this, __assign({ type: Shape.PATH, style: runtime.enableCSSParsing
13253
- ? __assign({ path: '', miterLimit: '' }, style) : __assign({}, style), initialParsedStyle: runtime.enableCSSParsing
13240
+ ? __assign({ d: '', miterLimit: '' }, style) : __assign({}, style), initialParsedStyle: runtime.enableCSSParsing
13254
13241
  ? null
13255
13242
  : {
13256
13243
  miterLimit: 4,
13257
- path: __assign({}, EMPTY_PARSED_PATH),
13244
+ d: __assign({}, EMPTY_PARSED_PATH),
13258
13245
  } }, rest)) || this;
13259
13246
  _this.markerStartAngle = 0;
13260
13247
  _this.markerEndAngle = 0;
@@ -13279,7 +13266,7 @@ var Path = /** @class */ (function (_super) {
13279
13266
  return _this;
13280
13267
  }
13281
13268
  Path.prototype.attributeChangedCallback = function (attrName, oldValue, newValue, prevParsedValue, newParsedValue) {
13282
- if (attrName === 'path') {
13269
+ if (attrName === 'd') {
13283
13270
  // recalc markers
13284
13271
  this.transformMarker(true);
13285
13272
  this.transformMarker(false);
@@ -13354,7 +13341,7 @@ var Path = /** @class */ (function (_super) {
13354
13341
  marker.setLocalPosition(ox + Math.cos(rad) * offset, oy + Math.sin(rad) * offset);
13355
13342
  };
13356
13343
  Path.prototype.placeMarkerMid = function (marker) {
13357
- var segments = this.parsedStyle.path.segments;
13344
+ var segments = this.parsedStyle.d.segments;
13358
13345
  // clear all existed markers
13359
13346
  this.markerMidList.forEach(function (marker) {
13360
13347
  marker.remove();
@@ -13383,7 +13370,7 @@ var Path = /** @class */ (function (_super) {
13383
13370
  */
13384
13371
  Path.prototype.getPointAtLength = function (distance, inWorldSpace) {
13385
13372
  if (inWorldSpace === void 0) { inWorldSpace = false; }
13386
- var absolutePath = this.parsedStyle.path.absolutePath;
13373
+ var absolutePath = this.parsedStyle.d.absolutePath;
13387
13374
  var _a = getPointAtLength(absolutePath, distance), x = _a.x, y = _a.y;
13388
13375
  var transformed = vec3.transformMat4(vec3.create(), vec3.fromValues(x, y, 0), inWorldSpace ? this.getWorldTransform() : this.getLocalTransform());
13389
13376
  // apply local transformation
@@ -13400,7 +13387,7 @@ var Path = /** @class */ (function (_super) {
13400
13387
  * Get start tangent vector
13401
13388
  */
13402
13389
  Path.prototype.getStartTangent = function () {
13403
- var segments = this.parsedStyle.path.segments;
13390
+ var segments = this.parsedStyle.d.segments;
13404
13391
  var result = [];
13405
13392
  if (segments.length > 1) {
13406
13393
  var startPoint = segments[0].currentPoint;
@@ -13422,7 +13409,7 @@ var Path = /** @class */ (function (_super) {
13422
13409
  * Get end tangent vector
13423
13410
  */
13424
13411
  Path.prototype.getEndTangent = function () {
13425
- var segments = this.parsedStyle.path.segments;
13412
+ var segments = this.parsedStyle.d.segments;
13426
13413
  var length = segments.length;
13427
13414
  var result = [];
13428
13415
  if (length > 1) {
@@ -13652,11 +13639,11 @@ var Polyline = /** @class */ (function (_super) {
13652
13639
 
13653
13640
  var Rect = /** @class */ (function (_super) {
13654
13641
  __extends(Rect, _super);
13655
- function Rect(_a) {
13656
- if (_a === void 0) { _a = {}; }
13657
- var style = _a.style, rest = __rest(_a, ["style"]);
13658
- return _super.call(this, __assign({ type: Shape.RECT, style: runtime.enableCSSParsing
13659
- ? __assign({ x: '', y: '', width: '', height: '', radius: '' }, style) : __assign({}, style) }, rest)) || this;
13642
+ function Rect(options) {
13643
+ if (options === void 0) { options = {}; }
13644
+ var _this = _super.call(this, options) || this;
13645
+ _this.nodeName = Shape.RECT;
13646
+ return _this;
13660
13647
  }
13661
13648
  return Rect;
13662
13649
  }(DisplayObject));
@@ -13678,26 +13665,7 @@ var Text = /** @class */ (function (_super) {
13678
13665
  return _super.call(this, __assign({ type: Shape.TEXT, style: runtime.enableCSSParsing
13679
13666
  ? __assign({ x: '', y: '', text: '', fontSize: '', fontFamily: '', fontStyle: '', fontWeight: '', fontVariant: '', textAlign: '', textBaseline: '', textTransform: '', fill: 'black', letterSpacing: '', lineHeight: '', miterLimit: '',
13680
13667
  // whiteSpace: 'pre',
13681
- wordWrap: false, wordWrapWidth: 0, leading: 0, dx: '', dy: '' }, style) : __assign({ fill: 'black' }, style), initialParsedStyle: runtime.enableCSSParsing
13682
- ? {}
13683
- : {
13684
- x: 0,
13685
- y: 0,
13686
- fontSize: 16,
13687
- fontFamily: 'sans-serif',
13688
- fontStyle: 'normal',
13689
- fontWeight: 'normal',
13690
- fontVariant: 'normal',
13691
- lineHeight: 0,
13692
- letterSpacing: 0,
13693
- textBaseline: 'alphabetic',
13694
- textAlign: 'start',
13695
- wordWrap: false,
13696
- wordWrapWidth: 0,
13697
- leading: 0,
13698
- dx: 0,
13699
- dy: 0,
13700
- } }, rest)) || this;
13668
+ wordWrap: false, wordWrapWidth: 0, leading: 0, dx: '', dy: '' }, style) : __assign({ fill: 'black' }, style) }, rest)) || this;
13701
13669
  }
13702
13670
  // lengthAdjust: SVGAnimatedEnumeration;
13703
13671
  // textLength: SVGAnimatedLength;
@@ -14717,7 +14685,7 @@ var PrepareRendererPlugin = /** @class */ (function () {
14717
14685
  * sync to RBush later
14718
14686
  */
14719
14687
  this.toSync = new Set();
14720
- // private isFirstTimeRendering = true;
14688
+ this.isFirstTimeRendering = true;
14721
14689
  this.syncing = false;
14722
14690
  }
14723
14691
  PrepareRendererPlugin.prototype.apply = function (context) {
@@ -14781,14 +14749,22 @@ var PrepareRendererPlugin = /** @class */ (function () {
14781
14749
  _this.toSync.clear();
14782
14750
  });
14783
14751
  renderingService.hooks.endFrame.tap(PrepareRendererPlugin.tag, function () {
14784
- requestIdleCallback(function () {
14752
+ if (_this.isFirstTimeRendering) {
14753
+ _this.isFirstTimeRendering = false;
14754
+ _this.syncing = true;
14755
+ requestIdleCallback(function () {
14756
+ _this.syncRTree(true);
14757
+ });
14758
+ }
14759
+ else {
14785
14760
  _this.syncRTree();
14786
- });
14761
+ }
14787
14762
  });
14788
14763
  };
14789
- PrepareRendererPlugin.prototype.syncRTree = function () {
14764
+ PrepareRendererPlugin.prototype.syncRTree = function (force) {
14790
14765
  var _this = this;
14791
- if (this.syncing || this.toSync.size === 0) {
14766
+ if (force === void 0) { force = false; }
14767
+ if (!force && (this.syncing || this.toSync.size === 0)) {
14792
14768
  return;
14793
14769
  }
14794
14770
  this.syncing = true;
@@ -14829,7 +14805,6 @@ var PrepareRendererPlugin = /** @class */ (function () {
14829
14805
  // use bulk inserting, which is ~2-3 times faster
14830
14806
  // @see https://github.com/mourner/rbush#bulk-inserting-data
14831
14807
  this.rBush.load(bulk);
14832
- console.log('sync...', Array.from(this.toSync));
14833
14808
  bulk.length = 0;
14834
14809
  this.toSync.clear();
14835
14810
  this.syncing = false;