@antv/g 5.1.3-alpha.1 → 5.1.5

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.
package/dist/index.js CHANGED
@@ -8,8 +8,8 @@ var eventemitter3 = require('eventemitter3');
8
8
  var tslib = require('tslib');
9
9
  var glMatrix = require('gl-matrix');
10
10
  var d3 = require('d3-color');
11
- var util = require('@antv/util');
12
11
  var gMath = require('@antv/g-math');
12
+ var util = require('@antv/util');
13
13
  var requestAnimationFramePolyfill = require('request-animation-frame-polyfill');
14
14
 
15
15
  function _interopNamespace(e) {
@@ -1186,554 +1186,167 @@ var Rectangle = /*#__PURE__*/function () {
1186
1186
  return Rectangle;
1187
1187
  }();
1188
1188
 
1189
- var SceneGraphSelectorFactory = manaSyringe.Syringe.defineToken('SceneGraphSelectorFactory');
1190
- var SceneGraphSelector = manaSyringe.Syringe.defineToken('SceneGraphSelector', {
1191
- multiple: false
1192
- });
1193
- var NAME_REGEXP = /\[\s*name=(.*)\s*\]/;
1189
+ function DCHECK(bool) {
1190
+ if (!bool) {
1191
+ throw new Error();
1192
+ }
1193
+ }
1194
+ function DCHECK_EQ(a, b) {
1195
+ if (a !== b) {
1196
+ throw new Error();
1197
+ }
1198
+ }
1199
+ function DCHECK_NE(a, b) {
1200
+ if (a === b) {
1201
+ throw new Error();
1202
+ }
1203
+ }
1204
+ function isUndefined(a) {
1205
+ return typeof a === 'undefined';
1206
+ }
1207
+ function isNil(a) {
1208
+ return a == null;
1209
+ }
1210
+ function isNumber(value) {
1211
+ return typeof value === 'number';
1212
+ }
1213
+ function isFunction(value) {
1214
+ return typeof value === 'function';
1215
+ }
1216
+ function isBoolean(value) {
1217
+ return typeof value === 'boolean';
1218
+ }
1219
+ function isObject(value) {
1220
+ return Object.prototype.toString.call(value) === '[object Object]';
1221
+ }
1222
+
1223
+ var canvasMap = {};
1224
+ var defaultCanvasIdCounter = 0;
1194
1225
  /**
1195
- * support the following DOM API:
1196
- * * getElementById
1197
- * * getElementsByClassName
1198
- * * getElementsByName
1199
- * * getElementsByTag
1200
- * * querySelector
1201
- * * querySelectorAll
1226
+ * destroy existed canvas with the same id
1202
1227
  */
1203
1228
 
1204
- exports.DefaultSceneGraphSelector = /*#__PURE__*/function () {
1205
- function DefaultSceneGraphSelector() {}
1206
-
1207
- var _proto = DefaultSceneGraphSelector.prototype;
1208
-
1209
- _proto.selectOne = function selectOne(query, root) {
1210
- if (query.startsWith('.')) {
1211
- return root.find(function (node) {
1212
- // return !node.shadow && node.id === query.substring(1);
1213
- return node.className === query.substring(1);
1214
- });
1215
- } else if (query.startsWith('#')) {
1216
- // getElementById('id')
1217
- return root.find(function (node) {
1218
- // return !node.shadow && node.id === query.substring(1);
1219
- return node.id === query.substring(1);
1220
- });
1221
- } else if (query.startsWith('[name=')) {
1222
- var matches = query.match(NAME_REGEXP);
1223
-
1224
- if (matches && matches.length > 1) {
1225
- var targetName = matches[1].replace(/"/g, ''); // getElementByName();
1229
+ function cleanExistedCanvas(container, canvas) {
1230
+ if (container) {
1231
+ var id = typeof container === 'string' ? container : container.id || defaultCanvasIdCounter++;
1226
1232
 
1227
- return root.find(function (node) {
1228
- return root !== node && node.name === targetName;
1229
- });
1230
- } else {
1231
- return null;
1232
- }
1233
- } else {
1234
- // getElementsByTag('circle');
1235
- return root.find(function (node) {
1236
- return root !== node && node.nodeName === query;
1237
- });
1233
+ if (canvasMap[id]) {
1234
+ canvasMap[id].destroy();
1238
1235
  }
1239
- };
1240
1236
 
1241
- _proto.selectAll = function selectAll(query, root) {
1242
- // only support `[name="${name}"]` `.className` `#id`
1243
- if (query.startsWith('.')) {
1244
- // getElementsByClassName('className');
1245
- // should not include itself
1246
- return root.findAll(function (node) {
1247
- return root !== node && node.className === query.substring(1);
1248
- });
1249
- } else if (query.startsWith('#')) {
1250
- return root.findAll(function (node) {
1251
- return root !== node && node.id === query.substring(1);
1252
- });
1253
- } else if (query.startsWith('[name=')) {
1254
- // getElementsByName();
1255
- var matches = query.match(NAME_REGEXP);
1237
+ canvasMap[id] = canvas;
1238
+ }
1239
+ }
1240
+ var isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
1256
1241
 
1257
- if (matches && matches.length > 1) {
1258
- var targetName = matches[1].replace(/"/g, ''); // getElementByName();
1242
+ /**
1243
+ * https://github.com/gre/bezier-easing
1244
+ * BezierEasing - use bezier curve for transition easing function
1245
+ * by Gaëtan Renaudeau 2014 - 2015 – MIT License
1246
+ */
1247
+ // These values are established by empiricism with tests (tradeoff: performance VS precision)
1248
+ var NEWTON_ITERATIONS = 4;
1249
+ var NEWTON_MIN_SLOPE = 0.001;
1250
+ var SUBDIVISION_PRECISION = 0.0000001;
1251
+ var SUBDIVISION_MAX_ITERATIONS = 10;
1252
+ var kSplineTableSize = 11;
1253
+ var kSampleStepSize = 1.0 / (kSplineTableSize - 1.0);
1254
+ var float32ArraySupported = typeof Float32Array === 'function';
1255
+ var A = function A(aA1, aA2) {
1256
+ return 1.0 - 3.0 * aA2 + 3.0 * aA1;
1257
+ };
1258
+ var B = function B(aA1, aA2) {
1259
+ return 3.0 * aA2 - 6.0 * aA1;
1260
+ };
1261
+ var C = function C(aA1) {
1262
+ return 3.0 * aA1;
1263
+ }; // Returns x(t) given t, x1, and x2, or y(t) given t, y1, and y2.
1259
1264
 
1260
- return root.findAll(function (node) {
1261
- return root !== node && node.name === targetName;
1262
- });
1263
- } else {
1264
- return [];
1265
- }
1266
- } else {
1267
- // getElementsByTag('circle');
1268
- return root.findAll(function (node) {
1269
- return root !== node && node.nodeName === query;
1270
- });
1271
- }
1272
- } // eslint-disable-next-line @typescript-eslint/no-unused-vars
1273
- ;
1265
+ var calcBezier = function calcBezier(aT, aA1, aA2) {
1266
+ return ((A(aA1, aA2) * aT + B(aA1, aA2)) * aT + C(aA1)) * aT;
1267
+ }; // Returns dx/dt given t, x1, and x2, or dy/dt given t, y1, and y2.
1274
1268
 
1275
- _proto.is = function is() {
1276
- // TODO: need a simple `matches` implementation
1277
- return true;
1278
- };
1269
+ var getSlope = function getSlope(aT, aA1, aA2) {
1270
+ return 3.0 * A(aA1, aA2) * aT * aT + 2.0 * B(aA1, aA2) * aT + C(aA1);
1271
+ };
1272
+ var binarySubdivide = function binarySubdivide(aX, aA, aB, mX1, mX2) {
1273
+ var currentX,
1274
+ currentT,
1275
+ i = 0;
1279
1276
 
1280
- return DefaultSceneGraphSelector;
1281
- }();
1277
+ do {
1278
+ currentT = aA + (aB - aA) / 2.0;
1279
+ currentX = calcBezier(currentT, mX1, mX2) - aX;
1280
+ if (currentX > 0.0) aB = currentT;else aA = currentT;
1281
+ } while (Math.abs(currentX) > SUBDIVISION_PRECISION && ++i < SUBDIVISION_MAX_ITERATIONS);
1282
1282
 
1283
- exports.DefaultSceneGraphSelector = tslib.__decorate([manaSyringe.singleton({
1284
- token: SceneGraphSelector
1285
- })], exports.DefaultSceneGraphSelector);
1283
+ return currentT;
1284
+ };
1285
+ var newtonRaphsonIterate = function newtonRaphsonIterate(aX, aGuessT, mX1, mX2) {
1286
+ for (var i = 0; i < NEWTON_ITERATIONS; ++i) {
1287
+ var currentSlope = getSlope(aGuessT, mX1, mX2);
1288
+ if (currentSlope === 0.0) return aGuessT;
1289
+ var currentX = calcBezier(aGuessT, mX1, mX2) - aX;
1290
+ aGuessT -= currentX / currentSlope;
1291
+ }
1286
1292
 
1287
- /**
1288
- * built-in events for element
1289
- * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationEvent
1290
- *
1291
- * TODO: use MutationObserver instead
1292
- * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
1293
- */
1293
+ return aGuessT;
1294
+ };
1295
+ var bezier = function bezier(mX1, mY1, mX2, mY2) {
1296
+ if (!(0 <= mX1 && mX1 <= 1 && 0 <= mX2 && mX2 <= 1)) throw new Error('bezier x values must be in [0, 1] range');
1297
+ if (mX1 === mY1 && mX2 === mY2) return function (t) {
1298
+ return t;
1299
+ }; // Precompute samples table
1294
1300
 
1295
- (function (ElementEvent) {
1296
- ElementEvent["DESTROY"] = "destroy";
1297
- /**
1298
- * @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMAttrModified
1299
- */
1301
+ var sampleValues = float32ArraySupported ? new Float32Array(kSplineTableSize) : new Array(kSplineTableSize);
1300
1302
 
1301
- ElementEvent["ATTR_MODIFIED"] = "DOMAttrModified";
1302
- /**
1303
- * it has been inserted
1304
- * @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMNodeInserted
1305
- */
1303
+ for (var i = 0; i < kSplineTableSize; ++i) {
1304
+ sampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2);
1305
+ }
1306
1306
 
1307
- ElementEvent["INSERTED"] = "DOMNodeInserted";
1308
- /**
1309
- * it has had a child inserted
1310
- */
1307
+ var getTForX = function getTForX(aX) {
1308
+ var intervalStart = 0.0;
1309
+ var currentSample = 1;
1310
+ var lastSample = kSplineTableSize - 1;
1311
1311
 
1312
- ElementEvent["CHILD_INSERTED"] = "child-inserted";
1313
- /**
1314
- * it is being removed
1315
- * @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMNodeRemoved
1316
- */
1312
+ for (; currentSample !== lastSample && sampleValues[currentSample] <= aX; ++currentSample) {
1313
+ intervalStart += kSampleStepSize;
1314
+ }
1317
1315
 
1318
- ElementEvent["REMOVED"] = "removed";
1319
- /**
1320
- * it has had a child removed
1321
- */
1316
+ --currentSample; // Interpolate to provide an initial guess for t
1322
1317
 
1323
- ElementEvent["CHILD_REMOVED"] = "child-removed";
1324
- /**
1325
- * @see https://www.w3.org/TR/DOM-Level-3-Events/#domnodeinsertedintodocument
1326
- */
1318
+ var dist = (aX - sampleValues[currentSample]) / (sampleValues[currentSample + 1] - sampleValues[currentSample]);
1319
+ var guessForT = intervalStart + dist * kSampleStepSize;
1320
+ var initialSlope = getSlope(guessForT, mX1, mX2);
1321
+ if (initialSlope >= NEWTON_MIN_SLOPE) return newtonRaphsonIterate(aX, guessForT, mX1, mX2);else if (initialSlope === 0.0) return guessForT;else {
1322
+ return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize, mX1, mX2);
1323
+ }
1324
+ };
1327
1325
 
1328
- ElementEvent["MOUNTED"] = "DOMNodeInsertedIntoDocument";
1329
- /**
1330
- * @see https://www.w3.org/TR/DOM-Level-3-Events/#domnoderemovedfromdocument
1331
- */
1326
+ return function (t) {
1327
+ // Because JavaScript number are imprecise, we should guarantee the extremes are right.
1328
+ if (t === 0 || t === 1) return t;
1329
+ return calcBezier(getTForX(t), mY1, mY2);
1330
+ };
1331
+ };
1332
1332
 
1333
- ElementEvent["UNMOUNTED"] = "DOMNodeRemovedFromDocument";
1334
- ElementEvent["BOUNDS_CHANGED"] = "bounds-changed";
1335
- ElementEvent["GEOMETRY_BOUNDS_CHANGED"] = "geometry-bounds-changed";
1336
- /**
1337
- * trigger when z-index changed
1338
- */
1333
+ function clamp(number, boundOne, boundTwo) {
1334
+ if (!boundTwo) {
1335
+ return Math.max(number, boundOne) === boundOne ? number : boundOne;
1336
+ } else if (Math.min(number, boundOne) === number) {
1337
+ return boundOne;
1338
+ } else if (Math.max(number, boundTwo) === number) {
1339
+ return boundTwo;
1340
+ }
1339
1341
 
1340
- ElementEvent["RENDER_ORDER_CHANGED"] = "render-order-changed";
1341
- })(exports.ElementEvent || (exports.ElementEvent = {}));
1342
-
1343
- /**
1344
- * An DOM-compatible synthetic event implementation that is "forwarded" on behalf of an original
1345
- * FederatedEvent or native {@link https://dom.spec.whatwg.org/#event Event}.
1346
- */
1347
-
1348
- var FederatedEvent = /*#__PURE__*/function () {
1349
- /**
1350
- * The event boundary which manages this event. Propagation can only occur
1351
- * within the boundary's jurisdiction.
1352
- */
1353
- function FederatedEvent(manager) {
1354
- this.type = void 0;
1355
- this.eventPhase = FederatedEvent.prototype.NONE;
1356
- this.target = void 0;
1357
- this.bubbles = true;
1358
- this.cancelBubble = true;
1359
- this.cancelable = false;
1360
- this.currentTarget = void 0;
1361
- this.defaultPrevented = false;
1362
- this.timeStamp = void 0;
1363
- this.nativeEvent = void 0;
1364
- this.originalEvent = void 0;
1365
- this.propagationStopped = false;
1366
- this.propagationImmediatelyStopped = false;
1367
- this.manager = void 0;
1368
- this.detail = void 0;
1369
- this.layer = new Point();
1370
- this.page = new Point();
1371
- this.canvas = new Point();
1372
- this.viewport = new Point();
1373
- this.path = void 0;
1374
- this.view = void 0;
1375
- this.which = void 0;
1376
- this.returnValue = void 0;
1377
- this.srcElement = void 0;
1378
- this.composed = false;
1379
- this.isTrusted = void 0;
1380
- this.NONE = 0;
1381
- this.CAPTURING_PHASE = 1;
1382
- this.AT_TARGET = 2;
1383
- this.BUBBLING_PHASE = 3;
1384
- this.manager = manager;
1385
- }
1386
-
1387
- var _proto = FederatedEvent.prototype;
1388
-
1389
- /**
1390
- * The propagation path for this event
1391
- * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Event/composedPath
1392
- *
1393
- * So composedPath()[0] represents the original target.
1394
- * @see https://polymer-library.polymer-project.org/3.0/docs/devguide/events#retargeting
1395
- */
1396
- _proto.composedPath = function composedPath() {
1397
- if (this.manager && (!this.path || this.path[0] !== this.target)) {
1398
- this.path = this.target ? this.manager.propagationPath(this.target) : [];
1399
- }
1400
-
1401
- return this.path;
1402
- }
1403
- /**
1404
- * @deprecated
1405
- */
1406
- ;
1407
-
1408
- /**
1409
- * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Event/preventDefault
1410
- */
1411
- _proto.preventDefault = function preventDefault() {
1412
- if (this.nativeEvent instanceof Event && this.nativeEvent.cancelable) {
1413
- this.nativeEvent.preventDefault();
1414
- }
1415
-
1416
- this.defaultPrevented = true;
1417
- }
1418
- /**
1419
- * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Event/stopImmediatePropagation
1420
- */
1421
- ;
1422
-
1423
- _proto.stopImmediatePropagation = function stopImmediatePropagation() {
1424
- this.propagationImmediatelyStopped = true;
1425
- }
1426
- /**
1427
- * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Event/stopPropagation
1428
- */
1429
- ;
1430
-
1431
- _proto.stopPropagation = function stopPropagation() {
1432
- this.propagationStopped = true;
1433
- }
1434
- /**
1435
- * @see https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/view
1436
- */
1437
- ;
1438
-
1439
- /**
1440
- * added for compatibility with DOM Event,
1441
- * deprecated props and methods
1442
- */
1443
- _proto.initEvent = function initEvent() {};
1444
-
1445
- _proto.initUIEvent = function initUIEvent() {};
1446
-
1447
- _createClass(FederatedEvent, [{
1448
- key: "name",
1449
- get:
1450
- /**
1451
- * The type of event, supports the following:
1452
- * * pointerdown
1453
- * * touchstart
1454
- * * mousedown
1455
- * * rightdown
1456
- * * ...
1457
- */
1458
-
1459
- /**
1460
- * @deprecated
1461
- */
1462
- function get() {
1463
- return this.type;
1464
- }
1465
- /**
1466
- * The propagation phase.
1467
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Event/eventPhase
1468
- */
1469
-
1470
- }, {
1471
- key: "layerX",
1472
- get: function get() {
1473
- return this.layer.x;
1474
- }
1475
- }, {
1476
- key: "layerY",
1477
- get: function get() {
1478
- return this.layer.y;
1479
- }
1480
- /**
1481
- * The coordinates of the event relative to the DOM document.
1482
- * This is a non-standard property.
1483
- * relative to the DOM document.
1484
- * @see https://developer.mozilla.org/zh-CN/docs/Web/API/MouseEvent/pageX
1485
- */
1486
-
1487
- }, {
1488
- key: "pageX",
1489
- get: function get() {
1490
- return this.page.x;
1491
- }
1492
- }, {
1493
- key: "pageY",
1494
- get: function get() {
1495
- return this.page.y;
1496
- }
1497
- /**
1498
- * relative to Canvas, origin is left-top
1499
- */
1500
-
1501
- }, {
1502
- key: "x",
1503
- get: function get() {
1504
- return this.canvas.x;
1505
- }
1506
- }, {
1507
- key: "y",
1508
- get: function get() {
1509
- return this.canvas.y;
1510
- }
1511
- }, {
1512
- key: "canvasX",
1513
- get: function get() {
1514
- return this.canvas.x;
1515
- }
1516
- }, {
1517
- key: "canvasY",
1518
- get: function get() {
1519
- return this.canvas.y;
1520
- }
1521
- /**
1522
- * relative to Viewport, account for Camera
1523
- */
1524
-
1525
- }, {
1526
- key: "viewportX",
1527
- get: function get() {
1528
- return this.viewport.x;
1529
- }
1530
- }, {
1531
- key: "viewportY",
1532
- get: function get() {
1533
- return this.viewport.y;
1534
- }
1535
- }, {
1536
- key: "propagationPath",
1537
- get: function get() {
1538
- return this.composedPath();
1539
- }
1540
- }]);
1541
-
1542
- return FederatedEvent;
1543
- }();
1544
-
1545
- var MutationEvent = /*#__PURE__*/function (_FederatedEvent) {
1546
- _inheritsLoose(MutationEvent, _FederatedEvent);
1547
-
1548
- function MutationEvent(typeArg, relatedNode, prevValue, newValue, attrName, attrChange, prevParsedValue, newParsedValue) {
1549
- var _this;
1550
-
1551
- _this = _FederatedEvent.call(this, null) || this;
1552
- _this.relatedNode = void 0;
1553
- _this.prevValue = void 0;
1554
- _this.newValue = void 0;
1555
- _this.attrName = void 0;
1556
- _this.attrChange = void 0;
1557
- _this.prevParsedValue = void 0;
1558
- _this.newParsedValue = void 0;
1559
- _this.relatedNode = relatedNode;
1560
- _this.prevValue = prevValue;
1561
- _this.newValue = newValue;
1562
- _this.attrName = attrName;
1563
- _this.attrChange = attrChange;
1564
- _this.prevParsedValue = prevParsedValue;
1565
- _this.newParsedValue = newParsedValue;
1566
- _this.type = typeArg;
1567
- return _this;
1568
- }
1569
-
1570
- return MutationEvent;
1571
- }(FederatedEvent);
1572
- MutationEvent.ADDITION = 2;
1573
- MutationEvent.MODIFICATION = 1;
1574
- MutationEvent.REMOVAL = 3;
1575
-
1576
- function DCHECK(bool) {
1577
- if (!bool) {
1578
- throw new Error();
1579
- }
1580
- }
1581
- function DCHECK_EQ(a, b) {
1582
- if (a !== b) {
1583
- throw new Error();
1584
- }
1585
- }
1586
- function DCHECK_NE(a, b) {
1587
- if (a === b) {
1588
- throw new Error();
1589
- }
1590
- }
1591
- function isUndefined(a) {
1592
- return typeof a === 'undefined';
1593
- }
1594
- function isNil(a) {
1595
- return a == null;
1596
- }
1597
- function isNumber(value) {
1598
- return typeof value === 'number';
1599
- }
1600
- function isFunction(value) {
1601
- return typeof value === 'function';
1602
- }
1603
- function isBoolean(value) {
1604
- return typeof value === 'boolean';
1605
- }
1606
- function isObject(value) {
1607
- return Object.prototype.toString.call(value) === '[object Object]';
1608
- }
1609
-
1610
- var canvasMap = {};
1611
- var defaultCanvasIdCounter = 0;
1612
- /**
1613
- * destroy existed canvas with the same id
1614
- */
1615
-
1616
- function cleanExistedCanvas(container, canvas) {
1617
- if (container) {
1618
- var id = typeof container === 'string' ? container : container.id || defaultCanvasIdCounter++;
1619
-
1620
- if (canvasMap[id]) {
1621
- canvasMap[id].destroy();
1622
- }
1623
-
1624
- canvasMap[id] = canvas;
1625
- }
1626
- }
1627
- var isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
1628
-
1629
- /**
1630
- * https://github.com/gre/bezier-easing
1631
- * BezierEasing - use bezier curve for transition easing function
1632
- * by Gaëtan Renaudeau 2014 - 2015 – MIT License
1633
- */
1634
- // These values are established by empiricism with tests (tradeoff: performance VS precision)
1635
- var NEWTON_ITERATIONS = 4;
1636
- var NEWTON_MIN_SLOPE = 0.001;
1637
- var SUBDIVISION_PRECISION = 0.0000001;
1638
- var SUBDIVISION_MAX_ITERATIONS = 10;
1639
- var kSplineTableSize = 11;
1640
- var kSampleStepSize = 1.0 / (kSplineTableSize - 1.0);
1641
- var float32ArraySupported = typeof Float32Array === 'function';
1642
- var A = function A(aA1, aA2) {
1643
- return 1.0 - 3.0 * aA2 + 3.0 * aA1;
1644
- };
1645
- var B = function B(aA1, aA2) {
1646
- return 3.0 * aA2 - 6.0 * aA1;
1647
- };
1648
- var C = function C(aA1) {
1649
- return 3.0 * aA1;
1650
- }; // Returns x(t) given t, x1, and x2, or y(t) given t, y1, and y2.
1651
-
1652
- var calcBezier = function calcBezier(aT, aA1, aA2) {
1653
- return ((A(aA1, aA2) * aT + B(aA1, aA2)) * aT + C(aA1)) * aT;
1654
- }; // Returns dx/dt given t, x1, and x2, or dy/dt given t, y1, and y2.
1655
-
1656
- var getSlope = function getSlope(aT, aA1, aA2) {
1657
- return 3.0 * A(aA1, aA2) * aT * aT + 2.0 * B(aA1, aA2) * aT + C(aA1);
1658
- };
1659
- var binarySubdivide = function binarySubdivide(aX, aA, aB, mX1, mX2) {
1660
- var currentX,
1661
- currentT,
1662
- i = 0;
1663
-
1664
- do {
1665
- currentT = aA + (aB - aA) / 2.0;
1666
- currentX = calcBezier(currentT, mX1, mX2) - aX;
1667
- if (currentX > 0.0) aB = currentT;else aA = currentT;
1668
- } while (Math.abs(currentX) > SUBDIVISION_PRECISION && ++i < SUBDIVISION_MAX_ITERATIONS);
1669
-
1670
- return currentT;
1671
- };
1672
- var newtonRaphsonIterate = function newtonRaphsonIterate(aX, aGuessT, mX1, mX2) {
1673
- for (var i = 0; i < NEWTON_ITERATIONS; ++i) {
1674
- var currentSlope = getSlope(aGuessT, mX1, mX2);
1675
- if (currentSlope === 0.0) return aGuessT;
1676
- var currentX = calcBezier(aGuessT, mX1, mX2) - aX;
1677
- aGuessT -= currentX / currentSlope;
1678
- }
1679
-
1680
- return aGuessT;
1681
- };
1682
- var bezier = function bezier(mX1, mY1, mX2, mY2) {
1683
- if (!(0 <= mX1 && mX1 <= 1 && 0 <= mX2 && mX2 <= 1)) throw new Error('bezier x values must be in [0, 1] range');
1684
- if (mX1 === mY1 && mX2 === mY2) return function (t) {
1685
- return t;
1686
- }; // Precompute samples table
1687
-
1688
- var sampleValues = float32ArraySupported ? new Float32Array(kSplineTableSize) : new Array(kSplineTableSize);
1689
-
1690
- for (var i = 0; i < kSplineTableSize; ++i) {
1691
- sampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2);
1692
- }
1693
-
1694
- var getTForX = function getTForX(aX) {
1695
- var intervalStart = 0.0;
1696
- var currentSample = 1;
1697
- var lastSample = kSplineTableSize - 1;
1698
-
1699
- for (; currentSample !== lastSample && sampleValues[currentSample] <= aX; ++currentSample) {
1700
- intervalStart += kSampleStepSize;
1701
- }
1702
-
1703
- --currentSample; // Interpolate to provide an initial guess for t
1704
-
1705
- var dist = (aX - sampleValues[currentSample]) / (sampleValues[currentSample + 1] - sampleValues[currentSample]);
1706
- var guessForT = intervalStart + dist * kSampleStepSize;
1707
- var initialSlope = getSlope(guessForT, mX1, mX2);
1708
- if (initialSlope >= NEWTON_MIN_SLOPE) return newtonRaphsonIterate(aX, guessForT, mX1, mX2);else if (initialSlope === 0.0) return guessForT;else {
1709
- return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize, mX1, mX2);
1710
- }
1711
- };
1712
-
1713
- return function (t) {
1714
- // Because JavaScript number are imprecise, we should guarantee the extremes are right.
1715
- if (t === 0 || t === 1) return t;
1716
- return calcBezier(getTForX(t), mY1, mY2);
1717
- };
1718
- };
1719
-
1720
- function clamp(number, boundOne, boundTwo) {
1721
- if (!boundTwo) {
1722
- return Math.max(number, boundOne) === boundOne ? number : boundOne;
1723
- } else if (Math.min(number, boundOne) === number) {
1724
- return boundOne;
1725
- } else if (Math.max(number, boundTwo) === number) {
1726
- return boundTwo;
1727
- }
1728
-
1729
- return number;
1730
- }
1731
- function getAngle(angle) {
1732
- if (angle === undefined) {
1733
- return 0;
1734
- } else if (angle > 360 || angle < -360) {
1735
- return angle % 360;
1736
- }
1342
+ return number;
1343
+ }
1344
+ function getAngle(angle) {
1345
+ if (angle === undefined) {
1346
+ return 0;
1347
+ } else if (angle > 360 || angle < -360) {
1348
+ return angle % 360;
1349
+ }
1737
1350
 
1738
1351
  return angle;
1739
1352
  }
@@ -2407,6 +2020,11 @@ var TOUCH_TO_POINTER = {
2407
2020
  */
2408
2021
 
2409
2022
  PropertySyntax["NUMBER"] = "<number>";
2023
+ /**
2024
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/angle
2025
+ */
2026
+
2027
+ PropertySyntax["ANGLE"] = "<angle>";
2410
2028
  /**
2411
2029
  * <number> with range 0..1
2412
2030
  * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#opacity_value
@@ -2434,32 +2052,287 @@ var TOUCH_TO_POINTER = {
2434
2052
  * @see https://developer.mozilla.org/en-US/docs/Web/CSS/margin#formal_syntax
2435
2053
  */
2436
2054
 
2437
- PropertySyntax["LENGTH_PERCENTAGE_14"] = "[<length> | <percentage>]{1,4}";
2438
- /**
2439
- * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#list-of-ts
2440
- */
2055
+ PropertySyntax["LENGTH_PERCENTAGE_14"] = "[<length> | <percentage>]{1,4}";
2056
+ /**
2057
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#list-of-ts
2058
+ */
2059
+
2060
+ PropertySyntax["LIST_OF_POINTS"] = "<list-of-points>";
2061
+ PropertySyntax["PATH"] = "<path>";
2062
+ /**
2063
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/filter#formal_syntax
2064
+ */
2065
+
2066
+ PropertySyntax["FILTER"] = "<filter>";
2067
+ PropertySyntax["Z_INDEX"] = "<z-index>";
2068
+ PropertySyntax["OFFSET_PATH"] = "<offset-path>";
2069
+ PropertySyntax["OFFSET_DISTANCE"] = "<offset-distance>";
2070
+ PropertySyntax["CLIP_PATH"] = "<clip-path>";
2071
+ PropertySyntax["TRANSFORM"] = "<transform>";
2072
+ PropertySyntax["TRANSFORM_ORIGIN"] = "<transform-origin>";
2073
+ PropertySyntax["TEXT"] = "<text>";
2074
+ PropertySyntax["TEXT_TRANSFORM"] = "<text-transform>";
2075
+ })(exports.PropertySyntax || (exports.PropertySyntax = {}));
2076
+
2077
+ var StyleValueRegistry = manaSyringe.Syringe.defineToken('StyleValueRegistry');
2078
+
2079
+ /**
2080
+ * built-in events for element
2081
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationEvent
2082
+ *
2083
+ * TODO: use MutationObserver instead
2084
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
2085
+ */
2086
+
2087
+ (function (ElementEvent) {
2088
+ ElementEvent["DESTROY"] = "destroy";
2089
+ /**
2090
+ * @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMAttrModified
2091
+ */
2092
+
2093
+ ElementEvent["ATTR_MODIFIED"] = "DOMAttrModified";
2094
+ /**
2095
+ * it has been inserted
2096
+ * @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMNodeInserted
2097
+ */
2098
+
2099
+ ElementEvent["INSERTED"] = "DOMNodeInserted";
2100
+ /**
2101
+ * it has had a child inserted
2102
+ */
2103
+
2104
+ ElementEvent["CHILD_INSERTED"] = "child-inserted";
2105
+ /**
2106
+ * it is being removed
2107
+ * @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMNodeRemoved
2108
+ */
2109
+
2110
+ ElementEvent["REMOVED"] = "removed";
2111
+ /**
2112
+ * it has had a child removed
2113
+ */
2114
+
2115
+ ElementEvent["CHILD_REMOVED"] = "child-removed";
2116
+ /**
2117
+ * @see https://www.w3.org/TR/DOM-Level-3-Events/#domnodeinsertedintodocument
2118
+ */
2119
+
2120
+ ElementEvent["MOUNTED"] = "DOMNodeInsertedIntoDocument";
2121
+ /**
2122
+ * @see https://www.w3.org/TR/DOM-Level-3-Events/#domnoderemovedfromdocument
2123
+ */
2124
+
2125
+ ElementEvent["UNMOUNTED"] = "DOMNodeRemovedFromDocument";
2126
+ ElementEvent["BOUNDS_CHANGED"] = "bounds-changed";
2127
+ ElementEvent["GEOMETRY_BOUNDS_CHANGED"] = "geometry-bounds-changed";
2128
+ /**
2129
+ * trigger when z-index changed
2130
+ */
2131
+
2132
+ ElementEvent["RENDER_ORDER_CHANGED"] = "render-order-changed";
2133
+ })(exports.ElementEvent || (exports.ElementEvent = {}));
2134
+
2135
+ /**
2136
+ * An DOM-compatible synthetic event implementation that is "forwarded" on behalf of an original
2137
+ * FederatedEvent or native {@link https://dom.spec.whatwg.org/#event Event}.
2138
+ */
2139
+
2140
+ var FederatedEvent = /*#__PURE__*/function () {
2141
+ /**
2142
+ * The event boundary which manages this event. Propagation can only occur
2143
+ * within the boundary's jurisdiction.
2144
+ */
2145
+ function FederatedEvent(manager) {
2146
+ this.type = void 0;
2147
+ this.eventPhase = FederatedEvent.prototype.NONE;
2148
+ this.target = void 0;
2149
+ this.bubbles = true;
2150
+ this.cancelBubble = true;
2151
+ this.cancelable = false;
2152
+ this.currentTarget = void 0;
2153
+ this.defaultPrevented = false;
2154
+ this.timeStamp = void 0;
2155
+ this.nativeEvent = void 0;
2156
+ this.originalEvent = void 0;
2157
+ this.propagationStopped = false;
2158
+ this.propagationImmediatelyStopped = false;
2159
+ this.manager = void 0;
2160
+ this.detail = void 0;
2161
+ this.layer = new Point();
2162
+ this.page = new Point();
2163
+ this.canvas = new Point();
2164
+ this.viewport = new Point();
2165
+ this.path = void 0;
2166
+ this.view = void 0;
2167
+ this.which = void 0;
2168
+ this.returnValue = void 0;
2169
+ this.srcElement = void 0;
2170
+ this.composed = false;
2171
+ this.isTrusted = void 0;
2172
+ this.NONE = 0;
2173
+ this.CAPTURING_PHASE = 1;
2174
+ this.AT_TARGET = 2;
2175
+ this.BUBBLING_PHASE = 3;
2176
+ this.manager = manager;
2177
+ }
2178
+
2179
+ var _proto = FederatedEvent.prototype;
2180
+
2181
+ /**
2182
+ * The propagation path for this event
2183
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Event/composedPath
2184
+ *
2185
+ * So composedPath()[0] represents the original target.
2186
+ * @see https://polymer-library.polymer-project.org/3.0/docs/devguide/events#retargeting
2187
+ */
2188
+ _proto.composedPath = function composedPath() {
2189
+ if (this.manager && (!this.path || this.path[0] !== this.target)) {
2190
+ this.path = this.target ? this.manager.propagationPath(this.target) : [];
2191
+ }
2192
+
2193
+ return this.path;
2194
+ }
2195
+ /**
2196
+ * @deprecated
2197
+ */
2198
+ ;
2199
+
2200
+ /**
2201
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Event/preventDefault
2202
+ */
2203
+ _proto.preventDefault = function preventDefault() {
2204
+ if (this.nativeEvent instanceof Event && this.nativeEvent.cancelable) {
2205
+ this.nativeEvent.preventDefault();
2206
+ }
2207
+
2208
+ this.defaultPrevented = true;
2209
+ }
2210
+ /**
2211
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Event/stopImmediatePropagation
2212
+ */
2213
+ ;
2214
+
2215
+ _proto.stopImmediatePropagation = function stopImmediatePropagation() {
2216
+ this.propagationImmediatelyStopped = true;
2217
+ }
2218
+ /**
2219
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Event/stopPropagation
2220
+ */
2221
+ ;
2222
+
2223
+ _proto.stopPropagation = function stopPropagation() {
2224
+ this.propagationStopped = true;
2225
+ }
2226
+ /**
2227
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/view
2228
+ */
2229
+ ;
2230
+
2231
+ /**
2232
+ * added for compatibility with DOM Event,
2233
+ * deprecated props and methods
2234
+ */
2235
+ _proto.initEvent = function initEvent() {};
2236
+
2237
+ _proto.initUIEvent = function initUIEvent() {};
2238
+
2239
+ _createClass(FederatedEvent, [{
2240
+ key: "name",
2241
+ get:
2242
+ /**
2243
+ * The type of event, supports the following:
2244
+ * * pointerdown
2245
+ * * touchstart
2246
+ * * mousedown
2247
+ * * rightdown
2248
+ * * ...
2249
+ */
2250
+
2251
+ /**
2252
+ * @deprecated
2253
+ */
2254
+ function get() {
2255
+ return this.type;
2256
+ }
2257
+ /**
2258
+ * The propagation phase.
2259
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Event/eventPhase
2260
+ */
2261
+
2262
+ }, {
2263
+ key: "layerX",
2264
+ get: function get() {
2265
+ return this.layer.x;
2266
+ }
2267
+ }, {
2268
+ key: "layerY",
2269
+ get: function get() {
2270
+ return this.layer.y;
2271
+ }
2272
+ /**
2273
+ * The coordinates of the event relative to the DOM document.
2274
+ * This is a non-standard property.
2275
+ * relative to the DOM document.
2276
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/MouseEvent/pageX
2277
+ */
2441
2278
 
2442
- PropertySyntax["LIST_OF_POINTS"] = "<list-of-points>";
2443
- PropertySyntax["PATH"] = "<path>";
2444
- /**
2445
- * @see https://developer.mozilla.org/en-US/docs/Web/CSS/filter#formal_syntax
2446
- */
2279
+ }, {
2280
+ key: "pageX",
2281
+ get: function get() {
2282
+ return this.page.x;
2283
+ }
2284
+ }, {
2285
+ key: "pageY",
2286
+ get: function get() {
2287
+ return this.page.y;
2288
+ }
2289
+ /**
2290
+ * relative to Canvas, origin is left-top
2291
+ */
2447
2292
 
2448
- PropertySyntax["FILTER"] = "<filter>";
2449
- PropertySyntax["Z_INDEX"] = "<z-index>";
2450
- PropertySyntax["OFFSET_PATH"] = "<offset-path>";
2451
- PropertySyntax["OFFSET_DISTANCE"] = "<offset-distance>";
2452
- PropertySyntax["CLIP_PATH"] = "<clip-path>";
2453
- PropertySyntax["TRANSFORM"] = "<transform>";
2454
- PropertySyntax["TRANSFORM_ORIGIN"] = "<transform-origin>";
2455
- PropertySyntax["TEXT"] = "<text>";
2456
- PropertySyntax["TEXT_TRANSFORM"] = "<text-transform>";
2457
- })(exports.PropertySyntax || (exports.PropertySyntax = {}));
2293
+ }, {
2294
+ key: "x",
2295
+ get: function get() {
2296
+ return this.canvas.x;
2297
+ }
2298
+ }, {
2299
+ key: "y",
2300
+ get: function get() {
2301
+ return this.canvas.y;
2302
+ }
2303
+ }, {
2304
+ key: "canvasX",
2305
+ get: function get() {
2306
+ return this.canvas.x;
2307
+ }
2308
+ }, {
2309
+ key: "canvasY",
2310
+ get: function get() {
2311
+ return this.canvas.y;
2312
+ }
2313
+ /**
2314
+ * relative to Viewport, account for Camera
2315
+ */
2458
2316
 
2459
- var StyleValueRegistry = manaSyringe.Syringe.defineToken('StyleValueRegistry');
2317
+ }, {
2318
+ key: "viewportX",
2319
+ get: function get() {
2320
+ return this.viewport.x;
2321
+ }
2322
+ }, {
2323
+ key: "viewportY",
2324
+ get: function get() {
2325
+ return this.viewport.y;
2326
+ }
2327
+ }, {
2328
+ key: "propagationPath",
2329
+ get: function get() {
2330
+ return this.composedPath();
2331
+ }
2332
+ }]);
2460
2333
 
