@antv/g-canvas 1.6.0-alpha.0 → 1.6.2

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.umd.js CHANGED
@@ -400,6 +400,21 @@
400
400
  return _setPrototypeOf(o, p);
401
401
  }
402
402
 
403
+ function _inheritsLoose$1(subClass, superClass) {
404
+ subClass.prototype = Object.create(superClass.prototype);
405
+ subClass.prototype.constructor = subClass;
406
+
407
+ _setPrototypeOf$1(subClass, superClass);
408
+ }
409
+
410
+ function _setPrototypeOf$1(o, p) {
411
+ _setPrototypeOf$1 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
412
+ o.__proto__ = p;
413
+ return o;
414
+ };
415
+ return _setPrototypeOf$1(o, p);
416
+ }
417
+
403
418
  var PathGeneratorFactory = g.Syringe.defineToken('PathGeneratorFactory');
404
419
  var PathGenerator = g.Syringe.defineToken('PathGenerator');
405
420
 
@@ -637,23 +652,33 @@
637
652
  });
638
653
  });
639
654
 
640
- var Plugin = /*#__PURE__*/function () {
655
+ var Plugin = /*#__PURE__*/function (_AbstractRendererPlug) {
656
+ _inheritsLoose$1(Plugin, _AbstractRendererPlug);
657
+
641
658
  function Plugin() {
642
- this.name = 'canvas-path-generator';
659
+ var _this;
660
+
661
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
662
+ args[_key] = arguments[_key];
663
+ }
664
+
665
+ _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
666
+ _this.name = 'canvas-path-generator';
667
+ return _this;
643
668
  }
644
669
 
645
670
  var _proto = Plugin.prototype;
646
671
 
647
- _proto.init = function init(container) {
648
- container.load(containerModule, true);
672
+ _proto.init = function init() {
673
+ this.container.load(containerModule, true);
649
674
  };
650
675
 
651
- _proto.destroy = function destroy(container) {
652
- container.unload(containerModule);
676
+ _proto.destroy = function destroy() {
677
+ this.container.unload(containerModule);
653
678
  };
654
679
 
655
680
  return Plugin;
656
- }();
681
+ }(g.AbstractRendererPlugin);
657
682
 
658
683
  var index_esm = /*#__PURE__*/Object.freeze({
659
684
  __proto__: null,
@@ -1073,6 +1098,21 @@
1073
1098
  });
1074
1099
  };
1075
1100
  }
