initial commit taken from gitlab.lrz.de

This commit is contained in:
privatereese
2018-08-24 18:09:42 +02:00
parent ae54ed4c48
commit fc05486403
28494 changed files with 2159823 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
# @babel/plugin-transform-computed-properties
> Compile ES2015 computed properties to ES5
See our website [@babel/plugin-transform-computed-properties](https://babeljs.io/docs/en/next/babel-plugin-transform-computed-properties.html) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/plugin-transform-computed-properties
```
or using yarn:
```sh
yarn add @babel/plugin-transform-computed-properties --dev
```

View File

@@ -0,0 +1,190 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
function _helperPluginUtils() {
const data = require("@babel/helper-plugin-utils");
_helperPluginUtils = function () {
return data;
};
return data;
}
function _core() {
const data = require("@babel/core");
_core = function () {
return data;
};
return data;
}
var _default = (0, _helperPluginUtils().declare)((api, options) => {
api.assertVersion(7);
const {
loose
} = options;
const pushComputedProps = loose ? pushComputedPropsLoose : pushComputedPropsSpec;
const buildMutatorMapAssign = (0, _core().template)(`
MUTATOR_MAP_REF[KEY] = MUTATOR_MAP_REF[KEY] || {};
MUTATOR_MAP_REF[KEY].KIND = VALUE;
`);
function getValue(prop) {
if (_core().types.isObjectProperty(prop)) {
return prop.value;
} else if (_core().types.isObjectMethod(prop)) {
return _core().types.functionExpression(null, prop.params, prop.body, prop.generator, prop.async);
}
}
function pushAssign(objId, prop, body) {
if (prop.kind === "get" && prop.kind === "set") {
pushMutatorDefine(objId, prop, body);
} else {
body.push(_core().types.expressionStatement(_core().types.assignmentExpression("=", _core().types.memberExpression(_core().types.cloneNode(objId), prop.key, prop.computed || _core().types.isLiteral(prop.key)), getValue(prop))));
}
}
function pushMutatorDefine({
body,
getMutatorId,
scope
}, prop) {
let key = !prop.computed && _core().types.isIdentifier(prop.key) ? _core().types.stringLiteral(prop.key.name) : prop.key;
const maybeMemoise = scope.maybeGenerateMemoised(key);
if (maybeMemoise) {
body.push(_core().types.expressionStatement(_core().types.assignmentExpression("=", maybeMemoise, key)));
key = maybeMemoise;
}
body.push(...buildMutatorMapAssign({
MUTATOR_MAP_REF: getMutatorId(),
KEY: _core().types.cloneNode(key),
VALUE: getValue(prop),
KIND: _core().types.identifier(prop.kind)
}));
}
function pushComputedPropsLoose(info) {
for (const prop of info.computedProps) {
if (prop.kind === "get" || prop.kind === "set") {
pushMutatorDefine(info, prop);
} else {
pushAssign(_core().types.cloneNode(info.objId), prop, info.body);
}
}
}
function pushComputedPropsSpec(info) {
const {
objId,
body,
computedProps,
state
} = info;
for (const prop of computedProps) {
const key = _core().types.toComputedKey(prop);
if (prop.kind === "get" || prop.kind === "set") {
pushMutatorDefine(info, prop);
} else if (_core().types.isStringLiteral(key, {
value: "__proto__"
})) {
pushAssign(objId, prop, body);
} else {
if (computedProps.length === 1) {
return _core().types.callExpression(state.addHelper("defineProperty"), [info.initPropExpression, key, getValue(prop)]);
} else {
body.push(_core().types.expressionStatement(_core().types.callExpression(state.addHelper("defineProperty"), [_core().types.cloneNode(objId), key, getValue(prop)])));
}
}
}
}
return {
visitor: {
ObjectExpression: {
exit(path, state) {
const {
node,
parent,
scope
} = path;
let hasComputed = false;
for (const prop of node.properties) {
hasComputed = prop.computed === true;
if (hasComputed) break;
}
if (!hasComputed) return;
const initProps = [];
const computedProps = [];
let foundComputed = false;
for (const prop of node.properties) {
if (prop.computed) {
foundComputed = true;
}
if (foundComputed) {
computedProps.push(prop);
} else {
initProps.push(prop);
}
}
const objId = scope.generateUidIdentifierBasedOnNode(parent);
const initPropExpression = _core().types.objectExpression(initProps);
const body = [];
body.push(_core().types.variableDeclaration("var", [_core().types.variableDeclarator(objId, initPropExpression)]));
let mutatorRef;
const getMutatorId = function () {
if (!mutatorRef) {
mutatorRef = scope.generateUidIdentifier("mutatorMap");
body.push(_core().types.variableDeclaration("var", [_core().types.variableDeclarator(mutatorRef, _core().types.objectExpression([]))]));
}
return _core().types.cloneNode(mutatorRef);
};
const single = pushComputedProps({
scope,
objId,
body,
computedProps,
initPropExpression,
getMutatorId,
state
});
if (mutatorRef) {
body.push(_core().types.expressionStatement(_core().types.callExpression(state.addHelper("defineEnumerableProperties"), [_core().types.cloneNode(objId), _core().types.cloneNode(mutatorRef)])));
}
if (single) {
path.replaceWith(single);
} else {
body.push(_core().types.expressionStatement(_core().types.cloneNode(objId)));
path.replaceWithMultiple(body);
}
}
}
}
};
});
exports.default = _default;

View File

@@ -0,0 +1,91 @@
{
"_args": [
[
"@babel/plugin-transform-computed-properties@^7.0.0-beta",
"/home/bernhard/freifunk-app/node_modules/metro"
]
],
"_from": "@babel/plugin-transform-computed-properties@>=7.0.0-beta <8.0.0",
"_id": "@babel/plugin-transform-computed-properties@7.0.0-beta.54",
"_inCache": true,
"_installable": true,
"_location": "/@babel/plugin-transform-computed-properties",
"_npmOperationalInternal": {
"host": "s3://npm-registry-packages",
"tmp": "tmp/plugin-transform-computed-properties_7.0.0-beta.54_1531764004420_0.648722120870213"
},
"_npmUser": {
"email": "hi@henryzoo.com",
"name": "hzoo"
},
"_phantomChildren": {},
"_requested": {
"name": "@babel/plugin-transform-computed-properties",
"raw": "@babel/plugin-transform-computed-properties@^7.0.0-beta",
"rawSpec": "^7.0.0-beta",
"scope": "@babel",
"spec": ">=7.0.0-beta <8.0.0",
"type": "range"
},
"_requiredBy": [
"/metro"
],
"_resolved": "https://registry.npmjs.org/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.0.0-beta.54.tgz",
"_shasum": "b28494942b94fb86d01994763d2b5c43bdd986af",
"_shrinkwrap": null,
"_spec": "@babel/plugin-transform-computed-properties@^7.0.0-beta",
"_where": "/home/bernhard/freifunk-app/node_modules/metro",
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.54"
},
"description": "Compile ES2015 computed properties to ES5",
"devDependencies": {
"@babel/core": "7.0.0-beta.54",
"@babel/helper-plugin-test-runner": "7.0.0-beta.54"
},
"directories": {},
"dist": {
"fileCount": 5,
"shasum": "b28494942b94fb86d01994763d2b5c43bdd986af",
"tarball": "https://registry.npmjs.org/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.0.0-beta.54.tgz",
"unpackedSize": 6559
},
"keywords": [
"babel-plugin"
],
"license": "MIT",
"main": "lib/index.js",
"maintainers": [
{
"name": "danez",
"email": "daniel@tschinder.de"
},
{
"name": "existentialism",
"email": "bng412@gmail.com"
},
{
"name": "hzoo",
"email": "hi@henryzoo.com"
},
{
"name": "loganfsmyth",
"email": "loganfsmyth@gmail.com"
},
{
"name": "xtuc",
"email": "contact@xtuc.fr"
}
],
"name": "@babel/plugin-transform-computed-properties",
"optionalDependencies": {},
"peerDependencies": {
"@babel/core": ">=7.0.0-beta.50 <7.0.0-rc.0"
},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-computed-properties"
},
"version": "7.0.0-beta.54"
}