2461
- var GeometryUpdaterFactory = manaSyringe.Syringe.defineToken('GeometryUpdaterFactory');
2462
- var GeometryAABBUpdater = manaSyringe.Syringe.defineToken('GeometryAABBUpdater');
2334
+ return FederatedEvent;
2335
+ }();
2463
2336
 
2464
2337
  /**
2465
2338
  * @see https://developer.mozilla.org/en-US/docs/Web/Events/Creating_and_triggering_events
@@ -3003,6 +2876,37 @@ var Sortable = function Sortable() {
3003
2876
  };
3004
2877
  Sortable.tag = 'c-sortable';
3005
2878
 
2879
+ var MutationEvent = /*#__PURE__*/function (_FederatedEvent) {
2880
+ _inheritsLoose(MutationEvent, _FederatedEvent);
2881
+
2882
+ function MutationEvent(typeArg, relatedNode, prevValue, newValue, attrName, attrChange, prevParsedValue, newParsedValue) {
2883
+ var _this;
2884
+
2885
+ _this = _FederatedEvent.call(this, null) || this;
2886
+ _this.relatedNode = void 0;
2887
+ _this.prevValue = void 0;
2888
+ _this.newValue = void 0;
2889
+ _this.attrName = void 0;
2890
+ _this.attrChange = void 0;
2891
+ _this.prevParsedValue = void 0;
2892
+ _this.newParsedValue = void 0;
2893
+ _this.relatedNode = relatedNode;
2894
+ _this.prevValue = prevValue;
2895
+ _this.newValue = newValue;
2896
+ _this.attrName = attrName;
2897
+ _this.attrChange = attrChange;
2898
+ _this.prevParsedValue = prevParsedValue;
2899
+ _this.newParsedValue = newParsedValue;
2900
+ _this.type = typeArg;
2901
+ return _this;
2902
+ }
2903
+
2904
+ return MutationEvent;
2905
+ }(FederatedEvent);
2906
+ MutationEvent.ADDITION = 2;
2907
+ MutationEvent.MODIFICATION = 1;
2908
+ MutationEvent.REMOVAL = 3;
2909
+
3006
2910
  var entityCounter = 0;
