@jsenv/core 40.3.1 → 40.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -33
- package/dist/browserslist_index/browserslist_index.js +4951 -0
- package/dist/build/build.js +189 -62
- package/dist/jsenv_core_node_modules.js +25 -1
- package/dist/jsenv_core_packages.js +6384 -11580
- package/dist/start_build_server/start_build_server.js +0 -5
- package/dist/start_dev_server/start_dev_server.js +108 -60
- package/package.json +20 -21
- package/src/build/build.js +80 -1
- package/src/kitchen/errors.js +6 -1
- package/src/kitchen/kitchen.js +95 -7
- package/src/plugins/package_side_effects/jsenv_plugin_package_side_effects.js +5 -51
- package/dist/babel_helpers/AsyncGenerator/AsyncGenerator.js +0 -112
- package/dist/babel_helpers/AwaitValue/AwaitValue.js +0 -3
- package/dist/babel_helpers/OverloadYield/OverloadYield.js +0 -11
- package/dist/babel_helpers/applyDecoratedDescriptor/applyDecoratedDescriptor.js +0 -32
- package/dist/babel_helpers/applyDecs/applyDecs.js +0 -813
- package/dist/babel_helpers/applyDecs2203/applyDecs2203.js +0 -635
- package/dist/babel_helpers/applyDecs2203R/applyDecs2203R.js +0 -654
- package/dist/babel_helpers/applyDecs2301/applyDecs2301.js +0 -721
- package/dist/babel_helpers/applyDecs2305/applyDecs2305.js +0 -531
- package/dist/babel_helpers/arrayLikeToArray/arrayLikeToArray.js +0 -7
- package/dist/babel_helpers/arrayWithHoles/arrayWithHoles.js +0 -4
- package/dist/babel_helpers/arrayWithoutHoles/arrayWithoutHoles.js +0 -6
- package/dist/babel_helpers/assertThisInitialized/assertThisInitialized.js +0 -9
- package/dist/babel_helpers/asyncGeneratorDelegate/asyncGeneratorDelegate.js +0 -55
- package/dist/babel_helpers/asyncIterator/asyncIterator.js +0 -68
- package/dist/babel_helpers/asyncToGenerator/asyncToGenerator.js +0 -34
- package/dist/babel_helpers/awaitAsyncGenerator/awaitAsyncGenerator.js +0 -5
- package/dist/babel_helpers/callSuper/callSuper.js +0 -25
- package/dist/babel_helpers/checkInRHS/checkInRHS.js +0 -11
- package/dist/babel_helpers/classApplyDescriptorDestructureSet/classApplyDescriptorDestructureSet.js +0 -23
- package/dist/babel_helpers/classApplyDescriptorGet/classApplyDescriptorGet.js +0 -6
- package/dist/babel_helpers/classApplyDescriptorSet/classApplyDescriptorSet.js +0 -13
- package/dist/babel_helpers/classCallCheck/classCallCheck.js +0 -5
- package/dist/babel_helpers/classCheckPrivateStaticAccess/classCheckPrivateStaticAccess.js +0 -8
- package/dist/babel_helpers/classCheckPrivateStaticFieldDescriptor/classCheckPrivateStaticFieldDescriptor.js +0 -11
- package/dist/babel_helpers/classExtractFieldDescriptor/classExtractFieldDescriptor.js +0 -13
- package/dist/babel_helpers/classNameTDZError/classNameTDZError.js +0 -6
- package/dist/babel_helpers/classPrivateFieldDestructureSet/classPrivateFieldDestructureSet.js +0 -7
- package/dist/babel_helpers/classPrivateFieldGet/classPrivateFieldGet.js +0 -7
- package/dist/babel_helpers/classPrivateFieldLooseBase/classPrivateFieldLooseBase.js +0 -6
- package/dist/babel_helpers/classPrivateFieldLooseKey/classPrivateFieldLooseKey.js +0 -5
- package/dist/babel_helpers/classPrivateFieldSet/classPrivateFieldSet.js +0 -8
- package/dist/babel_helpers/classPrivateMethodGet/classPrivateMethodGet.js +0 -6
- package/dist/babel_helpers/classPrivateMethodSet/classPrivateMethodSet.js +0 -3
- package/dist/babel_helpers/classStaticPrivateFieldSpecGet/classStaticPrivateFieldSpecGet.js +0 -13
- package/dist/babel_helpers/classStaticPrivateFieldSpecSet/classStaticPrivateFieldSpecSet.js +0 -15
- package/dist/babel_helpers/classStaticPrivateMethodGet/classStaticPrivateMethodGet.js +0 -10
- package/dist/babel_helpers/classStaticPrivateMethodSet/classStaticPrivateMethodSet.js +0 -3
- package/dist/babel_helpers/construct/construct.js +0 -20
- package/dist/babel_helpers/createClass/createClass.js +0 -17
- package/dist/babel_helpers/createForOfIteratorHelper/createForOfIteratorHelper.js +0 -61
- package/dist/babel_helpers/createForOfIteratorHelperLoose/createForOfIteratorHelperLoose.js +0 -24
- package/dist/babel_helpers/createRawReactElement/createRawReactElement.js +0 -50
- package/dist/babel_helpers/createSuper/createSuper.js +0 -22
- package/dist/babel_helpers/decorate/decorate.js +0 -488
- package/dist/babel_helpers/defaults/defaults.js +0 -11
- package/dist/babel_helpers/defineAccessor/defineAccessor.js +0 -6
- package/dist/babel_helpers/defineEnumerableProperties/defineEnumerableProperties.js +0 -23
- package/dist/babel_helpers/defineProperty/defineProperty.js +0 -21
- package/dist/babel_helpers/dispose/dispose.js +0 -45
- package/dist/babel_helpers/extends/extends.js +0 -14
- package/dist/babel_helpers/get/get.js +0 -19
- package/dist/babel_helpers/getPrototypeOf/getPrototypeOf.js +0 -4
- package/dist/babel_helpers/identity/identity.js +0 -3
- package/dist/babel_helpers/importDeferProxy/importDeferProxy.js +0 -31
- package/dist/babel_helpers/inherits/inherits.js +0 -19
- package/dist/babel_helpers/inheritsLoose/inheritsLoose.js +0 -7
- package/dist/babel_helpers/initializerDefineProperty/initializerDefineProperty.js +0 -12
- package/dist/babel_helpers/initializerWarningHelper/initializerWarningHelper.js +0 -6
- package/dist/babel_helpers/instanceof/instanceof.js +0 -10
- package/dist/babel_helpers/interopRequireDefault/interopRequireDefault.js +0 -3
- package/dist/babel_helpers/interopRequireWildcard/interopRequireWildcard.js +0 -47
- package/dist/babel_helpers/isNativeFunction/isNativeFunction.js +0 -9
- package/dist/babel_helpers/isNativeReflectConstruct/isNativeReflectConstruct.js +0 -19
- package/dist/babel_helpers/iterableToArray/iterableToArray.js +0 -7
- package/dist/babel_helpers/iterableToArrayLimit/iterableToArrayLimit.js +0 -54
- package/dist/babel_helpers/iterableToArrayLimitLoose/iterableToArrayLimitLoose.js +0 -16
- package/dist/babel_helpers/jsx/jsx.js +0 -50
- package/dist/babel_helpers/maybeArrayLike/maybeArrayLike.js +0 -10
- package/dist/babel_helpers/newArrowCheck/newArrowCheck.js +0 -5
- package/dist/babel_helpers/nonIterableRest/nonIterableRest.js +0 -5
- package/dist/babel_helpers/nonIterableSpread/nonIterableSpread.js +0 -5
- package/dist/babel_helpers/nullishReceiverError/nullishReceiverError.js +0 -3
- package/dist/babel_helpers/objectDestructuringEmpty/objectDestructuringEmpty.js +0 -3
- package/dist/babel_helpers/objectSpread/objectSpread.js +0 -23
- package/dist/babel_helpers/objectSpread2/objectSpread2.js +0 -43
- package/dist/babel_helpers/objectWithoutProperties/objectWithoutProperties.js +0 -19
- package/dist/babel_helpers/objectWithoutPropertiesLoose/objectWithoutPropertiesLoose.js +0 -13
- package/dist/babel_helpers/possibleConstructorReturn/possibleConstructorReturn.js +0 -12
- package/dist/babel_helpers/readOnlyError/readOnlyError.js +0 -4
- package/dist/babel_helpers/regeneratorRuntime/regeneratorRuntime.js +0 -698
- package/dist/babel_helpers/set/set.js +0 -47
- package/dist/babel_helpers/setFunctionName/setFunctionName.js +0 -19
- package/dist/babel_helpers/setPrototypeOf/setPrototypeOf.js +0 -7
- package/dist/babel_helpers/skipFirstGeneratorNext/skipFirstGeneratorNext.js +0 -8
- package/dist/babel_helpers/slicedToArray/slicedToArray.js +0 -10
- package/dist/babel_helpers/slicedToArrayLoose/slicedToArrayLoose.js +0 -13
- package/dist/babel_helpers/superPropBase/superPropBase.js +0 -10
- package/dist/babel_helpers/taggedTemplateLiteral/taggedTemplateLiteral.js +0 -10
- package/dist/babel_helpers/taggedTemplateLiteralLoose/taggedTemplateLiteralLoose.js +0 -7
- package/dist/babel_helpers/tdz/tdz.js +0 -4
- package/dist/babel_helpers/temporalRef/temporalRef.js +0 -6
- package/dist/babel_helpers/temporalUndefined/temporalUndefined.js +0 -3
- package/dist/babel_helpers/toArray/toArray.js +0 -10
- package/dist/babel_helpers/toConsumableArray/toConsumableArray.js +0 -10
- package/dist/babel_helpers/toPrimitive/toPrimitive.js +0 -14
- package/dist/babel_helpers/toPropertyKey/toPropertyKey.js +0 -10
- package/dist/babel_helpers/typeof/typeof.js +0 -15
- package/dist/babel_helpers/unsupportedIterableToArray/unsupportedIterableToArray.js +0 -12
- package/dist/babel_helpers/using/using.js +0 -23
- package/dist/babel_helpers/wrapAsyncGenerator/wrapAsyncGenerator.js +0 -8
- package/dist/babel_helpers/wrapNativeSuper/wrapNativeSuper.js +0 -30
- package/dist/babel_helpers/wrapRegExp/wrapRegExp.js +0 -79
- package/dist/babel_helpers/writeOnlyError/writeOnlyError.js +0 -3
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import superPropBase from "../superPropBase/superPropBase.js";
|
|
2
|
-
import defineProperty from "../defineProperty/defineProperty.js";
|
|
3
|
-
|
|
4
|
-
function reflectSetPolyfill(target, property, value, receiver) {
|
|
5
|
-
var base = superPropBase(target, property);
|
|
6
|
-
var desc;
|
|
7
|
-
if (base) {
|
|
8
|
-
desc = Object.getOwnPropertyDescriptor(base, property);
|
|
9
|
-
if (desc.set) {
|
|
10
|
-
desc.set.call(receiver, value);
|
|
11
|
-
return true;
|
|
12
|
-
} else if (!desc.writable) {
|
|
13
|
-
// Both getter and non-writable fall into this.
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
// Without a super that defines the property, spec boils down to
|
|
18
|
-
// "define on receiver" for some reason.
|
|
19
|
-
desc = Object.getOwnPropertyDescriptor(receiver, property);
|
|
20
|
-
if (desc) {
|
|
21
|
-
if (!desc.writable) {
|
|
22
|
-
// Setter, getter, and non-writable fall into this.
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
desc.value = value;
|
|
26
|
-
Object.defineProperty(receiver, property, desc);
|
|
27
|
-
} else {
|
|
28
|
-
// Avoid setters that may be defined on Sub's prototype, but not on
|
|
29
|
-
// the instance.
|
|
30
|
-
defineProperty(receiver, property, value);
|
|
31
|
-
}
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
var reflectSet =
|
|
36
|
-
typeof Reflect !== "undefined" && Reflect.set
|
|
37
|
-
? Reflect.set
|
|
38
|
-
: reflectSetPolyfill;
|
|
39
|
-
|
|
40
|
-
export default (target, property, value, receiver, isStrict) => {
|
|
41
|
-
// eslint-disable-next-line no-obj-calls
|
|
42
|
-
var s = reflectSet(target, property, value, receiver || target);
|
|
43
|
-
if (!s && isStrict) {
|
|
44
|
-
throw new TypeError("failed to set property");
|
|
45
|
-
}
|
|
46
|
-
return value;
|
|
47
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/* @minVersion 7.23.6 */
|
|
2
|
-
|
|
3
|
-
// https://tc39.es/ecma262/#sec-setfunctionname
|
|
4
|
-
export default function setFunctionName(fn, name, prefix) {
|
|
5
|
-
if (typeof name === "symbol") {
|
|
6
|
-
// Here `undefined` is possible, we check for it in the next line.
|
|
7
|
-
name = name.description;
|
|
8
|
-
name = name ? "[" + name + "]" : "";
|
|
9
|
-
}
|
|
10
|
-
// In some older browsers .name was non-configurable, here we catch any
|
|
11
|
-
// errors thrown by defineProperty.
|
|
12
|
-
try {
|
|
13
|
-
Object.defineProperty(fn, "name", {
|
|
14
|
-
configurable: true,
|
|
15
|
-
value: prefix ? prefix + " " + name : name,
|
|
16
|
-
});
|
|
17
|
-
} catch (_) {}
|
|
18
|
-
return fn;
|
|
19
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import arrayWithHoles from "../arrayWithHoles/arrayWithHoles.js";
|
|
2
|
-
import iterableToArrayLimit from "../iterableToArrayLimit/iterableToArrayLimit.js";
|
|
3
|
-
import unsupportedIterableToArray from "../unsupportedIterableToArray/unsupportedIterableToArray.js";
|
|
4
|
-
import nonIterableRest from "../nonIterableRest/nonIterableRest.js";
|
|
5
|
-
|
|
6
|
-
export default (arr, i) =>
|
|
7
|
-
arrayWithHoles(arr) ||
|
|
8
|
-
iterableToArrayLimit(arr, i) ||
|
|
9
|
-
unsupportedIterableToArray(arr, i) ||
|
|
10
|
-
nonIterableRest();
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import arrayWithHoles from "../arrayWithHoles/arrayWithHoles.js";
|
|
2
|
-
import iterableToArrayLimitLoose from "../iterableToArrayLimitLoose/iterableToArrayLimitLoose.js";
|
|
3
|
-
import unsupportedIterableToArray from "../unsupportedIterableToArray/unsupportedIterableToArray.js";
|
|
4
|
-
import nonIterableRest from "../nonIterableRest/nonIterableRest.js";
|
|
5
|
-
|
|
6
|
-
export default function (arr, i) {
|
|
7
|
-
return (
|
|
8
|
-
arrayWithHoles(arr) ||
|
|
9
|
-
iterableToArrayLimitLoose(arr, i) ||
|
|
10
|
-
unsupportedIterableToArray(arr, i) ||
|
|
11
|
-
nonIterableRest()
|
|
12
|
-
);
|
|
13
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import getPrototypeOf from "../getPrototypeOf/getPrototypeOf.js";
|
|
2
|
-
|
|
3
|
-
export default function (object, property) {
|
|
4
|
-
// Yes, this throws if object is null to being with, that's on purpose.
|
|
5
|
-
while (!Object.prototype.hasOwnProperty.call(object, property)) {
|
|
6
|
-
object = getPrototypeOf(object);
|
|
7
|
-
if (object === null) break;
|
|
8
|
-
}
|
|
9
|
-
return object;
|
|
10
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import arrayWithHoles from "../arrayWithHoles/arrayWithHoles.js";
|
|
2
|
-
import iterableToArray from "../iterableToArray/iterableToArray.js";
|
|
3
|
-
import unsupportedIterableToArray from "../unsupportedIterableToArray/unsupportedIterableToArray.js";
|
|
4
|
-
import nonIterableRest from "../nonIterableRest/nonIterableRest.js";
|
|
5
|
-
|
|
6
|
-
export default (arr) =>
|
|
7
|
-
arrayWithHoles(arr) ||
|
|
8
|
-
iterableToArray(arr) ||
|
|
9
|
-
unsupportedIterableToArray(arr) ||
|
|
10
|
-
nonIterableRest();
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import arrayWithoutHoles from "../arrayWithoutHoles/arrayWithoutHoles.js";
|
|
2
|
-
import iterableToArray from "../iterableToArray/iterableToArray.js";
|
|
3
|
-
import unsupportedIterableToArray from "../unsupportedIterableToArray/unsupportedIterableToArray.js";
|
|
4
|
-
import nonIterableSpread from "../nonIterableSpread/nonIterableSpread.js";
|
|
5
|
-
|
|
6
|
-
export default (arr) =>
|
|
7
|
-
arrayWithoutHoles(arr) ||
|
|
8
|
-
iterableToArray(arr) ||
|
|
9
|
-
unsupportedIterableToArray(arr) ||
|
|
10
|
-
nonIterableSpread();
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/* @minVersion 7.1.5 */
|
|
2
|
-
|
|
3
|
-
// https://tc39.es/ecma262/#sec-toprimitive
|
|
4
|
-
export default function toPrimitive(input, hint) {
|
|
5
|
-
if (typeof input !== "object" || !input) return input;
|
|
6
|
-
// @ts-expect-error Symbol.toPrimitive might not index {}
|
|
7
|
-
var prim = input[Symbol.toPrimitive];
|
|
8
|
-
if (prim !== undefined) {
|
|
9
|
-
var res = prim.call(input, hint || "default");
|
|
10
|
-
if (typeof res !== "object") return res;
|
|
11
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
12
|
-
}
|
|
13
|
-
return (hint === "string" ? String : Number)(input);
|
|
14
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/* @minVersion 7.1.5 */
|
|
2
|
-
|
|
3
|
-
// https://tc39.es/ecma262/#sec-topropertykey
|
|
4
|
-
|
|
5
|
-
import toPrimitive from "../toPrimitive/toPrimitive.js";
|
|
6
|
-
|
|
7
|
-
export default function toPropertyKey(arg) {
|
|
8
|
-
var key = toPrimitive(arg, "string");
|
|
9
|
-
return typeof key === "symbol" ? key : String(key);
|
|
10
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const nativeTypeOf = (obj) => typeof obj;
|
|
2
|
-
|
|
3
|
-
const customTypeOf = (obj) => {
|
|
4
|
-
return obj &&
|
|
5
|
-
typeof Symbol === "function" &&
|
|
6
|
-
obj.constructor === Symbol &&
|
|
7
|
-
obj !== Symbol.prototype
|
|
8
|
-
? "symbol"
|
|
9
|
-
: typeof obj;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default typeof Symbol === "function" &&
|
|
13
|
-
typeof Symbol.iterator === "symbol"
|
|
14
|
-
? nativeTypeOf
|
|
15
|
-
: customTypeOf;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/* eslint-disable consistent-return */
|
|
2
|
-
import arrayLikeToArray from "../arrayLikeToArray/arrayLikeToArray.js";
|
|
3
|
-
|
|
4
|
-
export default function unsupportedIterableToArray(o, minLen) {
|
|
5
|
-
if (!o) return;
|
|
6
|
-
if (typeof o === "string") return arrayLikeToArray(o, minLen);
|
|
7
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
8
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
9
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
10
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
11
|
-
return arrayLikeToArray(o, minLen);
|
|
12
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/* @minVersion 7.22.0 */
|
|
2
|
-
|
|
3
|
-
export default function _using(stack, value, isAwait) {
|
|
4
|
-
if (value === null || value === void 0) return value;
|
|
5
|
-
if (Object(value) !== value) {
|
|
6
|
-
throw new TypeError(
|
|
7
|
-
"using declarations can only be used with objects, functions, null, or undefined.",
|
|
8
|
-
);
|
|
9
|
-
}
|
|
10
|
-
// core-js-pure uses Symbol.for for polyfilling well-known symbols
|
|
11
|
-
if (isAwait) {
|
|
12
|
-
var dispose =
|
|
13
|
-
value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
|
|
14
|
-
}
|
|
15
|
-
if (dispose === null || dispose === void 0) {
|
|
16
|
-
dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
|
|
17
|
-
}
|
|
18
|
-
if (typeof dispose !== "function") {
|
|
19
|
-
throw new TypeError(`Property [Symbol.dispose] is not a function.`);
|
|
20
|
-
}
|
|
21
|
-
stack.push({ v: value, d: dispose, a: isAwait });
|
|
22
|
-
return value;
|
|
23
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import getPrototypeOf from "../getPrototypeOf/getPrototypeOf.js";
|
|
2
|
-
import setPrototypeOf from "../setPrototypeOf/setPrototypeOf.js";
|
|
3
|
-
import isNativeFunction from "../isNativeFunction/isNativeFunction.js";
|
|
4
|
-
import construct from "../construct/construct.js";
|
|
5
|
-
|
|
6
|
-
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
7
|
-
|
|
8
|
-
export default function (Class) {
|
|
9
|
-
if (Class === null || !isNativeFunction(Class)) return Class;
|
|
10
|
-
if (typeof Class !== "function") {
|
|
11
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
12
|
-
}
|
|
13
|
-
if (typeof _cache !== "undefined") {
|
|
14
|
-
if (_cache.has(Class)) return _cache.get(Class);
|
|
15
|
-
_cache.set(Class, Wrapper);
|
|
16
|
-
}
|
|
17
|
-
function Wrapper() {
|
|
18
|
-
// eslint-disable-next-line prefer-rest-params
|
|
19
|
-
return construct(Class, arguments, getPrototypeOf(this).constructor);
|
|
20
|
-
}
|
|
21
|
-
Wrapper.prototype = Object.create(Class.prototype, {
|
|
22
|
-
constructor: {
|
|
23
|
-
value: Wrapper,
|
|
24
|
-
enumerable: false,
|
|
25
|
-
writable: true,
|
|
26
|
-
configurable: true,
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
return setPrototypeOf(Wrapper, Class);
|
|
30
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/* @minVersion 7.19.0 */
|
|
2
|
-
|
|
3
|
-
import setPrototypeOf from "../setPrototypeOf/setPrototypeOf.js";
|
|
4
|
-
import inherits from "../inherits/inherits.js";
|
|
5
|
-
|
|
6
|
-
export default function _wrapRegExp() {
|
|
7
|
-
_wrapRegExp = function (re, groups) {
|
|
8
|
-
return new BabelRegExp(re, undefined, groups);
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
var _super = RegExp.prototype;
|
|
12
|
-
var _groups = new WeakMap();
|
|
13
|
-
|
|
14
|
-
function BabelRegExp(re, flags, groups) {
|
|
15
|
-
var _this = new RegExp(re, flags);
|
|
16
|
-
// if the regex is recreated with 'g' flag
|
|
17
|
-
_groups.set(_this, groups || _groups.get(re));
|
|
18
|
-
return setPrototypeOf(_this, BabelRegExp.prototype);
|
|
19
|
-
}
|
|
20
|
-
inherits(BabelRegExp, RegExp);
|
|
21
|
-
|
|
22
|
-
BabelRegExp.prototype.exec = function (str) {
|
|
23
|
-
var result = _super.exec.call(this, str);
|
|
24
|
-
if (result) {
|
|
25
|
-
result.groups = buildGroups(result, this);
|
|
26
|
-
var indices = result.indices;
|
|
27
|
-
if (indices) indices.groups = buildGroups(indices, this);
|
|
28
|
-
}
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
|
-
BabelRegExp.prototype[Symbol.replace] = function (str, substitution) {
|
|
32
|
-
if (typeof substitution === "string") {
|
|
33
|
-
var groups = _groups.get(this);
|
|
34
|
-
return _super[Symbol.replace].call(
|
|
35
|
-
this,
|
|
36
|
-
str,
|
|
37
|
-
substitution.replace(/\$<([^>]+)>/g, function (_, name) {
|
|
38
|
-
var group = groups[name];
|
|
39
|
-
return "$" + (Array.isArray(group) ? group.join("$") : group);
|
|
40
|
-
}),
|
|
41
|
-
);
|
|
42
|
-
} else if (typeof substitution === "function") {
|
|
43
|
-
var _this = this;
|
|
44
|
-
return _super[Symbol.replace].call(this, str, function () {
|
|
45
|
-
var args = arguments;
|
|
46
|
-
// Modern engines already pass result.groups returned by exec() as the last arg.
|
|
47
|
-
if (typeof args[args.length - 1] !== "object") {
|
|
48
|
-
args = [].slice.call(args);
|
|
49
|
-
args.push(buildGroups(args, _this));
|
|
50
|
-
}
|
|
51
|
-
return substitution.apply(this, args);
|
|
52
|
-
});
|
|
53
|
-
} else {
|
|
54
|
-
return _super[Symbol.replace].call(this, str, substitution);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
function buildGroups(result, re) {
|
|
59
|
-
// NOTE: This function should return undefined if there are no groups,
|
|
60
|
-
// but in that case Babel doesn't add the wrapper anyway.
|
|
61
|
-
|
|
62
|
-
var g = _groups.get(re);
|
|
63
|
-
return Object.keys(g).reduce(function (groups, name) {
|
|
64
|
-
var i = g[name];
|
|
65
|
-
if (typeof i === "number") groups[name] = result[i];
|
|
66
|
-
else {
|
|
67
|
-
// i is an array of indexes
|
|
68
|
-
var k = 0;
|
|
69
|
-
// if no group matched, we stop at k = i.length - 1 and then
|
|
70
|
-
// we store result[i[i.length - 1]] which is undefined.
|
|
71
|
-
while (result[i[k]] === undefined && k + 1 < i.length) k++;
|
|
72
|
-
groups[name] = result[i[k]];
|
|
73
|
-
}
|
|
74
|
-
return groups;
|
|
75
|
-
}, Object.create(null));
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return _wrapRegExp.apply(this, arguments);
|
|
79
|
-
}
|