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

7
node_modules/@svgr/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"
}