3007
2911
  /**
3008
2912
  * Has following capabilities:
@@ -3161,6 +3065,24 @@ var Element = /*#__PURE__*/function (_Node) {
3161
3065
  _proto.querySelectorAll = function querySelectorAll(selectors) {
3162
3066
  return this.sceneGraphService.querySelectorAll(selectors, this);
3163
3067
  }
3068
+ /**
3069
+ * should traverses the element and its parents (heading toward the document root)
3070
+ * until it finds a node that matches the specified CSS selector.
3071
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/closest
3072
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/closest#polyfill
3073
+ */
3074
+ ;
3075
+
3076
+ _proto.closest = function closest(selectors) {
3077
+ var el = this;
3078
+
3079
+ do {
3080
+ if (this.sceneGraphService.matches(selectors, el)) return el;
3081
+ el = el.parentElement;
3082
+ } while (el !== null);
3083
+
3084
+ return null;
3085
+ }
3164
3086
  /**
3165
3087
  * search in scene group, but should not include itself
3166
3088
  */
@@ -6984,6 +6906,8 @@ function parseDimension(unitRegExp, string) {
6984
6906
  if (isFinite(Number(string))) {
6985
6907
  if ('px'.search(unitRegExp) >= 0) {
6986
6908
  return new CSSUnitValue(Number(string), 'px');
6909
+ } else if ('deg'.search(unitRegExp) >= 0) {
6910
+ return new CSSUnitValue(Number(string), 'deg');
6987
6911
  }
6988
6912
  }
6989
6913
 
@@ -9190,6 +9114,75 @@ function convertKeyword2Percent(keyword) {
9190
9114
  return keyword;
9191
9115
  }
9192
9116
 
9117
+ var CSSPropertyAngle = {
9118
+ parser: parseAngle,
9119
+ mixer: mergeDimensions,
9120
+ calculator: function calculator(name, oldParsed, parsed, object) {
9121
+ return new CSSUnitValue(convertAngleUnit(parsed), 'deg');
9122
+ }
9123
+ };
9124
+
9125
+ /**
9126
+ * @see /zh/docs/api/basic/display-object#clippath
9127
+ * @example
9128
+ const image = new Image({
9129
+ style: {
9130
+ width: 200,
9131
+ height: 200,
9132
+ clipPath: new Circle({
9133
+ style: {
9134
+ x: 100, // 处于被裁剪图形局部坐标系下
9135
+ y: 100,
9136
+ r: 50,
9137
+ },
9138
+ }),
9139
+ }
9140
+ });
9141
+ */
9142
+
9143
+ var CSSPropertyClipPath = {
9144
+ calculator: function calculator(name, oldClipPath, newClipPath, object) {
9145
+ // unset
9146
+ if (newClipPath instanceof CSSKeywordValue) {
9147
+ newClipPath = null;
9148
+ } // clear ref to old clip path
9149
+
9150
+
9151
+ if (oldClipPath && oldClipPath !== newClipPath && oldClipPath.style.clipPathTargets) {
9152
+ var index = oldClipPath.style.clipPathTargets.indexOf(object);
9153
+ oldClipPath.style.clipPathTargets.splice(index, 1);
9154
+ }
9155
+
9156
+ if (newClipPath) {
9157
+ if (!newClipPath.style.clipPathTargets) {
9158
+ newClipPath.style.clipPathTargets = [];
9159
+ }
9160
+
9161
+ newClipPath.style.clipPathTargets.push(object);
9162
+ }
9163
+
9164
+ dirtifyToRoot(object);
9165
+ return newClipPath;
9166
+ }
9167
+ };
9168
+
9169
+ var CSSPropertyColor = {
9170
+ parser: parseColor,
9171
+ calculator: function calculator(name, oldParsed, parsed, object, registry) {
9172
+ if (parsed instanceof CSSKeywordValue) {
9173
+ // 'unset' 'none'
9174
+ return new CSSRGB(0, 0, 0, 0, parsed.value === 'none');
9175
+ }
9176
+
9177
+ return parsed;
9178
+ },
9179
+ mixer: mergeColors
9180
+ };
9181
+
9182
+ var CSSPropertyFilter = {
9183
+ parser: parseFilter
9184
+ };
9185
+
9193
9186
  function getFontSize(object) {
9194
9187
  var fontSize = object.parsedStyle.fontSize;
9195
9188
 
@@ -9244,38 +9237,92 @@ var CSSPropertyLengthOrPercentage = {
9244
9237
  } else if (computed.unit === exports.UnitType.kRems) {
9245
9238
  var _object$ownerDocument;
9246
9239
 
9247
- if (object === null || object === void 0 ? void 0 : (_object$ownerDocument = object.ownerDocument) === null || _object$ownerDocument === void 0 ? void 0 : _object$ownerDocument.documentElement) {
9248
- var _fontSize = getFontSize(object.ownerDocument.documentElement);
9240
+ if (object === null || object === void 0 ? void 0 : (_object$ownerDocument = object.ownerDocument) === null || _object$ownerDocument === void 0 ? void 0 : _object$ownerDocument.documentElement) {
9241
+ var _fontSize = getFontSize(object.ownerDocument.documentElement);
9242
+
9243
+ _fontSize.value *= computed.value;
9244
+ return _fontSize;
9245
+ }
9246
+
9247
+ return new CSSUnitValue(0, 'px');
9248
+ }
9249
+ } else {
9250
+ // remove listener if exists
9251
+ // registry.unregisterParentGeometryBoundsChangedHandler(object, name);
9252
+ // return absolute value
9253
+ return computed.clone();
9254
+ }
9255
+ } // private nameToBoundsIndex(name: string): number {
9256
+ // if (name === 'x' || name === 'cx' || name === 'width') {
9257
+ // return 0;
9258
+ // } else if (name === 'y' || name === 'cy' || name === 'height') {
9259
+ // return 1;
9260
+ // }
9261
+ // return 2;
9262
+ // }
9263
+ // private calculateUsedValueWithParentBounds(object: DisplayObject, name: string) {
9264
+ // const bounds = (object.parentElement as DisplayObject).getGeometryBounds();
9265
+ // const computedValue = object.computedStyle[name].value;
9266
+ // return new CSSUnitValue(
9267
+ // (bounds.halfExtents[this.nameToBoundsIndex(name)] * 2 * computedValue) / 100,
9268
+ // 'px',
9269
+ // );
9270
+ // }
9271
+
9272
+ };
9273
+
9274
+ /**
9275
+ * format to Tuple2<CSSUnitValue>
9276
+ *
9277
+ * @example
9278
+ * rect.style.lineDash = 10;
9279
+ * rect.style.lineDash = [10, 10];
9280
+ * rect.style.lineDash = '10 10';
9281
+ */
9282
+
9283
+ var CSSPropertyLengthOrPercentage12 = {
9284
+ parser: function parser(radius) {
9285
+ var parsed = parseDimensionArray(isNumber(radius) ? [radius] : radius);
9286
+ var formatted;
9287
+
9288
+ if (parsed.length === 1) {
9289
+ formatted = [parsed[0], parsed[0]];
9290
+ } else {
9291
+ formatted = [parsed[0], parsed[1]];
9292
+ }
9293
+
9294
+ return formatted;
9295
+ },
9296
+ mixer: mergeDimensionList
9297
+ };
9298
+
9299
+ /**
9300
+ * used in rounded rect
9301
+ *
9302
+ * @example
9303
+ * rect.style.radius = 10;
9304
+ * rect.style.radius = '10 10';
9305
+ * rect.style.radius = '10 10 10 10';
9306
+ */
9249
9307
 
9250
- _fontSize.value *= computed.value;
9251
- return _fontSize;
9252
- }
9308
+ var CSSPropertyLengthOrPercentage14 = {
9309
+ parser: function parser(radius) {
9310
+ var parsed = parseDimensionArray(isNumber(radius) ? [radius] : radius);
9311
+ var formatted; // format to Tuple<CSSUnitValue>
9253
9312
 
9254
- return new CSSUnitValue(0, 'px');
9255
- }
9313
+ if (parsed.length === 1) {
9314
+ formatted = [parsed[0], parsed[0], parsed[0], parsed[0]];
9315
+ } else if (parsed.length === 2) {
9316
+ formatted = [parsed[0], parsed[1], parsed[0], parsed[1]];
9317
+ } else if (parsed.length === 3) {
9318
+ formatted = [parsed[0], parsed[1], parsed[2], parsed[1]];
9256
9319
  } else {
9257
- // remove listener if exists
9258
- // registry.unregisterParentGeometryBoundsChangedHandler(object, name);
9259
- // return absolute value
9260
- return computed.clone();
9320
+ formatted = [parsed[0], parsed[1], parsed[2], parsed[3]];
9261
9321
  }
9262
- } // private nameToBoundsIndex(name: string): number {
9263
- // if (name === 'x' || name === 'cx' || name === 'width') {
9264
- // return 0;
9265
- // } else if (name === 'y' || name === 'cy' || name === 'height') {
9266
- // return 1;
9267
- // }
9268
- // return 2;
9269
- // }
9270
- // private calculateUsedValueWithParentBounds(object: DisplayObject, name: string) {
9271
- // const bounds = (object.parentElement as DisplayObject).getGeometryBounds();
9272
- // const computedValue = object.computedStyle[name].value;
9273
- // return new CSSUnitValue(
9274
- // (bounds.halfExtents[this.nameToBoundsIndex(name)] * 2 * computedValue) / 100,
9275
- // 'px',
9276
- // );
9277
- // }
9278
9322
 
