@antv/g 5.1.3 → 5.1.4

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
@@ -1186,393 +1186,6 @@ 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*\]/;
1194
- /**
1195
- * support the following DOM API:
1196
- * * getElementById
1197
- * * getElementsByClassName
1198
- * * getElementsByName
1199
- * * getElementsByTag
1200
- * * querySelector
1201
- * * querySelectorAll
1202
- */
1203
-
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();
1226
-
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
- });
1238
- }
1239
- };
1240
-
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);
1256
-
1257
- if (matches && matches.length > 1) {
1258
- var targetName = matches[1].replace(/"/g, ''); // getElementByName();
1259
-
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
- ;
1274
-
1275
- _proto.is = function is() {
1276
- // TODO: need a simple `matches` implementation
1277
- return true;
1278
- };
1279
-
1280
- return DefaultSceneGraphSelector;
1281
- }();
1282
-
1283
- exports.DefaultSceneGraphSelector = tslib.__decorate([manaSyringe.singleton({
1284
- token: SceneGraphSelector
1285
- })], exports.DefaultSceneGraphSelector);
1286
-
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
- */
1294
-
1295
- (function (ElementEvent) {
1296
- ElementEvent["DESTROY"] = "destroy";
1297
- /**
1298
- * @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMAttrModified
1299
- */
1300
-
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
- */
1306
-
1307
- ElementEvent["INSERTED"] = "DOMNodeInserted";
1308
- /**
1309
- * it has had a child inserted
1310
- */
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
- */
1317
-
1318
- ElementEvent["REMOVED"] = "removed";
1319
- /**
1320
- * it has had a child removed
1321
- */
1322
-
1323
- ElementEvent["CHILD_REMOVED"] = "child-removed";
1324
- /**
1325
- * @see https://www.w3.org/TR/DOM-Level-3-Events/#domnodeinsertedintodocument
1326
- */
1327
-
1328
- ElementEvent["MOUNTED"] = "DOMNodeInsertedIntoDocument";
1329
- /**
1330
- * @see https://www.w3.org/TR/DOM-Level-3-Events/#domnoderemovedfromdocument
1331
- */
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
- */
1339
-
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
1189
  function DCHECK(bool) {
1577
1190
  if (!bool) {
1578
1191
  throw new Error();
@@ -2427,39 +2040,297 @@ var TOUCH_TO_POINTER = {
2427
2040
  * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#percentage
2428
2041
  */
2429
2042
 
2430
- PropertySyntax["PERCENTAGE"] = "<percentage>";
2431
- PropertySyntax["LENGTH_PERCENTAGE"] = "<length> | <percentage>";
2432
- PropertySyntax["LENGTH_PERCENTAGE_12"] = "[<length> | <percentage>]{1,2}";
2433
- /**
2434
- * @see https://developer.mozilla.org/en-US/docs/Web/CSS/margin#formal_syntax
2435
- */
2043
+ PropertySyntax["PERCENTAGE"] = "<percentage>";
2044
+ PropertySyntax["LENGTH_PERCENTAGE"] = "<length> | <percentage>";
2045
+ PropertySyntax["LENGTH_PERCENTAGE_12"] = "[<length> | <percentage>]{1,2}";
2046
+ /**
2047
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/margin#formal_syntax
2048
+ */
2049
+
2050
+ PropertySyntax["LENGTH_PERCENTAGE_14"] = "[<length> | <percentage>]{1,4}";
2051
+ /**
2052
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#list-of-ts
2053
+ */
2054
+
2055
+ PropertySyntax["LIST_OF_POINTS"] = "<list-of-points>";
2056
+ PropertySyntax["PATH"] = "<path>";
2057
+ /**
2058
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/filter#formal_syntax
2059
+ */
2060
+
2061
+ PropertySyntax["FILTER"] = "<filter>";
2062
+ PropertySyntax["Z_INDEX"] = "<z-index>";
2063
+ PropertySyntax["OFFSET_PATH"] = "<offset-path>";
2064
+ PropertySyntax["OFFSET_DISTANCE"] = "<offset-distance>";
2065
+ PropertySyntax["CLIP_PATH"] = "<clip-path>";
2066
+ PropertySyntax["TRANSFORM"] = "<transform>";
2067
+ PropertySyntax["TRANSFORM_ORIGIN"] = "<transform-origin>";
2068
+ PropertySyntax["TEXT"] = "<text>";
2069
+ PropertySyntax["TEXT_TRANSFORM"] = "<text-transform>";
2070
+ })(exports.PropertySyntax || (exports.PropertySyntax = {}));
2071
+
2072
+ var StyleValueRegistry = manaSyringe.Syringe.defineToken('StyleValueRegistry');
2073
+
2074
+ var GeometryUpdaterFactory = manaSyringe.Syringe.defineToken('GeometryUpdaterFactory');
2075
+ var GeometryAABBUpdater = manaSyringe.Syringe.defineToken('GeometryAABBUpdater');
2076
+
2077
+ /**
2078
+ * built-in events for element
2079
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationEvent
2080
+ *
2081
+ * TODO: use MutationObserver instead
2082
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
2083
+ */
2084
+
2085
+ (function (ElementEvent) {
2086
+ ElementEvent["DESTROY"] = "destroy";
2087
+ /**
2088
+ * @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMAttrModified
2089
+ */
2090
+
2091
+ ElementEvent["ATTR_MODIFIED"] = "DOMAttrModified";
2092
+ /**
2093
+ * it has been inserted
2094
+ * @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMNodeInserted
2095
+ */
2096
+
2097
+ ElementEvent["INSERTED"] = "DOMNodeInserted";
2098
+ /**
2099
+ * it has had a child inserted
2100
+ */
2101
+
2102
+ ElementEvent["CHILD_INSERTED"] = "child-inserted";
2103
+ /**
2104
+ * it is being removed
2105
+ * @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMNodeRemoved
2106
+ */
2107
+
2108
+ ElementEvent["REMOVED"] = "removed";
2109
+ /**
2110
+ * it has had a child removed
2111
+ */
2112
+
2113
+ ElementEvent["CHILD_REMOVED"] = "child-removed";
2114
+ /**
2115
+ * @see https://www.w3.org/TR/DOM-Level-3-Events/#domnodeinsertedintodocument
2116
+ */
2117
+
2118
+ ElementEvent["MOUNTED"] = "DOMNodeInsertedIntoDocument";
2119
+ /**
2120
+ * @see https://www.w3.org/TR/DOM-Level-3-Events/#domnoderemovedfromdocument
2121
+ */
2122
+
2123
+ ElementEvent["UNMOUNTED"] = "DOMNodeRemovedFromDocument";
2124
+ ElementEvent["BOUNDS_CHANGED"] = "bounds-changed";
2125
+ ElementEvent["GEOMETRY_BOUNDS_CHANGED"] = "geometry-bounds-changed";
2126
+ /**
2127
+ * trigger when z-index changed
2128
+ */
2129
+
2130
+ ElementEvent["RENDER_ORDER_CHANGED"] = "render-order-changed";
2131
+ })(exports.ElementEvent || (exports.ElementEvent = {}));
2132
+
2133
+ /**
2134
+ * An DOM-compatible synthetic event implementation that is "forwarded" on behalf of an original
2135
+ * FederatedEvent or native {@link https://dom.spec.whatwg.org/#event Event}.
2136
+ */
2137
+
2138
+ var FederatedEvent = /*#__PURE__*/function () {
2139
+ /**
2140
+ * The event boundary which manages this event. Propagation can only occur
2141
+ * within the boundary's jurisdiction.
2142
+ */
2143
+ function FederatedEvent(manager) {
2144
+ this.type = void 0;
2145
+ this.eventPhase = FederatedEvent.prototype.NONE;
2146
+ this.target = void 0;
2147
+ this.bubbles = true;
2148
+ this.cancelBubble = true;
2149
+ this.cancelable = false;
2150
+ this.currentTarget = void 0;
2151
+ this.defaultPrevented = false;
2152
+ this.timeStamp = void 0;
2153
+ this.nativeEvent = void 0;
2154
+ this.originalEvent = void 0;
2155
+ this.propagationStopped = false;
2156
+ this.propagationImmediatelyStopped = false;
2157
+ this.manager = void 0;
2158
+ this.detail = void 0;
2159
+ this.layer = new Point();
2160
+ this.page = new Point();
2161
+ this.canvas = new Point();
2162
+ this.viewport = new Point();
2163
+ this.path = void 0;
2164
+ this.view = void 0;
2165
+ this.which = void 0;
2166
+ this.returnValue = void 0;
2167
+ this.srcElement = void 0;
2168
+ this.composed = false;
2169
+ this.isTrusted = void 0;
2170
+ this.NONE = 0;
2171
+ this.CAPTURING_PHASE = 1;
2172
+ this.AT_TARGET = 2;
2173
+ this.BUBBLING_PHASE = 3;
2174
+ this.manager = manager;
2175
+ }
2176
+
2177
+ var _proto = FederatedEvent.prototype;
2178
+
2179
+ /**
2180
+ * The propagation path for this event
2181
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Event/composedPath
2182
+ *
2183
+ * So composedPath()[0] represents the original target.
2184
+ * @see https://polymer-library.polymer-project.org/3.0/docs/devguide/events#retargeting
2185
+ */
2186
+ _proto.composedPath = function composedPath() {
2187
+ if (this.manager && (!this.path || this.path[0] !== this.target)) {
2188
+ this.path = this.target ? this.manager.propagationPath(this.target) : [];
2189
+ }
2190
+
2191
+ return this.path;
2192
+ }
2193
+ /**
2194
+ * @deprecated
2195
+ */
2196
+ ;
2197
+
2198
+ /**
2199
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Event/preventDefault
2200
+ */
2201
+ _proto.preventDefault = function preventDefault() {
2202
+ if (this.nativeEvent instanceof Event && this.nativeEvent.cancelable) {
2203
+ this.nativeEvent.preventDefault();
2204
+ }
2205
+
2206
+ this.defaultPrevented = true;
2207
+ }
2208
+ /**
2209
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Event/stopImmediatePropagation
2210
+ */
2211
+ ;
2212
+
2213
+ _proto.stopImmediatePropagation = function stopImmediatePropagation() {
2214
+ this.propagationImmediatelyStopped = true;
2215
+ }
2216
+ /**
2217
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Event/stopPropagation
2218
+ */
2219
+ ;
2220
+
2221
+ _proto.stopPropagation = function stopPropagation() {
2222
+ this.propagationStopped = true;
2223
+ }
2224
+ /**
2225
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/view
2226
+ */
2227
+ ;
2228
+
2229
+ /**
2230
+ * added for compatibility with DOM Event,
2231
+ * deprecated props and methods
2232
+ */
2233
+ _proto.initEvent = function initEvent() {};
2234
+
2235
+ _proto.initUIEvent = function initUIEvent() {};
2236
+
2237
+ _createClass(FederatedEvent, [{
2238
+ key: "name",
2239
+ get:
2240
+ /**
2241
+ * The type of event, supports the following:
2242
+ * * pointerdown
2243
+ * * touchstart
2244
+ * * mousedown
2245
+ * * rightdown
2246
+ * * ...
2247
+ */
2248
+
2249
+ /**
2250
+ * @deprecated
2251
+ */
2252
+ function get() {
2253
+ return this.type;
2254
+ }
2255
+ /**
2256
+ * The propagation phase.
2257
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Event/eventPhase
2258
+ */
2436
2259
 
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
- */
2260
+ }, {
2261
+ key: "layerX",
2262
+ get: function get() {
2263
+ return this.layer.x;
2264
+ }
2265
+ }, {
2266
+ key: "layerY",
2267
+ get: function get() {
2268
+ return this.layer.y;
2269
+ }
2270
+ /**
2271
+ * The coordinates of the event relative to the DOM document.
2272
+ * This is a non-standard property.
2273
+ * relative to the DOM document.
2274
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/MouseEvent/pageX
2275
+ */
2441
2276
 
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
- */
2277
+ }, {
2278
+ key: "pageX",
2279
+ get: function get() {
2280
+ return this.page.x;
2281
+ }
2282
+ }, {
2283
+ key: "pageY",
2284
+ get: function get() {
2285
+ return this.page.y;
2286
+ }
2287
+ /**
2288
+ * relative to Canvas, origin is left-top
2289
+ */
2447
2290
 
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 = {}));
2291
+ }, {
2292
+ key: "x",
2293
+ get: function get() {
2294
+ return this.canvas.x;
2295
+ }
2296
+ }, {
2297
+ key: "y",
2298
+ get: function get() {
2299
+ return this.canvas.y;
2300
+ }
2301
+ }, {
2302
+ key: "canvasX",
2303
+ get: function get() {
2304
+ return this.canvas.x;
2305
+ }
2306
+ }, {
2307
+ key: "canvasY",
2308
+ get: function get() {
2309
+ return this.canvas.y;
2310
+ }
2311
+ /**
2312
+ * relative to Viewport, account for Camera
2313
+ */
2458
2314
 
2459
- var StyleValueRegistry = manaSyringe.Syringe.defineToken('StyleValueRegistry');
2315
+ }, {
2316
+ key: "viewportX",
2317
+ get: function get() {
2318
+ return this.viewport.x;
2319
+ }
2320
+ }, {
2321
+ key: "viewportY",
2322
+ get: function get() {
2323
+ return this.viewport.y;
2324
+ }
2325
+ }, {
2326
+ key: "propagationPath",
2327
+ get: function get() {
2328
+ return this.composedPath();
2329
+ }
2330
+ }]);
2460
2331
 
2461
- var GeometryUpdaterFactory = manaSyringe.Syringe.defineToken('GeometryUpdaterFactory');
2462
- var GeometryAABBUpdater = manaSyringe.Syringe.defineToken('GeometryAABBUpdater');
2332
+ return FederatedEvent;
2333
+ }();
2463
2334
 
2464
2335
  /**
2465
2336
  * @see https://developer.mozilla.org/en-US/docs/Web/Events/Creating_and_triggering_events
@@ -3003,6 +2874,37 @@ var Sortable = function Sortable() {
3003
2874
  };
3004
2875
  Sortable.tag = 'c-sortable';
3005
2876
 
2877
+ var MutationEvent = /*#__PURE__*/function (_FederatedEvent) {
2878
+ _inheritsLoose(MutationEvent, _FederatedEvent);
2879
+
2880
+ function MutationEvent(typeArg, relatedNode, prevValue, newValue, attrName, attrChange, prevParsedValue, newParsedValue) {
2881
+ var _this;
2882
+
2883
+ _this = _FederatedEvent.call(this, null) || this;
2884
+ _this.relatedNode = void 0;
2885
+ _this.prevValue = void 0;
2886
+ _this.newValue = void 0;
2887
+ _this.attrName = void 0;
2888
+ _this.attrChange = void 0;
2889
+ _this.prevParsedValue = void 0;
2890
+ _this.newParsedValue = void 0;
2891
+ _this.relatedNode = relatedNode;
2892
+ _this.prevValue = prevValue;
2893
+ _this.newValue = newValue;
2894
+ _this.attrName = attrName;
2895
+ _this.attrChange = attrChange;
2896
+ _this.prevParsedValue = prevParsedValue;
2897
+ _this.newParsedValue = newParsedValue;
2898
+ _this.type = typeArg;
2899
+ return _this;
2900
+ }
2901
+
2902
+ return MutationEvent;
2903
+ }(FederatedEvent);
2904
+ MutationEvent.ADDITION = 2;
2905
+ MutationEvent.MODIFICATION = 1;
2906
+ MutationEvent.REMOVAL = 3;
2907
+
3006
2908
  var entityCounter = 0;
3007
2909
  /**
3008
2910
  * Has following capabilities:
@@ -3161,6 +3063,24 @@ var Element = /*#__PURE__*/function (_Node) {
3161
3063
  _proto.querySelectorAll = function querySelectorAll(selectors) {
3162
3064
  return this.sceneGraphService.querySelectorAll(selectors, this);
3163
3065
  }
3066
+ /**
3067
+ * should traverses the element and its parents (heading toward the document root)
3068
+ * until it finds a node that matches the specified CSS selector.
3069
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/closest
3070
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/closest#polyfill
3071
+ */
3072
+ ;
3073
+
3074
+ _proto.closest = function closest(selectors) {
3075
+ var el = this;
3076
+
3077
+ do {
3078
+ if (this.sceneGraphService.matches(selectors, el)) return el;
3079
+ el = el.parentElement;
3080
+ } while (el !== null);
3081
+
3082
+ return null;
3083
+ }
3164
3084
  /**
3165
3085
  * search in scene group, but should not include itself
3166
3086
  */
@@ -15058,6 +14978,159 @@ function toFontString(attributes) {
15058
14978
  return fontStyle + " " + fontVariant + " " + fontWeight + " " + fontSizeString + " " + fontFamilies.join(',');
15059
14979
  }
15060
14980
 
14981
+ var SceneGraphSelectorFactory = manaSyringe.Syringe.defineToken('SceneGraphSelectorFactory');
14982
+ var SceneGraphSelector = manaSyringe.Syringe.defineToken('SceneGraphSelector', {
14983
+ multiple: false
14984
+ });
14985
+ var ATTRIBUTE_REGEXP = /\[\s*(.*)=(.*)\s*\]/;
14986
+ /**
14987
+ * support the following DOM API:
14988
+ * * getElementById
14989
+ * * getElementsByClassName
14990
+ * * getElementsByName
14991
+ * * getElementsByTag
14992
+ * * querySelector
14993
+ * * querySelectorAll
14994
+ */
14995
+
14996
+ exports.DefaultSceneGraphSelector = /*#__PURE__*/function () {
14997
+ function DefaultSceneGraphSelector() {}
14998
+
14999
+ var _proto = DefaultSceneGraphSelector.prototype;
15000
+
15001
+ _proto.selectOne = function selectOne(query, root) {
15002
+ var _this = this;
15003
+
15004
+ if (query.startsWith('.')) {
15005
+ return root.find(function (node) {
15006
+ // return !node.shadow && node.id === query.substring(1);
15007
+ return node.className === _this.getIdOrClassname(query);
15008
+ });
15009
+ } else if (query.startsWith('#')) {
15010
+ // getElementById('id')
15011
+ return root.find(function (node) {
15012
+ // return !node.shadow && node.id === query.substring(1);
15013
+ return node.id === _this.getIdOrClassname(query);
15014
+ });
15015
+ } else if (query.startsWith('[')) {
15016
+ var _this$getAttribute = this.getAttribute(query),
15017
+ name = _this$getAttribute.name,
15018
+ value = _this$getAttribute.value;
15019
+
15020
+ if (name) {
15021
+ // getElementByName();
15022
+ return root.find(function (node) {
15023
+ return root !== node && (name === 'name' ? node.name === value : _this.attributeToString(node, name) === value);
15024
+ });
15025
+ } else {
15026
+ return null;
15027
+ }
15028
+ } else {
15029
+ // getElementsByTag('circle');
15030
+ return root.find(function (node) {
15031
+ return root !== node && node.nodeName === query;
15032
+ });
15033
+ }
15034
+ };
15035
+
15036
+ _proto.selectAll = function selectAll(query, root) {
15037
+ var _this2 = this;
15038
+
15039
+ // only support `[name="${name}"]` `.className` `#id`
15040
+ if (query.startsWith('.')) {
15041
+ // getElementsByClassName('className');
15042
+ // should not include itself
15043
+ return root.findAll(function (node) {
15044
+ return root !== node && node.className === _this2.getIdOrClassname(query);
15045
+ });
15046
+ } else if (query.startsWith('#')) {
15047
+ return root.findAll(function (node) {
15048
+ return root !== node && node.id === _this2.getIdOrClassname(query);
15049
+ });
15050
+ } else if (query.startsWith('[')) {
15051
+ var _this$getAttribute2 = this.getAttribute(query),
15052
+ name = _this$getAttribute2.name,
15053
+ value = _this$getAttribute2.value;
15054
+
15055
+ if (name) {
15056
+ // getElementsByName();
15057
+ return root.findAll(function (node) {
15058
+ return root !== node && (name === 'name' ? node.name === value : _this2.attributeToString(node, name) === value);
15059
+ });
15060
+ } else {
15061
+ return [];
15062
+ }
15063
+ } else {
15064
+ // getElementsByTag('circle');
15065
+ return root.findAll(function (node) {
15066
+ return root !== node && node.nodeName === query;
15067
+ });
15068
+ }
15069
+ } // eslint-disable-next-line @typescript-eslint/no-unused-vars
15070
+ ;
15071
+
15072
+ _proto.is = function is(query, node) {
15073
+ // a simple `matches` implementation
15074
+ if (query.startsWith('.')) {
15075
+ return node.className === this.getIdOrClassname(query);
15076
+ } else if (query.startsWith('#')) {
15077
+ return node.id === this.getIdOrClassname(query);
15078
+ } else if (query.startsWith('[')) {
15079
+ var _this$getAttribute3 = this.getAttribute(query),
15080
+ name = _this$getAttribute3.name,
15081
+ value = _this$getAttribute3.value;
15082
+
15083
+ return name === 'name' ? node.name === value : this.attributeToString(node, name) === value;
15084
+ } else {
15085
+ return node.nodeName === query;
15086
+ }
15087
+ };
15088
+
15089
+ _proto.getIdOrClassname = function getIdOrClassname(query) {
15090
+ return query.substring(1);
15091
+ };
15092
+
15093
+ _proto.getAttribute = function getAttribute(query) {
15094
+ var matches = query.match(ATTRIBUTE_REGEXP);
15095
+ var name = '';
15096
+ var value = '';
15097
+
15098
+ if (matches && matches.length > 2) {
15099
+ name = matches[1].replace(/"/g, '');
15100
+ value = matches[2].replace(/"/g, '');
15101
+ }
15102
+
15103
+ return {
15104
+ name: name,
15105
+ value: value
15106
+ };
15107
+ };
15108
+
15109
+ _proto.attributeToString = function attributeToString(node, name) {
15110
+ if (!node.getAttribute) {
15111
+ return '';
15112
+ }
15113
+
15114
+ var value = node.getAttribute(name);
15115
+
15116
+ if (isNil(value)) {
15117
+ return '';
15118
+ }
15119
+
15120
+ if (value.toString) {
15121
+ return value.toString();
15122
+ }
15123
+
15124
+ return '';
15125
+ };
15126
+
15127
+ return DefaultSceneGraphSelector;
15128
+ }();
15129
+
15130
+ exports.DefaultSceneGraphSelector = tslib.__decorate([manaSyringe.singleton({
15131
+ token: SceneGraphSelector
15132
+ })], exports.DefaultSceneGraphSelector);
15133
+
15061
15134
  function sortByZIndex(o1, o2) {
15062
15135
  var zIndex1 = Number(o1.style.zIndex);
15063
15136
  var zIndex2 = Number(o2.style.zIndex);
@@ -19843,7 +19916,7 @@ var EventPlugin = EventPlugin_1 = (_class$4 = /*#__PURE__*/function () {
19843
19916
  var _this$renderingContex, _this$renderingContex2;
19844
19917
 
19845
19918
  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;
19919
+ if (canvas.supportsTouchEvents && nativeEvent.pointerType === 'touch') return;
19847
19920
 
19848
19921
  var normalizedEvents = _this.normalizeToPointerEvent(nativeEvent, canvas);
19849
19922
 
@@ -19904,6 +19977,8 @@ var EventPlugin = EventPlugin_1 = (_class$4 = /*#__PURE__*/function () {
19904
19977
  _this2.eventService.mapEvent(wheelEvent);
19905
19978
  });
19906
19979
  renderingService.hooks.pointerDown.tap(EventPlugin_1.tag, function (nativeEvent) {
19980
+ if (canvas.supportsTouchEvents && nativeEvent.pointerType === 'touch') return;
19981
+
19907
19982
  var events = _this2.normalizeToPointerEvent(nativeEvent, canvas);
19908
19983
 
19909
19984
  if (_this2.autoPreventDefault && events[0].isNormalized) {
@@ -19925,7 +20000,7 @@ var EventPlugin = EventPlugin_1 = (_class$4 = /*#__PURE__*/function () {
19925
20000
  _this2.setCursor(_this2.eventService.cursor);
19926
20001
  });
19927
20002
  renderingService.hooks.pointerUp.tap(EventPlugin_1.tag, function (nativeEvent) {
19928
- if (canvas.supportTouchEvent && nativeEvent.pointerType === 'touch') return; // account for element in SVG
20003
+ if (canvas.supportsTouchEvents && nativeEvent.pointerType === 'touch') return; // account for element in SVG
19929
20004
 
19930
20005
  var $element = _this2.contextService.getDomElement();
19931
20006
 
@@ -19949,24 +20024,7 @@ var EventPlugin = EventPlugin_1 = (_class$4 = /*#__PURE__*/function () {
19949
20024
  });
19950
20025
  renderingService.hooks.pointerMove.tap(EventPlugin_1.tag, this.onPointerMove);
19951
20026
  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
- // );
20027
+ renderingService.hooks.pointerOut.tap(EventPlugin_1.tag, this.onPointerMove);
19970
20028
  };
19971
20029
 
19972
20030
  _proto.bootstrapEvent = function bootstrapEvent(e, nativeEvent, view) {
@@ -20245,8 +20303,8 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
20245
20303
  _this.requestAnimationFrame = void 0;
20246
20304
  _this.cancelAnimationFrame = void 0;
20247
20305
  _this.devicePixelRatio = void 0;
20248
- _this.supportPointerEvent = void 0;
20249
- _this.supportTouchEvent = void 0;
20306
+ _this.supportsPointerEvents = void 0;
20307
+ _this.supportsTouchEvents = void 0;
20250
20308
  _this.isTouchEvent = void 0;
20251
20309
  _this.isMouseEvent = void 0;
20252
20310
  _this.Element = DisplayObject;
@@ -20271,8 +20329,8 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
20271
20329
  requestAnimationFrame = config.requestAnimationFrame,
20272
20330
  cancelAnimationFrame = config.cancelAnimationFrame,
20273
20331
  createImage = config.createImage,
20274
- supportPointerEvent = config.supportPointerEvent,
20275
- supportTouchEvent = config.supportTouchEvent,
20332
+ supportsPointerEvents = config.supportsPointerEvents,
20333
+ supportsTouchEvents = config.supportsTouchEvents,
20276
20334
  isTouchEvent = config.isTouchEvent,
20277
20335
  isMouseEvent = config.isMouseEvent;
20278
20336
  cleanExistedCanvas(container, _assertThisInitialized(_this));
@@ -20301,13 +20359,13 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
20301
20359
  // the following feature-detect from hammer.js
20302
20360
  // @see https://github.com/hammerjs/hammer.js/blob/master/src/inputjs/input-consts.js#L5
20303
20361
 
20304
- _this.supportTouchEvent = supportTouchEvent !== null && supportTouchEvent !== void 0 ? supportTouchEvent : 'ontouchstart' in globalThis;
20305
- _this.supportPointerEvent = supportPointerEvent !== null && supportPointerEvent !== void 0 ? supportPointerEvent : !!globalThis.PointerEvent;
20362
+ _this.supportsTouchEvents = supportsTouchEvents !== null && supportsTouchEvents !== void 0 ? supportsTouchEvents : 'ontouchstart' in globalThis;
20363
+ _this.supportsPointerEvents = supportsPointerEvents !== null && supportsPointerEvents !== void 0 ? supportsPointerEvents : !!globalThis.PointerEvent;
20306
20364
  _this.isTouchEvent = isTouchEvent !== null && isTouchEvent !== void 0 ? isTouchEvent : function (event) {
20307
- return _this.supportTouchEvent && event instanceof globalThis.TouchEvent;
20365
+ return _this.supportsTouchEvents && event instanceof globalThis.TouchEvent;
20308
20366
  };
20309
20367
  _this.isMouseEvent = isMouseEvent !== null && isMouseEvent !== void 0 ? isMouseEvent : function (event) {
20310
- return !globalThis.MouseEvent || event instanceof globalThis.MouseEvent && (!_this.supportPointerEvent || !(event instanceof globalThis.PointerEvent));
20368
+ return !globalThis.MouseEvent || event instanceof globalThis.MouseEvent && (!_this.supportsPointerEvents || !(event instanceof globalThis.PointerEvent));
20311
20369
  };
20312
20370
 
20313
20371
  _this.initRenderingContext({