@galacean/effects-plugin-rich-text 2.8.0-alpha.2 → 2.8.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -3,11 +3,11 @@
3
3
  * Description: Galacean Effects player rich text plugin
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 云垣
6
- * Version: v2.8.0-alpha.2
6
+ * Version: v2.8.0-alpha.4
7
7
  */
8
8
 
9
9
  import * as EFFECTS from '@galacean/effects';
10
- import { AbstractPlugin, spec, effectsClass, applyMixins, TextComponentBase, TextStyle, math, assertExist, MaskableGraphic, registerPlugin, logger } from '@galacean/effects';
10
+ import { Plugin, spec, effectsClass, applyMixins, TextComponentBase, TextStyle, math, assertExist, MaskableGraphic, registerPlugin, logger } from '@galacean/effects';
11
11
 
12
12
  function _set_prototype_of(o, p) {
13
13
  _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
@@ -31,16 +31,84 @@ function _inherits(subClass, superClass) {
31
31
  if (superClass) _set_prototype_of(subClass, superClass);
32
32
  }
33
33
 
34
- var RichTextLoader = /*#__PURE__*/ function(AbstractPlugin) {
35
- _inherits(RichTextLoader, AbstractPlugin);
34
+ function _is_native_reflect_construct() {
35
+ // Since Reflect.construct can't be properly polyfilled, some
36
+ // implementations (e.g. core-js@2) don't set the correct internal slots.
37
+ // Those polyfills don't allow us to subclass built-ins, so we need to
38
+ // use our fallback implementation.
39
+ try {
40
+ // If the internal slots aren't set, this throws an error similar to
41
+ // TypeError: this is not a Boolean object.
42
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
43
+ } catch (_) {}
44
+ return (_is_native_reflect_construct = function _is_native_reflect_construct() {
45
+ return !!result;
46
+ })();
47
+ }
48
+
49
+ function _construct(Parent, args, Class) {
50
+ if (_is_native_reflect_construct()) _construct = Reflect.construct;
51
+ else {
52
+ _construct = function construct(Parent, args, Class) {
53
+ var a = [
54
+ null
55
+ ];
56
+ a.push.apply(a, args);
57
+ var Constructor = Function.bind.apply(Parent, a);
58
+ var instance = new Constructor();
59
+ if (Class) _set_prototype_of(instance, Class.prototype);
60
+ return instance;
61
+ };
62
+ }
63
+ return _construct.apply(null, arguments);
64
+ }
65
+
66
+ function _get_prototype_of(o) {
67
+ _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
68
+ return o.__proto__ || Object.getPrototypeOf(o);
69
+ };
70
+ return _get_prototype_of(o);
71
+ }
72
+
73
+ function _is_native_function(fn) {
74
+ return Function.toString.call(fn).indexOf("[native code]") !== -1;
75
+ }
76
+
77
+ function _wrap_native_super(Class) {
78
+ var _cache = typeof Map === "function" ? new Map() : undefined;
79
+ _wrap_native_super = function _wrap_native_super(Class) {
80
+ if (Class === null || !_is_native_function(Class)) return Class;
81
+ if (typeof Class !== "function") throw new TypeError("Super expression must either be null or a function");
82
+ if (typeof _cache !== "undefined") {
83
+ if (_cache.has(Class)) return _cache.get(Class);
84
+ _cache.set(Class, Wrapper);
85
+ }
86
+ function Wrapper() {
87
+ return _construct(Class, arguments, _get_prototype_of(this).constructor);
88
+ }
89
+ Wrapper.prototype = Object.create(Class.prototype, {
90
+ constructor: {
91
+ value: Wrapper,
92
+ enumerable: false,
93
+ writable: true,
94
+ configurable: true
95
+ }
96
+ });
97
+ return _set_prototype_of(Wrapper, Class);
98
+ };
99
+ return _wrap_native_super(Class);
100
+ }
101
+
102
+ var RichTextLoader = /*#__PURE__*/ function(Plugin) {
103
+ _inherits(RichTextLoader, Plugin);
36
104
  function RichTextLoader() {
37
105
  var _this;
38
- _this = AbstractPlugin.apply(this, arguments) || this;
106
+ _this = Plugin.apply(this, arguments) || this;
39
107
  _this.name = "rich-text";
40
108
  return _this;
41
109
  }
42
110
  return RichTextLoader;
43
- }(AbstractPlugin);
111
+ }(_wrap_native_super(Plugin));
44
112
 
45
113
  function _array_like_to_array(arr, len) {
46
114
  if (len == null || len > arr.length) len = arr.length;
@@ -467,7 +535,8 @@ var RichTextLayout = /*#__PURE__*/ function() {
467
535
  return result;
468
536
  } finally{
469
537
  // Clean up DOM element
470
- canvas.remove();
538
+ // 支付宝小程序不支持 remove 方法
539
+ canvas.remove == null ? void 0 : canvas.remove.call(canvas);
471
540
  }
472
541
  }
473
542
  throw new Error("Failed to get 2D context for color conversion!");
@@ -1604,7 +1673,7 @@ applyMixins(RichTextComponent, [
1604
1673
 
1605
1674
  /**
1606
1675
  * 插件版本号
1607
- */ var version = "2.8.0-alpha.2";
1676
+ */ var version = "2.8.0-alpha.4";
1608
1677
  registerPlugin("rich-text", RichTextLoader);
1609
1678
  logger.info("Plugin rich text version: " + version + ".");
1610
1679
  if (version !== EFFECTS.version) {