@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.esm.js CHANGED
@@ -1166,394 +1166,6 @@ var Rectangle = /*#__PURE__*/function () {
1166
1166
  return Rectangle;
1167
1167
  }();
1168
1168
 
1169
- var SceneGraphSelectorFactory = Syringe.defineToken('SceneGraphSelectorFactory');
1170
- var SceneGraphSelector = Syringe.defineToken('SceneGraphSelector', {
1171
- multiple: false
1172
- });
1173
- var NAME_REGEXP = /\[\s*name=(.*)\s*\]/;
1174
- /**
1175
- * support the following DOM API:
1176
- * * getElementById
1177
- * * getElementsByClassName
1178
- * * getElementsByName
1179
- * * getElementsByTag
1180
- * * querySelector
1181
- * * querySelectorAll
1182
- */
1183
-
1184
- var DefaultSceneGraphSelector = /*#__PURE__*/function () {
1185
- function DefaultSceneGraphSelector() {}
1186
-
1187
- var _proto = DefaultSceneGraphSelector.prototype;
1188
-
1189
- _proto.selectOne = function selectOne(query, root) {
1190
- if (query.startsWith('.')) {
1191
- return root.find(function (node) {
1192
- // return !node.shadow && node.id === query.substring(1);
1193
- return node.className === query.substring(1);
1194
- });
1195
- } else if (query.startsWith('#')) {
1196
- // getElementById('id')
1197
- return root.find(function (node) {
1198
- // return !node.shadow && node.id === query.substring(1);
1199
- return node.id === query.substring(1);
1200
- });
1201
- } else if (query.startsWith('[name=')) {
1202
- var matches = query.match(NAME_REGEXP);
1203
-
1204
- if (matches && matches.length > 1) {
1205
- var targetName = matches[1].replace(/"/g, ''); // getElementByName();
1206
-
1207
- return root.find(function (node) {
1208
- return root !== node && node.name === targetName;
1209
- });
1210
- } else {
1211
- return null;
1212
- }
1213
- } else {
1214
- // getElementsByTag('circle');
1215
- return root.find(function (node) {
1216
- return root !== node && node.nodeName === query;
1217
- });
1218
- }
1219
- };
1220
-
1221
- _proto.selectAll = function selectAll(query, root) {
1222
- // only support `[name="${name}"]` `.className` `#id`
1223
- if (query.startsWith('.')) {
1224
- // getElementsByClassName('className');
1225
- // should not include itself
1226
- return root.findAll(function (node) {
1227
- return root !== node && node.className === query.substring(1);
1228
- });
1229
- } else if (query.startsWith('#')) {
1230
- return root.findAll(function (node) {
1231
- return root !== node && node.id === query.substring(1);
1232
- });
1233
- } else if (query.startsWith('[name=')) {
1234
- // getElementsByName();
1235
- var matches = query.match(NAME_REGEXP);
1236
-
1237
- if (matches && matches.length > 1) {
1238
- var targetName = matches[1].replace(/"/g, ''); // getElementByName();
1239
-
1240
- return root.findAll(function (node) {
1241
- return root !== node && node.name === targetName;
1242
- });
1243
- } else {
1244
- return [];
1245
- }
1246
- } else {
1247
- // getElementsByTag('circle');
1248
- return root.findAll(function (node) {
1249
- return root !== node && node.nodeName === query;
1250
- });
1251
- }
1252
- } // eslint-disable-next-line @typescript-eslint/no-unused-vars
1253
- ;
1254
-
1255
- _proto.is = function is() {
1256
- // TODO: need a simple `matches` implementation
1257
- return true;
1258
- };
1259
-
1260
- return DefaultSceneGraphSelector;
1261
- }();
1262
-
1263
- DefaultSceneGraphSelector = __decorate([singleton({
1264
- token: SceneGraphSelector
1265
- })], DefaultSceneGraphSelector);
1266
-
1267
- /**
1268
- * built-in events for element
1269
- * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationEvent
1270
- *
1271
- * TODO: use MutationObserver instead
1272
- * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
1273
- */
1274
- var ElementEvent;
1275
-
1276
- (function (ElementEvent) {
1277
- ElementEvent["DESTROY"] = "destroy";
1278
- /**
1279
- * @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMAttrModified
1280
- */
1281
-
1282
- ElementEvent["ATTR_MODIFIED"] = "DOMAttrModified";
1283
- /**
1284
- * it has been inserted
1285
- * @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMNodeInserted
1286
- */
1287
-
1288
- ElementEvent["INSERTED"] = "DOMNodeInserted";
1289
- /**
1290
- * it has had a child inserted
1291
- */
1292
-
1293
- ElementEvent["CHILD_INSERTED"] = "child-inserted";
1294
- /**
1295
- * it is being removed
1296
- * @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMNodeRemoved
1297
- */
1298
-
1299
- ElementEvent["REMOVED"] = "removed";
1300
- /**
1301
- * it has had a child removed
1302
- */
1303
-
1304
- ElementEvent["CHILD_REMOVED"] = "child-removed";
1305
- /**
1306
- * @see https://www.w3.org/TR/DOM-Level-3-Events/#domnodeinsertedintodocument
1307
- */
1308
-
1309
- ElementEvent["MOUNTED"] = "DOMNodeInsertedIntoDocument";
1310
- /**
1311
- * @see https://www.w3.org/TR/DOM-Level-3-Events/#domnoderemovedfromdocument
1312
- */
1313
-
1314
- ElementEvent["UNMOUNTED"] = "DOMNodeRemovedFromDocument";
1315
- ElementEvent["BOUNDS_CHANGED"] = "bounds-changed";
1316
- ElementEvent["GEOMETRY_BOUNDS_CHANGED"] = "geometry-bounds-changed";
1317
- /**
1318
- * trigger when z-index changed
1319
- */
1320
-
1321
- ElementEvent["RENDER_ORDER_CHANGED"] = "render-order-changed";
1322
- })(ElementEvent || (ElementEvent = {}));
1323
-
1324
- /**
1325
- * An DOM-compatible synthetic event implementation that is "forwarded" on behalf of an original
1326
- * FederatedEvent or native {@link https://dom.spec.whatwg.org/#event Event}.
1327
- */
1328
-
1329
- var FederatedEvent = /*#__PURE__*/function () {
1330
- /**
1331
- * The event boundary which manages this event. Propagation can only occur
1332
- * within the boundary's jurisdiction.
1333
- */
1334
- function FederatedEvent(manager) {
1335
- this.type = void 0;
1336
- this.eventPhase = FederatedEvent.prototype.NONE;
1337
- this.target = void 0;
1338
- this.bubbles = true;
1339
- this.cancelBubble = true;
1340
- this.cancelable = false;
1341
- this.currentTarget = void 0;
1342
- this.defaultPrevented = false;
1343
- this.timeStamp = void 0;
1344
- this.nativeEvent = void 0;
1345
- this.originalEvent = void 0;
1346
- this.propagationStopped = false;
1347
- this.propagationImmediatelyStopped = false;
1348
- this.manager = void 0;
1349
- this.detail = void 0;
1350
- this.layer = new Point();
1351
- this.page = new Point();
1352
- this.canvas = new Point();
1353
- this.viewport = new Point();
1354
- this.path = void 0;
1355
- this.view = void 0;
1356
- this.which = void 0;
1357
- this.returnValue = void 0;
1358
- this.srcElement = void 0;
1359
- this.composed = false;
1360
- this.isTrusted = void 0;
1361
- this.NONE = 0;
1362
- this.CAPTURING_PHASE = 1;
1363
- this.AT_TARGET = 2;
1364
- this.BUBBLING_PHASE = 3;
1365
- this.manager = manager;
1366
- }
1367
-
1368
- var _proto = FederatedEvent.prototype;
1369
-
1370
- /**
1371
- * The propagation path for this event
1372
- * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Event/composedPath
1373
- *
1374
- * So composedPath()[0] represents the original target.
1375
- * @see https://polymer-library.polymer-project.org/3.0/docs/devguide/events#retargeting
1376
- */
1377
- _proto.composedPath = function composedPath() {
1378
- if (this.manager && (!this.path || this.path[0] !== this.target)) {
1379
- this.path = this.target ? this.manager.propagationPath(this.target) : [];
1380
- }
1381
-
1382
- return this.path;
1383
- }
1384
- /**
1385
- * @deprecated
1386
- */
1387
- ;
1388
-
1389
- /**
1390
- * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Event/preventDefault
1391
- */
1392
- _proto.preventDefault = function preventDefault() {
1393
- if (this.nativeEvent instanceof Event && this.nativeEvent.cancelable) {
1394
- this.nativeEvent.preventDefault();
1395
- }
1396
-
1397
- this.defaultPrevented = true;
1398
- }
1399
- /**
1400
- * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Event/stopImmediatePropagation
1401
- */
1402
- ;
1403
-
1404
- _proto.stopImmediatePropagation = function stopImmediatePropagation() {
1405
- this.propagationImmediatelyStopped = true;
1406
- }
1407
- /**
1408
- * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Event/stopPropagation
1409
- */
1410
- ;
1411
-
1412
- _proto.stopPropagation = function stopPropagation() {
1413
- this.propagationStopped = true;
1414
- }
1415
- /**
1416
- * @see https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/view
1417
- */
1418
- ;
1419
-
1420
- /**
1421
- * added for compatibility with DOM Event,
1422
- * deprecated props and methods
1423
- */
1424
- _proto.initEvent = function initEvent() {};
1425
-
1426
- _proto.initUIEvent = function initUIEvent() {};
1427
-
1428
- _createClass(FederatedEvent, [{
1429
- key: "name",
1430
- get:
1431
- /**
1432
- * The type of event, supports the following:
1433
- * * pointerdown
1434
- * * touchstart
1435
- * * mousedown
1436
- * * rightdown
1437
- * * ...
1438
- */
1439
-
1440
- /**
1441
- * @deprecated
1442
- */
1443
- function get() {
1444
- return this.type;
1445
- }
1446
- /**
1447
- * The propagation phase.
1448
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Event/eventPhase
1449
- */
1450
-
1451
- }, {
1452
- key: "layerX",
1453
- get: function get() {
1454
- return this.layer.x;
1455
- }
1456
- }, {
1457
- key: "layerY",
1458
- get: function get() {
1459
- return this.layer.y;
1460
- }
1461
- /**
1462
- * The coordinates of the event relative to the DOM document.
1463
- * This is a non-standard property.
1464
- * relative to the DOM document.
1465
- * @see https://developer.mozilla.org/zh-CN/docs/Web/API/MouseEvent/pageX
1466
- */
1467
-
1468
- }, {
1469
- key: "pageX",
1470
- get: function get() {
1471
- return this.page.x;
1472
- }
1473
- }, {
1474
- key: "pageY",
1475
- get: function get() {
1476
- return this.page.y;
1477
- }
1478
- /**
1479
- * relative to Canvas, origin is left-top
1480
- */
1481
-
1482
- }, {
1483
- key: "x",
1484
- get: function get() {
1485
- return this.canvas.x;
1486
- }
1487
- }, {
1488
- key: "y",
1489
- get: function get() {
1490
- return this.canvas.y;
1491
- }
1492
- }, {
1493
- key: "canvasX",
1494
- get: function get() {
1495
- return this.canvas.x;
1496
- }
1497
- }, {
1498
- key: "canvasY",
1499
- get: function get() {
1500
- return this.canvas.y;
1501
- }
1502
- /**
1503
- * relative to Viewport, account for Camera
1504
- */
1505
-
1506
- }, {
1507
- key: "viewportX",
1508
- get: function get() {
1509
- return this.viewport.x;
1510
- }
1511
- }, {
1512
- key: "viewportY",
1513
- get: function get() {
1514
- return this.viewport.y;
1515
- }
1516
- }, {
1517
- key: "propagationPath",
1518
- get: function get() {
1519
- return this.composedPath();
1520
- }
1521
- }]);
1522
-
1523
- return FederatedEvent;
1524
- }();
1525
-
1526
- var MutationEvent = /*#__PURE__*/function (_FederatedEvent) {
1527
- _inheritsLoose(MutationEvent, _FederatedEvent);
1528
-
1529
- function MutationEvent(typeArg, relatedNode, prevValue, newValue, attrName, attrChange, prevParsedValue, newParsedValue) {
1530
- var _this;
1531
-
1532
- _this = _FederatedEvent.call(this, null) || this;
1533
- _this.relatedNode = void 0;
1534
- _this.prevValue = void 0;
1535
- _this.newValue = void 0;
1536
- _this.attrName = void 0;
1537
- _this.attrChange = void 0;
1538
- _this.prevParsedValue = void 0;
1539
- _this.newParsedValue = void 0;
1540
- _this.relatedNode = relatedNode;
1541
- _this.prevValue = prevValue;
1542
- _this.newValue = newValue;
1543
- _this.attrName = attrName;
1544
- _this.attrChange = attrChange;
1545
- _this.prevParsedValue = prevParsedValue;
1546
- _this.newParsedValue = newParsedValue;
1547
- _this.type = typeArg;
1548
- return _this;
1549
- }
1550
-
1551
- return MutationEvent;
1552
- }(FederatedEvent);
1553
- MutationEvent.ADDITION = 2;
1554
- MutationEvent.MODIFICATION = 1;
1555
- MutationEvent.REMOVAL = 3;
1556
-
1557
1169
  function DCHECK(bool) {
1558
1170
  if (!bool) {
1559
1171
  throw new Error();
@@ -2414,39 +2026,298 @@ var PropertySyntax;
2414
2026
  * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#percentage
2415
2027
  */
2416
2028
 
2417
- PropertySyntax["PERCENTAGE"] = "<percentage>";
2418
- PropertySyntax["LENGTH_PERCENTAGE"] = "<length> | <percentage>";
2419
- PropertySyntax["LENGTH_PERCENTAGE_12"] = "[<length> | <percentage>]{1,2}";
2420
- /**
2421
- * @see https://developer.mozilla.org/en-US/docs/Web/CSS/margin#formal_syntax
2422
- */
2029
+ PropertySyntax["PERCENTAGE"] = "<percentage>";
2030
+ PropertySyntax["LENGTH_PERCENTAGE"] = "<length> | <percentage>";
2031
+ PropertySyntax["LENGTH_PERCENTAGE_12"] = "[<length> | <percentage>]{1,2}";
2032
+ /**
2033
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/margin#formal_syntax
2034
+ */
2035
+
2036
+ PropertySyntax["LENGTH_PERCENTAGE_14"] = "[<length> | <percentage>]{1,4}";
2037
+ /**
2038
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#list-of-ts
2039
+ */
2040
+
2041
+ PropertySyntax["LIST_OF_POINTS"] = "<list-of-points>";
2042
+ PropertySyntax["PATH"] = "<path>";
2043
+ /**
2044
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/filter#formal_syntax
2045
+ */
2046
+
2047
+ PropertySyntax["FILTER"] = "<filter>";
2048
+ PropertySyntax["Z_INDEX"] = "<z-index>";
2049
+ PropertySyntax["OFFSET_PATH"] = "<offset-path>";
2050
+ PropertySyntax["OFFSET_DISTANCE"] = "<offset-distance>";
2051
+ PropertySyntax["CLIP_PATH"] = "<clip-path>";
2052
+ PropertySyntax["TRANSFORM"] = "<transform>";
2053
+ PropertySyntax["TRANSFORM_ORIGIN"] = "<transform-origin>";
2054
+ PropertySyntax["TEXT"] = "<text>";
2055
+ PropertySyntax["TEXT_TRANSFORM"] = "<text-transform>";
2056
+ })(PropertySyntax || (PropertySyntax = {}));
2057
+
2058
+ var StyleValueRegistry = Syringe.defineToken('StyleValueRegistry');
2059
+
2060
+ var GeometryUpdaterFactory = Syringe.defineToken('GeometryUpdaterFactory');
2061
+ var GeometryAABBUpdater = Syringe.defineToken('GeometryAABBUpdater');
2062
+
2063
+ /**
2064
+ * built-in events for element
2065
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationEvent
2066
+ *
2067
+ * TODO: use MutationObserver instead
2068
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
2069
+ */
2070
+ var ElementEvent;
2071
+
2072
+ (function (ElementEvent) {
2073
+ ElementEvent["DESTROY"] = "destroy";
2074
+ /**
2075
+ * @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMAttrModified
2076
+ */
2077
+
2078
+ ElementEvent["ATTR_MODIFIED"] = "DOMAttrModified";
2079
+ /**
2080
+ * it has been inserted
2081
+ * @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMNodeInserted
2082
+ */
2083
+
2084
+ ElementEvent["INSERTED"] = "DOMNodeInserted";
2085
+ /**
2086
+ * it has had a child inserted
2087
+ */
2088
+
2089
+ ElementEvent["CHILD_INSERTED"] = "child-inserted";
2090
+ /**
2091
+ * it is being removed
2092
+ * @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMNodeRemoved
2093
+ */
2094
+
2095
+ ElementEvent["REMOVED"] = "removed";
2096
+ /**
2097
+ * it has had a child removed
2098
+ */
2099
+
2100
+ ElementEvent["CHILD_REMOVED"] = "child-removed";
2101
+ /**
2102
+ * @see https://www.w3.org/TR/DOM-Level-3-Events/#domnodeinsertedintodocument
2103
+ */
2104
+
2105
+ ElementEvent["MOUNTED"] = "DOMNodeInsertedIntoDocument";
2106
+ /**
2107
+ * @see https://www.w3.org/TR/DOM-Level-3-Events/#domnoderemovedfromdocument
2108
+ */
2109
+
2110
+ ElementEvent["UNMOUNTED"] = "DOMNodeRemovedFromDocument";
2111
+ ElementEvent["BOUNDS_CHANGED"] = "bounds-changed";
2112
+ ElementEvent["GEOMETRY_BOUNDS_CHANGED"] = "geometry-bounds-changed";
2113
+ /**
2114
+ * trigger when z-index changed
2115
+ */
2116
+
2117
+ ElementEvent["RENDER_ORDER_CHANGED"] = "render-order-changed";
2118
+ })(ElementEvent || (ElementEvent = {}));
2119
+
2120
+ /**
2121
+ * An DOM-compatible synthetic event implementation that is "forwarded" on behalf of an original
2122
+ * FederatedEvent or native {@link https://dom.spec.whatwg.org/#event Event}.
2123
+ */
2124
+
2125
+ var FederatedEvent = /*#__PURE__*/function () {
2126
+ /**
2127
+ * The event boundary which manages this event. Propagation can only occur
2128
+ * within the boundary's jurisdiction.
2129
+ */
2130
+ function FederatedEvent(manager) {
2131
+ this.type = void 0;
2132
+ this.eventPhase = FederatedEvent.prototype.NONE;
2133
+ this.target = void 0;
2134
+ this.bubbles = true;
2135
+ this.cancelBubble = true;
2136
+ this.cancelable = false;
2137
+ this.currentTarget = void 0;
2138
+ this.defaultPrevented = false;
2139
+ this.timeStamp = void 0;
2140
+ this.nativeEvent = void 0;
2141
+ this.originalEvent = void 0;
2142
+ this.propagationStopped = false;
2143
+ this.propagationImmediatelyStopped = false;
2144
+ this.manager = void 0;
2145
+ this.detail = void 0;
2146
+ this.layer = new Point();
2147
+ this.page = new Point();
2148
+ this.canvas = new Point();
2149
+ this.viewport = new Point();
2150
+ this.path = void 0;
2151
+ this.view = void 0;
2152
+ this.which = void 0;
2153
+ this.returnValue = void 0;
2154
+ this.srcElement = void 0;
2155
+ this.composed = false;
2156
+ this.isTrusted = void 0;
2157
+ this.NONE = 0;
2158
+ this.CAPTURING_PHASE = 1;
2159
+ this.AT_TARGET = 2;
2160
+ this.BUBBLING_PHASE = 3;
2161
+ this.manager = manager;
2162
+ }
2163
+
2164
+ var _proto = FederatedEvent.prototype;
2165
+
2166
+ /**
2167
+ * The propagation path for this event
2168
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Event/composedPath
2169
+ *
2170
+ * So composedPath()[0] represents the original target.
2171
+ * @see https://polymer-library.polymer-project.org/3.0/docs/devguide/events#retargeting
2172
+ */
2173
+ _proto.composedPath = function composedPath() {
2174
+ if (this.manager && (!this.path || this.path[0] !== this.target)) {
2175
+ this.path = this.target ? this.manager.propagationPath(this.target) : [];
2176
+ }
2177
+
2178
+ return this.path;
2179
+ }
2180
+ /**
2181
+ * @deprecated
2182
+ */
2183
+ ;
2184
+
2185
+ /**
2186
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Event/preventDefault
2187
+ */
2188
+ _proto.preventDefault = function preventDefault() {
2189
+ if (this.nativeEvent instanceof Event && this.nativeEvent.cancelable) {
2190
+ this.nativeEvent.preventDefault();
2191
+ }
2192
+
2193
+ this.defaultPrevented = true;
2194
+ }
2195
+ /**
2196
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Event/stopImmediatePropagation
2197
+ */
2198
+ ;
2199
+
2200
+ _proto.stopImmediatePropagation = function stopImmediatePropagation() {
2201
+ this.propagationImmediatelyStopped = true;
2202
+ }
2203
+ /**
2204
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Event/stopPropagation
2205
+ */
2206
+ ;
2207
+
2208
+ _proto.stopPropagation = function stopPropagation() {
2209
+ this.propagationStopped = true;
2210
+ }
2211
+ /**
2212
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/view
2213
+ */
2214
+ ;
2215
+
2216
+ /**
2217
+ * added for compatibility with DOM Event,
2218
+ * deprecated props and methods
2219
+ */
2220
+ _proto.initEvent = function initEvent() {};
2221
+
2222
+ _proto.initUIEvent = function initUIEvent() {};
2223
+
2224
+ _createClass(FederatedEvent, [{
2225
+ key: "name",
2226
+ get:
2227
+ /**
2228
+ * The type of event, supports the following:
2229
+ * * pointerdown
2230
+ * * touchstart
2231
+ * * mousedown
2232
+ * * rightdown
2233
+ * * ...
2234
+ */
2235
+
2236
+ /**
2237
+ * @deprecated
2238
+ */
2239
+ function get() {
2240
+ return this.type;
2241
+ }
2242
+ /**
2243
+ * The propagation phase.
2244
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Event/eventPhase
2245
+ */
2423
2246
 
2424
- PropertySyntax["LENGTH_PERCENTAGE_14"] = "[<length> | <percentage>]{1,4}";
2425
- /**
2426
- * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#list-of-ts
2427
- */
2247
+ }, {
2248
+ key: "layerX",
2249
+ get: function get() {
2250
+ return this.layer.x;
2251
+ }
2252
+ }, {
2253
+ key: "layerY",
2254
+ get: function get() {
2255
+ return this.layer.y;
2256
+ }
2257
+ /**
2258
+ * The coordinates of the event relative to the DOM document.
2259
+ * This is a non-standard property.
2260
+ * relative to the DOM document.
2261
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/MouseEvent/pageX
2262
+ */
2428
2263
 
2429
- PropertySyntax["LIST_OF_POINTS"] = "<list-of-points>";
2430
- PropertySyntax["PATH"] = "<path>";
2431
- /**
2432
- * @see https://developer.mozilla.org/en-US/docs/Web/CSS/filter#formal_syntax
2433
- */
2264
+ }, {
2265
+ key: "pageX",
2266
+ get: function get() {
2267
+ return this.page.x;
2268
+ }
2269
+ }, {
2270
+ key: "pageY",
2271
+ get: function get() {
2272
+ return this.page.y;
2273
+ }
2274
+ /**
2275
+ * relative to Canvas, origin is left-top
2276
+ */
2434
2277
 
2435
- PropertySyntax["FILTER"] = "<filter>";
2436
- PropertySyntax["Z_INDEX"] = "<z-index>";
2437
- PropertySyntax["OFFSET_PATH"] = "<offset-path>";
2438
- PropertySyntax["OFFSET_DISTANCE"] = "<offset-distance>";
2439
- PropertySyntax["CLIP_PATH"] = "<clip-path>";
2440
- PropertySyntax["TRANSFORM"] = "<transform>";
2441
- PropertySyntax["TRANSFORM_ORIGIN"] = "<transform-origin>";
2442
- PropertySyntax["TEXT"] = "<text>";
2443
- PropertySyntax["TEXT_TRANSFORM"] = "<text-transform>";
2444
- })(PropertySyntax || (PropertySyntax = {}));
2278
+ }, {
2279
+ key: "x",
2280
+ get: function get() {
2281
+ return this.canvas.x;
2282
+ }
2283
+ }, {
2284
+ key: "y",
2285
+ get: function get() {
2286
+ return this.canvas.y;
2287
+ }
2288
+ }, {
2289
+ key: "canvasX",
2290
+ get: function get() {
2291
+ return this.canvas.x;
2292
+ }
2293
+ }, {
2294
+ key: "canvasY",
2295
+ get: function get() {
2296
+ return this.canvas.y;
2297
+ }
2298
+ /**
2299
+ * relative to Viewport, account for Camera
2300
+ */
2445
2301
 
2446
- var StyleValueRegistry = Syringe.defineToken('StyleValueRegistry');
2302
+ }, {
2303
+ key: "viewportX",
2304
+ get: function get() {
2305
+ return this.viewport.x;
2306
+ }
2307
+ }, {
2308
+ key: "viewportY",
2309
+ get: function get() {
2310
+ return this.viewport.y;
2311
+ }
2312
+ }, {
2313
+ key: "propagationPath",
2314
+ get: function get() {
2315
+ return this.composedPath();
2316
+ }
2317
+ }]);
2447
2318
 
2448
- var GeometryUpdaterFactory = Syringe.defineToken('GeometryUpdaterFactory');
2449
- var GeometryAABBUpdater = Syringe.defineToken('GeometryAABBUpdater');
2319
+ return FederatedEvent;
2320
+ }();
2450
2321
 
