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-template-literals
> Compile ES2015 template literals to ES5
See our website [@babel/plugin-transform-template-literals](https://babeljs.io/docs/en/next/babel-plugin-transform-template-literals.html) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/plugin-transform-template-literals
```
or using yarn:
```sh
yarn add @babel/plugin-transform-template-literals --dev
```

View File

@@ -0,0 +1,147 @@
"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;
let helperName = "taggedTemplateLiteral";
if (loose) helperName += "Loose";
function buildConcatCallExressions(items) {
let avail = true;
return items.reduce(function (left, right) {
let canBeInserted = _core().types.isLiteral(right);
if (!canBeInserted && avail) {
canBeInserted = true;
avail = false;
}
if (canBeInserted && _core().types.isCallExpression(left)) {
left.arguments.push(right);
return left;
}
return _core().types.callExpression(_core().types.memberExpression(left, _core().types.identifier("concat")), [right]);
});
}
return {
visitor: {
TaggedTemplateExpression(path) {
const {
node
} = path;
const {
quasi
} = node;
const strings = [];
const raws = [];
let isStringsRawEqual = true;
for (const elem of quasi.quasis) {
const {
raw,
cooked
} = elem.value;
const value = cooked == null ? path.scope.buildUndefinedNode() : _core().types.stringLiteral(cooked);
strings.push(value);
raws.push(_core().types.stringLiteral(raw));
if (raw !== cooked) {
isStringsRawEqual = false;
}
}
const scope = path.scope.getProgramParent();
const templateObject = scope.generateUidIdentifier("templateObject");
const helperId = this.addHelper(helperName);
const callExpressionInput = [_core().types.arrayExpression(strings)];
if (!isStringsRawEqual) {
callExpressionInput.push(_core().types.arrayExpression(raws));
}
const lazyLoad = _core().template.ast`
function ${templateObject}() {
const data = ${_core().types.callExpression(helperId, callExpressionInput)};
${templateObject} = function() { return data };
return data;
}
`;
scope.path.unshiftContainer("body", lazyLoad);
path.replaceWith(_core().types.callExpression(node.tag, [_core().types.callExpression(_core().types.cloneNode(templateObject), []), ...quasi.expressions]));
},
TemplateLiteral(path) {
const nodes = [];
const expressions = path.get("expressions");
let index = 0;
for (const elem of path.node.quasis) {
if (elem.value.cooked) {
nodes.push(_core().types.stringLiteral(elem.value.cooked));
}
if (index < expressions.length) {
const expr = expressions[index++];
const node = expr.node;
if (!_core().types.isStringLiteral(node, {
value: ""
})) {
nodes.push(node);
}
}
}
const considerSecondNode = !loose || !_core().types.isStringLiteral(nodes[1]);
if (!_core().types.isStringLiteral(nodes[0]) && considerSecondNode) {
nodes.unshift(_core().types.stringLiteral(""));
}
let root = nodes[0];
if (loose) {
for (let i = 1; i < nodes.length; i++) {
root = _core().types.binaryExpression("+", root, nodes[i]);
}
} else if (nodes.length > 1) {
root = buildConcatCallExressions(nodes);
}
path.replaceWith(root);
}
}
};
});
exports.default = _default;

View File

@@ -0,0 +1,92 @@
{
"_args": [
[
"@babel/plugin-transform-template-literals@^7.0.0-beta",
"/home/bernhard/freifunk-app/node_modules/metro"
]
],
"_from": "@babel/plugin-transform-template-literals@>=7.0.0-beta <8.0.0",
"_id": "@babel/plugin-transform-template-literals@7.0.0-beta.54",
"_inCache": true,
"_installable": true,
"_location": "/@babel/plugin-transform-template-literals",
"_npmOperationalInternal": {
"host": "s3://npm-registry-packages",
"tmp": "tmp/plugin-transform-template-literals_7.0.0-beta.54_1531764019827_0.5969271705053687"
},
"_npmUser": {
"email": "hi@henryzoo.com",
"name": "hzoo"
},
"_phantomChildren": {},
"_requested": {
"name": "@babel/plugin-transform-template-literals",
"raw": "@babel/plugin-transform-template-literals@^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-template-literals/-/plugin-transform-template-literals-7.0.0-beta.54.tgz",
"_shasum": "cb1f6303cafb8442a6c6c69a0dfbb60699f327bc",
"_shrinkwrap": null,
"_spec": "@babel/plugin-transform-template-literals@^7.0.0-beta",
"_where": "/home/bernhard/freifunk-app/node_modules/metro",
"dependencies": {
"@babel/helper-annotate-as-pure": "7.0.0-beta.54",
"@babel/helper-plugin-utils": "7.0.0-beta.54"
},
"description": "Compile ES2015 template literals 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": "cb1f6303cafb8442a6c6c69a0dfbb60699f327bc",
"tarball": "https://registry.npmjs.org/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.0.0-beta.54.tgz",
"unpackedSize": 5028
},
"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-template-literals",
"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-template-literals"
},
"version": "7.0.0-beta.54"
}