1101
+
1102
+ function _inheritsLoose$2(subClass, superClass) {
1103
+ subClass.prototype = Object.create(superClass.prototype);
1104
+ subClass.prototype.constructor = subClass;
1105
+
1106
+ _setPrototypeOf$2(subClass, superClass);
1107
+ }
1108
+
1109
+ function _setPrototypeOf$2(o, p) {
1110
+ _setPrototypeOf$2 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
1111
+ o.__proto__ = p;
1112
+ return o;
1113
+ };
1114
+ return _setPrototypeOf$2(o, p);
1115
+ }
1076
1116
  /**
1077
1117
  * Common utilities
1078
1118
  * @module glMatrix
@@ -2524,192 +2564,39 @@
2524
2564
  register(CanvasPickerPlugin);
2525
2565
  });
2526
2566
 
2527
- var Plugin$1 = /*#__PURE__*/function () {
2567
+ var Plugin$1 = /*#__PURE__*/function (_AbstractRendererPlug) {
2568
+ _inheritsLoose$2(Plugin, _AbstractRendererPlug);
2569
+
2528
2570
  function Plugin() {
2529
- this.name = 'canvas-picker';
2571
+ var _this;
2572
+
2573
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2574
+ args[_key] = arguments[_key];
2575
+ }
2576
+
2577
+ _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
2578
+ _this.name = 'canvas-picker';
2579
+ return _this;
2530
2580
  }
2531
2581
 
2532
2582
  var _proto = Plugin.prototype;
2533
2583
 
2534
- _proto.init = function init(container) {
2535
- container.load(containerModule$1, true);
2584
+ _proto.init = function init() {
2585
+ this.container.load(containerModule$1, true);
2536
2586
  };
2537
2587
 
2538
- _proto.destroy = function destroy(container) {
2539
- container.unload(containerModule$1);
2588
+ _proto.destroy = function destroy() {
2589
+ this.container.unload(containerModule$1);
2540
2590
  };
2541
2591
 
2542
2592
  return Plugin;
2543
- }();
2593
+ }(g.AbstractRendererPlugin);
2544
2594
 
2545
2595
  var index_esm$1 = /*#__PURE__*/Object.freeze({
2546
2596
  __proto__: null,
2547
2597
  Plugin: Plugin$1
2548
2598
  });
2549
2599
 
2550
- var ImagePool = /*#__PURE__*/function () {
2551
- function ImagePool() {
2552
- this.imageCache = {};
2553
- this.gradientCache = {};
2554
- this.patternCache = {};
2555
- this.canvasConfig = void 0;
2556
- }
2557
-
2558
- var _proto = ImagePool.prototype;
2559
-
2560
- _proto.getImageSync = function getImageSync(src, callback) {
2561
- if (!this.imageCache[src]) {
2562
- this.getOrCreateImage(src).then(function () {
2563
- if (callback) {
2564
- callback();
2565
- }
2566
- });
2567
- }
2568
-
2569
- return this.imageCache[src];
2570
- };
2571
-
2572
- _proto.getOrCreateImage = function getOrCreateImage(src) {
2573
- var _this = this;
2574
-
2575
- if (this.imageCache[src]) {
2576
- return Promise.resolve(this.imageCache[src]);
2577
- } // @see https://github.com/antvis/g/issues/938
2578
-
2579
-
2580
- var createImage = this.canvasConfig.createImage;
2581
- return new Promise(function (resolve, reject) {
2582
- var image;
2583
-
2584
- if (createImage) {
2585
- image = createImage(src);
2586
- } else if (g.isBrowser) {
2587
- image = new window.Image();
2588
- }
2589
-
2590
- if (image) {
2591
- image.onload = function () {
2592
- resolve(image);
2593
- };
2594
-
2595
- image.onerror = function (ev) {
2596
- reject(ev);
2597
- };
2598
-
2599
- image.crossOrigin = 'Anonymous';
2600
- image.src = src;
2601
- _this.imageCache[src] = image;
2602
- }
2603
- });
2604
- };
2605
-
2606
- _proto.getOrCreatePatternSync = function getOrCreatePatternSync(pattern, context, callback) {
2607
- var patternKey = this.generatePatternKey(pattern);
2608
-
2609
- if (patternKey && this.patternCache[patternKey]) {
2610
- return this.patternCache[patternKey];
2611
- }
2612
-
2613
- var image = pattern.image,
2614
- repetition = pattern.repetition;
2615
- var src; // Image URL
2616
-
2617
- if (g.isString(image)) {
2618
- src = this.getImageSync(image, callback);
2619
- } else {
2620
- src = image;
2621
- } // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createPattern
2622
-
2623
-
2624
- var canvasPattern = src && context.createPattern(src, repetition);
2625
-
2626
- if (patternKey && canvasPattern) {
2627
- this.patternCache[patternKey] = canvasPattern;
2628
- }
2629
-
2630
- return canvasPattern;
2631
- };
2632
-
2633
- _proto.getOrCreateGradient = function getOrCreateGradient(params, context) {
2634
- var key = this.generateGradientKey(params); // @ts-ignore
2635
-
2636
- var type = params.type,
2637
- steps = params.steps,
2638
- width = params.width,
2639
- height = params.height,
2640
- angle = params.angle,
2641
- cx = params.cx,
2642
- cy = params.cy;
2643
-
2644
- if (this.gradientCache[key]) {
2645
- return this.gradientCache[key];
2646
- }
2647
-
2648
- var gradient = null;
2649
-
2650
- if (type === g.GradientType.LinearGradient) {
2651
- var _computeLinearGradien = g.computeLinearGradient(width, height, angle),
2652
- x1 = _computeLinearGradien.x1,
2653
- y1 = _computeLinearGradien.y1,
2654
- x2 = _computeLinearGradien.x2,
2655
- y2 = _computeLinearGradien.y2; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createLinearGradient
2656
-
2657
-
2658
- gradient = context.createLinearGradient(x1, y1, x2, y2);
2659
- } else if (type === g.GradientType.RadialGradient) {
2660
- var _computeRadialGradien = g.computeRadialGradient(width, height, cx, cy),
2661
- x = _computeRadialGradien.x,
2662
- y = _computeRadialGradien.y,
2663
- r = _computeRadialGradien.r; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createRadialGradient
2664
-
2665
-
2666
- gradient = context.createRadialGradient(x, y, 0, x, y, r);
2667
- }
2668
-
2669
- if (gradient) {
2670
- steps.forEach(function (_ref) {
2671
- var _gradient;
2672
-
2673
- var offset = _ref[0],
2674
- color = _ref[1];
2675
- (_gradient = gradient) === null || _gradient === void 0 ? void 0 : _gradient.addColorStop(offset, color);
2676
- });
2677
- this.gradientCache[key] = gradient;
2678
- }
2679
-
2680
- return this.gradientCache[key];
2681
- };
2682
-
2683
- _proto.generateGradientKey = function generateGradientKey(params) {
2684
- // @ts-ignore
2685
- var type = params.type,
2686
- width = params.width,
2687
- height = params.height,
2688
- steps = params.steps,
2689
- angle = params.angle,
2690
- cx = params.cx,
2691
- cy = params.cy;
2692
- return "gradient-" + type + "-" + (angle || 0) + "-" + (cx || 0) + "-" + (cy || 0) + "-" + width + "-" + height + "-" + steps.map(function (step) {
2693
- return step.join('');
2694
- }).join('-');
2695
- };
2696
-
2697
- _proto.generatePatternKey = function generatePatternKey(pattern) {
2698
- var image = pattern.image,
2699
- repetition = pattern.repetition; // only generate cache for Image
2700
-
2701
- if (g.isString(image)) {
2702
- return "pattern-" + image + "-" + repetition;
2703
- }
2704
- };
2705
-
2706
- return ImagePool;
2707
- }();
2708
-
2709
- __decorate([g.inject(g.CanvasConfig), __metadata("design:type", Object)], ImagePool.prototype, "canvasConfig", void 0);
2710
-
2711
- ImagePool = __decorate([g.singleton()], ImagePool);
2712
-
2713
2600
  function _regeneratorRuntime$2() {
2714
2601
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
2715
2602
  _regeneratorRuntime$2 = function _regeneratorRuntime() {
@@ -3044,57 +2931,235 @@
3044
2931
  resetTryEntry(entry);
3045
2932
  }
3046
2933
 
3047
- return thrown;
3048
- }
3049
- }
2934
+ return thrown;
2935
+ }
2936
+ }
2937
+
2938
+ throw new Error("illegal catch attempt");
2939
+ },
2940
+ delegateYield: function delegateYield(iterable, resultName, nextLoc) {
2941
+ return this.delegate = {
2942
+ iterator: values(iterable),
2943
+ resultName: resultName,
2944
+ nextLoc: nextLoc
2945
+ }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
2946
+ }
2947
+ }, exports;
2948
+ }
2949
+
2950
+ function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
2951
+ try {
2952
+ var info = gen[key](arg);
2953
+ var value = info.value;
2954
+ } catch (error) {
2955
+ reject(error);
2956
+ return;
2957
+ }
2958
+
2959
+ if (info.done) {
2960
+ resolve(value);
2961
+ } else {
2962
+ Promise.resolve(value).then(_next, _throw);
2963
+ }
2964
+ }
2965
+
2966
+ function _asyncToGenerator$2(fn) {
2967
+ return function () {
2968
+ var self = this,
2969
+ args = arguments;
2970
+ return new Promise(function (resolve, reject) {
2971
+ var gen = fn.apply(self, args);
2972
+
2973
+ function _next(value) {
2974
+ asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
2975
+ }
2976
+
2977
+ function _throw(err) {
2978
+ asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
2979
+ }
2980
+
2981
+ _next(undefined);
2982
+ });
2983
+ };
2984
+ }
2985
+
2986
+ function _inheritsLoose$3(subClass, superClass) {
2987
+ subClass.prototype = Object.create(superClass.prototype);
2988
+ subClass.prototype.constructor = subClass;
2989
+
2990
+ _setPrototypeOf$3(subClass, superClass);
2991
+ }
2992
+
2993
+ function _setPrototypeOf$3(o, p) {
2994
+ _setPrototypeOf$3 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
2995
+ o.__proto__ = p;
2996
+ return o;
2997
+ };
2998
+ return _setPrototypeOf$3(o, p);
2999
+ }
3000
+
3001
+ var ImagePool = /*#__PURE__*/function () {
3002
+ function ImagePool() {
3003
+ this.imageCache = {};
3004
+ this.gradientCache = {};
3005
+ this.patternCache = {};
3006
+ this.canvasConfig = void 0;
3007
+ }
3008
+
3009
+ var _proto = ImagePool.prototype;
3010
+
3011
+ _proto.getImageSync = function getImageSync(src, callback) {
3012
+ if (!this.imageCache[src]) {
3013
+ this.getOrCreateImage(src).then(function () {
3014
+ if (callback) {
3015
+ callback();
3016
+ }
3017
+ });
3018
+ }
3019
+
3020
+ return this.imageCache[src];
3021
+ };
3022
+
3023
+ _proto.getOrCreateImage = function getOrCreateImage(src) {
3024
+ var _this = this;
3025
+
3026
+ if (this.imageCache[src]) {
3027
+ return Promise.resolve(this.imageCache[src]);
3028
+ } // @see https://github.com/antvis/g/issues/938
3029
+
3030
+
3031
+ var createImage = this.canvasConfig.createImage;
3032
+ return new Promise(function (resolve, reject) {
3033
+ var image;
3034
+
3035
+ if (createImage) {
3036
+ image = createImage(src);
3037
+ } else if (g.isBrowser) {
3038
+ image = new window.Image();
3039
+ }
3040
+
3041
+ if (image) {
3042
+ image.onload = function () {
3043
+ resolve(image);
3044
+ };
3045
+
3046
+ image.onerror = function (ev) {
3047
+ reject(ev);
3048
+ };
3049
+
3050
+ image.crossOrigin = 'Anonymous';
3051
+ image.src = src;
3052
+ _this.imageCache[src] = image;
3053
+ }
3054
+ });
3055
+ };
3056
+
3057
+ _proto.getOrCreatePatternSync = function getOrCreatePatternSync(pattern, context, callback) {
3058
+ var patternKey = this.generatePatternKey(pattern);
3059
+
3060
+ if (patternKey && this.patternCache[patternKey]) {
3061
+ return this.patternCache[patternKey];
3062
+ }
3063
+
3064
+ var image = pattern.image,
3065
+ repetition = pattern.repetition;
3066
+ var src; // Image URL
3067
+
3068
+ if (g.isString(image)) {
3069
+ src = this.getImageSync(image, callback);
3070
+ } else {
3071
+ src = image;
3072
+ } // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createPattern
3073
+
3074
+
3075
+ var canvasPattern = src && context.createPattern(src, repetition);
3076
+
3077
+ if (patternKey && canvasPattern) {
3078
+ this.patternCache[patternKey] = canvasPattern;
3079
+ }
3080
+
3081
+ return canvasPattern;
3082
+ };
3083
+
3084
+ _proto.getOrCreateGradient = function getOrCreateGradient(params, context) {
3085
+ var key = this.generateGradientKey(params); // @ts-ignore
3086
+
3087
+ var type = params.type,
3088
+ steps = params.steps,
3089
+ width = params.width,
3090
+ height = params.height,
3091
+ angle = params.angle,
3092
+ cx = params.cx,
3093
+ cy = params.cy;
3094
+
3095
+ if (this.gradientCache[key]) {
3096
+ return this.gradientCache[key];
3097
+ }
3098
+
3099
+ var gradient = null;
3100
+
3101
+ if (type === g.GradientType.LinearGradient) {
3102
+ var _computeLinearGradien = g.computeLinearGradient(width, height, angle),
3103
+ x1 = _computeLinearGradien.x1,
3104
+ y1 = _computeLinearGradien.y1,
3105
+ x2 = _computeLinearGradien.x2,
3106
+ y2 = _computeLinearGradien.y2; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createLinearGradient
3107
+
3108
+
3109
+ gradient = context.createLinearGradient(x1, y1, x2, y2);
3110
+ } else if (type === g.GradientType.RadialGradient) {
3111
+ var _computeRadialGradien = g.computeRadialGradient(width, height, cx, cy),
3112
+ x = _computeRadialGradien.x,
3113
+ y = _computeRadialGradien.y,
3114
+ r = _computeRadialGradien.r; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createRadialGradient
3115
+
3050
3116
 
3051
- throw new Error("illegal catch attempt");
3052
- },
3053
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
3054
- return this.delegate = {
3055
- iterator: values(iterable),
3056
- resultName: resultName,
3057
- nextLoc: nextLoc
3058
- }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
3117
+ gradient = context.createRadialGradient(x, y, 0, x, y, r);
3059
3118
  }
3060
- }, exports;
3061
- }
3062
3119
 
