@cocojs/mvc 0.0.1-alpha202511172037 → 0.1.0-beta.6

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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/dist/index.cjs.js +1813 -2153
  3. package/dist/index.d.ts +218 -55
  4. package/package.json +35 -27
package/dist/index.cjs.js CHANGED
@@ -1,5 +1,124 @@
1
1
  'use strict';
2
2
 
3
+ function _applyDecs2311(e, t, n, r, o, i) {
4
+ var a,
5
+ c,
6
+ u,
7
+ s,
8
+ f,
9
+ l,
10
+ p,
11
+ d = Symbol.metadata || Symbol.for("Symbol.metadata"),
12
+ m = Object.defineProperty,
13
+ h = Object.create,
14
+ y = [h(null), h(null)],
15
+ v = t.length;
16
+ function g(t, n, r) {
17
+ return function (o, i) {
18
+ n && (i = o, o = e);
19
+ for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []);
20
+ return r ? i : o;
21
+ };
22
+ }
23
+ function b(e, t, n, r) {
24
+ if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined"));
25
+ return e;
26
+ }
27
+ function applyDec(e, t, n, r, o, i, u, s, f, l, p) {
28
+ function d(e) {
29
+ if (!p(e)) throw new TypeError("Attempted to access private element on non-instance");
30
+ }
31
+ var h = [].concat(t[0]),
32
+ v = t[3],
33
+ w = !u,
34
+ D = 1 === o,
35
+ S = 3 === o,
36
+ j = 4 === o,
37
+ E = 2 === o;
38
+ function I(t, n, r) {
39
+ return function (o, i) {
40
+ return n && (i = o, o = e), r && r(o), P[t].call(o, i);
41
+ };
42
+ }
43
+ if (!w) {
44
+ var P = {},
45
+ k = [],
46
+ F = S ? "get" : j || D ? "set" : "value";
47
+ if (f ? (l || D ? P = {
48
+ get: _setFunctionName(function () {
49
+ return v(this);
50
+ }, r, "get"),
51
+ set: function (e) {
52
+ t[4](this, e);
53
+ }
54
+ } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) {
55
+ if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet");
56
+ y[+s][r] = o < 3 ? 1 : o;
57
+ }
58
+ }
59
+ for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) {
60
+ var T = b(h[O], "A decorator", "be", true),
61
+ z = n ? h[O - 1] : void 0,
62
+ A = {},
63
+ H = {
64
+ kind: ["field", "accessor", "method", "getter", "setter", "class"][o],
65
+ name: r,
66
+ metadata: a,
67
+ addInitializer: function (e, t) {
68
+ if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished");
69
+ b(t, "An initializer", "be", true), i.push(t);
70
+ }.bind(null, A)
71
+ };
72
+ if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = {
73
+ has: f ? p.bind() : function (e) {
74
+ return r in e;
75
+ }
76
+ }, j || (c.get = f ? E ? function (e) {
77
+ return d(e), P.value;
78
+ } : I("get", 0, d) : function (e) {
79
+ return e[r];
80
+ }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) {
81
+ e[r] = t;
82
+ }), N = T.call(z, D ? {
83
+ get: P.get,
84
+ set: P.set
85
+ } : P[F], H), A.v = 1, D) {
86
+ if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined");
87
+ } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N);
88
+ }
89
+ return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N;
90
+ }
91
+ function w(e) {
92
+ return m(e, d, {
93
+ configurable: true,
94
+ enumerable: true,
95
+ value: a
96
+ });
97
+ }
98
+ return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) {
99
+ e && f.push(g(e));
100
+ }, p = function (t, r) {
101
+ for (var i = 0; i < n.length; i++) {
102
+ var a = n[i],
103
+ c = a[1],
104
+ l = 7 & c;
105
+ if ((8 & c) == t && !l == r) {
106
+ var p = a[2],
107
+ d = !!a[3],
108
+ m = 16 & c;
109
+ applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) {
110
+ return _checkInRHS(t) === e;
111
+ } : o);
112
+ }
113
+ }
114
+ }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), {
115
+ e: c,
116
+ get c() {
117
+ var n = [];
118
+ return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)];
119
+ }
120
+ };
121
+ }
3
122
  function _arrayLikeToArray(r, a) {
4
123
  (null == a || a > r.length) && (a = r.length);
5
124
  for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
@@ -18,6 +137,10 @@ function _assertThisInitialized(e) {
18
137
  function _callSuper(t, o, e) {
19
138
  return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
20
139
  }
140
+ function _checkInRHS(e) {
141
+ if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null"));
142
+ return e;
143
+ }
21
144
  function _classCallCheck(a, n) {
22
145
  if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
23
146
  }
@@ -100,6 +223,9 @@ function _getPrototypeOf(t) {
100
223
  return t.__proto__ || Object.getPrototypeOf(t);
101
224
  }, _getPrototypeOf(t);
102
225
  }
226
+ function _identity(t) {
227
+ return t;
228
+ }
103
229
  function _inherits(t, e) {
104
230
  if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
105
231
  t.prototype = Object.create(e && e.prototype, {
@@ -182,6 +308,16 @@ function _possibleConstructorReturn(t, e) {
182
308
  if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
183
309
  return _assertThisInitialized(t);
184
310
  }
311
+ function _setFunctionName(e, t, n) {
312
+ "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : "");
313
+ try {
314
+ Object.defineProperty(e, "name", {
315
+ configurable: !0,
316
+ value: n ? n + " " + t : t
317
+ });
318
+ } catch (e) {}
319
+ return e;
320
+ }
185
321
  function _setPrototypeOf(t, e) {
186
322
  return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
187
323
  return t.__proto__ = e, t;
@@ -239,15 +375,6 @@ function lowercaseFirstLetter(str) {
239
375
  };
240
376
  return transformStr(str, fn);
241
377
  }
242
- /**
243
- * 第一个字母改为大写,其他不变
244
- */
245
- function uppercaseFirstLetter(str) {
246
- var fn = function fn(str) {
247
- return str[0].toUpperCase() + str.slice(1);
248
- };
249
- return transformStr(str, fn);
250
- }
251
378
  function className2DecoratorName(className) {
252
379
  return "@".concat(lowercaseFirstLetter(className));
253
380
  }
@@ -310,11 +437,19 @@ function once(fn) {
310
437
  _onceFn.fn = fn;
311
438
  return _onceFn;
312
439
  }
313
- // 判断入参是否是类,因为class会转成function,所以不通过toString判断
440
+ // 是否是普通类,因为class会转成function,所以不通过toString判断
314
441
  function isClass(v) {
315
- // TODO: 是否要添加类名首字母必须大写的校验
316
442
  return typeof v === 'function' && v.prototype && v.prototype.constructor === v;
317
443
  }
444
+ /**
445
+ * 在coco/mvc中是否是一个合法的类
446
+ * @param v
447
+ */
448
+ function isCocoClass(v) {
449
+ return typeof v === 'function' && v.prototype && v.prototype.constructor === v &&
450
+ // 必须有$$id属性
451
+ typeof v.$$id === 'string' && v.$$id.trim();
452
+ }
318
453
 
319
454
  var defaultProp = 'value';
320
455
  /**
@@ -380,61 +515,6 @@ function instantiateMetadata(metadataCls, args) {
380
515
  return metadata;
381
516
  }
382
517
 
383
- function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
384
- function accept(f) {
385
- if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
386
- return f;
387
- }
388
- var kind = contextIn.kind,
389
- key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
390
- var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
391
- var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
392
- var _,
393
- done = false;
394
- for (var i = decorators.length - 1; i >= 0; i--) {
395
- var context = {};
396
- for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
397
- for (var p in contextIn.access) context.access[p] = contextIn.access[p];
398
- context.addInitializer = function (f) {
399
- if (done) throw new TypeError("Cannot add initializers after decoration has completed");
400
- extraInitializers.push(accept(f || null));
401
- };
402
- var result = (0, decorators[i])(kind === "accessor" ? {
403
- get: descriptor.get,
404
- set: descriptor.set
405
- } : descriptor[key], context);
406
- if (kind === "accessor") {
407
- if (result === void 0) continue;
408
- if (result === null || _typeof(result) !== "object") throw new TypeError("Object expected");
409
- if (_ = accept(result.get)) descriptor.get = _;
410
- if (_ = accept(result.set)) descriptor.set = _;
411
- if (_ = accept(result.init)) initializers.unshift(_);
412
- } else if (_ = accept(result)) {
413
- if (kind === "field") initializers.unshift(_);else descriptor[key] = _;
414
- }
415
- }
416
- if (target) Object.defineProperty(target, contextIn.name, descriptor);
417
- done = true;
418
- }
419
- function __runInitializers(thisArg, initializers, value) {
420
- var useValue = arguments.length > 2;
421
- for (var i = 0; i < initializers.length; i++) {
422
- value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
423
- }
424
- return useValue ? value : void 0;
425
- }
426
- function __setFunctionName(f, name, prefix) {
427
- if (_typeof(name) === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
428
- return Object.defineProperty(f, "name", {
429
- configurable: true,
430
- value: prefix ? "".concat(prefix, " ", name) : name
431
- });
432
- }
433
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
434
- var e = new Error(message);
435
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
436
- };
437
-
438
518
  var KindClass = 'class';
439
519
  var KindField = 'field';
440
520
  var KindMethod = 'method';
@@ -470,8 +550,11 @@ var DiagnoseCode;
470
550
  DiagnoseCode["CO10022"] = "CO10022";
471
551
  DiagnoseCode["CO10023"] = "CO10023";
472
552
  DiagnoseCode["CO10024"] = "CO10024";
553
+ DiagnoseCode["CO10025"] = "CO10025";
554
+ DiagnoseCode["CO10026"] = "CO10026";
555
+ DiagnoseCode["CO10027"] = "CO10027";
473
556
  })(DiagnoseCode || (DiagnoseCode = {}));
474
- var DiagnoseCodeMsg = (_DiagnoseCodeMsg = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_DiagnoseCodeMsg, DiagnoseCode.CO10001, '每个类最多只能添加一个component装饰器,但 %s 添加了:%s'), DiagnoseCode.CO10002, '元数据类 %s 必须有@target装饰器表明装饰目标'), DiagnoseCode.CO10003, '在一个类上不能添加多次同一个装饰器,但%s上存在重复装饰器: %s'), DiagnoseCode.CO10004, "%s \u7C7B\u4E0Aclass\u88C5\u9970\u5668 %s \u53EA\u80FD\u7528\u4E8E\u88C5\u9970%s"), DiagnoseCode.CO10005, "%s \u7C7B %s \u5B57\u6BB5\u4E0Afield\u88C5\u9970\u5668 %s \u53EA\u80FD\u7528\u4E8E\u88C5\u9970%s"), DiagnoseCode.CO10006, "%s \u7C7B %s \u65B9\u6CD5\u4E0Amethod\u88C5\u9970\u5668 %s \u53EA\u80FD\u7528\u4E8E\u88C5\u9970%s"), DiagnoseCode.CO10007, "\u4E1A\u52A1\u7C7B %s \u4E0D\u9700\u8981\u6DFB\u52A0@target\u88C5\u9970\u5668"), DiagnoseCode.CO10008, "%s \u7C7B %s \u65B9\u6CD5\u4E0A\u6709@component\u88C5\u9970\u5668\uFF0C\u4F46 %s \u6CA1\u6709@configuration\u7C7B\u88C5\u9970\u5668\u6216@configuration\u7684\u590D\u5408\u88C5\u9970\u5668"), DiagnoseCode.CO10009, "\u5B9E\u4F8B\u5316\u7EC4\u4EF6\u5931\u8D25\uFF0C%s \u7C7B\u5B58\u5728\u591A\u4E2A\u5B50\u7C7B %s\uFF0C\u4F46\u6CA1\u6709\u4F7F\u7528@qualifier\u6307\u5B9A\u5B50\u7C7Bid"), DiagnoseCode.CO10010, "\u5B9E\u4F8B\u5316\u7EC4\u4EF6\u5931\u8D25\uFF0C%s \u7C7B\u5B58\u5728\u591A\u4E2A\u5B50\u7C7B %s\uFF0C@qualifier\u88C5\u9970\u5668\u6307\u5B9A\u4E86\u4E00\u4E2A\u4E0D\u5B58\u5728\u7684\u5B50\u7C7Bid: %s"), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_DiagnoseCodeMsg, DiagnoseCode.CO10011, "\u5B9E\u4F8B\u5316\u7EC4\u4EF6\u5931\u8D25\uFF0C%s \u7C7B\u4E0D\u662Fioc\u7EC4\u4EF6"), DiagnoseCode.CO10012, "%s \u7C7B %s \u5B57\u6BB5\u4E0D\u80FD\u4F7F\u7528autowired\u6CE8\u5165\u81EA\u8EAB\uFF0C\u5B57\u6BB5\u7F6E\u4E3Aundefined"), DiagnoseCode.CO10013, "\u5B9E\u4F8B\u5316\u7EC4\u4EF6\u5931\u8D25\uFF0C%s \u7C7B\u7684\u6784\u9020\u51FD\u6570\u7684\u4F9D\u8D56 %s \u7C7B\u4E5F\u6CA1\u6709\u5B8C\u5168\u521D\u59CB\u5316\uFF0C\u53EF\u80FD\u662F\u5FAA\u73AF\u4F9D\u8D56\u4E86\uFF1F"), DiagnoseCode.CO10014, "\u5143\u6570\u636E\u7C7B %s \u521B\u5EFA\u4E86\u4E0D\u6B62\u4E00\u4E2A\u88C5\u9970\u5668\uFF0C\u6BCF\u4E2A\u5143\u6570\u636E\u7C7B\u53EA\u80FD\u521B\u5EFA\u4E00\u4E2A\u5BF9\u5E94\u7684\u88C5\u9970\u5668\u3002"), DiagnoseCode.CO10015, "\u5143\u6570\u636E\u7C7B %s \u672C\u8EAB\u5B58\u5728id\u5C5E\u6027\uFF0C\u4E14\u4E0D\u80FD\u88AB\u4FEE\u6539\u3002"), DiagnoseCode.CO10016, "\u5143\u6570\u636E\u7C7B %s \u6CA1\u6709id\u5C5E\u6027\u6216\u8005id\u5C5E\u6027\u4E0D\u662F\u5B57\u7B26\u4E32\uFF0C\u5FD8\u8BB0\u8C03\u7528assignMetadataId\u65B9\u6CD5\uFF1F"), DiagnoseCode.CO10017, "\u5143\u6570\u636E\u7C7B %s \u548C %s \u7684id\u5C5E\u6027\u76F8\u540C\uFF0Cid\u5C5E\u6027\u4E0D\u80FD\u91CD\u590D\u3002"), DiagnoseCode.CO10018, "createDecoratorExp\u7684\u7B2C\u4E00\u4E2A\u53C2\u6570 %s \u5FC5\u987B\u662FMetadata\u7684\u5B50\u7C7B\u3002"), DiagnoseCode.CO10019, "\u6846\u67B6\u6682\u4E0D\u652F\u6301\u4E3A %s \u6DFB\u52A0\u88C5\u9970\u5668\u3002"), DiagnoseCode.CO10020, "\u6709\u4E00\u4E2A\u5360\u4F4D\u88C5\u9970\u5668\u6CA1\u6709\u4F7F\u7528decorateSelf\u5173\u8054\u5177\u4F53\u7684\u5143\u6570\u636E\u7C7B\uFF0C\u5982\u679C\u4E0D\u4F7F\u7528\u7684\u8BDD\uFF0C\u76F4\u63A5\u5220\u9664\u8FD9\u4E2A\u88C5\u9970\u5668\u3002"), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_DiagnoseCodeMsg, DiagnoseCode.CO10021, "%s \u7C7B\u5B58\u5728\u4E00\u4E2A\u5360\u4F4D\u88C5\u9970\u5668\uFF0C\u4F46\u662F\u6CA1\u6709\u4F7F\u7528decorateSelf\u88C5\u9970\u5668\u5173\u8054\u771F\u6B63\u7684\u5143\u6570\u636E\u7C7B\u3002"), DiagnoseCode.CO10022, "\u5143\u6570\u636E\u7C7B %s \u53EA\u80FD\u6709 KindClass \u7C7B\u578B\u7684\u88C5\u9970\u5668\uFF0C\u5B57\u6BB5 %s \u4E0A\u7684\u88C5\u9970\u5668\u662F\u65E0\u6548\u7684\uFF0C\u8BF7\u5220\u9664\u3002"), DiagnoseCode.CO10023, "\u5143\u6570\u636E\u7C7B %s \u53EA\u80FD\u6709 KindClass \u7C7B\u578B\u7684\u88C5\u9970\u5668\uFF0C\u65B9\u6CD5 %s \u4E0A\u7684\u88C5\u9970\u5668\u662F\u65E0\u6548\u7684\uFF0C\u8BF7\u5220\u9664\u3002"), DiagnoseCode.CO10024, "\u5143\u6570\u636E\u7C7B %s \u5B58\u5728\u591A\u4E2A\u7EC4\u4EF6\u88C5\u9970\u5668 %s\uFF0C\u4E00\u4E2A\u5143\u6570\u636E\u7C7B\u6700\u591A\u53EA\u80FD\u6709\u4E00\u4E2A\u7EC4\u4EF6\u88C5\u9970\u5668\u3002"));
557
+ var DiagnoseCodeMsg = (_DiagnoseCodeMsg = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_DiagnoseCodeMsg, DiagnoseCode.CO10001, '每个类最多只能添加一个component装饰器,但 %s 添加了:%s'), DiagnoseCode.CO10002, '元数据类 %s 必须有@target装饰器表明装饰目标'), DiagnoseCode.CO10003, '在一个类上不能添加多次同一个装饰器,但%s上存在重复装饰器: %s'), DiagnoseCode.CO10004, "%s \u7C7B\u4E0Aclass\u88C5\u9970\u5668 %s \u53EA\u80FD\u7528\u4E8E\u88C5\u9970%s"), DiagnoseCode.CO10005, "%s \u7C7B %s \u5B57\u6BB5\u4E0Afield\u88C5\u9970\u5668 %s \u53EA\u80FD\u7528\u4E8E\u88C5\u9970%s"), DiagnoseCode.CO10006, "%s \u7C7B %s \u65B9\u6CD5\u4E0Amethod\u88C5\u9970\u5668 %s \u53EA\u80FD\u7528\u4E8E\u88C5\u9970%s"), DiagnoseCode.CO10007, "\u4E1A\u52A1\u7C7B %s \u4E0D\u9700\u8981\u6DFB\u52A0@target\u88C5\u9970\u5668"), DiagnoseCode.CO10008, "%s \u7C7B %s \u65B9\u6CD5\u4E0A\u6709@component\u88C5\u9970\u5668\uFF0C\u4F46 %s \u6CA1\u6709@configuration\u7C7B\u88C5\u9970\u5668\u6216@configuration\u7684\u590D\u5408\u88C5\u9970\u5668"), DiagnoseCode.CO10009, "\u5B9E\u4F8B\u5316\u7EC4\u4EF6\u5931\u8D25\uFF0C%s \u7C7B\u5B58\u5728\u591A\u4E2A\u5B50\u7C7B %s\uFF0C\u4F46\u6CA1\u6709\u4F7F\u7528@qualifier\u6307\u5B9A\u5B50\u7C7Bid"), DiagnoseCode.CO10010, "\u5B9E\u4F8B\u5316\u7EC4\u4EF6\u5931\u8D25\uFF0C%s \u7C7B\u5B58\u5728\u591A\u4E2A\u5B50\u7C7B %s\uFF0C@qualifier\u88C5\u9970\u5668\u6307\u5B9A\u4E86\u4E00\u4E2A\u4E0D\u5B58\u5728\u7684\u5B50\u7C7Bid: %s"), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_DiagnoseCodeMsg, DiagnoseCode.CO10011, "\u5B9E\u4F8B\u5316\u7EC4\u4EF6\u5931\u8D25\uFF0C%s \u7C7B\u4E0D\u662Fioc\u7EC4\u4EF6"), DiagnoseCode.CO10012, "%s \u7C7B %s \u5B57\u6BB5\u4E0D\u80FD\u4F7F\u7528autowired\u6CE8\u5165\u81EA\u8EAB\uFF0C\u5B57\u6BB5\u7F6E\u4E3Aundefined"), DiagnoseCode.CO10013, "\u5B9E\u4F8B\u5316\u7EC4\u4EF6\u5931\u8D25\uFF0C%s \u7C7B\u7684\u6784\u9020\u51FD\u6570\u7684\u4F9D\u8D56 %s \u7C7B\u4E5F\u6CA1\u6709\u5B8C\u5168\u521D\u59CB\u5316\uFF0C\u53EF\u80FD\u662F\u5FAA\u73AF\u4F9D\u8D56\u4E86\uFF1F"), DiagnoseCode.CO10014, "\u5143\u6570\u636E\u7C7B %s \u521B\u5EFA\u4E86\u4E0D\u6B62\u4E00\u4E2A\u88C5\u9970\u5668\uFF0C\u6BCF\u4E2A\u5143\u6570\u636E\u7C7B\u53EA\u80FD\u521B\u5EFA\u4E00\u4E2A\u5BF9\u5E94\u7684\u88C5\u9970\u5668\u3002"), DiagnoseCode.CO10015, "\u5143\u6570\u636E\u7C7B %s \u672C\u8EAB\u5B58\u5728id\u5C5E\u6027\uFF0C\u4E14\u4E0D\u80FD\u88AB\u4FEE\u6539\u3002"), DiagnoseCode.CO10016, "\u5143\u6570\u636E\u7C7B %s \u6CA1\u6709id\u5C5E\u6027\u6216\u8005id\u5C5E\u6027\u4E0D\u662F\u5B57\u7B26\u4E32\uFF0C\u5FD8\u8BB0\u8C03\u7528assignMetadataId\u65B9\u6CD5\uFF1F"), DiagnoseCode.CO10017, "\u5143\u6570\u636E\u7C7B %s \u548C %s \u7684id\u5C5E\u6027\u76F8\u540C\uFF0Cid\u5C5E\u6027\u4E0D\u80FD\u91CD\u590D\u3002"), DiagnoseCode.CO10018, "createDecoratorExp\u7684\u7B2C\u4E00\u4E2A\u53C2\u6570 %s \u5FC5\u987B\u662FMetadata\u7684\u5B50\u7C7B\u3002"), DiagnoseCode.CO10019, "\u6846\u67B6\u6682\u4E0D\u652F\u6301\u4E3A %s \u6DFB\u52A0\u88C5\u9970\u5668\u3002"), DiagnoseCode.CO10020, "\u6709\u4E00\u4E2A\u5360\u4F4D\u88C5\u9970\u5668\u6CA1\u6709\u4F7F\u7528decorateSelf\u5173\u8054\u5177\u4F53\u7684\u5143\u6570\u636E\u7C7B\uFF0C\u5982\u679C\u4E0D\u4F7F\u7528\u7684\u8BDD\uFF0C\u76F4\u63A5\u5220\u9664\u8FD9\u4E2A\u88C5\u9970\u5668\u3002"), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_DiagnoseCodeMsg, DiagnoseCode.CO10021, "%s \u7C7B\u5B58\u5728\u4E00\u4E2A\u5360\u4F4D\u88C5\u9970\u5668\uFF0C\u4F46\u662F\u6CA1\u6709\u4F7F\u7528decorateSelf\u88C5\u9970\u5668\u5173\u8054\u771F\u6B63\u7684\u5143\u6570\u636E\u7C7B\u3002"), DiagnoseCode.CO10022, "\u5143\u6570\u636E\u7C7B %s \u53EA\u80FD\u6709 KindClass \u7C7B\u578B\u7684\u88C5\u9970\u5668\uFF0C\u5B57\u6BB5 %s \u4E0A\u7684\u88C5\u9970\u5668\u662F\u65E0\u6548\u7684\uFF0C\u8BF7\u5220\u9664\u3002"), DiagnoseCode.CO10023, "\u5143\u6570\u636E\u7C7B %s \u53EA\u80FD\u6709 KindClass \u7C7B\u578B\u7684\u88C5\u9970\u5668\uFF0C\u65B9\u6CD5 %s \u4E0A\u7684\u88C5\u9970\u5668\u662F\u65E0\u6548\u7684\uFF0C\u8BF7\u5220\u9664\u3002"), DiagnoseCode.CO10024, "\u5143\u6570\u636E\u7C7B %s \u5B58\u5728\u591A\u4E2A\u7EC4\u4EF6\u88C5\u9970\u5668 %s\uFF0C\u4E00\u4E2A\u5143\u6570\u636E\u7C7B\u6700\u591A\u53EA\u80FD\u6709\u4E00\u4E2A\u7EC4\u4EF6\u88C5\u9970\u5668\u3002"), DiagnoseCode.CO10025, "findClassKindMetadataRecursively\u7684\u7B2C\u4E8C\u4E2A\u53C2\u6570 %s \u5FC5\u987B\u662F\u5143\u6570\u636E\u7C7B\u3002"), DiagnoseCode.CO10026, '在一个字段上不能添加多次同一个装饰器,但 %s 上 %s 字段存在重复装饰器: %s'), DiagnoseCode.CO10027, '在一个方法上不能添加多次同一个装饰器,但 %s 上 %s 字段存在重复装饰器: %s'));
475
558
  function createDiagnose(code) {
476
559
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
477
560
  args[_key - 1] = arguments[_key];
@@ -541,7 +624,6 @@ function addDecoratorParams(isPlaceholderMetaClass, beDecoratedCls, params) {
541
624
  if (!isClass(beDecoratedCls)) {
542
625
  return;
543
626
  }
544
- // TODO: 装饰器不应该允许重复添加,但是又需要允许添加类装饰器,field装饰器这样的场景
545
627
  if (!decoratorParamMap.has(beDecoratedCls)) {
546
628
  decoratorParamMap.set(beDecoratedCls, []);
547
629
  }
@@ -584,7 +666,6 @@ function replacePlaceholderMetaClassParams2RealMetadataClassParams(_ref) {
584
666
  var p = _step4.value;
585
667
  if (p.metadataClass === placeholderMetaClass) {
586
668
  p.metadataClass = realMetadataClass;
587
- p.placeholderMetadataClass = placeholderMetaClass;
588
669
  }
589
670
  }
590
671
  } catch (err) {
@@ -621,7 +702,7 @@ function replacePlaceholderMetaClassParams2RealMetadataClassParams(_ref) {
621
702
  function getDecoratorParam() {
622
703
  return decoratorParamMap;
623
704
  }
624
- function clear$4() {
705
+ function clear$2() {
625
706
  decoratorParamMap.clear();
626
707
  }
627
708
 
@@ -679,7 +760,7 @@ function getPlaceholderClassMap2RealMetadataClass() {
679
760
  notCalledDecorateSelfPlaceholderClassList: notCalledDecorateSelfPlaceholderClassList
680
761
  };
681
762
  }
682
- function clear$3() {
763
+ function clear$1() {
683
764
  metadataDecoratorOptions.clear();
684
765
  placeholderDecoratorOptions.clear();
685
766
  placeholderClassMap2RealMetadataClass.clear();
@@ -724,7 +805,7 @@ function createDecoratorExpFactory(fn) {
724
805
  if (config && config.toUpdateClassSet.size) {
725
806
  for (var _i = 0, _Array$from = Array.from(config.toUpdateClassSet); _i < _Array$from.length; _i++) {
726
807
  var cls = _Array$from[_i];
727
- beDecoratedCls === null || beDecoratedCls === void 0 ? void 0 : beDecoratedCls.classDecoratorModifyPrototype(cls.prototype);
808
+ beDecoratedCls === null || beDecoratedCls === void 0 || beDecoratedCls.classDecoratorModifyPrototype(cls.prototype);
728
809
  }
729
810
  }
730
811
  placeholderDecoratorModifyPrototype.set(MetaClsOrPlaceholderMetaCls, {
@@ -745,7 +826,6 @@ function createDecoratorExpFactory(fn) {
745
826
  }
746
827
  function doCreateDecoratorExp(userParam) {
747
828
  return function (beDecoratedCls, context) {
748
- var _a;
749
829
  switch (context.kind) {
750
830
  case KindClass:
751
831
  {
@@ -773,15 +853,16 @@ function createDecoratorExpFactory(fn) {
773
853
  // 又装饰器其他类,同样收集
774
854
  config.toUpdateClassSet.add(beDecoratedCls);
775
855
  } else if (config.classDecoratorModifyPrototype === null) {
856
+ var _config$toUpdateClass;
776
857
  // 不需要更新了,清空即可
777
- (_a = config.toUpdateClassSet) === null || _a === void 0 ? void 0 : _a.clear();
858
+ (_config$toUpdateClass = config.toUpdateClassSet) === null || _config$toUpdateClass === void 0 || _config$toUpdateClass.clear();
778
859
  }
779
860
  }
780
861
  }
781
862
  } else {
782
863
  // 不是占位装饰器,直接修改被装饰类的原型链
783
864
  if (typeof (MetaClsOrPlaceholderMetaCls === null || MetaClsOrPlaceholderMetaCls === void 0 ? void 0 : MetaClsOrPlaceholderMetaCls.classDecoratorModifyPrototype) === 'function') {
784
- MetaClsOrPlaceholderMetaCls === null || MetaClsOrPlaceholderMetaCls === void 0 ? void 0 : MetaClsOrPlaceholderMetaCls.classDecoratorModifyPrototype(beDecoratedCls.prototype);
865
+ MetaClsOrPlaceholderMetaCls === null || MetaClsOrPlaceholderMetaCls === void 0 || MetaClsOrPlaceholderMetaCls.classDecoratorModifyPrototype(beDecoratedCls.prototype);
785
866
  }
786
867
  }
787
868
  break;
@@ -795,7 +876,7 @@ function createDecoratorExpFactory(fn) {
795
876
  default:
796
877
  throw new Error(stringifyDiagnose(createDiagnose(DiagnoseCode.CO10019, context.kind)));
797
878
  }
798
- var initializerOnce = once(function initializer() {
879
+ var execOnce = once(function initializer() {
799
880
  switch (context.kind) {
800
881
  case KindField:
801
882
  case KindMethod:
@@ -809,7 +890,7 @@ function createDecoratorExpFactory(fn) {
809
890
  }
810
891
  });
811
892
  context.addInitializer(function () {
812
- initializerOnce(this);
893
+ execOnce(this);
813
894
  });
814
895
  return undefined;
815
896
  };
@@ -833,7 +914,8 @@ function createDecoratorExp(metadataCls, option) {
833
914
  return doCreateDecoratorExp(false, metadataCls, option);
834
915
  }
835
916
  /**
836
- * 创建一个未绑定元数据的装饰器表达式,后续通过表达式的第二个参数来绑定
917
+ * 创建一个未绑定元数据的装饰器表达式
918
+ * 需要在正式的元数据类上添加decorateSelf装饰器来关联真实的元数据类,装饰器到其他类的使用方式和createDecoratorExp是一致的。
837
919
  * 适用于装饰器装饰自己元数据类的场景
838
920
  * @public
839
921
  */
@@ -876,10 +958,25 @@ function initDecoratorParamModule() {
876
958
  mergePlaceholderClass2RealMetadataClassRelation();
877
959
  // 收集到的所有的装饰器参数,占位的元数据类替换成真实的元数据类
878
960
  replacePlaceholderMetaClassParams2RealMetadataClassParams(getPlaceholderClassMap2RealMetadataClass());
961
+ // 所有的被装饰类都要符合一定的要求
962
+ var _iterator2 = _createForOfIteratorHelper(getDecoratorParam().keys()),
963
+ _step2;
964
+ try {
965
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
966
+ var beDecoratedClass = _step2.value;
967
+ if (!isCocoClass(beDecoratedClass)) {
968
+ throw new Error("\u6240\u6709\u88AB\u88C5\u9970\u5668\u7684\u5BF9\u8C61".concat(beDecoratedClass === null || beDecoratedClass === void 0 ? void 0 : beDecoratedClass.name, "\u5FC5\u987B\u90FD\u662F\u7C7B\u6216\u8005\u7C7B\u5B57\u6BB5\u6216\u7C7B\u65B9\u6CD5\uFF0C\u4E14\u5FC5\u987B\u5B58\u5728\u9759\u6001$$id\u5B57\u6BB5\u3002"));
969
+ }
970
+ }
971
+ } catch (err) {
972
+ _iterator2.e(err);
973
+ } finally {
974
+ _iterator2.f();
975
+ }
879
976
  }
880
977
  function clearDecoratorParamModule() {
881
- clear$3();
882
- clear$4();
978
+ clear$1();
979
+ clear$2();
883
980
  }
884
981
 
885
982
  /**
@@ -896,101 +993,110 @@ var Type;
896
993
  */
897
994
  var target = createPlaceholderDecoratorExp();
898
995
 
996
+ var _Class$x, _Target3, _applyDecs$c$x;
997
+ var _initClass$x, _Target2;
899
998
  /**
900
999
  * @public
901
- * @id()装饰器
902
- * 用于为元数据类或者组件类设置id,id的作用是可以根据id返回元数据类,也可以根据id实例化组件,所以id必须要唯一。
903
- * 如果一个组件不添加id装饰器,那么组件或者元数据类的id就是class.name(webpack目前打包不会压缩class关键字,TODO: rollup打包会压缩class关键字,要么强制添加id装饰器,要么强制不压缩class关键字)
904
- * 如果用户显式设置了id装饰器,那么会使用用户设置的id
905
1000
  */
906
- var id$2 = createPlaceholderDecoratorExp();
907
-
1001
+ var _Target;
1002
+ new (_Target2 = (_Target3 = /*#__PURE__*/function (_Metadata) {
1003
+ function Target() {
1004
+ var _this;
1005
+ _classCallCheck(this, Target);
1006
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1007
+ args[_key] = arguments[_key];
1008
+ }
1009
+ _this = _callSuper(this, Target, [].concat(args));
1010
+ _defineProperty(_this, "value", void 0);
1011
+ return _this;
1012
+ }
1013
+ _inherits(Target, _Metadata);
1014
+ return _createClass(Target);
1015
+ }(Metadata), _applyDecs$c$x = _slicedToArray(_applyDecs2311(_Target3, [target.decorateSelf([Type.Class])], [], 0, void 0, Metadata).c, 2), _Target = _applyDecs$c$x[0], _initClass$x = _applyDecs$c$x[1], _Target3), _Class$x = /*#__PURE__*/function (_identity2) {
1016
+ function _Class() {
1017
+ var _this2;
1018
+ _classCallCheck(this, _Class);
1019
+ _this2 = _callSuper(this, _Class, [_Target]), _defineProperty(_assertThisInitialized(_this2), "$$id", "Target"), _defineProperty(_assertThisInitialized(_this2), "Type", Type), _initClass$x();
1020
+ return _this2;
1021
+ }
1022
+ _inherits(_Class, _identity2);
1023
+ return _createClass(_Class);
1024
+ }(_identity), _defineProperty(_Class$x, _Target2, void 0), _Class$x)();
1025
+ var Target = _Target;
1026
+
1027
+ var _Class$w, _Autowired3, _applyDecs$c$w;
1028
+ var _initClass$w, _Autowired2;
908
1029
  /**
909
1030
  * @public
910
1031
  */
911
- var Target = function () {
912
- var _classDecorators = [id$2('Target'), target.decorateSelf([Type.Class])];
913
- var _classDescriptor;
914
- var _classExtraInitializers = [];
915
- var _classThis;
916
- var _classSuper = Metadata;
917
- _classThis = /*#__PURE__*/function (_classSuper2) {
918
- function _classThis() {
919
- _classCallCheck(this, _classThis);
920
- return _callSuper(this, _classThis, arguments);
921
- }
922
- _inherits(_classThis, _classSuper2);
923
- return _createClass(_classThis);
924
- }(_classSuper);
925
- __setFunctionName(_classThis, "Target");
926
- (function () {
927
- var _a;
928
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
929
- __esDecorate(null, _classDescriptor = {
930
- value: _classThis
931
- }, _classDecorators, {
932
- kind: "class",
933
- name: _classThis.name,
934
- metadata: _metadata
935
- }, null, _classExtraInitializers);
936
- _classThis = _classDescriptor.value;
937
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
938
- enumerable: true,
939
- configurable: true,
940
- writable: true,
941
- value: _metadata
942
- });
943
- })();
944
- _classThis.Type = Type;
945
- (function () {
946
- __runInitializers(_classThis, _classExtraInitializers);
947
- })();
948
- return _classThis;
949
- }();
1032
+ var _Autowired;
1033
+ new (_Autowired2 = (_Autowired3 = /*#__PURE__*/function (_Metadata) {
1034
+ function Autowired() {
1035
+ var _this;
1036
+ _classCallCheck(this, Autowired);
1037
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1038
+ args[_key] = arguments[_key];
1039
+ }
1040
+ _this = _callSuper(this, Autowired, [].concat(args));
1041
+ _defineProperty(_this, "value", void 0);
1042
+ return _this;
1043
+ }
1044
+ _inherits(Autowired, _Metadata);
1045
+ return _createClass(Autowired);
1046
+ }(Metadata), _applyDecs$c$w = _slicedToArray(_applyDecs2311(_Autowired3, [target([Target.Type.Field])], [], 0, void 0, Metadata).c, 2), _Autowired = _applyDecs$c$w[0], _initClass$w = _applyDecs$c$w[1], _Autowired3), _Class$w = /*#__PURE__*/function (_identity2) {
1047
+ function _Class() {
1048
+ var _this2;
1049
+ _classCallCheck(this, _Class);
1050
+ _this2 = _callSuper(this, _Class, [_Autowired]), _defineProperty(_assertThisInitialized(_this2), "$$id", "Autowired"), _initClass$w();
1051
+ return _this2;
1052
+ }
1053
+ _inherits(_Class, _identity2);
1054
+ return _createClass(_Class);
1055
+ }(_identity), _defineProperty(_Class$w, _Autowired2, void 0), _Class$w)();
1056
+ var Autowired = _Autowired;
950
1057
 
