@dxtmisha/constructor 0.39.3 → 0.39.5
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/dist/Plugin-DUJ0epm4.js +628 -0
- package/dist/classes/Plugin/Plugin.d.ts +80 -0
- package/dist/classes/Plugin/PluginCode.d.ts +94 -0
- package/dist/classes/Plugin/PluginComponents.d.ts +38 -0
- package/dist/classes/Plugin/PluginData.d.ts +81 -0
- package/dist/classes/Plugin/PluginImport.d.ts +34 -0
- package/dist/classes/Plugin/PluginStyle.d.ts +71 -0
- package/dist/classes/Plugin/PluginTool.d.ts +42 -0
- package/dist/constructors/Accordion/props.d.ts +5 -7
- package/dist/constructors/ActionSheet/props.d.ts +4 -7
- package/dist/constructors/Actions/basicTypes.d.ts +2 -2
- package/dist/constructors/Actions/props.d.ts +5 -7
- package/dist/constructors/Anchor/AnchorIcon.d.ts +1 -1
- package/dist/constructors/Anchor/basicTypes.d.ts +2 -2
- package/dist/constructors/Anchor/props.d.ts +4 -7
- package/dist/constructors/Arrow/basicTypes.d.ts +2 -2
- package/dist/constructors/Arrow/props.d.ts +5 -7
- package/dist/constructors/Badge/basicTypes.d.ts +2 -2
- package/dist/constructors/Badge/props.d.ts +5 -7
- package/dist/constructors/Bars/Bars.d.ts +3 -6
- package/dist/constructors/Bars/basicTypes.d.ts +2 -2
- package/dist/constructors/Bars/props.d.ts +5 -7
- package/dist/constructors/Block/props.d.ts +4 -7
- package/dist/constructors/Button/basicTypes.d.ts +2 -2
- package/dist/constructors/Button/props.d.ts +5 -7
- package/dist/constructors/Cell/props.d.ts +5 -7
- package/dist/constructors/Chip/basicTypes.d.ts +2 -2
- package/dist/constructors/Chip/props.d.ts +4 -7
- package/dist/constructors/ChipGroup/props.d.ts +4 -7
- package/dist/constructors/Dialog/Dialog.d.ts +1 -2
- package/dist/constructors/Dialog/props.d.ts +5 -7
- package/dist/constructors/Field/FieldInclude.d.ts +3 -3
- package/dist/constructors/Field/basicTypes.d.ts +2 -2
- package/dist/constructors/Field/props.d.ts +5 -7
- package/dist/constructors/FieldCounter/props.d.ts +4 -7
- package/dist/constructors/FieldLabel/basicTypes.d.ts +2 -2
- package/dist/constructors/FieldLabel/props.d.ts +4 -7
- package/dist/constructors/FieldMessage/props.d.ts +4 -7
- package/dist/constructors/Icon/IconLiteInclude.d.ts +1 -2
- package/dist/constructors/Icon/basicTypes.d.ts +6 -6
- package/dist/constructors/Icon/props.d.ts +6 -8
- package/dist/constructors/Image/basicTypes.d.ts +2 -2
- package/dist/constructors/Image/props.d.ts +5 -7
- package/dist/constructors/Input/Input.d.ts +13 -13
- package/dist/constructors/Input/InputPassword.d.ts +1 -1
- package/dist/constructors/Input/props.d.ts +3 -7
- package/dist/constructors/List/List.d.ts +20 -21
- package/dist/constructors/List/props.d.ts +5 -7
- package/dist/constructors/ListGroup/basicTypes.d.ts +2 -2
- package/dist/constructors/ListGroup/props.d.ts +5 -7
- package/dist/constructors/ListItem/props.d.ts +5 -7
- package/dist/constructors/ListMenu/props.d.ts +4 -7
- package/dist/constructors/Mask/MaskInclude.d.ts +2 -2
- package/dist/constructors/Mask/MaskPattern.d.ts +1 -1
- package/dist/constructors/Mask/props.d.ts +5 -7
- package/dist/constructors/Menu/Menu.d.ts +1 -6
- package/dist/constructors/Menu/MenuRequest.d.ts +1 -5
- package/dist/constructors/Menu/basicTypes.d.ts +2 -2
- package/dist/constructors/Menu/props.d.ts +5 -7
- package/dist/constructors/Modal/props.d.ts +5 -7
- package/dist/constructors/MotionTransform/props.d.ts +5 -7
- package/dist/constructors/Page/props.d.ts +3 -7
- package/dist/constructors/Progress/basicTypes.d.ts +2 -2
- package/dist/constructors/Progress/props.d.ts +5 -7
- package/dist/constructors/Ripple/props.d.ts +4 -7
- package/dist/constructors/Scrollbar/basicTypes.d.ts +2 -2
- package/dist/constructors/Scrollbar/props.d.ts +5 -7
- package/dist/constructors/Section/props.d.ts +3 -7
- package/dist/constructors/Select/Select.d.ts +7 -7
- package/dist/constructors/Select/SelectInput.d.ts +3 -3
- package/dist/constructors/Select/props.d.ts +4 -7
- package/dist/constructors/SelectValue/props.d.ts +4 -7
- package/dist/constructors/Skeleton/basicTypes.d.ts +2 -2
- package/dist/constructors/Skeleton/props.d.ts +4 -7
- package/dist/constructors/TextareaAutosize/props.d.ts +4 -7
- package/dist/constructors/Tooltip/TooltipEvent.d.ts +1 -1
- package/dist/constructors/Tooltip/TooltipOpen.d.ts +1 -1
- package/dist/constructors/Tooltip/basicTypes.d.ts +2 -2
- package/dist/constructors/Tooltip/props.d.ts +4 -7
- package/dist/constructors/Window/basicTypes.d.ts +2 -2
- package/dist/constructors/Window/props.d.ts +5 -7
- package/dist/library/plugin.d.ts +2 -0
- package/dist/library.d.ts +22 -14
- package/dist/library.js +54 -46
- package/dist/media/styleModification.d.ts +6 -0
- package/dist/plugin.js +4 -0
- package/dist/types/ariaTypes.d.ts +15 -16
- package/dist/types/captionTypes.d.ts +2 -2
- package/dist/types/descriptionTypes.d.ts +2 -2
- package/dist/types/enabledTypes.d.ts +2 -2
- package/dist/types/eventClickTypes.d.ts +2 -2
- package/dist/types/fieldTypes.d.ts +40 -41
- package/dist/types/labelTypes.d.ts +6 -6
- package/dist/types/modelTypes.d.ts +4 -4
- package/dist/types/pluginTypes.d.ts +17 -0
- package/dist/types/prefixTypes.d.ts +2 -2
- package/dist/types/suffixTypes.d.ts +2 -2
- package/dist/types/textTypes.d.ts +9 -10
- package/package.json +88 -89
- /package/dist/classes/{field → Field}/FieldArrowInclude.d.ts +0 -0
- /package/dist/classes/{field → Field}/FieldAttributesInclude.d.ts +0 -0
- /package/dist/classes/{field → Field}/FieldChangeInclude.d.ts +0 -0
- /package/dist/classes/{field → Field}/FieldCodeInclude.d.ts +0 -0
- /package/dist/classes/{field → Field}/FieldElementInclude.d.ts +0 -0
- /package/dist/classes/{field → Field}/FieldEventInclude.d.ts +0 -0
- /package/dist/classes/{field → Field}/FieldInputCheckInclude.d.ts +0 -0
- /package/dist/classes/{field → Field}/FieldInputModeInclude.d.ts +0 -0
- /package/dist/classes/{field → Field}/FieldMatchInclude.d.ts +0 -0
- /package/dist/classes/{field → Field}/FieldPatternInclude.d.ts +0 -0
- /package/dist/classes/{field → Field}/FieldTypeInclude.d.ts +0 -0
- /package/dist/classes/{field → Field}/FieldValidationInclude.d.ts +0 -0
- /package/dist/classes/{field → Field}/FieldValueInclude.d.ts +0 -0
- /package/dist/classes/{field → Field}/FieldVisibilityInclude.d.ts +0 -0
|
@@ -0,0 +1,628 @@
|
|
|
1
|
+
var g = Object.defineProperty;
|
|
2
|
+
var d = (i, t, e) => t in i ? g(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
|
|
3
|
+
var a = (i, t, e) => d(i, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import l from "magic-string";
|
|
5
|
+
import { toCamelCase as m, toKebabCase as p } from "@dxtmisha/functional-basic";
|
|
6
|
+
class h {
|
|
7
|
+
/**
|
|
8
|
+
* Checks if the id is a user’s file.
|
|
9
|
+
*
|
|
10
|
+
* Проверяет, является ли id файлом пользователя.
|
|
11
|
+
* @param id file identification / идентификация файла
|
|
12
|
+
*/
|
|
13
|
+
static isSrc(t) {
|
|
14
|
+
return !!(t.match(/\/src\//i) && !t.match(/\/node_modules\//i));
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Checks if the id is a JS user’s file.
|
|
18
|
+
*
|
|
19
|
+
* Проверяет, является ли id файлом JS пользователя.
|
|
20
|
+
* @param id file identification / идентификация файла
|
|
21
|
+
*/
|
|
22
|
+
static isJs(t) {
|
|
23
|
+
return this.isSrc(t) && !!t.match(/\.ts|js|tsx/);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Checks if the id is a Vue user’s file.
|
|
27
|
+
*
|
|
28
|
+
* Проверяет, является ли id файлом vue пользователя.
|
|
29
|
+
* @param id file identification / идентификация файла
|
|
30
|
+
*/
|
|
31
|
+
static isVue(t) {
|
|
32
|
+
return this.isSrc(t) && !!t.match(/\.vue$/);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Checks if the id is a Style user’s file.
|
|
36
|
+
*
|
|
37
|
+
* Проверяет, является ли id файлом style пользователя.
|
|
38
|
+
* @param id file identification / идентификация файла
|
|
39
|
+
*/
|
|
40
|
+
static isCss(t) {
|
|
41
|
+
return this.isSrc(t) && !!t.match(/\.(css|sass|scss)/);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Checks if it is development mode.
|
|
45
|
+
*
|
|
46
|
+
* Проверяет, является ли режим разработка.
|
|
47
|
+
* @param mode current mode / текущий режим
|
|
48
|
+
*/
|
|
49
|
+
static isDev(t) {
|
|
50
|
+
return t === "development";
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
class u {
|
|
54
|
+
/**
|
|
55
|
+
* Constructor
|
|
56
|
+
* @param id file ID / ID файла
|
|
57
|
+
* @param code source code / исходный код
|
|
58
|
+
*/
|
|
59
|
+
constructor(t, e) {
|
|
60
|
+
a(this, "magicString");
|
|
61
|
+
a(this, "newCode");
|
|
62
|
+
this.id = t, this.code = e, this.magicString = new l(e), this.newCode = e;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Checks if the file is a Vue component.
|
|
66
|
+
*
|
|
67
|
+
* Проверяет, является ли файл компонентом Vue.
|
|
68
|
+
*/
|
|
69
|
+
isVue() {
|
|
70
|
+
return h.isVue(this.id);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Checks if the file is a SCSS file.
|
|
74
|
+
*
|
|
75
|
+
* Проверяет, является ли файл SCSS.
|
|
76
|
+
*/
|
|
77
|
+
isScss() {
|
|
78
|
+
return h.isCss(this.id);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Returns the modified code.
|
|
82
|
+
*
|
|
83
|
+
* Возвращает измененный код.
|
|
84
|
+
*/
|
|
85
|
+
get() {
|
|
86
|
+
return this.newCode;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Returns the file ID.
|
|
90
|
+
*
|
|
91
|
+
* Возвращает ID файла.
|
|
92
|
+
*/
|
|
93
|
+
getId() {
|
|
94
|
+
return this.id;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Returns the original code.
|
|
98
|
+
*
|
|
99
|
+
* Возвращает оригинальный код.
|
|
100
|
+
*/
|
|
101
|
+
getCode() {
|
|
102
|
+
return this.code;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Returns the source map.
|
|
106
|
+
*
|
|
107
|
+
* Возвращает карту кода.
|
|
108
|
+
*/
|
|
109
|
+
getMaps() {
|
|
110
|
+
return this.magicString.generateMap({
|
|
111
|
+
source: this.id,
|
|
112
|
+
includeContent: !0,
|
|
113
|
+
hires: !0
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Checks for the presence of code.
|
|
118
|
+
*
|
|
119
|
+
* Проверяет наличие кода.
|
|
120
|
+
* @param pattern search pattern / паттерн поиска
|
|
121
|
+
* @param flags search flags / флаги поиска
|
|
122
|
+
*/
|
|
123
|
+
has(t, e = "i") {
|
|
124
|
+
return typeof t == "string" ? this.code.includes(t) : new RegExp(t, e).test(this.code);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Adds code after the <script setup> tag.
|
|
128
|
+
* If the tag is missing, adds it to the beginning of the file.
|
|
129
|
+
*
|
|
130
|
+
* Добавляет код после тега <script setup>.
|
|
131
|
+
* Если тег отсутствует, добавляет в начало файла.
|
|
132
|
+
* @param code code to add / код для добавления
|
|
133
|
+
*/
|
|
134
|
+
addAfterScript(t) {
|
|
135
|
+
const e = /(<script[^>]*\bsetup\b[^>]*>)/;
|
|
136
|
+
return this.code.match(e) ? this.newCode = this.newCode.replace(e, `$1${t}`) : this.newCode = `<script setup>\r
|
|
137
|
+
${t}<\/script>${this.newCode}`, this;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Adds code to the beginning of the file.
|
|
141
|
+
*
|
|
142
|
+
* Добавляет код в начало файла.
|
|
143
|
+
* @param code code to add / код для добавления
|
|
144
|
+
*/
|
|
145
|
+
addStart(t) {
|
|
146
|
+
return this.newCode = `${t}${this.newCode}`, this;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Adds code to the beginning of the file if it is missing.
|
|
150
|
+
*
|
|
151
|
+
* Добавляет код в начало файла, если он отсутствует.
|
|
152
|
+
* @param code code to add / код для добавления
|
|
153
|
+
* @param pattern search pattern / паттерн поиска
|
|
154
|
+
*/
|
|
155
|
+
addStartIfNone(t, e) {
|
|
156
|
+
return this.has(e != null ? e : t) || this.addStart(t), this;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Replaces the found fragment with new code in newCode.
|
|
160
|
+
*
|
|
161
|
+
* Заменяет найденный фрагмент на новый код в newCode.
|
|
162
|
+
* @param pattern search pattern / паттерн поиска
|
|
163
|
+
* @param replacement replacement string / строка замены
|
|
164
|
+
*/
|
|
165
|
+
replace(t, e) {
|
|
166
|
+
return this.newCode = this.newCode.replace(t, e), this;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
const f = [
|
|
170
|
+
/* Flex */
|
|
171
|
+
"flex-position",
|
|
172
|
+
"flex-dynamic",
|
|
173
|
+
"justify-content",
|
|
174
|
+
/* Position */
|
|
175
|
+
"inset",
|
|
176
|
+
"horizon",
|
|
177
|
+
"vertically",
|
|
178
|
+
"left",
|
|
179
|
+
"right",
|
|
180
|
+
"absolute",
|
|
181
|
+
"absolute-top",
|
|
182
|
+
"absolute-bottom",
|
|
183
|
+
"absolute-after",
|
|
184
|
+
/* Padding */
|
|
185
|
+
"padding-x",
|
|
186
|
+
"padding-y",
|
|
187
|
+
"padding-left",
|
|
188
|
+
"padding-right",
|
|
189
|
+
/* Margin */
|
|
190
|
+
"margin-x",
|
|
191
|
+
"margin-y",
|
|
192
|
+
"margin-left",
|
|
193
|
+
"margin-right",
|
|
194
|
+
/* Dimension */
|
|
195
|
+
"width",
|
|
196
|
+
"height",
|
|
197
|
+
"width-basis",
|
|
198
|
+
"height-basis",
|
|
199
|
+
"aspect-ratio",
|
|
200
|
+
"aspect-ratio-width",
|
|
201
|
+
"aspect-ratio-height",
|
|
202
|
+
"squared",
|
|
203
|
+
"circle",
|
|
204
|
+
/* Font */
|
|
205
|
+
"font-size",
|
|
206
|
+
"line-height",
|
|
207
|
+
"text-align",
|
|
208
|
+
"text-overflow",
|
|
209
|
+
"clamp",
|
|
210
|
+
"text-select-none",
|
|
211
|
+
"text-case",
|
|
212
|
+
"paragraph-spacing",
|
|
213
|
+
/* Color */
|
|
214
|
+
"palette",
|
|
215
|
+
"palette-var",
|
|
216
|
+
"palette-color",
|
|
217
|
+
"palette-stroke",
|
|
218
|
+
"palette-background",
|
|
219
|
+
"palette-fill",
|
|
220
|
+
"palette-gradient",
|
|
221
|
+
"palette-border",
|
|
222
|
+
"color",
|
|
223
|
+
"color-opacity",
|
|
224
|
+
"stroke",
|
|
225
|
+
"stroke-opacity",
|
|
226
|
+
"background-color",
|
|
227
|
+
"background-opacity",
|
|
228
|
+
"background-size",
|
|
229
|
+
"fill",
|
|
230
|
+
"fill-opacity",
|
|
231
|
+
"gradient",
|
|
232
|
+
"gradient-opacity",
|
|
233
|
+
"border-color",
|
|
234
|
+
"border-opacity",
|
|
235
|
+
/* Transform */
|
|
236
|
+
"translate-x",
|
|
237
|
+
"translate-y",
|
|
238
|
+
"scale",
|
|
239
|
+
"rotate"
|
|
240
|
+
];
|
|
241
|
+
class C {
|
|
242
|
+
/**
|
|
243
|
+
* Constructor
|
|
244
|
+
* @param design design name / название дизайна
|
|
245
|
+
* @param packageName package name / название пакета
|
|
246
|
+
* @param componentsReg regular expression for finding components / регулярное выражение для поиска компонентов
|
|
247
|
+
* @param styleVarsReg regular expression for finding variables / регулярное выражение для поиска переменных
|
|
248
|
+
* @param componentsList list of components / список компонентов
|
|
249
|
+
*/
|
|
250
|
+
constructor(t, e, s, n, o) {
|
|
251
|
+
a(this, "styleModification");
|
|
252
|
+
this.design = t, this.packageName = e, this.componentsReg = s, this.styleVarsReg = n, this.componentsList = o, this.styleModification = this.initStyleModification();
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Checks if the code contains a component.
|
|
256
|
+
*
|
|
257
|
+
* Проверяет, содержит ли код компонент.
|
|
258
|
+
* @param code code to check / код для проверки
|
|
259
|
+
*/
|
|
260
|
+
hasComponent(t) {
|
|
261
|
+
return !!t.match(new RegExp(this.componentsReg, "i"));
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Checks if the code contains variables.
|
|
265
|
+
*
|
|
266
|
+
* Проверяет, содержит ли код переменные.
|
|
267
|
+
* @param code code to check / код для проверки
|
|
268
|
+
*/
|
|
269
|
+
hasVars(t) {
|
|
270
|
+
return !!t.match(new RegExp(this.styleVarsReg, "i"));
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Returns the design name.
|
|
274
|
+
*
|
|
275
|
+
* Возвращает название дизайна.
|
|
276
|
+
*/
|
|
277
|
+
getDesign() {
|
|
278
|
+
return this.design;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Returns the package name.
|
|
282
|
+
*
|
|
283
|
+
* Возвращает название пакета.
|
|
284
|
+
*/
|
|
285
|
+
getPackageName() {
|
|
286
|
+
return this.packageName;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Returns a list of all components in the code.
|
|
290
|
+
*
|
|
291
|
+
* Возвращает список всех компонентов в коде.
|
|
292
|
+
* @param code code to check / код для проверки
|
|
293
|
+
*/
|
|
294
|
+
getComponents(t) {
|
|
295
|
+
const e = t.match(this.componentsReg), s = [];
|
|
296
|
+
return e && e.forEach((n) => {
|
|
297
|
+
const o = this.findComponent(n);
|
|
298
|
+
o && !s.find((r) => r.name === o.name) && !t.match(`${this.getPackageName()}/${o.name}`) && s.push(o);
|
|
299
|
+
}), s;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Returns the regular expression for finding variables.
|
|
303
|
+
*
|
|
304
|
+
* Возвращает регулярное выражение для поиска переменных.
|
|
305
|
+
*/
|
|
306
|
+
getStyleVarsReg() {
|
|
307
|
+
return this.styleVarsReg;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Returns the style modification map.
|
|
311
|
+
*
|
|
312
|
+
* Возвращает карту модификации стилей.
|
|
313
|
+
*/
|
|
314
|
+
getStyleModification() {
|
|
315
|
+
return this.styleModification;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Finds a component by name.
|
|
319
|
+
*
|
|
320
|
+
* Находит компонент по имени.
|
|
321
|
+
* @param component component name / название компонента
|
|
322
|
+
*/
|
|
323
|
+
findComponent(t) {
|
|
324
|
+
return this.componentsList.find(
|
|
325
|
+
(e) => e.reg.test(t)
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Initializes the style modification map.
|
|
330
|
+
*
|
|
331
|
+
* Инициализирует карту модификации стилей.
|
|
332
|
+
*/
|
|
333
|
+
initStyleModification() {
|
|
334
|
+
const t = {};
|
|
335
|
+
return f.forEach((e) => {
|
|
336
|
+
t[p(e)] = m(e);
|
|
337
|
+
}), t;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
class y {
|
|
341
|
+
/**
|
|
342
|
+
* Constructor
|
|
343
|
+
* @param packageName package name / название пакета
|
|
344
|
+
* @param code file content / содержимое файла
|
|
345
|
+
*/
|
|
346
|
+
constructor(t, e) {
|
|
347
|
+
a(this, "code");
|
|
348
|
+
this.packageName = t, this.code = e;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Returns the file content.
|
|
352
|
+
*
|
|
353
|
+
* Возвращает содержимое файла.
|
|
354
|
+
*/
|
|
355
|
+
get() {
|
|
356
|
+
return this.code;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Returns the style connection code.
|
|
360
|
+
*
|
|
361
|
+
* Возвращает код подключения стиля.
|
|
362
|
+
*/
|
|
363
|
+
importStyle() {
|
|
364
|
+
return this.makeImport("style.css"), this;
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Creates an import line.
|
|
368
|
+
*
|
|
369
|
+
* Создает строку импорта.
|
|
370
|
+
* @param name file name / имя файла
|
|
371
|
+
*/
|
|
372
|
+
makeImport(t) {
|
|
373
|
+
const e = `${this.packageName}/${t}`;
|
|
374
|
+
this.code.includes(e) || (this.code = `import '${e}';${this.code}`);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
class k {
|
|
378
|
+
/**
|
|
379
|
+
* Constructor
|
|
380
|
+
* @param code file content / содержимое файла
|
|
381
|
+
* @param pluginData plugin data / данные плагина
|
|
382
|
+
*/
|
|
383
|
+
constructor(t, e) {
|
|
384
|
+
this.code = t, this.pluginData = e;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Initializes the data.
|
|
388
|
+
*
|
|
389
|
+
* Инициализирует данные.
|
|
390
|
+
*/
|
|
391
|
+
make() {
|
|
392
|
+
if (this.code.isVue() && this.pluginData.hasComponent(this.code.getCode())) {
|
|
393
|
+
const t = this.pluginData.getComponents(this.code.getCode());
|
|
394
|
+
if (t) {
|
|
395
|
+
const e = t.map((s) => this.importComponent(s)).join(`\r
|
|
396
|
+
`);
|
|
397
|
+
this.code.addAfterScript(e);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Returns the path to the component.
|
|
403
|
+
*
|
|
404
|
+
* Возвращает путь к компоненту.
|
|
405
|
+
* @param item component data / данные компонента
|
|
406
|
+
*/
|
|
407
|
+
getPath(t) {
|
|
408
|
+
return `${this.pluginData.getPackageName()}/${t.name}`;
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Generates the import string for a component.
|
|
412
|
+
*
|
|
413
|
+
* Генерирует строку импорта для компонента.
|
|
414
|
+
* @param item component data / данные компонента
|
|
415
|
+
*/
|
|
416
|
+
importComponent(t) {
|
|
417
|
+
return `import { ${t.name} } from'${this.getPath(t)}';`;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
class S {
|
|
421
|
+
/**
|
|
422
|
+
* Constructor
|
|
423
|
+
* @param code file content / содержимое файла
|
|
424
|
+
* @param data plugin data / данные плагина
|
|
425
|
+
*/
|
|
426
|
+
constructor(t, e) {
|
|
427
|
+
this.code = t, this.data = e;
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Initialization of the transformation of all style properties.
|
|
431
|
+
*
|
|
432
|
+
* Инициализация преобразования всех свойств стилей.
|
|
433
|
+
*/
|
|
434
|
+
make() {
|
|
435
|
+
return this.is() && this.importDesign().makeColors().makeVars().makeProperties(), this;
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Checks whether this file needs to be transformed.
|
|
439
|
+
*
|
|
440
|
+
* Проверяет, нужно ли преобразовывать этот файл.
|
|
441
|
+
*/
|
|
442
|
+
is() {
|
|
443
|
+
return this.code.isScss() && !this.code.has(this.getIgnoreComment());
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Returns the comment for ignoring the file.
|
|
447
|
+
*
|
|
448
|
+
* Возвращает комментарий для игнорирования файла.
|
|
449
|
+
*/
|
|
450
|
+
getIgnoreComment() {
|
|
451
|
+
return `// ${this.data.getDesign()}-css-ignore`;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Returns a string for a negative lookahead to exclude lines with a special comment.
|
|
455
|
+
*
|
|
456
|
+
* Возвращает строку для негативного просмотра вперед, чтобы исключить строки со специальным комментарием.
|
|
457
|
+
*/
|
|
458
|
+
getPropertiesNone() {
|
|
459
|
+
return `(?![^\r
|
|
460
|
+
]*// ${this.data.getDesign()}-mode-none)`;
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Returns a regular expression for finding properties that need to be replaced with mixins.
|
|
464
|
+
*
|
|
465
|
+
* Возвращает регулярное выражение для поиска свойств, которые необходимо заменить на миксины.
|
|
466
|
+
*/
|
|
467
|
+
getModificationRef() {
|
|
468
|
+
const t = this.data.getStyleModification();
|
|
469
|
+
return new RegExp(
|
|
470
|
+
`(?<=^\\s*)(${Object.keys(t).join("|")}):([^;\r
|
|
471
|
+
]+)(;*)${this.getPropertiesNone()}`,
|
|
472
|
+
"igm"
|
|
473
|
+
);
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Connects a list of tokens to work with values.
|
|
477
|
+
*
|
|
478
|
+
* Подключает список токенов для работы со значениями.
|
|
479
|
+
*/
|
|
480
|
+
importDesign() {
|
|
481
|
+
const t = `${this.data.getPackageName()}/style/ui-properties`, e = `@use '${t}.scss' as *;`;
|
|
482
|
+
return this.code.addStartIfNone(e, t), this;
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Removes default values from colors.
|
|
486
|
+
*
|
|
487
|
+
* Удаляет значения по умолчанию у цветов.
|
|
488
|
+
*/
|
|
489
|
+
makeColors() {
|
|
490
|
+
const t = new RegExp(`(?<=var\\([^,]+), ?(#[0-9abcdf]{4,6}|rgba?\\([^)]+\\))${this.getPropertiesNone()}`, "ig");
|
|
491
|
+
return this.code.has(t) && this.code.replace(t, ""), this;
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Transforms property values under the correct name.
|
|
495
|
+
*
|
|
496
|
+
* Преобразовывает значения свойств под правильным именем.
|
|
497
|
+
*/
|
|
498
|
+
makeVars() {
|
|
499
|
+
const t = this.data.getStyleVarsReg();
|
|
500
|
+
return this.code.has(t) && this.code.replace(
|
|
501
|
+
t,
|
|
502
|
+
`${this.data.getDesign()}-$1`
|
|
503
|
+
), this;
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Transformation of all properties into non-standard ones used through mixins.
|
|
507
|
+
*
|
|
508
|
+
* Преобразование всех свойств в нестандартные, используемые через миксины.
|
|
509
|
+
*/
|
|
510
|
+
makeProperties() {
|
|
511
|
+
const t = this.data.getStyleModification(), e = this.getModificationRef();
|
|
512
|
+
return this.code.has(e, "im") && this.code.replace(
|
|
513
|
+
e,
|
|
514
|
+
(s, n, o, r) => {
|
|
515
|
+
const c = o.trim();
|
|
516
|
+
return `@include ${t == null ? void 0 : t[n.trim()]}(${c.match(/[()]/) ? `#{${c}}` : c})${r}`;
|
|
517
|
+
}
|
|
518
|
+
), this;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
class P {
|
|
522
|
+
/**
|
|
523
|
+
* Constructor
|
|
524
|
+
* @param design design name / название дизайна
|
|
525
|
+
* @param packageName package name / название пакета
|
|
526
|
+
* @param componentsReg regular expression for finding components / регулярное выражение для поиска компонентов
|
|
527
|
+
* @param styleVarsReg regular expression for finding variables / регулярное выражение для поиска переменных
|
|
528
|
+
* @param componentsList list of components / список компонентов
|
|
529
|
+
* @param name plugin name / название плагина
|
|
530
|
+
* @param options plugin options / настройки плагина
|
|
531
|
+
*/
|
|
532
|
+
constructor(t, e, s, n, o, r = "vite-plugin-design-ui", c = {}) {
|
|
533
|
+
a(this, "data");
|
|
534
|
+
a(this, "first", !0);
|
|
535
|
+
a(this, "mode", "production");
|
|
536
|
+
this.design = t, this.packageName = e, this.componentsReg = s, this.styleVarsReg = n, this.componentsList = o, this.name = r, this.options = c, this.data = new C(
|
|
537
|
+
t,
|
|
538
|
+
e,
|
|
539
|
+
s,
|
|
540
|
+
n,
|
|
541
|
+
o
|
|
542
|
+
);
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* Initializes the plugin.
|
|
546
|
+
*
|
|
547
|
+
* Инициализирует плагин.
|
|
548
|
+
*/
|
|
549
|
+
init() {
|
|
550
|
+
var t;
|
|
551
|
+
return {
|
|
552
|
+
name: this.name,
|
|
553
|
+
enforce: "pre",
|
|
554
|
+
apply: (e, s) => (this.mode = s.mode, !0),
|
|
555
|
+
transform: (e, s) => this.transform(e, s),
|
|
556
|
+
...(t = this.options) == null ? void 0 : t.viteOptions
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Checks if components should be processed.
|
|
561
|
+
*
|
|
562
|
+
* Проверяет, нужно ли обрабатывать компоненты.
|
|
563
|
+
*/
|
|
564
|
+
isComponents() {
|
|
565
|
+
var t, e;
|
|
566
|
+
return !!((e = (t = this.options) == null ? void 0 : t.component) == null || e);
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* Checks if styles should be processed.
|
|
570
|
+
*
|
|
571
|
+
* Проверяет, нужно ли обрабатывать стили.
|
|
572
|
+
*/
|
|
573
|
+
isStyles() {
|
|
574
|
+
var t, e;
|
|
575
|
+
return !!((e = (t = this.options) == null ? void 0 : t.style) == null || e);
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* Transforms the code.
|
|
579
|
+
*
|
|
580
|
+
* Преобразовывает код.
|
|
581
|
+
* @param code file content / содержимое файла
|
|
582
|
+
* @param id file identification / идентификация файла
|
|
583
|
+
*/
|
|
584
|
+
transform(t, e) {
|
|
585
|
+
this.first && h.isJs(e) && (t = this.initMain(t), this.first = !1);
|
|
586
|
+
const s = new u(e, t);
|
|
587
|
+
return this.makeComponents(s), this.initStyles(s), {
|
|
588
|
+
code: s.get()
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
/**
|
|
592
|
+
* Initializes the main file.
|
|
593
|
+
*
|
|
594
|
+
* Инициализирует главный файл.
|
|
595
|
+
* @param code file content / содержимое файла
|
|
596
|
+
*/
|
|
597
|
+
initMain(t) {
|
|
598
|
+
const e = new y(this.packageName, t);
|
|
599
|
+
return e.importStyle(), e.get();
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* Initializes components.
|
|
603
|
+
*
|
|
604
|
+
* Инициализирует компоненты.
|
|
605
|
+
* @param code file content / содержимое файла
|
|
606
|
+
*/
|
|
607
|
+
makeComponents(t) {
|
|
608
|
+
return this.isComponents() && new k(t, this.data).make(), this;
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* Initializes styles.
|
|
612
|
+
*
|
|
613
|
+
* Инициализирует стили.
|
|
614
|
+
* @param code file content / содержимое файла
|
|
615
|
+
*/
|
|
616
|
+
initStyles(t) {
|
|
617
|
+
return this.isStyles() && new S(t, this.data).make(), this;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
export {
|
|
621
|
+
P,
|
|
622
|
+
u as a,
|
|
623
|
+
k as b,
|
|
624
|
+
C as c,
|
|
625
|
+
y as d,
|
|
626
|
+
S as e,
|
|
627
|
+
h as f
|
|
628
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { TransformResult } from 'rollup';
|
|
2
|
+
import { Plugin as VitePlugin } from 'vite';
|
|
3
|
+
import { PluginCode } from './PluginCode';
|
|
4
|
+
import { PluginData } from './PluginData';
|
|
5
|
+
import { PluginComponentImports, PluginOptions } from '../../types/pluginTypes';
|
|
6
|
+
/**
|
|
7
|
+
* Base class for the Vite plugin.
|
|
8
|
+
*
|
|
9
|
+
* Базовый класс для плагина Vite.
|
|
10
|
+
*/
|
|
11
|
+
export declare class Plugin {
|
|
12
|
+
protected readonly design: string;
|
|
13
|
+
protected readonly packageName: string;
|
|
14
|
+
protected readonly componentsReg: RegExp;
|
|
15
|
+
protected readonly styleVarsReg: RegExp;
|
|
16
|
+
protected readonly componentsList: PluginComponentImports;
|
|
17
|
+
protected readonly name: string;
|
|
18
|
+
protected readonly options: PluginOptions;
|
|
19
|
+
protected readonly data: PluginData;
|
|
20
|
+
protected first: boolean;
|
|
21
|
+
protected mode: string;
|
|
22
|
+
/**
|
|
23
|
+
* Constructor
|
|
24
|
+
* @param design design name / название дизайна
|
|
25
|
+
* @param packageName package name / название пакета
|
|
26
|
+
* @param componentsReg regular expression for finding components / регулярное выражение для поиска компонентов
|
|
27
|
+
* @param styleVarsReg regular expression for finding variables / регулярное выражение для поиска переменных
|
|
28
|
+
* @param componentsList list of components / список компонентов
|
|
29
|
+
* @param name plugin name / название плагина
|
|
30
|
+
* @param options plugin options / настройки плагина
|
|
31
|
+
*/
|
|
32
|
+
constructor(design: string, packageName: string, componentsReg: RegExp, styleVarsReg: RegExp, componentsList: PluginComponentImports, name?: string, options?: PluginOptions);
|
|
33
|
+
/**
|
|
34
|
+
* Initializes the plugin.
|
|
35
|
+
*
|
|
36
|
+
* Инициализирует плагин.
|
|
37
|
+
*/
|
|
38
|
+
init(): VitePlugin;
|
|
39
|
+
/**
|
|
40
|
+
* Checks if components should be processed.
|
|
41
|
+
*
|
|
42
|
+
* Проверяет, нужно ли обрабатывать компоненты.
|
|
43
|
+
*/
|
|
44
|
+
protected isComponents(): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Checks if styles should be processed.
|
|
47
|
+
*
|
|
48
|
+
* Проверяет, нужно ли обрабатывать стили.
|
|
49
|
+
*/
|
|
50
|
+
protected isStyles(): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Transforms the code.
|
|
53
|
+
*
|
|
54
|
+
* Преобразовывает код.
|
|
55
|
+
* @param code file content / содержимое файла
|
|
56
|
+
* @param id file identification / идентификация файла
|
|
57
|
+
*/
|
|
58
|
+
protected transform(code: string, id: string): TransformResult;
|
|
59
|
+
/**
|
|
60
|
+
* Initializes the main file.
|
|
61
|
+
*
|
|
62
|
+
* Инициализирует главный файл.
|
|
63
|
+
* @param code file content / содержимое файла
|
|
64
|
+
*/
|
|
65
|
+
protected initMain(code: string): string;
|
|
66
|
+
/**
|
|
67
|
+
* Initializes components.
|
|
68
|
+
*
|
|
69
|
+
* Инициализирует компоненты.
|
|
70
|
+
* @param code file content / содержимое файла
|
|
71
|
+
*/
|
|
72
|
+
protected makeComponents(code: PluginCode): this;
|
|
73
|
+
/**
|
|
74
|
+
* Initializes styles.
|
|
75
|
+
*
|
|
76
|
+
* Инициализирует стили.
|
|
77
|
+
* @param code file content / содержимое файла
|
|
78
|
+
*/
|
|
79
|
+
protected initStyles(code: PluginCode): this;
|
|
80
|
+
}
|