Add node modules and new code for release (#57)
Co-authored-by: taakleton <taakleton@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
da63a48ad7
commit
a517f2ff65
22
node_modules/@babel/helpers/LICENSE
generated
vendored
Normal file
22
node_modules/@babel/helpers/LICENSE
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2014-present Sebastian McKenzie and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
19
node_modules/@babel/helpers/README.md
generated
vendored
Normal file
19
node_modules/@babel/helpers/README.md
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
# @babel/helpers
|
||||
|
||||
> Collection of helper functions used by Babel transforms.
|
||||
|
||||
See our website [@babel/helpers](https://babeljs.io/docs/en/babel-helpers) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save-dev @babel/helpers
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add @babel/helpers --dev
|
||||
```
|
25
node_modules/@babel/helpers/lib/helpers-generated.js
generated
vendored
Normal file
25
node_modules/@babel/helpers/lib/helpers-generated.js
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _template = require("@babel/template");
|
||||
|
||||
function helper(minVersion, source) {
|
||||
return Object.freeze({
|
||||
minVersion,
|
||||
ast: () => _template.default.program.ast(source)
|
||||
});
|
||||
}
|
||||
|
||||
var _default = Object.freeze({
|
||||
asyncIterator: helper("7.15.9", 'export default function _asyncIterator(iterable){var method,async,sync,retry=2;for("undefined"!=typeof Symbol&&(async=Symbol.asyncIterator,sync=Symbol.iterator);retry--;){if(async&&null!=(method=iterable[async]))return method.call(iterable);if(sync&&null!=(method=iterable[sync]))return new AsyncFromSyncIterator(method.call(iterable));async="@@asyncIterator",sync="@@iterator"}throw new TypeError("Object is not async iterable")}function AsyncFromSyncIterator(s){function AsyncFromSyncIteratorContinuation(r){if(Object(r)!==r)return Promise.reject(new TypeError(r+" is not an object."));var done=r.done;return Promise.resolve(r.value).then((function(value){return{value:value,done:done}}))}return AsyncFromSyncIterator=function(s){this.s=s,this.n=s.next},AsyncFromSyncIterator.prototype={s:null,n:null,next:function(){return AsyncFromSyncIteratorContinuation(this.n.apply(this.s,arguments))},return:function(value){var ret=this.s.return;return void 0===ret?Promise.resolve({value:value,done:!0}):AsyncFromSyncIteratorContinuation(ret.apply(this.s,arguments))},throw:function(value){var thr=this.s.return;return void 0===thr?Promise.reject(value):AsyncFromSyncIteratorContinuation(thr.apply(this.s,arguments))}},new AsyncFromSyncIterator(s)}'),
|
||||
jsx: helper("7.0.0-beta.0", 'var REACT_ELEMENT_TYPE;export default function _createRawReactElement(type,props,key,children){REACT_ELEMENT_TYPE||(REACT_ELEMENT_TYPE="function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103);var defaultProps=type&&type.defaultProps,childrenLength=arguments.length-3;if(props||0===childrenLength||(props={children:void 0}),1===childrenLength)props.children=children;else if(childrenLength>1){for(var childArray=new Array(childrenLength),i=0;i<childrenLength;i++)childArray[i]=arguments[i+3];props.children=childArray}if(props&&defaultProps)for(var propName in defaultProps)void 0===props[propName]&&(props[propName]=defaultProps[propName]);else props||(props=defaultProps||{});return{$$typeof:REACT_ELEMENT_TYPE,type:type,key:void 0===key?null:""+key,ref:null,props:props,_owner:null}}'),
|
||||
objectSpread2: helper("7.5.0", 'import defineProperty from"defineProperty";function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter((function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable}))),keys.push.apply(keys,symbols)}return keys}export default function _objectSpread2(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys(Object(source),!0).forEach((function(key){defineProperty(target,key,source[key])})):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys(Object(source)).forEach((function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))}))}return target}'),
|
||||
typeof: helper("7.0.0-beta.0", 'export default function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj},_typeof(obj)}'),
|
||||
wrapRegExp: helper("7.2.6", 'import setPrototypeOf from"setPrototypeOf";import inherits from"inherits";export default function _wrapRegExp(){_wrapRegExp=function(re,groups){return new BabelRegExp(re,void 0,groups)};var _super=RegExp.prototype,_groups=new WeakMap;function BabelRegExp(re,flags,groups){var _this=new RegExp(re,flags);return _groups.set(_this,groups||_groups.get(re)),setPrototypeOf(_this,BabelRegExp.prototype)}function buildGroups(result,re){var g=_groups.get(re);return Object.keys(g).reduce((function(groups,name){return groups[name]=result[g[name]],groups}),Object.create(null))}return inherits(BabelRegExp,RegExp),BabelRegExp.prototype.exec=function(str){var result=_super.exec.call(this,str);return result&&(result.groups=buildGroups(result,this)),result},BabelRegExp.prototype[Symbol.replace]=function(str,substitution){if("string"==typeof substitution){var groups=_groups.get(this);return _super[Symbol.replace].call(this,str,substitution.replace(/\\$<([^>]+)>/g,(function(_,name){return"$"+groups[name]})))}if("function"==typeof substitution){var _this=this;return _super[Symbol.replace].call(this,str,(function(){var args=arguments;return"object"!=typeof args[args.length-1]&&(args=[].slice.call(args)).push(buildGroups(args,_this)),substitution.apply(this,args)}))}return _super[Symbol.replace].call(this,str,substitution)},_wrapRegExp.apply(this,arguments)}')
|
||||
});
|
||||
|
||||
exports.default = _default;
|
1954
node_modules/@babel/helpers/lib/helpers.js
generated
vendored
Normal file
1954
node_modules/@babel/helpers/lib/helpers.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
81
node_modules/@babel/helpers/lib/helpers/asyncIterator.js
generated
vendored
Normal file
81
node_modules/@babel/helpers/lib/helpers/asyncIterator.js
generated
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = _asyncIterator;
|
||||
|
||||
function _asyncIterator(iterable) {
|
||||
var method,
|
||||
async,
|
||||
sync,
|
||||
retry = 2;
|
||||
|
||||
if (typeof Symbol !== "undefined") {
|
||||
async = Symbol.asyncIterator;
|
||||
sync = Symbol.iterator;
|
||||
}
|
||||
|
||||
while (retry--) {
|
||||
if (async && (method = iterable[async]) != null) {
|
||||
return method.call(iterable);
|
||||
}
|
||||
|
||||
if (sync && (method = iterable[sync]) != null) {
|
||||
return new AsyncFromSyncIterator(method.call(iterable));
|
||||
}
|
||||
|
||||
async = "@@asyncIterator";
|
||||
sync = "@@iterator";
|
||||
}
|
||||
|
||||
throw new TypeError("Object is not async iterable");
|
||||
}
|
||||
|
||||
function AsyncFromSyncIterator(s) {
|
||||
AsyncFromSyncIterator = function (s) {
|
||||
this.s = s;
|
||||
this.n = s.next;
|
||||
};
|
||||
|
||||
AsyncFromSyncIterator.prototype = {
|
||||
s: null,
|
||||
n: null,
|
||||
next: function () {
|
||||
return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
|
||||
},
|
||||
return: function (value) {
|
||||
var ret = this.s.return;
|
||||
|
||||
if (ret === undefined) {
|
||||
return Promise.resolve({
|
||||
value: value,
|
||||
done: true
|
||||
});
|
||||
}
|
||||
|
||||
return AsyncFromSyncIteratorContinuation(ret.apply(this.s, arguments));
|
||||
},
|
||||
throw: function (value) {
|
||||
var thr = this.s.return;
|
||||
if (thr === undefined) return Promise.reject(value);
|
||||
return AsyncFromSyncIteratorContinuation(thr.apply(this.s, arguments));
|
||||
}
|
||||
};
|
||||
|
||||
function AsyncFromSyncIteratorContinuation(r) {
|
||||
if (Object(r) !== r) {
|
||||
return Promise.reject(new TypeError(r + " is not an object."));
|
||||
}
|
||||
|
||||
var done = r.done;
|
||||
return Promise.resolve(r.value).then(function (value) {
|
||||
return {
|
||||
value: value,
|
||||
done: done
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
return new AsyncFromSyncIterator(s);
|
||||
}
|
53
node_modules/@babel/helpers/lib/helpers/jsx.js
generated
vendored
Normal file
53
node_modules/@babel/helpers/lib/helpers/jsx.js
generated
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = _createRawReactElement;
|
||||
var REACT_ELEMENT_TYPE;
|
||||
|
||||
function _createRawReactElement(type, props, key, children) {
|
||||
if (!REACT_ELEMENT_TYPE) {
|
||||
REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol["for"] && Symbol["for"]("react.element") || 0xeac7;
|
||||
}
|
||||
|
||||
var defaultProps = type && type.defaultProps;
|
||||
var childrenLength = arguments.length - 3;
|
||||
|
||||
if (!props && childrenLength !== 0) {
|
||||
props = {
|
||||
children: void 0
|
||||
};
|
||||
}
|
||||
|
||||
if (childrenLength === 1) {
|
||||
props.children = children;
|
||||
} else if (childrenLength > 1) {
|
||||
var childArray = new Array(childrenLength);
|
||||
|
||||
for (var i = 0; i < childrenLength; i++) {
|
||||
childArray[i] = arguments[i + 3];
|
||||
}
|
||||
|
||||
props.children = childArray;
|
||||
}
|
||||
|
||||
if (props && defaultProps) {
|
||||
for (var propName in defaultProps) {
|
||||
if (props[propName] === void 0) {
|
||||
props[propName] = defaultProps[propName];
|
||||
}
|
||||
}
|
||||
} else if (!props) {
|
||||
props = defaultProps || {};
|
||||
}
|
||||
|
||||
return {
|
||||
$$typeof: REACT_ELEMENT_TYPE,
|
||||
type: type,
|
||||
key: key === undefined ? null : "" + key,
|
||||
ref: null,
|
||||
props: props,
|
||||
_owner: null
|
||||
};
|
||||
}
|
46
node_modules/@babel/helpers/lib/helpers/objectSpread2.js
generated
vendored
Normal file
46
node_modules/@babel/helpers/lib/helpers/objectSpread2.js
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = _objectSpread2;
|
||||
|
||||
var _defineProperty = require("defineProperty");
|
||||
|
||||
function ownKeys(object, enumerableOnly) {
|
||||
var keys = Object.keys(object);
|
||||
|
||||
if (Object.getOwnPropertySymbols) {
|
||||
var symbols = Object.getOwnPropertySymbols(object);
|
||||
|
||||
if (enumerableOnly) {
|
||||
symbols = symbols.filter(function (sym) {
|
||||
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
||||
});
|
||||
}
|
||||
|
||||
keys.push.apply(keys, symbols);
|
||||
}
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
function _objectSpread2(target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i] != null ? arguments[i] : {};
|
||||
|
||||
if (i % 2) {
|
||||
ownKeys(Object(source), true).forEach(function (key) {
|
||||
_defineProperty(target, key, source[key]);
|
||||
});
|
||||
} else if (Object.getOwnPropertyDescriptors) {
|
||||
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
||||
} else {
|
||||
ownKeys(Object(source)).forEach(function (key) {
|
||||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
22
node_modules/@babel/helpers/lib/helpers/typeof.js
generated
vendored
Normal file
22
node_modules/@babel/helpers/lib/helpers/typeof.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = _typeof;
|
||||
|
||||
function _typeof(obj) {
|
||||
"@babel/helpers - typeof";
|
||||
|
||||
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
||||
exports.default = _typeof = function (obj) {
|
||||
return typeof obj;
|
||||
};
|
||||
} else {
|
||||
exports.default = _typeof = function (obj) {
|
||||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
||||
};
|
||||
}
|
||||
|
||||
return _typeof(obj);
|
||||
}
|
73
node_modules/@babel/helpers/lib/helpers/wrapRegExp.js
generated
vendored
Normal file
73
node_modules/@babel/helpers/lib/helpers/wrapRegExp.js
generated
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = _wrapRegExp;
|
||||
|
||||
var _setPrototypeOf = require("setPrototypeOf");
|
||||
|
||||
var _inherits = require("inherits");
|
||||
|
||||
function _wrapRegExp() {
|
||||
exports.default = _wrapRegExp = function (re, groups) {
|
||||
return new BabelRegExp(re, undefined, groups);
|
||||
};
|
||||
|
||||
var _super = RegExp.prototype;
|
||||
|
||||
var _groups = new WeakMap();
|
||||
|
||||
function BabelRegExp(re, flags, groups) {
|
||||
var _this = new RegExp(re, flags);
|
||||
|
||||
_groups.set(_this, groups || _groups.get(re));
|
||||
|
||||
return _setPrototypeOf(_this, BabelRegExp.prototype);
|
||||
}
|
||||
|
||||
_inherits(BabelRegExp, RegExp);
|
||||
|
||||
BabelRegExp.prototype.exec = function (str) {
|
||||
var result = _super.exec.call(this, str);
|
||||
|
||||
if (result) result.groups = buildGroups(result, this);
|
||||
return result;
|
||||
};
|
||||
|
||||
BabelRegExp.prototype[Symbol.replace] = function (str, substitution) {
|
||||
if (typeof substitution === "string") {
|
||||
var groups = _groups.get(this);
|
||||
|
||||
return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) {
|
||||
return "$" + groups[name];
|
||||
}));
|
||||
} else if (typeof substitution === "function") {
|
||||
var _this = this;
|
||||
|
||||
return _super[Symbol.replace].call(this, str, function () {
|
||||
var args = arguments;
|
||||
|
||||
if (typeof args[args.length - 1] !== "object") {
|
||||
args = [].slice.call(args);
|
||||
args.push(buildGroups(args, _this));
|
||||
}
|
||||
|
||||
return substitution.apply(this, args);
|
||||
});
|
||||
} else {
|
||||
return _super[Symbol.replace].call(this, str, substitution);
|
||||
}
|
||||
};
|
||||
|
||||
function buildGroups(result, re) {
|
||||
var g = _groups.get(re);
|
||||
|
||||
return Object.keys(g).reduce(function (groups, name) {
|
||||
groups[name] = result[g[name]];
|
||||
return groups;
|
||||
}, Object.create(null));
|
||||
}
|
||||
|
||||
return _wrapRegExp.apply(this, arguments);
|
||||
}
|
300
node_modules/@babel/helpers/lib/index.js
generated
vendored
Normal file
300
node_modules/@babel/helpers/lib/index.js
generated
vendored
Normal file
@ -0,0 +1,300 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
exports.ensure = ensure;
|
||||
exports.get = get;
|
||||
exports.getDependencies = getDependencies;
|
||||
exports.list = void 0;
|
||||
exports.minVersion = minVersion;
|
||||
|
||||
var _traverse = require("@babel/traverse");
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
var _helpers = require("./helpers");
|
||||
|
||||
const {
|
||||
assignmentExpression,
|
||||
cloneNode,
|
||||
expressionStatement,
|
||||
file: t_file,
|
||||
identifier,
|
||||
variableDeclaration,
|
||||
variableDeclarator
|
||||
} = _t;
|
||||
|
||||
function makePath(path) {
|
||||
const parts = [];
|
||||
|
||||
for (; path.parentPath; path = path.parentPath) {
|
||||
parts.push(path.key);
|
||||
if (path.inList) parts.push(path.listKey);
|
||||
}
|
||||
|
||||
return parts.reverse().join(".");
|
||||
}
|
||||
|
||||
let fileClass = undefined;
|
||||
|
||||
function getHelperMetadata(file) {
|
||||
const globals = new Set();
|
||||
const localBindingNames = new Set();
|
||||
const dependencies = new Map();
|
||||
let exportName;
|
||||
let exportPath;
|
||||
const exportBindingAssignments = [];
|
||||
const importPaths = [];
|
||||
const importBindingsReferences = [];
|
||||
const dependencyVisitor = {
|
||||
ImportDeclaration(child) {
|
||||
const name = child.node.source.value;
|
||||
|
||||
if (!_helpers.default[name]) {
|
||||
throw child.buildCodeFrameError(`Unknown helper ${name}`);
|
||||
}
|
||||
|
||||
if (child.get("specifiers").length !== 1 || !child.get("specifiers.0").isImportDefaultSpecifier()) {
|
||||
throw child.buildCodeFrameError("Helpers can only import a default value");
|
||||
}
|
||||
|
||||
const bindingIdentifier = child.node.specifiers[0].local;
|
||||
dependencies.set(bindingIdentifier, name);
|
||||
importPaths.push(makePath(child));
|
||||
},
|
||||
|
||||
ExportDefaultDeclaration(child) {
|
||||
const decl = child.get("declaration");
|
||||
|
||||
if (decl.isFunctionDeclaration()) {
|
||||
if (!decl.node.id) {
|
||||
throw decl.buildCodeFrameError("Helpers should give names to their exported func declaration");
|
||||
}
|
||||
|
||||
exportName = decl.node.id.name;
|
||||
}
|
||||
|
||||
exportPath = makePath(child);
|
||||
},
|
||||
|
||||
ExportAllDeclaration(child) {
|
||||
throw child.buildCodeFrameError("Helpers can only export default");
|
||||
},
|
||||
|
||||
ExportNamedDeclaration(child) {
|
||||
throw child.buildCodeFrameError("Helpers can only export default");
|
||||
},
|
||||
|
||||
Statement(child) {
|
||||
if (child.isModuleDeclaration()) return;
|
||||
child.skip();
|
||||
}
|
||||
|
||||
};
|
||||
const referenceVisitor = {
|
||||
Program(path) {
|
||||
const bindings = path.scope.getAllBindings();
|
||||
Object.keys(bindings).forEach(name => {
|
||||
if (name === exportName) return;
|
||||
if (dependencies.has(bindings[name].identifier)) return;
|
||||
localBindingNames.add(name);
|
||||
});
|
||||
},
|
||||
|
||||
ReferencedIdentifier(child) {
|
||||
const name = child.node.name;
|
||||
const binding = child.scope.getBinding(name);
|
||||
|
||||
if (!binding) {
|
||||
globals.add(name);
|
||||
} else if (dependencies.has(binding.identifier)) {
|
||||
importBindingsReferences.push(makePath(child));
|
||||
}
|
||||
},
|
||||
|
||||
AssignmentExpression(child) {
|
||||
const left = child.get("left");
|
||||
if (!(exportName in left.getBindingIdentifiers())) return;
|
||||
|
||||
if (!left.isIdentifier()) {
|
||||
throw left.buildCodeFrameError("Only simple assignments to exports are allowed in helpers");
|
||||
}
|
||||
|
||||
const binding = child.scope.getBinding(exportName);
|
||||
|
||||
if (binding != null && binding.scope.path.isProgram()) {
|
||||
exportBindingAssignments.push(makePath(child));
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
(0, _traverse.default)(file.ast, dependencyVisitor, file.scope);
|
||||
(0, _traverse.default)(file.ast, referenceVisitor, file.scope);
|
||||
if (!exportPath) throw new Error("Helpers must default-export something.");
|
||||
exportBindingAssignments.reverse();
|
||||
return {
|
||||
globals: Array.from(globals),
|
||||
localBindingNames: Array.from(localBindingNames),
|
||||
dependencies,
|
||||
exportBindingAssignments,
|
||||
exportPath,
|
||||
exportName,
|
||||
importBindingsReferences,
|
||||
importPaths
|
||||
};
|
||||
}
|
||||
|
||||
function permuteHelperAST(file, metadata, id, localBindings, getDependency) {
|
||||
if (localBindings && !id) {
|
||||
throw new Error("Unexpected local bindings for module-based helpers.");
|
||||
}
|
||||
|
||||
if (!id) return;
|
||||
const {
|
||||
localBindingNames,
|
||||
dependencies,
|
||||
exportBindingAssignments,
|
||||
exportPath,
|
||||
exportName,
|
||||
importBindingsReferences,
|
||||
importPaths
|
||||
} = metadata;
|
||||
const dependenciesRefs = {};
|
||||
dependencies.forEach((name, id) => {
|
||||
dependenciesRefs[id.name] = typeof getDependency === "function" && getDependency(name) || id;
|
||||
});
|
||||
const toRename = {};
|
||||
const bindings = new Set(localBindings || []);
|
||||
localBindingNames.forEach(name => {
|
||||
let newName = name;
|
||||
|
||||
while (bindings.has(newName)) newName = "_" + newName;
|
||||
|
||||
if (newName !== name) toRename[name] = newName;
|
||||
});
|
||||
|
||||
if (id.type === "Identifier" && exportName !== id.name) {
|
||||
toRename[exportName] = id.name;
|
||||
}
|
||||
|
||||
const visitor = {
|
||||
Program(path) {
|
||||
const exp = path.get(exportPath);
|
||||
const imps = importPaths.map(p => path.get(p));
|
||||
const impsBindingRefs = importBindingsReferences.map(p => path.get(p));
|
||||
const decl = exp.get("declaration");
|
||||
|
||||
if (id.type === "Identifier") {
|
||||
if (decl.isFunctionDeclaration()) {
|
||||
exp.replaceWith(decl);
|
||||
} else {
|
||||
exp.replaceWith(variableDeclaration("var", [variableDeclarator(id, decl.node)]));
|
||||
}
|
||||
} else if (id.type === "MemberExpression") {
|
||||
if (decl.isFunctionDeclaration()) {
|
||||
exportBindingAssignments.forEach(assignPath => {
|
||||
const assign = path.get(assignPath);
|
||||
assign.replaceWith(assignmentExpression("=", id, assign.node));
|
||||
});
|
||||
exp.replaceWith(decl);
|
||||
path.pushContainer("body", expressionStatement(assignmentExpression("=", id, identifier(exportName))));
|
||||
} else {
|
||||
exp.replaceWith(expressionStatement(assignmentExpression("=", id, decl.node)));
|
||||
}
|
||||
} else {
|
||||
throw new Error("Unexpected helper format.");
|
||||
}
|
||||
|
||||
Object.keys(toRename).forEach(name => {
|
||||
path.scope.rename(name, toRename[name]);
|
||||
});
|
||||
|
||||
for (const path of imps) path.remove();
|
||||
|
||||
for (const path of impsBindingRefs) {
|
||||
const node = cloneNode(dependenciesRefs[path.node.name]);
|
||||
path.replaceWith(node);
|
||||
}
|
||||
|
||||
path.stop();
|
||||
}
|
||||
|
||||
};
|
||||
(0, _traverse.default)(file.ast, visitor, file.scope);
|
||||
}
|
||||
|
||||
const helperData = Object.create(null);
|
||||
|
||||
function loadHelper(name) {
|
||||
if (!helperData[name]) {
|
||||
const helper = _helpers.default[name];
|
||||
|
||||
if (!helper) {
|
||||
throw Object.assign(new ReferenceError(`Unknown helper ${name}`), {
|
||||
code: "BABEL_HELPER_UNKNOWN",
|
||||
helper: name
|
||||
});
|
||||
}
|
||||
|
||||
const fn = () => {
|
||||
const file = {
|
||||
ast: t_file(helper.ast())
|
||||
};
|
||||
|
||||
if (fileClass) {
|
||||
return new fileClass({
|
||||
filename: `babel-helper://${name}`
|
||||
}, file);
|
||||
}
|
||||
|
||||
return file;
|
||||
};
|
||||
|
||||
const metadata = getHelperMetadata(fn());
|
||||
helperData[name] = {
|
||||
build(getDependency, id, localBindings) {
|
||||
const file = fn();
|
||||
permuteHelperAST(file, metadata, id, localBindings, getDependency);
|
||||
return {
|
||||
nodes: file.ast.program.body,
|
||||
globals: metadata.globals
|
||||
};
|
||||
},
|
||||
|
||||
minVersion() {
|
||||
return helper.minVersion;
|
||||
},
|
||||
|
||||
dependencies: metadata.dependencies
|
||||
};
|
||||
}
|
||||
|
||||
return helperData[name];
|
||||
}
|
||||
|
||||
function get(name, getDependency, id, localBindings) {
|
||||
return loadHelper(name).build(getDependency, id, localBindings);
|
||||
}
|
||||
|
||||
function minVersion(name) {
|
||||
return loadHelper(name).minVersion();
|
||||
}
|
||||
|
||||
function getDependencies(name) {
|
||||
return Array.from(loadHelper(name).dependencies.values());
|
||||
}
|
||||
|
||||
function ensure(name, newFileClass) {
|
||||
if (!fileClass) {
|
||||
fileClass = newFileClass;
|
||||
}
|
||||
|
||||
loadHelper(name);
|
||||
}
|
||||
|
||||
const list = Object.keys(_helpers.default).map(name => name.replace(/^_/, ""));
|
||||
exports.list = list;
|
||||
var _default = get;
|
||||
exports.default = _default;
|
29
node_modules/@babel/helpers/package.json
generated
vendored
Normal file
29
node_modules/@babel/helpers/package.json
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "@babel/helpers",
|
||||
"version": "7.16.7",
|
||||
"description": "Collection of helper functions used by Babel transforms.",
|
||||
"author": "The Babel Team (https://babel.dev/team)",
|
||||
"homepage": "https://babel.dev/docs/en/next/babel-helpers",
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/babel/babel.git",
|
||||
"directory": "packages/babel-helpers"
|
||||
},
|
||||
"main": "./lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/template": "^7.16.7",
|
||||
"@babel/traverse": "^7.16.7",
|
||||
"@babel/types": "^7.16.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/helper-plugin-test-runner": "^7.16.7",
|
||||
"terser": "^5.9.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
}
|
||||
}
|
64
node_modules/@babel/helpers/scripts/generate-helpers.js
generated
vendored
Normal file
64
node_modules/@babel/helpers/scripts/generate-helpers.js
generated
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
import fs from "fs";
|
||||
import { join } from "path";
|
||||
import { URL, fileURLToPath } from "url";
|
||||
import { minify } from "terser"; // eslint-disable-line
|
||||
|
||||
const HELPERS_FOLDER = new URL("../src/helpers", import.meta.url);
|
||||
const IGNORED_FILES = new Set(["package.json"]);
|
||||
|
||||
export default async function generateHelpers() {
|
||||
let output = `/*
|
||||
* This file is auto-generated! Do not modify it directly.
|
||||
* To re-generate run 'yarn gulp generate-runtime-helpers'
|
||||
*/
|
||||
|
||||
import template from "@babel/template";
|
||||
|
||||
function helper(minVersion, source) {
|
||||
return Object.freeze({
|
||||
minVersion,
|
||||
ast: () => template.program.ast(source),
|
||||
})
|
||||
}
|
||||
|
||||
export default Object.freeze({
|
||||
`;
|
||||
|
||||
for (const file of (await fs.promises.readdir(HELPERS_FOLDER)).sort()) {
|
||||
if (IGNORED_FILES.has(file)) continue;
|
||||
if (file.startsWith(".")) continue; // ignore e.g. vim swap files
|
||||
|
||||
const [helperName] = file.split(".");
|
||||
|
||||
const filePath = join(fileURLToPath(HELPERS_FOLDER), file);
|
||||
if (!file.endsWith(".js")) {
|
||||
console.error("ignoring", filePath);
|
||||
continue;
|
||||
}
|
||||
|
||||
const fileContents = await fs.promises.readFile(filePath, "utf8");
|
||||
const minVersionMatch = fileContents.match(
|
||||
/^\s*\/\*\s*@minVersion\s+(?<minVersion>\S+)\s*\*\/\s*$/m
|
||||
);
|
||||
if (!minVersionMatch) {
|
||||
throw new Error(`@minVersion number missing in ${filePath}`);
|
||||
}
|
||||
const { minVersion } = minVersionMatch.groups;
|
||||
|
||||
const source = await minify(fileContents, {
|
||||
mangle: false,
|
||||
// The _typeof helper has a custom directive that we must keep
|
||||
compress: { directives: false },
|
||||
});
|
||||
|
||||
output += `\
|
||||
${JSON.stringify(helperName)}: helper(
|
||||
${JSON.stringify(minVersion)},
|
||||
${JSON.stringify(source.code)},
|
||||
),
|
||||
`;
|
||||
}
|
||||
|
||||
output += "});";
|
||||
return output;
|
||||
}
|
1
node_modules/@babel/helpers/scripts/package.json
generated
vendored
Normal file
1
node_modules/@babel/helpers/scripts/package.json
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{ "type": "module" }
|
Reference in New Issue
Block a user