@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
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.PropertySyntax = exports.DefaultStyleValueRegistry = exports.BUILT_IN_PROPERTIES = void 0;
6
+ exports.PROPERTY_HANDLERS = exports.DefaultStyleValueRegistry = exports.BUILT_IN_PROPERTIES = void 0;
7
7
 
8
8
  var _tslib = require("tslib");
9
9
 
@@ -31,19 +31,14 @@ var _shapes = require("../shapes");
31
31
 
32
32
  var _interfaces2 = require("./interfaces");
33
33
 
34
- var PropertySyntax = {
35
- COLOR: '<color>',
36
- PAINT: '<paint>',
37
- NUMBER: '<number>',
38
- LENGTH: '<length>',
39
- PERCENTAGE: '<percentage>',
40
- LENGTH_PERCENTAGE: '<length> | <percentage>'
41
- };
34
+ var _a;
35
+
36
+ var PROPERTY_HANDLERS = (_a = {}, _a[_interfaces2.PropertySyntax.COORDINATE] = _properties.CSSPropertyLocalPosition, _a[_interfaces2.PropertySyntax.COLOR] = _properties.CSSPropertyColor, _a[_interfaces2.PropertySyntax.PAINT] = _properties.CSSPropertyColor, _a[_interfaces2.PropertySyntax.OPACITY_VALUE] = _properties.CSSPropertyOpacity, _a[_interfaces2.PropertySyntax.LENGTH_PERCENTAGE] = _properties.CSSPropertyLengthOrPercentage, _a[_interfaces2.PropertySyntax.LENGTH_PERCENTAGE_12] = _properties.CSSPropertyLengthOrPercentage12, _a[_interfaces2.PropertySyntax.LENGTH_PERCENTAGE_14] = _properties.CSSPropertyLengthOrPercentage14, _a[_interfaces2.PropertySyntax.SHADOW_BLUR] = _properties.CSSPropertyShadowBlur, _a[_interfaces2.PropertySyntax.LIST_OF_POINTS] = _properties.CSSPropertyPoints, _a[_interfaces2.PropertySyntax.PATH] = _properties.CSSPropertyPath, _a[_interfaces2.PropertySyntax.FILTER] = _properties.CSSPropertyFilter, _a[_interfaces2.PropertySyntax.Z_INDEX] = _properties.CSSPropertyZIndex, _a[_interfaces2.PropertySyntax.OFFSET_PATH] = _properties.CSSPropertyOffsetPath, _a[_interfaces2.PropertySyntax.OFFSET_DISTANCE] = _properties.CSSPropertyOffsetDistance, _a[_interfaces2.PropertySyntax.CLIP_PATH] = _properties.CSSPropertyClipPath, _a[_interfaces2.PropertySyntax.TRANSFORM] = _properties.CSSPropertyTransform, _a[_interfaces2.PropertySyntax.TRANSFORM_ORIGIN] = _properties.CSSPropertyTransformOrigin, _a[_interfaces2.PropertySyntax.TEXT] = _properties.CSSPropertyText, _a[_interfaces2.PropertySyntax.TEXT_TRANSFORM] = _properties.CSSPropertyTextTransform, _a);
42
37
  /**
43
38
  * Blink used them in code generation(css_properties.json5)
44
39
  */
45
40
 
