@tinloof/typed-svg-sprite 0.0.1 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -13
- package/README.md +230 -190
- package/dist/astro.d.ts +63 -0
- package/dist/astro.js +47 -0
- package/dist/cli.js +15 -15
- package/dist/components.d.ts +5 -1
- package/dist/components.js +114 -40
- package/dist/core.js +3 -3
- package/dist/next.d.ts +2 -2
- package/dist/next.js +14 -123
- package/dist/shared.d.ts +6 -0
- package/dist/shared.js +129 -0
- package/dist/types.js +33 -33
- package/package.json +72 -64
package/CHANGELOG.md
CHANGED
|
@@ -1,13 +1,25 @@
|
|
|
1
|
-
# @tinloof/typed-svg-sprite
|
|
2
|
-
|
|
3
|
-
## 0.
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
-
|
|
1
|
+
# @tinloof/typed-svg-sprite
|
|
2
|
+
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 3120201: Generate the `Icon` component from `React.ComponentPropsWithRef<"svg">` instead of `React.SVGProps<SVGSVGElement>`. The old base typed `ref` as `LegacyRef` (allowing string refs), which React 19's intrinsic elements reject — causing a type error in the generated `Icon.tsx`. The new base uses the React-19-correct `Ref` typing.
|
|
8
|
+
|
|
9
|
+
## 0.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- b2234dd: Added astro integration
|
|
14
|
+
|
|
15
|
+
## 0.0.1
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Initial release of @tinloof/typed-svg-sprite
|
|
20
|
+
- Generate optimized SVG sprites with full TypeScript support
|
|
21
|
+
- CLI tool for generating sprites from SVG files
|
|
22
|
+
- Next.js integration with `withSpriteLoader`
|
|
23
|
+
- Auto-generated TypeScript definitions
|
|
24
|
+
- Auto-generated React Icon component
|
|
25
|
+
- Watch mode for development
|
package/README.md
CHANGED
|
@@ -1,190 +1,230 @@
|
|
|
1
|
-
# @tinloof/typed-svg-sprite
|
|
2
|
-
|
|
3
|
-
> Generate optimized SVG sprites with full TypeScript support
|
|
4
|
-
|
|
5
|
-
Automatically generates SVG sprite files with type-safe TypeScript definitions and a ready-to-use React component.
|
|
6
|
-
|
|
7
|
-
## Installation
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm install @tinloof/typed-svg-sprite
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Quick Start
|
|
14
|
-
|
|
15
|
-
### CLI
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
# Generate sprite
|
|
19
|
-
typed-svg-sprite --input public/icons --output public/sprite.svg
|
|
20
|
-
|
|
21
|
-
# Watch mode
|
|
22
|
-
typed-svg-sprite -i public/icons -o public/sprite.svg --watch
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
### Next.js
|
|
26
|
-
|
|
27
|
-
```typescript
|
|
28
|
-
// next.config.ts
|
|
29
|
-
import { withSpriteLoader } from "@tinloof/typed-svg-sprite/next";
|
|
30
|
-
|
|
31
|
-
export default withSpriteLoader({});
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
Place SVGs in `public/icons/` and use:
|
|
35
|
-
|
|
36
|
-
```typescript
|
|
37
|
-
import { HOME, SETTINGS } from "@/generated/icons";
|
|
38
|
-
import { Icon } from "@/generated/Icon";
|
|
39
|
-
|
|
40
|
-
function MyComponent() {
|
|
41
|
-
return (
|
|
42
|
-
<>
|
|
43
|
-
<Icon href={HOME} />
|
|
44
|
-
<Icon href={SETTINGS} size={32} />
|
|
45
|
-
</>
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
typed-svg-sprite
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
export
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
1
|
+
# @tinloof/typed-svg-sprite
|
|
2
|
+
|
|
3
|
+
> Generate optimized SVG sprites with full TypeScript support
|
|
4
|
+
|
|
5
|
+
Automatically generates SVG sprite files with type-safe TypeScript definitions and a ready-to-use React component. Works with Next.js, Astro, or standalone via CLI.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @tinloof/typed-svg-sprite
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
### CLI
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Generate sprite
|
|
19
|
+
typed-svg-sprite --input public/icons --output public/sprite.svg
|
|
20
|
+
|
|
21
|
+
# Watch mode
|
|
22
|
+
typed-svg-sprite -i public/icons -o public/sprite.svg --watch
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Next.js
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
// next.config.ts
|
|
29
|
+
import { withSpriteLoader } from "@tinloof/typed-svg-sprite/next";
|
|
30
|
+
|
|
31
|
+
export default withSpriteLoader({});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Place SVGs in `public/icons/` and use:
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { HOME, SETTINGS } from "@/generated/icons";
|
|
38
|
+
import { Icon } from "@/generated/Icon";
|
|
39
|
+
|
|
40
|
+
function MyComponent() {
|
|
41
|
+
return (
|
|
42
|
+
<>
|
|
43
|
+
<Icon href={HOME} />
|
|
44
|
+
<Icon href={SETTINGS} size={32} />
|
|
45
|
+
</>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Astro
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
// astro.config.mjs
|
|
54
|
+
import { defineConfig } from "astro/config";
|
|
55
|
+
import { svgSprite } from "@tinloof/typed-svg-sprite/astro";
|
|
56
|
+
|
|
57
|
+
export default defineConfig({
|
|
58
|
+
integrations: [svgSprite()],
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Place SVGs in `public/icons/` and use:
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import { HOME, SETTINGS } from "../generated/icons";
|
|
66
|
+
import { Icon } from "../generated/Icon";
|
|
67
|
+
|
|
68
|
+
<Icon href={HOME} />
|
|
69
|
+
<Icon href={SETTINGS} size={32} />
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Usage
|
|
73
|
+
|
|
74
|
+
### CLI Options
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
typed-svg-sprite --input <dir> --output <file> [options]
|
|
78
|
+
|
|
79
|
+
Options:
|
|
80
|
+
-i, --input <dir> Directory containing SVG files
|
|
81
|
+
-o, --output <file> Output sprite file path
|
|
82
|
+
-w, --watch Watch for changes and regenerate
|
|
83
|
+
-h, --help Show help message
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Next.js Configuration
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
export default withSpriteLoader(
|
|
90
|
+
{
|
|
91
|
+
// your existing Next.js config
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
inputDir?: string; // default: "public/icons"
|
|
95
|
+
outputFile?: string; // default: "public/sprite.svg"
|
|
96
|
+
url?: string; // default: "/"
|
|
97
|
+
filename?: string; // default: "sprite.svg"
|
|
98
|
+
typesOutputFile?: string; // default: "generated/icons.ts"
|
|
99
|
+
generateIconComponent?: boolean; // default: true
|
|
100
|
+
iconComponentOutputFile?: string; // default: "generated/Icon.tsx"
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Astro Configuration
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
export default defineConfig({
|
|
109
|
+
integrations: [
|
|
110
|
+
svgSprite({
|
|
111
|
+
inputDir?: string; // default: "public/icons"
|
|
112
|
+
outputFile?: string; // default: "public/sprite.svg"
|
|
113
|
+
url?: string; // default: "/"
|
|
114
|
+
filename?: string; // default: "sprite.svg"
|
|
115
|
+
typesOutputFile?: string; // default: "src/generated/icons.ts"
|
|
116
|
+
generateIconComponent?: boolean; // default: true
|
|
117
|
+
iconComponentOutputFile?: string; // default: "src/generated/Icon.tsx"
|
|
118
|
+
}),
|
|
119
|
+
],
|
|
120
|
+
});
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Generated Files
|
|
124
|
+
|
|
125
|
+
### 1. Sprite (`public/sprite.svg`)
|
|
126
|
+
|
|
127
|
+
```xml
|
|
128
|
+
<svg xmlns="http://www.w3.org/2000/svg" style="display:none">
|
|
129
|
+
<symbol id="a" viewBox="0 0 24 24"><!-- icon content --></symbol>
|
|
130
|
+
<symbol id="b" viewBox="0 0 24 24"><!-- icon content --></symbol>
|
|
131
|
+
</svg>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### 2. TypeScript Types (`generated/icons.ts`)
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
export enum IconId {
|
|
138
|
+
HOME = "a",
|
|
139
|
+
SETTINGS = "b",
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export type IconHref = `/sprite.svg#${IconId}`;
|
|
143
|
+
|
|
144
|
+
export const HOME: IconHref = "/sprite.svg#a";
|
|
145
|
+
export const SETTINGS: IconHref = "/sprite.svg#b";
|
|
146
|
+
|
|
147
|
+
export function getIconHref(iconId: IconId): IconHref;
|
|
148
|
+
export const allIcons: IconId[];
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### 3. React Component (`generated/Icon.tsx`)
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
import { IconHref } from "./icons";
|
|
155
|
+
|
|
156
|
+
export interface IconProps extends React.SVGProps<SVGSVGElement> {
|
|
157
|
+
href: IconHref;
|
|
158
|
+
size?: number | string;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export function Icon({ href, size = 24, ...props }: IconProps) {
|
|
162
|
+
// ...
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Examples
|
|
167
|
+
|
|
168
|
+
### Basic Usage
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
import { HOME, SEARCH, SETTINGS } from "@/generated/icons";
|
|
172
|
+
import { Icon } from "@/generated/Icon";
|
|
173
|
+
|
|
174
|
+
<Icon href={HOME} />
|
|
175
|
+
<Icon href={SEARCH} size={20} />
|
|
176
|
+
<Icon href={SETTINGS} className="text-blue-500" />
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Dynamic Icons
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
import { IconId, getIconHref } from "@/generated/icons";
|
|
183
|
+
|
|
184
|
+
function DynamicIcon({ iconId }: { iconId: IconId }) {
|
|
185
|
+
return <Icon href={getIconHref(iconId)} />;
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Build Script Integration
|
|
190
|
+
|
|
191
|
+
```json
|
|
192
|
+
{
|
|
193
|
+
"scripts": {
|
|
194
|
+
"generate:icons": "typed-svg-sprite --input public/icons --output public/sprite.svg",
|
|
195
|
+
"build": "npm run generate:icons && next build"
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Without React
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
# Generate sprite and types
|
|
204
|
+
typed-svg-sprite --input src/icons --output public/sprite.svg
|
|
205
|
+
|
|
206
|
+
# Use generated types
|
|
207
|
+
import { HOME, SETTINGS } from "./generated/icons";
|
|
208
|
+
|
|
209
|
+
// In your HTML/JS
|
|
210
|
+
<svg><use href={HOME} /></svg>
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## How It Works
|
|
214
|
+
|
|
215
|
+
1. Scans directory for `.svg` files
|
|
216
|
+
2. Extracts and optimizes SVG content
|
|
217
|
+
3. Generates compact base-52 IDs (`a`, `b`, `aa`, etc.)
|
|
218
|
+
4. Combines into single sprite file
|
|
219
|
+
5. Generates TypeScript types with file-based names
|
|
220
|
+
6. Generates React component (optional)
|
|
221
|
+
|
|
222
|
+
**Symbol IDs**: Short IDs (`a`, `b`) in sprite, original names (`HOME`, `SETTINGS`) in TypeScript exports.
|
|
223
|
+
|
|
224
|
+
## Roadmap
|
|
225
|
+
|
|
226
|
+
- [ ] Integrate SVGO for advanced SVG optimization
|
|
227
|
+
|
|
228
|
+
## License
|
|
229
|
+
|
|
230
|
+
MIT
|
package/dist/astro.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { AstroIntegration } from "astro";
|
|
2
|
+
export interface SpriteIntegrationOptions {
|
|
3
|
+
/**
|
|
4
|
+
* URL path where the sprite file will be served from.
|
|
5
|
+
* @default "/"
|
|
6
|
+
*/
|
|
7
|
+
url?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Filename for the sprite file.
|
|
10
|
+
* @default "sprite.svg"
|
|
11
|
+
*/
|
|
12
|
+
filename?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Directory containing SVG files to include in the sprite.
|
|
15
|
+
* Relative to project root.
|
|
16
|
+
* @default "public/icons"
|
|
17
|
+
*/
|
|
18
|
+
inputDir?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Output path for the sprite file.
|
|
21
|
+
* Relative to project root.
|
|
22
|
+
* @default "public/sprite.svg"
|
|
23
|
+
*/
|
|
24
|
+
outputFile?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Output path for the TypeScript types file.
|
|
27
|
+
* Relative to project root.
|
|
28
|
+
* @default "src/generated/icons.ts"
|
|
29
|
+
*/
|
|
30
|
+
typesOutputFile?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Whether to generate the Icon component.
|
|
33
|
+
* - `true`: generates both Astro and React components
|
|
34
|
+
* - `false`: generates no component
|
|
35
|
+
* - `{ astro?: boolean, react?: boolean }`: choose which to generate
|
|
36
|
+
* @default { astro: true }
|
|
37
|
+
*/
|
|
38
|
+
generateIconComponent?: boolean | {
|
|
39
|
+
astro?: boolean;
|
|
40
|
+
react?: boolean;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Output path for the Icon component file (without extension).
|
|
44
|
+
* Extension will be added based on component type (.astro, .tsx).
|
|
45
|
+
* Relative to project root.
|
|
46
|
+
* @default "src/generated/Icon"
|
|
47
|
+
*/
|
|
48
|
+
iconComponentOutputFile?: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Astro integration for generating SVG sprites with TypeScript types
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* // astro.config.mjs
|
|
56
|
+
* import { svgSprite } from '@tinloof/typed-svg-sprite/astro';
|
|
57
|
+
*
|
|
58
|
+
* export default defineConfig({
|
|
59
|
+
* integrations: [svgSprite()]
|
|
60
|
+
* });
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare function svgSprite(options?: SpriteIntegrationOptions): AstroIntegration;
|
package/dist/astro.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.svgSprite = svgSprite;
|
|
4
|
+
const shared_js_1 = require("./shared.js");
|
|
5
|
+
/**
|
|
6
|
+
* Astro integration for generating SVG sprites with TypeScript types
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* // astro.config.mjs
|
|
11
|
+
* import { svgSprite } from '@tinloof/typed-svg-sprite/astro';
|
|
12
|
+
*
|
|
13
|
+
* export default defineConfig({
|
|
14
|
+
* integrations: [svgSprite()]
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
function svgSprite(options) {
|
|
19
|
+
const inputDir = options?.inputDir ?? "public/icons";
|
|
20
|
+
const outputFile = options?.outputFile ?? "public/sprite.svg";
|
|
21
|
+
const spriteUrl = options?.url ?? "/";
|
|
22
|
+
const spriteFilename = options?.filename ?? "sprite.svg";
|
|
23
|
+
const typesOutputFile = options?.typesOutputFile ?? "src/generated/icons.ts";
|
|
24
|
+
const generateIcon = options?.generateIconComponent === false
|
|
25
|
+
? false
|
|
26
|
+
: options?.generateIconComponent === true
|
|
27
|
+
? true
|
|
28
|
+
: options?.generateIconComponent ?? { astro: true };
|
|
29
|
+
const iconComponentOutputFile = options?.iconComponentOutputFile ?? "src/generated/Icon";
|
|
30
|
+
return {
|
|
31
|
+
name: "typed-svg-sprite",
|
|
32
|
+
hooks: {
|
|
33
|
+
"astro:config:setup": ({ command }) => {
|
|
34
|
+
// Generate on startup
|
|
35
|
+
(0, shared_js_1.generateSpriteAndTypes)(inputDir, outputFile, spriteUrl, spriteFilename, typesOutputFile, generateIcon, iconComponentOutputFile);
|
|
36
|
+
// Watch in dev mode
|
|
37
|
+
if (command === "dev") {
|
|
38
|
+
(0, shared_js_1.startWatcher)(inputDir, outputFile, spriteUrl, spriteFilename, typesOutputFile, generateIcon, iconComponentOutputFile);
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"astro:build:start": () => {
|
|
42
|
+
// Regenerate before build
|
|
43
|
+
(0, shared_js_1.generateSpriteAndTypes)(inputDir, outputFile, spriteUrl, spriteFilename, typesOutputFile, generateIcon, iconComponentOutputFile);
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
package/dist/cli.js
CHANGED
|
@@ -68,21 +68,21 @@ function parseArgs() {
|
|
|
68
68
|
return options;
|
|
69
69
|
}
|
|
70
70
|
function printHelp() {
|
|
71
|
-
console.log(`
|
|
72
|
-
SVG Sprite Generator
|
|
73
|
-
|
|
74
|
-
Usage:
|
|
75
|
-
typed-svg-sprite --input <dir> --output <file> [options]
|
|
76
|
-
|
|
77
|
-
Options:
|
|
78
|
-
-i, --input <dir> Directory containing SVG files
|
|
79
|
-
-o, --output <file> Output sprite file path
|
|
80
|
-
-w, --watch Watch for changes and regenerate
|
|
81
|
-
-h, --help Show this help message
|
|
82
|
-
|
|
83
|
-
Examples:
|
|
84
|
-
typed-svg-sprite --input public/icons --output public/sprite.svg
|
|
85
|
-
typed-svg-sprite -i ./icons -o ./dist/sprite.svg --watch
|
|
71
|
+
console.log(`
|
|
72
|
+
SVG Sprite Generator
|
|
73
|
+
|
|
74
|
+
Usage:
|
|
75
|
+
typed-svg-sprite --input <dir> --output <file> [options]
|
|
76
|
+
|
|
77
|
+
Options:
|
|
78
|
+
-i, --input <dir> Directory containing SVG files
|
|
79
|
+
-o, --output <file> Output sprite file path
|
|
80
|
+
-w, --watch Watch for changes and regenerate
|
|
81
|
+
-h, --help Show this help message
|
|
82
|
+
|
|
83
|
+
Examples:
|
|
84
|
+
typed-svg-sprite --input public/icons --output public/sprite.svg
|
|
85
|
+
typed-svg-sprite -i ./icons -o ./dist/sprite.svg --watch
|
|
86
86
|
`);
|
|
87
87
|
}
|
|
88
88
|
function runSpriteGeneration(inputDir, outputFile) {
|
package/dist/components.d.ts
CHANGED
|
@@ -21,4 +21,8 @@ export interface IconComponentGenerationOptions {
|
|
|
21
21
|
/**
|
|
22
22
|
* Generate React Icon component file
|
|
23
23
|
*/
|
|
24
|
-
export declare function
|
|
24
|
+
export declare function generateReactIconComponent(options: IconComponentGenerationOptions): void;
|
|
25
|
+
/**
|
|
26
|
+
* Generate Astro Icon component file
|
|
27
|
+
*/
|
|
28
|
+
export declare function generateAstroIconComponent(options: IconComponentGenerationOptions): void;
|