Add yet-another-react-lightbox package and update .gitignore to exclude node_modules

This commit is contained in:
IGNY8 VPS (Salman)
2025-11-12 18:50:30 +00:00
parent bd2a5570a9
commit c92f4a5edd
9304 changed files with 29 additions and 2008667 deletions

View File

@@ -1,21 +0,0 @@
MIT License
Copyright (c) 2021 Rongjian Zhang
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

@@ -1,82 +0,0 @@
# vite-plugin-svgr
[![npm](https://img.shields.io/npm/v/vite-plugin-svgr.svg)](https://www.npmjs.com/package/vite-plugin-svgr)
Vite plugin to transform SVGs into React components. Uses [svgr](https://github.com/gregberge/svgr) under the hood.
## Installation
```sh
# npm
npm install --save-dev vite-plugin-svgr
# yarn
yarn add -D vite-plugin-svgr
# pnpm
pnpm add -D vite-plugin-svgr
```
## Usage
```js
// vite.config.js
import svgr from "vite-plugin-svgr";
export default {
// ...
plugins: [svgr()],
};
```
Then SVG files can be imported as React components:
```js
import Logo from "./logo.svg?react";
```
If you are using TypeScript, there is also a declaration helper for better type inference. Add the following to `vite-env.d.ts`:
```ts
/// <reference types="vite-plugin-svgr/client" />
```
### Options
```js
svgr({
// svgr options: https://react-svgr.com/docs/options/
svgrOptions: {
// ...
},
// esbuild options, to transform jsx to js
esbuildOptions: {
// ...
},
// A minimatch pattern, or array of patterns, which specifies the files in the build the plugin should include.
include: "**/*.svg?react",
// A minimatch pattern, or array of patterns, which specifies the files in the build the plugin should ignore. By default no files are ignored.
exclude: "",
});
```
If you want to enable SVGO you can install `@svgr/plugin-svgo` and use following options to enable and configure it:
```js
svgr({
svgrOptions: {
plugins: ["@svgr/plugin-svgo", "@svgr/plugin-jsx"],
svgoConfig: {
floatPrecision: 2,
},
},
// ...
});
```
## License
MIT

View File

@@ -1,12 +0,0 @@
// https://github.com/facebook/create-react-app/blob/0ee4765c39f820e5f4820abf4bf2e47b3324da7f/packages/react-scripts/lib/react-app.d.ts#L47-L56
// https://github.com/pd4d10/vite-plugin-svgr/pull/56 for preact compatiblility
declare module "*.svg?react" {
import * as React from "react";
const ReactComponent: React.FunctionComponent<
React.ComponentProps<"svg"> & { title?: string, titleId?: string, desc?: string, descId?: string }
>;
export default ReactComponent;
}

View File

@@ -1,8 +0,0 @@
{
"name": "codemods",
"version": "0.0.0",
"type": "commonjs",
"exports": {
"./package.json": "./package.json"
}
}

View File

@@ -1,31 +0,0 @@
# Codemod
## V4
convert named export to default
If you want to run it against `.js` or `.jsx` files, please use the command below:
```
npx jscodeshift@latest ./path/to/src/ \
--extensions=js,jsx \
--transform=./node_modules/vite-plugin-svgr/codemods/src/v4/default-export/default-export.js
```
If you want to run it against `.ts` or `.tsx` files, please use the command below:
```
npx jscodeshift@latest ./path/to/src/ \
--extensions=ts,tsx \
--parser=tsx \
--transform=./node_modules/vite-plugin-svgr/codemods/src/v4/default-export/default-export.js
```
**Note:** Applying the codemod might break your code formatting, so please don't forget to run `prettier` and/or `eslint` after you've applied the codemod!
Above codemod will convert as imports as bellow
```diff
- import { ReactComponent as NoticeModeIconActive2 } from 'assets/icon.svg';
+ import NoticeModeIconActive2 from 'assets/icon.svg?react';
```

View File

@@ -1,33 +0,0 @@
module.exports = function (file, api) {
const jscodeshift = api.jscodeshift;
const root = jscodeshift(file.source);
root.find(jscodeshift.ImportDeclaration).forEach((path) => {
const importPath = path.node.source.value;
if (importPath.endsWith(".svg")) {
const hasDefaultSpecifier = path.node.specifiers.some((specifier) =>
jscodeshift.ImportDefaultSpecifier.check(specifier),
);
// Skip transformation if there is a default import specifier
if (!hasDefaultSpecifier) {
const updatedImportPath = `${importPath}?react`;
path.node.specifiers.forEach((specifier) => {
if (jscodeshift.ImportSpecifier.check(specifier)) {
// Convert named import to default import
const newSpecifier = jscodeshift.importDefaultSpecifier(
jscodeshift.identifier(specifier.local.name),
);
specifier.type = "ImportDefaultSpecifier";
specifier.local = newSpecifier.local;
}
});
path.node.source = jscodeshift.literal(updatedImportPath);
}
}
});
return root.toSource();
};

View File

@@ -1,62 +0,0 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = vitePluginSvgr;
const pluginutils_1 = require("@rollup/pluginutils");
const fs_1 = __importDefault(require("fs"));
const vite_1 = require("vite");
function vitePluginSvgr({ svgrOptions, esbuildOptions, include = "**/*.svg?react", exclude, } = {}) {
const filter = (0, pluginutils_1.createFilter)(include, exclude);
const postfixRE = /[?#].*$/s;
return {
name: "vite-plugin-svgr",
enforce: "pre", // to override `vite:asset`'s behavior
async load(id) {
if (filter(id)) {
const { transform } = await Promise.resolve().then(() => __importStar(require("@svgr/core")));
const { default: jsx } = await Promise.resolve().then(() => __importStar(require("@svgr/plugin-jsx")));
const filePath = id.replace(postfixRE, "");
const svgCode = await fs_1.default.promises.readFile(filePath, "utf8");
const componentCode = await transform(svgCode, svgrOptions, {
filePath,
caller: {
defaultPlugins: [jsx],
},
});
const res = await (0, vite_1.transformWithEsbuild)(componentCode, id, {
loader: "jsx",
...esbuildOptions,
});
return {
code: res.code,
map: null, // TODO:
};
}
},
};
}

View File

@@ -1,11 +0,0 @@
import { FilterPattern } from "@rollup/pluginutils";
import type { Config } from "@svgr/core";
import type { Plugin } from "vite";
import { transformWithEsbuild } from "vite";
export interface VitePluginSvgrOptions {
svgrOptions?: Config;
esbuildOptions?: Parameters<typeof transformWithEsbuild>[2];
exclude?: FilterPattern;
include?: FilterPattern;
}
export default function vitePluginSvgr({ svgrOptions, esbuildOptions, include, exclude, }?: VitePluginSvgrOptions): Plugin;

View File

@@ -1,33 +0,0 @@
import { createFilter } from "@rollup/pluginutils";
import fs from "fs";
import { transformWithEsbuild } from "vite";
export default function vitePluginSvgr({ svgrOptions, esbuildOptions, include = "**/*.svg?react", exclude, } = {}) {
const filter = createFilter(include, exclude);
const postfixRE = /[?#].*$/s;
return {
name: "vite-plugin-svgr",
enforce: "pre", // to override `vite:asset`'s behavior
async load(id) {
if (filter(id)) {
const { transform } = await import("@svgr/core");
const { default: jsx } = await import("@svgr/plugin-jsx");
const filePath = id.replace(postfixRE, "");
const svgCode = await fs.promises.readFile(filePath, "utf8");
const componentCode = await transform(svgCode, svgrOptions, {
filePath,
caller: {
defaultPlugins: [jsx],
},
});
const res = await transformWithEsbuild(componentCode, id, {
loader: "jsx",
...esbuildOptions,
});
return {
code: res.code,
map: null, // TODO:
};
}
},
};
}

View File

@@ -1,48 +0,0 @@
{
"name": "vite-plugin-svgr",
"version": "4.3.0",
"description": "Vite plugin to transform SVGs into React components",
"type": "module",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"./client": {
"types": "./client.d.ts"
}
},
"scripts": {
"dev": "tsc --watch",
"build": "tsc --module commonjs && mv dist/index.js dist/index.cjs && tsc",
"prepare": "npm run build"
},
"repository": "pd4d10/vite-plugin-svgr",
"files": [
"dist",
"client.d.ts",
"codemods"
],
"keywords": [
"vite",
"vite-plugin"
],
"author": "Rongjian Zhang",
"license": "MIT",
"devDependencies": {
"@types/node": "^22.8.6",
"typescript": "^5.6.3"
},
"peerDependencies": {
"vite": ">=2.6.0"
},
"dependencies": {
"@rollup/pluginutils": "^5.1.3",
"@svgr/core": "^8.1.0",
"@svgr/plugin-jsx": "^8.1.0"
},
"packageManager": "pnpm@9.12.3+sha512.cce0f9de9c5a7c95bef944169cc5dfe8741abfb145078c0d508b868056848a87c81e626246cb60967cbd7fd29a6c062ef73ff840d96b3c86c40ac92cf4a813ee"
}