2451
2322
  /**
2452
2323
  * @see https://developer.mozilla.org/en-US/docs/Web/Events/Creating_and_triggering_events
@@ -2991,6 +2862,37 @@ var Sortable = function Sortable() {
2991
2862
  };
2992
2863
  Sortable.tag = 'c-sortable';
2993
2864
 
2865
+ var MutationEvent = /*#__PURE__*/function (_FederatedEvent) {
2866
+ _inheritsLoose(MutationEvent, _FederatedEvent);
2867
+
2868
+ function MutationEvent(typeArg, relatedNode, prevValue, newValue, attrName, attrChange, prevParsedValue, newParsedValue) {
2869
+ var _this;
2870
+
2871
+ _this = _FederatedEvent.call(this, null) || this;
2872
+ _this.relatedNode = void 0;
2873
+ _this.prevValue = void 0;
2874
+ _this.newValue = void 0;
2875
+ _this.attrName = void 0;
2876
+ _this.attrChange = void 0;
2877
+ _this.prevParsedValue = void 0;
2878
+ _this.newParsedValue = void 0;
2879
+ _this.relatedNode = relatedNode;
2880
+ _this.prevValue = prevValue;
2881
+ _this.newValue = newValue;
2882
+ _this.attrName = attrName;
2883
+ _this.attrChange = attrChange;
2884
+ _this.prevParsedValue = prevParsedValue;
2885
+ _this.newParsedValue = newParsedValue;
2886
+ _this.type = typeArg;
2887
+ return _this;
2888
+ }
2889
+
2890
+ return MutationEvent;
2891
+ }(FederatedEvent);
2892
+ MutationEvent.ADDITION = 2;
2893
+ MutationEvent.MODIFICATION = 1;
2894
+ MutationEvent.REMOVAL = 3;
2895
+
2994
2896
  var entityCounter = 0;
