-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Commit corejs3 helpers (#16212)
- Loading branch information
1 parent
7fe70fe
commit 345ea57
Showing
116 changed files
with
3,152 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
packages/babel-runtime-corejs3/helpers/esm/AsyncGenerator.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import _Promise from "core-js-pure/features/promise/index.js"; | ||
import _Symbol from "core-js-pure/features/symbol/index.js"; | ||
import _Symbol$asyncIterator from "core-js-pure/features/symbol/async-iterator.js"; | ||
import OverloadYield from "./OverloadYield.js"; | ||
export default function AsyncGenerator(e) { | ||
var r, t; | ||
function resume(r, t) { | ||
try { | ||
var n = e[r](t), | ||
o = n.value, | ||
u = o instanceof OverloadYield; | ||
_Promise.resolve(u ? o.v : o).then(function (t) { | ||
if (u) { | ||
var i = "return" === r ? "return" : "next"; | ||
if (!o.k || t.done) return resume(i, t); | ||
t = e[i](t).value; | ||
} | ||
settle(n.done ? "return" : "normal", t); | ||
}, function (e) { | ||
resume("throw", e); | ||
}); | ||
} catch (e) { | ||
settle("throw", e); | ||
} | ||
} | ||
function settle(e, n) { | ||
switch (e) { | ||
case "return": | ||
r.resolve({ | ||
value: n, | ||
done: !0 | ||
}); | ||
break; | ||
case "throw": | ||
r.reject(n); | ||
break; | ||
default: | ||
r.resolve({ | ||
value: n, | ||
done: !1 | ||
}); | ||
} | ||
(r = r.next) ? resume(r.key, r.arg) : t = null; | ||
} | ||
this._invoke = function (e, n) { | ||
return new _Promise(function (o, u) { | ||
var i = { | ||
key: e, | ||
arg: n, | ||
resolve: o, | ||
reject: u, | ||
next: null | ||
}; | ||
t ? t = t.next = i : (r = t = i, resume(e, n)); | ||
}); | ||
}, "function" != typeof e["return"] && (this["return"] = void 0); | ||
} | ||
AsyncGenerator.prototype["function" == typeof _Symbol && _Symbol$asyncIterator || "@@asyncIterator"] = function () { | ||
return this; | ||
}, AsyncGenerator.prototype.next = function (e) { | ||
return this._invoke("next", e); | ||
}, AsyncGenerator.prototype["throw"] = function (e) { | ||
return this._invoke("throw", e); | ||
}, AsyncGenerator.prototype["return"] = function (e) { | ||
return this._invoke("return", e); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function _AwaitValue(value) { | ||
this.wrapped = value; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function _OverloadYield(t, e) { | ||
this.v = t, this.k = e; | ||
} |
30 changes: 30 additions & 0 deletions
30
packages/babel-runtime-corejs3/helpers/esm/applyDecoratedDescriptor.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import _forEachInstanceProperty from "core-js-pure/features/instance/for-each.js"; | ||
import _Object$keys from "core-js-pure/features/object/keys.js"; | ||
import _reduceInstanceProperty from "core-js-pure/features/instance/reduce.js"; | ||
import _reverseInstanceProperty from "core-js-pure/features/instance/reverse.js"; | ||
import _sliceInstanceProperty from "core-js-pure/features/instance/slice.js"; | ||
import _Object$defineProperty from "core-js-pure/features/object/define-property.js"; | ||
export default function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { | ||
var _context, _context2, _context3; | ||
var desc = {}; | ||
_forEachInstanceProperty(_context = _Object$keys(descriptor)).call(_context, function (key) { | ||
desc[key] = descriptor[key]; | ||
}); | ||
desc.enumerable = !!desc.enumerable; | ||
desc.configurable = !!desc.configurable; | ||
if ('value' in desc || desc.initializer) { | ||
desc.writable = true; | ||
} | ||
desc = _reduceInstanceProperty(_context2 = _reverseInstanceProperty(_context3 = _sliceInstanceProperty(decorators).call(decorators)).call(_context3)).call(_context2, function (desc, decorator) { | ||
return decorator(target, property, desc) || desc; | ||
}, desc); | ||
if (context && desc.initializer !== void 0) { | ||
desc.value = desc.initializer ? desc.initializer.call(context) : void 0; | ||
desc.initializer = undefined; | ||
} | ||
if (desc.initializer === void 0) { | ||
_Object$defineProperty(target, property, desc); | ||
desc = null; | ||
} | ||
return desc; | ||
} |
249 changes: 249 additions & 0 deletions
249
packages/babel-runtime-corejs3/helpers/esm/applyDecs.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,249 @@ | ||
import _typeof from "./typeof.js"; | ||
import _Map from "core-js-pure/features/map/index.js"; | ||
import _Symbol$metadata from "core-js-pure/features/symbol/metadata.js"; | ||
import _Symbol$for from "core-js-pure/features/symbol/for.js"; | ||
import _Object$getOwnPropertySymbols from "core-js-pure/features/object/get-own-property-symbols.js"; | ||
import _Object$setPrototypeOf from "core-js-pure/features/object/set-prototype-of.js"; | ||
import _Array$from from "core-js-pure/features/array/from.js"; | ||
import _valuesInstanceProperty from "core-js-pure/features/instance/values.js"; | ||
import _concatInstanceProperty from "core-js-pure/features/instance/concat.js"; | ||
import _pushInstanceProperty from "core-js-pure/features/instance/push.js"; | ||
import _Symbol from "core-js-pure/features/symbol/index.js"; | ||
import _Object$assign from "core-js-pure/features/object/assign.js"; | ||
import _Object$getOwnPropertyDescriptor from "core-js-pure/features/object/get-own-property-descriptor.js"; | ||
import _Object$defineProperty from "core-js-pure/features/object/define-property.js"; | ||
import _Array$isArray from "core-js-pure/features/array/is-array.js"; | ||
import setFunctionName from "./setFunctionName.js"; | ||
import toPropertyKey from "./toPropertyKey.js"; | ||
function old_createMetadataMethodsForProperty(e, t, a, r) { | ||
return { | ||
getMetadata: function getMetadata(o) { | ||
old_assertNotFinished(r, "getMetadata"), old_assertMetadataKey(o); | ||
var i = e[o]; | ||
if (void 0 !== i) if (1 === t) { | ||
var n = i["public"]; | ||
if (void 0 !== n) return n[a]; | ||
} else if (2 === t) { | ||
var l = i["private"]; | ||
if (void 0 !== l) return l.get(a); | ||
} else if (Object.hasOwnProperty.call(i, "constructor")) return i.constructor; | ||
}, | ||
setMetadata: function setMetadata(o, i) { | ||
old_assertNotFinished(r, "setMetadata"), old_assertMetadataKey(o); | ||
var n = e[o]; | ||
if (void 0 === n && (n = e[o] = {}), 1 === t) { | ||
var l = n["public"]; | ||
void 0 === l && (l = n["public"] = {}), l[a] = i; | ||
} else if (2 === t) { | ||
var s = n.priv; | ||
void 0 === s && (s = n["private"] = new _Map()), s.set(a, i); | ||
} else n.constructor = i; | ||
} | ||
}; | ||
} | ||
function old_convertMetadataMapToFinal(e, t) { | ||
var a = e[_Symbol$metadata || _Symbol$for("Symbol.metadata")], | ||
r = _Object$getOwnPropertySymbols(t); | ||
if (0 !== r.length) { | ||
for (var o = 0; o < r.length; o++) { | ||
var i = r[o], | ||
n = t[i], | ||
l = a ? a[i] : null, | ||
s = n["public"], | ||
c = l ? l["public"] : null; | ||
s && c && _Object$setPrototypeOf(s, c); | ||
var d = n["private"]; | ||
if (d) { | ||
var u = _Array$from(_valuesInstanceProperty(d).call(d)), | ||
f = l ? l["private"] : null; | ||
f && (u = _concatInstanceProperty(u).call(u, f)), n["private"] = u; | ||
} | ||
l && _Object$setPrototypeOf(n, l); | ||
} | ||
a && _Object$setPrototypeOf(t, a), e[_Symbol$metadata || _Symbol$for("Symbol.metadata")] = t; | ||
} | ||
} | ||
function old_createAddInitializerMethod(e, t) { | ||
return function (a) { | ||
old_assertNotFinished(t, "addInitializer"), old_assertCallable(a, "An initializer"), _pushInstanceProperty(e).call(e, a); | ||
}; | ||
} | ||
function old_memberDec(e, t, a, r, o, i, n, l, s) { | ||
var c; | ||
switch (i) { | ||
case 1: | ||
c = "accessor"; | ||
break; | ||
case 2: | ||
c = "method"; | ||
break; | ||
case 3: | ||
c = "getter"; | ||
break; | ||
case 4: | ||
c = "setter"; | ||
break; | ||
default: | ||
c = "field"; | ||
} | ||
var d, | ||
u, | ||
f = { | ||
kind: c, | ||
name: l ? "#" + t : toPropertyKey(t), | ||
isStatic: n, | ||
isPrivate: l | ||
}, | ||
p = { | ||
v: !1 | ||
}; | ||
if (0 !== i && (f.addInitializer = old_createAddInitializerMethod(o, p)), l) { | ||
d = 2, u = _Symbol(t); | ||
var v = {}; | ||
0 === i ? (v.get = a.get, v.set = a.set) : 2 === i ? v.get = function () { | ||
return a.value; | ||
} : (1 !== i && 3 !== i || (v.get = function () { | ||
return a.get.call(this); | ||
}), 1 !== i && 4 !== i || (v.set = function (e) { | ||
a.set.call(this, e); | ||
})), f.access = v; | ||
} else d = 1, u = t; | ||
try { | ||
return e(s, _Object$assign(f, old_createMetadataMethodsForProperty(r, d, u, p))); | ||
} finally { | ||
p.v = !0; | ||
} | ||
} | ||
function old_assertNotFinished(e, t) { | ||
if (e.v) throw new Error("attempted to call " + t + " after decoration was finished"); | ||
} | ||
function old_assertMetadataKey(e) { | ||
if ("symbol" != _typeof(e)) throw new TypeError("Metadata keys must be symbols, received: " + e); | ||
} | ||
function old_assertCallable(e, t) { | ||
if ("function" != typeof e) throw new TypeError(t + " must be a function"); | ||
} | ||
function old_assertValidReturnValue(e, t) { | ||
var a = _typeof(t); | ||
if (1 === e) { | ||
if ("object" !== a || null === t) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0"); | ||
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"); | ||
} else if ("function" !== a) throw new TypeError((0 === e ? "field" : 10 === e ? "class" : "method") + " decorators must return a function or void 0"); | ||
} | ||
function old_getInit(e) { | ||
var t; | ||
return null == (t = e.init) && (t = e.initializer) && "undefined" != typeof console && console.warn(".initializer has been renamed to .init as of March 2022"), t; | ||
} | ||
function old_applyMemberDec(e, t, a, r, o, i, n, l, s) { | ||
var c, | ||
d, | ||
u, | ||
f, | ||
p, | ||
v, | ||
y, | ||
h = a[0]; | ||
if (n ? (0 === o || 1 === o ? (c = { | ||
get: a[3], | ||
set: a[4] | ||
}, u = "get") : 3 === o ? (c = { | ||
get: a[3] | ||
}, u = "get") : 4 === o ? (c = { | ||
set: a[3] | ||
}, u = "set") : c = { | ||
value: a[3] | ||
}, 0 !== o && (1 === o && setFunctionName(a[4], "#" + r, "set"), setFunctionName(a[3], "#" + r, u))) : 0 !== o && (c = _Object$getOwnPropertyDescriptor(t, r)), 1 === o ? f = { | ||
get: c.get, | ||
set: c.set | ||
} : 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 = { | ||
get: v, | ||
set: y | ||
}) : f = p);else for (var m = h.length - 1; m >= 0; m--) { | ||
var b; | ||
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 = { | ||
get: v, | ||
set: y | ||
}) : f = p, void 0 !== b && (void 0 === d ? d = b : "function" == typeof d ? d = [d, b] : _pushInstanceProperty(d).call(d, b))); | ||
} | ||
if (0 === o || 1 === o) { | ||
if (void 0 === d) d = function d(e, t) { | ||
return t; | ||
};else if ("function" != typeof d) { | ||
var g = d; | ||
d = function d(e, t) { | ||
for (var a = t, r = 0; r < g.length; r++) a = g[r].call(e, a); | ||
return a; | ||
}; | ||
} else { | ||
var _ = d; | ||
d = function d(e, t) { | ||
return _.call(e, t); | ||
}; | ||
} | ||
_pushInstanceProperty(e).call(e, d); | ||
} | ||
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) { | ||
return f.get.call(e, t); | ||
}), _pushInstanceProperty(e).call(e, function (e, t) { | ||
return f.set.call(e, t); | ||
})) : 2 === o ? _pushInstanceProperty(e).call(e, f) : _pushInstanceProperty(e).call(e, function (e, t) { | ||
return f.call(e, t); | ||
}) : _Object$defineProperty(t, r, c)); | ||
} | ||
function old_applyMemberDecs(e, t, a, r, o) { | ||
for (var i, n, l = new _Map(), s = new _Map(), c = 0; c < o.length; c++) { | ||
var d = o[c]; | ||
if (_Array$isArray(d)) { | ||
var u, | ||
f, | ||
p, | ||
v = d[1], | ||
y = d[2], | ||
h = d.length > 3, | ||
m = v >= 5; | ||
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) { | ||
var b = m ? s : l, | ||
g = b.get(y) || 0; | ||
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); | ||
!g && v > 2 ? b.set(y, v) : b.set(y, !0); | ||
} | ||
old_applyMemberDec(e, u, d, y, v, m, h, f, p); | ||
} | ||
} | ||
old_pushInitializers(e, i), old_pushInitializers(e, n); | ||
} | ||
function old_pushInitializers(e, t) { | ||
t && _pushInstanceProperty(e).call(e, function (e) { | ||
for (var a = 0; a < t.length; a++) t[a].call(e); | ||
return e; | ||
}); | ||
} | ||
function old_applyClassDecs(e, t, a, r) { | ||
if (r.length > 0) { | ||
for (var o = [], i = t, n = t.name, l = r.length - 1; l >= 0; l--) { | ||
var s = { | ||
v: !1 | ||
}; | ||
try { | ||
var c = _Object$assign({ | ||
kind: "class", | ||
name: n, | ||
addInitializer: old_createAddInitializerMethod(o, s) | ||
}, old_createMetadataMethodsForProperty(a, 0, n, s)), | ||
d = r[l](i, c); | ||
} finally { | ||
s.v = !0; | ||
} | ||
void 0 !== d && (old_assertValidReturnValue(10, d), i = d); | ||
} | ||
_pushInstanceProperty(e).call(e, i, function () { | ||
for (var e = 0; e < o.length; e++) o[e].call(i); | ||
}); | ||
} | ||
} | ||
export default function applyDecs(e, t, a) { | ||
var r = [], | ||
o = {}, | ||
i = {}; | ||
return old_applyMemberDecs(r, e, i, o, t), old_convertMetadataMapToFinal(e.prototype, i), old_applyClassDecs(r, e, o, a), old_convertMetadataMapToFinal(e, o), r; | ||
} |
Oops, something went wrong.