summaryrefslogtreecommitdiffstats
path: root/node_modules/babel-helper-builder-react-jsx
diff options
context:
space:
mode:
authorGravatar Piotr Russ <mail@pruss.it> 2020-11-16 00:10:28 +0100
committerGravatar Piotr Russ <mail@pruss.it> 2020-11-16 00:10:28 +0100
commite06ec920f7a5d784e674c4c4b4e6d1da3dc7391d (patch)
tree55713f725f77b44ebfec86e4eec3ce33e71458ca /node_modules/babel-helper-builder-react-jsx
downloadwebsite_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.gz
website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.bz2
website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.zip
api, login, auth
Diffstat (limited to 'node_modules/babel-helper-builder-react-jsx')
-rw-r--r--node_modules/babel-helper-builder-react-jsx/.npmignore3
-rw-r--r--node_modules/babel-helper-builder-react-jsx/README.md24
-rw-r--r--node_modules/babel-helper-builder-react-jsx/lib/index.js163
-rw-r--r--node_modules/babel-helper-builder-react-jsx/package-lock.json13
-rw-r--r--node_modules/babel-helper-builder-react-jsx/package.json41
5 files changed, 244 insertions, 0 deletions
diff --git a/node_modules/babel-helper-builder-react-jsx/.npmignore b/node_modules/babel-helper-builder-react-jsx/.npmignore
new file mode 100644
index 0000000..47cdd2c
--- /dev/null
+++ b/node_modules/babel-helper-builder-react-jsx/.npmignore
@@ -0,0 +1,3 @@
+src
+test
+node_modules
diff --git a/node_modules/babel-helper-builder-react-jsx/README.md b/node_modules/babel-helper-builder-react-jsx/README.md
new file mode 100644
index 0000000..895857e
--- /dev/null
+++ b/node_modules/babel-helper-builder-react-jsx/README.md
@@ -0,0 +1,24 @@
+# babel-helper-builder-react-jsx
+
+## Usage
+
+```javascript
+type ElementState = {
+ tagExpr: Object; // tag node
+ tagName: string; // raw string tag name
+ args: Array<Object>; // array of call arguments
+ call?: Object; // optional call property that can be set to override the call expression returned
+ pre?: Function; // function called with (state: ElementState) before building attribs
+ post?: Function; // function called with (state: ElementState) after building attribs
+};
+
+require("babel-helper-builder-react-jsx")({
+ pre: function (state: ElementState) {
+ // called before building the element
+ },
+
+ post: function (state: ElementState) {
+ // called after building the element
+ }
+});
+```
diff --git a/node_modules/babel-helper-builder-react-jsx/lib/index.js b/node_modules/babel-helper-builder-react-jsx/lib/index.js
new file mode 100644
index 0000000..fd7c7f7
--- /dev/null
+++ b/node_modules/babel-helper-builder-react-jsx/lib/index.js
@@ -0,0 +1,163 @@
+"use strict";
+
+exports.__esModule = true;
+
+exports.default = function (opts) {
+ var visitor = {};
+
+ visitor.JSXNamespacedName = function (path) {
+ throw path.buildCodeFrameError("Namespace tags are not supported. ReactJSX is not XML.");
+ };
+
+ visitor.JSXElement = {
+ exit: function exit(path, file) {
+ var callExpr = buildElementCall(path.get("openingElement"), file);
+
+ callExpr.arguments = callExpr.arguments.concat(path.node.children);
+
+ if (callExpr.arguments.length >= 3) {
+ callExpr._prettyCall = true;
+ }
+
+ path.replaceWith(t.inherits(callExpr, path.node));
+ }
+ };
+
+ return visitor;
+
+ function convertJSXIdentifier(node, parent) {
+ if (t.isJSXIdentifier(node)) {
+ if (node.name === "this" && t.isReferenced(node, parent)) {
+ return t.thisExpression();
+ } else if (_esutils2.default.keyword.isIdentifierNameES6(node.name)) {
+ node.type = "Identifier";
+ } else {
+ return t.stringLiteral(node.name);
+ }
+ } else if (t.isJSXMemberExpression(node)) {
+ return t.memberExpression(convertJSXIdentifier(node.object, node), convertJSXIdentifier(node.property, node));
+ }
+
+ return node;
+ }
+
+ function convertAttributeValue(node) {
+ if (t.isJSXExpressionContainer(node)) {
+ return node.expression;
+ } else {
+ return node;
+ }
+ }
+
+ function convertAttribute(node) {
+ var value = convertAttributeValue(node.value || t.booleanLiteral(true));
+
+ if (t.isStringLiteral(value) && !t.isJSXExpressionContainer(node.value)) {
+ value.value = value.value.replace(/\n\s+/g, " ");
+ }
+
+ if (t.isValidIdentifier(node.name.name)) {
+ node.name.type = "Identifier";
+ } else {
+ node.name = t.stringLiteral(node.name.name);
+ }
+
+ return t.inherits(t.objectProperty(node.name, value), node);
+ }
+
+ function buildElementCall(path, file) {
+ path.parent.children = t.react.buildChildren(path.parent);
+
+ var tagExpr = convertJSXIdentifier(path.node.name, path.node);
+ var args = [];
+
+ var tagName = void 0;
+ if (t.isIdentifier(tagExpr)) {
+ tagName = tagExpr.name;
+ } else if (t.isLiteral(tagExpr)) {
+ tagName = tagExpr.value;
+ }
+
+ var state = {
+ tagExpr: tagExpr,
+ tagName: tagName,
+ args: args
+ };
+
+ if (opts.pre) {
+ opts.pre(state, file);
+ }
+
+ var attribs = path.node.attributes;
+ if (attribs.length) {
+ attribs = buildOpeningElementAttributes(attribs, file);
+ } else {
+ attribs = t.nullLiteral();
+ }
+
+ args.push(attribs);
+
+ if (opts.post) {
+ opts.post(state, file);
+ }
+
+ return state.call || t.callExpression(state.callee, args);
+ }
+
+ function buildOpeningElementAttributes(attribs, file) {
+ var _props = [];
+ var objs = [];
+
+ var useBuiltIns = file.opts.useBuiltIns || false;
+ if (typeof useBuiltIns !== "boolean") {
+ throw new Error("transform-react-jsx currently only accepts a boolean option for " + "useBuiltIns (defaults to false)");
+ }
+
+ function pushProps() {
+ if (!_props.length) return;
+
+ objs.push(t.objectExpression(_props));
+ _props = [];
+ }
+
+ while (attribs.length) {
+ var prop = attribs.shift();
+ if (t.isJSXSpreadAttribute(prop)) {
+ pushProps();
+ objs.push(prop.argument);
+ } else {
+ _props.push(convertAttribute(prop));
+ }
+ }
+
+ pushProps();
+
+ if (objs.length === 1) {
+ attribs = objs[0];
+ } else {
+ if (!t.isObjectExpression(objs[0])) {
+ objs.unshift(t.objectExpression([]));
+ }
+
+ var helper = useBuiltIns ? t.memberExpression(t.identifier("Object"), t.identifier("assign")) : file.addHelper("extends");
+
+ attribs = t.callExpression(helper, objs);
+ }
+
+ return attribs;
+ }
+};
+
+var _esutils = require("esutils");
+
+var _esutils2 = _interopRequireDefault(_esutils);
+
+var _babelTypes = require("babel-types");
+
+var t = _interopRequireWildcard(_babelTypes);
+
+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 _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+module.exports = exports["default"]; \ No newline at end of file
diff --git a/node_modules/babel-helper-builder-react-jsx/package-lock.json b/node_modules/babel-helper-builder-react-jsx/package-lock.json
new file mode 100644
index 0000000..904af74
--- /dev/null
+++ b/node_modules/babel-helper-builder-react-jsx/package-lock.json
@@ -0,0 +1,13 @@
+{
+ "name": "babel-helper-builder-react-jsx",
+ "version": "6.24.1",
+ "lockfileVersion": 1,
+ "requires": true,
+ "dependencies": {
+ "esutils": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz",
+ "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs="
+ }
+ }
+}
diff --git a/node_modules/babel-helper-builder-react-jsx/package.json b/node_modules/babel-helper-builder-react-jsx/package.json
new file mode 100644
index 0000000..ed95d4a
--- /dev/null
+++ b/node_modules/babel-helper-builder-react-jsx/package.json
@@ -0,0 +1,41 @@
+{
+ "_from": "babel-helper-builder-react-jsx@^6.24.1",
+ "_id": "babel-helper-builder-react-jsx@6.26.0",
+ "_inBundle": false,
+ "_integrity": "sha1-Of+DE7dci2Xc7/HzHTg+D/KkCKA=",
+ "_location": "/babel-helper-builder-react-jsx",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "range",
+ "registry": true,
+ "raw": "babel-helper-builder-react-jsx@^6.24.1",
+ "name": "babel-helper-builder-react-jsx",
+ "escapedName": "babel-helper-builder-react-jsx",
+ "rawSpec": "^6.24.1",
+ "saveSpec": null,
+ "fetchSpec": "^6.24.1"
+ },
+ "_requiredBy": [
+ "/babel-plugin-transform-react-jsx"
+ ],
+ "_resolved": "https://registry.npmjs.org/babel-helper-builder-react-jsx/-/babel-helper-builder-react-jsx-6.26.0.tgz",
+ "_shasum": "39ff8313b75c8b65dceff1f31d383e0ff2a408a0",
+ "_spec": "babel-helper-builder-react-jsx@^6.24.1",
+ "_where": "/home/pruss/Dev/3-minute-website/node_modules/babel-plugin-transform-react-jsx",
+ "bundleDependencies": false,
+ "dependencies": {
+ "babel-runtime": "^6.26.0",
+ "babel-types": "^6.26.0",
+ "esutils": "^2.0.2"
+ },
+ "deprecated": false,
+ "description": "Helper function to build react jsx",
+ "license": "MIT",
+ "main": "lib/index.js",
+ "name": "babel-helper-builder-react-jsx",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/babel/babel/tree/master/packages/babel-helper-builder-react-jsx"
+ },
+ "version": "6.26.0"
+}