1058
+ // TODO: cls?: Class<any>如果去掉的话,在项目中会报错,应该是ts-server是拿到参数了,但是声明中确没有
1059
+ var autowired = createDecoratorExp(Autowired);
1060
+
1061
+ var _Class$v, _Id3, _applyDecs$c$v;
1062
+ var _initClass$v, _Id2;
951
1063
  /**
952
1064
  * @public
953
1065
  */
954
- var Autowired = function () {
955
- var _classDecorators = [id$2('Autowired'), target([Target.Type.Field])];
956
- var _classDescriptor;
957
- var _classExtraInitializers = [];
958
- var _classThis;
959
- var _classSuper = Metadata;
960
- _classThis = /*#__PURE__*/function (_classSuper2) {
961
- function _classThis() {
962
- _classCallCheck(this, _classThis);
963
- return _callSuper(this, _classThis, arguments);
964
- }
965
- _inherits(_classThis, _classSuper2);
966
- return _createClass(_classThis);
967
- }(_classSuper);
968
- __setFunctionName(_classThis, "Autowired");
969
- (function () {
970
- var _a;
971
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
972
- __esDecorate(null, _classDescriptor = {
973
- value: _classThis
974
- }, _classDecorators, {
975
- kind: "class",
976
- name: _classThis.name,
977
- metadata: _metadata
978
- }, null, _classExtraInitializers);
979
- _classThis = _classDescriptor.value;
980
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
981
- enumerable: true,
982
- configurable: true,
983
- writable: true,
984
- value: _metadata
985
- });
986
- __runInitializers(_classThis, _classExtraInitializers);
987
- })();
988
- return _classThis;
989
- }();
1066
+ var _Id;
1067
+ new (_Id2 = (_Id3 = /*#__PURE__*/function (_Metadata) {
1068
+ function Id() {
1069
+ var _this;
1070
+ _classCallCheck(this, Id);
1071
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1072
+ args[_key] = arguments[_key];
1073
+ }
1074
+ _this = _callSuper(this, Id, [].concat(args));
1075
+ _defineProperty(_this, "value", void 0);
1076
+ return _this;
1077
+ }
1078
+ _inherits(Id, _Metadata);
1079
+ return _createClass(Id);
1080
+ }(Metadata), _applyDecs$c$v = _slicedToArray(_applyDecs2311(_Id3, [target([Target.Type.Method])], [], 0, void 0, Metadata).c, 2), _Id = _applyDecs$c$v[0], _initClass$v = _applyDecs$c$v[1], _Id3), _Class$v = /*#__PURE__*/function (_identity2) {
1081
+ function _Class() {
1082
+ var _this2;
1083
+ _classCallCheck(this, _Class);
1084
+ _this2 = _callSuper(this, _Class, [_Id]), _defineProperty(_assertThisInitialized(_this2), "$$id", "Id"), _initClass$v();
1085
+ return _this2;
1086
+ }
1087
+ _inherits(_Class, _identity2);
1088
+ return _createClass(_Class);
1089
+ }(_identity), _defineProperty(_Class$v, _Id2, void 0), _Class$v)();
1090
+ var Id = _Id;
990
1091
 
991
- // TODO: cls?: Class<any>如果去掉的话,在项目中会报错,应该是ts-server是拿到参数了,但是声明中确没有
992
- var autowired = createDecoratorExp(Autowired);
1092
+ /**
1093
+ * @id装饰器
1094
+ * 在使用@component方法装饰注入的普通类,必须使用@id来申明组件的$$id
1095
+ */
1096
+ var id$2 = createDecoratorExp(Id);
993
1097
 
1098
+ var _Class$u, _Component3, _applyDecs$c$u;
1099
+ var _initClass$u, _Component2;
994
1100
  /**
995
1101
  * Component不添加@scope(SCOPE.Singleton)的原因:
996
1102
  * 因为不设置默认就是singleton,还可以避免 scope <-> target 循环依赖的问题
@@ -998,42 +1104,31 @@ var autowired = createDecoratorExp(Autowired);
998
1104
  /**
999
1105
  * @public
1000
1106
  */
1001
- var Component = function () {
1002
- var _classDecorators = [id$2('Component'), target([Target.Type.Class, Target.Type.Method])];
1003
- var _classDescriptor;
1004
- var _classExtraInitializers = [];
1005
- var _classThis;
1006
- var _classSuper = Metadata;
1007
- _classThis = /*#__PURE__*/function (_classSuper2) {
1008
- function _classThis() {
1009
- _classCallCheck(this, _classThis);
1010
- return _callSuper(this, _classThis, arguments);
1011
- }
1012
- _inherits(_classThis, _classSuper2);
1013
- return _createClass(_classThis);
1014
- }(_classSuper);
1015
- __setFunctionName(_classThis, "Component");
1016
- (function () {
1017
- var _a;
1018
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
1019
- __esDecorate(null, _classDescriptor = {
1020
- value: _classThis
1021
- }, _classDecorators, {
1022
- kind: "class",
1023
- name: _classThis.name,
1024
- metadata: _metadata
1025
- }, null, _classExtraInitializers);
1026
- _classThis = _classDescriptor.value;
1027
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
1028
- enumerable: true,
1029
- configurable: true,
1030
- writable: true,
1031
- value: _metadata
1032
- });
1033
- __runInitializers(_classThis, _classExtraInitializers);
1034
- })();
1035
- return _classThis;
1036
- }();
1107
+ var _Component;
1108
+ new (_Component2 = (_Component3 = /*#__PURE__*/function (_Metadata) {
1109
+ function Component() {
1110
+ var _this;
1111
+ _classCallCheck(this, Component);
1112
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1113
+ args[_key] = arguments[_key];
1114
+ }
1115
+ _this = _callSuper(this, Component, [].concat(args));
1116
+ _defineProperty(_this, "value", void 0);
1117
+ return _this;
1118
+ }
1119
+ _inherits(Component, _Metadata);
1120
+ return _createClass(Component);
1121
+ }(Metadata), _applyDecs$c$u = _slicedToArray(_applyDecs2311(_Component3, [target([Target.Type.Class, Target.Type.Method])], [], 0, void 0, Metadata).c, 2), _Component = _applyDecs$c$u[0], _initClass$u = _applyDecs$c$u[1], _Component3), _Class$u = /*#__PURE__*/function (_identity2) {
1122
+ function _Class() {
1123
+ var _this2;
1124
+ _classCallCheck(this, _Class);
1125
+ _this2 = _callSuper(this, _Class, [_Component]), _defineProperty(_assertThisInitialized(_this2), "$$id", "Component"), _initClass$u();
1126
+ return _this2;
1127
+ }
1128
+ _inherits(_Class, _identity2);
1129
+ return _createClass(_Class);
1130
+ }(_identity), _defineProperty(_Class$u, _Component2, void 0), _Class$u)();
1131
+ var Component = _Component;
1037
1132
 
1038
1133
  /**
1039
1134
  * ioc组件,只有ioc组件才能实例化
@@ -1041,130 +1136,68 @@ var Component = function () {
1041
1136
  */
1042
1137
  var component = createDecoratorExp(Component);
1043
1138
 
1139
+ var _Class$t, _Configuration3, _applyDecs$c$t;
1140
+ var _initClass$t, _Configuration2;
1044
1141
  /**
1045
1142
  * @public
1046
1143
  */
1047
- var Configuration = function () {
1048
- var _classDecorators = [id$2('Configuration'), target([Target.Type.Class])];
1049
- var _classDescriptor;
1050
- var _classExtraInitializers = [];
1051
- var _classThis;
1052
- var _classSuper = Metadata;
1053
- _classThis = /*#__PURE__*/function (_classSuper2) {
1054
- function _classThis() {
1055
- _classCallCheck(this, _classThis);
1056
- return _callSuper(this, _classThis, arguments);
1057
- }
1058
- _inherits(_classThis, _classSuper2);
1059
- return _createClass(_classThis);
1060
- }(_classSuper);
1061
- __setFunctionName(_classThis, "Configuration");
1062
- (function () {
1063
- var _a;
1064
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
1065
- __esDecorate(null, _classDescriptor = {
1066
- value: _classThis
1067
- }, _classDecorators, {
1068
- kind: "class",
1069
- name: _classThis.name,
1070
- metadata: _metadata
1071
- }, null, _classExtraInitializers);
1072
- _classThis = _classDescriptor.value;
1073
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
1074
- enumerable: true,
1075
- configurable: true,
1076
- writable: true,
1077
- value: _metadata
1078
- });
1079
- __runInitializers(_classThis, _classExtraInitializers);
1080
- })();
1081
- return _classThis;
1082
- }();
1144
+ var _Configuration;
1145
+ new (_Configuration2 = (_Configuration3 = /*#__PURE__*/function (_Metadata) {
1146
+ function Configuration() {
1147
+ _classCallCheck(this, Configuration);
1148
+ return _callSuper(this, Configuration, arguments);
1149
+ }
1150
+ _inherits(Configuration, _Metadata);
1151
+ return _createClass(Configuration);
1152
+ }(Metadata), _applyDecs$c$t = _slicedToArray(_applyDecs2311(_Configuration3, [target([Target.Type.Class])], [], 0, void 0, Metadata).c, 2), _Configuration = _applyDecs$c$t[0], _initClass$t = _applyDecs$c$t[1], _Configuration3), _Class$t = /*#__PURE__*/function (_identity2) {
1153
+ function _Class() {
1154
+ var _this;
1155
+ _classCallCheck(this, _Class);
1156
+ _this = _callSuper(this, _Class, [_Configuration]), _defineProperty(_assertThisInitialized(_this), "$$id", "Configuration"), _initClass$t();
1157
+ return _this;
1158
+ }
1159
+ _inherits(_Class, _identity2);
1160
+ return _createClass(_Class);
1161
+ }(_identity), _defineProperty(_Class$t, _Configuration2, void 0), _Class$t)();
1162
+ var Configuration = _Configuration;
1083
1163
 
1084
1164
  var configuration = createDecoratorExp(Configuration);
1085
1165
 
1166
+ var _Class$s, _ConstructorParam3, _applyDecs$c$s;
1167
+ var _initClass$s, _ConstructorParam2;
1086
1168
  /**
1087
1169
  * @public
1088
1170
  */
1089
- var ConstructorParam = function () {
1090
- var _classDecorators = [id$2('ConstructorParam'), target([Target.Type.Class])];
1091
- var _classDescriptor;
1092
- var _classExtraInitializers = [];
1093
- var _classThis;
1094
- var _classSuper = Metadata;
1095
- _classThis = /*#__PURE__*/function (_classSuper2) {
1096
- function _classThis() {
1097
- _classCallCheck(this, _classThis);
1098
- return _callSuper(this, _classThis, arguments);
1099
- }
1100
- _inherits(_classThis, _classSuper2);
1101
- return _createClass(_classThis);
1102
- }(_classSuper);
1103
- __setFunctionName(_classThis, "ConstructorParam");
1104
- (function () {
1105
- var _a;
1106
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
1107
- __esDecorate(null, _classDescriptor = {
1108
- value: _classThis
1109
- }, _classDecorators, {
1110
- kind: "class",
1111
- name: _classThis.name,
1112
- metadata: _metadata
1113
- }, null, _classExtraInitializers);
1114
- _classThis = _classDescriptor.value;
1115
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
1116
- enumerable: true,
1117
- configurable: true,
1118
- writable: true,
1119
- value: _metadata
1120
- });
1121
- __runInitializers(_classThis, _classExtraInitializers);
1122
- })();
1123
- return _classThis;
1124
- }();
1171
+ var _ConstructorParam;
1172
+ new (_ConstructorParam2 = (_ConstructorParam3 = /*#__PURE__*/function (_Metadata) {
1173
+ function ConstructorParam() {
1174
+ var _this;
1175
+ _classCallCheck(this, ConstructorParam);
1176
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1177
+ args[_key] = arguments[_key];
1178
+ }
1179
+ _this = _callSuper(this, ConstructorParam, [].concat(args));
1180
+ _defineProperty(_this, "value", void 0);
1181
+ return _this;
1182
+ }
1183
+ _inherits(ConstructorParam, _Metadata);
1184
+ return _createClass(ConstructorParam);
1185
+ }(Metadata), _applyDecs$c$s = _slicedToArray(_applyDecs2311(_ConstructorParam3, [target([Target.Type.Class])], [], 0, void 0, Metadata).c, 2), _ConstructorParam = _applyDecs$c$s[0], _initClass$s = _applyDecs$c$s[1], _ConstructorParam3), _Class$s = /*#__PURE__*/function (_identity2) {
1186
+ function _Class() {
1187
+ var _this2;
1188
+ _classCallCheck(this, _Class);
1189
+ _this2 = _callSuper(this, _Class, [_ConstructorParam]), _defineProperty(_assertThisInitialized(_this2), "$$id", "ConstructorParam"), _initClass$s();
1190
+ return _this2;
1191
+ }
1192
+ _inherits(_Class, _identity2);
1193
+ return _createClass(_Class);
1194
+ }(_identity), _defineProperty(_Class$s, _ConstructorParam2, void 0), _Class$s)();
1195
+ var ConstructorParam = _ConstructorParam;
1125
1196
 
1126
1197
  var constructorParam = createDecoratorExp(ConstructorParam);
1127
1198
 
1128
- /**
1129
- * @public
1130
- */
1131
- var Id = function () {
1132
- var _classDecorators = [id$2.decorateSelf('Id'), target([Target.Type.Class])];
1133
- var _classDescriptor;
1134
- var _classExtraInitializers = [];
1135
- var _classThis;
1136
- var _classSuper = Metadata;
1137
- _classThis = /*#__PURE__*/function (_classSuper2) {
1138
- function _classThis() {
1139
- _classCallCheck(this, _classThis);
1140
- return _callSuper(this, _classThis, arguments);
1141
- }
1142
- _inherits(_classThis, _classSuper2);
1143
- return _createClass(_classThis);
1144
- }(_classSuper);
1145
- __setFunctionName(_classThis, "Id");
1146
- (function () {
1147
- var _a;
1148
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
1149
- __esDecorate(null, _classDescriptor = {
1150
- value: _classThis
1151
- }, _classDecorators, {
1152
- kind: "class",
1153
- name: _classThis.name,
1154
- metadata: _metadata
1155
- }, null, _classExtraInitializers);
1156
- _classThis = _classDescriptor.value;
1157
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
1158
- enumerable: true,
1159
- configurable: true,
1160
- writable: true,
1161
- value: _metadata
1162
- });
1163
- __runInitializers(_classThis, _classExtraInitializers);
1164
- })();
1165
- return _classThis;
1166
- }();
1167
-
1199
+ var _Class$r, _Scope3, _applyDecs$c$r;
1200
+ var _initClass$r, _Scope2;
1168
1201
  /**
1169
1202
  * @public
1170
1203
  */
@@ -1178,129 +1211,97 @@ exports.SCOPE = void 0;
1178
1211
  /**
1179
1212
  * @public
1180
1213
  */
1181
- var Scope = function () {
1182
- var _classDecorators = [id$2('Scope'), target([Target.Type.Class, Target.Type.Method])];
1183
- var _classDescriptor;
1184
- var _classExtraInitializers = [];
1185
- var _classThis;
1186
- var _classSuper = Metadata;
1187
- _classThis = /*#__PURE__*/function (_classSuper2) {
1188
- function _classThis() {
1189
- var _this;
1190
- _classCallCheck(this, _classThis);
1191
- _this = _callSuper(this, _classThis, arguments);
1192
- _this.value = exports.SCOPE.Singleton;
1193
- return _this;
1194
- }
1195
- _inherits(_classThis, _classSuper2);
1196
- return _createClass(_classThis);
1197
- }(_classSuper);
1198
- __setFunctionName(_classThis, "Scope");
1199
- (function () {
1200
- var _a;
1201
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
1202
- __esDecorate(null, _classDescriptor = {
1203
- value: _classThis
1204
- }, _classDecorators, {
1205
- kind: "class",
1206
- name: _classThis.name,
1207
- metadata: _metadata
1208
- }, null, _classExtraInitializers);
1209
- _classThis = _classDescriptor.value;
1210
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
1211
- enumerable: true,
1212
- configurable: true,
1213
- writable: true,
1214
- value: _metadata
1215
- });
1216
- __runInitializers(_classThis, _classExtraInitializers);
1217
- })();
1218
- return _classThis;
1219
- }();
1214
+ var _Scope;
1215
+ new (_Scope2 = (_Scope3 = /*#__PURE__*/function (_Metadata) {
1216
+ function Scope() {
1217
+ var _this;
1218
+ _classCallCheck(this, Scope);
1219
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1220
+ args[_key] = arguments[_key];
1221
+ }
1222
+ _this = _callSuper(this, Scope, [].concat(args));
1223
+ _defineProperty(_this, "value", exports.SCOPE.Singleton);
1224
+ return _this;
1225
+ }
1226
+ _inherits(Scope, _Metadata);
1227
+ return _createClass(Scope);
1228
+ }(Metadata), _applyDecs$c$r = _slicedToArray(_applyDecs2311(_Scope3, [target([Target.Type.Class, Target.Type.Method])], [], 0, void 0, Metadata).c, 2), _Scope = _applyDecs$c$r[0], _initClass$r = _applyDecs$c$r[1], _Scope3), _Class$r = /*#__PURE__*/function (_identity2) {
1229
+ function _Class() {
1230
+ var _this2;
1231
+ _classCallCheck(this, _Class);
1232
+ _this2 = _callSuper(this, _Class, [_Scope]), _defineProperty(_assertThisInitialized(_this2), "$$id", "Scope"), _initClass$r();
1233
+ return _this2;
1234
+ }
1235
+ _inherits(_Class, _identity2);
1236
+ return _createClass(_Class);
1237
+ }(_identity), _defineProperty(_Class$r, _Scope2, void 0), _Class$r)();
1238
+ var Scope = _Scope;
1220
1239
 
1221
1240
  var scope = createDecoratorExp(Scope);
1222
1241
 
1242
+ var _Class$q, _Qualifier3, _applyDecs$c$q;
1243
+ var _initClass$q, _Qualifier2;
1223
1244
  /**
1224
1245
  * @public
1225
1246
  */
1226
- var Qualifier = function () {
1227
- var _classDecorators = [id$2('Qualifier'), target([Target.Type.Field])];
1228
- var _classDescriptor;
1229
- var _classExtraInitializers = [];
1230
- var _classThis;
1231
- var _classSuper = Metadata;
1232
- _classThis = /*#__PURE__*/function (_classSuper2) {
1233
- function _classThis() {
1234
- _classCallCheck(this, _classThis);
1235
- return _callSuper(this, _classThis, arguments);
1236
- }
1237
- _inherits(_classThis, _classSuper2);
1238
- return _createClass(_classThis);
1239
- }(_classSuper);
1240
- __setFunctionName(_classThis, "Qualifier");
1241
- (function () {
1242
- var _a;
1243
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
1244
- __esDecorate(null, _classDescriptor = {
1245
- value: _classThis
1246
- }, _classDecorators, {
1247
- kind: "class",
1248
- name: _classThis.name,
1249
- metadata: _metadata
1250
- }, null, _classExtraInitializers);
1251
- _classThis = _classDescriptor.value;
1252
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
1253
- enumerable: true,
1254
- configurable: true,
1255
- writable: true,
1256
- value: _metadata
1257
- });
1258
- __runInitializers(_classThis, _classExtraInitializers);
1259
- })();
1260
- return _classThis;
1261
- }();
1247
+ var _Qualifier;
1248
+ new (_Qualifier2 = (_Qualifier3 = /*#__PURE__*/function (_Metadata) {
1249
+ function Qualifier() {
1250
+ var _this;
1251
+ _classCallCheck(this, Qualifier);
1252
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1253
+ args[_key] = arguments[_key];
1254
+ }
1255
+ _this = _callSuper(this, Qualifier, [].concat(args));
1256
+ _defineProperty(_this, "value", void 0);
1257
+ return _this;
1258
+ }
1259
+ _inherits(Qualifier, _Metadata);
1260
+ return _createClass(Qualifier);
1261
+ }(Metadata), _applyDecs$c$q = _slicedToArray(_applyDecs2311(_Qualifier3, [target([Target.Type.Field])], [], 0, void 0, Metadata).c, 2), _Qualifier = _applyDecs$c$q[0], _initClass$q = _applyDecs$c$q[1], _Qualifier3), _Class$q = /*#__PURE__*/function (_identity2) {
1262
+ function _Class() {
1263
+ var _this2;
1264
+ _classCallCheck(this, _Class);
1265
+ _this2 = _callSuper(this, _Class, [_Qualifier]), _defineProperty(_assertThisInitialized(_this2), "$$id", "Qualifier"), _initClass$q();
1266
+ return _this2;
1267
+ }
1268
+ _inherits(_Class, _identity2);
1269
+ return _createClass(_Class);
1270
+ }(_identity), _defineProperty(_Class$q, _Qualifier2, void 0), _Class$q)();
1271
+ var Qualifier = _Qualifier;
1262
1272
 
1263
1273
  var qualifier = createDecoratorExp(Qualifier);
1264
1274
 
1275
+ var _Class$p, _Value3, _applyDecs$c$p;
1276
+ var _initClass$p, _Value2;
1265
1277
  /**
1266
1278
  * @public
1267
1279
  */