3063
- function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
3064
- try {
3065
- var info = gen[key](arg);
3066
- var value = info.value;
3067
- } catch (error) {
3068
- reject(error);
3069
- return;
3070
- }
3120
+ if (gradient) {
3121
+ steps.forEach(function (_ref) {
3122
+ var _gradient;
3071
3123
 
3072
- if (info.done) {
3073
- resolve(value);
3074
- } else {
3075
- Promise.resolve(value).then(_next, _throw);
3076
- }
3077
- }
3124
+ var offset = _ref[0],
3125
+ color = _ref[1];
3126
+ (_gradient = gradient) === null || _gradient === void 0 ? void 0 : _gradient.addColorStop(offset, color);
3127
+ });
3128
+ this.gradientCache[key] = gradient;
3129
+ }
3078
3130
 
3079
- function _asyncToGenerator$2(fn) {
3080
- return function () {
3081
- var self = this,
3082
- args = arguments;
3083
- return new Promise(function (resolve, reject) {
3084
- var gen = fn.apply(self, args);
3131
+ return this.gradientCache[key];
3132
+ };
3085
3133
 
3086
- function _next(value) {
3087
- asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
3088
- }
3134
+ _proto.generateGradientKey = function generateGradientKey(params) {
3135
+ // @ts-ignore
3136
+ var type = params.type,
3137
+ width = params.width,
3138
+ height = params.height,
3139
+ steps = params.steps,
3140
+ angle = params.angle,
3141
+ cx = params.cx,
3142
+ cy = params.cy;
3143
+ return "gradient-" + type + "-" + (angle || 0) + "-" + (cx || 0) + "-" + (cy || 0) + "-" + width + "-" + height + "-" + steps.map(function (step) {
3144
+ return step.join('');
3145
+ }).join('-');
3146
+ };
3089
3147
 
3090
- function _throw(err) {
3091
- asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
3092
- }
3148
+ _proto.generatePatternKey = function generatePatternKey(pattern) {
3149
+ var image = pattern.image,
3150
+ repetition = pattern.repetition; // only generate cache for Image
3093
3151
 
3094
- _next(undefined);
3095
- });
3152
+ if (g.isString(image)) {
3153
+ return "pattern-" + image + "-" + repetition;
3154
+ }
3096
3155
  };
3097
- }
3156
+
3157
+ return ImagePool;
3158
+ }();
3159
+
3160
+ __decorate([g.inject(g.CanvasConfig), __metadata("design:type", Object)], ImagePool.prototype, "canvasConfig", void 0);
3161
+
3162
+ ImagePool = __decorate([g.singleton()], ImagePool);
3098
3163
 
3099
3164
  var _class$1;
3100
3165
 
@@ -3184,23 +3249,33 @@
3184
3249
  register(LoadImagePlugin);
3185
3250
  });
3186
3251
 
