Compare commits
4 Commits
fix/fixed-
...
icons-pack
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be94febe4e | ||
|
|
6b618cd030 | ||
|
|
884bf6fb10 | ||
|
|
d2426203c9 |
6
.gitignore
vendored
@@ -20,13 +20,9 @@ packages/**/src/aliases/*.ts
|
||||
packages/**/src/aliases.ts
|
||||
!packages/**/src/aliases/index.ts
|
||||
packages/**/src/dynamicIconImports.ts
|
||||
packages/**/DynamicIcon.d.ts
|
||||
packages/**/dynamicIconImports.js
|
||||
packages/**/dynamicIconImports.d.ts
|
||||
packages/**/dynamicIconImports.js.map
|
||||
packages/**/dynamic.d.ts
|
||||
packages/**/dynamic.mjs.map
|
||||
packages/**/dynamic.mjs
|
||||
packages/**/LICENSE
|
||||
categories.json
|
||||
tags.json
|
||||
@@ -45,5 +41,3 @@ docs/.vitepress/data/iconDetails
|
||||
docs/.vitepress/data/relatedIcons.json
|
||||
docs/.vercel
|
||||
docs/.nitro
|
||||
.gitignore
|
||||
|
||||
|
||||
22
README.md
@@ -30,17 +30,17 @@ Lucide is an open-source icon library that provides 1000+ vector (svg) files for
|
||||
|
||||
## Packages
|
||||
|
||||
| Logo | Package | Version | Downloads | Links |
|
||||
| ---- | ------- | ------- | --------- | ----- |
|
||||
| <img src="https://lucide.dev/framework-logos/js.svg" alt="JS logo" width="48"> | **`lucide`** | [](https://www.npmjs.com/package/lucide) |  | [Docs](https://lucide.dev/guide/packages/lucide) · [Source](./packages/lucide) |
|
||||
| <img src="https://lucide.dev/framework-logos/react.svg" alt="React logo" width="48"> | **`lucide-react`** | [](https://www.npmjs.com/package/lucide-react) |  | [Docs](https://lucide.dev/guide/packages/lucide-react) · [Source](./packages/lucide-react) |
|
||||
| <img src="https://lucide.dev/framework-logos/vue.svg" alt="Vue logo" width="48"> | **`lucide-vue-next`** | [](https://www.npmjs.com/package/lucide-vue-next) |  | [Docs](https://lucide.dev/guide/packages/lucide-vue-next) · [Source](./packages/lucide-vue-next) |
|
||||
| <img src="https://lucide.dev/framework-logos/svelte.svg" alt="Svelte logo" width="48"> | **`lucide-svelte`** | [](https://www.npmjs.com/package/lucide-svelte) |  | [Docs](https://lucide.dev/guide/packages/lucide-svelte) · [Source](./packages/lucide-svelte) |
|
||||
| <img src="https://lucide.dev/framework-logos/solid.svg" alt="Solid logo" width="48"> | **`lucide-solid`** | [](https://www.npmjs.com/package/lucide-solid) |  | [Docs](https://lucide.dev/guide/packages/lucide-solid) · [Source](./packages/lucide-solid) |
|
||||
| <img src="https://lucide.dev/framework-logos/preact.svg" alt="Preact logo" width="48"> | **`lucide-preact`** | [](https://www.npmjs.com/package/lucide-preact) |  | [Docs](https://lucide.dev/guide/packages/lucide-preact) · [Source](./packages/lucide-preact) |
|
||||
| <img src="https://lucide.dev/framework-logos/react-native.svg" alt="React Native logo" width="48"> | **`lucide-react-native`** | [](https://www.npmjs.com/package/lucide-react-native) |  | [Docs](https://lucide.dev/guide/packages/lucide-react-native) · [Source](./packages/lucide-react-native) |
|
||||
| <img src="https://lucide.dev/framework-logos/angular.svg" alt="Angular logo" width="48"> | **`lucide-angular`** | [](https://www.npmjs.com/package/lucide-angular) |  | [Docs](https://lucide.dev/guide/packages/lucide-angular) · [Source](./packages/lucide-angular) |
|
||||
| <img src="https://lucide.dev/framework-logos/svg.svg" alt="SVG logo" width="48"> | **`lucide-static`** | [](https://www.npmjs.com/package/lucide-static) |  | [Docs](https://lucide.dev/guide/packages/lucide-static) · [Source](./packages/lucide-static) |
|
||||
| | Package | Version & Downloads | Links |
|
||||
| --- | --- | --- | --- |
|
||||
| <img src="https://lucide.dev/framework-logos/js.svg" alt="JS logo" width="48"> | `lucide` | [](https://www.npmjs.com/package/lucide)  | [Docs](https://lucide.dev/guide/packages/lucide) [Source](./packages/lucide) |
|
||||
| <img src="https://lucide.dev/framework-logos/react.svg" alt="React logo" width="48"> | `lucide-react` | [](https://www.npmjs.com/package/lucide-react)  | [Docs](https://lucide.dev/guide/packages/lucide-react) [Source](./packages/lucide-react) |
|
||||
| <img src="https://lucide.dev/framework-logos/vue.svg" alt="Vue logo" width="48"> | `lucide-vue-next` | [](https://www.npmjs.com/package/lucide-vue-next)  | [Docs](https://lucide.dev/guide/packages/lucide-vue-next) [Source](./packages/lucide-vue-next) |
|
||||
| <img src="https://lucide.dev/framework-logos/svelte.svg" alt="Svelte logo" width="48"> | `lucide-svelte` | [](https://www.npmjs.com/package/lucide-svelte)  | [Docs](https://lucide.dev/guide/packages/lucide-svelte) [Source](./packages/lucide-svelte) |
|
||||
| <img src="https://lucide.dev/framework-logos/solid.svg" alt="Solid logo" width="48"> | `lucide-solid` | [](https://www.npmjs.com/package/lucide-solid)  | [Docs](https://lucide.dev/guide/packages/lucide-solid) [Source](./packages/lucide-solid) |
|
||||
| <img src="https://lucide.dev/framework-logos/preact.svg" alt="Preact logo" width="48"> | `lucide-preact` | [](https://www.npmjs.com/package/lucide-preact)  | [Docs](https://lucide.dev/guide/packages/lucide-preact) [Source](./packages/lucide-preact) |
|
||||
| <img src="https://lucide.dev/framework-logos/react-native.svg" alt="React Native logo" width="48"> | `lucide-react-native` | [](https://www.npmjs.com/package/lucide-react-native)  | [Docs](https://lucide.dev/guide/packages/lucide-react-native) [Source](./packages/lucide-react-native) |
|
||||
| <img src="https://lucide.dev/framework-logos/angular.svg" alt="Angular logo" width="48"> | `lucide-angular` | [](https://www.npmjs.com/package/lucide-angular)  | [Docs](https://lucide.dev/guide/packages/lucide-angular) [Source](./packages/lucide-angular) |
|
||||
| <img src="https://lucide.dev/framework-logos/svg.svg" alt="SVG logo" width="48"> | `lucide-static` | [](https://www.npmjs.com/package/lucide-static)  | [Docs](https://lucide.dev/guide/packages/lucide-static) [Source](./packages/lucide-static) |
|
||||
|
||||
### Figma
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
},
|
||||
{
|
||||
"name": "finance",
|
||||
"title": "Finance"
|
||||
"title": "Money"
|
||||
},
|
||||
{
|
||||
"name": "food-beverage",
|
||||
@@ -85,7 +85,7 @@
|
||||
},
|
||||
{
|
||||
"name": "math",
|
||||
"title": "Mathematics"
|
||||
"title": "Math"
|
||||
},
|
||||
{
|
||||
"name": "medical",
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
import fs from 'fs/promises';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
const currentDir = process.cwd();
|
||||
const dataDirectory = path.resolve(currentDir, '.vitepress/data');
|
||||
const directory = path.join(process.cwd(), '../categories');
|
||||
|
||||
async function getAllCategoryFiles() {
|
||||
const categoryDirectoryContents = await fs.readdir(directory);
|
||||
const fileNames = categoryDirectoryContents.filter((file) => path.extname(file) === '.json');
|
||||
function getAllCategoryFiles() {
|
||||
const fileNames = fs.readdirSync(directory).filter((file) => path.extname(file) === '.json');
|
||||
|
||||
const categoryJSONReadPromises = fileNames.map(async (fileName) => {
|
||||
return fileNames.map((fileName) => {
|
||||
const name = path.basename(fileName, '.json');
|
||||
const fileContent = await fs.readFile(path.join(directory, fileName), 'utf8');
|
||||
const fileContent = fs.readFileSync(path.join(directory, fileName), 'utf8');
|
||||
|
||||
const parsedFileContent = JSON.parse(fileContent);
|
||||
|
||||
@@ -20,15 +19,14 @@ async function getAllCategoryFiles() {
|
||||
title: parsedFileContent.title,
|
||||
};
|
||||
});
|
||||
|
||||
return Promise.all(categoryJSONReadPromises);
|
||||
}
|
||||
|
||||
const categoriesFile = path.resolve(dataDirectory, `categoriesData.json`);
|
||||
|
||||
const categoriesData = await getAllCategoryFiles();
|
||||
const categoriesData = getAllCategoryFiles();
|
||||
|
||||
fs.writeFile(categoriesFile, JSON.stringify(categoriesData, null, 2), 'utf-8')
|
||||
fs.promises
|
||||
.writeFile(categoriesFile, JSON.stringify(categoriesData, null, 2), 'utf-8')
|
||||
.then(() => {
|
||||
console.log('Successfully written categoriesData.json file');
|
||||
})
|
||||
|
||||
@@ -4,7 +4,7 @@ import { readSvgDirectory, toCamelCase } from '@lucide/helpers';
|
||||
|
||||
const currentDir = process.cwd();
|
||||
const ICONS_DIR = path.resolve(currentDir, '../icons');
|
||||
const icons = await readSvgDirectory(ICONS_DIR, '.json');
|
||||
const icons = readSvgDirectory(ICONS_DIR, '.json');
|
||||
|
||||
const iconDetailsDirectory = path.resolve(currentDir, '.vitepress/data', 'iconDetails');
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { readSvgDirectory, toCamelCase } from '@lucide/helpers';
|
||||
|
||||
const currentDir = process.cwd();
|
||||
const ICONS_DIR = path.resolve(currentDir, '../icons');
|
||||
const iconJsonFiles = await readSvgDirectory(ICONS_DIR, '.json');
|
||||
const iconJsonFiles = readSvgDirectory(ICONS_DIR, '.json');
|
||||
|
||||
const location = path.resolve(currentDir, '.vitepress/data', 'iconMetaData.ts');
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ import { readSvgDirectory, toCamelCase } from '@lucide/helpers';
|
||||
|
||||
const currentDir = process.cwd();
|
||||
const ICONS_DIR = path.resolve(currentDir, '../icons');
|
||||
const svgFiles = await readSvgDirectory(ICONS_DIR);
|
||||
const icons = await renderIconsObject(svgFiles, ICONS_DIR, true);
|
||||
const svgFiles = readSvgDirectory(ICONS_DIR);
|
||||
const icons = renderIconsObject(svgFiles, ICONS_DIR, true);
|
||||
|
||||
const iconNodesDirectory = path.resolve(currentDir, '.vitepress/data', 'iconNodes');
|
||||
|
||||
@@ -32,7 +32,7 @@ const writeIconFiles = Object.entries(icons).map(async ([iconName, { children }]
|
||||
await fs.promises.writeFile(location, output, 'utf-8');
|
||||
|
||||
iconIndexFileImports.push(
|
||||
`import ${toCamelCase(iconName)}Node from './${iconName}.node.json' with { type: "json" };`,
|
||||
`import ${toCamelCase(iconName)}Node from './${iconName}.node.json' assert { type: "json" };`,
|
||||
);
|
||||
iconIndexFileExports.push(` ${toCamelCase(iconName)}Node as ${toCamelCase(iconName)},`);
|
||||
iconIndexFileDefaultExports.push(` '${iconName}': ${toCamelCase(iconName)}Node,`);
|
||||
|
||||
@@ -4,7 +4,7 @@ import { readSvgDirectory } from '@lucide/helpers';
|
||||
|
||||
const currentDir = process.cwd();
|
||||
const ICONS_DIR = path.resolve(currentDir, '../icons');
|
||||
const svgFiles = await readSvgDirectory(ICONS_DIR, '.json');
|
||||
const svgFiles = readSvgDirectory(ICONS_DIR, '.json');
|
||||
|
||||
const location = path.resolve(currentDir, '.vitepress/data', 'relatedIcons.json');
|
||||
|
||||
@@ -18,7 +18,9 @@ const categoryWeight = 3;
|
||||
|
||||
const MAX_RELATED_ICONS = 4 * 17; // grid of 4x17 icons, = 68 icons
|
||||
|
||||
const arrayMatches = (a, b) => a.filter((item) => b.includes(item)).length;
|
||||
const arrayMatches = (a, b) => {
|
||||
return a.filter((item) => b.includes(item)).length;
|
||||
};
|
||||
|
||||
const nameParts = (icon) =>
|
||||
[
|
||||
@@ -34,7 +36,6 @@ const getRelatedIcons = (currentIcon, icons) => {
|
||||
nameWeight * arrayMatches(nameParts(item), nameParts(currentIcon)) +
|
||||
categoryWeight * arrayMatches(item.categories ?? [], currentIcon.categories ?? []) +
|
||||
tagWeight * arrayMatches(item.tags ?? [], currentIcon.tags ?? []);
|
||||
|
||||
return icons
|
||||
.filter((i) => i.name !== currentIcon.name)
|
||||
.map((icon) => ({ icon, similarity: iconSimilarity(icon) }))
|
||||
@@ -45,8 +46,7 @@ const getRelatedIcons = (currentIcon, icons) => {
|
||||
};
|
||||
|
||||
const iconsMetaDataPromises = svgFiles.map(async (iconName) => {
|
||||
const metaDataFileContent = await fs.promises.readFile(`../icons/${iconName}`);
|
||||
const metaData = JSON.parse(metaDataFileContent);
|
||||
const metaData = JSON.parse(fs.readFileSync(`../icons/${iconName}`));
|
||||
|
||||
const name = iconName.replace('.json', '');
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ const git = simpleGit();
|
||||
|
||||
const currentDir = process.cwd();
|
||||
const ICONS_DIR = path.resolve(currentDir, '../icons');
|
||||
const iconJsonFiles = await readSvgDirectory(ICONS_DIR, '.json');
|
||||
const iconJsonFiles = readSvgDirectory(ICONS_DIR, '.json');
|
||||
const location = path.resolve(currentDir, '.vitepress/data', 'releaseMetaData.json');
|
||||
const releaseMetaDataDirectory = path.resolve(currentDir, '.vitepress/data', 'releaseMetadata');
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import { getCurrentDirPath } from '@lucide/helpers';
|
||||
const currentDir = process.cwd();
|
||||
const scriptDir = getCurrentDirPath(import.meta.url);
|
||||
|
||||
const iconMetaData = await getIconMetaData(path.resolve(scriptDir, '../../icons'));
|
||||
const iconMetaData = await getIconMetaData(path.resolve(scriptDir, '../icons'));
|
||||
|
||||
const iconAliasesRedirectRoutes = Object.entries(iconMetaData)
|
||||
.filter(([, { aliases }]) => aliases?.length)
|
||||
@@ -16,7 +16,7 @@ const iconAliasesRedirectRoutes = Object.entries(iconMetaData)
|
||||
const aliasRouteMatches = aliases.join('|');
|
||||
|
||||
return {
|
||||
src: `/icons/${aliasRouteMatches}`,
|
||||
src: `/icons/(${aliasRouteMatches})`,
|
||||
status: 302,
|
||||
headers: {
|
||||
Location: `/icons/${iconName}`,
|
||||
@@ -44,4 +44,4 @@ const output = JSON.stringify(vercelRouteConfig, null, 2);
|
||||
|
||||
const vercelOutputJSON = path.resolve(currentDir, '.vercel/output/config.json');
|
||||
|
||||
await fs.promises.writeFile(vercelOutputJSON, output, 'utf-8');
|
||||
fs.writeFileSync(vercelOutputJSON, output, 'utf-8');
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"$schema": "../icon.schema.json",
|
||||
"contributors": [
|
||||
"jamiemlaw"
|
||||
],
|
||||
"tags": [
|
||||
"shape",
|
||||
"bullet",
|
||||
"gender",
|
||||
"genderless"
|
||||
],
|
||||
"categories": [
|
||||
"shapes",
|
||||
"medical"
|
||||
]
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<circle cx="12" cy="12" r="6" />
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 243 B |
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"$schema": "../icon.schema.json",
|
||||
"contributors": [
|
||||
"jamiemlaw"
|
||||
],
|
||||
"tags": [
|
||||
"gender",
|
||||
"androgyne",
|
||||
"transgender"
|
||||
],
|
||||
"categories": [
|
||||
"medical"
|
||||
]
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="m14 6 4 4" />
|
||||
<path d="M17 3h4v4" />
|
||||
<path d="m21 3-7.75 7.75" />
|
||||
<circle cx="9" cy="15" r="6" />
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 323 B |
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"$schema": "../icon.schema.json",
|
||||
"contributors": [
|
||||
"jguddas",
|
||||
"jamiemlaw"
|
||||
],
|
||||
"tags": [
|
||||
"gender",
|
||||
"sex",
|
||||
"male",
|
||||
"masculine",
|
||||
"man",
|
||||
"boy"
|
||||
],
|
||||
"categories": [
|
||||
"medical"
|
||||
]
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M16 3h5v5" />
|
||||
<path d="m21 3-6.75 6.75" />
|
||||
<circle cx="10" cy="14" r="6" />
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 299 B |
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"$schema": "../icon.schema.json",
|
||||
"contributors": [
|
||||
"jamiemlaw"
|
||||
],
|
||||
"tags": [
|
||||
"gender",
|
||||
"nonbinary",
|
||||
"enby"
|
||||
],
|
||||
"categories": [
|
||||
"medical"
|
||||
]
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M12 2v10" />
|
||||
<path d="m9 4 6 4" />
|
||||
<path d="m9 8 6-4" />
|
||||
<circle cx="12" cy="17" r="5" />
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 315 B |
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"$schema": "../icon.schema.json",
|
||||
"contributors": [
|
||||
"jamiemlaw"
|
||||
],
|
||||
"tags": [
|
||||
"gender",
|
||||
"inclusive"
|
||||
],
|
||||
"categories": [
|
||||
"medical",
|
||||
"accessibility"
|
||||
]
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M12 16v6" />
|
||||
<path d="M14 20h-4" />
|
||||
<path d="M18 2h4v4" />
|
||||
<path d="m2 2 7.17 7.17" />
|
||||
<path d="M2 5.355V2h3.357" />
|
||||
<path d="m22 2-7.17 7.17" />
|
||||
<path d="M8 5 5 8" />
|
||||
<circle cx="12" cy="12" r="4" />
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 434 B |
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"$schema": "../icon.schema.json",
|
||||
"contributors": [
|
||||
"jamiemlaw"
|
||||
],
|
||||
"tags": [
|
||||
"gender",
|
||||
"sex",
|
||||
"intersex",
|
||||
"androgynous",
|
||||
"hermaphrodite"
|
||||
],
|
||||
"categories": [
|
||||
"medical"
|
||||
]
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M10 20h4" />
|
||||
<path d="M12 16v6" />
|
||||
<path d="M17 2h4v4" />
|
||||
<path d="m21 2-5.46 5.46" />
|
||||
<circle cx="12" cy="11" r="5" />
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 347 B |
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"$schema": "../icon.schema.json",
|
||||
"contributors": [
|
||||
"jguddas",
|
||||
"jamiemlaw"
|
||||
],
|
||||
"tags": [
|
||||
"gender",
|
||||
"sex",
|
||||
"female",
|
||||
"feminine",
|
||||
"woman",
|
||||
"girl"
|
||||
],
|
||||
"categories": [
|
||||
"medical"
|
||||
]
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M12 15v7" />
|
||||
<path d="M9 19h6" />
|
||||
<circle cx="12" cy="9" r="6" />
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 289 B |
10
packages/icons/.npmignore
Normal file
@@ -0,0 +1,10 @@
|
||||
stats
|
||||
node_modules
|
||||
tests
|
||||
scripts
|
||||
build
|
||||
src
|
||||
babel.config.js
|
||||
jest.config.js
|
||||
rollup.config.js
|
||||
yarn.error.log
|
||||
46
packages/icons/package.json
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"name": "@lucide/icons",
|
||||
"description": "Lucide is a community-run fork of Feather Icons, open for anyone to contribute icons.",
|
||||
"version": "0.0.1",
|
||||
"license": "ISC",
|
||||
"homepage": "https://lucide.dev",
|
||||
"bugs": "https://github.com/lucide-icons/lucide/issues",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/lucide-icons/lucide.git"
|
||||
},
|
||||
"keywords": [
|
||||
"Lucide",
|
||||
"Feather",
|
||||
"Icons",
|
||||
"Icon",
|
||||
"SVG",
|
||||
"Feather Icons",
|
||||
"Fontawesome",
|
||||
"Font Awesome"
|
||||
],
|
||||
"source": "src/lucide-icons.js",
|
||||
"main": "dist/cjs/lucide-icons.js",
|
||||
"module": "dist/esm/lucide-icons.js",
|
||||
"typings": "dist/lucide-icons.d.ts",
|
||||
"sideEffects": false,
|
||||
"scripts": {
|
||||
"copy:license": "cp ../../LICENSE ./LICENSE",
|
||||
"build": "pnpm clean && pnpm copy:license && pnpm build:icons && pnpm build:bundles",
|
||||
"build:tags": "node ../../scripts/migrateIconsToTags.mjs",
|
||||
"build:icons": "build-icons --output=./src --templateSrc=./scripts/exportTemplate.mjs --iconFileExtension=.ts --withAliases --aliasNamesOnly --aliasesFileExtension=.ts --exportFileName=index.ts",
|
||||
"build:lib": "node ./scripts/buildLib.mjs",
|
||||
"build:bundles": "rollup -c rollup.config.mjs",
|
||||
"clean": "rm -rf lib && rm -rf build && rm -rf icons && rm -f sprite.svg",
|
||||
"version": "pnpm version --git-tag-version=false"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@lucide/build-icons": "workspace:*",
|
||||
"@lucide/helpers": "workspace:*",
|
||||
"@lucide/rollup-plugins": "workspace:*",
|
||||
"prettier": "^2.3.2",
|
||||
"rollup": "^4.22.4",
|
||||
"rollup-plugin-dts": "^6.1.0",
|
||||
"svgson": "^5.2.1"
|
||||
}
|
||||
}
|
||||
59
packages/icons/rollup.config.mjs
Normal file
@@ -0,0 +1,59 @@
|
||||
import plugins from '@lucide/rollup-plugins';
|
||||
import dts from 'rollup-plugin-dts';
|
||||
import pkg from './package.json' assert { type: 'json' };
|
||||
|
||||
const outputFileName = pkg.name;
|
||||
const outputDir = 'dist';
|
||||
const inputs = ['src/lucide-icons.ts'];
|
||||
const bundles = [
|
||||
{
|
||||
format: 'cjs',
|
||||
inputs,
|
||||
outputDir,
|
||||
},
|
||||
{
|
||||
format: 'esm',
|
||||
inputs,
|
||||
outputDir,
|
||||
preserveModules: true,
|
||||
},
|
||||
];
|
||||
|
||||
const configs = bundles
|
||||
.map(({ inputs, outputDir, format, minify, preserveModules }) =>
|
||||
inputs.map((input) => ({
|
||||
input,
|
||||
plugins: plugins({ pkg, minify }),
|
||||
output: {
|
||||
name: outputFileName,
|
||||
...(preserveModules
|
||||
? {
|
||||
dir: `${outputDir}/${format}`,
|
||||
}
|
||||
: {
|
||||
file: `${outputDir}/${format}/${outputFileName}${minify ? '.min' : ''}.js`,
|
||||
}),
|
||||
format,
|
||||
sourcemap: true,
|
||||
preserveModules,
|
||||
},
|
||||
})),
|
||||
)
|
||||
.flat();
|
||||
|
||||
const typesFileConfig = {
|
||||
input: inputs[0],
|
||||
output: [
|
||||
{
|
||||
file: `${outputDir}/${outputFileName}.d.ts`,
|
||||
format: 'esm',
|
||||
},
|
||||
],
|
||||
plugins: [
|
||||
dts({
|
||||
include: ['src'],
|
||||
}),
|
||||
],
|
||||
};
|
||||
|
||||
export default [...configs, typesFileConfig];
|
||||
25
packages/icons/scripts/exportTemplate.mjs
Normal file
@@ -0,0 +1,25 @@
|
||||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs';
|
||||
import { toCamelCase } from '@lucide/helpers';
|
||||
|
||||
export default ({ iconName, children, getSvg, deprecated, deprecationReason }) => {
|
||||
const svgContents = getSvg();
|
||||
const svgBase64 = base64SVG(svgContents);
|
||||
const exportName = toCamelCase(iconName)
|
||||
|
||||
return `
|
||||
import { IconNode } from '../types';
|
||||
/**
|
||||
* @name ${iconName}
|
||||
* @description Lucide SVG string.
|
||||
*
|
||||
* @preview  - https://lucide.dev/icons/${iconName}
|
||||
*
|
||||
* @returns {IconNode}
|
||||
* ${deprecated ? `@deprecated ${deprecationReason}` : ''}
|
||||
*/
|
||||
const _${exportName}: IconNode = ${JSON.stringify(children)}
|
||||
|
||||
export default _${exportName};
|
||||
`;
|
||||
};
|
||||
1
packages/icons/src/aliases/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './aliases';
|
||||
1
packages/icons/src/icons/.gitkeep
Normal file
@@ -0,0 +1 @@
|
||||
Folder for generated icons
|
||||
2
packages/icons/src/lucide-icons.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './icons';
|
||||
export * from './aliases';
|
||||
3
packages/icons/src/types.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export type SVGProps = Record<string, string | number>;
|
||||
export type IconNode = readonly [tag: string, attrs: SVGProps][];
|
||||
export type Icons = { [key: string]: IconNode };
|
||||
17
packages/icons/tsconfig.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"strict": true,
|
||||
"declaration": true,
|
||||
"noEmitOnError": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"moduleResolution": "node",
|
||||
"module": "ESNext",
|
||||
"target": "ESNext",
|
||||
"esModuleInterop": true,
|
||||
"allowJs": true,
|
||||
"lib": ["esnext", "dom"],
|
||||
"resolveJsonModule": true,
|
||||
"sourceMap": true,
|
||||
"outDir": "./dist",
|
||||
},
|
||||
}
|
||||
@@ -1,15 +1,8 @@
|
||||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs';
|
||||
|
||||
export default async ({
|
||||
componentName,
|
||||
iconName,
|
||||
children,
|
||||
getSvg,
|
||||
deprecated,
|
||||
deprecationReason,
|
||||
}) => {
|
||||
const svgContents = await getSvg();
|
||||
export default ({ componentName, iconName, children, getSvg, deprecated, deprecationReason }) => {
|
||||
const svgContents = getSvg();
|
||||
const svgBase64 = base64SVG(svgContents);
|
||||
|
||||
return `\
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
"rollup": "^4.22.4",
|
||||
"rollup-plugin-dts": "^6.1.0",
|
||||
"typescript": "^5.3.3",
|
||||
"vite": "5.4.13",
|
||||
"vite": "5.1.8",
|
||||
"vitest": "^1.1.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import plugins from '@lucide/rollup-plugins';
|
||||
import dts from 'rollup-plugin-dts';
|
||||
import pkg from './package.json' with { type: 'json' };
|
||||
import pkg from './package.json' assert { type: 'json' };
|
||||
|
||||
const packageName = 'LucidePreact';
|
||||
const outputFileName = 'lucide-preact';
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs';
|
||||
|
||||
export default async ({
|
||||
componentName,
|
||||
iconName,
|
||||
children,
|
||||
getSvg,
|
||||
deprecated,
|
||||
deprecationReason,
|
||||
}) => {
|
||||
const svgContents = await getSvg();
|
||||
export default ({ componentName, iconName, children, getSvg, deprecated, deprecationReason }) => {
|
||||
const svgContents = getSvg();
|
||||
const svgBase64 = base64SVG(svgContents);
|
||||
|
||||
return `
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
"rollup": "^4.22.4",
|
||||
"rollup-plugin-dts": "^6.1.0",
|
||||
"typescript": "^4.8.4",
|
||||
"vite": "5.4.13",
|
||||
"vite": "5.1.8",
|
||||
"vitest": "^1.1.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs';
|
||||
|
||||
export default async ({
|
||||
componentName,
|
||||
iconName,
|
||||
children,
|
||||
getSvg,
|
||||
deprecated,
|
||||
deprecationReason,
|
||||
}) => {
|
||||
const svgContents = await getSvg();
|
||||
export default ({ componentName, iconName, children, getSvg, deprecated, deprecationReason }) => {
|
||||
const svgContents = getSvg();
|
||||
const svgBase64 = base64SVG(svgContents);
|
||||
|
||||
return `
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
export { default } from './dist/esm/dynamicIconImports.js';
|
||||
@@ -23,25 +23,57 @@
|
||||
],
|
||||
"author": "Eric Fennis",
|
||||
"amdName": "lucide-react",
|
||||
"main": "dist/cjs/lucide-react.js",
|
||||
"main:umd": "dist/umd/lucide-react.js",
|
||||
"module": "dist/esm/lucide-react.js",
|
||||
"unpkg": "dist/umd/lucide-react.min.js",
|
||||
"typings": "dist/lucide-react.d.ts",
|
||||
"sideEffects": false,
|
||||
"source": "src/lucide-react.ts",
|
||||
"main": "dist/esm/lucide-react.js",
|
||||
"types": "dist/lucide-react.d.ts",
|
||||
"type": "module",
|
||||
"files": [
|
||||
"dist",
|
||||
"dynamic.mjs",
|
||||
"dynamic.js.map",
|
||||
"dynamic.d.ts",
|
||||
"dynamicIconImports.mjs",
|
||||
"dynamicIconImports.js.map",
|
||||
"dynamicIconImports.d.ts"
|
||||
"dist"
|
||||
],
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/lucide-react.d.ts",
|
||||
"import": "./dist/esm/lucide-react.js",
|
||||
"browser": "./dist/esm/lucide-react.js",
|
||||
"require": "./dist/cjs/lucide-react.js",
|
||||
"node": "./dist/cjs/lucide-react.js"
|
||||
},
|
||||
"./icons": {
|
||||
"types": "./dist/lucide-react.d.ts",
|
||||
"import": "./dist/esm/lucide-react.js",
|
||||
"browser": "./dist/esm/lucide-react.js",
|
||||
"require": "./dist/cjs/lucide-react.js",
|
||||
"node": "./dist/cjs/lucide-react.js"
|
||||
},
|
||||
"./icons/*": {
|
||||
"types": "./dist/icons/*.d.ts",
|
||||
"import": "./dist/esm/icons/*.js",
|
||||
"browser": "./dist/esm/icons/*.js",
|
||||
"require": "./dist/cjs/icons/*.js",
|
||||
"node": "./dist/cjs/icons/*.js"
|
||||
},
|
||||
"./dynamic": {
|
||||
"types": "./dist/dynamic.d.ts",
|
||||
"import": "./dist/esm/dynamic.js",
|
||||
"browser": "./dist/esm/dynamic.js",
|
||||
"require": "./dist/cjs/dynamic.js",
|
||||
"node": "./dist/cjs/dynamic.js"
|
||||
},
|
||||
"./dynamicIconImports": {
|
||||
"types": "./dist/dynamicIconImports.d.ts",
|
||||
"import": "./dist/esm/dynamicIconImports.js",
|
||||
"browser": "./dist/esm/dynamicIconImports.js",
|
||||
"require": "./dist/cjs/dynamicIconImports.js",
|
||||
"node": "./dist/cjs/dynamicIconImports.js"
|
||||
},
|
||||
"./src/*": "./src/*.ts",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"scripts": {
|
||||
"build": "pnpm clean && pnpm copy:license && pnpm build:icons && pnpm typecheck && pnpm build:bundles",
|
||||
"copy:license": "cp ../../LICENSE ./LICENSE",
|
||||
"clean": "rm -rf dist && rm -rf stats && rm -rf ./src/icons/*.ts && rm -f dynamic.* && rm -f dynamicIconImports.d.ts",
|
||||
"clean": "rm -rf dist && rm -rf stats && rm -rf ./src/icons/*.ts && rm -f dynamicIconImports.*",
|
||||
"build:icons": "build-icons --output=./src --templateSrc=./scripts/exportTemplate.mjs --renderUniqueKey --withAliases --withDynamicImports --separateAliasesFile --aliasesFileExtension=.ts --iconFileExtension=.ts --exportFileName=index.ts",
|
||||
"build:bundles": "rollup -c ./rollup.config.mjs",
|
||||
"typecheck": "tsc",
|
||||
@@ -65,7 +97,7 @@
|
||||
"rollup-plugin-dts": "^6.1.0",
|
||||
"rollup-plugin-preserve-directives": "^0.4.0",
|
||||
"typescript": "^4.9.5",
|
||||
"vite": "5.4.13",
|
||||
"vite": "5.1.8",
|
||||
"vitest": "^1.1.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
||||
@@ -8,40 +8,42 @@ const aliasesEntries = await getAliasesEntryNames();
|
||||
|
||||
const packageName = 'LucideReact';
|
||||
const outputFileName = 'lucide-react';
|
||||
const outputDir = `dist`;
|
||||
const inputs = [`src/lucide-react.ts`];
|
||||
const bundles = [
|
||||
{
|
||||
format: 'umd',
|
||||
inputs,
|
||||
outputDir: 'dist/umd',
|
||||
outputDir,
|
||||
minify: true,
|
||||
},
|
||||
{
|
||||
format: 'umd',
|
||||
inputs,
|
||||
outputDir: 'dist/umd',
|
||||
outputDir,
|
||||
},
|
||||
{
|
||||
format: 'cjs',
|
||||
inputs,
|
||||
outputDir: 'dist/cjs',
|
||||
outputDir,
|
||||
},
|
||||
{
|
||||
format: 'esm',
|
||||
inputs: [...inputs, , 'src/dynamicIconImports.ts', 'src/DynamicIcon.ts', ...aliasesEntries],
|
||||
outputDir: 'dist/esm',
|
||||
inputs: [...inputs, ...aliasesEntries],
|
||||
outputDir,
|
||||
preserveModules: true,
|
||||
},
|
||||
{
|
||||
format: 'esm',
|
||||
inputs: ['src/dynamic.ts'],
|
||||
outputFile: 'dynamic.mjs',
|
||||
inputs: ['src/dynamic.ts', 'src/dynamicIconImports.ts', 'src/DynamicIcon.ts'],
|
||||
outputDir,
|
||||
preserveModules: true,
|
||||
external: [/src/],
|
||||
paths: (id) => {
|
||||
if (id.match(/src/)) {
|
||||
const [, modulePath] = id.match(/src\/(.*)\.ts/);
|
||||
|
||||
return `dist/esm/${modulePath}.js`;
|
||||
return `${modulePath}.js`;
|
||||
}
|
||||
},
|
||||
},
|
||||
@@ -75,10 +77,12 @@ const configs = bundles
|
||||
name: packageName,
|
||||
...(preserveModules
|
||||
? {
|
||||
dir: outputDir,
|
||||
dir: `${outputDir}/${format}`,
|
||||
}
|
||||
: {
|
||||
file: outputFile ?? `${outputDir}/${outputFileName}${minify ? '.min' : ''}.js`,
|
||||
file:
|
||||
outputFile ??
|
||||
`${outputDir}/${format}/${outputFileName}${minify ? '.min' : ''}.js`,
|
||||
}),
|
||||
paths,
|
||||
entryFileNames,
|
||||
@@ -100,17 +104,31 @@ export default [
|
||||
input: 'src/dynamicIconImports.ts',
|
||||
output: [
|
||||
{
|
||||
file: `dynamicIconImports.d.ts`,
|
||||
file: `dist/dynamicIconImports.d.ts`,
|
||||
format: 'es',
|
||||
},
|
||||
],
|
||||
plugins: [
|
||||
dts({
|
||||
exclude: ['./src/icons'],
|
||||
}),
|
||||
],
|
||||
},
|
||||
{
|
||||
input: 'src/dynamic.ts',
|
||||
output: [
|
||||
{
|
||||
file: `dist/dynamic.d.ts`,
|
||||
format: 'es',
|
||||
},
|
||||
],
|
||||
plugins: [dts()],
|
||||
},
|
||||
{
|
||||
input: 'src/dynamic.ts',
|
||||
input: 'src/DynamicIcon.ts',
|
||||
output: [
|
||||
{
|
||||
file: `dynamic.d.ts`,
|
||||
file: `dist/DynamicIcon.d.ts`,
|
||||
format: 'es',
|
||||
},
|
||||
],
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs';
|
||||
|
||||
export default async ({
|
||||
componentName,
|
||||
iconName,
|
||||
children,
|
||||
getSvg,
|
||||
deprecated,
|
||||
deprecationReason,
|
||||
}) => {
|
||||
const svgContents = await getSvg();
|
||||
export default ({ componentName, iconName, children, getSvg, deprecated, deprecationReason }) => {
|
||||
const svgContents = getSvg();
|
||||
const svgBase64 = base64SVG(svgContents);
|
||||
|
||||
return `
|
||||
|
||||
@@ -83,10 +83,10 @@
|
||||
"rollup": "^4.22.4",
|
||||
"solid-js": "^1.8.7",
|
||||
"typescript": "^4.9.4",
|
||||
"vite": "5.4.13",
|
||||
"vite": "5.1.8",
|
||||
"vite-plugin-solid": "^2.10.1",
|
||||
"vitest": "^1.1.1",
|
||||
"esbuild": "^0.25.0"
|
||||
"esbuild": "^0.19.11"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"solid-js": "^1.4.7"
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs';
|
||||
|
||||
export default async ({
|
||||
componentName,
|
||||
iconName,
|
||||
children,
|
||||
getSvg,
|
||||
deprecated,
|
||||
deprecationReason,
|
||||
}) => {
|
||||
const svgContents = await getSvg();
|
||||
export default ({ componentName, iconName, children, getSvg, deprecated, deprecationReason }) => {
|
||||
const svgContents = getSvg();
|
||||
const svgBase64 = base64SVG(svgContents);
|
||||
|
||||
return `
|
||||
|
||||
@@ -30,8 +30,8 @@ const license = `@license ${pkg.name} v${pkg.version} - ${pkg.license}`;
|
||||
createDirectory(LIB_DIR);
|
||||
createDirectory(ICON_MODULE_DIR);
|
||||
|
||||
const svgFiles = await readSvgDirectory(ICONS_DIR);
|
||||
const svgs = await readSvgs(svgFiles, ICONS_DIR);
|
||||
const svgFiles = readSvgDirectory(ICONS_DIR);
|
||||
const svgs = readSvgs(svgFiles, ICONS_DIR);
|
||||
|
||||
const parsedSvgs = svgs.map(({ name, contents }) => ({
|
||||
name,
|
||||
@@ -39,8 +39,6 @@ const parsedSvgs = svgs.map(({ name, contents }) => ({
|
||||
parsedSvg: parseSync(contents),
|
||||
}));
|
||||
|
||||
await Promise.all([
|
||||
generateSprite(parsedSvgs, PACKAGE_DIR, license),
|
||||
generateIconNodes(parsedSvgs, PACKAGE_DIR),
|
||||
copyIcons(parsedSvgs, PACKAGE_DIR, license),
|
||||
]);
|
||||
generateSprite(parsedSvgs, PACKAGE_DIR, license);
|
||||
generateIconNodes(parsedSvgs, PACKAGE_DIR);
|
||||
copyIcons(parsedSvgs, PACKAGE_DIR, license);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs';
|
||||
|
||||
export default async ({ componentName, iconName, getSvg, deprecated, deprecationReason }) => {
|
||||
let svgContents = await getSvg();
|
||||
export default ({ componentName, iconName, children, getSvg, deprecated, deprecationReason }) => {
|
||||
let svgContents = getSvg();
|
||||
const svgBase64 = base64SVG(svgContents);
|
||||
|
||||
svgContents = svgContents.replace(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { writeFile } from '@lucide/helpers';
|
||||
|
||||
export default async function generateIconNodes(parsedSvgs, packageDir) {
|
||||
export default function generateIconNodes(parsedSvgs, packageDir) {
|
||||
const iconNodes = parsedSvgs.reduce((acc, { name, parsedSvg }) => {
|
||||
acc[name] = parsedSvg.children.map(({ name, attributes }) => [name, attributes]);
|
||||
|
||||
@@ -9,5 +9,5 @@ export default async function generateIconNodes(parsedSvgs, packageDir) {
|
||||
|
||||
const iconNodesStringified = JSON.stringify(iconNodes, null, 2);
|
||||
|
||||
await writeFile(iconNodesStringified, 'icon-nodes.json', packageDir);
|
||||
writeFile(iconNodesStringified, 'icon-nodes.json', packageDir);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { stringify } from 'svgson';
|
||||
import { format } from 'prettier';
|
||||
import { appendFile } from '@lucide/helpers';
|
||||
|
||||
export default async function generateSprite(svgs, packageDir, license) {
|
||||
export default function generateSprite(svgs, packageDir, license) {
|
||||
const symbols = svgs.map(({ name, parsedSvg }) => ({
|
||||
name: 'symbol',
|
||||
type: 'element',
|
||||
@@ -34,6 +34,6 @@ export default async function generateSprite(svgs, packageDir, license) {
|
||||
|
||||
const xmlMeta = `<?xml version="1.0" encoding="utf-8"?>\n<!-- ${license} -->\n`;
|
||||
|
||||
await appendFile(xmlMeta, `sprite.svg`, packageDir);
|
||||
await appendFile(prettifiedSprite, `sprite.svg`, packageDir);
|
||||
appendFile(xmlMeta, `sprite.svg`, packageDir);
|
||||
appendFile(prettifiedSprite, `sprite.svg`, packageDir);
|
||||
}
|
||||
|
||||
@@ -9,12 +9,10 @@ import { readSvg } from '@lucide/helpers';
|
||||
* @returns {Object}
|
||||
*/
|
||||
export default function readSVGs(svgFiles, iconsDirectory) {
|
||||
const SVGReadPromises = svgFiles.map(async (svgFile) => {
|
||||
return svgFiles.map((svgFile) => {
|
||||
const name = basename(svgFile, '.svg');
|
||||
const contents = await readSvg(svgFile, iconsDirectory);
|
||||
const contents = readSvg(svgFile, iconsDirectory);
|
||||
|
||||
return { name, contents };
|
||||
});
|
||||
|
||||
return Promise.all(SVGReadPromises);
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
"svelte-check": "^3.4.4",
|
||||
"svelte-preprocess": "^5.0.4",
|
||||
"typescript": "^5.1.6",
|
||||
"vite": "5.4.13",
|
||||
"vite": "5.1.8",
|
||||
"vitest": "^1.1.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
||||
@@ -4,7 +4,7 @@ import path from 'path';
|
||||
import { getCurrentDirPath } from '@lucide/helpers';
|
||||
import { getJSBanner } from './license.mjs';
|
||||
|
||||
const currentDir = await getCurrentDirPath(import.meta.url);
|
||||
const currentDir = getCurrentDirPath(import.meta.url);
|
||||
const targetDirectory = path.join(currentDir, '../dist');
|
||||
|
||||
const files = await readdir(targetDirectory, {
|
||||
|
||||
@@ -2,15 +2,8 @@
|
||||
import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs';
|
||||
import { getJSBanner } from './license.mjs';
|
||||
|
||||
export default async ({
|
||||
iconName,
|
||||
children,
|
||||
componentName,
|
||||
getSvg,
|
||||
deprecated,
|
||||
deprecationReason,
|
||||
}) => {
|
||||
const svgContents = await getSvg();
|
||||
export default ({ iconName, children, componentName, getSvg, deprecated, deprecationReason }) => {
|
||||
const svgContents = getSvg();
|
||||
const svgBase64 = base64SVG(svgContents);
|
||||
|
||||
return `\
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
"@vue/test-utils": "2.4.5",
|
||||
"rollup": "^4.22.4",
|
||||
"rollup-plugin-dts": "^6.1.0",
|
||||
"vite": "5.4.13",
|
||||
"vite": "5.1.8",
|
||||
"vitest": "^1.4.0",
|
||||
"vue": "^3.4.21"
|
||||
},
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs';
|
||||
|
||||
export default async ({
|
||||
componentName,
|
||||
iconName,
|
||||
children,
|
||||
getSvg,
|
||||
deprecated,
|
||||
deprecationReason,
|
||||
}) => {
|
||||
const svgContents = await getSvg();
|
||||
export default ({ componentName, iconName, children, getSvg, deprecated, deprecationReason }) => {
|
||||
const svgContents = getSvg();
|
||||
const svgBase64 = base64SVG(svgContents);
|
||||
|
||||
return `
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
"@vue/test-utils": "1.3.0",
|
||||
"rollup": "^3.29.5",
|
||||
"typescript": "^4.9.5",
|
||||
"vite": "5.4.13",
|
||||
"vite": "5.1.8",
|
||||
"vitest": "^0.32.2",
|
||||
"vue": "2.7.14",
|
||||
"vue-template-compiler": "2.7.14"
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs';
|
||||
|
||||
export default async ({
|
||||
componentName,
|
||||
iconName,
|
||||
children,
|
||||
getSvg,
|
||||
deprecated,
|
||||
deprecationReason,
|
||||
}) => {
|
||||
const svgContents = await getSvg();
|
||||
export default ({ componentName, iconName, children, getSvg, deprecated, deprecationReason }) => {
|
||||
const svgContents = getSvg();
|
||||
const svgBase64 = base64SVG(svgContents);
|
||||
|
||||
return `
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
"build:icons": "build-icons --output=./src --templateSrc=./scripts/exportTemplate.mjs --iconFileExtension=.ts --withAliases --aliasNamesOnly --aliasesFileExtension=.ts --exportFileName=index.ts",
|
||||
"build:bundle": "rollup -c rollup.config.mjs",
|
||||
"test": "pnpm build:icons && vitest run",
|
||||
"test:watch": "vitest watch",
|
||||
"version": "pnpm version --git-tag-version=false"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -51,7 +50,7 @@
|
||||
"rollup": "^4.22.4",
|
||||
"rollup-plugin-dts": "^6.1.0",
|
||||
"typescript": "^4.9.3",
|
||||
"vite": "5.4.13",
|
||||
"vite": "5.1.8",
|
||||
"vitest": "^1.1.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs';
|
||||
|
||||
export default async ({
|
||||
componentName,
|
||||
iconName,
|
||||
children,
|
||||
getSvg,
|
||||
deprecated,
|
||||
deprecationReason,
|
||||
}) => {
|
||||
const svgContents = await getSvg();
|
||||
export default ({ componentName, iconName, children, getSvg, deprecated, deprecationReason }) => {
|
||||
const svgContents = getSvg();
|
||||
const svgBase64 = base64SVG(svgContents);
|
||||
|
||||
return `
|
||||
@@ -26,7 +19,11 @@ import type { IconNode } from '../types';
|
||||
* @returns {Array}
|
||||
* ${deprecated ? `@deprecated ${deprecationReason}` : ''}
|
||||
*/
|
||||
const ${componentName}: IconNode = ${JSON.stringify(children)}
|
||||
const ${componentName}: IconNode = [
|
||||
'svg',
|
||||
defaultAttributes,
|
||||
${JSON.stringify(children)}
|
||||
];
|
||||
|
||||
export default ${componentName};
|
||||
`;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { IconNode, SVGProps } from './types';
|
||||
|
||||
type CreateElementParams = [tag: string, attrs: SVGProps, children?: IconNode];
|
||||
import { IconNode, IconNodeChild, SVGProps } from './types';
|
||||
|
||||
/**
|
||||
* Creates a new HTMLElement from icon node
|
||||
@@ -9,16 +7,16 @@ type CreateElementParams = [tag: string, attrs: SVGProps, children?: IconNode];
|
||||
* @param {array} children
|
||||
* @returns {HTMLElement}
|
||||
*/
|
||||
const createElement = ([tag, attrs, children]: CreateElementParams) => {
|
||||
const createElement = (tag: string, attrs: SVGProps, children: IconNodeChild[] = []) => {
|
||||
const element = document.createElementNS('http://www.w3.org/2000/svg', tag);
|
||||
|
||||
Object.keys(attrs).forEach((name) => {
|
||||
element.setAttribute(name, String(attrs[name]));
|
||||
});
|
||||
|
||||
if (children?.length) {
|
||||
if (children.length) {
|
||||
children.forEach((child) => {
|
||||
const childElement = createElement(child);
|
||||
const childElement = createElement(...child);
|
||||
|
||||
element.appendChild(childElement);
|
||||
});
|
||||
@@ -27,4 +25,9 @@ const createElement = ([tag, attrs, children]: CreateElementParams) => {
|
||||
return element;
|
||||
};
|
||||
|
||||
export default createElement;
|
||||
/**
|
||||
* Creates a new HTMLElement from icon node
|
||||
* @param {[tag: string, attrs: object, children: array]} iconNode
|
||||
* @returns {HTMLElement}
|
||||
*/
|
||||
export default ([tag, attrs, children]: IconNode) => createElement(tag, attrs, children);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import createElement from './createElement';
|
||||
import defaultAttributes from './defaultAttributes';
|
||||
import { Icons } from './types';
|
||||
|
||||
export type CustomAttrs = { [attr: string]: any };
|
||||
@@ -20,9 +19,7 @@ export const getAttrs = (element: Element): Record<string, string> =>
|
||||
* @param {Object} attrs
|
||||
* @returns {Array}
|
||||
*/
|
||||
export const getClassNames = (
|
||||
attrs: Record<string, string | string[]> | string,
|
||||
): string | string[] => {
|
||||
export const getClassNames = (attrs: Record<string, string> | string): string | string[] => {
|
||||
if (typeof attrs === 'string') return attrs;
|
||||
if (!attrs || !attrs.class) return '';
|
||||
if (attrs.class && typeof attrs.class === 'string') {
|
||||
@@ -39,9 +36,7 @@ export const getClassNames = (
|
||||
* @param {array} arrayOfClassnames
|
||||
* @returns {string}
|
||||
*/
|
||||
export const combineClassNames = (
|
||||
arrayOfClassnames: (string | Record<string, string | string[]>)[],
|
||||
) => {
|
||||
export const combineClassNames = (arrayOfClassnames: (string | Record<string, string>)[]) => {
|
||||
const classNameArray = arrayOfClassnames.flatMap(getClassNames);
|
||||
|
||||
return classNameArray
|
||||
@@ -82,9 +77,10 @@ const replaceElement = (element: Element, { nameAttr, icons, attrs }: ReplaceEle
|
||||
}
|
||||
|
||||
const elementAttrs = getAttrs(element);
|
||||
const [tag, iconAttributes, children] = iconNode;
|
||||
|
||||
const iconAttrs = {
|
||||
...defaultAttributes,
|
||||
...iconAttributes,
|
||||
'data-lucide': iconName,
|
||||
...attrs,
|
||||
...elementAttrs,
|
||||
@@ -98,7 +94,7 @@ const replaceElement = (element: Element, { nameAttr, icons, attrs }: ReplaceEle
|
||||
});
|
||||
}
|
||||
|
||||
const svgElement = createElement(['svg', iconAttrs, iconNode]);
|
||||
const svgElement = createElement([tag, iconAttrs, children]);
|
||||
|
||||
return element.parentNode?.replaceChild(svgElement, element);
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// className is not supported in svg elements
|
||||
export type SVGProps = Record<string, string | number>;
|
||||
|
||||
export type IconNode = [tag: string, attrs: SVGProps][];
|
||||
export type IconNodeChild = readonly [tag: string, attrs: SVGProps];
|
||||
export type IconNode = readonly [tag: string, attrs: SVGProps, children?: IconNodeChild[]];
|
||||
export type Icons = { [key: string]: IconNode };
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`combineClassNames > should retuns a string of classNames 1`] = `"item item1 item2 item3 item4 item5 item6 item7 item8 item9"`;
|
||||
@@ -1,3 +0,0 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`combineClassNames > should returns a string of classNames 1`] = `"item item1 item2 item3 item4 item5 item6 item7 item8 item9"`;
|
||||
@@ -6,7 +6,7 @@ import { parseSync, stringify } from 'svgson';
|
||||
|
||||
const ICONS_DIR = path.resolve(__dirname, '../../../icons');
|
||||
|
||||
const getOriginalSvg = (iconName: string, aliasName?: string) => {
|
||||
const getOriginalSvg = (iconName, aliasName) => {
|
||||
const svgContent = fs.readFileSync(path.join(ICONS_DIR, `${iconName}.svg`), 'utf8');
|
||||
const svgParsed = parseSync(svgContent);
|
||||
|
||||
@@ -51,17 +51,14 @@ describe('createIcons', () => {
|
||||
|
||||
createIcons({ icons, attrs });
|
||||
|
||||
const element = document.querySelector('svg') as SVGSVGElement;
|
||||
const element = document.querySelector('svg');
|
||||
const attributes = element.getAttributeNames();
|
||||
|
||||
const attributesAndValues = attributes.reduce(
|
||||
(acc, item) => {
|
||||
acc[item] = element.getAttribute(item);
|
||||
const attributesAndValues = attributes.reduce((acc, item) => {
|
||||
acc[item] = element.getAttribute(item);
|
||||
|
||||
return acc;
|
||||
},
|
||||
{} as Record<string, string | null>,
|
||||
);
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
expect(document.body.innerHTML).toMatchSnapshot();
|
||||
|
||||
@@ -77,17 +74,14 @@ describe('createIcons', () => {
|
||||
|
||||
createIcons({ icons });
|
||||
|
||||
const element = document.querySelector('svg') as SVGSVGElement;
|
||||
const element = document.querySelector('svg');
|
||||
const attributes = element.getAttributeNames();
|
||||
|
||||
const attributesAndValues = attributes.reduce(
|
||||
(acc, item) => {
|
||||
acc[item] = element.getAttribute(item);
|
||||
const attributesAndValues = attributes.reduce((acc, item) => {
|
||||
acc[item] = element.getAttribute(item);
|
||||
|
||||
return acc;
|
||||
},
|
||||
{} as Record<string, string | null>,
|
||||
);
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
expect(attributesAndValues).toEqual(expect.objectContaining(attrs));
|
||||
});
|
||||
@@ -16,7 +16,7 @@ describe('getAtts', () => {
|
||||
],
|
||||
};
|
||||
|
||||
const attrs = getAttrs(element as unknown as Element);
|
||||
const attrs = getAttrs(element);
|
||||
|
||||
expect(attrs.class).toBe(element.attributes[0].value);
|
||||
});
|
||||
@@ -43,8 +43,8 @@ describe('getClassNames', () => {
|
||||
});
|
||||
|
||||
describe('combineClassNames', () => {
|
||||
it('should returns a string of classNames', () => {
|
||||
const arrayOfClassnames: (string | Record<string, string[]>)[] = [
|
||||
it('should retuns a string of classNames', () => {
|
||||
const arrayOfClassnames = [
|
||||
'item',
|
||||
{
|
||||
class: ['item1', 'item2', 'item3'],
|
||||
1221
pnpm-lock.yaml
generated
@@ -7,13 +7,13 @@ import {
|
||||
|
||||
const currentDir = getCurrentDirPath(import.meta.url);
|
||||
const ICONS_DIR = path.resolve(currentDir, '../icons');
|
||||
const icons = await readAllMetadata(ICONS_DIR);
|
||||
const icons = readAllMetadata(ICONS_DIR);
|
||||
const CATEGORIES_DIR = path.resolve(currentDir, '../categories');
|
||||
const categories = await readAllMetadata(CATEGORIES_DIR);
|
||||
const categories = readAllMetadata(CATEGORIES_DIR);
|
||||
|
||||
console.log('Reading all icons');
|
||||
|
||||
const svgFiles = await readSvgDirectory(ICONS_DIR);
|
||||
const svgFiles = readSvgDirectory(ICONS_DIR);
|
||||
const iconNames = svgFiles.map((icon) => icon.split('.')[0]);
|
||||
|
||||
let error = false;
|
||||
|
||||
@@ -3,6 +3,7 @@ import path from 'path';
|
||||
import { parseSync } from 'svgson';
|
||||
import {
|
||||
shuffleArray,
|
||||
readSvgDirectory,
|
||||
getCurrentDirPath,
|
||||
minifySvg,
|
||||
toPascalCase,
|
||||
@@ -42,7 +43,7 @@ const getImageTagsByFiles = (files, getBaseUrl, width) =>
|
||||
return `<img title="${file}" alt="${file}" ${widthAttr} src="${url}/${base64}.svg"/>`;
|
||||
});
|
||||
|
||||
const svgFiles = fs.readdirSync(ICONS_DIR).map((file) => `icons/${file}`);
|
||||
const svgFiles = readSvgDirectory(ICONS_DIR).map((file) => `icons/${file}`);
|
||||
|
||||
const iconsFilteredByName = (search) => svgFiles.filter((file) => file.includes(search));
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import path from 'path';
|
||||
import categories from '../categories.json' with { type: 'json' };
|
||||
import categories from '../categories.json' assert { type: 'json' };
|
||||
import {
|
||||
mergeArrays,
|
||||
writeFile,
|
||||
|
||||
@@ -3,7 +3,7 @@ import { writeFile, getCurrentDirPath, readAllMetadata } from '../tools/build-he
|
||||
|
||||
const currentDir = getCurrentDirPath(import.meta.url);
|
||||
const ICONS_DIR = path.resolve(currentDir, '../icons');
|
||||
const icons = await readAllMetadata(ICONS_DIR);
|
||||
const icons = readAllMetadata(ICONS_DIR);
|
||||
|
||||
const tags = Object.keys(icons)
|
||||
.sort()
|
||||
@@ -14,4 +14,4 @@ const tags = Object.keys(icons)
|
||||
|
||||
const tagsContent = JSON.stringify(tags, null, 2);
|
||||
|
||||
await writeFile(tagsContent, 'tags.json', path.resolve(process.cwd()));
|
||||
writeFile(tagsContent, 'tags.json', path.resolve(process.cwd()));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
import fs from 'fs/promises';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
/**
|
||||
@@ -10,4 +10,4 @@ import path from 'path';
|
||||
* @param {string} outputDirectory
|
||||
*/
|
||||
export const appendFile = (content, fileName, outputDirectory) =>
|
||||
fs.appendFile(path.join(outputDirectory, fileName), content, 'utf-8');
|
||||
fs.appendFileSync(path.join(outputDirectory, fileName), content, 'utf-8');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
import fs from 'fs/promises';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { readMetadata } from './readMetadata.mjs';
|
||||
|
||||
@@ -9,14 +9,11 @@ import { readMetadata } from './readMetadata.mjs';
|
||||
* @param {string} directory
|
||||
* @returns {object} A map of icon or category metadata
|
||||
*/
|
||||
export const readAllMetadata = async (directory) => {
|
||||
const directoryContent = await fs.readdir(directory);
|
||||
|
||||
const metaDataPromises = directoryContent
|
||||
export const readAllMetadata = (directory) =>
|
||||
fs
|
||||
.readdirSync(directory)
|
||||
.filter((file) => path.extname(file) === '.json')
|
||||
.map(async (file) => [path.basename(file, '.json'), await readMetadata(file, directory)]);
|
||||
|
||||
const metadata = await Promise.all(metaDataPromises);
|
||||
|
||||
return Object.fromEntries(metadata);
|
||||
};
|
||||
.reduce((acc, fileName) => {
|
||||
acc[path.basename(fileName, '.json')] = readMetadata(fileName, directory);
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
import fs from 'fs/promises';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
/**
|
||||
@@ -8,4 +8,4 @@ import path from 'path';
|
||||
* @param {string} path
|
||||
* @returns {string} The contents of a file
|
||||
*/
|
||||
export const readFile = (path) => fs.readFile(path.resolve(__dirname, '../', path), 'utf-8');
|
||||
export const readFile = (path) => fs.readFileSync(path.resolve(__dirname, '../', path), 'utf-8');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
import fs from 'fs/promises';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
/**
|
||||
@@ -9,8 +9,5 @@ import path from 'path';
|
||||
* @param {string} directory
|
||||
* @returns {object} The metadata for the icon or category
|
||||
*/
|
||||
export const readMetadata = async (fileName, directory) => {
|
||||
const metadataFileContent = await fs.readFile(path.join(directory, fileName), 'utf-8');
|
||||
|
||||
return JSON.parse(metadataFileContent);
|
||||
};
|
||||
export const readMetadata = (fileName, directory) =>
|
||||
JSON.parse(fs.readFileSync(path.join(directory, fileName), 'utf-8'));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
import fs from 'fs/promises';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
/**
|
||||
@@ -9,4 +9,4 @@ import path from 'path';
|
||||
* @param {string} directory
|
||||
*/
|
||||
export const readSvg = (fileName, directory) =>
|
||||
fs.readFile(path.join(directory, fileName), 'utf-8');
|
||||
fs.readFileSync(path.join(directory, fileName), 'utf-8');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
import fs from 'fs/promises';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
/**
|
||||
@@ -9,8 +9,5 @@ import path from 'path';
|
||||
* @param {string} fileExtension
|
||||
* @returns {array} An array of file paths containing svgs
|
||||
*/
|
||||
export const readSvgDirectory = async (directory, fileExtension = '.svg') => {
|
||||
const directoryContents = await fs.readdir(directory);
|
||||
|
||||
return directoryContents.filter((file) => path.extname(file) === fileExtension);
|
||||
};
|
||||
export const readSvgDirectory = (directory, fileExtension = '.svg') =>
|
||||
fs.readdirSync(directory).filter((file) => path.extname(file) === fileExtension);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
import fs from 'fs/promises';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
/**
|
||||
@@ -9,4 +9,4 @@ import path from 'path';
|
||||
* @param {string} outputDirectory
|
||||
*/
|
||||
export const resetFile = (fileName, outputDirectory) =>
|
||||
fs.writeFile(path.join(outputDirectory, fileName), '', 'utf-8');
|
||||
fs.writeFileSync(path.join(outputDirectory, fileName), '', 'utf-8');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
import fs from 'fs/promises';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
/**
|
||||
@@ -10,4 +10,4 @@ import path from 'path';
|
||||
* @param {string} outputDirectory
|
||||
*/
|
||||
export const writeFile = (content, fileName, outputDirectory) =>
|
||||
fs.writeFile(path.join(outputDirectory, fileName), content, 'utf-8');
|
||||
fs.writeFileSync(path.join(outputDirectory, fileName), content, 'utf-8');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
import fs from 'fs/promises';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { writeFile } from './writeFile.mjs';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
import fs from 'fs/promises';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
/**
|
||||
@@ -10,4 +10,4 @@ import path from 'path';
|
||||
* @param {string} content
|
||||
*/
|
||||
export const writeSvgFile = (fileName, outputDirectory, content) =>
|
||||
fs.writeFile(path.join(outputDirectory, fileName), content, 'utf-8');
|
||||
fs.writeFileSync(path.join(outputDirectory, fileName), content, 'utf-8');
|
||||
|
||||
@@ -31,11 +31,11 @@ export default async function generateAliasesFiles({
|
||||
}
|
||||
|
||||
// Reset files
|
||||
await resetFile(aliasFileName, destinationDirectory);
|
||||
resetFile(aliasFileName, destinationDirectory);
|
||||
|
||||
if (!aliasNamesOnly) {
|
||||
await resetFile(aliasPrefixesFileName, destinationDirectory);
|
||||
await resetFile(aliasSuffixFileName, destinationDirectory);
|
||||
resetFile(aliasPrefixesFileName, destinationDirectory);
|
||||
resetFile(aliasSuffixFileName, destinationDirectory);
|
||||
}
|
||||
|
||||
// Generate Import for Icon VNodes
|
||||
@@ -149,20 +149,20 @@ export default async function generateAliasesFiles({
|
||||
);
|
||||
}
|
||||
|
||||
await appendFile(aliasFileContent, aliasFileName, destinationDirectory);
|
||||
appendFile(aliasFileContent, aliasFileName, destinationDirectory);
|
||||
|
||||
if (!aliasNamesOnly) {
|
||||
await appendFile(aliasPrefixesFileContent, aliasPrefixesFileName, destinationDirectory);
|
||||
await appendFile(aliasSuffixFileContent, aliasSuffixFileName, destinationDirectory);
|
||||
appendFile(aliasPrefixesFileContent, aliasPrefixesFileName, destinationDirectory);
|
||||
appendFile(aliasSuffixFileContent, aliasSuffixFileName, destinationDirectory);
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
await appendFile('\n', aliasFileName, destinationDirectory);
|
||||
appendFile('\n', aliasFileName, destinationDirectory);
|
||||
|
||||
if (!aliasNamesOnly) {
|
||||
await appendFile('\n', aliasPrefixesFileName, destinationDirectory);
|
||||
await appendFile('\n', aliasSuffixFileName, destinationDirectory);
|
||||
appendFile('\n', aliasPrefixesFileName, destinationDirectory);
|
||||
appendFile('\n', aliasSuffixFileName, destinationDirectory);
|
||||
}
|
||||
|
||||
if (showLog) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import path from 'path';
|
||||
import { resetFile, appendFile } from '@lucide/helpers';
|
||||
|
||||
export default async function generateDynamicImports({
|
||||
export default function generateDynamicImports({
|
||||
iconNodes,
|
||||
outputDirectory,
|
||||
fileExtension,
|
||||
@@ -12,7 +12,7 @@ export default async function generateDynamicImports({
|
||||
const icons = Object.keys(iconNodes);
|
||||
|
||||
// Reset file
|
||||
await resetFile(fileName, outputDirectory);
|
||||
resetFile(fileName, outputDirectory);
|
||||
|
||||
let importString = `const dynamicIconImports = {\n`;
|
||||
|
||||
@@ -40,7 +40,7 @@ export default async function generateDynamicImports({
|
||||
|
||||
importString += '};\nexport default dynamicIconImports;\n';
|
||||
|
||||
await appendFile(importString, fileName, outputDirectory);
|
||||
appendFile(importString, fileName, outputDirectory);
|
||||
|
||||
if (showLog) {
|
||||
console.log(`Successfully generated ${fileName} file`);
|
||||
|
||||
@@ -3,22 +3,22 @@ import path from 'path';
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
import { toPascalCase, toCamelCase, resetFile, appendFile } from '@lucide/helpers';
|
||||
|
||||
export default async function generateExportFile(
|
||||
export default (
|
||||
inputEntry,
|
||||
outputDirectory,
|
||||
iconNodes,
|
||||
exportModuleNameCasing,
|
||||
iconFileExtension = '',
|
||||
) {
|
||||
) => {
|
||||
const fileName = path.basename(inputEntry);
|
||||
|
||||
// Reset file
|
||||
await resetFile(fileName, outputDirectory);
|
||||
resetFile(fileName, outputDirectory);
|
||||
|
||||
const icons = Object.keys(iconNodes);
|
||||
|
||||
// Generate Import for Icon VNodes
|
||||
const iconImportNodesPromises = icons.map(async (iconName) => {
|
||||
icons.forEach((iconName) => {
|
||||
let componentName;
|
||||
|
||||
if (exportModuleNameCasing === 'camel') {
|
||||
@@ -27,12 +27,10 @@ export default async function generateExportFile(
|
||||
componentName = toPascalCase(iconName);
|
||||
}
|
||||
const importString = `export { default as ${componentName} } from './${iconName}${iconFileExtension}';\n`;
|
||||
return appendFile(importString, fileName, outputDirectory);
|
||||
appendFile(importString, fileName, outputDirectory);
|
||||
});
|
||||
|
||||
await Promise.all(iconImportNodesPromises);
|
||||
|
||||
await appendFile('\n', fileName, outputDirectory);
|
||||
appendFile('\n', fileName, outputDirectory);
|
||||
|
||||
console.log(`Successfully generated ${fileName} file`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -4,7 +4,7 @@ import prettier from 'prettier';
|
||||
import { readSvg, toPascalCase } from '@lucide/helpers';
|
||||
import deprecationReasonTemplate from '../utils/deprecationReasonTemplate.mjs';
|
||||
|
||||
function generateIconFiles({
|
||||
export default ({
|
||||
iconNodes,
|
||||
outputDirectory,
|
||||
template,
|
||||
@@ -15,7 +15,7 @@ function generateIconFiles({
|
||||
pretty = true,
|
||||
iconsDir,
|
||||
iconMetaData,
|
||||
}) {
|
||||
}) => {
|
||||
const icons = Object.keys(iconNodes);
|
||||
const iconsDistDirectory = path.join(outputDirectory, `icons`);
|
||||
|
||||
@@ -40,7 +40,7 @@ function generateIconFiles({
|
||||
})
|
||||
: '';
|
||||
|
||||
const elementTemplate = await template({
|
||||
const elementTemplate = template({
|
||||
componentName,
|
||||
iconName,
|
||||
children,
|
||||
@@ -71,7 +71,7 @@ function generateIconFiles({
|
||||
}
|
||||
});
|
||||
|
||||
return Promise.all(writeIconFiles)
|
||||
Promise.all(writeIconFiles)
|
||||
.then(() => {
|
||||
if (showLog) {
|
||||
console.log('Successfully built', icons.length, 'icons.');
|
||||
@@ -80,6 +80,4 @@ function generateIconFiles({
|
||||
.catch((error) => {
|
||||
throw new Error(`Something went wrong generating icon files,\n ${error}`);
|
||||
});
|
||||
}
|
||||
|
||||
export default generateIconFiles;
|
||||
};
|
||||
|
||||
@@ -47,16 +47,16 @@ async function buildIcons() {
|
||||
throw new Error('No `templateSrc` argument given.');
|
||||
}
|
||||
|
||||
const svgFiles = await readSvgDirectory(ICONS_DIR);
|
||||
const svgFiles = readSvgDirectory(ICONS_DIR);
|
||||
|
||||
const icons = await renderIconsObject(svgFiles, ICONS_DIR, renderUniqueKey);
|
||||
const icons = renderIconsObject(svgFiles, ICONS_DIR, renderUniqueKey);
|
||||
|
||||
const { default: iconFileTemplate } = await import(path.resolve(process.cwd(), templateSrc));
|
||||
|
||||
const iconMetaData = await getIconMetaData(ICONS_DIR);
|
||||
|
||||
// Generates iconsNodes files for each icon
|
||||
await generateIconFiles({
|
||||
generateIconFiles({
|
||||
iconNodes: icons,
|
||||
outputDirectory: OUTPUT_DIR,
|
||||
template: iconFileTemplate,
|
||||
@@ -86,7 +86,7 @@ async function buildIcons() {
|
||||
}
|
||||
|
||||
if (withDynamicImports) {
|
||||
await generateDynamicImports({
|
||||
generateDynamicImports({
|
||||
iconNodes: icons,
|
||||
outputDirectory: OUTPUT_DIR,
|
||||
fileExtension: aliasesFileExtension,
|
||||
@@ -96,7 +96,7 @@ async function buildIcons() {
|
||||
}
|
||||
|
||||
// Generates entry files for the compiler filled with icons exports
|
||||
await generateExportsFile(
|
||||
generateExportsFile(
|
||||
path.join(OUTPUT_DIR, 'icons', exportFileName),
|
||||
path.join(OUTPUT_DIR, 'icons'),
|
||||
icons,
|
||||
|
||||
@@ -20,13 +20,11 @@
|
||||
"@lucide/helpers": "workspace:*"
|
||||
},
|
||||
"dependencies": {
|
||||
"@lucide/helpers": "^1.0.0",
|
||||
"minimist": "^1.2.7",
|
||||
"node-fetch": "^3.2.10",
|
||||
"prettier": "2.7.1",
|
||||
"svgo": "^3.0.0",
|
||||
"svgson": "^5.2.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@lucide/helpers": "*"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,39 +8,32 @@ import { generateHashedKey, readSvg, hasDuplicatedChildren } from '@lucide/helpe
|
||||
* @param {Function} getSvg - A function that returns the contents of an SVG file given a filename.
|
||||
* @returns {Object}
|
||||
*/
|
||||
export default async function generateIconObject(
|
||||
svgFiles,
|
||||
iconsDirectory,
|
||||
renderUniqueKey = false,
|
||||
) {
|
||||
const svgsContentPromises = svgFiles.map(async (svgFile) => {
|
||||
const name = basename(svgFile, '.svg');
|
||||
const svg = await readSvg(svgFile, iconsDirectory);
|
||||
const contents = parseSync(svg);
|
||||
export default (svgFiles, iconsDirectory, renderUniqueKey = false) =>
|
||||
svgFiles
|
||||
.map((svgFile) => {
|
||||
const name = basename(svgFile, '.svg');
|
||||
const svg = readSvg(svgFile, iconsDirectory);
|
||||
const contents = parseSync(svg);
|
||||
|
||||
if (!(contents.children && contents.children.length)) {
|
||||
throw new Error(`${name}.svg has no children!`);
|
||||
}
|
||||
if (!(contents.children && contents.children.length)) {
|
||||
throw new Error(`${name}.svg has no children!`);
|
||||
}
|
||||
|
||||
if (hasDuplicatedChildren(contents.children)) {
|
||||
throw new Error(`Duplicated children in ${name}.svg`);
|
||||
}
|
||||
if (hasDuplicatedChildren(contents.children)) {
|
||||
throw new Error(`Duplicated children in ${name}.svg`);
|
||||
}
|
||||
|
||||
if (renderUniqueKey) {
|
||||
contents.children = contents.children.map((child) => {
|
||||
child.attributes.key = generateHashedKey(child);
|
||||
if (renderUniqueKey) {
|
||||
contents.children = contents.children.map((child) => {
|
||||
child.attributes.key = generateHashedKey(child);
|
||||
|
||||
return child;
|
||||
});
|
||||
}
|
||||
return child;
|
||||
});
|
||||
}
|
||||
|
||||
return { name, contents };
|
||||
});
|
||||
|
||||
const svgsContents = await Promise.all(svgsContentPromises);
|
||||
|
||||
return svgsContents.reduce((icons, icon) => {
|
||||
icons[icon.name] = icon.contents;
|
||||
return icons;
|
||||
}, {});
|
||||
}
|
||||
return { name, contents };
|
||||
})
|
||||
.reduce((icons, icon) => {
|
||||
icons[icon.name] = icon.contents;
|
||||
return icons;
|
||||
}, {});
|
||||
|
||||
@@ -2,7 +2,7 @@ import path from 'path';
|
||||
import { readSvgDirectory } from '@lucide/helpers';
|
||||
|
||||
async function getAliases(iconDirectory) {
|
||||
const iconJsons = await readSvgDirectory(iconDirectory, '.json');
|
||||
const iconJsons = readSvgDirectory(iconDirectory, '.json');
|
||||
const aliasesEntries = await Promise.all(
|
||||
iconJsons.map(async (jsonFile) => {
|
||||
const file = await import(path.join(iconDirectory, jsonFile), { with: { type: 'json' } });
|
||||
|
||||
@@ -2,7 +2,7 @@ import path from 'path';
|
||||
import { readSvgDirectory } from '@lucide/helpers';
|
||||
|
||||
async function getIconMetaData(iconDirectory) {
|
||||
const iconJsons = await readSvgDirectory(iconDirectory, '.json');
|
||||
const iconJsons = readSvgDirectory(iconDirectory, '.json');
|
||||
const aliasesEntries = await Promise.all(
|
||||
iconJsons.map(async (jsonFile) => {
|
||||
/** eslint-disable */
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
"@atomico/rollup-plugin-sizes": "^1.1.4",
|
||||
"@rollup/plugin-node-resolve": "^15.2.3",
|
||||
"@rollup/plugin-replace": "^6.0.1",
|
||||
"esbuild": "^0.25.0",
|
||||
"esbuild": "^0.19.11",
|
||||
"rollup": "^4.22.4",
|
||||
"rollup-plugin-esbuild": "^6.1.0",
|
||||
"rollup-plugin-license": "^3.2.0",
|
||||
|
||||