1268
- var Value = function () {
1269
- var _classDecorators = [id$2('Value'), target([Target.Type.Field])];
1270
- var _classDescriptor;
1271
- var _classExtraInitializers = [];
1272
- var _classThis;
1273
- var _classSuper = Metadata;
1274
- _classThis = /*#__PURE__*/function (_classSuper2) {
1275
- function _classThis() {
1276
- _classCallCheck(this, _classThis);
1277
- return _callSuper(this, _classThis, arguments);
1278
- }
1279
- _inherits(_classThis, _classSuper2);
1280
- return _createClass(_classThis);
1281
- }(_classSuper);
1282
- __setFunctionName(_classThis, "Value");
1283
- (function () {
1284
- var _a;
1285
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
1286
- __esDecorate(null, _classDescriptor = {
1287
- value: _classThis
1288
- }, _classDecorators, {
1289
- kind: "class",
1290
- name: _classThis.name,
1291
- metadata: _metadata
1292
- }, null, _classExtraInitializers);
1293
- _classThis = _classDescriptor.value;
1294
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
1295
- enumerable: true,
1296
- configurable: true,
1297
- writable: true,
1298
- value: _metadata
1299
- });
1300
- __runInitializers(_classThis, _classExtraInitializers);
1301
- })();
1302
- return _classThis;
1303
- }();
1280
+ var _Value;
1281
+ new (_Value2 = (_Value3 = /*#__PURE__*/function (_Metadata) {
1282
+ function Value() {
1283
+ var _this;
1284
+ _classCallCheck(this, Value);
1285
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1286
+ args[_key] = arguments[_key];
1287
+ }
1288
+ _this = _callSuper(this, Value, [].concat(args));
1289
+ _defineProperty(_this, "value", void 0);
1290
+ return _this;
1291
+ }
1292
+ _inherits(Value, _Metadata);
1293
+ return _createClass(Value);
1294
+ }(Metadata), _applyDecs$c$p = _slicedToArray(_applyDecs2311(_Value3, [target([Target.Type.Field])], [], 0, void 0, Metadata).c, 2), _Value = _applyDecs$c$p[0], _initClass$p = _applyDecs$c$p[1], _Value3), _Class$p = /*#__PURE__*/function (_identity2) {
1295
+ function _Class() {
1296
+ var _this2;
1297
+ _classCallCheck(this, _Class);
1298
+ _this2 = _callSuper(this, _Class, [_Value]), _defineProperty(_assertThisInitialized(_this2), "$$id", "Value"), _initClass$p();
1299
+ return _this2;
1300
+ }
1301
+ _inherits(_Class, _identity2);
1302
+ return _createClass(_Class);
1303
+ }(_identity), _defineProperty(_Class$p, _Value2, void 0), _Class$p)();
1304
+ var Value = _Value;
1304
1305
 
1305
1306
  var value = createDecoratorExp(Value, {
1306
1307
  componentPostConstruct: function componentPostConstruct(metadata, application, field) {
@@ -1312,498 +1313,68 @@ var value = createDecoratorExp(Value, {
1312
1313
  }
1313
1314
  });
1314
1315
 
1315
- function newIocComponentDefinition(id, cls, isSingleton, instantiateType) {
1316
- return {
1317
- id: id,
1318
- cls: cls,
1319
- isSingleton: isSingleton,
1320
- instantiateType: instantiateType
1321
- };
1322
- }
1323
- var idDefinitionMap = new Map();
1324
- var clsDefinitionMap = new Map();
1325
- function addDefinition(cls, isSingleton, methodInstantiateOpts) {
1326
- var existClsDef = clsDefinitionMap.get(cls);
1327
- if (existClsDef) {
1328
- throw new Error("\u5B58\u5728\u540C\u540D\u7684\u7EC4\u4EF6: [".concat(existClsDef.cls.name, "] - [").concat(cls.name, "]"));
1329
- }
1330
- var id = uppercaseFirstLetter(cls.name);
1331
- if (typeof id !== 'string' || !id.trim()) {
1332
- throw new Error("\u751F\u6210\u7EC4\u4EF6id\u5931\u8D25: [".concat(cls.name, "]"));
1333
- }
1334
- var existIdDef = idDefinitionMap.get(id);
1335
- if (existIdDef) {
1336
- throw new Error("\u5B58\u5728id\u7684\u7EC4\u4EF6: [".concat(existIdDef.cls.name, "] - [").concat(cls.name, "]"));
1337
- }
1338
- var componentDefinition = newIocComponentDefinition(id, cls, isSingleton, methodInstantiateOpts ? 'method' : 'new');
1339
- if (methodInstantiateOpts) {
1340
- componentDefinition.methodInstantiateOpts = methodInstantiateOpts;
1341
- }
1342
- idDefinitionMap.set(id, componentDefinition);
1343
- clsDefinitionMap.set(cls, componentDefinition);
1344
- }
1345
- /**
1346
- * 获取真正会实例化的类定义
1347
- * @param ClsOrId 想要实例化的类或类id
1348
- * @param qualifier 如果存在多个后端类,需要通过qualifier指定具体的类id
1349
- * @returns 真正会实例化的类定义
1350
- */
1351
- function getInstantiateDefinition(ClsOrId, qualifier) {
1352
- var definition = getDefinition(ClsOrId);
1353
- if (!definition) {
1354
- var diagnose = createDiagnose(DiagnoseCode.CO10011, typeof ClsOrId === 'string' ? ClsOrId : ClsOrId.name);
1355
- throw new Error(stringifyDiagnose(diagnose));
1356
- }
1357
- var descendantList = Array.from(clsDefinitionMap.keys()).filter(function (i) {
1358
- return isDescendantOf(i, definition.cls);
1359
- });
1360
- if (descendantList.length === 0) {
1361
- // 没有子组件直接返回本身
1362
- return definition;
1363
- } else if (descendantList.length === 1) {
1364
- // 有一个子组件
1365
- return clsDefinitionMap.get(descendantList[0]);
1366
- } else {
1367
- // 多个子组件
1368
- if (qualifier) {
1369
- var _iterator = _createForOfIteratorHelper(descendantList),
1370
- _step;
1371
- try {
1372
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
1373
- var child = _step.value;
1374
- var def = clsDefinitionMap.get(child);
1375
- if (def.id === qualifier) {
1376
- return def;
1377
- }
1378
- }
1379
- } catch (err) {
1380
- _iterator.e(err);
1381
- } finally {
1382
- _iterator.f();
1383
- }
1384
- }
1385
- if (qualifier) {
1386
- var _diagnose = createDiagnose(DiagnoseCode.CO10010, definition.id, descendantList.map(function (i) {
1387
- return i.name;
1388
- }), qualifier);
1389
- throw new Error(stringifyDiagnose(_diagnose));
1390
- } else {
1391
- var _diagnose2 = createDiagnose(DiagnoseCode.CO10009, definition.id, descendantList.map(function (i) {
1392
- return i.name;
1393
- }));
1394
- throw new Error(stringifyDiagnose(_diagnose2));
1395
- }
1396
- }
1397
- }
1398
- function getDefinition(ClsOrId) {
1399
- if (typeof ClsOrId === 'string') {
1400
- return idDefinitionMap.get(ClsOrId);
1401
- } else {
1402
- return clsDefinitionMap.get(ClsOrId);
1403
- }
1404
- }
1405
- function clear$2() {
1406
- idDefinitionMap.clear();
1407
- clsDefinitionMap.clear();
1408
- }
1409
-
1410
- // 单例构造函数和单例的映射关系
1411
- var singletonInstances = new Map();
1412
- function createComponent(application, definition, constructorArgs) {
1413
- var cls = definition.cls,
1414
- instantiateType = definition.instantiateType;
1415
- var component;
1416
- if (instantiateType === 'new') {
1417
- component = _construct(cls, _toConsumableArray(constructorArgs));
1418
- } else {
1419
- var _definition$methodIns = definition.methodInstantiateOpts,
1420
- configurationCls = _definition$methodIns.configurationCls,
1421
- method = _definition$methodIns.method;
1422
- var configuration = new configurationCls();
1423
- component = configuration[method]();
1424
- }
1425
- var metadatas = application.metadataRepository.getMetadataByClass(cls);
1426
- if (metadatas) {
1427
- var classMetadata = metadatas.classMetadata,
1428
- methodMetadata = metadatas.methodMetadata,
1429
- fieldMetadata = metadatas.fieldMetadata;
1430
- var _iterator = _createForOfIteratorHelper(classMetadata),
1316
+ var MetadataRepository = /*#__PURE__*/function () {
1317
+ function MetadataRepository(decoratorMap) {
1318
+ _classCallCheck(this, MetadataRepository);
1319
+ _defineProperty(this, "metaMetadataMap", new Map());
1320
+ _defineProperty(this, "bizMetadataMap", new Map());
1321
+ var _iterator = _createForOfIteratorHelper(decoratorMap.entries()),
1431
1322
  _step;
1432
1323
  try {
1433
1324
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
1434
- var meta = _step.value;
1435
- var option = getCreateDecoratorOption(meta.constructor);
1436
- if (option) {
1437
- option.componentPostConstruct.call(component, meta, application);
1438
- }
1439
- }
1440
- } catch (err) {
1441
- _iterator.e(err);
1442
- } finally {
1443
- _iterator.f();
1444
- }
1445
- var _iterator2 = _createForOfIteratorHelper(fieldMetadata.entries()),
1446
- _step2;
1447
- try {
1448
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
1449
- var _step2$value = _slicedToArray(_step2.value, 2),
1450
- field = _step2$value[0],
1451
- metaList = _step2$value[1];
1452
- var _iterator4 = _createForOfIteratorHelper(metaList),
1453
- _step4;
1454
- try {
1455
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
1456
- var _meta = _step4.value;
1457
- var _option = getCreateDecoratorOption(_meta.constructor);
1458
- if (_option) {
1459
- _option.componentPostConstruct.call(component, _meta, application, field);
1460
- }
1461
- }
1462
- } catch (err) {
1463
- _iterator4.e(err);
1464
- } finally {
1465
- _iterator4.f();
1466
- }
1467
- }
1468
- } catch (err) {
1469
- _iterator2.e(err);
1470
- } finally {
1471
- _iterator2.f();
1472
- }
1473
- var _iterator3 = _createForOfIteratorHelper(methodMetadata.entries()),
1474
- _step3;
1475
- try {
1476
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
1477
- var _step3$value = _slicedToArray(_step3.value, 2),
1478
- _method = _step3$value[0],
1479
- _metaList = _step3$value[1];
1480
- var _iterator5 = _createForOfIteratorHelper(_metaList),
1481
- _step5;
1325
+ var entity = _step.value;
1326
+ var beDecoratedCls = entity[0];
1327
+ var list = entity[1];
1328
+ var _iterator2 = _createForOfIteratorHelper(list),
1329
+ _step2;
1482
1330
  try {
1483
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
1484
- var _meta2 = _step5.value;
1485
- var _option2 = getCreateDecoratorOption(_meta2.constructor);
1486
- if (_option2) {
1487
- _option2.componentPostConstruct.call(component, _meta2, application, _method);
1331
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
1332
+ var p = _step2.value;
1333
+ var metadataKind = p.metadataKind;
1334
+ var metadataClass = p.metadataClass;
1335
+ var metadataParam = p.metadataParam;
1336
+ var field = p.field;
1337
+ switch (metadataKind) {
1338
+ case KindClass:
1339
+ this.addClassKindMetadata(beDecoratedCls, metadataClass, metadataParam);
1340
+ break;
1341
+ case KindField:
1342
+ this.addFieldKindMetadata(beDecoratedCls, field, metadataClass, metadataParam);
1343
+ break;
1344
+ case KindMethod:
1345
+ this.addMethodKindMetadata(beDecoratedCls, field, metadataClass, metadataParam);
1346
+ break;
1488
1347
  }
1489
1348
  }
1490
1349
  } catch (err) {
1491
- _iterator5.e(err);
1350
+ _iterator2.e(err);
1492
1351
  } finally {
1493
- _iterator5.f();
1352
+ _iterator2.f();
1494
1353
  }
1495
1354
  }
1496
1355
  } catch (err) {
1497
- _iterator3.e(err);
1356
+ _iterator.e(err);
1498
1357
  } finally {
1499
- _iterator3.f();
1500
- }
1501
- }
1502
- return component;
1503
- }
1504
- function getComponents(application, userOption) {
1505
- var _a, _b;
1506
- var targetClsInstanceMap = new Map(); // 想要实例化的类和对应的实例
1507
- var instanceInstantiateClsMap = new Map(); // 新建实例和对应的实例化类
1508
- var newSingletonInstances = new Map(); // 新增的单例,最后要合并到singletonInstances
1509
- var instantiatingStage = new Set(); // 实例化中
1510
- var assignningStage = new Set(); // field赋值中
1511
- var finishedStage = new Set(); // 已完成
1512
- // 已经有的单例填充到finishedStage和instances
1513
- var _iterator6 = _createForOfIteratorHelper(singletonInstances.entries()),
1514
- _step6;
1515
- try {
1516
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
1517
- var _step6$value = _slicedToArray(_step6.value, 2),
1518
- _cls = _step6$value[0],
1519
- _instance2 = _step6$value[1];
1520
- targetClsInstanceMap.set(_cls, _instance2);
1358
+ _iterator.f();
1521
1359
  }
1522
- // 完整的初始化一个组件
1523
- } catch (err) {
1524
- _iterator6.e(err);
1525
- } finally {
1526
- _iterator6.f();
1527
1360
  }
1528
- function instantiateComponent(opt) {
1529
- var classOrId = opt.classOrId;
1530
- // 要实例化的类定义
1531
- var targetDefinition = getDefinition(classOrId);
1532
- if (!targetDefinition) {
1533
- var diagnose = createDiagnose(DiagnoseCode.CO10011, typeof classOrId === 'string' ? classOrId : classOrId.name);
1534
- throw new Error(stringifyDiagnose(diagnose));
1535
- }
1536
- var qualifier = opt.qualifier;
1537
- if (!qualifier) {
1538
- // 如果没有指定,尝试从配置中获取
1539
- qualifier = application.propertiesConfig.getValue("".concat(targetDefinition.id, ".qualifier"));
1540
- }
1541
- // 真正实例化的类定义
1542
- var instantiateDefinition = getInstantiateDefinition(classOrId, qualifier);
1543
- if (instantiateDefinition.isSingleton) {
1544
- if (singletonInstances.has(instantiateDefinition.cls)) {
1545
- return singletonInstances.get(instantiateDefinition.cls);
1546
- } else if (newSingletonInstances.has(instantiateDefinition.cls)) {
1547
- return newSingletonInstances.get(instantiateDefinition.cls);
1548
- }
1549
- }
1550
- if (instantiatingStage.has(targetDefinition.cls)) {
1551
- // 理论上不可能走到这里
1552
- throw new Error("\u5FAA\u73AF\u4F9D\u8D56: ".concat(targetDefinition.cls.name));
1553
- }
1554
- // 在实例化中或者已实例化,返回实例
1555
- if (assignningStage.has(targetDefinition.cls) || finishedStage.has(targetDefinition.cls)) {
1556
- return targetClsInstanceMap.get(targetDefinition.cls);
1557
- }
1558
- instantiatingStage.add(targetDefinition.cls);
1559
- var constructorArgs = [];
1560
- var constructorParams = application.metadataRepository.listClassKindMetadata(instantiateDefinition.cls, ConstructorParam);
1561
- if (constructorParams.length > 0) {
1562
- // 因为元数据不能重复,所以只有一个
1563
- var constructorParamsParams = constructorParams[0].value;
1564
- var _iterator7 = _createForOfIteratorHelper(constructorParamsParams),
1565
- _step7;
1566
- try {
1567
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
1568
- var dependency = _step7.value;
1569
- if (dependency === undefined) {
1570
- constructorArgs.push(undefined);
1571
- } else {
1572
- var depInstance = instantiateComponent({
1573
- classOrId: dependency
1574
- });
1575
- // 确保依赖已完全注入
1576
- if (!finishedStage.has(dependency) && !singletonInstances.has(dependency)) {
1577
- var _diagnose = createDiagnose(DiagnoseCode.CO10013, targetDefinition.cls.name, dependency.name);
1578
- throw new Error(stringifyDiagnose(_diagnose));
1579
- }
1580
- constructorArgs.push(depInstance);
1581
- }
1582
- }
1583
- } catch (err) {
1584
- _iterator7.e(err);
1585
- } finally {
1586
- _iterator7.f();
1587
- }
1361
+ return _createClass(MetadataRepository, [{
1362
+ key: "getAll",
1363
+ value: function getAll() {
1364
+ return [this.metaMetadataMap, this.bizMetadataMap];
1588
1365
  }
1589
- // 2. 实例化,同时执行componentPostConstruct
1590
- var instance = createComponent(application, instantiateDefinition, constructorArgs);
1591
- if (instantiateDefinition.isSingleton) {
1592
- newSingletonInstances.set(instantiateDefinition.cls, instance);
1366
+ }, {
1367
+ key: "destructor",
1368
+ value: function destructor() {
1369
+ this.metaMetadataMap.clear();
1370
+ this.bizMetadataMap.clear();
1593
1371
  }
1594
- targetClsInstanceMap.set(targetDefinition.cls, instance);
1595
- instanceInstantiateClsMap.set(instance, instantiateDefinition.cls);
1596
- instantiatingStage["delete"](targetDefinition.cls);
1597
- assignningStage.add(targetDefinition.cls);
1598
- // 3. 递归实例化field注入
1599
- var autowiredFields = application.metadataRepository.listFieldByMetadataCls(instantiateDefinition.cls, Autowired);
1600
- var _iterator8 = _createForOfIteratorHelper(autowiredFields),
1601
- _step8;
1602
- try {
1603
- for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
1604
- var field = _step8.value;
1605
- var autowiredMetadatas = application.metadataRepository.listFieldKindMetadata(instantiateDefinition.cls, field, Autowired);
1606
- if (autowiredMetadatas.length > 0) {
1607
- var autowiredCls = autowiredMetadatas[0].value;
1608
- if (autowiredCls === undefined) {
1609
- instance[field] = undefined;
1610
- } else if (autowiredCls === instantiateDefinition.cls) {
1611
- // 检查自依赖:不能注入自己
1612
- // TODO: 如果autowiredCls是instantiateDefinition.cls的祖先类或者子孙类怎么办?
1613
- var _diagnose2 = createDiagnose(DiagnoseCode.CO10012, instantiateDefinition.cls.name, field);
1614
- printDiagnose(_diagnose2);
1615
- instance[field] = undefined;
1616
- } else {
1617
- var qualifierMetadatas = application.metadataRepository.listFieldKindMetadata(instantiateDefinition.cls, field, Qualifier);
1618
- var _qualifier = void 0;
1619
- if (qualifierMetadatas.length > 0) {
1620
- _qualifier = qualifierMetadatas[0].value;
1621
- }
1622
- var autowiredInstance = instantiateComponent({
1623
- classOrId: autowiredCls,
1624
- qualifier: _qualifier
1625
- });
1626
- instance[field] = autowiredInstance;
1627
- }
1628
- }
1629
- }
1630
- // 4. 标记为完全注入
1631
- } catch (err) {
1632
- _iterator8.e(err);
1633
- } finally {
1634
- _iterator8.f();
1635
- }
1636
- assignningStage["delete"](targetDefinition.cls);
1637
- finishedStage.add(targetDefinition.cls);
1638
- return instance;
1639
- }
1640
- // TODO: 如果初始化多个,有没有先后顺序问题?
1641
- var instance = instantiateComponent(userOption);
1642
- // merge newSingletonInstances to singletonInstances
1643
- if (newSingletonInstances.size > 0) {
1644
- var _iterator9 = _createForOfIteratorHelper(newSingletonInstances.entries()),
1645
- _step9;
1646
- try {
1647
- for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
1648
- var _step9$value = _slicedToArray(_step9.value, 2),
1649
- cls = _step9$value[0],
1650
- _instance = _step9$value[1];
1651
- singletonInstances.set(cls, _instance);
1652
- // 现在默认子类的singleton和父类都是保持一致的。TODO: 如果子类的singleton不是单例了,应该如何处理
1653
- }
1654
- } catch (err) {
1655
- _iterator9.e(err);
1656
- } finally {
1657
- _iterator9.f();
1658
- }
1659
- }
1660
- // 5. 所有新增的单例执行init方法
1661
- var _iterator0 = _createForOfIteratorHelper(finishedStage.keys()),
1662
- _step0;
1663
- try {
1664
- for (_iterator0.s(); !(_step0 = _iterator0.n()).done;) {
1665
- var _cls2 = _step0.value;
1666
- // 这里应该是根据instance来判断是否已经存在的
1667
- var _instance3 = targetClsInstanceMap.get(_cls2);
1668
- if (typeof _instance3['init'] === 'function') {
1669
- (_a = _instance3['init']) === null || _a === void 0 ? void 0 : _a.call(_instance3, application);
1670
- }
1671
- }
1672
- // 执行start方法
1673
- } catch (err) {
1674
- _iterator0.e(err);
1675
- } finally {
1676
- _iterator0.f();
1677
- }
1678
- var _iterator1 = _createForOfIteratorHelper(finishedStage.keys()),
1679
- _step1;
1680
- try {
1681
- for (_iterator1.s(); !(_step1 = _iterator1.n()).done;) {
1682
- var _cls3 = _step1.value;
1683
- var _instance4 = targetClsInstanceMap.get(_cls3);
1684
- if (typeof _instance4['start'] === 'function') {
1685
- (_b = _instance4['start']) === null || _b === void 0 ? void 0 : _b.call(_instance4, application);
1686
- }
1687
- }
1688
- } catch (err) {
1689
- _iterator1.e(err);
1690
- } finally {
1691
- _iterator1.f();
1692
- }
1693
- return instance;
1694
- }
1695
- function getViewComponent(application, viewClass, props) {
1696
- var targetDefinition = getDefinition(viewClass);
1697
- if (!targetDefinition) {
1698
- var diagnose = createDiagnose(DiagnoseCode.CO10011, typeof viewClass === 'string' ? viewClass : viewClass.name);
1699
- throw new Error(stringifyDiagnose(diagnose));
1700
- }
1701
- // 视图组件目前简单的认为全是prototype,且不支持实例化子组件
1702
- var instance = createComponent(application, targetDefinition, [props]);
1703
- var autowiredFields = application.metadataRepository.listFieldByMetadataCls(targetDefinition.cls, Autowired);
1704
- var _iterator10 = _createForOfIteratorHelper(autowiredFields),
1705
- _step10;
1706
- try {
1707
- for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
1708
- var field = _step10.value;
1709
- var autowiredMetadatas = application.metadataRepository.listFieldKindMetadata(targetDefinition.cls, field, Autowired);
1710
- if (autowiredMetadatas.length > 0) {
1711
- var autowiredCls = autowiredMetadatas[0].value;
1712
- if (autowiredCls === undefined) {
1713
- instance[field] = undefined;
1714
- } else if (autowiredCls === targetDefinition.cls) {
1715
- // 检查自依赖:不能注入自己
1716
- // TODO: 如果autowiredCls是instantiateDefinition.cls的祖先类或者子孙类怎么办?
1717
- var _diagnose3 = createDiagnose(DiagnoseCode.CO10012, targetDefinition.cls.name, field);
1718
- printDiagnose(_diagnose3);
1719
- instance[field] = undefined;
1720
- } else {
1721
- var qualifierMetadatas = application.metadataRepository.listFieldKindMetadata(targetDefinition.cls, field, Qualifier);
1722
- var qualifier = void 0;
1723
- if (qualifierMetadatas.length > 0) {
1724
- qualifier = qualifierMetadatas[0].value;
1725
- }
1726
- var autowiredInstance = getComponents(application, {
1727
- classOrId: autowiredCls,
1728
- qualifier: qualifier
1729
- });
1730
- instance[field] = autowiredInstance;
1731
- }
1732
- }
1733
- }
1734
- } catch (err) {
1735
- _iterator10.e(err);
1736
- } finally {
1737
- _iterator10.f();
1738
- }
1739
- return instance;
1740
- }
1741
- function clear$1() {
1742
- singletonInstances.clear();
1743
- }
1744
-
1745
- var MetadataRepository = /*#__PURE__*/function () {
1746
- function MetadataRepository(decoratorMap) {
1747
- _classCallCheck(this, MetadataRepository);
1748
- this.metaMetadataMap = new Map();
1749
- this.bizMetadataMap = new Map();
1750
- var _iterator = _createForOfIteratorHelper(decoratorMap.entries()),
1751
- _step;
1752
- try {
1753
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
1754
- var entity = _step.value;
1755
- var beDecoratedCls = entity[0];
1756
- var list = entity[1];
1757
- var _iterator2 = _createForOfIteratorHelper(list),
1758
- _step2;
1759
- try {
1760
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
1761
- var p = _step2.value;
1762
- var metadataKind = p.metadataKind;
1763
- var metadataClass = p.metadataClass;
1764
- var metadataParam = p.metadataParam;
1765
- var field = p.field;
1766
- switch (metadataKind) {
1767
- case KindClass:
1768
- this.addClassKindMetadata(beDecoratedCls, metadataClass, metadataParam);
1769
- break;
1770
- case KindField:
1771
- this.addFieldKindMetadata(beDecoratedCls, field, metadataClass, metadataParam);
1772
- break;
1773
- case KindMethod:
1774
- this.addMethodKindMetadata(beDecoratedCls, field, metadataClass, metadataParam);
1775
- break;
1776
- }
1777
- }
1778
- } catch (err) {
1779
- _iterator2.e(err);
1780
- } finally {
1781
- _iterator2.f();
1782
- }
1783
- }
1784
- } catch (err) {
1785
- _iterator.e(err);
1786
- } finally {
1787
- _iterator.f();
1788
- }
1789
- }
1790
- return _createClass(MetadataRepository, [{
1791
- key: "getAll",
1792
- value: function getAll() {
1793
- return [this.metaMetadataMap, this.bizMetadataMap];
1794
- }
1795
- }, {
1796
- key: "destructor",
1797
- value: function destructor() {
1798
- this.metaMetadataMap.clear();
1799
- this.bizMetadataMap.clear();
1800
- }
1801
- // 返回指定类的所有元数据
1802
- }, {
1803
- key: "getMetadataByClass",
1804
- value: function getMetadataByClass(Cls) {
1805
- var value = Object.getPrototypeOf(Cls) === Metadata ? this.metaMetadataMap.get(Cls) : this.bizMetadataMap.get(Cls);
1806
- return value;
1372
+ // 返回指定类的所有元数据
1373
+ }, {
1374
+ key: "getMetadataByClass",
1375
+ value: function getMetadataByClass(Cls) {
1376
+ var value = Object.getPrototypeOf(Cls) === Metadata ? this.metaMetadataMap.get(Cls) : this.bizMetadataMap.get(Cls);
1377
+ return value;
1807
1378
  }
1808
1379
  }, {
1809
1380
  key: "addToMap",
@@ -1848,12 +1419,6 @@ var MetadataRepository = /*#__PURE__*/function () {
1848
1419
  fieldMetas = [];
1849
1420
  fieldMetadata.set(fieldName, fieldMetas);
1850
1421
  }
1851
- // if (fieldMetas.find((i) => i instanceof MetadataCls)) {
1852
- // if (false) {
1853
- // // TODO: 挪到validate中
1854
- // throw new Error('相同的Field装饰器装饰了2次!');
1855
- // }
1856
- // }
1857
1422
  var metadata = instantiateMetadata(MetadataCls, args);
1858
1423
  fieldMetas.push(metadata);
1859
1424
  }
@@ -1871,12 +1436,6 @@ var MetadataRepository = /*#__PURE__*/function () {
1871
1436
  methodMetas = [];
1872
1437
  methodMetadata.set(fieldName, methodMetas);
1873
1438
  }
1874
- // if (methodMetas.find((i) => i instanceof MetadataCls)) {
1875
- // if (false) {
1876
- // // TODO: 挪到validate中
1877
- // throw new Error('相同的Field装饰器装饰了2次!');
1878
- // }
1879
- // }
1880
1439
  var metadata = instantiateMetadata(MetadataCls, args);
1881
1440
  methodMetas.push(metadata);
1882
1441
  }
@@ -1931,14 +1490,19 @@ var MetadataRepository = /*#__PURE__*/function () {
1931
1490
  });
1932
1491
  }
1933
1492
  /**
1934
- * 在类的所有类类型的元数据中递归查找某个元数据类实例,找到就直接返回
1935
- * TODO: 因为现在组件装饰器的层数没有限制了,那么upward这个参数是否还有必要存在
1493
+ * listClassKindMetadata的递归版本,在类装饰器的元数据类递归,但只返回一个
1494
+ * @param beDecoratedCls 被查找的类
1495
+ * @param TargetCls 想要匹配的元数据类定义
1496
+ * @param levels 递归层数,默认无限制,就是查找所有的装饰器的元数据类,也可以使用数字指定,0表示只查当前装饰器,1表示再查当前装饰器的元数据的装饰器,依次类推
1936
1497
  */
