vite-svg-sprite-generator-plugin 1.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.
@@ -0,0 +1,171 @@
1
+ /**
2
+ * Vite SVG Sprite Plugin - TypeScript Definitions (Production-Ready)
3
+ * @version 3.1.0 - SVGO optimization integration
4
+ */
5
+
6
+ import type { Plugin } from 'vite';
7
+
8
+ /**
9
+ * Опции плагина SVG Sprite
10
+ */
11
+ export interface SvgSpritePluginOptions {
12
+ /**
13
+ * Папка с SVG иконками
14
+ * @default 'src/icons'
15
+ * @example 'assets/icons'
16
+ */
17
+ iconsFolder?: string;
18
+
19
+ /**
20
+ * ID элемента спрайта в DOM
21
+ * @default 'icon-sprite'
22
+ * @example 'my-sprite'
23
+ */
24
+ spriteId?: string;
25
+
26
+ /**
27
+ * CSS класс спрайта
28
+ * @default 'svg-sprite'
29
+ * @example 'custom-sprite'
30
+ */
31
+ spriteClass?: string;
32
+
33
+ /**
34
+ * Префикс для ID символов
35
+ * @default '' (empty string - uses only filename)
36
+ * @example 'icon' will generate 'icon-home', 'icon-user'
37
+ * @example '' will generate 'home', 'user'
38
+ */
39
+ idPrefix?: string;
40
+
41
+ /**
42
+ * Оптимизировать SVG (будущая функция)
43
+ * @default true
44
+ */
45
+ optimize?: boolean;
46
+
47
+ /**
48
+ * Включить отслеживание изменений в dev-режиме
49
+ * @default true
50
+ */
51
+ watch?: boolean;
52
+
53
+ /**
54
+ * Задержка debounce для множественных изменений (мс)
55
+ * @default 100
56
+ */
57
+ debounceDelay?: number;
58
+
59
+ /**
60
+ * Подробное логирование
61
+ * @default true в development, false в production
62
+ */
63
+ verbose?: boolean;
64
+
65
+ /**
66
+ * Оптимизация SVG с помощью SVGO
67
+ * @default true в production, false в development
68
+ */
69
+ svgoOptimize?: boolean;
70
+
71
+ /**
72
+ * Кастомная конфигурация SVGO
73
+ * @default оптимальные настройки для спрайтов
74
+ */
75
+ svgoConfig?: any;
76
+ }
77
+
78
+ /**
79
+ * Информация об иконке в спрайте
80
+ */
81
+ export interface SpriteIcon {
82
+ /** Уникальный ID символа */
83
+ id: string;
84
+ /** Относительный путь к файлу */
85
+ file: string;
86
+ }
87
+
88
+ /**
89
+ * Vite плагин для генерации SVG спрайтов
90
+ *
91
+ * @example
92
+ * ```ts
93
+ * import { defineConfig } from 'vite';
94
+ * import svgSpritePlugin from './vite-svg-sprite-plugin';
95
+ *
96
+ * export default defineConfig({
97
+ * plugins: [
98
+ * svgSpritePlugin({
99
+ * iconsFolder: 'src/icons',
100
+ * spriteId: 'icon-sprite',
101
+ * verbose: true
102
+ * })
103
+ * ]
104
+ * });
105
+ * ```
106
+ */
107
+ export default function svgSpritePlugin(options?: SvgSpritePluginOptions): Plugin;
108
+
109
+ /**
110
+ * Виртуальный модуль для программного доступа к спрайту
111
+ *
112
+ * @example
113
+ * ```ts
114
+ * import { getIconHref, icons, useIcon } from 'virtual:svg-sprite';
115
+ *
116
+ * // Получить href для иконки
117
+ * const href = getIconHref('home'); // '#icon-home'
118
+ *
119
+ * // Список всех доступных иконок
120
+ * console.log(icons); // [{ id: 'icon-home', file: 'src/icons/home.svg' }, ...]
121
+ *
122
+ * // Создать SVG элемент
123
+ * const svg = useIcon('home', { width: 24, height: 24 });
124
+ * ```
125
+ */
126
+ declare module 'virtual:svg-sprite' {
127
+ /**
128
+ * ID спрайта в DOM
129
+ */
130
+ export const spriteId: string;
131
+
132
+ /**
133
+ * Список всех доступных иконок
134
+ */
135
+ export const icons: SpriteIcon[];
136
+
137
+ /**
138
+ * Получить href для использования в <use>
139
+ * @param name Имя иконки (без префикса)
140
+ * @returns href строка, например '#icon-home'
141
+ *
142
+ * @example
143
+ * ```ts
144
+ * const href = getIconHref('home');
145
+ * // '<svg><use href="#icon-home"></use></svg>'
146
+ * ```
147
+ */
148
+ export function getIconHref(name: string): string;
149
+
150
+ /**
151
+ * Создать SVG элемент с иконкой
152
+ * @param name Имя иконки (без префикса)
153
+ * @param attrs Атрибуты для SVG элемента
154
+ * @returns HTML строка с SVG элементом
155
+ *
156
+ * @example
157
+ * ```ts
158
+ * const svg = useIcon('home', {
159
+ * width: 24,
160
+ * height: 24,
161
+ * fill: 'currentColor'
162
+ * });
163
+ * document.body.innerHTML += svg;
164
+ * ```
165
+ */
166
+ export function useIcon(
167
+ name: string,
168
+ attrs?: Record<string, string | number>
169
+ ): string;
170
+ }
171
+