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