3187
- var Plugin$2 = /*#__PURE__*/function () {
3252
+ var Plugin$2 = /*#__PURE__*/function (_AbstractRendererPlug) {
3253
+ _inheritsLoose$3(Plugin, _AbstractRendererPlug);
3254
+
3188
3255
  function Plugin() {
3189
- this.name = 'image-loader';
3256
+ var _this;
3257
+
3258
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3259
+ args[_key] = arguments[_key];
3260
+ }
3261
+
3262
+ _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
3263
+ _this.name = 'image-loader';
3264
+ return _this;
3190
3265
  }
3191
3266
 
3192
3267
  var _proto = Plugin.prototype;
3193
3268
 
3194
- _proto.init = function init(container) {
3195
- container.load(containerModule$2, true);
3269
+ _proto.init = function init() {
3270
+ this.container.load(containerModule$2, true);
3196
3271
  };
3197
3272
 
3198
- _proto.destroy = function destroy(container) {
3199
- container.unload(containerModule$2);
3273
+ _proto.destroy = function destroy() {
3274
+ this.container.unload(containerModule$2);
3200
3275
  };
3201
3276
 
3202
3277
  return Plugin;
3203
- }();
3278
+ }(g.AbstractRendererPlugin);
3204
3279
 
3205
3280
  var index_esm$2 = /*#__PURE__*/Object.freeze({
3206
3281
  __proto__: null,
@@ -3611,19 +3686,19 @@
3611
3686
  return _extends.apply(this, arguments);
3612
3687
  }
3613
3688
 
3614
- function _inheritsLoose$1(subClass, superClass) {
3689
+ function _inheritsLoose$4(subClass, superClass) {
3615
3690
  subClass.prototype = Object.create(superClass.prototype);
3616
3691
  subClass.prototype.constructor = subClass;
3617
3692
 
3618
- _setPrototypeOf$1(subClass, superClass);
3693
+ _setPrototypeOf$4(subClass, superClass);
3619
3694
  }
3620
3695
 
3621
- function _setPrototypeOf$1(o, p) {
3622
- _setPrototypeOf$1 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
3696
+ function _setPrototypeOf$4(o, p) {
3697
+ _setPrototypeOf$4 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
3623
3698
  o.__proto__ = p;
3624
3699
  return o;
3625
3700
  };
3626
- return _setPrototypeOf$1(o, p);
3701
+ return _setPrototypeOf$4(o, p);
3627
3702
  }
3628
3703
  /**
3629
3704
  * Common utilities
@@ -3895,6 +3970,28 @@
3895
3970
  out[2] = z;
3896
3971
  return out;
3897
3972
  }
3973
+ /**
3974
+ * Transforms the vec3 with a mat4.
3975
+ * 4th vector component is implicitly '1'
3976
+ *
3977
+ * @param {vec3} out the receiving vector
3978
+ * @param {ReadonlyVec3} a the vector to transform
3979
+ * @param {ReadonlyMat4} m matrix to transform with
3980
+ * @returns {vec3} out
3981
+ */
3982
+
3983
+
3984
+ function transformMat4$1(out, a, m) {
3985
+ var x = a[0],
3986
+ y = a[1],
3987
+ z = a[2];
3988
+ var w = m[3] * x + m[7] * y + m[11] * z + m[15];
3989
+ w = w || 1.0;
3990
+ out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;
3991
+ out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;
3992
+ out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;
3993
+ return out;
3994
+ }
3898
3995
  /**
3899
3996
  * Perform some operation over an array of vec3s.
3900
3997
  *
@@ -4023,10 +4120,8 @@
4023
4120
  textAlign = parsedStyle.textAlign,
4024
4121
  textBaseline = parsedStyle.textBaseline,
4025
4122
  lineJoin = parsedStyle.lineJoin,
4026
- _parsedStyle$miterLim = parsedStyle.miterLimit,
4027
- miterLimit = _parsedStyle$miterLim === void 0 ? 0 : _parsedStyle$miterLim,
4028
- _parsedStyle$letterSp = parsedStyle.letterSpacing,
4029
- letterSpacing = _parsedStyle$letterSp === void 0 ? 0 : _parsedStyle$letterSp,
4123
+ miterLimit = parsedStyle.miterLimit,
4124
+ letterSpacing = parsedStyle.letterSpacing,
4030
4125
  stroke = parsedStyle.stroke,
4031
4126
  fill = parsedStyle.fill,
4032
4127
  fillOpacity = parsedStyle.fillOpacity,
@@ -4045,7 +4140,11 @@
4045
4140
  context.textAlign = textAlign.value;
4046
4141
  context.textBaseline = textBaseline.value;
4047
4142
  context.lineJoin = lineJoin.value;
4048
- context.miterLimit = miterLimit;
4143
+
4144
+ if (!g.isNil(miterLimit)) {
4145
+ context.miterLimit = miterLimit.value;
4146
+ }
4147
+
4049
4148
  var linePositionY = 0; // handle vertical text baseline
4050
4149
 
4051
4150
  if (textBaseline.value === 'middle') {
@@ -4074,11 +4173,11 @@
4074
4173
  // @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textAlign
4075
4174
 
4076
4175
  if (!g.isNil(stroke) && !stroke.isNone && lineWidth && lineWidth.value) {
4077
- this.drawLetterSpacing(context, lines[i], lineMetrics[i], textAlign.value, linePositionX, linePositionY, letterSpacing, fillOpacity.value, strokeOpacity.value, opacity.value, true);
4176
+ this.drawLetterSpacing(context, lines[i], lineMetrics[i], textAlign.value, linePositionX, linePositionY, letterSpacing.value, fillOpacity.value, strokeOpacity.value, opacity.value, true);
4078
4177
  }
4079
4178
 
4080
4179
  if (!g.isNil(fill)) {
4081
- this.drawLetterSpacing(context, lines[i], lineMetrics[i], textAlign.value, linePositionX, linePositionY, letterSpacing, fillOpacity.value, strokeOpacity.value, opacity.value);
4180
+ this.drawLetterSpacing(context, lines[i], lineMetrics[i], textAlign.value, linePositionX, linePositionY, letterSpacing.value, fillOpacity.value, strokeOpacity.value, opacity.value);
4082
4181
  }
4083
4182
  }
4084
4183
  };
@@ -4186,93 +4285,106 @@
4186
4285
  lineWidth = parsedStyle.lineWidth,
4187
4286
  lineCap = parsedStyle.lineCap,
4188
4287
  lineJoin = parsedStyle.lineJoin,
4288
+ shadowType = parsedStyle.shadowType,
4189
4289
  shadowColor = parsedStyle.shadowColor,
4290
+ shadowBlur = parsedStyle.shadowBlur,
4190
4291
  filter = parsedStyle.filter,
4191
4292
  miterLimit = parsedStyle.miterLimit;
4192
4293
  var hasFill = !g.isNil(fill) && !fill.isNone;
4193
- var hasStroke = !g.isNil(stroke) && !stroke.isNone;
4294
+ var hasStroke = !g.isNil(stroke) && !stroke.isNone && lineWidth && lineWidth.value > 0;
4194
4295
  var isFillTransparent = fill.alpha === 0;
4296
+ var hasFilter = !g.isNil(filter);
4297
+ var hasShadow = !g.isNil(shadowColor) && (shadowBlur === null || shadowBlur === void 0 ? void 0 : shadowBlur.value) > 0;
4298
+ var nodeName = object.nodeName;
4299
+ var isInnerShadow = (shadowType === null || shadowType === void 0 ? void 0 : shadowType.value) === 'inner';
4300
+ var shouldDrawShadowWithStroke = hasStroke && hasShadow && (nodeName === g.Shape.PATH || nodeName === g.Shape.LINE || nodeName === g.Shape.POLYLINE || isFillTransparent || isInnerShadow);
4195
4301
 
4196
4302
  if (hasFill) {
4197
- if (!g.isNil(fillOpacity) && fillOpacity.value !== 1) {
4198
- context.globalAlpha = fillOpacity.value;
4199
- this.fill(context, object, fill, renderingService);
4200
- context.globalAlpha = opacity.value;
4201
- } else {
4202
- this.fill(context, object, fill, renderingService);
4303
+ context.globalAlpha = opacity.value * fillOpacity.value;
4304
+
4305
+ if (!shouldDrawShadowWithStroke) {
4306
+ this.setShadowAndFilter(object, context, hasShadow);
4203
4307
  }
4204
- }
4205
4308
 
4206
- if (hasStroke) {
4207
- if (lineWidth && lineWidth.value > 0) {
4208
- var applyOpacity = !g.isNil(strokeOpacity) && strokeOpacity.value !== 1;
4309
+ this.fill(context, object, fill, renderingService);
4209
4310
 
4210
- if (applyOpacity) {
4211
- context.globalAlpha = strokeOpacity.value;
4212
- }
4311
+ if (!shouldDrawShadowWithStroke) {
4312
+ this.clearShadowAndFilter(context, hasFilter, hasShadow);
4313
+ }
4314
+ }
4213
4315
 
4214
- context.lineWidth = lineWidth.value;
4316
+ if (hasStroke) {
4317
+ context.globalAlpha = opacity.value * strokeOpacity.value;
4318
+ context.lineWidth = lineWidth.value;
4215
4319
 
4216
- if (!g.isNil(miterLimit)) {
4217
- context.miterLimit = miterLimit;
4218
- }
4320
+ if (!g.isNil(miterLimit)) {
4321
+ context.miterLimit = miterLimit.value;
4322
+ }
4219
4323
 
4220
- if (!g.isNil(lineCap)) {
4221
- context.lineCap = lineCap.value;
4222
- }
4324
+ if (!g.isNil(lineCap)) {
4325
+ context.lineCap = lineCap.value;
4326
+ }
4223
4327
 
4224
- if (!g.isNil(lineJoin)) {
4225
- context.lineJoin = lineJoin.value;
4226
- }
4328
+ if (!g.isNil(lineJoin)) {
4329
+ context.lineJoin = lineJoin.value;
4330
+ }
4227
4331
 
4228
- var oldShadowBlur;
4229
- var oldShadowColor;
4230
- var oldFilter;
4231
- var hasShadowColor = !g.isNil(shadowColor);
4232
- var hasFilter = !g.isNil(filter);
4233
-
4234
- if (hasShadowColor) {
4235
- // prevent inner shadow when drawing stroke, toggle shadowBlur & filter(drop-shadow)
4236
- // save shadow blur
4237
- oldShadowBlur = context.shadowBlur;
4238
- oldShadowColor = context.shadowColor;
4239
-
4240
- if (!g.isNil(oldShadowBlur)) {
4241
- context.shadowColor = 'transparent';
4242
- context.shadowBlur = 0;
4243
- }
4332
+ if (shouldDrawShadowWithStroke) {
4333
+ if (isInnerShadow) {
4334
+ context.globalCompositeOperation = 'source-atop';
4244
4335
  }
4245
4336
 
4246
- if (hasFilter) {
4247
- // save drop-shadow filter
4248
- oldFilter = context.filter;
4337
+ this.setShadowAndFilter(object, context, true);
4249
4338
 
4250
- if (!g.isNil(oldFilter) && oldFilter.indexOf('drop-shadow') > -1) {
4251
- context.filter = oldFilter.replace(/drop-shadow\([^)]*\)/, '').trim() || 'none';
4252
- }
4339
+ if (isInnerShadow) {
4340
+ this.stroke(context, object, stroke, renderingService);
4341
+ context.globalCompositeOperation = 'source-over';
4342
+ this.clearShadowAndFilter(context, hasFilter, true);
4253
4343
  }
4344
+ }
4254
4345
 
4255
- var drawStroke = hasFill && !isFillTransparent;
4346
+ this.stroke(context, object, stroke, renderingService);
4347
+ }
4348
+ };
4256
4349
 
4257
- if (drawStroke) {
4258
- this.stroke(context, object, stroke, renderingService);
4259
- } // restore shadow blur
4350
+ _proto.clearShadowAndFilter = function clearShadowAndFilter(context, hasFilter, hasShadow) {
4351
+ if (hasShadow) {
4352
+ context.shadowColor = 'transparent';
4353
+ context.shadowBlur = 0;
4354
+ }
4260
4355
 
4356
+ if (hasFilter) {
4357
+ // save drop-shadow filter
4358
+ var oldFilter = context.filter;
4261
4359
 
4262
- if (hasShadowColor) {
4263
- context.shadowColor = oldShadowColor;
4264
- context.shadowBlur = oldShadowBlur;
4265
- } // restore filters
4360
+ if (!g.isNil(oldFilter) && oldFilter.indexOf('drop-shadow') > -1) {
4361
+ context.filter = oldFilter.replace(/drop-shadow\([^)]*\)/, '').trim() || 'none';
4362
+ }
4363
+ }
4364
+ }
4365
+ /**
4366
+ * apply before fill and stroke but only once
4367
+ */
4368
+ ;
4266
4369
 
4370
+ _proto.setShadowAndFilter = function setShadowAndFilter(object, context, hasShadow) {
4371
+ var _object$parsedStyle = object.parsedStyle,
4372
+ filter = _object$parsedStyle.filter,
4373
+ shadowColor = _object$parsedStyle.shadowColor,
4374
+ shadowBlur = _object$parsedStyle.shadowBlur,
4375
+ shadowOffsetX = _object$parsedStyle.shadowOffsetX,
4376
+ shadowOffsetY = _object$parsedStyle.shadowOffsetY;
4267
4377
 
4268
- if (hasFilter) {
4269
- context.filter = oldFilter;
4270
- }
4378
+ if (!g.isNil(filter)) {
4379
+ // use raw filter string
4380
+ context.filter = object.style.filter;
4381
+ }
4271
4382
 
4272
- if (!drawStroke) {
4273
- this.stroke(context, object, stroke, renderingService);
4274
- }
4275
- }
4383
+ if (hasShadow) {
4384
+ context.shadowColor = shadowColor.toString();
4385
+ context.shadowBlur = shadowBlur && shadowBlur.value || 0;
4386
+ context.shadowOffsetX = shadowOffsetX && shadowOffsetX.value || 0;
4387
+ context.shadowOffsetY = shadowOffsetY && shadowOffsetY.value || 0;
4276
4388
  }
4277
4389
  };
4278
4390
 
@@ -4345,7 +4457,7 @@
4345
4457
  DefaultRenderer = __decorate([g.singleton()], DefaultRenderer);
4346
4458
 
4347
4459
  var RectRenderer = /*#__PURE__*/function (_DefaultRenderer) {
4348
- _inheritsLoose$1(RectRenderer, _DefaultRenderer);
4460
+ _inheritsLoose$4(RectRenderer, _DefaultRenderer);
4349
4461
 
4350
4462
  function RectRenderer() {
4351
4463
  return _DefaultRenderer.apply(this, arguments) || this;
@@ -4359,7 +4471,7 @@
4359
4471
  })], RectRenderer);
