Skip to content

Commit 345ea57

Browse files
authored
chore: Commit corejs3 helpers (#16212)
1 parent 7fe70fe commit 345ea57

116 files changed

Lines changed: 3152 additions & 18 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ package-lock.json
2626
/packages/babel-compat-data/build
2727

2828
/packages/babel-core/src/vendor/*.js
29-
/packages/babel-core/src/vendor/*.ts
3029

3130
/packages/babel-runtime/helpers/*.js
3231
!/packages/babel-runtime/helpers/dispose.js
@@ -56,10 +55,6 @@ package-lock.json
5655
!/packages/babel-runtime-corejs2/core-js/map.js
5756

5857
/packages/babel-runtime-corejs3/helpers/*.js
59-
!/packages/babel-runtime-corejs3/helpers/dispose.js
60-
!/packages/babel-runtime-corejs3/helpers/possibleConstructorReturn.js
61-
/packages/babel-runtime-corejs3/helpers/esm/*.js
62-
!/packages/babel-runtime-corejs3/helpers/esm/possibleConstructorReturn.js
6358
/packages/babel-runtime-corejs3/core-js/**/*.js
6459
/packages/babel-runtime-corejs3/core-js-stable/**/*.js
6560

@@ -81,9 +76,9 @@ packages/babel-standalone/babel.min.js.map
8176

8277
/eslint/*/lib
8378
/eslint/*/LICENSE
84-
!/packages/babel-eslint-plugin/LICENSE
79+
!/eslint/babel-eslint-plugin/LICENSE
8580

86-
/.vscode
81+
/.vscode/**
8782
!/.vscode/settings.example.json
8883
# local directory for VSCode Extension - https://marketplace.visualstudio.com/items?itemName=xyz.local-history
8984
/.history
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import _Promise from "core-js-pure/features/promise/index.js";
2+
import _Symbol from "core-js-pure/features/symbol/index.js";
3+
import _Symbol$asyncIterator from "core-js-pure/features/symbol/async-iterator.js";
4+
import OverloadYield from "./OverloadYield.js";
5+
export default function AsyncGenerator(e) {
6+
var r, t;
7+
function resume(r, t) {
8+
try {
9+
var n = e[r](t),
10+
o = n.value,
11+
u = o instanceof OverloadYield;
12+
_Promise.resolve(u ? o.v : o).then(function (t) {
13+
if (u) {
14+
var i = "return" === r ? "return" : "next";
15+
if (!o.k || t.done) return resume(i, t);
16+
t = e[i](t).value;
17+
}
18+
settle(n.done ? "return" : "normal", t);
19+
}, function (e) {
20+
resume("throw", e);
21+
});
22+
} catch (e) {
23+
settle("throw", e);
24+
}
25+
}
26+
function settle(e, n) {
27+
switch (e) {
28+
case "return":
29+
r.resolve({
30+
value: n,
31+
done: !0
32+
});
33+
break;
34+
case "throw":
35+
r.reject(n);
36+
break;
37+
default:
38+
r.resolve({
39+
value: n,
40+
done: !1
41+
});
42+
}
43+
(r = r.next) ? resume(r.key, r.arg) : t = null;
44+
}
45+
this._invoke = function (e, n) {
46+
return new _Promise(function (o, u) {
47+
var i = {
48+
key: e,
49+
arg: n,
50+
resolve: o,
51+
reject: u,
52+
next: null
53+
};
54+
t ? t = t.next = i : (r = t = i, resume(e, n));
55+
});
56+
}, "function" != typeof e["return"] && (this["return"] = void 0);
57+
}
58+
AsyncGenerator.prototype["function" == typeof _Symbol && _Symbol$asyncIterator || "@@asyncIterator"] = function () {
59+
return this;
60+
}, AsyncGenerator.prototype.next = function (e) {
61+
return this._invoke("next", e);
62+
}, AsyncGenerator.prototype["throw"] = function (e) {
63+
return this._invoke("throw", e);
64+
}, AsyncGenerator.prototype["return"] = function (e) {
65+
return this._invoke("return", e);
66+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function _AwaitValue(value) {
2+
this.wrapped = value;
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function _OverloadYield(t, e) {
2+
this.v = t, this.k = e;
3+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import _forEachInstanceProperty from "core-js-pure/features/instance/for-each.js";
2+
import _Object$keys from "core-js-pure/features/object/keys.js";
3+
import _reduceInstanceProperty from "core-js-pure/features/instance/reduce.js";
4+
import _reverseInstanceProperty from "core-js-pure/features/instance/reverse.js";
5+
import _sliceInstanceProperty from "core-js-pure/features/instance/slice.js";
6+
import _Object$defineProperty from "core-js-pure/features/object/define-property.js";
7+
export default function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {
8+
var _context, _context2, _context3;
9+
var desc = {};
10+
_forEachInstanceProperty(_context = _Object$keys(descriptor)).call(_context, function (key) {
11+
desc[key] = descriptor[key];
12+
});
13+
desc.enumerable = !!desc.enumerable;
14+
desc.configurable = !!desc.configurable;
15+
if ('value' in desc || desc.initializer) {
16+
desc.writable = true;
17+
}
18+
desc = _reduceInstanceProperty(_context2 = _reverseInstanceProperty(_context3 = _sliceInstanceProperty(decorators).call(decorators)).call(_context3)).call(_context2, function (desc, decorator) {
19+
return decorator(target, property, desc) || desc;
20+
}, desc);
21+
if (context && desc.initializer !== void 0) {
22+
desc.value = desc.initializer ? desc.initializer.call(context) : void 0;
23+
desc.initializer = undefined;
24+
}
25+
if (desc.initializer === void 0) {
26+
_Object$defineProperty(target, property, desc);
27+
desc = null;
28+
}
29+
return desc;
30+
}
Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
import _typeof from "./typeof.js";
2+
import _Map from "core-js-pure/features/map/index.js";
3+
import _Symbol$metadata from "core-js-pure/features/symbol/metadata.js";
4+
import _Symbol$for from "core-js-pure/features/symbol/for.js";
5+
import _Object$getOwnPropertySymbols from "core-js-pure/features/object/get-own-property-symbols.js";
6+
import _Object$setPrototypeOf from "core-js-pure/features/object/set-prototype-of.js";
7+
import _Array$from from "core-js-pure/features/array/from.js";
8+
import _valuesInstanceProperty from "core-js-pure/features/instance/values.js";
9+
import _concatInstanceProperty from "core-js-pure/features/instance/concat.js";
10+
import _pushInstanceProperty from "core-js-pure/features/instance/push.js";
11+
import _Symbol from "core-js-pure/features/symbol/index.js";
12+
import _Object$assign from "core-js-pure/features/object/assign.js";
13+
import _Object$getOwnPropertyDescriptor from "core-js-pure/features/object/get-own-property-descriptor.js";
14+
import _Object$defineProperty from "core-js-pure/features/object/define-property.js";
15+
import _Array$isArray from "core-js-pure/features/array/is-array.js";
16+
import setFunctionName from "./setFunctionName.js";
17+
import toPropertyKey from "./toPropertyKey.js";
18+
function old_createMetadataMethodsForProperty(e, t, a, r) {
19+
return {
20+
getMetadata: function getMetadata(o) {
21+
old_assertNotFinished(r, "getMetadata"), old_assertMetadataKey(o);
22+
var i = e[o];
23+
if (void 0 !== i) if (1 === t) {
24+
var n = i["public"];
25+
if (void 0 !== n) return n[a];
26+
} else if (2 === t) {
27+
var l = i["private"];
28+
if (void 0 !== l) return l.get(a);
29+
} else if (Object.hasOwnProperty.call(i, "constructor")) return i.constructor;
30+
},
31+
setMetadata: function setMetadata(o, i) {
32+
old_assertNotFinished(r, "setMetadata"), old_assertMetadataKey(o);
33+
var n = e[o];
34+
if (void 0 === n && (n = e[o] = {}), 1 === t) {
35+
var l = n["public"];
36+
void 0 === l && (l = n["public"] = {}), l[a] = i;
37+
} else if (2 === t) {
38+
var s = n.priv;
39+
void 0 === s && (s = n["private"] = new _Map()), s.set(a, i);
40+
} else n.constructor = i;
41+
}
42+
};
43+
}
44+
function old_convertMetadataMapToFinal(e, t) {
45+
var a = e[_Symbol$metadata || _Symbol$for("Symbol.metadata")],
46+
r = _Object$getOwnPropertySymbols(t);
47+
if (0 !== r.length) {
48+
for (var o = 0; o < r.length; o++) {
49+
var i = r[o],
50+
n = t[i],
51+
l = a ? a[i] : null,
52+
s = n["public"],
53+
c = l ? l["public"] : null;
54+
s && c && _Object$setPrototypeOf(s, c);
55+
var d = n["private"];
56+
if (d) {
57+
var u = _Array$from(_valuesInstanceProperty(d).call(d)),
58+
f = l ? l["private"] : null;
59+
f && (u = _concatInstanceProperty(u).call(u, f)), n["private"] = u;
60+
}
61+
l && _Object$setPrototypeOf(n, l);
62+
}
63+
a && _Object$setPrototypeOf(t, a), e[_Symbol$metadata || _Symbol$for("Symbol.metadata")] = t;
64+
}
65+
}
66+
function old_createAddInitializerMethod(e, t) {
67+
return function (a) {
68+
old_assertNotFinished(t, "addInitializer"), old_assertCallable(a, "An initializer"), _pushInstanceProperty(e).call(e, a);
69+
};
70+
}
71+
function old_memberDec(e, t, a, r, o, i, n, l, s) {
72+
var c;
73+
switch (i) {
74+
case 1:
75+
c = "accessor";
76+
break;
77+
case 2:
78+
c = "method";
79+
break;
80+
case 3:
81+
c = "getter";
82+
break;
83+
case 4:
84+
c = "setter";
85+
break;
86+
default:
87+
c = "field";
88+
}
89+
var d,
90+
u,
91+
f = {
92+
kind: c,
93+
name: l ? "#" + t : toPropertyKey(t),
94+
isStatic: n,
95+
isPrivate: l
96+
},
97+
p = {
98+
v: !1
99+
};
100+
if (0 !== i && (f.addInitializer = old_createAddInitializerMethod(o, p)), l) {
101+
d = 2, u = _Symbol(t);
102+
var v = {};
103+
0 === i ? (v.get = a.get, v.set = a.set) : 2 === i ? v.get = function () {
104+
return a.value;
105+
} : (1 !== i && 3 !== i || (v.get = function () {
106+
return a.get.call(this);
107+
}), 1 !== i && 4 !== i || (v.set = function (e) {
108+
a.set.call(this, e);
109+
})), f.access = v;
110+
} else d = 1, u = t;
111+
try {
112+
return e(s, _Object$assign(f, old_createMetadataMethodsForProperty(r, d, u, p)));
113+
} finally {
114+
p.v = !0;
115+
}
116+
}
117+
function old_assertNotFinished(e, t) {
118+
if (e.v) throw new Error("attempted to call " + t + " after decoration was finished");
119+
}
120+
function old_assertMetadataKey(e) {
121+
if ("symbol" != _typeof(e)) throw new TypeError("Metadata keys must be symbols, received: " + e);
122+
}
123+
function old_assertCallable(e, t) {
124+
if ("function" != typeof e) throw new TypeError(t + " must be a function");
125+
}
126+
function old_assertValidReturnValue(e, t) {
127+
var a = _typeof(t);
128+
if (1 === e) {
129+
if ("object" !== a || null === t) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
130+
void 0 !== t.get && old_assertCallable(t.get, "accessor.get"), void 0 !== t.set && old_assertCallable(t.set, "accessor.set"), void 0 !== t.init && old_assertCallable(t.init, "accessor.init"), void 0 !== t.initializer && old_assertCallable(t.initializer, "accessor.initializer");
131+
} else if ("function" !== a) throw new TypeError((0 === e ? "field" : 10 === e ? "class" : "method") + " decorators must return a function or void 0");
132+
}
133+
function old_getInit(e) {
134+
var t;
135+
return null == (t = e.init) && (t = e.initializer) && "undefined" != typeof console && console.warn(".initializer has been renamed to .init as of March 2022"), t;
136+
}
137+
function old_applyMemberDec(e, t, a, r, o, i, n, l, s) {
138+
var c,
139+
d,
140+
u,
141+
f,
142+
p,
143+
v,
144+
y,
145+
h = a[0];
146+
if (n ? (0 === o || 1 === o ? (c = {
147+
get: a[3],
148+
set: a[4]
149+
}, u = "get") : 3 === o ? (c = {
150+
get: a[3]
151+
}, u = "get") : 4 === o ? (c = {
152+
set: a[3]
153+
}, u = "set") : c = {
154+
value: a[3]
155+
}, 0 !== o && (1 === o && setFunctionName(a[4], "#" + r, "set"), setFunctionName(a[3], "#" + r, u))) : 0 !== o && (c = _Object$getOwnPropertyDescriptor(t, r)), 1 === o ? f = {
156+
get: c.get,
157+
set: c.set
158+
} : 2 === o ? f = c.value : 3 === o ? f = c.get : 4 === o && (f = c.set), "function" == typeof h) void 0 !== (p = old_memberDec(h, r, c, l, s, o, i, n, f)) && (old_assertValidReturnValue(o, p), 0 === o ? d = p : 1 === o ? (d = old_getInit(p), v = p.get || f.get, y = p.set || f.set, f = {
159+
get: v,
160+
set: y
161+
}) : f = p);else for (var m = h.length - 1; m >= 0; m--) {
162+
var b;
163+
void 0 !== (p = old_memberDec(h[m], r, c, l, s, o, i, n, f)) && (old_assertValidReturnValue(o, p), 0 === o ? b = p : 1 === o ? (b = old_getInit(p), v = p.get || f.get, y = p.set || f.set, f = {
164+
get: v,
165+
set: y
166+
}) : f = p, void 0 !== b && (void 0 === d ? d = b : "function" == typeof d ? d = [d, b] : _pushInstanceProperty(d).call(d, b)));
167+
}
168+
if (0 === o || 1 === o) {
169+
if (void 0 === d) d = function d(e, t) {
170+
return t;
171+
};else if ("function" != typeof d) {
172+
var g = d;
173+
d = function d(e, t) {
174+
for (var a = t, r = 0; r < g.length; r++) a = g[r].call(e, a);
175+
return a;
176+
};
177+
} else {
178+
var _ = d;
179+
d = function d(e, t) {
180+
return _.call(e, t);
181+
};
182+
}
183+
_pushInstanceProperty(e).call(e, d);
184+
}
185+
0 !== o && (1 === o ? (c.get = f.get, c.set = f.set) : 2 === o ? c.value = f : 3 === o ? c.get = f : 4 === o && (c.set = f), n ? 1 === o ? (_pushInstanceProperty(e).call(e, function (e, t) {
186+
return f.get.call(e, t);
187+
}), _pushInstanceProperty(e).call(e, function (e, t) {
188+
return f.set.call(e, t);
189+
})) : 2 === o ? _pushInstanceProperty(e).call(e, f) : _pushInstanceProperty(e).call(e, function (e, t) {
190+
return f.call(e, t);
191+
}) : _Object$defineProperty(t, r, c));
192+
}
193+
function old_applyMemberDecs(e, t, a, r, o) {
194+
for (var i, n, l = new _Map(), s = new _Map(), c = 0; c < o.length; c++) {
195+
var d = o[c];
196+
if (_Array$isArray(d)) {
197+
var u,
198+
f,
199+
p,
200+
v = d[1],
201+
y = d[2],
202+
h = d.length > 3,
203+
m = v >= 5;
204+
if (m ? (u = t, f = r, 0 != (v -= 5) && (p = n = n || [])) : (u = t.prototype, f = a, 0 !== v && (p = i = i || [])), 0 !== v && !h) {
205+
var b = m ? s : l,
206+
g = b.get(y) || 0;
207+
if (!0 === g || 3 === g && 4 !== v || 4 === g && 3 !== v) 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: " + y);
208+
!g && v > 2 ? b.set(y, v) : b.set(y, !0);
209+
}
210+
old_applyMemberDec(e, u, d, y, v, m, h, f, p);
211+
}
212+
}
213+
old_pushInitializers(e, i), old_pushInitializers(e, n);
214+
}
215+
function old_pushInitializers(e, t) {
216+
t && _pushInstanceProperty(e).call(e, function (e) {
217+
for (var a = 0; a < t.length; a++) t[a].call(e);
218+
return e;
219+
});
220+
}
221+
function old_applyClassDecs(e, t, a, r) {
222+
if (r.length > 0) {
223+
for (var o = [], i = t, n = t.name, l = r.length - 1; l >= 0; l--) {
224+
var s = {
225+
v: !1
226+
};
227+
try {
228+
var c = _Object$assign({
229+
kind: "class",
230+
name: n,
231+
addInitializer: old_createAddInitializerMethod(o, s)
232+
}, old_createMetadataMethodsForProperty(a, 0, n, s)),
233+
d = r[l](i, c);
234+
} finally {
235+
s.v = !0;
236+
}
237+
void 0 !== d && (old_assertValidReturnValue(10, d), i = d);
238+
}
239+
_pushInstanceProperty(e).call(e, i, function () {
240+
for (var e = 0; e < o.length; e++) o[e].call(i);
241+
});
242+
}
243+
}
244+
export default function applyDecs(e, t, a) {
245+
var r = [],
246+
o = {},
247+
i = {};
248+
return old_applyMemberDecs(r, e, i, o, t), old_convertMetadataMapToFinal(e.prototype, i), old_applyClassDecs(r, e, o, a), old_convertMetadataMapToFinal(e, o), r;
249+
}

0 commit comments

Comments
 (0)