@antv/g 5.0.14 → 5.0.15

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 (70) hide show
  1. package/dist/index.umd.min.js +2 -2
  2. package/es/Canvas.js +1 -0
  3. package/es/canvas-module.js +7 -15
  4. package/es/display-objects/Circle.d.ts +3 -1
  5. package/es/display-objects/DisplayObject.js +6 -2
  6. package/es/display-objects/Ellipse.d.ts +5 -2
  7. package/es/display-objects/Group.js +4 -1
  8. package/es/display-objects/HTML.d.ts +5 -0
  9. package/es/display-objects/HTML.js +1 -1
  10. package/es/display-objects/Image.d.ts +7 -4
  11. package/es/display-objects/Image.js +3 -1
  12. package/es/display-objects/Rect.d.ts +7 -4
  13. package/es/display-objects/Rect.js +2 -2
  14. package/es/display-objects/Text.js +1 -1
  15. package/es/dom/Element.d.ts +4 -4
  16. package/es/global-module.d.ts +3 -1
  17. package/es/global-module.js +28 -69
  18. package/es/property-handlers/aabb.js +3 -4
  19. package/es/property-handlers/anchor.js +2 -1
  20. package/es/property-handlers/dimension.d.ts +2 -1
  21. package/es/property-handlers/dimension.js +30 -2
  22. package/es/property-handlers/path.d.ts +1 -1
  23. package/es/services/SceneGraphService.d.ts +7 -7
  24. package/es/services/SceneGraphService.js +5 -5
  25. package/es/services/aabb/CircleUpdater.d.ts +2 -2
  26. package/es/services/aabb/CircleUpdater.js +19 -9
  27. package/es/services/aabb/EllipseUpdater.d.ts +2 -2
  28. package/es/services/aabb/EllipseUpdater.js +26 -11
  29. package/es/services/aabb/RectUpdater.d.ts +2 -2
  30. package/es/services/aabb/RectUpdater.js +27 -14
  31. package/es/shapes/AABB.d.ts +1 -0
  32. package/es/shapes/AABB.js +8 -0
  33. package/es/types.d.ts +0 -2
  34. package/es/utils/path.d.ts +1 -1
  35. package/es/utils/path.js +5 -5
  36. package/lib/Canvas.js +1 -0
  37. package/lib/canvas-module.js +9 -16
  38. package/lib/display-objects/Circle.d.ts +3 -1
  39. package/lib/display-objects/DisplayObject.js +6 -2
  40. package/lib/display-objects/Ellipse.d.ts +5 -2
  41. package/lib/display-objects/Group.js +4 -1
  42. package/lib/display-objects/HTML.d.ts +5 -0
  43. package/lib/display-objects/HTML.js +1 -1
  44. package/lib/display-objects/Image.d.ts +7 -4
  45. package/lib/display-objects/Image.js +3 -1
  46. package/lib/display-objects/Rect.d.ts +7 -4
  47. package/lib/display-objects/Rect.js +2 -2
  48. package/lib/display-objects/Text.js +1 -1
  49. package/lib/dom/Element.d.ts +4 -4
  50. package/lib/global-module.d.ts +3 -1
  51. package/lib/global-module.js +32 -69
  52. package/lib/property-handlers/aabb.js +3 -4
  53. package/lib/property-handlers/anchor.js +3 -1
  54. package/lib/property-handlers/dimension.d.ts +2 -1
  55. package/lib/property-handlers/dimension.js +33 -2
  56. package/lib/property-handlers/path.d.ts +1 -1
  57. package/lib/services/SceneGraphService.d.ts +7 -7
  58. package/lib/services/SceneGraphService.js +5 -5
  59. package/lib/services/aabb/CircleUpdater.d.ts +2 -2
  60. package/lib/services/aabb/CircleUpdater.js +19 -9
  61. package/lib/services/aabb/EllipseUpdater.d.ts +2 -2
  62. package/lib/services/aabb/EllipseUpdater.js +26 -11
  63. package/lib/services/aabb/RectUpdater.d.ts +2 -2
  64. package/lib/services/aabb/RectUpdater.js +27 -14
  65. package/lib/shapes/AABB.d.ts +1 -0
  66. package/lib/shapes/AABB.js +8 -0
  67. package/lib/types.d.ts +0 -2
  68. package/lib/utils/path.d.ts +1 -1
  69. package/lib/utils/path.js +5 -5
  70. package/package.json +4 -4