4360
4472
 
4361
4473
  var CircleRenderer = /*#__PURE__*/function (_DefaultRenderer) {
4362
- _inheritsLoose$1(CircleRenderer, _DefaultRenderer);
4474
+ _inheritsLoose$4(CircleRenderer, _DefaultRenderer);
4363
4475
 
4364
4476
  function CircleRenderer() {
4365
4477
  return _DefaultRenderer.apply(this, arguments) || this;
@@ -4373,7 +4485,7 @@
4373
4485
  })], CircleRenderer);
4374
4486
 
4375
4487
  var EllipseRenderer = /*#__PURE__*/function (_DefaultRenderer) {
4376
- _inheritsLoose$1(EllipseRenderer, _DefaultRenderer);
4488
+ _inheritsLoose$4(EllipseRenderer, _DefaultRenderer);
4377
4489
 
4378
4490
  function EllipseRenderer() {
4379
4491
  return _DefaultRenderer.apply(this, arguments) || this;
@@ -4387,7 +4499,7 @@
4387
4499
  })], EllipseRenderer);
4388
4500
 
4389
4501
  var LineRenderer = /*#__PURE__*/function (_DefaultRenderer) {
4390
- _inheritsLoose$1(LineRenderer, _DefaultRenderer);
4502
+ _inheritsLoose$4(LineRenderer, _DefaultRenderer);
4391
4503
 
4392
4504
  function LineRenderer() {
4393
4505
  return _DefaultRenderer.apply(this, arguments) || this;
@@ -4401,7 +4513,7 @@
4401
4513
  })], LineRenderer);