2995
2897
  /**
2996
2898
  * Has following capabilities:
@@ -3149,6 +3051,24 @@ var Element = /*#__PURE__*/function (_Node) {
3149
3051
  _proto.querySelectorAll = function querySelectorAll(selectors) {
3150
3052
  return this.sceneGraphService.querySelectorAll(selectors, this);
3151
3053
  }
3054
+ /**
3055
+ * should traverses the element and its parents (heading toward the document root)
3056
+ * until it finds a node that matches the specified CSS selector.
3057
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/closest
3058
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/closest#polyfill
3059
+ */
3060
+ ;
3061
+
3062
+ _proto.closest = function closest(selectors) {
3063
+ var el = this;
3064
+
3065
+ do {
3066
+ if (this.sceneGraphService.matches(selectors, el)) return el;
3067
+ el = el.parentElement;
3068
+ } while (el !== null);
3069
+
3070
+ return null;
3071
+ }
3152
3072
  /**
3153
3073
  * search in scene group, but should not include itself
3154
3074
  */
@@ -15067,6 +14987,159 @@ function toFontString(attributes) {
15067
14987
  return fontStyle + " " + fontVariant + " " + fontWeight + " " + fontSizeString + " " + fontFamilies.join(',');
15068
14988
  }
15069
14989
 
14990
+ var SceneGraphSelectorFactory = Syringe.defineToken('SceneGraphSelectorFactory');
14991
+ var SceneGraphSelector = Syringe.defineToken('SceneGraphSelector', {
14992
+ multiple: false
14993
+ });
14994
+ var ATTRIBUTE_REGEXP = /\[\s*(.*)=(.*)\s*\]/;
14995
+ /**
14996
+ * support the following DOM API:
14997
+ * * getElementById
14998
+ * * getElementsByClassName
14999
+ * * getElementsByName
15000
+ * * getElementsByTag
15001
+ * * querySelector
15002
+ * * querySelectorAll
15003
+ */
15004
+
15005
+ var DefaultSceneGraphSelector = /*#__PURE__*/function () {
15006
+ function DefaultSceneGraphSelector() {}
15007
+
15008
+ var _proto = DefaultSceneGraphSelector.prototype;
15009
+
15010
+ _proto.selectOne = function selectOne(query, root) {
15011
+ var _this = this;
15012
+
15013
+ if (query.startsWith('.')) {
15014
+ return root.find(function (node) {
15015
+ // return !node.shadow && node.id === query.substring(1);
15016
+ return node.className === _this.getIdOrClassname(query);
15017
+ });
15018
+ } else if (query.startsWith('#')) {
15019
+ // getElementById('id')
15020
+ return root.find(function (node) {
15021
+ // return !node.shadow && node.id === query.substring(1);
15022
+ return node.id === _this.getIdOrClassname(query);
15023
+ });
15024
+ } else if (query.startsWith('[')) {
15025
+ var _this$getAttribute = this.getAttribute(query),
15026
+ name = _this$getAttribute.name,
15027
+ value = _this$getAttribute.value;
15028
+
15029
+ if (name) {
15030
+ // getElementByName();
15031
+ return root.find(function (node) {
15032
+ return root !== node && (name === 'name' ? node.name === value : _this.attributeToString(node, name) === value);
15033
+ });
15034
+ } else {
15035
+ return null;
15036
+ }
15037
+ } else {
15038
+ // getElementsByTag('circle');
15039
+ return root.find(function (node) {
15040
+ return root !== node && node.nodeName === query;
15041
+ });
15042
+ }
15043
+ };
15044
+
15045
+ _proto.selectAll = function selectAll(query, root) {
15046
+ var _this2 = this;
15047
+
15048
+ // only support `[name="${name}"]` `.className` `#id`
15049
+ if (query.startsWith('.')) {
15050
+ // getElementsByClassName('className');
15051
+ // should not include itself
15052
+ return root.findAll(function (node) {
15053
+ return root !== node && node.className === _this2.getIdOrClassname(query);
15054
+ });
15055
+ } else if (query.startsWith('#')) {
15056
+ return root.findAll(function (node) {
15057
+ return root !== node && node.id === _this2.getIdOrClassname(query);
15058
+ });
15059
+ } else if (query.startsWith('[')) {
15060
+ var _this$getAttribute2 = this.getAttribute(query),
15061
+ name = _this$getAttribute2.name,
15062
+ value = _this$getAttribute2.value;
15063
+
15064
+ if (name) {
15065
+ // getElementsByName();
15066
+ return root.findAll(function (node) {
15067
+ return root !== node && (name === 'name' ? node.name === value : _this2.attributeToString(node, name) === value);
15068
+ });
15069
+ } else {
15070
+ return [];
15071
+ }
15072
+ } else {
15073
+ // getElementsByTag('circle');
15074
+ return root.findAll(function (node) {
15075
+ return root !== node && node.nodeName === query;
15076
+ });
15077
+ }
15078
+ } // eslint-disable-next-line @typescript-eslint/no-unused-vars
15079
+ ;
15080
+
15081
+ _proto.is = function is(query, node) {
15082
+ // a simple `matches` implementation
15083
+ if (query.startsWith('.')) {
15084
+ return node.className === this.getIdOrClassname(query);
15085
+ } else if (query.startsWith('#')) {
15086
+ return node.id === this.getIdOrClassname(query);
15087
+ } else if (query.startsWith('[')) {
15088
+ var _this$getAttribute3 = this.getAttribute(query),
15089
+ name = _this$getAttribute3.name,
15090
+ value = _this$getAttribute3.value;
15091
+
15092
+ return name === 'name' ? node.name === value : this.attributeToString(node, name) === value;
15093
+ } else {
15094
+ return node.nodeName === query;
15095
+ }
15096
+ };
15097
+
15098
+ _proto.getIdOrClassname = function getIdOrClassname(query) {
15099
+ return query.substring(1);
15100
+ };
15101
+
15102
+ _proto.getAttribute = function getAttribute(query) {
15103
+ var matches = query.match(ATTRIBUTE_REGEXP);
15104
+ var name = '';
15105
+ var value = '';
15106
+
15107
+ if (matches && matches.length > 2) {
15108
+ name = matches[1].replace(/"/g, '');
15109
+ value = matches[2].replace(/"/g, '');
15110
+ }
15111
+
15112
+ return {
15113
+ name: name,
15114
+ value: value
15115
+ };
15116
+ };
15117
+
15118
+ _proto.attributeToString = function attributeToString(node, name) {
15119
+ if (!node.getAttribute) {
15120
+ return '';
15121
+ }
15122
+
15123
+ var value = node.getAttribute(name);
15124
+
15125
+ if (isNil(value)) {
15126
+ return '';
15127
+ }
15128
+
15129
+ if (value.toString) {
15130
+ return value.toString();
15131
+ }
15132
+
15133
+ return '';
15134
+ };
15135
+
15136
+ return DefaultSceneGraphSelector;
15137
+ }();
15138
+
15139
+ DefaultSceneGraphSelector = __decorate([singleton({
15140
+ token: SceneGraphSelector
15141
+ })], DefaultSceneGraphSelector);
15142
+
15070
15143
  function sortByZIndex(o1, o2) {
15071
15144
  var zIndex1 = Number(o1.style.zIndex);
15072
15145
  var zIndex2 = Number(o2.style.zIndex);
@@ -19867,7 +19940,7 @@ var EventPlugin = EventPlugin_1 = (_class$4 = /*#__PURE__*/function () {
19867
19940
  var _this$renderingContex, _this$renderingContex2;
19868
19941
 
19869
19942
  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;
19870
- if (canvas.supportTouchEvent && nativeEvent.pointerType === 'touch') return;
19943
+ if (canvas.supportsTouchEvents && nativeEvent.pointerType === 'touch') return;
19871
19944
 
19872
19945
  var normalizedEvents = _this.normalizeToPointerEvent(nativeEvent, canvas);
19873
19946
 
@@ -19928,6 +20001,8 @@ var EventPlugin = EventPlugin_1 = (_class$4 = /*#__PURE__*/function () {
19928
20001
  _this2.eventService.mapEvent(wheelEvent);
19929
20002
  });
19930
20003
  renderingService.hooks.pointerDown.tap(EventPlugin_1.tag, function (nativeEvent) {
20004
+ if (canvas.supportsTouchEvents && nativeEvent.pointerType === 'touch') return;
20005
+
19931
20006
  var events = _this2.normalizeToPointerEvent(nativeEvent, canvas);
19932
20007
 
19933
20008
  if (_this2.autoPreventDefault && events[0].isNormalized) {
@@ -19949,7 +20024,7 @@ var EventPlugin = EventPlugin_1 = (_class$4 = /*#__PURE__*/function () {
19949
20024
  _this2.setCursor(_this2.eventService.cursor);
19950
20025
  });
19951
20026
  renderingService.hooks.pointerUp.tap(EventPlugin_1.tag, function (nativeEvent) {
19952
- if (canvas.supportTouchEvent && nativeEvent.pointerType === 'touch') return; // account for element in SVG
20027
+ if (canvas.supportsTouchEvents && nativeEvent.pointerType === 'touch') return; // account for element in SVG
19953
20028
 
19954
20029
  var $element = _this2.contextService.getDomElement();
19955
20030
 
@@ -19973,24 +20048,7 @@ var EventPlugin = EventPlugin_1 = (_class$4 = /*#__PURE__*/function () {
19973
20048
  });
19974
20049
  renderingService.hooks.pointerMove.tap(EventPlugin_1.tag, this.onPointerMove);
19975
20050
  renderingService.hooks.pointerOver.tap(EventPlugin_1.tag, this.onPointerMove);
19976
- renderingService.hooks.pointerOut.tap(EventPlugin_1.tag, this.onPointerMove); // renderingService.hooks.pointerCancel.tap(
19977
- // EventPlugin.tag,
19978
- // (nativeEvent: InteractivePointerEvent) => {
19979
- // if (canvas.supportTouchEvent && (nativeEvent as PointerEvent).pointerType === 'touch') {
19980
- // return;
19981
- // }
19982
- // const normalizedEvent = this.normalizeToPointerEvent(nativeEvent, canvas);
19983
- // if (this.autoPreventDefault && (normalizedEvent as any).isNormalized) {
19984
- // const cancelable = nativeEvent.cancelable || !('cancelable' in nativeEvent);
19985
- // if (cancelable) {
19986
- // nativeEvent.preventDefault();
19987
- // }
19988
- // }
19989
- // const federatedEvent = this.bootstrapEvent(this.rootPointerEvent, normalizedEvent, canvas);
19990
- // this.eventService.mapEvent(federatedEvent);
19991
- // this.setCursor(this.eventService.cursor);
19992
- // },
19993
- // );
20051
+ renderingService.hooks.pointerOut.tap(EventPlugin_1.tag, this.onPointerMove);
19994
20052
  };
19995
20053
 
19996
20054
  _proto.bootstrapEvent = function bootstrapEvent(e, nativeEvent, view) {
@@ -20271,8 +20329,8 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
20271
20329
  _this.requestAnimationFrame = void 0;
20272
20330
  _this.cancelAnimationFrame = void 0;
20273
20331
  _this.devicePixelRatio = void 0;
20274
- _this.supportPointerEvent = void 0;
20275
- _this.supportTouchEvent = void 0;
20332
+ _this.supportsPointerEvents = void 0;
20333
+ _this.supportsTouchEvents = void 0;
20276
20334
  _this.isTouchEvent = void 0;
20277
20335
  _this.isMouseEvent = void 0;
20278
20336
  _this.Element = DisplayObject;
@@ -20297,8 +20355,8 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
20297
20355
  requestAnimationFrame = config.requestAnimationFrame,
20298
20356
  cancelAnimationFrame = config.cancelAnimationFrame,
20299
20357
  createImage = config.createImage,
20300
- supportPointerEvent = config.supportPointerEvent,
20301
- supportTouchEvent = config.supportTouchEvent,
20358
+ supportsPointerEvents = config.supportsPointerEvents,
20359
+ supportsTouchEvents = config.supportsTouchEvents,
20302
20360
  isTouchEvent = config.isTouchEvent,
20303
20361
  isMouseEvent = config.isMouseEvent;
20304
20362
  cleanExistedCanvas(container, _assertThisInitialized(_this));
@@ -20327,13 +20385,13 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
20327
20385
  // the following feature-detect from hammer.js
20328
20386
  // @see https://github.com/hammerjs/hammer.js/blob/master/src/inputjs/input-consts.js#L5
20329
20387
 
20330
- _this.supportTouchEvent = supportTouchEvent !== null && supportTouchEvent !== void 0 ? supportTouchEvent : 'ontouchstart' in globalThis;
20331
- _this.supportPointerEvent = supportPointerEvent !== null && supportPointerEvent !== void 0 ? supportPointerEvent : !!globalThis.PointerEvent;
20388
+ _this.supportsTouchEvents = supportsTouchEvents !== null && supportsTouchEvents !== void 0 ? supportsTouchEvents : 'ontouchstart' in globalThis;
20389
+ _this.supportsPointerEvents = supportsPointerEvents !== null && supportsPointerEvents !== void 0 ? supportsPointerEvents : !!globalThis.PointerEvent;
20332
20390
  _this.isTouchEvent = isTouchEvent !== null && isTouchEvent !== void 0 ? isTouchEvent : function (event) {
20333
- return _this.supportTouchEvent && event instanceof globalThis.TouchEvent;
20391
+ return _this.supportsTouchEvents && event instanceof globalThis.TouchEvent;
20334
20392
  };
20335
20393
  _this.isMouseEvent = isMouseEvent !== null && isMouseEvent !== void 0 ? isMouseEvent : function (event) {
20336
- return !globalThis.MouseEvent || event instanceof globalThis.MouseEvent && (!_this.supportPointerEvent || !(event instanceof globalThis.PointerEvent));
20394
+ return !globalThis.MouseEvent || event instanceof globalThis.MouseEvent && (!_this.supportsPointerEvents || !(event instanceof globalThis.PointerEvent));
20337
20395
  };
20338
20396
 
20339
20397
  _this.initRenderingContext({