This commit is contained in:
2024-03-22 03:47:51 +05:30
parent 8bcf3d211e
commit 89819f6fe2
28440 changed files with 3211033 additions and 2 deletions

7
node_modules/@svgr/plugin-jsx/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,7 @@
Copyright 2017 Smooth Code
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.

73
node_modules/@svgr/plugin-jsx/README.md generated vendored Normal file
View File

@@ -0,0 +1,73 @@
# @svgr/plugin-jsx
[![Build Status](https://img.shields.io/travis/smooth-code/svgr.svg)](https://travis-ci.org/smooth-code/svgr)
[![Version](https://img.shields.io/npm/v/@svgr/plugin-jsx.svg)](https://www.npmjs.com/package/@svgr/plugin-jsx)
[![MIT License](https://img.shields.io/npm/l/@svgr/plugin-jsx.svg)](https://github.com/smooth-code/svgr/blob/master/LICENSE)
Transforms SVG into JSX.
## Install
```
npm install --save-dev @svgr/plugin-jsx
```
## Usage
**.svgrrc**
```json
{
"plugins": ["@svgr/plugin-jsx"]
}
```
## How does it work?
`@svgr/plugin-jsx` consists in three phases:
- Parsing the SVG code using [svg-parser](https://github.com/Rich-Harris/svg-parser)
- Converting the [HAST](https://github.com/syntax-tree/hast) into a [Babel AST](https://github.com/babel/babel/blob/master/packages/babel-parser/ast/spec.md)
- Applying [`@svgr/babel-preset`](../babel-preset/README.md) transformations
## Applying custom transformations
You can extend the Babel config applied in this plugin using `jsx.babelConfig` config path:
```js
// .svgrrc.js
module.exports = {
jsx: {
babelConfig: {
plugins: [
// For an example, this plugin will remove "id" attribute from "svg" tag
[
'@svgr/babel-plugin-remove-jsx-attribute',
{
elements: ['svg'],
attributes: ['id'],
},
],
],
},
},
}
```
Several Babel plugins are available:
- [`@svgr/babel-plugin-add-jsx-attribute`](../babel-plugin-add-jsx-attribute/README.md)
- [`@svgr/babel-plugin-remove-jsx-attribute`](../babel-plugin-remove-jsx-attribute/README.md)
- [`@svgr/babel-plugin-remove-jsx-empty-expression`](../babel-plugin-remove-jsx-empty-expression/README.md)
- [`@svgr/babel-plugin-replace-jsx-attribute-value`](../babel-plugin-replace-jsx-attribute-value/README.md)
- [`@svgr/babel-plugin-svg-dynamic-title`](../babel-plugin-svg-dynamic-title/README.md)
- [`@svgr/babel-plugin-svg-em-dimensions`](../babel-plugin-svg-em-dimensions/README.md)
- [`@svgr/babel-plugin-transform-react-native-svg`](../babel-plugin-transform-react-native-svg/README.md)
- [`@svgr/babel-plugin-transform-svg-component`](../babel-plugin-transform-svg-component/README.md)
If you want to create your own, reading [Babel Handbook](https://github.com/jamiebuilds/babel-handbook/blob/master/translations/en/plugin-handbook.md) is a good start!
## License
MIT

5
node_modules/@svgr/plugin-jsx/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
import { Plugin } from '@svgr/core';
declare const jsxPlugin: Plugin;
export { jsxPlugin as default };

99
node_modules/@svgr/plugin-jsx/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,99 @@
'use strict';
var svgParser = require('svg-parser');
var hastToBabelAst = require('@svgr/hast-util-to-babel-ast');
var core = require('@babel/core');
var svgrBabelPreset = require('@svgr/babel-preset');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var hastToBabelAst__default = /*#__PURE__*/_interopDefaultLegacy(hastToBabelAst);
var svgrBabelPreset__default = /*#__PURE__*/_interopDefaultLegacy(svgrBabelPreset);
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
const getJsxRuntimeOptions = (config) => {
switch (config.jsxRuntime) {
case null:
case void 0:
case "classic":
return {
jsxRuntime: "classic",
importSource: "react",
jsxRuntimeImport: { namespace: "React", source: "react" }
};
case "classic-preact":
return {
jsxRuntime: "classic",
importSource: "preact/compat",
jsxRuntimeImport: { specifiers: ["h"], source: "preact" }
};
case "automatic":
return { jsxRuntime: "automatic" };
default:
throw new Error(`Unsupported "jsxRuntime" "${config.jsxRuntime}"`);
}
};
const jsxPlugin = (code, config, state) => {
const filePath = state.filePath || "unknown";
const hastTree = svgParser.parse(code);
const babelTree = hastToBabelAst__default["default"](hastTree);
const svgPresetOptions = __spreadProps(__spreadValues({
ref: config.ref,
titleProp: config.titleProp,
descProp: config.descProp,
expandProps: config.expandProps,
dimensions: config.dimensions,
icon: config.icon,
native: config.native,
svgProps: config.svgProps,
replaceAttrValues: config.replaceAttrValues,
typescript: config.typescript,
template: config.template,
memo: config.memo,
exportType: config.exportType,
namedExport: config.namedExport
}, getJsxRuntimeOptions(config)), {
state
});
const result = core.transformFromAstSync(babelTree, code, __spreadValues({
caller: {
name: "svgr"
},
presets: [
core.createConfigItem([svgrBabelPreset__default["default"], svgPresetOptions], {
type: "preset"
})
],
filename: filePath,
babelrc: false,
configFile: false,
code: true,
ast: false,
inputSourceMap: false
}, config.jsx && config.jsx.babelConfig));
if (!(result == null ? void 0 : result.code)) {
throw new Error(`Unable to generate SVG file`);
}
return result.code;
};
module.exports = jsxPlugin;
//# sourceMappingURL=index.js.map

1
node_modules/@svgr/plugin-jsx/dist/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { parse } from 'svg-parser'\nimport hastToBabelAst from '@svgr/hast-util-to-babel-ast'\nimport { transformFromAstSync, createConfigItem } from '@babel/core'\nimport svgrBabelPreset, {\n Options as SvgrPresetOptions,\n} from '@svgr/babel-preset'\nimport type { Plugin, Config } from '@svgr/core'\n\nconst getJsxRuntimeOptions = (config: Config): Partial<SvgrPresetOptions> => {\n switch (config.jsxRuntime) {\n case null:\n case undefined:\n case 'classic':\n return {\n jsxRuntime: 'classic',\n importSource: 'react',\n jsxRuntimeImport: { namespace: 'React', source: 'react' },\n }\n case 'classic-preact':\n return {\n jsxRuntime: 'classic',\n importSource: 'preact/compat',\n jsxRuntimeImport: { specifiers: ['h'], source: 'preact' },\n }\n case 'automatic':\n return { jsxRuntime: 'automatic' }\n default:\n throw new Error(`Unsupported \"jsxRuntime\" \"${config.jsxRuntime}\"`)\n }\n}\n\nconst jsxPlugin: Plugin = (code, config, state) => {\n const filePath = state.filePath || 'unknown'\n const hastTree = parse(code)\n\n const babelTree = hastToBabelAst(hastTree)\n\n const svgPresetOptions: SvgrPresetOptions = {\n ref: config.ref,\n titleProp: config.titleProp,\n descProp: config.descProp,\n expandProps: config.expandProps,\n dimensions: config.dimensions,\n icon: config.icon,\n native: config.native,\n svgProps: config.svgProps,\n replaceAttrValues: config.replaceAttrValues,\n typescript: config.typescript,\n template: config.template,\n memo: config.memo,\n exportType: config.exportType,\n namedExport: config.namedExport,\n ...getJsxRuntimeOptions(config),\n state,\n }\n\n const result = transformFromAstSync(babelTree, code, {\n caller: {\n name: 'svgr',\n },\n presets: [\n createConfigItem([svgrBabelPreset, svgPresetOptions], {\n type: 'preset',\n }),\n ],\n filename: filePath,\n babelrc: false,\n configFile: false,\n code: true,\n ast: false,\n // @ts-ignore\n inputSourceMap: false,\n ...(config.jsx && config.jsx.babelConfig),\n })\n\n if (!result?.code) {\n throw new Error(`Unable to generate SVG file`)\n }\n\n return result.code\n}\n\nexport default jsxPlugin\n"],"names":["parse","hastToBabelAst","transformFromAstSync","createConfigItem","svgrBabelPreset"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,MAAM,oBAAA,GAAuB,CAAC,MAA+C,KAAA;AAC3E,EAAA,QAAQ,OAAO,UAAY;AAAA,IACzB,KAAK,IAAA,CAAA;AAAA,IACL,KAAK,KAAA,CAAA,CAAA;AAAA,IACL,KAAK,SAAA;AACH,MAAO,OAAA;AAAA,QACL,UAAY,EAAA,SAAA;AAAA,QACZ,YAAc,EAAA,OAAA;AAAA,QACd,gBAAkB,EAAA,EAAE,SAAW,EAAA,OAAA,EAAS,QAAQ,OAAQ,EAAA;AAAA,OAC1D,CAAA;AAAA,IACF,KAAK,gBAAA;AACH,MAAO,OAAA;AAAA,QACL,UAAY,EAAA,SAAA;AAAA,QACZ,YAAc,EAAA,eAAA;AAAA,QACd,kBAAkB,EAAE,UAAA,EAAY,CAAC,GAAG,CAAA,EAAG,QAAQ,QAAS,EAAA;AAAA,OAC1D,CAAA;AAAA,IACF,KAAK,WAAA;AACH,MAAO,OAAA,EAAE,YAAY,WAAY,EAAA,CAAA;AAAA,IACnC;AACE,MAAA,MAAM,IAAI,KAAA,CAAM,CAA6B,0BAAA,EAAA,MAAA,CAAO,UAAa,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,GACrE;AACF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U,EAAA,QAAA;AAAA,IACV,OAAS,EAAA,KAAA;AAAA,IACT,UAAY,EAAA,KAAA;AAAA,IACZ,IAAM,EAAA,IAAA;AAAA,IACN,GAAK,EAAA,KAAA;AAAA,IAEL,cAAgB,EAAA,KAAA;AAAA,GAAA,EACZ,MAAO,CAAA,GAAA,IAAO,MAAO,CAAA,GAAA,CAAI,WAC9B,CAAA,CAAA,CAAA;AAED,EAAI,IAAA,EAAC,iCAAQ,IAAM,CAAA,EAAA;AACjB,IAAM,MAAA,IAAI,MAAM,CAA6B,2BAAA,CAAA,CAAA,CAAA;AAAA,GAC/C;AAEA,EAAA,OAAO,MAAO,CAAA,IAAA,CAAA;AAChB;;;;"}

46
node_modules/@svgr/plugin-jsx/package.json generated vendored Normal file
View File

@@ -0,0 +1,46 @@
{
"name": "@svgr/plugin-jsx",
"description": "Transform SVG into JSX",
"version": "6.5.1",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./package.json": "./package.json"
},
"repository": "https://github.com/gregberge/svgr/tree/main/packages/plugin-jsx",
"author": "Greg Bergé <berge.greg@gmail.com>",
"publishConfig": {
"access": "public"
},
"keywords": [
"svgr-plugin"
],
"engines": {
"node": ">=10"
},
"homepage": "https://react-svgr.com",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/gregberge"
},
"license": "MIT",
"scripts": {
"reset": "rm -rf dist",
"build": "rollup -c ../../build/rollup.config.js",
"prepublishOnly": "npm run reset && npm run build"
},
"peerDependencies": {
"@svgr/core": "^6.0.0"
},
"dependencies": {
"@babel/core": "^7.19.6",
"@svgr/babel-preset": "^6.5.1",
"@svgr/hast-util-to-babel-ast": "^6.5.1",
"svg-parser": "^2.0.4"
},
"gitHead": "d5efedd372999692f84d30072e502b5a6b8fe734"
}