@antv/g-lite 1.0.33 → 1.0.35

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 (36) hide show
  1. package/dist/css/CSSProperty.d.ts +1 -1
  2. package/dist/css/CSSProperty.d.ts.map +1 -1
  3. package/dist/css/CSSStyleValuePool.d.ts +2 -5
  4. package/dist/css/CSSStyleValuePool.d.ts.map +1 -1
  5. package/dist/css/StyleValueRegistry.d.ts +1 -1
  6. package/dist/css/StyleValueRegistry.d.ts.map +1 -1
  7. package/dist/css/cssom/CSSNumericValue.d.ts +5 -185
  8. package/dist/css/cssom/CSSNumericValue.d.ts.map +1 -1
  9. package/dist/css/parser/dimension.d.ts +1 -4
  10. package/dist/css/parser/dimension.d.ts.map +1 -1
  11. package/dist/css/parser/transform-origin.d.ts.map +1 -1
  12. package/dist/css/properties/CSSPropertyLengthOrPercentage.d.ts +1 -7
  13. package/dist/css/properties/CSSPropertyLengthOrPercentage.d.ts.map +1 -1
  14. package/dist/css/properties/CSSPropertyLocalPosition.d.ts +1 -1
  15. package/dist/css/properties/CSSPropertyLocalPosition.d.ts.map +1 -1
  16. package/dist/display-objects/DisplayObject.d.ts.map +1 -1
  17. package/dist/display-objects/HTML.d.ts.map +1 -1
  18. package/dist/dom/Element.d.ts.map +1 -1
  19. package/dist/global-runtime.d.ts +1 -0
  20. package/dist/global-runtime.d.ts.map +1 -1
  21. package/dist/index.esm.js +835 -1727
  22. package/dist/index.js +883 -1775
  23. package/dist/index.umd.js +791 -1719
  24. package/dist/index.umd.min.js +1 -1
  25. package/dist/plugins/FrustumCullingStrategy.d.ts.map +1 -1
  26. package/dist/plugins/PrepareRendererPlugin.d.ts.map +1 -1
  27. package/dist/services/OffscreenCanvasCreator.d.ts +2 -2
  28. package/dist/services/OffscreenCanvasCreator.d.ts.map +1 -1
  29. package/dist/services/RenderingService.d.ts.map +1 -1
  30. package/dist/shapes/AABB.d.ts +12 -13
  31. package/dist/shapes/AABB.d.ts.map +1 -1
  32. package/dist/types.d.ts +1 -0
  33. package/dist/types.d.ts.map +1 -1
  34. package/dist/utils/math.d.ts +7 -0
  35. package/dist/utils/math.d.ts.map +1 -1
  36. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -4,9 +4,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var RBush = require('rbush/rbush.js');
6
6
  var util = require('@antv/util');
7
- var glMatrix = require('gl-matrix');
8
7
  var d3 = require('d3-color');
9
8
  var gMath = require('@antv/g-math');
9
+ var glMatrix = require('gl-matrix');
10
10
  var EventEmitter = require('eventemitter3');
11
11
 
12
12
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -31,429 +31,54 @@ var EventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(EventEmitter);
31
31
  */
32
32
  PropertySyntax["PAINT"] = "<paint>";
33
33
  /**
34
- * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#number
35
- */
36
- PropertySyntax["NUMBER"] = "<number>";
37
- /**
38
- * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/angle
39
- */
40
- PropertySyntax["ANGLE"] = "<angle>";
41
- /**
42
- * <number> with range 0..1
43
- * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#opacity_value
44
- */
45
- PropertySyntax["OPACITY_VALUE"] = "<opacity-value>";
46
- /**
47
- * <number> with range 0..Infinity
48
- */
49
- PropertySyntax["SHADOW_BLUR"] = "<shadow-blur>";
50
- /**
51
- * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#length
52
- */
53
- PropertySyntax["LENGTH"] = "<length>";
54
- /**
55
- * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#percentage
56
- */
57
- PropertySyntax["PERCENTAGE"] = "<percentage>";
58
- PropertySyntax["LENGTH_PERCENTAGE"] = "<length> | <percentage>";
59
- PropertySyntax["LENGTH_PERCENTAGE_12"] = "[<length> | <percentage>]{1,2}";
60
- /**
61
- * @see https://developer.mozilla.org/en-US/docs/Web/CSS/margin#formal_syntax
62
- */
63
- PropertySyntax["LENGTH_PERCENTAGE_14"] = "[<length> | <percentage>]{1,4}";
64
- /**
65
- * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#list-of-ts
66
- */
67
- PropertySyntax["LIST_OF_POINTS"] = "<list-of-points>";
68
- PropertySyntax["PATH"] = "<path>";
69
- /**
70
- * @see https://developer.mozilla.org/en-US/docs/Web/CSS/filter#formal_syntax
71
- */
72
- PropertySyntax["FILTER"] = "<filter>";
73
- PropertySyntax["Z_INDEX"] = "<z-index>";
74
- PropertySyntax["OFFSET_DISTANCE"] = "<offset-distance>";
75
- PropertySyntax["DEFINED_PATH"] = "<defined-path>";
76
- PropertySyntax["MARKER"] = "<marker>";
77
- PropertySyntax["TRANSFORM"] = "<transform>";
78
- PropertySyntax["TRANSFORM_ORIGIN"] = "<transform-origin>";
79
- PropertySyntax["TEXT"] = "<text>";
80
- PropertySyntax["TEXT_TRANSFORM"] = "<text-transform>";
81
- })(exports.PropertySyntax || (exports.PropertySyntax = {}));
82
-
83
- /**
84
- * Axis-Aligned Bounding Box
85
- * 为了便于后续 Frustum Culling,通过查找表定义 p-vertex 和 n-vertex
86
- * @see https://github.com/antvis/GWebGPUEngine/issues/3
87
- */
88
- var AABB = /*#__PURE__*/function () {
89
- AABB.isEmpty = function isEmpty(aabb) {
90
- return !aabb || aabb.halfExtents[0] === 0 && aabb.halfExtents[1] === 0 && aabb.halfExtents[2] === 0;
91
- };
92
- function AABB(center, halfExtents) {
93
- if (center === void 0) {
94
- center = [0, 0, 0];
95
- }
96
- if (halfExtents === void 0) {
97
- halfExtents = [0, 0, 0];
98
- }
99
- this.center = glMatrix.vec3.create();
100
- this.halfExtents = glMatrix.vec3.create();
101
- this.min = glMatrix.vec3.create();
102
- this.max = glMatrix.vec3.create();
103
- this.update(center, halfExtents);
104
- }
105
- var _proto = AABB.prototype;
106
- _proto.update = function update(center, halfExtents) {
107
- glMatrix.vec3.copy(this.center, center);
108
- glMatrix.vec3.copy(this.halfExtents, halfExtents);
109
- glMatrix.vec3.sub(this.min, this.center, this.halfExtents);
110
- glMatrix.vec3.add(this.max, this.center, this.halfExtents);
111
- };
112
- _proto.setMinMax = function setMinMax(min, max) {
113
- glMatrix.vec3.add(this.center, max, min);
114
- glMatrix.vec3.scale(this.center, this.center, 0.5);
115
- glMatrix.vec3.sub(this.halfExtents, max, min);
116
- glMatrix.vec3.scale(this.halfExtents, this.halfExtents, 0.5);
117
- glMatrix.vec3.copy(this.min, min);
118
- glMatrix.vec3.copy(this.max, max);
119
- };
120
- _proto.getMin = function getMin() {
121
- return this.min;
122
- };
123
- _proto.getMax = function getMax() {
124
- return this.max;
125
- };
126
- _proto.add = function add(aabb) {
127
- if (AABB.isEmpty(aabb)) {
128
- return;
129
- }
130
- if (AABB.isEmpty(this)) {
131
- this.setMinMax(aabb.getMin(), aabb.getMax());
132
- return;
133
- }
134
- var tc = this.center;
135
- var tcx = tc[0];
136
- var tcy = tc[1];
137
- var tcz = tc[2];
138
- var th = this.halfExtents;
139
- var thx = th[0];
140
- var thy = th[1];
141
- var thz = th[2];
142
- var tminx = tcx - thx;
143
- var tmaxx = tcx + thx;
144
- var tminy = tcy - thy;
145
- var tmaxy = tcy + thy;
146
- var tminz = tcz - thz;
147
- var tmaxz = tcz + thz;
148
- var oc = aabb.center;
149
- var ocx = oc[0];
150
- var ocy = oc[1];
151
- var ocz = oc[2];
152
- var oh = aabb.halfExtents;
153
- var ohx = oh[0];
154
- var ohy = oh[1];
155
- var ohz = oh[2];
156
- var ominx = ocx - ohx;
157
- var omaxx = ocx + ohx;
158
- var ominy = ocy - ohy;
159
- var omaxy = ocy + ohy;
160
- var ominz = ocz - ohz;
161
- var omaxz = ocz + ohz;
162
- if (ominx < tminx) {
163
- tminx = ominx;
164
- }
165
- if (omaxx > tmaxx) {
166
- tmaxx = omaxx;
167
- }
168
- if (ominy < tminy) {
169
- tminy = ominy;
170
- }
171
- if (omaxy > tmaxy) {
172
- tmaxy = omaxy;
173
- }
174
- if (ominz < tminz) {
175
- tminz = ominz;
176
- }
177
- if (omaxz > tmaxz) {
178
- tmaxz = omaxz;
179
- }
180
- tc[0] = (tminx + tmaxx) * 0.5;
181
- tc[1] = (tminy + tmaxy) * 0.5;
182
- tc[2] = (tminz + tmaxz) * 0.5;
183
- th[0] = (tmaxx - tminx) * 0.5;
184
- th[1] = (tmaxy - tminy) * 0.5;
185
- th[2] = (tmaxz - tminz) * 0.5;
186
- this.min[0] = tminx;
187
- this.min[1] = tminy;
188
- this.min[2] = tminz;
189
- this.max[0] = tmaxx;
190
- this.max[1] = tmaxy;
191
- this.max[2] = tmaxz;
192
- };
193
- _proto.setFromTransformedAABB = function setFromTransformedAABB(aabb, m) {
194
- var bc = this.center;
195
- var br = this.halfExtents;
196
- var ac = aabb.center;
197
- var ar = aabb.halfExtents;
198
- var mx0 = m[0];
199
- var mx1 = m[4];
200
- var mx2 = m[8];
201
- var my0 = m[1];
202
- var my1 = m[5];
203
- var my2 = m[9];
204
- var mz0 = m[2];
205
- var mz1 = m[6];
206
- var mz2 = m[10];
207
- var mx0a = Math.abs(mx0);
208
- var mx1a = Math.abs(mx1);
209
- var mx2a = Math.abs(mx2);
210
- var my0a = Math.abs(my0);
211
- var my1a = Math.abs(my1);
212
- var my2a = Math.abs(my2);
213
- var mz0a = Math.abs(mz0);
214
- var mz1a = Math.abs(mz1);
215
- var mz2a = Math.abs(mz2);
216
- glMatrix.vec3.set(bc, m[12] + mx0 * ac[0] + mx1 * ac[1] + mx2 * ac[2], m[13] + my0 * ac[0] + my1 * ac[1] + my2 * ac[2], m[14] + mz0 * ac[0] + mz1 * ac[1] + mz2 * ac[2]);
217
- glMatrix.vec3.set(br, mx0a * ar[0] + mx1a * ar[1] + mx2a * ar[2], my0a * ar[0] + my1a * ar[1] + my2a * ar[2], mz0a * ar[0] + mz1a * ar[1] + mz2a * ar[2]);
218
- this.min = glMatrix.vec3.sub(this.min, bc, br);
219
- this.max = glMatrix.vec3.add(this.max, bc, br);
220
- };
221
- _proto.intersects = function intersects(aabb) {
222
- var aMax = this.getMax();
223
- var aMin = this.getMin();
224
- var bMax = aabb.getMax();
225
- var bMin = aabb.getMin();
226
- return aMin[0] <= bMax[0] && aMax[0] >= bMin[0] && aMin[1] <= bMax[1] && aMax[1] >= bMin[1] && aMin[2] <= bMax[2] && aMax[2] >= bMin[2];
227
- };
228
- _proto.intersection = function intersection(aabb) {
229
- if (!this.intersects(aabb)) {
230
- return null;
231
- }
232
- var intersection = new AABB();
233
- var min = glMatrix.vec3.max(glMatrix.vec3.create(), this.getMin(), aabb.getMin());
234
- var max = glMatrix.vec3.min(glMatrix.vec3.create(), this.getMax(), aabb.getMax());
235
- intersection.setMinMax(min, max);
236
- return intersection;
237
- };
238
- _proto.containsPoint = function containsPoint(point) {
239
- var min = this.getMin();
240
- var max = this.getMax();
241
- return !(point[0] < min[0] || point[0] > max[0] || point[1] < min[1] || point[1] > max[1] || point[2] < min[2] || point[2] > max[2]);
242
- }
243
- /**
244
- * get n-vertex
245
- * @param plane plane of CullingVolume
246
- */;
247
- _proto.getNegativeFarPoint = function getNegativeFarPoint(plane) {
248
- if (plane.pnVertexFlag === 0x111) {
249
- return glMatrix.vec3.copy(glMatrix.vec3.create(), this.min);
250
- } else if (plane.pnVertexFlag === 0x110) {
251
- return glMatrix.vec3.fromValues(this.min[0], this.min[1], this.max[2]);
252
- } else if (plane.pnVertexFlag === 0x101) {
253
- return glMatrix.vec3.fromValues(this.min[0], this.max[1], this.min[2]);
254
- } else if (plane.pnVertexFlag === 0x100) {
255
- return glMatrix.vec3.fromValues(this.min[0], this.max[1], this.max[2]);
256
- } else if (plane.pnVertexFlag === 0x011) {
257
- return glMatrix.vec3.fromValues(this.max[0], this.min[1], this.min[2]);
258
- } else if (plane.pnVertexFlag === 0x010) {
259
- return glMatrix.vec3.fromValues(this.max[0], this.min[1], this.max[2]);
260
- } else if (plane.pnVertexFlag === 0x001) {
261
- return glMatrix.vec3.fromValues(this.max[0], this.max[1], this.min[2]);
262
- } else {
263
- return glMatrix.vec3.fromValues(this.max[0], this.max[1], this.max[2]);
264
- }
265
- }
266
- /**
267
- * get p-vertex
268
- * @param plane plane of CullingVolume
269
- */;
270
- _proto.getPositiveFarPoint = function getPositiveFarPoint(plane) {
271
- if (plane.pnVertexFlag === 0x111) {
272
- return glMatrix.vec3.copy(glMatrix.vec3.create(), this.max);
273
- } else if (plane.pnVertexFlag === 0x110) {
274
- return glMatrix.vec3.fromValues(this.max[0], this.max[1], this.min[2]);
275
- } else if (plane.pnVertexFlag === 0x101) {
276
- return glMatrix.vec3.fromValues(this.max[0], this.min[1], this.max[2]);
277
- } else if (plane.pnVertexFlag === 0x100) {
278
- return glMatrix.vec3.fromValues(this.max[0], this.min[1], this.min[2]);
279
- } else if (plane.pnVertexFlag === 0x011) {
280
- return glMatrix.vec3.fromValues(this.min[0], this.max[1], this.max[2]);
281
- } else if (plane.pnVertexFlag === 0x010) {
282
- return glMatrix.vec3.fromValues(this.min[0], this.max[1], this.min[2]);
283
- } else if (plane.pnVertexFlag === 0x001) {
284
- return glMatrix.vec3.fromValues(this.min[0], this.min[1], this.max[2]);
285
- } else {
286
- return glMatrix.vec3.fromValues(this.min[0], this.min[1], this.min[2]);
287
- }
288
- };
289
- return AABB;
290
- }();
291
-
292
- var Plane = /*#__PURE__*/function () {
293
- /**
294
- * lookup table for p-vertex & n-vertex when doing frustum culling
295
- */
296
-
297
- function Plane(distance, normal) {
298
- this.distance = void 0;
299
- this.normal = void 0;
300
- this.pnVertexFlag = void 0;
301
- this.distance = distance || 0;
302
- this.normal = normal || glMatrix.vec3.fromValues(0, 1, 0);
303
- this.updatePNVertexFlag();
304
- }
305
- var _proto = Plane.prototype;
306
- _proto.updatePNVertexFlag = function updatePNVertexFlag() {
307
- this.pnVertexFlag = (Number(this.normal[0] >= 0) << 8) + (Number(this.normal[1] >= 0) << 4) + Number(this.normal[2] >= 0);
308
- };
309
- _proto.distanceToPoint = function distanceToPoint(point) {
310
- return glMatrix.vec3.dot(point, this.normal) - this.distance;
311
- };
312
- _proto.normalize = function normalize() {
313
- var invLen = 1 / glMatrix.vec3.len(this.normal);
314
- glMatrix.vec3.scale(this.normal, this.normal, invLen);
315
- this.distance *= invLen;
316
- };
317
- _proto.intersectsLine = function intersectsLine(start, end, point) {
318
- var d0 = this.distanceToPoint(start);
319
- var d1 = this.distanceToPoint(end);
320
- var t = d0 / (d0 - d1);
321
- var intersects = t >= 0 && t <= 1;
322
- if (intersects && point) {
323
- glMatrix.vec3.lerp(point, start, end, t);
324
- }
325
- return intersects;
326
- };
327
- return Plane;
328
- }();
329
-
330
- (function (Mask) {
331
- Mask[Mask["OUTSIDE"] = 4294967295] = "OUTSIDE";
332
- Mask[Mask["INSIDE"] = 0] = "INSIDE";
333
- Mask[Mask["INDETERMINATE"] = 2147483647] = "INDETERMINATE";
334
- })(exports.Mask || (exports.Mask = {}));
335
- var Frustum = /*#__PURE__*/function () {
336
- function Frustum(planes) {
337
- this.planes = [];
338
- if (planes) {
339
- this.planes = planes;
340
- } else {
341
- for (var i = 0; i < 6; i++) {
342
- this.planes.push(new Plane());
343
- }
344
- }
345
- }
346
- /**
347
- * extract 6 planes from projectionMatrix
348
- * @see http://www8.cs.umu.se/kurser/5DV051/HT12/lab/plane_extraction.pdf
349
- */
350
- var _proto = Frustum.prototype;
351
- _proto.extractFromVPMatrix = function extractFromVPMatrix(projectionMatrix) {
352
- // @ts-ignore
353
- var m0 = projectionMatrix[0],
354
- m1 = projectionMatrix[1],
355
- m2 = projectionMatrix[2],
356
- m3 = projectionMatrix[3],
357
- m4 = projectionMatrix[4],
358
- m5 = projectionMatrix[5],
359
- m6 = projectionMatrix[6],
360
- m7 = projectionMatrix[7],
361
- m8 = projectionMatrix[8],
362
- m9 = projectionMatrix[9],
363
- m10 = projectionMatrix[10],
364
- m11 = projectionMatrix[11],
365
- m12 = projectionMatrix[12],
366
- m13 = projectionMatrix[13],
367
- m14 = projectionMatrix[14],
368
- m15 = projectionMatrix[15];
369
- // right
370
- glMatrix.vec3.set(this.planes[0].normal, m3 - m0, m7 - m4, m11 - m8);
371
- this.planes[0].distance = m15 - m12;
372
- // left
373
- glMatrix.vec3.set(this.planes[1].normal, m3 + m0, m7 + m4, m11 + m8);
374
- this.planes[1].distance = m15 + m12;
375
- // bottom
376
- glMatrix.vec3.set(this.planes[2].normal, m3 + m1, m7 + m5, m11 + m9);
377
- this.planes[2].distance = m15 + m13;
378
- // top
379
- glMatrix.vec3.set(this.planes[3].normal, m3 - m1, m7 - m5, m11 - m9);
380
- this.planes[3].distance = m15 - m13;
381
- // far
382
- glMatrix.vec3.set(this.planes[4].normal, m3 - m2, m7 - m6, m11 - m10);
383
- this.planes[4].distance = m15 - m14;
384
- // near
385
- glMatrix.vec3.set(this.planes[5].normal, m3 + m2, m7 + m6, m11 + m10);
386
- this.planes[5].distance = m15 + m14;
387
- this.planes.forEach(function (plane) {
388
- plane.normalize();
389
- plane.updatePNVertexFlag();
390
- });
391
- };
392
- return Frustum;
393
- }();
394
-
395
- var Point = /*#__PURE__*/function () {
396
- function Point(x, y) {
397
- if (x === void 0) {
398
- x = 0;
399
- }
400
- if (y === void 0) {
401
- y = 0;
402
- }
403
- this.x = 0;
404
- this.y = 0;
405
- this.x = x;
406
- this.y = y;
407
- }
408
- var _proto = Point.prototype;
409
- _proto.clone = function clone() {
410
- return new Point(this.x, this.y);
411
- };
412
- _proto.copyFrom = function copyFrom(p) {
413
- this.x = p.x;
414
- this.y = p.y;
415
- };
416
- return Point;
417
- }();
418
-
419
- var Rectangle = /*#__PURE__*/function () {
420
- function Rectangle(x, y, width, height) {
421
- this.x = void 0;
422
- this.y = void 0;
423
- this.width = void 0;
424
- this.height = void 0;
425
- this.left = void 0;
426
- this.right = void 0;
427
- this.top = void 0;
428
- this.bottom = void 0;
429
- this.x = x;
430
- this.y = y;
431
- this.width = width;
432
- this.height = height;
433
- this.left = x;
434
- this.right = x + width;
435
- this.top = y;
436
- this.bottom = y + height;
437
- }
438
- var _proto = Rectangle.prototype;
439
- _proto.toJSON = function toJSON() {};
440
- return Rectangle;
441
- }();
442
-
443
- (function (Shape) {
444
- Shape["GROUP"] = "g";
445
- Shape["CIRCLE"] = "circle";
446
- Shape["ELLIPSE"] = "ellipse";
447
- Shape["IMAGE"] = "image";
448
- Shape["RECT"] = "rect";
449
- Shape["LINE"] = "line";
450
- Shape["POLYLINE"] = "polyline";
451
- Shape["POLYGON"] = "polygon";
452
- Shape["TEXT"] = "text";
453
- Shape["PATH"] = "path";
454
- Shape["HTML"] = "html";
455
- Shape["MESH"] = "mesh";
456
- })(exports.Shape || (exports.Shape = {}));
34
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#number
35
+ */
36
+ PropertySyntax["NUMBER"] = "<number>";
37
+ /**
38
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/angle
39
+ */
40
+ PropertySyntax["ANGLE"] = "<angle>";
41
+ /**
42
+ * <number> with range 0..1
43
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#opacity_value
44
+ */
45
+ PropertySyntax["OPACITY_VALUE"] = "<opacity-value>";
46
+ /**
47
+ * <number> with range 0..Infinity
48
+ */
49
+ PropertySyntax["SHADOW_BLUR"] = "<shadow-blur>";
50
+ /**
51
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#length
52
+ */
53
+ PropertySyntax["LENGTH"] = "<length>";
54
+ /**
55
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#percentage
56
+ */
57
+ PropertySyntax["PERCENTAGE"] = "<percentage>";
58
+ PropertySyntax["LENGTH_PERCENTAGE"] = "<length> | <percentage>";
59
+ PropertySyntax["LENGTH_PERCENTAGE_12"] = "[<length> | <percentage>]{1,2}";
60
+ /**
61
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/margin#formal_syntax
62
+ */
63
+ PropertySyntax["LENGTH_PERCENTAGE_14"] = "[<length> | <percentage>]{1,4}";
64
+ /**
65
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#list-of-ts
66
+ */
67
+ PropertySyntax["LIST_OF_POINTS"] = "<list-of-points>";
68
+ PropertySyntax["PATH"] = "<path>";
69
+ /**
70
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/filter#formal_syntax
71
+ */
72
+ PropertySyntax["FILTER"] = "<filter>";
73
+ PropertySyntax["Z_INDEX"] = "<z-index>";
74
+ PropertySyntax["OFFSET_DISTANCE"] = "<offset-distance>";
75
+ PropertySyntax["DEFINED_PATH"] = "<defined-path>";
76
+ PropertySyntax["MARKER"] = "<marker>";
77
+ PropertySyntax["TRANSFORM"] = "<transform>";
78
+ PropertySyntax["TRANSFORM_ORIGIN"] = "<transform-origin>";
79
+ PropertySyntax["TEXT"] = "<text>";
80
+ PropertySyntax["TEXT_TRANSFORM"] = "<text-transform>";
81
+ })(exports.PropertySyntax || (exports.PropertySyntax = {}));
457
82
 