46
- exports.PropertySyntax = PropertySyntax;
41
+ exports.PROPERTY_HANDLERS = PROPERTY_HANDLERS;
47
42
  var BUILT_IN_PROPERTIES = [{
48
43
  /**
49
44
  * used in CSS Layout API
@@ -51,29 +46,6 @@ var BUILT_IN_PROPERTIES = [{
51
46
  */
52
47
  name: 'display',
53
48
  keywords: ['none']
54
- }, {
55
- // x in local space
56
- name: 'x',
57
- interpolable: true,
58
- alias: ['cx'],
59
- defaultValue: '0',
60
- syntax: PropertySyntax.LENGTH_PERCENTAGE,
61
- handler: _properties.CSSPropertyLocalPosition
62
- }, {
63
- // y in local space
64
- name: 'y',
65
- interpolable: true,
66
- alias: ['cy'],
67
- defaultValue: '0',
68
- syntax: PropertySyntax.LENGTH_PERCENTAGE,
69
- handler: _properties.CSSPropertyLocalPosition
70
- }, {
71
- // z in local space
72
- name: 'z',
73
- interpolable: true,
74
- defaultValue: '0',
75
- syntax: PropertySyntax.LENGTH_PERCENTAGE,
76
- handler: _properties.CSSPropertyLocalPosition
77
49
  }, {
78
50
  /**
79
51
  * range [0.0, 1.0]
@@ -82,8 +54,7 @@ var BUILT_IN_PROPERTIES = [{
82
54
  name: 'opacity',
83
55
  interpolable: true,
84
56
  defaultValue: '1',
85
- syntax: PropertySyntax.NUMBER,
86
- handler: _properties.CSSPropertyOpacity
57
+ syntax: _interfaces2.PropertySyntax.OPACITY_VALUE
87
58
  }, {
88
59
  /**
89
60
  * range [0.0, 1.0]
@@ -93,8 +64,7 @@ var BUILT_IN_PROPERTIES = [{
93
64
  interpolable: true,
94
65
  inherited: true,
95
66
  defaultValue: '1',
96
- syntax: PropertySyntax.NUMBER,
97
- handler: _properties.CSSPropertyOpacity
67
+ syntax: _interfaces2.PropertySyntax.OPACITY_VALUE
98
68
  }, {
99
69
  /**
100
70
  * range [0.0, 1.0]
@@ -104,8 +74,7 @@ var BUILT_IN_PROPERTIES = [{
104
74
  interpolable: true,
105
75
  inherited: true,
106
76
  defaultValue: '1',
107
- syntax: PropertySyntax.NUMBER,
108
- handler: _properties.CSSPropertyOpacity
77
+ syntax: _interfaces2.PropertySyntax.OPACITY_VALUE
109
78
  }, {
110
79
  /**
111
80
  * background-color is not inheritable
@@ -115,37 +84,32 @@ var BUILT_IN_PROPERTIES = [{
115
84
  interpolable: true,
116
85
  keywords: ['none'],
117
86
  defaultValue: 'none',
118
- syntax: PropertySyntax.PAINT,
119
- handler: _properties.CSSPropertyColor
87
+ syntax: _interfaces2.PropertySyntax.PAINT
120
88
  }, {
121
89
  name: 'stroke',
122
90
  interpolable: true,
123
91
  keywords: ['none'],
124
92
  defaultValue: 'none',
125
- syntax: PropertySyntax.PAINT,
126
- handler: _properties.CSSPropertyColor
93
+ syntax: _interfaces2.PropertySyntax.PAINT
127
94
  }, {
128
95
  name: 'shadowColor',
129
96
  interpolable: true,
130
- syntax: PropertySyntax.COLOR,
131
- handler: _properties.CSSPropertyColor
97
+ syntax: _interfaces2.PropertySyntax.COLOR
132
98
  }, {
133
99
  name: 'shadowOffsetX',
134
100
  interpolable: true,
135
101
  layoutDependent: true,
136
- syntax: PropertySyntax.LENGTH_PERCENTAGE,
137
- handler: _properties.CSSPropertyLengthOrPercentage
102
+ syntax: _interfaces2.PropertySyntax.LENGTH_PERCENTAGE
138
103
  }, {
139
104
  name: 'shadowOffsetY',
140
105
  interpolable: true,
141
106
  layoutDependent: true,
142
- syntax: PropertySyntax.LENGTH_PERCENTAGE,
143
- handler: _properties.CSSPropertyLengthOrPercentage
107
+ syntax: _interfaces2.PropertySyntax.LENGTH_PERCENTAGE
144
108
  }, {
145
109
  name: 'shadowBlur',
146
110
  interpolable: true,
147
111
  layoutDependent: true,
148
- handler: _properties.CSSPropertyShadowBlur
112
+ syntax: _interfaces2.PropertySyntax.SHADOW_BLUR
149
113
  }, {
150
114
  /**
151
115
  * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-width
@@ -156,15 +120,13 @@ var BUILT_IN_PROPERTIES = [{
156
120
  defaultValue: '1',
157
121
  layoutDependent: true,
158
122
  alias: ['strokeWidth'],
159
- syntax: PropertySyntax.LENGTH_PERCENTAGE,
160
- handler: _properties.CSSPropertyLengthOrPercentage
123
+ syntax: _interfaces2.PropertySyntax.LENGTH_PERCENTAGE
161
124
  }, {
162
125
  name: 'increasedLineWidthForHitTesting',
163
126
  inherited: true,
164
127
  defaultValue: '0',
165
128
  layoutDependent: true,
166
- syntax: PropertySyntax.LENGTH_PERCENTAGE,
167
- handler: _properties.CSSPropertyLengthOrPercentage
129
+ syntax: _interfaces2.PropertySyntax.LENGTH_PERCENTAGE
168
130
  }, {
169
131
  name: 'lineJoin',
170
132
  inherited: true,
@@ -185,40 +147,40 @@ var BUILT_IN_PROPERTIES = [{
185
147
  inherited: true,
186
148
  keywords: ['none'],
187
149
  alias: ['strokeDasharray'],
188
- handler: _properties.CSSPropertyLineDash
150
+ syntax: _interfaces2.PropertySyntax.LENGTH_PERCENTAGE_12
189
151
  }, {
190
152
  name: 'lineDashOffset',
191
153
  interpolable: true,
192
154
  inherited: true,
193
155
  defaultValue: '0',
194
156
  alias: ['strokeDashoffset'],
195
- handler: _properties.CSSPropertyLengthOrPercentage
157
+ syntax: _interfaces2.PropertySyntax.LENGTH_PERCENTAGE
196
158
  }, {
197
159
  name: 'offsetPath',
198
- handler: _properties.CSSPropertyOffsetPath
160
+ syntax: _interfaces2.PropertySyntax.OFFSET_PATH
199
161
  }, {
200
162
  name: 'offsetDistance',
201
163
  interpolable: true,
202
- handler: _properties.CSSPropertyOffsetDistance
164
+ syntax: _interfaces2.PropertySyntax.OFFSET_DISTANCE
203
165
  }, {
204
166
  name: 'dx',
205
167
  interpolable: true,
206
168
  layoutDependent: true,
207
169
  defaultValue: '0',
208
- handler: _properties.CSSPropertyLengthOrPercentage
170
+ syntax: _interfaces2.PropertySyntax.LENGTH_PERCENTAGE
209
171
  }, {
210
172
  name: 'dy',
211
173
  interpolable: true,
212
174
  layoutDependent: true,
213
175
  defaultValue: '0',
214
- handler: _properties.CSSPropertyLengthOrPercentage
176
+ syntax: _interfaces2.PropertySyntax.LENGTH_PERCENTAGE
215
177
  }, {
216
178
  name: 'zIndex',
217
179
  independent: true,
218
180
  interpolable: true,
219
181
  defaultValue: '0',
220
182
  keywords: ['auto'],
221
- handler: _properties.CSSPropertyZIndex
183
+ syntax: _interfaces2.PropertySyntax.Z_INDEX
222
184
  }, {
223
185
  name: 'visibility',
224
186
  keywords: ['visible', 'hidden'],
@@ -240,49 +202,78 @@ var BUILT_IN_PROPERTIES = [{
240
202
  name: 'filter',
241
203
  independent: true,
242
204
  layoutDependent: true,
243
- handler: _properties.CSSPropertyFilter
205
+ syntax: _interfaces2.PropertySyntax.FILTER
244
206
  }, {
245
207
  name: 'clipPath',
246
- handler: _properties.CSSPropertyClipPath
208
+ syntax: _interfaces2.PropertySyntax.CLIP_PATH
247
209
  }, {
248
210
  name: 'transform',
211
+ parsePriority: 100,
249
212
  interpolable: true,
250
213
  keywords: ['none'],
251
214
  defaultValue: 'none',
252
- handler: _properties.CSSPropertyTransform
215
+ syntax: _interfaces2.PropertySyntax.TRANSFORM
253
216
  }, {
254
217
  name: 'transformOrigin',
255
218
  parsePriority: 100,
256
219
  // interpolable: true,
257
220
  defaultValue: 'left top',
258
221
  layoutDependent: true,
259
- handler: _properties.CSSPropertyTransformOrigin
222
+ syntax: _interfaces2.PropertySyntax.TRANSFORM_ORIGIN
260
223
  }, {
261
224
  name: 'anchor',
262
225
  parsePriority: 99,
263
226
  layoutDependent: true,
264
- handler: _properties.CSSPropertyAnchor
265
- }, // Circle
227
+ syntax: _interfaces2.PropertySyntax.LENGTH_PERCENTAGE_12
228
+ }, // <circle> & <ellipse>
266
229
  {
230
+ name: 'cx',
231
+ interpolable: true,
232
+ defaultValue: '0',
233
+ syntax: _interfaces2.PropertySyntax.COORDINATE
234
+ }, {
235
+ name: 'cy',
236
+ interpolable: true,
237
+ defaultValue: '0',
238
+ syntax: _interfaces2.PropertySyntax.COORDINATE
239
+ }, {
267
240
  name: 'r',
268
241
  interpolable: true,
269
242
  layoutDependent: true,
270
243
  defaultValue: '0',
271
- handler: _properties.CSSPropertyLengthOrPercentage
244
+ syntax: _interfaces2.PropertySyntax.LENGTH_PERCENTAGE
272
245
  }, {
273
246
  name: 'rx',
274
247
  interpolable: true,
275
248
  layoutDependent: true,
276
249
  defaultValue: 'auto',
277
- handler: _properties.CSSPropertyLengthOrPercentage
250
+ syntax: _interfaces2.PropertySyntax.LENGTH_PERCENTAGE
278
251
  }, {
279
252
  name: 'ry',
280
253
  interpolable: true,
281
254
  layoutDependent: true,
282
255
  defaultValue: 'auto',
283
- handler: _properties.CSSPropertyLengthOrPercentage
284
- }, // Rect Image
256
+ syntax: _interfaces2.PropertySyntax.LENGTH_PERCENTAGE
257
+ }, // Rect Image Group
285
258
  {
259
+ // x in local space
260
+ name: 'x',
261
+ interpolable: true,
262
+ defaultValue: '0',
263
+ syntax: _interfaces2.PropertySyntax.COORDINATE
264
+ }, {
265
+ // y in local space
266
+ name: 'y',
267
+ interpolable: true,
268
+ defaultValue: '0',
269
+ syntax: _interfaces2.PropertySyntax.COORDINATE
270
+ }, {
271
+ // z in local space
272
+ name: 'z',
273
+ interpolable: true,
274
+ defaultValue: '0',
275
+ syntax: _interfaces2.PropertySyntax.COORDINATE
276
+ }, {
286
277
  name: 'width',
287
278
  interpolable: true,
288
279
  layoutDependent: true,
@@ -291,8 +282,8 @@ var BUILT_IN_PROPERTIES = [{
291
282
  * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/width
292
283
  */
293
284
  keywords: ['auto', 'fit-content', 'min-content', 'max-content'],
294
- defaultValue: '0',
295
- handler: _properties.CSSPropertyLengthOrPercentage
285
+ defaultValue: 'auto',
286
+ syntax: _interfaces2.PropertySyntax.LENGTH_PERCENTAGE
296
287
  }, {
297
288
  name: 'height',
298
289
  interpolable: true,
@@ -302,70 +293,71 @@ var BUILT_IN_PROPERTIES = [{
302
293
  * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/height
303
294
  */
304
295
  keywords: ['auto', 'fit-content', 'min-content', 'max-content'],
305
- defaultValue: '0',
306
- handler: _properties.CSSPropertyLengthOrPercentage
296
+ defaultValue: 'auto',
297
+ syntax: _interfaces2.PropertySyntax.LENGTH_PERCENTAGE
307
298
  }, {
308
299
  name: 'radius',
309
300
  interpolable: true,
310
301
  layoutDependent: true,
311
302
  defaultValue: '0',
312
- handler: _properties.CSSPropertyLengthOrPercentage
303
+ syntax: _interfaces2.PropertySyntax.LENGTH_PERCENTAGE_14
313
304
  }, // Line
314
305
  {
315
306
  name: 'x1',
316
307
  interpolable: true,
317
308
  layoutDependent: true,
318
- handler: _properties.CSSPropertyLocalPosition
309
+ syntax: _interfaces2.PropertySyntax.COORDINATE
319
310
  }, {
320
311
  name: 'y1',
321
312
  interpolable: true,
322
313
  layoutDependent: true,
323
- handler: _properties.CSSPropertyLocalPosition
314
+ syntax: _interfaces2.PropertySyntax.COORDINATE
324
315
  }, {
325
316
  name: 'z1',
326
317
  interpolable: true,
327
318
  layoutDependent: true,
328
- handler: _properties.CSSPropertyLocalPosition
319
+ syntax: _interfaces2.PropertySyntax.COORDINATE
329
320
  }, {
330
321
  name: 'x2',
331
322
  interpolable: true,
332
323
  layoutDependent: true,
333
- handler: _properties.CSSPropertyLocalPosition
324
+ syntax: _interfaces2.PropertySyntax.COORDINATE
334
325
  }, {
335
326
  name: 'y2',
336
327
  interpolable: true,
337
328
  layoutDependent: true,
338
- handler: _properties.CSSPropertyLocalPosition
329
+ syntax: _interfaces2.PropertySyntax.COORDINATE
339
330
  }, {
340
331
  name: 'z2',
341
332
  interpolable: true,
342
333
  layoutDependent: true,
343
- handler: _properties.CSSPropertyLocalPosition
334
+ syntax: _interfaces2.PropertySyntax.COORDINATE
344
335
  }, // Path
345
336
  {
346
337
  name: 'path',
347
338
  interpolable: true,
348
339
  layoutDependent: true,
349
340
  defaultValue: '',
350
- handler: _properties.CSSPropertyPath
351
- }, // Polyline
341
+ alias: ['d'],
342
+ syntax: _interfaces2.PropertySyntax.PATH
343
+ }, // Polyline & Polygon
352
344
  {
353
345
  name: 'points',
354
346
  layoutDependent: true,
355
- handler: _properties.CSSPropertyPoints
347
+ syntax: _interfaces2.PropertySyntax.LIST_OF_POINTS
356
348
  }, // Text
357
349
  {
358
350
  name: 'text',
359
351
  layoutDependent: true,
360
- handler: _properties.CSSPropertyText,
361
- defaultValue: ''
352
+ defaultValue: '',
353
+ syntax: _interfaces2.PropertySyntax.TEXT
362
354
  }, {
363
355
  name: 'textTransform',
364
356
  layoutDependent: true,
365
357
  inherited: true,
366
358
  keywords: ['capitalize', 'uppercase', 'lowercase', 'none'],
367
359
  defaultValue: 'none',
368
- handler: _properties.CSSPropertyTextTransform
360
+ syntax: _interfaces2.PropertySyntax.TEXT_TRANSFORM
369
361
  }, {
370
362
  name: 'font',
371
363
  layoutDependent: true
@@ -379,7 +371,7 @@ var BUILT_IN_PROPERTIES = [{
379
371
  */
380
372
  defaultValue: '16px',
381
373
  layoutDependent: true,
382
- handler: _properties.CSSPropertyLengthOrPercentage
374
+ syntax: _interfaces2.PropertySyntax.LENGTH_PERCENTAGE
383
375
  }, {
384
376
  name: 'fontFamily',
385
377
  layoutDependent: true,
@@ -497,6 +489,10 @@ function () {
497
489
  });
498
490
  };
499
491
 
492
+ DefaultStyleValueRegistry.prototype.unregisterMetadata = function (name) {
493
+ delete this.cache[name];
494
+ };
495
+
500
496
  DefaultStyleValueRegistry.prototype.getMetadata = function (name) {
501
497
  return this.cache[name];
502
498
  };
@@ -548,7 +544,7 @@ function () {
548
544
 
549
545
  if (!skipParse) {
550
546
  sortedNames.forEach(function (name) {
551
- object.computedStyle[name] = _this.parseProperty(name, object.attributes[name]);
547
+ object.computedStyle[name] = _this.parseProperty(name, object.attributes[name], object);
552
548
  });
553
549
  }
554
550
 
@@ -592,11 +588,11 @@ function () {
592
588
  */
593
589
 
594
590
 
595
- DefaultStyleValueRegistry.prototype.parseProperty = function (name, value) {
591
+ DefaultStyleValueRegistry.prototype.parseProperty = function (name, value, object) {
596
592
  var metadata = this.getMetadata(name);
597
593
  var computed = value;
598
594
 
599
- if (value === '') {
595
+ if (value === '' || (0, _utils.isNil)(value)) {
600
596
  value = 'unset';
601
597
  }
602
598
 
@@ -605,7 +601,8 @@ function () {
605
601
  } else {
606
602
  if (metadata) {
607
603
  var keywords = metadata.keywords,
608
- handler = metadata.handler; // use keywords
604
+ syntax = metadata.syntax;
605
+ var handler = syntax && PROPERTY_HANDLERS[syntax]; // use keywords
609
606
 
610
607
  if (keywords && keywords.indexOf(value) > -1) {
611
608
  computed = new _cssom.CSSKeywordValue(value);
@@ -615,7 +612,7 @@ function () {
615
612
 
616
613
  if (propertyHandler && propertyHandler.parser) {
617
614
  // try to parse it to CSSStyleValue, eg. '10px' -> CSS.px(10)
618
- computed = propertyHandler.parser(value);
615
+ computed = propertyHandler.parser(value, object);
619
616
  }
620
617
  }
621
618
  }
@@ -634,7 +631,7 @@ function () {
634
631
  var used = computed instanceof _cssom.CSSStyleValue ? computed.clone() : computed;
635
632
 
636
633
  if (metadata) {
637
- var handler = metadata.handler,
634
+ var syntax = metadata.syntax,
638
635
  inherited = metadata.inherited,
639
636
  defaultValue = metadata.defaultValue;
640
637
 
@@ -654,8 +651,8 @@ function () {
654
651
 
655
652
  if (value === 'initial') {
656
653
  // @see https://developer.mozilla.org/en-US/docs/Web/CSS/initial
657
- if (defaultValue) {
658
- computed = this.parseProperty(name, defaultValue);
654
+ if (!(0, _utils.isNil)(defaultValue)) {
655
+ computed = this.parseProperty(name, defaultValue, object);
659
656
  }
660
657
  } else if (value === 'inherit') {
661
658
  // @see https://developer.mozilla.org/en-US/docs/Web/CSS/inherit
@@ -674,6 +671,8 @@ function () {
674
671
  }
675
672
  }
676
673
 
674
+ var handler = syntax && PROPERTY_HANDLERS[syntax];
675
+
677
676
  if (handler) {
678
677
  var propertyHandler = _manaSyringe.GlobalContainer.get(handler); // convert computed value to used value
679
678
 
@@ -696,8 +695,10 @@ function () {
696
695
  DefaultStyleValueRegistry.prototype.postProcessProperty = function (name, object) {
697
696
  var metadata = this.getMetadata(name);
698
697
 
699
- if (metadata && metadata.handler) {
700
- var propertyHandler = _manaSyringe.GlobalContainer.get(metadata.handler);
698
+ if (metadata && metadata.syntax) {
699
+ var handler = metadata.syntax && PROPERTY_HANDLERS[metadata.syntax];
700
+
701
+ var propertyHandler = _manaSyringe.GlobalContainer.get(handler);
701
702
 
702
703
  if (propertyHandler && propertyHandler.postProcessor) {
703
704
  propertyHandler.postProcessor(object);
@@ -794,42 +795,24 @@ function () {
794
795
  height = _b.height,
795
796
  _c = _b.depth,
796
797
  depth = _c === void 0 ? 0 : _c,
797
- _d = _b.x,
798
- x = _d === void 0 ? 0 : _d,
799
- _e = _b.y,
800
- y = _e === void 0 ? 0 : _e,
801
- // z = 0,
802
- _f = _b.offsetX,
803
- // z = 0,
804
- offsetX = _f === void 0 ? 0 : _f,
805
- _g = _b.offsetY,
806
- offsetY = _g === void 0 ? 0 : _g,
807
- _h = _b.offsetZ,
808
- offsetZ = _h === void 0 ? 0 : _h;
809
-
810
- if (object.nodeName === _types.Shape.LINE || object.nodeName === _types.Shape.POLYLINE || object.nodeName === _types.Shape.POLYGON || object.nodeName === _types.Shape.PATH) {
811
- parsedStyle.offsetX = x - (parsedStyle.defX || 0);
812
- parsedStyle.offsetY = y - (parsedStyle.defY || 0);
813
- parsedStyle.defX = x;
814
- parsedStyle.defY = y; // modify x/y/z
815
-
816
- object.attributes.x += parsedStyle.offsetX;
817
- object.attributes.y += parsedStyle.offsetY;
818
- parsedStyle.x = parsedStyle.x.add(new _cssom.CSSUnitValue(parsedStyle.offsetX, 'px'));
819
- parsedStyle.y = parsedStyle.y.add(new _cssom.CSSUnitValue(parsedStyle.offsetY, 'px'));
820
- } // init with content box
798
+ _d = _b.offsetX,
799
+ offsetX = _d === void 0 ? 0 : _d,
800
+ _e = _b.offsetY,
801
+ offsetY = _e === void 0 ? 0 : _e,
802
+ _f = _b.offsetZ,
803
+ offsetZ = _f === void 0 ? 0 : _f; // init with content box
821
804
 
822
805
 
823
806
  var halfExtents = _glMatrix.vec3.fromValues(width / 2, height / 2, depth / 2); // anchor is center by default, don't account for lineWidth here
824
807
 
825
808
 
826
- var _j = parsedStyle,
827
- lineWidth = _j.lineWidth,
828
- increasedLineWidthForHitTesting = _j.increasedLineWidthForHitTesting,
829
- shadowColor = _j.shadowColor,
830
- _k = _j.filter,
831
- filter = _k === void 0 ? [] : _k,
832
- transformOrigin = _j.transformOrigin;
809
+ var _g = parsedStyle,
810
+ lineWidth = _g.lineWidth,
811
+ increasedLineWidthForHitTesting = _g.increasedLineWidthForHitTesting,
812
+ shadowColor = _g.shadowColor,
813
+ _h = _g.filter,
814
+ filter = _h === void 0 ? [] : _h,
815
+ transformOrigin = _g.transformOrigin;
833
816
  var anchor = parsedStyle.anchor; // <Text> use textAlign & textBaseline instead of anchor
834
817
 
835
818
  if (object.nodeName === _types.Shape.TEXT) {
@@ -847,13 +830,13 @@ function () {
847
830
  geometry_1.renderBounds.update(center, halfExtents); // account for shadow, only support constant value now
848
831
 
849
832
  if (shadowColor) {
850
- var _l = geometry_1.renderBounds,
851
- min = _l.min,
852
- max = _l.max;
853
- var _m = parsedStyle,
854
- shadowBlur = _m.shadowBlur,
855
- shadowOffsetX = _m.shadowOffsetX,
856
- shadowOffsetY = _m.shadowOffsetY;
833
+ var _j = geometry_1.renderBounds,
834
+ min = _j.min,
835
+ max = _j.max;
836
+ var _k = parsedStyle,
837
+ shadowBlur = _k.shadowBlur,
838
+ shadowOffsetX = _k.shadowOffsetX,
839
+ shadowOffsetY = _k.shadowOffsetY;
857
840
  var shadowBlurInPixels = shadowBlur && shadowBlur.value || 0;
858
841
  var shadowOffsetXInPixels = shadowOffsetX && shadowOffsetX.value || 0;
859
842
  var shadowOffsetYInPixels = shadowOffsetY && shadowOffsetY.value || 0;
@@ -1,6 +1,116 @@
1
1
  import { Syringe } from 'mana-syringe';
2
2
  import type { DisplayObject } from '../display-objects';
3
+ /**
4
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type
5
+ */
6
+ export declare enum PropertySyntax {
7
+ /**
8
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#coordinate
9
+ */
10
+ COORDINATE = "<coordinate>",
11
+ /**
12
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#color
13
+ */
14
+ COLOR = "<color>",
15
+ /**
16
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#paint
17
+ */
18
+ PAINT = "<paint>",
19
+ /**
20
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#number
21
+ */
22
+ NUMBER = "<number>",
23
+ /**
24
+ * <number> with range 0..1
25
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#opacity_value
26
+ */
27
+ OPACITY_VALUE = "<opacity-value>",
28
+ /**
29
+ * <number> with range 0..Infinity
30
+ */
31
+ SHADOW_BLUR = "<shadow-blur>",
32
+ /**
33
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#length
34
+ */
35
+ LENGTH = "<length>",
36
+ /**
37
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#percentage
38
+ */
39
+ PERCENTAGE = "<percentage>",
40
+ LENGTH_PERCENTAGE = "<length> | <percentage>",
41
+ LENGTH_PERCENTAGE_12 = "[<length> | <percentage>]{1,2}",
42
+ /**
43
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/margin#formal_syntax
44
+ */
45
+ LENGTH_PERCENTAGE_14 = "[<length> | <percentage>]{1,4}",
46
+ /**
47
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#list-of-ts
48
+ */
49
+ LIST_OF_POINTS = "<list-of-points>",
50
+ PATH = "<path>",
51
+ /**
52
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/filter#formal_syntax
53
+ */
54
+ FILTER = "<filter>",
55
+ Z_INDEX = "<z-index>",
56
+ OFFSET_PATH = "<offset-path>",
57
+ OFFSET_DISTANCE = "<offset-distance>",
58
+ CLIP_PATH = "<clip-path>",
59
+ TRANSFORM = "<transform>",
60
+ TRANSFORM_ORIGIN = "<transform-origin>",
61
+ TEXT = "<text>",
62
+ TEXT_TRANSFORM = "<text-transform>"
63
+ }
64
+ export interface PropertyMetadata {
65
+ name: string;
66
+ /**
67
+ * The interpolable flag indicates whether a property can be animated smoothly.
68
+ * Default to `false`.
69
+ */
70
+ interpolable?: boolean;
71
+ /**
72
+ * The property will inherit by default if no value is specified.
73
+ * Default to `false`.
74
+ */
75
+ inherited?: boolean;
76
+ /**
77
+ * This property affects only one field on ComputedStyle, and can be set
78
+ * directly during inheritance instead of forcing a recalc.
79
+ */
80
+ independent?: boolean;
81
+ /**
82
+ * This specifies the default value for this field.
83
+ * - for keyword fields, this is the initial keyword
84
+ * - for other fields, this is a string containg the C++ expression that is used to initialise the field.
85
+ */
86
+ defaultValue?: string;
87
+ /**
88
+ * The resolved value used for getComputedStyle() depends on layout for this
89
+ * property, which means we may need to update layout to return the correct
90
+ * value from getComputedStyle().
91
+ */
92
+ layoutDependent?: boolean;
93
+ /**
94
+ * This specifies all valid keyword values for the property.
95
+ */
96
+ keywords?: string[];
97
+ /**
98
+ * eg. strokeWidth is an alias of lineWidth
99
+ */
100
+ alias?: string[];
101
+ /**
102
+ * sort before init attributes according to this priority
103
+ */
104
+ parsePriority?: number;
105
+ /**
106
+ * eg. <color> <paint> <number>
107
+ */
108
+ syntax?: string;
109
+ }
3
110
  export declare const StyleValueRegistry: Syringe.DefinedToken;
4
111
  export interface StyleValueRegistry {
5
112
  recalc: (displayObject: DisplayObject) => void;
113
+ registerMetadata: (metadata: PropertyMetadata) => void;
114
+ unregisterMetadata: (name: string) => void;
115
+ getMetadata: (name: string) => PropertyMetadata;
6
116
  }