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

View File

@@ -0,0 +1,50 @@
# Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [6.5.1](https://github.com/gregberge/svgr/compare/v6.5.0...v6.5.1) (2022-10-27)
**Note:** Version bump only for package @svgr/babel-plugin-add-jsx-attribute
# [6.5.0](https://github.com/gregberge/svgr/compare/v6.4.0...v6.5.0) (2022-10-14)
**Note:** Version bump only for package @svgr/babel-plugin-add-jsx-attribute
## [6.3.1](https://github.com/gregberge/svgr/compare/v6.3.0...v6.3.1) (2022-07-22)
### Bug Fixes
- fix exports compat with ESM ([#749](https://github.com/gregberge/svgr/issues/749)) ([f3e304c](https://github.com/gregberge/svgr/commit/f3e304c166282f042ecd4d6c396a0798a7f0b490))
# [6.3.0](https://github.com/gregberge/svgr/compare/v6.2.1...v6.3.0) (2022-07-18)
### Bug Fixes
- **package.json:** fix exports ([#745](https://github.com/gregberge/svgr/issues/745)) ([2a368d1](https://github.com/gregberge/svgr/commit/2a368d1305949ec6426c7c7312c04224071ec2bd))
# [5.4.0](https://github.com/gregberge/svgr/tree/master/packages/babel-plugin-add-jsx-attribute/compare/v5.3.1...v5.4.0) (2020-04-27)
**Note:** Version bump only for package @svgr/babel-plugin-add-jsx-attribute
## [5.0.1](https://github.com/gregberge/svgr/tree/master/packages/babel-plugin-add-jsx-attribute/compare/v5.0.0...v5.0.1) (2019-12-29)
### Bug Fixes
- fix engines in package.json ([a45d6fc](https://github.com/gregberge/svgr/tree/master/packages/babel-plugin-add-jsx-attribute/commit/a45d6fc8b43402bec60ed4e9273f90fdc65a23a7))
# [4.2.0](https://github.com/gregberge/svgr/tree/master/packages/babel-plugin-add-jsx-attribute/compare/v4.1.0...v4.2.0) (2019-04-11)
**Note:** Version bump only for package @svgr/babel-plugin-add-jsx-attribute
# [4.0.0](https://github.com/gregberge/svgr/compare/v3.1.0...v4.0.0) (2018-11-04)
### Features
- **v4:** new architecture ([ac8b8ca](https://github.com/gregberge/svgr/commit/ac8b8ca))
### BREAKING CHANGES
- **v4:** - `template` option must now returns a Babel AST
* `@svgr/core` does not include svgo & prettier by default

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.

View File

@@ -0,0 +1,37 @@
# @svgr/babel-plugin-add-jsx-attribute
## Install
```
npm install --save-dev @svgr/babel-plugin-add-jsx-attribute
```
## Usage
**.babelrc**
```json
{
"plugins": [
[
"@svgr/babel-plugin-add-jsx-attribute",
{
"elements": ["svg"],
"attributes": [
{
"name": "width",
"value": "200",
"spread": false,
"literal": false,
"position": "end"
}
]
}
]
]
}
```
## License
MIT

View File

@@ -0,0 +1,20 @@
import { ConfigAPI, NodePath, types } from '@babel/core';
interface Attribute {
name: string;
value?: boolean | number | string | null;
spread?: boolean;
literal?: boolean;
position?: 'start' | 'end';
}
interface Options {
elements: string[];
attributes: Attribute[];
}
declare const addJSXAttribute: (_: ConfigAPI, opts: Options) => {
visitor: {
JSXOpeningElement(path: NodePath<types.JSXOpeningElement>): void;
};
};
export { Attribute, Options, addJSXAttribute as default };

View File

@@ -0,0 +1,79 @@
'use strict';
var core = require('@babel/core');
const positionMethod = {
start: "unshiftContainer",
end: "pushContainer"
};
const addJSXAttribute = (_, opts) => {
function getAttributeValue({
literal,
value
}) {
if (typeof value === "boolean") {
return core.types.jsxExpressionContainer(core.types.booleanLiteral(value));
}
if (typeof value === "number") {
return core.types.jsxExpressionContainer(core.types.numericLiteral(value));
}
if (typeof value === "string" && literal) {
return core.types.jsxExpressionContainer(
core.template.ast(value).expression
);
}
if (typeof value === "string") {
return core.types.stringLiteral(value);
}
return null;
}
function getAttribute({ spread, name, value, literal }) {
if (spread) {
return core.types.jsxSpreadAttribute(core.types.identifier(name));
}
return core.types.jsxAttribute(
core.types.jsxIdentifier(name),
getAttributeValue({ value, literal })
);
}
return {
visitor: {
JSXOpeningElement(path) {
if (!core.types.isJSXIdentifier(path.node.name))
return;
if (!opts.elements.includes(path.node.name.name))
return;
opts.attributes.forEach(
({
name,
value = null,
spread = false,
literal = false,
position = "end"
}) => {
const method = positionMethod[position];
const newAttribute = getAttribute({ spread, name, value, literal });
const attributes = path.get("attributes");
const isEqualAttribute = (attribute) => {
if (spread)
return attribute.isJSXSpreadAttribute() && attribute.get("argument").isIdentifier({ name });
return attribute.isJSXAttribute() && attribute.get("name").isJSXIdentifier({ name });
};
const replaced = attributes.some((attribute) => {
if (!isEqualAttribute(attribute))
return false;
attribute.replaceWith(newAttribute);
return true;
});
if (!replaced) {
path[method]("attributes", newAttribute);
}
}
);
}
}
};
};
module.exports = addJSXAttribute;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,40 @@
{
"name": "@svgr/babel-plugin-add-jsx-attribute",
"description": "Add JSX attribute",
"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/babel-plugin-add-jsx-attribute",
"author": "Greg Bergé <berge.greg@gmail.com>",
"publishConfig": {
"access": "public"
},
"keywords": [
"babel-plugin"
],
"engines": {
"node": ">=10"
},
"homepage": "https://react-svgr.com",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/gregberge"
},
"license": "MIT",
"peerDependencies": {
"@babel/core": "^7.0.0-0"
},
"scripts": {
"reset": "rm -rf dist",
"build": "rollup -c ../../build/rollup.config.js",
"prepublishOnly": "npm run reset && npm run build"
},
"gitHead": "d5efedd372999692f84d30072e502b5a6b8fe734"
}

View File

@@ -0,0 +1,4 @@
{
"extends": "../../tsconfig",
"include": ["src"]
}

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.

View File

@@ -0,0 +1,29 @@
# @svgr/babel-plugin-remove-jsx-attribute
## Install
```
npm install --save-dev @svgr/babel-plugin-remove-jsx-attribute
```
## Usage
**.babelrc**
```json
{
"plugins": [
[
"@svgr/babel-plugin-remove-jsx-attribute",
{
"elements": ["svg"],
"attributes": ["width", "height"]
}
]
]
}
```
## License
MIT

View File

@@ -0,0 +1,13 @@
import { ConfigAPI, NodePath, types } from '@babel/core';
interface Options {
elements: string[];
attributes: string[];
}
declare const removeJSXAttribute: (_: ConfigAPI, opts: Options) => {
visitor: {
JSXOpeningElement(path: NodePath<types.JSXOpeningElement>): void;
};
};
export { Options, removeJSXAttribute as default };

View File

@@ -0,0 +1,22 @@
'use strict';
var core = require('@babel/core');
const removeJSXAttribute = (_, opts) => ({
visitor: {
JSXOpeningElement(path) {
if (!core.types.isJSXIdentifier(path.node.name))
return;
if (!opts.elements.includes(path.node.name.name))
return;
path.get("attributes").forEach((attribute) => {
if (core.types.isJSXAttribute(attribute.node) && core.types.isJSXIdentifier(attribute.node.name) && opts.attributes.includes(attribute.node.name.name)) {
attribute.remove();
}
});
}
}
});
module.exports = removeJSXAttribute;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\nimport { ConfigAPI, types as t, NodePath } from '@babel/core'\n\nexport interface Options {\n elements: string[]\n attributes: string[]\n}\n\nconst removeJSXAttribute = (_: ConfigAPI, opts: Options) => ({\n visitor: {\n JSXOpeningElement(path: NodePath<t.JSXOpeningElement>) {\n if (!t.isJSXIdentifier(path.node.name)) return\n if (!opts.elements.includes(path.node.name.name)) return\n\n // @ts-ignore\n path.get('attributes').forEach((attribute) => {\n if (\n t.isJSXAttribute(attribute.node) &&\n t.isJSXIdentifier(attribute.node.name) &&\n opts.attributes.includes(attribute.node.name.name)\n ) {\n attribute.remove()\n }\n })\n },\n },\n})\n\nexport default removeJSXAttribute\n"],"names":["t"],"mappings":";;;;AAQM,MAAA,kBAAA,GAAqB,CAAC,CAAA,EAAc,IAAmB,MAAA;AAAA,EAC3D,OAAS,EAAA;AAAA,IACP,kBAAkB,IAAqC,EAAA;AACrD,MAAA,IAAI,CAACA,UAAA,CAAE,eAAgB,CAAA,IAAA,CAAK,KAAK,IAAI,CAAA;AAAG,QAAA,OAAA;AACxC,MAAA,IAAI,CAAC,IAAK,CAAA,QAAA,CAAS,SAAS,IAAK,CAAA,IAAA,CAAK,KAAK,IAAI,CAAA;AAAG,QAAA,OAAA;AAGlD,MAAA,IAAA,CAAK,GAAI,CAAA,YAAY,CAAE,CAAA,OAAA,CAAQ,CAAC,SAAc,KAAA;AAC5C,QAAA,IACEA,WAAE,cAAe,CAAA,SAAA,CAAU,IAAI,CAC/B,IAAAA,UAAA,CAAE,gBAAgB,SAAU,CAAA,IAAA,CAAK,IAAI,CAAA,IACrC,KAAK,UAAW,CAAA,QAAA,CAAS,UAAU,IAAK,CAAA,IAAA,CAAK,IAAI,CACjD,EAAA;AACA,UAAA,SAAA,CAAU,MAAO,EAAA,CAAA;AAAA,SACnB;AAAA,OACD,CAAA,CAAA;AAAA,KACH;AAAA,GACF;AACF,CAAA;;;;"}

View File

@@ -0,0 +1,40 @@
{
"name": "@svgr/babel-plugin-remove-jsx-attribute",
"description": "Remove JSX attribute",
"version": "8.0.0",
"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/babel-plugin-remove-jsx-attribute",
"author": "Greg Bergé <berge.greg@gmail.com>",
"publishConfig": {
"access": "public"
},
"keywords": [
"babel-plugin"
],
"engines": {
"node": ">=14"
},
"homepage": "https://react-svgr.com",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/gregberge"
},
"license": "MIT",
"peerDependencies": {
"@babel/core": "^7.0.0-0"
},
"scripts": {
"reset": "rm -rf dist",
"build": "rollup -c ../../build/rollup.config.mjs",
"prepublishOnly": "pnpm run reset && pnpm run build"
},
"gitHead": "52a1079681477587ef0d842c0e78531adf2d2520"
}

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.

View File

@@ -0,0 +1,21 @@
# @svgr/babel-plugin-remove-jsx-empty-expression
## Install
```
npm install --save-dev @svgr/babel-plugin-remove-jsx-empty-expression
```
## Usage
**.babelrc**
```json
{
"plugins": ["@svgr/babel-plugin-remove-jsx-empty-expression"]
}
```
## License
MIT

View File

@@ -0,0 +1,9 @@
import { NodePath, types } from '@babel/core';
declare const removeJSXEmptyExpression: () => {
visitor: {
JSXExpressionContainer(path: NodePath<types.JSXExpressionContainer>): void;
};
};
export { removeJSXEmptyExpression as default };

View File

@@ -0,0 +1,16 @@
'use strict';
var core = require('@babel/core');
const removeJSXEmptyExpression = () => ({
visitor: {
JSXExpressionContainer(path) {
if (core.types.isJSXEmptyExpression(path.get("expression"))) {
path.remove();
}
}
}
});
module.exports = removeJSXEmptyExpression;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\nimport { types as t, NodePath } from '@babel/core'\n\nconst removeJSXEmptyExpression = () => ({\n visitor: {\n JSXExpressionContainer(path: NodePath<t.JSXExpressionContainer>) {\n if (t.isJSXEmptyExpression(path.get('expression'))) {\n path.remove()\n }\n },\n },\n})\n\nexport default removeJSXEmptyExpression\n"],"names":["t"],"mappings":";;;;AAGA,MAAM,2BAA2B,OAAO;AAAA,EACtC,OAAS,EAAA;AAAA,IACP,uBAAuB,IAA0C,EAAA;AAC/D,MAAA,IAAIA,WAAE,oBAAqB,CAAA,IAAA,CAAK,GAAI,CAAA,YAAY,CAAC,CAAG,EAAA;AAClD,QAAA,IAAA,CAAK,MAAO,EAAA,CAAA;AAAA,OACd;AAAA,KACF;AAAA,GACF;AACF,CAAA;;;;"}

View File

@@ -0,0 +1,40 @@
{
"name": "@svgr/babel-plugin-remove-jsx-empty-expression",
"description": "Remove JSX empty expression",
"version": "8.0.0",
"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/babel-plugin-remove-jsx-empty-expression",
"author": "Greg Bergé <berge.greg@gmail.com>",
"publishConfig": {
"access": "public"
},
"keywords": [
"babel-plugin"
],
"engines": {
"node": ">=14"
},
"homepage": "https://react-svgr.com",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/gregberge"
},
"license": "MIT",
"peerDependencies": {
"@babel/core": "^7.0.0-0"
},
"scripts": {
"reset": "rm -rf dist",
"build": "rollup -c ../../build/rollup.config.mjs",
"prepublishOnly": "pnpm run reset && pnpm run build"
},
"gitHead": "52a1079681477587ef0d842c0e78531adf2d2520"
}

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.

View File

@@ -0,0 +1,31 @@
# @svgr/babel-plugin-replace-jsx-attribute-value
## Install
```
npm install --save-dev @svgr/babel-plugin-replace-jsx-attribute-value
```
## Usage
**.babelrc**
```json
{
"plugins": [
[
"@svgr/babel-plugin-replace-jsx-attribute-value",
{
"values": [
{ "value": "#000", "newValue": "#fff" },
{ "value": "blue", "newValue": "props.color", "literal": true }
]
}
]
]
}
```
## License
MIT

View File

@@ -0,0 +1,17 @@
import { ConfigAPI, NodePath, types } from '@babel/core';
interface Value {
value: string;
newValue: string | boolean | number;
literal?: boolean;
}
interface Options {
values: Value[];
}
declare const addJSXAttribute: (api: ConfigAPI, opts: Options) => {
visitor: {
JSXAttribute(path: NodePath<types.JSXAttribute>): void;
};
};
export { Options, Value, addJSXAttribute as default };

View File

@@ -0,0 +1,43 @@
'use strict';
var core = require('@babel/core');
const addJSXAttribute = (api, opts) => {
const getAttributeValue = (value, literal) => {
if (typeof value === "string" && literal) {
return core.types.jsxExpressionContainer(
core.template.ast(value).expression
);
}
if (typeof value === "string") {
return core.types.stringLiteral(value);
}
if (typeof value === "boolean") {
return core.types.jsxExpressionContainer(core.types.booleanLiteral(value));
}
if (typeof value === "number") {
return core.types.jsxExpressionContainer(core.types.numericLiteral(value));
}
return null;
};
return {
visitor: {
JSXAttribute(path) {
const valuePath = path.get("value");
if (!valuePath.isStringLiteral())
return;
opts.values.forEach(({ value, newValue, literal }) => {
if (!valuePath.isStringLiteral({ value }))
return;
const attributeValue = getAttributeValue(newValue, literal);
if (attributeValue) {
valuePath.replaceWith(attributeValue);
}
});
}
}
};
};
module.exports = addJSXAttribute;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\nimport { ConfigAPI, types as t, NodePath, template } from '@babel/core'\n\nexport interface Value {\n value: string\n newValue: string | boolean | number\n literal?: boolean\n}\n\nexport interface Options {\n values: Value[]\n}\n\nconst addJSXAttribute = (api: ConfigAPI, opts: Options) => {\n const getAttributeValue = (\n value: string | boolean | number,\n literal?: boolean,\n ) => {\n if (typeof value === 'string' && literal) {\n return t.jsxExpressionContainer(\n (template.ast(value) as t.ExpressionStatement).expression,\n )\n }\n\n if (typeof value === 'string') {\n return t.stringLiteral(value)\n }\n\n if (typeof value === 'boolean') {\n return t.jsxExpressionContainer(t.booleanLiteral(value))\n }\n\n if (typeof value === 'number') {\n return t.jsxExpressionContainer(t.numericLiteral(value))\n }\n\n return null\n }\n\n return {\n visitor: {\n JSXAttribute(path: NodePath<t.JSXAttribute>) {\n const valuePath = path.get('value')\n if (!valuePath.isStringLiteral()) return\n\n opts.values.forEach(({ value, newValue, literal }) => {\n if (!valuePath.isStringLiteral({ value })) return\n const attributeValue = getAttributeValue(newValue, literal)\n if (attributeValue) {\n valuePath.replaceWith(attributeValue)\n }\n })\n },\n },\n }\n}\n\nexport default addJSXAttribute\n"],"names":["t","template"],"mappings":";;;;AAaM,MAAA,eAAA,GAAkB,CAAC,GAAA,EAAgB,IAAkB,KAAA;AACzD,EAAM,MAAA,iBAAA,GAAoB,CACxB,KAAA,EACA,OACG,KAAA;AACH,IAAI,IAAA,OAAO,KAAU,KAAA,QAAA,IAAY,OAAS,EAAA;AACxC,MAAA,OAAOA,UAAE,CAAA,sBAAA;AAAA,QACNC,aAAA,CAAS,GAAI,CAAA,KAAK,CAA4B,CAAA,UAAA;AAAA,OACjD,CAAA;AAAA,KACF;AAEA,IAAI,IAAA,OAAO,UAAU,QAAU,EAAA;AAC7B,MAAO,OAAAD,UAAA,CAAE,cAAc,KAAK,CAAA,CAAA;AAAA,KAC9B;AAEA,IAAI,IAAA,OAAO,UAAU,SAAW,EAAA;AAC9B,MAAA,OAAOA,UAAE,CAAA,sBAAA,CAAuBA,UAAE,CAAA,cAAA,CAAe,KAAK,CAAC,CAAA,CAAA;AAAA,KACzD;AAEA,IAAI,IAAA,OAAO,UAAU,QAAU,EAAA;AAC7B,MAAA,OAAOA,UAAE,CAAA,sBAAA,CAAuBA,UAAE,CAAA,cAAA,CAAe,KAAK,CAAC,CAAA,CAAA;AAAA,KACzD;AAEA,IAAO,OAAA,IAAA,CAAA;AAAA,GACT,CAAA;AAEA,EAAO,OAAA;AAAA,IACL,OAAS,EAAA;AAAA,MACP,aAAa,IAAgC,EAAA;AAC3C,QAAM,MAAA,SAAA,GAAY,IAAK,CAAA,GAAA,CAAI,OAAO,CAAA,CAAA;AAClC,QAAI,IAAA,CAAC,UAAU,eAAgB,EAAA;AAAG,UAAA,OAAA;AAElC,QAAA,IAAA,CAAK,OAAO,OAAQ,CAAA,CAAC,EAAE,KAAO,EAAA,QAAA,EAAU,SAAc,KAAA;AACpD,UAAA,IAAI,CAAC,SAAA,CAAU,eAAgB,CAAA,EAAE,OAAO,CAAA;AAAG,YAAA,OAAA;AAC3C,UAAM,MAAA,cAAA,GAAiB,iBAAkB,CAAA,QAAA,EAAU,OAAO,CAAA,CAAA;AAC1D,UAAA,IAAI,cAAgB,EAAA;AAClB,YAAA,SAAA,CAAU,YAAY,cAAc,CAAA,CAAA;AAAA,WACtC;AAAA,SACD,CAAA,CAAA;AAAA,OACH;AAAA,KACF;AAAA,GACF,CAAA;AACF;;;;"}

View File

@@ -0,0 +1,40 @@
{
"name": "@svgr/babel-plugin-replace-jsx-attribute-value",
"description": "Replace JSX attribute value",
"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/babel-plugin-replace-jsx-attribute-value",
"author": "Greg Bergé <berge.greg@gmail.com>",
"publishConfig": {
"access": "public"
},
"keywords": [
"babel-plugin"
],
"engines": {
"node": ">=10"
},
"homepage": "https://react-svgr.com",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/gregberge"
},
"license": "MIT",
"peerDependencies": {
"@babel/core": "^7.0.0-0"
},
"scripts": {
"reset": "rm -rf dist",
"build": "rollup -c ../../build/rollup.config.js",
"prepublishOnly": "npm run reset && npm run build"
},
"gitHead": "d5efedd372999692f84d30072e502b5a6b8fe734"
}

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.

View File

@@ -0,0 +1,25 @@
# @svgr/babel-plugin-svg-dynamic-title
## Install
```
npm install --save-dev @svgr/babel-plugin-svg-dynamic-title
```
## Usage
**.babelrc**
```json
{
"plugins": ["@svgr/babel-plugin-svg-dynamic-title"]
}
```
## Note
This plugin handles both the titleProp and descProp options. By default, it will handle titleProp only.
## License
MIT

View File

@@ -0,0 +1,16 @@
import { NodePath, types } from '@babel/core';
declare type tag = 'title' | 'desc';
interface Options {
tag: tag | null;
}
interface State {
opts: Options;
}
declare const plugin: () => {
visitor: {
JSXElement(path: NodePath<types.JSXElement>, state: State): void;
};
};
export { Options, plugin as default };

View File

@@ -0,0 +1,101 @@
'use strict';
var core = require('@babel/core');
const elements = ["svg", "Svg"];
const createTagElement = (tag, children = [], attributes = []) => {
const eleName = core.types.jsxIdentifier(tag);
return core.types.jsxElement(
core.types.jsxOpeningElement(eleName, attributes),
core.types.jsxClosingElement(eleName),
children
);
};
const createTagIdAttribute = (tag) => core.types.jsxAttribute(
core.types.jsxIdentifier("id"),
core.types.jsxExpressionContainer(core.types.identifier(`${tag}Id`))
);
const addTagIdAttribute = (tag, attributes) => {
const existingId = attributes.find(
(attribute) => core.types.isJSXAttribute(attribute) && attribute.name.name === "id"
);
if (!existingId) {
return [...attributes, createTagIdAttribute(tag)];
}
existingId.value = core.types.jsxExpressionContainer(
core.types.isStringLiteral(existingId.value) ? core.types.logicalExpression("||", core.types.identifier(`${tag}Id`), existingId.value) : core.types.identifier(`${tag}Id`)
);
return attributes;
};
const plugin = () => ({
visitor: {
JSXElement(path, state) {
const tag = state.opts.tag || "title";
if (!elements.length)
return;
const openingElement = path.get("openingElement");
const openingElementName = openingElement.get("name");
if (!elements.some(
(element) => openingElementName.isJSXIdentifier({ name: element })
)) {
return;
}
const getTagElement = (existingTitle) => {
var _a;
const tagExpression = core.types.identifier(tag);
if (existingTitle) {
existingTitle.openingElement.attributes = addTagIdAttribute(
tag,
existingTitle.openingElement.attributes
);
}
const conditionalTitle = core.types.conditionalExpression(
tagExpression,
createTagElement(
tag,
[core.types.jsxExpressionContainer(tagExpression)],
existingTitle ? existingTitle.openingElement.attributes : [createTagIdAttribute(tag)]
),
core.types.nullLiteral()
);
if ((_a = existingTitle == null ? void 0 : existingTitle.children) == null ? void 0 : _a.length) {
return core.types.jsxExpressionContainer(
core.types.conditionalExpression(
core.types.binaryExpression(
"===",
tagExpression,
core.types.identifier("undefined")
),
existingTitle,
conditionalTitle
)
);
}
return core.types.jsxExpressionContainer(conditionalTitle);
};
let tagElement = null;
const hasTitle = path.get("children").some((childPath) => {
if (childPath.node === tagElement)
return false;
if (!childPath.isJSXElement())
return false;
const name = childPath.get("openingElement").get("name");
if (!name.isJSXIdentifier())
return false;
if (name.node.name !== tag)
return false;
tagElement = getTagElement(childPath.node);
childPath.replaceWith(tagElement);
return true;
});
tagElement = tagElement || getTagElement();
if (!hasTitle) {
path.node.children.unshift(tagElement);
path.replaceWith(path.node);
}
}
}
});
module.exports = plugin;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,40 @@
{
"name": "@svgr/babel-plugin-svg-dynamic-title",
"description": "Transform SVG by adding a dynamic title element",
"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/babel-plugin-svg-dynamic-title",
"author": "Greg Bergé <berge.greg@gmail.com>",
"publishConfig": {
"access": "public"
},
"keywords": [
"babel-plugin"
],
"engines": {
"node": ">=10"
},
"homepage": "https://react-svgr.com",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/gregberge"
},
"license": "MIT",
"peerDependencies": {
"@babel/core": "^7.0.0-0"
},
"scripts": {
"reset": "rm -rf dist",
"build": "rollup -c ../../build/rollup.config.js",
"prepublishOnly": "npm run reset && npm run build"
},
"gitHead": "d5efedd372999692f84d30072e502b5a6b8fe734"
}

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.

View File

@@ -0,0 +1,23 @@
# @svgr/babel-plugin-svg-em-dimensions
## Install
```
npm install --save-dev @svgr/babel-plugin-svg-em-dimensions
```
## Usage
**.babelrc**
```json
{
"plugins": [
["@svgr/babel-plugin-svg-em-dimensions", { "width": 24, "height": 24 }]
]
}
```
## License
MIT

View File

@@ -0,0 +1,13 @@
import { ConfigAPI, NodePath, types } from '@babel/core';
interface Options {
width: number | string;
height: number | string;
}
declare const plugin: (_: ConfigAPI, opts: Options) => {
visitor: {
JSXOpeningElement(path: NodePath<types.JSXOpeningElement>): void;
};
};
export { Options, plugin as default };

View File

@@ -0,0 +1,57 @@
'use strict';
var core = require('@babel/core');
const elements = ["svg", "Svg"];
const getValue = (raw) => {
if (raw === void 0)
return core.types.stringLiteral("1em");
switch (typeof raw) {
case "number":
return core.types.jsxExpressionContainer(core.types.numericLiteral(raw));
case "string":
return core.types.stringLiteral(raw);
default:
return core.types.stringLiteral("1em");
}
};
const plugin = (_, opts) => ({
visitor: {
JSXOpeningElement(path) {
if (!elements.some(
(element) => path.get("name").isJSXIdentifier({ name: element })
))
return;
const values = {
width: getValue(opts.width),
height: getValue(opts.height)
};
const requiredAttributes = Object.keys(values);
path.get("attributes").forEach((attributePath) => {
if (!attributePath.isJSXAttribute())
return;
const namePath = attributePath.get("name");
if (!namePath.isJSXIdentifier())
return;
const index = requiredAttributes.indexOf(namePath.node.name);
if (index === -1)
return;
const valuePath = attributePath.get("value");
valuePath.replaceWith(values[namePath.node.name]);
requiredAttributes.splice(index, 1);
});
path.pushContainer(
"attributes",
requiredAttributes.map(
(attr) => core.types.jsxAttribute(
core.types.jsxIdentifier(attr),
values[attr]
)
)
);
}
}
});
module.exports = plugin;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\nimport { types as t, NodePath, ConfigAPI } from '@babel/core'\n\nconst elements = ['svg', 'Svg']\n\nexport interface Options {\n width: number | string\n height: number | string\n}\n\nconst getValue = (raw: undefined | number | string) => {\n if (raw === undefined) return t.stringLiteral('1em')\n switch (typeof raw) {\n case 'number':\n return t.jsxExpressionContainer(t.numericLiteral(raw))\n case 'string':\n return t.stringLiteral(raw)\n default:\n return t.stringLiteral('1em')\n }\n}\n\nconst plugin = (_: ConfigAPI, opts: Options) => ({\n visitor: {\n JSXOpeningElement(path: NodePath<t.JSXOpeningElement>) {\n if (\n !elements.some((element) =>\n path.get('name').isJSXIdentifier({ name: element }),\n )\n )\n return\n\n const values = {\n width: getValue(opts.width),\n height: getValue(opts.height),\n }\n const requiredAttributes = Object.keys(values)\n\n path.get('attributes').forEach((attributePath) => {\n if (!attributePath.isJSXAttribute()) return\n const namePath = attributePath.get('name')\n if (!namePath.isJSXIdentifier()) return\n const index = requiredAttributes.indexOf(namePath.node.name)\n\n if (index === -1) return\n\n const valuePath = attributePath.get('value')\n valuePath.replaceWith(values[namePath.node.name as 'width' | 'height'])\n requiredAttributes.splice(index, 1)\n })\n\n path.pushContainer(\n 'attributes',\n requiredAttributes.map((attr) =>\n t.jsxAttribute(\n t.jsxIdentifier(attr),\n values[attr as 'width' | 'height'],\n ),\n ),\n )\n },\n },\n})\n\nexport default plugin\n"],"names":["t"],"mappings":";;;;AAGA,MAAM,QAAA,GAAW,CAAC,KAAA,EAAO,KAAK,CAAA,CAAA;AAO9B,MAAM,QAAA,GAAW,CAAC,GAAqC,KAAA;AACrD,EAAA,IAAI,GAAQ,KAAA,KAAA,CAAA;AAAW,IAAO,OAAAA,UAAA,CAAE,cAAc,KAAK,CAAA,CAAA;AACnD,EAAA,QAAQ,OAAO,GAAK;AAAA,IAClB,KAAK,QAAA;AACH,MAAA,OAAOA,UAAE,CAAA,sBAAA,CAAuBA,UAAE,CAAA,cAAA,CAAe,GAAG,CAAC,CAAA,CAAA;AAAA,IACvD,KAAK,QAAA;AACH,MAAO,OAAAA,UAAA,CAAE,cAAc,GAAG,CAAA,CAAA;AAAA,IAC5B;AACE,MAAO,OAAAA,UAAA,CAAE,cAAc,KAAK,CAAA,CAAA;AAAA,GAChC;AACF,CAAA,CAAA;AAEM,MAAA,MAAA,GAAS,CAAC,CAAA,EAAc,IAAmB,MAAA;AAAA,EAC/C,OAAS,EAAA;AAAA,IACP,kBAAkB,IAAqC,EAAA;AACrD,MAAA,IACE,CAAC,QAAS,CAAA,IAAA;AAAA,QAAK,CAAC,OACd,KAAA,IAAA,CAAK,GAAI,CAAA,MAAM,EAAE,eAAgB,CAAA,EAAE,IAAM,EAAA,OAAA,EAAS,CAAA;AAAA,OACpD;AAEA,QAAA,OAAA;AAEF,MAAA,MAAM,MAAS,GAAA;AAAA,QACb,KAAA,EAAO,QAAS,CAAA,IAAA,CAAK,KAAK,CAAA;AAAA,QAC1B,MAAA,EAAQ,QAAS,CAAA,IAAA,CAAK,MAAM,CAAA;AAAA,OAC9B,CAAA;AACA,MAAM,MAAA,kBAAA,GAAqB,MAAO,CAAA,IAAA,CAAK,MAAM,CAAA,CAAA;AAE7C,MAAA,IAAA,CAAK,GAAI,CAAA,YAAY,CAAE,CAAA,OAAA,CAAQ,CAAC,aAAkB,KAAA;AAChD,QAAI,IAAA,CAAC,cAAc,cAAe,EAAA;AAAG,UAAA,OAAA;AACrC,QAAM,MAAA,QAAA,GAAW,aAAc,CAAA,GAAA,CAAI,MAAM,CAAA,CAAA;AACzC,QAAI,IAAA,CAAC,SAAS,eAAgB,EAAA;AAAG,UAAA,OAAA;AACjC,QAAA,MAAM,KAAQ,GAAA,kBAAA,CAAmB,OAAQ,CAAA,QAAA,CAAS,KAAK,IAAI,CAAA,CAAA;AAE3D,QAAA,IAAI,KAAU,KAAA,CAAA,CAAA;AAAI,UAAA,OAAA;AAElB,QAAM,MAAA,SAAA,GAAY,aAAc,CAAA,GAAA,CAAI,OAAO,CAAA,CAAA;AAC3C,QAAA,SAAA,CAAU,WAAY,CAAA,MAAA,CAAO,QAAS,CAAA,IAAA,CAAK,IAA2B,CAAA,CAAA,CAAA;AACtE,QAAmB,kBAAA,CAAA,MAAA,CAAO,OAAO,CAAC,CAAA,CAAA;AAAA,OACnC,CAAA,CAAA;AAED,MAAK,IAAA,CAAA,aAAA;AAAA,QACH,YAAA;AAAA,QACA,kBAAmB,CAAA,GAAA;AAAA,UAAI,CAAC,SACtBA,UAAE,CAAA,YAAA;AAAA,YACAA,UAAA,CAAE,cAAc,IAAI,CAAA;AAAA,YACpB,MAAO,CAAA,IAAA,CAAA;AAAA,WACT;AAAA,SACF;AAAA,OACF,CAAA;AAAA,KACF;AAAA,GACF;AACF,CAAA;;;;"}

View File

@@ -0,0 +1,40 @@
{
"name": "@svgr/babel-plugin-svg-em-dimensions",
"description": "Transform SVG to use em-based dimensions",
"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/babel-plugin-svg-em-dimensions",
"author": "Greg Bergé <berge.greg@gmail.com>",
"publishConfig": {
"access": "public"
},
"keywords": [
"babel-plugin"
],
"engines": {
"node": ">=10"
},
"homepage": "https://react-svgr.com",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/gregberge"
},
"license": "MIT",
"peerDependencies": {
"@babel/core": "^7.0.0-0"
},
"scripts": {
"reset": "rm -rf dist",
"build": "rollup -c ../../build/rollup.config.js",
"prepublishOnly": "npm run reset && npm run build"
},
"gitHead": "d5efedd372999692f84d30072e502b5a6b8fe734"
}

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.

View File

@@ -0,0 +1,21 @@
# @svgr/babel-plugin-transform-react-native-svg
## Install
```
npm install --save-dev @svgr/babel-plugin-transform-react-native-svg
```
## Usage
**.babelrc**
```json
{
"plugins": ["@svgr/babel-plugin-transform-react-native-svg"]
}
```
## License
MIT

View File

@@ -0,0 +1,13 @@
import { NodePath, types } from '@babel/core';
interface State {
replacedComponents: Set<string>;
unsupportedComponents: Set<string>;
}
declare const plugin: () => {
visitor: {
Program(path: NodePath<types.Program>, state: Partial<State>): void;
};
};
export { plugin as default };

View File

@@ -0,0 +1,107 @@
'use strict';
var core = require('@babel/core');
const elementToComponent = {
svg: "Svg",
circle: "Circle",
clipPath: "ClipPath",
ellipse: "Ellipse",
g: "G",
linearGradient: "LinearGradient",
radialGradient: "RadialGradient",
line: "Line",
path: "Path",
pattern: "Pattern",
polygon: "Polygon",
polyline: "Polyline",
rect: "Rect",
symbol: "Symbol",
text: "Text",
textPath: "TextPath",
tspan: "TSpan",
use: "Use",
defs: "Defs",
stop: "Stop",
mask: "Mask",
image: "Image",
foreignObject: "ForeignObject"
};
const plugin = () => {
function replaceElement(path, state) {
const namePath = path.get("openingElement").get("name");
if (!namePath.isJSXIdentifier())
return;
const { name } = namePath.node;
const component = elementToComponent[name];
if (component) {
namePath.replaceWith(core.types.jsxIdentifier(component));
if (path.has("closingElement")) {
const closingNamePath = path.get("closingElement").get("name");
closingNamePath.replaceWith(core.types.jsxIdentifier(component));
}
state.replacedComponents.add(component);
return;
}
state.unsupportedComponents.add(name);
path.remove();
}
const svgElementVisitor = {
JSXElement(path, state) {
if (!path.get("openingElement").get("name").isJSXIdentifier({ name: "svg" })) {
return;
}
replaceElement(path, state);
path.traverse(jsxElementVisitor, state);
}
};
const jsxElementVisitor = {
JSXElement(path, state) {
replaceElement(path, state);
}
};
const importDeclarationVisitor = {
ImportDeclaration(path, state) {
if (path.get("source").isStringLiteral({ value: "react-native-svg" })) {
state.replacedComponents.forEach((component) => {
if (path.get("specifiers").some(
(specifier) => specifier.get("local").isIdentifier({ name: component })
)) {
return;
}
path.pushContainer(
"specifiers",
core.types.importSpecifier(core.types.identifier(component), core.types.identifier(component))
);
});
} else if (path.get("source").isStringLiteral({ value: "expo" })) {
path.pushContainer(
"specifiers",
core.types.importSpecifier(core.types.identifier("Svg"), core.types.identifier("Svg"))
);
} else {
return;
}
if (state.unsupportedComponents.size && !path.has("trailingComments")) {
const componentList = [...state.unsupportedComponents].join(", ");
path.addComment(
"trailing",
` SVGR has dropped some elements not supported by react-native-svg: ${componentList} `
);
}
}
};
return {
visitor: {
Program(path, state) {
state.replacedComponents = /* @__PURE__ */ new Set();
state.unsupportedComponents = /* @__PURE__ */ new Set();
path.traverse(svgElementVisitor, state);
path.traverse(importDeclarationVisitor, state);
}
}
};
};
module.exports = plugin;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,40 @@
{
"name": "@svgr/babel-plugin-transform-react-native-svg",
"description": "Transform DOM elements into react-native-svg components",
"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/babel-plugin-transform-react-native-svg",
"author": "Greg Bergé <berge.greg@gmail.com>",
"publishConfig": {
"access": "public"
},
"keywords": [
"babel-plugin"
],
"engines": {
"node": ">=10"
},
"homepage": "https://react-svgr.com",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/gregberge"
},
"license": "MIT",
"peerDependencies": {
"@babel/core": "^7.0.0-0"
},
"scripts": {
"reset": "rm -rf dist",
"build": "rollup -c ../../build/rollup.config.js",
"prepublishOnly": "npm run reset && npm run build"
},
"gitHead": "d5efedd372999692f84d30072e502b5a6b8fe734"
}

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.

View File

@@ -0,0 +1,23 @@
# @svgr/babel-plugin-transform-svg-component
## Install
```
npm install --save-dev @svgr/babel-plugin-transform-svg-component
```
## Usage
**.babelrc**
```json
{
"plugins": [
["@svgr/babel-plugin-transform-svg-component", { "titleProp": true }]
]
}
```
## License
MIT

View File

@@ -0,0 +1,53 @@
import { types, ConfigAPI, NodePath } from '@babel/core';
import { TemplateBuilder } from '@babel/template';
interface TemplateVariables {
componentName: string;
interfaces: types.TSInterfaceDeclaration[];
props: (types.ObjectPattern | types.Identifier)[];
imports: types.ImportDeclaration[];
exports: (types.VariableDeclaration | types.ExportDeclaration | types.Statement)[];
jsx: types.JSXElement;
}
interface TemplateContext {
options: Options;
tpl: TemplateBuilder<types.Statement | types.Statement[]>['ast'];
}
interface Template {
(variables: TemplateVariables, context: TemplateContext): types.Statement | types.Statement[];
}
interface State {
componentName: string;
caller?: {
previousExport?: string | null;
};
}
interface JSXRuntimeImport {
source: string;
namespace?: string;
specifiers?: string[];
}
interface Options {
typescript?: boolean;
titleProp?: boolean;
descProp?: boolean;
expandProps?: boolean | 'start' | 'end';
ref?: boolean;
template?: Template;
state: State;
native?: boolean;
memo?: boolean;
exportType?: 'named' | 'default';
namedExport?: string;
jsxRuntime?: 'automatic' | 'classic';
jsxRuntimeImport?: JSXRuntimeImport;
importSource?: string;
}
declare const plugin: (_: ConfigAPI, opts: Options) => {
visitor: {
Program(path: NodePath<types.Program>): void;
};
};
export { Options, Template, plugin as default };

View File

@@ -0,0 +1,295 @@
'use strict';
var core = require('@babel/core');
const defaultTemplate = (variables, { tpl }) => {
return tpl`
${variables.imports};
${variables.interfaces};
const ${variables.componentName} = (${variables.props}) => (
${variables.jsx}
);
${variables.exports};
`;
};
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 tsOptionalPropertySignature = (...args) => {
return __spreadProps(__spreadValues({}, core.types.tsPropertySignature(...args)), {
optional: true
});
};
const getOrCreateImport = ({ imports }, sourceValue) => {
const existing = imports.find(
(imp2) => imp2.source.value === sourceValue && !imp2.specifiers.some(
(specifier) => specifier.type === "ImportNamespaceSpecifier"
)
);
if (existing)
return existing;
const imp = core.types.importDeclaration([], core.types.stringLiteral(sourceValue));
imports.push(imp);
return imp;
};
const tsTypeReferenceSVGProps = (ctx) => {
if (ctx.opts.native) {
const identifier2 = core.types.identifier("SvgProps");
getOrCreateImport(ctx, "react-native-svg").specifiers.push(
core.types.importSpecifier(identifier2, identifier2)
);
return core.types.tsTypeReference(identifier2);
}
const identifier = core.types.identifier("SVGProps");
getOrCreateImport(ctx, ctx.importSource).specifiers.push(
core.types.importSpecifier(identifier, identifier)
);
return core.types.tsTypeReference(
identifier,
core.types.tsTypeParameterInstantiation([
core.types.tsTypeReference(core.types.identifier("SVGSVGElement"))
])
);
};
const tsTypeReferenceSVGRef = (ctx) => {
const identifier = core.types.identifier("Ref");
getOrCreateImport(ctx, ctx.importSource).specifiers.push(
core.types.importSpecifier(identifier, identifier)
);
return core.types.tsTypeReference(
identifier,
core.types.tsTypeParameterInstantiation([
core.types.tsTypeReference(core.types.identifier("SVGSVGElement"))
])
);
};
const getJsxRuntimeImport = (cfg) => {
const specifiers = (() => {
if (cfg.namespace)
return [core.types.importNamespaceSpecifier(core.types.identifier(cfg.namespace))];
if (cfg.specifiers)
return cfg.specifiers.map((specifier) => {
const identifier = core.types.identifier(specifier);
return core.types.importSpecifier(identifier, identifier);
});
throw new Error(
`Specify either "namespace" or "specifiers" in "jsxRuntimeImport" option`
);
})();
return core.types.importDeclaration(specifiers, core.types.stringLiteral(cfg.source));
};
const defaultJsxRuntimeImport = {
source: "react",
namespace: "React"
};
const defaultImportSource = "react";
const getVariables = ({
opts,
jsx
}) => {
var _a, _b, _c, _d;
const interfaces = [];
const props = [];
const imports = [];
const exports = [];
const ctx = {
importSource: (_a = opts.importSource) != null ? _a : defaultImportSource,
exportIdentifier: core.types.identifier(opts.state.componentName),
opts,
interfaces,
props,
imports,
exports
};
if (opts.jsxRuntime !== "automatic") {
imports.push(
getJsxRuntimeImport((_b = opts.jsxRuntimeImport) != null ? _b : defaultJsxRuntimeImport)
);
}
if (opts.native) {
getOrCreateImport(ctx, "react-native-svg").specifiers.push(
core.types.importDefaultSpecifier(core.types.identifier("Svg"))
);
}
if (opts.titleProp || opts.descProp) {
const properties = [];
const propertySignatures = [];
const createProperty = (attr) => {
return core.types.objectProperty(
core.types.identifier(attr),
core.types.identifier(attr),
false,
true
);
};
const createSignature = (attr) => {
return tsOptionalPropertySignature(
core.types.identifier(attr),
core.types.tsTypeAnnotation(core.types.tsStringKeyword())
);
};
if (opts.titleProp) {
properties.push(createProperty("title"), createProperty("titleId"));
if (opts.typescript) {
propertySignatures.push(
createSignature("title"),
createSignature("titleId")
);
}
}
if (opts.descProp) {
properties.push(createProperty("desc"), createProperty("descId"));
if (opts.typescript) {
propertySignatures.push(
createSignature("desc"),
createSignature("descId")
);
}
}
const prop = core.types.objectPattern(properties);
props.push(prop);
if (opts.typescript) {
interfaces.push(
core.types.tsInterfaceDeclaration(
core.types.identifier("SVGRProps"),
null,
null,
core.types.tSInterfaceBody(propertySignatures)
)
);
prop.typeAnnotation = core.types.tsTypeAnnotation(
core.types.tsTypeReference(core.types.identifier("SVGRProps"))
);
}
}
if (opts.expandProps) {
const identifier = core.types.identifier("props");
if (core.types.isObjectPattern(props[0])) {
props[0].properties.push(core.types.restElement(identifier));
if (opts.typescript) {
props[0].typeAnnotation = core.types.tsTypeAnnotation(
core.types.tsIntersectionType([
tsTypeReferenceSVGProps(ctx),
props[0].typeAnnotation.typeAnnotation
])
);
}
} else {
props.push(identifier);
if (opts.typescript) {
identifier.typeAnnotation = core.types.tsTypeAnnotation(
tsTypeReferenceSVGProps(ctx)
);
}
}
}
if (opts.ref) {
if (props.length === 0) {
props.push(core.types.identifier("_"));
}
const prop = core.types.identifier("ref");
props.push(prop);
if (opts.typescript) {
prop.typeAnnotation = core.types.tsTypeAnnotation(tsTypeReferenceSVGRef(ctx));
}
const forwardRef = core.types.identifier("forwardRef");
const ForwardRef = core.types.identifier("ForwardRef");
getOrCreateImport(ctx, ctx.importSource).specifiers.push(
core.types.importSpecifier(forwardRef, forwardRef)
);
exports.push(
core.types.variableDeclaration("const", [
core.types.variableDeclarator(
ForwardRef,
core.types.callExpression(forwardRef, [ctx.exportIdentifier])
)
])
);
ctx.exportIdentifier = ForwardRef;
}
if (opts.memo) {
const memo = core.types.identifier("memo");
const Memo = core.types.identifier("Memo");
getOrCreateImport(ctx, ctx.importSource).specifiers.push(
core.types.importSpecifier(memo, memo)
);
exports.push(
core.types.variableDeclaration("const", [
core.types.variableDeclarator(
Memo,
core.types.callExpression(memo, [ctx.exportIdentifier])
)
])
);
ctx.exportIdentifier = Memo;
}
if (((_c = opts.state.caller) == null ? void 0 : _c.previousExport) || opts.exportType === "named") {
if (!opts.namedExport) {
throw new Error(`"namedExport" not specified`);
}
exports.push(
core.types.exportNamedDeclaration(null, [
core.types.exportSpecifier(ctx.exportIdentifier, core.types.identifier(opts.namedExport))
])
);
if ((_d = opts.state.caller) == null ? void 0 : _d.previousExport) {
const previousExportAst = core.template.ast(opts.state.caller.previousExport);
exports.push(
...Array.isArray(previousExportAst) ? previousExportAst : [previousExportAst]
);
}
} else {
exports.push(core.types.exportDefaultDeclaration(ctx.exportIdentifier));
}
return {
componentName: opts.state.componentName,
props,
interfaces,
imports,
exports,
jsx
};
};
const plugin = (_, opts) => {
const template = opts.template || defaultTemplate;
const plugins = opts.typescript ? ["jsx", "typescript"] : ["jsx"];
const tpl = core.template.smart({ plugins, preserveComments: true }).ast;
return {
visitor: {
Program(path) {
const jsx = path.node.body[0].expression;
const variables = getVariables({
opts,
jsx
});
const body = template(variables, { options: opts, tpl });
path.node.body = Array.isArray(body) ? body : [body];
path.replaceWith(path.node);
}
}
};
};
module.exports = plugin;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,40 @@
{
"name": "@svgr/babel-plugin-transform-svg-component",
"description": "Transform SVG into component",
"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/babel-plugin-transform-svg-component",
"author": "Greg Bergé <berge.greg@gmail.com>",
"publishConfig": {
"access": "public"
},
"keywords": [
"babel-plugin"
],
"engines": {
"node": ">=12"
},
"homepage": "https://react-svgr.com",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/gregberge"
},
"license": "MIT",
"peerDependencies": {
"@babel/core": "^7.0.0-0"
},
"scripts": {
"reset": "rm -rf dist",
"build": "rollup -c ../../build/rollup.config.js",
"prepublishOnly": "npm run reset && npm run build"
},
"gitHead": "d5efedd372999692f84d30072e502b5a6b8fe734"
}

7
node_modules/@svgr/babel-preset/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.

21
node_modules/@svgr/babel-preset/README.md generated vendored Normal file
View File

@@ -0,0 +1,21 @@
# @svgr/babel-preset
## Install
```
npm install --save-dev @svgr/babel-preset
```
## Usage
**.babelrc**
```json
{
"presets": [["@svgr/babel-preset", { "svgProps": { "width": 200 } }]]
}
```
## License
MIT

23
node_modules/@svgr/babel-preset/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,23 @@
import { ConfigAPI } from '@babel/core';
import { Options as Options$1 } from '@svgr/babel-plugin-transform-svg-component';
interface Options extends Options$1 {
ref?: boolean;
titleProp?: boolean;
descProp?: boolean;
expandProps?: boolean | 'start' | 'end';
dimensions?: boolean;
icon?: boolean | string | number;
native?: boolean;
svgProps?: {
[key: string]: string;
};
replaceAttrValues?: {
[key: string]: string;
};
}
declare const plugin: (_: ConfigAPI, opts: Options) => {
plugins: any[];
};
export { Options, plugin as default };

125
node_modules/@svgr/babel-preset/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,125 @@
'use strict';
var addJSXAttribute = require('@svgr/babel-plugin-add-jsx-attribute');
var removeJSXAttribute = require('@svgr/babel-plugin-remove-jsx-attribute');
var removeJSXEmptyExpression = require('@svgr/babel-plugin-remove-jsx-empty-expression');
var replaceJSXAttributeValue = require('@svgr/babel-plugin-replace-jsx-attribute-value');
var svgDynamicTitle = require('@svgr/babel-plugin-svg-dynamic-title');
var svgEmDimensions = require('@svgr/babel-plugin-svg-em-dimensions');
var transformReactNativeSVG = require('@svgr/babel-plugin-transform-react-native-svg');
var transformSvgComponent = require('@svgr/babel-plugin-transform-svg-component');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var addJSXAttribute__default = /*#__PURE__*/_interopDefaultLegacy(addJSXAttribute);
var removeJSXAttribute__default = /*#__PURE__*/_interopDefaultLegacy(removeJSXAttribute);
var removeJSXEmptyExpression__default = /*#__PURE__*/_interopDefaultLegacy(removeJSXEmptyExpression);
var replaceJSXAttributeValue__default = /*#__PURE__*/_interopDefaultLegacy(replaceJSXAttributeValue);
var svgDynamicTitle__default = /*#__PURE__*/_interopDefaultLegacy(svgDynamicTitle);
var svgEmDimensions__default = /*#__PURE__*/_interopDefaultLegacy(svgEmDimensions);
var transformReactNativeSVG__default = /*#__PURE__*/_interopDefaultLegacy(transformReactNativeSVG);
var transformSvgComponent__default = /*#__PURE__*/_interopDefaultLegacy(transformSvgComponent);
const getAttributeValue = (value) => {
const literal = typeof value === "string" && value.startsWith("{") && value.endsWith("}");
return { value: literal ? value.slice(1, -1) : value, literal };
};
const propsToAttributes = (props) => {
return Object.keys(props).map((name) => {
const { literal, value } = getAttributeValue(props[name]);
return { name, literal, value };
});
};
function replaceMapToValues(replaceMap) {
return Object.keys(replaceMap).map((value) => {
const { literal, value: newValue } = getAttributeValue(replaceMap[value]);
return { value, newValue, literal };
});
}
const plugin = (_, opts) => {
let toRemoveAttributes = ["version"];
let toAddAttributes = [];
if (opts.svgProps) {
toAddAttributes = [...toAddAttributes, ...propsToAttributes(opts.svgProps)];
}
if (opts.ref) {
toAddAttributes = [
...toAddAttributes,
{
name: "ref",
value: "ref",
literal: true
}
];
}
if (opts.titleProp) {
toAddAttributes = [
...toAddAttributes,
{
name: "aria-labelledby",
value: "titleId",
literal: true
}
];
}
if (opts.descProp) {
toAddAttributes = [
...toAddAttributes,
{
name: "aria-describedby",
value: "descId",
literal: true
}
];
}
if (opts.expandProps) {
toAddAttributes = [
...toAddAttributes,
{
name: "props",
spread: true,
position: opts.expandProps === "start" || opts.expandProps === "end" ? opts.expandProps : void 0
}
];
}
if (!opts.dimensions) {
toRemoveAttributes = [...toRemoveAttributes, "width", "height"];
}
const plugins = [
[transformSvgComponent__default["default"], opts],
...opts.icon !== false && opts.dimensions ? [
[
svgEmDimensions__default["default"],
opts.icon !== true ? { width: opts.icon, height: opts.icon } : opts.native ? { width: 24, height: 24 } : {}
]
] : [],
[
removeJSXAttribute__default["default"],
{ elements: ["svg", "Svg"], attributes: toRemoveAttributes }
],
[
addJSXAttribute__default["default"],
{ elements: ["svg", "Svg"], attributes: toAddAttributes }
],
removeJSXEmptyExpression__default["default"]
];
if (opts.replaceAttrValues) {
plugins.push([
replaceJSXAttributeValue__default["default"],
{ values: replaceMapToValues(opts.replaceAttrValues) }
]);
}
if (opts.titleProp) {
plugins.push(svgDynamicTitle__default["default"]);
}
if (opts.descProp) {
plugins.push([svgDynamicTitle__default["default"], { tag: "desc" }, "desc"]);
}
if (opts.native) {
plugins.push(transformReactNativeSVG__default["default"]);
}
return { plugins };
};
module.exports = plugin;
//# sourceMappingURL=index.js.map

1
node_modules/@svgr/babel-preset/dist/index.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

51
node_modules/@svgr/babel-preset/package.json generated vendored Normal file
View File

@@ -0,0 +1,51 @@
{
"name": "@svgr/babel-preset",
"description": "SVGR preset that apply transformations from config",
"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/babel-preset",
"author": "Greg Bergé <berge.greg@gmail.com>",
"publishConfig": {
"access": "public"
},
"keywords": [
"babel-plugin",
"babel-preset"
],
"engines": {
"node": ">=10"
},
"homepage": "https://react-svgr.com",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/gregberge"
},
"license": "MIT",
"dependencies": {
"@svgr/babel-plugin-add-jsx-attribute": "^6.5.1",
"@svgr/babel-plugin-remove-jsx-attribute": "*",
"@svgr/babel-plugin-remove-jsx-empty-expression": "*",
"@svgr/babel-plugin-replace-jsx-attribute-value": "^6.5.1",
"@svgr/babel-plugin-svg-dynamic-title": "^6.5.1",
"@svgr/babel-plugin-svg-em-dimensions": "^6.5.1",
"@svgr/babel-plugin-transform-react-native-svg": "^6.5.1",
"@svgr/babel-plugin-transform-svg-component": "^6.5.1"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0"
},
"scripts": {
"reset": "rm -rf dist",
"build": "rollup -c ../../build/rollup.config.js",
"prepublishOnly": "npm run reset && npm run build"
},
"gitHead": "d5efedd372999692f84d30072e502b5a6b8fe734"
}

7
node_modules/@svgr/core/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.

60
node_modules/@svgr/core/README.md generated vendored Normal file
View File

@@ -0,0 +1,60 @@
# @svgr/core
[![Build Status][build-badge]][build]
[![version][version-badge]][package]
[![MIT License][license-badge]][license]
Node API of SVGR.
```
npm install @svgr/core
```
## Usage
```js
import { transform } from '@svgr/core'
const svgCode = `
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<rect x="10" y="10" height="100" width="100"
style="stroke:#ff0000; fill: #0000ff"/>
</svg>
`
transform(svgCode, { icon: true }, { componentName: 'MyComponent' }).then(
(jsCode) => {
console.log(jsCode)
},
)
```
Use `svgr.sync(code, config, state)` if you would like to use sync version.
### Plugins
By default `@svgr/core` doesn't include `svgo` and `prettier` plugins, if you want them, you have to install them and include them in config.
```js
svgr(svgCode, {
plugins: ['@svgr/plugin-svgo', '@svgr/plugin-jsx', '@svgr/plugin-prettier'],
}).then((jsCode) => {
console.log(jsCode)
})
```
## License
MIT
[build-badge]: https://img.shields.io/travis/smooth-code/svgr.svg?style=flat-square
[build]: https://travis-ci.org/smooth-code/svgr
[version-badge]: https://img.shields.io/npm/v/@svgr/core.svg?style=flat-square
[package]: https://www.npmjs.com/package/@svgr/core
[license-badge]: https://img.shields.io/npm/l/@svgr/core.svg?style=flat-square
[license]: https://github.com/smooth-code/svgr/blob/master/LICENSE
```
```

72
node_modules/@svgr/core/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,72 @@
import { Options } from 'prettier';
import { OptimizeOptions } from 'svgo';
import { Options as Options$1 } from '@svgr/babel-preset';
import { TransformOptions } from '@babel/core';
interface State {
filePath?: string;
componentName: string;
caller?: {
name?: string;
previousExport?: string | null;
defaultPlugins?: ConfigPlugin[];
};
}
interface Plugin {
(code: string, config: Config, state: State): string;
}
declare type ConfigPlugin = string | Plugin;
interface Config {
ref?: boolean;
titleProp?: boolean;
descProp?: boolean;
expandProps?: boolean | 'start' | 'end';
dimensions?: boolean;
icon?: boolean | string | number;
native?: boolean;
svgProps?: {
[key: string]: string;
};
replaceAttrValues?: {
[key: string]: string;
};
runtimeConfig?: boolean;
typescript?: boolean;
prettier?: boolean;
prettierConfig?: Options;
svgo?: boolean;
svgoConfig?: OptimizeOptions;
configFile?: string;
template?: Options$1['template'];
memo?: boolean;
exportType?: 'named' | 'default';
namedExport?: string;
jsxRuntime?: 'classic' | 'classic-preact' | 'automatic';
index?: boolean;
plugins?: ConfigPlugin[];
jsx?: {
babelConfig?: TransformOptions;
};
}
declare const DEFAULT_CONFIG: Config;
declare const resolveConfig: {
(searchFrom?: string, configFile?: string): Promise<Config | null>;
sync(searchFrom?: string, configFile?: string): Config | null;
};
declare const resolveConfigFile: {
(filePath: string): Promise<string | null>;
sync(filePath: string): string | null;
};
declare const loadConfig: {
({ configFile, ...baseConfig }: Config, state?: Pick<State, 'filePath'>): Promise<Config>;
sync({ configFile, ...baseConfig }: Config, state?: Pick<State, 'filePath'>): Config;
};
declare const transform: {
(code: string, config?: Config, state?: Partial<State>): Promise<string>;
sync(code: string, config?: Config, state?: Partial<State>): string;
};
export { Config, ConfigPlugin, DEFAULT_CONFIG, Plugin, State, loadConfig, resolveConfig, resolveConfigFile, transform };

200
node_modules/@svgr/core/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,200 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var path = require('path');
var camelCase = require('camelcase');
var cosmiconfig = require('cosmiconfig');
var jsx = require('@svgr/plugin-jsx');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var camelCase__default = /*#__PURE__*/_interopDefaultLegacy(camelCase);
var jsx__default = /*#__PURE__*/_interopDefaultLegacy(jsx);
var __defProp$1 = Object.defineProperty;
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues$1 = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp$1.call(b, prop))
__defNormalProp$1(a, prop, b[prop]);
if (__getOwnPropSymbols$1)
for (var prop of __getOwnPropSymbols$1(b)) {
if (__propIsEnum$1.call(b, prop))
__defNormalProp$1(a, prop, b[prop]);
}
return a;
};
const VALID_CHAR_REGEX = /[^a-zA-Z0-9 _-]/g;
const getComponentName = (filePath) => {
if (!filePath)
return "SvgComponent";
const pascalCaseFileName = camelCase__default["default"](
path.parse(filePath).name.replace(VALID_CHAR_REGEX, ""),
{
pascalCase: true
}
);
return `Svg${pascalCaseFileName}`;
};
const expandState = (state) => {
return __spreadValues$1({
componentName: state.componentName || getComponentName(state.filePath)
}, state);
};
var __defProp = Object.defineProperty;
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 __objRest = (source, exclude) => {
var target = {};
for (var prop in source)
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
target[prop] = source[prop];
if (source != null && __getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(source)) {
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
target[prop] = source[prop];
}
return target;
};
const DEFAULT_CONFIG = {
dimensions: true,
expandProps: "end",
icon: false,
native: false,
typescript: false,
prettier: true,
prettierConfig: void 0,
memo: false,
ref: false,
replaceAttrValues: void 0,
svgProps: void 0,
svgo: true,
svgoConfig: void 0,
template: void 0,
index: false,
titleProp: false,
descProp: false,
runtimeConfig: true,
namedExport: "ReactComponent",
exportType: "default"
};
const explorer = cosmiconfig.cosmiconfig("svgr");
const explorerSync = cosmiconfig.cosmiconfigSync("svgr");
const resolveConfig = async (searchFrom, configFile) => {
if (configFile == null) {
const result2 = await explorer.search(searchFrom);
return result2 ? result2.config : null;
}
const result = await explorer.load(configFile);
return result ? result.config : null;
};
resolveConfig.sync = (searchFrom, configFile) => {
if (configFile == null) {
const result2 = explorerSync.search(searchFrom);
return result2 ? result2.config : null;
}
const result = explorerSync.load(configFile);
return result ? result.config : null;
};
const resolveConfigFile = async (filePath) => {
const result = await explorer.search(filePath);
return result ? result.filepath : null;
};
resolveConfigFile.sync = (filePath) => {
const result = explorerSync.search(filePath);
return result ? result.filepath : null;
};
const loadConfig = async (_a, state = {}) => {
var _b = _a, { configFile } = _b, baseConfig = __objRest(_b, ["configFile"]);
const rcConfig = state.filePath && baseConfig.runtimeConfig !== false ? await resolveConfig(state.filePath, configFile) : {};
return __spreadValues(__spreadValues(__spreadValues({}, DEFAULT_CONFIG), rcConfig), baseConfig);
};
loadConfig.sync = (_c, state = {}) => {
var _d = _c, { configFile } = _d, baseConfig = __objRest(_d, ["configFile"]);
const rcConfig = state.filePath && baseConfig.runtimeConfig !== false ? resolveConfig.sync(state.filePath, configFile) : {};
return __spreadValues(__spreadValues(__spreadValues({}, DEFAULT_CONFIG), rcConfig), baseConfig);
};
const DEFAULT_PLUGINS = [jsx__default["default"]];
const getPlugins = (config, state) => {
var _a;
if (config.plugins) {
return config.plugins;
}
if ((_a = state.caller) == null ? void 0 : _a.defaultPlugins) {
return state.caller.defaultPlugins;
}
return DEFAULT_PLUGINS;
};
const resolvePlugin = (plugin) => {
if (typeof plugin === "function") {
return plugin;
}
if (typeof plugin === "string") {
return loadPlugin(plugin);
}
throw new Error(`Invalid plugin "${plugin}"`);
};
const pluginCache = {};
const resolveModule = (m) => m ? m.default || m : null;
const loadPlugin = (moduleName) => {
if (pluginCache[moduleName]) {
return pluginCache[moduleName];
}
try {
const plugin = resolveModule(require(moduleName));
if (!plugin) {
throw new Error(`Invalid plugin "${moduleName}"`);
}
pluginCache[moduleName] = plugin;
return pluginCache[moduleName];
} catch (error) {
console.log(error);
throw new Error(
`Module "${moduleName}" missing. Maybe \`npm install ${moduleName}\` could help!`
);
}
};
const run = (code, config, state) => {
const expandedState = expandState(state);
const plugins = getPlugins(config, state).map(resolvePlugin);
let nextCode = String(code).replace("\0", "");
for (const plugin of plugins) {
nextCode = plugin(nextCode, config, expandedState);
}
return nextCode;
};
const transform = async (code, config = {}, state = {}) => {
config = await loadConfig(config, state);
return run(code, config, state);
};
transform.sync = (code, config = {}, state = {}) => {
config = loadConfig.sync(config, state);
return run(code, config, state);
};
exports.DEFAULT_CONFIG = DEFAULT_CONFIG;
exports.loadConfig = loadConfig;
exports.resolveConfig = resolveConfig;
exports.resolveConfigFile = resolveConfigFile;
exports.transform = transform;
//# sourceMappingURL=index.js.map

1
node_modules/@svgr/core/dist/index.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

51
node_modules/@svgr/core/package.json generated vendored Normal file
View File

@@ -0,0 +1,51 @@
{
"name": "@svgr/core",
"description": "Transform SVG into React Components.",
"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/core",
"author": "Greg Bergé <berge.greg@gmail.com>",
"publishConfig": {
"access": "public"
},
"keywords": [
"svgr",
"svg",
"react",
"core",
"api"
],
"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"
},
"dependencies": {
"@babel/core": "^7.19.6",
"@svgr/babel-preset": "^6.5.1",
"@svgr/plugin-jsx": "^6.5.1",
"camelcase": "^6.2.0",
"cosmiconfig": "^7.0.1"
},
"devDependencies": {
"@types/svgo": "^2.6.4"
},
"gitHead": "d5efedd372999692f84d30072e502b5a6b8fe734"
}

