@antv/g 5.0.24 → 5.1.2

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 (168) hide show
  1. package/dist/index.umd.min.js +2 -2
  2. package/es/Canvas.js +2 -0
  3. package/es/css/CSS.d.ts +4 -2
  4. package/es/css/CSS.js +6 -2
  5. package/es/css/CSSProperty.d.ts +2 -1
  6. package/es/css/StyleValueRegistry.d.ts +24 -55
  7. package/es/css/StyleValueRegistry.js +120 -138
  8. package/es/css/interfaces.d.ts +110 -0
  9. package/es/css/interfaces.js +75 -0
  10. package/es/css/parser/color.d.ts +1 -1
  11. package/es/css/parser/color.js +2 -2
  12. package/es/css/parser/dimension.js +5 -1
  13. package/es/css/parser/path.d.ts +2 -2
  14. package/es/css/parser/path.js +9 -2
  15. package/es/css/parser/points.d.ts +8 -1
  16. package/es/css/parser/points.js +33 -3
  17. package/es/css/parser/transform.js +1 -1
  18. package/es/css/properties/CSSPropertyClipPath.js +7 -1
  19. package/es/css/properties/CSSPropertyLengthOrPercentage.d.ts +1 -2
  20. package/es/css/properties/CSSPropertyLengthOrPercentage.js +34 -14
  21. package/es/css/properties/CSSPropertyLengthOrPercentage12.d.ts +15 -0
  22. package/es/css/properties/CSSPropertyLengthOrPercentage12.js +38 -0
  23. package/es/css/properties/CSSPropertyLengthOrPercentage14.d.ts +25 -0
  24. package/es/css/properties/CSSPropertyLengthOrPercentage14.js +42 -0
  25. package/es/css/properties/CSSPropertyLocalPosition.d.ts +0 -9
  26. package/es/css/properties/CSSPropertyLocalPosition.js +59 -20
  27. package/es/css/properties/CSSPropertyPath.d.ts +3 -3
  28. package/es/css/properties/CSSPropertyPath.js +11 -6
  29. package/es/css/properties/CSSPropertyPoints.js +7 -5
  30. package/es/css/properties/CSSPropertyTransform.d.ts +1 -1
  31. package/es/css/properties/CSSPropertyTransform.js +76 -104
  32. package/es/css/properties/index.d.ts +2 -2
  33. package/es/css/properties/index.js +2 -2
  34. package/es/display-objects/Circle.d.ts +4 -0
  35. package/es/display-objects/Circle.js +2 -0
  36. package/es/display-objects/CustomElement.d.ts +6 -2
  37. package/es/display-objects/CustomElement.js +15 -5
  38. package/es/display-objects/DisplayObject.d.ts +1 -7
  39. package/es/display-objects/DisplayObject.js +6 -26
  40. package/es/display-objects/Ellipse.d.ts +4 -0
  41. package/es/display-objects/Ellipse.js +2 -0
  42. package/es/display-objects/Group.d.ts +4 -0
  43. package/es/display-objects/Group.js +2 -0
  44. package/es/display-objects/HTML.d.ts +4 -4
  45. package/es/display-objects/HTML.js +5 -3
  46. package/es/display-objects/Image.d.ts +4 -0
  47. package/es/display-objects/Image.js +2 -0
  48. package/es/display-objects/Line.js +2 -0
  49. package/es/display-objects/Polygon.js +1 -1
  50. package/es/display-objects/Polyline.js +1 -1
  51. package/es/display-objects/Rect.d.ts +11 -4
  52. package/es/display-objects/Rect.js +2 -0
  53. package/es/display-objects/Text.d.ts +4 -0
  54. package/es/display-objects/Text.js +4 -2
  55. package/es/dom/Element.js +1 -0
  56. package/es/global-module.js +4 -4
  57. package/es/services/EventService.js +10 -2
  58. package/es/services/SceneGraphService.d.ts +2 -0
  59. package/es/services/SceneGraphService.js +9 -0
  60. package/es/services/aabb/CircleUpdater.d.ts +0 -2
  61. package/es/services/aabb/CircleUpdater.js +2 -6
  62. package/es/services/aabb/EllipseUpdater.d.ts +0 -2
  63. package/es/services/aabb/EllipseUpdater.js +2 -6
  64. package/es/services/aabb/LineUpdater.d.ts +0 -2
  65. package/es/services/aabb/LineUpdater.js +1 -3
  66. package/es/services/aabb/PathUpdater.d.ts +0 -2
  67. package/es/services/aabb/PathUpdater.js +1 -5
  68. package/es/services/aabb/PolylineUpdater.d.ts +0 -2
  69. package/es/services/aabb/PolylineUpdater.js +1 -3
  70. package/es/services/aabb/RectUpdater.d.ts +0 -2
  71. package/es/services/aabb/RectUpdater.js +1 -5
  72. package/es/services/aabb/TextUpdater.d.ts +7 -0
  73. package/es/services/aabb/TextUpdater.js +0 -4
  74. package/es/services/aabb/interfaces.d.ts +0 -3
  75. package/es/types.d.ts +6 -19
  76. package/es/types.js +1 -0
  77. package/es/utils/interpolation.js +5 -10
  78. package/es/utils/math.js +4 -3
  79. package/es/utils/path.d.ts +2 -2
  80. package/es/utils/path.js +76 -26
  81. package/lib/Canvas.js +2 -0
  82. package/lib/css/CSS.d.ts +4 -2
  83. package/lib/css/CSS.js +6 -2
  84. package/lib/css/CSSProperty.d.ts +2 -1
  85. package/lib/css/StyleValueRegistry.d.ts +24 -55
  86. package/lib/css/StyleValueRegistry.js +120 -137
  87. package/lib/css/interfaces.d.ts +110 -0
  88. package/lib/css/interfaces.js +76 -1
  89. package/lib/css/parser/color.d.ts +1 -1
  90. package/lib/css/parser/color.js +1 -1
  91. package/lib/css/parser/dimension.js +4 -0
  92. package/lib/css/parser/path.d.ts +2 -2
  93. package/lib/css/parser/path.js +9 -2
  94. package/lib/css/parser/points.d.ts +8 -1
  95. package/lib/css/parser/points.js +33 -3
  96. package/lib/css/parser/transform.js +1 -1
  97. package/lib/css/properties/CSSPropertyClipPath.js +8 -1
  98. package/lib/css/properties/CSSPropertyLengthOrPercentage.d.ts +1 -2
  99. package/lib/css/properties/CSSPropertyLengthOrPercentage.js +34 -14
  100. package/lib/css/properties/CSSPropertyLengthOrPercentage12.d.ts +15 -0
  101. package/lib/css/properties/CSSPropertyLengthOrPercentage12.js +48 -0
  102. package/lib/css/properties/CSSPropertyLengthOrPercentage14.d.ts +25 -0
  103. package/lib/css/properties/CSSPropertyLengthOrPercentage14.js +52 -0
  104. package/lib/css/properties/CSSPropertyLocalPosition.d.ts +0 -9
  105. package/lib/css/properties/CSSPropertyLocalPosition.js +60 -20
  106. package/lib/css/properties/CSSPropertyPath.d.ts +3 -3
  107. package/lib/css/properties/CSSPropertyPath.js +12 -6
  108. package/lib/css/properties/CSSPropertyPoints.js +8 -5
  109. package/lib/css/properties/CSSPropertyTransform.d.ts +1 -1
  110. package/lib/css/properties/CSSPropertyTransform.js +75 -103
  111. package/lib/css/properties/index.d.ts +2 -2
  112. package/lib/css/properties/index.js +17 -17
  113. package/lib/display-objects/Circle.d.ts +4 -0
  114. package/lib/display-objects/Circle.js +2 -0
  115. package/lib/display-objects/CustomElement.d.ts +6 -2
  116. package/lib/display-objects/CustomElement.js +13 -4
  117. package/lib/display-objects/DisplayObject.d.ts +1 -7
  118. package/lib/display-objects/DisplayObject.js +6 -27
  119. package/lib/display-objects/Ellipse.d.ts +4 -0
  120. package/lib/display-objects/Ellipse.js +2 -0
  121. package/lib/display-objects/Group.d.ts +4 -0
  122. package/lib/display-objects/Group.js +2 -0
  123. package/lib/display-objects/HTML.d.ts +4 -4
  124. package/lib/display-objects/HTML.js +5 -3
  125. package/lib/display-objects/Image.d.ts +4 -0
  126. package/lib/display-objects/Image.js +2 -0
  127. package/lib/display-objects/Line.js +2 -0
  128. package/lib/display-objects/Polygon.js +1 -1
  129. package/lib/display-objects/Polyline.js +1 -1
  130. package/lib/display-objects/Rect.d.ts +11 -4
  131. package/lib/display-objects/Rect.js +2 -0
  132. package/lib/display-objects/Text.d.ts +4 -0
  133. package/lib/display-objects/Text.js +4 -2
  134. package/lib/dom/Element.js +1 -0
  135. package/lib/global-module.js +3 -3
  136. package/lib/services/EventService.js +10 -2
  137. package/lib/services/SceneGraphService.d.ts +2 -0
  138. package/lib/services/SceneGraphService.js +12 -0
  139. package/lib/services/aabb/CircleUpdater.d.ts +0 -2
  140. package/lib/services/aabb/CircleUpdater.js +2 -6
  141. package/lib/services/aabb/EllipseUpdater.d.ts +0 -2
  142. package/lib/services/aabb/EllipseUpdater.js +2 -6
  143. package/lib/services/aabb/LineUpdater.d.ts +0 -2
  144. package/lib/services/aabb/LineUpdater.js +1 -3
  145. package/lib/services/aabb/PathUpdater.d.ts +0 -2
  146. package/lib/services/aabb/PathUpdater.js +1 -5
  147. package/lib/services/aabb/PolylineUpdater.d.ts +0 -2
  148. package/lib/services/aabb/PolylineUpdater.js +1 -3
  149. package/lib/services/aabb/RectUpdater.d.ts +0 -2
  150. package/lib/services/aabb/RectUpdater.js +1 -5
  151. package/lib/services/aabb/TextUpdater.d.ts +7 -0
  152. package/lib/services/aabb/TextUpdater.js +0 -4
  153. package/lib/services/aabb/interfaces.d.ts +0 -3
  154. package/lib/types.d.ts +6 -19
  155. package/lib/types.js +1 -0
  156. package/lib/utils/interpolation.js +6 -10
  157. package/lib/utils/math.js +4 -3
  158. package/lib/utils/path.d.ts +2 -2
  159. package/lib/utils/path.js +70 -26
  160. package/package.json +3 -3
  161. package/es/css/properties/CSSPropertyAnchor.d.ts +0 -8
  162. package/es/css/properties/CSSPropertyAnchor.js +0 -25
  163. package/es/css/properties/CSSPropertyLineDash.d.ts +0 -9
  164. package/es/css/properties/CSSPropertyLineDash.js +0 -25
  165. package/lib/css/properties/CSSPropertyAnchor.d.ts +0 -8
  166. package/lib/css/properties/CSSPropertyAnchor.js +0 -35
  167. package/lib/css/properties/CSSPropertyLineDash.d.ts +0 -9
  168. package/lib/css/properties/CSSPropertyLineDash.js +0 -34
