applyDecs2203R.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. var _typeof = require("./typeof.js")["default"];
  2. var setFunctionName = require("./setFunctionName.js");
  3. var toPropertyKey = require("./toPropertyKey.js");
  4. function applyDecs2203RFactory() {
  5. function createAddInitializerMethod(e, t) {
  6. return function (r) {
  7. !function (e, t) {
  8. if (e.v) throw Error("attempted to call addInitializer after decoration was finished");
  9. }(t), assertCallable(r, "An initializer"), e.push(r);
  10. };
  11. }
  12. function memberDec(e, t, r, n, a, i, o, s) {
  13. var c;
  14. switch (a) {
  15. case 1:
  16. c = "accessor";
  17. break;
  18. case 2:
  19. c = "method";
  20. break;
  21. case 3:
  22. c = "getter";
  23. break;
  24. case 4:
  25. c = "setter";
  26. break;
  27. default:
  28. c = "field";
  29. }
  30. var l,
  31. u,
  32. f = {
  33. kind: c,
  34. name: o ? "#" + t : toPropertyKey(t),
  35. "static": i,
  36. "private": o
  37. },
  38. p = {
  39. v: !1
  40. };
  41. 0 !== a && (f.addInitializer = createAddInitializerMethod(n, p)), 0 === a ? o ? (l = r.get, u = r.set) : (l = function l() {
  42. return this[t];
  43. }, u = function u(e) {
  44. this[t] = e;
  45. }) : 2 === a ? l = function l() {
  46. return r.value;
  47. } : (1 !== a && 3 !== a || (l = function l() {
  48. return r.get.call(this);
  49. }), 1 !== a && 4 !== a || (u = function u(e) {
  50. r.set.call(this, e);
  51. })), f.access = l && u ? {
  52. get: l,
  53. set: u
  54. } : l ? {
  55. get: l
  56. } : {
  57. set: u
  58. };
  59. try {
  60. return e(s, f);
  61. } finally {
  62. p.v = !0;
  63. }
  64. }
  65. function assertCallable(e, t) {
  66. if ("function" != typeof e) throw new TypeError(t + " must be a function");
  67. }
  68. function assertValidReturnValue(e, t) {
  69. var r = _typeof(t);
  70. if (1 === e) {
  71. if ("object" !== r || null === t) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
  72. void 0 !== t.get && assertCallable(t.get, "accessor.get"), void 0 !== t.set && assertCallable(t.set, "accessor.set"), void 0 !== t.init && assertCallable(t.init, "accessor.init");
  73. } else if ("function" !== r) throw new TypeError((0 === e ? "field" : 10 === e ? "class" : "method") + " decorators must return a function or void 0");
  74. }
  75. function applyMemberDec(e, t, r, n, a, i, o, s) {
  76. var c,
  77. l,
  78. u,
  79. f,
  80. p,
  81. d,
  82. h,
  83. v = r[0];
  84. if (o ? (0 === a || 1 === a ? (c = {
  85. get: r[3],
  86. set: r[4]
  87. }, u = "get") : 3 === a ? (c = {
  88. get: r[3]
  89. }, u = "get") : 4 === a ? (c = {
  90. set: r[3]
  91. }, u = "set") : c = {
  92. value: r[3]
  93. }, 0 !== a && (1 === a && setFunctionName(r[4], "#" + n, "set"), setFunctionName(r[3], "#" + n, u))) : 0 !== a && (c = Object.getOwnPropertyDescriptor(t, n)), 1 === a ? f = {
  94. get: c.get,
  95. set: c.set
  96. } : 2 === a ? f = c.value : 3 === a ? f = c.get : 4 === a && (f = c.set), "function" == typeof v) void 0 !== (p = memberDec(v, n, c, s, a, i, o, f)) && (assertValidReturnValue(a, p), 0 === a ? l = p : 1 === a ? (l = p.init, d = p.get || f.get, h = p.set || f.set, f = {
  97. get: d,
  98. set: h
  99. }) : f = p);else for (var g = v.length - 1; g >= 0; g--) {
  100. var y;
  101. void 0 !== (p = memberDec(v[g], n, c, s, a, i, o, f)) && (assertValidReturnValue(a, p), 0 === a ? y = p : 1 === a ? (y = p.init, d = p.get || f.get, h = p.set || f.set, f = {
  102. get: d,
  103. set: h
  104. }) : f = p, void 0 !== y && (void 0 === l ? l = y : "function" == typeof l ? l = [l, y] : l.push(y)));
  105. }
  106. if (0 === a || 1 === a) {
  107. if (void 0 === l) l = function l(e, t) {
  108. return t;
  109. };else if ("function" != typeof l) {
  110. var m = l;
  111. l = function l(e, t) {
  112. for (var r = t, n = 0; n < m.length; n++) r = m[n].call(e, r);
  113. return r;
  114. };
  115. } else {
  116. var b = l;
  117. l = function l(e, t) {
  118. return b.call(e, t);
  119. };
  120. }
  121. e.push(l);
  122. }
  123. 0 !== a && (1 === a ? (c.get = f.get, c.set = f.set) : 2 === a ? c.value = f : 3 === a ? c.get = f : 4 === a && (c.set = f), o ? 1 === a ? (e.push(function (e, t) {
  124. return f.get.call(e, t);
  125. }), e.push(function (e, t) {
  126. return f.set.call(e, t);
  127. })) : 2 === a ? e.push(f) : e.push(function (e, t) {
  128. return f.call(e, t);
  129. }) : Object.defineProperty(t, n, c));
  130. }
  131. function applyMemberDecs(e, t) {
  132. for (var r, n, a = [], i = new Map(), o = new Map(), s = 0; s < t.length; s++) {
  133. var c = t[s];
  134. if (Array.isArray(c)) {
  135. var l,
  136. u,
  137. f = c[1],
  138. p = c[2],
  139. d = c.length > 3,
  140. h = f >= 5;
  141. if (h ? (l = e, 0 != (f -= 5) && (u = n = n || [])) : (l = e.prototype, 0 !== f && (u = r = r || [])), 0 !== f && !d) {
  142. var v = h ? o : i,
  143. g = v.get(p) || 0;
  144. if (!0 === g || 3 === g && 4 !== f || 4 === g && 3 !== f) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + p);
  145. !g && f > 2 ? v.set(p, f) : v.set(p, !0);
  146. }
  147. applyMemberDec(a, l, c, p, f, h, d, u);
  148. }
  149. }
  150. return pushInitializers(a, r), pushInitializers(a, n), a;
  151. }
  152. function pushInitializers(e, t) {
  153. t && e.push(function (e) {
  154. for (var r = 0; r < t.length; r++) t[r].call(e);
  155. return e;
  156. });
  157. }
  158. return function (e, t, r) {
  159. return {
  160. e: applyMemberDecs(e, t),
  161. get c() {
  162. return function (e, t) {
  163. if (t.length > 0) {
  164. for (var r = [], n = e, a = e.name, i = t.length - 1; i >= 0; i--) {
  165. var o = {
  166. v: !1
  167. };
  168. try {
  169. var s = t[i](n, {
  170. kind: "class",
  171. name: a,
  172. addInitializer: createAddInitializerMethod(r, o)
  173. });
  174. } finally {
  175. o.v = !0;
  176. }
  177. void 0 !== s && (assertValidReturnValue(10, s), n = s);
  178. }
  179. return [n, function () {
  180. for (var e = 0; e < r.length; e++) r[e].call(n);
  181. }];
  182. }
  183. }(e, r);
  184. }
  185. };
  186. };
  187. }
  188. function applyDecs2203R(e, t, r) {
  189. return (module.exports = applyDecs2203R = applyDecs2203RFactory(), module.exports.__esModule = true, module.exports["default"] = module.exports)(e, t, r);
  190. }
  191. module.exports = applyDecs2203R, module.exports.__esModule = true, module.exports["default"] = module.exports;