7
node_modules/@svgr/hast-util-to-babel-ast/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.

28
node_modules/@svgr/hast-util-to-babel-ast/README.md generated vendored Normal file
View File

@@ -0,0 +1,28 @@
# @svgr/hast-util-to-babel-ast
[![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/hast-util-to-babel-ast.svg)](https://www.npmjs.com/package/@svgr/hast-util-to-babel-ast)
[![MIT License](https://img.shields.io/npm/l/@svgr/hast-util-to-babel-ast.svg)](https://github.com/smooth-code/svgr/blob/master/LICENSE)
Transforms HAST into Babel AST.
## Install
```
npm install --save-dev @svgr/hast-util-to-babel-ast
```
## Usage
```js
import { parse } from 'svg-parser'
import hastToBabelAst from '@svgr/hast-util-to-babel-ast'
const hastTree = parse(`<svg></svg>`)
const babelTree = hastToBabelAst(hastTree)
```
## License
MIT

View File

@@ -0,0 +1,6 @@
import { RootNode } from 'svg-parser';
import * as t from '@babel/types';
declare const toBabelAST: (tree: RootNode) => t.Program;
export { toBabelAST as default };

797
node_modules/@svgr/hast-util-to-babel-ast/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,797 @@
'use strict';
var t = require('@babel/types');
var entities = require('entities');
function _interopNamespace(e) {
if (e && e.__esModule) return e;
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n["default"] = e;
return Object.freeze(n);
}
var t__namespace = /*#__PURE__*/_interopNamespace(t);
const one = (h, node, parent) => {
const type = node && node.type;
const fn = h.handlers[type];
if (!type) {
throw new Error(`Expected node, got \`${node}\``);
}
if (!fn) {
throw new Error(`Node of type ${type} is unknown`);
}
return fn(h, node, parent);
};
const all = (helpers, parent) => {
const nodes = parent.children || [];
const { length } = nodes;
const values = [];
let index = -1;
while (++index < length) {
const node = nodes[index];
if (typeof node !== "string") {
const result = one(helpers, node, parent);
values.push(result);
}
}
return values.filter(Boolean);
};
const isNumeric = (value) => {
return !Number.isNaN(value - parseFloat(value));
};
const hyphenToCamelCase = (string) => {
return string.replace(/-(.)/g, (_, chr) => chr.toUpperCase());
};
const trimEnd = (haystack, needle) => {
return haystack.endsWith(needle) ? haystack.slice(0, -needle.length) : haystack;
};
const KEBAB_REGEX = /[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g;
const kebabCase = (str) => {
return str.replace(KEBAB_REGEX, (match) => `-${match.toLowerCase()}`);
};
const SPACES_REGEXP = /[\t\r\n\u0085\u2028\u2029]+/g;
const replaceSpaces = (str) => {
return str.replace(SPACES_REGEXP, " ");
};
const PX_REGEX = /^\d+px$/;
const MS_REGEX = /^-ms-/;
const VAR_REGEX = /^--/;
const isConvertiblePixelValue = (value) => {
return PX_REGEX.test(value);
};
const formatKey = (key) => {
if (VAR_REGEX.test(key)) {
return t__namespace.stringLiteral(key);
}
key = key.toLowerCase();
if (MS_REGEX.test(key))
key = key.substr(1);
return t__namespace.identifier(hyphenToCamelCase(key));
};
const formatValue = (value) => {
if (isNumeric(value))
return t__namespace.numericLiteral(Number(value));
if (isConvertiblePixelValue(value))
return t__namespace.numericLiteral(Number(trimEnd(value, "px")));
return t__namespace.stringLiteral(value);
};
const stringToObjectStyle = (rawStyle) => {
const entries = rawStyle.split(";");
const properties = [];
let index = -1;
while (++index < entries.length) {
const entry = entries[index];
const style = entry.trim();
const firstColon = style.indexOf(":");
const value = style.substr(firstColon + 1).trim();
const key = style.substr(0, firstColon);
if (key !== "") {
const property = t__namespace.objectProperty(formatKey(key), formatValue(value));
properties.push(property);
}
}
return t__namespace.objectExpression(properties);
};
const ATTRIBUTE_MAPPING = {
accept: "accept",
acceptcharset: "acceptCharset",
"accept-charset": "acceptCharset",
accesskey: "accessKey",
action: "action",
allowfullscreen: "allowFullScreen",
alt: "alt",
as: "as",
async: "async",
autocapitalize: "autoCapitalize",
autocomplete: "autoComplete",
autocorrect: "autoCorrect",
autofocus: "autoFocus",
autoplay: "autoPlay",
autosave: "autoSave",
capture: "capture",
cellpadding: "cellPadding",
cellspacing: "cellSpacing",
challenge: "challenge",
charset: "charSet",
checked: "checked",
children: "children",
cite: "cite",
class: "className",
classid: "classID",
classname: "className",
cols: "cols",
colspan: "colSpan",
content: "content",
contenteditable: "contentEditable",
contextmenu: "contextMenu",
controls: "controls",
controlslist: "controlsList",
coords: "coords",
crossorigin: "crossOrigin",
dangerouslysetinnerhtml: "dangerouslySetInnerHTML",
data: "data",
datetime: "dateTime",
default: "default",
defaultchecked: "defaultChecked",
defaultvalue: "defaultValue",
defer: "defer",
dir: "dir",
disabled: "disabled",
download: "download",
draggable: "draggable",
enctype: "encType",
for: "htmlFor",
form: "form",
formmethod: "formMethod",
formaction: "formAction",
formenctype: "formEncType",
formnovalidate: "formNoValidate",
formtarget: "formTarget",
frameborder: "frameBorder",
headers: "headers",
height: "height",
hidden: "hidden",
high: "high",
href: "href",
hreflang: "hrefLang",
htmlfor: "htmlFor",
httpequiv: "httpEquiv",
"http-equiv": "httpEquiv",
icon: "icon",
id: "id",
innerhtml: "innerHTML",
inputmode: "inputMode",
integrity: "integrity",
is: "is",
itemid: "itemID",
itemprop: "itemProp",
itemref: "itemRef",
itemscope: "itemScope",
itemtype: "itemType",
keyparams: "keyParams",
keytype: "keyType",
kind: "kind",
label: "label",
lang: "lang",
list: "list",
loop: "loop",
low: "low",
manifest: "manifest",
marginwidth: "marginWidth",
marginheight: "marginHeight",
max: "max",
maxlength: "maxLength",
media: "media",
mediagroup: "mediaGroup",
method: "method",
min: "min",
minlength: "minLength",
multiple: "multiple",
muted: "muted",
name: "name",
nomodule: "noModule",
nonce: "nonce",
novalidate: "noValidate",
open: "open",
optimum: "optimum",
pattern: "pattern",
placeholder: "placeholder",
playsinline: "playsInline",
poster: "poster",
preload: "preload",
profile: "profile",
radiogroup: "radioGroup",
readonly: "readOnly",
referrerpolicy: "referrerPolicy",
rel: "rel",
required: "required",
reversed: "reversed",
role: "role",
rows: "rows",
rowspan: "rowSpan",
sandbox: "sandbox",
scope: "scope",
scoped: "scoped",
scrolling: "scrolling",
seamless: "seamless",
selected: "selected",
shape: "shape",
size: "size",
sizes: "sizes",
span: "span",
spellcheck: "spellCheck",
src: "src",
srcdoc: "srcDoc",
srclang: "srcLang",
srcset: "srcSet",
start: "start",
step: "step",
style: "style",
summary: "summary",
tabindex: "tabIndex",
target: "target",
title: "title",
type: "type",
usemap: "useMap",
value: "value",
width: "width",
wmode: "wmode",
wrap: "wrap",
about: "about",
accentheight: "accentHeight",
"accent-height": "accentHeight",
accumulate: "accumulate",
additive: "additive",
alignmentbaseline: "alignmentBaseline",
"alignment-baseline": "alignmentBaseline",
allowreorder: "allowReorder",
alphabetic: "alphabetic",
amplitude: "amplitude",
arabicform: "arabicForm",
"arabic-form": "arabicForm",
ascent: "ascent",
attributename: "attributeName",
attributetype: "attributeType",
autoreverse: "autoReverse",
azimuth: "azimuth",
basefrequency: "baseFrequency",
baselineshift: "baselineShift",
"baseline-shift": "baselineShift",
baseprofile: "baseProfile",
bbox: "bbox",
begin: "begin",
bias: "bias",
by: "by",
calcmode: "calcMode",
capheight: "capHeight",
"cap-height": "capHeight",
clip: "clip",
clippath: "clipPath",
"clip-path": "clipPath",
clippathunits: "clipPathUnits",
cliprule: "clipRule",
"clip-rule": "clipRule",
color: "color",
colorinterpolation: "colorInterpolation",
"color-interpolation": "colorInterpolation",
colorinterpolationfilters: "colorInterpolationFilters",
"color-interpolation-filters": "colorInterpolationFilters",
colorprofile: "colorProfile",
"color-profile": "colorProfile",
colorrendering: "colorRendering",
"color-rendering": "colorRendering",
contentscripttype: "contentScriptType",
contentstyletype: "contentStyleType",
cursor: "cursor",
cx: "cx",
cy: "cy",
d: "d",
datatype: "datatype",
decelerate: "decelerate",
descent: "descent",
diffuseconstant: "diffuseConstant",
direction: "direction",
display: "display",
divisor: "divisor",
dominantbaseline: "dominantBaseline",
"dominant-baseline": "dominantBaseline",
dur: "dur",
dx: "dx",
dy: "dy",
edgemode: "edgeMode",
elevation: "elevation",
enablebackground: "enableBackground",
"enable-background": "enableBackground",
end: "end",
exponent: "exponent",
externalresourcesrequired: "externalResourcesRequired",
fill: "fill",
fillopacity: "fillOpacity",
"fill-opacity": "fillOpacity",
fillrule: "fillRule",
"fill-rule": "fillRule",
filter: "filter",
filterres: "filterRes",
filterunits: "filterUnits",
floodopacity: "floodOpacity",
"flood-opacity": "floodOpacity",
floodcolor: "floodColor",
"flood-color": "floodColor",
focusable: "focusable",
fontfamily: "fontFamily",
"font-family": "fontFamily",
fontsize: "fontSize",
"font-size": "fontSize",
fontsizeadjust: "fontSizeAdjust",
"font-size-adjust": "fontSizeAdjust",
fontstretch: "fontStretch",
"font-stretch": "fontStretch",
fontstyle: "fontStyle",
"font-style": "fontStyle",
fontvariant: "fontVariant",
"font-variant": "fontVariant",
fontweight: "fontWeight",
"font-weight": "fontWeight",
format: "format",
from: "from",
fx: "fx",
fy: "fy",
g1: "g1",
g2: "g2",
glyphname: "glyphName",
"glyph-name": "glyphName",
glyphorientationhorizontal: "glyphOrientationHorizontal",
"glyph-orientation-horizontal": "glyphOrientationHorizontal",
glyphorientationvertical: "glyphOrientationVertical",
"glyph-orientation-vertical": "glyphOrientationVertical",
glyphref: "glyphRef",
gradienttransform: "gradientTransform",
gradientunits: "gradientUnits",
hanging: "hanging",
horizadvx: "horizAdvX",
"horiz-adv-x": "horizAdvX",
horizoriginx: "horizOriginX",
"horiz-origin-x": "horizOriginX",
ideographic: "ideographic",
imagerendering: "imageRendering",
"image-rendering": "imageRendering",
in2: "in2",
in: "in",
inlist: "inlist",
intercept: "intercept",
k1: "k1",
k2: "k2",
k3: "k3",
k4: "k4",
k: "k",
kernelmatrix: "kernelMatrix",
kernelunitlength: "kernelUnitLength",
kerning: "kerning",
keypoints: "keyPoints",
keysplines: "keySplines",
keytimes: "keyTimes",
lengthadjust: "lengthAdjust",
letterspacing: "letterSpacing",
"letter-spacing": "letterSpacing",
lightingcolor: "lightingColor",
"lighting-color": "lightingColor",
limitingconeangle: "limitingConeAngle",
local: "local",
markerend: "markerEnd",
"marker-end": "markerEnd",
markerheight: "markerHeight",
markermid: "markerMid",
"marker-mid": "markerMid",
markerstart: "markerStart",
"marker-start": "markerStart",
markerunits: "markerUnits",
markerwidth: "markerWidth",
mask: "mask",
maskcontentunits: "maskContentUnits",
maskunits: "maskUnits",
mathematical: "mathematical",
mode: "mode",
numoctaves: "numOctaves",
offset: "offset",
opacity: "opacity",
operator: "operator",
order: "order",
orient: "orient",
orientation: "orientation",
origin: "origin",
overflow: "overflow",
overlineposition: "overlinePosition",
"overline-position": "overlinePosition",
overlinethickness: "overlineThickness",
"overline-thickness": "overlineThickness",
paintorder: "paintOrder",
"paint-order": "paintOrder",
panose1: "panose1",
"panose-1": "panose1",
pathlength: "pathLength",
patterncontentunits: "patternContentUnits",
patterntransform: "patternTransform",
patternunits: "patternUnits",
pointerevents: "pointerEvents",
"pointer-events": "pointerEvents",
points: "points",
pointsatx: "pointsAtX",
pointsaty: "pointsAtY",
pointsatz: "pointsAtZ",
prefix: "prefix",
preservealpha: "preserveAlpha",
preserveaspectratio: "preserveAspectRatio",
primitiveunits: "primitiveUnits",
property: "property",
r: "r",
radius: "radius",
refx: "refX",
refy: "refY",
renderingintent: "renderingIntent",
"rendering-intent": "renderingIntent",
repeatcount: "repeatCount",
repeatdur: "repeatDur",
requiredextensions: "requiredExtensions",
requiredfeatures: "requiredFeatures",
resource: "resource",
restart: "restart",
result: "result",
results: "results",
rotate: "rotate",
rx: "rx",
ry: "ry",
scale: "scale",
security: "security",
seed: "seed",
shaperendering: "shapeRendering",
"shape-rendering": "shapeRendering",
slope: "slope",
spacing: "spacing",
specularconstant: "specularConstant",
specularexponent: "specularExponent",
speed: "speed",
spreadmethod: "spreadMethod",
startoffset: "startOffset",
stddeviation: "stdDeviation",
stemh: "stemh",
stemv: "stemv",
stitchtiles: "stitchTiles",
stopcolor: "stopColor",
"stop-color": "stopColor",
stopopacity: "stopOpacity",
"stop-opacity": "stopOpacity",
strikethroughposition: "strikethroughPosition",
"strikethrough-position": "strikethroughPosition",
strikethroughthickness: "strikethroughThickness",
"strikethrough-thickness": "strikethroughThickness",
string: "string",
stroke: "stroke",
strokedasharray: "strokeDasharray",
"stroke-dasharray": "strokeDasharray",
strokedashoffset: "strokeDashoffset",
"stroke-dashoffset": "strokeDashoffset",
strokelinecap: "strokeLinecap",
"stroke-linecap": "strokeLinecap",
strokelinejoin: "strokeLinejoin",
"stroke-linejoin": "strokeLinejoin",
strokemiterlimit: "strokeMiterlimit",
"stroke-miterlimit": "strokeMiterlimit",
strokewidth: "strokeWidth",
"stroke-width": "strokeWidth",
strokeopacity: "strokeOpacity",
"stroke-opacity": "strokeOpacity",
suppresscontenteditablewarning: "suppressContentEditableWarning",
suppresshydrationwarning: "suppressHydrationWarning",
surfacescale: "surfaceScale",
systemlanguage: "systemLanguage",
tablevalues: "tableValues",
targetx: "targetX",
targety: "targetY",
textanchor: "textAnchor",
"text-anchor": "textAnchor",
textdecoration: "textDecoration",
"text-decoration": "textDecoration",
textlength: "textLength",
textrendering: "textRendering",
"text-rendering": "textRendering",
to: "to",
transform: "transform",
typeof: "typeof",
u1: "u1",
u2: "u2",
underlineposition: "underlinePosition",
"underline-position": "underlinePosition",
underlinethickness: "underlineThickness",
"underline-thickness": "underlineThickness",
unicode: "unicode",
unicodebidi: "unicodeBidi",
"unicode-bidi": "unicodeBidi",
unicoderange: "unicodeRange",
"unicode-range": "unicodeRange",
unitsperem: "unitsPerEm",
"units-per-em": "unitsPerEm",
unselectable: "unselectable",
valphabetic: "vAlphabetic",
"v-alphabetic": "vAlphabetic",
values: "values",
vectoreffect: "vectorEffect",
"vector-effect": "vectorEffect",
version: "version",
vertadvy: "vertAdvY",
"vert-adv-y": "vertAdvY",
vertoriginx: "vertOriginX",
"vert-origin-x": "vertOriginX",
vertoriginy: "vertOriginY",
"vert-origin-y": "vertOriginY",
vhanging: "vHanging",
"v-hanging": "vHanging",
videographic: "vIdeographic",
"v-ideographic": "vIdeographic",
viewbox: "viewBox",
viewtarget: "viewTarget",
visibility: "visibility",
vmathematical: "vMathematical",
"v-mathematical": "vMathematical",
vocab: "vocab",
widths: "widths",
wordspacing: "wordSpacing",
"word-spacing": "wordSpacing",
writingmode: "writingMode",
"writing-mode": "writingMode",
x1: "x1",
x2: "x2",
x: "x",
xchannelselector: "xChannelSelector",
xheight: "xHeight",
"x-height": "xHeight",
xlinkactuate: "xlinkActuate",
"xlink:actuate": "xlinkActuate",
xlinkarcrole: "xlinkArcrole",
"xlink:arcrole": "xlinkArcrole",
xlinkhref: "xlinkHref",
"xlink:href": "xlinkHref",
xlinkrole: "xlinkRole",
"xlink:role": "xlinkRole",
xlinkshow: "xlinkShow",
"xlink:show": "xlinkShow",
xlinktitle: "xlinkTitle",
"xlink:title": "xlinkTitle",
xlinktype: "xlinkType",
"xlink:type": "xlinkType",
xmlbase: "xmlBase",
"xml:base": "xmlBase",
xmllang: "xmlLang",
"xml:lang": "xmlLang",
xmlns: "xmlns",
"xml:space": "xmlSpace",
xmlnsxlink: "xmlnsXlink",
"xmlns:xlink": "xmlnsXlink",
xmlspace: "xmlSpace",
y1: "y1",
y2: "y2",
y: "y",
ychannelselector: "yChannelSelector",
z: "z",
zoomandpan: "zoomAndPan"
};
const ELEMENT_ATTRIBUTE_MAPPING = {
input: {
checked: "defaultChecked",
value: "defaultValue",
maxlength: "maxLength"
},
form: {
enctype: "encType"
}
};
const ELEMENT_TAG_NAME_MAPPING = {
a: "a",
altglyph: "altGlyph",
altglyphdef: "altGlyphDef",
altglyphitem: "altGlyphItem",
animate: "animate",
animatecolor: "animateColor",
animatemotion: "animateMotion",
animatetransform: "animateTransform",
audio: "audio",
canvas: "canvas",
circle: "circle",
clippath: "clipPath",
"color-profile": "colorProfile",
cursor: "cursor",
defs: "defs",
desc: "desc",
discard: "discard",
ellipse: "ellipse",
feblend: "feBlend",
fecolormatrix: "feColorMatrix",
fecomponenttransfer: "feComponentTransfer",
fecomposite: "feComposite",
feconvolvematrix: "feConvolveMatrix",
fediffuselighting: "feDiffuseLighting",
fedisplacementmap: "feDisplacementMap",
fedistantlight: "feDistantLight",
fedropshadow: "feDropShadow",
feflood: "feFlood",
fefunca: "feFuncA",
fefuncb: "feFuncB",
fefuncg: "feFuncG",
fefuncr: "feFuncR",
fegaussianblur: "feGaussianBlur",
feimage: "feImage",
femerge: "feMerge",
femergenode: "feMergeNode",
femorphology: "feMorphology",
feoffset: "feOffset",
fepointlight: "fePointLight",
fespecularlighting: "feSpecularLighting",
fespotlight: "feSpotLight",
fetile: "feTile",
feturbulence: "feTurbulence",
filter: "filter",
font: "font",
"font-face": "fontFace",
"font-face-format": "fontFaceFormat",
"font-face-name": "fontFaceName",
"font-face-src": "fontFaceSrc",
"font-face-uri": "fontFaceUri",
foreignobject: "foreignObject",
g: "g",
glyph: "glyph",
glyphref: "glyphRef",
hatch: "hatch",
hatchpath: "hatchpath",
hkern: "hkern",
iframe: "iframe",
image: "image",
line: "line",
lineargradient: "linearGradient",
marker: "marker",
mask: "mask",
mesh: "mesh",
meshgradient: "meshgradient",
meshpatch: "meshpatch",
meshrow: "meshrow",
metadata: "metadata",
"missing-glyph": "missingGlyph",
mpath: "mpath",
path: "path",
pattern: "pattern",
polygon: "polygon",
polyline: "polyline",
radialgradient: "radialGradient",
rect: "rect",
script: "script",
set: "set",
solidcolor: "solidcolor",
stop: "stop",
style: "style",
svg: "svg",
switch: "switch",
symbol: "symbol",
text: "text",
textpath: "textPath",
title: "title",
tref: "tref",
tspan: "tspan",
unknown: "unknown",
use: "use",
video: "video",
view: "view",
vkern: "vkern"
};
const convertAriaAttribute = (kebabKey) => {
const [aria, ...parts] = kebabKey.split("-");
return `${aria}-${parts.join("").toLowerCase()}`;
};
const getKey = (key, node) => {
const lowerCaseKey = key.toLowerCase();
const mappedElementAttribute = ELEMENT_ATTRIBUTE_MAPPING[node.name] && ELEMENT_ATTRIBUTE_MAPPING[node.name][lowerCaseKey];
const mappedAttribute = ATTRIBUTE_MAPPING[lowerCaseKey];
if (mappedElementAttribute || mappedAttribute) {
return t__namespace.jsxIdentifier(mappedElementAttribute || mappedAttribute);
}
const kebabKey = kebabCase(key);
if (kebabKey.startsWith("aria-")) {
return t__namespace.jsxIdentifier(convertAriaAttribute(kebabKey));
}
if (kebabKey.startsWith("data-")) {
return t__namespace.jsxIdentifier(kebabKey);
}
return t__namespace.jsxIdentifier(key);
};
const getValue = (key, value) => {
if (Array.isArray(value)) {
return t__namespace.stringLiteral(replaceSpaces(value.join(" ")));
}
if (key === "style") {
return t__namespace.jsxExpressionContainer(stringToObjectStyle(value));
}
if (typeof value === "number" || isNumeric(value)) {
return t__namespace.jsxExpressionContainer(t__namespace.numericLiteral(Number(value)));
}
return t__namespace.stringLiteral(replaceSpaces(value));
};
const getAttributes = (node) => {
if (!node.properties)
return [];
const keys = Object.keys(node.properties);
const attributes = [];
let index = -1;
while (++index < keys.length) {
const key = keys[index];
const value = node.properties[key];
const attribute = t__namespace.jsxAttribute(getKey(key, node), getValue(key, value));
attributes.push(attribute);
}
return attributes;
};
const root = (h, node) => t__namespace.program(all(h, node));
const comment = (_, node, parent) => {
if (parent.type === "root" || !node.value)
return null;
const expression = t__namespace.jsxEmptyExpression();
t__namespace.addComment(expression, "inner", node.value);
return t__namespace.jsxExpressionContainer(expression);
};
const SPACE_REGEX = /^\s+$/;
const text = (h, node, parent) => {
if (parent.type === "root")
return null;
if (typeof node.value === "string" && SPACE_REGEX.test(node.value))
return null;
return t__namespace.jsxExpressionContainer(
t__namespace.stringLiteral(entities.decodeXML(String(node.value)))
);
};
const element = (h, node, parent) => {
if (!node.tagName)
return null;
const children = all(h, node);
const selfClosing = children.length === 0;
const name = ELEMENT_TAG_NAME_MAPPING[node.tagName] || node.tagName;
const openingElement = t__namespace.jsxOpeningElement(
t__namespace.jsxIdentifier(name),
getAttributes(node),
selfClosing
);
const closingElement = !selfClosing ? t__namespace.jsxClosingElement(t__namespace.jsxIdentifier(name)) : null;
const jsxElement = t__namespace.jsxElement(openingElement, closingElement, children);
if (parent.type === "root") {
return t__namespace.expressionStatement(jsxElement);
}
return jsxElement;
};
var handlers = /*#__PURE__*/Object.freeze({
__proto__: null,
root: root,
comment: comment,
text: text,
element: element
});
const helpers = { handlers };
const toBabelAST = (tree) => root(helpers, tree);
module.exports = toBabelAST;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

49
node_modules/@svgr/hast-util-to-babel-ast/package.json generated vendored Normal file
View File

@@ -0,0 +1,49 @@
{
"name": "@svgr/hast-util-to-babel-ast",
"description": "Transform HAST to Babel AST (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/hast-util-to-babel-ast",
"author": "Greg Bergé <berge.greg@gmail.com>",
"publishConfig": {
"access": "public"
},
"keywords": [
"html",
"hast",
"babel",
"hast-util",
"unist-util",
"unist"
],
"engines": {
"node": ">=10"
},
"homepage": "https://react-svgr.com",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/gregberge"
},
"license": "MIT",
"dependencies": {
"@babel/types": "^7.20.0",
"entities": "^4.4.0"
},
"scripts": {
"reset": "rm -rf dist",
"build": "rollup -c ../../build/rollup.config.js",
"prepublishOnly": "npm run reset && npm run build"
},
"devDependencies": {
"@types/svg-parser": "^2.0.3"
},
"gitHead": "d5efedd372999692f84d30072e502b5a6b8fe734"
}

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,CAAA,CAAA;AAEA,MAAM,SAAoB,GAAA,CAAC,IAAM,EAAA,MAAA,EAAQ,KAAU,KAAA;AACjD,EAAM,MAAA,QAAA,GAAW,MAAM,QAAY,IAAA,SAAA,CAAA;AACnC,EAAM,MAAA,QAAA,GAAWA,gBAAM,IAAI,CAAA,CAAA;AAE3B,EAAM,MAAA,SAAA,GAAYC,mCAAe,QAAQ,CAAA,CAAA;AAEzC,EAAA,MAAM,gBAAsC,GAAA,aAAA,CAAA,cAAA,CAAA;AAAA,IAC1C,KAAK,MAAO,CAAA,GAAA;AAAA,IACZ,WAAW,MAAO,CAAA,SAAA;AAAA,IAClB,UAAU,MAAO,CAAA,QAAA;AAAA,IACjB,aAAa,MAAO,CAAA,WAAA;AAAA,IACpB,YAAY,MAAO,CAAA,UAAA;AAAA,IACnB,MAAM,MAAO,CAAA,IAAA;AAAA,IACb,QAAQ,MAAO,CAAA,MAAA;AAAA,IACf,UAAU,MAAO,CAAA,QAAA;AAAA,IACjB,mBAAmB,MAAO,CAAA,iBAAA;AAAA,IAC1B,YAAY,MAAO,CAAA,UAAA;AAAA,IACnB,UAAU,MAAO,CAAA,QAAA;AAAA,IACjB,MAAM,MAAO,CAAA,IAAA;AAAA,IACb,YAAY,MAAO,CAAA,UAAA;AAAA,IACnB,aAAa,MAAO,CAAA,WAAA;AAAA,GACjB,EAAA,oBAAA,CAAqB,MAAM,CAfY,CAAA,EAAA;AAAA,IAgB1C,KAAA;AAAA,GACF,CAAA,CAAA;AAEA,EAAM,MAAA,MAAA,GAASC,yBAAqB,CAAA,SAAA,EAAW,IAAM,EAAA,cAAA,CAAA;AAAA,IACnD,MAAQ,EAAA;AAAA,MACN,IAAM,EAAA,MAAA;AAAA,KACR;AAAA,IACA,OAAS,EAAA;AAAA,MACPC,qBAAiB,CAAA,CAACC,mCAAiB,EAAA,gBAAgB,CAAG,EAAA;AAAA,QACpD,IAAM,EAAA,QAAA;AAAA,OACP,CAAA;AAAA,KACH;AAAA,IACA,QAAU,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"
}

7
node_modules/@svgr/plugin-svgo/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.

27
node_modules/@svgr/plugin-svgo/README.md generated vendored Normal file
View File

@@ -0,0 +1,27 @@
# @svgr/plugin-svgo
[![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-svgo.svg)](https://www.npmjs.com/package/@svgr/plugin-svgo)
[![MIT License](https://img.shields.io/npm/l/@svgr/plugin-svgo.svg)](https://github.com/smooth-code/svgr/blob/master/LICENSE)
Optimize SVG using SVGO.
## Install
```
npm install --save-dev @svgr/plugin-svgo
```
## Usage
**.svgrrc**
```json
{
"plugins": ["@svgr/plugin-svgo"]
}
```
## License
MIT

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

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

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

@@ -0,0 +1,83 @@
'use strict';
var svgo = require('svgo');
var cosmiconfig = require('cosmiconfig');
const explorer = cosmiconfig.cosmiconfigSync("svgo", {
searchPlaces: [
"package.json",
".svgorc",
".svgorc.js",
".svgorc.json",
".svgorc.yaml",
".svgorc.yml",
"svgo.config.js",
".svgo.yml"
],
transform: (result) => result && result.config,
cache: true
});
const getSvgoConfigFromSvgrConfig = (config) => {
const params = { overrides: {} };
if (config.icon || config.dimensions === false) {
params.overrides.removeViewBox = false;
}
if (config.native) {
params.overrides.inlineStyles = {
onlyMatchedOnce: false
};
}
return {
plugins: [
{
name: "preset-default",
params
},
"prefixIds"
]
};
};
const getSvgoConfig = (config, state) => {
const cwd = state.filePath || process.cwd();
if (config.svgoConfig)
return config.svgoConfig;
if (config.runtimeConfig) {
const userConfig = explorer.search(cwd);
if (userConfig)
return userConfig;
}
return getSvgoConfigFromSvgrConfig(config);
};
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 svgoPlugin = (code, config, state) => {
if (!config.svgo)
return code;
const svgoConfig = getSvgoConfig(config, state);
const result = svgo.optimize(code, __spreadProps(__spreadValues({}, svgoConfig), { path: state.filePath }));
if (result.modernError) {
throw result.modernError;
}
return result.data;
};
module.exports = svgoPlugin;
//# sourceMappingURL=index.js.map

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

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../src/config.ts","../src/index.ts"],"sourcesContent":["import { cosmiconfigSync } from 'cosmiconfig'\nimport type { Config, State } from '@svgr/core'\n\nconst explorer = cosmiconfigSync('svgo', {\n searchPlaces: [\n 'package.json',\n '.svgorc',\n '.svgorc.js',\n '.svgorc.json',\n '.svgorc.yaml',\n '.svgorc.yml',\n 'svgo.config.js',\n '.svgo.yml',\n ],\n transform: (result) => result && result.config,\n cache: true,\n})\n\nconst getSvgoConfigFromSvgrConfig = (config: Config): any => {\n const params = { overrides: {} as any }\n if (config.icon || config.dimensions === false) {\n params.overrides.removeViewBox = false\n }\n if (config.native) {\n params.overrides.inlineStyles = {\n onlyMatchedOnce: false,\n }\n }\n\n return {\n plugins: [\n {\n name: 'preset-default',\n params,\n },\n 'prefixIds',\n ],\n }\n}\n\nexport const getSvgoConfig = (config: Config, state: State): any => {\n const cwd = state.filePath || process.cwd()\n if (config.svgoConfig) return config.svgoConfig\n if (config.runtimeConfig) {\n const userConfig = explorer.search(cwd)\n if (userConfig) return userConfig\n }\n return getSvgoConfigFromSvgrConfig(config)\n}\n","import { optimize } from 'svgo'\nimport { getSvgoConfig } from './config'\nimport type { Plugin } from '@svgr/core'\n\nconst svgoPlugin: Plugin = (code, config, state) => {\n if (!config.svgo) return code\n const svgoConfig = getSvgoConfig(config, state)\n const result = optimize(code, { ...svgoConfig, path: state.filePath })\n\n // @ts-ignore\n if (result.modernError) {\n // @ts-ignore\n throw result.modernError\n }\n\n return result.data\n}\n\nexport default svgoPlugin\n"],"names":["cosmiconfigSync","optimize"],"mappings":";;;;;AAGA,MAAM,QAAA,GAAWA,4BAAgB,MAAQ,EAAA;AAAA,EACvC,YAAc,EAAA;AAAA,IACZ,cAAA;AAAA,IACA,SAAA;AAAA,IACA,YAAA;AAAA,IACA,cAAA;AAAA,IACA,cAAA;AAAA,IACA,aAAA;AAAA,IACA,gBAAA;AAAA,IACA,WAAA;AAAA,GACF;AAAA,EACA,SAAW,EAAA,CAAC,MAAW,KAAA,MAAA,IAAU,MAAO,CAAA,MAAA;AAAA,EACxC,KAAO,EAAA,IAAA;AACT,CAAC,CAAA,CAAA;AAED,MAAM,2BAAA,GAA8B,CAAC,MAAwB,KAAA;AAC3D,EAAA,MAAM,MAAS,GAAA,EAAE,SAAW,EAAA,EAAU,EAAA,CAAA;AACtC,EAAA,IAAI,MAAO,CAAA,IAAA,IAAQ,MAAO,CAAA,UAAA,KAAe,KAAO,EAAA;AAC9C,IAAA,MAAA,CAAO,UAAU,aAAgB,GAAA,KAAA,CAAA;AAAA,GACnC;AACA,EAAA,IAAI,OAAO,MAAQ,EAAA;AACjB,IAAA,MAAA,CAAO,UAAU,YAAe,GAAA;AAAA,MAC9B,eAAiB,EAAA,KAAA;AAAA,KACnB,CAAA;AAAA,GACF;AAEA,EAAO,OAAA;AAAA,IACL,OAAS,EAAA;AAAA,MACP;AAAA,QACE,IAAM,EAAA,gBAAA;AAAA,QACN,MAAA;AAAA,OACF;AAAA,MACA,WAAA;AAAA,KACF;AAAA,GACF,CAAA;AACF,CAAA,CAAA;AAEa,MAAA,aAAA,GAAgB,CAAC,MAAA,EAAgB,KAAsB,KAAA;AAClE,EAAA,MAAM,GAAM,GAAA,KAAA,CAAM,QAAY,IAAA,OAAA,CAAQ,GAAI,EAAA,CAAA;AAC1C,EAAA,IAAI,MAAO,CAAA,UAAA;AAAY,IAAA,OAAO,MAAO,CAAA,UAAA,CAAA;AACrC,EAAA,IAAI,OAAO,aAAe,EAAA;AACxB,IAAM,MAAA,UAAA,GAAa,QAAS,CAAA,MAAA,CAAO,GAAG,CAAA,CAAA;AACtC,IAAI,IAAA,UAAA;AAAY,MAAO,OAAA,UAAA,CAAA;AAAA,GACzB;AACA,EAAA,OAAO,4BAA4B,MAAM,CAAA,CAAA;AAC3C,CAAA;;;;;;;;;;;;;;;;;;;;;AC5CA,MAAM,UAAqB,GAAA,CAAC,IAAM,EAAA,MAAA,EAAQ,KAAU,KAAA;AAClD,EAAA,IAAI,CAAC,MAAO,CAAA,IAAA;AAAM,IAAO,OAAA,IAAA,CAAA;AACzB,EAAM,MAAA,UAAA,GAAa,aAAc,CAAA,MAAA,EAAQ,KAAK,CAAA,CAAA;AAC9C,EAAM,MAAA,MAAA,GAASC,cAAS,IAAM,EAAA,aAAA,CAAA,cAAA,CAAA,EAAA,EAAK,aAAL,EAAiB,IAAA,EAAM,KAAM,CAAA,QAAA,EAAU,CAAA,CAAA,CAAA;AAGrE,EAAA,IAAI,OAAO,WAAa,EAAA;AAEtB,IAAA,MAAM,MAAO,CAAA,WAAA,CAAA;AAAA,GACf;AAEA,EAAA,OAAO,MAAO,CAAA,IAAA,CAAA;AAChB;;;;"}

45
node_modules/@svgr/plugin-svgo/package.json generated vendored Normal file
View File

@@ -0,0 +1,45 @@
{
"name": "@svgr/plugin-svgo",
"description": "Optimize SVG",
"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-svgo",
"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": "*"
},
"dependencies": {
"cosmiconfig": "^7.0.1",
"deepmerge": "^4.2.2",
"svgo": "^2.8.0"
},
"gitHead": "d5efedd372999692f84d30072e502b5a6b8fe734"
}

7
node_modules/@svgr/webpack/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.

129
node_modules/@svgr/webpack/README.md generated vendored Normal file
View File

@@ -0,0 +1,129 @@
# @svgr/webpack
[![Build Status](https://img.shields.io/travis/gregberge/svgr.svg)](https://travis-ci.org/gregberge/svgr)
[![Version](https://img.shields.io/npm/v/@svgr/webpack.svg)](https://www.npmjs.com/package/@svgr/webpack)
[![MIT License](https://img.shields.io/npm/l/@svgr/webpack.svg)](https://github.com/gregberge/svgr/blob/master/LICENSE)
Webpack loader for SVGR.
```
npm install @svgr/webpack --save-dev
```
## Usage
In your `webpack.config.js`:
```js
{
test: /\.svg$/,
use: ['@svgr/webpack'],
}
```
In your code:
```js
import Star from './star.svg'
const App = () => (
<div>
<Star />
</div>
)
```
### Passing options
```js
{
test: /\.svg$/,
use: [
{
loader: '@svgr/webpack',
options: {
native: true,
},
},
],
}
```
### Using with `url-loader` or `file-loader`
It is possible to use it with [`url-loader`](https://github.com/webpack-contrib/url-loader) or [`file-loader`](https://github.com/webpack-contrib/file-loader).
In your `webpack.config.js`:
```js
{
test: /\.svg$/,
use: ['@svgr/webpack', 'url-loader'],
}
```
In your code:
```js
import starUrl, { ReactComponent as Star } from './star.svg'
const App = () => (
<div>
<img src={starUrl} alt="star" />
<Star />
</div>
)
```
The named export defaults to `ReactComponent`, but can be customized with the `namedExport` option.
Please note that by default, `@svgr/webpack` will try to export the React Component via default export if there is no other loader handling svg files with default export. When there is already any other loader using default export for svg files, `@svgr/webpack` will always export the React component via named export.
If you prefer named export in any case, you may set the `exportType` option to `named`.
### Use your own Babel configuration
By default, `@svgr/webpack` includes a `babel-loader` with [an optimized configuration](https://github.com/gregberge/svgr/blob/main/packages/webpack/src/index.ts). In some case you may want to apply a custom one (if you are using Preact for an example). You can turn off Babel transformation by specifying `babel: false` in options.
```js
// Example using preact
{
test: /\.svg$/,
use: [
{
loader: 'babel-loader',
options: {
presets: ['preact', 'env'],
},
},
{
loader: '@svgr/webpack',
options: { babel: false },
}
],
}
```
### Handle SVG in CSS, Sass or Less
It is possible to detect the module that requires your SVG using [`Rule.issuer`](https://webpack.js.org/configuration/module/#ruleissuer) in Webpack 5. Using it you can specify two different configurations for JavaScript and the rest of your files.
```js
;[
{
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
issuer: /\.[jt]sx?$/,
use: ['babel-loader', '@svgr/webpack', 'url-loader'],
},
{
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader',
},
]
```
_[Rule.issuer](https://v4.webpack.js.org/configuration/module/#ruleissuer) in Webpack 4 has additional conditions which are not available in Webpack 5._
## License
MIT

9
node_modules/@svgr/webpack/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,9 @@
import { Config } from '@svgr/core';
import * as webpack from 'webpack';
interface LoaderOptions extends Config {
babel?: boolean;
}
declare function svgrLoader(this: webpack.LoaderContext<LoaderOptions>, contents: string): void;
export { svgrLoader as default };

126
node_modules/@svgr/webpack/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,126 @@
'use strict';
var util = require('util');
var core = require('@babel/core');
var core$1 = require('@svgr/core');
var path = require('path');
var svgo = require('@svgr/plugin-svgo');
var jsx = require('@svgr/plugin-jsx');
var presetReact = require('@babel/preset-react');
var presetEnv = require('@babel/preset-env');
var presetTS = require('@babel/preset-typescript');
var pluginTransformReactConstantElements = require('@babel/plugin-transform-react-constant-elements');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var svgo__default = /*#__PURE__*/_interopDefaultLegacy(svgo);
var jsx__default = /*#__PURE__*/_interopDefaultLegacy(jsx);
var presetReact__default = /*#__PURE__*/_interopDefaultLegacy(presetReact);
var presetEnv__default = /*#__PURE__*/_interopDefaultLegacy(presetEnv);
var presetTS__default = /*#__PURE__*/_interopDefaultLegacy(presetTS);
var pluginTransformReactConstantElements__default = /*#__PURE__*/_interopDefaultLegacy(pluginTransformReactConstantElements);
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));
var __objRest = (source, exclude) => {
var target = {};
for (var prop in source)
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
target[prop] = source[prop];
if (source != null && __getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(source)) {
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
target[prop] = source[prop];
}
return target;
};
const babelOptions = {
babelrc: false,
configFile: false,
presets: [
core.createConfigItem(presetReact__default["default"], { type: "preset" }),
core.createConfigItem([presetEnv__default["default"], { modules: false }], { type: "preset" })
],
plugins: [core.createConfigItem(pluginTransformReactConstantElements__default["default"])]
};
const typeScriptBabelOptions = __spreadProps(__spreadValues({}, babelOptions), {
presets: [
...babelOptions.presets,
core.createConfigItem(
[presetTS__default["default"], { allowNamespaces: true, allExtensions: true, isTSX: true }],
{ type: "preset" }
)
]
});
const tranformSvg = util.callbackify(
async (contents, options, state) => {
const _a = options, { babel = true } = _a, config = __objRest(_a, ["babel"]);
const jsCode = await core$1.transform(contents, config, state);
if (!babel)
return jsCode;
const result = await core.transformAsync(
jsCode,
options.typescript ? typeScriptBabelOptions : babelOptions
);
if (!(result == null ? void 0 : result.code)) {
throw new Error(`Error while transforming using Babel`);
}
return result.code;
}
);
function svgrLoader(contents) {
this.cacheable && this.cacheable();
const callback = this.async();
const options = this.getOptions();
const previousExport = (() => {
if (contents.startsWith("export "))
return contents;
const exportMatches = contents.match(/^module.exports\s*=\s*(.*)/);
return exportMatches ? `export default ${exportMatches[1]}` : null;
})();
const state = {
caller: {
name: "@svgr/webpack",
previousExport,
defaultPlugins: [svgo__default["default"], jsx__default["default"]]
},
filePath: path.normalize(this.resourcePath)
};
if (!previousExport) {
tranformSvg(contents, options, state, callback);
} else {
this.fs.readFile(this.resourcePath, (err, result) => {
if (err) {
callback(err);
return;
}
tranformSvg(String(result), options, state, (err2, content) => {
if (err2) {
callback(err2);
return;
}
callback(null, content);
});
});
}
}
module.exports = svgrLoader;
//# sourceMappingURL=index.js.map

1
node_modules/@svgr/webpack/dist/index.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

57
node_modules/@svgr/webpack/package.json generated vendored Normal file
View File

@@ -0,0 +1,57 @@
{
"name": "@svgr/webpack",
"description": "SVGR webpack loader.",
"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/webpack",
"author": "Greg Bergé <berge.greg@gmail.com>",
"publishConfig": {
"access": "public"
},
"keywords": [
"svgr",
"svg",
"react",
"webpack",
"webpack-loader"
],
"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"
},
"dependencies": {
"@babel/core": "^7.19.6",
"@babel/plugin-transform-react-constant-elements": "^7.18.12",
"@babel/preset-env": "^7.19.4",
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.18.6",
"@svgr/core": "^6.5.1",
"@svgr/plugin-jsx": "^6.5.1",
"@svgr/plugin-svgo": "^6.5.1"
},
"devDependencies": {
"babel-loader": "^9.0.0",
"memory-fs": "^0.5.0",
"url-loader": "^4.1.1",
"webpack": "^5.74.0"
},
"gitHead": "d5efedd372999692f84d30072e502b5a6b8fe734"
}