package/es/Canvas.js CHANGED
@@ -367,6 +367,7 @@ function (_super) {
367
367
  };
368
368
 
369
369
  Canvas.prototype.loadCommonContainerModule = function () {
370
+ this.container.unload(commonContainerModule);
370
371
  this.container.load(commonContainerModule, true);
371
372
  };
372
373
 
@@ -6,22 +6,14 @@ import { FrustumCullingStrategy } from './plugins/FrustumCullingStrategy';
6
6
  import { RenderingPluginContribution, RenderingService } from './services';
7
7
  import { EventPlugin } from './plugins/EventPlugin';
8
8
  import { EventService } from './services';
9
- export var containerModule = Module(function (register, context) {
10
- if (context.container.isBound(RenderingService)) {
11
- // remove rendering plugins
12
- context.container.remove(RenderingPluginContribution);
13
- context.container.remove(RenderingService);
14
- context.container.remove(FrustumCullingStrategy);
15
- } else {
16
- Contribution.register(register, RenderingPluginContribution, {
17
- cache: false
18
- }); // culling plugin
19
-
20
- Contribution.register(register, CullingStrategyContribution, {
21
- cache: false
22
- });
23
- } // register built-in rendering plugins
9
+ export var containerModule = Module(function (register) {
10
+ Contribution.register(register, RenderingPluginContribution, {
11
+ cache: false
12
+ }); // culling plugin
24
13
 
14
+ Contribution.register(register, CullingStrategyContribution, {
15
+ cache: false
16
+ }); // register built-in rendering plugins
25
17
 
26
18
  register(RenderingService);
27
19
  register(EventService);
@@ -1,11 +1,13 @@
1
1
  import type { DisplayObjectConfig } from '../dom/interfaces';
2
2
  import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
3
3
  import { DisplayObject } from './DisplayObject';
4
+ import type { ParsedElement } from '../property-handlers';
4
5
  export interface CircleStyleProps extends BaseStyleProps {
5
6
  r: number;
6
7
  }
7
8
  export interface ParsedCircleStyleProps extends ParsedBaseStyleProps {
8
- r: number;
9
+ r: ParsedElement;
10
+ rInPixels: number;
9
11
  }
10
12
  export declare class Circle extends DisplayObject<CircleStyleProps, ParsedCircleStyleProps> {
11
13
  constructor({ style, ...rest }: DisplayObjectConfig<CircleStyleProps>);
@@ -228,7 +228,9 @@ function (_super) {
228
228
 
229
229
  this.parseStyleProperty(name, value); // @ts-ignore
230
230
 
231
- this.updateStyleProperty(name, oldParsedValue, this.parsedStyle[name]); // inform clip path targets
231
+ var newParsedValue = this.parsedStyle[name]; // @ts-ignore
232
+
233
+ this.updateStyleProperty(name, oldParsedValue, newParsedValue); // inform clip path targets
232
234
 
233
235
  if (this.attributes.clipPathTargets && this.attributes.clipPathTargets.length) {
234
236
  this.attributes.clipPathTargets.forEach(function (target) {
@@ -246,7 +248,9 @@ function (_super) {
246
248
  this.emit(ElementEvent.ATTRIBUTE_CHANGED, {
247
249
  attributeName: name,
248
250
  oldValue: oldValue,
249
- newValue: value
251
+ newValue: value,
252
+ oldParsedValue: oldParsedValue,
253
+ newParsedValue: newParsedValue
250
254
  });
251
255
  }; // #region transformable
252
256
 
@@ -1,13 +1,16 @@
1
1
  import type { DisplayObjectConfig } from '../dom/interfaces';
2
2
  import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
3
3
  import { DisplayObject } from './DisplayObject';
4
+ import type { ParsedElement } from '../property-handlers';
4
5
  export interface EllipseStyleProps extends BaseStyleProps {
5
6
  rx: number;
6
7
  ry: number;
7
8
  }
8
9
  export interface ParsedEllipseStyleProps extends ParsedBaseStyleProps {
9
- rx: number;
10
- ry: number;
10
+ rx: ParsedElement;
11
+ ry: ParsedElement;
12
+ rxInPixels: number;
13
+ ryInPixels: number;
11
14
  }
12
15
  export declare class Ellipse extends DisplayObject<EllipseStyleProps, ParsedEllipseStyleProps> {
13
16
  constructor({ style, ...rest }: DisplayObjectConfig<EllipseStyleProps>);
@@ -16,7 +16,10 @@ function (_super) {
16
16
 
17
17
  _this = _super.call(this, __assign({
18
18
  type: SHAPE.Group,
19
- style: __assign({}, style)
19
+ style: __assign({
20
+ width: 'auto',
21
+ height: 'auto'
22
+ }, style)
20
23
  }, rest)) || this;
21
24
  return _this;
22
25
  }
@@ -2,14 +2,19 @@ import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
2
2
  import { DisplayObject } from './DisplayObject';
3
3
  import type { DisplayObjectConfig } from '../dom';
4
4
  import { AABB } from '../shapes';
5
+ import type { ParsedElement } from '../property-handlers';
5
6
  export interface HTMLStyleProps extends BaseStyleProps {
6
7
  innerHTML: string | HTMLElement;
8
+ width: number;
9
+ height: number;
7
10
  className?: string | string[];
8
11
  style?: string;
9
12
  }
10
13
  export interface ParsedHTMLStyleProps extends ParsedBaseStyleProps {
11
14
  $el: HTMLElement;
12
15
  innerHTML: string | HTMLElement;
16
+ width: ParsedElement;
17
+ height: ParsedElement;
13
18
  className?: string | string[];
14
19
  style?: string;
15
20
  }
@@ -77,7 +77,7 @@ function (_super) {
77
77
  var parentInvert = mat4.invert(mat4.create(), this.parentNode.getWorldTransform());
78
78
  var bounds = this.getBounds();
79
79
 
80
- if (bounds) {
80
+ if (!AABB.isEmpty(bounds)) {
81
81
  var localBounds = new AABB();
82
82
  localBounds.setFromTransformedAABB(bounds, parentInvert);
83
83
  return localBounds;
@@ -1,15 +1,18 @@
1
1
  import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
2
2
  import { DisplayObject } from './DisplayObject';
3
3
  import type { DisplayObjectConfig } from '../dom';
4
+ import type { ParsedElement } from '../property-handlers';
4
5
  export interface ImageStyleProps extends BaseStyleProps {
5
6
  img: string | HTMLImageElement;
6
- width?: number;
7
- height?: number;
7
+ width?: number | string;
8
+ height?: number | string;
8
9
  }
9
10
  export interface ParsedImageStyleProps extends ParsedBaseStyleProps {
10
11
  img: string | HTMLImageElement;
11
- width?: number;
12
- height?: number;
12
+ width?: ParsedElement;
13
+ height?: ParsedElement;
14
+ widthInPixels?: number;
15
+ heightInPixels?: number;
13
16
  }
14
17
  export declare class Image extends DisplayObject<ImageStyleProps, ParsedImageStyleProps> {
15
18
  constructor({ style, ...rest }: DisplayObjectConfig<ImageStyleProps>);
@@ -14,7 +14,9 @@ function (_super) {
14
14
  return _super.call(this, __assign({
15
15
  type: SHAPE.Image,
16
16
  style: __assign({
17
- img: ''
17
+ img: '',
18
+ width: 'auto',
19
+ height: 'auto'
18
20
  }, style)
19
21
  }, rest)) || this;
20
22
  }
@@ -1,14 +1,17 @@
1
1
  import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
2
2
  import { DisplayObject } from './DisplayObject';
3
3
  import type { DisplayObjectConfig } from '../dom';
4
+ import type { ParsedElement } from '../property-handlers';
4
5
  export interface RectStyleProps extends BaseStyleProps {
5
- width: number;
6
- height: number;
6
+ width: number | string;
7
+ height: number | string;
7
8
  radius?: number;
8
9
  }
9
10
  export interface ParsedRectStyleProps extends ParsedBaseStyleProps {
10
- width: number;
11
- height: number;
11
+ width: ParsedElement;
12
+ height: ParsedElement;
13
+ widthInPixels: number;
14
+ heightInPixels: number;
12
15
  radius?: number;
13
16
  }
14
17
  export declare class Rect extends DisplayObject<RectStyleProps, ParsedRectStyleProps> {
@@ -14,8 +14,8 @@ function (_super) {
14
14
  return _super.call(this, __assign({
15
15
  type: SHAPE.Rect,
16
16
  style: __assign({
17
- width: 0,
18
- height: 0
17
+ width: 'auto',
18
+ height: 'auto'
19
19
  }, style)
20
20
  }, rest)) || this;
21
21
  }
@@ -39,7 +39,7 @@ function (_super) {
39
39
  stroke: '#000',
40
40
  whiteSpace: 'pre',
41
41
  wordWrap: false,
42
- wordWrapWidth: 100,
42
+ wordWrapWidth: 0,
43
43
  leading: 0
44
44
  }, style)
45
45
  }, rest)) || this;
@@ -103,16 +103,16 @@ export declare class Element<StyleProps extends BaseStyleProps = any, ParsedStyl
103
103
  */
104
104
  destroyed: boolean;
105
105
  destroy(): void;
106
- getGeometryBounds(): AABB | null;
107
- getRenderBounds(): AABB | null;
106
+ getGeometryBounds(): AABB;
107
+ getRenderBounds(): AABB;
108
108
  /**
109
109
  * get bounds in world space, account for children
110
110
  */
111
- getBounds(): AABB | null;
111
+ getBounds(): AABB;
112
112
  /**
113
113
  * get bounds in local space, account for children
114
114
  */
115
- getLocalBounds(): AABB | null;
115
+ getLocalBounds(): AABB;
116
116
  /**
117
117
  * account for context's bounds in client space,
118
118
  * but not accounting for children
@@ -1,6 +1,8 @@
1
- import type { StylePropertyParser, StylePropertyMerger, StylePropertyUpdater } from './property-handlers';
1
+ import type { Interpolatable, StylePropertyParser, StylePropertyMerger, StylePropertyUpdater } from './property-handlers';
2
2
  export declare const globalContainer: import("mana-syringe").Container;
3
3
  export declare const stylePropertyParserFactory: Record<string, StylePropertyParser<any, any>>;
4
4
  export declare const stylePropertyUpdaterFactory: Record<string, StylePropertyUpdater<any>[]>;
5
5
  export declare const stylePropertyMergerFactory: Record<string, StylePropertyMerger<any, any>>;
6
+ export declare function addPropertyHandler<O, P, I extends Interpolatable = number>(property: string, parser: StylePropertyParser<O, P> | undefined, merger: StylePropertyMerger<P, I> | undefined, updater: StylePropertyUpdater<O> | undefined): void;
7
+ export declare function addPropertiesHandler<O, P, I extends Interpolatable = number>(properties: string[], parser: StylePropertyParser<O, P> | undefined, merger: StylePropertyMerger<P, I> | undefined, updater: StylePropertyUpdater<O> | undefined): void;
6
8
  export declare const containerModule: import("mana-syringe").SyringeModule;
@@ -7,6 +7,7 @@ import { TextService } from './services/text';
7
7
  import { TextUpdater } from './services/aabb/TextUpdater';
8
8
  import { OffscreenCanvasCreator } from './services/text/OffscreenCanvasCreator';
9
9
  import { DefaultSceneGraphSelector, SceneGraphSelector, SceneGraphSelectorFactory } from './services/SceneGraphSelector';
10
+ import { parseLengthOrPercent, mergeDimensions } from './property-handlers';
10
11
  import { // StylePropertyParserFactory,
11
12
  // StylePropertyUpdaterFactory,
12
13
  // StylePropertyMergerFactory,
@@ -15,6 +16,28 @@ export var globalContainer = GlobalContainer;
15
16
  export var stylePropertyParserFactory = {};
16
17
  export var stylePropertyUpdaterFactory = {};
17
18
  export var stylePropertyMergerFactory = {};
19
+ export function addPropertyHandler(property, parser, merger, updater) {
20
+ if (parser) {
21
+ stylePropertyParserFactory[property] = parser; // register({ token: { token: StylePropertyParser, named: property }, useValue: parser });
22
+ }
23
+
24
+ if (merger) {
25
+ stylePropertyMergerFactory[property] = merger; // register({ token: { token: StylePropertyMerger, named: property }, useValue: merger });
26
+ }
27
+
28
+ if (updater) {
29
+ if (!stylePropertyUpdaterFactory[property]) {
30
+ stylePropertyUpdaterFactory[property] = [];
31
+ }
32
+
33
+ stylePropertyUpdaterFactory[property].push(updater); // register({ token: { token: StylePropertyUpdater, named: property }, useValue: updater });
34
+ }
35
+ }
36
+ export function addPropertiesHandler(properties, parser, merger, updater) {
37
+ for (var i = 0; i < properties.length; i++) {
38
+ addPropertyHandler(properties[i], parser, merger, updater);
39
+ }
40
+ }
18
41
  export var containerModule = Module(function (register) {
19
42
  decorate(injectable(), EventEmitter); // bind DisplayObject pool
20
43
 
@@ -62,77 +85,13 @@ export var containerModule = Module(function (register) {
62
85
  return cache[tagName];
63
86
  };
64
87
  }
65
- }); // // bind style property handlers
66
- // register({
67
- // token: StylePropertyParserFactory,
68
- // useFactory: (context) => {
69
- // const cache = {};
70
- // return (propertyName: string) => {
71
- // if (!cache[propertyName]) {
72
- // if (context.container.isBoundNamed(StylePropertyParser, propertyName)) {
73
- // cache[propertyName] = context.container.getNamed(StylePropertyParser, propertyName);
74
- // }
75
- // }
76
- // return cache[propertyName];
77
- // };
78
- // },
79
- // });
80
- // register({
81
- // token: StylePropertyUpdaterFactory,
82
- // useFactory: (context) => {
83
- // const cache = {};
84
- // return (propertyName: string) => {
85
- // if (!cache[propertyName]) {
86
- // if (context.container.isBoundNamed(StylePropertyUpdater, propertyName)) {
87
- // cache[propertyName] = context.container.getAllNamed(StylePropertyUpdater, propertyName);
88
- // }
89
- // }
90
- // return cache[propertyName];
91
- // };
92
- // },
93
- // });
94
- // register({
95
- // token: StylePropertyMergerFactory,
96
- // useFactory: (context) => {
97
- // const cache = {};
98
- // return (propertyName: string) => {
99
- // if (!cache[propertyName]) {
100
- // if (context.container.isBoundNamed(StylePropertyMerger, propertyName)) {
101
- // cache[propertyName] = context.container.getNamed(StylePropertyMerger, propertyName);
102
- // }
103
- // }
104
- // return cache[propertyName];
105
- // };
106
- // },
107
- // });
108
-
109
- function addPropertyHandler(property, parser, merger, updater) {
110
- if (parser) {
111
- stylePropertyParserFactory[property] = parser; // register({ token: { token: StylePropertyParser, named: property }, useValue: parser });
112
- }
113
-
114
- if (merger) {
115
- stylePropertyMergerFactory[property] = merger; // register({ token: { token: StylePropertyMerger, named: property }, useValue: merger });
116
- }
117
-
118
- if (updater) {
119
- if (!stylePropertyUpdaterFactory[property]) {
120
- stylePropertyUpdaterFactory[property] = [];
121
- }
122
-
123
- stylePropertyUpdaterFactory[property].push(updater); // register({ token: { token: StylePropertyUpdater, named: property }, useValue: updater });
124
- }
125
- }
126
-
127
- function addPropertiesHandler(properties, parser, merger, updater) {
128
- for (var i = 0; i < properties.length; i++) {
129
- addPropertyHandler(properties[i], parser, merger, updater);
130
- }
131
- } // bind handlers for properties
132
-
88
+ }); // bind handlers for properties
133
89
 
134
90
  addPropertiesHandler(['opacity', 'fillOpacity', 'strokeOpacity', 'offsetDistance'], parseNumber, clampedMergeNumbers(0, 1), undefined);
135
- addPropertiesHandler(['r', 'rx', 'ry', 'lineWidth', 'width', 'height', 'shadowBlur'], parseNumber, clampedMergeNumbers(0, Infinity), undefined);
91
+ addPropertiesHandler(['lineWidth', 'shadowBlur'], parseNumber, clampedMergeNumbers(0, Infinity), undefined); // support percent
92
+
93
+ addPropertiesHandler(['r', 'rx', 'ry', 'width', 'height'], parseLengthOrPercent, // @ts-ignore
94
+ mergeDimensions, undefined);
136
95
  addPropertiesHandler(['lineDash'], parseLineDash, // @ts-ignore
137
96
  mergeNumberLists, undefined);
138
97
  addPropertiesHandler(['x1', 'x2', 'y1', 'y2', 'lineDashOffset', 'shadowOffsetX', 'shadowOffsetY'], parseNumber, mergeNumbers, undefined);
@@ -35,11 +35,10 @@ export function updateGeometry(oldValue, newValue, object) {
35
35
  _g = _a.offsetY,
36
36
  offsetY = _g === void 0 ? 0 : _g,
37
37
  _h = _a.offsetZ,
38
- offsetZ = _h === void 0 ? 0 : _h;
38
+ offsetZ = _h === void 0 ? 0 : _h; // object.parsedStyle.width = width;
39
+ // object.parsedStyle.height = height;
40
+ // object.parsedStyle.depth = depth;
39
41
 
40
- object.parsedStyle.width = width;
41
- object.parsedStyle.height = height;
42
- object.parsedStyle.depth = depth;
43
42
 
44
43
  if (object.nodeName === SHAPE.Line || object.nodeName === SHAPE.Polyline || object.nodeName === SHAPE.Polygon || object.nodeName === SHAPE.Path) {
45
44
  object.parsedStyle.offsetX = x - (object.parsedStyle.defX || 0);
@@ -1,11 +1,12 @@
1
1
  import { __read, __spreadArray } from "tslib";
2
2
  import { vec3 } from 'gl-matrix';
3
3
  import { dirtifyToRoot } from '../services';
4
+ import { AABB } from '../shapes';
4
5
  import { createVec3 } from '../utils';
5
6
  export function updateAnchor(oldValue, newValue, object) {
6
7
  var bounds = object.getGeometryBounds();
7
8
 
8
- if (bounds) {
9
+ if (!AABB.isEmpty(bounds)) {
9
10
  var geometry = object.geometry;
10
11
 
11
12
  if (geometry && geometry.contentBounds) {
@@ -1,7 +1,7 @@
1
1
  import type { DisplayObject } from '../display-objects/DisplayObject';
2
2
  export declare type LengthUnit = 'px' | '%';
3
3
  export declare type AngleUnit = 'deg' | 'rad' | 'turn';
4
- export declare type Unit = LengthUnit | AngleUnit | '';
4
+ export declare type Unit = LengthUnit | AngleUnit | '' | 'auto';
5
5
  export interface ParsedElement {
6
6
  unit: Unit;
7
7
  value: number;
@@ -14,5 +14,6 @@ export declare function mergeDimensions(left: ParsedElement, right: ParsedElemen
14
14
  export declare const parseLength: any;
15
15
  export declare const parseLengthOrPercent: any;
16
16
  export declare const parseAngle: any;
17
+ export declare function parseLengthOrPercentList(list: (string | number)[]): ParsedElement[];
17
18
  export declare function convertPercentUnit(valueWithUnit: ParsedElement, vec3Index: number, target: DisplayObject | null): number;
18
19
  export declare function convertAngleUnit(valueWithUnit: ParsedElement): number;
@@ -1,6 +1,7 @@
1
1
  import { numberToString } from './numeric';
2
2
  import { rad2deg } from '../utils/math';
3
3
  import { isFinite } from '@antv/util';
4
+ import { AABB } from '../shapes';
4
5
 
5
6
  function isLengthUnit(unit) {
6
7
  return unit === 'px' || unit === '%';
@@ -11,7 +12,7 @@ function isAngleUnit(unit) {
11
12
  }
12
13
 
13
14
  export function parseDimension(unitRegExp, string) {
14
- string = string.trim().toLowerCase();
15
+ string = ("" + string).trim().toLowerCase();
15
16
 
16
17
  if (string === '0') {
17
18
  if ('px'.search(unitRegExp) >= 0) {
@@ -27,6 +28,11 @@ export function parseDimension(unitRegExp, string) {
27
28
  value: 0
28
29
  };
29
30
  }
31
+ } else if (string === 'auto') {
32
+ return {
33
+ unit: 'auto',
34
+ value: 0
35
+ };
30
36
  }
31
37
 
32
38
  if (isFinite(Number(string))) {
@@ -91,6 +97,28 @@ var lengthUnits = 'px';
91
97
  export var parseLength = parseDimension.bind(null, new RegExp(lengthUnits, 'g'));
92
98
  export var parseLengthOrPercent = parseDimension.bind(null, new RegExp(lengthUnits + '|%', 'g'));
93
99
  export var parseAngle = parseDimension.bind(null, /deg|rad|grad|turn/g);
100
+ export function parseLengthOrPercentList(list) {
101
+ return list.map(parseLengthOrPercent);
102
+ } // export function mergeDimensionsLists(
103
+ // left: ParsedElement[],
104
+ // right: ParsedElement[],
105
+ // target: DisplayObject | null,
106
+ // ): [ParsedElement[], ParsedElement[], (list: ParsedElement[]) => string] | undefined {
107
+ // if (left.length != right.length) {
108
+ // return;
109
+ // }
110
+ // return [
111
+ // leftValue,
112
+ // rightValue,
113
+ // (value: number) => {
114
+ // if (nonNegative) {
115
+ // value = Math.max(value, 0);
116
+ // }
117
+ // return numberToString(value) + unit;
118
+ // },
119
+ // ];
120
+ // }
121
+
94
122
  export function convertPercentUnit(valueWithUnit, vec3Index, target) {
95
123
  if (valueWithUnit.unit === 'px') {
96
124
  return Number(valueWithUnit.value);
@@ -99,7 +127,7 @@ export function convertPercentUnit(valueWithUnit, vec3Index, target) {
99
127
  var bounds = target.getBounds();
100
128
  var size = 0;
101
129
 
102
- if (bounds) {
130
+ if (!AABB.isEmpty(bounds)) {
103
131
  size = bounds.halfExtents[vec3Index] * 2;
104
132
  }
105
133
 
@@ -1,4 +1,4 @@
1
1
  import type { PathCommand } from '../types';
2
2
  import type { ParsedPathStyleProps } from '../display-objects';
3
3
  export declare function parsePath(path: string): ParsedPathStyleProps;
4
- export declare function mergePaths(left: ParsedPathStyleProps, right: ParsedPathStyleProps): ((string[] | ["a" | "A", number, number, number, number, number, number, number] | ["C" | "c", number, number, number, number, number, number] | ["o" | "O", number, number] | ["h" | "H", number] | ["l" | "L", number, number] | ["M" | "m", number, number] | ["r" | "R", number, number, number, number] | ["q" | "Q", number, number, number, number] | ["s" | "S", number, number, number, number, number, number, number] | ["t" | "T", number, number] | ["v" | "V", number] | ["u" | "U", number, number, number])[] | ((pathArray: PathCommand[]) => PathCommand[]))[];
4
+ export declare function mergePaths(left: ParsedPathStyleProps, right: ParsedPathStyleProps): ((string[] | ["a" | "A", number, number, number, number, number, number, number] | ["C" | "c", number, number, number, number, number, number] | ["o" | "O", number, number] | ["h" | "H", number] | ["l" | "L", number, number] | ["m" | "M", number, number] | ["r" | "R", number, number, number, number] | ["q" | "Q", number, number, number, number] | ["s" | "S", number, number, number, number, number, number, number] | ["t" | "T", number, number] | ["v" | "V", number] | ["u" | "U", number, number, number])[] | ((pathArray: PathCommand[]) => PathCommand[]))[];
@@ -35,9 +35,9 @@ export interface SceneGraphService {
35
35
  getWorldTransform: (element: INode, transform?: Transform) => mat4;
36
36
  getLocalTransform: (element: INode, transform?: Transform) => mat4;
37
37
  resetLocalTransform: (element: INode) => void;
38
- getBounds: (element: INode, render?: boolean) => AABB | null;
39
- getLocalBounds: (element: INode, render?: boolean) => AABB | null;
40
- getGeometryBounds: (element: INode, render?: boolean) => AABB | null;
38
+ getBounds: (element: INode, render?: boolean) => AABB;
39
+ getLocalBounds: (element: INode, render?: boolean) => AABB;
40
+ getGeometryBounds: (element: INode, render?: boolean) => AABB;
41
41
  getBoundingClientRect: (element: INode) => Rectangle;
42
42
  syncHierarchy: (element: INode) => void;
43
43
  }
@@ -130,19 +130,19 @@ export declare class DefaultSceneGraphService implements SceneGraphService {
130
130
  getLocalScale(element: INode): vec3;
131
131
  getLocalTransform(element: INode): mat4;
132
132
  resetLocalTransform(element: INode): void;
133
- getTransformedGeometryBounds(element: INode, render?: boolean): AABB | null;
133
+ private getTransformedGeometryBounds;
134
134
  /**
135
135
  * won't account for children
136
136
  */
137
- getGeometryBounds(element: INode, render?: boolean): AABB | null;
137
+ getGeometryBounds(element: INode, render?: boolean): AABB;
138
138
  /**
139
139
  * account for children in world space
140
140
  */
141
- getBounds(element: INode, render?: boolean): AABB | null;
141
+ getBounds(element: INode, render?: boolean): AABB;
142
142
  /**
143
143
  * account for children in local space
144
144
  */
145
- getLocalBounds(element: INode): AABB | null;
145
+ getLocalBounds(element: INode): AABB;
146
146
  getBoundingClientRect(element: INode): Rectangle;
147
147
  private dirtifyWorldInternal;
148
148
  syncHierarchy(element: INode): void;
@@ -613,7 +613,7 @@ function () {
613
613
 
614
614
  var bounds = this.getGeometryBounds(element, render);
615
615
 
616
- if (bounds) {
616
+ if (!AABB.isEmpty(bounds)) {
617
617
  var aabb = new AABB();
618
618
  aabb.setFromTransformedAABB(bounds, this.getWorldTransform(element));
619
619
  return aabb;
@@ -633,7 +633,7 @@ function () {
633
633
 
634
634
  var geometry = element.geometry;
635
635
  var bounds = render ? geometry.renderBounds : geometry.contentBounds || null;
636
- return bounds && new AABB(bounds.center, bounds.halfExtents) || null;
636
+ return bounds && new AABB(bounds.center, bounds.halfExtents) || new AABB();
637
637
  };
638
638
  /**
639
639
  * account for children in world space
@@ -707,7 +707,7 @@ function () {
707
707
  renderable.boundsDirty = false;
708
708
  }
709
709
 
710
- return aabb || null;
710
+ return aabb || new AABB();
711
711
  };
712
712
  /**
713
713
  * account for children in local space
@@ -724,7 +724,7 @@ function () {
724
724
 
725
725
  var bounds = this.getBounds(element);
726
726
 
727
- if (bounds) {
727
+ if (!AABB.isEmpty(bounds)) {
728
728
  var localBounds = new AABB();
729
729
  localBounds.setFromTransformedAABB(bounds, parentInvert);
730
730
  return localBounds;
@@ -740,7 +740,7 @@ function () {
740
740
  var aabb;
741
741
  var bounds = this.getGeometryBounds(element);
742
742
 
743
- if (bounds) {
743
+ if (!AABB.isEmpty(bounds)) {
744
744
  aabb = new AABB(); // apply transformation to aabb
745
745
 
746
746
  aabb.setFromTransformedAABB(bounds, this.getWorldTransform(element));
@@ -1,7 +1,7 @@
1
1
  import { GeometryAABBUpdater } from './interfaces';
2
- import type { ParsedCircleStyleProps } from '../../display-objects/Circle';
2
+ import type { Circle, ParsedCircleStyleProps } from '../../display-objects/Circle';
3
3
  export declare class CircleUpdater implements GeometryAABBUpdater<ParsedCircleStyleProps> {
4
- update(parsedStyle: ParsedCircleStyleProps): {
4
+ update(parsedStyle: ParsedCircleStyleProps, object: Circle): {
5
5
  width: number;
6
6
  height: number;
7
7
  x: number;
@@ -8,16 +8,26 @@ var CircleUpdater =
8
8
  function () {
9
9
  function CircleUpdater() {}
10
10
 
11
- CircleUpdater.prototype.update = function (parsedStyle) {
12
- var _a = parsedStyle.r,
13
- r = _a === void 0 ? 0 : _a,
14
- _b = parsedStyle.x,
15
- x = _b === void 0 ? 0 : _b,
16
- _c = parsedStyle.y,
17
- y = _c === void 0 ? 0 : _c;
11
+ CircleUpdater.prototype.update = function (parsedStyle, object) {
12
+ var r = parsedStyle.r,
13
+ _a = parsedStyle.x,
14
+ x = _a === void 0 ? 0 : _a,
15
+ _b = parsedStyle.y,
16
+ y = _b === void 0 ? 0 : _b;
17
+ var unit = r.unit,
18
+ value = r.value;
19
+ var width = 0;
20
+ var height = 0;
21
+
22
+ if (unit === '' || unit === 'px') {
23
+ width = value * 2;
24
+ height = value * 2;
25
+ }
26
+
27
+ object.parsedStyle.rInPixels = width / 2;
18
28
  return {
19
- width: r * 2,
20
- height: r * 2,
29
+ width: width,
30
+ height: height,
21
31
  x: x,
22
32
  y: y
23
33
  };
@@ -1,7 +1,7 @@
1
1
  import { GeometryAABBUpdater } from './interfaces';
2
- import type { ParsedEllipseStyleProps } from '../../display-objects/Ellipse';
2
+ import type { Ellipse, ParsedEllipseStyleProps } from '../../display-objects/Ellipse';
3
3
  export declare class EllipseUpdater implements GeometryAABBUpdater<ParsedEllipseStyleProps> {
4
- update(parsedStyle: ParsedEllipseStyleProps): {
4
+ update(parsedStyle: ParsedEllipseStyleProps, object: Ellipse): {
5
5
  width: number;
6
6
  height: number;
7
7
  x: number;