summaryrefslogtreecommitdiff
path: root/node_modules/@babel/plugin-transform-react-jsx-source
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/@babel/plugin-transform-react-jsx-source')
-rw-r--r--node_modules/@babel/plugin-transform-react-jsx-source/LICENSE22
-rw-r--r--node_modules/@babel/plugin-transform-react-jsx-source/README.md19
-rw-r--r--node_modules/@babel/plugin-transform-react-jsx-source/lib/index.js51
-rw-r--r--node_modules/@babel/plugin-transform-react-jsx-source/lib/index.js.map1
-rw-r--r--node_modules/@babel/plugin-transform-react-jsx-source/package.json35
5 files changed, 128 insertions, 0 deletions
diff --git a/node_modules/@babel/plugin-transform-react-jsx-source/LICENSE b/node_modules/@babel/plugin-transform-react-jsx-source/LICENSE
new file mode 100644
index 0000000..f31575e
--- /dev/null
+++ b/node_modules/@babel/plugin-transform-react-jsx-source/LICENSE
@@ -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.
diff --git a/node_modules/@babel/plugin-transform-react-jsx-source/README.md b/node_modules/@babel/plugin-transform-react-jsx-source/README.md
new file mode 100644
index 0000000..b77d0b1
--- /dev/null
+++ b/node_modules/@babel/plugin-transform-react-jsx-source/README.md
@@ -0,0 +1,19 @@
+# @babel/plugin-transform-react-jsx-source
+
+> Add a __source prop to all JSX Elements
+
+See our website [@babel/plugin-transform-react-jsx-source](https://babeljs.io/docs/babel-plugin-transform-react-jsx-source) for more information.
+
+## Install
+
+Using npm:
+
+```sh
+npm install --save-dev @babel/plugin-transform-react-jsx-source
+```
+
+or using yarn:
+
+```sh
+yarn add @babel/plugin-transform-react-jsx-source --dev
+```
diff --git a/node_modules/@babel/plugin-transform-react-jsx-source/lib/index.js b/node_modules/@babel/plugin-transform-react-jsx-source/lib/index.js
new file mode 100644
index 0000000..68526b4
--- /dev/null
+++ b/node_modules/@babel/plugin-transform-react-jsx-source/lib/index.js
@@ -0,0 +1,51 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = void 0;
+var _helperPluginUtils = require("@babel/helper-plugin-utils");
+var _core = require("@babel/core");
+const TRACE_ID = "__source";
+const FILE_NAME_VAR = "_jsxFileName";
+const createNodeFromNullish = (val, fn) => val == null ? _core.types.nullLiteral() : fn(val);
+var _default = exports.default = (0, _helperPluginUtils.declare)(api => {
+ api.assertVersion(7);
+ function makeTrace(fileNameIdentifier, {
+ line,
+ column
+ }) {
+ const fileLineLiteral = createNodeFromNullish(line, _core.types.numericLiteral);
+ const fileColumnLiteral = createNodeFromNullish(column, c => _core.types.numericLiteral(c + 1));
+ return _core.template.expression.ast`{
+ fileName: ${fileNameIdentifier},
+ lineNumber: ${fileLineLiteral},
+ columnNumber: ${fileColumnLiteral},
+ }`;
+ }
+ const isSourceAttr = attr => _core.types.isJSXAttribute(attr) && attr.name.name === TRACE_ID;
+ return {
+ name: "transform-react-jsx-source",
+ visitor: {
+ JSXOpeningElement(path, state) {
+ const {
+ node
+ } = path;
+ if (!node.loc || path.node.attributes.some(isSourceAttr)) {
+ return;
+ }
+ if (!state.fileNameIdentifier) {
+ const fileNameId = path.scope.generateUidIdentifier(FILE_NAME_VAR);
+ state.fileNameIdentifier = fileNameId;
+ path.scope.getProgramParent().push({
+ id: fileNameId,
+ init: _core.types.stringLiteral(state.filename || "")
+ });
+ }
+ node.attributes.push(_core.types.jsxAttribute(_core.types.jsxIdentifier(TRACE_ID), _core.types.jsxExpressionContainer(makeTrace(_core.types.cloneNode(state.fileNameIdentifier), node.loc.start))));
+ }
+ }
+ };
+});
+
+//# sourceMappingURL=index.js.map
diff --git a/node_modules/@babel/plugin-transform-react-jsx-source/lib/index.js.map b/node_modules/@babel/plugin-transform-react-jsx-source/lib/index.js.map
new file mode 100644
index 0000000..0748e6a
--- /dev/null
+++ b/node_modules/@babel/plugin-transform-react-jsx-source/lib/index.js.map
@@ -0,0 +1 @@
+{"version":3,"names":["_helperPluginUtils","require","_core","TRACE_ID","FILE_NAME_VAR","createNodeFromNullish","val","fn","t","nullLiteral","_default","exports","default","declare","api","assertVersion","makeTrace","fileNameIdentifier","line","column","fileLineLiteral","numericLiteral","fileColumnLiteral","c","template","expression","ast","isSourceAttr","attr","isJSXAttribute","name","visitor","JSXOpeningElement","path","state","node","loc","attributes","some","fileNameId","scope","generateUidIdentifier","getProgramParent","push","id","init","stringLiteral","filename","jsxAttribute","jsxIdentifier","jsxExpressionContainer","cloneNode","start"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * This adds {fileName, lineNumber, columnNumber} annotations to JSX tags.\n *\n * NOTE: lineNumber and columnNumber are both 1-based.\n *\n * == JSX Literals ==\n *\n * <sometag />\n *\n * becomes:\n *\n * var __jsxFileName = 'this/file.js';\n * <sometag __source={{fileName: __jsxFileName, lineNumber: 10, columnNumber: 1}}/>\n */\nimport { declare } from \"@babel/helper-plugin-utils\";\nimport { types as t, template } from \"@babel/core\";\n\nconst TRACE_ID = \"__source\";\nconst FILE_NAME_VAR = \"_jsxFileName\";\n\nconst createNodeFromNullish = <T, N extends t.Node>(\n val: T | null,\n fn: (val: T) => N,\n): N | t.NullLiteral => (val == null ? t.nullLiteral() : fn(val));\n\ntype State = {\n fileNameIdentifier: t.Identifier;\n};\nexport default declare<State>(api => {\n api.assertVersion(REQUIRED_VERSION(7));\n\n function makeTrace(\n fileNameIdentifier: t.Identifier,\n { line, column }: { line: number; column: number },\n ) {\n const fileLineLiteral = createNodeFromNullish(line, t.numericLiteral);\n const fileColumnLiteral = createNodeFromNullish(column, c =>\n // c + 1 to make it 1-based instead of 0-based.\n t.numericLiteral(c + 1),\n );\n\n return template.expression.ast`{\n fileName: ${fileNameIdentifier},\n lineNumber: ${fileLineLiteral},\n columnNumber: ${fileColumnLiteral},\n }`;\n }\n\n const isSourceAttr = (attr: t.Node) =>\n t.isJSXAttribute(attr) && attr.name.name === TRACE_ID;\n\n return {\n name: \"transform-react-jsx-source\",\n visitor: {\n JSXOpeningElement(path, state) {\n const { node } = path;\n if (\n // the element was generated and doesn't have location information\n !node.loc ||\n // Already has __source\n path.node.attributes.some(isSourceAttr)\n ) {\n return;\n }\n\n if (!state.fileNameIdentifier) {\n const fileNameId = path.scope.generateUidIdentifier(FILE_NAME_VAR);\n state.fileNameIdentifier = fileNameId;\n\n path.scope.getProgramParent().push({\n id: fileNameId,\n init: t.stringLiteral(state.filename || \"\"),\n });\n }\n\n node.attributes.push(\n t.jsxAttribute(\n t.jsxIdentifier(TRACE_ID),\n t.jsxExpressionContainer(\n makeTrace(t.cloneNode(state.fileNameIdentifier), node.loc.start),\n ),\n ),\n );\n },\n },\n };\n});\n"],"mappings":";;;;;;AAcA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAEA,MAAME,QAAQ,GAAG,UAAU;AAC3B,MAAMC,aAAa,GAAG,cAAc;AAEpC,MAAMC,qBAAqB,GAAGA,CAC5BC,GAAa,EACbC,EAAiB,KACMD,GAAG,IAAI,IAAI,GAAGE,WAAC,CAACC,WAAW,CAAC,CAAC,GAAG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EL,UAAU;YACdM,IAAI,EAAErC,WAAC,CAACsC,aAAa,CAACZ,KAAK,CAACa,QAAQ,IAAI,EAAE;UAC5C,CAAC,CAAC;QACJ;QAEAZ,IAAI,CAACE,UAAU,CAACM,IAAI,CAClBnC,WAAC,CAACwC,YAAY,CACZxC,WAAC,CAACyC,aAAa,CAAC9C,QAAQ,CAAC,EACzBK,WAAC,CAAC0C,sBAAsB,CACtBlC,SAAS,CAACR,WAAC,CAAC2C,SAAS,CAACjB,KAAK,CAACjB,kBAAkB,CAAC,EAAEkB,IAAI,CAACC,GAAG,CAACgB,KAAK,CACjE,CACF,CACF,CAAC;MACH;IACF;EACF,CAAC;AACH,CAAC,CAAC","ignoreList":[]} \ No newline at end of file
diff --git a/node_modules/@babel/plugin-transform-react-jsx-source/package.json b/node_modules/@babel/plugin-transform-react-jsx-source/package.json
new file mode 100644
index 0000000..d919468
--- /dev/null
+++ b/node_modules/@babel/plugin-transform-react-jsx-source/package.json
@@ -0,0 +1,35 @@
+{
+ "name": "@babel/plugin-transform-react-jsx-source",
+ "version": "7.27.1",
+ "description": "Add a __source prop to all JSX Elements",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/babel/babel.git",
+ "directory": "packages/babel-plugin-transform-react-jsx-source"
+ },
+ "homepage": "https://babel.dev/docs/en/next/babel-plugin-transform-react-jsx-source",
+ "license": "MIT",
+ "publishConfig": {
+ "access": "public"
+ },
+ "main": "./lib/index.js",
+ "keywords": [
+ "babel-plugin"
+ ],
+ "dependencies": {
+ "@babel/helper-plugin-utils": "^7.27.1"
+ },
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
+ },
+ "devDependencies": {
+ "@babel/core": "^7.27.1",
+ "@babel/helper-plugin-test-runner": "^7.27.1",
+ "@babel/plugin-syntax-jsx": "^7.27.1"
+ },
+ "engines": {
+ "node": ">=6.9.0"
+ },
+ "author": "The Babel Team (https://babel.dev/team)",
+ "type": "commonjs"
+} \ No newline at end of file