1937
1498
  }, {
1938
1499
  key: "findClassKindMetadataRecursively",
1939
1500
  value: function findClassKindMetadataRecursively(beDecoratedCls, TargetCls) {
1940
- var upward = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
1941
- if (upward < 0) {
1501
+ var levels = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Infinity;
1502
+ if (!TargetCls || !this.metaMetadataMap.has(TargetCls)) {
1503
+ throw new Error(stringifyDiagnose(createDiagnose(DiagnoseCode.CO10025, TargetCls !== null && TargetCls !== void 0 && TargetCls.name ? TargetCls.name : TargetCls)));
1504
+ }
1505
+ if (levels < 0) {
1942
1506
  return null;
1943
1507
  }
1944
1508
  var classMetadataList = this.listClassKindMetadata(beDecoratedCls);
@@ -1946,7 +1510,7 @@ var MetadataRepository = /*#__PURE__*/function () {
1946
1510
  return null;
1947
1511
  }
1948
1512
  var instance = classMetadataList.find(function (i) {
1949
- return i instanceof TargetCls;
1513
+ return i.constructor === TargetCls;
1950
1514
  });
1951
1515
  if (instance) {
1952
1516
  return instance;
@@ -1956,7 +1520,7 @@ var MetadataRepository = /*#__PURE__*/function () {
1956
1520
  try {
1957
1521
  for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
1958
1522
  var metadata = _step3.value;
1959
- var find = this.findClassKindMetadataRecursively(metadata.constructor, TargetCls, upward - 1);
1523
+ var find = this.findClassKindMetadataRecursively(metadata.constructor, TargetCls, levels - 1);
1960
1524
  if (find) {
1961
1525
  return find;
1962
1526
  }
@@ -2066,9 +1630,14 @@ var MetadataRepository = /*#__PURE__*/function () {
2066
1630
  var ComponentMetadataClass = /*#__PURE__*/function () {
2067
1631
  function ComponentMetadataClass() {
2068
1632
  _classCallCheck(this, ComponentMetadataClass);
2069
- this.isComponent = new Map();
1633
+ _defineProperty(this, "isComponent", new Map());
2070
1634
  }
2071
1635
  return _createClass(ComponentMetadataClass, [{
1636
+ key: "destructor",
1637
+ value: function destructor() {
1638
+ this.isComponent.clear();
1639
+ }
1640
+ }, {
2072
1641
  key: "isComponentMetadata",
2073
1642
  value: function isComponentMetadata(MetadataClass) {
2074
1643
  return this.isComponent.has(MetadataClass) ? this.isComponent.get(MetadataClass) : false;
@@ -2537,8 +2106,10 @@ function validateNoNeedTargetDecorator(target) {
2537
2106
  return undefined;
2538
2107
  }
2539
2108
  }
2540
- function validateDuplicatedDecorator(target) {
2109
+ function validateDuplicatedDecorator(beDecoratedClass) {
2541
2110
  var metadatas = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
2111
+ var fieldName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
2112
+ var methodName = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
2542
2113
  var map = new Map();
2543
2114
  for (var idx = 0; idx < metadatas.length; idx++) {
2544
2115
  var metadata = metadatas[idx];
@@ -2559,7 +2130,13 @@ function validateDuplicatedDecorator(target) {
2559
2130
  _MetadataClass = _step$value[0],
2560
2131
  dupIdxs = _step$value[1];
2561
2132
  if (dupIdxs.length > 1) {
2562
- diagnoseList.push(createDiagnose(DiagnoseCode.CO10003, target.name, className2DecoratorName(_MetadataClass.name)));
2133
+ if (fieldName) {
2134
+ diagnoseList.push(createDiagnose(DiagnoseCode.CO10026, beDecoratedClass.name, fieldName, className2DecoratorName(_MetadataClass.name)));
2135
+ } else if (methodName) {
2136
+ diagnoseList.push(createDiagnose(DiagnoseCode.CO10027, beDecoratedClass.name, methodName, className2DecoratorName(_MetadataClass.name)));
2137
+ } else {
2138
+ diagnoseList.push(createDiagnose(DiagnoseCode.CO10003, beDecoratedClass.name, className2DecoratorName(_MetadataClass.name)));
2139
+ }
2563
2140
  toDelIdxs.push.apply(toDelIdxs, _toConsumableArray(dupIdxs));
2564
2141
  }
2565
2142
  }
@@ -2581,14 +2158,14 @@ function hasComponentDecorator() {
2581
2158
  }
2582
2159
  // 是否是Component装饰器或component的一级复合装饰器或component的二级复合装饰器
2583
2160
  function isComponentDecorator(metadata, metaMetadataMap) {
2584
- var _a, _b;
2161
+ var _metaMetadataMap$get;
2585
2162
  // 是否是@component
2586
2163
  if (metadata instanceof Component) {
2587
2164
  return true;
2588
2165
  }
2589
2166
  var MetadataClass = metadata.constructor;
2590
2167
  // 在一级复合中查找
2591
- var classMetadatas = (_a = metaMetadataMap.get(MetadataClass)) === null || _a === void 0 ? void 0 : _a.classMetadata;
2168
+ var classMetadatas = (_metaMetadataMap$get = metaMetadataMap.get(MetadataClass)) === null || _metaMetadataMap$get === void 0 ? void 0 : _metaMetadataMap$get.classMetadata;
2592
2169
  if (!classMetadatas || classMetadatas.length === 0) {
2593
2170
  return false;
2594
2171
  }
@@ -2601,9 +2178,10 @@ function isComponentDecorator(metadata, metaMetadataMap) {
2601
2178
  _step2;
2602
2179
  try {
2603
2180
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
2181
+ var _metaMetadataMap$get2;
2604
2182
  var classMetadata = _step2.value;
2605
2183
  var parentClass = classMetadata.constructor;
2606
- var parentClassMetadatas = (_b = metaMetadataMap.get(parentClass)) === null || _b === void 0 ? void 0 : _b.classMetadata;
2184
+ var parentClassMetadatas = (_metaMetadataMap$get2 = metaMetadataMap.get(parentClass)) === null || _metaMetadataMap$get2 === void 0 ? void 0 : _metaMetadataMap$get2.classMetadata;
2607
2185
  if (hasComponentDecorator(parentClassMetadatas)) {
2608
2186
  return true;
2609
2187
  }
@@ -2623,14 +2201,14 @@ function hasConfigurationDecorator() {
2623
2201
  }
2624
2202
  // 是否是Configuration装饰器或configuration的一级复合装饰器
2625
2203
  function isConfigurationDecorator(metadata, metaMetadataMap) {
2626
- var _a;
2204
+ var _metaMetadataMap$get3;
2627
2205
  // 是否是@configuration
2628
2206
  if (metadata instanceof Configuration) {
2629
2207
  return true;
2630
2208
  }
2631
2209
  var MetadataClass = metadata.constructor;
2632
2210
  // 在一级复合中查找
2633
- var classMetadatas = (_a = metaMetadataMap.get(MetadataClass)) === null || _a === void 0 ? void 0 : _a.classMetadata;
2211
+ var classMetadatas = (_metaMetadataMap$get3 = metaMetadataMap.get(MetadataClass)) === null || _metaMetadataMap$get3 === void 0 ? void 0 : _metaMetadataMap$get3.classMetadata;
2634
2212
  if (!classMetadatas || classMetadatas.length === 0) {
2635
2213
  return false;
2636
2214
  }
@@ -2659,15 +2237,15 @@ function validateMoreThenOneComponentDecorator(target, metadatas, metaMetadataMa
2659
2237
  return undefined;
2660
2238
  }
2661
2239
  function validateDecoratorTarget(beDecorated, metadatas, metaMetadataMap) {
2662
- var _a;
2663
2240
  var diagnoseList = [];
2664
2241
  var targetDecoratorIdxs = [];
2665
2242
  var cls = beDecorated.cls,
2666
2243
  target = beDecorated.target,
2667
2244
  field = beDecorated.field;
2668
2245
  for (var idx = 0; idx < metadatas.length; idx++) {
2246
+ var _metaMetadataMap$get4;
2669
2247
  var metadata = metadatas[idx];
2670
- var classMetadatas = (_a = metaMetadataMap.get(metadata.constructor)) === null || _a === void 0 ? void 0 : _a.classMetadata;
2248
+ var classMetadatas = (_metaMetadataMap$get4 = metaMetadataMap.get(metadata.constructor)) === null || _metaMetadataMap$get4 === void 0 ? void 0 : _metaMetadataMap$get4.classMetadata;
2671
2249
  var targetMetadata = classMetadatas === null || classMetadatas === void 0 ? void 0 : classMetadatas.find(function (metadata) {
2672
2250
  return metadata instanceof Target;
2673
2251
  });
@@ -2796,20 +2374,6 @@ function validate(metadataList, componentMetadataClass) {
2796
2374
  }
2797
2375
  }
2798
2376
  // 业务类校验是否包含重复装饰器
2799
- // for (const [metadataClass, metadataList] of bizMetadataMap.entries()) {
2800
- // const diagnose = validateDuplicatedDecorator(metadataClass, metadataList.classMetadata);
2801
- // if (diagnose.length) {
2802
- // let invalidMetadata: Diagnose[]
2803
- // if (diagnoseMap.has(metadataClass)) {
2804
- // invalidMetadata = diagnoseMap.get(metadataClass)!;
2805
- // } else {
2806
- // invalidMetadata = []
2807
- // diagnoseMap.set(metadataClass, invalidMetadata);
2808
- // }
2809
- // invalidMetadata.push(...diagnose);
2810
- // }
2811
- // }
2812
- // 业务类不需要添加@target装饰器
2813
2377
  } catch (err) {
2814
2378
  _iterator6.e(err);
2815
2379
  } finally {
@@ -2822,12 +2386,46 @@ function validate(metadataList, componentMetadataClass) {
2822
2386
  var _step7$value = _slicedToArray(_step7.value, 2),
2823
2387
  _metadataClass4 = _step7$value[0],
2824
2388
  _metadataList3 = _step7$value[1];
2825
- var _diagnose3 = validateNoNeedTargetDecorator(_metadataClass4, _metadataList3.classMetadata);
2826
- if (_diagnose3) {
2827
- diagnoseList.push(_diagnose3);
2389
+ var _diagnose3 = validateDuplicatedDecorator(_metadataClass4, _metadataList3.classMetadata);
2390
+ if (_diagnose3.length) {
2391
+ diagnoseList.push.apply(diagnoseList, _toConsumableArray(_diagnose3));
2392
+ }
2393
+ var _iterator10 = _createForOfIteratorHelper(_metadataList3.fieldMetadata.entries()),
2394
+ _step10;
2395
+ try {
2396
+ for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
2397
+ var _step10$value = _slicedToArray(_step10.value, 2),
2398
+ field = _step10$value[0],
2399
+ metadatas = _step10$value[1];
2400
+ var _diagnose4 = validateDuplicatedDecorator(_metadataClass4, metadatas, field);
2401
+ if (_diagnose4.length) {
2402
+ diagnoseList.push.apply(diagnoseList, _toConsumableArray(_diagnose4));
2403
+ }
2404
+ }
2405
+ } catch (err) {
2406
+ _iterator10.e(err);
2407
+ } finally {
2408
+ _iterator10.f();
2409
+ }
2410
+ var _iterator11 = _createForOfIteratorHelper(_metadataList3.methodMetadata.entries()),
2411
+ _step11;
2412
+ try {
2413
+ for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
2414
+ var _step11$value = _slicedToArray(_step11.value, 2),
2415
+ method = _step11$value[0],
2416
+ _metadatas = _step11$value[1];
2417
+ var _diagnose5 = validateDuplicatedDecorator(_metadataClass4, _metadatas, '', method);
2418
+ if (_diagnose5.length) {
2419
+ diagnoseList.push.apply(diagnoseList, _toConsumableArray(_diagnose5));
2420
+ }
2421
+ }
2422
+ } catch (err) {
2423
+ _iterator11.e(err);
2424
+ } finally {
2425
+ _iterator11.f();
2828
2426
  }
2829
2427
  }
2830
- // 校验业务类不能包含大于1个component装饰器
2428
+ // 业务类不需要添加@target装饰器
2831
2429
  } catch (err) {
2832
2430
  _iterator7.e(err);
2833
2431
  } finally {
@@ -2840,12 +2438,12 @@ function validate(metadataList, componentMetadataClass) {
2840
2438
  var _step8$value = _slicedToArray(_step8.value, 2),
2841
2439
  _metadataClass5 = _step8$value[0],
2842
2440
  _metadataList4 = _step8$value[1];
2843
- var _diagnose4 = validateMoreThenOneComponentDecorator(_metadataClass5, _metadataList4.classMetadata, metaMetadataMap);
2844
- if (_diagnose4) {
2845
- diagnoseList.push(_diagnose4);
2441
+ var _diagnose6 = validateNoNeedTargetDecorator(_metadataClass5, _metadataList4.classMetadata);
2442
+ if (_diagnose6) {
2443
+ diagnoseList.push(_diagnose6);
2846
2444
  }
2847
2445
  }
2848
- // 校验业务类的装饰器的目标是否符合装饰器的target值
2446
+ // 校验业务类不能包含大于1个component装饰器
2849
2447
  } catch (err) {
2850
2448
  _iterator8.e(err);
2851
2449
  } finally {
@@ -2858,82 +2456,100 @@ function validate(metadataList, componentMetadataClass) {
2858
2456
  var _step9$value = _slicedToArray(_step9.value, 2),
2859
2457
  _metadataClass6 = _step9$value[0],
2860
2458
  _metadataList5 = _step9$value[1];
2459
+ var _diagnose7 = validateMoreThenOneComponentDecorator(_metadataClass6, _metadataList5.classMetadata, metaMetadataMap);
2460
+ if (_diagnose7) {
2461
+ diagnoseList.push(_diagnose7);
2462
+ }
2463
+ }
2464
+ // 校验业务类的装饰器的目标是否符合装饰器的target值
2465
+ } catch (err) {
2466
+ _iterator9.e(err);
2467
+ } finally {
2468
+ _iterator9.f();
2469
+ }
2470
+ var _iterator0 = _createForOfIteratorHelper(bizMetadataMap.entries()),
2471
+ _step0;
2472
+ try {
2473
+ for (_iterator0.s(); !(_step0 = _iterator0.n()).done;) {
2474
+ var _step0$value = _slicedToArray(_step0.value, 2),
2475
+ _metadataClass7 = _step0$value[0],
2476
+ _metadataList6 = _step0$value[1];
2861
2477
  var _diagnoses = validateDecoratorTarget({
2862
- cls: _metadataClass6,
2478
+ cls: _metadataClass7,
2863
2479
  target: Type.Class
2864
- }, _metadataList5.classMetadata, metaMetadataMap);
2480
+ }, _metadataList6.classMetadata, metaMetadataMap);
2865
2481
  if (_diagnoses.length) {
2866
2482
  diagnoseList.push.apply(diagnoseList, _toConsumableArray(_diagnoses));
2867
2483
  }
2868
- var _iterator1 = _createForOfIteratorHelper(_metadataList5.fieldMetadata.entries()),
2869
- _step1;
2484
+ var _iterator12 = _createForOfIteratorHelper(_metadataList6.fieldMetadata.entries()),
2485
+ _step12;
2870
2486
  try {
2871
- for (_iterator1.s(); !(_step1 = _iterator1.n()).done;) {
2872
- var _step1$value = _slicedToArray(_step1.value, 2),
2873
- field = _step1$value[0],
2874
- fieldMetadata = _step1$value[1];
2487
+ for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
2488
+ var _step12$value = _slicedToArray(_step12.value, 2),
2489
+ _field = _step12$value[0],
2490
+ fieldMetadata = _step12$value[1];
2875
2491
  var _diagnoses2 = validateDecoratorTarget({
2876
- cls: _metadataClass6,
2492
+ cls: _metadataClass7,
2877
2493
  target: Type.Field,
2878
- field: field
2494
+ field: _field
2879
2495
  }, fieldMetadata, metaMetadataMap);
2880
2496
  if (_diagnoses2.length) {
2881
2497
  diagnoseList.push.apply(diagnoseList, _toConsumableArray(_diagnoses2));
2882
2498
  }
2883
2499
  }
2884
2500
  } catch (err) {
2885
- _iterator1.e(err);
2501
+ _iterator12.e(err);
2886
2502
  } finally {
2887
- _iterator1.f();
2503
+ _iterator12.f();
2888
2504
  }
2889
- var _iterator10 = _createForOfIteratorHelper(_metadataList5.methodMetadata.entries()),
2890
- _step10;
2505
+ var _iterator13 = _createForOfIteratorHelper(_metadataList6.methodMetadata.entries()),
2506
+ _step13;
2891
2507
  try {
2892
- for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
2893
- var _step10$value = _slicedToArray(_step10.value, 2),
2894
- _field = _step10$value[0],
2895
- methodMetadata = _step10$value[1];
2508
+ for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
2509
+ var _step13$value = _slicedToArray(_step13.value, 2),
2510
+ _field2 = _step13$value[0],
2511
+ methodMetadata = _step13$value[1];
2896
2512
  var _diagnoses3 = validateDecoratorTarget({
2897
- cls: _metadataClass6,
2513
+ cls: _metadataClass7,
2898
2514
  target: Type.Method,
2899
- field: _field
2515
+ field: _field2
2900
2516
  }, methodMetadata, metaMetadataMap);
2901
2517
  if (_diagnoses3.length) {
2902
2518
  diagnoseList.push.apply(diagnoseList, _toConsumableArray(_diagnoses3));
2903
2519
  }
2904
2520
  }
2905
2521
  } catch (err) {
2906
- _iterator10.e(err);
2522
+ _iterator13.e(err);
2907
2523
  } finally {
2908
- _iterator10.f();
2524
+ _iterator13.f();
2909
2525
  }
2910
2526
  }
2911
2527
  // 校验如果使用component注入第三方组件,则必须在配置类内部。
2912
2528
  } catch (err) {
2913
- _iterator9.e(err);
2529
+ _iterator0.e(err);
2914
2530
  } finally {
2915
- _iterator9.f();
2531
+ _iterator0.f();
2916
2532
  }
2917
- var _iterator0 = _createForOfIteratorHelper(bizMetadataMap.entries()),
2918
- _step0;
2533
+ var _iterator1 = _createForOfIteratorHelper(bizMetadataMap.entries()),
2534
+ _step1;
2919
2535
  try {
2920
- for (_iterator0.s(); !(_step0 = _iterator0.n()).done;) {
2921
- var _step0$value = _slicedToArray(_step0.value, 2),
2922
- _metadataClass7 = _step0$value[0],
2923
- _metadataList6 = _step0$value[1];
2924
- var isConfigClass = !!_metadataList6.classMetadata.find(function (metadata) {
2536
+ for (_iterator1.s(); !(_step1 = _iterator1.n()).done;) {
2537
+ var _step1$value = _slicedToArray(_step1.value, 2),
2538
+ _metadataClass8 = _step1$value[0],
2539
+ _metadataList7 = _step1$value[1];
2540
+ var isConfigClass = !!_metadataList7.classMetadata.find(function (metadata) {
2925
2541
  return isConfigurationDecorator(metadata, metaMetadataMap);
2926
2542
  });
2927
- var _iterator11 = _createForOfIteratorHelper(_metadataList6.methodMetadata.entries()),
2928
- _step11;
2543
+ var _iterator14 = _createForOfIteratorHelper(_metadataList7.methodMetadata.entries()),
2544
+ _step14;
2929
2545
  try {
2930
- for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
2931
- var _step11$value = _slicedToArray(_step11.value, 2),
2932
- _field2 = _step11$value[0],
2933
- _methodMetadata = _step11$value[1];
2546
+ for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
2547
+ var _step14$value = _slicedToArray(_step14.value, 2),
2548
+ _field3 = _step14$value[0],
2549
+ _methodMetadata = _step14$value[1];
2934
2550
  var _diagnoses4 = validateMethodComponentMustInConfiguration({
2935
- cls: _metadataClass7,
2936
- field: _field2,
2551
+ cls: _metadataClass8,
2552
+ field: _field3,
2937
2553
  isConfigClass: isConfigClass
2938
2554
  }, _methodMetadata, metaMetadataMap);
2939
2555
  if (_diagnoses4.length) {
@@ -2941,15 +2557,15 @@ function validate(metadataList, componentMetadataClass) {
2941
2557
  }
2942
2558
  }
2943
2559
  } catch (err) {
2944
- _iterator11.e(err);
2560
+ _iterator14.e(err);
2945
2561
  } finally {
2946
- _iterator11.f();
2562
+ _iterator14.f();
2947
2563
  }
2948
2564
  }
2949
2565
  } catch (err) {
2950
- _iterator0.e(err);
2566
+ _iterator1.e(err);
2951
2567
  } finally {
2952
- _iterator0.f();
2568
+ _iterator1.f();
2953
2569
  }
2954
2570
  return diagnoseList;
2955
2571
  }
@@ -2961,19 +2577,14 @@ var IdClassMap = /*#__PURE__*/function () {
2961
2577
  */
2962
2578
  function IdClassMap(metaMetadataMap) {
2963
2579
  _classCallCheck(this, IdClassMap);
2964
- this.idClassMap = new Map();
2965
- var _iterator = _createForOfIteratorHelper(metaMetadataMap.entries()),
2580
+ _defineProperty(this, "idClassMap", new Map());
2581
+ var _iterator = _createForOfIteratorHelper(metaMetadataMap.keys()),
2966
2582
  _step;
2967
2583
  try {
2968
2584
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
2969
- var _step$value = _slicedToArray(_step.value, 2),
2970
- cls = _step$value[0],
2971
- metadataList = _step$value[1];
2972
- var idMetadata = metadataList.classMetadata.find(function (m) {
2973
- return m.constructor === Id;
2974
- });
2975
- var id = idMetadata ? idMetadata.value : cls.name; // 如果用户没有显式设置id,则使用类名作为id
2976
- if (typeof id !== 'string' || !id) {
2585
+ var cls = _step.value;
2586
+ var id = cls.$$id;
2587
+ if (typeof id !== 'string' || !id.trim()) {
2977
2588
  throw new Error(stringifyDiagnose(createDiagnose(DiagnoseCode.CO10016, cls.name)));
2978
2589
  }
2979
2590
  if (this.idClassMap.has(id)) {
@@ -2988,7 +2599,7 @@ var IdClassMap = /*#__PURE__*/function () {
2988
2599
  }
2989
2600
  }
2990
2601
  /**
2991
- * * 根据id获取元数据类
2602
+ * * 根据$$id获取元数据类
2992
2603
  * * @param id 元数据类id
2993
2604
  * * @returns 元数据类
2994
2605
  */
@@ -3033,179 +2644,568 @@ function initMetadataModule(decoratorMap) {
3033
2644
  };
3034
2645
  }
3035
2646
  // 元数据相关数据清理
3036
- function clearMetadataModule(metadataRepository, idClassMap) {
2647
+ function clearMetadataModule(metadataRepository, idClassMap, componentMetadataClass) {
3037
2648
  if (metadataRepository) {
3038
2649
  metadataRepository.destructor();
3039
2650
  }
3040
2651
  if (idClassMap) {
3041
2652
  idClassMap.destructor();
3042
2653
  }
2654
+ if (componentMetadataClass) {
2655
+ componentMetadataClass.destructor();
2656
+ }
3043
2657
  }
3044
2658
 
3045
- // 所有的组件装饰器对应的元数据类组成的树,使用map表示
3046
- var componentMetadataTree = new Map();
3047
- /**
3048
- * TODO: 不限制3层,可以无限层
3049
- * 初始化组件装饰器对应的元数据类的集合
3050
- * 遍历元数据类map,如果满足以下3种情况:
3051
- * 1. @component对应的元数据类,即:Component
3052
- * 2. 一级复合的组件装饰对应的元数据类,类装饰器中包含了@component装饰器
3053
- * 例如@view装饰器的元数据类是View
3054
- * @component()
3055
- * class View {}
3056
- * 3. 二级复合的组件装饰对应的元数据类,类装饰器中包含了一级复合装饰器
3057
- * 例如@page装饰器的元数据类是Page
3058
- * @view()
3059
- * class Page {}
3060
- */
3061
- function buildComponentMetadataSet(metadataRepository) {
3062
- // 找到当前被装饰器上面的scope元数据
3063
- function getScope(beDecoratedCls) {
3064
- var _a;
3065
- var _metadataRepository$g = metadataRepository.getAll(),
3066
- _metadataRepository$g2 = _slicedToArray(_metadataRepository$g, 1),
3067
- metaMetadataMap = _metadataRepository$g2[0];
3068
- var classMetadata = (_a = metaMetadataMap.get(beDecoratedCls)) === null || _a === void 0 ? void 0 : _a.classMetadata;
3069
- if (classMetadata) {
3070
- return classMetadata.find(function (i) {
3071
- return i.constructor === Scope;
3072
- });
3073
- }
3074
- return undefined;
2659
+ var scopeCache = new Map();
2660
+ function getComponentDecoratorScope(componentMetadata, metaMetadataMap, componentMetadataClass) {
2661
+ var _metaMetadataMap$get;
2662
+ if (scopeCache.has(componentMetadata)) {
2663
+ return scopeCache.get(componentMetadata);
3075
2664
  }
3076
- var _metadataRepository$g3 = metadataRepository.getAll(),
3077
- _metadataRepository$g4 = _slicedToArray(_metadataRepository$g3, 1),
3078
- metaMetadataMap = _metadataRepository$g4[0];
3079
- // 首先添加Component类
3080
- componentMetadataTree.set(Component, {
3081
- scope: getScope(Component),
3082
- compositeComponentMetadataCls: null
2665
+ var classMetadata = (_metaMetadataMap$get = metaMetadataMap.get(componentMetadata.constructor)) === null || _metaMetadataMap$get === void 0 ? void 0 : _metaMetadataMap$get.classMetadata;
2666
+ var scope = classMetadata.find(function (i) {
2667
+ return i.constructor === Scope;
3083
2668
  });
3084
- // 一级复合的组件装饰器
3085
- var firstClassSet = new Set();
3086
- var _iterator = _createForOfIteratorHelper(metaMetadataMap.entries()),
2669
+ if (scope) {
2670
+ // 如果有@scope装饰器
2671
+ scopeCache.set(componentMetadata, scope.value);
2672
+ return scope.value;
2673
+ }
2674
+ var parentComponentMetadata = classMetadata.find(function (metadata) {
2675
+ return componentMetadataClass.isComponentMetadata(metadata.constructor);
2676
+ });
2677
+ if (parentComponentMetadata) {
2678
+ // 如果被另外一个组件装饰器装饰
2679
+ var _scope = getComponentDecoratorScope(parentComponentMetadata, metaMetadataMap, componentMetadataClass);
2680
+ scopeCache.set(componentMetadata, _scope);
2681
+ return _scope;
2682
+ } else if (componentMetadata.constructor === Component) {
2683
+ // 只能是Component
2684
+ scopeCache.set(componentMetadata, exports.SCOPE.Singleton);
2685
+ return exports.SCOPE.Singleton;
2686
+ } else {
2687
+ throw new Error("\u8FD9\u662F\u4E00\u4E2A bug\uFF0C\u6CA1\u80FD\u6B63\u786E\u89E3\u6790\u51FAscope\u7684\u503C: ".concat(componentMetadata.constructor.name));
2688
+ }
2689
+ }
2690
+ function clear() {
2691
+ scopeCache.clear();
2692
+ }
2693
+ // 找到组件装饰器对应的元数据
2694
+ function findComponentMetadata(bizMetadata, componentMetadataClass) {
2695
+ var classMetadata = bizMetadata.classMetadata;
2696
+ var _iterator = _createForOfIteratorHelper(classMetadata),
3087
2697
  _step;
3088
2698
  try {
3089
2699
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
3090
- var _step$value = _slicedToArray(_step.value, 2),
3091
- beDecoratedCls = _step$value[0],
3092
- classMetadata = _step$value[1].classMetadata;
3093
- var metadata = classMetadata.find(function (i) {
3094
- return i.constructor === Component;
3095
- });
3096
- if (metadata) {
3097
- componentMetadataTree.set(beDecoratedCls, {
3098
- scope: getScope(beDecoratedCls),
3099
- compositeComponentMetadataCls: Component
3100
- });
3101
- firstClassSet.add(beDecoratedCls);
2700
+ var metadata = _step.value;
2701
+ if (componentMetadataClass.isComponentMetadata(metadata.constructor)) {
2702
+ return metadata;
3102
2703
  }
3103
2704
  }
3104
- // 二级复合组件装饰器
3105
2705
  } catch (err) {
3106
2706
  _iterator.e(err);
3107
2707
  } finally {
3108
2708
  _iterator.f();
3109
2709
  }
3110
- var _iterator2 = _createForOfIteratorHelper(metaMetadataMap.entries()),
3111
- _step2;
3112
- try {
3113
- var _loop = function _loop() {
3114
- var _step2$value = _slicedToArray(_step2.value, 2),
3115
- beDecoratedCls = _step2$value[0],
3116
- classMetadata = _step2$value[1].classMetadata;
3117
- if (firstClassSet.has(beDecoratedCls)) {
3118
- return 1; // continue
3119
- }
3120
- var firstClass = null;
3121
- var metadata = classMetadata.find(function (i) {
3122
- if (firstClassSet.has(i.constructor)) {
3123
- firstClass = i.constructor;
3124
- return true;
2710
+ return undefined;
2711
+ }
2712
+
2713
+ var IocComponentDefinition = /*#__PURE__*/function () {
2714
+ function IocComponentDefinition() {
2715
+ _classCallCheck(this, IocComponentDefinition);
2716
+ _defineProperty(this, "idDefinitionMap", new Map());
2717
+ _defineProperty(this, "clsDefinitionMap", new Map());
2718
+ }
2719
+ return _createClass(IocComponentDefinition, [{
2720
+ key: "newIocComponentDefinition",
2721
+ value: function newIocComponentDefinition(id, cls, isSingleton, instantiateType) {
2722
+ return {
2723
+ id: id,
2724
+ cls: cls,
2725
+ isSingleton: isSingleton,
2726
+ instantiateType: instantiateType
2727
+ };
2728
+ }
2729
+ }, {
2730
+ key: "addDefinition",
2731
+ value: function addDefinition(cls, id, isSingleton, methodInstantiateOpts) {
2732
+ if (typeof id !== 'string' || !id.trim()) {
2733
+ throw new Error("\u751F\u6210\u7EC4\u4EF6id\u5931\u8D25: [".concat(cls.name, "]"));
2734
+ }
2735
+ var existIdDef = this.idDefinitionMap.get(id);
2736
+ if (existIdDef) {
2737
+ throw new Error("\u5B58\u5728id\u7684\u7EC4\u4EF6: [".concat(id, "] - [").concat(existIdDef.cls.name, "] - [").concat(cls.name, "]"));
2738
+ }
2739
+ var existClsDef = this.clsDefinitionMap.get(cls);
2740
+ if (existClsDef) {
2741
+ throw new Error("\u5B58\u5728\u540C\u540D\u7684\u7EC4\u4EF6: [".concat(existClsDef.cls.name, "] - [").concat(cls.name, "]"));
2742
+ }
2743
+ var componentDefinition = this.newIocComponentDefinition(id, cls, isSingleton, methodInstantiateOpts ? 'method' : 'new');
2744
+ if (methodInstantiateOpts) {
2745
+ componentDefinition.methodInstantiateOpts = methodInstantiateOpts;
2746
+ }
2747
+ this.idDefinitionMap.set(id, componentDefinition);
2748
+ this.clsDefinitionMap.set(cls, componentDefinition);
2749
+ }
2750
+ /**
2751
+ * 获取真正会实例化的类定义
2752
+ * @param ClsOrId 想要实例化的类或类id
2753
+ * @param qualifier 如果存在多个后端类,需要通过qualifier指定具体的类id
2754
+ * @returns 真正会实例化的类定义
2755
+ */
2756
+ }, {
2757
+ key: "getInstantiateDefinition",
2758
+ value: function getInstantiateDefinition(ClsOrId, qualifier) {
2759
+ var definition = this.getDefinition(ClsOrId);
2760
+ if (!definition) {
2761
+ var diagnose = createDiagnose(DiagnoseCode.CO10011, typeof ClsOrId === 'string' ? ClsOrId : ClsOrId.name);
2762
+ throw new Error(stringifyDiagnose(diagnose));
2763
+ }
2764
+ var descendantList = Array.from(this.clsDefinitionMap.keys()).filter(function (i) {
2765
+ return isDescendantOf(i, definition.cls);
2766
+ });
2767
+ if (descendantList.length === 0) {
2768
+ // 没有子组件直接返回本身
2769
+ return definition;
2770
+ } else if (descendantList.length === 1) {
2771
+ // 有一个子组件
2772
+ return this.clsDefinitionMap.get(descendantList[0]);
2773
+ } else {
2774
+ // 多个子组件
2775
+ if (qualifier) {
2776
+ var _iterator = _createForOfIteratorHelper(descendantList),
2777
+ _step;
2778
+ try {
2779
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
2780
+ var child = _step.value;
2781
+ var def = this.clsDefinitionMap.get(child);
2782
+ if (def.id === qualifier) {
2783
+ return def;
2784
+ }
2785
+ }
2786
+ } catch (err) {
2787
+ _iterator.e(err);
2788
+ } finally {
2789
+ _iterator.f();
2790
+ }
2791
+ }
2792
+ if (qualifier) {
2793
+ var _diagnose = createDiagnose(DiagnoseCode.CO10010, definition.id, descendantList.map(function (i) {
2794
+ return i.name;
2795
+ }), qualifier);
2796
+ throw new Error(stringifyDiagnose(_diagnose));
2797
+ } else {
2798
+ var _diagnose2 = createDiagnose(DiagnoseCode.CO10009, definition.id, descendantList.map(function (i) {
2799
+ return i.name;
2800
+ }));
2801
+ throw new Error(stringifyDiagnose(_diagnose2));
2802
+ }
2803
+ }
2804
+ }
2805
+ }, {
2806
+ key: "getDefinition",
2807
+ value: function getDefinition(ClsOrId) {
2808
+ if (typeof ClsOrId === 'string') {
2809
+ return this.idDefinitionMap.get(ClsOrId);
2810
+ } else {
2811
+ return this.clsDefinitionMap.get(ClsOrId);
2812
+ }
2813
+ }
2814
+ }, {
2815
+ key: "existDefinition",
2816
+ value: function existDefinition(ClsOrId) {
2817
+ if (typeof ClsOrId === 'string') {
2818
+ return this.idDefinitionMap.has(ClsOrId);
2819
+ } else {
2820
+ return this.clsDefinitionMap.has(ClsOrId);
2821
+ }
2822
+ }
2823
+ }, {
2824
+ key: "destructor",
2825
+ value: function destructor() {
2826
+ this.idDefinitionMap.clear();
2827
+ this.clsDefinitionMap.clear();
2828
+ }
2829
+ }]);
2830
+ }();
2831
+
2832
+ var IocComponentFactory = /*#__PURE__*/function () {
2833
+ function IocComponentFactory() {
2834
+ _classCallCheck(this, IocComponentFactory);
2835
+ // 单例构造函数和单例的映射关系
2836
+ _defineProperty(this, "singletonInstances", new Map());
2837
+ }
2838
+ return _createClass(IocComponentFactory, [{
2839
+ key: "createComponent",
2840
+ value: function createComponent(application, definition, constructorArgs) {
2841
+ var cls = definition.cls,
2842
+ instantiateType = definition.instantiateType;
2843
+ var component;
2844
+ if (instantiateType === 'new') {
2845
+ component = _construct(cls, _toConsumableArray(constructorArgs));
2846
+ } else {
2847
+ var _definition$methodIns = definition.methodInstantiateOpts,
2848
+ configurationCls = _definition$methodIns.configurationCls,
2849
+ method = _definition$methodIns.method;
2850
+ var configuration = new configurationCls();
2851
+ component = configuration[method]();
2852
+ }
2853
+ var metadatas = application.metadataRepository.getMetadataByClass(cls);
2854
+ if (metadatas) {
2855
+ var classMetadata = metadatas.classMetadata,
2856
+ methodMetadata = metadatas.methodMetadata,
2857
+ fieldMetadata = metadatas.fieldMetadata;
2858
+ var _iterator = _createForOfIteratorHelper(classMetadata),
2859
+ _step;
2860
+ try {
2861
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
2862
+ var meta = _step.value;
2863
+ var option = getCreateDecoratorOption(meta.constructor);
2864
+ if (option) {
2865
+ option.componentPostConstruct.call(component, meta, application);
2866
+ }
2867
+ }
2868
+ } catch (err) {
2869
+ _iterator.e(err);
2870
+ } finally {
2871
+ _iterator.f();
2872
+ }
2873
+ var _iterator2 = _createForOfIteratorHelper(fieldMetadata.entries()),
2874
+ _step2;
2875
+ try {
2876
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
2877
+ var _step2$value = _slicedToArray(_step2.value, 2),
2878
+ field = _step2$value[0],
2879
+ metaList = _step2$value[1];
2880
+ var _iterator4 = _createForOfIteratorHelper(metaList),
2881
+ _step4;
2882
+ try {
2883
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
2884
+ var _meta = _step4.value;
2885
+ var _option = getCreateDecoratorOption(_meta.constructor);
2886
+ if (_option) {
2887
+ _option.componentPostConstruct.call(component, _meta, application, field);
2888
+ }
2889
+ }
2890
+ } catch (err) {
2891
+ _iterator4.e(err);
2892
+ } finally {
2893
+ _iterator4.f();
2894
+ }
2895
+ }
2896
+ } catch (err) {
2897
+ _iterator2.e(err);
2898
+ } finally {
2899
+ _iterator2.f();
2900
+ }
2901
+ var _iterator3 = _createForOfIteratorHelper(methodMetadata.entries()),
2902
+ _step3;
2903
+ try {
2904
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
2905
+ var _step3$value = _slicedToArray(_step3.value, 2),
2906
+ _method = _step3$value[0],
2907
+ _metaList = _step3$value[1];
2908
+ var _iterator5 = _createForOfIteratorHelper(_metaList),
2909
+ _step5;
2910
+ try {
2911
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
2912
+ var _meta2 = _step5.value;
2913
+ var _option2 = getCreateDecoratorOption(_meta2.constructor);
2914
+ if (_option2) {
2915
+ _option2.componentPostConstruct.call(component, _meta2, application, _method);
2916
+ }
2917
+ }
2918
+ } catch (err) {
2919
+ _iterator5.e(err);
2920
+ } finally {
2921
+ _iterator5.f();
2922
+ }
2923
+ }
2924
+ } catch (err) {
2925
+ _iterator3.e(err);
2926
+ } finally {
2927
+ _iterator3.f();
2928
+ }
2929
+ }
2930
+ return component;
2931
+ }
2932
+ }, {
2933
+ key: "getComponents",
2934
+ value: function getComponents(application, userOption) {
2935
+ var _this = this;
2936
+ var targetClsInstanceMap = new Map(); // 想要实例化的类和对应的实例
2937
+ var instanceInstantiateClsMap = new Map(); // 新建实例和对应的实例化类
2938
+ var newSingletonInstances = new Map(); // 新增的单例,最后要合并到singletonInstances
2939
+ var instantiatingStage = new Set(); // 实例化中
2940
+ var assignningStage = new Set(); // field赋值中
2941
+ var finishedStage = new Set(); // 已完成
2942
+ // 已经有的单例填充到finishedStage和instances
2943
+ var _iterator6 = _createForOfIteratorHelper(this.singletonInstances.entries()),
2944
+ _step6;
2945
+ try {
2946
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
2947
+ var _step6$value = _slicedToArray(_step6.value, 2),
2948
+ _cls = _step6$value[0],
2949
+ _instance2 = _step6$value[1];
2950
+ targetClsInstanceMap.set(_cls, _instance2);
2951
+ }
2952
+ // 完整的初始化一个组件
2953
+ } catch (err) {
2954
+ _iterator6.e(err);
2955
+ } finally {
2956
+ _iterator6.f();
2957
+ }
2958
+ var _instantiateComponent = function instantiateComponent(opt) {
2959
+ var classOrId = opt.classOrId;
2960
+ // 要实例化的类定义
2961
+ var targetDefinition = application.iocComponentDefinition.getDefinition(classOrId);
2962
+ if (!targetDefinition) {
2963
+ var diagnose = createDiagnose(DiagnoseCode.CO10011, typeof classOrId === 'string' ? classOrId : classOrId.name);
2964
+ throw new Error(stringifyDiagnose(diagnose));
2965
+ }
2966
+ var qualifier = opt.qualifier;
2967
+ if (!qualifier) {
2968
+ // 如果没有指定,尝试从配置中获取
2969
+ qualifier = application.propertiesConfig.getValue("".concat(targetDefinition.id, ".qualifier"));
2970
+ }
2971
+ // 真正实例化的类定义
2972
+ var instantiateDefinition = application.iocComponentDefinition.getInstantiateDefinition(classOrId, qualifier);
2973
+ if (instantiateDefinition.isSingleton) {
2974
+ if (_this.singletonInstances.has(instantiateDefinition.cls)) {
2975
+ return _this.singletonInstances.get(instantiateDefinition.cls);
2976
+ } else if (newSingletonInstances.has(instantiateDefinition.cls)) {
2977
+ return newSingletonInstances.get(instantiateDefinition.cls);
2978
+ }
2979
+ }
2980
+ if (instantiatingStage.has(targetDefinition.cls)) {
2981
+ // 理论上不可能走到这里
2982
+ throw new Error("\u5FAA\u73AF\u4F9D\u8D56: ".concat(targetDefinition.cls.name));
2983
+ }
2984
+ // 在实例化中或者已实例化,返回实例
2985
+ if (assignningStage.has(targetDefinition.cls) || finishedStage.has(targetDefinition.cls)) {
2986
+ return targetClsInstanceMap.get(targetDefinition.cls);
2987
+ }
2988
+ instantiatingStage.add(targetDefinition.cls);
2989
+ var constructorArgs = [];
2990
+ var constructorParams = application.metadataRepository.listClassKindMetadata(instantiateDefinition.cls, ConstructorParam);
2991
+ if (constructorParams.length > 0) {
2992
+ // 因为元数据不能重复,所以只有一个
2993
+ var constructorParamsParams = constructorParams[0].value;
2994
+ var _iterator7 = _createForOfIteratorHelper(constructorParamsParams),
2995
+ _step7;
2996
+ try {
2997
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
2998
+ var dependency = _step7.value;
2999
+ if (dependency === undefined) {
3000
+ constructorArgs.push(undefined);
3001
+ } else {
3002
+ var depInstance = _instantiateComponent({
3003
+ classOrId: dependency
3004
+ });
3005
+ // 确保依赖已完全注入
3006
+ if (!finishedStage.has(dependency) && !_this.singletonInstances.has(dependency)) {
3007
+ var _diagnose = createDiagnose(DiagnoseCode.CO10013, targetDefinition.cls.name, dependency.name);
3008
+ throw new Error(stringifyDiagnose(_diagnose));
3009
+ }
3010
+ constructorArgs.push(depInstance);
3011
+ }
3012
+ }
3013
+ } catch (err) {
3014
+ _iterator7.e(err);
3015
+ } finally {
3016
+ _iterator7.f();
3017
+ }
3018
+ }
3019
+ // 2. 实例化,同时执行componentPostConstruct
3020
+ var instance = _this.createComponent(application, instantiateDefinition, constructorArgs);
3021
+ if (instantiateDefinition.isSingleton) {
3022
+ newSingletonInstances.set(instantiateDefinition.cls, instance);
3023
+ }
3024
+ targetClsInstanceMap.set(targetDefinition.cls, instance);
3025
+ instanceInstantiateClsMap.set(instance, instantiateDefinition.cls);
3026
+ instantiatingStage["delete"](targetDefinition.cls);
3027
+ assignningStage.add(targetDefinition.cls);
3028
+ // 3. 递归实例化field注入
3029
+ var autowiredFields = application.metadataRepository.listFieldByMetadataCls(instantiateDefinition.cls, Autowired);
3030
+ var _iterator8 = _createForOfIteratorHelper(autowiredFields),
3031
+ _step8;
3032
+ try {
3033
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
3034
+ var field = _step8.value;
3035
+ var autowiredMetadatas = application.metadataRepository.listFieldKindMetadata(instantiateDefinition.cls, field, Autowired);
3036
+ if (autowiredMetadatas.length > 0) {
3037
+ var autowiredCls = autowiredMetadatas[0].value;
3038
+ if (autowiredCls === undefined) {
3039
+ instance[field] = undefined;
3040
+ } else if (autowiredCls === instantiateDefinition.cls) {
3041
+ // 检查自依赖:不能注入自己
3042
+ // TODO: 如果autowiredCls是instantiateDefinition.cls的祖先类或者子孙类怎么办?
3043
+ var _diagnose2 = createDiagnose(DiagnoseCode.CO10012, instantiateDefinition.cls.name, field);
3044
+ printDiagnose(_diagnose2);
3045
+ instance[field] = undefined;
3046
+ } else {
3047
+ var qualifierMetadatas = application.metadataRepository.listFieldKindMetadata(instantiateDefinition.cls, field, Qualifier);
3048
+ var _qualifier = void 0;
3049
+ if (qualifierMetadatas.length > 0) {
3050
+ _qualifier = qualifierMetadatas[0].value;
3051
+ }
3052
+ var autowiredInstance = _instantiateComponent({
3053
+ classOrId: autowiredCls,
3054
+ qualifier: _qualifier
3055
+ });
3056
+ instance[field] = autowiredInstance;
3057
+ }
3058
+ }
3059
+ }
3060
+ // 4. 标记为完全注入
3061
+ } catch (err) {
3062
+ _iterator8.e(err);
3063
+ } finally {
3064
+ _iterator8.f();
3065
+ }
3066
+ assignningStage["delete"](targetDefinition.cls);
3067
+ finishedStage.add(targetDefinition.cls);
3068
+ return instance;
3069
+ };
3070
+ // TODO: 如果初始化多个,有没有先后顺序问题?
3071
+ var instance = _instantiateComponent(userOption);
3072
+ // merge newSingletonInstances to singletonInstances
3073
+ if (newSingletonInstances.size > 0) {
3074
+ var _iterator9 = _createForOfIteratorHelper(newSingletonInstances.entries()),
3075
+ _step9;
3076
+ try {
3077
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
3078
+ var _step9$value = _slicedToArray(_step9.value, 2),
3079
+ cls = _step9$value[0],
3080
+ _instance = _step9$value[1];
3081
+ this.singletonInstances.set(cls, _instance);
3082
+ // 现在默认子类的singleton和父类都是保持一致的。TODO: 如果子类的singleton不是单例了,应该如何处理
3083
+ }
3084
+ } catch (err) {
3085
+ _iterator9.e(err);
3086
+ } finally {
3087
+ _iterator9.f();
3088
+ }
3089
+ }
3090
+ // 5. 所有新增的单例执行init方法
3091
+ var _iterator0 = _createForOfIteratorHelper(finishedStage.keys()),
3092
+ _step0;
3093
+ try {
3094
+ for (_iterator0.s(); !(_step0 = _iterator0.n()).done;) {
3095
+ var _cls2 = _step0.value;
3096
+ // 这里应该是根据instance来判断是否已经存在的
3097
+ var _instance3 = targetClsInstanceMap.get(_cls2);
3098
+ if (typeof _instance3['init'] === 'function') {
3099
+ var _instance3$init;
3100
+ (_instance3$init = _instance3['init']) === null || _instance3$init === void 0 || _instance3$init.call(_instance3, application);
3101
+ }
3102
+ }
3103
+ // 执行start方法
3104
+ } catch (err) {
3105
+ _iterator0.e(err);
3106
+ } finally {
3107
+ _iterator0.f();
3108
+ }
3109
+ var _iterator1 = _createForOfIteratorHelper(finishedStage.keys()),
3110
+ _step1;
3111
+ try {
3112
+ for (_iterator1.s(); !(_step1 = _iterator1.n()).done;) {
3113
+ var _cls3 = _step1.value;
3114
+ var _instance4 = targetClsInstanceMap.get(_cls3);
3115
+ if (typeof _instance4['start'] === 'function') {
3116
+ var _instance4$start;
3117
+ (_instance4$start = _instance4['start']) === null || _instance4$start === void 0 || _instance4$start.call(_instance4, application);
3118
+ }
3119
+ }
3120
+ } catch (err) {
3121
+ _iterator1.e(err);
3122
+ } finally {
3123
+ _iterator1.f();
3124
+ }
3125
+ return instance;
3126
+ }
3127
+ }, {
3128
+ key: "getViewComponent",
3129
+ value: function getViewComponent(application, viewClass, props) {
3130
+ var targetDefinition = application.iocComponentDefinition.getDefinition(viewClass);
3131
+ if (!targetDefinition) {
3132
+ var diagnose = createDiagnose(DiagnoseCode.CO10011, typeof viewClass === 'string' ? viewClass : viewClass.name);
3133
+ throw new Error(stringifyDiagnose(diagnose));
3134
+ }
3135
+ // 视图组件目前简单的认为全是prototype,且不支持实例化子组件
3136
+ var instance = this.createComponent(application, targetDefinition, [props]);
3137
+ var autowiredFields = application.metadataRepository.listFieldByMetadataCls(targetDefinition.cls, Autowired);
3138
+ var _iterator10 = _createForOfIteratorHelper(autowiredFields),
3139
+ _step10;
3140
+ try {
3141
+ for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
3142
+ var field = _step10.value;
3143
+ var autowiredMetadatas = application.metadataRepository.listFieldKindMetadata(targetDefinition.cls, field, Autowired);
3144
+ if (autowiredMetadatas.length > 0) {
3145
+ var autowiredCls = autowiredMetadatas[0].value;
3146
+ if (autowiredCls === undefined) {
3147
+ instance[field] = undefined;
3148
+ } else if (autowiredCls === targetDefinition.cls) {
3149
+ // 检查自依赖:不能注入自己
3150
+ // TODO: 如果autowiredCls是instantiateDefinition.cls的祖先类或者子孙类怎么办?
3151
+ var _diagnose3 = createDiagnose(DiagnoseCode.CO10012, targetDefinition.cls.name, field);
3152
+ printDiagnose(_diagnose3);
3153
+ instance[field] = undefined;
3154
+ } else {
3155
+ var qualifierMetadatas = application.metadataRepository.listFieldKindMetadata(targetDefinition.cls, field, Qualifier);
3156
+ var qualifier = void 0;
3157
+ if (qualifierMetadatas.length > 0) {
3158
+ qualifier = qualifierMetadatas[0].value;
3159
+ }
3160
+ var autowiredInstance = this.getComponents(application, {
3161
+ classOrId: autowiredCls,
3162
+ qualifier: qualifier
3163
+ });
3164
+ instance[field] = autowiredInstance;
3165
+ }
3166
+ }
3125
3167
  }
3126
- return false;
3127
- });
3128
- if (metadata) {
3129
- componentMetadataTree.set(beDecoratedCls, {
3130
- scope: getScope(beDecoratedCls),
3131
- compositeComponentMetadataCls: firstClass
3132
- });
3168
+ } catch (err) {
3169
+ _iterator10.e(err);
3170
+ } finally {
3171
+ _iterator10.f();
3133
3172
  }
3134
- };
3135
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
3136
- if (_loop()) continue;
3173
+ return instance;
3137
3174
  }
3138
- } catch (err) {
3139
- _iterator2.e(err);
3140
- } finally {
3141
- _iterator2.f();
3142
- }
3143
- }
3144
- /**
3145
- * 指定一个类装饰器的scope的值
3146
- * @param componentMetadata
3147
- */
3148
- function findComponentDecoratorScope(componentMetadata) {
3149
- var MetadataClass = componentMetadata.constructor;
3150
- while (MetadataClass) {
3151
- var config = componentMetadataTree.get(MetadataClass);
3152
- if (config === undefined) {
3153
- throw new Error("\u672A\u77E5\u7684\u88C5\u9970\u5668\u5143\u6570\u636E\u7C7B\uFF1A".concat(MetadataClass.name));
3154
- }
3155
- var scope = config.scope,
3156
- compositeComponentMetadataCls = config.compositeComponentMetadataCls;
3157
- if (compositeComponentMetadataCls === null) {
3158
- // Component情况
3159
- return exports.SCOPE.Singleton;
3160
- } else if (scope) {
3161
- // 有scope就取scope的值
3162
- return scope.value;
3163
- } else {
3164
- // 继续找复合的装饰器
3165
- MetadataClass = compositeComponentMetadataCls;
3175
+ }, {
3176
+ key: "destructor",
3177
+ value: function destructor() {
3178
+ // TODO: 调用组件的destroy方法
3179
+ this.singletonInstances.clear();
3166
3180
  }
3167
- }
3168
- throw new Error("\u8FD9\u5E94\u8BE5\u662F\u4E00\u4E2Abug\uFF1A".concat(MetadataClass.name));
3169
- }
3170
- /**
3171
- * 一个类的类装饰中是否包含组件装饰器
3172
- * @param beDecoratedCls
3173
- */
3174
- function findComponentDecorator(beDecoratedCls, bizMetadataMap) {
3175
- var bizMetadata = bizMetadataMap.get(beDecoratedCls);
3176
- if (bizMetadata) {
3177
- return bizMetadata.classMetadata.find(function (i) {
3178
- return componentMetadataTree.has(i.constructor);
3179
- });
3180
- }
3181
- return null;
3182
- }
3183
- function clear() {
3184
- componentMetadataTree.clear();
3185
- }
3181
+ }]);
3182
+ }();
3186
3183
 
3187
- function doBuildIocComponentDefinition(metadataRepository) {
3184
+ function doBuildIocComponentDefinition(metadataRepository, componentMetadataClass, iocComponentDefinition) {
3188
3185
  var _metadataRepository$g = metadataRepository.getAll(),
3189
- _metadataRepository$g2 = _slicedToArray(_metadataRepository$g, 2);
3190
- _metadataRepository$g2[0];
3191
- var bizMetadata = _metadataRepository$g2[1];
3192
- var _iterator = _createForOfIteratorHelper(bizMetadata.keys()),
3186
+ _metadataRepository$g2 = _slicedToArray(_metadataRepository$g, 2),
3187
+ metaMetadata = _metadataRepository$g2[0],
3188
+ bizMetadata = _metadataRepository$g2[1];
3189
+ var _iterator = _createForOfIteratorHelper(bizMetadata.entries()),
3193
3190
  _step;
3194
3191
  try {
3195
3192
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
3196
- var beDecoratedCls = _step.value;
3193
+ var _step$value = _slicedToArray(_step.value, 2),
3194
+ beDecoratedCls = _step$value[0],
3195
+ bizMeta = _step$value[1];
3197
3196
  if (bizMetadata.has(beDecoratedCls)) {
3198
- var componentMetadata = findComponentDecorator(beDecoratedCls, bizMetadata);
3197
+ var componentMetadata = findComponentMetadata(bizMeta, componentMetadataClass);
3199
3198
  if (componentMetadata) {
3200
- // 确定存在component类装饰器,再确定scope值
3201
3199
  var scope = void 0;
3202
3200
  var selfScopeMetadata = metadataRepository.listClassKindMetadata(beDecoratedCls, Scope);
3203
3201
  if (selfScopeMetadata.length > 0) {
3202
+ // 优先取被装饰器类上的@scope装饰器
3204
3203
  scope = selfScopeMetadata[0].value;
3205
3204
  } else {
3206
- scope = findComponentDecoratorScope(componentMetadata);
3205
+ // 取组件装饰器的@scope装饰器
3206
+ scope = getComponentDecoratorScope(componentMetadata, metaMetadata, componentMetadataClass);
3207
3207
  }
3208
- addDefinition(beDecoratedCls, scope === exports.SCOPE.Singleton);
3208
+ iocComponentDefinition.addDefinition(beDecoratedCls, beDecoratedCls.$$id, scope === exports.SCOPE.Singleton);
3209
3209
  } else {
3210
3210
  var methods = metadataRepository.listMethodByMetadataCls(beDecoratedCls, Component);
3211
3211
  var _iterator2 = _createForOfIteratorHelper(methods),
@@ -3214,8 +3214,11 @@ function doBuildIocComponentDefinition(metadataRepository) {
3214
3214
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
3215
3215
  var method = _step2.value;
3216
3216
  var componentMetas = metadataRepository.listMethodKindMetadata(beDecoratedCls, method, Component);
3217
+ // TODO: @component()装饰器的参数能否在 ioc 组件中定义了,没有定义都是有问题的
3217
3218
  var scopeMetas = metadataRepository.listMethodKindMetadata(beDecoratedCls, method, Scope);
3218
- addDefinition(componentMetas[0].value, !scopeMetas.length || scopeMetas[0].value === exports.SCOPE.Singleton, {
3219
+ // TODO: 添加校验是否有@id装饰器;
3220
+ var idMetas = metadataRepository.listMethodKindMetadata(beDecoratedCls, method, Id);
3221
+ iocComponentDefinition.addDefinition(componentMetas[0].value, idMetas[0].value, !scopeMetas.length || scopeMetas[0].value === exports.SCOPE.Singleton, {
3219
3222
  configurationCls: beDecoratedCls,
3220
3223
  method: method
3221
3224
  });
@@ -3239,14 +3242,20 @@ function doBuildIocComponentDefinition(metadataRepository) {
3239
3242
  * 遍历所有的业务类,如果有类装饰器,那么就是类组件
3240
3243
  * 遍历所有配置类的方法,如果有@component装饰器,那么也是类组件
3241
3244
  */
3242
- function initIocComponentDefinitionModule(metadataRepository) {
3243
- buildComponentMetadataSet(metadataRepository);
3244
- doBuildIocComponentDefinition(metadataRepository);
3245
+ function initIocComponentModule(metadataRepository, componentMetadataClass) {
3246
+ var iocComponentDefinition = new IocComponentDefinition();
3247
+ doBuildIocComponentDefinition(metadataRepository, componentMetadataClass, iocComponentDefinition);
3245
3248
  clear();
3249
+ return {
3250
+ iocComponentDefinition: iocComponentDefinition,
3251
+ iocComponentFactory: new IocComponentFactory()
3252
+ };
3246
3253
  }
3247
- function clearIocComponentDefinitionModule() {
3248
- clear$1();
3249
- clear$2();
3254
+ function destructorIocComponentModule(iocComponentDefinition, iocComponentFactory) {
3255
+ {
3256
+ iocComponentFactory.destructor();
3257
+ iocComponentDefinition.destructor();
3258
+ }
3250
3259
  }
3251
3260
 
3252
3261
  /**
@@ -3257,6 +3266,7 @@ var PropertiesConfig = /*#__PURE__*/function () {
3257
3266
  function PropertiesConfig() {
3258
3267
  var jsonConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3259
3268
  _classCallCheck(this, PropertiesConfig);
3269
+ _defineProperty(this, "beanConfig", void 0);
3260
3270
  this.beanConfig = jsonConfig;
3261
3271
  }
3262
3272
  return _createClass(PropertiesConfig, [{
@@ -3300,7 +3310,7 @@ var PropertiesConfig = /*#__PURE__*/function () {
3300
3310
  }
3301
3311
  }]);
3302
3312
  }();
3303
- PropertiesConfig.bootComponentKey = 'bootComponents';
3313
+ _defineProperty(PropertiesConfig, "bootComponentKey", 'bootComponents');
3304
3314
 
3305
3315
  /**
3306
3316
  * 表示一个web应用实例
@@ -3310,6 +3320,12 @@ var Application = /*#__PURE__*/function () {
3310
3320
  function Application() {
3311
3321
  var jsonConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3312
3322
  _classCallCheck(this, Application);
3323
+ _defineProperty(this, "componentMetadataClass", void 0);
3324
+ _defineProperty(this, "metadataRepository", void 0);
3325
+ _defineProperty(this, "idClassMap", void 0);
3326
+ _defineProperty(this, "propertiesConfig", void 0);
3327
+ _defineProperty(this, "iocComponentDefinition", void 0);
3328
+ _defineProperty(this, "iocComponentFactory", void 0);
3313
3329
  this.propertiesConfig = new PropertiesConfig(jsonConfig);
3314
3330
  }
3315
3331
  /**
@@ -3329,29 +3345,28 @@ var Application = /*#__PURE__*/function () {
3329
3345
  this.idClassMap = idClassMap;
3330
3346
  this.componentMetadataClass = componentMetadataClass;
3331
3347
  // 用元数据信息初始化ioc组件数据
3332
- initIocComponentDefinitionModule(this.metadataRepository);
3348
+ var _initIocComponentModu = initIocComponentModule(this.metadataRepository, this.componentMetadataClass),
3349
+ iocComponentFactory = _initIocComponentModu.iocComponentFactory,
3350
+ iocComponentDefinition = _initIocComponentModu.iocComponentDefinition;
3351
+ this.iocComponentDefinition = iocComponentDefinition;
3352
+ this.iocComponentFactory = iocComponentFactory;
3333
3353
  // 实例化配置启动项的组件
3334
3354
  this.bootComponent();
3335
3355
  }
3336
3356
  }, {
3337
3357
  key: "destructor",
3338
3358
  value: function destructor() {
3339
- clearIocComponentDefinitionModule();
3340
- clearMetadataModule(this.metadataRepository, this.idClassMap);
3359
+ destructorIocComponentModule(this.iocComponentDefinition, this.iocComponentFactory);
3360
+ clearMetadataModule(this.metadataRepository, this.idClassMap, this.componentMetadataClass);
3341
3361
  clearDecoratorParamModule();
3342
3362
  }
3343
3363
  }, {
3344
3364
  key: "getComponent",
3345
- value: function getComponent(ClsOrId, option) {
3346
- if (typeof ClsOrId === 'string') {
3347
- // TODO:
3348
- return null;
3349
- } else {
3350
- return getComponents(this, {
3351
- classOrId: ClsOrId,
3352
- qualifier: option === null || option === void 0 ? void 0 : option.qualifier
3353
- });
3354
- }
3365
+ value: function getComponent(ClassOrId, option) {
3366
+ return this.iocComponentFactory.getComponents(this, {
3367
+ classOrId: ClassOrId,
3368
+ qualifier: option === null || option === void 0 ? void 0 : option.qualifier
3369
+ });
3355
3370
  }
3356
3371
  /**
3357
3372
  * 仅用于view组件的实例化入口,其他ioc组件都应该使用getComponent
@@ -3361,8 +3376,8 @@ var Application = /*#__PURE__*/function () {
3361
3376
  */
3362
3377
  }, {
3363
3378
  key: "getViewComponent",
3364
- value: function getViewComponent$1(viewClass, props) {
3365
- return getViewComponent(this, viewClass, props);
3379
+ value: function getViewComponent(viewClass, props) {
3380
+ return this.iocComponentFactory.getViewComponent(this, viewClass, props);
3366
3381
  }
3367
3382
  }, {
3368
3383
  key: "listFieldByMetadataCls",
@@ -3372,8 +3387,8 @@ var Application = /*#__PURE__*/function () {
3372
3387
  }, {
3373
3388
  key: "findClassKindMetadataRecursively",
3374
3389
  value: function findClassKindMetadataRecursively(beDecoratedCls, TargetCls) {
3375
- var upward = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
3376
- return this.metadataRepository.findClassKindMetadataRecursively(beDecoratedCls, TargetCls, upward);
3390
+ var levels = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Infinity;
3391
+ return this.metadataRepository.findClassKindMetadataRecursively(beDecoratedCls, TargetCls, levels);
3377
3392
  }
3378
3393
  }, {
3379
3394
  key: "listBeDecoratedClsByClassKindMetadata",
@@ -3398,52 +3413,37 @@ var Application = /*#__PURE__*/function () {
3398
3413
  }
3399
3414
  // TODO: 支持多个组件初始化
3400
3415
  var bootComponent = bootComponents[0];
3401
- getComponents(this, {
3416
+ this.iocComponentFactory.getComponents(this, {
3402
3417
  classOrId: bootComponent
3403
3418
  });
3404
3419
  }
3405
3420
  }]);
3406
3421
  }();
3407
3422
 
3423
+ var _Class$o, _Bind3, _applyDecs$c$o;
3424
+ var _initClass$o, _Bind2;
3408
3425
  /**
3409
3426
  * @public
3410
3427
  */
3411
- var Bind = function () {
3412
- var _classDecorators = [id$2('Bind'), target([Target.Type.Method])];
3413
- var _classDescriptor;
3414
- var _classExtraInitializers = [];
3415
- var _classThis;
3416
- var _classSuper = Metadata;
3417
- _classThis = /*#__PURE__*/function (_classSuper2) {
3418
- function _classThis() {
3419
- _classCallCheck(this, _classThis);
3420
- return _callSuper(this, _classThis, arguments);
3421
- }
3422
- _inherits(_classThis, _classSuper2);
3423
- return _createClass(_classThis);
3424
- }(_classSuper);
3425
- __setFunctionName(_classThis, "Bind");
3426
- (function () {
3427
- var _a;
3428
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
3429
- __esDecorate(null, _classDescriptor = {
3430
- value: _classThis
3431
- }, _classDecorators, {
3432
- kind: "class",
3433
- name: _classThis.name,
3434
- metadata: _metadata
3435
- }, null, _classExtraInitializers);
3436
- _classThis = _classDescriptor.value;
3437
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
3438
- enumerable: true,
3439
- configurable: true,
3440
- writable: true,
3441
- value: _metadata
3442
- });
3443
- __runInitializers(_classThis, _classExtraInitializers);
3444
- })();
3445
- return _classThis;
3446
- }();
3428
+ var _Bind;
3429
+ new (_Bind2 = (_Bind3 = /*#__PURE__*/function (_Metadata) {
3430
+ function Bind() {
3431
+ _classCallCheck(this, Bind);
3432
+ return _callSuper(this, Bind, arguments);
3433
+ }
3434
+ _inherits(Bind, _Metadata);
3435
+ return _createClass(Bind);
3436
+ }(Metadata), _applyDecs$c$o = _slicedToArray(_applyDecs2311(_Bind3, [target([Target.Type.Method])], [], 0, void 0, Metadata).c, 2), _Bind = _applyDecs$c$o[0], _initClass$o = _applyDecs$c$o[1], _Bind3), _Class$o = /*#__PURE__*/function (_identity2) {
3437
+ function _Class() {
3438
+ var _this;
3439
+ _classCallCheck(this, _Class);
3440
+ _this = _callSuper(this, _Class, [_Bind]), _defineProperty(_assertThisInitialized(_this), "$$id", "Bind"), _initClass$o();
3441
+ return _this;
3442
+ }
3443
+ _inherits(_Class, _identity2);
3444
+ return _createClass(_Class);
3445
+ }(_identity), _defineProperty(_Class$o, _Bind2, void 0), _Class$o)();
3446
+ var Bind = _Bind;
3447
3447
 
3448
3448
  var bind = createDecoratorExp(Bind, {
3449
3449
  componentPostConstruct: function componentPostConstruct(metadata, application, field) {
@@ -3451,45 +3451,30 @@ var bind = createDecoratorExp(Bind, {
3451
3451
  }
3452
3452
  });
3453
3453
 
3454
+ var _Class$n, _Cookie3, _applyDecs$c$n;
3455
+ var _initClass$n, _Cookie2;
3454
3456
  /**
3455
3457
  * @public
3456
3458
  */
3457
- var Cookie = function () {
3458
- var _classDecorators = [id$2('Cookie'), target([Target.Type.Class]), component()];
3459
- var _classDescriptor;
3460
- var _classExtraInitializers = [];
3461
- var _classThis;
3462
- var _classSuper = Metadata;
3463
- _classThis = /*#__PURE__*/function (_classSuper2) {
3464
- function _classThis() {
3465
- _classCallCheck(this, _classThis);
3466
- return _callSuper(this, _classThis, arguments);
3467
- }
3468
- _inherits(_classThis, _classSuper2);
3469
- return _createClass(_classThis);
3470
- }(_classSuper);
3471
- __setFunctionName(_classThis, "Cookie");
3472
- (function () {
3473
- var _a;
3474
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
3475
- __esDecorate(null, _classDescriptor = {
3476
- value: _classThis
3477
- }, _classDecorators, {
3478
- kind: "class",
3479
- name: _classThis.name,
3480
- metadata: _metadata
3481
- }, null, _classExtraInitializers);
3482
- _classThis = _classDescriptor.value;
3483
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
3484
- enumerable: true,
3485
- configurable: true,
3486
- writable: true,
3487
- value: _metadata
3488
- });
3489
- __runInitializers(_classThis, _classExtraInitializers);
3490
- })();
3491
- return _classThis;
3492
- }();
3459
+ var _Cookie;
3460
+ new (_Cookie2 = (_Cookie3 = /*#__PURE__*/function (_Metadata) {
3461
+ function Cookie() {
3462
+ _classCallCheck(this, Cookie);
3463
+ return _callSuper(this, Cookie, arguments);
3464
+ }
3465
+ _inherits(Cookie, _Metadata);
3466
+ return _createClass(Cookie);
3467
+ }(Metadata), _applyDecs$c$n = _slicedToArray(_applyDecs2311(_Cookie3, [target([Target.Type.Class]), component()], [], 0, void 0, Metadata).c, 2), _Cookie = _applyDecs$c$n[0], _initClass$n = _applyDecs$c$n[1], _Cookie3), _Class$n = /*#__PURE__*/function (_identity2) {
3468
+ function _Class() {
3469
+ var _this;
3470
+ _classCallCheck(this, _Class);
3471
+ _this = _callSuper(this, _Class, [_Cookie]), _defineProperty(_assertThisInitialized(_this), "$$id", "Cookie"), _initClass$n();
3472
+ return _this;
3473
+ }
3474
+ _inherits(_Class, _identity2);
3475
+ return _createClass(_Class);
3476
+ }(_identity), _defineProperty(_Class$n, _Cookie2, void 0), _Class$n)();
3477
+ var Cookie = _Cookie;
3493
3478
 
3494
3479
  var cookie = createDecoratorExp(Cookie);
3495
3480
 
@@ -3719,196 +3704,139 @@ var Children = {
3719
3704
  forEach: forEachChildren
3720
3705
  };
3721
3706
 
3707
+ var _Class$m, _View3, _applyDecs$c$m;
3708
+ var _initClass$m, _View2;
3722
3709
  /**
3723
3710
  * @public
3724
3711
  */
3725
- var View = function () {
3726
- var _classDecorators = [id$2('View'), target([Target.Type.Class]), scope(exports.SCOPE.Prototype), component()];
3727
- var _classDescriptor;
3728
- var _classExtraInitializers = [];
3729
- var _classThis;
3730
- var _classSuper = Metadata;
3731
- _classThis = /*#__PURE__*/function (_classSuper2) {
3732
- function _classThis() {
3733
- _classCallCheck(this, _classThis);
3734
- return _callSuper(this, _classThis, arguments);
3735
- }
3736
- _inherits(_classThis, _classSuper2);
3737
- return _createClass(_classThis, null, [{
3738
- key: "classDecoratorModifyPrototype",
3739
- value:
3740
- // 当@view作为类装饰时,下面的函数将修改被装饰器的prototype
3741
- // TODO: View的复合装饰器也要支持的吧
3742
- function classDecoratorModifyPrototype(prototype) {
3743
- if (!prototype) {
3744
- prototype.updater = ReactNoopUpdateQueue;
3745
- }
3712
+ var _View;
3713
+ new (_View2 = (_View3 = /*#__PURE__*/function (_Metadata) {
3714
+ function View() {
3715
+ _classCallCheck(this, View);
3716
+ return _callSuper(this, View, arguments);
3717
+ }
3718
+ _inherits(View, _Metadata);
3719
+ return _createClass(View, null, [{
3720
+ key: "classDecoratorModifyPrototype",
3721
+ value:
3722
+ // 当@view作为类装饰时,下面的函数将修改被装饰器的prototype
3723
+ // TODO: View的复合装饰器也要支持的吧
3724
+ function classDecoratorModifyPrototype(prototype) {
3725
+ if (!prototype) {
3726
+ prototype.updater = ReactNoopUpdateQueue;
3746
3727
  }
3747
- }]);
3748
- }(_classSuper);
3749
- __setFunctionName(_classThis, "View");
3750
- (function () {
3751
- var _a;
3752
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
3753
- __esDecorate(null, _classDescriptor = {
3754
- value: _classThis
3755
- }, _classDecorators, {
3756
- kind: "class",
3757
- name: _classThis.name,
3758
- metadata: _metadata
3759
- }, null, _classExtraInitializers);
3760
- _classThis = _classDescriptor.value;
3761
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
3762
- enumerable: true,
3763
- configurable: true,
3764
- writable: true,
3765
- value: _metadata
3766
- });
3767
- __runInitializers(_classThis, _classExtraInitializers);
3768
- })();
3769
- return _classThis;
3770
- }();
3728
+ }
3729
+ }]);
3730
+ }(Metadata), _applyDecs$c$m = _slicedToArray(_applyDecs2311(_View3, [target([Target.Type.Class]), scope(exports.SCOPE.Prototype), component()], [], 0, void 0, Metadata).c, 2), _View = _applyDecs$c$m[0], _initClass$m = _applyDecs$c$m[1], _View3), _Class$m = /*#__PURE__*/function (_identity2) {
3731
+ function _Class() {
3732
+ var _this;
3733
+ _classCallCheck(this, _Class);
3734
+ _this = _callSuper(this, _Class, [_View]), _defineProperty(_assertThisInitialized(_this), "$$id", "View"), _initClass$m();
3735
+ return _this;
3736
+ }
3737
+ _inherits(_Class, _identity2);
3738
+ return _createClass(_Class);
3739
+ }(_identity), _defineProperty(_Class$m, _View2, void 0), _Class$m)();
3740
+ var View = _View;
3771
3741
 
3772
3742
  var view = createDecoratorExp(View);
3773
3743
 
3744
+ var _Class$l, _Layout3, _applyDecs$c$l;
3745
+ var _initClass$l, _Layout2;
3774
3746
  /**
3775
3747
  * @public
3776
3748
  */
3777
- var Layout = function () {
3778
- var _classDecorators = [id$2('Layout'), target([Target.Type.Class]), view()];
3779
- var _classDescriptor;
3780
- var _classExtraInitializers = [];
3781
- var _classThis;
3782
- var _classSuper = Metadata;
3783
- _classThis = /*#__PURE__*/function (_classSuper2) {
3784
- function _classThis() {
3785
- _classCallCheck(this, _classThis);
3786
- return _callSuper(this, _classThis, arguments);
3787
- }
3788
- _inherits(_classThis, _classSuper2);
3789
- return _createClass(_classThis);
3790
- }(_classSuper);
3791
- __setFunctionName(_classThis, "Layout");
3792
- (function () {
3793
- var _a;
3794
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
3795
- __esDecorate(null, _classDescriptor = {
3796
- value: _classThis
3797
- }, _classDecorators, {
3798
- kind: "class",
3799
- name: _classThis.name,
3800
- metadata: _metadata
3801
- }, null, _classExtraInitializers);
3802
- _classThis = _classDescriptor.value;
3803
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
3804
- enumerable: true,
3805
- configurable: true,
3806
- writable: true,
3807
- value: _metadata
3808
- });
3809
- __runInitializers(_classThis, _classExtraInitializers);
3810
- })();
3811
- return _classThis;
3812
- }();
3749
+ var _Layout;
3750
+ new (_Layout2 = (_Layout3 = /*#__PURE__*/function (_Metadata) {
3751
+ function Layout() {
3752
+ _classCallCheck(this, Layout);
3753
+ return _callSuper(this, Layout, arguments);
3754
+ }
3755
+ _inherits(Layout, _Metadata);
3756
+ return _createClass(Layout);
3757
+ }(Metadata), _applyDecs$c$l = _slicedToArray(_applyDecs2311(_Layout3, [target([Target.Type.Class]), view()], [], 0, void 0, Metadata).c, 2), _Layout = _applyDecs$c$l[0], _initClass$l = _applyDecs$c$l[1], _Layout3), _Class$l = /*#__PURE__*/function (_identity2) {
3758
+ function _Class() {
3759
+ var _this;
3760
+ _classCallCheck(this, _Class);
3761
+ _this = _callSuper(this, _Class, [_Layout]), _defineProperty(_assertThisInitialized(_this), "$$id", "Layout"), _initClass$l();
3762
+ return _this;
3763
+ }
3764
+ _inherits(_Class, _identity2);
3765
+ return _createClass(_Class);
3766
+ }(_identity), _defineProperty(_Class$l, _Layout2, void 0), _Class$l)();
3767
+ var Layout = _Layout;
3813
3768
 
3814
3769
  var layout = createDecoratorExp(Layout);
3815
3770
 
3771
+ var _Class$k, _LocalStorage3, _applyDecs$c$k;
3772
+ var _initClass$k, _LocalStorage2;
3816
3773
  /**
3817
3774
  * @public
3818
3775
  */
3819
- var LocalStorage = function () {
3820
- var _classDecorators = [id$2('LocalStorage'), target([Target.Type.Class]), component()];
3821
- var _classDescriptor;
3822
- var _classExtraInitializers = [];
3823
- var _classThis;
3824
- var _classSuper = Metadata;
3825
- _classThis = /*#__PURE__*/function (_classSuper2) {
3826
- function _classThis() {
3827
- _classCallCheck(this, _classThis);
3828
- return _callSuper(this, _classThis, arguments);
3829
- }
3830
- _inherits(_classThis, _classSuper2);
3831
- return _createClass(_classThis);
3832
- }(_classSuper);
3833
- __setFunctionName(_classThis, "LocalStorage");
3834
- (function () {
3835
- var _a;
3836
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
3837
- __esDecorate(null, _classDescriptor = {
3838
- value: _classThis
3839
- }, _classDecorators, {
3840
- kind: "class",
3841
- name: _classThis.name,
3842
- metadata: _metadata
3843
- }, null, _classExtraInitializers);
3844
- _classThis = _classDescriptor.value;
3845
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
3846
- enumerable: true,
3847
- configurable: true,
3848
- writable: true,
3849
- value: _metadata
3850
- });
3851
- __runInitializers(_classThis, _classExtraInitializers);
3852
- })();
3853
- return _classThis;
3854
- }();
3776
+ var _LocalStorage;
3777
+ new (_LocalStorage2 = (_LocalStorage3 = /*#__PURE__*/function (_Metadata) {
3778
+ function LocalStorage() {
3779
+ _classCallCheck(this, LocalStorage);
3780
+ return _callSuper(this, LocalStorage, arguments);
3781
+ }
3782
+ _inherits(LocalStorage, _Metadata);
3783
+ return _createClass(LocalStorage);
3784
+ }(Metadata), _applyDecs$c$k = _slicedToArray(_applyDecs2311(_LocalStorage3, [target([Target.Type.Class]), component()], [], 0, void 0, Metadata).c, 2), _LocalStorage = _applyDecs$c$k[0], _initClass$k = _applyDecs$c$k[1], _LocalStorage3), _Class$k = /*#__PURE__*/function (_identity2) {
3785
+ function _Class() {
3786
+ var _this;
3787
+ _classCallCheck(this, _Class);
3788
+ _this = _callSuper(this, _Class, [_LocalStorage]), _defineProperty(_assertThisInitialized(_this), "$$id", "LocalStorage"), _initClass$k();
3789
+ return _this;
3790
+ }
3791
+ _inherits(_Class, _identity2);
3792
+ return _createClass(_Class);
3793
+ }(_identity), _defineProperty(_Class$k, _LocalStorage2, void 0), _Class$k)();
3794
+ var LocalStorage = _LocalStorage;
3855
3795
 
3856
3796
  var localStorage = createDecoratorExp(LocalStorage);
3857
3797
 
3798
+ var _Class$j, _Memoized3, _applyDecs$c$j;
3799
+ var _initClass$j, _Memoized2;
3858
3800
  /**
3859
3801
  * @public
3860
3802
  */
3861
- var Memoized = function () {
3862
- var _classDecorators = [id$2('Memoized'), target([Target.Type.Method])];
3863
- var _classDescriptor;
3864
- var _classExtraInitializers = [];
3865
- var _classThis;
3866
- var _classSuper = Metadata;
3867
- _classThis = /*#__PURE__*/function (_classSuper2) {
3868
- function _classThis() {
3869
- _classCallCheck(this, _classThis);
3870
- return _callSuper(this, _classThis, arguments);
3871
- }
3872
- _inherits(_classThis, _classSuper2);
3873
- return _createClass(_classThis);
3874
- }(_classSuper);
3875
- __setFunctionName(_classThis, "Memoized");
3876
- (function () {
3877
- var _a;
3878
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
3879
- __esDecorate(null, _classDescriptor = {
3880
- value: _classThis
3881
- }, _classDecorators, {
3882
- kind: "class",
3883
- name: _classThis.name,
3884
- metadata: _metadata
3885
- }, null, _classExtraInitializers);
3886
- _classThis = _classDescriptor.value;
3887
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
3888
- enumerable: true,
3889
- configurable: true,
3890
- writable: true,
3891
- value: _metadata
3892
- });
3893
- __runInitializers(_classThis, _classExtraInitializers);
3894
- })();
3895
- return _classThis;
3896
- }();
3803
+ var _Memoized;
3804
+ new (_Memoized2 = (_Memoized3 = /*#__PURE__*/function (_Metadata) {
3805
+ function Memoized() {
3806
+ _classCallCheck(this, Memoized);
3807
+ return _callSuper(this, Memoized, arguments);
3808
+ }
3809
+ _inherits(Memoized, _Metadata);
3810
+ return _createClass(Memoized);
3811
+ }(Metadata), _applyDecs$c$j = _slicedToArray(_applyDecs2311(_Memoized3, [target([Target.Type.Method])], [], 0, void 0, Metadata).c, 2), _Memoized = _applyDecs$c$j[0], _initClass$j = _applyDecs$c$j[1], _Memoized3), _Class$j = /*#__PURE__*/function (_identity2) {
3812
+ function _Class() {
3813
+ var _this;
3814
+ _classCallCheck(this, _Class);
3815
+ _this = _callSuper(this, _Class, [_Memoized]), _defineProperty(_assertThisInitialized(_this), "$$id", "Memoized"), _initClass$j();
3816
+ return _this;
3817
+ }
3818
+ _inherits(_Class, _identity2);
3819
+ return _createClass(_Class);
3820
+ }(_identity), _defineProperty(_Class$j, _Memoized2, void 0), _Class$j)();
3821
+ var Memoized = _Memoized;
3897
3822
 
3898
3823
  var Subscriber = /*#__PURE__*/function () {
3899
3824
  function Subscriber(bindThisFn) {
3900
3825
  var _this = this;
3901
3826
  _classCallCheck(this, Subscriber);
3902
- this.isDirty = true;
3903
- this.publishers = [];
3904
- this.subscribe = function (publisher) {
3827
+ _defineProperty(this, "isDirty", true);
3828
+ _defineProperty(this, "publishers", []);
3829
+ // 组件方法,且绑定了fn对应的this
3830
+ _defineProperty(this, "fn", void 0);
3831
+ _defineProperty(this, "value", void 0);
3832
+ _defineProperty(this, "subscribe", function (publisher) {
3905
3833
  if (_this.publishers.indexOf(publisher) === -1) {
3906
3834
  publisher.addListener(_this);
3907
3835
  _this.publishers.push(publisher);
3908
3836
  }
3909
- };
3837
+ });
3910
3838
  // **必须是field,绑定当前this对象**
3911
- this.memoizedFn = function () {
3839
+ _defineProperty(this, "memoizedFn", function () {
3912
3840
  if (_this.isDirty) {
3913
3841
  {
3914
3842
  // clear
@@ -3938,7 +3866,7 @@ var Subscriber = /*#__PURE__*/function () {
3938
3866
  _this.isDirty = false;
3939
3867
  }
3940
3868
  return _this.value;
3941
- };
3869
+ });
3942
3870
  this.fn = bindThisFn;
3943
3871
  }
3944
3872
  return _createClass(Subscriber, [{
@@ -3948,6 +3876,7 @@ var Subscriber = /*#__PURE__*/function () {
3948
3876
  }
3949
3877
  }]);
3950
3878
  }();
3879
+ _defineProperty(Subscriber, "Executing", void 0);
3951
3880
 
3952
3881
  var memoized = createDecoratorExp(Memoized, {
3953
3882
  componentPostConstruct: function componentPostConstruct(metadata, application, field) {
@@ -3957,94 +3886,65 @@ var memoized = createDecoratorExp(Memoized, {
3957
3886
  }
3958
3887
  });
3959
3888
 
3889
+ var _Class$i, _Page3, _applyDecs$c$i;
3890
+ var _initClass$i, _Page2;
3960
3891
  /**
3961
3892
  * @public
3962
3893
  */
3963
- var Page = function () {
3964
- var _classDecorators = [id$2('Page'), target([Target.Type.Class]), view()];
3965
- var _classDescriptor;
3966
- var _classExtraInitializers = [];
3967
- var _classThis;
3968
- var _classSuper = Metadata;
3969
- _classThis = /*#__PURE__*/function (_classSuper2) {
3970
- function _classThis() {
3971
- _classCallCheck(this, _classThis);
3972
- return _callSuper(this, _classThis, arguments);
3973
- }
3974
- _inherits(_classThis, _classSuper2);
3975
- return _createClass(_classThis);
3976
- }(_classSuper);
3977
- __setFunctionName(_classThis, "Page");
3978
- (function () {
3979
- var _a;
3980
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
3981
- __esDecorate(null, _classDescriptor = {
3982
- value: _classThis
3983
- }, _classDecorators, {
3984
- kind: "class",
3985
- name: _classThis.name,
3986
- metadata: _metadata
3987
- }, null, _classExtraInitializers);
3988
- _classThis = _classDescriptor.value;
3989
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
3990
- enumerable: true,
3991
- configurable: true,
3992
- writable: true,
3993
- value: _metadata
3994
- });
3995
- __runInitializers(_classThis, _classExtraInitializers);
3996
- })();
3997
- return _classThis;
3998
- }();
3894
+ var _Page;
3895
+ new (_Page2 = (_Page3 = /*#__PURE__*/function (_Metadata) {
3896
+ function Page() {
3897
+ _classCallCheck(this, Page);
3898
+ return _callSuper(this, Page, arguments);
3899
+ }
3900
+ _inherits(Page, _Metadata);
3901
+ return _createClass(Page);
3902
+ }(Metadata), _applyDecs$c$i = _slicedToArray(_applyDecs2311(_Page3, [target([Target.Type.Class]), view()], [], 0, void 0, Metadata).c, 2), _Page = _applyDecs$c$i[0], _initClass$i = _applyDecs$c$i[1], _Page3), _Class$i = /*#__PURE__*/function (_identity2) {
3903
+ function _Class() {
3904
+ var _this;
3905
+ _classCallCheck(this, _Class);
3906
+ _this = _callSuper(this, _Class, [_Page]), _defineProperty(_assertThisInitialized(_this), "$$id", "Page"), _initClass$i();
3907
+ return _this;
3908
+ }
3909
+ _inherits(_Class, _identity2);
3910
+ return _createClass(_Class);
3911
+ }(_identity), _defineProperty(_Class$i, _Page2, void 0), _Class$i)();
3912
+ var Page = _Page;
3999
3913
 
4000
3914
  var page = createDecoratorExp(Page);
4001
3915
 
3916
+ var _Class$h, _Reactive3, _applyDecs$c$h;
3917
+ var _initClass$h, _Reactive2;
4002
3918
  /**
4003
3919
  * 加在field表明是响应式
4004
3920
  * 加在metadata上用于自定义reactive元数据
4005
3921
  * @public
4006
3922
  */
4007
- var Reactive = function () {
4008
- var _classDecorators = [id$2('Reactive'), target([Target.Type.Field])];
4009
- var _classDescriptor;
4010
- var _classExtraInitializers = [];
4011
- var _classThis;
4012
- var _classSuper = Metadata;
4013
- _classThis = /*#__PURE__*/function (_classSuper2) {
4014
- function _classThis() {
4015
- _classCallCheck(this, _classThis);
4016
- return _callSuper(this, _classThis, arguments);
4017
- }
4018
- _inherits(_classThis, _classSuper2);
4019
- return _createClass(_classThis);
4020
- }(_classSuper);
4021
- __setFunctionName(_classThis, "Reactive");
4022
- (function () {
4023
- var _a;
4024
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
4025
- __esDecorate(null, _classDescriptor = {
4026
- value: _classThis
4027
- }, _classDecorators, {
4028
- kind: "class",
4029
- name: _classThis.name,
4030
- metadata: _metadata
4031
- }, null, _classExtraInitializers);
4032
- _classThis = _classDescriptor.value;
4033
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
4034
- enumerable: true,
4035
- configurable: true,
4036
- writable: true,
4037
- value: _metadata
4038
- });
4039
- __runInitializers(_classThis, _classExtraInitializers);
4040
- })();
4041
- return _classThis;
4042
- }();
3923
+ var _Reactive;
3924
+ new (_Reactive2 = (_Reactive3 = /*#__PURE__*/function (_Metadata) {
3925
+ function Reactive() {
3926
+ _classCallCheck(this, Reactive);
3927
+ return _callSuper(this, Reactive, arguments);
3928
+ }
3929
+ _inherits(Reactive, _Metadata);
3930
+ return _createClass(Reactive);
3931
+ }(Metadata), _applyDecs$c$h = _slicedToArray(_applyDecs2311(_Reactive3, [target([Target.Type.Field])], [], 0, void 0, Metadata).c, 2), _Reactive = _applyDecs$c$h[0], _initClass$h = _applyDecs$c$h[1], _Reactive3), _Class$h = /*#__PURE__*/function (_identity2) {
3932
+ function _Class() {
3933
+ var _this;
3934
+ _classCallCheck(this, _Class);
3935
+ _this = _callSuper(this, _Class, [_Reactive]), _defineProperty(_assertThisInitialized(_this), "$$id", "Reactive"), _initClass$h();
3936
+ return _this;
3937
+ }
3938
+ _inherits(_Class, _identity2);
3939
+ return _createClass(_Class);
3940
+ }(_identity), _defineProperty(_Class$h, _Reactive2, void 0), _Class$h)();
3941
+ var Reactive = _Reactive;
4043
3942
 
4044
3943
  var Publisher = /*#__PURE__*/function () {
4045
3944
  function Publisher(name) {
4046
3945
  _classCallCheck(this, Publisher);
4047
- this.subscribers = [];
3946
+ _defineProperty(this, "name", void 0);
3947
+ _defineProperty(this, "subscribers", []);
4048
3948
  this.name = name;
4049
3949
  }
4050
3950
  return _createClass(Publisher, [{
@@ -4070,7 +3970,6 @@ var Publisher = /*#__PURE__*/function () {
4070
3970
  }]);
4071
3971
  }();
4072
3972
 
4073
- // TODO: props也使用此函数进行响应式
4074
3973
  function defineReactive(object, field, getter, setter) {
4075
3974
  var publisher = new Publisher();
4076
3975
  Object.defineProperty(object, field, {
@@ -4088,7 +3987,7 @@ function defineReactive(object, field, getter, setter) {
4088
3987
  return true;
4089
3988
  }
4090
3989
  publisher.notify();
4091
- setter === null || setter === void 0 ? void 0 : setter(object, field, newValue);
3990
+ setter === null || setter === void 0 || setter(object, field, newValue);
4092
3991
  return true;
4093
3992
  }
4094
3993
  });
@@ -4097,7 +3996,7 @@ function defineReactive(object, field, getter, setter) {
4097
3996
  var reactive = createDecoratorExp(Reactive, {
4098
3997
  componentPostConstruct: function componentPostConstruct(metadata, application, name) {
4099
3998
  var Store = application.getMetaClassById('Store');
4100
- var isStoreComponent = application.findClassKindMetadataRecursively(this.constructor, Store);
3999
+ var isStoreComponent = application.findClassKindMetadataRecursively(this.constructor, Store, 0);
4101
4000
  var value = this[name];
4102
4001
  var setter;
4103
4002
  var getter = function getter() {
@@ -4106,9 +4005,9 @@ var reactive = createDecoratorExp(Reactive, {
4106
4005
  if (isStoreComponent) {
4107
4006
  // store 组件目前是直接赋值,然后走forceUpdate逻辑的
4108
4007
  setter = function setter(object, key, newValue) {
4109
- var _a;
4008
+ var _object$storePublishe;
4110
4009
  value = newValue;
4111
- (_a = object['storePublisher']) === null || _a === void 0 ? void 0 : _a.broadcast();
4010
+ (_object$storePublishe = object['storePublisher']) === null || _object$storePublishe === void 0 || _object$storePublishe.broadcast();
4112
4011
  };
4113
4012
  } else {
4114
4013
  // 不是store组件目前可以都认为是视图组件,视图组件是走批量更新逻辑的
@@ -4128,45 +4027,30 @@ var reactive = createDecoratorExp(Reactive, {
4128
4027
  }
4129
4028
  });
4130
4029
 
4030
+ var _Class$g, _Ref3, _applyDecs$c$g;
4031
+ var _initClass$g, _Ref2;
4131
4032
  /**
4132
4033
  * @public
4133
4034
  */
4134
- var Ref$1 = function () {
4135
- var _classDecorators = [id$2('Ref'), target([Target.Type.Field])];
4136
- var _classDescriptor;
4137
- var _classExtraInitializers = [];
4138
- var _classThis;
4139
- var _classSuper = Metadata;
4140
- _classThis = /*#__PURE__*/function (_classSuper2) {
4141
- function _classThis() {
4142
- _classCallCheck(this, _classThis);
4143
- return _callSuper(this, _classThis, arguments);
4144
- }
4145
- _inherits(_classThis, _classSuper2);
4146
- return _createClass(_classThis);
4147
- }(_classSuper);
4148
- __setFunctionName(_classThis, "Ref");
4149
- (function () {
4150
- var _a;
4151
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
4152
- __esDecorate(null, _classDescriptor = {
4153
- value: _classThis
4154
- }, _classDecorators, {
4155
- kind: "class",
4156
- name: _classThis.name,
4157
- metadata: _metadata
4158
- }, null, _classExtraInitializers);
4159
- _classThis = _classDescriptor.value;
4160
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
4161
- enumerable: true,
4162
- configurable: true,
4163
- writable: true,
4164
- value: _metadata
4165
- });
4166
- __runInitializers(_classThis, _classExtraInitializers);
4167
- })();
4168
- return _classThis;
4169
- }();
4035
+ var _Ref;
4036
+ new (_Ref2 = (_Ref3 = /*#__PURE__*/function (_Metadata) {
4037
+ function Ref() {
4038
+ _classCallCheck(this, Ref);
4039
+ return _callSuper(this, Ref, arguments);
4040
+ }
4041
+ _inherits(Ref, _Metadata);
4042
+ return _createClass(Ref);
4043
+ }(Metadata), _applyDecs$c$g = _slicedToArray(_applyDecs2311(_Ref3, [target([Target.Type.Field])], [], 0, void 0, Metadata).c, 2), _Ref = _applyDecs$c$g[0], _initClass$g = _applyDecs$c$g[1], _Ref3), _Class$g = /*#__PURE__*/function (_identity2) {
4044
+ function _Class() {
4045
+ var _this;
4046
+ _classCallCheck(this, _Class);
4047
+ _this = _callSuper(this, _Class, [_Ref]), _defineProperty(_assertThisInitialized(_this), "$$id", "Ref"), _initClass$g();
4048
+ return _this;
4049
+ }
4050
+ _inherits(_Class, _identity2);
4051
+ return _createClass(_Class);
4052
+ }(_identity), _defineProperty(_Class$g, _Ref2, void 0), _Class$g)();
4053
+ var Ref$1 = _Ref;
4170
4054
 
4171
4055
  var ref = createDecoratorExp(Ref$1, {
4172
4056
  componentPostConstruct: function componentPostConstruct(metadata, application, field) {
@@ -4176,45 +4060,30 @@ var ref = createDecoratorExp(Ref$1, {
4176
4060
  }
4177
4061
  });
4178
4062
 
4063
+ var _Class$f, _Refs3, _applyDecs$c$f;
4064
+ var _initClass$f, _Refs2;
4179
4065
  /**
4180
4066
  * @public
4181
4067
  */
4182
- var Refs = function () {
4183
- var _classDecorators = [id$2('Refs'), target([Target.Type.Field])];
4184
- var _classDescriptor;
4185
- var _classExtraInitializers = [];
4186
- var _classThis;
4187
- var _classSuper = Metadata;
4188
- _classThis = /*#__PURE__*/function (_classSuper2) {
4189
- function _classThis() {
4190
- _classCallCheck(this, _classThis);
4191
- return _callSuper(this, _classThis, arguments);
4192
- }
4193
- _inherits(_classThis, _classSuper2);
4194
- return _createClass(_classThis);
4195
- }(_classSuper);
4196
- __setFunctionName(_classThis, "Refs");
4197
- (function () {
4198
- var _a;
4199
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
4200
- __esDecorate(null, _classDescriptor = {
4201
- value: _classThis
4202
- }, _classDecorators, {
4203
- kind: "class",
4204
- name: _classThis.name,
4205
- metadata: _metadata
4206
- }, null, _classExtraInitializers);
4207
- _classThis = _classDescriptor.value;
4208
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
4209
- enumerable: true,
4210
- configurable: true,
4211
- writable: true,
4212
- value: _metadata
4213
- });
4214
- __runInitializers(_classThis, _classExtraInitializers);
4215
- })();
4216
- return _classThis;
4217
- }();
4068
+ var _Refs;
4069
+ new (_Refs2 = (_Refs3 = /*#__PURE__*/function (_Metadata) {
4070
+ function Refs() {
4071
+ _classCallCheck(this, Refs);
4072
+ return _callSuper(this, Refs, arguments);
4073
+ }
4074
+ _inherits(Refs, _Metadata);
4075
+ return _createClass(Refs);
4076
+ }(Metadata), _applyDecs$c$f = _slicedToArray(_applyDecs2311(_Refs3, [target([Target.Type.Field])], [], 0, void 0, Metadata).c, 2), _Refs = _applyDecs$c$f[0], _initClass$f = _applyDecs$c$f[1], _Refs3), _Class$f = /*#__PURE__*/function (_identity2) {
4077
+ function _Class() {
4078
+ var _this;
4079
+ _classCallCheck(this, _Class);
4080
+ _this = _callSuper(this, _Class, [_Refs]), _defineProperty(_assertThisInitialized(_this), "$$id", "Refs"), _initClass$f();
4081
+ return _this;
4082
+ }
4083
+ _inherits(_Class, _identity2);
4084
+ return _createClass(_Class);
4085
+ }(_identity), _defineProperty(_Class$f, _Refs2, void 0), _Class$f)();
4086
+ var Refs = _Refs;
4218
4087
 
4219
4088
  var refs = createDecoratorExp(Refs, {
4220
4089
  componentPostConstruct: function componentPostConstruct(metadata, application, field) {
@@ -4222,93 +4091,64 @@ var refs = createDecoratorExp(Refs, {
4222
4091
  }
4223
4092
  });
4224
4093
 
4094
+ var _Class$e, _SessionStorage3, _applyDecs$c$e;
4095
+ var _initClass$e, _SessionStorage2;
4225
4096
  /**
4226
4097
  * @public
4227
4098
  */
4228
- var SessionStorage = function () {
4229
- var _classDecorators = [id$2('SessionStorage'), target([Target.Type.Class]), component()];
4230
- var _classDescriptor;
4231
- var _classExtraInitializers = [];
4232
- var _classThis;
4233
- var _classSuper = Metadata;
4234
- _classThis = /*#__PURE__*/function (_classSuper2) {
4235
- function _classThis() {
4236
- _classCallCheck(this, _classThis);
4237
- return _callSuper(this, _classThis, arguments);
4238
- }
4239
- _inherits(_classThis, _classSuper2);
4240
- return _createClass(_classThis);
4241
- }(_classSuper);
4242
- __setFunctionName(_classThis, "SessionStorage");
4243
- (function () {
4244
- var _a;
4245
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
4246
- __esDecorate(null, _classDescriptor = {
4247
- value: _classThis
4248
- }, _classDecorators, {
4249
- kind: "class",
4250
- name: _classThis.name,
4251
- metadata: _metadata
4252
- }, null, _classExtraInitializers);
4253
- _classThis = _classDescriptor.value;
4254
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
4255
- enumerable: true,
4256
- configurable: true,
4257
- writable: true,
4258
- value: _metadata
4259
- });
4260
- __runInitializers(_classThis, _classExtraInitializers);
4261
- })();
4262
- return _classThis;
4263
- }();
4099
+ var _SessionStorage;
4100
+ new (_SessionStorage2 = (_SessionStorage3 = /*#__PURE__*/function (_Metadata) {
4101
+ function SessionStorage() {
4102
+ _classCallCheck(this, SessionStorage);
4103
+ return _callSuper(this, SessionStorage, arguments);
4104
+ }
4105
+ _inherits(SessionStorage, _Metadata);
4106
+ return _createClass(SessionStorage);
4107
+ }(Metadata), _applyDecs$c$e = _slicedToArray(_applyDecs2311(_SessionStorage3, [target([Target.Type.Class]), component()], [], 0, void 0, Metadata).c, 2), _SessionStorage = _applyDecs$c$e[0], _initClass$e = _applyDecs$c$e[1], _SessionStorage3), _Class$e = /*#__PURE__*/function (_identity2) {
4108
+ function _Class() {
4109
+ var _this;
4110
+ _classCallCheck(this, _Class);
4111
+ _this = _callSuper(this, _Class, [_SessionStorage]), _defineProperty(_assertThisInitialized(_this), "$$id", "SessionStorage"), _initClass$e();
4112
+ return _this;
4113
+ }
4114
+ _inherits(_Class, _identity2);
4115
+ return _createClass(_Class);
4116
+ }(_identity), _defineProperty(_Class$e, _SessionStorage2, void 0), _Class$e)();
4117
+ var SessionStorage = _SessionStorage;
4264
4118
 
4265
4119
  var sessionStorage = createDecoratorExp(SessionStorage);
4266
4120
 
4121
+ var _Class$d, _Store3, _applyDecs$c$d;
4122
+ var _initClass$d, _Store2;
4267
4123
  /**
4268
4124
  * @public
4269
4125
  */
4270
- var Store = function () {
4271
- var _classDecorators = [id$2('Store'), target([Target.Type.Class]), component()];
4272
- var _classDescriptor;
4273
- var _classExtraInitializers = [];
4274
- var _classThis;
4275
- var _classSuper = Metadata;
4276
- _classThis = /*#__PURE__*/function (_classSuper2) {
4277
- function _classThis() {
4278
- _classCallCheck(this, _classThis);
4279
- return _callSuper(this, _classThis, arguments);
4280
- }
4281
- _inherits(_classThis, _classSuper2);
4282
- return _createClass(_classThis);
4283
- }(_classSuper);
4284
- __setFunctionName(_classThis, "Store");
4285
- (function () {
4286
- var _a;
4287
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
4288
- __esDecorate(null, _classDescriptor = {
4289
- value: _classThis
4290
- }, _classDecorators, {
4291
- kind: "class",
4292
- name: _classThis.name,
4293
- metadata: _metadata
4294
- }, null, _classExtraInitializers);
4295
- _classThis = _classDescriptor.value;
4296
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
4297
- enumerable: true,
4298
- configurable: true,
4299
- writable: true,
4300
- value: _metadata
4301
- });
4302
- __runInitializers(_classThis, _classExtraInitializers);
4303
- })();
4304
- return _classThis;
4305
- }();
4126
+ var _Store;
4127
+ new (_Store2 = (_Store3 = /*#__PURE__*/function (_Metadata) {
4128
+ function Store() {
4129
+ _classCallCheck(this, Store);
4130
+ return _callSuper(this, Store, arguments);
4131
+ }
4132
+ _inherits(Store, _Metadata);
4133
+ return _createClass(Store);
4134
+ }(Metadata), _applyDecs$c$d = _slicedToArray(_applyDecs2311(_Store3, [target([Target.Type.Class]), component()], [], 0, void 0, Metadata).c, 2), _Store = _applyDecs$c$d[0], _initClass$d = _applyDecs$c$d[1], _Store3), _Class$d = /*#__PURE__*/function (_identity2) {
4135
+ function _Class() {
4136
+ var _this;
4137
+ _classCallCheck(this, _Class);
4138
+ _this = _callSuper(this, _Class, [_Store]), _defineProperty(_assertThisInitialized(_this), "$$id", "Store"), _initClass$d();
4139
+ return _this;
4140
+ }
4141
+ _inherits(_Class, _identity2);
4142
+ return _createClass(_Class);
4143
+ }(_identity), _defineProperty(_Class$d, _Store2, void 0), _Class$d)();
4144
+ var Store = _Store;
4306
4145
 
4307
4146
  var id$1 = 0;
4308
4147
  var StorePublisher = /*#__PURE__*/function () {
4309
4148
  function StorePublisher() {
4310
4149
  _classCallCheck(this, StorePublisher);
4311
- this.subscribers = [];
4150
+ _defineProperty(this, "id", void 0);
4151
+ _defineProperty(this, "subscribers", []);
4312
4152
  this.id = id$1++;
4313
4153
  }
4314
4154
  return _createClass(StorePublisher, [{
@@ -4368,7 +4208,9 @@ var id = 0;
4368
4208
  var StoreSubscriber = /*#__PURE__*/function () {
4369
4209
  function StoreSubscriber(runner) {
4370
4210
  _classCallCheck(this, StoreSubscriber);
4371
- this.publishers = [];
4211
+ _defineProperty(this, "id", void 0);
4212
+ _defineProperty(this, "publishers", []);
4213
+ _defineProperty(this, "runner", void 0);
4372
4214
  this.id = id++;
4373
4215
  this.runner = runner;
4374
4216
  }
@@ -4401,123 +4243,92 @@ var StoreSubscriber = /*#__PURE__*/function () {
4401
4243
  }]);
4402
4244
  }();
4403
4245
 
4404
- var Router$1 = function () {
4405
- var _classDecorators = [id$2('Router'), target([Target.Type.Class]), component()];
4406
- var _classDescriptor;
4407
- var _classExtraInitializers = [];
4408
- var _classThis;
4409
- var _classSuper = Metadata;
4410
- _classThis = /*#__PURE__*/function (_classSuper2) {
4411
- function _classThis() {
4412
- _classCallCheck(this, _classThis);
4413
- return _callSuper(this, _classThis, arguments);
4414
- }
4415
- _inherits(_classThis, _classSuper2);
4416
- return _createClass(_classThis);
4417
- }(_classSuper);
4418
- __setFunctionName(_classThis, "Router");
4419
- (function () {
4420
- var _a;
4421
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
4422
- __esDecorate(null, _classDescriptor = {
4423
- value: _classThis
4424
- }, _classDecorators, {
4425
- kind: "class",
4426
- name: _classThis.name,
4427
- metadata: _metadata
4428
- }, null, _classExtraInitializers);
4429
- _classThis = _classDescriptor.value;
4430
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
4431
- enumerable: true,
4432
- configurable: true,
4433
- writable: true,
4434
- value: _metadata
4435
- });
4436
- __runInitializers(_classThis, _classExtraInitializers);
4437
- })();
4438
- return _classThis;
4439
- }();
4440
-
4246
+ var _Class$c, _Router3$1, _applyDecs$c$c;
4247
+ var _initClass$c, _Router2$1;
4248
+ var _Router$1;
4249
+ new (_Router2$1 = (_Router3$1 = /*#__PURE__*/function (_Metadata) {
4250
+ function Router() {
4251
+ _classCallCheck(this, Router);
4252
+ return _callSuper(this, Router, arguments);
4253
+ }
4254
+ _inherits(Router, _Metadata);
4255
+ return _createClass(Router);
4256
+ }(Metadata), _applyDecs$c$c = _slicedToArray(_applyDecs2311(_Router3$1, [target([Target.Type.Class]), component()], [], 0, void 0, Metadata).c, 2), _Router$1 = _applyDecs$c$c[0], _initClass$c = _applyDecs$c$c[1], _Router3$1), _Class$c = /*#__PURE__*/function (_identity2) {
4257
+ function _Class() {
4258
+ var _this;
4259
+ _classCallCheck(this, _Class);
4260
+ _this = _callSuper(this, _Class, [_Router$1]), _defineProperty(_assertThisInitialized(_this), "$$id", "Router"), _initClass$c();
4261
+ return _this;
4262
+ }
4263
+ _inherits(_Class, _identity2);
4264
+ return _createClass(_Class);
4265
+ }(_identity), _defineProperty(_Class$c, _Router2$1, void 0), _Class$c)();
4266
+ var Router$1 = _Router$1;
4267
+
4268
+ var _Class$b, _Route3$1, _applyDecs$c$b;
4269
+ var _initClass$b, _Route2$1;
4441
4270
  /**
4442
4271
  * @public
4443
4272
  */
4444
- var Route$1 = function () {
4445
- var _classDecorators = [id$2('Route'), target([Target.Type.Class])];
4446
- var _classDescriptor;
4447
- var _classExtraInitializers = [];
4448
- var _classThis;
4449
- var _classSuper = Metadata;
4450
- _classThis = /*#__PURE__*/function (_classSuper2) {
4451
- function _classThis() {
4452
- _classCallCheck(this, _classThis);
4453
- return _callSuper(this, _classThis, arguments);
4454
- }
4455
- _inherits(_classThis, _classSuper2);
4456
- return _createClass(_classThis);
4457
- }(_classSuper);
4458
- __setFunctionName(_classThis, "Route");
4459
- (function () {
4460
- var _a;
4461
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
4462
- __esDecorate(null, _classDescriptor = {
4463
- value: _classThis
4464
- }, _classDecorators, {
4465
- kind: "class",
4466
- name: _classThis.name,
4467
- metadata: _metadata
4468
- }, null, _classExtraInitializers);
4469
- _classThis = _classDescriptor.value;
4470
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
4471
- enumerable: true,
4472
- configurable: true,
4473
- writable: true,
4474
- value: _metadata
4475
- });
4476
- __runInitializers(_classThis, _classExtraInitializers);
4477
- })();
4478
- return _classThis;
4479
- }();
4480
-
4481
- var route = createDecoratorExp(Route$1);
4273
+ var _Route$1;
4274
+ new (_Route2$1 = (_Route3$1 = /*#__PURE__*/function (_Metadata) {
4275
+ function Route() {
4276
+ var _this;
4277
+ _classCallCheck(this, Route);
4278
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4279
+ args[_key] = arguments[_key];
4280
+ }
4281
+ _this = _callSuper(this, Route, [].concat(args));
4282
+ _defineProperty(_this, "value", void 0);
4283
+ return _this;
4284
+ }
4285
+ _inherits(Route, _Metadata);
4286
+ return _createClass(Route);
4287
+ }(Metadata), _applyDecs$c$b = _slicedToArray(_applyDecs2311(_Route3$1, [target([Target.Type.Class])], [], 0, void 0, Metadata).c, 2), _Route$1 = _applyDecs$c$b[0], _initClass$b = _applyDecs$c$b[1], _Route3$1), _Class$b = /*#__PURE__*/function (_identity2) {
4288
+ function _Class() {
4289
+ var _this2;
4290
+ _classCallCheck(this, _Class);
4291
+ _this2 = _callSuper(this, _Class, [_Route$1]), _defineProperty(_assertThisInitialized(_this2), "$$id", "Route"), _initClass$b();
4292
+ return _this2;
4293
+ }
4294
+ _inherits(_Class, _identity2);
4295
+ return _createClass(_Class);
4296
+ }(_identity), _defineProperty(_Class$b, _Route2$1, void 0), _Class$b)();
4297
+ var RouteMeta = _Route$1;
4298
+
4299
+ var route = createDecoratorExp(RouteMeta);
4482
4300
 
4483
4301
  var router = createDecoratorExp(Router$1);
4484
4302
 
4303
+ var _Class$a, _Router3, _applyDecs$c$a;
4304
+ var _initClass$a, _Router2;
4485
4305
  /**
4486
4306
  * @public
4487
4307
  */
4488
- var Router = function () {
4489
- var _classDecorators = [router()];
4490
- var _classDescriptor;
4491
- var _classExtraInitializers = [];
4492
- var _classThis;
4493
- _classThis = /*#__PURE__*/_createClass(function _classThis() {
4494
- _classCallCheck(this, _classThis);
4495
- });
4496
- __setFunctionName(_classThis, "Router");
4497
- (function () {
4498
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
4499
- __esDecorate(null, _classDescriptor = {
4500
- value: _classThis
4501
- }, _classDecorators, {
4502
- kind: "class",
4503
- name: _classThis.name,
4504
- metadata: _metadata
4505
- }, null, _classExtraInitializers);
4506
- _classThis = _classDescriptor.value;
4507
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
4508
- enumerable: true,
4509
- configurable: true,
4510
- writable: true,
4511
- value: _metadata
4512
- });
4513
- __runInitializers(_classThis, _classExtraInitializers);
4514
- })();
4515
- return _classThis;
4516
- }();
4308
+ var _Router;
4309
+ new (_Router2 = (_Router3 = /*#__PURE__*/_createClass(function Router() {
4310
+ _classCallCheck(this, Router);
4311
+ _defineProperty(this, "route", void 0);
4312
+ _defineProperty(this, "render", void 0);
4313
+ _defineProperty(this, "routeComponentMapper", void 0);
4314
+ }), _applyDecs$c$a = _slicedToArray(_applyDecs2311(_Router3, [router()], []).c, 2), _Router = _applyDecs$c$a[0], _initClass$a = _applyDecs$c$a[1], _Router3), _Class$a = /*#__PURE__*/function (_identity2) {
4315
+ function _Class() {
4316
+ var _this;
4317
+ _classCallCheck(this, _Class);
4318
+ _this = _callSuper(this, _Class, [_Router]), _defineProperty(_assertThisInitialized(_this), "$$id", "Router"), _initClass$a();
4319
+ return _this;
4320
+ }
4321
+ _inherits(_Class, _identity2);
4322
+ return _createClass(_Class);
4323
+ }(_identity), _defineProperty(_Class$a, _Router2, void 0), _Class$a)();
4324
+ var Router = _Router;
4517
4325
 
4518
4326
  var DynamicRoute = /*#__PURE__*/function () {
4327
+ // pathname通过/拆分而来
4519
4328
  function DynamicRoute(url) {
4520
4329
  _classCallCheck(this, DynamicRoute);
4330
+ _defineProperty(this, "regExp", void 0);
4331
+ _defineProperty(this, "paths", void 0);
4521
4332
  if (!url.includes(':')) {
4522
4333
  throw new Error('不包含:,不需要使用正则匹配');
4523
4334
  }
@@ -4561,7 +4372,7 @@ var DynamicRoute = /*#__PURE__*/function () {
4561
4372
  var RouteComponentMapper = /*#__PURE__*/function () {
4562
4373
  function RouteComponentMapper() {
4563
4374
  _classCallCheck(this, RouteComponentMapper);
4564
- this.mapper = new Map();
4375
+ _defineProperty(this, "mapper", new Map());
4565
4376
  }
4566
4377
  return _createClass(RouteComponentMapper, [{
4567
4378
  key: "init",
@@ -4630,109 +4441,70 @@ var RouteComponentMapper = /*#__PURE__*/function () {
4630
4441
  }]);
4631
4442
  }();
4632
4443
 
4633
- var Route = function () {
4634
- var _classDecorators = [store()];
4635
- var _classDescriptor;
4636
- var _classExtraInitializers = [];
4637
- var _classThis;
4638
- _classThis = /*#__PURE__*/_createClass(function _classThis() {
4639
- _classCallCheck(this, _classThis);
4640
- // 动态路由参数
4641
- this.params = {};
4642
- });
4643
- __setFunctionName(_classThis, "Route");
4644
- (function () {
4645
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
4646
- __esDecorate(null, _classDescriptor = {
4647
- value: _classThis
4648
- }, _classDecorators, {
4649
- kind: "class",
4650
- name: _classThis.name,
4651
- metadata: _metadata
4652
- }, null, _classExtraInitializers);
4653
- _classThis = _classDescriptor.value;
4654
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
4655
- enumerable: true,
4656
- configurable: true,
4657
- writable: true,
4658
- value: _metadata
4659
- });
4660
- __runInitializers(_classThis, _classExtraInitializers);
4661
- })();
4662
- return _classThis;
4663
- }();
4664
-
4665
- var Render$1 = function () {
4666
- var _classDecorators = [id$2('Render'), target([Target.Type.Class]), component()];
4667
- var _classDescriptor;
4668
- var _classExtraInitializers = [];
4669
- var _classThis;
4670
- var _classSuper = Metadata;
4671
- _classThis = /*#__PURE__*/function (_classSuper2) {
4672
- function _classThis() {
4673
- _classCallCheck(this, _classThis);
4674
- return _callSuper(this, _classThis, arguments);
4675
- }
4676
- _inherits(_classThis, _classSuper2);
4677
- return _createClass(_classThis);
4678
- }(_classSuper);
4679
- __setFunctionName(_classThis, "Render");
4680
- (function () {
4681
- var _a;
4682
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
4683
- __esDecorate(null, _classDescriptor = {
4684
- value: _classThis
4685
- }, _classDecorators, {
4686
- kind: "class",
4687
- name: _classThis.name,
4688
- metadata: _metadata
4689
- }, null, _classExtraInitializers);
4690
- _classThis = _classDescriptor.value;
4691
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
4692
- enumerable: true,
4693
- configurable: true,
4694
- writable: true,
4695
- value: _metadata
4696
- });
4697
- __runInitializers(_classThis, _classExtraInitializers);
4698
- })();
4699
- return _classThis;
4700
- }();
4444
+ var _Class$9, _Route3, _applyDecs$c$9;
4445
+ var _initClass$9, _Route2;
4446
+ var _Route;
4447
+ new (_Route2 = (_Route3 = /*#__PURE__*/_createClass(function Route() {
4448
+ _classCallCheck(this, Route);
4449
+ // window.location.pathname
4450
+ _defineProperty(this, "pathname", void 0);
4451
+ // 动态路由参数
4452
+ _defineProperty(this, "params", {});
4453
+ }), _applyDecs$c$9 = _slicedToArray(_applyDecs2311(_Route3, [store()], []).c, 2), _Route = _applyDecs$c$9[0], _initClass$9 = _applyDecs$c$9[1], _Route3), _Class$9 = /*#__PURE__*/function (_identity2) {
4454
+ function _Class() {
4455
+ var _this;
4456
+ _classCallCheck(this, _Class);
4457
+ _this = _callSuper(this, _Class, [_Route]), _defineProperty(_assertThisInitialized(_this), "$$id", "Route"), _initClass$9();
4458
+ return _this;
4459
+ }
4460
+ _inherits(_Class, _identity2);
4461
+ return _createClass(_Class);
4462
+ }(_identity), _defineProperty(_Class$9, _Route2, void 0), _Class$9)();
4463
+ var Route = _Route;
4464
+
4465
+ var _Class$8, _Render3$1, _applyDecs$c$8;
4466
+ var _initClass$8, _Render2$1;
4467
+ var _Render$1;
4468
+ new (_Render2$1 = (_Render3$1 = /*#__PURE__*/function (_Metadata) {
4469
+ function Render() {
4470
+ _classCallCheck(this, Render);
4471
+ return _callSuper(this, Render, arguments);
4472
+ }
4473
+ _inherits(Render, _Metadata);
4474
+ return _createClass(Render);
4475
+ }(Metadata), _applyDecs$c$8 = _slicedToArray(_applyDecs2311(_Render3$1, [target([Target.Type.Class]), component()], [], 0, void 0, Metadata).c, 2), _Render$1 = _applyDecs$c$8[0], _initClass$8 = _applyDecs$c$8[1], _Render3$1), _Class$8 = /*#__PURE__*/function (_identity2) {
4476
+ function _Class() {
4477
+ var _this;
4478
+ _classCallCheck(this, _Class);
4479
+ _this = _callSuper(this, _Class, [_Render$1]), _defineProperty(_assertThisInitialized(_this), "$$id", "Render"), _initClass$8();
4480
+ return _this;
4481
+ }
4482
+ _inherits(_Class, _identity2);
4483
+ return _createClass(_Class);
4484
+ }(_identity), _defineProperty(_Class$8, _Render2$1, void 0), _Class$8)();
4485
+ var Render$1 = _Render$1;
4701
4486
 
4702
4487
  var render$1 = createDecoratorExp(Render$1);
4703
4488
 
4489
+ var _Class$7, _Render3, _applyDecs$c$7;
4490
+ var _initClass$7, _Render2;
4704
4491
  /**
4705
4492
  * @public
4706
4493
  */
4707
- var Render = function () {
4708
- var _classDecorators = [render$1()];
4709
- var _classDescriptor;
4710
- var _classExtraInitializers = [];
4711
- var _classThis;
4712
- _classThis = /*#__PURE__*/_createClass(function _classThis() {
4713
- _classCallCheck(this, _classThis);
4714
- });
4715
- __setFunctionName(_classThis, "Render");
4716
- (function () {
4717
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
4718
- __esDecorate(null, _classDescriptor = {
4719
- value: _classThis
4720
- }, _classDecorators, {
4721
- kind: "class",
4722
- name: _classThis.name,
4723
- metadata: _metadata
4724
- }, null, _classExtraInitializers);
4725
- _classThis = _classDescriptor.value;
4726
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
4727
- enumerable: true,
4728
- configurable: true,
4729
- writable: true,
4730
- value: _metadata
4731
- });
4732
- __runInitializers(_classThis, _classExtraInitializers);
4733
- })();
4734
- return _classThis;
4735
- }();
4494
+ var _Render;
4495
+ new (_Render2 = (_Render3 = /*#__PURE__*/_createClass(function Render() {
4496
+ _classCallCheck(this, Render);
4497
+ }), _applyDecs$c$7 = _slicedToArray(_applyDecs2311(_Render3, [render$1()], []).c, 2), _Render = _applyDecs$c$7[0], _initClass$7 = _applyDecs$c$7[1], _Render3), _Class$7 = /*#__PURE__*/function (_identity2) {
4498
+ function _Class() {
4499
+ var _this;
4500
+ _classCallCheck(this, _Class);
4501
+ _this = _callSuper(this, _Class, [_Render]), _defineProperty(_assertThisInitialized(_this), "$$id", "Render"), _initClass$7();
4502
+ return _this;
4503
+ }
4504
+ _inherits(_Class, _identity2);
4505
+ return _createClass(_Class);
4506
+ }(_identity), _defineProperty(_Class$7, _Render2, void 0), _Class$7)();
4507
+ var Render = _Render;
4736
4508
 
4737
4509
  /**
4738
4510
  * Mapping from registration name to event name
@@ -7523,7 +7295,7 @@ function connectStore(ctor, instance) {
7523
7295
  var Store = application.getMetaClassById('Store');
7524
7296
  // 过滤出所有注入的store
7525
7297
  var stores = autowiredComponents.filter(Boolean).filter(function (comp) {
7526
- return application.findClassKindMetadataRecursively(comp.constructor, Store);
7298
+ return application.findClassKindMetadataRecursively(comp.constructor, Store, 0);
7527
7299
  });
7528
7300
  // store去重
7529
7301
  var uniqueStores = stores.filter(function (s, idx) {
@@ -7561,6 +7333,7 @@ function disconnectStore(instance) {
7561
7333
  */
7562
7334
  var NoReactiveProps = ['children'];
7563
7335
  function initProps(instance, newProps) {
7336
+ // TODO: 添加 props 相关测试用例
7564
7337
  instance.props = newProps;
7565
7338
  var _values = {};
7566
7339
  var _loop = function _loop() {
@@ -7568,26 +7341,14 @@ function initProps(instance, newProps) {
7568
7341
  if (NoReactiveProps.indexOf(field) !== -1) {
7569
7342
  return 1; // continue
7570
7343
  }
7571
- var publisher = new Publisher();
7572
7344
  _values[field] = newProps[field];
7573
- Object.defineProperty(instance.props, field, {
7574
- configurable: false,
7575
- enumerable: true,
7576
- get: function get() {
7577
- if (Subscriber.Executing) {
7578
- Subscriber.Executing.subscribe(publisher);
7579
- }
7580
- return _values[field];
7581
- },
7582
- set: function set(v) {
7583
- if (_values[field] === v || v !== v && _values[field] !== _values[field]) {
7584
- return true;
7585
- }
7586
- _values[field] = v;
7587
- publisher.notify();
7588
- return true;
7589
- }
7590
- });
7345
+ var getter = function getter() {
7346
+ return _values[field];
7347
+ };
7348
+ var setter = function setter(object, key, newValue) {
7349
+ _values[field] = newValue;
7350
+ };
7351
+ defineReactive(instance.props, field, getter, setter);
7591
7352
  };
7592
7353
  for (var _i = 0, _Object$keys = Object.keys(newProps); _i < _Object$keys.length; _i++) {
7593
7354
  if (_loop()) continue;
@@ -8948,348 +8709,249 @@ function render(element, container) {
8948
8709
  return legacyRenderSubtreeIntoContainer(null, element, container);
8949
8710
  }
8950
8711
 
8712
+ var _Class$6, _WebRender3, _applyDecs$c$6;
8713
+ var _initClass$6, _WebRender2;
8951
8714
  /**
8952
8715
  * @public
8953
8716
  */
8954
- var WebRender = function () {
8955
- var _classDecorators = [render$1()];
8956
- var _classDescriptor;
8957
- var _classExtraInitializers = [];
8958
- var _classThis;
8959
- var _classSuper = Render;
8960
- _classThis = /*#__PURE__*/function (_classSuper2) {
8961
- function _classThis() {
8962
- _classCallCheck(this, _classThis);
8963
- return _callSuper(this, _classThis, arguments);
8964
- }
8965
- _inherits(_classThis, _classSuper2);
8966
- return _createClass(_classThis, [{
8967
- key: "init",
8968
- value: function init(application) {
8969
- registerCommonApi(application);
8970
- this.container = document.getElementById('root');
8971
- if (!this.container) {
8972
- console.error('未找到根节点');
8973
- }
8717
+ var _WebRender;
8718
+ new (_WebRender2 = (_WebRender3 = /*#__PURE__*/function (_Render) {
8719
+ function WebRender() {
8720
+ var _this;
8721
+ _classCallCheck(this, WebRender);
8722
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
8723
+ args[_key] = arguments[_key];
8724
+ }
8725
+ _this = _callSuper(this, WebRender, [].concat(args));
8726
+ _defineProperty(_this, "container", void 0);
8727
+ return _this;
8728
+ }
8729
+ _inherits(WebRender, _Render);
8730
+ return _createClass(WebRender, [{
8731
+ key: "init",
8732
+ value: function init(application) {
8733
+ registerCommonApi(application);
8734
+ this.container = document.getElementById('root');
8735
+ if (!this.container) {
8736
+ console.error('未找到根节点');
8974
8737
  }
8975
- }, {
8976
- key: "render",
8977
- value: function render$1(component) {
8978
- return render(jsx(component, undefined), this.container);
8979
- }
8980
- }]);
8981
- }(_classSuper);
8982
- __setFunctionName(_classThis, "WebRender");
8983
- (function () {
8984
- var _a;
8985
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
8986
- __esDecorate(null, _classDescriptor = {
8987
- value: _classThis
8988
- }, _classDecorators, {
8989
- kind: "class",
8990
- name: _classThis.name,
8991
- metadata: _metadata
8992
- }, null, _classExtraInitializers);
8993
- _classThis = _classDescriptor.value;
8994
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
8995
- enumerable: true,
8996
- configurable: true,
8997
- writable: true,
8998
- value: _metadata
8999
- });
9000
- __runInitializers(_classThis, _classExtraInitializers);
9001
- })();
9002
- return _classThis;
9003
- }();
9004
-
8738
+ }
8739
+ }, {
8740
+ key: "render",
8741
+ value: function render$1(component) {
8742
+ return render(jsx(component, undefined), this.container);
8743
+ }
8744
+ }]);
8745
+ }(Render), _applyDecs$c$6 = _slicedToArray(_applyDecs2311(_WebRender3, [render$1()], [], 0, void 0, Render).c, 2), _WebRender = _applyDecs$c$6[0], _initClass$6 = _applyDecs$c$6[1], _WebRender3), _Class$6 = /*#__PURE__*/function (_identity2) {
8746
+ function _Class() {
8747
+ var _this2;
8748
+ _classCallCheck(this, _Class);
8749
+ _this2 = _callSuper(this, _Class, [_WebRender]), _defineProperty(_assertThisInitialized(_this2), "$$id", "WebRender"), _initClass$6();
8750
+ return _this2;
8751
+ }
8752
+ _inherits(_Class, _identity2);
8753
+ return _createClass(_Class);
8754
+ }(_identity), _defineProperty(_Class$6, _WebRender2, void 0), _Class$6)();
8755
+ var _WebRender$1 = _WebRender;
8756
+
8757
+ var _Class$5, _HistoryRouter3, _applyDecs$c$5;
8758
+ var _initClass$5, _HistoryRouter2;
9005
8759
  /**
9006
8760
  * @public
9007
8761
  */
9008
- var HistoryRouter = function () {
9009
- var _classDecorators = [router(), constructorParam([Render])];
9010
- var _classDescriptor;
9011
- var _classExtraInitializers = [];
9012
- var _classThis;
9013
- var _classSuper = Router;
9014
- _classThis = /*#__PURE__*/function (_classSuper2) {
9015
- function _classThis(render) {
9016
- var _this;
9017
- _classCallCheck(this, _classThis);
9018
- _this = _callSuper(this, _classThis);
9019
- _this.handleRouteChange = function () {
9020
- var pathname = window.location.pathname;
9021
- var _this$routeComponentM = _this.routeComponentMapper.match(pathname),
9022
- pageComponent = _this$routeComponentM.pageComponent,
9023
- params = _this$routeComponentM.params;
9024
- _this.route.pathname = pathname;
9025
- _this.route.params = params || {};
9026
- if (pageComponent) {
9027
- _this.render.render(pageComponent);
9028
- }
9029
- };
9030
- _this.render = render;
9031
- return _this;
9032
- }
9033
- _inherits(_classThis, _classSuper2);
9034
- return _createClass(_classThis, [{
9035
- key: "init",
9036
- value: function init(application) {
9037
- var routeComponentMap = application.listBeDecoratedClsByClassKindMetadata(Route$1);
9038
- this.routeComponentMapper = new RouteComponentMapper();
9039
- this.routeComponentMapper.init(routeComponentMap);
9040
- this.route = application.getComponent(Route);
9041
- }
9042
- }, {
9043
- key: "start",
9044
- value: function start() {
9045
- window.addEventListener('popstate', this.handleRouteChange);
9046
- // 初始化渲染
9047
- this.handleRouteChange();
9048
- }
9049
- }, {
9050
- key: "removeListener",
9051
- value: function removeListener() {
9052
- window.removeEventListener('popstate', this.handleRouteChange);
9053
- }
9054
- }, {
9055
- key: "navigateTo",
9056
- value: function navigateTo(url) {
9057
- window.history.pushState({}, '', url);
9058
- this.handleRouteChange();
9059
- }
9060
- }]);
9061
- }(_classSuper);
9062
- __setFunctionName(_classThis, "HistoryRouter");
9063
- (function () {
9064
- var _a;
9065
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
9066
- __esDecorate(null, _classDescriptor = {
9067
- value: _classThis
9068
- }, _classDecorators, {
9069
- kind: "class",
9070
- name: _classThis.name,
9071
- metadata: _metadata
9072
- }, null, _classExtraInitializers);
9073
- _classThis = _classDescriptor.value;
9074
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
9075
- enumerable: true,
9076
- configurable: true,
9077
- writable: true,
9078
- value: _metadata
8762
+ var _HistoryRouter;
8763
+ new (_HistoryRouter2 = (_HistoryRouter3 = /*#__PURE__*/function (_Router) {
8764
+ function HistoryRouter(render) {
8765
+ var _this;
8766
+ _classCallCheck(this, HistoryRouter);
8767
+ _this = _callSuper(this, HistoryRouter);
8768
+ _defineProperty(_this, "handleRouteChange", function () {
8769
+ var pathname = window.location.pathname;
8770
+ var _this$routeComponentM = _this.routeComponentMapper.match(pathname),
8771
+ pageComponent = _this$routeComponentM.pageComponent,
8772
+ params = _this$routeComponentM.params;
8773
+ _this.route.pathname = pathname;
8774
+ _this.route.params = params || {};
8775
+ if (pageComponent) {
8776
+ _this.render.render(pageComponent);
8777
+ }
9079
8778
  });
9080
- __runInitializers(_classThis, _classExtraInitializers);
9081
- })();
9082
- return _classThis;
9083
- }();
9084
-
8779
+ _this.render = render;
8780
+ return _this;
8781
+ }
8782
+ _inherits(HistoryRouter, _Router);
8783
+ return _createClass(HistoryRouter, [{
8784
+ key: "init",
8785
+ value: function init(application) {
8786
+ var routeComponentMap = application.listBeDecoratedClsByClassKindMetadata(RouteMeta);
8787
+ this.routeComponentMapper = new RouteComponentMapper();
8788
+ this.routeComponentMapper.init(routeComponentMap);
8789
+ this.route = application.getComponent(Route);
8790
+ }
8791
+ }, {
8792
+ key: "start",
8793
+ value: function start() {
8794
+ window.addEventListener('popstate', this.handleRouteChange);
8795
+ // 初始化渲染
8796
+ this.handleRouteChange();
8797
+ }
8798
+ }, {
8799
+ key: "removeListener",
8800
+ value: function removeListener() {
8801
+ window.removeEventListener('popstate', this.handleRouteChange);
8802
+ }
8803
+ }, {
8804
+ key: "navigateTo",
8805
+ value: function navigateTo(url) {
8806
+ window.history.pushState({}, '', url);
8807
+ this.handleRouteChange();
8808
+ }
8809
+ }]);
8810
+ }(Router), _applyDecs$c$5 = _slicedToArray(_applyDecs2311(_HistoryRouter3, [router(), constructorParam([Render])], [], 0, void 0, Router).c, 2), _HistoryRouter = _applyDecs$c$5[0], _initClass$5 = _applyDecs$c$5[1], _HistoryRouter3), _Class$5 = /*#__PURE__*/function (_identity2) {
8811
+ function _Class() {
8812
+ var _this2;
8813
+ _classCallCheck(this, _Class);
8814
+ _this2 = _callSuper(this, _Class, [_HistoryRouter]), _defineProperty(_assertThisInitialized(_this2), "$$id", "HistoryRouter"), _initClass$5();
8815
+ return _this2;
8816
+ }
8817
+ _inherits(_Class, _identity2);
8818
+ return _createClass(_Class);
8819
+ }(_identity), _defineProperty(_Class$5, _HistoryRouter2, void 0), _Class$5)();
8820
+ var _HistoryRouter$1 = _HistoryRouter;
8821
+
8822
+ var _Class$4, _Util3, _applyDecs$c$4;
8823
+ var _initClass$4, _Util2;
9085
8824
  /**
9086
8825
  * @public
9087
8826
  */
9088
- var Util = function () {
9089
- var _classDecorators = [id$2('Util'), target([Target.Type.Class]), component()];
9090
- var _classDescriptor;
9091
- var _classExtraInitializers = [];
9092
- var _classThis;
9093
- var _classSuper = Metadata;
9094
- _classThis = /*#__PURE__*/function (_classSuper2) {
9095
- function _classThis() {
9096
- _classCallCheck(this, _classThis);
9097
- return _callSuper(this, _classThis, arguments);
9098
- }
9099
- _inherits(_classThis, _classSuper2);
9100
- return _createClass(_classThis);
9101
- }(_classSuper);
9102
- __setFunctionName(_classThis, "Util");
9103
- (function () {
9104
- var _a;
9105
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
9106
- __esDecorate(null, _classDescriptor = {
9107
- value: _classThis
9108
- }, _classDecorators, {
9109
- kind: "class",
9110
- name: _classThis.name,
9111
- metadata: _metadata
9112
- }, null, _classExtraInitializers);
9113
- _classThis = _classDescriptor.value;
9114
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
9115
- enumerable: true,
9116
- configurable: true,
9117
- writable: true,
9118
- value: _metadata
9119
- });
9120
- __runInitializers(_classThis, _classExtraInitializers);
9121
- })();
9122
- return _classThis;
9123
- }();
8827
+ var _Util;
8828
+ new (_Util2 = (_Util3 = /*#__PURE__*/function (_Metadata) {
8829
+ function Util() {
8830
+ _classCallCheck(this, Util);
8831
+ return _callSuper(this, Util, arguments);
8832
+ }
8833
+ _inherits(Util, _Metadata);
8834
+ return _createClass(Util);
8835
+ }(Metadata), _applyDecs$c$4 = _slicedToArray(_applyDecs2311(_Util3, [target([Target.Type.Class]), component()], [], 0, void 0, Metadata).c, 2), _Util = _applyDecs$c$4[0], _initClass$4 = _applyDecs$c$4[1], _Util3), _Class$4 = /*#__PURE__*/function (_identity2) {
8836
+ function _Class() {
8837
+ var _this;
8838
+ _classCallCheck(this, _Class);
8839
+ _this = _callSuper(this, _Class, [_Util]), _defineProperty(_assertThisInitialized(_this), "$$id", "Util"), _initClass$4();
8840
+ return _this;
8841
+ }
8842
+ _inherits(_Class, _identity2);
8843
+ return _createClass(_Class);
8844
+ }(_identity), _defineProperty(_Class$4, _Util2, void 0), _Class$4)();
8845
+ var Util = _Util;
9124
8846
 
9125
8847
  var util = createDecoratorExp(Util);
9126
8848
 
8849
+ var _Class$3, _Api3, _applyDecs$c$3;
8850
+ var _initClass$3, _Api2;
9127
8851
  /**
9128
8852
  * @public
9129
8853
  */
9130
- var Api = function () {
9131
- var _classDecorators = [id$2('Api'), target([Target.Type.Class]), util()];
9132
- var _classDescriptor;
9133
- var _classExtraInitializers = [];
9134
- var _classThis;
9135
- var _classSuper = Metadata;
9136
- _classThis = /*#__PURE__*/function (_classSuper2) {
9137
- function _classThis() {
9138
- _classCallCheck(this, _classThis);
9139
- return _callSuper(this, _classThis, arguments);
9140
- }
9141
- _inherits(_classThis, _classSuper2);
9142
- return _createClass(_classThis);
9143
- }(_classSuper);
9144
- __setFunctionName(_classThis, "Api");
9145
- (function () {
9146
- var _a;
9147
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
9148
- __esDecorate(null, _classDescriptor = {
9149
- value: _classThis
9150
- }, _classDecorators, {
9151
- kind: "class",
9152
- name: _classThis.name,
9153
- metadata: _metadata
9154
- }, null, _classExtraInitializers);
9155
- _classThis = _classDescriptor.value;
9156
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
9157
- enumerable: true,
9158
- configurable: true,
9159
- writable: true,
9160
- value: _metadata
9161
- });
9162
- __runInitializers(_classThis, _classExtraInitializers);
9163
- })();
9164
- return _classThis;
9165
- }();
8854
+ var _Api;
8855
+ new (_Api2 = (_Api3 = /*#__PURE__*/function (_Metadata) {
8856
+ function Api() {
8857
+ _classCallCheck(this, Api);
8858
+ return _callSuper(this, Api, arguments);
8859
+ }
8860
+ _inherits(Api, _Metadata);
8861
+ return _createClass(Api);
8862
+ }(Metadata), _applyDecs$c$3 = _slicedToArray(_applyDecs2311(_Api3, [target([Target.Type.Class]), util()], [], 0, void 0, Metadata).c, 2), _Api = _applyDecs$c$3[0], _initClass$3 = _applyDecs$c$3[1], _Api3), _Class$3 = /*#__PURE__*/function (_identity2) {
8863
+ function _Class() {
8864
+ var _this;
8865
+ _classCallCheck(this, _Class);
8866
+ _this = _callSuper(this, _Class, [_Api]), _defineProperty(_assertThisInitialized(_this), "$$id", "Api"), _initClass$3();
8867
+ return _this;
8868
+ }
8869
+ _inherits(_Class, _identity2);
8870
+ return _createClass(_Class);
8871
+ }(_identity), _defineProperty(_Class$3, _Api2, void 0), _Class$3)();
8872
+ var Api = _Api;
9166
8873
 
9167
8874
  var api = createDecoratorExp(Api);
9168
8875
 
8876
+ var _Class$2, _Flow3, _applyDecs$c$2;
8877
+ var _initClass$2, _Flow2;
9169
8878
  /**
9170
8879
  * @public
9171
8880
  */
9172
- var Flow = function () {
9173
- var _classDecorators = [id$2('Flow'), target([Target.Type.Class]), component(), scope(exports.SCOPE.Prototype)];
9174
- var _classDescriptor;
9175
- var _classExtraInitializers = [];
9176
- var _classThis;
9177
- var _classSuper = Metadata;
9178
- _classThis = /*#__PURE__*/function (_classSuper2) {
9179
- function _classThis() {
9180
- _classCallCheck(this, _classThis);
9181
- return _callSuper(this, _classThis, arguments);
9182
- }
9183
- _inherits(_classThis, _classSuper2);
9184
- return _createClass(_classThis);
9185
- }(_classSuper);
9186
- __setFunctionName(_classThis, "Flow");
9187
- (function () {
9188
- var _a;
9189
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
9190
- __esDecorate(null, _classDescriptor = {
9191
- value: _classThis
9192
- }, _classDecorators, {
9193
- kind: "class",
9194
- name: _classThis.name,
9195
- metadata: _metadata
9196
- }, null, _classExtraInitializers);
9197
- _classThis = _classDescriptor.value;
9198
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
9199
- enumerable: true,
9200
- configurable: true,
9201
- writable: true,
9202
- value: _metadata
9203
- });
9204
- __runInitializers(_classThis, _classExtraInitializers);
9205
- })();
9206
- return _classThis;
9207
- }();
8881
+ var _Flow;
8882
+ new (_Flow2 = (_Flow3 = /*#__PURE__*/function (_Metadata) {
8883
+ function Flow() {
8884
+ _classCallCheck(this, Flow);
8885
+ return _callSuper(this, Flow, arguments);
8886
+ }
8887
+ _inherits(Flow, _Metadata);
8888
+ return _createClass(Flow);
8889
+ }(Metadata), _applyDecs$c$2 = _slicedToArray(_applyDecs2311(_Flow3, [target([Target.Type.Class]), component(), scope(exports.SCOPE.Prototype)], [], 0, void 0, Metadata).c, 2), _Flow = _applyDecs$c$2[0], _initClass$2 = _applyDecs$c$2[1], _Flow3), _Class$2 = /*#__PURE__*/function (_identity2) {
8890
+ function _Class() {
8891
+ var _this;
8892
+ _classCallCheck(this, _Class);
8893
+ _this = _callSuper(this, _Class, [_Flow]), _defineProperty(_assertThisInitialized(_this), "$$id", "Flow"), _initClass$2();
8894
+ return _this;
8895
+ }
8896
+ _inherits(_Class, _identity2);
8897
+ return _createClass(_Class);
8898
+ }(_identity), _defineProperty(_Class$2, _Flow2, void 0), _Class$2)();
8899
+ var Flow = _Flow;
9208
8900
 
9209
8901
  var flow = createDecoratorExp(Flow);
9210
8902
 
8903
+ var _Class$1, _GlobalData3, _applyDecs$c$1;
8904
+ var _initClass$1, _GlobalData2;
9211
8905
  // TODO: view 包添加 viewData装饰器
9212
8906
  /**
9213
8907
  * @public
9214
8908
  */
9215
- var GlobalData = function () {
9216
- var _classDecorators = [id$2('GlobalData'), target([Target.Type.Class]), component()];
9217
- var _classDescriptor;
9218
- var _classExtraInitializers = [];
9219
- var _classThis;
9220
- var _classSuper = Metadata;
9221
- _classThis = /*#__PURE__*/function (_classSuper2) {
9222
- function _classThis() {
9223
- _classCallCheck(this, _classThis);
9224
- return _callSuper(this, _classThis, arguments);
9225
- }
9226
- _inherits(_classThis, _classSuper2);
9227
- return _createClass(_classThis);
9228
- }(_classSuper);
9229
- __setFunctionName(_classThis, "GlobalData");
9230
- (function () {
9231
- var _a;
9232
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
9233
- __esDecorate(null, _classDescriptor = {
9234
- value: _classThis
9235
- }, _classDecorators, {
9236
- kind: "class",
9237
- name: _classThis.name,
9238
- metadata: _metadata
9239
- }, null, _classExtraInitializers);
9240
- _classThis = _classDescriptor.value;
9241
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
9242
- enumerable: true,
9243
- configurable: true,
9244
- writable: true,
9245
- value: _metadata
9246
- });
9247
- __runInitializers(_classThis, _classExtraInitializers);
9248
- })();
9249
- return _classThis;
9250
- }();
8909
+ var _GlobalData;
8910
+ new (_GlobalData2 = (_GlobalData3 = /*#__PURE__*/function (_Metadata) {
8911
+ function GlobalData() {
8912
+ _classCallCheck(this, GlobalData);
8913
+ return _callSuper(this, GlobalData, arguments);
8914
+ }
8915
+ _inherits(GlobalData, _Metadata);
8916
+ return _createClass(GlobalData);
8917
+ }(Metadata), _applyDecs$c$1 = _slicedToArray(_applyDecs2311(_GlobalData3, [target([Target.Type.Class]), component()], [], 0, void 0, Metadata).c, 2), _GlobalData = _applyDecs$c$1[0], _initClass$1 = _applyDecs$c$1[1], _GlobalData3), _Class$1 = /*#__PURE__*/function (_identity2) {
8918
+ function _Class() {
8919
+ var _this;
8920
+ _classCallCheck(this, _Class);
8921
+ _this = _callSuper(this, _Class, [_GlobalData]), _defineProperty(_assertThisInitialized(_this), "$$id", "GlobalData"), _initClass$1();
8922
+ return _this;
8923
+ }
8924
+ _inherits(_Class, _identity2);
8925
+ return _createClass(_Class);
8926
+ }(_identity), _defineProperty(_Class$1, _GlobalData2, void 0), _Class$1)();
8927
+ var GlobalData = _GlobalData;
9251
8928
 
9252
8929
  var globalData = createDecoratorExp(GlobalData);
9253
8930
 
8931
+ var _Class, _WebApplication3, _applyDecs$c;
8932
+ var _initClass, _WebApplication2;
9254
8933
  /**
9255
8934
  * @public
9256
8935
  */
9257
- var WebApplication = function () {
9258
- var _classDecorators = [id$2('WebApplication'), target([Target.Type.Class]), configuration()];
9259
- var _classDescriptor;
9260
- var _classExtraInitializers = [];
9261
- var _classThis;
9262
- var _classSuper = Metadata;
9263
- _classThis = /*#__PURE__*/function (_classSuper2) {
9264
- function _classThis() {
9265
- _classCallCheck(this, _classThis);
9266
- return _callSuper(this, _classThis, arguments);
9267
- }
9268
- _inherits(_classThis, _classSuper2);
9269
- return _createClass(_classThis);
9270
- }(_classSuper);
9271
- __setFunctionName(_classThis, "WebApplication");
9272
- (function () {
9273
- var _a;
9274
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
9275
- __esDecorate(null, _classDescriptor = {
9276
- value: _classThis
9277
- }, _classDecorators, {
9278
- kind: "class",
9279
- name: _classThis.name,
9280
- metadata: _metadata
9281
- }, null, _classExtraInitializers);
9282
- _classThis = _classDescriptor.value;
9283
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
9284
- enumerable: true,
9285
- configurable: true,
9286
- writable: true,
9287
- value: _metadata
9288
- });
9289
- __runInitializers(_classThis, _classExtraInitializers);
9290
- })();
9291
- return _classThis;
9292
- }();
8936
+ var _WebApplication;
8937
+ new (_WebApplication2 = (_WebApplication3 = /*#__PURE__*/function (_Metadata) {
8938
+ function WebApplication() {
8939
+ _classCallCheck(this, WebApplication);
8940
+ return _callSuper(this, WebApplication, arguments);
8941
+ }
8942
+ _inherits(WebApplication, _Metadata);
8943
+ return _createClass(WebApplication);
8944
+ }(Metadata), _applyDecs$c = _slicedToArray(_applyDecs2311(_WebApplication3, [target([Target.Type.Class]), configuration()], [], 0, void 0, Metadata).c, 2), _WebApplication = _applyDecs$c[0], _initClass = _applyDecs$c[1], _WebApplication3), _Class = /*#__PURE__*/function (_identity2) {
8945
+ function _Class() {
8946
+ var _this;
8947
+ _classCallCheck(this, _Class);
8948
+ _this = _callSuper(this, _Class, [_WebApplication]), _defineProperty(_assertThisInitialized(_this), "$$id", "WebApplication"), _initClass();
8949
+ return _this;
8950
+ }
8951
+ _inherits(_Class, _identity2);
8952
+ return _createClass(_Class);
8953
+ }(_identity), _defineProperty(_Class, _WebApplication2, void 0), _Class)();
8954
+ var WebApplication = _WebApplication;
9293
8955
 
9294
8956
  var webApplication = createDecoratorExp(WebApplication);
9295
8957
 
@@ -9304,7 +8966,7 @@ exports.ConstructorParam = ConstructorParam;
9304
8966
  exports.Cookie = Cookie;
9305
8967
  exports.Flow = Flow;
9306
8968
  exports.GlobalData = GlobalData;
9307
- exports.HistoryRouter = HistoryRouter;
8969
+ exports.HistoryRouter = _HistoryRouter$1;
9308
8970
  exports.Id = Id;
9309
8971
  exports.KindClass = KindClass;
9310
8972
  exports.KindField = KindField;
@@ -9315,7 +8977,6 @@ exports.Memoized = Memoized;
9315
8977
  exports.Metadata = Metadata;
9316
8978
  exports.Page = Page;
9317
8979
  exports.PropertiesConfig = PropertiesConfig;
9318
- exports.Publisher = Publisher;
9319
8980
  exports.Qualifier = Qualifier;
9320
8981
  exports.ReactNoopUpdateQueue = ReactNoopUpdateQueue;
9321
8982
  exports.Reactive = Reactive;
@@ -9323,21 +8984,19 @@ exports.Ref = Ref$1;
9323
8984
  exports.Refs = Refs;
9324
8985
  exports.Render = Render;
9325
8986
  exports.Route = Route;
9326
- exports.RouteMeta = Route$1;
8987
+ exports.RouteMeta = RouteMeta;
9327
8988
  exports.Router = Router;
9328
8989
  exports.RouterMeta = Router$1;
9329
8990
  exports.Scope = Scope;
9330
8991
  exports.SessionStorage = SessionStorage;
9331
8992
  exports.Store = Store;
9332
- exports.StorePublisher = StorePublisher;
9333
8993
  exports.StoreSubscriber = StoreSubscriber;
9334
- exports.Subscriber = Subscriber;
9335
8994
  exports.Target = Target;
9336
8995
  exports.Util = Util;
9337
8996
  exports.Value = Value;
9338
8997
  exports.View = View;
9339
8998
  exports.WebApplication = WebApplication;
9340
- exports.WebRender = WebRender;
8999
+ exports.WebRender = _WebRender$1;
9341
9000
  exports.api = api;
9342
9001
  exports.autowired = autowired;
9343
9002
  exports.bind = bind;
@@ -9347,6 +9006,7 @@ exports.constructorParam = constructorParam;
9347
9006
  exports.cookie = cookie;
9348
9007
  exports.createDecoratorExp = createDecoratorExp;
9349
9008
  exports.createPlaceholderDecoratorExp = createPlaceholderDecoratorExp;
9009
+ exports.defineReactive = defineReactive;
9350
9010
  exports.flow = flow;
9351
9011
  exports.globalData = globalData;
9352
9012
  exports.id = id$2;