mirror of
https://github.com/Feodor2/Mypal68.git
synced 2025-06-18 14:55:44 -04:00
44466 lines
1.2 MiB
44466 lines
1.2 MiB
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||
|
||
(function webpackUniversalModuleDefinition(root, factory) {
|
||
if(typeof exports === 'object' && typeof module === 'object')
|
||
module.exports = factory();
|
||
else if(typeof define === 'function' && define.amd)
|
||
define([], factory);
|
||
else {
|
||
var a = factory();
|
||
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
||
}
|
||
})(typeof self !== 'undefined' ? self : this, function() {
|
||
return /******/ (function(modules) { // webpackBootstrap
|
||
/******/ // The module cache
|
||
/******/ var installedModules = {};
|
||
/******/
|
||
/******/ // The require function
|
||
/******/ function __webpack_require__(moduleId) {
|
||
/******/
|
||
/******/ // Check if module is in cache
|
||
/******/ if(installedModules[moduleId]) {
|
||
/******/ return installedModules[moduleId].exports;
|
||
/******/ }
|
||
/******/ // Create a new module (and put it into the cache)
|
||
/******/ var module = installedModules[moduleId] = {
|
||
/******/ i: moduleId,
|
||
/******/ l: false,
|
||
/******/ exports: {}
|
||
/******/ };
|
||
/******/
|
||
/******/ // Execute the module function
|
||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
||
/******/
|
||
/******/ // Flag the module as loaded
|
||
/******/ module.l = true;
|
||
/******/
|
||
/******/ // Return the exports of the module
|
||
/******/ return module.exports;
|
||
/******/ }
|
||
/******/
|
||
/******/
|
||
/******/ // expose the modules object (__webpack_modules__)
|
||
/******/ __webpack_require__.m = modules;
|
||
/******/
|
||
/******/ // expose the module cache
|
||
/******/ __webpack_require__.c = installedModules;
|
||
/******/
|
||
/******/ // define getter function for harmony exports
|
||
/******/ __webpack_require__.d = function(exports, name, getter) {
|
||
/******/ if(!__webpack_require__.o(exports, name)) {
|
||
/******/ Object.defineProperty(exports, name, {
|
||
/******/ configurable: false,
|
||
/******/ enumerable: true,
|
||
/******/ get: getter
|
||
/******/ });
|
||
/******/ }
|
||
/******/ };
|
||
/******/
|
||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||
/******/ __webpack_require__.n = function(module) {
|
||
/******/ var getter = module && module.__esModule ?
|
||
/******/ function getDefault() { return module['default']; } :
|
||
/******/ function getModuleExports() { return module; };
|
||
/******/ __webpack_require__.d(getter, 'a', getter);
|
||
/******/ return getter;
|
||
/******/ };
|
||
/******/
|
||
/******/ // Object.prototype.hasOwnProperty.call
|
||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
||
/******/
|
||
/******/ // __webpack_public_path__
|
||
/******/ __webpack_require__.p = "/assets/build";
|
||
/******/
|
||
/******/ // Load entry module and return exports
|
||
/******/ return __webpack_require__(__webpack_require__.s = 198);
|
||
/******/ })
|
||
/************************************************************************/
|
||
/******/ ([
|
||
/* 0 */,
|
||
/* 1 */,
|
||
/* 2 */,
|
||
/* 3 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
var _exportNames = {
|
||
react: true,
|
||
assertNode: true,
|
||
createTypeAnnotationBasedOnTypeof: true,
|
||
createUnionTypeAnnotation: true,
|
||
cloneNode: true,
|
||
clone: true,
|
||
cloneDeep: true,
|
||
cloneWithoutLoc: true,
|
||
addComment: true,
|
||
addComments: true,
|
||
inheritInnerComments: true,
|
||
inheritLeadingComments: true,
|
||
inheritsComments: true,
|
||
inheritTrailingComments: true,
|
||
removeComments: true,
|
||
ensureBlock: true,
|
||
toBindingIdentifierName: true,
|
||
toBlock: true,
|
||
toComputedKey: true,
|
||
toExpression: true,
|
||
toIdentifier: true,
|
||
toKeyAlias: true,
|
||
toSequenceExpression: true,
|
||
toStatement: true,
|
||
valueToNode: true,
|
||
appendToMemberExpression: true,
|
||
inherits: true,
|
||
prependToMemberExpression: true,
|
||
removeProperties: true,
|
||
removePropertiesDeep: true,
|
||
removeTypeDuplicates: true,
|
||
getBindingIdentifiers: true,
|
||
getOuterBindingIdentifiers: true,
|
||
traverse: true,
|
||
traverseFast: true,
|
||
shallowEqual: true,
|
||
is: true,
|
||
isBinding: true,
|
||
isBlockScoped: true,
|
||
isImmutable: true,
|
||
isLet: true,
|
||
isNode: true,
|
||
isNodesEquivalent: true,
|
||
isPlaceholderType: true,
|
||
isReferenced: true,
|
||
isScope: true,
|
||
isSpecifierDefault: true,
|
||
isType: true,
|
||
isValidES3Identifier: true,
|
||
isValidIdentifier: true,
|
||
isVar: true,
|
||
matchesPattern: true,
|
||
validate: true,
|
||
buildMatchMemberExpression: true
|
||
};
|
||
Object.defineProperty(exports, "assertNode", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _assertNode.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "createTypeAnnotationBasedOnTypeof", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _createTypeAnnotationBasedOnTypeof.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "createUnionTypeAnnotation", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _createUnionTypeAnnotation.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "cloneNode", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _cloneNode.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "clone", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _clone.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "cloneDeep", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _cloneDeep.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "cloneWithoutLoc", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _cloneWithoutLoc.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "addComment", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _addComment.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "addComments", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _addComments.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "inheritInnerComments", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _inheritInnerComments.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "inheritLeadingComments", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _inheritLeadingComments.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "inheritsComments", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _inheritsComments.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "inheritTrailingComments", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _inheritTrailingComments.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "removeComments", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _removeComments.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "ensureBlock", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _ensureBlock.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "toBindingIdentifierName", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _toBindingIdentifierName.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "toBlock", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _toBlock.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "toComputedKey", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _toComputedKey.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "toExpression", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _toExpression.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "toIdentifier", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _toIdentifier.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "toKeyAlias", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _toKeyAlias.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "toSequenceExpression", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _toSequenceExpression.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "toStatement", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _toStatement.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "valueToNode", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _valueToNode.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "appendToMemberExpression", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _appendToMemberExpression.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "inherits", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _inherits.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "prependToMemberExpression", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _prependToMemberExpression.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "removeProperties", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _removeProperties.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "removePropertiesDeep", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _removePropertiesDeep.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "removeTypeDuplicates", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _removeTypeDuplicates.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "getBindingIdentifiers", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _getBindingIdentifiers.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "getOuterBindingIdentifiers", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _getOuterBindingIdentifiers.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "traverse", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _traverse.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "traverseFast", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _traverseFast.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "shallowEqual", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _shallowEqual.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "is", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _is.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "isBinding", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _isBinding.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "isBlockScoped", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _isBlockScoped.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "isImmutable", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _isImmutable.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "isLet", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _isLet.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "isNode", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _isNode.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "isNodesEquivalent", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _isNodesEquivalent.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "isPlaceholderType", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _isPlaceholderType.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "isReferenced", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _isReferenced.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "isScope", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _isScope.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "isSpecifierDefault", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _isSpecifierDefault.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "isType", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _isType.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "isValidES3Identifier", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _isValidES3Identifier.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "isValidIdentifier", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _isValidIdentifier.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "isVar", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _isVar.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "matchesPattern", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _matchesPattern.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "validate", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _validate.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "buildMatchMemberExpression", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _buildMatchMemberExpression.default;
|
||
}
|
||
});
|
||
exports.react = void 0;
|
||
|
||
var _isReactComponent = _interopRequireDefault(__webpack_require__(200));
|
||
|
||
var _isCompatTag = _interopRequireDefault(__webpack_require__(201));
|
||
|
||
var _buildChildren = _interopRequireDefault(__webpack_require__(202));
|
||
|
||
var _assertNode = _interopRequireDefault(__webpack_require__(274));
|
||
|
||
var _generated = __webpack_require__(275);
|
||
|
||
Object.keys(_generated).forEach(function (key) {
|
||
if (key === "default" || key === "__esModule") return;
|
||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||
Object.defineProperty(exports, key, {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _generated[key];
|
||
}
|
||
});
|
||
});
|
||
|
||
var _createTypeAnnotationBasedOnTypeof = _interopRequireDefault(__webpack_require__(276));
|
||
|
||
var _createUnionTypeAnnotation = _interopRequireDefault(__webpack_require__(277));
|
||
|
||
var _generated2 = __webpack_require__(10);
|
||
|
||
Object.keys(_generated2).forEach(function (key) {
|
||
if (key === "default" || key === "__esModule") return;
|
||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||
Object.defineProperty(exports, key, {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _generated2[key];
|
||
}
|
||
});
|
||
});
|
||
|
||
var _cloneNode = _interopRequireDefault(__webpack_require__(31));
|
||
|
||
var _clone = _interopRequireDefault(__webpack_require__(139));
|
||
|
||
var _cloneDeep = _interopRequireDefault(__webpack_require__(278));
|
||
|
||
var _cloneWithoutLoc = _interopRequireDefault(__webpack_require__(279));
|
||
|
||
var _addComment = _interopRequireDefault(__webpack_require__(280));
|
||
|
||
var _addComments = _interopRequireDefault(__webpack_require__(140));
|
||
|
||
var _inheritInnerComments = _interopRequireDefault(__webpack_require__(141));
|
||
|
||
var _inheritLeadingComments = _interopRequireDefault(__webpack_require__(144));
|
||
|
||
var _inheritsComments = _interopRequireDefault(__webpack_require__(145));
|
||
|
||
var _inheritTrailingComments = _interopRequireDefault(__webpack_require__(146));
|
||
|
||
var _removeComments = _interopRequireDefault(__webpack_require__(292));
|
||
|
||
var _generated3 = __webpack_require__(293);
|
||
|
||
Object.keys(_generated3).forEach(function (key) {
|
||
if (key === "default" || key === "__esModule") return;
|
||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||
Object.defineProperty(exports, key, {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _generated3[key];
|
||
}
|
||
});
|
||
});
|
||
|
||
var _constants = __webpack_require__(27);
|
||
|
||
Object.keys(_constants).forEach(function (key) {
|
||
if (key === "default" || key === "__esModule") return;
|
||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||
Object.defineProperty(exports, key, {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _constants[key];
|
||
}
|
||
});
|
||
});
|
||
|
||
var _ensureBlock = _interopRequireDefault(__webpack_require__(294));
|
||
|
||
var _toBindingIdentifierName = _interopRequireDefault(__webpack_require__(295));
|
||
|
||
var _toBlock = _interopRequireDefault(__webpack_require__(147));
|
||
|
||
var _toComputedKey = _interopRequireDefault(__webpack_require__(296));
|
||
|
||
var _toExpression = _interopRequireDefault(__webpack_require__(297));
|
||
|
||
var _toIdentifier = _interopRequireDefault(__webpack_require__(148));
|
||
|
||
var _toKeyAlias = _interopRequireDefault(__webpack_require__(298));
|
||
|
||
var _toSequenceExpression = _interopRequireDefault(__webpack_require__(299));
|
||
|
||
var _toStatement = _interopRequireDefault(__webpack_require__(301));
|
||
|
||
var _valueToNode = _interopRequireDefault(__webpack_require__(302));
|
||
|
||
var _definitions = __webpack_require__(16);
|
||
|
||
Object.keys(_definitions).forEach(function (key) {
|
||
if (key === "default" || key === "__esModule") return;
|
||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||
Object.defineProperty(exports, key, {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _definitions[key];
|
||
}
|
||
});
|
||
});
|
||
|
||
var _appendToMemberExpression = _interopRequireDefault(__webpack_require__(306));
|
||
|
||
var _inherits = _interopRequireDefault(__webpack_require__(307));
|
||
|
||
var _prependToMemberExpression = _interopRequireDefault(__webpack_require__(308));
|
||
|
||
var _removeProperties = _interopRequireDefault(__webpack_require__(151));
|
||
|
||
var _removePropertiesDeep = _interopRequireDefault(__webpack_require__(149));
|
||
|
||
var _removeTypeDuplicates = _interopRequireDefault(__webpack_require__(138));
|
||
|
||
var _getBindingIdentifiers = _interopRequireDefault(__webpack_require__(53));
|
||
|
||
var _getOuterBindingIdentifiers = _interopRequireDefault(__webpack_require__(309));
|
||
|
||
var _traverse = _interopRequireDefault(__webpack_require__(310));
|
||
|
||
var _traverseFast = _interopRequireDefault(__webpack_require__(150));
|
||
|
||
var _shallowEqual = _interopRequireDefault(__webpack_require__(68));
|
||
|
||
var _is = _interopRequireDefault(__webpack_require__(82));
|
||
|
||
var _isBinding = _interopRequireDefault(__webpack_require__(311));
|
||
|
||
var _isBlockScoped = _interopRequireDefault(__webpack_require__(312));
|
||
|
||
var _isImmutable = _interopRequireDefault(__webpack_require__(313));
|
||
|
||
var _isLet = _interopRequireDefault(__webpack_require__(152));
|
||
|
||
var _isNode = _interopRequireDefault(__webpack_require__(137));
|
||
|
||
var _isNodesEquivalent = _interopRequireDefault(__webpack_require__(314));
|
||
|
||
var _isPlaceholderType = _interopRequireDefault(__webpack_require__(517));
|
||
|
||
var _isReferenced = _interopRequireDefault(__webpack_require__(315));
|
||
|
||
var _isScope = _interopRequireDefault(__webpack_require__(316));
|
||
|
||
var _isSpecifierDefault = _interopRequireDefault(__webpack_require__(317));
|
||
|
||
var _isType = _interopRequireDefault(__webpack_require__(83));
|
||
|
||
var _isValidES3Identifier = _interopRequireDefault(__webpack_require__(318));
|
||
|
||
var _isValidIdentifier = _interopRequireDefault(__webpack_require__(30));
|
||
|
||
var _isVar = _interopRequireDefault(__webpack_require__(319));
|
||
|
||
var _matchesPattern = _interopRequireDefault(__webpack_require__(119));
|
||
|
||
var _validate = _interopRequireDefault(__webpack_require__(136));
|
||
|
||
var _buildMatchMemberExpression = _interopRequireDefault(__webpack_require__(118));
|
||
|
||
var _generated4 = __webpack_require__(5);
|
||
|
||
Object.keys(_generated4).forEach(function (key) {
|
||
if (key === "default" || key === "__esModule") return;
|
||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||
Object.defineProperty(exports, key, {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _generated4[key];
|
||
}
|
||
});
|
||
});
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
const react = {
|
||
isReactComponent: _isReactComponent.default,
|
||
isCompatTag: _isCompatTag.default,
|
||
buildChildren: _buildChildren.default
|
||
};
|
||
exports.react = react;
|
||
|
||
/***/ }),
|
||
/* 4 */,
|
||
/* 5 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.isArrayExpression = isArrayExpression;
|
||
exports.isAssignmentExpression = isAssignmentExpression;
|
||
exports.isBinaryExpression = isBinaryExpression;
|
||
exports.isInterpreterDirective = isInterpreterDirective;
|
||
exports.isDirective = isDirective;
|
||
exports.isDirectiveLiteral = isDirectiveLiteral;
|
||
exports.isBlockStatement = isBlockStatement;
|
||
exports.isBreakStatement = isBreakStatement;
|
||
exports.isCallExpression = isCallExpression;
|
||
exports.isCatchClause = isCatchClause;
|
||
exports.isConditionalExpression = isConditionalExpression;
|
||
exports.isContinueStatement = isContinueStatement;
|
||
exports.isDebuggerStatement = isDebuggerStatement;
|
||
exports.isDoWhileStatement = isDoWhileStatement;
|
||
exports.isEmptyStatement = isEmptyStatement;
|
||
exports.isExpressionStatement = isExpressionStatement;
|
||
exports.isFile = isFile;
|
||
exports.isForInStatement = isForInStatement;
|
||
exports.isForStatement = isForStatement;
|
||
exports.isFunctionDeclaration = isFunctionDeclaration;
|
||
exports.isFunctionExpression = isFunctionExpression;
|
||
exports.isIdentifier = isIdentifier;
|
||
exports.isIfStatement = isIfStatement;
|
||
exports.isLabeledStatement = isLabeledStatement;
|
||
exports.isStringLiteral = isStringLiteral;
|
||
exports.isNumericLiteral = isNumericLiteral;
|
||
exports.isNullLiteral = isNullLiteral;
|
||
exports.isBooleanLiteral = isBooleanLiteral;
|
||
exports.isRegExpLiteral = isRegExpLiteral;
|
||
exports.isLogicalExpression = isLogicalExpression;
|
||
exports.isMemberExpression = isMemberExpression;
|
||
exports.isNewExpression = isNewExpression;
|
||
exports.isProgram = isProgram;
|
||
exports.isObjectExpression = isObjectExpression;
|
||
exports.isObjectMethod = isObjectMethod;
|
||
exports.isObjectProperty = isObjectProperty;
|
||
exports.isRestElement = isRestElement;
|
||
exports.isReturnStatement = isReturnStatement;
|
||
exports.isSequenceExpression = isSequenceExpression;
|
||
exports.isParenthesizedExpression = isParenthesizedExpression;
|
||
exports.isSwitchCase = isSwitchCase;
|
||
exports.isSwitchStatement = isSwitchStatement;
|
||
exports.isThisExpression = isThisExpression;
|
||
exports.isThrowStatement = isThrowStatement;
|
||
exports.isTryStatement = isTryStatement;
|
||
exports.isUnaryExpression = isUnaryExpression;
|
||
exports.isUpdateExpression = isUpdateExpression;
|
||
exports.isVariableDeclaration = isVariableDeclaration;
|
||
exports.isVariableDeclarator = isVariableDeclarator;
|
||
exports.isWhileStatement = isWhileStatement;
|
||
exports.isWithStatement = isWithStatement;
|
||
exports.isAssignmentPattern = isAssignmentPattern;
|
||
exports.isArrayPattern = isArrayPattern;
|
||
exports.isArrowFunctionExpression = isArrowFunctionExpression;
|
||
exports.isClassBody = isClassBody;
|
||
exports.isClassDeclaration = isClassDeclaration;
|
||
exports.isClassExpression = isClassExpression;
|
||
exports.isExportAllDeclaration = isExportAllDeclaration;
|
||
exports.isExportDefaultDeclaration = isExportDefaultDeclaration;
|
||
exports.isExportNamedDeclaration = isExportNamedDeclaration;
|
||
exports.isExportSpecifier = isExportSpecifier;
|
||
exports.isForOfStatement = isForOfStatement;
|
||
exports.isImportDeclaration = isImportDeclaration;
|
||
exports.isImportDefaultSpecifier = isImportDefaultSpecifier;
|
||
exports.isImportNamespaceSpecifier = isImportNamespaceSpecifier;
|
||
exports.isImportSpecifier = isImportSpecifier;
|
||
exports.isMetaProperty = isMetaProperty;
|
||
exports.isClassMethod = isClassMethod;
|
||
exports.isObjectPattern = isObjectPattern;
|
||
exports.isSpreadElement = isSpreadElement;
|
||
exports.isSuper = isSuper;
|
||
exports.isTaggedTemplateExpression = isTaggedTemplateExpression;
|
||
exports.isTemplateElement = isTemplateElement;
|
||
exports.isTemplateLiteral = isTemplateLiteral;
|
||
exports.isYieldExpression = isYieldExpression;
|
||
exports.isAnyTypeAnnotation = isAnyTypeAnnotation;
|
||
exports.isArrayTypeAnnotation = isArrayTypeAnnotation;
|
||
exports.isBooleanTypeAnnotation = isBooleanTypeAnnotation;
|
||
exports.isBooleanLiteralTypeAnnotation = isBooleanLiteralTypeAnnotation;
|
||
exports.isNullLiteralTypeAnnotation = isNullLiteralTypeAnnotation;
|
||
exports.isClassImplements = isClassImplements;
|
||
exports.isDeclareClass = isDeclareClass;
|
||
exports.isDeclareFunction = isDeclareFunction;
|
||
exports.isDeclareInterface = isDeclareInterface;
|
||
exports.isDeclareModule = isDeclareModule;
|
||
exports.isDeclareModuleExports = isDeclareModuleExports;
|
||
exports.isDeclareTypeAlias = isDeclareTypeAlias;
|
||
exports.isDeclareOpaqueType = isDeclareOpaqueType;
|
||
exports.isDeclareVariable = isDeclareVariable;
|
||
exports.isDeclareExportDeclaration = isDeclareExportDeclaration;
|
||
exports.isDeclareExportAllDeclaration = isDeclareExportAllDeclaration;
|
||
exports.isDeclaredPredicate = isDeclaredPredicate;
|
||
exports.isExistsTypeAnnotation = isExistsTypeAnnotation;
|
||
exports.isFunctionTypeAnnotation = isFunctionTypeAnnotation;
|
||
exports.isFunctionTypeParam = isFunctionTypeParam;
|
||
exports.isGenericTypeAnnotation = isGenericTypeAnnotation;
|
||
exports.isInferredPredicate = isInferredPredicate;
|
||
exports.isInterfaceExtends = isInterfaceExtends;
|
||
exports.isInterfaceDeclaration = isInterfaceDeclaration;
|
||
exports.isInterfaceTypeAnnotation = isInterfaceTypeAnnotation;
|
||
exports.isIntersectionTypeAnnotation = isIntersectionTypeAnnotation;
|
||
exports.isMixedTypeAnnotation = isMixedTypeAnnotation;
|
||
exports.isEmptyTypeAnnotation = isEmptyTypeAnnotation;
|
||
exports.isNullableTypeAnnotation = isNullableTypeAnnotation;
|
||
exports.isNumberLiteralTypeAnnotation = isNumberLiteralTypeAnnotation;
|
||
exports.isNumberTypeAnnotation = isNumberTypeAnnotation;
|
||
exports.isObjectTypeAnnotation = isObjectTypeAnnotation;
|
||
exports.isObjectTypeInternalSlot = isObjectTypeInternalSlot;
|
||
exports.isObjectTypeCallProperty = isObjectTypeCallProperty;
|
||
exports.isObjectTypeIndexer = isObjectTypeIndexer;
|
||
exports.isObjectTypeProperty = isObjectTypeProperty;
|
||
exports.isObjectTypeSpreadProperty = isObjectTypeSpreadProperty;
|
||
exports.isOpaqueType = isOpaqueType;
|
||
exports.isQualifiedTypeIdentifier = isQualifiedTypeIdentifier;
|
||
exports.isStringLiteralTypeAnnotation = isStringLiteralTypeAnnotation;
|
||
exports.isStringTypeAnnotation = isStringTypeAnnotation;
|
||
exports.isThisTypeAnnotation = isThisTypeAnnotation;
|
||
exports.isTupleTypeAnnotation = isTupleTypeAnnotation;
|
||
exports.isTypeofTypeAnnotation = isTypeofTypeAnnotation;
|
||
exports.isTypeAlias = isTypeAlias;
|
||
exports.isTypeAnnotation = isTypeAnnotation;
|
||
exports.isTypeCastExpression = isTypeCastExpression;
|
||
exports.isTypeParameter = isTypeParameter;
|
||
exports.isTypeParameterDeclaration = isTypeParameterDeclaration;
|
||
exports.isTypeParameterInstantiation = isTypeParameterInstantiation;
|
||
exports.isUnionTypeAnnotation = isUnionTypeAnnotation;
|
||
exports.isVariance = isVariance;
|
||
exports.isVoidTypeAnnotation = isVoidTypeAnnotation;
|
||
exports.isJSXAttribute = isJSXAttribute;
|
||
exports.isJSXClosingElement = isJSXClosingElement;
|
||
exports.isJSXElement = isJSXElement;
|
||
exports.isJSXEmptyExpression = isJSXEmptyExpression;
|
||
exports.isJSXExpressionContainer = isJSXExpressionContainer;
|
||
exports.isJSXSpreadChild = isJSXSpreadChild;
|
||
exports.isJSXIdentifier = isJSXIdentifier;
|
||
exports.isJSXMemberExpression = isJSXMemberExpression;
|
||
exports.isJSXNamespacedName = isJSXNamespacedName;
|
||
exports.isJSXOpeningElement = isJSXOpeningElement;
|
||
exports.isJSXSpreadAttribute = isJSXSpreadAttribute;
|
||
exports.isJSXText = isJSXText;
|
||
exports.isJSXFragment = isJSXFragment;
|
||
exports.isJSXOpeningFragment = isJSXOpeningFragment;
|
||
exports.isJSXClosingFragment = isJSXClosingFragment;
|
||
exports.isNoop = isNoop;
|
||
exports.isPlaceholder = isPlaceholder;
|
||
exports.isArgumentPlaceholder = isArgumentPlaceholder;
|
||
exports.isAwaitExpression = isAwaitExpression;
|
||
exports.isBindExpression = isBindExpression;
|
||
exports.isClassProperty = isClassProperty;
|
||
exports.isOptionalMemberExpression = isOptionalMemberExpression;
|
||
exports.isPipelineTopicExpression = isPipelineTopicExpression;
|
||
exports.isPipelineBareFunction = isPipelineBareFunction;
|
||
exports.isPipelinePrimaryTopicReference = isPipelinePrimaryTopicReference;
|
||
exports.isOptionalCallExpression = isOptionalCallExpression;
|
||
exports.isClassPrivateProperty = isClassPrivateProperty;
|
||
exports.isClassPrivateMethod = isClassPrivateMethod;
|
||
exports.isImport = isImport;
|
||
exports.isDecorator = isDecorator;
|
||
exports.isDoExpression = isDoExpression;
|
||
exports.isExportDefaultSpecifier = isExportDefaultSpecifier;
|
||
exports.isExportNamespaceSpecifier = isExportNamespaceSpecifier;
|
||
exports.isPrivateName = isPrivateName;
|
||
exports.isBigIntLiteral = isBigIntLiteral;
|
||
exports.isTSParameterProperty = isTSParameterProperty;
|
||
exports.isTSDeclareFunction = isTSDeclareFunction;
|
||
exports.isTSDeclareMethod = isTSDeclareMethod;
|
||
exports.isTSQualifiedName = isTSQualifiedName;
|
||
exports.isTSCallSignatureDeclaration = isTSCallSignatureDeclaration;
|
||
exports.isTSConstructSignatureDeclaration = isTSConstructSignatureDeclaration;
|
||
exports.isTSPropertySignature = isTSPropertySignature;
|
||
exports.isTSMethodSignature = isTSMethodSignature;
|
||
exports.isTSIndexSignature = isTSIndexSignature;
|
||
exports.isTSAnyKeyword = isTSAnyKeyword;
|
||
exports.isTSUnknownKeyword = isTSUnknownKeyword;
|
||
exports.isTSNumberKeyword = isTSNumberKeyword;
|
||
exports.isTSObjectKeyword = isTSObjectKeyword;
|
||
exports.isTSBooleanKeyword = isTSBooleanKeyword;
|
||
exports.isTSStringKeyword = isTSStringKeyword;
|
||
exports.isTSSymbolKeyword = isTSSymbolKeyword;
|
||
exports.isTSVoidKeyword = isTSVoidKeyword;
|
||
exports.isTSUndefinedKeyword = isTSUndefinedKeyword;
|
||
exports.isTSNullKeyword = isTSNullKeyword;
|
||
exports.isTSNeverKeyword = isTSNeverKeyword;
|
||
exports.isTSThisType = isTSThisType;
|
||
exports.isTSFunctionType = isTSFunctionType;
|
||
exports.isTSConstructorType = isTSConstructorType;
|
||
exports.isTSTypeReference = isTSTypeReference;
|
||
exports.isTSTypePredicate = isTSTypePredicate;
|
||
exports.isTSTypeQuery = isTSTypeQuery;
|
||
exports.isTSTypeLiteral = isTSTypeLiteral;
|
||
exports.isTSArrayType = isTSArrayType;
|
||
exports.isTSTupleType = isTSTupleType;
|
||
exports.isTSOptionalType = isTSOptionalType;
|
||
exports.isTSRestType = isTSRestType;
|
||
exports.isTSUnionType = isTSUnionType;
|
||
exports.isTSIntersectionType = isTSIntersectionType;
|
||
exports.isTSConditionalType = isTSConditionalType;
|
||
exports.isTSInferType = isTSInferType;
|
||
exports.isTSParenthesizedType = isTSParenthesizedType;
|
||
exports.isTSTypeOperator = isTSTypeOperator;
|
||
exports.isTSIndexedAccessType = isTSIndexedAccessType;
|
||
exports.isTSMappedType = isTSMappedType;
|
||
exports.isTSLiteralType = isTSLiteralType;
|
||
exports.isTSExpressionWithTypeArguments = isTSExpressionWithTypeArguments;
|
||
exports.isTSInterfaceDeclaration = isTSInterfaceDeclaration;
|
||
exports.isTSInterfaceBody = isTSInterfaceBody;
|
||
exports.isTSTypeAliasDeclaration = isTSTypeAliasDeclaration;
|
||
exports.isTSAsExpression = isTSAsExpression;
|
||
exports.isTSTypeAssertion = isTSTypeAssertion;
|
||
exports.isTSEnumDeclaration = isTSEnumDeclaration;
|
||
exports.isTSEnumMember = isTSEnumMember;
|
||
exports.isTSModuleDeclaration = isTSModuleDeclaration;
|
||
exports.isTSModuleBlock = isTSModuleBlock;
|
||
exports.isTSImportType = isTSImportType;
|
||
exports.isTSImportEqualsDeclaration = isTSImportEqualsDeclaration;
|
||
exports.isTSExternalModuleReference = isTSExternalModuleReference;
|
||
exports.isTSNonNullExpression = isTSNonNullExpression;
|
||
exports.isTSExportAssignment = isTSExportAssignment;
|
||
exports.isTSNamespaceExportDeclaration = isTSNamespaceExportDeclaration;
|
||
exports.isTSTypeAnnotation = isTSTypeAnnotation;
|
||
exports.isTSTypeParameterInstantiation = isTSTypeParameterInstantiation;
|
||
exports.isTSTypeParameterDeclaration = isTSTypeParameterDeclaration;
|
||
exports.isTSTypeParameter = isTSTypeParameter;
|
||
exports.isExpression = isExpression;
|
||
exports.isBinary = isBinary;
|
||
exports.isScopable = isScopable;
|
||
exports.isBlockParent = isBlockParent;
|
||
exports.isBlock = isBlock;
|
||
exports.isStatement = isStatement;
|
||
exports.isTerminatorless = isTerminatorless;
|
||
exports.isCompletionStatement = isCompletionStatement;
|
||
exports.isConditional = isConditional;
|
||
exports.isLoop = isLoop;
|
||
exports.isWhile = isWhile;
|
||
exports.isExpressionWrapper = isExpressionWrapper;
|
||
exports.isFor = isFor;
|
||
exports.isForXStatement = isForXStatement;
|
||
exports.isFunction = isFunction;
|
||
exports.isFunctionParent = isFunctionParent;
|
||
exports.isPureish = isPureish;
|
||
exports.isDeclaration = isDeclaration;
|
||
exports.isPatternLike = isPatternLike;
|
||
exports.isLVal = isLVal;
|
||
exports.isTSEntityName = isTSEntityName;
|
||
exports.isLiteral = isLiteral;
|
||
exports.isImmutable = isImmutable;
|
||
exports.isUserWhitespacable = isUserWhitespacable;
|
||
exports.isMethod = isMethod;
|
||
exports.isObjectMember = isObjectMember;
|
||
exports.isProperty = isProperty;
|
||
exports.isUnaryLike = isUnaryLike;
|
||
exports.isPattern = isPattern;
|
||
exports.isClass = isClass;
|
||
exports.isModuleDeclaration = isModuleDeclaration;
|
||
exports.isExportDeclaration = isExportDeclaration;
|
||
exports.isModuleSpecifier = isModuleSpecifier;
|
||
exports.isFlow = isFlow;
|
||
exports.isFlowType = isFlowType;
|
||
exports.isFlowBaseAnnotation = isFlowBaseAnnotation;
|
||
exports.isFlowDeclaration = isFlowDeclaration;
|
||
exports.isFlowPredicate = isFlowPredicate;
|
||
exports.isJSX = isJSX;
|
||
exports.isPrivate = isPrivate;
|
||
exports.isTSTypeElement = isTSTypeElement;
|
||
exports.isTSType = isTSType;
|
||
exports.isNumberLiteral = isNumberLiteral;
|
||
exports.isRegexLiteral = isRegexLiteral;
|
||
exports.isRestProperty = isRestProperty;
|
||
exports.isSpreadProperty = isSpreadProperty;
|
||
|
||
var _shallowEqual = _interopRequireDefault(__webpack_require__(68));
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function isArrayExpression(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ArrayExpression") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isAssignmentExpression(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "AssignmentExpression") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isBinaryExpression(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "BinaryExpression") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isInterpreterDirective(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "InterpreterDirective") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isDirective(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "Directive") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isDirectiveLiteral(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "DirectiveLiteral") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isBlockStatement(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "BlockStatement") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isBreakStatement(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "BreakStatement") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isCallExpression(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "CallExpression") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isCatchClause(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "CatchClause") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isConditionalExpression(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ConditionalExpression") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isContinueStatement(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ContinueStatement") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isDebuggerStatement(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "DebuggerStatement") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isDoWhileStatement(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "DoWhileStatement") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isEmptyStatement(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "EmptyStatement") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isExpressionStatement(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ExpressionStatement") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isFile(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "File") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isForInStatement(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ForInStatement") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isForStatement(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ForStatement") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isFunctionDeclaration(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "FunctionDeclaration") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isFunctionExpression(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "FunctionExpression") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isIdentifier(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "Identifier") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isIfStatement(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "IfStatement") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isLabeledStatement(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "LabeledStatement") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isStringLiteral(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "StringLiteral") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isNumericLiteral(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "NumericLiteral") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isNullLiteral(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "NullLiteral") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isBooleanLiteral(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "BooleanLiteral") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isRegExpLiteral(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "RegExpLiteral") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isLogicalExpression(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "LogicalExpression") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isMemberExpression(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "MemberExpression") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isNewExpression(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "NewExpression") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isProgram(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "Program") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isObjectExpression(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ObjectExpression") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isObjectMethod(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ObjectMethod") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isObjectProperty(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ObjectProperty") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isRestElement(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "RestElement") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isReturnStatement(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ReturnStatement") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isSequenceExpression(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "SequenceExpression") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isParenthesizedExpression(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ParenthesizedExpression") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isSwitchCase(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "SwitchCase") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isSwitchStatement(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "SwitchStatement") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isThisExpression(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ThisExpression") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isThrowStatement(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ThrowStatement") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTryStatement(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TryStatement") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isUnaryExpression(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "UnaryExpression") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isUpdateExpression(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "UpdateExpression") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isVariableDeclaration(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "VariableDeclaration") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isVariableDeclarator(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "VariableDeclarator") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isWhileStatement(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "WhileStatement") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isWithStatement(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "WithStatement") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isAssignmentPattern(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "AssignmentPattern") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isArrayPattern(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ArrayPattern") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isArrowFunctionExpression(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ArrowFunctionExpression") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isClassBody(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ClassBody") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isClassDeclaration(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ClassDeclaration") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isClassExpression(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ClassExpression") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isExportAllDeclaration(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ExportAllDeclaration") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isExportDefaultDeclaration(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ExportDefaultDeclaration") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isExportNamedDeclaration(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ExportNamedDeclaration") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isExportSpecifier(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ExportSpecifier") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isForOfStatement(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ForOfStatement") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isImportDeclaration(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ImportDeclaration") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isImportDefaultSpecifier(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ImportDefaultSpecifier") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isImportNamespaceSpecifier(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ImportNamespaceSpecifier") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isImportSpecifier(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ImportSpecifier") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isMetaProperty(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "MetaProperty") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isClassMethod(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ClassMethod") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isObjectPattern(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ObjectPattern") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isSpreadElement(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "SpreadElement") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isSuper(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "Super") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTaggedTemplateExpression(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TaggedTemplateExpression") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTemplateElement(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TemplateElement") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTemplateLiteral(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TemplateLiteral") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isYieldExpression(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "YieldExpression") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isAnyTypeAnnotation(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "AnyTypeAnnotation") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isArrayTypeAnnotation(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ArrayTypeAnnotation") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isBooleanTypeAnnotation(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "BooleanTypeAnnotation") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isBooleanLiteralTypeAnnotation(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "BooleanLiteralTypeAnnotation") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isNullLiteralTypeAnnotation(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "NullLiteralTypeAnnotation") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isClassImplements(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ClassImplements") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isDeclareClass(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "DeclareClass") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isDeclareFunction(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "DeclareFunction") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isDeclareInterface(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "DeclareInterface") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isDeclareModule(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "DeclareModule") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isDeclareModuleExports(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "DeclareModuleExports") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isDeclareTypeAlias(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "DeclareTypeAlias") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isDeclareOpaqueType(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "DeclareOpaqueType") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isDeclareVariable(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "DeclareVariable") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isDeclareExportDeclaration(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "DeclareExportDeclaration") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isDeclareExportAllDeclaration(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "DeclareExportAllDeclaration") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isDeclaredPredicate(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "DeclaredPredicate") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isExistsTypeAnnotation(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ExistsTypeAnnotation") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isFunctionTypeAnnotation(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "FunctionTypeAnnotation") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isFunctionTypeParam(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "FunctionTypeParam") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isGenericTypeAnnotation(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "GenericTypeAnnotation") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isInferredPredicate(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "InferredPredicate") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isInterfaceExtends(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "InterfaceExtends") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isInterfaceDeclaration(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "InterfaceDeclaration") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isInterfaceTypeAnnotation(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "InterfaceTypeAnnotation") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isIntersectionTypeAnnotation(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "IntersectionTypeAnnotation") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isMixedTypeAnnotation(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "MixedTypeAnnotation") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isEmptyTypeAnnotation(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "EmptyTypeAnnotation") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isNullableTypeAnnotation(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "NullableTypeAnnotation") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isNumberLiteralTypeAnnotation(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "NumberLiteralTypeAnnotation") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isNumberTypeAnnotation(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "NumberTypeAnnotation") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isObjectTypeAnnotation(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ObjectTypeAnnotation") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isObjectTypeInternalSlot(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ObjectTypeInternalSlot") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isObjectTypeCallProperty(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ObjectTypeCallProperty") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isObjectTypeIndexer(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ObjectTypeIndexer") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isObjectTypeProperty(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ObjectTypeProperty") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isObjectTypeSpreadProperty(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ObjectTypeSpreadProperty") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isOpaqueType(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "OpaqueType") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isQualifiedTypeIdentifier(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "QualifiedTypeIdentifier") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isStringLiteralTypeAnnotation(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "StringLiteralTypeAnnotation") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isStringTypeAnnotation(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "StringTypeAnnotation") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isThisTypeAnnotation(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ThisTypeAnnotation") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTupleTypeAnnotation(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TupleTypeAnnotation") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTypeofTypeAnnotation(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TypeofTypeAnnotation") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTypeAlias(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TypeAlias") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTypeAnnotation(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TypeAnnotation") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTypeCastExpression(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TypeCastExpression") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTypeParameter(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TypeParameter") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTypeParameterDeclaration(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TypeParameterDeclaration") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTypeParameterInstantiation(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TypeParameterInstantiation") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isUnionTypeAnnotation(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "UnionTypeAnnotation") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isVariance(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "Variance") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isVoidTypeAnnotation(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "VoidTypeAnnotation") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isJSXAttribute(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "JSXAttribute") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isJSXClosingElement(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "JSXClosingElement") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isJSXElement(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "JSXElement") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isJSXEmptyExpression(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "JSXEmptyExpression") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isJSXExpressionContainer(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "JSXExpressionContainer") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isJSXSpreadChild(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "JSXSpreadChild") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isJSXIdentifier(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "JSXIdentifier") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isJSXMemberExpression(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "JSXMemberExpression") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isJSXNamespacedName(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "JSXNamespacedName") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isJSXOpeningElement(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "JSXOpeningElement") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isJSXSpreadAttribute(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "JSXSpreadAttribute") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isJSXText(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "JSXText") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isJSXFragment(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "JSXFragment") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isJSXOpeningFragment(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "JSXOpeningFragment") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isJSXClosingFragment(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "JSXClosingFragment") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isNoop(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "Noop") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isPlaceholder(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "Placeholder") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isArgumentPlaceholder(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ArgumentPlaceholder") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isAwaitExpression(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "AwaitExpression") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isBindExpression(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "BindExpression") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isClassProperty(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ClassProperty") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isOptionalMemberExpression(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "OptionalMemberExpression") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isPipelineTopicExpression(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "PipelineTopicExpression") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isPipelineBareFunction(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "PipelineBareFunction") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isPipelinePrimaryTopicReference(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "PipelinePrimaryTopicReference") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isOptionalCallExpression(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "OptionalCallExpression") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isClassPrivateProperty(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ClassPrivateProperty") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isClassPrivateMethod(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ClassPrivateMethod") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isImport(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "Import") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isDecorator(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "Decorator") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isDoExpression(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "DoExpression") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isExportDefaultSpecifier(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ExportDefaultSpecifier") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isExportNamespaceSpecifier(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ExportNamespaceSpecifier") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isPrivateName(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "PrivateName") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isBigIntLiteral(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "BigIntLiteral") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSParameterProperty(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSParameterProperty") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSDeclareFunction(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSDeclareFunction") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSDeclareMethod(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSDeclareMethod") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSQualifiedName(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSQualifiedName") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSCallSignatureDeclaration(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSCallSignatureDeclaration") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSConstructSignatureDeclaration(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSConstructSignatureDeclaration") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSPropertySignature(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSPropertySignature") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSMethodSignature(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSMethodSignature") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSIndexSignature(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSIndexSignature") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSAnyKeyword(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSAnyKeyword") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSUnknownKeyword(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSUnknownKeyword") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSNumberKeyword(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSNumberKeyword") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSObjectKeyword(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSObjectKeyword") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSBooleanKeyword(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSBooleanKeyword") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSStringKeyword(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSStringKeyword") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSSymbolKeyword(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSSymbolKeyword") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSVoidKeyword(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSVoidKeyword") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSUndefinedKeyword(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSUndefinedKeyword") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSNullKeyword(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSNullKeyword") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSNeverKeyword(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSNeverKeyword") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSThisType(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSThisType") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSFunctionType(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSFunctionType") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSConstructorType(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSConstructorType") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSTypeReference(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSTypeReference") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSTypePredicate(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSTypePredicate") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSTypeQuery(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSTypeQuery") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSTypeLiteral(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSTypeLiteral") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSArrayType(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSArrayType") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSTupleType(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSTupleType") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSOptionalType(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSOptionalType") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSRestType(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSRestType") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSUnionType(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSUnionType") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSIntersectionType(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSIntersectionType") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSConditionalType(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSConditionalType") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSInferType(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSInferType") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSParenthesizedType(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSParenthesizedType") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSTypeOperator(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSTypeOperator") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSIndexedAccessType(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSIndexedAccessType") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSMappedType(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSMappedType") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSLiteralType(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSLiteralType") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSExpressionWithTypeArguments(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSExpressionWithTypeArguments") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSInterfaceDeclaration(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSInterfaceDeclaration") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSInterfaceBody(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSInterfaceBody") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSTypeAliasDeclaration(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSTypeAliasDeclaration") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSAsExpression(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSAsExpression") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSTypeAssertion(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSTypeAssertion") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSEnumDeclaration(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSEnumDeclaration") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSEnumMember(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSEnumMember") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSModuleDeclaration(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSModuleDeclaration") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSModuleBlock(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSModuleBlock") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSImportType(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSImportType") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSImportEqualsDeclaration(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSImportEqualsDeclaration") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSExternalModuleReference(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSExternalModuleReference") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSNonNullExpression(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSNonNullExpression") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSExportAssignment(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSExportAssignment") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSNamespaceExportDeclaration(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSNamespaceExportDeclaration") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSTypeAnnotation(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSTypeAnnotation") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSTypeParameterInstantiation(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSTypeParameterInstantiation") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSTypeParameterDeclaration(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSTypeParameterDeclaration") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSTypeParameter(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSTypeParameter") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isExpression(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "Expression" || "ArrayExpression" === nodeType || "AssignmentExpression" === nodeType || "BinaryExpression" === nodeType || "CallExpression" === nodeType || "ConditionalExpression" === nodeType || "FunctionExpression" === nodeType || "Identifier" === nodeType || "StringLiteral" === nodeType || "NumericLiteral" === nodeType || "NullLiteral" === nodeType || "BooleanLiteral" === nodeType || "RegExpLiteral" === nodeType || "LogicalExpression" === nodeType || "MemberExpression" === nodeType || "NewExpression" === nodeType || "ObjectExpression" === nodeType || "SequenceExpression" === nodeType || "ParenthesizedExpression" === nodeType || "ThisExpression" === nodeType || "UnaryExpression" === nodeType || "UpdateExpression" === nodeType || "ArrowFunctionExpression" === nodeType || "ClassExpression" === nodeType || "MetaProperty" === nodeType || "Super" === nodeType || "TaggedTemplateExpression" === nodeType || "TemplateLiteral" === nodeType || "YieldExpression" === nodeType || "TypeCastExpression" === nodeType || "JSXElement" === nodeType || "JSXFragment" === nodeType || "AwaitExpression" === nodeType || "BindExpression" === nodeType || "OptionalMemberExpression" === nodeType || "PipelinePrimaryTopicReference" === nodeType || "OptionalCallExpression" === nodeType || "Import" === nodeType || "DoExpression" === nodeType || "BigIntLiteral" === nodeType || "TSAsExpression" === nodeType || "TSTypeAssertion" === nodeType || "TSNonNullExpression" === nodeType || nodeType === "Placeholder" && ("Expression" === node.expectedNode || "Identifier" === node.expectedNode || "StringLiteral" === node.expectedNode)) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isBinary(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "Binary" || "BinaryExpression" === nodeType || "LogicalExpression" === nodeType) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isScopable(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "Scopable" || "BlockStatement" === nodeType || "CatchClause" === nodeType || "DoWhileStatement" === nodeType || "ForInStatement" === nodeType || "ForStatement" === nodeType || "FunctionDeclaration" === nodeType || "FunctionExpression" === nodeType || "Program" === nodeType || "ObjectMethod" === nodeType || "SwitchStatement" === nodeType || "WhileStatement" === nodeType || "ArrowFunctionExpression" === nodeType || "ClassDeclaration" === nodeType || "ClassExpression" === nodeType || "ForOfStatement" === nodeType || "ClassMethod" === nodeType || "ClassPrivateMethod" === nodeType || "TSModuleBlock" === nodeType || nodeType === "Placeholder" && "BlockStatement" === node.expectedNode) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isBlockParent(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "BlockParent" || "BlockStatement" === nodeType || "CatchClause" === nodeType || "DoWhileStatement" === nodeType || "ForInStatement" === nodeType || "ForStatement" === nodeType || "FunctionDeclaration" === nodeType || "FunctionExpression" === nodeType || "Program" === nodeType || "ObjectMethod" === nodeType || "SwitchStatement" === nodeType || "WhileStatement" === nodeType || "ArrowFunctionExpression" === nodeType || "ForOfStatement" === nodeType || "ClassMethod" === nodeType || "ClassPrivateMethod" === nodeType || "TSModuleBlock" === nodeType || nodeType === "Placeholder" && "BlockStatement" === node.expectedNode) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isBlock(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "Block" || "BlockStatement" === nodeType || "Program" === nodeType || "TSModuleBlock" === nodeType || nodeType === "Placeholder" && "BlockStatement" === node.expectedNode) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isStatement(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "Statement" || "BlockStatement" === nodeType || "BreakStatement" === nodeType || "ContinueStatement" === nodeType || "DebuggerStatement" === nodeType || "DoWhileStatement" === nodeType || "EmptyStatement" === nodeType || "ExpressionStatement" === nodeType || "ForInStatement" === nodeType || "ForStatement" === nodeType || "FunctionDeclaration" === nodeType || "IfStatement" === nodeType || "LabeledStatement" === nodeType || "ReturnStatement" === nodeType || "SwitchStatement" === nodeType || "ThrowStatement" === nodeType || "TryStatement" === nodeType || "VariableDeclaration" === nodeType || "WhileStatement" === nodeType || "WithStatement" === nodeType || "ClassDeclaration" === nodeType || "ExportAllDeclaration" === nodeType || "ExportDefaultDeclaration" === nodeType || "ExportNamedDeclaration" === nodeType || "ForOfStatement" === nodeType || "ImportDeclaration" === nodeType || "DeclareClass" === nodeType || "DeclareFunction" === nodeType || "DeclareInterface" === nodeType || "DeclareModule" === nodeType || "DeclareModuleExports" === nodeType || "DeclareTypeAlias" === nodeType || "DeclareOpaqueType" === nodeType || "DeclareVariable" === nodeType || "DeclareExportDeclaration" === nodeType || "DeclareExportAllDeclaration" === nodeType || "InterfaceDeclaration" === nodeType || "OpaqueType" === nodeType || "TypeAlias" === nodeType || "TSDeclareFunction" === nodeType || "TSInterfaceDeclaration" === nodeType || "TSTypeAliasDeclaration" === nodeType || "TSEnumDeclaration" === nodeType || "TSModuleDeclaration" === nodeType || "TSImportEqualsDeclaration" === nodeType || "TSExportAssignment" === nodeType || "TSNamespaceExportDeclaration" === nodeType || nodeType === "Placeholder" && ("Statement" === node.expectedNode || "Declaration" === node.expectedNode || "BlockStatement" === node.expectedNode)) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTerminatorless(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "Terminatorless" || "BreakStatement" === nodeType || "ContinueStatement" === nodeType || "ReturnStatement" === nodeType || "ThrowStatement" === nodeType || "YieldExpression" === nodeType || "AwaitExpression" === nodeType) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isCompletionStatement(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "CompletionStatement" || "BreakStatement" === nodeType || "ContinueStatement" === nodeType || "ReturnStatement" === nodeType || "ThrowStatement" === nodeType) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isConditional(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "Conditional" || "ConditionalExpression" === nodeType || "IfStatement" === nodeType) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isLoop(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "Loop" || "DoWhileStatement" === nodeType || "ForInStatement" === nodeType || "ForStatement" === nodeType || "WhileStatement" === nodeType || "ForOfStatement" === nodeType) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isWhile(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "While" || "DoWhileStatement" === nodeType || "WhileStatement" === nodeType) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isExpressionWrapper(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ExpressionWrapper" || "ExpressionStatement" === nodeType || "ParenthesizedExpression" === nodeType || "TypeCastExpression" === nodeType) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isFor(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "For" || "ForInStatement" === nodeType || "ForStatement" === nodeType || "ForOfStatement" === nodeType) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isForXStatement(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ForXStatement" || "ForInStatement" === nodeType || "ForOfStatement" === nodeType) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isFunction(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "Function" || "FunctionDeclaration" === nodeType || "FunctionExpression" === nodeType || "ObjectMethod" === nodeType || "ArrowFunctionExpression" === nodeType || "ClassMethod" === nodeType || "ClassPrivateMethod" === nodeType) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isFunctionParent(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "FunctionParent" || "FunctionDeclaration" === nodeType || "FunctionExpression" === nodeType || "ObjectMethod" === nodeType || "ArrowFunctionExpression" === nodeType || "ClassMethod" === nodeType || "ClassPrivateMethod" === nodeType) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isPureish(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "Pureish" || "FunctionDeclaration" === nodeType || "FunctionExpression" === nodeType || "StringLiteral" === nodeType || "NumericLiteral" === nodeType || "NullLiteral" === nodeType || "BooleanLiteral" === nodeType || "ArrowFunctionExpression" === nodeType || "ClassDeclaration" === nodeType || "ClassExpression" === nodeType || "BigIntLiteral" === nodeType || nodeType === "Placeholder" && "StringLiteral" === node.expectedNode) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isDeclaration(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "Declaration" || "FunctionDeclaration" === nodeType || "VariableDeclaration" === nodeType || "ClassDeclaration" === nodeType || "ExportAllDeclaration" === nodeType || "ExportDefaultDeclaration" === nodeType || "ExportNamedDeclaration" === nodeType || "ImportDeclaration" === nodeType || "DeclareClass" === nodeType || "DeclareFunction" === nodeType || "DeclareInterface" === nodeType || "DeclareModule" === nodeType || "DeclareModuleExports" === nodeType || "DeclareTypeAlias" === nodeType || "DeclareOpaqueType" === nodeType || "DeclareVariable" === nodeType || "DeclareExportDeclaration" === nodeType || "DeclareExportAllDeclaration" === nodeType || "InterfaceDeclaration" === nodeType || "OpaqueType" === nodeType || "TypeAlias" === nodeType || "TSDeclareFunction" === nodeType || "TSInterfaceDeclaration" === nodeType || "TSTypeAliasDeclaration" === nodeType || "TSEnumDeclaration" === nodeType || "TSModuleDeclaration" === nodeType || nodeType === "Placeholder" && "Declaration" === node.expectedNode) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isPatternLike(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "PatternLike" || "Identifier" === nodeType || "RestElement" === nodeType || "AssignmentPattern" === nodeType || "ArrayPattern" === nodeType || "ObjectPattern" === nodeType || nodeType === "Placeholder" && ("Pattern" === node.expectedNode || "Identifier" === node.expectedNode)) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isLVal(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "LVal" || "Identifier" === nodeType || "MemberExpression" === nodeType || "RestElement" === nodeType || "AssignmentPattern" === nodeType || "ArrayPattern" === nodeType || "ObjectPattern" === nodeType || "TSParameterProperty" === nodeType || nodeType === "Placeholder" && ("Pattern" === node.expectedNode || "Identifier" === node.expectedNode)) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSEntityName(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSEntityName" || "Identifier" === nodeType || "TSQualifiedName" === nodeType || nodeType === "Placeholder" && "Identifier" === node.expectedNode) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isLiteral(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "Literal" || "StringLiteral" === nodeType || "NumericLiteral" === nodeType || "NullLiteral" === nodeType || "BooleanLiteral" === nodeType || "RegExpLiteral" === nodeType || "TemplateLiteral" === nodeType || "BigIntLiteral" === nodeType || nodeType === "Placeholder" && "StringLiteral" === node.expectedNode) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isImmutable(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "Immutable" || "StringLiteral" === nodeType || "NumericLiteral" === nodeType || "NullLiteral" === nodeType || "BooleanLiteral" === nodeType || "JSXAttribute" === nodeType || "JSXClosingElement" === nodeType || "JSXElement" === nodeType || "JSXExpressionContainer" === nodeType || "JSXSpreadChild" === nodeType || "JSXOpeningElement" === nodeType || "JSXText" === nodeType || "JSXFragment" === nodeType || "JSXOpeningFragment" === nodeType || "JSXClosingFragment" === nodeType || "BigIntLiteral" === nodeType || nodeType === "Placeholder" && "StringLiteral" === node.expectedNode) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isUserWhitespacable(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "UserWhitespacable" || "ObjectMethod" === nodeType || "ObjectProperty" === nodeType || "ObjectTypeInternalSlot" === nodeType || "ObjectTypeCallProperty" === nodeType || "ObjectTypeIndexer" === nodeType || "ObjectTypeProperty" === nodeType || "ObjectTypeSpreadProperty" === nodeType) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isMethod(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "Method" || "ObjectMethod" === nodeType || "ClassMethod" === nodeType || "ClassPrivateMethod" === nodeType) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isObjectMember(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ObjectMember" || "ObjectMethod" === nodeType || "ObjectProperty" === nodeType) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isProperty(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "Property" || "ObjectProperty" === nodeType || "ClassProperty" === nodeType || "ClassPrivateProperty" === nodeType) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isUnaryLike(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "UnaryLike" || "UnaryExpression" === nodeType || "SpreadElement" === nodeType) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isPattern(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "Pattern" || "AssignmentPattern" === nodeType || "ArrayPattern" === nodeType || "ObjectPattern" === nodeType || nodeType === "Placeholder" && "Pattern" === node.expectedNode) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isClass(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "Class" || "ClassDeclaration" === nodeType || "ClassExpression" === nodeType) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isModuleDeclaration(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ModuleDeclaration" || "ExportAllDeclaration" === nodeType || "ExportDefaultDeclaration" === nodeType || "ExportNamedDeclaration" === nodeType || "ImportDeclaration" === nodeType) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isExportDeclaration(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ExportDeclaration" || "ExportAllDeclaration" === nodeType || "ExportDefaultDeclaration" === nodeType || "ExportNamedDeclaration" === nodeType) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isModuleSpecifier(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "ModuleSpecifier" || "ExportSpecifier" === nodeType || "ImportDefaultSpecifier" === nodeType || "ImportNamespaceSpecifier" === nodeType || "ImportSpecifier" === nodeType || "ExportDefaultSpecifier" === nodeType || "ExportNamespaceSpecifier" === nodeType) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isFlow(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "Flow" || "AnyTypeAnnotation" === nodeType || "ArrayTypeAnnotation" === nodeType || "BooleanTypeAnnotation" === nodeType || "BooleanLiteralTypeAnnotation" === nodeType || "NullLiteralTypeAnnotation" === nodeType || "ClassImplements" === nodeType || "DeclareClass" === nodeType || "DeclareFunction" === nodeType || "DeclareInterface" === nodeType || "DeclareModule" === nodeType || "DeclareModuleExports" === nodeType || "DeclareTypeAlias" === nodeType || "DeclareOpaqueType" === nodeType || "DeclareVariable" === nodeType || "DeclareExportDeclaration" === nodeType || "DeclareExportAllDeclaration" === nodeType || "DeclaredPredicate" === nodeType || "ExistsTypeAnnotation" === nodeType || "FunctionTypeAnnotation" === nodeType || "FunctionTypeParam" === nodeType || "GenericTypeAnnotation" === nodeType || "InferredPredicate" === nodeType || "InterfaceExtends" === nodeType || "InterfaceDeclaration" === nodeType || "InterfaceTypeAnnotation" === nodeType || "IntersectionTypeAnnotation" === nodeType || "MixedTypeAnnotation" === nodeType || "EmptyTypeAnnotation" === nodeType || "NullableTypeAnnotation" === nodeType || "NumberLiteralTypeAnnotation" === nodeType || "NumberTypeAnnotation" === nodeType || "ObjectTypeAnnotation" === nodeType || "ObjectTypeInternalSlot" === nodeType || "ObjectTypeCallProperty" === nodeType || "ObjectTypeIndexer" === nodeType || "ObjectTypeProperty" === nodeType || "ObjectTypeSpreadProperty" === nodeType || "OpaqueType" === nodeType || "QualifiedTypeIdentifier" === nodeType || "StringLiteralTypeAnnotation" === nodeType || "StringTypeAnnotation" === nodeType || "ThisTypeAnnotation" === nodeType || "TupleTypeAnnotation" === nodeType || "TypeofTypeAnnotation" === nodeType || "TypeAlias" === nodeType || "TypeAnnotation" === nodeType || "TypeCastExpression" === nodeType || "TypeParameter" === nodeType || "TypeParameterDeclaration" === nodeType || "TypeParameterInstantiation" === nodeType || "UnionTypeAnnotation" === nodeType || "Variance" === nodeType || "VoidTypeAnnotation" === nodeType) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isFlowType(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "FlowType" || "AnyTypeAnnotation" === nodeType || "ArrayTypeAnnotation" === nodeType || "BooleanTypeAnnotation" === nodeType || "BooleanLiteralTypeAnnotation" === nodeType || "NullLiteralTypeAnnotation" === nodeType || "ExistsTypeAnnotation" === nodeType || "FunctionTypeAnnotation" === nodeType || "GenericTypeAnnotation" === nodeType || "InterfaceTypeAnnotation" === nodeType || "IntersectionTypeAnnotation" === nodeType || "MixedTypeAnnotation" === nodeType || "EmptyTypeAnnotation" === nodeType || "NullableTypeAnnotation" === nodeType || "NumberLiteralTypeAnnotation" === nodeType || "NumberTypeAnnotation" === nodeType || "ObjectTypeAnnotation" === nodeType || "StringLiteralTypeAnnotation" === nodeType || "StringTypeAnnotation" === nodeType || "ThisTypeAnnotation" === nodeType || "TupleTypeAnnotation" === nodeType || "TypeofTypeAnnotation" === nodeType || "UnionTypeAnnotation" === nodeType || "VoidTypeAnnotation" === nodeType) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isFlowBaseAnnotation(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "FlowBaseAnnotation" || "AnyTypeAnnotation" === nodeType || "BooleanTypeAnnotation" === nodeType || "NullLiteralTypeAnnotation" === nodeType || "MixedTypeAnnotation" === nodeType || "EmptyTypeAnnotation" === nodeType || "NumberTypeAnnotation" === nodeType || "StringTypeAnnotation" === nodeType || "ThisTypeAnnotation" === nodeType || "VoidTypeAnnotation" === nodeType) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isFlowDeclaration(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "FlowDeclaration" || "DeclareClass" === nodeType || "DeclareFunction" === nodeType || "DeclareInterface" === nodeType || "DeclareModule" === nodeType || "DeclareModuleExports" === nodeType || "DeclareTypeAlias" === nodeType || "DeclareOpaqueType" === nodeType || "DeclareVariable" === nodeType || "DeclareExportDeclaration" === nodeType || "DeclareExportAllDeclaration" === nodeType || "InterfaceDeclaration" === nodeType || "OpaqueType" === nodeType || "TypeAlias" === nodeType) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isFlowPredicate(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "FlowPredicate" || "DeclaredPredicate" === nodeType || "InferredPredicate" === nodeType) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isJSX(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "JSX" || "JSXAttribute" === nodeType || "JSXClosingElement" === nodeType || "JSXElement" === nodeType || "JSXEmptyExpression" === nodeType || "JSXExpressionContainer" === nodeType || "JSXSpreadChild" === nodeType || "JSXIdentifier" === nodeType || "JSXMemberExpression" === nodeType || "JSXNamespacedName" === nodeType || "JSXOpeningElement" === nodeType || "JSXSpreadAttribute" === nodeType || "JSXText" === nodeType || "JSXFragment" === nodeType || "JSXOpeningFragment" === nodeType || "JSXClosingFragment" === nodeType) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isPrivate(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "Private" || "ClassPrivateProperty" === nodeType || "ClassPrivateMethod" === nodeType || "PrivateName" === nodeType) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSTypeElement(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSTypeElement" || "TSCallSignatureDeclaration" === nodeType || "TSConstructSignatureDeclaration" === nodeType || "TSPropertySignature" === nodeType || "TSMethodSignature" === nodeType || "TSIndexSignature" === nodeType) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isTSType(node, opts) {
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "TSType" || "TSAnyKeyword" === nodeType || "TSUnknownKeyword" === nodeType || "TSNumberKeyword" === nodeType || "TSObjectKeyword" === nodeType || "TSBooleanKeyword" === nodeType || "TSStringKeyword" === nodeType || "TSSymbolKeyword" === nodeType || "TSVoidKeyword" === nodeType || "TSUndefinedKeyword" === nodeType || "TSNullKeyword" === nodeType || "TSNeverKeyword" === nodeType || "TSThisType" === nodeType || "TSFunctionType" === nodeType || "TSConstructorType" === nodeType || "TSTypeReference" === nodeType || "TSTypePredicate" === nodeType || "TSTypeQuery" === nodeType || "TSTypeLiteral" === nodeType || "TSArrayType" === nodeType || "TSTupleType" === nodeType || "TSOptionalType" === nodeType || "TSRestType" === nodeType || "TSUnionType" === nodeType || "TSIntersectionType" === nodeType || "TSConditionalType" === nodeType || "TSInferType" === nodeType || "TSParenthesizedType" === nodeType || "TSTypeOperator" === nodeType || "TSIndexedAccessType" === nodeType || "TSMappedType" === nodeType || "TSLiteralType" === nodeType || "TSExpressionWithTypeArguments" === nodeType || "TSImportType" === nodeType) {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isNumberLiteral(node, opts) {
|
||
console.trace("The node type NumberLiteral has been renamed to NumericLiteral");
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "NumberLiteral") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isRegexLiteral(node, opts) {
|
||
console.trace("The node type RegexLiteral has been renamed to RegExpLiteral");
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "RegexLiteral") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isRestProperty(node, opts) {
|
||
console.trace("The node type RestProperty has been renamed to RestElement");
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "RestProperty") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isSpreadProperty(node, opts) {
|
||
console.trace("The node type SpreadProperty has been renamed to SpreadElement");
|
||
if (!node) return false;
|
||
const nodeType = node.type;
|
||
|
||
if (nodeType === "SpreadProperty") {
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 6 */,
|
||
/* 7 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||
const networkRequest = __webpack_require__(13);
|
||
|
||
const workerUtils = __webpack_require__(14);
|
||
|
||
module.exports = {
|
||
networkRequest,
|
||
workerUtils
|
||
};
|
||
|
||
/***/ }),
|
||
/* 8 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var freeGlobal = __webpack_require__(43);
|
||
|
||
/** Detect free variable `self`. */
|
||
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
||
|
||
/** Used as a reference to the global object. */
|
||
var root = freeGlobal || freeSelf || Function('return this')();
|
||
|
||
module.exports = root;
|
||
|
||
|
||
/***/ }),
|
||
/* 9 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* Checks if `value` is classified as an `Array` object.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 0.1.0
|
||
* @category Lang
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
|
||
* @example
|
||
*
|
||
* _.isArray([1, 2, 3]);
|
||
* // => true
|
||
*
|
||
* _.isArray(document.body.children);
|
||
* // => false
|
||
*
|
||
* _.isArray('abc');
|
||
* // => false
|
||
*
|
||
* _.isArray(_.noop);
|
||
* // => false
|
||
*/
|
||
var isArray = Array.isArray;
|
||
|
||
module.exports = isArray;
|
||
|
||
|
||
/***/ }),
|
||
/* 10 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.arrayExpression = exports.ArrayExpression = ArrayExpression;
|
||
exports.assignmentExpression = exports.AssignmentExpression = AssignmentExpression;
|
||
exports.binaryExpression = exports.BinaryExpression = BinaryExpression;
|
||
exports.interpreterDirective = exports.InterpreterDirective = InterpreterDirective;
|
||
exports.directive = exports.Directive = Directive;
|
||
exports.directiveLiteral = exports.DirectiveLiteral = DirectiveLiteral;
|
||
exports.blockStatement = exports.BlockStatement = BlockStatement;
|
||
exports.breakStatement = exports.BreakStatement = BreakStatement;
|
||
exports.callExpression = exports.CallExpression = CallExpression;
|
||
exports.catchClause = exports.CatchClause = CatchClause;
|
||
exports.conditionalExpression = exports.ConditionalExpression = ConditionalExpression;
|
||
exports.continueStatement = exports.ContinueStatement = ContinueStatement;
|
||
exports.debuggerStatement = exports.DebuggerStatement = DebuggerStatement;
|
||
exports.doWhileStatement = exports.DoWhileStatement = DoWhileStatement;
|
||
exports.emptyStatement = exports.EmptyStatement = EmptyStatement;
|
||
exports.expressionStatement = exports.ExpressionStatement = ExpressionStatement;
|
||
exports.file = exports.File = File;
|
||
exports.forInStatement = exports.ForInStatement = ForInStatement;
|
||
exports.forStatement = exports.ForStatement = ForStatement;
|
||
exports.functionDeclaration = exports.FunctionDeclaration = FunctionDeclaration;
|
||
exports.functionExpression = exports.FunctionExpression = FunctionExpression;
|
||
exports.identifier = exports.Identifier = Identifier;
|
||
exports.ifStatement = exports.IfStatement = IfStatement;
|
||
exports.labeledStatement = exports.LabeledStatement = LabeledStatement;
|
||
exports.stringLiteral = exports.StringLiteral = StringLiteral;
|
||
exports.numericLiteral = exports.NumericLiteral = NumericLiteral;
|
||
exports.nullLiteral = exports.NullLiteral = NullLiteral;
|
||
exports.booleanLiteral = exports.BooleanLiteral = BooleanLiteral;
|
||
exports.regExpLiteral = exports.RegExpLiteral = RegExpLiteral;
|
||
exports.logicalExpression = exports.LogicalExpression = LogicalExpression;
|
||
exports.memberExpression = exports.MemberExpression = MemberExpression;
|
||
exports.newExpression = exports.NewExpression = NewExpression;
|
||
exports.program = exports.Program = Program;
|
||
exports.objectExpression = exports.ObjectExpression = ObjectExpression;
|
||
exports.objectMethod = exports.ObjectMethod = ObjectMethod;
|
||
exports.objectProperty = exports.ObjectProperty = ObjectProperty;
|
||
exports.restElement = exports.RestElement = RestElement;
|
||
exports.returnStatement = exports.ReturnStatement = ReturnStatement;
|
||
exports.sequenceExpression = exports.SequenceExpression = SequenceExpression;
|
||
exports.parenthesizedExpression = exports.ParenthesizedExpression = ParenthesizedExpression;
|
||
exports.switchCase = exports.SwitchCase = SwitchCase;
|
||
exports.switchStatement = exports.SwitchStatement = SwitchStatement;
|
||
exports.thisExpression = exports.ThisExpression = ThisExpression;
|
||
exports.throwStatement = exports.ThrowStatement = ThrowStatement;
|
||
exports.tryStatement = exports.TryStatement = TryStatement;
|
||
exports.unaryExpression = exports.UnaryExpression = UnaryExpression;
|
||
exports.updateExpression = exports.UpdateExpression = UpdateExpression;
|
||
exports.variableDeclaration = exports.VariableDeclaration = VariableDeclaration;
|
||
exports.variableDeclarator = exports.VariableDeclarator = VariableDeclarator;
|
||
exports.whileStatement = exports.WhileStatement = WhileStatement;
|
||
exports.withStatement = exports.WithStatement = WithStatement;
|
||
exports.assignmentPattern = exports.AssignmentPattern = AssignmentPattern;
|
||
exports.arrayPattern = exports.ArrayPattern = ArrayPattern;
|
||
exports.arrowFunctionExpression = exports.ArrowFunctionExpression = ArrowFunctionExpression;
|
||
exports.classBody = exports.ClassBody = ClassBody;
|
||
exports.classDeclaration = exports.ClassDeclaration = ClassDeclaration;
|
||
exports.classExpression = exports.ClassExpression = ClassExpression;
|
||
exports.exportAllDeclaration = exports.ExportAllDeclaration = ExportAllDeclaration;
|
||
exports.exportDefaultDeclaration = exports.ExportDefaultDeclaration = ExportDefaultDeclaration;
|
||
exports.exportNamedDeclaration = exports.ExportNamedDeclaration = ExportNamedDeclaration;
|
||
exports.exportSpecifier = exports.ExportSpecifier = ExportSpecifier;
|
||
exports.forOfStatement = exports.ForOfStatement = ForOfStatement;
|
||
exports.importDeclaration = exports.ImportDeclaration = ImportDeclaration;
|
||
exports.importDefaultSpecifier = exports.ImportDefaultSpecifier = ImportDefaultSpecifier;
|
||
exports.importNamespaceSpecifier = exports.ImportNamespaceSpecifier = ImportNamespaceSpecifier;
|
||
exports.importSpecifier = exports.ImportSpecifier = ImportSpecifier;
|
||
exports.metaProperty = exports.MetaProperty = MetaProperty;
|
||
exports.classMethod = exports.ClassMethod = ClassMethod;
|
||
exports.objectPattern = exports.ObjectPattern = ObjectPattern;
|
||
exports.spreadElement = exports.SpreadElement = SpreadElement;
|
||
exports.super = exports.Super = Super;
|
||
exports.taggedTemplateExpression = exports.TaggedTemplateExpression = TaggedTemplateExpression;
|
||
exports.templateElement = exports.TemplateElement = TemplateElement;
|
||
exports.templateLiteral = exports.TemplateLiteral = TemplateLiteral;
|
||
exports.yieldExpression = exports.YieldExpression = YieldExpression;
|
||
exports.anyTypeAnnotation = exports.AnyTypeAnnotation = AnyTypeAnnotation;
|
||
exports.arrayTypeAnnotation = exports.ArrayTypeAnnotation = ArrayTypeAnnotation;
|
||
exports.booleanTypeAnnotation = exports.BooleanTypeAnnotation = BooleanTypeAnnotation;
|
||
exports.booleanLiteralTypeAnnotation = exports.BooleanLiteralTypeAnnotation = BooleanLiteralTypeAnnotation;
|
||
exports.nullLiteralTypeAnnotation = exports.NullLiteralTypeAnnotation = NullLiteralTypeAnnotation;
|
||
exports.classImplements = exports.ClassImplements = ClassImplements;
|
||
exports.declareClass = exports.DeclareClass = DeclareClass;
|
||
exports.declareFunction = exports.DeclareFunction = DeclareFunction;
|
||
exports.declareInterface = exports.DeclareInterface = DeclareInterface;
|
||
exports.declareModule = exports.DeclareModule = DeclareModule;
|
||
exports.declareModuleExports = exports.DeclareModuleExports = DeclareModuleExports;
|
||
exports.declareTypeAlias = exports.DeclareTypeAlias = DeclareTypeAlias;
|
||
exports.declareOpaqueType = exports.DeclareOpaqueType = DeclareOpaqueType;
|
||
exports.declareVariable = exports.DeclareVariable = DeclareVariable;
|
||
exports.declareExportDeclaration = exports.DeclareExportDeclaration = DeclareExportDeclaration;
|
||
exports.declareExportAllDeclaration = exports.DeclareExportAllDeclaration = DeclareExportAllDeclaration;
|
||
exports.declaredPredicate = exports.DeclaredPredicate = DeclaredPredicate;
|
||
exports.existsTypeAnnotation = exports.ExistsTypeAnnotation = ExistsTypeAnnotation;
|
||
exports.functionTypeAnnotation = exports.FunctionTypeAnnotation = FunctionTypeAnnotation;
|
||
exports.functionTypeParam = exports.FunctionTypeParam = FunctionTypeParam;
|
||
exports.genericTypeAnnotation = exports.GenericTypeAnnotation = GenericTypeAnnotation;
|
||
exports.inferredPredicate = exports.InferredPredicate = InferredPredicate;
|
||
exports.interfaceExtends = exports.InterfaceExtends = InterfaceExtends;
|
||
exports.interfaceDeclaration = exports.InterfaceDeclaration = InterfaceDeclaration;
|
||
exports.interfaceTypeAnnotation = exports.InterfaceTypeAnnotation = InterfaceTypeAnnotation;
|
||
exports.intersectionTypeAnnotation = exports.IntersectionTypeAnnotation = IntersectionTypeAnnotation;
|
||
exports.mixedTypeAnnotation = exports.MixedTypeAnnotation = MixedTypeAnnotation;
|
||
exports.emptyTypeAnnotation = exports.EmptyTypeAnnotation = EmptyTypeAnnotation;
|
||
exports.nullableTypeAnnotation = exports.NullableTypeAnnotation = NullableTypeAnnotation;
|
||
exports.numberLiteralTypeAnnotation = exports.NumberLiteralTypeAnnotation = NumberLiteralTypeAnnotation;
|
||
exports.numberTypeAnnotation = exports.NumberTypeAnnotation = NumberTypeAnnotation;
|
||
exports.objectTypeAnnotation = exports.ObjectTypeAnnotation = ObjectTypeAnnotation;
|
||
exports.objectTypeInternalSlot = exports.ObjectTypeInternalSlot = ObjectTypeInternalSlot;
|
||
exports.objectTypeCallProperty = exports.ObjectTypeCallProperty = ObjectTypeCallProperty;
|
||
exports.objectTypeIndexer = exports.ObjectTypeIndexer = ObjectTypeIndexer;
|
||
exports.objectTypeProperty = exports.ObjectTypeProperty = ObjectTypeProperty;
|
||
exports.objectTypeSpreadProperty = exports.ObjectTypeSpreadProperty = ObjectTypeSpreadProperty;
|
||
exports.opaqueType = exports.OpaqueType = OpaqueType;
|
||
exports.qualifiedTypeIdentifier = exports.QualifiedTypeIdentifier = QualifiedTypeIdentifier;
|
||
exports.stringLiteralTypeAnnotation = exports.StringLiteralTypeAnnotation = StringLiteralTypeAnnotation;
|
||
exports.stringTypeAnnotation = exports.StringTypeAnnotation = StringTypeAnnotation;
|
||
exports.thisTypeAnnotation = exports.ThisTypeAnnotation = ThisTypeAnnotation;
|
||
exports.tupleTypeAnnotation = exports.TupleTypeAnnotation = TupleTypeAnnotation;
|
||
exports.typeofTypeAnnotation = exports.TypeofTypeAnnotation = TypeofTypeAnnotation;
|
||
exports.typeAlias = exports.TypeAlias = TypeAlias;
|
||
exports.typeAnnotation = exports.TypeAnnotation = TypeAnnotation;
|
||
exports.typeCastExpression = exports.TypeCastExpression = TypeCastExpression;
|
||
exports.typeParameter = exports.TypeParameter = TypeParameter;
|
||
exports.typeParameterDeclaration = exports.TypeParameterDeclaration = TypeParameterDeclaration;
|
||
exports.typeParameterInstantiation = exports.TypeParameterInstantiation = TypeParameterInstantiation;
|
||
exports.unionTypeAnnotation = exports.UnionTypeAnnotation = UnionTypeAnnotation;
|
||
exports.variance = exports.Variance = Variance;
|
||
exports.voidTypeAnnotation = exports.VoidTypeAnnotation = VoidTypeAnnotation;
|
||
exports.jSXAttribute = exports.jsxAttribute = exports.JSXAttribute = JSXAttribute;
|
||
exports.jSXClosingElement = exports.jsxClosingElement = exports.JSXClosingElement = JSXClosingElement;
|
||
exports.jSXElement = exports.jsxElement = exports.JSXElement = JSXElement;
|
||
exports.jSXEmptyExpression = exports.jsxEmptyExpression = exports.JSXEmptyExpression = JSXEmptyExpression;
|
||
exports.jSXExpressionContainer = exports.jsxExpressionContainer = exports.JSXExpressionContainer = JSXExpressionContainer;
|
||
exports.jSXSpreadChild = exports.jsxSpreadChild = exports.JSXSpreadChild = JSXSpreadChild;
|
||
exports.jSXIdentifier = exports.jsxIdentifier = exports.JSXIdentifier = JSXIdentifier;
|
||
exports.jSXMemberExpression = exports.jsxMemberExpression = exports.JSXMemberExpression = JSXMemberExpression;
|
||
exports.jSXNamespacedName = exports.jsxNamespacedName = exports.JSXNamespacedName = JSXNamespacedName;
|
||
exports.jSXOpeningElement = exports.jsxOpeningElement = exports.JSXOpeningElement = JSXOpeningElement;
|
||
exports.jSXSpreadAttribute = exports.jsxSpreadAttribute = exports.JSXSpreadAttribute = JSXSpreadAttribute;
|
||
exports.jSXText = exports.jsxText = exports.JSXText = JSXText;
|
||
exports.jSXFragment = exports.jsxFragment = exports.JSXFragment = JSXFragment;
|
||
exports.jSXOpeningFragment = exports.jsxOpeningFragment = exports.JSXOpeningFragment = JSXOpeningFragment;
|
||
exports.jSXClosingFragment = exports.jsxClosingFragment = exports.JSXClosingFragment = JSXClosingFragment;
|
||
exports.noop = exports.Noop = Noop;
|
||
exports.placeholder = exports.Placeholder = Placeholder;
|
||
exports.argumentPlaceholder = exports.ArgumentPlaceholder = ArgumentPlaceholder;
|
||
exports.awaitExpression = exports.AwaitExpression = AwaitExpression;
|
||
exports.bindExpression = exports.BindExpression = BindExpression;
|
||
exports.classProperty = exports.ClassProperty = ClassProperty;
|
||
exports.optionalMemberExpression = exports.OptionalMemberExpression = OptionalMemberExpression;
|
||
exports.pipelineTopicExpression = exports.PipelineTopicExpression = PipelineTopicExpression;
|
||
exports.pipelineBareFunction = exports.PipelineBareFunction = PipelineBareFunction;
|
||
exports.pipelinePrimaryTopicReference = exports.PipelinePrimaryTopicReference = PipelinePrimaryTopicReference;
|
||
exports.optionalCallExpression = exports.OptionalCallExpression = OptionalCallExpression;
|
||
exports.classPrivateProperty = exports.ClassPrivateProperty = ClassPrivateProperty;
|
||
exports.classPrivateMethod = exports.ClassPrivateMethod = ClassPrivateMethod;
|
||
exports.import = exports.Import = Import;
|
||
exports.decorator = exports.Decorator = Decorator;
|
||
exports.doExpression = exports.DoExpression = DoExpression;
|
||
exports.exportDefaultSpecifier = exports.ExportDefaultSpecifier = ExportDefaultSpecifier;
|
||
exports.exportNamespaceSpecifier = exports.ExportNamespaceSpecifier = ExportNamespaceSpecifier;
|
||
exports.privateName = exports.PrivateName = PrivateName;
|
||
exports.bigIntLiteral = exports.BigIntLiteral = BigIntLiteral;
|
||
exports.tSParameterProperty = exports.tsParameterProperty = exports.TSParameterProperty = TSParameterProperty;
|
||
exports.tSDeclareFunction = exports.tsDeclareFunction = exports.TSDeclareFunction = TSDeclareFunction;
|
||
exports.tSDeclareMethod = exports.tsDeclareMethod = exports.TSDeclareMethod = TSDeclareMethod;
|
||
exports.tSQualifiedName = exports.tsQualifiedName = exports.TSQualifiedName = TSQualifiedName;
|
||
exports.tSCallSignatureDeclaration = exports.tsCallSignatureDeclaration = exports.TSCallSignatureDeclaration = TSCallSignatureDeclaration;
|
||
exports.tSConstructSignatureDeclaration = exports.tsConstructSignatureDeclaration = exports.TSConstructSignatureDeclaration = TSConstructSignatureDeclaration;
|
||
exports.tSPropertySignature = exports.tsPropertySignature = exports.TSPropertySignature = TSPropertySignature;
|
||
exports.tSMethodSignature = exports.tsMethodSignature = exports.TSMethodSignature = TSMethodSignature;
|
||
exports.tSIndexSignature = exports.tsIndexSignature = exports.TSIndexSignature = TSIndexSignature;
|
||
exports.tSAnyKeyword = exports.tsAnyKeyword = exports.TSAnyKeyword = TSAnyKeyword;
|
||
exports.tSUnknownKeyword = exports.tsUnknownKeyword = exports.TSUnknownKeyword = TSUnknownKeyword;
|
||
exports.tSNumberKeyword = exports.tsNumberKeyword = exports.TSNumberKeyword = TSNumberKeyword;
|
||
exports.tSObjectKeyword = exports.tsObjectKeyword = exports.TSObjectKeyword = TSObjectKeyword;
|
||
exports.tSBooleanKeyword = exports.tsBooleanKeyword = exports.TSBooleanKeyword = TSBooleanKeyword;
|
||
exports.tSStringKeyword = exports.tsStringKeyword = exports.TSStringKeyword = TSStringKeyword;
|
||
exports.tSSymbolKeyword = exports.tsSymbolKeyword = exports.TSSymbolKeyword = TSSymbolKeyword;
|
||
exports.tSVoidKeyword = exports.tsVoidKeyword = exports.TSVoidKeyword = TSVoidKeyword;
|
||
exports.tSUndefinedKeyword = exports.tsUndefinedKeyword = exports.TSUndefinedKeyword = TSUndefinedKeyword;
|
||
exports.tSNullKeyword = exports.tsNullKeyword = exports.TSNullKeyword = TSNullKeyword;
|
||
exports.tSNeverKeyword = exports.tsNeverKeyword = exports.TSNeverKeyword = TSNeverKeyword;
|
||
exports.tSThisType = exports.tsThisType = exports.TSThisType = TSThisType;
|
||
exports.tSFunctionType = exports.tsFunctionType = exports.TSFunctionType = TSFunctionType;
|
||
exports.tSConstructorType = exports.tsConstructorType = exports.TSConstructorType = TSConstructorType;
|
||
exports.tSTypeReference = exports.tsTypeReference = exports.TSTypeReference = TSTypeReference;
|
||
exports.tSTypePredicate = exports.tsTypePredicate = exports.TSTypePredicate = TSTypePredicate;
|
||
exports.tSTypeQuery = exports.tsTypeQuery = exports.TSTypeQuery = TSTypeQuery;
|
||
exports.tSTypeLiteral = exports.tsTypeLiteral = exports.TSTypeLiteral = TSTypeLiteral;
|
||
exports.tSArrayType = exports.tsArrayType = exports.TSArrayType = TSArrayType;
|
||
exports.tSTupleType = exports.tsTupleType = exports.TSTupleType = TSTupleType;
|
||
exports.tSOptionalType = exports.tsOptionalType = exports.TSOptionalType = TSOptionalType;
|
||
exports.tSRestType = exports.tsRestType = exports.TSRestType = TSRestType;
|
||
exports.tSUnionType = exports.tsUnionType = exports.TSUnionType = TSUnionType;
|
||
exports.tSIntersectionType = exports.tsIntersectionType = exports.TSIntersectionType = TSIntersectionType;
|
||
exports.tSConditionalType = exports.tsConditionalType = exports.TSConditionalType = TSConditionalType;
|
||
exports.tSInferType = exports.tsInferType = exports.TSInferType = TSInferType;
|
||
exports.tSParenthesizedType = exports.tsParenthesizedType = exports.TSParenthesizedType = TSParenthesizedType;
|
||
exports.tSTypeOperator = exports.tsTypeOperator = exports.TSTypeOperator = TSTypeOperator;
|
||
exports.tSIndexedAccessType = exports.tsIndexedAccessType = exports.TSIndexedAccessType = TSIndexedAccessType;
|
||
exports.tSMappedType = exports.tsMappedType = exports.TSMappedType = TSMappedType;
|
||
exports.tSLiteralType = exports.tsLiteralType = exports.TSLiteralType = TSLiteralType;
|
||
exports.tSExpressionWithTypeArguments = exports.tsExpressionWithTypeArguments = exports.TSExpressionWithTypeArguments = TSExpressionWithTypeArguments;
|
||
exports.tSInterfaceDeclaration = exports.tsInterfaceDeclaration = exports.TSInterfaceDeclaration = TSInterfaceDeclaration;
|
||
exports.tSInterfaceBody = exports.tsInterfaceBody = exports.TSInterfaceBody = TSInterfaceBody;
|
||
exports.tSTypeAliasDeclaration = exports.tsTypeAliasDeclaration = exports.TSTypeAliasDeclaration = TSTypeAliasDeclaration;
|
||
exports.tSAsExpression = exports.tsAsExpression = exports.TSAsExpression = TSAsExpression;
|
||
exports.tSTypeAssertion = exports.tsTypeAssertion = exports.TSTypeAssertion = TSTypeAssertion;
|
||
exports.tSEnumDeclaration = exports.tsEnumDeclaration = exports.TSEnumDeclaration = TSEnumDeclaration;
|
||
exports.tSEnumMember = exports.tsEnumMember = exports.TSEnumMember = TSEnumMember;
|
||
exports.tSModuleDeclaration = exports.tsModuleDeclaration = exports.TSModuleDeclaration = TSModuleDeclaration;
|
||
exports.tSModuleBlock = exports.tsModuleBlock = exports.TSModuleBlock = TSModuleBlock;
|
||
exports.tSImportType = exports.tsImportType = exports.TSImportType = TSImportType;
|
||
exports.tSImportEqualsDeclaration = exports.tsImportEqualsDeclaration = exports.TSImportEqualsDeclaration = TSImportEqualsDeclaration;
|
||
exports.tSExternalModuleReference = exports.tsExternalModuleReference = exports.TSExternalModuleReference = TSExternalModuleReference;
|
||
exports.tSNonNullExpression = exports.tsNonNullExpression = exports.TSNonNullExpression = TSNonNullExpression;
|
||
exports.tSExportAssignment = exports.tsExportAssignment = exports.TSExportAssignment = TSExportAssignment;
|
||
exports.tSNamespaceExportDeclaration = exports.tsNamespaceExportDeclaration = exports.TSNamespaceExportDeclaration = TSNamespaceExportDeclaration;
|
||
exports.tSTypeAnnotation = exports.tsTypeAnnotation = exports.TSTypeAnnotation = TSTypeAnnotation;
|
||
exports.tSTypeParameterInstantiation = exports.tsTypeParameterInstantiation = exports.TSTypeParameterInstantiation = TSTypeParameterInstantiation;
|
||
exports.tSTypeParameterDeclaration = exports.tsTypeParameterDeclaration = exports.TSTypeParameterDeclaration = TSTypeParameterDeclaration;
|
||
exports.tSTypeParameter = exports.tsTypeParameter = exports.TSTypeParameter = TSTypeParameter;
|
||
exports.numberLiteral = exports.NumberLiteral = NumberLiteral;
|
||
exports.regexLiteral = exports.RegexLiteral = RegexLiteral;
|
||
exports.restProperty = exports.RestProperty = RestProperty;
|
||
exports.spreadProperty = exports.SpreadProperty = SpreadProperty;
|
||
|
||
var _builder = _interopRequireDefault(__webpack_require__(204));
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function ArrayExpression(...args) {
|
||
return (0, _builder.default)("ArrayExpression", ...args);
|
||
}
|
||
|
||
function AssignmentExpression(...args) {
|
||
return (0, _builder.default)("AssignmentExpression", ...args);
|
||
}
|
||
|
||
function BinaryExpression(...args) {
|
||
return (0, _builder.default)("BinaryExpression", ...args);
|
||
}
|
||
|
||
function InterpreterDirective(...args) {
|
||
return (0, _builder.default)("InterpreterDirective", ...args);
|
||
}
|
||
|
||
function Directive(...args) {
|
||
return (0, _builder.default)("Directive", ...args);
|
||
}
|
||
|
||
function DirectiveLiteral(...args) {
|
||
return (0, _builder.default)("DirectiveLiteral", ...args);
|
||
}
|
||
|
||
function BlockStatement(...args) {
|
||
return (0, _builder.default)("BlockStatement", ...args);
|
||
}
|
||
|
||
function BreakStatement(...args) {
|
||
return (0, _builder.default)("BreakStatement", ...args);
|
||
}
|
||
|
||
function CallExpression(...args) {
|
||
return (0, _builder.default)("CallExpression", ...args);
|
||
}
|
||
|
||
function CatchClause(...args) {
|
||
return (0, _builder.default)("CatchClause", ...args);
|
||
}
|
||
|
||
function ConditionalExpression(...args) {
|
||
return (0, _builder.default)("ConditionalExpression", ...args);
|
||
}
|
||
|
||
function ContinueStatement(...args) {
|
||
return (0, _builder.default)("ContinueStatement", ...args);
|
||
}
|
||
|
||
function DebuggerStatement(...args) {
|
||
return (0, _builder.default)("DebuggerStatement", ...args);
|
||
}
|
||
|
||
function DoWhileStatement(...args) {
|
||
return (0, _builder.default)("DoWhileStatement", ...args);
|
||
}
|
||
|
||
function EmptyStatement(...args) {
|
||
return (0, _builder.default)("EmptyStatement", ...args);
|
||
}
|
||
|
||
function ExpressionStatement(...args) {
|
||
return (0, _builder.default)("ExpressionStatement", ...args);
|
||
}
|
||
|
||
function File(...args) {
|
||
return (0, _builder.default)("File", ...args);
|
||
}
|
||
|
||
function ForInStatement(...args) {
|
||
return (0, _builder.default)("ForInStatement", ...args);
|
||
}
|
||
|
||
function ForStatement(...args) {
|
||
return (0, _builder.default)("ForStatement", ...args);
|
||
}
|
||
|
||
function FunctionDeclaration(...args) {
|
||
return (0, _builder.default)("FunctionDeclaration", ...args);
|
||
}
|
||
|
||
function FunctionExpression(...args) {
|
||
return (0, _builder.default)("FunctionExpression", ...args);
|
||
}
|
||
|
||
function Identifier(...args) {
|
||
return (0, _builder.default)("Identifier", ...args);
|
||
}
|
||
|
||
function IfStatement(...args) {
|
||
return (0, _builder.default)("IfStatement", ...args);
|
||
}
|
||
|
||
function LabeledStatement(...args) {
|
||
return (0, _builder.default)("LabeledStatement", ...args);
|
||
}
|
||
|
||
function StringLiteral(...args) {
|
||
return (0, _builder.default)("StringLiteral", ...args);
|
||
}
|
||
|
||
function NumericLiteral(...args) {
|
||
return (0, _builder.default)("NumericLiteral", ...args);
|
||
}
|
||
|
||
function NullLiteral(...args) {
|
||
return (0, _builder.default)("NullLiteral", ...args);
|
||
}
|
||
|
||
function BooleanLiteral(...args) {
|
||
return (0, _builder.default)("BooleanLiteral", ...args);
|
||
}
|
||
|
||
function RegExpLiteral(...args) {
|
||
return (0, _builder.default)("RegExpLiteral", ...args);
|
||
}
|
||
|
||
function LogicalExpression(...args) {
|
||
return (0, _builder.default)("LogicalExpression", ...args);
|
||
}
|
||
|
||
function MemberExpression(...args) {
|
||
return (0, _builder.default)("MemberExpression", ...args);
|
||
}
|
||
|
||
function NewExpression(...args) {
|
||
return (0, _builder.default)("NewExpression", ...args);
|
||
}
|
||
|
||
function Program(...args) {
|
||
return (0, _builder.default)("Program", ...args);
|
||
}
|
||
|
||
function ObjectExpression(...args) {
|
||
return (0, _builder.default)("ObjectExpression", ...args);
|
||
}
|
||
|
||
function ObjectMethod(...args) {
|
||
return (0, _builder.default)("ObjectMethod", ...args);
|
||
}
|
||
|
||
function ObjectProperty(...args) {
|
||
return (0, _builder.default)("ObjectProperty", ...args);
|
||
}
|
||
|
||
function RestElement(...args) {
|
||
return (0, _builder.default)("RestElement", ...args);
|
||
}
|
||
|
||
function ReturnStatement(...args) {
|
||
return (0, _builder.default)("ReturnStatement", ...args);
|
||
}
|
||
|
||
function SequenceExpression(...args) {
|
||
return (0, _builder.default)("SequenceExpression", ...args);
|
||
}
|
||
|
||
function ParenthesizedExpression(...args) {
|
||
return (0, _builder.default)("ParenthesizedExpression", ...args);
|
||
}
|
||
|
||
function SwitchCase(...args) {
|
||
return (0, _builder.default)("SwitchCase", ...args);
|
||
}
|
||
|
||
function SwitchStatement(...args) {
|
||
return (0, _builder.default)("SwitchStatement", ...args);
|
||
}
|
||
|
||
function ThisExpression(...args) {
|
||
return (0, _builder.default)("ThisExpression", ...args);
|
||
}
|
||
|
||
function ThrowStatement(...args) {
|
||
return (0, _builder.default)("ThrowStatement", ...args);
|
||
}
|
||
|
||
function TryStatement(...args) {
|
||
return (0, _builder.default)("TryStatement", ...args);
|
||
}
|
||
|
||
function UnaryExpression(...args) {
|
||
return (0, _builder.default)("UnaryExpression", ...args);
|
||
}
|
||
|
||
function UpdateExpression(...args) {
|
||
return (0, _builder.default)("UpdateExpression", ...args);
|
||
}
|
||
|
||
function VariableDeclaration(...args) {
|
||
return (0, _builder.default)("VariableDeclaration", ...args);
|
||
}
|
||
|
||
function VariableDeclarator(...args) {
|
||
return (0, _builder.default)("VariableDeclarator", ...args);
|
||
}
|
||
|
||
function WhileStatement(...args) {
|
||
return (0, _builder.default)("WhileStatement", ...args);
|
||
}
|
||
|
||
function WithStatement(...args) {
|
||
return (0, _builder.default)("WithStatement", ...args);
|
||
}
|
||
|
||
function AssignmentPattern(...args) {
|
||
return (0, _builder.default)("AssignmentPattern", ...args);
|
||
}
|
||
|
||
function ArrayPattern(...args) {
|
||
return (0, _builder.default)("ArrayPattern", ...args);
|
||
}
|
||
|
||
function ArrowFunctionExpression(...args) {
|
||
return (0, _builder.default)("ArrowFunctionExpression", ...args);
|
||
}
|
||
|
||
function ClassBody(...args) {
|
||
return (0, _builder.default)("ClassBody", ...args);
|
||
}
|
||
|
||
function ClassDeclaration(...args) {
|
||
return (0, _builder.default)("ClassDeclaration", ...args);
|
||
}
|
||
|
||
function ClassExpression(...args) {
|
||
return (0, _builder.default)("ClassExpression", ...args);
|
||
}
|
||
|
||
function ExportAllDeclaration(...args) {
|
||
return (0, _builder.default)("ExportAllDeclaration", ...args);
|
||
}
|
||
|
||
function ExportDefaultDeclaration(...args) {
|
||
return (0, _builder.default)("ExportDefaultDeclaration", ...args);
|
||
}
|
||
|
||
function ExportNamedDeclaration(...args) {
|
||
return (0, _builder.default)("ExportNamedDeclaration", ...args);
|
||
}
|
||
|
||
function ExportSpecifier(...args) {
|
||
return (0, _builder.default)("ExportSpecifier", ...args);
|
||
}
|
||
|
||
function ForOfStatement(...args) {
|
||
return (0, _builder.default)("ForOfStatement", ...args);
|
||
}
|
||
|
||
function ImportDeclaration(...args) {
|
||
return (0, _builder.default)("ImportDeclaration", ...args);
|
||
}
|
||
|
||
function ImportDefaultSpecifier(...args) {
|
||
return (0, _builder.default)("ImportDefaultSpecifier", ...args);
|
||
}
|
||
|
||
function ImportNamespaceSpecifier(...args) {
|
||
return (0, _builder.default)("ImportNamespaceSpecifier", ...args);
|
||
}
|
||
|
||
function ImportSpecifier(...args) {
|
||
return (0, _builder.default)("ImportSpecifier", ...args);
|
||
}
|
||
|
||
function MetaProperty(...args) {
|
||
return (0, _builder.default)("MetaProperty", ...args);
|
||
}
|
||
|
||
function ClassMethod(...args) {
|
||
return (0, _builder.default)("ClassMethod", ...args);
|
||
}
|
||
|
||
function ObjectPattern(...args) {
|
||
return (0, _builder.default)("ObjectPattern", ...args);
|
||
}
|
||
|
||
function SpreadElement(...args) {
|
||
return (0, _builder.default)("SpreadElement", ...args);
|
||
}
|
||
|
||
function Super(...args) {
|
||
return (0, _builder.default)("Super", ...args);
|
||
}
|
||
|
||
function TaggedTemplateExpression(...args) {
|
||
return (0, _builder.default)("TaggedTemplateExpression", ...args);
|
||
}
|
||
|
||
function TemplateElement(...args) {
|
||
return (0, _builder.default)("TemplateElement", ...args);
|
||
}
|
||
|
||
function TemplateLiteral(...args) {
|
||
return (0, _builder.default)("TemplateLiteral", ...args);
|
||
}
|
||
|
||
function YieldExpression(...args) {
|
||
return (0, _builder.default)("YieldExpression", ...args);
|
||
}
|
||
|
||
function AnyTypeAnnotation(...args) {
|
||
return (0, _builder.default)("AnyTypeAnnotation", ...args);
|
||
}
|
||
|
||
function ArrayTypeAnnotation(...args) {
|
||
return (0, _builder.default)("ArrayTypeAnnotation", ...args);
|
||
}
|
||
|
||
function BooleanTypeAnnotation(...args) {
|
||
return (0, _builder.default)("BooleanTypeAnnotation", ...args);
|
||
}
|
||
|
||
function BooleanLiteralTypeAnnotation(...args) {
|
||
return (0, _builder.default)("BooleanLiteralTypeAnnotation", ...args);
|
||
}
|
||
|
||
function NullLiteralTypeAnnotation(...args) {
|
||
return (0, _builder.default)("NullLiteralTypeAnnotation", ...args);
|
||
}
|
||
|
||
function ClassImplements(...args) {
|
||
return (0, _builder.default)("ClassImplements", ...args);
|
||
}
|
||
|
||
function DeclareClass(...args) {
|
||
return (0, _builder.default)("DeclareClass", ...args);
|
||
}
|
||
|
||
function DeclareFunction(...args) {
|
||
return (0, _builder.default)("DeclareFunction", ...args);
|
||
}
|
||
|
||
function DeclareInterface(...args) {
|
||
return (0, _builder.default)("DeclareInterface", ...args);
|
||
}
|
||
|
||
function DeclareModule(...args) {
|
||
return (0, _builder.default)("DeclareModule", ...args);
|
||
}
|
||
|
||
function DeclareModuleExports(...args) {
|
||
return (0, _builder.default)("DeclareModuleExports", ...args);
|
||
}
|
||
|
||
function DeclareTypeAlias(...args) {
|
||
return (0, _builder.default)("DeclareTypeAlias", ...args);
|
||
}
|
||
|
||
function DeclareOpaqueType(...args) {
|
||
return (0, _builder.default)("DeclareOpaqueType", ...args);
|
||
}
|
||
|
||
function DeclareVariable(...args) {
|
||
return (0, _builder.default)("DeclareVariable", ...args);
|
||
}
|
||
|
||
function DeclareExportDeclaration(...args) {
|
||
return (0, _builder.default)("DeclareExportDeclaration", ...args);
|
||
}
|
||
|
||
function DeclareExportAllDeclaration(...args) {
|
||
return (0, _builder.default)("DeclareExportAllDeclaration", ...args);
|
||
}
|
||
|
||
function DeclaredPredicate(...args) {
|
||
return (0, _builder.default)("DeclaredPredicate", ...args);
|
||
}
|
||
|
||
function ExistsTypeAnnotation(...args) {
|
||
return (0, _builder.default)("ExistsTypeAnnotation", ...args);
|
||
}
|
||
|
||
function FunctionTypeAnnotation(...args) {
|
||
return (0, _builder.default)("FunctionTypeAnnotation", ...args);
|
||
}
|
||
|
||
function FunctionTypeParam(...args) {
|
||
return (0, _builder.default)("FunctionTypeParam", ...args);
|
||
}
|
||
|
||
function GenericTypeAnnotation(...args) {
|
||
return (0, _builder.default)("GenericTypeAnnotation", ...args);
|
||
}
|
||
|
||
function InferredPredicate(...args) {
|
||
return (0, _builder.default)("InferredPredicate", ...args);
|
||
}
|
||
|
||
function InterfaceExtends(...args) {
|
||
return (0, _builder.default)("InterfaceExtends", ...args);
|
||
}
|
||
|
||
function InterfaceDeclaration(...args) {
|
||
return (0, _builder.default)("InterfaceDeclaration", ...args);
|
||
}
|
||
|
||
function InterfaceTypeAnnotation(...args) {
|
||
return (0, _builder.default)("InterfaceTypeAnnotation", ...args);
|
||
}
|
||
|
||
function IntersectionTypeAnnotation(...args) {
|
||
return (0, _builder.default)("IntersectionTypeAnnotation", ...args);
|
||
}
|
||
|
||
function MixedTypeAnnotation(...args) {
|
||
return (0, _builder.default)("MixedTypeAnnotation", ...args);
|
||
}
|
||
|
||
function EmptyTypeAnnotation(...args) {
|
||
return (0, _builder.default)("EmptyTypeAnnotation", ...args);
|
||
}
|
||
|
||
function NullableTypeAnnotation(...args) {
|
||
return (0, _builder.default)("NullableTypeAnnotation", ...args);
|
||
}
|
||
|
||
function NumberLiteralTypeAnnotation(...args) {
|
||
return (0, _builder.default)("NumberLiteralTypeAnnotation", ...args);
|
||
}
|
||
|
||
function NumberTypeAnnotation(...args) {
|
||
return (0, _builder.default)("NumberTypeAnnotation", ...args);
|
||
}
|
||
|
||
function ObjectTypeAnnotation(...args) {
|
||
return (0, _builder.default)("ObjectTypeAnnotation", ...args);
|
||
}
|
||
|
||
function ObjectTypeInternalSlot(...args) {
|
||
return (0, _builder.default)("ObjectTypeInternalSlot", ...args);
|
||
}
|
||
|
||
function ObjectTypeCallProperty(...args) {
|
||
return (0, _builder.default)("ObjectTypeCallProperty", ...args);
|
||
}
|
||
|
||
function ObjectTypeIndexer(...args) {
|
||
return (0, _builder.default)("ObjectTypeIndexer", ...args);
|
||
}
|
||
|
||
function ObjectTypeProperty(...args) {
|
||
return (0, _builder.default)("ObjectTypeProperty", ...args);
|
||
}
|
||
|
||
function ObjectTypeSpreadProperty(...args) {
|
||
return (0, _builder.default)("ObjectTypeSpreadProperty", ...args);
|
||
}
|
||
|
||
function OpaqueType(...args) {
|
||
return (0, _builder.default)("OpaqueType", ...args);
|
||
}
|
||
|
||
function QualifiedTypeIdentifier(...args) {
|
||
return (0, _builder.default)("QualifiedTypeIdentifier", ...args);
|
||
}
|
||
|
||
function StringLiteralTypeAnnotation(...args) {
|
||
return (0, _builder.default)("StringLiteralTypeAnnotation", ...args);
|
||
}
|
||
|
||
function StringTypeAnnotation(...args) {
|
||
return (0, _builder.default)("StringTypeAnnotation", ...args);
|
||
}
|
||
|
||
function ThisTypeAnnotation(...args) {
|
||
return (0, _builder.default)("ThisTypeAnnotation", ...args);
|
||
}
|
||
|
||
function TupleTypeAnnotation(...args) {
|
||
return (0, _builder.default)("TupleTypeAnnotation", ...args);
|
||
}
|
||
|
||
function TypeofTypeAnnotation(...args) {
|
||
return (0, _builder.default)("TypeofTypeAnnotation", ...args);
|
||
}
|
||
|
||
function TypeAlias(...args) {
|
||
return (0, _builder.default)("TypeAlias", ...args);
|
||
}
|
||
|
||
function TypeAnnotation(...args) {
|
||
return (0, _builder.default)("TypeAnnotation", ...args);
|
||
}
|
||
|
||
function TypeCastExpression(...args) {
|
||
return (0, _builder.default)("TypeCastExpression", ...args);
|
||
}
|
||
|
||
function TypeParameter(...args) {
|
||
return (0, _builder.default)("TypeParameter", ...args);
|
||
}
|
||
|
||
function TypeParameterDeclaration(...args) {
|
||
return (0, _builder.default)("TypeParameterDeclaration", ...args);
|
||
}
|
||
|
||
function TypeParameterInstantiation(...args) {
|
||
return (0, _builder.default)("TypeParameterInstantiation", ...args);
|
||
}
|
||
|
||
function UnionTypeAnnotation(...args) {
|
||
return (0, _builder.default)("UnionTypeAnnotation", ...args);
|
||
}
|
||
|
||
function Variance(...args) {
|
||
return (0, _builder.default)("Variance", ...args);
|
||
}
|
||
|
||
function VoidTypeAnnotation(...args) {
|
||
return (0, _builder.default)("VoidTypeAnnotation", ...args);
|
||
}
|
||
|
||
function JSXAttribute(...args) {
|
||
return (0, _builder.default)("JSXAttribute", ...args);
|
||
}
|
||
|
||
function JSXClosingElement(...args) {
|
||
return (0, _builder.default)("JSXClosingElement", ...args);
|
||
}
|
||
|
||
function JSXElement(...args) {
|
||
return (0, _builder.default)("JSXElement", ...args);
|
||
}
|
||
|
||
function JSXEmptyExpression(...args) {
|
||
return (0, _builder.default)("JSXEmptyExpression", ...args);
|
||
}
|
||
|
||
function JSXExpressionContainer(...args) {
|
||
return (0, _builder.default)("JSXExpressionContainer", ...args);
|
||
}
|
||
|
||
function JSXSpreadChild(...args) {
|
||
return (0, _builder.default)("JSXSpreadChild", ...args);
|
||
}
|
||
|
||
function JSXIdentifier(...args) {
|
||
return (0, _builder.default)("JSXIdentifier", ...args);
|
||
}
|
||
|
||
function JSXMemberExpression(...args) {
|
||
return (0, _builder.default)("JSXMemberExpression", ...args);
|
||
}
|
||
|
||
function JSXNamespacedName(...args) {
|
||
return (0, _builder.default)("JSXNamespacedName", ...args);
|
||
}
|
||
|
||
function JSXOpeningElement(...args) {
|
||
return (0, _builder.default)("JSXOpeningElement", ...args);
|
||
}
|
||
|
||
function JSXSpreadAttribute(...args) {
|
||
return (0, _builder.default)("JSXSpreadAttribute", ...args);
|
||
}
|
||
|
||
function JSXText(...args) {
|
||
return (0, _builder.default)("JSXText", ...args);
|
||
}
|
||
|
||
function JSXFragment(...args) {
|
||
return (0, _builder.default)("JSXFragment", ...args);
|
||
}
|
||
|
||
function JSXOpeningFragment(...args) {
|
||
return (0, _builder.default)("JSXOpeningFragment", ...args);
|
||
}
|
||
|
||
function JSXClosingFragment(...args) {
|
||
return (0, _builder.default)("JSXClosingFragment", ...args);
|
||
}
|
||
|
||
function Noop(...args) {
|
||
return (0, _builder.default)("Noop", ...args);
|
||
}
|
||
|
||
function Placeholder(...args) {
|
||
return (0, _builder.default)("Placeholder", ...args);
|
||
}
|
||
|
||
function ArgumentPlaceholder(...args) {
|
||
return (0, _builder.default)("ArgumentPlaceholder", ...args);
|
||
}
|
||
|
||
function AwaitExpression(...args) {
|
||
return (0, _builder.default)("AwaitExpression", ...args);
|
||
}
|
||
|
||
function BindExpression(...args) {
|
||
return (0, _builder.default)("BindExpression", ...args);
|
||
}
|
||
|
||
function ClassProperty(...args) {
|
||
return (0, _builder.default)("ClassProperty", ...args);
|
||
}
|
||
|
||
function OptionalMemberExpression(...args) {
|
||
return (0, _builder.default)("OptionalMemberExpression", ...args);
|
||
}
|
||
|
||
function PipelineTopicExpression(...args) {
|
||
return (0, _builder.default)("PipelineTopicExpression", ...args);
|
||
}
|
||
|
||
function PipelineBareFunction(...args) {
|
||
return (0, _builder.default)("PipelineBareFunction", ...args);
|
||
}
|
||
|
||
function PipelinePrimaryTopicReference(...args) {
|
||
return (0, _builder.default)("PipelinePrimaryTopicReference", ...args);
|
||
}
|
||
|
||
function OptionalCallExpression(...args) {
|
||
return (0, _builder.default)("OptionalCallExpression", ...args);
|
||
}
|
||
|
||
function ClassPrivateProperty(...args) {
|
||
return (0, _builder.default)("ClassPrivateProperty", ...args);
|
||
}
|
||
|
||
function ClassPrivateMethod(...args) {
|
||
return (0, _builder.default)("ClassPrivateMethod", ...args);
|
||
}
|
||
|
||
function Import(...args) {
|
||
return (0, _builder.default)("Import", ...args);
|
||
}
|
||
|
||
function Decorator(...args) {
|
||
return (0, _builder.default)("Decorator", ...args);
|
||
}
|
||
|
||
function DoExpression(...args) {
|
||
return (0, _builder.default)("DoExpression", ...args);
|
||
}
|
||
|
||
function ExportDefaultSpecifier(...args) {
|
||
return (0, _builder.default)("ExportDefaultSpecifier", ...args);
|
||
}
|
||
|
||
function ExportNamespaceSpecifier(...args) {
|
||
return (0, _builder.default)("ExportNamespaceSpecifier", ...args);
|
||
}
|
||
|
||
function PrivateName(...args) {
|
||
return (0, _builder.default)("PrivateName", ...args);
|
||
}
|
||
|
||
function BigIntLiteral(...args) {
|
||
return (0, _builder.default)("BigIntLiteral", ...args);
|
||
}
|
||
|
||
function TSParameterProperty(...args) {
|
||
return (0, _builder.default)("TSParameterProperty", ...args);
|
||
}
|
||
|
||
function TSDeclareFunction(...args) {
|
||
return (0, _builder.default)("TSDeclareFunction", ...args);
|
||
}
|
||
|
||
function TSDeclareMethod(...args) {
|
||
return (0, _builder.default)("TSDeclareMethod", ...args);
|
||
}
|
||
|
||
function TSQualifiedName(...args) {
|
||
return (0, _builder.default)("TSQualifiedName", ...args);
|
||
}
|
||
|
||
function TSCallSignatureDeclaration(...args) {
|
||
return (0, _builder.default)("TSCallSignatureDeclaration", ...args);
|
||
}
|
||
|
||
function TSConstructSignatureDeclaration(...args) {
|
||
return (0, _builder.default)("TSConstructSignatureDeclaration", ...args);
|
||
}
|
||
|
||
function TSPropertySignature(...args) {
|
||
return (0, _builder.default)("TSPropertySignature", ...args);
|
||
}
|
||
|
||
function TSMethodSignature(...args) {
|
||
return (0, _builder.default)("TSMethodSignature", ...args);
|
||
}
|
||
|
||
function TSIndexSignature(...args) {
|
||
return (0, _builder.default)("TSIndexSignature", ...args);
|
||
}
|
||
|
||
function TSAnyKeyword(...args) {
|
||
return (0, _builder.default)("TSAnyKeyword", ...args);
|
||
}
|
||
|
||
function TSUnknownKeyword(...args) {
|
||
return (0, _builder.default)("TSUnknownKeyword", ...args);
|
||
}
|
||
|
||
function TSNumberKeyword(...args) {
|
||
return (0, _builder.default)("TSNumberKeyword", ...args);
|
||
}
|
||
|
||
function TSObjectKeyword(...args) {
|
||
return (0, _builder.default)("TSObjectKeyword", ...args);
|
||
}
|
||
|
||
function TSBooleanKeyword(...args) {
|
||
return (0, _builder.default)("TSBooleanKeyword", ...args);
|
||
}
|
||
|
||
function TSStringKeyword(...args) {
|
||
return (0, _builder.default)("TSStringKeyword", ...args);
|
||
}
|
||
|
||
function TSSymbolKeyword(...args) {
|
||
return (0, _builder.default)("TSSymbolKeyword", ...args);
|
||
}
|
||
|
||
function TSVoidKeyword(...args) {
|
||
return (0, _builder.default)("TSVoidKeyword", ...args);
|
||
}
|
||
|
||
function TSUndefinedKeyword(...args) {
|
||
return (0, _builder.default)("TSUndefinedKeyword", ...args);
|
||
}
|
||
|
||
function TSNullKeyword(...args) {
|
||
return (0, _builder.default)("TSNullKeyword", ...args);
|
||
}
|
||
|
||
function TSNeverKeyword(...args) {
|
||
return (0, _builder.default)("TSNeverKeyword", ...args);
|
||
}
|
||
|
||
function TSThisType(...args) {
|
||
return (0, _builder.default)("TSThisType", ...args);
|
||
}
|
||
|
||
function TSFunctionType(...args) {
|
||
return (0, _builder.default)("TSFunctionType", ...args);
|
||
}
|
||
|
||
function TSConstructorType(...args) {
|
||
return (0, _builder.default)("TSConstructorType", ...args);
|
||
}
|
||
|
||
function TSTypeReference(...args) {
|
||
return (0, _builder.default)("TSTypeReference", ...args);
|
||
}
|
||
|
||
function TSTypePredicate(...args) {
|
||
return (0, _builder.default)("TSTypePredicate", ...args);
|
||
}
|
||
|
||
function TSTypeQuery(...args) {
|
||
return (0, _builder.default)("TSTypeQuery", ...args);
|
||
}
|
||
|
||
function TSTypeLiteral(...args) {
|
||
return (0, _builder.default)("TSTypeLiteral", ...args);
|
||
}
|
||
|
||
function TSArrayType(...args) {
|
||
return (0, _builder.default)("TSArrayType", ...args);
|
||
}
|
||
|
||
function TSTupleType(...args) {
|
||
return (0, _builder.default)("TSTupleType", ...args);
|
||
}
|
||
|
||
function TSOptionalType(...args) {
|
||
return (0, _builder.default)("TSOptionalType", ...args);
|
||
}
|
||
|
||
function TSRestType(...args) {
|
||
return (0, _builder.default)("TSRestType", ...args);
|
||
}
|
||
|
||
function TSUnionType(...args) {
|
||
return (0, _builder.default)("TSUnionType", ...args);
|
||
}
|
||
|
||
function TSIntersectionType(...args) {
|
||
return (0, _builder.default)("TSIntersectionType", ...args);
|
||
}
|
||
|
||
function TSConditionalType(...args) {
|
||
return (0, _builder.default)("TSConditionalType", ...args);
|
||
}
|
||
|
||
function TSInferType(...args) {
|
||
return (0, _builder.default)("TSInferType", ...args);
|
||
}
|
||
|
||
function TSParenthesizedType(...args) {
|
||
return (0, _builder.default)("TSParenthesizedType", ...args);
|
||
}
|
||
|
||
function TSTypeOperator(...args) {
|
||
return (0, _builder.default)("TSTypeOperator", ...args);
|
||
}
|
||
|
||
function TSIndexedAccessType(...args) {
|
||
return (0, _builder.default)("TSIndexedAccessType", ...args);
|
||
}
|
||
|
||
function TSMappedType(...args) {
|
||
return (0, _builder.default)("TSMappedType", ...args);
|
||
}
|
||
|
||
function TSLiteralType(...args) {
|
||
return (0, _builder.default)("TSLiteralType", ...args);
|
||
}
|
||
|
||
function TSExpressionWithTypeArguments(...args) {
|
||
return (0, _builder.default)("TSExpressionWithTypeArguments", ...args);
|
||
}
|
||
|
||
function TSInterfaceDeclaration(...args) {
|
||
return (0, _builder.default)("TSInterfaceDeclaration", ...args);
|
||
}
|
||
|
||
function TSInterfaceBody(...args) {
|
||
return (0, _builder.default)("TSInterfaceBody", ...args);
|
||
}
|
||
|
||
function TSTypeAliasDeclaration(...args) {
|
||
return (0, _builder.default)("TSTypeAliasDeclaration", ...args);
|
||
}
|
||
|
||
function TSAsExpression(...args) {
|
||
return (0, _builder.default)("TSAsExpression", ...args);
|
||
}
|
||
|
||
function TSTypeAssertion(...args) {
|
||
return (0, _builder.default)("TSTypeAssertion", ...args);
|
||
}
|
||
|
||
function TSEnumDeclaration(...args) {
|
||
return (0, _builder.default)("TSEnumDeclaration", ...args);
|
||
}
|
||
|
||
function TSEnumMember(...args) {
|
||
return (0, _builder.default)("TSEnumMember", ...args);
|
||
}
|
||
|
||
function TSModuleDeclaration(...args) {
|
||
return (0, _builder.default)("TSModuleDeclaration", ...args);
|
||
}
|
||
|
||
function TSModuleBlock(...args) {
|
||
return (0, _builder.default)("TSModuleBlock", ...args);
|
||
}
|
||
|
||
function TSImportType(...args) {
|
||
return (0, _builder.default)("TSImportType", ...args);
|
||
}
|
||
|
||
function TSImportEqualsDeclaration(...args) {
|
||
return (0, _builder.default)("TSImportEqualsDeclaration", ...args);
|
||
}
|
||
|
||
function TSExternalModuleReference(...args) {
|
||
return (0, _builder.default)("TSExternalModuleReference", ...args);
|
||
}
|
||
|
||
function TSNonNullExpression(...args) {
|
||
return (0, _builder.default)("TSNonNullExpression", ...args);
|
||
}
|
||
|
||
function TSExportAssignment(...args) {
|
||
return (0, _builder.default)("TSExportAssignment", ...args);
|
||
}
|
||
|
||
function TSNamespaceExportDeclaration(...args) {
|
||
return (0, _builder.default)("TSNamespaceExportDeclaration", ...args);
|
||
}
|
||
|
||
function TSTypeAnnotation(...args) {
|
||
return (0, _builder.default)("TSTypeAnnotation", ...args);
|
||
}
|
||
|
||
function TSTypeParameterInstantiation(...args) {
|
||
return (0, _builder.default)("TSTypeParameterInstantiation", ...args);
|
||
}
|
||
|
||
function TSTypeParameterDeclaration(...args) {
|
||
return (0, _builder.default)("TSTypeParameterDeclaration", ...args);
|
||
}
|
||
|
||
function TSTypeParameter(...args) {
|
||
return (0, _builder.default)("TSTypeParameter", ...args);
|
||
}
|
||
|
||
function NumberLiteral(...args) {
|
||
console.trace("The node type NumberLiteral has been renamed to NumericLiteral");
|
||
return NumberLiteral("NumberLiteral", ...args);
|
||
}
|
||
|
||
function RegexLiteral(...args) {
|
||
console.trace("The node type RegexLiteral has been renamed to RegExpLiteral");
|
||
return RegexLiteral("RegexLiteral", ...args);
|
||
}
|
||
|
||
function RestProperty(...args) {
|
||
console.trace("The node type RestProperty has been renamed to RestElement");
|
||
return RestProperty("RestProperty", ...args);
|
||
}
|
||
|
||
function SpreadProperty(...args) {
|
||
console.trace("The node type SpreadProperty has been renamed to SpreadElement");
|
||
return SpreadProperty("SpreadProperty", ...args);
|
||
}
|
||
|
||
/***/ }),
|
||
/* 11 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
||
* and has a `typeof` result of "object".
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 4.0.0
|
||
* @category Lang
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
||
* @example
|
||
*
|
||
* _.isObjectLike({});
|
||
* // => true
|
||
*
|
||
* _.isObjectLike([1, 2, 3]);
|
||
* // => true
|
||
*
|
||
* _.isObjectLike(_.noop);
|
||
* // => false
|
||
*
|
||
* _.isObjectLike(null);
|
||
* // => false
|
||
*/
|
||
function isObjectLike(value) {
|
||
return value != null && typeof value == 'object';
|
||
}
|
||
|
||
module.exports = isObjectLike;
|
||
|
||
|
||
/***/ }),
|
||
/* 12 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/* Copyright 2011 Mozilla Foundation and contributors
|
||
* Licensed under the New BSD license. See LICENSE or:
|
||
* http://opensource.org/licenses/BSD-3-Clause
|
||
*/
|
||
|
||
/**
|
||
* This is a helper function for getting values from parameter/options
|
||
* objects.
|
||
*
|
||
* @param args The object we are extracting values from
|
||
* @param name The name of the property we are getting.
|
||
* @param defaultValue An optional value to return if the property is missing
|
||
* from the object. If this is not specified and the property is missing, an
|
||
* error will be thrown.
|
||
*/
|
||
function getArg(aArgs, aName, aDefaultValue) {
|
||
if (aName in aArgs) {
|
||
return aArgs[aName];
|
||
} else if (arguments.length === 3) {
|
||
return aDefaultValue;
|
||
} else {
|
||
throw new Error('"' + aName + '" is a required argument.');
|
||
}
|
||
}
|
||
exports.getArg = getArg;
|
||
|
||
var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.]*)(?::(\d+))?(\S*)$/;
|
||
var dataUrlRegexp = /^data:.+\,.+$/;
|
||
|
||
function urlParse(aUrl) {
|
||
var match = aUrl.match(urlRegexp);
|
||
if (!match) {
|
||
return null;
|
||
}
|
||
return {
|
||
scheme: match[1],
|
||
auth: match[2],
|
||
host: match[3],
|
||
port: match[4],
|
||
path: match[5]
|
||
};
|
||
}
|
||
exports.urlParse = urlParse;
|
||
|
||
function urlGenerate(aParsedUrl) {
|
||
var url = '';
|
||
if (aParsedUrl.scheme) {
|
||
url += aParsedUrl.scheme + ':';
|
||
}
|
||
url += '//';
|
||
if (aParsedUrl.auth) {
|
||
url += aParsedUrl.auth + '@';
|
||
}
|
||
if (aParsedUrl.host) {
|
||
url += aParsedUrl.host;
|
||
}
|
||
if (aParsedUrl.port) {
|
||
url += ":" + aParsedUrl.port
|
||
}
|
||
if (aParsedUrl.path) {
|
||
url += aParsedUrl.path;
|
||
}
|
||
return url;
|
||
}
|
||
exports.urlGenerate = urlGenerate;
|
||
|
||
/**
|
||
* Normalizes a path, or the path portion of a URL:
|
||
*
|
||
* - Replaces consecutive slashes with one slash.
|
||
* - Removes unnecessary '.' parts.
|
||
* - Removes unnecessary '<dir>/..' parts.
|
||
*
|
||
* Based on code in the Node.js 'path' core module.
|
||
*
|
||
* @param aPath The path or url to normalize.
|
||
*/
|
||
function normalize(aPath) {
|
||
var path = aPath;
|
||
var url = urlParse(aPath);
|
||
if (url) {
|
||
if (!url.path) {
|
||
return aPath;
|
||
}
|
||
path = url.path;
|
||
}
|
||
var isAbsolute = exports.isAbsolute(path);
|
||
|
||
var parts = path.split(/\/+/);
|
||
for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
|
||
part = parts[i];
|
||
if (part === '.') {
|
||
parts.splice(i, 1);
|
||
} else if (part === '..') {
|
||
up++;
|
||
} else if (up > 0) {
|
||
if (part === '') {
|
||
// The first part is blank if the path is absolute. Trying to go
|
||
// above the root is a no-op. Therefore we can remove all '..' parts
|
||
// directly after the root.
|
||
parts.splice(i + 1, up);
|
||
up = 0;
|
||
} else {
|
||
parts.splice(i, 2);
|
||
up--;
|
||
}
|
||
}
|
||
}
|
||
path = parts.join('/');
|
||
|
||
if (path === '') {
|
||
path = isAbsolute ? '/' : '.';
|
||
}
|
||
|
||
if (url) {
|
||
url.path = path;
|
||
return urlGenerate(url);
|
||
}
|
||
return path;
|
||
}
|
||
exports.normalize = normalize;
|
||
|
||
/**
|
||
* Joins two paths/URLs.
|
||
*
|
||
* @param aRoot The root path or URL.
|
||
* @param aPath The path or URL to be joined with the root.
|
||
*
|
||
* - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
|
||
* scheme-relative URL: Then the scheme of aRoot, if any, is prepended
|
||
* first.
|
||
* - Otherwise aPath is a path. If aRoot is a URL, then its path portion
|
||
* is updated with the result and aRoot is returned. Otherwise the result
|
||
* is returned.
|
||
* - If aPath is absolute, the result is aPath.
|
||
* - Otherwise the two paths are joined with a slash.
|
||
* - Joining for example 'http://' and 'www.example.com' is also supported.
|
||
*/
|
||
function join(aRoot, aPath) {
|
||
if (aRoot === "") {
|
||
aRoot = ".";
|
||
}
|
||
if (aPath === "") {
|
||
aPath = ".";
|
||
}
|
||
var aPathUrl = urlParse(aPath);
|
||
var aRootUrl = urlParse(aRoot);
|
||
if (aRootUrl) {
|
||
aRoot = aRootUrl.path || '/';
|
||
}
|
||
|
||
// `join(foo, '//www.example.org')`
|
||
if (aPathUrl && !aPathUrl.scheme) {
|
||
if (aRootUrl) {
|
||
aPathUrl.scheme = aRootUrl.scheme;
|
||
}
|
||
return urlGenerate(aPathUrl);
|
||
}
|
||
|
||
if (aPathUrl || aPath.match(dataUrlRegexp)) {
|
||
return aPath;
|
||
}
|
||
|
||
// `join('http://', 'www.example.com')`
|
||
if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
|
||
aRootUrl.host = aPath;
|
||
return urlGenerate(aRootUrl);
|
||
}
|
||
|
||
var joined = aPath.charAt(0) === '/'
|
||
? aPath
|
||
: normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
|
||
|
||
if (aRootUrl) {
|
||
aRootUrl.path = joined;
|
||
return urlGenerate(aRootUrl);
|
||
}
|
||
return joined;
|
||
}
|
||
exports.join = join;
|
||
|
||
exports.isAbsolute = function (aPath) {
|
||
return aPath.charAt(0) === '/' || !!aPath.match(urlRegexp);
|
||
};
|
||
|
||
/**
|
||
* Make a path relative to a URL or another path.
|
||
*
|
||
* @param aRoot The root path or URL.
|
||
* @param aPath The path or URL to be made relative to aRoot.
|
||
*/
|
||
function relative(aRoot, aPath) {
|
||
if (aRoot === "") {
|
||
aRoot = ".";
|
||
}
|
||
|
||
aRoot = aRoot.replace(/\/$/, '');
|
||
|
||
// It is possible for the path to be above the root. In this case, simply
|
||
// checking whether the root is a prefix of the path won't work. Instead, we
|
||
// need to remove components from the root one by one, until either we find
|
||
// a prefix that fits, or we run out of components to remove.
|
||
var level = 0;
|
||
while (aPath.indexOf(aRoot + '/') !== 0) {
|
||
var index = aRoot.lastIndexOf("/");
|
||
if (index < 0) {
|
||
return aPath;
|
||
}
|
||
|
||
// If the only part of the root that is left is the scheme (i.e. http://,
|
||
// file:///, etc.), one or more slashes (/), or simply nothing at all, we
|
||
// have exhausted all components, so the path is not relative to the root.
|
||
aRoot = aRoot.slice(0, index);
|
||
if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {
|
||
return aPath;
|
||
}
|
||
|
||
++level;
|
||
}
|
||
|
||
// Make sure we add a "../" for each component we removed from the root.
|
||
return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
|
||
}
|
||
exports.relative = relative;
|
||
|
||
var supportsNullProto = (function () {
|
||
var obj = Object.create(null);
|
||
return !('__proto__' in obj);
|
||
}());
|
||
|
||
function identity (s) {
|
||
return s;
|
||
}
|
||
|
||
/**
|
||
* Because behavior goes wacky when you set `__proto__` on objects, we
|
||
* have to prefix all the strings in our set with an arbitrary character.
|
||
*
|
||
* See https://github.com/mozilla/source-map/pull/31 and
|
||
* https://github.com/mozilla/source-map/issues/30
|
||
*
|
||
* @param String aStr
|
||
*/
|
||
function toSetString(aStr) {
|
||
if (isProtoString(aStr)) {
|
||
return '$' + aStr;
|
||
}
|
||
|
||
return aStr;
|
||
}
|
||
exports.toSetString = supportsNullProto ? identity : toSetString;
|
||
|
||
function fromSetString(aStr) {
|
||
if (isProtoString(aStr)) {
|
||
return aStr.slice(1);
|
||
}
|
||
|
||
return aStr;
|
||
}
|
||
exports.fromSetString = supportsNullProto ? identity : fromSetString;
|
||
|
||
function isProtoString(s) {
|
||
if (!s) {
|
||
return false;
|
||
}
|
||
|
||
var length = s.length;
|
||
|
||
if (length < 9 /* "__proto__".length */) {
|
||
return false;
|
||
}
|
||
|
||
if (s.charCodeAt(length - 1) !== 95 /* '_' */ ||
|
||
s.charCodeAt(length - 2) !== 95 /* '_' */ ||
|
||
s.charCodeAt(length - 3) !== 111 /* 'o' */ ||
|
||
s.charCodeAt(length - 4) !== 116 /* 't' */ ||
|
||
s.charCodeAt(length - 5) !== 111 /* 'o' */ ||
|
||
s.charCodeAt(length - 6) !== 114 /* 'r' */ ||
|
||
s.charCodeAt(length - 7) !== 112 /* 'p' */ ||
|
||
s.charCodeAt(length - 8) !== 95 /* '_' */ ||
|
||
s.charCodeAt(length - 9) !== 95 /* '_' */) {
|
||
return false;
|
||
}
|
||
|
||
for (var i = length - 10; i >= 0; i--) {
|
||
if (s.charCodeAt(i) !== 36 /* '$' */) {
|
||
return false;
|
||
}
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
/**
|
||
* Comparator between two mappings where the original positions are compared.
|
||
*
|
||
* Optionally pass in `true` as `onlyCompareGenerated` to consider two
|
||
* mappings with the same original source/line/column, but different generated
|
||
* line and column the same. Useful when searching for a mapping with a
|
||
* stubbed out mapping.
|
||
*/
|
||
function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
|
||
var cmp = mappingA.source - mappingB.source;
|
||
if (cmp !== 0) {
|
||
return cmp;
|
||
}
|
||
|
||
cmp = mappingA.originalLine - mappingB.originalLine;
|
||
if (cmp !== 0) {
|
||
return cmp;
|
||
}
|
||
|
||
cmp = mappingA.originalColumn - mappingB.originalColumn;
|
||
if (cmp !== 0 || onlyCompareOriginal) {
|
||
return cmp;
|
||
}
|
||
|
||
cmp = mappingA.generatedColumn - mappingB.generatedColumn;
|
||
if (cmp !== 0) {
|
||
return cmp;
|
||
}
|
||
|
||
cmp = mappingA.generatedLine - mappingB.generatedLine;
|
||
if (cmp !== 0) {
|
||
return cmp;
|
||
}
|
||
|
||
return mappingA.name - mappingB.name;
|
||
}
|
||
exports.compareByOriginalPositions = compareByOriginalPositions;
|
||
|
||
/**
|
||
* Comparator between two mappings with deflated source and name indices where
|
||
* the generated positions are compared.
|
||
*
|
||
* Optionally pass in `true` as `onlyCompareGenerated` to consider two
|
||
* mappings with the same generated line and column, but different
|
||
* source/name/original line and column the same. Useful when searching for a
|
||
* mapping with a stubbed out mapping.
|
||
*/
|
||
function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
|
||
var cmp = mappingA.generatedLine - mappingB.generatedLine;
|
||
if (cmp !== 0) {
|
||
return cmp;
|
||
}
|
||
|
||
cmp = mappingA.generatedColumn - mappingB.generatedColumn;
|
||
if (cmp !== 0 || onlyCompareGenerated) {
|
||
return cmp;
|
||
}
|
||
|
||
cmp = mappingA.source - mappingB.source;
|
||
if (cmp !== 0) {
|
||
return cmp;
|
||
}
|
||
|
||
cmp = mappingA.originalLine - mappingB.originalLine;
|
||
if (cmp !== 0) {
|
||
return cmp;
|
||
}
|
||
|
||
cmp = mappingA.originalColumn - mappingB.originalColumn;
|
||
if (cmp !== 0) {
|
||
return cmp;
|
||
}
|
||
|
||
return mappingA.name - mappingB.name;
|
||
}
|
||
exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
|
||
|
||
function strcmp(aStr1, aStr2) {
|
||
if (aStr1 === aStr2) {
|
||
return 0;
|
||
}
|
||
|
||
if (aStr1 > aStr2) {
|
||
return 1;
|
||
}
|
||
|
||
return -1;
|
||
}
|
||
|
||
/**
|
||
* Comparator between two mappings with inflated source and name strings where
|
||
* the generated positions are compared.
|
||
*/
|
||
function compareByGeneratedPositionsInflated(mappingA, mappingB) {
|
||
var cmp = mappingA.generatedLine - mappingB.generatedLine;
|
||
if (cmp !== 0) {
|
||
return cmp;
|
||
}
|
||
|
||
cmp = mappingA.generatedColumn - mappingB.generatedColumn;
|
||
if (cmp !== 0) {
|
||
return cmp;
|
||
}
|
||
|
||
cmp = strcmp(mappingA.source, mappingB.source);
|
||
if (cmp !== 0) {
|
||
return cmp;
|
||
}
|
||
|
||
cmp = mappingA.originalLine - mappingB.originalLine;
|
||
if (cmp !== 0) {
|
||
return cmp;
|
||
}
|
||
|
||
cmp = mappingA.originalColumn - mappingB.originalColumn;
|
||
if (cmp !== 0) {
|
||
return cmp;
|
||
}
|
||
|
||
return strcmp(mappingA.name, mappingB.name);
|
||
}
|
||
exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
|
||
|
||
|
||
/***/ }),
|
||
/* 13 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||
function networkRequest(url, opts) {
|
||
return fetch(url, {
|
||
cache: opts.loadFromCache ? "default" : "no-cache"
|
||
}).then(res => {
|
||
if (res.status >= 200 && res.status < 300) {
|
||
if (res.headers.get("Content-Type") === "application/wasm") {
|
||
return res.arrayBuffer().then(buffer => ({
|
||
content: buffer,
|
||
isDwarf: true
|
||
}));
|
||
}
|
||
|
||
return res.text().then(text => ({
|
||
content: text
|
||
}));
|
||
}
|
||
|
||
return Promise.reject(`request failed with status ${res.status}`);
|
||
});
|
||
}
|
||
|
||
module.exports = networkRequest;
|
||
|
||
/***/ }),
|
||
/* 14 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||
function WorkerDispatcher() {
|
||
this.msgId = 1;
|
||
this.worker = null;
|
||
}
|
||
|
||
WorkerDispatcher.prototype = {
|
||
start(url, win = window) {
|
||
this.worker = new win.Worker(url);
|
||
|
||
this.worker.onerror = () => {
|
||
console.error(`Error in worker ${url}`);
|
||
};
|
||
},
|
||
|
||
stop() {
|
||
if (!this.worker) {
|
||
return;
|
||
}
|
||
|
||
this.worker.terminate();
|
||
this.worker = null;
|
||
},
|
||
|
||
task(method, {
|
||
queue = false
|
||
} = {}) {
|
||
const calls = [];
|
||
|
||
const push = args => {
|
||
return new Promise((resolve, reject) => {
|
||
if (queue && calls.length === 0) {
|
||
Promise.resolve().then(flush);
|
||
}
|
||
|
||
calls.push([args, resolve, reject]);
|
||
|
||
if (!queue) {
|
||
flush();
|
||
}
|
||
});
|
||
};
|
||
|
||
const flush = () => {
|
||
const items = calls.slice();
|
||
calls.length = 0;
|
||
|
||
if (!this.worker) {
|
||
return;
|
||
}
|
||
|
||
const id = this.msgId++;
|
||
this.worker.postMessage({
|
||
id,
|
||
method,
|
||
calls: items.map(item => item[0])
|
||
});
|
||
|
||
const listener = ({
|
||
data: result
|
||
}) => {
|
||
if (result.id !== id) {
|
||
return;
|
||
}
|
||
|
||
if (!this.worker) {
|
||
return;
|
||
}
|
||
|
||
this.worker.removeEventListener("message", listener);
|
||
result.results.forEach((resultData, i) => {
|
||
const [, resolve, reject] = items[i];
|
||
|
||
if (resultData.error) {
|
||
const err = new Error(resultData.message);
|
||
err.metadata = resultData.metadata;
|
||
reject(err);
|
||
} else {
|
||
resolve(resultData.response);
|
||
}
|
||
});
|
||
};
|
||
|
||
this.worker.addEventListener("message", listener);
|
||
};
|
||
|
||
return (...args) => push(args);
|
||
},
|
||
|
||
invoke(method, ...args) {
|
||
return this.task(method)(...args);
|
||
}
|
||
|
||
};
|
||
|
||
function workerHandler(publicInterface) {
|
||
return function (msg) {
|
||
const {
|
||
id,
|
||
method,
|
||
calls
|
||
} = msg.data;
|
||
Promise.all(calls.map(args => {
|
||
try {
|
||
const response = publicInterface[method].apply(undefined, args);
|
||
|
||
if (response instanceof Promise) {
|
||
return response.then(val => ({
|
||
response: val
|
||
}), err => asErrorMessage(err));
|
||
}
|
||
|
||
return {
|
||
response
|
||
};
|
||
} catch (error) {
|
||
return asErrorMessage(error);
|
||
}
|
||
})).then(results => {
|
||
self.postMessage({
|
||
id,
|
||
results
|
||
});
|
||
});
|
||
};
|
||
}
|
||
|
||
function asErrorMessage(error) {
|
||
if (typeof error === "object" && error && "message" in error) {
|
||
// Error can't be sent via postMessage, so be sure to convert to
|
||
// string.
|
||
return {
|
||
error: true,
|
||
message: error.message,
|
||
metadata: error.metadata
|
||
};
|
||
}
|
||
|
||
return {
|
||
error: true,
|
||
message: error == null ? error : error.toString(),
|
||
metadata: undefined
|
||
};
|
||
}
|
||
|
||
module.exports = {
|
||
WorkerDispatcher,
|
||
workerHandler
|
||
};
|
||
|
||
/***/ }),
|
||
/* 15 */
|
||
/***/ (function(module, exports) {
|
||
|
||
var g;
|
||
|
||
// This works in non-strict mode
|
||
g = (function() {
|
||
return this;
|
||
})();
|
||
|
||
try {
|
||
// This works if eval is allowed (see CSP)
|
||
g = g || Function("return this")() || (1,eval)("this");
|
||
} catch(e) {
|
||
// This works if the window reference is available
|
||
if(typeof window === "object")
|
||
g = window;
|
||
}
|
||
|
||
// g can still be undefined, but nothing to do about it...
|
||
// We return undefined, instead of nothing here, so it's
|
||
// easier to handle this case. if(!global) { ...}
|
||
|
||
module.exports = g;
|
||
|
||
|
||
/***/ }),
|
||
/* 16 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
Object.defineProperty(exports, "VISITOR_KEYS", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _utils.VISITOR_KEYS;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "ALIAS_KEYS", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _utils.ALIAS_KEYS;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "FLIPPED_ALIAS_KEYS", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _utils.FLIPPED_ALIAS_KEYS;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "NODE_FIELDS", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _utils.NODE_FIELDS;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "BUILDER_KEYS", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _utils.BUILDER_KEYS;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "DEPRECATED_KEYS", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _utils.DEPRECATED_KEYS;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "PLACEHOLDERS", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _placeholders.PLACEHOLDERS;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "PLACEHOLDERS_ALIAS", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _placeholders.PLACEHOLDERS_ALIAS;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "PLACEHOLDERS_FLIPPED_ALIAS", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _placeholders.PLACEHOLDERS_FLIPPED_ALIAS;
|
||
}
|
||
});
|
||
exports.TYPES = void 0;
|
||
|
||
function _toFastProperties() {
|
||
const data = _interopRequireDefault(__webpack_require__(265));
|
||
|
||
_toFastProperties = function () {
|
||
return data;
|
||
};
|
||
|
||
return data;
|
||
}
|
||
|
||
__webpack_require__(81);
|
||
|
||
__webpack_require__(84);
|
||
|
||
__webpack_require__(269);
|
||
|
||
__webpack_require__(270);
|
||
|
||
__webpack_require__(271);
|
||
|
||
__webpack_require__(272);
|
||
|
||
__webpack_require__(273);
|
||
|
||
var _utils = __webpack_require__(23);
|
||
|
||
var _placeholders = __webpack_require__(518);
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
(0, _toFastProperties().default)(_utils.VISITOR_KEYS);
|
||
(0, _toFastProperties().default)(_utils.ALIAS_KEYS);
|
||
(0, _toFastProperties().default)(_utils.FLIPPED_ALIAS_KEYS);
|
||
(0, _toFastProperties().default)(_utils.NODE_FIELDS);
|
||
(0, _toFastProperties().default)(_utils.BUILDER_KEYS);
|
||
(0, _toFastProperties().default)(_utils.DEPRECATED_KEYS);
|
||
(0, _toFastProperties().default)(_placeholders.PLACEHOLDERS_ALIAS);
|
||
(0, _toFastProperties().default)(_placeholders.PLACEHOLDERS_FLIPPED_ALIAS);
|
||
const TYPES = Object.keys(_utils.VISITOR_KEYS).concat(Object.keys(_utils.FLIPPED_ALIAS_KEYS)).concat(Object.keys(_utils.DEPRECATED_KEYS));
|
||
exports.TYPES = TYPES;
|
||
|
||
/***/ }),
|
||
/* 17 */,
|
||
/* 18 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var Symbol = __webpack_require__(19),
|
||
getRawTag = __webpack_require__(71),
|
||
objectToString = __webpack_require__(72);
|
||
|
||
/** `Object#toString` result references. */
|
||
var nullTag = '[object Null]',
|
||
undefinedTag = '[object Undefined]';
|
||
|
||
/** Built-in value references. */
|
||
var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
|
||
|
||
/**
|
||
* The base implementation of `getTag` without fallbacks for buggy environments.
|
||
*
|
||
* @private
|
||
* @param {*} value The value to query.
|
||
* @returns {string} Returns the `toStringTag`.
|
||
*/
|
||
function baseGetTag(value) {
|
||
if (value == null) {
|
||
return value === undefined ? undefinedTag : nullTag;
|
||
}
|
||
return (symToStringTag && symToStringTag in Object(value))
|
||
? getRawTag(value)
|
||
: objectToString(value);
|
||
}
|
||
|
||
module.exports = baseGetTag;
|
||
|
||
|
||
/***/ }),
|
||
/* 19 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var root = __webpack_require__(8);
|
||
|
||
/** Built-in value references. */
|
||
var Symbol = root.Symbol;
|
||
|
||
module.exports = Symbol;
|
||
|
||
|
||
/***/ }),
|
||
/* 20 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.parse = parse;
|
||
exports.parseConsoleScript = parseConsoleScript;
|
||
exports.parseScript = parseScript;
|
||
exports.getAst = getAst;
|
||
exports.clearASTs = clearASTs;
|
||
exports.traverseAst = traverseAst;
|
||
exports.hasNode = hasNode;
|
||
exports.replaceNode = replaceNode;
|
||
|
||
var _parseScriptTags = _interopRequireDefault(__webpack_require__(320));
|
||
|
||
var babelParser = _interopRequireWildcard(__webpack_require__(324));
|
||
|
||
var t = _interopRequireWildcard(__webpack_require__(3));
|
||
|
||
var _isEmpty = _interopRequireDefault(__webpack_require__(154));
|
||
|
||
var _sources = __webpack_require__(155);
|
||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||
let ASTs = new Map();
|
||
|
||
function _parse(code, opts) {
|
||
return babelParser.parse(code, { ...opts,
|
||
tokens: true
|
||
});
|
||
}
|
||
|
||
const sourceOptions = {
|
||
generated: {
|
||
sourceType: "unambiguous",
|
||
tokens: true,
|
||
plugins: ["objectRestSpread"]
|
||
},
|
||
original: {
|
||
sourceType: "unambiguous",
|
||
tokens: true,
|
||
plugins: ["jsx", "flow", "doExpressions", "decorators-legacy", "objectRestSpread", "classProperties", "exportDefaultFrom", "exportNamespaceFrom", "asyncGenerators", "functionBind", "functionSent", "dynamicImport", "react-jsx"]
|
||
}
|
||
};
|
||
|
||
function parse(text, opts) {
|
||
let ast;
|
||
|
||
if (!text) {
|
||
return;
|
||
}
|
||
|
||
try {
|
||
ast = _parse(text, opts);
|
||
} catch (error) {
|
||
console.error(error);
|
||
ast = {};
|
||
}
|
||
|
||
return ast;
|
||
} // Custom parser for parse-script-tags that adapts its input structure to
|
||
// our parser's signature
|
||
|
||
|
||
function htmlParser({
|
||
source,
|
||
line
|
||
}) {
|
||
return parse(source, {
|
||
startLine: line
|
||
});
|
||
}
|
||
|
||
const VUE_COMPONENT_START = /^\s*</;
|
||
|
||
function vueParser({
|
||
source,
|
||
line
|
||
}) {
|
||
return parse(source, {
|
||
startLine: line,
|
||
...sourceOptions.original
|
||
});
|
||
}
|
||
|
||
function parseVueScript(code) {
|
||
if (typeof code !== "string") {
|
||
return;
|
||
}
|
||
|
||
let ast; // .vue files go through several passes, so while there is a
|
||
// single-file-component Vue template, there are also generally .vue files
|
||
// that are still just JS as well.
|
||
|
||
if (code.match(VUE_COMPONENT_START)) {
|
||
ast = (0, _parseScriptTags.default)(code, vueParser);
|
||
|
||
if (t.isFile(ast)) {
|
||
// parseScriptTags is currently hard-coded to return scripts, but Vue
|
||
// always expects ESM syntax, so we just hard-code it.
|
||
ast.program.sourceType = "module";
|
||
}
|
||
} else {
|
||
ast = parse(code, sourceOptions.original);
|
||
}
|
||
|
||
return ast;
|
||
}
|
||
|
||
function parseConsoleScript(text, opts) {
|
||
try {
|
||
return _parse(text, {
|
||
plugins: ["objectRestSpread", "dynamicImport"],
|
||
...opts,
|
||
allowAwaitOutsideFunction: true
|
||
});
|
||
} catch (e) {
|
||
return null;
|
||
}
|
||
}
|
||
|
||
function parseScript(text, opts) {
|
||
return _parse(text, opts);
|
||
}
|
||
|
||
function getAst(sourceId) {
|
||
if (ASTs.has(sourceId)) {
|
||
return ASTs.get(sourceId);
|
||
}
|
||
|
||
const source = (0, _sources.getSource)(sourceId);
|
||
|
||
if (source.isWasm) {
|
||
return null;
|
||
}
|
||
|
||
let ast = {};
|
||
const {
|
||
contentType
|
||
} = source;
|
||
|
||
if (contentType == "text/html") {
|
||
ast = (0, _parseScriptTags.default)(source.text, htmlParser) || {};
|
||
} else if (contentType && contentType === "text/vue") {
|
||
ast = parseVueScript(source.text) || {};
|
||
} else if (contentType && contentType.match(/(javascript|jsx)/) && !contentType.match(/typescript-jsx/)) {
|
||
const type = source.id.includes("original") ? "original" : "generated";
|
||
const options = sourceOptions[type];
|
||
ast = parse(source.text, options);
|
||
} else if (contentType && contentType.match(/typescript/)) {
|
||
const options = { ...sourceOptions.original,
|
||
plugins: [...sourceOptions.original.plugins.filter(p => p !== "flow" && p !== "decorators" && p !== "decorators2" && (p !== "jsx" || contentType.match(/typescript-jsx/))), "decorators-legacy", "typescript"]
|
||
};
|
||
ast = parse(source.text, options);
|
||
}
|
||
|
||
ASTs.set(source.id, ast);
|
||
return ast;
|
||
}
|
||
|
||
function clearASTs() {
|
||
ASTs = new Map();
|
||
}
|
||
|
||
function traverseAst(sourceId, visitor, state) {
|
||
const ast = getAst(sourceId);
|
||
|
||
if ((0, _isEmpty.default)(ast)) {
|
||
return null;
|
||
}
|
||
|
||
t.traverse(ast, visitor, state);
|
||
return ast;
|
||
}
|
||
|
||
function hasNode(rootNode, predicate) {
|
||
try {
|
||
t.traverse(rootNode, {
|
||
enter: (node, ancestors) => {
|
||
if (predicate(node, ancestors)) {
|
||
throw new Error("MATCH");
|
||
}
|
||
}
|
||
});
|
||
} catch (e) {
|
||
if (e.message === "MATCH") {
|
||
return true;
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function replaceNode(ancestors, node) {
|
||
const parent = ancestors[ancestors.length - 1];
|
||
|
||
if (typeof parent.index === "number") {
|
||
if (Array.isArray(node)) {
|
||
parent.node[parent.key].splice(parent.index, 1, ...node);
|
||
} else {
|
||
parent.node[parent.key][parent.index] = node;
|
||
}
|
||
} else {
|
||
parent.node[parent.key] = node;
|
||
}
|
||
}
|
||
|
||
/***/ }),
|
||
/* 21 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* Checks if `value` is the
|
||
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
||
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 0.1.0
|
||
* @category Lang
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
||
* @example
|
||
*
|
||
* _.isObject({});
|
||
* // => true
|
||
*
|
||
* _.isObject([1, 2, 3]);
|
||
* // => true
|
||
*
|
||
* _.isObject(_.noop);
|
||
* // => true
|
||
*
|
||
* _.isObject(null);
|
||
* // => false
|
||
*/
|
||
function isObject(value) {
|
||
var type = typeof value;
|
||
return value != null && (type == 'object' || type == 'function');
|
||
}
|
||
|
||
module.exports = isObject;
|
||
|
||
|
||
/***/ }),
|
||
/* 22 */
|
||
/***/ (function(module, exports) {
|
||
|
||
module.exports = function(module) {
|
||
if(!module.webpackPolyfill) {
|
||
module.deprecate = function() {};
|
||
module.paths = [];
|
||
// module.parent = undefined by default
|
||
if(!module.children) module.children = [];
|
||
Object.defineProperty(module, "loaded", {
|
||
enumerable: true,
|
||
get: function() {
|
||
return module.l;
|
||
}
|
||
});
|
||
Object.defineProperty(module, "id", {
|
||
enumerable: true,
|
||
get: function() {
|
||
return module.i;
|
||
}
|
||
});
|
||
module.webpackPolyfill = 1;
|
||
}
|
||
return module;
|
||
};
|
||
|
||
|
||
/***/ }),
|
||
/* 23 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.validate = validate;
|
||
exports.typeIs = typeIs;
|
||
exports.validateType = validateType;
|
||
exports.validateOptional = validateOptional;
|
||
exports.validateOptionalType = validateOptionalType;
|
||
exports.arrayOf = arrayOf;
|
||
exports.arrayOfType = arrayOfType;
|
||
exports.validateArrayOfType = validateArrayOfType;
|
||
exports.assertEach = assertEach;
|
||
exports.assertOneOf = assertOneOf;
|
||
exports.assertNodeType = assertNodeType;
|
||
exports.assertNodeOrValueType = assertNodeOrValueType;
|
||
exports.assertValueType = assertValueType;
|
||
exports.assertShape = assertShape;
|
||
exports.chain = chain;
|
||
exports.default = defineType;
|
||
exports.DEPRECATED_KEYS = exports.BUILDER_KEYS = exports.NODE_FIELDS = exports.FLIPPED_ALIAS_KEYS = exports.ALIAS_KEYS = exports.VISITOR_KEYS = void 0;
|
||
|
||
var _is = _interopRequireDefault(__webpack_require__(82));
|
||
|
||
var _validate = __webpack_require__(136);
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
const VISITOR_KEYS = {};
|
||
exports.VISITOR_KEYS = VISITOR_KEYS;
|
||
const ALIAS_KEYS = {};
|
||
exports.ALIAS_KEYS = ALIAS_KEYS;
|
||
const FLIPPED_ALIAS_KEYS = {};
|
||
exports.FLIPPED_ALIAS_KEYS = FLIPPED_ALIAS_KEYS;
|
||
const NODE_FIELDS = {};
|
||
exports.NODE_FIELDS = NODE_FIELDS;
|
||
const BUILDER_KEYS = {};
|
||
exports.BUILDER_KEYS = BUILDER_KEYS;
|
||
const DEPRECATED_KEYS = {};
|
||
exports.DEPRECATED_KEYS = DEPRECATED_KEYS;
|
||
|
||
function getType(val) {
|
||
if (Array.isArray(val)) {
|
||
return "array";
|
||
} else if (val === null) {
|
||
return "null";
|
||
} else if (val === undefined) {
|
||
return "undefined";
|
||
} else {
|
||
return typeof val;
|
||
}
|
||
}
|
||
|
||
function validate(validate) {
|
||
return {
|
||
validate
|
||
};
|
||
}
|
||
|
||
function typeIs(typeName) {
|
||
return typeof typeName === "string" ? assertNodeType(typeName) : assertNodeType(...typeName);
|
||
}
|
||
|
||
function validateType(typeName) {
|
||
return validate(typeIs(typeName));
|
||
}
|
||
|
||
function validateOptional(validate) {
|
||
return {
|
||
validate,
|
||
optional: true
|
||
};
|
||
}
|
||
|
||
function validateOptionalType(typeName) {
|
||
return {
|
||
validate: typeIs(typeName),
|
||
optional: true
|
||
};
|
||
}
|
||
|
||
function arrayOf(elementType) {
|
||
return chain(assertValueType("array"), assertEach(elementType));
|
||
}
|
||
|
||
function arrayOfType(typeName) {
|
||
return arrayOf(typeIs(typeName));
|
||
}
|
||
|
||
function validateArrayOfType(typeName) {
|
||
return validate(arrayOfType(typeName));
|
||
}
|
||
|
||
function assertEach(callback) {
|
||
function validator(node, key, val) {
|
||
if (!Array.isArray(val)) return;
|
||
|
||
for (let i = 0; i < val.length; i++) {
|
||
callback(node, `${key}[${i}]`, val[i]);
|
||
}
|
||
}
|
||
|
||
validator.each = callback;
|
||
return validator;
|
||
}
|
||
|
||
function assertOneOf(...values) {
|
||
function validate(node, key, val) {
|
||
if (values.indexOf(val) < 0) {
|
||
throw new TypeError(`Property ${key} expected value to be one of ${JSON.stringify(values)} but got ${JSON.stringify(val)}`);
|
||
}
|
||
}
|
||
|
||
validate.oneOf = values;
|
||
return validate;
|
||
}
|
||
|
||
function assertNodeType(...types) {
|
||
function validate(node, key, val) {
|
||
let valid = false;
|
||
|
||
for (const type of types) {
|
||
if ((0, _is.default)(type, val)) {
|
||
valid = true;
|
||
break;
|
||
}
|
||
}
|
||
|
||
if (!valid) {
|
||
throw new TypeError(`Property ${key} of ${node.type} expected node to be of a type ${JSON.stringify(types)} ` + `but instead got ${JSON.stringify(val && val.type)}`);
|
||
}
|
||
}
|
||
|
||
validate.oneOfNodeTypes = types;
|
||
return validate;
|
||
}
|
||
|
||
function assertNodeOrValueType(...types) {
|
||
function validate(node, key, val) {
|
||
let valid = false;
|
||
|
||
for (const type of types) {
|
||
if (getType(val) === type || (0, _is.default)(type, val)) {
|
||
valid = true;
|
||
break;
|
||
}
|
||
}
|
||
|
||
if (!valid) {
|
||
throw new TypeError(`Property ${key} of ${node.type} expected node to be of a type ${JSON.stringify(types)} ` + `but instead got ${JSON.stringify(val && val.type)}`);
|
||
}
|
||
}
|
||
|
||
validate.oneOfNodeOrValueTypes = types;
|
||
return validate;
|
||
}
|
||
|
||
function assertValueType(type) {
|
||
function validate(node, key, val) {
|
||
const valid = getType(val) === type;
|
||
|
||
if (!valid) {
|
||
throw new TypeError(`Property ${key} expected type of ${type} but got ${getType(val)}`);
|
||
}
|
||
}
|
||
|
||
validate.type = type;
|
||
return validate;
|
||
}
|
||
|
||
function assertShape(shape) {
|
||
function validate(node, key, val) {
|
||
const errors = [];
|
||
|
||
for (const property of Object.keys(shape)) {
|
||
try {
|
||
(0, _validate.validateField)(node, property, val[property], shape[property]);
|
||
} catch (error) {
|
||
if (error instanceof TypeError) {
|
||
errors.push(error.message);
|
||
continue;
|
||
}
|
||
|
||
throw error;
|
||
}
|
||
}
|
||
|
||
if (errors.length) {
|
||
throw new TypeError(`Property ${key} of ${node.type} expected to have the following:\n${errors.join("\n")}`);
|
||
}
|
||
}
|
||
|
||
validate.shapeOf = shape;
|
||
return validate;
|
||
}
|
||
|
||
function chain(...fns) {
|
||
function validate(...args) {
|
||
for (const fn of fns) {
|
||
fn(...args);
|
||
}
|
||
}
|
||
|
||
validate.chainOf = fns;
|
||
return validate;
|
||
}
|
||
|
||
function defineType(type, opts = {}) {
|
||
const inherits = opts.inherits && store[opts.inherits] || {};
|
||
const fields = opts.fields || inherits.fields || {};
|
||
const visitor = opts.visitor || inherits.visitor || [];
|
||
const aliases = opts.aliases || inherits.aliases || [];
|
||
const builder = opts.builder || inherits.builder || opts.visitor || [];
|
||
|
||
if (opts.deprecatedAlias) {
|
||
DEPRECATED_KEYS[opts.deprecatedAlias] = type;
|
||
}
|
||
|
||
for (const key of visitor.concat(builder)) {
|
||
fields[key] = fields[key] || {};
|
||
}
|
||
|
||
for (const key of Object.keys(fields)) {
|
||
const field = fields[key];
|
||
|
||
if (builder.indexOf(key) === -1) {
|
||
field.optional = true;
|
||
}
|
||
|
||
if (field.default === undefined) {
|
||
field.default = null;
|
||
} else if (!field.validate) {
|
||
field.validate = assertValueType(getType(field.default));
|
||
}
|
||
}
|
||
|
||
VISITOR_KEYS[type] = opts.visitor = visitor;
|
||
BUILDER_KEYS[type] = opts.builder = builder;
|
||
NODE_FIELDS[type] = opts.fields = fields;
|
||
ALIAS_KEYS[type] = opts.aliases = aliases;
|
||
aliases.forEach(alias => {
|
||
FLIPPED_ALIAS_KEYS[alias] = FLIPPED_ALIAS_KEYS[alias] || [];
|
||
FLIPPED_ALIAS_KEYS[alias].push(type);
|
||
});
|
||
store[type] = opts;
|
||
}
|
||
|
||
const store = {};
|
||
|
||
/***/ }),
|
||
/* 24 */,
|
||
/* 25 */,
|
||
/* 26 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var baseIsNative = __webpack_require__(217),
|
||
getValue = __webpack_require__(220);
|
||
|
||
/**
|
||
* Gets the native function at `key` of `object`.
|
||
*
|
||
* @private
|
||
* @param {Object} object The object to query.
|
||
* @param {string} key The key of the method to get.
|
||
* @returns {*} Returns the function if it's native, else `undefined`.
|
||
*/
|
||
function getNative(object, key) {
|
||
var value = getValue(object, key);
|
||
return baseIsNative(value) ? value : undefined;
|
||
}
|
||
|
||
module.exports = getNative;
|
||
|
||
|
||
/***/ }),
|
||
/* 27 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.NOT_LOCAL_BINDING = exports.BLOCK_SCOPED_SYMBOL = exports.INHERIT_KEYS = exports.UNARY_OPERATORS = exports.STRING_UNARY_OPERATORS = exports.NUMBER_UNARY_OPERATORS = exports.BOOLEAN_UNARY_OPERATORS = exports.BINARY_OPERATORS = exports.NUMBER_BINARY_OPERATORS = exports.BOOLEAN_BINARY_OPERATORS = exports.COMPARISON_BINARY_OPERATORS = exports.EQUALITY_BINARY_OPERATORS = exports.BOOLEAN_NUMBER_BINARY_OPERATORS = exports.UPDATE_OPERATORS = exports.LOGICAL_OPERATORS = exports.COMMENT_KEYS = exports.FOR_INIT_KEYS = exports.FLATTENABLE_KEYS = exports.STATEMENT_OR_BLOCK_KEYS = void 0;
|
||
const STATEMENT_OR_BLOCK_KEYS = ["consequent", "body", "alternate"];
|
||
exports.STATEMENT_OR_BLOCK_KEYS = STATEMENT_OR_BLOCK_KEYS;
|
||
const FLATTENABLE_KEYS = ["body", "expressions"];
|
||
exports.FLATTENABLE_KEYS = FLATTENABLE_KEYS;
|
||
const FOR_INIT_KEYS = ["left", "init"];
|
||
exports.FOR_INIT_KEYS = FOR_INIT_KEYS;
|
||
const COMMENT_KEYS = ["leadingComments", "trailingComments", "innerComments"];
|
||
exports.COMMENT_KEYS = COMMENT_KEYS;
|
||
const LOGICAL_OPERATORS = ["||", "&&", "??"];
|
||
exports.LOGICAL_OPERATORS = LOGICAL_OPERATORS;
|
||
const UPDATE_OPERATORS = ["++", "--"];
|
||
exports.UPDATE_OPERATORS = UPDATE_OPERATORS;
|
||
const BOOLEAN_NUMBER_BINARY_OPERATORS = [">", "<", ">=", "<="];
|
||
exports.BOOLEAN_NUMBER_BINARY_OPERATORS = BOOLEAN_NUMBER_BINARY_OPERATORS;
|
||
const EQUALITY_BINARY_OPERATORS = ["==", "===", "!=", "!=="];
|
||
exports.EQUALITY_BINARY_OPERATORS = EQUALITY_BINARY_OPERATORS;
|
||
const COMPARISON_BINARY_OPERATORS = [...EQUALITY_BINARY_OPERATORS, "in", "instanceof"];
|
||
exports.COMPARISON_BINARY_OPERATORS = COMPARISON_BINARY_OPERATORS;
|
||
const BOOLEAN_BINARY_OPERATORS = [...COMPARISON_BINARY_OPERATORS, ...BOOLEAN_NUMBER_BINARY_OPERATORS];
|
||
exports.BOOLEAN_BINARY_OPERATORS = BOOLEAN_BINARY_OPERATORS;
|
||
const NUMBER_BINARY_OPERATORS = ["-", "/", "%", "*", "**", "&", "|", ">>", ">>>", "<<", "^"];
|
||
exports.NUMBER_BINARY_OPERATORS = NUMBER_BINARY_OPERATORS;
|
||
const BINARY_OPERATORS = ["+", ...NUMBER_BINARY_OPERATORS, ...BOOLEAN_BINARY_OPERATORS];
|
||
exports.BINARY_OPERATORS = BINARY_OPERATORS;
|
||
const BOOLEAN_UNARY_OPERATORS = ["delete", "!"];
|
||
exports.BOOLEAN_UNARY_OPERATORS = BOOLEAN_UNARY_OPERATORS;
|
||
const NUMBER_UNARY_OPERATORS = ["+", "-", "~"];
|
||
exports.NUMBER_UNARY_OPERATORS = NUMBER_UNARY_OPERATORS;
|
||
const STRING_UNARY_OPERATORS = ["typeof"];
|
||
exports.STRING_UNARY_OPERATORS = STRING_UNARY_OPERATORS;
|
||
const UNARY_OPERATORS = ["void", "throw", ...BOOLEAN_UNARY_OPERATORS, ...NUMBER_UNARY_OPERATORS, ...STRING_UNARY_OPERATORS];
|
||
exports.UNARY_OPERATORS = UNARY_OPERATORS;
|
||
const INHERIT_KEYS = {
|
||
optional: ["typeAnnotation", "typeParameters", "returnType"],
|
||
force: ["start", "loc", "end"]
|
||
};
|
||
exports.INHERIT_KEYS = INHERIT_KEYS;
|
||
const BLOCK_SCOPED_SYMBOL = Symbol.for("var used to be block scoped");
|
||
exports.BLOCK_SCOPED_SYMBOL = BLOCK_SCOPED_SYMBOL;
|
||
const NOT_LOCAL_BINDING = Symbol.for("should not be considered a local binding");
|
||
exports.NOT_LOCAL_BINDING = NOT_LOCAL_BINDING;
|
||
|
||
/***/ }),
|
||
/* 28 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var baseGetTag = __webpack_require__(18),
|
||
isObjectLike = __webpack_require__(11);
|
||
|
||
/** `Object#toString` result references. */
|
||
var symbolTag = '[object Symbol]';
|
||
|
||
/**
|
||
* Checks if `value` is classified as a `Symbol` primitive or object.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 4.0.0
|
||
* @category Lang
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
|
||
* @example
|
||
*
|
||
* _.isSymbol(Symbol.iterator);
|
||
* // => true
|
||
*
|
||
* _.isSymbol('abc');
|
||
* // => false
|
||
*/
|
||
function isSymbol(value) {
|
||
return typeof value == 'symbol' ||
|
||
(isObjectLike(value) && baseGetTag(value) == symbolTag);
|
||
}
|
||
|
||
module.exports = isSymbol;
|
||
|
||
|
||
/***/ }),
|
||
/* 29 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var DataView = __webpack_require__(250),
|
||
Map = __webpack_require__(70),
|
||
Promise = __webpack_require__(251),
|
||
Set = __webpack_require__(133),
|
||
WeakMap = __webpack_require__(252),
|
||
baseGetTag = __webpack_require__(18),
|
||
toSource = __webpack_require__(121);
|
||
|
||
/** `Object#toString` result references. */
|
||
var mapTag = '[object Map]',
|
||
objectTag = '[object Object]',
|
||
promiseTag = '[object Promise]',
|
||
setTag = '[object Set]',
|
||
weakMapTag = '[object WeakMap]';
|
||
|
||
var dataViewTag = '[object DataView]';
|
||
|
||
/** Used to detect maps, sets, and weakmaps. */
|
||
var dataViewCtorString = toSource(DataView),
|
||
mapCtorString = toSource(Map),
|
||
promiseCtorString = toSource(Promise),
|
||
setCtorString = toSource(Set),
|
||
weakMapCtorString = toSource(WeakMap);
|
||
|
||
/**
|
||
* Gets the `toStringTag` of `value`.
|
||
*
|
||
* @private
|
||
* @param {*} value The value to query.
|
||
* @returns {string} Returns the `toStringTag`.
|
||
*/
|
||
var getTag = baseGetTag;
|
||
|
||
// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
|
||
if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
|
||
(Map && getTag(new Map) != mapTag) ||
|
||
(Promise && getTag(Promise.resolve()) != promiseTag) ||
|
||
(Set && getTag(new Set) != setTag) ||
|
||
(WeakMap && getTag(new WeakMap) != weakMapTag)) {
|
||
getTag = function(value) {
|
||
var result = baseGetTag(value),
|
||
Ctor = result == objectTag ? value.constructor : undefined,
|
||
ctorString = Ctor ? toSource(Ctor) : '';
|
||
|
||
if (ctorString) {
|
||
switch (ctorString) {
|
||
case dataViewCtorString: return dataViewTag;
|
||
case mapCtorString: return mapTag;
|
||
case promiseCtorString: return promiseTag;
|
||
case setCtorString: return setTag;
|
||
case weakMapCtorString: return weakMapTag;
|
||
}
|
||
}
|
||
return result;
|
||
};
|
||
}
|
||
|
||
module.exports = getTag;
|
||
|
||
|
||
/***/ }),
|
||
/* 30 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = isValidIdentifier;
|
||
|
||
function _esutils() {
|
||
const data = _interopRequireDefault(__webpack_require__(266));
|
||
|
||
_esutils = function () {
|
||
return data;
|
||
};
|
||
|
||
return data;
|
||
}
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function isValidIdentifier(name) {
|
||
if (typeof name !== "string" || _esutils().default.keyword.isReservedWordES6(name, true)) {
|
||
return false;
|
||
} else if (name === "await") {
|
||
return false;
|
||
} else {
|
||
return _esutils().default.keyword.isIdentifierNameES6(name);
|
||
}
|
||
}
|
||
|
||
/***/ }),
|
||
/* 31 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = cloneNode;
|
||
|
||
var _definitions = __webpack_require__(16);
|
||
|
||
const has = Function.call.bind(Object.prototype.hasOwnProperty);
|
||
|
||
function cloneIfNode(obj, deep) {
|
||
if (obj && typeof obj.type === "string" && obj.type !== "CommentLine" && obj.type !== "CommentBlock") {
|
||
return cloneNode(obj, deep);
|
||
}
|
||
|
||
return obj;
|
||
}
|
||
|
||
function cloneIfNodeOrArray(obj, deep) {
|
||
if (Array.isArray(obj)) {
|
||
return obj.map(node => cloneIfNode(node, deep));
|
||
}
|
||
|
||
return cloneIfNode(obj, deep);
|
||
}
|
||
|
||
function cloneNode(node, deep = true) {
|
||
if (!node) return node;
|
||
const {
|
||
type
|
||
} = node;
|
||
const newNode = {
|
||
type
|
||
};
|
||
|
||
if (type === "Identifier") {
|
||
newNode.name = node.name;
|
||
|
||
if (has(node, "optional") && typeof node.optional === "boolean") {
|
||
newNode.optional = node.optional;
|
||
}
|
||
|
||
if (has(node, "typeAnnotation")) {
|
||
newNode.typeAnnotation = deep ? cloneIfNodeOrArray(node.typeAnnotation, true) : node.typeAnnotation;
|
||
}
|
||
} else if (!has(_definitions.NODE_FIELDS, type)) {
|
||
throw new Error(`Unknown node type: "${type}"`);
|
||
} else {
|
||
for (const field of Object.keys(_definitions.NODE_FIELDS[type])) {
|
||
if (has(node, field)) {
|
||
newNode[field] = deep ? cloneIfNodeOrArray(node[field], true) : node[field];
|
||
}
|
||
}
|
||
}
|
||
|
||
if (has(node, "loc")) {
|
||
newNode.loc = node.loc;
|
||
}
|
||
|
||
if (has(node, "leadingComments")) {
|
||
newNode.leadingComments = node.leadingComments;
|
||
}
|
||
|
||
if (has(node, "innerComments")) {
|
||
newNode.innerComments = node.innerComments;
|
||
}
|
||
|
||
if (has(node, "trailingComments")) {
|
||
newNode.trailingComments = node.trailingComments;
|
||
}
|
||
|
||
if (has(node, "extra")) {
|
||
newNode.extra = Object.assign({}, node.extra);
|
||
}
|
||
|
||
return newNode;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 32 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
/* Copyright 2011 Mozilla Foundation and contributors
|
||
* Licensed under the New BSD license. See LICENSE or:
|
||
* http://opensource.org/licenses/BSD-3-Clause
|
||
*/
|
||
|
||
var base64VLQ = __webpack_require__(33);
|
||
var util = __webpack_require__(12);
|
||
var ArraySet = __webpack_require__(34).ArraySet;
|
||
var MappingList = __webpack_require__(90).MappingList;
|
||
|
||
/**
|
||
* An instance of the SourceMapGenerator represents a source map which is
|
||
* being built incrementally. You may pass an object with the following
|
||
* properties:
|
||
*
|
||
* - file: The filename of the generated source.
|
||
* - sourceRoot: A root for all relative URLs in this source map.
|
||
*/
|
||
function SourceMapGenerator(aArgs) {
|
||
if (!aArgs) {
|
||
aArgs = {};
|
||
}
|
||
this._file = util.getArg(aArgs, 'file', null);
|
||
this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null);
|
||
this._skipValidation = util.getArg(aArgs, 'skipValidation', false);
|
||
this._sources = new ArraySet();
|
||
this._names = new ArraySet();
|
||
this._mappings = new MappingList();
|
||
this._sourcesContents = null;
|
||
}
|
||
|
||
SourceMapGenerator.prototype._version = 3;
|
||
|
||
/**
|
||
* Creates a new SourceMapGenerator based on a SourceMapConsumer
|
||
*
|
||
* @param aSourceMapConsumer The SourceMap.
|
||
*/
|
||
SourceMapGenerator.fromSourceMap =
|
||
function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) {
|
||
var sourceRoot = aSourceMapConsumer.sourceRoot;
|
||
var generator = new SourceMapGenerator({
|
||
file: aSourceMapConsumer.file,
|
||
sourceRoot: sourceRoot
|
||
});
|
||
aSourceMapConsumer.eachMapping(function (mapping) {
|
||
var newMapping = {
|
||
generated: {
|
||
line: mapping.generatedLine,
|
||
column: mapping.generatedColumn
|
||
}
|
||
};
|
||
|
||
if (mapping.source != null) {
|
||
newMapping.source = mapping.source;
|
||
if (sourceRoot != null) {
|
||
newMapping.source = util.relative(sourceRoot, newMapping.source);
|
||
}
|
||
|
||
newMapping.original = {
|
||
line: mapping.originalLine,
|
||
column: mapping.originalColumn
|
||
};
|
||
|
||
if (mapping.name != null) {
|
||
newMapping.name = mapping.name;
|
||
}
|
||
}
|
||
|
||
generator.addMapping(newMapping);
|
||
});
|
||
aSourceMapConsumer.sources.forEach(function (sourceFile) {
|
||
var content = aSourceMapConsumer.sourceContentFor(sourceFile);
|
||
if (content != null) {
|
||
generator.setSourceContent(sourceFile, content);
|
||
}
|
||
});
|
||
return generator;
|
||
};
|
||
|
||
/**
|
||
* Add a single mapping from original source line and column to the generated
|
||
* source's line and column for this source map being created. The mapping
|
||
* object should have the following properties:
|
||
*
|
||
* - generated: An object with the generated line and column positions.
|
||
* - original: An object with the original line and column positions.
|
||
* - source: The original source file (relative to the sourceRoot).
|
||
* - name: An optional original token name for this mapping.
|
||
*/
|
||
SourceMapGenerator.prototype.addMapping =
|
||
function SourceMapGenerator_addMapping(aArgs) {
|
||
var generated = util.getArg(aArgs, 'generated');
|
||
var original = util.getArg(aArgs, 'original', null);
|
||
var source = util.getArg(aArgs, 'source', null);
|
||
var name = util.getArg(aArgs, 'name', null);
|
||
|
||
if (!this._skipValidation) {
|
||
this._validateMapping(generated, original, source, name);
|
||
}
|
||
|
||
if (source != null) {
|
||
source = String(source);
|
||
if (!this._sources.has(source)) {
|
||
this._sources.add(source);
|
||
}
|
||
}
|
||
|
||
if (name != null) {
|
||
name = String(name);
|
||
if (!this._names.has(name)) {
|
||
this._names.add(name);
|
||
}
|
||
}
|
||
|
||
this._mappings.add({
|
||
generatedLine: generated.line,
|
||
generatedColumn: generated.column,
|
||
originalLine: original != null && original.line,
|
||
originalColumn: original != null && original.column,
|
||
source: source,
|
||
name: name
|
||
});
|
||
};
|
||
|
||
/**
|
||
* Set the source content for a source file.
|
||
*/
|
||
SourceMapGenerator.prototype.setSourceContent =
|
||
function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
|
||
var source = aSourceFile;
|
||
if (this._sourceRoot != null) {
|
||
source = util.relative(this._sourceRoot, source);
|
||
}
|
||
|
||
if (aSourceContent != null) {
|
||
// Add the source content to the _sourcesContents map.
|
||
// Create a new _sourcesContents map if the property is null.
|
||
if (!this._sourcesContents) {
|
||
this._sourcesContents = Object.create(null);
|
||
}
|
||
this._sourcesContents[util.toSetString(source)] = aSourceContent;
|
||
} else if (this._sourcesContents) {
|
||
// Remove the source file from the _sourcesContents map.
|
||
// If the _sourcesContents map is empty, set the property to null.
|
||
delete this._sourcesContents[util.toSetString(source)];
|
||
if (Object.keys(this._sourcesContents).length === 0) {
|
||
this._sourcesContents = null;
|
||
}
|
||
}
|
||
};
|
||
|
||
/**
|
||
* Applies the mappings of a sub-source-map for a specific source file to the
|
||
* source map being generated. Each mapping to the supplied source file is
|
||
* rewritten using the supplied source map. Note: The resolution for the
|
||
* resulting mappings is the minimium of this map and the supplied map.
|
||
*
|
||
* @param aSourceMapConsumer The source map to be applied.
|
||
* @param aSourceFile Optional. The filename of the source file.
|
||
* If omitted, SourceMapConsumer's file property will be used.
|
||
* @param aSourceMapPath Optional. The dirname of the path to the source map
|
||
* to be applied. If relative, it is relative to the SourceMapConsumer.
|
||
* This parameter is needed when the two source maps aren't in the same
|
||
* directory, and the source map to be applied contains relative source
|
||
* paths. If so, those relative source paths need to be rewritten
|
||
* relative to the SourceMapGenerator.
|
||
*/
|
||
SourceMapGenerator.prototype.applySourceMap =
|
||
function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
|
||
var sourceFile = aSourceFile;
|
||
// If aSourceFile is omitted, we will use the file property of the SourceMap
|
||
if (aSourceFile == null) {
|
||
if (aSourceMapConsumer.file == null) {
|
||
throw new Error(
|
||
'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
|
||
'or the source map\'s "file" property. Both were omitted.'
|
||
);
|
||
}
|
||
sourceFile = aSourceMapConsumer.file;
|
||
}
|
||
var sourceRoot = this._sourceRoot;
|
||
// Make "sourceFile" relative if an absolute Url is passed.
|
||
if (sourceRoot != null) {
|
||
sourceFile = util.relative(sourceRoot, sourceFile);
|
||
}
|
||
// Applying the SourceMap can add and remove items from the sources and
|
||
// the names array.
|
||
var newSources = new ArraySet();
|
||
var newNames = new ArraySet();
|
||
|
||
// Find mappings for the "sourceFile"
|
||
this._mappings.unsortedForEach(function (mapping) {
|
||
if (mapping.source === sourceFile && mapping.originalLine != null) {
|
||
// Check if it can be mapped by the source map, then update the mapping.
|
||
var original = aSourceMapConsumer.originalPositionFor({
|
||
line: mapping.originalLine,
|
||
column: mapping.originalColumn
|
||
});
|
||
if (original.source != null) {
|
||
// Copy mapping
|
||
mapping.source = original.source;
|
||
if (aSourceMapPath != null) {
|
||
mapping.source = util.join(aSourceMapPath, mapping.source)
|
||
}
|
||
if (sourceRoot != null) {
|
||
mapping.source = util.relative(sourceRoot, mapping.source);
|
||
}
|
||
mapping.originalLine = original.line;
|
||
mapping.originalColumn = original.column;
|
||
if (original.name != null) {
|
||
mapping.name = original.name;
|
||
}
|
||
}
|
||
}
|
||
|
||
var source = mapping.source;
|
||
if (source != null && !newSources.has(source)) {
|
||
newSources.add(source);
|
||
}
|
||
|
||
var name = mapping.name;
|
||
if (name != null && !newNames.has(name)) {
|
||
newNames.add(name);
|
||
}
|
||
|
||
}, this);
|
||
this._sources = newSources;
|
||
this._names = newNames;
|
||
|
||
// Copy sourcesContents of applied map.
|
||
aSourceMapConsumer.sources.forEach(function (sourceFile) {
|
||
var content = aSourceMapConsumer.sourceContentFor(sourceFile);
|
||
if (content != null) {
|
||
if (aSourceMapPath != null) {
|
||
sourceFile = util.join(aSourceMapPath, sourceFile);
|
||
}
|
||
if (sourceRoot != null) {
|
||
sourceFile = util.relative(sourceRoot, sourceFile);
|
||
}
|
||
this.setSourceContent(sourceFile, content);
|
||
}
|
||
}, this);
|
||
};
|
||
|
||
/**
|
||
* A mapping can have one of the three levels of data:
|
||
*
|
||
* 1. Just the generated position.
|
||
* 2. The Generated position, original position, and original source.
|
||
* 3. Generated and original position, original source, as well as a name
|
||
* token.
|
||
*
|
||
* To maintain consistency, we validate that any new mapping being added falls
|
||
* in to one of these categories.
|
||
*/
|
||
SourceMapGenerator.prototype._validateMapping =
|
||
function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
|
||
aName) {
|
||
// When aOriginal is truthy but has empty values for .line and .column,
|
||
// it is most likely a programmer error. In this case we throw a very
|
||
// specific error message to try to guide them the right way.
|
||
// For example: https://github.com/Polymer/polymer-bundler/pull/519
|
||
if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') {
|
||
throw new Error(
|
||
'original.line and original.column are not numbers -- you probably meant to omit ' +
|
||
'the original mapping entirely and only map the generated position. If so, pass ' +
|
||
'null for the original mapping instead of an object with empty or null values.'
|
||
);
|
||
}
|
||
|
||
if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
|
||
&& aGenerated.line > 0 && aGenerated.column >= 0
|
||
&& !aOriginal && !aSource && !aName) {
|
||
// Case 1.
|
||
return;
|
||
}
|
||
else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
|
||
&& aOriginal && 'line' in aOriginal && 'column' in aOriginal
|
||
&& aGenerated.line > 0 && aGenerated.column >= 0
|
||
&& aOriginal.line > 0 && aOriginal.column >= 0
|
||
&& aSource) {
|
||
// Cases 2 and 3.
|
||
return;
|
||
}
|
||
else {
|
||
throw new Error('Invalid mapping: ' + JSON.stringify({
|
||
generated: aGenerated,
|
||
source: aSource,
|
||
original: aOriginal,
|
||
name: aName
|
||
}));
|
||
}
|
||
};
|
||
|
||
/**
|
||
* Serialize the accumulated mappings in to the stream of base 64 VLQs
|
||
* specified by the source map format.
|
||
*/
|
||
SourceMapGenerator.prototype._serializeMappings =
|
||
function SourceMapGenerator_serializeMappings() {
|
||
var previousGeneratedColumn = 0;
|
||
var previousGeneratedLine = 1;
|
||
var previousOriginalColumn = 0;
|
||
var previousOriginalLine = 0;
|
||
var previousName = 0;
|
||
var previousSource = 0;
|
||
var result = '';
|
||
var next;
|
||
var mapping;
|
||
var nameIdx;
|
||
var sourceIdx;
|
||
|
||
var mappings = this._mappings.toArray();
|
||
for (var i = 0, len = mappings.length; i < len; i++) {
|
||
mapping = mappings[i];
|
||
next = ''
|
||
|
||
if (mapping.generatedLine !== previousGeneratedLine) {
|
||
previousGeneratedColumn = 0;
|
||
while (mapping.generatedLine !== previousGeneratedLine) {
|
||
next += ';';
|
||
previousGeneratedLine++;
|
||
}
|
||
}
|
||
else {
|
||
if (i > 0) {
|
||
if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
|
||
continue;
|
||
}
|
||
next += ',';
|
||
}
|
||
}
|
||
|
||
next += base64VLQ.encode(mapping.generatedColumn
|
||
- previousGeneratedColumn);
|
||
previousGeneratedColumn = mapping.generatedColumn;
|
||
|
||
if (mapping.source != null) {
|
||
sourceIdx = this._sources.indexOf(mapping.source);
|
||
next += base64VLQ.encode(sourceIdx - previousSource);
|
||
previousSource = sourceIdx;
|
||
|
||
// lines are stored 0-based in SourceMap spec version 3
|
||
next += base64VLQ.encode(mapping.originalLine - 1
|
||
- previousOriginalLine);
|
||
previousOriginalLine = mapping.originalLine - 1;
|
||
|
||
next += base64VLQ.encode(mapping.originalColumn
|
||
- previousOriginalColumn);
|
||
previousOriginalColumn = mapping.originalColumn;
|
||
|
||
if (mapping.name != null) {
|
||
nameIdx = this._names.indexOf(mapping.name);
|
||
next += base64VLQ.encode(nameIdx - previousName);
|
||
previousName = nameIdx;
|
||
}
|
||
}
|
||
|
||
result += next;
|
||
}
|
||
|
||
return result;
|
||
};
|
||
|
||
SourceMapGenerator.prototype._generateSourcesContent =
|
||
function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
|
||
return aSources.map(function (source) {
|
||
if (!this._sourcesContents) {
|
||
return null;
|
||
}
|
||
if (aSourceRoot != null) {
|
||
source = util.relative(aSourceRoot, source);
|
||
}
|
||
var key = util.toSetString(source);
|
||
return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)
|
||
? this._sourcesContents[key]
|
||
: null;
|
||
}, this);
|
||
};
|
||
|
||
/**
|
||
* Externalize the source map.
|
||
*/
|
||
SourceMapGenerator.prototype.toJSON =
|
||
function SourceMapGenerator_toJSON() {
|
||
var map = {
|
||
version: this._version,
|
||
sources: this._sources.toArray(),
|
||
names: this._names.toArray(),
|
||
mappings: this._serializeMappings()
|
||
};
|
||
if (this._file != null) {
|
||
map.file = this._file;
|
||
}
|
||
if (this._sourceRoot != null) {
|
||
map.sourceRoot = this._sourceRoot;
|
||
}
|
||
if (this._sourcesContents) {
|
||
map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
|
||
}
|
||
|
||
return map;
|
||
};
|
||
|
||
/**
|
||
* Render the source map being generated to a string.
|
||
*/
|
||
SourceMapGenerator.prototype.toString =
|
||
function SourceMapGenerator_toString() {
|
||
return JSON.stringify(this.toJSON());
|
||
};
|
||
|
||
exports.SourceMapGenerator = SourceMapGenerator;
|
||
|
||
|
||
/***/ }),
|
||
/* 33 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
/* Copyright 2011 Mozilla Foundation and contributors
|
||
* Licensed under the New BSD license. See LICENSE or:
|
||
* http://opensource.org/licenses/BSD-3-Clause
|
||
*
|
||
* Based on the Base 64 VLQ implementation in Closure Compiler:
|
||
* https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
|
||
*
|
||
* Copyright 2011 The Closure Compiler Authors. All rights reserved.
|
||
* Redistribution and use in source and binary forms, with or without
|
||
* modification, are permitted provided that the following conditions are
|
||
* met:
|
||
*
|
||
* * Redistributions of source code must retain the above copyright
|
||
* notice, this list of conditions and the following disclaimer.
|
||
* * Redistributions in binary form must reproduce the above
|
||
* copyright notice, this list of conditions and the following
|
||
* disclaimer in the documentation and/or other materials provided
|
||
* with the distribution.
|
||
* * Neither the name of Google Inc. nor the names of its
|
||
* contributors may be used to endorse or promote products derived
|
||
* from this software without specific prior written permission.
|
||
*
|
||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||
*/
|
||
|
||
var base64 = __webpack_require__(89);
|
||
|
||
// A single base 64 digit can contain 6 bits of data. For the base 64 variable
|
||
// length quantities we use in the source map spec, the first bit is the sign,
|
||
// the next four bits are the actual value, and the 6th bit is the
|
||
// continuation bit. The continuation bit tells us whether there are more
|
||
// digits in this value following this digit.
|
||
//
|
||
// Continuation
|
||
// | Sign
|
||
// | |
|
||
// V V
|
||
// 101011
|
||
|
||
var VLQ_BASE_SHIFT = 5;
|
||
|
||
// binary: 100000
|
||
var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
|
||
|
||
// binary: 011111
|
||
var VLQ_BASE_MASK = VLQ_BASE - 1;
|
||
|
||
// binary: 100000
|
||
var VLQ_CONTINUATION_BIT = VLQ_BASE;
|
||
|
||
/**
|
||
* Converts from a two-complement value to a value where the sign bit is
|
||
* placed in the least significant bit. For example, as decimals:
|
||
* 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
|
||
* 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
|
||
*/
|
||
function toVLQSigned(aValue) {
|
||
return aValue < 0
|
||
? ((-aValue) << 1) + 1
|
||
: (aValue << 1) + 0;
|
||
}
|
||
|
||
/**
|
||
* Converts to a two-complement value from a value where the sign bit is
|
||
* placed in the least significant bit. For example, as decimals:
|
||
* 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
|
||
* 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
|
||
*/
|
||
function fromVLQSigned(aValue) {
|
||
var isNegative = (aValue & 1) === 1;
|
||
var shifted = aValue >> 1;
|
||
return isNegative
|
||
? -shifted
|
||
: shifted;
|
||
}
|
||
|
||
/**
|
||
* Returns the base 64 VLQ encoded value.
|
||
*/
|
||
exports.encode = function base64VLQ_encode(aValue) {
|
||
var encoded = "";
|
||
var digit;
|
||
|
||
var vlq = toVLQSigned(aValue);
|
||
|
||
do {
|
||
digit = vlq & VLQ_BASE_MASK;
|
||
vlq >>>= VLQ_BASE_SHIFT;
|
||
if (vlq > 0) {
|
||
// There are still more digits in this value, so we must make sure the
|
||
// continuation bit is marked.
|
||
digit |= VLQ_CONTINUATION_BIT;
|
||
}
|
||
encoded += base64.encode(digit);
|
||
} while (vlq > 0);
|
||
|
||
return encoded;
|
||
};
|
||
|
||
/**
|
||
* Decodes the next base 64 VLQ value from the given string and returns the
|
||
* value and the rest of the string via the out parameter.
|
||
*/
|
||
exports.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {
|
||
var strLen = aStr.length;
|
||
var result = 0;
|
||
var shift = 0;
|
||
var continuation, digit;
|
||
|
||
do {
|
||
if (aIndex >= strLen) {
|
||
throw new Error("Expected more digits in base 64 VLQ value.");
|
||
}
|
||
|
||
digit = base64.decode(aStr.charCodeAt(aIndex++));
|
||
if (digit === -1) {
|
||
throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1));
|
||
}
|
||
|
||
continuation = !!(digit & VLQ_CONTINUATION_BIT);
|
||
digit &= VLQ_BASE_MASK;
|
||
result = result + (digit << shift);
|
||
shift += VLQ_BASE_SHIFT;
|
||
} while (continuation);
|
||
|
||
aOutParam.value = fromVLQSigned(result);
|
||
aOutParam.rest = aIndex;
|
||
};
|
||
|
||
|
||
/***/ }),
|
||
/* 34 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
/* Copyright 2011 Mozilla Foundation and contributors
|
||
* Licensed under the New BSD license. See LICENSE or:
|
||
* http://opensource.org/licenses/BSD-3-Clause
|
||
*/
|
||
|
||
var util = __webpack_require__(12);
|
||
var has = Object.prototype.hasOwnProperty;
|
||
var hasNativeMap = typeof Map !== "undefined";
|
||
|
||
/**
|
||
* A data structure which is a combination of an array and a set. Adding a new
|
||
* member is O(1), testing for membership is O(1), and finding the index of an
|
||
* element is O(1). Removing elements from the set is not supported. Only
|
||
* strings are supported for membership.
|
||
*/
|
||
function ArraySet() {
|
||
this._array = [];
|
||
this._set = hasNativeMap ? new Map() : Object.create(null);
|
||
}
|
||
|
||
/**
|
||
* Static method for creating ArraySet instances from an existing array.
|
||
*/
|
||
ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
|
||
var set = new ArraySet();
|
||
for (var i = 0, len = aArray.length; i < len; i++) {
|
||
set.add(aArray[i], aAllowDuplicates);
|
||
}
|
||
return set;
|
||
};
|
||
|
||
/**
|
||
* Return how many unique items are in this ArraySet. If duplicates have been
|
||
* added, than those do not count towards the size.
|
||
*
|
||
* @returns Number
|
||
*/
|
||
ArraySet.prototype.size = function ArraySet_size() {
|
||
return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length;
|
||
};
|
||
|
||
/**
|
||
* Add the given string to this set.
|
||
*
|
||
* @param String aStr
|
||
*/
|
||
ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
|
||
var sStr = hasNativeMap ? aStr : util.toSetString(aStr);
|
||
var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr);
|
||
var idx = this._array.length;
|
||
if (!isDuplicate || aAllowDuplicates) {
|
||
this._array.push(aStr);
|
||
}
|
||
if (!isDuplicate) {
|
||
if (hasNativeMap) {
|
||
this._set.set(aStr, idx);
|
||
} else {
|
||
this._set[sStr] = idx;
|
||
}
|
||
}
|
||
};
|
||
|
||
/**
|
||
* Is the given string a member of this set?
|
||
*
|
||
* @param String aStr
|
||
*/
|
||
ArraySet.prototype.has = function ArraySet_has(aStr) {
|
||
if (hasNativeMap) {
|
||
return this._set.has(aStr);
|
||
} else {
|
||
var sStr = util.toSetString(aStr);
|
||
return has.call(this._set, sStr);
|
||
}
|
||
};
|
||
|
||
/**
|
||
* What is the index of the given string in the array?
|
||
*
|
||
* @param String aStr
|
||
*/
|
||
ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
|
||
if (hasNativeMap) {
|
||
var idx = this._set.get(aStr);
|
||
if (idx >= 0) {
|
||
return idx;
|
||
}
|
||
} else {
|
||
var sStr = util.toSetString(aStr);
|
||
if (has.call(this._set, sStr)) {
|
||
return this._set[sStr];
|
||
}
|
||
}
|
||
|
||
throw new Error('"' + aStr + '" is not in the set.');
|
||
};
|
||
|
||
/**
|
||
* What is the element at the given index?
|
||
*
|
||
* @param Number aIdx
|
||
*/
|
||
ArraySet.prototype.at = function ArraySet_at(aIdx) {
|
||
if (aIdx >= 0 && aIdx < this._array.length) {
|
||
return this._array[aIdx];
|
||
}
|
||
throw new Error('No element indexed by ' + aIdx);
|
||
};
|
||
|
||
/**
|
||
* Returns the array representation of this set (which has the proper indices
|
||
* indicated by indexOf). Note that this is a copy of the internal array used
|
||
* for storing the members so that no one can mess with internal state.
|
||
*/
|
||
ArraySet.prototype.toArray = function ArraySet_toArray() {
|
||
return this._array.slice();
|
||
};
|
||
|
||
exports.ArraySet = ArraySet;
|
||
|
||
|
||
/***/ }),
|
||
/* 35 */,
|
||
/* 36 */,
|
||
/* 37 */,
|
||
/* 38 */,
|
||
/* 39 */,
|
||
/* 40 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var listCacheClear = __webpack_require__(207),
|
||
listCacheDelete = __webpack_require__(208),
|
||
listCacheGet = __webpack_require__(209),
|
||
listCacheHas = __webpack_require__(210),
|
||
listCacheSet = __webpack_require__(211);
|
||
|
||
/**
|
||
* Creates an list cache object.
|
||
*
|
||
* @private
|
||
* @constructor
|
||
* @param {Array} [entries] The key-value pairs to cache.
|
||
*/
|
||
function ListCache(entries) {
|
||
var index = -1,
|
||
length = entries == null ? 0 : entries.length;
|
||
|
||
this.clear();
|
||
while (++index < length) {
|
||
var entry = entries[index];
|
||
this.set(entry[0], entry[1]);
|
||
}
|
||
}
|
||
|
||
// Add methods to `ListCache`.
|
||
ListCache.prototype.clear = listCacheClear;
|
||
ListCache.prototype['delete'] = listCacheDelete;
|
||
ListCache.prototype.get = listCacheGet;
|
||
ListCache.prototype.has = listCacheHas;
|
||
ListCache.prototype.set = listCacheSet;
|
||
|
||
module.exports = ListCache;
|
||
|
||
|
||
/***/ }),
|
||
/* 41 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var eq = __webpack_require__(42);
|
||
|
||
/**
|
||
* Gets the index at which the `key` is found in `array` of key-value pairs.
|
||
*
|
||
* @private
|
||
* @param {Array} array The array to inspect.
|
||
* @param {*} key The key to search for.
|
||
* @returns {number} Returns the index of the matched value, else `-1`.
|
||
*/
|
||
function assocIndexOf(array, key) {
|
||
var length = array.length;
|
||
while (length--) {
|
||
if (eq(array[length][0], key)) {
|
||
return length;
|
||
}
|
||
}
|
||
return -1;
|
||
}
|
||
|
||
module.exports = assocIndexOf;
|
||
|
||
|
||
/***/ }),
|
||
/* 42 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* Performs a
|
||
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
||
* comparison between two values to determine if they are equivalent.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 4.0.0
|
||
* @category Lang
|
||
* @param {*} value The value to compare.
|
||
* @param {*} other The other value to compare.
|
||
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
||
* @example
|
||
*
|
||
* var object = { 'a': 1 };
|
||
* var other = { 'a': 1 };
|
||
*
|
||
* _.eq(object, object);
|
||
* // => true
|
||
*
|
||
* _.eq(object, other);
|
||
* // => false
|
||
*
|
||
* _.eq('a', 'a');
|
||
* // => true
|
||
*
|
||
* _.eq('a', Object('a'));
|
||
* // => false
|
||
*
|
||
* _.eq(NaN, NaN);
|
||
* // => true
|
||
*/
|
||
function eq(value, other) {
|
||
return value === other || (value !== value && other !== other);
|
||
}
|
||
|
||
module.exports = eq;
|
||
|
||
|
||
/***/ }),
|
||
/* 43 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
/* WEBPACK VAR INJECTION */(function(global) {/** Detect free variable `global` from Node.js. */
|
||
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
|
||
|
||
module.exports = freeGlobal;
|
||
|
||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(15)))
|
||
|
||
/***/ }),
|
||
/* 44 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var getNative = __webpack_require__(26);
|
||
|
||
/* Built-in method references that are verified to be native. */
|
||
var nativeCreate = getNative(Object, 'create');
|
||
|
||
module.exports = nativeCreate;
|
||
|
||
|
||
/***/ }),
|
||
/* 45 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var isKeyable = __webpack_require__(229);
|
||
|
||
/**
|
||
* Gets the data for `map`.
|
||
*
|
||
* @private
|
||
* @param {Object} map The map to query.
|
||
* @param {string} key The reference key.
|
||
* @returns {*} Returns the map data.
|
||
*/
|
||
function getMapData(map, key) {
|
||
var data = map.__data__;
|
||
return isKeyable(key)
|
||
? data[typeof key == 'string' ? 'string' : 'hash']
|
||
: data.map;
|
||
}
|
||
|
||
module.exports = getMapData;
|
||
|
||
|
||
/***/ }),
|
||
/* 46 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var assignValue = __webpack_require__(122),
|
||
baseAssignValue = __webpack_require__(123);
|
||
|
||
/**
|
||
* Copies properties of `source` to `object`.
|
||
*
|
||
* @private
|
||
* @param {Object} source The object to copy properties from.
|
||
* @param {Array} props The property identifiers to copy.
|
||
* @param {Object} [object={}] The object to copy properties to.
|
||
* @param {Function} [customizer] The function to customize copied values.
|
||
* @returns {Object} Returns `object`.
|
||
*/
|
||
function copyObject(source, props, object, customizer) {
|
||
var isNew = !object;
|
||
object || (object = {});
|
||
|
||
var index = -1,
|
||
length = props.length;
|
||
|
||
while (++index < length) {
|
||
var key = props[index];
|
||
|
||
var newValue = customizer
|
||
? customizer(object[key], source[key], key, object, source)
|
||
: undefined;
|
||
|
||
if (newValue === undefined) {
|
||
newValue = source[key];
|
||
}
|
||
if (isNew) {
|
||
baseAssignValue(object, key, newValue);
|
||
} else {
|
||
assignValue(object, key, newValue);
|
||
}
|
||
}
|
||
return object;
|
||
}
|
||
|
||
module.exports = copyObject;
|
||
|
||
|
||
/***/ }),
|
||
/* 47 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var arrayLikeKeys = __webpack_require__(124),
|
||
baseKeys = __webpack_require__(125),
|
||
isArrayLike = __webpack_require__(52);
|
||
|
||
/**
|
||
* Creates an array of the own enumerable property names of `object`.
|
||
*
|
||
* **Note:** Non-object values are coerced to objects. See the
|
||
* [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
|
||
* for more details.
|
||
*
|
||
* @static
|
||
* @since 0.1.0
|
||
* @memberOf _
|
||
* @category Object
|
||
* @param {Object} object The object to query.
|
||
* @returns {Array} Returns the array of property names.
|
||
* @example
|
||
*
|
||
* function Foo() {
|
||
* this.a = 1;
|
||
* this.b = 2;
|
||
* }
|
||
*
|
||
* Foo.prototype.c = 3;
|
||
*
|
||
* _.keys(new Foo);
|
||
* // => ['a', 'b'] (iteration order is not guaranteed)
|
||
*
|
||
* _.keys('hi');
|
||
* // => ['0', '1']
|
||
*/
|
||
function keys(object) {
|
||
return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
|
||
}
|
||
|
||
module.exports = keys;
|
||
|
||
|
||
/***/ }),
|
||
/* 48 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
/* WEBPACK VAR INJECTION */(function(module) {var root = __webpack_require__(8),
|
||
stubFalse = __webpack_require__(238);
|
||
|
||
/** Detect free variable `exports`. */
|
||
var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
|
||
|
||
/** Detect free variable `module`. */
|
||
var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
|
||
|
||
/** Detect the popular CommonJS extension `module.exports`. */
|
||
var moduleExports = freeModule && freeModule.exports === freeExports;
|
||
|
||
/** Built-in value references. */
|
||
var Buffer = moduleExports ? root.Buffer : undefined;
|
||
|
||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||
var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
|
||
|
||
/**
|
||
* Checks if `value` is a buffer.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 4.3.0
|
||
* @category Lang
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
|
||
* @example
|
||
*
|
||
* _.isBuffer(new Buffer(2));
|
||
* // => true
|
||
*
|
||
* _.isBuffer(new Uint8Array(2));
|
||
* // => false
|
||
*/
|
||
var isBuffer = nativeIsBuffer || stubFalse;
|
||
|
||
module.exports = isBuffer;
|
||
|
||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(22)(module)))
|
||
|
||
/***/ }),
|
||
/* 49 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* The base implementation of `_.unary` without support for storing metadata.
|
||
*
|
||
* @private
|
||
* @param {Function} func The function to cap arguments for.
|
||
* @returns {Function} Returns the new capped function.
|
||
*/
|
||
function baseUnary(func) {
|
||
return function(value) {
|
||
return func(value);
|
||
};
|
||
}
|
||
|
||
module.exports = baseUnary;
|
||
|
||
|
||
/***/ }),
|
||
/* 50 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
/* WEBPACK VAR INJECTION */(function(module) {var freeGlobal = __webpack_require__(43);
|
||
|
||
/** Detect free variable `exports`. */
|
||
var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
|
||
|
||
/** Detect free variable `module`. */
|
||
var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
|
||
|
||
/** Detect the popular CommonJS extension `module.exports`. */
|
||
var moduleExports = freeModule && freeModule.exports === freeExports;
|
||
|
||
/** Detect free variable `process` from Node.js. */
|
||
var freeProcess = moduleExports && freeGlobal.process;
|
||
|
||
/** Used to access faster Node.js helpers. */
|
||
var nodeUtil = (function() {
|
||
try {
|
||
// Use `util.types` for Node.js 10+.
|
||
var types = freeModule && freeModule.require && freeModule.require('util').types;
|
||
|
||
if (types) {
|
||
return types;
|
||
}
|
||
|
||
// Legacy `process.binding('util')` for Node.js < 10.
|
||
return freeProcess && freeProcess.binding && freeProcess.binding('util');
|
||
} catch (e) {}
|
||
}());
|
||
|
||
module.exports = nodeUtil;
|
||
|
||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(22)(module)))
|
||
|
||
/***/ }),
|
||
/* 51 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/** Used for built-in method references. */
|
||
var objectProto = Object.prototype;
|
||
|
||
/**
|
||
* Checks if `value` is likely a prototype object.
|
||
*
|
||
* @private
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
|
||
*/
|
||
function isPrototype(value) {
|
||
var Ctor = value && value.constructor,
|
||
proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
|
||
|
||
return value === proto;
|
||
}
|
||
|
||
module.exports = isPrototype;
|
||
|
||
|
||
/***/ }),
|
||
/* 52 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var isFunction = __webpack_require__(120),
|
||
isLength = __webpack_require__(77);
|
||
|
||
/**
|
||
* Checks if `value` is array-like. A value is considered array-like if it's
|
||
* not a function and has a `value.length` that's an integer greater than or
|
||
* equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 4.0.0
|
||
* @category Lang
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
|
||
* @example
|
||
*
|
||
* _.isArrayLike([1, 2, 3]);
|
||
* // => true
|
||
*
|
||
* _.isArrayLike(document.body.children);
|
||
* // => true
|
||
*
|
||
* _.isArrayLike('abc');
|
||
* // => true
|
||
*
|
||
* _.isArrayLike(_.noop);
|
||
* // => false
|
||
*/
|
||
function isArrayLike(value) {
|
||
return value != null && isLength(value.length) && !isFunction(value);
|
||
}
|
||
|
||
module.exports = isArrayLike;
|
||
|
||
|
||
/***/ }),
|
||
/* 53 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = getBindingIdentifiers;
|
||
|
||
var _generated = __webpack_require__(5);
|
||
|
||
function getBindingIdentifiers(node, duplicates, outerOnly) {
|
||
let search = [].concat(node);
|
||
const ids = Object.create(null);
|
||
|
||
while (search.length) {
|
||
const id = search.shift();
|
||
if (!id) continue;
|
||
const keys = getBindingIdentifiers.keys[id.type];
|
||
|
||
if ((0, _generated.isIdentifier)(id)) {
|
||
if (duplicates) {
|
||
const _ids = ids[id.name] = ids[id.name] || [];
|
||
|
||
_ids.push(id);
|
||
} else {
|
||
ids[id.name] = id;
|
||
}
|
||
|
||
continue;
|
||
}
|
||
|
||
if ((0, _generated.isExportDeclaration)(id)) {
|
||
if ((0, _generated.isDeclaration)(id.declaration)) {
|
||
search.push(id.declaration);
|
||
}
|
||
|
||
continue;
|
||
}
|
||
|
||
if (outerOnly) {
|
||
if ((0, _generated.isFunctionDeclaration)(id)) {
|
||
search.push(id.id);
|
||
continue;
|
||
}
|
||
|
||
if ((0, _generated.isFunctionExpression)(id)) {
|
||
continue;
|
||
}
|
||
}
|
||
|
||
if (keys) {
|
||
for (let i = 0; i < keys.length; i++) {
|
||
const key = keys[i];
|
||
|
||
if (id[key]) {
|
||
search = search.concat(id[key]);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
return ids;
|
||
}
|
||
|
||
getBindingIdentifiers.keys = {
|
||
DeclareClass: ["id"],
|
||
DeclareFunction: ["id"],
|
||
DeclareModule: ["id"],
|
||
DeclareVariable: ["id"],
|
||
DeclareInterface: ["id"],
|
||
DeclareTypeAlias: ["id"],
|
||
DeclareOpaqueType: ["id"],
|
||
InterfaceDeclaration: ["id"],
|
||
TypeAlias: ["id"],
|
||
OpaqueType: ["id"],
|
||
CatchClause: ["param"],
|
||
LabeledStatement: ["label"],
|
||
UnaryExpression: ["argument"],
|
||
AssignmentExpression: ["left"],
|
||
ImportSpecifier: ["local"],
|
||
ImportNamespaceSpecifier: ["local"],
|
||
ImportDefaultSpecifier: ["local"],
|
||
ImportDeclaration: ["specifiers"],
|
||
ExportSpecifier: ["exported"],
|
||
ExportNamespaceSpecifier: ["exported"],
|
||
ExportDefaultSpecifier: ["exported"],
|
||
FunctionDeclaration: ["id", "params"],
|
||
FunctionExpression: ["id", "params"],
|
||
ArrowFunctionExpression: ["params"],
|
||
ObjectMethod: ["params"],
|
||
ClassMethod: ["params"],
|
||
ForInStatement: ["left"],
|
||
ForOfStatement: ["left"],
|
||
ClassDeclaration: ["id"],
|
||
ClassExpression: ["id"],
|
||
RestElement: ["argument"],
|
||
UpdateExpression: ["argument"],
|
||
ObjectProperty: ["value"],
|
||
AssignmentPattern: ["left"],
|
||
ArrayPattern: ["elements"],
|
||
ObjectPattern: ["properties"],
|
||
VariableDeclaration: ["declarations"],
|
||
VariableDeclarator: ["id"]
|
||
};
|
||
|
||
/***/ }),
|
||
/* 54 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.isFunction = isFunction;
|
||
exports.isAwaitExpression = isAwaitExpression;
|
||
exports.isYieldExpression = isYieldExpression;
|
||
exports.isObjectShorthand = isObjectShorthand;
|
||
exports.getObjectExpressionValue = getObjectExpressionValue;
|
||
exports.getCode = getCode;
|
||
exports.getComments = getComments;
|
||
exports.getSpecifiers = getSpecifiers;
|
||
exports.isComputedExpression = isComputedExpression;
|
||
exports.getMemberExpression = getMemberExpression;
|
||
exports.getVariables = getVariables;
|
||
exports.getPatternIdentifiers = getPatternIdentifiers;
|
||
exports.isTopLevel = isTopLevel;
|
||
exports.nodeLocationKey = nodeLocationKey;
|
||
exports.getFunctionParameterNames = getFunctionParameterNames;
|
||
|
||
var t = _interopRequireWildcard(__webpack_require__(3));
|
||
|
||
var _generator = _interopRequireDefault(__webpack_require__(55));
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||
|
||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||
function isFunction(node) {
|
||
return t.isFunction(node) || t.isArrowFunctionExpression(node) || t.isObjectMethod(node) || t.isClassMethod(node);
|
||
}
|
||
|
||
function isAwaitExpression(path) {
|
||
const {
|
||
node,
|
||
parent
|
||
} = path;
|
||
return t.isAwaitExpression(node) || t.isAwaitExpression(parent.init) || t.isAwaitExpression(parent);
|
||
}
|
||
|
||
function isYieldExpression(path) {
|
||
const {
|
||
node,
|
||
parent
|
||
} = path;
|
||
return t.isYieldExpression(node) || t.isYieldExpression(parent.init) || t.isYieldExpression(parent);
|
||
}
|
||
|
||
function isObjectShorthand(parent) {
|
||
return t.isObjectProperty(parent) && parent.value && parent.key.start == parent.value.start && parent.key.loc.identifierName === parent.value.loc.identifierName;
|
||
}
|
||
|
||
function getObjectExpressionValue(node) {
|
||
const {
|
||
value
|
||
} = node;
|
||
|
||
if (t.isIdentifier(value)) {
|
||
return value.name;
|
||
}
|
||
|
||
if (t.isCallExpression(value) || t.isFunctionExpression(value)) {
|
||
return "";
|
||
}
|
||
|
||
const code = (0, _generator.default)(value).code;
|
||
const shouldWrap = t.isObjectExpression(value);
|
||
return shouldWrap ? `(${code})` : code;
|
||
}
|
||
|
||
function getCode(node) {
|
||
return (0, _generator.default)(node).code;
|
||
}
|
||
|
||
function getComments(ast) {
|
||
if (!ast || !ast.comments) {
|
||
return [];
|
||
}
|
||
|
||
return ast.comments.map(comment => ({
|
||
name: comment.location,
|
||
location: comment.loc
|
||
}));
|
||
}
|
||
|
||
function getSpecifiers(specifiers) {
|
||
if (!specifiers) {
|
||
return [];
|
||
}
|
||
|
||
return specifiers.map(specifier => {
|
||
var _specifier$local;
|
||
|
||
return (_specifier$local = specifier.local) === null || _specifier$local === void 0 ? void 0 : _specifier$local.name;
|
||
});
|
||
}
|
||
|
||
function isComputedExpression(expression) {
|
||
return /^\[/m.test(expression);
|
||
}
|
||
|
||
function getMemberExpression(root) {
|
||
function _getMemberExpression(node, expr) {
|
||
if (t.isMemberExpression(node)) {
|
||
expr = [node.property.name].concat(expr);
|
||
return _getMemberExpression(node.object, expr);
|
||
}
|
||
|
||
if (t.isCallExpression(node)) {
|
||
return [];
|
||
}
|
||
|
||
if (t.isThisExpression(node)) {
|
||
return ["this"].concat(expr);
|
||
}
|
||
|
||
return [node.name].concat(expr);
|
||
}
|
||
|
||
const expr = _getMemberExpression(root, []);
|
||
|
||
return expr.join(".");
|
||
}
|
||
|
||
function getVariables(dec) {
|
||
if (!dec.id) {
|
||
return [];
|
||
}
|
||
|
||
if (t.isArrayPattern(dec.id)) {
|
||
if (!dec.id.elements) {
|
||
return [];
|
||
} // NOTE: it's possible that an element is empty or has several variables
|
||
// e.g. const [, a] = arr
|
||
// e.g. const [{a, b }] = 2
|
||
|
||
|
||
return dec.id.elements.filter(element => element).map(element => {
|
||
var _element$argument;
|
||
|
||
return {
|
||
name: t.isAssignmentPattern(element) ? element.left.name : element.name || ((_element$argument = element.argument) === null || _element$argument === void 0 ? void 0 : _element$argument.name),
|
||
location: element.loc
|
||
};
|
||
}).filter(({
|
||
name
|
||
}) => name);
|
||
}
|
||
|
||
return [{
|
||
name: dec.id.name,
|
||
location: dec.loc
|
||
}];
|
||
}
|
||
|
||
function getPatternIdentifiers(pattern) {
|
||
let items = [];
|
||
|
||
if (t.isObjectPattern(pattern)) {
|
||
items = pattern.properties.map(({
|
||
value
|
||
}) => value);
|
||
}
|
||
|
||
if (t.isArrayPattern(pattern)) {
|
||
items = pattern.elements;
|
||
}
|
||
|
||
return getIdentifiers(items);
|
||
}
|
||
|
||
function getIdentifiers(items) {
|
||
let ids = [];
|
||
items.forEach(function (item) {
|
||
if (t.isObjectPattern(item) || t.isArrayPattern(item)) {
|
||
ids = ids.concat(getPatternIdentifiers(item));
|
||
} else if (t.isIdentifier(item)) {
|
||
const {
|
||
start,
|
||
end
|
||
} = item.loc;
|
||
ids.push({
|
||
name: item.name,
|
||
expression: item.name,
|
||
location: {
|
||
start,
|
||
end
|
||
}
|
||
});
|
||
}
|
||
});
|
||
return ids;
|
||
} // Top Level checks the number of "body" nodes in the ancestor chain
|
||
// if the node is top-level, then it shoul only have one body.
|
||
|
||
|
||
function isTopLevel(ancestors) {
|
||
return ancestors.filter(ancestor => ancestor.key == "body").length == 1;
|
||
}
|
||
|
||
function nodeLocationKey(a) {
|
||
const {
|
||
start,
|
||
end
|
||
} = a.location;
|
||
return `${start.line}:${start.column}:${end.line}:${end.column}`;
|
||
}
|
||
|
||
function getFunctionParameterNames(path) {
|
||
if (path.node.params != null) {
|
||
return path.node.params.map(param => {
|
||
if (param.type !== "AssignmentPattern") {
|
||
return param.name;
|
||
} // Parameter with default value
|
||
|
||
|
||
if (param.left.type === "Identifier" && param.right.type === "Identifier") {
|
||
return `${param.left.name} = ${param.right.name}`;
|
||
} else if (param.left.type === "Identifier" && param.right.type === "StringLiteral") {
|
||
return `${param.left.name} = ${param.right.value}`;
|
||
} else if (param.left.type === "Identifier" && param.right.type === "ObjectExpression") {
|
||
return `${param.left.name} = {}`;
|
||
} else if (param.left.type === "Identifier" && param.right.type === "ArrayExpression") {
|
||
return `${param.left.name} = []`;
|
||
} else if (param.left.type === "Identifier" && param.right.type === "NullLiteral") {
|
||
return `${param.left.name} = null`;
|
||
}
|
||
});
|
||
}
|
||
|
||
return [];
|
||
}
|
||
|
||
/***/ }),
|
||
/* 55 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = _default;
|
||
exports.CodeGenerator = void 0;
|
||
|
||
var _sourceMap = _interopRequireDefault(__webpack_require__(325));
|
||
|
||
var _printer = _interopRequireDefault(__webpack_require__(326));
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
class Generator extends _printer.default {
|
||
constructor(ast, opts = {}, code) {
|
||
const format = normalizeOptions(code, opts);
|
||
const map = opts.sourceMaps ? new _sourceMap.default(opts, code) : null;
|
||
super(format, map);
|
||
this.ast = ast;
|
||
}
|
||
|
||
generate() {
|
||
return super.generate(this.ast);
|
||
}
|
||
|
||
}
|
||
|
||
function normalizeOptions(code, opts) {
|
||
const format = {
|
||
auxiliaryCommentBefore: opts.auxiliaryCommentBefore,
|
||
auxiliaryCommentAfter: opts.auxiliaryCommentAfter,
|
||
shouldPrintComment: opts.shouldPrintComment,
|
||
retainLines: opts.retainLines,
|
||
retainFunctionParens: opts.retainFunctionParens,
|
||
comments: opts.comments == null || opts.comments,
|
||
compact: opts.compact,
|
||
minified: opts.minified,
|
||
concise: opts.concise,
|
||
jsonCompatibleStrings: opts.jsonCompatibleStrings,
|
||
indent: {
|
||
adjustMultilineComment: true,
|
||
style: " ",
|
||
base: 0
|
||
},
|
||
decoratorsBeforeExport: !!opts.decoratorsBeforeExport,
|
||
jsescOption: Object.assign({
|
||
quotes: "double",
|
||
wrap: true
|
||
}, opts.jsescOption)
|
||
};
|
||
|
||
if (format.minified) {
|
||
format.compact = true;
|
||
|
||
format.shouldPrintComment = format.shouldPrintComment || (() => format.comments);
|
||
} else {
|
||
format.shouldPrintComment = format.shouldPrintComment || (value => format.comments || value.indexOf("@license") >= 0 || value.indexOf("@preserve") >= 0);
|
||
}
|
||
|
||
if (format.compact === "auto") {
|
||
format.compact = code.length > 500000;
|
||
|
||
if (format.compact) {
|
||
console.error("[BABEL] Note: The code generator has deoptimised the styling of " + `${opts.filename} as it exceeds the max of ${"500KB"}.`);
|
||
}
|
||
}
|
||
|
||
if (format.compact) {
|
||
format.indent.adjustMultilineComment = false;
|
||
}
|
||
|
||
return format;
|
||
}
|
||
|
||
class CodeGenerator {
|
||
constructor(ast, opts, code) {
|
||
this._generator = new Generator(ast, opts, code);
|
||
}
|
||
|
||
generate() {
|
||
return this._generator.generate();
|
||
}
|
||
|
||
}
|
||
|
||
exports.CodeGenerator = CodeGenerator;
|
||
|
||
function _default(ast, opts, code) {
|
||
const gen = new Generator(ast, opts, code);
|
||
return gen.generate();
|
||
}
|
||
|
||
/***/ }),
|
||
/* 56 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var toFinite = __webpack_require__(328);
|
||
|
||
/**
|
||
* Converts `value` to an integer.
|
||
*
|
||
* **Note:** This method is loosely based on
|
||
* [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 4.0.0
|
||
* @category Lang
|
||
* @param {*} value The value to convert.
|
||
* @returns {number} Returns the converted integer.
|
||
* @example
|
||
*
|
||
* _.toInteger(3.2);
|
||
* // => 3
|
||
*
|
||
* _.toInteger(Number.MIN_VALUE);
|
||
* // => 0
|
||
*
|
||
* _.toInteger(Infinity);
|
||
* // => 1.7976931348623157e+308
|
||
*
|
||
* _.toInteger('3.2');
|
||
* // => 3
|
||
*/
|
||
function toInteger(value) {
|
||
var result = toFinite(value),
|
||
remainder = result % 1;
|
||
|
||
return result === result ? (remainder ? result - remainder : result) : 0;
|
||
}
|
||
|
||
module.exports = toInteger;
|
||
|
||
|
||
/***/ }),
|
||
/* 57 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var baseToString = __webpack_require__(95);
|
||
|
||
/**
|
||
* Converts `value` to a string. An empty string is returned for `null`
|
||
* and `undefined` values. The sign of `-0` is preserved.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 4.0.0
|
||
* @category Lang
|
||
* @param {*} value The value to convert.
|
||
* @returns {string} Returns the converted string.
|
||
* @example
|
||
*
|
||
* _.toString(null);
|
||
* // => ''
|
||
*
|
||
* _.toString(-0);
|
||
* // => '-0'
|
||
*
|
||
* _.toString([1, 2, 3]);
|
||
* // => '1,2,3'
|
||
*/
|
||
function toString(value) {
|
||
return value == null ? '' : baseToString(value);
|
||
}
|
||
|
||
module.exports = toString;
|
||
|
||
|
||
/***/ }),
|
||
/* 58 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
/* WEBPACK VAR INJECTION */(function(global) {/*!
|
||
* The buffer module from node.js, for the browser.
|
||
*
|
||
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
|
||
* @license MIT
|
||
*/
|
||
/* eslint-disable no-proto */
|
||
|
||
|
||
|
||
var base64 = __webpack_require__(98)
|
||
var ieee754 = __webpack_require__(99)
|
||
var isArray = __webpack_require__(100)
|
||
|
||
exports.Buffer = Buffer
|
||
exports.SlowBuffer = SlowBuffer
|
||
exports.INSPECT_MAX_BYTES = 50
|
||
|
||
/**
|
||
* If `Buffer.TYPED_ARRAY_SUPPORT`:
|
||
* === true Use Uint8Array implementation (fastest)
|
||
* === false Use Object implementation (most compatible, even IE6)
|
||
*
|
||
* Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
|
||
* Opera 11.6+, iOS 4.2+.
|
||
*
|
||
* Due to various browser bugs, sometimes the Object implementation will be used even
|
||
* when the browser supports typed arrays.
|
||
*
|
||
* Note:
|
||
*
|
||
* - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
|
||
* See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
|
||
*
|
||
* - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
|
||
*
|
||
* - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
|
||
* incorrect length in some situations.
|
||
|
||
* We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
|
||
* get the Object implementation, which is slower but behaves correctly.
|
||
*/
|
||
Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
|
||
? global.TYPED_ARRAY_SUPPORT
|
||
: typedArraySupport()
|
||
|
||
/*
|
||
* Export kMaxLength after typed array support is determined.
|
||
*/
|
||
exports.kMaxLength = kMaxLength()
|
||
|
||
function typedArraySupport () {
|
||
try {
|
||
var arr = new Uint8Array(1)
|
||
arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
|
||
return arr.foo() === 42 && // typed array instances can be augmented
|
||
typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
|
||
arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
|
||
} catch (e) {
|
||
return false
|
||
}
|
||
}
|
||
|
||
function kMaxLength () {
|
||
return Buffer.TYPED_ARRAY_SUPPORT
|
||
? 0x7fffffff
|
||
: 0x3fffffff
|
||
}
|
||
|
||
function createBuffer (that, length) {
|
||
if (kMaxLength() < length) {
|
||
throw new RangeError('Invalid typed array length')
|
||
}
|
||
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
||
// Return an augmented `Uint8Array` instance, for best performance
|
||
that = new Uint8Array(length)
|
||
that.__proto__ = Buffer.prototype
|
||
} else {
|
||
// Fallback: Return an object instance of the Buffer class
|
||
if (that === null) {
|
||
that = new Buffer(length)
|
||
}
|
||
that.length = length
|
||
}
|
||
|
||
return that
|
||
}
|
||
|
||
/**
|
||
* The Buffer constructor returns instances of `Uint8Array` that have their
|
||
* prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
|
||
* `Uint8Array`, so the returned instances will have all the node `Buffer` methods
|
||
* and the `Uint8Array` methods. Square bracket notation works as expected -- it
|
||
* returns a single octet.
|
||
*
|
||
* The `Uint8Array` prototype remains unmodified.
|
||
*/
|
||
|
||
function Buffer (arg, encodingOrOffset, length) {
|
||
if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
|
||
return new Buffer(arg, encodingOrOffset, length)
|
||
}
|
||
|
||
// Common case.
|
||
if (typeof arg === 'number') {
|
||
if (typeof encodingOrOffset === 'string') {
|
||
throw new Error(
|
||
'If encoding is specified then the first argument must be a string'
|
||
)
|
||
}
|
||
return allocUnsafe(this, arg)
|
||
}
|
||
return from(this, arg, encodingOrOffset, length)
|
||
}
|
||
|
||
Buffer.poolSize = 8192 // not used by this implementation
|
||
|
||
// TODO: Legacy, not needed anymore. Remove in next major version.
|
||
Buffer._augment = function (arr) {
|
||
arr.__proto__ = Buffer.prototype
|
||
return arr
|
||
}
|
||
|
||
function from (that, value, encodingOrOffset, length) {
|
||
if (typeof value === 'number') {
|
||
throw new TypeError('"value" argument must not be a number')
|
||
}
|
||
|
||
if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
|
||
return fromArrayBuffer(that, value, encodingOrOffset, length)
|
||
}
|
||
|
||
if (typeof value === 'string') {
|
||
return fromString(that, value, encodingOrOffset)
|
||
}
|
||
|
||
return fromObject(that, value)
|
||
}
|
||
|
||
/**
|
||
* Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
|
||
* if value is a number.
|
||
* Buffer.from(str[, encoding])
|
||
* Buffer.from(array)
|
||
* Buffer.from(buffer)
|
||
* Buffer.from(arrayBuffer[, byteOffset[, length]])
|
||
**/
|
||
Buffer.from = function (value, encodingOrOffset, length) {
|
||
return from(null, value, encodingOrOffset, length)
|
||
}
|
||
|
||
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
||
Buffer.prototype.__proto__ = Uint8Array.prototype
|
||
Buffer.__proto__ = Uint8Array
|
||
if (typeof Symbol !== 'undefined' && Symbol.species &&
|
||
Buffer[Symbol.species] === Buffer) {
|
||
// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
|
||
Object.defineProperty(Buffer, Symbol.species, {
|
||
value: null,
|
||
configurable: true
|
||
})
|
||
}
|
||
}
|
||
|
||
function assertSize (size) {
|
||
if (typeof size !== 'number') {
|
||
throw new TypeError('"size" argument must be a number')
|
||
} else if (size < 0) {
|
||
throw new RangeError('"size" argument must not be negative')
|
||
}
|
||
}
|
||
|
||
function alloc (that, size, fill, encoding) {
|
||
assertSize(size)
|
||
if (size <= 0) {
|
||
return createBuffer(that, size)
|
||
}
|
||
if (fill !== undefined) {
|
||
// Only pay attention to encoding if it's a string. This
|
||
// prevents accidentally sending in a number that would
|
||
// be interpretted as a start offset.
|
||
return typeof encoding === 'string'
|
||
? createBuffer(that, size).fill(fill, encoding)
|
||
: createBuffer(that, size).fill(fill)
|
||
}
|
||
return createBuffer(that, size)
|
||
}
|
||
|
||
/**
|
||
* Creates a new filled Buffer instance.
|
||
* alloc(size[, fill[, encoding]])
|
||
**/
|
||
Buffer.alloc = function (size, fill, encoding) {
|
||
return alloc(null, size, fill, encoding)
|
||
}
|
||
|
||
function allocUnsafe (that, size) {
|
||
assertSize(size)
|
||
that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
|
||
if (!Buffer.TYPED_ARRAY_SUPPORT) {
|
||
for (var i = 0; i < size; ++i) {
|
||
that[i] = 0
|
||
}
|
||
}
|
||
return that
|
||
}
|
||
|
||
/**
|
||
* Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
|
||
* */
|
||
Buffer.allocUnsafe = function (size) {
|
||
return allocUnsafe(null, size)
|
||
}
|
||
/**
|
||
* Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
||
*/
|
||
Buffer.allocUnsafeSlow = function (size) {
|
||
return allocUnsafe(null, size)
|
||
}
|
||
|
||
function fromString (that, string, encoding) {
|
||
if (typeof encoding !== 'string' || encoding === '') {
|
||
encoding = 'utf8'
|
||
}
|
||
|
||
if (!Buffer.isEncoding(encoding)) {
|
||
throw new TypeError('"encoding" must be a valid string encoding')
|
||
}
|
||
|
||
var length = byteLength(string, encoding) | 0
|
||
that = createBuffer(that, length)
|
||
|
||
var actual = that.write(string, encoding)
|
||
|
||
if (actual !== length) {
|
||
// Writing a hex string, for example, that contains invalid characters will
|
||
// cause everything after the first invalid character to be ignored. (e.g.
|
||
// 'abxxcd' will be treated as 'ab')
|
||
that = that.slice(0, actual)
|
||
}
|
||
|
||
return that
|
||
}
|
||
|
||
function fromArrayLike (that, array) {
|
||
var length = array.length < 0 ? 0 : checked(array.length) | 0
|
||
that = createBuffer(that, length)
|
||
for (var i = 0; i < length; i += 1) {
|
||
that[i] = array[i] & 255
|
||
}
|
||
return that
|
||
}
|
||
|
||
function fromArrayBuffer (that, array, byteOffset, length) {
|
||
array.byteLength // this throws if `array` is not a valid ArrayBuffer
|
||
|
||
if (byteOffset < 0 || array.byteLength < byteOffset) {
|
||
throw new RangeError('\'offset\' is out of bounds')
|
||
}
|
||
|
||
if (array.byteLength < byteOffset + (length || 0)) {
|
||
throw new RangeError('\'length\' is out of bounds')
|
||
}
|
||
|
||
if (byteOffset === undefined && length === undefined) {
|
||
array = new Uint8Array(array)
|
||
} else if (length === undefined) {
|
||
array = new Uint8Array(array, byteOffset)
|
||
} else {
|
||
array = new Uint8Array(array, byteOffset, length)
|
||
}
|
||
|
||
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
||
// Return an augmented `Uint8Array` instance, for best performance
|
||
that = array
|
||
that.__proto__ = Buffer.prototype
|
||
} else {
|
||
// Fallback: Return an object instance of the Buffer class
|
||
that = fromArrayLike(that, array)
|
||
}
|
||
return that
|
||
}
|
||
|
||
function fromObject (that, obj) {
|
||
if (Buffer.isBuffer(obj)) {
|
||
var len = checked(obj.length) | 0
|
||
that = createBuffer(that, len)
|
||
|
||
if (that.length === 0) {
|
||
return that
|
||
}
|
||
|
||
obj.copy(that, 0, 0, len)
|
||
return that
|
||
}
|
||
|
||
if (obj) {
|
||
if ((typeof ArrayBuffer !== 'undefined' &&
|
||
obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
|
||
if (typeof obj.length !== 'number' || isnan(obj.length)) {
|
||
return createBuffer(that, 0)
|
||
}
|
||
return fromArrayLike(that, obj)
|
||
}
|
||
|
||
if (obj.type === 'Buffer' && isArray(obj.data)) {
|
||
return fromArrayLike(that, obj.data)
|
||
}
|
||
}
|
||
|
||
throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
|
||
}
|
||
|
||
function checked (length) {
|
||
// Note: cannot use `length < kMaxLength()` here because that fails when
|
||
// length is NaN (which is otherwise coerced to zero.)
|
||
if (length >= kMaxLength()) {
|
||
throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
|
||
'size: 0x' + kMaxLength().toString(16) + ' bytes')
|
||
}
|
||
return length | 0
|
||
}
|
||
|
||
function SlowBuffer (length) {
|
||
if (+length != length) { // eslint-disable-line eqeqeq
|
||
length = 0
|
||
}
|
||
return Buffer.alloc(+length)
|
||
}
|
||
|
||
Buffer.isBuffer = function isBuffer (b) {
|
||
return !!(b != null && b._isBuffer)
|
||
}
|
||
|
||
Buffer.compare = function compare (a, b) {
|
||
if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
|
||
throw new TypeError('Arguments must be Buffers')
|
||
}
|
||
|
||
if (a === b) return 0
|
||
|
||
var x = a.length
|
||
var y = b.length
|
||
|
||
for (var i = 0, len = Math.min(x, y); i < len; ++i) {
|
||
if (a[i] !== b[i]) {
|
||
x = a[i]
|
||
y = b[i]
|
||
break
|
||
}
|
||
}
|
||
|
||
if (x < y) return -1
|
||
if (y < x) return 1
|
||
return 0
|
||
}
|
||
|
||
Buffer.isEncoding = function isEncoding (encoding) {
|
||
switch (String(encoding).toLowerCase()) {
|
||
case 'hex':
|
||
case 'utf8':
|
||
case 'utf-8':
|
||
case 'ascii':
|
||
case 'latin1':
|
||
case 'binary':
|
||
case 'base64':
|
||
case 'ucs2':
|
||
case 'ucs-2':
|
||
case 'utf16le':
|
||
case 'utf-16le':
|
||
return true
|
||
default:
|
||
return false
|
||
}
|
||
}
|
||
|
||
Buffer.concat = function concat (list, length) {
|
||
if (!isArray(list)) {
|
||
throw new TypeError('"list" argument must be an Array of Buffers')
|
||
}
|
||
|
||
if (list.length === 0) {
|
||
return Buffer.alloc(0)
|
||
}
|
||
|
||
var i
|
||
if (length === undefined) {
|
||
length = 0
|
||
for (i = 0; i < list.length; ++i) {
|
||
length += list[i].length
|
||
}
|
||
}
|
||
|
||
var buffer = Buffer.allocUnsafe(length)
|
||
var pos = 0
|
||
for (i = 0; i < list.length; ++i) {
|
||
var buf = list[i]
|
||
if (!Buffer.isBuffer(buf)) {
|
||
throw new TypeError('"list" argument must be an Array of Buffers')
|
||
}
|
||
buf.copy(buffer, pos)
|
||
pos += buf.length
|
||
}
|
||
return buffer
|
||
}
|
||
|
||
function byteLength (string, encoding) {
|
||
if (Buffer.isBuffer(string)) {
|
||
return string.length
|
||
}
|
||
if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
|
||
(ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
|
||
return string.byteLength
|
||
}
|
||
if (typeof string !== 'string') {
|
||
string = '' + string
|
||
}
|
||
|
||
var len = string.length
|
||
if (len === 0) return 0
|
||
|
||
// Use a for loop to avoid recursion
|
||
var loweredCase = false
|
||
for (;;) {
|
||
switch (encoding) {
|
||
case 'ascii':
|
||
case 'latin1':
|
||
case 'binary':
|
||
return len
|
||
case 'utf8':
|
||
case 'utf-8':
|
||
case undefined:
|
||
return utf8ToBytes(string).length
|
||
case 'ucs2':
|
||
case 'ucs-2':
|
||
case 'utf16le':
|
||
case 'utf-16le':
|
||
return len * 2
|
||
case 'hex':
|
||
return len >>> 1
|
||
case 'base64':
|
||
return base64ToBytes(string).length
|
||
default:
|
||
if (loweredCase) return utf8ToBytes(string).length // assume utf8
|
||
encoding = ('' + encoding).toLowerCase()
|
||
loweredCase = true
|
||
}
|
||
}
|
||
}
|
||
Buffer.byteLength = byteLength
|
||
|
||
function slowToString (encoding, start, end) {
|
||
var loweredCase = false
|
||
|
||
// No need to verify that "this.length <= MAX_UINT32" since it's a read-only
|
||
// property of a typed array.
|
||
|
||
// This behaves neither like String nor Uint8Array in that we set start/end
|
||
// to their upper/lower bounds if the value passed is out of range.
|
||
// undefined is handled specially as per ECMA-262 6th Edition,
|
||
// Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
|
||
if (start === undefined || start < 0) {
|
||
start = 0
|
||
}
|
||
// Return early if start > this.length. Done here to prevent potential uint32
|
||
// coercion fail below.
|
||
if (start > this.length) {
|
||
return ''
|
||
}
|
||
|
||
if (end === undefined || end > this.length) {
|
||
end = this.length
|
||
}
|
||
|
||
if (end <= 0) {
|
||
return ''
|
||
}
|
||
|
||
// Force coersion to uint32. This will also coerce falsey/NaN values to 0.
|
||
end >>>= 0
|
||
start >>>= 0
|
||
|
||
if (end <= start) {
|
||
return ''
|
||
}
|
||
|
||
if (!encoding) encoding = 'utf8'
|
||
|
||
while (true) {
|
||
switch (encoding) {
|
||
case 'hex':
|
||
return hexSlice(this, start, end)
|
||
|
||
case 'utf8':
|
||
case 'utf-8':
|
||
return utf8Slice(this, start, end)
|
||
|
||
case 'ascii':
|
||
return asciiSlice(this, start, end)
|
||
|
||
case 'latin1':
|
||
case 'binary':
|
||
return latin1Slice(this, start, end)
|
||
|
||
case 'base64':
|
||
return base64Slice(this, start, end)
|
||
|
||
case 'ucs2':
|
||
case 'ucs-2':
|
||
case 'utf16le':
|
||
case 'utf-16le':
|
||
return utf16leSlice(this, start, end)
|
||
|
||
default:
|
||
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
||
encoding = (encoding + '').toLowerCase()
|
||
loweredCase = true
|
||
}
|
||
}
|
||
}
|
||
|
||
// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
|
||
// Buffer instances.
|
||
Buffer.prototype._isBuffer = true
|
||
|
||
function swap (b, n, m) {
|
||
var i = b[n]
|
||
b[n] = b[m]
|
||
b[m] = i
|
||
}
|
||
|
||
Buffer.prototype.swap16 = function swap16 () {
|
||
var len = this.length
|
||
if (len % 2 !== 0) {
|
||
throw new RangeError('Buffer size must be a multiple of 16-bits')
|
||
}
|
||
for (var i = 0; i < len; i += 2) {
|
||
swap(this, i, i + 1)
|
||
}
|
||
return this
|
||
}
|
||
|
||
Buffer.prototype.swap32 = function swap32 () {
|
||
var len = this.length
|
||
if (len % 4 !== 0) {
|
||
throw new RangeError('Buffer size must be a multiple of 32-bits')
|
||
}
|
||
for (var i = 0; i < len; i += 4) {
|
||
swap(this, i, i + 3)
|
||
swap(this, i + 1, i + 2)
|
||
}
|
||
return this
|
||
}
|
||
|
||
Buffer.prototype.swap64 = function swap64 () {
|
||
var len = this.length
|
||
if (len % 8 !== 0) {
|
||
throw new RangeError('Buffer size must be a multiple of 64-bits')
|
||
}
|
||
for (var i = 0; i < len; i += 8) {
|
||
swap(this, i, i + 7)
|
||
swap(this, i + 1, i + 6)
|
||
swap(this, i + 2, i + 5)
|
||
swap(this, i + 3, i + 4)
|
||
}
|
||
return this
|
||
}
|
||
|
||
Buffer.prototype.toString = function toString () {
|
||
var length = this.length | 0
|
||
if (length === 0) return ''
|
||
if (arguments.length === 0) return utf8Slice(this, 0, length)
|
||
return slowToString.apply(this, arguments)
|
||
}
|
||
|
||
Buffer.prototype.equals = function equals (b) {
|
||
if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
|
||
if (this === b) return true
|
||
return Buffer.compare(this, b) === 0
|
||
}
|
||
|
||
Buffer.prototype.inspect = function inspect () {
|
||
var str = ''
|
||
var max = exports.INSPECT_MAX_BYTES
|
||
if (this.length > 0) {
|
||
str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
|
||
if (this.length > max) str += ' ... '
|
||
}
|
||
return '<Buffer ' + str + '>'
|
||
}
|
||
|
||
Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
|
||
if (!Buffer.isBuffer(target)) {
|
||
throw new TypeError('Argument must be a Buffer')
|
||
}
|
||
|
||
if (start === undefined) {
|
||
start = 0
|
||
}
|
||
if (end === undefined) {
|
||
end = target ? target.length : 0
|
||
}
|
||
if (thisStart === undefined) {
|
||
thisStart = 0
|
||
}
|
||
if (thisEnd === undefined) {
|
||
thisEnd = this.length
|
||
}
|
||
|
||
if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
|
||
throw new RangeError('out of range index')
|
||
}
|
||
|
||
if (thisStart >= thisEnd && start >= end) {
|
||
return 0
|
||
}
|
||
if (thisStart >= thisEnd) {
|
||
return -1
|
||
}
|
||
if (start >= end) {
|
||
return 1
|
||
}
|
||
|
||
start >>>= 0
|
||
end >>>= 0
|
||
thisStart >>>= 0
|
||
thisEnd >>>= 0
|
||
|
||
if (this === target) return 0
|
||
|
||
var x = thisEnd - thisStart
|
||
var y = end - start
|
||
var len = Math.min(x, y)
|
||
|
||
var thisCopy = this.slice(thisStart, thisEnd)
|
||
var targetCopy = target.slice(start, end)
|
||
|
||
for (var i = 0; i < len; ++i) {
|
||
if (thisCopy[i] !== targetCopy[i]) {
|
||
x = thisCopy[i]
|
||
y = targetCopy[i]
|
||
break
|
||
}
|
||
}
|
||
|
||
if (x < y) return -1
|
||
if (y < x) return 1
|
||
return 0
|
||
}
|
||
|
||
// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
|
||
// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
|
||
//
|
||
// Arguments:
|
||
// - buffer - a Buffer to search
|
||
// - val - a string, Buffer, or number
|
||
// - byteOffset - an index into `buffer`; will be clamped to an int32
|
||
// - encoding - an optional encoding, relevant is val is a string
|
||
// - dir - true for indexOf, false for lastIndexOf
|
||
function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
|
||
// Empty buffer means no match
|
||
if (buffer.length === 0) return -1
|
||
|
||
// Normalize byteOffset
|
||
if (typeof byteOffset === 'string') {
|
||
encoding = byteOffset
|
||
byteOffset = 0
|
||
} else if (byteOffset > 0x7fffffff) {
|
||
byteOffset = 0x7fffffff
|
||
} else if (byteOffset < -0x80000000) {
|
||
byteOffset = -0x80000000
|
||
}
|
||
byteOffset = +byteOffset // Coerce to Number.
|
||
if (isNaN(byteOffset)) {
|
||
// byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
|
||
byteOffset = dir ? 0 : (buffer.length - 1)
|
||
}
|
||
|
||
// Normalize byteOffset: negative offsets start from the end of the buffer
|
||
if (byteOffset < 0) byteOffset = buffer.length + byteOffset
|
||
if (byteOffset >= buffer.length) {
|
||
if (dir) return -1
|
||
else byteOffset = buffer.length - 1
|
||
} else if (byteOffset < 0) {
|
||
if (dir) byteOffset = 0
|
||
else return -1
|
||
}
|
||
|
||
// Normalize val
|
||
if (typeof val === 'string') {
|
||
val = Buffer.from(val, encoding)
|
||
}
|
||
|
||
// Finally, search either indexOf (if dir is true) or lastIndexOf
|
||
if (Buffer.isBuffer(val)) {
|
||
// Special case: looking for empty string/buffer always fails
|
||
if (val.length === 0) {
|
||
return -1
|
||
}
|
||
return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
|
||
} else if (typeof val === 'number') {
|
||
val = val & 0xFF // Search for a byte value [0-255]
|
||
if (Buffer.TYPED_ARRAY_SUPPORT &&
|
||
typeof Uint8Array.prototype.indexOf === 'function') {
|
||
if (dir) {
|
||
return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
|
||
} else {
|
||
return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
|
||
}
|
||
}
|
||
return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
|
||
}
|
||
|
||
throw new TypeError('val must be string, number or Buffer')
|
||
}
|
||
|
||
function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
|
||
var indexSize = 1
|
||
var arrLength = arr.length
|
||
var valLength = val.length
|
||
|
||
if (encoding !== undefined) {
|
||
encoding = String(encoding).toLowerCase()
|
||
if (encoding === 'ucs2' || encoding === 'ucs-2' ||
|
||
encoding === 'utf16le' || encoding === 'utf-16le') {
|
||
if (arr.length < 2 || val.length < 2) {
|
||
return -1
|
||
}
|
||
indexSize = 2
|
||
arrLength /= 2
|
||
valLength /= 2
|
||
byteOffset /= 2
|
||
}
|
||
}
|
||
|
||
function read (buf, i) {
|
||
if (indexSize === 1) {
|
||
return buf[i]
|
||
} else {
|
||
return buf.readUInt16BE(i * indexSize)
|
||
}
|
||
}
|
||
|
||
var i
|
||
if (dir) {
|
||
var foundIndex = -1
|
||
for (i = byteOffset; i < arrLength; i++) {
|
||
if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
|
||
if (foundIndex === -1) foundIndex = i
|
||
if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
|
||
} else {
|
||
if (foundIndex !== -1) i -= i - foundIndex
|
||
foundIndex = -1
|
||
}
|
||
}
|
||
} else {
|
||
if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
|
||
for (i = byteOffset; i >= 0; i--) {
|
||
var found = true
|
||
for (var j = 0; j < valLength; j++) {
|
||
if (read(arr, i + j) !== read(val, j)) {
|
||
found = false
|
||
break
|
||
}
|
||
}
|
||
if (found) return i
|
||
}
|
||
}
|
||
|
||
return -1
|
||
}
|
||
|
||
Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
|
||
return this.indexOf(val, byteOffset, encoding) !== -1
|
||
}
|
||
|
||
Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
|
||
return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
|
||
}
|
||
|
||
Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
|
||
return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
|
||
}
|
||
|
||
function hexWrite (buf, string, offset, length) {
|
||
offset = Number(offset) || 0
|
||
var remaining = buf.length - offset
|
||
if (!length) {
|
||
length = remaining
|
||
} else {
|
||
length = Number(length)
|
||
if (length > remaining) {
|
||
length = remaining
|
||
}
|
||
}
|
||
|
||
// must be an even number of digits
|
||
var strLen = string.length
|
||
if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
|
||
|
||
if (length > strLen / 2) {
|
||
length = strLen / 2
|
||
}
|
||
for (var i = 0; i < length; ++i) {
|
||
var parsed = parseInt(string.substr(i * 2, 2), 16)
|
||
if (isNaN(parsed)) return i
|
||
buf[offset + i] = parsed
|
||
}
|
||
return i
|
||
}
|
||
|
||
function utf8Write (buf, string, offset, length) {
|
||
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
|
||
}
|
||
|
||
function asciiWrite (buf, string, offset, length) {
|
||
return blitBuffer(asciiToBytes(string), buf, offset, length)
|
||
}
|
||
|
||
function latin1Write (buf, string, offset, length) {
|
||
return asciiWrite(buf, string, offset, length)
|
||
}
|
||
|
||
function base64Write (buf, string, offset, length) {
|
||
return blitBuffer(base64ToBytes(string), buf, offset, length)
|
||
}
|
||
|
||
function ucs2Write (buf, string, offset, length) {
|
||
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
|
||
}
|
||
|
||
Buffer.prototype.write = function write (string, offset, length, encoding) {
|
||
// Buffer#write(string)
|
||
if (offset === undefined) {
|
||
encoding = 'utf8'
|
||
length = this.length
|
||
offset = 0
|
||
// Buffer#write(string, encoding)
|
||
} else if (length === undefined && typeof offset === 'string') {
|
||
encoding = offset
|
||
length = this.length
|
||
offset = 0
|
||
// Buffer#write(string, offset[, length][, encoding])
|
||
} else if (isFinite(offset)) {
|
||
offset = offset | 0
|
||
if (isFinite(length)) {
|
||
length = length | 0
|
||
if (encoding === undefined) encoding = 'utf8'
|
||
} else {
|
||
encoding = length
|
||
length = undefined
|
||
}
|
||
// legacy write(string, encoding, offset, length) - remove in v0.13
|
||
} else {
|
||
throw new Error(
|
||
'Buffer.write(string, encoding, offset[, length]) is no longer supported'
|
||
)
|
||
}
|
||
|
||
var remaining = this.length - offset
|
||
if (length === undefined || length > remaining) length = remaining
|
||
|
||
if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
|
||
throw new RangeError('Attempt to write outside buffer bounds')
|
||
}
|
||
|
||
if (!encoding) encoding = 'utf8'
|
||
|
||
var loweredCase = false
|
||
for (;;) {
|
||
switch (encoding) {
|
||
case 'hex':
|
||
return hexWrite(this, string, offset, length)
|
||
|
||
case 'utf8':
|
||
case 'utf-8':
|
||
return utf8Write(this, string, offset, length)
|
||
|
||
case 'ascii':
|
||
return asciiWrite(this, string, offset, length)
|
||
|
||
case 'latin1':
|
||
case 'binary':
|
||
return latin1Write(this, string, offset, length)
|
||
|
||
case 'base64':
|
||
// Warning: maxLength not taken into account in base64Write
|
||
return base64Write(this, string, offset, length)
|
||
|
||
case 'ucs2':
|
||
case 'ucs-2':
|
||
case 'utf16le':
|
||
case 'utf-16le':
|
||
return ucs2Write(this, string, offset, length)
|
||
|
||
default:
|
||
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
||
encoding = ('' + encoding).toLowerCase()
|
||
loweredCase = true
|
||
}
|
||
}
|
||
}
|
||
|
||
Buffer.prototype.toJSON = function toJSON () {
|
||
return {
|
||
type: 'Buffer',
|
||
data: Array.prototype.slice.call(this._arr || this, 0)
|
||
}
|
||
}
|
||
|
||
function base64Slice (buf, start, end) {
|
||
if (start === 0 && end === buf.length) {
|
||
return base64.fromByteArray(buf)
|
||
} else {
|
||
return base64.fromByteArray(buf.slice(start, end))
|
||
}
|
||
}
|
||
|
||
function utf8Slice (buf, start, end) {
|
||
end = Math.min(buf.length, end)
|
||
var res = []
|
||
|
||
var i = start
|
||
while (i < end) {
|
||
var firstByte = buf[i]
|
||
var codePoint = null
|
||
var bytesPerSequence = (firstByte > 0xEF) ? 4
|
||
: (firstByte > 0xDF) ? 3
|
||
: (firstByte > 0xBF) ? 2
|
||
: 1
|
||
|
||
if (i + bytesPerSequence <= end) {
|
||
var secondByte, thirdByte, fourthByte, tempCodePoint
|
||
|
||
switch (bytesPerSequence) {
|
||
case 1:
|
||
if (firstByte < 0x80) {
|
||
codePoint = firstByte
|
||
}
|
||
break
|
||
case 2:
|
||
secondByte = buf[i + 1]
|
||
if ((secondByte & 0xC0) === 0x80) {
|
||
tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
|
||
if (tempCodePoint > 0x7F) {
|
||
codePoint = tempCodePoint
|
||
}
|
||
}
|
||
break
|
||
case 3:
|
||
secondByte = buf[i + 1]
|
||
thirdByte = buf[i + 2]
|
||
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
|
||
tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
|
||
if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
|
||
codePoint = tempCodePoint
|
||
}
|
||
}
|
||
break
|
||
case 4:
|
||
secondByte = buf[i + 1]
|
||
thirdByte = buf[i + 2]
|
||
fourthByte = buf[i + 3]
|
||
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
|
||
tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
|
||
if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
|
||
codePoint = tempCodePoint
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
if (codePoint === null) {
|
||
// we did not generate a valid codePoint so insert a
|
||
// replacement char (U+FFFD) and advance only 1 byte
|
||
codePoint = 0xFFFD
|
||
bytesPerSequence = 1
|
||
} else if (codePoint > 0xFFFF) {
|
||
// encode to utf16 (surrogate pair dance)
|
||
codePoint -= 0x10000
|
||
res.push(codePoint >>> 10 & 0x3FF | 0xD800)
|
||
codePoint = 0xDC00 | codePoint & 0x3FF
|
||
}
|
||
|
||
res.push(codePoint)
|
||
i += bytesPerSequence
|
||
}
|
||
|
||
return decodeCodePointsArray(res)
|
||
}
|
||
|
||
// Based on http://stackoverflow.com/a/22747272/680742, the browser with
|
||
// the lowest limit is Chrome, with 0x10000 args.
|
||
// We go 1 magnitude less, for safety
|
||
var MAX_ARGUMENTS_LENGTH = 0x1000
|
||
|
||
function decodeCodePointsArray (codePoints) {
|
||
var len = codePoints.length
|
||
if (len <= MAX_ARGUMENTS_LENGTH) {
|
||
return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
|
||
}
|
||
|
||
// Decode in chunks to avoid "call stack size exceeded".
|
||
var res = ''
|
||
var i = 0
|
||
while (i < len) {
|
||
res += String.fromCharCode.apply(
|
||
String,
|
||
codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
|
||
)
|
||
}
|
||
return res
|
||
}
|
||
|
||
function asciiSlice (buf, start, end) {
|
||
var ret = ''
|
||
end = Math.min(buf.length, end)
|
||
|
||
for (var i = start; i < end; ++i) {
|
||
ret += String.fromCharCode(buf[i] & 0x7F)
|
||
}
|
||
return ret
|
||
}
|
||
|
||
function latin1Slice (buf, start, end) {
|
||
var ret = ''
|
||
end = Math.min(buf.length, end)
|
||
|
||
for (var i = start; i < end; ++i) {
|
||
ret += String.fromCharCode(buf[i])
|
||
}
|
||
return ret
|
||
}
|
||
|
||
function hexSlice (buf, start, end) {
|
||
var len = buf.length
|
||
|
||
if (!start || start < 0) start = 0
|
||
if (!end || end < 0 || end > len) end = len
|
||
|
||
var out = ''
|
||
for (var i = start; i < end; ++i) {
|
||
out += toHex(buf[i])
|
||
}
|
||
return out
|
||
}
|
||
|
||
function utf16leSlice (buf, start, end) {
|
||
var bytes = buf.slice(start, end)
|
||
var res = ''
|
||
for (var i = 0; i < bytes.length; i += 2) {
|
||
res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
|
||
}
|
||
return res
|
||
}
|
||
|
||
Buffer.prototype.slice = function slice (start, end) {
|
||
var len = this.length
|
||
start = ~~start
|
||
end = end === undefined ? len : ~~end
|
||
|
||
if (start < 0) {
|
||
start += len
|
||
if (start < 0) start = 0
|
||
} else if (start > len) {
|
||
start = len
|
||
}
|
||
|
||
if (end < 0) {
|
||
end += len
|
||
if (end < 0) end = 0
|
||
} else if (end > len) {
|
||
end = len
|
||
}
|
||
|
||
if (end < start) end = start
|
||
|
||
var newBuf
|
||
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
||
newBuf = this.subarray(start, end)
|
||
newBuf.__proto__ = Buffer.prototype
|
||
} else {
|
||
var sliceLen = end - start
|
||
newBuf = new Buffer(sliceLen, undefined)
|
||
for (var i = 0; i < sliceLen; ++i) {
|
||
newBuf[i] = this[i + start]
|
||
}
|
||
}
|
||
|
||
return newBuf
|
||
}
|
||
|
||
/*
|
||
* Need to make sure that buffer isn't trying to write out of bounds.
|
||
*/
|
||
function checkOffset (offset, ext, length) {
|
||
if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
|
||
if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
|
||
}
|
||
|
||
Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
|
||
offset = offset | 0
|
||
byteLength = byteLength | 0
|
||
if (!noAssert) checkOffset(offset, byteLength, this.length)
|
||
|
||
var val = this[offset]
|
||
var mul = 1
|
||
var i = 0
|
||
while (++i < byteLength && (mul *= 0x100)) {
|
||
val += this[offset + i] * mul
|
||
}
|
||
|
||
return val
|
||
}
|
||
|
||
Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
|
||
offset = offset | 0
|
||
byteLength = byteLength | 0
|
||
if (!noAssert) {
|
||
checkOffset(offset, byteLength, this.length)
|
||
}
|
||
|
||
var val = this[offset + --byteLength]
|
||
var mul = 1
|
||
while (byteLength > 0 && (mul *= 0x100)) {
|
||
val += this[offset + --byteLength] * mul
|
||
}
|
||
|
||
return val
|
||
}
|
||
|
||
Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
|
||
if (!noAssert) checkOffset(offset, 1, this.length)
|
||
return this[offset]
|
||
}
|
||
|
||
Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
|
||
if (!noAssert) checkOffset(offset, 2, this.length)
|
||
return this[offset] | (this[offset + 1] << 8)
|
||
}
|
||
|
||
Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
|
||
if (!noAssert) checkOffset(offset, 2, this.length)
|
||
return (this[offset] << 8) | this[offset + 1]
|
||
}
|
||
|
||
Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
|
||
if (!noAssert) checkOffset(offset, 4, this.length)
|
||
|
||
return ((this[offset]) |
|
||
(this[offset + 1] << 8) |
|
||
(this[offset + 2] << 16)) +
|
||
(this[offset + 3] * 0x1000000)
|
||
}
|
||
|
||
Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
|
||
if (!noAssert) checkOffset(offset, 4, this.length)
|
||
|
||
return (this[offset] * 0x1000000) +
|
||
((this[offset + 1] << 16) |
|
||
(this[offset + 2] << 8) |
|
||
this[offset + 3])
|
||
}
|
||
|
||
Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
|
||
offset = offset | 0
|
||
byteLength = byteLength | 0
|
||
if (!noAssert) checkOffset(offset, byteLength, this.length)
|
||
|
||
var val = this[offset]
|
||
var mul = 1
|
||
var i = 0
|
||
while (++i < byteLength && (mul *= 0x100)) {
|
||
val += this[offset + i] * mul
|
||
}
|
||
mul *= 0x80
|
||
|
||
if (val >= mul) val -= Math.pow(2, 8 * byteLength)
|
||
|
||
return val
|
||
}
|
||
|
||
Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
|
||
offset = offset | 0
|
||
byteLength = byteLength | 0
|
||
if (!noAssert) checkOffset(offset, byteLength, this.length)
|
||
|
||
var i = byteLength
|
||
var mul = 1
|
||
var val = this[offset + --i]
|
||
while (i > 0 && (mul *= 0x100)) {
|
||
val += this[offset + --i] * mul
|
||
}
|
||
mul *= 0x80
|
||
|
||
if (val >= mul) val -= Math.pow(2, 8 * byteLength)
|
||
|
||
return val
|
||
}
|
||
|
||
Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
|
||
if (!noAssert) checkOffset(offset, 1, this.length)
|
||
if (!(this[offset] & 0x80)) return (this[offset])
|
||
return ((0xff - this[offset] + 1) * -1)
|
||
}
|
||
|
||
Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
|
||
if (!noAssert) checkOffset(offset, 2, this.length)
|
||
var val = this[offset] | (this[offset + 1] << 8)
|
||
return (val & 0x8000) ? val | 0xFFFF0000 : val
|
||
}
|
||
|
||
Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
|
||
if (!noAssert) checkOffset(offset, 2, this.length)
|
||
var val = this[offset + 1] | (this[offset] << 8)
|
||
return (val & 0x8000) ? val | 0xFFFF0000 : val
|
||
}
|
||
|
||
Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
|
||
if (!noAssert) checkOffset(offset, 4, this.length)
|
||
|
||
return (this[offset]) |
|
||
(this[offset + 1] << 8) |
|
||
(this[offset + 2] << 16) |
|
||
(this[offset + 3] << 24)
|
||
}
|
||
|
||
Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
|
||
if (!noAssert) checkOffset(offset, 4, this.length)
|
||
|
||
return (this[offset] << 24) |
|
||
(this[offset + 1] << 16) |
|
||
(this[offset + 2] << 8) |
|
||
(this[offset + 3])
|
||
}
|
||
|
||
Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
|
||
if (!noAssert) checkOffset(offset, 4, this.length)
|
||
return ieee754.read(this, offset, true, 23, 4)
|
||
}
|
||
|
||
Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
|
||
if (!noAssert) checkOffset(offset, 4, this.length)
|
||
return ieee754.read(this, offset, false, 23, 4)
|
||
}
|
||
|
||
Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
|
||
if (!noAssert) checkOffset(offset, 8, this.length)
|
||
return ieee754.read(this, offset, true, 52, 8)
|
||
}
|
||
|
||
Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
|
||
if (!noAssert) checkOffset(offset, 8, this.length)
|
||
return ieee754.read(this, offset, false, 52, 8)
|
||
}
|
||
|
||
function checkInt (buf, value, offset, ext, max, min) {
|
||
if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
|
||
if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
|
||
if (offset + ext > buf.length) throw new RangeError('Index out of range')
|
||
}
|
||
|
||
Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
|
||
value = +value
|
||
offset = offset | 0
|
||
byteLength = byteLength | 0
|
||
if (!noAssert) {
|
||
var maxBytes = Math.pow(2, 8 * byteLength) - 1
|
||
checkInt(this, value, offset, byteLength, maxBytes, 0)
|
||
}
|
||
|
||
var mul = 1
|
||
var i = 0
|
||
this[offset] = value & 0xFF
|
||
while (++i < byteLength && (mul *= 0x100)) {
|
||
this[offset + i] = (value / mul) & 0xFF
|
||
}
|
||
|
||
return offset + byteLength
|
||
}
|
||
|
||
Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
|
||
value = +value
|
||
offset = offset | 0
|
||
byteLength = byteLength | 0
|
||
if (!noAssert) {
|
||
var maxBytes = Math.pow(2, 8 * byteLength) - 1
|
||
checkInt(this, value, offset, byteLength, maxBytes, 0)
|
||
}
|
||
|
||
var i = byteLength - 1
|
||
var mul = 1
|
||
this[offset + i] = value & 0xFF
|
||
while (--i >= 0 && (mul *= 0x100)) {
|
||
this[offset + i] = (value / mul) & 0xFF
|
||
}
|
||
|
||
return offset + byteLength
|
||
}
|
||
|
||
Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
|
||
value = +value
|
||
offset = offset | 0
|
||
if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
|
||
if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
|
||
this[offset] = (value & 0xff)
|
||
return offset + 1
|
||
}
|
||
|
||
function objectWriteUInt16 (buf, value, offset, littleEndian) {
|
||
if (value < 0) value = 0xffff + value + 1
|
||
for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
|
||
buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
|
||
(littleEndian ? i : 1 - i) * 8
|
||
}
|
||
}
|
||
|
||
Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
|
||
value = +value
|
||
offset = offset | 0
|
||
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
|
||
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
||
this[offset] = (value & 0xff)
|
||
this[offset + 1] = (value >>> 8)
|
||
} else {
|
||
objectWriteUInt16(this, value, offset, true)
|
||
}
|
||
return offset + 2
|
||
}
|
||
|
||
Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
|
||
value = +value
|
||
offset = offset | 0
|
||
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
|
||
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
||
this[offset] = (value >>> 8)
|
||
this[offset + 1] = (value & 0xff)
|
||
} else {
|
||
objectWriteUInt16(this, value, offset, false)
|
||
}
|
||
return offset + 2
|
||
}
|
||
|
||
function objectWriteUInt32 (buf, value, offset, littleEndian) {
|
||
if (value < 0) value = 0xffffffff + value + 1
|
||
for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
|
||
buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
|
||
}
|
||
}
|
||
|
||
Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
|
||
value = +value
|
||
offset = offset | 0
|
||
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
|
||
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
||
this[offset + 3] = (value >>> 24)
|
||
this[offset + 2] = (value >>> 16)
|
||
this[offset + 1] = (value >>> 8)
|
||
this[offset] = (value & 0xff)
|
||
} else {
|
||
objectWriteUInt32(this, value, offset, true)
|
||
}
|
||
return offset + 4
|
||
}
|
||
|
||
Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
|
||
value = +value
|
||
offset = offset | 0
|
||
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
|
||
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
||
this[offset] = (value >>> 24)
|
||
this[offset + 1] = (value >>> 16)
|
||
this[offset + 2] = (value >>> 8)
|
||
this[offset + 3] = (value & 0xff)
|
||
} else {
|
||
objectWriteUInt32(this, value, offset, false)
|
||
}
|
||
return offset + 4
|
||
}
|
||
|
||
Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
|
||
value = +value
|
||
offset = offset | 0
|
||
if (!noAssert) {
|
||
var limit = Math.pow(2, 8 * byteLength - 1)
|
||
|
||
checkInt(this, value, offset, byteLength, limit - 1, -limit)
|
||
}
|
||
|
||
var i = 0
|
||
var mul = 1
|
||
var sub = 0
|
||
this[offset] = value & 0xFF
|
||
while (++i < byteLength && (mul *= 0x100)) {
|
||
if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
|
||
sub = 1
|
||
}
|
||
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
|
||
}
|
||
|
||
return offset + byteLength
|
||
}
|
||
|
||
Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
|
||
value = +value
|
||
offset = offset | 0
|
||
if (!noAssert) {
|
||
var limit = Math.pow(2, 8 * byteLength - 1)
|
||
|
||
checkInt(this, value, offset, byteLength, limit - 1, -limit)
|
||
}
|
||
|
||
var i = byteLength - 1
|
||
var mul = 1
|
||
var sub = 0
|
||
this[offset + i] = value & 0xFF
|
||
while (--i >= 0 && (mul *= 0x100)) {
|
||
if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
|
||
sub = 1
|
||
}
|
||
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
|
||
}
|
||
|
||
return offset + byteLength
|
||
}
|
||
|
||
Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
|
||
value = +value
|
||
offset = offset | 0
|
||
if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
|
||
if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
|
||
if (value < 0) value = 0xff + value + 1
|
||
this[offset] = (value & 0xff)
|
||
return offset + 1
|
||
}
|
||
|
||
Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
|
||
value = +value
|
||
offset = offset | 0
|
||
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
|
||
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
||
this[offset] = (value & 0xff)
|
||
this[offset + 1] = (value >>> 8)
|
||
} else {
|
||
objectWriteUInt16(this, value, offset, true)
|
||
}
|
||
return offset + 2
|
||
}
|
||
|
||
Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
|
||
value = +value
|
||
offset = offset | 0
|
||
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
|
||
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
||
this[offset] = (value >>> 8)
|
||
this[offset + 1] = (value & 0xff)
|
||
} else {
|
||
objectWriteUInt16(this, value, offset, false)
|
||
}
|
||
return offset + 2
|
||
}
|
||
|
||
Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
|
||
value = +value
|
||
offset = offset | 0
|
||
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
|
||
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
||
this[offset] = (value & 0xff)
|
||
this[offset + 1] = (value >>> 8)
|
||
this[offset + 2] = (value >>> 16)
|
||
this[offset + 3] = (value >>> 24)
|
||
} else {
|
||
objectWriteUInt32(this, value, offset, true)
|
||
}
|
||
return offset + 4
|
||
}
|
||
|
||
Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
|
||
value = +value
|
||
offset = offset | 0
|
||
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
|
||
if (value < 0) value = 0xffffffff + value + 1
|
||
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
||
this[offset] = (value >>> 24)
|
||
this[offset + 1] = (value >>> 16)
|
||
this[offset + 2] = (value >>> 8)
|
||
this[offset + 3] = (value & 0xff)
|
||
} else {
|
||
objectWriteUInt32(this, value, offset, false)
|
||
}
|
||
return offset + 4
|
||
}
|
||
|
||
function checkIEEE754 (buf, value, offset, ext, max, min) {
|
||
if (offset + ext > buf.length) throw new RangeError('Index out of range')
|
||
if (offset < 0) throw new RangeError('Index out of range')
|
||
}
|
||
|
||
function writeFloat (buf, value, offset, littleEndian, noAssert) {
|
||
if (!noAssert) {
|
||
checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
|
||
}
|
||
ieee754.write(buf, value, offset, littleEndian, 23, 4)
|
||
return offset + 4
|
||
}
|
||
|
||
Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
|
||
return writeFloat(this, value, offset, true, noAssert)
|
||
}
|
||
|
||
Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
|
||
return writeFloat(this, value, offset, false, noAssert)
|
||
}
|
||
|
||
function writeDouble (buf, value, offset, littleEndian, noAssert) {
|
||
if (!noAssert) {
|
||
checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
|
||
}
|
||
ieee754.write(buf, value, offset, littleEndian, 52, 8)
|
||
return offset + 8
|
||
}
|
||
|
||
Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
|
||
return writeDouble(this, value, offset, true, noAssert)
|
||
}
|
||
|
||
Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
|
||
return writeDouble(this, value, offset, false, noAssert)
|
||
}
|
||
|
||
// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
|
||
Buffer.prototype.copy = function copy (target, targetStart, start, end) {
|
||
if (!start) start = 0
|
||
if (!end && end !== 0) end = this.length
|
||
if (targetStart >= target.length) targetStart = target.length
|
||
if (!targetStart) targetStart = 0
|
||
if (end > 0 && end < start) end = start
|
||
|
||
// Copy 0 bytes; we're done
|
||
if (end === start) return 0
|
||
if (target.length === 0 || this.length === 0) return 0
|
||
|
||
// Fatal error conditions
|
||
if (targetStart < 0) {
|
||
throw new RangeError('targetStart out of bounds')
|
||
}
|
||
if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
|
||
if (end < 0) throw new RangeError('sourceEnd out of bounds')
|
||
|
||
// Are we oob?
|
||
if (end > this.length) end = this.length
|
||
if (target.length - targetStart < end - start) {
|
||
end = target.length - targetStart + start
|
||
}
|
||
|
||
var len = end - start
|
||
var i
|
||
|
||
if (this === target && start < targetStart && targetStart < end) {
|
||
// descending copy from end
|
||
for (i = len - 1; i >= 0; --i) {
|
||
target[i + targetStart] = this[i + start]
|
||
}
|
||
} else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
|
||
// ascending copy from start
|
||
for (i = 0; i < len; ++i) {
|
||
target[i + targetStart] = this[i + start]
|
||
}
|
||
} else {
|
||
Uint8Array.prototype.set.call(
|
||
target,
|
||
this.subarray(start, start + len),
|
||
targetStart
|
||
)
|
||
}
|
||
|
||
return len
|
||
}
|
||
|
||
// Usage:
|
||
// buffer.fill(number[, offset[, end]])
|
||
// buffer.fill(buffer[, offset[, end]])
|
||
// buffer.fill(string[, offset[, end]][, encoding])
|
||
Buffer.prototype.fill = function fill (val, start, end, encoding) {
|
||
// Handle string cases:
|
||
if (typeof val === 'string') {
|
||
if (typeof start === 'string') {
|
||
encoding = start
|
||
start = 0
|
||
end = this.length
|
||
} else if (typeof end === 'string') {
|
||
encoding = end
|
||
end = this.length
|
||
}
|
||
if (val.length === 1) {
|
||
var code = val.charCodeAt(0)
|
||
if (code < 256) {
|
||
val = code
|
||
}
|
||
}
|
||
if (encoding !== undefined && typeof encoding !== 'string') {
|
||
throw new TypeError('encoding must be a string')
|
||
}
|
||
if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
|
||
throw new TypeError('Unknown encoding: ' + encoding)
|
||
}
|
||
} else if (typeof val === 'number') {
|
||
val = val & 255
|
||
}
|
||
|
||
// Invalid ranges are not set to a default, so can range check early.
|
||
if (start < 0 || this.length < start || this.length < end) {
|
||
throw new RangeError('Out of range index')
|
||
}
|
||
|
||
if (end <= start) {
|
||
return this
|
||
}
|
||
|
||
start = start >>> 0
|
||
end = end === undefined ? this.length : end >>> 0
|
||
|
||
if (!val) val = 0
|
||
|
||
var i
|
||
if (typeof val === 'number') {
|
||
for (i = start; i < end; ++i) {
|
||
this[i] = val
|
||
}
|
||
} else {
|
||
var bytes = Buffer.isBuffer(val)
|
||
? val
|
||
: utf8ToBytes(new Buffer(val, encoding).toString())
|
||
var len = bytes.length
|
||
for (i = 0; i < end - start; ++i) {
|
||
this[i + start] = bytes[i % len]
|
||
}
|
||
}
|
||
|
||
return this
|
||
}
|
||
|
||
// HELPER FUNCTIONS
|
||
// ================
|
||
|
||
var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
|
||
|
||
function base64clean (str) {
|
||
// Node strips out invalid characters like \n and \t from the string, base64-js does not
|
||
str = stringtrim(str).replace(INVALID_BASE64_RE, '')
|
||
// Node converts strings with length < 2 to ''
|
||
if (str.length < 2) return ''
|
||
// Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
|
||
while (str.length % 4 !== 0) {
|
||
str = str + '='
|
||
}
|
||
return str
|
||
}
|
||
|
||
function stringtrim (str) {
|
||
if (str.trim) return str.trim()
|
||
return str.replace(/^\s+|\s+$/g, '')
|
||
}
|
||
|
||
function toHex (n) {
|
||
if (n < 16) return '0' + n.toString(16)
|
||
return n.toString(16)
|
||
}
|
||
|
||
function utf8ToBytes (string, units) {
|
||
units = units || Infinity
|
||
var codePoint
|
||
var length = string.length
|
||
var leadSurrogate = null
|
||
var bytes = []
|
||
|
||
for (var i = 0; i < length; ++i) {
|
||
codePoint = string.charCodeAt(i)
|
||
|
||
// is surrogate component
|
||
if (codePoint > 0xD7FF && codePoint < 0xE000) {
|
||
// last char was a lead
|
||
if (!leadSurrogate) {
|
||
// no lead yet
|
||
if (codePoint > 0xDBFF) {
|
||
// unexpected trail
|
||
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
||
continue
|
||
} else if (i + 1 === length) {
|
||
// unpaired lead
|
||
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
||
continue
|
||
}
|
||
|
||
// valid lead
|
||
leadSurrogate = codePoint
|
||
|
||
continue
|
||
}
|
||
|
||
// 2 leads in a row
|
||
if (codePoint < 0xDC00) {
|
||
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
||
leadSurrogate = codePoint
|
||
continue
|
||
}
|
||
|
||
// valid surrogate pair
|
||
codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
|
||
} else if (leadSurrogate) {
|
||
// valid bmp char, but last char was a lead
|
||
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
||
}
|
||
|
||
leadSurrogate = null
|
||
|
||
// encode utf8
|
||
if (codePoint < 0x80) {
|
||
if ((units -= 1) < 0) break
|
||
bytes.push(codePoint)
|
||
} else if (codePoint < 0x800) {
|
||
if ((units -= 2) < 0) break
|
||
bytes.push(
|
||
codePoint >> 0x6 | 0xC0,
|
||
codePoint & 0x3F | 0x80
|
||
)
|
||
} else if (codePoint < 0x10000) {
|
||
if ((units -= 3) < 0) break
|
||
bytes.push(
|
||
codePoint >> 0xC | 0xE0,
|
||
codePoint >> 0x6 & 0x3F | 0x80,
|
||
codePoint & 0x3F | 0x80
|
||
)
|
||
} else if (codePoint < 0x110000) {
|
||
if ((units -= 4) < 0) break
|
||
bytes.push(
|
||
codePoint >> 0x12 | 0xF0,
|
||
codePoint >> 0xC & 0x3F | 0x80,
|
||
codePoint >> 0x6 & 0x3F | 0x80,
|
||
codePoint & 0x3F | 0x80
|
||
)
|
||
} else {
|
||
throw new Error('Invalid code point')
|
||
}
|
||
}
|
||
|
||
return bytes
|
||
}
|
||
|
||
function asciiToBytes (str) {
|
||
var byteArray = []
|
||
for (var i = 0; i < str.length; ++i) {
|
||
// Node's code seems to be doing this and not & 0x7F..
|
||
byteArray.push(str.charCodeAt(i) & 0xFF)
|
||
}
|
||
return byteArray
|
||
}
|
||
|
||
function utf16leToBytes (str, units) {
|
||
var c, hi, lo
|
||
var byteArray = []
|
||
for (var i = 0; i < str.length; ++i) {
|
||
if ((units -= 2) < 0) break
|
||
|
||
c = str.charCodeAt(i)
|
||
hi = c >> 8
|
||
lo = c % 256
|
||
byteArray.push(lo)
|
||
byteArray.push(hi)
|
||
}
|
||
|
||
return byteArray
|
||
}
|
||
|
||
function base64ToBytes (str) {
|
||
return base64.toByteArray(base64clean(str))
|
||
}
|
||
|
||
function blitBuffer (src, dst, offset, length) {
|
||
for (var i = 0; i < length; ++i) {
|
||
if ((i + offset >= dst.length) || (i >= src.length)) break
|
||
dst[i + offset] = src[i]
|
||
}
|
||
return i
|
||
}
|
||
|
||
function isnan (val) {
|
||
return val !== val // eslint-disable-line no-self-compare
|
||
}
|
||
|
||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(15)))
|
||
|
||
/***/ }),
|
||
/* 59 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var isSymbol = __webpack_require__(28);
|
||
|
||
/** Used as references for various `Number` constants. */
|
||
var INFINITY = 1 / 0;
|
||
|
||
/**
|
||
* Converts `value` to a string key if it's not a string or symbol.
|
||
*
|
||
* @private
|
||
* @param {*} value The value to inspect.
|
||
* @returns {string|symbol} Returns the key.
|
||
*/
|
||
function toKey(value) {
|
||
if (typeof value == 'string' || isSymbol(value)) {
|
||
return value;
|
||
}
|
||
var result = (value + '');
|
||
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
|
||
}
|
||
|
||
module.exports = toKey;
|
||
|
||
|
||
/***/ }),
|
||
/* 60 */,
|
||
/* 61 */,
|
||
/* 62 */,
|
||
/* 63 */,
|
||
/* 64 */,
|
||
/* 65 */,
|
||
/* 66 */,
|
||
/* 67 */,
|
||
/* 68 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = shallowEqual;
|
||
|
||
function shallowEqual(actual, expected) {
|
||
const keys = Object.keys(expected);
|
||
|
||
for (const key of keys) {
|
||
if (actual[key] !== expected[key]) {
|
||
return false;
|
||
}
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 69 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var ListCache = __webpack_require__(40),
|
||
stackClear = __webpack_require__(212),
|
||
stackDelete = __webpack_require__(213),
|
||
stackGet = __webpack_require__(214),
|
||
stackHas = __webpack_require__(215),
|
||
stackSet = __webpack_require__(216);
|
||
|
||
/**
|
||
* Creates a stack cache object to store key-value pairs.
|
||
*
|
||
* @private
|
||
* @constructor
|
||
* @param {Array} [entries] The key-value pairs to cache.
|
||
*/
|
||
function Stack(entries) {
|
||
var data = this.__data__ = new ListCache(entries);
|
||
this.size = data.size;
|
||
}
|
||
|
||
// Add methods to `Stack`.
|
||
Stack.prototype.clear = stackClear;
|
||
Stack.prototype['delete'] = stackDelete;
|
||
Stack.prototype.get = stackGet;
|
||
Stack.prototype.has = stackHas;
|
||
Stack.prototype.set = stackSet;
|
||
|
||
module.exports = Stack;
|
||
|
||
|
||
/***/ }),
|
||
/* 70 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var getNative = __webpack_require__(26),
|
||
root = __webpack_require__(8);
|
||
|
||
/* Built-in method references that are verified to be native. */
|
||
var Map = getNative(root, 'Map');
|
||
|
||
module.exports = Map;
|
||
|
||
|
||
/***/ }),
|
||
/* 71 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var Symbol = __webpack_require__(19);
|
||
|
||
/** Used for built-in method references. */
|
||
var objectProto = Object.prototype;
|
||
|
||
/** Used to check objects for own properties. */
|
||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||
|
||
/**
|
||
* Used to resolve the
|
||
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
||
* of values.
|
||
*/
|
||
var nativeObjectToString = objectProto.toString;
|
||
|
||
/** Built-in value references. */
|
||
var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
|
||
|
||
/**
|
||
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
||
*
|
||
* @private
|
||
* @param {*} value The value to query.
|
||
* @returns {string} Returns the raw `toStringTag`.
|
||
*/
|
||
function getRawTag(value) {
|
||
var isOwn = hasOwnProperty.call(value, symToStringTag),
|
||
tag = value[symToStringTag];
|
||
|
||
try {
|
||
value[symToStringTag] = undefined;
|
||
var unmasked = true;
|
||
} catch (e) {}
|
||
|
||
var result = nativeObjectToString.call(value);
|
||
if (unmasked) {
|
||
if (isOwn) {
|
||
value[symToStringTag] = tag;
|
||
} else {
|
||
delete value[symToStringTag];
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
|
||
module.exports = getRawTag;
|
||
|
||
|
||
/***/ }),
|
||
/* 72 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/** Used for built-in method references. */
|
||
var objectProto = Object.prototype;
|
||
|
||
/**
|
||
* Used to resolve the
|
||
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
||
* of values.
|
||
*/
|
||
var nativeObjectToString = objectProto.toString;
|
||
|
||
/**
|
||
* Converts `value` to a string using `Object.prototype.toString`.
|
||
*
|
||
* @private
|
||
* @param {*} value The value to convert.
|
||
* @returns {string} Returns the converted string.
|
||
*/
|
||
function objectToString(value) {
|
||
return nativeObjectToString.call(value);
|
||
}
|
||
|
||
module.exports = objectToString;
|
||
|
||
|
||
/***/ }),
|
||
/* 73 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var mapCacheClear = __webpack_require__(221),
|
||
mapCacheDelete = __webpack_require__(228),
|
||
mapCacheGet = __webpack_require__(230),
|
||
mapCacheHas = __webpack_require__(231),
|
||
mapCacheSet = __webpack_require__(232);
|
||
|
||
/**
|
||
* Creates a map cache object to store key-value pairs.
|
||
*
|
||
* @private
|
||
* @constructor
|
||
* @param {Array} [entries] The key-value pairs to cache.
|
||
*/
|
||
function MapCache(entries) {
|
||
var index = -1,
|
||
length = entries == null ? 0 : entries.length;
|
||
|
||
this.clear();
|
||
while (++index < length) {
|
||
var entry = entries[index];
|
||
this.set(entry[0], entry[1]);
|
||
}
|
||
}
|
||
|
||
// Add methods to `MapCache`.
|
||
MapCache.prototype.clear = mapCacheClear;
|
||
MapCache.prototype['delete'] = mapCacheDelete;
|
||
MapCache.prototype.get = mapCacheGet;
|
||
MapCache.prototype.has = mapCacheHas;
|
||
MapCache.prototype.set = mapCacheSet;
|
||
|
||
module.exports = MapCache;
|
||
|
||
|
||
/***/ }),
|
||
/* 74 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var baseIsArguments = __webpack_require__(237),
|
||
isObjectLike = __webpack_require__(11);
|
||
|
||
/** Used for built-in method references. */
|
||
var objectProto = Object.prototype;
|
||
|
||
/** Used to check objects for own properties. */
|
||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||
|
||
/** Built-in value references. */
|
||
var propertyIsEnumerable = objectProto.propertyIsEnumerable;
|
||
|
||
/**
|
||
* Checks if `value` is likely an `arguments` object.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 0.1.0
|
||
* @category Lang
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
||
* else `false`.
|
||
* @example
|
||
*
|
||
* _.isArguments(function() { return arguments; }());
|
||
* // => true
|
||
*
|
||
* _.isArguments([1, 2, 3]);
|
||
* // => false
|
||
*/
|
||
var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
|
||
return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
|
||
!propertyIsEnumerable.call(value, 'callee');
|
||
};
|
||
|
||
module.exports = isArguments;
|
||
|
||
|
||
/***/ }),
|
||
/* 75 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/** Used as references for various `Number` constants. */
|
||
var MAX_SAFE_INTEGER = 9007199254740991;
|
||
|
||
/** Used to detect unsigned integer values. */
|
||
var reIsUint = /^(?:0|[1-9]\d*)$/;
|
||
|
||
/**
|
||
* Checks if `value` is a valid array-like index.
|
||
*
|
||
* @private
|
||
* @param {*} value The value to check.
|
||
* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
|
||
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
|
||
*/
|
||
function isIndex(value, length) {
|
||
var type = typeof value;
|
||
length = length == null ? MAX_SAFE_INTEGER : length;
|
||
|
||
return !!length &&
|
||
(type == 'number' ||
|
||
(type != 'symbol' && reIsUint.test(value))) &&
|
||
(value > -1 && value % 1 == 0 && value < length);
|
||
}
|
||
|
||
module.exports = isIndex;
|
||
|
||
|
||
/***/ }),
|
||
/* 76 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var baseIsTypedArray = __webpack_require__(239),
|
||
baseUnary = __webpack_require__(49),
|
||
nodeUtil = __webpack_require__(50);
|
||
|
||
/* Node.js helper references. */
|
||
var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
|
||
|
||
/**
|
||
* Checks if `value` is classified as a typed array.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 3.0.0
|
||
* @category Lang
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
|
||
* @example
|
||
*
|
||
* _.isTypedArray(new Uint8Array);
|
||
* // => true
|
||
*
|
||
* _.isTypedArray([]);
|
||
* // => false
|
||
*/
|
||
var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
|
||
|
||
module.exports = isTypedArray;
|
||
|
||
|
||
/***/ }),
|
||
/* 77 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/** Used as references for various `Number` constants. */
|
||
var MAX_SAFE_INTEGER = 9007199254740991;
|
||
|
||
/**
|
||
* Checks if `value` is a valid array-like length.
|
||
*
|
||
* **Note:** This method is loosely based on
|
||
* [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 4.0.0
|
||
* @category Lang
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
|
||
* @example
|
||
*
|
||
* _.isLength(3);
|
||
* // => true
|
||
*
|
||
* _.isLength(Number.MIN_VALUE);
|
||
* // => false
|
||
*
|
||
* _.isLength(Infinity);
|
||
* // => false
|
||
*
|
||
* _.isLength('3');
|
||
* // => false
|
||
*/
|
||
function isLength(value) {
|
||
return typeof value == 'number' &&
|
||
value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
||
}
|
||
|
||
module.exports = isLength;
|
||
|
||
|
||
/***/ }),
|
||
/* 78 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var arrayFilter = __webpack_require__(247),
|
||
stubArray = __webpack_require__(128);
|
||
|
||
/** Used for built-in method references. */
|
||
var objectProto = Object.prototype;
|
||
|
||
/** Built-in value references. */
|
||
var propertyIsEnumerable = objectProto.propertyIsEnumerable;
|
||
|
||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||
var nativeGetSymbols = Object.getOwnPropertySymbols;
|
||
|
||
/**
|
||
* Creates an array of the own enumerable symbols of `object`.
|
||
*
|
||
* @private
|
||
* @param {Object} object The object to query.
|
||
* @returns {Array} Returns the array of symbols.
|
||
*/
|
||
var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
|
||
if (object == null) {
|
||
return [];
|
||
}
|
||
object = Object(object);
|
||
return arrayFilter(nativeGetSymbols(object), function(symbol) {
|
||
return propertyIsEnumerable.call(object, symbol);
|
||
});
|
||
};
|
||
|
||
module.exports = getSymbols;
|
||
|
||
|
||
/***/ }),
|
||
/* 79 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var overArg = __webpack_require__(126);
|
||
|
||
/** Built-in value references. */
|
||
var getPrototype = overArg(Object.getPrototypeOf, Object);
|
||
|
||
module.exports = getPrototype;
|
||
|
||
|
||
/***/ }),
|
||
/* 80 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var Uint8Array = __webpack_require__(134);
|
||
|
||
/**
|
||
* Creates a clone of `arrayBuffer`.
|
||
*
|
||
* @private
|
||
* @param {ArrayBuffer} arrayBuffer The array buffer to clone.
|
||
* @returns {ArrayBuffer} Returns the cloned array buffer.
|
||
*/
|
||
function cloneArrayBuffer(arrayBuffer) {
|
||
var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
|
||
new Uint8Array(result).set(new Uint8Array(arrayBuffer));
|
||
return result;
|
||
}
|
||
|
||
module.exports = cloneArrayBuffer;
|
||
|
||
|
||
/***/ }),
|
||
/* 81 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.patternLikeCommon = exports.functionDeclarationCommon = exports.functionTypeAnnotationCommon = exports.functionCommon = void 0;
|
||
|
||
var _isValidIdentifier = _interopRequireDefault(__webpack_require__(30));
|
||
|
||
var _constants = __webpack_require__(27);
|
||
|
||
var _utils = _interopRequireWildcard(__webpack_require__(23));
|
||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
(0, _utils.default)("ArrayExpression", {
|
||
fields: {
|
||
elements: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeOrValueType)("null", "Expression", "SpreadElement"))),
|
||
default: []
|
||
}
|
||
},
|
||
visitor: ["elements"],
|
||
aliases: ["Expression"]
|
||
});
|
||
(0, _utils.default)("AssignmentExpression", {
|
||
fields: {
|
||
operator: {
|
||
validate: (0, _utils.assertValueType)("string")
|
||
},
|
||
left: {
|
||
validate: (0, _utils.assertNodeType)("LVal")
|
||
},
|
||
right: {
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
}
|
||
},
|
||
builder: ["operator", "left", "right"],
|
||
visitor: ["left", "right"],
|
||
aliases: ["Expression"]
|
||
});
|
||
(0, _utils.default)("BinaryExpression", {
|
||
builder: ["operator", "left", "right"],
|
||
fields: {
|
||
operator: {
|
||
validate: (0, _utils.assertOneOf)(..._constants.BINARY_OPERATORS)
|
||
},
|
||
left: {
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
},
|
||
right: {
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
}
|
||
},
|
||
visitor: ["left", "right"],
|
||
aliases: ["Binary", "Expression"]
|
||
});
|
||
(0, _utils.default)("InterpreterDirective", {
|
||
builder: ["value"],
|
||
fields: {
|
||
value: {
|
||
validate: (0, _utils.assertValueType)("string")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("Directive", {
|
||
visitor: ["value"],
|
||
fields: {
|
||
value: {
|
||
validate: (0, _utils.assertNodeType)("DirectiveLiteral")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("DirectiveLiteral", {
|
||
builder: ["value"],
|
||
fields: {
|
||
value: {
|
||
validate: (0, _utils.assertValueType)("string")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("BlockStatement", {
|
||
builder: ["body", "directives"],
|
||
visitor: ["directives", "body"],
|
||
fields: {
|
||
directives: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Directive"))),
|
||
default: []
|
||
},
|
||
body: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Statement")))
|
||
}
|
||
},
|
||
aliases: ["Scopable", "BlockParent", "Block", "Statement"]
|
||
});
|
||
(0, _utils.default)("BreakStatement", {
|
||
visitor: ["label"],
|
||
fields: {
|
||
label: {
|
||
validate: (0, _utils.assertNodeType)("Identifier"),
|
||
optional: true
|
||
}
|
||
},
|
||
aliases: ["Statement", "Terminatorless", "CompletionStatement"]
|
||
});
|
||
(0, _utils.default)("CallExpression", {
|
||
visitor: ["callee", "arguments", "typeParameters", "typeArguments"],
|
||
builder: ["callee", "arguments"],
|
||
aliases: ["Expression"],
|
||
fields: {
|
||
callee: {
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
},
|
||
arguments: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression", "SpreadElement", "JSXNamespacedName", "ArgumentPlaceholder")))
|
||
},
|
||
optional: {
|
||
validate: (0, _utils.assertOneOf)(true, false),
|
||
optional: true
|
||
},
|
||
typeArguments: {
|
||
validate: (0, _utils.assertNodeType)("TypeParameterInstantiation"),
|
||
optional: true
|
||
},
|
||
typeParameters: {
|
||
validate: (0, _utils.assertNodeType)("TSTypeParameterInstantiation"),
|
||
optional: true
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("CatchClause", {
|
||
visitor: ["param", "body"],
|
||
fields: {
|
||
param: {
|
||
validate: (0, _utils.assertNodeType)("Identifier"),
|
||
optional: true
|
||
},
|
||
body: {
|
||
validate: (0, _utils.assertNodeType)("BlockStatement")
|
||
}
|
||
},
|
||
aliases: ["Scopable", "BlockParent"]
|
||
});
|
||
(0, _utils.default)("ConditionalExpression", {
|
||
visitor: ["test", "consequent", "alternate"],
|
||
fields: {
|
||
test: {
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
},
|
||
consequent: {
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
},
|
||
alternate: {
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
}
|
||
},
|
||
aliases: ["Expression", "Conditional"]
|
||
});
|
||
(0, _utils.default)("ContinueStatement", {
|
||
visitor: ["label"],
|
||
fields: {
|
||
label: {
|
||
validate: (0, _utils.assertNodeType)("Identifier"),
|
||
optional: true
|
||
}
|
||
},
|
||
aliases: ["Statement", "Terminatorless", "CompletionStatement"]
|
||
});
|
||
(0, _utils.default)("DebuggerStatement", {
|
||
aliases: ["Statement"]
|
||
});
|
||
(0, _utils.default)("DoWhileStatement", {
|
||
visitor: ["test", "body"],
|
||
fields: {
|
||
test: {
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
},
|
||
body: {
|
||
validate: (0, _utils.assertNodeType)("Statement")
|
||
}
|
||
},
|
||
aliases: ["Statement", "BlockParent", "Loop", "While", "Scopable"]
|
||
});
|
||
(0, _utils.default)("EmptyStatement", {
|
||
aliases: ["Statement"]
|
||
});
|
||
(0, _utils.default)("ExpressionStatement", {
|
||
visitor: ["expression"],
|
||
fields: {
|
||
expression: {
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
}
|
||
},
|
||
aliases: ["Statement", "ExpressionWrapper"]
|
||
});
|
||
(0, _utils.default)("File", {
|
||
builder: ["program", "comments", "tokens"],
|
||
visitor: ["program"],
|
||
fields: {
|
||
program: {
|
||
validate: (0, _utils.assertNodeType)("Program")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("ForInStatement", {
|
||
visitor: ["left", "right", "body"],
|
||
aliases: ["Scopable", "Statement", "For", "BlockParent", "Loop", "ForXStatement"],
|
||
fields: {
|
||
left: {
|
||
validate: (0, _utils.assertNodeType)("VariableDeclaration", "LVal")
|
||
},
|
||
right: {
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
},
|
||
body: {
|
||
validate: (0, _utils.assertNodeType)("Statement")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("ForStatement", {
|
||
visitor: ["init", "test", "update", "body"],
|
||
aliases: ["Scopable", "Statement", "For", "BlockParent", "Loop"],
|
||
fields: {
|
||
init: {
|
||
validate: (0, _utils.assertNodeType)("VariableDeclaration", "Expression"),
|
||
optional: true
|
||
},
|
||
test: {
|
||
validate: (0, _utils.assertNodeType)("Expression"),
|
||
optional: true
|
||
},
|
||
update: {
|
||
validate: (0, _utils.assertNodeType)("Expression"),
|
||
optional: true
|
||
},
|
||
body: {
|
||
validate: (0, _utils.assertNodeType)("Statement")
|
||
}
|
||
}
|
||
});
|
||
const functionCommon = {
|
||
params: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Identifier", "Pattern", "RestElement", "TSParameterProperty")))
|
||
},
|
||
generator: {
|
||
default: false,
|
||
validate: (0, _utils.assertValueType)("boolean")
|
||
},
|
||
async: {
|
||
validate: (0, _utils.assertValueType)("boolean"),
|
||
default: false
|
||
}
|
||
};
|
||
exports.functionCommon = functionCommon;
|
||
const functionTypeAnnotationCommon = {
|
||
returnType: {
|
||
validate: (0, _utils.assertNodeType)("TypeAnnotation", "TSTypeAnnotation", "Noop"),
|
||
optional: true
|
||
},
|
||
typeParameters: {
|
||
validate: (0, _utils.assertNodeType)("TypeParameterDeclaration", "TSTypeParameterDeclaration", "Noop"),
|
||
optional: true
|
||
}
|
||
};
|
||
exports.functionTypeAnnotationCommon = functionTypeAnnotationCommon;
|
||
const functionDeclarationCommon = Object.assign({}, functionCommon, {
|
||
declare: {
|
||
validate: (0, _utils.assertValueType)("boolean"),
|
||
optional: true
|
||
},
|
||
id: {
|
||
validate: (0, _utils.assertNodeType)("Identifier"),
|
||
optional: true
|
||
}
|
||
});
|
||
exports.functionDeclarationCommon = functionDeclarationCommon;
|
||
(0, _utils.default)("FunctionDeclaration", {
|
||
builder: ["id", "params", "body", "generator", "async"],
|
||
visitor: ["id", "params", "body", "returnType", "typeParameters"],
|
||
fields: Object.assign({}, functionDeclarationCommon, functionTypeAnnotationCommon, {
|
||
body: {
|
||
validate: (0, _utils.assertNodeType)("BlockStatement")
|
||
}
|
||
}),
|
||
aliases: ["Scopable", "Function", "BlockParent", "FunctionParent", "Statement", "Pureish", "Declaration"]
|
||
});
|
||
(0, _utils.default)("FunctionExpression", {
|
||
inherits: "FunctionDeclaration",
|
||
aliases: ["Scopable", "Function", "BlockParent", "FunctionParent", "Expression", "Pureish"],
|
||
fields: Object.assign({}, functionCommon, functionTypeAnnotationCommon, {
|
||
id: {
|
||
validate: (0, _utils.assertNodeType)("Identifier"),
|
||
optional: true
|
||
},
|
||
body: {
|
||
validate: (0, _utils.assertNodeType)("BlockStatement")
|
||
}
|
||
})
|
||
});
|
||
const patternLikeCommon = {
|
||
typeAnnotation: {
|
||
validate: (0, _utils.assertNodeType)("TypeAnnotation", "TSTypeAnnotation", "Noop"),
|
||
optional: true
|
||
},
|
||
decorators: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator")))
|
||
}
|
||
};
|
||
exports.patternLikeCommon = patternLikeCommon;
|
||
(0, _utils.default)("Identifier", {
|
||
builder: ["name"],
|
||
visitor: ["typeAnnotation", "decorators"],
|
||
aliases: ["Expression", "PatternLike", "LVal", "TSEntityName"],
|
||
fields: Object.assign({}, patternLikeCommon, {
|
||
name: {
|
||
validate: (0, _utils.chain)(function (node, key, val) {
|
||
if (!(0, _isValidIdentifier.default)(val)) {}
|
||
}, (0, _utils.assertValueType)("string"))
|
||
},
|
||
optional: {
|
||
validate: (0, _utils.assertValueType)("boolean"),
|
||
optional: true
|
||
}
|
||
})
|
||
});
|
||
(0, _utils.default)("IfStatement", {
|
||
visitor: ["test", "consequent", "alternate"],
|
||
aliases: ["Statement", "Conditional"],
|
||
fields: {
|
||
test: {
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
},
|
||
consequent: {
|
||
validate: (0, _utils.assertNodeType)("Statement")
|
||
},
|
||
alternate: {
|
||
optional: true,
|
||
validate: (0, _utils.assertNodeType)("Statement")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("LabeledStatement", {
|
||
visitor: ["label", "body"],
|
||
aliases: ["Statement"],
|
||
fields: {
|
||
label: {
|
||
validate: (0, _utils.assertNodeType)("Identifier")
|
||
},
|
||
body: {
|
||
validate: (0, _utils.assertNodeType)("Statement")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("StringLiteral", {
|
||
builder: ["value"],
|
||
fields: {
|
||
value: {
|
||
validate: (0, _utils.assertValueType)("string")
|
||
}
|
||
},
|
||
aliases: ["Expression", "Pureish", "Literal", "Immutable"]
|
||
});
|
||
(0, _utils.default)("NumericLiteral", {
|
||
builder: ["value"],
|
||
deprecatedAlias: "NumberLiteral",
|
||
fields: {
|
||
value: {
|
||
validate: (0, _utils.assertValueType)("number")
|
||
}
|
||
},
|
||
aliases: ["Expression", "Pureish", "Literal", "Immutable"]
|
||
});
|
||
(0, _utils.default)("NullLiteral", {
|
||
aliases: ["Expression", "Pureish", "Literal", "Immutable"]
|
||
});
|
||
(0, _utils.default)("BooleanLiteral", {
|
||
builder: ["value"],
|
||
fields: {
|
||
value: {
|
||
validate: (0, _utils.assertValueType)("boolean")
|
||
}
|
||
},
|
||
aliases: ["Expression", "Pureish", "Literal", "Immutable"]
|
||
});
|
||
(0, _utils.default)("RegExpLiteral", {
|
||
builder: ["pattern", "flags"],
|
||
deprecatedAlias: "RegexLiteral",
|
||
aliases: ["Expression", "Literal"],
|
||
fields: {
|
||
pattern: {
|
||
validate: (0, _utils.assertValueType)("string")
|
||
},
|
||
flags: {
|
||
validate: (0, _utils.assertValueType)("string"),
|
||
default: ""
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("LogicalExpression", {
|
||
builder: ["operator", "left", "right"],
|
||
visitor: ["left", "right"],
|
||
aliases: ["Binary", "Expression"],
|
||
fields: {
|
||
operator: {
|
||
validate: (0, _utils.assertOneOf)(..._constants.LOGICAL_OPERATORS)
|
||
},
|
||
left: {
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
},
|
||
right: {
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("MemberExpression", {
|
||
builder: ["object", "property", "computed", "optional"],
|
||
visitor: ["object", "property"],
|
||
aliases: ["Expression", "LVal"],
|
||
fields: {
|
||
object: {
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
},
|
||
property: {
|
||
validate: function () {
|
||
const normal = (0, _utils.assertNodeType)("Identifier", "PrivateName");
|
||
const computed = (0, _utils.assertNodeType)("Expression");
|
||
return function (node, key, val) {
|
||
const validator = node.computed ? computed : normal;
|
||
validator(node, key, val);
|
||
};
|
||
}()
|
||
},
|
||
computed: {
|
||
default: false
|
||
},
|
||
optional: {
|
||
validate: (0, _utils.assertOneOf)(true, false),
|
||
optional: true
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("NewExpression", {
|
||
inherits: "CallExpression"
|
||
});
|
||
(0, _utils.default)("Program", {
|
||
visitor: ["directives", "body"],
|
||
builder: ["body", "directives", "sourceType", "interpreter"],
|
||
fields: {
|
||
sourceFile: {
|
||
validate: (0, _utils.assertValueType)("string")
|
||
},
|
||
sourceType: {
|
||
validate: (0, _utils.assertOneOf)("script", "module"),
|
||
default: "script"
|
||
},
|
||
interpreter: {
|
||
validate: (0, _utils.assertNodeType)("InterpreterDirective"),
|
||
default: null,
|
||
optional: true
|
||
},
|
||
directives: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Directive"))),
|
||
default: []
|
||
},
|
||
body: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Statement")))
|
||
}
|
||
},
|
||
aliases: ["Scopable", "BlockParent", "Block"]
|
||
});
|
||
(0, _utils.default)("ObjectExpression", {
|
||
visitor: ["properties"],
|
||
aliases: ["Expression"],
|
||
fields: {
|
||
properties: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ObjectMethod", "ObjectProperty", "SpreadElement")))
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("ObjectMethod", {
|
||
builder: ["kind", "key", "params", "body", "computed"],
|
||
fields: Object.assign({}, functionCommon, functionTypeAnnotationCommon, {
|
||
kind: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("string"), (0, _utils.assertOneOf)("method", "get", "set")),
|
||
default: "method"
|
||
},
|
||
computed: {
|
||
validate: (0, _utils.assertValueType)("boolean"),
|
||
default: false
|
||
},
|
||
key: {
|
||
validate: function () {
|
||
const normal = (0, _utils.assertNodeType)("Identifier", "StringLiteral", "NumericLiteral");
|
||
const computed = (0, _utils.assertNodeType)("Expression");
|
||
return function (node, key, val) {
|
||
const validator = node.computed ? computed : normal;
|
||
validator(node, key, val);
|
||
};
|
||
}()
|
||
},
|
||
decorators: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator")))
|
||
},
|
||
body: {
|
||
validate: (0, _utils.assertNodeType)("BlockStatement")
|
||
}
|
||
}),
|
||
visitor: ["key", "params", "body", "decorators", "returnType", "typeParameters"],
|
||
aliases: ["UserWhitespacable", "Function", "Scopable", "BlockParent", "FunctionParent", "Method", "ObjectMember"]
|
||
});
|
||
(0, _utils.default)("ObjectProperty", {
|
||
builder: ["key", "value", "computed", "shorthand", "decorators"],
|
||
fields: {
|
||
computed: {
|
||
validate: (0, _utils.assertValueType)("boolean"),
|
||
default: false
|
||
},
|
||
key: {
|
||
validate: function () {
|
||
const normal = (0, _utils.assertNodeType)("Identifier", "StringLiteral", "NumericLiteral");
|
||
const computed = (0, _utils.assertNodeType)("Expression");
|
||
return function (node, key, val) {
|
||
const validator = node.computed ? computed : normal;
|
||
validator(node, key, val);
|
||
};
|
||
}()
|
||
},
|
||
value: {
|
||
validate: (0, _utils.assertNodeType)("Expression", "PatternLike")
|
||
},
|
||
shorthand: {
|
||
validate: (0, _utils.assertValueType)("boolean"),
|
||
default: false
|
||
},
|
||
decorators: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))),
|
||
optional: true
|
||
}
|
||
},
|
||
visitor: ["key", "value", "decorators"],
|
||
aliases: ["UserWhitespacable", "Property", "ObjectMember"]
|
||
});
|
||
(0, _utils.default)("RestElement", {
|
||
visitor: ["argument", "typeAnnotation"],
|
||
builder: ["argument"],
|
||
aliases: ["LVal", "PatternLike"],
|
||
deprecatedAlias: "RestProperty",
|
||
fields: Object.assign({}, patternLikeCommon, {
|
||
argument: {
|
||
validate: (0, _utils.assertNodeType)("LVal")
|
||
}
|
||
})
|
||
});
|
||
(0, _utils.default)("ReturnStatement", {
|
||
visitor: ["argument"],
|
||
aliases: ["Statement", "Terminatorless", "CompletionStatement"],
|
||
fields: {
|
||
argument: {
|
||
validate: (0, _utils.assertNodeType)("Expression"),
|
||
optional: true
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("SequenceExpression", {
|
||
visitor: ["expressions"],
|
||
fields: {
|
||
expressions: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression")))
|
||
}
|
||
},
|
||
aliases: ["Expression"]
|
||
});
|
||
(0, _utils.default)("ParenthesizedExpression", {
|
||
visitor: ["expression"],
|
||
aliases: ["Expression", "ExpressionWrapper"],
|
||
fields: {
|
||
expression: {
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("SwitchCase", {
|
||
visitor: ["test", "consequent"],
|
||
fields: {
|
||
test: {
|
||
validate: (0, _utils.assertNodeType)("Expression"),
|
||
optional: true
|
||
},
|
||
consequent: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Statement")))
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("SwitchStatement", {
|
||
visitor: ["discriminant", "cases"],
|
||
aliases: ["Statement", "BlockParent", "Scopable"],
|
||
fields: {
|
||
discriminant: {
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
},
|
||
cases: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("SwitchCase")))
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("ThisExpression", {
|
||
aliases: ["Expression"]
|
||
});
|
||
(0, _utils.default)("ThrowStatement", {
|
||
visitor: ["argument"],
|
||
aliases: ["Statement", "Terminatorless", "CompletionStatement"],
|
||
fields: {
|
||
argument: {
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("TryStatement", {
|
||
visitor: ["block", "handler", "finalizer"],
|
||
aliases: ["Statement"],
|
||
fields: {
|
||
block: {
|
||
validate: (0, _utils.assertNodeType)("BlockStatement")
|
||
},
|
||
handler: {
|
||
optional: true,
|
||
validate: (0, _utils.assertNodeType)("CatchClause")
|
||
},
|
||
finalizer: {
|
||
optional: true,
|
||
validate: (0, _utils.assertNodeType)("BlockStatement")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("UnaryExpression", {
|
||
builder: ["operator", "argument", "prefix"],
|
||
fields: {
|
||
prefix: {
|
||
default: true
|
||
},
|
||
argument: {
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
},
|
||
operator: {
|
||
validate: (0, _utils.assertOneOf)(..._constants.UNARY_OPERATORS)
|
||
}
|
||
},
|
||
visitor: ["argument"],
|
||
aliases: ["UnaryLike", "Expression"]
|
||
});
|
||
(0, _utils.default)("UpdateExpression", {
|
||
builder: ["operator", "argument", "prefix"],
|
||
fields: {
|
||
prefix: {
|
||
default: false
|
||
},
|
||
argument: {
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
},
|
||
operator: {
|
||
validate: (0, _utils.assertOneOf)(..._constants.UPDATE_OPERATORS)
|
||
}
|
||
},
|
||
visitor: ["argument"],
|
||
aliases: ["Expression"]
|
||
});
|
||
(0, _utils.default)("VariableDeclaration", {
|
||
builder: ["kind", "declarations"],
|
||
visitor: ["declarations"],
|
||
aliases: ["Statement", "Declaration"],
|
||
fields: {
|
||
declare: {
|
||
validate: (0, _utils.assertValueType)("boolean"),
|
||
optional: true
|
||
},
|
||
kind: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("string"), (0, _utils.assertOneOf)("var", "let", "const"))
|
||
},
|
||
declarations: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("VariableDeclarator")))
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("VariableDeclarator", {
|
||
visitor: ["id", "init"],
|
||
fields: {
|
||
id: {
|
||
validate: (0, _utils.assertNodeType)("LVal")
|
||
},
|
||
definite: {
|
||
optional: true,
|
||
validate: (0, _utils.assertValueType)("boolean")
|
||
},
|
||
init: {
|
||
optional: true,
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("WhileStatement", {
|
||
visitor: ["test", "body"],
|
||
aliases: ["Statement", "BlockParent", "Loop", "While", "Scopable"],
|
||
fields: {
|
||
test: {
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
},
|
||
body: {
|
||
validate: (0, _utils.assertNodeType)("BlockStatement", "Statement")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("WithStatement", {
|
||
visitor: ["object", "body"],
|
||
aliases: ["Statement"],
|
||
fields: {
|
||
object: {
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
},
|
||
body: {
|
||
validate: (0, _utils.assertNodeType)("BlockStatement", "Statement")
|
||
}
|
||
}
|
||
});
|
||
|
||
/***/ }),
|
||
/* 82 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = is;
|
||
|
||
var _shallowEqual = _interopRequireDefault(__webpack_require__(68));
|
||
|
||
var _isType = _interopRequireDefault(__webpack_require__(83));
|
||
|
||
var _isPlaceholderType = _interopRequireDefault(__webpack_require__(517));
|
||
|
||
var _definitions = __webpack_require__(16);
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function is(type, node, opts) {
|
||
if (!node) return false;
|
||
const matches = (0, _isType.default)(node.type, type);
|
||
|
||
if (!matches) {
|
||
if (!opts && node.type === "Placeholder" && type in _definitions.FLIPPED_ALIAS_KEYS) {
|
||
return (0, _isPlaceholderType.default)(node.expectedNode, type);
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
if (typeof opts === "undefined") {
|
||
return true;
|
||
} else {
|
||
return (0, _shallowEqual.default)(node, opts);
|
||
}
|
||
}
|
||
|
||
/***/ }),
|
||
/* 83 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = isType;
|
||
|
||
var _definitions = __webpack_require__(16);
|
||
|
||
function isType(nodeType, targetType) {
|
||
if (nodeType === targetType) return true;
|
||
if (_definitions.ALIAS_KEYS[targetType]) return false;
|
||
const aliases = _definitions.FLIPPED_ALIAS_KEYS[targetType];
|
||
|
||
if (aliases) {
|
||
if (aliases[0] === nodeType) return true;
|
||
|
||
for (const alias of aliases) {
|
||
if (nodeType === alias) return true;
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 84 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.classMethodOrDeclareMethodCommon = exports.classMethodOrPropertyCommon = void 0;
|
||
|
||
var _utils = _interopRequireWildcard(__webpack_require__(23));
|
||
|
||
var _core = __webpack_require__(81);
|
||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||
|
||
(0, _utils.default)("AssignmentPattern", {
|
||
visitor: ["left", "right", "decorators"],
|
||
builder: ["left", "right"],
|
||
aliases: ["Pattern", "PatternLike", "LVal"],
|
||
fields: Object.assign({}, _core.patternLikeCommon, {
|
||
left: {
|
||
validate: (0, _utils.assertNodeType)("Identifier", "ObjectPattern", "ArrayPattern", "MemberExpression")
|
||
},
|
||
right: {
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
},
|
||
decorators: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator")))
|
||
}
|
||
})
|
||
});
|
||
(0, _utils.default)("ArrayPattern", {
|
||
visitor: ["elements", "typeAnnotation"],
|
||
builder: ["elements"],
|
||
aliases: ["Pattern", "PatternLike", "LVal"],
|
||
fields: Object.assign({}, _core.patternLikeCommon, {
|
||
elements: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("PatternLike")))
|
||
},
|
||
decorators: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator")))
|
||
}
|
||
})
|
||
});
|
||
(0, _utils.default)("ArrowFunctionExpression", {
|
||
builder: ["params", "body", "async"],
|
||
visitor: ["params", "body", "returnType", "typeParameters"],
|
||
aliases: ["Scopable", "Function", "BlockParent", "FunctionParent", "Expression", "Pureish"],
|
||
fields: Object.assign({}, _core.functionCommon, _core.functionTypeAnnotationCommon, {
|
||
expression: {
|
||
validate: (0, _utils.assertValueType)("boolean")
|
||
},
|
||
body: {
|
||
validate: (0, _utils.assertNodeType)("BlockStatement", "Expression")
|
||
}
|
||
})
|
||
});
|
||
(0, _utils.default)("ClassBody", {
|
||
visitor: ["body"],
|
||
fields: {
|
||
body: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ClassMethod", "ClassPrivateMethod", "ClassProperty", "ClassPrivateProperty", "TSDeclareMethod", "TSIndexSignature")))
|
||
}
|
||
}
|
||
});
|
||
const classCommon = {
|
||
typeParameters: {
|
||
validate: (0, _utils.assertNodeType)("TypeParameterDeclaration", "TSTypeParameterDeclaration", "Noop"),
|
||
optional: true
|
||
},
|
||
body: {
|
||
validate: (0, _utils.assertNodeType)("ClassBody")
|
||
},
|
||
superClass: {
|
||
optional: true,
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
},
|
||
superTypeParameters: {
|
||
validate: (0, _utils.assertNodeType)("TypeParameterInstantiation", "TSTypeParameterInstantiation"),
|
||
optional: true
|
||
},
|
||
implements: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("TSExpressionWithTypeArguments", "ClassImplements"))),
|
||
optional: true
|
||
}
|
||
};
|
||
(0, _utils.default)("ClassDeclaration", {
|
||
builder: ["id", "superClass", "body", "decorators"],
|
||
visitor: ["id", "body", "superClass", "mixins", "typeParameters", "superTypeParameters", "implements", "decorators"],
|
||
aliases: ["Scopable", "Class", "Statement", "Declaration", "Pureish"],
|
||
fields: Object.assign({}, classCommon, {
|
||
declare: {
|
||
validate: (0, _utils.assertValueType)("boolean"),
|
||
optional: true
|
||
},
|
||
abstract: {
|
||
validate: (0, _utils.assertValueType)("boolean"),
|
||
optional: true
|
||
},
|
||
id: {
|
||
validate: (0, _utils.assertNodeType)("Identifier"),
|
||
optional: true
|
||
},
|
||
decorators: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))),
|
||
optional: true
|
||
}
|
||
})
|
||
});
|
||
(0, _utils.default)("ClassExpression", {
|
||
inherits: "ClassDeclaration",
|
||
aliases: ["Scopable", "Class", "Expression", "Pureish"],
|
||
fields: Object.assign({}, classCommon, {
|
||
id: {
|
||
optional: true,
|
||
validate: (0, _utils.assertNodeType)("Identifier")
|
||
},
|
||
body: {
|
||
validate: (0, _utils.assertNodeType)("ClassBody")
|
||
},
|
||
superClass: {
|
||
optional: true,
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
},
|
||
decorators: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))),
|
||
optional: true
|
||
}
|
||
})
|
||
});
|
||
(0, _utils.default)("ExportAllDeclaration", {
|
||
visitor: ["source"],
|
||
aliases: ["Statement", "Declaration", "ModuleDeclaration", "ExportDeclaration"],
|
||
fields: {
|
||
source: {
|
||
validate: (0, _utils.assertNodeType)("StringLiteral")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("ExportDefaultDeclaration", {
|
||
visitor: ["declaration"],
|
||
aliases: ["Statement", "Declaration", "ModuleDeclaration", "ExportDeclaration"],
|
||
fields: {
|
||
declaration: {
|
||
validate: (0, _utils.assertNodeType)("FunctionDeclaration", "TSDeclareFunction", "ClassDeclaration", "Expression")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("ExportNamedDeclaration", {
|
||
visitor: ["declaration", "specifiers", "source"],
|
||
aliases: ["Statement", "Declaration", "ModuleDeclaration", "ExportDeclaration"],
|
||
fields: {
|
||
declaration: {
|
||
validate: (0, _utils.assertNodeType)("Declaration"),
|
||
optional: true
|
||
},
|
||
specifiers: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ExportSpecifier", "ExportDefaultSpecifier", "ExportNamespaceSpecifier")))
|
||
},
|
||
source: {
|
||
validate: (0, _utils.assertNodeType)("StringLiteral"),
|
||
optional: true
|
||
},
|
||
exportKind: (0, _utils.validateOptional)((0, _utils.assertOneOf)("type", "value"))
|
||
}
|
||
});
|
||
(0, _utils.default)("ExportSpecifier", {
|
||
visitor: ["local", "exported"],
|
||
aliases: ["ModuleSpecifier"],
|
||
fields: {
|
||
local: {
|
||
validate: (0, _utils.assertNodeType)("Identifier")
|
||
},
|
||
exported: {
|
||
validate: (0, _utils.assertNodeType)("Identifier")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("ForOfStatement", {
|
||
visitor: ["left", "right", "body"],
|
||
aliases: ["Scopable", "Statement", "For", "BlockParent", "Loop", "ForXStatement"],
|
||
fields: {
|
||
left: {
|
||
validate: (0, _utils.assertNodeType)("VariableDeclaration", "LVal")
|
||
},
|
||
right: {
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
},
|
||
body: {
|
||
validate: (0, _utils.assertNodeType)("Statement")
|
||
},
|
||
await: {
|
||
default: false,
|
||
validate: (0, _utils.assertValueType)("boolean")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("ImportDeclaration", {
|
||
visitor: ["specifiers", "source"],
|
||
aliases: ["Statement", "Declaration", "ModuleDeclaration"],
|
||
fields: {
|
||
specifiers: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ImportSpecifier", "ImportDefaultSpecifier", "ImportNamespaceSpecifier")))
|
||
},
|
||
source: {
|
||
validate: (0, _utils.assertNodeType)("StringLiteral")
|
||
},
|
||
importKind: {
|
||
validate: (0, _utils.assertOneOf)("type", "typeof", "value"),
|
||
optional: true
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("ImportDefaultSpecifier", {
|
||
visitor: ["local"],
|
||
aliases: ["ModuleSpecifier"],
|
||
fields: {
|
||
local: {
|
||
validate: (0, _utils.assertNodeType)("Identifier")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("ImportNamespaceSpecifier", {
|
||
visitor: ["local"],
|
||
aliases: ["ModuleSpecifier"],
|
||
fields: {
|
||
local: {
|
||
validate: (0, _utils.assertNodeType)("Identifier")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("ImportSpecifier", {
|
||
visitor: ["local", "imported"],
|
||
aliases: ["ModuleSpecifier"],
|
||
fields: {
|
||
local: {
|
||
validate: (0, _utils.assertNodeType)("Identifier")
|
||
},
|
||
imported: {
|
||
validate: (0, _utils.assertNodeType)("Identifier")
|
||
},
|
||
importKind: {
|
||
validate: (0, _utils.assertOneOf)("type", "typeof"),
|
||
optional: true
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("MetaProperty", {
|
||
visitor: ["meta", "property"],
|
||
aliases: ["Expression"],
|
||
fields: {
|
||
meta: {
|
||
validate: (0, _utils.assertNodeType)("Identifier")
|
||
},
|
||
property: {
|
||
validate: (0, _utils.assertNodeType)("Identifier")
|
||
}
|
||
}
|
||
});
|
||
const classMethodOrPropertyCommon = {
|
||
abstract: {
|
||
validate: (0, _utils.assertValueType)("boolean"),
|
||
optional: true
|
||
},
|
||
accessibility: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("string"), (0, _utils.assertOneOf)("public", "private", "protected")),
|
||
optional: true
|
||
},
|
||
static: {
|
||
validate: (0, _utils.assertValueType)("boolean"),
|
||
optional: true
|
||
},
|
||
computed: {
|
||
default: false,
|
||
validate: (0, _utils.assertValueType)("boolean")
|
||
},
|
||
optional: {
|
||
validate: (0, _utils.assertValueType)("boolean"),
|
||
optional: true
|
||
},
|
||
key: {
|
||
validate: (0, _utils.chain)(function () {
|
||
const normal = (0, _utils.assertNodeType)("Identifier", "StringLiteral", "NumericLiteral");
|
||
const computed = (0, _utils.assertNodeType)("Expression");
|
||
return function (node, key, val) {
|
||
const validator = node.computed ? computed : normal;
|
||
validator(node, key, val);
|
||
};
|
||
}(), (0, _utils.assertNodeType)("Identifier", "StringLiteral", "NumericLiteral", "Expression"))
|
||
}
|
||
};
|
||
exports.classMethodOrPropertyCommon = classMethodOrPropertyCommon;
|
||
const classMethodOrDeclareMethodCommon = Object.assign({}, _core.functionCommon, classMethodOrPropertyCommon, {
|
||
kind: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("string"), (0, _utils.assertOneOf)("get", "set", "method", "constructor")),
|
||
default: "method"
|
||
},
|
||
access: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("string"), (0, _utils.assertOneOf)("public", "private", "protected")),
|
||
optional: true
|
||
},
|
||
decorators: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))),
|
||
optional: true
|
||
}
|
||
});
|
||
exports.classMethodOrDeclareMethodCommon = classMethodOrDeclareMethodCommon;
|
||
(0, _utils.default)("ClassMethod", {
|
||
aliases: ["Function", "Scopable", "BlockParent", "FunctionParent", "Method"],
|
||
builder: ["kind", "key", "params", "body", "computed", "static"],
|
||
visitor: ["key", "params", "body", "decorators", "returnType", "typeParameters"],
|
||
fields: Object.assign({}, classMethodOrDeclareMethodCommon, _core.functionTypeAnnotationCommon, {
|
||
body: {
|
||
validate: (0, _utils.assertNodeType)("BlockStatement")
|
||
}
|
||
})
|
||
});
|
||
(0, _utils.default)("ObjectPattern", {
|
||
visitor: ["properties", "typeAnnotation", "decorators"],
|
||
builder: ["properties"],
|
||
aliases: ["Pattern", "PatternLike", "LVal"],
|
||
fields: Object.assign({}, _core.patternLikeCommon, {
|
||
properties: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("RestElement", "ObjectProperty")))
|
||
}
|
||
})
|
||
});
|
||
(0, _utils.default)("SpreadElement", {
|
||
visitor: ["argument"],
|
||
aliases: ["UnaryLike"],
|
||
deprecatedAlias: "SpreadProperty",
|
||
fields: {
|
||
argument: {
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("Super", {
|
||
aliases: ["Expression"]
|
||
});
|
||
(0, _utils.default)("TaggedTemplateExpression", {
|
||
visitor: ["tag", "quasi"],
|
||
aliases: ["Expression"],
|
||
fields: {
|
||
tag: {
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
},
|
||
quasi: {
|
||
validate: (0, _utils.assertNodeType)("TemplateLiteral")
|
||
},
|
||
typeParameters: {
|
||
validate: (0, _utils.assertNodeType)("TypeParameterInstantiation", "TSTypeParameterInstantiation"),
|
||
optional: true
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("TemplateElement", {
|
||
builder: ["value", "tail"],
|
||
fields: {
|
||
value: {
|
||
validate: (0, _utils.assertShape)({
|
||
raw: {
|
||
validate: (0, _utils.assertValueType)("string")
|
||
},
|
||
cooked: {
|
||
validate: (0, _utils.assertValueType)("string"),
|
||
optional: true
|
||
}
|
||
})
|
||
},
|
||
tail: {
|
||
validate: (0, _utils.assertValueType)("boolean"),
|
||
default: false
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("TemplateLiteral", {
|
||
visitor: ["quasis", "expressions"],
|
||
aliases: ["Expression", "Literal"],
|
||
fields: {
|
||
quasis: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("TemplateElement")))
|
||
},
|
||
expressions: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression")))
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("YieldExpression", {
|
||
builder: ["argument", "delegate"],
|
||
visitor: ["argument"],
|
||
aliases: ["Expression", "Terminatorless"],
|
||
fields: {
|
||
delegate: {
|
||
validate: (0, _utils.assertValueType)("boolean"),
|
||
default: false
|
||
},
|
||
argument: {
|
||
optional: true,
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
}
|
||
}
|
||
});
|
||
|
||
/***/ }),
|
||
/* 85 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = inherit;
|
||
|
||
function _uniq() {
|
||
const data = _interopRequireDefault(__webpack_require__(281));
|
||
|
||
_uniq = function () {
|
||
return data;
|
||
};
|
||
|
||
return data;
|
||
}
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function inherit(key, child, parent) {
|
||
if (child && parent) {
|
||
child[key] = (0, _uniq().default)([].concat(child[key], parent[key]).filter(Boolean));
|
||
}
|
||
}
|
||
|
||
/***/ }),
|
||
/* 86 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* The base implementation of `_.findIndex` and `_.findLastIndex` without
|
||
* support for iteratee shorthands.
|
||
*
|
||
* @private
|
||
* @param {Array} array The array to inspect.
|
||
* @param {Function} predicate The function invoked per iteration.
|
||
* @param {number} fromIndex The index to search from.
|
||
* @param {boolean} [fromRight] Specify iterating from right to left.
|
||
* @returns {number} Returns the index of the matched value, else `-1`.
|
||
*/
|
||
function baseFindIndex(array, predicate, fromIndex, fromRight) {
|
||
var length = array.length,
|
||
index = fromIndex + (fromRight ? 1 : -1);
|
||
|
||
while ((fromRight ? index-- : ++index < length)) {
|
||
if (predicate(array[index], index, array)) {
|
||
return index;
|
||
}
|
||
}
|
||
return -1;
|
||
}
|
||
|
||
module.exports = baseFindIndex;
|
||
|
||
|
||
/***/ }),
|
||
/* 87 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* Converts `set` to an array of its values.
|
||
*
|
||
* @private
|
||
* @param {Object} set The set to convert.
|
||
* @returns {Array} Returns the values.
|
||
*/
|
||
function setToArray(set) {
|
||
var index = -1,
|
||
result = Array(set.size);
|
||
|
||
set.forEach(function(value) {
|
||
result[++index] = value;
|
||
});
|
||
return result;
|
||
}
|
||
|
||
module.exports = setToArray;
|
||
|
||
|
||
/***/ }),
|
||
/* 88 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
/*
|
||
* Copyright 2009-2011 Mozilla Foundation and contributors
|
||
* Licensed under the New BSD license. See LICENSE.txt or:
|
||
* http://opensource.org/licenses/BSD-3-Clause
|
||
*/
|
||
exports.SourceMapGenerator = __webpack_require__(32).SourceMapGenerator;
|
||
exports.SourceMapConsumer = __webpack_require__(91).SourceMapConsumer;
|
||
exports.SourceNode = __webpack_require__(94).SourceNode;
|
||
|
||
|
||
/***/ }),
|
||
/* 89 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/* Copyright 2011 Mozilla Foundation and contributors
|
||
* Licensed under the New BSD license. See LICENSE or:
|
||
* http://opensource.org/licenses/BSD-3-Clause
|
||
*/
|
||
|
||
var intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
|
||
|
||
/**
|
||
* Encode an integer in the range of 0 to 63 to a single base 64 digit.
|
||
*/
|
||
exports.encode = function (number) {
|
||
if (0 <= number && number < intToCharMap.length) {
|
||
return intToCharMap[number];
|
||
}
|
||
throw new TypeError("Must be between 0 and 63: " + number);
|
||
};
|
||
|
||
/**
|
||
* Decode a single base 64 character code digit to an integer. Returns -1 on
|
||
* failure.
|
||
*/
|
||
exports.decode = function (charCode) {
|
||
var bigA = 65; // 'A'
|
||
var bigZ = 90; // 'Z'
|
||
|
||
var littleA = 97; // 'a'
|
||
var littleZ = 122; // 'z'
|
||
|
||
var zero = 48; // '0'
|
||
var nine = 57; // '9'
|
||
|
||
var plus = 43; // '+'
|
||
var slash = 47; // '/'
|
||
|
||
var littleOffset = 26;
|
||
var numberOffset = 52;
|
||
|
||
// 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
||
if (bigA <= charCode && charCode <= bigZ) {
|
||
return (charCode - bigA);
|
||
}
|
||
|
||
// 26 - 51: abcdefghijklmnopqrstuvwxyz
|
||
if (littleA <= charCode && charCode <= littleZ) {
|
||
return (charCode - littleA + littleOffset);
|
||
}
|
||
|
||
// 52 - 61: 0123456789
|
||
if (zero <= charCode && charCode <= nine) {
|
||
return (charCode - zero + numberOffset);
|
||
}
|
||
|
||
// 62: +
|
||
if (charCode == plus) {
|
||
return 62;
|
||
}
|
||
|
||
// 63: /
|
||
if (charCode == slash) {
|
||
return 63;
|
||
}
|
||
|
||
// Invalid base64 digit.
|
||
return -1;
|
||
};
|
||
|
||
|
||
/***/ }),
|
||
/* 90 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
/* Copyright 2014 Mozilla Foundation and contributors
|
||
* Licensed under the New BSD license. See LICENSE or:
|
||
* http://opensource.org/licenses/BSD-3-Clause
|
||
*/
|
||
|
||
var util = __webpack_require__(12);
|
||
|
||
/**
|
||
* Determine whether mappingB is after mappingA with respect to generated
|
||
* position.
|
||
*/
|
||
function generatedPositionAfter(mappingA, mappingB) {
|
||
// Optimized for most common case
|
||
var lineA = mappingA.generatedLine;
|
||
var lineB = mappingB.generatedLine;
|
||
var columnA = mappingA.generatedColumn;
|
||
var columnB = mappingB.generatedColumn;
|
||
return lineB > lineA || lineB == lineA && columnB >= columnA ||
|
||
util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
|
||
}
|
||
|
||
/**
|
||
* A data structure to provide a sorted view of accumulated mappings in a
|
||
* performance conscious manner. It trades a neglibable overhead in general
|
||
* case for a large speedup in case of mappings being added in order.
|
||
*/
|
||
function MappingList() {
|
||
this._array = [];
|
||
this._sorted = true;
|
||
// Serves as infimum
|
||
this._last = {generatedLine: -1, generatedColumn: 0};
|
||
}
|
||
|
||
/**
|
||
* Iterate through internal items. This method takes the same arguments that
|
||
* `Array.prototype.forEach` takes.
|
||
*
|
||
* NOTE: The order of the mappings is NOT guaranteed.
|
||
*/
|
||
MappingList.prototype.unsortedForEach =
|
||
function MappingList_forEach(aCallback, aThisArg) {
|
||
this._array.forEach(aCallback, aThisArg);
|
||
};
|
||
|
||
/**
|
||
* Add the given source mapping.
|
||
*
|
||
* @param Object aMapping
|
||
*/
|
||
MappingList.prototype.add = function MappingList_add(aMapping) {
|
||
if (generatedPositionAfter(this._last, aMapping)) {
|
||
this._last = aMapping;
|
||
this._array.push(aMapping);
|
||
} else {
|
||
this._sorted = false;
|
||
this._array.push(aMapping);
|
||
}
|
||
};
|
||
|
||
/**
|
||
* Returns the flat, sorted array of mappings. The mappings are sorted by
|
||
* generated position.
|
||
*
|
||
* WARNING: This method returns internal data without copying, for
|
||
* performance. The return value must NOT be mutated, and should be treated as
|
||
* an immutable borrow. If you want to take ownership, you must make your own
|
||
* copy.
|
||
*/
|
||
MappingList.prototype.toArray = function MappingList_toArray() {
|
||
if (!this._sorted) {
|
||
this._array.sort(util.compareByGeneratedPositionsInflated);
|
||
this._sorted = true;
|
||
}
|
||
return this._array;
|
||
};
|
||
|
||
exports.MappingList = MappingList;
|
||
|
||
|
||
/***/ }),
|
||
/* 91 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
/* Copyright 2011 Mozilla Foundation and contributors
|
||
* Licensed under the New BSD license. See LICENSE or:
|
||
* http://opensource.org/licenses/BSD-3-Clause
|
||
*/
|
||
|
||
var util = __webpack_require__(12);
|
||
var binarySearch = __webpack_require__(92);
|
||
var ArraySet = __webpack_require__(34).ArraySet;
|
||
var base64VLQ = __webpack_require__(33);
|
||
var quickSort = __webpack_require__(93).quickSort;
|
||
|
||
function SourceMapConsumer(aSourceMap) {
|
||
var sourceMap = aSourceMap;
|
||
if (typeof aSourceMap === 'string') {
|
||
sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
|
||
}
|
||
|
||
return sourceMap.sections != null
|
||
? new IndexedSourceMapConsumer(sourceMap)
|
||
: new BasicSourceMapConsumer(sourceMap);
|
||
}
|
||
|
||
SourceMapConsumer.fromSourceMap = function(aSourceMap) {
|
||
return BasicSourceMapConsumer.fromSourceMap(aSourceMap);
|
||
}
|
||
|
||
/**
|
||
* The version of the source mapping spec that we are consuming.
|
||
*/
|
||
SourceMapConsumer.prototype._version = 3;
|
||
|
||
// `__generatedMappings` and `__originalMappings` are arrays that hold the
|
||
// parsed mapping coordinates from the source map's "mappings" attribute. They
|
||
// are lazily instantiated, accessed via the `_generatedMappings` and
|
||
// `_originalMappings` getters respectively, and we only parse the mappings
|
||
// and create these arrays once queried for a source location. We jump through
|
||
// these hoops because there can be many thousands of mappings, and parsing
|
||
// them is expensive, so we only want to do it if we must.
|
||
//
|
||
// Each object in the arrays is of the form:
|
||
//
|
||
// {
|
||
// generatedLine: The line number in the generated code,
|
||
// generatedColumn: The column number in the generated code,
|
||
// source: The path to the original source file that generated this
|
||
// chunk of code,
|
||
// originalLine: The line number in the original source that
|
||
// corresponds to this chunk of generated code,
|
||
// originalColumn: The column number in the original source that
|
||
// corresponds to this chunk of generated code,
|
||
// name: The name of the original symbol which generated this chunk of
|
||
// code.
|
||
// }
|
||
//
|
||
// All properties except for `generatedLine` and `generatedColumn` can be
|
||
// `null`.
|
||
//
|
||
// `_generatedMappings` is ordered by the generated positions.
|
||
//
|
||
// `_originalMappings` is ordered by the original positions.
|
||
|
||
SourceMapConsumer.prototype.__generatedMappings = null;
|
||
Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', {
|
||
get: function () {
|
||
if (!this.__generatedMappings) {
|
||
this._parseMappings(this._mappings, this.sourceRoot);
|
||
}
|
||
|
||
return this.__generatedMappings;
|
||
}
|
||
});
|
||
|
||
SourceMapConsumer.prototype.__originalMappings = null;
|
||
Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', {
|
||
get: function () {
|
||
if (!this.__originalMappings) {
|
||
this._parseMappings(this._mappings, this.sourceRoot);
|
||
}
|
||
|
||
return this.__originalMappings;
|
||
}
|
||
});
|
||
|
||
SourceMapConsumer.prototype._charIsMappingSeparator =
|
||
function SourceMapConsumer_charIsMappingSeparator(aStr, index) {
|
||
var c = aStr.charAt(index);
|
||
return c === ";" || c === ",";
|
||
};
|
||
|
||
/**
|
||
* Parse the mappings in a string in to a data structure which we can easily
|
||
* query (the ordered arrays in the `this.__generatedMappings` and
|
||
* `this.__originalMappings` properties).
|
||
*/
|
||
SourceMapConsumer.prototype._parseMappings =
|
||
function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
|
||
throw new Error("Subclasses must implement _parseMappings");
|
||
};
|
||
|
||
SourceMapConsumer.GENERATED_ORDER = 1;
|
||
SourceMapConsumer.ORIGINAL_ORDER = 2;
|
||
|
||
SourceMapConsumer.GREATEST_LOWER_BOUND = 1;
|
||
SourceMapConsumer.LEAST_UPPER_BOUND = 2;
|
||
|
||
/**
|
||
* Iterate over each mapping between an original source/line/column and a
|
||
* generated line/column in this source map.
|
||
*
|
||
* @param Function aCallback
|
||
* The function that is called with each mapping.
|
||
* @param Object aContext
|
||
* Optional. If specified, this object will be the value of `this` every
|
||
* time that `aCallback` is called.
|
||
* @param aOrder
|
||
* Either `SourceMapConsumer.GENERATED_ORDER` or
|
||
* `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
|
||
* iterate over the mappings sorted by the generated file's line/column
|
||
* order or the original's source/line/column order, respectively. Defaults to
|
||
* `SourceMapConsumer.GENERATED_ORDER`.
|
||
*/
|
||
SourceMapConsumer.prototype.eachMapping =
|
||
function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
|
||
var context = aContext || null;
|
||
var order = aOrder || SourceMapConsumer.GENERATED_ORDER;
|
||
|
||
var mappings;
|
||
switch (order) {
|
||
case SourceMapConsumer.GENERATED_ORDER:
|
||
mappings = this._generatedMappings;
|
||
break;
|
||
case SourceMapConsumer.ORIGINAL_ORDER:
|
||
mappings = this._originalMappings;
|
||
break;
|
||
default:
|
||
throw new Error("Unknown order of iteration.");
|
||
}
|
||
|
||
var sourceRoot = this.sourceRoot;
|
||
mappings.map(function (mapping) {
|
||
var source = mapping.source === null ? null : this._sources.at(mapping.source);
|
||
if (source != null && sourceRoot != null) {
|
||
source = util.join(sourceRoot, source);
|
||
}
|
||
return {
|
||
source: source,
|
||
generatedLine: mapping.generatedLine,
|
||
generatedColumn: mapping.generatedColumn,
|
||
originalLine: mapping.originalLine,
|
||
originalColumn: mapping.originalColumn,
|
||
name: mapping.name === null ? null : this._names.at(mapping.name)
|
||
};
|
||
}, this).forEach(aCallback, context);
|
||
};
|
||
|
||
/**
|
||
* Returns all generated line and column information for the original source,
|
||
* line, and column provided. If no column is provided, returns all mappings
|
||
* corresponding to a either the line we are searching for or the next
|
||
* closest line that has any mappings. Otherwise, returns all mappings
|
||
* corresponding to the given line and either the column we are searching for
|
||
* or the next closest column that has any offsets.
|
||
*
|
||
* The only argument is an object with the following properties:
|
||
*
|
||
* - source: The filename of the original source.
|
||
* - line: The line number in the original source.
|
||
* - column: Optional. the column number in the original source.
|
||
*
|
||
* and an array of objects is returned, each with the following properties:
|
||
*
|
||
* - line: The line number in the generated source, or null.
|
||
* - column: The column number in the generated source, or null.
|
||
*/
|
||
SourceMapConsumer.prototype.allGeneratedPositionsFor =
|
||
function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
|
||
var line = util.getArg(aArgs, 'line');
|
||
|
||
// When there is no exact match, BasicSourceMapConsumer.prototype._findMapping
|
||
// returns the index of the closest mapping less than the needle. By
|
||
// setting needle.originalColumn to 0, we thus find the last mapping for
|
||
// the given line, provided such a mapping exists.
|
||
var needle = {
|
||
source: util.getArg(aArgs, 'source'),
|
||
originalLine: line,
|
||
originalColumn: util.getArg(aArgs, 'column', 0)
|
||
};
|
||
|
||
if (this.sourceRoot != null) {
|
||
needle.source = util.relative(this.sourceRoot, needle.source);
|
||
}
|
||
if (!this._sources.has(needle.source)) {
|
||
return [];
|
||
}
|
||
needle.source = this._sources.indexOf(needle.source);
|
||
|
||
var mappings = [];
|
||
|
||
var index = this._findMapping(needle,
|
||
this._originalMappings,
|
||
"originalLine",
|
||
"originalColumn",
|
||
util.compareByOriginalPositions,
|
||
binarySearch.LEAST_UPPER_BOUND);
|
||
if (index >= 0) {
|
||
var mapping = this._originalMappings[index];
|
||
|
||
if (aArgs.column === undefined) {
|
||
var originalLine = mapping.originalLine;
|
||
|
||
// Iterate until either we run out of mappings, or we run into
|
||
// a mapping for a different line than the one we found. Since
|
||
// mappings are sorted, this is guaranteed to find all mappings for
|
||
// the line we found.
|
||
while (mapping && mapping.originalLine === originalLine) {
|
||
mappings.push({
|
||
line: util.getArg(mapping, 'generatedLine', null),
|
||
column: util.getArg(mapping, 'generatedColumn', null),
|
||
lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
|
||
});
|
||
|
||
mapping = this._originalMappings[++index];
|
||
}
|
||
} else {
|
||
var originalColumn = mapping.originalColumn;
|
||
|
||
// Iterate until either we run out of mappings, or we run into
|
||
// a mapping for a different line than the one we were searching for.
|
||
// Since mappings are sorted, this is guaranteed to find all mappings for
|
||
// the line we are searching for.
|
||
while (mapping &&
|
||
mapping.originalLine === line &&
|
||
mapping.originalColumn == originalColumn) {
|
||
mappings.push({
|
||
line: util.getArg(mapping, 'generatedLine', null),
|
||
column: util.getArg(mapping, 'generatedColumn', null),
|
||
lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
|
||
});
|
||
|
||
mapping = this._originalMappings[++index];
|
||
}
|
||
}
|
||
}
|
||
|
||
return mappings;
|
||
};
|
||
|
||
exports.SourceMapConsumer = SourceMapConsumer;
|
||
|
||
/**
|
||
* A BasicSourceMapConsumer instance represents a parsed source map which we can
|
||
* query for information about the original file positions by giving it a file
|
||
* position in the generated source.
|
||
*
|
||
* The only parameter is the raw source map (either as a JSON string, or
|
||
* already parsed to an object). According to the spec, source maps have the
|
||
* following attributes:
|
||
*
|
||
* - version: Which version of the source map spec this map is following.
|
||
* - sources: An array of URLs to the original source files.
|
||
* - names: An array of identifiers which can be referrenced by individual mappings.
|
||
* - sourceRoot: Optional. The URL root from which all sources are relative.
|
||
* - sourcesContent: Optional. An array of contents of the original source files.
|
||
* - mappings: A string of base64 VLQs which contain the actual mappings.
|
||
* - file: Optional. The generated file this source map is associated with.
|
||
*
|
||
* Here is an example source map, taken from the source map spec[0]:
|
||
*
|
||
* {
|
||
* version : 3,
|
||
* file: "out.js",
|
||
* sourceRoot : "",
|
||
* sources: ["foo.js", "bar.js"],
|
||
* names: ["src", "maps", "are", "fun"],
|
||
* mappings: "AA,AB;;ABCDE;"
|
||
* }
|
||
*
|
||
* [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
|
||
*/
|
||
function BasicSourceMapConsumer(aSourceMap) {
|
||
var sourceMap = aSourceMap;
|
||
if (typeof aSourceMap === 'string') {
|
||
sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
|
||
}
|
||
|
||
var version = util.getArg(sourceMap, 'version');
|
||
var sources = util.getArg(sourceMap, 'sources');
|
||
// Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
|
||
// requires the array) to play nice here.
|
||
var names = util.getArg(sourceMap, 'names', []);
|
||
var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null);
|
||
var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null);
|
||
var mappings = util.getArg(sourceMap, 'mappings');
|
||
var file = util.getArg(sourceMap, 'file', null);
|
||
|
||
// Once again, Sass deviates from the spec and supplies the version as a
|
||
// string rather than a number, so we use loose equality checking here.
|
||
if (version != this._version) {
|
||
throw new Error('Unsupported version: ' + version);
|
||
}
|
||
|
||
sources = sources
|
||
.map(String)
|
||
// Some source maps produce relative source paths like "./foo.js" instead of
|
||
// "foo.js". Normalize these first so that future comparisons will succeed.
|
||
// See bugzil.la/1090768.
|
||
.map(util.normalize)
|
||
// Always ensure that absolute sources are internally stored relative to
|
||
// the source root, if the source root is absolute. Not doing this would
|
||
// be particularly problematic when the source root is a prefix of the
|
||
// source (valid, but why??). See github issue #199 and bugzil.la/1188982.
|
||
.map(function (source) {
|
||
return sourceRoot && util.isAbsolute(sourceRoot) && util.isAbsolute(source)
|
||
? util.relative(sourceRoot, source)
|
||
: source;
|
||
});
|
||
|
||
// Pass `true` below to allow duplicate names and sources. While source maps
|
||
// are intended to be compressed and deduplicated, the TypeScript compiler
|
||
// sometimes generates source maps with duplicates in them. See Github issue
|
||
// #72 and bugzil.la/889492.
|
||
this._names = ArraySet.fromArray(names.map(String), true);
|
||
this._sources = ArraySet.fromArray(sources, true);
|
||
|
||
this.sourceRoot = sourceRoot;
|
||
this.sourcesContent = sourcesContent;
|
||
this._mappings = mappings;
|
||
this.file = file;
|
||
}
|
||
|
||
BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
|
||
BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer;
|
||
|
||
/**
|
||
* Create a BasicSourceMapConsumer from a SourceMapGenerator.
|
||
*
|
||
* @param SourceMapGenerator aSourceMap
|
||
* The source map that will be consumed.
|
||
* @returns BasicSourceMapConsumer
|
||
*/
|
||
BasicSourceMapConsumer.fromSourceMap =
|
||
function SourceMapConsumer_fromSourceMap(aSourceMap) {
|
||
var smc = Object.create(BasicSourceMapConsumer.prototype);
|
||
|
||
var names = smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);
|
||
var sources = smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);
|
||
smc.sourceRoot = aSourceMap._sourceRoot;
|
||
smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
|
||
smc.sourceRoot);
|
||
smc.file = aSourceMap._file;
|
||
|
||
// Because we are modifying the entries (by converting string sources and
|
||
// names to indices into the sources and names ArraySets), we have to make
|
||
// a copy of the entry or else bad things happen. Shared mutable state
|
||
// strikes again! See github issue #191.
|
||
|
||
var generatedMappings = aSourceMap._mappings.toArray().slice();
|
||
var destGeneratedMappings = smc.__generatedMappings = [];
|
||
var destOriginalMappings = smc.__originalMappings = [];
|
||
|
||
for (var i = 0, length = generatedMappings.length; i < length; i++) {
|
||
var srcMapping = generatedMappings[i];
|
||
var destMapping = new Mapping;
|
||
destMapping.generatedLine = srcMapping.generatedLine;
|
||
destMapping.generatedColumn = srcMapping.generatedColumn;
|
||
|
||
if (srcMapping.source) {
|
||
destMapping.source = sources.indexOf(srcMapping.source);
|
||
destMapping.originalLine = srcMapping.originalLine;
|
||
destMapping.originalColumn = srcMapping.originalColumn;
|
||
|
||
if (srcMapping.name) {
|
||
destMapping.name = names.indexOf(srcMapping.name);
|
||
}
|
||
|
||
destOriginalMappings.push(destMapping);
|
||
}
|
||
|
||
destGeneratedMappings.push(destMapping);
|
||
}
|
||
|
||
quickSort(smc.__originalMappings, util.compareByOriginalPositions);
|
||
|
||
return smc;
|
||
};
|
||
|
||
/**
|
||
* The version of the source mapping spec that we are consuming.
|
||
*/
|
||
BasicSourceMapConsumer.prototype._version = 3;
|
||
|
||
/**
|
||
* The list of original sources.
|
||
*/
|
||
Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {
|
||
get: function () {
|
||
return this._sources.toArray().map(function (s) {
|
||
return this.sourceRoot != null ? util.join(this.sourceRoot, s) : s;
|
||
}, this);
|
||
}
|
||
});
|
||
|
||
/**
|
||
* Provide the JIT with a nice shape / hidden class.
|
||
*/
|
||
function Mapping() {
|
||
this.generatedLine = 0;
|
||
this.generatedColumn = 0;
|
||
this.source = null;
|
||
this.originalLine = null;
|
||
this.originalColumn = null;
|
||
this.name = null;
|
||
}
|
||
|
||
/**
|
||
* Parse the mappings in a string in to a data structure which we can easily
|
||
* query (the ordered arrays in the `this.__generatedMappings` and
|
||
* `this.__originalMappings` properties).
|
||
*/
|
||
BasicSourceMapConsumer.prototype._parseMappings =
|
||
function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
|
||
var generatedLine = 1;
|
||
var previousGeneratedColumn = 0;
|
||
var previousOriginalLine = 0;
|
||
var previousOriginalColumn = 0;
|
||
var previousSource = 0;
|
||
var previousName = 0;
|
||
var length = aStr.length;
|
||
var index = 0;
|
||
var cachedSegments = {};
|
||
var temp = {};
|
||
var originalMappings = [];
|
||
var generatedMappings = [];
|
||
var mapping, str, segment, end, value;
|
||
|
||
while (index < length) {
|
||
if (aStr.charAt(index) === ';') {
|
||
generatedLine++;
|
||
index++;
|
||
previousGeneratedColumn = 0;
|
||
}
|
||
else if (aStr.charAt(index) === ',') {
|
||
index++;
|
||
}
|
||
else {
|
||
mapping = new Mapping();
|
||
mapping.generatedLine = generatedLine;
|
||
|
||
// Because each offset is encoded relative to the previous one,
|
||
// many segments often have the same encoding. We can exploit this
|
||
// fact by caching the parsed variable length fields of each segment,
|
||
// allowing us to avoid a second parse if we encounter the same
|
||
// segment again.
|
||
for (end = index; end < length; end++) {
|
||
if (this._charIsMappingSeparator(aStr, end)) {
|
||
break;
|
||
}
|
||
}
|
||
str = aStr.slice(index, end);
|
||
|
||
segment = cachedSegments[str];
|
||
if (segment) {
|
||
index += str.length;
|
||
} else {
|
||
segment = [];
|
||
while (index < end) {
|
||
base64VLQ.decode(aStr, index, temp);
|
||
value = temp.value;
|
||
index = temp.rest;
|
||
segment.push(value);
|
||
}
|
||
|
||
if (segment.length === 2) {
|
||
throw new Error('Found a source, but no line and column');
|
||
}
|
||
|
||
if (segment.length === 3) {
|
||
throw new Error('Found a source and line, but no column');
|
||
}
|
||
|
||
cachedSegments[str] = segment;
|
||
}
|
||
|
||
// Generated column.
|
||
mapping.generatedColumn = previousGeneratedColumn + segment[0];
|
||
previousGeneratedColumn = mapping.generatedColumn;
|
||
|
||
if (segment.length > 1) {
|
||
// Original source.
|
||
mapping.source = previousSource + segment[1];
|
||
previousSource += segment[1];
|
||
|
||
// Original line.
|
||
mapping.originalLine = previousOriginalLine + segment[2];
|
||
previousOriginalLine = mapping.originalLine;
|
||
// Lines are stored 0-based
|
||
mapping.originalLine += 1;
|
||
|
||
// Original column.
|
||
mapping.originalColumn = previousOriginalColumn + segment[3];
|
||
previousOriginalColumn = mapping.originalColumn;
|
||
|
||
if (segment.length > 4) {
|
||
// Original name.
|
||
mapping.name = previousName + segment[4];
|
||
previousName += segment[4];
|
||
}
|
||
}
|
||
|
||
generatedMappings.push(mapping);
|
||
if (typeof mapping.originalLine === 'number') {
|
||
originalMappings.push(mapping);
|
||
}
|
||
}
|
||
}
|
||
|
||
quickSort(generatedMappings, util.compareByGeneratedPositionsDeflated);
|
||
this.__generatedMappings = generatedMappings;
|
||
|
||
quickSort(originalMappings, util.compareByOriginalPositions);
|
||
this.__originalMappings = originalMappings;
|
||
};
|
||
|
||
/**
|
||
* Find the mapping that best matches the hypothetical "needle" mapping that
|
||
* we are searching for in the given "haystack" of mappings.
|
||
*/
|
||
BasicSourceMapConsumer.prototype._findMapping =
|
||
function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,
|
||
aColumnName, aComparator, aBias) {
|
||
// To return the position we are searching for, we must first find the
|
||
// mapping for the given position and then return the opposite position it
|
||
// points to. Because the mappings are sorted, we can use binary search to
|
||
// find the best mapping.
|
||
|
||
if (aNeedle[aLineName] <= 0) {
|
||
throw new TypeError('Line must be greater than or equal to 1, got '
|
||
+ aNeedle[aLineName]);
|
||
}
|
||
if (aNeedle[aColumnName] < 0) {
|
||
throw new TypeError('Column must be greater than or equal to 0, got '
|
||
+ aNeedle[aColumnName]);
|
||
}
|
||
|
||
return binarySearch.search(aNeedle, aMappings, aComparator, aBias);
|
||
};
|
||
|
||
/**
|
||
* Compute the last column for each generated mapping. The last column is
|
||
* inclusive.
|
||
*/
|
||
BasicSourceMapConsumer.prototype.computeColumnSpans =
|
||
function SourceMapConsumer_computeColumnSpans() {
|
||
for (var index = 0; index < this._generatedMappings.length; ++index) {
|
||
var mapping = this._generatedMappings[index];
|
||
|
||
// Mappings do not contain a field for the last generated columnt. We
|
||
// can come up with an optimistic estimate, however, by assuming that
|
||
// mappings are contiguous (i.e. given two consecutive mappings, the
|
||
// first mapping ends where the second one starts).
|
||
if (index + 1 < this._generatedMappings.length) {
|
||
var nextMapping = this._generatedMappings[index + 1];
|
||
|
||
if (mapping.generatedLine === nextMapping.generatedLine) {
|
||
mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
|
||
continue;
|
||
}
|
||
}
|
||
|
||
// The last mapping for each line spans the entire line.
|
||
mapping.lastGeneratedColumn = Infinity;
|
||
}
|
||
};
|
||
|
||
/**
|
||
* Returns the original source, line, and column information for the generated
|
||
* source's line and column positions provided. The only argument is an object
|
||
* with the following properties:
|
||
*
|
||
* - line: The line number in the generated source.
|
||
* - column: The column number in the generated source.
|
||
* - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
|
||
* 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
|
||
* closest element that is smaller than or greater than the one we are
|
||
* searching for, respectively, if the exact element cannot be found.
|
||
* Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
|
||
*
|
||
* and an object is returned with the following properties:
|
||
*
|
||
* - source: The original source file, or null.
|
||
* - line: The line number in the original source, or null.
|
||
* - column: The column number in the original source, or null.
|
||
* - name: The original identifier, or null.
|
||
*/
|
||
BasicSourceMapConsumer.prototype.originalPositionFor =
|
||
function SourceMapConsumer_originalPositionFor(aArgs) {
|
||
var needle = {
|
||
generatedLine: util.getArg(aArgs, 'line'),
|
||
generatedColumn: util.getArg(aArgs, 'column')
|
||
};
|
||
|
||
var index = this._findMapping(
|
||
needle,
|
||
this._generatedMappings,
|
||
"generatedLine",
|
||
"generatedColumn",
|
||
util.compareByGeneratedPositionsDeflated,
|
||
util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)
|
||
);
|
||
|
||
if (index >= 0) {
|
||
var mapping = this._generatedMappings[index];
|
||
|
||
if (mapping.generatedLine === needle.generatedLine) {
|
||
var source = util.getArg(mapping, 'source', null);
|
||
if (source !== null) {
|
||
source = this._sources.at(source);
|
||
if (this.sourceRoot != null) {
|
||
source = util.join(this.sourceRoot, source);
|
||
}
|
||
}
|
||
var name = util.getArg(mapping, 'name', null);
|
||
if (name !== null) {
|
||
name = this._names.at(name);
|
||
}
|
||
return {
|
||
source: source,
|
||
line: util.getArg(mapping, 'originalLine', null),
|
||
column: util.getArg(mapping, 'originalColumn', null),
|
||
name: name
|
||
};
|
||
}
|
||
}
|
||
|
||
return {
|
||
source: null,
|
||
line: null,
|
||
column: null,
|
||
name: null
|
||
};
|
||
};
|
||
|
||
/**
|
||
* Return true if we have the source content for every source in the source
|
||
* map, false otherwise.
|
||
*/
|
||
BasicSourceMapConsumer.prototype.hasContentsOfAllSources =
|
||
function BasicSourceMapConsumer_hasContentsOfAllSources() {
|
||
if (!this.sourcesContent) {
|
||
return false;
|
||
}
|
||
return this.sourcesContent.length >= this._sources.size() &&
|
||
!this.sourcesContent.some(function (sc) { return sc == null; });
|
||
};
|
||
|
||
/**
|
||
* Returns the original source content. The only argument is the url of the
|
||
* original source file. Returns null if no original source content is
|
||
* available.
|
||
*/
|
||
BasicSourceMapConsumer.prototype.sourceContentFor =
|
||
function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
|
||
if (!this.sourcesContent) {
|
||
return null;
|
||
}
|
||
|
||
if (this.sourceRoot != null) {
|
||
aSource = util.relative(this.sourceRoot, aSource);
|
||
}
|
||
|
||
if (this._sources.has(aSource)) {
|
||
return this.sourcesContent[this._sources.indexOf(aSource)];
|
||
}
|
||
|
||
var url;
|
||
if (this.sourceRoot != null
|
||
&& (url = util.urlParse(this.sourceRoot))) {
|
||
// XXX: file:// URIs and absolute paths lead to unexpected behavior for
|
||
// many users. We can help them out when they expect file:// URIs to
|
||
// behave like it would if they were running a local HTTP server. See
|
||
// https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
|
||
var fileUriAbsPath = aSource.replace(/^file:\/\//, "");
|
||
if (url.scheme == "file"
|
||
&& this._sources.has(fileUriAbsPath)) {
|
||
return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
|
||
}
|
||
|
||
if ((!url.path || url.path == "/")
|
||
&& this._sources.has("/" + aSource)) {
|
||
return this.sourcesContent[this._sources.indexOf("/" + aSource)];
|
||
}
|
||
}
|
||
|
||
// This function is used recursively from
|
||
// IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we
|
||
// don't want to throw if we can't find the source - we just want to
|
||
// return null, so we provide a flag to exit gracefully.
|
||
if (nullOnMissing) {
|
||
return null;
|
||
}
|
||
else {
|
||
throw new Error('"' + aSource + '" is not in the SourceMap.');
|
||
}
|
||
};
|
||
|
||
/**
|
||
* Returns the generated line and column information for the original source,
|
||
* line, and column positions provided. The only argument is an object with
|
||
* the following properties:
|
||
*
|
||
* - source: The filename of the original source.
|
||
* - line: The line number in the original source.
|
||
* - column: The column number in the original source.
|
||
* - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
|
||
* 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
|
||
* closest element that is smaller than or greater than the one we are
|
||
* searching for, respectively, if the exact element cannot be found.
|
||
* Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
|
||
*
|
||
* and an object is returned with the following properties:
|
||
*
|
||
* - line: The line number in the generated source, or null.
|
||
* - column: The column number in the generated source, or null.
|
||
*/
|
||
BasicSourceMapConsumer.prototype.generatedPositionFor =
|
||
function SourceMapConsumer_generatedPositionFor(aArgs) {
|
||
var source = util.getArg(aArgs, 'source');
|
||
if (this.sourceRoot != null) {
|
||
source = util.relative(this.sourceRoot, source);
|
||
}
|
||
if (!this._sources.has(source)) {
|
||
return {
|
||
line: null,
|
||
column: null,
|
||
lastColumn: null
|
||
};
|
||
}
|
||
source = this._sources.indexOf(source);
|
||
|
||
var needle = {
|
||
source: source,
|
||
originalLine: util.getArg(aArgs, 'line'),
|
||
originalColumn: util.getArg(aArgs, 'column')
|
||
};
|
||
|
||
var index = this._findMapping(
|
||
needle,
|
||
this._originalMappings,
|
||
"originalLine",
|
||
"originalColumn",
|
||
util.compareByOriginalPositions,
|
||
util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)
|
||
);
|
||
|
||
if (index >= 0) {
|
||
var mapping = this._originalMappings[index];
|
||
|
||
if (mapping.source === needle.source) {
|
||
return {
|
||
line: util.getArg(mapping, 'generatedLine', null),
|
||
column: util.getArg(mapping, 'generatedColumn', null),
|
||
lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
|
||
};
|
||
}
|
||
}
|
||
|
||
return {
|
||
line: null,
|
||
column: null,
|
||
lastColumn: null
|
||
};
|
||
};
|
||
|
||
exports.BasicSourceMapConsumer = BasicSourceMapConsumer;
|
||
|
||
/**
|
||
* An IndexedSourceMapConsumer instance represents a parsed source map which
|
||
* we can query for information. It differs from BasicSourceMapConsumer in
|
||
* that it takes "indexed" source maps (i.e. ones with a "sections" field) as
|
||
* input.
|
||
*
|
||
* The only parameter is a raw source map (either as a JSON string, or already
|
||
* parsed to an object). According to the spec for indexed source maps, they
|
||
* have the following attributes:
|
||
*
|
||
* - version: Which version of the source map spec this map is following.
|
||
* - file: Optional. The generated file this source map is associated with.
|
||
* - sections: A list of section definitions.
|
||
*
|
||
* Each value under the "sections" field has two fields:
|
||
* - offset: The offset into the original specified at which this section
|
||
* begins to apply, defined as an object with a "line" and "column"
|
||
* field.
|
||
* - map: A source map definition. This source map could also be indexed,
|
||
* but doesn't have to be.
|
||
*
|
||
* Instead of the "map" field, it's also possible to have a "url" field
|
||
* specifying a URL to retrieve a source map from, but that's currently
|
||
* unsupported.
|
||
*
|
||
* Here's an example source map, taken from the source map spec[0], but
|
||
* modified to omit a section which uses the "url" field.
|
||
*
|
||
* {
|
||
* version : 3,
|
||
* file: "app.js",
|
||
* sections: [{
|
||
* offset: {line:100, column:10},
|
||
* map: {
|
||
* version : 3,
|
||
* file: "section.js",
|
||
* sources: ["foo.js", "bar.js"],
|
||
* names: ["src", "maps", "are", "fun"],
|
||
* mappings: "AAAA,E;;ABCDE;"
|
||
* }
|
||
* }],
|
||
* }
|
||
*
|
||
* [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt
|
||
*/
|
||
function IndexedSourceMapConsumer(aSourceMap) {
|
||
var sourceMap = aSourceMap;
|
||
if (typeof aSourceMap === 'string') {
|
||
sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
|
||
}
|
||
|
||
var version = util.getArg(sourceMap, 'version');
|
||
var sections = util.getArg(sourceMap, 'sections');
|
||
|
||
if (version != this._version) {
|
||
throw new Error('Unsupported version: ' + version);
|
||
}
|
||
|
||
this._sources = new ArraySet();
|
||
this._names = new ArraySet();
|
||
|
||
var lastOffset = {
|
||
line: -1,
|
||
column: 0
|
||
};
|
||
this._sections = sections.map(function (s) {
|
||
if (s.url) {
|
||
// The url field will require support for asynchronicity.
|
||
// See https://github.com/mozilla/source-map/issues/16
|
||
throw new Error('Support for url field in sections not implemented.');
|
||
}
|
||
var offset = util.getArg(s, 'offset');
|
||
var offsetLine = util.getArg(offset, 'line');
|
||
var offsetColumn = util.getArg(offset, 'column');
|
||
|
||
if (offsetLine < lastOffset.line ||
|
||
(offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
|
||
throw new Error('Section offsets must be ordered and non-overlapping.');
|
||
}
|
||
lastOffset = offset;
|
||
|
||
return {
|
||
generatedOffset: {
|
||
// The offset fields are 0-based, but we use 1-based indices when
|
||
// encoding/decoding from VLQ.
|
||
generatedLine: offsetLine + 1,
|
||
generatedColumn: offsetColumn + 1
|
||
},
|
||
consumer: new SourceMapConsumer(util.getArg(s, 'map'))
|
||
}
|
||
});
|
||
}
|
||
|
||
IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
|
||
IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer;
|
||
|
||
/**
|
||
* The version of the source mapping spec that we are consuming.
|
||
*/
|
||
IndexedSourceMapConsumer.prototype._version = 3;
|
||
|
||
/**
|
||
* The list of original sources.
|
||
*/
|
||
Object.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', {
|
||
get: function () {
|
||
var sources = [];
|
||
for (var i = 0; i < this._sections.length; i++) {
|
||
for (var j = 0; j < this._sections[i].consumer.sources.length; j++) {
|
||
sources.push(this._sections[i].consumer.sources[j]);
|
||
}
|
||
}
|
||
return sources;
|
||
}
|
||
});
|
||
|
||
/**
|
||
* Returns the original source, line, and column information for the generated
|
||
* source's line and column positions provided. The only argument is an object
|
||
* with the following properties:
|
||
*
|
||
* - line: The line number in the generated source.
|
||
* - column: The column number in the generated source.
|
||
*
|
||
* and an object is returned with the following properties:
|
||
*
|
||
* - source: The original source file, or null.
|
||
* - line: The line number in the original source, or null.
|
||
* - column: The column number in the original source, or null.
|
||
* - name: The original identifier, or null.
|
||
*/
|
||
IndexedSourceMapConsumer.prototype.originalPositionFor =
|
||
function IndexedSourceMapConsumer_originalPositionFor(aArgs) {
|
||
var needle = {
|
||
generatedLine: util.getArg(aArgs, 'line'),
|
||
generatedColumn: util.getArg(aArgs, 'column')
|
||
};
|
||
|
||
// Find the section containing the generated position we're trying to map
|
||
// to an original position.
|
||
var sectionIndex = binarySearch.search(needle, this._sections,
|
||
function(needle, section) {
|
||
var cmp = needle.generatedLine - section.generatedOffset.generatedLine;
|
||
if (cmp) {
|
||
return cmp;
|
||
}
|
||
|
||
return (needle.generatedColumn -
|
||
section.generatedOffset.generatedColumn);
|
||
});
|
||
var section = this._sections[sectionIndex];
|
||
|
||
if (!section) {
|
||
return {
|
||
source: null,
|
||
line: null,
|
||
column: null,
|
||
name: null
|
||
};
|
||
}
|
||
|
||
return section.consumer.originalPositionFor({
|
||
line: needle.generatedLine -
|
||
(section.generatedOffset.generatedLine - 1),
|
||
column: needle.generatedColumn -
|
||
(section.generatedOffset.generatedLine === needle.generatedLine
|
||
? section.generatedOffset.generatedColumn - 1
|
||
: 0),
|
||
bias: aArgs.bias
|
||
});
|
||
};
|
||
|
||
/**
|
||
* Return true if we have the source content for every source in the source
|
||
* map, false otherwise.
|
||
*/
|
||
IndexedSourceMapConsumer.prototype.hasContentsOfAllSources =
|
||
function IndexedSourceMapConsumer_hasContentsOfAllSources() {
|
||
return this._sections.every(function (s) {
|
||
return s.consumer.hasContentsOfAllSources();
|
||
});
|
||
};
|
||
|
||
/**
|
||
* Returns the original source content. The only argument is the url of the
|
||
* original source file. Returns null if no original source content is
|
||
* available.
|
||
*/
|
||
IndexedSourceMapConsumer.prototype.sourceContentFor =
|
||
function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
|
||
for (var i = 0; i < this._sections.length; i++) {
|
||
var section = this._sections[i];
|
||
|
||
var content = section.consumer.sourceContentFor(aSource, true);
|
||
if (content) {
|
||
return content;
|
||
}
|
||
}
|
||
if (nullOnMissing) {
|
||
return null;
|
||
}
|
||
else {
|
||
throw new Error('"' + aSource + '" is not in the SourceMap.');
|
||
}
|
||
};
|
||
|
||
/**
|
||
* Returns the generated line and column information for the original source,
|
||
* line, and column positions provided. The only argument is an object with
|
||
* the following properties:
|
||
*
|
||
* - source: The filename of the original source.
|
||
* - line: The line number in the original source.
|
||
* - column: The column number in the original source.
|
||
*
|
||
* and an object is returned with the following properties:
|
||
*
|
||
* - line: The line number in the generated source, or null.
|
||
* - column: The column number in the generated source, or null.
|
||
*/
|
||
IndexedSourceMapConsumer.prototype.generatedPositionFor =
|
||
function IndexedSourceMapConsumer_generatedPositionFor(aArgs) {
|
||
for (var i = 0; i < this._sections.length; i++) {
|
||
var section = this._sections[i];
|
||
|
||
// Only consider this section if the requested source is in the list of
|
||
// sources of the consumer.
|
||
if (section.consumer.sources.indexOf(util.getArg(aArgs, 'source')) === -1) {
|
||
continue;
|
||
}
|
||
var generatedPosition = section.consumer.generatedPositionFor(aArgs);
|
||
if (generatedPosition) {
|
||
var ret = {
|
||
line: generatedPosition.line +
|
||
(section.generatedOffset.generatedLine - 1),
|
||
column: generatedPosition.column +
|
||
(section.generatedOffset.generatedLine === generatedPosition.line
|
||
? section.generatedOffset.generatedColumn - 1
|
||
: 0)
|
||
};
|
||
return ret;
|
||
}
|
||
}
|
||
|
||
return {
|
||
line: null,
|
||
column: null
|
||
};
|
||
};
|
||
|
||
/**
|
||
* Parse the mappings in a string in to a data structure which we can easily
|
||
* query (the ordered arrays in the `this.__generatedMappings` and
|
||
* `this.__originalMappings` properties).
|
||
*/
|
||
IndexedSourceMapConsumer.prototype._parseMappings =
|
||
function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) {
|
||
this.__generatedMappings = [];
|
||
this.__originalMappings = [];
|
||
for (var i = 0; i < this._sections.length; i++) {
|
||
var section = this._sections[i];
|
||
var sectionMappings = section.consumer._generatedMappings;
|
||
for (var j = 0; j < sectionMappings.length; j++) {
|
||
var mapping = sectionMappings[j];
|
||
|
||
var source = section.consumer._sources.at(mapping.source);
|
||
if (section.consumer.sourceRoot !== null) {
|
||
source = util.join(section.consumer.sourceRoot, source);
|
||
}
|
||
this._sources.add(source);
|
||
source = this._sources.indexOf(source);
|
||
|
||
var name = section.consumer._names.at(mapping.name);
|
||
this._names.add(name);
|
||
name = this._names.indexOf(name);
|
||
|
||
// The mappings coming from the consumer for the section have
|
||
// generated positions relative to the start of the section, so we
|
||
// need to offset them to be relative to the start of the concatenated
|
||
// generated file.
|
||
var adjustedMapping = {
|
||
source: source,
|
||
generatedLine: mapping.generatedLine +
|
||
(section.generatedOffset.generatedLine - 1),
|
||
generatedColumn: mapping.generatedColumn +
|
||
(section.generatedOffset.generatedLine === mapping.generatedLine
|
||
? section.generatedOffset.generatedColumn - 1
|
||
: 0),
|
||
originalLine: mapping.originalLine,
|
||
originalColumn: mapping.originalColumn,
|
||
name: name
|
||
};
|
||
|
||
this.__generatedMappings.push(adjustedMapping);
|
||
if (typeof adjustedMapping.originalLine === 'number') {
|
||
this.__originalMappings.push(adjustedMapping);
|
||
}
|
||
}
|
||
}
|
||
|
||
quickSort(this.__generatedMappings, util.compareByGeneratedPositionsDeflated);
|
||
quickSort(this.__originalMappings, util.compareByOriginalPositions);
|
||
};
|
||
|
||
exports.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
|
||
|
||
|
||
/***/ }),
|
||
/* 92 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/* Copyright 2011 Mozilla Foundation and contributors
|
||
* Licensed under the New BSD license. See LICENSE or:
|
||
* http://opensource.org/licenses/BSD-3-Clause
|
||
*/
|
||
|
||
exports.GREATEST_LOWER_BOUND = 1;
|
||
exports.LEAST_UPPER_BOUND = 2;
|
||
|
||
/**
|
||
* Recursive implementation of binary search.
|
||
*
|
||
* @param aLow Indices here and lower do not contain the needle.
|
||
* @param aHigh Indices here and higher do not contain the needle.
|
||
* @param aNeedle The element being searched for.
|
||
* @param aHaystack The non-empty array being searched.
|
||
* @param aCompare Function which takes two elements and returns -1, 0, or 1.
|
||
* @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
|
||
* 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
|
||
* closest element that is smaller than or greater than the one we are
|
||
* searching for, respectively, if the exact element cannot be found.
|
||
*/
|
||
function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
|
||
// This function terminates when one of the following is true:
|
||
//
|
||
// 1. We find the exact element we are looking for.
|
||
//
|
||
// 2. We did not find the exact element, but we can return the index of
|
||
// the next-closest element.
|
||
//
|
||
// 3. We did not find the exact element, and there is no next-closest
|
||
// element than the one we are searching for, so we return -1.
|
||
var mid = Math.floor((aHigh - aLow) / 2) + aLow;
|
||
var cmp = aCompare(aNeedle, aHaystack[mid], true);
|
||
if (cmp === 0) {
|
||
// Found the element we are looking for.
|
||
return mid;
|
||
}
|
||
else if (cmp > 0) {
|
||
// Our needle is greater than aHaystack[mid].
|
||
if (aHigh - mid > 1) {
|
||
// The element is in the upper half.
|
||
return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
|
||
}
|
||
|
||
// The exact needle element was not found in this haystack. Determine if
|
||
// we are in termination case (3) or (2) and return the appropriate thing.
|
||
if (aBias == exports.LEAST_UPPER_BOUND) {
|
||
return aHigh < aHaystack.length ? aHigh : -1;
|
||
} else {
|
||
return mid;
|
||
}
|
||
}
|
||
else {
|
||
// Our needle is less than aHaystack[mid].
|
||
if (mid - aLow > 1) {
|
||
// The element is in the lower half.
|
||
return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
|
||
}
|
||
|
||
// we are in termination case (3) or (2) and return the appropriate thing.
|
||
if (aBias == exports.LEAST_UPPER_BOUND) {
|
||
return mid;
|
||
} else {
|
||
return aLow < 0 ? -1 : aLow;
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* This is an implementation of binary search which will always try and return
|
||
* the index of the closest element if there is no exact hit. This is because
|
||
* mappings between original and generated line/col pairs are single points,
|
||
* and there is an implicit region between each of them, so a miss just means
|
||
* that you aren't on the very start of a region.
|
||
*
|
||
* @param aNeedle The element you are looking for.
|
||
* @param aHaystack The array that is being searched.
|
||
* @param aCompare A function which takes the needle and an element in the
|
||
* array and returns -1, 0, or 1 depending on whether the needle is less
|
||
* than, equal to, or greater than the element, respectively.
|
||
* @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
|
||
* 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
|
||
* closest element that is smaller than or greater than the one we are
|
||
* searching for, respectively, if the exact element cannot be found.
|
||
* Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.
|
||
*/
|
||
exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
|
||
if (aHaystack.length === 0) {
|
||
return -1;
|
||
}
|
||
|
||
var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
|
||
aCompare, aBias || exports.GREATEST_LOWER_BOUND);
|
||
if (index < 0) {
|
||
return -1;
|
||
}
|
||
|
||
// We have found either the exact element, or the next-closest element than
|
||
// the one we are searching for. However, there may be more than one such
|
||
// element. Make sure we always return the smallest of these.
|
||
while (index - 1 >= 0) {
|
||
if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
|
||
break;
|
||
}
|
||
--index;
|
||
}
|
||
|
||
return index;
|
||
};
|
||
|
||
|
||
/***/ }),
|
||
/* 93 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/* Copyright 2011 Mozilla Foundation and contributors
|
||
* Licensed under the New BSD license. See LICENSE or:
|
||
* http://opensource.org/licenses/BSD-3-Clause
|
||
*/
|
||
|
||
// It turns out that some (most?) JavaScript engines don't self-host
|
||
// `Array.prototype.sort`. This makes sense because C++ will likely remain
|
||
// faster than JS when doing raw CPU-intensive sorting. However, when using a
|
||
// custom comparator function, calling back and forth between the VM's C++ and
|
||
// JIT'd JS is rather slow *and* loses JIT type information, resulting in
|
||
// worse generated code for the comparator function than would be optimal. In
|
||
// fact, when sorting with a comparator, these costs outweigh the benefits of
|
||
// sorting in C++. By using our own JS-implemented Quick Sort (below), we get
|
||
// a ~3500ms mean speed-up in `bench/bench.html`.
|
||
|
||
/**
|
||
* Swap the elements indexed by `x` and `y` in the array `ary`.
|
||
*
|
||
* @param {Array} ary
|
||
* The array.
|
||
* @param {Number} x
|
||
* The index of the first item.
|
||
* @param {Number} y
|
||
* The index of the second item.
|
||
*/
|
||
function swap(ary, x, y) {
|
||
var temp = ary[x];
|
||
ary[x] = ary[y];
|
||
ary[y] = temp;
|
||
}
|
||
|
||
/**
|
||
* Returns a random integer within the range `low .. high` inclusive.
|
||
*
|
||
* @param {Number} low
|
||
* The lower bound on the range.
|
||
* @param {Number} high
|
||
* The upper bound on the range.
|
||
*/
|
||
function randomIntInRange(low, high) {
|
||
return Math.round(low + (Math.random() * (high - low)));
|
||
}
|
||
|
||
/**
|
||
* The Quick Sort algorithm.
|
||
*
|
||
* @param {Array} ary
|
||
* An array to sort.
|
||
* @param {function} comparator
|
||
* Function to use to compare two items.
|
||
* @param {Number} p
|
||
* Start index of the array
|
||
* @param {Number} r
|
||
* End index of the array
|
||
*/
|
||
function doQuickSort(ary, comparator, p, r) {
|
||
// If our lower bound is less than our upper bound, we (1) partition the
|
||
// array into two pieces and (2) recurse on each half. If it is not, this is
|
||
// the empty array and our base case.
|
||
|
||
if (p < r) {
|
||
// (1) Partitioning.
|
||
//
|
||
// The partitioning chooses a pivot between `p` and `r` and moves all
|
||
// elements that are less than or equal to the pivot to the before it, and
|
||
// all the elements that are greater than it after it. The effect is that
|
||
// once partition is done, the pivot is in the exact place it will be when
|
||
// the array is put in sorted order, and it will not need to be moved
|
||
// again. This runs in O(n) time.
|
||
|
||
// Always choose a random pivot so that an input array which is reverse
|
||
// sorted does not cause O(n^2) running time.
|
||
var pivotIndex = randomIntInRange(p, r);
|
||
var i = p - 1;
|
||
|
||
swap(ary, pivotIndex, r);
|
||
var pivot = ary[r];
|
||
|
||
// Immediately after `j` is incremented in this loop, the following hold
|
||
// true:
|
||
//
|
||
// * Every element in `ary[p .. i]` is less than or equal to the pivot.
|
||
//
|
||
// * Every element in `ary[i+1 .. j-1]` is greater than the pivot.
|
||
for (var j = p; j < r; j++) {
|
||
if (comparator(ary[j], pivot) <= 0) {
|
||
i += 1;
|
||
swap(ary, i, j);
|
||
}
|
||
}
|
||
|
||
swap(ary, i + 1, j);
|
||
var q = i + 1;
|
||
|
||
// (2) Recurse on each half.
|
||
|
||
doQuickSort(ary, comparator, p, q - 1);
|
||
doQuickSort(ary, comparator, q + 1, r);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Sort the given array in-place with the given comparator function.
|
||
*
|
||
* @param {Array} ary
|
||
* An array to sort.
|
||
* @param {function} comparator
|
||
* Function to use to compare two items.
|
||
*/
|
||
exports.quickSort = function (ary, comparator) {
|
||
doQuickSort(ary, comparator, 0, ary.length - 1);
|
||
};
|
||
|
||
|
||
/***/ }),
|
||
/* 94 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
/* Copyright 2011 Mozilla Foundation and contributors
|
||
* Licensed under the New BSD license. See LICENSE or:
|
||
* http://opensource.org/licenses/BSD-3-Clause
|
||
*/
|
||
|
||
var SourceMapGenerator = __webpack_require__(32).SourceMapGenerator;
|
||
var util = __webpack_require__(12);
|
||
|
||
// Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
|
||
// operating systems these days (capturing the result).
|
||
var REGEX_NEWLINE = /(\r?\n)/;
|
||
|
||
// Newline character code for charCodeAt() comparisons
|
||
var NEWLINE_CODE = 10;
|
||
|
||
// Private symbol for identifying `SourceNode`s when multiple versions of
|
||
// the source-map library are loaded. This MUST NOT CHANGE across
|
||
// versions!
|
||
var isSourceNode = "$$$isSourceNode$$$";
|
||
|
||
/**
|
||
* SourceNodes provide a way to abstract over interpolating/concatenating
|
||
* snippets of generated JavaScript source code while maintaining the line and
|
||
* column information associated with the original source code.
|
||
*
|
||
* @param aLine The original line number.
|
||
* @param aColumn The original column number.
|
||
* @param aSource The original source's filename.
|
||
* @param aChunks Optional. An array of strings which are snippets of
|
||
* generated JS, or other SourceNodes.
|
||
* @param aName The original identifier.
|
||
*/
|
||
function SourceNode(aLine, aColumn, aSource, aChunks, aName) {
|
||
this.children = [];
|
||
this.sourceContents = {};
|
||
this.line = aLine == null ? null : aLine;
|
||
this.column = aColumn == null ? null : aColumn;
|
||
this.source = aSource == null ? null : aSource;
|
||
this.name = aName == null ? null : aName;
|
||
this[isSourceNode] = true;
|
||
if (aChunks != null) this.add(aChunks);
|
||
}
|
||
|
||
/**
|
||
* Creates a SourceNode from generated code and a SourceMapConsumer.
|
||
*
|
||
* @param aGeneratedCode The generated code
|
||
* @param aSourceMapConsumer The SourceMap for the generated code
|
||
* @param aRelativePath Optional. The path that relative sources in the
|
||
* SourceMapConsumer should be relative to.
|
||
*/
|
||
SourceNode.fromStringWithSourceMap =
|
||
function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
|
||
// The SourceNode we want to fill with the generated code
|
||
// and the SourceMap
|
||
var node = new SourceNode();
|
||
|
||
// All even indices of this array are one line of the generated code,
|
||
// while all odd indices are the newlines between two adjacent lines
|
||
// (since `REGEX_NEWLINE` captures its match).
|
||
// Processed fragments are accessed by calling `shiftNextLine`.
|
||
var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
|
||
var remainingLinesIndex = 0;
|
||
var shiftNextLine = function() {
|
||
var lineContents = getNextLine();
|
||
// The last line of a file might not have a newline.
|
||
var newLine = getNextLine() || "";
|
||
return lineContents + newLine;
|
||
|
||
function getNextLine() {
|
||
return remainingLinesIndex < remainingLines.length ?
|
||
remainingLines[remainingLinesIndex++] : undefined;
|
||
}
|
||
};
|
||
|
||
// We need to remember the position of "remainingLines"
|
||
var lastGeneratedLine = 1, lastGeneratedColumn = 0;
|
||
|
||
// The generate SourceNodes we need a code range.
|
||
// To extract it current and last mapping is used.
|
||
// Here we store the last mapping.
|
||
var lastMapping = null;
|
||
|
||
aSourceMapConsumer.eachMapping(function (mapping) {
|
||
if (lastMapping !== null) {
|
||
// We add the code from "lastMapping" to "mapping":
|
||
// First check if there is a new line in between.
|
||
if (lastGeneratedLine < mapping.generatedLine) {
|
||
// Associate first line with "lastMapping"
|
||
addMappingWithCode(lastMapping, shiftNextLine());
|
||
lastGeneratedLine++;
|
||
lastGeneratedColumn = 0;
|
||
// The remaining code is added without mapping
|
||
} else {
|
||
// There is no new line in between.
|
||
// Associate the code between "lastGeneratedColumn" and
|
||
// "mapping.generatedColumn" with "lastMapping"
|
||
var nextLine = remainingLines[remainingLinesIndex];
|
||
var code = nextLine.substr(0, mapping.generatedColumn -
|
||
lastGeneratedColumn);
|
||
remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -
|
||
lastGeneratedColumn);
|
||
lastGeneratedColumn = mapping.generatedColumn;
|
||
addMappingWithCode(lastMapping, code);
|
||
// No more remaining code, continue
|
||
lastMapping = mapping;
|
||
return;
|
||
}
|
||
}
|
||
// We add the generated code until the first mapping
|
||
// to the SourceNode without any mapping.
|
||
// Each line is added as separate string.
|
||
while (lastGeneratedLine < mapping.generatedLine) {
|
||
node.add(shiftNextLine());
|
||
lastGeneratedLine++;
|
||
}
|
||
if (lastGeneratedColumn < mapping.generatedColumn) {
|
||
var nextLine = remainingLines[remainingLinesIndex];
|
||
node.add(nextLine.substr(0, mapping.generatedColumn));
|
||
remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
|
||
lastGeneratedColumn = mapping.generatedColumn;
|
||
}
|
||
lastMapping = mapping;
|
||
}, this);
|
||
// We have processed all mappings.
|
||
if (remainingLinesIndex < remainingLines.length) {
|
||
if (lastMapping) {
|
||
// Associate the remaining code in the current line with "lastMapping"
|
||
addMappingWithCode(lastMapping, shiftNextLine());
|
||
}
|
||
// and add the remaining lines without any mapping
|
||
node.add(remainingLines.splice(remainingLinesIndex).join(""));
|
||
}
|
||
|
||
// Copy sourcesContent into SourceNode
|
||
aSourceMapConsumer.sources.forEach(function (sourceFile) {
|
||
var content = aSourceMapConsumer.sourceContentFor(sourceFile);
|
||
if (content != null) {
|
||
if (aRelativePath != null) {
|
||
sourceFile = util.join(aRelativePath, sourceFile);
|
||
}
|
||
node.setSourceContent(sourceFile, content);
|
||
}
|
||
});
|
||
|
||
return node;
|
||
|
||
function addMappingWithCode(mapping, code) {
|
||
if (mapping === null || mapping.source === undefined) {
|
||
node.add(code);
|
||
} else {
|
||
var source = aRelativePath
|
||
? util.join(aRelativePath, mapping.source)
|
||
: mapping.source;
|
||
node.add(new SourceNode(mapping.originalLine,
|
||
mapping.originalColumn,
|
||
source,
|
||
code,
|
||
mapping.name));
|
||
}
|
||
}
|
||
};
|
||
|
||
/**
|
||
* Add a chunk of generated JS to this source node.
|
||
*
|
||
* @param aChunk A string snippet of generated JS code, another instance of
|
||
* SourceNode, or an array where each member is one of those things.
|
||
*/
|
||
SourceNode.prototype.add = function SourceNode_add(aChunk) {
|
||
if (Array.isArray(aChunk)) {
|
||
aChunk.forEach(function (chunk) {
|
||
this.add(chunk);
|
||
}, this);
|
||
}
|
||
else if (aChunk[isSourceNode] || typeof aChunk === "string") {
|
||
if (aChunk) {
|
||
this.children.push(aChunk);
|
||
}
|
||
}
|
||
else {
|
||
throw new TypeError(
|
||
"Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
|
||
);
|
||
}
|
||
return this;
|
||
};
|
||
|
||
/**
|
||
* Add a chunk of generated JS to the beginning of this source node.
|
||
*
|
||
* @param aChunk A string snippet of generated JS code, another instance of
|
||
* SourceNode, or an array where each member is one of those things.
|
||
*/
|
||
SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {
|
||
if (Array.isArray(aChunk)) {
|
||
for (var i = aChunk.length-1; i >= 0; i--) {
|
||
this.prepend(aChunk[i]);
|
||
}
|
||
}
|
||
else if (aChunk[isSourceNode] || typeof aChunk === "string") {
|
||
this.children.unshift(aChunk);
|
||
}
|
||
else {
|
||
throw new TypeError(
|
||
"Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
|
||
);
|
||
}
|
||
return this;
|
||
};
|
||
|
||
/**
|
||
* Walk over the tree of JS snippets in this node and its children. The
|
||
* walking function is called once for each snippet of JS and is passed that
|
||
* snippet and the its original associated source's line/column location.
|
||
*
|
||
* @param aFn The traversal function.
|
||
*/
|
||
SourceNode.prototype.walk = function SourceNode_walk(aFn) {
|
||
var chunk;
|
||
for (var i = 0, len = this.children.length; i < len; i++) {
|
||
chunk = this.children[i];
|
||
if (chunk[isSourceNode]) {
|
||
chunk.walk(aFn);
|
||
}
|
||
else {
|
||
if (chunk !== '') {
|
||
aFn(chunk, { source: this.source,
|
||
line: this.line,
|
||
column: this.column,
|
||
name: this.name });
|
||
}
|
||
}
|
||
}
|
||
};
|
||
|
||
/**
|
||
* Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
|
||
* each of `this.children`.
|
||
*
|
||
* @param aSep The separator.
|
||
*/
|
||
SourceNode.prototype.join = function SourceNode_join(aSep) {
|
||
var newChildren;
|
||
var i;
|
||
var len = this.children.length;
|
||
if (len > 0) {
|
||
newChildren = [];
|
||
for (i = 0; i < len-1; i++) {
|
||
newChildren.push(this.children[i]);
|
||
newChildren.push(aSep);
|
||
}
|
||
newChildren.push(this.children[i]);
|
||
this.children = newChildren;
|
||
}
|
||
return this;
|
||
};
|
||
|
||
/**
|
||
* Call String.prototype.replace on the very right-most source snippet. Useful
|
||
* for trimming whitespace from the end of a source node, etc.
|
||
*
|
||
* @param aPattern The pattern to replace.
|
||
* @param aReplacement The thing to replace the pattern with.
|
||
*/
|
||
SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
|
||
var lastChild = this.children[this.children.length - 1];
|
||
if (lastChild[isSourceNode]) {
|
||
lastChild.replaceRight(aPattern, aReplacement);
|
||
}
|
||
else if (typeof lastChild === 'string') {
|
||
this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
|
||
}
|
||
else {
|
||
this.children.push(''.replace(aPattern, aReplacement));
|
||
}
|
||
return this;
|
||
};
|
||
|
||
/**
|
||
* Set the source content for a source file. This will be added to the SourceMapGenerator
|
||
* in the sourcesContent field.
|
||
*
|
||
* @param aSourceFile The filename of the source file
|
||
* @param aSourceContent The content of the source file
|
||
*/
|
||
SourceNode.prototype.setSourceContent =
|
||
function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
|
||
this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
|
||
};
|
||
|
||
/**
|
||
* Walk over the tree of SourceNodes. The walking function is called for each
|
||
* source file content and is passed the filename and source content.
|
||
*
|
||
* @param aFn The traversal function.
|
||
*/
|
||
SourceNode.prototype.walkSourceContents =
|
||
function SourceNode_walkSourceContents(aFn) {
|
||
for (var i = 0, len = this.children.length; i < len; i++) {
|
||
if (this.children[i][isSourceNode]) {
|
||
this.children[i].walkSourceContents(aFn);
|
||
}
|
||
}
|
||
|
||
var sources = Object.keys(this.sourceContents);
|
||
for (var i = 0, len = sources.length; i < len; i++) {
|
||
aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
|
||
}
|
||
};
|
||
|
||
/**
|
||
* Return the string representation of this source node. Walks over the tree
|
||
* and concatenates all the various snippets together to one string.
|
||
*/
|
||
SourceNode.prototype.toString = function SourceNode_toString() {
|
||
var str = "";
|
||
this.walk(function (chunk) {
|
||
str += chunk;
|
||
});
|
||
return str;
|
||
};
|
||
|
||
/**
|
||
* Returns the string representation of this source node along with a source
|
||
* map.
|
||
*/
|
||
SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
|
||
var generated = {
|
||
code: "",
|
||
line: 1,
|
||
column: 0
|
||
};
|
||
var map = new SourceMapGenerator(aArgs);
|
||
var sourceMappingActive = false;
|
||
var lastOriginalSource = null;
|
||
var lastOriginalLine = null;
|
||
var lastOriginalColumn = null;
|
||
var lastOriginalName = null;
|
||
this.walk(function (chunk, original) {
|
||
generated.code += chunk;
|
||
if (original.source !== null
|
||
&& original.line !== null
|
||
&& original.column !== null) {
|
||
if(lastOriginalSource !== original.source
|
||
|| lastOriginalLine !== original.line
|
||
|| lastOriginalColumn !== original.column
|
||
|| lastOriginalName !== original.name) {
|
||
map.addMapping({
|
||
source: original.source,
|
||
original: {
|
||
line: original.line,
|
||
column: original.column
|
||
},
|
||
generated: {
|
||
line: generated.line,
|
||
column: generated.column
|
||
},
|
||
name: original.name
|
||
});
|
||
}
|
||
lastOriginalSource = original.source;
|
||
lastOriginalLine = original.line;
|
||
lastOriginalColumn = original.column;
|
||
lastOriginalName = original.name;
|
||
sourceMappingActive = true;
|
||
} else if (sourceMappingActive) {
|
||
map.addMapping({
|
||
generated: {
|
||
line: generated.line,
|
||
column: generated.column
|
||
}
|
||
});
|
||
lastOriginalSource = null;
|
||
sourceMappingActive = false;
|
||
}
|
||
for (var idx = 0, length = chunk.length; idx < length; idx++) {
|
||
if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
|
||
generated.line++;
|
||
generated.column = 0;
|
||
// Mappings end at eol
|
||
if (idx + 1 === length) {
|
||
lastOriginalSource = null;
|
||
sourceMappingActive = false;
|
||
} else if (sourceMappingActive) {
|
||
map.addMapping({
|
||
source: original.source,
|
||
original: {
|
||
line: original.line,
|
||
column: original.column
|
||
},
|
||
generated: {
|
||
line: generated.line,
|
||
column: generated.column
|
||
},
|
||
name: original.name
|
||
});
|
||
}
|
||
} else {
|
||
generated.column++;
|
||
}
|
||
}
|
||
});
|
||
this.walkSourceContents(function (sourceFile, sourceContent) {
|
||
map.setSourceContent(sourceFile, sourceContent);
|
||
});
|
||
|
||
return { code: generated.code, map: map };
|
||
};
|
||
|
||
exports.SourceNode = SourceNode;
|
||
|
||
|
||
/***/ }),
|
||
/* 95 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var Symbol = __webpack_require__(19),
|
||
arrayMap = __webpack_require__(96),
|
||
isArray = __webpack_require__(9),
|
||
isSymbol = __webpack_require__(28);
|
||
|
||
/** Used as references for various `Number` constants. */
|
||
var INFINITY = 1 / 0;
|
||
|
||
/** Used to convert symbols to primitives and strings. */
|
||
var symbolProto = Symbol ? Symbol.prototype : undefined,
|
||
symbolToString = symbolProto ? symbolProto.toString : undefined;
|
||
|
||
/**
|
||
* The base implementation of `_.toString` which doesn't convert nullish
|
||
* values to empty strings.
|
||
*
|
||
* @private
|
||
* @param {*} value The value to process.
|
||
* @returns {string} Returns the string.
|
||
*/
|
||
function baseToString(value) {
|
||
// Exit early for strings to avoid a performance hit in some environments.
|
||
if (typeof value == 'string') {
|
||
return value;
|
||
}
|
||
if (isArray(value)) {
|
||
// Recursively convert values (susceptible to call stack limits).
|
||
return arrayMap(value, baseToString) + '';
|
||
}
|
||
if (isSymbol(value)) {
|
||
return symbolToString ? symbolToString.call(value) : '';
|
||
}
|
||
var result = (value + '');
|
||
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
|
||
}
|
||
|
||
module.exports = baseToString;
|
||
|
||
|
||
/***/ }),
|
||
/* 96 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* A specialized version of `_.map` for arrays without support for iteratee
|
||
* shorthands.
|
||
*
|
||
* @private
|
||
* @param {Array} [array] The array to iterate over.
|
||
* @param {Function} iteratee The function invoked per iteration.
|
||
* @returns {Array} Returns the new mapped array.
|
||
*/
|
||
function arrayMap(array, iteratee) {
|
||
var index = -1,
|
||
length = array == null ? 0 : array.length,
|
||
result = Array(length);
|
||
|
||
while (++index < length) {
|
||
result[index] = iteratee(array[index], index, array);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
module.exports = arrayMap;
|
||
|
||
|
||
/***/ }),
|
||
/* 97 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.Identifier = Identifier;
|
||
exports.ArgumentPlaceholder = ArgumentPlaceholder;
|
||
exports.SpreadElement = exports.RestElement = RestElement;
|
||
exports.ObjectPattern = exports.ObjectExpression = ObjectExpression;
|
||
exports.ObjectMethod = ObjectMethod;
|
||
exports.ObjectProperty = ObjectProperty;
|
||
exports.ArrayPattern = exports.ArrayExpression = ArrayExpression;
|
||
exports.RegExpLiteral = RegExpLiteral;
|
||
exports.BooleanLiteral = BooleanLiteral;
|
||
exports.NullLiteral = NullLiteral;
|
||
exports.NumericLiteral = NumericLiteral;
|
||
exports.StringLiteral = StringLiteral;
|
||
exports.BigIntLiteral = BigIntLiteral;
|
||
exports.PipelineTopicExpression = PipelineTopicExpression;
|
||
exports.PipelineBareFunction = PipelineBareFunction;
|
||
exports.PipelinePrimaryTopicReference = PipelinePrimaryTopicReference;
|
||
|
||
function t() {
|
||
const data = _interopRequireWildcard(__webpack_require__(3));
|
||
|
||
t = function () {
|
||
return data;
|
||
};
|
||
|
||
return data;
|
||
}
|
||
|
||
function _jsesc() {
|
||
const data = _interopRequireDefault(__webpack_require__(343));
|
||
|
||
_jsesc = function () {
|
||
return data;
|
||
};
|
||
|
||
return data;
|
||
}
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||
|
||
function Identifier(node) {
|
||
this.exactSource(node.loc, () => {
|
||
this.word(node.name);
|
||
});
|
||
}
|
||
|
||
function ArgumentPlaceholder() {
|
||
this.token("?");
|
||
}
|
||
|
||
function RestElement(node) {
|
||
this.token("...");
|
||
this.print(node.argument, node);
|
||
}
|
||
|
||
function ObjectExpression(node) {
|
||
const props = node.properties;
|
||
this.token("{");
|
||
this.printInnerComments(node);
|
||
|
||
if (props.length) {
|
||
this.space();
|
||
this.printList(props, node, {
|
||
indent: true,
|
||
statement: true
|
||
});
|
||
this.space();
|
||
}
|
||
|
||
this.token("}");
|
||
}
|
||
|
||
function ObjectMethod(node) {
|
||
this.printJoin(node.decorators, node);
|
||
|
||
this._methodHead(node);
|
||
|
||
this.space();
|
||
this.print(node.body, node);
|
||
}
|
||
|
||
function ObjectProperty(node) {
|
||
this.printJoin(node.decorators, node);
|
||
|
||
if (node.computed) {
|
||
this.token("[");
|
||
this.print(node.key, node);
|
||
this.token("]");
|
||
} else {
|
||
if (t().isAssignmentPattern(node.value) && t().isIdentifier(node.key) && node.key.name === node.value.left.name) {
|
||
this.print(node.value, node);
|
||
return;
|
||
}
|
||
|
||
this.print(node.key, node);
|
||
|
||
if (node.shorthand && t().isIdentifier(node.key) && t().isIdentifier(node.value) && node.key.name === node.value.name) {
|
||
return;
|
||
}
|
||
}
|
||
|
||
this.token(":");
|
||
this.space();
|
||
this.print(node.value, node);
|
||
}
|
||
|
||
function ArrayExpression(node) {
|
||
const elems = node.elements;
|
||
const len = elems.length;
|
||
this.token("[");
|
||
this.printInnerComments(node);
|
||
|
||
for (let i = 0; i < elems.length; i++) {
|
||
const elem = elems[i];
|
||
|
||
if (elem) {
|
||
if (i > 0) this.space();
|
||
this.print(elem, node);
|
||
if (i < len - 1) this.token(",");
|
||
} else {
|
||
this.token(",");
|
||
}
|
||
}
|
||
|
||
this.token("]");
|
||
}
|
||
|
||
function RegExpLiteral(node) {
|
||
this.word(`/${node.pattern}/${node.flags}`);
|
||
}
|
||
|
||
function BooleanLiteral(node) {
|
||
this.word(node.value ? "true" : "false");
|
||
}
|
||
|
||
function NullLiteral() {
|
||
this.word("null");
|
||
}
|
||
|
||
function NumericLiteral(node) {
|
||
const raw = this.getPossibleRaw(node);
|
||
const value = node.value + "";
|
||
|
||
if (raw == null) {
|
||
this.number(value);
|
||
} else if (this.format.minified) {
|
||
this.number(raw.length < value.length ? raw : value);
|
||
} else {
|
||
this.number(raw);
|
||
}
|
||
}
|
||
|
||
function StringLiteral(node) {
|
||
const raw = this.getPossibleRaw(node);
|
||
|
||
if (!this.format.minified && raw != null) {
|
||
this.token(raw);
|
||
return;
|
||
}
|
||
|
||
const opts = this.format.jsescOption;
|
||
|
||
if (this.format.jsonCompatibleStrings) {
|
||
opts.json = true;
|
||
}
|
||
|
||
const val = (0, _jsesc().default)(node.value, opts);
|
||
return this.token(val);
|
||
}
|
||
|
||
function BigIntLiteral(node) {
|
||
const raw = this.getPossibleRaw(node);
|
||
|
||
if (!this.format.minified && raw != null) {
|
||
this.token(raw);
|
||
return;
|
||
}
|
||
|
||
this.token(node.value);
|
||
}
|
||
|
||
function PipelineTopicExpression(node) {
|
||
this.print(node.expression, node);
|
||
}
|
||
|
||
function PipelineBareFunction(node) {
|
||
this.print(node.callee, node);
|
||
}
|
||
|
||
function PipelinePrimaryTopicReference() {
|
||
this.token("#");
|
||
}
|
||
|
||
/***/ }),
|
||
/* 98 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
exports.byteLength = byteLength
|
||
exports.toByteArray = toByteArray
|
||
exports.fromByteArray = fromByteArray
|
||
|
||
var lookup = []
|
||
var revLookup = []
|
||
var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
|
||
|
||
var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
|
||
for (var i = 0, len = code.length; i < len; ++i) {
|
||
lookup[i] = code[i]
|
||
revLookup[code.charCodeAt(i)] = i
|
||
}
|
||
|
||
// Support decoding URL-safe base64 strings, as Node.js does.
|
||
// See: https://en.wikipedia.org/wiki/Base64#URL_applications
|
||
revLookup['-'.charCodeAt(0)] = 62
|
||
revLookup['_'.charCodeAt(0)] = 63
|
||
|
||
function getLens (b64) {
|
||
var len = b64.length
|
||
|
||
if (len % 4 > 0) {
|
||
throw new Error('Invalid string. Length must be a multiple of 4')
|
||
}
|
||
|
||
// Trim off extra bytes after placeholder bytes are found
|
||
// See: https://github.com/beatgammit/base64-js/issues/42
|
||
var validLen = b64.indexOf('=')
|
||
if (validLen === -1) validLen = len
|
||
|
||
var placeHoldersLen = validLen === len
|
||
? 0
|
||
: 4 - (validLen % 4)
|
||
|
||
return [validLen, placeHoldersLen]
|
||
}
|
||
|
||
// base64 is 4/3 + up to two characters of the original data
|
||
function byteLength (b64) {
|
||
var lens = getLens(b64)
|
||
var validLen = lens[0]
|
||
var placeHoldersLen = lens[1]
|
||
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
|
||
}
|
||
|
||
function _byteLength (b64, validLen, placeHoldersLen) {
|
||
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
|
||
}
|
||
|
||
function toByteArray (b64) {
|
||
var tmp
|
||
var lens = getLens(b64)
|
||
var validLen = lens[0]
|
||
var placeHoldersLen = lens[1]
|
||
|
||
var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
|
||
|
||
var curByte = 0
|
||
|
||
// if there are placeholders, only get up to the last complete 4 chars
|
||
var len = placeHoldersLen > 0
|
||
? validLen - 4
|
||
: validLen
|
||
|
||
for (var i = 0; i < len; i += 4) {
|
||
tmp =
|
||
(revLookup[b64.charCodeAt(i)] << 18) |
|
||
(revLookup[b64.charCodeAt(i + 1)] << 12) |
|
||
(revLookup[b64.charCodeAt(i + 2)] << 6) |
|
||
revLookup[b64.charCodeAt(i + 3)]
|
||
arr[curByte++] = (tmp >> 16) & 0xFF
|
||
arr[curByte++] = (tmp >> 8) & 0xFF
|
||
arr[curByte++] = tmp & 0xFF
|
||
}
|
||
|
||
if (placeHoldersLen === 2) {
|
||
tmp =
|
||
(revLookup[b64.charCodeAt(i)] << 2) |
|
||
(revLookup[b64.charCodeAt(i + 1)] >> 4)
|
||
arr[curByte++] = tmp & 0xFF
|
||
}
|
||
|
||
if (placeHoldersLen === 1) {
|
||
tmp =
|
||
(revLookup[b64.charCodeAt(i)] << 10) |
|
||
(revLookup[b64.charCodeAt(i + 1)] << 4) |
|
||
(revLookup[b64.charCodeAt(i + 2)] >> 2)
|
||
arr[curByte++] = (tmp >> 8) & 0xFF
|
||
arr[curByte++] = tmp & 0xFF
|
||
}
|
||
|
||
return arr
|
||
}
|
||
|
||
function tripletToBase64 (num) {
|
||
return lookup[num >> 18 & 0x3F] +
|
||
lookup[num >> 12 & 0x3F] +
|
||
lookup[num >> 6 & 0x3F] +
|
||
lookup[num & 0x3F]
|
||
}
|
||
|
||
function encodeChunk (uint8, start, end) {
|
||
var tmp
|
||
var output = []
|
||
for (var i = start; i < end; i += 3) {
|
||
tmp =
|
||
((uint8[i] << 16) & 0xFF0000) +
|
||
((uint8[i + 1] << 8) & 0xFF00) +
|
||
(uint8[i + 2] & 0xFF)
|
||
output.push(tripletToBase64(tmp))
|
||
}
|
||
return output.join('')
|
||
}
|
||
|
||
function fromByteArray (uint8) {
|
||
var tmp
|
||
var len = uint8.length
|
||
var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
|
||
var parts = []
|
||
var maxChunkLength = 16383 // must be multiple of 3
|
||
|
||
// go through the array every three bytes, we'll deal with trailing stuff later
|
||
for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
|
||
parts.push(encodeChunk(
|
||
uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
|
||
))
|
||
}
|
||
|
||
// pad the end with zeros, but make sure to not forget the extra bytes
|
||
if (extraBytes === 1) {
|
||
tmp = uint8[len - 1]
|
||
parts.push(
|
||
lookup[tmp >> 2] +
|
||
lookup[(tmp << 4) & 0x3F] +
|
||
'=='
|
||
)
|
||
} else if (extraBytes === 2) {
|
||
tmp = (uint8[len - 2] << 8) + uint8[len - 1]
|
||
parts.push(
|
||
lookup[tmp >> 10] +
|
||
lookup[(tmp >> 4) & 0x3F] +
|
||
lookup[(tmp << 2) & 0x3F] +
|
||
'='
|
||
)
|
||
}
|
||
|
||
return parts.join('')
|
||
}
|
||
|
||
|
||
/***/ }),
|
||
/* 99 */
|
||
/***/ (function(module, exports) {
|
||
|
||
exports.read = function (buffer, offset, isLE, mLen, nBytes) {
|
||
var e, m
|
||
var eLen = (nBytes * 8) - mLen - 1
|
||
var eMax = (1 << eLen) - 1
|
||
var eBias = eMax >> 1
|
||
var nBits = -7
|
||
var i = isLE ? (nBytes - 1) : 0
|
||
var d = isLE ? -1 : 1
|
||
var s = buffer[offset + i]
|
||
|
||
i += d
|
||
|
||
e = s & ((1 << (-nBits)) - 1)
|
||
s >>= (-nBits)
|
||
nBits += eLen
|
||
for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
|
||
|
||
m = e & ((1 << (-nBits)) - 1)
|
||
e >>= (-nBits)
|
||
nBits += mLen
|
||
for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
|
||
|
||
if (e === 0) {
|
||
e = 1 - eBias
|
||
} else if (e === eMax) {
|
||
return m ? NaN : ((s ? -1 : 1) * Infinity)
|
||
} else {
|
||
m = m + Math.pow(2, mLen)
|
||
e = e - eBias
|
||
}
|
||
return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
|
||
}
|
||
|
||
exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
|
||
var e, m, c
|
||
var eLen = (nBytes * 8) - mLen - 1
|
||
var eMax = (1 << eLen) - 1
|
||
var eBias = eMax >> 1
|
||
var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
|
||
var i = isLE ? 0 : (nBytes - 1)
|
||
var d = isLE ? 1 : -1
|
||
var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
|
||
|
||
value = Math.abs(value)
|
||
|
||
if (isNaN(value) || value === Infinity) {
|
||
m = isNaN(value) ? 1 : 0
|
||
e = eMax
|
||
} else {
|
||
e = Math.floor(Math.log(value) / Math.LN2)
|
||
if (value * (c = Math.pow(2, -e)) < 1) {
|
||
e--
|
||
c *= 2
|
||
}
|
||
if (e + eBias >= 1) {
|
||
value += rt / c
|
||
} else {
|
||
value += rt * Math.pow(2, 1 - eBias)
|
||
}
|
||
if (value * c >= 2) {
|
||
e++
|
||
c /= 2
|
||
}
|
||
|
||
if (e + eBias >= eMax) {
|
||
m = 0
|
||
e = eMax
|
||
} else if (e + eBias >= 1) {
|
||
m = ((value * c) - 1) * Math.pow(2, mLen)
|
||
e = e + eBias
|
||
} else {
|
||
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
|
||
e = 0
|
||
}
|
||
}
|
||
|
||
for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
|
||
|
||
e = (e << mLen) | m
|
||
eLen += mLen
|
||
for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
|
||
|
||
buffer[offset + i - d] |= s * 128
|
||
}
|
||
|
||
|
||
/***/ }),
|
||
/* 100 */
|
||
/***/ (function(module, exports) {
|
||
|
||
var toString = {}.toString;
|
||
|
||
module.exports = Array.isArray || function (arr) {
|
||
return toString.call(arr) == '[object Array]';
|
||
};
|
||
|
||
|
||
/***/ }),
|
||
/* 101 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var isArray = __webpack_require__(9),
|
||
isSymbol = __webpack_require__(28);
|
||
|
||
/** Used to match property names within property paths. */
|
||
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
|
||
reIsPlainProp = /^\w*$/;
|
||
|
||
/**
|
||
* Checks if `value` is a property name and not a property path.
|
||
*
|
||
* @private
|
||
* @param {*} value The value to check.
|
||
* @param {Object} [object] The object to query keys on.
|
||
* @returns {boolean} Returns `true` if `value` is a property name, else `false`.
|
||
*/
|
||
function isKey(value, object) {
|
||
if (isArray(value)) {
|
||
return false;
|
||
}
|
||
var type = typeof value;
|
||
if (type == 'number' || type == 'symbol' || type == 'boolean' ||
|
||
value == null || isSymbol(value)) {
|
||
return true;
|
||
}
|
||
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
|
||
(object != null && value in Object(object));
|
||
}
|
||
|
||
module.exports = isKey;
|
||
|
||
|
||
/***/ }),
|
||
/* 102 */,
|
||
/* 103 */,
|
||
/* 104 */,
|
||
/* 105 */,
|
||
/* 106 */,
|
||
/* 107 */,
|
||
/* 108 */,
|
||
/* 109 */,
|
||
/* 110 */,
|
||
/* 111 */,
|
||
/* 112 */,
|
||
/* 113 */,
|
||
/* 114 */,
|
||
/* 115 */,
|
||
/* 116 */,
|
||
/* 117 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.clearSymbols = clearSymbols;
|
||
exports.getSymbols = getSymbols;
|
||
|
||
var t = _interopRequireWildcard(__webpack_require__(3));
|
||
|
||
var _simplePath = _interopRequireDefault(__webpack_require__(153));
|
||
|
||
var _ast = __webpack_require__(20);
|
||
|
||
var _helpers = __webpack_require__(54);
|
||
|
||
var _inferClassName = __webpack_require__(348);
|
||
|
||
var _getFunctionName = _interopRequireDefault(__webpack_require__(158));
|
||
|
||
var _frameworks = __webpack_require__(159);
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||
|
||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||
let symbolDeclarations = new Map();
|
||
|
||
function getUniqueIdentifiers(identifiers) {
|
||
const newIdentifiers = [];
|
||
const locationKeys = new Set();
|
||
|
||
for (const newId of identifiers) {
|
||
const key = (0, _helpers.nodeLocationKey)(newId);
|
||
|
||
if (!locationKeys.has(key)) {
|
||
locationKeys.add(key);
|
||
newIdentifiers.push(newId);
|
||
}
|
||
}
|
||
|
||
return newIdentifiers;
|
||
}
|
||
/* eslint-disable complexity */
|
||
|
||
|
||
function extractSymbol(path, symbols, state) {
|
||
if ((0, _helpers.isFunction)(path)) {
|
||
const name = (0, _getFunctionName.default)(path.node, path.parent);
|
||
|
||
if (!state.fnCounts[name]) {
|
||
state.fnCounts[name] = 0;
|
||
}
|
||
|
||
const index = state.fnCounts[name]++;
|
||
symbols.functions.push({
|
||
name,
|
||
klass: (0, _inferClassName.inferClassName)(path),
|
||
location: path.node.loc,
|
||
parameterNames: (0, _helpers.getFunctionParameterNames)(path),
|
||
identifier: path.node.id,
|
||
// indicates the occurence of the function in a file
|
||
// e.g { name: foo, ... index: 4 } is the 4th foo function
|
||
// in the file
|
||
index
|
||
});
|
||
}
|
||
|
||
if (t.isJSXElement(path)) {
|
||
symbols.hasJsx = true;
|
||
}
|
||
|
||
if (t.isGenericTypeAnnotation(path)) {
|
||
symbols.hasTypes = true;
|
||
}
|
||
|
||
if (t.isClassDeclaration(path)) {
|
||
const {
|
||
loc,
|
||
superClass
|
||
} = path.node;
|
||
symbols.classes.push({
|
||
name: path.node.id.name,
|
||
parent: superClass ? {
|
||
name: t.isMemberExpression(superClass) ? (0, _helpers.getCode)(superClass) : superClass.name,
|
||
location: superClass.loc
|
||
} : null,
|
||
location: loc
|
||
});
|
||
}
|
||
|
||
if (t.isImportDeclaration(path)) {
|
||
symbols.imports.push({
|
||
source: path.node.source.value,
|
||
location: path.node.loc,
|
||
specifiers: (0, _helpers.getSpecifiers)(path.node.specifiers)
|
||
});
|
||
}
|
||
|
||
if (t.isObjectProperty(path)) {
|
||
const {
|
||
start,
|
||
end,
|
||
identifierName
|
||
} = path.node.key.loc;
|
||
symbols.objectProperties.push({
|
||
name: identifierName,
|
||
location: {
|
||
start,
|
||
end
|
||
},
|
||
expression: getSnippet(path)
|
||
});
|
||
}
|
||
|
||
if (t.isMemberExpression(path)) {
|
||
const {
|
||
start,
|
||
end
|
||
} = path.node.property.loc;
|
||
symbols.memberExpressions.push({
|
||
name: path.node.property.name,
|
||
location: {
|
||
start,
|
||
end
|
||
},
|
||
expression: getSnippet(path),
|
||
computed: path.node.computed
|
||
});
|
||
}
|
||
|
||
if ((t.isStringLiteral(path) || t.isNumericLiteral(path)) && t.isMemberExpression(path.parentPath)) {
|
||
// We only need literals that are part of computed memeber expressions
|
||
const {
|
||
start,
|
||
end
|
||
} = path.node.loc;
|
||
symbols.literals.push({
|
||
name: path.node.value,
|
||
location: {
|
||
start,
|
||
end
|
||
},
|
||
expression: getSnippet(path.parentPath)
|
||
});
|
||
}
|
||
|
||
if (t.isCallExpression(path)) {
|
||
const callee = path.node.callee;
|
||
const args = path.node.arguments;
|
||
|
||
if (t.isMemberExpression(callee)) {
|
||
const {
|
||
property: {
|
||
name,
|
||
loc
|
||
}
|
||
} = callee;
|
||
symbols.callExpressions.push({
|
||
name: name,
|
||
values: args.filter(arg => arg.value).map(arg => arg.value),
|
||
location: loc
|
||
});
|
||
} else {
|
||
const {
|
||
start,
|
||
end,
|
||
identifierName
|
||
} = callee.loc;
|
||
symbols.callExpressions.push({
|
||
name: identifierName,
|
||
values: args.filter(arg => arg.value).map(arg => arg.value),
|
||
location: {
|
||
start,
|
||
end
|
||
}
|
||
});
|
||
}
|
||
}
|
||
|
||
if (t.isStringLiteral(path) && t.isProperty(path.parentPath)) {
|
||
const {
|
||
start,
|
||
end
|
||
} = path.node.loc;
|
||
return symbols.identifiers.push({
|
||
name: path.node.value,
|
||
expression: (0, _helpers.getObjectExpressionValue)(path.parent),
|
||
location: {
|
||
start,
|
||
end
|
||
}
|
||
});
|
||
}
|
||
|
||
if (t.isIdentifier(path) && !t.isGenericTypeAnnotation(path.parent)) {
|
||
let {
|
||
start,
|
||
end
|
||
} = path.node.loc; // We want to include function params, but exclude the function name
|
||
|
||
if (t.isClassMethod(path.parent) && !path.inList) {
|
||
return;
|
||
}
|
||
|
||
if (t.isProperty(path.parentPath) && !(0, _helpers.isObjectShorthand)(path.parent)) {
|
||
return symbols.identifiers.push({
|
||
name: path.node.name,
|
||
expression: (0, _helpers.getObjectExpressionValue)(path.parent),
|
||
location: {
|
||
start,
|
||
end
|
||
}
|
||
});
|
||
}
|
||
|
||
if (path.node.typeAnnotation) {
|
||
const column = path.node.typeAnnotation.loc.start.column;
|
||
end = { ...end,
|
||
column
|
||
};
|
||
}
|
||
|
||
symbols.identifiers.push({
|
||
name: path.node.name,
|
||
expression: path.node.name,
|
||
location: {
|
||
start,
|
||
end
|
||
}
|
||
});
|
||
}
|
||
|
||
if (t.isThisExpression(path.node)) {
|
||
const {
|
||
start,
|
||
end
|
||
} = path.node.loc;
|
||
symbols.identifiers.push({
|
||
name: "this",
|
||
location: {
|
||
start,
|
||
end
|
||
},
|
||
expression: "this"
|
||
});
|
||
}
|
||
|
||
if (t.isVariableDeclarator(path)) {
|
||
const nodeId = path.node.id;
|
||
symbols.identifiers.push(...(0, _helpers.getPatternIdentifiers)(nodeId));
|
||
}
|
||
}
|
||
/* eslint-enable complexity */
|
||
|
||
|
||
function extractSymbols(sourceId) {
|
||
const symbols = {
|
||
functions: [],
|
||
callExpressions: [],
|
||
memberExpressions: [],
|
||
objectProperties: [],
|
||
comments: [],
|
||
identifiers: [],
|
||
classes: [],
|
||
imports: [],
|
||
literals: [],
|
||
hasJsx: false,
|
||
hasTypes: false,
|
||
loading: false,
|
||
framework: undefined
|
||
};
|
||
const state = {
|
||
fnCounts: Object.create(null)
|
||
};
|
||
const ast = (0, _ast.traverseAst)(sourceId, {
|
||
enter(node, ancestors) {
|
||
try {
|
||
const path = (0, _simplePath.default)(ancestors);
|
||
|
||
if (path) {
|
||
extractSymbol(path, symbols, state);
|
||
}
|
||
} catch (e) {
|
||
console.error(e);
|
||
}
|
||
}
|
||
|
||
}); // comments are extracted separately from the AST
|
||
|
||
symbols.comments = (0, _helpers.getComments)(ast);
|
||
symbols.identifiers = getUniqueIdentifiers(symbols.identifiers);
|
||
symbols.framework = (0, _frameworks.getFramework)(symbols);
|
||
return symbols;
|
||
}
|
||
|
||
function extendSnippet(name, expression, path, prevPath) {
|
||
var _path$node$property, _path$node$property$e;
|
||
|
||
const computed = path === null || path === void 0 ? void 0 : path.node.computed;
|
||
const prevComputed = prevPath === null || prevPath === void 0 ? void 0 : prevPath.node.computed;
|
||
const prevArray = t.isArrayExpression(prevPath);
|
||
const array = t.isArrayExpression(path);
|
||
const value = (path === null || path === void 0 ? void 0 : (_path$node$property = path.node.property) === null || _path$node$property === void 0 ? void 0 : (_path$node$property$e = _path$node$property.extra) === null || _path$node$property$e === void 0 ? void 0 : _path$node$property$e.raw) || "";
|
||
|
||
if (expression === "") {
|
||
if (computed) {
|
||
return name === undefined ? `[${value}]` : `[${name}]`;
|
||
}
|
||
|
||
return name;
|
||
}
|
||
|
||
if (computed || array) {
|
||
if (prevComputed || prevArray) {
|
||
return `[${name}]${expression}`;
|
||
}
|
||
|
||
return `[${name === undefined ? value : name}].${expression}`;
|
||
}
|
||
|
||
if (prevComputed || prevArray) {
|
||
return `${name}${expression}`;
|
||
}
|
||
|
||
if ((0, _helpers.isComputedExpression)(expression) && name !== undefined) {
|
||
return `${name}${expression}`;
|
||
}
|
||
|
||
return `${name}.${expression}`;
|
||
}
|
||
|
||
function getMemberSnippet(node, expression = "") {
|
||
if (t.isMemberExpression(node)) {
|
||
const name = node.property.name;
|
||
const snippet = getMemberSnippet(node.object, extendSnippet(name, expression, {
|
||
node
|
||
}));
|
||
return snippet;
|
||
}
|
||
|
||
if (t.isCallExpression(node)) {
|
||
return "";
|
||
}
|
||
|
||
if (t.isThisExpression(node)) {
|
||
return `this.${expression}`;
|
||
}
|
||
|
||
if (t.isIdentifier(node)) {
|
||
if ((0, _helpers.isComputedExpression)(expression)) {
|
||
return `${node.name}${expression}`;
|
||
}
|
||
|
||
return `${node.name}.${expression}`;
|
||
}
|
||
|
||
return expression;
|
||
}
|
||
|
||
function getObjectSnippet(path, prevPath, expression = "") {
|
||
var _path$parentPath;
|
||
|
||
if (!path) {
|
||
return expression;
|
||
}
|
||
|
||
const name = path.node.key.name;
|
||
const extendedExpression = extendSnippet(name, expression, path, prevPath);
|
||
const nextPrevPath = path;
|
||
const nextPath = (_path$parentPath = path.parentPath) === null || _path$parentPath === void 0 ? void 0 : _path$parentPath.parentPath;
|
||
return getSnippet(nextPath, nextPrevPath, extendedExpression);
|
||
}
|
||
|
||
function getArraySnippet(path, prevPath, expression) {
|
||
var _path$parentPath2;
|
||
|
||
if (!prevPath.parentPath) {
|
||
throw new Error("Assertion failure - path should exist");
|
||
}
|
||
|
||
const index = `${prevPath.parentPath.containerIndex}`;
|
||
const extendedExpression = extendSnippet(index, expression, path, prevPath);
|
||
const nextPrevPath = path;
|
||
const nextPath = (_path$parentPath2 = path.parentPath) === null || _path$parentPath2 === void 0 ? void 0 : _path$parentPath2.parentPath;
|
||
return getSnippet(nextPath, nextPrevPath, extendedExpression);
|
||
}
|
||
|
||
function getSnippet(path, prevPath, expression = "") {
|
||
if (!path) {
|
||
return expression;
|
||
}
|
||
|
||
if (t.isVariableDeclaration(path)) {
|
||
const node = path.node.declarations[0];
|
||
const name = node.id.name;
|
||
return extendSnippet(name, expression, path, prevPath);
|
||
}
|
||
|
||
if (t.isVariableDeclarator(path)) {
|
||
const node = path.node.id;
|
||
|
||
if (t.isObjectPattern(node)) {
|
||
return expression;
|
||
}
|
||
|
||
const name = node.name;
|
||
const prop = extendSnippet(name, expression, path, prevPath);
|
||
return prop;
|
||
}
|
||
|
||
if (t.isAssignmentExpression(path)) {
|
||
const node = path.node.left;
|
||
const name = t.isMemberExpression(node) ? getMemberSnippet(node) : node.name;
|
||
const prop = extendSnippet(name, expression, path, prevPath);
|
||
return prop;
|
||
}
|
||
|
||
if ((0, _helpers.isFunction)(path)) {
|
||
return expression;
|
||
}
|
||
|
||
if (t.isIdentifier(path)) {
|
||
const node = path.node;
|
||
return `${node.name}.${expression}`;
|
||
}
|
||
|
||
if (t.isObjectProperty(path)) {
|
||
return getObjectSnippet(path, prevPath, expression);
|
||
}
|
||
|
||
if (t.isObjectExpression(path)) {
|
||
const parentPath = prevPath && prevPath.parentPath;
|
||
return getObjectSnippet(parentPath, prevPath, expression);
|
||
}
|
||
|
||
if (t.isMemberExpression(path)) {
|
||
return getMemberSnippet(path.node, expression);
|
||
}
|
||
|
||
if (t.isArrayExpression(path)) {
|
||
if (!prevPath) {
|
||
throw new Error("Assertion failure - path should exist");
|
||
}
|
||
|
||
return getArraySnippet(path, prevPath, expression);
|
||
}
|
||
|
||
return "";
|
||
}
|
||
|
||
function clearSymbols() {
|
||
symbolDeclarations = new Map();
|
||
}
|
||
|
||
function getSymbols(sourceId) {
|
||
if (symbolDeclarations.has(sourceId)) {
|
||
const symbols = symbolDeclarations.get(sourceId);
|
||
|
||
if (symbols) {
|
||
return symbols;
|
||
}
|
||
}
|
||
|
||
const symbols = extractSymbols(sourceId);
|
||
symbolDeclarations.set(sourceId, symbols);
|
||
return symbols;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 118 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = buildMatchMemberExpression;
|
||
|
||
var _matchesPattern = _interopRequireDefault(__webpack_require__(119));
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function buildMatchMemberExpression(match, allowPartial) {
|
||
const parts = match.split(".");
|
||
return member => (0, _matchesPattern.default)(member, parts, allowPartial);
|
||
}
|
||
|
||
/***/ }),
|
||
/* 119 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = matchesPattern;
|
||
|
||
var _generated = __webpack_require__(5);
|
||
|
||
function matchesPattern(member, match, allowPartial) {
|
||
if (!(0, _generated.isMemberExpression)(member)) return false;
|
||
const parts = Array.isArray(match) ? match : match.split(".");
|
||
const nodes = [];
|
||
let node;
|
||
|
||
for (node = member; (0, _generated.isMemberExpression)(node); node = node.object) {
|
||
nodes.push(node.property);
|
||
}
|
||
|
||
nodes.push(node);
|
||
if (nodes.length < parts.length) return false;
|
||
if (!allowPartial && nodes.length > parts.length) return false;
|
||
|
||
for (let i = 0, j = nodes.length - 1; i < parts.length; i++, j--) {
|
||
const node = nodes[j];
|
||
let value;
|
||
|
||
if ((0, _generated.isIdentifier)(node)) {
|
||
value = node.name;
|
||
} else if ((0, _generated.isStringLiteral)(node)) {
|
||
value = node.value;
|
||
} else {
|
||
return false;
|
||
}
|
||
|
||
if (parts[i] !== value) return false;
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 120 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var baseGetTag = __webpack_require__(18),
|
||
isObject = __webpack_require__(21);
|
||
|
||
/** `Object#toString` result references. */
|
||
var asyncTag = '[object AsyncFunction]',
|
||
funcTag = '[object Function]',
|
||
genTag = '[object GeneratorFunction]',
|
||
proxyTag = '[object Proxy]';
|
||
|
||
/**
|
||
* Checks if `value` is classified as a `Function` object.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 0.1.0
|
||
* @category Lang
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
||
* @example
|
||
*
|
||
* _.isFunction(_);
|
||
* // => true
|
||
*
|
||
* _.isFunction(/abc/);
|
||
* // => false
|
||
*/
|
||
function isFunction(value) {
|
||
if (!isObject(value)) {
|
||
return false;
|
||
}
|
||
// The use of `Object#toString` avoids issues with the `typeof` operator
|
||
// in Safari 9 which returns 'object' for typed arrays and other constructors.
|
||
var tag = baseGetTag(value);
|
||
return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
|
||
}
|
||
|
||
module.exports = isFunction;
|
||
|
||
|
||
/***/ }),
|
||
/* 121 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/** Used for built-in method references. */
|
||
var funcProto = Function.prototype;
|
||
|
||
/** Used to resolve the decompiled source of functions. */
|
||
var funcToString = funcProto.toString;
|
||
|
||
/**
|
||
* Converts `func` to its source code.
|
||
*
|
||
* @private
|
||
* @param {Function} func The function to convert.
|
||
* @returns {string} Returns the source code.
|
||
*/
|
||
function toSource(func) {
|
||
if (func != null) {
|
||
try {
|
||
return funcToString.call(func);
|
||
} catch (e) {}
|
||
try {
|
||
return (func + '');
|
||
} catch (e) {}
|
||
}
|
||
return '';
|
||
}
|
||
|
||
module.exports = toSource;
|
||
|
||
|
||
/***/ }),
|
||
/* 122 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var baseAssignValue = __webpack_require__(123),
|
||
eq = __webpack_require__(42);
|
||
|
||
/** Used for built-in method references. */
|
||
var objectProto = Object.prototype;
|
||
|
||
/** Used to check objects for own properties. */
|
||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||
|
||
/**
|
||
* Assigns `value` to `key` of `object` if the existing value is not equivalent
|
||
* using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
||
* for equality comparisons.
|
||
*
|
||
* @private
|
||
* @param {Object} object The object to modify.
|
||
* @param {string} key The key of the property to assign.
|
||
* @param {*} value The value to assign.
|
||
*/
|
||
function assignValue(object, key, value) {
|
||
var objValue = object[key];
|
||
if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
|
||
(value === undefined && !(key in object))) {
|
||
baseAssignValue(object, key, value);
|
||
}
|
||
}
|
||
|
||
module.exports = assignValue;
|
||
|
||
|
||
/***/ }),
|
||
/* 123 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var defineProperty = __webpack_require__(234);
|
||
|
||
/**
|
||
* The base implementation of `assignValue` and `assignMergeValue` without
|
||
* value checks.
|
||
*
|
||
* @private
|
||
* @param {Object} object The object to modify.
|
||
* @param {string} key The key of the property to assign.
|
||
* @param {*} value The value to assign.
|
||
*/
|
||
function baseAssignValue(object, key, value) {
|
||
if (key == '__proto__' && defineProperty) {
|
||
defineProperty(object, key, {
|
||
'configurable': true,
|
||
'enumerable': true,
|
||
'value': value,
|
||
'writable': true
|
||
});
|
||
} else {
|
||
object[key] = value;
|
||
}
|
||
}
|
||
|
||
module.exports = baseAssignValue;
|
||
|
||
|
||
/***/ }),
|
||
/* 124 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var baseTimes = __webpack_require__(236),
|
||
isArguments = __webpack_require__(74),
|
||
isArray = __webpack_require__(9),
|
||
isBuffer = __webpack_require__(48),
|
||
isIndex = __webpack_require__(75),
|
||
isTypedArray = __webpack_require__(76);
|
||
|
||
/** Used for built-in method references. */
|
||
var objectProto = Object.prototype;
|
||
|
||
/** Used to check objects for own properties. */
|
||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||
|
||
/**
|
||
* Creates an array of the enumerable property names of the array-like `value`.
|
||
*
|
||
* @private
|
||
* @param {*} value The value to query.
|
||
* @param {boolean} inherited Specify returning inherited property names.
|
||
* @returns {Array} Returns the array of property names.
|
||
*/
|
||
function arrayLikeKeys(value, inherited) {
|
||
var isArr = isArray(value),
|
||
isArg = !isArr && isArguments(value),
|
||
isBuff = !isArr && !isArg && isBuffer(value),
|
||
isType = !isArr && !isArg && !isBuff && isTypedArray(value),
|
||
skipIndexes = isArr || isArg || isBuff || isType,
|
||
result = skipIndexes ? baseTimes(value.length, String) : [],
|
||
length = result.length;
|
||
|
||
for (var key in value) {
|
||
if ((inherited || hasOwnProperty.call(value, key)) &&
|
||
!(skipIndexes && (
|
||
// Safari 9 has enumerable `arguments.length` in strict mode.
|
||
key == 'length' ||
|
||
// Node.js 0.10 has enumerable non-index properties on buffers.
|
||
(isBuff && (key == 'offset' || key == 'parent')) ||
|
||
// PhantomJS 2 has enumerable non-index properties on typed arrays.
|
||
(isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
|
||
// Skip index properties.
|
||
isIndex(key, length)
|
||
))) {
|
||
result.push(key);
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
|
||
module.exports = arrayLikeKeys;
|
||
|
||
|
||
/***/ }),
|
||
/* 125 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var isPrototype = __webpack_require__(51),
|
||
nativeKeys = __webpack_require__(240);
|
||
|
||
/** Used for built-in method references. */
|
||
var objectProto = Object.prototype;
|
||
|
||
/** Used to check objects for own properties. */
|
||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||
|
||
/**
|
||
* The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
|
||
*
|
||
* @private
|
||
* @param {Object} object The object to query.
|
||
* @returns {Array} Returns the array of property names.
|
||
*/
|
||
function baseKeys(object) {
|
||
if (!isPrototype(object)) {
|
||
return nativeKeys(object);
|
||
}
|
||
var result = [];
|
||
for (var key in Object(object)) {
|
||
if (hasOwnProperty.call(object, key) && key != 'constructor') {
|
||
result.push(key);
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
|
||
module.exports = baseKeys;
|
||
|
||
|
||
/***/ }),
|
||
/* 126 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* Creates a unary function that invokes `func` with its argument transformed.
|
||
*
|
||
* @private
|
||
* @param {Function} func The function to wrap.
|
||
* @param {Function} transform The argument transform.
|
||
* @returns {Function} Returns the new function.
|
||
*/
|
||
function overArg(func, transform) {
|
||
return function(arg) {
|
||
return func(transform(arg));
|
||
};
|
||
}
|
||
|
||
module.exports = overArg;
|
||
|
||
|
||
/***/ }),
|
||
/* 127 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var arrayLikeKeys = __webpack_require__(124),
|
||
baseKeysIn = __webpack_require__(242),
|
||
isArrayLike = __webpack_require__(52);
|
||
|
||
/**
|
||
* Creates an array of the own and inherited enumerable property names of `object`.
|
||
*
|
||
* **Note:** Non-object values are coerced to objects.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 3.0.0
|
||
* @category Object
|
||
* @param {Object} object The object to query.
|
||
* @returns {Array} Returns the array of property names.
|
||
* @example
|
||
*
|
||
* function Foo() {
|
||
* this.a = 1;
|
||
* this.b = 2;
|
||
* }
|
||
*
|
||
* Foo.prototype.c = 3;
|
||
*
|
||
* _.keysIn(new Foo);
|
||
* // => ['a', 'b', 'c'] (iteration order is not guaranteed)
|
||
*/
|
||
function keysIn(object) {
|
||
return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
|
||
}
|
||
|
||
module.exports = keysIn;
|
||
|
||
|
||
/***/ }),
|
||
/* 128 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* This method returns a new empty array.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 4.13.0
|
||
* @category Util
|
||
* @returns {Array} Returns the new empty array.
|
||
* @example
|
||
*
|
||
* var arrays = _.times(2, _.stubArray);
|
||
*
|
||
* console.log(arrays);
|
||
* // => [[], []]
|
||
*
|
||
* console.log(arrays[0] === arrays[1]);
|
||
* // => false
|
||
*/
|
||
function stubArray() {
|
||
return [];
|
||
}
|
||
|
||
module.exports = stubArray;
|
||
|
||
|
||
/***/ }),
|
||
/* 129 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var arrayPush = __webpack_require__(130),
|
||
getPrototype = __webpack_require__(79),
|
||
getSymbols = __webpack_require__(78),
|
||
stubArray = __webpack_require__(128);
|
||
|
||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||
var nativeGetSymbols = Object.getOwnPropertySymbols;
|
||
|
||
/**
|
||
* Creates an array of the own and inherited enumerable symbols of `object`.
|
||
*
|
||
* @private
|
||
* @param {Object} object The object to query.
|
||
* @returns {Array} Returns the array of symbols.
|
||
*/
|
||
var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
|
||
var result = [];
|
||
while (object) {
|
||
arrayPush(result, getSymbols(object));
|
||
object = getPrototype(object);
|
||
}
|
||
return result;
|
||
};
|
||
|
||
module.exports = getSymbolsIn;
|
||
|
||
|
||
/***/ }),
|
||
/* 130 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* Appends the elements of `values` to `array`.
|
||
*
|
||
* @private
|
||
* @param {Array} array The array to modify.
|
||
* @param {Array} values The values to append.
|
||
* @returns {Array} Returns `array`.
|
||
*/
|
||
function arrayPush(array, values) {
|
||
var index = -1,
|
||
length = values.length,
|
||
offset = array.length;
|
||
|
||
while (++index < length) {
|
||
array[offset + index] = values[index];
|
||
}
|
||
return array;
|
||
}
|
||
|
||
module.exports = arrayPush;
|
||
|
||
|
||
/***/ }),
|
||
/* 131 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var baseGetAllKeys = __webpack_require__(132),
|
||
getSymbols = __webpack_require__(78),
|
||
keys = __webpack_require__(47);
|
||
|
||
/**
|
||
* Creates an array of own enumerable property names and symbols of `object`.
|
||
*
|
||
* @private
|
||
* @param {Object} object The object to query.
|
||
* @returns {Array} Returns the array of property names and symbols.
|
||
*/
|
||
function getAllKeys(object) {
|
||
return baseGetAllKeys(object, keys, getSymbols);
|
||
}
|
||
|
||
module.exports = getAllKeys;
|
||
|
||
|
||
/***/ }),
|
||
/* 132 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var arrayPush = __webpack_require__(130),
|
||
isArray = __webpack_require__(9);
|
||
|
||
/**
|
||
* The base implementation of `getAllKeys` and `getAllKeysIn` which uses
|
||
* `keysFunc` and `symbolsFunc` to get the enumerable property names and
|
||
* symbols of `object`.
|
||
*
|
||
* @private
|
||
* @param {Object} object The object to query.
|
||
* @param {Function} keysFunc The function to get the keys of `object`.
|
||
* @param {Function} symbolsFunc The function to get the symbols of `object`.
|
||
* @returns {Array} Returns the array of property names and symbols.
|
||
*/
|
||
function baseGetAllKeys(object, keysFunc, symbolsFunc) {
|
||
var result = keysFunc(object);
|
||
return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
|
||
}
|
||
|
||
module.exports = baseGetAllKeys;
|
||
|
||
|
||
/***/ }),
|
||
/* 133 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var getNative = __webpack_require__(26),
|
||
root = __webpack_require__(8);
|
||
|
||
/* Built-in method references that are verified to be native. */
|
||
var Set = getNative(root, 'Set');
|
||
|
||
module.exports = Set;
|
||
|
||
|
||
/***/ }),
|
||
/* 134 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var root = __webpack_require__(8);
|
||
|
||
/** Built-in value references. */
|
||
var Uint8Array = root.Uint8Array;
|
||
|
||
module.exports = Uint8Array;
|
||
|
||
|
||
/***/ }),
|
||
/* 135 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/*
|
||
Copyright (C) 2013-2014 Yusuke Suzuki <utatane.tea@gmail.com>
|
||
Copyright (C) 2014 Ivan Nikulin <ifaaan@gmail.com>
|
||
|
||
Redistribution and use in source and binary forms, with or without
|
||
modification, are permitted provided that the following conditions are met:
|
||
|
||
* Redistributions of source code must retain the above copyright
|
||
notice, this list of conditions and the following disclaimer.
|
||
* Redistributions in binary form must reproduce the above copyright
|
||
notice, this list of conditions and the following disclaimer in the
|
||
documentation and/or other materials provided with the distribution.
|
||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||
*/
|
||
|
||
(function () {
|
||
'use strict';
|
||
|
||
var ES6Regex, ES5Regex, NON_ASCII_WHITESPACES, IDENTIFIER_START, IDENTIFIER_PART, ch;
|
||
|
||
// See `tools/generate-identifier-regex.js`.
|
||
ES5Regex = {
|
||
// ECMAScript 5.1/Unicode v7.0.0 NonAsciiIdentifierStart:
|
||
NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B2\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,
|
||
// ECMAScript 5.1/Unicode v7.0.0 NonAsciiIdentifierPart:
|
||
NonAsciiIdentifierPart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B2\u08E4-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA69D\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2D\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/
|
||
};
|
||
|
||
ES6Regex = {
|
||
// ECMAScript 6/Unicode v7.0.0 NonAsciiIdentifierStart:
|
||
NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B2\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDE00-\uDE11\uDE13-\uDE2B\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF5D-\uDF61]|\uD805[\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDE00-\uDE2F\uDE44\uDE80-\uDEAA]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF98]|\uD809[\uDC00-\uDC6E]|[\uD80C\uD840-\uD868\uD86A-\uD86C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D]|\uD87E[\uDC00-\uDE1D]/,
|
||
// ECMAScript 6/Unicode v7.0.0 NonAsciiIdentifierPart:
|
||
NonAsciiIdentifierPart: /[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B2\u08E4-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA69D\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2D\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDD0-\uDDDA\uDE00-\uDE11\uDE13-\uDE37\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF01-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF98]|\uD809[\uDC00-\uDC6E]|[\uD80C\uD840-\uD868\uD86A-\uD86C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/
|
||
};
|
||
|
||
function isDecimalDigit(ch) {
|
||
return 0x30 <= ch && ch <= 0x39; // 0..9
|
||
}
|
||
|
||
function isHexDigit(ch) {
|
||
return 0x30 <= ch && ch <= 0x39 || // 0..9
|
||
0x61 <= ch && ch <= 0x66 || // a..f
|
||
0x41 <= ch && ch <= 0x46; // A..F
|
||
}
|
||
|
||
function isOctalDigit(ch) {
|
||
return ch >= 0x30 && ch <= 0x37; // 0..7
|
||
}
|
||
|
||
// 7.2 White Space
|
||
|
||
NON_ASCII_WHITESPACES = [
|
||
0x1680, 0x180E,
|
||
0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A,
|
||
0x202F, 0x205F,
|
||
0x3000,
|
||
0xFEFF
|
||
];
|
||
|
||
function isWhiteSpace(ch) {
|
||
return ch === 0x20 || ch === 0x09 || ch === 0x0B || ch === 0x0C || ch === 0xA0 ||
|
||
ch >= 0x1680 && NON_ASCII_WHITESPACES.indexOf(ch) >= 0;
|
||
}
|
||
|
||
// 7.3 Line Terminators
|
||
|
||
function isLineTerminator(ch) {
|
||
return ch === 0x0A || ch === 0x0D || ch === 0x2028 || ch === 0x2029;
|
||
}
|
||
|
||
// 7.6 Identifier Names and Identifiers
|
||
|
||
function fromCodePoint(cp) {
|
||
if (cp <= 0xFFFF) { return String.fromCharCode(cp); }
|
||
var cu1 = String.fromCharCode(Math.floor((cp - 0x10000) / 0x400) + 0xD800);
|
||
var cu2 = String.fromCharCode(((cp - 0x10000) % 0x400) + 0xDC00);
|
||
return cu1 + cu2;
|
||
}
|
||
|
||
IDENTIFIER_START = new Array(0x80);
|
||
for(ch = 0; ch < 0x80; ++ch) {
|
||
IDENTIFIER_START[ch] =
|
||
ch >= 0x61 && ch <= 0x7A || // a..z
|
||
ch >= 0x41 && ch <= 0x5A || // A..Z
|
||
ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore)
|
||
}
|
||
|
||
IDENTIFIER_PART = new Array(0x80);
|
||
for(ch = 0; ch < 0x80; ++ch) {
|
||
IDENTIFIER_PART[ch] =
|
||
ch >= 0x61 && ch <= 0x7A || // a..z
|
||
ch >= 0x41 && ch <= 0x5A || // A..Z
|
||
ch >= 0x30 && ch <= 0x39 || // 0..9
|
||
ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore)
|
||
}
|
||
|
||
function isIdentifierStartES5(ch) {
|
||
return ch < 0x80 ? IDENTIFIER_START[ch] : ES5Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch));
|
||
}
|
||
|
||
function isIdentifierPartES5(ch) {
|
||
return ch < 0x80 ? IDENTIFIER_PART[ch] : ES5Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch));
|
||
}
|
||
|
||
function isIdentifierStartES6(ch) {
|
||
return ch < 0x80 ? IDENTIFIER_START[ch] : ES6Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch));
|
||
}
|
||
|
||
function isIdentifierPartES6(ch) {
|
||
return ch < 0x80 ? IDENTIFIER_PART[ch] : ES6Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch));
|
||
}
|
||
|
||
module.exports = {
|
||
isDecimalDigit: isDecimalDigit,
|
||
isHexDigit: isHexDigit,
|
||
isOctalDigit: isOctalDigit,
|
||
isWhiteSpace: isWhiteSpace,
|
||
isLineTerminator: isLineTerminator,
|
||
isIdentifierStartES5: isIdentifierStartES5,
|
||
isIdentifierPartES5: isIdentifierPartES5,
|
||
isIdentifierStartES6: isIdentifierStartES6,
|
||
isIdentifierPartES6: isIdentifierPartES6
|
||
};
|
||
}());
|
||
|
||
|
||
/***/ }),
|
||
/* 136 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = validate;
|
||
exports.validateField = validateField;
|
||
|
||
var _definitions = __webpack_require__(16);
|
||
|
||
function validate(node, key, val) {
|
||
if (!node) return;
|
||
const fields = _definitions.NODE_FIELDS[node.type];
|
||
if (!fields) return;
|
||
const field = fields[key];
|
||
validateField(node, key, val, field);
|
||
}
|
||
|
||
function validateField(node, key, val, field) {
|
||
if (!field || !field.validate) return;
|
||
if (field.optional && val == null) return;
|
||
field.validate(node, key, val);
|
||
}
|
||
|
||
/***/ }),
|
||
/* 137 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = isNode;
|
||
|
||
var _definitions = __webpack_require__(16);
|
||
|
||
function isNode(node) {
|
||
return !!(node && _definitions.VISITOR_KEYS[node.type]);
|
||
}
|
||
|
||
/***/ }),
|
||
/* 138 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = removeTypeDuplicates;
|
||
|
||
var _generated = __webpack_require__(5);
|
||
|
||
function removeTypeDuplicates(nodes) {
|
||
const generics = {};
|
||
const bases = {};
|
||
const typeGroups = [];
|
||
const types = [];
|
||
|
||
for (let i = 0; i < nodes.length; i++) {
|
||
const node = nodes[i];
|
||
if (!node) continue;
|
||
|
||
if (types.indexOf(node) >= 0) {
|
||
continue;
|
||
}
|
||
|
||
if ((0, _generated.isAnyTypeAnnotation)(node)) {
|
||
return [node];
|
||
}
|
||
|
||
if ((0, _generated.isFlowBaseAnnotation)(node)) {
|
||
bases[node.type] = node;
|
||
continue;
|
||
}
|
||
|
||
if ((0, _generated.isUnionTypeAnnotation)(node)) {
|
||
if (typeGroups.indexOf(node.types) < 0) {
|
||
nodes = nodes.concat(node.types);
|
||
typeGroups.push(node.types);
|
||
}
|
||
|
||
continue;
|
||
}
|
||
|
||
if ((0, _generated.isGenericTypeAnnotation)(node)) {
|
||
const name = node.id.name;
|
||
|
||
if (generics[name]) {
|
||
let existing = generics[name];
|
||
|
||
if (existing.typeParameters) {
|
||
if (node.typeParameters) {
|
||
existing.typeParameters.params = removeTypeDuplicates(existing.typeParameters.params.concat(node.typeParameters.params));
|
||
}
|
||
} else {
|
||
existing = node.typeParameters;
|
||
}
|
||
} else {
|
||
generics[name] = node;
|
||
}
|
||
|
||
continue;
|
||
}
|
||
|
||
types.push(node);
|
||
}
|
||
|
||
for (const type of Object.keys(bases)) {
|
||
types.push(bases[type]);
|
||
}
|
||
|
||
for (const name of Object.keys(generics)) {
|
||
types.push(generics[name]);
|
||
}
|
||
|
||
return types;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 139 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = clone;
|
||
|
||
var _cloneNode = _interopRequireDefault(__webpack_require__(31));
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function clone(node) {
|
||
return (0, _cloneNode.default)(node, false);
|
||
}
|
||
|
||
/***/ }),
|
||
/* 140 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = addComments;
|
||
|
||
function addComments(node, type, comments) {
|
||
if (!comments || !node) return node;
|
||
const key = `${type}Comments`;
|
||
|
||
if (node[key]) {
|
||
if (type === "leading") {
|
||
node[key] = comments.concat(node[key]);
|
||
} else {
|
||
node[key] = node[key].concat(comments);
|
||
}
|
||
} else {
|
||
node[key] = comments;
|
||
}
|
||
|
||
return node;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 141 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = inheritInnerComments;
|
||
|
||
var _inherit = _interopRequireDefault(__webpack_require__(85));
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function inheritInnerComments(child, parent) {
|
||
(0, _inherit.default)("innerComments", child, parent);
|
||
}
|
||
|
||
/***/ }),
|
||
/* 142 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var MapCache = __webpack_require__(73),
|
||
setCacheAdd = __webpack_require__(283),
|
||
setCacheHas = __webpack_require__(284);
|
||
|
||
/**
|
||
*
|
||
* Creates an array cache object to store unique values.
|
||
*
|
||
* @private
|
||
* @constructor
|
||
* @param {Array} [values] The values to cache.
|
||
*/
|
||
function SetCache(values) {
|
||
var index = -1,
|
||
length = values == null ? 0 : values.length;
|
||
|
||
this.__data__ = new MapCache;
|
||
while (++index < length) {
|
||
this.add(values[index]);
|
||
}
|
||
}
|
||
|
||
// Add methods to `SetCache`.
|
||
SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
|
||
SetCache.prototype.has = setCacheHas;
|
||
|
||
module.exports = SetCache;
|
||
|
||
|
||
/***/ }),
|
||
/* 143 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* Checks if a `cache` value for `key` exists.
|
||
*
|
||
* @private
|
||
* @param {Object} cache The cache to query.
|
||
* @param {string} key The key of the entry to check.
|
||
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
||
*/
|
||
function cacheHas(cache, key) {
|
||
return cache.has(key);
|
||
}
|
||
|
||
module.exports = cacheHas;
|
||
|
||
|
||
/***/ }),
|
||
/* 144 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = inheritLeadingComments;
|
||
|
||
var _inherit = _interopRequireDefault(__webpack_require__(85));
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function inheritLeadingComments(child, parent) {
|
||
(0, _inherit.default)("leadingComments", child, parent);
|
||
}
|
||
|
||
/***/ }),
|
||
/* 145 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = inheritsComments;
|
||
|
||
var _inheritTrailingComments = _interopRequireDefault(__webpack_require__(146));
|
||
|
||
var _inheritLeadingComments = _interopRequireDefault(__webpack_require__(144));
|
||
|
||
var _inheritInnerComments = _interopRequireDefault(__webpack_require__(141));
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function inheritsComments(child, parent) {
|
||
(0, _inheritTrailingComments.default)(child, parent);
|
||
(0, _inheritLeadingComments.default)(child, parent);
|
||
(0, _inheritInnerComments.default)(child, parent);
|
||
return child;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 146 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = inheritTrailingComments;
|
||
|
||
var _inherit = _interopRequireDefault(__webpack_require__(85));
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function inheritTrailingComments(child, parent) {
|
||
(0, _inherit.default)("trailingComments", child, parent);
|
||
}
|
||
|
||
/***/ }),
|
||
/* 147 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = toBlock;
|
||
|
||
var _generated = __webpack_require__(5);
|
||
|
||
var _generated2 = __webpack_require__(10);
|
||
|
||
function toBlock(node, parent) {
|
||
if ((0, _generated.isBlockStatement)(node)) {
|
||
return node;
|
||
}
|
||
|
||
let blockNodes = [];
|
||
|
||
if ((0, _generated.isEmptyStatement)(node)) {
|
||
blockNodes = [];
|
||
} else {
|
||
if (!(0, _generated.isStatement)(node)) {
|
||
if ((0, _generated.isFunction)(parent)) {
|
||
node = (0, _generated2.returnStatement)(node);
|
||
} else {
|
||
node = (0, _generated2.expressionStatement)(node);
|
||
}
|
||
}
|
||
|
||
blockNodes = [node];
|
||
}
|
||
|
||
return (0, _generated2.blockStatement)(blockNodes);
|
||
}
|
||
|
||
/***/ }),
|
||
/* 148 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = toIdentifier;
|
||
|
||
var _isValidIdentifier = _interopRequireDefault(__webpack_require__(30));
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function toIdentifier(name) {
|
||
name = name + "";
|
||
name = name.replace(/[^a-zA-Z0-9$_]/g, "-");
|
||
name = name.replace(/^[-0-9]+/, "");
|
||
name = name.replace(/[-\s]+(.)?/g, function (match, c) {
|
||
return c ? c.toUpperCase() : "";
|
||
});
|
||
|
||
if (!(0, _isValidIdentifier.default)(name)) {
|
||
name = `_${name}`;
|
||
}
|
||
|
||
return name || "_";
|
||
}
|
||
|
||
/***/ }),
|
||
/* 149 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = removePropertiesDeep;
|
||
|
||
var _traverseFast = _interopRequireDefault(__webpack_require__(150));
|
||
|
||
var _removeProperties = _interopRequireDefault(__webpack_require__(151));
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function removePropertiesDeep(tree, opts) {
|
||
(0, _traverseFast.default)(tree, _removeProperties.default, opts);
|
||
return tree;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 150 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = traverseFast;
|
||
|
||
var _definitions = __webpack_require__(16);
|
||
|
||
function traverseFast(node, enter, opts) {
|
||
if (!node) return;
|
||
const keys = _definitions.VISITOR_KEYS[node.type];
|
||
if (!keys) return;
|
||
opts = opts || {};
|
||
enter(node, opts);
|
||
|
||
for (const key of keys) {
|
||
const subNode = node[key];
|
||
|
||
if (Array.isArray(subNode)) {
|
||
for (const node of subNode) {
|
||
traverseFast(node, enter, opts);
|
||
}
|
||
} else {
|
||
traverseFast(subNode, enter, opts);
|
||
}
|
||
}
|
||
}
|
||
|
||
/***/ }),
|
||
/* 151 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = removeProperties;
|
||
|
||
var _constants = __webpack_require__(27);
|
||
|
||
const CLEAR_KEYS = ["tokens", "start", "end", "loc", "raw", "rawValue"];
|
||
|
||
const CLEAR_KEYS_PLUS_COMMENTS = _constants.COMMENT_KEYS.concat(["comments"]).concat(CLEAR_KEYS);
|
||
|
||
function removeProperties(node, opts = {}) {
|
||
const map = opts.preserveComments ? CLEAR_KEYS : CLEAR_KEYS_PLUS_COMMENTS;
|
||
|
||
for (const key of map) {
|
||
if (node[key] != null) node[key] = undefined;
|
||
}
|
||
|
||
for (const key of Object.keys(node)) {
|
||
if (key[0] === "_" && node[key] != null) node[key] = undefined;
|
||
}
|
||
|
||
const symbols = Object.getOwnPropertySymbols(node);
|
||
|
||
for (const sym of symbols) {
|
||
node[sym] = null;
|
||
}
|
||
}
|
||
|
||
/***/ }),
|
||
/* 152 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = isLet;
|
||
|
||
var _generated = __webpack_require__(5);
|
||
|
||
var _constants = __webpack_require__(27);
|
||
|
||
function isLet(node) {
|
||
return (0, _generated.isVariableDeclaration)(node) && (node.kind !== "var" || node[_constants.BLOCK_SCOPED_SYMBOL]);
|
||
}
|
||
|
||
/***/ }),
|
||
/* 153 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = createSimplePath;
|
||
|
||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||
function createSimplePath(ancestors) {
|
||
if (ancestors.length === 0) {
|
||
return null;
|
||
} // Slice the array because babel-types traverse may continue mutating
|
||
// the ancestors array in later traversal logic.
|
||
|
||
|
||
return new SimplePath(ancestors.slice());
|
||
}
|
||
|
||
/**
|
||
* Mimics @babel/traverse's NodePath API in a simpler fashion that isn't as
|
||
* heavy, but still allows the ease of passing paths around to process nested
|
||
* AST structures.
|
||
*/
|
||
class SimplePath {
|
||
constructor(ancestors, index = ancestors.length - 1) {
|
||
if (index < 0 || index >= ancestors.length) {
|
||
console.error(ancestors);
|
||
throw new Error("Created invalid path");
|
||
}
|
||
|
||
this._ancestors = ancestors;
|
||
this._ancestor = ancestors[index];
|
||
this._index = index;
|
||
}
|
||
|
||
get parentPath() {
|
||
let path = this._parentPath;
|
||
|
||
if (path === undefined) {
|
||
if (this._index === 0) {
|
||
path = null;
|
||
} else {
|
||
path = new SimplePath(this._ancestors, this._index - 1);
|
||
}
|
||
|
||
this._parentPath = path;
|
||
}
|
||
|
||
return path;
|
||
}
|
||
|
||
get parent() {
|
||
return this._ancestor.node;
|
||
}
|
||
|
||
get node() {
|
||
const {
|
||
node,
|
||
key,
|
||
index
|
||
} = this._ancestor;
|
||
|
||
if (typeof index === "number") {
|
||
return node[key][index];
|
||
}
|
||
|
||
return node[key];
|
||
}
|
||
|
||
get key() {
|
||
return this._ancestor.key;
|
||
}
|
||
|
||
set node(replacement) {
|
||
if (this.type !== "Identifier") {
|
||
throw new Error("Replacing anything other than leaf nodes is undefined behavior " + "in t.traverse()");
|
||
}
|
||
|
||
const {
|
||
node,
|
||
key,
|
||
index
|
||
} = this._ancestor;
|
||
|
||
if (typeof index === "number") {
|
||
node[key][index] = replacement;
|
||
} else {
|
||
node[key] = replacement;
|
||
}
|
||
}
|
||
|
||
get type() {
|
||
return this.node.type;
|
||
}
|
||
|
||
get inList() {
|
||
return typeof this._ancestor.index === "number";
|
||
}
|
||
|
||
get containerIndex() {
|
||
const {
|
||
index
|
||
} = this._ancestor;
|
||
|
||
if (typeof index !== "number") {
|
||
throw new Error("Cannot get index of non-array node");
|
||
}
|
||
|
||
return index;
|
||
}
|
||
|
||
get depth() {
|
||
return this._index;
|
||
}
|
||
|
||
replace(node) {
|
||
this.node = node;
|
||
}
|
||
|
||
find(predicate) {
|
||
for (let path = this; path; path = path.parentPath) {
|
||
if (predicate(path)) {
|
||
return path;
|
||
}
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
findParent(predicate) {
|
||
if (!this.parentPath) {
|
||
throw new Error("Cannot use findParent on root path");
|
||
}
|
||
|
||
return this.parentPath.find(predicate);
|
||
}
|
||
|
||
getSibling(offset) {
|
||
const {
|
||
node,
|
||
key,
|
||
index
|
||
} = this._ancestor;
|
||
|
||
if (typeof index !== "number") {
|
||
throw new Error("Non-array nodes do not have siblings");
|
||
}
|
||
|
||
const container = node[key];
|
||
const siblingIndex = index + offset;
|
||
|
||
if (siblingIndex < 0 || siblingIndex >= container.length) {
|
||
return null;
|
||
}
|
||
|
||
return new SimplePath(this._ancestors.slice(0, -1).concat([{
|
||
node,
|
||
key,
|
||
index: siblingIndex
|
||
}]));
|
||
}
|
||
|
||
}
|
||
|
||
/***/ }),
|
||
/* 154 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var baseKeys = __webpack_require__(125),
|
||
getTag = __webpack_require__(29),
|
||
isArguments = __webpack_require__(74),
|
||
isArray = __webpack_require__(9),
|
||
isArrayLike = __webpack_require__(52),
|
||
isBuffer = __webpack_require__(48),
|
||
isPrototype = __webpack_require__(51),
|
||
isTypedArray = __webpack_require__(76);
|
||
|
||
/** `Object#toString` result references. */
|
||
var mapTag = '[object Map]',
|
||
setTag = '[object Set]';
|
||
|
||
/** Used for built-in method references. */
|
||
var objectProto = Object.prototype;
|
||
|
||
/** Used to check objects for own properties. */
|
||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||
|
||
/**
|
||
* Checks if `value` is an empty object, collection, map, or set.
|
||
*
|
||
* Objects are considered empty if they have no own enumerable string keyed
|
||
* properties.
|
||
*
|
||
* Array-like values such as `arguments` objects, arrays, buffers, strings, or
|
||
* jQuery-like collections are considered empty if they have a `length` of `0`.
|
||
* Similarly, maps and sets are considered empty if they have a `size` of `0`.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 0.1.0
|
||
* @category Lang
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is empty, else `false`.
|
||
* @example
|
||
*
|
||
* _.isEmpty(null);
|
||
* // => true
|
||
*
|
||
* _.isEmpty(true);
|
||
* // => true
|
||
*
|
||
* _.isEmpty(1);
|
||
* // => true
|
||
*
|
||
* _.isEmpty([1, 2, 3]);
|
||
* // => false
|
||
*
|
||
* _.isEmpty({ 'a': 1 });
|
||
* // => false
|
||
*/
|
||
function isEmpty(value) {
|
||
if (value == null) {
|
||
return true;
|
||
}
|
||
if (isArrayLike(value) &&
|
||
(isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
|
||
isBuffer(value) || isTypedArray(value) || isArguments(value))) {
|
||
return !value.length;
|
||
}
|
||
var tag = getTag(value);
|
||
if (tag == mapTag || tag == setTag) {
|
||
return !value.size;
|
||
}
|
||
if (isPrototype(value)) {
|
||
return !baseKeys(value).length;
|
||
}
|
||
for (var key in value) {
|
||
if (hasOwnProperty.call(value, key)) {
|
||
return false;
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
|
||
module.exports = isEmpty;
|
||
|
||
|
||
/***/ }),
|
||
/* 155 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.setSource = setSource;
|
||
exports.getSource = getSource;
|
||
exports.clearSources = clearSources;
|
||
|
||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||
const cachedSources = new Map();
|
||
|
||
function setSource(source) {
|
||
cachedSources.set(source.id, source);
|
||
}
|
||
|
||
function getSource(sourceId) {
|
||
const source = cachedSources.get(sourceId);
|
||
|
||
if (!source) {
|
||
throw new Error(`Parser: source ${sourceId} was not provided.`);
|
||
}
|
||
|
||
return source;
|
||
}
|
||
|
||
function clearSources() {
|
||
cachedSources.clear();
|
||
}
|
||
|
||
/***/ }),
|
||
/* 156 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.needsWhitespace = needsWhitespace;
|
||
exports.needsWhitespaceBefore = needsWhitespaceBefore;
|
||
exports.needsWhitespaceAfter = needsWhitespaceAfter;
|
||
exports.needsParens = needsParens;
|
||
|
||
var whitespace = _interopRequireWildcard(__webpack_require__(335));
|
||
|
||
var parens = _interopRequireWildcard(__webpack_require__(336));
|
||
|
||
function t() {
|
||
const data = _interopRequireWildcard(__webpack_require__(3));
|
||
|
||
t = function () {
|
||
return data;
|
||
};
|
||
|
||
return data;
|
||
}
|
||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||
|
||
function expandAliases(obj) {
|
||
const newObj = {};
|
||
|
||
function add(type, func) {
|
||
const fn = newObj[type];
|
||
newObj[type] = fn ? function (node, parent, stack) {
|
||
const result = fn(node, parent, stack);
|
||
return result == null ? func(node, parent, stack) : result;
|
||
} : func;
|
||
}
|
||
|
||
for (const type of Object.keys(obj)) {
|
||
const aliases = t().FLIPPED_ALIAS_KEYS[type];
|
||
|
||
if (aliases) {
|
||
for (const alias of aliases) {
|
||
add(alias, obj[type]);
|
||
}
|
||
} else {
|
||
add(type, obj[type]);
|
||
}
|
||
}
|
||
|
||
return newObj;
|
||
}
|
||
|
||
const expandedParens = expandAliases(parens);
|
||
const expandedWhitespaceNodes = expandAliases(whitespace.nodes);
|
||
const expandedWhitespaceList = expandAliases(whitespace.list);
|
||
|
||
function find(obj, node, parent, printStack) {
|
||
const fn = obj[node.type];
|
||
return fn ? fn(node, parent, printStack) : null;
|
||
}
|
||
|
||
function isOrHasCallExpression(node) {
|
||
if (t().isCallExpression(node)) {
|
||
return true;
|
||
}
|
||
|
||
if (t().isMemberExpression(node)) {
|
||
return isOrHasCallExpression(node.object) || !node.computed && isOrHasCallExpression(node.property);
|
||
} else {
|
||
return false;
|
||
}
|
||
}
|
||
|
||
function needsWhitespace(node, parent, type) {
|
||
if (!node) return 0;
|
||
|
||
if (t().isExpressionStatement(node)) {
|
||
node = node.expression;
|
||
}
|
||
|
||
let linesInfo = find(expandedWhitespaceNodes, node, parent);
|
||
|
||
if (!linesInfo) {
|
||
const items = find(expandedWhitespaceList, node, parent);
|
||
|
||
if (items) {
|
||
for (let i = 0; i < items.length; i++) {
|
||
linesInfo = needsWhitespace(items[i], node, type);
|
||
if (linesInfo) break;
|
||
}
|
||
}
|
||
}
|
||
|
||
if (typeof linesInfo === "object" && linesInfo !== null) {
|
||
return linesInfo[type] || 0;
|
||
}
|
||
|
||
return 0;
|
||
}
|
||
|
||
function needsWhitespaceBefore(node, parent) {
|
||
return needsWhitespace(node, parent, "before");
|
||
}
|
||
|
||
function needsWhitespaceAfter(node, parent) {
|
||
return needsWhitespace(node, parent, "after");
|
||
}
|
||
|
||
function needsParens(node, parent, printStack) {
|
||
if (!parent) return false;
|
||
|
||
if (t().isNewExpression(parent) && parent.callee === node) {
|
||
if (isOrHasCallExpression(node)) return true;
|
||
}
|
||
|
||
return find(expandedParens, node, parent, printStack);
|
||
}
|
||
|
||
/***/ }),
|
||
/* 157 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.ImportSpecifier = ImportSpecifier;
|
||
exports.ImportDefaultSpecifier = ImportDefaultSpecifier;
|
||
exports.ExportDefaultSpecifier = ExportDefaultSpecifier;
|
||
exports.ExportSpecifier = ExportSpecifier;
|
||
exports.ExportNamespaceSpecifier = ExportNamespaceSpecifier;
|
||
exports.ExportAllDeclaration = ExportAllDeclaration;
|
||
exports.ExportNamedDeclaration = ExportNamedDeclaration;
|
||
exports.ExportDefaultDeclaration = ExportDefaultDeclaration;
|
||
exports.ImportDeclaration = ImportDeclaration;
|
||
exports.ImportNamespaceSpecifier = ImportNamespaceSpecifier;
|
||
|
||
function t() {
|
||
const data = _interopRequireWildcard(__webpack_require__(3));
|
||
|
||
t = function () {
|
||
return data;
|
||
};
|
||
|
||
return data;
|
||
}
|
||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||
|
||
function ImportSpecifier(node) {
|
||
if (node.importKind === "type" || node.importKind === "typeof") {
|
||
this.word(node.importKind);
|
||
this.space();
|
||
}
|
||
|
||
this.print(node.imported, node);
|
||
|
||
if (node.local && node.local.name !== node.imported.name) {
|
||
this.space();
|
||
this.word("as");
|
||
this.space();
|
||
this.print(node.local, node);
|
||
}
|
||
}
|
||
|
||
function ImportDefaultSpecifier(node) {
|
||
this.print(node.local, node);
|
||
}
|
||
|
||
function ExportDefaultSpecifier(node) {
|
||
this.print(node.exported, node);
|
||
}
|
||
|
||
function ExportSpecifier(node) {
|
||
this.print(node.local, node);
|
||
|
||
if (node.exported && node.local.name !== node.exported.name) {
|
||
this.space();
|
||
this.word("as");
|
||
this.space();
|
||
this.print(node.exported, node);
|
||
}
|
||
}
|
||
|
||
function ExportNamespaceSpecifier(node) {
|
||
this.token("*");
|
||
this.space();
|
||
this.word("as");
|
||
this.space();
|
||
this.print(node.exported, node);
|
||
}
|
||
|
||
function ExportAllDeclaration(node) {
|
||
this.word("export");
|
||
this.space();
|
||
|
||
if (node.exportKind === "type") {
|
||
this.word("type");
|
||
this.space();
|
||
}
|
||
|
||
this.token("*");
|
||
this.space();
|
||
this.word("from");
|
||
this.space();
|
||
this.print(node.source, node);
|
||
this.semicolon();
|
||
}
|
||
|
||
function ExportNamedDeclaration(node) {
|
||
if (this.format.decoratorsBeforeExport && t().isClassDeclaration(node.declaration)) {
|
||
this.printJoin(node.declaration.decorators, node);
|
||
}
|
||
|
||
this.word("export");
|
||
this.space();
|
||
ExportDeclaration.apply(this, arguments);
|
||
}
|
||
|
||
function ExportDefaultDeclaration(node) {
|
||
if (this.format.decoratorsBeforeExport && t().isClassDeclaration(node.declaration)) {
|
||
this.printJoin(node.declaration.decorators, node);
|
||
}
|
||
|
||
this.word("export");
|
||
this.space();
|
||
this.word("default");
|
||
this.space();
|
||
ExportDeclaration.apply(this, arguments);
|
||
}
|
||
|
||
function ExportDeclaration(node) {
|
||
if (node.declaration) {
|
||
const declar = node.declaration;
|
||
this.print(declar, node);
|
||
if (!t().isStatement(declar)) this.semicolon();
|
||
} else {
|
||
if (node.exportKind === "type") {
|
||
this.word("type");
|
||
this.space();
|
||
}
|
||
|
||
const specifiers = node.specifiers.slice(0);
|
||
let hasSpecial = false;
|
||
|
||
while (true) {
|
||
const first = specifiers[0];
|
||
|
||
if (t().isExportDefaultSpecifier(first) || t().isExportNamespaceSpecifier(first)) {
|
||
hasSpecial = true;
|
||
this.print(specifiers.shift(), node);
|
||
|
||
if (specifiers.length) {
|
||
this.token(",");
|
||
this.space();
|
||
}
|
||
} else {
|
||
break;
|
||
}
|
||
}
|
||
|
||
if (specifiers.length || !specifiers.length && !hasSpecial) {
|
||
this.token("{");
|
||
|
||
if (specifiers.length) {
|
||
this.space();
|
||
this.printList(specifiers, node);
|
||
this.space();
|
||
}
|
||
|
||
this.token("}");
|
||
}
|
||
|
||
if (node.source) {
|
||
this.space();
|
||
this.word("from");
|
||
this.space();
|
||
this.print(node.source, node);
|
||
}
|
||
|
||
this.semicolon();
|
||
}
|
||
}
|
||
|
||
function ImportDeclaration(node) {
|
||
this.word("import");
|
||
this.space();
|
||
|
||
if (node.importKind === "type" || node.importKind === "typeof") {
|
||
this.word(node.importKind);
|
||
this.space();
|
||
}
|
||
|
||
const specifiers = node.specifiers.slice(0);
|
||
|
||
if (specifiers && specifiers.length) {
|
||
while (true) {
|
||
const first = specifiers[0];
|
||
|
||
if (t().isImportDefaultSpecifier(first) || t().isImportNamespaceSpecifier(first)) {
|
||
this.print(specifiers.shift(), node);
|
||
|
||
if (specifiers.length) {
|
||
this.token(",");
|
||
this.space();
|
||
}
|
||
} else {
|
||
break;
|
||
}
|
||
}
|
||
|
||
if (specifiers.length) {
|
||
this.token("{");
|
||
this.space();
|
||
this.printList(specifiers, node);
|
||
this.space();
|
||
this.token("}");
|
||
}
|
||
|
||
this.space();
|
||
this.word("from");
|
||
this.space();
|
||
}
|
||
|
||
this.print(node.source, node);
|
||
this.semicolon();
|
||
}
|
||
|
||
function ImportNamespaceSpecifier(node) {
|
||
this.token("*");
|
||
this.space();
|
||
this.word("as");
|
||
this.space();
|
||
this.print(node.local, node);
|
||
}
|
||
|
||
/***/ }),
|
||
/* 158 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = getFunctionName;
|
||
|
||
var t = _interopRequireWildcard(__webpack_require__(3));
|
||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||
|
||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||
// Perform ES6's anonymous function name inference for all
|
||
// locations where static analysis is possible.
|
||
// eslint-disable-next-line complexity
|
||
function getFunctionName(node, parent) {
|
||
if (t.isIdentifier(node.id)) {
|
||
return node.id.name;
|
||
}
|
||
|
||
if (t.isObjectMethod(node, {
|
||
computed: false
|
||
}) || t.isClassMethod(node, {
|
||
computed: false
|
||
})) {
|
||
const key = node.key;
|
||
|
||
if (t.isIdentifier(key)) {
|
||
return key.name;
|
||
}
|
||
|
||
if (t.isStringLiteral(key)) {
|
||
return key.value;
|
||
}
|
||
|
||
if (t.isNumericLiteral(key)) {
|
||
return `${key.value}`;
|
||
}
|
||
}
|
||
|
||
if (t.isObjectProperty(parent, {
|
||
computed: false,
|
||
value: node
|
||
}) || // TODO: Babylon 6 doesn't support computed class props. It is included
|
||
// here so that it is most flexible. Once Babylon 7 is used, this
|
||
// can change to use computed: false like ObjectProperty.
|
||
t.isClassProperty(parent, {
|
||
value: node
|
||
}) && !parent.computed) {
|
||
const key = parent.key;
|
||
|
||
if (t.isIdentifier(key)) {
|
||
return key.name;
|
||
}
|
||
|
||
if (t.isStringLiteral(key)) {
|
||
return key.value;
|
||
}
|
||
|
||
if (t.isNumericLiteral(key)) {
|
||
return `${key.value}`;
|
||
}
|
||
}
|
||
|
||
if (t.isAssignmentExpression(parent, {
|
||
operator: "=",
|
||
right: node
|
||
})) {
|
||
if (t.isIdentifier(parent.left)) {
|
||
return parent.left.name;
|
||
} // This case is not supported in standard ES6 name inference, but it
|
||
// is included here since it is still a helpful case during debugging.
|
||
|
||
|
||
if (t.isMemberExpression(parent.left, {
|
||
computed: false
|
||
})) {
|
||
return parent.left.property.name;
|
||
}
|
||
}
|
||
|
||
if (t.isAssignmentPattern(parent, {
|
||
right: node
|
||
}) && t.isIdentifier(parent.left)) {
|
||
return parent.left.name;
|
||
}
|
||
|
||
if (t.isVariableDeclarator(parent, {
|
||
init: node
|
||
}) && t.isIdentifier(parent.id)) {
|
||
return parent.id.name;
|
||
}
|
||
|
||
if (t.isExportDefaultDeclaration(parent, {
|
||
declaration: node
|
||
}) && t.isFunctionDeclaration(node)) {
|
||
return "default";
|
||
}
|
||
|
||
return "anonymous";
|
||
}
|
||
|
||
/***/ }),
|
||
/* 159 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.getFramework = getFramework;
|
||
|
||
var t = _interopRequireWildcard(__webpack_require__(3));
|
||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||
|
||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||
function getFramework(symbols) {
|
||
if (isReactComponent(symbols)) {
|
||
return "React";
|
||
}
|
||
|
||
if (isAngularComponent(symbols)) {
|
||
return "Angular";
|
||
}
|
||
|
||
if (isVueComponent(symbols)) {
|
||
return "Vue";
|
||
}
|
||
}
|
||
|
||
function isReactComponent({
|
||
imports,
|
||
classes,
|
||
callExpressions,
|
||
identifiers
|
||
}) {
|
||
return importsReact(imports) || requiresReact(callExpressions) || extendsReactComponent(classes) || isReact(identifiers) || isRedux(identifiers);
|
||
}
|
||
|
||
function importsReact(imports) {
|
||
return imports.some(importObj => importObj.source === "react" && importObj.specifiers.some(specifier => specifier === "React"));
|
||
}
|
||
|
||
function requiresReact(callExpressions) {
|
||
return callExpressions.some(callExpression => callExpression.name === "require" && callExpression.values.some(value => value === "react"));
|
||
}
|
||
|
||
function extendsReactComponent(classes) {
|
||
return classes.some(classObj => t.isIdentifier(classObj.parent, {
|
||
name: "Component"
|
||
}) || t.isIdentifier(classObj.parent, {
|
||
name: "PureComponent"
|
||
}) || t.isMemberExpression(classObj.parent, {
|
||
computed: false
|
||
}) && t.isIdentifier(classObj.parent, {
|
||
name: "Component"
|
||
}));
|
||
}
|
||
|
||
function isAngularComponent({
|
||
memberExpressions
|
||
}) {
|
||
return memberExpressions.some(item => item.expression == "angular.controller" || item.expression == "angular.module");
|
||
}
|
||
|
||
function isVueComponent({
|
||
identifiers
|
||
}) {
|
||
return identifiers.some(identifier => identifier.name == "Vue");
|
||
}
|
||
/* This identifies the react lib file */
|
||
|
||
|
||
function isReact(identifiers) {
|
||
return identifiers.some(identifier => identifier.name == "isReactComponent");
|
||
}
|
||
/* This identifies the redux lib file */
|
||
|
||
|
||
function isRedux(identifiers) {
|
||
return identifiers.some(identifier => identifier.name == "Redux");
|
||
}
|
||
|
||
/***/ }),
|
||
/* 160 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = getScopes;
|
||
exports.clearScopes = clearScopes;
|
||
Object.defineProperty(exports, "buildScopeList", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _visitor.buildScopeList;
|
||
}
|
||
});
|
||
|
||
var _visitor = __webpack_require__(349);
|
||
|
||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||
let parsedScopesCache = new Map();
|
||
|
||
function getScopes(location) {
|
||
const {
|
||
sourceId
|
||
} = location;
|
||
let parsedScopes = parsedScopesCache.get(sourceId);
|
||
|
||
if (!parsedScopes) {
|
||
parsedScopes = (0, _visitor.parseSourceScopes)(sourceId);
|
||
parsedScopesCache.set(sourceId, parsedScopes);
|
||
}
|
||
|
||
return parsedScopes ? findScopes(parsedScopes, location) : [];
|
||
}
|
||
|
||
function clearScopes() {
|
||
parsedScopesCache = new Map();
|
||
}
|
||
|
||
/**
|
||
* Searches all scopes and their bindings at the specific location.
|
||
*/
|
||
function findScopes(scopes, location) {
|
||
// Find inner most in the tree structure.
|
||
let searchInScopes = scopes;
|
||
const found = [];
|
||
|
||
while (searchInScopes) {
|
||
const foundOne = searchInScopes.some(s => {
|
||
if (compareLocations(s.start, location) <= 0 && compareLocations(location, s.end) < 0) {
|
||
// Found the next scope, trying to search recusevly in its children.
|
||
found.unshift(s);
|
||
searchInScopes = s.children;
|
||
return true;
|
||
}
|
||
|
||
return false;
|
||
});
|
||
|
||
if (!foundOne) {
|
||
break;
|
||
}
|
||
}
|
||
|
||
return found.map(i => ({
|
||
type: i.type,
|
||
scopeKind: i.scopeKind,
|
||
displayName: i.displayName,
|
||
start: i.start,
|
||
end: i.end,
|
||
bindings: i.bindings
|
||
}));
|
||
}
|
||
|
||
function compareLocations(a, b) {
|
||
// According to type of Location.column can be undefined, if will not be the
|
||
// case here, ignoring flow error.
|
||
// $FlowIgnore
|
||
return a.line == b.line ? a.column - b.column : a.line - b.line;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 161 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var baseGet = __webpack_require__(162);
|
||
|
||
/**
|
||
* Gets the value at `path` of `object`. If the resolved value is
|
||
* `undefined`, the `defaultValue` is returned in its place.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 3.7.0
|
||
* @category Object
|
||
* @param {Object} object The object to query.
|
||
* @param {Array|string} path The path of the property to get.
|
||
* @param {*} [defaultValue] The value returned for `undefined` resolved values.
|
||
* @returns {*} Returns the resolved value.
|
||
* @example
|
||
*
|
||
* var object = { 'a': [{ 'b': { 'c': 3 } }] };
|
||
*
|
||
* _.get(object, 'a[0].b.c');
|
||
* // => 3
|
||
*
|
||
* _.get(object, ['a', '0', 'b', 'c']);
|
||
* // => 3
|
||
*
|
||
* _.get(object, 'a.b.c', 'default');
|
||
* // => 'default'
|
||
*/
|
||
function get(object, path, defaultValue) {
|
||
var result = object == null ? undefined : baseGet(object, path);
|
||
return result === undefined ? defaultValue : result;
|
||
}
|
||
|
||
module.exports = get;
|
||
|
||
|
||
/***/ }),
|
||
/* 162 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var castPath = __webpack_require__(163),
|
||
toKey = __webpack_require__(59);
|
||
|
||
/**
|
||
* The base implementation of `_.get` without support for default values.
|
||
*
|
||
* @private
|
||
* @param {Object} object The object to query.
|
||
* @param {Array|string} path The path of the property to get.
|
||
* @returns {*} Returns the resolved value.
|
||
*/
|
||
function baseGet(object, path) {
|
||
path = castPath(path, object);
|
||
|
||
var index = 0,
|
||
length = path.length;
|
||
|
||
while (object != null && index < length) {
|
||
object = object[toKey(path[index++])];
|
||
}
|
||
return (index && index == length) ? object : undefined;
|
||
}
|
||
|
||
module.exports = baseGet;
|
||
|
||
|
||
/***/ }),
|
||
/* 163 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var isArray = __webpack_require__(9),
|
||
isKey = __webpack_require__(101),
|
||
stringToPath = __webpack_require__(351),
|
||
toString = __webpack_require__(57);
|
||
|
||
/**
|
||
* Casts `value` to a path array if it's not one.
|
||
*
|
||
* @private
|
||
* @param {*} value The value to inspect.
|
||
* @param {Object} [object] The object to query keys on.
|
||
* @returns {Array} Returns the cast property path array.
|
||
*/
|
||
function castPath(value, object) {
|
||
if (isArray(value)) {
|
||
return value;
|
||
}
|
||
return isKey(value, object) ? [value] : stringToPath(toString(value));
|
||
}
|
||
|
||
module.exports = castPath;
|
||
|
||
|
||
/***/ }),
|
||
/* 164 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var baseMatches = __webpack_require__(355),
|
||
baseMatchesProperty = __webpack_require__(363),
|
||
identity = __webpack_require__(367),
|
||
isArray = __webpack_require__(9),
|
||
property = __webpack_require__(368);
|
||
|
||
/**
|
||
* The base implementation of `_.iteratee`.
|
||
*
|
||
* @private
|
||
* @param {*} [value=_.identity] The value to convert to an iteratee.
|
||
* @returns {Function} Returns the iteratee.
|
||
*/
|
||
function baseIteratee(value) {
|
||
// Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
|
||
// See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
|
||
if (typeof value == 'function') {
|
||
return value;
|
||
}
|
||
if (value == null) {
|
||
return identity;
|
||
}
|
||
if (typeof value == 'object') {
|
||
return isArray(value)
|
||
? baseMatchesProperty(value[0], value[1])
|
||
: baseMatches(value);
|
||
}
|
||
return property(value);
|
||
}
|
||
|
||
module.exports = baseIteratee;
|
||
|
||
|
||
/***/ }),
|
||
/* 165 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var baseIsEqualDeep = __webpack_require__(357),
|
||
isObjectLike = __webpack_require__(11);
|
||
|
||
/**
|
||
* The base implementation of `_.isEqual` which supports partial comparisons
|
||
* and tracks traversed objects.
|
||
*
|
||
* @private
|
||
* @param {*} value The value to compare.
|
||
* @param {*} other The other value to compare.
|
||
* @param {boolean} bitmask The bitmask flags.
|
||
* 1 - Unordered comparison
|
||
* 2 - Partial comparison
|
||
* @param {Function} [customizer] The function to customize comparisons.
|
||
* @param {Object} [stack] Tracks traversed `value` and `other` objects.
|
||
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
||
*/
|
||
function baseIsEqual(value, other, bitmask, customizer, stack) {
|
||
if (value === other) {
|
||
return true;
|
||
}
|
||
if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
|
||
return value !== value && other !== other;
|
||
}
|
||
return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
|
||
}
|
||
|
||
module.exports = baseIsEqual;
|
||
|
||
|
||
/***/ }),
|
||
/* 166 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var SetCache = __webpack_require__(142),
|
||
arraySome = __webpack_require__(358),
|
||
cacheHas = __webpack_require__(143);
|
||
|
||
/** Used to compose bitmasks for value comparisons. */
|
||
var COMPARE_PARTIAL_FLAG = 1,
|
||
COMPARE_UNORDERED_FLAG = 2;
|
||
|
||
/**
|
||
* A specialized version of `baseIsEqualDeep` for arrays with support for
|
||
* partial deep comparisons.
|
||
*
|
||
* @private
|
||
* @param {Array} array The array to compare.
|
||
* @param {Array} other The other array to compare.
|
||
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
||
* @param {Function} customizer The function to customize comparisons.
|
||
* @param {Function} equalFunc The function to determine equivalents of values.
|
||
* @param {Object} stack Tracks traversed `array` and `other` objects.
|
||
* @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
|
||
*/
|
||
function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
|
||
var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
|
||
arrLength = array.length,
|
||
othLength = other.length;
|
||
|
||
if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
|
||
return false;
|
||
}
|
||
// Assume cyclic values are equal.
|
||
var stacked = stack.get(array);
|
||
if (stacked && stack.get(other)) {
|
||
return stacked == other;
|
||
}
|
||
var index = -1,
|
||
result = true,
|
||
seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
|
||
|
||
stack.set(array, other);
|
||
stack.set(other, array);
|
||
|
||
// Ignore non-index properties.
|
||
while (++index < arrLength) {
|
||
var arrValue = array[index],
|
||
othValue = other[index];
|
||
|
||
if (customizer) {
|
||
var compared = isPartial
|
||
? customizer(othValue, arrValue, index, other, array, stack)
|
||
: customizer(arrValue, othValue, index, array, other, stack);
|
||
}
|
||
if (compared !== undefined) {
|
||
if (compared) {
|
||
continue;
|
||
}
|
||
result = false;
|
||
break;
|
||
}
|
||
// Recursively compare arrays (susceptible to call stack limits).
|
||
if (seen) {
|
||
if (!arraySome(other, function(othValue, othIndex) {
|
||
if (!cacheHas(seen, othIndex) &&
|
||
(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
|
||
return seen.push(othIndex);
|
||
}
|
||
})) {
|
||
result = false;
|
||
break;
|
||
}
|
||
} else if (!(
|
||
arrValue === othValue ||
|
||
equalFunc(arrValue, othValue, bitmask, customizer, stack)
|
||
)) {
|
||
result = false;
|
||
break;
|
||
}
|
||
}
|
||
stack['delete'](array);
|
||
stack['delete'](other);
|
||
return result;
|
||
}
|
||
|
||
module.exports = equalArrays;
|
||
|
||
|
||
/***/ }),
|
||
/* 167 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var isObject = __webpack_require__(21);
|
||
|
||
/**
|
||
* Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
|
||
*
|
||
* @private
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` if suitable for strict
|
||
* equality comparisons, else `false`.
|
||
*/
|
||
function isStrictComparable(value) {
|
||
return value === value && !isObject(value);
|
||
}
|
||
|
||
module.exports = isStrictComparable;
|
||
|
||
|
||
/***/ }),
|
||
/* 168 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* A specialized version of `matchesProperty` for source values suitable
|
||
* for strict equality comparisons, i.e. `===`.
|
||
*
|
||
* @private
|
||
* @param {string} key The key of the property to get.
|
||
* @param {*} srcValue The value to match.
|
||
* @returns {Function} Returns the new spec function.
|
||
*/
|
||
function matchesStrictComparable(key, srcValue) {
|
||
return function(object) {
|
||
if (object == null) {
|
||
return false;
|
||
}
|
||
return object[key] === srcValue &&
|
||
(srcValue !== undefined || (key in Object(object)));
|
||
};
|
||
}
|
||
|
||
module.exports = matchesStrictComparable;
|
||
|
||
|
||
/***/ }),
|
||
/* 169 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.containsPosition = containsPosition;
|
||
exports.containsLocation = containsLocation;
|
||
exports.nodeContainsPosition = nodeContainsPosition;
|
||
|
||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||
function startsBefore(a, b) {
|
||
let before = a.start.line < b.line;
|
||
|
||
if (a.start.line === b.line) {
|
||
before = a.start.column >= 0 && b.column >= 0 ? a.start.column <= b.column : true;
|
||
}
|
||
|
||
return before;
|
||
}
|
||
|
||
function endsAfter(a, b) {
|
||
let after = a.end.line > b.line;
|
||
|
||
if (a.end.line === b.line) {
|
||
after = a.end.column >= 0 && b.column >= 0 ? a.end.column >= b.column : true;
|
||
}
|
||
|
||
return after;
|
||
}
|
||
|
||
function containsPosition(a, b) {
|
||
return startsBefore(a, b) && endsAfter(a, b);
|
||
}
|
||
|
||
function containsLocation(a, b) {
|
||
return containsPosition(a, b.start) && containsPosition(a, b.end);
|
||
}
|
||
|
||
function nodeContainsPosition(node, position) {
|
||
return containsPosition(node.loc, position);
|
||
}
|
||
|
||
/***/ }),
|
||
/* 170 */,
|
||
/* 171 */,
|
||
/* 172 */,
|
||
/* 173 */,
|
||
/* 174 */,
|
||
/* 175 */,
|
||
/* 176 */,
|
||
/* 177 */,
|
||
/* 178 */,
|
||
/* 179 */,
|
||
/* 180 */,
|
||
/* 181 */,
|
||
/* 182 */,
|
||
/* 183 */,
|
||
/* 184 */,
|
||
/* 185 */,
|
||
/* 186 */,
|
||
/* 187 */,
|
||
/* 188 */,
|
||
/* 189 */,
|
||
/* 190 */,
|
||
/* 191 */,
|
||
/* 192 */,
|
||
/* 193 */,
|
||
/* 194 */,
|
||
/* 195 */,
|
||
/* 196 */,
|
||
/* 197 */,
|
||
/* 198 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
module.exports = __webpack_require__(199);
|
||
|
||
|
||
/***/ }),
|
||
/* 199 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
var _getSymbols = __webpack_require__(117);
|
||
|
||
var _ast = __webpack_require__(20);
|
||
|
||
var _getScopes = _interopRequireWildcard(__webpack_require__(160));
|
||
|
||
var _sources = __webpack_require__(155);
|
||
|
||
var _findOutOfScopeLocations = _interopRequireDefault(__webpack_require__(350));
|
||
|
||
var _steps = __webpack_require__(372);
|
||
|
||
var _validate = __webpack_require__(374);
|
||
|
||
var _mapExpression = _interopRequireDefault(__webpack_require__(375));
|
||
|
||
var _devtoolsUtils = __webpack_require__(7);
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||
|
||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||
const {
|
||
workerHandler
|
||
} = _devtoolsUtils.workerUtils;
|
||
|
||
function clearState() {
|
||
(0, _ast.clearASTs)();
|
||
(0, _getScopes.clearScopes)();
|
||
(0, _sources.clearSources)();
|
||
(0, _getSymbols.clearSymbols)();
|
||
}
|
||
|
||
self.onmessage = workerHandler({
|
||
findOutOfScopeLocations: _findOutOfScopeLocations.default,
|
||
getSymbols: _getSymbols.getSymbols,
|
||
getScopes: _getScopes.default,
|
||
clearState,
|
||
getNextStep: _steps.getNextStep,
|
||
hasSyntaxError: _validate.hasSyntaxError,
|
||
mapExpression: _mapExpression.default,
|
||
setSource: _sources.setSource
|
||
});
|
||
|
||
/***/ }),
|
||
/* 200 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
|
||
var _buildMatchMemberExpression = _interopRequireDefault(__webpack_require__(118));
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
const isReactComponent = (0, _buildMatchMemberExpression.default)("React.Component");
|
||
var _default = isReactComponent;
|
||
exports.default = _default;
|
||
|
||
/***/ }),
|
||
/* 201 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = isCompatTag;
|
||
|
||
function isCompatTag(tagName) {
|
||
return !!tagName && /^[a-z]/.test(tagName);
|
||
}
|
||
|
||
/***/ }),
|
||
/* 202 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = buildChildren;
|
||
|
||
var _generated = __webpack_require__(5);
|
||
|
||
var _cleanJSXElementLiteralChild = _interopRequireDefault(__webpack_require__(203));
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function buildChildren(node) {
|
||
const elements = [];
|
||
|
||
for (let i = 0; i < node.children.length; i++) {
|
||
let child = node.children[i];
|
||
|
||
if ((0, _generated.isJSXText)(child)) {
|
||
(0, _cleanJSXElementLiteralChild.default)(child, elements);
|
||
continue;
|
||
}
|
||
|
||
if ((0, _generated.isJSXExpressionContainer)(child)) child = child.expression;
|
||
if ((0, _generated.isJSXEmptyExpression)(child)) continue;
|
||
elements.push(child);
|
||
}
|
||
|
||
return elements;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 203 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = cleanJSXElementLiteralChild;
|
||
|
||
var _generated = __webpack_require__(10);
|
||
|
||
function cleanJSXElementLiteralChild(child, args) {
|
||
const lines = child.value.split(/\r\n|\n|\r/);
|
||
let lastNonEmptyLine = 0;
|
||
|
||
for (let i = 0; i < lines.length; i++) {
|
||
if (lines[i].match(/[^ \t]/)) {
|
||
lastNonEmptyLine = i;
|
||
}
|
||
}
|
||
|
||
let str = "";
|
||
|
||
for (let i = 0; i < lines.length; i++) {
|
||
const line = lines[i];
|
||
const isFirstLine = i === 0;
|
||
const isLastLine = i === lines.length - 1;
|
||
const isLastNonEmptyLine = i === lastNonEmptyLine;
|
||
let trimmedLine = line.replace(/\t/g, " ");
|
||
|
||
if (!isFirstLine) {
|
||
trimmedLine = trimmedLine.replace(/^[ ]+/, "");
|
||
}
|
||
|
||
if (!isLastLine) {
|
||
trimmedLine = trimmedLine.replace(/[ ]+$/, "");
|
||
}
|
||
|
||
if (trimmedLine) {
|
||
if (!isLastNonEmptyLine) {
|
||
trimmedLine += " ";
|
||
}
|
||
|
||
str += trimmedLine;
|
||
}
|
||
}
|
||
|
||
if (str) args.push((0, _generated.stringLiteral)(str));
|
||
}
|
||
|
||
/***/ }),
|
||
/* 204 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = builder;
|
||
|
||
function _clone() {
|
||
const data = _interopRequireDefault(__webpack_require__(205));
|
||
|
||
_clone = function () {
|
||
return data;
|
||
};
|
||
|
||
return data;
|
||
}
|
||
|
||
var _definitions = __webpack_require__(16);
|
||
|
||
var _validate = _interopRequireDefault(__webpack_require__(136));
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function builder(type, ...args) {
|
||
const keys = _definitions.BUILDER_KEYS[type];
|
||
const countArgs = args.length;
|
||
|
||
if (countArgs > keys.length) {
|
||
throw new Error(`${type}: Too many arguments passed. Received ${countArgs} but can receive no more than ${keys.length}`);
|
||
}
|
||
|
||
const node = {
|
||
type
|
||
};
|
||
let i = 0;
|
||
keys.forEach(key => {
|
||
const field = _definitions.NODE_FIELDS[type][key];
|
||
let arg;
|
||
if (i < countArgs) arg = args[i];
|
||
if (arg === undefined) arg = (0, _clone().default)(field.default);
|
||
node[key] = arg;
|
||
i++;
|
||
});
|
||
|
||
for (const key of Object.keys(node)) {
|
||
(0, _validate.default)(node, key, node[key]);
|
||
}
|
||
|
||
return node;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 205 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var baseClone = __webpack_require__(206);
|
||
|
||
/** Used to compose bitmasks for cloning. */
|
||
var CLONE_SYMBOLS_FLAG = 4;
|
||
|
||
/**
|
||
* Creates a shallow clone of `value`.
|
||
*
|
||
* **Note:** This method is loosely based on the
|
||
* [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
|
||
* and supports cloning arrays, array buffers, booleans, date objects, maps,
|
||
* numbers, `Object` objects, regexes, sets, strings, symbols, and typed
|
||
* arrays. The own enumerable properties of `arguments` objects are cloned
|
||
* as plain objects. An empty object is returned for uncloneable values such
|
||
* as error objects, functions, DOM nodes, and WeakMaps.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 0.1.0
|
||
* @category Lang
|
||
* @param {*} value The value to clone.
|
||
* @returns {*} Returns the cloned value.
|
||
* @see _.cloneDeep
|
||
* @example
|
||
*
|
||
* var objects = [{ 'a': 1 }, { 'b': 2 }];
|
||
*
|
||
* var shallow = _.clone(objects);
|
||
* console.log(shallow[0] === objects[0]);
|
||
* // => true
|
||
*/
|
||
function clone(value) {
|
||
return baseClone(value, CLONE_SYMBOLS_FLAG);
|
||
}
|
||
|
||
module.exports = clone;
|
||
|
||
|
||
/***/ }),
|
||
/* 206 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var Stack = __webpack_require__(69),
|
||
arrayEach = __webpack_require__(233),
|
||
assignValue = __webpack_require__(122),
|
||
baseAssign = __webpack_require__(235),
|
||
baseAssignIn = __webpack_require__(241),
|
||
cloneBuffer = __webpack_require__(244),
|
||
copyArray = __webpack_require__(245),
|
||
copySymbols = __webpack_require__(246),
|
||
copySymbolsIn = __webpack_require__(248),
|
||
getAllKeys = __webpack_require__(131),
|
||
getAllKeysIn = __webpack_require__(249),
|
||
getTag = __webpack_require__(29),
|
||
initCloneArray = __webpack_require__(253),
|
||
initCloneByTag = __webpack_require__(254),
|
||
initCloneObject = __webpack_require__(259),
|
||
isArray = __webpack_require__(9),
|
||
isBuffer = __webpack_require__(48),
|
||
isMap = __webpack_require__(261),
|
||
isObject = __webpack_require__(21),
|
||
isSet = __webpack_require__(263),
|
||
keys = __webpack_require__(47);
|
||
|
||
/** Used to compose bitmasks for cloning. */
|
||
var CLONE_DEEP_FLAG = 1,
|
||
CLONE_FLAT_FLAG = 2,
|
||
CLONE_SYMBOLS_FLAG = 4;
|
||
|
||
/** `Object#toString` result references. */
|
||
var argsTag = '[object Arguments]',
|
||
arrayTag = '[object Array]',
|
||
boolTag = '[object Boolean]',
|
||
dateTag = '[object Date]',
|
||
errorTag = '[object Error]',
|
||
funcTag = '[object Function]',
|
||
genTag = '[object GeneratorFunction]',
|
||
mapTag = '[object Map]',
|
||
numberTag = '[object Number]',
|
||
objectTag = '[object Object]',
|
||
regexpTag = '[object RegExp]',
|
||
setTag = '[object Set]',
|
||
stringTag = '[object String]',
|
||
symbolTag = '[object Symbol]',
|
||
weakMapTag = '[object WeakMap]';
|
||
|
||
var arrayBufferTag = '[object ArrayBuffer]',
|
||
dataViewTag = '[object DataView]',
|
||
float32Tag = '[object Float32Array]',
|
||
float64Tag = '[object Float64Array]',
|
||
int8Tag = '[object Int8Array]',
|
||
int16Tag = '[object Int16Array]',
|
||
int32Tag = '[object Int32Array]',
|
||
uint8Tag = '[object Uint8Array]',
|
||
uint8ClampedTag = '[object Uint8ClampedArray]',
|
||
uint16Tag = '[object Uint16Array]',
|
||
uint32Tag = '[object Uint32Array]';
|
||
|
||
/** Used to identify `toStringTag` values supported by `_.clone`. */
|
||
var cloneableTags = {};
|
||
cloneableTags[argsTag] = cloneableTags[arrayTag] =
|
||
cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
|
||
cloneableTags[boolTag] = cloneableTags[dateTag] =
|
||
cloneableTags[float32Tag] = cloneableTags[float64Tag] =
|
||
cloneableTags[int8Tag] = cloneableTags[int16Tag] =
|
||
cloneableTags[int32Tag] = cloneableTags[mapTag] =
|
||
cloneableTags[numberTag] = cloneableTags[objectTag] =
|
||
cloneableTags[regexpTag] = cloneableTags[setTag] =
|
||
cloneableTags[stringTag] = cloneableTags[symbolTag] =
|
||
cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
|
||
cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
|
||
cloneableTags[errorTag] = cloneableTags[funcTag] =
|
||
cloneableTags[weakMapTag] = false;
|
||
|
||
/**
|
||
* The base implementation of `_.clone` and `_.cloneDeep` which tracks
|
||
* traversed objects.
|
||
*
|
||
* @private
|
||
* @param {*} value The value to clone.
|
||
* @param {boolean} bitmask The bitmask flags.
|
||
* 1 - Deep clone
|
||
* 2 - Flatten inherited properties
|
||
* 4 - Clone symbols
|
||
* @param {Function} [customizer] The function to customize cloning.
|
||
* @param {string} [key] The key of `value`.
|
||
* @param {Object} [object] The parent object of `value`.
|
||
* @param {Object} [stack] Tracks traversed objects and their clone counterparts.
|
||
* @returns {*} Returns the cloned value.
|
||
*/
|
||
function baseClone(value, bitmask, customizer, key, object, stack) {
|
||
var result,
|
||
isDeep = bitmask & CLONE_DEEP_FLAG,
|
||
isFlat = bitmask & CLONE_FLAT_FLAG,
|
||
isFull = bitmask & CLONE_SYMBOLS_FLAG;
|
||
|
||
if (customizer) {
|
||
result = object ? customizer(value, key, object, stack) : customizer(value);
|
||
}
|
||
if (result !== undefined) {
|
||
return result;
|
||
}
|
||
if (!isObject(value)) {
|
||
return value;
|
||
}
|
||
var isArr = isArray(value);
|
||
if (isArr) {
|
||
result = initCloneArray(value);
|
||
if (!isDeep) {
|
||
return copyArray(value, result);
|
||
}
|
||
} else {
|
||
var tag = getTag(value),
|
||
isFunc = tag == funcTag || tag == genTag;
|
||
|
||
if (isBuffer(value)) {
|
||
return cloneBuffer(value, isDeep);
|
||
}
|
||
if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
|
||
result = (isFlat || isFunc) ? {} : initCloneObject(value);
|
||
if (!isDeep) {
|
||
return isFlat
|
||
? copySymbolsIn(value, baseAssignIn(result, value))
|
||
: copySymbols(value, baseAssign(result, value));
|
||
}
|
||
} else {
|
||
if (!cloneableTags[tag]) {
|
||
return object ? value : {};
|
||
}
|
||
result = initCloneByTag(value, tag, isDeep);
|
||
}
|
||
}
|
||
// Check for circular references and return its corresponding clone.
|
||
stack || (stack = new Stack);
|
||
var stacked = stack.get(value);
|
||
if (stacked) {
|
||
return stacked;
|
||
}
|
||
stack.set(value, result);
|
||
|
||
if (isSet(value)) {
|
||
value.forEach(function(subValue) {
|
||
result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
|
||
});
|
||
} else if (isMap(value)) {
|
||
value.forEach(function(subValue, key) {
|
||
result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
|
||
});
|
||
}
|
||
|
||
var keysFunc = isFull
|
||
? (isFlat ? getAllKeysIn : getAllKeys)
|
||
: (isFlat ? keysIn : keys);
|
||
|
||
var props = isArr ? undefined : keysFunc(value);
|
||
arrayEach(props || value, function(subValue, key) {
|
||
if (props) {
|
||
key = subValue;
|
||
subValue = value[key];
|
||
}
|
||
// Recursively populate clone (susceptible to call stack limits).
|
||
assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
|
||
});
|
||
return result;
|
||
}
|
||
|
||
module.exports = baseClone;
|
||
|
||
|
||
/***/ }),
|
||
/* 207 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* Removes all key-value entries from the list cache.
|
||
*
|
||
* @private
|
||
* @name clear
|
||
* @memberOf ListCache
|
||
*/
|
||
function listCacheClear() {
|
||
this.__data__ = [];
|
||
this.size = 0;
|
||
}
|
||
|
||
module.exports = listCacheClear;
|
||
|
||
|
||
/***/ }),
|
||
/* 208 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var assocIndexOf = __webpack_require__(41);
|
||
|
||
/** Used for built-in method references. */
|
||
var arrayProto = Array.prototype;
|
||
|
||
/** Built-in value references. */
|
||
var splice = arrayProto.splice;
|
||
|
||
/**
|
||
* Removes `key` and its value from the list cache.
|
||
*
|
||
* @private
|
||
* @name delete
|
||
* @memberOf ListCache
|
||
* @param {string} key The key of the value to remove.
|
||
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
||
*/
|
||
function listCacheDelete(key) {
|
||
var data = this.__data__,
|
||
index = assocIndexOf(data, key);
|
||
|
||
if (index < 0) {
|
||
return false;
|
||
}
|
||
var lastIndex = data.length - 1;
|
||
if (index == lastIndex) {
|
||
data.pop();
|
||
} else {
|
||
splice.call(data, index, 1);
|
||
}
|
||
--this.size;
|
||
return true;
|
||
}
|
||
|
||
module.exports = listCacheDelete;
|
||
|
||
|
||
/***/ }),
|
||
/* 209 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var assocIndexOf = __webpack_require__(41);
|
||
|
||
/**
|
||
* Gets the list cache value for `key`.
|
||
*
|
||
* @private
|
||
* @name get
|
||
* @memberOf ListCache
|
||
* @param {string} key The key of the value to get.
|
||
* @returns {*} Returns the entry value.
|
||
*/
|
||
function listCacheGet(key) {
|
||
var data = this.__data__,
|
||
index = assocIndexOf(data, key);
|
||
|
||
return index < 0 ? undefined : data[index][1];
|
||
}
|
||
|
||
module.exports = listCacheGet;
|
||
|
||
|
||
/***/ }),
|
||
/* 210 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var assocIndexOf = __webpack_require__(41);
|
||
|
||
/**
|
||
* Checks if a list cache value for `key` exists.
|
||
*
|
||
* @private
|
||
* @name has
|
||
* @memberOf ListCache
|
||
* @param {string} key The key of the entry to check.
|
||
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
||
*/
|
||
function listCacheHas(key) {
|
||
return assocIndexOf(this.__data__, key) > -1;
|
||
}
|
||
|
||
module.exports = listCacheHas;
|
||
|
||
|
||
/***/ }),
|
||
/* 211 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var assocIndexOf = __webpack_require__(41);
|
||
|
||
/**
|
||
* Sets the list cache `key` to `value`.
|
||
*
|
||
* @private
|
||
* @name set
|
||
* @memberOf ListCache
|
||
* @param {string} key The key of the value to set.
|
||
* @param {*} value The value to set.
|
||
* @returns {Object} Returns the list cache instance.
|
||
*/
|
||
function listCacheSet(key, value) {
|
||
var data = this.__data__,
|
||
index = assocIndexOf(data, key);
|
||
|
||
if (index < 0) {
|
||
++this.size;
|
||
data.push([key, value]);
|
||
} else {
|
||
data[index][1] = value;
|
||
}
|
||
return this;
|
||
}
|
||
|
||
module.exports = listCacheSet;
|
||
|
||
|
||
/***/ }),
|
||
/* 212 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var ListCache = __webpack_require__(40);
|
||
|
||
/**
|
||
* Removes all key-value entries from the stack.
|
||
*
|
||
* @private
|
||
* @name clear
|
||
* @memberOf Stack
|
||
*/
|
||
function stackClear() {
|
||
this.__data__ = new ListCache;
|
||
this.size = 0;
|
||
}
|
||
|
||
module.exports = stackClear;
|
||
|
||
|
||
/***/ }),
|
||
/* 213 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* Removes `key` and its value from the stack.
|
||
*
|
||
* @private
|
||
* @name delete
|
||
* @memberOf Stack
|
||
* @param {string} key The key of the value to remove.
|
||
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
||
*/
|
||
function stackDelete(key) {
|
||
var data = this.__data__,
|
||
result = data['delete'](key);
|
||
|
||
this.size = data.size;
|
||
return result;
|
||
}
|
||
|
||
module.exports = stackDelete;
|
||
|
||
|
||
/***/ }),
|
||
/* 214 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* Gets the stack value for `key`.
|
||
*
|
||
* @private
|
||
* @name get
|
||
* @memberOf Stack
|
||
* @param {string} key The key of the value to get.
|
||
* @returns {*} Returns the entry value.
|
||
*/
|
||
function stackGet(key) {
|
||
return this.__data__.get(key);
|
||
}
|
||
|
||
module.exports = stackGet;
|
||
|
||
|
||
/***/ }),
|
||
/* 215 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* Checks if a stack value for `key` exists.
|
||
*
|
||
* @private
|
||
* @name has
|
||
* @memberOf Stack
|
||
* @param {string} key The key of the entry to check.
|
||
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
||
*/
|
||
function stackHas(key) {
|
||
return this.__data__.has(key);
|
||
}
|
||
|
||
module.exports = stackHas;
|
||
|
||
|
||
/***/ }),
|
||
/* 216 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var ListCache = __webpack_require__(40),
|
||
Map = __webpack_require__(70),
|
||
MapCache = __webpack_require__(73);
|
||
|
||
/** Used as the size to enable large array optimizations. */
|
||
var LARGE_ARRAY_SIZE = 200;
|
||
|
||
/**
|
||
* Sets the stack `key` to `value`.
|
||
*
|
||
* @private
|
||
* @name set
|
||
* @memberOf Stack
|
||
* @param {string} key The key of the value to set.
|
||
* @param {*} value The value to set.
|
||
* @returns {Object} Returns the stack cache instance.
|
||
*/
|
||
function stackSet(key, value) {
|
||
var data = this.__data__;
|
||
if (data instanceof ListCache) {
|
||
var pairs = data.__data__;
|
||
if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
|
||
pairs.push([key, value]);
|
||
this.size = ++data.size;
|
||
return this;
|
||
}
|
||
data = this.__data__ = new MapCache(pairs);
|
||
}
|
||
data.set(key, value);
|
||
this.size = data.size;
|
||
return this;
|
||
}
|
||
|
||
module.exports = stackSet;
|
||
|
||
|
||
/***/ }),
|
||
/* 217 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var isFunction = __webpack_require__(120),
|
||
isMasked = __webpack_require__(218),
|
||
isObject = __webpack_require__(21),
|
||
toSource = __webpack_require__(121);
|
||
|
||
/**
|
||
* Used to match `RegExp`
|
||
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
|
||
*/
|
||
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
||
|
||
/** Used to detect host constructors (Safari). */
|
||
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
||
|
||
/** Used for built-in method references. */
|
||
var funcProto = Function.prototype,
|
||
objectProto = Object.prototype;
|
||
|
||
/** Used to resolve the decompiled source of functions. */
|
||
var funcToString = funcProto.toString;
|
||
|
||
/** Used to check objects for own properties. */
|
||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||
|
||
/** Used to detect if a method is native. */
|
||
var reIsNative = RegExp('^' +
|
||
funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
|
||
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
|
||
);
|
||
|
||
/**
|
||
* The base implementation of `_.isNative` without bad shim checks.
|
||
*
|
||
* @private
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is a native function,
|
||
* else `false`.
|
||
*/
|
||
function baseIsNative(value) {
|
||
if (!isObject(value) || isMasked(value)) {
|
||
return false;
|
||
}
|
||
var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
|
||
return pattern.test(toSource(value));
|
||
}
|
||
|
||
module.exports = baseIsNative;
|
||
|
||
|
||
/***/ }),
|
||
/* 218 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var coreJsData = __webpack_require__(219);
|
||
|
||
/** Used to detect methods masquerading as native. */
|
||
var maskSrcKey = (function() {
|
||
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
|
||
return uid ? ('Symbol(src)_1.' + uid) : '';
|
||
}());
|
||
|
||
/**
|
||
* Checks if `func` has its source masked.
|
||
*
|
||
* @private
|
||
* @param {Function} func The function to check.
|
||
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
|
||
*/
|
||
function isMasked(func) {
|
||
return !!maskSrcKey && (maskSrcKey in func);
|
||
}
|
||
|
||
module.exports = isMasked;
|
||
|
||
|
||
/***/ }),
|
||
/* 219 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var root = __webpack_require__(8);
|
||
|
||
/** Used to detect overreaching core-js shims. */
|
||
var coreJsData = root['__core-js_shared__'];
|
||
|
||
module.exports = coreJsData;
|
||
|
||
|
||
/***/ }),
|
||
/* 220 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* Gets the value at `key` of `object`.
|
||
*
|
||
* @private
|
||
* @param {Object} [object] The object to query.
|
||
* @param {string} key The key of the property to get.
|
||
* @returns {*} Returns the property value.
|
||
*/
|
||
function getValue(object, key) {
|
||
return object == null ? undefined : object[key];
|
||
}
|
||
|
||
module.exports = getValue;
|
||
|
||
|
||
/***/ }),
|
||
/* 221 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var Hash = __webpack_require__(222),
|
||
ListCache = __webpack_require__(40),
|
||
Map = __webpack_require__(70);
|
||
|
||
/**
|
||
* Removes all key-value entries from the map.
|
||
*
|
||
* @private
|
||
* @name clear
|
||
* @memberOf MapCache
|
||
*/
|
||
function mapCacheClear() {
|
||
this.size = 0;
|
||
this.__data__ = {
|
||
'hash': new Hash,
|
||
'map': new (Map || ListCache),
|
||
'string': new Hash
|
||
};
|
||
}
|
||
|
||
module.exports = mapCacheClear;
|
||
|
||
|
||
/***/ }),
|
||
/* 222 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var hashClear = __webpack_require__(223),
|
||
hashDelete = __webpack_require__(224),
|
||
hashGet = __webpack_require__(225),
|
||
hashHas = __webpack_require__(226),
|
||
hashSet = __webpack_require__(227);
|
||
|
||
/**
|
||
* Creates a hash object.
|
||
*
|
||
* @private
|
||
* @constructor
|
||
* @param {Array} [entries] The key-value pairs to cache.
|
||
*/
|
||
function Hash(entries) {
|
||
var index = -1,
|
||
length = entries == null ? 0 : entries.length;
|
||
|
||
this.clear();
|
||
while (++index < length) {
|
||
var entry = entries[index];
|
||
this.set(entry[0], entry[1]);
|
||
}
|
||
}
|
||
|
||
// Add methods to `Hash`.
|
||
Hash.prototype.clear = hashClear;
|
||
Hash.prototype['delete'] = hashDelete;
|
||
Hash.prototype.get = hashGet;
|
||
Hash.prototype.has = hashHas;
|
||
Hash.prototype.set = hashSet;
|
||
|
||
module.exports = Hash;
|
||
|
||
|
||
/***/ }),
|
||
/* 223 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var nativeCreate = __webpack_require__(44);
|
||
|
||
/**
|
||
* Removes all key-value entries from the hash.
|
||
*
|
||
* @private
|
||
* @name clear
|
||
* @memberOf Hash
|
||
*/
|
||
function hashClear() {
|
||
this.__data__ = nativeCreate ? nativeCreate(null) : {};
|
||
this.size = 0;
|
||
}
|
||
|
||
module.exports = hashClear;
|
||
|
||
|
||
/***/ }),
|
||
/* 224 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* Removes `key` and its value from the hash.
|
||
*
|
||
* @private
|
||
* @name delete
|
||
* @memberOf Hash
|
||
* @param {Object} hash The hash to modify.
|
||
* @param {string} key The key of the value to remove.
|
||
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
||
*/
|
||
function hashDelete(key) {
|
||
var result = this.has(key) && delete this.__data__[key];
|
||
this.size -= result ? 1 : 0;
|
||
return result;
|
||
}
|
||
|
||
module.exports = hashDelete;
|
||
|
||
|
||
/***/ }),
|
||
/* 225 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var nativeCreate = __webpack_require__(44);
|
||
|
||
/** Used to stand-in for `undefined` hash values. */
|
||
var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
||
|
||
/** Used for built-in method references. */
|
||
var objectProto = Object.prototype;
|
||
|
||
/** Used to check objects for own properties. */
|
||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||
|
||
/**
|
||
* Gets the hash value for `key`.
|
||
*
|
||
* @private
|
||
* @name get
|
||
* @memberOf Hash
|
||
* @param {string} key The key of the value to get.
|
||
* @returns {*} Returns the entry value.
|
||
*/
|
||
function hashGet(key) {
|
||
var data = this.__data__;
|
||
if (nativeCreate) {
|
||
var result = data[key];
|
||
return result === HASH_UNDEFINED ? undefined : result;
|
||
}
|
||
return hasOwnProperty.call(data, key) ? data[key] : undefined;
|
||
}
|
||
|
||
module.exports = hashGet;
|
||
|
||
|
||
/***/ }),
|
||
/* 226 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var nativeCreate = __webpack_require__(44);
|
||
|
||
/** Used for built-in method references. */
|
||
var objectProto = Object.prototype;
|
||
|
||
/** Used to check objects for own properties. */
|
||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||
|
||
/**
|
||
* Checks if a hash value for `key` exists.
|
||
*
|
||
* @private
|
||
* @name has
|
||
* @memberOf Hash
|
||
* @param {string} key The key of the entry to check.
|
||
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
||
*/
|
||
function hashHas(key) {
|
||
var data = this.__data__;
|
||
return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
|
||
}
|
||
|
||
module.exports = hashHas;
|
||
|
||
|
||
/***/ }),
|
||
/* 227 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var nativeCreate = __webpack_require__(44);
|
||
|
||
/** Used to stand-in for `undefined` hash values. */
|
||
var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
||
|
||
/**
|
||
* Sets the hash `key` to `value`.
|
||
*
|
||
* @private
|
||
* @name set
|
||
* @memberOf Hash
|
||
* @param {string} key The key of the value to set.
|
||
* @param {*} value The value to set.
|
||
* @returns {Object} Returns the hash instance.
|
||
*/
|
||
function hashSet(key, value) {
|
||
var data = this.__data__;
|
||
this.size += this.has(key) ? 0 : 1;
|
||
data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
|
||
return this;
|
||
}
|
||
|
||
module.exports = hashSet;
|
||
|
||
|
||
/***/ }),
|
||
/* 228 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var getMapData = __webpack_require__(45);
|
||
|
||
/**
|
||
* Removes `key` and its value from the map.
|
||
*
|
||
* @private
|
||
* @name delete
|
||
* @memberOf MapCache
|
||
* @param {string} key The key of the value to remove.
|
||
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
||
*/
|
||
function mapCacheDelete(key) {
|
||
var result = getMapData(this, key)['delete'](key);
|
||
this.size -= result ? 1 : 0;
|
||
return result;
|
||
}
|
||
|
||
module.exports = mapCacheDelete;
|
||
|
||
|
||
/***/ }),
|
||
/* 229 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* Checks if `value` is suitable for use as unique object key.
|
||
*
|
||
* @private
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is suitable, else `false`.
|
||
*/
|
||
function isKeyable(value) {
|
||
var type = typeof value;
|
||
return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
|
||
? (value !== '__proto__')
|
||
: (value === null);
|
||
}
|
||
|
||
module.exports = isKeyable;
|
||
|
||
|
||
/***/ }),
|
||
/* 230 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var getMapData = __webpack_require__(45);
|
||
|
||
/**
|
||
* Gets the map value for `key`.
|
||
*
|
||
* @private
|
||
* @name get
|
||
* @memberOf MapCache
|
||
* @param {string} key The key of the value to get.
|
||
* @returns {*} Returns the entry value.
|
||
*/
|
||
function mapCacheGet(key) {
|
||
return getMapData(this, key).get(key);
|
||
}
|
||
|
||
module.exports = mapCacheGet;
|
||
|
||
|
||
/***/ }),
|
||
/* 231 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var getMapData = __webpack_require__(45);
|
||
|
||
/**
|
||
* Checks if a map value for `key` exists.
|
||
*
|
||
* @private
|
||
* @name has
|
||
* @memberOf MapCache
|
||
* @param {string} key The key of the entry to check.
|
||
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
||
*/
|
||
function mapCacheHas(key) {
|
||
return getMapData(this, key).has(key);
|
||
}
|
||
|
||
module.exports = mapCacheHas;
|
||
|
||
|
||
/***/ }),
|
||
/* 232 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var getMapData = __webpack_require__(45);
|
||
|
||
/**
|
||
* Sets the map `key` to `value`.
|
||
*
|
||
* @private
|
||
* @name set
|
||
* @memberOf MapCache
|
||
* @param {string} key The key of the value to set.
|
||
* @param {*} value The value to set.
|
||
* @returns {Object} Returns the map cache instance.
|
||
*/
|
||
function mapCacheSet(key, value) {
|
||
var data = getMapData(this, key),
|
||
size = data.size;
|
||
|
||
data.set(key, value);
|
||
this.size += data.size == size ? 0 : 1;
|
||
return this;
|
||
}
|
||
|
||
module.exports = mapCacheSet;
|
||
|
||
|
||
/***/ }),
|
||
/* 233 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* A specialized version of `_.forEach` for arrays without support for
|
||
* iteratee shorthands.
|
||
*
|
||
* @private
|
||
* @param {Array} [array] The array to iterate over.
|
||
* @param {Function} iteratee The function invoked per iteration.
|
||
* @returns {Array} Returns `array`.
|
||
*/
|
||
function arrayEach(array, iteratee) {
|
||
var index = -1,
|
||
length = array == null ? 0 : array.length;
|
||
|
||
while (++index < length) {
|
||
if (iteratee(array[index], index, array) === false) {
|
||
break;
|
||
}
|
||
}
|
||
return array;
|
||
}
|
||
|
||
module.exports = arrayEach;
|
||
|
||
|
||
/***/ }),
|
||
/* 234 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var getNative = __webpack_require__(26);
|
||
|
||
var defineProperty = (function() {
|
||
try {
|
||
var func = getNative(Object, 'defineProperty');
|
||
func({}, '', {});
|
||
return func;
|
||
} catch (e) {}
|
||
}());
|
||
|
||
module.exports = defineProperty;
|
||
|
||
|
||
/***/ }),
|
||
/* 235 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var copyObject = __webpack_require__(46),
|
||
keys = __webpack_require__(47);
|
||
|
||
/**
|
||
* The base implementation of `_.assign` without support for multiple sources
|
||
* or `customizer` functions.
|
||
*
|
||
* @private
|
||
* @param {Object} object The destination object.
|
||
* @param {Object} source The source object.
|
||
* @returns {Object} Returns `object`.
|
||
*/
|
||
function baseAssign(object, source) {
|
||
return object && copyObject(source, keys(source), object);
|
||
}
|
||
|
||
module.exports = baseAssign;
|
||
|
||
|
||
/***/ }),
|
||
/* 236 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* The base implementation of `_.times` without support for iteratee shorthands
|
||
* or max array length checks.
|
||
*
|
||
* @private
|
||
* @param {number} n The number of times to invoke `iteratee`.
|
||
* @param {Function} iteratee The function invoked per iteration.
|
||
* @returns {Array} Returns the array of results.
|
||
*/
|
||
function baseTimes(n, iteratee) {
|
||
var index = -1,
|
||
result = Array(n);
|
||
|
||
while (++index < n) {
|
||
result[index] = iteratee(index);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
module.exports = baseTimes;
|
||
|
||
|
||
/***/ }),
|
||
/* 237 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var baseGetTag = __webpack_require__(18),
|
||
isObjectLike = __webpack_require__(11);
|
||
|
||
/** `Object#toString` result references. */
|
||
var argsTag = '[object Arguments]';
|
||
|
||
/**
|
||
* The base implementation of `_.isArguments`.
|
||
*
|
||
* @private
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
||
*/
|
||
function baseIsArguments(value) {
|
||
return isObjectLike(value) && baseGetTag(value) == argsTag;
|
||
}
|
||
|
||
module.exports = baseIsArguments;
|
||
|
||
|
||
/***/ }),
|
||
/* 238 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* This method returns `false`.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 4.13.0
|
||
* @category Util
|
||
* @returns {boolean} Returns `false`.
|
||
* @example
|
||
*
|
||
* _.times(2, _.stubFalse);
|
||
* // => [false, false]
|
||
*/
|
||
function stubFalse() {
|
||
return false;
|
||
}
|
||
|
||
module.exports = stubFalse;
|
||
|
||
|
||
/***/ }),
|
||
/* 239 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var baseGetTag = __webpack_require__(18),
|
||
isLength = __webpack_require__(77),
|
||
isObjectLike = __webpack_require__(11);
|
||
|
||
/** `Object#toString` result references. */
|
||
var argsTag = '[object Arguments]',
|
||
arrayTag = '[object Array]',
|
||
boolTag = '[object Boolean]',
|
||
dateTag = '[object Date]',
|
||
errorTag = '[object Error]',
|
||
funcTag = '[object Function]',
|
||
mapTag = '[object Map]',
|
||
numberTag = '[object Number]',
|
||
objectTag = '[object Object]',
|
||
regexpTag = '[object RegExp]',
|
||
setTag = '[object Set]',
|
||
stringTag = '[object String]',
|
||
weakMapTag = '[object WeakMap]';
|
||
|
||
var arrayBufferTag = '[object ArrayBuffer]',
|
||
dataViewTag = '[object DataView]',
|
||
float32Tag = '[object Float32Array]',
|
||
float64Tag = '[object Float64Array]',
|
||
int8Tag = '[object Int8Array]',
|
||
int16Tag = '[object Int16Array]',
|
||
int32Tag = '[object Int32Array]',
|
||
uint8Tag = '[object Uint8Array]',
|
||
uint8ClampedTag = '[object Uint8ClampedArray]',
|
||
uint16Tag = '[object Uint16Array]',
|
||
uint32Tag = '[object Uint32Array]';
|
||
|
||
/** Used to identify `toStringTag` values of typed arrays. */
|
||
var typedArrayTags = {};
|
||
typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
|
||
typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
|
||
typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
|
||
typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
|
||
typedArrayTags[uint32Tag] = true;
|
||
typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
|
||
typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
|
||
typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
|
||
typedArrayTags[errorTag] = typedArrayTags[funcTag] =
|
||
typedArrayTags[mapTag] = typedArrayTags[numberTag] =
|
||
typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
|
||
typedArrayTags[setTag] = typedArrayTags[stringTag] =
|
||
typedArrayTags[weakMapTag] = false;
|
||
|
||
/**
|
||
* The base implementation of `_.isTypedArray` without Node.js optimizations.
|
||
*
|
||
* @private
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
|
||
*/
|
||
function baseIsTypedArray(value) {
|
||
return isObjectLike(value) &&
|
||
isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
|
||
}
|
||
|
||
module.exports = baseIsTypedArray;
|
||
|
||
|
||
/***/ }),
|
||
/* 240 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var overArg = __webpack_require__(126);
|
||
|
||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||
var nativeKeys = overArg(Object.keys, Object);
|
||
|
||
module.exports = nativeKeys;
|
||
|
||
|
||
/***/ }),
|
||
/* 241 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var copyObject = __webpack_require__(46),
|
||
keysIn = __webpack_require__(127);
|
||
|
||
/**
|
||
* The base implementation of `_.assignIn` without support for multiple sources
|
||
* or `customizer` functions.
|
||
*
|
||
* @private
|
||
* @param {Object} object The destination object.
|
||
* @param {Object} source The source object.
|
||
* @returns {Object} Returns `object`.
|
||
*/
|
||
function baseAssignIn(object, source) {
|
||
return object && copyObject(source, keysIn(source), object);
|
||
}
|
||
|
||
module.exports = baseAssignIn;
|
||
|
||
|
||
/***/ }),
|
||
/* 242 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var isObject = __webpack_require__(21),
|
||
isPrototype = __webpack_require__(51),
|
||
nativeKeysIn = __webpack_require__(243);
|
||
|
||
/** Used for built-in method references. */
|
||
var objectProto = Object.prototype;
|
||
|
||
/** Used to check objects for own properties. */
|
||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||
|
||
/**
|
||
* The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
|
||
*
|
||
* @private
|
||
* @param {Object} object The object to query.
|
||
* @returns {Array} Returns the array of property names.
|
||
*/
|
||
function baseKeysIn(object) {
|
||
if (!isObject(object)) {
|
||
return nativeKeysIn(object);
|
||
}
|
||
var isProto = isPrototype(object),
|
||
result = [];
|
||
|
||
for (var key in object) {
|
||
if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
|
||
result.push(key);
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
|
||
module.exports = baseKeysIn;
|
||
|
||
|
||
/***/ }),
|
||
/* 243 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* This function is like
|
||
* [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
|
||
* except that it includes inherited enumerable properties.
|
||
*
|
||
* @private
|
||
* @param {Object} object The object to query.
|
||
* @returns {Array} Returns the array of property names.
|
||
*/
|
||
function nativeKeysIn(object) {
|
||
var result = [];
|
||
if (object != null) {
|
||
for (var key in Object(object)) {
|
||
result.push(key);
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
|
||
module.exports = nativeKeysIn;
|
||
|
||
|
||
/***/ }),
|
||
/* 244 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
/* WEBPACK VAR INJECTION */(function(module) {var root = __webpack_require__(8);
|
||
|
||
/** Detect free variable `exports`. */
|
||
var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
|
||
|
||
/** Detect free variable `module`. */
|
||
var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
|
||
|
||
/** Detect the popular CommonJS extension `module.exports`. */
|
||
var moduleExports = freeModule && freeModule.exports === freeExports;
|
||
|
||
/** Built-in value references. */
|
||
var Buffer = moduleExports ? root.Buffer : undefined,
|
||
allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined;
|
||
|
||
/**
|
||
* Creates a clone of `buffer`.
|
||
*
|
||
* @private
|
||
* @param {Buffer} buffer The buffer to clone.
|
||
* @param {boolean} [isDeep] Specify a deep clone.
|
||
* @returns {Buffer} Returns the cloned buffer.
|
||
*/
|
||
function cloneBuffer(buffer, isDeep) {
|
||
if (isDeep) {
|
||
return buffer.slice();
|
||
}
|
||
var length = buffer.length,
|
||
result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
|
||
|
||
buffer.copy(result);
|
||
return result;
|
||
}
|
||
|
||
module.exports = cloneBuffer;
|
||
|
||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(22)(module)))
|
||
|
||
/***/ }),
|
||
/* 245 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* Copies the values of `source` to `array`.
|
||
*
|
||
* @private
|
||
* @param {Array} source The array to copy values from.
|
||
* @param {Array} [array=[]] The array to copy values to.
|
||
* @returns {Array} Returns `array`.
|
||
*/
|
||
function copyArray(source, array) {
|
||
var index = -1,
|
||
length = source.length;
|
||
|
||
array || (array = Array(length));
|
||
while (++index < length) {
|
||
array[index] = source[index];
|
||
}
|
||
return array;
|
||
}
|
||
|
||
module.exports = copyArray;
|
||
|
||
|
||
/***/ }),
|
||
/* 246 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var copyObject = __webpack_require__(46),
|
||
getSymbols = __webpack_require__(78);
|
||
|
||
/**
|
||
* Copies own symbols of `source` to `object`.
|
||
*
|
||
* @private
|
||
* @param {Object} source The object to copy symbols from.
|
||
* @param {Object} [object={}] The object to copy symbols to.
|
||
* @returns {Object} Returns `object`.
|
||
*/
|
||
function copySymbols(source, object) {
|
||
return copyObject(source, getSymbols(source), object);
|
||
}
|
||
|
||
module.exports = copySymbols;
|
||
|
||
|
||
/***/ }),
|
||
/* 247 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* A specialized version of `_.filter` for arrays without support for
|
||
* iteratee shorthands.
|
||
*
|
||
* @private
|
||
* @param {Array} [array] The array to iterate over.
|
||
* @param {Function} predicate The function invoked per iteration.
|
||
* @returns {Array} Returns the new filtered array.
|
||
*/
|
||
function arrayFilter(array, predicate) {
|
||
var index = -1,
|
||
length = array == null ? 0 : array.length,
|
||
resIndex = 0,
|
||
result = [];
|
||
|
||
while (++index < length) {
|
||
var value = array[index];
|
||
if (predicate(value, index, array)) {
|
||
result[resIndex++] = value;
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
|
||
module.exports = arrayFilter;
|
||
|
||
|
||
/***/ }),
|
||
/* 248 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var copyObject = __webpack_require__(46),
|
||
getSymbolsIn = __webpack_require__(129);
|
||
|
||
/**
|
||
* Copies own and inherited symbols of `source` to `object`.
|
||
*
|
||
* @private
|
||
* @param {Object} source The object to copy symbols from.
|
||
* @param {Object} [object={}] The object to copy symbols to.
|
||
* @returns {Object} Returns `object`.
|
||
*/
|
||
function copySymbolsIn(source, object) {
|
||
return copyObject(source, getSymbolsIn(source), object);
|
||
}
|
||
|
||
module.exports = copySymbolsIn;
|
||
|
||
|
||
/***/ }),
|
||
/* 249 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var baseGetAllKeys = __webpack_require__(132),
|
||
getSymbolsIn = __webpack_require__(129),
|
||
keysIn = __webpack_require__(127);
|
||
|
||
/**
|
||
* Creates an array of own and inherited enumerable property names and
|
||
* symbols of `object`.
|
||
*
|
||
* @private
|
||
* @param {Object} object The object to query.
|
||
* @returns {Array} Returns the array of property names and symbols.
|
||
*/
|
||
function getAllKeysIn(object) {
|
||
return baseGetAllKeys(object, keysIn, getSymbolsIn);
|
||
}
|
||
|
||
module.exports = getAllKeysIn;
|
||
|
||
|
||
/***/ }),
|
||
/* 250 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var getNative = __webpack_require__(26),
|
||
root = __webpack_require__(8);
|
||
|
||
/* Built-in method references that are verified to be native. */
|
||
var DataView = getNative(root, 'DataView');
|
||
|
||
module.exports = DataView;
|
||
|
||
|
||
/***/ }),
|
||
/* 251 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var getNative = __webpack_require__(26),
|
||
root = __webpack_require__(8);
|
||
|
||
/* Built-in method references that are verified to be native. */
|
||
var Promise = getNative(root, 'Promise');
|
||
|
||
module.exports = Promise;
|
||
|
||
|
||
/***/ }),
|
||
/* 252 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var getNative = __webpack_require__(26),
|
||
root = __webpack_require__(8);
|
||
|
||
/* Built-in method references that are verified to be native. */
|
||
var WeakMap = getNative(root, 'WeakMap');
|
||
|
||
module.exports = WeakMap;
|
||
|
||
|
||
/***/ }),
|
||
/* 253 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/** Used for built-in method references. */
|
||
var objectProto = Object.prototype;
|
||
|
||
/** Used to check objects for own properties. */
|
||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||
|
||
/**
|
||
* Initializes an array clone.
|
||
*
|
||
* @private
|
||
* @param {Array} array The array to clone.
|
||
* @returns {Array} Returns the initialized clone.
|
||
*/
|
||
function initCloneArray(array) {
|
||
var length = array.length,
|
||
result = new array.constructor(length);
|
||
|
||
// Add properties assigned by `RegExp#exec`.
|
||
if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
|
||
result.index = array.index;
|
||
result.input = array.input;
|
||
}
|
||
return result;
|
||
}
|
||
|
||
module.exports = initCloneArray;
|
||
|
||
|
||
/***/ }),
|
||
/* 254 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var cloneArrayBuffer = __webpack_require__(80),
|
||
cloneDataView = __webpack_require__(255),
|
||
cloneRegExp = __webpack_require__(256),
|
||
cloneSymbol = __webpack_require__(257),
|
||
cloneTypedArray = __webpack_require__(258);
|
||
|
||
/** `Object#toString` result references. */
|
||
var boolTag = '[object Boolean]',
|
||
dateTag = '[object Date]',
|
||
mapTag = '[object Map]',
|
||
numberTag = '[object Number]',
|
||
regexpTag = '[object RegExp]',
|
||
setTag = '[object Set]',
|
||
stringTag = '[object String]',
|
||
symbolTag = '[object Symbol]';
|
||
|
||
var arrayBufferTag = '[object ArrayBuffer]',
|
||
dataViewTag = '[object DataView]',
|
||
float32Tag = '[object Float32Array]',
|
||
float64Tag = '[object Float64Array]',
|
||
int8Tag = '[object Int8Array]',
|
||
int16Tag = '[object Int16Array]',
|
||
int32Tag = '[object Int32Array]',
|
||
uint8Tag = '[object Uint8Array]',
|
||
uint8ClampedTag = '[object Uint8ClampedArray]',
|
||
uint16Tag = '[object Uint16Array]',
|
||
uint32Tag = '[object Uint32Array]';
|
||
|
||
/**
|
||
* Initializes an object clone based on its `toStringTag`.
|
||
*
|
||
* **Note:** This function only supports cloning values with tags of
|
||
* `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
|
||
*
|
||
* @private
|
||
* @param {Object} object The object to clone.
|
||
* @param {string} tag The `toStringTag` of the object to clone.
|
||
* @param {boolean} [isDeep] Specify a deep clone.
|
||
* @returns {Object} Returns the initialized clone.
|
||
*/
|
||
function initCloneByTag(object, tag, isDeep) {
|
||
var Ctor = object.constructor;
|
||
switch (tag) {
|
||
case arrayBufferTag:
|
||
return cloneArrayBuffer(object);
|
||
|
||
case boolTag:
|
||
case dateTag:
|
||
return new Ctor(+object);
|
||
|
||
case dataViewTag:
|
||
return cloneDataView(object, isDeep);
|
||
|
||
case float32Tag: case float64Tag:
|
||
case int8Tag: case int16Tag: case int32Tag:
|
||
case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
|
||
return cloneTypedArray(object, isDeep);
|
||
|
||
case mapTag:
|
||
return new Ctor;
|
||
|
||
case numberTag:
|
||
case stringTag:
|
||
return new Ctor(object);
|
||
|
||
case regexpTag:
|
||
return cloneRegExp(object);
|
||
|
||
case setTag:
|
||
return new Ctor;
|
||
|
||
case symbolTag:
|
||
return cloneSymbol(object);
|
||
}
|
||
}
|
||
|
||
module.exports = initCloneByTag;
|
||
|
||
|
||
/***/ }),
|
||
/* 255 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var cloneArrayBuffer = __webpack_require__(80);
|
||
|
||
/**
|
||
* Creates a clone of `dataView`.
|
||
*
|
||
* @private
|
||
* @param {Object} dataView The data view to clone.
|
||
* @param {boolean} [isDeep] Specify a deep clone.
|
||
* @returns {Object} Returns the cloned data view.
|
||
*/
|
||
function cloneDataView(dataView, isDeep) {
|
||
var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
|
||
return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
|
||
}
|
||
|
||
module.exports = cloneDataView;
|
||
|
||
|
||
/***/ }),
|
||
/* 256 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/** Used to match `RegExp` flags from their coerced string values. */
|
||
var reFlags = /\w*$/;
|
||
|
||
/**
|
||
* Creates a clone of `regexp`.
|
||
*
|
||
* @private
|
||
* @param {Object} regexp The regexp to clone.
|
||
* @returns {Object} Returns the cloned regexp.
|
||
*/
|
||
function cloneRegExp(regexp) {
|
||
var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
|
||
result.lastIndex = regexp.lastIndex;
|
||
return result;
|
||
}
|
||
|
||
module.exports = cloneRegExp;
|
||
|
||
|
||
/***/ }),
|
||
/* 257 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var Symbol = __webpack_require__(19);
|
||
|
||
/** Used to convert symbols to primitives and strings. */
|
||
var symbolProto = Symbol ? Symbol.prototype : undefined,
|
||
symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
|
||
|
||
/**
|
||
* Creates a clone of the `symbol` object.
|
||
*
|
||
* @private
|
||
* @param {Object} symbol The symbol object to clone.
|
||
* @returns {Object} Returns the cloned symbol object.
|
||
*/
|
||
function cloneSymbol(symbol) {
|
||
return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
|
||
}
|
||
|
||
module.exports = cloneSymbol;
|
||
|
||
|
||
/***/ }),
|
||
/* 258 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var cloneArrayBuffer = __webpack_require__(80);
|
||
|
||
/**
|
||
* Creates a clone of `typedArray`.
|
||
*
|
||
* @private
|
||
* @param {Object} typedArray The typed array to clone.
|
||
* @param {boolean} [isDeep] Specify a deep clone.
|
||
* @returns {Object} Returns the cloned typed array.
|
||
*/
|
||
function cloneTypedArray(typedArray, isDeep) {
|
||
var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
|
||
return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
|
||
}
|
||
|
||
module.exports = cloneTypedArray;
|
||
|
||
|
||
/***/ }),
|
||
/* 259 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var baseCreate = __webpack_require__(260),
|
||
getPrototype = __webpack_require__(79),
|
||
isPrototype = __webpack_require__(51);
|
||
|
||
/**
|
||
* Initializes an object clone.
|
||
*
|
||
* @private
|
||
* @param {Object} object The object to clone.
|
||
* @returns {Object} Returns the initialized clone.
|
||
*/
|
||
function initCloneObject(object) {
|
||
return (typeof object.constructor == 'function' && !isPrototype(object))
|
||
? baseCreate(getPrototype(object))
|
||
: {};
|
||
}
|
||
|
||
module.exports = initCloneObject;
|
||
|
||
|
||
/***/ }),
|
||
/* 260 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var isObject = __webpack_require__(21);
|
||
|
||
/** Built-in value references. */
|
||
var objectCreate = Object.create;
|
||
|
||
/**
|
||
* The base implementation of `_.create` without support for assigning
|
||
* properties to the created object.
|
||
*
|
||
* @private
|
||
* @param {Object} proto The object to inherit from.
|
||
* @returns {Object} Returns the new object.
|
||
*/
|
||
var baseCreate = (function() {
|
||
function object() {}
|
||
return function(proto) {
|
||
if (!isObject(proto)) {
|
||
return {};
|
||
}
|
||
if (objectCreate) {
|
||
return objectCreate(proto);
|
||
}
|
||
object.prototype = proto;
|
||
var result = new object;
|
||
object.prototype = undefined;
|
||
return result;
|
||
};
|
||
}());
|
||
|
||
module.exports = baseCreate;
|
||
|
||
|
||
/***/ }),
|
||
/* 261 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var baseIsMap = __webpack_require__(262),
|
||
baseUnary = __webpack_require__(49),
|
||
nodeUtil = __webpack_require__(50);
|
||
|
||
/* Node.js helper references. */
|
||
var nodeIsMap = nodeUtil && nodeUtil.isMap;
|
||
|
||
/**
|
||
* Checks if `value` is classified as a `Map` object.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 4.3.0
|
||
* @category Lang
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is a map, else `false`.
|
||
* @example
|
||
*
|
||
* _.isMap(new Map);
|
||
* // => true
|
||
*
|
||
* _.isMap(new WeakMap);
|
||
* // => false
|
||
*/
|
||
var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
|
||
|
||
module.exports = isMap;
|
||
|
||
|
||
/***/ }),
|
||
/* 262 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var getTag = __webpack_require__(29),
|
||
isObjectLike = __webpack_require__(11);
|
||
|
||
/** `Object#toString` result references. */
|
||
var mapTag = '[object Map]';
|
||
|
||
/**
|
||
* The base implementation of `_.isMap` without Node.js optimizations.
|
||
*
|
||
* @private
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is a map, else `false`.
|
||
*/
|
||
function baseIsMap(value) {
|
||
return isObjectLike(value) && getTag(value) == mapTag;
|
||
}
|
||
|
||
module.exports = baseIsMap;
|
||
|
||
|
||
/***/ }),
|
||
/* 263 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var baseIsSet = __webpack_require__(264),
|
||
baseUnary = __webpack_require__(49),
|
||
nodeUtil = __webpack_require__(50);
|
||
|
||
/* Node.js helper references. */
|
||
var nodeIsSet = nodeUtil && nodeUtil.isSet;
|
||
|
||
/**
|
||
* Checks if `value` is classified as a `Set` object.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 4.3.0
|
||
* @category Lang
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is a set, else `false`.
|
||
* @example
|
||
*
|
||
* _.isSet(new Set);
|
||
* // => true
|
||
*
|
||
* _.isSet(new WeakSet);
|
||
* // => false
|
||
*/
|
||
var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
|
||
|
||
module.exports = isSet;
|
||
|
||
|
||
/***/ }),
|
||
/* 264 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var getTag = __webpack_require__(29),
|
||
isObjectLike = __webpack_require__(11);
|
||
|
||
/** `Object#toString` result references. */
|
||
var setTag = '[object Set]';
|
||
|
||
/**
|
||
* The base implementation of `_.isSet` without Node.js optimizations.
|
||
*
|
||
* @private
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is a set, else `false`.
|
||
*/
|
||
function baseIsSet(value) {
|
||
return isObjectLike(value) && getTag(value) == setTag;
|
||
}
|
||
|
||
module.exports = baseIsSet;
|
||
|
||
|
||
/***/ }),
|
||
/* 265 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
let fastProto = null;
|
||
|
||
// Creates an object with permanently fast properties in V8. See Toon Verwaest's
|
||
// post https://medium.com/@tverwaes/setting-up-prototypes-in-v8-ec9c9491dfe2#5f62
|
||
// for more details. Use %HasFastProperties(object) and the Node.js flag
|
||
// --allow-natives-syntax to check whether an object has fast properties.
|
||
function FastObject(o) {
|
||
// A prototype object will have "fast properties" enabled once it is checked
|
||
// against the inline property cache of a function, e.g. fastProto.property:
|
||
// https://github.com/v8/v8/blob/6.0.122/test/mjsunit/fast-prototype.js#L48-L63
|
||
if (fastProto !== null && typeof fastProto.property) {
|
||
const result = fastProto;
|
||
fastProto = FastObject.prototype = null;
|
||
return result;
|
||
}
|
||
fastProto = FastObject.prototype = o == null ? Object.create(null) : o;
|
||
return new FastObject;
|
||
}
|
||
|
||
// Initialize the inline property cache of FastObject
|
||
FastObject();
|
||
|
||
module.exports = function toFastproperties(o) {
|
||
return FastObject(o);
|
||
};
|
||
|
||
|
||
/***/ }),
|
||
/* 266 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
/*
|
||
Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
|
||
|
||
Redistribution and use in source and binary forms, with or without
|
||
modification, are permitted provided that the following conditions are met:
|
||
|
||
* Redistributions of source code must retain the above copyright
|
||
notice, this list of conditions and the following disclaimer.
|
||
* Redistributions in binary form must reproduce the above copyright
|
||
notice, this list of conditions and the following disclaimer in the
|
||
documentation and/or other materials provided with the distribution.
|
||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||
*/
|
||
|
||
|
||
(function () {
|
||
'use strict';
|
||
|
||
exports.ast = __webpack_require__(267);
|
||
exports.code = __webpack_require__(135);
|
||
exports.keyword = __webpack_require__(268);
|
||
}());
|
||
|
||
|
||
/***/ }),
|
||
/* 267 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/*
|
||
Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
|
||
|
||
Redistribution and use in source and binary forms, with or without
|
||
modification, are permitted provided that the following conditions are met:
|
||
|
||
* Redistributions of source code must retain the above copyright
|
||
notice, this list of conditions and the following disclaimer.
|
||
* Redistributions in binary form must reproduce the above copyright
|
||
notice, this list of conditions and the following disclaimer in the
|
||
documentation and/or other materials provided with the distribution.
|
||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
|
||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||
*/
|
||
|
||
(function () {
|
||
'use strict';
|
||
|
||
function isExpression(node) {
|
||
if (node == null) { return false; }
|
||
switch (node.type) {
|
||
case 'ArrayExpression':
|
||
case 'AssignmentExpression':
|
||
case 'BinaryExpression':
|
||
case 'CallExpression':
|
||
case 'ConditionalExpression':
|
||
case 'FunctionExpression':
|
||
case 'Identifier':
|
||
case 'Literal':
|
||
case 'LogicalExpression':
|
||
case 'MemberExpression':
|
||
case 'NewExpression':
|
||
case 'ObjectExpression':
|
||
case 'SequenceExpression':
|
||
case 'ThisExpression':
|
||
case 'UnaryExpression':
|
||
case 'UpdateExpression':
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
function isIterationStatement(node) {
|
||
if (node == null) { return false; }
|
||
switch (node.type) {
|
||
case 'DoWhileStatement':
|
||
case 'ForInStatement':
|
||
case 'ForStatement':
|
||
case 'WhileStatement':
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
function isStatement(node) {
|
||
if (node == null) { return false; }
|
||
switch (node.type) {
|
||
case 'BlockStatement':
|
||
case 'BreakStatement':
|
||
case 'ContinueStatement':
|
||
case 'DebuggerStatement':
|
||
case 'DoWhileStatement':
|
||
case 'EmptyStatement':
|
||
case 'ExpressionStatement':
|
||
case 'ForInStatement':
|
||
case 'ForStatement':
|
||
case 'IfStatement':
|
||
case 'LabeledStatement':
|
||
case 'ReturnStatement':
|
||
case 'SwitchStatement':
|
||
case 'ThrowStatement':
|
||
case 'TryStatement':
|
||
case 'VariableDeclaration':
|
||
case 'WhileStatement':
|
||
case 'WithStatement':
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
function isSourceElement(node) {
|
||
return isStatement(node) || node != null && node.type === 'FunctionDeclaration';
|
||
}
|
||
|
||
function trailingStatement(node) {
|
||
switch (node.type) {
|
||
case 'IfStatement':
|
||
if (node.alternate != null) {
|
||
return node.alternate;
|
||
}
|
||
return node.consequent;
|
||
|
||
case 'LabeledStatement':
|
||
case 'ForStatement':
|
||
case 'ForInStatement':
|
||
case 'WhileStatement':
|
||
case 'WithStatement':
|
||
return node.body;
|
||
}
|
||
return null;
|
||
}
|
||
|
||
function isProblematicIfStatement(node) {
|
||
var current;
|
||
|
||
if (node.type !== 'IfStatement') {
|
||
return false;
|
||
}
|
||
if (node.alternate == null) {
|
||
return false;
|
||
}
|
||
current = node.consequent;
|
||
do {
|
||
if (current.type === 'IfStatement') {
|
||
if (current.alternate == null) {
|
||
return true;
|
||
}
|
||
}
|
||
current = trailingStatement(current);
|
||
} while (current);
|
||
|
||
return false;
|
||
}
|
||
|
||
module.exports = {
|
||
isExpression: isExpression,
|
||
isStatement: isStatement,
|
||
isIterationStatement: isIterationStatement,
|
||
isSourceElement: isSourceElement,
|
||
isProblematicIfStatement: isProblematicIfStatement,
|
||
|
||
trailingStatement: trailingStatement
|
||
};
|
||
}());
|
||
|
||
|
||
/***/ }),
|
||
/* 268 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
/*
|
||
Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
|
||
|
||
Redistribution and use in source and binary forms, with or without
|
||
modification, are permitted provided that the following conditions are met:
|
||
|
||
* Redistributions of source code must retain the above copyright
|
||
notice, this list of conditions and the following disclaimer.
|
||
* Redistributions in binary form must reproduce the above copyright
|
||
notice, this list of conditions and the following disclaimer in the
|
||
documentation and/or other materials provided with the distribution.
|
||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||
*/
|
||
|
||
(function () {
|
||
'use strict';
|
||
|
||
var code = __webpack_require__(135);
|
||
|
||
function isStrictModeReservedWordES6(id) {
|
||
switch (id) {
|
||
case 'implements':
|
||
case 'interface':
|
||
case 'package':
|
||
case 'private':
|
||
case 'protected':
|
||
case 'public':
|
||
case 'static':
|
||
case 'let':
|
||
return true;
|
||
default:
|
||
return false;
|
||
}
|
||
}
|
||
|
||
function isKeywordES5(id, strict) {
|
||
// yield should not be treated as keyword under non-strict mode.
|
||
if (!strict && id === 'yield') {
|
||
return false;
|
||
}
|
||
return isKeywordES6(id, strict);
|
||
}
|
||
|
||
function isKeywordES6(id, strict) {
|
||
if (strict && isStrictModeReservedWordES6(id)) {
|
||
return true;
|
||
}
|
||
|
||
switch (id.length) {
|
||
case 2:
|
||
return (id === 'if') || (id === 'in') || (id === 'do');
|
||
case 3:
|
||
return (id === 'var') || (id === 'for') || (id === 'new') || (id === 'try');
|
||
case 4:
|
||
return (id === 'this') || (id === 'else') || (id === 'case') ||
|
||
(id === 'void') || (id === 'with') || (id === 'enum');
|
||
case 5:
|
||
return (id === 'while') || (id === 'break') || (id === 'catch') ||
|
||
(id === 'throw') || (id === 'const') || (id === 'yield') ||
|
||
(id === 'class') || (id === 'super');
|
||
case 6:
|
||
return (id === 'return') || (id === 'typeof') || (id === 'delete') ||
|
||
(id === 'switch') || (id === 'export') || (id === 'import');
|
||
case 7:
|
||
return (id === 'default') || (id === 'finally') || (id === 'extends');
|
||
case 8:
|
||
return (id === 'function') || (id === 'continue') || (id === 'debugger');
|
||
case 10:
|
||
return (id === 'instanceof');
|
||
default:
|
||
return false;
|
||
}
|
||
}
|
||
|
||
function isReservedWordES5(id, strict) {
|
||
return id === 'null' || id === 'true' || id === 'false' || isKeywordES5(id, strict);
|
||
}
|
||
|
||
function isReservedWordES6(id, strict) {
|
||
return id === 'null' || id === 'true' || id === 'false' || isKeywordES6(id, strict);
|
||
}
|
||
|
||
function isRestrictedWord(id) {
|
||
return id === 'eval' || id === 'arguments';
|
||
}
|
||
|
||
function isIdentifierNameES5(id) {
|
||
var i, iz, ch;
|
||
|
||
if (id.length === 0) { return false; }
|
||
|
||
ch = id.charCodeAt(0);
|
||
if (!code.isIdentifierStartES5(ch)) {
|
||
return false;
|
||
}
|
||
|
||
for (i = 1, iz = id.length; i < iz; ++i) {
|
||
ch = id.charCodeAt(i);
|
||
if (!code.isIdentifierPartES5(ch)) {
|
||
return false;
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
|
||
function decodeUtf16(lead, trail) {
|
||
return (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
|
||
}
|
||
|
||
function isIdentifierNameES6(id) {
|
||
var i, iz, ch, lowCh, check;
|
||
|
||
if (id.length === 0) { return false; }
|
||
|
||
check = code.isIdentifierStartES6;
|
||
for (i = 0, iz = id.length; i < iz; ++i) {
|
||
ch = id.charCodeAt(i);
|
||
if (0xD800 <= ch && ch <= 0xDBFF) {
|
||
++i;
|
||
if (i >= iz) { return false; }
|
||
lowCh = id.charCodeAt(i);
|
||
if (!(0xDC00 <= lowCh && lowCh <= 0xDFFF)) {
|
||
return false;
|
||
}
|
||
ch = decodeUtf16(ch, lowCh);
|
||
}
|
||
if (!check(ch)) {
|
||
return false;
|
||
}
|
||
check = code.isIdentifierPartES6;
|
||
}
|
||
return true;
|
||
}
|
||
|
||
function isIdentifierES5(id, strict) {
|
||
return isIdentifierNameES5(id) && !isReservedWordES5(id, strict);
|
||
}
|
||
|
||
function isIdentifierES6(id, strict) {
|
||
return isIdentifierNameES6(id) && !isReservedWordES6(id, strict);
|
||
}
|
||
|
||
module.exports = {
|
||
isKeywordES5: isKeywordES5,
|
||
isKeywordES6: isKeywordES6,
|
||
isReservedWordES5: isReservedWordES5,
|
||
isReservedWordES6: isReservedWordES6,
|
||
isRestrictedWord: isRestrictedWord,
|
||
isIdentifierNameES5: isIdentifierNameES5,
|
||
isIdentifierNameES6: isIdentifierNameES6,
|
||
isIdentifierES5: isIdentifierES5,
|
||
isIdentifierES6: isIdentifierES6
|
||
};
|
||
}());
|
||
|
||
|
||
/***/ }),
|
||
/* 269 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
var _utils = _interopRequireWildcard(__webpack_require__(23));
|
||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||
|
||
const defineInterfaceishType = (name, typeParameterType = "TypeParameterDeclaration") => {
|
||
(0, _utils.default)(name, {
|
||
builder: ["id", "typeParameters", "extends", "body"],
|
||
visitor: ["id", "typeParameters", "extends", "mixins", "implements", "body"],
|
||
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"],
|
||
fields: {
|
||
id: (0, _utils.validateType)("Identifier"),
|
||
typeParameters: (0, _utils.validateOptionalType)(typeParameterType),
|
||
extends: (0, _utils.validateOptional)((0, _utils.arrayOfType)("InterfaceExtends")),
|
||
mixins: (0, _utils.validateOptional)((0, _utils.arrayOfType)("InterfaceExtends")),
|
||
implements: (0, _utils.validateOptional)((0, _utils.arrayOfType)("ClassImplements")),
|
||
body: (0, _utils.validateType)("ObjectTypeAnnotation")
|
||
}
|
||
});
|
||
};
|
||
|
||
(0, _utils.default)("AnyTypeAnnotation", {
|
||
aliases: ["Flow", "FlowType", "FlowBaseAnnotation"]
|
||
});
|
||
(0, _utils.default)("ArrayTypeAnnotation", {
|
||
visitor: ["elementType"],
|
||
aliases: ["Flow", "FlowType"],
|
||
fields: {
|
||
elementType: (0, _utils.validateType)("FlowType")
|
||
}
|
||
});
|
||
(0, _utils.default)("BooleanTypeAnnotation", {
|
||
aliases: ["Flow", "FlowType", "FlowBaseAnnotation"]
|
||
});
|
||
(0, _utils.default)("BooleanLiteralTypeAnnotation", {
|
||
builder: ["value"],
|
||
aliases: ["Flow", "FlowType"],
|
||
fields: {
|
||
value: (0, _utils.validate)((0, _utils.assertValueType)("boolean"))
|
||
}
|
||
});
|
||
(0, _utils.default)("NullLiteralTypeAnnotation", {
|
||
aliases: ["Flow", "FlowType", "FlowBaseAnnotation"]
|
||
});
|
||
(0, _utils.default)("ClassImplements", {
|
||
visitor: ["id", "typeParameters"],
|
||
aliases: ["Flow"],
|
||
fields: {
|
||
id: (0, _utils.validateType)("Identifier"),
|
||
typeParameters: (0, _utils.validateOptionalType)("TypeParameterInstantiation")
|
||
}
|
||
});
|
||
defineInterfaceishType("DeclareClass");
|
||
(0, _utils.default)("DeclareFunction", {
|
||
visitor: ["id"],
|
||
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"],
|
||
fields: {
|
||
id: (0, _utils.validateType)("Identifier"),
|
||
predicate: (0, _utils.validateOptionalType)("DeclaredPredicate")
|
||
}
|
||
});
|
||
defineInterfaceishType("DeclareInterface");
|
||
(0, _utils.default)("DeclareModule", {
|
||
builder: ["id", "body", "kind"],
|
||
visitor: ["id", "body"],
|
||
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"],
|
||
fields: {
|
||
id: (0, _utils.validateType)(["Identifier", "StringLiteral"]),
|
||
body: (0, _utils.validateType)("BlockStatement"),
|
||
kind: (0, _utils.validateOptional)((0, _utils.assertOneOf)("CommonJS", "ES"))
|
||
}
|
||
});
|
||
(0, _utils.default)("DeclareModuleExports", {
|
||
visitor: ["typeAnnotation"],
|
||
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"],
|
||
fields: {
|
||
typeAnnotation: (0, _utils.validateType)("TypeAnnotation")
|
||
}
|
||
});
|
||
(0, _utils.default)("DeclareTypeAlias", {
|
||
visitor: ["id", "typeParameters", "right"],
|
||
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"],
|
||
fields: {
|
||
id: (0, _utils.validateType)("Identifier"),
|
||
typeParameters: (0, _utils.validateOptionalType)("TypeParameterDeclaration"),
|
||
right: (0, _utils.validateType)("FlowType")
|
||
}
|
||
});
|
||
(0, _utils.default)("DeclareOpaqueType", {
|
||
visitor: ["id", "typeParameters", "supertype"],
|
||
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"],
|
||
fields: {
|
||
id: (0, _utils.validateType)("Identifier"),
|
||
typeParameters: (0, _utils.validateOptionalType)("TypeParameterDeclaration"),
|
||
supertype: (0, _utils.validateOptionalType)("FlowType")
|
||
}
|
||
});
|
||
(0, _utils.default)("DeclareVariable", {
|
||
visitor: ["id"],
|
||
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"],
|
||
fields: {
|
||
id: (0, _utils.validateType)("Identifier")
|
||
}
|
||
});
|
||
(0, _utils.default)("DeclareExportDeclaration", {
|
||
visitor: ["declaration", "specifiers", "source"],
|
||
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"],
|
||
fields: {
|
||
declaration: (0, _utils.validateOptionalType)("Flow"),
|
||
specifiers: (0, _utils.validateOptional)((0, _utils.arrayOfType)(["ExportSpecifier", "ExportNamespaceSpecifier"])),
|
||
source: (0, _utils.validateOptionalType)("StringLiteral"),
|
||
default: (0, _utils.validateOptional)((0, _utils.assertValueType)("boolean"))
|
||
}
|
||
});
|
||
(0, _utils.default)("DeclareExportAllDeclaration", {
|
||
visitor: ["source"],
|
||
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"],
|
||
fields: {
|
||
source: (0, _utils.validateType)("StringLiteral"),
|
||
exportKind: (0, _utils.validateOptional)((0, _utils.assertOneOf)("type", "value"))
|
||
}
|
||
});
|
||
(0, _utils.default)("DeclaredPredicate", {
|
||
visitor: ["value"],
|
||
aliases: ["Flow", "FlowPredicate"],
|
||
fields: {
|
||
value: (0, _utils.validateType)("Flow")
|
||
}
|
||
});
|
||
(0, _utils.default)("ExistsTypeAnnotation", {
|
||
aliases: ["Flow", "FlowType"]
|
||
});
|
||
(0, _utils.default)("FunctionTypeAnnotation", {
|
||
visitor: ["typeParameters", "params", "rest", "returnType"],
|
||
aliases: ["Flow", "FlowType"],
|
||
fields: {
|
||
typeParameters: (0, _utils.validateOptionalType)("TypeParameterDeclaration"),
|
||
params: (0, _utils.validate)((0, _utils.arrayOfType)("FunctionTypeParam")),
|
||
rest: (0, _utils.validateOptionalType)("FunctionTypeParam"),
|
||
returnType: (0, _utils.validateType)("FlowType")
|
||
}
|
||
});
|
||
(0, _utils.default)("FunctionTypeParam", {
|
||
visitor: ["name", "typeAnnotation"],
|
||
aliases: ["Flow"],
|
||
fields: {
|
||
name: (0, _utils.validateOptionalType)("Identifier"),
|
||
typeAnnotation: (0, _utils.validateType)("FlowType"),
|
||
optional: (0, _utils.validateOptional)((0, _utils.assertValueType)("boolean"))
|
||
}
|
||
});
|
||
(0, _utils.default)("GenericTypeAnnotation", {
|
||
visitor: ["id", "typeParameters"],
|
||
aliases: ["Flow", "FlowType"],
|
||
fields: {
|
||
id: (0, _utils.validateType)(["Identifier", "QualifiedTypeIdentifier"]),
|
||
typeParameters: (0, _utils.validateOptionalType)("TypeParameterInstantiation")
|
||
}
|
||
});
|
||
(0, _utils.default)("InferredPredicate", {
|
||
aliases: ["Flow", "FlowPredicate"]
|
||
});
|
||
(0, _utils.default)("InterfaceExtends", {
|
||
visitor: ["id", "typeParameters"],
|
||
aliases: ["Flow"],
|
||
fields: {
|
||
id: (0, _utils.validateType)(["Identifier", "QualifiedTypeIdentifier"]),
|
||
typeParameters: (0, _utils.validateOptionalType)("TypeParameterInstantiation")
|
||
}
|
||
});
|
||
defineInterfaceishType("InterfaceDeclaration");
|
||
(0, _utils.default)("InterfaceTypeAnnotation", {
|
||
visitor: ["extends", "body"],
|
||
aliases: ["Flow", "FlowType"],
|
||
fields: {
|
||
extends: (0, _utils.validateOptional)((0, _utils.arrayOfType)("InterfaceExtends")),
|
||
body: (0, _utils.validateType)("ObjectTypeAnnotation")
|
||
}
|
||
});
|
||
(0, _utils.default)("IntersectionTypeAnnotation", {
|
||
visitor: ["types"],
|
||
aliases: ["Flow", "FlowType"],
|
||
fields: {
|
||
types: (0, _utils.validate)((0, _utils.arrayOfType)("FlowType"))
|
||
}
|
||
});
|
||
(0, _utils.default)("MixedTypeAnnotation", {
|
||
aliases: ["Flow", "FlowType", "FlowBaseAnnotation"]
|
||
});
|
||
(0, _utils.default)("EmptyTypeAnnotation", {
|
||
aliases: ["Flow", "FlowType", "FlowBaseAnnotation"]
|
||
});
|
||
(0, _utils.default)("NullableTypeAnnotation", {
|
||
visitor: ["typeAnnotation"],
|
||
aliases: ["Flow", "FlowType"],
|
||
fields: {
|
||
typeAnnotation: (0, _utils.validateType)("FlowType")
|
||
}
|
||
});
|
||
(0, _utils.default)("NumberLiteralTypeAnnotation", {
|
||
builder: ["value"],
|
||
aliases: ["Flow", "FlowType"],
|
||
fields: {
|
||
value: (0, _utils.validate)((0, _utils.assertValueType)("number"))
|
||
}
|
||
});
|
||
(0, _utils.default)("NumberTypeAnnotation", {
|
||
aliases: ["Flow", "FlowType", "FlowBaseAnnotation"]
|
||
});
|
||
(0, _utils.default)("ObjectTypeAnnotation", {
|
||
visitor: ["properties", "indexers", "callProperties", "internalSlots"],
|
||
aliases: ["Flow", "FlowType"],
|
||
builder: ["properties", "indexers", "callProperties", "internalSlots", "exact"],
|
||
fields: {
|
||
properties: (0, _utils.validate)((0, _utils.arrayOfType)(["ObjectTypeProperty", "ObjectTypeSpreadProperty"])),
|
||
indexers: (0, _utils.validateOptional)((0, _utils.arrayOfType)("ObjectTypeIndexer")),
|
||
callProperties: (0, _utils.validateOptional)((0, _utils.arrayOfType)("ObjectTypeCallProperty")),
|
||
internalSlots: (0, _utils.validateOptional)((0, _utils.arrayOfType)("ObjectTypeInternalSlot")),
|
||
exact: {
|
||
validate: (0, _utils.assertValueType)("boolean"),
|
||
default: false
|
||
},
|
||
inexact: (0, _utils.validateOptional)((0, _utils.assertValueType)("boolean"))
|
||
}
|
||
});
|
||
(0, _utils.default)("ObjectTypeInternalSlot", {
|
||
visitor: ["id", "value", "optional", "static", "method"],
|
||
aliases: ["Flow", "UserWhitespacable"],
|
||
fields: {
|
||
id: (0, _utils.validateType)("Identifier"),
|
||
value: (0, _utils.validateType)("FlowType"),
|
||
optional: (0, _utils.validate)((0, _utils.assertValueType)("boolean")),
|
||
static: (0, _utils.validate)((0, _utils.assertValueType)("boolean")),
|
||
method: (0, _utils.validate)((0, _utils.assertValueType)("boolean"))
|
||
}
|
||
});
|
||
(0, _utils.default)("ObjectTypeCallProperty", {
|
||
visitor: ["value"],
|
||
aliases: ["Flow", "UserWhitespacable"],
|
||
fields: {
|
||
value: (0, _utils.validateType)("FlowType"),
|
||
static: (0, _utils.validate)((0, _utils.assertValueType)("boolean"))
|
||
}
|
||
});
|
||
(0, _utils.default)("ObjectTypeIndexer", {
|
||
visitor: ["id", "key", "value", "variance"],
|
||
aliases: ["Flow", "UserWhitespacable"],
|
||
fields: {
|
||
id: (0, _utils.validateOptionalType)("Identifier"),
|
||
key: (0, _utils.validateType)("FlowType"),
|
||
value: (0, _utils.validateType)("FlowType"),
|
||
static: (0, _utils.validate)((0, _utils.assertValueType)("boolean")),
|
||
variance: (0, _utils.validateOptionalType)("Variance")
|
||
}
|
||
});
|
||
(0, _utils.default)("ObjectTypeProperty", {
|
||
visitor: ["key", "value", "variance"],
|
||
aliases: ["Flow", "UserWhitespacable"],
|
||
fields: {
|
||
key: (0, _utils.validateType)(["Identifier", "StringLiteral"]),
|
||
value: (0, _utils.validateType)("FlowType"),
|
||
kind: (0, _utils.validate)((0, _utils.assertOneOf)("init", "get", "set")),
|
||
static: (0, _utils.validate)((0, _utils.assertValueType)("boolean")),
|
||
proto: (0, _utils.validate)((0, _utils.assertValueType)("boolean")),
|
||
optional: (0, _utils.validate)((0, _utils.assertValueType)("boolean")),
|
||
variance: (0, _utils.validateOptionalType)("Variance")
|
||
}
|
||
});
|
||
(0, _utils.default)("ObjectTypeSpreadProperty", {
|
||
visitor: ["argument"],
|
||
aliases: ["Flow", "UserWhitespacable"],
|
||
fields: {
|
||
argument: (0, _utils.validateType)("FlowType")
|
||
}
|
||
});
|
||
(0, _utils.default)("OpaqueType", {
|
||
visitor: ["id", "typeParameters", "supertype", "impltype"],
|
||
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"],
|
||
fields: {
|
||
id: (0, _utils.validateType)("Identifier"),
|
||
typeParameters: (0, _utils.validateOptionalType)("TypeParameterDeclaration"),
|
||
supertype: (0, _utils.validateOptionalType)("FlowType"),
|
||
impltype: (0, _utils.validateType)("FlowType")
|
||
}
|
||
});
|
||
(0, _utils.default)("QualifiedTypeIdentifier", {
|
||
visitor: ["id", "qualification"],
|
||
aliases: ["Flow"],
|
||
fields: {
|
||
id: (0, _utils.validateType)("Identifier"),
|
||
qualification: (0, _utils.validateType)(["Identifier", "QualifiedTypeIdentifier"])
|
||
}
|
||
});
|
||
(0, _utils.default)("StringLiteralTypeAnnotation", {
|
||
builder: ["value"],
|
||
aliases: ["Flow", "FlowType"],
|
||
fields: {
|
||
value: (0, _utils.validate)((0, _utils.assertValueType)("string"))
|
||
}
|
||
});
|
||
(0, _utils.default)("StringTypeAnnotation", {
|
||
aliases: ["Flow", "FlowType", "FlowBaseAnnotation"]
|
||
});
|
||
(0, _utils.default)("ThisTypeAnnotation", {
|
||
aliases: ["Flow", "FlowType", "FlowBaseAnnotation"]
|
||
});
|
||
(0, _utils.default)("TupleTypeAnnotation", {
|
||
visitor: ["types"],
|
||
aliases: ["Flow", "FlowType"],
|
||
fields: {
|
||
types: (0, _utils.validate)((0, _utils.arrayOfType)("FlowType"))
|
||
}
|
||
});
|
||
(0, _utils.default)("TypeofTypeAnnotation", {
|
||
visitor: ["argument"],
|
||
aliases: ["Flow", "FlowType"],
|
||
fields: {
|
||
argument: (0, _utils.validateType)("FlowType")
|
||
}
|
||
});
|
||
(0, _utils.default)("TypeAlias", {
|
||
visitor: ["id", "typeParameters", "right"],
|
||
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"],
|
||
fields: {
|
||
id: (0, _utils.validateType)("Identifier"),
|
||
typeParameters: (0, _utils.validateOptionalType)("TypeParameterDeclaration"),
|
||
right: (0, _utils.validateType)("FlowType")
|
||
}
|
||
});
|
||
(0, _utils.default)("TypeAnnotation", {
|
||
aliases: ["Flow"],
|
||
visitor: ["typeAnnotation"],
|
||
fields: {
|
||
typeAnnotation: (0, _utils.validateType)("FlowType")
|
||
}
|
||
});
|
||
(0, _utils.default)("TypeCastExpression", {
|
||
visitor: ["expression", "typeAnnotation"],
|
||
aliases: ["Flow", "ExpressionWrapper", "Expression"],
|
||
fields: {
|
||
expression: (0, _utils.validateType)("Expression"),
|
||
typeAnnotation: (0, _utils.validateType)("TypeAnnotation")
|
||
}
|
||
});
|
||
(0, _utils.default)("TypeParameter", {
|
||
aliases: ["Flow"],
|
||
visitor: ["bound", "default", "variance"],
|
||
fields: {
|
||
name: (0, _utils.validate)((0, _utils.assertValueType)("string")),
|
||
bound: (0, _utils.validateOptionalType)("TypeAnnotation"),
|
||
default: (0, _utils.validateOptionalType)("FlowType"),
|
||
variance: (0, _utils.validateOptionalType)("Variance")
|
||
}
|
||
});
|
||
(0, _utils.default)("TypeParameterDeclaration", {
|
||
aliases: ["Flow"],
|
||
visitor: ["params"],
|
||
fields: {
|
||
params: (0, _utils.validate)((0, _utils.arrayOfType)("TypeParameter"))
|
||
}
|
||
});
|
||
(0, _utils.default)("TypeParameterInstantiation", {
|
||
aliases: ["Flow"],
|
||
visitor: ["params"],
|
||
fields: {
|
||
params: (0, _utils.validate)((0, _utils.arrayOfType)("FlowType"))
|
||
}
|
||
});
|
||
(0, _utils.default)("UnionTypeAnnotation", {
|
||
visitor: ["types"],
|
||
aliases: ["Flow", "FlowType"],
|
||
fields: {
|
||
types: (0, _utils.validate)((0, _utils.arrayOfType)("FlowType"))
|
||
}
|
||
});
|
||
(0, _utils.default)("Variance", {
|
||
aliases: ["Flow"],
|
||
builder: ["kind"],
|
||
fields: {
|
||
kind: (0, _utils.validate)((0, _utils.assertOneOf)("minus", "plus"))
|
||
}
|
||
});
|
||
(0, _utils.default)("VoidTypeAnnotation", {
|
||
aliases: ["Flow", "FlowType", "FlowBaseAnnotation"]
|
||
});
|
||
|
||
/***/ }),
|
||
/* 270 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
var _utils = _interopRequireWildcard(__webpack_require__(23));
|
||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||
|
||
(0, _utils.default)("JSXAttribute", {
|
||
visitor: ["name", "value"],
|
||
aliases: ["JSX", "Immutable"],
|
||
fields: {
|
||
name: {
|
||
validate: (0, _utils.assertNodeType)("JSXIdentifier", "JSXNamespacedName")
|
||
},
|
||
value: {
|
||
optional: true,
|
||
validate: (0, _utils.assertNodeType)("JSXElement", "JSXFragment", "StringLiteral", "JSXExpressionContainer")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("JSXClosingElement", {
|
||
visitor: ["name"],
|
||
aliases: ["JSX", "Immutable"],
|
||
fields: {
|
||
name: {
|
||
validate: (0, _utils.assertNodeType)("JSXIdentifier", "JSXMemberExpression")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("JSXElement", {
|
||
builder: ["openingElement", "closingElement", "children", "selfClosing"],
|
||
visitor: ["openingElement", "children", "closingElement"],
|
||
aliases: ["JSX", "Immutable", "Expression"],
|
||
fields: {
|
||
openingElement: {
|
||
validate: (0, _utils.assertNodeType)("JSXOpeningElement")
|
||
},
|
||
closingElement: {
|
||
optional: true,
|
||
validate: (0, _utils.assertNodeType)("JSXClosingElement")
|
||
},
|
||
children: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("JSXText", "JSXExpressionContainer", "JSXSpreadChild", "JSXElement", "JSXFragment")))
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("JSXEmptyExpression", {
|
||
aliases: ["JSX"]
|
||
});
|
||
(0, _utils.default)("JSXExpressionContainer", {
|
||
visitor: ["expression"],
|
||
aliases: ["JSX", "Immutable"],
|
||
fields: {
|
||
expression: {
|
||
validate: (0, _utils.assertNodeType)("Expression", "JSXEmptyExpression")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("JSXSpreadChild", {
|
||
visitor: ["expression"],
|
||
aliases: ["JSX", "Immutable"],
|
||
fields: {
|
||
expression: {
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("JSXIdentifier", {
|
||
builder: ["name"],
|
||
aliases: ["JSX"],
|
||
fields: {
|
||
name: {
|
||
validate: (0, _utils.assertValueType)("string")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("JSXMemberExpression", {
|
||
visitor: ["object", "property"],
|
||
aliases: ["JSX"],
|
||
fields: {
|
||
object: {
|
||
validate: (0, _utils.assertNodeType)("JSXMemberExpression", "JSXIdentifier")
|
||
},
|
||
property: {
|
||
validate: (0, _utils.assertNodeType)("JSXIdentifier")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("JSXNamespacedName", {
|
||
visitor: ["namespace", "name"],
|
||
aliases: ["JSX"],
|
||
fields: {
|
||
namespace: {
|
||
validate: (0, _utils.assertNodeType)("JSXIdentifier")
|
||
},
|
||
name: {
|
||
validate: (0, _utils.assertNodeType)("JSXIdentifier")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("JSXOpeningElement", {
|
||
builder: ["name", "attributes", "selfClosing"],
|
||
visitor: ["name", "attributes"],
|
||
aliases: ["JSX", "Immutable"],
|
||
fields: {
|
||
name: {
|
||
validate: (0, _utils.assertNodeType)("JSXIdentifier", "JSXMemberExpression")
|
||
},
|
||
selfClosing: {
|
||
default: false,
|
||
validate: (0, _utils.assertValueType)("boolean")
|
||
},
|
||
attributes: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("JSXAttribute", "JSXSpreadAttribute")))
|
||
},
|
||
typeParameters: {
|
||
validate: (0, _utils.assertNodeType)("TypeParameterInstantiation", "TSTypeParameterInstantiation"),
|
||
optional: true
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("JSXSpreadAttribute", {
|
||
visitor: ["argument"],
|
||
aliases: ["JSX"],
|
||
fields: {
|
||
argument: {
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("JSXText", {
|
||
aliases: ["JSX", "Immutable"],
|
||
builder: ["value"],
|
||
fields: {
|
||
value: {
|
||
validate: (0, _utils.assertValueType)("string")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("JSXFragment", {
|
||
builder: ["openingFragment", "closingFragment", "children"],
|
||
visitor: ["openingFragment", "children", "closingFragment"],
|
||
aliases: ["JSX", "Immutable", "Expression"],
|
||
fields: {
|
||
openingFragment: {
|
||
validate: (0, _utils.assertNodeType)("JSXOpeningFragment")
|
||
},
|
||
closingFragment: {
|
||
validate: (0, _utils.assertNodeType)("JSXClosingFragment")
|
||
},
|
||
children: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("JSXText", "JSXExpressionContainer", "JSXSpreadChild", "JSXElement", "JSXFragment")))
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("JSXOpeningFragment", {
|
||
aliases: ["JSX", "Immutable"]
|
||
});
|
||
(0, _utils.default)("JSXClosingFragment", {
|
||
aliases: ["JSX", "Immutable"]
|
||
});
|
||
|
||
/***/ }),
|
||
/* 271 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
var _utils = _interopRequireWildcard(__webpack_require__(23));
|
||
|
||
var _placeholders = __webpack_require__(518);
|
||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||
|
||
(0, _utils.default)("Noop", {
|
||
visitor: []
|
||
});
|
||
(0, _utils.default)("Placeholder", {
|
||
visitor: [],
|
||
builder: ["expectedNode", "name"],
|
||
fields: {
|
||
name: {
|
||
validate: (0, _utils.assertNodeType)("Identifier")
|
||
},
|
||
expectedNode: {
|
||
validate: (0, _utils.assertOneOf)(..._placeholders.PLACEHOLDERS)
|
||
}
|
||
}
|
||
});
|
||
|
||
/***/ }),
|
||
/* 272 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
var _utils = _interopRequireWildcard(__webpack_require__(23));
|
||
|
||
var _es = __webpack_require__(84);
|
||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||
|
||
(0, _utils.default)("ArgumentPlaceholder", {});
|
||
(0, _utils.default)("AwaitExpression", {
|
||
builder: ["argument"],
|
||
visitor: ["argument"],
|
||
aliases: ["Expression", "Terminatorless"],
|
||
fields: {
|
||
argument: {
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("BindExpression", {
|
||
visitor: ["object", "callee"],
|
||
aliases: ["Expression"],
|
||
fields: {}
|
||
});
|
||
(0, _utils.default)("ClassProperty", {
|
||
visitor: ["key", "value", "typeAnnotation", "decorators"],
|
||
builder: ["key", "value", "typeAnnotation", "decorators", "computed"],
|
||
aliases: ["Property"],
|
||
fields: Object.assign({}, _es.classMethodOrPropertyCommon, {
|
||
value: {
|
||
validate: (0, _utils.assertNodeType)("Expression"),
|
||
optional: true
|
||
},
|
||
definite: {
|
||
validate: (0, _utils.assertValueType)("boolean"),
|
||
optional: true
|
||
},
|
||
typeAnnotation: {
|
||
validate: (0, _utils.assertNodeType)("TypeAnnotation", "TSTypeAnnotation", "Noop"),
|
||
optional: true
|
||
},
|
||
decorators: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))),
|
||
optional: true
|
||
},
|
||
readonly: {
|
||
validate: (0, _utils.assertValueType)("boolean"),
|
||
optional: true
|
||
}
|
||
})
|
||
});
|
||
(0, _utils.default)("OptionalMemberExpression", {
|
||
builder: ["object", "property", "computed", "optional"],
|
||
visitor: ["object", "property"],
|
||
aliases: ["Expression"],
|
||
fields: {
|
||
object: {
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
},
|
||
property: {
|
||
validate: function () {
|
||
const normal = (0, _utils.assertNodeType)("Identifier");
|
||
const computed = (0, _utils.assertNodeType)("Expression");
|
||
return function (node, key, val) {
|
||
const validator = node.computed ? computed : normal;
|
||
validator(node, key, val);
|
||
};
|
||
}()
|
||
},
|
||
computed: {
|
||
default: false
|
||
},
|
||
optional: {
|
||
validate: (0, _utils.assertValueType)("boolean")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("PipelineTopicExpression", {
|
||
builder: ["expression"],
|
||
visitor: ["expression"],
|
||
fields: {
|
||
expression: {
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("PipelineBareFunction", {
|
||
builder: ["callee"],
|
||
visitor: ["callee"],
|
||
fields: {
|
||
callee: {
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("PipelinePrimaryTopicReference", {
|
||
aliases: ["Expression"]
|
||
});
|
||
(0, _utils.default)("OptionalCallExpression", {
|
||
visitor: ["callee", "arguments", "typeParameters", "typeArguments"],
|
||
builder: ["callee", "arguments", "optional"],
|
||
aliases: ["Expression"],
|
||
fields: {
|
||
callee: {
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
},
|
||
arguments: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression", "SpreadElement", "JSXNamespacedName")))
|
||
},
|
||
optional: {
|
||
validate: (0, _utils.assertValueType)("boolean")
|
||
},
|
||
typeArguments: {
|
||
validate: (0, _utils.assertNodeType)("TypeParameterInstantiation"),
|
||
optional: true
|
||
},
|
||
typeParameters: {
|
||
validate: (0, _utils.assertNodeType)("TSTypeParameterInstantiation"),
|
||
optional: true
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("ClassPrivateProperty", {
|
||
visitor: ["key", "value"],
|
||
builder: ["key", "value"],
|
||
aliases: ["Property", "Private"],
|
||
fields: {
|
||
key: {
|
||
validate: (0, _utils.assertNodeType)("PrivateName")
|
||
},
|
||
value: {
|
||
validate: (0, _utils.assertNodeType)("Expression"),
|
||
optional: true
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("ClassPrivateMethod", {
|
||
builder: ["kind", "key", "params", "body", "static"],
|
||
visitor: ["key", "params", "body", "decorators", "returnType", "typeParameters"],
|
||
aliases: ["Function", "Scopable", "BlockParent", "FunctionParent", "Method", "Private"],
|
||
fields: Object.assign({}, _es.classMethodOrDeclareMethodCommon, {
|
||
key: {
|
||
validate: (0, _utils.assertNodeType)("PrivateName")
|
||
},
|
||
body: {
|
||
validate: (0, _utils.assertNodeType)("BlockStatement")
|
||
}
|
||
})
|
||
});
|
||
(0, _utils.default)("Import", {
|
||
aliases: ["Expression"]
|
||
});
|
||
(0, _utils.default)("Decorator", {
|
||
visitor: ["expression"],
|
||
fields: {
|
||
expression: {
|
||
validate: (0, _utils.assertNodeType)("Expression")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("DoExpression", {
|
||
visitor: ["body"],
|
||
aliases: ["Expression"],
|
||
fields: {
|
||
body: {
|
||
validate: (0, _utils.assertNodeType)("BlockStatement")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("ExportDefaultSpecifier", {
|
||
visitor: ["exported"],
|
||
aliases: ["ModuleSpecifier"],
|
||
fields: {
|
||
exported: {
|
||
validate: (0, _utils.assertNodeType)("Identifier")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("ExportNamespaceSpecifier", {
|
||
visitor: ["exported"],
|
||
aliases: ["ModuleSpecifier"],
|
||
fields: {
|
||
exported: {
|
||
validate: (0, _utils.assertNodeType)("Identifier")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("PrivateName", {
|
||
visitor: ["id"],
|
||
aliases: ["Private"],
|
||
fields: {
|
||
id: {
|
||
validate: (0, _utils.assertNodeType)("Identifier")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("BigIntLiteral", {
|
||
builder: ["value"],
|
||
fields: {
|
||
value: {
|
||
validate: (0, _utils.assertValueType)("string")
|
||
}
|
||
},
|
||
aliases: ["Expression", "Pureish", "Literal", "Immutable"]
|
||
});
|
||
|
||
/***/ }),
|
||
/* 273 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
var _utils = _interopRequireWildcard(__webpack_require__(23));
|
||
|
||
var _core = __webpack_require__(81);
|
||
|
||
var _es = __webpack_require__(84);
|
||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||
|
||
const bool = (0, _utils.assertValueType)("boolean");
|
||
const tSFunctionTypeAnnotationCommon = {
|
||
returnType: {
|
||
validate: (0, _utils.assertNodeType)("TSTypeAnnotation", "Noop"),
|
||
optional: true
|
||
},
|
||
typeParameters: {
|
||
validate: (0, _utils.assertNodeType)("TSTypeParameterDeclaration", "Noop"),
|
||
optional: true
|
||
}
|
||
};
|
||
(0, _utils.default)("TSParameterProperty", {
|
||
aliases: ["LVal"],
|
||
visitor: ["parameter"],
|
||
fields: {
|
||
accessibility: {
|
||
validate: (0, _utils.assertOneOf)("public", "private", "protected"),
|
||
optional: true
|
||
},
|
||
readonly: {
|
||
validate: (0, _utils.assertValueType)("boolean"),
|
||
optional: true
|
||
},
|
||
parameter: {
|
||
validate: (0, _utils.assertNodeType)("Identifier", "AssignmentPattern")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("TSDeclareFunction", {
|
||
aliases: ["Statement", "Declaration"],
|
||
visitor: ["id", "typeParameters", "params", "returnType"],
|
||
fields: Object.assign({}, _core.functionDeclarationCommon, tSFunctionTypeAnnotationCommon)
|
||
});
|
||
(0, _utils.default)("TSDeclareMethod", {
|
||
visitor: ["decorators", "key", "typeParameters", "params", "returnType"],
|
||
fields: Object.assign({}, _es.classMethodOrDeclareMethodCommon, tSFunctionTypeAnnotationCommon)
|
||
});
|
||
(0, _utils.default)("TSQualifiedName", {
|
||
aliases: ["TSEntityName"],
|
||
visitor: ["left", "right"],
|
||
fields: {
|
||
left: (0, _utils.validateType)("TSEntityName"),
|
||
right: (0, _utils.validateType)("Identifier")
|
||
}
|
||
});
|
||
const signatureDeclarationCommon = {
|
||
typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterDeclaration"),
|
||
parameters: (0, _utils.validateArrayOfType)(["Identifier", "RestElement"]),
|
||
typeAnnotation: (0, _utils.validateOptionalType)("TSTypeAnnotation")
|
||
};
|
||
const callConstructSignatureDeclaration = {
|
||
aliases: ["TSTypeElement"],
|
||
visitor: ["typeParameters", "parameters", "typeAnnotation"],
|
||
fields: signatureDeclarationCommon
|
||
};
|
||
(0, _utils.default)("TSCallSignatureDeclaration", callConstructSignatureDeclaration);
|
||
(0, _utils.default)("TSConstructSignatureDeclaration", callConstructSignatureDeclaration);
|
||
const namedTypeElementCommon = {
|
||
key: (0, _utils.validateType)("Expression"),
|
||
computed: (0, _utils.validate)(bool),
|
||
optional: (0, _utils.validateOptional)(bool)
|
||
};
|
||
(0, _utils.default)("TSPropertySignature", {
|
||
aliases: ["TSTypeElement"],
|
||
visitor: ["key", "typeAnnotation", "initializer"],
|
||
fields: Object.assign({}, namedTypeElementCommon, {
|
||
readonly: (0, _utils.validateOptional)(bool),
|
||
typeAnnotation: (0, _utils.validateOptionalType)("TSTypeAnnotation"),
|
||
initializer: (0, _utils.validateOptionalType)("Expression")
|
||
})
|
||
});
|
||
(0, _utils.default)("TSMethodSignature", {
|
||
aliases: ["TSTypeElement"],
|
||
visitor: ["key", "typeParameters", "parameters", "typeAnnotation"],
|
||
fields: Object.assign({}, signatureDeclarationCommon, namedTypeElementCommon)
|
||
});
|
||
(0, _utils.default)("TSIndexSignature", {
|
||
aliases: ["TSTypeElement"],
|
||
visitor: ["parameters", "typeAnnotation"],
|
||
fields: {
|
||
readonly: (0, _utils.validateOptional)(bool),
|
||
parameters: (0, _utils.validateArrayOfType)("Identifier"),
|
||
typeAnnotation: (0, _utils.validateOptionalType)("TSTypeAnnotation")
|
||
}
|
||
});
|
||
const tsKeywordTypes = ["TSAnyKeyword", "TSUnknownKeyword", "TSNumberKeyword", "TSObjectKeyword", "TSBooleanKeyword", "TSStringKeyword", "TSSymbolKeyword", "TSVoidKeyword", "TSUndefinedKeyword", "TSNullKeyword", "TSNeverKeyword"];
|
||
|
||
for (const type of tsKeywordTypes) {
|
||
(0, _utils.default)(type, {
|
||
aliases: ["TSType"],
|
||
visitor: [],
|
||
fields: {}
|
||
});
|
||
}
|
||
|
||
(0, _utils.default)("TSThisType", {
|
||
aliases: ["TSType"],
|
||
visitor: [],
|
||
fields: {}
|
||
});
|
||
const fnOrCtr = {
|
||
aliases: ["TSType"],
|
||
visitor: ["typeParameters", "parameters", "typeAnnotation"],
|
||
fields: signatureDeclarationCommon
|
||
};
|
||
(0, _utils.default)("TSFunctionType", fnOrCtr);
|
||
(0, _utils.default)("TSConstructorType", fnOrCtr);
|
||
(0, _utils.default)("TSTypeReference", {
|
||
aliases: ["TSType"],
|
||
visitor: ["typeName", "typeParameters"],
|
||
fields: {
|
||
typeName: (0, _utils.validateType)("TSEntityName"),
|
||
typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterInstantiation")
|
||
}
|
||
});
|
||
(0, _utils.default)("TSTypePredicate", {
|
||
aliases: ["TSType"],
|
||
visitor: ["parameterName", "typeAnnotation"],
|
||
fields: {
|
||
parameterName: (0, _utils.validateType)(["Identifier", "TSThisType"]),
|
||
typeAnnotation: (0, _utils.validateType)("TSTypeAnnotation")
|
||
}
|
||
});
|
||
(0, _utils.default)("TSTypeQuery", {
|
||
aliases: ["TSType"],
|
||
visitor: ["exprName"],
|
||
fields: {
|
||
exprName: (0, _utils.validateType)(["TSEntityName", "TSImportType"])
|
||
}
|
||
});
|
||
(0, _utils.default)("TSTypeLiteral", {
|
||
aliases: ["TSType"],
|
||
visitor: ["members"],
|
||
fields: {
|
||
members: (0, _utils.validateArrayOfType)("TSTypeElement")
|
||
}
|
||
});
|
||
(0, _utils.default)("TSArrayType", {
|
||
aliases: ["TSType"],
|
||
visitor: ["elementType"],
|
||
fields: {
|
||
elementType: (0, _utils.validateType)("TSType")
|
||
}
|
||
});
|
||
(0, _utils.default)("TSTupleType", {
|
||
aliases: ["TSType"],
|
||
visitor: ["elementTypes"],
|
||
fields: {
|
||
elementTypes: (0, _utils.validateArrayOfType)("TSType")
|
||
}
|
||
});
|
||
(0, _utils.default)("TSOptionalType", {
|
||
aliases: ["TSType"],
|
||
visitor: ["typeAnnotation"],
|
||
fields: {
|
||
typeAnnotation: (0, _utils.validateType)("TSType")
|
||
}
|
||
});
|
||
(0, _utils.default)("TSRestType", {
|
||
aliases: ["TSType"],
|
||
visitor: ["typeAnnotation"],
|
||
fields: {
|
||
typeAnnotation: (0, _utils.validateType)("TSType")
|
||
}
|
||
});
|
||
const unionOrIntersection = {
|
||
aliases: ["TSType"],
|
||
visitor: ["types"],
|
||
fields: {
|
||
types: (0, _utils.validateArrayOfType)("TSType")
|
||
}
|
||
};
|
||
(0, _utils.default)("TSUnionType", unionOrIntersection);
|
||
(0, _utils.default)("TSIntersectionType", unionOrIntersection);
|
||
(0, _utils.default)("TSConditionalType", {
|
||
aliases: ["TSType"],
|
||
visitor: ["checkType", "extendsType", "trueType", "falseType"],
|
||
fields: {
|
||
checkType: (0, _utils.validateType)("TSType"),
|
||
extendsType: (0, _utils.validateType)("TSType"),
|
||
trueType: (0, _utils.validateType)("TSType"),
|
||
falseType: (0, _utils.validateType)("TSType")
|
||
}
|
||
});
|
||
(0, _utils.default)("TSInferType", {
|
||
aliases: ["TSType"],
|
||
visitor: ["typeParameter"],
|
||
fields: {
|
||
typeParameter: (0, _utils.validateType)("TSTypeParameter")
|
||
}
|
||
});
|
||
(0, _utils.default)("TSParenthesizedType", {
|
||
aliases: ["TSType"],
|
||
visitor: ["typeAnnotation"],
|
||
fields: {
|
||
typeAnnotation: (0, _utils.validateType)("TSType")
|
||
}
|
||
});
|
||
(0, _utils.default)("TSTypeOperator", {
|
||
aliases: ["TSType"],
|
||
visitor: ["typeAnnotation"],
|
||
fields: {
|
||
operator: (0, _utils.validate)((0, _utils.assertValueType)("string")),
|
||
typeAnnotation: (0, _utils.validateType)("TSType")
|
||
}
|
||
});
|
||
(0, _utils.default)("TSIndexedAccessType", {
|
||
aliases: ["TSType"],
|
||
visitor: ["objectType", "indexType"],
|
||
fields: {
|
||
objectType: (0, _utils.validateType)("TSType"),
|
||
indexType: (0, _utils.validateType)("TSType")
|
||
}
|
||
});
|
||
(0, _utils.default)("TSMappedType", {
|
||
aliases: ["TSType"],
|
||
visitor: ["typeParameter", "typeAnnotation"],
|
||
fields: {
|
||
readonly: (0, _utils.validateOptional)(bool),
|
||
typeParameter: (0, _utils.validateType)("TSTypeParameter"),
|
||
optional: (0, _utils.validateOptional)(bool),
|
||
typeAnnotation: (0, _utils.validateOptionalType)("TSType")
|
||
}
|
||
});
|
||
(0, _utils.default)("TSLiteralType", {
|
||
aliases: ["TSType"],
|
||
visitor: ["literal"],
|
||
fields: {
|
||
literal: (0, _utils.validateType)(["NumericLiteral", "StringLiteral", "BooleanLiteral"])
|
||
}
|
||
});
|
||
(0, _utils.default)("TSExpressionWithTypeArguments", {
|
||
aliases: ["TSType"],
|
||
visitor: ["expression", "typeParameters"],
|
||
fields: {
|
||
expression: (0, _utils.validateType)("TSEntityName"),
|
||
typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterInstantiation")
|
||
}
|
||
});
|
||
(0, _utils.default)("TSInterfaceDeclaration", {
|
||
aliases: ["Statement", "Declaration"],
|
||
visitor: ["id", "typeParameters", "extends", "body"],
|
||
fields: {
|
||
declare: (0, _utils.validateOptional)(bool),
|
||
id: (0, _utils.validateType)("Identifier"),
|
||
typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterDeclaration"),
|
||
extends: (0, _utils.validateOptional)((0, _utils.arrayOfType)("TSExpressionWithTypeArguments")),
|
||
body: (0, _utils.validateType)("TSInterfaceBody")
|
||
}
|
||
});
|
||
(0, _utils.default)("TSInterfaceBody", {
|
||
visitor: ["body"],
|
||
fields: {
|
||
body: (0, _utils.validateArrayOfType)("TSTypeElement")
|
||
}
|
||
});
|
||
(0, _utils.default)("TSTypeAliasDeclaration", {
|
||
aliases: ["Statement", "Declaration"],
|
||
visitor: ["id", "typeParameters", "typeAnnotation"],
|
||
fields: {
|
||
declare: (0, _utils.validateOptional)(bool),
|
||
id: (0, _utils.validateType)("Identifier"),
|
||
typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterDeclaration"),
|
||
typeAnnotation: (0, _utils.validateType)("TSType")
|
||
}
|
||
});
|
||
(0, _utils.default)("TSAsExpression", {
|
||
aliases: ["Expression"],
|
||
visitor: ["expression", "typeAnnotation"],
|
||
fields: {
|
||
expression: (0, _utils.validateType)("Expression"),
|
||
typeAnnotation: (0, _utils.validateType)("TSType")
|
||
}
|
||
});
|
||
(0, _utils.default)("TSTypeAssertion", {
|
||
aliases: ["Expression"],
|
||
visitor: ["typeAnnotation", "expression"],
|
||
fields: {
|
||
typeAnnotation: (0, _utils.validateType)("TSType"),
|
||
expression: (0, _utils.validateType)("Expression")
|
||
}
|
||
});
|
||
(0, _utils.default)("TSEnumDeclaration", {
|
||
aliases: ["Statement", "Declaration"],
|
||
visitor: ["id", "members"],
|
||
fields: {
|
||
declare: (0, _utils.validateOptional)(bool),
|
||
const: (0, _utils.validateOptional)(bool),
|
||
id: (0, _utils.validateType)("Identifier"),
|
||
members: (0, _utils.validateArrayOfType)("TSEnumMember"),
|
||
initializer: (0, _utils.validateOptionalType)("Expression")
|
||
}
|
||
});
|
||
(0, _utils.default)("TSEnumMember", {
|
||
visitor: ["id", "initializer"],
|
||
fields: {
|
||
id: (0, _utils.validateType)(["Identifier", "StringLiteral"]),
|
||
initializer: (0, _utils.validateOptionalType)("Expression")
|
||
}
|
||
});
|
||
(0, _utils.default)("TSModuleDeclaration", {
|
||
aliases: ["Statement", "Declaration"],
|
||
visitor: ["id", "body"],
|
||
fields: {
|
||
declare: (0, _utils.validateOptional)(bool),
|
||
global: (0, _utils.validateOptional)(bool),
|
||
id: (0, _utils.validateType)(["Identifier", "StringLiteral"]),
|
||
body: (0, _utils.validateType)(["TSModuleBlock", "TSModuleDeclaration"])
|
||
}
|
||
});
|
||
(0, _utils.default)("TSModuleBlock", {
|
||
aliases: ["Scopable", "Block", "BlockParent"],
|
||
visitor: ["body"],
|
||
fields: {
|
||
body: (0, _utils.validateArrayOfType)("Statement")
|
||
}
|
||
});
|
||
(0, _utils.default)("TSImportType", {
|
||
aliases: ["TSType"],
|
||
visitor: ["argument", "qualifier", "typeParameters"],
|
||
fields: {
|
||
argument: (0, _utils.validateType)("StringLiteral"),
|
||
qualifier: (0, _utils.validateOptionalType)("TSEntityName"),
|
||
typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterInstantiation")
|
||
}
|
||
});
|
||
(0, _utils.default)("TSImportEqualsDeclaration", {
|
||
aliases: ["Statement"],
|
||
visitor: ["id", "moduleReference"],
|
||
fields: {
|
||
isExport: (0, _utils.validate)(bool),
|
||
id: (0, _utils.validateType)("Identifier"),
|
||
moduleReference: (0, _utils.validateType)(["TSEntityName", "TSExternalModuleReference"])
|
||
}
|
||
});
|
||
(0, _utils.default)("TSExternalModuleReference", {
|
||
visitor: ["expression"],
|
||
fields: {
|
||
expression: (0, _utils.validateType)("StringLiteral")
|
||
}
|
||
});
|
||
(0, _utils.default)("TSNonNullExpression", {
|
||
aliases: ["Expression"],
|
||
visitor: ["expression"],
|
||
fields: {
|
||
expression: (0, _utils.validateType)("Expression")
|
||
}
|
||
});
|
||
(0, _utils.default)("TSExportAssignment", {
|
||
aliases: ["Statement"],
|
||
visitor: ["expression"],
|
||
fields: {
|
||
expression: (0, _utils.validateType)("Expression")
|
||
}
|
||
});
|
||
(0, _utils.default)("TSNamespaceExportDeclaration", {
|
||
aliases: ["Statement"],
|
||
visitor: ["id"],
|
||
fields: {
|
||
id: (0, _utils.validateType)("Identifier")
|
||
}
|
||
});
|
||
(0, _utils.default)("TSTypeAnnotation", {
|
||
visitor: ["typeAnnotation"],
|
||
fields: {
|
||
typeAnnotation: {
|
||
validate: (0, _utils.assertNodeType)("TSType")
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("TSTypeParameterInstantiation", {
|
||
visitor: ["params"],
|
||
fields: {
|
||
params: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("TSType")))
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("TSTypeParameterDeclaration", {
|
||
visitor: ["params"],
|
||
fields: {
|
||
params: {
|
||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("TSTypeParameter")))
|
||
}
|
||
}
|
||
});
|
||
(0, _utils.default)("TSTypeParameter", {
|
||
visitor: ["constraint", "default"],
|
||
fields: {
|
||
name: {
|
||
validate: (0, _utils.assertValueType)("string")
|
||
},
|
||
constraint: {
|
||
validate: (0, _utils.assertNodeType)("TSType"),
|
||
optional: true
|
||
},
|
||
default: {
|
||
validate: (0, _utils.assertNodeType)("TSType"),
|
||
optional: true
|
||
}
|
||
}
|
||
});
|
||
|
||
/***/ }),
|
||
/* 274 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = assertNode;
|
||
|
||
var _isNode = _interopRequireDefault(__webpack_require__(137));
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function assertNode(node) {
|
||
if (!(0, _isNode.default)(node)) {
|
||
const type = node && node.type || JSON.stringify(node);
|
||
throw new TypeError(`Not a valid node of type "${type}"`);
|
||
}
|
||
}
|
||
|
||
/***/ }),
|
||
/* 275 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.assertArrayExpression = assertArrayExpression;
|
||
exports.assertAssignmentExpression = assertAssignmentExpression;
|
||
exports.assertBinaryExpression = assertBinaryExpression;
|
||
exports.assertInterpreterDirective = assertInterpreterDirective;
|
||
exports.assertDirective = assertDirective;
|
||
exports.assertDirectiveLiteral = assertDirectiveLiteral;
|
||
exports.assertBlockStatement = assertBlockStatement;
|
||
exports.assertBreakStatement = assertBreakStatement;
|
||
exports.assertCallExpression = assertCallExpression;
|
||
exports.assertCatchClause = assertCatchClause;
|
||
exports.assertConditionalExpression = assertConditionalExpression;
|
||
exports.assertContinueStatement = assertContinueStatement;
|
||
exports.assertDebuggerStatement = assertDebuggerStatement;
|
||
exports.assertDoWhileStatement = assertDoWhileStatement;
|
||
exports.assertEmptyStatement = assertEmptyStatement;
|
||
exports.assertExpressionStatement = assertExpressionStatement;
|
||
exports.assertFile = assertFile;
|
||
exports.assertForInStatement = assertForInStatement;
|
||
exports.assertForStatement = assertForStatement;
|
||
exports.assertFunctionDeclaration = assertFunctionDeclaration;
|
||
exports.assertFunctionExpression = assertFunctionExpression;
|
||
exports.assertIdentifier = assertIdentifier;
|
||
exports.assertIfStatement = assertIfStatement;
|
||
exports.assertLabeledStatement = assertLabeledStatement;
|
||
exports.assertStringLiteral = assertStringLiteral;
|
||
exports.assertNumericLiteral = assertNumericLiteral;
|
||
exports.assertNullLiteral = assertNullLiteral;
|
||
exports.assertBooleanLiteral = assertBooleanLiteral;
|
||
exports.assertRegExpLiteral = assertRegExpLiteral;
|
||
exports.assertLogicalExpression = assertLogicalExpression;
|
||
exports.assertMemberExpression = assertMemberExpression;
|
||
exports.assertNewExpression = assertNewExpression;
|
||
exports.assertProgram = assertProgram;
|
||
exports.assertObjectExpression = assertObjectExpression;
|
||
exports.assertObjectMethod = assertObjectMethod;
|
||
exports.assertObjectProperty = assertObjectProperty;
|
||
exports.assertRestElement = assertRestElement;
|
||
exports.assertReturnStatement = assertReturnStatement;
|
||
exports.assertSequenceExpression = assertSequenceExpression;
|
||
exports.assertParenthesizedExpression = assertParenthesizedExpression;
|
||
exports.assertSwitchCase = assertSwitchCase;
|
||
exports.assertSwitchStatement = assertSwitchStatement;
|
||
exports.assertThisExpression = assertThisExpression;
|
||
exports.assertThrowStatement = assertThrowStatement;
|
||
exports.assertTryStatement = assertTryStatement;
|
||
exports.assertUnaryExpression = assertUnaryExpression;
|
||
exports.assertUpdateExpression = assertUpdateExpression;
|
||
exports.assertVariableDeclaration = assertVariableDeclaration;
|
||
exports.assertVariableDeclarator = assertVariableDeclarator;
|
||
exports.assertWhileStatement = assertWhileStatement;
|
||
exports.assertWithStatement = assertWithStatement;
|
||
exports.assertAssignmentPattern = assertAssignmentPattern;
|
||
exports.assertArrayPattern = assertArrayPattern;
|
||
exports.assertArrowFunctionExpression = assertArrowFunctionExpression;
|
||
exports.assertClassBody = assertClassBody;
|
||
exports.assertClassDeclaration = assertClassDeclaration;
|
||
exports.assertClassExpression = assertClassExpression;
|
||
exports.assertExportAllDeclaration = assertExportAllDeclaration;
|
||
exports.assertExportDefaultDeclaration = assertExportDefaultDeclaration;
|
||
exports.assertExportNamedDeclaration = assertExportNamedDeclaration;
|
||
exports.assertExportSpecifier = assertExportSpecifier;
|
||
exports.assertForOfStatement = assertForOfStatement;
|
||
exports.assertImportDeclaration = assertImportDeclaration;
|
||
exports.assertImportDefaultSpecifier = assertImportDefaultSpecifier;
|
||
exports.assertImportNamespaceSpecifier = assertImportNamespaceSpecifier;
|
||
exports.assertImportSpecifier = assertImportSpecifier;
|
||
exports.assertMetaProperty = assertMetaProperty;
|
||
exports.assertClassMethod = assertClassMethod;
|
||
exports.assertObjectPattern = assertObjectPattern;
|
||
exports.assertSpreadElement = assertSpreadElement;
|
||
exports.assertSuper = assertSuper;
|
||
exports.assertTaggedTemplateExpression = assertTaggedTemplateExpression;
|
||
exports.assertTemplateElement = assertTemplateElement;
|
||
exports.assertTemplateLiteral = assertTemplateLiteral;
|
||
exports.assertYieldExpression = assertYieldExpression;
|
||
exports.assertAnyTypeAnnotation = assertAnyTypeAnnotation;
|
||
exports.assertArrayTypeAnnotation = assertArrayTypeAnnotation;
|
||
exports.assertBooleanTypeAnnotation = assertBooleanTypeAnnotation;
|
||
exports.assertBooleanLiteralTypeAnnotation = assertBooleanLiteralTypeAnnotation;
|
||
exports.assertNullLiteralTypeAnnotation = assertNullLiteralTypeAnnotation;
|
||
exports.assertClassImplements = assertClassImplements;
|
||
exports.assertDeclareClass = assertDeclareClass;
|
||
exports.assertDeclareFunction = assertDeclareFunction;
|
||
exports.assertDeclareInterface = assertDeclareInterface;
|
||
exports.assertDeclareModule = assertDeclareModule;
|
||
exports.assertDeclareModuleExports = assertDeclareModuleExports;
|
||
exports.assertDeclareTypeAlias = assertDeclareTypeAlias;
|
||
exports.assertDeclareOpaqueType = assertDeclareOpaqueType;
|
||
exports.assertDeclareVariable = assertDeclareVariable;
|
||
exports.assertDeclareExportDeclaration = assertDeclareExportDeclaration;
|
||
exports.assertDeclareExportAllDeclaration = assertDeclareExportAllDeclaration;
|
||
exports.assertDeclaredPredicate = assertDeclaredPredicate;
|
||
exports.assertExistsTypeAnnotation = assertExistsTypeAnnotation;
|
||
exports.assertFunctionTypeAnnotation = assertFunctionTypeAnnotation;
|
||
exports.assertFunctionTypeParam = assertFunctionTypeParam;
|
||
exports.assertGenericTypeAnnotation = assertGenericTypeAnnotation;
|
||
exports.assertInferredPredicate = assertInferredPredicate;
|
||
exports.assertInterfaceExtends = assertInterfaceExtends;
|
||
exports.assertInterfaceDeclaration = assertInterfaceDeclaration;
|
||
exports.assertInterfaceTypeAnnotation = assertInterfaceTypeAnnotation;
|
||
exports.assertIntersectionTypeAnnotation = assertIntersectionTypeAnnotation;
|
||
exports.assertMixedTypeAnnotation = assertMixedTypeAnnotation;
|
||
exports.assertEmptyTypeAnnotation = assertEmptyTypeAnnotation;
|
||
exports.assertNullableTypeAnnotation = assertNullableTypeAnnotation;
|
||
exports.assertNumberLiteralTypeAnnotation = assertNumberLiteralTypeAnnotation;
|
||
exports.assertNumberTypeAnnotation = assertNumberTypeAnnotation;
|
||
exports.assertObjectTypeAnnotation = assertObjectTypeAnnotation;
|
||
exports.assertObjectTypeInternalSlot = assertObjectTypeInternalSlot;
|
||
exports.assertObjectTypeCallProperty = assertObjectTypeCallProperty;
|
||
exports.assertObjectTypeIndexer = assertObjectTypeIndexer;
|
||
exports.assertObjectTypeProperty = assertObjectTypeProperty;
|
||
exports.assertObjectTypeSpreadProperty = assertObjectTypeSpreadProperty;
|
||
exports.assertOpaqueType = assertOpaqueType;
|
||
exports.assertQualifiedTypeIdentifier = assertQualifiedTypeIdentifier;
|
||
exports.assertStringLiteralTypeAnnotation = assertStringLiteralTypeAnnotation;
|
||
exports.assertStringTypeAnnotation = assertStringTypeAnnotation;
|
||
exports.assertThisTypeAnnotation = assertThisTypeAnnotation;
|
||
exports.assertTupleTypeAnnotation = assertTupleTypeAnnotation;
|
||
exports.assertTypeofTypeAnnotation = assertTypeofTypeAnnotation;
|
||
exports.assertTypeAlias = assertTypeAlias;
|
||
exports.assertTypeAnnotation = assertTypeAnnotation;
|
||
exports.assertTypeCastExpression = assertTypeCastExpression;
|
||
exports.assertTypeParameter = assertTypeParameter;
|
||
exports.assertTypeParameterDeclaration = assertTypeParameterDeclaration;
|
||
exports.assertTypeParameterInstantiation = assertTypeParameterInstantiation;
|
||
exports.assertUnionTypeAnnotation = assertUnionTypeAnnotation;
|
||
exports.assertVariance = assertVariance;
|
||
exports.assertVoidTypeAnnotation = assertVoidTypeAnnotation;
|
||
exports.assertJSXAttribute = assertJSXAttribute;
|
||
exports.assertJSXClosingElement = assertJSXClosingElement;
|
||
exports.assertJSXElement = assertJSXElement;
|
||
exports.assertJSXEmptyExpression = assertJSXEmptyExpression;
|
||
exports.assertJSXExpressionContainer = assertJSXExpressionContainer;
|
||
exports.assertJSXSpreadChild = assertJSXSpreadChild;
|
||
exports.assertJSXIdentifier = assertJSXIdentifier;
|
||
exports.assertJSXMemberExpression = assertJSXMemberExpression;
|
||
exports.assertJSXNamespacedName = assertJSXNamespacedName;
|
||
exports.assertJSXOpeningElement = assertJSXOpeningElement;
|
||
exports.assertJSXSpreadAttribute = assertJSXSpreadAttribute;
|
||
exports.assertJSXText = assertJSXText;
|
||
exports.assertJSXFragment = assertJSXFragment;
|
||
exports.assertJSXOpeningFragment = assertJSXOpeningFragment;
|
||
exports.assertJSXClosingFragment = assertJSXClosingFragment;
|
||
exports.assertNoop = assertNoop;
|
||
exports.assertPlaceholder = assertPlaceholder;
|
||
exports.assertArgumentPlaceholder = assertArgumentPlaceholder;
|
||
exports.assertAwaitExpression = assertAwaitExpression;
|
||
exports.assertBindExpression = assertBindExpression;
|
||
exports.assertClassProperty = assertClassProperty;
|
||
exports.assertOptionalMemberExpression = assertOptionalMemberExpression;
|
||
exports.assertPipelineTopicExpression = assertPipelineTopicExpression;
|
||
exports.assertPipelineBareFunction = assertPipelineBareFunction;
|
||
exports.assertPipelinePrimaryTopicReference = assertPipelinePrimaryTopicReference;
|
||
exports.assertOptionalCallExpression = assertOptionalCallExpression;
|
||
exports.assertClassPrivateProperty = assertClassPrivateProperty;
|
||
exports.assertClassPrivateMethod = assertClassPrivateMethod;
|
||
exports.assertImport = assertImport;
|
||
exports.assertDecorator = assertDecorator;
|
||
exports.assertDoExpression = assertDoExpression;
|
||
exports.assertExportDefaultSpecifier = assertExportDefaultSpecifier;
|
||
exports.assertExportNamespaceSpecifier = assertExportNamespaceSpecifier;
|
||
exports.assertPrivateName = assertPrivateName;
|
||
exports.assertBigIntLiteral = assertBigIntLiteral;
|
||
exports.assertTSParameterProperty = assertTSParameterProperty;
|
||
exports.assertTSDeclareFunction = assertTSDeclareFunction;
|
||
exports.assertTSDeclareMethod = assertTSDeclareMethod;
|
||
exports.assertTSQualifiedName = assertTSQualifiedName;
|
||
exports.assertTSCallSignatureDeclaration = assertTSCallSignatureDeclaration;
|
||
exports.assertTSConstructSignatureDeclaration = assertTSConstructSignatureDeclaration;
|
||
exports.assertTSPropertySignature = assertTSPropertySignature;
|
||
exports.assertTSMethodSignature = assertTSMethodSignature;
|
||
exports.assertTSIndexSignature = assertTSIndexSignature;
|
||
exports.assertTSAnyKeyword = assertTSAnyKeyword;
|
||
exports.assertTSUnknownKeyword = assertTSUnknownKeyword;
|
||
exports.assertTSNumberKeyword = assertTSNumberKeyword;
|
||
exports.assertTSObjectKeyword = assertTSObjectKeyword;
|
||
exports.assertTSBooleanKeyword = assertTSBooleanKeyword;
|
||
exports.assertTSStringKeyword = assertTSStringKeyword;
|
||
exports.assertTSSymbolKeyword = assertTSSymbolKeyword;
|
||
exports.assertTSVoidKeyword = assertTSVoidKeyword;
|
||
exports.assertTSUndefinedKeyword = assertTSUndefinedKeyword;
|
||
exports.assertTSNullKeyword = assertTSNullKeyword;
|
||
exports.assertTSNeverKeyword = assertTSNeverKeyword;
|
||
exports.assertTSThisType = assertTSThisType;
|
||
exports.assertTSFunctionType = assertTSFunctionType;
|
||
exports.assertTSConstructorType = assertTSConstructorType;
|
||
exports.assertTSTypeReference = assertTSTypeReference;
|
||
exports.assertTSTypePredicate = assertTSTypePredicate;
|
||
exports.assertTSTypeQuery = assertTSTypeQuery;
|
||
exports.assertTSTypeLiteral = assertTSTypeLiteral;
|
||
exports.assertTSArrayType = assertTSArrayType;
|
||
exports.assertTSTupleType = assertTSTupleType;
|
||
exports.assertTSOptionalType = assertTSOptionalType;
|
||
exports.assertTSRestType = assertTSRestType;
|
||
exports.assertTSUnionType = assertTSUnionType;
|
||
exports.assertTSIntersectionType = assertTSIntersectionType;
|
||
exports.assertTSConditionalType = assertTSConditionalType;
|
||
exports.assertTSInferType = assertTSInferType;
|
||
exports.assertTSParenthesizedType = assertTSParenthesizedType;
|
||
exports.assertTSTypeOperator = assertTSTypeOperator;
|
||
exports.assertTSIndexedAccessType = assertTSIndexedAccessType;
|
||
exports.assertTSMappedType = assertTSMappedType;
|
||
exports.assertTSLiteralType = assertTSLiteralType;
|
||
exports.assertTSExpressionWithTypeArguments = assertTSExpressionWithTypeArguments;
|
||
exports.assertTSInterfaceDeclaration = assertTSInterfaceDeclaration;
|
||
exports.assertTSInterfaceBody = assertTSInterfaceBody;
|
||
exports.assertTSTypeAliasDeclaration = assertTSTypeAliasDeclaration;
|
||
exports.assertTSAsExpression = assertTSAsExpression;
|
||
exports.assertTSTypeAssertion = assertTSTypeAssertion;
|
||
exports.assertTSEnumDeclaration = assertTSEnumDeclaration;
|
||
exports.assertTSEnumMember = assertTSEnumMember;
|
||
exports.assertTSModuleDeclaration = assertTSModuleDeclaration;
|
||
exports.assertTSModuleBlock = assertTSModuleBlock;
|
||
exports.assertTSImportType = assertTSImportType;
|
||
exports.assertTSImportEqualsDeclaration = assertTSImportEqualsDeclaration;
|
||
exports.assertTSExternalModuleReference = assertTSExternalModuleReference;
|
||
exports.assertTSNonNullExpression = assertTSNonNullExpression;
|
||
exports.assertTSExportAssignment = assertTSExportAssignment;
|
||
exports.assertTSNamespaceExportDeclaration = assertTSNamespaceExportDeclaration;
|
||
exports.assertTSTypeAnnotation = assertTSTypeAnnotation;
|
||
exports.assertTSTypeParameterInstantiation = assertTSTypeParameterInstantiation;
|
||
exports.assertTSTypeParameterDeclaration = assertTSTypeParameterDeclaration;
|
||
exports.assertTSTypeParameter = assertTSTypeParameter;
|
||
exports.assertExpression = assertExpression;
|
||
exports.assertBinary = assertBinary;
|
||
exports.assertScopable = assertScopable;
|
||
exports.assertBlockParent = assertBlockParent;
|
||
exports.assertBlock = assertBlock;
|
||
exports.assertStatement = assertStatement;
|
||
exports.assertTerminatorless = assertTerminatorless;
|
||
exports.assertCompletionStatement = assertCompletionStatement;
|
||
exports.assertConditional = assertConditional;
|
||
exports.assertLoop = assertLoop;
|
||
exports.assertWhile = assertWhile;
|
||
exports.assertExpressionWrapper = assertExpressionWrapper;
|
||
exports.assertFor = assertFor;
|
||
exports.assertForXStatement = assertForXStatement;
|
||
exports.assertFunction = assertFunction;
|
||
exports.assertFunctionParent = assertFunctionParent;
|
||
exports.assertPureish = assertPureish;
|
||
exports.assertDeclaration = assertDeclaration;
|
||
exports.assertPatternLike = assertPatternLike;
|
||
exports.assertLVal = assertLVal;
|
||
exports.assertTSEntityName = assertTSEntityName;
|
||
exports.assertLiteral = assertLiteral;
|
||
exports.assertImmutable = assertImmutable;
|
||
exports.assertUserWhitespacable = assertUserWhitespacable;
|
||
exports.assertMethod = assertMethod;
|
||
exports.assertObjectMember = assertObjectMember;
|
||
exports.assertProperty = assertProperty;
|
||
exports.assertUnaryLike = assertUnaryLike;
|
||
exports.assertPattern = assertPattern;
|
||
exports.assertClass = assertClass;
|
||
exports.assertModuleDeclaration = assertModuleDeclaration;
|
||
exports.assertExportDeclaration = assertExportDeclaration;
|
||
exports.assertModuleSpecifier = assertModuleSpecifier;
|
||
exports.assertFlow = assertFlow;
|
||
exports.assertFlowType = assertFlowType;
|
||
exports.assertFlowBaseAnnotation = assertFlowBaseAnnotation;
|
||
exports.assertFlowDeclaration = assertFlowDeclaration;
|
||
exports.assertFlowPredicate = assertFlowPredicate;
|
||
exports.assertJSX = assertJSX;
|
||
exports.assertPrivate = assertPrivate;
|
||
exports.assertTSTypeElement = assertTSTypeElement;
|
||
exports.assertTSType = assertTSType;
|
||
exports.assertNumberLiteral = assertNumberLiteral;
|
||
exports.assertRegexLiteral = assertRegexLiteral;
|
||
exports.assertRestProperty = assertRestProperty;
|
||
exports.assertSpreadProperty = assertSpreadProperty;
|
||
|
||
var _is = _interopRequireDefault(__webpack_require__(82));
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function assert(type, node, opts) {
|
||
if (!(0, _is.default)(type, node, opts)) {
|
||
throw new Error(`Expected type "${type}" with option ${JSON.stringify(opts)}, but instead got "${node.type}".`);
|
||
}
|
||
}
|
||
|
||
function assertArrayExpression(node, opts = {}) {
|
||
assert("ArrayExpression", node, opts);
|
||
}
|
||
|
||
function assertAssignmentExpression(node, opts = {}) {
|
||
assert("AssignmentExpression", node, opts);
|
||
}
|
||
|
||
function assertBinaryExpression(node, opts = {}) {
|
||
assert("BinaryExpression", node, opts);
|
||
}
|
||
|
||
function assertInterpreterDirective(node, opts = {}) {
|
||
assert("InterpreterDirective", node, opts);
|
||
}
|
||
|
||
function assertDirective(node, opts = {}) {
|
||
assert("Directive", node, opts);
|
||
}
|
||
|
||
function assertDirectiveLiteral(node, opts = {}) {
|
||
assert("DirectiveLiteral", node, opts);
|
||
}
|
||
|
||
function assertBlockStatement(node, opts = {}) {
|
||
assert("BlockStatement", node, opts);
|
||
}
|
||
|
||
function assertBreakStatement(node, opts = {}) {
|
||
assert("BreakStatement", node, opts);
|
||
}
|
||
|
||
function assertCallExpression(node, opts = {}) {
|
||
assert("CallExpression", node, opts);
|
||
}
|
||
|
||
function assertCatchClause(node, opts = {}) {
|
||
assert("CatchClause", node, opts);
|
||
}
|
||
|
||
function assertConditionalExpression(node, opts = {}) {
|
||
assert("ConditionalExpression", node, opts);
|
||
}
|
||
|
||
function assertContinueStatement(node, opts = {}) {
|
||
assert("ContinueStatement", node, opts);
|
||
}
|
||
|
||
function assertDebuggerStatement(node, opts = {}) {
|
||
assert("DebuggerStatement", node, opts);
|
||
}
|
||
|
||
function assertDoWhileStatement(node, opts = {}) {
|
||
assert("DoWhileStatement", node, opts);
|
||
}
|
||
|
||
function assertEmptyStatement(node, opts = {}) {
|
||
assert("EmptyStatement", node, opts);
|
||
}
|
||
|
||
function assertExpressionStatement(node, opts = {}) {
|
||
assert("ExpressionStatement", node, opts);
|
||
}
|
||
|
||
function assertFile(node, opts = {}) {
|
||
assert("File", node, opts);
|
||
}
|
||
|
||
function assertForInStatement(node, opts = {}) {
|
||
assert("ForInStatement", node, opts);
|
||
}
|
||
|
||
function assertForStatement(node, opts = {}) {
|
||
assert("ForStatement", node, opts);
|
||
}
|
||
|
||
function assertFunctionDeclaration(node, opts = {}) {
|
||
assert("FunctionDeclaration", node, opts);
|
||
}
|
||
|
||
function assertFunctionExpression(node, opts = {}) {
|
||
assert("FunctionExpression", node, opts);
|
||
}
|
||
|
||
function assertIdentifier(node, opts = {}) {
|
||
assert("Identifier", node, opts);
|
||
}
|
||
|
||
function assertIfStatement(node, opts = {}) {
|
||
assert("IfStatement", node, opts);
|
||
}
|
||
|
||
function assertLabeledStatement(node, opts = {}) {
|
||
assert("LabeledStatement", node, opts);
|
||
}
|
||
|
||
function assertStringLiteral(node, opts = {}) {
|
||
assert("StringLiteral", node, opts);
|
||
}
|
||
|
||
function assertNumericLiteral(node, opts = {}) {
|
||
assert("NumericLiteral", node, opts);
|
||
}
|
||
|
||
function assertNullLiteral(node, opts = {}) {
|
||
assert("NullLiteral", node, opts);
|
||
}
|
||
|
||
function assertBooleanLiteral(node, opts = {}) {
|
||
assert("BooleanLiteral", node, opts);
|
||
}
|
||
|
||
function assertRegExpLiteral(node, opts = {}) {
|
||
assert("RegExpLiteral", node, opts);
|
||
}
|
||
|
||
function assertLogicalExpression(node, opts = {}) {
|
||
assert("LogicalExpression", node, opts);
|
||
}
|
||
|
||
function assertMemberExpression(node, opts = {}) {
|
||
assert("MemberExpression", node, opts);
|
||
}
|
||
|
||
function assertNewExpression(node, opts = {}) {
|
||
assert("NewExpression", node, opts);
|
||
}
|
||
|
||
function assertProgram(node, opts = {}) {
|
||
assert("Program", node, opts);
|
||
}
|
||
|
||
function assertObjectExpression(node, opts = {}) {
|
||
assert("ObjectExpression", node, opts);
|
||
}
|
||
|
||
function assertObjectMethod(node, opts = {}) {
|
||
assert("ObjectMethod", node, opts);
|
||
}
|
||
|
||
function assertObjectProperty(node, opts = {}) {
|
||
assert("ObjectProperty", node, opts);
|
||
}
|
||
|
||
function assertRestElement(node, opts = {}) {
|
||
assert("RestElement", node, opts);
|
||
}
|
||
|
||
function assertReturnStatement(node, opts = {}) {
|
||
assert("ReturnStatement", node, opts);
|
||
}
|
||
|
||
function assertSequenceExpression(node, opts = {}) {
|
||
assert("SequenceExpression", node, opts);
|
||
}
|
||
|
||
function assertParenthesizedExpression(node, opts = {}) {
|
||
assert("ParenthesizedExpression", node, opts);
|
||
}
|
||
|
||
function assertSwitchCase(node, opts = {}) {
|
||
assert("SwitchCase", node, opts);
|
||
}
|
||
|
||
function assertSwitchStatement(node, opts = {}) {
|
||
assert("SwitchStatement", node, opts);
|
||
}
|
||
|
||
function assertThisExpression(node, opts = {}) {
|
||
assert("ThisExpression", node, opts);
|
||
}
|
||
|
||
function assertThrowStatement(node, opts = {}) {
|
||
assert("ThrowStatement", node, opts);
|
||
}
|
||
|
||
function assertTryStatement(node, opts = {}) {
|
||
assert("TryStatement", node, opts);
|
||
}
|
||
|
||
function assertUnaryExpression(node, opts = {}) {
|
||
assert("UnaryExpression", node, opts);
|
||
}
|
||
|
||
function assertUpdateExpression(node, opts = {}) {
|
||
assert("UpdateExpression", node, opts);
|
||
}
|
||
|
||
function assertVariableDeclaration(node, opts = {}) {
|
||
assert("VariableDeclaration", node, opts);
|
||
}
|
||
|
||
function assertVariableDeclarator(node, opts = {}) {
|
||
assert("VariableDeclarator", node, opts);
|
||
}
|
||
|
||
function assertWhileStatement(node, opts = {}) {
|
||
assert("WhileStatement", node, opts);
|
||
}
|
||
|
||
function assertWithStatement(node, opts = {}) {
|
||
assert("WithStatement", node, opts);
|
||
}
|
||
|
||
function assertAssignmentPattern(node, opts = {}) {
|
||
assert("AssignmentPattern", node, opts);
|
||
}
|
||
|
||
function assertArrayPattern(node, opts = {}) {
|
||
assert("ArrayPattern", node, opts);
|
||
}
|
||
|
||
function assertArrowFunctionExpression(node, opts = {}) {
|
||
assert("ArrowFunctionExpression", node, opts);
|
||
}
|
||
|
||
function assertClassBody(node, opts = {}) {
|
||
assert("ClassBody", node, opts);
|
||
}
|
||
|
||
function assertClassDeclaration(node, opts = {}) {
|
||
assert("ClassDeclaration", node, opts);
|
||
}
|
||
|
||
function assertClassExpression(node, opts = {}) {
|
||
assert("ClassExpression", node, opts);
|
||
}
|
||
|
||
function assertExportAllDeclaration(node, opts = {}) {
|
||
assert("ExportAllDeclaration", node, opts);
|
||
}
|
||
|
||
function assertExportDefaultDeclaration(node, opts = {}) {
|
||
assert("ExportDefaultDeclaration", node, opts);
|
||
}
|
||
|
||
function assertExportNamedDeclaration(node, opts = {}) {
|
||
assert("ExportNamedDeclaration", node, opts);
|
||
}
|
||
|
||
function assertExportSpecifier(node, opts = {}) {
|
||
assert("ExportSpecifier", node, opts);
|
||
}
|
||
|
||
function assertForOfStatement(node, opts = {}) {
|
||
assert("ForOfStatement", node, opts);
|
||
}
|
||
|
||
function assertImportDeclaration(node, opts = {}) {
|
||
assert("ImportDeclaration", node, opts);
|
||
}
|
||
|
||
function assertImportDefaultSpecifier(node, opts = {}) {
|
||
assert("ImportDefaultSpecifier", node, opts);
|
||
}
|
||
|
||
function assertImportNamespaceSpecifier(node, opts = {}) {
|
||
assert("ImportNamespaceSpecifier", node, opts);
|
||
}
|
||
|
||
function assertImportSpecifier(node, opts = {}) {
|
||
assert("ImportSpecifier", node, opts);
|
||
}
|
||
|
||
function assertMetaProperty(node, opts = {}) {
|
||
assert("MetaProperty", node, opts);
|
||
}
|
||
|
||
function assertClassMethod(node, opts = {}) {
|
||
assert("ClassMethod", node, opts);
|
||
}
|
||
|
||
function assertObjectPattern(node, opts = {}) {
|
||
assert("ObjectPattern", node, opts);
|
||
}
|
||
|
||
function assertSpreadElement(node, opts = {}) {
|
||
assert("SpreadElement", node, opts);
|
||
}
|
||
|
||
function assertSuper(node, opts = {}) {
|
||
assert("Super", node, opts);
|
||
}
|
||
|
||
function assertTaggedTemplateExpression(node, opts = {}) {
|
||
assert("TaggedTemplateExpression", node, opts);
|
||
}
|
||
|
||
function assertTemplateElement(node, opts = {}) {
|
||
assert("TemplateElement", node, opts);
|
||
}
|
||
|
||
function assertTemplateLiteral(node, opts = {}) {
|
||
assert("TemplateLiteral", node, opts);
|
||
}
|
||
|
||
function assertYieldExpression(node, opts = {}) {
|
||
assert("YieldExpression", node, opts);
|
||
}
|
||
|
||
function assertAnyTypeAnnotation(node, opts = {}) {
|
||
assert("AnyTypeAnnotation", node, opts);
|
||
}
|
||
|
||
function assertArrayTypeAnnotation(node, opts = {}) {
|
||
assert("ArrayTypeAnnotation", node, opts);
|
||
}
|
||
|
||
function assertBooleanTypeAnnotation(node, opts = {}) {
|
||
assert("BooleanTypeAnnotation", node, opts);
|
||
}
|
||
|
||
function assertBooleanLiteralTypeAnnotation(node, opts = {}) {
|
||
assert("BooleanLiteralTypeAnnotation", node, opts);
|
||
}
|
||
|
||
function assertNullLiteralTypeAnnotation(node, opts = {}) {
|
||
assert("NullLiteralTypeAnnotation", node, opts);
|
||
}
|
||
|
||
function assertClassImplements(node, opts = {}) {
|
||
assert("ClassImplements", node, opts);
|
||
}
|
||
|
||
function assertDeclareClass(node, opts = {}) {
|
||
assert("DeclareClass", node, opts);
|
||
}
|
||
|
||
function assertDeclareFunction(node, opts = {}) {
|
||
assert("DeclareFunction", node, opts);
|
||
}
|
||
|
||
function assertDeclareInterface(node, opts = {}) {
|
||
assert("DeclareInterface", node, opts);
|
||
}
|
||
|
||
function assertDeclareModule(node, opts = {}) {
|
||
assert("DeclareModule", node, opts);
|
||
}
|
||
|
||
function assertDeclareModuleExports(node, opts = {}) {
|
||
assert("DeclareModuleExports", node, opts);
|
||
}
|
||
|
||
function assertDeclareTypeAlias(node, opts = {}) {
|
||
assert("DeclareTypeAlias", node, opts);
|
||
}
|
||
|
||
function assertDeclareOpaqueType(node, opts = {}) {
|
||
assert("DeclareOpaqueType", node, opts);
|
||
}
|
||
|
||
function assertDeclareVariable(node, opts = {}) {
|
||
assert("DeclareVariable", node, opts);
|
||
}
|
||
|
||
function assertDeclareExportDeclaration(node, opts = {}) {
|
||
assert("DeclareExportDeclaration", node, opts);
|
||
}
|
||
|
||
function assertDeclareExportAllDeclaration(node, opts = {}) {
|
||
assert("DeclareExportAllDeclaration", node, opts);
|
||
}
|
||
|
||
function assertDeclaredPredicate(node, opts = {}) {
|
||
assert("DeclaredPredicate", node, opts);
|
||
}
|
||
|
||
function assertExistsTypeAnnotation(node, opts = {}) {
|
||
assert("ExistsTypeAnnotation", node, opts);
|
||
}
|
||
|
||
function assertFunctionTypeAnnotation(node, opts = {}) {
|
||
assert("FunctionTypeAnnotation", node, opts);
|
||
}
|
||
|
||
function assertFunctionTypeParam(node, opts = {}) {
|
||
assert("FunctionTypeParam", node, opts);
|
||
}
|
||
|
||
function assertGenericTypeAnnotation(node, opts = {}) {
|
||
assert("GenericTypeAnnotation", node, opts);
|
||
}
|
||
|
||
function assertInferredPredicate(node, opts = {}) {
|
||
assert("InferredPredicate", node, opts);
|
||
}
|
||
|
||
function assertInterfaceExtends(node, opts = {}) {
|
||
assert("InterfaceExtends", node, opts);
|
||
}
|
||
|
||
function assertInterfaceDeclaration(node, opts = {}) {
|
||
assert("InterfaceDeclaration", node, opts);
|
||
}
|
||
|
||
function assertInterfaceTypeAnnotation(node, opts = {}) {
|
||
assert("InterfaceTypeAnnotation", node, opts);
|
||
}
|
||
|
||
function assertIntersectionTypeAnnotation(node, opts = {}) {
|
||
assert("IntersectionTypeAnnotation", node, opts);
|
||
}
|
||
|
||
function assertMixedTypeAnnotation(node, opts = {}) {
|
||
assert("MixedTypeAnnotation", node, opts);
|
||
}
|
||
|
||
function assertEmptyTypeAnnotation(node, opts = {}) {
|
||
assert("EmptyTypeAnnotation", node, opts);
|
||
}
|
||
|
||
function assertNullableTypeAnnotation(node, opts = {}) {
|
||
assert("NullableTypeAnnotation", node, opts);
|
||
}
|
||
|
||
function assertNumberLiteralTypeAnnotation(node, opts = {}) {
|
||
assert("NumberLiteralTypeAnnotation", node, opts);
|
||
}
|
||
|
||
function assertNumberTypeAnnotation(node, opts = {}) {
|
||
assert("NumberTypeAnnotation", node, opts);
|
||
}
|
||
|
||
function assertObjectTypeAnnotation(node, opts = {}) {
|
||
assert("ObjectTypeAnnotation", node, opts);
|
||
}
|
||
|
||
function assertObjectTypeInternalSlot(node, opts = {}) {
|
||
assert("ObjectTypeInternalSlot", node, opts);
|
||
}
|
||
|
||
function assertObjectTypeCallProperty(node, opts = {}) {
|
||
assert("ObjectTypeCallProperty", node, opts);
|
||
}
|
||
|
||
function assertObjectTypeIndexer(node, opts = {}) {
|
||
assert("ObjectTypeIndexer", node, opts);
|
||
}
|
||
|
||
function assertObjectTypeProperty(node, opts = {}) {
|
||
assert("ObjectTypeProperty", node, opts);
|
||
}
|
||
|
||
function assertObjectTypeSpreadProperty(node, opts = {}) {
|
||
assert("ObjectTypeSpreadProperty", node, opts);
|
||
}
|
||
|
||
function assertOpaqueType(node, opts = {}) {
|
||
assert("OpaqueType", node, opts);
|
||
}
|
||
|
||
function assertQualifiedTypeIdentifier(node, opts = {}) {
|
||
assert("QualifiedTypeIdentifier", node, opts);
|
||
}
|
||
|
||
function assertStringLiteralTypeAnnotation(node, opts = {}) {
|
||
assert("StringLiteralTypeAnnotation", node, opts);
|
||
}
|
||
|
||
function assertStringTypeAnnotation(node, opts = {}) {
|
||
assert("StringTypeAnnotation", node, opts);
|
||
}
|
||
|
||
function assertThisTypeAnnotation(node, opts = {}) {
|
||
assert("ThisTypeAnnotation", node, opts);
|
||
}
|
||
|
||
function assertTupleTypeAnnotation(node, opts = {}) {
|
||
assert("TupleTypeAnnotation", node, opts);
|
||
}
|
||
|
||
function assertTypeofTypeAnnotation(node, opts = {}) {
|
||
assert("TypeofTypeAnnotation", node, opts);
|
||
}
|
||
|
||
function assertTypeAlias(node, opts = {}) {
|
||
assert("TypeAlias", node, opts);
|
||
}
|
||
|
||
function assertTypeAnnotation(node, opts = {}) {
|
||
assert("TypeAnnotation", node, opts);
|
||
}
|
||
|
||
function assertTypeCastExpression(node, opts = {}) {
|
||
assert("TypeCastExpression", node, opts);
|
||
}
|
||
|
||
function assertTypeParameter(node, opts = {}) {
|
||
assert("TypeParameter", node, opts);
|
||
}
|
||
|
||
function assertTypeParameterDeclaration(node, opts = {}) {
|
||
assert("TypeParameterDeclaration", node, opts);
|
||
}
|
||
|
||
function assertTypeParameterInstantiation(node, opts = {}) {
|
||
assert("TypeParameterInstantiation", node, opts);
|
||
}
|
||
|
||
function assertUnionTypeAnnotation(node, opts = {}) {
|
||
assert("UnionTypeAnnotation", node, opts);
|
||
}
|
||
|
||
function assertVariance(node, opts = {}) {
|
||
assert("Variance", node, opts);
|
||
}
|
||
|
||
function assertVoidTypeAnnotation(node, opts = {}) {
|
||
assert("VoidTypeAnnotation", node, opts);
|
||
}
|
||
|
||
function assertJSXAttribute(node, opts = {}) {
|
||
assert("JSXAttribute", node, opts);
|
||
}
|
||
|
||
function assertJSXClosingElement(node, opts = {}) {
|
||
assert("JSXClosingElement", node, opts);
|
||
}
|
||
|
||
function assertJSXElement(node, opts = {}) {
|
||
assert("JSXElement", node, opts);
|
||
}
|
||
|
||
function assertJSXEmptyExpression(node, opts = {}) {
|
||
assert("JSXEmptyExpression", node, opts);
|
||
}
|
||
|
||
function assertJSXExpressionContainer(node, opts = {}) {
|
||
assert("JSXExpressionContainer", node, opts);
|
||
}
|
||
|
||
function assertJSXSpreadChild(node, opts = {}) {
|
||
assert("JSXSpreadChild", node, opts);
|
||
}
|
||
|
||
function assertJSXIdentifier(node, opts = {}) {
|
||
assert("JSXIdentifier", node, opts);
|
||
}
|
||
|
||
function assertJSXMemberExpression(node, opts = {}) {
|
||
assert("JSXMemberExpression", node, opts);
|
||
}
|
||
|
||
function assertJSXNamespacedName(node, opts = {}) {
|
||
assert("JSXNamespacedName", node, opts);
|
||
}
|
||
|
||
function assertJSXOpeningElement(node, opts = {}) {
|
||
assert("JSXOpeningElement", node, opts);
|
||
}
|
||
|
||
function assertJSXSpreadAttribute(node, opts = {}) {
|
||
assert("JSXSpreadAttribute", node, opts);
|
||
}
|
||
|
||
function assertJSXText(node, opts = {}) {
|
||
assert("JSXText", node, opts);
|
||
}
|
||
|
||
function assertJSXFragment(node, opts = {}) {
|
||
assert("JSXFragment", node, opts);
|
||
}
|
||
|
||
function assertJSXOpeningFragment(node, opts = {}) {
|
||
assert("JSXOpeningFragment", node, opts);
|
||
}
|
||
|
||
function assertJSXClosingFragment(node, opts = {}) {
|
||
assert("JSXClosingFragment", node, opts);
|
||
}
|
||
|
||
function assertNoop(node, opts = {}) {
|
||
assert("Noop", node, opts);
|
||
}
|
||
|
||
function assertPlaceholder(node, opts = {}) {
|
||
assert("Placeholder", node, opts);
|
||
}
|
||
|
||
function assertArgumentPlaceholder(node, opts = {}) {
|
||
assert("ArgumentPlaceholder", node, opts);
|
||
}
|
||
|
||
function assertAwaitExpression(node, opts = {}) {
|
||
assert("AwaitExpression", node, opts);
|
||
}
|
||
|
||
function assertBindExpression(node, opts = {}) {
|
||
assert("BindExpression", node, opts);
|
||
}
|
||
|
||
function assertClassProperty(node, opts = {}) {
|
||
assert("ClassProperty", node, opts);
|
||
}
|
||
|
||
function assertOptionalMemberExpression(node, opts = {}) {
|
||
assert("OptionalMemberExpression", node, opts);
|
||
}
|
||
|
||
function assertPipelineTopicExpression(node, opts = {}) {
|
||
assert("PipelineTopicExpression", node, opts);
|
||
}
|
||
|
||
function assertPipelineBareFunction(node, opts = {}) {
|
||
assert("PipelineBareFunction", node, opts);
|
||
}
|
||
|
||
function assertPipelinePrimaryTopicReference(node, opts = {}) {
|
||
assert("PipelinePrimaryTopicReference", node, opts);
|
||
}
|
||
|
||
function assertOptionalCallExpression(node, opts = {}) {
|
||
assert("OptionalCallExpression", node, opts);
|
||
}
|
||
|
||
function assertClassPrivateProperty(node, opts = {}) {
|
||
assert("ClassPrivateProperty", node, opts);
|
||
}
|
||
|
||
function assertClassPrivateMethod(node, opts = {}) {
|
||
assert("ClassPrivateMethod", node, opts);
|
||
}
|
||
|
||
function assertImport(node, opts = {}) {
|
||
assert("Import", node, opts);
|
||
}
|
||
|
||
function assertDecorator(node, opts = {}) {
|
||
assert("Decorator", node, opts);
|
||
}
|
||
|
||
function assertDoExpression(node, opts = {}) {
|
||
assert("DoExpression", node, opts);
|
||
}
|
||
|
||
function assertExportDefaultSpecifier(node, opts = {}) {
|
||
assert("ExportDefaultSpecifier", node, opts);
|
||
}
|
||
|
||
function assertExportNamespaceSpecifier(node, opts = {}) {
|
||
assert("ExportNamespaceSpecifier", node, opts);
|
||
}
|
||
|
||
function assertPrivateName(node, opts = {}) {
|
||
assert("PrivateName", node, opts);
|
||
}
|
||
|
||
function assertBigIntLiteral(node, opts = {}) {
|
||
assert("BigIntLiteral", node, opts);
|
||
}
|
||
|
||
function assertTSParameterProperty(node, opts = {}) {
|
||
assert("TSParameterProperty", node, opts);
|
||
}
|
||
|
||
function assertTSDeclareFunction(node, opts = {}) {
|
||
assert("TSDeclareFunction", node, opts);
|
||
}
|
||
|
||
function assertTSDeclareMethod(node, opts = {}) {
|
||
assert("TSDeclareMethod", node, opts);
|
||
}
|
||
|
||
function assertTSQualifiedName(node, opts = {}) {
|
||
assert("TSQualifiedName", node, opts);
|
||
}
|
||
|
||
function assertTSCallSignatureDeclaration(node, opts = {}) {
|
||
assert("TSCallSignatureDeclaration", node, opts);
|
||
}
|
||
|
||
function assertTSConstructSignatureDeclaration(node, opts = {}) {
|
||
assert("TSConstructSignatureDeclaration", node, opts);
|
||
}
|
||
|
||
function assertTSPropertySignature(node, opts = {}) {
|
||
assert("TSPropertySignature", node, opts);
|
||
}
|
||
|
||
function assertTSMethodSignature(node, opts = {}) {
|
||
assert("TSMethodSignature", node, opts);
|
||
}
|
||
|
||
function assertTSIndexSignature(node, opts = {}) {
|
||
assert("TSIndexSignature", node, opts);
|
||
}
|
||
|
||
function assertTSAnyKeyword(node, opts = {}) {
|
||
assert("TSAnyKeyword", node, opts);
|
||
}
|
||
|
||
function assertTSUnknownKeyword(node, opts = {}) {
|
||
assert("TSUnknownKeyword", node, opts);
|
||
}
|
||
|
||
function assertTSNumberKeyword(node, opts = {}) {
|
||
assert("TSNumberKeyword", node, opts);
|
||
}
|
||
|
||
function assertTSObjectKeyword(node, opts = {}) {
|
||
assert("TSObjectKeyword", node, opts);
|
||
}
|
||
|
||
function assertTSBooleanKeyword(node, opts = {}) {
|
||
assert("TSBooleanKeyword", node, opts);
|
||
}
|
||
|
||
function assertTSStringKeyword(node, opts = {}) {
|
||
assert("TSStringKeyword", node, opts);
|
||
}
|
||
|
||
function assertTSSymbolKeyword(node, opts = {}) {
|
||
assert("TSSymbolKeyword", node, opts);
|
||
}
|
||
|
||
function assertTSVoidKeyword(node, opts = {}) {
|
||
assert("TSVoidKeyword", node, opts);
|
||
}
|
||
|
||
function assertTSUndefinedKeyword(node, opts = {}) {
|
||
assert("TSUndefinedKeyword", node, opts);
|
||
}
|
||
|
||
function assertTSNullKeyword(node, opts = {}) {
|
||
assert("TSNullKeyword", node, opts);
|
||
}
|
||
|
||
function assertTSNeverKeyword(node, opts = {}) {
|
||
assert("TSNeverKeyword", node, opts);
|
||
}
|
||
|
||
function assertTSThisType(node, opts = {}) {
|
||
assert("TSThisType", node, opts);
|
||
}
|
||
|
||
function assertTSFunctionType(node, opts = {}) {
|
||
assert("TSFunctionType", node, opts);
|
||
}
|
||
|
||
function assertTSConstructorType(node, opts = {}) {
|
||
assert("TSConstructorType", node, opts);
|
||
}
|
||
|
||
function assertTSTypeReference(node, opts = {}) {
|
||
assert("TSTypeReference", node, opts);
|
||
}
|
||
|
||
function assertTSTypePredicate(node, opts = {}) {
|
||
assert("TSTypePredicate", node, opts);
|
||
}
|
||
|
||
function assertTSTypeQuery(node, opts = {}) {
|
||
assert("TSTypeQuery", node, opts);
|
||
}
|
||
|
||
function assertTSTypeLiteral(node, opts = {}) {
|
||
assert("TSTypeLiteral", node, opts);
|
||
}
|
||
|
||
function assertTSArrayType(node, opts = {}) {
|
||
assert("TSArrayType", node, opts);
|
||
}
|
||
|
||
function assertTSTupleType(node, opts = {}) {
|
||
assert("TSTupleType", node, opts);
|
||
}
|
||
|
||
function assertTSOptionalType(node, opts = {}) {
|
||
assert("TSOptionalType", node, opts);
|
||
}
|
||
|
||
function assertTSRestType(node, opts = {}) {
|
||
assert("TSRestType", node, opts);
|
||
}
|
||
|
||
function assertTSUnionType(node, opts = {}) {
|
||
assert("TSUnionType", node, opts);
|
||
}
|
||
|
||
function assertTSIntersectionType(node, opts = {}) {
|
||
assert("TSIntersectionType", node, opts);
|
||
}
|
||
|
||
function assertTSConditionalType(node, opts = {}) {
|
||
assert("TSConditionalType", node, opts);
|
||
}
|
||
|
||
function assertTSInferType(node, opts = {}) {
|
||
assert("TSInferType", node, opts);
|
||
}
|
||
|
||
function assertTSParenthesizedType(node, opts = {}) {
|
||
assert("TSParenthesizedType", node, opts);
|
||
}
|
||
|
||
function assertTSTypeOperator(node, opts = {}) {
|
||
assert("TSTypeOperator", node, opts);
|
||
}
|
||
|
||
function assertTSIndexedAccessType(node, opts = {}) {
|
||
assert("TSIndexedAccessType", node, opts);
|
||
}
|
||
|
||
function assertTSMappedType(node, opts = {}) {
|
||
assert("TSMappedType", node, opts);
|
||
}
|
||
|
||
function assertTSLiteralType(node, opts = {}) {
|
||
assert("TSLiteralType", node, opts);
|
||
}
|
||
|
||
function assertTSExpressionWithTypeArguments(node, opts = {}) {
|
||
assert("TSExpressionWithTypeArguments", node, opts);
|
||
}
|
||
|
||
function assertTSInterfaceDeclaration(node, opts = {}) {
|
||
assert("TSInterfaceDeclaration", node, opts);
|
||
}
|
||
|
||
function assertTSInterfaceBody(node, opts = {}) {
|
||
assert("TSInterfaceBody", node, opts);
|
||
}
|
||
|
||
function assertTSTypeAliasDeclaration(node, opts = {}) {
|
||
assert("TSTypeAliasDeclaration", node, opts);
|
||
}
|
||
|
||
function assertTSAsExpression(node, opts = {}) {
|
||
assert("TSAsExpression", node, opts);
|
||
}
|
||
|
||
function assertTSTypeAssertion(node, opts = {}) {
|
||
assert("TSTypeAssertion", node, opts);
|
||
}
|
||
|
||
function assertTSEnumDeclaration(node, opts = {}) {
|
||
assert("TSEnumDeclaration", node, opts);
|
||
}
|
||
|
||
function assertTSEnumMember(node, opts = {}) {
|
||
assert("TSEnumMember", node, opts);
|
||
}
|
||
|
||
function assertTSModuleDeclaration(node, opts = {}) {
|
||
assert("TSModuleDeclaration", node, opts);
|
||
}
|
||
|
||
function assertTSModuleBlock(node, opts = {}) {
|
||
assert("TSModuleBlock", node, opts);
|
||
}
|
||
|
||
function assertTSImportType(node, opts = {}) {
|
||
assert("TSImportType", node, opts);
|
||
}
|
||
|
||
function assertTSImportEqualsDeclaration(node, opts = {}) {
|
||
assert("TSImportEqualsDeclaration", node, opts);
|
||
}
|
||
|
||
function assertTSExternalModuleReference(node, opts = {}) {
|
||
assert("TSExternalModuleReference", node, opts);
|
||
}
|
||
|
||
function assertTSNonNullExpression(node, opts = {}) {
|
||
assert("TSNonNullExpression", node, opts);
|
||
}
|
||
|
||
function assertTSExportAssignment(node, opts = {}) {
|
||
assert("TSExportAssignment", node, opts);
|
||
}
|
||
|
||
function assertTSNamespaceExportDeclaration(node, opts = {}) {
|
||
assert("TSNamespaceExportDeclaration", node, opts);
|
||
}
|
||
|
||
function assertTSTypeAnnotation(node, opts = {}) {
|
||
assert("TSTypeAnnotation", node, opts);
|
||
}
|
||
|
||
function assertTSTypeParameterInstantiation(node, opts = {}) {
|
||
assert("TSTypeParameterInstantiation", node, opts);
|
||
}
|
||
|
||
function assertTSTypeParameterDeclaration(node, opts = {}) {
|
||
assert("TSTypeParameterDeclaration", node, opts);
|
||
}
|
||
|
||
function assertTSTypeParameter(node, opts = {}) {
|
||
assert("TSTypeParameter", node, opts);
|
||
}
|
||
|
||
function assertExpression(node, opts = {}) {
|
||
assert("Expression", node, opts);
|
||
}
|
||
|
||
function assertBinary(node, opts = {}) {
|
||
assert("Binary", node, opts);
|
||
}
|
||
|
||
function assertScopable(node, opts = {}) {
|
||
assert("Scopable", node, opts);
|
||
}
|
||
|
||
function assertBlockParent(node, opts = {}) {
|
||
assert("BlockParent", node, opts);
|
||
}
|
||
|
||
function assertBlock(node, opts = {}) {
|
||
assert("Block", node, opts);
|
||
}
|
||
|
||
function assertStatement(node, opts = {}) {
|
||
assert("Statement", node, opts);
|
||
}
|
||
|
||
function assertTerminatorless(node, opts = {}) {
|
||
assert("Terminatorless", node, opts);
|
||
}
|
||
|
||
function assertCompletionStatement(node, opts = {}) {
|
||
assert("CompletionStatement", node, opts);
|
||
}
|
||
|
||
function assertConditional(node, opts = {}) {
|
||
assert("Conditional", node, opts);
|
||
}
|
||
|
||
function assertLoop(node, opts = {}) {
|
||
assert("Loop", node, opts);
|
||
}
|
||
|
||
function assertWhile(node, opts = {}) {
|
||
assert("While", node, opts);
|
||
}
|
||
|
||
function assertExpressionWrapper(node, opts = {}) {
|
||
assert("ExpressionWrapper", node, opts);
|
||
}
|
||
|
||
function assertFor(node, opts = {}) {
|
||
assert("For", node, opts);
|
||
}
|
||
|
||
function assertForXStatement(node, opts = {}) {
|
||
assert("ForXStatement", node, opts);
|
||
}
|
||
|
||
function assertFunction(node, opts = {}) {
|
||
assert("Function", node, opts);
|
||
}
|
||
|
||
function assertFunctionParent(node, opts = {}) {
|
||
assert("FunctionParent", node, opts);
|
||
}
|
||
|
||
function assertPureish(node, opts = {}) {
|
||
assert("Pureish", node, opts);
|
||
}
|
||
|
||
function assertDeclaration(node, opts = {}) {
|
||
assert("Declaration", node, opts);
|
||
}
|
||
|
||
function assertPatternLike(node, opts = {}) {
|
||
assert("PatternLike", node, opts);
|
||
}
|
||
|
||
function assertLVal(node, opts = {}) {
|
||
assert("LVal", node, opts);
|
||
}
|
||
|
||
function assertTSEntityName(node, opts = {}) {
|
||
assert("TSEntityName", node, opts);
|
||
}
|
||
|
||
function assertLiteral(node, opts = {}) {
|
||
assert("Literal", node, opts);
|
||
}
|
||
|
||
function assertImmutable(node, opts = {}) {
|
||
assert("Immutable", node, opts);
|
||
}
|
||
|
||
function assertUserWhitespacable(node, opts = {}) {
|
||
assert("UserWhitespacable", node, opts);
|
||
}
|
||
|
||
function assertMethod(node, opts = {}) {
|
||
assert("Method", node, opts);
|
||
}
|
||
|
||
function assertObjectMember(node, opts = {}) {
|
||
assert("ObjectMember", node, opts);
|
||
}
|
||
|
||
function assertProperty(node, opts = {}) {
|
||
assert("Property", node, opts);
|
||
}
|
||
|
||
function assertUnaryLike(node, opts = {}) {
|
||
assert("UnaryLike", node, opts);
|
||
}
|
||
|
||
function assertPattern(node, opts = {}) {
|
||
assert("Pattern", node, opts);
|
||
}
|
||
|
||
function assertClass(node, opts = {}) {
|
||
assert("Class", node, opts);
|
||
}
|
||
|
||
function assertModuleDeclaration(node, opts = {}) {
|
||
assert("ModuleDeclaration", node, opts);
|
||
}
|
||
|
||
function assertExportDeclaration(node, opts = {}) {
|
||
assert("ExportDeclaration", node, opts);
|
||
}
|
||
|
||
function assertModuleSpecifier(node, opts = {}) {
|
||
assert("ModuleSpecifier", node, opts);
|
||
}
|
||
|
||
function assertFlow(node, opts = {}) {
|
||
assert("Flow", node, opts);
|
||
}
|
||
|
||
function assertFlowType(node, opts = {}) {
|
||
assert("FlowType", node, opts);
|
||
}
|
||
|
||
function assertFlowBaseAnnotation(node, opts = {}) {
|
||
assert("FlowBaseAnnotation", node, opts);
|
||
}
|
||
|
||
function assertFlowDeclaration(node, opts = {}) {
|
||
assert("FlowDeclaration", node, opts);
|
||
}
|
||
|
||
function assertFlowPredicate(node, opts = {}) {
|
||
assert("FlowPredicate", node, opts);
|
||
}
|
||
|
||
function assertJSX(node, opts = {}) {
|
||
assert("JSX", node, opts);
|
||
}
|
||
|
||
function assertPrivate(node, opts = {}) {
|
||
assert("Private", node, opts);
|
||
}
|
||
|
||
function assertTSTypeElement(node, opts = {}) {
|
||
assert("TSTypeElement", node, opts);
|
||
}
|
||
|
||
function assertTSType(node, opts = {}) {
|
||
assert("TSType", node, opts);
|
||
}
|
||
|
||
function assertNumberLiteral(node, opts) {
|
||
console.trace("The node type NumberLiteral has been renamed to NumericLiteral");
|
||
assert("NumberLiteral", node, opts);
|
||
}
|
||
|
||
function assertRegexLiteral(node, opts) {
|
||
console.trace("The node type RegexLiteral has been renamed to RegExpLiteral");
|
||
assert("RegexLiteral", node, opts);
|
||
}
|
||
|
||
function assertRestProperty(node, opts) {
|
||
console.trace("The node type RestProperty has been renamed to RestElement");
|
||
assert("RestProperty", node, opts);
|
||
}
|
||
|
||
function assertSpreadProperty(node, opts) {
|
||
console.trace("The node type SpreadProperty has been renamed to SpreadElement");
|
||
assert("SpreadProperty", node, opts);
|
||
}
|
||
|
||
/***/ }),
|
||
/* 276 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = createTypeAnnotationBasedOnTypeof;
|
||
|
||
var _generated = __webpack_require__(10);
|
||
|
||
function createTypeAnnotationBasedOnTypeof(type) {
|
||
if (type === "string") {
|
||
return (0, _generated.stringTypeAnnotation)();
|
||
} else if (type === "number") {
|
||
return (0, _generated.numberTypeAnnotation)();
|
||
} else if (type === "undefined") {
|
||
return (0, _generated.voidTypeAnnotation)();
|
||
} else if (type === "boolean") {
|
||
return (0, _generated.booleanTypeAnnotation)();
|
||
} else if (type === "function") {
|
||
return (0, _generated.genericTypeAnnotation)((0, _generated.identifier)("Function"));
|
||
} else if (type === "object") {
|
||
return (0, _generated.genericTypeAnnotation)((0, _generated.identifier)("Object"));
|
||
} else if (type === "symbol") {
|
||
return (0, _generated.genericTypeAnnotation)((0, _generated.identifier)("Symbol"));
|
||
} else {
|
||
throw new Error("Invalid typeof value");
|
||
}
|
||
}
|
||
|
||
/***/ }),
|
||
/* 277 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = createUnionTypeAnnotation;
|
||
|
||
var _generated = __webpack_require__(10);
|
||
|
||
var _removeTypeDuplicates = _interopRequireDefault(__webpack_require__(138));
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function createUnionTypeAnnotation(types) {
|
||
const flattened = (0, _removeTypeDuplicates.default)(types);
|
||
|
||
if (flattened.length === 1) {
|
||
return flattened[0];
|
||
} else {
|
||
return (0, _generated.unionTypeAnnotation)(flattened);
|
||
}
|
||
}
|
||
|
||
/***/ }),
|
||
/* 278 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = cloneDeep;
|
||
|
||
var _cloneNode = _interopRequireDefault(__webpack_require__(31));
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function cloneDeep(node) {
|
||
return (0, _cloneNode.default)(node);
|
||
}
|
||
|
||
/***/ }),
|
||
/* 279 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = cloneWithoutLoc;
|
||
|
||
var _clone = _interopRequireDefault(__webpack_require__(139));
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function cloneWithoutLoc(node) {
|
||
const newNode = (0, _clone.default)(node);
|
||
newNode.loc = null;
|
||
return newNode;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 280 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = addComment;
|
||
|
||
var _addComments = _interopRequireDefault(__webpack_require__(140));
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function addComment(node, type, content, line) {
|
||
return (0, _addComments.default)(node, type, [{
|
||
type: line ? "CommentLine" : "CommentBlock",
|
||
value: content
|
||
}]);
|
||
}
|
||
|
||
/***/ }),
|
||
/* 281 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var baseUniq = __webpack_require__(282);
|
||
|
||
/**
|
||
* Creates a duplicate-free version of an array, using
|
||
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
||
* for equality comparisons, in which only the first occurrence of each element
|
||
* is kept. The order of result values is determined by the order they occur
|
||
* in the array.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 0.1.0
|
||
* @category Array
|
||
* @param {Array} array The array to inspect.
|
||
* @returns {Array} Returns the new duplicate free array.
|
||
* @example
|
||
*
|
||
* _.uniq([2, 1, 2]);
|
||
* // => [2, 1]
|
||
*/
|
||
function uniq(array) {
|
||
return (array && array.length) ? baseUniq(array) : [];
|
||
}
|
||
|
||
module.exports = uniq;
|
||
|
||
|
||
/***/ }),
|
||
/* 282 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var SetCache = __webpack_require__(142),
|
||
arrayIncludes = __webpack_require__(285),
|
||
arrayIncludesWith = __webpack_require__(289),
|
||
cacheHas = __webpack_require__(143),
|
||
createSet = __webpack_require__(290),
|
||
setToArray = __webpack_require__(87);
|
||
|
||
/** Used as the size to enable large array optimizations. */
|
||
var LARGE_ARRAY_SIZE = 200;
|
||
|
||
/**
|
||
* The base implementation of `_.uniqBy` without support for iteratee shorthands.
|
||
*
|
||
* @private
|
||
* @param {Array} array The array to inspect.
|
||
* @param {Function} [iteratee] The iteratee invoked per element.
|
||
* @param {Function} [comparator] The comparator invoked per element.
|
||
* @returns {Array} Returns the new duplicate free array.
|
||
*/
|
||
function baseUniq(array, iteratee, comparator) {
|
||
var index = -1,
|
||
includes = arrayIncludes,
|
||
length = array.length,
|
||
isCommon = true,
|
||
result = [],
|
||
seen = result;
|
||
|
||
if (comparator) {
|
||
isCommon = false;
|
||
includes = arrayIncludesWith;
|
||
}
|
||
else if (length >= LARGE_ARRAY_SIZE) {
|
||
var set = iteratee ? null : createSet(array);
|
||
if (set) {
|
||
return setToArray(set);
|
||
}
|
||
isCommon = false;
|
||
includes = cacheHas;
|
||
seen = new SetCache;
|
||
}
|
||
else {
|
||
seen = iteratee ? [] : result;
|
||
}
|
||
outer:
|
||
while (++index < length) {
|
||
var value = array[index],
|
||
computed = iteratee ? iteratee(value) : value;
|
||
|
||
value = (comparator || value !== 0) ? value : 0;
|
||
if (isCommon && computed === computed) {
|
||
var seenIndex = seen.length;
|
||
while (seenIndex--) {
|
||
if (seen[seenIndex] === computed) {
|
||
continue outer;
|
||
}
|
||
}
|
||
if (iteratee) {
|
||
seen.push(computed);
|
||
}
|
||
result.push(value);
|
||
}
|
||
else if (!includes(seen, computed, comparator)) {
|
||
if (seen !== result) {
|
||
seen.push(computed);
|
||
}
|
||
result.push(value);
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
|
||
module.exports = baseUniq;
|
||
|
||
|
||
/***/ }),
|
||
/* 283 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/** Used to stand-in for `undefined` hash values. */
|
||
var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
||
|
||
/**
|
||
* Adds `value` to the array cache.
|
||
*
|
||
* @private
|
||
* @name add
|
||
* @memberOf SetCache
|
||
* @alias push
|
||
* @param {*} value The value to cache.
|
||
* @returns {Object} Returns the cache instance.
|
||
*/
|
||
function setCacheAdd(value) {
|
||
this.__data__.set(value, HASH_UNDEFINED);
|
||
return this;
|
||
}
|
||
|
||
module.exports = setCacheAdd;
|
||
|
||
|
||
/***/ }),
|
||
/* 284 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* Checks if `value` is in the array cache.
|
||
*
|
||
* @private
|
||
* @name has
|
||
* @memberOf SetCache
|
||
* @param {*} value The value to search for.
|
||
* @returns {number} Returns `true` if `value` is found, else `false`.
|
||
*/
|
||
function setCacheHas(value) {
|
||
return this.__data__.has(value);
|
||
}
|
||
|
||
module.exports = setCacheHas;
|
||
|
||
|
||
/***/ }),
|
||
/* 285 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var baseIndexOf = __webpack_require__(286);
|
||
|
||
/**
|
||
* A specialized version of `_.includes` for arrays without support for
|
||
* specifying an index to search from.
|
||
*
|
||
* @private
|
||
* @param {Array} [array] The array to inspect.
|
||
* @param {*} target The value to search for.
|
||
* @returns {boolean} Returns `true` if `target` is found, else `false`.
|
||
*/
|
||
function arrayIncludes(array, value) {
|
||
var length = array == null ? 0 : array.length;
|
||
return !!length && baseIndexOf(array, value, 0) > -1;
|
||
}
|
||
|
||
module.exports = arrayIncludes;
|
||
|
||
|
||
/***/ }),
|
||
/* 286 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var baseFindIndex = __webpack_require__(86),
|
||
baseIsNaN = __webpack_require__(287),
|
||
strictIndexOf = __webpack_require__(288);
|
||
|
||
/**
|
||
* The base implementation of `_.indexOf` without `fromIndex` bounds checks.
|
||
*
|
||
* @private
|
||
* @param {Array} array The array to inspect.
|
||
* @param {*} value The value to search for.
|
||
* @param {number} fromIndex The index to search from.
|
||
* @returns {number} Returns the index of the matched value, else `-1`.
|
||
*/
|
||
function baseIndexOf(array, value, fromIndex) {
|
||
return value === value
|
||
? strictIndexOf(array, value, fromIndex)
|
||
: baseFindIndex(array, baseIsNaN, fromIndex);
|
||
}
|
||
|
||
module.exports = baseIndexOf;
|
||
|
||
|
||
/***/ }),
|
||
/* 287 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* The base implementation of `_.isNaN` without support for number objects.
|
||
*
|
||
* @private
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
|
||
*/
|
||
function baseIsNaN(value) {
|
||
return value !== value;
|
||
}
|
||
|
||
module.exports = baseIsNaN;
|
||
|
||
|
||
/***/ }),
|
||
/* 288 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* A specialized version of `_.indexOf` which performs strict equality
|
||
* comparisons of values, i.e. `===`.
|
||
*
|
||
* @private
|
||
* @param {Array} array The array to inspect.
|
||
* @param {*} value The value to search for.
|
||
* @param {number} fromIndex The index to search from.
|
||
* @returns {number} Returns the index of the matched value, else `-1`.
|
||
*/
|
||
function strictIndexOf(array, value, fromIndex) {
|
||
var index = fromIndex - 1,
|
||
length = array.length;
|
||
|
||
while (++index < length) {
|
||
if (array[index] === value) {
|
||
return index;
|
||
}
|
||
}
|
||
return -1;
|
||
}
|
||
|
||
module.exports = strictIndexOf;
|
||
|
||
|
||
/***/ }),
|
||
/* 289 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* This function is like `arrayIncludes` except that it accepts a comparator.
|
||
*
|
||
* @private
|
||
* @param {Array} [array] The array to inspect.
|
||
* @param {*} target The value to search for.
|
||
* @param {Function} comparator The comparator invoked per element.
|
||
* @returns {boolean} Returns `true` if `target` is found, else `false`.
|
||
*/
|
||
function arrayIncludesWith(array, value, comparator) {
|
||
var index = -1,
|
||
length = array == null ? 0 : array.length;
|
||
|
||
while (++index < length) {
|
||
if (comparator(value, array[index])) {
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
module.exports = arrayIncludesWith;
|
||
|
||
|
||
/***/ }),
|
||
/* 290 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var Set = __webpack_require__(133),
|
||
noop = __webpack_require__(291),
|
||
setToArray = __webpack_require__(87);
|
||
|
||
/** Used as references for various `Number` constants. */
|
||
var INFINITY = 1 / 0;
|
||
|
||
/**
|
||
* Creates a set object of `values`.
|
||
*
|
||
* @private
|
||
* @param {Array} values The values to add to the set.
|
||
* @returns {Object} Returns the new set.
|
||
*/
|
||
var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
|
||
return new Set(values);
|
||
};
|
||
|
||
module.exports = createSet;
|
||
|
||
|
||
/***/ }),
|
||
/* 291 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* This method returns `undefined`.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 2.3.0
|
||
* @category Util
|
||
* @example
|
||
*
|
||
* _.times(2, _.noop);
|
||
* // => [undefined, undefined]
|
||
*/
|
||
function noop() {
|
||
// No operation performed.
|
||
}
|
||
|
||
module.exports = noop;
|
||
|
||
|
||
/***/ }),
|
||
/* 292 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = removeComments;
|
||
|
||
var _constants = __webpack_require__(27);
|
||
|
||
function removeComments(node) {
|
||
_constants.COMMENT_KEYS.forEach(key => {
|
||
node[key] = null;
|
||
});
|
||
|
||
return node;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 293 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.TSTYPE_TYPES = exports.TSTYPEELEMENT_TYPES = exports.PRIVATE_TYPES = exports.JSX_TYPES = exports.FLOWPREDICATE_TYPES = exports.FLOWDECLARATION_TYPES = exports.FLOWBASEANNOTATION_TYPES = exports.FLOWTYPE_TYPES = exports.FLOW_TYPES = exports.MODULESPECIFIER_TYPES = exports.EXPORTDECLARATION_TYPES = exports.MODULEDECLARATION_TYPES = exports.CLASS_TYPES = exports.PATTERN_TYPES = exports.UNARYLIKE_TYPES = exports.PROPERTY_TYPES = exports.OBJECTMEMBER_TYPES = exports.METHOD_TYPES = exports.USERWHITESPACABLE_TYPES = exports.IMMUTABLE_TYPES = exports.LITERAL_TYPES = exports.TSENTITYNAME_TYPES = exports.LVAL_TYPES = exports.PATTERNLIKE_TYPES = exports.DECLARATION_TYPES = exports.PUREISH_TYPES = exports.FUNCTIONPARENT_TYPES = exports.FUNCTION_TYPES = exports.FORXSTATEMENT_TYPES = exports.FOR_TYPES = exports.EXPRESSIONWRAPPER_TYPES = exports.WHILE_TYPES = exports.LOOP_TYPES = exports.CONDITIONAL_TYPES = exports.COMPLETIONSTATEMENT_TYPES = exports.TERMINATORLESS_TYPES = exports.STATEMENT_TYPES = exports.BLOCK_TYPES = exports.BLOCKPARENT_TYPES = exports.SCOPABLE_TYPES = exports.BINARY_TYPES = exports.EXPRESSION_TYPES = void 0;
|
||
|
||
var _definitions = __webpack_require__(16);
|
||
|
||
const EXPRESSION_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Expression"];
|
||
exports.EXPRESSION_TYPES = EXPRESSION_TYPES;
|
||
const BINARY_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Binary"];
|
||
exports.BINARY_TYPES = BINARY_TYPES;
|
||
const SCOPABLE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Scopable"];
|
||
exports.SCOPABLE_TYPES = SCOPABLE_TYPES;
|
||
const BLOCKPARENT_TYPES = _definitions.FLIPPED_ALIAS_KEYS["BlockParent"];
|
||
exports.BLOCKPARENT_TYPES = BLOCKPARENT_TYPES;
|
||
const BLOCK_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Block"];
|
||
exports.BLOCK_TYPES = BLOCK_TYPES;
|
||
const STATEMENT_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Statement"];
|
||
exports.STATEMENT_TYPES = STATEMENT_TYPES;
|
||
const TERMINATORLESS_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Terminatorless"];
|
||
exports.TERMINATORLESS_TYPES = TERMINATORLESS_TYPES;
|
||
const COMPLETIONSTATEMENT_TYPES = _definitions.FLIPPED_ALIAS_KEYS["CompletionStatement"];
|
||
exports.COMPLETIONSTATEMENT_TYPES = COMPLETIONSTATEMENT_TYPES;
|
||
const CONDITIONAL_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Conditional"];
|
||
exports.CONDITIONAL_TYPES = CONDITIONAL_TYPES;
|
||
const LOOP_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Loop"];
|
||
exports.LOOP_TYPES = LOOP_TYPES;
|
||
const WHILE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["While"];
|
||
exports.WHILE_TYPES = WHILE_TYPES;
|
||
const EXPRESSIONWRAPPER_TYPES = _definitions.FLIPPED_ALIAS_KEYS["ExpressionWrapper"];
|
||
exports.EXPRESSIONWRAPPER_TYPES = EXPRESSIONWRAPPER_TYPES;
|
||
const FOR_TYPES = _definitions.FLIPPED_ALIAS_KEYS["For"];
|
||
exports.FOR_TYPES = FOR_TYPES;
|
||
const FORXSTATEMENT_TYPES = _definitions.FLIPPED_ALIAS_KEYS["ForXStatement"];
|
||
exports.FORXSTATEMENT_TYPES = FORXSTATEMENT_TYPES;
|
||
const FUNCTION_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Function"];
|
||
exports.FUNCTION_TYPES = FUNCTION_TYPES;
|
||
const FUNCTIONPARENT_TYPES = _definitions.FLIPPED_ALIAS_KEYS["FunctionParent"];
|
||
exports.FUNCTIONPARENT_TYPES = FUNCTIONPARENT_TYPES;
|
||
const PUREISH_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Pureish"];
|
||
exports.PUREISH_TYPES = PUREISH_TYPES;
|
||
const DECLARATION_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Declaration"];
|
||
exports.DECLARATION_TYPES = DECLARATION_TYPES;
|
||
const PATTERNLIKE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["PatternLike"];
|
||
exports.PATTERNLIKE_TYPES = PATTERNLIKE_TYPES;
|
||
const LVAL_TYPES = _definitions.FLIPPED_ALIAS_KEYS["LVal"];
|
||
exports.LVAL_TYPES = LVAL_TYPES;
|
||
const TSENTITYNAME_TYPES = _definitions.FLIPPED_ALIAS_KEYS["TSEntityName"];
|
||
exports.TSENTITYNAME_TYPES = TSENTITYNAME_TYPES;
|
||
const LITERAL_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Literal"];
|
||
exports.LITERAL_TYPES = LITERAL_TYPES;
|
||
const IMMUTABLE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Immutable"];
|
||
exports.IMMUTABLE_TYPES = IMMUTABLE_TYPES;
|
||
const USERWHITESPACABLE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["UserWhitespacable"];
|
||
exports.USERWHITESPACABLE_TYPES = USERWHITESPACABLE_TYPES;
|
||
const METHOD_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Method"];
|
||
exports.METHOD_TYPES = METHOD_TYPES;
|
||
const OBJECTMEMBER_TYPES = _definitions.FLIPPED_ALIAS_KEYS["ObjectMember"];
|
||
exports.OBJECTMEMBER_TYPES = OBJECTMEMBER_TYPES;
|
||
const PROPERTY_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Property"];
|
||
exports.PROPERTY_TYPES = PROPERTY_TYPES;
|
||
const UNARYLIKE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["UnaryLike"];
|
||
exports.UNARYLIKE_TYPES = UNARYLIKE_TYPES;
|
||
const PATTERN_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Pattern"];
|
||
exports.PATTERN_TYPES = PATTERN_TYPES;
|
||
const CLASS_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Class"];
|
||
exports.CLASS_TYPES = CLASS_TYPES;
|
||
const MODULEDECLARATION_TYPES = _definitions.FLIPPED_ALIAS_KEYS["ModuleDeclaration"];
|
||
exports.MODULEDECLARATION_TYPES = MODULEDECLARATION_TYPES;
|
||
const EXPORTDECLARATION_TYPES = _definitions.FLIPPED_ALIAS_KEYS["ExportDeclaration"];
|
||
exports.EXPORTDECLARATION_TYPES = EXPORTDECLARATION_TYPES;
|
||
const MODULESPECIFIER_TYPES = _definitions.FLIPPED_ALIAS_KEYS["ModuleSpecifier"];
|
||
exports.MODULESPECIFIER_TYPES = MODULESPECIFIER_TYPES;
|
||
const FLOW_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Flow"];
|
||
exports.FLOW_TYPES = FLOW_TYPES;
|
||
const FLOWTYPE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["FlowType"];
|
||
exports.FLOWTYPE_TYPES = FLOWTYPE_TYPES;
|
||
const FLOWBASEANNOTATION_TYPES = _definitions.FLIPPED_ALIAS_KEYS["FlowBaseAnnotation"];
|
||
exports.FLOWBASEANNOTATION_TYPES = FLOWBASEANNOTATION_TYPES;
|
||
const FLOWDECLARATION_TYPES = _definitions.FLIPPED_ALIAS_KEYS["FlowDeclaration"];
|
||
exports.FLOWDECLARATION_TYPES = FLOWDECLARATION_TYPES;
|
||
const FLOWPREDICATE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["FlowPredicate"];
|
||
exports.FLOWPREDICATE_TYPES = FLOWPREDICATE_TYPES;
|
||
const JSX_TYPES = _definitions.FLIPPED_ALIAS_KEYS["JSX"];
|
||
exports.JSX_TYPES = JSX_TYPES;
|
||
const PRIVATE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Private"];
|
||
exports.PRIVATE_TYPES = PRIVATE_TYPES;
|
||
const TSTYPEELEMENT_TYPES = _definitions.FLIPPED_ALIAS_KEYS["TSTypeElement"];
|
||
exports.TSTYPEELEMENT_TYPES = TSTYPEELEMENT_TYPES;
|
||
const TSTYPE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["TSType"];
|
||
exports.TSTYPE_TYPES = TSTYPE_TYPES;
|
||
|
||
/***/ }),
|
||
/* 294 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = ensureBlock;
|
||
|
||
var _toBlock = _interopRequireDefault(__webpack_require__(147));
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function ensureBlock(node, key = "body") {
|
||
return node[key] = (0, _toBlock.default)(node[key], node);
|
||
}
|
||
|
||
/***/ }),
|
||
/* 295 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = toBindingIdentifierName;
|
||
|
||
var _toIdentifier = _interopRequireDefault(__webpack_require__(148));
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function toBindingIdentifierName(name) {
|
||
name = (0, _toIdentifier.default)(name);
|
||
if (name === "eval" || name === "arguments") name = "_" + name;
|
||
return name;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 296 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = toComputedKey;
|
||
|
||
var _generated = __webpack_require__(5);
|
||
|
||
var _generated2 = __webpack_require__(10);
|
||
|
||
function toComputedKey(node, key = node.key || node.property) {
|
||
if (!node.computed && (0, _generated.isIdentifier)(key)) key = (0, _generated2.stringLiteral)(key.name);
|
||
return key;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 297 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = toExpression;
|
||
|
||
var _generated = __webpack_require__(5);
|
||
|
||
function toExpression(node) {
|
||
if ((0, _generated.isExpressionStatement)(node)) {
|
||
node = node.expression;
|
||
}
|
||
|
||
if ((0, _generated.isExpression)(node)) {
|
||
return node;
|
||
}
|
||
|
||
if ((0, _generated.isClass)(node)) {
|
||
node.type = "ClassExpression";
|
||
} else if ((0, _generated.isFunction)(node)) {
|
||
node.type = "FunctionExpression";
|
||
}
|
||
|
||
if (!(0, _generated.isExpression)(node)) {
|
||
throw new Error(`cannot turn ${node.type} to an expression`);
|
||
}
|
||
|
||
return node;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 298 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = toKeyAlias;
|
||
|
||
var _generated = __webpack_require__(5);
|
||
|
||
var _cloneNode = _interopRequireDefault(__webpack_require__(31));
|
||
|
||
var _removePropertiesDeep = _interopRequireDefault(__webpack_require__(149));
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function toKeyAlias(node, key = node.key) {
|
||
let alias;
|
||
|
||
if (node.kind === "method") {
|
||
return toKeyAlias.increment() + "";
|
||
} else if ((0, _generated.isIdentifier)(key)) {
|
||
alias = key.name;
|
||
} else if ((0, _generated.isStringLiteral)(key)) {
|
||
alias = JSON.stringify(key.value);
|
||
} else {
|
||
alias = JSON.stringify((0, _removePropertiesDeep.default)((0, _cloneNode.default)(key)));
|
||
}
|
||
|
||
if (node.computed) {
|
||
alias = `[${alias}]`;
|
||
}
|
||
|
||
if (node.static) {
|
||
alias = `static:${alias}`;
|
||
}
|
||
|
||
return alias;
|
||
}
|
||
|
||
toKeyAlias.uid = 0;
|
||
|
||
toKeyAlias.increment = function () {
|
||
if (toKeyAlias.uid >= Number.MAX_SAFE_INTEGER) {
|
||
return toKeyAlias.uid = 0;
|
||
} else {
|
||
return toKeyAlias.uid++;
|
||
}
|
||
};
|
||
|
||
/***/ }),
|
||
/* 299 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = toSequenceExpression;
|
||
|
||
var _gatherSequenceExpressions = _interopRequireDefault(__webpack_require__(300));
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function toSequenceExpression(nodes, scope) {
|
||
if (!nodes || !nodes.length) return;
|
||
const declars = [];
|
||
const result = (0, _gatherSequenceExpressions.default)(nodes, scope, declars);
|
||
if (!result) return;
|
||
|
||
for (const declar of declars) {
|
||
scope.push(declar);
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 300 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = gatherSequenceExpressions;
|
||
|
||
var _getBindingIdentifiers = _interopRequireDefault(__webpack_require__(53));
|
||
|
||
var _generated = __webpack_require__(5);
|
||
|
||
var _generated2 = __webpack_require__(10);
|
||
|
||
var _cloneNode = _interopRequireDefault(__webpack_require__(31));
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function gatherSequenceExpressions(nodes, scope, declars) {
|
||
const exprs = [];
|
||
let ensureLastUndefined = true;
|
||
|
||
for (const node of nodes) {
|
||
ensureLastUndefined = false;
|
||
|
||
if ((0, _generated.isExpression)(node)) {
|
||
exprs.push(node);
|
||
} else if ((0, _generated.isExpressionStatement)(node)) {
|
||
exprs.push(node.expression);
|
||
} else if ((0, _generated.isVariableDeclaration)(node)) {
|
||
if (node.kind !== "var") return;
|
||
|
||
for (const declar of node.declarations) {
|
||
const bindings = (0, _getBindingIdentifiers.default)(declar);
|
||
|
||
for (const key of Object.keys(bindings)) {
|
||
declars.push({
|
||
kind: node.kind,
|
||
id: (0, _cloneNode.default)(bindings[key])
|
||
});
|
||
}
|
||
|
||
if (declar.init) {
|
||
exprs.push((0, _generated2.assignmentExpression)("=", declar.id, declar.init));
|
||
}
|
||
}
|
||
|
||
ensureLastUndefined = true;
|
||
} else if ((0, _generated.isIfStatement)(node)) {
|
||
const consequent = node.consequent ? gatherSequenceExpressions([node.consequent], scope, declars) : scope.buildUndefinedNode();
|
||
const alternate = node.alternate ? gatherSequenceExpressions([node.alternate], scope, declars) : scope.buildUndefinedNode();
|
||
if (!consequent || !alternate) return;
|
||
exprs.push((0, _generated2.conditionalExpression)(node.test, consequent, alternate));
|
||
} else if ((0, _generated.isBlockStatement)(node)) {
|
||
const body = gatherSequenceExpressions(node.body, scope, declars);
|
||
if (!body) return;
|
||
exprs.push(body);
|
||
} else if ((0, _generated.isEmptyStatement)(node)) {
|
||
ensureLastUndefined = true;
|
||
} else {
|
||
return;
|
||
}
|
||
}
|
||
|
||
if (ensureLastUndefined) {
|
||
exprs.push(scope.buildUndefinedNode());
|
||
}
|
||
|
||
if (exprs.length === 1) {
|
||
return exprs[0];
|
||
} else {
|
||
return (0, _generated2.sequenceExpression)(exprs);
|
||
}
|
||
}
|
||
|
||
/***/ }),
|
||
/* 301 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = toStatement;
|
||
|
||
var _generated = __webpack_require__(5);
|
||
|
||
var _generated2 = __webpack_require__(10);
|
||
|
||
function toStatement(node, ignore) {
|
||
if ((0, _generated.isStatement)(node)) {
|
||
return node;
|
||
}
|
||
|
||
let mustHaveId = false;
|
||
let newType;
|
||
|
||
if ((0, _generated.isClass)(node)) {
|
||
mustHaveId = true;
|
||
newType = "ClassDeclaration";
|
||
} else if ((0, _generated.isFunction)(node)) {
|
||
mustHaveId = true;
|
||
newType = "FunctionDeclaration";
|
||
} else if ((0, _generated.isAssignmentExpression)(node)) {
|
||
return (0, _generated2.expressionStatement)(node);
|
||
}
|
||
|
||
if (mustHaveId && !node.id) {
|
||
newType = false;
|
||
}
|
||
|
||
if (!newType) {
|
||
if (ignore) {
|
||
return false;
|
||
} else {
|
||
throw new Error(`cannot turn ${node.type} to a statement`);
|
||
}
|
||
}
|
||
|
||
node.type = newType;
|
||
return node;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 302 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = valueToNode;
|
||
|
||
function _isPlainObject() {
|
||
const data = _interopRequireDefault(__webpack_require__(303));
|
||
|
||
_isPlainObject = function () {
|
||
return data;
|
||
};
|
||
|
||
return data;
|
||
}
|
||
|
||
function _isRegExp() {
|
||
const data = _interopRequireDefault(__webpack_require__(304));
|
||
|
||
_isRegExp = function () {
|
||
return data;
|
||
};
|
||
|
||
return data;
|
||
}
|
||
|
||
var _isValidIdentifier = _interopRequireDefault(__webpack_require__(30));
|
||
|
||
var _generated = __webpack_require__(10);
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function valueToNode(value) {
|
||
if (value === undefined) {
|
||
return (0, _generated.identifier)("undefined");
|
||
}
|
||
|
||
if (value === true || value === false) {
|
||
return (0, _generated.booleanLiteral)(value);
|
||
}
|
||
|
||
if (value === null) {
|
||
return (0, _generated.nullLiteral)();
|
||
}
|
||
|
||
if (typeof value === "string") {
|
||
return (0, _generated.stringLiteral)(value);
|
||
}
|
||
|
||
if (typeof value === "number") {
|
||
let result;
|
||
|
||
if (Number.isFinite(value)) {
|
||
result = (0, _generated.numericLiteral)(Math.abs(value));
|
||
} else {
|
||
let numerator;
|
||
|
||
if (Number.isNaN(value)) {
|
||
numerator = (0, _generated.numericLiteral)(0);
|
||
} else {
|
||
numerator = (0, _generated.numericLiteral)(1);
|
||
}
|
||
|
||
result = (0, _generated.binaryExpression)("/", numerator, (0, _generated.numericLiteral)(0));
|
||
}
|
||
|
||
if (value < 0 || Object.is(value, -0)) {
|
||
result = (0, _generated.unaryExpression)("-", result);
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
if ((0, _isRegExp().default)(value)) {
|
||
const pattern = value.source;
|
||
const flags = value.toString().match(/\/([a-z]+|)$/)[1];
|
||
return (0, _generated.regExpLiteral)(pattern, flags);
|
||
}
|
||
|
||
if (Array.isArray(value)) {
|
||
return (0, _generated.arrayExpression)(value.map(valueToNode));
|
||
}
|
||
|
||
if ((0, _isPlainObject().default)(value)) {
|
||
const props = [];
|
||
|
||
for (const key of Object.keys(value)) {
|
||
let nodeKey;
|
||
|
||
if ((0, _isValidIdentifier.default)(key)) {
|
||
nodeKey = (0, _generated.identifier)(key);
|
||
} else {
|
||
nodeKey = (0, _generated.stringLiteral)(key);
|
||
}
|
||
|
||
props.push((0, _generated.objectProperty)(nodeKey, valueToNode(value[key])));
|
||
}
|
||
|
||
return (0, _generated.objectExpression)(props);
|
||
}
|
||
|
||
throw new Error("don't know how to turn this value into a node");
|
||
}
|
||
|
||
/***/ }),
|
||
/* 303 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var baseGetTag = __webpack_require__(18),
|
||
getPrototype = __webpack_require__(79),
|
||
isObjectLike = __webpack_require__(11);
|
||
|
||
/** `Object#toString` result references. */
|
||
var objectTag = '[object Object]';
|
||
|
||
/** Used for built-in method references. */
|
||
var funcProto = Function.prototype,
|
||
objectProto = Object.prototype;
|
||
|
||
/** Used to resolve the decompiled source of functions. */
|
||
var funcToString = funcProto.toString;
|
||
|
||
/** Used to check objects for own properties. */
|
||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||
|
||
/** Used to infer the `Object` constructor. */
|
||
var objectCtorString = funcToString.call(Object);
|
||
|
||
/**
|
||
* Checks if `value` is a plain object, that is, an object created by the
|
||
* `Object` constructor or one with a `[[Prototype]]` of `null`.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 0.8.0
|
||
* @category Lang
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
|
||
* @example
|
||
*
|
||
* function Foo() {
|
||
* this.a = 1;
|
||
* }
|
||
*
|
||
* _.isPlainObject(new Foo);
|
||
* // => false
|
||
*
|
||
* _.isPlainObject([1, 2, 3]);
|
||
* // => false
|
||
*
|
||
* _.isPlainObject({ 'x': 0, 'y': 0 });
|
||
* // => true
|
||
*
|
||
* _.isPlainObject(Object.create(null));
|
||
* // => true
|
||
*/
|
||
function isPlainObject(value) {
|
||
if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
|
||
return false;
|
||
}
|
||
var proto = getPrototype(value);
|
||
if (proto === null) {
|
||
return true;
|
||
}
|
||
var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
|
||
return typeof Ctor == 'function' && Ctor instanceof Ctor &&
|
||
funcToString.call(Ctor) == objectCtorString;
|
||
}
|
||
|
||
module.exports = isPlainObject;
|
||
|
||
|
||
/***/ }),
|
||
/* 304 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var baseIsRegExp = __webpack_require__(305),
|
||
baseUnary = __webpack_require__(49),
|
||
nodeUtil = __webpack_require__(50);
|
||
|
||
/* Node.js helper references. */
|
||
var nodeIsRegExp = nodeUtil && nodeUtil.isRegExp;
|
||
|
||
/**
|
||
* Checks if `value` is classified as a `RegExp` object.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 0.1.0
|
||
* @category Lang
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
|
||
* @example
|
||
*
|
||
* _.isRegExp(/abc/);
|
||
* // => true
|
||
*
|
||
* _.isRegExp('/abc/');
|
||
* // => false
|
||
*/
|
||
var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
|
||
|
||
module.exports = isRegExp;
|
||
|
||
|
||
/***/ }),
|
||
/* 305 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var baseGetTag = __webpack_require__(18),
|
||
isObjectLike = __webpack_require__(11);
|
||
|
||
/** `Object#toString` result references. */
|
||
var regexpTag = '[object RegExp]';
|
||
|
||
/**
|
||
* The base implementation of `_.isRegExp` without Node.js optimizations.
|
||
*
|
||
* @private
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
|
||
*/
|
||
function baseIsRegExp(value) {
|
||
return isObjectLike(value) && baseGetTag(value) == regexpTag;
|
||
}
|
||
|
||
module.exports = baseIsRegExp;
|
||
|
||
|
||
/***/ }),
|
||
/* 306 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = appendToMemberExpression;
|
||
|
||
var _generated = __webpack_require__(10);
|
||
|
||
function appendToMemberExpression(member, append, computed = false) {
|
||
member.object = (0, _generated.memberExpression)(member.object, member.property, member.computed);
|
||
member.property = append;
|
||
member.computed = !!computed;
|
||
return member;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 307 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = inherits;
|
||
|
||
var _constants = __webpack_require__(27);
|
||
|
||
var _inheritsComments = _interopRequireDefault(__webpack_require__(145));
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function inherits(child, parent) {
|
||
if (!child || !parent) return child;
|
||
|
||
for (const key of _constants.INHERIT_KEYS.optional) {
|
||
if (child[key] == null) {
|
||
child[key] = parent[key];
|
||
}
|
||
}
|
||
|
||
for (const key of Object.keys(parent)) {
|
||
if (key[0] === "_" && key !== "__clone") child[key] = parent[key];
|
||
}
|
||
|
||
for (const key of _constants.INHERIT_KEYS.force) {
|
||
child[key] = parent[key];
|
||
}
|
||
|
||
(0, _inheritsComments.default)(child, parent);
|
||
return child;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 308 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = prependToMemberExpression;
|
||
|
||
var _generated = __webpack_require__(10);
|
||
|
||
function prependToMemberExpression(member, prepend) {
|
||
member.object = (0, _generated.memberExpression)(prepend, member.object);
|
||
return member;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 309 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = getOuterBindingIdentifiers;
|
||
|
||
var _getBindingIdentifiers = _interopRequireDefault(__webpack_require__(53));
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function getOuterBindingIdentifiers(node, duplicates) {
|
||
return (0, _getBindingIdentifiers.default)(node, duplicates, true);
|
||
}
|
||
|
||
/***/ }),
|
||
/* 310 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = traverse;
|
||
|
||
var _definitions = __webpack_require__(16);
|
||
|
||
function traverse(node, handlers, state) {
|
||
if (typeof handlers === "function") {
|
||
handlers = {
|
||
enter: handlers
|
||
};
|
||
}
|
||
|
||
const {
|
||
enter,
|
||
exit
|
||
} = handlers;
|
||
traverseSimpleImpl(node, enter, exit, state, []);
|
||
}
|
||
|
||
function traverseSimpleImpl(node, enter, exit, state, ancestors) {
|
||
const keys = _definitions.VISITOR_KEYS[node.type];
|
||
if (!keys) return;
|
||
if (enter) enter(node, ancestors, state);
|
||
|
||
for (const key of keys) {
|
||
const subNode = node[key];
|
||
|
||
if (Array.isArray(subNode)) {
|
||
for (let i = 0; i < subNode.length; i++) {
|
||
const child = subNode[i];
|
||
if (!child) continue;
|
||
ancestors.push({
|
||
node,
|
||
key,
|
||
index: i
|
||
});
|
||
traverseSimpleImpl(child, enter, exit, state, ancestors);
|
||
ancestors.pop();
|
||
}
|
||
} else if (subNode) {
|
||
ancestors.push({
|
||
node,
|
||
key
|
||
});
|
||
traverseSimpleImpl(subNode, enter, exit, state, ancestors);
|
||
ancestors.pop();
|
||
}
|
||
}
|
||
|
||
if (exit) exit(node, ancestors, state);
|
||
}
|
||
|
||
/***/ }),
|
||
/* 311 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = isBinding;
|
||
|
||
var _getBindingIdentifiers = _interopRequireDefault(__webpack_require__(53));
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function isBinding(node, parent, grandparent) {
|
||
if (grandparent && node.type === "Identifier" && parent.type === "ObjectProperty" && grandparent.type === "ObjectExpression") {
|
||
return false;
|
||
}
|
||
|
||
const keys = _getBindingIdentifiers.default.keys[parent.type];
|
||
|
||
if (keys) {
|
||
for (let i = 0; i < keys.length; i++) {
|
||
const key = keys[i];
|
||
const val = parent[key];
|
||
|
||
if (Array.isArray(val)) {
|
||
if (val.indexOf(node) >= 0) return true;
|
||
} else {
|
||
if (val === node) return true;
|
||
}
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 312 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = isBlockScoped;
|
||
|
||
var _generated = __webpack_require__(5);
|
||
|
||
var _isLet = _interopRequireDefault(__webpack_require__(152));
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function isBlockScoped(node) {
|
||
return (0, _generated.isFunctionDeclaration)(node) || (0, _generated.isClassDeclaration)(node) || (0, _isLet.default)(node);
|
||
}
|
||
|
||
/***/ }),
|
||
/* 313 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = isImmutable;
|
||
|
||
var _isType = _interopRequireDefault(__webpack_require__(83));
|
||
|
||
var _generated = __webpack_require__(5);
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function isImmutable(node) {
|
||
if ((0, _isType.default)(node.type, "Immutable")) return true;
|
||
|
||
if ((0, _generated.isIdentifier)(node)) {
|
||
if (node.name === "undefined") {
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 314 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = isNodesEquivalent;
|
||
|
||
var _definitions = __webpack_require__(16);
|
||
|
||
function isNodesEquivalent(a, b) {
|
||
if (typeof a !== "object" || typeof b !== "object" || a == null || b == null) {
|
||
return a === b;
|
||
}
|
||
|
||
if (a.type !== b.type) {
|
||
return false;
|
||
}
|
||
|
||
const fields = Object.keys(_definitions.NODE_FIELDS[a.type] || a.type);
|
||
const visitorKeys = _definitions.VISITOR_KEYS[a.type];
|
||
|
||
for (const field of fields) {
|
||
if (typeof a[field] !== typeof b[field]) {
|
||
return false;
|
||
}
|
||
|
||
if (a[field] == null && b[field] == null) {
|
||
continue;
|
||
} else if (a[field] == null || b[field] == null) {
|
||
return false;
|
||
}
|
||
|
||
if (Array.isArray(a[field])) {
|
||
if (!Array.isArray(b[field])) {
|
||
return false;
|
||
}
|
||
|
||
if (a[field].length !== b[field].length) {
|
||
return false;
|
||
}
|
||
|
||
for (let i = 0; i < a[field].length; i++) {
|
||
if (!isNodesEquivalent(a[field][i], b[field][i])) {
|
||
return false;
|
||
}
|
||
}
|
||
|
||
continue;
|
||
}
|
||
|
||
if (typeof a[field] === "object" && (!visitorKeys || !visitorKeys.includes(field))) {
|
||
for (const key of Object.keys(a[field])) {
|
||
if (a[field][key] !== b[field][key]) {
|
||
return false;
|
||
}
|
||
}
|
||
|
||
continue;
|
||
}
|
||
|
||
if (!isNodesEquivalent(a[field], b[field])) {
|
||
return false;
|
||
}
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 315 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = isReferenced;
|
||
|
||
function isReferenced(node, parent, grandparent) {
|
||
switch (parent.type) {
|
||
case "MemberExpression":
|
||
case "JSXMemberExpression":
|
||
case "OptionalMemberExpression":
|
||
if (parent.property === node) {
|
||
return !!parent.computed;
|
||
}
|
||
|
||
return parent.object === node;
|
||
|
||
case "VariableDeclarator":
|
||
return parent.init === node;
|
||
|
||
case "ArrowFunctionExpression":
|
||
return parent.body === node;
|
||
|
||
case "ExportSpecifier":
|
||
if (parent.source) {
|
||
return false;
|
||
}
|
||
|
||
return parent.local === node;
|
||
|
||
case "PrivateName":
|
||
return false;
|
||
|
||
case "ObjectProperty":
|
||
case "ClassProperty":
|
||
case "ClassPrivateProperty":
|
||
case "ClassMethod":
|
||
case "ClassPrivateMethod":
|
||
case "ObjectMethod":
|
||
if (parent.key === node) {
|
||
return !!parent.computed;
|
||
}
|
||
|
||
if (parent.value === node) {
|
||
return !grandparent || grandparent.type !== "ObjectPattern";
|
||
}
|
||
|
||
return true;
|
||
|
||
case "ClassDeclaration":
|
||
case "ClassExpression":
|
||
return parent.superClass === node;
|
||
|
||
case "AssignmentExpression":
|
||
return parent.right === node;
|
||
|
||
case "AssignmentPattern":
|
||
return parent.right === node;
|
||
|
||
case "LabeledStatement":
|
||
return false;
|
||
|
||
case "CatchClause":
|
||
return false;
|
||
|
||
case "RestElement":
|
||
return false;
|
||
|
||
case "BreakStatement":
|
||
case "ContinueStatement":
|
||
return false;
|
||
|
||
case "FunctionDeclaration":
|
||
case "FunctionExpression":
|
||
return false;
|
||
|
||
case "ExportNamespaceSpecifier":
|
||
case "ExportDefaultSpecifier":
|
||
return false;
|
||
|
||
case "ImportDefaultSpecifier":
|
||
case "ImportNamespaceSpecifier":
|
||
case "ImportSpecifier":
|
||
return false;
|
||
|
||
case "JSXAttribute":
|
||
return false;
|
||
|
||
case "ObjectPattern":
|
||
case "ArrayPattern":
|
||
return false;
|
||
|
||
case "MetaProperty":
|
||
return false;
|
||
|
||
case "ObjectTypeProperty":
|
||
return parent.key !== node;
|
||
|
||
case "TSEnumMember":
|
||
return parent.id !== node;
|
||
|
||
case "TSPropertySignature":
|
||
if (parent.key === node) {
|
||
return !!parent.computed;
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 316 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = isScope;
|
||
|
||
var _generated = __webpack_require__(5);
|
||
|
||
function isScope(node, parent) {
|
||
if ((0, _generated.isBlockStatement)(node) && (0, _generated.isFunction)(parent, {
|
||
body: node
|
||
})) {
|
||
return false;
|
||
}
|
||
|
||
if ((0, _generated.isBlockStatement)(node) && (0, _generated.isCatchClause)(parent, {
|
||
body: node
|
||
})) {
|
||
return false;
|
||
}
|
||
|
||
return (0, _generated.isScopable)(node);
|
||
}
|
||
|
||
/***/ }),
|
||
/* 317 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = isSpecifierDefault;
|
||
|
||
var _generated = __webpack_require__(5);
|
||
|
||
function isSpecifierDefault(specifier) {
|
||
return (0, _generated.isImportDefaultSpecifier)(specifier) || (0, _generated.isIdentifier)(specifier.imported || specifier.exported, {
|
||
name: "default"
|
||
});
|
||
}
|
||
|
||
/***/ }),
|
||
/* 318 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = isValidES3Identifier;
|
||
|
||
var _isValidIdentifier = _interopRequireDefault(__webpack_require__(30));
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
const RESERVED_WORDS_ES3_ONLY = new Set(["abstract", "boolean", "byte", "char", "double", "enum", "final", "float", "goto", "implements", "int", "interface", "long", "native", "package", "private", "protected", "public", "short", "static", "synchronized", "throws", "transient", "volatile"]);
|
||
|
||
function isValidES3Identifier(name) {
|
||
return (0, _isValidIdentifier.default)(name) && !RESERVED_WORDS_ES3_ONLY.has(name);
|
||
}
|
||
|
||
/***/ }),
|
||
/* 319 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = isVar;
|
||
|
||
var _generated = __webpack_require__(5);
|
||
|
||
var _constants = __webpack_require__(27);
|
||
|
||
function isVar(node) {
|
||
return (0, _generated.isVariableDeclaration)(node, {
|
||
kind: "var"
|
||
}) && !node[_constants.BLOCK_SCOPED_SYMBOL];
|
||
}
|
||
|
||
/***/ }),
|
||
/* 320 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.parseScriptTags = exports.parseScripts = exports.parseScript = exports.getCandidateScriptLocations = exports.generateWhitespace = exports.extractScriptTags = undefined;
|
||
|
||
var _types = __webpack_require__(3);
|
||
|
||
var types = _interopRequireWildcard(_types);
|
||
|
||
var _parser = __webpack_require__(324);
|
||
|
||
var parser = _interopRequireWildcard(_parser);
|
||
|
||
var _customParse = __webpack_require__(322);
|
||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
||
|
||
function parseScript(_ref) {
|
||
var source = _ref.source,
|
||
line = _ref.line;
|
||
|
||
// remove empty or only whitespace scripts
|
||
if (source.length === 0 || /^\s+$/.test(source)) {
|
||
return null;
|
||
}
|
||
|
||
try {
|
||
return parser.parse(source, {
|
||
sourceType: "script",
|
||
startLine: line
|
||
});
|
||
} catch (e) {
|
||
return null;
|
||
}
|
||
}
|
||
|
||
function parseScripts(locations) {
|
||
var parser = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : parseScript;
|
||
|
||
return (0, _customParse.parseScripts)(locations, parser);
|
||
}
|
||
|
||
function extractScriptTags(source) {
|
||
return parseScripts((0, _customParse.getCandidateScriptLocations)(source), function (loc) {
|
||
var ast = parseScript(loc);
|
||
|
||
if (ast) {
|
||
return loc;
|
||
}
|
||
|
||
return null;
|
||
}).filter(types.isFile);
|
||
}
|
||
|
||
function parseScriptTags(source) {
|
||
var parser = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : parseScript;
|
||
|
||
return (0, _customParse.parseScriptTags)(source, parser);
|
||
}
|
||
|
||
exports.default = parseScriptTags;
|
||
exports.extractScriptTags = extractScriptTags;
|
||
exports.generateWhitespace = _customParse.generateWhitespace;
|
||
exports.getCandidateScriptLocations = _customParse.getCandidateScriptLocations;
|
||
exports.parseScript = parseScript;
|
||
exports.parseScripts = parseScripts;
|
||
exports.parseScriptTags = parseScriptTags;
|
||
|
||
/***/ }),
|
||
/* 321 */,
|
||
/* 322 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.parseScriptTags = exports.parseScripts = exports.getCandidateScriptLocations = exports.generateWhitespace = undefined;
|
||
|
||
var _types = __webpack_require__(3);
|
||
|
||
var types = _interopRequireWildcard(_types);
|
||
|
||
var _parseScriptFragment = __webpack_require__(323);
|
||
|
||
var _parseScriptFragment2 = _interopRequireDefault(_parseScriptFragment);
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
||
|
||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
||
|
||
var startScript = /<script[^>]*>/im;
|
||
var endScript = /<\/script\s*>/im;
|
||
// https://stackoverflow.com/questions/5034781/js-regex-to-split-by-line#comment5633979_5035005
|
||
var newLines = /\r\n|[\n\v\f\r\x85\u2028\u2029]/;
|
||
|
||
function getType(tag) {
|
||
var fragment = (0, _parseScriptFragment2.default)(tag);
|
||
|
||
if (fragment) {
|
||
var type = fragment.attributes.type;
|
||
|
||
return type ? type.toLowerCase() : null;
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
function getCandidateScriptLocations(source, index) {
|
||
var i = index || 0;
|
||
var str = source.substring(i);
|
||
|
||
var startMatch = startScript.exec(str);
|
||
if (startMatch) {
|
||
var startsAt = startMatch.index + startMatch[0].length;
|
||
var afterStart = str.substring(startsAt);
|
||
var endMatch = endScript.exec(afterStart);
|
||
if (endMatch) {
|
||
var locLength = endMatch.index;
|
||
var locIndex = i + startsAt;
|
||
var endIndex = locIndex + locLength + endMatch[0].length;
|
||
|
||
// extract the complete tag (incl start and end tags and content). if the
|
||
// type is invalid (= not JS), skip this tag and continue
|
||
var tag = source.substring(i + startMatch.index, endIndex);
|
||
var type = getType(tag);
|
||
if (type && type !== "javascript" && type !== "text/javascript") {
|
||
return getCandidateScriptLocations(source, endIndex);
|
||
}
|
||
|
||
return [adjustForLineAndColumn(source, {
|
||
index: locIndex,
|
||
length: locLength,
|
||
source: source.substring(locIndex, locIndex + locLength)
|
||
})].concat(_toConsumableArray(getCandidateScriptLocations(source, endIndex)));
|
||
}
|
||
}
|
||
|
||
return [];
|
||
}
|
||
|
||
function parseScripts(locations, parser) {
|
||
return locations.map(parser);
|
||
}
|
||
|
||
function generateWhitespace(length) {
|
||
return Array.from(new Array(length + 1)).join(" ");
|
||
}
|
||
|
||
function calcLineAndColumn(source, index) {
|
||
var lines = source.substring(0, index).split(newLines);
|
||
var line = lines.length;
|
||
var column = lines.pop().length + 1;
|
||
|
||
return {
|
||
column: column,
|
||
line: line
|
||
};
|
||
}
|
||
|
||
function adjustForLineAndColumn(fullSource, location) {
|
||
var _calcLineAndColumn = calcLineAndColumn(fullSource, location.index),
|
||
column = _calcLineAndColumn.column,
|
||
line = _calcLineAndColumn.line;
|
||
|
||
return Object.assign({}, location, {
|
||
line: line,
|
||
column: column,
|
||
// prepend whitespace for scripts that do not start on the first column
|
||
source: generateWhitespace(column) + location.source
|
||
});
|
||
}
|
||
|
||
function parseScriptTags(source, parser) {
|
||
var scripts = parseScripts(getCandidateScriptLocations(source), parser).filter(types.isFile).reduce(function (main, script) {
|
||
return {
|
||
statements: main.statements.concat(script.program.body),
|
||
comments: main.comments.concat(script.comments),
|
||
tokens: main.tokens.concat(script.tokens)
|
||
};
|
||
}, {
|
||
statements: [],
|
||
comments: [],
|
||
tokens: []
|
||
});
|
||
|
||
var program = types.program(scripts.statements);
|
||
var file = types.file(program, scripts.comments, scripts.tokens);
|
||
|
||
var end = calcLineAndColumn(source, source.length);
|
||
file.start = program.start = 0;
|
||
file.end = program.end = source.length;
|
||
file.loc = program.loc = {
|
||
start: {
|
||
line: 1,
|
||
column: 0
|
||
},
|
||
end: end
|
||
};
|
||
|
||
return file;
|
||
}
|
||
|
||
exports.default = parseScriptTags;
|
||
exports.generateWhitespace = generateWhitespace;
|
||
exports.getCandidateScriptLocations = getCandidateScriptLocations;
|
||
exports.parseScripts = parseScripts;
|
||
exports.parseScriptTags = parseScriptTags;
|
||
|
||
/***/ }),
|
||
/* 323 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
|
||
var alphanum = /[a-z0-9\-]/i;
|
||
|
||
function parseToken(str, start) {
|
||
var i = start;
|
||
while (i < str.length && alphanum.test(str.charAt(i++))) {
|
||
continue;
|
||
}
|
||
|
||
if (i !== start) {
|
||
return {
|
||
token: str.substring(start, i - 1),
|
||
index: i
|
||
};
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
function parseAttributes(str, start) {
|
||
var i = start;
|
||
var attributes = {};
|
||
var attribute = null;
|
||
|
||
while (i < str.length) {
|
||
var c = str.charAt(i);
|
||
|
||
if (attribute === null && c == ">") {
|
||
break;
|
||
} else if (attribute === null && alphanum.test(c)) {
|
||
attribute = {
|
||
name: null,
|
||
value: true,
|
||
bool: true,
|
||
terminator: null
|
||
};
|
||
|
||
var attributeNameNode = parseToken(str, i);
|
||
if (attributeNameNode) {
|
||
attribute.name = attributeNameNode.token;
|
||
i = attributeNameNode.index - 2;
|
||
}
|
||
} else if (attribute !== null) {
|
||
if (c === "=") {
|
||
// once we've started an attribute, look for = to indicate
|
||
// it's a non-boolean attribute
|
||
attribute.bool = false;
|
||
if (attribute.value === true) {
|
||
attribute.value = "";
|
||
}
|
||
} else if (!attribute.bool && attribute.terminator === null && (c === '"' || c === "'")) {
|
||
// once we've determined it's non-boolean, look for a
|
||
// value terminator (", ')
|
||
attribute.terminator = c;
|
||
} else if (attribute.terminator) {
|
||
if (c === attribute.terminator) {
|
||
// if we had a terminator and found another, we've
|
||
// reach the end of the attribute
|
||
attributes[attribute.name] = attribute.value;
|
||
attribute = null;
|
||
} else {
|
||
// otherwise, append the character to the attribute value
|
||
attribute.value += c;
|
||
|
||
// check for an escaped terminator and push it as well
|
||
// to avoid terminating prematurely
|
||
if (c === "\\") {
|
||
var next = str.charAt(i + 1);
|
||
if (next === attribute.terminator) {
|
||
attribute.value += next;
|
||
i += 1;
|
||
}
|
||
}
|
||
}
|
||
} else if (!/\s/.test(c)) {
|
||
// if we've hit a non-space character and aren't processing a value,
|
||
// we're starting a new attribute so push the attribute and clear the
|
||
// local variable
|
||
attributes[attribute.name] = attribute.value;
|
||
attribute = null;
|
||
|
||
// move the cursor back to re-find the start of the attribute
|
||
i -= 1;
|
||
}
|
||
}
|
||
|
||
i++;
|
||
}
|
||
|
||
if (i !== start) {
|
||
return {
|
||
attributes: attributes,
|
||
index: i
|
||
};
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
function parseFragment(str) {
|
||
var start = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
||
|
||
var tag = null;
|
||
var open = false;
|
||
var attributes = {};
|
||
|
||
var i = start;
|
||
while (i < str.length) {
|
||
var c = str.charAt(i++);
|
||
|
||
if (!open && !tag && c === "<") {
|
||
// Open Start Tag
|
||
open = true;
|
||
|
||
var tagNode = parseToken(str, i);
|
||
if (!tagNode) {
|
||
return null;
|
||
}
|
||
|
||
i = tagNode.index - 1;
|
||
tag = tagNode.token;
|
||
} else if (open && c === ">") {
|
||
// Close Start Tag
|
||
break;
|
||
} else if (open) {
|
||
// Attributes
|
||
var attributeNode = parseAttributes(str, i - 1);
|
||
|
||
if (attributeNode) {
|
||
i = attributeNode.index;
|
||
attributes = attributeNode.attributes || attributes;
|
||
}
|
||
}
|
||
}
|
||
|
||
if (tag) {
|
||
return {
|
||
tag: tag,
|
||
attributes: attributes
|
||
};
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
exports.default = parseFragment;
|
||
exports.parseFragment = parseFragment;
|
||
|
||
/***/ }),
|
||
/* 324 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, '__esModule', { value: true });
|
||
|
||
const beforeExpr = true;
|
||
const startsExpr = true;
|
||
const isLoop = true;
|
||
const isAssign = true;
|
||
const prefix = true;
|
||
const postfix = true;
|
||
class TokenType {
|
||
constructor(label, conf = {}) {
|
||
this.label = label;
|
||
this.keyword = conf.keyword;
|
||
this.beforeExpr = !!conf.beforeExpr;
|
||
this.startsExpr = !!conf.startsExpr;
|
||
this.rightAssociative = !!conf.rightAssociative;
|
||
this.isLoop = !!conf.isLoop;
|
||
this.isAssign = !!conf.isAssign;
|
||
this.prefix = !!conf.prefix;
|
||
this.postfix = !!conf.postfix;
|
||
this.binop = conf.binop != null ? conf.binop : null;
|
||
this.updateContext = null;
|
||
}
|
||
|
||
}
|
||
const keywords = new Map();
|
||
|
||
function createKeyword(name, options = {}) {
|
||
options.keyword = name;
|
||
const token = new TokenType(name, options);
|
||
keywords.set(name, token);
|
||
return token;
|
||
}
|
||
|
||
function createBinop(name, binop) {
|
||
return new TokenType(name, {
|
||
beforeExpr,
|
||
binop
|
||
});
|
||
}
|
||
|
||
const types = {
|
||
num: new TokenType("num", {
|
||
startsExpr
|
||
}),
|
||
bigint: new TokenType("bigint", {
|
||
startsExpr
|
||
}),
|
||
regexp: new TokenType("regexp", {
|
||
startsExpr
|
||
}),
|
||
string: new TokenType("string", {
|
||
startsExpr
|
||
}),
|
||
name: new TokenType("name", {
|
||
startsExpr
|
||
}),
|
||
eof: new TokenType("eof"),
|
||
bracketL: new TokenType("[", {
|
||
beforeExpr,
|
||
startsExpr
|
||
}),
|
||
bracketR: new TokenType("]"),
|
||
braceL: new TokenType("{", {
|
||
beforeExpr,
|
||
startsExpr
|
||
}),
|
||
braceBarL: new TokenType("{|", {
|
||
beforeExpr,
|
||
startsExpr
|
||
}),
|
||
braceR: new TokenType("}"),
|
||
braceBarR: new TokenType("|}"),
|
||
parenL: new TokenType("(", {
|
||
beforeExpr,
|
||
startsExpr
|
||
}),
|
||
parenR: new TokenType(")"),
|
||
comma: new TokenType(",", {
|
||
beforeExpr
|
||
}),
|
||
semi: new TokenType(";", {
|
||
beforeExpr
|
||
}),
|
||
colon: new TokenType(":", {
|
||
beforeExpr
|
||
}),
|
||
doubleColon: new TokenType("::", {
|
||
beforeExpr
|
||
}),
|
||
dot: new TokenType("."),
|
||
question: new TokenType("?", {
|
||
beforeExpr
|
||
}),
|
||
questionDot: new TokenType("?."),
|
||
arrow: new TokenType("=>", {
|
||
beforeExpr
|
||
}),
|
||
template: new TokenType("template"),
|
||
ellipsis: new TokenType("...", {
|
||
beforeExpr
|
||
}),
|
||
backQuote: new TokenType("`", {
|
||
startsExpr
|
||
}),
|
||
dollarBraceL: new TokenType("${", {
|
||
beforeExpr,
|
||
startsExpr
|
||
}),
|
||
at: new TokenType("@"),
|
||
hash: new TokenType("#", {
|
||
startsExpr
|
||
}),
|
||
interpreterDirective: new TokenType("#!..."),
|
||
eq: new TokenType("=", {
|
||
beforeExpr,
|
||
isAssign
|
||
}),
|
||
assign: new TokenType("_=", {
|
||
beforeExpr,
|
||
isAssign
|
||
}),
|
||
incDec: new TokenType("++/--", {
|
||
prefix,
|
||
postfix,
|
||
startsExpr
|
||
}),
|
||
bang: new TokenType("!", {
|
||
beforeExpr,
|
||
prefix,
|
||
startsExpr
|
||
}),
|
||
tilde: new TokenType("~", {
|
||
beforeExpr,
|
||
prefix,
|
||
startsExpr
|
||
}),
|
||
pipeline: createBinop("|>", 0),
|
||
nullishCoalescing: createBinop("??", 1),
|
||
logicalOR: createBinop("||", 1),
|
||
logicalAND: createBinop("&&", 2),
|
||
bitwiseOR: createBinop("|", 3),
|
||
bitwiseXOR: createBinop("^", 4),
|
||
bitwiseAND: createBinop("&", 5),
|
||
equality: createBinop("==/!=/===/!==", 6),
|
||
relational: createBinop("</>/<=/>=", 7),
|
||
bitShift: createBinop("<</>>/>>>", 8),
|
||
plusMin: new TokenType("+/-", {
|
||
beforeExpr,
|
||
binop: 9,
|
||
prefix,
|
||
startsExpr
|
||
}),
|
||
modulo: createBinop("%", 10),
|
||
star: createBinop("*", 10),
|
||
slash: createBinop("/", 10),
|
||
exponent: new TokenType("**", {
|
||
beforeExpr,
|
||
binop: 11,
|
||
rightAssociative: true
|
||
}),
|
||
_break: createKeyword("break"),
|
||
_case: createKeyword("case", {
|
||
beforeExpr
|
||
}),
|
||
_catch: createKeyword("catch"),
|
||
_continue: createKeyword("continue"),
|
||
_debugger: createKeyword("debugger"),
|
||
_default: createKeyword("default", {
|
||
beforeExpr
|
||
}),
|
||
_do: createKeyword("do", {
|
||
isLoop,
|
||
beforeExpr
|
||
}),
|
||
_else: createKeyword("else", {
|
||
beforeExpr
|
||
}),
|
||
_finally: createKeyword("finally"),
|
||
_for: createKeyword("for", {
|
||
isLoop
|
||
}),
|
||
_function: createKeyword("function", {
|
||
startsExpr
|
||
}),
|
||
_if: createKeyword("if"),
|
||
_return: createKeyword("return", {
|
||
beforeExpr
|
||
}),
|
||
_switch: createKeyword("switch"),
|
||
_throw: createKeyword("throw", {
|
||
beforeExpr,
|
||
prefix,
|
||
startsExpr
|
||
}),
|
||
_try: createKeyword("try"),
|
||
_var: createKeyword("var"),
|
||
_const: createKeyword("const"),
|
||
_while: createKeyword("while", {
|
||
isLoop
|
||
}),
|
||
_with: createKeyword("with"),
|
||
_new: createKeyword("new", {
|
||
beforeExpr,
|
||
startsExpr
|
||
}),
|
||
_this: createKeyword("this", {
|
||
startsExpr
|
||
}),
|
||
_super: createKeyword("super", {
|
||
startsExpr
|
||
}),
|
||
_class: createKeyword("class", {
|
||
startsExpr
|
||
}),
|
||
_extends: createKeyword("extends", {
|
||
beforeExpr
|
||
}),
|
||
_export: createKeyword("export"),
|
||
_import: createKeyword("import", {
|
||
startsExpr
|
||
}),
|
||
_null: createKeyword("null", {
|
||
startsExpr
|
||
}),
|
||
_true: createKeyword("true", {
|
||
startsExpr
|
||
}),
|
||
_false: createKeyword("false", {
|
||
startsExpr
|
||
}),
|
||
_in: createKeyword("in", {
|
||
beforeExpr,
|
||
binop: 7
|
||
}),
|
||
_instanceof: createKeyword("instanceof", {
|
||
beforeExpr,
|
||
binop: 7
|
||
}),
|
||
_typeof: createKeyword("typeof", {
|
||
beforeExpr,
|
||
prefix,
|
||
startsExpr
|
||
}),
|
||
_void: createKeyword("void", {
|
||
beforeExpr,
|
||
prefix,
|
||
startsExpr
|
||
}),
|
||
_delete: createKeyword("delete", {
|
||
beforeExpr,
|
||
prefix,
|
||
startsExpr
|
||
})
|
||
};
|
||
|
||
const SCOPE_OTHER = 0b000000000,
|
||
SCOPE_PROGRAM = 0b000000001,
|
||
SCOPE_FUNCTION = 0b000000010,
|
||
SCOPE_ASYNC = 0b000000100,
|
||
SCOPE_GENERATOR = 0b000001000,
|
||
SCOPE_ARROW = 0b000010000,
|
||
SCOPE_SIMPLE_CATCH = 0b000100000,
|
||
SCOPE_SUPER = 0b001000000,
|
||
SCOPE_DIRECT_SUPER = 0b010000000,
|
||
SCOPE_CLASS = 0b100000000,
|
||
SCOPE_VAR = SCOPE_PROGRAM | SCOPE_FUNCTION;
|
||
function functionFlags(isAsync, isGenerator) {
|
||
return SCOPE_FUNCTION | (isAsync ? SCOPE_ASYNC : 0) | (isGenerator ? SCOPE_GENERATOR : 0);
|
||
}
|
||
const BIND_KIND_VALUE = 0b00000000001,
|
||
BIND_KIND_TYPE = 0b00000000010,
|
||
BIND_SCOPE_VAR = 0b00000000100,
|
||
BIND_SCOPE_LEXICAL = 0b00000001000,
|
||
BIND_SCOPE_FUNCTION = 0b00000010000,
|
||
BIND_FLAGS_NONE = 0b00001000000,
|
||
BIND_FLAGS_CLASS = 0b00010000000,
|
||
BIND_FLAGS_TS_ENUM = 0b00100000000,
|
||
BIND_FLAGS_TS_CONST_ENUM = 0b01000000000,
|
||
BIND_FLAGS_TS_EXPORT_ONLY = 0b10000000000;
|
||
const BIND_CLASS = BIND_KIND_VALUE | BIND_KIND_TYPE | BIND_SCOPE_LEXICAL | BIND_FLAGS_CLASS,
|
||
BIND_LEXICAL = BIND_KIND_VALUE | 0 | BIND_SCOPE_LEXICAL | 0,
|
||
BIND_VAR = BIND_KIND_VALUE | 0 | BIND_SCOPE_VAR | 0,
|
||
BIND_FUNCTION = BIND_KIND_VALUE | 0 | BIND_SCOPE_FUNCTION | 0,
|
||
BIND_TS_INTERFACE = 0 | BIND_KIND_TYPE | 0 | BIND_FLAGS_CLASS,
|
||
BIND_TS_TYPE = 0 | BIND_KIND_TYPE | 0 | 0,
|
||
BIND_TS_ENUM = BIND_KIND_VALUE | BIND_KIND_TYPE | BIND_SCOPE_LEXICAL | BIND_FLAGS_TS_ENUM,
|
||
BIND_TS_FN_TYPE = 0 | 0 | 0 | BIND_FLAGS_TS_EXPORT_ONLY,
|
||
BIND_NONE = 0 | 0 | 0 | BIND_FLAGS_NONE,
|
||
BIND_OUTSIDE = BIND_KIND_VALUE | 0 | 0 | BIND_FLAGS_NONE,
|
||
BIND_TS_CONST_ENUM = BIND_TS_ENUM | BIND_FLAGS_TS_CONST_ENUM,
|
||
BIND_TS_NAMESPACE = BIND_TS_FN_TYPE;
|
||
|
||
function isSimpleProperty(node) {
|
||
return node != null && node.type === "Property" && node.kind === "init" && node.method === false;
|
||
}
|
||
|
||
var estree = (superClass => class extends superClass {
|
||
estreeParseRegExpLiteral({
|
||
pattern,
|
||
flags
|
||
}) {
|
||
let regex = null;
|
||
|
||
try {
|
||
regex = new RegExp(pattern, flags);
|
||
} catch (e) {}
|
||
|
||
const node = this.estreeParseLiteral(regex);
|
||
node.regex = {
|
||
pattern,
|
||
flags
|
||
};
|
||
return node;
|
||
}
|
||
|
||
estreeParseLiteral(value) {
|
||
return this.parseLiteral(value, "Literal");
|
||
}
|
||
|
||
directiveToStmt(directive) {
|
||
const directiveLiteral = directive.value;
|
||
const stmt = this.startNodeAt(directive.start, directive.loc.start);
|
||
const expression = this.startNodeAt(directiveLiteral.start, directiveLiteral.loc.start);
|
||
expression.value = directiveLiteral.value;
|
||
expression.raw = directiveLiteral.extra.raw;
|
||
stmt.expression = this.finishNodeAt(expression, "Literal", directiveLiteral.end, directiveLiteral.loc.end);
|
||
stmt.directive = directiveLiteral.extra.raw.slice(1, -1);
|
||
return this.finishNodeAt(stmt, "ExpressionStatement", directive.end, directive.loc.end);
|
||
}
|
||
|
||
initFunction(node, isAsync) {
|
||
super.initFunction(node, isAsync);
|
||
node.expression = false;
|
||
}
|
||
|
||
checkDeclaration(node) {
|
||
if (isSimpleProperty(node)) {
|
||
this.checkDeclaration(node.value);
|
||
} else {
|
||
super.checkDeclaration(node);
|
||
}
|
||
}
|
||
|
||
checkGetterSetterParams(method) {
|
||
const prop = method;
|
||
const paramCount = prop.kind === "get" ? 0 : 1;
|
||
const start = prop.start;
|
||
|
||
if (prop.value.params.length !== paramCount) {
|
||
if (prop.kind === "get") {
|
||
this.raise(start, "getter must not have any formal parameters");
|
||
} else {
|
||
this.raise(start, "setter must have exactly one formal parameter");
|
||
}
|
||
}
|
||
|
||
if (prop.kind === "set" && prop.value.params[0].type === "RestElement") {
|
||
this.raise(start, "setter function argument must not be a rest parameter");
|
||
}
|
||
}
|
||
|
||
checkLVal(expr, bindingType = BIND_NONE, checkClashes, contextDescription) {
|
||
switch (expr.type) {
|
||
case "ObjectPattern":
|
||
expr.properties.forEach(prop => {
|
||
this.checkLVal(prop.type === "Property" ? prop.value : prop, bindingType, checkClashes, "object destructuring pattern");
|
||
});
|
||
break;
|
||
|
||
default:
|
||
super.checkLVal(expr, bindingType, checkClashes, contextDescription);
|
||
}
|
||
}
|
||
|
||
checkPropClash(prop, propHash) {
|
||
if (prop.type === "SpreadElement" || prop.computed || prop.method || prop.shorthand) {
|
||
return;
|
||
}
|
||
|
||
const key = prop.key;
|
||
const name = key.type === "Identifier" ? key.name : String(key.value);
|
||
|
||
if (name === "__proto__" && prop.kind === "init") {
|
||
if (propHash.proto) {
|
||
this.raise(key.start, "Redefinition of __proto__ property");
|
||
}
|
||
|
||
propHash.proto = true;
|
||
}
|
||
}
|
||
|
||
isStrictBody(node) {
|
||
const isBlockStatement = node.body.type === "BlockStatement";
|
||
|
||
if (isBlockStatement && node.body.body.length > 0) {
|
||
for (let _i = 0, _node$body$body = node.body.body; _i < _node$body$body.length; _i++) {
|
||
const directive = _node$body$body[_i];
|
||
|
||
if (directive.type === "ExpressionStatement" && directive.expression.type === "Literal") {
|
||
if (directive.expression.value === "use strict") return true;
|
||
} else {
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
isValidDirective(stmt) {
|
||
return stmt.type === "ExpressionStatement" && stmt.expression.type === "Literal" && typeof stmt.expression.value === "string" && (!stmt.expression.extra || !stmt.expression.extra.parenthesized);
|
||
}
|
||
|
||
stmtToDirective(stmt) {
|
||
const directive = super.stmtToDirective(stmt);
|
||
const value = stmt.expression.value;
|
||
directive.value.value = value;
|
||
return directive;
|
||
}
|
||
|
||
parseBlockBody(node, allowDirectives, topLevel, end) {
|
||
super.parseBlockBody(node, allowDirectives, topLevel, end);
|
||
const directiveStatements = node.directives.map(d => this.directiveToStmt(d));
|
||
node.body = directiveStatements.concat(node.body);
|
||
delete node.directives;
|
||
}
|
||
|
||
pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
|
||
this.parseMethod(method, isGenerator, isAsync, isConstructor, allowsDirectSuper, "ClassMethod", true);
|
||
|
||
if (method.typeParameters) {
|
||
method.value.typeParameters = method.typeParameters;
|
||
delete method.typeParameters;
|
||
}
|
||
|
||
classBody.body.push(method);
|
||
}
|
||
|
||
parseExprAtom(refShorthandDefaultPos) {
|
||
switch (this.state.type) {
|
||
case types.regexp:
|
||
return this.estreeParseRegExpLiteral(this.state.value);
|
||
|
||
case types.num:
|
||
case types.string:
|
||
return this.estreeParseLiteral(this.state.value);
|
||
|
||
case types._null:
|
||
return this.estreeParseLiteral(null);
|
||
|
||
case types._true:
|
||
return this.estreeParseLiteral(true);
|
||
|
||
case types._false:
|
||
return this.estreeParseLiteral(false);
|
||
|
||
default:
|
||
return super.parseExprAtom(refShorthandDefaultPos);
|
||
}
|
||
}
|
||
|
||
parseLiteral(value, type, startPos, startLoc) {
|
||
const node = super.parseLiteral(value, type, startPos, startLoc);
|
||
node.raw = node.extra.raw;
|
||
delete node.extra;
|
||
return node;
|
||
}
|
||
|
||
parseFunctionBody(node, allowExpression, isMethod = false) {
|
||
super.parseFunctionBody(node, allowExpression, isMethod);
|
||
node.expression = node.body.type !== "BlockStatement";
|
||
}
|
||
|
||
parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope = false) {
|
||
let funcNode = this.startNode();
|
||
funcNode.kind = node.kind;
|
||
funcNode = super.parseMethod(funcNode, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope);
|
||
funcNode.type = "FunctionExpression";
|
||
delete funcNode.kind;
|
||
node.value = funcNode;
|
||
type = type === "ClassMethod" ? "MethodDefinition" : type;
|
||
return this.finishNode(node, type);
|
||
}
|
||
|
||
parseObjectMethod(prop, isGenerator, isAsync, isPattern, containsEsc) {
|
||
const node = super.parseObjectMethod(prop, isGenerator, isAsync, isPattern, containsEsc);
|
||
|
||
if (node) {
|
||
node.type = "Property";
|
||
if (node.kind === "method") node.kind = "init";
|
||
node.shorthand = false;
|
||
}
|
||
|
||
return node;
|
||
}
|
||
|
||
parseObjectProperty(prop, startPos, startLoc, isPattern, refShorthandDefaultPos) {
|
||
const node = super.parseObjectProperty(prop, startPos, startLoc, isPattern, refShorthandDefaultPos);
|
||
|
||
if (node) {
|
||
node.kind = "init";
|
||
node.type = "Property";
|
||
}
|
||
|
||
return node;
|
||
}
|
||
|
||
toAssignable(node, isBinding, contextDescription) {
|
||
if (isSimpleProperty(node)) {
|
||
this.toAssignable(node.value, isBinding, contextDescription);
|
||
return node;
|
||
}
|
||
|
||
return super.toAssignable(node, isBinding, contextDescription);
|
||
}
|
||
|
||
toAssignableObjectExpressionProp(prop, isBinding, isLast) {
|
||
if (prop.kind === "get" || prop.kind === "set") {
|
||
this.raise(prop.key.start, "Object pattern can't contain getter or setter");
|
||
} else if (prop.method) {
|
||
this.raise(prop.key.start, "Object pattern can't contain methods");
|
||
} else {
|
||
super.toAssignableObjectExpressionProp(prop, isBinding, isLast);
|
||
}
|
||
}
|
||
|
||
});
|
||
|
||
const lineBreak = /\r\n?|[\n\u2028\u2029]/;
|
||
const lineBreakG = new RegExp(lineBreak.source, "g");
|
||
function isNewLine(code) {
|
||
switch (code) {
|
||
case 10:
|
||
case 13:
|
||
case 8232:
|
||
case 8233:
|
||
return true;
|
||
|
||
default:
|
||
return false;
|
||
}
|
||
}
|
||
const skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
|
||
function isWhitespace(code) {
|
||
switch (code) {
|
||
case 0x0009:
|
||
case 0x000b:
|
||
case 0x000c:
|
||
case 32:
|
||
case 160:
|
||
case 5760:
|
||
case 0x2000:
|
||
case 0x2001:
|
||
case 0x2002:
|
||
case 0x2003:
|
||
case 0x2004:
|
||
case 0x2005:
|
||
case 0x2006:
|
||
case 0x2007:
|
||
case 0x2008:
|
||
case 0x2009:
|
||
case 0x200a:
|
||
case 0x202f:
|
||
case 0x205f:
|
||
case 0x3000:
|
||
case 0xfeff:
|
||
return true;
|
||
|
||
default:
|
||
return false;
|
||
}
|
||
}
|
||
|
||
class TokContext {
|
||
constructor(token, isExpr, preserveSpace, override) {
|
||
this.token = token;
|
||
this.isExpr = !!isExpr;
|
||
this.preserveSpace = !!preserveSpace;
|
||
this.override = override;
|
||
}
|
||
|
||
}
|
||
const types$1 = {
|
||
braceStatement: new TokContext("{", false),
|
||
braceExpression: new TokContext("{", true),
|
||
templateQuasi: new TokContext("${", false),
|
||
parenStatement: new TokContext("(", false),
|
||
parenExpression: new TokContext("(", true),
|
||
template: new TokContext("`", true, true, p => p.readTmplToken()),
|
||
functionExpression: new TokContext("function", true),
|
||
functionStatement: new TokContext("function", false)
|
||
};
|
||
|
||
types.parenR.updateContext = types.braceR.updateContext = function () {
|
||
if (this.state.context.length === 1) {
|
||
this.state.exprAllowed = true;
|
||
return;
|
||
}
|
||
|
||
let out = this.state.context.pop();
|
||
|
||
if (out === types$1.braceStatement && this.curContext().token === "function") {
|
||
out = this.state.context.pop();
|
||
}
|
||
|
||
this.state.exprAllowed = !out.isExpr;
|
||
};
|
||
|
||
types.name.updateContext = function (prevType) {
|
||
let allowed = false;
|
||
|
||
if (prevType !== types.dot) {
|
||
if (this.state.value === "of" && !this.state.exprAllowed || this.state.value === "yield" && this.scope.inGenerator) {
|
||
allowed = true;
|
||
}
|
||
}
|
||
|
||
this.state.exprAllowed = allowed;
|
||
|
||
if (this.state.isIterator) {
|
||
this.state.isIterator = false;
|
||
}
|
||
};
|
||
|
||
types.braceL.updateContext = function (prevType) {
|
||
this.state.context.push(this.braceIsBlock(prevType) ? types$1.braceStatement : types$1.braceExpression);
|
||
this.state.exprAllowed = true;
|
||
};
|
||
|
||
types.dollarBraceL.updateContext = function () {
|
||
this.state.context.push(types$1.templateQuasi);
|
||
this.state.exprAllowed = true;
|
||
};
|
||
|
||
types.parenL.updateContext = function (prevType) {
|
||
const statementParens = prevType === types._if || prevType === types._for || prevType === types._with || prevType === types._while;
|
||
this.state.context.push(statementParens ? types$1.parenStatement : types$1.parenExpression);
|
||
this.state.exprAllowed = true;
|
||
};
|
||
|
||
types.incDec.updateContext = function () {};
|
||
|
||
types._function.updateContext = types._class.updateContext = function (prevType) {
|
||
if (prevType.beforeExpr && prevType !== types.semi && prevType !== types._else && !(prevType === types._return && lineBreak.test(this.input.slice(this.state.lastTokEnd, this.state.start))) && !((prevType === types.colon || prevType === types.braceL) && this.curContext() === types$1.b_stat)) {
|
||
this.state.context.push(types$1.functionExpression);
|
||
} else {
|
||
this.state.context.push(types$1.functionStatement);
|
||
}
|
||
|
||
this.state.exprAllowed = false;
|
||
};
|
||
|
||
types.backQuote.updateContext = function () {
|
||
if (this.curContext() === types$1.template) {
|
||
this.state.context.pop();
|
||
} else {
|
||
this.state.context.push(types$1.template);
|
||
}
|
||
|
||
this.state.exprAllowed = false;
|
||
};
|
||
|
||
const reservedWords = {
|
||
strict: ["implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"],
|
||
strictBind: ["eval", "arguments"]
|
||
};
|
||
const reservedWordsStrictSet = new Set(reservedWords.strict);
|
||
const reservedWordsStrictBindSet = new Set(reservedWords.strict.concat(reservedWords.strictBind));
|
||
const isReservedWord = (word, inModule) => {
|
||
return inModule && word === "await" || word === "enum";
|
||
};
|
||
function isStrictReservedWord(word, inModule) {
|
||
return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word);
|
||
}
|
||
function isStrictBindReservedWord(word, inModule) {
|
||
return isReservedWord(word, inModule) || reservedWordsStrictBindSet.has(word);
|
||
}
|
||
function isKeyword(word) {
|
||
return keywords.has(word);
|
||
}
|
||
const keywordRelationalOperator = /^in(stanceof)?$/;
|
||
let nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u08a0-\u08b4\u08b6-\u08bd\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fef\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7bf\ua7c2-\ua7c6\ua7f7-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab67\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc";
|
||
let nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08d3-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1df9\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f";
|
||
const nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
|
||
const nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
|
||
nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;
|
||
const astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 157, 310, 10, 21, 11, 7, 153, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 477, 28, 11, 0, 9, 21, 155, 22, 13, 52, 76, 44, 33, 24, 27, 35, 30, 0, 12, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 85, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 159, 52, 19, 3, 21, 0, 33, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 230, 43, 117, 63, 32, 0, 161, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 35, 56, 264, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 328, 18, 270, 921, 103, 110, 18, 195, 2749, 1070, 4050, 582, 8634, 568, 8, 30, 114, 29, 19, 47, 17, 3, 32, 20, 6, 18, 689, 63, 129, 74, 6, 0, 67, 12, 65, 1, 2, 0, 29, 6135, 9, 754, 9486, 286, 50, 2, 18, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 2357, 44, 11, 6, 17, 0, 370, 43, 1301, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42710, 42, 4148, 12, 221, 3, 5761, 15, 7472, 3104, 541];
|
||
const astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 525, 10, 176, 2, 54, 14, 32, 9, 16, 3, 46, 10, 54, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 4, 9, 83, 11, 7, 0, 161, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 14, 5, 9, 243, 14, 166, 9, 232, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 406, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 19306, 9, 135, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 19723, 1, 5319, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 262, 6, 10, 9, 419, 13, 1495, 6, 110, 6, 6, 9, 792487, 239];
|
||
|
||
function isInAstralSet(code, set) {
|
||
let pos = 0x10000;
|
||
|
||
for (let i = 0, length = set.length; i < length; i += 2) {
|
||
pos += set[i];
|
||
if (pos > code) return false;
|
||
pos += set[i + 1];
|
||
if (pos >= code) return true;
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function isIdentifierStart(code) {
|
||
if (code < 65) return code === 36;
|
||
if (code <= 90) return true;
|
||
if (code < 97) return code === 95;
|
||
if (code <= 122) return true;
|
||
|
||
if (code <= 0xffff) {
|
||
return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code));
|
||
}
|
||
|
||
return isInAstralSet(code, astralIdentifierStartCodes);
|
||
}
|
||
function isIteratorStart(current, next) {
|
||
return current === 64 && next === 64;
|
||
}
|
||
function isIdentifierChar(code) {
|
||
if (code < 48) return code === 36;
|
||
if (code < 58) return true;
|
||
if (code < 65) return false;
|
||
if (code <= 90) return true;
|
||
if (code < 97) return code === 95;
|
||
if (code <= 122) return true;
|
||
|
||
if (code <= 0xffff) {
|
||
return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code));
|
||
}
|
||
|
||
return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes);
|
||
}
|
||
|
||
const reservedTypes = ["any", "bool", "boolean", "empty", "false", "mixed", "null", "number", "static", "string", "true", "typeof", "void", "interface", "extends", "_"];
|
||
|
||
function isEsModuleType(bodyElement) {
|
||
return bodyElement.type === "DeclareExportAllDeclaration" || bodyElement.type === "DeclareExportDeclaration" && (!bodyElement.declaration || bodyElement.declaration.type !== "TypeAlias" && bodyElement.declaration.type !== "InterfaceDeclaration");
|
||
}
|
||
|
||
function hasTypeImportKind(node) {
|
||
return node.importKind === "type" || node.importKind === "typeof";
|
||
}
|
||
|
||
function isMaybeDefaultImport(state) {
|
||
return (state.type === types.name || !!state.type.keyword) && state.value !== "from";
|
||
}
|
||
|
||
const exportSuggestions = {
|
||
const: "declare export var",
|
||
let: "declare export var",
|
||
type: "export type",
|
||
interface: "export interface"
|
||
};
|
||
|
||
function partition(list, test) {
|
||
const list1 = [];
|
||
const list2 = [];
|
||
|
||
for (let i = 0; i < list.length; i++) {
|
||
(test(list[i], i, list) ? list1 : list2).push(list[i]);
|
||
}
|
||
|
||
return [list1, list2];
|
||
}
|
||
|
||
const FLOW_PRAGMA_REGEX = /\*?\s*@((?:no)?flow)\b/;
|
||
var flow = (superClass => class extends superClass {
|
||
constructor(options, input) {
|
||
super(options, input);
|
||
this.flowPragma = undefined;
|
||
}
|
||
|
||
shouldParseTypes() {
|
||
return this.getPluginOption("flow", "all") || this.flowPragma === "flow";
|
||
}
|
||
|
||
finishToken(type, val) {
|
||
if (type !== types.string && type !== types.semi && type !== types.interpreterDirective) {
|
||
if (this.flowPragma === undefined) {
|
||
this.flowPragma = null;
|
||
}
|
||
}
|
||
|
||
return super.finishToken(type, val);
|
||
}
|
||
|
||
addComment(comment) {
|
||
if (this.flowPragma === undefined) {
|
||
const matches = FLOW_PRAGMA_REGEX.exec(comment.value);
|
||
|
||
if (!matches) ; else if (matches[1] === "flow") {
|
||
this.flowPragma = "flow";
|
||
} else if (matches[1] === "noflow") {
|
||
this.flowPragma = "noflow";
|
||
} else {
|
||
throw new Error("Unexpected flow pragma");
|
||
}
|
||
}
|
||
|
||
return super.addComment(comment);
|
||
}
|
||
|
||
flowParseTypeInitialiser(tok) {
|
||
const oldInType = this.state.inType;
|
||
this.state.inType = true;
|
||
this.expect(tok || types.colon);
|
||
const type = this.flowParseType();
|
||
this.state.inType = oldInType;
|
||
return type;
|
||
}
|
||
|
||
flowParsePredicate() {
|
||
const node = this.startNode();
|
||
const moduloLoc = this.state.startLoc;
|
||
const moduloPos = this.state.start;
|
||
this.expect(types.modulo);
|
||
const checksLoc = this.state.startLoc;
|
||
this.expectContextual("checks");
|
||
|
||
if (moduloLoc.line !== checksLoc.line || moduloLoc.column !== checksLoc.column - 1) {
|
||
this.raise(moduloPos, "Spaces between ´%´ and ´checks´ are not allowed here.");
|
||
}
|
||
|
||
if (this.eat(types.parenL)) {
|
||
node.value = this.parseExpression();
|
||
this.expect(types.parenR);
|
||
return this.finishNode(node, "DeclaredPredicate");
|
||
} else {
|
||
return this.finishNode(node, "InferredPredicate");
|
||
}
|
||
}
|
||
|
||
flowParseTypeAndPredicateInitialiser() {
|
||
const oldInType = this.state.inType;
|
||
this.state.inType = true;
|
||
this.expect(types.colon);
|
||
let type = null;
|
||
let predicate = null;
|
||
|
||
if (this.match(types.modulo)) {
|
||
this.state.inType = oldInType;
|
||
predicate = this.flowParsePredicate();
|
||
} else {
|
||
type = this.flowParseType();
|
||
this.state.inType = oldInType;
|
||
|
||
if (this.match(types.modulo)) {
|
||
predicate = this.flowParsePredicate();
|
||
}
|
||
}
|
||
|
||
return [type, predicate];
|
||
}
|
||
|
||
flowParseDeclareClass(node) {
|
||
this.next();
|
||
this.flowParseInterfaceish(node, true);
|
||
return this.finishNode(node, "DeclareClass");
|
||
}
|
||
|
||
flowParseDeclareFunction(node) {
|
||
this.next();
|
||
const id = node.id = this.parseIdentifier();
|
||
const typeNode = this.startNode();
|
||
const typeContainer = this.startNode();
|
||
|
||
if (this.isRelational("<")) {
|
||
typeNode.typeParameters = this.flowParseTypeParameterDeclaration();
|
||
} else {
|
||
typeNode.typeParameters = null;
|
||
}
|
||
|
||
this.expect(types.parenL);
|
||
const tmp = this.flowParseFunctionTypeParams();
|
||
typeNode.params = tmp.params;
|
||
typeNode.rest = tmp.rest;
|
||
this.expect(types.parenR);
|
||
[typeNode.returnType, node.predicate] = this.flowParseTypeAndPredicateInitialiser();
|
||
typeContainer.typeAnnotation = this.finishNode(typeNode, "FunctionTypeAnnotation");
|
||
id.typeAnnotation = this.finishNode(typeContainer, "TypeAnnotation");
|
||
this.resetEndLocation(id);
|
||
this.semicolon();
|
||
return this.finishNode(node, "DeclareFunction");
|
||
}
|
||
|
||
flowParseDeclare(node, insideModule) {
|
||
if (this.match(types._class)) {
|
||
return this.flowParseDeclareClass(node);
|
||
} else if (this.match(types._function)) {
|
||
return this.flowParseDeclareFunction(node);
|
||
} else if (this.match(types._var)) {
|
||
return this.flowParseDeclareVariable(node);
|
||
} else if (this.eatContextual("module")) {
|
||
if (this.match(types.dot)) {
|
||
return this.flowParseDeclareModuleExports(node);
|
||
} else {
|
||
if (insideModule) {
|
||
this.unexpected(this.state.lastTokStart, "`declare module` cannot be used inside another `declare module`");
|
||
}
|
||
|
||
return this.flowParseDeclareModule(node);
|
||
}
|
||
} else if (this.isContextual("type")) {
|
||
return this.flowParseDeclareTypeAlias(node);
|
||
} else if (this.isContextual("opaque")) {
|
||
return this.flowParseDeclareOpaqueType(node);
|
||
} else if (this.isContextual("interface")) {
|
||
return this.flowParseDeclareInterface(node);
|
||
} else if (this.match(types._export)) {
|
||
return this.flowParseDeclareExportDeclaration(node, insideModule);
|
||
} else {
|
||
throw this.unexpected();
|
||
}
|
||
}
|
||
|
||
flowParseDeclareVariable(node) {
|
||
this.next();
|
||
node.id = this.flowParseTypeAnnotatableIdentifier(true);
|
||
this.semicolon();
|
||
return this.finishNode(node, "DeclareVariable");
|
||
}
|
||
|
||
flowParseDeclareModule(node) {
|
||
this.scope.enter(SCOPE_OTHER);
|
||
|
||
if (this.match(types.string)) {
|
||
node.id = this.parseExprAtom();
|
||
} else {
|
||
node.id = this.parseIdentifier();
|
||
}
|
||
|
||
const bodyNode = node.body = this.startNode();
|
||
const body = bodyNode.body = [];
|
||
this.expect(types.braceL);
|
||
|
||
while (!this.match(types.braceR)) {
|
||
let bodyNode = this.startNode();
|
||
|
||
if (this.match(types._import)) {
|
||
this.next();
|
||
|
||
if (!this.isContextual("type") && !this.match(types._typeof)) {
|
||
this.unexpected(this.state.lastTokStart, "Imports within a `declare module` body must always be `import type` or `import typeof`");
|
||
}
|
||
|
||
this.parseImport(bodyNode);
|
||
} else {
|
||
this.expectContextual("declare", "Only declares and type imports are allowed inside declare module");
|
||
bodyNode = this.flowParseDeclare(bodyNode, true);
|
||
}
|
||
|
||
body.push(bodyNode);
|
||
}
|
||
|
||
this.scope.exit();
|
||
this.expect(types.braceR);
|
||
this.finishNode(bodyNode, "BlockStatement");
|
||
let kind = null;
|
||
let hasModuleExport = false;
|
||
const errorMessage = "Found both `declare module.exports` and `declare export` in the same module. " + "Modules can only have 1 since they are either an ES module or they are a CommonJS module";
|
||
body.forEach(bodyElement => {
|
||
if (isEsModuleType(bodyElement)) {
|
||
if (kind === "CommonJS") {
|
||
this.unexpected(bodyElement.start, errorMessage);
|
||
}
|
||
|
||
kind = "ES";
|
||
} else if (bodyElement.type === "DeclareModuleExports") {
|
||
if (hasModuleExport) {
|
||
this.unexpected(bodyElement.start, "Duplicate `declare module.exports` statement");
|
||
}
|
||
|
||
if (kind === "ES") this.unexpected(bodyElement.start, errorMessage);
|
||
kind = "CommonJS";
|
||
hasModuleExport = true;
|
||
}
|
||
});
|
||
node.kind = kind || "CommonJS";
|
||
return this.finishNode(node, "DeclareModule");
|
||
}
|
||
|
||
flowParseDeclareExportDeclaration(node, insideModule) {
|
||
this.expect(types._export);
|
||
|
||
if (this.eat(types._default)) {
|
||
if (this.match(types._function) || this.match(types._class)) {
|
||
node.declaration = this.flowParseDeclare(this.startNode());
|
||
} else {
|
||
node.declaration = this.flowParseType();
|
||
this.semicolon();
|
||
}
|
||
|
||
node.default = true;
|
||
return this.finishNode(node, "DeclareExportDeclaration");
|
||
} else {
|
||
if (this.match(types._const) || this.isLet() || (this.isContextual("type") || this.isContextual("interface")) && !insideModule) {
|
||
const label = this.state.value;
|
||
const suggestion = exportSuggestions[label];
|
||
this.unexpected(this.state.start, `\`declare export ${label}\` is not supported. Use \`${suggestion}\` instead`);
|
||
}
|
||
|
||
if (this.match(types._var) || this.match(types._function) || this.match(types._class) || this.isContextual("opaque")) {
|
||
node.declaration = this.flowParseDeclare(this.startNode());
|
||
node.default = false;
|
||
return this.finishNode(node, "DeclareExportDeclaration");
|
||
} else if (this.match(types.star) || this.match(types.braceL) || this.isContextual("interface") || this.isContextual("type") || this.isContextual("opaque")) {
|
||
node = this.parseExport(node);
|
||
|
||
if (node.type === "ExportNamedDeclaration") {
|
||
node.type = "ExportDeclaration";
|
||
node.default = false;
|
||
delete node.exportKind;
|
||
}
|
||
|
||
node.type = "Declare" + node.type;
|
||
return node;
|
||
}
|
||
}
|
||
|
||
throw this.unexpected();
|
||
}
|
||
|
||
flowParseDeclareModuleExports(node) {
|
||
this.next();
|
||
this.expectContextual("exports");
|
||
node.typeAnnotation = this.flowParseTypeAnnotation();
|
||
this.semicolon();
|
||
return this.finishNode(node, "DeclareModuleExports");
|
||
}
|
||
|
||
flowParseDeclareTypeAlias(node) {
|
||
this.next();
|
||
this.flowParseTypeAlias(node);
|
||
node.type = "DeclareTypeAlias";
|
||
return node;
|
||
}
|
||
|
||
flowParseDeclareOpaqueType(node) {
|
||
this.next();
|
||
this.flowParseOpaqueType(node, true);
|
||
node.type = "DeclareOpaqueType";
|
||
return node;
|
||
}
|
||
|
||
flowParseDeclareInterface(node) {
|
||
this.next();
|
||
this.flowParseInterfaceish(node);
|
||
return this.finishNode(node, "DeclareInterface");
|
||
}
|
||
|
||
flowParseInterfaceish(node, isClass = false) {
|
||
node.id = this.flowParseRestrictedIdentifier(!isClass);
|
||
|
||
if (this.isRelational("<")) {
|
||
node.typeParameters = this.flowParseTypeParameterDeclaration();
|
||
} else {
|
||
node.typeParameters = null;
|
||
}
|
||
|
||
node.extends = [];
|
||
node.implements = [];
|
||
node.mixins = [];
|
||
|
||
if (this.eat(types._extends)) {
|
||
do {
|
||
node.extends.push(this.flowParseInterfaceExtends());
|
||
} while (!isClass && this.eat(types.comma));
|
||
}
|
||
|
||
if (this.isContextual("mixins")) {
|
||
this.next();
|
||
|
||
do {
|
||
node.mixins.push(this.flowParseInterfaceExtends());
|
||
} while (this.eat(types.comma));
|
||
}
|
||
|
||
if (this.isContextual("implements")) {
|
||
this.next();
|
||
|
||
do {
|
||
node.implements.push(this.flowParseInterfaceExtends());
|
||
} while (this.eat(types.comma));
|
||
}
|
||
|
||
node.body = this.flowParseObjectType({
|
||
allowStatic: isClass,
|
||
allowExact: false,
|
||
allowSpread: false,
|
||
allowProto: isClass,
|
||
allowInexact: false
|
||
});
|
||
}
|
||
|
||
flowParseInterfaceExtends() {
|
||
const node = this.startNode();
|
||
node.id = this.flowParseQualifiedTypeIdentifier();
|
||
|
||
if (this.isRelational("<")) {
|
||
node.typeParameters = this.flowParseTypeParameterInstantiation();
|
||
} else {
|
||
node.typeParameters = null;
|
||
}
|
||
|
||
return this.finishNode(node, "InterfaceExtends");
|
||
}
|
||
|
||
flowParseInterface(node) {
|
||
this.flowParseInterfaceish(node);
|
||
return this.finishNode(node, "InterfaceDeclaration");
|
||
}
|
||
|
||
checkNotUnderscore(word) {
|
||
if (word === "_") {
|
||
throw this.unexpected(null, "`_` is only allowed as a type argument to call or new");
|
||
}
|
||
}
|
||
|
||
checkReservedType(word, startLoc) {
|
||
if (reservedTypes.indexOf(word) > -1) {
|
||
this.raise(startLoc, `Cannot overwrite reserved type ${word}`);
|
||
}
|
||
}
|
||
|
||
flowParseRestrictedIdentifier(liberal) {
|
||
this.checkReservedType(this.state.value, this.state.start);
|
||
return this.parseIdentifier(liberal);
|
||
}
|
||
|
||
flowParseTypeAlias(node) {
|
||
node.id = this.flowParseRestrictedIdentifier();
|
||
this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.start);
|
||
|
||
if (this.isRelational("<")) {
|
||
node.typeParameters = this.flowParseTypeParameterDeclaration();
|
||
} else {
|
||
node.typeParameters = null;
|
||
}
|
||
|
||
node.right = this.flowParseTypeInitialiser(types.eq);
|
||
this.semicolon();
|
||
return this.finishNode(node, "TypeAlias");
|
||
}
|
||
|
||
flowParseOpaqueType(node, declare) {
|
||
this.expectContextual("type");
|
||
node.id = this.flowParseRestrictedIdentifier(true);
|
||
this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.start);
|
||
|
||
if (this.isRelational("<")) {
|
||
node.typeParameters = this.flowParseTypeParameterDeclaration();
|
||
} else {
|
||
node.typeParameters = null;
|
||
}
|
||
|
||
node.supertype = null;
|
||
|
||
if (this.match(types.colon)) {
|
||
node.supertype = this.flowParseTypeInitialiser(types.colon);
|
||
}
|
||
|
||
node.impltype = null;
|
||
|
||
if (!declare) {
|
||
node.impltype = this.flowParseTypeInitialiser(types.eq);
|
||
}
|
||
|
||
this.semicolon();
|
||
return this.finishNode(node, "OpaqueType");
|
||
}
|
||
|
||
flowParseTypeParameter(requireDefault = false) {
|
||
const nodeStart = this.state.start;
|
||
const node = this.startNode();
|
||
const variance = this.flowParseVariance();
|
||
const ident = this.flowParseTypeAnnotatableIdentifier();
|
||
node.name = ident.name;
|
||
node.variance = variance;
|
||
node.bound = ident.typeAnnotation;
|
||
|
||
if (this.match(types.eq)) {
|
||
this.eat(types.eq);
|
||
node.default = this.flowParseType();
|
||
} else {
|
||
if (requireDefault) {
|
||
this.unexpected(nodeStart, "Type parameter declaration needs a default, since a preceding type parameter declaration has a default.");
|
||
}
|
||
}
|
||
|
||
return this.finishNode(node, "TypeParameter");
|
||
}
|
||
|
||
flowParseTypeParameterDeclaration() {
|
||
const oldInType = this.state.inType;
|
||
const node = this.startNode();
|
||
node.params = [];
|
||
this.state.inType = true;
|
||
|
||
if (this.isRelational("<") || this.match(types.jsxTagStart)) {
|
||
this.next();
|
||
} else {
|
||
this.unexpected();
|
||
}
|
||
|
||
let defaultRequired = false;
|
||
|
||
do {
|
||
const typeParameter = this.flowParseTypeParameter(defaultRequired);
|
||
node.params.push(typeParameter);
|
||
|
||
if (typeParameter.default) {
|
||
defaultRequired = true;
|
||
}
|
||
|
||
if (!this.isRelational(">")) {
|
||
this.expect(types.comma);
|
||
}
|
||
} while (!this.isRelational(">"));
|
||
|
||
this.expectRelational(">");
|
||
this.state.inType = oldInType;
|
||
return this.finishNode(node, "TypeParameterDeclaration");
|
||
}
|
||
|
||
flowParseTypeParameterInstantiation() {
|
||
const node = this.startNode();
|
||
const oldInType = this.state.inType;
|
||
node.params = [];
|
||
this.state.inType = true;
|
||
this.expectRelational("<");
|
||
const oldNoAnonFunctionType = this.state.noAnonFunctionType;
|
||
this.state.noAnonFunctionType = false;
|
||
|
||
while (!this.isRelational(">")) {
|
||
node.params.push(this.flowParseType());
|
||
|
||
if (!this.isRelational(">")) {
|
||
this.expect(types.comma);
|
||
}
|
||
}
|
||
|
||
this.state.noAnonFunctionType = oldNoAnonFunctionType;
|
||
this.expectRelational(">");
|
||
this.state.inType = oldInType;
|
||
return this.finishNode(node, "TypeParameterInstantiation");
|
||
}
|
||
|
||
flowParseTypeParameterInstantiationCallOrNew() {
|
||
const node = this.startNode();
|
||
const oldInType = this.state.inType;
|
||
node.params = [];
|
||
this.state.inType = true;
|
||
this.expectRelational("<");
|
||
|
||
while (!this.isRelational(">")) {
|
||
node.params.push(this.flowParseTypeOrImplicitInstantiation());
|
||
|
||
if (!this.isRelational(">")) {
|
||
this.expect(types.comma);
|
||
}
|
||
}
|
||
|
||
this.expectRelational(">");
|
||
this.state.inType = oldInType;
|
||
return this.finishNode(node, "TypeParameterInstantiation");
|
||
}
|
||
|
||
flowParseInterfaceType() {
|
||
const node = this.startNode();
|
||
this.expectContextual("interface");
|
||
node.extends = [];
|
||
|
||
if (this.eat(types._extends)) {
|
||
do {
|
||
node.extends.push(this.flowParseInterfaceExtends());
|
||
} while (this.eat(types.comma));
|
||
}
|
||
|
||
node.body = this.flowParseObjectType({
|
||
allowStatic: false,
|
||
allowExact: false,
|
||
allowSpread: false,
|
||
allowProto: false,
|
||
allowInexact: false
|
||
});
|
||
return this.finishNode(node, "InterfaceTypeAnnotation");
|
||
}
|
||
|
||
flowParseObjectPropertyKey() {
|
||
return this.match(types.num) || this.match(types.string) ? this.parseExprAtom() : this.parseIdentifier(true);
|
||
}
|
||
|
||
flowParseObjectTypeIndexer(node, isStatic, variance) {
|
||
node.static = isStatic;
|
||
|
||
if (this.lookahead().type === types.colon) {
|
||
node.id = this.flowParseObjectPropertyKey();
|
||
node.key = this.flowParseTypeInitialiser();
|
||
} else {
|
||
node.id = null;
|
||
node.key = this.flowParseType();
|
||
}
|
||
|
||
this.expect(types.bracketR);
|
||
node.value = this.flowParseTypeInitialiser();
|
||
node.variance = variance;
|
||
return this.finishNode(node, "ObjectTypeIndexer");
|
||
}
|
||
|
||
flowParseObjectTypeInternalSlot(node, isStatic) {
|
||
node.static = isStatic;
|
||
node.id = this.flowParseObjectPropertyKey();
|
||
this.expect(types.bracketR);
|
||
this.expect(types.bracketR);
|
||
|
||
if (this.isRelational("<") || this.match(types.parenL)) {
|
||
node.method = true;
|
||
node.optional = false;
|
||
node.value = this.flowParseObjectTypeMethodish(this.startNodeAt(node.start, node.loc.start));
|
||
} else {
|
||
node.method = false;
|
||
|
||
if (this.eat(types.question)) {
|
||
node.optional = true;
|
||
}
|
||
|
||
node.value = this.flowParseTypeInitialiser();
|
||
}
|
||
|
||
return this.finishNode(node, "ObjectTypeInternalSlot");
|
||
}
|
||
|
||
flowParseObjectTypeMethodish(node) {
|
||
node.params = [];
|
||
node.rest = null;
|
||
node.typeParameters = null;
|
||
|
||
if (this.isRelational("<")) {
|
||
node.typeParameters = this.flowParseTypeParameterDeclaration();
|
||
}
|
||
|
||
this.expect(types.parenL);
|
||
|
||
while (!this.match(types.parenR) && !this.match(types.ellipsis)) {
|
||
node.params.push(this.flowParseFunctionTypeParam());
|
||
|
||
if (!this.match(types.parenR)) {
|
||
this.expect(types.comma);
|
||
}
|
||
}
|
||
|
||
if (this.eat(types.ellipsis)) {
|
||
node.rest = this.flowParseFunctionTypeParam();
|
||
}
|
||
|
||
this.expect(types.parenR);
|
||
node.returnType = this.flowParseTypeInitialiser();
|
||
return this.finishNode(node, "FunctionTypeAnnotation");
|
||
}
|
||
|
||
flowParseObjectTypeCallProperty(node, isStatic) {
|
||
const valueNode = this.startNode();
|
||
node.static = isStatic;
|
||
node.value = this.flowParseObjectTypeMethodish(valueNode);
|
||
return this.finishNode(node, "ObjectTypeCallProperty");
|
||
}
|
||
|
||
flowParseObjectType({
|
||
allowStatic,
|
||
allowExact,
|
||
allowSpread,
|
||
allowProto,
|
||
allowInexact
|
||
}) {
|
||
const oldInType = this.state.inType;
|
||
this.state.inType = true;
|
||
const nodeStart = this.startNode();
|
||
nodeStart.callProperties = [];
|
||
nodeStart.properties = [];
|
||
nodeStart.indexers = [];
|
||
nodeStart.internalSlots = [];
|
||
let endDelim;
|
||
let exact;
|
||
let inexact = false;
|
||
|
||
if (allowExact && this.match(types.braceBarL)) {
|
||
this.expect(types.braceBarL);
|
||
endDelim = types.braceBarR;
|
||
exact = true;
|
||
} else {
|
||
this.expect(types.braceL);
|
||
endDelim = types.braceR;
|
||
exact = false;
|
||
}
|
||
|
||
nodeStart.exact = exact;
|
||
|
||
while (!this.match(endDelim)) {
|
||
let isStatic = false;
|
||
let protoStart = null;
|
||
const node = this.startNode();
|
||
|
||
if (allowProto && this.isContextual("proto")) {
|
||
const lookahead = this.lookahead();
|
||
|
||
if (lookahead.type !== types.colon && lookahead.type !== types.question) {
|
||
this.next();
|
||
protoStart = this.state.start;
|
||
allowStatic = false;
|
||
}
|
||
}
|
||
|
||
if (allowStatic && this.isContextual("static")) {
|
||
const lookahead = this.lookahead();
|
||
|
||
if (lookahead.type !== types.colon && lookahead.type !== types.question) {
|
||
this.next();
|
||
isStatic = true;
|
||
}
|
||
}
|
||
|
||
const variance = this.flowParseVariance();
|
||
|
||
if (this.eat(types.bracketL)) {
|
||
if (protoStart != null) {
|
||
this.unexpected(protoStart);
|
||
}
|
||
|
||
if (this.eat(types.bracketL)) {
|
||
if (variance) {
|
||
this.unexpected(variance.start);
|
||
}
|
||
|
||
nodeStart.internalSlots.push(this.flowParseObjectTypeInternalSlot(node, isStatic));
|
||
} else {
|
||
nodeStart.indexers.push(this.flowParseObjectTypeIndexer(node, isStatic, variance));
|
||
}
|
||
} else if (this.match(types.parenL) || this.isRelational("<")) {
|
||
if (protoStart != null) {
|
||
this.unexpected(protoStart);
|
||
}
|
||
|
||
if (variance) {
|
||
this.unexpected(variance.start);
|
||
}
|
||
|
||
nodeStart.callProperties.push(this.flowParseObjectTypeCallProperty(node, isStatic));
|
||
} else {
|
||
let kind = "init";
|
||
|
||
if (this.isContextual("get") || this.isContextual("set")) {
|
||
const lookahead = this.lookahead();
|
||
|
||
if (lookahead.type === types.name || lookahead.type === types.string || lookahead.type === types.num) {
|
||
kind = this.state.value;
|
||
this.next();
|
||
}
|
||
}
|
||
|
||
const propOrInexact = this.flowParseObjectTypeProperty(node, isStatic, protoStart, variance, kind, allowSpread, allowInexact);
|
||
|
||
if (propOrInexact === null) {
|
||
inexact = true;
|
||
} else {
|
||
nodeStart.properties.push(propOrInexact);
|
||
}
|
||
}
|
||
|
||
this.flowObjectTypeSemicolon();
|
||
}
|
||
|
||
this.expect(endDelim);
|
||
|
||
if (allowSpread) {
|
||
nodeStart.inexact = inexact;
|
||
}
|
||
|
||
const out = this.finishNode(nodeStart, "ObjectTypeAnnotation");
|
||
this.state.inType = oldInType;
|
||
return out;
|
||
}
|
||
|
||
flowParseObjectTypeProperty(node, isStatic, protoStart, variance, kind, allowSpread, allowInexact) {
|
||
if (this.match(types.ellipsis)) {
|
||
if (!allowSpread) {
|
||
this.unexpected(null, "Spread operator cannot appear in class or interface definitions");
|
||
}
|
||
|
||
if (protoStart != null) {
|
||
this.unexpected(protoStart);
|
||
}
|
||
|
||
if (variance) {
|
||
this.unexpected(variance.start, "Spread properties cannot have variance");
|
||
}
|
||
|
||
this.expect(types.ellipsis);
|
||
const isInexactToken = this.eat(types.comma) || this.eat(types.semi);
|
||
|
||
if (this.match(types.braceR)) {
|
||
if (allowInexact) return null;
|
||
this.unexpected(null, "Explicit inexact syntax is only allowed inside inexact objects");
|
||
}
|
||
|
||
if (this.match(types.braceBarR)) {
|
||
this.unexpected(null, "Explicit inexact syntax cannot appear inside an explicit exact object type");
|
||
}
|
||
|
||
if (isInexactToken) {
|
||
this.unexpected(null, "Explicit inexact syntax must appear at the end of an inexact object");
|
||
}
|
||
|
||
node.argument = this.flowParseType();
|
||
return this.finishNode(node, "ObjectTypeSpreadProperty");
|
||
} else {
|
||
node.key = this.flowParseObjectPropertyKey();
|
||
node.static = isStatic;
|
||
node.proto = protoStart != null;
|
||
node.kind = kind;
|
||
let optional = false;
|
||
|
||
if (this.isRelational("<") || this.match(types.parenL)) {
|
||
node.method = true;
|
||
|
||
if (protoStart != null) {
|
||
this.unexpected(protoStart);
|
||
}
|
||
|
||
if (variance) {
|
||
this.unexpected(variance.start);
|
||
}
|
||
|
||
node.value = this.flowParseObjectTypeMethodish(this.startNodeAt(node.start, node.loc.start));
|
||
|
||
if (kind === "get" || kind === "set") {
|
||
this.flowCheckGetterSetterParams(node);
|
||
}
|
||
} else {
|
||
if (kind !== "init") this.unexpected();
|
||
node.method = false;
|
||
|
||
if (this.eat(types.question)) {
|
||
optional = true;
|
||
}
|
||
|
||
node.value = this.flowParseTypeInitialiser();
|
||
node.variance = variance;
|
||
}
|
||
|
||
node.optional = optional;
|
||
return this.finishNode(node, "ObjectTypeProperty");
|
||
}
|
||
}
|
||
|
||
flowCheckGetterSetterParams(property) {
|
||
const paramCount = property.kind === "get" ? 0 : 1;
|
||
const start = property.start;
|
||
const length = property.value.params.length + (property.value.rest ? 1 : 0);
|
||
|
||
if (length !== paramCount) {
|
||
if (property.kind === "get") {
|
||
this.raise(start, "getter must not have any formal parameters");
|
||
} else {
|
||
this.raise(start, "setter must have exactly one formal parameter");
|
||
}
|
||
}
|
||
|
||
if (property.kind === "set" && property.value.rest) {
|
||
this.raise(start, "setter function argument must not be a rest parameter");
|
||
}
|
||
}
|
||
|
||
flowObjectTypeSemicolon() {
|
||
if (!this.eat(types.semi) && !this.eat(types.comma) && !this.match(types.braceR) && !this.match(types.braceBarR)) {
|
||
this.unexpected();
|
||
}
|
||
}
|
||
|
||
flowParseQualifiedTypeIdentifier(startPos, startLoc, id) {
|
||
startPos = startPos || this.state.start;
|
||
startLoc = startLoc || this.state.startLoc;
|
||
let node = id || this.parseIdentifier();
|
||
|
||
while (this.eat(types.dot)) {
|
||
const node2 = this.startNodeAt(startPos, startLoc);
|
||
node2.qualification = node;
|
||
node2.id = this.parseIdentifier();
|
||
node = this.finishNode(node2, "QualifiedTypeIdentifier");
|
||
}
|
||
|
||
return node;
|
||
}
|
||
|
||
flowParseGenericType(startPos, startLoc, id) {
|
||
const node = this.startNodeAt(startPos, startLoc);
|
||
node.typeParameters = null;
|
||
node.id = this.flowParseQualifiedTypeIdentifier(startPos, startLoc, id);
|
||
|
||
if (this.isRelational("<")) {
|
||
node.typeParameters = this.flowParseTypeParameterInstantiation();
|
||
}
|
||
|
||
return this.finishNode(node, "GenericTypeAnnotation");
|
||
}
|
||
|
||
flowParseTypeofType() {
|
||
const node = this.startNode();
|
||
this.expect(types._typeof);
|
||
node.argument = this.flowParsePrimaryType();
|
||
return this.finishNode(node, "TypeofTypeAnnotation");
|
||
}
|
||
|
||
flowParseTupleType() {
|
||
const node = this.startNode();
|
||
node.types = [];
|
||
this.expect(types.bracketL);
|
||
|
||
while (this.state.pos < this.length && !this.match(types.bracketR)) {
|
||
node.types.push(this.flowParseType());
|
||
if (this.match(types.bracketR)) break;
|
||
this.expect(types.comma);
|
||
}
|
||
|
||
this.expect(types.bracketR);
|
||
return this.finishNode(node, "TupleTypeAnnotation");
|
||
}
|
||
|
||
flowParseFunctionTypeParam() {
|
||
let name = null;
|
||
let optional = false;
|
||
let typeAnnotation = null;
|
||
const node = this.startNode();
|
||
const lh = this.lookahead();
|
||
|
||
if (lh.type === types.colon || lh.type === types.question) {
|
||
name = this.parseIdentifier();
|
||
|
||
if (this.eat(types.question)) {
|
||
optional = true;
|
||
}
|
||
|
||
typeAnnotation = this.flowParseTypeInitialiser();
|
||
} else {
|
||
typeAnnotation = this.flowParseType();
|
||
}
|
||
|
||
node.name = name;
|
||
node.optional = optional;
|
||
node.typeAnnotation = typeAnnotation;
|
||
return this.finishNode(node, "FunctionTypeParam");
|
||
}
|
||
|
||
reinterpretTypeAsFunctionTypeParam(type) {
|
||
const node = this.startNodeAt(type.start, type.loc.start);
|
||
node.name = null;
|
||
node.optional = false;
|
||
node.typeAnnotation = type;
|
||
return this.finishNode(node, "FunctionTypeParam");
|
||
}
|
||
|
||
flowParseFunctionTypeParams(params = []) {
|
||
let rest = null;
|
||
|
||
while (!this.match(types.parenR) && !this.match(types.ellipsis)) {
|
||
params.push(this.flowParseFunctionTypeParam());
|
||
|
||
if (!this.match(types.parenR)) {
|
||
this.expect(types.comma);
|
||
}
|
||
}
|
||
|
||
if (this.eat(types.ellipsis)) {
|
||
rest = this.flowParseFunctionTypeParam();
|
||
}
|
||
|
||
return {
|
||
params,
|
||
rest
|
||
};
|
||
}
|
||
|
||
flowIdentToTypeAnnotation(startPos, startLoc, node, id) {
|
||
switch (id.name) {
|
||
case "any":
|
||
return this.finishNode(node, "AnyTypeAnnotation");
|
||
|
||
case "bool":
|
||
case "boolean":
|
||
return this.finishNode(node, "BooleanTypeAnnotation");
|
||
|
||
case "mixed":
|
||
return this.finishNode(node, "MixedTypeAnnotation");
|
||
|
||
case "empty":
|
||
return this.finishNode(node, "EmptyTypeAnnotation");
|
||
|
||
case "number":
|
||
return this.finishNode(node, "NumberTypeAnnotation");
|
||
|
||
case "string":
|
||
return this.finishNode(node, "StringTypeAnnotation");
|
||
|
||
default:
|
||
this.checkNotUnderscore(id.name);
|
||
return this.flowParseGenericType(startPos, startLoc, id);
|
||
}
|
||
}
|
||
|
||
flowParsePrimaryType() {
|
||
const startPos = this.state.start;
|
||
const startLoc = this.state.startLoc;
|
||
const node = this.startNode();
|
||
let tmp;
|
||
let type;
|
||
let isGroupedType = false;
|
||
const oldNoAnonFunctionType = this.state.noAnonFunctionType;
|
||
|
||
switch (this.state.type) {
|
||
case types.name:
|
||
if (this.isContextual("interface")) {
|
||
return this.flowParseInterfaceType();
|
||
}
|
||
|
||
return this.flowIdentToTypeAnnotation(startPos, startLoc, node, this.parseIdentifier());
|
||
|
||
case types.braceL:
|
||
return this.flowParseObjectType({
|
||
allowStatic: false,
|
||
allowExact: false,
|
||
allowSpread: true,
|
||
allowProto: false,
|
||
allowInexact: true
|
||
});
|
||
|
||
case types.braceBarL:
|
||
return this.flowParseObjectType({
|
||
allowStatic: false,
|
||
allowExact: true,
|
||
allowSpread: true,
|
||
allowProto: false,
|
||
allowInexact: false
|
||
});
|
||
|
||
case types.bracketL:
|
||
this.state.noAnonFunctionType = false;
|
||
type = this.flowParseTupleType();
|
||
this.state.noAnonFunctionType = oldNoAnonFunctionType;
|
||
return type;
|
||
|
||
case types.relational:
|
||
if (this.state.value === "<") {
|
||
node.typeParameters = this.flowParseTypeParameterDeclaration();
|
||
this.expect(types.parenL);
|
||
tmp = this.flowParseFunctionTypeParams();
|
||
node.params = tmp.params;
|
||
node.rest = tmp.rest;
|
||
this.expect(types.parenR);
|
||
this.expect(types.arrow);
|
||
node.returnType = this.flowParseType();
|
||
return this.finishNode(node, "FunctionTypeAnnotation");
|
||
}
|
||
|
||
break;
|
||
|
||
case types.parenL:
|
||
this.next();
|
||
|
||
if (!this.match(types.parenR) && !this.match(types.ellipsis)) {
|
||
if (this.match(types.name)) {
|
||
const token = this.lookahead().type;
|
||
isGroupedType = token !== types.question && token !== types.colon;
|
||
} else {
|
||
isGroupedType = true;
|
||
}
|
||
}
|
||
|
||
if (isGroupedType) {
|
||
this.state.noAnonFunctionType = false;
|
||
type = this.flowParseType();
|
||
this.state.noAnonFunctionType = oldNoAnonFunctionType;
|
||
|
||
if (this.state.noAnonFunctionType || !(this.match(types.comma) || this.match(types.parenR) && this.lookahead().type === types.arrow)) {
|
||
this.expect(types.parenR);
|
||
return type;
|
||
} else {
|
||
this.eat(types.comma);
|
||
}
|
||
}
|
||
|
||
if (type) {
|
||
tmp = this.flowParseFunctionTypeParams([this.reinterpretTypeAsFunctionTypeParam(type)]);
|
||
} else {
|
||
tmp = this.flowParseFunctionTypeParams();
|
||
}
|
||
|
||
node.params = tmp.params;
|
||
node.rest = tmp.rest;
|
||
this.expect(types.parenR);
|
||
this.expect(types.arrow);
|
||
node.returnType = this.flowParseType();
|
||
node.typeParameters = null;
|
||
return this.finishNode(node, "FunctionTypeAnnotation");
|
||
|
||
case types.string:
|
||
return this.parseLiteral(this.state.value, "StringLiteralTypeAnnotation");
|
||
|
||
case types._true:
|
||
case types._false:
|
||
node.value = this.match(types._true);
|
||
this.next();
|
||
return this.finishNode(node, "BooleanLiteralTypeAnnotation");
|
||
|
||
case types.plusMin:
|
||
if (this.state.value === "-") {
|
||
this.next();
|
||
|
||
if (this.match(types.num)) {
|
||
return this.parseLiteral(-this.state.value, "NumberLiteralTypeAnnotation", node.start, node.loc.start);
|
||
}
|
||
|
||
if (this.match(types.bigint)) {
|
||
return this.parseLiteral(-this.state.value, "BigIntLiteralTypeAnnotation", node.start, node.loc.start);
|
||
}
|
||
|
||
this.unexpected(null, `Unexpected token, expected "number" or "bigint"`);
|
||
}
|
||
|
||
this.unexpected();
|
||
|
||
case types.num:
|
||
return this.parseLiteral(this.state.value, "NumberLiteralTypeAnnotation");
|
||
|
||
case types.bigint:
|
||
return this.parseLiteral(this.state.value, "BigIntLiteralTypeAnnotation");
|
||
|
||
case types._void:
|
||
this.next();
|
||
return this.finishNode(node, "VoidTypeAnnotation");
|
||
|
||
case types._null:
|
||
this.next();
|
||
return this.finishNode(node, "NullLiteralTypeAnnotation");
|
||
|
||
case types._this:
|
||
this.next();
|
||
return this.finishNode(node, "ThisTypeAnnotation");
|
||
|
||
case types.star:
|
||
this.next();
|
||
return this.finishNode(node, "ExistsTypeAnnotation");
|
||
|
||
default:
|
||
if (this.state.type.keyword === "typeof") {
|
||
return this.flowParseTypeofType();
|
||
} else if (this.state.type.keyword) {
|
||
const label = this.state.type.label;
|
||
this.next();
|
||
return super.createIdentifier(node, label);
|
||
}
|
||
|
||
}
|
||
|
||
throw this.unexpected();
|
||
}
|
||
|
||
flowParsePostfixType() {
|
||
const startPos = this.state.start,
|
||
startLoc = this.state.startLoc;
|
||
let type = this.flowParsePrimaryType();
|
||
|
||
while (this.match(types.bracketL) && !this.canInsertSemicolon()) {
|
||
const node = this.startNodeAt(startPos, startLoc);
|
||
node.elementType = type;
|
||
this.expect(types.bracketL);
|
||
this.expect(types.bracketR);
|
||
type = this.finishNode(node, "ArrayTypeAnnotation");
|
||
}
|
||
|
||
return type;
|
||
}
|
||
|
||
flowParsePrefixType() {
|
||
const node = this.startNode();
|
||
|
||
if (this.eat(types.question)) {
|
||
node.typeAnnotation = this.flowParsePrefixType();
|
||
return this.finishNode(node, "NullableTypeAnnotation");
|
||
} else {
|
||
return this.flowParsePostfixType();
|
||
}
|
||
}
|
||
|
||
flowParseAnonFunctionWithoutParens() {
|
||
const param = this.flowParsePrefixType();
|
||
|
||
if (!this.state.noAnonFunctionType && this.eat(types.arrow)) {
|
||
const node = this.startNodeAt(param.start, param.loc.start);
|
||
node.params = [this.reinterpretTypeAsFunctionTypeParam(param)];
|
||
node.rest = null;
|
||
node.returnType = this.flowParseType();
|
||
node.typeParameters = null;
|
||
return this.finishNode(node, "FunctionTypeAnnotation");
|
||
}
|
||
|
||
return param;
|
||
}
|
||
|
||
flowParseIntersectionType() {
|
||
const node = this.startNode();
|
||
this.eat(types.bitwiseAND);
|
||
const type = this.flowParseAnonFunctionWithoutParens();
|
||
node.types = [type];
|
||
|
||
while (this.eat(types.bitwiseAND)) {
|
||
node.types.push(this.flowParseAnonFunctionWithoutParens());
|
||
}
|
||
|
||
return node.types.length === 1 ? type : this.finishNode(node, "IntersectionTypeAnnotation");
|
||
}
|
||
|
||
flowParseUnionType() {
|
||
const node = this.startNode();
|
||
this.eat(types.bitwiseOR);
|
||
const type = this.flowParseIntersectionType();
|
||
node.types = [type];
|
||
|
||
while (this.eat(types.bitwiseOR)) {
|
||
node.types.push(this.flowParseIntersectionType());
|
||
}
|
||
|
||
return node.types.length === 1 ? type : this.finishNode(node, "UnionTypeAnnotation");
|
||
}
|
||
|
||
flowParseType() {
|
||
const oldInType = this.state.inType;
|
||
this.state.inType = true;
|
||
const type = this.flowParseUnionType();
|
||
this.state.inType = oldInType;
|
||
this.state.exprAllowed = this.state.exprAllowed || this.state.noAnonFunctionType;
|
||
return type;
|
||
}
|
||
|
||
flowParseTypeOrImplicitInstantiation() {
|
||
if (this.state.type === types.name && this.state.value === "_") {
|
||
const startPos = this.state.start;
|
||
const startLoc = this.state.startLoc;
|
||
const node = this.parseIdentifier();
|
||
return this.flowParseGenericType(startPos, startLoc, node);
|
||
} else {
|
||
return this.flowParseType();
|
||
}
|
||
}
|
||
|
||
flowParseTypeAnnotation() {
|
||
const node = this.startNode();
|
||
node.typeAnnotation = this.flowParseTypeInitialiser();
|
||
return this.finishNode(node, "TypeAnnotation");
|
||
}
|
||
|
||
flowParseTypeAnnotatableIdentifier(allowPrimitiveOverride) {
|
||
const ident = allowPrimitiveOverride ? this.parseIdentifier() : this.flowParseRestrictedIdentifier();
|
||
|
||
if (this.match(types.colon)) {
|
||
ident.typeAnnotation = this.flowParseTypeAnnotation();
|
||
this.resetEndLocation(ident);
|
||
}
|
||
|
||
return ident;
|
||
}
|
||
|
||
typeCastToParameter(node) {
|
||
node.expression.typeAnnotation = node.typeAnnotation;
|
||
this.resetEndLocation(node.expression, node.typeAnnotation.end, node.typeAnnotation.loc.end);
|
||
return node.expression;
|
||
}
|
||
|
||
flowParseVariance() {
|
||
let variance = null;
|
||
|
||
if (this.match(types.plusMin)) {
|
||
variance = this.startNode();
|
||
|
||
if (this.state.value === "+") {
|
||
variance.kind = "plus";
|
||
} else {
|
||
variance.kind = "minus";
|
||
}
|
||
|
||
this.next();
|
||
this.finishNode(variance, "Variance");
|
||
}
|
||
|
||
return variance;
|
||
}
|
||
|
||
parseFunctionBody(node, allowExpressionBody, isMethod = false) {
|
||
if (allowExpressionBody) {
|
||
return this.forwardNoArrowParamsConversionAt(node, () => super.parseFunctionBody(node, true, isMethod));
|
||
}
|
||
|
||
return super.parseFunctionBody(node, false, isMethod);
|
||
}
|
||
|
||
parseFunctionBodyAndFinish(node, type, isMethod = false) {
|
||
if (this.match(types.colon)) {
|
||
const typeNode = this.startNode();
|
||
[typeNode.typeAnnotation, node.predicate] = this.flowParseTypeAndPredicateInitialiser();
|
||
node.returnType = typeNode.typeAnnotation ? this.finishNode(typeNode, "TypeAnnotation") : null;
|
||
}
|
||
|
||
super.parseFunctionBodyAndFinish(node, type, isMethod);
|
||
}
|
||
|
||
parseStatement(context, topLevel) {
|
||
if (this.state.strict && this.match(types.name) && this.state.value === "interface") {
|
||
const node = this.startNode();
|
||
this.next();
|
||
return this.flowParseInterface(node);
|
||
} else {
|
||
const stmt = super.parseStatement(context, topLevel);
|
||
|
||
if (this.flowPragma === undefined && !this.isValidDirective(stmt)) {
|
||
this.flowPragma = null;
|
||
}
|
||
|
||
return stmt;
|
||
}
|
||
}
|
||
|
||
parseExpressionStatement(node, expr) {
|
||
if (expr.type === "Identifier") {
|
||
if (expr.name === "declare") {
|
||
if (this.match(types._class) || this.match(types.name) || this.match(types._function) || this.match(types._var) || this.match(types._export)) {
|
||
return this.flowParseDeclare(node);
|
||
}
|
||
} else if (this.match(types.name)) {
|
||
if (expr.name === "interface") {
|
||
return this.flowParseInterface(node);
|
||
} else if (expr.name === "type") {
|
||
return this.flowParseTypeAlias(node);
|
||
} else if (expr.name === "opaque") {
|
||
return this.flowParseOpaqueType(node, false);
|
||
}
|
||
}
|
||
}
|
||
|
||
return super.parseExpressionStatement(node, expr);
|
||
}
|
||
|
||
shouldParseExportDeclaration() {
|
||
return this.isContextual("type") || this.isContextual("interface") || this.isContextual("opaque") || super.shouldParseExportDeclaration();
|
||
}
|
||
|
||
isExportDefaultSpecifier() {
|
||
if (this.match(types.name) && (this.state.value === "type" || this.state.value === "interface" || this.state.value === "opaque")) {
|
||
return false;
|
||
}
|
||
|
||
return super.isExportDefaultSpecifier();
|
||
}
|
||
|
||
parseConditional(expr, noIn, startPos, startLoc, refNeedsArrowPos) {
|
||
if (!this.match(types.question)) return expr;
|
||
|
||
if (refNeedsArrowPos) {
|
||
const state = this.state.clone();
|
||
|
||
try {
|
||
return super.parseConditional(expr, noIn, startPos, startLoc);
|
||
} catch (err) {
|
||
if (err instanceof SyntaxError) {
|
||
this.state = state;
|
||
refNeedsArrowPos.start = err.pos || this.state.start;
|
||
return expr;
|
||
} else {
|
||
throw err;
|
||
}
|
||
}
|
||
}
|
||
|
||
this.expect(types.question);
|
||
const state = this.state.clone();
|
||
const originalNoArrowAt = this.state.noArrowAt;
|
||
const node = this.startNodeAt(startPos, startLoc);
|
||
let {
|
||
consequent,
|
||
failed
|
||
} = this.tryParseConditionalConsequent();
|
||
let [valid, invalid] = this.getArrowLikeExpressions(consequent);
|
||
|
||
if (failed || invalid.length > 0) {
|
||
const noArrowAt = [...originalNoArrowAt];
|
||
|
||
if (invalid.length > 0) {
|
||
this.state = state;
|
||
this.state.noArrowAt = noArrowAt;
|
||
|
||
for (let i = 0; i < invalid.length; i++) {
|
||
noArrowAt.push(invalid[i].start);
|
||
}
|
||
|
||
({
|
||
consequent,
|
||
failed
|
||
} = this.tryParseConditionalConsequent());
|
||
[valid, invalid] = this.getArrowLikeExpressions(consequent);
|
||
}
|
||
|
||
if (failed && valid.length > 1) {
|
||
this.raise(state.start, "Ambiguous expression: wrap the arrow functions in parentheses to disambiguate.");
|
||
}
|
||
|
||
if (failed && valid.length === 1) {
|
||
this.state = state;
|
||
this.state.noArrowAt = noArrowAt.concat(valid[0].start);
|
||
({
|
||
consequent,
|
||
failed
|
||
} = this.tryParseConditionalConsequent());
|
||
}
|
||
|
||
this.getArrowLikeExpressions(consequent, true);
|
||
}
|
||
|
||
this.state.noArrowAt = originalNoArrowAt;
|
||
this.expect(types.colon);
|
||
node.test = expr;
|
||
node.consequent = consequent;
|
||
node.alternate = this.forwardNoArrowParamsConversionAt(node, () => this.parseMaybeAssign(noIn, undefined, undefined, undefined));
|
||
return this.finishNode(node, "ConditionalExpression");
|
||
}
|
||
|
||
tryParseConditionalConsequent() {
|
||
this.state.noArrowParamsConversionAt.push(this.state.start);
|
||
const consequent = this.parseMaybeAssign();
|
||
const failed = !this.match(types.colon);
|
||
this.state.noArrowParamsConversionAt.pop();
|
||
return {
|
||
consequent,
|
||
failed
|
||
};
|
||
}
|
||
|
||
getArrowLikeExpressions(node, disallowInvalid) {
|
||
const stack = [node];
|
||
const arrows = [];
|
||
|
||
while (stack.length !== 0) {
|
||
const node = stack.pop();
|
||
|
||
if (node.type === "ArrowFunctionExpression") {
|
||
if (node.typeParameters || !node.returnType) {
|
||
this.toAssignableList(node.params, true, "arrow function parameters");
|
||
this.scope.enter(functionFlags(false, false) | SCOPE_ARROW);
|
||
super.checkParams(node, false, true);
|
||
this.scope.exit();
|
||
} else {
|
||
arrows.push(node);
|
||
}
|
||
|
||
stack.push(node.body);
|
||
} else if (node.type === "ConditionalExpression") {
|
||
stack.push(node.consequent);
|
||
stack.push(node.alternate);
|
||
}
|
||
}
|
||
|
||
if (disallowInvalid) {
|
||
for (let i = 0; i < arrows.length; i++) {
|
||
this.toAssignableList(node.params, true, "arrow function parameters");
|
||
}
|
||
|
||
return [arrows, []];
|
||
}
|
||
|
||
return partition(arrows, node => {
|
||
try {
|
||
this.toAssignableList(node.params, true, "arrow function parameters");
|
||
return true;
|
||
} catch (err) {
|
||
return false;
|
||
}
|
||
});
|
||
}
|
||
|
||
forwardNoArrowParamsConversionAt(node, parse) {
|
||
let result;
|
||
|
||
if (this.state.noArrowParamsConversionAt.indexOf(node.start) !== -1) {
|
||
this.state.noArrowParamsConversionAt.push(this.state.start);
|
||
result = parse();
|
||
this.state.noArrowParamsConversionAt.pop();
|
||
} else {
|
||
result = parse();
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
parseParenItem(node, startPos, startLoc) {
|
||
node = super.parseParenItem(node, startPos, startLoc);
|
||
|
||
if (this.eat(types.question)) {
|
||
node.optional = true;
|
||
this.resetEndLocation(node);
|
||
}
|
||
|
||
if (this.match(types.colon)) {
|
||
const typeCastNode = this.startNodeAt(startPos, startLoc);
|
||
typeCastNode.expression = node;
|
||
typeCastNode.typeAnnotation = this.flowParseTypeAnnotation();
|
||
return this.finishNode(typeCastNode, "TypeCastExpression");
|
||
}
|
||
|
||
return node;
|
||
}
|
||
|
||
assertModuleNodeAllowed(node) {
|
||
if (node.type === "ImportDeclaration" && (node.importKind === "type" || node.importKind === "typeof") || node.type === "ExportNamedDeclaration" && node.exportKind === "type" || node.type === "ExportAllDeclaration" && node.exportKind === "type") {
|
||
return;
|
||
}
|
||
|
||
super.assertModuleNodeAllowed(node);
|
||
}
|
||
|
||
parseExport(node) {
|
||
const decl = super.parseExport(node);
|
||
|
||
if (decl.type === "ExportNamedDeclaration" || decl.type === "ExportAllDeclaration") {
|
||
decl.exportKind = decl.exportKind || "value";
|
||
}
|
||
|
||
return decl;
|
||
}
|
||
|
||
parseExportDeclaration(node) {
|
||
if (this.isContextual("type")) {
|
||
node.exportKind = "type";
|
||
const declarationNode = this.startNode();
|
||
this.next();
|
||
|
||
if (this.match(types.braceL)) {
|
||
node.specifiers = this.parseExportSpecifiers();
|
||
this.parseExportFrom(node);
|
||
return null;
|
||
} else {
|
||
return this.flowParseTypeAlias(declarationNode);
|
||
}
|
||
} else if (this.isContextual("opaque")) {
|
||
node.exportKind = "type";
|
||
const declarationNode = this.startNode();
|
||
this.next();
|
||
return this.flowParseOpaqueType(declarationNode, false);
|
||
} else if (this.isContextual("interface")) {
|
||
node.exportKind = "type";
|
||
const declarationNode = this.startNode();
|
||
this.next();
|
||
return this.flowParseInterface(declarationNode);
|
||
} else {
|
||
return super.parseExportDeclaration(node);
|
||
}
|
||
}
|
||
|
||
eatExportStar(node) {
|
||
if (super.eatExportStar(...arguments)) return true;
|
||
|
||
if (this.isContextual("type") && this.lookahead().type === types.star) {
|
||
node.exportKind = "type";
|
||
this.next();
|
||
this.next();
|
||
return true;
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
maybeParseExportNamespaceSpecifier(node) {
|
||
const pos = this.state.start;
|
||
const hasNamespace = super.maybeParseExportNamespaceSpecifier(node);
|
||
|
||
if (hasNamespace && node.exportKind === "type") {
|
||
this.unexpected(pos);
|
||
}
|
||
|
||
return hasNamespace;
|
||
}
|
||
|
||
parseClassId(node, isStatement, optionalId) {
|
||
super.parseClassId(node, isStatement, optionalId);
|
||
|
||
if (this.isRelational("<")) {
|
||
node.typeParameters = this.flowParseTypeParameterDeclaration();
|
||
}
|
||
}
|
||
|
||
getTokenFromCode(code) {
|
||
const next = this.input.charCodeAt(this.state.pos + 1);
|
||
|
||
if (code === 123 && next === 124) {
|
||
return this.finishOp(types.braceBarL, 2);
|
||
} else if (this.state.inType && (code === 62 || code === 60)) {
|
||
return this.finishOp(types.relational, 1);
|
||
} else if (isIteratorStart(code, next)) {
|
||
this.state.isIterator = true;
|
||
return super.readWord();
|
||
} else {
|
||
return super.getTokenFromCode(code);
|
||
}
|
||
}
|
||
|
||
toAssignable(node, isBinding, contextDescription) {
|
||
if (node.type === "TypeCastExpression") {
|
||
return super.toAssignable(this.typeCastToParameter(node), isBinding, contextDescription);
|
||
} else {
|
||
return super.toAssignable(node, isBinding, contextDescription);
|
||
}
|
||
}
|
||
|
||
toAssignableList(exprList, isBinding, contextDescription) {
|
||
for (let i = 0; i < exprList.length; i++) {
|
||
const expr = exprList[i];
|
||
|
||
if (expr && expr.type === "TypeCastExpression") {
|
||
exprList[i] = this.typeCastToParameter(expr);
|
||
}
|
||
}
|
||
|
||
return super.toAssignableList(exprList, isBinding, contextDescription);
|
||
}
|
||
|
||
toReferencedList(exprList, isParenthesizedExpr) {
|
||
for (let i = 0; i < exprList.length; i++) {
|
||
const expr = exprList[i];
|
||
|
||
if (expr && expr.type === "TypeCastExpression" && (!expr.extra || !expr.extra.parenthesized) && (exprList.length > 1 || !isParenthesizedExpr)) {
|
||
this.raise(expr.typeAnnotation.start, "The type cast expression is expected to be wrapped with parenthesis");
|
||
}
|
||
}
|
||
|
||
return exprList;
|
||
}
|
||
|
||
checkLVal(expr, bindingType = BIND_NONE, checkClashes, contextDescription) {
|
||
if (expr.type !== "TypeCastExpression") {
|
||
return super.checkLVal(expr, bindingType, checkClashes, contextDescription);
|
||
}
|
||
}
|
||
|
||
parseClassProperty(node) {
|
||
if (this.match(types.colon)) {
|
||
node.typeAnnotation = this.flowParseTypeAnnotation();
|
||
}
|
||
|
||
return super.parseClassProperty(node);
|
||
}
|
||
|
||
parseClassPrivateProperty(node) {
|
||
if (this.match(types.colon)) {
|
||
node.typeAnnotation = this.flowParseTypeAnnotation();
|
||
}
|
||
|
||
return super.parseClassPrivateProperty(node);
|
||
}
|
||
|
||
isClassMethod() {
|
||
return this.isRelational("<") || super.isClassMethod();
|
||
}
|
||
|
||
isClassProperty() {
|
||
return this.match(types.colon) || super.isClassProperty();
|
||
}
|
||
|
||
isNonstaticConstructor(method) {
|
||
return !this.match(types.colon) && super.isNonstaticConstructor(method);
|
||
}
|
||
|
||
pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
|
||
if (method.variance) {
|
||
this.unexpected(method.variance.start);
|
||
}
|
||
|
||
delete method.variance;
|
||
|
||
if (this.isRelational("<")) {
|
||
method.typeParameters = this.flowParseTypeParameterDeclaration();
|
||
}
|
||
|
||
super.pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper);
|
||
}
|
||
|
||
pushClassPrivateMethod(classBody, method, isGenerator, isAsync) {
|
||
if (method.variance) {
|
||
this.unexpected(method.variance.start);
|
||
}
|
||
|
||
delete method.variance;
|
||
|
||
if (this.isRelational("<")) {
|
||
method.typeParameters = this.flowParseTypeParameterDeclaration();
|
||
}
|
||
|
||
super.pushClassPrivateMethod(classBody, method, isGenerator, isAsync);
|
||
}
|
||
|
||
parseClassSuper(node) {
|
||
super.parseClassSuper(node);
|
||
|
||
if (node.superClass && this.isRelational("<")) {
|
||
node.superTypeParameters = this.flowParseTypeParameterInstantiation();
|
||
}
|
||
|
||
if (this.isContextual("implements")) {
|
||
this.next();
|
||
const implemented = node.implements = [];
|
||
|
||
do {
|
||
const node = this.startNode();
|
||
node.id = this.flowParseRestrictedIdentifier(true);
|
||
|
||
if (this.isRelational("<")) {
|
||
node.typeParameters = this.flowParseTypeParameterInstantiation();
|
||
} else {
|
||
node.typeParameters = null;
|
||
}
|
||
|
||
implemented.push(this.finishNode(node, "ClassImplements"));
|
||
} while (this.eat(types.comma));
|
||
}
|
||
}
|
||
|
||
parsePropertyName(node) {
|
||
const variance = this.flowParseVariance();
|
||
const key = super.parsePropertyName(node);
|
||
node.variance = variance;
|
||
return key;
|
||
}
|
||
|
||
parseObjPropValue(prop, startPos, startLoc, isGenerator, isAsync, isPattern, refShorthandDefaultPos, containsEsc) {
|
||
if (prop.variance) {
|
||
this.unexpected(prop.variance.start);
|
||
}
|
||
|
||
delete prop.variance;
|
||
let typeParameters;
|
||
|
||
if (this.isRelational("<")) {
|
||
typeParameters = this.flowParseTypeParameterDeclaration();
|
||
if (!this.match(types.parenL)) this.unexpected();
|
||
}
|
||
|
||
super.parseObjPropValue(prop, startPos, startLoc, isGenerator, isAsync, isPattern, refShorthandDefaultPos, containsEsc);
|
||
|
||
if (typeParameters) {
|
||
(prop.value || prop).typeParameters = typeParameters;
|
||
}
|
||
}
|
||
|
||
parseAssignableListItemTypes(param) {
|
||
if (this.eat(types.question)) {
|
||
if (param.type !== "Identifier") {
|
||
throw this.raise(param.start, "A binding pattern parameter cannot be optional in an implementation signature.");
|
||
}
|
||
|
||
param.optional = true;
|
||
}
|
||
|
||
if (this.match(types.colon)) {
|
||
param.typeAnnotation = this.flowParseTypeAnnotation();
|
||
}
|
||
|
||
this.resetEndLocation(param);
|
||
return param;
|
||
}
|
||
|
||
parseMaybeDefault(startPos, startLoc, left) {
|
||
const node = super.parseMaybeDefault(startPos, startLoc, left);
|
||
|
||
if (node.type === "AssignmentPattern" && node.typeAnnotation && node.right.start < node.typeAnnotation.start) {
|
||
this.raise(node.typeAnnotation.start, "Type annotations must come before default assignments, " + "e.g. instead of `age = 25: number` use `age: number = 25`");
|
||
}
|
||
|
||
return node;
|
||
}
|
||
|
||
shouldParseDefaultImport(node) {
|
||
if (!hasTypeImportKind(node)) {
|
||
return super.shouldParseDefaultImport(node);
|
||
}
|
||
|
||
return isMaybeDefaultImport(this.state);
|
||
}
|
||
|
||
parseImportSpecifierLocal(node, specifier, type, contextDescription) {
|
||
specifier.local = hasTypeImportKind(node) ? this.flowParseRestrictedIdentifier(true) : this.parseIdentifier();
|
||
this.checkLVal(specifier.local, BIND_LEXICAL, undefined, contextDescription);
|
||
node.specifiers.push(this.finishNode(specifier, type));
|
||
}
|
||
|
||
maybeParseDefaultImportSpecifier(node) {
|
||
node.importKind = "value";
|
||
let kind = null;
|
||
|
||
if (this.match(types._typeof)) {
|
||
kind = "typeof";
|
||
} else if (this.isContextual("type")) {
|
||
kind = "type";
|
||
}
|
||
|
||
if (kind) {
|
||
const lh = this.lookahead();
|
||
|
||
if (kind === "type" && lh.type === types.star) {
|
||
this.unexpected(lh.start);
|
||
}
|
||
|
||
if (isMaybeDefaultImport(lh) || lh.type === types.braceL || lh.type === types.star) {
|
||
this.next();
|
||
node.importKind = kind;
|
||
}
|
||
}
|
||
|
||
return super.maybeParseDefaultImportSpecifier(node);
|
||
}
|
||
|
||
parseImportSpecifier(node) {
|
||
const specifier = this.startNode();
|
||
const firstIdentLoc = this.state.start;
|
||
const firstIdent = this.parseIdentifier(true);
|
||
let specifierTypeKind = null;
|
||
|
||
if (firstIdent.name === "type") {
|
||
specifierTypeKind = "type";
|
||
} else if (firstIdent.name === "typeof") {
|
||
specifierTypeKind = "typeof";
|
||
}
|
||
|
||
let isBinding = false;
|
||
|
||
if (this.isContextual("as") && !this.isLookaheadContextual("as")) {
|
||
const as_ident = this.parseIdentifier(true);
|
||
|
||
if (specifierTypeKind !== null && !this.match(types.name) && !this.state.type.keyword) {
|
||
specifier.imported = as_ident;
|
||
specifier.importKind = specifierTypeKind;
|
||
specifier.local = as_ident.__clone();
|
||
} else {
|
||
specifier.imported = firstIdent;
|
||
specifier.importKind = null;
|
||
specifier.local = this.parseIdentifier();
|
||
}
|
||
} else if (specifierTypeKind !== null && (this.match(types.name) || this.state.type.keyword)) {
|
||
specifier.imported = this.parseIdentifier(true);
|
||
specifier.importKind = specifierTypeKind;
|
||
|
||
if (this.eatContextual("as")) {
|
||
specifier.local = this.parseIdentifier();
|
||
} else {
|
||
isBinding = true;
|
||
specifier.local = specifier.imported.__clone();
|
||
}
|
||
} else {
|
||
isBinding = true;
|
||
specifier.imported = firstIdent;
|
||
specifier.importKind = null;
|
||
specifier.local = specifier.imported.__clone();
|
||
}
|
||
|
||
const nodeIsTypeImport = hasTypeImportKind(node);
|
||
const specifierIsTypeImport = hasTypeImportKind(specifier);
|
||
|
||
if (nodeIsTypeImport && specifierIsTypeImport) {
|
||
this.raise(firstIdentLoc, "The `type` and `typeof` keywords on named imports can only be used on regular " + "`import` statements. It cannot be used with `import type` or `import typeof` statements");
|
||
}
|
||
|
||
if (nodeIsTypeImport || specifierIsTypeImport) {
|
||
this.checkReservedType(specifier.local.name, specifier.local.start);
|
||
}
|
||
|
||
if (isBinding && !nodeIsTypeImport && !specifierIsTypeImport) {
|
||
this.checkReservedWord(specifier.local.name, specifier.start, true, true);
|
||
}
|
||
|
||
this.checkLVal(specifier.local, BIND_LEXICAL, undefined, "import specifier");
|
||
node.specifiers.push(this.finishNode(specifier, "ImportSpecifier"));
|
||
}
|
||
|
||
parseFunctionParams(node, allowModifiers) {
|
||
const kind = node.kind;
|
||
|
||
if (kind !== "get" && kind !== "set" && this.isRelational("<")) {
|
||
node.typeParameters = this.flowParseTypeParameterDeclaration();
|
||
}
|
||
|
||
super.parseFunctionParams(node, allowModifiers);
|
||
}
|
||
|
||
parseVarId(decl, kind) {
|
||
super.parseVarId(decl, kind);
|
||
|
||
if (this.match(types.colon)) {
|
||
decl.id.typeAnnotation = this.flowParseTypeAnnotation();
|
||
this.resetEndLocation(decl.id);
|
||
}
|
||
}
|
||
|
||
parseAsyncArrowFromCallExpression(node, call) {
|
||
if (this.match(types.colon)) {
|
||
const oldNoAnonFunctionType = this.state.noAnonFunctionType;
|
||
this.state.noAnonFunctionType = true;
|
||
node.returnType = this.flowParseTypeAnnotation();
|
||
this.state.noAnonFunctionType = oldNoAnonFunctionType;
|
||
}
|
||
|
||
return super.parseAsyncArrowFromCallExpression(node, call);
|
||
}
|
||
|
||
shouldParseAsyncArrow() {
|
||
return this.match(types.colon) || super.shouldParseAsyncArrow();
|
||
}
|
||
|
||
parseMaybeAssign(noIn, refShorthandDefaultPos, afterLeftParse, refNeedsArrowPos) {
|
||
let jsxError = null;
|
||
|
||
if (this.hasPlugin("jsx") && (this.match(types.jsxTagStart) || this.isRelational("<"))) {
|
||
const state = this.state.clone();
|
||
|
||
try {
|
||
return super.parseMaybeAssign(noIn, refShorthandDefaultPos, afterLeftParse, refNeedsArrowPos);
|
||
} catch (err) {
|
||
if (err instanceof SyntaxError) {
|
||
this.state = state;
|
||
const cLength = this.state.context.length;
|
||
|
||
if (this.state.context[cLength - 1] === types$1.j_oTag) {
|
||
this.state.context.length -= 2;
|
||
}
|
||
|
||
jsxError = err;
|
||
} else {
|
||
throw err;
|
||
}
|
||
}
|
||
}
|
||
|
||
if (jsxError != null || this.isRelational("<")) {
|
||
let arrowExpression;
|
||
let typeParameters;
|
||
|
||
try {
|
||
typeParameters = this.flowParseTypeParameterDeclaration();
|
||
arrowExpression = this.forwardNoArrowParamsConversionAt(typeParameters, () => super.parseMaybeAssign(noIn, refShorthandDefaultPos, afterLeftParse, refNeedsArrowPos));
|
||
arrowExpression.typeParameters = typeParameters;
|
||
this.resetStartLocationFromNode(arrowExpression, typeParameters);
|
||
} catch (err) {
|
||
throw jsxError || err;
|
||
}
|
||
|
||
if (arrowExpression.type === "ArrowFunctionExpression") {
|
||
return arrowExpression;
|
||
} else if (jsxError != null) {
|
||
throw jsxError;
|
||
} else {
|
||
this.raise(typeParameters.start, "Expected an arrow function after this type parameter declaration");
|
||
}
|
||
}
|
||
|
||
return super.parseMaybeAssign(noIn, refShorthandDefaultPos, afterLeftParse, refNeedsArrowPos);
|
||
}
|
||
|
||
parseArrow(node) {
|
||
if (this.match(types.colon)) {
|
||
const state = this.state.clone();
|
||
|
||
try {
|
||
const oldNoAnonFunctionType = this.state.noAnonFunctionType;
|
||
this.state.noAnonFunctionType = true;
|
||
const typeNode = this.startNode();
|
||
[typeNode.typeAnnotation, node.predicate] = this.flowParseTypeAndPredicateInitialiser();
|
||
this.state.noAnonFunctionType = oldNoAnonFunctionType;
|
||
if (this.canInsertSemicolon()) this.unexpected();
|
||
if (!this.match(types.arrow)) this.unexpected();
|
||
node.returnType = typeNode.typeAnnotation ? this.finishNode(typeNode, "TypeAnnotation") : null;
|
||
} catch (err) {
|
||
if (err instanceof SyntaxError) {
|
||
this.state = state;
|
||
} else {
|
||
throw err;
|
||
}
|
||
}
|
||
}
|
||
|
||
return super.parseArrow(node);
|
||
}
|
||
|
||
shouldParseArrow() {
|
||
return this.match(types.colon) || super.shouldParseArrow();
|
||
}
|
||
|
||
setArrowFunctionParameters(node, params) {
|
||
if (this.state.noArrowParamsConversionAt.indexOf(node.start) !== -1) {
|
||
node.params = params;
|
||
} else {
|
||
super.setArrowFunctionParameters(node, params);
|
||
}
|
||
}
|
||
|
||
checkParams(node, allowDuplicates, isArrowFunction) {
|
||
if (isArrowFunction && this.state.noArrowParamsConversionAt.indexOf(node.start) !== -1) {
|
||
return;
|
||
}
|
||
|
||
return super.checkParams(node, allowDuplicates, isArrowFunction);
|
||
}
|
||
|
||
parseParenAndDistinguishExpression(canBeArrow) {
|
||
return super.parseParenAndDistinguishExpression(canBeArrow && this.state.noArrowAt.indexOf(this.state.start) === -1);
|
||
}
|
||
|
||
parseSubscripts(base, startPos, startLoc, noCalls) {
|
||
if (base.type === "Identifier" && base.name === "async" && this.state.noArrowAt.indexOf(startPos) !== -1) {
|
||
this.next();
|
||
const node = this.startNodeAt(startPos, startLoc);
|
||
node.callee = base;
|
||
node.arguments = this.parseCallExpressionArguments(types.parenR, false);
|
||
base = this.finishNode(node, "CallExpression");
|
||
} else if (base.type === "Identifier" && base.name === "async" && this.isRelational("<")) {
|
||
const state = this.state.clone();
|
||
let error;
|
||
|
||
try {
|
||
const node = this.parseAsyncArrowWithTypeParameters(startPos, startLoc);
|
||
if (node) return node;
|
||
} catch (e) {
|
||
error = e;
|
||
}
|
||
|
||
this.state = state;
|
||
|
||
try {
|
||
return super.parseSubscripts(base, startPos, startLoc, noCalls);
|
||
} catch (e) {
|
||
throw error || e;
|
||
}
|
||
}
|
||
|
||
return super.parseSubscripts(base, startPos, startLoc, noCalls);
|
||
}
|
||
|
||
parseSubscript(base, startPos, startLoc, noCalls, subscriptState, maybeAsyncArrow) {
|
||
if (this.match(types.questionDot) && this.isLookaheadRelational("<")) {
|
||
this.expectPlugin("optionalChaining");
|
||
subscriptState.optionalChainMember = true;
|
||
|
||
if (noCalls) {
|
||
subscriptState.stop = true;
|
||
return base;
|
||
}
|
||
|
||
this.next();
|
||
const node = this.startNodeAt(startPos, startLoc);
|
||
node.callee = base;
|
||
node.typeArguments = this.flowParseTypeParameterInstantiation();
|
||
this.expect(types.parenL);
|
||
node.arguments = this.parseCallExpressionArguments(types.parenR, false);
|
||
node.optional = true;
|
||
return this.finishNode(node, "OptionalCallExpression");
|
||
} else if (!noCalls && this.shouldParseTypes() && this.isRelational("<")) {
|
||
const node = this.startNodeAt(startPos, startLoc);
|
||
node.callee = base;
|
||
const state = this.state.clone();
|
||
|
||
try {
|
||
node.typeArguments = this.flowParseTypeParameterInstantiationCallOrNew();
|
||
this.expect(types.parenL);
|
||
node.arguments = this.parseCallExpressionArguments(types.parenR, false);
|
||
|
||
if (subscriptState.optionalChainMember) {
|
||
node.optional = false;
|
||
return this.finishNode(node, "OptionalCallExpression");
|
||
}
|
||
|
||
return this.finishNode(node, "CallExpression");
|
||
} catch (e) {
|
||
if (e instanceof SyntaxError) {
|
||
this.state = state;
|
||
} else {
|
||
throw e;
|
||
}
|
||
}
|
||
}
|
||
|
||
return super.parseSubscript(base, startPos, startLoc, noCalls, subscriptState, maybeAsyncArrow);
|
||
}
|
||
|
||
parseNewArguments(node) {
|
||
let targs = null;
|
||
|
||
if (this.shouldParseTypes() && this.isRelational("<")) {
|
||
const state = this.state.clone();
|
||
|
||
try {
|
||
targs = this.flowParseTypeParameterInstantiationCallOrNew();
|
||
} catch (e) {
|
||
if (e instanceof SyntaxError) {
|
||
this.state = state;
|
||
} else {
|
||
throw e;
|
||
}
|
||
}
|
||
}
|
||
|
||
node.typeArguments = targs;
|
||
super.parseNewArguments(node);
|
||
}
|
||
|
||
parseAsyncArrowWithTypeParameters(startPos, startLoc) {
|
||
const node = this.startNodeAt(startPos, startLoc);
|
||
this.parseFunctionParams(node);
|
||
if (!this.parseArrow(node)) return;
|
||
return this.parseArrowExpression(node, undefined, true);
|
||
}
|
||
|
||
readToken_mult_modulo(code) {
|
||
const next = this.input.charCodeAt(this.state.pos + 1);
|
||
|
||
if (code === 42 && next === 47 && this.state.hasFlowComment) {
|
||
this.state.hasFlowComment = false;
|
||
this.state.pos += 2;
|
||
this.nextToken();
|
||
return;
|
||
}
|
||
|
||
super.readToken_mult_modulo(code);
|
||
}
|
||
|
||
readToken_pipe_amp(code) {
|
||
const next = this.input.charCodeAt(this.state.pos + 1);
|
||
|
||
if (code === 124 && next === 125) {
|
||
this.finishOp(types.braceBarR, 2);
|
||
return;
|
||
}
|
||
|
||
super.readToken_pipe_amp(code);
|
||
}
|
||
|
||
parseTopLevel(file, program) {
|
||
const fileNode = super.parseTopLevel(file, program);
|
||
|
||
if (this.state.hasFlowComment) {
|
||
this.unexpected(null, "Unterminated flow-comment");
|
||
}
|
||
|
||
return fileNode;
|
||
}
|
||
|
||
skipBlockComment() {
|
||
if (this.hasPlugin("flowComments") && this.skipFlowComment()) {
|
||
if (this.state.hasFlowComment) {
|
||
this.unexpected(null, "Cannot have a flow comment inside another flow comment");
|
||
}
|
||
|
||
this.hasFlowCommentCompletion();
|
||
this.state.pos += this.skipFlowComment();
|
||
this.state.hasFlowComment = true;
|
||
return;
|
||
}
|
||
|
||
if (this.state.hasFlowComment) {
|
||
const end = this.input.indexOf("*-/", this.state.pos += 2);
|
||
if (end === -1) this.raise(this.state.pos - 2, "Unterminated comment");
|
||
this.state.pos = end + 3;
|
||
return;
|
||
}
|
||
|
||
super.skipBlockComment();
|
||
}
|
||
|
||
skipFlowComment() {
|
||
const {
|
||
pos
|
||
} = this.state;
|
||
let shiftToFirstNonWhiteSpace = 2;
|
||
|
||
while ([32, 9].includes(this.input.charCodeAt(pos + shiftToFirstNonWhiteSpace))) {
|
||
shiftToFirstNonWhiteSpace++;
|
||
}
|
||
|
||
const ch2 = this.input.charCodeAt(shiftToFirstNonWhiteSpace + pos);
|
||
const ch3 = this.input.charCodeAt(shiftToFirstNonWhiteSpace + pos + 1);
|
||
|
||
if (ch2 === 58 && ch3 === 58) {
|
||
return shiftToFirstNonWhiteSpace + 2;
|
||
}
|
||
|
||
if (this.input.slice(shiftToFirstNonWhiteSpace + pos, shiftToFirstNonWhiteSpace + pos + 12) === "flow-include") {
|
||
return shiftToFirstNonWhiteSpace + 12;
|
||
}
|
||
|
||
if (ch2 === 58 && ch3 !== 58) {
|
||
return shiftToFirstNonWhiteSpace;
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
hasFlowCommentCompletion() {
|
||
const end = this.input.indexOf("*/", this.state.pos);
|
||
|
||
if (end === -1) {
|
||
this.raise(this.state.pos, "Unterminated comment");
|
||
}
|
||
}
|
||
|
||
});
|
||
|
||
const entities = {
|
||
quot: "\u0022",
|
||
amp: "&",
|
||
apos: "\u0027",
|
||
lt: "<",
|
||
gt: ">",
|
||
nbsp: "\u00A0",
|
||
iexcl: "\u00A1",
|
||
cent: "\u00A2",
|
||
pound: "\u00A3",
|
||
curren: "\u00A4",
|
||
yen: "\u00A5",
|
||
brvbar: "\u00A6",
|
||
sect: "\u00A7",
|
||
uml: "\u00A8",
|
||
copy: "\u00A9",
|
||
ordf: "\u00AA",
|
||
laquo: "\u00AB",
|
||
not: "\u00AC",
|
||
shy: "\u00AD",
|
||
reg: "\u00AE",
|
||
macr: "\u00AF",
|
||
deg: "\u00B0",
|
||
plusmn: "\u00B1",
|
||
sup2: "\u00B2",
|
||
sup3: "\u00B3",
|
||
acute: "\u00B4",
|
||
micro: "\u00B5",
|
||
para: "\u00B6",
|
||
middot: "\u00B7",
|
||
cedil: "\u00B8",
|
||
sup1: "\u00B9",
|
||
ordm: "\u00BA",
|
||
raquo: "\u00BB",
|
||
frac14: "\u00BC",
|
||
frac12: "\u00BD",
|
||
frac34: "\u00BE",
|
||
iquest: "\u00BF",
|
||
Agrave: "\u00C0",
|
||
Aacute: "\u00C1",
|
||
Acirc: "\u00C2",
|
||
Atilde: "\u00C3",
|
||
Auml: "\u00C4",
|
||
Aring: "\u00C5",
|
||
AElig: "\u00C6",
|
||
Ccedil: "\u00C7",
|
||
Egrave: "\u00C8",
|
||
Eacute: "\u00C9",
|
||
Ecirc: "\u00CA",
|
||
Euml: "\u00CB",
|
||
Igrave: "\u00CC",
|
||
Iacute: "\u00CD",
|
||
Icirc: "\u00CE",
|
||
Iuml: "\u00CF",
|
||
ETH: "\u00D0",
|
||
Ntilde: "\u00D1",
|
||
Ograve: "\u00D2",
|
||
Oacute: "\u00D3",
|
||
Ocirc: "\u00D4",
|
||
Otilde: "\u00D5",
|
||
Ouml: "\u00D6",
|
||
times: "\u00D7",
|
||
Oslash: "\u00D8",
|
||
Ugrave: "\u00D9",
|
||
Uacute: "\u00DA",
|
||
Ucirc: "\u00DB",
|
||
Uuml: "\u00DC",
|
||
Yacute: "\u00DD",
|
||
THORN: "\u00DE",
|
||
szlig: "\u00DF",
|
||
agrave: "\u00E0",
|
||
aacute: "\u00E1",
|
||
acirc: "\u00E2",
|
||
atilde: "\u00E3",
|
||
auml: "\u00E4",
|
||
aring: "\u00E5",
|
||
aelig: "\u00E6",
|
||
ccedil: "\u00E7",
|
||
egrave: "\u00E8",
|
||
eacute: "\u00E9",
|
||
ecirc: "\u00EA",
|
||
euml: "\u00EB",
|
||
igrave: "\u00EC",
|
||
iacute: "\u00ED",
|
||
icirc: "\u00EE",
|
||
iuml: "\u00EF",
|
||
eth: "\u00F0",
|
||
ntilde: "\u00F1",
|
||
ograve: "\u00F2",
|
||
oacute: "\u00F3",
|
||
ocirc: "\u00F4",
|
||
otilde: "\u00F5",
|
||
ouml: "\u00F6",
|
||
divide: "\u00F7",
|
||
oslash: "\u00F8",
|
||
ugrave: "\u00F9",
|
||
uacute: "\u00FA",
|
||
ucirc: "\u00FB",
|
||
uuml: "\u00FC",
|
||
yacute: "\u00FD",
|
||
thorn: "\u00FE",
|
||
yuml: "\u00FF",
|
||
OElig: "\u0152",
|
||
oelig: "\u0153",
|
||
Scaron: "\u0160",
|
||
scaron: "\u0161",
|
||
Yuml: "\u0178",
|
||
fnof: "\u0192",
|
||
circ: "\u02C6",
|
||
tilde: "\u02DC",
|
||
Alpha: "\u0391",
|
||
Beta: "\u0392",
|
||
Gamma: "\u0393",
|
||
Delta: "\u0394",
|
||
Epsilon: "\u0395",
|
||
Zeta: "\u0396",
|
||
Eta: "\u0397",
|
||
Theta: "\u0398",
|
||
Iota: "\u0399",
|
||
Kappa: "\u039A",
|
||
Lambda: "\u039B",
|
||
Mu: "\u039C",
|
||
Nu: "\u039D",
|
||
Xi: "\u039E",
|
||
Omicron: "\u039F",
|
||
Pi: "\u03A0",
|
||
Rho: "\u03A1",
|
||
Sigma: "\u03A3",
|
||
Tau: "\u03A4",
|
||
Upsilon: "\u03A5",
|
||
Phi: "\u03A6",
|
||
Chi: "\u03A7",
|
||
Psi: "\u03A8",
|
||
Omega: "\u03A9",
|
||
alpha: "\u03B1",
|
||
beta: "\u03B2",
|
||
gamma: "\u03B3",
|
||
delta: "\u03B4",
|
||
epsilon: "\u03B5",
|
||
zeta: "\u03B6",
|
||
eta: "\u03B7",
|
||
theta: "\u03B8",
|
||
iota: "\u03B9",
|
||
kappa: "\u03BA",
|
||
lambda: "\u03BB",
|
||
mu: "\u03BC",
|
||
nu: "\u03BD",
|
||
xi: "\u03BE",
|
||
omicron: "\u03BF",
|
||
pi: "\u03C0",
|
||
rho: "\u03C1",
|
||
sigmaf: "\u03C2",
|
||
sigma: "\u03C3",
|
||
tau: "\u03C4",
|
||
upsilon: "\u03C5",
|
||
phi: "\u03C6",
|
||
chi: "\u03C7",
|
||
psi: "\u03C8",
|
||
omega: "\u03C9",
|
||
thetasym: "\u03D1",
|
||
upsih: "\u03D2",
|
||
piv: "\u03D6",
|
||
ensp: "\u2002",
|
||
emsp: "\u2003",
|
||
thinsp: "\u2009",
|
||
zwnj: "\u200C",
|
||
zwj: "\u200D",
|
||
lrm: "\u200E",
|
||
rlm: "\u200F",
|
||
ndash: "\u2013",
|
||
mdash: "\u2014",
|
||
lsquo: "\u2018",
|
||
rsquo: "\u2019",
|
||
sbquo: "\u201A",
|
||
ldquo: "\u201C",
|
||
rdquo: "\u201D",
|
||
bdquo: "\u201E",
|
||
dagger: "\u2020",
|
||
Dagger: "\u2021",
|
||
bull: "\u2022",
|
||
hellip: "\u2026",
|
||
permil: "\u2030",
|
||
prime: "\u2032",
|
||
Prime: "\u2033",
|
||
lsaquo: "\u2039",
|
||
rsaquo: "\u203A",
|
||
oline: "\u203E",
|
||
frasl: "\u2044",
|
||
euro: "\u20AC",
|
||
image: "\u2111",
|
||
weierp: "\u2118",
|
||
real: "\u211C",
|
||
trade: "\u2122",
|
||
alefsym: "\u2135",
|
||
larr: "\u2190",
|
||
uarr: "\u2191",
|
||
rarr: "\u2192",
|
||
darr: "\u2193",
|
||
harr: "\u2194",
|
||
crarr: "\u21B5",
|
||
lArr: "\u21D0",
|
||
uArr: "\u21D1",
|
||
rArr: "\u21D2",
|
||
dArr: "\u21D3",
|
||
hArr: "\u21D4",
|
||
forall: "\u2200",
|
||
part: "\u2202",
|
||
exist: "\u2203",
|
||
empty: "\u2205",
|
||
nabla: "\u2207",
|
||
isin: "\u2208",
|
||
notin: "\u2209",
|
||
ni: "\u220B",
|
||
prod: "\u220F",
|
||
sum: "\u2211",
|
||
minus: "\u2212",
|
||
lowast: "\u2217",
|
||
radic: "\u221A",
|
||
prop: "\u221D",
|
||
infin: "\u221E",
|
||
ang: "\u2220",
|
||
and: "\u2227",
|
||
or: "\u2228",
|
||
cap: "\u2229",
|
||
cup: "\u222A",
|
||
int: "\u222B",
|
||
there4: "\u2234",
|
||
sim: "\u223C",
|
||
cong: "\u2245",
|
||
asymp: "\u2248",
|
||
ne: "\u2260",
|
||
equiv: "\u2261",
|
||
le: "\u2264",
|
||
ge: "\u2265",
|
||
sub: "\u2282",
|
||
sup: "\u2283",
|
||
nsub: "\u2284",
|
||
sube: "\u2286",
|
||
supe: "\u2287",
|
||
oplus: "\u2295",
|
||
otimes: "\u2297",
|
||
perp: "\u22A5",
|
||
sdot: "\u22C5",
|
||
lceil: "\u2308",
|
||
rceil: "\u2309",
|
||
lfloor: "\u230A",
|
||
rfloor: "\u230B",
|
||
lang: "\u2329",
|
||
rang: "\u232A",
|
||
loz: "\u25CA",
|
||
spades: "\u2660",
|
||
clubs: "\u2663",
|
||
hearts: "\u2665",
|
||
diams: "\u2666"
|
||
};
|
||
|
||
const HEX_NUMBER = /^[\da-fA-F]+$/;
|
||
const DECIMAL_NUMBER = /^\d+$/;
|
||
types$1.j_oTag = new TokContext("<tag", false);
|
||
types$1.j_cTag = new TokContext("</tag", false);
|
||
types$1.j_expr = new TokContext("<tag>...</tag>", true, true);
|
||
types.jsxName = new TokenType("jsxName");
|
||
types.jsxText = new TokenType("jsxText", {
|
||
beforeExpr: true
|
||
});
|
||
types.jsxTagStart = new TokenType("jsxTagStart", {
|
||
startsExpr: true
|
||
});
|
||
types.jsxTagEnd = new TokenType("jsxTagEnd");
|
||
|
||
types.jsxTagStart.updateContext = function () {
|
||
this.state.context.push(types$1.j_expr);
|
||
this.state.context.push(types$1.j_oTag);
|
||
this.state.exprAllowed = false;
|
||
};
|
||
|
||
types.jsxTagEnd.updateContext = function (prevType) {
|
||
const out = this.state.context.pop();
|
||
|
||
if (out === types$1.j_oTag && prevType === types.slash || out === types$1.j_cTag) {
|
||
this.state.context.pop();
|
||
this.state.exprAllowed = this.curContext() === types$1.j_expr;
|
||
} else {
|
||
this.state.exprAllowed = true;
|
||
}
|
||
};
|
||
|
||
function isFragment(object) {
|
||
return object ? object.type === "JSXOpeningFragment" || object.type === "JSXClosingFragment" : false;
|
||
}
|
||
|
||
function getQualifiedJSXName(object) {
|
||
if (object.type === "JSXIdentifier") {
|
||
return object.name;
|
||
}
|
||
|
||
if (object.type === "JSXNamespacedName") {
|
||
return object.namespace.name + ":" + object.name.name;
|
||
}
|
||
|
||
if (object.type === "JSXMemberExpression") {
|
||
return getQualifiedJSXName(object.object) + "." + getQualifiedJSXName(object.property);
|
||
}
|
||
|
||
throw new Error("Node had unexpected type: " + object.type);
|
||
}
|
||
|
||
var jsx = (superClass => class extends superClass {
|
||
jsxReadToken() {
|
||
let out = "";
|
||
let chunkStart = this.state.pos;
|
||
|
||
for (;;) {
|
||
if (this.state.pos >= this.length) {
|
||
this.raise(this.state.start, "Unterminated JSX contents");
|
||
}
|
||
|
||
const ch = this.input.charCodeAt(this.state.pos);
|
||
|
||
switch (ch) {
|
||
case 60:
|
||
case 123:
|
||
if (this.state.pos === this.state.start) {
|
||
if (ch === 60 && this.state.exprAllowed) {
|
||
++this.state.pos;
|
||
return this.finishToken(types.jsxTagStart);
|
||
}
|
||
|
||
return super.getTokenFromCode(ch);
|
||
}
|
||
|
||
out += this.input.slice(chunkStart, this.state.pos);
|
||
return this.finishToken(types.jsxText, out);
|
||
|
||
case 38:
|
||
out += this.input.slice(chunkStart, this.state.pos);
|
||
out += this.jsxReadEntity();
|
||
chunkStart = this.state.pos;
|
||
break;
|
||
|
||
default:
|
||
if (isNewLine(ch)) {
|
||
out += this.input.slice(chunkStart, this.state.pos);
|
||
out += this.jsxReadNewLine(true);
|
||
chunkStart = this.state.pos;
|
||
} else {
|
||
++this.state.pos;
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
|
||
jsxReadNewLine(normalizeCRLF) {
|
||
const ch = this.input.charCodeAt(this.state.pos);
|
||
let out;
|
||
++this.state.pos;
|
||
|
||
if (ch === 13 && this.input.charCodeAt(this.state.pos) === 10) {
|
||
++this.state.pos;
|
||
out = normalizeCRLF ? "\n" : "\r\n";
|
||
} else {
|
||
out = String.fromCharCode(ch);
|
||
}
|
||
|
||
++this.state.curLine;
|
||
this.state.lineStart = this.state.pos;
|
||
return out;
|
||
}
|
||
|
||
jsxReadString(quote) {
|
||
let out = "";
|
||
let chunkStart = ++this.state.pos;
|
||
|
||
for (;;) {
|
||
if (this.state.pos >= this.length) {
|
||
this.raise(this.state.start, "Unterminated string constant");
|
||
}
|
||
|
||
const ch = this.input.charCodeAt(this.state.pos);
|
||
if (ch === quote) break;
|
||
|
||
if (ch === 38) {
|
||
out += this.input.slice(chunkStart, this.state.pos);
|
||
out += this.jsxReadEntity();
|
||
chunkStart = this.state.pos;
|
||
} else if (isNewLine(ch)) {
|
||
out += this.input.slice(chunkStart, this.state.pos);
|
||
out += this.jsxReadNewLine(false);
|
||
chunkStart = this.state.pos;
|
||
} else {
|
||
++this.state.pos;
|
||
}
|
||
}
|
||
|
||
out += this.input.slice(chunkStart, this.state.pos++);
|
||
return this.finishToken(types.string, out);
|
||
}
|
||
|
||
jsxReadEntity() {
|
||
let str = "";
|
||
let count = 0;
|
||
let entity;
|
||
let ch = this.input[this.state.pos];
|
||
const startPos = ++this.state.pos;
|
||
|
||
while (this.state.pos < this.length && count++ < 10) {
|
||
ch = this.input[this.state.pos++];
|
||
|
||
if (ch === ";") {
|
||
if (str[0] === "#") {
|
||
if (str[1] === "x") {
|
||
str = str.substr(2);
|
||
|
||
if (HEX_NUMBER.test(str)) {
|
||
entity = String.fromCodePoint(parseInt(str, 16));
|
||
}
|
||
} else {
|
||
str = str.substr(1);
|
||
|
||
if (DECIMAL_NUMBER.test(str)) {
|
||
entity = String.fromCodePoint(parseInt(str, 10));
|
||
}
|
||
}
|
||
} else {
|
||
entity = entities[str];
|
||
}
|
||
|
||
break;
|
||
}
|
||
|
||
str += ch;
|
||
}
|
||
|
||
if (!entity) {
|
||
this.state.pos = startPos;
|
||
return "&";
|
||
}
|
||
|
||
return entity;
|
||
}
|
||
|
||
jsxReadWord() {
|
||
let ch;
|
||
const start = this.state.pos;
|
||
|
||
do {
|
||
ch = this.input.charCodeAt(++this.state.pos);
|
||
} while (isIdentifierChar(ch) || ch === 45);
|
||
|
||
return this.finishToken(types.jsxName, this.input.slice(start, this.state.pos));
|
||
}
|
||
|
||
jsxParseIdentifier() {
|
||
const node = this.startNode();
|
||
|
||
if (this.match(types.jsxName)) {
|
||
node.name = this.state.value;
|
||
} else if (this.state.type.keyword) {
|
||
node.name = this.state.type.keyword;
|
||
} else {
|
||
this.unexpected();
|
||
}
|
||
|
||
this.next();
|
||
return this.finishNode(node, "JSXIdentifier");
|
||
}
|
||
|
||
jsxParseNamespacedName() {
|
||
const startPos = this.state.start;
|
||
const startLoc = this.state.startLoc;
|
||
const name = this.jsxParseIdentifier();
|
||
if (!this.eat(types.colon)) return name;
|
||
const node = this.startNodeAt(startPos, startLoc);
|
||
node.namespace = name;
|
||
node.name = this.jsxParseIdentifier();
|
||
return this.finishNode(node, "JSXNamespacedName");
|
||
}
|
||
|
||
jsxParseElementName() {
|
||
const startPos = this.state.start;
|
||
const startLoc = this.state.startLoc;
|
||
let node = this.jsxParseNamespacedName();
|
||
|
||
while (this.eat(types.dot)) {
|
||
const newNode = this.startNodeAt(startPos, startLoc);
|
||
newNode.object = node;
|
||
newNode.property = this.jsxParseIdentifier();
|
||
node = this.finishNode(newNode, "JSXMemberExpression");
|
||
}
|
||
|
||
return node;
|
||
}
|
||
|
||
jsxParseAttributeValue() {
|
||
let node;
|
||
|
||
switch (this.state.type) {
|
||
case types.braceL:
|
||
node = this.startNode();
|
||
this.next();
|
||
node = this.jsxParseExpressionContainer(node);
|
||
|
||
if (node.expression.type === "JSXEmptyExpression") {
|
||
throw this.raise(node.start, "JSX attributes must only be assigned a non-empty expression");
|
||
} else {
|
||
return node;
|
||
}
|
||
|
||
case types.jsxTagStart:
|
||
case types.string:
|
||
return this.parseExprAtom();
|
||
|
||
default:
|
||
throw this.raise(this.state.start, "JSX value should be either an expression or a quoted JSX text");
|
||
}
|
||
}
|
||
|
||
jsxParseEmptyExpression() {
|
||
const node = this.startNodeAt(this.state.lastTokEnd, this.state.lastTokEndLoc);
|
||
return this.finishNodeAt(node, "JSXEmptyExpression", this.state.start, this.state.startLoc);
|
||
}
|
||
|
||
jsxParseSpreadChild(node) {
|
||
this.next();
|
||
node.expression = this.parseExpression();
|
||
this.expect(types.braceR);
|
||
return this.finishNode(node, "JSXSpreadChild");
|
||
}
|
||
|
||
jsxParseExpressionContainer(node) {
|
||
if (this.match(types.braceR)) {
|
||
node.expression = this.jsxParseEmptyExpression();
|
||
} else {
|
||
node.expression = this.parseExpression();
|
||
}
|
||
|
||
this.expect(types.braceR);
|
||
return this.finishNode(node, "JSXExpressionContainer");
|
||
}
|
||
|
||
jsxParseAttribute() {
|
||
const node = this.startNode();
|
||
|
||
if (this.eat(types.braceL)) {
|
||
this.expect(types.ellipsis);
|
||
node.argument = this.parseMaybeAssign();
|
||
this.expect(types.braceR);
|
||
return this.finishNode(node, "JSXSpreadAttribute");
|
||
}
|
||
|
||
node.name = this.jsxParseNamespacedName();
|
||
node.value = this.eat(types.eq) ? this.jsxParseAttributeValue() : null;
|
||
return this.finishNode(node, "JSXAttribute");
|
||
}
|
||
|
||
jsxParseOpeningElementAt(startPos, startLoc) {
|
||
const node = this.startNodeAt(startPos, startLoc);
|
||
|
||
if (this.match(types.jsxTagEnd)) {
|
||
this.expect(types.jsxTagEnd);
|
||
return this.finishNode(node, "JSXOpeningFragment");
|
||
}
|
||
|
||
node.name = this.jsxParseElementName();
|
||
return this.jsxParseOpeningElementAfterName(node);
|
||
}
|
||
|
||
jsxParseOpeningElementAfterName(node) {
|
||
const attributes = [];
|
||
|
||
while (!this.match(types.slash) && !this.match(types.jsxTagEnd)) {
|
||
attributes.push(this.jsxParseAttribute());
|
||
}
|
||
|
||
node.attributes = attributes;
|
||
node.selfClosing = this.eat(types.slash);
|
||
this.expect(types.jsxTagEnd);
|
||
return this.finishNode(node, "JSXOpeningElement");
|
||
}
|
||
|
||
jsxParseClosingElementAt(startPos, startLoc) {
|
||
const node = this.startNodeAt(startPos, startLoc);
|
||
|
||
if (this.match(types.jsxTagEnd)) {
|
||
this.expect(types.jsxTagEnd);
|
||
return this.finishNode(node, "JSXClosingFragment");
|
||
}
|
||
|
||
node.name = this.jsxParseElementName();
|
||
this.expect(types.jsxTagEnd);
|
||
return this.finishNode(node, "JSXClosingElement");
|
||
}
|
||
|
||
jsxParseElementAt(startPos, startLoc) {
|
||
const node = this.startNodeAt(startPos, startLoc);
|
||
const children = [];
|
||
const openingElement = this.jsxParseOpeningElementAt(startPos, startLoc);
|
||
let closingElement = null;
|
||
|
||
if (!openingElement.selfClosing) {
|
||
contents: for (;;) {
|
||
switch (this.state.type) {
|
||
case types.jsxTagStart:
|
||
startPos = this.state.start;
|
||
startLoc = this.state.startLoc;
|
||
this.next();
|
||
|
||
if (this.eat(types.slash)) {
|
||
closingElement = this.jsxParseClosingElementAt(startPos, startLoc);
|
||
break contents;
|
||
}
|
||
|
||
children.push(this.jsxParseElementAt(startPos, startLoc));
|
||
break;
|
||
|
||
case types.jsxText:
|
||
children.push(this.parseExprAtom());
|
||
break;
|
||
|
||
case types.braceL:
|
||
{
|
||
const node = this.startNode();
|
||
this.next();
|
||
|
||
if (this.match(types.ellipsis)) {
|
||
children.push(this.jsxParseSpreadChild(node));
|
||
} else {
|
||
children.push(this.jsxParseExpressionContainer(node));
|
||
}
|
||
|
||
break;
|
||
}
|
||
|
||
default:
|
||
throw this.unexpected();
|
||
}
|
||
}
|
||
|
||
if (isFragment(openingElement) && !isFragment(closingElement)) {
|
||
this.raise(closingElement.start, "Expected corresponding JSX closing tag for <>");
|
||
} else if (!isFragment(openingElement) && isFragment(closingElement)) {
|
||
this.raise(closingElement.start, "Expected corresponding JSX closing tag for <" + getQualifiedJSXName(openingElement.name) + ">");
|
||
} else if (!isFragment(openingElement) && !isFragment(closingElement)) {
|
||
if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name)) {
|
||
this.raise(closingElement.start, "Expected corresponding JSX closing tag for <" + getQualifiedJSXName(openingElement.name) + ">");
|
||
}
|
||
}
|
||
}
|
||
|
||
if (isFragment(openingElement)) {
|
||
node.openingFragment = openingElement;
|
||
node.closingFragment = closingElement;
|
||
} else {
|
||
node.openingElement = openingElement;
|
||
node.closingElement = closingElement;
|
||
}
|
||
|
||
node.children = children;
|
||
|
||
if (this.match(types.relational) && this.state.value === "<") {
|
||
this.raise(this.state.start, "Adjacent JSX elements must be wrapped in an enclosing tag. " + "Did you want a JSX fragment <>...</>?");
|
||
}
|
||
|
||
return isFragment(openingElement) ? this.finishNode(node, "JSXFragment") : this.finishNode(node, "JSXElement");
|
||
}
|
||
|
||
jsxParseElement() {
|
||
const startPos = this.state.start;
|
||
const startLoc = this.state.startLoc;
|
||
this.next();
|
||
return this.jsxParseElementAt(startPos, startLoc);
|
||
}
|
||
|
||
parseExprAtom(refShortHandDefaultPos) {
|
||
if (this.match(types.jsxText)) {
|
||
return this.parseLiteral(this.state.value, "JSXText");
|
||
} else if (this.match(types.jsxTagStart)) {
|
||
return this.jsxParseElement();
|
||
} else if (this.isRelational("<") && this.input.charCodeAt(this.state.pos) !== 33) {
|
||
this.finishToken(types.jsxTagStart);
|
||
return this.jsxParseElement();
|
||
} else {
|
||
return super.parseExprAtom(refShortHandDefaultPos);
|
||
}
|
||
}
|
||
|
||
getTokenFromCode(code) {
|
||
if (this.state.inPropertyName) return super.getTokenFromCode(code);
|
||
const context = this.curContext();
|
||
|
||
if (context === types$1.j_expr) {
|
||
return this.jsxReadToken();
|
||
}
|
||
|
||
if (context === types$1.j_oTag || context === types$1.j_cTag) {
|
||
if (isIdentifierStart(code)) {
|
||
return this.jsxReadWord();
|
||
}
|
||
|
||
if (code === 62) {
|
||
++this.state.pos;
|
||
return this.finishToken(types.jsxTagEnd);
|
||
}
|
||
|
||
if ((code === 34 || code === 39) && context === types$1.j_oTag) {
|
||
return this.jsxReadString(code);
|
||
}
|
||
}
|
||
|
||
if (code === 60 && this.state.exprAllowed && this.input.charCodeAt(this.state.pos + 1) !== 33) {
|
||
++this.state.pos;
|
||
return this.finishToken(types.jsxTagStart);
|
||
}
|
||
|
||
return super.getTokenFromCode(code);
|
||
}
|
||
|
||
updateContext(prevType) {
|
||
if (this.match(types.braceL)) {
|
||
const curContext = this.curContext();
|
||
|
||
if (curContext === types$1.j_oTag) {
|
||
this.state.context.push(types$1.braceExpression);
|
||
} else if (curContext === types$1.j_expr) {
|
||
this.state.context.push(types$1.templateQuasi);
|
||
} else {
|
||
super.updateContext(prevType);
|
||
}
|
||
|
||
this.state.exprAllowed = true;
|
||
} else if (this.match(types.slash) && prevType === types.jsxTagStart) {
|
||
this.state.context.length -= 2;
|
||
this.state.context.push(types$1.j_cTag);
|
||
this.state.exprAllowed = false;
|
||
} else {
|
||
return super.updateContext(prevType);
|
||
}
|
||
}
|
||
|
||
});
|
||
|
||
class Scope {
|
||
constructor(flags) {
|
||
this.var = [];
|
||
this.lexical = [];
|
||
this.functions = [];
|
||
this.flags = flags;
|
||
}
|
||
|
||
}
|
||
class ScopeHandler {
|
||
constructor(raise, inModule) {
|
||
this.scopeStack = [];
|
||
this.undefinedExports = new Map();
|
||
this.raise = raise;
|
||
this.inModule = inModule;
|
||
}
|
||
|
||
get inFunction() {
|
||
return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0;
|
||
}
|
||
|
||
get inGenerator() {
|
||
return (this.currentVarScope().flags & SCOPE_GENERATOR) > 0;
|
||
}
|
||
|
||
get inAsync() {
|
||
return (this.currentVarScope().flags & SCOPE_ASYNC) > 0;
|
||
}
|
||
|
||
get allowSuper() {
|
||
return (this.currentThisScope().flags & SCOPE_SUPER) > 0;
|
||
}
|
||
|
||
get allowDirectSuper() {
|
||
return (this.currentThisScope().flags & SCOPE_DIRECT_SUPER) > 0;
|
||
}
|
||
|
||
get inNonArrowFunction() {
|
||
return (this.currentThisScope().flags & SCOPE_FUNCTION) > 0;
|
||
}
|
||
|
||
get treatFunctionsAsVar() {
|
||
return this.treatFunctionsAsVarInScope(this.currentScope());
|
||
}
|
||
|
||
createScope(flags) {
|
||
return new Scope(flags);
|
||
}
|
||
|
||
enter(flags) {
|
||
this.scopeStack.push(this.createScope(flags));
|
||
}
|
||
|
||
exit() {
|
||
this.scopeStack.pop();
|
||
}
|
||
|
||
treatFunctionsAsVarInScope(scope) {
|
||
return !!(scope.flags & SCOPE_FUNCTION || !this.inModule && scope.flags & SCOPE_PROGRAM);
|
||
}
|
||
|
||
declareName(name, bindingType, pos) {
|
||
let scope = this.currentScope();
|
||
|
||
if (bindingType & BIND_SCOPE_LEXICAL || bindingType & BIND_SCOPE_FUNCTION) {
|
||
this.checkRedeclarationInScope(scope, name, bindingType, pos);
|
||
|
||
if (bindingType & BIND_SCOPE_FUNCTION) {
|
||
scope.functions.push(name);
|
||
} else {
|
||
scope.lexical.push(name);
|
||
}
|
||
|
||
if (bindingType & BIND_SCOPE_LEXICAL) {
|
||
this.maybeExportDefined(scope, name);
|
||
}
|
||
} else if (bindingType & BIND_SCOPE_VAR) {
|
||
for (let i = this.scopeStack.length - 1; i >= 0; --i) {
|
||
scope = this.scopeStack[i];
|
||
this.checkRedeclarationInScope(scope, name, bindingType, pos);
|
||
scope.var.push(name);
|
||
this.maybeExportDefined(scope, name);
|
||
if (scope.flags & SCOPE_VAR) break;
|
||
}
|
||
}
|
||
|
||
if (this.inModule && scope.flags & SCOPE_PROGRAM) {
|
||
this.undefinedExports.delete(name);
|
||
}
|
||
}
|
||
|
||
maybeExportDefined(scope, name) {
|
||
if (this.inModule && scope.flags & SCOPE_PROGRAM) {
|
||
this.undefinedExports.delete(name);
|
||
}
|
||
}
|
||
|
||
checkRedeclarationInScope(scope, name, bindingType, pos) {
|
||
if (this.isRedeclaredInScope(scope, name, bindingType)) {
|
||
this.raise(pos, `Identifier '${name}' has already been declared`);
|
||
}
|
||
}
|
||
|
||
isRedeclaredInScope(scope, name, bindingType) {
|
||
if (!(bindingType & BIND_KIND_VALUE)) return false;
|
||
|
||
if (bindingType & BIND_SCOPE_LEXICAL) {
|
||
return scope.lexical.indexOf(name) > -1 || scope.functions.indexOf(name) > -1 || scope.var.indexOf(name) > -1;
|
||
}
|
||
|
||
if (bindingType & BIND_SCOPE_FUNCTION) {
|
||
return scope.lexical.indexOf(name) > -1 || !this.treatFunctionsAsVarInScope(scope) && scope.var.indexOf(name) > -1;
|
||
}
|
||
|
||
return scope.lexical.indexOf(name) > -1 && !(scope.flags & SCOPE_SIMPLE_CATCH && scope.lexical[0] === name) || !this.treatFunctionsAsVarInScope(scope) && scope.functions.indexOf(name) > -1;
|
||
}
|
||
|
||
checkLocalExport(id) {
|
||
if (this.scopeStack[0].lexical.indexOf(id.name) === -1 && this.scopeStack[0].var.indexOf(id.name) === -1 && this.scopeStack[0].functions.indexOf(id.name) === -1) {
|
||
this.undefinedExports.set(id.name, id.start);
|
||
}
|
||
}
|
||
|
||
currentScope() {
|
||
return this.scopeStack[this.scopeStack.length - 1];
|
||
}
|
||
|
||
currentVarScope() {
|
||
for (let i = this.scopeStack.length - 1;; i--) {
|
||
const scope = this.scopeStack[i];
|
||
|
||
if (scope.flags & SCOPE_VAR) {
|
||
return scope;
|
||
}
|
||
}
|
||
}
|
||
|
||
currentThisScope() {
|
||
for (let i = this.scopeStack.length - 1;; i--) {
|
||
const scope = this.scopeStack[i];
|
||
|
||
if ((scope.flags & SCOPE_VAR || scope.flags & SCOPE_CLASS) && !(scope.flags & SCOPE_ARROW)) {
|
||
return scope;
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
class TypeScriptScope extends Scope {
|
||
constructor(...args) {
|
||
super(...args);
|
||
this.types = [];
|
||
this.enums = [];
|
||
this.constEnums = [];
|
||
this.classes = [];
|
||
this.exportOnlyBindings = [];
|
||
}
|
||
|
||
}
|
||
|
||
class TypeScriptScopeHandler extends ScopeHandler {
|
||
createScope(flags) {
|
||
return new TypeScriptScope(flags);
|
||
}
|
||
|
||
declareName(name, bindingType, pos) {
|
||
const scope = this.currentScope();
|
||
|
||
if (bindingType & BIND_FLAGS_TS_EXPORT_ONLY) {
|
||
this.maybeExportDefined(scope, name);
|
||
scope.exportOnlyBindings.push(name);
|
||
return;
|
||
}
|
||
|
||
super.declareName(...arguments);
|
||
|
||
if (bindingType & BIND_KIND_TYPE) {
|
||
if (!(bindingType & BIND_KIND_VALUE)) {
|
||
this.checkRedeclarationInScope(scope, name, bindingType, pos);
|
||
this.maybeExportDefined(scope, name);
|
||
}
|
||
|
||
scope.types.push(name);
|
||
}
|
||
|
||
if (bindingType & BIND_FLAGS_TS_ENUM) scope.enums.push(name);
|
||
if (bindingType & BIND_FLAGS_TS_CONST_ENUM) scope.constEnums.push(name);
|
||
if (bindingType & BIND_FLAGS_CLASS) scope.classes.push(name);
|
||
}
|
||
|
||
isRedeclaredInScope(scope, name, bindingType) {
|
||
if (scope.enums.indexOf(name) > -1) {
|
||
if (bindingType & BIND_FLAGS_TS_ENUM) {
|
||
const isConst = !!(bindingType & BIND_FLAGS_TS_CONST_ENUM);
|
||
const wasConst = scope.constEnums.indexOf(name) > -1;
|
||
return isConst !== wasConst;
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
if (bindingType & BIND_FLAGS_CLASS && scope.classes.indexOf(name) > -1) {
|
||
if (scope.lexical.indexOf(name) > -1) {
|
||
return !!(bindingType & BIND_KIND_VALUE);
|
||
} else {
|
||
return false;
|
||
}
|
||
}
|
||
|
||
if (bindingType & BIND_KIND_TYPE && scope.types.indexOf(name) > -1) {
|
||
return true;
|
||
}
|
||
|
||
return super.isRedeclaredInScope(...arguments);
|
||
}
|
||
|
||
checkLocalExport(id) {
|
||
if (this.scopeStack[0].types.indexOf(id.name) === -1 && this.scopeStack[0].exportOnlyBindings.indexOf(id.name) === -1) {
|
||
super.checkLocalExport(id);
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
function nonNull(x) {
|
||
if (x == null) {
|
||
throw new Error(`Unexpected ${x} value.`);
|
||
}
|
||
|
||
return x;
|
||
}
|
||
|
||
function assert(x) {
|
||
if (!x) {
|
||
throw new Error("Assert fail");
|
||
}
|
||
}
|
||
|
||
function keywordTypeFromName(value) {
|
||
switch (value) {
|
||
case "any":
|
||
return "TSAnyKeyword";
|
||
|
||
case "boolean":
|
||
return "TSBooleanKeyword";
|
||
|
||
case "bigint":
|
||
return "TSBigIntKeyword";
|
||
|
||
case "never":
|
||
return "TSNeverKeyword";
|
||
|
||
case "number":
|
||
return "TSNumberKeyword";
|
||
|
||
case "object":
|
||
return "TSObjectKeyword";
|
||
|
||
case "string":
|
||
return "TSStringKeyword";
|
||
|
||
case "symbol":
|
||
return "TSSymbolKeyword";
|
||
|
||
case "undefined":
|
||
return "TSUndefinedKeyword";
|
||
|
||
case "unknown":
|
||
return "TSUnknownKeyword";
|
||
|
||
default:
|
||
return undefined;
|
||
}
|
||
}
|
||
|
||
var typescript = (superClass => class extends superClass {
|
||
getScopeHandler() {
|
||
return TypeScriptScopeHandler;
|
||
}
|
||
|
||
tsIsIdentifier() {
|
||
return this.match(types.name);
|
||
}
|
||
|
||
tsNextTokenCanFollowModifier() {
|
||
this.next();
|
||
return !this.hasPrecedingLineBreak() && !this.match(types.parenL) && !this.match(types.parenR) && !this.match(types.colon) && !this.match(types.eq) && !this.match(types.question) && !this.match(types.bang);
|
||
}
|
||
|
||
tsParseModifier(allowedModifiers) {
|
||
if (!this.match(types.name)) {
|
||
return undefined;
|
||
}
|
||
|
||
const modifier = this.state.value;
|
||
|
||
if (allowedModifiers.indexOf(modifier) !== -1 && this.tsTryParse(this.tsNextTokenCanFollowModifier.bind(this))) {
|
||
return modifier;
|
||
}
|
||
|
||
return undefined;
|
||
}
|
||
|
||
tsIsListTerminator(kind) {
|
||
switch (kind) {
|
||
case "EnumMembers":
|
||
case "TypeMembers":
|
||
return this.match(types.braceR);
|
||
|
||
case "HeritageClauseElement":
|
||
return this.match(types.braceL);
|
||
|
||
case "TupleElementTypes":
|
||
return this.match(types.bracketR);
|
||
|
||
case "TypeParametersOrArguments":
|
||
return this.isRelational(">");
|
||
}
|
||
|
||
throw new Error("Unreachable");
|
||
}
|
||
|
||
tsParseList(kind, parseElement) {
|
||
const result = [];
|
||
|
||
while (!this.tsIsListTerminator(kind)) {
|
||
result.push(parseElement());
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
tsParseDelimitedList(kind, parseElement) {
|
||
return nonNull(this.tsParseDelimitedListWorker(kind, parseElement, true));
|
||
}
|
||
|
||
tsParseDelimitedListWorker(kind, parseElement, expectSuccess) {
|
||
const result = [];
|
||
|
||
while (true) {
|
||
if (this.tsIsListTerminator(kind)) {
|
||
break;
|
||
}
|
||
|
||
const element = parseElement();
|
||
|
||
if (element == null) {
|
||
return undefined;
|
||
}
|
||
|
||
result.push(element);
|
||
|
||
if (this.eat(types.comma)) {
|
||
continue;
|
||
}
|
||
|
||
if (this.tsIsListTerminator(kind)) {
|
||
break;
|
||
}
|
||
|
||
if (expectSuccess) {
|
||
this.expect(types.comma);
|
||
}
|
||
|
||
return undefined;
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
tsParseBracketedList(kind, parseElement, bracket, skipFirstToken) {
|
||
if (!skipFirstToken) {
|
||
if (bracket) {
|
||
this.expect(types.bracketL);
|
||
} else {
|
||
this.expectRelational("<");
|
||
}
|
||
}
|
||
|
||
const result = this.tsParseDelimitedList(kind, parseElement);
|
||
|
||
if (bracket) {
|
||
this.expect(types.bracketR);
|
||
} else {
|
||
this.expectRelational(">");
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
tsParseImportType() {
|
||
const node = this.startNode();
|
||
this.expect(types._import);
|
||
this.expect(types.parenL);
|
||
|
||
if (!this.match(types.string)) {
|
||
throw this.unexpected(null, "Argument in a type import must be a string literal");
|
||
}
|
||
|
||
node.argument = this.parseExprAtom();
|
||
this.expect(types.parenR);
|
||
|
||
if (this.eat(types.dot)) {
|
||
node.qualifier = this.tsParseEntityName(true);
|
||
}
|
||
|
||
if (this.isRelational("<")) {
|
||
node.typeParameters = this.tsParseTypeArguments();
|
||
}
|
||
|
||
return this.finishNode(node, "TSImportType");
|
||
}
|
||
|
||
tsParseEntityName(allowReservedWords) {
|
||
let entity = this.parseIdentifier();
|
||
|
||
while (this.eat(types.dot)) {
|
||
const node = this.startNodeAtNode(entity);
|
||
node.left = entity;
|
||
node.right = this.parseIdentifier(allowReservedWords);
|
||
entity = this.finishNode(node, "TSQualifiedName");
|
||
}
|
||
|
||
return entity;
|
||
}
|
||
|
||
tsParseTypeReference() {
|
||
const node = this.startNode();
|
||
node.typeName = this.tsParseEntityName(false);
|
||
|
||
if (!this.hasPrecedingLineBreak() && this.isRelational("<")) {
|
||
node.typeParameters = this.tsParseTypeArguments();
|
||
}
|
||
|
||
return this.finishNode(node, "TSTypeReference");
|
||
}
|
||
|
||
tsParseThisTypePredicate(lhs) {
|
||
this.next();
|
||
const node = this.startNodeAtNode(lhs);
|
||
node.parameterName = lhs;
|
||
node.typeAnnotation = this.tsParseTypeAnnotation(false);
|
||
return this.finishNode(node, "TSTypePredicate");
|
||
}
|
||
|
||
tsParseThisTypeNode() {
|
||
const node = this.startNode();
|
||
this.next();
|
||
return this.finishNode(node, "TSThisType");
|
||
}
|
||
|
||
tsParseTypeQuery() {
|
||
const node = this.startNode();
|
||
this.expect(types._typeof);
|
||
|
||
if (this.match(types._import)) {
|
||
node.exprName = this.tsParseImportType();
|
||
} else {
|
||
node.exprName = this.tsParseEntityName(true);
|
||
}
|
||
|
||
return this.finishNode(node, "TSTypeQuery");
|
||
}
|
||
|
||
tsParseTypeParameter() {
|
||
const node = this.startNode();
|
||
node.name = this.parseIdentifierName(node.start);
|
||
node.constraint = this.tsEatThenParseType(types._extends);
|
||
node.default = this.tsEatThenParseType(types.eq);
|
||
return this.finishNode(node, "TSTypeParameter");
|
||
}
|
||
|
||
tsTryParseTypeParameters() {
|
||
if (this.isRelational("<")) {
|
||
return this.tsParseTypeParameters();
|
||
}
|
||
}
|
||
|
||
tsParseTypeParameters() {
|
||
const node = this.startNode();
|
||
|
||
if (this.isRelational("<") || this.match(types.jsxTagStart)) {
|
||
this.next();
|
||
} else {
|
||
this.unexpected();
|
||
}
|
||
|
||
node.params = this.tsParseBracketedList("TypeParametersOrArguments", this.tsParseTypeParameter.bind(this), false, true);
|
||
return this.finishNode(node, "TSTypeParameterDeclaration");
|
||
}
|
||
|
||
tsTryNextParseConstantContext() {
|
||
if (this.lookahead().type === types._const) {
|
||
this.next();
|
||
return this.tsParseTypeReference();
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
tsFillSignature(returnToken, signature) {
|
||
const returnTokenRequired = returnToken === types.arrow;
|
||
signature.typeParameters = this.tsTryParseTypeParameters();
|
||
this.expect(types.parenL);
|
||
signature.parameters = this.tsParseBindingListForSignature();
|
||
|
||
if (returnTokenRequired) {
|
||
signature.typeAnnotation = this.tsParseTypeOrTypePredicateAnnotation(returnToken);
|
||
} else if (this.match(returnToken)) {
|
||
signature.typeAnnotation = this.tsParseTypeOrTypePredicateAnnotation(returnToken);
|
||
}
|
||
}
|
||
|
||
tsParseBindingListForSignature() {
|
||
return this.parseBindingList(types.parenR).map(pattern => {
|
||
if (pattern.type !== "Identifier" && pattern.type !== "RestElement" && pattern.type !== "ObjectPattern" && pattern.type !== "ArrayPattern") {
|
||
throw this.unexpected(pattern.start, `Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got ${pattern.type}`);
|
||
}
|
||
|
||
return pattern;
|
||
});
|
||
}
|
||
|
||
tsParseTypeMemberSemicolon() {
|
||
if (!this.eat(types.comma)) {
|
||
this.semicolon();
|
||
}
|
||
}
|
||
|
||
tsParseSignatureMember(kind, node) {
|
||
this.tsFillSignature(types.colon, node);
|
||
this.tsParseTypeMemberSemicolon();
|
||
return this.finishNode(node, kind);
|
||
}
|
||
|
||
tsIsUnambiguouslyIndexSignature() {
|
||
this.next();
|
||
return this.eat(types.name) && this.match(types.colon);
|
||
}
|
||
|
||
tsTryParseIndexSignature(node) {
|
||
if (!(this.match(types.bracketL) && this.tsLookAhead(this.tsIsUnambiguouslyIndexSignature.bind(this)))) {
|
||
return undefined;
|
||
}
|
||
|
||
this.expect(types.bracketL);
|
||
const id = this.parseIdentifier();
|
||
id.typeAnnotation = this.tsParseTypeAnnotation();
|
||
this.resetEndLocation(id);
|
||
this.expect(types.bracketR);
|
||
node.parameters = [id];
|
||
const type = this.tsTryParseTypeAnnotation();
|
||
if (type) node.typeAnnotation = type;
|
||
this.tsParseTypeMemberSemicolon();
|
||
return this.finishNode(node, "TSIndexSignature");
|
||
}
|
||
|
||
tsParsePropertyOrMethodSignature(node, readonly) {
|
||
if (this.eat(types.question)) node.optional = true;
|
||
const nodeAny = node;
|
||
|
||
if (!readonly && (this.match(types.parenL) || this.isRelational("<"))) {
|
||
const method = nodeAny;
|
||
this.tsFillSignature(types.colon, method);
|
||
this.tsParseTypeMemberSemicolon();
|
||
return this.finishNode(method, "TSMethodSignature");
|
||
} else {
|
||
const property = nodeAny;
|
||
if (readonly) property.readonly = true;
|
||
const type = this.tsTryParseTypeAnnotation();
|
||
if (type) property.typeAnnotation = type;
|
||
this.tsParseTypeMemberSemicolon();
|
||
return this.finishNode(property, "TSPropertySignature");
|
||
}
|
||
}
|
||
|
||
tsParseTypeMember() {
|
||
const node = this.startNode();
|
||
|
||
if (this.match(types.parenL) || this.isRelational("<")) {
|
||
return this.tsParseSignatureMember("TSCallSignatureDeclaration", node);
|
||
}
|
||
|
||
if (this.match(types._new)) {
|
||
const id = this.startNode();
|
||
this.next();
|
||
|
||
if (this.match(types.parenL) || this.isRelational("<")) {
|
||
return this.tsParseSignatureMember("TSConstructSignatureDeclaration", node);
|
||
} else {
|
||
node.key = this.createIdentifier(id, "new");
|
||
return this.tsParsePropertyOrMethodSignature(node, false);
|
||
}
|
||
}
|
||
|
||
const readonly = !!this.tsParseModifier(["readonly"]);
|
||
const idx = this.tsTryParseIndexSignature(node);
|
||
|
||
if (idx) {
|
||
if (readonly) node.readonly = true;
|
||
return idx;
|
||
}
|
||
|
||
this.parsePropertyName(node);
|
||
return this.tsParsePropertyOrMethodSignature(node, readonly);
|
||
}
|
||
|
||
tsParseTypeLiteral() {
|
||
const node = this.startNode();
|
||
node.members = this.tsParseObjectTypeMembers();
|
||
return this.finishNode(node, "TSTypeLiteral");
|
||
}
|
||
|
||
tsParseObjectTypeMembers() {
|
||
this.expect(types.braceL);
|
||
const members = this.tsParseList("TypeMembers", this.tsParseTypeMember.bind(this));
|
||
this.expect(types.braceR);
|
||
return members;
|
||
}
|
||
|
||
tsIsStartOfMappedType() {
|
||
this.next();
|
||
|
||
if (this.eat(types.plusMin)) {
|
||
return this.isContextual("readonly");
|
||
}
|
||
|
||
if (this.isContextual("readonly")) {
|
||
this.next();
|
||
}
|
||
|
||
if (!this.match(types.bracketL)) {
|
||
return false;
|
||
}
|
||
|
||
this.next();
|
||
|
||
if (!this.tsIsIdentifier()) {
|
||
return false;
|
||
}
|
||
|
||
this.next();
|
||
return this.match(types._in);
|
||
}
|
||
|
||
tsParseMappedTypeParameter() {
|
||
const node = this.startNode();
|
||
node.name = this.parseIdentifierName(node.start);
|
||
node.constraint = this.tsExpectThenParseType(types._in);
|
||
return this.finishNode(node, "TSTypeParameter");
|
||
}
|
||
|
||
tsParseMappedType() {
|
||
const node = this.startNode();
|
||
this.expect(types.braceL);
|
||
|
||
if (this.match(types.plusMin)) {
|
||
node.readonly = this.state.value;
|
||
this.next();
|
||
this.expectContextual("readonly");
|
||
} else if (this.eatContextual("readonly")) {
|
||
node.readonly = true;
|
||
}
|
||
|
||
this.expect(types.bracketL);
|
||
node.typeParameter = this.tsParseMappedTypeParameter();
|
||
this.expect(types.bracketR);
|
||
|
||
if (this.match(types.plusMin)) {
|
||
node.optional = this.state.value;
|
||
this.next();
|
||
this.expect(types.question);
|
||
} else if (this.eat(types.question)) {
|
||
node.optional = true;
|
||
}
|
||
|
||
node.typeAnnotation = this.tsTryParseType();
|
||
this.semicolon();
|
||
this.expect(types.braceR);
|
||
return this.finishNode(node, "TSMappedType");
|
||
}
|
||
|
||
tsParseTupleType() {
|
||
const node = this.startNode();
|
||
node.elementTypes = this.tsParseBracketedList("TupleElementTypes", this.tsParseTupleElementType.bind(this), true, false);
|
||
let seenOptionalElement = false;
|
||
node.elementTypes.forEach(elementNode => {
|
||
if (elementNode.type === "TSOptionalType") {
|
||
seenOptionalElement = true;
|
||
} else if (seenOptionalElement && elementNode.type !== "TSRestType") {
|
||
this.raise(elementNode.start, "A required element cannot follow an optional element.");
|
||
}
|
||
});
|
||
return this.finishNode(node, "TSTupleType");
|
||
}
|
||
|
||
tsParseTupleElementType() {
|
||
if (this.match(types.ellipsis)) {
|
||
const restNode = this.startNode();
|
||
this.next();
|
||
restNode.typeAnnotation = this.tsParseType();
|
||
this.checkCommaAfterRest();
|
||
return this.finishNode(restNode, "TSRestType");
|
||
}
|
||
|
||
const type = this.tsParseType();
|
||
|
||
if (this.eat(types.question)) {
|
||
const optionalTypeNode = this.startNodeAtNode(type);
|
||
optionalTypeNode.typeAnnotation = type;
|
||
return this.finishNode(optionalTypeNode, "TSOptionalType");
|
||
}
|
||
|
||
return type;
|
||
}
|
||
|
||
tsParseParenthesizedType() {
|
||
const node = this.startNode();
|
||
this.expect(types.parenL);
|
||
node.typeAnnotation = this.tsParseType();
|
||
this.expect(types.parenR);
|
||
return this.finishNode(node, "TSParenthesizedType");
|
||
}
|
||
|
||
tsParseFunctionOrConstructorType(type) {
|
||
const node = this.startNode();
|
||
|
||
if (type === "TSConstructorType") {
|
||
this.expect(types._new);
|
||
}
|
||
|
||
this.tsFillSignature(types.arrow, node);
|
||
return this.finishNode(node, type);
|
||
}
|
||
|
||
tsParseLiteralTypeNode() {
|
||
const node = this.startNode();
|
||
|
||
node.literal = (() => {
|
||
switch (this.state.type) {
|
||
case types.num:
|
||
case types.string:
|
||
case types._true:
|
||
case types._false:
|
||
return this.parseExprAtom();
|
||
|
||
default:
|
||
throw this.unexpected();
|
||
}
|
||
})();
|
||
|
||
return this.finishNode(node, "TSLiteralType");
|
||
}
|
||
|
||
tsParseTemplateLiteralType() {
|
||
const node = this.startNode();
|
||
const templateNode = this.parseTemplate(false);
|
||
|
||
if (templateNode.expressions.length > 0) {
|
||
throw this.raise(templateNode.expressions[0].start, "Template literal types cannot have any substitution");
|
||
}
|
||
|
||
node.literal = templateNode;
|
||
return this.finishNode(node, "TSLiteralType");
|
||
}
|
||
|
||
tsParseNonArrayType() {
|
||
switch (this.state.type) {
|
||
case types.name:
|
||
case types._void:
|
||
case types._null:
|
||
{
|
||
const type = this.match(types._void) ? "TSVoidKeyword" : this.match(types._null) ? "TSNullKeyword" : keywordTypeFromName(this.state.value);
|
||
|
||
if (type !== undefined && this.lookahead().type !== types.dot) {
|
||
const node = this.startNode();
|
||
this.next();
|
||
return this.finishNode(node, type);
|
||
}
|
||
|
||
return this.tsParseTypeReference();
|
||
}
|
||
|
||
case types.string:
|
||
case types.num:
|
||
case types._true:
|
||
case types._false:
|
||
return this.tsParseLiteralTypeNode();
|
||
|
||
case types.plusMin:
|
||
if (this.state.value === "-") {
|
||
const node = this.startNode();
|
||
|
||
if (this.lookahead().type !== types.num) {
|
||
throw this.unexpected();
|
||
}
|
||
|
||
node.literal = this.parseMaybeUnary();
|
||
return this.finishNode(node, "TSLiteralType");
|
||
}
|
||
|
||
break;
|
||
|
||
case types._this:
|
||
{
|
||
const thisKeyword = this.tsParseThisTypeNode();
|
||
|
||
if (this.isContextual("is") && !this.hasPrecedingLineBreak()) {
|
||
return this.tsParseThisTypePredicate(thisKeyword);
|
||
} else {
|
||
return thisKeyword;
|
||
}
|
||
}
|
||
|
||
case types._typeof:
|
||
return this.tsParseTypeQuery();
|
||
|
||
case types._import:
|
||
return this.tsParseImportType();
|
||
|
||
case types.braceL:
|
||
return this.tsLookAhead(this.tsIsStartOfMappedType.bind(this)) ? this.tsParseMappedType() : this.tsParseTypeLiteral();
|
||
|
||
case types.bracketL:
|
||
return this.tsParseTupleType();
|
||
|
||
case types.parenL:
|
||
return this.tsParseParenthesizedType();
|
||
|
||
case types.backQuote:
|
||
return this.tsParseTemplateLiteralType();
|
||
}
|
||
|
||
throw this.unexpected();
|
||
}
|
||
|
||
tsParseArrayTypeOrHigher() {
|
||
let type = this.tsParseNonArrayType();
|
||
|
||
while (!this.hasPrecedingLineBreak() && this.eat(types.bracketL)) {
|
||
if (this.match(types.bracketR)) {
|
||
const node = this.startNodeAtNode(type);
|
||
node.elementType = type;
|
||
this.expect(types.bracketR);
|
||
type = this.finishNode(node, "TSArrayType");
|
||
} else {
|
||
const node = this.startNodeAtNode(type);
|
||
node.objectType = type;
|
||
node.indexType = this.tsParseType();
|
||
this.expect(types.bracketR);
|
||
type = this.finishNode(node, "TSIndexedAccessType");
|
||
}
|
||
}
|
||
|
||
return type;
|
||
}
|
||
|
||
tsParseTypeOperator(operator) {
|
||
const node = this.startNode();
|
||
this.expectContextual(operator);
|
||
node.operator = operator;
|
||
node.typeAnnotation = this.tsParseTypeOperatorOrHigher();
|
||
|
||
if (operator === "readonly") {
|
||
this.tsCheckTypeAnnotationForReadOnly(node);
|
||
}
|
||
|
||
return this.finishNode(node, "TSTypeOperator");
|
||
}
|
||
|
||
tsCheckTypeAnnotationForReadOnly(node) {
|
||
switch (node.typeAnnotation.type) {
|
||
case "TSTupleType":
|
||
case "TSArrayType":
|
||
return;
|
||
|
||
default:
|
||
this.raise(node.start, "'readonly' type modifier is only permitted on array and tuple literal types.");
|
||
}
|
||
}
|
||
|
||
tsParseInferType() {
|
||
const node = this.startNode();
|
||
this.expectContextual("infer");
|
||
const typeParameter = this.startNode();
|
||
typeParameter.name = this.parseIdentifierName(typeParameter.start);
|
||
node.typeParameter = this.finishNode(typeParameter, "TSTypeParameter");
|
||
return this.finishNode(node, "TSInferType");
|
||
}
|
||
|
||
tsParseTypeOperatorOrHigher() {
|
||
const operator = ["keyof", "unique", "readonly"].find(kw => this.isContextual(kw));
|
||
return operator ? this.tsParseTypeOperator(operator) : this.isContextual("infer") ? this.tsParseInferType() : this.tsParseArrayTypeOrHigher();
|
||
}
|
||
|
||
tsParseUnionOrIntersectionType(kind, parseConstituentType, operator) {
|
||
this.eat(operator);
|
||
let type = parseConstituentType();
|
||
|
||
if (this.match(operator)) {
|
||
const types = [type];
|
||
|
||
while (this.eat(operator)) {
|
||
types.push(parseConstituentType());
|
||
}
|
||
|
||
const node = this.startNodeAtNode(type);
|
||
node.types = types;
|
||
type = this.finishNode(node, kind);
|
||
}
|
||
|
||
return type;
|
||
}
|
||
|
||
tsParseIntersectionTypeOrHigher() {
|
||
return this.tsParseUnionOrIntersectionType("TSIntersectionType", this.tsParseTypeOperatorOrHigher.bind(this), types.bitwiseAND);
|
||
}
|
||
|
||
tsParseUnionTypeOrHigher() {
|
||
return this.tsParseUnionOrIntersectionType("TSUnionType", this.tsParseIntersectionTypeOrHigher.bind(this), types.bitwiseOR);
|
||
}
|
||
|
||
tsIsStartOfFunctionType() {
|
||
if (this.isRelational("<")) {
|
||
return true;
|
||
}
|
||
|
||
return this.match(types.parenL) && this.tsLookAhead(this.tsIsUnambiguouslyStartOfFunctionType.bind(this));
|
||
}
|
||
|
||
tsSkipParameterStart() {
|
||
if (this.match(types.name) || this.match(types._this)) {
|
||
this.next();
|
||
return true;
|
||
}
|
||
|
||
if (this.match(types.braceL)) {
|
||
let braceStackCounter = 1;
|
||
this.next();
|
||
|
||
while (braceStackCounter > 0) {
|
||
if (this.match(types.braceL)) {
|
||
++braceStackCounter;
|
||
} else if (this.match(types.braceR)) {
|
||
--braceStackCounter;
|
||
}
|
||
|
||
this.next();
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
if (this.match(types.bracketL)) {
|
||
let braceStackCounter = 1;
|
||
this.next();
|
||
|
||
while (braceStackCounter > 0) {
|
||
if (this.match(types.bracketL)) {
|
||
++braceStackCounter;
|
||
} else if (this.match(types.bracketR)) {
|
||
--braceStackCounter;
|
||
}
|
||
|
||
this.next();
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
tsIsUnambiguouslyStartOfFunctionType() {
|
||
this.next();
|
||
|
||
if (this.match(types.parenR) || this.match(types.ellipsis)) {
|
||
return true;
|
||
}
|
||
|
||
if (this.tsSkipParameterStart()) {
|
||
if (this.match(types.colon) || this.match(types.comma) || this.match(types.question) || this.match(types.eq)) {
|
||
return true;
|
||
}
|
||
|
||
if (this.match(types.parenR)) {
|
||
this.next();
|
||
|
||
if (this.match(types.arrow)) {
|
||
return true;
|
||
}
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
tsParseTypeOrTypePredicateAnnotation(returnToken) {
|
||
return this.tsInType(() => {
|
||
const t = this.startNode();
|
||
this.expect(returnToken);
|
||
const typePredicateVariable = this.tsIsIdentifier() && this.tsTryParse(this.tsParseTypePredicatePrefix.bind(this));
|
||
|
||
if (!typePredicateVariable) {
|
||
return this.tsParseTypeAnnotation(false, t);
|
||
}
|
||
|
||
const type = this.tsParseTypeAnnotation(false);
|
||
const node = this.startNodeAtNode(typePredicateVariable);
|
||
node.parameterName = typePredicateVariable;
|
||
node.typeAnnotation = type;
|
||
t.typeAnnotation = this.finishNode(node, "TSTypePredicate");
|
||
return this.finishNode(t, "TSTypeAnnotation");
|
||
});
|
||
}
|
||
|
||
tsTryParseTypeOrTypePredicateAnnotation() {
|
||
return this.match(types.colon) ? this.tsParseTypeOrTypePredicateAnnotation(types.colon) : undefined;
|
||
}
|
||
|
||
tsTryParseTypeAnnotation() {
|
||
return this.match(types.colon) ? this.tsParseTypeAnnotation() : undefined;
|
||
}
|
||
|
||
tsTryParseType() {
|
||
return this.tsEatThenParseType(types.colon);
|
||
}
|
||
|
||
tsParseTypePredicatePrefix() {
|
||
const id = this.parseIdentifier();
|
||
|
||
if (this.isContextual("is") && !this.hasPrecedingLineBreak()) {
|
||
this.next();
|
||
return id;
|
||
}
|
||
}
|
||
|
||
tsParseTypeAnnotation(eatColon = true, t = this.startNode()) {
|
||
this.tsInType(() => {
|
||
if (eatColon) this.expect(types.colon);
|
||
t.typeAnnotation = this.tsParseType();
|
||
});
|
||
return this.finishNode(t, "TSTypeAnnotation");
|
||
}
|
||
|
||
tsParseType() {
|
||
assert(this.state.inType);
|
||
const type = this.tsParseNonConditionalType();
|
||
|
||
if (this.hasPrecedingLineBreak() || !this.eat(types._extends)) {
|
||
return type;
|
||
}
|
||
|
||
const node = this.startNodeAtNode(type);
|
||
node.checkType = type;
|
||
node.extendsType = this.tsParseNonConditionalType();
|
||
this.expect(types.question);
|
||
node.trueType = this.tsParseType();
|
||
this.expect(types.colon);
|
||
node.falseType = this.tsParseType();
|
||
return this.finishNode(node, "TSConditionalType");
|
||
}
|
||
|
||
tsParseNonConditionalType() {
|
||
if (this.tsIsStartOfFunctionType()) {
|
||
return this.tsParseFunctionOrConstructorType("TSFunctionType");
|
||
}
|
||
|
||
if (this.match(types._new)) {
|
||
return this.tsParseFunctionOrConstructorType("TSConstructorType");
|
||
}
|
||
|
||
return this.tsParseUnionTypeOrHigher();
|
||
}
|
||
|
||
tsParseTypeAssertion() {
|
||
const node = this.startNode();
|
||
|
||
const _const = this.tsTryNextParseConstantContext();
|
||
|
||
node.typeAnnotation = _const || this.tsNextThenParseType();
|
||
this.expectRelational(">");
|
||
node.expression = this.parseMaybeUnary();
|
||
return this.finishNode(node, "TSTypeAssertion");
|
||
}
|
||
|
||
tsParseHeritageClause(descriptor) {
|
||
const originalStart = this.state.start;
|
||
const delimitedList = this.tsParseDelimitedList("HeritageClauseElement", this.tsParseExpressionWithTypeArguments.bind(this));
|
||
|
||
if (!delimitedList.length) {
|
||
this.raise(originalStart, `'${descriptor}' list cannot be empty.`);
|
||
}
|
||
|
||
return delimitedList;
|
||
}
|
||
|
||
tsParseExpressionWithTypeArguments() {
|
||
const node = this.startNode();
|
||
node.expression = this.tsParseEntityName(false);
|
||
|
||
if (this.isRelational("<")) {
|
||
node.typeParameters = this.tsParseTypeArguments();
|
||
}
|
||
|
||
return this.finishNode(node, "TSExpressionWithTypeArguments");
|
||
}
|
||
|
||
tsParseInterfaceDeclaration(node) {
|
||
node.id = this.parseIdentifier();
|
||
this.checkLVal(node.id, BIND_TS_INTERFACE, undefined, "typescript interface declaration");
|
||
node.typeParameters = this.tsTryParseTypeParameters();
|
||
|
||
if (this.eat(types._extends)) {
|
||
node.extends = this.tsParseHeritageClause("extends");
|
||
}
|
||
|
||
const body = this.startNode();
|
||
body.body = this.tsInType(this.tsParseObjectTypeMembers.bind(this));
|
||
node.body = this.finishNode(body, "TSInterfaceBody");
|
||
return this.finishNode(node, "TSInterfaceDeclaration");
|
||
}
|
||
|
||
tsParseTypeAliasDeclaration(node) {
|
||
node.id = this.parseIdentifier();
|
||
this.checkLVal(node.id, BIND_TS_TYPE, undefined, "typescript type alias");
|
||
node.typeParameters = this.tsTryParseTypeParameters();
|
||
node.typeAnnotation = this.tsExpectThenParseType(types.eq);
|
||
this.semicolon();
|
||
return this.finishNode(node, "TSTypeAliasDeclaration");
|
||
}
|
||
|
||
tsInNoContext(cb) {
|
||
const oldContext = this.state.context;
|
||
this.state.context = [oldContext[0]];
|
||
|
||
try {
|
||
return cb();
|
||
} finally {
|
||
this.state.context = oldContext;
|
||
}
|
||
}
|
||
|
||
tsInType(cb) {
|
||
const oldInType = this.state.inType;
|
||
this.state.inType = true;
|
||
|
||
try {
|
||
return cb();
|
||
} finally {
|
||
this.state.inType = oldInType;
|
||
}
|
||
}
|
||
|
||
tsEatThenParseType(token) {
|
||
return !this.match(token) ? undefined : this.tsNextThenParseType();
|
||
}
|
||
|
||
tsExpectThenParseType(token) {
|
||
return this.tsDoThenParseType(() => this.expect(token));
|
||
}
|
||
|
||
tsNextThenParseType() {
|
||
return this.tsDoThenParseType(() => this.next());
|
||
}
|
||
|
||
tsDoThenParseType(cb) {
|
||
return this.tsInType(() => {
|
||
cb();
|
||
return this.tsParseType();
|
||
});
|
||
}
|
||
|
||
tsParseEnumMember() {
|
||
const node = this.startNode();
|
||
node.id = this.match(types.string) ? this.parseExprAtom() : this.parseIdentifier(true);
|
||
|
||
if (this.eat(types.eq)) {
|
||
node.initializer = this.parseMaybeAssign();
|
||
}
|
||
|
||
return this.finishNode(node, "TSEnumMember");
|
||
}
|
||
|
||
tsParseEnumDeclaration(node, isConst) {
|
||
if (isConst) node.const = true;
|
||
node.id = this.parseIdentifier();
|
||
this.checkLVal(node.id, isConst ? BIND_TS_CONST_ENUM : BIND_TS_ENUM, undefined, "typescript enum declaration");
|
||
this.expect(types.braceL);
|
||
node.members = this.tsParseDelimitedList("EnumMembers", this.tsParseEnumMember.bind(this));
|
||
this.expect(types.braceR);
|
||
return this.finishNode(node, "TSEnumDeclaration");
|
||
}
|
||
|
||
tsParseModuleBlock() {
|
||
const node = this.startNode();
|
||
this.scope.enter(SCOPE_OTHER);
|
||
this.expect(types.braceL);
|
||
this.parseBlockOrModuleBlockBody(node.body = [], undefined, true, types.braceR);
|
||
this.scope.exit();
|
||
return this.finishNode(node, "TSModuleBlock");
|
||
}
|
||
|
||
tsParseModuleOrNamespaceDeclaration(node, nested = false) {
|
||
node.id = this.parseIdentifier();
|
||
|
||
if (!nested) {
|
||
this.checkLVal(node.id, BIND_TS_NAMESPACE, null, "module or namespace declaration");
|
||
}
|
||
|
||
if (this.eat(types.dot)) {
|
||
const inner = this.startNode();
|
||
this.tsParseModuleOrNamespaceDeclaration(inner, true);
|
||
node.body = inner;
|
||
} else {
|
||
node.body = this.tsParseModuleBlock();
|
||
}
|
||
|
||
return this.finishNode(node, "TSModuleDeclaration");
|
||
}
|
||
|
||
tsParseAmbientExternalModuleDeclaration(node) {
|
||
if (this.isContextual("global")) {
|
||
node.global = true;
|
||
node.id = this.parseIdentifier();
|
||
} else if (this.match(types.string)) {
|
||
node.id = this.parseExprAtom();
|
||
} else {
|
||
this.unexpected();
|
||
}
|
||
|
||
if (this.match(types.braceL)) {
|
||
node.body = this.tsParseModuleBlock();
|
||
} else {
|
||
this.semicolon();
|
||
}
|
||
|
||
return this.finishNode(node, "TSModuleDeclaration");
|
||
}
|
||
|
||
tsParseImportEqualsDeclaration(node, isExport) {
|
||
node.isExport = isExport || false;
|
||
node.id = this.parseIdentifier();
|
||
this.expect(types.eq);
|
||
node.moduleReference = this.tsParseModuleReference();
|
||
this.semicolon();
|
||
return this.finishNode(node, "TSImportEqualsDeclaration");
|
||
}
|
||
|
||
tsIsExternalModuleReference() {
|
||
return this.isContextual("require") && this.lookahead().type === types.parenL;
|
||
}
|
||
|
||
tsParseModuleReference() {
|
||
return this.tsIsExternalModuleReference() ? this.tsParseExternalModuleReference() : this.tsParseEntityName(false);
|
||
}
|
||
|
||
tsParseExternalModuleReference() {
|
||
const node = this.startNode();
|
||
this.expectContextual("require");
|
||
this.expect(types.parenL);
|
||
|
||
if (!this.match(types.string)) {
|
||
throw this.unexpected();
|
||
}
|
||
|
||
node.expression = this.parseExprAtom();
|
||
this.expect(types.parenR);
|
||
return this.finishNode(node, "TSExternalModuleReference");
|
||
}
|
||
|
||
tsLookAhead(f) {
|
||
const state = this.state.clone();
|
||
const res = f();
|
||
this.state = state;
|
||
return res;
|
||
}
|
||
|
||
tsTryParseAndCatch(f) {
|
||
const state = this.state.clone();
|
||
|
||
try {
|
||
return f();
|
||
} catch (e) {
|
||
if (e instanceof SyntaxError) {
|
||
this.state = state;
|
||
return undefined;
|
||
}
|
||
|
||
throw e;
|
||
}
|
||
}
|
||
|
||
tsTryParse(f) {
|
||
const state = this.state.clone();
|
||
const result = f();
|
||
|
||
if (result !== undefined && result !== false) {
|
||
return result;
|
||
} else {
|
||
this.state = state;
|
||
return undefined;
|
||
}
|
||
}
|
||
|
||
tsTryParseDeclare(nany) {
|
||
if (this.isLineTerminator()) {
|
||
return;
|
||
}
|
||
|
||
let starttype = this.state.type;
|
||
let kind;
|
||
|
||
if (this.isContextual("let")) {
|
||
starttype = types._var;
|
||
kind = "let";
|
||
}
|
||
|
||
switch (starttype) {
|
||
case types._function:
|
||
return this.parseFunctionStatement(nany, false, true);
|
||
|
||
case types._class:
|
||
return this.parseClass(nany, true, false);
|
||
|
||
case types._const:
|
||
if (this.match(types._const) && this.isLookaheadContextual("enum")) {
|
||
this.expect(types._const);
|
||
this.expectContextual("enum");
|
||
return this.tsParseEnumDeclaration(nany, true);
|
||
}
|
||
|
||
case types._var:
|
||
kind = kind || this.state.value;
|
||
return this.parseVarStatement(nany, kind);
|
||
|
||
case types.name:
|
||
{
|
||
const value = this.state.value;
|
||
|
||
if (value === "global") {
|
||
return this.tsParseAmbientExternalModuleDeclaration(nany);
|
||
} else {
|
||
return this.tsParseDeclaration(nany, value, true);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
tsTryParseExportDeclaration() {
|
||
return this.tsParseDeclaration(this.startNode(), this.state.value, true);
|
||
}
|
||
|
||
tsParseExpressionStatement(node, expr) {
|
||
switch (expr.name) {
|
||
case "declare":
|
||
{
|
||
const declaration = this.tsTryParseDeclare(node);
|
||
|
||
if (declaration) {
|
||
declaration.declare = true;
|
||
return declaration;
|
||
}
|
||
|
||
break;
|
||
}
|
||
|
||
case "global":
|
||
if (this.match(types.braceL)) {
|
||
const mod = node;
|
||
mod.global = true;
|
||
mod.id = expr;
|
||
mod.body = this.tsParseModuleBlock();
|
||
return this.finishNode(mod, "TSModuleDeclaration");
|
||
}
|
||
|
||
break;
|
||
|
||
default:
|
||
return this.tsParseDeclaration(node, expr.name, false);
|
||
}
|
||
}
|
||
|
||
tsParseDeclaration(node, value, next) {
|
||
switch (value) {
|
||
case "abstract":
|
||
if (this.tsCheckLineTerminatorAndMatch(types._class, next)) {
|
||
const cls = node;
|
||
cls.abstract = true;
|
||
|
||
if (next) {
|
||
this.next();
|
||
|
||
if (!this.match(types._class)) {
|
||
this.unexpected(null, types._class);
|
||
}
|
||
}
|
||
|
||
return this.parseClass(cls, true, false);
|
||
}
|
||
|
||
break;
|
||
|
||
case "enum":
|
||
if (next || this.match(types.name)) {
|
||
if (next) this.next();
|
||
return this.tsParseEnumDeclaration(node, false);
|
||
}
|
||
|
||
break;
|
||
|
||
case "interface":
|
||
if (this.tsCheckLineTerminatorAndMatch(types.name, next)) {
|
||
if (next) this.next();
|
||
return this.tsParseInterfaceDeclaration(node);
|
||
}
|
||
|
||
break;
|
||
|
||
case "module":
|
||
if (next) this.next();
|
||
|
||
if (this.match(types.string)) {
|
||
return this.tsParseAmbientExternalModuleDeclaration(node);
|
||
} else if (this.tsCheckLineTerminatorAndMatch(types.name, next)) {
|
||
return this.tsParseModuleOrNamespaceDeclaration(node);
|
||
}
|
||
|
||
break;
|
||
|
||
case "namespace":
|
||
if (this.tsCheckLineTerminatorAndMatch(types.name, next)) {
|
||
if (next) this.next();
|
||
return this.tsParseModuleOrNamespaceDeclaration(node);
|
||
}
|
||
|
||
break;
|
||
|
||
case "type":
|
||
if (this.tsCheckLineTerminatorAndMatch(types.name, next)) {
|
||
if (next) this.next();
|
||
return this.tsParseTypeAliasDeclaration(node);
|
||
}
|
||
|
||
break;
|
||
}
|
||
}
|
||
|
||
tsCheckLineTerminatorAndMatch(tokenType, next) {
|
||
return (next || this.match(tokenType)) && !this.isLineTerminator();
|
||
}
|
||
|
||
tsTryParseGenericAsyncArrowFunction(startPos, startLoc) {
|
||
if (!this.isRelational("<")) {
|
||
return undefined;
|
||
}
|
||
|
||
const res = this.tsTryParseAndCatch(() => {
|
||
const node = this.startNodeAt(startPos, startLoc);
|
||
node.typeParameters = this.tsParseTypeParameters();
|
||
super.parseFunctionParams(node);
|
||
node.returnType = this.tsTryParseTypeOrTypePredicateAnnotation();
|
||
this.expect(types.arrow);
|
||
return node;
|
||
});
|
||
|
||
if (!res) {
|
||
return undefined;
|
||
}
|
||
|
||
return this.parseArrowExpression(res, null, true);
|
||
}
|
||
|
||
tsParseTypeArguments() {
|
||
const node = this.startNode();
|
||
node.params = this.tsInType(() => this.tsInNoContext(() => {
|
||
this.expectRelational("<");
|
||
return this.tsParseDelimitedList("TypeParametersOrArguments", this.tsParseType.bind(this));
|
||
}));
|
||
this.state.exprAllowed = false;
|
||
this.expectRelational(">");
|
||
return this.finishNode(node, "TSTypeParameterInstantiation");
|
||
}
|
||
|
||
tsIsDeclarationStart() {
|
||
if (this.match(types.name)) {
|
||
switch (this.state.value) {
|
||
case "abstract":
|
||
case "declare":
|
||
case "enum":
|
||
case "interface":
|
||
case "module":
|
||
case "namespace":
|
||
case "type":
|
||
return true;
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
isExportDefaultSpecifier() {
|
||
if (this.tsIsDeclarationStart()) return false;
|
||
return super.isExportDefaultSpecifier();
|
||
}
|
||
|
||
parseAssignableListItem(allowModifiers, decorators) {
|
||
const startPos = this.state.start;
|
||
const startLoc = this.state.startLoc;
|
||
let accessibility;
|
||
let readonly = false;
|
||
|
||
if (allowModifiers) {
|
||
accessibility = this.parseAccessModifier();
|
||
readonly = !!this.tsParseModifier(["readonly"]);
|
||
}
|
||
|
||
const left = this.parseMaybeDefault();
|
||
this.parseAssignableListItemTypes(left);
|
||
const elt = this.parseMaybeDefault(left.start, left.loc.start, left);
|
||
|
||
if (accessibility || readonly) {
|
||
const pp = this.startNodeAt(startPos, startLoc);
|
||
|
||
if (decorators.length) {
|
||
pp.decorators = decorators;
|
||
}
|
||
|
||
if (accessibility) pp.accessibility = accessibility;
|
||
if (readonly) pp.readonly = readonly;
|
||
|
||
if (elt.type !== "Identifier" && elt.type !== "AssignmentPattern") {
|
||
throw this.raise(pp.start, "A parameter property may not be declared using a binding pattern.");
|
||
}
|
||
|
||
pp.parameter = elt;
|
||
return this.finishNode(pp, "TSParameterProperty");
|
||
}
|
||
|
||
if (decorators.length) {
|
||
left.decorators = decorators;
|
||
}
|
||
|
||
return elt;
|
||
}
|
||
|
||
parseFunctionBodyAndFinish(node, type, isMethod = false) {
|
||
if (this.match(types.colon)) {
|
||
node.returnType = this.tsParseTypeOrTypePredicateAnnotation(types.colon);
|
||
}
|
||
|
||
const bodilessType = type === "FunctionDeclaration" ? "TSDeclareFunction" : type === "ClassMethod" ? "TSDeclareMethod" : undefined;
|
||
|
||
if (bodilessType && !this.match(types.braceL) && this.isLineTerminator()) {
|
||
this.finishNode(node, bodilessType);
|
||
return;
|
||
}
|
||
|
||
super.parseFunctionBodyAndFinish(node, type, isMethod);
|
||
}
|
||
|
||
checkFunctionStatementId(node) {
|
||
if (!node.body && node.id) {
|
||
this.checkLVal(node.id, BIND_TS_FN_TYPE, null, "function name");
|
||
} else {
|
||
super.checkFunctionStatementId(...arguments);
|
||
}
|
||
}
|
||
|
||
parseSubscript(base, startPos, startLoc, noCalls, state, maybeAsyncArrow) {
|
||
if (!this.hasPrecedingLineBreak() && this.match(types.bang)) {
|
||
this.state.exprAllowed = false;
|
||
this.next();
|
||
const nonNullExpression = this.startNodeAt(startPos, startLoc);
|
||
nonNullExpression.expression = base;
|
||
return this.finishNode(nonNullExpression, "TSNonNullExpression");
|
||
}
|
||
|
||
if (this.isRelational("<")) {
|
||
const result = this.tsTryParseAndCatch(() => {
|
||
if (!noCalls && this.atPossibleAsync(base)) {
|
||
const asyncArrowFn = this.tsTryParseGenericAsyncArrowFunction(startPos, startLoc);
|
||
|
||
if (asyncArrowFn) {
|
||
return asyncArrowFn;
|
||
}
|
||
}
|
||
|
||
const node = this.startNodeAt(startPos, startLoc);
|
||
node.callee = base;
|
||
const typeArguments = this.tsParseTypeArguments();
|
||
|
||
if (typeArguments) {
|
||
if (!noCalls && this.eat(types.parenL)) {
|
||
node.arguments = this.parseCallExpressionArguments(types.parenR, false);
|
||
node.typeParameters = typeArguments;
|
||
return this.finishCallExpression(node);
|
||
} else if (this.match(types.backQuote)) {
|
||
return this.parseTaggedTemplateExpression(startPos, startLoc, base, state, typeArguments);
|
||
}
|
||
}
|
||
|
||
this.unexpected();
|
||
});
|
||
if (result) return result;
|
||
}
|
||
|
||
return super.parseSubscript(base, startPos, startLoc, noCalls, state, maybeAsyncArrow);
|
||
}
|
||
|
||
parseNewArguments(node) {
|
||
if (this.isRelational("<")) {
|
||
const typeParameters = this.tsTryParseAndCatch(() => {
|
||
const args = this.tsParseTypeArguments();
|
||
if (!this.match(types.parenL)) this.unexpected();
|
||
return args;
|
||
});
|
||
|
||
if (typeParameters) {
|
||
node.typeParameters = typeParameters;
|
||
}
|
||
}
|
||
|
||
super.parseNewArguments(node);
|
||
}
|
||
|
||
parseExprOp(left, leftStartPos, leftStartLoc, minPrec, noIn) {
|
||
if (nonNull(types._in.binop) > minPrec && !this.hasPrecedingLineBreak() && this.isContextual("as")) {
|
||
const node = this.startNodeAt(leftStartPos, leftStartLoc);
|
||
node.expression = left;
|
||
|
||
const _const = this.tsTryNextParseConstantContext();
|
||
|
||
if (_const) {
|
||
node.typeAnnotation = _const;
|
||
} else {
|
||
node.typeAnnotation = this.tsNextThenParseType();
|
||
}
|
||
|
||
this.finishNode(node, "TSAsExpression");
|
||
return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, noIn);
|
||
}
|
||
|
||
return super.parseExprOp(left, leftStartPos, leftStartLoc, minPrec, noIn);
|
||
}
|
||
|
||
checkReservedWord(word, startLoc, checkKeywords, isBinding) {}
|
||
|
||
checkDuplicateExports() {}
|
||
|
||
parseImport(node) {
|
||
if (this.match(types.name) && this.lookahead().type === types.eq) {
|
||
return this.tsParseImportEqualsDeclaration(node);
|
||
}
|
||
|
||
return super.parseImport(node);
|
||
}
|
||
|
||
parseExport(node) {
|
||
if (this.match(types._import)) {
|
||
this.expect(types._import);
|
||
return this.tsParseImportEqualsDeclaration(node, true);
|
||
} else if (this.eat(types.eq)) {
|
||
const assign = node;
|
||
assign.expression = this.parseExpression();
|
||
this.semicolon();
|
||
return this.finishNode(assign, "TSExportAssignment");
|
||
} else if (this.eatContextual("as")) {
|
||
const decl = node;
|
||
this.expectContextual("namespace");
|
||
decl.id = this.parseIdentifier();
|
||
this.semicolon();
|
||
return this.finishNode(decl, "TSNamespaceExportDeclaration");
|
||
} else {
|
||
return super.parseExport(node);
|
||
}
|
||
}
|
||
|
||
isAbstractClass() {
|
||
return this.isContextual("abstract") && this.lookahead().type === types._class;
|
||
}
|
||
|
||
parseExportDefaultExpression() {
|
||
if (this.isAbstractClass()) {
|
||
const cls = this.startNode();
|
||
this.next();
|
||
this.parseClass(cls, true, true);
|
||
cls.abstract = true;
|
||
return cls;
|
||
}
|
||
|
||
if (this.state.value === "interface") {
|
||
const result = this.tsParseDeclaration(this.startNode(), this.state.value, true);
|
||
if (result) return result;
|
||
}
|
||
|
||
return super.parseExportDefaultExpression();
|
||
}
|
||
|
||
parseStatementContent(context, topLevel) {
|
||
if (this.state.type === types._const) {
|
||
const ahead = this.lookahead();
|
||
|
||
if (ahead.type === types.name && ahead.value === "enum") {
|
||
const node = this.startNode();
|
||
this.expect(types._const);
|
||
this.expectContextual("enum");
|
||
return this.tsParseEnumDeclaration(node, true);
|
||
}
|
||
}
|
||
|
||
return super.parseStatementContent(context, topLevel);
|
||
}
|
||
|
||
parseAccessModifier() {
|
||
return this.tsParseModifier(["public", "protected", "private"]);
|
||
}
|
||
|
||
parseClassMember(classBody, member, state, constructorAllowsSuper) {
|
||
const accessibility = this.parseAccessModifier();
|
||
if (accessibility) member.accessibility = accessibility;
|
||
super.parseClassMember(classBody, member, state, constructorAllowsSuper);
|
||
}
|
||
|
||
parseClassMemberWithIsStatic(classBody, member, state, isStatic, constructorAllowsSuper) {
|
||
const methodOrProp = member;
|
||
const prop = member;
|
||
const propOrIdx = member;
|
||
let abstract = false,
|
||
readonly = false;
|
||
const mod = this.tsParseModifier(["abstract", "readonly"]);
|
||
|
||
switch (mod) {
|
||
case "readonly":
|
||
readonly = true;
|
||
abstract = !!this.tsParseModifier(["abstract"]);
|
||
break;
|
||
|
||
case "abstract":
|
||
abstract = true;
|
||
readonly = !!this.tsParseModifier(["readonly"]);
|
||
break;
|
||
}
|
||
|
||
if (abstract) methodOrProp.abstract = true;
|
||
if (readonly) propOrIdx.readonly = true;
|
||
|
||
if (!abstract && !isStatic && !methodOrProp.accessibility) {
|
||
const idx = this.tsTryParseIndexSignature(member);
|
||
|
||
if (idx) {
|
||
classBody.body.push(idx);
|
||
return;
|
||
}
|
||
}
|
||
|
||
if (readonly) {
|
||
methodOrProp.static = isStatic;
|
||
this.parseClassPropertyName(prop);
|
||
this.parsePostMemberNameModifiers(methodOrProp);
|
||
this.pushClassProperty(classBody, prop);
|
||
return;
|
||
}
|
||
|
||
super.parseClassMemberWithIsStatic(classBody, member, state, isStatic, constructorAllowsSuper);
|
||
}
|
||
|
||
parsePostMemberNameModifiers(methodOrProp) {
|
||
const optional = this.eat(types.question);
|
||
if (optional) methodOrProp.optional = true;
|
||
}
|
||
|
||
parseExpressionStatement(node, expr) {
|
||
const decl = expr.type === "Identifier" ? this.tsParseExpressionStatement(node, expr) : undefined;
|
||
return decl || super.parseExpressionStatement(node, expr);
|
||
}
|
||
|
||
shouldParseExportDeclaration() {
|
||
if (this.tsIsDeclarationStart()) return true;
|
||
return super.shouldParseExportDeclaration();
|
||
}
|
||
|
||
parseConditional(expr, noIn, startPos, startLoc, refNeedsArrowPos) {
|
||
if (!refNeedsArrowPos || !this.match(types.question)) {
|
||
return super.parseConditional(expr, noIn, startPos, startLoc, refNeedsArrowPos);
|
||
}
|
||
|
||
const state = this.state.clone();
|
||
|
||
try {
|
||
return super.parseConditional(expr, noIn, startPos, startLoc);
|
||
} catch (err) {
|
||
if (!(err instanceof SyntaxError)) {
|
||
throw err;
|
||
}
|
||
|
||
this.state = state;
|
||
refNeedsArrowPos.start = err.pos || this.state.start;
|
||
return expr;
|
||
}
|
||
}
|
||
|
||
parseParenItem(node, startPos, startLoc) {
|
||
node = super.parseParenItem(node, startPos, startLoc);
|
||
|
||
if (this.eat(types.question)) {
|
||
node.optional = true;
|
||
this.resetEndLocation(node);
|
||
}
|
||
|
||
if (this.match(types.colon)) {
|
||
const typeCastNode = this.startNodeAt(startPos, startLoc);
|
||
typeCastNode.expression = node;
|
||
typeCastNode.typeAnnotation = this.tsParseTypeAnnotation();
|
||
return this.finishNode(typeCastNode, "TSTypeCastExpression");
|
||
}
|
||
|
||
return node;
|
||
}
|
||
|
||
parseExportDeclaration(node) {
|
||
const startPos = this.state.start;
|
||
const startLoc = this.state.startLoc;
|
||
const isDeclare = this.eatContextual("declare");
|
||
let declaration;
|
||
|
||
if (this.match(types.name)) {
|
||
declaration = this.tsTryParseExportDeclaration();
|
||
}
|
||
|
||
if (!declaration) {
|
||
declaration = super.parseExportDeclaration(node);
|
||
}
|
||
|
||
if (declaration && isDeclare) {
|
||
this.resetStartLocation(declaration, startPos, startLoc);
|
||
declaration.declare = true;
|
||
}
|
||
|
||
return declaration;
|
||
}
|
||
|
||
parseClassId(node, isStatement, optionalId) {
|
||
if ((!isStatement || optionalId) && this.isContextual("implements")) {
|
||
return;
|
||
}
|
||
|
||
super.parseClassId(...arguments);
|
||
const typeParameters = this.tsTryParseTypeParameters();
|
||
if (typeParameters) node.typeParameters = typeParameters;
|
||
}
|
||
|
||
parseClassProperty(node) {
|
||
if (!node.optional && this.eat(types.bang)) {
|
||
node.definite = true;
|
||
}
|
||
|
||
const type = this.tsTryParseTypeAnnotation();
|
||
if (type) node.typeAnnotation = type;
|
||
return super.parseClassProperty(node);
|
||
}
|
||
|
||
pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
|
||
const typeParameters = this.tsTryParseTypeParameters();
|
||
if (typeParameters) method.typeParameters = typeParameters;
|
||
super.pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper);
|
||
}
|
||
|
||
pushClassPrivateMethod(classBody, method, isGenerator, isAsync) {
|
||
const typeParameters = this.tsTryParseTypeParameters();
|
||
if (typeParameters) method.typeParameters = typeParameters;
|
||
super.pushClassPrivateMethod(classBody, method, isGenerator, isAsync);
|
||
}
|
||
|
||
parseClassSuper(node) {
|
||
super.parseClassSuper(node);
|
||
|
||
if (node.superClass && this.isRelational("<")) {
|
||
node.superTypeParameters = this.tsParseTypeArguments();
|
||
}
|
||
|
||
if (this.eatContextual("implements")) {
|
||
node.implements = this.tsParseHeritageClause("implements");
|
||
}
|
||
}
|
||
|
||
parseObjPropValue(prop, ...args) {
|
||
const typeParameters = this.tsTryParseTypeParameters();
|
||
if (typeParameters) prop.typeParameters = typeParameters;
|
||
super.parseObjPropValue(prop, ...args);
|
||
}
|
||
|
||
parseFunctionParams(node, allowModifiers) {
|
||
const typeParameters = this.tsTryParseTypeParameters();
|
||
if (typeParameters) node.typeParameters = typeParameters;
|
||
super.parseFunctionParams(node, allowModifiers);
|
||
}
|
||
|
||
parseVarId(decl, kind) {
|
||
super.parseVarId(decl, kind);
|
||
|
||
if (decl.id.type === "Identifier" && this.eat(types.bang)) {
|
||
decl.definite = true;
|
||
}
|
||
|
||
const type = this.tsTryParseTypeAnnotation();
|
||
|
||
if (type) {
|
||
decl.id.typeAnnotation = type;
|
||
this.resetEndLocation(decl.id);
|
||
}
|
||
}
|
||
|
||
parseAsyncArrowFromCallExpression(node, call) {
|
||
if (this.match(types.colon)) {
|
||
node.returnType = this.tsParseTypeAnnotation();
|
||
}
|
||
|
||
return super.parseAsyncArrowFromCallExpression(node, call);
|
||
}
|
||
|
||
parseMaybeAssign(...args) {
|
||
let jsxError;
|
||
|
||
if (this.match(types.jsxTagStart)) {
|
||
const context = this.curContext();
|
||
assert(context === types$1.j_oTag);
|
||
assert(this.state.context[this.state.context.length - 2] === types$1.j_expr);
|
||
const state = this.state.clone();
|
||
|
||
try {
|
||
return super.parseMaybeAssign(...args);
|
||
} catch (err) {
|
||
if (!(err instanceof SyntaxError)) {
|
||
throw err;
|
||
}
|
||
|
||
this.state = state;
|
||
assert(this.curContext() === types$1.j_oTag);
|
||
this.state.context.pop();
|
||
assert(this.curContext() === types$1.j_expr);
|
||
this.state.context.pop();
|
||
jsxError = err;
|
||
}
|
||
}
|
||
|
||
if (jsxError === undefined && !this.isRelational("<")) {
|
||
return super.parseMaybeAssign(...args);
|
||
}
|
||
|
||
let arrowExpression;
|
||
let typeParameters;
|
||
const state = this.state.clone();
|
||
|
||
try {
|
||
typeParameters = this.tsParseTypeParameters();
|
||
arrowExpression = super.parseMaybeAssign(...args);
|
||
|
||
if (arrowExpression.type !== "ArrowFunctionExpression" || arrowExpression.extra && arrowExpression.extra.parenthesized) {
|
||
this.unexpected();
|
||
}
|
||
} catch (err) {
|
||
if (!(err instanceof SyntaxError)) {
|
||
throw err;
|
||
}
|
||
|
||
if (jsxError) {
|
||
throw jsxError;
|
||
}
|
||
|
||
assert(!this.hasPlugin("jsx"));
|
||
this.state = state;
|
||
return super.parseMaybeAssign(...args);
|
||
}
|
||
|
||
if (typeParameters && typeParameters.params.length !== 0) {
|
||
this.resetStartLocationFromNode(arrowExpression, typeParameters);
|
||
}
|
||
|
||
arrowExpression.typeParameters = typeParameters;
|
||
return arrowExpression;
|
||
}
|
||
|
||
parseMaybeUnary(refShorthandDefaultPos) {
|
||
if (!this.hasPlugin("jsx") && this.isRelational("<")) {
|
||
return this.tsParseTypeAssertion();
|
||
} else {
|
||
return super.parseMaybeUnary(refShorthandDefaultPos);
|
||
}
|
||
}
|
||
|
||
parseArrow(node) {
|
||
if (this.match(types.colon)) {
|
||
const state = this.state.clone();
|
||
|
||
try {
|
||
const returnType = this.tsParseTypeOrTypePredicateAnnotation(types.colon);
|
||
|
||
if (this.canInsertSemicolon() || !this.match(types.arrow)) {
|
||
this.state = state;
|
||
return undefined;
|
||
}
|
||
|
||
node.returnType = returnType;
|
||
} catch (err) {
|
||
if (err instanceof SyntaxError) {
|
||
this.state = state;
|
||
} else {
|
||
throw err;
|
||
}
|
||
}
|
||
}
|
||
|
||
return super.parseArrow(node);
|
||
}
|
||
|
||
parseAssignableListItemTypes(param) {
|
||
if (this.eat(types.question)) {
|
||
if (param.type !== "Identifier") {
|
||
throw this.raise(param.start, "A binding pattern parameter cannot be optional in an implementation signature.");
|
||
}
|
||
|
||
param.optional = true;
|
||
}
|
||
|
||
const type = this.tsTryParseTypeAnnotation();
|
||
if (type) param.typeAnnotation = type;
|
||
this.resetEndLocation(param);
|
||
return param;
|
||
}
|
||
|
||
toAssignable(node, isBinding, contextDescription) {
|
||
switch (node.type) {
|
||
case "TSTypeCastExpression":
|
||
return super.toAssignable(this.typeCastToParameter(node), isBinding, contextDescription);
|
||
|
||
case "TSParameterProperty":
|
||
return super.toAssignable(node, isBinding, contextDescription);
|
||
|
||
case "TSAsExpression":
|
||
case "TSNonNullExpression":
|
||
case "TSTypeAssertion":
|
||
node.expression = this.toAssignable(node.expression, isBinding, contextDescription);
|
||
return node;
|
||
|
||
default:
|
||
return super.toAssignable(node, isBinding, contextDescription);
|
||
}
|
||
}
|
||
|
||
checkLVal(expr, bindingType = BIND_NONE, checkClashes, contextDescription) {
|
||
switch (expr.type) {
|
||
case "TSTypeCastExpression":
|
||
return;
|
||
|
||
case "TSParameterProperty":
|
||
this.checkLVal(expr.parameter, bindingType, checkClashes, "parameter property");
|
||
return;
|
||
|
||
case "TSAsExpression":
|
||
case "TSNonNullExpression":
|
||
case "TSTypeAssertion":
|
||
this.checkLVal(expr.expression, bindingType, checkClashes, contextDescription);
|
||
return;
|
||
|
||
default:
|
||
super.checkLVal(expr, bindingType, checkClashes, contextDescription);
|
||
return;
|
||
}
|
||
}
|
||
|
||
parseBindingAtom() {
|
||
switch (this.state.type) {
|
||
case types._this:
|
||
return this.parseIdentifier(true);
|
||
|
||
default:
|
||
return super.parseBindingAtom();
|
||
}
|
||
}
|
||
|
||
parseMaybeDecoratorArguments(expr) {
|
||
if (this.isRelational("<")) {
|
||
const typeArguments = this.tsParseTypeArguments();
|
||
|
||
if (this.match(types.parenL)) {
|
||
const call = super.parseMaybeDecoratorArguments(expr);
|
||
call.typeParameters = typeArguments;
|
||
return call;
|
||
}
|
||
|
||
this.unexpected(this.state.start, types.parenL);
|
||
}
|
||
|
||
return super.parseMaybeDecoratorArguments(expr);
|
||
}
|
||
|
||
isClassMethod() {
|
||
return this.isRelational("<") || super.isClassMethod();
|
||
}
|
||
|
||
isClassProperty() {
|
||
return this.match(types.bang) || this.match(types.colon) || super.isClassProperty();
|
||
}
|
||
|
||
parseMaybeDefault(...args) {
|
||
const node = super.parseMaybeDefault(...args);
|
||
|
||
if (node.type === "AssignmentPattern" && node.typeAnnotation && node.right.start < node.typeAnnotation.start) {
|
||
this.raise(node.typeAnnotation.start, "Type annotations must come before default assignments, " + "e.g. instead of `age = 25: number` use `age: number = 25`");
|
||
}
|
||
|
||
return node;
|
||
}
|
||
|
||
getTokenFromCode(code) {
|
||
if (this.state.inType && (code === 62 || code === 60)) {
|
||
return this.finishOp(types.relational, 1);
|
||
} else {
|
||
return super.getTokenFromCode(code);
|
||
}
|
||
}
|
||
|
||
toAssignableList(exprList, isBinding, contextDescription) {
|
||
for (let i = 0; i < exprList.length; i++) {
|
||
const expr = exprList[i];
|
||
if (!expr) continue;
|
||
|
||
switch (expr.type) {
|
||
case "TSTypeCastExpression":
|
||
exprList[i] = this.typeCastToParameter(expr);
|
||
break;
|
||
|
||
case "TSAsExpression":
|
||
case "TSTypeAssertion":
|
||
this.raise(expr.start, "Unexpected type cast in parameter position.");
|
||
break;
|
||
}
|
||
}
|
||
|
||
return super.toAssignableList(exprList, isBinding, contextDescription);
|
||
}
|
||
|
||
typeCastToParameter(node) {
|
||
node.expression.typeAnnotation = node.typeAnnotation;
|
||
this.resetEndLocation(node.expression, node.typeAnnotation.end, node.typeAnnotation.loc.end);
|
||
return node.expression;
|
||
}
|
||
|
||
toReferencedList(exprList, isInParens) {
|
||
for (let i = 0; i < exprList.length; i++) {
|
||
const expr = exprList[i];
|
||
|
||
if (expr && expr._exprListItem && expr.type === "TsTypeCastExpression") {
|
||
this.raise(expr.start, "Did not expect a type annotation here.");
|
||
}
|
||
}
|
||
|
||
return exprList;
|
||
}
|
||
|
||
shouldParseArrow() {
|
||
return this.match(types.colon) || super.shouldParseArrow();
|
||
}
|
||
|
||
shouldParseAsyncArrow() {
|
||
return this.match(types.colon) || super.shouldParseAsyncArrow();
|
||
}
|
||
|
||
canHaveLeadingDecorator() {
|
||
return super.canHaveLeadingDecorator() || this.isAbstractClass();
|
||
}
|
||
|
||
jsxParseOpeningElementAfterName(node) {
|
||
if (this.isRelational("<")) {
|
||
const typeArguments = this.tsTryParseAndCatch(() => this.tsParseTypeArguments());
|
||
if (typeArguments) node.typeParameters = typeArguments;
|
||
}
|
||
|
||
return super.jsxParseOpeningElementAfterName(node);
|
||
}
|
||
|
||
getGetterSetterExpectedParamCount(method) {
|
||
const baseCount = super.getGetterSetterExpectedParamCount(method);
|
||
const firstParam = method.params[0];
|
||
const hasContextParam = firstParam && firstParam.type === "Identifier" && firstParam.name === "this";
|
||
return hasContextParam ? baseCount + 1 : baseCount;
|
||
}
|
||
|
||
});
|
||
|
||
types.placeholder = new TokenType("%%", {
|
||
startsExpr: true
|
||
});
|
||
var placeholders = (superClass => class extends superClass {
|
||
parsePlaceholder(expectedNode) {
|
||
if (this.match(types.placeholder)) {
|
||
const node = this.startNode();
|
||
this.next();
|
||
this.assertNoSpace("Unexpected space in placeholder.");
|
||
node.name = super.parseIdentifier(true);
|
||
this.assertNoSpace("Unexpected space in placeholder.");
|
||
this.expect(types.placeholder);
|
||
return this.finishPlaceholder(node, expectedNode);
|
||
}
|
||
}
|
||
|
||
finishPlaceholder(node, expectedNode) {
|
||
const isFinished = !!(node.expectedNode && node.type === "Placeholder");
|
||
node.expectedNode = expectedNode;
|
||
return isFinished ? node : this.finishNode(node, "Placeholder");
|
||
}
|
||
|
||
getTokenFromCode(code) {
|
||
if (code === 37 && this.input.charCodeAt(this.state.pos + 1) === 37) {
|
||
return this.finishOp(types.placeholder, 2);
|
||
}
|
||
|
||
return super.getTokenFromCode(...arguments);
|
||
}
|
||
|
||
parseExprAtom() {
|
||
return this.parsePlaceholder("Expression") || super.parseExprAtom(...arguments);
|
||
}
|
||
|
||
parseIdentifier() {
|
||
return this.parsePlaceholder("Identifier") || super.parseIdentifier(...arguments);
|
||
}
|
||
|
||
checkReservedWord(word) {
|
||
if (word !== undefined) super.checkReservedWord(...arguments);
|
||
}
|
||
|
||
parseBindingAtom() {
|
||
return this.parsePlaceholder("Pattern") || super.parseBindingAtom(...arguments);
|
||
}
|
||
|
||
checkLVal(expr) {
|
||
if (expr.type !== "Placeholder") super.checkLVal(...arguments);
|
||
}
|
||
|
||
toAssignable(node) {
|
||
if (node && node.type === "Placeholder" && node.expectedNode === "Expression") {
|
||
node.expectedNode = "Pattern";
|
||
return node;
|
||
}
|
||
|
||
return super.toAssignable(...arguments);
|
||
}
|
||
|
||
verifyBreakContinue(node) {
|
||
if (node.label && node.label.type === "Placeholder") return;
|
||
super.verifyBreakContinue(...arguments);
|
||
}
|
||
|
||
parseExpressionStatement(node, expr) {
|
||
if (expr.type !== "Placeholder" || expr.extra && expr.extra.parenthesized) {
|
||
return super.parseExpressionStatement(...arguments);
|
||
}
|
||
|
||
if (this.match(types.colon)) {
|
||
const stmt = node;
|
||
stmt.label = this.finishPlaceholder(expr, "Identifier");
|
||
this.next();
|
||
stmt.body = this.parseStatement("label");
|
||
return this.finishNode(stmt, "LabeledStatement");
|
||
}
|
||
|
||
this.semicolon();
|
||
node.name = expr.name;
|
||
return this.finishPlaceholder(node, "Statement");
|
||
}
|
||
|
||
parseBlock() {
|
||
return this.parsePlaceholder("BlockStatement") || super.parseBlock(...arguments);
|
||
}
|
||
|
||
parseFunctionId() {
|
||
return this.parsePlaceholder("Identifier") || super.parseFunctionId(...arguments);
|
||
}
|
||
|
||
parseClass(node, isStatement, optionalId) {
|
||
const type = isStatement ? "ClassDeclaration" : "ClassExpression";
|
||
this.next();
|
||
this.takeDecorators(node);
|
||
const placeholder = this.parsePlaceholder("Identifier");
|
||
|
||
if (placeholder) {
|
||
if (this.match(types._extends) || this.match(types.placeholder) || this.match(types.braceL)) {
|
||
node.id = placeholder;
|
||
} else if (optionalId || !isStatement) {
|
||
node.id = null;
|
||
node.body = this.finishPlaceholder(placeholder, "ClassBody");
|
||
return this.finishNode(node, type);
|
||
} else {
|
||
this.unexpected(null, "A class name is required");
|
||
}
|
||
} else {
|
||
this.parseClassId(node, isStatement, optionalId);
|
||
}
|
||
|
||
this.parseClassSuper(node);
|
||
node.body = this.parsePlaceholder("ClassBody") || this.parseClassBody(!!node.superClass);
|
||
return this.finishNode(node, type);
|
||
}
|
||
|
||
parseExport(node) {
|
||
const placeholder = this.parsePlaceholder("Identifier");
|
||
if (!placeholder) return super.parseExport(...arguments);
|
||
|
||
if (!this.isContextual("from") && !this.match(types.comma)) {
|
||
node.specifiers = [];
|
||
node.source = null;
|
||
node.declaration = this.finishPlaceholder(placeholder, "Declaration");
|
||
return this.finishNode(node, "ExportNamedDeclaration");
|
||
}
|
||
|
||
this.expectPlugin("exportDefaultFrom");
|
||
const specifier = this.startNode();
|
||
specifier.exported = placeholder;
|
||
node.specifiers = [this.finishNode(specifier, "ExportDefaultSpecifier")];
|
||
return super.parseExport(node);
|
||
}
|
||
|
||
maybeParseExportDefaultSpecifier(node) {
|
||
if (node.specifiers && node.specifiers.length > 0) {
|
||
return true;
|
||
}
|
||
|
||
return super.maybeParseExportDefaultSpecifier(...arguments);
|
||
}
|
||
|
||
checkExport(node) {
|
||
const {
|
||
specifiers
|
||
} = node;
|
||
|
||
if (specifiers && specifiers.length) {
|
||
node.specifiers = specifiers.filter(node => node.exported.type === "Placeholder");
|
||
}
|
||
|
||
super.checkExport(node);
|
||
node.specifiers = specifiers;
|
||
}
|
||
|
||
parseImport(node) {
|
||
const placeholder = this.parsePlaceholder("Identifier");
|
||
if (!placeholder) return super.parseImport(...arguments);
|
||
node.specifiers = [];
|
||
|
||
if (!this.isContextual("from") && !this.match(types.comma)) {
|
||
node.source = this.finishPlaceholder(placeholder, "StringLiteral");
|
||
this.semicolon();
|
||
return this.finishNode(node, "ImportDeclaration");
|
||
}
|
||
|
||
const specifier = this.startNodeAtNode(placeholder);
|
||
specifier.local = placeholder;
|
||
this.finishNode(specifier, "ImportDefaultSpecifier");
|
||
node.specifiers.push(specifier);
|
||
|
||
if (this.eat(types.comma)) {
|
||
const hasStarImport = this.maybeParseStarImportSpecifier(node);
|
||
if (!hasStarImport) this.parseNamedImportSpecifiers(node);
|
||
}
|
||
|
||
this.expectContextual("from");
|
||
node.source = this.parseImportSource();
|
||
this.semicolon();
|
||
return this.finishNode(node, "ImportDeclaration");
|
||
}
|
||
|
||
parseImportSource() {
|
||
return this.parsePlaceholder("StringLiteral") || super.parseImportSource(...arguments);
|
||
}
|
||
|
||
});
|
||
|
||
function hasPlugin(plugins, name) {
|
||
return plugins.some(plugin => {
|
||
if (Array.isArray(plugin)) {
|
||
return plugin[0] === name;
|
||
} else {
|
||
return plugin === name;
|
||
}
|
||
});
|
||
}
|
||
function getPluginOption(plugins, name, option) {
|
||
const plugin = plugins.find(plugin => {
|
||
if (Array.isArray(plugin)) {
|
||
return plugin[0] === name;
|
||
} else {
|
||
return plugin === name;
|
||
}
|
||
});
|
||
|
||
if (plugin && Array.isArray(plugin)) {
|
||
return plugin[1][option];
|
||
}
|
||
|
||
return null;
|
||
}
|
||
const PIPELINE_PROPOSALS = ["minimal", "smart", "fsharp"];
|
||
function validatePlugins(plugins) {
|
||
if (hasPlugin(plugins, "decorators")) {
|
||
if (hasPlugin(plugins, "decorators-legacy")) {
|
||
throw new Error("Cannot use the decorators and decorators-legacy plugin together");
|
||
}
|
||
|
||
const decoratorsBeforeExport = getPluginOption(plugins, "decorators", "decoratorsBeforeExport");
|
||
|
||
if (decoratorsBeforeExport == null) {
|
||
throw new Error("The 'decorators' plugin requires a 'decoratorsBeforeExport' option," + " whose value must be a boolean. If you are migrating from" + " Babylon/Babel 6 or want to use the old decorators proposal, you" + " should use the 'decorators-legacy' plugin instead of 'decorators'.");
|
||
} else if (typeof decoratorsBeforeExport !== "boolean") {
|
||
throw new Error("'decoratorsBeforeExport' must be a boolean.");
|
||
}
|
||
}
|
||
|
||
if (hasPlugin(plugins, "flow") && hasPlugin(plugins, "typescript")) {
|
||
throw new Error("Cannot combine flow and typescript plugins.");
|
||
}
|
||
|
||
if (hasPlugin(plugins, "pipelineOperator") && !PIPELINE_PROPOSALS.includes(getPluginOption(plugins, "pipelineOperator", "proposal"))) {
|
||
throw new Error("'pipelineOperator' requires 'proposal' option whose value should be one of: " + PIPELINE_PROPOSALS.map(p => `'${p}'`).join(", "));
|
||
}
|
||
}
|
||
const mixinPlugins = {
|
||
estree,
|
||
jsx,
|
||
flow,
|
||
typescript,
|
||
placeholders
|
||
};
|
||
const mixinPluginNames = Object.keys(mixinPlugins);
|
||
|
||
const defaultOptions = {
|
||
sourceType: "script",
|
||
sourceFilename: undefined,
|
||
startLine: 1,
|
||
allowAwaitOutsideFunction: false,
|
||
allowReturnOutsideFunction: false,
|
||
allowImportExportEverywhere: false,
|
||
allowSuperOutsideMethod: false,
|
||
allowUndeclaredExports: false,
|
||
plugins: [],
|
||
strictMode: null,
|
||
ranges: false,
|
||
tokens: false,
|
||
createParenthesizedExpressions: false
|
||
};
|
||
function getOptions(opts) {
|
||
const options = {};
|
||
|
||
for (let _i = 0, _Object$keys = Object.keys(defaultOptions); _i < _Object$keys.length; _i++) {
|
||
const key = _Object$keys[_i];
|
||
options[key] = opts && opts[key] != null ? opts[key] : defaultOptions[key];
|
||
}
|
||
|
||
return options;
|
||
}
|
||
|
||
class Position {
|
||
constructor(line, col) {
|
||
this.line = line;
|
||
this.column = col;
|
||
}
|
||
|
||
}
|
||
class SourceLocation {
|
||
constructor(start, end) {
|
||
this.start = start;
|
||
this.end = end;
|
||
}
|
||
|
||
}
|
||
function getLineInfo(input, offset) {
|
||
let line = 1;
|
||
let lineStart = 0;
|
||
let match;
|
||
lineBreakG.lastIndex = 0;
|
||
|
||
while ((match = lineBreakG.exec(input)) && match.index < offset) {
|
||
line++;
|
||
lineStart = lineBreakG.lastIndex;
|
||
}
|
||
|
||
return new Position(line, offset - lineStart);
|
||
}
|
||
|
||
class BaseParser {
|
||
constructor() {
|
||
this.sawUnambiguousESM = false;
|
||
}
|
||
|
||
hasPlugin(name) {
|
||
return this.plugins.has(name);
|
||
}
|
||
|
||
getPluginOption(plugin, name) {
|
||
if (this.hasPlugin(plugin)) return this.plugins.get(plugin)[name];
|
||
}
|
||
|
||
}
|
||
|
||
function last(stack) {
|
||
return stack[stack.length - 1];
|
||
}
|
||
|
||
class CommentsParser extends BaseParser {
|
||
addComment(comment) {
|
||
if (this.filename) comment.loc.filename = this.filename;
|
||
this.state.trailingComments.push(comment);
|
||
this.state.leadingComments.push(comment);
|
||
}
|
||
|
||
processComment(node) {
|
||
if (node.type === "Program" && node.body.length > 0) return;
|
||
const stack = this.state.commentStack;
|
||
let firstChild, lastChild, trailingComments, i, j;
|
||
|
||
if (this.state.trailingComments.length > 0) {
|
||
if (this.state.trailingComments[0].start >= node.end) {
|
||
trailingComments = this.state.trailingComments;
|
||
this.state.trailingComments = [];
|
||
} else {
|
||
this.state.trailingComments.length = 0;
|
||
}
|
||
} else if (stack.length > 0) {
|
||
const lastInStack = last(stack);
|
||
|
||
if (lastInStack.trailingComments && lastInStack.trailingComments[0].start >= node.end) {
|
||
trailingComments = lastInStack.trailingComments;
|
||
delete lastInStack.trailingComments;
|
||
}
|
||
}
|
||
|
||
if (stack.length > 0 && last(stack).start >= node.start) {
|
||
firstChild = stack.pop();
|
||
}
|
||
|
||
while (stack.length > 0 && last(stack).start >= node.start) {
|
||
lastChild = stack.pop();
|
||
}
|
||
|
||
if (!lastChild && firstChild) lastChild = firstChild;
|
||
|
||
if (firstChild && this.state.leadingComments.length > 0) {
|
||
const lastComment = last(this.state.leadingComments);
|
||
|
||
if (firstChild.type === "ObjectProperty") {
|
||
if (lastComment.start >= node.start) {
|
||
if (this.state.commentPreviousNode) {
|
||
for (j = 0; j < this.state.leadingComments.length; j++) {
|
||
if (this.state.leadingComments[j].end < this.state.commentPreviousNode.end) {
|
||
this.state.leadingComments.splice(j, 1);
|
||
j--;
|
||
}
|
||
}
|
||
|
||
if (this.state.leadingComments.length > 0) {
|
||
firstChild.trailingComments = this.state.leadingComments;
|
||
this.state.leadingComments = [];
|
||
}
|
||
}
|
||
}
|
||
} else if (node.type === "CallExpression" && node.arguments && node.arguments.length) {
|
||
const lastArg = last(node.arguments);
|
||
|
||
if (lastArg && lastComment.start >= lastArg.start && lastComment.end <= node.end) {
|
||
if (this.state.commentPreviousNode) {
|
||
for (j = 0; j < this.state.leadingComments.length; j++) {
|
||
if (this.state.leadingComments[j].end < this.state.commentPreviousNode.end) {
|
||
this.state.leadingComments.splice(j, 1);
|
||
j--;
|
||
}
|
||
}
|
||
|
||
if (this.state.leadingComments.length > 0) {
|
||
lastArg.trailingComments = this.state.leadingComments;
|
||
this.state.leadingComments = [];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
if (lastChild) {
|
||
if (lastChild.leadingComments) {
|
||
if (lastChild !== node && lastChild.leadingComments.length > 0 && last(lastChild.leadingComments).end <= node.start) {
|
||
node.leadingComments = lastChild.leadingComments;
|
||
delete lastChild.leadingComments;
|
||
} else {
|
||
for (i = lastChild.leadingComments.length - 2; i >= 0; --i) {
|
||
if (lastChild.leadingComments[i].end <= node.start) {
|
||
node.leadingComments = lastChild.leadingComments.splice(0, i + 1);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
} else if (this.state.leadingComments.length > 0) {
|
||
if (last(this.state.leadingComments).end <= node.start) {
|
||
if (this.state.commentPreviousNode) {
|
||
for (j = 0; j < this.state.leadingComments.length; j++) {
|
||
if (this.state.leadingComments[j].end < this.state.commentPreviousNode.end) {
|
||
this.state.leadingComments.splice(j, 1);
|
||
j--;
|
||
}
|
||
}
|
||
}
|
||
|
||
if (this.state.leadingComments.length > 0) {
|
||
node.leadingComments = this.state.leadingComments;
|
||
this.state.leadingComments = [];
|
||
}
|
||
} else {
|
||
for (i = 0; i < this.state.leadingComments.length; i++) {
|
||
if (this.state.leadingComments[i].end > node.start) {
|
||
break;
|
||
}
|
||
}
|
||
|
||
const leadingComments = this.state.leadingComments.slice(0, i);
|
||
|
||
if (leadingComments.length) {
|
||
node.leadingComments = leadingComments;
|
||
}
|
||
|
||
trailingComments = this.state.leadingComments.slice(i);
|
||
|
||
if (trailingComments.length === 0) {
|
||
trailingComments = null;
|
||
}
|
||
}
|
||
}
|
||
|
||
this.state.commentPreviousNode = node;
|
||
|
||
if (trailingComments) {
|
||
if (trailingComments.length && trailingComments[0].start >= node.start && last(trailingComments).end <= node.end) {
|
||
node.innerComments = trailingComments;
|
||
} else {
|
||
node.trailingComments = trailingComments;
|
||
}
|
||
}
|
||
|
||
stack.push(node);
|
||
}
|
||
|
||
}
|
||
|
||
class LocationParser extends CommentsParser {
|
||
getLocationForPosition(pos) {
|
||
let loc;
|
||
if (pos === this.state.start) loc = this.state.startLoc;else if (pos === this.state.lastTokStart) loc = this.state.lastTokStartLoc;else if (pos === this.state.end) loc = this.state.endLoc;else if (pos === this.state.lastTokEnd) loc = this.state.lastTokEndLoc;else loc = getLineInfo(this.input, pos);
|
||
return loc;
|
||
}
|
||
|
||
raise(pos, message, {
|
||
missingPluginNames,
|
||
code
|
||
} = {}) {
|
||
const loc = this.getLocationForPosition(pos);
|
||
message += ` (${loc.line}:${loc.column})`;
|
||
const err = new SyntaxError(message);
|
||
err.pos = pos;
|
||
err.loc = loc;
|
||
|
||
if (missingPluginNames) {
|
||
err.missingPlugin = missingPluginNames;
|
||
}
|
||
|
||
if (code !== undefined) {
|
||
err.code = code;
|
||
}
|
||
|
||
throw err;
|
||
}
|
||
|
||
}
|
||
|
||
class State {
|
||
constructor() {
|
||
this.potentialArrowAt = -1;
|
||
this.noArrowAt = [];
|
||
this.noArrowParamsConversionAt = [];
|
||
this.commaAfterSpreadAt = -1;
|
||
this.inParameters = false;
|
||
this.maybeInArrowParameters = false;
|
||
this.inPipeline = false;
|
||
this.inType = false;
|
||
this.noAnonFunctionType = false;
|
||
this.inPropertyName = false;
|
||
this.inClassProperty = false;
|
||
this.hasFlowComment = false;
|
||
this.isIterator = false;
|
||
this.topicContext = {
|
||
maxNumOfResolvableTopics: 0,
|
||
maxTopicIndex: null
|
||
};
|
||
this.soloAwait = false;
|
||
this.inFSharpPipelineDirectBody = false;
|
||
this.classLevel = 0;
|
||
this.labels = [];
|
||
this.decoratorStack = [[]];
|
||
this.yieldPos = 0;
|
||
this.awaitPos = 0;
|
||
this.tokens = [];
|
||
this.comments = [];
|
||
this.trailingComments = [];
|
||
this.leadingComments = [];
|
||
this.commentStack = [];
|
||
this.commentPreviousNode = null;
|
||
this.pos = 0;
|
||
this.lineStart = 0;
|
||
this.type = types.eof;
|
||
this.value = null;
|
||
this.start = 0;
|
||
this.end = 0;
|
||
this.lastTokEndLoc = null;
|
||
this.lastTokStartLoc = null;
|
||
this.lastTokStart = 0;
|
||
this.lastTokEnd = 0;
|
||
this.context = [types$1.braceStatement];
|
||
this.exprAllowed = true;
|
||
this.containsEsc = false;
|
||
this.containsOctal = false;
|
||
this.octalPosition = null;
|
||
this.exportedIdentifiers = [];
|
||
this.invalidTemplateEscapePosition = null;
|
||
}
|
||
|
||
init(options) {
|
||
this.strict = options.strictMode === false ? false : options.sourceType === "module";
|
||
this.curLine = options.startLine;
|
||
this.startLoc = this.endLoc = this.curPosition();
|
||
}
|
||
|
||
curPosition() {
|
||
return new Position(this.curLine, this.pos - this.lineStart);
|
||
}
|
||
|
||
clone(skipArrays) {
|
||
const state = new State();
|
||
const keys = Object.keys(this);
|
||
|
||
for (let i = 0, length = keys.length; i < length; i++) {
|
||
const key = keys[i];
|
||
let val = this[key];
|
||
|
||
if (!skipArrays && Array.isArray(val)) {
|
||
val = val.slice();
|
||
}
|
||
|
||
state[key] = val;
|
||
}
|
||
|
||
return state;
|
||
}
|
||
|
||
}
|
||
|
||
var _isDigit = function isDigit(code) {
|
||
return code >= 48 && code <= 57;
|
||
};
|
||
const VALID_REGEX_FLAGS = new Set(["g", "m", "s", "i", "y", "u"]);
|
||
const forbiddenNumericSeparatorSiblings = {
|
||
decBinOct: [46, 66, 69, 79, 95, 98, 101, 111],
|
||
hex: [46, 88, 95, 120]
|
||
};
|
||
const allowedNumericSeparatorSiblings = {};
|
||
allowedNumericSeparatorSiblings.bin = [48, 49];
|
||
allowedNumericSeparatorSiblings.oct = [...allowedNumericSeparatorSiblings.bin, 50, 51, 52, 53, 54, 55];
|
||
allowedNumericSeparatorSiblings.dec = [...allowedNumericSeparatorSiblings.oct, 56, 57];
|
||
allowedNumericSeparatorSiblings.hex = [...allowedNumericSeparatorSiblings.dec, 65, 66, 67, 68, 69, 70, 97, 98, 99, 100, 101, 102];
|
||
class Token {
|
||
constructor(state) {
|
||
this.type = state.type;
|
||
this.value = state.value;
|
||
this.start = state.start;
|
||
this.end = state.end;
|
||
this.loc = new SourceLocation(state.startLoc, state.endLoc);
|
||
}
|
||
|
||
}
|
||
class Tokenizer extends LocationParser {
|
||
constructor(options, input) {
|
||
super();
|
||
this.state = new State();
|
||
this.state.init(options);
|
||
this.input = input;
|
||
this.length = input.length;
|
||
this.isLookahead = false;
|
||
}
|
||
|
||
next() {
|
||
if (this.options.tokens && !this.isLookahead) {
|
||
this.state.tokens.push(new Token(this.state));
|
||
}
|
||
|
||
this.state.lastTokEnd = this.state.end;
|
||
this.state.lastTokStart = this.state.start;
|
||
this.state.lastTokEndLoc = this.state.endLoc;
|
||
this.state.lastTokStartLoc = this.state.startLoc;
|
||
this.nextToken();
|
||
}
|
||
|
||
eat(type) {
|
||
if (this.match(type)) {
|
||
this.next();
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
}
|
||
|
||
match(type) {
|
||
return this.state.type === type;
|
||
}
|
||
|
||
lookahead() {
|
||
const old = this.state;
|
||
this.state = old.clone(true);
|
||
this.isLookahead = true;
|
||
this.next();
|
||
this.isLookahead = false;
|
||
const curr = this.state;
|
||
this.state = old;
|
||
return curr;
|
||
}
|
||
|
||
setStrict(strict) {
|
||
this.state.strict = strict;
|
||
if (!this.match(types.num) && !this.match(types.string)) return;
|
||
this.state.pos = this.state.start;
|
||
|
||
while (this.state.pos < this.state.lineStart) {
|
||
this.state.lineStart = this.input.lastIndexOf("\n", this.state.lineStart - 2) + 1;
|
||
--this.state.curLine;
|
||
}
|
||
|
||
this.nextToken();
|
||
}
|
||
|
||
curContext() {
|
||
return this.state.context[this.state.context.length - 1];
|
||
}
|
||
|
||
nextToken() {
|
||
const curContext = this.curContext();
|
||
if (!curContext || !curContext.preserveSpace) this.skipSpace();
|
||
this.state.containsOctal = false;
|
||
this.state.octalPosition = null;
|
||
this.state.start = this.state.pos;
|
||
this.state.startLoc = this.state.curPosition();
|
||
|
||
if (this.state.pos >= this.length) {
|
||
this.finishToken(types.eof);
|
||
return;
|
||
}
|
||
|
||
if (curContext.override) {
|
||
curContext.override(this);
|
||
} else {
|
||
this.getTokenFromCode(this.input.codePointAt(this.state.pos));
|
||
}
|
||
}
|
||
|
||
pushComment(block, text, start, end, startLoc, endLoc) {
|
||
const comment = {
|
||
type: block ? "CommentBlock" : "CommentLine",
|
||
value: text,
|
||
start: start,
|
||
end: end,
|
||
loc: new SourceLocation(startLoc, endLoc)
|
||
};
|
||
if (this.options.tokens) this.state.tokens.push(comment);
|
||
this.state.comments.push(comment);
|
||
this.addComment(comment);
|
||
}
|
||
|
||
skipBlockComment() {
|
||
const startLoc = this.state.curPosition();
|
||
const start = this.state.pos;
|
||
const end = this.input.indexOf("*/", this.state.pos += 2);
|
||
if (end === -1) this.raise(this.state.pos - 2, "Unterminated comment");
|
||
this.state.pos = end + 2;
|
||
lineBreakG.lastIndex = start;
|
||
let match;
|
||
|
||
while ((match = lineBreakG.exec(this.input)) && match.index < this.state.pos) {
|
||
++this.state.curLine;
|
||
this.state.lineStart = match.index + match[0].length;
|
||
}
|
||
|
||
if (this.isLookahead) return;
|
||
this.pushComment(true, this.input.slice(start + 2, end), start, this.state.pos, startLoc, this.state.curPosition());
|
||
}
|
||
|
||
skipLineComment(startSkip) {
|
||
const start = this.state.pos;
|
||
const startLoc = this.state.curPosition();
|
||
let ch = this.input.charCodeAt(this.state.pos += startSkip);
|
||
|
||
if (this.state.pos < this.length) {
|
||
while (ch !== 10 && ch !== 13 && ch !== 8232 && ch !== 8233 && ++this.state.pos < this.length) {
|
||
ch = this.input.charCodeAt(this.state.pos);
|
||
}
|
||
}
|
||
|
||
if (this.isLookahead) return;
|
||
this.pushComment(false, this.input.slice(start + startSkip, this.state.pos), start, this.state.pos, startLoc, this.state.curPosition());
|
||
}
|
||
|
||
skipSpace() {
|
||
loop: while (this.state.pos < this.length) {
|
||
const ch = this.input.charCodeAt(this.state.pos);
|
||
|
||
switch (ch) {
|
||
case 32:
|
||
case 160:
|
||
case 9:
|
||
++this.state.pos;
|
||
break;
|
||
|
||
case 13:
|
||
if (this.input.charCodeAt(this.state.pos + 1) === 10) {
|
||
++this.state.pos;
|
||
}
|
||
|
||
case 10:
|
||
case 8232:
|
||
case 8233:
|
||
++this.state.pos;
|
||
++this.state.curLine;
|
||
this.state.lineStart = this.state.pos;
|
||
break;
|
||
|
||
case 47:
|
||
switch (this.input.charCodeAt(this.state.pos + 1)) {
|
||
case 42:
|
||
this.skipBlockComment();
|
||
break;
|
||
|
||
case 47:
|
||
this.skipLineComment(2);
|
||
break;
|
||
|
||
default:
|
||
break loop;
|
||
}
|
||
|
||
break;
|
||
|
||
default:
|
||
if (isWhitespace(ch)) {
|
||
++this.state.pos;
|
||
} else {
|
||
break loop;
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
|
||
finishToken(type, val) {
|
||
this.state.end = this.state.pos;
|
||
this.state.endLoc = this.state.curPosition();
|
||
const prevType = this.state.type;
|
||
this.state.type = type;
|
||
this.state.value = val;
|
||
if (!this.isLookahead) this.updateContext(prevType);
|
||
}
|
||
|
||
readToken_numberSign() {
|
||
if (this.state.pos === 0 && this.readToken_interpreter()) {
|
||
return;
|
||
}
|
||
|
||
const nextPos = this.state.pos + 1;
|
||
const next = this.input.charCodeAt(nextPos);
|
||
|
||
if (next >= 48 && next <= 57) {
|
||
this.raise(this.state.pos, "Unexpected digit after hash token");
|
||
}
|
||
|
||
if ((this.hasPlugin("classPrivateProperties") || this.hasPlugin("classPrivateMethods")) && this.state.classLevel > 0) {
|
||
++this.state.pos;
|
||
this.finishToken(types.hash);
|
||
return;
|
||
} else if (this.getPluginOption("pipelineOperator", "proposal") === "smart") {
|
||
this.finishOp(types.hash, 1);
|
||
} else {
|
||
this.raise(this.state.pos, "Unexpected character '#'");
|
||
}
|
||
}
|
||
|
||
readToken_dot() {
|
||
const next = this.input.charCodeAt(this.state.pos + 1);
|
||
|
||
if (next >= 48 && next <= 57) {
|
||
this.readNumber(true);
|
||
return;
|
||
}
|
||
|
||
const next2 = this.input.charCodeAt(this.state.pos + 2);
|
||
|
||
if (next === 46 && next2 === 46) {
|
||
this.state.pos += 3;
|
||
this.finishToken(types.ellipsis);
|
||
} else {
|
||
++this.state.pos;
|
||
this.finishToken(types.dot);
|
||
}
|
||
}
|
||
|
||
readToken_slash() {
|
||
if (this.state.exprAllowed && !this.state.inType) {
|
||
++this.state.pos;
|
||
this.readRegexp();
|
||
return;
|
||
}
|
||
|
||
const next = this.input.charCodeAt(this.state.pos + 1);
|
||
|
||
if (next === 61) {
|
||
this.finishOp(types.assign, 2);
|
||
} else {
|
||
this.finishOp(types.slash, 1);
|
||
}
|
||
}
|
||
|
||
readToken_interpreter() {
|
||
if (this.state.pos !== 0 || this.length < 2) return false;
|
||
const start = this.state.pos;
|
||
this.state.pos += 1;
|
||
let ch = this.input.charCodeAt(this.state.pos);
|
||
if (ch !== 33) return false;
|
||
|
||
while (ch !== 10 && ch !== 13 && ch !== 8232 && ch !== 8233 && ++this.state.pos < this.length) {
|
||
ch = this.input.charCodeAt(this.state.pos);
|
||
}
|
||
|
||
const value = this.input.slice(start + 2, this.state.pos);
|
||
this.finishToken(types.interpreterDirective, value);
|
||
return true;
|
||
}
|
||
|
||
readToken_mult_modulo(code) {
|
||
let type = code === 42 ? types.star : types.modulo;
|
||
let width = 1;
|
||
let next = this.input.charCodeAt(this.state.pos + 1);
|
||
const exprAllowed = this.state.exprAllowed;
|
||
|
||
if (code === 42 && next === 42) {
|
||
width++;
|
||
next = this.input.charCodeAt(this.state.pos + 2);
|
||
type = types.exponent;
|
||
}
|
||
|
||
if (next === 61 && !exprAllowed) {
|
||
width++;
|
||
type = types.assign;
|
||
}
|
||
|
||
this.finishOp(type, width);
|
||
}
|
||
|
||
readToken_pipe_amp(code) {
|
||
const next = this.input.charCodeAt(this.state.pos + 1);
|
||
|
||
if (next === code) {
|
||
if (this.input.charCodeAt(this.state.pos + 2) === 61) {
|
||
this.finishOp(types.assign, 3);
|
||
} else {
|
||
this.finishOp(code === 124 ? types.logicalOR : types.logicalAND, 2);
|
||
}
|
||
|
||
return;
|
||
}
|
||
|
||
if (code === 124) {
|
||
if (next === 62) {
|
||
this.finishOp(types.pipeline, 2);
|
||
return;
|
||
}
|
||
}
|
||
|
||
if (next === 61) {
|
||
this.finishOp(types.assign, 2);
|
||
return;
|
||
}
|
||
|
||
this.finishOp(code === 124 ? types.bitwiseOR : types.bitwiseAND, 1);
|
||
}
|
||
|
||
readToken_caret() {
|
||
const next = this.input.charCodeAt(this.state.pos + 1);
|
||
|
||
if (next === 61) {
|
||
this.finishOp(types.assign, 2);
|
||
} else {
|
||
this.finishOp(types.bitwiseXOR, 1);
|
||
}
|
||
}
|
||
|
||
readToken_plus_min(code) {
|
||
const next = this.input.charCodeAt(this.state.pos + 1);
|
||
|
||
if (next === code) {
|
||
if (next === 45 && !this.inModule && this.input.charCodeAt(this.state.pos + 2) === 62 && (this.state.lastTokEnd === 0 || lineBreak.test(this.input.slice(this.state.lastTokEnd, this.state.pos)))) {
|
||
this.skipLineComment(3);
|
||
this.skipSpace();
|
||
this.nextToken();
|
||
return;
|
||
}
|
||
|
||
this.finishOp(types.incDec, 2);
|
||
return;
|
||
}
|
||
|
||
if (next === 61) {
|
||
this.finishOp(types.assign, 2);
|
||
} else {
|
||
this.finishOp(types.plusMin, 1);
|
||
}
|
||
}
|
||
|
||
readToken_lt_gt(code) {
|
||
const next = this.input.charCodeAt(this.state.pos + 1);
|
||
let size = 1;
|
||
|
||
if (next === code) {
|
||
size = code === 62 && this.input.charCodeAt(this.state.pos + 2) === 62 ? 3 : 2;
|
||
|
||
if (this.input.charCodeAt(this.state.pos + size) === 61) {
|
||
this.finishOp(types.assign, size + 1);
|
||
return;
|
||
}
|
||
|
||
this.finishOp(types.bitShift, size);
|
||
return;
|
||
}
|
||
|
||
if (next === 33 && code === 60 && !this.inModule && this.input.charCodeAt(this.state.pos + 2) === 45 && this.input.charCodeAt(this.state.pos + 3) === 45) {
|
||
this.skipLineComment(4);
|
||
this.skipSpace();
|
||
this.nextToken();
|
||
return;
|
||
}
|
||
|
||
if (next === 61) {
|
||
size = 2;
|
||
}
|
||
|
||
this.finishOp(types.relational, size);
|
||
}
|
||
|
||
readToken_eq_excl(code) {
|
||
const next = this.input.charCodeAt(this.state.pos + 1);
|
||
|
||
if (next === 61) {
|
||
this.finishOp(types.equality, this.input.charCodeAt(this.state.pos + 2) === 61 ? 3 : 2);
|
||
return;
|
||
}
|
||
|
||
if (code === 61 && next === 62) {
|
||
this.state.pos += 2;
|
||
this.finishToken(types.arrow);
|
||
return;
|
||
}
|
||
|
||
this.finishOp(code === 61 ? types.eq : types.bang, 1);
|
||
}
|
||
|
||
readToken_question() {
|
||
const next = this.input.charCodeAt(this.state.pos + 1);
|
||
const next2 = this.input.charCodeAt(this.state.pos + 2);
|
||
|
||
if (next === 63 && !this.state.inType) {
|
||
if (next2 === 61) {
|
||
this.finishOp(types.assign, 3);
|
||
} else {
|
||
this.finishOp(types.nullishCoalescing, 2);
|
||
}
|
||
} else if (next === 46 && !(next2 >= 48 && next2 <= 57)) {
|
||
this.state.pos += 2;
|
||
this.finishToken(types.questionDot);
|
||
} else {
|
||
++this.state.pos;
|
||
this.finishToken(types.question);
|
||
}
|
||
}
|
||
|
||
getTokenFromCode(code) {
|
||
switch (code) {
|
||
case 46:
|
||
this.readToken_dot();
|
||
return;
|
||
|
||
case 40:
|
||
++this.state.pos;
|
||
this.finishToken(types.parenL);
|
||
return;
|
||
|
||
case 41:
|
||
++this.state.pos;
|
||
this.finishToken(types.parenR);
|
||
return;
|
||
|
||
case 59:
|
||
++this.state.pos;
|
||
this.finishToken(types.semi);
|
||
return;
|
||
|
||
case 44:
|
||
++this.state.pos;
|
||
this.finishToken(types.comma);
|
||
return;
|
||
|
||
case 91:
|
||
++this.state.pos;
|
||
this.finishToken(types.bracketL);
|
||
return;
|
||
|
||
case 93:
|
||
++this.state.pos;
|
||
this.finishToken(types.bracketR);
|
||
return;
|
||
|
||
case 123:
|
||
++this.state.pos;
|
||
this.finishToken(types.braceL);
|
||
return;
|
||
|
||
case 125:
|
||
++this.state.pos;
|
||
this.finishToken(types.braceR);
|
||
return;
|
||
|
||
case 58:
|
||
if (this.hasPlugin("functionBind") && this.input.charCodeAt(this.state.pos + 1) === 58) {
|
||
this.finishOp(types.doubleColon, 2);
|
||
} else {
|
||
++this.state.pos;
|
||
this.finishToken(types.colon);
|
||
}
|
||
|
||
return;
|
||
|
||
case 63:
|
||
this.readToken_question();
|
||
return;
|
||
|
||
case 96:
|
||
++this.state.pos;
|
||
this.finishToken(types.backQuote);
|
||
return;
|
||
|
||
case 48:
|
||
{
|
||
const next = this.input.charCodeAt(this.state.pos + 1);
|
||
|
||
if (next === 120 || next === 88) {
|
||
this.readRadixNumber(16);
|
||
return;
|
||
}
|
||
|
||
if (next === 111 || next === 79) {
|
||
this.readRadixNumber(8);
|
||
return;
|
||
}
|
||
|
||
if (next === 98 || next === 66) {
|
||
this.readRadixNumber(2);
|
||
return;
|
||
}
|
||
}
|
||
|
||
case 49:
|
||
case 50:
|
||
case 51:
|
||
case 52:
|
||
case 53:
|
||
case 54:
|
||
case 55:
|
||
case 56:
|
||
case 57:
|
||
this.readNumber(false);
|
||
return;
|
||
|
||
case 34:
|
||
case 39:
|
||
this.readString(code);
|
||
return;
|
||
|
||
case 47:
|
||
this.readToken_slash();
|
||
return;
|
||
|
||
case 37:
|
||
case 42:
|
||
this.readToken_mult_modulo(code);
|
||
return;
|
||
|
||
case 124:
|
||
case 38:
|
||
this.readToken_pipe_amp(code);
|
||
return;
|
||
|
||
case 94:
|
||
this.readToken_caret();
|
||
return;
|
||
|
||
case 43:
|
||
case 45:
|
||
this.readToken_plus_min(code);
|
||
return;
|
||
|
||
case 60:
|
||
case 62:
|
||
this.readToken_lt_gt(code);
|
||
return;
|
||
|
||
case 61:
|
||
case 33:
|
||
this.readToken_eq_excl(code);
|
||
return;
|
||
|
||
case 126:
|
||
this.finishOp(types.tilde, 1);
|
||
return;
|
||
|
||
case 64:
|
||
++this.state.pos;
|
||
this.finishToken(types.at);
|
||
return;
|
||
|
||
case 35:
|
||
this.readToken_numberSign();
|
||
return;
|
||
|
||
case 92:
|
||
this.readWord();
|
||
return;
|
||
|
||
default:
|
||
if (isIdentifierStart(code)) {
|
||
this.readWord();
|
||
return;
|
||
}
|
||
|
||
}
|
||
|
||
this.raise(this.state.pos, `Unexpected character '${String.fromCodePoint(code)}'`);
|
||
}
|
||
|
||
finishOp(type, size) {
|
||
const str = this.input.slice(this.state.pos, this.state.pos + size);
|
||
this.state.pos += size;
|
||
this.finishToken(type, str);
|
||
}
|
||
|
||
readRegexp() {
|
||
const start = this.state.pos;
|
||
let escaped, inClass;
|
||
|
||
for (;;) {
|
||
if (this.state.pos >= this.length) {
|
||
this.raise(start, "Unterminated regular expression");
|
||
}
|
||
|
||
const ch = this.input.charAt(this.state.pos);
|
||
|
||
if (lineBreak.test(ch)) {
|
||
this.raise(start, "Unterminated regular expression");
|
||
}
|
||
|
||
if (escaped) {
|
||
escaped = false;
|
||
} else {
|
||
if (ch === "[") {
|
||
inClass = true;
|
||
} else if (ch === "]" && inClass) {
|
||
inClass = false;
|
||
} else if (ch === "/" && !inClass) {
|
||
break;
|
||
}
|
||
|
||
escaped = ch === "\\";
|
||
}
|
||
|
||
++this.state.pos;
|
||
}
|
||
|
||
const content = this.input.slice(start, this.state.pos);
|
||
++this.state.pos;
|
||
let mods = "";
|
||
|
||
while (this.state.pos < this.length) {
|
||
const char = this.input[this.state.pos];
|
||
const charCode = this.input.codePointAt(this.state.pos);
|
||
|
||
if (VALID_REGEX_FLAGS.has(char)) {
|
||
if (mods.indexOf(char) > -1) {
|
||
this.raise(this.state.pos + 1, "Duplicate regular expression flag");
|
||
}
|
||
|
||
++this.state.pos;
|
||
mods += char;
|
||
} else if (isIdentifierChar(charCode) || charCode === 92) {
|
||
this.raise(this.state.pos + 1, "Invalid regular expression flag");
|
||
} else {
|
||
break;
|
||
}
|
||
}
|
||
|
||
this.finishToken(types.regexp, {
|
||
pattern: content,
|
||
flags: mods
|
||
});
|
||
}
|
||
|
||
readInt(radix, len) {
|
||
const start = this.state.pos;
|
||
const forbiddenSiblings = radix === 16 ? forbiddenNumericSeparatorSiblings.hex : forbiddenNumericSeparatorSiblings.decBinOct;
|
||
const allowedSiblings = radix === 16 ? allowedNumericSeparatorSiblings.hex : radix === 10 ? allowedNumericSeparatorSiblings.dec : radix === 8 ? allowedNumericSeparatorSiblings.oct : allowedNumericSeparatorSiblings.bin;
|
||
let total = 0;
|
||
|
||
for (let i = 0, e = len == null ? Infinity : len; i < e; ++i) {
|
||
const code = this.input.charCodeAt(this.state.pos);
|
||
let val;
|
||
|
||
if (this.hasPlugin("numericSeparator")) {
|
||
const prev = this.input.charCodeAt(this.state.pos - 1);
|
||
const next = this.input.charCodeAt(this.state.pos + 1);
|
||
|
||
if (code === 95) {
|
||
if (allowedSiblings.indexOf(next) === -1) {
|
||
this.raise(this.state.pos, "Invalid or unexpected token");
|
||
}
|
||
|
||
if (forbiddenSiblings.indexOf(prev) > -1 || forbiddenSiblings.indexOf(next) > -1 || Number.isNaN(next)) {
|
||
this.raise(this.state.pos, "Invalid or unexpected token");
|
||
}
|
||
|
||
++this.state.pos;
|
||
continue;
|
||
}
|
||
}
|
||
|
||
if (code >= 97) {
|
||
val = code - 97 + 10;
|
||
} else if (code >= 65) {
|
||
val = code - 65 + 10;
|
||
} else if (_isDigit(code)) {
|
||
val = code - 48;
|
||
} else {
|
||
val = Infinity;
|
||
}
|
||
|
||
if (val >= radix) break;
|
||
++this.state.pos;
|
||
total = total * radix + val;
|
||
}
|
||
|
||
if (this.state.pos === start || len != null && this.state.pos - start !== len) {
|
||
return null;
|
||
}
|
||
|
||
return total;
|
||
}
|
||
|
||
readRadixNumber(radix) {
|
||
const start = this.state.pos;
|
||
let isBigInt = false;
|
||
this.state.pos += 2;
|
||
const val = this.readInt(radix);
|
||
|
||
if (val == null) {
|
||
this.raise(this.state.start + 2, "Expected number in radix " + radix);
|
||
}
|
||
|
||
if (this.hasPlugin("bigInt")) {
|
||
if (this.input.charCodeAt(this.state.pos) === 110) {
|
||
++this.state.pos;
|
||
isBigInt = true;
|
||
}
|
||
}
|
||
|
||
if (isIdentifierStart(this.input.codePointAt(this.state.pos))) {
|
||
this.raise(this.state.pos, "Identifier directly after number");
|
||
}
|
||
|
||
if (isBigInt) {
|
||
const str = this.input.slice(start, this.state.pos).replace(/[_n]/g, "");
|
||
this.finishToken(types.bigint, str);
|
||
return;
|
||
}
|
||
|
||
this.finishToken(types.num, val);
|
||
}
|
||
|
||
readNumber(startsWithDot) {
|
||
const start = this.state.pos;
|
||
let isFloat = false;
|
||
let isBigInt = false;
|
||
|
||
if (!startsWithDot && this.readInt(10) === null) {
|
||
this.raise(start, "Invalid number");
|
||
}
|
||
|
||
let octal = this.state.pos - start >= 2 && this.input.charCodeAt(start) === 48;
|
||
|
||
if (octal) {
|
||
if (this.state.strict) {
|
||
this.raise(start, "Legacy octal literals are not allowed in strict mode");
|
||
}
|
||
|
||
if (/[89]/.test(this.input.slice(start, this.state.pos))) {
|
||
octal = false;
|
||
}
|
||
}
|
||
|
||
let next = this.input.charCodeAt(this.state.pos);
|
||
|
||
if (next === 46 && !octal) {
|
||
++this.state.pos;
|
||
this.readInt(10);
|
||
isFloat = true;
|
||
next = this.input.charCodeAt(this.state.pos);
|
||
}
|
||
|
||
if ((next === 69 || next === 101) && !octal) {
|
||
next = this.input.charCodeAt(++this.state.pos);
|
||
|
||
if (next === 43 || next === 45) {
|
||
++this.state.pos;
|
||
}
|
||
|
||
if (this.readInt(10) === null) this.raise(start, "Invalid number");
|
||
isFloat = true;
|
||
next = this.input.charCodeAt(this.state.pos);
|
||
}
|
||
|
||
if (this.hasPlugin("bigInt")) {
|
||
if (next === 110) {
|
||
if (isFloat || octal) this.raise(start, "Invalid BigIntLiteral");
|
||
++this.state.pos;
|
||
isBigInt = true;
|
||
}
|
||
}
|
||
|
||
if (isIdentifierStart(this.input.codePointAt(this.state.pos))) {
|
||
this.raise(this.state.pos, "Identifier directly after number");
|
||
}
|
||
|
||
const str = this.input.slice(start, this.state.pos).replace(/[_n]/g, "");
|
||
|
||
if (isBigInt) {
|
||
this.finishToken(types.bigint, str);
|
||
return;
|
||
}
|
||
|
||
const val = octal ? parseInt(str, 8) : parseFloat(str);
|
||
this.finishToken(types.num, val);
|
||
}
|
||
|
||
readCodePoint(throwOnInvalid) {
|
||
const ch = this.input.charCodeAt(this.state.pos);
|
||
let code;
|
||
|
||
if (ch === 123) {
|
||
const codePos = ++this.state.pos;
|
||
code = this.readHexChar(this.input.indexOf("}", this.state.pos) - this.state.pos, throwOnInvalid);
|
||
++this.state.pos;
|
||
|
||
if (code === null) {
|
||
--this.state.invalidTemplateEscapePosition;
|
||
} else if (code > 0x10ffff) {
|
||
if (throwOnInvalid) {
|
||
this.raise(codePos, "Code point out of bounds");
|
||
} else {
|
||
this.state.invalidTemplateEscapePosition = codePos - 2;
|
||
return null;
|
||
}
|
||
}
|
||
} else {
|
||
code = this.readHexChar(4, throwOnInvalid);
|
||
}
|
||
|
||
return code;
|
||
}
|
||
|
||
readString(quote) {
|
||
let out = "",
|
||
chunkStart = ++this.state.pos;
|
||
|
||
for (;;) {
|
||
if (this.state.pos >= this.length) {
|
||
this.raise(this.state.start, "Unterminated string constant");
|
||
}
|
||
|
||
const ch = this.input.charCodeAt(this.state.pos);
|
||
if (ch === quote) break;
|
||
|
||
if (ch === 92) {
|
||
out += this.input.slice(chunkStart, this.state.pos);
|
||
out += this.readEscapedChar(false);
|
||
chunkStart = this.state.pos;
|
||
} else if (ch === 8232 || ch === 8233) {
|
||
++this.state.pos;
|
||
++this.state.curLine;
|
||
} else if (isNewLine(ch)) {
|
||
this.raise(this.state.start, "Unterminated string constant");
|
||
} else {
|
||
++this.state.pos;
|
||
}
|
||
}
|
||
|
||
out += this.input.slice(chunkStart, this.state.pos++);
|
||
this.finishToken(types.string, out);
|
||
}
|
||
|
||
readTmplToken() {
|
||
let out = "",
|
||
chunkStart = this.state.pos,
|
||
containsInvalid = false;
|
||
|
||
for (;;) {
|
||
if (this.state.pos >= this.length) {
|
||
this.raise(this.state.start, "Unterminated template");
|
||
}
|
||
|
||
const ch = this.input.charCodeAt(this.state.pos);
|
||
|
||
if (ch === 96 || ch === 36 && this.input.charCodeAt(this.state.pos + 1) === 123) {
|
||
if (this.state.pos === this.state.start && this.match(types.template)) {
|
||
if (ch === 36) {
|
||
this.state.pos += 2;
|
||
this.finishToken(types.dollarBraceL);
|
||
return;
|
||
} else {
|
||
++this.state.pos;
|
||
this.finishToken(types.backQuote);
|
||
return;
|
||
}
|
||
}
|
||
|
||
out += this.input.slice(chunkStart, this.state.pos);
|
||
this.finishToken(types.template, containsInvalid ? null : out);
|
||
return;
|
||
}
|
||
|
||
if (ch === 92) {
|
||
out += this.input.slice(chunkStart, this.state.pos);
|
||
const escaped = this.readEscapedChar(true);
|
||
|
||
if (escaped === null) {
|
||
containsInvalid = true;
|
||
} else {
|
||
out += escaped;
|
||
}
|
||
|
||
chunkStart = this.state.pos;
|
||
} else if (isNewLine(ch)) {
|
||
out += this.input.slice(chunkStart, this.state.pos);
|
||
++this.state.pos;
|
||
|
||
switch (ch) {
|
||
case 13:
|
||
if (this.input.charCodeAt(this.state.pos) === 10) {
|
||
++this.state.pos;
|
||
}
|
||
|
||
case 10:
|
||
out += "\n";
|
||
break;
|
||
|
||
default:
|
||
out += String.fromCharCode(ch);
|
||
break;
|
||
}
|
||
|
||
++this.state.curLine;
|
||
this.state.lineStart = this.state.pos;
|
||
chunkStart = this.state.pos;
|
||
} else {
|
||
++this.state.pos;
|
||
}
|
||
}
|
||
}
|
||
|
||
readEscapedChar(inTemplate) {
|
||
const throwOnInvalid = !inTemplate;
|
||
const ch = this.input.charCodeAt(++this.state.pos);
|
||
++this.state.pos;
|
||
|
||
switch (ch) {
|
||
case 110:
|
||
return "\n";
|
||
|
||
case 114:
|
||
return "\r";
|
||
|
||
case 120:
|
||
{
|
||
const code = this.readHexChar(2, throwOnInvalid);
|
||
return code === null ? null : String.fromCharCode(code);
|
||
}
|
||
|
||
case 117:
|
||
{
|
||
const code = this.readCodePoint(throwOnInvalid);
|
||
return code === null ? null : String.fromCodePoint(code);
|
||
}
|
||
|
||
case 116:
|
||
return "\t";
|
||
|
||
case 98:
|
||
return "\b";
|
||
|
||
case 118:
|
||
return "\u000b";
|
||
|
||
case 102:
|
||
return "\f";
|
||
|
||
case 13:
|
||
if (this.input.charCodeAt(this.state.pos) === 10) {
|
||
++this.state.pos;
|
||
}
|
||
|
||
case 10:
|
||
this.state.lineStart = this.state.pos;
|
||
++this.state.curLine;
|
||
|
||
case 8232:
|
||
case 8233:
|
||
return "";
|
||
|
||
default:
|
||
if (ch >= 48 && ch <= 55) {
|
||
const codePos = this.state.pos - 1;
|
||
let octalStr = this.input.substr(this.state.pos - 1, 3).match(/^[0-7]+/)[0];
|
||
let octal = parseInt(octalStr, 8);
|
||
|
||
if (octal > 255) {
|
||
octalStr = octalStr.slice(0, -1);
|
||
octal = parseInt(octalStr, 8);
|
||
}
|
||
|
||
this.state.pos += octalStr.length - 1;
|
||
const next = this.input.charCodeAt(this.state.pos);
|
||
|
||
if (octalStr !== "0" || next === 56 || next === 57) {
|
||
if (inTemplate) {
|
||
this.state.invalidTemplateEscapePosition = codePos;
|
||
return null;
|
||
} else if (this.state.strict) {
|
||
this.raise(codePos, "Octal literal in strict mode");
|
||
} else if (!this.state.containsOctal) {
|
||
this.state.containsOctal = true;
|
||
this.state.octalPosition = codePos;
|
||
}
|
||
}
|
||
|
||
return String.fromCharCode(octal);
|
||
}
|
||
|
||
return String.fromCharCode(ch);
|
||
}
|
||
}
|
||
|
||
readHexChar(len, throwOnInvalid) {
|
||
const codePos = this.state.pos;
|
||
const n = this.readInt(16, len);
|
||
|
||
if (n === null) {
|
||
if (throwOnInvalid) {
|
||
this.raise(codePos, "Bad character escape sequence");
|
||
} else {
|
||
this.state.pos = codePos - 1;
|
||
this.state.invalidTemplateEscapePosition = codePos - 1;
|
||
}
|
||
}
|
||
|
||
return n;
|
||
}
|
||
|
||
readWord1() {
|
||
let word = "";
|
||
this.state.containsEsc = false;
|
||
const start = this.state.pos;
|
||
let chunkStart = this.state.pos;
|
||
|
||
while (this.state.pos < this.length) {
|
||
const ch = this.input.codePointAt(this.state.pos);
|
||
|
||
if (isIdentifierChar(ch)) {
|
||
this.state.pos += ch <= 0xffff ? 1 : 2;
|
||
} else if (this.state.isIterator && ch === 64) {
|
||
++this.state.pos;
|
||
} else if (ch === 92) {
|
||
this.state.containsEsc = true;
|
||
word += this.input.slice(chunkStart, this.state.pos);
|
||
const escStart = this.state.pos;
|
||
const identifierCheck = this.state.pos === start ? isIdentifierStart : isIdentifierChar;
|
||
|
||
if (this.input.charCodeAt(++this.state.pos) !== 117) {
|
||
this.raise(this.state.pos, "Expecting Unicode escape sequence \\uXXXX");
|
||
}
|
||
|
||
++this.state.pos;
|
||
const esc = this.readCodePoint(true);
|
||
|
||
if (!identifierCheck(esc, true)) {
|
||
this.raise(escStart, "Invalid Unicode escape");
|
||
}
|
||
|
||
word += String.fromCodePoint(esc);
|
||
chunkStart = this.state.pos;
|
||
} else {
|
||
break;
|
||
}
|
||
}
|
||
|
||
return word + this.input.slice(chunkStart, this.state.pos);
|
||
}
|
||
|
||
isIterator(word) {
|
||
return word === "@@iterator" || word === "@@asyncIterator";
|
||
}
|
||
|
||
readWord() {
|
||
const word = this.readWord1();
|
||
const type = keywords.get(word) || types.name;
|
||
|
||
if (type.keyword && this.state.containsEsc) {
|
||
this.raise(this.state.pos, `Escape sequence in keyword ${word}`);
|
||
}
|
||
|
||
if (this.state.isIterator && (!this.isIterator(word) || !this.state.inType)) {
|
||
this.raise(this.state.pos, `Invalid identifier ${word}`);
|
||
}
|
||
|
||
this.finishToken(type, word);
|
||
}
|
||
|
||
braceIsBlock(prevType) {
|
||
const parent = this.curContext();
|
||
|
||
if (parent === types$1.functionExpression || parent === types$1.functionStatement) {
|
||
return true;
|
||
}
|
||
|
||
if (prevType === types.colon && (parent === types$1.braceStatement || parent === types$1.braceExpression)) {
|
||
return !parent.isExpr;
|
||
}
|
||
|
||
if (prevType === types._return || prevType === types.name && this.state.exprAllowed) {
|
||
return lineBreak.test(this.input.slice(this.state.lastTokEnd, this.state.start));
|
||
}
|
||
|
||
if (prevType === types._else || prevType === types.semi || prevType === types.eof || prevType === types.parenR || prevType === types.arrow) {
|
||
return true;
|
||
}
|
||
|
||
if (prevType === types.braceL) {
|
||
return parent === types$1.braceStatement;
|
||
}
|
||
|
||
if (prevType === types._var || prevType === types._const || prevType === types.name) {
|
||
return false;
|
||
}
|
||
|
||
if (prevType === types.relational) {
|
||
return true;
|
||
}
|
||
|
||
return !this.state.exprAllowed;
|
||
}
|
||
|
||
updateContext(prevType) {
|
||
const type = this.state.type;
|
||
let update;
|
||
|
||
if (type.keyword && (prevType === types.dot || prevType === types.questionDot)) {
|
||
this.state.exprAllowed = false;
|
||
} else if (update = type.updateContext) {
|
||
update.call(this, prevType);
|
||
} else {
|
||
this.state.exprAllowed = type.beforeExpr;
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
const literal = /^('|")((?:\\?.)*?)\1/;
|
||
class UtilParser extends Tokenizer {
|
||
addExtra(node, key, val) {
|
||
if (!node) return;
|
||
const extra = node.extra = node.extra || {};
|
||
extra[key] = val;
|
||
}
|
||
|
||
isRelational(op) {
|
||
return this.match(types.relational) && this.state.value === op;
|
||
}
|
||
|
||
isLookaheadRelational(op) {
|
||
const l = this.lookahead();
|
||
return l.type === types.relational && l.value === op;
|
||
}
|
||
|
||
expectRelational(op) {
|
||
if (this.isRelational(op)) {
|
||
this.next();
|
||
} else {
|
||
this.unexpected(null, types.relational);
|
||
}
|
||
}
|
||
|
||
eatRelational(op) {
|
||
if (this.isRelational(op)) {
|
||
this.next();
|
||
return true;
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
isContextual(name) {
|
||
return this.match(types.name) && this.state.value === name && !this.state.containsEsc;
|
||
}
|
||
|
||
isLookaheadContextual(name) {
|
||
const l = this.lookahead();
|
||
return l.type === types.name && l.value === name;
|
||
}
|
||
|
||
eatContextual(name) {
|
||
return this.isContextual(name) && this.eat(types.name);
|
||
}
|
||
|
||
expectContextual(name, message) {
|
||
if (!this.eatContextual(name)) this.unexpected(null, message);
|
||
}
|
||
|
||
canInsertSemicolon() {
|
||
return this.match(types.eof) || this.match(types.braceR) || this.hasPrecedingLineBreak();
|
||
}
|
||
|
||
hasPrecedingLineBreak() {
|
||
return lineBreak.test(this.input.slice(this.state.lastTokEnd, this.state.start));
|
||
}
|
||
|
||
isLineTerminator() {
|
||
return this.eat(types.semi) || this.canInsertSemicolon();
|
||
}
|
||
|
||
semicolon() {
|
||
if (!this.isLineTerminator()) this.unexpected(null, types.semi);
|
||
}
|
||
|
||
expect(type, pos) {
|
||
this.eat(type) || this.unexpected(pos, type);
|
||
}
|
||
|
||
assertNoSpace(message = "Unexpected space.") {
|
||
if (this.state.start > this.state.lastTokEnd) {
|
||
this.raise(this.state.lastTokEnd, message);
|
||
}
|
||
}
|
||
|
||
unexpected(pos, messageOrType = "Unexpected token") {
|
||
if (typeof messageOrType !== "string") {
|
||
messageOrType = `Unexpected token, expected "${messageOrType.label}"`;
|
||
}
|
||
|
||
throw this.raise(pos != null ? pos : this.state.start, messageOrType);
|
||
}
|
||
|
||
expectPlugin(name, pos) {
|
||
if (!this.hasPlugin(name)) {
|
||
throw this.raise(pos != null ? pos : this.state.start, `This experimental syntax requires enabling the parser plugin: '${name}'`, {
|
||
missingPluginNames: [name]
|
||
});
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
expectOnePlugin(names, pos) {
|
||
if (!names.some(n => this.hasPlugin(n))) {
|
||
throw this.raise(pos != null ? pos : this.state.start, `This experimental syntax requires enabling one of the following parser plugin(s): '${names.join(", ")}'`, {
|
||
missingPluginNames: names
|
||
});
|
||
}
|
||
}
|
||
|
||
checkYieldAwaitInDefaultParams() {
|
||
if (this.state.yieldPos && (!this.state.awaitPos || this.state.yieldPos < this.state.awaitPos)) {
|
||
this.raise(this.state.yieldPos, "Yield cannot be used as name inside a generator function");
|
||
}
|
||
|
||
if (this.state.awaitPos) {
|
||
this.raise(this.state.awaitPos, "Await cannot be used as name inside an async function");
|
||
}
|
||
}
|
||
|
||
strictDirective(start) {
|
||
for (;;) {
|
||
skipWhiteSpace.lastIndex = start;
|
||
start += skipWhiteSpace.exec(this.input)[0].length;
|
||
const match = literal.exec(this.input.slice(start));
|
||
if (!match) break;
|
||
if (match[2] === "use strict") return true;
|
||
start += match[0].length;
|
||
skipWhiteSpace.lastIndex = start;
|
||
start += skipWhiteSpace.exec(this.input)[0].length;
|
||
|
||
if (this.input[start] === ";") {
|
||
start++;
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
}
|
||
|
||
class Node {
|
||
constructor(parser, pos, loc) {
|
||
this.type = "";
|
||
this.start = pos;
|
||
this.end = 0;
|
||
this.loc = new SourceLocation(loc);
|
||
if (parser && parser.options.ranges) this.range = [pos, 0];
|
||
if (parser && parser.filename) this.loc.filename = parser.filename;
|
||
}
|
||
|
||
__clone() {
|
||
const newNode = new Node();
|
||
const keys = Object.keys(this);
|
||
|
||
for (let i = 0, length = keys.length; i < length; i++) {
|
||
const key = keys[i];
|
||
|
||
if (key !== "leadingComments" && key !== "trailingComments" && key !== "innerComments") {
|
||
newNode[key] = this[key];
|
||
}
|
||
}
|
||
|
||
return newNode;
|
||
}
|
||
|
||
}
|
||
|
||
class NodeUtils extends UtilParser {
|
||
startNode() {
|
||
return new Node(this, this.state.start, this.state.startLoc);
|
||
}
|
||
|
||
startNodeAt(pos, loc) {
|
||
return new Node(this, pos, loc);
|
||
}
|
||
|
||
startNodeAtNode(type) {
|
||
return this.startNodeAt(type.start, type.loc.start);
|
||
}
|
||
|
||
finishNode(node, type) {
|
||
return this.finishNodeAt(node, type, this.state.lastTokEnd, this.state.lastTokEndLoc);
|
||
}
|
||
|
||
finishNodeAt(node, type, pos, loc) {
|
||
|
||
node.type = type;
|
||
node.end = pos;
|
||
node.loc.end = loc;
|
||
if (this.options.ranges) node.range[1] = pos;
|
||
this.processComment(node);
|
||
return node;
|
||
}
|
||
|
||
resetStartLocation(node, start, startLoc) {
|
||
node.start = start;
|
||
node.loc.start = startLoc;
|
||
if (this.options.ranges) node.range[0] = start;
|
||
}
|
||
|
||
resetEndLocation(node, end = this.state.lastTokEnd, endLoc = this.state.lastTokEndLoc) {
|
||
node.end = end;
|
||
node.loc.end = endLoc;
|
||
if (this.options.ranges) node.range[1] = end;
|
||
}
|
||
|
||
resetStartLocationFromNode(node, locationNode) {
|
||
this.resetStartLocation(node, locationNode.start, locationNode.loc.start);
|
||
}
|
||
|
||
}
|
||
|
||
class LValParser extends NodeUtils {
|
||
toAssignable(node, isBinding, contextDescription) {
|
||
if (node) {
|
||
switch (node.type) {
|
||
case "Identifier":
|
||
case "ObjectPattern":
|
||
case "ArrayPattern":
|
||
case "AssignmentPattern":
|
||
break;
|
||
|
||
case "ObjectExpression":
|
||
node.type = "ObjectPattern";
|
||
|
||
for (let i = 0, length = node.properties.length, last = length - 1; i < length; i++) {
|
||
const prop = node.properties[i];
|
||
const isLast = i === last;
|
||
this.toAssignableObjectExpressionProp(prop, isBinding, isLast);
|
||
}
|
||
|
||
break;
|
||
|
||
case "ObjectProperty":
|
||
this.toAssignable(node.value, isBinding, contextDescription);
|
||
break;
|
||
|
||
case "SpreadElement":
|
||
{
|
||
this.checkToRestConversion(node);
|
||
node.type = "RestElement";
|
||
const arg = node.argument;
|
||
this.toAssignable(arg, isBinding, contextDescription);
|
||
break;
|
||
}
|
||
|
||
case "ArrayExpression":
|
||
node.type = "ArrayPattern";
|
||
this.toAssignableList(node.elements, isBinding, contextDescription);
|
||
break;
|
||
|
||
case "AssignmentExpression":
|
||
if (node.operator === "=") {
|
||
node.type = "AssignmentPattern";
|
||
delete node.operator;
|
||
} else {
|
||
this.raise(node.left.end, "Only '=' operator can be used for specifying default value.");
|
||
}
|
||
|
||
break;
|
||
|
||
case "ParenthesizedExpression":
|
||
node.expression = this.toAssignable(node.expression, isBinding, contextDescription);
|
||
break;
|
||
|
||
case "MemberExpression":
|
||
if (!isBinding) break;
|
||
|
||
default:
|
||
{
|
||
const message = "Invalid left-hand side" + (contextDescription ? " in " + contextDescription : "expression");
|
||
this.raise(node.start, message);
|
||
}
|
||
}
|
||
}
|
||
|
||
return node;
|
||
}
|
||
|
||
toAssignableObjectExpressionProp(prop, isBinding, isLast) {
|
||
if (prop.type === "ObjectMethod") {
|
||
const error = prop.kind === "get" || prop.kind === "set" ? "Object pattern can't contain getter or setter" : "Object pattern can't contain methods";
|
||
this.raise(prop.key.start, error);
|
||
} else if (prop.type === "SpreadElement" && !isLast) {
|
||
this.raiseRestNotLast(prop.start);
|
||
} else {
|
||
this.toAssignable(prop, isBinding, "object destructuring pattern");
|
||
}
|
||
}
|
||
|
||
toAssignableList(exprList, isBinding, contextDescription) {
|
||
let end = exprList.length;
|
||
|
||
if (end) {
|
||
const last = exprList[end - 1];
|
||
|
||
if (last && last.type === "RestElement") {
|
||
--end;
|
||
} else if (last && last.type === "SpreadElement") {
|
||
last.type = "RestElement";
|
||
const arg = last.argument;
|
||
this.toAssignable(arg, isBinding, contextDescription);
|
||
|
||
if (arg.type !== "Identifier" && arg.type !== "MemberExpression" && arg.type !== "ArrayPattern" && arg.type !== "ObjectPattern") {
|
||
this.unexpected(arg.start);
|
||
}
|
||
|
||
--end;
|
||
}
|
||
}
|
||
|
||
for (let i = 0; i < end; i++) {
|
||
const elt = exprList[i];
|
||
|
||
if (elt) {
|
||
this.toAssignable(elt, isBinding, contextDescription);
|
||
|
||
if (elt.type === "RestElement") {
|
||
this.raiseRestNotLast(elt.start);
|
||
}
|
||
}
|
||
}
|
||
|
||
return exprList;
|
||
}
|
||
|
||
toReferencedList(exprList, isParenthesizedExpr) {
|
||
return exprList;
|
||
}
|
||
|
||
toReferencedListDeep(exprList, isParenthesizedExpr) {
|
||
this.toReferencedList(exprList, isParenthesizedExpr);
|
||
|
||
for (let _i = 0; _i < exprList.length; _i++) {
|
||
const expr = exprList[_i];
|
||
|
||
if (expr && expr.type === "ArrayExpression") {
|
||
this.toReferencedListDeep(expr.elements);
|
||
}
|
||
}
|
||
|
||
return exprList;
|
||
}
|
||
|
||
parseSpread(refShorthandDefaultPos, refNeedsArrowPos) {
|
||
const node = this.startNode();
|
||
this.next();
|
||
node.argument = this.parseMaybeAssign(false, refShorthandDefaultPos, undefined, refNeedsArrowPos);
|
||
|
||
if (this.state.commaAfterSpreadAt === -1 && this.match(types.comma)) {
|
||
this.state.commaAfterSpreadAt = this.state.start;
|
||
}
|
||
|
||
return this.finishNode(node, "SpreadElement");
|
||
}
|
||
|
||
parseRestBinding() {
|
||
const node = this.startNode();
|
||
this.next();
|
||
node.argument = this.parseBindingAtom();
|
||
return this.finishNode(node, "RestElement");
|
||
}
|
||
|
||
parseBindingAtom() {
|
||
switch (this.state.type) {
|
||
case types.bracketL:
|
||
{
|
||
const node = this.startNode();
|
||
this.next();
|
||
node.elements = this.parseBindingList(types.bracketR, true);
|
||
return this.finishNode(node, "ArrayPattern");
|
||
}
|
||
|
||
case types.braceL:
|
||
return this.parseObj(true);
|
||
}
|
||
|
||
return this.parseIdentifier();
|
||
}
|
||
|
||
parseBindingList(close, allowEmpty, allowModifiers) {
|
||
const elts = [];
|
||
let first = true;
|
||
|
||
while (!this.eat(close)) {
|
||
if (first) {
|
||
first = false;
|
||
} else {
|
||
this.expect(types.comma);
|
||
}
|
||
|
||
if (allowEmpty && this.match(types.comma)) {
|
||
elts.push(null);
|
||
} else if (this.eat(close)) {
|
||
break;
|
||
} else if (this.match(types.ellipsis)) {
|
||
elts.push(this.parseAssignableListItemTypes(this.parseRestBinding()));
|
||
this.checkCommaAfterRest();
|
||
this.expect(close);
|
||
break;
|
||
} else {
|
||
const decorators = [];
|
||
|
||
if (this.match(types.at) && this.hasPlugin("decorators")) {
|
||
this.raise(this.state.start, "Stage 2 decorators cannot be used to decorate parameters");
|
||
}
|
||
|
||
while (this.match(types.at)) {
|
||
decorators.push(this.parseDecorator());
|
||
}
|
||
|
||
elts.push(this.parseAssignableListItem(allowModifiers, decorators));
|
||
}
|
||
}
|
||
|
||
return elts;
|
||
}
|
||
|
||
parseAssignableListItem(allowModifiers, decorators) {
|
||
const left = this.parseMaybeDefault();
|
||
this.parseAssignableListItemTypes(left);
|
||
const elt = this.parseMaybeDefault(left.start, left.loc.start, left);
|
||
|
||
if (decorators.length) {
|
||
left.decorators = decorators;
|
||
}
|
||
|
||
return elt;
|
||
}
|
||
|
||
parseAssignableListItemTypes(param) {
|
||
return param;
|
||
}
|
||
|
||
parseMaybeDefault(startPos, startLoc, left) {
|
||
startLoc = startLoc || this.state.startLoc;
|
||
startPos = startPos || this.state.start;
|
||
left = left || this.parseBindingAtom();
|
||
if (!this.eat(types.eq)) return left;
|
||
const node = this.startNodeAt(startPos, startLoc);
|
||
node.left = left;
|
||
node.right = this.parseMaybeAssign();
|
||
return this.finishNode(node, "AssignmentPattern");
|
||
}
|
||
|
||
checkLVal(expr, bindingType = BIND_NONE, checkClashes, contextDescription) {
|
||
switch (expr.type) {
|
||
case "Identifier":
|
||
if (this.state.strict && isStrictBindReservedWord(expr.name, this.inModule)) {
|
||
this.raise(expr.start, `${bindingType === BIND_NONE ? "Assigning to" : "Binding"} '${expr.name}' in strict mode`);
|
||
}
|
||
|
||
if (checkClashes) {
|
||
const key = `_${expr.name}`;
|
||
|
||
if (checkClashes[key]) {
|
||
this.raise(expr.start, "Argument name clash");
|
||
} else {
|
||
checkClashes[key] = true;
|
||
}
|
||
}
|
||
|
||
if (bindingType === BIND_LEXICAL && expr.name === "let") {
|
||
this.raise(expr.start, "'let' is not allowed to be used as a name in 'let' or 'const' declarations.");
|
||
}
|
||
|
||
if (!(bindingType & BIND_NONE)) {
|
||
this.scope.declareName(expr.name, bindingType, expr.start);
|
||
}
|
||
|
||
break;
|
||
|
||
case "MemberExpression":
|
||
if (bindingType !== BIND_NONE) {
|
||
this.raise(expr.start, "Binding member expression");
|
||
}
|
||
|
||
break;
|
||
|
||
case "ObjectPattern":
|
||
for (let _i2 = 0, _expr$properties = expr.properties; _i2 < _expr$properties.length; _i2++) {
|
||
let prop = _expr$properties[_i2];
|
||
if (prop.type === "ObjectProperty") prop = prop.value;
|
||
this.checkLVal(prop, bindingType, checkClashes, "object destructuring pattern");
|
||
}
|
||
|
||
break;
|
||
|
||
case "ArrayPattern":
|
||
for (let _i3 = 0, _expr$elements = expr.elements; _i3 < _expr$elements.length; _i3++) {
|
||
const elem = _expr$elements[_i3];
|
||
|
||
if (elem) {
|
||
this.checkLVal(elem, bindingType, checkClashes, "array destructuring pattern");
|
||
}
|
||
}
|
||
|
||
break;
|
||
|
||
case "AssignmentPattern":
|
||
this.checkLVal(expr.left, bindingType, checkClashes, "assignment pattern");
|
||
break;
|
||
|
||
case "RestElement":
|
||
this.checkLVal(expr.argument, bindingType, checkClashes, "rest element");
|
||
break;
|
||
|
||
case "ParenthesizedExpression":
|
||
this.checkLVal(expr.expression, bindingType, checkClashes, "parenthesized expression");
|
||
break;
|
||
|
||
default:
|
||
{
|
||
const message = (bindingType === BIND_NONE ? "Invalid" : "Binding invalid") + " left-hand side" + (contextDescription ? " in " + contextDescription : "expression");
|
||
this.raise(expr.start, message);
|
||
}
|
||
}
|
||
}
|
||
|
||
checkToRestConversion(node) {
|
||
if (node.argument.type !== "Identifier" && node.argument.type !== "MemberExpression") {
|
||
this.raise(node.argument.start, "Invalid rest operator's argument");
|
||
}
|
||
}
|
||
|
||
checkCommaAfterRest() {
|
||
if (this.match(types.comma)) {
|
||
this.raiseRestNotLast(this.state.start);
|
||
}
|
||
}
|
||
|
||
checkCommaAfterRestFromSpread() {
|
||
if (this.state.commaAfterSpreadAt > -1) {
|
||
this.raiseRestNotLast(this.state.commaAfterSpreadAt);
|
||
}
|
||
}
|
||
|
||
raiseRestNotLast(pos) {
|
||
this.raise(pos, `Rest element must be last element`);
|
||
}
|
||
|
||
}
|
||
|
||
const unwrapParenthesizedExpression = node => {
|
||
return node.type === "ParenthesizedExpression" ? unwrapParenthesizedExpression(node.expression) : node;
|
||
};
|
||
|
||
class ExpressionParser extends LValParser {
|
||
checkPropClash(prop, propHash) {
|
||
if (prop.type === "SpreadElement" || prop.computed || prop.kind || prop.shorthand) {
|
||
return;
|
||
}
|
||
|
||
const key = prop.key;
|
||
const name = key.type === "Identifier" ? key.name : String(key.value);
|
||
|
||
if (name === "__proto__") {
|
||
if (propHash.proto) {
|
||
this.raise(key.start, "Redefinition of __proto__ property");
|
||
}
|
||
|
||
propHash.proto = true;
|
||
}
|
||
}
|
||
|
||
getExpression() {
|
||
this.scope.enter(SCOPE_PROGRAM);
|
||
this.nextToken();
|
||
const expr = this.parseExpression();
|
||
|
||
if (!this.match(types.eof)) {
|
||
this.unexpected();
|
||
}
|
||
|
||
expr.comments = this.state.comments;
|
||
return expr;
|
||
}
|
||
|
||
parseExpression(noIn, refShorthandDefaultPos) {
|
||
const startPos = this.state.start;
|
||
const startLoc = this.state.startLoc;
|
||
const expr = this.parseMaybeAssign(noIn, refShorthandDefaultPos);
|
||
|
||
if (this.match(types.comma)) {
|
||
const node = this.startNodeAt(startPos, startLoc);
|
||
node.expressions = [expr];
|
||
|
||
while (this.eat(types.comma)) {
|
||
node.expressions.push(this.parseMaybeAssign(noIn, refShorthandDefaultPos));
|
||
}
|
||
|
||
this.toReferencedList(node.expressions);
|
||
return this.finishNode(node, "SequenceExpression");
|
||
}
|
||
|
||
return expr;
|
||
}
|
||
|
||
parseMaybeAssign(noIn, refShorthandDefaultPos, afterLeftParse, refNeedsArrowPos) {
|
||
const startPos = this.state.start;
|
||
const startLoc = this.state.startLoc;
|
||
|
||
if (this.isContextual("yield")) {
|
||
if (this.scope.inGenerator) {
|
||
let left = this.parseYield(noIn);
|
||
|
||
if (afterLeftParse) {
|
||
left = afterLeftParse.call(this, left, startPos, startLoc);
|
||
}
|
||
|
||
return left;
|
||
} else {
|
||
this.state.exprAllowed = false;
|
||
}
|
||
}
|
||
|
||
const oldCommaAfterSpreadAt = this.state.commaAfterSpreadAt;
|
||
this.state.commaAfterSpreadAt = -1;
|
||
let failOnShorthandAssign;
|
||
|
||
if (refShorthandDefaultPos) {
|
||
failOnShorthandAssign = false;
|
||
} else {
|
||
refShorthandDefaultPos = {
|
||
start: 0
|
||
};
|
||
failOnShorthandAssign = true;
|
||
}
|
||
|
||
if (this.match(types.parenL) || this.match(types.name)) {
|
||
this.state.potentialArrowAt = this.state.start;
|
||
}
|
||
|
||
let left = this.parseMaybeConditional(noIn, refShorthandDefaultPos, refNeedsArrowPos);
|
||
|
||
if (afterLeftParse) {
|
||
left = afterLeftParse.call(this, left, startPos, startLoc);
|
||
}
|
||
|
||
if (this.state.type.isAssign) {
|
||
const node = this.startNodeAt(startPos, startLoc);
|
||
const operator = this.state.value;
|
||
node.operator = operator;
|
||
|
||
if (operator === "??=") {
|
||
this.expectPlugin("nullishCoalescingOperator");
|
||
this.expectPlugin("logicalAssignment");
|
||
}
|
||
|
||
if (operator === "||=" || operator === "&&=") {
|
||
this.expectPlugin("logicalAssignment");
|
||
}
|
||
|
||
node.left = this.match(types.eq) ? this.toAssignable(left, undefined, "assignment expression") : left;
|
||
refShorthandDefaultPos.start = 0;
|
||
this.checkLVal(left, undefined, undefined, "assignment expression");
|
||
const maybePattern = unwrapParenthesizedExpression(left);
|
||
let patternErrorMsg;
|
||
|
||
if (maybePattern.type === "ObjectPattern") {
|
||
patternErrorMsg = "`({a}) = 0` use `({a} = 0)`";
|
||
} else if (maybePattern.type === "ArrayPattern") {
|
||
patternErrorMsg = "`([a]) = 0` use `([a] = 0)`";
|
||
}
|
||
|
||
if (patternErrorMsg && (left.extra && left.extra.parenthesized || left.type === "ParenthesizedExpression")) {
|
||
this.raise(maybePattern.start, `You're trying to assign to a parenthesized expression, eg. instead of ${patternErrorMsg}`);
|
||
}
|
||
|
||
if (patternErrorMsg) this.checkCommaAfterRestFromSpread();
|
||
this.state.commaAfterSpreadAt = oldCommaAfterSpreadAt;
|
||
this.next();
|
||
node.right = this.parseMaybeAssign(noIn);
|
||
return this.finishNode(node, "AssignmentExpression");
|
||
} else if (failOnShorthandAssign && refShorthandDefaultPos.start) {
|
||
this.unexpected(refShorthandDefaultPos.start);
|
||
}
|
||
|
||
this.state.commaAfterSpreadAt = oldCommaAfterSpreadAt;
|
||
return left;
|
||
}
|
||
|
||
parseMaybeConditional(noIn, refShorthandDefaultPos, refNeedsArrowPos) {
|
||
const startPos = this.state.start;
|
||
const startLoc = this.state.startLoc;
|
||
const potentialArrowAt = this.state.potentialArrowAt;
|
||
const expr = this.parseExprOps(noIn, refShorthandDefaultPos);
|
||
|
||
if (expr.type === "ArrowFunctionExpression" && expr.start === potentialArrowAt) {
|
||
return expr;
|
||
}
|
||
|
||
if (refShorthandDefaultPos && refShorthandDefaultPos.start) return expr;
|
||
return this.parseConditional(expr, noIn, startPos, startLoc, refNeedsArrowPos);
|
||
}
|
||
|
||
parseConditional(expr, noIn, startPos, startLoc, refNeedsArrowPos) {
|
||
if (this.eat(types.question)) {
|
||
const node = this.startNodeAt(startPos, startLoc);
|
||
node.test = expr;
|
||
node.consequent = this.parseMaybeAssign();
|
||
this.expect(types.colon);
|
||
node.alternate = this.parseMaybeAssign(noIn);
|
||
return this.finishNode(node, "ConditionalExpression");
|
||
}
|
||
|
||
return expr;
|
||
}
|
||
|
||
parseExprOps(noIn, refShorthandDefaultPos) {
|
||
const startPos = this.state.start;
|
||
const startLoc = this.state.startLoc;
|
||
const potentialArrowAt = this.state.potentialArrowAt;
|
||
const expr = this.parseMaybeUnary(refShorthandDefaultPos);
|
||
|
||
if (expr.type === "ArrowFunctionExpression" && expr.start === potentialArrowAt) {
|
||
return expr;
|
||
}
|
||
|
||
if (refShorthandDefaultPos && refShorthandDefaultPos.start) {
|
||
return expr;
|
||
}
|
||
|
||
return this.parseExprOp(expr, startPos, startLoc, -1, noIn);
|
||
}
|
||
|
||
parseExprOp(left, leftStartPos, leftStartLoc, minPrec, noIn) {
|
||
const prec = this.state.type.binop;
|
||
|
||
if (prec != null && (!noIn || !this.match(types._in))) {
|
||
if (prec > minPrec) {
|
||
const operator = this.state.value;
|
||
|
||
if (operator === "|>" && this.state.inFSharpPipelineDirectBody) {
|
||
return left;
|
||
}
|
||
|
||
const node = this.startNodeAt(leftStartPos, leftStartLoc);
|
||
node.left = left;
|
||
node.operator = operator;
|
||
|
||
if (operator === "**" && left.type === "UnaryExpression" && (this.options.createParenthesizedExpressions || !(left.extra && left.extra.parenthesized))) {
|
||
this.raise(left.argument.start, "Illegal expression. Wrap left hand side or entire exponentiation in parentheses.");
|
||
}
|
||
|
||
const op = this.state.type;
|
||
|
||
if (op === types.pipeline) {
|
||
this.expectPlugin("pipelineOperator");
|
||
this.state.inPipeline = true;
|
||
this.checkPipelineAtInfixOperator(left, leftStartPos);
|
||
} else if (op === types.nullishCoalescing) {
|
||
this.expectPlugin("nullishCoalescingOperator");
|
||
}
|
||
|
||
this.next();
|
||
|
||
if (op === types.pipeline && this.getPluginOption("pipelineOperator", "proposal") === "minimal") {
|
||
if (this.match(types.name) && this.state.value === "await" && this.scope.inAsync) {
|
||
throw this.raise(this.state.start, `Unexpected "await" after pipeline body; await must have parentheses in minimal proposal`);
|
||
}
|
||
}
|
||
|
||
node.right = this.parseExprOpRightExpr(op, prec, noIn);
|
||
this.finishNode(node, op === types.logicalOR || op === types.logicalAND || op === types.nullishCoalescing ? "LogicalExpression" : "BinaryExpression");
|
||
return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, noIn);
|
||
}
|
||
}
|
||
|
||
return left;
|
||
}
|
||
|
||
parseExprOpRightExpr(op, prec, noIn) {
|
||
const startPos = this.state.start;
|
||
const startLoc = this.state.startLoc;
|
||
|
||
switch (op) {
|
||
case types.pipeline:
|
||
switch (this.getPluginOption("pipelineOperator", "proposal")) {
|
||
case "smart":
|
||
return this.withTopicPermittingContext(() => {
|
||
return this.parseSmartPipelineBody(this.parseExprOpBaseRightExpr(op, prec, noIn), startPos, startLoc);
|
||
});
|
||
|
||
case "fsharp":
|
||
return this.withSoloAwaitPermittingContext(() => {
|
||
return this.parseFSharpPipelineBody(prec, noIn);
|
||
});
|
||
}
|
||
|
||
default:
|
||
return this.parseExprOpBaseRightExpr(op, prec, noIn);
|
||
}
|
||
}
|
||
|
||
parseExprOpBaseRightExpr(op, prec, noIn) {
|
||
const startPos = this.state.start;
|
||
const startLoc = this.state.startLoc;
|
||
return this.parseExprOp(this.parseMaybeUnary(), startPos, startLoc, op.rightAssociative ? prec - 1 : prec, noIn);
|
||
}
|
||
|
||
parseMaybeUnary(refShorthandDefaultPos) {
|
||
if (this.isContextual("await") && (this.scope.inAsync || !this.scope.inFunction && this.options.allowAwaitOutsideFunction)) {
|
||
return this.parseAwait();
|
||
} else if (this.state.type.prefix) {
|
||
const node = this.startNode();
|
||
const update = this.match(types.incDec);
|
||
node.operator = this.state.value;
|
||
node.prefix = true;
|
||
|
||
if (node.operator === "throw") {
|
||
this.expectPlugin("throwExpressions");
|
||
}
|
||
|
||
this.next();
|
||
node.argument = this.parseMaybeUnary();
|
||
|
||
if (refShorthandDefaultPos && refShorthandDefaultPos.start) {
|
||
this.unexpected(refShorthandDefaultPos.start);
|
||
}
|
||
|
||
if (update) {
|
||
this.checkLVal(node.argument, undefined, undefined, "prefix operation");
|
||
} else if (this.state.strict && node.operator === "delete") {
|
||
const arg = node.argument;
|
||
|
||
if (arg.type === "Identifier") {
|
||
this.raise(node.start, "Deleting local variable in strict mode");
|
||
} else if (arg.type === "MemberExpression" && arg.property.type === "PrivateName") {
|
||
this.raise(node.start, "Deleting a private field is not allowed");
|
||
}
|
||
}
|
||
|
||
return this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression");
|
||
}
|
||
|
||
const startPos = this.state.start;
|
||
const startLoc = this.state.startLoc;
|
||
let expr = this.parseExprSubscripts(refShorthandDefaultPos);
|
||
if (refShorthandDefaultPos && refShorthandDefaultPos.start) return expr;
|
||
|
||
while (this.state.type.postfix && !this.canInsertSemicolon()) {
|
||
const node = this.startNodeAt(startPos, startLoc);
|
||
node.operator = this.state.value;
|
||
node.prefix = false;
|
||
node.argument = expr;
|
||
this.checkLVal(expr, undefined, undefined, "postfix operation");
|
||
this.next();
|
||
expr = this.finishNode(node, "UpdateExpression");
|
||
}
|
||
|
||
return expr;
|
||
}
|
||
|
||
parseExprSubscripts(refShorthandDefaultPos) {
|
||
const startPos = this.state.start;
|
||
const startLoc = this.state.startLoc;
|
||
const potentialArrowAt = this.state.potentialArrowAt;
|
||
const expr = this.parseExprAtom(refShorthandDefaultPos);
|
||
|
||
if (expr.type === "ArrowFunctionExpression" && expr.start === potentialArrowAt) {
|
||
return expr;
|
||
}
|
||
|
||
if (refShorthandDefaultPos && refShorthandDefaultPos.start) {
|
||
return expr;
|
||
}
|
||
|
||
return this.parseSubscripts(expr, startPos, startLoc);
|
||
}
|
||
|
||
parseSubscripts(base, startPos, startLoc, noCalls) {
|
||
const maybeAsyncArrow = this.atPossibleAsync(base);
|
||
const state = {
|
||
optionalChainMember: false,
|
||
stop: false
|
||
};
|
||
|
||
do {
|
||
base = this.parseSubscript(base, startPos, startLoc, noCalls, state, maybeAsyncArrow);
|
||
} while (!state.stop);
|
||
|
||
return base;
|
||
}
|
||
|
||
parseSubscript(base, startPos, startLoc, noCalls, state, maybeAsyncArrow) {
|
||
if (!noCalls && this.eat(types.doubleColon)) {
|
||
const node = this.startNodeAt(startPos, startLoc);
|
||
node.object = base;
|
||
node.callee = this.parseNoCallExpr();
|
||
state.stop = true;
|
||
return this.parseSubscripts(this.finishNode(node, "BindExpression"), startPos, startLoc, noCalls);
|
||
} else if (this.match(types.questionDot)) {
|
||
this.expectPlugin("optionalChaining");
|
||
state.optionalChainMember = true;
|
||
|
||
if (noCalls && this.lookahead().type === types.parenL) {
|
||
state.stop = true;
|
||
return base;
|
||
}
|
||
|
||
this.next();
|
||
const node = this.startNodeAt(startPos, startLoc);
|
||
|
||
if (this.eat(types.bracketL)) {
|
||
node.object = base;
|
||
node.property = this.parseExpression();
|
||
node.computed = true;
|
||
node.optional = true;
|
||
this.expect(types.bracketR);
|
||
return this.finishNode(node, "OptionalMemberExpression");
|
||
} else if (this.eat(types.parenL)) {
|
||
node.callee = base;
|
||
node.arguments = this.parseCallExpressionArguments(types.parenR, false);
|
||
node.optional = true;
|
||
return this.finishNode(node, "OptionalCallExpression");
|
||
} else {
|
||
node.object = base;
|
||
node.property = this.parseIdentifier(true);
|
||
node.computed = false;
|
||
node.optional = true;
|
||
return this.finishNode(node, "OptionalMemberExpression");
|
||
}
|
||
} else if (this.eat(types.dot)) {
|
||
const node = this.startNodeAt(startPos, startLoc);
|
||
node.object = base;
|
||
node.property = this.parseMaybePrivateName();
|
||
node.computed = false;
|
||
|
||
if (state.optionalChainMember) {
|
||
node.optional = false;
|
||
return this.finishNode(node, "OptionalMemberExpression");
|
||
}
|
||
|
||
return this.finishNode(node, "MemberExpression");
|
||
} else if (this.eat(types.bracketL)) {
|
||
const node = this.startNodeAt(startPos, startLoc);
|
||
node.object = base;
|
||
node.property = this.parseExpression();
|
||
node.computed = true;
|
||
this.expect(types.bracketR);
|
||
|
||
if (state.optionalChainMember) {
|
||
node.optional = false;
|
||
return this.finishNode(node, "OptionalMemberExpression");
|
||
}
|
||
|
||
return this.finishNode(node, "MemberExpression");
|
||
} else if (!noCalls && this.match(types.parenL)) {
|
||
const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
|
||
const oldYieldPos = this.state.yieldPos;
|
||
const oldAwaitPos = this.state.awaitPos;
|
||
this.state.maybeInArrowParameters = true;
|
||
this.state.yieldPos = 0;
|
||
this.state.awaitPos = 0;
|
||
this.next();
|
||
let node = this.startNodeAt(startPos, startLoc);
|
||
node.callee = base;
|
||
const oldCommaAfterSpreadAt = this.state.commaAfterSpreadAt;
|
||
this.state.commaAfterSpreadAt = -1;
|
||
node.arguments = this.parseCallExpressionArguments(types.parenR, maybeAsyncArrow, base.type === "Import", base.type !== "Super");
|
||
|
||
if (!state.optionalChainMember) {
|
||
this.finishCallExpression(node);
|
||
} else {
|
||
this.finishOptionalCallExpression(node);
|
||
}
|
||
|
||
if (maybeAsyncArrow && this.shouldParseAsyncArrow()) {
|
||
state.stop = true;
|
||
this.checkCommaAfterRestFromSpread();
|
||
node = this.parseAsyncArrowFromCallExpression(this.startNodeAt(startPos, startLoc), node);
|
||
this.checkYieldAwaitInDefaultParams();
|
||
this.state.yieldPos = oldYieldPos;
|
||
this.state.awaitPos = oldAwaitPos;
|
||
} else {
|
||
this.toReferencedListDeep(node.arguments);
|
||
this.state.yieldPos = oldYieldPos || this.state.yieldPos;
|
||
this.state.awaitPos = oldAwaitPos || this.state.awaitPos;
|
||
}
|
||
|
||
this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
|
||
this.state.commaAfterSpreadAt = oldCommaAfterSpreadAt;
|
||
return node;
|
||
} else if (this.match(types.backQuote)) {
|
||
return this.parseTaggedTemplateExpression(startPos, startLoc, base, state);
|
||
} else {
|
||
state.stop = true;
|
||
return base;
|
||
}
|
||
}
|
||
|
||
parseTaggedTemplateExpression(startPos, startLoc, base, state, typeArguments) {
|
||
const node = this.startNodeAt(startPos, startLoc);
|
||
node.tag = base;
|
||
node.quasi = this.parseTemplate(true);
|
||
if (typeArguments) node.typeParameters = typeArguments;
|
||
|
||
if (state.optionalChainMember) {
|
||
this.raise(startPos, "Tagged Template Literals are not allowed in optionalChain");
|
||
}
|
||
|
||
return this.finishNode(node, "TaggedTemplateExpression");
|
||
}
|
||
|
||
atPossibleAsync(base) {
|
||
return base.type === "Identifier" && base.name === "async" && this.state.lastTokEnd === base.end && !this.canInsertSemicolon() && this.input.slice(base.start, base.end) === "async";
|
||
}
|
||
|
||
finishCallExpression(node) {
|
||
if (node.callee.type === "Import") {
|
||
if (node.arguments.length !== 1) {
|
||
this.raise(node.start, "import() requires exactly one argument");
|
||
}
|
||
|
||
const importArg = node.arguments[0];
|
||
|
||
if (importArg && importArg.type === "SpreadElement") {
|
||
this.raise(importArg.start, "... is not allowed in import()");
|
||
}
|
||
}
|
||
|
||
return this.finishNode(node, "CallExpression");
|
||
}
|
||
|
||
finishOptionalCallExpression(node) {
|
||
if (node.callee.type === "Import") {
|
||
if (node.arguments.length !== 1) {
|
||
this.raise(node.start, "import() requires exactly one argument");
|
||
}
|
||
|
||
const importArg = node.arguments[0];
|
||
|
||
if (importArg && importArg.type === "SpreadElement") {
|
||
this.raise(importArg.start, "... is not allowed in import()");
|
||
}
|
||
}
|
||
|
||
return this.finishNode(node, "OptionalCallExpression");
|
||
}
|
||
|
||
parseCallExpressionArguments(close, possibleAsyncArrow, dynamicImport, allowPlaceholder) {
|
||
const elts = [];
|
||
let innerParenStart;
|
||
let first = true;
|
||
const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
|
||
this.state.inFSharpPipelineDirectBody = false;
|
||
|
||
while (!this.eat(close)) {
|
||
if (first) {
|
||
first = false;
|
||
} else {
|
||
this.expect(types.comma);
|
||
|
||
if (this.eat(close)) {
|
||
if (dynamicImport) {
|
||
this.raise(this.state.lastTokStart, "Trailing comma is disallowed inside import(...) arguments");
|
||
}
|
||
|
||
break;
|
||
}
|
||
}
|
||
|
||
if (this.match(types.parenL) && !innerParenStart) {
|
||
innerParenStart = this.state.start;
|
||
}
|
||
|
||
elts.push(this.parseExprListItem(false, possibleAsyncArrow ? {
|
||
start: 0
|
||
} : undefined, possibleAsyncArrow ? {
|
||
start: 0
|
||
} : undefined, allowPlaceholder));
|
||
}
|
||
|
||
if (possibleAsyncArrow && innerParenStart && this.shouldParseAsyncArrow()) {
|
||
this.unexpected();
|
||
}
|
||
|
||
this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
|
||
return elts;
|
||
}
|
||
|
||
shouldParseAsyncArrow() {
|
||
return this.match(types.arrow) && !this.canInsertSemicolon();
|
||
}
|
||
|
||
parseAsyncArrowFromCallExpression(node, call) {
|
||
this.expect(types.arrow);
|
||
this.parseArrowExpression(node, call.arguments, true);
|
||
return node;
|
||
}
|
||
|
||
parseNoCallExpr() {
|
||
const startPos = this.state.start;
|
||
const startLoc = this.state.startLoc;
|
||
return this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true);
|
||
}
|
||
|
||
parseExprAtom(refShorthandDefaultPos) {
|
||
if (this.state.type === types.slash) this.readRegexp();
|
||
const canBeArrow = this.state.potentialArrowAt === this.state.start;
|
||
let node;
|
||
|
||
switch (this.state.type) {
|
||
case types._super:
|
||
if (!this.scope.allowSuper && !this.options.allowSuperOutsideMethod) {
|
||
this.raise(this.state.start, "super is only allowed in object methods and classes");
|
||
}
|
||
|
||
node = this.startNode();
|
||
this.next();
|
||
|
||
if (this.match(types.parenL) && !this.scope.allowDirectSuper && !this.options.allowSuperOutsideMethod) {
|
||
this.raise(node.start, "super() is only valid inside a class constructor of a subclass. " + "Maybe a typo in the method name ('constructor') or not extending another class?");
|
||
}
|
||
|
||
if (!this.match(types.parenL) && !this.match(types.bracketL) && !this.match(types.dot)) {
|
||
this.unexpected();
|
||
}
|
||
|
||
return this.finishNode(node, "Super");
|
||
|
||
case types._import:
|
||
node = this.startNode();
|
||
this.next();
|
||
|
||
if (this.match(types.dot)) {
|
||
return this.parseImportMetaProperty(node);
|
||
}
|
||
|
||
this.expectPlugin("dynamicImport", node.start);
|
||
|
||
if (!this.match(types.parenL)) {
|
||
this.unexpected(null, types.parenL);
|
||
}
|
||
|
||
return this.finishNode(node, "Import");
|
||
|
||
case types._this:
|
||
node = this.startNode();
|
||
this.next();
|
||
return this.finishNode(node, "ThisExpression");
|
||
|
||
case types.name:
|
||
{
|
||
node = this.startNode();
|
||
const containsEsc = this.state.containsEsc;
|
||
const id = this.parseIdentifier();
|
||
|
||
if (!containsEsc && id.name === "async" && this.match(types._function) && !this.canInsertSemicolon()) {
|
||
this.next();
|
||
return this.parseFunction(node, undefined, true);
|
||
} else if (canBeArrow && !containsEsc && id.name === "async" && this.match(types.name) && !this.canInsertSemicolon()) {
|
||
const params = [this.parseIdentifier()];
|
||
this.expect(types.arrow);
|
||
this.parseArrowExpression(node, params, true);
|
||
return node;
|
||
}
|
||
|
||
if (canBeArrow && this.match(types.arrow) && !this.canInsertSemicolon()) {
|
||
this.next();
|
||
this.parseArrowExpression(node, [id], false);
|
||
return node;
|
||
}
|
||
|
||
return id;
|
||
}
|
||
|
||
case types._do:
|
||
{
|
||
this.expectPlugin("doExpressions");
|
||
const node = this.startNode();
|
||
this.next();
|
||
const oldLabels = this.state.labels;
|
||
this.state.labels = [];
|
||
node.body = this.parseBlock();
|
||
this.state.labels = oldLabels;
|
||
return this.finishNode(node, "DoExpression");
|
||
}
|
||
|
||
case types.regexp:
|
||
{
|
||
const value = this.state.value;
|
||
node = this.parseLiteral(value.value, "RegExpLiteral");
|
||
node.pattern = value.pattern;
|
||
node.flags = value.flags;
|
||
return node;
|
||
}
|
||
|
||
case types.num:
|
||
return this.parseLiteral(this.state.value, "NumericLiteral");
|
||
|
||
case types.bigint:
|
||
return this.parseLiteral(this.state.value, "BigIntLiteral");
|
||
|
||
case types.string:
|
||
return this.parseLiteral(this.state.value, "StringLiteral");
|
||
|
||
case types._null:
|
||
node = this.startNode();
|
||
this.next();
|
||
return this.finishNode(node, "NullLiteral");
|
||
|
||
case types._true:
|
||
case types._false:
|
||
return this.parseBooleanLiteral();
|
||
|
||
case types.parenL:
|
||
return this.parseParenAndDistinguishExpression(canBeArrow);
|
||
|
||
case types.bracketL:
|
||
{
|
||
const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
|
||
this.state.inFSharpPipelineDirectBody = false;
|
||
node = this.startNode();
|
||
this.next();
|
||
node.elements = this.parseExprList(types.bracketR, true, refShorthandDefaultPos);
|
||
|
||
if (!this.state.maybeInArrowParameters) {
|
||
this.toReferencedList(node.elements);
|
||
}
|
||
|
||
this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
|
||
return this.finishNode(node, "ArrayExpression");
|
||
}
|
||
|
||
case types.braceL:
|
||
{
|
||
const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
|
||
this.state.inFSharpPipelineDirectBody = false;
|
||
const ret = this.parseObj(false, refShorthandDefaultPos);
|
||
this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
|
||
return ret;
|
||
}
|
||
|
||
case types._function:
|
||
return this.parseFunctionExpression();
|
||
|
||
case types.at:
|
||
this.parseDecorators();
|
||
|
||
case types._class:
|
||
node = this.startNode();
|
||
this.takeDecorators(node);
|
||
return this.parseClass(node, false);
|
||
|
||
case types._new:
|
||
return this.parseNew();
|
||
|
||
case types.backQuote:
|
||
return this.parseTemplate(false);
|
||
|
||
case types.doubleColon:
|
||
{
|
||
node = this.startNode();
|
||
this.next();
|
||
node.object = null;
|
||
const callee = node.callee = this.parseNoCallExpr();
|
||
|
||
if (callee.type === "MemberExpression") {
|
||
return this.finishNode(node, "BindExpression");
|
||
} else {
|
||
throw this.raise(callee.start, "Binding should be performed on object property.");
|
||
}
|
||
}
|
||
|
||
case types.hash:
|
||
{
|
||
if (this.state.inPipeline) {
|
||
node = this.startNode();
|
||
|
||
if (this.getPluginOption("pipelineOperator", "proposal") !== "smart") {
|
||
this.raise(node.start, "Primary Topic Reference found but pipelineOperator not passed 'smart' for 'proposal' option.");
|
||
}
|
||
|
||
this.next();
|
||
|
||
if (this.primaryTopicReferenceIsAllowedInCurrentTopicContext()) {
|
||
this.registerTopicReference();
|
||
return this.finishNode(node, "PipelinePrimaryTopicReference");
|
||
} else {
|
||
throw this.raise(node.start, `Topic reference was used in a lexical context without topic binding`);
|
||
}
|
||
}
|
||
}
|
||
|
||
default:
|
||
throw this.unexpected();
|
||
}
|
||
}
|
||
|
||
parseBooleanLiteral() {
|
||
const node = this.startNode();
|
||
node.value = this.match(types._true);
|
||
this.next();
|
||
return this.finishNode(node, "BooleanLiteral");
|
||
}
|
||
|
||
parseMaybePrivateName() {
|
||
const isPrivate = this.match(types.hash);
|
||
|
||
if (isPrivate) {
|
||
this.expectOnePlugin(["classPrivateProperties", "classPrivateMethods"]);
|
||
const node = this.startNode();
|
||
this.next();
|
||
this.assertNoSpace("Unexpected space between # and identifier");
|
||
node.id = this.parseIdentifier(true);
|
||
return this.finishNode(node, "PrivateName");
|
||
} else {
|
||
return this.parseIdentifier(true);
|
||
}
|
||
}
|
||
|
||
parseFunctionExpression() {
|
||
const node = this.startNode();
|
||
let meta = this.startNode();
|
||
this.next();
|
||
meta = this.createIdentifier(meta, "function");
|
||
|
||
if (this.scope.inGenerator && this.eat(types.dot)) {
|
||
return this.parseMetaProperty(node, meta, "sent");
|
||
}
|
||
|
||
return this.parseFunction(node);
|
||
}
|
||
|
||
parseMetaProperty(node, meta, propertyName) {
|
||
node.meta = meta;
|
||
|
||
if (meta.name === "function" && propertyName === "sent") {
|
||
if (this.isContextual(propertyName)) {
|
||
this.expectPlugin("functionSent");
|
||
} else if (!this.hasPlugin("functionSent")) {
|
||
this.unexpected();
|
||
}
|
||
}
|
||
|
||
const containsEsc = this.state.containsEsc;
|
||
node.property = this.parseIdentifier(true);
|
||
|
||
if (node.property.name !== propertyName || containsEsc) {
|
||
this.raise(node.property.start, `The only valid meta property for ${meta.name} is ${meta.name}.${propertyName}`);
|
||
}
|
||
|
||
return this.finishNode(node, "MetaProperty");
|
||
}
|
||
|
||
parseImportMetaProperty(node) {
|
||
const id = this.createIdentifier(this.startNodeAtNode(node), "import");
|
||
this.expect(types.dot);
|
||
|
||
if (this.isContextual("meta")) {
|
||
this.expectPlugin("importMeta");
|
||
} else if (!this.hasPlugin("importMeta")) {
|
||
this.raise(id.start, `Dynamic imports require a parameter: import('a.js')`);
|
||
}
|
||
|
||
if (!this.inModule) {
|
||
this.raise(id.start, `import.meta may appear only with 'sourceType: "module"'`, {
|
||
code: "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED"
|
||
});
|
||
}
|
||
|
||
this.sawUnambiguousESM = true;
|
||
return this.parseMetaProperty(node, id, "meta");
|
||
}
|
||
|
||
parseLiteral(value, type, startPos, startLoc) {
|
||
startPos = startPos || this.state.start;
|
||
startLoc = startLoc || this.state.startLoc;
|
||
const node = this.startNodeAt(startPos, startLoc);
|
||
this.addExtra(node, "rawValue", value);
|
||
this.addExtra(node, "raw", this.input.slice(startPos, this.state.end));
|
||
node.value = value;
|
||
this.next();
|
||
return this.finishNode(node, type);
|
||
}
|
||
|
||
parseParenAndDistinguishExpression(canBeArrow) {
|
||
const startPos = this.state.start;
|
||
const startLoc = this.state.startLoc;
|
||
let val;
|
||
this.expect(types.parenL);
|
||
const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
|
||
const oldYieldPos = this.state.yieldPos;
|
||
const oldAwaitPos = this.state.awaitPos;
|
||
const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
|
||
this.state.maybeInArrowParameters = true;
|
||
this.state.yieldPos = 0;
|
||
this.state.awaitPos = 0;
|
||
this.state.inFSharpPipelineDirectBody = false;
|
||
const innerStartPos = this.state.start;
|
||
const innerStartLoc = this.state.startLoc;
|
||
const exprList = [];
|
||
const refShorthandDefaultPos = {
|
||
start: 0
|
||
};
|
||
const refNeedsArrowPos = {
|
||
start: 0
|
||
};
|
||
let first = true;
|
||
let spreadStart;
|
||
let optionalCommaStart;
|
||
|
||
while (!this.match(types.parenR)) {
|
||
if (first) {
|
||
first = false;
|
||
} else {
|
||
this.expect(types.comma, refNeedsArrowPos.start || null);
|
||
|
||
if (this.match(types.parenR)) {
|
||
optionalCommaStart = this.state.start;
|
||
break;
|
||
}
|
||
}
|
||
|
||
if (this.match(types.ellipsis)) {
|
||
const spreadNodeStartPos = this.state.start;
|
||
const spreadNodeStartLoc = this.state.startLoc;
|
||
spreadStart = this.state.start;
|
||
exprList.push(this.parseParenItem(this.parseRestBinding(), spreadNodeStartPos, spreadNodeStartLoc));
|
||
this.checkCommaAfterRest();
|
||
break;
|
||
} else {
|
||
exprList.push(this.parseMaybeAssign(false, refShorthandDefaultPos, this.parseParenItem, refNeedsArrowPos));
|
||
}
|
||
}
|
||
|
||
const innerEndPos = this.state.start;
|
||
const innerEndLoc = this.state.startLoc;
|
||
this.expect(types.parenR);
|
||
this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
|
||
this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
|
||
let arrowNode = this.startNodeAt(startPos, startLoc);
|
||
|
||
if (canBeArrow && this.shouldParseArrow() && (arrowNode = this.parseArrow(arrowNode))) {
|
||
this.checkYieldAwaitInDefaultParams();
|
||
this.state.yieldPos = oldYieldPos;
|
||
this.state.awaitPos = oldAwaitPos;
|
||
|
||
for (let _i = 0; _i < exprList.length; _i++) {
|
||
const param = exprList[_i];
|
||
|
||
if (param.extra && param.extra.parenthesized) {
|
||
this.unexpected(param.extra.parenStart);
|
||
}
|
||
}
|
||
|
||
this.parseArrowExpression(arrowNode, exprList, false);
|
||
return arrowNode;
|
||
}
|
||
|
||
this.state.yieldPos = oldYieldPos || this.state.yieldPos;
|
||
this.state.awaitPos = oldAwaitPos || this.state.awaitPos;
|
||
|
||
if (!exprList.length) {
|
||
this.unexpected(this.state.lastTokStart);
|
||
}
|
||
|
||
if (optionalCommaStart) this.unexpected(optionalCommaStart);
|
||
if (spreadStart) this.unexpected(spreadStart);
|
||
|
||
if (refShorthandDefaultPos.start) {
|
||
this.unexpected(refShorthandDefaultPos.start);
|
||
}
|
||
|
||
if (refNeedsArrowPos.start) this.unexpected(refNeedsArrowPos.start);
|
||
this.toReferencedListDeep(exprList, true);
|
||
|
||
if (exprList.length > 1) {
|
||
val = this.startNodeAt(innerStartPos, innerStartLoc);
|
||
val.expressions = exprList;
|
||
this.finishNodeAt(val, "SequenceExpression", innerEndPos, innerEndLoc);
|
||
} else {
|
||
val = exprList[0];
|
||
}
|
||
|
||
if (!this.options.createParenthesizedExpressions) {
|
||
this.addExtra(val, "parenthesized", true);
|
||
this.addExtra(val, "parenStart", startPos);
|
||
return val;
|
||
}
|
||
|
||
const parenExpression = this.startNodeAt(startPos, startLoc);
|
||
parenExpression.expression = val;
|
||
this.finishNode(parenExpression, "ParenthesizedExpression");
|
||
return parenExpression;
|
||
}
|
||
|
||
shouldParseArrow() {
|
||
return !this.canInsertSemicolon();
|
||
}
|
||
|
||
parseArrow(node) {
|
||
if (this.eat(types.arrow)) {
|
||
return node;
|
||
}
|
||
}
|
||
|
||
parseParenItem(node, startPos, startLoc) {
|
||
return node;
|
||
}
|
||
|
||
parseNew() {
|
||
const node = this.startNode();
|
||
const meta = this.parseIdentifier(true);
|
||
|
||
if (this.eat(types.dot)) {
|
||
const metaProp = this.parseMetaProperty(node, meta, "target");
|
||
|
||
if (!this.scope.inNonArrowFunction && !this.state.inClassProperty) {
|
||
let error = "new.target can only be used in functions";
|
||
|
||
if (this.hasPlugin("classProperties")) {
|
||
error += " or class properties";
|
||
}
|
||
|
||
this.raise(metaProp.start, error);
|
||
}
|
||
|
||
return metaProp;
|
||
}
|
||
|
||
node.callee = this.parseNoCallExpr();
|
||
|
||
if (node.callee.type === "Import") {
|
||
this.raise(node.callee.start, "Cannot use new with import(...)");
|
||
} else if (node.callee.type === "OptionalMemberExpression" || node.callee.type === "OptionalCallExpression") {
|
||
this.raise(this.state.lastTokEnd, "constructors in/after an Optional Chain are not allowed");
|
||
} else if (this.eat(types.questionDot)) {
|
||
this.raise(this.state.start, "constructors in/after an Optional Chain are not allowed");
|
||
}
|
||
|
||
this.parseNewArguments(node);
|
||
return this.finishNode(node, "NewExpression");
|
||
}
|
||
|
||
parseNewArguments(node) {
|
||
if (this.eat(types.parenL)) {
|
||
const args = this.parseExprList(types.parenR);
|
||
this.toReferencedList(args);
|
||
node.arguments = args;
|
||
} else {
|
||
node.arguments = [];
|
||
}
|
||
}
|
||
|
||
parseTemplateElement(isTagged) {
|
||
const elem = this.startNode();
|
||
|
||
if (this.state.value === null) {
|
||
if (!isTagged) {
|
||
this.raise(this.state.invalidTemplateEscapePosition || 0, "Invalid escape sequence in template");
|
||
} else {
|
||
this.state.invalidTemplateEscapePosition = null;
|
||
}
|
||
}
|
||
|
||
elem.value = {
|
||
raw: this.input.slice(this.state.start, this.state.end).replace(/\r\n?/g, "\n"),
|
||
cooked: this.state.value
|
||
};
|
||
this.next();
|
||
elem.tail = this.match(types.backQuote);
|
||
return this.finishNode(elem, "TemplateElement");
|
||
}
|
||
|
||
parseTemplate(isTagged) {
|
||
const node = this.startNode();
|
||
this.next();
|
||
node.expressions = [];
|
||
let curElt = this.parseTemplateElement(isTagged);
|
||
node.quasis = [curElt];
|
||
|
||
while (!curElt.tail) {
|
||
this.expect(types.dollarBraceL);
|
||
node.expressions.push(this.parseExpression());
|
||
this.expect(types.braceR);
|
||
node.quasis.push(curElt = this.parseTemplateElement(isTagged));
|
||
}
|
||
|
||
this.next();
|
||
return this.finishNode(node, "TemplateLiteral");
|
||
}
|
||
|
||
parseObj(isPattern, refShorthandDefaultPos) {
|
||
const propHash = Object.create(null);
|
||
let first = true;
|
||
const node = this.startNode();
|
||
node.properties = [];
|
||
this.next();
|
||
|
||
while (!this.eat(types.braceR)) {
|
||
if (first) {
|
||
first = false;
|
||
} else {
|
||
this.expect(types.comma);
|
||
if (this.eat(types.braceR)) break;
|
||
}
|
||
|
||
const prop = this.parseObjectMember(isPattern, refShorthandDefaultPos);
|
||
if (!isPattern) this.checkPropClash(prop, propHash);
|
||
|
||
if (prop.shorthand) {
|
||
this.addExtra(prop, "shorthand", true);
|
||
}
|
||
|
||
node.properties.push(prop);
|
||
}
|
||
|
||
return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression");
|
||
}
|
||
|
||
isAsyncProp(prop) {
|
||
return !prop.computed && prop.key.type === "Identifier" && prop.key.name === "async" && (this.match(types.name) || this.match(types.num) || this.match(types.string) || this.match(types.bracketL) || this.state.type.keyword || this.match(types.star)) && !this.hasPrecedingLineBreak();
|
||
}
|
||
|
||
parseObjectMember(isPattern, refShorthandDefaultPos) {
|
||
let decorators = [];
|
||
|
||
if (this.match(types.at)) {
|
||
if (this.hasPlugin("decorators")) {
|
||
this.raise(this.state.start, "Stage 2 decorators disallow object literal property decorators");
|
||
} else {
|
||
while (this.match(types.at)) {
|
||
decorators.push(this.parseDecorator());
|
||
}
|
||
}
|
||
}
|
||
|
||
const prop = this.startNode();
|
||
let isGenerator = false;
|
||
let isAsync = false;
|
||
let startPos;
|
||
let startLoc;
|
||
|
||
if (this.match(types.ellipsis)) {
|
||
if (decorators.length) this.unexpected();
|
||
|
||
if (isPattern) {
|
||
this.next();
|
||
prop.argument = this.parseIdentifier();
|
||
this.checkCommaAfterRest();
|
||
return this.finishNode(prop, "RestElement");
|
||
}
|
||
|
||
return this.parseSpread();
|
||
}
|
||
|
||
if (decorators.length) {
|
||
prop.decorators = decorators;
|
||
decorators = [];
|
||
}
|
||
|
||
prop.method = false;
|
||
|
||
if (isPattern || refShorthandDefaultPos) {
|
||
startPos = this.state.start;
|
||
startLoc = this.state.startLoc;
|
||
}
|
||
|
||
if (!isPattern) {
|
||
isGenerator = this.eat(types.star);
|
||
}
|
||
|
||
const containsEsc = this.state.containsEsc;
|
||
this.parsePropertyName(prop);
|
||
|
||
if (!isPattern && !containsEsc && !isGenerator && this.isAsyncProp(prop)) {
|
||
isAsync = true;
|
||
isGenerator = this.eat(types.star);
|
||
this.parsePropertyName(prop);
|
||
} else {
|
||
isAsync = false;
|
||
}
|
||
|
||
this.parseObjPropValue(prop, startPos, startLoc, isGenerator, isAsync, isPattern, refShorthandDefaultPos, containsEsc);
|
||
return prop;
|
||
}
|
||
|
||
isGetterOrSetterMethod(prop, isPattern) {
|
||
return !isPattern && !prop.computed && prop.key.type === "Identifier" && (prop.key.name === "get" || prop.key.name === "set") && (this.match(types.string) || this.match(types.num) || this.match(types.bracketL) || this.match(types.name) || !!this.state.type.keyword);
|
||
}
|
||
|
||
getGetterSetterExpectedParamCount(method) {
|
||
return method.kind === "get" ? 0 : 1;
|
||
}
|
||
|
||
checkGetterSetterParams(method) {
|
||
const paramCount = this.getGetterSetterExpectedParamCount(method);
|
||
const start = method.start;
|
||
|
||
if (method.params.length !== paramCount) {
|
||
if (method.kind === "get") {
|
||
this.raise(start, "getter must not have any formal parameters");
|
||
} else {
|
||
this.raise(start, "setter must have exactly one formal parameter");
|
||
}
|
||
}
|
||
|
||
if (method.kind === "set" && method.params[method.params.length - 1].type === "RestElement") {
|
||
this.raise(start, "setter function argument must not be a rest parameter");
|
||
}
|
||
}
|
||
|
||
parseObjectMethod(prop, isGenerator, isAsync, isPattern, containsEsc) {
|
||
if (isAsync || isGenerator || this.match(types.parenL)) {
|
||
if (isPattern) this.unexpected();
|
||
prop.kind = "method";
|
||
prop.method = true;
|
||
return this.parseMethod(prop, isGenerator, isAsync, false, false, "ObjectMethod");
|
||
}
|
||
|
||
if (!containsEsc && this.isGetterOrSetterMethod(prop, isPattern)) {
|
||
if (isGenerator || isAsync) this.unexpected();
|
||
prop.kind = prop.key.name;
|
||
this.parsePropertyName(prop);
|
||
this.parseMethod(prop, false, false, false, false, "ObjectMethod");
|
||
this.checkGetterSetterParams(prop);
|
||
return prop;
|
||
}
|
||
}
|
||
|
||
parseObjectProperty(prop, startPos, startLoc, isPattern, refShorthandDefaultPos) {
|
||
prop.shorthand = false;
|
||
|
||
if (this.eat(types.colon)) {
|
||
prop.value = isPattern ? this.parseMaybeDefault(this.state.start, this.state.startLoc) : this.parseMaybeAssign(false, refShorthandDefaultPos);
|
||
return this.finishNode(prop, "ObjectProperty");
|
||
}
|
||
|
||
if (!prop.computed && prop.key.type === "Identifier") {
|
||
this.checkReservedWord(prop.key.name, prop.key.start, true, true);
|
||
|
||
if (isPattern) {
|
||
prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key.__clone());
|
||
} else if (this.match(types.eq) && refShorthandDefaultPos) {
|
||
if (!refShorthandDefaultPos.start) {
|
||
refShorthandDefaultPos.start = this.state.start;
|
||
}
|
||
|
||
prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key.__clone());
|
||
} else {
|
||
prop.value = prop.key.__clone();
|
||
}
|
||
|
||
prop.shorthand = true;
|
||
return this.finishNode(prop, "ObjectProperty");
|
||
}
|
||
}
|
||
|
||
parseObjPropValue(prop, startPos, startLoc, isGenerator, isAsync, isPattern, refShorthandDefaultPos, containsEsc) {
|
||
const node = this.parseObjectMethod(prop, isGenerator, isAsync, isPattern, containsEsc) || this.parseObjectProperty(prop, startPos, startLoc, isPattern, refShorthandDefaultPos);
|
||
if (!node) this.unexpected();
|
||
return node;
|
||
}
|
||
|
||
parsePropertyName(prop) {
|
||
if (this.eat(types.bracketL)) {
|
||
prop.computed = true;
|
||
prop.key = this.parseMaybeAssign();
|
||
this.expect(types.bracketR);
|
||
} else {
|
||
const oldInPropertyName = this.state.inPropertyName;
|
||
this.state.inPropertyName = true;
|
||
prop.key = this.match(types.num) || this.match(types.string) ? this.parseExprAtom() : this.parseMaybePrivateName();
|
||
|
||
if (prop.key.type !== "PrivateName") {
|
||
prop.computed = false;
|
||
}
|
||
|
||
this.state.inPropertyName = oldInPropertyName;
|
||
}
|
||
|
||
return prop.key;
|
||
}
|
||
|
||
initFunction(node, isAsync) {
|
||
node.id = null;
|
||
node.generator = false;
|
||
node.async = !!isAsync;
|
||
}
|
||
|
||
parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope = false) {
|
||
const oldYieldPos = this.state.yieldPos;
|
||
const oldAwaitPos = this.state.awaitPos;
|
||
this.state.yieldPos = 0;
|
||
this.state.awaitPos = 0;
|
||
this.initFunction(node, isAsync);
|
||
node.generator = !!isGenerator;
|
||
const allowModifiers = isConstructor;
|
||
this.scope.enter(functionFlags(isAsync, node.generator) | SCOPE_SUPER | (inClassScope ? SCOPE_CLASS : 0) | (allowDirectSuper ? SCOPE_DIRECT_SUPER : 0));
|
||
this.parseFunctionParams(node, allowModifiers);
|
||
this.checkYieldAwaitInDefaultParams();
|
||
this.parseFunctionBodyAndFinish(node, type, true);
|
||
this.scope.exit();
|
||
this.state.yieldPos = oldYieldPos;
|
||
this.state.awaitPos = oldAwaitPos;
|
||
return node;
|
||
}
|
||
|
||
parseArrowExpression(node, params, isAsync) {
|
||
this.scope.enter(functionFlags(isAsync, false) | SCOPE_ARROW);
|
||
this.initFunction(node, isAsync);
|
||
const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
|
||
const oldYieldPos = this.state.yieldPos;
|
||
const oldAwaitPos = this.state.awaitPos;
|
||
this.state.maybeInArrowParameters = false;
|
||
this.state.yieldPos = 0;
|
||
this.state.awaitPos = 0;
|
||
if (params) this.setArrowFunctionParameters(node, params);
|
||
this.parseFunctionBody(node, true);
|
||
this.scope.exit();
|
||
this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
|
||
this.state.yieldPos = oldYieldPos;
|
||
this.state.awaitPos = oldAwaitPos;
|
||
return this.finishNode(node, "ArrowFunctionExpression");
|
||
}
|
||
|
||
setArrowFunctionParameters(node, params) {
|
||
node.params = this.toAssignableList(params, true, "arrow function parameters");
|
||
}
|
||
|
||
isStrictBody(node) {
|
||
const isBlockStatement = node.body.type === "BlockStatement";
|
||
|
||
if (isBlockStatement && node.body.directives.length) {
|
||
for (let _i2 = 0, _node$body$directives = node.body.directives; _i2 < _node$body$directives.length; _i2++) {
|
||
const directive = _node$body$directives[_i2];
|
||
|
||
if (directive.value.value === "use strict") {
|
||
return true;
|
||
}
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
parseFunctionBodyAndFinish(node, type, isMethod = false) {
|
||
this.parseFunctionBody(node, false, isMethod);
|
||
this.finishNode(node, type);
|
||
}
|
||
|
||
parseFunctionBody(node, allowExpression, isMethod = false) {
|
||
const isExpression = allowExpression && !this.match(types.braceL);
|
||
const oldStrict = this.state.strict;
|
||
let useStrict = false;
|
||
const oldInParameters = this.state.inParameters;
|
||
this.state.inParameters = false;
|
||
|
||
if (isExpression) {
|
||
node.body = this.parseMaybeAssign();
|
||
this.checkParams(node, false, allowExpression);
|
||
} else {
|
||
const nonSimple = !this.isSimpleParamList(node.params);
|
||
|
||
if (!oldStrict || nonSimple) {
|
||
useStrict = this.strictDirective(this.state.end);
|
||
|
||
if (useStrict && nonSimple) {
|
||
const errorPos = (node.kind === "method" || node.kind === "constructor") && !!node.key ? node.key.end : node.start;
|
||
this.raise(errorPos, "Illegal 'use strict' directive in function with non-simple parameter list");
|
||
}
|
||
}
|
||
|
||
const oldLabels = this.state.labels;
|
||
this.state.labels = [];
|
||
if (useStrict) this.state.strict = true;
|
||
this.checkParams(node, !oldStrict && !useStrict && !allowExpression && !isMethod && !nonSimple, allowExpression);
|
||
node.body = this.parseBlock(true, false);
|
||
this.state.labels = oldLabels;
|
||
}
|
||
|
||
this.state.inParameters = oldInParameters;
|
||
|
||
if (this.state.strict && node.id) {
|
||
this.checkLVal(node.id, BIND_OUTSIDE, undefined, "function name");
|
||
}
|
||
|
||
this.state.strict = oldStrict;
|
||
}
|
||
|
||
isSimpleParamList(params) {
|
||
for (let i = 0, len = params.length; i < len; i++) {
|
||
if (params[i].type !== "Identifier") return false;
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
checkParams(node, allowDuplicates, isArrowFunction) {
|
||
const nameHash = Object.create(null);
|
||
|
||
for (let i = 0; i < node.params.length; i++) {
|
||
this.checkLVal(node.params[i], BIND_VAR, allowDuplicates ? null : nameHash, "function paramter list");
|
||
}
|
||
}
|
||
|
||
parseExprList(close, allowEmpty, refShorthandDefaultPos) {
|
||
const elts = [];
|
||
let first = true;
|
||
|
||
while (!this.eat(close)) {
|
||
if (first) {
|
||
first = false;
|
||
} else {
|
||
this.expect(types.comma);
|
||
if (this.eat(close)) break;
|
||
}
|
||
|
||
elts.push(this.parseExprListItem(allowEmpty, refShorthandDefaultPos));
|
||
}
|
||
|
||
return elts;
|
||
}
|
||
|
||
parseExprListItem(allowEmpty, refShorthandDefaultPos, refNeedsArrowPos, allowPlaceholder) {
|
||
let elt;
|
||
|
||
if (allowEmpty && this.match(types.comma)) {
|
||
elt = null;
|
||
} else if (this.match(types.ellipsis)) {
|
||
const spreadNodeStartPos = this.state.start;
|
||
const spreadNodeStartLoc = this.state.startLoc;
|
||
elt = this.parseParenItem(this.parseSpread(refShorthandDefaultPos, refNeedsArrowPos), spreadNodeStartPos, spreadNodeStartLoc);
|
||
} else if (this.match(types.question)) {
|
||
this.expectPlugin("partialApplication");
|
||
|
||
if (!allowPlaceholder) {
|
||
this.raise(this.state.start, "Unexpected argument placeholder");
|
||
}
|
||
|
||
const node = this.startNode();
|
||
this.next();
|
||
elt = this.finishNode(node, "ArgumentPlaceholder");
|
||
} else {
|
||
elt = this.parseMaybeAssign(false, refShorthandDefaultPos, this.parseParenItem, refNeedsArrowPos);
|
||
}
|
||
|
||
return elt;
|
||
}
|
||
|
||
parseIdentifier(liberal) {
|
||
const node = this.startNode();
|
||
const name = this.parseIdentifierName(node.start, liberal);
|
||
return this.createIdentifier(node, name);
|
||
}
|
||
|
||
createIdentifier(node, name) {
|
||
node.name = name;
|
||
node.loc.identifierName = name;
|
||
return this.finishNode(node, "Identifier");
|
||
}
|
||
|
||
parseIdentifierName(pos, liberal) {
|
||
let name;
|
||
|
||
if (this.match(types.name)) {
|
||
name = this.state.value;
|
||
} else if (this.state.type.keyword) {
|
||
name = this.state.type.keyword;
|
||
|
||
if ((name === "class" || name === "function") && (this.state.lastTokEnd !== this.state.lastTokStart + 1 || this.input.charCodeAt(this.state.lastTokStart) !== 46)) {
|
||
this.state.context.pop();
|
||
}
|
||
} else {
|
||
throw this.unexpected();
|
||
}
|
||
|
||
if (!liberal) {
|
||
this.checkReservedWord(name, this.state.start, !!this.state.type.keyword, false);
|
||
}
|
||
|
||
this.next();
|
||
return name;
|
||
}
|
||
|
||
checkReservedWord(word, startLoc, checkKeywords, isBinding) {
|
||
if (this.scope.inGenerator && word === "yield") {
|
||
this.raise(startLoc, "Can not use 'yield' as identifier inside a generator");
|
||
}
|
||
|
||
if (this.scope.inAsync && word === "await") {
|
||
this.raise(startLoc, "Can not use 'await' as identifier inside an async function");
|
||
}
|
||
|
||
if (this.state.inClassProperty && word === "arguments") {
|
||
this.raise(startLoc, "'arguments' is not allowed in class field initializer");
|
||
}
|
||
|
||
if (checkKeywords && isKeyword(word)) {
|
||
this.raise(startLoc, `Unexpected keyword '${word}'`);
|
||
}
|
||
|
||
const reservedTest = !this.state.strict ? isReservedWord : isBinding ? isStrictBindReservedWord : isStrictReservedWord;
|
||
|
||
if (reservedTest(word, this.inModule)) {
|
||
if (!this.scope.inAsync && word === "await") {
|
||
this.raise(startLoc, "Can not use keyword 'await' outside an async function");
|
||
}
|
||
|
||
this.raise(startLoc, `Unexpected reserved word '${word}'`);
|
||
}
|
||
}
|
||
|
||
parseAwait() {
|
||
if (!this.state.awaitPos) {
|
||
this.state.awaitPos = this.state.start;
|
||
}
|
||
|
||
const node = this.startNode();
|
||
this.next();
|
||
|
||
if (this.state.inParameters) {
|
||
this.raise(node.start, "await is not allowed in async function parameters");
|
||
}
|
||
|
||
if (this.match(types.star)) {
|
||
this.raise(node.start, "await* has been removed from the async functions proposal. Use Promise.all() instead.");
|
||
}
|
||
|
||
if (!this.state.soloAwait) {
|
||
node.argument = this.parseMaybeUnary();
|
||
}
|
||
|
||
return this.finishNode(node, "AwaitExpression");
|
||
}
|
||
|
||
parseYield(noIn) {
|
||
if (!this.state.yieldPos) {
|
||
this.state.yieldPos = this.state.start;
|
||
}
|
||
|
||
const node = this.startNode();
|
||
|
||
if (this.state.inParameters) {
|
||
this.raise(node.start, "yield is not allowed in generator parameters");
|
||
}
|
||
|
||
this.next();
|
||
|
||
if (this.match(types.semi) || !this.match(types.star) && !this.state.type.startsExpr || this.canInsertSemicolon()) {
|
||
node.delegate = false;
|
||
node.argument = null;
|
||
} else {
|
||
node.delegate = this.eat(types.star);
|
||
node.argument = this.parseMaybeAssign(noIn);
|
||
}
|
||
|
||
return this.finishNode(node, "YieldExpression");
|
||
}
|
||
|
||
checkPipelineAtInfixOperator(left, leftStartPos) {
|
||
if (this.getPluginOption("pipelineOperator", "proposal") === "smart") {
|
||
if (left.type === "SequenceExpression") {
|
||
throw this.raise(leftStartPos, `Pipeline head should not be a comma-separated sequence expression`);
|
||
}
|
||
}
|
||
}
|
||
|
||
parseSmartPipelineBody(childExpression, startPos, startLoc) {
|
||
const pipelineStyle = this.checkSmartPipelineBodyStyle(childExpression);
|
||
this.checkSmartPipelineBodyEarlyErrors(childExpression, pipelineStyle, startPos);
|
||
return this.parseSmartPipelineBodyInStyle(childExpression, pipelineStyle, startPos, startLoc);
|
||
}
|
||
|
||
checkSmartPipelineBodyEarlyErrors(childExpression, pipelineStyle, startPos) {
|
||
if (this.match(types.arrow)) {
|
||
throw this.raise(this.state.start, `Unexpected arrow "=>" after pipeline body; arrow function in pipeline body must be parenthesized`);
|
||
} else if (pipelineStyle === "PipelineTopicExpression" && childExpression.type === "SequenceExpression") {
|
||
throw this.raise(startPos, `Pipeline body may not be a comma-separated sequence expression`);
|
||
}
|
||
}
|
||
|
||
parseSmartPipelineBodyInStyle(childExpression, pipelineStyle, startPos, startLoc) {
|
||
const bodyNode = this.startNodeAt(startPos, startLoc);
|
||
|
||
switch (pipelineStyle) {
|
||
case "PipelineBareFunction":
|
||
bodyNode.callee = childExpression;
|
||
break;
|
||
|
||
case "PipelineBareConstructor":
|
||
bodyNode.callee = childExpression.callee;
|
||
break;
|
||
|
||
case "PipelineBareAwaitedFunction":
|
||
bodyNode.callee = childExpression.argument;
|
||
break;
|
||
|
||
case "PipelineTopicExpression":
|
||
if (!this.topicReferenceWasUsedInCurrentTopicContext()) {
|
||
throw this.raise(startPos, `Pipeline is in topic style but does not use topic reference`);
|
||
}
|
||
|
||
bodyNode.expression = childExpression;
|
||
break;
|
||
|
||
default:
|
||
throw this.raise(startPos, `Unknown pipeline style ${pipelineStyle}`);
|
||
}
|
||
|
||
return this.finishNode(bodyNode, pipelineStyle);
|
||
}
|
||
|
||
checkSmartPipelineBodyStyle(expression) {
|
||
switch (expression.type) {
|
||
default:
|
||
return this.isSimpleReference(expression) ? "PipelineBareFunction" : "PipelineTopicExpression";
|
||
}
|
||
}
|
||
|
||
isSimpleReference(expression) {
|
||
switch (expression.type) {
|
||
case "MemberExpression":
|
||
return !expression.computed && this.isSimpleReference(expression.object);
|
||
|
||
case "Identifier":
|
||
return true;
|
||
|
||
default:
|
||
return false;
|
||
}
|
||
}
|
||
|
||
withTopicPermittingContext(callback) {
|
||
const outerContextTopicState = this.state.topicContext;
|
||
this.state.topicContext = {
|
||
maxNumOfResolvableTopics: 1,
|
||
maxTopicIndex: null
|
||
};
|
||
|
||
try {
|
||
return callback();
|
||
} finally {
|
||
this.state.topicContext = outerContextTopicState;
|
||
}
|
||
}
|
||
|
||
withTopicForbiddingContext(callback) {
|
||
const outerContextTopicState = this.state.topicContext;
|
||
this.state.topicContext = {
|
||
maxNumOfResolvableTopics: 0,
|
||
maxTopicIndex: null
|
||
};
|
||
|
||
try {
|
||
return callback();
|
||
} finally {
|
||
this.state.topicContext = outerContextTopicState;
|
||
}
|
||
}
|
||
|
||
withSoloAwaitPermittingContext(callback) {
|
||
const outerContextSoloAwaitState = this.state.soloAwait;
|
||
this.state.soloAwait = true;
|
||
|
||
try {
|
||
return callback();
|
||
} finally {
|
||
this.state.soloAwait = outerContextSoloAwaitState;
|
||
}
|
||
}
|
||
|
||
registerTopicReference() {
|
||
this.state.topicContext.maxTopicIndex = 0;
|
||
}
|
||
|
||
primaryTopicReferenceIsAllowedInCurrentTopicContext() {
|
||
return this.state.topicContext.maxNumOfResolvableTopics >= 1;
|
||
}
|
||
|
||
topicReferenceWasUsedInCurrentTopicContext() {
|
||
return this.state.topicContext.maxTopicIndex != null && this.state.topicContext.maxTopicIndex >= 0;
|
||
}
|
||
|
||
parseFSharpPipelineBody(prec, noIn) {
|
||
const startPos = this.state.start;
|
||
const startLoc = this.state.startLoc;
|
||
this.state.potentialArrowAt = this.state.start;
|
||
const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
|
||
this.state.inFSharpPipelineDirectBody = true;
|
||
const ret = this.parseExprOp(this.parseMaybeUnary(), startPos, startLoc, prec, noIn);
|
||
this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
|
||
return ret;
|
||
}
|
||
|
||
}
|
||
|
||
const loopLabel = {
|
||
kind: "loop"
|
||
},
|
||
switchLabel = {
|
||
kind: "switch"
|
||
};
|
||
const FUNC_NO_FLAGS = 0b000,
|
||
FUNC_STATEMENT = 0b001,
|
||
FUNC_HANGING_STATEMENT = 0b010,
|
||
FUNC_NULLABLE_ID = 0b100;
|
||
class StatementParser extends ExpressionParser {
|
||
parseTopLevel(file, program) {
|
||
program.sourceType = this.options.sourceType;
|
||
program.interpreter = this.parseInterpreterDirective();
|
||
this.parseBlockBody(program, true, true, types.eof);
|
||
|
||
if (this.inModule && !this.options.allowUndeclaredExports && this.scope.undefinedExports.size > 0) {
|
||
for (let _i = 0, _Array$from = Array.from(this.scope.undefinedExports); _i < _Array$from.length; _i++) {
|
||
const [name] = _Array$from[_i];
|
||
const pos = this.scope.undefinedExports.get(name);
|
||
this.raise(pos, `Export '${name}' is not defined`);
|
||
}
|
||
}
|
||
|
||
file.program = this.finishNode(program, "Program");
|
||
file.comments = this.state.comments;
|
||
if (this.options.tokens) file.tokens = this.state.tokens;
|
||
return this.finishNode(file, "File");
|
||
}
|
||
|
||
stmtToDirective(stmt) {
|
||
const expr = stmt.expression;
|
||
const directiveLiteral = this.startNodeAt(expr.start, expr.loc.start);
|
||
const directive = this.startNodeAt(stmt.start, stmt.loc.start);
|
||
const raw = this.input.slice(expr.start, expr.end);
|
||
const val = directiveLiteral.value = raw.slice(1, -1);
|
||
this.addExtra(directiveLiteral, "raw", raw);
|
||
this.addExtra(directiveLiteral, "rawValue", val);
|
||
directive.value = this.finishNodeAt(directiveLiteral, "DirectiveLiteral", expr.end, expr.loc.end);
|
||
return this.finishNodeAt(directive, "Directive", stmt.end, stmt.loc.end);
|
||
}
|
||
|
||
parseInterpreterDirective() {
|
||
if (!this.match(types.interpreterDirective)) {
|
||
return null;
|
||
}
|
||
|
||
const node = this.startNode();
|
||
node.value = this.state.value;
|
||
this.next();
|
||
return this.finishNode(node, "InterpreterDirective");
|
||
}
|
||
|
||
isLet(context) {
|
||
if (!this.isContextual("let")) {
|
||
return false;
|
||
}
|
||
|
||
skipWhiteSpace.lastIndex = this.state.pos;
|
||
const skip = skipWhiteSpace.exec(this.input);
|
||
const next = this.state.pos + skip[0].length;
|
||
const nextCh = this.input.charCodeAt(next);
|
||
if (nextCh === 91) return true;
|
||
if (context) return false;
|
||
if (nextCh === 123) return true;
|
||
|
||
if (isIdentifierStart(nextCh)) {
|
||
let pos = next + 1;
|
||
|
||
while (isIdentifierChar(this.input.charCodeAt(pos))) {
|
||
++pos;
|
||
}
|
||
|
||
const ident = this.input.slice(next, pos);
|
||
if (!keywordRelationalOperator.test(ident)) return true;
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
parseStatement(context, topLevel) {
|
||
if (this.match(types.at)) {
|
||
this.parseDecorators(true);
|
||
}
|
||
|
||
return this.parseStatementContent(context, topLevel);
|
||
}
|
||
|
||
parseStatementContent(context, topLevel) {
|
||
let starttype = this.state.type;
|
||
const node = this.startNode();
|
||
let kind;
|
||
|
||
if (this.isLet(context)) {
|
||
starttype = types._var;
|
||
kind = "let";
|
||
}
|
||
|
||
switch (starttype) {
|
||
case types._break:
|
||
case types._continue:
|
||
return this.parseBreakContinueStatement(node, starttype.keyword);
|
||
|
||
case types._debugger:
|
||
return this.parseDebuggerStatement(node);
|
||
|
||
case types._do:
|
||
return this.parseDoStatement(node);
|
||
|
||
case types._for:
|
||
return this.parseForStatement(node);
|
||
|
||
case types._function:
|
||
if (this.lookahead().type === types.dot) break;
|
||
|
||
if (context) {
|
||
if (this.state.strict) {
|
||
this.raise(this.state.start, "In strict mode code, functions can only be declared at top level or inside a block");
|
||
} else if (context !== "if" && context !== "label") {
|
||
this.raise(this.state.start, "In non-strict mode code, functions can only be declared at top level, " + "inside a block, or as the body of an if statement");
|
||
}
|
||
}
|
||
|
||
return this.parseFunctionStatement(node, false, !context);
|
||
|
||
case types._class:
|
||
if (context) this.unexpected();
|
||
return this.parseClass(node, true);
|
||
|
||
case types._if:
|
||
return this.parseIfStatement(node);
|
||
|
||
case types._return:
|
||
return this.parseReturnStatement(node);
|
||
|
||
case types._switch:
|
||
return this.parseSwitchStatement(node);
|
||
|
||
case types._throw:
|
||
return this.parseThrowStatement(node);
|
||
|
||
case types._try:
|
||
return this.parseTryStatement(node);
|
||
|
||
case types._const:
|
||
case types._var:
|
||
kind = kind || this.state.value;
|
||
|
||
if (context && kind !== "var") {
|
||
this.unexpected(this.state.start, "Lexical declaration cannot appear in a single-statement context");
|
||
}
|
||
|
||
return this.parseVarStatement(node, kind);
|
||
|
||
case types._while:
|
||
return this.parseWhileStatement(node);
|
||
|
||
case types._with:
|
||
return this.parseWithStatement(node);
|
||
|
||
case types.braceL:
|
||
return this.parseBlock();
|
||
|
||
case types.semi:
|
||
return this.parseEmptyStatement(node);
|
||
|
||
case types._export:
|
||
case types._import:
|
||
{
|
||
const nextToken = this.lookahead();
|
||
|
||
if (nextToken.type === types.parenL || nextToken.type === types.dot) {
|
||
break;
|
||
}
|
||
|
||
if (!this.options.allowImportExportEverywhere && !topLevel) {
|
||
this.raise(this.state.start, "'import' and 'export' may only appear at the top level");
|
||
}
|
||
|
||
this.next();
|
||
let result;
|
||
|
||
if (starttype === types._import) {
|
||
result = this.parseImport(node);
|
||
|
||
if (result.type === "ImportDeclaration" && (!result.importKind || result.importKind === "value")) {
|
||
this.sawUnambiguousESM = true;
|
||
}
|
||
} else {
|
||
result = this.parseExport(node);
|
||
|
||
if (result.type === "ExportNamedDeclaration" && (!result.exportKind || result.exportKind === "value") || result.type === "ExportAllDeclaration" && (!result.exportKind || result.exportKind === "value") || result.type === "ExportDefaultDeclaration") {
|
||
this.sawUnambiguousESM = true;
|
||
}
|
||
}
|
||
|
||
this.assertModuleNodeAllowed(node);
|
||
return result;
|
||
}
|
||
|
||
default:
|
||
{
|
||
if (this.isAsyncFunction()) {
|
||
if (context) {
|
||
this.unexpected(null, "Async functions can only be declared at the top level or inside a block");
|
||
}
|
||
|
||
this.next();
|
||
return this.parseFunctionStatement(node, true, !context);
|
||
}
|
||
}
|
||
}
|
||
|
||
const maybeName = this.state.value;
|
||
const expr = this.parseExpression();
|
||
|
||
if (starttype === types.name && expr.type === "Identifier" && this.eat(types.colon)) {
|
||
return this.parseLabeledStatement(node, maybeName, expr, context);
|
||
} else {
|
||
return this.parseExpressionStatement(node, expr);
|
||
}
|
||
}
|
||
|
||
assertModuleNodeAllowed(node) {
|
||
if (!this.options.allowImportExportEverywhere && !this.inModule) {
|
||
this.raise(node.start, `'import' and 'export' may appear only with 'sourceType: "module"'`, {
|
||
code: "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED"
|
||
});
|
||
}
|
||
}
|
||
|
||
takeDecorators(node) {
|
||
const decorators = this.state.decoratorStack[this.state.decoratorStack.length - 1];
|
||
|
||
if (decorators.length) {
|
||
node.decorators = decorators;
|
||
this.resetStartLocationFromNode(node, decorators[0]);
|
||
this.state.decoratorStack[this.state.decoratorStack.length - 1] = [];
|
||
}
|
||
}
|
||
|
||
canHaveLeadingDecorator() {
|
||
return this.match(types._class);
|
||
}
|
||
|
||
parseDecorators(allowExport) {
|
||
const currentContextDecorators = this.state.decoratorStack[this.state.decoratorStack.length - 1];
|
||
|
||
while (this.match(types.at)) {
|
||
const decorator = this.parseDecorator();
|
||
currentContextDecorators.push(decorator);
|
||
}
|
||
|
||
if (this.match(types._export)) {
|
||
if (!allowExport) {
|
||
this.unexpected();
|
||
}
|
||
|
||
if (this.hasPlugin("decorators") && !this.getPluginOption("decorators", "decoratorsBeforeExport")) {
|
||
this.raise(this.state.start, "Using the export keyword between a decorator and a class is not allowed. " + "Please use `export @dec class` instead.");
|
||
}
|
||
} else if (!this.canHaveLeadingDecorator()) {
|
||
this.raise(this.state.start, "Leading decorators must be attached to a class declaration");
|
||
}
|
||
}
|
||
|
||
parseDecorator() {
|
||
this.expectOnePlugin(["decorators-legacy", "decorators"]);
|
||
const node = this.startNode();
|
||
this.next();
|
||
|
||
if (this.hasPlugin("decorators")) {
|
||
this.state.decoratorStack.push([]);
|
||
const startPos = this.state.start;
|
||
const startLoc = this.state.startLoc;
|
||
let expr;
|
||
|
||
if (this.eat(types.parenL)) {
|
||
expr = this.parseExpression();
|
||
this.expect(types.parenR);
|
||
} else {
|
||
expr = this.parseIdentifier(false);
|
||
|
||
while (this.eat(types.dot)) {
|
||
const node = this.startNodeAt(startPos, startLoc);
|
||
node.object = expr;
|
||
node.property = this.parseIdentifier(true);
|
||
node.computed = false;
|
||
expr = this.finishNode(node, "MemberExpression");
|
||
}
|
||
}
|
||
|
||
node.expression = this.parseMaybeDecoratorArguments(expr);
|
||
this.state.decoratorStack.pop();
|
||
} else {
|
||
node.expression = this.parseExprSubscripts();
|
||
}
|
||
|
||
return this.finishNode(node, "Decorator");
|
||
}
|
||
|
||
parseMaybeDecoratorArguments(expr) {
|
||
if (this.eat(types.parenL)) {
|
||
const node = this.startNodeAtNode(expr);
|
||
node.callee = expr;
|
||
node.arguments = this.parseCallExpressionArguments(types.parenR, false);
|
||
this.toReferencedList(node.arguments);
|
||
return this.finishNode(node, "CallExpression");
|
||
}
|
||
|
||
return expr;
|
||
}
|
||
|
||
parseBreakContinueStatement(node, keyword) {
|
||
const isBreak = keyword === "break";
|
||
this.next();
|
||
|
||
if (this.isLineTerminator()) {
|
||
node.label = null;
|
||
} else {
|
||
node.label = this.parseIdentifier();
|
||
this.semicolon();
|
||
}
|
||
|
||
this.verifyBreakContinue(node, keyword);
|
||
return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement");
|
||
}
|
||
|
||
verifyBreakContinue(node, keyword) {
|
||
const isBreak = keyword === "break";
|
||
let i;
|
||
|
||
for (i = 0; i < this.state.labels.length; ++i) {
|
||
const lab = this.state.labels[i];
|
||
|
||
if (node.label == null || lab.name === node.label.name) {
|
||
if (lab.kind != null && (isBreak || lab.kind === "loop")) break;
|
||
if (node.label && isBreak) break;
|
||
}
|
||
}
|
||
|
||
if (i === this.state.labels.length) {
|
||
this.raise(node.start, "Unsyntactic " + keyword);
|
||
}
|
||
}
|
||
|
||
parseDebuggerStatement(node) {
|
||
this.next();
|
||
this.semicolon();
|
||
return this.finishNode(node, "DebuggerStatement");
|
||
}
|
||
|
||
parseHeaderExpression() {
|
||
this.expect(types.parenL);
|
||
const val = this.parseExpression();
|
||
this.expect(types.parenR);
|
||
return val;
|
||
}
|
||
|
||
parseDoStatement(node) {
|
||
this.next();
|
||
this.state.labels.push(loopLabel);
|
||
node.body = this.withTopicForbiddingContext(() => this.parseStatement("do"));
|
||
this.state.labels.pop();
|
||
this.expect(types._while);
|
||
node.test = this.parseHeaderExpression();
|
||
this.eat(types.semi);
|
||
return this.finishNode(node, "DoWhileStatement");
|
||
}
|
||
|
||
parseForStatement(node) {
|
||
this.next();
|
||
this.state.labels.push(loopLabel);
|
||
let awaitAt = -1;
|
||
|
||
if ((this.scope.inAsync || !this.scope.inFunction && this.options.allowAwaitOutsideFunction) && this.eatContextual("await")) {
|
||
awaitAt = this.state.lastTokStart;
|
||
}
|
||
|
||
this.scope.enter(SCOPE_OTHER);
|
||
this.expect(types.parenL);
|
||
|
||
if (this.match(types.semi)) {
|
||
if (awaitAt > -1) {
|
||
this.unexpected(awaitAt);
|
||
}
|
||
|
||
return this.parseFor(node, null);
|
||
}
|
||
|
||
const isLet = this.isLet();
|
||
|
||
if (this.match(types._var) || this.match(types._const) || isLet) {
|
||
const init = this.startNode();
|
||
const kind = isLet ? "let" : this.state.value;
|
||
this.next();
|
||
this.parseVar(init, true, kind);
|
||
this.finishNode(init, "VariableDeclaration");
|
||
|
||
if ((this.match(types._in) || this.isContextual("of")) && init.declarations.length === 1) {
|
||
return this.parseForIn(node, init, awaitAt);
|
||
}
|
||
|
||
if (awaitAt > -1) {
|
||
this.unexpected(awaitAt);
|
||
}
|
||
|
||
return this.parseFor(node, init);
|
||
}
|
||
|
||
const refShorthandDefaultPos = {
|
||
start: 0
|
||
};
|
||
const init = this.parseExpression(true, refShorthandDefaultPos);
|
||
|
||
if (this.match(types._in) || this.isContextual("of")) {
|
||
const description = this.isContextual("of") ? "for-of statement" : "for-in statement";
|
||
this.toAssignable(init, undefined, description);
|
||
this.checkLVal(init, undefined, undefined, description);
|
||
return this.parseForIn(node, init, awaitAt);
|
||
} else if (refShorthandDefaultPos.start) {
|
||
this.unexpected(refShorthandDefaultPos.start);
|
||
}
|
||
|
||
if (awaitAt > -1) {
|
||
this.unexpected(awaitAt);
|
||
}
|
||
|
||
return this.parseFor(node, init);
|
||
}
|
||
|
||
parseFunctionStatement(node, isAsync, declarationPosition) {
|
||
this.next();
|
||
return this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), isAsync);
|
||
}
|
||
|
||
parseIfStatement(node) {
|
||
this.next();
|
||
node.test = this.parseHeaderExpression();
|
||
node.consequent = this.parseStatement("if");
|
||
node.alternate = this.eat(types._else) ? this.parseStatement("if") : null;
|
||
return this.finishNode(node, "IfStatement");
|
||
}
|
||
|
||
parseReturnStatement(node) {
|
||
if (!this.scope.inFunction && !this.options.allowReturnOutsideFunction) {
|
||
this.raise(this.state.start, "'return' outside of function");
|
||
}
|
||
|
||
this.next();
|
||
|
||
if (this.isLineTerminator()) {
|
||
node.argument = null;
|
||
} else {
|
||
node.argument = this.parseExpression();
|
||
this.semicolon();
|
||
}
|
||
|
||
return this.finishNode(node, "ReturnStatement");
|
||
}
|
||
|
||
parseSwitchStatement(node) {
|
||
this.next();
|
||
node.discriminant = this.parseHeaderExpression();
|
||
const cases = node.cases = [];
|
||
this.expect(types.braceL);
|
||
this.state.labels.push(switchLabel);
|
||
this.scope.enter(SCOPE_OTHER);
|
||
let cur;
|
||
|
||
for (let sawDefault; !this.match(types.braceR);) {
|
||
if (this.match(types._case) || this.match(types._default)) {
|
||
const isCase = this.match(types._case);
|
||
if (cur) this.finishNode(cur, "SwitchCase");
|
||
cases.push(cur = this.startNode());
|
||
cur.consequent = [];
|
||
this.next();
|
||
|
||
if (isCase) {
|
||
cur.test = this.parseExpression();
|
||
} else {
|
||
if (sawDefault) {
|
||
this.raise(this.state.lastTokStart, "Multiple default clauses");
|
||
}
|
||
|
||
sawDefault = true;
|
||
cur.test = null;
|
||
}
|
||
|
||
this.expect(types.colon);
|
||
} else {
|
||
if (cur) {
|
||
cur.consequent.push(this.parseStatement(null));
|
||
} else {
|
||
this.unexpected();
|
||
}
|
||
}
|
||
}
|
||
|
||
this.scope.exit();
|
||
if (cur) this.finishNode(cur, "SwitchCase");
|
||
this.next();
|
||
this.state.labels.pop();
|
||
return this.finishNode(node, "SwitchStatement");
|
||
}
|
||
|
||
parseThrowStatement(node) {
|
||
this.next();
|
||
|
||
if (lineBreak.test(this.input.slice(this.state.lastTokEnd, this.state.start))) {
|
||
this.raise(this.state.lastTokEnd, "Illegal newline after throw");
|
||
}
|
||
|
||
node.argument = this.parseExpression();
|
||
this.semicolon();
|
||
return this.finishNode(node, "ThrowStatement");
|
||
}
|
||
|
||
parseTryStatement(node) {
|
||
this.next();
|
||
node.block = this.parseBlock();
|
||
node.handler = null;
|
||
|
||
if (this.match(types._catch)) {
|
||
const clause = this.startNode();
|
||
this.next();
|
||
|
||
if (this.match(types.parenL)) {
|
||
this.expect(types.parenL);
|
||
clause.param = this.parseBindingAtom();
|
||
const simple = clause.param.type === "Identifier";
|
||
this.scope.enter(simple ? SCOPE_SIMPLE_CATCH : 0);
|
||
this.checkLVal(clause.param, BIND_LEXICAL, null, "catch clause");
|
||
this.expect(types.parenR);
|
||
} else {
|
||
clause.param = null;
|
||
this.scope.enter(SCOPE_OTHER);
|
||
}
|
||
|
||
clause.body = this.withTopicForbiddingContext(() => this.parseBlock(false, false));
|
||
this.scope.exit();
|
||
node.handler = this.finishNode(clause, "CatchClause");
|
||
}
|
||
|
||
node.finalizer = this.eat(types._finally) ? this.parseBlock() : null;
|
||
|
||
if (!node.handler && !node.finalizer) {
|
||
this.raise(node.start, "Missing catch or finally clause");
|
||
}
|
||
|
||
return this.finishNode(node, "TryStatement");
|
||
}
|
||
|
||
parseVarStatement(node, kind) {
|
||
this.next();
|
||
this.parseVar(node, false, kind);
|
||
this.semicolon();
|
||
return this.finishNode(node, "VariableDeclaration");
|
||
}
|
||
|
||
parseWhileStatement(node) {
|
||
this.next();
|
||
node.test = this.parseHeaderExpression();
|
||
this.state.labels.push(loopLabel);
|
||
node.body = this.withTopicForbiddingContext(() => this.parseStatement("while"));
|
||
this.state.labels.pop();
|
||
return this.finishNode(node, "WhileStatement");
|
||
}
|
||
|
||
parseWithStatement(node) {
|
||
if (this.state.strict) {
|
||
this.raise(this.state.start, "'with' in strict mode");
|
||
}
|
||
|
||
this.next();
|
||
node.object = this.parseHeaderExpression();
|
||
node.body = this.withTopicForbiddingContext(() => this.parseStatement("with"));
|
||
return this.finishNode(node, "WithStatement");
|
||
}
|
||
|
||
parseEmptyStatement(node) {
|
||
this.next();
|
||
return this.finishNode(node, "EmptyStatement");
|
||
}
|
||
|
||
parseLabeledStatement(node, maybeName, expr, context) {
|
||
for (let _i2 = 0, _this$state$labels = this.state.labels; _i2 < _this$state$labels.length; _i2++) {
|
||
const label = _this$state$labels[_i2];
|
||
|
||
if (label.name === maybeName) {
|
||
this.raise(expr.start, `Label '${maybeName}' is already declared`);
|
||
}
|
||
}
|
||
|
||
const kind = this.state.type.isLoop ? "loop" : this.match(types._switch) ? "switch" : null;
|
||
|
||
for (let i = this.state.labels.length - 1; i >= 0; i--) {
|
||
const label = this.state.labels[i];
|
||
|
||
if (label.statementStart === node.start) {
|
||
label.statementStart = this.state.start;
|
||
label.kind = kind;
|
||
} else {
|
||
break;
|
||
}
|
||
}
|
||
|
||
this.state.labels.push({
|
||
name: maybeName,
|
||
kind: kind,
|
||
statementStart: this.state.start
|
||
});
|
||
node.body = this.parseStatement(context ? context.indexOf("label") === -1 ? context + "label" : context : "label");
|
||
this.state.labels.pop();
|
||
node.label = expr;
|
||
return this.finishNode(node, "LabeledStatement");
|
||
}
|
||
|
||
parseExpressionStatement(node, expr) {
|
||
node.expression = expr;
|
||
this.semicolon();
|
||
return this.finishNode(node, "ExpressionStatement");
|
||
}
|
||
|
||
parseBlock(allowDirectives = false, createNewLexicalScope = true) {
|
||
const node = this.startNode();
|
||
this.expect(types.braceL);
|
||
|
||
if (createNewLexicalScope) {
|
||
this.scope.enter(SCOPE_OTHER);
|
||
}
|
||
|
||
this.parseBlockBody(node, allowDirectives, false, types.braceR);
|
||
|
||
if (createNewLexicalScope) {
|
||
this.scope.exit();
|
||
}
|
||
|
||
return this.finishNode(node, "BlockStatement");
|
||
}
|
||
|
||
isValidDirective(stmt) {
|
||
return stmt.type === "ExpressionStatement" && stmt.expression.type === "StringLiteral" && !stmt.expression.extra.parenthesized;
|
||
}
|
||
|
||
parseBlockBody(node, allowDirectives, topLevel, end) {
|
||
const body = node.body = [];
|
||
const directives = node.directives = [];
|
||
this.parseBlockOrModuleBlockBody(body, allowDirectives ? directives : undefined, topLevel, end);
|
||
}
|
||
|
||
parseBlockOrModuleBlockBody(body, directives, topLevel, end) {
|
||
let parsedNonDirective = false;
|
||
let oldStrict;
|
||
let octalPosition;
|
||
|
||
while (!this.eat(end)) {
|
||
if (!parsedNonDirective && this.state.containsOctal && !octalPosition) {
|
||
octalPosition = this.state.octalPosition;
|
||
}
|
||
|
||
const stmt = this.parseStatement(null, topLevel);
|
||
|
||
if (directives && !parsedNonDirective && this.isValidDirective(stmt)) {
|
||
const directive = this.stmtToDirective(stmt);
|
||
directives.push(directive);
|
||
|
||
if (oldStrict === undefined && directive.value.value === "use strict") {
|
||
oldStrict = this.state.strict;
|
||
this.setStrict(true);
|
||
|
||
if (octalPosition) {
|
||
this.raise(octalPosition, "Octal literal in strict mode");
|
||
}
|
||
}
|
||
|
||
continue;
|
||
}
|
||
|
||
parsedNonDirective = true;
|
||
body.push(stmt);
|
||
}
|
||
|
||
if (oldStrict === false) {
|
||
this.setStrict(false);
|
||
}
|
||
}
|
||
|
||
parseFor(node, init) {
|
||
node.init = init;
|
||
this.expect(types.semi);
|
||
node.test = this.match(types.semi) ? null : this.parseExpression();
|
||
this.expect(types.semi);
|
||
node.update = this.match(types.parenR) ? null : this.parseExpression();
|
||
this.expect(types.parenR);
|
||
node.body = this.withTopicForbiddingContext(() => this.parseStatement("for"));
|
||
this.scope.exit();
|
||
this.state.labels.pop();
|
||
return this.finishNode(node, "ForStatement");
|
||
}
|
||
|
||
parseForIn(node, init, awaitAt) {
|
||
const isForIn = this.match(types._in);
|
||
this.next();
|
||
|
||
if (isForIn) {
|
||
if (awaitAt > -1) this.unexpected(awaitAt);
|
||
} else {
|
||
node.await = awaitAt > -1;
|
||
}
|
||
|
||
if (init.type === "VariableDeclaration" && init.declarations[0].init != null && (!isForIn || this.state.strict || init.kind !== "var" || init.declarations[0].id.type !== "Identifier")) {
|
||
this.raise(init.start, `${isForIn ? "for-in" : "for-of"} loop variable declaration may not have an initializer`);
|
||
} else if (init.type === "AssignmentPattern") {
|
||
this.raise(init.start, "Invalid left-hand side in for-loop");
|
||
}
|
||
|
||
node.left = init;
|
||
node.right = isForIn ? this.parseExpression() : this.parseMaybeAssign();
|
||
this.expect(types.parenR);
|
||
node.body = this.withTopicForbiddingContext(() => this.parseStatement("for"));
|
||
this.scope.exit();
|
||
this.state.labels.pop();
|
||
return this.finishNode(node, isForIn ? "ForInStatement" : "ForOfStatement");
|
||
}
|
||
|
||
parseVar(node, isFor, kind) {
|
||
const declarations = node.declarations = [];
|
||
const isTypescript = this.hasPlugin("typescript");
|
||
node.kind = kind;
|
||
|
||
for (;;) {
|
||
const decl = this.startNode();
|
||
this.parseVarId(decl, kind);
|
||
|
||
if (this.eat(types.eq)) {
|
||
decl.init = this.parseMaybeAssign(isFor);
|
||
} else {
|
||
if (kind === "const" && !(this.match(types._in) || this.isContextual("of"))) {
|
||
if (!isTypescript) {
|
||
this.unexpected();
|
||
}
|
||
} else if (decl.id.type !== "Identifier" && !(isFor && (this.match(types._in) || this.isContextual("of")))) {
|
||
this.raise(this.state.lastTokEnd, "Complex binding patterns require an initialization value");
|
||
}
|
||
|
||
decl.init = null;
|
||
}
|
||
|
||
declarations.push(this.finishNode(decl, "VariableDeclarator"));
|
||
if (!this.eat(types.comma)) break;
|
||
}
|
||
|
||
return node;
|
||
}
|
||
|
||
parseVarId(decl, kind) {
|
||
decl.id = this.parseBindingAtom();
|
||
this.checkLVal(decl.id, kind === "var" ? BIND_VAR : BIND_LEXICAL, undefined, "variable declaration");
|
||
}
|
||
|
||
parseFunction(node, statement = FUNC_NO_FLAGS, isAsync = false) {
|
||
const isStatement = statement & FUNC_STATEMENT;
|
||
const isHangingStatement = statement & FUNC_HANGING_STATEMENT;
|
||
const requireId = !!isStatement && !(statement & FUNC_NULLABLE_ID);
|
||
this.initFunction(node, isAsync);
|
||
|
||
if (this.match(types.star) && isHangingStatement) {
|
||
this.unexpected(this.state.start, "Generators can only be declared at the top level or inside a block");
|
||
}
|
||
|
||
node.generator = this.eat(types.star);
|
||
|
||
if (isStatement) {
|
||
node.id = this.parseFunctionId(requireId);
|
||
}
|
||
|
||
const oldInClassProperty = this.state.inClassProperty;
|
||
const oldYieldPos = this.state.yieldPos;
|
||
const oldAwaitPos = this.state.awaitPos;
|
||
this.state.inClassProperty = false;
|
||
this.state.yieldPos = 0;
|
||
this.state.awaitPos = 0;
|
||
this.scope.enter(functionFlags(node.async, node.generator));
|
||
|
||
if (!isStatement) {
|
||
node.id = this.parseFunctionId();
|
||
}
|
||
|
||
this.parseFunctionParams(node);
|
||
this.withTopicForbiddingContext(() => {
|
||
this.parseFunctionBodyAndFinish(node, isStatement ? "FunctionDeclaration" : "FunctionExpression");
|
||
});
|
||
this.scope.exit();
|
||
|
||
if (isStatement && !isHangingStatement) {
|
||
this.checkFunctionStatementId(node);
|
||
}
|
||
|
||
this.state.inClassProperty = oldInClassProperty;
|
||
this.state.yieldPos = oldYieldPos;
|
||
this.state.awaitPos = oldAwaitPos;
|
||
return node;
|
||
}
|
||
|
||
parseFunctionId(requireId) {
|
||
return requireId || this.match(types.name) ? this.parseIdentifier() : null;
|
||
}
|
||
|
||
parseFunctionParams(node, allowModifiers) {
|
||
const oldInParameters = this.state.inParameters;
|
||
this.state.inParameters = true;
|
||
this.expect(types.parenL);
|
||
node.params = this.parseBindingList(types.parenR, false, allowModifiers);
|
||
this.state.inParameters = oldInParameters;
|
||
this.checkYieldAwaitInDefaultParams();
|
||
}
|
||
|
||
checkFunctionStatementId(node) {
|
||
if (!node.id) return;
|
||
this.checkLVal(node.id, this.state.strict || node.generator || node.async ? this.scope.treatFunctionsAsVar ? BIND_VAR : BIND_LEXICAL : BIND_FUNCTION, null, "function name");
|
||
}
|
||
|
||
parseClass(node, isStatement, optionalId) {
|
||
this.next();
|
||
this.takeDecorators(node);
|
||
const oldStrict = this.state.strict;
|
||
this.state.strict = true;
|
||
this.parseClassId(node, isStatement, optionalId);
|
||
this.parseClassSuper(node);
|
||
node.body = this.parseClassBody(!!node.superClass);
|
||
this.state.strict = oldStrict;
|
||
return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression");
|
||
}
|
||
|
||
isClassProperty() {
|
||
return this.match(types.eq) || this.match(types.semi) || this.match(types.braceR);
|
||
}
|
||
|
||
isClassMethod() {
|
||
return this.match(types.parenL);
|
||
}
|
||
|
||
isNonstaticConstructor(method) {
|
||
return !method.computed && !method.static && (method.key.name === "constructor" || method.key.value === "constructor");
|
||
}
|
||
|
||
parseClassBody(constructorAllowsSuper) {
|
||
this.state.classLevel++;
|
||
const state = {
|
||
hadConstructor: false
|
||
};
|
||
let decorators = [];
|
||
const classBody = this.startNode();
|
||
classBody.body = [];
|
||
this.expect(types.braceL);
|
||
this.withTopicForbiddingContext(() => {
|
||
while (!this.eat(types.braceR)) {
|
||
if (this.eat(types.semi)) {
|
||
if (decorators.length > 0) {
|
||
this.raise(this.state.lastTokEnd, "Decorators must not be followed by a semicolon");
|
||
}
|
||
|
||
continue;
|
||
}
|
||
|
||
if (this.match(types.at)) {
|
||
decorators.push(this.parseDecorator());
|
||
continue;
|
||
}
|
||
|
||
const member = this.startNode();
|
||
|
||
if (decorators.length) {
|
||
member.decorators = decorators;
|
||
this.resetStartLocationFromNode(member, decorators[0]);
|
||
decorators = [];
|
||
}
|
||
|
||
this.parseClassMember(classBody, member, state, constructorAllowsSuper);
|
||
|
||
if (member.kind === "constructor" && member.decorators && member.decorators.length > 0) {
|
||
this.raise(member.start, "Decorators can't be used with a constructor. Did you mean '@dec class { ... }'?");
|
||
}
|
||
}
|
||
});
|
||
|
||
if (decorators.length) {
|
||
this.raise(this.state.start, "You have trailing decorators with no method");
|
||
}
|
||
|
||
this.state.classLevel--;
|
||
return this.finishNode(classBody, "ClassBody");
|
||
}
|
||
|
||
parseClassMember(classBody, member, state, constructorAllowsSuper) {
|
||
let isStatic = false;
|
||
const containsEsc = this.state.containsEsc;
|
||
|
||
if (this.match(types.name) && this.state.value === "static") {
|
||
const key = this.parseIdentifier(true);
|
||
|
||
if (this.isClassMethod()) {
|
||
const method = member;
|
||
method.kind = "method";
|
||
method.computed = false;
|
||
method.key = key;
|
||
method.static = false;
|
||
this.pushClassMethod(classBody, method, false, false, false, false);
|
||
return;
|
||
} else if (this.isClassProperty()) {
|
||
const prop = member;
|
||
prop.computed = false;
|
||
prop.key = key;
|
||
prop.static = false;
|
||
classBody.body.push(this.parseClassProperty(prop));
|
||
return;
|
||
} else if (containsEsc) {
|
||
throw this.unexpected();
|
||
}
|
||
|
||
isStatic = true;
|
||
}
|
||
|
||
this.parseClassMemberWithIsStatic(classBody, member, state, isStatic, constructorAllowsSuper);
|
||
}
|
||
|
||
parseClassMemberWithIsStatic(classBody, member, state, isStatic, constructorAllowsSuper) {
|
||
const publicMethod = member;
|
||
const privateMethod = member;
|
||
const publicProp = member;
|
||
const privateProp = member;
|
||
const method = publicMethod;
|
||
const publicMember = publicMethod;
|
||
member.static = isStatic;
|
||
|
||
if (this.eat(types.star)) {
|
||
method.kind = "method";
|
||
this.parseClassPropertyName(method);
|
||
|
||
if (method.key.type === "PrivateName") {
|
||
this.pushClassPrivateMethod(classBody, privateMethod, true, false);
|
||
return;
|
||
}
|
||
|
||
if (this.isNonstaticConstructor(publicMethod)) {
|
||
this.raise(publicMethod.key.start, "Constructor can't be a generator");
|
||
}
|
||
|
||
this.pushClassMethod(classBody, publicMethod, true, false, false, false);
|
||
return;
|
||
}
|
||
|
||
const containsEsc = this.state.containsEsc;
|
||
const key = this.parseClassPropertyName(member);
|
||
const isPrivate = key.type === "PrivateName";
|
||
const isSimple = key.type === "Identifier";
|
||
this.parsePostMemberNameModifiers(publicMember);
|
||
|
||
if (this.isClassMethod()) {
|
||
method.kind = "method";
|
||
|
||
if (isPrivate) {
|
||
this.pushClassPrivateMethod(classBody, privateMethod, false, false);
|
||
return;
|
||
}
|
||
|
||
const isConstructor = this.isNonstaticConstructor(publicMethod);
|
||
let allowsDirectSuper = false;
|
||
|
||
if (isConstructor) {
|
||
publicMethod.kind = "constructor";
|
||
|
||
if (publicMethod.decorators) {
|
||
this.raise(publicMethod.start, "You can't attach decorators to a class constructor");
|
||
}
|
||
|
||
if (state.hadConstructor && !this.hasPlugin("typescript")) {
|
||
this.raise(key.start, "Duplicate constructor in the same class");
|
||
}
|
||
|
||
state.hadConstructor = true;
|
||
allowsDirectSuper = constructorAllowsSuper;
|
||
}
|
||
|
||
this.pushClassMethod(classBody, publicMethod, false, false, isConstructor, allowsDirectSuper);
|
||
} else if (this.isClassProperty()) {
|
||
if (isPrivate) {
|
||
this.pushClassPrivateProperty(classBody, privateProp);
|
||
} else {
|
||
this.pushClassProperty(classBody, publicProp);
|
||
}
|
||
} else if (isSimple && key.name === "async" && !containsEsc && !this.isLineTerminator()) {
|
||
const isGenerator = this.eat(types.star);
|
||
method.kind = "method";
|
||
this.parseClassPropertyName(method);
|
||
|
||
if (method.key.type === "PrivateName") {
|
||
this.pushClassPrivateMethod(classBody, privateMethod, isGenerator, true);
|
||
} else {
|
||
if (this.isNonstaticConstructor(publicMethod)) {
|
||
this.raise(publicMethod.key.start, "Constructor can't be an async function");
|
||
}
|
||
|
||
this.pushClassMethod(classBody, publicMethod, isGenerator, true, false, false);
|
||
}
|
||
} else if (isSimple && (key.name === "get" || key.name === "set") && !containsEsc && !(this.match(types.star) && this.isLineTerminator())) {
|
||
method.kind = key.name;
|
||
this.parseClassPropertyName(publicMethod);
|
||
|
||
if (method.key.type === "PrivateName") {
|
||
this.pushClassPrivateMethod(classBody, privateMethod, false, false);
|
||
} else {
|
||
if (this.isNonstaticConstructor(publicMethod)) {
|
||
this.raise(publicMethod.key.start, "Constructor can't have get/set modifier");
|
||
}
|
||
|
||
this.pushClassMethod(classBody, publicMethod, false, false, false, false);
|
||
}
|
||
|
||
this.checkGetterSetterParams(publicMethod);
|
||
} else if (this.isLineTerminator()) {
|
||
if (isPrivate) {
|
||
this.pushClassPrivateProperty(classBody, privateProp);
|
||
} else {
|
||
this.pushClassProperty(classBody, publicProp);
|
||
}
|
||
} else {
|
||
this.unexpected();
|
||
}
|
||
}
|
||
|
||
parseClassPropertyName(member) {
|
||
const key = this.parsePropertyName(member);
|
||
|
||
if (!member.computed && member.static && (key.name === "prototype" || key.value === "prototype")) {
|
||
this.raise(key.start, "Classes may not have static property named prototype");
|
||
}
|
||
|
||
if (key.type === "PrivateName" && key.id.name === "constructor") {
|
||
this.raise(key.start, "Classes may not have a private field named '#constructor'");
|
||
}
|
||
|
||
return key;
|
||
}
|
||
|
||
pushClassProperty(classBody, prop) {
|
||
if (this.isNonstaticConstructor(prop)) {
|
||
this.raise(prop.key.start, "Classes may not have a non-static field named 'constructor'");
|
||
}
|
||
|
||
classBody.body.push(this.parseClassProperty(prop));
|
||
}
|
||
|
||
pushClassPrivateProperty(classBody, prop) {
|
||
this.expectPlugin("classPrivateProperties", prop.key.start);
|
||
classBody.body.push(this.parseClassPrivateProperty(prop));
|
||
}
|
||
|
||
pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
|
||
classBody.body.push(this.parseMethod(method, isGenerator, isAsync, isConstructor, allowsDirectSuper, "ClassMethod", true));
|
||
}
|
||
|
||
pushClassPrivateMethod(classBody, method, isGenerator, isAsync) {
|
||
this.expectPlugin("classPrivateMethods", method.key.start);
|
||
classBody.body.push(this.parseMethod(method, isGenerator, isAsync, false, false, "ClassPrivateMethod", true));
|
||
}
|
||
|
||
parsePostMemberNameModifiers(methodOrProp) {}
|
||
|
||
parseAccessModifier() {
|
||
return undefined;
|
||
}
|
||
|
||
parseClassPrivateProperty(node) {
|
||
this.state.inClassProperty = true;
|
||
this.scope.enter(SCOPE_CLASS | SCOPE_SUPER);
|
||
node.value = this.eat(types.eq) ? this.parseMaybeAssign() : null;
|
||
this.semicolon();
|
||
this.state.inClassProperty = false;
|
||
this.scope.exit();
|
||
return this.finishNode(node, "ClassPrivateProperty");
|
||
}
|
||
|
||
parseClassProperty(node) {
|
||
if (!node.typeAnnotation) {
|
||
this.expectPlugin("classProperties");
|
||
}
|
||
|
||
this.state.inClassProperty = true;
|
||
this.scope.enter(SCOPE_CLASS | SCOPE_SUPER);
|
||
|
||
if (this.match(types.eq)) {
|
||
this.expectPlugin("classProperties");
|
||
this.next();
|
||
node.value = this.parseMaybeAssign();
|
||
} else {
|
||
node.value = null;
|
||
}
|
||
|
||
this.semicolon();
|
||
this.state.inClassProperty = false;
|
||
this.scope.exit();
|
||
return this.finishNode(node, "ClassProperty");
|
||
}
|
||
|
||
parseClassId(node, isStatement, optionalId) {
|
||
if (this.match(types.name)) {
|
||
node.id = this.parseIdentifier();
|
||
|
||
if (isStatement) {
|
||
this.checkLVal(node.id, BIND_CLASS, undefined, "class name");
|
||
}
|
||
} else {
|
||
if (optionalId || !isStatement) {
|
||
node.id = null;
|
||
} else {
|
||
this.unexpected(null, "A class name is required");
|
||
}
|
||
}
|
||
}
|
||
|
||
parseClassSuper(node) {
|
||
node.superClass = this.eat(types._extends) ? this.parseExprSubscripts() : null;
|
||
}
|
||
|
||
parseExport(node) {
|
||
const hasDefault = this.maybeParseExportDefaultSpecifier(node);
|
||
const parseAfterDefault = !hasDefault || this.eat(types.comma);
|
||
const hasStar = parseAfterDefault && this.eatExportStar(node);
|
||
const hasNamespace = hasStar && this.maybeParseExportNamespaceSpecifier(node);
|
||
const parseAfterNamespace = parseAfterDefault && (!hasNamespace || this.eat(types.comma));
|
||
const isFromRequired = hasDefault || hasStar;
|
||
|
||
if (hasStar && !hasNamespace) {
|
||
if (hasDefault) this.unexpected();
|
||
this.parseExportFrom(node, true);
|
||
return this.finishNode(node, "ExportAllDeclaration");
|
||
}
|
||
|
||
const hasSpecifiers = this.maybeParseExportNamedSpecifiers(node);
|
||
|
||
if (hasDefault && parseAfterDefault && !hasStar && !hasSpecifiers || hasNamespace && parseAfterNamespace && !hasSpecifiers) {
|
||
throw this.unexpected(null, types.braceL);
|
||
}
|
||
|
||
let hasDeclaration;
|
||
|
||
if (isFromRequired || hasSpecifiers) {
|
||
hasDeclaration = false;
|
||
this.parseExportFrom(node, isFromRequired);
|
||
} else {
|
||
hasDeclaration = this.maybeParseExportDeclaration(node);
|
||
}
|
||
|
||
if (isFromRequired || hasSpecifiers || hasDeclaration) {
|
||
this.checkExport(node, true, false, !!node.source);
|
||
return this.finishNode(node, "ExportNamedDeclaration");
|
||
}
|
||
|
||
if (this.eat(types._default)) {
|
||
node.declaration = this.parseExportDefaultExpression();
|
||
this.checkExport(node, true, true);
|
||
return this.finishNode(node, "ExportDefaultDeclaration");
|
||
}
|
||
|
||
throw this.unexpected(null, types.braceL);
|
||
}
|
||
|
||
eatExportStar(node) {
|
||
return this.eat(types.star);
|
||
}
|
||
|
||
maybeParseExportDefaultSpecifier(node) {
|
||
if (this.isExportDefaultSpecifier()) {
|
||
this.expectPlugin("exportDefaultFrom");
|
||
const specifier = this.startNode();
|
||
specifier.exported = this.parseIdentifier(true);
|
||
node.specifiers = [this.finishNode(specifier, "ExportDefaultSpecifier")];
|
||
return true;
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
maybeParseExportNamespaceSpecifier(node) {
|
||
if (this.isContextual("as")) {
|
||
if (!node.specifiers) node.specifiers = [];
|
||
this.expectPlugin("exportNamespaceFrom");
|
||
const specifier = this.startNodeAt(this.state.lastTokStart, this.state.lastTokStartLoc);
|
||
this.next();
|
||
specifier.exported = this.parseIdentifier(true);
|
||
node.specifiers.push(this.finishNode(specifier, "ExportNamespaceSpecifier"));
|
||
return true;
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
maybeParseExportNamedSpecifiers(node) {
|
||
if (this.match(types.braceL)) {
|
||
if (!node.specifiers) node.specifiers = [];
|
||
node.specifiers.push(...this.parseExportSpecifiers());
|
||
node.source = null;
|
||
node.declaration = null;
|
||
return true;
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
maybeParseExportDeclaration(node) {
|
||
if (this.shouldParseExportDeclaration()) {
|
||
if (this.isContextual("async")) {
|
||
const next = this.lookahead();
|
||
|
||
if (next.type !== types._function) {
|
||
this.unexpected(next.start, `Unexpected token, expected "function"`);
|
||
}
|
||
}
|
||
|
||
node.specifiers = [];
|
||
node.source = null;
|
||
node.declaration = this.parseExportDeclaration(node);
|
||
return true;
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
isAsyncFunction() {
|
||
if (!this.isContextual("async")) return false;
|
||
const {
|
||
pos
|
||
} = this.state;
|
||
skipWhiteSpace.lastIndex = pos;
|
||
const skip = skipWhiteSpace.exec(this.input);
|
||
if (!skip || !skip.length) return false;
|
||
const next = pos + skip[0].length;
|
||
return !lineBreak.test(this.input.slice(pos, next)) && this.input.slice(next, next + 8) === "function" && (next + 8 === this.length || !isIdentifierChar(this.input.charCodeAt(next + 8)));
|
||
}
|
||
|
||
parseExportDefaultExpression() {
|
||
const expr = this.startNode();
|
||
const isAsync = this.isAsyncFunction();
|
||
|
||
if (this.match(types._function) || isAsync) {
|
||
this.next();
|
||
|
||
if (isAsync) {
|
||
this.next();
|
||
}
|
||
|
||
return this.parseFunction(expr, FUNC_STATEMENT | FUNC_NULLABLE_ID, isAsync);
|
||
} else if (this.match(types._class)) {
|
||
return this.parseClass(expr, true, true);
|
||
} else if (this.match(types.at)) {
|
||
if (this.hasPlugin("decorators") && this.getPluginOption("decorators", "decoratorsBeforeExport")) {
|
||
this.unexpected(this.state.start, "Decorators must be placed *before* the 'export' keyword." + " You can set the 'decoratorsBeforeExport' option to false to use" + " the 'export @decorator class {}' syntax");
|
||
}
|
||
|
||
this.parseDecorators(false);
|
||
return this.parseClass(expr, true, true);
|
||
} else if (this.match(types._const) || this.match(types._var) || this.isLet()) {
|
||
return this.raise(this.state.start, "Only expressions, functions or classes are allowed as the `default` export.");
|
||
} else {
|
||
const res = this.parseMaybeAssign();
|
||
this.semicolon();
|
||
return res;
|
||
}
|
||
}
|
||
|
||
parseExportDeclaration(node) {
|
||
return this.parseStatement(null);
|
||
}
|
||
|
||
isExportDefaultSpecifier() {
|
||
if (this.match(types.name)) {
|
||
return this.state.value !== "async" && this.state.value !== "let";
|
||
}
|
||
|
||
if (!this.match(types._default)) {
|
||
return false;
|
||
}
|
||
|
||
const lookahead = this.lookahead();
|
||
return lookahead.type === types.comma || lookahead.type === types.name && lookahead.value === "from";
|
||
}
|
||
|
||
parseExportFrom(node, expect) {
|
||
if (this.eatContextual("from")) {
|
||
node.source = this.parseImportSource();
|
||
this.checkExport(node);
|
||
} else {
|
||
if (expect) {
|
||
this.unexpected();
|
||
} else {
|
||
node.source = null;
|
||
}
|
||
}
|
||
|
||
this.semicolon();
|
||
}
|
||
|
||
shouldParseExportDeclaration() {
|
||
if (this.match(types.at)) {
|
||
this.expectOnePlugin(["decorators", "decorators-legacy"]);
|
||
|
||
if (this.hasPlugin("decorators")) {
|
||
if (this.getPluginOption("decorators", "decoratorsBeforeExport")) {
|
||
this.unexpected(this.state.start, "Decorators must be placed *before* the 'export' keyword." + " You can set the 'decoratorsBeforeExport' option to false to use" + " the 'export @decorator class {}' syntax");
|
||
} else {
|
||
return true;
|
||
}
|
||
}
|
||
}
|
||
|
||
return this.state.type.keyword === "var" || this.state.type.keyword === "const" || this.state.type.keyword === "function" || this.state.type.keyword === "class" || this.isLet() || this.isAsyncFunction();
|
||
}
|
||
|
||
checkExport(node, checkNames, isDefault, isFrom) {
|
||
if (checkNames) {
|
||
if (isDefault) {
|
||
this.checkDuplicateExports(node, "default");
|
||
} else if (node.specifiers && node.specifiers.length) {
|
||
for (let _i3 = 0, _node$specifiers = node.specifiers; _i3 < _node$specifiers.length; _i3++) {
|
||
const specifier = _node$specifiers[_i3];
|
||
this.checkDuplicateExports(specifier, specifier.exported.name);
|
||
|
||
if (!isFrom && specifier.local) {
|
||
this.checkReservedWord(specifier.local.name, specifier.local.start, true, false);
|
||
this.scope.checkLocalExport(specifier.local);
|
||
}
|
||
}
|
||
} else if (node.declaration) {
|
||
if (node.declaration.type === "FunctionDeclaration" || node.declaration.type === "ClassDeclaration") {
|
||
const id = node.declaration.id;
|
||
if (!id) throw new Error("Assertion failure");
|
||
this.checkDuplicateExports(node, id.name);
|
||
} else if (node.declaration.type === "VariableDeclaration") {
|
||
for (let _i4 = 0, _node$declaration$dec = node.declaration.declarations; _i4 < _node$declaration$dec.length; _i4++) {
|
||
const declaration = _node$declaration$dec[_i4];
|
||
this.checkDeclaration(declaration.id);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
const currentContextDecorators = this.state.decoratorStack[this.state.decoratorStack.length - 1];
|
||
|
||
if (currentContextDecorators.length) {
|
||
const isClass = node.declaration && (node.declaration.type === "ClassDeclaration" || node.declaration.type === "ClassExpression");
|
||
|
||
if (!node.declaration || !isClass) {
|
||
throw this.raise(node.start, "You can only use decorators on an export when exporting a class");
|
||
}
|
||
|
||
this.takeDecorators(node.declaration);
|
||
}
|
||
}
|
||
|
||
checkDeclaration(node) {
|
||
if (node.type === "Identifier") {
|
||
this.checkDuplicateExports(node, node.name);
|
||
} else if (node.type === "ObjectPattern") {
|
||
for (let _i5 = 0, _node$properties = node.properties; _i5 < _node$properties.length; _i5++) {
|
||
const prop = _node$properties[_i5];
|
||
this.checkDeclaration(prop);
|
||
}
|
||
} else if (node.type === "ArrayPattern") {
|
||
for (let _i6 = 0, _node$elements = node.elements; _i6 < _node$elements.length; _i6++) {
|
||
const elem = _node$elements[_i6];
|
||
|
||
if (elem) {
|
||
this.checkDeclaration(elem);
|
||
}
|
||
}
|
||
} else if (node.type === "ObjectProperty") {
|
||
this.checkDeclaration(node.value);
|
||
} else if (node.type === "RestElement") {
|
||
this.checkDeclaration(node.argument);
|
||
} else if (node.type === "AssignmentPattern") {
|
||
this.checkDeclaration(node.left);
|
||
}
|
||
}
|
||
|
||
checkDuplicateExports(node, name) {
|
||
if (this.state.exportedIdentifiers.indexOf(name) > -1) {
|
||
throw this.raise(node.start, name === "default" ? "Only one default export allowed per module." : `\`${name}\` has already been exported. Exported identifiers must be unique.`);
|
||
}
|
||
|
||
this.state.exportedIdentifiers.push(name);
|
||
}
|
||
|
||
parseExportSpecifiers() {
|
||
const nodes = [];
|
||
let first = true;
|
||
this.expect(types.braceL);
|
||
|
||
while (!this.eat(types.braceR)) {
|
||
if (first) {
|
||
first = false;
|
||
} else {
|
||
this.expect(types.comma);
|
||
if (this.eat(types.braceR)) break;
|
||
}
|
||
|
||
const node = this.startNode();
|
||
node.local = this.parseIdentifier(true);
|
||
node.exported = this.eatContextual("as") ? this.parseIdentifier(true) : node.local.__clone();
|
||
nodes.push(this.finishNode(node, "ExportSpecifier"));
|
||
}
|
||
|
||
return nodes;
|
||
}
|
||
|
||
parseImport(node) {
|
||
node.specifiers = [];
|
||
|
||
if (!this.match(types.string)) {
|
||
const hasDefault = this.maybeParseDefaultImportSpecifier(node);
|
||
const parseNext = !hasDefault || this.eat(types.comma);
|
||
const hasStar = parseNext && this.maybeParseStarImportSpecifier(node);
|
||
if (parseNext && !hasStar) this.parseNamedImportSpecifiers(node);
|
||
this.expectContextual("from");
|
||
}
|
||
|
||
node.source = this.parseImportSource();
|
||
this.semicolon();
|
||
return this.finishNode(node, "ImportDeclaration");
|
||
}
|
||
|
||
parseImportSource() {
|
||
if (!this.match(types.string)) this.unexpected();
|
||
return this.parseExprAtom();
|
||
}
|
||
|
||
shouldParseDefaultImport(node) {
|
||
return this.match(types.name);
|
||
}
|
||
|
||
parseImportSpecifierLocal(node, specifier, type, contextDescription) {
|
||
specifier.local = this.parseIdentifier();
|
||
this.checkLVal(specifier.local, BIND_LEXICAL, undefined, contextDescription);
|
||
node.specifiers.push(this.finishNode(specifier, type));
|
||
}
|
||
|
||
maybeParseDefaultImportSpecifier(node) {
|
||
if (this.shouldParseDefaultImport(node)) {
|
||
this.parseImportSpecifierLocal(node, this.startNode(), "ImportDefaultSpecifier", "default import specifier");
|
||
return true;
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
maybeParseStarImportSpecifier(node) {
|
||
if (this.match(types.star)) {
|
||
const specifier = this.startNode();
|
||
this.next();
|
||
this.expectContextual("as");
|
||
this.parseImportSpecifierLocal(node, specifier, "ImportNamespaceSpecifier", "import namespace specifier");
|
||
return true;
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
parseNamedImportSpecifiers(node) {
|
||
let first = true;
|
||
this.expect(types.braceL);
|
||
|
||
while (!this.eat(types.braceR)) {
|
||
if (first) {
|
||
first = false;
|
||
} else {
|
||
if (this.eat(types.colon)) {
|
||
this.unexpected(null, "ES2015 named imports do not destructure. " + "Use another statement for destructuring after the import.");
|
||
}
|
||
|
||
this.expect(types.comma);
|
||
if (this.eat(types.braceR)) break;
|
||
}
|
||
|
||
this.parseImportSpecifier(node);
|
||
}
|
||
}
|
||
|
||
parseImportSpecifier(node) {
|
||
const specifier = this.startNode();
|
||
specifier.imported = this.parseIdentifier(true);
|
||
|
||
if (this.eatContextual("as")) {
|
||
specifier.local = this.parseIdentifier();
|
||
} else {
|
||
this.checkReservedWord(specifier.imported.name, specifier.start, true, true);
|
||
specifier.local = specifier.imported.__clone();
|
||
}
|
||
|
||
this.checkLVal(specifier.local, BIND_LEXICAL, undefined, "import specifier");
|
||
node.specifiers.push(this.finishNode(specifier, "ImportSpecifier"));
|
||
}
|
||
|
||
}
|
||
|
||
class Parser extends StatementParser {
|
||
constructor(options, input) {
|
||
options = getOptions(options);
|
||
super(options, input);
|
||
const ScopeHandler = this.getScopeHandler();
|
||
this.options = options;
|
||
this.inModule = this.options.sourceType === "module";
|
||
this.scope = new ScopeHandler(this.raise.bind(this), this.inModule);
|
||
this.plugins = pluginsMap(this.options.plugins);
|
||
this.filename = options.sourceFilename;
|
||
}
|
||
|
||
getScopeHandler() {
|
||
return ScopeHandler;
|
||
}
|
||
|
||
parse() {
|
||
this.scope.enter(SCOPE_PROGRAM);
|
||
const file = this.startNode();
|
||
const program = this.startNode();
|
||
this.nextToken();
|
||
return this.parseTopLevel(file, program);
|
||
}
|
||
|
||
}
|
||
|
||
function pluginsMap(plugins) {
|
||
const pluginMap = new Map();
|
||
|
||
for (let _i = 0; _i < plugins.length; _i++) {
|
||
const plugin = plugins[_i];
|
||
const [name, options] = Array.isArray(plugin) ? plugin : [plugin, {}];
|
||
if (!pluginMap.has(name)) pluginMap.set(name, options || {});
|
||
}
|
||
|
||
return pluginMap;
|
||
}
|
||
|
||
function parse(input, options) {
|
||
if (options && options.sourceType === "unambiguous") {
|
||
options = Object.assign({}, options);
|
||
|
||
try {
|
||
options.sourceType = "module";
|
||
const parser = getParser(options, input);
|
||
const ast = parser.parse();
|
||
if (!parser.sawUnambiguousESM) ast.program.sourceType = "script";
|
||
return ast;
|
||
} catch (moduleError) {
|
||
try {
|
||
options.sourceType = "script";
|
||
return getParser(options, input).parse();
|
||
} catch (scriptError) {}
|
||
|
||
throw moduleError;
|
||
}
|
||
} else {
|
||
return getParser(options, input).parse();
|
||
}
|
||
}
|
||
function parseExpression(input, options) {
|
||
const parser = getParser(options, input);
|
||
|
||
if (parser.options.strictMode) {
|
||
parser.state.strict = true;
|
||
}
|
||
|
||
return parser.getExpression();
|
||
}
|
||
|
||
function getParser(options, input) {
|
||
let cls = Parser;
|
||
|
||
if (options && options.plugins) {
|
||
validatePlugins(options.plugins);
|
||
cls = getParserClass(options.plugins);
|
||
}
|
||
|
||
return new cls(options, input);
|
||
}
|
||
|
||
const parserClassCache = {};
|
||
|
||
function getParserClass(pluginsFromOptions) {
|
||
const pluginList = mixinPluginNames.filter(name => hasPlugin(pluginsFromOptions, name));
|
||
const key = pluginList.join("/");
|
||
let cls = parserClassCache[key];
|
||
|
||
if (!cls) {
|
||
cls = Parser;
|
||
|
||
for (let _i = 0; _i < pluginList.length; _i++) {
|
||
const plugin = pluginList[_i];
|
||
cls = mixinPlugins[plugin](cls);
|
||
}
|
||
|
||
parserClassCache[key] = cls;
|
||
}
|
||
|
||
return cls;
|
||
}
|
||
|
||
exports.parse = parse;
|
||
exports.parseExpression = parseExpression;
|
||
exports.tokTypes = types;
|
||
|
||
|
||
/***/ }),
|
||
/* 325 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
|
||
function _sourceMap() {
|
||
const data = _interopRequireDefault(__webpack_require__(88));
|
||
|
||
_sourceMap = function () {
|
||
return data;
|
||
};
|
||
|
||
return data;
|
||
}
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
class SourceMap {
|
||
constructor(opts, code) {
|
||
this._cachedMap = null;
|
||
this._code = code;
|
||
this._opts = opts;
|
||
this._rawMappings = [];
|
||
}
|
||
|
||
get() {
|
||
if (!this._cachedMap) {
|
||
const map = this._cachedMap = new (_sourceMap().default.SourceMapGenerator)({
|
||
sourceRoot: this._opts.sourceRoot
|
||
});
|
||
const code = this._code;
|
||
|
||
if (typeof code === "string") {
|
||
map.setSourceContent(this._opts.sourceFileName, code);
|
||
} else if (typeof code === "object") {
|
||
Object.keys(code).forEach(sourceFileName => {
|
||
map.setSourceContent(sourceFileName, code[sourceFileName]);
|
||
});
|
||
}
|
||
|
||
this._rawMappings.forEach(map.addMapping, map);
|
||
}
|
||
|
||
return this._cachedMap.toJSON();
|
||
}
|
||
|
||
getRawMappings() {
|
||
return this._rawMappings.slice();
|
||
}
|
||
|
||
mark(generatedLine, generatedColumn, line, column, identifierName, filename, force) {
|
||
if (this._lastGenLine !== generatedLine && line === null) return;
|
||
|
||
if (!force && this._lastGenLine === generatedLine && this._lastSourceLine === line && this._lastSourceColumn === column) {
|
||
return;
|
||
}
|
||
|
||
this._cachedMap = null;
|
||
this._lastGenLine = generatedLine;
|
||
this._lastSourceLine = line;
|
||
this._lastSourceColumn = column;
|
||
|
||
this._rawMappings.push({
|
||
name: identifierName || undefined,
|
||
generated: {
|
||
line: generatedLine,
|
||
column: generatedColumn
|
||
},
|
||
source: line == null ? undefined : filename || this._opts.sourceFileName,
|
||
original: line == null ? undefined : {
|
||
line: line,
|
||
column: column
|
||
}
|
||
});
|
||
}
|
||
|
||
}
|
||
|
||
exports.default = SourceMap;
|
||
|
||
/***/ }),
|
||
/* 326 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
|
||
function _isInteger() {
|
||
const data = _interopRequireDefault(__webpack_require__(327));
|
||
|
||
_isInteger = function () {
|
||
return data;
|
||
};
|
||
|
||
return data;
|
||
}
|
||
|
||
function _repeat() {
|
||
const data = _interopRequireDefault(__webpack_require__(330));
|
||
|
||
_repeat = function () {
|
||
return data;
|
||
};
|
||
|
||
return data;
|
||
}
|
||
|
||
var _buffer = _interopRequireDefault(__webpack_require__(333));
|
||
|
||
var n = _interopRequireWildcard(__webpack_require__(156));
|
||
|
||
function t() {
|
||
const data = _interopRequireWildcard(__webpack_require__(3));
|
||
|
||
t = function () {
|
||
return data;
|
||
};
|
||
|
||
return data;
|
||
}
|
||
|
||
var generatorFunctions = _interopRequireWildcard(__webpack_require__(337));
|
||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
const SCIENTIFIC_NOTATION = /e/i;
|
||
const ZERO_DECIMAL_INTEGER = /\.0+$/;
|
||
const NON_DECIMAL_LITERAL = /^0[box]/;
|
||
|
||
class Printer {
|
||
constructor(format, map) {
|
||
this.inForStatementInitCounter = 0;
|
||
this._printStack = [];
|
||
this._indent = 0;
|
||
this._insideAux = false;
|
||
this._printedCommentStarts = {};
|
||
this._parenPushNewlineState = null;
|
||
this._noLineTerminator = false;
|
||
this._printAuxAfterOnNextUserNode = false;
|
||
this._printedComments = new WeakSet();
|
||
this._endsWithInteger = false;
|
||
this._endsWithWord = false;
|
||
this.format = format || {};
|
||
this._buf = new _buffer.default(map);
|
||
}
|
||
|
||
generate(ast) {
|
||
this.print(ast);
|
||
|
||
this._maybeAddAuxComment();
|
||
|
||
return this._buf.get();
|
||
}
|
||
|
||
indent() {
|
||
if (this.format.compact || this.format.concise) return;
|
||
this._indent++;
|
||
}
|
||
|
||
dedent() {
|
||
if (this.format.compact || this.format.concise) return;
|
||
this._indent--;
|
||
}
|
||
|
||
semicolon(force = false) {
|
||
this._maybeAddAuxComment();
|
||
|
||
this._append(";", !force);
|
||
}
|
||
|
||
rightBrace() {
|
||
if (this.format.minified) {
|
||
this._buf.removeLastSemicolon();
|
||
}
|
||
|
||
this.token("}");
|
||
}
|
||
|
||
space(force = false) {
|
||
if (this.format.compact) return;
|
||
|
||
if (this._buf.hasContent() && !this.endsWith(" ") && !this.endsWith("\n") || force) {
|
||
this._space();
|
||
}
|
||
}
|
||
|
||
word(str) {
|
||
if (this._endsWithWord || this.endsWith("/") && str.indexOf("/") === 0) {
|
||
this._space();
|
||
}
|
||
|
||
this._maybeAddAuxComment();
|
||
|
||
this._append(str);
|
||
|
||
this._endsWithWord = true;
|
||
}
|
||
|
||
number(str) {
|
||
this.word(str);
|
||
this._endsWithInteger = (0, _isInteger().default)(+str) && !NON_DECIMAL_LITERAL.test(str) && !SCIENTIFIC_NOTATION.test(str) && !ZERO_DECIMAL_INTEGER.test(str) && str[str.length - 1] !== ".";
|
||
}
|
||
|
||
token(str) {
|
||
if (str === "--" && this.endsWith("!") || str[0] === "+" && this.endsWith("+") || str[0] === "-" && this.endsWith("-") || str[0] === "." && this._endsWithInteger) {
|
||
this._space();
|
||
}
|
||
|
||
this._maybeAddAuxComment();
|
||
|
||
this._append(str);
|
||
}
|
||
|
||
newline(i) {
|
||
if (this.format.retainLines || this.format.compact) return;
|
||
|
||
if (this.format.concise) {
|
||
this.space();
|
||
return;
|
||
}
|
||
|
||
if (this.endsWith("\n\n")) return;
|
||
if (typeof i !== "number") i = 1;
|
||
i = Math.min(2, i);
|
||
if (this.endsWith("{\n") || this.endsWith(":\n")) i--;
|
||
if (i <= 0) return;
|
||
|
||
for (let j = 0; j < i; j++) {
|
||
this._newline();
|
||
}
|
||
}
|
||
|
||
endsWith(str) {
|
||
return this._buf.endsWith(str);
|
||
}
|
||
|
||
removeTrailingNewline() {
|
||
this._buf.removeTrailingNewline();
|
||
}
|
||
|
||
exactSource(loc, cb) {
|
||
this._catchUp("start", loc);
|
||
|
||
this._buf.exactSource(loc, cb);
|
||
}
|
||
|
||
source(prop, loc) {
|
||
this._catchUp(prop, loc);
|
||
|
||
this._buf.source(prop, loc);
|
||
}
|
||
|
||
withSource(prop, loc, cb) {
|
||
this._catchUp(prop, loc);
|
||
|
||
this._buf.withSource(prop, loc, cb);
|
||
}
|
||
|
||
_space() {
|
||
this._append(" ", true);
|
||
}
|
||
|
||
_newline() {
|
||
this._append("\n", true);
|
||
}
|
||
|
||
_append(str, queue = false) {
|
||
this._maybeAddParen(str);
|
||
|
||
this._maybeIndent(str);
|
||
|
||
if (queue) this._buf.queue(str);else this._buf.append(str);
|
||
this._endsWithWord = false;
|
||
this._endsWithInteger = false;
|
||
}
|
||
|
||
_maybeIndent(str) {
|
||
if (this._indent && this.endsWith("\n") && str[0] !== "\n") {
|
||
this._buf.queue(this._getIndent());
|
||
}
|
||
}
|
||
|
||
_maybeAddParen(str) {
|
||
const parenPushNewlineState = this._parenPushNewlineState;
|
||
if (!parenPushNewlineState) return;
|
||
this._parenPushNewlineState = null;
|
||
let i;
|
||
|
||
for (i = 0; i < str.length && str[i] === " "; i++) continue;
|
||
|
||
if (i === str.length) return;
|
||
const cha = str[i];
|
||
|
||
if (cha !== "\n") {
|
||
if (cha !== "/") return;
|
||
if (i + 1 === str.length) return;
|
||
const chaPost = str[i + 1];
|
||
if (chaPost !== "/" && chaPost !== "*") return;
|
||
}
|
||
|
||
this.token("(");
|
||
this.indent();
|
||
parenPushNewlineState.printed = true;
|
||
}
|
||
|
||
_catchUp(prop, loc) {
|
||
if (!this.format.retainLines) return;
|
||
const pos = loc ? loc[prop] : null;
|
||
|
||
if (pos && pos.line !== null) {
|
||
const count = pos.line - this._buf.getCurrentLine();
|
||
|
||
for (let i = 0; i < count; i++) {
|
||
this._newline();
|
||
}
|
||
}
|
||
}
|
||
|
||
_getIndent() {
|
||
return (0, _repeat().default)(this.format.indent.style, this._indent);
|
||
}
|
||
|
||
startTerminatorless(isLabel = false) {
|
||
if (isLabel) {
|
||
this._noLineTerminator = true;
|
||
return null;
|
||
} else {
|
||
return this._parenPushNewlineState = {
|
||
printed: false
|
||
};
|
||
}
|
||
}
|
||
|
||
endTerminatorless(state) {
|
||
this._noLineTerminator = false;
|
||
|
||
if (state && state.printed) {
|
||
this.dedent();
|
||
this.newline();
|
||
this.token(")");
|
||
}
|
||
}
|
||
|
||
print(node, parent) {
|
||
if (!node) return;
|
||
const oldConcise = this.format.concise;
|
||
|
||
if (node._compact) {
|
||
this.format.concise = true;
|
||
}
|
||
|
||
const printMethod = this[node.type];
|
||
|
||
if (!printMethod) {
|
||
throw new ReferenceError(`unknown node of type ${JSON.stringify(node.type)} with constructor ${JSON.stringify(node && node.constructor.name)}`);
|
||
}
|
||
|
||
this._printStack.push(node);
|
||
|
||
const oldInAux = this._insideAux;
|
||
this._insideAux = !node.loc;
|
||
|
||
this._maybeAddAuxComment(this._insideAux && !oldInAux);
|
||
|
||
let needsParens = n.needsParens(node, parent, this._printStack);
|
||
|
||
if (this.format.retainFunctionParens && node.type === "FunctionExpression" && node.extra && node.extra.parenthesized) {
|
||
needsParens = true;
|
||
}
|
||
|
||
if (needsParens) this.token("(");
|
||
|
||
this._printLeadingComments(node);
|
||
|
||
const loc = t().isProgram(node) || t().isFile(node) ? null : node.loc;
|
||
this.withSource("start", loc, () => {
|
||
printMethod.call(this, node, parent);
|
||
});
|
||
|
||
this._printTrailingComments(node);
|
||
|
||
if (needsParens) this.token(")");
|
||
|
||
this._printStack.pop();
|
||
|
||
this.format.concise = oldConcise;
|
||
this._insideAux = oldInAux;
|
||
}
|
||
|
||
_maybeAddAuxComment(enteredPositionlessNode) {
|
||
if (enteredPositionlessNode) this._printAuxBeforeComment();
|
||
if (!this._insideAux) this._printAuxAfterComment();
|
||
}
|
||
|
||
_printAuxBeforeComment() {
|
||
if (this._printAuxAfterOnNextUserNode) return;
|
||
this._printAuxAfterOnNextUserNode = true;
|
||
const comment = this.format.auxiliaryCommentBefore;
|
||
|
||
if (comment) {
|
||
this._printComment({
|
||
type: "CommentBlock",
|
||
value: comment
|
||
});
|
||
}
|
||
}
|
||
|
||
_printAuxAfterComment() {
|
||
if (!this._printAuxAfterOnNextUserNode) return;
|
||
this._printAuxAfterOnNextUserNode = false;
|
||
const comment = this.format.auxiliaryCommentAfter;
|
||
|
||
if (comment) {
|
||
this._printComment({
|
||
type: "CommentBlock",
|
||
value: comment
|
||
});
|
||
}
|
||
}
|
||
|
||
getPossibleRaw(node) {
|
||
const extra = node.extra;
|
||
|
||
if (extra && extra.raw != null && extra.rawValue != null && node.value === extra.rawValue) {
|
||
return extra.raw;
|
||
}
|
||
}
|
||
|
||
printJoin(nodes, parent, opts = {}) {
|
||
if (!nodes || !nodes.length) return;
|
||
if (opts.indent) this.indent();
|
||
const newlineOpts = {
|
||
addNewlines: opts.addNewlines
|
||
};
|
||
|
||
for (let i = 0; i < nodes.length; i++) {
|
||
const node = nodes[i];
|
||
if (!node) continue;
|
||
if (opts.statement) this._printNewline(true, node, parent, newlineOpts);
|
||
this.print(node, parent);
|
||
|
||
if (opts.iterator) {
|
||
opts.iterator(node, i);
|
||
}
|
||
|
||
if (opts.separator && i < nodes.length - 1) {
|
||
opts.separator.call(this);
|
||
}
|
||
|
||
if (opts.statement) this._printNewline(false, node, parent, newlineOpts);
|
||
}
|
||
|
||
if (opts.indent) this.dedent();
|
||
}
|
||
|
||
printAndIndentOnComments(node, parent) {
|
||
const indent = node.leadingComments && node.leadingComments.length > 0;
|
||
if (indent) this.indent();
|
||
this.print(node, parent);
|
||
if (indent) this.dedent();
|
||
}
|
||
|
||
printBlock(parent) {
|
||
const node = parent.body;
|
||
|
||
if (!t().isEmptyStatement(node)) {
|
||
this.space();
|
||
}
|
||
|
||
this.print(node, parent);
|
||
}
|
||
|
||
_printTrailingComments(node) {
|
||
this._printComments(this._getComments(false, node));
|
||
}
|
||
|
||
_printLeadingComments(node) {
|
||
this._printComments(this._getComments(true, node));
|
||
}
|
||
|
||
printInnerComments(node, indent = true) {
|
||
if (!node.innerComments || !node.innerComments.length) return;
|
||
if (indent) this.indent();
|
||
|
||
this._printComments(node.innerComments);
|
||
|
||
if (indent) this.dedent();
|
||
}
|
||
|
||
printSequence(nodes, parent, opts = {}) {
|
||
opts.statement = true;
|
||
return this.printJoin(nodes, parent, opts);
|
||
}
|
||
|
||
printList(items, parent, opts = {}) {
|
||
if (opts.separator == null) {
|
||
opts.separator = commaSeparator;
|
||
}
|
||
|
||
return this.printJoin(items, parent, opts);
|
||
}
|
||
|
||
_printNewline(leading, node, parent, opts) {
|
||
if (this.format.retainLines || this.format.compact) return;
|
||
|
||
if (this.format.concise) {
|
||
this.space();
|
||
return;
|
||
}
|
||
|
||
let lines = 0;
|
||
|
||
if (this._buf.hasContent()) {
|
||
if (!leading) lines++;
|
||
if (opts.addNewlines) lines += opts.addNewlines(leading, node) || 0;
|
||
const needs = leading ? n.needsWhitespaceBefore : n.needsWhitespaceAfter;
|
||
if (needs(node, parent)) lines++;
|
||
}
|
||
|
||
this.newline(lines);
|
||
}
|
||
|
||
_getComments(leading, node) {
|
||
return node && (leading ? node.leadingComments : node.trailingComments) || [];
|
||
}
|
||
|
||
_printComment(comment) {
|
||
if (!this.format.shouldPrintComment(comment.value)) return;
|
||
if (comment.ignore) return;
|
||
if (this._printedComments.has(comment)) return;
|
||
|
||
this._printedComments.add(comment);
|
||
|
||
if (comment.start != null) {
|
||
if (this._printedCommentStarts[comment.start]) return;
|
||
this._printedCommentStarts[comment.start] = true;
|
||
}
|
||
|
||
const isBlockComment = comment.type === "CommentBlock";
|
||
this.newline(this._buf.hasContent() && !this._noLineTerminator && isBlockComment ? 1 : 0);
|
||
if (!this.endsWith("[") && !this.endsWith("{")) this.space();
|
||
let val = !isBlockComment && !this._noLineTerminator ? `//${comment.value}\n` : `/*${comment.value}*/`;
|
||
|
||
if (isBlockComment && this.format.indent.adjustMultilineComment) {
|
||
const offset = comment.loc && comment.loc.start.column;
|
||
|
||
if (offset) {
|
||
const newlineRegex = new RegExp("\\n\\s{1," + offset + "}", "g");
|
||
val = val.replace(newlineRegex, "\n");
|
||
}
|
||
|
||
const indentSize = Math.max(this._getIndent().length, this._buf.getCurrentColumn());
|
||
val = val.replace(/\n(?!$)/g, `\n${(0, _repeat().default)(" ", indentSize)}`);
|
||
}
|
||
|
||
if (this.endsWith("/")) this._space();
|
||
this.withSource("start", comment.loc, () => {
|
||
this._append(val);
|
||
});
|
||
this.newline(isBlockComment && !this._noLineTerminator ? 1 : 0);
|
||
}
|
||
|
||
_printComments(comments) {
|
||
if (!comments || !comments.length) return;
|
||
|
||
for (const comment of comments) {
|
||
this._printComment(comment);
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
exports.default = Printer;
|
||
Object.assign(Printer.prototype, generatorFunctions);
|
||
|
||
function commaSeparator() {
|
||
this.token(",");
|
||
this.space();
|
||
}
|
||
|
||
/***/ }),
|
||
/* 327 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var toInteger = __webpack_require__(56);
|
||
|
||
/**
|
||
* Checks if `value` is an integer.
|
||
*
|
||
* **Note:** This method is based on
|
||
* [`Number.isInteger`](https://mdn.io/Number/isInteger).
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 4.0.0
|
||
* @category Lang
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is an integer, else `false`.
|
||
* @example
|
||
*
|
||
* _.isInteger(3);
|
||
* // => true
|
||
*
|
||
* _.isInteger(Number.MIN_VALUE);
|
||
* // => false
|
||
*
|
||
* _.isInteger(Infinity);
|
||
* // => false
|
||
*
|
||
* _.isInteger('3');
|
||
* // => false
|
||
*/
|
||
function isInteger(value) {
|
||
return typeof value == 'number' && value == toInteger(value);
|
||
}
|
||
|
||
module.exports = isInteger;
|
||
|
||
|
||
/***/ }),
|
||
/* 328 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var toNumber = __webpack_require__(329);
|
||
|
||
/** Used as references for various `Number` constants. */
|
||
var INFINITY = 1 / 0,
|
||
MAX_INTEGER = 1.7976931348623157e+308;
|
||
|
||
/**
|
||
* Converts `value` to a finite number.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 4.12.0
|
||
* @category Lang
|
||
* @param {*} value The value to convert.
|
||
* @returns {number} Returns the converted number.
|
||
* @example
|
||
*
|
||
* _.toFinite(3.2);
|
||
* // => 3.2
|
||
*
|
||
* _.toFinite(Number.MIN_VALUE);
|
||
* // => 5e-324
|
||
*
|
||
* _.toFinite(Infinity);
|
||
* // => 1.7976931348623157e+308
|
||
*
|
||
* _.toFinite('3.2');
|
||
* // => 3.2
|
||
*/
|
||
function toFinite(value) {
|
||
if (!value) {
|
||
return value === 0 ? value : 0;
|
||
}
|
||
value = toNumber(value);
|
||
if (value === INFINITY || value === -INFINITY) {
|
||
var sign = (value < 0 ? -1 : 1);
|
||
return sign * MAX_INTEGER;
|
||
}
|
||
return value === value ? value : 0;
|
||
}
|
||
|
||
module.exports = toFinite;
|
||
|
||
|
||
/***/ }),
|
||
/* 329 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var isObject = __webpack_require__(21),
|
||
isSymbol = __webpack_require__(28);
|
||
|
||
/** Used as references for various `Number` constants. */
|
||
var NAN = 0 / 0;
|
||
|
||
/** Used to match leading and trailing whitespace. */
|
||
var reTrim = /^\s+|\s+$/g;
|
||
|
||
/** Used to detect bad signed hexadecimal string values. */
|
||
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
|
||
|
||
/** Used to detect binary string values. */
|
||
var reIsBinary = /^0b[01]+$/i;
|
||
|
||
/** Used to detect octal string values. */
|
||
var reIsOctal = /^0o[0-7]+$/i;
|
||
|
||
/** Built-in method references without a dependency on `root`. */
|
||
var freeParseInt = parseInt;
|
||
|
||
/**
|
||
* Converts `value` to a number.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 4.0.0
|
||
* @category Lang
|
||
* @param {*} value The value to process.
|
||
* @returns {number} Returns the number.
|
||
* @example
|
||
*
|
||
* _.toNumber(3.2);
|
||
* // => 3.2
|
||
*
|
||
* _.toNumber(Number.MIN_VALUE);
|
||
* // => 5e-324
|
||
*
|
||
* _.toNumber(Infinity);
|
||
* // => Infinity
|
||
*
|
||
* _.toNumber('3.2');
|
||
* // => 3.2
|
||
*/
|
||
function toNumber(value) {
|
||
if (typeof value == 'number') {
|
||
return value;
|
||
}
|
||
if (isSymbol(value)) {
|
||
return NAN;
|
||
}
|
||
if (isObject(value)) {
|
||
var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
|
||
value = isObject(other) ? (other + '') : other;
|
||
}
|
||
if (typeof value != 'string') {
|
||
return value === 0 ? value : +value;
|
||
}
|
||
value = value.replace(reTrim, '');
|
||
var isBinary = reIsBinary.test(value);
|
||
return (isBinary || reIsOctal.test(value))
|
||
? freeParseInt(value.slice(2), isBinary ? 2 : 8)
|
||
: (reIsBadHex.test(value) ? NAN : +value);
|
||
}
|
||
|
||
module.exports = toNumber;
|
||
|
||
|
||
/***/ }),
|
||
/* 330 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var baseRepeat = __webpack_require__(331),
|
||
isIterateeCall = __webpack_require__(332),
|
||
toInteger = __webpack_require__(56),
|
||
toString = __webpack_require__(57);
|
||
|
||
/**
|
||
* Repeats the given string `n` times.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 3.0.0
|
||
* @category String
|
||
* @param {string} [string=''] The string to repeat.
|
||
* @param {number} [n=1] The number of times to repeat the string.
|
||
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
|
||
* @returns {string} Returns the repeated string.
|
||
* @example
|
||
*
|
||
* _.repeat('*', 3);
|
||
* // => '***'
|
||
*
|
||
* _.repeat('abc', 2);
|
||
* // => 'abcabc'
|
||
*
|
||
* _.repeat('abc', 0);
|
||
* // => ''
|
||
*/
|
||
function repeat(string, n, guard) {
|
||
if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
|
||
n = 1;
|
||
} else {
|
||
n = toInteger(n);
|
||
}
|
||
return baseRepeat(toString(string), n);
|
||
}
|
||
|
||
module.exports = repeat;
|
||
|
||
|
||
/***/ }),
|
||
/* 331 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/** Used as references for various `Number` constants. */
|
||
var MAX_SAFE_INTEGER = 9007199254740991;
|
||
|
||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||
var nativeFloor = Math.floor;
|
||
|
||
/**
|
||
* The base implementation of `_.repeat` which doesn't coerce arguments.
|
||
*
|
||
* @private
|
||
* @param {string} string The string to repeat.
|
||
* @param {number} n The number of times to repeat the string.
|
||
* @returns {string} Returns the repeated string.
|
||
*/
|
||
function baseRepeat(string, n) {
|
||
var result = '';
|
||
if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
|
||
return result;
|
||
}
|
||
// Leverage the exponentiation by squaring algorithm for a faster repeat.
|
||
// See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
|
||
do {
|
||
if (n % 2) {
|
||
result += string;
|
||
}
|
||
n = nativeFloor(n / 2);
|
||
if (n) {
|
||
string += string;
|
||
}
|
||
} while (n);
|
||
|
||
return result;
|
||
}
|
||
|
||
module.exports = baseRepeat;
|
||
|
||
|
||
/***/ }),
|
||
/* 332 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var eq = __webpack_require__(42),
|
||
isArrayLike = __webpack_require__(52),
|
||
isIndex = __webpack_require__(75),
|
||
isObject = __webpack_require__(21);
|
||
|
||
/**
|
||
* Checks if the given arguments are from an iteratee call.
|
||
*
|
||
* @private
|
||
* @param {*} value The potential iteratee value argument.
|
||
* @param {*} index The potential iteratee index or key argument.
|
||
* @param {*} object The potential iteratee object argument.
|
||
* @returns {boolean} Returns `true` if the arguments are from an iteratee call,
|
||
* else `false`.
|
||
*/
|
||
function isIterateeCall(value, index, object) {
|
||
if (!isObject(object)) {
|
||
return false;
|
||
}
|
||
var type = typeof index;
|
||
if (type == 'number'
|
||
? (isArrayLike(object) && isIndex(index, object.length))
|
||
: (type == 'string' && index in object)
|
||
) {
|
||
return eq(object[index], value);
|
||
}
|
||
return false;
|
||
}
|
||
|
||
module.exports = isIterateeCall;
|
||
|
||
|
||
/***/ }),
|
||
/* 333 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
|
||
function _trimRight() {
|
||
const data = _interopRequireDefault(__webpack_require__(334));
|
||
|
||
_trimRight = function () {
|
||
return data;
|
||
};
|
||
|
||
return data;
|
||
}
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
const SPACES_RE = /^[ \t]+$/;
|
||
|
||
class Buffer {
|
||
constructor(map) {
|
||
this._map = null;
|
||
this._buf = [];
|
||
this._last = "";
|
||
this._queue = [];
|
||
this._position = {
|
||
line: 1,
|
||
column: 0
|
||
};
|
||
this._sourcePosition = {
|
||
identifierName: null,
|
||
line: null,
|
||
column: null,
|
||
filename: null
|
||
};
|
||
this._disallowedPop = null;
|
||
this._map = map;
|
||
}
|
||
|
||
get() {
|
||
this._flush();
|
||
|
||
const map = this._map;
|
||
const result = {
|
||
code: (0, _trimRight().default)(this._buf.join("")),
|
||
map: null,
|
||
rawMappings: map && map.getRawMappings()
|
||
};
|
||
|
||
if (map) {
|
||
Object.defineProperty(result, "map", {
|
||
configurable: true,
|
||
enumerable: true,
|
||
|
||
get() {
|
||
return this.map = map.get();
|
||
},
|
||
|
||
set(value) {
|
||
Object.defineProperty(this, "map", {
|
||
value,
|
||
writable: true
|
||
});
|
||
}
|
||
|
||
});
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
append(str) {
|
||
this._flush();
|
||
|
||
const {
|
||
line,
|
||
column,
|
||
filename,
|
||
identifierName,
|
||
force
|
||
} = this._sourcePosition;
|
||
|
||
this._append(str, line, column, identifierName, filename, force);
|
||
}
|
||
|
||
queue(str) {
|
||
if (str === "\n") {
|
||
while (this._queue.length > 0 && SPACES_RE.test(this._queue[0][0])) {
|
||
this._queue.shift();
|
||
}
|
||
}
|
||
|
||
const {
|
||
line,
|
||
column,
|
||
filename,
|
||
identifierName,
|
||
force
|
||
} = this._sourcePosition;
|
||
|
||
this._queue.unshift([str, line, column, identifierName, filename, force]);
|
||
}
|
||
|
||
_flush() {
|
||
let item;
|
||
|
||
while (item = this._queue.pop()) this._append(...item);
|
||
}
|
||
|
||
_append(str, line, column, identifierName, filename, force) {
|
||
if (this._map && str[0] !== "\n") {
|
||
this._map.mark(this._position.line, this._position.column, line, column, identifierName, filename, force);
|
||
}
|
||
|
||
this._buf.push(str);
|
||
|
||
this._last = str[str.length - 1];
|
||
|
||
for (let i = 0; i < str.length; i++) {
|
||
if (str[i] === "\n") {
|
||
this._position.line++;
|
||
this._position.column = 0;
|
||
} else {
|
||
this._position.column++;
|
||
}
|
||
}
|
||
}
|
||
|
||
removeTrailingNewline() {
|
||
if (this._queue.length > 0 && this._queue[0][0] === "\n") {
|
||
this._queue.shift();
|
||
}
|
||
}
|
||
|
||
removeLastSemicolon() {
|
||
if (this._queue.length > 0 && this._queue[0][0] === ";") {
|
||
this._queue.shift();
|
||
}
|
||
}
|
||
|
||
endsWith(suffix) {
|
||
if (suffix.length === 1) {
|
||
let last;
|
||
|
||
if (this._queue.length > 0) {
|
||
const str = this._queue[0][0];
|
||
last = str[str.length - 1];
|
||
} else {
|
||
last = this._last;
|
||
}
|
||
|
||
return last === suffix;
|
||
}
|
||
|
||
const end = this._last + this._queue.reduce((acc, item) => item[0] + acc, "");
|
||
|
||
if (suffix.length <= end.length) {
|
||
return end.slice(-suffix.length) === suffix;
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
hasContent() {
|
||
return this._queue.length > 0 || !!this._last;
|
||
}
|
||
|
||
exactSource(loc, cb) {
|
||
this.source("start", loc, true);
|
||
cb();
|
||
this.source("end", loc);
|
||
|
||
this._disallowPop("start", loc);
|
||
}
|
||
|
||
source(prop, loc, force) {
|
||
if (prop && !loc) return;
|
||
|
||
this._normalizePosition(prop, loc, this._sourcePosition, force);
|
||
}
|
||
|
||
withSource(prop, loc, cb) {
|
||
if (!this._map) return cb();
|
||
const originalLine = this._sourcePosition.line;
|
||
const originalColumn = this._sourcePosition.column;
|
||
const originalFilename = this._sourcePosition.filename;
|
||
const originalIdentifierName = this._sourcePosition.identifierName;
|
||
this.source(prop, loc);
|
||
cb();
|
||
|
||
if ((!this._sourcePosition.force || this._sourcePosition.line !== originalLine || this._sourcePosition.column !== originalColumn || this._sourcePosition.filename !== originalFilename) && (!this._disallowedPop || this._disallowedPop.line !== originalLine || this._disallowedPop.column !== originalColumn || this._disallowedPop.filename !== originalFilename)) {
|
||
this._sourcePosition.line = originalLine;
|
||
this._sourcePosition.column = originalColumn;
|
||
this._sourcePosition.filename = originalFilename;
|
||
this._sourcePosition.identifierName = originalIdentifierName;
|
||
this._sourcePosition.force = false;
|
||
this._disallowedPop = null;
|
||
}
|
||
}
|
||
|
||
_disallowPop(prop, loc) {
|
||
if (prop && !loc) return;
|
||
this._disallowedPop = this._normalizePosition(prop, loc);
|
||
}
|
||
|
||
_normalizePosition(prop, loc, targetObj, force) {
|
||
const pos = loc ? loc[prop] : null;
|
||
|
||
if (targetObj === undefined) {
|
||
targetObj = {
|
||
identifierName: null,
|
||
line: null,
|
||
column: null,
|
||
filename: null,
|
||
force: false
|
||
};
|
||
}
|
||
|
||
const origLine = targetObj.line;
|
||
const origColumn = targetObj.column;
|
||
const origFilename = targetObj.filename;
|
||
targetObj.identifierName = prop === "start" && loc && loc.identifierName || null;
|
||
targetObj.line = pos ? pos.line : null;
|
||
targetObj.column = pos ? pos.column : null;
|
||
targetObj.filename = loc && loc.filename || null;
|
||
|
||
if (force || targetObj.line !== origLine || targetObj.column !== origColumn || targetObj.filename !== origFilename) {
|
||
targetObj.force = force;
|
||
}
|
||
|
||
return targetObj;
|
||
}
|
||
|
||
getCurrentColumn() {
|
||
const extra = this._queue.reduce((acc, item) => item[0] + acc, "");
|
||
|
||
const lastIndex = extra.lastIndexOf("\n");
|
||
return lastIndex === -1 ? this._position.column + extra.length : extra.length - 1 - lastIndex;
|
||
}
|
||
|
||
getCurrentLine() {
|
||
const extra = this._queue.reduce((acc, item) => item[0] + acc, "");
|
||
|
||
let count = 0;
|
||
|
||
for (let i = 0; i < extra.length; i++) {
|
||
if (extra[i] === "\n") count++;
|
||
}
|
||
|
||
return this._position.line + count;
|
||
}
|
||
|
||
}
|
||
|
||
exports.default = Buffer;
|
||
|
||
/***/ }),
|
||
/* 334 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
module.exports = function (str) {
|
||
var tail = str.length;
|
||
|
||
while (/[\s\uFEFF\u00A0]/.test(str[tail - 1])) {
|
||
tail--;
|
||
}
|
||
|
||
return str.slice(0, tail);
|
||
};
|
||
|
||
|
||
/***/ }),
|
||
/* 335 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.list = exports.nodes = void 0;
|
||
|
||
function t() {
|
||
const data = _interopRequireWildcard(__webpack_require__(3));
|
||
|
||
t = function () {
|
||
return data;
|
||
};
|
||
|
||
return data;
|
||
}
|
||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||
|
||
function crawl(node, state = {}) {
|
||
if (t().isMemberExpression(node)) {
|
||
crawl(node.object, state);
|
||
if (node.computed) crawl(node.property, state);
|
||
} else if (t().isBinary(node) || t().isAssignmentExpression(node)) {
|
||
crawl(node.left, state);
|
||
crawl(node.right, state);
|
||
} else if (t().isCallExpression(node)) {
|
||
state.hasCall = true;
|
||
crawl(node.callee, state);
|
||
} else if (t().isFunction(node)) {
|
||
state.hasFunction = true;
|
||
} else if (t().isIdentifier(node)) {
|
||
state.hasHelper = state.hasHelper || isHelper(node.callee);
|
||
}
|
||
|
||
return state;
|
||
}
|
||
|
||
function isHelper(node) {
|
||
if (t().isMemberExpression(node)) {
|
||
return isHelper(node.object) || isHelper(node.property);
|
||
} else if (t().isIdentifier(node)) {
|
||
return node.name === "require" || node.name[0] === "_";
|
||
} else if (t().isCallExpression(node)) {
|
||
return isHelper(node.callee);
|
||
} else if (t().isBinary(node) || t().isAssignmentExpression(node)) {
|
||
return t().isIdentifier(node.left) && isHelper(node.left) || isHelper(node.right);
|
||
} else {
|
||
return false;
|
||
}
|
||
}
|
||
|
||
function isType(node) {
|
||
return t().isLiteral(node) || t().isObjectExpression(node) || t().isArrayExpression(node) || t().isIdentifier(node) || t().isMemberExpression(node);
|
||
}
|
||
|
||
const nodes = {
|
||
AssignmentExpression(node) {
|
||
const state = crawl(node.right);
|
||
|
||
if (state.hasCall && state.hasHelper || state.hasFunction) {
|
||
return {
|
||
before: state.hasFunction,
|
||
after: true
|
||
};
|
||
}
|
||
},
|
||
|
||
SwitchCase(node, parent) {
|
||
return {
|
||
before: node.consequent.length || parent.cases[0] === node,
|
||
after: !node.consequent.length && parent.cases[parent.cases.length - 1] === node
|
||
};
|
||
},
|
||
|
||
LogicalExpression(node) {
|
||
if (t().isFunction(node.left) || t().isFunction(node.right)) {
|
||
return {
|
||
after: true
|
||
};
|
||
}
|
||
},
|
||
|
||
Literal(node) {
|
||
if (node.value === "use strict") {
|
||
return {
|
||
after: true
|
||
};
|
||
}
|
||
},
|
||
|
||
CallExpression(node) {
|
||
if (t().isFunction(node.callee) || isHelper(node)) {
|
||
return {
|
||
before: true,
|
||
after: true
|
||
};
|
||
}
|
||
},
|
||
|
||
VariableDeclaration(node) {
|
||
for (let i = 0; i < node.declarations.length; i++) {
|
||
const declar = node.declarations[i];
|
||
let enabled = isHelper(declar.id) && !isType(declar.init);
|
||
|
||
if (!enabled) {
|
||
const state = crawl(declar.init);
|
||
enabled = isHelper(declar.init) && state.hasCall || state.hasFunction;
|
||
}
|
||
|
||
if (enabled) {
|
||
return {
|
||
before: true,
|
||
after: true
|
||
};
|
||
}
|
||
}
|
||
},
|
||
|
||
IfStatement(node) {
|
||
if (t().isBlockStatement(node.consequent)) {
|
||
return {
|
||
before: true,
|
||
after: true
|
||
};
|
||
}
|
||
}
|
||
|
||
};
|
||
exports.nodes = nodes;
|
||
|
||
nodes.ObjectProperty = nodes.ObjectTypeProperty = nodes.ObjectMethod = function (node, parent) {
|
||
if (parent.properties[0] === node) {
|
||
return {
|
||
before: true
|
||
};
|
||
}
|
||
};
|
||
|
||
nodes.ObjectTypeCallProperty = function (node, parent) {
|
||
if (parent.callProperties[0] === node && (!parent.properties || !parent.properties.length)) {
|
||
return {
|
||
before: true
|
||
};
|
||
}
|
||
};
|
||
|
||
nodes.ObjectTypeIndexer = function (node, parent) {
|
||
if (parent.indexers[0] === node && (!parent.properties || !parent.properties.length) && (!parent.callProperties || !parent.callProperties.length)) {
|
||
return {
|
||
before: true
|
||
};
|
||
}
|
||
};
|
||
|
||
nodes.ObjectTypeInternalSlot = function (node, parent) {
|
||
if (parent.internalSlots[0] === node && (!parent.properties || !parent.properties.length) && (!parent.callProperties || !parent.callProperties.length) && (!parent.indexers || !parent.indexers.length)) {
|
||
return {
|
||
before: true
|
||
};
|
||
}
|
||
};
|
||
|
||
const list = {
|
||
VariableDeclaration(node) {
|
||
return node.declarations.map(decl => decl.init);
|
||
},
|
||
|
||
ArrayExpression(node) {
|
||
return node.elements;
|
||
},
|
||
|
||
ObjectExpression(node) {
|
||
return node.properties;
|
||
}
|
||
|
||
};
|
||
exports.list = list;
|
||
[["Function", true], ["Class", true], ["Loop", true], ["LabeledStatement", true], ["SwitchStatement", true], ["TryStatement", true]].forEach(function ([type, amounts]) {
|
||
if (typeof amounts === "boolean") {
|
||
amounts = {
|
||
after: amounts,
|
||
before: amounts
|
||
};
|
||
}
|
||
|
||
[type].concat(t().FLIPPED_ALIAS_KEYS[type] || []).forEach(function (type) {
|
||
nodes[type] = function () {
|
||
return amounts;
|
||
};
|
||
});
|
||
});
|
||
|
||
/***/ }),
|
||
/* 336 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.NullableTypeAnnotation = NullableTypeAnnotation;
|
||
exports.FunctionTypeAnnotation = FunctionTypeAnnotation;
|
||
exports.UpdateExpression = UpdateExpression;
|
||
exports.ObjectExpression = ObjectExpression;
|
||
exports.DoExpression = DoExpression;
|
||
exports.Binary = Binary;
|
||
exports.IntersectionTypeAnnotation = exports.UnionTypeAnnotation = UnionTypeAnnotation;
|
||
exports.TSAsExpression = TSAsExpression;
|
||
exports.TSTypeAssertion = TSTypeAssertion;
|
||
exports.TSIntersectionType = exports.TSUnionType = TSUnionType;
|
||
exports.BinaryExpression = BinaryExpression;
|
||
exports.SequenceExpression = SequenceExpression;
|
||
exports.AwaitExpression = exports.YieldExpression = YieldExpression;
|
||
exports.ClassExpression = ClassExpression;
|
||
exports.UnaryLike = UnaryLike;
|
||
exports.FunctionExpression = FunctionExpression;
|
||
exports.ArrowFunctionExpression = ArrowFunctionExpression;
|
||
exports.ConditionalExpression = ConditionalExpression;
|
||
exports.OptionalMemberExpression = OptionalMemberExpression;
|
||
exports.AssignmentExpression = AssignmentExpression;
|
||
exports.NewExpression = NewExpression;
|
||
|
||
function t() {
|
||
const data = _interopRequireWildcard(__webpack_require__(3));
|
||
|
||
t = function () {
|
||
return data;
|
||
};
|
||
|
||
return data;
|
||
}
|
||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||
|
||
const PRECEDENCE = {
|
||
"||": 0,
|
||
"&&": 1,
|
||
"|": 2,
|
||
"^": 3,
|
||
"&": 4,
|
||
"==": 5,
|
||
"===": 5,
|
||
"!=": 5,
|
||
"!==": 5,
|
||
"<": 6,
|
||
">": 6,
|
||
"<=": 6,
|
||
">=": 6,
|
||
in: 6,
|
||
instanceof: 6,
|
||
">>": 7,
|
||
"<<": 7,
|
||
">>>": 7,
|
||
"+": 8,
|
||
"-": 8,
|
||
"*": 9,
|
||
"/": 9,
|
||
"%": 9,
|
||
"**": 10
|
||
};
|
||
|
||
const isClassExtendsClause = (node, parent) => (t().isClassDeclaration(parent) || t().isClassExpression(parent)) && parent.superClass === node;
|
||
|
||
function NullableTypeAnnotation(node, parent) {
|
||
return t().isArrayTypeAnnotation(parent);
|
||
}
|
||
|
||
function FunctionTypeAnnotation(node, parent) {
|
||
return t().isUnionTypeAnnotation(parent) || t().isIntersectionTypeAnnotation(parent) || t().isArrayTypeAnnotation(parent);
|
||
}
|
||
|
||
function UpdateExpression(node, parent) {
|
||
return t().isMemberExpression(parent, {
|
||
object: node
|
||
}) || t().isCallExpression(parent, {
|
||
callee: node
|
||
}) || t().isNewExpression(parent, {
|
||
callee: node
|
||
}) || isClassExtendsClause(node, parent);
|
||
}
|
||
|
||
function ObjectExpression(node, parent, printStack) {
|
||
return isFirstInStatement(printStack, {
|
||
considerArrow: true
|
||
});
|
||
}
|
||
|
||
function DoExpression(node, parent, printStack) {
|
||
return isFirstInStatement(printStack);
|
||
}
|
||
|
||
function Binary(node, parent) {
|
||
if (node.operator === "**" && t().isBinaryExpression(parent, {
|
||
operator: "**"
|
||
})) {
|
||
return parent.left === node;
|
||
}
|
||
|
||
if (isClassExtendsClause(node, parent)) {
|
||
return true;
|
||
}
|
||
|
||
if ((t().isCallExpression(parent) || t().isNewExpression(parent)) && parent.callee === node || t().isUnaryLike(parent) || t().isMemberExpression(parent) && parent.object === node || t().isAwaitExpression(parent)) {
|
||
return true;
|
||
}
|
||
|
||
if (t().isBinary(parent)) {
|
||
const parentOp = parent.operator;
|
||
const parentPos = PRECEDENCE[parentOp];
|
||
const nodeOp = node.operator;
|
||
const nodePos = PRECEDENCE[nodeOp];
|
||
|
||
if (parentPos === nodePos && parent.right === node && !t().isLogicalExpression(parent) || parentPos > nodePos) {
|
||
return true;
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function UnionTypeAnnotation(node, parent) {
|
||
return t().isArrayTypeAnnotation(parent) || t().isNullableTypeAnnotation(parent) || t().isIntersectionTypeAnnotation(parent) || t().isUnionTypeAnnotation(parent);
|
||
}
|
||
|
||
function TSAsExpression() {
|
||
return true;
|
||
}
|
||
|
||
function TSTypeAssertion() {
|
||
return true;
|
||
}
|
||
|
||
function TSUnionType(node, parent) {
|
||
return t().isTSArrayType(parent) || t().isTSOptionalType(parent) || t().isTSIntersectionType(parent) || t().isTSUnionType(parent) || t().isTSRestType(parent);
|
||
}
|
||
|
||
function BinaryExpression(node, parent) {
|
||
return node.operator === "in" && (t().isVariableDeclarator(parent) || t().isFor(parent));
|
||
}
|
||
|
||
function SequenceExpression(node, parent) {
|
||
if (t().isForStatement(parent) || t().isThrowStatement(parent) || t().isReturnStatement(parent) || t().isIfStatement(parent) && parent.test === node || t().isWhileStatement(parent) && parent.test === node || t().isForInStatement(parent) && parent.right === node || t().isSwitchStatement(parent) && parent.discriminant === node || t().isExpressionStatement(parent) && parent.expression === node) {
|
||
return false;
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
function YieldExpression(node, parent) {
|
||
return t().isBinary(parent) || t().isUnaryLike(parent) || t().isCallExpression(parent) || t().isMemberExpression(parent) || t().isNewExpression(parent) || t().isAwaitExpression(parent) && t().isYieldExpression(node) || t().isConditionalExpression(parent) && node === parent.test || isClassExtendsClause(node, parent);
|
||
}
|
||
|
||
function ClassExpression(node, parent, printStack) {
|
||
return isFirstInStatement(printStack, {
|
||
considerDefaultExports: true
|
||
});
|
||
}
|
||
|
||
function UnaryLike(node, parent) {
|
||
return t().isMemberExpression(parent, {
|
||
object: node
|
||
}) || t().isCallExpression(parent, {
|
||
callee: node
|
||
}) || t().isNewExpression(parent, {
|
||
callee: node
|
||
}) || t().isBinaryExpression(parent, {
|
||
operator: "**",
|
||
left: node
|
||
}) || isClassExtendsClause(node, parent);
|
||
}
|
||
|
||
function FunctionExpression(node, parent, printStack) {
|
||
return isFirstInStatement(printStack, {
|
||
considerDefaultExports: true
|
||
});
|
||
}
|
||
|
||
function ArrowFunctionExpression(node, parent) {
|
||
return t().isExportDeclaration(parent) || ConditionalExpression(node, parent);
|
||
}
|
||
|
||
function ConditionalExpression(node, parent) {
|
||
if (t().isUnaryLike(parent) || t().isBinary(parent) || t().isConditionalExpression(parent, {
|
||
test: node
|
||
}) || t().isAwaitExpression(parent) || t().isOptionalMemberExpression(parent) || t().isTaggedTemplateExpression(parent) || t().isTSTypeAssertion(parent) || t().isTSAsExpression(parent)) {
|
||
return true;
|
||
}
|
||
|
||
return UnaryLike(node, parent);
|
||
}
|
||
|
||
function OptionalMemberExpression(node, parent) {
|
||
return t().isCallExpression(parent) || t().isMemberExpression(parent);
|
||
}
|
||
|
||
function AssignmentExpression(node) {
|
||
if (t().isObjectPattern(node.left)) {
|
||
return true;
|
||
} else {
|
||
return ConditionalExpression(...arguments);
|
||
}
|
||
}
|
||
|
||
function NewExpression(node, parent) {
|
||
return isClassExtendsClause(node, parent);
|
||
}
|
||
|
||
function isFirstInStatement(printStack, {
|
||
considerArrow = false,
|
||
considerDefaultExports = false
|
||
} = {}) {
|
||
let i = printStack.length - 1;
|
||
let node = printStack[i];
|
||
i--;
|
||
let parent = printStack[i];
|
||
|
||
while (i > 0) {
|
||
if (t().isExpressionStatement(parent, {
|
||
expression: node
|
||
}) || t().isTaggedTemplateExpression(parent) || considerDefaultExports && t().isExportDefaultDeclaration(parent, {
|
||
declaration: node
|
||
}) || considerArrow && t().isArrowFunctionExpression(parent, {
|
||
body: node
|
||
})) {
|
||
return true;
|
||
}
|
||
|
||
if (t().isCallExpression(parent, {
|
||
callee: node
|
||
}) || t().isSequenceExpression(parent) && parent.expressions[0] === node || t().isMemberExpression(parent, {
|
||
object: node
|
||
}) || t().isConditional(parent, {
|
||
test: node
|
||
}) || t().isBinary(parent, {
|
||
left: node
|
||
}) || t().isAssignmentExpression(parent, {
|
||
left: node
|
||
})) {
|
||
node = parent;
|
||
i--;
|
||
parent = printStack[i];
|
||
} else {
|
||
return false;
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 337 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
|
||
var _templateLiterals = __webpack_require__(338);
|
||
|
||
Object.keys(_templateLiterals).forEach(function (key) {
|
||
if (key === "default" || key === "__esModule") return;
|
||
Object.defineProperty(exports, key, {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _templateLiterals[key];
|
||
}
|
||
});
|
||
});
|
||
|
||
var _expressions = __webpack_require__(339);
|
||
|
||
Object.keys(_expressions).forEach(function (key) {
|
||
if (key === "default" || key === "__esModule") return;
|
||
Object.defineProperty(exports, key, {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _expressions[key];
|
||
}
|
||
});
|
||
});
|
||
|
||
var _statements = __webpack_require__(340);
|
||
|
||
Object.keys(_statements).forEach(function (key) {
|
||
if (key === "default" || key === "__esModule") return;
|
||
Object.defineProperty(exports, key, {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _statements[key];
|
||
}
|
||
});
|
||
});
|
||
|
||
var _classes = __webpack_require__(341);
|
||
|
||
Object.keys(_classes).forEach(function (key) {
|
||
if (key === "default" || key === "__esModule") return;
|
||
Object.defineProperty(exports, key, {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _classes[key];
|
||
}
|
||
});
|
||
});
|
||
|
||
var _methods = __webpack_require__(342);
|
||
|
||
Object.keys(_methods).forEach(function (key) {
|
||
if (key === "default" || key === "__esModule") return;
|
||
Object.defineProperty(exports, key, {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _methods[key];
|
||
}
|
||
});
|
||
});
|
||
|
||
var _modules = __webpack_require__(157);
|
||
|
||
Object.keys(_modules).forEach(function (key) {
|
||
if (key === "default" || key === "__esModule") return;
|
||
Object.defineProperty(exports, key, {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _modules[key];
|
||
}
|
||
});
|
||
});
|
||
|
||
var _types = __webpack_require__(97);
|
||
|
||
Object.keys(_types).forEach(function (key) {
|
||
if (key === "default" || key === "__esModule") return;
|
||
Object.defineProperty(exports, key, {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _types[key];
|
||
}
|
||
});
|
||
});
|
||
|
||
var _flow = __webpack_require__(344);
|
||
|
||
Object.keys(_flow).forEach(function (key) {
|
||
if (key === "default" || key === "__esModule") return;
|
||
Object.defineProperty(exports, key, {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _flow[key];
|
||
}
|
||
});
|
||
});
|
||
|
||
var _base = __webpack_require__(345);
|
||
|
||
Object.keys(_base).forEach(function (key) {
|
||
if (key === "default" || key === "__esModule") return;
|
||
Object.defineProperty(exports, key, {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _base[key];
|
||
}
|
||
});
|
||
});
|
||
|
||
var _jsx = __webpack_require__(346);
|
||
|
||
Object.keys(_jsx).forEach(function (key) {
|
||
if (key === "default" || key === "__esModule") return;
|
||
Object.defineProperty(exports, key, {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _jsx[key];
|
||
}
|
||
});
|
||
});
|
||
|
||
var _typescript = __webpack_require__(347);
|
||
|
||
Object.keys(_typescript).forEach(function (key) {
|
||
if (key === "default" || key === "__esModule") return;
|
||
Object.defineProperty(exports, key, {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _typescript[key];
|
||
}
|
||
});
|
||
});
|
||
|
||
/***/ }),
|
||
/* 338 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.TaggedTemplateExpression = TaggedTemplateExpression;
|
||
exports.TemplateElement = TemplateElement;
|
||
exports.TemplateLiteral = TemplateLiteral;
|
||
|
||
function TaggedTemplateExpression(node) {
|
||
this.print(node.tag, node);
|
||
this.print(node.typeParameters, node);
|
||
this.print(node.quasi, node);
|
||
}
|
||
|
||
function TemplateElement(node, parent) {
|
||
const isFirst = parent.quasis[0] === node;
|
||
const isLast = parent.quasis[parent.quasis.length - 1] === node;
|
||
const value = (isFirst ? "`" : "}") + node.value.raw + (isLast ? "`" : "${");
|
||
this.token(value);
|
||
}
|
||
|
||
function TemplateLiteral(node) {
|
||
const quasis = node.quasis;
|
||
|
||
for (let i = 0; i < quasis.length; i++) {
|
||
this.print(quasis[i], node);
|
||
|
||
if (i + 1 < quasis.length) {
|
||
this.print(node.expressions[i], node);
|
||
}
|
||
}
|
||
}
|
||
|
||
/***/ }),
|
||
/* 339 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.UnaryExpression = UnaryExpression;
|
||
exports.DoExpression = DoExpression;
|
||
exports.ParenthesizedExpression = ParenthesizedExpression;
|
||
exports.UpdateExpression = UpdateExpression;
|
||
exports.ConditionalExpression = ConditionalExpression;
|
||
exports.NewExpression = NewExpression;
|
||
exports.SequenceExpression = SequenceExpression;
|
||
exports.ThisExpression = ThisExpression;
|
||
exports.Super = Super;
|
||
exports.Decorator = Decorator;
|
||
exports.OptionalMemberExpression = OptionalMemberExpression;
|
||
exports.OptionalCallExpression = OptionalCallExpression;
|
||
exports.CallExpression = CallExpression;
|
||
exports.Import = Import;
|
||
exports.EmptyStatement = EmptyStatement;
|
||
exports.ExpressionStatement = ExpressionStatement;
|
||
exports.AssignmentPattern = AssignmentPattern;
|
||
exports.LogicalExpression = exports.BinaryExpression = exports.AssignmentExpression = AssignmentExpression;
|
||
exports.BindExpression = BindExpression;
|
||
exports.MemberExpression = MemberExpression;
|
||
exports.MetaProperty = MetaProperty;
|
||
exports.PrivateName = PrivateName;
|
||
exports.AwaitExpression = exports.YieldExpression = void 0;
|
||
|
||
function t() {
|
||
const data = _interopRequireWildcard(__webpack_require__(3));
|
||
|
||
t = function () {
|
||
return data;
|
||
};
|
||
|
||
return data;
|
||
}
|
||
|
||
var n = _interopRequireWildcard(__webpack_require__(156));
|
||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||
|
||
function UnaryExpression(node) {
|
||
if (node.operator === "void" || node.operator === "delete" || node.operator === "typeof" || node.operator === "throw") {
|
||
this.word(node.operator);
|
||
this.space();
|
||
} else {
|
||
this.token(node.operator);
|
||
}
|
||
|
||
this.print(node.argument, node);
|
||
}
|
||
|
||
function DoExpression(node) {
|
||
this.word("do");
|
||
this.space();
|
||
this.print(node.body, node);
|
||
}
|
||
|
||
function ParenthesizedExpression(node) {
|
||
this.token("(");
|
||
this.print(node.expression, node);
|
||
this.token(")");
|
||
}
|
||
|
||
function UpdateExpression(node) {
|
||
if (node.prefix) {
|
||
this.token(node.operator);
|
||
this.print(node.argument, node);
|
||
} else {
|
||
this.startTerminatorless(true);
|
||
this.print(node.argument, node);
|
||
this.endTerminatorless();
|
||
this.token(node.operator);
|
||
}
|
||
}
|
||
|
||
function ConditionalExpression(node) {
|
||
this.print(node.test, node);
|
||
this.space();
|
||
this.token("?");
|
||
this.space();
|
||
this.print(node.consequent, node);
|
||
this.space();
|
||
this.token(":");
|
||
this.space();
|
||
this.print(node.alternate, node);
|
||
}
|
||
|
||
function NewExpression(node, parent) {
|
||
this.word("new");
|
||
this.space();
|
||
this.print(node.callee, node);
|
||
|
||
if (this.format.minified && node.arguments.length === 0 && !node.optional && !t().isCallExpression(parent, {
|
||
callee: node
|
||
}) && !t().isMemberExpression(parent) && !t().isNewExpression(parent)) {
|
||
return;
|
||
}
|
||
|
||
this.print(node.typeArguments, node);
|
||
this.print(node.typeParameters, node);
|
||
|
||
if (node.optional) {
|
||
this.token("?.");
|
||
}
|
||
|
||
this.token("(");
|
||
this.printList(node.arguments, node);
|
||
this.token(")");
|
||
}
|
||
|
||
function SequenceExpression(node) {
|
||
this.printList(node.expressions, node);
|
||
}
|
||
|
||
function ThisExpression() {
|
||
this.word("this");
|
||
}
|
||
|
||
function Super() {
|
||
this.word("super");
|
||
}
|
||
|
||
function Decorator(node) {
|
||
this.token("@");
|
||
this.print(node.expression, node);
|
||
this.newline();
|
||
}
|
||
|
||
function OptionalMemberExpression(node) {
|
||
this.print(node.object, node);
|
||
|
||
if (!node.computed && t().isMemberExpression(node.property)) {
|
||
throw new TypeError("Got a MemberExpression for MemberExpression property");
|
||
}
|
||
|
||
let computed = node.computed;
|
||
|
||
if (t().isLiteral(node.property) && typeof node.property.value === "number") {
|
||
computed = true;
|
||
}
|
||
|
||
if (node.optional) {
|
||
this.token("?.");
|
||
}
|
||
|
||
if (computed) {
|
||
this.token("[");
|
||
this.print(node.property, node);
|
||
this.token("]");
|
||
} else {
|
||
if (!node.optional) {
|
||
this.token(".");
|
||
}
|
||
|
||
this.print(node.property, node);
|
||
}
|
||
}
|
||
|
||
function OptionalCallExpression(node) {
|
||
this.print(node.callee, node);
|
||
this.print(node.typeArguments, node);
|
||
this.print(node.typeParameters, node);
|
||
|
||
if (node.optional) {
|
||
this.token("?.");
|
||
}
|
||
|
||
this.token("(");
|
||
this.printList(node.arguments, node);
|
||
this.token(")");
|
||
}
|
||
|
||
function CallExpression(node) {
|
||
this.print(node.callee, node);
|
||
this.print(node.typeArguments, node);
|
||
this.print(node.typeParameters, node);
|
||
this.token("(");
|
||
this.printList(node.arguments, node);
|
||
this.token(")");
|
||
}
|
||
|
||
function Import() {
|
||
this.word("import");
|
||
}
|
||
|
||
function buildYieldAwait(keyword) {
|
||
return function (node) {
|
||
this.word(keyword);
|
||
|
||
if (node.delegate) {
|
||
this.token("*");
|
||
}
|
||
|
||
if (node.argument) {
|
||
this.space();
|
||
const terminatorState = this.startTerminatorless();
|
||
this.print(node.argument, node);
|
||
this.endTerminatorless(terminatorState);
|
||
}
|
||
};
|
||
}
|
||
|
||
const YieldExpression = buildYieldAwait("yield");
|
||
exports.YieldExpression = YieldExpression;
|
||
const AwaitExpression = buildYieldAwait("await");
|
||
exports.AwaitExpression = AwaitExpression;
|
||
|
||
function EmptyStatement() {
|
||
this.semicolon(true);
|
||
}
|
||
|
||
function ExpressionStatement(node) {
|
||
this.print(node.expression, node);
|
||
this.semicolon();
|
||
}
|
||
|
||
function AssignmentPattern(node) {
|
||
this.print(node.left, node);
|
||
if (node.left.optional) this.token("?");
|
||
this.print(node.left.typeAnnotation, node);
|
||
this.space();
|
||
this.token("=");
|
||
this.space();
|
||
this.print(node.right, node);
|
||
}
|
||
|
||
function AssignmentExpression(node, parent) {
|
||
const parens = this.inForStatementInitCounter && node.operator === "in" && !n.needsParens(node, parent);
|
||
|
||
if (parens) {
|
||
this.token("(");
|
||
}
|
||
|
||
this.print(node.left, node);
|
||
this.space();
|
||
|
||
if (node.operator === "in" || node.operator === "instanceof") {
|
||
this.word(node.operator);
|
||
} else {
|
||
this.token(node.operator);
|
||
}
|
||
|
||
this.space();
|
||
this.print(node.right, node);
|
||
|
||
if (parens) {
|
||
this.token(")");
|
||
}
|
||
}
|
||
|
||
function BindExpression(node) {
|
||
this.print(node.object, node);
|
||
this.token("::");
|
||
this.print(node.callee, node);
|
||
}
|
||
|
||
function MemberExpression(node) {
|
||
this.print(node.object, node);
|
||
|
||
if (!node.computed && t().isMemberExpression(node.property)) {
|
||
throw new TypeError("Got a MemberExpression for MemberExpression property");
|
||
}
|
||
|
||
let computed = node.computed;
|
||
|
||
if (t().isLiteral(node.property) && typeof node.property.value === "number") {
|
||
computed = true;
|
||
}
|
||
|
||
if (computed) {
|
||
this.token("[");
|
||
this.print(node.property, node);
|
||
this.token("]");
|
||
} else {
|
||
this.token(".");
|
||
this.print(node.property, node);
|
||
}
|
||
}
|
||
|
||
function MetaProperty(node) {
|
||
this.print(node.meta, node);
|
||
this.token(".");
|
||
this.print(node.property, node);
|
||
}
|
||
|
||
function PrivateName(node) {
|
||
this.token("#");
|
||
this.print(node.id, node);
|
||
}
|
||
|
||
/***/ }),
|
||
/* 340 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.WithStatement = WithStatement;
|
||
exports.IfStatement = IfStatement;
|
||
exports.ForStatement = ForStatement;
|
||
exports.WhileStatement = WhileStatement;
|
||
exports.DoWhileStatement = DoWhileStatement;
|
||
exports.LabeledStatement = LabeledStatement;
|
||
exports.TryStatement = TryStatement;
|
||
exports.CatchClause = CatchClause;
|
||
exports.SwitchStatement = SwitchStatement;
|
||
exports.SwitchCase = SwitchCase;
|
||
exports.DebuggerStatement = DebuggerStatement;
|
||
exports.VariableDeclaration = VariableDeclaration;
|
||
exports.VariableDeclarator = VariableDeclarator;
|
||
exports.ThrowStatement = exports.BreakStatement = exports.ReturnStatement = exports.ContinueStatement = exports.ForOfStatement = exports.ForInStatement = void 0;
|
||
|
||
function t() {
|
||
const data = _interopRequireWildcard(__webpack_require__(3));
|
||
|
||
t = function () {
|
||
return data;
|
||
};
|
||
|
||
return data;
|
||
}
|
||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||
|
||
function WithStatement(node) {
|
||
this.word("with");
|
||
this.space();
|
||
this.token("(");
|
||
this.print(node.object, node);
|
||
this.token(")");
|
||
this.printBlock(node);
|
||
}
|
||
|
||
function IfStatement(node) {
|
||
this.word("if");
|
||
this.space();
|
||
this.token("(");
|
||
this.print(node.test, node);
|
||
this.token(")");
|
||
this.space();
|
||
const needsBlock = node.alternate && t().isIfStatement(getLastStatement(node.consequent));
|
||
|
||
if (needsBlock) {
|
||
this.token("{");
|
||
this.newline();
|
||
this.indent();
|
||
}
|
||
|
||
this.printAndIndentOnComments(node.consequent, node);
|
||
|
||
if (needsBlock) {
|
||
this.dedent();
|
||
this.newline();
|
||
this.token("}");
|
||
}
|
||
|
||
if (node.alternate) {
|
||
if (this.endsWith("}")) this.space();
|
||
this.word("else");
|
||
this.space();
|
||
this.printAndIndentOnComments(node.alternate, node);
|
||
}
|
||
}
|
||
|
||
function getLastStatement(statement) {
|
||
if (!t().isStatement(statement.body)) return statement;
|
||
return getLastStatement(statement.body);
|
||
}
|
||
|
||
function ForStatement(node) {
|
||
this.word("for");
|
||
this.space();
|
||
this.token("(");
|
||
this.inForStatementInitCounter++;
|
||
this.print(node.init, node);
|
||
this.inForStatementInitCounter--;
|
||
this.token(";");
|
||
|
||
if (node.test) {
|
||
this.space();
|
||
this.print(node.test, node);
|
||
}
|
||
|
||
this.token(";");
|
||
|
||
if (node.update) {
|
||
this.space();
|
||
this.print(node.update, node);
|
||
}
|
||
|
||
this.token(")");
|
||
this.printBlock(node);
|
||
}
|
||
|
||
function WhileStatement(node) {
|
||
this.word("while");
|
||
this.space();
|
||
this.token("(");
|
||
this.print(node.test, node);
|
||
this.token(")");
|
||
this.printBlock(node);
|
||
}
|
||
|
||
const buildForXStatement = function (op) {
|
||
return function (node) {
|
||
this.word("for");
|
||
this.space();
|
||
|
||
if (op === "of" && node.await) {
|
||
this.word("await");
|
||
this.space();
|
||
}
|
||
|
||
this.token("(");
|
||
this.print(node.left, node);
|
||
this.space();
|
||
this.word(op);
|
||
this.space();
|
||
this.print(node.right, node);
|
||
this.token(")");
|
||
this.printBlock(node);
|
||
};
|
||
};
|
||
|
||
const ForInStatement = buildForXStatement("in");
|
||
exports.ForInStatement = ForInStatement;
|
||
const ForOfStatement = buildForXStatement("of");
|
||
exports.ForOfStatement = ForOfStatement;
|
||
|
||
function DoWhileStatement(node) {
|
||
this.word("do");
|
||
this.space();
|
||
this.print(node.body, node);
|
||
this.space();
|
||
this.word("while");
|
||
this.space();
|
||
this.token("(");
|
||
this.print(node.test, node);
|
||
this.token(")");
|
||
this.semicolon();
|
||
}
|
||
|
||
function buildLabelStatement(prefix, key = "label") {
|
||
return function (node) {
|
||
this.word(prefix);
|
||
const label = node[key];
|
||
|
||
if (label) {
|
||
this.space();
|
||
const isLabel = key == "label";
|
||
const terminatorState = this.startTerminatorless(isLabel);
|
||
this.print(label, node);
|
||
this.endTerminatorless(terminatorState);
|
||
}
|
||
|
||
this.semicolon();
|
||
};
|
||
}
|
||
|
||
const ContinueStatement = buildLabelStatement("continue");
|
||
exports.ContinueStatement = ContinueStatement;
|
||
const ReturnStatement = buildLabelStatement("return", "argument");
|
||
exports.ReturnStatement = ReturnStatement;
|
||
const BreakStatement = buildLabelStatement("break");
|
||
exports.BreakStatement = BreakStatement;
|
||
const ThrowStatement = buildLabelStatement("throw", "argument");
|
||
exports.ThrowStatement = ThrowStatement;
|
||
|
||
function LabeledStatement(node) {
|
||
this.print(node.label, node);
|
||
this.token(":");
|
||
this.space();
|
||
this.print(node.body, node);
|
||
}
|
||
|
||
function TryStatement(node) {
|
||
this.word("try");
|
||
this.space();
|
||
this.print(node.block, node);
|
||
this.space();
|
||
|
||
if (node.handlers) {
|
||
this.print(node.handlers[0], node);
|
||
} else {
|
||
this.print(node.handler, node);
|
||
}
|
||
|
||
if (node.finalizer) {
|
||
this.space();
|
||
this.word("finally");
|
||
this.space();
|
||
this.print(node.finalizer, node);
|
||
}
|
||
}
|
||
|
||
function CatchClause(node) {
|
||
this.word("catch");
|
||
this.space();
|
||
|
||
if (node.param) {
|
||
this.token("(");
|
||
this.print(node.param, node);
|
||
this.token(")");
|
||
this.space();
|
||
}
|
||
|
||
this.print(node.body, node);
|
||
}
|
||
|
||
function SwitchStatement(node) {
|
||
this.word("switch");
|
||
this.space();
|
||
this.token("(");
|
||
this.print(node.discriminant, node);
|
||
this.token(")");
|
||
this.space();
|
||
this.token("{");
|
||
this.printSequence(node.cases, node, {
|
||
indent: true,
|
||
|
||
addNewlines(leading, cas) {
|
||
if (!leading && node.cases[node.cases.length - 1] === cas) return -1;
|
||
}
|
||
|
||
});
|
||
this.token("}");
|
||
}
|
||
|
||
function SwitchCase(node) {
|
||
if (node.test) {
|
||
this.word("case");
|
||
this.space();
|
||
this.print(node.test, node);
|
||
this.token(":");
|
||
} else {
|
||
this.word("default");
|
||
this.token(":");
|
||
}
|
||
|
||
if (node.consequent.length) {
|
||
this.newline();
|
||
this.printSequence(node.consequent, node, {
|
||
indent: true
|
||
});
|
||
}
|
||
}
|
||
|
||
function DebuggerStatement() {
|
||
this.word("debugger");
|
||
this.semicolon();
|
||
}
|
||
|
||
function variableDeclarationIndent() {
|
||
this.token(",");
|
||
this.newline();
|
||
if (this.endsWith("\n")) for (let i = 0; i < 4; i++) this.space(true);
|
||
}
|
||
|
||
function constDeclarationIndent() {
|
||
this.token(",");
|
||
this.newline();
|
||
if (this.endsWith("\n")) for (let i = 0; i < 6; i++) this.space(true);
|
||
}
|
||
|
||
function VariableDeclaration(node, parent) {
|
||
if (node.declare) {
|
||
this.word("declare");
|
||
this.space();
|
||
}
|
||
|
||
this.word(node.kind);
|
||
this.space();
|
||
let hasInits = false;
|
||
|
||
if (!t().isFor(parent)) {
|
||
for (const declar of node.declarations) {
|
||
if (declar.init) {
|
||
hasInits = true;
|
||
}
|
||
}
|
||
}
|
||
|
||
let separator;
|
||
|
||
if (hasInits) {
|
||
separator = node.kind === "const" ? constDeclarationIndent : variableDeclarationIndent;
|
||
}
|
||
|
||
this.printList(node.declarations, node, {
|
||
separator
|
||
});
|
||
|
||
if (t().isFor(parent)) {
|
||
if (parent.left === node || parent.init === node) return;
|
||
}
|
||
|
||
this.semicolon();
|
||
}
|
||
|
||
function VariableDeclarator(node) {
|
||
this.print(node.id, node);
|
||
if (node.definite) this.token("!");
|
||
this.print(node.id.typeAnnotation, node);
|
||
|
||
if (node.init) {
|
||
this.space();
|
||
this.token("=");
|
||
this.space();
|
||
this.print(node.init, node);
|
||
}
|
||
}
|
||
|
||
/***/ }),
|
||
/* 341 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.ClassExpression = exports.ClassDeclaration = ClassDeclaration;
|
||
exports.ClassBody = ClassBody;
|
||
exports.ClassProperty = ClassProperty;
|
||
exports.ClassPrivateProperty = ClassPrivateProperty;
|
||
exports.ClassMethod = ClassMethod;
|
||
exports.ClassPrivateMethod = ClassPrivateMethod;
|
||
exports._classMethodHead = _classMethodHead;
|
||
|
||
function t() {
|
||
const data = _interopRequireWildcard(__webpack_require__(3));
|
||
|
||
t = function () {
|
||
return data;
|
||
};
|
||
|
||
return data;
|
||
}
|
||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||
|
||
function ClassDeclaration(node, parent) {
|
||
if (!this.format.decoratorsBeforeExport || !t().isExportDefaultDeclaration(parent) && !t().isExportNamedDeclaration(parent)) {
|
||
this.printJoin(node.decorators, node);
|
||
}
|
||
|
||
if (node.declare) {
|
||
this.word("declare");
|
||
this.space();
|
||
}
|
||
|
||
if (node.abstract) {
|
||
this.word("abstract");
|
||
this.space();
|
||
}
|
||
|
||
this.word("class");
|
||
|
||
if (node.id) {
|
||
this.space();
|
||
this.print(node.id, node);
|
||
}
|
||
|
||
this.print(node.typeParameters, node);
|
||
|
||
if (node.superClass) {
|
||
this.space();
|
||
this.word("extends");
|
||
this.space();
|
||
this.print(node.superClass, node);
|
||
this.print(node.superTypeParameters, node);
|
||
}
|
||
|
||
if (node.implements) {
|
||
this.space();
|
||
this.word("implements");
|
||
this.space();
|
||
this.printList(node.implements, node);
|
||
}
|
||
|
||
this.space();
|
||
this.print(node.body, node);
|
||
}
|
||
|
||
function ClassBody(node) {
|
||
this.token("{");
|
||
this.printInnerComments(node);
|
||
|
||
if (node.body.length === 0) {
|
||
this.token("}");
|
||
} else {
|
||
this.newline();
|
||
this.indent();
|
||
this.printSequence(node.body, node);
|
||
this.dedent();
|
||
if (!this.endsWith("\n")) this.newline();
|
||
this.rightBrace();
|
||
}
|
||
}
|
||
|
||
function ClassProperty(node) {
|
||
this.printJoin(node.decorators, node);
|
||
|
||
if (node.accessibility) {
|
||
this.word(node.accessibility);
|
||
this.space();
|
||
}
|
||
|
||
if (node.static) {
|
||
this.word("static");
|
||
this.space();
|
||
}
|
||
|
||
if (node.abstract) {
|
||
this.word("abstract");
|
||
this.space();
|
||
}
|
||
|
||
if (node.readonly) {
|
||
this.word("readonly");
|
||
this.space();
|
||
}
|
||
|
||
if (node.computed) {
|
||
this.token("[");
|
||
this.print(node.key, node);
|
||
this.token("]");
|
||
} else {
|
||
this._variance(node);
|
||
|
||
this.print(node.key, node);
|
||
}
|
||
|
||
if (node.optional) {
|
||
this.token("?");
|
||
}
|
||
|
||
if (node.definite) {
|
||
this.token("!");
|
||
}
|
||
|
||
this.print(node.typeAnnotation, node);
|
||
|
||
if (node.value) {
|
||
this.space();
|
||
this.token("=");
|
||
this.space();
|
||
this.print(node.value, node);
|
||
}
|
||
|
||
this.semicolon();
|
||
}
|
||
|
||
function ClassPrivateProperty(node) {
|
||
if (node.static) {
|
||
this.word("static");
|
||
this.space();
|
||
}
|
||
|
||
this.print(node.key, node);
|
||
this.print(node.typeAnnotation, node);
|
||
|
||
if (node.value) {
|
||
this.space();
|
||
this.token("=");
|
||
this.space();
|
||
this.print(node.value, node);
|
||
}
|
||
|
||
this.semicolon();
|
||
}
|
||
|
||
function ClassMethod(node) {
|
||
this._classMethodHead(node);
|
||
|
||
this.space();
|
||
this.print(node.body, node);
|
||
}
|
||
|
||
function ClassPrivateMethod(node) {
|
||
this._classMethodHead(node);
|
||
|
||
this.space();
|
||
this.print(node.body, node);
|
||
}
|
||
|
||
function _classMethodHead(node) {
|
||
this.printJoin(node.decorators, node);
|
||
|
||
if (node.accessibility) {
|
||
this.word(node.accessibility);
|
||
this.space();
|
||
}
|
||
|
||
if (node.abstract) {
|
||
this.word("abstract");
|
||
this.space();
|
||
}
|
||
|
||
if (node.static) {
|
||
this.word("static");
|
||
this.space();
|
||
}
|
||
|
||
this._methodHead(node);
|
||
}
|
||
|
||
/***/ }),
|
||
/* 342 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports._params = _params;
|
||
exports._parameters = _parameters;
|
||
exports._param = _param;
|
||
exports._methodHead = _methodHead;
|
||
exports._predicate = _predicate;
|
||
exports._functionHead = _functionHead;
|
||
exports.FunctionDeclaration = exports.FunctionExpression = FunctionExpression;
|
||
exports.ArrowFunctionExpression = ArrowFunctionExpression;
|
||
|
||
function t() {
|
||
const data = _interopRequireWildcard(__webpack_require__(3));
|
||
|
||
t = function () {
|
||
return data;
|
||
};
|
||
|
||
return data;
|
||
}
|
||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||
|
||
function _params(node) {
|
||
this.print(node.typeParameters, node);
|
||
this.token("(");
|
||
|
||
this._parameters(node.params, node);
|
||
|
||
this.token(")");
|
||
this.print(node.returnType, node);
|
||
}
|
||
|
||
function _parameters(parameters, parent) {
|
||
for (let i = 0; i < parameters.length; i++) {
|
||
this._param(parameters[i], parent);
|
||
|
||
if (i < parameters.length - 1) {
|
||
this.token(",");
|
||
this.space();
|
||
}
|
||
}
|
||
}
|
||
|
||
function _param(parameter, parent) {
|
||
this.printJoin(parameter.decorators, parameter);
|
||
this.print(parameter, parent);
|
||
if (parameter.optional) this.token("?");
|
||
this.print(parameter.typeAnnotation, parameter);
|
||
}
|
||
|
||
function _methodHead(node) {
|
||
const kind = node.kind;
|
||
const key = node.key;
|
||
|
||
if (kind === "get" || kind === "set") {
|
||
this.word(kind);
|
||
this.space();
|
||
}
|
||
|
||
if (node.async) {
|
||
this.word("async");
|
||
this.space();
|
||
}
|
||
|
||
if (kind === "method" || kind === "init") {
|
||
if (node.generator) {
|
||
this.token("*");
|
||
}
|
||
}
|
||
|
||
if (node.computed) {
|
||
this.token("[");
|
||
this.print(key, node);
|
||
this.token("]");
|
||
} else {
|
||
this.print(key, node);
|
||
}
|
||
|
||
if (node.optional) {
|
||
this.token("?");
|
||
}
|
||
|
||
this._params(node);
|
||
}
|
||
|
||
function _predicate(node) {
|
||
if (node.predicate) {
|
||
if (!node.returnType) {
|
||
this.token(":");
|
||
}
|
||
|
||
this.space();
|
||
this.print(node.predicate, node);
|
||
}
|
||
}
|
||
|
||
function _functionHead(node) {
|
||
if (node.async) {
|
||
this.word("async");
|
||
this.space();
|
||
}
|
||
|
||
this.word("function");
|
||
if (node.generator) this.token("*");
|
||
this.space();
|
||
|
||
if (node.id) {
|
||
this.print(node.id, node);
|
||
}
|
||
|
||
this._params(node);
|
||
|
||
this._predicate(node);
|
||
}
|
||
|
||
function FunctionExpression(node) {
|
||
this._functionHead(node);
|
||
|
||
this.space();
|
||
this.print(node.body, node);
|
||
}
|
||
|
||
function ArrowFunctionExpression(node) {
|
||
if (node.async) {
|
||
this.word("async");
|
||
this.space();
|
||
}
|
||
|
||
const firstParam = node.params[0];
|
||
|
||
if (node.params.length === 1 && t().isIdentifier(firstParam) && !hasTypes(node, firstParam)) {
|
||
if (this.format.retainLines && node.loc && node.body.loc && node.loc.start.line < node.body.loc.start.line) {
|
||
this.token("(");
|
||
|
||
if (firstParam.loc && firstParam.loc.start.line > node.loc.start.line) {
|
||
this.indent();
|
||
this.print(firstParam, node);
|
||
this.dedent();
|
||
|
||
this._catchUp("start", node.body.loc);
|
||
} else {
|
||
this.print(firstParam, node);
|
||
}
|
||
|
||
this.token(")");
|
||
} else {
|
||
this.print(firstParam, node);
|
||
}
|
||
} else {
|
||
this._params(node);
|
||
}
|
||
|
||
this._predicate(node);
|
||
|
||
this.space();
|
||
this.token("=>");
|
||
this.space();
|
||
this.print(node.body, node);
|
||
}
|
||
|
||
function hasTypes(node, param) {
|
||
return node.typeParameters || node.returnType || param.typeAnnotation || param.optional || param.trailingComments;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 343 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
/* WEBPACK VAR INJECTION */(function(Buffer) {
|
||
|
||
const object = {};
|
||
const hasOwnProperty = object.hasOwnProperty;
|
||
const forOwn = (object, callback) => {
|
||
for (const key in object) {
|
||
if (hasOwnProperty.call(object, key)) {
|
||
callback(key, object[key]);
|
||
}
|
||
}
|
||
};
|
||
|
||
const extend = (destination, source) => {
|
||
if (!source) {
|
||
return destination;
|
||
}
|
||
forOwn(source, (key, value) => {
|
||
destination[key] = value;
|
||
});
|
||
return destination;
|
||
};
|
||
|
||
const forEach = (array, callback) => {
|
||
const length = array.length;
|
||
let index = -1;
|
||
while (++index < length) {
|
||
callback(array[index]);
|
||
}
|
||
};
|
||
|
||
const toString = object.toString;
|
||
const isArray = Array.isArray;
|
||
const isBuffer = Buffer.isBuffer;
|
||
const isObject = (value) => {
|
||
// This is a very simple check, but it’s good enough for what we need.
|
||
return toString.call(value) == '[object Object]';
|
||
};
|
||
const isString = (value) => {
|
||
return typeof value == 'string' ||
|
||
toString.call(value) == '[object String]';
|
||
};
|
||
const isNumber = (value) => {
|
||
return typeof value == 'number' ||
|
||
toString.call(value) == '[object Number]';
|
||
};
|
||
const isFunction = (value) => {
|
||
return typeof value == 'function';
|
||
};
|
||
const isMap = (value) => {
|
||
return toString.call(value) == '[object Map]';
|
||
};
|
||
const isSet = (value) => {
|
||
return toString.call(value) == '[object Set]';
|
||
};
|
||
|
||
/*--------------------------------------------------------------------------*/
|
||
|
||
// https://mathiasbynens.be/notes/javascript-escapes#single
|
||
const singleEscapes = {
|
||
'"': '\\"',
|
||
'\'': '\\\'',
|
||
'\\': '\\\\',
|
||
'\b': '\\b',
|
||
'\f': '\\f',
|
||
'\n': '\\n',
|
||
'\r': '\\r',
|
||
'\t': '\\t'
|
||
// `\v` is omitted intentionally, because in IE < 9, '\v' == 'v'.
|
||
// '\v': '\\x0B'
|
||
};
|
||
const regexSingleEscape = /["'\\\b\f\n\r\t]/;
|
||
|
||
const regexDigit = /[0-9]/;
|
||
const regexWhitelist = /[ !#-&\(-\[\]-~]/;
|
||
|
||
const jsesc = (argument, options) => {
|
||
const increaseIndentation = () => {
|
||
oldIndent = indent;
|
||
++options.indentLevel;
|
||
indent = options.indent.repeat(options.indentLevel)
|
||
};
|
||
// Handle options
|
||
const defaults = {
|
||
'escapeEverything': false,
|
||
'minimal': false,
|
||
'isScriptContext': false,
|
||
'quotes': 'single',
|
||
'wrap': false,
|
||
'es6': false,
|
||
'json': false,
|
||
'compact': true,
|
||
'lowercaseHex': false,
|
||
'numbers': 'decimal',
|
||
'indent': '\t',
|
||
'indentLevel': 0,
|
||
'__inline1__': false,
|
||
'__inline2__': false
|
||
};
|
||
const json = options && options.json;
|
||
if (json) {
|
||
defaults.quotes = 'double';
|
||
defaults.wrap = true;
|
||
}
|
||
options = extend(defaults, options);
|
||
if (
|
||
options.quotes != 'single' &&
|
||
options.quotes != 'double' &&
|
||
options.quotes != 'backtick'
|
||
) {
|
||
options.quotes = 'single';
|
||
}
|
||
const quote = options.quotes == 'double' ?
|
||
'"' :
|
||
(options.quotes == 'backtick' ?
|
||
'`' :
|
||
'\''
|
||
);
|
||
const compact = options.compact;
|
||
const lowercaseHex = options.lowercaseHex;
|
||
let indent = options.indent.repeat(options.indentLevel);
|
||
let oldIndent = '';
|
||
const inline1 = options.__inline1__;
|
||
const inline2 = options.__inline2__;
|
||
const newLine = compact ? '' : '\n';
|
||
let result;
|
||
let isEmpty = true;
|
||
const useBinNumbers = options.numbers == 'binary';
|
||
const useOctNumbers = options.numbers == 'octal';
|
||
const useDecNumbers = options.numbers == 'decimal';
|
||
const useHexNumbers = options.numbers == 'hexadecimal';
|
||
|
||
if (json && argument && isFunction(argument.toJSON)) {
|
||
argument = argument.toJSON();
|
||
}
|
||
|
||
if (!isString(argument)) {
|
||
if (isMap(argument)) {
|
||
if (argument.size == 0) {
|
||
return 'new Map()';
|
||
}
|
||
if (!compact) {
|
||
options.__inline1__ = true;
|
||
options.__inline2__ = false;
|
||
}
|
||
return 'new Map(' + jsesc(Array.from(argument), options) + ')';
|
||
}
|
||
if (isSet(argument)) {
|
||
if (argument.size == 0) {
|
||
return 'new Set()';
|
||
}
|
||
return 'new Set(' + jsesc(Array.from(argument), options) + ')';
|
||
}
|
||
if (isBuffer(argument)) {
|
||
if (argument.length == 0) {
|
||
return 'Buffer.from([])';
|
||
}
|
||
return 'Buffer.from(' + jsesc(Array.from(argument), options) + ')';
|
||
}
|
||
if (isArray(argument)) {
|
||
result = [];
|
||
options.wrap = true;
|
||
if (inline1) {
|
||
options.__inline1__ = false;
|
||
options.__inline2__ = true;
|
||
}
|
||
if (!inline2) {
|
||
increaseIndentation();
|
||
}
|
||
forEach(argument, (value) => {
|
||
isEmpty = false;
|
||
if (inline2) {
|
||
options.__inline2__ = false;
|
||
}
|
||
result.push(
|
||
(compact || inline2 ? '' : indent) +
|
||
jsesc(value, options)
|
||
);
|
||
});
|
||
if (isEmpty) {
|
||
return '[]';
|
||
}
|
||
if (inline2) {
|
||
return '[' + result.join(', ') + ']';
|
||
}
|
||
return '[' + newLine + result.join(',' + newLine) + newLine +
|
||
(compact ? '' : oldIndent) + ']';
|
||
} else if (isNumber(argument)) {
|
||
if (json) {
|
||
// Some number values (e.g. `Infinity`) cannot be represented in JSON.
|
||
return JSON.stringify(argument);
|
||
}
|
||
if (useDecNumbers) {
|
||
return String(argument);
|
||
}
|
||
if (useHexNumbers) {
|
||
let hexadecimal = argument.toString(16);
|
||
if (!lowercaseHex) {
|
||
hexadecimal = hexadecimal.toUpperCase();
|
||
}
|
||
return '0x' + hexadecimal;
|
||
}
|
||
if (useBinNumbers) {
|
||
return '0b' + argument.toString(2);
|
||
}
|
||
if (useOctNumbers) {
|
||
return '0o' + argument.toString(8);
|
||
}
|
||
} else if (!isObject(argument)) {
|
||
if (json) {
|
||
// For some values (e.g. `undefined`, `function` objects),
|
||
// `JSON.stringify(value)` returns `undefined` (which isn’t valid
|
||
// JSON) instead of `'null'`.
|
||
return JSON.stringify(argument) || 'null';
|
||
}
|
||
return String(argument);
|
||
} else { // it’s an object
|
||
result = [];
|
||
options.wrap = true;
|
||
increaseIndentation();
|
||
forOwn(argument, (key, value) => {
|
||
isEmpty = false;
|
||
result.push(
|
||
(compact ? '' : indent) +
|
||
jsesc(key, options) + ':' +
|
||
(compact ? '' : ' ') +
|
||
jsesc(value, options)
|
||
);
|
||
});
|
||
if (isEmpty) {
|
||
return '{}';
|
||
}
|
||
return '{' + newLine + result.join(',' + newLine) + newLine +
|
||
(compact ? '' : oldIndent) + '}';
|
||
}
|
||
}
|
||
|
||
const string = argument;
|
||
// Loop over each code unit in the string and escape it
|
||
let index = -1;
|
||
const length = string.length;
|
||
result = '';
|
||
while (++index < length) {
|
||
const character = string.charAt(index);
|
||
if (options.es6) {
|
||
const first = string.charCodeAt(index);
|
||
if ( // check if it’s the start of a surrogate pair
|
||
first >= 0xD800 && first <= 0xDBFF && // high surrogate
|
||
length > index + 1 // there is a next code unit
|
||
) {
|
||
const second = string.charCodeAt(index + 1);
|
||
if (second >= 0xDC00 && second <= 0xDFFF) { // low surrogate
|
||
// https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
|
||
const codePoint = (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
|
||
let hexadecimal = codePoint.toString(16);
|
||
if (!lowercaseHex) {
|
||
hexadecimal = hexadecimal.toUpperCase();
|
||
}
|
||
result += '\\u{' + hexadecimal + '}';
|
||
++index;
|
||
continue;
|
||
}
|
||
}
|
||
}
|
||
if (!options.escapeEverything) {
|
||
if (regexWhitelist.test(character)) {
|
||
// It’s a printable ASCII character that is not `"`, `'` or `\`,
|
||
// so don’t escape it.
|
||
result += character;
|
||
continue;
|
||
}
|
||
if (character == '"') {
|
||
result += quote == character ? '\\"' : character;
|
||
continue;
|
||
}
|
||
if (character == '`') {
|
||
result += quote == character ? '\\`' : character;
|
||
continue;
|
||
}
|
||
if (character == '\'') {
|
||
result += quote == character ? '\\\'' : character;
|
||
continue;
|
||
}
|
||
}
|
||
if (
|
||
character == '\0' &&
|
||
!json &&
|
||
!regexDigit.test(string.charAt(index + 1))
|
||
) {
|
||
result += '\\0';
|
||
continue;
|
||
}
|
||
if (regexSingleEscape.test(character)) {
|
||
// no need for a `hasOwnProperty` check here
|
||
result += singleEscapes[character];
|
||
continue;
|
||
}
|
||
const charCode = character.charCodeAt(0);
|
||
if (options.minimal && charCode != 0x2028 && charCode != 0x2029) {
|
||
result += character;
|
||
continue;
|
||
}
|
||
let hexadecimal = charCode.toString(16);
|
||
if (!lowercaseHex) {
|
||
hexadecimal = hexadecimal.toUpperCase();
|
||
}
|
||
const longhand = hexadecimal.length > 2 || json;
|
||
const escaped = '\\' + (longhand ? 'u' : 'x') +
|
||
('0000' + hexadecimal).slice(longhand ? -4 : -2);
|
||
result += escaped;
|
||
continue;
|
||
}
|
||
if (options.wrap) {
|
||
result = quote + result + quote;
|
||
}
|
||
if (quote == '`') {
|
||
result = result.replace(/\$\{/g, '\\\$\{');
|
||
}
|
||
if (options.isScriptContext) {
|
||
// https://mathiasbynens.be/notes/etago
|
||
return result
|
||
.replace(/<\/(script|style)/gi, '<\\/$1')
|
||
.replace(/<!--/g, json ? '\\u003C!--' : '\\x3C!--');
|
||
}
|
||
return result;
|
||
};
|
||
|
||
jsesc.version = '2.5.1';
|
||
|
||
module.exports = jsesc;
|
||
|
||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(58).Buffer))
|
||
|
||
/***/ }),
|
||
/* 344 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.AnyTypeAnnotation = AnyTypeAnnotation;
|
||
exports.ArrayTypeAnnotation = ArrayTypeAnnotation;
|
||
exports.BooleanTypeAnnotation = BooleanTypeAnnotation;
|
||
exports.BooleanLiteralTypeAnnotation = BooleanLiteralTypeAnnotation;
|
||
exports.NullLiteralTypeAnnotation = NullLiteralTypeAnnotation;
|
||
exports.DeclareClass = DeclareClass;
|
||
exports.DeclareFunction = DeclareFunction;
|
||
exports.InferredPredicate = InferredPredicate;
|
||
exports.DeclaredPredicate = DeclaredPredicate;
|
||
exports.DeclareInterface = DeclareInterface;
|
||
exports.DeclareModule = DeclareModule;
|
||
exports.DeclareModuleExports = DeclareModuleExports;
|
||
exports.DeclareTypeAlias = DeclareTypeAlias;
|
||
exports.DeclareOpaqueType = DeclareOpaqueType;
|
||
exports.DeclareVariable = DeclareVariable;
|
||
exports.DeclareExportDeclaration = DeclareExportDeclaration;
|
||
exports.DeclareExportAllDeclaration = DeclareExportAllDeclaration;
|
||
exports.ExistsTypeAnnotation = ExistsTypeAnnotation;
|
||
exports.FunctionTypeAnnotation = FunctionTypeAnnotation;
|
||
exports.FunctionTypeParam = FunctionTypeParam;
|
||
exports.GenericTypeAnnotation = exports.ClassImplements = exports.InterfaceExtends = InterfaceExtends;
|
||
exports._interfaceish = _interfaceish;
|
||
exports._variance = _variance;
|
||
exports.InterfaceDeclaration = InterfaceDeclaration;
|
||
exports.InterfaceTypeAnnotation = InterfaceTypeAnnotation;
|
||
exports.IntersectionTypeAnnotation = IntersectionTypeAnnotation;
|
||
exports.MixedTypeAnnotation = MixedTypeAnnotation;
|
||
exports.EmptyTypeAnnotation = EmptyTypeAnnotation;
|
||
exports.NullableTypeAnnotation = NullableTypeAnnotation;
|
||
exports.NumberTypeAnnotation = NumberTypeAnnotation;
|
||
exports.StringTypeAnnotation = StringTypeAnnotation;
|
||
exports.ThisTypeAnnotation = ThisTypeAnnotation;
|
||
exports.TupleTypeAnnotation = TupleTypeAnnotation;
|
||
exports.TypeofTypeAnnotation = TypeofTypeAnnotation;
|
||
exports.TypeAlias = TypeAlias;
|
||
exports.TypeAnnotation = TypeAnnotation;
|
||
exports.TypeParameterDeclaration = exports.TypeParameterInstantiation = TypeParameterInstantiation;
|
||
exports.TypeParameter = TypeParameter;
|
||
exports.OpaqueType = OpaqueType;
|
||
exports.ObjectTypeAnnotation = ObjectTypeAnnotation;
|
||
exports.ObjectTypeInternalSlot = ObjectTypeInternalSlot;
|
||
exports.ObjectTypeCallProperty = ObjectTypeCallProperty;
|
||
exports.ObjectTypeIndexer = ObjectTypeIndexer;
|
||
exports.ObjectTypeProperty = ObjectTypeProperty;
|
||
exports.ObjectTypeSpreadProperty = ObjectTypeSpreadProperty;
|
||
exports.QualifiedTypeIdentifier = QualifiedTypeIdentifier;
|
||
exports.UnionTypeAnnotation = UnionTypeAnnotation;
|
||
exports.TypeCastExpression = TypeCastExpression;
|
||
exports.Variance = Variance;
|
||
exports.VoidTypeAnnotation = VoidTypeAnnotation;
|
||
Object.defineProperty(exports, "NumberLiteralTypeAnnotation", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _types2.NumericLiteral;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "StringLiteralTypeAnnotation", {
|
||
enumerable: true,
|
||
get: function () {
|
||
return _types2.StringLiteral;
|
||
}
|
||
});
|
||
|
||
function t() {
|
||
const data = _interopRequireWildcard(__webpack_require__(3));
|
||
|
||
t = function () {
|
||
return data;
|
||
};
|
||
|
||
return data;
|
||
}
|
||
|
||
var _modules = __webpack_require__(157);
|
||
|
||
var _types2 = __webpack_require__(97);
|
||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||
|
||
function AnyTypeAnnotation() {
|
||
this.word("any");
|
||
}
|
||
|
||
function ArrayTypeAnnotation(node) {
|
||
this.print(node.elementType, node);
|
||
this.token("[");
|
||
this.token("]");
|
||
}
|
||
|
||
function BooleanTypeAnnotation() {
|
||
this.word("boolean");
|
||
}
|
||
|
||
function BooleanLiteralTypeAnnotation(node) {
|
||
this.word(node.value ? "true" : "false");
|
||
}
|
||
|
||
function NullLiteralTypeAnnotation() {
|
||
this.word("null");
|
||
}
|
||
|
||
function DeclareClass(node, parent) {
|
||
if (!t().isDeclareExportDeclaration(parent)) {
|
||
this.word("declare");
|
||
this.space();
|
||
}
|
||
|
||
this.word("class");
|
||
this.space();
|
||
|
||
this._interfaceish(node);
|
||
}
|
||
|
||
function DeclareFunction(node, parent) {
|
||
if (!t().isDeclareExportDeclaration(parent)) {
|
||
this.word("declare");
|
||
this.space();
|
||
}
|
||
|
||
this.word("function");
|
||
this.space();
|
||
this.print(node.id, node);
|
||
this.print(node.id.typeAnnotation.typeAnnotation, node);
|
||
|
||
if (node.predicate) {
|
||
this.space();
|
||
this.print(node.predicate, node);
|
||
}
|
||
|
||
this.semicolon();
|
||
}
|
||
|
||
function InferredPredicate() {
|
||
this.token("%");
|
||
this.word("checks");
|
||
}
|
||
|
||
function DeclaredPredicate(node) {
|
||
this.token("%");
|
||
this.word("checks");
|
||
this.token("(");
|
||
this.print(node.value, node);
|
||
this.token(")");
|
||
}
|
||
|
||
function DeclareInterface(node) {
|
||
this.word("declare");
|
||
this.space();
|
||
this.InterfaceDeclaration(node);
|
||
}
|
||
|
||
function DeclareModule(node) {
|
||
this.word("declare");
|
||
this.space();
|
||
this.word("module");
|
||
this.space();
|
||
this.print(node.id, node);
|
||
this.space();
|
||
this.print(node.body, node);
|
||
}
|
||
|
||
function DeclareModuleExports(node) {
|
||
this.word("declare");
|
||
this.space();
|
||
this.word("module");
|
||
this.token(".");
|
||
this.word("exports");
|
||
this.print(node.typeAnnotation, node);
|
||
}
|
||
|
||
function DeclareTypeAlias(node) {
|
||
this.word("declare");
|
||
this.space();
|
||
this.TypeAlias(node);
|
||
}
|
||
|
||
function DeclareOpaqueType(node, parent) {
|
||
if (!t().isDeclareExportDeclaration(parent)) {
|
||
this.word("declare");
|
||
this.space();
|
||
}
|
||
|
||
this.OpaqueType(node);
|
||
}
|
||
|
||
function DeclareVariable(node, parent) {
|
||
if (!t().isDeclareExportDeclaration(parent)) {
|
||
this.word("declare");
|
||
this.space();
|
||
}
|
||
|
||
this.word("var");
|
||
this.space();
|
||
this.print(node.id, node);
|
||
this.print(node.id.typeAnnotation, node);
|
||
this.semicolon();
|
||
}
|
||
|
||
function DeclareExportDeclaration(node) {
|
||
this.word("declare");
|
||
this.space();
|
||
this.word("export");
|
||
this.space();
|
||
|
||
if (node.default) {
|
||
this.word("default");
|
||
this.space();
|
||
}
|
||
|
||
FlowExportDeclaration.apply(this, arguments);
|
||
}
|
||
|
||
function DeclareExportAllDeclaration() {
|
||
this.word("declare");
|
||
this.space();
|
||
|
||
_modules.ExportAllDeclaration.apply(this, arguments);
|
||
}
|
||
|
||
function FlowExportDeclaration(node) {
|
||
if (node.declaration) {
|
||
const declar = node.declaration;
|
||
this.print(declar, node);
|
||
if (!t().isStatement(declar)) this.semicolon();
|
||
} else {
|
||
this.token("{");
|
||
|
||
if (node.specifiers.length) {
|
||
this.space();
|
||
this.printList(node.specifiers, node);
|
||
this.space();
|
||
}
|
||
|
||
this.token("}");
|
||
|
||
if (node.source) {
|
||
this.space();
|
||
this.word("from");
|
||
this.space();
|
||
this.print(node.source, node);
|
||
}
|
||
|
||
this.semicolon();
|
||
}
|
||
}
|
||
|
||
function ExistsTypeAnnotation() {
|
||
this.token("*");
|
||
}
|
||
|
||
function FunctionTypeAnnotation(node, parent) {
|
||
this.print(node.typeParameters, node);
|
||
this.token("(");
|
||
this.printList(node.params, node);
|
||
|
||
if (node.rest) {
|
||
if (node.params.length) {
|
||
this.token(",");
|
||
this.space();
|
||
}
|
||
|
||
this.token("...");
|
||
this.print(node.rest, node);
|
||
}
|
||
|
||
this.token(")");
|
||
|
||
if (parent.type === "ObjectTypeCallProperty" || parent.type === "DeclareFunction" || parent.type === "ObjectTypeProperty" && parent.method) {
|
||
this.token(":");
|
||
} else {
|
||
this.space();
|
||
this.token("=>");
|
||
}
|
||
|
||
this.space();
|
||
this.print(node.returnType, node);
|
||
}
|
||
|
||
function FunctionTypeParam(node) {
|
||
this.print(node.name, node);
|
||
if (node.optional) this.token("?");
|
||
|
||
if (node.name) {
|
||
this.token(":");
|
||
this.space();
|
||
}
|
||
|
||
this.print(node.typeAnnotation, node);
|
||
}
|
||
|
||
function InterfaceExtends(node) {
|
||
this.print(node.id, node);
|
||
this.print(node.typeParameters, node);
|
||
}
|
||
|
||
function _interfaceish(node) {
|
||
this.print(node.id, node);
|
||
this.print(node.typeParameters, node);
|
||
|
||
if (node.extends.length) {
|
||
this.space();
|
||
this.word("extends");
|
||
this.space();
|
||
this.printList(node.extends, node);
|
||
}
|
||
|
||
if (node.mixins && node.mixins.length) {
|
||
this.space();
|
||
this.word("mixins");
|
||
this.space();
|
||
this.printList(node.mixins, node);
|
||
}
|
||
|
||
if (node.implements && node.implements.length) {
|
||
this.space();
|
||
this.word("implements");
|
||
this.space();
|
||
this.printList(node.implements, node);
|
||
}
|
||
|
||
this.space();
|
||
this.print(node.body, node);
|
||
}
|
||
|
||
function _variance(node) {
|
||
if (node.variance) {
|
||
if (node.variance.kind === "plus") {
|
||
this.token("+");
|
||
} else if (node.variance.kind === "minus") {
|
||
this.token("-");
|
||
}
|
||
}
|
||
}
|
||
|
||
function InterfaceDeclaration(node) {
|
||
this.word("interface");
|
||
this.space();
|
||
|
||
this._interfaceish(node);
|
||
}
|
||
|
||
function andSeparator() {
|
||
this.space();
|
||
this.token("&");
|
||
this.space();
|
||
}
|
||
|
||
function InterfaceTypeAnnotation(node) {
|
||
this.word("interface");
|
||
|
||
if (node.extends && node.extends.length) {
|
||
this.space();
|
||
this.word("extends");
|
||
this.space();
|
||
this.printList(node.extends, node);
|
||
}
|
||
|
||
this.space();
|
||
this.print(node.body, node);
|
||
}
|
||
|
||
function IntersectionTypeAnnotation(node) {
|
||
this.printJoin(node.types, node, {
|
||
separator: andSeparator
|
||
});
|
||
}
|
||
|
||
function MixedTypeAnnotation() {
|
||
this.word("mixed");
|
||
}
|
||
|
||
function EmptyTypeAnnotation() {
|
||
this.word("empty");
|
||
}
|
||
|
||
function NullableTypeAnnotation(node) {
|
||
this.token("?");
|
||
this.print(node.typeAnnotation, node);
|
||
}
|
||
|
||
function NumberTypeAnnotation() {
|
||
this.word("number");
|
||
}
|
||
|
||
function StringTypeAnnotation() {
|
||
this.word("string");
|
||
}
|
||
|
||
function ThisTypeAnnotation() {
|
||
this.word("this");
|
||
}
|
||
|
||
function TupleTypeAnnotation(node) {
|
||
this.token("[");
|
||
this.printList(node.types, node);
|
||
this.token("]");
|
||
}
|
||
|
||
function TypeofTypeAnnotation(node) {
|
||
this.word("typeof");
|
||
this.space();
|
||
this.print(node.argument, node);
|
||
}
|
||
|
||
function TypeAlias(node) {
|
||
this.word("type");
|
||
this.space();
|
||
this.print(node.id, node);
|
||
this.print(node.typeParameters, node);
|
||
this.space();
|
||
this.token("=");
|
||
this.space();
|
||
this.print(node.right, node);
|
||
this.semicolon();
|
||
}
|
||
|
||
function TypeAnnotation(node) {
|
||
this.token(":");
|
||
this.space();
|
||
if (node.optional) this.token("?");
|
||
this.print(node.typeAnnotation, node);
|
||
}
|
||
|
||
function TypeParameterInstantiation(node) {
|
||
this.token("<");
|
||
this.printList(node.params, node, {});
|
||
this.token(">");
|
||
}
|
||
|
||
function TypeParameter(node) {
|
||
this._variance(node);
|
||
|
||
this.word(node.name);
|
||
|
||
if (node.bound) {
|
||
this.print(node.bound, node);
|
||
}
|
||
|
||
if (node.default) {
|
||
this.space();
|
||
this.token("=");
|
||
this.space();
|
||
this.print(node.default, node);
|
||
}
|
||
}
|
||
|
||
function OpaqueType(node) {
|
||
this.word("opaque");
|
||
this.space();
|
||
this.word("type");
|
||
this.space();
|
||
this.print(node.id, node);
|
||
this.print(node.typeParameters, node);
|
||
|
||
if (node.supertype) {
|
||
this.token(":");
|
||
this.space();
|
||
this.print(node.supertype, node);
|
||
}
|
||
|
||
if (node.impltype) {
|
||
this.space();
|
||
this.token("=");
|
||
this.space();
|
||
this.print(node.impltype, node);
|
||
}
|
||
|
||
this.semicolon();
|
||
}
|
||
|
||
function ObjectTypeAnnotation(node) {
|
||
if (node.exact) {
|
||
this.token("{|");
|
||
} else {
|
||
this.token("{");
|
||
}
|
||
|
||
const props = node.properties.concat(node.callProperties || [], node.indexers || [], node.internalSlots || []);
|
||
|
||
if (props.length) {
|
||
this.space();
|
||
this.printJoin(props, node, {
|
||
addNewlines(leading) {
|
||
if (leading && !props[0]) return 1;
|
||
},
|
||
|
||
indent: true,
|
||
statement: true,
|
||
iterator: () => {
|
||
if (props.length !== 1 || node.inexact) {
|
||
this.token(",");
|
||
this.space();
|
||
}
|
||
}
|
||
});
|
||
this.space();
|
||
}
|
||
|
||
if (node.inexact) {
|
||
this.indent();
|
||
this.token("...");
|
||
|
||
if (props.length) {
|
||
this.newline();
|
||
}
|
||
|
||
this.dedent();
|
||
}
|
||
|
||
if (node.exact) {
|
||
this.token("|}");
|
||
} else {
|
||
this.token("}");
|
||
}
|
||
}
|
||
|
||
function ObjectTypeInternalSlot(node) {
|
||
if (node.static) {
|
||
this.word("static");
|
||
this.space();
|
||
}
|
||
|
||
this.token("[");
|
||
this.token("[");
|
||
this.print(node.id, node);
|
||
this.token("]");
|
||
this.token("]");
|
||
if (node.optional) this.token("?");
|
||
|
||
if (!node.method) {
|
||
this.token(":");
|
||
this.space();
|
||
}
|
||
|
||
this.print(node.value, node);
|
||
}
|
||
|
||
function ObjectTypeCallProperty(node) {
|
||
if (node.static) {
|
||
this.word("static");
|
||
this.space();
|
||
}
|
||
|
||
this.print(node.value, node);
|
||
}
|
||
|
||
function ObjectTypeIndexer(node) {
|
||
if (node.static) {
|
||
this.word("static");
|
||
this.space();
|
||
}
|
||
|
||
this._variance(node);
|
||
|
||
this.token("[");
|
||
|
||
if (node.id) {
|
||
this.print(node.id, node);
|
||
this.token(":");
|
||
this.space();
|
||
}
|
||
|
||
this.print(node.key, node);
|
||
this.token("]");
|
||
this.token(":");
|
||
this.space();
|
||
this.print(node.value, node);
|
||
}
|
||
|
||
function ObjectTypeProperty(node) {
|
||
if (node.proto) {
|
||
this.word("proto");
|
||
this.space();
|
||
}
|
||
|
||
if (node.static) {
|
||
this.word("static");
|
||
this.space();
|
||
}
|
||
|
||
this._variance(node);
|
||
|
||
this.print(node.key, node);
|
||
if (node.optional) this.token("?");
|
||
|
||
if (!node.method) {
|
||
this.token(":");
|
||
this.space();
|
||
}
|
||
|
||
this.print(node.value, node);
|
||
}
|
||
|
||
function ObjectTypeSpreadProperty(node) {
|
||
this.token("...");
|
||
this.print(node.argument, node);
|
||
}
|
||
|
||
function QualifiedTypeIdentifier(node) {
|
||
this.print(node.qualification, node);
|
||
this.token(".");
|
||
this.print(node.id, node);
|
||
}
|
||
|
||
function orSeparator() {
|
||
this.space();
|
||
this.token("|");
|
||
this.space();
|
||
}
|
||
|
||
function UnionTypeAnnotation(node) {
|
||
this.printJoin(node.types, node, {
|
||
separator: orSeparator
|
||
});
|
||
}
|
||
|
||
function TypeCastExpression(node) {
|
||
this.token("(");
|
||
this.print(node.expression, node);
|
||
this.print(node.typeAnnotation, node);
|
||
this.token(")");
|
||
}
|
||
|
||
function Variance(node) {
|
||
if (node.kind === "plus") {
|
||
this.token("+");
|
||
} else {
|
||
this.token("-");
|
||
}
|
||
}
|
||
|
||
function VoidTypeAnnotation() {
|
||
this.word("void");
|
||
}
|
||
|
||
/***/ }),
|
||
/* 345 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.File = File;
|
||
exports.Program = Program;
|
||
exports.BlockStatement = BlockStatement;
|
||
exports.Noop = Noop;
|
||
exports.Directive = Directive;
|
||
exports.DirectiveLiteral = DirectiveLiteral;
|
||
exports.InterpreterDirective = InterpreterDirective;
|
||
exports.Placeholder = Placeholder;
|
||
|
||
function File(node) {
|
||
if (node.program) {
|
||
this.print(node.program.interpreter, node);
|
||
}
|
||
|
||
this.print(node.program, node);
|
||
}
|
||
|
||
function Program(node) {
|
||
this.printInnerComments(node, false);
|
||
this.printSequence(node.directives, node);
|
||
if (node.directives && node.directives.length) this.newline();
|
||
this.printSequence(node.body, node);
|
||
}
|
||
|
||
function BlockStatement(node) {
|
||
this.token("{");
|
||
this.printInnerComments(node);
|
||
const hasDirectives = node.directives && node.directives.length;
|
||
|
||
if (node.body.length || hasDirectives) {
|
||
this.newline();
|
||
this.printSequence(node.directives, node, {
|
||
indent: true
|
||
});
|
||
if (hasDirectives) this.newline();
|
||
this.printSequence(node.body, node, {
|
||
indent: true
|
||
});
|
||
this.removeTrailingNewline();
|
||
this.source("end", node.loc);
|
||
if (!this.endsWith("\n")) this.newline();
|
||
this.rightBrace();
|
||
} else {
|
||
this.source("end", node.loc);
|
||
this.token("}");
|
||
}
|
||
}
|
||
|
||
function Noop() {}
|
||
|
||
function Directive(node) {
|
||
this.print(node.value, node);
|
||
this.semicolon();
|
||
}
|
||
|
||
const unescapedSingleQuoteRE = /(?:^|[^\\])(?:\\\\)*'/;
|
||
const unescapedDoubleQuoteRE = /(?:^|[^\\])(?:\\\\)*"/;
|
||
|
||
function DirectiveLiteral(node) {
|
||
const raw = this.getPossibleRaw(node);
|
||
|
||
if (raw != null) {
|
||
this.token(raw);
|
||
return;
|
||
}
|
||
|
||
const {
|
||
value
|
||
} = node;
|
||
|
||
if (!unescapedDoubleQuoteRE.test(value)) {
|
||
this.token(`"${value}"`);
|
||
} else if (!unescapedSingleQuoteRE.test(value)) {
|
||
this.token(`'${value}'`);
|
||
} else {
|
||
throw new Error("Malformed AST: it is not possible to print a directive containing" + " both unescaped single and double quotes.");
|
||
}
|
||
}
|
||
|
||
function InterpreterDirective(node) {
|
||
this.token(`#!${node.value}\n`);
|
||
}
|
||
|
||
function Placeholder(node) {
|
||
this.token("%%");
|
||
this.print(node.name);
|
||
this.token("%%");
|
||
|
||
if (node.expectedNode === "Statement") {
|
||
this.semicolon();
|
||
}
|
||
}
|
||
|
||
/***/ }),
|
||
/* 346 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.JSXAttribute = JSXAttribute;
|
||
exports.JSXIdentifier = JSXIdentifier;
|
||
exports.JSXNamespacedName = JSXNamespacedName;
|
||
exports.JSXMemberExpression = JSXMemberExpression;
|
||
exports.JSXSpreadAttribute = JSXSpreadAttribute;
|
||
exports.JSXExpressionContainer = JSXExpressionContainer;
|
||
exports.JSXSpreadChild = JSXSpreadChild;
|
||
exports.JSXText = JSXText;
|
||
exports.JSXElement = JSXElement;
|
||
exports.JSXOpeningElement = JSXOpeningElement;
|
||
exports.JSXClosingElement = JSXClosingElement;
|
||
exports.JSXEmptyExpression = JSXEmptyExpression;
|
||
exports.JSXFragment = JSXFragment;
|
||
exports.JSXOpeningFragment = JSXOpeningFragment;
|
||
exports.JSXClosingFragment = JSXClosingFragment;
|
||
|
||
function JSXAttribute(node) {
|
||
this.print(node.name, node);
|
||
|
||
if (node.value) {
|
||
this.token("=");
|
||
this.print(node.value, node);
|
||
}
|
||
}
|
||
|
||
function JSXIdentifier(node) {
|
||
this.word(node.name);
|
||
}
|
||
|
||
function JSXNamespacedName(node) {
|
||
this.print(node.namespace, node);
|
||
this.token(":");
|
||
this.print(node.name, node);
|
||
}
|
||
|
||
function JSXMemberExpression(node) {
|
||
this.print(node.object, node);
|
||
this.token(".");
|
||
this.print(node.property, node);
|
||
}
|
||
|
||
function JSXSpreadAttribute(node) {
|
||
this.token("{");
|
||
this.token("...");
|
||
this.print(node.argument, node);
|
||
this.token("}");
|
||
}
|
||
|
||
function JSXExpressionContainer(node) {
|
||
this.token("{");
|
||
this.print(node.expression, node);
|
||
this.token("}");
|
||
}
|
||
|
||
function JSXSpreadChild(node) {
|
||
this.token("{");
|
||
this.token("...");
|
||
this.print(node.expression, node);
|
||
this.token("}");
|
||
}
|
||
|
||
function JSXText(node) {
|
||
const raw = this.getPossibleRaw(node);
|
||
|
||
if (raw != null) {
|
||
this.token(raw);
|
||
} else {
|
||
this.token(node.value);
|
||
}
|
||
}
|
||
|
||
function JSXElement(node) {
|
||
const open = node.openingElement;
|
||
this.print(open, node);
|
||
if (open.selfClosing) return;
|
||
this.indent();
|
||
|
||
for (const child of node.children) {
|
||
this.print(child, node);
|
||
}
|
||
|
||
this.dedent();
|
||
this.print(node.closingElement, node);
|
||
}
|
||
|
||
function spaceSeparator() {
|
||
this.space();
|
||
}
|
||
|
||
function JSXOpeningElement(node) {
|
||
this.token("<");
|
||
this.print(node.name, node);
|
||
this.print(node.typeParameters, node);
|
||
|
||
if (node.attributes.length > 0) {
|
||
this.space();
|
||
this.printJoin(node.attributes, node, {
|
||
separator: spaceSeparator
|
||
});
|
||
}
|
||
|
||
if (node.selfClosing) {
|
||
this.space();
|
||
this.token("/>");
|
||
} else {
|
||
this.token(">");
|
||
}
|
||
}
|
||
|
||
function JSXClosingElement(node) {
|
||
this.token("</");
|
||
this.print(node.name, node);
|
||
this.token(">");
|
||
}
|
||
|
||
function JSXEmptyExpression(node) {
|
||
this.printInnerComments(node);
|
||
}
|
||
|
||
function JSXFragment(node) {
|
||
this.print(node.openingFragment, node);
|
||
this.indent();
|
||
|
||
for (const child of node.children) {
|
||
this.print(child, node);
|
||
}
|
||
|
||
this.dedent();
|
||
this.print(node.closingFragment, node);
|
||
}
|
||
|
||
function JSXOpeningFragment() {
|
||
this.token("<");
|
||
this.token(">");
|
||
}
|
||
|
||
function JSXClosingFragment() {
|
||
this.token("</");
|
||
this.token(">");
|
||
}
|
||
|
||
/***/ }),
|
||
/* 347 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.TSTypeAnnotation = TSTypeAnnotation;
|
||
exports.TSTypeParameterDeclaration = exports.TSTypeParameterInstantiation = TSTypeParameterInstantiation;
|
||
exports.TSTypeParameter = TSTypeParameter;
|
||
exports.TSParameterProperty = TSParameterProperty;
|
||
exports.TSDeclareFunction = TSDeclareFunction;
|
||
exports.TSDeclareMethod = TSDeclareMethod;
|
||
exports.TSQualifiedName = TSQualifiedName;
|
||
exports.TSCallSignatureDeclaration = TSCallSignatureDeclaration;
|
||
exports.TSConstructSignatureDeclaration = TSConstructSignatureDeclaration;
|
||
exports.TSPropertySignature = TSPropertySignature;
|
||
exports.tsPrintPropertyOrMethodName = tsPrintPropertyOrMethodName;
|
||
exports.TSMethodSignature = TSMethodSignature;
|
||
exports.TSIndexSignature = TSIndexSignature;
|
||
exports.TSAnyKeyword = TSAnyKeyword;
|
||
exports.TSUnknownKeyword = TSUnknownKeyword;
|
||
exports.TSNumberKeyword = TSNumberKeyword;
|
||
exports.TSObjectKeyword = TSObjectKeyword;
|
||
exports.TSBooleanKeyword = TSBooleanKeyword;
|
||
exports.TSStringKeyword = TSStringKeyword;
|
||
exports.TSSymbolKeyword = TSSymbolKeyword;
|
||
exports.TSVoidKeyword = TSVoidKeyword;
|
||
exports.TSUndefinedKeyword = TSUndefinedKeyword;
|
||
exports.TSNullKeyword = TSNullKeyword;
|
||
exports.TSNeverKeyword = TSNeverKeyword;
|
||
exports.TSThisType = TSThisType;
|
||
exports.TSFunctionType = TSFunctionType;
|
||
exports.TSConstructorType = TSConstructorType;
|
||
exports.tsPrintFunctionOrConstructorType = tsPrintFunctionOrConstructorType;
|
||
exports.TSTypeReference = TSTypeReference;
|
||
exports.TSTypePredicate = TSTypePredicate;
|
||
exports.TSTypeQuery = TSTypeQuery;
|
||
exports.TSTypeLiteral = TSTypeLiteral;
|
||
exports.tsPrintTypeLiteralOrInterfaceBody = tsPrintTypeLiteralOrInterfaceBody;
|
||
exports.tsPrintBraced = tsPrintBraced;
|
||
exports.TSArrayType = TSArrayType;
|
||
exports.TSTupleType = TSTupleType;
|
||
exports.TSOptionalType = TSOptionalType;
|
||
exports.TSRestType = TSRestType;
|
||
exports.TSUnionType = TSUnionType;
|
||
exports.TSIntersectionType = TSIntersectionType;
|
||
exports.tsPrintUnionOrIntersectionType = tsPrintUnionOrIntersectionType;
|
||
exports.TSConditionalType = TSConditionalType;
|
||
exports.TSInferType = TSInferType;
|
||
exports.TSParenthesizedType = TSParenthesizedType;
|
||
exports.TSTypeOperator = TSTypeOperator;
|
||
exports.TSIndexedAccessType = TSIndexedAccessType;
|
||
exports.TSMappedType = TSMappedType;
|
||
exports.TSLiteralType = TSLiteralType;
|
||
exports.TSExpressionWithTypeArguments = TSExpressionWithTypeArguments;
|
||
exports.TSInterfaceDeclaration = TSInterfaceDeclaration;
|
||
exports.TSInterfaceBody = TSInterfaceBody;
|
||
exports.TSTypeAliasDeclaration = TSTypeAliasDeclaration;
|
||
exports.TSAsExpression = TSAsExpression;
|
||
exports.TSTypeAssertion = TSTypeAssertion;
|
||
exports.TSEnumDeclaration = TSEnumDeclaration;
|
||
exports.TSEnumMember = TSEnumMember;
|
||
exports.TSModuleDeclaration = TSModuleDeclaration;
|
||
exports.TSModuleBlock = TSModuleBlock;
|
||
exports.TSImportType = TSImportType;
|
||
exports.TSImportEqualsDeclaration = TSImportEqualsDeclaration;
|
||
exports.TSExternalModuleReference = TSExternalModuleReference;
|
||
exports.TSNonNullExpression = TSNonNullExpression;
|
||
exports.TSExportAssignment = TSExportAssignment;
|
||
exports.TSNamespaceExportDeclaration = TSNamespaceExportDeclaration;
|
||
exports.tsPrintSignatureDeclarationBase = tsPrintSignatureDeclarationBase;
|
||
|
||
function TSTypeAnnotation(node) {
|
||
this.token(":");
|
||
this.space();
|
||
if (node.optional) this.token("?");
|
||
this.print(node.typeAnnotation, node);
|
||
}
|
||
|
||
function TSTypeParameterInstantiation(node) {
|
||
this.token("<");
|
||
this.printList(node.params, node, {});
|
||
this.token(">");
|
||
}
|
||
|
||
function TSTypeParameter(node) {
|
||
this.word(node.name);
|
||
|
||
if (node.constraint) {
|
||
this.space();
|
||
this.word("extends");
|
||
this.space();
|
||
this.print(node.constraint, node);
|
||
}
|
||
|
||
if (node.default) {
|
||
this.space();
|
||
this.token("=");
|
||
this.space();
|
||
this.print(node.default, node);
|
||
}
|
||
}
|
||
|
||
function TSParameterProperty(node) {
|
||
if (node.accessibility) {
|
||
this.word(node.accessibility);
|
||
this.space();
|
||
}
|
||
|
||
if (node.readonly) {
|
||
this.word("readonly");
|
||
this.space();
|
||
}
|
||
|
||
this._param(node.parameter);
|
||
}
|
||
|
||
function TSDeclareFunction(node) {
|
||
if (node.declare) {
|
||
this.word("declare");
|
||
this.space();
|
||
}
|
||
|
||
this._functionHead(node);
|
||
|
||
this.token(";");
|
||
}
|
||
|
||
function TSDeclareMethod(node) {
|
||
this._classMethodHead(node);
|
||
|
||
this.token(";");
|
||
}
|
||
|
||
function TSQualifiedName(node) {
|
||
this.print(node.left, node);
|
||
this.token(".");
|
||
this.print(node.right, node);
|
||
}
|
||
|
||
function TSCallSignatureDeclaration(node) {
|
||
this.tsPrintSignatureDeclarationBase(node);
|
||
}
|
||
|
||
function TSConstructSignatureDeclaration(node) {
|
||
this.word("new");
|
||
this.space();
|
||
this.tsPrintSignatureDeclarationBase(node);
|
||
}
|
||
|
||
function TSPropertySignature(node) {
|
||
const {
|
||
readonly,
|
||
initializer
|
||
} = node;
|
||
|
||
if (readonly) {
|
||
this.word("readonly");
|
||
this.space();
|
||
}
|
||
|
||
this.tsPrintPropertyOrMethodName(node);
|
||
this.print(node.typeAnnotation, node);
|
||
|
||
if (initializer) {
|
||
this.space();
|
||
this.token("=");
|
||
this.space();
|
||
this.print(initializer, node);
|
||
}
|
||
|
||
this.token(";");
|
||
}
|
||
|
||
function tsPrintPropertyOrMethodName(node) {
|
||
if (node.computed) {
|
||
this.token("[");
|
||
}
|
||
|
||
this.print(node.key, node);
|
||
|
||
if (node.computed) {
|
||
this.token("]");
|
||
}
|
||
|
||
if (node.optional) {
|
||
this.token("?");
|
||
}
|
||
}
|
||
|
||
function TSMethodSignature(node) {
|
||
this.tsPrintPropertyOrMethodName(node);
|
||
this.tsPrintSignatureDeclarationBase(node);
|
||
this.token(";");
|
||
}
|
||
|
||
function TSIndexSignature(node) {
|
||
const {
|
||
readonly
|
||
} = node;
|
||
|
||
if (readonly) {
|
||
this.word("readonly");
|
||
this.space();
|
||
}
|
||
|
||
this.token("[");
|
||
|
||
this._parameters(node.parameters, node);
|
||
|
||
this.token("]");
|
||
this.print(node.typeAnnotation, node);
|
||
this.token(";");
|
||
}
|
||
|
||
function TSAnyKeyword() {
|
||
this.word("any");
|
||
}
|
||
|
||
function TSUnknownKeyword() {
|
||
this.word("unknown");
|
||
}
|
||
|
||
function TSNumberKeyword() {
|
||
this.word("number");
|
||
}
|
||
|
||
function TSObjectKeyword() {
|
||
this.word("object");
|
||
}
|
||
|
||
function TSBooleanKeyword() {
|
||
this.word("boolean");
|
||
}
|
||
|
||
function TSStringKeyword() {
|
||
this.word("string");
|
||
}
|
||
|
||
function TSSymbolKeyword() {
|
||
this.word("symbol");
|
||
}
|
||
|
||
function TSVoidKeyword() {
|
||
this.word("void");
|
||
}
|
||
|
||
function TSUndefinedKeyword() {
|
||
this.word("undefined");
|
||
}
|
||
|
||
function TSNullKeyword() {
|
||
this.word("null");
|
||
}
|
||
|
||
function TSNeverKeyword() {
|
||
this.word("never");
|
||
}
|
||
|
||
function TSThisType() {
|
||
this.word("this");
|
||
}
|
||
|
||
function TSFunctionType(node) {
|
||
this.tsPrintFunctionOrConstructorType(node);
|
||
}
|
||
|
||
function TSConstructorType(node) {
|
||
this.word("new");
|
||
this.space();
|
||
this.tsPrintFunctionOrConstructorType(node);
|
||
}
|
||
|
||
function tsPrintFunctionOrConstructorType(node) {
|
||
const {
|
||
typeParameters,
|
||
parameters
|
||
} = node;
|
||
this.print(typeParameters, node);
|
||
this.token("(");
|
||
|
||
this._parameters(parameters, node);
|
||
|
||
this.token(")");
|
||
this.space();
|
||
this.token("=>");
|
||
this.space();
|
||
this.print(node.typeAnnotation.typeAnnotation, node);
|
||
}
|
||
|
||
function TSTypeReference(node) {
|
||
this.print(node.typeName, node);
|
||
this.print(node.typeParameters, node);
|
||
}
|
||
|
||
function TSTypePredicate(node) {
|
||
this.print(node.parameterName);
|
||
this.space();
|
||
this.word("is");
|
||
this.space();
|
||
this.print(node.typeAnnotation.typeAnnotation);
|
||
}
|
||
|
||
function TSTypeQuery(node) {
|
||
this.word("typeof");
|
||
this.space();
|
||
this.print(node.exprName);
|
||
}
|
||
|
||
function TSTypeLiteral(node) {
|
||
this.tsPrintTypeLiteralOrInterfaceBody(node.members, node);
|
||
}
|
||
|
||
function tsPrintTypeLiteralOrInterfaceBody(members, node) {
|
||
this.tsPrintBraced(members, node);
|
||
}
|
||
|
||
function tsPrintBraced(members, node) {
|
||
this.token("{");
|
||
|
||
if (members.length) {
|
||
this.indent();
|
||
this.newline();
|
||
|
||
for (const member of members) {
|
||
this.print(member, node);
|
||
this.newline();
|
||
}
|
||
|
||
this.dedent();
|
||
this.rightBrace();
|
||
} else {
|
||
this.token("}");
|
||
}
|
||
}
|
||
|
||
function TSArrayType(node) {
|
||
this.print(node.elementType, node);
|
||
this.token("[]");
|
||
}
|
||
|
||
function TSTupleType(node) {
|
||
this.token("[");
|
||
this.printList(node.elementTypes, node);
|
||
this.token("]");
|
||
}
|
||
|
||
function TSOptionalType(node) {
|
||
this.print(node.typeAnnotation, node);
|
||
this.token("?");
|
||
}
|
||
|
||
function TSRestType(node) {
|
||
this.token("...");
|
||
this.print(node.typeAnnotation, node);
|
||
}
|
||
|
||
function TSUnionType(node) {
|
||
this.tsPrintUnionOrIntersectionType(node, "|");
|
||
}
|
||
|
||
function TSIntersectionType(node) {
|
||
this.tsPrintUnionOrIntersectionType(node, "&");
|
||
}
|
||
|
||
function tsPrintUnionOrIntersectionType(node, sep) {
|
||
this.printJoin(node.types, node, {
|
||
separator() {
|
||
this.space();
|
||
this.token(sep);
|
||
this.space();
|
||
}
|
||
|
||
});
|
||
}
|
||
|
||
function TSConditionalType(node) {
|
||
this.print(node.checkType);
|
||
this.space();
|
||
this.word("extends");
|
||
this.space();
|
||
this.print(node.extendsType);
|
||
this.space();
|
||
this.token("?");
|
||
this.space();
|
||
this.print(node.trueType);
|
||
this.space();
|
||
this.token(":");
|
||
this.space();
|
||
this.print(node.falseType);
|
||
}
|
||
|
||
function TSInferType(node) {
|
||
this.token("infer");
|
||
this.space();
|
||
this.print(node.typeParameter);
|
||
}
|
||
|
||
function TSParenthesizedType(node) {
|
||
this.token("(");
|
||
this.print(node.typeAnnotation, node);
|
||
this.token(")");
|
||
}
|
||
|
||
function TSTypeOperator(node) {
|
||
this.token(node.operator);
|
||
this.space();
|
||
this.print(node.typeAnnotation, node);
|
||
}
|
||
|
||
function TSIndexedAccessType(node) {
|
||
this.print(node.objectType, node);
|
||
this.token("[");
|
||
this.print(node.indexType, node);
|
||
this.token("]");
|
||
}
|
||
|
||
function TSMappedType(node) {
|
||
const {
|
||
readonly,
|
||
typeParameter,
|
||
optional
|
||
} = node;
|
||
this.token("{");
|
||
this.space();
|
||
|
||
if (readonly) {
|
||
tokenIfPlusMinus(this, readonly);
|
||
this.word("readonly");
|
||
this.space();
|
||
}
|
||
|
||
this.token("[");
|
||
this.word(typeParameter.name);
|
||
this.space();
|
||
this.word("in");
|
||
this.space();
|
||
this.print(typeParameter.constraint, typeParameter);
|
||
this.token("]");
|
||
|
||
if (optional) {
|
||
tokenIfPlusMinus(this, optional);
|
||
this.token("?");
|
||
}
|
||
|
||
this.token(":");
|
||
this.space();
|
||
this.print(node.typeAnnotation, node);
|
||
this.space();
|
||
this.token("}");
|
||
}
|
||
|
||
function tokenIfPlusMinus(self, tok) {
|
||
if (tok !== true) {
|
||
self.token(tok);
|
||
}
|
||
}
|
||
|
||
function TSLiteralType(node) {
|
||
this.print(node.literal, node);
|
||
}
|
||
|
||
function TSExpressionWithTypeArguments(node) {
|
||
this.print(node.expression, node);
|
||
this.print(node.typeParameters, node);
|
||
}
|
||
|
||
function TSInterfaceDeclaration(node) {
|
||
const {
|
||
declare,
|
||
id,
|
||
typeParameters,
|
||
extends: extendz,
|
||
body
|
||
} = node;
|
||
|
||
if (declare) {
|
||
this.word("declare");
|
||
this.space();
|
||
}
|
||
|
||
this.word("interface");
|
||
this.space();
|
||
this.print(id, node);
|
||
this.print(typeParameters, node);
|
||
|
||
if (extendz) {
|
||
this.space();
|
||
this.word("extends");
|
||
this.space();
|
||
this.printList(extendz, node);
|
||
}
|
||
|
||
this.space();
|
||
this.print(body, node);
|
||
}
|
||
|
||
function TSInterfaceBody(node) {
|
||
this.tsPrintTypeLiteralOrInterfaceBody(node.body, node);
|
||
}
|
||
|
||
function TSTypeAliasDeclaration(node) {
|
||
const {
|
||
declare,
|
||
id,
|
||
typeParameters,
|
||
typeAnnotation
|
||
} = node;
|
||
|
||
if (declare) {
|
||
this.word("declare");
|
||
this.space();
|
||
}
|
||
|
||
this.word("type");
|
||
this.space();
|
||
this.print(id, node);
|
||
this.print(typeParameters, node);
|
||
this.space();
|
||
this.token("=");
|
||
this.space();
|
||
this.print(typeAnnotation, node);
|
||
this.token(";");
|
||
}
|
||
|
||
function TSAsExpression(node) {
|
||
const {
|
||
expression,
|
||
typeAnnotation
|
||
} = node;
|
||
this.print(expression, node);
|
||
this.space();
|
||
this.word("as");
|
||
this.space();
|
||
this.print(typeAnnotation, node);
|
||
}
|
||
|
||
function TSTypeAssertion(node) {
|
||
const {
|
||
typeAnnotation,
|
||
expression
|
||
} = node;
|
||
this.token("<");
|
||
this.print(typeAnnotation, node);
|
||
this.token(">");
|
||
this.space();
|
||
this.print(expression, node);
|
||
}
|
||
|
||
function TSEnumDeclaration(node) {
|
||
const {
|
||
declare,
|
||
const: isConst,
|
||
id,
|
||
members
|
||
} = node;
|
||
|
||
if (declare) {
|
||
this.word("declare");
|
||
this.space();
|
||
}
|
||
|
||
if (isConst) {
|
||
this.word("const");
|
||
this.space();
|
||
}
|
||
|
||
this.word("enum");
|
||
this.space();
|
||
this.print(id, node);
|
||
this.space();
|
||
this.tsPrintBraced(members, node);
|
||
}
|
||
|
||
function TSEnumMember(node) {
|
||
const {
|
||
id,
|
||
initializer
|
||
} = node;
|
||
this.print(id, node);
|
||
|
||
if (initializer) {
|
||
this.space();
|
||
this.token("=");
|
||
this.space();
|
||
this.print(initializer, node);
|
||
}
|
||
|
||
this.token(",");
|
||
}
|
||
|
||
function TSModuleDeclaration(node) {
|
||
const {
|
||
declare,
|
||
id
|
||
} = node;
|
||
|
||
if (declare) {
|
||
this.word("declare");
|
||
this.space();
|
||
}
|
||
|
||
if (!node.global) {
|
||
this.word(id.type === "Identifier" ? "namespace" : "module");
|
||
this.space();
|
||
}
|
||
|
||
this.print(id, node);
|
||
|
||
if (!node.body) {
|
||
this.token(";");
|
||
return;
|
||
}
|
||
|
||
let body = node.body;
|
||
|
||
while (body.type === "TSModuleDeclaration") {
|
||
this.token(".");
|
||
this.print(body.id, body);
|
||
body = body.body;
|
||
}
|
||
|
||
this.space();
|
||
this.print(body, node);
|
||
}
|
||
|
||
function TSModuleBlock(node) {
|
||
this.tsPrintBraced(node.body, node);
|
||
}
|
||
|
||
function TSImportType(node) {
|
||
const {
|
||
argument,
|
||
qualifier,
|
||
typeParameters
|
||
} = node;
|
||
this.word("import");
|
||
this.token("(");
|
||
this.print(argument, node);
|
||
this.token(")");
|
||
|
||
if (qualifier) {
|
||
this.token(".");
|
||
this.print(qualifier, node);
|
||
}
|
||
|
||
if (typeParameters) {
|
||
this.print(typeParameters, node);
|
||
}
|
||
}
|
||
|
||
function TSImportEqualsDeclaration(node) {
|
||
const {
|
||
isExport,
|
||
id,
|
||
moduleReference
|
||
} = node;
|
||
|
||
if (isExport) {
|
||
this.word("export");
|
||
this.space();
|
||
}
|
||
|
||
this.word("import");
|
||
this.space();
|
||
this.print(id, node);
|
||
this.space();
|
||
this.token("=");
|
||
this.space();
|
||
this.print(moduleReference, node);
|
||
this.token(";");
|
||
}
|
||
|
||
function TSExternalModuleReference(node) {
|
||
this.token("require(");
|
||
this.print(node.expression, node);
|
||
this.token(")");
|
||
}
|
||
|
||
function TSNonNullExpression(node) {
|
||
this.print(node.expression, node);
|
||
this.token("!");
|
||
}
|
||
|
||
function TSExportAssignment(node) {
|
||
this.word("export");
|
||
this.space();
|
||
this.token("=");
|
||
this.space();
|
||
this.print(node.expression, node);
|
||
this.token(";");
|
||
}
|
||
|
||
function TSNamespaceExportDeclaration(node) {
|
||
this.word("export");
|
||
this.space();
|
||
this.word("as");
|
||
this.space();
|
||
this.word("namespace");
|
||
this.space();
|
||
this.print(node.id, node);
|
||
}
|
||
|
||
function tsPrintSignatureDeclarationBase(node) {
|
||
const {
|
||
typeParameters,
|
||
parameters
|
||
} = node;
|
||
this.print(typeParameters, node);
|
||
this.token("(");
|
||
|
||
this._parameters(parameters, node);
|
||
|
||
this.token(")");
|
||
this.print(node.typeAnnotation, node);
|
||
}
|
||
|
||
/***/ }),
|
||
/* 348 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.inferClassName = inferClassName;
|
||
|
||
var t = _interopRequireWildcard(__webpack_require__(3));
|
||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||
|
||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||
// the function class is inferred from a call like
|
||
// createClass or extend
|
||
function fromCallExpression(callExpression) {
|
||
const whitelist = ["extend", "createClass"];
|
||
const callee = callExpression.node.callee;
|
||
|
||
if (!callee) {
|
||
return null;
|
||
}
|
||
|
||
const name = t.isMemberExpression(callee) ? callee.property.name : callee.name;
|
||
|
||
if (!whitelist.includes(name)) {
|
||
return null;
|
||
}
|
||
|
||
const variable = callExpression.findParent(p => t.isVariableDeclarator(p.node));
|
||
|
||
if (variable) {
|
||
return variable.node.id.name;
|
||
}
|
||
|
||
const assignment = callExpression.findParent(p => t.isAssignmentExpression(p.node));
|
||
|
||
if (!assignment) {
|
||
return null;
|
||
}
|
||
|
||
const left = assignment.node.left;
|
||
|
||
if (left.name) {
|
||
return name;
|
||
}
|
||
|
||
if (t.isMemberExpression(left)) {
|
||
return left.property.name;
|
||
}
|
||
|
||
return null;
|
||
} // the function class is inferred from a prototype assignment
|
||
// e.g. TodoClass.prototype.render = function() {}
|
||
|
||
|
||
function fromPrototype(assignment) {
|
||
const left = assignment.node.left;
|
||
|
||
if (!left) {
|
||
return null;
|
||
}
|
||
|
||
if (t.isMemberExpression(left) && left.object && t.isMemberExpression(left.object) && left.object.property.identifier === "prototype") {
|
||
return left.object.object.name;
|
||
}
|
||
|
||
return null;
|
||
} // infer class finds an appropriate class for functions
|
||
// that are defined inside of a class like thing.
|
||
// e.g. `class Foo`, `TodoClass.prototype.foo`,
|
||
// `Todo = createClass({ foo: () => {}})`
|
||
|
||
|
||
function inferClassName(path) {
|
||
const classDeclaration = path.findParent(p => t.isClassDeclaration(p.node));
|
||
|
||
if (classDeclaration) {
|
||
return classDeclaration.node.id.name;
|
||
}
|
||
|
||
const callExpression = path.findParent(p => t.isCallExpression(p.node));
|
||
|
||
if (callExpression) {
|
||
return fromCallExpression(callExpression);
|
||
}
|
||
|
||
const assignment = path.findParent(p => t.isAssignmentExpression(p.node));
|
||
|
||
if (assignment) {
|
||
return fromPrototype(assignment);
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 349 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.parseSourceScopes = parseSourceScopes;
|
||
exports.buildScopeList = buildScopeList;
|
||
|
||
var _isEmpty = _interopRequireDefault(__webpack_require__(154));
|
||
|
||
var t = _interopRequireWildcard(__webpack_require__(3));
|
||
|
||
var _getFunctionName = _interopRequireDefault(__webpack_require__(158));
|
||
|
||
var _ast = __webpack_require__(20);
|
||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||
function isGeneratedId(id) {
|
||
return !/\/originalSource/.test(id);
|
||
}
|
||
|
||
function parseSourceScopes(sourceId) {
|
||
const ast = (0, _ast.getAst)(sourceId);
|
||
|
||
if ((0, _isEmpty.default)(ast)) {
|
||
return null;
|
||
}
|
||
|
||
return buildScopeList(ast, sourceId);
|
||
}
|
||
|
||
function buildScopeList(ast, sourceId) {
|
||
const {
|
||
global,
|
||
lexical
|
||
} = createGlobalScope(ast, sourceId);
|
||
const state = {
|
||
sourceId,
|
||
freeVariables: new Map(),
|
||
freeVariableStack: [],
|
||
inType: null,
|
||
scope: lexical,
|
||
scopeStack: [],
|
||
declarationBindingIds: new Set()
|
||
};
|
||
t.traverse(ast, scopeCollectionVisitor, state);
|
||
|
||
for (const [key, freeVariables] of state.freeVariables) {
|
||
let binding = global.bindings[key];
|
||
|
||
if (!binding) {
|
||
binding = {
|
||
type: "global",
|
||
refs: []
|
||
};
|
||
global.bindings[key] = binding;
|
||
}
|
||
|
||
binding.refs = freeVariables.concat(binding.refs);
|
||
} // TODO: This should probably check for ".mjs" extension on the
|
||
// original file, and should also be skipped if the the generated
|
||
// code is an ES6 module rather than a script.
|
||
|
||
|
||
if (isGeneratedId(sourceId) || ast.program.sourceType === "script" && !looksLikeCommonJS(global)) {
|
||
stripModuleScope(global);
|
||
}
|
||
|
||
return toParsedScopes([global], sourceId) || [];
|
||
}
|
||
|
||
function toParsedScopes(children, sourceId) {
|
||
if (!children || children.length === 0) {
|
||
return undefined;
|
||
}
|
||
|
||
return children.map(scope => ({
|
||
// Removing unneed information from TempScope such as parent reference.
|
||
// We also need to convert BabelLocation to the Location type.
|
||
start: scope.loc.start,
|
||
end: scope.loc.end,
|
||
type: scope.type === "module" || scope.type === "function-body" ? "block" : scope.type,
|
||
scopeKind: "",
|
||
displayName: scope.displayName,
|
||
bindings: scope.bindings,
|
||
children: toParsedScopes(scope.children, sourceId)
|
||
}));
|
||
}
|
||
|
||
function createTempScope(type, displayName, parent, loc) {
|
||
const result = {
|
||
type,
|
||
displayName,
|
||
parent,
|
||
children: [],
|
||
loc,
|
||
bindings: Object.create(null)
|
||
};
|
||
|
||
if (parent) {
|
||
parent.children.push(result);
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
function pushTempScope(state, type, displayName, loc) {
|
||
const scope = createTempScope(type, displayName, state.scope, loc);
|
||
state.scope = scope;
|
||
state.freeVariableStack.push(state.freeVariables);
|
||
state.freeVariables = new Map();
|
||
return scope;
|
||
}
|
||
|
||
function isNode(node, type) {
|
||
return node ? node.type === type : false;
|
||
}
|
||
|
||
function getVarScope(scope) {
|
||
let s = scope;
|
||
|
||
while (s.type !== "function" && s.type !== "module") {
|
||
if (!s.parent) {
|
||
return s;
|
||
}
|
||
|
||
s = s.parent;
|
||
}
|
||
|
||
return s;
|
||
}
|
||
|
||
function fromBabelLocation(location, sourceId) {
|
||
return {
|
||
sourceId,
|
||
line: location.line,
|
||
column: location.column
|
||
};
|
||
}
|
||
|
||
function parseDeclarator(declaratorId, targetScope, type, locationType, declaration, state) {
|
||
if (isNode(declaratorId, "Identifier")) {
|
||
let existing = targetScope.bindings[declaratorId.name];
|
||
|
||
if (!existing) {
|
||
existing = {
|
||
type,
|
||
refs: []
|
||
};
|
||
targetScope.bindings[declaratorId.name] = existing;
|
||
}
|
||
|
||
state.declarationBindingIds.add(declaratorId);
|
||
existing.refs.push({
|
||
type: locationType,
|
||
start: fromBabelLocation(declaratorId.loc.start, state.sourceId),
|
||
end: fromBabelLocation(declaratorId.loc.end, state.sourceId),
|
||
declaration: {
|
||
start: fromBabelLocation(declaration.loc.start, state.sourceId),
|
||
end: fromBabelLocation(declaration.loc.end, state.sourceId)
|
||
}
|
||
});
|
||
} else if (isNode(declaratorId, "ObjectPattern")) {
|
||
declaratorId.properties.forEach(prop => {
|
||
parseDeclarator(prop.value, targetScope, type, locationType, declaration, state);
|
||
});
|
||
} else if (isNode(declaratorId, "ArrayPattern")) {
|
||
declaratorId.elements.forEach(item => {
|
||
parseDeclarator(item, targetScope, type, locationType, declaration, state);
|
||
});
|
||
} else if (isNode(declaratorId, "AssignmentPattern")) {
|
||
parseDeclarator(declaratorId.left, targetScope, type, locationType, declaration, state);
|
||
} else if (isNode(declaratorId, "RestElement")) {
|
||
parseDeclarator(declaratorId.argument, targetScope, type, locationType, declaration, state);
|
||
} else if (t.isTSParameterProperty(declaratorId)) {
|
||
parseDeclarator(declaratorId.parameter, targetScope, type, locationType, declaration, state);
|
||
}
|
||
}
|
||
|
||
function isLetOrConst(node) {
|
||
return node.kind === "let" || node.kind === "const";
|
||
}
|
||
|
||
function hasLexicalDeclaration(node, parent) {
|
||
const nodes = [];
|
||
|
||
if (t.isSwitchStatement(node)) {
|
||
for (const caseNode of node.cases) {
|
||
nodes.push(...caseNode.consequent);
|
||
}
|
||
} else {
|
||
nodes.push(...node.body);
|
||
}
|
||
|
||
const isFunctionBody = t.isFunction(parent, {
|
||
body: node
|
||
});
|
||
return nodes.some(child => isLexicalVariable(child) || t.isClassDeclaration(child) || !isFunctionBody && t.isFunctionDeclaration(child));
|
||
}
|
||
|
||
function isLexicalVariable(node) {
|
||
return isNode(node, "VariableDeclaration") && isLetOrConst(node);
|
||
}
|
||
|
||
function createGlobalScope(ast, sourceId) {
|
||
const global = createTempScope("object", "Global", null, {
|
||
start: fromBabelLocation(ast.loc.start, sourceId),
|
||
end: fromBabelLocation(ast.loc.end, sourceId)
|
||
});
|
||
const lexical = createTempScope("block", "Lexical Global", global, {
|
||
start: fromBabelLocation(ast.loc.start, sourceId),
|
||
end: fromBabelLocation(ast.loc.end, sourceId)
|
||
});
|
||
return {
|
||
global,
|
||
lexical
|
||
};
|
||
}
|
||
|
||
const scopeCollectionVisitor = {
|
||
// eslint-disable-next-line complexity
|
||
enter(node, ancestors, state) {
|
||
state.scopeStack.push(state.scope);
|
||
const parentNode = ancestors.length === 0 ? null : ancestors[ancestors.length - 1].node;
|
||
|
||
if (state.inType) {
|
||
return;
|
||
}
|
||
|
||
if (t.isProgram(node)) {
|
||
const scope = pushTempScope(state, "module", "Module", {
|
||
start: fromBabelLocation(node.loc.start, state.sourceId),
|
||
end: fromBabelLocation(node.loc.end, state.sourceId)
|
||
});
|
||
scope.bindings.this = {
|
||
type: "implicit",
|
||
refs: []
|
||
};
|
||
} else if (t.isFunction(node)) {
|
||
let scope = state.scope;
|
||
|
||
if (t.isFunctionExpression(node) && isNode(node.id, "Identifier")) {
|
||
scope = pushTempScope(state, "block", "Function Expression", {
|
||
start: fromBabelLocation(node.loc.start, state.sourceId),
|
||
end: fromBabelLocation(node.loc.end, state.sourceId)
|
||
});
|
||
state.declarationBindingIds.add(node.id);
|
||
scope.bindings[node.id.name] = {
|
||
type: "const",
|
||
refs: [{
|
||
type: "fn-expr",
|
||
start: fromBabelLocation(node.id.loc.start, state.sourceId),
|
||
end: fromBabelLocation(node.id.loc.end, state.sourceId),
|
||
declaration: {
|
||
start: fromBabelLocation(node.loc.start, state.sourceId),
|
||
end: fromBabelLocation(node.loc.end, state.sourceId)
|
||
}
|
||
}]
|
||
};
|
||
}
|
||
|
||
if (t.isFunctionDeclaration(node) && isNode(node.id, "Identifier")) {
|
||
// This ignores Annex B function declaration hoisting, which
|
||
// is probably a fine assumption.
|
||
state.declarationBindingIds.add(node.id);
|
||
const refs = [{
|
||
type: "fn-decl",
|
||
start: fromBabelLocation(node.id.loc.start, state.sourceId),
|
||
end: fromBabelLocation(node.id.loc.end, state.sourceId),
|
||
declaration: {
|
||
start: fromBabelLocation(node.loc.start, state.sourceId),
|
||
end: fromBabelLocation(node.loc.end, state.sourceId)
|
||
}
|
||
}];
|
||
|
||
if (scope.type === "block") {
|
||
scope.bindings[node.id.name] = {
|
||
type: "let",
|
||
refs
|
||
};
|
||
} else {
|
||
getVarScope(scope).bindings[node.id.name] = {
|
||
type: "var",
|
||
refs
|
||
};
|
||
}
|
||
}
|
||
|
||
scope = pushTempScope(state, "function", (0, _getFunctionName.default)(node, parentNode), {
|
||
// Being at the start of a function doesn't count as
|
||
// being inside of it.
|
||
start: fromBabelLocation(node.params[0] ? node.params[0].loc.start : node.loc.start, state.sourceId),
|
||
end: fromBabelLocation(node.loc.end, state.sourceId)
|
||
});
|
||
node.params.forEach(param => parseDeclarator(param, scope, "var", "fn-param", node, state));
|
||
|
||
if (!t.isArrowFunctionExpression(node)) {
|
||
scope.bindings.this = {
|
||
type: "implicit",
|
||
refs: []
|
||
};
|
||
scope.bindings.arguments = {
|
||
type: "implicit",
|
||
refs: []
|
||
};
|
||
}
|
||
|
||
if (t.isBlockStatement(node.body) && hasLexicalDeclaration(node.body, node)) {
|
||
scope = pushTempScope(state, "function-body", "Function Body", {
|
||
start: fromBabelLocation(node.body.loc.start, state.sourceId),
|
||
end: fromBabelLocation(node.body.loc.end, state.sourceId)
|
||
});
|
||
}
|
||
} else if (t.isClass(node)) {
|
||
if (t.isIdentifier(node.id)) {
|
||
// For decorated classes, the AST considers the first the decorator
|
||
// to be the start of the class. For the purposes of mapping class
|
||
// declarations however, we really want to look for the "class Foo"
|
||
// piece. To achieve that, we estimate the location of the declaration
|
||
// instead.
|
||
let declStart = node.loc.start;
|
||
|
||
if (node.decorators && node.decorators.length > 0) {
|
||
// Estimate the location of the "class" keyword since it
|
||
// is unlikely to be a different line than the class name.
|
||
declStart = {
|
||
line: node.id.loc.start.line,
|
||
column: node.id.loc.start.column - "class ".length
|
||
};
|
||
}
|
||
|
||
const declaration = {
|
||
start: fromBabelLocation(declStart, state.sourceId),
|
||
end: fromBabelLocation(node.loc.end, state.sourceId)
|
||
};
|
||
|
||
if (t.isClassDeclaration(node)) {
|
||
state.declarationBindingIds.add(node.id);
|
||
state.scope.bindings[node.id.name] = {
|
||
type: "let",
|
||
refs: [{
|
||
type: "class-decl",
|
||
start: fromBabelLocation(node.id.loc.start, state.sourceId),
|
||
end: fromBabelLocation(node.id.loc.end, state.sourceId),
|
||
declaration
|
||
}]
|
||
};
|
||
}
|
||
|
||
const scope = pushTempScope(state, "block", "Class", {
|
||
start: fromBabelLocation(node.loc.start, state.sourceId),
|
||
end: fromBabelLocation(node.loc.end, state.sourceId)
|
||
});
|
||
state.declarationBindingIds.add(node.id);
|
||
scope.bindings[node.id.name] = {
|
||
type: "const",
|
||
refs: [{
|
||
type: "class-inner",
|
||
start: fromBabelLocation(node.id.loc.start, state.sourceId),
|
||
end: fromBabelLocation(node.id.loc.end, state.sourceId),
|
||
declaration
|
||
}]
|
||
};
|
||
}
|
||
} else if (t.isForXStatement(node) || t.isForStatement(node)) {
|
||
const init = node.init || node.left;
|
||
|
||
if (isNode(init, "VariableDeclaration") && isLetOrConst(init)) {
|
||
// Debugger will create new lexical environment for the for.
|
||
pushTempScope(state, "block", "For", {
|
||
// Being at the start of a for loop doesn't count as
|
||
// being inside it.
|
||
start: fromBabelLocation(init.loc.start, state.sourceId),
|
||
end: fromBabelLocation(node.loc.end, state.sourceId)
|
||
});
|
||
}
|
||
} else if (t.isCatchClause(node)) {
|
||
const scope = pushTempScope(state, "block", "Catch", {
|
||
start: fromBabelLocation(node.loc.start, state.sourceId),
|
||
end: fromBabelLocation(node.loc.end, state.sourceId)
|
||
});
|
||
parseDeclarator(node.param, scope, "var", "catch", node, state);
|
||
} else if (t.isBlockStatement(node) && // Function body's are handled in the function logic above.
|
||
!t.isFunction(parentNode) && hasLexicalDeclaration(node, parentNode)) {
|
||
// Debugger will create new lexical environment for the block.
|
||
pushTempScope(state, "block", "Block", {
|
||
start: fromBabelLocation(node.loc.start, state.sourceId),
|
||
end: fromBabelLocation(node.loc.end, state.sourceId)
|
||
});
|
||
} else if (t.isVariableDeclaration(node) && (node.kind === "var" || // Lexical declarations in for statements are handled above.
|
||
!t.isForStatement(parentNode, {
|
||
init: node
|
||
}) || !t.isForXStatement(parentNode, {
|
||
left: node
|
||
}))) {
|
||
// Finds right lexical environment
|
||
const hoistAt = !isLetOrConst(node) ? getVarScope(state.scope) : state.scope;
|
||
node.declarations.forEach(declarator => {
|
||
parseDeclarator(declarator.id, hoistAt, node.kind, node.kind, node, state);
|
||
});
|
||
} else if (t.isImportDeclaration(node) && (!node.importKind || node.importKind === "value")) {
|
||
node.specifiers.forEach(spec => {
|
||
if (spec.importKind && spec.importKind !== "value") {
|
||
return;
|
||
}
|
||
|
||
if (t.isImportNamespaceSpecifier(spec)) {
|
||
state.declarationBindingIds.add(spec.local);
|
||
state.scope.bindings[spec.local.name] = {
|
||
// Imported namespaces aren't live import bindings, they are
|
||
// just normal const bindings.
|
||
type: "const",
|
||
refs: [{
|
||
type: "import-ns-decl",
|
||
start: fromBabelLocation(spec.local.loc.start, state.sourceId),
|
||
end: fromBabelLocation(spec.local.loc.end, state.sourceId),
|
||
declaration: {
|
||
start: fromBabelLocation(node.loc.start, state.sourceId),
|
||
end: fromBabelLocation(node.loc.end, state.sourceId)
|
||
}
|
||
}]
|
||
};
|
||
} else {
|
||
state.declarationBindingIds.add(spec.local);
|
||
state.scope.bindings[spec.local.name] = {
|
||
type: "import",
|
||
refs: [{
|
||
type: "import-decl",
|
||
start: fromBabelLocation(spec.local.loc.start, state.sourceId),
|
||
end: fromBabelLocation(spec.local.loc.end, state.sourceId),
|
||
importName: t.isImportDefaultSpecifier(spec) ? "default" : spec.imported.name,
|
||
declaration: {
|
||
start: fromBabelLocation(node.loc.start, state.sourceId),
|
||
end: fromBabelLocation(node.loc.end, state.sourceId)
|
||
}
|
||
}]
|
||
};
|
||
}
|
||
});
|
||
} else if (t.isTSEnumDeclaration(node)) {
|
||
state.declarationBindingIds.add(node.id);
|
||
state.scope.bindings[node.id.name] = {
|
||
type: "const",
|
||
refs: [{
|
||
type: "ts-enum-decl",
|
||
start: fromBabelLocation(node.id.loc.start, state.sourceId),
|
||
end: fromBabelLocation(node.id.loc.end, state.sourceId),
|
||
declaration: {
|
||
start: fromBabelLocation(node.loc.start, state.sourceId),
|
||
end: fromBabelLocation(node.loc.end, state.sourceId)
|
||
}
|
||
}]
|
||
};
|
||
} else if (t.isTSModuleDeclaration(node)) {
|
||
state.declarationBindingIds.add(node.id);
|
||
state.scope.bindings[node.id.name] = {
|
||
type: "const",
|
||
refs: [{
|
||
type: "ts-namespace-decl",
|
||
start: fromBabelLocation(node.id.loc.start, state.sourceId),
|
||
end: fromBabelLocation(node.id.loc.end, state.sourceId),
|
||
declaration: {
|
||
start: fromBabelLocation(node.loc.start, state.sourceId),
|
||
end: fromBabelLocation(node.loc.end, state.sourceId)
|
||
}
|
||
}]
|
||
};
|
||
} else if (t.isTSModuleBlock(node)) {
|
||
pushTempScope(state, "block", "TypeScript Namespace", {
|
||
start: fromBabelLocation(node.loc.start, state.sourceId),
|
||
end: fromBabelLocation(node.loc.end, state.sourceId)
|
||
});
|
||
} else if (t.isIdentifier(node) && t.isReferenced(node, parentNode) && // Babel doesn't cover this in 'isReferenced' yet, but it should
|
||
// eventually.
|
||
!t.isTSEnumMember(parentNode, {
|
||
id: node
|
||
}) && !t.isTSModuleDeclaration(parentNode, {
|
||
id: node
|
||
}) && // isReferenced above fails to see `var { foo } = ...` as a non-reference
|
||
// because the direct parent is not enough to know that the pattern is
|
||
// used within a variable declaration.
|
||
!state.declarationBindingIds.has(node)) {
|
||
let freeVariables = state.freeVariables.get(node.name);
|
||
|
||
if (!freeVariables) {
|
||
freeVariables = [];
|
||
state.freeVariables.set(node.name, freeVariables);
|
||
}
|
||
|
||
freeVariables.push({
|
||
type: "ref",
|
||
start: fromBabelLocation(node.loc.start, state.sourceId),
|
||
end: fromBabelLocation(node.loc.end, state.sourceId),
|
||
meta: buildMetaBindings(state.sourceId, node, ancestors)
|
||
});
|
||
} else if (isOpeningJSXIdentifier(node, ancestors)) {
|
||
let freeVariables = state.freeVariables.get(node.name);
|
||
|
||
if (!freeVariables) {
|
||
freeVariables = [];
|
||
state.freeVariables.set(node.name, freeVariables);
|
||
}
|
||
|
||
freeVariables.push({
|
||
type: "ref",
|
||
start: fromBabelLocation(node.loc.start, state.sourceId),
|
||
end: fromBabelLocation(node.loc.end, state.sourceId),
|
||
meta: buildMetaBindings(state.sourceId, node, ancestors)
|
||
});
|
||
} else if (t.isThisExpression(node)) {
|
||
let freeVariables = state.freeVariables.get("this");
|
||
|
||
if (!freeVariables) {
|
||
freeVariables = [];
|
||
state.freeVariables.set("this", freeVariables);
|
||
}
|
||
|
||
freeVariables.push({
|
||
type: "ref",
|
||
start: fromBabelLocation(node.loc.start, state.sourceId),
|
||
end: fromBabelLocation(node.loc.end, state.sourceId),
|
||
meta: buildMetaBindings(state.sourceId, node, ancestors)
|
||
});
|
||
} else if (t.isClassProperty(parentNode, {
|
||
value: node
|
||
})) {
|
||
const scope = pushTempScope(state, "function", "Class Field", {
|
||
start: fromBabelLocation(node.loc.start, state.sourceId),
|
||
end: fromBabelLocation(node.loc.end, state.sourceId)
|
||
});
|
||
scope.bindings.this = {
|
||
type: "implicit",
|
||
refs: []
|
||
};
|
||
scope.bindings.arguments = {
|
||
type: "implicit",
|
||
refs: []
|
||
};
|
||
} else if (t.isSwitchStatement(node) && hasLexicalDeclaration(node, parentNode)) {
|
||
pushTempScope(state, "block", "Switch", {
|
||
start: fromBabelLocation(node.loc.start, state.sourceId),
|
||
end: fromBabelLocation(node.loc.end, state.sourceId)
|
||
});
|
||
}
|
||
|
||
if ( // In general Flow expressions are deleted, so they can't contain
|
||
// runtime bindings, but typecasts are the one exception there.
|
||
t.isFlow(node) && !t.isTypeCastExpression(node) || // In general TS items are deleted, but TS has a few wrapper node
|
||
// types that can contain general JS expressions.
|
||
node.type.startsWith("TS") && !t.isTSTypeAssertion(node) && !t.isTSAsExpression(node) && !t.isTSNonNullExpression(node) && !t.isTSModuleDeclaration(node) && !t.isTSModuleBlock(node) && !t.isTSParameterProperty(node) && !t.isTSExportAssignment(node)) {
|
||
// Flag this node as a root "type" node. All items inside of this
|
||
// will be skipped entirely.
|
||
state.inType = node;
|
||
}
|
||
},
|
||
|
||
exit(node, ancestors, state) {
|
||
const currentScope = state.scope;
|
||
const parentScope = state.scopeStack.pop();
|
||
|
||
if (!parentScope) {
|
||
throw new Error("Assertion failure - unsynchronized pop");
|
||
}
|
||
|
||
state.scope = parentScope; // It is possible, as in the case of function expressions, that a single
|
||
// node has added multiple scopes, so we need to traverse upward here
|
||
// rather than jumping stright to 'parentScope'.
|
||
|
||
for (let scope = currentScope; scope && scope !== parentScope; scope = scope.parent) {
|
||
const freeVariables = state.freeVariables;
|
||
state.freeVariables = state.freeVariableStack.pop();
|
||
const parentFreeVariables = state.freeVariables; // Match up any free variables that match this scope's bindings and
|
||
// merge then into the refs.
|
||
|
||
for (const key of Object.keys(scope.bindings)) {
|
||
const binding = scope.bindings[key];
|
||
const freeVars = freeVariables.get(key);
|
||
|
||
if (freeVars) {
|
||
binding.refs.push(...freeVars);
|
||
freeVariables.delete(key);
|
||
}
|
||
} // Move any undeclared references in this scope into the parent for
|
||
// processing in higher scopes.
|
||
|
||
|
||
for (const [key, value] of freeVariables) {
|
||
let refs = parentFreeVariables.get(key);
|
||
|
||
if (!refs) {
|
||
refs = [];
|
||
parentFreeVariables.set(key, refs);
|
||
}
|
||
|
||
refs.push(...value);
|
||
}
|
||
}
|
||
|
||
if (state.inType === node) {
|
||
state.inType = null;
|
||
}
|
||
}
|
||
|
||
};
|
||
|
||
function isOpeningJSXIdentifier(node, ancestors) {
|
||
if (!t.isJSXIdentifier(node)) {
|
||
return false;
|
||
}
|
||
|
||
for (let i = ancestors.length - 1; i >= 0; i--) {
|
||
const {
|
||
node: parent,
|
||
key
|
||
} = ancestors[i];
|
||
|
||
if (t.isJSXOpeningElement(parent) && key === "name") {
|
||
return true;
|
||
} else if (!t.isJSXMemberExpression(parent) || key !== "object") {
|
||
break;
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
function buildMetaBindings(sourceId, node, ancestors, parentIndex = ancestors.length - 1) {
|
||
if (parentIndex <= 1) {
|
||
return null;
|
||
}
|
||
|
||
const parent = ancestors[parentIndex].node;
|
||
const grandparent = ancestors[parentIndex - 1].node; // Consider "0, foo" to be equivalent to "foo".
|
||
|
||
if (t.isSequenceExpression(parent) && parent.expressions.length === 2 && t.isNumericLiteral(parent.expressions[0]) && parent.expressions[1] === node) {
|
||
let start = parent.loc.start;
|
||
let end = parent.loc.end;
|
||
|
||
if (t.isCallExpression(grandparent, {
|
||
callee: parent
|
||
})) {
|
||
// Attempt to expand the range around parentheses, e.g.
|
||
// (0, foo.bar)()
|
||
start = grandparent.loc.start;
|
||
end = Object.assign({}, end);
|
||
end.column += 1;
|
||
}
|
||
|
||
return {
|
||
type: "inherit",
|
||
start: fromBabelLocation(start, sourceId),
|
||
end: fromBabelLocation(end, sourceId),
|
||
parent: buildMetaBindings(sourceId, parent, ancestors, parentIndex - 1)
|
||
};
|
||
} // Consider "Object(foo)", and "__webpack_require__.i(foo)" to be
|
||
// equivalent to "foo" since they are essentially identity functions.
|
||
|
||
|
||
if (t.isCallExpression(parent) && (t.isIdentifier(parent.callee, {
|
||
name: "Object"
|
||
}) || t.isMemberExpression(parent.callee, {
|
||
computed: false
|
||
}) && t.isIdentifier(parent.callee.object, {
|
||
name: "__webpack_require__"
|
||
}) && t.isIdentifier(parent.callee.property, {
|
||
name: "i"
|
||
})) && parent.arguments.length === 1 && parent.arguments[0] === node) {
|
||
return {
|
||
type: "inherit",
|
||
start: fromBabelLocation(parent.loc.start, sourceId),
|
||
end: fromBabelLocation(parent.loc.end, sourceId),
|
||
parent: buildMetaBindings(sourceId, parent, ancestors, parentIndex - 1)
|
||
};
|
||
}
|
||
|
||
if (t.isMemberExpression(parent, {
|
||
object: node
|
||
})) {
|
||
if (parent.computed) {
|
||
if (t.isStringLiteral(parent.property)) {
|
||
return {
|
||
type: "member",
|
||
start: fromBabelLocation(parent.loc.start, sourceId),
|
||
end: fromBabelLocation(parent.loc.end, sourceId),
|
||
property: parent.property.value,
|
||
parent: buildMetaBindings(sourceId, parent, ancestors, parentIndex - 1)
|
||
};
|
||
}
|
||
} else {
|
||
return {
|
||
type: "member",
|
||
start: fromBabelLocation(parent.loc.start, sourceId),
|
||
end: fromBabelLocation(parent.loc.end, sourceId),
|
||
property: parent.property.name,
|
||
parent: buildMetaBindings(sourceId, parent, ancestors, parentIndex - 1)
|
||
};
|
||
}
|
||
}
|
||
|
||
if (t.isCallExpression(parent, {
|
||
callee: node
|
||
}) && parent.arguments.length == 0) {
|
||
return {
|
||
type: "call",
|
||
start: fromBabelLocation(parent.loc.start, sourceId),
|
||
end: fromBabelLocation(parent.loc.end, sourceId),
|
||
parent: buildMetaBindings(sourceId, parent, ancestors, parentIndex - 1)
|
||
};
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
function looksLikeCommonJS(rootScope) {
|
||
const hasRefs = name => rootScope.bindings[name] && rootScope.bindings[name].refs.length > 0;
|
||
|
||
return hasRefs("__dirname") || hasRefs("__filename") || hasRefs("require") || hasRefs("exports") || hasRefs("module");
|
||
}
|
||
|
||
function stripModuleScope(rootScope) {
|
||
const rootLexicalScope = rootScope.children[0];
|
||
const moduleScope = rootLexicalScope.children[0];
|
||
|
||
if (moduleScope.type !== "module") {
|
||
throw new Error("Assertion failure - should be module");
|
||
}
|
||
|
||
Object.keys(moduleScope.bindings).forEach(name => {
|
||
const binding = moduleScope.bindings[name];
|
||
|
||
if (binding.type === "let" || binding.type === "const") {
|
||
rootLexicalScope.bindings[name] = binding;
|
||
} else {
|
||
rootScope.bindings[name] = binding;
|
||
}
|
||
});
|
||
rootLexicalScope.children = moduleScope.children;
|
||
rootLexicalScope.children.forEach(child => {
|
||
child.parent = rootLexicalScope;
|
||
});
|
||
}
|
||
|
||
/***/ }),
|
||
/* 350 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
|
||
var _findIndex = _interopRequireDefault(__webpack_require__(354));
|
||
|
||
var _findLastIndex = _interopRequireDefault(__webpack_require__(371));
|
||
|
||
var _contains = __webpack_require__(169);
|
||
|
||
var _getSymbols = __webpack_require__(117);
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||
function findSymbols(source) {
|
||
const {
|
||
functions,
|
||
comments
|
||
} = (0, _getSymbols.getSymbols)(source);
|
||
return {
|
||
functions,
|
||
comments
|
||
};
|
||
}
|
||
/**
|
||
* Returns the location for a given function path. If the path represents a
|
||
* function declaration, the location will begin after the function identifier
|
||
* but before the function parameters.
|
||
*/
|
||
|
||
|
||
function getLocation(func) {
|
||
var _func$identifier, _func$identifier$loc;
|
||
|
||
const location = { ...func.location
|
||
}; // if the function has an identifier, start the block after it so the
|
||
// identifier is included in the "scope" of its parent
|
||
|
||
const identifierEnd = func === null || func === void 0 ? void 0 : (_func$identifier = func.identifier) === null || _func$identifier === void 0 ? void 0 : (_func$identifier$loc = _func$identifier.loc) === null || _func$identifier$loc === void 0 ? void 0 : _func$identifier$loc.end;
|
||
|
||
if (identifierEnd) {
|
||
location.start = identifierEnd;
|
||
}
|
||
|
||
return location;
|
||
}
|
||
/**
|
||
* Find the nearest location containing the input position and
|
||
* return new locations without inner locations under that nearest location
|
||
*
|
||
* @param locations Notice! The locations MUST be sorted by `sortByStart`
|
||
* so that we can do linear time complexity operation.
|
||
*/
|
||
|
||
|
||
function removeInnerLocations(locations, position) {
|
||
// First, let's find the nearest position-enclosing function location,
|
||
// which is to find the last location enclosing the position.
|
||
const newLocs = locations.slice();
|
||
const parentIndex = (0, _findLastIndex.default)(newLocs, loc => (0, _contains.containsPosition)(loc, position));
|
||
|
||
if (parentIndex < 0) {
|
||
return newLocs;
|
||
} // Second, from the nearest location, loop locations again, stop looping
|
||
// once seeing the 1st location not enclosed by the nearest location
|
||
// to find the last inner locations inside the nearest location.
|
||
|
||
|
||
const innerStartIndex = parentIndex + 1;
|
||
const parentLoc = newLocs[parentIndex];
|
||
const outerBoundaryIndex = (0, _findIndex.default)(newLocs, loc => !(0, _contains.containsLocation)(parentLoc, loc), innerStartIndex);
|
||
const innerBoundaryIndex = outerBoundaryIndex < 0 ? newLocs.length - 1 : outerBoundaryIndex - 1; // Third, remove those inner functions
|
||
|
||
newLocs.splice(innerStartIndex, innerBoundaryIndex - parentIndex);
|
||
return newLocs;
|
||
}
|
||
/**
|
||
* Return an new locations array which excludes
|
||
* items that are completely enclosed by another location in the input locations
|
||
*
|
||
* @param locations Notice! The locations MUST be sorted by `sortByStart`
|
||
* so that we can do linear time complexity operation.
|
||
*/
|
||
|
||
|
||
function removeOverlaps(locations) {
|
||
if (locations.length == 0) {
|
||
return [];
|
||
}
|
||
|
||
const firstParent = locations[0];
|
||
return locations.reduce(deduplicateNode, [firstParent]);
|
||
}
|
||
|
||
function deduplicateNode(nodes, location) {
|
||
const parent = nodes[nodes.length - 1];
|
||
|
||
if (!(0, _contains.containsLocation)(parent, location)) {
|
||
nodes.push(location);
|
||
}
|
||
|
||
return nodes;
|
||
}
|
||
/**
|
||
* Sorts an array of locations by start position
|
||
*/
|
||
|
||
|
||
function sortByStart(a, b) {
|
||
if (a.start.line < b.start.line) {
|
||
return -1;
|
||
} else if (a.start.line === b.start.line) {
|
||
return a.start.column - b.start.column;
|
||
}
|
||
|
||
return 1;
|
||
}
|
||
/**
|
||
* Returns an array of locations that are considered out of scope for the given
|
||
* location.
|
||
*/
|
||
|
||
|
||
function findOutOfScopeLocations(sourceId, position) {
|
||
const {
|
||
functions,
|
||
comments
|
||
} = findSymbols(sourceId);
|
||
const commentLocations = comments.map(c => c.location);
|
||
let locations = functions.map(getLocation).concat(commentLocations).sort(sortByStart); // Must remove inner locations then filter, otherwise,
|
||
// we will mis-judge in-scope inner locations as out of scope.
|
||
|
||
locations = removeInnerLocations(locations, position).filter(loc => !(0, _contains.containsPosition)(loc, position));
|
||
return removeOverlaps(locations);
|
||
}
|
||
|
||
var _default = findOutOfScopeLocations;
|
||
exports.default = _default;
|
||
|
||
/***/ }),
|
||
/* 351 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var memoizeCapped = __webpack_require__(352);
|
||
|
||
/** Used to match property names within property paths. */
|
||
var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
|
||
|
||
/** Used to match backslashes in property paths. */
|
||
var reEscapeChar = /\\(\\)?/g;
|
||
|
||
/**
|
||
* Converts `string` to a property path array.
|
||
*
|
||
* @private
|
||
* @param {string} string The string to convert.
|
||
* @returns {Array} Returns the property path array.
|
||
*/
|
||
var stringToPath = memoizeCapped(function(string) {
|
||
var result = [];
|
||
if (string.charCodeAt(0) === 46 /* . */) {
|
||
result.push('');
|
||
}
|
||
string.replace(rePropName, function(match, number, quote, subString) {
|
||
result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
|
||
});
|
||
return result;
|
||
});
|
||
|
||
module.exports = stringToPath;
|
||
|
||
|
||
/***/ }),
|
||
/* 352 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var memoize = __webpack_require__(353);
|
||
|
||
/** Used as the maximum memoize cache size. */
|
||
var MAX_MEMOIZE_SIZE = 500;
|
||
|
||
/**
|
||
* A specialized version of `_.memoize` which clears the memoized function's
|
||
* cache when it exceeds `MAX_MEMOIZE_SIZE`.
|
||
*
|
||
* @private
|
||
* @param {Function} func The function to have its output memoized.
|
||
* @returns {Function} Returns the new memoized function.
|
||
*/
|
||
function memoizeCapped(func) {
|
||
var result = memoize(func, function(key) {
|
||
if (cache.size === MAX_MEMOIZE_SIZE) {
|
||
cache.clear();
|
||
}
|
||
return key;
|
||
});
|
||
|
||
var cache = result.cache;
|
||
return result;
|
||
}
|
||
|
||
module.exports = memoizeCapped;
|
||
|
||
|
||
/***/ }),
|
||
/* 353 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var MapCache = __webpack_require__(73);
|
||
|
||
/** Error message constants. */
|
||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||
|
||
/**
|
||
* Creates a function that memoizes the result of `func`. If `resolver` is
|
||
* provided, it determines the cache key for storing the result based on the
|
||
* arguments provided to the memoized function. By default, the first argument
|
||
* provided to the memoized function is used as the map cache key. The `func`
|
||
* is invoked with the `this` binding of the memoized function.
|
||
*
|
||
* **Note:** The cache is exposed as the `cache` property on the memoized
|
||
* function. Its creation may be customized by replacing the `_.memoize.Cache`
|
||
* constructor with one whose instances implement the
|
||
* [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
|
||
* method interface of `clear`, `delete`, `get`, `has`, and `set`.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 0.1.0
|
||
* @category Function
|
||
* @param {Function} func The function to have its output memoized.
|
||
* @param {Function} [resolver] The function to resolve the cache key.
|
||
* @returns {Function} Returns the new memoized function.
|
||
* @example
|
||
*
|
||
* var object = { 'a': 1, 'b': 2 };
|
||
* var other = { 'c': 3, 'd': 4 };
|
||
*
|
||
* var values = _.memoize(_.values);
|
||
* values(object);
|
||
* // => [1, 2]
|
||
*
|
||
* values(other);
|
||
* // => [3, 4]
|
||
*
|
||
* object.a = 2;
|
||
* values(object);
|
||
* // => [1, 2]
|
||
*
|
||
* // Modify the result cache.
|
||
* values.cache.set(object, ['a', 'b']);
|
||
* values(object);
|
||
* // => ['a', 'b']
|
||
*
|
||
* // Replace `_.memoize.Cache`.
|
||
* _.memoize.Cache = WeakMap;
|
||
*/
|
||
function memoize(func, resolver) {
|
||
if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
|
||
throw new TypeError(FUNC_ERROR_TEXT);
|
||
}
|
||
var memoized = function() {
|
||
var args = arguments,
|
||
key = resolver ? resolver.apply(this, args) : args[0],
|
||
cache = memoized.cache;
|
||
|
||
if (cache.has(key)) {
|
||
return cache.get(key);
|
||
}
|
||
var result = func.apply(this, args);
|
||
memoized.cache = cache.set(key, result) || cache;
|
||
return result;
|
||
};
|
||
memoized.cache = new (memoize.Cache || MapCache);
|
||
return memoized;
|
||
}
|
||
|
||
// Expose `MapCache`.
|
||
memoize.Cache = MapCache;
|
||
|
||
module.exports = memoize;
|
||
|
||
|
||
/***/ }),
|
||
/* 354 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var baseFindIndex = __webpack_require__(86),
|
||
baseIteratee = __webpack_require__(164),
|
||
toInteger = __webpack_require__(56);
|
||
|
||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||
var nativeMax = Math.max;
|
||
|
||
/**
|
||
* This method is like `_.find` except that it returns the index of the first
|
||
* element `predicate` returns truthy for instead of the element itself.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 1.1.0
|
||
* @category Array
|
||
* @param {Array} array The array to inspect.
|
||
* @param {Function} [predicate=_.identity] The function invoked per iteration.
|
||
* @param {number} [fromIndex=0] The index to search from.
|
||
* @returns {number} Returns the index of the found element, else `-1`.
|
||
* @example
|
||
*
|
||
* var users = [
|
||
* { 'user': 'barney', 'active': false },
|
||
* { 'user': 'fred', 'active': false },
|
||
* { 'user': 'pebbles', 'active': true }
|
||
* ];
|
||
*
|
||
* _.findIndex(users, function(o) { return o.user == 'barney'; });
|
||
* // => 0
|
||
*
|
||
* // The `_.matches` iteratee shorthand.
|
||
* _.findIndex(users, { 'user': 'fred', 'active': false });
|
||
* // => 1
|
||
*
|
||
* // The `_.matchesProperty` iteratee shorthand.
|
||
* _.findIndex(users, ['active', false]);
|
||
* // => 0
|
||
*
|
||
* // The `_.property` iteratee shorthand.
|
||
* _.findIndex(users, 'active');
|
||
* // => 2
|
||
*/
|
||
function findIndex(array, predicate, fromIndex) {
|
||
var length = array == null ? 0 : array.length;
|
||
if (!length) {
|
||
return -1;
|
||
}
|
||
var index = fromIndex == null ? 0 : toInteger(fromIndex);
|
||
if (index < 0) {
|
||
index = nativeMax(length + index, 0);
|
||
}
|
||
return baseFindIndex(array, baseIteratee(predicate, 3), index);
|
||
}
|
||
|
||
module.exports = findIndex;
|
||
|
||
|
||
/***/ }),
|
||
/* 355 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var baseIsMatch = __webpack_require__(356),
|
||
getMatchData = __webpack_require__(362),
|
||
matchesStrictComparable = __webpack_require__(168);
|
||
|
||
/**
|
||
* The base implementation of `_.matches` which doesn't clone `source`.
|
||
*
|
||
* @private
|
||
* @param {Object} source The object of property values to match.
|
||
* @returns {Function} Returns the new spec function.
|
||
*/
|
||
function baseMatches(source) {
|
||
var matchData = getMatchData(source);
|
||
if (matchData.length == 1 && matchData[0][2]) {
|
||
return matchesStrictComparable(matchData[0][0], matchData[0][1]);
|
||
}
|
||
return function(object) {
|
||
return object === source || baseIsMatch(object, source, matchData);
|
||
};
|
||
}
|
||
|
||
module.exports = baseMatches;
|
||
|
||
|
||
/***/ }),
|
||
/* 356 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var Stack = __webpack_require__(69),
|
||
baseIsEqual = __webpack_require__(165);
|
||
|
||
/** Used to compose bitmasks for value comparisons. */
|
||
var COMPARE_PARTIAL_FLAG = 1,
|
||
COMPARE_UNORDERED_FLAG = 2;
|
||
|
||
/**
|
||
* The base implementation of `_.isMatch` without support for iteratee shorthands.
|
||
*
|
||
* @private
|
||
* @param {Object} object The object to inspect.
|
||
* @param {Object} source The object of property values to match.
|
||
* @param {Array} matchData The property names, values, and compare flags to match.
|
||
* @param {Function} [customizer] The function to customize comparisons.
|
||
* @returns {boolean} Returns `true` if `object` is a match, else `false`.
|
||
*/
|
||
function baseIsMatch(object, source, matchData, customizer) {
|
||
var index = matchData.length,
|
||
length = index,
|
||
noCustomizer = !customizer;
|
||
|
||
if (object == null) {
|
||
return !length;
|
||
}
|
||
object = Object(object);
|
||
while (index--) {
|
||
var data = matchData[index];
|
||
if ((noCustomizer && data[2])
|
||
? data[1] !== object[data[0]]
|
||
: !(data[0] in object)
|
||
) {
|
||
return false;
|
||
}
|
||
}
|
||
while (++index < length) {
|
||
data = matchData[index];
|
||
var key = data[0],
|
||
objValue = object[key],
|
||
srcValue = data[1];
|
||
|
||
if (noCustomizer && data[2]) {
|
||
if (objValue === undefined && !(key in object)) {
|
||
return false;
|
||
}
|
||
} else {
|
||
var stack = new Stack;
|
||
if (customizer) {
|
||
var result = customizer(objValue, srcValue, key, object, source, stack);
|
||
}
|
||
if (!(result === undefined
|
||
? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
|
||
: result
|
||
)) {
|
||
return false;
|
||
}
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
|
||
module.exports = baseIsMatch;
|
||
|
||
|
||
/***/ }),
|
||
/* 357 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var Stack = __webpack_require__(69),
|
||
equalArrays = __webpack_require__(166),
|
||
equalByTag = __webpack_require__(359),
|
||
equalObjects = __webpack_require__(361),
|
||
getTag = __webpack_require__(29),
|
||
isArray = __webpack_require__(9),
|
||
isBuffer = __webpack_require__(48),
|
||
isTypedArray = __webpack_require__(76);
|
||
|
||
/** Used to compose bitmasks for value comparisons. */
|
||
var COMPARE_PARTIAL_FLAG = 1;
|
||
|
||
/** `Object#toString` result references. */
|
||
var argsTag = '[object Arguments]',
|
||
arrayTag = '[object Array]',
|
||
objectTag = '[object Object]';
|
||
|
||
/** Used for built-in method references. */
|
||
var objectProto = Object.prototype;
|
||
|
||
/** Used to check objects for own properties. */
|
||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||
|
||
/**
|
||
* A specialized version of `baseIsEqual` for arrays and objects which performs
|
||
* deep comparisons and tracks traversed objects enabling objects with circular
|
||
* references to be compared.
|
||
*
|
||
* @private
|
||
* @param {Object} object The object to compare.
|
||
* @param {Object} other The other object to compare.
|
||
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
||
* @param {Function} customizer The function to customize comparisons.
|
||
* @param {Function} equalFunc The function to determine equivalents of values.
|
||
* @param {Object} [stack] Tracks traversed `object` and `other` objects.
|
||
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
||
*/
|
||
function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
|
||
var objIsArr = isArray(object),
|
||
othIsArr = isArray(other),
|
||
objTag = objIsArr ? arrayTag : getTag(object),
|
||
othTag = othIsArr ? arrayTag : getTag(other);
|
||
|
||
objTag = objTag == argsTag ? objectTag : objTag;
|
||
othTag = othTag == argsTag ? objectTag : othTag;
|
||
|
||
var objIsObj = objTag == objectTag,
|
||
othIsObj = othTag == objectTag,
|
||
isSameTag = objTag == othTag;
|
||
|
||
if (isSameTag && isBuffer(object)) {
|
||
if (!isBuffer(other)) {
|
||
return false;
|
||
}
|
||
objIsArr = true;
|
||
objIsObj = false;
|
||
}
|
||
if (isSameTag && !objIsObj) {
|
||
stack || (stack = new Stack);
|
||
return (objIsArr || isTypedArray(object))
|
||
? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
|
||
: equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
|
||
}
|
||
if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
|
||
var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
|
||
othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
|
||
|
||
if (objIsWrapped || othIsWrapped) {
|
||
var objUnwrapped = objIsWrapped ? object.value() : object,
|
||
othUnwrapped = othIsWrapped ? other.value() : other;
|
||
|
||
stack || (stack = new Stack);
|
||
return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
|
||
}
|
||
}
|
||
if (!isSameTag) {
|
||
return false;
|
||
}
|
||
stack || (stack = new Stack);
|
||
return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
|
||
}
|
||
|
||
module.exports = baseIsEqualDeep;
|
||
|
||
|
||
/***/ }),
|
||
/* 358 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* A specialized version of `_.some` for arrays without support for iteratee
|
||
* shorthands.
|
||
*
|
||
* @private
|
||
* @param {Array} [array] The array to iterate over.
|
||
* @param {Function} predicate The function invoked per iteration.
|
||
* @returns {boolean} Returns `true` if any element passes the predicate check,
|
||
* else `false`.
|
||
*/
|
||
function arraySome(array, predicate) {
|
||
var index = -1,
|
||
length = array == null ? 0 : array.length;
|
||
|
||
while (++index < length) {
|
||
if (predicate(array[index], index, array)) {
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
module.exports = arraySome;
|
||
|
||
|
||
/***/ }),
|
||
/* 359 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var Symbol = __webpack_require__(19),
|
||
Uint8Array = __webpack_require__(134),
|
||
eq = __webpack_require__(42),
|
||
equalArrays = __webpack_require__(166),
|
||
mapToArray = __webpack_require__(360),
|
||
setToArray = __webpack_require__(87);
|
||
|
||
/** Used to compose bitmasks for value comparisons. */
|
||
var COMPARE_PARTIAL_FLAG = 1,
|
||
COMPARE_UNORDERED_FLAG = 2;
|
||
|
||
/** `Object#toString` result references. */
|
||
var boolTag = '[object Boolean]',
|
||
dateTag = '[object Date]',
|
||
errorTag = '[object Error]',
|
||
mapTag = '[object Map]',
|
||
numberTag = '[object Number]',
|
||
regexpTag = '[object RegExp]',
|
||
setTag = '[object Set]',
|
||
stringTag = '[object String]',
|
||
symbolTag = '[object Symbol]';
|
||
|
||
var arrayBufferTag = '[object ArrayBuffer]',
|
||
dataViewTag = '[object DataView]';
|
||
|
||
/** Used to convert symbols to primitives and strings. */
|
||
var symbolProto = Symbol ? Symbol.prototype : undefined,
|
||
symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
|
||
|
||
/**
|
||
* A specialized version of `baseIsEqualDeep` for comparing objects of
|
||
* the same `toStringTag`.
|
||
*
|
||
* **Note:** This function only supports comparing values with tags of
|
||
* `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
|
||
*
|
||
* @private
|
||
* @param {Object} object The object to compare.
|
||
* @param {Object} other The other object to compare.
|
||
* @param {string} tag The `toStringTag` of the objects to compare.
|
||
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
||
* @param {Function} customizer The function to customize comparisons.
|
||
* @param {Function} equalFunc The function to determine equivalents of values.
|
||
* @param {Object} stack Tracks traversed `object` and `other` objects.
|
||
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
||
*/
|
||
function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
|
||
switch (tag) {
|
||
case dataViewTag:
|
||
if ((object.byteLength != other.byteLength) ||
|
||
(object.byteOffset != other.byteOffset)) {
|
||
return false;
|
||
}
|
||
object = object.buffer;
|
||
other = other.buffer;
|
||
|
||
case arrayBufferTag:
|
||
if ((object.byteLength != other.byteLength) ||
|
||
!equalFunc(new Uint8Array(object), new Uint8Array(other))) {
|
||
return false;
|
||
}
|
||
return true;
|
||
|
||
case boolTag:
|
||
case dateTag:
|
||
case numberTag:
|
||
// Coerce booleans to `1` or `0` and dates to milliseconds.
|
||
// Invalid dates are coerced to `NaN`.
|
||
return eq(+object, +other);
|
||
|
||
case errorTag:
|
||
return object.name == other.name && object.message == other.message;
|
||
|
||
case regexpTag:
|
||
case stringTag:
|
||
// Coerce regexes to strings and treat strings, primitives and objects,
|
||
// as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
|
||
// for more details.
|
||
return object == (other + '');
|
||
|
||
case mapTag:
|
||
var convert = mapToArray;
|
||
|
||
case setTag:
|
||
var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
|
||
convert || (convert = setToArray);
|
||
|
||
if (object.size != other.size && !isPartial) {
|
||
return false;
|
||
}
|
||
// Assume cyclic values are equal.
|
||
var stacked = stack.get(object);
|
||
if (stacked) {
|
||
return stacked == other;
|
||
}
|
||
bitmask |= COMPARE_UNORDERED_FLAG;
|
||
|
||
// Recursively compare objects (susceptible to call stack limits).
|
||
stack.set(object, other);
|
||
var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
|
||
stack['delete'](object);
|
||
return result;
|
||
|
||
case symbolTag:
|
||
if (symbolValueOf) {
|
||
return symbolValueOf.call(object) == symbolValueOf.call(other);
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
module.exports = equalByTag;
|
||
|
||
|
||
/***/ }),
|
||
/* 360 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* Converts `map` to its key-value pairs.
|
||
*
|
||
* @private
|
||
* @param {Object} map The map to convert.
|
||
* @returns {Array} Returns the key-value pairs.
|
||
*/
|
||
function mapToArray(map) {
|
||
var index = -1,
|
||
result = Array(map.size);
|
||
|
||
map.forEach(function(value, key) {
|
||
result[++index] = [key, value];
|
||
});
|
||
return result;
|
||
}
|
||
|
||
module.exports = mapToArray;
|
||
|
||
|
||
/***/ }),
|
||
/* 361 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var getAllKeys = __webpack_require__(131);
|
||
|
||
/** Used to compose bitmasks for value comparisons. */
|
||
var COMPARE_PARTIAL_FLAG = 1;
|
||
|
||
/** Used for built-in method references. */
|
||
var objectProto = Object.prototype;
|
||
|
||
/** Used to check objects for own properties. */
|
||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||
|
||
/**
|
||
* A specialized version of `baseIsEqualDeep` for objects with support for
|
||
* partial deep comparisons.
|
||
*
|
||
* @private
|
||
* @param {Object} object The object to compare.
|
||
* @param {Object} other The other object to compare.
|
||
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
||
* @param {Function} customizer The function to customize comparisons.
|
||
* @param {Function} equalFunc The function to determine equivalents of values.
|
||
* @param {Object} stack Tracks traversed `object` and `other` objects.
|
||
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
||
*/
|
||
function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
|
||
var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
|
||
objProps = getAllKeys(object),
|
||
objLength = objProps.length,
|
||
othProps = getAllKeys(other),
|
||
othLength = othProps.length;
|
||
|
||
if (objLength != othLength && !isPartial) {
|
||
return false;
|
||
}
|
||
var index = objLength;
|
||
while (index--) {
|
||
var key = objProps[index];
|
||
if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
|
||
return false;
|
||
}
|
||
}
|
||
// Assume cyclic values are equal.
|
||
var stacked = stack.get(object);
|
||
if (stacked && stack.get(other)) {
|
||
return stacked == other;
|
||
}
|
||
var result = true;
|
||
stack.set(object, other);
|
||
stack.set(other, object);
|
||
|
||
var skipCtor = isPartial;
|
||
while (++index < objLength) {
|
||
key = objProps[index];
|
||
var objValue = object[key],
|
||
othValue = other[key];
|
||
|
||
if (customizer) {
|
||
var compared = isPartial
|
||
? customizer(othValue, objValue, key, other, object, stack)
|
||
: customizer(objValue, othValue, key, object, other, stack);
|
||
}
|
||
// Recursively compare objects (susceptible to call stack limits).
|
||
if (!(compared === undefined
|
||
? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
|
||
: compared
|
||
)) {
|
||
result = false;
|
||
break;
|
||
}
|
||
skipCtor || (skipCtor = key == 'constructor');
|
||
}
|
||
if (result && !skipCtor) {
|
||
var objCtor = object.constructor,
|
||
othCtor = other.constructor;
|
||
|
||
// Non `Object` object instances with different constructors are not equal.
|
||
if (objCtor != othCtor &&
|
||
('constructor' in object && 'constructor' in other) &&
|
||
!(typeof objCtor == 'function' && objCtor instanceof objCtor &&
|
||
typeof othCtor == 'function' && othCtor instanceof othCtor)) {
|
||
result = false;
|
||
}
|
||
}
|
||
stack['delete'](object);
|
||
stack['delete'](other);
|
||
return result;
|
||
}
|
||
|
||
module.exports = equalObjects;
|
||
|
||
|
||
/***/ }),
|
||
/* 362 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var isStrictComparable = __webpack_require__(167),
|
||
keys = __webpack_require__(47);
|
||
|
||
/**
|
||
* Gets the property names, values, and compare flags of `object`.
|
||
*
|
||
* @private
|
||
* @param {Object} object The object to query.
|
||
* @returns {Array} Returns the match data of `object`.
|
||
*/
|
||
function getMatchData(object) {
|
||
var result = keys(object),
|
||
length = result.length;
|
||
|
||
while (length--) {
|
||
var key = result[length],
|
||
value = object[key];
|
||
|
||
result[length] = [key, value, isStrictComparable(value)];
|
||
}
|
||
return result;
|
||
}
|
||
|
||
module.exports = getMatchData;
|
||
|
||
|
||
/***/ }),
|
||
/* 363 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var baseIsEqual = __webpack_require__(165),
|
||
get = __webpack_require__(161),
|
||
hasIn = __webpack_require__(364),
|
||
isKey = __webpack_require__(101),
|
||
isStrictComparable = __webpack_require__(167),
|
||
matchesStrictComparable = __webpack_require__(168),
|
||
toKey = __webpack_require__(59);
|
||
|
||
/** Used to compose bitmasks for value comparisons. */
|
||
var COMPARE_PARTIAL_FLAG = 1,
|
||
COMPARE_UNORDERED_FLAG = 2;
|
||
|
||
/**
|
||
* The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
|
||
*
|
||
* @private
|
||
* @param {string} path The path of the property to get.
|
||
* @param {*} srcValue The value to match.
|
||
* @returns {Function} Returns the new spec function.
|
||
*/
|
||
function baseMatchesProperty(path, srcValue) {
|
||
if (isKey(path) && isStrictComparable(srcValue)) {
|
||
return matchesStrictComparable(toKey(path), srcValue);
|
||
}
|
||
return function(object) {
|
||
var objValue = get(object, path);
|
||
return (objValue === undefined && objValue === srcValue)
|
||
? hasIn(object, path)
|
||
: baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
|
||
};
|
||
}
|
||
|
||
module.exports = baseMatchesProperty;
|
||
|
||
|
||
/***/ }),
|
||
/* 364 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var baseHasIn = __webpack_require__(365),
|
||
hasPath = __webpack_require__(366);
|
||
|
||
/**
|
||
* Checks if `path` is a direct or inherited property of `object`.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 4.0.0
|
||
* @category Object
|
||
* @param {Object} object The object to query.
|
||
* @param {Array|string} path The path to check.
|
||
* @returns {boolean} Returns `true` if `path` exists, else `false`.
|
||
* @example
|
||
*
|
||
* var object = _.create({ 'a': _.create({ 'b': 2 }) });
|
||
*
|
||
* _.hasIn(object, 'a');
|
||
* // => true
|
||
*
|
||
* _.hasIn(object, 'a.b');
|
||
* // => true
|
||
*
|
||
* _.hasIn(object, ['a', 'b']);
|
||
* // => true
|
||
*
|
||
* _.hasIn(object, 'b');
|
||
* // => false
|
||
*/
|
||
function hasIn(object, path) {
|
||
return object != null && hasPath(object, path, baseHasIn);
|
||
}
|
||
|
||
module.exports = hasIn;
|
||
|
||
|
||
/***/ }),
|
||
/* 365 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* The base implementation of `_.hasIn` without support for deep paths.
|
||
*
|
||
* @private
|
||
* @param {Object} [object] The object to query.
|
||
* @param {Array|string} key The key to check.
|
||
* @returns {boolean} Returns `true` if `key` exists, else `false`.
|
||
*/
|
||
function baseHasIn(object, key) {
|
||
return object != null && key in Object(object);
|
||
}
|
||
|
||
module.exports = baseHasIn;
|
||
|
||
|
||
/***/ }),
|
||
/* 366 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var castPath = __webpack_require__(163),
|
||
isArguments = __webpack_require__(74),
|
||
isArray = __webpack_require__(9),
|
||
isIndex = __webpack_require__(75),
|
||
isLength = __webpack_require__(77),
|
||
toKey = __webpack_require__(59);
|
||
|
||
/**
|
||
* Checks if `path` exists on `object`.
|
||
*
|
||
* @private
|
||
* @param {Object} object The object to query.
|
||
* @param {Array|string} path The path to check.
|
||
* @param {Function} hasFunc The function to check properties.
|
||
* @returns {boolean} Returns `true` if `path` exists, else `false`.
|
||
*/
|
||
function hasPath(object, path, hasFunc) {
|
||
path = castPath(path, object);
|
||
|
||
var index = -1,
|
||
length = path.length,
|
||
result = false;
|
||
|
||
while (++index < length) {
|
||
var key = toKey(path[index]);
|
||
if (!(result = object != null && hasFunc(object, key))) {
|
||
break;
|
||
}
|
||
object = object[key];
|
||
}
|
||
if (result || ++index != length) {
|
||
return result;
|
||
}
|
||
length = object == null ? 0 : object.length;
|
||
return !!length && isLength(length) && isIndex(key, length) &&
|
||
(isArray(object) || isArguments(object));
|
||
}
|
||
|
||
module.exports = hasPath;
|
||
|
||
|
||
/***/ }),
|
||
/* 367 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* This method returns the first argument it receives.
|
||
*
|
||
* @static
|
||
* @since 0.1.0
|
||
* @memberOf _
|
||
* @category Util
|
||
* @param {*} value Any value.
|
||
* @returns {*} Returns `value`.
|
||
* @example
|
||
*
|
||
* var object = { 'a': 1 };
|
||
*
|
||
* console.log(_.identity(object) === object);
|
||
* // => true
|
||
*/
|
||
function identity(value) {
|
||
return value;
|
||
}
|
||
|
||
module.exports = identity;
|
||
|
||
|
||
/***/ }),
|
||
/* 368 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var baseProperty = __webpack_require__(369),
|
||
basePropertyDeep = __webpack_require__(370),
|
||
isKey = __webpack_require__(101),
|
||
toKey = __webpack_require__(59);
|
||
|
||
/**
|
||
* Creates a function that returns the value at `path` of a given object.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 2.4.0
|
||
* @category Util
|
||
* @param {Array|string} path The path of the property to get.
|
||
* @returns {Function} Returns the new accessor function.
|
||
* @example
|
||
*
|
||
* var objects = [
|
||
* { 'a': { 'b': 2 } },
|
||
* { 'a': { 'b': 1 } }
|
||
* ];
|
||
*
|
||
* _.map(objects, _.property('a.b'));
|
||
* // => [2, 1]
|
||
*
|
||
* _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
|
||
* // => [1, 2]
|
||
*/
|
||
function property(path) {
|
||
return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
|
||
}
|
||
|
||
module.exports = property;
|
||
|
||
|
||
/***/ }),
|
||
/* 369 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* The base implementation of `_.property` without support for deep paths.
|
||
*
|
||
* @private
|
||
* @param {string} key The key of the property to get.
|
||
* @returns {Function} Returns the new accessor function.
|
||
*/
|
||
function baseProperty(key) {
|
||
return function(object) {
|
||
return object == null ? undefined : object[key];
|
||
};
|
||
}
|
||
|
||
module.exports = baseProperty;
|
||
|
||
|
||
/***/ }),
|
||
/* 370 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var baseGet = __webpack_require__(162);
|
||
|
||
/**
|
||
* A specialized version of `baseProperty` which supports deep paths.
|
||
*
|
||
* @private
|
||
* @param {Array|string} path The path of the property to get.
|
||
* @returns {Function} Returns the new accessor function.
|
||
*/
|
||
function basePropertyDeep(path) {
|
||
return function(object) {
|
||
return baseGet(object, path);
|
||
};
|
||
}
|
||
|
||
module.exports = basePropertyDeep;
|
||
|
||
|
||
/***/ }),
|
||
/* 371 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var baseFindIndex = __webpack_require__(86),
|
||
baseIteratee = __webpack_require__(164),
|
||
toInteger = __webpack_require__(56);
|
||
|
||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||
var nativeMax = Math.max,
|
||
nativeMin = Math.min;
|
||
|
||
/**
|
||
* This method is like `_.findIndex` except that it iterates over elements
|
||
* of `collection` from right to left.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 2.0.0
|
||
* @category Array
|
||
* @param {Array} array The array to inspect.
|
||
* @param {Function} [predicate=_.identity] The function invoked per iteration.
|
||
* @param {number} [fromIndex=array.length-1] The index to search from.
|
||
* @returns {number} Returns the index of the found element, else `-1`.
|
||
* @example
|
||
*
|
||
* var users = [
|
||
* { 'user': 'barney', 'active': true },
|
||
* { 'user': 'fred', 'active': false },
|
||
* { 'user': 'pebbles', 'active': false }
|
||
* ];
|
||
*
|
||
* _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
|
||
* // => 2
|
||
*
|
||
* // The `_.matches` iteratee shorthand.
|
||
* _.findLastIndex(users, { 'user': 'barney', 'active': true });
|
||
* // => 0
|
||
*
|
||
* // The `_.matchesProperty` iteratee shorthand.
|
||
* _.findLastIndex(users, ['active', false]);
|
||
* // => 2
|
||
*
|
||
* // The `_.property` iteratee shorthand.
|
||
* _.findLastIndex(users, 'active');
|
||
* // => 0
|
||
*/
|
||
function findLastIndex(array, predicate, fromIndex) {
|
||
var length = array == null ? 0 : array.length;
|
||
if (!length) {
|
||
return -1;
|
||
}
|
||
var index = length - 1;
|
||
if (fromIndex !== undefined) {
|
||
index = toInteger(fromIndex);
|
||
index = fromIndex < 0
|
||
? nativeMax(length + index, 0)
|
||
: nativeMin(index, length - 1);
|
||
}
|
||
return baseFindIndex(array, baseIteratee(predicate, 3), index, true);
|
||
}
|
||
|
||
module.exports = findLastIndex;
|
||
|
||
|
||
/***/ }),
|
||
/* 372 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.getNextStep = getNextStep;
|
||
|
||
var t = _interopRequireWildcard(__webpack_require__(3));
|
||
|
||
var _closest = __webpack_require__(373);
|
||
|
||
var _helpers = __webpack_require__(54);
|
||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||
|
||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||
function getNextStep(sourceId, pausedPosition) {
|
||
const currentExpression = getSteppableExpression(sourceId, pausedPosition);
|
||
|
||
if (!currentExpression) {
|
||
return null;
|
||
}
|
||
|
||
const currentStatement = currentExpression.find(p => {
|
||
return p.inList && t.isStatement(p.node);
|
||
});
|
||
|
||
if (!currentStatement) {
|
||
throw new Error("Assertion failure - this should always find at least Program");
|
||
}
|
||
|
||
return _getNextStep(currentStatement, sourceId, pausedPosition);
|
||
}
|
||
|
||
function getSteppableExpression(sourceId, pausedPosition) {
|
||
const closestPath = (0, _closest.getClosestPath)(sourceId, pausedPosition);
|
||
|
||
if (!closestPath) {
|
||
return null;
|
||
}
|
||
|
||
if ((0, _helpers.isAwaitExpression)(closestPath) || (0, _helpers.isYieldExpression)(closestPath)) {
|
||
return closestPath;
|
||
}
|
||
|
||
return closestPath.find(p => t.isAwaitExpression(p.node) || t.isYieldExpression(p.node));
|
||
}
|
||
|
||
function _getNextStep(statement, sourceId, position) {
|
||
const nextStatement = statement.getSibling(1);
|
||
|
||
if (nextStatement) {
|
||
return { ...nextStatement.node.loc.start,
|
||
sourceId: sourceId
|
||
};
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 373 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.getClosestPath = getClosestPath;
|
||
|
||
var _simplePath = _interopRequireDefault(__webpack_require__(153));
|
||
|
||
var _ast = __webpack_require__(20);
|
||
|
||
var _contains = __webpack_require__(169);
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||
function getClosestPath(sourceId, location) {
|
||
let closestPath = null;
|
||
(0, _ast.traverseAst)(sourceId, {
|
||
enter(node, ancestors) {
|
||
if ((0, _contains.nodeContainsPosition)(node, location)) {
|
||
const path = (0, _simplePath.default)(ancestors);
|
||
|
||
if (path && (!closestPath || path.depth > closestPath.depth)) {
|
||
closestPath = path;
|
||
}
|
||
}
|
||
}
|
||
|
||
});
|
||
|
||
if (!closestPath) {
|
||
throw new Error("Assertion failure - This should always fine a path");
|
||
}
|
||
|
||
return closestPath;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 374 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.hasSyntaxError = hasSyntaxError;
|
||
|
||
var _ast = __webpack_require__(20);
|
||
|
||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||
function hasSyntaxError(input) {
|
||
try {
|
||
(0, _ast.parseScript)(input);
|
||
return false;
|
||
} catch (e) {
|
||
return `${e.name} : ${e.message}`;
|
||
}
|
||
}
|
||
|
||
/***/ }),
|
||
/* 375 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = mapExpression;
|
||
|
||
var _ast = __webpack_require__(20);
|
||
|
||
var _mapOriginalExpression = _interopRequireDefault(__webpack_require__(376));
|
||
|
||
var _mapBindings = _interopRequireDefault(__webpack_require__(377));
|
||
|
||
var _mapAwaitExpression = _interopRequireDefault(__webpack_require__(378));
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||
function mapExpression(expression, mappings, bindings, shouldMapBindings = true, shouldMapAwait = true) {
|
||
const mapped = {
|
||
await: false,
|
||
bindings: false,
|
||
originalExpression: false
|
||
};
|
||
const ast = (0, _ast.parseConsoleScript)(expression);
|
||
|
||
try {
|
||
if (mappings && ast) {
|
||
const beforeOriginalExpression = expression;
|
||
expression = (0, _mapOriginalExpression.default)(expression, ast, mappings);
|
||
mapped.originalExpression = beforeOriginalExpression !== expression;
|
||
}
|
||
|
||
if (shouldMapBindings && ast) {
|
||
const beforeBindings = expression;
|
||
expression = (0, _mapBindings.default)(expression, ast, bindings);
|
||
mapped.bindings = beforeBindings !== expression;
|
||
}
|
||
|
||
if (shouldMapAwait) {
|
||
const beforeAwait = expression;
|
||
expression = (0, _mapAwaitExpression.default)(expression, ast);
|
||
mapped.await = beforeAwait !== expression;
|
||
}
|
||
} catch (e) {
|
||
console.warn(`Error when mapping ${expression} expression:`, e);
|
||
}
|
||
|
||
return {
|
||
expression,
|
||
mapped
|
||
};
|
||
}
|
||
|
||
/***/ }),
|
||
/* 376 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = mapOriginalExpression;
|
||
|
||
var _ast = __webpack_require__(20);
|
||
|
||
var _getScopes = __webpack_require__(160);
|
||
|
||
var _generator = _interopRequireDefault(__webpack_require__(55));
|
||
|
||
var t = _interopRequireWildcard(__webpack_require__(3));
|
||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||
// NOTE: this will only work if we are replacing an original identifier
|
||
function replaceNode(ancestors, node) {
|
||
const ancestor = ancestors[ancestors.length - 1];
|
||
|
||
if (typeof ancestor.index === "number") {
|
||
ancestor.node[ancestor.key][ancestor.index] = node;
|
||
} else {
|
||
ancestor.node[ancestor.key] = node;
|
||
}
|
||
}
|
||
|
||
function getFirstExpression(ast) {
|
||
const statements = ast.program.body;
|
||
|
||
if (statements.length == 0) {
|
||
return null;
|
||
}
|
||
|
||
return statements[0].expression;
|
||
}
|
||
|
||
function locationKey(start) {
|
||
return `${start.line}:${start.column}`;
|
||
}
|
||
|
||
function mapOriginalExpression(expression, ast, mappings) {
|
||
const scopes = (0, _getScopes.buildScopeList)(ast, "");
|
||
let shouldUpdate = false;
|
||
const nodes = new Map();
|
||
const replacements = new Map(); // The ref-only global bindings are the ones that are accessed, but not
|
||
// declared anywhere in the parsed code, meaning they are either global,
|
||
// or declared somewhere in a scope outside the parsed code, so we
|
||
// rewrite all of those specifically to avoid rewritting declarations that
|
||
// shadow outer mappings.
|
||
|
||
for (const name of Object.keys(scopes[0].bindings)) {
|
||
const {
|
||
refs
|
||
} = scopes[0].bindings[name];
|
||
const mapping = mappings[name];
|
||
|
||
if (!refs.every(ref => ref.type === "ref") || !mapping || mapping === name) {
|
||
continue;
|
||
}
|
||
|
||
let node = nodes.get(name);
|
||
|
||
if (!node) {
|
||
node = getFirstExpression((0, _ast.parseScript)(mapping));
|
||
nodes.set(name, node);
|
||
}
|
||
|
||
for (const ref of refs) {
|
||
let {
|
||
line,
|
||
column
|
||
} = ref.start; // This shouldn't happen, just keeping Flow happy.
|
||
|
||
if (typeof column !== "number") {
|
||
column = 0;
|
||
}
|
||
|
||
replacements.set(locationKey({
|
||
line,
|
||
column
|
||
}), node);
|
||
}
|
||
}
|
||
|
||
if (replacements.size === 0) {
|
||
// Avoid the extra code generation work and also avoid potentially
|
||
// reformatting the user's code unnecessarily.
|
||
return expression;
|
||
}
|
||
|
||
t.traverse(ast, (node, ancestors) => {
|
||
if (!t.isIdentifier(node) && !t.isThisExpression(node)) {
|
||
return;
|
||
}
|
||
|
||
const ancestor = ancestors[ancestors.length - 1]; // Shorthand properties can have a key and value with `node.loc.start` value
|
||
// and we only want to replace the value.
|
||
|
||
if (t.isObjectProperty(ancestor.node) && ancestor.key !== "value") {
|
||
return;
|
||
}
|
||
|
||
const replacement = replacements.get(locationKey(node.loc.start));
|
||
|
||
if (replacement) {
|
||
replaceNode(ancestors, t.cloneNode(replacement));
|
||
shouldUpdate = true;
|
||
}
|
||
});
|
||
|
||
if (shouldUpdate) {
|
||
return (0, _generator.default)(ast).code;
|
||
}
|
||
|
||
return expression;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 377 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = mapExpressionBindings;
|
||
|
||
var _ast = __webpack_require__(20);
|
||
|
||
var _helpers = __webpack_require__(54);
|
||
|
||
var _generator = _interopRequireDefault(__webpack_require__(55));
|
||
|
||
var t = _interopRequireWildcard(__webpack_require__(3));
|
||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||
function getAssignmentTarget(node, bindings) {
|
||
if (t.isObjectPattern(node)) {
|
||
for (const property of node.properties) {
|
||
if (t.isRestElement(property)) {
|
||
property.argument = getAssignmentTarget(property.argument, bindings);
|
||
} else {
|
||
property.value = getAssignmentTarget(property.value, bindings);
|
||
}
|
||
}
|
||
|
||
return node;
|
||
}
|
||
|
||
if (t.isArrayPattern(node)) {
|
||
for (const [i, element] of node.elements.entries()) {
|
||
node.elements[i] = getAssignmentTarget(element, bindings);
|
||
}
|
||
|
||
return node;
|
||
}
|
||
|
||
if (t.isAssignmentPattern(node)) {
|
||
node.left = getAssignmentTarget(node.left, bindings);
|
||
return node;
|
||
}
|
||
|
||
if (t.isRestElement(node)) {
|
||
node.argument = getAssignmentTarget(node.argument, bindings);
|
||
return node;
|
||
}
|
||
|
||
if (t.isIdentifier(node)) {
|
||
return bindings.includes(node.name) ? node : t.memberExpression(t.identifier("self"), node);
|
||
}
|
||
|
||
return node;
|
||
} // translates new bindings `var a = 3` into `self.a = 3`
|
||
// and existing bindings `var a = 3` into `a = 3` for re-assignments
|
||
|
||
|
||
function globalizeDeclaration(node, bindings) {
|
||
return node.declarations.map(declaration => t.expressionStatement(t.assignmentExpression("=", getAssignmentTarget(declaration.id, bindings), declaration.init || t.unaryExpression("void", t.numericLiteral(0)))));
|
||
} // translates new bindings `a = 3` into `self.a = 3`
|
||
// and keeps assignments the same for existing bindings.
|
||
|
||
|
||
function globalizeAssignment(node, bindings) {
|
||
return t.assignmentExpression(node.operator, getAssignmentTarget(node.left, bindings), node.right);
|
||
}
|
||
|
||
function mapExpressionBindings(expression, ast, bindings = []) {
|
||
let isMapped = false;
|
||
let shouldUpdate = true;
|
||
t.traverse(ast, (node, ancestors) => {
|
||
const parent = ancestors[ancestors.length - 1];
|
||
|
||
if (t.isWithStatement(node)) {
|
||
shouldUpdate = false;
|
||
return;
|
||
}
|
||
|
||
if (!(0, _helpers.isTopLevel)(ancestors)) {
|
||
return;
|
||
}
|
||
|
||
if (t.isAssignmentExpression(node)) {
|
||
if (t.isIdentifier(node.left) || t.isPattern(node.left)) {
|
||
const newNode = globalizeAssignment(node, bindings);
|
||
isMapped = true;
|
||
return (0, _ast.replaceNode)(ancestors, newNode);
|
||
}
|
||
|
||
return;
|
||
}
|
||
|
||
if (!t.isVariableDeclaration(node)) {
|
||
return;
|
||
}
|
||
|
||
if (!t.isForStatement(parent.node)) {
|
||
const newNodes = globalizeDeclaration(node, bindings);
|
||
isMapped = true;
|
||
(0, _ast.replaceNode)(ancestors, newNodes);
|
||
}
|
||
});
|
||
|
||
if (!shouldUpdate || !isMapped) {
|
||
return expression;
|
||
}
|
||
|
||
return (0, _generator.default)(ast).code;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 378 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = mapTopLevelAwait;
|
||
|
||
var _generator = _interopRequireDefault(__webpack_require__(55));
|
||
|
||
var t = _interopRequireWildcard(__webpack_require__(3));
|
||
|
||
var _ast = __webpack_require__(20);
|
||
|
||
var _helpers = __webpack_require__(54);
|
||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||
function hasTopLevelAwait(ast) {
|
||
const hasAwait = (0, _ast.hasNode)(ast, (node, ancestors, b) => t.isAwaitExpression(node) && (0, _helpers.isTopLevel)(ancestors));
|
||
return hasAwait;
|
||
} // translates new bindings `var a = 3` into `a = 3`.
|
||
|
||
|
||
function translateDeclarationIntoAssignment(node) {
|
||
return node.declarations.reduce((acc, declaration) => {
|
||
// Don't translate declaration without initial assignment (e.g. `var a;`)
|
||
if (!declaration.init) {
|
||
return acc;
|
||
}
|
||
|
||
acc.push(t.expressionStatement(t.assignmentExpression("=", declaration.id, declaration.init)));
|
||
return acc;
|
||
}, []);
|
||
}
|
||
/**
|
||
* Given an AST, compute its last statement and replace it with a
|
||
* return statement.
|
||
*/
|
||
|
||
|
||
function addReturnNode(ast) {
|
||
const statements = ast.program.body;
|
||
const lastStatement = statements[statements.length - 1];
|
||
return statements.slice(0, -1).concat(t.returnStatement(lastStatement.expression));
|
||
}
|
||
|
||
function getDeclarations(node) {
|
||
const {
|
||
kind,
|
||
declarations
|
||
} = node;
|
||
const declaratorNodes = declarations.reduce((acc, d) => {
|
||
const declarators = getVariableDeclarators(d.id);
|
||
return acc.concat(declarators);
|
||
}, []); // We can't declare const variables outside of the async iife because we
|
||
// wouldn't be able to re-assign them. As a workaround, we transform them
|
||
// to `let` which should be good enough for those case.
|
||
|
||
return t.variableDeclaration(kind === "const" ? "let" : kind, declaratorNodes);
|
||
}
|
||
|
||
function getVariableDeclarators(node) {
|
||
if (t.isIdentifier(node)) {
|
||
return t.variableDeclarator(t.identifier(node.name));
|
||
}
|
||
|
||
if (t.isObjectProperty(node)) {
|
||
return getVariableDeclarators(node.value);
|
||
}
|
||
|
||
if (t.isRestElement(node)) {
|
||
return getVariableDeclarators(node.argument);
|
||
}
|
||
|
||
if (t.isAssignmentPattern(node)) {
|
||
return getVariableDeclarators(node.left);
|
||
}
|
||
|
||
if (t.isArrayPattern(node)) {
|
||
return node.elements.reduce((acc, element) => acc.concat(getVariableDeclarators(element)), []);
|
||
}
|
||
|
||
if (t.isObjectPattern(node)) {
|
||
return node.properties.reduce((acc, property) => acc.concat(getVariableDeclarators(property)), []);
|
||
}
|
||
|
||
return [];
|
||
}
|
||
/**
|
||
* Given an AST and an array of variableDeclaration nodes, return a new AST with
|
||
* all the declarations at the top of the AST.
|
||
*/
|
||
|
||
|
||
function addTopDeclarationNodes(ast, declarationNodes) {
|
||
const statements = [];
|
||
declarationNodes.forEach(declarationNode => {
|
||
statements.push(getDeclarations(declarationNode));
|
||
});
|
||
statements.push(ast);
|
||
return t.program(statements);
|
||
}
|
||
/**
|
||
* Given an AST, return an object of the following shape:
|
||
* - newAst: {AST} the AST where variable declarations were transformed into
|
||
* variable assignments
|
||
* - declarations: {Array<Node>} An array of all the declaration nodes needed
|
||
* outside of the async iife.
|
||
*/
|
||
|
||
|
||
function translateDeclarationsIntoAssignment(ast) {
|
||
const declarations = [];
|
||
t.traverse(ast, (node, ancestors) => {
|
||
const parent = ancestors[ancestors.length - 1];
|
||
|
||
if (t.isWithStatement(node) || !(0, _helpers.isTopLevel)(ancestors) || t.isAssignmentExpression(node) || !t.isVariableDeclaration(node) || t.isForStatement(parent.node) || !Array.isArray(node.declarations) || node.declarations.length === 0) {
|
||
return;
|
||
}
|
||
|
||
const newNodes = translateDeclarationIntoAssignment(node);
|
||
(0, _ast.replaceNode)(ancestors, newNodes);
|
||
declarations.push(node);
|
||
});
|
||
return {
|
||
newAst: ast,
|
||
declarations
|
||
};
|
||
}
|
||
/**
|
||
* Given an AST, wrap its body in an async iife, transform variable declarations
|
||
* in assignments and move the variable declarations outside of the async iife.
|
||
* Example: With the AST for the following expression: `let a = await 123`, the
|
||
* function will return:
|
||
* let a;
|
||
* (async => {
|
||
* return a = await 123;
|
||
* })();
|
||
*/
|
||
|
||
|
||
function wrapExpressionFromAst(ast) {
|
||
// Transform let and var declarations into assignments, and get back an array
|
||
// of variable declarations.
|
||
let {
|
||
newAst,
|
||
declarations
|
||
} = translateDeclarationsIntoAssignment(ast);
|
||
const body = addReturnNode(newAst); // Create the async iife.
|
||
|
||
newAst = t.expressionStatement(t.callExpression(t.arrowFunctionExpression([], t.blockStatement(body), true), [])); // Now let's put all the variable declarations at the top of the async iife.
|
||
|
||
newAst = addTopDeclarationNodes(newAst, declarations);
|
||
return (0, _generator.default)(newAst).code;
|
||
}
|
||
|
||
function mapTopLevelAwait(expression, ast) {
|
||
if (!ast) {
|
||
// If there's no ast this means the expression is malformed. And if the
|
||
// expression contains the await keyword, we still want to wrap it in an
|
||
// async iife in order to get a meaningful message (without this, the
|
||
// engine will throw an Error stating that await keywords are only valid
|
||
// in async functions and generators).
|
||
if (expression.includes("await ")) {
|
||
return `(async () => { ${expression} })();`;
|
||
}
|
||
|
||
return expression;
|
||
}
|
||
|
||
if (!hasTopLevelAwait(ast)) {
|
||
return expression;
|
||
}
|
||
|
||
return wrapExpressionFromAst(ast);
|
||
}
|
||
|
||
/***/ }),
|
||
/* 379 */,
|
||
/* 380 */,
|
||
/* 381 */,
|
||
/* 382 */,
|
||
/* 383 */,
|
||
/* 384 */,
|
||
/* 385 */,
|
||
/* 386 */,
|
||
/* 387 */,
|
||
/* 388 */,
|
||
/* 389 */,
|
||
/* 390 */,
|
||
/* 391 */,
|
||
/* 392 */,
|
||
/* 393 */,
|
||
/* 394 */,
|
||
/* 395 */,
|
||
/* 396 */,
|
||
/* 397 */,
|
||
/* 398 */,
|
||
/* 399 */,
|
||
/* 400 */,
|
||
/* 401 */,
|
||
/* 402 */,
|
||
/* 403 */,
|
||
/* 404 */,
|
||
/* 405 */,
|
||
/* 406 */,
|
||
/* 407 */,
|
||
/* 408 */,
|
||
/* 409 */,
|
||
/* 410 */,
|
||
/* 411 */,
|
||
/* 412 */,
|
||
/* 413 */,
|
||
/* 414 */,
|
||
/* 415 */,
|
||
/* 416 */,
|
||
/* 417 */,
|
||
/* 418 */,
|
||
/* 419 */,
|
||
/* 420 */,
|
||
/* 421 */,
|
||
/* 422 */,
|
||
/* 423 */,
|
||
/* 424 */,
|
||
/* 425 */,
|
||
/* 426 */,
|
||
/* 427 */,
|
||
/* 428 */,
|
||
/* 429 */,
|
||
/* 430 */,
|
||
/* 431 */,
|
||
/* 432 */,
|
||
/* 433 */,
|
||
/* 434 */,
|
||
/* 435 */,
|
||
/* 436 */,
|
||
/* 437 */,
|
||
/* 438 */,
|
||
/* 439 */,
|
||
/* 440 */,
|
||
/* 441 */,
|
||
/* 442 */,
|
||
/* 443 */,
|
||
/* 444 */,
|
||
/* 445 */,
|
||
/* 446 */,
|
||
/* 447 */,
|
||
/* 448 */,
|
||
/* 449 */,
|
||
/* 450 */,
|
||
/* 451 */,
|
||
/* 452 */,
|
||
/* 453 */,
|
||
/* 454 */,
|
||
/* 455 */,
|
||
/* 456 */,
|
||
/* 457 */,
|
||
/* 458 */,
|
||
/* 459 */,
|
||
/* 460 */,
|
||
/* 461 */,
|
||
/* 462 */,
|
||
/* 463 */,
|
||
/* 464 */,
|
||
/* 465 */,
|
||
/* 466 */,
|
||
/* 467 */,
|
||
/* 468 */,
|
||
/* 469 */,
|
||
/* 470 */,
|
||
/* 471 */,
|
||
/* 472 */,
|
||
/* 473 */,
|
||
/* 474 */,
|
||
/* 475 */,
|
||
/* 476 */,
|
||
/* 477 */,
|
||
/* 478 */,
|
||
/* 479 */,
|
||
/* 480 */,
|
||
/* 481 */,
|
||
/* 482 */,
|
||
/* 483 */,
|
||
/* 484 */,
|
||
/* 485 */,
|
||
/* 486 */,
|
||
/* 487 */,
|
||
/* 488 */,
|
||
/* 489 */,
|
||
/* 490 */,
|
||
/* 491 */,
|
||
/* 492 */,
|
||
/* 493 */,
|
||
/* 494 */,
|
||
/* 495 */,
|
||
/* 496 */,
|
||
/* 497 */,
|
||
/* 498 */,
|
||
/* 499 */,
|
||
/* 500 */,
|
||
/* 501 */,
|
||
/* 502 */,
|
||
/* 503 */,
|
||
/* 504 */,
|
||
/* 505 */,
|
||
/* 506 */,
|
||
/* 507 */,
|
||
/* 508 */,
|
||
/* 509 */,
|
||
/* 510 */,
|
||
/* 511 */,
|
||
/* 512 */,
|
||
/* 513 */,
|
||
/* 514 */,
|
||
/* 515 */,
|
||
/* 516 */,
|
||
/* 517 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = isPlaceholderType;
|
||
|
||
var _definitions = __webpack_require__(16);
|
||
|
||
function isPlaceholderType(placeholderType, targetType) {
|
||
if (placeholderType === targetType) return true;
|
||
const aliases = _definitions.PLACEHOLDERS_ALIAS[placeholderType];
|
||
|
||
if (aliases) {
|
||
for (const alias of aliases) {
|
||
if (targetType === alias) return true;
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
/***/ }),
|
||
/* 518 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.PLACEHOLDERS_FLIPPED_ALIAS = exports.PLACEHOLDERS_ALIAS = exports.PLACEHOLDERS = void 0;
|
||
|
||
var _utils = __webpack_require__(23);
|
||
|
||
const PLACEHOLDERS = ["Identifier", "StringLiteral", "Expression", "Statement", "Declaration", "BlockStatement", "ClassBody", "Pattern"];
|
||
exports.PLACEHOLDERS = PLACEHOLDERS;
|
||
const PLACEHOLDERS_ALIAS = {
|
||
Declaration: ["Statement"],
|
||
Pattern: ["PatternLike", "LVal"]
|
||
};
|
||
exports.PLACEHOLDERS_ALIAS = PLACEHOLDERS_ALIAS;
|
||
|
||
for (const type of PLACEHOLDERS) {
|
||
const alias = _utils.ALIAS_KEYS[type];
|
||
if (alias && alias.length) PLACEHOLDERS_ALIAS[type] = alias;
|
||
}
|
||
|
||
const PLACEHOLDERS_FLIPPED_ALIAS = {};
|
||
exports.PLACEHOLDERS_FLIPPED_ALIAS = PLACEHOLDERS_FLIPPED_ALIAS;
|
||
Object.keys(PLACEHOLDERS_ALIAS).forEach(type => {
|
||
PLACEHOLDERS_ALIAS[type].forEach(alias => {
|
||
if (!Object.hasOwnProperty.call(PLACEHOLDERS_FLIPPED_ALIAS, alias)) {
|
||
PLACEHOLDERS_FLIPPED_ALIAS[alias] = [];
|
||
}
|
||
|
||
PLACEHOLDERS_FLIPPED_ALIAS[alias].push(type);
|
||
});
|
||
});
|
||
|
||
/***/ })
|
||
/******/ ]);
|
||
}); |