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