applyDecs2305.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. var _typeof = require("./typeof.js")["default"];
  2. var checkInRHS = require("./checkInRHS.js");
  3. var setFunctionName = require("./setFunctionName.js");
  4. var toPropertyKey = require("./toPropertyKey.js");
  5. function applyDecs2305(e, t, r, n, o, a) {
  6. function i(e, t, r) {
  7. return function (n, o) {
  8. return r && r(n), e[t].call(n, o);
  9. };
  10. }
  11. function c(e, t) {
  12. for (var r = 0; r < e.length; r++) e[r].call(t);
  13. return t;
  14. }
  15. function s(e, t, r, n) {
  16. if ("function" != typeof e && (n || void 0 !== e)) throw new TypeError(t + " must " + (r || "be") + " a function" + (n ? "" : " or undefined"));
  17. return e;
  18. }
  19. function applyDec(e, t, r, n, o, a, c, u, l, f, p, d, h) {
  20. function m(e) {
  21. if (!h(e)) throw new TypeError("Attempted to access private element on non-instance");
  22. }
  23. var y,
  24. v,
  25. g = t[0],
  26. b = t[3],
  27. w = !u;
  28. if (!w) {
  29. r || Array.isArray(g) || (g = [g]);
  30. var S = {},
  31. A = [],
  32. P = 3 === o ? "get" : 4 === o || d ? "set" : "value";
  33. f ? (p || d ? S = {
  34. get: setFunctionName(function () {
  35. return b(this);
  36. }, n, "get"),
  37. set: function set(e) {
  38. t[4](this, e);
  39. }
  40. } : S[P] = b, p || setFunctionName(S[P], n, 2 === o ? "" : P)) : p || (S = Object.getOwnPropertyDescriptor(e, n));
  41. }
  42. for (var j = g.length - 1; j >= 0; j -= r ? 2 : 1) {
  43. var D = g[j],
  44. E = r ? g[j - 1] : void 0,
  45. I = {},
  46. O = {
  47. kind: ["field", "accessor", "method", "getter", "setter", "field", "class"][o],
  48. name: n,
  49. metadata: a,
  50. addInitializer: function (e, t) {
  51. if (e.v) throw new Error("attempted to call addInitializer after decoration was finished");
  52. s(t, "An initializer", "be", !0), c.push(t);
  53. }.bind(null, I)
  54. };
  55. try {
  56. if (w) v = D.call(E, e, O);else {
  57. var k, F;
  58. O["static"] = l, O["private"] = f, f || !p && 2 !== o ? 2 === o ? k = function k(e) {
  59. return m(e), S.value;
  60. } : ((o < 2 || 3 === o) && (k = i(S, "get", f && m)), (o < 2 || 4 === o) && (F = i(S, "set", f && m))) : (k = function k(e) {
  61. return e[n];
  62. }, p && (F = function F(e, t) {
  63. e[n] = t;
  64. }));
  65. var N = O.access = {
  66. has: f ? h.bind() : function (e) {
  67. return n in e;
  68. }
  69. };
  70. if (k && (N.get = k), F && (N.set = F), v = D.call(E, d ? {
  71. get: S.get,
  72. set: S.set
  73. } : S[P], O), d) {
  74. if ("object" == _typeof(v) && v) (y = s(v.get, "accessor.get")) && (S.get = y), (y = s(v.set, "accessor.set")) && (S.set = y), (y = s(v.init, "accessor.init")) && A.push(y);else if (void 0 !== v) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
  75. } else s(v, (p ? "field" : "method") + " decorators", "return") && (p ? A.push(v) : S[P] = v);
  76. }
  77. } finally {
  78. I.v = !0;
  79. }
  80. }
  81. return (p || d) && u.push(function (e, t) {
  82. for (var r = A.length - 1; r >= 0; r--) t = A[r].call(e, t);
  83. return t;
  84. }), p || w || (f ? d ? u.push(i(S, "get"), i(S, "set")) : u.push(2 === o ? S[P] : i.call.bind(S[P])) : Object.defineProperty(e, n, S)), v;
  85. }
  86. function u(e, t) {
  87. return Object.defineProperty(e, Symbol.metadata || Symbol["for"]("Symbol.metadata"), {
  88. configurable: !0,
  89. enumerable: !0,
  90. value: t
  91. });
  92. }
  93. if (arguments.length >= 6) var l = a[Symbol.metadata || Symbol["for"]("Symbol.metadata")];
  94. var f = Object.create(null == l ? null : l),
  95. p = function (e, t, r, n) {
  96. var o,
  97. a,
  98. i = [],
  99. s = function s(t) {
  100. return checkInRHS(t) === e;
  101. },
  102. u = new Map();
  103. function l(e) {
  104. e && i.push(c.bind(null, e));
  105. }
  106. for (var f = 0; f < t.length; f++) {
  107. var p = t[f];
  108. if (Array.isArray(p)) {
  109. var d = p[1],
  110. h = p[2],
  111. m = p.length > 3,
  112. y = 16 & d,
  113. v = !!(8 & d),
  114. g = 0 == (d &= 7),
  115. b = h + "/" + v;
  116. if (!g && !m) {
  117. var w = u.get(b);
  118. if (!0 === w || 3 === w && 4 !== d || 4 === w && 3 !== d) throw new 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: " + h);
  119. u.set(b, !(d > 2) || d);
  120. }
  121. applyDec(v ? e : e.prototype, p, y, m ? "#" + h : toPropertyKey(h), d, n, v ? a = a || [] : o = o || [], i, v, m, g, 1 === d, v && m ? s : r);
  122. }
  123. }
  124. return l(o), l(a), i;
  125. }(e, t, o, f);
  126. return r.length || u(e, f), {
  127. e: p,
  128. get c() {
  129. var t = [];
  130. return r.length && [u(s(applyDec(e, [r], n, e.name, 5, f, t), "class decorators", "return") || e, f), c.bind(null, t, e)];
  131. }
  132. };
  133. }
  134. module.exports = applyDecs2305, module.exports.__esModule = true, module.exports["default"] = module.exports;