4402
4514
 
4403
4515
  var PolylineRenderer = /*#__PURE__*/function (_DefaultRenderer) {
4404
- _inheritsLoose$1(PolylineRenderer, _DefaultRenderer);
4516
+ _inheritsLoose$4(PolylineRenderer, _DefaultRenderer);
4405
4517
 
4406
4518
  function PolylineRenderer() {
4407
4519
  return _DefaultRenderer.apply(this, arguments) || this;
@@ -4415,7 +4527,7 @@
4415
4527
  })], PolylineRenderer);
4416
4528
 
4417
4529
  var PolygonRenderer = /*#__PURE__*/function (_DefaultRenderer) {
4418
- _inheritsLoose$1(PolygonRenderer, _DefaultRenderer);
4530
+ _inheritsLoose$4(PolygonRenderer, _DefaultRenderer);
4419
4531
 
4420
4532
  function PolygonRenderer() {
4421
4533
  return _DefaultRenderer.apply(this, arguments) || this;
@@ -4429,7 +4541,7 @@
4429
4541
  })], PolygonRenderer);
4430
4542
 
4431
4543
  var PathRenderer = /*#__PURE__*/function (_DefaultRenderer) {
4432
- _inheritsLoose$1(PathRenderer, _DefaultRenderer);
4544
+ _inheritsLoose$4(PathRenderer, _DefaultRenderer);
4433
4545
 
4434
4546
  function PathRenderer() {
4435
4547
  return _DefaultRenderer.apply(this, arguments) || this;
@@ -4557,13 +4669,30 @@
4557
4669
  _this.clearFullScreen = renderingService.disableDirtyRectangleRendering() || rendered > dirtyObjectNumThreshold && ratio > dirtyObjectRatioThreshold;
4558
4670
 
4559
4671
  if (context) {
4560
- if (_this.clearFullScreen) {
4561
- context.resetTransform();
4672
+ context.resetTransform();
4562
4673
 
4674
+ if (_this.clearFullScreen) {
4563
4675
  _this.clearRect(context, 0, 0, width * dpr, height * dpr);
4564
4676
  }
4565
4677
  }
4566
- }); // render at the end of frame
4678
+ });
4679
+
4680
+ var renderByZIndex = function renderByZIndex(object) {
4681
+ if (object.isVisible() && !object.isCulled()) {
4682
+ _this.renderDisplayObject(object, renderingService); // if we did a full screen rendering last frame
4683
+
4684
+
4685
+ _this.saveDirtyAABB(object);
4686
+ } // should account for z-index
4687
+
4688
+
4689
+ if (object.sortable.sorted && object.sortable.sorted.length) {
4690
+ object.sortable.sorted.forEach(function (child) {
4691
+ renderByZIndex(child);
4692
+ });
4693
+ }
4694
+ }; // render at the end of frame
4695
+
4567
4696
 