package/lib/css/CSS.js CHANGED
@@ -104,14 +104,18 @@ var CSS = {
104
104
  registerProperty: function registerProperty(definition) {
105
105
  var name = definition.name,
106
106
  inherits = definition.inherits,
107
- initialValue = definition.initialValue;
107
+ interpolable = definition.interpolable,
108
+ initialValue = definition.initialValue,
109
+ syntax = definition.syntax;
108
110
 
109
111
  var registry = _manaSyringe.GlobalContainer.get(_interfaces.StyleValueRegistry);
110
112
 
111
113
  registry.registerMetadata({
112
114
  name: name,
113
115
  inherited: inherits,
114
- defaultValue: initialValue
116
+ interpolable: interpolable,
117
+ defaultValue: initialValue,
118
+ syntax: syntax
115
119
  });
116
120
  },
117
121
 
@@ -1,8 +1,9 @@
1
+ import type { DisplayObject } from '../display-objects';
1
2
  import type { IElement } from '../dom';
2
3
  import type { StyleValueRegistry } from './interfaces';
3
4
  export declare type Interpolatable = number | boolean | number[] | boolean[];
4
5
  declare type CSSPropertyMixer<Parsed = any, T extends Interpolatable = any> = (left: Parsed, right: Parsed, displayObject: IElement | null) => [T, T, (i: T) => string | any] | undefined;
5
- declare type CSSPropertyParser<Parsed> = (value: string | any) => Parsed;
6
+ declare type CSSPropertyParser<Parsed> = (value: string | any, object: DisplayObject) => Parsed;
6
7
  declare type CSSPropertyCalculator<Parsed, Used> = (name: string, oldParsed: Parsed, parsed: Parsed, object: IElement, registry: StyleValueRegistry) => Used;
7
8
  /**
8
9
  * 1. parser: raw CSS string -> Computed Value
@@ -1,67 +1,35 @@
1
1
  import type { DisplayObject } from '../display-objects';
2
2
  import type { BaseStyleProps } from '../types';
3
3
  import { CSSStyleValue } from './cssom';
4
+ import { CSSPropertyLocalPosition, CSSPropertyOpacity, CSSPropertyColor, CSSPropertyFilter, CSSPropertyLengthOrPercentage, CSSPropertyLengthOrPercentage12, CSSPropertyLengthOrPercentage14, CSSPropertyShadowBlur, CSSPropertyOffsetPath, CSSPropertyOffsetDistance, CSSPropertyZIndex, CSSPropertyTransform, CSSPropertyTransformOrigin, CSSPropertyPath, CSSPropertyClipPath, CSSPropertyPoints, CSSPropertyText, CSSPropertyTextTransform } from './properties';
5
+ import type { PropertyMetadata } from './interfaces';
4
6
  import { StyleValueRegistry } from './interfaces';
5
7
  export declare type CSSGlobalKeywords = 'unset' | 'initial' | 'inherit' | '';
6
8
  export interface PropertyParseOptions {
7
9
  skipUpdateAttribute: boolean;
8
10
  skipParse: boolean;
9
11
  }
10
- export declare const PropertySyntax: {
11
- COLOR: string;
12
- PAINT: string;
13
- NUMBER: string;
14
- LENGTH: string;
15
- PERCENTAGE: string;
16
- LENGTH_PERCENTAGE: string;
12
+ export declare const PROPERTY_HANDLERS: {
13
+ "<coordinate>": typeof CSSPropertyLocalPosition;
14
+ "<color>": typeof CSSPropertyColor;
15
+ "<paint>": typeof CSSPropertyColor;
16
+ "<opacity-value>": typeof CSSPropertyOpacity;
17
+ "<length> | <percentage>": typeof CSSPropertyLengthOrPercentage;
18
+ "[<length> | <percentage>]{1,2}": typeof CSSPropertyLengthOrPercentage12;
19
+ "[<length> | <percentage>]{1,4}": typeof CSSPropertyLengthOrPercentage14;
20
+ "<shadow-blur>": typeof CSSPropertyShadowBlur;
21
+ "<list-of-points>": typeof CSSPropertyPoints;
22
+ "<path>": typeof CSSPropertyPath;
23
+ "<filter>": typeof CSSPropertyFilter;
24
+ "<z-index>": typeof CSSPropertyZIndex;
25
+ "<offset-path>": typeof CSSPropertyOffsetPath;
26
+ "<offset-distance>": typeof CSSPropertyOffsetDistance;
27
+ "<clip-path>": typeof CSSPropertyClipPath;
28
+ "<transform>": typeof CSSPropertyTransform;
29
+ "<transform-origin>": typeof CSSPropertyTransformOrigin;
30
+ "<text>": typeof CSSPropertyText;
31
+ "<text-transform>": typeof CSSPropertyTextTransform;
17
32
  };
18
- export interface PropertyMetadata {
19
- name: string;
20
- /**
21
- * The interpolable flag indicates whether a property can be animated smoothly.
22
- * Default to `false`.
23
- */
24
- interpolable?: boolean;
25
- /**
26
- * The property will inherit by default if no value is specified.
27
- * Default to `false`.
28
- */
29
- inherited?: boolean;
30
- /**
31
- * This property affects only one field on ComputedStyle, and can be set
32
- * directly during inheritance instead of forcing a recalc.
33
- */
34
- independent?: boolean;
35
- /**
36
- * This specifies the default value for this field.
37
- * - for keyword fields, this is the initial keyword
38
- * - for other fields, this is a string containg the C++ expression that is used to initialise the field.
39
- */
40
- defaultValue?: string;
41
- /**
42
- * The resolved value used for getComputedStyle() depends on layout for this
43
- * property, which means we may need to update layout to return the correct
44
- * value from getComputedStyle().
45
- */
46
- layoutDependent?: boolean;
47
- /**
48
- * This specifies all valid keyword values for the property.
49
- */
50
- keywords?: string[];
51
- /**
52
- * eg. strokeWidth is an alias of lineWidth
53
- */
54
- alias?: string[];
55
- /**
56
- * sort before init attributes according to this priority
57
- */
58
- parsePriority?: number;
59
- /**
60
- * eg. <color> <paint> <number>
61
- */
62
- syntax?: string;
63
- handler?: any;
64
- }
65
33
  /**
66
34
  * Blink used them in code generation(css_properties.json5)
67
35
  */
@@ -85,6 +53,7 @@ export declare class DefaultStyleValueRegistry implements StyleValueRegistry {
85
53
  private cascadeProperties;
86
54
  init(): void;
87
55
  registerMetadata(metadata: PropertyMetadata): void;
56
+ unregisterMetadata(name: string): void;
88
57
  getMetadata(name: string): PropertyMetadata;
89
58
  /**
90
59
  * * parse value, eg.
@@ -99,7 +68,7 @@ export declare class DefaultStyleValueRegistry implements StyleValueRegistry {
99
68
  /**
100
69
  * string -> parsed value
101
70
  */
102
- parseProperty(name: string, value: any): CSSStyleValue;
71
+ parseProperty(name: string, value: any, object: DisplayObject): CSSStyleValue;
103
72
  /**
104
73
  * computed value -> used value
105
74
  */