@antv/g-canvas 1.9.19 → 1.9.20
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 +240 -120
- package/dist/index.js +240 -120
- package/dist/index.umd.js +2720 -1622
- package/dist/index.umd.min.js +1 -1
- package/package.json +8 -8
package/dist/index.umd.js
CHANGED
|
@@ -305,6 +305,15 @@
|
|
|
305
305
|
}
|
|
306
306
|
}, exports;
|
|
307
307
|
}
|
|
308
|
+
function _typeof(obj) {
|
|
309
|
+
"@babel/helpers - typeof";
|
|
310
|
+
|
|
311
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
312
|
+
return typeof obj;
|
|
313
|
+
} : function (obj) {
|
|
314
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
315
|
+
}, _typeof(obj);
|
|
316
|
+
}
|
|
308
317
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
309
318
|
try {
|
|
310
319
|
var info = gen[key](arg);
|
|
@@ -335,10 +344,49 @@
|
|
|
335
344
|
});
|
|
336
345
|
};
|
|
337
346
|
}
|
|
338
|
-
function
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
347
|
+
function _classCallCheck(instance, Constructor) {
|
|
348
|
+
if (!(instance instanceof Constructor)) {
|
|
349
|
+
throw new TypeError("Cannot call a class as a function");
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
function _defineProperties(target, props) {
|
|
353
|
+
for (var i = 0; i < props.length; i++) {
|
|
354
|
+
var descriptor = props[i];
|
|
355
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
356
|
+
descriptor.configurable = true;
|
|
357
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
358
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
362
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
363
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
364
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
365
|
+
writable: false
|
|
366
|
+
});
|
|
367
|
+
return Constructor;
|
|
368
|
+
}
|
|
369
|
+
function _inherits(subClass, superClass) {
|
|
370
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
371
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
372
|
+
}
|
|
373
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
374
|
+
constructor: {
|
|
375
|
+
value: subClass,
|
|
376
|
+
writable: true,
|
|
377
|
+
configurable: true
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
Object.defineProperty(subClass, "prototype", {
|
|
381
|
+
writable: false
|
|
382
|
+
});
|
|
383
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
384
|
+
}
|
|
385
|
+
function _getPrototypeOf(o) {
|
|
386
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
387
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
388
|
+
};
|
|
389
|
+
return _getPrototypeOf(o);
|
|
342
390
|
}
|
|
343
391
|
function _setPrototypeOf(o, p) {
|
|
344
392
|
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
@@ -347,6 +395,59 @@
|
|
|
347
395
|
};
|
|
348
396
|
return _setPrototypeOf(o, p);
|
|
349
397
|
}
|
|
398
|
+
function _isNativeReflectConstruct() {
|
|
399
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
400
|
+
if (Reflect.construct.sham) return false;
|
|
401
|
+
if (typeof Proxy === "function") return true;
|
|
402
|
+
try {
|
|
403
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
404
|
+
return true;
|
|
405
|
+
} catch (e) {
|
|
406
|
+
return false;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
function _assertThisInitialized(self) {
|
|
410
|
+
if (self === void 0) {
|
|
411
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
412
|
+
}
|
|
413
|
+
return self;
|
|
414
|
+
}
|
|
415
|
+
function _possibleConstructorReturn(self, call) {
|
|
416
|
+
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
417
|
+
return call;
|
|
418
|
+
} else if (call !== void 0) {
|
|
419
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
420
|
+
}
|
|
421
|
+
return _assertThisInitialized(self);
|
|
422
|
+
}
|
|
423
|
+
function _createSuper(Derived) {
|
|
424
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
425
|
+
return function _createSuperInternal() {
|
|
426
|
+
var Super = _getPrototypeOf(Derived),
|
|
427
|
+
result;
|
|
428
|
+
if (hasNativeReflectConstruct) {
|
|
429
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
|
430
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
431
|
+
} else {
|
|
432
|
+
result = Super.apply(this, arguments);
|
|
433
|
+
}
|
|
434
|
+
return _possibleConstructorReturn(this, result);
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
function _toPrimitive(input, hint) {
|
|
438
|
+
if (typeof input !== "object" || input === null) return input;
|
|
439
|
+
var prim = input[Symbol.toPrimitive];
|
|
440
|
+
if (prim !== undefined) {
|
|
441
|
+
var res = prim.call(input, hint || "default");
|
|
442
|
+
if (typeof res !== "object") return res;
|
|
443
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
444
|
+
}
|
|
445
|
+
return (hint === "string" ? String : Number)(input);
|
|
446
|
+
}
|
|
447
|
+
function _toPropertyKey(arg) {
|
|
448
|
+
var key = _toPrimitive(arg, "string");
|
|
449
|
+
return typeof key === "symbol" ? key : String(key);
|
|
450
|
+
}
|
|
350
451
|
|
|
351
452
|
/**
|
|
352
453
|
* Common utilities
|
|
@@ -1183,10 +1284,92 @@
|
|
|
1183
1284
|
return a;
|
|
1184
1285
|
};
|
|
1185
1286
|
|
|
1186
|
-
function
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1287
|
+
function _iterableToArrayLimit(arr, i) {
|
|
1288
|
+
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
|
|
1289
|
+
if (null != _i) {
|
|
1290
|
+
var _s,
|
|
1291
|
+
_e,
|
|
1292
|
+
_x,
|
|
1293
|
+
_r,
|
|
1294
|
+
_arr = [],
|
|
1295
|
+
_n = !0,
|
|
1296
|
+
_d = !1;
|
|
1297
|
+
try {
|
|
1298
|
+
if (_x = (_i = _i.call(arr)).next, 0 === i) {
|
|
1299
|
+
if (Object(_i) !== _i) return;
|
|
1300
|
+
_n = !1;
|
|
1301
|
+
} else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0) {
|
|
1302
|
+
;
|
|
1303
|
+
}
|
|
1304
|
+
} catch (err) {
|
|
1305
|
+
_d = !0, _e = err;
|
|
1306
|
+
} finally {
|
|
1307
|
+
try {
|
|
1308
|
+
if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
|
|
1309
|
+
} finally {
|
|
1310
|
+
if (_d) throw _e;
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
return _arr;
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
function _classCallCheck$1(instance, Constructor) {
|
|
1317
|
+
if (!(instance instanceof Constructor)) {
|
|
1318
|
+
throw new TypeError("Cannot call a class as a function");
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
function _defineProperties$1(target, props) {
|
|
1322
|
+
for (var i = 0; i < props.length; i++) {
|
|
1323
|
+
var descriptor = props[i];
|
|
1324
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
1325
|
+
descriptor.configurable = true;
|
|
1326
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
1327
|
+
Object.defineProperty(target, _toPropertyKey$1(descriptor.key), descriptor);
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
function _createClass$1(Constructor, protoProps, staticProps) {
|
|
1331
|
+
if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
|
|
1332
|
+
if (staticProps) _defineProperties$1(Constructor, staticProps);
|
|
1333
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
1334
|
+
writable: false
|
|
1335
|
+
});
|
|
1336
|
+
return Constructor;
|
|
1337
|
+
}
|
|
1338
|
+
function _defineProperty(obj, key, value) {
|
|
1339
|
+
key = _toPropertyKey$1(key);
|
|
1340
|
+
if (key in obj) {
|
|
1341
|
+
Object.defineProperty(obj, key, {
|
|
1342
|
+
value: value,
|
|
1343
|
+
enumerable: true,
|
|
1344
|
+
configurable: true,
|
|
1345
|
+
writable: true
|
|
1346
|
+
});
|
|
1347
|
+
} else {
|
|
1348
|
+
obj[key] = value;
|
|
1349
|
+
}
|
|
1350
|
+
return obj;
|
|
1351
|
+
}
|
|
1352
|
+
function _inherits$1(subClass, superClass) {
|
|
1353
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
1354
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
1355
|
+
}
|
|
1356
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
1357
|
+
constructor: {
|
|
1358
|
+
value: subClass,
|
|
1359
|
+
writable: true,
|
|
1360
|
+
configurable: true
|
|
1361
|
+
}
|
|
1362
|
+
});
|
|
1363
|
+
Object.defineProperty(subClass, "prototype", {
|
|
1364
|
+
writable: false
|
|
1365
|
+
});
|
|
1366
|
+
if (superClass) _setPrototypeOf$1(subClass, superClass);
|
|
1367
|
+
}
|
|
1368
|
+
function _getPrototypeOf$1(o) {
|
|
1369
|
+
_getPrototypeOf$1 = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
1370
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
1371
|
+
};
|
|
1372
|
+
return _getPrototypeOf$1(o);
|
|
1190
1373
|
}
|
|
1191
1374
|
function _setPrototypeOf$1(o, p) {
|
|
1192
1375
|
_setPrototypeOf$1 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
@@ -1195,6 +1378,83 @@
|
|
|
1195
1378
|
};
|
|
1196
1379
|
return _setPrototypeOf$1(o, p);
|
|
1197
1380
|
}
|
|
1381
|
+
function _isNativeReflectConstruct$1() {
|
|
1382
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
1383
|
+
if (Reflect.construct.sham) return false;
|
|
1384
|
+
if (typeof Proxy === "function") return true;
|
|
1385
|
+
try {
|
|
1386
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
1387
|
+
return true;
|
|
1388
|
+
} catch (e) {
|
|
1389
|
+
return false;
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
function _assertThisInitialized$1(self) {
|
|
1393
|
+
if (self === void 0) {
|
|
1394
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
1395
|
+
}
|
|
1396
|
+
return self;
|
|
1397
|
+
}
|
|
1398
|
+
function _possibleConstructorReturn$1(self, call) {
|
|
1399
|
+
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
1400
|
+
return call;
|
|
1401
|
+
} else if (call !== void 0) {
|
|
1402
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
1403
|
+
}
|
|
1404
|
+
return _assertThisInitialized$1(self);
|
|
1405
|
+
}
|
|
1406
|
+
function _createSuper$1(Derived) {
|
|
1407
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct$1();
|
|
1408
|
+
return function _createSuperInternal() {
|
|
1409
|
+
var Super = _getPrototypeOf$1(Derived),
|
|
1410
|
+
result;
|
|
1411
|
+
if (hasNativeReflectConstruct) {
|
|
1412
|
+
var NewTarget = _getPrototypeOf$1(this).constructor;
|
|
1413
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
1414
|
+
} else {
|
|
1415
|
+
result = Super.apply(this, arguments);
|
|
1416
|
+
}
|
|
1417
|
+
return _possibleConstructorReturn$1(this, result);
|
|
1418
|
+
};
|
|
1419
|
+
}
|
|
1420
|
+
function _slicedToArray(arr, i) {
|
|
1421
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
1422
|
+
}
|
|
1423
|
+
function _arrayWithHoles(arr) {
|
|
1424
|
+
if (Array.isArray(arr)) return arr;
|
|
1425
|
+
}
|
|
1426
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
1427
|
+
if (!o) return;
|
|
1428
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
1429
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1430
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1431
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
1432
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
1433
|
+
}
|
|
1434
|
+
function _arrayLikeToArray(arr, len) {
|
|
1435
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
1436
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
1437
|
+
arr2[i] = arr[i];
|
|
1438
|
+
}
|
|
1439
|
+
return arr2;
|
|
1440
|
+
}
|
|
1441
|
+
function _nonIterableRest() {
|
|
1442
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1443
|
+
}
|
|
1444
|
+
function _toPrimitive$1(input, hint) {
|
|
1445
|
+
if (_typeof(input) !== "object" || input === null) return input;
|
|
1446
|
+
var prim = input[Symbol.toPrimitive];
|
|
1447
|
+
if (prim !== undefined) {
|
|
1448
|
+
var res = prim.call(input, hint || "default");
|
|
1449
|
+
if (_typeof(res) !== "object") return res;
|
|
1450
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1451
|
+
}
|
|
1452
|
+
return (hint === "string" ? String : Number)(input);
|
|
1453
|
+
}
|
|
1454
|
+
function _toPropertyKey$1(arg) {
|
|
1455
|
+
var key = _toPrimitive$1(arg, "string");
|
|
1456
|
+
return _typeof(key) === "symbol" ? key : String(key);
|
|
1457
|
+
}
|
|
1198
1458
|
function generatePath(context, parsedStyle) {
|
|
1199
1459
|
var r = parsedStyle.r;
|
|
1200
1460
|
context.arc(r, r, r, 0, Math.PI * 2, false);
|
|
@@ -1275,8 +1535,9 @@
|
|
|
1275
1535
|
var y;
|
|
1276
1536
|
if (markerStart && markerStart instanceof gLite.DisplayObject && markerStartOffset) {
|
|
1277
1537
|
var _markerStart$parentNo = markerStart.parentNode.getStartTangent(),
|
|
1278
|
-
|
|
1279
|
-
|
|
1538
|
+
_markerStart$parentNo2 = _slicedToArray(_markerStart$parentNo, 2),
|
|
1539
|
+
p1 = _markerStart$parentNo2[0],
|
|
1540
|
+
p2 = _markerStart$parentNo2[1];
|
|
1280
1541
|
x = p1[0] - p2[0];
|
|
1281
1542
|
y = p1[1] - p2[1];
|
|
1282
1543
|
rad = Math.atan2(y, x);
|
|
@@ -1285,8 +1546,9 @@
|
|
|
1285
1546
|
}
|
|
1286
1547
|
if (markerEnd && markerEnd instanceof gLite.DisplayObject && markerEndOffset) {
|
|
1287
1548
|
var _markerEnd$parentNode = markerEnd.parentNode.getEndTangent(),
|
|
1288
|
-
|
|
1289
|
-
|
|
1549
|
+
_markerEnd$parentNode2 = _slicedToArray(_markerEnd$parentNode, 2),
|
|
1550
|
+
_p = _markerEnd$parentNode2[0],
|
|
1551
|
+
_p2 = _markerEnd$parentNode2[1];
|
|
1290
1552
|
x = _p[0] - _p2[0];
|
|
1291
1553
|
y = _p[1] - _p2[1];
|
|
1292
1554
|
rad = Math.atan2(y, x);
|
|
@@ -1471,10 +1733,11 @@
|
|
|
1471
1733
|
var _radius$map = radius.map(function (r) {
|
|
1472
1734
|
return clamp(r, 0, Math.min(Math.abs(w) / 2, Math.abs(h) / 2));
|
|
1473
1735
|
}),
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1736
|
+
_radius$map2 = _slicedToArray(_radius$map, 4),
|
|
1737
|
+
tlr = _radius$map2[0],
|
|
1738
|
+
trr = _radius$map2[1],
|
|
1739
|
+
brr = _radius$map2[2],
|
|
1740
|
+
blr = _radius$map2[3];
|
|
1478
1741
|
context.moveTo(signX * tlr, 0);
|
|
1479
1742
|
context.lineTo(w - signX * trr, 0);
|
|
1480
1743
|
if (trr !== 0) {
|
|
@@ -1495,27 +1758,33 @@
|
|
|
1495
1758
|
}
|
|
1496
1759
|
}
|
|
1497
1760
|
var Plugin = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
1498
|
-
|
|
1761
|
+
_inherits$1(Plugin, _AbstractRendererPlug);
|
|
1762
|
+
var _super = _createSuper$1(Plugin);
|
|
1499
1763
|
function Plugin() {
|
|
1500
1764
|
var _this;
|
|
1765
|
+
_classCallCheck$1(this, Plugin);
|
|
1501
1766
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1502
1767
|
args[_key] = arguments[_key];
|
|
1503
1768
|
}
|
|
1504
|
-
_this =
|
|
1769
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
1505
1770
|
_this.name = 'canvas-path-generator';
|
|
1506
1771
|
return _this;
|
|
1507
1772
|
}
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1773
|
+
_createClass$1(Plugin, [{
|
|
1774
|
+
key: "init",
|
|
1775
|
+
value: function init() {
|
|
1776
|
+
var _pathGeneratorFactory;
|
|
1777
|
+
var pathGeneratorFactory = (_pathGeneratorFactory = {}, _defineProperty(_pathGeneratorFactory, gLite.Shape.CIRCLE, generatePath), _defineProperty(_pathGeneratorFactory, gLite.Shape.ELLIPSE, generatePath$1), _defineProperty(_pathGeneratorFactory, gLite.Shape.RECT, generatePath$6), _defineProperty(_pathGeneratorFactory, gLite.Shape.LINE, generatePath$2), _defineProperty(_pathGeneratorFactory, gLite.Shape.POLYLINE, generatePath$5), _defineProperty(_pathGeneratorFactory, gLite.Shape.POLYGON, generatePath$4), _defineProperty(_pathGeneratorFactory, gLite.Shape.PATH, generatePath$3), _defineProperty(_pathGeneratorFactory, gLite.Shape.TEXT, undefined), _defineProperty(_pathGeneratorFactory, gLite.Shape.GROUP, undefined), _defineProperty(_pathGeneratorFactory, gLite.Shape.IMAGE, undefined), _defineProperty(_pathGeneratorFactory, gLite.Shape.HTML, undefined), _defineProperty(_pathGeneratorFactory, gLite.Shape.MESH, undefined), _pathGeneratorFactory);
|
|
1778
|
+
// @ts-ignore
|
|
1779
|
+
this.context.pathGeneratorFactory = pathGeneratorFactory;
|
|
1780
|
+
}
|
|
1781
|
+
}, {
|
|
1782
|
+
key: "destroy",
|
|
1783
|
+
value: function destroy() {
|
|
1784
|
+
// @ts-ignore
|
|
1785
|
+
delete this.context.pathGeneratorFactory;
|
|
1786
|
+
}
|
|
1787
|
+
}]);
|
|
1519
1788
|
return Plugin;
|
|
1520
1789
|
}(gLite.AbstractRendererPlugin);
|
|
1521
1790
|
|
|
@@ -1524,6 +1793,35 @@
|
|
|
1524
1793
|
Plugin: Plugin
|
|
1525
1794
|
});
|
|
1526
1795
|
|
|
1796
|
+
function _iterableToArrayLimit$1(arr, i) {
|
|
1797
|
+
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
|
|
1798
|
+
if (null != _i) {
|
|
1799
|
+
var _s,
|
|
1800
|
+
_e,
|
|
1801
|
+
_x,
|
|
1802
|
+
_r,
|
|
1803
|
+
_arr = [],
|
|
1804
|
+
_n = !0,
|
|
1805
|
+
_d = !1;
|
|
1806
|
+
try {
|
|
1807
|
+
if (_x = (_i = _i.call(arr)).next, 0 === i) {
|
|
1808
|
+
if (Object(_i) !== _i) return;
|
|
1809
|
+
_n = !1;
|
|
1810
|
+
} else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0) {
|
|
1811
|
+
;
|
|
1812
|
+
}
|
|
1813
|
+
} catch (err) {
|
|
1814
|
+
_d = !0, _e = err;
|
|
1815
|
+
} finally {
|
|
1816
|
+
try {
|
|
1817
|
+
if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
|
|
1818
|
+
} finally {
|
|
1819
|
+
if (_d) throw _e;
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
return _arr;
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1527
1825
|
function _regeneratorRuntime$1() {
|
|
1528
1826
|
_regeneratorRuntime$1 = function _regeneratorRuntime() {
|
|
1529
1827
|
return exports;
|
|
@@ -1600,7 +1898,7 @@
|
|
|
1600
1898
|
if ("throw" !== record.type) {
|
|
1601
1899
|
var result = record.arg,
|
|
1602
1900
|
value = result.value;
|
|
1603
|
-
return value && "object" ==
|
|
1901
|
+
return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
1604
1902
|
invoke("next", value, resolve, reject);
|
|
1605
1903
|
}, function (err) {
|
|
1606
1904
|
invoke("throw", err, resolve, reject);
|
|
@@ -1861,10 +2159,63 @@
|
|
|
1861
2159
|
});
|
|
1862
2160
|
};
|
|
1863
2161
|
}
|
|
1864
|
-
function
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
2162
|
+
function _classCallCheck$2(instance, Constructor) {
|
|
2163
|
+
if (!(instance instanceof Constructor)) {
|
|
2164
|
+
throw new TypeError("Cannot call a class as a function");
|
|
2165
|
+
}
|
|
2166
|
+
}
|
|
2167
|
+
function _defineProperties$2(target, props) {
|
|
2168
|
+
for (var i = 0; i < props.length; i++) {
|
|
2169
|
+
var descriptor = props[i];
|
|
2170
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
2171
|
+
descriptor.configurable = true;
|
|
2172
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
2173
|
+
Object.defineProperty(target, _toPropertyKey$2(descriptor.key), descriptor);
|
|
2174
|
+
}
|
|
2175
|
+
}
|
|
2176
|
+
function _createClass$2(Constructor, protoProps, staticProps) {
|
|
2177
|
+
if (protoProps) _defineProperties$2(Constructor.prototype, protoProps);
|
|
2178
|
+
if (staticProps) _defineProperties$2(Constructor, staticProps);
|
|
2179
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
2180
|
+
writable: false
|
|
2181
|
+
});
|
|
2182
|
+
return Constructor;
|
|
2183
|
+
}
|
|
2184
|
+
function _defineProperty$1(obj, key, value) {
|
|
2185
|
+
key = _toPropertyKey$2(key);
|
|
2186
|
+
if (key in obj) {
|
|
2187
|
+
Object.defineProperty(obj, key, {
|
|
2188
|
+
value: value,
|
|
2189
|
+
enumerable: true,
|
|
2190
|
+
configurable: true,
|
|
2191
|
+
writable: true
|
|
2192
|
+
});
|
|
2193
|
+
} else {
|
|
2194
|
+
obj[key] = value;
|
|
2195
|
+
}
|
|
2196
|
+
return obj;
|
|
2197
|
+
}
|
|
2198
|
+
function _inherits$2(subClass, superClass) {
|
|
2199
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
2200
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
2201
|
+
}
|
|
2202
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
2203
|
+
constructor: {
|
|
2204
|
+
value: subClass,
|
|
2205
|
+
writable: true,
|
|
2206
|
+
configurable: true
|
|
2207
|
+
}
|
|
2208
|
+
});
|
|
2209
|
+
Object.defineProperty(subClass, "prototype", {
|
|
2210
|
+
writable: false
|
|
2211
|
+
});
|
|
2212
|
+
if (superClass) _setPrototypeOf$2(subClass, superClass);
|
|
2213
|
+
}
|
|
2214
|
+
function _getPrototypeOf$2(o) {
|
|
2215
|
+
_getPrototypeOf$2 = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
2216
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
2217
|
+
};
|
|
2218
|
+
return _getPrototypeOf$2(o);
|
|
1868
2219
|
}
|
|
1869
2220
|
function _setPrototypeOf$2(o, p) {
|
|
1870
2221
|
_setPrototypeOf$2 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
@@ -1873,38 +2224,133 @@
|
|
|
1873
2224
|
};
|
|
1874
2225
|
return _setPrototypeOf$2(o, p);
|
|
1875
2226
|
}
|
|
1876
|
-
function
|
|
2227
|
+
function _isNativeReflectConstruct$2() {
|
|
2228
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
2229
|
+
if (Reflect.construct.sham) return false;
|
|
2230
|
+
if (typeof Proxy === "function") return true;
|
|
2231
|
+
try {
|
|
2232
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
2233
|
+
return true;
|
|
2234
|
+
} catch (e) {
|
|
2235
|
+
return false;
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2238
|
+
function _assertThisInitialized$2(self) {
|
|
2239
|
+
if (self === void 0) {
|
|
2240
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
2241
|
+
}
|
|
2242
|
+
return self;
|
|
2243
|
+
}
|
|
2244
|
+
function _possibleConstructorReturn$2(self, call) {
|
|
2245
|
+
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
2246
|
+
return call;
|
|
2247
|
+
} else if (call !== void 0) {
|
|
2248
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
2249
|
+
}
|
|
2250
|
+
return _assertThisInitialized$2(self);
|
|
2251
|
+
}
|
|
2252
|
+
function _createSuper$2(Derived) {
|
|
2253
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct$2();
|
|
2254
|
+
return function _createSuperInternal() {
|
|
2255
|
+
var Super = _getPrototypeOf$2(Derived),
|
|
2256
|
+
result;
|
|
2257
|
+
if (hasNativeReflectConstruct) {
|
|
2258
|
+
var NewTarget = _getPrototypeOf$2(this).constructor;
|
|
2259
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
2260
|
+
} else {
|
|
2261
|
+
result = Super.apply(this, arguments);
|
|
2262
|
+
}
|
|
2263
|
+
return _possibleConstructorReturn$2(this, result);
|
|
2264
|
+
};
|
|
2265
|
+
}
|
|
2266
|
+
function _slicedToArray$1(arr, i) {
|
|
2267
|
+
return _arrayWithHoles$1(arr) || _iterableToArrayLimit$1(arr, i) || _unsupportedIterableToArray$1(arr, i) || _nonIterableRest$1();
|
|
2268
|
+
}
|
|
2269
|
+
function _arrayWithHoles$1(arr) {
|
|
2270
|
+
if (Array.isArray(arr)) return arr;
|
|
2271
|
+
}
|
|
2272
|
+
function _unsupportedIterableToArray$1(o, minLen) {
|
|
1877
2273
|
if (!o) return;
|
|
1878
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
2274
|
+
if (typeof o === "string") return _arrayLikeToArray$1(o, minLen);
|
|
1879
2275
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1880
2276
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1881
2277
|
if (n === "Map" || n === "Set") return Array.from(o);
|
|
1882
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
2278
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen);
|
|
1883
2279
|
}
|
|
1884
|
-
function _arrayLikeToArray(arr, len) {
|
|
2280
|
+
function _arrayLikeToArray$1(arr, len) {
|
|
1885
2281
|
if (len == null || len > arr.length) len = arr.length;
|
|
1886
2282
|
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
1887
2283
|
arr2[i] = arr[i];
|
|
1888
2284
|
}
|
|
1889
2285
|
return arr2;
|
|
1890
2286
|
}
|
|
1891
|
-
function
|
|
2287
|
+
function _nonIterableRest$1() {
|
|
2288
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
2289
|
+
}
|
|
2290
|
+
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
1892
2291
|
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
1893
|
-
if (it)
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
if (i >= o.length) return {
|
|
1899
|
-
done: true
|
|
1900
|
-
};
|
|
2292
|
+
if (!it) {
|
|
2293
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
2294
|
+
if (it) o = it;
|
|
2295
|
+
var i = 0;
|
|
2296
|
+
var F = function F() {};
|
|
1901
2297
|
return {
|
|
1902
|
-
|
|
1903
|
-
|
|
2298
|
+
s: F,
|
|
2299
|
+
n: function n() {
|
|
2300
|
+
if (i >= o.length) return {
|
|
2301
|
+
done: true
|
|
2302
|
+
};
|
|
2303
|
+
return {
|
|
2304
|
+
done: false,
|
|
2305
|
+
value: o[i++]
|
|
2306
|
+
};
|
|
2307
|
+
},
|
|
2308
|
+
e: function e(_e2) {
|
|
2309
|
+
throw _e2;
|
|
2310
|
+
},
|
|
2311
|
+
f: F
|
|
1904
2312
|
};
|
|
1905
|
-
}
|
|
2313
|
+
}
|
|
2314
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1906
2315
|
}
|
|
1907
|
-
|
|
2316
|
+
var normalCompletion = true,
|
|
2317
|
+
didErr = false,
|
|
2318
|
+
err;
|
|
2319
|
+
return {
|
|
2320
|
+
s: function s() {
|
|
2321
|
+
it = it.call(o);
|
|
2322
|
+
},
|
|
2323
|
+
n: function n() {
|
|
2324
|
+
var step = it.next();
|
|
2325
|
+
normalCompletion = step.done;
|
|
2326
|
+
return step;
|
|
2327
|
+
},
|
|
2328
|
+
e: function e(_e3) {
|
|
2329
|
+
didErr = true;
|
|
2330
|
+
err = _e3;
|
|
2331
|
+
},
|
|
2332
|
+
f: function f() {
|
|
2333
|
+
try {
|
|
2334
|
+
if (!normalCompletion && it.return != null) it.return();
|
|
2335
|
+
} finally {
|
|
2336
|
+
if (didErr) throw err;
|
|
2337
|
+
}
|
|
2338
|
+
}
|
|
2339
|
+
};
|
|
2340
|
+
}
|
|
2341
|
+
function _toPrimitive$2(input, hint) {
|
|
2342
|
+
if (_typeof(input) !== "object" || input === null) return input;
|
|
2343
|
+
var prim = input[Symbol.toPrimitive];
|
|
2344
|
+
if (prim !== undefined) {
|
|
2345
|
+
var res = prim.call(input, hint || "default");
|
|
2346
|
+
if (_typeof(res) !== "object") return res;
|
|
2347
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
2348
|
+
}
|
|
2349
|
+
return (hint === "string" ? String : Number)(input);
|
|
2350
|
+
}
|
|
2351
|
+
function _toPropertyKey$2(arg) {
|
|
2352
|
+
var key = _toPrimitive$2(arg, "string");
|
|
2353
|
+
return _typeof(key) === "symbol" ? key : String(key);
|
|
1908
2354
|
}
|
|
1909
2355
|
var tmpVec3a = create$1();
|
|
1910
2356
|
var tmpVec3b = create$1();
|
|
@@ -1919,6 +2365,7 @@
|
|
|
1919
2365
|
var CanvasPickerPlugin = /*#__PURE__*/function () {
|
|
1920
2366
|
function CanvasPickerPlugin() {
|
|
1921
2367
|
var _this = this;
|
|
2368
|
+
_classCallCheck$2(this, CanvasPickerPlugin);
|
|
1922
2369
|
this.canvasConfig = void 0;
|
|
1923
2370
|
this.pathGeneratorFactory = void 0;
|
|
1924
2371
|
this.pointInPathPickerFactory = void 0;
|
|
@@ -1953,87 +2400,126 @@
|
|
|
1953
2400
|
return context.isPointInPath(position.x, position.y);
|
|
1954
2401
|
};
|
|
1955
2402
|
}
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
2403
|
+
_createClass$2(CanvasPickerPlugin, [{
|
|
2404
|
+
key: "apply",
|
|
2405
|
+
value: function apply(context) {
|
|
2406
|
+
var _renderingContext$roo,
|
|
2407
|
+
_this2 = this;
|
|
2408
|
+
var config = context.config,
|
|
2409
|
+
renderingService = context.renderingService,
|
|
2410
|
+
renderingContext = context.renderingContext,
|
|
2411
|
+
pathGeneratorFactory = context.pathGeneratorFactory,
|
|
2412
|
+
pointInPathPickerFactory = context.pointInPathPickerFactory;
|
|
2413
|
+
this.canvasConfig = config;
|
|
2414
|
+
this.pathGeneratorFactory = pathGeneratorFactory;
|
|
2415
|
+
this.pointInPathPickerFactory = pointInPathPickerFactory;
|
|
2416
|
+
var document = (_renderingContext$roo = renderingContext.root) === null || _renderingContext$roo === void 0 ? void 0 : _renderingContext$roo.ownerDocument;
|
|
2417
|
+
renderingService.hooks.pick.tapPromise(CanvasPickerPlugin.tag, /*#__PURE__*/function () {
|
|
2418
|
+
var _ref = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee(result) {
|
|
2419
|
+
return _regeneratorRuntime$1().wrap(function _callee$(_context) {
|
|
2420
|
+
while (1) {
|
|
2421
|
+
switch (_context.prev = _context.next) {
|
|
2422
|
+
case 0:
|
|
2423
|
+
return _context.abrupt("return", _this2.pick(document, result));
|
|
2424
|
+
case 1:
|
|
2425
|
+
case "end":
|
|
2426
|
+
return _context.stop();
|
|
2427
|
+
}
|
|
1979
2428
|
}
|
|
1980
|
-
}
|
|
1981
|
-
}
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
};
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
}
|
|
1990
|
-
}
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
var
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
if (
|
|
2015
|
-
|
|
2016
|
-
|
|
2429
|
+
}, _callee);
|
|
2430
|
+
}));
|
|
2431
|
+
return function (_x) {
|
|
2432
|
+
return _ref.apply(this, arguments);
|
|
2433
|
+
};
|
|
2434
|
+
}());
|
|
2435
|
+
renderingService.hooks.pickSync.tap(CanvasPickerPlugin.tag, function (result) {
|
|
2436
|
+
return _this2.pick(document, result);
|
|
2437
|
+
});
|
|
2438
|
+
}
|
|
2439
|
+
}, {
|
|
2440
|
+
key: "pick",
|
|
2441
|
+
value: function pick(document, result) {
|
|
2442
|
+
var topmost = result.topmost,
|
|
2443
|
+
_result$position = result.position,
|
|
2444
|
+
x = _result$position.x,
|
|
2445
|
+
y = _result$position.y;
|
|
2446
|
+
// position in world space
|
|
2447
|
+
var position = set(tmpVec3a, x, y, 0);
|
|
2448
|
+
// query by AABB first with spatial index(r-tree)
|
|
2449
|
+
var hitTestList = document.elementsFromBBox(position[0], position[1], position[0], position[1]);
|
|
2450
|
+
// test with clip path & origin shape
|
|
2451
|
+
// @see https://github.com/antvis/g/issues/1064
|
|
2452
|
+
var pickedDisplayObjects = [];
|
|
2453
|
+
var _iterator = _createForOfIteratorHelper(hitTestList),
|
|
2454
|
+
_step;
|
|
2455
|
+
try {
|
|
2456
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2457
|
+
var displayObject = _step.value;
|
|
2458
|
+
var worldTransform = displayObject.getWorldTransform();
|
|
2459
|
+
var isHitOriginShape = this.isHit(displayObject, position, worldTransform, false);
|
|
2460
|
+
if (isHitOriginShape) {
|
|
2461
|
+
// should look up in the ancestor node
|
|
2462
|
+
var clipped = gLite.findClosestClipPathTarget(displayObject);
|
|
2463
|
+
if (clipped) {
|
|
2464
|
+
var clipPath = clipped.parsedStyle.clipPath;
|
|
2465
|
+
var isHitClipPath = this.isHit(clipPath, position, clipPath.getWorldTransform(), true);
|
|
2466
|
+
if (isHitClipPath) {
|
|
2467
|
+
if (topmost) {
|
|
2468
|
+
result.picked = [displayObject];
|
|
2469
|
+
return result;
|
|
2470
|
+
} else {
|
|
2471
|
+
pickedDisplayObjects.push(displayObject);
|
|
2472
|
+
}
|
|
2473
|
+
}
|
|
2017
2474
|
} else {
|
|
2018
|
-
|
|
2475
|
+
if (topmost) {
|
|
2476
|
+
result.picked = [displayObject];
|
|
2477
|
+
return result;
|
|
2478
|
+
} else {
|
|
2479
|
+
pickedDisplayObjects.push(displayObject);
|
|
2480
|
+
}
|
|
2019
2481
|
}
|
|
2020
2482
|
}
|
|
2021
|
-
} else {
|
|
2022
|
-
if (topmost) {
|
|
2023
|
-
result.picked = [displayObject];
|
|
2024
|
-
return result;
|
|
2025
|
-
} else {
|
|
2026
|
-
pickedDisplayObjects.push(displayObject);
|
|
2027
|
-
}
|
|
2028
2483
|
}
|
|
2484
|
+
} catch (err) {
|
|
2485
|
+
_iterator.e(err);
|
|
2486
|
+
} finally {
|
|
2487
|
+
_iterator.f();
|
|
2029
2488
|
}
|
|
2489
|
+
result.picked = pickedDisplayObjects;
|
|
2490
|
+
return result;
|
|
2030
2491
|
}
|
|
2031
|
-
|
|
2032
|
-
return result;
|
|
2033
|
-
};
|
|
2492
|
+
}]);
|
|
2034
2493
|
return CanvasPickerPlugin;
|
|
2035
2494
|
}();
|
|
2036
2495
|
CanvasPickerPlugin.tag = 'CanvasPicker';
|
|
2496
|
+
function _toConsumableArray(arr) {
|
|
2497
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray$1$1(arr) || _nonIterableSpread();
|
|
2498
|
+
}
|
|
2499
|
+
function _arrayWithoutHoles(arr) {
|
|
2500
|
+
if (Array.isArray(arr)) return _arrayLikeToArray$1$1(arr);
|
|
2501
|
+
}
|
|
2502
|
+
function _iterableToArray(iter) {
|
|
2503
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
2504
|
+
}
|
|
2505
|
+
function _unsupportedIterableToArray$1$1(o, minLen) {
|
|
2506
|
+
if (!o) return;
|
|
2507
|
+
if (typeof o === "string") return _arrayLikeToArray$1$1(o, minLen);
|
|
2508
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
2509
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
2510
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
2511
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1$1(o, minLen);
|
|
2512
|
+
}
|
|
2513
|
+
function _arrayLikeToArray$1$1(arr, len) {
|
|
2514
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
2515
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
2516
|
+
arr2[i] = arr[i];
|
|
2517
|
+
}
|
|
2518
|
+
return arr2;
|
|
2519
|
+
}
|
|
2520
|
+
function _nonIterableSpread() {
|
|
2521
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
2522
|
+
}
|
|
2037
2523
|
|
|
2038
2524
|
/**
|
|
2039
2525
|
* 两点之间的距离
|
|
@@ -2052,10 +2538,10 @@
|
|
|
2052
2538
|
return Math.abs(v1 - v2) < 0.001;
|
|
2053
2539
|
}
|
|
2054
2540
|
function getBBoxByArray(xArr, yArr) {
|
|
2055
|
-
var minX = Math.min.apply(Math, xArr);
|
|
2056
|
-
var minY = Math.min.apply(Math, yArr);
|
|
2057
|
-
var maxX = Math.max.apply(Math, xArr);
|
|
2058
|
-
var maxY = Math.max.apply(Math, yArr);
|
|
2541
|
+
var minX = Math.min.apply(Math, _toConsumableArray(xArr));
|
|
2542
|
+
var minY = Math.min.apply(Math, _toConsumableArray(yArr));
|
|
2543
|
+
var maxX = Math.max.apply(Math, _toConsumableArray(xArr));
|
|
2544
|
+
var maxY = Math.max.apply(Math, _toConsumableArray(yArr));
|
|
2059
2545
|
return {
|
|
2060
2546
|
x: minX,
|
|
2061
2547
|
y: minY,
|
|
@@ -2181,7 +2667,7 @@
|
|
|
2181
2667
|
var interval = increaseRate / 10;
|
|
2182
2668
|
for (var i = 0; i <= segNum; i++) {
|
|
2183
2669
|
var _t = i * increaseRate;
|
|
2184
|
-
var v1 = [tCallback.apply(void 0, xArr.concat([_t])), tCallback.apply(void 0, yArr.concat([_t]))];
|
|
2670
|
+
var v1 = [tCallback.apply(void 0, _toConsumableArray(xArr.concat([_t]))), tCallback.apply(void 0, _toConsumableArray(yArr.concat([_t])))];
|
|
2185
2671
|
var d1 = distance(v0[0], v0[1], v1[0], v1[1]);
|
|
2186
2672
|
if (d1 < d) {
|
|
2187
2673
|
t = _t;
|
|
@@ -2209,13 +2695,13 @@
|
|
|
2209
2695
|
}
|
|
2210
2696
|
var prev = t - interval;
|
|
2211
2697
|
var next = t + interval;
|
|
2212
|
-
var _v = [tCallback.apply(void 0, xArr.concat([prev])), tCallback.apply(void 0, yArr.concat([prev]))];
|
|
2698
|
+
var _v = [tCallback.apply(void 0, _toConsumableArray(xArr.concat([prev]))), tCallback.apply(void 0, _toConsumableArray(yArr.concat([prev])))];
|
|
2213
2699
|
var _d = distance(v0[0], v0[1], _v[0], _v[1]);
|
|
2214
2700
|
if (prev >= 0 && _d < d) {
|
|
2215
2701
|
t = prev;
|
|
2216
2702
|
d = _d;
|
|
2217
2703
|
} else {
|
|
2218
|
-
var v2 = [tCallback.apply(void 0, xArr.concat([next])), tCallback.apply(void 0, yArr.concat([next]))];
|
|
2704
|
+
var v2 = [tCallback.apply(void 0, _toConsumableArray(xArr.concat([next]))), tCallback.apply(void 0, _toConsumableArray(yArr.concat([next])))];
|
|
2219
2705
|
var d2 = distance(v0[0], v0[1], v2[0], v2[1]);
|
|
2220
2706
|
if (next <= 1 && d2 < d) {
|
|
2221
2707
|
t = next;
|
|
@@ -2226,8 +2712,8 @@
|
|
|
2226
2712
|
}
|
|
2227
2713
|
}
|
|
2228
2714
|
return {
|
|
2229
|
-
x: tCallback.apply(void 0, xArr.concat([t])),
|
|
2230
|
-
y: tCallback.apply(void 0, yArr.concat([t]))
|
|
2715
|
+
x: tCallback.apply(void 0, _toConsumableArray(xArr.concat([t]))),
|
|
2716
|
+
y: tCallback.apply(void 0, _toConsumableArray(yArr.concat([t])))
|
|
2231
2717
|
};
|
|
2232
2718
|
}
|
|
2233
2719
|
// 近似求解 https://community.khronos.org/t/3d-cubic-bezier-segment-length/62363/2
|
|
@@ -2285,7 +2771,7 @@
|
|
|
2285
2771
|
var right = quadratics[1];
|
|
2286
2772
|
left.push(iterationCount - 1);
|
|
2287
2773
|
right.push(iterationCount - 1);
|
|
2288
|
-
return quadraticLength.apply(void 0, left) + quadraticLength.apply(void 0, right);
|
|
2774
|
+
return quadraticLength.apply(void 0, _toConsumableArray(left)) + quadraticLength.apply(void 0, _toConsumableArray(right));
|
|
2289
2775
|
}
|
|
2290
2776
|
var quadratic = {
|
|
2291
2777
|
box: function box(x1, y1, x2, y2, x3, y3) {
|
|
@@ -2389,9 +2875,9 @@
|
|
|
2389
2875
|
return snapLength([x1, x2, x3, x4], [y1, y2, y3, y4]);
|
|
2390
2876
|
}
|
|
2391
2877
|
var cubics = divideCubic(x1, y1, x2, y2, x3, y3, x4, y4, 0.5);
|
|
2392
|
-
var left = [].concat(cubics[0], [iterationCount - 1]);
|
|
2393
|
-
var right = [].concat(cubics[1], [iterationCount - 1]);
|
|
2394
|
-
return cubicLength.apply(void 0, left) + cubicLength.apply(void 0, right);
|
|
2878
|
+
var left = [].concat(_toConsumableArray(cubics[0]), [iterationCount - 1]);
|
|
2879
|
+
var right = [].concat(_toConsumableArray(cubics[1]), [iterationCount - 1]);
|
|
2880
|
+
return cubicLength.apply(void 0, _toConsumableArray(left)) + cubicLength.apply(void 0, _toConsumableArray(right));
|
|
2395
2881
|
}
|
|
2396
2882
|
var cubic = {
|
|
2397
2883
|
extrema: extrema$1,
|
|
@@ -2565,8 +3051,9 @@
|
|
|
2565
3051
|
var halfLineWidth = ((lineWidth || 0) + (increasedLineWidthForHitTesting || 0)) / 2;
|
|
2566
3052
|
var absDistance = distance$1(r, r, position.x, position.y);
|
|
2567
3053
|
var _isFillOrStrokeAffect = gLite.isFillOrStrokeAffected(pointerEvents, fill, stroke),
|
|
2568
|
-
|
|
2569
|
-
|
|
3054
|
+
_isFillOrStrokeAffect2 = _slicedToArray$1(_isFillOrStrokeAffect, 2),
|
|
3055
|
+
hasFill = _isFillOrStrokeAffect2[0],
|
|
3056
|
+
hasStroke = _isFillOrStrokeAffect2[1];
|
|
2570
3057
|
if (hasFill && hasStroke || isClipPath) {
|
|
2571
3058
|
return absDistance <= r + halfLineWidth;
|
|
2572
3059
|
}
|
|
@@ -2593,8 +3080,9 @@
|
|
|
2593
3080
|
var x = position.x,
|
|
2594
3081
|
y = position.y;
|
|
2595
3082
|
var _isFillOrStrokeAffect = gLite.isFillOrStrokeAffected(pointerEvents, fill, stroke),
|
|
2596
|
-
|
|
2597
|
-
|
|
3083
|
+
_isFillOrStrokeAffect2 = _slicedToArray$1(_isFillOrStrokeAffect, 2),
|
|
3084
|
+
hasFill = _isFillOrStrokeAffect2[0],
|
|
3085
|
+
hasStroke = _isFillOrStrokeAffect2[1];
|
|
2598
3086
|
var halfLineWith = ((lineWidth || 0) + (increasedLineWidthForHitTesting || 0)) / 2;
|
|
2599
3087
|
var squareX = (x - rx) * (x - rx);
|
|
2600
3088
|
var squareY = (y - ry) * (y - ry);
|
|
@@ -2627,8 +3115,9 @@
|
|
|
2627
3115
|
stroke = _displayObject$parsed.stroke;
|
|
2628
3116
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2629
3117
|
var _isFillOrStrokeAffect = gLite.isFillOrStrokeAffected(pointerEvents, fill, stroke),
|
|
2630
|
-
|
|
2631
|
-
|
|
3118
|
+
_isFillOrStrokeAffect2 = _slicedToArray$1(_isFillOrStrokeAffect, 2),
|
|
3119
|
+
_ = _isFillOrStrokeAffect2[0],
|
|
3120
|
+
hasStroke = _isFillOrStrokeAffect2[1];
|
|
2632
3121
|
if (!hasStroke && !isClipPath || !lineWidth) {
|
|
2633
3122
|
return false;
|
|
2634
3123
|
}
|
|
@@ -2712,8 +3201,9 @@
|
|
|
2712
3201
|
path = _displayObject$parsed.path,
|
|
2713
3202
|
pointerEvents = _displayObject$parsed.pointerEvents;
|
|
2714
3203
|
var _isFillOrStrokeAffect = gLite.isFillOrStrokeAffected(pointerEvents, fill, stroke),
|
|
2715
|
-
|
|
2716
|
-
|
|
3204
|
+
_isFillOrStrokeAffect2 = _slicedToArray$1(_isFillOrStrokeAffect, 2),
|
|
3205
|
+
hasFill = _isFillOrStrokeAffect2[0],
|
|
3206
|
+
hasStroke = _isFillOrStrokeAffect2[1];
|
|
2717
3207
|
var segments = path.segments,
|
|
2718
3208
|
hasArc = path.hasArc,
|
|
2719
3209
|
polylines = path.polylines,
|
|
@@ -2747,8 +3237,9 @@
|
|
|
2747
3237
|
y = _displayObject$parsed3 === void 0 ? 0 : _displayObject$parsed3,
|
|
2748
3238
|
pointerEvents = _displayObject$parsed.pointerEvents;
|
|
2749
3239
|
var _isFillOrStrokeAffect = gLite.isFillOrStrokeAffected(pointerEvents, fill, stroke),
|
|
2750
|
-
|
|
2751
|
-
|
|
3240
|
+
_isFillOrStrokeAffect2 = _slicedToArray$1(_isFillOrStrokeAffect, 2),
|
|
3241
|
+
hasFill = _isFillOrStrokeAffect2[0],
|
|
3242
|
+
hasStroke = _isFillOrStrokeAffect2[1];
|
|
2752
3243
|
var isHit = false;
|
|
2753
3244
|
if (hasStroke || isClipPath) {
|
|
2754
3245
|
isHit = inPolyline(points.points, (lineWidth || 0) + (increasedLineWidthForHitTesting || 0), position.x + x, position.y + y, true);
|
|
@@ -2771,7 +3262,8 @@
|
|
|
2771
3262
|
fill = _displayObject$parsed.fill,
|
|
2772
3263
|
stroke = _displayObject$parsed.stroke;
|
|
2773
3264
|
var _isFillOrStrokeAffect = gLite.isFillOrStrokeAffected(pointerEvents, fill, stroke),
|
|
2774
|
-
|
|
3265
|
+
_isFillOrStrokeAffect2 = _slicedToArray$1(_isFillOrStrokeAffect, 2),
|
|
3266
|
+
hasStroke = _isFillOrStrokeAffect2[1];
|
|
2775
3267
|
if (!hasStroke && !isClipPath || !lineWidth) {
|
|
2776
3268
|
return false;
|
|
2777
3269
|
}
|
|
@@ -2788,8 +3280,9 @@
|
|
|
2788
3280
|
height = _displayObject$parsed.height,
|
|
2789
3281
|
pointerEvents = _displayObject$parsed.pointerEvents;
|
|
2790
3282
|
var _isFillOrStrokeAffect = gLite.isFillOrStrokeAffected(pointerEvents, fill, stroke),
|
|
2791
|
-
|
|
2792
|
-
|
|
3283
|
+
_isFillOrStrokeAffect2 = _slicedToArray$1(_isFillOrStrokeAffect, 2),
|
|
3284
|
+
hasFill = _isFillOrStrokeAffect2[0],
|
|
3285
|
+
hasStroke = _isFillOrStrokeAffect2[1];
|
|
2793
3286
|
var hasRadius = radius && radius.some(function (r) {
|
|
2794
3287
|
return r !== 0;
|
|
2795
3288
|
});
|
|
@@ -2825,39 +3318,46 @@
|
|
|
2825
3318
|
return false;
|
|
2826
3319
|
}
|
|
2827
3320
|
function inRectWithRadius(minX, minY, width, height, radiusArray, lineWidth, x, y) {
|
|
2828
|
-
var
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
3321
|
+
var _radiusArray = _slicedToArray$1(radiusArray, 4),
|
|
3322
|
+
tlr = _radiusArray[0],
|
|
3323
|
+
trr = _radiusArray[1],
|
|
3324
|
+
brr = _radiusArray[2],
|
|
3325
|
+
blr = _radiusArray[3];
|
|
2832
3326
|
return inLine(minX + tlr, minY, minX + width - trr, minY, lineWidth, x, y) || inLine(minX + width, minY + trr, minX + width, minY + height - brr, lineWidth, x, y) || inLine(minX + width - brr, minY + height, minX + blr, minY + height, lineWidth, x, y) || inLine(minX, minY + height - blr, minX, minY + tlr, lineWidth, x, y) || inArc(minX + width - trr, minY + trr, trr, 1.5 * Math.PI, 2 * Math.PI, lineWidth, x, y) || inArc(minX + width - brr, minY + height - brr, brr, 0, 0.5 * Math.PI, lineWidth, x, y) || inArc(minX + blr, minY + height - blr, blr, 0.5 * Math.PI, Math.PI, lineWidth, x, y) || inArc(minX + tlr, minY + tlr, tlr, Math.PI, 1.5 * Math.PI, lineWidth, x, y);
|
|
2833
3327
|
}
|
|
2834
3328
|
var Plugin$1 = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
2835
|
-
|
|
3329
|
+
_inherits$2(Plugin, _AbstractRendererPlug);
|
|
3330
|
+
var _super = _createSuper$2(Plugin);
|
|
2836
3331
|
function Plugin() {
|
|
2837
3332
|
var _this;
|
|
3333
|
+
_classCallCheck$2(this, Plugin);
|
|
2838
3334
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2839
3335
|
args[_key] = arguments[_key];
|
|
2840
3336
|
}
|
|
2841
|
-
_this =
|
|
3337
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
2842
3338
|
_this.name = 'canvas-picker';
|
|
2843
3339
|
return _this;
|
|
2844
3340
|
}
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
3341
|
+
_createClass$2(Plugin, [{
|
|
3342
|
+
key: "init",
|
|
3343
|
+
value: function init() {
|
|
3344
|
+
var _pointInPathPickerFac;
|
|
3345
|
+
var trueFunc = function trueFunc() {
|
|
3346
|
+
return true;
|
|
3347
|
+
};
|
|
3348
|
+
var pointInPathPickerFactory = (_pointInPathPickerFac = {}, _defineProperty$1(_pointInPathPickerFac, gLite.Shape.CIRCLE, isPointInPath), _defineProperty$1(_pointInPathPickerFac, gLite.Shape.ELLIPSE, isPointInPath$1), _defineProperty$1(_pointInPathPickerFac, gLite.Shape.RECT, isPointInPath$6), _defineProperty$1(_pointInPathPickerFac, gLite.Shape.LINE, isPointInPath$2), _defineProperty$1(_pointInPathPickerFac, gLite.Shape.POLYLINE, isPointInPath$5), _defineProperty$1(_pointInPathPickerFac, gLite.Shape.POLYGON, isPointInPath$4), _defineProperty$1(_pointInPathPickerFac, gLite.Shape.PATH, isPointInPath$3), _defineProperty$1(_pointInPathPickerFac, gLite.Shape.TEXT, trueFunc), _defineProperty$1(_pointInPathPickerFac, gLite.Shape.GROUP, null), _defineProperty$1(_pointInPathPickerFac, gLite.Shape.IMAGE, trueFunc), _defineProperty$1(_pointInPathPickerFac, gLite.Shape.HTML, null), _defineProperty$1(_pointInPathPickerFac, gLite.Shape.MESH, null), _pointInPathPickerFac);
|
|
3349
|
+
// @ts-ignore
|
|
3350
|
+
this.context.pointInPathPickerFactory = pointInPathPickerFactory;
|
|
3351
|
+
this.addRenderingPlugin(new CanvasPickerPlugin());
|
|
3352
|
+
}
|
|
3353
|
+
}, {
|
|
3354
|
+
key: "destroy",
|
|
3355
|
+
value: function destroy() {
|
|
3356
|
+
// @ts-ignore
|
|
3357
|
+
delete this.context.pointInPathPickerFactory;
|
|
3358
|
+
this.removeAllRenderingPlugins();
|
|
3359
|
+
}
|
|
3360
|
+
}]);
|
|
2861
3361
|
return Plugin;
|
|
2862
3362
|
}(gLite.AbstractRendererPlugin);
|
|
2863
3363
|
|
|
@@ -2866,6 +3366,56 @@
|
|
|
2866
3366
|
Plugin: Plugin$1
|
|
2867
3367
|
});
|
|
2868
3368
|
|
|
3369
|
+
function _iterableToArrayLimit$2(arr, i) {
|
|
3370
|
+
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
|
|
3371
|
+
if (null != _i) {
|
|
3372
|
+
var _s,
|
|
3373
|
+
_e,
|
|
3374
|
+
_x,
|
|
3375
|
+
_r,
|
|
3376
|
+
_arr = [],
|
|
3377
|
+
_n = !0,
|
|
3378
|
+
_d = !1;
|
|
3379
|
+
try {
|
|
3380
|
+
if (_x = (_i = _i.call(arr)).next, 0 === i) {
|
|
3381
|
+
if (Object(_i) !== _i) return;
|
|
3382
|
+
_n = !1;
|
|
3383
|
+
} else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0) {
|
|
3384
|
+
;
|
|
3385
|
+
}
|
|
3386
|
+
} catch (err) {
|
|
3387
|
+
_d = !0, _e = err;
|
|
3388
|
+
} finally {
|
|
3389
|
+
try {
|
|
3390
|
+
if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
|
|
3391
|
+
} finally {
|
|
3392
|
+
if (_d) throw _e;
|
|
3393
|
+
}
|
|
3394
|
+
}
|
|
3395
|
+
return _arr;
|
|
3396
|
+
}
|
|
3397
|
+
}
|
|
3398
|
+
function ownKeys(object, enumerableOnly) {
|
|
3399
|
+
var keys = Object.keys(object);
|
|
3400
|
+
if (Object.getOwnPropertySymbols) {
|
|
3401
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
3402
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
3403
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
3404
|
+
})), keys.push.apply(keys, symbols);
|
|
3405
|
+
}
|
|
3406
|
+
return keys;
|
|
3407
|
+
}
|
|
3408
|
+
function _objectSpread2(target) {
|
|
3409
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
3410
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
3411
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
3412
|
+
_defineProperty$2(target, key, source[key]);
|
|
3413
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
3414
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
3415
|
+
});
|
|
3416
|
+
}
|
|
3417
|
+
return target;
|
|
3418
|
+
}
|
|
2869
3419
|
function _regeneratorRuntime$2() {
|
|
2870
3420
|
_regeneratorRuntime$2 = function _regeneratorRuntime() {
|
|
2871
3421
|
return exports;
|
|
@@ -2942,7 +3492,7 @@
|
|
|
2942
3492
|
if ("throw" !== record.type) {
|
|
2943
3493
|
var result = record.arg,
|
|
2944
3494
|
value = result.value;
|
|
2945
|
-
return value && "object" ==
|
|
3495
|
+
return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
2946
3496
|
invoke("next", value, resolve, reject);
|
|
2947
3497
|
}, function (err) {
|
|
2948
3498
|
invoke("throw", err, resolve, reject);
|
|
@@ -3203,24 +3753,63 @@
|
|
|
3203
3753
|
});
|
|
3204
3754
|
};
|
|
3205
3755
|
}
|
|
3206
|
-
function
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3756
|
+
function _classCallCheck$3(instance, Constructor) {
|
|
3757
|
+
if (!(instance instanceof Constructor)) {
|
|
3758
|
+
throw new TypeError("Cannot call a class as a function");
|
|
3759
|
+
}
|
|
3760
|
+
}
|
|
3761
|
+
function _defineProperties$3(target, props) {
|
|
3762
|
+
for (var i = 0; i < props.length; i++) {
|
|
3763
|
+
var descriptor = props[i];
|
|
3764
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
3765
|
+
descriptor.configurable = true;
|
|
3766
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
3767
|
+
Object.defineProperty(target, _toPropertyKey$3(descriptor.key), descriptor);
|
|
3768
|
+
}
|
|
3769
|
+
}
|
|
3770
|
+
function _createClass$3(Constructor, protoProps, staticProps) {
|
|
3771
|
+
if (protoProps) _defineProperties$3(Constructor.prototype, protoProps);
|
|
3772
|
+
if (staticProps) _defineProperties$3(Constructor, staticProps);
|
|
3773
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
3774
|
+
writable: false
|
|
3775
|
+
});
|
|
3776
|
+
return Constructor;
|
|
3777
|
+
}
|
|
3778
|
+
function _defineProperty$2(obj, key, value) {
|
|
3779
|
+
key = _toPropertyKey$3(key);
|
|
3780
|
+
if (key in obj) {
|
|
3781
|
+
Object.defineProperty(obj, key, {
|
|
3782
|
+
value: value,
|
|
3783
|
+
enumerable: true,
|
|
3784
|
+
configurable: true,
|
|
3785
|
+
writable: true
|
|
3786
|
+
});
|
|
3787
|
+
} else {
|
|
3788
|
+
obj[key] = value;
|
|
3789
|
+
}
|
|
3790
|
+
return obj;
|
|
3791
|
+
}
|
|
3792
|
+
function _inherits$3(subClass, superClass) {
|
|
3793
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
3794
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
3795
|
+
}
|
|
3796
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
3797
|
+
constructor: {
|
|
3798
|
+
value: subClass,
|
|
3799
|
+
writable: true,
|
|
3800
|
+
configurable: true
|
|
3215
3801
|
}
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3802
|
+
});
|
|
3803
|
+
Object.defineProperty(subClass, "prototype", {
|
|
3804
|
+
writable: false
|
|
3805
|
+
});
|
|
3806
|
+
if (superClass) _setPrototypeOf$3(subClass, superClass);
|
|
3219
3807
|
}
|
|
3220
|
-
function
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3808
|
+
function _getPrototypeOf$3(o) {
|
|
3809
|
+
_getPrototypeOf$3 = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
3810
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
3811
|
+
};
|
|
3812
|
+
return _getPrototypeOf$3(o);
|
|
3224
3813
|
}
|
|
3225
3814
|
function _setPrototypeOf$3(o, p) {
|
|
3226
3815
|
_setPrototypeOf$3 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
@@ -3229,28 +3818,118 @@
|
|
|
3229
3818
|
};
|
|
3230
3819
|
return _setPrototypeOf$3(o, p);
|
|
3231
3820
|
}
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
this
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3821
|
+
function _isNativeReflectConstruct$3() {
|
|
3822
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
3823
|
+
if (Reflect.construct.sham) return false;
|
|
3824
|
+
if (typeof Proxy === "function") return true;
|
|
3825
|
+
try {
|
|
3826
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
3827
|
+
return true;
|
|
3828
|
+
} catch (e) {
|
|
3829
|
+
return false;
|
|
3830
|
+
}
|
|
3831
|
+
}
|
|
3832
|
+
function _assertThisInitialized$3(self) {
|
|
3833
|
+
if (self === void 0) {
|
|
3834
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
3835
|
+
}
|
|
3836
|
+
return self;
|
|
3837
|
+
}
|
|
3838
|
+
function _possibleConstructorReturn$3(self, call) {
|
|
3839
|
+
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
3840
|
+
return call;
|
|
3841
|
+
} else if (call !== void 0) {
|
|
3842
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
3843
|
+
}
|
|
3844
|
+
return _assertThisInitialized$3(self);
|
|
3845
|
+
}
|
|
3846
|
+
function _createSuper$3(Derived) {
|
|
3847
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct$3();
|
|
3848
|
+
return function _createSuperInternal() {
|
|
3849
|
+
var Super = _getPrototypeOf$3(Derived),
|
|
3850
|
+
result;
|
|
3851
|
+
if (hasNativeReflectConstruct) {
|
|
3852
|
+
var NewTarget = _getPrototypeOf$3(this).constructor;
|
|
3853
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
3854
|
+
} else {
|
|
3855
|
+
result = Super.apply(this, arguments);
|
|
3856
|
+
}
|
|
3857
|
+
return _possibleConstructorReturn$3(this, result);
|
|
3858
|
+
};
|
|
3859
|
+
}
|
|
3860
|
+
function _slicedToArray$2(arr, i) {
|
|
3861
|
+
return _arrayWithHoles$2(arr) || _iterableToArrayLimit$2(arr, i) || _unsupportedIterableToArray$2(arr, i) || _nonIterableRest$2();
|
|
3862
|
+
}
|
|
3863
|
+
function _toConsumableArray$1(arr) {
|
|
3864
|
+
return _arrayWithoutHoles$1(arr) || _iterableToArray$1(arr) || _unsupportedIterableToArray$2(arr) || _nonIterableSpread$1();
|
|
3865
|
+
}
|
|
3866
|
+
function _arrayWithoutHoles$1(arr) {
|
|
3867
|
+
if (Array.isArray(arr)) return _arrayLikeToArray$2(arr);
|
|
3868
|
+
}
|
|
3869
|
+
function _arrayWithHoles$2(arr) {
|
|
3870
|
+
if (Array.isArray(arr)) return arr;
|
|
3871
|
+
}
|
|
3872
|
+
function _iterableToArray$1(iter) {
|
|
3873
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
3874
|
+
}
|
|
3875
|
+
function _unsupportedIterableToArray$2(o, minLen) {
|
|
3876
|
+
if (!o) return;
|
|
3877
|
+
if (typeof o === "string") return _arrayLikeToArray$2(o, minLen);
|
|
3878
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
3879
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
3880
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
3881
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$2(o, minLen);
|
|
3882
|
+
}
|
|
3883
|
+
function _arrayLikeToArray$2(arr, len) {
|
|
3884
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
3885
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
3886
|
+
arr2[i] = arr[i];
|
|
3887
|
+
}
|
|
3888
|
+
return arr2;
|
|
3889
|
+
}
|
|
3890
|
+
function _nonIterableSpread$1() {
|
|
3891
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
3892
|
+
}
|
|
3893
|
+
function _nonIterableRest$2() {
|
|
3894
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
3895
|
+
}
|
|
3896
|
+
function _toPrimitive$3(input, hint) {
|
|
3897
|
+
if (_typeof(input) !== "object" || input === null) return input;
|
|
3898
|
+
var prim = input[Symbol.toPrimitive];
|
|
3899
|
+
if (prim !== undefined) {
|
|
3900
|
+
var res = prim.call(input, hint || "default");
|
|
3901
|
+
if (_typeof(res) !== "object") return res;
|
|
3902
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
3903
|
+
}
|
|
3904
|
+
return (hint === "string" ? String : Number)(input);
|
|
3905
|
+
}
|
|
3906
|
+
function _toPropertyKey$3(arg) {
|
|
3907
|
+
var key = _toPrimitive$3(arg, "string");
|
|
3908
|
+
return _typeof(key) === "symbol" ? key : String(key);
|
|
3909
|
+
}
|
|
3910
|
+
|
|
3911
|
+
/**
|
|
3912
|
+
* support 2 modes in rendering:
|
|
3913
|
+
* * immediate
|
|
3914
|
+
* * delayed: render at the end of frame with dirty-rectangle
|
|
3915
|
+
*/
|
|
3916
|
+
var CanvasRendererPlugin = /*#__PURE__*/function () {
|
|
3917
|
+
/**
|
|
3918
|
+
* RBush used in dirty rectangle rendering
|
|
3919
|
+
*/
|
|
3920
|
+
|
|
3921
|
+
function CanvasRendererPlugin(canvasRendererPluginOptions) {
|
|
3922
|
+
_classCallCheck$3(this, CanvasRendererPlugin);
|
|
3923
|
+
this.canvasRendererPluginOptions = void 0;
|
|
3924
|
+
this.context = void 0;
|
|
3925
|
+
this.pathGeneratorFactory = void 0;
|
|
3926
|
+
this.rBush = void 0;
|
|
3927
|
+
this.removedRBushNodeAABBs = [];
|
|
3928
|
+
this.renderQueue = [];
|
|
3929
|
+
this.restoreStack = [];
|
|
3930
|
+
this.clearFullScreen = false;
|
|
3931
|
+
this.vpMatrix = create();
|
|
3932
|
+
this.dprMatrix = create();
|
|
3254
3933
|
this.tmpMat4 = create();
|
|
3255
3934
|
this.vec3a = create$1();
|
|
3256
3935
|
this.vec3b = create$1();
|
|
@@ -3258,544 +3937,579 @@
|
|
|
3258
3937
|
this.vec3d = create$1();
|
|
3259
3938
|
this.canvasRendererPluginOptions = canvasRendererPluginOptions;
|
|
3260
3939
|
}
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
var
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
};
|
|
3285
|
-
var handleCulled = function handleCulled(e) {
|
|
3286
|
-
var object = e.target;
|
|
3287
|
-
// @ts-ignore
|
|
3288
|
-
var rBushNode = object.rBushNode;
|
|
3289
|
-
if (rBushNode.aabb) {
|
|
3290
|
-
// save removed aabbs for dirty-rectangle rendering later
|
|
3291
|
-
_this.removedRBushNodeAABBs.push(rBushNode.aabb);
|
|
3292
|
-
}
|
|
3293
|
-
};
|
|
3294
|
-
renderingService.hooks.init.tapPromise(CanvasRendererPlugin.tag, /*#__PURE__*/_asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee() {
|
|
3295
|
-
var dpr, width, height, context;
|
|
3296
|
-
return _regeneratorRuntime$2().wrap(function _callee$(_context) {
|
|
3297
|
-
while (1) {
|
|
3298
|
-
switch (_context.prev = _context.next) {
|
|
3299
|
-
case 0:
|
|
3300
|
-
canvas.addEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
3301
|
-
canvas.addEventListener(gLite.ElementEvent.CULLED, handleCulled);
|
|
3302
|
-
// clear fullscreen
|
|
3303
|
-
dpr = contextService.getDPR();
|
|
3304
|
-
width = config.width, height = config.height;
|
|
3305
|
-
context = contextService.getContext();
|
|
3306
|
-
_this.clearRect(context, 0, 0, width * dpr, height * dpr, config.background);
|
|
3307
|
-
case 6:
|
|
3308
|
-
case "end":
|
|
3309
|
-
return _context.stop();
|
|
3310
|
-
}
|
|
3940
|
+
_createClass$3(CanvasRendererPlugin, [{
|
|
3941
|
+
key: "apply",
|
|
3942
|
+
value: function apply(context) {
|
|
3943
|
+
var _this = this;
|
|
3944
|
+
this.context = context;
|
|
3945
|
+
var config = context.config,
|
|
3946
|
+
camera = context.camera,
|
|
3947
|
+
renderingService = context.renderingService,
|
|
3948
|
+
renderingContext = context.renderingContext,
|
|
3949
|
+
rBushRoot = context.rBushRoot,
|
|
3950
|
+
pathGeneratorFactory = context.pathGeneratorFactory;
|
|
3951
|
+
this.rBush = rBushRoot;
|
|
3952
|
+
this.pathGeneratorFactory = pathGeneratorFactory;
|
|
3953
|
+
var contextService = context.contextService;
|
|
3954
|
+
var canvas = renderingContext.root.ownerDocument.defaultView;
|
|
3955
|
+
var handleUnmounted = function handleUnmounted(e) {
|
|
3956
|
+
var object = e.target;
|
|
3957
|
+
// remove r-bush node
|
|
3958
|
+
// @ts-ignore
|
|
3959
|
+
var rBushNode = object.rBushNode;
|
|
3960
|
+
if (rBushNode.aabb) {
|
|
3961
|
+
// save removed aabbs for dirty-rectangle rendering later
|
|
3962
|
+
_this.removedRBushNodeAABBs.push(rBushNode.aabb);
|
|
3311
3963
|
}
|
|
3312
|
-
}
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
var dpr = contextService.getDPR();
|
|
3321
|
-
var width = config.width,
|
|
3322
|
-
height = config.height;
|
|
3323
|
-
var _this$canvasRendererP = _this.canvasRendererPluginOptions,
|
|
3324
|
-
dirtyObjectNumThreshold = _this$canvasRendererP.dirtyObjectNumThreshold,
|
|
3325
|
-
dirtyObjectRatioThreshold = _this$canvasRendererP.dirtyObjectRatioThreshold;
|
|
3326
|
-
// some heuristic conditions such as 80% object changed
|
|
3327
|
-
var _renderingService$get = renderingService.getStats(),
|
|
3328
|
-
total = _renderingService$get.total,
|
|
3329
|
-
rendered = _renderingService$get.rendered;
|
|
3330
|
-
var ratio = rendered / total;
|
|
3331
|
-
_this.clearFullScreen = renderingService.disableDirtyRectangleRendering() || rendered > dirtyObjectNumThreshold && ratio > dirtyObjectRatioThreshold;
|
|
3332
|
-
if (context) {
|
|
3333
|
-
context.resetTransform();
|
|
3334
|
-
if (_this.clearFullScreen) {
|
|
3335
|
-
_this.clearRect(context, 0, 0, width * dpr, height * dpr, config.background);
|
|
3964
|
+
};
|
|
3965
|
+
var handleCulled = function handleCulled(e) {
|
|
3966
|
+
var object = e.target;
|
|
3967
|
+
// @ts-ignore
|
|
3968
|
+
var rBushNode = object.rBushNode;
|
|
3969
|
+
if (rBushNode.aabb) {
|
|
3970
|
+
// save removed aabbs for dirty-rectangle rendering later
|
|
3971
|
+
_this.removedRBushNodeAABBs.push(rBushNode.aabb);
|
|
3336
3972
|
}
|
|
3337
|
-
}
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3973
|
+
};
|
|
3974
|
+
renderingService.hooks.init.tapPromise(CanvasRendererPlugin.tag, /*#__PURE__*/_asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee() {
|
|
3975
|
+
var dpr, width, height, context;
|
|
3976
|
+
return _regeneratorRuntime$2().wrap(function _callee$(_context) {
|
|
3977
|
+
while (1) {
|
|
3978
|
+
switch (_context.prev = _context.next) {
|
|
3979
|
+
case 0:
|
|
3980
|
+
canvas.addEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
3981
|
+
canvas.addEventListener(gLite.ElementEvent.CULLED, handleCulled);
|
|
3982
|
+
// clear fullscreen
|
|
3983
|
+
dpr = contextService.getDPR();
|
|
3984
|
+
width = config.width, height = config.height;
|
|
3985
|
+
context = contextService.getContext();
|
|
3986
|
+
_this.clearRect(context, 0, 0, width * dpr, height * dpr, config.background);
|
|
3987
|
+
case 6:
|
|
3988
|
+
case "end":
|
|
3989
|
+
return _context.stop();
|
|
3990
|
+
}
|
|
3991
|
+
}
|
|
3992
|
+
}, _callee);
|
|
3993
|
+
})));
|
|
3994
|
+
renderingService.hooks.destroy.tap(CanvasRendererPlugin.tag, function () {
|
|
3995
|
+
canvas.removeEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
3996
|
+
canvas.removeEventListener(gLite.ElementEvent.CULLED, handleCulled);
|
|
3349
3997
|
});
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
var
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
return aabb;
|
|
3370
|
-
})));
|
|
3371
|
-
_this.removedRBushNodeAABBs = [];
|
|
3372
|
-
if (gLite.AABB.isEmpty(dirtyRenderBounds)) {
|
|
3373
|
-
_this.renderQueue = [];
|
|
3374
|
-
return;
|
|
3998
|
+
renderingService.hooks.beginFrame.tap(CanvasRendererPlugin.tag, function () {
|
|
3999
|
+
var context = contextService.getContext();
|
|
4000
|
+
var dpr = contextService.getDPR();
|
|
4001
|
+
var width = config.width,
|
|
4002
|
+
height = config.height;
|
|
4003
|
+
var _this$canvasRendererP = _this.canvasRendererPluginOptions,
|
|
4004
|
+
dirtyObjectNumThreshold = _this$canvasRendererP.dirtyObjectNumThreshold,
|
|
4005
|
+
dirtyObjectRatioThreshold = _this$canvasRendererP.dirtyObjectRatioThreshold;
|
|
4006
|
+
// some heuristic conditions such as 80% object changed
|
|
4007
|
+
var _renderingService$get = renderingService.getStats(),
|
|
4008
|
+
total = _renderingService$get.total,
|
|
4009
|
+
rendered = _renderingService$get.rendered;
|
|
4010
|
+
var ratio = rendered / total;
|
|
4011
|
+
_this.clearFullScreen = renderingService.disableDirtyRectangleRendering() || rendered > dirtyObjectNumThreshold && ratio > dirtyObjectRatioThreshold;
|
|
4012
|
+
if (context) {
|
|
4013
|
+
context.resetTransform();
|
|
4014
|
+
if (_this.clearFullScreen) {
|
|
4015
|
+
_this.clearRect(context, 0, 0, width * dpr, height * dpr, config.background);
|
|
4016
|
+
}
|
|
3375
4017
|
}
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
var tr = transformMat4(_this.vec3b, fromValues(x + width, y, 0), _this.vpMatrix);
|
|
3383
|
-
var bl = transformMat4(_this.vec3c, fromValues(x, y + height, 0), _this.vpMatrix);
|
|
3384
|
-
var br = transformMat4(_this.vec3d, fromValues(x + width, y + height, 0), _this.vpMatrix);
|
|
3385
|
-
var minx = Math.min(tl[0], tr[0], br[0], bl[0]);
|
|
3386
|
-
var miny = Math.min(tl[1], tr[1], br[1], bl[1]);
|
|
3387
|
-
var maxx = Math.max(tl[0], tr[0], br[0], bl[0]);
|
|
3388
|
-
var maxy = Math.max(tl[1], tr[1], br[1], bl[1]);
|
|
3389
|
-
var ix = Math.floor(minx);
|
|
3390
|
-
var iy = Math.floor(miny);
|
|
3391
|
-
var iwidth = Math.ceil(maxx - minx);
|
|
3392
|
-
var iheight = Math.ceil(maxy - miny);
|
|
3393
|
-
context.save();
|
|
3394
|
-
_this.clearRect(context, ix, iy, iwidth, iheight, config.background);
|
|
3395
|
-
context.beginPath();
|
|
3396
|
-
context.rect(ix, iy, iwidth, iheight);
|
|
3397
|
-
context.clip();
|
|
3398
|
-
// @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
|
|
3399
|
-
context.setTransform(_this.vpMatrix[0], _this.vpMatrix[1], _this.vpMatrix[4], _this.vpMatrix[5], _this.vpMatrix[12], _this.vpMatrix[13]);
|
|
3400
|
-
// draw dirty rectangle
|
|
3401
|
-
var _config$renderer$getC = config.renderer.getConfig(),
|
|
3402
|
-
enableDirtyRectangleRenderingDebug = _config$renderer$getC.enableDirtyRectangleRenderingDebug;
|
|
3403
|
-
if (enableDirtyRectangleRenderingDebug) {
|
|
3404
|
-
canvas.dispatchEvent(new gLite.CustomEvent(gLite.CanvasEvent.DIRTY_RECTANGLE, {
|
|
3405
|
-
dirtyRect: {
|
|
3406
|
-
x: ix,
|
|
3407
|
-
y: iy,
|
|
3408
|
-
width: iwidth,
|
|
3409
|
-
height: iheight
|
|
3410
|
-
}
|
|
3411
|
-
}));
|
|
4018
|
+
});
|
|
4019
|
+
var renderByZIndex = function renderByZIndex(object, context) {
|
|
4020
|
+
if (object.isVisible() && !object.isCulled()) {
|
|
4021
|
+
_this.renderDisplayObject(object, context, _this.context, _this.restoreStack);
|
|
4022
|
+
// if we did a full screen rendering last frame
|
|
4023
|
+
_this.saveDirtyAABB(object);
|
|
3412
4024
|
}
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
4025
|
+
var sorted = object.sortable.sorted || object.childNodes;
|
|
4026
|
+
// should account for z-index
|
|
4027
|
+
sorted.forEach(function (child) {
|
|
4028
|
+
renderByZIndex(child, context);
|
|
4029
|
+
});
|
|
4030
|
+
};
|
|
4031
|
+
// render at the end of frame
|
|
4032
|
+
renderingService.hooks.endFrame.tap(CanvasRendererPlugin.tag, function () {
|
|
4033
|
+
var context = contextService.getContext();
|
|
4034
|
+
// clear & clip dirty rectangle
|
|
4035
|
+
var dpr = contextService.getDPR();
|
|
4036
|
+
fromScaling(_this.dprMatrix, fromValues(dpr, dpr, 1));
|
|
4037
|
+
multiply(_this.vpMatrix, _this.dprMatrix, camera.getOrthoMatrix());
|
|
4038
|
+
if (_this.clearFullScreen) {
|
|
4039
|
+
renderByZIndex(renderingContext.root, context);
|
|
4040
|
+
} else {
|
|
4041
|
+
// merge removed AABB
|
|
4042
|
+
var dirtyRenderBounds = _this.safeMergeAABB.apply(_this, [_this.mergeDirtyAABBs(_this.renderQueue)].concat(_toConsumableArray$1(_this.removedRBushNodeAABBs.map(function (_ref2) {
|
|
4043
|
+
var minX = _ref2.minX,
|
|
4044
|
+
minY = _ref2.minY,
|
|
4045
|
+
maxX = _ref2.maxX,
|
|
4046
|
+
maxY = _ref2.maxY;
|
|
4047
|
+
var aabb = new gLite.AABB();
|
|
4048
|
+
aabb.setMinMax(fromValues(minX, minY, 0), fromValues(maxX, maxY, 0));
|
|
4049
|
+
return aabb;
|
|
4050
|
+
}))));
|
|
4051
|
+
_this.removedRBushNodeAABBs = [];
|
|
4052
|
+
if (gLite.AABB.isEmpty(dirtyRenderBounds)) {
|
|
4053
|
+
_this.renderQueue = [];
|
|
4054
|
+
return;
|
|
4055
|
+
}
|
|
4056
|
+
var dirtyRect = _this.convertAABB2Rect(dirtyRenderBounds);
|
|
4057
|
+
var x = dirtyRect.x,
|
|
4058
|
+
y = dirtyRect.y,
|
|
4059
|
+
width = dirtyRect.width,
|
|
4060
|
+
height = dirtyRect.height;
|
|
4061
|
+
var tl = transformMat4(_this.vec3a, fromValues(x, y, 0), _this.vpMatrix);
|
|
4062
|
+
var tr = transformMat4(_this.vec3b, fromValues(x + width, y, 0), _this.vpMatrix);
|
|
4063
|
+
var bl = transformMat4(_this.vec3c, fromValues(x, y + height, 0), _this.vpMatrix);
|
|
4064
|
+
var br = transformMat4(_this.vec3d, fromValues(x + width, y + height, 0), _this.vpMatrix);
|
|
4065
|
+
var minx = Math.min(tl[0], tr[0], br[0], bl[0]);
|
|
4066
|
+
var miny = Math.min(tl[1], tr[1], br[1], bl[1]);
|
|
4067
|
+
var maxx = Math.max(tl[0], tr[0], br[0], bl[0]);
|
|
4068
|
+
var maxy = Math.max(tl[1], tr[1], br[1], bl[1]);
|
|
4069
|
+
var ix = Math.floor(minx);
|
|
4070
|
+
var iy = Math.floor(miny);
|
|
4071
|
+
var iwidth = Math.ceil(maxx - minx);
|
|
4072
|
+
var iheight = Math.ceil(maxy - miny);
|
|
4073
|
+
context.save();
|
|
4074
|
+
_this.clearRect(context, ix, iy, iwidth, iheight, config.background);
|
|
4075
|
+
context.beginPath();
|
|
4076
|
+
context.rect(ix, iy, iwidth, iheight);
|
|
4077
|
+
context.clip();
|
|
4078
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
|
|
4079
|
+
context.setTransform(_this.vpMatrix[0], _this.vpMatrix[1], _this.vpMatrix[4], _this.vpMatrix[5], _this.vpMatrix[12], _this.vpMatrix[13]);
|
|
4080
|
+
// draw dirty rectangle
|
|
4081
|
+
var _config$renderer$getC = config.renderer.getConfig(),
|
|
4082
|
+
enableDirtyRectangleRenderingDebug = _config$renderer$getC.enableDirtyRectangleRenderingDebug;
|
|
4083
|
+
if (enableDirtyRectangleRenderingDebug) {
|
|
4084
|
+
canvas.dispatchEvent(new gLite.CustomEvent(gLite.CanvasEvent.DIRTY_RECTANGLE, {
|
|
4085
|
+
dirtyRect: {
|
|
4086
|
+
x: ix,
|
|
4087
|
+
y: iy,
|
|
4088
|
+
width: iwidth,
|
|
4089
|
+
height: iheight
|
|
4090
|
+
}
|
|
4091
|
+
}));
|
|
3424
4092
|
}
|
|
4093
|
+
// search objects intersect with dirty rectangle
|
|
4094
|
+
var dirtyObjects = _this.searchDirtyObjects(dirtyRenderBounds);
|
|
4095
|
+
// do rendering
|
|
4096
|
+
dirtyObjects
|
|
4097
|
+
// sort by z-index
|
|
4098
|
+
.sort(function (a, b) {
|
|
4099
|
+
return a.sortable.renderOrder - b.sortable.renderOrder;
|
|
4100
|
+
}).forEach(function (object) {
|
|
4101
|
+
// culled object should not be rendered
|
|
4102
|
+
if (object && object.isVisible() && !object.isCulled()) {
|
|
4103
|
+
_this.renderDisplayObject(object, context, _this.context, _this.restoreStack);
|
|
4104
|
+
}
|
|
4105
|
+
});
|
|
4106
|
+
context.restore();
|
|
4107
|
+
// save dirty AABBs in last frame
|
|
4108
|
+
_this.renderQueue.forEach(function (object) {
|
|
4109
|
+
_this.saveDirtyAABB(object);
|
|
4110
|
+
});
|
|
4111
|
+
// clear queue
|
|
4112
|
+
_this.renderQueue = [];
|
|
4113
|
+
}
|
|
4114
|
+
// pop restore stack, eg. root -> parent -> child
|
|
4115
|
+
_this.restoreStack.forEach(function () {
|
|
4116
|
+
context.restore();
|
|
3425
4117
|
});
|
|
4118
|
+
// clear restore stack
|
|
4119
|
+
_this.restoreStack = [];
|
|
4120
|
+
});
|
|
4121
|
+
renderingService.hooks.render.tap(CanvasRendererPlugin.tag, function (object) {
|
|
4122
|
+
if (!_this.clearFullScreen) {
|
|
4123
|
+
// render at the end of frame
|
|
4124
|
+
_this.renderQueue.push(object);
|
|
4125
|
+
}
|
|
4126
|
+
});
|
|
4127
|
+
}
|
|
4128
|
+
}, {
|
|
4129
|
+
key: "clearRect",
|
|
4130
|
+
value: function clearRect(context, x, y, width, height, background) {
|
|
4131
|
+
// clearRect is faster than fillRect @see https://stackoverflow.com/a/30830253
|
|
4132
|
+
context.clearRect(x, y, width, height);
|
|
4133
|
+
if (background) {
|
|
4134
|
+
context.fillStyle = background;
|
|
4135
|
+
context.fillRect(x, y, width, height);
|
|
4136
|
+
}
|
|
4137
|
+
}
|
|
4138
|
+
}, {
|
|
4139
|
+
key: "renderDisplayObject",
|
|
4140
|
+
value: function renderDisplayObject(object, context, canvasContext, restoreStack) {
|
|
4141
|
+
var nodeName = object.nodeName;
|
|
4142
|
+
// restore to its ancestor
|
|
4143
|
+
var parent = restoreStack[restoreStack.length - 1];
|
|
4144
|
+
if (parent && !(object.compareDocumentPosition(parent) & Node.DOCUMENT_POSITION_CONTAINS)) {
|
|
3426
4145
|
context.restore();
|
|
3427
|
-
|
|
3428
|
-
_this.renderQueue.forEach(function (object) {
|
|
3429
|
-
_this.saveDirtyAABB(object);
|
|
3430
|
-
});
|
|
3431
|
-
// clear queue
|
|
3432
|
-
_this.renderQueue = [];
|
|
4146
|
+
restoreStack.pop();
|
|
3433
4147
|
}
|
|
3434
|
-
//
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
4148
|
+
// @ts-ignore
|
|
4149
|
+
var styleRenderer = this.context.styleRendererFactory[nodeName];
|
|
4150
|
+
var generatePath = this.pathGeneratorFactory[nodeName];
|
|
4151
|
+
// clip path
|
|
4152
|
+
var clipPath = object.parsedStyle.clipPath;
|
|
4153
|
+
if (clipPath) {
|
|
4154
|
+
this.applyWorldTransform(context, clipPath);
|
|
4155
|
+
// generate path in local space
|
|
4156
|
+
var _generatePath = this.pathGeneratorFactory[clipPath.nodeName];
|
|
4157
|
+
if (_generatePath) {
|
|
4158
|
+
context.save();
|
|
4159
|
+
// save clip
|
|
4160
|
+
restoreStack.push(object);
|
|
4161
|
+
context.beginPath();
|
|
4162
|
+
_generatePath(context, clipPath.parsedStyle);
|
|
4163
|
+
context.closePath();
|
|
4164
|
+
context.clip();
|
|
4165
|
+
}
|
|
3445
4166
|
}
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
// clearRect is faster than fillRect @see https://stackoverflow.com/a/30830253
|
|
3450
|
-
context.clearRect(x, y, width, height);
|
|
3451
|
-
if (background) {
|
|
3452
|
-
context.fillStyle = background;
|
|
3453
|
-
context.fillRect(x, y, width, height);
|
|
3454
|
-
}
|
|
3455
|
-
};
|
|
3456
|
-
_proto.renderDisplayObject = function renderDisplayObject(object, context, canvasContext, restoreStack) {
|
|
3457
|
-
var nodeName = object.nodeName;
|
|
3458
|
-
// restore to its ancestor
|
|
3459
|
-
var parent = restoreStack[restoreStack.length - 1];
|
|
3460
|
-
if (parent && !(object.compareDocumentPosition(parent) & Node.DOCUMENT_POSITION_CONTAINS)) {
|
|
3461
|
-
context.restore();
|
|
3462
|
-
restoreStack.pop();
|
|
3463
|
-
}
|
|
3464
|
-
// @ts-ignore
|
|
3465
|
-
var styleRenderer = this.context.styleRendererFactory[nodeName];
|
|
3466
|
-
var generatePath = this.pathGeneratorFactory[nodeName];
|
|
3467
|
-
// clip path
|
|
3468
|
-
var clipPath = object.parsedStyle.clipPath;
|
|
3469
|
-
if (clipPath) {
|
|
3470
|
-
this.applyWorldTransform(context, clipPath);
|
|
3471
|
-
// generate path in local space
|
|
3472
|
-
var _generatePath = this.pathGeneratorFactory[clipPath.nodeName];
|
|
3473
|
-
if (_generatePath) {
|
|
4167
|
+
// fill & stroke
|
|
4168
|
+
if (styleRenderer) {
|
|
4169
|
+
this.applyWorldTransform(context, object);
|
|
3474
4170
|
context.save();
|
|
3475
|
-
//
|
|
3476
|
-
|
|
4171
|
+
// apply attributes to context
|
|
4172
|
+
this.applyAttributesToContext(context, object);
|
|
4173
|
+
}
|
|
4174
|
+
if (generatePath) {
|
|
3477
4175
|
context.beginPath();
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
4176
|
+
generatePath(context, object.parsedStyle);
|
|
4177
|
+
if (object.nodeName !== gLite.Shape.LINE && object.nodeName !== gLite.Shape.PATH && object.nodeName !== gLite.Shape.POLYLINE) {
|
|
4178
|
+
context.closePath();
|
|
4179
|
+
}
|
|
3481
4180
|
}
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
// apply attributes to context
|
|
3488
|
-
this.applyAttributesToContext(context, object);
|
|
3489
|
-
}
|
|
3490
|
-
if (generatePath) {
|
|
3491
|
-
context.beginPath();
|
|
3492
|
-
generatePath(context, object.parsedStyle);
|
|
3493
|
-
if (object.nodeName !== gLite.Shape.LINE && object.nodeName !== gLite.Shape.PATH && object.nodeName !== gLite.Shape.POLYLINE) {
|
|
3494
|
-
context.closePath();
|
|
4181
|
+
// fill & stroke
|
|
4182
|
+
if (styleRenderer) {
|
|
4183
|
+
styleRenderer.render(context, object.parsedStyle, object, canvasContext, this);
|
|
4184
|
+
// restore applied attributes, eg. shadowBlur shadowColor...
|
|
4185
|
+
context.restore();
|
|
3495
4186
|
}
|
|
4187
|
+
// finish rendering, clear dirty flag
|
|
4188
|
+
object.renderable.dirty = false;
|
|
4189
|
+
}
|
|
4190
|
+
}, {
|
|
4191
|
+
key: "convertAABB2Rect",
|
|
4192
|
+
value: function convertAABB2Rect(aabb) {
|
|
4193
|
+
var min = aabb.getMin();
|
|
4194
|
+
var max = aabb.getMax();
|
|
4195
|
+
// expand the rectangle a bit to avoid artifacts
|
|
4196
|
+
// @see https://www.yuque.com/antv/ou292n/bi8nix#ExvCu
|
|
4197
|
+
var minX = Math.floor(min[0]);
|
|
4198
|
+
var minY = Math.floor(min[1]);
|
|
4199
|
+
var maxX = Math.ceil(max[0]);
|
|
4200
|
+
var maxY = Math.ceil(max[1]);
|
|
4201
|
+
var width = maxX - minX;
|
|
4202
|
+
var height = maxY - minY;
|
|
4203
|
+
return {
|
|
4204
|
+
x: minX,
|
|
4205
|
+
y: minY,
|
|
4206
|
+
width: width,
|
|
4207
|
+
height: height
|
|
4208
|
+
};
|
|
3496
4209
|
}
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
4210
|
+
/**
|
|
4211
|
+
* TODO: merge dirty rectangles with some strategies.
|
|
4212
|
+
* For now, we just simply merge all the rectangles into one.
|
|
4213
|
+
* @see https://idom.me/articles/841.html
|
|
4214
|
+
*/
|
|
4215
|
+
}, {
|
|
4216
|
+
key: "mergeDirtyAABBs",
|
|
4217
|
+
value: function mergeDirtyAABBs(dirtyObjects) {
|
|
4218
|
+
// merge into a big AABB
|
|
4219
|
+
// TODO: skip descendant if ancestor is caculated, but compareNodePosition is really slow
|
|
4220
|
+
var aabb = new gLite.AABB();
|
|
4221
|
+
dirtyObjects.forEach(function (object) {
|
|
4222
|
+
var renderBounds = object.getRenderBounds();
|
|
4223
|
+
aabb.add(renderBounds);
|
|
4224
|
+
var dirtyRenderBounds = object.renderable.dirtyRenderBounds;
|
|
4225
|
+
if (dirtyRenderBounds) {
|
|
4226
|
+
aabb.add(dirtyRenderBounds);
|
|
4227
|
+
}
|
|
4228
|
+
});
|
|
4229
|
+
return aabb;
|
|
4230
|
+
}
|
|
4231
|
+
}, {
|
|
4232
|
+
key: "searchDirtyObjects",
|
|
4233
|
+
value: function searchDirtyObjects(dirtyRectangle) {
|
|
4234
|
+
// search in r-tree, get all affected nodes
|
|
4235
|
+
var _dirtyRectangle$getMi = dirtyRectangle.getMin(),
|
|
4236
|
+
_dirtyRectangle$getMi2 = _slicedToArray$2(_dirtyRectangle$getMi, 2),
|
|
4237
|
+
minX = _dirtyRectangle$getMi2[0],
|
|
4238
|
+
minY = _dirtyRectangle$getMi2[1];
|
|
4239
|
+
var _dirtyRectangle$getMa = dirtyRectangle.getMax(),
|
|
4240
|
+
_dirtyRectangle$getMa2 = _slicedToArray$2(_dirtyRectangle$getMa, 2),
|
|
4241
|
+
maxX = _dirtyRectangle$getMa2[0],
|
|
4242
|
+
maxY = _dirtyRectangle$getMa2[1];
|
|
4243
|
+
var rBushNodes = this.rBush.search({
|
|
4244
|
+
minX: minX,
|
|
4245
|
+
minY: minY,
|
|
4246
|
+
maxX: maxX,
|
|
4247
|
+
maxY: maxY
|
|
4248
|
+
});
|
|
4249
|
+
return rBushNodes.map(function (_ref3) {
|
|
4250
|
+
var id = _ref3.id;
|
|
4251
|
+
return gLite.runtime.displayObjectPool.getByEntity(id);
|
|
4252
|
+
});
|
|
3502
4253
|
}
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
// @see https://www.yuque.com/antv/ou292n/bi8nix#ExvCu
|
|
3511
|
-
var minX = Math.floor(min[0]);
|
|
3512
|
-
var minY = Math.floor(min[1]);
|
|
3513
|
-
var maxX = Math.ceil(max[0]);
|
|
3514
|
-
var maxY = Math.ceil(max[1]);
|
|
3515
|
-
var width = maxX - minX;
|
|
3516
|
-
var height = maxY - minY;
|
|
3517
|
-
return {
|
|
3518
|
-
x: minX,
|
|
3519
|
-
y: minY,
|
|
3520
|
-
width: width,
|
|
3521
|
-
height: height
|
|
3522
|
-
};
|
|
3523
|
-
}
|
|
3524
|
-
/**
|
|
3525
|
-
* TODO: merge dirty rectangles with some strategies.
|
|
3526
|
-
* For now, we just simply merge all the rectangles into one.
|
|
3527
|
-
* @see https://idom.me/articles/841.html
|
|
3528
|
-
*/;
|
|
3529
|
-
_proto.mergeDirtyAABBs = function mergeDirtyAABBs(dirtyObjects) {
|
|
3530
|
-
// merge into a big AABB
|
|
3531
|
-
// TODO: skip descendant if ancestor is caculated, but compareNodePosition is really slow
|
|
3532
|
-
var aabb = new gLite.AABB();
|
|
3533
|
-
dirtyObjects.forEach(function (object) {
|
|
4254
|
+
}, {
|
|
4255
|
+
key: "saveDirtyAABB",
|
|
4256
|
+
value: function saveDirtyAABB(object) {
|
|
4257
|
+
var renderable = object.renderable;
|
|
4258
|
+
if (!renderable.dirtyRenderBounds) {
|
|
4259
|
+
renderable.dirtyRenderBounds = new gLite.AABB();
|
|
4260
|
+
}
|
|
3534
4261
|
var renderBounds = object.getRenderBounds();
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
aabb.add(dirtyRenderBounds);
|
|
4262
|
+
if (renderBounds) {
|
|
4263
|
+
// save last dirty aabb
|
|
4264
|
+
renderable.dirtyRenderBounds.update(renderBounds.center, renderBounds.halfExtents);
|
|
3539
4265
|
}
|
|
3540
|
-
});
|
|
3541
|
-
return aabb;
|
|
3542
|
-
};
|
|
3543
|
-
_proto.searchDirtyObjects = function searchDirtyObjects(dirtyRectangle) {
|
|
3544
|
-
// search in r-tree, get all affected nodes
|
|
3545
|
-
var _dirtyRectangle$getMi = dirtyRectangle.getMin(),
|
|
3546
|
-
minX = _dirtyRectangle$getMi[0],
|
|
3547
|
-
minY = _dirtyRectangle$getMi[1];
|
|
3548
|
-
var _dirtyRectangle$getMa = dirtyRectangle.getMax(),
|
|
3549
|
-
maxX = _dirtyRectangle$getMa[0],
|
|
3550
|
-
maxY = _dirtyRectangle$getMa[1];
|
|
3551
|
-
var rBushNodes = this.rBush.search({
|
|
3552
|
-
minX: minX,
|
|
3553
|
-
minY: minY,
|
|
3554
|
-
maxX: maxX,
|
|
3555
|
-
maxY: maxY
|
|
3556
|
-
});
|
|
3557
|
-
return rBushNodes.map(function (_ref3) {
|
|
3558
|
-
var id = _ref3.id;
|
|
3559
|
-
return gLite.runtime.displayObjectPool.getByEntity(id);
|
|
3560
|
-
});
|
|
3561
|
-
};
|
|
3562
|
-
_proto.saveDirtyAABB = function saveDirtyAABB(object) {
|
|
3563
|
-
var renderable = object.renderable;
|
|
3564
|
-
if (!renderable.dirtyRenderBounds) {
|
|
3565
|
-
renderable.dirtyRenderBounds = new gLite.AABB();
|
|
3566
|
-
}
|
|
3567
|
-
var renderBounds = object.getRenderBounds();
|
|
3568
|
-
if (renderBounds) {
|
|
3569
|
-
// save last dirty aabb
|
|
3570
|
-
renderable.dirtyRenderBounds.update(renderBounds.center, renderBounds.halfExtents);
|
|
3571
4266
|
}
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
var
|
|
3610
|
-
var
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
4267
|
+
/**
|
|
4268
|
+
* TODO: batch the same global attributes
|
|
4269
|
+
*/
|
|
4270
|
+
}, {
|
|
4271
|
+
key: "applyAttributesToContext",
|
|
4272
|
+
value: function applyAttributesToContext(context, object) {
|
|
4273
|
+
var _object$parsedStyle = object.parsedStyle,
|
|
4274
|
+
stroke = _object$parsedStyle.stroke,
|
|
4275
|
+
fill = _object$parsedStyle.fill,
|
|
4276
|
+
opacity = _object$parsedStyle.opacity,
|
|
4277
|
+
lineDash = _object$parsedStyle.lineDash,
|
|
4278
|
+
lineDashOffset = _object$parsedStyle.lineDashOffset;
|
|
4279
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/setLineDash
|
|
4280
|
+
if (lineDash) {
|
|
4281
|
+
context.setLineDash(lineDash);
|
|
4282
|
+
}
|
|
4283
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/lineDashOffset
|
|
4284
|
+
if (!isNil(lineDashOffset)) {
|
|
4285
|
+
context.lineDashOffset = lineDashOffset;
|
|
4286
|
+
}
|
|
4287
|
+
if (!isNil(opacity)) {
|
|
4288
|
+
context.globalAlpha *= opacity;
|
|
4289
|
+
}
|
|
4290
|
+
if (!isNil(stroke) && !Array.isArray(stroke) && !stroke.isNone) {
|
|
4291
|
+
context.strokeStyle = object.attributes.stroke;
|
|
4292
|
+
}
|
|
4293
|
+
if (!isNil(fill) && !Array.isArray(fill) && !fill.isNone) {
|
|
4294
|
+
context.fillStyle = object.attributes.fill;
|
|
4295
|
+
}
|
|
4296
|
+
}
|
|
4297
|
+
}, {
|
|
4298
|
+
key: "applyWorldTransform",
|
|
4299
|
+
value: function applyWorldTransform(context, object, matrix) {
|
|
4300
|
+
var tx = 0;
|
|
4301
|
+
var ty = 0;
|
|
4302
|
+
var _ref4 = object.parsedStyle || {},
|
|
4303
|
+
anchor = _ref4.anchor;
|
|
4304
|
+
var anchorX = anchor && anchor[0] || 0;
|
|
4305
|
+
var anchorY = anchor && anchor[1] || 0;
|
|
4306
|
+
if (anchorX !== 0 || anchorY !== 0) {
|
|
4307
|
+
var bounds = object.getGeometryBounds();
|
|
4308
|
+
var width = bounds && bounds.halfExtents[0] * 2 || 0;
|
|
4309
|
+
var height = bounds && bounds.halfExtents[1] * 2 || 0;
|
|
4310
|
+
tx = -(anchorX * width);
|
|
4311
|
+
ty = -(anchorY * height);
|
|
4312
|
+
}
|
|
4313
|
+
// apply clip shape's RTS
|
|
4314
|
+
if (matrix) {
|
|
4315
|
+
copy(this.tmpMat4, object.getLocalTransform());
|
|
4316
|
+
this.vec3a[0] = tx;
|
|
4317
|
+
this.vec3a[1] = ty;
|
|
4318
|
+
this.vec3a[2] = 0;
|
|
4319
|
+
translate(this.tmpMat4, this.tmpMat4, this.vec3a);
|
|
4320
|
+
multiply(this.tmpMat4, matrix, this.tmpMat4);
|
|
4321
|
+
multiply(this.tmpMat4, this.vpMatrix, this.tmpMat4);
|
|
4322
|
+
} else {
|
|
4323
|
+
// apply RTS transformation in world space
|
|
4324
|
+
copy(this.tmpMat4, object.getWorldTransform());
|
|
4325
|
+
this.vec3a[0] = tx;
|
|
4326
|
+
this.vec3a[1] = ty;
|
|
4327
|
+
this.vec3a[2] = 0;
|
|
4328
|
+
translate(this.tmpMat4, this.tmpMat4, this.vec3a);
|
|
4329
|
+
multiply(this.tmpMat4, this.vpMatrix, this.tmpMat4);
|
|
4330
|
+
}
|
|
4331
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
|
|
4332
|
+
context.setTransform(this.tmpMat4[0], this.tmpMat4[1], this.tmpMat4[4], this.tmpMat4[5], this.tmpMat4[12], this.tmpMat4[13]);
|
|
4333
|
+
}
|
|
4334
|
+
}, {
|
|
4335
|
+
key: "safeMergeAABB",
|
|
4336
|
+
value: function safeMergeAABB() {
|
|
4337
|
+
var merged = new gLite.AABB();
|
|
4338
|
+
for (var _len = arguments.length, aabbs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
4339
|
+
aabbs[_key] = arguments[_key];
|
|
4340
|
+
}
|
|
4341
|
+
aabbs.forEach(function (aabb) {
|
|
4342
|
+
merged.add(aabb);
|
|
4343
|
+
});
|
|
4344
|
+
return merged;
|
|
3640
4345
|
}
|
|
3641
|
-
|
|
3642
|
-
merged.add(aabb);
|
|
3643
|
-
});
|
|
3644
|
-
return merged;
|
|
3645
|
-
};
|
|
4346
|
+
}]);
|
|
3646
4347
|
return CanvasRendererPlugin;
|
|
3647
4348
|
}();
|
|
3648
4349
|
CanvasRendererPlugin.tag = 'CanvasRenderer';
|
|
3649
4350
|
var DefaultRenderer = /*#__PURE__*/function () {
|
|
3650
4351
|
function DefaultRenderer(imagePool) {
|
|
4352
|
+
_classCallCheck$3(this, DefaultRenderer);
|
|
3651
4353
|
this.imagePool = void 0;
|
|
3652
4354
|
this.imagePool = imagePool;
|
|
3653
4355
|
}
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
if (hasStroke) {
|
|
3689
|
-
context.globalAlpha = opacity * strokeOpacity;
|
|
3690
|
-
context.lineWidth = lineWidth;
|
|
3691
|
-
if (!isNil(miterLimit)) {
|
|
3692
|
-
context.miterLimit = miterLimit;
|
|
3693
|
-
}
|
|
3694
|
-
if (!isNil(lineCap)) {
|
|
3695
|
-
context.lineCap = lineCap;
|
|
3696
|
-
}
|
|
3697
|
-
if (!isNil(lineJoin)) {
|
|
3698
|
-
context.lineJoin = lineJoin;
|
|
4356
|
+
_createClass$3(DefaultRenderer, [{
|
|
4357
|
+
key: "render",
|
|
4358
|
+
value: function render(context, parsedStyle, object, canvasContext, plugin) {
|
|
4359
|
+
var fill = parsedStyle.fill,
|
|
4360
|
+
fillRule = parsedStyle.fillRule,
|
|
4361
|
+
opacity = parsedStyle.opacity,
|
|
4362
|
+
fillOpacity = parsedStyle.fillOpacity,
|
|
4363
|
+
stroke = parsedStyle.stroke,
|
|
4364
|
+
strokeOpacity = parsedStyle.strokeOpacity,
|
|
4365
|
+
lineWidth = parsedStyle.lineWidth,
|
|
4366
|
+
lineCap = parsedStyle.lineCap,
|
|
4367
|
+
lineJoin = parsedStyle.lineJoin,
|
|
4368
|
+
shadowType = parsedStyle.shadowType,
|
|
4369
|
+
shadowColor = parsedStyle.shadowColor,
|
|
4370
|
+
shadowBlur = parsedStyle.shadowBlur,
|
|
4371
|
+
filter = parsedStyle.filter,
|
|
4372
|
+
miterLimit = parsedStyle.miterLimit;
|
|
4373
|
+
var hasFill = !isNil(fill) && !fill.isNone;
|
|
4374
|
+
var hasStroke = !isNil(stroke) && !stroke.isNone && lineWidth > 0;
|
|
4375
|
+
var isFillTransparent = fill.alpha === 0;
|
|
4376
|
+
var hasFilter = !!(filter && filter.length);
|
|
4377
|
+
var hasShadow = !isNil(shadowColor) && shadowBlur > 0;
|
|
4378
|
+
var nodeName = object.nodeName;
|
|
4379
|
+
var isInnerShadow = shadowType === 'inner';
|
|
4380
|
+
var shouldDrawShadowWithStroke = hasStroke && hasShadow && (nodeName === gLite.Shape.PATH || nodeName === gLite.Shape.LINE || nodeName === gLite.Shape.POLYLINE || isFillTransparent || isInnerShadow);
|
|
4381
|
+
if (hasFill) {
|
|
4382
|
+
context.globalAlpha = opacity * fillOpacity;
|
|
4383
|
+
if (!shouldDrawShadowWithStroke) {
|
|
4384
|
+
setShadowAndFilter(object, context, hasShadow);
|
|
4385
|
+
}
|
|
4386
|
+
this.fill(context, object, fill, fillRule, canvasContext, plugin);
|
|
4387
|
+
if (!shouldDrawShadowWithStroke) {
|
|
4388
|
+
this.clearShadowAndFilter(context, hasFilter, hasShadow);
|
|
4389
|
+
}
|
|
3699
4390
|
}
|
|
3700
|
-
if (
|
|
3701
|
-
|
|
3702
|
-
|
|
4391
|
+
if (hasStroke) {
|
|
4392
|
+
context.globalAlpha = opacity * strokeOpacity;
|
|
4393
|
+
context.lineWidth = lineWidth;
|
|
4394
|
+
if (!isNil(miterLimit)) {
|
|
4395
|
+
context.miterLimit = miterLimit;
|
|
3703
4396
|
}
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
this.stroke(context, object, stroke, canvasContext, plugin);
|
|
3707
|
-
context.globalCompositeOperation = 'source-over';
|
|
3708
|
-
this.clearShadowAndFilter(context, hasFilter, true);
|
|
4397
|
+
if (!isNil(lineCap)) {
|
|
4398
|
+
context.lineCap = lineCap;
|
|
3709
4399
|
}
|
|
4400
|
+
if (!isNil(lineJoin)) {
|
|
4401
|
+
context.lineJoin = lineJoin;
|
|
4402
|
+
}
|
|
4403
|
+
if (shouldDrawShadowWithStroke) {
|
|
4404
|
+
if (isInnerShadow) {
|
|
4405
|
+
context.globalCompositeOperation = 'source-atop';
|
|
4406
|
+
}
|
|
4407
|
+
setShadowAndFilter(object, context, true);
|
|
4408
|
+
if (isInnerShadow) {
|
|
4409
|
+
this.stroke(context, object, stroke, canvasContext, plugin);
|
|
4410
|
+
context.globalCompositeOperation = 'source-over';
|
|
4411
|
+
this.clearShadowAndFilter(context, hasFilter, true);
|
|
4412
|
+
}
|
|
4413
|
+
}
|
|
4414
|
+
this.stroke(context, object, stroke, canvasContext, plugin);
|
|
3710
4415
|
}
|
|
3711
|
-
this.stroke(context, object, stroke, canvasContext, plugin);
|
|
3712
|
-
}
|
|
3713
|
-
};
|
|
3714
|
-
_proto.clearShadowAndFilter = function clearShadowAndFilter(context, hasFilter, hasShadow) {
|
|
3715
|
-
if (hasShadow) {
|
|
3716
|
-
context.shadowColor = 'transparent';
|
|
3717
|
-
context.shadowBlur = 0;
|
|
3718
4416
|
}
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
if (
|
|
3723
|
-
context.
|
|
4417
|
+
}, {
|
|
4418
|
+
key: "clearShadowAndFilter",
|
|
4419
|
+
value: function clearShadowAndFilter(context, hasFilter, hasShadow) {
|
|
4420
|
+
if (hasShadow) {
|
|
4421
|
+
context.shadowColor = 'transparent';
|
|
4422
|
+
context.shadowBlur = 0;
|
|
4423
|
+
}
|
|
4424
|
+
if (hasFilter) {
|
|
4425
|
+
// save drop-shadow filter
|
|
4426
|
+
var oldFilter = context.filter;
|
|
4427
|
+
if (!isNil(oldFilter) && oldFilter.indexOf('drop-shadow') > -1) {
|
|
4428
|
+
context.filter = oldFilter.replace(/drop-shadow\([^)]*\)/, '').trim() || 'none';
|
|
4429
|
+
}
|
|
3724
4430
|
}
|
|
3725
4431
|
}
|
|
3726
|
-
}
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
4432
|
+
}, {
|
|
4433
|
+
key: "fill",
|
|
4434
|
+
value: function fill(context, object, _fill, fillRule, canvasContext, plugin) {
|
|
4435
|
+
var _this = this;
|
|
4436
|
+
if (Array.isArray(_fill)) {
|
|
4437
|
+
_fill.forEach(function (gradient) {
|
|
4438
|
+
context.fillStyle = _this.getColor(gradient, object, context);
|
|
4439
|
+
context.fill(fillRule);
|
|
4440
|
+
});
|
|
4441
|
+
} else {
|
|
4442
|
+
if (gLite.isPattern(_fill)) {
|
|
4443
|
+
context.fillStyle = this.getPattern(_fill, object, context, canvasContext, plugin);
|
|
4444
|
+
}
|
|
3732
4445
|
context.fill(fillRule);
|
|
3733
|
-
});
|
|
3734
|
-
} else {
|
|
3735
|
-
if (gLite.isPattern(_fill)) {
|
|
3736
|
-
context.fillStyle = this.getPattern(_fill, object, context, canvasContext, plugin);
|
|
3737
4446
|
}
|
|
3738
|
-
context.fill(fillRule);
|
|
3739
4447
|
}
|
|
3740
|
-
}
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
4448
|
+
}, {
|
|
4449
|
+
key: "stroke",
|
|
4450
|
+
value: function stroke(context, object, _stroke, canvasContext, plugin) {
|
|
4451
|
+
var _this2 = this;
|
|
4452
|
+
if (Array.isArray(_stroke)) {
|
|
4453
|
+
_stroke.forEach(function (gradient) {
|
|
4454
|
+
context.strokeStyle = _this2.getColor(gradient, object, context);
|
|
4455
|
+
context.stroke();
|
|
4456
|
+
});
|
|
4457
|
+
} else {
|
|
4458
|
+
if (gLite.isPattern(_stroke)) {
|
|
4459
|
+
context.strokeStyle = this.getPattern(_stroke, object, context, canvasContext, plugin);
|
|
4460
|
+
}
|
|
3746
4461
|
context.stroke();
|
|
3747
|
-
});
|
|
3748
|
-
} else {
|
|
3749
|
-
if (gLite.isPattern(_stroke)) {
|
|
3750
|
-
context.strokeStyle = this.getPattern(_stroke, object, context, canvasContext, plugin);
|
|
3751
4462
|
}
|
|
3752
|
-
context.stroke();
|
|
3753
4463
|
}
|
|
3754
|
-
}
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
4464
|
+
}, {
|
|
4465
|
+
key: "getPattern",
|
|
4466
|
+
value: function getPattern(pattern, object, context, canvasContext, plugin) {
|
|
4467
|
+
var $offscreenCanvas;
|
|
4468
|
+
var dpr;
|
|
4469
|
+
if (pattern.image instanceof gLite.Rect) {
|
|
4470
|
+
var _pattern$image$parsed = pattern.image.parsedStyle,
|
|
4471
|
+
width = _pattern$image$parsed.width,
|
|
4472
|
+
height = _pattern$image$parsed.height;
|
|
4473
|
+
dpr = canvasContext.contextService.getDPR();
|
|
4474
|
+
var offscreenCanvas = canvasContext.config.offscreenCanvas;
|
|
4475
|
+
$offscreenCanvas = gLite.runtime.offscreenCanvas.getOrCreateCanvas(offscreenCanvas);
|
|
4476
|
+
$offscreenCanvas.width = width * dpr;
|
|
4477
|
+
$offscreenCanvas.height = height * dpr;
|
|
4478
|
+
var offscreenCanvasContext = gLite.runtime.offscreenCanvas.getOrCreateContext(offscreenCanvas);
|
|
4479
|
+
var restoreStack = [];
|
|
4480
|
+
// offscreenCanvasContext.scale(1 / dpr, 1 / dpr);
|
|
4481
|
+
pattern.image.forEach(function (object) {
|
|
4482
|
+
plugin.renderDisplayObject(object, offscreenCanvasContext, canvasContext, restoreStack);
|
|
4483
|
+
});
|
|
4484
|
+
restoreStack.forEach(function () {
|
|
4485
|
+
offscreenCanvasContext.restore();
|
|
4486
|
+
});
|
|
4487
|
+
}
|
|
4488
|
+
var canvasPattern = this.imagePool.getOrCreatePatternSync(pattern, context, $offscreenCanvas, dpr, function () {
|
|
4489
|
+
// set dirty rectangle flag
|
|
4490
|
+
object.renderable.dirty = true;
|
|
4491
|
+
canvasContext.renderingService.dirtify();
|
|
3775
4492
|
});
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
}
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
}
|
|
3797
|
-
return color;
|
|
3798
|
-
};
|
|
4493
|
+
return canvasPattern;
|
|
4494
|
+
}
|
|
4495
|
+
}, {
|
|
4496
|
+
key: "getColor",
|
|
4497
|
+
value: function getColor(parsedColor, object, context) {
|
|
4498
|
+
var color;
|
|
4499
|
+
if (parsedColor.type === gLite.GradientType.LinearGradient || parsedColor.type === gLite.GradientType.RadialGradient) {
|
|
4500
|
+
var bounds = object.getGeometryBounds();
|
|
4501
|
+
var width = bounds && bounds.halfExtents[0] * 2 || 1;
|
|
4502
|
+
var height = bounds && bounds.halfExtents[1] * 2 || 1;
|
|
4503
|
+
color = this.imagePool.getOrCreateGradient(_objectSpread2(_objectSpread2({
|
|
4504
|
+
type: parsedColor.type
|
|
4505
|
+
}, parsedColor.value), {}, {
|
|
4506
|
+
width: width,
|
|
4507
|
+
height: height
|
|
4508
|
+
}), context);
|
|
4509
|
+
}
|
|
4510
|
+
return color;
|
|
4511
|
+
}
|
|
4512
|
+
}]);
|
|
3799
4513
|
return DefaultRenderer;
|
|
3800
4514
|
}();
|
|
3801
4515
|
/**
|
|
@@ -3821,246 +4535,275 @@
|
|
|
3821
4535
|
}
|
|
3822
4536
|
var ImageRenderer = /*#__PURE__*/function () {
|
|
3823
4537
|
function ImageRenderer(imagePool) {
|
|
4538
|
+
_classCallCheck$3(this, ImageRenderer);
|
|
3824
4539
|
this.imagePool = void 0;
|
|
3825
4540
|
this.imagePool = imagePool;
|
|
3826
4541
|
}
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
4542
|
+
_createClass$3(ImageRenderer, [{
|
|
4543
|
+
key: "render",
|
|
4544
|
+
value: function render(context, parsedStyle, object) {
|
|
4545
|
+
var width = parsedStyle.width,
|
|
4546
|
+
height = parsedStyle.height,
|
|
4547
|
+
img = parsedStyle.img,
|
|
4548
|
+
shadowColor = parsedStyle.shadowColor,
|
|
4549
|
+
shadowBlur = parsedStyle.shadowBlur;
|
|
4550
|
+
var image;
|
|
4551
|
+
var iw = width;
|
|
4552
|
+
var ih = height;
|
|
4553
|
+
if (isString(img)) {
|
|
4554
|
+
// image has been loaded in `mounted` hook
|
|
4555
|
+
image = this.imagePool.getImageSync(img);
|
|
4556
|
+
} else {
|
|
4557
|
+
iw || (iw = img.width);
|
|
4558
|
+
ih || (ih = img.height);
|
|
4559
|
+
image = img;
|
|
4560
|
+
}
|
|
4561
|
+
if (image) {
|
|
4562
|
+
var hasShadow = !isNil(shadowColor) && shadowBlur > 0;
|
|
4563
|
+
setShadowAndFilter(object, context, hasShadow);
|
|
4564
|
+
// node-canvas will throw the following err:
|
|
4565
|
+
// Error: Image given has not completed loading
|
|
4566
|
+
try {
|
|
4567
|
+
context.drawImage(image, 0, 0, iw, ih);
|
|
4568
|
+
} catch (e) {}
|
|
4569
|
+
}
|
|
3853
4570
|
}
|
|
3854
|
-
};
|
|
4571
|
+
}]);
|
|
3855
4572
|
return ImageRenderer;
|
|
3856
4573
|
}();
|
|
3857
4574
|
var TextRenderer = /*#__PURE__*/function () {
|
|
3858
|
-
function TextRenderer() {
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
context.
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
if (textBaseline === 'middle') {
|
|
3893
|
-
linePositionY = -height / 2 - lineHeight / 2;
|
|
3894
|
-
} else if (textBaseline === 'bottom' || textBaseline === 'alphabetic' || textBaseline === 'ideographic') {
|
|
3895
|
-
linePositionY = -height;
|
|
3896
|
-
} else if (textBaseline === 'top' || textBaseline === 'hanging') {
|
|
3897
|
-
linePositionY = -lineHeight;
|
|
3898
|
-
}
|
|
3899
|
-
// account for dx & dy
|
|
3900
|
-
var offsetX = dx || 0;
|
|
3901
|
-
linePositionY += dy || 0;
|
|
3902
|
-
var hasShadow = !isNil(shadowColor) && shadowBlur > 0;
|
|
3903
|
-
setShadowAndFilter(object, context, hasShadow);
|
|
3904
|
-
// draw lines line by line
|
|
3905
|
-
for (var i = 0; i < lines.length; i++) {
|
|
3906
|
-
var linePositionX = lineWidth / 2 + offsetX;
|
|
3907
|
-
linePositionY += lineHeight;
|
|
3908
|
-
// no need to re-position X, cause we already set text align
|
|
3909
|
-
// @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textAlign
|
|
3910
|
-
if (!isNil(stroke) && !stroke.isNone && lineWidth) {
|
|
3911
|
-
this.drawLetterSpacing(context, lines[i], lineMetrics[i], textAlign, linePositionX, linePositionY, letterSpacing, fillOpacity, strokeOpacity, opacity, true);
|
|
3912
|
-
}
|
|
3913
|
-
if (!isNil(fill)) {
|
|
3914
|
-
this.drawLetterSpacing(context, lines[i], lineMetrics[i], textAlign, linePositionX, linePositionY, letterSpacing, fillOpacity, strokeOpacity, opacity);
|
|
4575
|
+
function TextRenderer() {
|
|
4576
|
+
_classCallCheck$3(this, TextRenderer);
|
|
4577
|
+
}
|
|
4578
|
+
_createClass$3(TextRenderer, [{
|
|
4579
|
+
key: "render",
|
|
4580
|
+
value: function render(context, parsedStyle, object) {
|
|
4581
|
+
var lineWidth = parsedStyle.lineWidth,
|
|
4582
|
+
textAlign = parsedStyle.textAlign,
|
|
4583
|
+
textBaseline = parsedStyle.textBaseline,
|
|
4584
|
+
lineJoin = parsedStyle.lineJoin,
|
|
4585
|
+
miterLimit = parsedStyle.miterLimit,
|
|
4586
|
+
letterSpacing = parsedStyle.letterSpacing,
|
|
4587
|
+
stroke = parsedStyle.stroke,
|
|
4588
|
+
fill = parsedStyle.fill,
|
|
4589
|
+
fillOpacity = parsedStyle.fillOpacity,
|
|
4590
|
+
strokeOpacity = parsedStyle.strokeOpacity,
|
|
4591
|
+
opacity = parsedStyle.opacity,
|
|
4592
|
+
metrics = parsedStyle.metrics,
|
|
4593
|
+
dx = parsedStyle.dx,
|
|
4594
|
+
dy = parsedStyle.dy,
|
|
4595
|
+
shadowColor = parsedStyle.shadowColor,
|
|
4596
|
+
shadowBlur = parsedStyle.shadowBlur;
|
|
4597
|
+
var font = metrics.font,
|
|
4598
|
+
lines = metrics.lines,
|
|
4599
|
+
height = metrics.height,
|
|
4600
|
+
lineHeight = metrics.lineHeight,
|
|
4601
|
+
lineMetrics = metrics.lineMetrics;
|
|
4602
|
+
context.font = font;
|
|
4603
|
+
context.lineWidth = lineWidth;
|
|
4604
|
+
context.textAlign = textAlign === 'middle' ? 'center' : textAlign;
|
|
4605
|
+
context.textBaseline = textBaseline;
|
|
4606
|
+
context.lineJoin = lineJoin;
|
|
4607
|
+
if (!isNil(miterLimit)) {
|
|
4608
|
+
context.miterLimit = miterLimit;
|
|
3915
4609
|
}
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
var currentWidth = 0;
|
|
3943
|
-
for (var i = 0; i < stringArray.length; ++i) {
|
|
3944
|
-
var currentChar = stringArray[i];
|
|
3945
|
-
if (isStroke) {
|
|
3946
|
-
this.strokeText(context, currentChar, currentPosition, y, strokeOpacity);
|
|
3947
|
-
} else {
|
|
3948
|
-
this.fillText(context, currentChar, currentPosition, y, fillOpacity, opacity);
|
|
4610
|
+
var linePositionY = 0;
|
|
4611
|
+
// handle vertical text baseline
|
|
4612
|
+
if (textBaseline === 'middle') {
|
|
4613
|
+
linePositionY = -height / 2 - lineHeight / 2;
|
|
4614
|
+
} else if (textBaseline === 'bottom' || textBaseline === 'alphabetic' || textBaseline === 'ideographic') {
|
|
4615
|
+
linePositionY = -height;
|
|
4616
|
+
} else if (textBaseline === 'top' || textBaseline === 'hanging') {
|
|
4617
|
+
linePositionY = -lineHeight;
|
|
4618
|
+
}
|
|
4619
|
+
// account for dx & dy
|
|
4620
|
+
var offsetX = dx || 0;
|
|
4621
|
+
linePositionY += dy || 0;
|
|
4622
|
+
var hasShadow = !isNil(shadowColor) && shadowBlur > 0;
|
|
4623
|
+
setShadowAndFilter(object, context, hasShadow);
|
|
4624
|
+
// draw lines line by line
|
|
4625
|
+
for (var i = 0; i < lines.length; i++) {
|
|
4626
|
+
var linePositionX = lineWidth / 2 + offsetX;
|
|
4627
|
+
linePositionY += lineHeight;
|
|
4628
|
+
// no need to re-position X, cause we already set text align
|
|
4629
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textAlign
|
|
4630
|
+
if (!isNil(stroke) && !stroke.isNone && lineWidth) {
|
|
4631
|
+
this.drawLetterSpacing(context, lines[i], lineMetrics[i], textAlign, linePositionX, linePositionY, letterSpacing, fillOpacity, strokeOpacity, opacity, true);
|
|
4632
|
+
}
|
|
4633
|
+
if (!isNil(fill)) {
|
|
4634
|
+
this.drawLetterSpacing(context, lines[i], lineMetrics[i], textAlign, linePositionX, linePositionY, letterSpacing, fillOpacity, strokeOpacity, opacity);
|
|
4635
|
+
}
|
|
3949
4636
|
}
|
|
3950
|
-
currentWidth = context.measureText(text.substring(i + 1)).width;
|
|
3951
|
-
currentPosition += previousWidth - currentWidth + letterSpacing;
|
|
3952
|
-
previousWidth = currentWidth;
|
|
3953
|
-
}
|
|
3954
|
-
context.textAlign = currentTextAlign;
|
|
3955
|
-
};
|
|
3956
|
-
_proto.fillText = function fillText(context, text, x, y, fillOpacity, opacity) {
|
|
3957
|
-
var currentGlobalAlpha;
|
|
3958
|
-
var applyOpacity = !isNil(fillOpacity) && fillOpacity !== 1;
|
|
3959
|
-
if (applyOpacity) {
|
|
3960
|
-
currentGlobalAlpha = context.globalAlpha;
|
|
3961
|
-
context.globalAlpha = fillOpacity * opacity;
|
|
3962
4637
|
}
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
4638
|
+
}, {
|
|
4639
|
+
key: "drawLetterSpacing",
|
|
4640
|
+
value: function drawLetterSpacing(context, text, lineMetrics, textAlign, x, y, letterSpacing, fillOpacity, strokeOpacity, opacity) {
|
|
4641
|
+
var isStroke = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : false;
|
|
4642
|
+
// letterSpacing of 0 means normal, render all texts directly
|
|
4643
|
+
if (letterSpacing === 0) {
|
|
4644
|
+
if (isStroke) {
|
|
4645
|
+
this.strokeText(context, text, x, y, strokeOpacity);
|
|
4646
|
+
} else {
|
|
4647
|
+
this.fillText(context, text, x, y, fillOpacity, opacity);
|
|
4648
|
+
}
|
|
4649
|
+
return;
|
|
4650
|
+
}
|
|
4651
|
+
// draw text using left align
|
|
4652
|
+
var currentTextAlign = context.textAlign;
|
|
4653
|
+
context.textAlign = 'left';
|
|
4654
|
+
var currentPosition = x;
|
|
4655
|
+
if (textAlign === 'center' || textAlign === 'middle') {
|
|
4656
|
+
currentPosition = x - lineMetrics.width / 2;
|
|
4657
|
+
} else if (textAlign === 'right' || textAlign === 'end') {
|
|
4658
|
+
currentPosition = x - lineMetrics.width;
|
|
4659
|
+
}
|
|
4660
|
+
var stringArray = Array.from(text);
|
|
4661
|
+
var previousWidth = context.measureText(text).width;
|
|
4662
|
+
var currentWidth = 0;
|
|
4663
|
+
for (var i = 0; i < stringArray.length; ++i) {
|
|
4664
|
+
var currentChar = stringArray[i];
|
|
4665
|
+
if (isStroke) {
|
|
4666
|
+
this.strokeText(context, currentChar, currentPosition, y, strokeOpacity);
|
|
4667
|
+
} else {
|
|
4668
|
+
this.fillText(context, currentChar, currentPosition, y, fillOpacity, opacity);
|
|
4669
|
+
}
|
|
4670
|
+
currentWidth = context.measureText(text.substring(i + 1)).width;
|
|
4671
|
+
currentPosition += previousWidth - currentWidth + letterSpacing;
|
|
4672
|
+
previousWidth = currentWidth;
|
|
4673
|
+
}
|
|
4674
|
+
context.textAlign = currentTextAlign;
|
|
3966
4675
|
}
|
|
3967
|
-
}
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
4676
|
+
}, {
|
|
4677
|
+
key: "fillText",
|
|
4678
|
+
value: function fillText(context, text, x, y, fillOpacity, opacity) {
|
|
4679
|
+
var currentGlobalAlpha;
|
|
4680
|
+
var applyOpacity = !isNil(fillOpacity) && fillOpacity !== 1;
|
|
4681
|
+
if (applyOpacity) {
|
|
4682
|
+
currentGlobalAlpha = context.globalAlpha;
|
|
4683
|
+
context.globalAlpha = fillOpacity * opacity;
|
|
4684
|
+
}
|
|
4685
|
+
context.fillText(text, x, y);
|
|
4686
|
+
if (applyOpacity) {
|
|
4687
|
+
context.globalAlpha = currentGlobalAlpha;
|
|
4688
|
+
}
|
|
3974
4689
|
}
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
4690
|
+
}, {
|
|
4691
|
+
key: "strokeText",
|
|
4692
|
+
value: function strokeText(context, text, x, y, strokeOpacity) {
|
|
4693
|
+
var currentGlobalAlpha;
|
|
4694
|
+
var applyOpacity = !isNil(strokeOpacity) && strokeOpacity !== 1;
|
|
4695
|
+
if (applyOpacity) {
|
|
4696
|
+
currentGlobalAlpha = context.globalAlpha;
|
|
4697
|
+
context.globalAlpha = strokeOpacity;
|
|
4698
|
+
}
|
|
4699
|
+
context.strokeText(text, x, y);
|
|
4700
|
+
if (applyOpacity) {
|
|
4701
|
+
context.globalAlpha = currentGlobalAlpha;
|
|
4702
|
+
}
|
|
3978
4703
|
}
|
|
3979
|
-
};
|
|
4704
|
+
}]);
|
|
3980
4705
|
return TextRenderer;
|
|
3981
4706
|
}();
|
|
3982
4707
|
var RectRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
3983
|
-
|
|
4708
|
+
_inherits$3(RectRenderer, _DefaultRenderer);
|
|
4709
|
+
var _super = _createSuper$3(RectRenderer);
|
|
3984
4710
|
function RectRenderer() {
|
|
3985
|
-
|
|
4711
|
+
_classCallCheck$3(this, RectRenderer);
|
|
4712
|
+
return _super.apply(this, arguments);
|
|
3986
4713
|
}
|
|
3987
|
-
return RectRenderer;
|
|
4714
|
+
return _createClass$3(RectRenderer);
|
|
3988
4715
|
}(DefaultRenderer);
|
|
3989
4716
|
var CircleRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
3990
|
-
|
|
4717
|
+
_inherits$3(CircleRenderer, _DefaultRenderer);
|
|
4718
|
+
var _super = _createSuper$3(CircleRenderer);
|
|
3991
4719
|
function CircleRenderer() {
|
|
3992
|
-
|
|
4720
|
+
_classCallCheck$3(this, CircleRenderer);
|
|
4721
|
+
return _super.apply(this, arguments);
|
|
3993
4722
|
}
|
|
3994
|
-
return CircleRenderer;
|
|
4723
|
+
return _createClass$3(CircleRenderer);
|
|
3995
4724
|
}(DefaultRenderer);
|
|
3996
4725
|
var EllipseRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
3997
|
-
|
|
4726
|
+
_inherits$3(EllipseRenderer, _DefaultRenderer);
|
|
4727
|
+
var _super = _createSuper$3(EllipseRenderer);
|
|
3998
4728
|
function EllipseRenderer() {
|
|
3999
|
-
|
|
4729
|
+
_classCallCheck$3(this, EllipseRenderer);
|
|
4730
|
+
return _super.apply(this, arguments);
|
|
4000
4731
|
}
|
|
4001
|
-
return EllipseRenderer;
|
|
4732
|
+
return _createClass$3(EllipseRenderer);
|
|
4002
4733
|
}(DefaultRenderer);
|
|
4003
4734
|
var LineRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
4004
|
-
|
|
4735
|
+
_inherits$3(LineRenderer, _DefaultRenderer);
|
|
4736
|
+
var _super = _createSuper$3(LineRenderer);
|
|
4005
4737
|
function LineRenderer() {
|
|
4006
|
-
|
|
4738
|
+
_classCallCheck$3(this, LineRenderer);
|
|
4739
|
+
return _super.apply(this, arguments);
|
|
4007
4740
|
}
|
|
4008
|
-
return LineRenderer;
|
|
4741
|
+
return _createClass$3(LineRenderer);
|
|
4009
4742
|
}(DefaultRenderer);
|
|
4010
4743
|
var PolylineRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
4011
|
-
|
|
4744
|
+
_inherits$3(PolylineRenderer, _DefaultRenderer);
|
|
4745
|
+
var _super = _createSuper$3(PolylineRenderer);
|
|
4012
4746
|
function PolylineRenderer() {
|
|
4013
|
-
|
|
4747
|
+
_classCallCheck$3(this, PolylineRenderer);
|
|
4748
|
+
return _super.apply(this, arguments);
|
|
4014
4749
|
}
|
|
4015
|
-
return PolylineRenderer;
|
|
4750
|
+
return _createClass$3(PolylineRenderer);
|
|
4016
4751
|
}(DefaultRenderer);
|
|
4017
4752
|
var PolygonRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
4018
|
-
|
|
4753
|
+
_inherits$3(PolygonRenderer, _DefaultRenderer);
|
|
4754
|
+
var _super = _createSuper$3(PolygonRenderer);
|
|
4019
4755
|
function PolygonRenderer() {
|
|
4020
|
-
|
|
4756
|
+
_classCallCheck$3(this, PolygonRenderer);
|
|
4757
|
+
return _super.apply(this, arguments);
|
|
4021
4758
|
}
|
|
4022
|
-
return PolygonRenderer;
|
|
4759
|
+
return _createClass$3(PolygonRenderer);
|
|
4023
4760
|
}(DefaultRenderer);
|
|
4024
4761
|
var PathRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
4025
|
-
|
|
4762
|
+
_inherits$3(PathRenderer, _DefaultRenderer);
|
|
4763
|
+
var _super = _createSuper$3(PathRenderer);
|
|
4026
4764
|
function PathRenderer() {
|
|
4027
|
-
|
|
4765
|
+
_classCallCheck$3(this, PathRenderer);
|
|
4766
|
+
return _super.apply(this, arguments);
|
|
4028
4767
|
}
|
|
4029
|
-
return PathRenderer;
|
|
4768
|
+
return _createClass$3(PathRenderer);
|
|
4030
4769
|
}(DefaultRenderer);
|
|
4031
4770
|
var Plugin$2 = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
4032
|
-
|
|
4033
|
-
|
|
4771
|
+
_inherits$3(Plugin, _AbstractRendererPlug);
|
|
4772
|
+
var _super = _createSuper$3(Plugin);
|
|
4773
|
+
function Plugin() {
|
|
4034
4774
|
var _this;
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
_this = _AbstractRendererPlug.call(this) || this;
|
|
4775
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
4776
|
+
_classCallCheck$3(this, Plugin);
|
|
4777
|
+
_this = _super.call(this);
|
|
4039
4778
|
_this.options = void 0;
|
|
4040
4779
|
_this.name = 'canvas-renderer';
|
|
4041
4780
|
_this.options = options;
|
|
4042
4781
|
return _this;
|
|
4043
4782
|
}
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4783
|
+
_createClass$3(Plugin, [{
|
|
4784
|
+
key: "init",
|
|
4785
|
+
value: function init() {
|
|
4786
|
+
var _defaultStyleRenderer;
|
|
4787
|
+
var canvasRendererPluginOptions = _objectSpread2({
|
|
4788
|
+
dirtyObjectNumThreshold: 500,
|
|
4789
|
+
dirtyObjectRatioThreshold: 0.8
|
|
4790
|
+
}, this.options);
|
|
4791
|
+
// @ts-ignore
|
|
4792
|
+
var imagePool = this.context.imagePool;
|
|
4793
|
+
var defaultRenderer = new DefaultRenderer(imagePool);
|
|
4794
|
+
var defaultStyleRendererFactory = (_defaultStyleRenderer = {}, _defineProperty$2(_defaultStyleRenderer, gLite.Shape.CIRCLE, defaultRenderer), _defineProperty$2(_defaultStyleRenderer, gLite.Shape.ELLIPSE, defaultRenderer), _defineProperty$2(_defaultStyleRenderer, gLite.Shape.RECT, defaultRenderer), _defineProperty$2(_defaultStyleRenderer, gLite.Shape.IMAGE, new ImageRenderer(imagePool)), _defineProperty$2(_defaultStyleRenderer, gLite.Shape.TEXT, new TextRenderer()), _defineProperty$2(_defaultStyleRenderer, gLite.Shape.LINE, defaultRenderer), _defineProperty$2(_defaultStyleRenderer, gLite.Shape.POLYLINE, defaultRenderer), _defineProperty$2(_defaultStyleRenderer, gLite.Shape.POLYGON, defaultRenderer), _defineProperty$2(_defaultStyleRenderer, gLite.Shape.PATH, defaultRenderer), _defineProperty$2(_defaultStyleRenderer, gLite.Shape.GROUP, undefined), _defineProperty$2(_defaultStyleRenderer, gLite.Shape.HTML, undefined), _defineProperty$2(_defaultStyleRenderer, gLite.Shape.MESH, undefined), _defaultStyleRenderer);
|
|
4795
|
+
this.context.defaultStyleRendererFactory = defaultStyleRendererFactory;
|
|
4796
|
+
this.context.styleRendererFactory = defaultStyleRendererFactory;
|
|
4797
|
+
this.addRenderingPlugin(new CanvasRendererPlugin(canvasRendererPluginOptions));
|
|
4798
|
+
}
|
|
4799
|
+
}, {
|
|
4800
|
+
key: "destroy",
|
|
4801
|
+
value: function destroy() {
|
|
4802
|
+
this.removeAllRenderingPlugins();
|
|
4803
|
+
delete this.context.defaultStyleRendererFactory;
|
|
4804
|
+
delete this.context.styleRendererFactory;
|
|
4805
|
+
}
|
|
4806
|
+
}]);
|
|
4064
4807
|
return Plugin;
|
|
4065
4808
|
}(gLite.AbstractRendererPlugin);
|
|
4066
4809
|
|
|
@@ -4154,7 +4897,7 @@
|
|
|
4154
4897
|
if ("throw" !== record.type) {
|
|
4155
4898
|
var result = record.arg,
|
|
4156
4899
|
value = result.value;
|
|
4157
|
-
return value && "object" ==
|
|
4900
|
+
return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
4158
4901
|
invoke("next", value, resolve, reject);
|
|
4159
4902
|
}, function (err) {
|
|
4160
4903
|
invoke("throw", err, resolve, reject);
|
|
@@ -4415,10 +5158,49 @@
|
|
|
4415
5158
|
});
|
|
4416
5159
|
};
|
|
4417
5160
|
}
|
|
4418
|
-
function
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
5161
|
+
function _classCallCheck$4(instance, Constructor) {
|
|
5162
|
+
if (!(instance instanceof Constructor)) {
|
|
5163
|
+
throw new TypeError("Cannot call a class as a function");
|
|
5164
|
+
}
|
|
5165
|
+
}
|
|
5166
|
+
function _defineProperties$4(target, props) {
|
|
5167
|
+
for (var i = 0; i < props.length; i++) {
|
|
5168
|
+
var descriptor = props[i];
|
|
5169
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
5170
|
+
descriptor.configurable = true;
|
|
5171
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
5172
|
+
Object.defineProperty(target, _toPropertyKey$4(descriptor.key), descriptor);
|
|
5173
|
+
}
|
|
5174
|
+
}
|
|
5175
|
+
function _createClass$4(Constructor, protoProps, staticProps) {
|
|
5176
|
+
if (protoProps) _defineProperties$4(Constructor.prototype, protoProps);
|
|
5177
|
+
if (staticProps) _defineProperties$4(Constructor, staticProps);
|
|
5178
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
5179
|
+
writable: false
|
|
5180
|
+
});
|
|
5181
|
+
return Constructor;
|
|
5182
|
+
}
|
|
5183
|
+
function _inherits$4(subClass, superClass) {
|
|
5184
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
5185
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
5186
|
+
}
|
|
5187
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
5188
|
+
constructor: {
|
|
5189
|
+
value: subClass,
|
|
5190
|
+
writable: true,
|
|
5191
|
+
configurable: true
|
|
5192
|
+
}
|
|
5193
|
+
});
|
|
5194
|
+
Object.defineProperty(subClass, "prototype", {
|
|
5195
|
+
writable: false
|
|
5196
|
+
});
|
|
5197
|
+
if (superClass) _setPrototypeOf$4(subClass, superClass);
|
|
5198
|
+
}
|
|
5199
|
+
function _getPrototypeOf$4(o) {
|
|
5200
|
+
_getPrototypeOf$4 = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
5201
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
5202
|
+
};
|
|
5203
|
+
return _getPrototypeOf$4(o);
|
|
4422
5204
|
}
|
|
4423
5205
|
function _setPrototypeOf$4(o, p) {
|
|
4424
5206
|
_setPrototypeOf$4 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
@@ -4427,6 +5209,59 @@
|
|
|
4427
5209
|
};
|
|
4428
5210
|
return _setPrototypeOf$4(o, p);
|
|
4429
5211
|
}
|
|
5212
|
+
function _isNativeReflectConstruct$4() {
|
|
5213
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
5214
|
+
if (Reflect.construct.sham) return false;
|
|
5215
|
+
if (typeof Proxy === "function") return true;
|
|
5216
|
+
try {
|
|
5217
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
5218
|
+
return true;
|
|
5219
|
+
} catch (e) {
|
|
5220
|
+
return false;
|
|
5221
|
+
}
|
|
5222
|
+
}
|
|
5223
|
+
function _assertThisInitialized$4(self) {
|
|
5224
|
+
if (self === void 0) {
|
|
5225
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
5226
|
+
}
|
|
5227
|
+
return self;
|
|
5228
|
+
}
|
|
5229
|
+
function _possibleConstructorReturn$4(self, call) {
|
|
5230
|
+
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
5231
|
+
return call;
|
|
5232
|
+
} else if (call !== void 0) {
|
|
5233
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
5234
|
+
}
|
|
5235
|
+
return _assertThisInitialized$4(self);
|
|
5236
|
+
}
|
|
5237
|
+
function _createSuper$4(Derived) {
|
|
5238
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct$4();
|
|
5239
|
+
return function _createSuperInternal() {
|
|
5240
|
+
var Super = _getPrototypeOf$4(Derived),
|
|
5241
|
+
result;
|
|
5242
|
+
if (hasNativeReflectConstruct) {
|
|
5243
|
+
var NewTarget = _getPrototypeOf$4(this).constructor;
|
|
5244
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
5245
|
+
} else {
|
|
5246
|
+
result = Super.apply(this, arguments);
|
|
5247
|
+
}
|
|
5248
|
+
return _possibleConstructorReturn$4(this, result);
|
|
5249
|
+
};
|
|
5250
|
+
}
|
|
5251
|
+
function _toPrimitive$4(input, hint) {
|
|
5252
|
+
if (_typeof(input) !== "object" || input === null) return input;
|
|
5253
|
+
var prim = input[Symbol.toPrimitive];
|
|
5254
|
+
if (prim !== undefined) {
|
|
5255
|
+
var res = prim.call(input, hint || "default");
|
|
5256
|
+
if (_typeof(res) !== "object") return res;
|
|
5257
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
5258
|
+
}
|
|
5259
|
+
return (hint === "string" ? String : Number)(input);
|
|
5260
|
+
}
|
|
5261
|
+
function _toPropertyKey$4(arg) {
|
|
5262
|
+
var key = _toPrimitive$4(arg, "string");
|
|
5263
|
+
return _typeof(key) === "symbol" ? key : String(key);
|
|
5264
|
+
}
|
|
4430
5265
|
|
|
4431
5266
|
// const MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
|
|
4432
5267
|
/**
|
|
@@ -4434,156 +5269,165 @@
|
|
|
4434
5269
|
*/
|
|
4435
5270
|
var DOMInteractionPlugin = /*#__PURE__*/function () {
|
|
4436
5271
|
function DOMInteractionPlugin() {
|
|
5272
|
+
_classCallCheck$4(this, DOMInteractionPlugin);
|
|
4437
5273
|
this.context = void 0;
|
|
4438
5274
|
}
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
$el
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
$el
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
5275
|
+
_createClass$4(DOMInteractionPlugin, [{
|
|
5276
|
+
key: "apply",
|
|
5277
|
+
value: function apply(context) {
|
|
5278
|
+
var _this = this;
|
|
5279
|
+
var renderingService = context.renderingService,
|
|
5280
|
+
renderingContext = context.renderingContext;
|
|
5281
|
+
this.context = context;
|
|
5282
|
+
var canvas = renderingContext.root.ownerDocument.defaultView;
|
|
5283
|
+
// const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent);
|
|
5284
|
+
var onPointerMove = function onPointerMove(ev) {
|
|
5285
|
+
renderingService.hooks.pointerMove.call(ev);
|
|
5286
|
+
};
|
|
5287
|
+
var onPointerUp = function onPointerUp(ev) {
|
|
5288
|
+
renderingService.hooks.pointerUp.call(ev);
|
|
5289
|
+
};
|
|
5290
|
+
var onPointerDown = function onPointerDown(ev) {
|
|
5291
|
+
renderingService.hooks.pointerDown.call(ev);
|
|
5292
|
+
};
|
|
5293
|
+
var onPointerOver = function onPointerOver(ev) {
|
|
5294
|
+
renderingService.hooks.pointerOver.call(ev);
|
|
5295
|
+
};
|
|
5296
|
+
var onPointerOut = function onPointerOut(ev) {
|
|
5297
|
+
renderingService.hooks.pointerOut.call(ev);
|
|
5298
|
+
};
|
|
5299
|
+
var onPointerCancel = function onPointerCancel(ev) {
|
|
5300
|
+
renderingService.hooks.pointerCancel.call(ev);
|
|
5301
|
+
};
|
|
5302
|
+
var onPointerWheel = function onPointerWheel(ev) {
|
|
5303
|
+
renderingService.hooks.pointerWheel.call(ev);
|
|
5304
|
+
};
|
|
5305
|
+
var addPointerEventListener = function addPointerEventListener($el) {
|
|
5306
|
+
globalThis.document.addEventListener('pointermove', onPointerMove, true);
|
|
5307
|
+
$el.addEventListener('pointerdown', onPointerDown, true);
|
|
5308
|
+
$el.addEventListener('pointerleave', onPointerOut, true);
|
|
5309
|
+
$el.addEventListener('pointerover', onPointerOver, true);
|
|
5310
|
+
globalThis.addEventListener('pointerup', onPointerUp, true);
|
|
5311
|
+
};
|
|
5312
|
+
var addTouchEventListener = function addTouchEventListener($el) {
|
|
5313
|
+
$el.addEventListener('touchstart', onPointerDown, true);
|
|
5314
|
+
$el.addEventListener('touchend', onPointerUp, true);
|
|
5315
|
+
$el.addEventListener('touchmove', onPointerMove, true);
|
|
5316
|
+
$el.addEventListener('touchcancel', onPointerCancel, true);
|
|
5317
|
+
};
|
|
5318
|
+
var addMouseEventListener = function addMouseEventListener($el) {
|
|
5319
|
+
globalThis.document.addEventListener('mousemove', onPointerMove, true);
|
|
5320
|
+
$el.addEventListener('mousedown', onPointerDown, true);
|
|
5321
|
+
$el.addEventListener('mouseout', onPointerOut, true);
|
|
5322
|
+
$el.addEventListener('mouseover', onPointerOver, true);
|
|
5323
|
+
globalThis.addEventListener('mouseup', onPointerUp, true);
|
|
5324
|
+
};
|
|
5325
|
+
var removePointerEventListener = function removePointerEventListener($el) {
|
|
5326
|
+
globalThis.document.removeEventListener('pointermove', onPointerMove, true);
|
|
5327
|
+
$el.removeEventListener('pointerdown', onPointerDown, true);
|
|
5328
|
+
$el.removeEventListener('pointerleave', onPointerOut, true);
|
|
5329
|
+
$el.removeEventListener('pointerover', onPointerOver, true);
|
|
5330
|
+
globalThis.removeEventListener('pointerup', onPointerUp, true);
|
|
5331
|
+
};
|
|
5332
|
+
var removeTouchEventListener = function removeTouchEventListener($el) {
|
|
5333
|
+
$el.removeEventListener('touchstart', onPointerDown, true);
|
|
5334
|
+
$el.removeEventListener('touchend', onPointerUp, true);
|
|
5335
|
+
$el.removeEventListener('touchmove', onPointerMove, true);
|
|
5336
|
+
$el.removeEventListener('touchcancel', onPointerCancel, true);
|
|
5337
|
+
};
|
|
5338
|
+
var removeMouseEventListener = function removeMouseEventListener($el) {
|
|
5339
|
+
globalThis.document.removeEventListener('mousemove', onPointerMove, true);
|
|
5340
|
+
$el.removeEventListener('mousedown', onPointerDown, true);
|
|
5341
|
+
$el.removeEventListener('mouseout', onPointerOut, true);
|
|
5342
|
+
$el.removeEventListener('mouseover', onPointerOver, true);
|
|
5343
|
+
globalThis.removeEventListener('mouseup', onPointerUp, true);
|
|
5344
|
+
};
|
|
5345
|
+
renderingService.hooks.init.tapPromise(DOMInteractionPlugin.tag, /*#__PURE__*/_asyncToGenerator$3( /*#__PURE__*/_regeneratorRuntime$3().mark(function _callee() {
|
|
5346
|
+
var $el;
|
|
5347
|
+
return _regeneratorRuntime$3().wrap(function _callee$(_context) {
|
|
5348
|
+
while (1) {
|
|
5349
|
+
switch (_context.prev = _context.next) {
|
|
5350
|
+
case 0:
|
|
5351
|
+
$el = _this.context.contextService.getDomElement(); // @ts-ignore
|
|
5352
|
+
if (globalThis.navigator.msPointerEnabled) {
|
|
5353
|
+
// @ts-ignore
|
|
5354
|
+
$el.style.msContentZooming = 'none';
|
|
5355
|
+
// @ts-ignore
|
|
5356
|
+
$el.style.msTouchAction = 'none';
|
|
5357
|
+
} else if (canvas.supportsPointerEvents) {
|
|
5358
|
+
$el.style.touchAction = 'none';
|
|
5359
|
+
}
|
|
5360
|
+
if (canvas.supportsPointerEvents) {
|
|
5361
|
+
addPointerEventListener($el);
|
|
5362
|
+
} else {
|
|
5363
|
+
addMouseEventListener($el);
|
|
5364
|
+
}
|
|
5365
|
+
if (canvas.supportsTouchEvents) {
|
|
5366
|
+
addTouchEventListener($el);
|
|
5367
|
+
}
|
|
5368
|
+
// use passive event listeners
|
|
5369
|
+
// @see https://zhuanlan.zhihu.com/p/24555031
|
|
5370
|
+
$el.addEventListener('wheel', onPointerWheel, {
|
|
5371
|
+
passive: true,
|
|
5372
|
+
capture: true
|
|
5373
|
+
});
|
|
5374
|
+
case 5:
|
|
5375
|
+
case "end":
|
|
5376
|
+
return _context.stop();
|
|
5377
|
+
}
|
|
4540
5378
|
}
|
|
4541
|
-
}
|
|
4542
|
-
}
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
var $el = _this.context.contextService.getDomElement();
|
|
4546
|
-
// @ts-ignore
|
|
4547
|
-
if (globalThis.navigator.msPointerEnabled) {
|
|
4548
|
-
// @ts-ignore
|
|
4549
|
-
$el.style.msContentZooming = '';
|
|
5379
|
+
}, _callee);
|
|
5380
|
+
})));
|
|
5381
|
+
renderingService.hooks.destroy.tap(DOMInteractionPlugin.tag, function () {
|
|
5382
|
+
var $el = _this.context.contextService.getDomElement();
|
|
4550
5383
|
// @ts-ignore
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
5384
|
+
if (globalThis.navigator.msPointerEnabled) {
|
|
5385
|
+
// @ts-ignore
|
|
5386
|
+
$el.style.msContentZooming = '';
|
|
5387
|
+
// @ts-ignore
|
|
5388
|
+
$el.style.msTouchAction = '';
|
|
5389
|
+
} else if (canvas.supportsPointerEvents) {
|
|
5390
|
+
$el.style.touchAction = '';
|
|
5391
|
+
}
|
|
5392
|
+
if (canvas.supportsPointerEvents) {
|
|
5393
|
+
removePointerEventListener($el);
|
|
5394
|
+
} else {
|
|
5395
|
+
removeMouseEventListener($el);
|
|
5396
|
+
}
|
|
5397
|
+
if (canvas.supportsTouchEvents) {
|
|
5398
|
+
removeTouchEventListener($el);
|
|
5399
|
+
}
|
|
5400
|
+
$el.removeEventListener('wheel', onPointerWheel, true);
|
|
5401
|
+
});
|
|
5402
|
+
}
|
|
5403
|
+
}]);
|
|
4566
5404
|
return DOMInteractionPlugin;
|
|
4567
5405
|
}();
|
|
4568
5406
|
DOMInteractionPlugin.tag = 'DOMInteraction';
|
|
4569
5407
|
var Plugin$3 = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
4570
|
-
|
|
5408
|
+
_inherits$4(Plugin, _AbstractRendererPlug);
|
|
5409
|
+
var _super = _createSuper$4(Plugin);
|
|
4571
5410
|
function Plugin() {
|
|
4572
5411
|
var _this;
|
|
5412
|
+
_classCallCheck$4(this, Plugin);
|
|
4573
5413
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
4574
5414
|
args[_key] = arguments[_key];
|
|
4575
5415
|
}
|
|
4576
|
-
_this =
|
|
5416
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
4577
5417
|
_this.name = 'dom-interaction';
|
|
4578
5418
|
return _this;
|
|
4579
5419
|
}
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
5420
|
+
_createClass$4(Plugin, [{
|
|
5421
|
+
key: "init",
|
|
5422
|
+
value: function init() {
|
|
5423
|
+
this.addRenderingPlugin(new DOMInteractionPlugin());
|
|
5424
|
+
}
|
|
5425
|
+
}, {
|
|
5426
|
+
key: "destroy",
|
|
5427
|
+
value: function destroy() {
|
|
5428
|
+
this.removeAllRenderingPlugins();
|
|
5429
|
+
}
|
|
5430
|
+
}]);
|
|
4587
5431
|
return Plugin;
|
|
4588
5432
|
}(gLite.AbstractRendererPlugin);
|
|
4589
5433
|
|
|
@@ -4668,7 +5512,7 @@
|
|
|
4668
5512
|
if ("throw" !== record.type) {
|
|
4669
5513
|
var result = record.arg,
|
|
4670
5514
|
value = result.value;
|
|
4671
|
-
return value && "object" ==
|
|
5515
|
+
return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
4672
5516
|
invoke("next", value, resolve, reject);
|
|
4673
5517
|
}, function (err) {
|
|
4674
5518
|
invoke("throw", err, resolve, reject);
|
|
@@ -4929,10 +5773,49 @@
|
|
|
4929
5773
|
});
|
|
4930
5774
|
};
|
|
4931
5775
|
}
|
|
4932
|
-
function
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
5776
|
+
function _classCallCheck$5(instance, Constructor) {
|
|
5777
|
+
if (!(instance instanceof Constructor)) {
|
|
5778
|
+
throw new TypeError("Cannot call a class as a function");
|
|
5779
|
+
}
|
|
5780
|
+
}
|
|
5781
|
+
function _defineProperties$5(target, props) {
|
|
5782
|
+
for (var i = 0; i < props.length; i++) {
|
|
5783
|
+
var descriptor = props[i];
|
|
5784
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
5785
|
+
descriptor.configurable = true;
|
|
5786
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
5787
|
+
Object.defineProperty(target, _toPropertyKey$5(descriptor.key), descriptor);
|
|
5788
|
+
}
|
|
5789
|
+
}
|
|
5790
|
+
function _createClass$5(Constructor, protoProps, staticProps) {
|
|
5791
|
+
if (protoProps) _defineProperties$5(Constructor.prototype, protoProps);
|
|
5792
|
+
if (staticProps) _defineProperties$5(Constructor, staticProps);
|
|
5793
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
5794
|
+
writable: false
|
|
5795
|
+
});
|
|
5796
|
+
return Constructor;
|
|
5797
|
+
}
|
|
5798
|
+
function _inherits$5(subClass, superClass) {
|
|
5799
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
5800
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
5801
|
+
}
|
|
5802
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
5803
|
+
constructor: {
|
|
5804
|
+
value: subClass,
|
|
5805
|
+
writable: true,
|
|
5806
|
+
configurable: true
|
|
5807
|
+
}
|
|
5808
|
+
});
|
|
5809
|
+
Object.defineProperty(subClass, "prototype", {
|
|
5810
|
+
writable: false
|
|
5811
|
+
});
|
|
5812
|
+
if (superClass) _setPrototypeOf$5(subClass, superClass);
|
|
5813
|
+
}
|
|
5814
|
+
function _getPrototypeOf$5(o) {
|
|
5815
|
+
_getPrototypeOf$5 = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
5816
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
5817
|
+
};
|
|
5818
|
+
return _getPrototypeOf$5(o);
|
|
4936
5819
|
}
|
|
4937
5820
|
function _setPrototypeOf$5(o, p) {
|
|
4938
5821
|
_setPrototypeOf$5 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
@@ -4941,286 +5824,358 @@
|
|
|
4941
5824
|
};
|
|
4942
5825
|
return _setPrototypeOf$5(o, p);
|
|
4943
5826
|
}
|
|
5827
|
+
function _isNativeReflectConstruct$5() {
|
|
5828
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
5829
|
+
if (Reflect.construct.sham) return false;
|
|
5830
|
+
if (typeof Proxy === "function") return true;
|
|
5831
|
+
try {
|
|
5832
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
5833
|
+
return true;
|
|
5834
|
+
} catch (e) {
|
|
5835
|
+
return false;
|
|
5836
|
+
}
|
|
5837
|
+
}
|
|
5838
|
+
function _assertThisInitialized$5(self) {
|
|
5839
|
+
if (self === void 0) {
|
|
5840
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
5841
|
+
}
|
|
5842
|
+
return self;
|
|
5843
|
+
}
|
|
5844
|
+
function _possibleConstructorReturn$5(self, call) {
|
|
5845
|
+
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
5846
|
+
return call;
|
|
5847
|
+
} else if (call !== void 0) {
|
|
5848
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
5849
|
+
}
|
|
5850
|
+
return _assertThisInitialized$5(self);
|
|
5851
|
+
}
|
|
5852
|
+
function _createSuper$5(Derived) {
|
|
5853
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct$5();
|
|
5854
|
+
return function _createSuperInternal() {
|
|
5855
|
+
var Super = _getPrototypeOf$5(Derived),
|
|
5856
|
+
result;
|
|
5857
|
+
if (hasNativeReflectConstruct) {
|
|
5858
|
+
var NewTarget = _getPrototypeOf$5(this).constructor;
|
|
5859
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
5860
|
+
} else {
|
|
5861
|
+
result = Super.apply(this, arguments);
|
|
5862
|
+
}
|
|
5863
|
+
return _possibleConstructorReturn$5(this, result);
|
|
5864
|
+
};
|
|
5865
|
+
}
|
|
5866
|
+
function _toPrimitive$5(input, hint) {
|
|
5867
|
+
if (_typeof(input) !== "object" || input === null) return input;
|
|
5868
|
+
var prim = input[Symbol.toPrimitive];
|
|
5869
|
+
if (prim !== undefined) {
|
|
5870
|
+
var res = prim.call(input, hint || "default");
|
|
5871
|
+
if (_typeof(res) !== "object") return res;
|
|
5872
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
5873
|
+
}
|
|
5874
|
+
return (hint === "string" ? String : Number)(input);
|
|
5875
|
+
}
|
|
5876
|
+
function _toPropertyKey$5(arg) {
|
|
5877
|
+
var key = _toPrimitive$5(arg, "string");
|
|
5878
|
+
return _typeof(key) === "symbol" ? key : String(key);
|
|
5879
|
+
}
|
|
4944
5880
|
var HTML_PREFIX = 'g-html-';
|
|
4945
5881
|
var CANVAS_CAMERA_ID = 'g-canvas-camera';
|
|
4946
5882
|
var HTMLRenderingPlugin = /*#__PURE__*/function () {
|
|
4947
5883
|
function HTMLRenderingPlugin() {
|
|
5884
|
+
_classCallCheck$5(this, HTMLRenderingPlugin);
|
|
4948
5885
|
this.context = void 0;
|
|
4949
5886
|
this.$camera = void 0;
|
|
4950
5887
|
}
|
|
4951
|
-
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
5888
|
+
_createClass$5(HTMLRenderingPlugin, [{
|
|
5889
|
+
key: "joinTransformMatrix",
|
|
5890
|
+
value: function joinTransformMatrix(matrix) {
|
|
5891
|
+
return "matrix(".concat([matrix[0], matrix[1], matrix[4], matrix[5], matrix[12], matrix[13]].join(','), ")");
|
|
5892
|
+
}
|
|
5893
|
+
}, {
|
|
5894
|
+
key: "apply",
|
|
5895
|
+
value: function apply(context) {
|
|
5896
|
+
var _this = this;
|
|
5897
|
+
var camera = context.camera,
|
|
5898
|
+
renderingContext = context.renderingContext,
|
|
5899
|
+
renderingService = context.renderingService,
|
|
5900
|
+
displayObjectPool = context.displayObjectPool;
|
|
5901
|
+
this.context = context;
|
|
5902
|
+
var canvas = renderingContext.root.ownerDocument.defaultView;
|
|
5903
|
+
var setTransform = function setTransform(object, $el) {
|
|
5904
|
+
$el.style.transform = _this.joinTransformMatrix(object.getWorldTransform());
|
|
5905
|
+
};
|
|
5906
|
+
var handleMounted = function handleMounted(e) {
|
|
5907
|
+
var object = e.target;
|
|
5908
|
+
if (object.nodeName === gLite.Shape.HTML) {
|
|
5909
|
+
if (!_this.$camera) {
|
|
5910
|
+
_this.$camera = _this.createCamera(camera);
|
|
5911
|
+
}
|
|
5912
|
+
// create DOM element
|
|
5913
|
+
var $el = _this.getOrCreateEl(object);
|
|
5914
|
+
_this.$camera.appendChild($el);
|
|
5915
|
+
// apply documentElement's style
|
|
5916
|
+
var attributes = object.ownerDocument.documentElement.attributes;
|
|
5917
|
+
Object.keys(attributes).forEach(function (name) {
|
|
5918
|
+
$el.style[name] = attributes[name];
|
|
5919
|
+
});
|
|
5920
|
+
Object.keys(object.attributes).forEach(function (name) {
|
|
5921
|
+
_this.updateAttribute(name, object);
|
|
5922
|
+
});
|
|
5923
|
+
setTransform(object, $el);
|
|
4971
5924
|
}
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
};
|
|
4986
|
-
var handleUnmounted = function handleUnmounted(e) {
|
|
4987
|
-
var object = e.target;
|
|
4988
|
-
if (object.nodeName === gLite.Shape.HTML && _this.$camera) {
|
|
4989
|
-
var $el = _this.getOrCreateEl(object);
|
|
4990
|
-
if ($el) {
|
|
4991
|
-
$el.remove();
|
|
5925
|
+
};
|
|
5926
|
+
var handleUnmounted = function handleUnmounted(e) {
|
|
5927
|
+
var object = e.target;
|
|
5928
|
+
if (object.nodeName === gLite.Shape.HTML && _this.$camera) {
|
|
5929
|
+
var $el = _this.getOrCreateEl(object);
|
|
5930
|
+
if ($el) {
|
|
5931
|
+
$el.remove();
|
|
5932
|
+
}
|
|
5933
|
+
// const existedId = this.getId(object);
|
|
5934
|
+
// const $existedElement: HTMLElement | null = this.$camera.querySelector('#' + existedId);
|
|
5935
|
+
// if ($existedElement) {
|
|
5936
|
+
// this.$camera.removeChild($existedElement);
|
|
5937
|
+
// }
|
|
4992
5938
|
}
|
|
4993
|
-
|
|
4994
|
-
// const $existedElement: HTMLElement | null = this.$camera.querySelector('#' + existedId);
|
|
4995
|
-
// if ($existedElement) {
|
|
4996
|
-
// this.$camera.removeChild($existedElement);
|
|
4997
|
-
// }
|
|
4998
|
-
}
|
|
4999
|
-
};
|
|
5939
|
+
};
|
|
5000
5940
|
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5941
|
+
var handleAttributeChanged = function handleAttributeChanged(e) {
|
|
5942
|
+
var object = e.target;
|
|
5943
|
+
if (object.nodeName === gLite.Shape.HTML) {
|
|
5944
|
+
var attrName = e.attrName;
|
|
5945
|
+
_this.updateAttribute(attrName, object);
|
|
5946
|
+
}
|
|
5947
|
+
};
|
|
5948
|
+
var handleBoundsChanged = function handleBoundsChanged(e) {
|
|
5949
|
+
var object = e.target;
|
|
5950
|
+
if (object.nodeName === gLite.Shape.HTML) {
|
|
5951
|
+
var $el = _this.getOrCreateEl(object);
|
|
5952
|
+
setTransform(object, $el);
|
|
5953
|
+
}
|
|
5954
|
+
};
|
|
5955
|
+
var handleCanvasResize = function handleCanvasResize() {
|
|
5956
|
+
if (_this.$camera) {
|
|
5957
|
+
var _this$context$config = _this.context.config,
|
|
5958
|
+
width = _this$context$config.width,
|
|
5959
|
+
height = _this$context$config.height;
|
|
5960
|
+
_this.$camera.style.width = "".concat(width || 0, "px");
|
|
5961
|
+
_this.$camera.style.height = "".concat(height || 0, "px");
|
|
5962
|
+
}
|
|
5963
|
+
};
|
|
5964
|
+
renderingService.hooks.init.tapPromise(HTMLRenderingPlugin.tag, /*#__PURE__*/_asyncToGenerator$4( /*#__PURE__*/_regeneratorRuntime$4().mark(function _callee() {
|
|
5965
|
+
return _regeneratorRuntime$4().wrap(function _callee$(_context) {
|
|
5966
|
+
while (1) {
|
|
5967
|
+
switch (_context.prev = _context.next) {
|
|
5968
|
+
case 0:
|
|
5969
|
+
if (displayObjectPool.getHTMLs().length) {
|
|
5970
|
+
// append camera
|
|
5971
|
+
_this.$camera = _this.createCamera(camera);
|
|
5972
|
+
}
|
|
5973
|
+
canvas.addEventListener(gLite.CanvasEvent.RESIZE, handleCanvasResize);
|
|
5974
|
+
canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
|
|
5975
|
+
canvas.addEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
5976
|
+
canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
5977
|
+
canvas.addEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
|
|
5978
|
+
case 6:
|
|
5979
|
+
case "end":
|
|
5980
|
+
return _context.stop();
|
|
5981
|
+
}
|
|
5041
5982
|
}
|
|
5983
|
+
}, _callee);
|
|
5984
|
+
})));
|
|
5985
|
+
renderingService.hooks.endFrame.tap(HTMLRenderingPlugin.tag, function () {
|
|
5986
|
+
if (_this.$camera && renderingContext.renderReasons.has(gLite.RenderReason.CAMERA_CHANGED)) {
|
|
5987
|
+
_this.$camera.style.transform = _this.joinTransformMatrix(camera.getOrthoMatrix());
|
|
5042
5988
|
}
|
|
5043
|
-
}
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
}
|
|
5055
|
-
canvas.removeEventListener(gLite.CanvasEvent.RESIZE, handleCanvasResize);
|
|
5056
|
-
canvas.removeEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
|
|
5057
|
-
canvas.removeEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
5058
|
-
canvas.removeEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
5059
|
-
canvas.removeEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
|
|
5060
|
-
});
|
|
5061
|
-
};
|
|
5062
|
-
_proto.getId = function getId(object) {
|
|
5063
|
-
return object.id || HTML_PREFIX + object.entity;
|
|
5064
|
-
};
|
|
5065
|
-
_proto.createCamera = function createCamera(camera) {
|
|
5066
|
-
var _this$context$config2 = this.context.config,
|
|
5067
|
-
doc = _this$context$config2.document,
|
|
5068
|
-
width = _this$context$config2.width,
|
|
5069
|
-
height = _this$context$config2.height;
|
|
5070
|
-
var $canvas = this.context.contextService.getDomElement();
|
|
5071
|
-
var $container = $canvas.parentNode;
|
|
5072
|
-
if ($container) {
|
|
5073
|
-
var cameraId = CANVAS_CAMERA_ID;
|
|
5074
|
-
var $existedCamera = $container.querySelector('#' + cameraId);
|
|
5075
|
-
if (!$existedCamera) {
|
|
5076
|
-
var $camera = (doc || document).createElement('div');
|
|
5077
|
-
$existedCamera = $camera;
|
|
5078
|
-
$camera.id = cameraId;
|
|
5079
|
-
// use absolute position
|
|
5080
|
-
$camera.style.position = 'absolute';
|
|
5081
|
-
// account for DOM element's offset @see https://github.com/antvis/G/issues/1150
|
|
5082
|
-
$camera.style.left = ($canvas.offsetLeft || 0) + "px";
|
|
5083
|
-
$camera.style.top = ($canvas.offsetTop || 0) + "px";
|
|
5084
|
-
$camera.style.transformOrigin = 'left top';
|
|
5085
|
-
$camera.style.transform = this.joinTransformMatrix(camera.getOrthoMatrix());
|
|
5086
|
-
// HTML elements should not overflow with canvas @see https://github.com/antvis/G/issues/1163
|
|
5087
|
-
$camera.style.overflow = 'hidden';
|
|
5088
|
-
$camera.style.pointerEvents = 'none';
|
|
5089
|
-
$camera.style.width = (width || 0) + "px";
|
|
5090
|
-
$camera.style.height = (height || 0) + "px";
|
|
5091
|
-
$container.appendChild($camera);
|
|
5092
|
-
}
|
|
5093
|
-
return $existedCamera;
|
|
5989
|
+
});
|
|
5990
|
+
renderingService.hooks.destroy.tap(HTMLRenderingPlugin.tag, function () {
|
|
5991
|
+
// remove camera
|
|
5992
|
+
if (_this.$camera) {
|
|
5993
|
+
_this.$camera.remove();
|
|
5994
|
+
}
|
|
5995
|
+
canvas.removeEventListener(gLite.CanvasEvent.RESIZE, handleCanvasResize);
|
|
5996
|
+
canvas.removeEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
|
|
5997
|
+
canvas.removeEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
5998
|
+
canvas.removeEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
5999
|
+
canvas.removeEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
|
|
6000
|
+
});
|
|
5094
6001
|
}
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
$
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
$
|
|
5128
|
-
|
|
5129
|
-
$el.innerHTML = '';
|
|
5130
|
-
$el.appendChild(innerHTML);
|
|
6002
|
+
}, {
|
|
6003
|
+
key: "getId",
|
|
6004
|
+
value: function getId(object) {
|
|
6005
|
+
return object.id || HTML_PREFIX + object.entity;
|
|
6006
|
+
}
|
|
6007
|
+
}, {
|
|
6008
|
+
key: "createCamera",
|
|
6009
|
+
value: function createCamera(camera) {
|
|
6010
|
+
var _this$context$config2 = this.context.config,
|
|
6011
|
+
doc = _this$context$config2.document,
|
|
6012
|
+
width = _this$context$config2.width,
|
|
6013
|
+
height = _this$context$config2.height;
|
|
6014
|
+
var $canvas = this.context.contextService.getDomElement();
|
|
6015
|
+
var $container = $canvas.parentNode;
|
|
6016
|
+
if ($container) {
|
|
6017
|
+
var cameraId = CANVAS_CAMERA_ID;
|
|
6018
|
+
var $existedCamera = $container.querySelector('#' + cameraId);
|
|
6019
|
+
if (!$existedCamera) {
|
|
6020
|
+
var $camera = (doc || document).createElement('div');
|
|
6021
|
+
$existedCamera = $camera;
|
|
6022
|
+
$camera.id = cameraId;
|
|
6023
|
+
// use absolute position
|
|
6024
|
+
$camera.style.position = 'absolute';
|
|
6025
|
+
// account for DOM element's offset @see https://github.com/antvis/G/issues/1150
|
|
6026
|
+
$camera.style.left = "".concat($canvas.offsetLeft || 0, "px");
|
|
6027
|
+
$camera.style.top = "".concat($canvas.offsetTop || 0, "px");
|
|
6028
|
+
$camera.style.transformOrigin = 'left top';
|
|
6029
|
+
$camera.style.transform = this.joinTransformMatrix(camera.getOrthoMatrix());
|
|
6030
|
+
// HTML elements should not overflow with canvas @see https://github.com/antvis/G/issues/1163
|
|
6031
|
+
$camera.style.overflow = 'hidden';
|
|
6032
|
+
$camera.style.pointerEvents = 'none';
|
|
6033
|
+
$camera.style.width = "".concat(width || 0, "px");
|
|
6034
|
+
$camera.style.height = "".concat(height || 0, "px");
|
|
6035
|
+
$container.appendChild($camera);
|
|
5131
6036
|
}
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
$
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
$
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
-
|
|
5166
|
-
|
|
6037
|
+
return $existedCamera;
|
|
6038
|
+
}
|
|
6039
|
+
return null;
|
|
6040
|
+
}
|
|
6041
|
+
}, {
|
|
6042
|
+
key: "getOrCreateEl",
|
|
6043
|
+
value: function getOrCreateEl(object) {
|
|
6044
|
+
var doc = this.context.config.document;
|
|
6045
|
+
var existedId = this.getId(object);
|
|
6046
|
+
var $existedElement = this.$camera.querySelector('#' + existedId);
|
|
6047
|
+
if (!$existedElement) {
|
|
6048
|
+
$existedElement = (doc || document).createElement('div');
|
|
6049
|
+
object.parsedStyle.$el = $existedElement;
|
|
6050
|
+
$existedElement.id = existedId;
|
|
6051
|
+
if (object.name) {
|
|
6052
|
+
$existedElement.setAttribute('name', object.name);
|
|
6053
|
+
}
|
|
6054
|
+
if (object.className) {
|
|
6055
|
+
$existedElement.className = object.className;
|
|
6056
|
+
}
|
|
6057
|
+
// use absolute position
|
|
6058
|
+
$existedElement.style.position = 'absolute';
|
|
6059
|
+
// @see https://github.com/antvis/G/issues/1150
|
|
6060
|
+
$existedElement.style.left = "0px";
|
|
6061
|
+
$existedElement.style.top = "0px";
|
|
6062
|
+
$existedElement.style['will-change'] = 'transform';
|
|
6063
|
+
$existedElement.style.transform = this.joinTransformMatrix(object.getWorldTransform());
|
|
6064
|
+
}
|
|
6065
|
+
return $existedElement;
|
|
6066
|
+
}
|
|
6067
|
+
}, {
|
|
6068
|
+
key: "updateAttribute",
|
|
6069
|
+
value: function updateAttribute(name, object) {
|
|
6070
|
+
var $el = this.getOrCreateEl(object);
|
|
6071
|
+
switch (name) {
|
|
6072
|
+
case 'innerHTML':
|
|
6073
|
+
var innerHTML = object.parsedStyle.innerHTML;
|
|
6074
|
+
if (isString(innerHTML)) {
|
|
6075
|
+
$el.innerHTML = innerHTML;
|
|
5167
6076
|
} else {
|
|
5168
|
-
|
|
6077
|
+
$el.innerHTML = '';
|
|
6078
|
+
$el.appendChild(innerHTML);
|
|
5169
6079
|
}
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
6080
|
+
break;
|
|
6081
|
+
case 'transformOrigin':
|
|
6082
|
+
var transformOrigin = object.parsedStyle.transformOrigin;
|
|
6083
|
+
$el.style['transform-origin'] = "".concat(transformOrigin[0].value, " ").concat(transformOrigin[1].value);
|
|
6084
|
+
break;
|
|
6085
|
+
case 'width':
|
|
6086
|
+
var width = object.computedStyleMap().get('width');
|
|
6087
|
+
$el.style.width = width.toString();
|
|
6088
|
+
break;
|
|
6089
|
+
case 'height':
|
|
6090
|
+
var height = object.computedStyleMap().get('height');
|
|
6091
|
+
$el.style.height = height.toString();
|
|
6092
|
+
break;
|
|
6093
|
+
case 'zIndex':
|
|
6094
|
+
var zIndex = object.parsedStyle.zIndex;
|
|
6095
|
+
$el.style['z-index'] = "".concat(zIndex);
|
|
6096
|
+
break;
|
|
6097
|
+
case 'visibility':
|
|
6098
|
+
var visibility = object.parsedStyle.visibility;
|
|
6099
|
+
$el.style.visibility = visibility;
|
|
6100
|
+
break;
|
|
6101
|
+
case 'pointerEvents':
|
|
6102
|
+
var pointerEvents = object.parsedStyle.pointerEvents;
|
|
6103
|
+
$el.style.pointerEvents = pointerEvents;
|
|
6104
|
+
break;
|
|
6105
|
+
case 'opacity':
|
|
6106
|
+
var opacity = object.parsedStyle.opacity;
|
|
6107
|
+
$el.style.opacity = "".concat(opacity);
|
|
6108
|
+
break;
|
|
6109
|
+
case 'fill':
|
|
6110
|
+
var fill = object.parsedStyle.fill;
|
|
6111
|
+
var color = '';
|
|
6112
|
+
if (fill instanceof gLite.CSSRGB) {
|
|
6113
|
+
if (fill.isNone) {
|
|
6114
|
+
color = 'transparent';
|
|
6115
|
+
} else {
|
|
6116
|
+
color = object.getAttribute('fill');
|
|
6117
|
+
}
|
|
6118
|
+
} else if (Array.isArray(fill)) {
|
|
6119
|
+
color = object.getAttribute('fill');
|
|
6120
|
+
} else if (gLite.isPattern(fill)) ;
|
|
6121
|
+
$el.style.background = color;
|
|
6122
|
+
break;
|
|
6123
|
+
case 'stroke':
|
|
6124
|
+
var stroke = object.parsedStyle.stroke;
|
|
6125
|
+
var borderColor = '';
|
|
6126
|
+
if (stroke instanceof gLite.CSSRGB) {
|
|
6127
|
+
if (stroke.isNone) {
|
|
6128
|
+
borderColor = 'transparent';
|
|
6129
|
+
} else {
|
|
6130
|
+
borderColor = object.getAttribute('stroke');
|
|
6131
|
+
}
|
|
6132
|
+
} else if (Array.isArray(stroke)) {
|
|
5182
6133
|
borderColor = object.getAttribute('stroke');
|
|
5183
|
-
}
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
$el.style.filter = filter;
|
|
5200
|
-
break;
|
|
6134
|
+
} else if (gLite.isPattern(stroke)) ;
|
|
6135
|
+
$el.style['border-color'] = borderColor;
|
|
6136
|
+
$el.style['border-style'] = 'solid';
|
|
6137
|
+
break;
|
|
6138
|
+
case 'lineWidth':
|
|
6139
|
+
var lineWidth = object.parsedStyle.lineWidth;
|
|
6140
|
+
$el.style['border-width'] = "".concat(lineWidth || 0, "px");
|
|
6141
|
+
break;
|
|
6142
|
+
case 'lineDash':
|
|
6143
|
+
$el.style['border-style'] = 'dashed';
|
|
6144
|
+
break;
|
|
6145
|
+
case 'filter':
|
|
6146
|
+
var filter = object.style.filter;
|
|
6147
|
+
$el.style.filter = filter;
|
|
6148
|
+
break;
|
|
6149
|
+
}
|
|
5201
6150
|
}
|
|
5202
|
-
};
|
|
6151
|
+
}]);
|
|
5203
6152
|
return HTMLRenderingPlugin;
|
|
5204
6153
|
}();
|
|
5205
6154
|
HTMLRenderingPlugin.tag = 'HTMLRendering';
|
|
5206
6155
|
var Plugin$4 = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
5207
|
-
|
|
6156
|
+
_inherits$5(Plugin, _AbstractRendererPlug);
|
|
6157
|
+
var _super = _createSuper$5(Plugin);
|
|
5208
6158
|
function Plugin() {
|
|
5209
6159
|
var _this;
|
|
6160
|
+
_classCallCheck$5(this, Plugin);
|
|
5210
6161
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
5211
6162
|
args[_key] = arguments[_key];
|
|
5212
6163
|
}
|
|
5213
|
-
_this =
|
|
6164
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
5214
6165
|
_this.name = 'html-renderer';
|
|
5215
6166
|
return _this;
|
|
5216
6167
|
}
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
6168
|
+
_createClass$5(Plugin, [{
|
|
6169
|
+
key: "init",
|
|
6170
|
+
value: function init() {
|
|
6171
|
+
this.addRenderingPlugin(new HTMLRenderingPlugin());
|
|
6172
|
+
}
|
|
6173
|
+
}, {
|
|
6174
|
+
key: "destroy",
|
|
6175
|
+
value: function destroy() {
|
|
6176
|
+
this.removeAllRenderingPlugins();
|
|
6177
|
+
}
|
|
6178
|
+
}]);
|
|
5224
6179
|
return Plugin;
|
|
5225
6180
|
}(gLite.AbstractRendererPlugin);
|
|
5226
6181
|
|
|
@@ -5305,7 +6260,7 @@
|
|
|
5305
6260
|
if ("throw" !== record.type) {
|
|
5306
6261
|
var result = record.arg,
|
|
5307
6262
|
value = result.value;
|
|
5308
|
-
return value && "object" ==
|
|
6263
|
+
return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
5309
6264
|
invoke("next", value, resolve, reject);
|
|
5310
6265
|
}, function (err) {
|
|
5311
6266
|
invoke("throw", err, resolve, reject);
|
|
@@ -5566,10 +6521,49 @@
|
|
|
5566
6521
|
});
|
|
5567
6522
|
};
|
|
5568
6523
|
}
|
|
5569
|
-
function
|
|
5570
|
-
|
|
5571
|
-
|
|
5572
|
-
|
|
6524
|
+
function _classCallCheck$6(instance, Constructor) {
|
|
6525
|
+
if (!(instance instanceof Constructor)) {
|
|
6526
|
+
throw new TypeError("Cannot call a class as a function");
|
|
6527
|
+
}
|
|
6528
|
+
}
|
|
6529
|
+
function _defineProperties$6(target, props) {
|
|
6530
|
+
for (var i = 0; i < props.length; i++) {
|
|
6531
|
+
var descriptor = props[i];
|
|
6532
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
6533
|
+
descriptor.configurable = true;
|
|
6534
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
6535
|
+
Object.defineProperty(target, _toPropertyKey$6(descriptor.key), descriptor);
|
|
6536
|
+
}
|
|
6537
|
+
}
|
|
6538
|
+
function _createClass$6(Constructor, protoProps, staticProps) {
|
|
6539
|
+
if (protoProps) _defineProperties$6(Constructor.prototype, protoProps);
|
|
6540
|
+
if (staticProps) _defineProperties$6(Constructor, staticProps);
|
|
6541
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
6542
|
+
writable: false
|
|
6543
|
+
});
|
|
6544
|
+
return Constructor;
|
|
6545
|
+
}
|
|
6546
|
+
function _inherits$6(subClass, superClass) {
|
|
6547
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
6548
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
6549
|
+
}
|
|
6550
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
6551
|
+
constructor: {
|
|
6552
|
+
value: subClass,
|
|
6553
|
+
writable: true,
|
|
6554
|
+
configurable: true
|
|
6555
|
+
}
|
|
6556
|
+
});
|
|
6557
|
+
Object.defineProperty(subClass, "prototype", {
|
|
6558
|
+
writable: false
|
|
6559
|
+
});
|
|
6560
|
+
if (superClass) _setPrototypeOf$6(subClass, superClass);
|
|
6561
|
+
}
|
|
6562
|
+
function _getPrototypeOf$6(o) {
|
|
6563
|
+
_getPrototypeOf$6 = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
6564
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
6565
|
+
};
|
|
6566
|
+
return _getPrototypeOf$6(o);
|
|
5573
6567
|
}
|
|
5574
6568
|
function _setPrototypeOf$6(o, p) {
|
|
5575
6569
|
_setPrototypeOf$6 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
@@ -5578,6 +6572,59 @@
|
|
|
5578
6572
|
};
|
|
5579
6573
|
return _setPrototypeOf$6(o, p);
|
|
5580
6574
|
}
|
|
6575
|
+
function _isNativeReflectConstruct$6() {
|
|
6576
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
6577
|
+
if (Reflect.construct.sham) return false;
|
|
6578
|
+
if (typeof Proxy === "function") return true;
|
|
6579
|
+
try {
|
|
6580
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
6581
|
+
return true;
|
|
6582
|
+
} catch (e) {
|
|
6583
|
+
return false;
|
|
6584
|
+
}
|
|
6585
|
+
}
|
|
6586
|
+
function _assertThisInitialized$6(self) {
|
|
6587
|
+
if (self === void 0) {
|
|
6588
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
6589
|
+
}
|
|
6590
|
+
return self;
|
|
6591
|
+
}
|
|
6592
|
+
function _possibleConstructorReturn$6(self, call) {
|
|
6593
|
+
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
6594
|
+
return call;
|
|
6595
|
+
} else if (call !== void 0) {
|
|
6596
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
6597
|
+
}
|
|
6598
|
+
return _assertThisInitialized$6(self);
|
|
6599
|
+
}
|
|
6600
|
+
function _createSuper$6(Derived) {
|
|
6601
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct$6();
|
|
6602
|
+
return function _createSuperInternal() {
|
|
6603
|
+
var Super = _getPrototypeOf$6(Derived),
|
|
6604
|
+
result;
|
|
6605
|
+
if (hasNativeReflectConstruct) {
|
|
6606
|
+
var NewTarget = _getPrototypeOf$6(this).constructor;
|
|
6607
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
6608
|
+
} else {
|
|
6609
|
+
result = Super.apply(this, arguments);
|
|
6610
|
+
}
|
|
6611
|
+
return _possibleConstructorReturn$6(this, result);
|
|
6612
|
+
};
|
|
6613
|
+
}
|
|
6614
|
+
function _toPrimitive$6(input, hint) {
|
|
6615
|
+
if (_typeof(input) !== "object" || input === null) return input;
|
|
6616
|
+
var prim = input[Symbol.toPrimitive];
|
|
6617
|
+
if (prim !== undefined) {
|
|
6618
|
+
var res = prim.call(input, hint || "default");
|
|
6619
|
+
if (_typeof(res) !== "object") return res;
|
|
6620
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
6621
|
+
}
|
|
6622
|
+
return (hint === "string" ? String : Number)(input);
|
|
6623
|
+
}
|
|
6624
|
+
function _toPropertyKey$6(arg) {
|
|
6625
|
+
var key = _toPrimitive$6(arg, "string");
|
|
6626
|
+
return _typeof(key) === "symbol" ? key : String(key);
|
|
6627
|
+
}
|
|
5581
6628
|
|
|
5582
6629
|
/**
|
|
5583
6630
|
* Common utilities
|
|
@@ -5685,252 +6732,275 @@
|
|
|
5685
6732
|
}
|
|
5686
6733
|
var ImagePool = /*#__PURE__*/function () {
|
|
5687
6734
|
function ImagePool(canvasConfig) {
|
|
6735
|
+
_classCallCheck$6(this, ImagePool);
|
|
5688
6736
|
this.canvasConfig = void 0;
|
|
5689
6737
|
this.imageCache = {};
|
|
5690
6738
|
this.gradientCache = {};
|
|
5691
6739
|
this.patternCache = {};
|
|
5692
6740
|
this.canvasConfig = canvasConfig;
|
|
5693
6741
|
}
|
|
5694
|
-
|
|
5695
|
-
|
|
5696
|
-
|
|
5697
|
-
this.
|
|
6742
|
+
_createClass$6(ImagePool, [{
|
|
6743
|
+
key: "getImageSync",
|
|
6744
|
+
value: function getImageSync(src, callback) {
|
|
6745
|
+
if (!this.imageCache[src]) {
|
|
6746
|
+
this.getOrCreateImage(src).then(function () {
|
|
6747
|
+
if (callback) {
|
|
6748
|
+
callback();
|
|
6749
|
+
}
|
|
6750
|
+
});
|
|
6751
|
+
} else {
|
|
5698
6752
|
if (callback) {
|
|
5699
6753
|
callback();
|
|
5700
6754
|
}
|
|
5701
|
-
});
|
|
5702
|
-
} else {
|
|
5703
|
-
if (callback) {
|
|
5704
|
-
callback();
|
|
5705
6755
|
}
|
|
6756
|
+
return this.imageCache[src];
|
|
6757
|
+
}
|
|
6758
|
+
}, {
|
|
6759
|
+
key: "getOrCreateImage",
|
|
6760
|
+
value: function getOrCreateImage(src) {
|
|
6761
|
+
var _this = this;
|
|
6762
|
+
if (this.imageCache[src]) {
|
|
6763
|
+
return Promise.resolve(this.imageCache[src]);
|
|
6764
|
+
}
|
|
6765
|
+
// @see https://github.com/antvis/g/issues/938
|
|
6766
|
+
var createImage = this.canvasConfig.createImage;
|
|
6767
|
+
return new Promise(function (resolve, reject) {
|
|
6768
|
+
var image;
|
|
6769
|
+
if (createImage) {
|
|
6770
|
+
image = createImage(src);
|
|
6771
|
+
} else if (gLite.isBrowser) {
|
|
6772
|
+
image = new window.Image();
|
|
6773
|
+
}
|
|
6774
|
+
if (image) {
|
|
6775
|
+
image.onload = function () {
|
|
6776
|
+
resolve(image);
|
|
6777
|
+
};
|
|
6778
|
+
image.onerror = function (ev) {
|
|
6779
|
+
reject(ev);
|
|
6780
|
+
};
|
|
6781
|
+
image.crossOrigin = 'Anonymous';
|
|
6782
|
+
image.src = src;
|
|
6783
|
+
_this.imageCache[src] = image;
|
|
6784
|
+
}
|
|
6785
|
+
});
|
|
5706
6786
|
}
|
|
5707
|
-
|
|
5708
|
-
|
|
5709
|
-
|
|
5710
|
-
|
|
5711
|
-
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
|
|
5716
|
-
|
|
5717
|
-
var
|
|
5718
|
-
|
|
5719
|
-
|
|
5720
|
-
|
|
5721
|
-
|
|
6787
|
+
}, {
|
|
6788
|
+
key: "getOrCreatePatternSync",
|
|
6789
|
+
value: function getOrCreatePatternSync(pattern, context, $offscreenCanvas, dpr, callback) {
|
|
6790
|
+
var patternKey = this.generatePatternKey(pattern);
|
|
6791
|
+
if (patternKey && this.patternCache[patternKey]) {
|
|
6792
|
+
return this.patternCache[patternKey];
|
|
6793
|
+
}
|
|
6794
|
+
var image = pattern.image,
|
|
6795
|
+
repetition = pattern.repetition,
|
|
6796
|
+
transform = pattern.transform;
|
|
6797
|
+
var src;
|
|
6798
|
+
var needScaleWithDPR = false;
|
|
6799
|
+
// Image URL
|
|
6800
|
+
if (isString(image)) {
|
|
6801
|
+
src = this.getImageSync(image, callback);
|
|
6802
|
+
} else if ($offscreenCanvas) {
|
|
6803
|
+
src = $offscreenCanvas;
|
|
6804
|
+
needScaleWithDPR = true;
|
|
6805
|
+
} else {
|
|
6806
|
+
src = image;
|
|
6807
|
+
}
|
|
6808
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createPattern
|
|
6809
|
+
var canvasPattern = src && context.createPattern(src, repetition);
|
|
6810
|
+
if (canvasPattern) {
|
|
6811
|
+
var mat;
|
|
6812
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasPattern/setTransform
|
|
6813
|
+
if (transform) {
|
|
6814
|
+
mat = gLite.parsedTransformToMat4(gLite.parseTransform(transform));
|
|
6815
|
+
} else {
|
|
6816
|
+
mat = identity(create$3());
|
|
6817
|
+
}
|
|
6818
|
+
if (needScaleWithDPR) {
|
|
6819
|
+
scale(mat, mat, [1 / dpr, 1 / dpr, 1]);
|
|
6820
|
+
}
|
|
6821
|
+
canvasPattern.setTransform({
|
|
6822
|
+
a: mat[0],
|
|
6823
|
+
b: mat[1],
|
|
6824
|
+
c: mat[4],
|
|
6825
|
+
d: mat[5],
|
|
6826
|
+
e: mat[12],
|
|
6827
|
+
f: mat[13]
|
|
6828
|
+
});
|
|
5722
6829
|
}
|
|
5723
|
-
if (
|
|
5724
|
-
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
|
|
5728
|
-
|
|
5729
|
-
|
|
5730
|
-
|
|
5731
|
-
|
|
5732
|
-
|
|
6830
|
+
if (patternKey && canvasPattern) {
|
|
6831
|
+
this.patternCache[patternKey] = canvasPattern;
|
|
6832
|
+
}
|
|
6833
|
+
return canvasPattern;
|
|
6834
|
+
}
|
|
6835
|
+
}, {
|
|
6836
|
+
key: "getOrCreateGradient",
|
|
6837
|
+
value: function getOrCreateGradient(params, context) {
|
|
6838
|
+
var key = this.generateGradientKey(params);
|
|
6839
|
+
var type = params.type,
|
|
6840
|
+
steps = params.steps,
|
|
6841
|
+
width = params.width,
|
|
6842
|
+
height = params.height,
|
|
6843
|
+
angle = params.angle,
|
|
6844
|
+
cx = params.cx,
|
|
6845
|
+
cy = params.cy,
|
|
6846
|
+
size = params.size;
|
|
6847
|
+
if (this.gradientCache[key]) {
|
|
6848
|
+
return this.gradientCache[key];
|
|
6849
|
+
}
|
|
6850
|
+
var gradient = null;
|
|
6851
|
+
if (type === gLite.GradientType.LinearGradient) {
|
|
6852
|
+
var _computeLinearGradien = gLite.computeLinearGradient(width, height, angle),
|
|
6853
|
+
x1 = _computeLinearGradien.x1,
|
|
6854
|
+
y1 = _computeLinearGradien.y1,
|
|
6855
|
+
x2 = _computeLinearGradien.x2,
|
|
6856
|
+
y2 = _computeLinearGradien.y2;
|
|
6857
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createLinearGradient
|
|
6858
|
+
gradient = context.createLinearGradient(x1, y1, x2, y2);
|
|
6859
|
+
} else if (type === gLite.GradientType.RadialGradient) {
|
|
6860
|
+
var _computeRadialGradien = gLite.computeRadialGradient(width, height, cx, cy, size),
|
|
6861
|
+
x = _computeRadialGradien.x,
|
|
6862
|
+
y = _computeRadialGradien.y,
|
|
6863
|
+
r = _computeRadialGradien.r;
|
|
6864
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createRadialGradient
|
|
6865
|
+
gradient = context.createRadialGradient(x, y, 0, x, y, r);
|
|
6866
|
+
}
|
|
6867
|
+
if (gradient) {
|
|
6868
|
+
steps.forEach(function (_ref) {
|
|
6869
|
+
var offset = _ref.offset,
|
|
6870
|
+
color = _ref.color;
|
|
6871
|
+
if (offset.unit === gLite.UnitType.kPercentage) {
|
|
6872
|
+
var _gradient;
|
|
6873
|
+
(_gradient = gradient) === null || _gradient === void 0 ? void 0 : _gradient.addColorStop(offset.value / 100, color.toString());
|
|
6874
|
+
}
|
|
6875
|
+
});
|
|
6876
|
+
this.gradientCache[key] = gradient;
|
|
5733
6877
|
}
|
|
5734
|
-
});
|
|
5735
|
-
};
|
|
5736
|
-
_proto.getOrCreatePatternSync = function getOrCreatePatternSync(pattern, context, $offscreenCanvas, dpr, callback) {
|
|
5737
|
-
var patternKey = this.generatePatternKey(pattern);
|
|
5738
|
-
if (patternKey && this.patternCache[patternKey]) {
|
|
5739
|
-
return this.patternCache[patternKey];
|
|
5740
|
-
}
|
|
5741
|
-
var image = pattern.image,
|
|
5742
|
-
repetition = pattern.repetition,
|
|
5743
|
-
transform = pattern.transform;
|
|
5744
|
-
var src;
|
|
5745
|
-
var needScaleWithDPR = false;
|
|
5746
|
-
// Image URL
|
|
5747
|
-
if (isString(image)) {
|
|
5748
|
-
src = this.getImageSync(image, callback);
|
|
5749
|
-
} else if ($offscreenCanvas) {
|
|
5750
|
-
src = $offscreenCanvas;
|
|
5751
|
-
needScaleWithDPR = true;
|
|
5752
|
-
} else {
|
|
5753
|
-
src = image;
|
|
5754
|
-
}
|
|
5755
|
-
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createPattern
|
|
5756
|
-
var canvasPattern = src && context.createPattern(src, repetition);
|
|
5757
|
-
if (canvasPattern) {
|
|
5758
|
-
var mat;
|
|
5759
|
-
// @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasPattern/setTransform
|
|
5760
|
-
if (transform) {
|
|
5761
|
-
mat = gLite.parsedTransformToMat4(gLite.parseTransform(transform));
|
|
5762
|
-
} else {
|
|
5763
|
-
mat = identity(create$3());
|
|
5764
|
-
}
|
|
5765
|
-
if (needScaleWithDPR) {
|
|
5766
|
-
scale(mat, mat, [1 / dpr, 1 / dpr, 1]);
|
|
5767
|
-
}
|
|
5768
|
-
canvasPattern.setTransform({
|
|
5769
|
-
a: mat[0],
|
|
5770
|
-
b: mat[1],
|
|
5771
|
-
c: mat[4],
|
|
5772
|
-
d: mat[5],
|
|
5773
|
-
e: mat[12],
|
|
5774
|
-
f: mat[13]
|
|
5775
|
-
});
|
|
5776
|
-
}
|
|
5777
|
-
if (patternKey && canvasPattern) {
|
|
5778
|
-
this.patternCache[patternKey] = canvasPattern;
|
|
5779
|
-
}
|
|
5780
|
-
return canvasPattern;
|
|
5781
|
-
};
|
|
5782
|
-
_proto.getOrCreateGradient = function getOrCreateGradient(params, context) {
|
|
5783
|
-
var key = this.generateGradientKey(params);
|
|
5784
|
-
var type = params.type,
|
|
5785
|
-
steps = params.steps,
|
|
5786
|
-
width = params.width,
|
|
5787
|
-
height = params.height,
|
|
5788
|
-
angle = params.angle,
|
|
5789
|
-
cx = params.cx,
|
|
5790
|
-
cy = params.cy,
|
|
5791
|
-
size = params.size;
|
|
5792
|
-
if (this.gradientCache[key]) {
|
|
5793
6878
|
return this.gradientCache[key];
|
|
5794
6879
|
}
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
}
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
|
|
5816
|
-
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
})
|
|
5821
|
-
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
};
|
|
5825
|
-
_proto.generateGradientKey = function generateGradientKey(params) {
|
|
5826
|
-
var type = params.type,
|
|
5827
|
-
width = params.width,
|
|
5828
|
-
height = params.height,
|
|
5829
|
-
steps = params.steps,
|
|
5830
|
-
angle = params.angle,
|
|
5831
|
-
cx = params.cx,
|
|
5832
|
-
cy = params.cy,
|
|
5833
|
-
size = params.size;
|
|
5834
|
-
return "gradient-" + type + "-" + ((angle === null || angle === void 0 ? void 0 : angle.toString()) || 0) + "-" + ((cx === null || cx === void 0 ? void 0 : cx.toString()) || 0) + "-" + ((cy === null || cy === void 0 ? void 0 : cy.toString()) || 0) + "-" + ((size === null || size === void 0 ? void 0 : size.toString()) || 0) + "-" + width + "-" + height + "-" + steps.map(function (_ref2) {
|
|
5835
|
-
var offset = _ref2.offset,
|
|
5836
|
-
color = _ref2.color;
|
|
5837
|
-
return "" + offset + color;
|
|
5838
|
-
}).join('-');
|
|
5839
|
-
};
|
|
5840
|
-
_proto.generatePatternKey = function generatePatternKey(pattern) {
|
|
5841
|
-
var image = pattern.image,
|
|
5842
|
-
repetition = pattern.repetition;
|
|
5843
|
-
// only generate cache for Image
|
|
5844
|
-
if (isString(image)) {
|
|
5845
|
-
return "pattern-" + image + "-" + repetition;
|
|
5846
|
-
} else if (image instanceof gLite.Rect) {
|
|
5847
|
-
return "pattern-" + image.entity + "-" + repetition;
|
|
5848
|
-
}
|
|
5849
|
-
};
|
|
6880
|
+
}, {
|
|
6881
|
+
key: "generateGradientKey",
|
|
6882
|
+
value: function generateGradientKey(params) {
|
|
6883
|
+
var type = params.type,
|
|
6884
|
+
width = params.width,
|
|
6885
|
+
height = params.height,
|
|
6886
|
+
steps = params.steps,
|
|
6887
|
+
angle = params.angle,
|
|
6888
|
+
cx = params.cx,
|
|
6889
|
+
cy = params.cy,
|
|
6890
|
+
size = params.size;
|
|
6891
|
+
return "gradient-".concat(type, "-").concat((angle === null || angle === void 0 ? void 0 : angle.toString()) || 0, "-").concat((cx === null || cx === void 0 ? void 0 : cx.toString()) || 0, "-").concat((cy === null || cy === void 0 ? void 0 : cy.toString()) || 0, "-").concat((size === null || size === void 0 ? void 0 : size.toString()) || 0, "-").concat(width, "-").concat(height, "-").concat(steps.map(function (_ref2) {
|
|
6892
|
+
var offset = _ref2.offset,
|
|
6893
|
+
color = _ref2.color;
|
|
6894
|
+
return "".concat(offset).concat(color);
|
|
6895
|
+
}).join('-'));
|
|
6896
|
+
}
|
|
6897
|
+
}, {
|
|
6898
|
+
key: "generatePatternKey",
|
|
6899
|
+
value: function generatePatternKey(pattern) {
|
|
6900
|
+
var image = pattern.image,
|
|
6901
|
+
repetition = pattern.repetition;
|
|
6902
|
+
// only generate cache for Image
|
|
6903
|
+
if (isString(image)) {
|
|
6904
|
+
return "pattern-".concat(image, "-").concat(repetition);
|
|
6905
|
+
} else if (image instanceof gLite.Rect) {
|
|
6906
|
+
return "pattern-".concat(image.entity, "-").concat(repetition);
|
|
6907
|
+
}
|
|
6908
|
+
}
|
|
6909
|
+
}]);
|
|
5850
6910
|
return ImagePool;
|
|
5851
6911
|
}();
|
|
5852
6912
|
var LoadImagePlugin = /*#__PURE__*/function () {
|
|
5853
|
-
function LoadImagePlugin() {
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
|
|
5862
|
-
|
|
5863
|
-
var
|
|
5864
|
-
|
|
5865
|
-
|
|
5866
|
-
var
|
|
5867
|
-
|
|
5868
|
-
|
|
5869
|
-
|
|
5870
|
-
|
|
5871
|
-
|
|
5872
|
-
});
|
|
5873
|
-
}
|
|
5874
|
-
}
|
|
5875
|
-
};
|
|
5876
|
-
var handleAttributeChanged = function handleAttributeChanged(e) {
|
|
5877
|
-
var object = e.target;
|
|
5878
|
-
var attrName = e.attrName,
|
|
5879
|
-
newValue = e.newValue;
|
|
5880
|
-
if (object.nodeName === gLite.Shape.IMAGE) {
|
|
5881
|
-
if (attrName === 'img') {
|
|
5882
|
-
if (isString(newValue)) {
|
|
5883
|
-
imagePool.getOrCreateImage(newValue).then(function () {
|
|
6913
|
+
function LoadImagePlugin() {
|
|
6914
|
+
_classCallCheck$6(this, LoadImagePlugin);
|
|
6915
|
+
}
|
|
6916
|
+
_createClass$6(LoadImagePlugin, [{
|
|
6917
|
+
key: "apply",
|
|
6918
|
+
value: function apply(context) {
|
|
6919
|
+
// @ts-ignore
|
|
6920
|
+
var renderingService = context.renderingService,
|
|
6921
|
+
renderingContext = context.renderingContext,
|
|
6922
|
+
imagePool = context.imagePool;
|
|
6923
|
+
var canvas = renderingContext.root.ownerDocument.defaultView;
|
|
6924
|
+
var handleMounted = function handleMounted(e) {
|
|
6925
|
+
var object = e.target;
|
|
6926
|
+
var nodeName = object.nodeName,
|
|
6927
|
+
attributes = object.attributes;
|
|
6928
|
+
if (nodeName === gLite.Shape.IMAGE) {
|
|
6929
|
+
var img = attributes.img;
|
|
6930
|
+
if (isString(img)) {
|
|
6931
|
+
imagePool.getImageSync(img, function () {
|
|
5884
6932
|
// set dirty rectangle flag
|
|
5885
6933
|
object.renderable.dirty = true;
|
|
5886
6934
|
renderingService.dirtify();
|
|
5887
6935
|
});
|
|
5888
6936
|
}
|
|
5889
6937
|
}
|
|
5890
|
-
}
|
|
5891
|
-
|
|
5892
|
-
|
|
5893
|
-
|
|
5894
|
-
|
|
5895
|
-
|
|
5896
|
-
|
|
5897
|
-
|
|
5898
|
-
|
|
5899
|
-
|
|
5900
|
-
|
|
5901
|
-
|
|
6938
|
+
};
|
|
6939
|
+
var handleAttributeChanged = function handleAttributeChanged(e) {
|
|
6940
|
+
var object = e.target;
|
|
6941
|
+
var attrName = e.attrName,
|
|
6942
|
+
newValue = e.newValue;
|
|
6943
|
+
if (object.nodeName === gLite.Shape.IMAGE) {
|
|
6944
|
+
if (attrName === 'img') {
|
|
6945
|
+
if (isString(newValue)) {
|
|
6946
|
+
imagePool.getOrCreateImage(newValue).then(function () {
|
|
6947
|
+
// set dirty rectangle flag
|
|
6948
|
+
object.renderable.dirty = true;
|
|
6949
|
+
renderingService.dirtify();
|
|
6950
|
+
});
|
|
6951
|
+
}
|
|
5902
6952
|
}
|
|
5903
6953
|
}
|
|
5904
|
-
}
|
|
5905
|
-
|
|
5906
|
-
|
|
5907
|
-
|
|
5908
|
-
|
|
5909
|
-
|
|
5910
|
-
|
|
6954
|
+
};
|
|
6955
|
+
renderingService.hooks.init.tapPromise(LoadImagePlugin.tag, /*#__PURE__*/_asyncToGenerator$5( /*#__PURE__*/_regeneratorRuntime$5().mark(function _callee() {
|
|
6956
|
+
return _regeneratorRuntime$5().wrap(function _callee$(_context) {
|
|
6957
|
+
while (1) {
|
|
6958
|
+
switch (_context.prev = _context.next) {
|
|
6959
|
+
case 0:
|
|
6960
|
+
canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
|
|
6961
|
+
canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
6962
|
+
case 2:
|
|
6963
|
+
case "end":
|
|
6964
|
+
return _context.stop();
|
|
6965
|
+
}
|
|
6966
|
+
}
|
|
6967
|
+
}, _callee);
|
|
6968
|
+
})));
|
|
6969
|
+
renderingService.hooks.destroy.tap(LoadImagePlugin.tag, function () {
|
|
6970
|
+
canvas.removeEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
|
|
6971
|
+
canvas.removeEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
6972
|
+
});
|
|
6973
|
+
}
|
|
6974
|
+
}]);
|
|
5911
6975
|
return LoadImagePlugin;
|
|
5912
6976
|
}();
|
|
5913
6977
|
LoadImagePlugin.tag = 'LoadImage';
|
|
5914
6978
|
var Plugin$5 = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
5915
|
-
|
|
6979
|
+
_inherits$6(Plugin, _AbstractRendererPlug);
|
|
6980
|
+
var _super = _createSuper$6(Plugin);
|
|
5916
6981
|
function Plugin() {
|
|
5917
6982
|
var _this;
|
|
6983
|
+
_classCallCheck$6(this, Plugin);
|
|
5918
6984
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
5919
6985
|
args[_key] = arguments[_key];
|
|
5920
6986
|
}
|
|
5921
|
-
_this =
|
|
6987
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
5922
6988
|
_this.name = 'image-loader';
|
|
5923
6989
|
return _this;
|
|
5924
6990
|
}
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
|
|
5928
|
-
|
|
5929
|
-
|
|
5930
|
-
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
|
|
6991
|
+
_createClass$6(Plugin, [{
|
|
6992
|
+
key: "init",
|
|
6993
|
+
value: function init() {
|
|
6994
|
+
// @ts-ignore
|
|
6995
|
+
this.context.imagePool = new ImagePool(this.context.config);
|
|
6996
|
+
this.addRenderingPlugin(new LoadImagePlugin());
|
|
6997
|
+
}
|
|
6998
|
+
}, {
|
|
6999
|
+
key: "destroy",
|
|
7000
|
+
value: function destroy() {
|
|
7001
|
+
this.removeAllRenderingPlugins();
|
|
7002
|
+
}
|
|
7003
|
+
}]);
|
|
5934
7004
|
return Plugin;
|
|
5935
7005
|
}(gLite.AbstractRendererPlugin);
|
|
5936
7006
|
|
|
@@ -5942,6 +7012,7 @@
|
|
|
5942
7012
|
|
|
5943
7013
|
var Canvas2DContextService = /*#__PURE__*/function () {
|
|
5944
7014
|
function Canvas2DContextService(context) {
|
|
7015
|
+
_classCallCheck(this, Canvas2DContextService);
|
|
5945
7016
|
this.$container = void 0;
|
|
5946
7017
|
this.$canvas = void 0;
|
|
5947
7018
|
this.dpr = void 0;
|
|
@@ -5951,149 +7022,176 @@
|
|
|
5951
7022
|
this.renderingContext = context.renderingContext;
|
|
5952
7023
|
this.canvasConfig = context.config;
|
|
5953
7024
|
}
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
var
|
|
5958
|
-
|
|
5959
|
-
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
|
|
5963
|
-
|
|
5964
|
-
|
|
5965
|
-
|
|
5966
|
-
container.
|
|
5967
|
-
|
|
5968
|
-
|
|
5969
|
-
|
|
5970
|
-
|
|
5971
|
-
|
|
5972
|
-
|
|
5973
|
-
|
|
5974
|
-
|
|
5975
|
-
|
|
5976
|
-
|
|
5977
|
-
|
|
5978
|
-
this.$container.style.position
|
|
7025
|
+
_createClass(Canvas2DContextService, [{
|
|
7026
|
+
key: "init",
|
|
7027
|
+
value: function () {
|
|
7028
|
+
var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
7029
|
+
var _this$canvasConfig, container, canvas, $canvas;
|
|
7030
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
7031
|
+
while (1) {
|
|
7032
|
+
switch (_context.prev = _context.next) {
|
|
7033
|
+
case 0:
|
|
7034
|
+
_this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas;
|
|
7035
|
+
if (canvas) {
|
|
7036
|
+
this.$canvas = canvas;
|
|
7037
|
+
if (container && canvas.parentElement !== container) {
|
|
7038
|
+
container.appendChild(canvas);
|
|
7039
|
+
}
|
|
7040
|
+
this.$container = canvas.parentElement;
|
|
7041
|
+
this.canvasConfig.container = this.$container;
|
|
7042
|
+
} else if (container) {
|
|
7043
|
+
// create container
|
|
7044
|
+
this.$container = isString(container) ? document.getElementById(container) : container;
|
|
7045
|
+
if (this.$container) {
|
|
7046
|
+
// create canvas
|
|
7047
|
+
$canvas = document.createElement('canvas');
|
|
7048
|
+
this.$container.appendChild($canvas);
|
|
7049
|
+
if (!this.$container.style.position) {
|
|
7050
|
+
this.$container.style.position = 'relative';
|
|
7051
|
+
}
|
|
7052
|
+
this.$canvas = $canvas;
|
|
5979
7053
|
}
|
|
5980
|
-
this.$canvas = $canvas;
|
|
5981
7054
|
}
|
|
5982
|
-
|
|
5983
|
-
|
|
5984
|
-
|
|
5985
|
-
|
|
5986
|
-
|
|
5987
|
-
|
|
7055
|
+
this.context = this.$canvas.getContext('2d');
|
|
7056
|
+
this.resize(this.canvasConfig.width, this.canvasConfig.height);
|
|
7057
|
+
case 4:
|
|
7058
|
+
case "end":
|
|
7059
|
+
return _context.stop();
|
|
7060
|
+
}
|
|
5988
7061
|
}
|
|
5989
|
-
}
|
|
5990
|
-
}
|
|
5991
|
-
|
|
5992
|
-
|
|
5993
|
-
|
|
5994
|
-
|
|
5995
|
-
|
|
5996
|
-
}
|
|
5997
|
-
|
|
5998
|
-
|
|
5999
|
-
|
|
6000
|
-
|
|
6001
|
-
|
|
6002
|
-
|
|
6003
|
-
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
|
|
6008
|
-
|
|
6009
|
-
|
|
6010
|
-
|
|
6011
|
-
|
|
6012
|
-
|
|
6013
|
-
|
|
6014
|
-
|
|
7062
|
+
}, _callee, this);
|
|
7063
|
+
}));
|
|
7064
|
+
function init() {
|
|
7065
|
+
return _init.apply(this, arguments);
|
|
7066
|
+
}
|
|
7067
|
+
return init;
|
|
7068
|
+
}()
|
|
7069
|
+
}, {
|
|
7070
|
+
key: "getContext",
|
|
7071
|
+
value: function getContext() {
|
|
7072
|
+
return this.context;
|
|
7073
|
+
}
|
|
7074
|
+
}, {
|
|
7075
|
+
key: "getDomElement",
|
|
7076
|
+
value: function getDomElement() {
|
|
7077
|
+
return this.$canvas;
|
|
7078
|
+
}
|
|
7079
|
+
}, {
|
|
7080
|
+
key: "getDPR",
|
|
7081
|
+
value: function getDPR() {
|
|
7082
|
+
return this.dpr;
|
|
7083
|
+
}
|
|
7084
|
+
}, {
|
|
7085
|
+
key: "getBoundingClientRect",
|
|
7086
|
+
value: function getBoundingClientRect() {
|
|
7087
|
+
if (this.$canvas.getBoundingClientRect) {
|
|
7088
|
+
return this.$canvas.getBoundingClientRect();
|
|
7089
|
+
}
|
|
7090
|
+
}
|
|
7091
|
+
}, {
|
|
7092
|
+
key: "destroy",
|
|
7093
|
+
value: function destroy() {
|
|
6015
7094
|
// @ts-ignore
|
|
6016
|
-
this.$container
|
|
6017
|
-
|
|
6018
|
-
|
|
6019
|
-
|
|
6020
|
-
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
|
|
6026
|
-
//
|
|
6027
|
-
|
|
6028
|
-
|
|
6029
|
-
|
|
6030
|
-
|
|
6031
|
-
|
|
6032
|
-
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
7095
|
+
if (this.$container && this.$canvas && this.$canvas.parentNode) {
|
|
7096
|
+
// destroy context
|
|
7097
|
+
// @ts-ignore
|
|
7098
|
+
this.$container.removeChild(this.$canvas);
|
|
7099
|
+
}
|
|
7100
|
+
}
|
|
7101
|
+
}, {
|
|
7102
|
+
key: "resize",
|
|
7103
|
+
value: function resize(width, height) {
|
|
7104
|
+
var devicePixelRatio = this.canvasConfig.devicePixelRatio;
|
|
7105
|
+
// use user-defined dpr first
|
|
7106
|
+
var dpr = devicePixelRatio || gLite.isBrowser && window.devicePixelRatio || 1;
|
|
7107
|
+
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
7108
|
+
this.dpr = dpr;
|
|
7109
|
+
if (this.$canvas) {
|
|
7110
|
+
// set canvas width & height
|
|
7111
|
+
this.$canvas.width = this.dpr * width;
|
|
7112
|
+
this.$canvas.height = this.dpr * height;
|
|
7113
|
+
// set CSS style width & height
|
|
7114
|
+
gLite.setDOMSize(this.$canvas, width, height);
|
|
7115
|
+
// const dpr = this.getDPR();
|
|
7116
|
+
// scale all drawing operations by the dpr
|
|
7117
|
+
// @see https://www.html5rocks.com/en/tutorials/canvas/hidpi/
|
|
7118
|
+
// this.context.scale(dpr, dpr);
|
|
7119
|
+
}
|
|
6036
7120
|
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
|
|
7121
|
+
this.renderingContext.renderReasons.add(gLite.RenderReason.CAMERA_CHANGED);
|
|
7122
|
+
}
|
|
7123
|
+
}, {
|
|
7124
|
+
key: "applyCursorStyle",
|
|
7125
|
+
value: function applyCursorStyle(cursor) {
|
|
7126
|
+
if (this.$container && this.$container.style) {
|
|
7127
|
+
this.$container.style.cursor = cursor;
|
|
7128
|
+
}
|
|
7129
|
+
}
|
|
7130
|
+
}, {
|
|
7131
|
+
key: "toDataURL",
|
|
7132
|
+
value: function () {
|
|
7133
|
+
var _toDataURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
7134
|
+
var options,
|
|
7135
|
+
type,
|
|
7136
|
+
encoderOptions,
|
|
7137
|
+
_args2 = arguments;
|
|
7138
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
7139
|
+
while (1) {
|
|
7140
|
+
switch (_context2.prev = _context2.next) {
|
|
7141
|
+
case 0:
|
|
7142
|
+
options = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
|
|
7143
|
+
type = options.type, encoderOptions = options.encoderOptions;
|
|
7144
|
+
return _context2.abrupt("return", this.context.canvas.toDataURL(type, encoderOptions));
|
|
7145
|
+
case 3:
|
|
7146
|
+
case "end":
|
|
7147
|
+
return _context2.stop();
|
|
7148
|
+
}
|
|
6059
7149
|
}
|
|
6060
|
-
}
|
|
6061
|
-
}
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
|
|
6065
|
-
|
|
6066
|
-
|
|
6067
|
-
}
|
|
7150
|
+
}, _callee2, this);
|
|
7151
|
+
}));
|
|
7152
|
+
function toDataURL() {
|
|
7153
|
+
return _toDataURL.apply(this, arguments);
|
|
7154
|
+
}
|
|
7155
|
+
return toDataURL;
|
|
7156
|
+
}()
|
|
7157
|
+
}]);
|
|
6068
7158
|
return Canvas2DContextService;
|
|
6069
7159
|
}();
|
|
6070
7160
|
|
|
6071
7161
|
var ContextRegisterPlugin = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
6072
|
-
|
|
7162
|
+
_inherits(ContextRegisterPlugin, _AbstractRendererPlug);
|
|
7163
|
+
var _super = _createSuper(ContextRegisterPlugin);
|
|
6073
7164
|
function ContextRegisterPlugin() {
|
|
6074
7165
|
var _this;
|
|
7166
|
+
_classCallCheck(this, ContextRegisterPlugin);
|
|
6075
7167
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
6076
7168
|
args[_key] = arguments[_key];
|
|
6077
7169
|
}
|
|
6078
|
-
_this =
|
|
7170
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
6079
7171
|
_this.name = 'canvas-context-register';
|
|
6080
7172
|
return _this;
|
|
6081
7173
|
}
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
|
-
|
|
6088
|
-
|
|
7174
|
+
_createClass(ContextRegisterPlugin, [{
|
|
7175
|
+
key: "init",
|
|
7176
|
+
value: function init() {
|
|
7177
|
+
this.context.ContextService = Canvas2DContextService;
|
|
7178
|
+
}
|
|
7179
|
+
}, {
|
|
7180
|
+
key: "destroy",
|
|
7181
|
+
value: function destroy() {
|
|
7182
|
+
delete this.context.ContextService;
|
|
7183
|
+
}
|
|
7184
|
+
}]);
|
|
6089
7185
|
return ContextRegisterPlugin;
|
|
6090
7186
|
}(gLite.AbstractRendererPlugin);
|
|
6091
7187
|
|
|
6092
7188
|
var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
6093
|
-
|
|
7189
|
+
_inherits(Renderer, _AbstractRenderer);
|
|
7190
|
+
var _super = _createSuper(Renderer);
|
|
6094
7191
|
function Renderer(config) {
|
|
6095
7192
|
var _this;
|
|
6096
|
-
|
|
7193
|
+
_classCallCheck(this, Renderer);
|
|
7194
|
+
_this = _super.call(this, config);
|
|
6097
7195
|
// register Canvas2DContext
|
|
6098
7196
|
_this.registerPlugin(new ContextRegisterPlugin());
|
|
6099
7197
|
_this.registerPlugin(new Plugin$5());
|
|
@@ -6107,7 +7205,7 @@
|
|
|
6107
7205
|
_this.registerPlugin(new Plugin$4());
|
|
6108
7206
|
return _this;
|
|
6109
7207
|
}
|
|
6110
|
-
return Renderer;
|
|
7208
|
+
return _createClass(Renderer);
|
|
6111
7209
|
}(gLite.AbstractRenderer);
|
|
6112
7210
|
|
|
6113
7211
|
exports.CanvasPathGenerator = index_esm;
|