9323
+ return formatted;
9324
+ },
9325
+ mixer: mergeDimensionList
9279
9326
  };
9280
9327
 
9281
9328
  /**
@@ -9349,90 +9396,24 @@ var CSSPropertyLocalPosition = {
9349
9396
  }
9350
9397
  };
9351
9398
 
9352
- /**
9353
- * opacity
9354
- */
9355
-
9356
- var CSSPropertyOpacity = {
9399
+ var CSSPropertyOffsetDistance = {
9357
9400
  parser: parseNumber,
9358
- mixer: clampedMergeNumbers(0, 1)
9359
- };
9360
-
9361
- var CSSPropertyColor = {
9362
- parser: parseColor,
9363
- calculator: function calculator(name, oldParsed, parsed, object, registry) {
9364
- if (parsed instanceof CSSKeywordValue) {
9365
- // 'unset' 'none'
9366
- return new CSSRGB(0, 0, 0, 0, parsed.value === 'none');
9367
- }
9368
-
9369
- return parsed;
9370
- },
9371
- mixer: mergeColors
9372
- };
9373
-
9374
- var CSSPropertyFilter = {
9375
- parser: parseFilter
9376
- };
9377
-
9378
- /**
9379
- * format to Tuple2<CSSUnitValue>
9380
- *
9381
- * @example
9382
- * rect.style.lineDash = 10;
9383
- * rect.style.lineDash = [10, 10];
9384
- * rect.style.lineDash = '10 10';
9385
- */
9386
-
9387
- var CSSPropertyLengthOrPercentage12 = {
9388
- parser: function parser(radius) {
9389
- var parsed = parseDimensionArray(isNumber(radius) ? [radius] : radius);
9390
- var formatted;
9391
-
9392
- if (parsed.length === 1) {
9393
- formatted = [parsed[0], parsed[0]];
9394
- } else {
9395
- formatted = [parsed[0], parsed[1]];
9401
+ mixer: clampedMergeNumbers(0, 1),
9402
+ postProcessor: function postProcessor(object) {
9403
+ if (!object.attributes.offsetPath) {
9404
+ return;
9396
9405
  }
9397
9406
 
9398
- return formatted;
9399
- },
9400
- mixer: mergeDimensionList
9401
- };
9402
-
9403
- /**
9404
- * used in rounded rect
9405
- *
9406
- * @example
9407
- * rect.style.radius = 10;
9408
- * rect.style.radius = '10 10';
9409
- * rect.style.radius = '10 10 10 10';
9410
- */
9407
+ var offsetPathNodeName = object.attributes.offsetPath.nodeName;
9411
9408
 
9412
- var CSSPropertyLengthOrPercentage14 = {
9413
- parser: function parser(radius) {
9414
- var parsed = parseDimensionArray(isNumber(radius) ? [radius] : radius);
9415
- var formatted; // format to Tuple<CSSUnitValue>
9409
+ if (offsetPathNodeName === exports.Shape.LINE || offsetPathNodeName === exports.Shape.PATH || offsetPathNodeName === exports.Shape.POLYLINE) {
9410
+ var point = object.attributes.offsetPath.getPoint(object.parsedStyle.offsetDistance.value);
9416
9411
 
9417
- if (parsed.length === 1) {
9418
- formatted = [parsed[0], parsed[0], parsed[0], parsed[0]];
9419
- } else if (parsed.length === 2) {
9420
- formatted = [parsed[0], parsed[1], parsed[0], parsed[1]];
9421
- } else if (parsed.length === 3) {
9422
- formatted = [parsed[0], parsed[1], parsed[2], parsed[1]];
9423
- } else {
9424
- formatted = [parsed[0], parsed[1], parsed[2], parsed[3]];
9412
+ if (point) {
9413
+ object.setLocalPosition(point.x, point.y);
9414
+ }
9425
9415
  }
9426
-
9427
- return formatted;
9428
- },
9429
- mixer: mergeDimensionList
9430
- };
9431
-
9432
- var CSSPropertyShadowBlur = {
9433
- parser: CSSPropertyLengthOrPercentage.parser,
9434
- mixer: clampedMergeNumbers(0, Infinity),
9435
- calculator: CSSPropertyLengthOrPercentage.calculator
9416
+ }
9436
9417
  };
9437
9418
 
9438
9419
  var CSSPropertyOffsetPath = {
@@ -9455,43 +9436,118 @@ var CSSPropertyOffsetPath = {
9455
9436
  }
9456
9437
  };
9457
9438
 
9458
- var CSSPropertyOffsetDistance = {
9439
+ /**
9440
+ * opacity
9441
+ */
9442
+
9443
+ var CSSPropertyOpacity = {
9459
9444
  parser: parseNumber,
9460
- mixer: clampedMergeNumbers(0, 1),
9461
- postProcessor: function postProcessor(object) {
9462
- if (!object.attributes.offsetPath) {
9463
- return;
9445
+ mixer: clampedMergeNumbers(0, 1)
9446
+ };
9447
+
9448
+ var CSSPropertyPath = {
9449
+ /**
9450
+ * path2Curve
9451
+ */
9452
+ parser: parsePath,
9453
+ calculator: function calculator(name, oldParsed, parsed) {
9454
+ // unset
9455
+ if (parsed instanceof CSSKeywordValue && parsed.value === 'unset') {
9456
+ return {
9457
+ absolutePath: [],
9458
+ hasArc: false,
9459
+ segments: [],
9460
+ polygons: [],
9461
+ polylines: [],
9462
+ curve: [],
9463
+ totalLength: 0,
9464
+ curveSegments: [],
9465
+ zCommandIndexes: [],
9466
+ rect: new Rectangle(0, 0, 0, 0)
9467
+ };
9464
9468
  }
9465
9469
 
9466
- var offsetPathNodeName = object.attributes.offsetPath.nodeName;
9470
+ return parsed;
9471
+ },
9472
+ mixer: mergePaths,
9467
9473
 
9468
- if (offsetPathNodeName === exports.Shape.LINE || offsetPathNodeName === exports.Shape.PATH || offsetPathNodeName === exports.Shape.POLYLINE) {
9469
- var point = object.attributes.offsetPath.getPoint(object.parsedStyle.offsetDistance.value);
9474
+ /**
9475
+ * update local position
9476
+ */
9477
+ postProcessor: function postProcessor(object) {
9478
+ if (object.nodeName === exports.Shape.PATH) {
9479
+ var _object$parsedStyle = object.parsedStyle,
9480
+ _object$parsedStyle$d = _object$parsedStyle.defX,
9481
+ defX = _object$parsedStyle$d === void 0 ? 0 : _object$parsedStyle$d,
9482
+ _object$parsedStyle$d2 = _object$parsedStyle.defY,
9483
+ defY = _object$parsedStyle$d2 === void 0 ? 0 : _object$parsedStyle$d2;
9484
+ object.setLocalPosition(defX, defY);
9485
+ }
9486
+ }
9487
+ };
9470
9488
 
9471
- if (point) {
9472
- object.setLocalPosition(point.x, point.y);
9473
- }
9489
+ var CSSPropertyPoints = {
9490
+ parser: parsePoints,
9491
+
9492
+ /**
9493
+ * update local position
9494
+ */
9495
+ postProcessor: function postProcessor(object) {
9496
+ if (object.nodeName === exports.Shape.POLYGON || object.nodeName === exports.Shape.POLYLINE) {
9497
+ var _object$parsedStyle = object.parsedStyle,
9498
+ defX = _object$parsedStyle.defX,
9499
+ defY = _object$parsedStyle.defY;
9500
+ object.setLocalPosition(defX, defY);
9474
9501
  }
9475
9502
  }
9476
9503
  };
9477
9504
 
9478
- var CSSPropertyZIndex = {
9479
- parser: parseNumber,
9505
+ var CSSPropertyShadowBlur = {
9506
+ parser: CSSPropertyLengthOrPercentage.parser,
9507
+ mixer: clampedMergeNumbers(0, Infinity),
9508
+ calculator: CSSPropertyLengthOrPercentage.calculator
9509
+ };
9510
+
9511
+ var CSSPropertyText = {
9512
+ calculator: function calculator(name, oldParsed, parsed, object) {
9513
+ if (parsed instanceof CSSKeywordValue) {
9514
+ if (parsed.value === 'unset') {
9515
+ return '';
9516
+ } else {
9517
+ return parsed.value;
9518
+ }
9519
+ }
9520
+
9521
+ return parsed;
9522
+ },
9480
9523
  postProcessor: function postProcessor(object) {
9481
- if (object.parentNode) {
9482
- var parentEntity = object.parentNode;
9483
- var parentRenderable = parentEntity.renderable;
9484
- var parentSortable = parentEntity.sortable;
9524
+ object.nodeValue = "" + object.parsedStyle.text || '';
9525
+ }
9526
+ };
9485
9527
 
9486
- if (parentRenderable) {
9487
- parentRenderable.dirty = true;
9488
- } // need re-sort on parent
9528
+ /**
9529
+ * it must transform after text get parsed
9530
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/text-transform
9531
+ */
9532
+ var CSSPropertyTextTransform = {
9533
+ calculator: function calculator(name, oldParsed, parsed, object) {
9534
+ var rawText = object.getAttribute('text');
9489
9535
 
9536
+ if (rawText) {
9537
+ var transformedText = rawText;
9490
9538
 
9491
- if (parentSortable) {
9492
- parentSortable.dirty = true;
9539
+ if (parsed.value === 'capitalize') {
9540
+ transformedText = rawText.charAt(0).toUpperCase() + rawText.slice(1);
9541
+ } else if (parsed.value === 'lowercase') {
9542
+ transformedText = rawText.toLowerCase();
9543
+ } else if (parsed.value === 'uppercase') {
9544
+ transformedText = rawText.toUpperCase();
9493
9545
  }
9546
+
9547
+ object.parsedStyle.text = transformedText;
9494
9548
  }
9549
+
9550
+ return parsed;
9495
9551
  }
9496
9552
  };
9497
9553
 
@@ -9623,143 +9679,23 @@ var CSSPropertyTransformOrigin = {
9623
9679
  parser: parseTransformOrigin
9624
9680
  };
9625
9681
 
9626
- var CSSPropertyPath = {
9627
- /**
9628
- * path2Curve
9629
- */
9630
- parser: parsePath,
9631
- calculator: function calculator(name, oldParsed, parsed) {
9632
- // unset
9633
- if (parsed instanceof CSSKeywordValue && parsed.value === 'unset') {
9634
- return {
9635
- absolutePath: [],
9636
- hasArc: false,
9637
- segments: [],
9638
- polygons: [],
9639
- polylines: [],
9640
- curve: [],
9641
- totalLength: 0,
9642
- curveSegments: [],
9643
- zCommandIndexes: [],
9644
- rect: new Rectangle(0, 0, 0, 0)
9645
- };
9646
- }
9647
-
9648
- return parsed;
9649
- },
9650
- mixer: mergePaths,
9651
-
9652
- /**
9653
- * update local position
9654
- */
9655
- postProcessor: function postProcessor(object) {
9656
- if (object.nodeName === exports.Shape.PATH) {
9657
- var _object$parsedStyle = object.parsedStyle,
9658
- _object$parsedStyle$d = _object$parsedStyle.defX,
9659
- defX = _object$parsedStyle$d === void 0 ? 0 : _object$parsedStyle$d,
9660
- _object$parsedStyle$d2 = _object$parsedStyle.defY,
9661
- defY = _object$parsedStyle$d2 === void 0 ? 0 : _object$parsedStyle$d2;
9662
- object.setLocalPosition(defX, defY);
9663
- }
9664
- }
9665
- };
9666
-
9667
- var CSSPropertyPoints = {
9668
- parser: parsePoints,
9669
-
9670
- /**
9671
- * update local position
9672
- */
9673
- postProcessor: function postProcessor(object) {
9674
- if (object.nodeName === exports.Shape.POLYGON || object.nodeName === exports.Shape.POLYLINE) {
9675
- var _object$parsedStyle = object.parsedStyle,
9676
- defX = _object$parsedStyle.defX,
9677
- defY = _object$parsedStyle.defY;
9678
- object.setLocalPosition(defX, defY);
9679
- }
9680
- }
9681
- };
9682
-
9683
- /**
9684
- * @see /zh/docs/api/basic/display-object#clippath
9685
- * @example
9686
- const image = new Image({
9687
- style: {
9688
- width: 200,
9689
- height: 200,
9690
- clipPath: new Circle({
9691
- style: {
9692
- x: 100, // 处于被裁剪图形局部坐标系下
9693
- y: 100,
9694
- r: 50,
9695
- },
9696
- }),
9697
- }
9698
- });
9699
- */
9700
-
9701
- var CSSPropertyClipPath = {
9702
- calculator: function calculator(name, oldClipPath, newClipPath, object) {
9703
- // unset
9704
- if (newClipPath instanceof CSSKeywordValue) {
9705
- newClipPath = null;
9706
- } // clear ref to old clip path
9707
-
9708
-
9709
- if (oldClipPath && oldClipPath !== newClipPath && oldClipPath.style.clipPathTargets) {
9710
- var index = oldClipPath.style.clipPathTargets.indexOf(object);
9711
- oldClipPath.style.clipPathTargets.splice(index, 1);
9712
- }
9713
-
9714
- if (newClipPath) {
9715
- if (!newClipPath.style.clipPathTargets) {
9716
- newClipPath.style.clipPathTargets = [];
9717
- }
9718
-
9719
- newClipPath.style.clipPathTargets.push(object);
9720
- }
9721
-
9722
- dirtifyToRoot(object);
9723
- return newClipPath;
9724
- }
9725
- };
9726
-
9727
- var CSSPropertyText = {
9728
- calculator: function calculator(name, oldParsed, parsed, object) {
9729
- if (parsed instanceof CSSKeywordValue) {
9730
- if (parsed.value === 'unset') {
9731
- return '';
9732
- } else {
9733
- return parsed.value;
9734
- }
9735
- }
9736
-
9737
- return parsed;
9738
- },
9682
+ var CSSPropertyZIndex = {
9683
+ parser: parseNumber,
9739
9684
  postProcessor: function postProcessor(object) {
9740
- object.nodeValue = "" + object.parsedStyle.text || '';
9741
- }
9742
- };
9685
+ if (object.parentNode) {
9686
+ var parentEntity = object.parentNode;
9687
+ var parentRenderable = parentEntity.renderable;
9688
+ var parentSortable = parentEntity.sortable;
9743
9689
 
9744
- var CSSPropertyTextTransform = {
9745
- calculator: function calculator(name, oldParsed, parsed, object) {
9746
- var rawText = object.getAttribute('text');
9690
+ if (parentRenderable) {
9691
+ parentRenderable.dirty = true;
9692
+ } // need re-sort on parent
9747
9693
 
9748
- if (rawText) {
9749
- var transformedText = rawText;
9750
9694
 
9751
- if (parsed.value === 'capitalize') {
9752
- transformedText = rawText.charAt(0).toUpperCase() + rawText.slice(1);
9753
- } else if (parsed.value === 'lowercase') {
9754
- transformedText = rawText.toLowerCase();
9755
- } else if (parsed.value === 'uppercase') {
9756
- transformedText = rawText.toUpperCase();
9695
+ if (parentSortable) {
9696
+ parentSortable.dirty = true;
9757
9697
  }
9758
-
9759
- object.parsedStyle.text = transformedText;
9760
9698
  }
9761
-
9762
- return parsed;
9763
9699
  }
9764
9700
  };
9765
9701
 
@@ -9976,7 +9912,7 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
9976
9912
  dirtifyToRoot(target);
9977
9913
  target.dispatchEvent(new MutationEvent(exports.ElementEvent.ATTR_MODIFIED, target, _this2, _this2, 'clipPath', MutationEvent.MODIFICATION, _this2, _this2));
9978
9914
 
9979
- if (target.isCustomElement) {
9915
+ if (target.isCustomElement && target.isConnected) {
9980
9916
  if (target.attributeChangedCallback) {
9981
9917
  target.attributeChangedCallback('clipPath', _this2, _this2);
9982
9918
  }
@@ -9988,7 +9924,7 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
9988
9924
  renderable.dirty = true;
9989
9925
  this.dispatchEvent(new MutationEvent(exports.ElementEvent.ATTR_MODIFIED, this, oldValue, value, name, MutationEvent.MODIFICATION, oldParsedValue, this.parsedStyle[name]));
9990
9926
 
9991
- if (this.isCustomElement) {
9927
+ if (this.isCustomElement && this.isConnected) {
9992
9928
  if (this.attributeChangedCallback) {
9993
9929
  this.attributeChangedCallback(name, oldValue, value);
9994
9930
  }
@@ -12857,8 +12793,11 @@ var CustomElementRegistry = /*#__PURE__*/function () {
12857
12793
  return CustomElementRegistry;
12858
12794
  }();
12859
12795
 
12796
+ var GeometryUpdaterFactory = manaSyringe.Syringe.defineToken('GeometryUpdaterFactory');
12797
+ var GeometryAABBUpdater = manaSyringe.Syringe.defineToken('GeometryAABBUpdater');
12798
+
12860
12799
  var _PROPERTY_HANDLERS;
12861
- var PROPERTY_HANDLERS = (_PROPERTY_HANDLERS = {}, _PROPERTY_HANDLERS[exports.PropertySyntax.COORDINATE] = CSSPropertyLocalPosition, _PROPERTY_HANDLERS[exports.PropertySyntax.COLOR] = CSSPropertyColor, _PROPERTY_HANDLERS[exports.PropertySyntax.PAINT] = CSSPropertyColor, _PROPERTY_HANDLERS[exports.PropertySyntax.OPACITY_VALUE] = CSSPropertyOpacity, _PROPERTY_HANDLERS[exports.PropertySyntax.LENGTH_PERCENTAGE] = CSSPropertyLengthOrPercentage, _PROPERTY_HANDLERS[exports.PropertySyntax.LENGTH_PERCENTAGE_12] = CSSPropertyLengthOrPercentage12, _PROPERTY_HANDLERS[exports.PropertySyntax.LENGTH_PERCENTAGE_14] = CSSPropertyLengthOrPercentage14, _PROPERTY_HANDLERS[exports.PropertySyntax.SHADOW_BLUR] = CSSPropertyShadowBlur, _PROPERTY_HANDLERS[exports.PropertySyntax.LIST_OF_POINTS] = CSSPropertyPoints, _PROPERTY_HANDLERS[exports.PropertySyntax.PATH] = CSSPropertyPath, _PROPERTY_HANDLERS[exports.PropertySyntax.FILTER] = CSSPropertyFilter, _PROPERTY_HANDLERS[exports.PropertySyntax.Z_INDEX] = CSSPropertyZIndex, _PROPERTY_HANDLERS[exports.PropertySyntax.OFFSET_PATH] = CSSPropertyOffsetPath, _PROPERTY_HANDLERS[exports.PropertySyntax.OFFSET_DISTANCE] = CSSPropertyOffsetDistance, _PROPERTY_HANDLERS[exports.PropertySyntax.CLIP_PATH] = CSSPropertyClipPath, _PROPERTY_HANDLERS[exports.PropertySyntax.TRANSFORM] = CSSPropertyTransform, _PROPERTY_HANDLERS[exports.PropertySyntax.TRANSFORM_ORIGIN] = CSSPropertyTransformOrigin, _PROPERTY_HANDLERS[exports.PropertySyntax.TEXT] = CSSPropertyText, _PROPERTY_HANDLERS[exports.PropertySyntax.TEXT_TRANSFORM] = CSSPropertyTextTransform, _PROPERTY_HANDLERS);
12800
+ var PROPERTY_HANDLERS = (_PROPERTY_HANDLERS = {}, _PROPERTY_HANDLERS[exports.PropertySyntax.COORDINATE] = CSSPropertyLocalPosition, _PROPERTY_HANDLERS[exports.PropertySyntax.ANGLE] = CSSPropertyAngle, _PROPERTY_HANDLERS[exports.PropertySyntax.COLOR] = CSSPropertyColor, _PROPERTY_HANDLERS[exports.PropertySyntax.PAINT] = CSSPropertyColor, _PROPERTY_HANDLERS[exports.PropertySyntax.OPACITY_VALUE] = CSSPropertyOpacity, _PROPERTY_HANDLERS[exports.PropertySyntax.LENGTH_PERCENTAGE] = CSSPropertyLengthOrPercentage, _PROPERTY_HANDLERS[exports.PropertySyntax.LENGTH_PERCENTAGE_12] = CSSPropertyLengthOrPercentage12, _PROPERTY_HANDLERS[exports.PropertySyntax.LENGTH_PERCENTAGE_14] = CSSPropertyLengthOrPercentage14, _PROPERTY_HANDLERS[exports.PropertySyntax.SHADOW_BLUR] = CSSPropertyShadowBlur, _PROPERTY_HANDLERS[exports.PropertySyntax.LIST_OF_POINTS] = CSSPropertyPoints, _PROPERTY_HANDLERS[exports.PropertySyntax.PATH] = CSSPropertyPath, _PROPERTY_HANDLERS[exports.PropertySyntax.FILTER] = CSSPropertyFilter, _PROPERTY_HANDLERS[exports.PropertySyntax.Z_INDEX] = CSSPropertyZIndex, _PROPERTY_HANDLERS[exports.PropertySyntax.OFFSET_PATH] = CSSPropertyOffsetPath, _PROPERTY_HANDLERS[exports.PropertySyntax.OFFSET_DISTANCE] = CSSPropertyOffsetDistance, _PROPERTY_HANDLERS[exports.PropertySyntax.CLIP_PATH] = CSSPropertyClipPath, _PROPERTY_HANDLERS[exports.PropertySyntax.TRANSFORM] = CSSPropertyTransform, _PROPERTY_HANDLERS[exports.PropertySyntax.TRANSFORM_ORIGIN] = CSSPropertyTransformOrigin, _PROPERTY_HANDLERS[exports.PropertySyntax.TEXT] = CSSPropertyText, _PROPERTY_HANDLERS[exports.PropertySyntax.TEXT_TRANSFORM] = CSSPropertyTextTransform, _PROPERTY_HANDLERS);
12862
12801
  /**
12863
12802
  * Blink used them in code generation(css_properties.json5)
12864
12803
  */
@@ -13174,14 +13113,17 @@ var BUILT_IN_PROPERTIES = [{
13174
13113
  name: 'text',
13175
13114
  layoutDependent: true,
13176
13115
  defaultValue: '',
13177
- syntax: exports.PropertySyntax.TEXT
13116
+ syntax: exports.PropertySyntax.TEXT,
13117
+ parsePriority: 50
13178
13118
  }, {
13179
13119
  name: 'textTransform',
13180
13120
  layoutDependent: true,
13181
13121
  inherited: true,
13182
13122
  keywords: ['capitalize', 'uppercase', 'lowercase', 'none'],
13183
13123
  defaultValue: 'none',
13184
- syntax: exports.PropertySyntax.TEXT_TRANSFORM
13124
+ syntax: exports.PropertySyntax.TEXT_TRANSFORM,
13125
+ parsePriority: 51 // it must get parsed after text
13126
+
13185
13127
  }, {
13186
13128
  name: 'font',
13187
13129
  layoutDependent: true
@@ -15058,6 +15000,159 @@ function toFontString(attributes) {
15058
15000
  return fontStyle + " " + fontVariant + " " + fontWeight + " " + fontSizeString + " " + fontFamilies.join(',');
15059
15001
  }
15060
15002
 
15003
+ var SceneGraphSelectorFactory = manaSyringe.Syringe.defineToken('SceneGraphSelectorFactory');
15004
+ var SceneGraphSelector = manaSyringe.Syringe.defineToken('SceneGraphSelector', {
15005
+ multiple: false
15006
+ });
15007
+ var ATTRIBUTE_REGEXP = /\[\s*(.*)=(.*)\s*\]/;
15008
+ /**
15009
+ * support the following DOM API:
15010
+ * * getElementById
15011
+ * * getElementsByClassName
15012
+ * * getElementsByName
15013
+ * * getElementsByTag
15014
+ * * querySelector
15015
+ * * querySelectorAll
15016
+ */
15017
+
15018
+ exports.DefaultSceneGraphSelector = /*#__PURE__*/function () {
15019
+ function DefaultSceneGraphSelector() {}
15020
+
15021
+ var _proto = DefaultSceneGraphSelector.prototype;
15022
+
15023
+ _proto.selectOne = function selectOne(query, root) {
15024
+ var _this = this;
15025
+
15026
+ if (query.startsWith('.')) {
15027
+ return root.find(function (node) {
15028
+ // return !node.shadow && node.id === query.substring(1);
15029
+ return node.className === _this.getIdOrClassname(query);
15030
+ });
15031
+ } else if (query.startsWith('#')) {
15032
+ // getElementById('id')
15033
+ return root.find(function (node) {
15034
+ // return !node.shadow && node.id === query.substring(1);
15035
+ return node.id === _this.getIdOrClassname(query);
15036
+ });
15037
+ } else if (query.startsWith('[')) {
15038
+ var _this$getAttribute = this.getAttribute(query),
15039
+ name = _this$getAttribute.name,
15040
+ value = _this$getAttribute.value;
15041
+
15042
+ if (name) {
15043
+ // getElementByName();
15044
+ return root.find(function (node) {
15045
+ return root !== node && (name === 'name' ? node.name === value : _this.attributeToString(node, name) === value);
15046
+ });
15047
+ } else {
15048
+ return null;
15049
+ }
15050
+ } else {
15051
+ // getElementsByTag('circle');
15052
+ return root.find(function (node) {
15053
+ return root !== node && node.nodeName === query;
15054
+ });
15055
+ }
15056
+ };
15057
+
15058
+ _proto.selectAll = function selectAll(query, root) {
15059
+ var _this2 = this;
15060
+
15061
+ // only support `[name="${name}"]` `.className` `#id`
15062
+ if (query.startsWith('.')) {
15063
+ // getElementsByClassName('className');
15064
+ // should not include itself
15065
+ return root.findAll(function (node) {
15066
+ return root !== node && node.className === _this2.getIdOrClassname(query);
15067
+ });
15068
+ } else if (query.startsWith('#')) {
15069
+ return root.findAll(function (node) {
15070
+ return root !== node && node.id === _this2.getIdOrClassname(query);
15071
+ });
15072
+ } else if (query.startsWith('[')) {
15073
+ var _this$getAttribute2 = this.getAttribute(query),
15074
+ name = _this$getAttribute2.name,
15075
+ value = _this$getAttribute2.value;
15076
+
15077
+ if (name) {
15078
+ // getElementsByName();
15079
+ return root.findAll(function (node) {
15080
+ return root !== node && (name === 'name' ? node.name === value : _this2.attributeToString(node, name) === value);
15081
+ });
15082
+ } else {
15083
+ return [];
15084
+ }
15085
+ } else {
15086
+ // getElementsByTag('circle');
15087
+ return root.findAll(function (node) {
15088
+ return root !== node && node.nodeName === query;
15089
+ });
15090
+ }
15091
+ } // eslint-disable-next-line @typescript-eslint/no-unused-vars
15092
+ ;
15093
+
15094
+ _proto.is = function is(query, node) {
15095
+ // a simple `matches` implementation
15096
+ if (query.startsWith('.')) {
15097
+ return node.className === this.getIdOrClassname(query);
15098
+ } else if (query.startsWith('#')) {
15099
+ return node.id === this.getIdOrClassname(query);
15100
+ } else if (query.startsWith('[')) {
15101
+ var _this$getAttribute3 = this.getAttribute(query),
15102
+ name = _this$getAttribute3.name,
15103
+ value = _this$getAttribute3.value;
15104
+
15105
+ return name === 'name' ? node.name === value : this.attributeToString(node, name) === value;
15106
+ } else {
15107
+ return node.nodeName === query;
15108
+ }
15109
+ };
15110
+
15111
+ _proto.getIdOrClassname = function getIdOrClassname(query) {
15112
+ return query.substring(1);
15113
+ };
15114
+
15115
+ _proto.getAttribute = function getAttribute(query) {
15116
+ var matches = query.match(ATTRIBUTE_REGEXP);
15117
+ var name = '';
15118
+ var value = '';
15119
+
15120
+ if (matches && matches.length > 2) {
15121
+ name = matches[1].replace(/"/g, '');
15122
+ value = matches[2].replace(/"/g, '');
15123
+ }
15124
+
15125
+ return {
15126
+ name: name,
15127
+ value: value
15128
+ };
15129
+ };
15130
+
15131
+ _proto.attributeToString = function attributeToString(node, name) {
15132
+ if (!node.getAttribute) {
15133
+ return '';
15134
+ }
15135
+
15136
+ var value = node.getAttribute(name);
15137
+
15138
+ if (isNil(value)) {
15139
+ return '';
15140
+ }
15141
+
15142
+ if (value.toString) {
15143
+ return value.toString();
15144
+ }
15145
+
15146
+ return '';
15147
+ };
15148
+
15149
+ return DefaultSceneGraphSelector;
15150
+ }();
15151
+
15152
+ exports.DefaultSceneGraphSelector = tslib.__decorate([manaSyringe.singleton({
15153
+ token: SceneGraphSelector
15154
+ })], exports.DefaultSceneGraphSelector);
15155
+
15061
15156
  function sortByZIndex(o1, o2) {
15062
15157
  var zIndex1 = Number(o1.style.zIndex);
15063
15158
  var zIndex2 = Number(o2.style.zIndex);
@@ -19843,7 +19938,7 @@ var EventPlugin = EventPlugin_1 = (_class$4 = /*#__PURE__*/function () {
19843
19938
  var _this$renderingContex, _this$renderingContex2;
19844
19939
 
19845
19940
  var canvas = (_this$renderingContex = _this.renderingContext.root) === null || _this$renderingContex === void 0 ? void 0 : (_this$renderingContex2 = _this$renderingContex.ownerDocument) === null || _this$renderingContex2 === void 0 ? void 0 : _this$renderingContex2.defaultView;
19846
- if (canvas.supportTouchEvent && nativeEvent.pointerType === 'touch') return;
19941
+ if (canvas.supportsTouchEvents && nativeEvent.pointerType === 'touch') return;
19847
19942
 
19848
19943
  var normalizedEvents = _this.normalizeToPointerEvent(nativeEvent, canvas);
19849
19944
 
@@ -19904,6 +19999,8 @@ var EventPlugin = EventPlugin_1 = (_class$4 = /*#__PURE__*/function () {
19904
19999
  _this2.eventService.mapEvent(wheelEvent);
19905
20000
  });
19906
20001
  renderingService.hooks.pointerDown.tap(EventPlugin_1.tag, function (nativeEvent) {
20002
+ if (canvas.supportsTouchEvents && nativeEvent.pointerType === 'touch') return;
20003
+
19907
20004
  var events = _this2.normalizeToPointerEvent(nativeEvent, canvas);
19908
20005
 
19909
20006
  if (_this2.autoPreventDefault && events[0].isNormalized) {
@@ -19925,7 +20022,7 @@ var EventPlugin = EventPlugin_1 = (_class$4 = /*#__PURE__*/function () {
19925
20022
  _this2.setCursor(_this2.eventService.cursor);
19926
20023
  });
19927
20024
  renderingService.hooks.pointerUp.tap(EventPlugin_1.tag, function (nativeEvent) {
19928
- if (canvas.supportTouchEvent && nativeEvent.pointerType === 'touch') return; // account for element in SVG
20025
+ if (canvas.supportsTouchEvents && nativeEvent.pointerType === 'touch') return; // account for element in SVG
19929
20026
 
19930
20027
  var $element = _this2.contextService.getDomElement();
19931
20028
 
@@ -19949,24 +20046,7 @@ var EventPlugin = EventPlugin_1 = (_class$4 = /*#__PURE__*/function () {
19949
20046
  });
19950
20047
  renderingService.hooks.pointerMove.tap(EventPlugin_1.tag, this.onPointerMove);
19951
20048
  renderingService.hooks.pointerOver.tap(EventPlugin_1.tag, this.onPointerMove);
19952
- renderingService.hooks.pointerOut.tap(EventPlugin_1.tag, this.onPointerMove); // renderingService.hooks.pointerCancel.tap(
19953
- // EventPlugin.tag,
19954
- // (nativeEvent: InteractivePointerEvent) => {
19955
- // if (canvas.supportTouchEvent && (nativeEvent as PointerEvent).pointerType === 'touch') {
19956
- // return;
19957
- // }
19958
- // const normalizedEvent = this.normalizeToPointerEvent(nativeEvent, canvas);
19959
- // if (this.autoPreventDefault && (normalizedEvent as any).isNormalized) {
19960
- // const cancelable = nativeEvent.cancelable || !('cancelable' in nativeEvent);
19961
- // if (cancelable) {
19962
- // nativeEvent.preventDefault();
19963
- // }
19964
- // }
19965
- // const federatedEvent = this.bootstrapEvent(this.rootPointerEvent, normalizedEvent, canvas);
19966
- // this.eventService.mapEvent(federatedEvent);
19967
- // this.setCursor(this.eventService.cursor);
19968
- // },
19969
- // );
20049
+ renderingService.hooks.pointerOut.tap(EventPlugin_1.tag, this.onPointerMove);
19970
20050
  };
19971
20051
 
19972
20052
  _proto.bootstrapEvent = function bootstrapEvent(e, nativeEvent, view) {
@@ -20245,8 +20325,8 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
20245
20325
  _this.requestAnimationFrame = void 0;
20246
20326
  _this.cancelAnimationFrame = void 0;
20247
20327
  _this.devicePixelRatio = void 0;
20248
- _this.supportPointerEvent = void 0;
20249
- _this.supportTouchEvent = void 0;
20328
+ _this.supportsPointerEvents = void 0;
20329
+ _this.supportsTouchEvents = void 0;
20250
20330
  _this.isTouchEvent = void 0;
20251
20331
  _this.isMouseEvent = void 0;
20252
20332
  _this.Element = DisplayObject;
@@ -20271,8 +20351,8 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
20271
20351
  requestAnimationFrame = config.requestAnimationFrame,
20272
20352
  cancelAnimationFrame = config.cancelAnimationFrame,
20273
20353
  createImage = config.createImage,
20274
- supportPointerEvent = config.supportPointerEvent,
20275
- supportTouchEvent = config.supportTouchEvent,
20354
+ supportsPointerEvents = config.supportsPointerEvents,
20355
+ supportsTouchEvents = config.supportsTouchEvents,
20276
20356
  isTouchEvent = config.isTouchEvent,
20277
20357
  isMouseEvent = config.isMouseEvent;
20278
20358
  cleanExistedCanvas(container, _assertThisInitialized(_this));
@@ -20301,13 +20381,13 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
20301
20381
  // the following feature-detect from hammer.js
20302
20382
  // @see https://github.com/hammerjs/hammer.js/blob/master/src/inputjs/input-consts.js#L5
20303
20383
 
20304
- _this.supportTouchEvent = supportTouchEvent !== null && supportTouchEvent !== void 0 ? supportTouchEvent : 'ontouchstart' in globalThis;
20305
- _this.supportPointerEvent = supportPointerEvent !== null && supportPointerEvent !== void 0 ? supportPointerEvent : !!globalThis.PointerEvent;
20384
+ _this.supportsTouchEvents = supportsTouchEvents !== null && supportsTouchEvents !== void 0 ? supportsTouchEvents : 'ontouchstart' in globalThis;
20385
+ _this.supportsPointerEvents = supportsPointerEvents !== null && supportsPointerEvents !== void 0 ? supportsPointerEvents : !!globalThis.PointerEvent;
20306
20386
  _this.isTouchEvent = isTouchEvent !== null && isTouchEvent !== void 0 ? isTouchEvent : function (event) {
20307
- return _this.supportTouchEvent && event instanceof globalThis.TouchEvent;
20387
+ return _this.supportsTouchEvents && event instanceof globalThis.TouchEvent;
20308
20388
  };
20309
20389
  _this.isMouseEvent = isMouseEvent !== null && isMouseEvent !== void 0 ? isMouseEvent : function (event) {
20310
- return !globalThis.MouseEvent || event instanceof globalThis.MouseEvent && (!_this.supportPointerEvent || !(event instanceof globalThis.PointerEvent));
20390
+ return !globalThis.MouseEvent || event instanceof globalThis.MouseEvent && (!_this.supportsPointerEvents || !(event instanceof globalThis.PointerEvent));
20311
20391
  };
20312
20392
 
20313
20393
  _this.initRenderingContext({
@@ -20612,9 +20692,9 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
20612
20692
  var oldRenderer = canvasConfig.renderer;
20613
20693
  canvasConfig.renderer = renderer; // keep all children undestroyed
20614
20694
 
20615
- this.destroy(false); // destroy all plugins
20695
+ this.destroy(false); // destroy all plugins, reverse will mutate origin array
20616
20696
 
20617
- oldRenderer === null || oldRenderer === void 0 ? void 0 : oldRenderer.getPlugins().reverse().forEach(function (plugin) {
20697
+ [].concat(oldRenderer === null || oldRenderer === void 0 ? void 0 : oldRenderer.getPlugins()).reverse().forEach(function (plugin) {
20618
20698
  plugin.destroy(_this6.container);
20619
20699
  });
20620
20700
  this.initRenderer(renderer);
@@ -20763,6 +20843,7 @@ exports.CSSMathValue = CSSMathValue;
20763
20843
  exports.CSSMathVariadic = CSSMathVariadic;
20764
20844
  exports.CSSNumericValue = CSSNumericValue;
20765
20845
  exports.CSSNumericValueType = CSSNumericValueType;
20846
+ exports.CSSPropertyAngle = CSSPropertyAngle;
20766
20847
  exports.CSSPropertyClipPath = CSSPropertyClipPath;
20767
20848
  exports.CSSPropertyColor = CSSPropertyColor;
20768
20849
  exports.CSSPropertyFilter = CSSPropertyFilter;