4568
4697
  renderingService.hooks.endFrame.tap(CanvasRendererPlugin_1.tag, function () {
4569
4698
  var context = _this.contextService.getContext(); // clear & clip dirty rectangle
@@ -4572,14 +4701,7 @@
4572
4701
  multiply$1(_this.vpMatrix, _this.dprMatrix, _this.camera.getOrthoMatrix());
4573
4702
 
4574
4703
  if (_this.clearFullScreen) {
4575
- _this.renderingContext.root.forEach(function (object) {
4576
- if (object.isVisible() && !object.isCulled()) {
4577
- _this.renderDisplayObject(object, renderingService); // if we did a full screen rendering last frame
4578
-
4579
-
4580
- _this.saveDirtyAABB(object);
4581
- }
4582
- });
4704
+ renderByZIndex(_this.renderingContext.root);
4583
4705
  } else {
4584
4706
  // merge removed AABB
4585
4707
  var dirtyRenderBounds = _this.safeMergeAABB.apply(_this, [_this.mergeDirtyAABBs(_this.renderQueue)].concat(_this.removedRBushNodeAABBs.map(function (_ref2) {
@@ -4604,16 +4726,22 @@
4604
4726
  var x = dirtyRect.x,
4605
4727
  y = dirtyRect.y,
4606
4728
  width = dirtyRect.width,
4607
- height = dirtyRect.height; // @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
4608
-
4609
- context.setTransform(_this.vpMatrix[0], _this.vpMatrix[1], _this.vpMatrix[4], _this.vpMatrix[5], _this.vpMatrix[12], _this.vpMatrix[13]);
4729
+ height = dirtyRect.height;
4730
+ var tl = transformMat4$1(_this.tmpVec3, fromValues$1(x, y, 0), _this.vpMatrix);
4731
+ var br = transformMat4$1(create$1$1(), fromValues$1(x + width, y + height, 0), _this.vpMatrix);
4732
+ var ix = Math.floor(tl[0]);
4733
+ var iy = Math.floor(tl[1]);
4734
+ var iwidth = Math.ceil(br[0] - tl[0]);
4735
+ var iheight = Math.ceil(br[1] - tl[1]);
4610
4736
  context.save();
4611
4737
 
4612
- _this.clearRect(context, x, y, width, height);
4738
+ _this.clearRect(context, ix, iy, iwidth, iheight);
4613
4739
 
4614
4740
  context.beginPath();
4615
- context.rect(x, y, width, height);
4616
- context.clip(); // draw dirty rectangle
4741
+ context.rect(ix, iy, iwidth, iheight);
4742
+ context.clip(); // @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
4743
+
4744
+ context.setTransform(_this.vpMatrix[0], _this.vpMatrix[1], _this.vpMatrix[4], _this.vpMatrix[5], _this.vpMatrix[12], _this.vpMatrix[13]); // draw dirty rectangle
4617
4745
 
4618
4746
  var _this$canvasConfig$re = _this.canvasConfig.renderer.getConfig(),
4619
4747
  enableDirtyRectangleRenderingDebug = _this$canvasConfig$re.enableDirtyRectangleRenderingDebug;
@@ -4664,6 +4792,7 @@
4664
4792
  };
4665
4793
 
4666
4794
  _proto.clearRect = function clearRect(context, x, y, width, height) {
4795
+ // clearRect is faster than fillRect @see https://stackoverflow.com/a/30830253
4667
4796
  context.clearRect(x, y, width, height);
4668
4797
  var background = this.canvasConfig.background;
4669
4798
 
@@ -4777,7 +4906,7 @@
4777
4906
 
4778
4907
  _proto.mergeDirtyAABBs = function mergeDirtyAABBs(dirtyObjects) {
4779
4908
  // merge into a big AABB
4780
- // TODO: skip descendant if ancestor is caculated
4909
+ // TODO: skip descendant if ancestor is caculated, but compareNodePosition is really slow
4781
4910
  var aabb = new g.AABB();
4782
4911
  dirtyObjects.forEach(function (object) {
4783
4912
  var renderBounds = object.getRenderBounds();
@@ -4840,12 +4969,7 @@
4840
4969
  fill = _object$parsedStyle.fill,
4841
4970
  opacity = _object$parsedStyle.opacity,
4842
4971
  lineDash = _object$parsedStyle.lineDash,
4843
- lineDashOffset = _object$parsedStyle.lineDashOffset,
4844
- filter = _object$parsedStyle.filter,
4845
- shadowColor = _object$parsedStyle.shadowColor,
4846
- shadowBlur = _object$parsedStyle.shadowBlur,
4847
- shadowOffsetX = _object$parsedStyle.shadowOffsetX,
4848
- shadowOffsetY = _object$parsedStyle.shadowOffsetY; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/setLineDash
4972
+ lineDashOffset = _object$parsedStyle.lineDashOffset; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/setLineDash
4849
4973
 
4850
4974
  if (lineDash && Array.isArray(lineDash)) {
4851
4975
  context.setLineDash(lineDash.map(function (segment) {
@@ -4869,20 +4993,6 @@
4869
4993
  if (!g.isNil(fill) && !Array.isArray(fill) && !fill.isNone) {
4870
4994
  context.fillStyle = object.attributes.fill;
4871
4995
  }
4872
-
4873
- if (!g.isNil(filter)) {
4874
- // use raw filter string
4875
- context.filter = object.style.filter;
4876
- }
4877
-
4878
- var hasShadow = !g.isNil(shadowColor) && (shadowBlur === null || shadowBlur === void 0 ? void 0 : shadowBlur.value) > 0;
4879
-
4880
- if (hasShadow) {
4881
- context.shadowColor = shadowColor.toString();
4882
- context.shadowBlur = shadowBlur && shadowBlur.value || 0;
4883
- context.shadowOffsetX = shadowOffsetX && shadowOffsetX.value || 0;
4884
- context.shadowOffsetY = shadowOffsetY && shadowOffsetY.value || 0;
4885
- }
4886
4996
  };
4887
4997
 
4888
4998
  _proto.applyWorldTransform = function applyWorldTransform(context, object, matrix) {
@@ -4993,36 +5103,42 @@
4993
5103
  register(CanvasRendererPlugin);
4994
5104
  });
4995
5105
 
4996
- var Plugin$3 = /*#__PURE__*/function () {
5106
+ var Plugin$3 = /*#__PURE__*/function (_AbstractRendererPlug) {
5107
+ _inheritsLoose$4(Plugin, _AbstractRendererPlug);
5108
+
4997
5109
  function Plugin(options) {
5110
+ var _this;
5111
+
4998
5112
  if (options === void 0) {
4999
5113
  options = {};
5000
5114
  }
5001
5115
 
5002
- this.options = void 0;
5003
- this.name = 'canvas-renderer';
5004
- this.options = options;
5116
+ _this = _AbstractRendererPlug.call(this) || this;
5117
+ _this.options = void 0;
5118
+ _this.name = 'canvas-renderer';
5119
+ _this.options = options;
5120
+ return _this;
5005
5121
  }
5006
5122
 
5007
5123
  var _proto = Plugin.prototype;
5008
5124
 
5009
- _proto.init = function init(container) {
5010
- container.register(CanvasRendererPluginOptions, {
5125
+ _proto.init = function init() {
5126
+ this.container.register(CanvasRendererPluginOptions, {
5011
5127
  useValue: _extends({
5012
5128
  dirtyObjectNumThreshold: 500,
5013
5129
  dirtyObjectRatioThreshold: 0.8
5014
5130
  }, this.options)
5015
5131
  });
5016
- container.load(containerModule$3, true);
5132
+ this.container.load(containerModule$3, true);
5017
5133
  };
5018
5134
 
5019
- _proto.destroy = function destroy(container) {
5020
- container.unload(containerModule$3);
5021
- container.remove(CanvasRendererPluginOptions);
5135
+ _proto.destroy = function destroy() {
5136
+ this.container.unload(containerModule$3);
5137
+ this.container.remove(CanvasRendererPluginOptions);
5022
5138
  };
5023
5139
 
5024
5140
  return Plugin;
5025
- }();
5141
+ }(g.AbstractRendererPlugin);
5026
5142
 
5027
5143
  var index_esm$3 = /*#__PURE__*/Object.freeze({
5028
5144
  __proto__: null,
@@ -5434,6 +5550,21 @@
5434
5550
  };
5435
5551
  }
5436
5552
 
5553
+ function _inheritsLoose$5(subClass, superClass) {
5554
+ subClass.prototype = Object.create(superClass.prototype);
5555
+ subClass.prototype.constructor = subClass;
5556
+
5557
+ _setPrototypeOf$5(subClass, superClass);
5558
+ }
5559
+
5560
+ function _setPrototypeOf$5(o, p) {
5561
+ _setPrototypeOf$5 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
5562
+ o.__proto__ = p;
5563
+ return o;
5564
+ };
5565
+ return _setPrototypeOf$5(o, p);
5566
+ }
5567
+
5437
5568
  var _class$3;
5438
5569
 
5439
5570
  var DOMInteractionPlugin_1;
@@ -5493,7 +5624,7 @@
5493
5624
  var addTouchEventListener = function addTouchEventListener($el) {
5494
5625
  $el.addEventListener('touchstart', onPointerDown, true);
5495
5626
  $el.addEventListener('touchend', onPointerUp, true);
5496
- globalThis.document.addEventListener('touchmove', onPointerMove, true);
5627
+ $el.addEventListener('touchmove', onPointerMove, true);
5497
5628
  $el.addEventListener('touchcancel', onPointerCancel, true);
5498
5629
  };
5499
5630
 
@@ -5516,8 +5647,8 @@
5516
5647
  var removeTouchEventListener = function removeTouchEventListener($el) {
5517
5648
  $el.removeEventListener('touchstart', onPointerDown, true);
5518
5649
  $el.removeEventListener('touchend', onPointerUp, true);
5650
+ $el.removeEventListener('touchmove', onPointerMove, true);
5519
5651
  $el.removeEventListener('touchcancel', onPointerCancel, true);
5520
- globalThis.document.removeEventListener('touchmove', onPointerMove, true);
5521
5652
  };
5522
5653
 
5523
5654
  var removeMouseEventListener = function removeMouseEventListener($el) {
@@ -5600,23 +5731,33 @@
5600
5731
  register(DOMInteractionPlugin);
5601
5732
  });
5602
5733
 
5603
- var Plugin$4 = /*#__PURE__*/function () {
5734
+ var Plugin$4 = /*#__PURE__*/function (_AbstractRendererPlug) {
5735
+ _inheritsLoose$5(Plugin, _AbstractRendererPlug);
5736
+
5604
5737
  function Plugin() {
5605
- this.name = 'dom-interaction';
5738
+ var _this;
5739
+
5740
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
5741
+ args[_key] = arguments[_key];
5742
+ }
5743
+
5744
+ _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
5745
+ _this.name = 'dom-interaction';
5746
+ return _this;
5606
5747
  }
5607
5748
 
5608
5749
  var _proto = Plugin.prototype;
5609
5750
 
5610
- _proto.init = function init(container) {
5611
- container.load(containerModule$4, true);
5751
+ _proto.init = function init() {
5752
+ this.container.load(containerModule$4, true);
5612
5753
  };
5613
5754
 
5614
- _proto.destroy = function destroy(container) {
5615
- container.unload(containerModule$4);
5755
+ _proto.destroy = function destroy() {
5756
+ this.container.unload(containerModule$4);
5616
5757
  };
5617
5758
 
5618
5759
  return Plugin;
5619
- }();
5760
+ }(g.AbstractRendererPlugin);
5620
5761
 
5621
5762
  var index_esm$4 = /*#__PURE__*/Object.freeze({
5622
5763
  __proto__: null,
@@ -6009,6 +6150,21 @@
6009
6150
  };
6010
6151
  }
6011
6152
 
6153
+ function _inheritsLoose$6(subClass, superClass) {
6154
+ subClass.prototype = Object.create(superClass.prototype);
6155
+ subClass.prototype.constructor = subClass;
6156
+
6157
+ _setPrototypeOf$6(subClass, superClass);
6158
+ }
6159
+
6160
+ function _setPrototypeOf$6(o, p) {
6161
+ _setPrototypeOf$6 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
6162
+ o.__proto__ = p;
6163
+ return o;
6164
+ };
6165
+ return _setPrototypeOf$6(o, p);
6166
+ }
6167
+
6012
6168
  var _class$4;
6013
6169
 
6014
6170
  var HTMLRenderingPlugin_1;
@@ -6277,23 +6433,33 @@
6277
6433
  register(HTMLRenderingPlugin);
6278
6434
  });
6279
6435
 
6280
- var Plugin$5 = /*#__PURE__*/function () {
6436
+ var Plugin$5 = /*#__PURE__*/function (_AbstractRendererPlug) {
6437
+ _inheritsLoose$6(Plugin, _AbstractRendererPlug);
6438
+
6281
6439
  function Plugin() {
6282
- this.name = 'html-renderer';
6440
+ var _this;
6441
+
6442
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
6443
+ args[_key] = arguments[_key];
6444
+ }
6445
+
6446
+ _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
6447
+ _this.name = 'html-renderer';
6448
+ return _this;
6283
6449
  }
6284
6450
 
6285
6451
  var _proto = Plugin.prototype;
6286
6452
 
6287
- _proto.init = function init(container) {
6288
- container.load(containerModule$5, true);
6453
+ _proto.init = function init() {
6454
+ this.container.load(containerModule$5, true);
6289
6455
  };
6290
6456
 
6291
- _proto.destroy = function destroy(container) {
6292
- container.unload(containerModule$5);
6457
+ _proto.destroy = function destroy() {
6458
+ this.container.unload(containerModule$5);
6293
6459
  };
6294
6460
 
6295
6461
  return Plugin;
6296
- }();
6462
+ }(g.AbstractRendererPlugin);
6297
6463
 
6298
6464
  var index_esm$5 = /*#__PURE__*/Object.freeze({
6299
6465
  __proto__: null,
@@ -6460,23 +6626,33 @@
6460
6626
  */
6461
6627
  register(Canvas2DContextService);
6462
6628
  });
6463
- var ContextRegisterPlugin = /*#__PURE__*/function () {
6629
+ var ContextRegisterPlugin = /*#__PURE__*/function (_AbstractRendererPlug) {
6630
+ _inheritsLoose(ContextRegisterPlugin, _AbstractRendererPlug);
6631
+
6464
6632
  function ContextRegisterPlugin() {
6465
- this.name = 'canvas-context-register';
6633
+ var _this;
6634
+
6635
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
6636
+ args[_key] = arguments[_key];
6637
+ }
6638
+
6639
+ _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
6640
+ _this.name = 'canvas-context-register';
6641
+ return _this;
6466
6642
  }
6467
6643
 
6468
6644
  var _proto = ContextRegisterPlugin.prototype;
6469
6645
 
6470
- _proto.init = function init(container) {
6471
- container.load(containerModule$6, true);
6646
+ _proto.init = function init() {
6647
+ this.container.load(containerModule$6, true);
6472
6648
  };
6473
6649
 
6474
- _proto.destroy = function destroy(container) {
6475
- container.unload(containerModule$6);
6650
+ _proto.destroy = function destroy() {
6651
+ this.container.unload(containerModule$6);
6476
6652
  };
6477
6653
 
6478
6654
  return ContextRegisterPlugin;
6479
- }();
6655
+ }(g.AbstractRendererPlugin);
6480
6656
 
6481
6657
  var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
6482
6658
  _inheritsLoose(Renderer, _AbstractRenderer);