458
83
  function memoize(func, resolver) {
459
84
  if (typeof func !== 'function' || resolver != null && typeof resolver !== 'function') {
@@ -491,16 +116,6 @@ function DCHECK(bool) {
491
116
  throw new Error();
492
117
  }
493
118
  }
494
- function DCHECK_EQ(a, b) {
495
- if (a !== b) {
496
- throw new Error();
497
- }
498
- }
499
- function DCHECK_NE(a, b) {
500
- if (a === b) {
501
- throw new Error();
502
- }
503
- }
504
119
  function isFunction(func) {
505
120
  return typeof func === 'function';
506
121
  }
@@ -1662,649 +1277,106 @@ var CSSColorValue = /*#__PURE__*/function (_CSSStyleValue) {
1662
1277
  function CSSColorValue(colorSpace) {
1663
1278
  var _this;
1664
1279
  _this = _CSSStyleValue.call(this) || this;
1665
- _this.colorSpace = void 0;
1666
- _this.colorSpace = colorSpace;
1667
- return _this;
1668
- }
1669
- var _proto = CSSColorValue.prototype;
1670
- _proto.getType = function getType() {
1671
- return CSSStyleValueType.kColorType;
1672
- }
1673
- // buildCSSText(n: Nested, p: ParenLess, result: string): string {
1674
- // let text = '';
1675
- // if (this.colorSpace === 'rgb') {
1676
- // text = `rgba(${this.channels.join(',')},${this.alpha})`;
1677
- // }
1678
- // return (result += text);
1679
- // }
1680
- /**
1681
- * @see https://drafts.css-houdini.org/css-typed-om-1/#dom-csscolorvalue-to
1682
- */;
1683
- _proto.to = function to(colorSpace) {
1684
- return this;
1685
- };
1686
- return CSSColorValue;
1687
- }(CSSStyleValue);
1688
-
1689
- (function (GradientType) {
1690
- GradientType[GradientType["Constant"] = 0] = "Constant";
1691
- GradientType[GradientType["LinearGradient"] = 1] = "LinearGradient";
1692
- GradientType[GradientType["RadialGradient"] = 2] = "RadialGradient";
1693
- })(exports.GradientType || (exports.GradientType = {}));
1694
- var CSSGradientValue = /*#__PURE__*/function (_CSSStyleValue) {
1695
- _inheritsLoose(CSSGradientValue, _CSSStyleValue);
1696
- function CSSGradientValue(type, value) {
1697
- var _this;
1698
- _this = _CSSStyleValue.call(this) || this;
1699
- _this.type = void 0;
1700
- _this.value = void 0;
1701
- _this.type = type;
1702
- _this.value = value;
1703
- return _this;
1704
- }
1705
- var _proto = CSSGradientValue.prototype;
1706
- _proto.clone = function clone() {
1707
- return new CSSGradientValue(this.type, this.value);
1708
- };
1709
- _proto.buildCSSText = function buildCSSText(n, p, result) {
1710
- return result;
1711
- };
1712
- _proto.getType = function getType() {
1713
- return CSSStyleValueType.kColorType;
1714
- };
1715
- return CSSGradientValue;
1716
- }(CSSStyleValue);
1717
-
1718
- /**
1719
- * CSSKeywordValue represents CSS Values that are specified as keywords
1720
- * eg. 'initial'
1721
- * @see https://developer.mozilla.org/en-US/docs/Web/API/CSSKeywordValue
1722
- * @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_keyword_value.idl
1723
- */
1724
- var CSSKeywordValue = /*#__PURE__*/function (_CSSStyleValue) {
1725
- _inheritsLoose(CSSKeywordValue, _CSSStyleValue);
1726
- function CSSKeywordValue(value) {
1727
- var _this;
1728
- _this = _CSSStyleValue.call(this) || this;
1729
- _this.value = void 0;
1730
- _this.value = value;
1731
- return _this;
1732
- }
1733
- var _proto = CSSKeywordValue.prototype;
1734
- _proto.clone = function clone() {
1735
- return new CSSKeywordValue(this.value);
1736
- };
1737
- _proto.getType = function getType() {
1738
- return CSSStyleValueType.kKeywordType;
1739
- };
1740
- _proto.buildCSSText = function buildCSSText(n, p, result) {
1741
- return result + this.value;
1742
- };
1743
- return CSSKeywordValue;
1744
- }(CSSStyleValue);
1745
-
1746
- var CSSMathOperator;
1747
- (function (CSSMathOperator) {
1748
- CSSMathOperator["kAdd"] = "+";
1749
- CSSMathOperator["kSubtract"] = "-";
1750
- CSSMathOperator["kMultiply"] = "*";
1751
- CSSMathOperator["kDivide"] = "/";
1752
- CSSMathOperator["kMin"] = "min";
1753
- CSSMathOperator["kMax"] = "max";
1754
- CSSMathOperator["kClamp"] = "clamp";
1755
- CSSMathOperator["kInvalid"] = "";
1756
- })(CSSMathOperator || (CSSMathOperator = {}));
1757
-
1758
- // https://drafts.css-houdini.org/css-typed-om/#enumdef-cssnumericbasetype
1759
- var BaseType;
1760
- (function (BaseType) {
1761
- BaseType[BaseType["kLength"] = 0] = "kLength";
1762
- BaseType[BaseType["kAngle"] = 1] = "kAngle";
1763
- BaseType[BaseType["kTime"] = 2] = "kTime";
1764
- BaseType[BaseType["kFrequency"] = 3] = "kFrequency";
1765
- BaseType[BaseType["kResolution"] = 4] = "kResolution";
1766
- BaseType[BaseType["kFlex"] = 5] = "kFlex";
1767
- BaseType[BaseType["kPercent"] = 6] = "kPercent";
1768
- BaseType[BaseType["kNumBaseTypes"] = 7] = "kNumBaseTypes";
1769
- })(BaseType || (BaseType = {}));
1770
- function unitTypeToBaseType(unit) {
1771
- DCHECK_NE(unit, exports.UnitType.kNumber);
1772
- switch (unit) {
1773
- case exports.UnitType.kEms:
1774
- // case UnitType.kExs:
1775
- case exports.UnitType.kPixels:
1776
- // case UnitType.kCentimeters:
1777
- // case UnitType.kMillimeters:
1778
- // case UnitType.kQuarterMillimeters:
1779
- // case UnitType.kInches:
1780
- // case UnitType.kPoints:
1781
- // case UnitType.kPicas:
1782
- // case UnitType.kUserUnits:
1783
- // case UnitType.kViewportWidth:
1784
- // case UnitType.kViewportHeight:
1785
- // case UnitType.kViewportInlineSize:
1786
- // case UnitType.kViewportBlockSize:
1787
- // case UnitType.kViewportMin:
1788
- // case UnitType.kViewportMax:
1789
- // case UnitType.kSmallViewportWidth:
1790
- // case UnitType.kSmallViewportHeight:
1791
- // case UnitType.kSmallViewportInlineSize:
1792
- // case UnitType.kSmallViewportBlockSize:
1793
- // case UnitType.kSmallViewportMin:
1794
- // case UnitType.kSmallViewportMax:
1795
- // case UnitType.kLargeViewportWidth:
1796
- // case UnitType.kLargeViewportHeight:
1797
- // case UnitType.kLargeViewportInlineSize:
1798
- // case UnitType.kLargeViewportBlockSize:
1799
- // case UnitType.kLargeViewportMin:
1800
- // case UnitType.kLargeViewportMax:
1801
- // case UnitType.kDynamicViewportWidth:
1802
- // case UnitType.kDynamicViewportHeight:
1803
- // case UnitType.kDynamicViewportInlineSize:
1804
- // case UnitType.kDynamicViewportBlockSize:
1805
- // case UnitType.kDynamicViewportMin:
1806
- // case UnitType.kDynamicViewportMax:
1807
- // case UnitType.kContainerWidth:
1808
- // case UnitType.kContainerHeight:
1809
- // case UnitType.kContainerInlineSize:
1810
- // case UnitType.kContainerBlockSize:
1811
- // case UnitType.kContainerMin:
1812
- // case UnitType.kContainerMax:
1813
- case exports.UnitType.kRems:
1814
- // case UnitType.kChs:
1815
- return BaseType.kLength;
1816
- case exports.UnitType.kMilliseconds:
1817
- case exports.UnitType.kSeconds:
1818
- return BaseType.kTime;
1819
- case exports.UnitType.kDegrees:
1820
- case exports.UnitType.kRadians:
1821
- case exports.UnitType.kGradians:
1822
- case exports.UnitType.kTurns:
1823
- return BaseType.kAngle;
1824
- // case UnitType.kHertz:
1825
- // case UnitType.kKilohertz:
1826
- // return BaseType.kFrequency;
1827
- // case UnitType.kDotsPerPixel:
1828
- // case UnitType.kDotsPerInch:
1829
- // case UnitType.kDotsPerCentimeter:
1830
- // return BaseType.kResolution;
1831
- // case UnitType.kFraction:
1832
- // return BaseType.kFlex;
1833
- case exports.UnitType.kPercentage:
1834
- return BaseType.kPercent;
1835
- default:
1836
- return BaseType.kLength;
1837
- }
1838
- }
1839
- function baseTypeToString(baseType) {
1840
- switch (baseType) {
1841
- case BaseType.kLength:
1842
- return 'length';
1843
- case BaseType.kAngle:
1844
- return 'angle';
1845
- case BaseType.kTime:
1846
- return 'time';
1847
- case BaseType.kFrequency:
1848
- return 'frequency';
1849
- case BaseType.kResolution:
1850
- return 'resolution';
1851
- case BaseType.kFlex:
1852
- return 'flex';
1853
- case BaseType.kPercent:
1854
- return 'percent';
1855
- }
1856
- return '';
1857
- }
1858
- var CSSNumericValueType = /*#__PURE__*/function () {
1859
- function CSSNumericValueType(unit, exponent) {
1860
- if (unit === void 0) {
1861
- unit = exports.UnitType.kNumber;
1862
- }
1863
- if (exponent === void 0) {
1864
- exponent = 1;
1865
- }
1866
- this.exponents = [];
1867
- this.numNonZeroEntries = 0;
1868
- this.percentHint = BaseType.kPercent;
1869
- this.hasPercentHint = false;
1870
- this.exponents = new Array(BaseType.kNumBaseTypes).fill(0);
1871
- if (unit !== exports.UnitType.kNumber) {
1872
- this.setExponent(unitTypeToBaseType(unit), exponent);
1873
- }
1874
- }
1875
- var _proto = CSSNumericValueType.prototype;
1876
- _proto.applyPercentHint = function applyPercentHint(hint) {
1877
- DCHECK_NE(hint, BaseType.kPercent);
1878
- this.setExponent(hint, this.exponent(hint) + this.exponent(BaseType.kPercent));
1879
- this.setExponent(BaseType.kPercent, 0);
1880
- this.percentHint = hint;
1881
- this.hasPercentHint = true;
1882
- };
1883
- _proto.hasNonZeroEntries = function hasNonZeroEntries() {
1884
- return this.numNonZeroEntries > 0;
1885
- };
1886
- _proto.isOnlyNonZeroEntry = function isOnlyNonZeroEntry(baseType, value) {
1887
- DCHECK_NE(value, 0);
1888
- return this.numNonZeroEntries === 1 && this.exponent(baseType) === value;
1889
- };
1890
- _proto.exponent = function exponent(type) {
1891
- return this.exponents[type];
1892
- };
1893
- _proto.setExponent = function setExponent(type, newValue) {
1894
- var oldValue = this.exponents[type];
1895
- if (oldValue == 0 && newValue !== 0) {
1896
- this.numNonZeroEntries++;
1897
- } else if (oldValue !== 0 && newValue == 0) {
1898
- this.numNonZeroEntries--;
1899
- }
1900
- this.exponents[type] = newValue;
1901
- };
1902
- CSSNumericValueType.negateExponents = function negateExponents(type) {
1903
- type.exponents.forEach(function (v) {
1904
- return v *= -1;
1905
- });
1906
- return type;
1907
- };
1908
- _proto.matchesBaseType = function matchesBaseType(baseType) {
1909
- DCHECK_NE(baseType, BaseType.kPercent);
1910
- return this.isOnlyNonZeroEntry(baseType, 1) && !this.hasPercentHint;
1911
- };
1912
- _proto.matchesPercentage = function matchesPercentage() {
1913
- return this.isOnlyNonZeroEntry(BaseType.kPercent, 1);
1914
- };
1915
- _proto.matchesBaseTypePercentage = function matchesBaseTypePercentage(baseType) {
1916
- DCHECK_NE(baseType, BaseType.kPercent);
1917
- return this.isOnlyNonZeroEntry(baseType, 1) || this.isOnlyNonZeroEntry(BaseType.kPercent, 1);
1918
- };
1919
- _proto.matchesNumber = function matchesNumber() {
1920
- return !this.hasNonZeroEntries() && !this.hasPercentHint;
1921
- };
1922
- _proto.matchesNumberPercentage = function matchesNumberPercentage() {
1923
- return !this.hasNonZeroEntries() || this.isOnlyNonZeroEntry(BaseType.kPercent, 1);
1924
- };
1925
- CSSNumericValueType.add = function add(type1, type2, error) {
1926
- if (type1.hasPercentHint && type2.hasPercentHint && type1.percentHint != type2.percentHint) {
1927
- return type1;
1928
- }
1929
- if (type1.hasPercentHint) type2.applyPercentHint(type1.percentHint);else if (type2.hasPercentHint) type1.applyPercentHint(type2.percentHint);
1930
- DCHECK_EQ(type1.percentHint, type2.percentHint);
1931
- // Match up base types. Try to use the percent hint to match up any
1932
- // differences.
1933
- for (var i = 0; i < BaseType.kNumBaseTypes; ++i) {
1934
- var base_type = i;
1935
- if (type1.exponents[i] !== type2.exponents[i]) {
1936
- if (base_type !== BaseType.kPercent) {
1937
- type1.applyPercentHint(base_type);
1938
- type2.applyPercentHint(base_type);
1939
- }
1940
- if (type1.exponents[i] !== type2.exponents[i]) {
1941
- return type1;
1942
- }
1943
- }
1944
- }
1945
- return type1;
1946
- };
1947
- CSSNumericValueType.multiply = function multiply(type1, type2, error) {
1948
- if (type1.hasPercentHint && type2.hasPercentHint && type1.percentHint != type2.percentHint) {
1949
- return type1;
1950
- }
1951
- if (type1.hasPercentHint) type2.applyPercentHint(type1.percentHint);else if (type2.hasPercentHint) type1.applyPercentHint(type2.percentHint);
1952
- for (var i = 0; i < BaseType.kNumBaseTypes; ++i) {
1953
- var base_type = i;
1954
- type1.setExponent(base_type, type1.exponent(base_type) + type2.exponent(base_type));
1955
- }
1956
- return type1;
1957
- };
1958
- return CSSNumericValueType;
1959
- }();
1960
- var fromNumberish = function fromNumberish(value) {
1961
- if (typeof value === 'number') {
1962
- return new CSSUnitValue(value, exports.UnitType.kNumber);
1963
- }
1964
- return value;
1965
- };
1966
- /**
1967
- * CSSNumericValue is the base class for numeric and length typed CSS Values.
1968
- * @see https://drafts.css-houdini.org/css-typed-om/#numeric-objects
1969
- * @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue
1970
- * @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_numeric_value.idl
1971
- */
1972
- var CSSNumericValue = /*#__PURE__*/function (_CSSStyleValue) {
1973
- _inheritsLoose(CSSNumericValue, _CSSStyleValue);
1974
- /**
1975
- * @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_numeric_value.cc#296
1976
- */
1977
- // static fromPercentish(value: CSSNumberish): CSSNumericValue {
1978
- // if (typeof value === 'number') {
1979
- // return new CSSUnitValue(value * 100, UnitType.kPercentage);
1980
- // }
1981
- // return value;
1982
- // }
1983
- function CSSNumericValue(type_) {
1984
- var _this;
1985
- _this = _CSSStyleValue.call(this) || this;
1986
- _this.type_ = void 0;
1987
- _this.type_ = type_;
1988
- return _this;
1989
- }
1990
- var _proto2 = CSSNumericValue.prototype;
1991
- _proto2.getType = function getType() {
1992
- return CSSStyleValueType.kUnknownType;
1993
- }
1994
- // toCSSValue() {
1995
- // return null;
1996
- // }
1997
- /**
1998
- * @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue/equals
1999
- */;
2000
- _proto2.equals = function equals() {
2001
- var _this2 = this;
2002
- for (var _len = arguments.length, numberishes = new Array(_len), _key = 0; _key < _len; _key++) {
2003
- numberishes[_key] = arguments[_key];
2004
- }
2005
- var values = cssNumberishesToNumericValues(numberishes);
2006
- return values.every(function (value) {
2007
- return _this2.equals(value);
2008
- });
2009
- }
2010
- /**
2011
- * @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_numeric_value.cc#439
2012
- */;
2013
- _proto2.add = function add() {
2014
- for (var _len2 = arguments.length, numberishes = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
2015
- numberishes[_key2] = arguments[_key2];
2016
- }
2017
- var values = cssNumberishesToNumericValues(numberishes);
2018
- prependValueForArithmetic(CSSStyleValueType.kSumType, values, this);
2019
- // eg. 1px + 2px = 3px
2020
- var unitValue = maybeSimplifyAsUnitValue(values, CSSMathOperator.kAdd);
2021
- if (unitValue) {
2022
- return unitValue;
2023
- }
2024
- return CSSMathSum.create(values);
2025
- }
2026
- /**
2027
- * @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_numeric_value.cc#452
2028
- */;
2029
- _proto2.sub = function sub() {
2030
- for (var _len3 = arguments.length, numberishes = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
2031
- numberishes[_key3] = arguments[_key3];
2032
- }
2033
- var values = cssNumberishesToNumericValues(numberishes);
2034
- values = values.map(function (value) {
2035
- return value.negate();
2036
- });
2037
- prependValueForArithmetic(CSSStyleValueType.kSumType, values, this);
2038
- // eg. 3px - 2px = 1px
2039
- var unitValue = maybeSimplifyAsUnitValue(values, CSSMathOperator.kAdd);
2040
- if (unitValue) {
2041
- return unitValue;
2042
- }
2043
- return CSSMathSum.create(values);
2044
- }
2045
- /**
2046
- * @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue/mul
2047
- */;
2048
- _proto2.mul = function mul() {
2049
- for (var _len4 = arguments.length, numberishes = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
2050
- numberishes[_key4] = arguments[_key4];
2051
- }
2052
- var values = cssNumberishesToNumericValues(numberishes);
2053
- prependValueForArithmetic(CSSStyleValueType.kProductType, values, this);
2054
- var unitValue = maybeMultiplyAsUnitValue(values);
2055
- if (unitValue) {
2056
- return unitValue;
2057
- }
2058
- return CSSMathProduct.create(values);
2059
- }
2060
- /**
2061
- * eg. calc(24px / 4%)
2062
- * @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue/div
2063
- */;
2064
- _proto2.div = function div() {
2065
- for (var _len5 = arguments.length, numberishes = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
2066
- numberishes[_key5] = arguments[_key5];
2067
- }
2068
- var values = cssNumberishesToNumericValues(numberishes);
2069
- values = values.map(function (value) {
2070
- return value.invert();
2071
- });
2072
- prependValueForArithmetic(CSSStyleValueType.kProductType, values, this);
2073
- var unitValue = maybeMultiplyAsUnitValue(values);
2074
- if (unitValue) {
2075
- return unitValue;
2076
- }
2077
- return CSSMathProduct.create(values);
2078
- };
2079
- _proto2.min = function min() {
2080
- for (var _len6 = arguments.length, numberishes = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
2081
- numberishes[_key6] = arguments[_key6];
2082
- }
2083
- var values = cssNumberishesToNumericValues(numberishes);
2084
- prependValueForArithmetic(CSSStyleValueType.kMinType, values, this);
2085
- var unitValue = maybeSimplifyAsUnitValue(values, CSSMathOperator.kMin);
2086
- if (unitValue) {
2087
- return unitValue;
2088
- }
2089
- return CSSMathMin.create(values);
2090
- };
2091
- _proto2.max = function max() {
2092
- for (var _len7 = arguments.length, numberishes = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
2093
- numberishes[_key7] = arguments[_key7];
2094
- }
2095
- var values = cssNumberishesToNumericValues(numberishes);
2096
- prependValueForArithmetic(CSSStyleValueType.kMaxType, values, this);
2097
- var unitValue = maybeSimplifyAsUnitValue(values, CSSMathOperator.kMax);
2098
- if (unitValue) {
2099
- return unitValue;
2100
- }
2101
- return CSSMathMax.create(values);
2102
- }
2103
- /**
2104
- * @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue/to
2105
- * @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_numeric_value.cc#331
2106
- */;
2107
- _proto2.to = function to(unitOrName) {
2108
- var sum = this.sumValue();
2109
- if (sum.length === 0 || sum.length !== 1) return null;
2110
- var value = cssNumericSumValueEntryToUnitValue(sum[0]);
2111
- if (!value) return null;
2112
- var unit;
2113
- if (typeof unitOrName === 'string') {
2114
- unit = unitFromName(unitOrName);
2115
- } else {
2116
- unit = unitOrName;
2117
- }
2118
- return value.convertTo(unit);
2119
- }
2120
- /**
2121
- * converts the object's value to a CSSMathSum object to values of the specified unit.
2122
- * @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue/toSum
2123
- */;
2124
- _proto2.toSum = function toSum() {
2125
- for (var _len8 = arguments.length, unit_strings = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
2126
- unit_strings[_key8] = arguments[_key8];
2127
- }
2128
- for (var _i = 0, _unit_strings = unit_strings; _i < _unit_strings.length; _i++) {
2129
- var unit_string = _unit_strings[_i];
2130
- if (!CSSNumericValue.isValidUnit(unitFromName(unit_string))) {
2131
- return null;
2132
- }
2133
- }
2134
- var sum = this.sumValue();
2135
- if (!sum.length) {
2136
- return null;
2137
- }
2138
- var values = [];
2139
- for (var _iterator = _createForOfIteratorHelperLoose(sum), _step; !(_step = _iterator()).done;) {
2140
- var term = _step.value;
2141
- var value = cssNumericSumValueEntryToUnitValue(term);
2142
- if (!value) {
2143
- return null;
2144
- }
2145
- values.push(value);
2146
- }
2147
- if (unit_strings.length === 0) {
2148
- values.sort(function (a, b) {
2149
- return a.unit - b.unit;
2150
- });
2151
- // We got 'values' from a sum value, so it must be a valid CSSMathSum.
2152
- var _result = CSSMathSum.create(values);
2153
- DCHECK(!!_result);
2154
- return _result;
2155
- }
2156
- var result = [];
2157
- var _loop = function _loop() {
2158
- var unit_string = _unit_strings2[_i2];
2159
- var target_unit = unitFromName(unit_string);
2160
- DCHECK(CSSNumericValue.isValidUnit(target_unit));
2161
- // Collect all the terms that are compatible with this unit.
2162
- // We mark used terms as null so we don't use them again.
2163
- var total_value = values.reduce(function (cur_sum, value, i) {
2164
- if (value) {
2165
- var unit_value = value;
2166
- var converted_value = unit_value.convertTo(target_unit);
2167
- if (converted_value) {
2168
- cur_sum += converted_value.value;
2169
- values[i] = null;
2170
- }
2171
- }
2172
- return cur_sum;
2173
- }, 0);
2174
- result.push(new CSSUnitValue(total_value, target_unit));
2175
- };
2176
- for (var _i2 = 0, _unit_strings2 = unit_strings; _i2 < _unit_strings2.length; _i2++) {
2177
- _loop();
2178
- }
2179
- if (values.some(function (v) {
2180
- return !!v;
2181
- })) {
2182
- throw new Error('There were leftover terms that were not converted');
2183
- }
2184
- return CSSMathSum.create(result);
1280
+ _this.colorSpace = void 0;
1281
+ _this.colorSpace = colorSpace;
1282
+ return _this;
1283
+ }
1284
+ var _proto = CSSColorValue.prototype;
1285
+ _proto.getType = function getType() {
1286
+ return CSSStyleValueType.kColorType;
2185
1287
  }
1288
+ // buildCSSText(n: Nested, p: ParenLess, result: string): string {
1289
+ // let text = '';
1290
+ // if (this.colorSpace === 'rgb') {
1291
+ // text = `rgba(${this.channels.join(',')},${this.alpha})`;
1292
+ // }
1293
+ // return (result += text);
1294
+ // }
2186
1295
  /**
2187
- * @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue/type
2188
- * @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_numeric_value.cc#414
1296
+ * @see https://drafts.css-houdini.org/css-typed-om-1/#dom-csscolorvalue-to
2189
1297
  */;
2190
- _proto2.type = function type() {
2191
- var type = {
2192
- length: 0,
2193
- angle: 0,
2194
- time: 0,
2195
- frequency: 0,
2196
- resolution: 0,
2197
- flex: 0,
2198
- percent: 0,
2199
- percentHint: 'length'
2200
- };
2201
- var exponent = this.type_.exponent(BaseType.kLength);
2202
- if (exponent) {
2203
- type.length = exponent;
2204
- }
2205
- exponent = this.type_.exponent(BaseType.kAngle);
2206
- if (exponent) {
2207
- type.angle = exponent;
2208
- }
2209
- exponent = this.type_.exponent(BaseType.kTime);
2210
- if (exponent) {
2211
- type.time = exponent;
2212
- }
2213
- exponent = this.type_.exponent(BaseType.kFrequency);
2214
- if (exponent) {
2215
- type.frequency = exponent;
2216
- }
2217
- exponent = this.type_.exponent(BaseType.kResolution);
2218
- if (exponent) {
2219
- type.resolution = exponent;
2220
- }
2221
- exponent = this.type_.exponent(BaseType.kFlex);
2222
- if (exponent) {
2223
- type.flex = exponent;
2224
- }
2225
- exponent = this.type_.exponent(BaseType.kPercent);
2226
- if (exponent) {
2227
- type.percent = exponent;
2228
- }
2229
- if (this.type_.hasPercentHint) {
2230
- type.percentHint = baseTypeToString(this.type_.percentHint);
2231
- }
2232
- return type;
2233
- };
2234
- CSSNumericValue.isValidUnit = function isValidUnit(unit) {
2235
- // if (unit === UnitType.kUserUnits) return false;
2236
- if (unit === exports.UnitType.kNumber || unit == exports.UnitType.kPercentage || this.isLength(unit) || this.isAngle(unit) || this.isTime(unit)
2237
- // this.isFrequency(unit) ||
2238
- // this.isResolution(unit) ||
2239
- // this.isFlex(unit)
2240
- ) return true;
2241
- return false;
1298
+ _proto.to = function to(colorSpace) {
1299
+ return this;
1300
+ };
1301
+ return CSSColorValue;
1302
+ }(CSSStyleValue);
1303
+
1304
+ (function (GradientType) {
1305
+ GradientType[GradientType["Constant"] = 0] = "Constant";
1306
+ GradientType[GradientType["LinearGradient"] = 1] = "LinearGradient";
1307
+ GradientType[GradientType["RadialGradient"] = 2] = "RadialGradient";
1308
+ })(exports.GradientType || (exports.GradientType = {}));
1309
+ var CSSGradientValue = /*#__PURE__*/function (_CSSStyleValue) {
1310
+ _inheritsLoose(CSSGradientValue, _CSSStyleValue);
1311
+ function CSSGradientValue(type, value) {
1312
+ var _this;
1313
+ _this = _CSSStyleValue.call(this) || this;
1314
+ _this.type = void 0;
1315
+ _this.value = void 0;
1316
+ _this.type = type;
1317
+ _this.value = value;
1318
+ return _this;
1319
+ }
1320
+ var _proto = CSSGradientValue.prototype;
1321
+ _proto.clone = function clone() {
1322
+ return new CSSGradientValue(this.type, this.value);
2242
1323
  };
2243
- _proto2.negate = function negate() {
2244
- return CSSMathNegate.create(this);
1324
+ _proto.buildCSSText = function buildCSSText(n, p, result) {
1325
+ return result;
2245
1326
  };
2246
- _proto2.invert = function invert() {
2247
- return CSSMathInvert.create(this);
1327
+ _proto.getType = function getType() {
1328
+ return CSSStyleValueType.kColorType;
2248
1329
  };
2249
- return CSSNumericValue;
1330
+ return CSSGradientValue;
2250
1331
  }(CSSStyleValue);
2251
- function cssNumberishesToNumericValues(values) {
2252
- return values.map(fromNumberish);
2253
- }
2254
- function prependValueForArithmetic(type, values, value) {
2255
- DCHECK(!!value);
2256
- if (value.getType() === type) {
2257
- values.unshift.apply(values, value.numericValues());
2258
- } else {
2259
- values.unshift(value);
2260
- }
2261
- }
2262
- function cssNumericSumValueEntryToUnitValue(term) {
2263
- if (Object.keys(term.units).length === 0) {
2264
- return new CSSUnitValue(term.value);
2265
- }
2266
- if (Object.keys(term.units).length === 1 && term.units[Object.keys(term.units)[0]] === 1) {
2267
- return new CSSUnitValue(term.value, Number(Object.keys(term.units)[0]));
1332
+
1333
+ /**
1334
+ * CSSKeywordValue represents CSS Values that are specified as keywords
1335
+ * eg. 'initial'
1336
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/CSSKeywordValue
1337
+ * @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_keyword_value.idl
1338
+ */
1339
+ var CSSKeywordValue = /*#__PURE__*/function (_CSSStyleValue) {
1340
+ _inheritsLoose(CSSKeywordValue, _CSSStyleValue);
1341
+ function CSSKeywordValue(value) {
1342
+ var _this;
1343
+ _this = _CSSStyleValue.call(this) || this;
1344
+ _this.value = void 0;
1345
+ _this.value = value;
1346
+ return _this;
2268
1347
  }
2269
- return null;
2270
- }
2271
- function maybeSimplifyAsUnitValue(values, operator) {
2272
- DCHECK(!!values.length);
2273
- var first_unit_value = values[0] instanceof CSSUnitValue ? values[0] : null;
2274
- if (!first_unit_value) return null;
2275
- var final_value = first_unit_value.value;
2276
- for (var i = 1; i < values.length; i++) {
2277
- var unit_value = values[i] instanceof CSSUnitValue ? values[i] : null;
2278
- if (!unit_value || unit_value.unit !== first_unit_value.unit) return null;
2279
- if (operator === CSSMathOperator.kAdd) {
2280
- final_value += unit_value.value;
2281
- } else if (operator === CSSMathOperator.kMax) {
2282
- final_value = Math.max(final_value, unit_value.value);
2283
- } else if (operator === CSSMathOperator.kMin) {
2284
- final_value = Math.min(final_value, unit_value.value);
2285
- }
2286
- }
2287
- return new CSSUnitValue(final_value, first_unit_value.unit);
2288
- }
2289
- function maybeMultiplyAsUnitValue(values) {
2290
- DCHECK(!!values.length);
2291
- // We are allowed one unit value with type other than kNumber.
2292
- var unit_other_than_number = exports.UnitType.kNumber;
2293
- var final_value = 1.0;
2294
- for (var i = 0; i < values.length; i++) {
2295
- var unit_value = values[i] instanceof CSSUnitValue ? values[i] : null;
2296
- if (!unit_value) return null;
2297
- if (unit_value.unit !== exports.UnitType.kNumber) {
2298
- if (unit_other_than_number !== exports.UnitType.kNumber) return null;
2299
- unit_other_than_number = unit_value.unit;
2300
- }
2301
- final_value *= unit_value.value;
2302
- }
2303
- return new CSSUnitValue(final_value, unit_other_than_number);
2304
- }
2305
- var toCanonicalUnit = function toCanonicalUnit(unit) {
2306
- return canonicalUnitTypeForCategory(unitTypeToUnitCategory(unit));
2307
- };
1348
+ var _proto = CSSKeywordValue.prototype;
1349
+ _proto.clone = function clone() {
1350
+ return new CSSKeywordValue(this.value);
1351
+ };
1352
+ _proto.getType = function getType() {
1353
+ return CSSStyleValueType.kKeywordType;
1354
+ };
1355
+ _proto.buildCSSText = function buildCSSText(n, p, result) {
1356
+ return result + this.value;
1357
+ };
1358
+ return CSSKeywordValue;
1359
+ }(CSSStyleValue);
1360
+
1361
+ // type CSSNumericBaseType =
1362
+ // | 'length'
1363
+ // | 'angle'
1364
+ // | 'time'
1365
+ // | 'frequency'
1366
+ // | 'resolution'
1367
+ // | 'flex'
1368
+ // | 'percent';
1369
+ // https://drafts.css-houdini.org/css-typed-om/#dictdef-cssnumerictype
1370
+ // interface CSSNumericType {
1371
+ // length: number;
1372
+ // angle: number;
1373
+ // time: number;
1374
+ // frequency: number;
1375
+ // resolution: number;
1376
+ // flex: number;
1377
+ // percent: number;
1378
+ // percentHint: CSSNumericBaseType;
1379
+ // }
2308
1380
  var formatInfinityOrNaN = function formatInfinityOrNaN(number, suffix) {
2309
1381
  if (suffix === void 0) {
2310
1382
  suffix = '';
@@ -2318,49 +1390,52 @@ var formatInfinityOrNaN = function formatInfinityOrNaN(number, suffix) {
2318
1390
  }
2319
1391
  return result += suffix;
2320
1392
  };
2321
- var toCanonicalUnitIfPossible = function toCanonicalUnitIfPossible(unit) {
2322
- var canonical_unit = toCanonicalUnit(unit);
2323
- if (canonical_unit === exports.UnitType.kUnknown) return unit;
2324
- return canonical_unit;
1393
+ var toCanonicalUnit = function toCanonicalUnit(unit) {
1394
+ return canonicalUnitTypeForCategory(unitTypeToUnitCategory(unit));
2325
1395
  };
1396
+ /**
1397
+ * CSSNumericValue is the base class for numeric and length typed CSS Values.
1398
+ * @see https://drafts.css-houdini.org/css-typed-om/#numeric-objects
1399
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue
1400
+ * @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_numeric_value.idl
1401
+ */
2326
1402
  /**
2327
1403
  * Represents numeric values that can be expressed as a single number plus a
2328
1404
  * unit (or a naked number or percentage).
2329
1405
  * @see https://drafts.css-houdini.org/css-typed-om/#cssunitvalue
2330
1406
  */
2331
- var CSSUnitValue = /*#__PURE__*/function (_CSSNumericValue) {
2332
- _inheritsLoose(CSSUnitValue, _CSSNumericValue);
2333
- // static fromCSSValue(value: CSSNumericLiteralValue) {
2334
- // let unit = value.type;
2335
- // if (unit === UnitType.kInteger) unit = UnitType.kNumber;
2336
- // if (!this.isValidUnit(unit)) return null;
2337
- // return new CSSUnitValue(value.getDoubleValue(), unit);
2338
- // }
2339
-
1407
+ var CSSUnitValue = /*#__PURE__*/function (_CSSStyleValue) {
1408
+ _inheritsLoose(CSSUnitValue, _CSSStyleValue);
2340
1409
  function CSSUnitValue(value, unitOrName) {
2341
- var _this3;
1410
+ var _this;
2342
1411
  if (unitOrName === void 0) {
2343
1412
  unitOrName = exports.UnitType.kNumber;
2344
1413
  }
1414
+ _this = _CSSStyleValue.call(this) || this;
1415
+ _this.unit = void 0;
1416
+ _this.value = void 0;
2345
1417
  var unit;
2346
1418
  if (typeof unitOrName === 'string') {
2347
1419
  unit = unitFromName(unitOrName);
2348
1420
  } else {
2349
1421
  unit = unitOrName;
2350
1422
  }
2351
- // DCHECK(CSSUnitValue.isValidUnit(unit));
2352
- _this3 = _CSSNumericValue.call(this, new CSSNumericValueType(unit)) || this;
2353
- _this3.unit = void 0;
2354
- _this3.value = void 0;
2355
- _this3.unit = unit;
2356
- _this3.value = value;
2357
- return _this3;
1423
+ _this.unit = unit;
1424
+ _this.value = value;
1425
+ return _this;
2358
1426
  }
2359
- var _proto3 = CSSUnitValue.prototype;
2360
- _proto3.clone = function clone() {
1427
+ var _proto = CSSUnitValue.prototype;
1428
+ _proto.clone = function clone() {
2361
1429
  return new CSSUnitValue(this.value, this.unit);
2362
1430
  };
2363
- _proto3.convertTo = function convertTo(target_unit) {
1431
+ _proto.equals = function equals(other) {
1432
+ var other_unit_value = other;
1433
+ return this.value === other_unit_value.value && this.unit === other_unit_value.unit;
1434
+ };
1435
+ _proto.getType = function getType() {
1436
+ return CSSStyleValueType.kUnitType;
1437
+ };
1438
+ _proto.convertTo = function convertTo(target_unit) {
2364
1439
  if (this.unit === target_unit) {
2365
1440
  return new CSSUnitValue(this.value, this.unit);
2366
1441
  }
@@ -2374,46 +1449,7 @@ var CSSUnitValue = /*#__PURE__*/function (_CSSNumericValue) {
2374
1449
  var scale_factor = conversionToCanonicalUnitsScaleFactor(this.unit) / conversionToCanonicalUnitsScaleFactor(target_unit);
2375
1450
  return new CSSUnitValue(this.value * scale_factor, target_unit);
2376
1451
  };
2377
- _proto3.equals = function equals(other) {
2378
- var other_unit_value = other;
2379
- return this.value === other_unit_value.value && this.unit === other_unit_value.unit;
2380
- };
2381
- _proto3.getType = function getType() {
2382
- return CSSStyleValueType.kUnitType;
2383
- }
2384
- // toCSSValue() {
2385
- // return new CSSNumericLiteralValue(this.value, this.unit);
2386
- // }
2387
- // // const CSSPrimitiveValue* ToCSSValueWithProperty(CSSPropertyID) const final;
2388
- // toCalcExpressionNode() {
2389
- // return CSSMathExpressionNumericLiteral.create(
2390
- // new CSSNumericLiteralValue(this.value, this.unit),
2391
- // );
2392
- // }
2393
- ;
2394
- _proto3.sumValue = function sumValue() {
2395
- var sum = [];
2396
- var unit_map = {};
2397
- if (this.unit !== exports.UnitType.kNumber) {
2398
- unit_map[toCanonicalUnitIfPossible(this.unit)] = 1;
2399
- }
2400
- sum.push({
2401
- value: this.value * conversionToCanonicalUnitsScaleFactor(this.unit),
2402
- units: unit_map
2403
- });
2404
- return sum;
2405
- };
2406
- _proto3.negate = function negate() {
2407
- return new CSSUnitValue(-this.value, this.unit);
2408
- };
2409
- _proto3.invert = function invert() {
2410
- if (this.unit === exports.UnitType.kNumber) {
2411
- if (this.value === 0) return null;
2412
- return new CSSUnitValue(1.0 / this.value, this.unit);
2413
- }
2414
- return CSSMathInvert.create(this);
2415
- };
2416
- _proto3.buildCSSText = function buildCSSText(n, p, result) {
1452
+ _proto.buildCSSText = function buildCSSText(n, p, result) {
2417
1453
  var text;
2418
1454
  switch (this.unit) {
2419
1455
  case exports.UnitType.kUnknown:
@@ -2448,12 +1484,7 @@ var CSSUnitValue = /*#__PURE__*/function (_CSSNumericValue) {
2448
1484
  // case UnitType.kHertz:
2449
1485
  // case UnitType.kKilohertz:
2450
1486
  case exports.UnitType.kTurns:
2451
- // case UnitType.kDynamicViewportMax: // case UnitType.kDynamicViewportMin: // case UnitType.kDynamicViewportBlockSize: // case UnitType.kDynamicViewportInlineSize: // case UnitType.kDynamicViewportHeight: // case UnitType.kDynamicViewportWidth: // case UnitType.kLargeViewportMax: // case UnitType.kLargeViewportMin: // case UnitType.kLargeViewportBlockSize: // case UnitType.kLargeViewportInlineSize: // case UnitType.kLargeViewportHeight: // case UnitType.kLargeViewportWidth: // case UnitType.kSmallViewportMax: // case UnitType.kSmallViewportMin: // case UnitType.kSmallViewportBlockSize: // case UnitType.kSmallViewportInlineSize: // case UnitType.kSmallViewportHeight: // case UnitType.kSmallViewportWidth: // case UnitType.kViewportMax: // case UnitType.kViewportMin: // case UnitType.kViewportBlockSize: // case UnitType.kViewportInlineSize: // case UnitType.kViewportHeight: // case UnitType.kViewportWidth: // case UnitType.kFraction:
2452
- // case UnitType.kContainerWidth:
2453
- // case UnitType.kContainerHeight:
2454
- // case UnitType.kContainerInlineSize:
2455
- // case UnitType.kContainerBlockSize:
2456
- // case UnitType.kContainerMin:
1487
+ // case UnitType.kContainerMin: // case UnitType.kContainerBlockSize: // case UnitType.kContainerInlineSize: // case UnitType.kContainerHeight: // case UnitType.kContainerWidth: // case UnitType.kDynamicViewportMax: // case UnitType.kDynamicViewportMin: // case UnitType.kDynamicViewportBlockSize: // case UnitType.kDynamicViewportInlineSize: // case UnitType.kDynamicViewportHeight: // case UnitType.kDynamicViewportWidth: // case UnitType.kLargeViewportMax: // case UnitType.kLargeViewportMin: // case UnitType.kLargeViewportBlockSize: // case UnitType.kLargeViewportInlineSize: // case UnitType.kLargeViewportHeight: // case UnitType.kLargeViewportWidth: // case UnitType.kSmallViewportMax: // case UnitType.kSmallViewportMin: // case UnitType.kSmallViewportBlockSize: // case UnitType.kSmallViewportInlineSize: // case UnitType.kSmallViewportHeight: // case UnitType.kSmallViewportWidth: // case UnitType.kViewportMax: // case UnitType.kViewportMin: // case UnitType.kViewportBlockSize: // case UnitType.kViewportInlineSize: // case UnitType.kViewportHeight: // case UnitType.kViewportWidth: // case UnitType.kFraction:
2457
1488
  // case UnitType.kContainerMax: {
2458
1489
  {
2459
1490
  var kMinInteger = -999999;
@@ -2476,504 +1507,7 @@ var CSSUnitValue = /*#__PURE__*/function (_CSSNumericValue) {
2476
1507
  return result;
2477
1508
  };
2478
1509
  return CSSUnitValue;
2479
- }(CSSNumericValue);
2480
- /**
2481
- * The CSSMathValue interface of the CSS_Object_Model a base class for classes representing complex numeric values.
2482
- *
2483
- * @see https://developer.mozilla.org/en-US/docs/Web/API/CSSMathValue
2484
- * @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_math_value.idl
2485
- */
2486
- var CSSMathValue = /*#__PURE__*/function (_CSSNumericValue2) {
2487
- _inheritsLoose(CSSMathValue, _CSSNumericValue2);
2488
- function CSSMathValue() {
2489
- return _CSSNumericValue2.apply(this, arguments) || this;
2490
- }
2491
- var _proto4 = CSSMathValue.prototype;
2492
- // From CSSNumericValue
2493
- _proto4.isUnitValue = function isUnitValue() {
2494
- return false;
2495
- };
2496
- return CSSMathValue;
2497
- }(CSSNumericValue);
2498
- var CSSMathInvert = /*#__PURE__*/function (_CSSMathValue) {
2499
- _inheritsLoose(CSSMathInvert, _CSSMathValue);
2500
- CSSMathInvert.create = function create(value) {
2501
- var type = CSSNumericValueType.negateExponents(value.type_);
2502
- return new CSSMathInvert(value, type);
2503
- };
2504
- function CSSMathInvert(value, type) {
2505
- var _this4;
2506
- _this4 = _CSSMathValue.call(this, type) || this;
2507
- _this4.value = void 0;
2508
- _this4.operator = 'invert';
2509
- _this4.value = value;
2510
- return _this4;
2511
- }
2512
- var _proto5 = CSSMathInvert.prototype;
2513
- _proto5.clone = function clone() {
2514
- return new CSSMathInvert(this.value, this.type_);
2515
- };
2516
- _proto5.getType = function getType() {
2517
- return CSSStyleValueType.kInvertType;
2518
- };
2519
- _proto5.equals = function equals(other) {
2520
- if (other.getType() !== CSSStyleValueType.kInvertType) {
2521
- return false;
2522
- }
2523
- // We can safely cast here as we know 'other' has the same type as us.
2524
- var other_invert = other;
2525
- return this.value.equals(other_invert.value);
2526
- };
2527
- _proto5.sumValue = function sumValue() {
2528
- var sum = this.value.sumValue();
2529
- if (sum.length === 0 || sum.length !== 1 || sum[0].value === 0) {
2530
- return null;
2531
- }
2532
- Object.keys(sum[0].units).forEach(function (key) {
2533
- sum[0].units[key] *= -1;
2534
- });
2535
- sum[0].value = 1.0 / sum[0].value;
2536
- return sum;
2537
- }
2538
- // toCalcExpressionNode(): CSSMathExpressionNode {
2539
- // const right_side = this.value.toCalcExpressionNode();
2540
- // if (!right_side) {
2541
- // return null;
2542
- // }
2543
- // // return CSSMathExpressionOperation::CreateArithmeticOperation(
2544
- // // CSSMathExpressionNumericLiteral::Create(
2545
- // // 1, UnitType.kNumber),
2546
- // // right_side, CSSMathOperator.kDivide);
2547
- // return null;
2548
- // }
2549
- ;
2550
- _proto5.buildCSSText = function buildCSSText(nested, paren_less, result) {
2551
- if (paren_less == ParenLess.kNo) {
2552
- result += nested === Nested.kYes ? '(' : 'calc(';
2553
- }
2554
- result += '1 / ';
2555
- result = this.value.buildCSSText(Nested.kYes, ParenLess.kNo, result);
2556
- if (paren_less === ParenLess.kNo) {
2557
- result += ')';
2558
- }
2559
- return result;
2560
- };
2561
- return CSSMathInvert;
2562
- }(CSSMathValue);
2563
- var CSSMathNegate = /*#__PURE__*/function (_CSSMathValue2) {
2564
- _inheritsLoose(CSSMathNegate, _CSSMathValue2);
2565
- CSSMathNegate.create = function create(value) {
2566
- return new CSSMathNegate(value, value.type_);
2567
- };
2568
- function CSSMathNegate(value, type) {
2569
- var _this5;
2570
- _this5 = _CSSMathValue2.call(this, type) || this;
2571
- _this5.value = void 0;
2572
- _this5.operator = 'negate';
2573
- _this5.value = value;
2574
- return _this5;
2575
- }
2576
- var _proto6 = CSSMathNegate.prototype;
2577
- _proto6.clone = function clone() {
2578
- return new CSSMathNegate(this.value, this.type_);
2579
- };
2580
- _proto6.getType = function getType() {
2581
- return CSSStyleValueType.kNegateType;
2582
- };
2583
- _proto6.equals = function equals(other) {
2584
- if (other.getType() !== CSSStyleValueType.kNegateType) {
2585
- return false;
2586
- }
2587
- var other_invert = other;
2588
- return this.value.equals(other_invert.value);
2589
- };
2590
- _proto6.sumValue = function sumValue() {
2591
- var sum = this.value.sumValue();
2592
- if (sum.length === 0) {
2593
- return null;
2594
- }
2595
- sum.forEach(function (term) {
2596
- term.value *= -1;
2597
- });
2598
- return sum;
2599
- }
2600
- // toCalcExpressionNode(): CSSMathExpressionNode {
2601
- // const right_side = this.value.toCalcExpressionNode();
2602
- // if (!right_side) {
2603
- // return null;
2604
- // }
2605
- // // return CSSMathExpressionOperation::CreateArithmeticOperationSimplified(
2606
- // // CSSMathExpressionNumericLiteral::Create(
2607
- // // -1, CSSPrimitiveValue::UnitType::kNumber),
2608
- // // right_side, CSSMathOperator::kMultiply);
2609
- // }
2610
- ;
2611
- _proto6.buildCSSText = function buildCSSText(nested, paren_less, result) {
2612
- if (paren_less == ParenLess.kNo) {
2613
- result += nested === Nested.kYes ? '(' : 'calc(';
2614
- }
2615
- result += '-';
2616
- result = this.value.buildCSSText(Nested.kYes, ParenLess.kNo, result);
2617
- if (paren_less === ParenLess.kNo) {
2618
- result += ')';
2619
- }
2620
- return result;
2621
- };
2622
- return CSSMathNegate;
2623
- }(CSSMathValue);
2624
- function typeCheck(values, op, error) {
2625
- error = false;
2626
- var final_type = values[0].type_;
2627
- for (var i = 1; i < values.length; i++) {
2628
- final_type = op(final_type, values[i].type_, error);
2629
- if (error) return final_type;
2630
- }
2631
- return final_type;
2632
- }
2633
- // Represents an arithmetic operation with one or more CSSNumericValues.
2634
- var CSSMathVariadic = /*#__PURE__*/function (_CSSMathValue3) {
2635
- _inheritsLoose(CSSMathVariadic, _CSSMathValue3);
2636
- function CSSMathVariadic(values, type) {
2637
- var _this6;
2638
- _this6 = _CSSMathValue3.call(this, type) || this;
2639
- _this6.values = void 0;
2640
- _this6.values = values;
2641
- return _this6;
2642
- }
2643
- var _proto7 = CSSMathVariadic.prototype;
2644
- _proto7.numericValues = function numericValues() {
2645
- return this.values;
2646
- };
2647
- _proto7.equals = function equals(other) {
2648
- if (this.getType() !== other.getType()) {
2649
- return false;
2650
- }
2651
- return this.values.every(function (value, i) {
2652
- return value.equals(other.values[i]);
2653
- });
2654
- };
2655
- return CSSMathVariadic;
2656
- }(CSSMathValue);
2657
- // Represents the minimum of one or more CSSNumericValues.
2658
- // @see https://drafts.css-houdini.org/css-typed-om/#cssmathsum
2659
- var CSSMathMin = /*#__PURE__*/function (_CSSMathVariadic) {
2660
- _inheritsLoose(CSSMathMin, _CSSMathVariadic);
2661
- function CSSMathMin() {
2662
- var _this7;
2663
- for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
2664
- args[_key9] = arguments[_key9];
2665
- }
2666
- _this7 = _CSSMathVariadic.call.apply(_CSSMathVariadic, [this].concat(args)) || this;
2667
- _this7.operator = 'min';
2668
- return _this7;
2669
- }
2670
- CSSMathMin.create = function create(values) {
2671
- var error = false;
2672
- var final_type = typeCheck(values, CSSNumericValueType.add, error);
2673
- return new CSSMathMin(values, final_type);
2674
- };
2675
- var _proto8 = CSSMathMin.prototype;
2676
- _proto8.clone = function clone() {
2677
- return new CSSMathMin(this.values, this.type_);
2678
- };
2679
- _proto8.getType = function getType() {
2680
- return CSSStyleValueType.kMinType;
2681
- };
2682
- _proto8.sumValue = function sumValue() {
2683
- var cur_min = this.numericValues()[0].sumValue();
2684
- if (!cur_min.length) {
2685
- return null;
2686
- }
2687
- for (var _iterator2 = _createForOfIteratorHelperLoose(this.numericValues()), _step2; !(_step2 = _iterator2()).done;) {
2688
- var value = _step2.value;
2689
- var child_sum = value.sumValue();
2690
- if (!child_sum.length || JSON.stringify(child_sum[0].units) !== JSON.stringify(cur_min[0].units)) {
2691
- return null;
2692
- }
2693
- if (child_sum[0].value < cur_min[0].value) {
2694
- cur_min = child_sum;
2695
- }
2696
- }
2697
- return cur_min;
2698
- }
2699
- // toCalcExpressionNode() {
2700
- // const operands: CSSMathExpressionOperation[] = [];
2701
- // for (const value of this.numericValues()) {
2702
- // const operand = value.toCalcExpressionNode();
2703
- // if (!operand) {
2704
- // continue;
2705
- // }
2706
- // operands.push(operand as CSSMathExpressionOperation);
2707
- // }
2708
- // return CSSMathExpressionOperation.createComparisonFunction(operands, CSSMathOperator.kMin);
2709
- // }
2710
- ;
2711
- _proto8.buildCSSText = function buildCSSText(nested, paren_less, result) {
2712
- result += 'min(';
2713
- var first_iteration = true;
2714
- for (var _iterator3 = _createForOfIteratorHelperLoose(this.numericValues()), _step3; !(_step3 = _iterator3()).done;) {
2715
- var value = _step3.value;
2716
- if (!first_iteration) result += ', ';
2717
- first_iteration = false;
2718
- result = value.buildCSSText(Nested.kYes, ParenLess.kYes, result);
2719
- }
2720
- result += ')';
2721
- return result;
2722
- };
2723
- return CSSMathMin;
2724
- }(CSSMathVariadic);
2725
- // Represents the maximum of one or more CSSNumericValues.
2726
- // @see https://drafts.css-houdini.org/css-typed-om/#cssmathsum
2727
- var CSSMathMax = /*#__PURE__*/function (_CSSMathVariadic2) {
2728
- _inheritsLoose(CSSMathMax, _CSSMathVariadic2);
2729
- function CSSMathMax() {
2730
- var _this8;
2731
- for (var _len10 = arguments.length, args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
2732
- args[_key10] = arguments[_key10];
2733
- }
2734
- _this8 = _CSSMathVariadic2.call.apply(_CSSMathVariadic2, [this].concat(args)) || this;
2735
- _this8.operator = 'max';
2736
- return _this8;
2737
- }
2738
- CSSMathMax.create = function create(values) {
2739
- var error = false;
2740
- var final_type = typeCheck(values, CSSNumericValueType.add, error);
2741
- return new CSSMathMax(values, final_type);
2742
- };
2743
- var _proto9 = CSSMathMax.prototype;
2744
- _proto9.clone = function clone() {
2745
- return new CSSMathMax(this.values, this.type_);
2746
- };
2747
- _proto9.getType = function getType() {
2748
- return CSSStyleValueType.kMaxType;
2749
- };
2750
- _proto9.sumValue = function sumValue() {
2751
- var cur_max = this.numericValues()[0].sumValue();
2752
- if (!cur_max.length) {
2753
- return null;
2754
- }
2755
- for (var _iterator4 = _createForOfIteratorHelperLoose(this.numericValues()), _step4; !(_step4 = _iterator4()).done;) {
2756
- var value = _step4.value;
2757
- var child_sum = value.sumValue();
2758
- if (!child_sum.length || JSON.stringify(child_sum[0].units) !== JSON.stringify(cur_max[0].units)) {
2759
- return null;
2760
- }
2761
- if (child_sum[0].value < cur_max[0].value) {
2762
- cur_max = child_sum;
2763
- }
2764
- }
2765
- return cur_max;
2766
- }
2767
- // toCalcExpressionNode() {
2768
- // const operands: CSSMathExpressionOperation[] = [];
2769
- // for (const value of this.numericValues()) {
2770
- // const operand = value.toCalcExpressionNode();
2771
- // if (!operand) {
2772
- // continue;
2773
- // }
2774
- // operands.push(operand as CSSMathExpressionOperation);
2775
- // }
2776
- // return CSSMathExpressionOperation.createComparisonFunction(operands, CSSMathOperator.kMax);
2777
- // }
2778
- ;
2779
- _proto9.buildCSSText = function buildCSSText(nested, paren_less, result) {
2780
- result += 'max(';
2781
- var first_iteration = true;
2782
- for (var _iterator5 = _createForOfIteratorHelperLoose(this.numericValues()), _step5; !(_step5 = _iterator5()).done;) {
2783
- var value = _step5.value;
2784
- if (!first_iteration) result += ', ';
2785
- first_iteration = false;
2786
- result = value.buildCSSText(Nested.kYes, ParenLess.kYes, result);
2787
- }
2788
- result += ')';
2789
- return result;
2790
- };
2791
- return CSSMathMax;
2792
- }(CSSMathVariadic);
2793
- /**
2794
- * Represents the sum of one or more CSSNumericValues.
2795
- * @see https://drafts.css-houdini.org/css-typed-om/#cssmathsum
2796
- */
2797
- var CSSMathSum = /*#__PURE__*/function (_CSSMathVariadic3) {
2798
- _inheritsLoose(CSSMathSum, _CSSMathVariadic3);
2799
- function CSSMathSum() {
2800
- var _this9;
2801
- for (var _len11 = arguments.length, args = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) {
2802
- args[_key11] = arguments[_key11];
2803
- }
2804
- _this9 = _CSSMathVariadic3.call.apply(_CSSMathVariadic3, [this].concat(args)) || this;
2805
- _this9.operator = 'sum';
2806
- return _this9;
2807
- }
2808
- CSSMathSum.create = function create(values) {
2809
- var error = false;
2810
- var finalType = typeCheck(values, CSSNumericValueType.add, error);
2811
- return new CSSMathSum(values, finalType);
2812
- };
2813
- CSSMathSum.numericTypeFromUnitMap = function numericTypeFromUnitMap(units) {
2814
- var type = new CSSNumericValueType();
2815
- Object.keys(units).forEach(function (key) {
2816
- var exp = units[key];
2817
- var error = false;
2818
- type = CSSNumericValueType.multiply(type, new CSSNumericValueType(Number(key), exp), error);
2819
- DCHECK(!error);
2820
- });
2821
- return type;
2822
- };
2823
- CSSMathSum.canCreateNumericTypeFromSumValue = function canCreateNumericTypeFromSumValue(sum) {
2824
- var _this10 = this;
2825
- DCHECK(!!sum.length);
2826
- var first_type = this.numericTypeFromUnitMap(sum[0].units);
2827
- return sum.every(function (term) {
2828
- var error = false;
2829
- CSSNumericValueType.add(first_type, _this10.numericTypeFromUnitMap(term.units), error);
2830
- return !error;
2831
- });
2832
- };
2833
- var _proto10 = CSSMathSum.prototype;
2834
- _proto10.clone = function clone() {
2835
- return new CSSMathSum(this.values, this.type_);
2836
- };
2837
- _proto10.getType = function getType() {
2838
- return CSSStyleValueType.kSumType;
2839
- }
2840
- // toCalcExpressionNode() {
2841
- // return this.toCalcExporessionNodeForVariadic(CSSMathOperator.kAdd);
2842
- // }
2843
- ;
2844
- _proto10.sumValue = function sumValue() {
2845
- var sum = [];
2846
- this.numericValues().forEach(function (value) {
2847
- var child_sum = value.sumValue();
2848
- if (!child_sum.length) {
2849
- return null;
2850
- }
2851
- child_sum.forEach(function (term) {
2852
- var index = sum.findIndex(function (s) {
2853
- return JSON.stringify(s.units) === JSON.stringify(term.units);
2854
- });
2855
- if (index === -1) {
2856
- sum.push(_extends({}, term));
2857
- } else {
2858
- sum[index].value += term.value;
2859
- }
2860
- });
2861
- });
2862
- if (!CSSMathSum.canCreateNumericTypeFromSumValue(sum)) return null;
2863
- return sum;
2864
- };
2865
- _proto10.buildCSSText = function buildCSSText(nested, paren_less, result) {
2866
- if (paren_less == ParenLess.kNo) {
2867
- result += nested === Nested.kYes ? '(' : 'calc(';
2868
- }
2869
- var values = this.numericValues();
2870
- result = values[0].buildCSSText(Nested.kYes, ParenLess.kNo, result);
2871
- for (var i = 1; i < values.length; i++) {
2872
- var arg = values[i];
2873
- if (arg.getType() === CSSStyleValueType.kNegateType) {
2874
- result += ' - ';
2875
- result = arg.value.buildCSSText(Nested.kYes, ParenLess.kNo, result);
2876
- } else {
2877
- result += ' + ';
2878
- result = arg.buildCSSText(Nested.kYes, ParenLess.kNo, result);
2879
- }
2880
- }
2881
- if (paren_less === ParenLess.kNo) {
2882
- result += ')';
2883
- }
2884
- return result;
2885
- };
2886
- return CSSMathSum;
2887
- }(CSSMathVariadic);
2888
- /**
2889
- * Represents the product of one or more CSSNumericValues.
2890
- * @see https://drafts.css-houdini.org/css-typed-om/#cssmathproduct
2891
- */
2892
- var CSSMathProduct = /*#__PURE__*/function (_CSSMathVariadic4) {
2893
- _inheritsLoose(CSSMathProduct, _CSSMathVariadic4);
2894
- function CSSMathProduct() {
2895
- var _this11;
2896
- for (var _len12 = arguments.length, args = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) {
2897
- args[_key12] = arguments[_key12];
2898
- }
2899
- _this11 = _CSSMathVariadic4.call.apply(_CSSMathVariadic4, [this].concat(args)) || this;
2900
- _this11.operator = 'product';
2901
- return _this11;
2902
- }
2903
- CSSMathProduct.create = function create(values) {
2904
- var error = false;
2905
- var finalType = typeCheck(values, CSSNumericValueType.multiply, error);
2906
- return new CSSMathProduct(values, finalType);
2907
- };
2908
- CSSMathProduct.multiplyUnitMaps = function multiplyUnitMaps(a, b) {
2909
- Object.keys(b).forEach(function (key) {
2910
- DCHECK_NE(b[key].value, 0);
2911
- var old_value = key in a ? a[key].value : 0;
2912
- if (old_value + b[key].value === 0) {
2913
- delete a[key];
2914
- } else {
2915
- a[key] = old_value + b[key].value;
2916
- }
2917
- });
2918
- return a;
2919
- };
2920
- var _proto11 = CSSMathProduct.prototype;
2921
- _proto11.clone = function clone() {
2922
- return new CSSMathProduct(this.values, this.type_);
2923
- };
2924
- _proto11.getType = function getType() {
2925
- return CSSStyleValueType.kProductType;
2926
- }
2927
- // toCalcExpressionNode() {
2928
- // return this.toCalcExporessionNodeForVariadic(CSSMathOperator.kMultiply);
2929
- // }
2930
- ;
2931
- _proto11.sumValue = function sumValue() {
2932
- var sum = [{
2933
- value: 1,
2934
- units: {}
2935
- }];
2936
- this.numericValues().forEach(function (value) {
2937
- var child_sum = value.sumValue();
2938
- if (!child_sum.length) {
2939
- return null;
2940
- }
2941
- var new_sum = [];
2942
- sum.forEach(function (a) {
2943
- child_sum.forEach(function (b) {
2944
- new_sum.push({
2945
- value: a.value * b.value,
2946
- units: CSSMathProduct.multiplyUnitMaps(a.units, b.units)
2947
- });
2948
- });
2949
- });
2950
- sum = new_sum;
2951
- });
2952
- return sum;
2953
- };
2954
- _proto11.buildCSSText = function buildCSSText(nested, paren_less, result) {
2955
- if (paren_less == ParenLess.kNo) {
2956
- result += nested === Nested.kYes ? '(' : 'calc(';
2957
- }
2958
- var values = this.numericValues();
2959
- result = values[0].buildCSSText(Nested.kYes, ParenLess.kNo, result);
2960
- for (var i = 1; i < values.length; i++) {
2961
- var arg = values[i];
2962
- if (arg.getType() === CSSStyleValueType.kInvertType) {
2963
- result += ' / ';
2964
- result = arg.value.buildCSSText(Nested.kYes, ParenLess.kNo, result);
2965
- } else {
2966
- result += ' * ';
2967
- result = arg.buildCSSText(Nested.kYes, ParenLess.kNo, result);
2968
- }
2969
- }
2970
- if (paren_less === ParenLess.kNo) {
2971
- result += ')';
2972
- }
2973
- return result;
2974
- };
2975
- return CSSMathProduct;
2976
- }(CSSMathVariadic);
1510
+ }(CSSStyleValue);
2977
1511
  var Opx = new CSSUnitValue(0, 'px');
2978
1512
  var Lpx = new CSSUnitValue(1, 'px');
2979
1513
  var Odeg = new CSSUnitValue(0, 'deg');
@@ -3155,17 +1689,20 @@ var getOrCreateRGBA = memoize(function (r, g, b, a) {
3155
1689
  }, function (r, g, b, a) {
3156
1690
  return "rgba(" + r + "," + g + "," + b + "," + a + ")";
3157
1691
  });
3158
- var getOrCreateUnitValue = memoize(function (value, unitOrName) {
1692
+ // export const getOrCreateUnitValue = memoize(
1693
+ // (value: number, unitOrName: UnitType | string = UnitType.kNumber) => {
1694
+ // return new CSSUnitValue(value, unitOrName);
1695
+ // },
1696
+ // (value: number, unitOrName: UnitType | string = UnitType.kNumber) => {
1697
+ // return `${value}${unitOrName}`;
1698
+ // },
1699
+ // );
1700
+ var getOrCreateUnitValue = function getOrCreateUnitValue(value, unitOrName) {
3159
1701
  if (unitOrName === void 0) {
3160
1702
  unitOrName = exports.UnitType.kNumber;
3161
1703
  }
3162
1704
  return new CSSUnitValue(value, unitOrName);
3163
- }, function (value, unitOrName) {
3164
- if (unitOrName === void 0) {
3165
- unitOrName = exports.UnitType.kNumber;
3166
- }
3167
- return "" + value + unitOrName;
3168
- });
1705
+ };
3169
1706
 
3170
1707
  var regexLG = /^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i;
3171
1708
  var regexRG = /^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i;
@@ -3288,7 +1825,7 @@ var parseGradient = memoize(function (colorStr) {
3288
1825
  var steps = colorStops.map(function (colorStop) {
3289
1826
  // TODO: only support % for now, should calc percentage of axis length when using px/em
3290
1827
  return {
3291
- offset: getOrCreateUnitValue(colorStop.length.value, '%'),
1828
+ offset: getOrCreateUnitValue(Number(colorStop.length.value), '%'),
3292
1829
  color: colorStopToString(colorStop)
3293
1830
  };
3294
1831
  });
@@ -3483,6 +2020,21 @@ function mergeColors(left, right) {
3483
2020
  }];
3484
2021
  }
3485
2022
 
2023
+ (function (Shape) {
2024
+ Shape["GROUP"] = "g";
2025
+ Shape["CIRCLE"] = "circle";
2026
+ Shape["ELLIPSE"] = "ellipse";
2027
+ Shape["IMAGE"] = "image";
2028
+ Shape["RECT"] = "rect";
2029
+ Shape["LINE"] = "line";
2030
+ Shape["POLYLINE"] = "polyline";
2031
+ Shape["POLYGON"] = "polygon";
2032
+ Shape["TEXT"] = "text";
2033
+ Shape["PATH"] = "path";
2034
+ Shape["HTML"] = "html";
2035
+ Shape["MESH"] = "mesh";
2036
+ })(exports.Shape || (exports.Shape = {}));
2037
+
3486
2038
  function parseDimension(unitRegExp, string) {
3487
2039
  if (util.isNil(string)) {
3488
2040
  return getOrCreateUnitValue(0, 'px');
@@ -3526,12 +2078,20 @@ var parserPercentage = memoize(function (css) {
3526
2078
  *
3527
2079
  * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/length-percentage
3528
2080
  */
3529
- var parseLengthOrPercentage = memoize(function (css) {
2081
+ // export const parseLengthOrPercentage = memoize((css: string): CSSUnitValue => {
2082
+ // if (isNumber(css) || isFinite(Number(css))) {
2083
+ // return getOrCreateUnitValue(Number(css), 'px');
2084
+ // }
2085
+ // return parseDimension(new RegExp('px|%|em|rem', 'g'), css) as CSSUnitValue;
2086
+ // });
2087
+ var parseLengthOrPercentage = function parseLengthOrPercentage(css) {
3530
2088
  if (util.isNumber(css) || isFinite(Number(css))) {
3531
2089
  return getOrCreateUnitValue(Number(css), 'px');
2090
+ // return Number(css);
3532
2091
  }
2092
+
3533
2093
  return parseDimension(new RegExp('px|%|em|rem', 'g'), css);
3534
- });
2094
+ };
3535
2095
  var parseAngle = memoize(function (css) {
3536
2096
  return parseDimension(new RegExp('deg|rad|grad|turn', 'g'), css);
3537
2097
  });
@@ -4462,6 +3022,9 @@ var CSSPropertyLengthOrPercentage = /*#__PURE__*/function () {
4462
3022
  * CSS.percent(50) -> CSS.px(0.5 * parent.width)
4463
3023
  */
4464
3024
  _proto.calculator = function calculator(name, oldParsed, computed, object, registry) {
3025
+ if (util.isNumber(computed)) {
3026
+ return computed;
3027
+ }
4465
3028
  if (CSSUnitValue.isRelativeUnit(computed.unit)) {
4466
3029
  if (computed.unit === exports.UnitType.kPercentage) {
4467
3030
  // TODO: merge dimensions
@@ -4583,7 +3146,7 @@ var CSSPropertyLocalPosition = /*#__PURE__*/function (_CSSPropertyLengthOrP) {
4583
3146
  /**
4584
3147
  * update local position
4585
3148
  */
4586
- _proto.postProcessor = function postProcessor(object) {
3149
+ _proto.postProcessor = function postProcessor(object, attributes) {
4587
3150
  var x;
4588
3151
  var y;
4589
3152
  var z;
@@ -4631,12 +3194,19 @@ var CSSPropertyLocalPosition = /*#__PURE__*/function (_CSSPropertyLengthOrP) {
4631
3194
  object.parsedStyle.defY = y || 0;
4632
3195
  }
4633
3196
  var needResetLocalPosition = !util.isNil(x) || !util.isNil(y) || !util.isNil(z);
4634
- if (needResetLocalPosition) {
4635
- var _object$getLocalPosit = object.getLocalPosition(),
4636
- ox = _object$getLocalPosit[0],
4637
- oy = _object$getLocalPosit[1],
4638
- oz = _object$getLocalPosit[2];
4639
- object.setLocalPosition(util.isNil(x) ? ox : x, util.isNil(y) ? oy : y, util.isNil(z) ? oz : z);
3197
+ // only if `transform` won't be processed later
3198
+ if (needResetLocalPosition && attributes.indexOf('transform') === -1) {
3199
+ // account for current transform if needed
3200
+ var transform = object.parsedStyle.transform;
3201
+ if (transform && transform.length) {
3202
+ parsedTransformToMat4(transform, object);
3203
+ } else {
3204
+ var _object$getLocalPosit = object.getLocalPosition(),
3205
+ ox = _object$getLocalPosit[0],
3206
+ oy = _object$getLocalPosit[1],
3207
+ oz = _object$getLocalPosit[2];
3208
+ object.setLocalPosition(util.isNil(x) ? ox : x, util.isNil(y) ? oy : y, util.isNil(z) ? oz : z);
3209
+ }
4640
3210
  }
4641
3211
  };
4642
3212
  return CSSPropertyLocalPosition;
@@ -4951,6 +3521,30 @@ var CustomElementRegistry = /*#__PURE__*/function () {
4951
3521
  return CustomElementRegistry;
4952
3522
  }();
4953
3523
 
3524
+ var Point = /*#__PURE__*/function () {
3525
+ function Point(x, y) {
3526
+ if (x === void 0) {
3527
+ x = 0;
3528
+ }
3529
+ if (y === void 0) {
3530
+ y = 0;
3531
+ }
3532
+ this.x = 0;
3533
+ this.y = 0;
3534
+ this.x = x;
3535
+ this.y = y;
3536
+ }
3537
+ var _proto = Point.prototype;
3538
+ _proto.clone = function clone() {
3539
+ return new Point(this.x, this.y);
3540
+ };
3541
+ _proto.copyFrom = function copyFrom(p) {
3542
+ this.x = p.x;
3543
+ this.y = p.y;
3544
+ };
3545
+ return Point;
3546
+ }();
3547
+
4954
3548
  function isFederatedEvent(value) {
4955
3549
  return !!value.type;
4956
3550
  }
@@ -6046,16 +4640,26 @@ var Element = /*#__PURE__*/function (_Node) {
6046
4640
  dirtyFlag: false,
6047
4641
  localDirtyFlag: false,
6048
4642
  frozen: false,
6049
- localPosition: glMatrix.vec3.fromValues(0, 0, 0),
6050
- localRotation: glMatrix.quat.fromValues(0, 0, 0, 1),
6051
- localScale: glMatrix.vec3.fromValues(1, 1, 1),
4643
+ // localPosition: vec3.fromValues(0, 0, 0),
4644
+ // localRotation: quat.fromValues(0, 0, 0, 1),
4645
+ // localScale: vec3.fromValues(1, 1, 1),
4646
+ // localTransform: mat4.create(),
4647
+ // localSkew: vec2.fromValues(0, 0),
4648
+ // position: vec3.fromValues(0, 0, 0),
4649
+ // rotation: quat.fromValues(0, 0, 0, 1),
4650
+ // scaling: vec3.fromValues(1, 1, 1),
4651
+ // worldTransform: mat4.create(),
4652
+ // origin: vec3.fromValues(0, 0, 0),
4653
+ localPosition: [0, 0, 0],
4654
+ localRotation: [0, 0, 0, 1],
4655
+ localScale: [1, 1, 1],
6052
4656
  localTransform: glMatrix.mat4.create(),
6053
- localSkew: glMatrix.vec2.fromValues(0, 0),
6054
- position: glMatrix.vec3.fromValues(0, 0, 0),
6055
- rotation: glMatrix.quat.fromValues(0, 0, 0, 1),
6056
- scaling: glMatrix.vec3.fromValues(1, 1, 1),
4657
+ localSkew: [0, 0],
4658
+ position: [0, 0, 0],
4659
+ rotation: [0, 0, 0, 1],
4660
+ scaling: [1, 1, 1],
6057
4661
  worldTransform: glMatrix.mat4.create(),
6058
- origin: glMatrix.vec3.fromValues(0, 0, 0)
4662
+ origin: [0, 0, 0]
6059
4663
  };
6060
4664
  _this.sortable = {
6061
4665
  dirty: false,
@@ -6772,6 +5376,20 @@ var DEFAULT_PARSED_STYLE_PROPS = {
6772
5376
  filter: [],
6773
5377
  shadowType: 'outer'
6774
5378
  };
5379
+ var DEFAULT_PARSED_STYLE_PROPS_CSS_DISABLED = _extends({}, DEFAULT_PARSED_STYLE_PROPS, {
5380
+ opacity: 1,
5381
+ fillOpacity: 1,
5382
+ strokeOpacity: 1,
5383
+ visibility: 'visible',
5384
+ pointerEvents: 'auto',
5385
+ lineWidth: 1,
5386
+ lineCap: 'butt',
5387
+ lineJoin: 'miter',
5388
+ increasedLineWidthForHitTesting: 0,
5389
+ fillRule: 'nonzero'
5390
+ // TODO: transformOrigin
5391
+ });
5392
+
6775
5393
  var INHERITABLE_BASE_STYLE_PROPS = ['opacity', 'fillOpacity', 'strokeOpacity', 'transformOrigin', 'visibility', 'pointerEvents', 'lineWidth', 'lineCap', 'lineJoin', 'increasedLineWidthForHitTesting'];
6776
5394
  var INHERITABLE_STYLE_PROPS = [].concat(INHERITABLE_BASE_STYLE_PROPS, ['fontSize', 'fontFamily', 'fontStyle', 'fontWeight', 'fontVariant', 'textAlign', 'textBaseline', 'textTransform']);
6777
5395
  /**
@@ -6826,7 +5444,13 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
6826
5444
  }
6827
5445
  _this.nodeName = _this.config.type || exports.Shape.GROUP;
6828
5446
  // compatible with G 3.0
6829
- _this.config.style = _extends({}, _this.config.style, _this.config.attrs);
5447
+ _this.config.style = _this.config.style || _this.config.attrs || {};
5448
+ Object.assign(_this.config.style, _this.config.attrs);
5449
+ // this.config.style = {
5450
+ // // ...DEFAULT_STYLE_PROPS,
5451
+ // ...this.config.style,
5452
+ // ...this.config.attrs,
5453
+ // };
6830
5454
  if (_this.config.visible != null) {
6831
5455
  _this.config.style.visibility = _this.config.visible === false ? 'hidden' : 'visible';
6832
5456
  }
@@ -6834,8 +5458,10 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
6834
5458
  _this.config.style.pointerEvents = _this.config.interactive === false ? 'none' : 'auto';
6835
5459
  }
6836
5460
  // merge parsed value
6837
- Object.assign(_this.parsedStyle, DEFAULT_PARSED_STYLE_PROPS, _this.config.initialParsedStyle);
6838
- Object.assign(_this.attributes, DEFAULT_STYLE_PROPS);
5461
+ Object.assign(_this.parsedStyle, runtime.enableCSSParsing ? DEFAULT_PARSED_STYLE_PROPS : DEFAULT_PARSED_STYLE_PROPS_CSS_DISABLED, _this.config.initialParsedStyle);
5462
+ if (runtime.enableCSSParsing) {
5463
+ Object.assign(_this.attributes, DEFAULT_STYLE_PROPS);
5464
+ }
6839
5465
  // start to process attributes
6840
5466
  _this.initAttributes(_this.config.style);
6841
5467
  _this.style = new Proxy(
@@ -6930,16 +5556,21 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
6930
5556
  attributes = {};
6931
5557
  }
6932
5558
  var renderable = this.renderable;
6933
- // account for FCP, process properties as less as possible
6934
- runtime.styleValueRegistry.processProperties(this, attributes, {
6935
- forceUpdateGeometry: true,
6936
- usedAttributes: INHERITABLE_STYLE_PROPS
5559
+ var options = {
5560
+ forceUpdateGeometry: true
6937
5561
  // usedAttributes:
6938
5562
  // // only Group / Text should account for text relative props
6939
5563
  // this.tagName === Shape.GROUP || this.tagName === Shape.TEXT
6940
5564
  // ? INHERITABLE_STYLE_PROPS
6941
5565
  // : INHERITABLE_BASE_STYLE_PROPS,
6942
- });
5566
+ };
5567
+
5568
+ if (runtime.enableCSSParsing) {
5569
+ // @ts-ignore
5570
+ options.usedAttributes = INHERITABLE_STYLE_PROPS;
5571
+ }
5572
+ // account for FCP, process properties as less as possible
5573
+ runtime.styleValueRegistry.processProperties(this, attributes, options);
6943
5574
  // redraw at next frame
6944
5575
  renderable.dirty = true;
6945
5576
  };
@@ -7674,7 +6305,11 @@ var HTML = /*#__PURE__*/function (_DisplayObject) {
7674
6305
  var minX = clientRect.left - canvasRect.left;
7675
6306
  var minY = clientRect.top - canvasRect.top;
7676
6307
  var aabb = new AABB();
7677
- aabb.setMinMax(glMatrix.vec3.fromValues(minX, minY, 0), glMatrix.vec3.fromValues(minX + clientRect.width, minY + clientRect.height, 0));
6308
+ // aabb.setMinMax(
6309
+ // vec3.fromValues(minX, minY, 0),
6310
+ // vec3.fromValues(minX + clientRect.width, minY + clientRect.height, 0),
6311
+ // );
6312
+ aabb.setMinMax([minX, minY, 0], [minX + clientRect.width, minY + clientRect.height, 0]);
7678
6313
  return aabb;
7679
6314
  }
7680
6315
  return null;
@@ -8419,6 +7054,42 @@ var Text = /*#__PURE__*/function (_DisplayObject) {
8419
7054
  return Text;
8420
7055
  }(DisplayObject);
8421
7056
 
7057
+ function copyVec3(a, b) {
7058
+ a[0] = b[0];
7059
+ a[1] = b[1];
7060
+ a[2] = b[2];
7061
+ return a;
7062
+ }
7063
+ function subVec3(o, a, b) {
7064
+ o[0] = a[0] - b[0];
7065
+ o[1] = a[1] - b[1];
7066
+ o[2] = a[2] - b[2];
7067
+ return o;
7068
+ }
7069
+ function addVec3(o, a, b) {
7070
+ o[0] = a[0] + b[0];
7071
+ o[1] = a[1] + b[1];
7072
+ o[2] = a[2] + b[2];
7073
+ return o;
7074
+ }
7075
+ function scaleVec3(o, a, b) {
7076
+ o[0] = a[0] * b;
7077
+ o[1] = a[1] * b;
7078
+ o[2] = a[2] * b;
7079
+ return o;
7080
+ }
7081
+ function maxVec3(o, a, b) {
7082
+ o[0] = Math.max(a[0], b[0]);
7083
+ o[1] = Math.max(a[1], b[1]);
7084
+ o[2] = Math.max(a[2], b[2]);
7085
+ return o;
7086
+ }
7087
+ function minVec3(o, a, b) {
7088
+ o[0] = Math.min(a[0], b[0]);
7089
+ o[1] = Math.min(a[1], b[1]);
7090
+ o[2] = Math.min(a[2], b[2]);
7091
+ return o;
7092
+ }
8422
7093
  function getAngle(angle) {
8423
7094
  if (angle === undefined) {
8424
7095
  return 0;
@@ -8788,16 +7459,16 @@ function parsedTransformToMat4(transform, object) {
8788
7459
  object.translateLocal(_newTranslation4[0].value, _newTranslation4[1].value, _newTranslation4[2].value);
8789
7460
  } else if (t === 'rotate') {
8790
7461
  var newAngles = d || [Odeg];
8791
- object.rotateLocal(0, 0, newAngles[0].value);
7462
+ object.rotateLocal(0, 0, convertAngleUnit(newAngles[0]));
8792
7463
  } else if (t === 'rotatex') {
8793
7464
  var _newAngles = d || [Odeg];
8794
- object.rotateLocal(_newAngles[0].value, 0, 0);
7465
+ object.rotateLocal(convertAngleUnit(_newAngles[0]), 0, 0);
8795
7466
  } else if (t === 'rotatey') {
8796
7467
  var _newAngles2 = d || [Odeg];
8797
- object.rotateLocal(0, _newAngles2[0].value, 0);
7468
+ object.rotateLocal(0, convertAngleUnit(_newAngles2[0]), 0);
8798
7469
  } else if (t === 'rotatez') {
8799
7470
  var _newAngles3 = d || [Odeg];
8800
- object.rotateLocal(0, 0, _newAngles3[0].value);
7471
+ object.rotateLocal(0, 0, convertAngleUnit(_newAngles3[0]));
8801
7472
  } else if (t === 'rotate3d') ; else if (t === 'skew') {
8802
7473
  var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) {
8803
7474
  return s.value;
@@ -10836,90 +9507,483 @@ function toFontString(attributes) {
10836
9507
  if (!stringRegExp.test(_fontFamily) && genericFontFamilies.indexOf(_fontFamily) < 0) {
10837
9508
  _fontFamily = "\"" + _fontFamily + "\"";
10838
9509
  }
10839
- fontFamilies[i] = _fontFamily;
9510
+ fontFamilies[i] = _fontFamily;
9511
+ }
9512
+ return fontStyle + " " + fontVariant + " " + fontWeight + " " + fontSizeString + " " + fontFamilies.join(',');
9513
+ }
9514
+
9515
+ /**
9516
+ * Thanks for following contributor of codes
9517
+ * https://gist.github.com/1866474
9518
+ * http://paulirish.com/2011/requestanimationframe-for-smart-animating/
9519
+ * http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
9520
+ * https://github.com/Financial-Times/polyfill-library/blob/master/polyfills/requestAnimationFrame/polyfill.js
9521
+ **/
9522
+ var uId = 1;
9523
+ var uniqueId = function uniqueId() {
9524
+ return uId++;
9525
+ };
9526
+ // We use `self` instead of `window` for `WebWorker` support.
9527
+ var root = typeof self === 'object' && self.self == self ? self :
9528
+ // @ts-ignore
9529
+ typeof global === 'object' && global.global == global ?
9530
+ // @ts-ignore
9531
+ global : {};
9532
+ var nowOffset = Date.now();
9533
+ // use performance api if exist, otherwise use Date.now.
9534
+ // Date.now polyfill required.
9535
+ var pnow = function pnow() {
9536
+ if (root.performance && typeof root.performance.now === 'function') {
9537
+ return root.performance.now();
9538
+ }
9539
+ // fallback
9540
+ return Date.now() - nowOffset;
9541
+ };
9542
+ var reservedCBs = {};
9543
+ var lastTime = Date.now();
9544
+ var polyfillRaf = function polyfillRaf(callback) {
9545
+ if (typeof callback !== 'function') {
9546
+ throw new TypeError(callback + ' is not a function');
9547
+ }
9548
+ var currentTime = Date.now();
9549
+ var gap = currentTime - lastTime;
9550
+ var delay = gap > 16 ? 0 : 16 - gap;
9551
+ var id = uniqueId();
9552
+ reservedCBs[id] = callback;
9553
+ // keys(reservedCBs).length > 1 의미는 이미 setTimeout 이 걸려있는 경우.
9554
+ // 함께 callback 이 실행될 수 있게 reservedCBs 에만 추가해주고 return
9555
+ if (Object.keys(reservedCBs).length > 1) return id;
9556
+ setTimeout(function () {
9557
+ lastTime = currentTime;
9558
+ var copied = reservedCBs;
9559
+ reservedCBs = {};
9560
+ Object.keys(copied).forEach(function (key) {
9561
+ return copied[key](pnow());
9562
+ });
9563
+ }, delay);
9564
+ return id;
9565
+ };
9566
+ var polyfillCaf = function polyfillCaf(id) {
9567
+ delete reservedCBs[id];
9568
+ };
9569
+ var vendorPrefixes = ['', 'webkit', 'moz', 'ms', 'o'];
9570
+ var getRequestAnimationFrame = function getRequestAnimationFrame(vp) {
9571
+ if (typeof vp !== 'string') return polyfillRaf;
9572
+ if (vp === '') return root['requestAnimationFrame'];
9573
+ return root[vp + 'RequestAnimationFrame'];
9574
+ };
9575
+ var getCancelAnimationFrame = function getCancelAnimationFrame(vp) {
9576
+ if (typeof vp !== 'string') return polyfillCaf;
9577
+ if (vp === '') return root['cancelAnimationFrame'];
9578
+ return root[vp + 'CancelAnimationFrame'] || root[vp + 'CancelRequestAnimationFrame'];
9579
+ };
9580
+ var find = function find(arr, predicate) {
9581
+ var i = 0;
9582
+ while (arr[i] !== void 0) {
9583
+ if (predicate(arr[i])) return arr[i];
9584
+ i = i + 1;
9585
+ }
9586
+ };
9587
+ var vp = find(vendorPrefixes, function (vp) {
9588
+ return !!getRequestAnimationFrame(vp);
9589
+ });
9590
+ var raf = getRequestAnimationFrame(vp);
9591
+ var caf = getCancelAnimationFrame(vp);
9592
+ root.requestAnimationFrame = raf;
9593
+ root.cancelAnimationFrame = caf;
9594
+
9595
+ /**
9596
+ * Axis-Aligned Bounding Box
9597
+ * 为了便于后续 Frustum Culling,通过查找表定义 p-vertex 和 n-vertex
9598
+ * @see https://github.com/antvis/GWebGPUEngine/issues/3
9599
+ */
9600
+ var AABB = /*#__PURE__*/function () {
9601
+ AABB.isEmpty = function isEmpty(aabb) {
9602
+ return !aabb || aabb.halfExtents[0] === 0 && aabb.halfExtents[1] === 0 && aabb.halfExtents[2] === 0;
9603
+ };
9604
+ // center: vec3 = vec3.create();
9605
+ // halfExtents: vec3 = vec3.create();
9606
+ // min: vec3 = vec3.create();
9607
+ // max: vec3 = vec3.create();
9608
+ function AABB(center, halfExtents) {
9609
+ if (center === void 0) {
9610
+ center = [0, 0, 0];
9611
+ }
9612
+ if (halfExtents === void 0) {
9613
+ halfExtents = [0, 0, 0];
9614
+ }
9615
+ this.center = [0, 0, 0];
9616
+ this.halfExtents = [0, 0, 0];
9617
+ this.min = [0, 0, 0];
9618
+ this.max = [0, 0, 0];
9619
+ this.update(center, halfExtents);
9620
+ }
9621
+ var _proto = AABB.prototype;
9622
+ _proto.update = function update(center, halfExtents) {
9623
+ copyVec3(this.center, center);
9624
+ copyVec3(this.halfExtents, halfExtents);
9625
+ subVec3(this.min, this.center, this.halfExtents);
9626
+ addVec3(this.max, this.center, this.halfExtents);
9627
+ // vec3.copy(this.center, center);
9628
+ // vec3.copy(this.halfExtents, halfExtents);
9629
+ // vec3.sub(this.min, this.center, this.halfExtents);
9630
+ // vec3.add(this.max, this.center, this.halfExtents);
9631
+ };
9632
+ _proto.setMinMax = function setMinMax(min, max) {
9633
+ // vec3.add(this.center, max, min);
9634
+ // vec3.scale(this.center, this.center, 0.5);
9635
+ // vec3.sub(this.halfExtents, max, min);
9636
+ // vec3.scale(this.halfExtents, this.halfExtents, 0.5);
9637
+ // vec3.copy(this.min, min);
9638
+ // vec3.copy(this.max, max);
9639
+ addVec3(this.center, max, min);
9640
+ scaleVec3(this.center, this.center, 0.5);
9641
+ subVec3(this.halfExtents, max, min);
9642
+ scaleVec3(this.halfExtents, this.halfExtents, 0.5);
9643
+ copyVec3(this.min, min);
9644
+ copyVec3(this.max, max);
9645
+ };
9646
+ _proto.getMin = function getMin() {
9647
+ return this.min;
9648
+ };
9649
+ _proto.getMax = function getMax() {
9650
+ return this.max;
9651
+ };
9652
+ _proto.add = function add(aabb) {
9653
+ if (AABB.isEmpty(aabb)) {
9654
+ return;
9655
+ }
9656
+ if (AABB.isEmpty(this)) {
9657
+ this.setMinMax(aabb.getMin(), aabb.getMax());
9658
+ return;
9659
+ }
9660
+ var tc = this.center;
9661
+ var tcx = tc[0];
9662
+ var tcy = tc[1];
9663
+ var tcz = tc[2];
9664
+ var th = this.halfExtents;
9665
+ var thx = th[0];
9666
+ var thy = th[1];
9667
+ var thz = th[2];
9668
+ var tminx = tcx - thx;
9669
+ var tmaxx = tcx + thx;
9670
+ var tminy = tcy - thy;
9671
+ var tmaxy = tcy + thy;
9672
+ var tminz = tcz - thz;
9673
+ var tmaxz = tcz + thz;
9674
+ var oc = aabb.center;
9675
+ var ocx = oc[0];
9676
+ var ocy = oc[1];
9677
+ var ocz = oc[2];
9678
+ var oh = aabb.halfExtents;
9679
+ var ohx = oh[0];
9680
+ var ohy = oh[1];
9681
+ var ohz = oh[2];
9682
+ var ominx = ocx - ohx;
9683
+ var omaxx = ocx + ohx;
9684
+ var ominy = ocy - ohy;
9685
+ var omaxy = ocy + ohy;
9686
+ var ominz = ocz - ohz;
9687
+ var omaxz = ocz + ohz;
9688
+ if (ominx < tminx) {
9689
+ tminx = ominx;
9690
+ }
9691
+ if (omaxx > tmaxx) {
9692
+ tmaxx = omaxx;
9693
+ }
9694
+ if (ominy < tminy) {
9695
+ tminy = ominy;
9696
+ }
9697
+ if (omaxy > tmaxy) {
9698
+ tmaxy = omaxy;
9699
+ }
9700
+ if (ominz < tminz) {
9701
+ tminz = ominz;
9702
+ }
9703
+ if (omaxz > tmaxz) {
9704
+ tmaxz = omaxz;
9705
+ }
9706
+ tc[0] = (tminx + tmaxx) * 0.5;
9707
+ tc[1] = (tminy + tmaxy) * 0.5;
9708
+ tc[2] = (tminz + tmaxz) * 0.5;
9709
+ th[0] = (tmaxx - tminx) * 0.5;
9710
+ th[1] = (tmaxy - tminy) * 0.5;
9711
+ th[2] = (tmaxz - tminz) * 0.5;
9712
+ this.min[0] = tminx;
9713
+ this.min[1] = tminy;
9714
+ this.min[2] = tminz;
9715
+ this.max[0] = tmaxx;
9716
+ this.max[1] = tmaxy;
9717
+ this.max[2] = tmaxz;
9718
+ };
9719
+ _proto.setFromTransformedAABB = function setFromTransformedAABB(aabb, m) {
9720
+ var bc = this.center;
9721
+ var br = this.halfExtents;
9722
+ var ac = aabb.center;
9723
+ var ar = aabb.halfExtents;
9724
+ var mx0 = m[0];
9725
+ var mx1 = m[4];
9726
+ var mx2 = m[8];
9727
+ var my0 = m[1];
9728
+ var my1 = m[5];
9729
+ var my2 = m[9];
9730
+ var mz0 = m[2];
9731
+ var mz1 = m[6];
9732
+ var mz2 = m[10];
9733
+ var mx0a = Math.abs(mx0);
9734
+ var mx1a = Math.abs(mx1);
9735
+ var mx2a = Math.abs(mx2);
9736
+ var my0a = Math.abs(my0);
9737
+ var my1a = Math.abs(my1);
9738
+ var my2a = Math.abs(my2);
9739
+ var mz0a = Math.abs(mz0);
9740
+ var mz1a = Math.abs(mz1);
9741
+ var mz2a = Math.abs(mz2);
9742
+ bc[0] = m[12] + mx0 * ac[0] + mx1 * ac[1] + mx2 * ac[2];
9743
+ bc[1] = m[13] + my0 * ac[0] + my1 * ac[1] + my2 * ac[2];
9744
+ bc[2] = m[14] + mz0 * ac[0] + mz1 * ac[1] + mz2 * ac[2];
9745
+ // vec3.set(
9746
+ // bc,
9747
+ // m[12] + mx0 * ac[0] + mx1 * ac[1] + mx2 * ac[2],
9748
+ // m[13] + my0 * ac[0] + my1 * ac[1] + my2 * ac[2],
9749
+ // m[14] + mz0 * ac[0] + mz1 * ac[1] + mz2 * ac[2],
9750
+ // );
9751
+ br[0] = mx0a * ar[0] + mx1a * ar[1] + mx2a * ar[2];
9752
+ br[1] = my0a * ar[0] + my1a * ar[1] + my2a * ar[2];
9753
+ br[2] = mz0a * ar[0] + mz1a * ar[1] + mz2a * ar[2];
9754
+ // vec3.set(
9755
+ // br,
9756
+ // mx0a * ar[0] + mx1a * ar[1] + mx2a * ar[2],
9757
+ // my0a * ar[0] + my1a * ar[1] + my2a * ar[2],
9758
+ // mz0a * ar[0] + mz1a * ar[1] + mz2a * ar[2],
9759
+ // );
9760
+ // this.min = vec3.sub(this.min, bc, br);
9761
+ // this.max = vec3.add(this.max, bc, br);
9762
+ subVec3(this.min, bc, br);
9763
+ addVec3(this.max, bc, br);
9764
+ };
9765
+ _proto.intersects = function intersects(aabb) {
9766
+ var aMax = this.getMax();
9767
+ var aMin = this.getMin();
9768
+ var bMax = aabb.getMax();
9769
+ var bMin = aabb.getMin();
9770
+ return aMin[0] <= bMax[0] && aMax[0] >= bMin[0] && aMin[1] <= bMax[1] && aMax[1] >= bMin[1] && aMin[2] <= bMax[2] && aMax[2] >= bMin[2];
9771
+ };
9772
+ _proto.intersection = function intersection(aabb) {
9773
+ if (!this.intersects(aabb)) {
9774
+ return null;
9775
+ }
9776
+ var intersection = new AABB();
9777
+ // const min = vec3.max(vec3.create(), this.getMin(), aabb.getMin());
9778
+ // const max = vec3.min(vec3.create(), this.getMax(), aabb.getMax());
9779
+ var min = maxVec3([0, 0, 0], this.getMin(), aabb.getMin());
9780
+ var max = minVec3([0, 0, 0], this.getMax(), aabb.getMax());
9781
+ intersection.setMinMax(min, max);
9782
+ return intersection;
10840
9783
  }
10841
- return fontStyle + " " + fontVariant + " " + fontWeight + " " + fontSizeString + " " + fontFamilies.join(',');
10842
- }
9784
+ // containsPoint(point: vec3) {
9785
+ // const min = this.getMin();
9786
+ // const max = this.getMax();
9787
+ // return !(
9788
+ // point[0] < min[0] ||
9789
+ // point[0] > max[0] ||
9790
+ // point[1] < min[1] ||
9791
+ // point[1] > max[1] ||
9792
+ // point[2] < min[2] ||
9793
+ // point[2] > max[2]
9794
+ // );
9795
+ // }
9796
+ /**
9797
+ * get n-vertex
9798
+ * @param plane plane of CullingVolume
9799
+ */;
9800
+ _proto.getNegativeFarPoint = function getNegativeFarPoint(plane) {
9801
+ if (plane.pnVertexFlag === 0x111) {
9802
+ return copyVec3([0, 0, 0], this.min);
9803
+ // return vec3.copy(vec3.create(), this.min);
9804
+ } else if (plane.pnVertexFlag === 0x110) {
9805
+ return [this.min[0], this.min[1], this.max[2]];
9806
+ // return vec3.fromValues(this.min[0], this.min[1], this.max[2]);
9807
+ } else if (plane.pnVertexFlag === 0x101) {
9808
+ return [this.min[0], this.max[1], this.min[2]];
9809
+ // return vec3.fromValues(this.min[0], this.max[1], this.min[2]);
9810
+ } else if (plane.pnVertexFlag === 0x100) {
9811
+ return [this.min[0], this.max[1], this.max[2]];
9812
+ // return vec3.fromValues(this.min[0], this.max[1], this.max[2]);
9813
+ } else if (plane.pnVertexFlag === 0x011) {
9814
+ return [this.max[0], this.min[1], this.min[2]];
9815
+ // return vec3.fromValues(this.max[0], this.min[1], this.min[2]);
9816
+ } else if (plane.pnVertexFlag === 0x010) {
9817
+ return [this.max[0], this.min[1], this.max[2]];
9818
+ // return vec3.fromValues(this.max[0], this.min[1], this.max[2]);
9819
+ } else if (plane.pnVertexFlag === 0x001) {
9820
+ return [this.max[0], this.max[1], this.min[2]];
9821
+ // return vec3.fromValues(this.max[0], this.max[1], this.min[2]);
9822
+ } else {
9823
+ return [this.max[0], this.max[1], this.max[2]];
9824
+ // return vec3.fromValues(this.max[0], this.max[1], this.max[2]);
9825
+ }
9826
+ }
9827
+ /**
9828
+ * get p-vertex
9829
+ * @param plane plane of CullingVolume
9830
+ */;
9831
+ _proto.getPositiveFarPoint = function getPositiveFarPoint(plane) {
9832
+ if (plane.pnVertexFlag === 0x111) {
9833
+ return copyVec3([0, 0, 0], this.max);
9834
+ // return vec3.copy(vec3.create(), this.max);
9835
+ } else if (plane.pnVertexFlag === 0x110) {
9836
+ return [this.max[0], this.max[1], this.min[2]];
9837
+ // return vec3.fromValues(this.max[0], this.max[1], this.min[2]);
9838
+ } else if (plane.pnVertexFlag === 0x101) {
9839
+ return [this.max[0], this.min[1], this.max[2]];
9840
+ // return vec3.fromValues(this.max[0], this.min[1], this.max[2]);
9841
+ } else if (plane.pnVertexFlag === 0x100) {
9842
+ return [this.max[0], this.min[1], this.min[2]];
9843
+ // return vec3.fromValues(this.max[0], this.min[1], this.min[2]);
9844
+ } else if (plane.pnVertexFlag === 0x011) {
9845
+ return [this.min[0], this.max[1], this.max[2]];
9846
+ // return vec3.fromValues(this.min[0], this.max[1], this.max[2]);
9847
+ } else if (plane.pnVertexFlag === 0x010) {
9848
+ return [this.min[0], this.max[1], this.min[2]];
9849
+ // return vec3.fromValues(this.min[0], this.max[1], this.min[2]);
9850
+ } else if (plane.pnVertexFlag === 0x001) {
9851
+ return [this.min[0], this.min[1], this.max[2]];
9852
+ // return vec3.fromValues(this.min[0], this.min[1], this.max[2]);
9853
+ } else {
9854
+ return [this.min[0], this.min[1], this.min[2]];
9855
+ // return vec3.fromValues(this.min[0], this.min[1], this.min[2]);
9856
+ }
9857
+ };
9858
+ return AABB;
9859
+ }();
10843
9860
 
10844
- /**
10845
- * Thanks for following contributor of codes
10846
- * https://gist.github.com/1866474
10847
- * http://paulirish.com/2011/requestanimationframe-for-smart-animating/
10848
- * http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
10849
- * https://github.com/Financial-Times/polyfill-library/blob/master/polyfills/requestAnimationFrame/polyfill.js
10850
- **/
10851
- var uId = 1;
10852
- var uniqueId = function uniqueId() {
10853
- return uId++;
10854
- };
10855
- // We use `self` instead of `window` for `WebWorker` support.
10856
- var root = typeof self === 'object' && self.self == self ? self :
10857
- // @ts-ignore
10858
- typeof global === 'object' && global.global == global ?
10859
- // @ts-ignore
10860
- global : {};
10861
- var nowOffset = Date.now();
10862
- // use performance api if exist, otherwise use Date.now.
10863
- // Date.now polyfill required.
10864
- var pnow = function pnow() {
10865
- if (root.performance && typeof root.performance.now === 'function') {
10866
- return root.performance.now();
9861
+ var Plane = /*#__PURE__*/function () {
9862
+ /**
9863
+ * lookup table for p-vertex & n-vertex when doing frustum culling
9864
+ */
9865
+
9866
+ function Plane(distance, normal) {
9867
+ this.distance = void 0;
9868
+ this.normal = void 0;
9869
+ this.pnVertexFlag = void 0;
9870
+ this.distance = distance || 0;
9871
+ this.normal = normal || glMatrix.vec3.fromValues(0, 1, 0);
9872
+ this.updatePNVertexFlag();
10867
9873
  }
10868
- // fallback
10869
- return Date.now() - nowOffset;
10870
- };
10871
- var reservedCBs = {};
10872
- var lastTime = Date.now();
10873
- var polyfillRaf = function polyfillRaf(callback) {
10874
- if (typeof callback !== 'function') {
10875
- throw new TypeError(callback + ' is not a function');
9874
+ var _proto = Plane.prototype;
9875
+ _proto.updatePNVertexFlag = function updatePNVertexFlag() {
9876
+ this.pnVertexFlag = (Number(this.normal[0] >= 0) << 8) + (Number(this.normal[1] >= 0) << 4) + Number(this.normal[2] >= 0);
9877
+ };
9878
+ _proto.distanceToPoint = function distanceToPoint(point) {
9879
+ return glMatrix.vec3.dot(point, this.normal) - this.distance;
9880
+ };
9881
+ _proto.normalize = function normalize() {
9882
+ var invLen = 1 / glMatrix.vec3.len(this.normal);
9883
+ glMatrix.vec3.scale(this.normal, this.normal, invLen);
9884
+ this.distance *= invLen;
9885
+ };
9886
+ _proto.intersectsLine = function intersectsLine(start, end, point) {
9887
+ var d0 = this.distanceToPoint(start);
9888
+ var d1 = this.distanceToPoint(end);
9889
+ var t = d0 / (d0 - d1);
9890
+ var intersects = t >= 0 && t <= 1;
9891
+ if (intersects && point) {
9892
+ glMatrix.vec3.lerp(point, start, end, t);
9893
+ }
9894
+ return intersects;
9895
+ };
9896
+ return Plane;
9897
+ }();
9898
+
9899
+ (function (Mask) {
9900
+ Mask[Mask["OUTSIDE"] = 4294967295] = "OUTSIDE";
9901
+ Mask[Mask["INSIDE"] = 0] = "INSIDE";
9902
+ Mask[Mask["INDETERMINATE"] = 2147483647] = "INDETERMINATE";
9903
+ })(exports.Mask || (exports.Mask = {}));
9904
+ var Frustum = /*#__PURE__*/function () {
9905
+ function Frustum(planes) {
9906
+ this.planes = [];
9907
+ if (planes) {
9908
+ this.planes = planes;
9909
+ } else {
9910
+ for (var i = 0; i < 6; i++) {
9911
+ this.planes.push(new Plane());
9912
+ }
9913
+ }
10876
9914
  }
10877
- var currentTime = Date.now();
10878
- var gap = currentTime - lastTime;
10879
- var delay = gap > 16 ? 0 : 16 - gap;
10880
- var id = uniqueId();
10881
- reservedCBs[id] = callback;
10882
- // keys(reservedCBs).length > 1 의미는 이미 setTimeout 이 걸려있는 경우.
10883
- // 함께 callback 이 실행될 수 있게 reservedCBs 에만 추가해주고 return
10884
- if (Object.keys(reservedCBs).length > 1) return id;
10885
- setTimeout(function () {
10886
- lastTime = currentTime;
10887
- var copied = reservedCBs;
10888
- reservedCBs = {};
10889
- Object.keys(copied).forEach(function (key) {
10890
- return copied[key](pnow());
9915
+ /**
9916
+ * extract 6 planes from projectionMatrix
9917
+ * @see http://www8.cs.umu.se/kurser/5DV051/HT12/lab/plane_extraction.pdf
9918
+ */
9919
+ var _proto = Frustum.prototype;
9920
+ _proto.extractFromVPMatrix = function extractFromVPMatrix(projectionMatrix) {
9921
+ // @ts-ignore
9922
+ var m0 = projectionMatrix[0],
9923
+ m1 = projectionMatrix[1],
9924
+ m2 = projectionMatrix[2],
9925
+ m3 = projectionMatrix[3],
9926
+ m4 = projectionMatrix[4],
9927
+ m5 = projectionMatrix[5],
9928
+ m6 = projectionMatrix[6],
9929
+ m7 = projectionMatrix[7],
9930
+ m8 = projectionMatrix[8],
9931
+ m9 = projectionMatrix[9],
9932
+ m10 = projectionMatrix[10],
9933
+ m11 = projectionMatrix[11],
9934
+ m12 = projectionMatrix[12],
9935
+ m13 = projectionMatrix[13],
9936
+ m14 = projectionMatrix[14],
9937
+ m15 = projectionMatrix[15];
9938
+ // right
9939
+ glMatrix.vec3.set(this.planes[0].normal, m3 - m0, m7 - m4, m11 - m8);
9940
+ this.planes[0].distance = m15 - m12;
9941
+ // left
9942
+ glMatrix.vec3.set(this.planes[1].normal, m3 + m0, m7 + m4, m11 + m8);
9943
+ this.planes[1].distance = m15 + m12;
9944
+ // bottom
9945
+ glMatrix.vec3.set(this.planes[2].normal, m3 + m1, m7 + m5, m11 + m9);
9946
+ this.planes[2].distance = m15 + m13;
9947
+ // top
9948
+ glMatrix.vec3.set(this.planes[3].normal, m3 - m1, m7 - m5, m11 - m9);
9949
+ this.planes[3].distance = m15 - m13;
9950
+ // far
9951
+ glMatrix.vec3.set(this.planes[4].normal, m3 - m2, m7 - m6, m11 - m10);
9952
+ this.planes[4].distance = m15 - m14;
9953
+ // near
9954
+ glMatrix.vec3.set(this.planes[5].normal, m3 + m2, m7 + m6, m11 + m10);
9955
+ this.planes[5].distance = m15 + m14;
9956
+ this.planes.forEach(function (plane) {
9957
+ plane.normalize();
9958
+ plane.updatePNVertexFlag();
10891
9959
  });
10892
- }, delay);
10893
- return id;
10894
- };
10895
- var polyfillCaf = function polyfillCaf(id) {
10896
- delete reservedCBs[id];
10897
- };
10898
- var vendorPrefixes = ['', 'webkit', 'moz', 'ms', 'o'];
10899
- var getRequestAnimationFrame = function getRequestAnimationFrame(vp) {
10900
- if (typeof vp !== 'string') return polyfillRaf;
10901
- if (vp === '') return root['requestAnimationFrame'];
10902
- return root[vp + 'RequestAnimationFrame'];
10903
- };
10904
- var getCancelAnimationFrame = function getCancelAnimationFrame(vp) {
10905
- if (typeof vp !== 'string') return polyfillCaf;
10906
- if (vp === '') return root['cancelAnimationFrame'];
10907
- return root[vp + 'CancelAnimationFrame'] || root[vp + 'CancelRequestAnimationFrame'];
10908
- };
10909
- var find = function find(arr, predicate) {
10910
- var i = 0;
10911
- while (arr[i] !== void 0) {
10912
- if (predicate(arr[i])) return arr[i];
10913
- i = i + 1;
9960
+ };
9961
+ return Frustum;
9962
+ }();
9963
+
9964
+ var Rectangle = /*#__PURE__*/function () {
9965
+ function Rectangle(x, y, width, height) {
9966
+ this.x = void 0;
9967
+ this.y = void 0;
9968
+ this.width = void 0;
9969
+ this.height = void 0;
9970
+ this.left = void 0;
9971
+ this.right = void 0;
9972
+ this.top = void 0;
9973
+ this.bottom = void 0;
9974
+ this.x = x;
9975
+ this.y = y;
9976
+ this.width = width;
9977
+ this.height = height;
9978
+ this.left = x;
9979
+ this.right = x + width;
9980
+ this.top = y;
9981
+ this.bottom = y + height;
10914
9982
  }
10915
- };
10916
- var vp = find(vendorPrefixes, function (vp) {
10917
- return !!getRequestAnimationFrame(vp);
10918
- });
10919
- var raf = getRequestAnimationFrame(vp);
10920
- var caf = getCancelAnimationFrame(vp);
10921
- root.requestAnimationFrame = raf;
10922
- root.cancelAnimationFrame = caf;
9983
+ var _proto = Rectangle.prototype;
9984
+ _proto.toJSON = function toJSON() {};
9985
+ return Rectangle;
9986
+ }();
10923
9987
 
10924
9988
  /**
10925
9989
  * Blink used them in code generation(css_properties.json5)
@@ -11416,9 +10480,9 @@ var BUILT_IN_PROPERTIES = [{
11416
10480
  var propertyMetadataCache = {};
11417
10481
  var unresolvedProperties = new WeakMap();
11418
10482
  // const uniqueAttributeSet = new Set<string>();
11419
- var tmpVec3a = glMatrix.vec3.create();
11420
- var tmpVec3b = glMatrix.vec3.create();
11421
- var tmpVec3c = glMatrix.vec3.create();
10483
+ // const tmpVec3a = vec3.create();
10484
+ // const tmpVec3b = vec3.create();
10485
+ // const tmpVec3c = vec3.create();
11422
10486
  var isPropertyResolved = function isPropertyResolved(object, name) {
11423
10487
  var properties = unresolvedProperties.get(object);
11424
10488
  if (!properties || properties.length === 0) {
@@ -11468,6 +10532,25 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
11468
10532
  usedAttributes: []
11469
10533
  };
11470
10534
  }
10535
+ if (!runtime.enableCSSParsing) {
10536
+ Object.assign(object.attributes, attributes);
10537
+ object.parsedStyle = Object.assign(object.parsedStyle, attributes);
10538
+ if (attributes.fill) {
10539
+ object.parsedStyle.fill = parseColor(attributes.fill);
10540
+ }
10541
+ if (attributes.stroke) {
10542
+ object.parsedStyle.stroke = parseColor(attributes.stroke);
10543
+ }
10544
+ // @ts-ignore
10545
+ if (attributes.cx || attributes.cy) {
10546
+ // @ts-ignore
10547
+ runtime.CSSPropertySyntaxFactory['<coordinate>'].postProcessor(object);
10548
+ }
10549
+ // console.log(object.parsedStyle);
10550
+ // console.log(attributes);
10551
+ this.updateGeometry(object);
10552
+ return;
10553
+ }
11471
10554
  var _options = options,
11472
10555
  skipUpdateAttribute = _options.skipUpdateAttribute,
11473
10556
  skipParse = _options.skipParse,
@@ -11526,10 +10609,10 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
11526
10609
  }
11527
10610
  attributeNames.forEach(function (name) {
11528
10611
  if (name in object.parsedStyle) {
11529
- _this2.postProcessProperty(name, object);
10612
+ _this2.postProcessProperty(name, object, attributeNames);
11530
10613
  }
11531
10614
  });
11532
- if (object.children.length) {
10615
+ if (runtime.enableCSSParsing && object.children.length) {
11533
10616
  attributeNames.forEach(function (name) {
11534
10617
  if (name in object.parsedStyle && _this2.isPropertyInheritable(name)) {
11535
10618
  // update children's inheritable
@@ -11632,13 +10715,13 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
11632
10715
  // return false;
11633
10716
  return used;
11634
10717
  };
11635
- _proto.postProcessProperty = function postProcessProperty(name, object) {
10718
+ _proto.postProcessProperty = function postProcessProperty(name, object, attributes) {
11636
10719
  var metadata = propertyMetadataCache[name];
11637
10720
  if (metadata && metadata.syntax) {
11638
10721
  var handler = metadata.syntax && this.getPropertySyntax(metadata.syntax);
11639
10722
  var propertyHandler = handler;
11640
10723
  if (propertyHandler && propertyHandler.postProcessor) {
11641
- propertyHandler.postProcessor(object);
10724
+ propertyHandler.postProcessor(object, attributes);
11642
10725
  }
11643
10726
  }
11644
10727
  }
@@ -11723,7 +10806,13 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
11723
10806
  var flipY = width < 0;
11724
10807
  var flipX = height < 0;
11725
10808
  // init with content box
11726
- var halfExtents = glMatrix.vec3.set(tmpVec3a, Math.abs(width) / 2, Math.abs(height) / 2, depth / 2);
10809
+ var halfExtents = [Math.abs(width) / 2, Math.abs(height) / 2, depth / 2];
10810
+ // const halfExtents = vec3.set(
10811
+ // tmpVec3a,
10812
+ // Math.abs(width) / 2,
10813
+ // Math.abs(height) / 2,
10814
+ // depth / 2,
10815
+ // );
11727
10816
  // anchor is center by default, don't account for lineWidth here
11728
10817
  var stroke = parsedStyle.stroke,
11729
10818
  lineWidth = parsedStyle.lineWidth,
@@ -11738,7 +10827,13 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
11738
10827
  if (object.nodeName === exports.Shape.TEXT) {
11739
10828
  delete parsedStyle.anchor;
11740
10829
  }
11741
- var center = glMatrix.vec3.set(tmpVec3b, (1 - (anchor && anchor[0] || 0) * 2) * width / 2 + offsetX, (1 - (anchor && anchor[1] || 0) * 2) * height / 2 + offsetY, (1 - (anchor && anchor[2] || 0) * 2) * halfExtents[2] + offsetZ);
10830
+ var center = [(1 - (anchor && anchor[0] || 0) * 2) * width / 2 + offsetX, (1 - (anchor && anchor[1] || 0) * 2) * height / 2 + offsetY, (1 - (anchor && anchor[2] || 0) * 2) * halfExtents[2] + offsetZ];
10831
+ // const center = vec3.set(
10832
+ // tmpVec3b,
10833
+ // ((1 - ((anchor && anchor[0]) || 0) * 2) * width) / 2 + offsetX,
10834
+ // ((1 - ((anchor && anchor[1]) || 0) * 2) * height) / 2 + offsetY,
10835
+ // (1 - ((anchor && anchor[2]) || 0) * 2) * halfExtents[2] + offsetZ,
10836
+ // );
11742
10837
  // update geometry's AABB
11743
10838
  geometry.contentBounds.update(center, halfExtents);
11744
10839
  // @see https://github.molgen.mpg.de/git-mirror/cairo/blob/master/src/cairo-stroke-style.c#L97..L128
@@ -11755,8 +10850,15 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
11755
10850
  var halfLineWidth = ((lineWidth || 0) + (increasedLineWidthForHitTesting || 0)) * expansion;
11756
10851
  // halfExtents[0] += halfLineWidth[0];
11757
10852
  // halfExtents[1] += halfLineWidth[1];
11758
- glMatrix.vec3.add(halfExtents, halfExtents, glMatrix.vec3.set(tmpVec3c, halfLineWidth, halfLineWidth, 0));
10853
+ halfExtents[0] += halfLineWidth;
10854
+ halfExtents[1] += halfLineWidth;
10855
+ // vec3.add(
10856
+ // halfExtents,
10857
+ // halfExtents,
10858
+ // vec3.set(tmpVec3c, halfLineWidth, halfLineWidth, 0),
10859
+ // );
11759
10860
  }
10861
+
11760
10862
  geometry.renderBounds.update(center, halfExtents);
11761
10863
  // account for shadow, only support constant value now
11762
10864
  if (shadowColor && shadowType && shadowType !== 'inner') {
@@ -11785,7 +10887,7 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
11785
10887
  params = _ref.params;
11786
10888
  if (name === 'blur') {
11787
10889
  var blurRadius = params[0].value;
11788
- geometry.renderBounds.update(geometry.renderBounds.center, glMatrix.vec3.add(geometry.renderBounds.halfExtents, geometry.renderBounds.halfExtents, glMatrix.vec3.fromValues(blurRadius, blurRadius, 0)));
10890
+ geometry.renderBounds.update(geometry.renderBounds.center, addVec3(geometry.renderBounds.halfExtents, geometry.renderBounds.halfExtents, [blurRadius, blurRadius, 0]));
11789
10891
  } else if (name === 'drop-shadow') {
11790
10892
  var _shadowOffsetX = params[0].value;
11791
10893
  var _shadowOffsetY = params[1].value;
@@ -11806,8 +10908,8 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
11806
10908
  });
11807
10909
  anchor = parsedStyle.anchor;
11808
10910
  // set transform origin
11809
- var usedOriginXValue = (flipY ? -1 : 1) * convertPercentUnit(transformOrigin[0], 0, object);
11810
- var usedOriginYValue = (flipX ? -1 : 1) * convertPercentUnit(transformOrigin[1], 1, object);
10911
+ var usedOriginXValue = (flipY ? -1 : 1) * (transformOrigin ? convertPercentUnit(transformOrigin[0], 0, object) : 0);
10912
+ var usedOriginYValue = (flipX ? -1 : 1) * (transformOrigin ? convertPercentUnit(transformOrigin[1], 1, object) : 0);
11811
10913
  usedOriginXValue = usedOriginXValue - (flipY ? -1 : 1) * (anchor && anchor[0] || 0) * geometry.contentBounds.halfExtents[0] * 2;
11812
10914
  usedOriginYValue = usedOriginYValue - (flipX ? -1 : 1) * (anchor && anchor[1] || 0) * geometry.contentBounds.halfExtents[1] * 2;
11813
10915
  object.setOrigin(usedOriginXValue, usedOriginYValue);
@@ -13694,37 +12796,37 @@ var OffscreenCanvasCreator = /*#__PURE__*/function () {
13694
12796
  this.context = void 0;
13695
12797
  }
13696
12798
  var _proto = OffscreenCanvasCreator.prototype;
13697
- _proto.getOrCreateCanvas = function getOrCreateCanvas(offscreenCanvas) {
12799
+ _proto.getOrCreateCanvas = function getOrCreateCanvas(offscreenCanvas, contextAttributes) {
13698
12800
  if (this.canvas) {
13699
12801
  return this.canvas;
13700
12802
  }
13701
12803
  // user-defined offscreen canvas
13702
12804
  if (offscreenCanvas) {
13703
12805
  this.canvas = offscreenCanvas;
13704
- this.context = this.canvas.getContext('2d');
12806
+ this.context = this.canvas.getContext('2d', contextAttributes);
13705
12807
  } else {
13706
12808
  try {
13707
12809
  // OffscreenCanvas2D measureText can be up to 40% faster.
13708
12810
  this.canvas = new window.OffscreenCanvas(0, 0);
13709
- this.context = this.canvas.getContext('2d');
12811
+ this.context = this.canvas.getContext('2d', contextAttributes);
13710
12812
  if (!this.context || !this.context.measureText) {
13711
12813
  this.canvas = document.createElement('canvas');
13712
12814
  this.context = this.canvas.getContext('2d');
13713
12815
  }
13714
12816
  } catch (ex) {
13715
12817
  this.canvas = document.createElement('canvas');
13716
- this.context = this.canvas.getContext('2d');
12818
+ this.context = this.canvas.getContext('2d', contextAttributes);
13717
12819
  }
13718
12820
  }
13719
12821
  this.canvas.width = 10;
13720
12822
  this.canvas.height = 10;
13721
12823
  return this.canvas;
13722
12824
  };
13723
- _proto.getOrCreateContext = function getOrCreateContext(offscreenCanvas) {
12825
+ _proto.getOrCreateContext = function getOrCreateContext(offscreenCanvas, contextAttributes) {
13724
12826
  if (this.context) {
13725
12827
  return this.context;
13726
12828
  }
13727
- this.getOrCreateCanvas(offscreenCanvas);
12829
+ this.getOrCreateCanvas(offscreenCanvas, contextAttributes);
13728
12830
  return this.context;
13729
12831
  };
13730
12832
  return OffscreenCanvasCreator;
@@ -13890,7 +12992,9 @@ var RenderingService = /*#__PURE__*/function () {
13890
12992
  enableDirtyCheck = _canvasConfig$rendere.enableDirtyCheck,
13891
12993
  enableCulling = _canvasConfig$rendere.enableCulling;
13892
12994
  // recalc style values
13893
- this.globalRuntime.styleValueRegistry.recalc(displayObject);
12995
+ if (this.globalRuntime.enableCSSParsing) {
12996
+ this.globalRuntime.styleValueRegistry.recalc(displayObject);
12997
+ }
13894
12998
  // TODO: relayout
13895
12999
  // dirtycheck first
13896
13000
  var objectChanged = enableDirtyCheck ? this.hooks.dirtycheck.call(displayObject) : displayObject;
@@ -15226,6 +14330,7 @@ runtime.CSSPropertySyntaxFactory = CSSPropertySyntaxFactory;
15226
14330
  runtime.styleValueRegistry = new DefaultStyleValueRegistry();
15227
14331
  runtime.layoutRegistry = null;
15228
14332
  runtime.globalThis = getGlobalThis();
14333
+ runtime.enableCSSParsing = true;
15229
14334
 
15230
14335
  var AbstractRendererPlugin = /*#__PURE__*/function () {
15231
14336
  function AbstractRendererPlugin() {
@@ -15768,8 +14873,10 @@ var PrepareRendererPlugin = /*#__PURE__*/function () {
15768
14873
  };
15769
14874
  var handleMounted = function handleMounted(e) {
15770
14875
  var object = e.target;
15771
- // recalc style values
15772
- runtime.styleValueRegistry.recalc(object);
14876
+ if (runtime.enableCSSParsing) {
14877
+ // recalc style values
14878
+ runtime.styleValueRegistry.recalc(object);
14879
+ }
15773
14880
  runtime.sceneGraphService.dirtifyToRoot(object);
15774
14881
  renderingService.dirtify();
15775
14882
  };
@@ -15804,6 +14911,7 @@ var PrepareRendererPlugin = /*#__PURE__*/function () {
15804
14911
  canvas.removeEventListener(exports.ElementEvent.UNMOUNTED, handleUnmounted);
15805
14912
  canvas.removeEventListener(exports.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
15806
14913
  canvas.removeEventListener(exports.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
14914
+ _this.toSync.clear();
15807
14915
  });
15808
14916
  renderingService.hooks.endFrame.tap(PrepareRendererPlugin.tag, function () {
15809
14917
  // if (this.isFirstTimeRendering) {