unocss-preset-zyyv 2.0.0-beta.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/LICENSE +21 -0
- package/README.md +282 -0
- package/dist/dist-sozkiTde.mjs +19 -0
- package/dist/index.d.mts +281 -0
- package/dist/index.mjs +447 -0
- package/package.json +61 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 zyyv <https://github.com/zyyv>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
# unocss-preset-zyyv [](https://npmjs.com/package/unocss-preset-zyyv)
|
|
2
|
+
|
|
3
|
+
Integrate and useful preset.
|
|
4
|
+
|
|
5
|
+
> [!WARNING]
|
|
6
|
+
> The package name has been changed to `unocss-preset-zyyv`.
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
- 🔥 All-in-One popular presets.
|
|
10
|
+
- 🚀 Collection of features not integrated into UnoCSS.
|
|
11
|
+
- 🍥 Support extract base64 image.
|
|
12
|
+
- 🎨 Support extract rgba color in css variable.
|
|
13
|
+
- 💜 Support expand theme animation name usage.
|
|
14
|
+
- 🍬 etc.
|
|
15
|
+
- 📦 Build-In [Magic Animate](https://github.com/unocss-community/unocss-preset-magicss).
|
|
16
|
+
- 🌬️ Align with TW theme configuration.
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
```shell
|
|
20
|
+
pnpm i -D unocss-preset-zyyv unocss
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
// unocss.config.ts
|
|
25
|
+
import { defineConfig } from 'unocss'
|
|
26
|
+
import { presetZyyv } from 'unocss-preset-zyyv'
|
|
27
|
+
|
|
28
|
+
export default defineConfig({
|
|
29
|
+
presets: [
|
|
30
|
+
presetZyyv(),
|
|
31
|
+
],
|
|
32
|
+
})
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
<details>
|
|
36
|
+
<summary>Options</summary><br>
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
export interface ZyyvOptions {
|
|
40
|
+
/**
|
|
41
|
+
* Enable default shortcuts
|
|
42
|
+
*
|
|
43
|
+
* @default true
|
|
44
|
+
*/
|
|
45
|
+
enableDefaultShortcuts?: boolean
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Enable magic animations
|
|
49
|
+
*
|
|
50
|
+
* @default false
|
|
51
|
+
* @deprecated Use `magicss` option instead.
|
|
52
|
+
*/
|
|
53
|
+
enableMagicAnimations?: boolean
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Extract rgba color in css variable
|
|
57
|
+
*
|
|
58
|
+
* @default false
|
|
59
|
+
*/
|
|
60
|
+
unColor?: boolean | string
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Improve theme to be more useful, and align with Tailwind theme configuration
|
|
64
|
+
*
|
|
65
|
+
* - Add `animation` to theme, Expand theme animation name usage
|
|
66
|
+
*
|
|
67
|
+
* [ name, duration, timing-function, iteration-count ]
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
*
|
|
71
|
+
* ```ts
|
|
72
|
+
* theme: {
|
|
73
|
+
* extend: {
|
|
74
|
+
* animation: {
|
|
75
|
+
* shape: 'shape 5s linear infinite'
|
|
76
|
+
* },
|
|
77
|
+
* // ...
|
|
78
|
+
* }
|
|
79
|
+
* }
|
|
80
|
+
* ```
|
|
81
|
+
* You can choose to use special symbols as placeholders, to indicate whether to inject this property into the uno theme
|
|
82
|
+
*
|
|
83
|
+
* - `*` Abandon injection
|
|
84
|
+
* - `+` Injection, but the value is empty
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
*
|
|
88
|
+
* ```ts
|
|
89
|
+
* theme: {
|
|
90
|
+
* extend: {
|
|
91
|
+
* animation: {
|
|
92
|
+
* foo: 'foo 1s * 3',
|
|
93
|
+
* bar: 'bar 1s +',
|
|
94
|
+
* },
|
|
95
|
+
* // ...
|
|
96
|
+
* }
|
|
97
|
+
* }
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
*/
|
|
101
|
+
theme?: ZyyvTheme
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Enable the default preset
|
|
105
|
+
* Only works when `presets` is not specified
|
|
106
|
+
* @default true
|
|
107
|
+
*/
|
|
108
|
+
uno?: boolean | PresetUnoOptions
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Enable attributify mode and the options of it
|
|
112
|
+
* Only works when `presets` is not specified
|
|
113
|
+
* @default false
|
|
114
|
+
*/
|
|
115
|
+
attributify?: boolean | AttributifyOptions
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Enable icons preset and the options of it
|
|
119
|
+
* Only works when `presets` is not specified
|
|
120
|
+
* @default false
|
|
121
|
+
*/
|
|
122
|
+
icons?: boolean | IconsOptions
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Enable webFonts preset and the options of it
|
|
126
|
+
* Only works when `presets` is not specified
|
|
127
|
+
* @default false
|
|
128
|
+
*/
|
|
129
|
+
webFonts?: boolean | WebFontsOptions
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Enable typography preset and the options of it
|
|
133
|
+
* Only works when `presets` is not specified
|
|
134
|
+
* @default false
|
|
135
|
+
*/
|
|
136
|
+
typography?: boolean | TypographyOptions
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Enable tagify preset and the options of it
|
|
140
|
+
* Only works when `presets` is not specified
|
|
141
|
+
* @default false
|
|
142
|
+
*/
|
|
143
|
+
tagify?: boolean | TagifyOptions
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Enable remToPx preset and the options of it
|
|
147
|
+
* Only works when `presets` is not specified
|
|
148
|
+
* @default false
|
|
149
|
+
*/
|
|
150
|
+
remToPx?: boolean | RemToPxOptions
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
<br></details>
|
|
155
|
+
|
|
156
|
+
## Details
|
|
157
|
+
|
|
158
|
+
<details>
|
|
159
|
+
<summary>Expand it see more details</summary><br>
|
|
160
|
+
|
|
161
|
+
### extractors
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
// https://github.com/unocss/unocss/pull/2485
|
|
165
|
+
// Support extract base64 image.
|
|
166
|
+
export const extractors: Extractor[] = [
|
|
167
|
+
{
|
|
168
|
+
name: 'unocss-preset-zyyv-extractor-includes-base64',
|
|
169
|
+
order: 0,
|
|
170
|
+
extract({ code }) {
|
|
171
|
+
return [...new Set(code.split(/[\\:]?[\s'"`{}]|;(?!base64)+/g))]
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
]
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### postprocess
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
// https://github.com/unocss/unocss/discussions/2816
|
|
181
|
+
// Extract rgba color in css variable.
|
|
182
|
+
export function postprocessWithUnColor(unColor: string): Postprocessor {
|
|
183
|
+
return (util) => {
|
|
184
|
+
util.entries.forEach((i) => {
|
|
185
|
+
const value = i[1]
|
|
186
|
+
if (typeof value === 'string') {
|
|
187
|
+
const match = value.match(rgbaRE)
|
|
188
|
+
if (match != null) {
|
|
189
|
+
i[1] = value.replace(rgbaRE, `rgba(var(${unColor}),$2)`)
|
|
190
|
+
util.entries.unshift([unColor, match[1]])
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
})
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### rules
|
|
199
|
+
|
|
200
|
+
```ts
|
|
201
|
+
// Use any css variable easily.
|
|
202
|
+
export const rules: Rule[] = [
|
|
203
|
+
[/^(.+)::(.+)$/, ([, n, v], { theme }) => {
|
|
204
|
+
const color = parseColor(v, theme)
|
|
205
|
+
if (color?.cssColor?.type === 'rgb' && color.cssColor.components) {
|
|
206
|
+
return {
|
|
207
|
+
[`--${n}`]: `${color.cssColor.components.join(',')}`,
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return {
|
|
211
|
+
[`--${n}`]: v,
|
|
212
|
+
}
|
|
213
|
+
}],
|
|
214
|
+
]
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### shortcuts
|
|
218
|
+
|
|
219
|
+
```ts
|
|
220
|
+
// FYI. My own shortcuts.
|
|
221
|
+
const _shortcuts: CustomStaticShortcuts = [
|
|
222
|
+
// position
|
|
223
|
+
['pr', 'relative'],
|
|
224
|
+
['pa', 'absolute'],
|
|
225
|
+
['pf', 'fixed'],
|
|
226
|
+
['ps', 'sticky'],
|
|
227
|
+
|
|
228
|
+
// position layout
|
|
229
|
+
[['pxc', 'p-x-c'], 'pa left-1/2 -translate-x-1/2'],
|
|
230
|
+
[['pyc', 'p-y-c'], 'pa top-1/2 -translate-y-1/2'],
|
|
231
|
+
[['pcc', 'pc', 'p-c', 'p-c-c'], 'pxc pyc'],
|
|
232
|
+
|
|
233
|
+
// flex layout
|
|
234
|
+
[['f-c', 'fcc'], 'flex justify-center items-center'],
|
|
235
|
+
[['f-c-c', 'fccc'], 'f-c flex-col'],
|
|
236
|
+
[['fc', 'fxc', 'f-x-c'], 'flex justify-center'],
|
|
237
|
+
[['fi', 'fyc', 'f-y-c'], 'flex items-center'],
|
|
238
|
+
['fs', 'flex justify-start'],
|
|
239
|
+
['fsc', 'flex justify-start items-center'],
|
|
240
|
+
['fse', 'flex justify-start items-end'],
|
|
241
|
+
['fe', 'flex justify-end'],
|
|
242
|
+
['fec', 'flex justify-end items-center'],
|
|
243
|
+
['fb', 'flex justify-between'],
|
|
244
|
+
['fbc', 'flex justify-between items-center'],
|
|
245
|
+
['fa', 'flex justify-around'],
|
|
246
|
+
['fac', 'flex justify-around items-center'],
|
|
247
|
+
['fw', 'flex justify-wrap'],
|
|
248
|
+
['fwr', 'flex justify-wrap-reverse'],
|
|
249
|
+
|
|
250
|
+
// transition
|
|
251
|
+
['trans', 'transition-all-350 ease-linear'],
|
|
252
|
+
]
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### magic-animate
|
|
256
|
+
|
|
257
|
+
```ts
|
|
258
|
+
export function magicAnimate(): Theme['animation'] {
|
|
259
|
+
const keyframesObj = getKeyframes(magicCSS)
|
|
260
|
+
|
|
261
|
+
function generate<T = string>(val?: T): Record<string, T> {
|
|
262
|
+
return Object.keys(keyframesObj).reduce((acc, key) => {
|
|
263
|
+
const name = key.replace('@keyframes ', '')
|
|
264
|
+
// @ts-expect-error nothing
|
|
265
|
+
acc[name] = val ?? `{${cssObj2StrSync(keyframesObj[key])}}`
|
|
266
|
+
return acc
|
|
267
|
+
}, {})
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return {
|
|
271
|
+
keyframes: generate(),
|
|
272
|
+
durations: generate('1s'),
|
|
273
|
+
properties: generate({ 'animation-fill-mode': 'both' }),
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
<br></details>
|
|
279
|
+
|
|
280
|
+
## License
|
|
281
|
+
|
|
282
|
+
[MIT](./LICENSE) License © 2022 [zyyv](https://github.com/zyyv)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { definePreset } from "@unocss/core";
|
|
2
|
+
|
|
3
|
+
//#region ../../node_modules/.pnpm/@unocss+preset-rem-to-px@66.5.10/node_modules/@unocss/preset-rem-to-px/dist/index.mjs
|
|
4
|
+
const remRE = /(-?[.\d]+)rem/g;
|
|
5
|
+
const presetRemToPx = definePreset((options = {}) => {
|
|
6
|
+
const { baseFontSize = 16 } = options;
|
|
7
|
+
return {
|
|
8
|
+
name: "@unocss/preset-rem-to-px",
|
|
9
|
+
postprocess: (util) => {
|
|
10
|
+
util.entries.forEach((i) => {
|
|
11
|
+
const value = i[1];
|
|
12
|
+
if (typeof value === "string" && remRE.test(value)) i[1] = value.replace(remRE, (_, p1) => `${p1 * baseFontSize}px`);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { presetRemToPx as default, presetRemToPx };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import * as _unocss_core0 from "@unocss/core";
|
|
2
|
+
import { CSSObject, StaticShortcut } from "@unocss/core";
|
|
3
|
+
import { UserConfig } from "unocss";
|
|
4
|
+
import { AttributifyOptions } from "@unocss/preset-attributify";
|
|
5
|
+
import { IconsOptions } from "@unocss/preset-icons";
|
|
6
|
+
import { RemToPxOptions } from "@unocss/preset-rem-to-px";
|
|
7
|
+
import { TagifyOptions } from "@unocss/preset-tagify";
|
|
8
|
+
import { TypographyOptions } from "@unocss/preset-typography";
|
|
9
|
+
import { WebFontsOptions } from "@unocss/preset-web-fonts";
|
|
10
|
+
import { PresetWind3Options, Theme } from "@unocss/preset-wind3";
|
|
11
|
+
import { PresetWind4Options, Theme as Theme$1 } from "@unocss/preset-wind4";
|
|
12
|
+
import { CompileClassOptions } from "@unocss/transformer-compile-class";
|
|
13
|
+
import { TransformerDirectivesOptions } from "@unocss/transformer-directives";
|
|
14
|
+
import { TransformerVariantGroupOptions } from "@unocss/transformer-variant-group";
|
|
15
|
+
import { ThemeAnimation } from "@unocss/preset-mini";
|
|
16
|
+
|
|
17
|
+
//#region src/types.d.ts
|
|
18
|
+
type CustomStaticShortcut = [string | string[], StaticShortcut[1]] | [string | string[], StaticShortcut[1], StaticShortcut[2]];
|
|
19
|
+
type CustomStaticShortcuts = CustomStaticShortcut[];
|
|
20
|
+
type Objectiable<T> = Record<string, T>;
|
|
21
|
+
type CSSKeyframesRule = Objectiable<CSSObject>;
|
|
22
|
+
interface ZyyvExtends extends Exclude<ZyyvTheme, 'extend'> {
|
|
23
|
+
keyframes?: Record<string, CSSKeyframesRule>;
|
|
24
|
+
/**
|
|
25
|
+
* Different from the original, you can use the following formats:
|
|
26
|
+
*
|
|
27
|
+
* ```ts
|
|
28
|
+
* { name : 'name duration timing-function iteration-count' }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
animation?: Objectiable<string>;
|
|
32
|
+
}
|
|
33
|
+
interface ZyyvTheme extends Omit<Theme, 'container' | 'containers'>, Theme$1 {
|
|
34
|
+
extend?: ZyyvExtends;
|
|
35
|
+
}
|
|
36
|
+
interface PostprocessOptions {
|
|
37
|
+
/**
|
|
38
|
+
* Make all unitilities important.
|
|
39
|
+
*
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
important?: boolean | ImportantOptions;
|
|
43
|
+
/**
|
|
44
|
+
* Extract rgba color in css variable, default key name is `--un-color`
|
|
45
|
+
*
|
|
46
|
+
* Only works when `wind3` is enabled
|
|
47
|
+
*
|
|
48
|
+
* @default false
|
|
49
|
+
*/
|
|
50
|
+
unColor?: boolean | string;
|
|
51
|
+
}
|
|
52
|
+
type FilterPattern = Array<string | RegExp> | string | RegExp | null;
|
|
53
|
+
interface ImportantOptions {
|
|
54
|
+
/**
|
|
55
|
+
* Make all unitilities important.
|
|
56
|
+
*
|
|
57
|
+
*/
|
|
58
|
+
includes?: FilterPattern;
|
|
59
|
+
/**
|
|
60
|
+
* Make all unitilities important.
|
|
61
|
+
*
|
|
62
|
+
*/
|
|
63
|
+
excludes?: FilterPattern;
|
|
64
|
+
}
|
|
65
|
+
interface ZyyvOptions {
|
|
66
|
+
/**
|
|
67
|
+
* Enable built-in postprocess
|
|
68
|
+
*
|
|
69
|
+
* @default false
|
|
70
|
+
*/
|
|
71
|
+
postprocess?: boolean | PostprocessOptions;
|
|
72
|
+
shortcuts?: boolean | {
|
|
73
|
+
/**
|
|
74
|
+
* Enable default shortcuts
|
|
75
|
+
*
|
|
76
|
+
* @default true
|
|
77
|
+
*/
|
|
78
|
+
default?: boolean;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Improve theme to be more useful, and align with Tailwind theme configuration
|
|
82
|
+
*
|
|
83
|
+
* - Add `animation` to theme, Expand theme animation name usage
|
|
84
|
+
*
|
|
85
|
+
* [ name, duration, timing-function, iteration-count ]
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
*
|
|
89
|
+
* ```ts
|
|
90
|
+
* theme: {
|
|
91
|
+
* extend: {
|
|
92
|
+
* animation: {
|
|
93
|
+
* shape: 'shape 5s linear infinite'
|
|
94
|
+
* },
|
|
95
|
+
* // ...
|
|
96
|
+
* }
|
|
97
|
+
* }
|
|
98
|
+
* ```
|
|
99
|
+
* You can choose to use special symbols as placeholders, to indicate whether to inject this property into the uno theme
|
|
100
|
+
*
|
|
101
|
+
* - `*` Abandon injection
|
|
102
|
+
* - `+` Injection, but the value is empty
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
*
|
|
106
|
+
* ```ts
|
|
107
|
+
* theme: {
|
|
108
|
+
* extend: {
|
|
109
|
+
* animation: {
|
|
110
|
+
* foo: 'foo 1s * 3',
|
|
111
|
+
* bar: 'bar 1s +',
|
|
112
|
+
* },
|
|
113
|
+
* // ...
|
|
114
|
+
* }
|
|
115
|
+
* }
|
|
116
|
+
* ```
|
|
117
|
+
*
|
|
118
|
+
*/
|
|
119
|
+
theme?: ZyyvTheme;
|
|
120
|
+
/**
|
|
121
|
+
* Enable the default preset for preset-wind3
|
|
122
|
+
* Only works when `presets` is not specified
|
|
123
|
+
*
|
|
124
|
+
* @about [@unocss/preset-wind3](https://unocss.dev/presets/wind3)
|
|
125
|
+
* @default false
|
|
126
|
+
*/
|
|
127
|
+
wind3?: boolean | PresetWind3Options;
|
|
128
|
+
/**
|
|
129
|
+
* Enable the default preset for preset-wind4
|
|
130
|
+
* Only works when `presets` is not specified
|
|
131
|
+
*
|
|
132
|
+
* After v1.0.0, wind4 is the default preset
|
|
133
|
+
*
|
|
134
|
+
* @about [@unocss/preset-wind4](https://unocss.dev/presets/wind4)
|
|
135
|
+
* @default true
|
|
136
|
+
*/
|
|
137
|
+
wind4?: boolean | PresetWind4Options;
|
|
138
|
+
/**
|
|
139
|
+
* Enable attributify mode and the options of it
|
|
140
|
+
* Only works when `presets` is not specified
|
|
141
|
+
*
|
|
142
|
+
* @about [@unocss/preset-attributify](https://unocss.dev/presets/attributify)
|
|
143
|
+
* @default false
|
|
144
|
+
*/
|
|
145
|
+
attributify?: boolean | AttributifyOptions;
|
|
146
|
+
/**
|
|
147
|
+
* Enable icons preset and the options of it
|
|
148
|
+
* Only works when `presets` is not specified
|
|
149
|
+
*
|
|
150
|
+
* @about [@unocss/preset-icons](https://unocss.dev/presets/icons)
|
|
151
|
+
* @default false
|
|
152
|
+
*/
|
|
153
|
+
icons?: boolean | IconsOptions;
|
|
154
|
+
/**
|
|
155
|
+
* Enable webFonts preset and the options of it
|
|
156
|
+
* Only works when `presets` is not specified
|
|
157
|
+
*
|
|
158
|
+
* **Note:** Default by [`fontsource`](https://fontsource.org/) provider
|
|
159
|
+
*
|
|
160
|
+
* @about [@unocss/preset-web-fonts](https://unocss.dev/presets/web-fonts)
|
|
161
|
+
* @default false
|
|
162
|
+
*/
|
|
163
|
+
webFonts?: boolean | WebFontsOptions;
|
|
164
|
+
/**
|
|
165
|
+
* Enable typography preset and the options of it
|
|
166
|
+
* Only works when `presets` is not specified
|
|
167
|
+
*
|
|
168
|
+
* @about [@unocss/preset-typography](https://unocss.dev/presets/typography)
|
|
169
|
+
* @default false
|
|
170
|
+
*/
|
|
171
|
+
typography?: boolean | TypographyOptions;
|
|
172
|
+
/**
|
|
173
|
+
* Enable tagify preset and the options of it
|
|
174
|
+
* Only works when `presets` is not specified
|
|
175
|
+
*
|
|
176
|
+
* @about [@unocss/preset-tagify](https://unocss.dev/presets/tagify)
|
|
177
|
+
* @default false
|
|
178
|
+
*/
|
|
179
|
+
tagify?: boolean | TagifyOptions;
|
|
180
|
+
/**
|
|
181
|
+
* Enable remToPx preset and the options of it
|
|
182
|
+
* Only works when `presets` is not specified
|
|
183
|
+
*
|
|
184
|
+
* @about [@unocss/preset-rem-to-px](https://unocss.dev/presets/rem-to-px)
|
|
185
|
+
* @default false
|
|
186
|
+
*/
|
|
187
|
+
remToPx?: boolean | RemToPxOptions;
|
|
188
|
+
/**
|
|
189
|
+
* Enable magicss preset
|
|
190
|
+
*
|
|
191
|
+
* @about [unocss-preset-magicss](https://github.com/unpreset/unocss-preset-magicss)
|
|
192
|
+
* @default false
|
|
193
|
+
*/
|
|
194
|
+
magicss?: boolean;
|
|
195
|
+
/**
|
|
196
|
+
* Enable directives transformer and the options of it
|
|
197
|
+
*
|
|
198
|
+
* @about [@unocss/transformer-directives](https://unocss.dev/transformers/directives)
|
|
199
|
+
* @default true
|
|
200
|
+
*/
|
|
201
|
+
directives?: boolean | TransformerDirectivesOptions;
|
|
202
|
+
/**
|
|
203
|
+
* Enables the variant group feature of Windi CSS for UnoCSS.
|
|
204
|
+
*
|
|
205
|
+
* @about [@unocss/transformer-variant-group](https://unocss.dev/transformers/variant-group)
|
|
206
|
+
* @default true
|
|
207
|
+
*/
|
|
208
|
+
variantGroup?: boolean | TransformerVariantGroupOptions;
|
|
209
|
+
/**
|
|
210
|
+
* Compile group of classes into one class
|
|
211
|
+
*
|
|
212
|
+
* @about [@unocss/transformer-class-group](https://unocss.dev/transformers/compile-class)
|
|
213
|
+
* @default false
|
|
214
|
+
*/
|
|
215
|
+
compileClass?: boolean | CompileClassOptions;
|
|
216
|
+
}
|
|
217
|
+
type DeepPartial<T> = { [P in keyof T]?: DeepPartial<T[P]> };
|
|
218
|
+
//#endregion
|
|
219
|
+
//#region src/utils.d.ts
|
|
220
|
+
declare const animationRegExp: RegExp;
|
|
221
|
+
/**
|
|
222
|
+
* Normalize custom animate usage to UnoCSS animations theme.
|
|
223
|
+
*
|
|
224
|
+
* ⚠️ You must strictly follow the following format. ⚠️
|
|
225
|
+
*
|
|
226
|
+
* [ name, duration, timing-function, iteration-count ]
|
|
227
|
+
*
|
|
228
|
+
* If you use * as placeholder, it will be ignored.
|
|
229
|
+
*
|
|
230
|
+
* [name, duration, *, iteration-count]
|
|
231
|
+
*
|
|
232
|
+
* If you use + as placeholder, it will be replaced with empty string.
|
|
233
|
+
*
|
|
234
|
+
* [name, duration, +, iteration-count]
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
*
|
|
238
|
+
* { animate: ['spin 1s linear infinite'] }
|
|
239
|
+
*
|
|
240
|
+
* Will be transformd:
|
|
241
|
+
*
|
|
242
|
+
* {
|
|
243
|
+
* animate: ['spin 1s linear infinite'],
|
|
244
|
+
* durations: {
|
|
245
|
+
* spin: '1s',
|
|
246
|
+
* },
|
|
247
|
+
* timingFns: {
|
|
248
|
+
* spin: 'linear',
|
|
249
|
+
* },
|
|
250
|
+
* counts: {
|
|
251
|
+
* spin: 'infinite',
|
|
252
|
+
* },
|
|
253
|
+
* }
|
|
254
|
+
*/
|
|
255
|
+
declare function resolveAnimation(extend_animation: Objectiable<string>): {
|
|
256
|
+
animation: ThemeAnimation;
|
|
257
|
+
shortcuts: CustomStaticShortcuts;
|
|
258
|
+
};
|
|
259
|
+
/**
|
|
260
|
+
* Deep merge two objects.
|
|
261
|
+
* @param original Original object
|
|
262
|
+
* @param patch Patch object
|
|
263
|
+
* @returns Merged object
|
|
264
|
+
*/
|
|
265
|
+
declare function deepMerge<T>(original: T, patch: DeepPartial<T>): T;
|
|
266
|
+
declare function isObject(val: unknown): val is Record<any, any>;
|
|
267
|
+
declare function getKeyframes(css: string): Record<string, Record<string, CSSObject>>;
|
|
268
|
+
declare function cssObj2StrSync(style: Record<string, CSSObject>): string;
|
|
269
|
+
declare function stringifyObj(obj: CSSObject): string;
|
|
270
|
+
declare function cssObj2StrAsync(style: Record<string, CSSObject>): Promise<string>;
|
|
271
|
+
declare function toArray<T>(val: T | T[]): T[];
|
|
272
|
+
declare function camelToHyphen(str: string): string;
|
|
273
|
+
//#endregion
|
|
274
|
+
//#region src/index.d.ts
|
|
275
|
+
declare const presetZyyv: _unocss_core0.PresetFactoryAwaitable<ZyyvTheme, ZyyvOptions>;
|
|
276
|
+
declare const presetUseful: _unocss_core0.PresetFactoryAwaitable<ZyyvTheme, ZyyvOptions>;
|
|
277
|
+
declare function defineConfig<T extends object = ZyyvTheme>(config: UserConfig<T>): UserConfig<T>;
|
|
278
|
+
declare function defineZyyvConfig<T extends object = ZyyvTheme>(options?: ZyyvOptions, config?: UserConfig<T>): UserConfig<object>;
|
|
279
|
+
declare const defineUsefulConfig: typeof defineZyyvConfig;
|
|
280
|
+
//#endregion
|
|
281
|
+
export { type ZyyvOptions, type ZyyvTheme, animationRegExp, camelToHyphen, cssObj2StrAsync, cssObj2StrSync, deepMerge, presetZyyv as default, presetZyyv, defineConfig, defineUsefulConfig, defineZyyvConfig, getKeyframes, isObject, presetUseful, resolveAnimation, stringifyObj, toArray };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
import { definePreset, mergeConfigs, symbols, toArray as toArray$1 } from "@unocss/core";
|
|
2
|
+
import postcss from "postcss";
|
|
3
|
+
import postcssJs, { objectify } from "postcss-js";
|
|
4
|
+
|
|
5
|
+
//#region src/core/extractors.ts
|
|
6
|
+
const extractors = [{
|
|
7
|
+
name: "unocss-preset-zyyv-extractor-includes-base64",
|
|
8
|
+
order: 0,
|
|
9
|
+
extract({ code }) {
|
|
10
|
+
return [...new Set(code.split(/[\\:]?[\s'"`{}]|;(?!base64)+/g))];
|
|
11
|
+
}
|
|
12
|
+
}];
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/core/postprocess/important.ts
|
|
16
|
+
function createFilter(include, exclude) {
|
|
17
|
+
const includePattern = toArray$1(include || []);
|
|
18
|
+
const excludePattern = toArray$1(exclude || []);
|
|
19
|
+
return (id) => {
|
|
20
|
+
if (excludePattern.some((p) => id.match(p))) return false;
|
|
21
|
+
return includePattern.some((p) => id.match(p));
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function importantProcess(importantOptions) {
|
|
25
|
+
const keyFilter = createFilter(importantOptions.includes, importantOptions.excludes);
|
|
26
|
+
function nonKeysValidate(key) {
|
|
27
|
+
return !key.startsWith("$$") && ![
|
|
28
|
+
"syntax",
|
|
29
|
+
"initial-value",
|
|
30
|
+
"inherits"
|
|
31
|
+
].includes(key);
|
|
32
|
+
}
|
|
33
|
+
return (util) => {
|
|
34
|
+
for (const item of util.entries) if (keyFilter(item[0]) && nonKeysValidate(item[0])) {
|
|
35
|
+
if (item[1] != null && !String(item[1]).includes("!important")) item[1] += " !important";
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/core/postprocess/uncolor.ts
|
|
42
|
+
const rgbRE = /rgb\(([\d\s]+?)\s*\/\s*([^)]+)\)/;
|
|
43
|
+
const rgbaRE = /rgba\(([\d\s,]+),\s*([^)]+)\)/;
|
|
44
|
+
function postprocessWithUnColor(unColor) {
|
|
45
|
+
return (util) => {
|
|
46
|
+
util.entries.forEach((i) => {
|
|
47
|
+
const value = i[1];
|
|
48
|
+
if (typeof value === "string") {
|
|
49
|
+
let match = value.match(rgbaRE);
|
|
50
|
+
if (match != null) {
|
|
51
|
+
i[1] = value.replace(rgbaRE, `rgba(var(${unColor}) , $2)`);
|
|
52
|
+
util.entries.unshift([unColor, match[1]]);
|
|
53
|
+
} else {
|
|
54
|
+
match = value.match(rgbRE);
|
|
55
|
+
if (match != null) {
|
|
56
|
+
i[1] = value.replace(rgbRE, `rgb(var(${unColor}) / $2)`);
|
|
57
|
+
util.entries.unshift([unColor, match[1].trim()]);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/core/postprocess/index.ts
|
|
67
|
+
function postprocess(options) {
|
|
68
|
+
const { unColor, important } = options;
|
|
69
|
+
return [unColor ? postprocessWithUnColor(unColor) : void 0, important ? importantProcess(important) : void 0].filter(Boolean);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/core/preflights/index.ts
|
|
74
|
+
function preflights() {
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/meta.ts
|
|
80
|
+
const PRESET_NAME = "zyyv";
|
|
81
|
+
const layerMeta = { layer: PRESET_NAME };
|
|
82
|
+
|
|
83
|
+
//#endregion
|
|
84
|
+
//#region src/core/rules.ts
|
|
85
|
+
const rules = [[/^([^:]+)::(\S|[^:]+)$/, ([, k, v]) => {
|
|
86
|
+
return { [`--${k}`]: v };
|
|
87
|
+
}], ["no-scrollbar", [{
|
|
88
|
+
"scrollbar-width": "none",
|
|
89
|
+
"-ms-overflow-style": "none"
|
|
90
|
+
}, {
|
|
91
|
+
[symbols.selector]: (s) => `${s}::-webkit-scrollbar`,
|
|
92
|
+
display: "none"
|
|
93
|
+
}]]];
|
|
94
|
+
normalizeRuleMeta(layerMeta);
|
|
95
|
+
function normalizeRuleMeta(ruleMeta) {
|
|
96
|
+
for (const r of rules) r[2] = Object.assign(r[2] || {}, ruleMeta);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/core/shortcuts.ts
|
|
101
|
+
const _shortcuts = [
|
|
102
|
+
["pr", "relative"],
|
|
103
|
+
["pa", "absolute"],
|
|
104
|
+
["pf", "fixed"],
|
|
105
|
+
["ps", "sticky"],
|
|
106
|
+
[["pxc", "p-x-c"], "pa left-1/2 -translate-x-1/2"],
|
|
107
|
+
[["pyc", "p-y-c"], "pa top-1/2 -translate-y-1/2"],
|
|
108
|
+
[[
|
|
109
|
+
"pcc",
|
|
110
|
+
"pc",
|
|
111
|
+
"p-c",
|
|
112
|
+
"p-c-c"
|
|
113
|
+
], "pxc pyc"],
|
|
114
|
+
[["fcc", "f-c"], "flex justify-center items-center"],
|
|
115
|
+
[["fccc", "f-c-c"], "f-c flex-col"],
|
|
116
|
+
[[
|
|
117
|
+
"fc",
|
|
118
|
+
"fxc",
|
|
119
|
+
"f-x-c"
|
|
120
|
+
], "flex justify-center"],
|
|
121
|
+
[[
|
|
122
|
+
"fi",
|
|
123
|
+
"fyc",
|
|
124
|
+
"f-y-c"
|
|
125
|
+
], "flex items-center"],
|
|
126
|
+
[["fs", "fxs"], "flex justify-start"],
|
|
127
|
+
["fsc", "flex justify-start items-center"],
|
|
128
|
+
["fse", "flex justify-start items-end"],
|
|
129
|
+
[["fe", "fxe"], "flex justify-end"],
|
|
130
|
+
["fec", "flex justify-end items-center"],
|
|
131
|
+
["fb", "flex justify-between"],
|
|
132
|
+
["fbc", "flex justify-between items-center"],
|
|
133
|
+
["fa", "flex justify-around"],
|
|
134
|
+
["fac", "flex justify-around items-center"],
|
|
135
|
+
["fw", "flex flex-wrap"],
|
|
136
|
+
["fwr", "flex flex-wrap-reverse"],
|
|
137
|
+
["trans", "transition-all-350 ease-DEFAULT"]
|
|
138
|
+
];
|
|
139
|
+
const shortcuts = normalizeShortcut(_shortcuts);
|
|
140
|
+
normalizeShortcutMeta(layerMeta);
|
|
141
|
+
function normalizeShortcutMeta(ruleMeta) {
|
|
142
|
+
for (const r of shortcuts) r[2] = Object.assign(r[2] || {}, ruleMeta);
|
|
143
|
+
}
|
|
144
|
+
function normalizeShortcut(shortcut) {
|
|
145
|
+
return shortcut.flatMap((s) => {
|
|
146
|
+
if (Array.isArray(s[0])) return s[0].map((i) => [
|
|
147
|
+
i,
|
|
148
|
+
s[1],
|
|
149
|
+
s[2]
|
|
150
|
+
]);
|
|
151
|
+
return [s];
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
//#endregion
|
|
156
|
+
//#region src/core/theme/index.ts
|
|
157
|
+
function nomarlizeTheme(theme) {
|
|
158
|
+
return { ...theme };
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
//#endregion
|
|
162
|
+
//#region src/core/variants/active.ts
|
|
163
|
+
const v_active = {
|
|
164
|
+
name: "@active",
|
|
165
|
+
match(matcher) {
|
|
166
|
+
if (!matcher.startsWith("@active")) return matcher;
|
|
167
|
+
return {
|
|
168
|
+
matcher: matcher.slice(8),
|
|
169
|
+
selector: (s) => `${s}.active`
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
//#endregion
|
|
175
|
+
//#region src/core/variants/index.ts
|
|
176
|
+
function variants(_options) {
|
|
177
|
+
return [v_active];
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
//#endregion
|
|
181
|
+
//#region src/utils.ts
|
|
182
|
+
const animationRegExp = /^([a-z-]+)\s+([0-9.]+m?s?|[*+])?\s?([a-z-]+(?:\([^)]+\))?|[*+])?\s*([a-z0-9-]+|[*+])?$/i;
|
|
183
|
+
/**
|
|
184
|
+
* Normalize custom animate usage to UnoCSS animations theme.
|
|
185
|
+
*
|
|
186
|
+
* ⚠️ You must strictly follow the following format. ⚠️
|
|
187
|
+
*
|
|
188
|
+
* [ name, duration, timing-function, iteration-count ]
|
|
189
|
+
*
|
|
190
|
+
* If you use * as placeholder, it will be ignored.
|
|
191
|
+
*
|
|
192
|
+
* [name, duration, *, iteration-count]
|
|
193
|
+
*
|
|
194
|
+
* If you use + as placeholder, it will be replaced with empty string.
|
|
195
|
+
*
|
|
196
|
+
* [name, duration, +, iteration-count]
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
*
|
|
200
|
+
* { animate: ['spin 1s linear infinite'] }
|
|
201
|
+
*
|
|
202
|
+
* Will be transformd:
|
|
203
|
+
*
|
|
204
|
+
* {
|
|
205
|
+
* animate: ['spin 1s linear infinite'],
|
|
206
|
+
* durations: {
|
|
207
|
+
* spin: '1s',
|
|
208
|
+
* },
|
|
209
|
+
* timingFns: {
|
|
210
|
+
* spin: 'linear',
|
|
211
|
+
* },
|
|
212
|
+
* counts: {
|
|
213
|
+
* spin: 'infinite',
|
|
214
|
+
* },
|
|
215
|
+
* }
|
|
216
|
+
*/
|
|
217
|
+
function resolveAnimation(extend_animation) {
|
|
218
|
+
const animation = {};
|
|
219
|
+
const keys = [
|
|
220
|
+
"durations",
|
|
221
|
+
"timingFns",
|
|
222
|
+
"counts"
|
|
223
|
+
];
|
|
224
|
+
const shortcuts$1 = [];
|
|
225
|
+
for (const k in extend_animation) {
|
|
226
|
+
const match = extend_animation[k].match(animationRegExp);
|
|
227
|
+
if (match != null) {
|
|
228
|
+
const [, name, duration, timing, count] = match;
|
|
229
|
+
const values = [
|
|
230
|
+
duration,
|
|
231
|
+
timing,
|
|
232
|
+
count
|
|
233
|
+
];
|
|
234
|
+
if (name !== k) shortcuts$1.push([`animate-${k}`, `animate-${name}`]);
|
|
235
|
+
for (let i = 0; i < keys.length; i++) {
|
|
236
|
+
const key = keys[i];
|
|
237
|
+
const value = values[i];
|
|
238
|
+
if (value != null) {
|
|
239
|
+
if (value === "*") continue;
|
|
240
|
+
if (animation[key]) animation[key][name] = values[i] === "+" ? "" : values[i];
|
|
241
|
+
else animation[key] = { [name]: values[i] === "+" ? "" : values[i] };
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return {
|
|
247
|
+
animation,
|
|
248
|
+
shortcuts: shortcuts$1
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Deep merge two objects.
|
|
253
|
+
* @param original Original object
|
|
254
|
+
* @param patch Patch object
|
|
255
|
+
* @returns Merged object
|
|
256
|
+
*/
|
|
257
|
+
function deepMerge(original, patch) {
|
|
258
|
+
const o = original;
|
|
259
|
+
const p = patch;
|
|
260
|
+
if (Array.isArray(o) && Array.isArray(p)) return [...o, ...p];
|
|
261
|
+
if (Array.isArray(o)) return [...o];
|
|
262
|
+
const output = { ...o };
|
|
263
|
+
if (isObject(o) && isObject(p)) Object.keys(p).forEach((key) => {
|
|
264
|
+
if (isObject(p[key])) if (!(key in o)) Object.assign(output, { [key]: p[key] });
|
|
265
|
+
else output[key] = deepMerge(o[key], p[key]);
|
|
266
|
+
else Object.assign(output, { [key]: p[key] });
|
|
267
|
+
});
|
|
268
|
+
return output;
|
|
269
|
+
}
|
|
270
|
+
function isObject(val) {
|
|
271
|
+
return val !== null && typeof val === "object";
|
|
272
|
+
}
|
|
273
|
+
function getKeyframes(css) {
|
|
274
|
+
const obj = objectify(postcss.parse(css));
|
|
275
|
+
return Object.keys(obj).reduce((acc, key) => {
|
|
276
|
+
if (key.startsWith("@keyframes")) acc[key] = obj[key];
|
|
277
|
+
return acc;
|
|
278
|
+
}, {});
|
|
279
|
+
}
|
|
280
|
+
function cssObj2StrSync(style) {
|
|
281
|
+
return Object.keys(style).reduce((str, key) => {
|
|
282
|
+
return `${str}${key}${stringifyObj(style[key])}`;
|
|
283
|
+
}, "").replace(/\n/g, "");
|
|
284
|
+
}
|
|
285
|
+
function stringifyObj(obj) {
|
|
286
|
+
return `{${Object.keys(obj).reduce((str, key) => {
|
|
287
|
+
return `${str}${camelToHyphen(key)}:${obj[key]};`;
|
|
288
|
+
}, "")}}`;
|
|
289
|
+
}
|
|
290
|
+
async function cssObj2StrAsync(style) {
|
|
291
|
+
return postcss().process(style, { parser: postcssJs }).then((result) => result.css);
|
|
292
|
+
}
|
|
293
|
+
function toArray(val) {
|
|
294
|
+
return Array.isArray(val) ? val : [val];
|
|
295
|
+
}
|
|
296
|
+
function camelToHyphen(str) {
|
|
297
|
+
return str.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
//#endregion
|
|
301
|
+
//#region src/resolve.ts
|
|
302
|
+
const defaultOptions = {
|
|
303
|
+
theme: {},
|
|
304
|
+
postprocess: {
|
|
305
|
+
important: false,
|
|
306
|
+
unColor: false
|
|
307
|
+
},
|
|
308
|
+
shortcuts: { default: true },
|
|
309
|
+
wind4: true,
|
|
310
|
+
wind3: false,
|
|
311
|
+
attributify: true,
|
|
312
|
+
icons: true,
|
|
313
|
+
webFonts: false,
|
|
314
|
+
typography: false,
|
|
315
|
+
tagify: false,
|
|
316
|
+
remToPx: false,
|
|
317
|
+
magicss: false,
|
|
318
|
+
directives: true,
|
|
319
|
+
variantGroup: true,
|
|
320
|
+
compileClass: false
|
|
321
|
+
};
|
|
322
|
+
const defaultPresetOptions = { webFonts: { provider: "fontsource" } };
|
|
323
|
+
const defaultPostprocessOptions = {
|
|
324
|
+
important: {
|
|
325
|
+
excludes: [],
|
|
326
|
+
includes: [/.*/g]
|
|
327
|
+
},
|
|
328
|
+
unColor: "--un-color"
|
|
329
|
+
};
|
|
330
|
+
async function resolveOptions(options) {
|
|
331
|
+
const optionsWithDefault = Object.assign({}, defaultOptions, options);
|
|
332
|
+
if (optionsWithDefault.wind4 && optionsWithDefault.wind3) {
|
|
333
|
+
console.warn("wind3 and wind4 are mutually exclusive, only one can be enabled");
|
|
334
|
+
optionsWithDefault.wind3 = false;
|
|
335
|
+
}
|
|
336
|
+
if (optionsWithDefault.postprocess === true) optionsWithDefault.postprocess = defaultPostprocessOptions;
|
|
337
|
+
else if (typeof optionsWithDefault.postprocess === "object") {
|
|
338
|
+
if (typeof optionsWithDefault.postprocess.important === "object") optionsWithDefault.postprocess.important = {
|
|
339
|
+
...defaultPostprocessOptions.important,
|
|
340
|
+
...optionsWithDefault.postprocess.important
|
|
341
|
+
};
|
|
342
|
+
else if (optionsWithDefault.postprocess.important === true) optionsWithDefault.postprocess.important = defaultPostprocessOptions.important;
|
|
343
|
+
if (optionsWithDefault.postprocess.unColor === true) optionsWithDefault.postprocess.unColor = defaultPostprocessOptions.unColor;
|
|
344
|
+
} else optionsWithDefault.postprocess = {};
|
|
345
|
+
const presets = await resolvePresets(optionsWithDefault);
|
|
346
|
+
const transformers = await resolveTransformers(optionsWithDefault);
|
|
347
|
+
const { theme: t_theme, shortcuts: shortcuts$1 } = resolveExtend(optionsWithDefault.theme.extend ?? {});
|
|
348
|
+
const _theme = deepMerge(optionsWithDefault.theme, t_theme);
|
|
349
|
+
return {
|
|
350
|
+
...optionsWithDefault,
|
|
351
|
+
theme: nomarlizeTheme(_theme),
|
|
352
|
+
meta: {
|
|
353
|
+
presets,
|
|
354
|
+
shortcuts: shortcuts$1,
|
|
355
|
+
transformers
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
function resolveExtend(extend) {
|
|
360
|
+
const _shortcuts$1 = [];
|
|
361
|
+
const { animation, keyframes } = extend;
|
|
362
|
+
const { animation: resolvedAnimation, shortcuts: shortcuts$1 } = resolveAnimation(animation ?? {});
|
|
363
|
+
_shortcuts$1.push(...shortcuts$1);
|
|
364
|
+
resolvedAnimation.keyframes = {};
|
|
365
|
+
for (const key in keyframes) resolvedAnimation.keyframes[key] = `{${cssObj2StrSync(keyframes[key])}}`;
|
|
366
|
+
return {
|
|
367
|
+
theme: { animation: resolvedAnimation },
|
|
368
|
+
shortcuts: _shortcuts$1
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
async function resolvePresets(options) {
|
|
372
|
+
const presets = [];
|
|
373
|
+
const presetMap = {
|
|
374
|
+
wind3: import("unocss").then((m) => m.presetWind3),
|
|
375
|
+
wind4: import("unocss").then((m) => m.presetWind4),
|
|
376
|
+
attributify: import("unocss").then((m) => m.presetAttributify),
|
|
377
|
+
icons: import("unocss").then((m) => m.presetIcons),
|
|
378
|
+
webFonts: import("unocss").then((m) => m.presetWebFonts),
|
|
379
|
+
typography: import("unocss").then((m) => m.presetTypography),
|
|
380
|
+
tagify: import("unocss").then((m) => m.presetTagify),
|
|
381
|
+
remToPx: import("./dist-sozkiTde.mjs").then((m) => m.presetRemToPx),
|
|
382
|
+
magicss: import("unocss-preset-magicss").then((m) => m.presetMagicss)
|
|
383
|
+
};
|
|
384
|
+
for (const [key, preset] of Object.entries(presetMap)) {
|
|
385
|
+
const option = options[key];
|
|
386
|
+
if (option) {
|
|
387
|
+
const p = await preset;
|
|
388
|
+
const presetOptions = defaultPresetOptions[key];
|
|
389
|
+
if (typeof option === "object") presets.push(p({
|
|
390
|
+
...presetOptions,
|
|
391
|
+
...option
|
|
392
|
+
}));
|
|
393
|
+
else presets.push(p(presetOptions ?? {}));
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
return presets;
|
|
397
|
+
}
|
|
398
|
+
async function resolveTransformers(options) {
|
|
399
|
+
const transformers = [];
|
|
400
|
+
const transformerMap = {
|
|
401
|
+
directives: import("unocss").then((m) => m.transformerDirectives),
|
|
402
|
+
variantGroup: import("unocss").then((m) => m.transformerVariantGroup),
|
|
403
|
+
compileClass: import("unocss").then((m) => m.transformerCompileClass)
|
|
404
|
+
};
|
|
405
|
+
for (const [key, transformer] of Object.entries(transformerMap)) {
|
|
406
|
+
const option = options[key];
|
|
407
|
+
if (option) {
|
|
408
|
+
const t = await transformer;
|
|
409
|
+
transformers.push(t(typeof option === "boolean" ? {} : option));
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
return transformers;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
//#endregion
|
|
416
|
+
//#region src/index.ts
|
|
417
|
+
const presetZyyv = definePreset(async (options) => {
|
|
418
|
+
const resolvedOptions = await resolveOptions(options ?? {});
|
|
419
|
+
const { theme, meta, shortcuts: userShortcuts } = resolvedOptions;
|
|
420
|
+
const shortcuts$1 = userShortcuts === true || typeof userShortcuts === "object" && userShortcuts.default !== false ? shortcuts : [];
|
|
421
|
+
return {
|
|
422
|
+
name: `unocss-preset-${PRESET_NAME}`,
|
|
423
|
+
layers: { [PRESET_NAME]: 2 },
|
|
424
|
+
rules,
|
|
425
|
+
theme,
|
|
426
|
+
variants: variants(resolvedOptions),
|
|
427
|
+
shortcuts: shortcuts$1,
|
|
428
|
+
extractors,
|
|
429
|
+
postprocess: postprocess(resolvedOptions.postprocess),
|
|
430
|
+
presets: meta.presets,
|
|
431
|
+
transformers: meta.transformers,
|
|
432
|
+
preflights: preflights(),
|
|
433
|
+
options: resolvedOptions
|
|
434
|
+
};
|
|
435
|
+
});
|
|
436
|
+
const presetUseful = presetZyyv;
|
|
437
|
+
var src_default = presetZyyv;
|
|
438
|
+
function defineConfig(config) {
|
|
439
|
+
return config;
|
|
440
|
+
}
|
|
441
|
+
function defineZyyvConfig(options = {}, config = {}) {
|
|
442
|
+
return mergeConfigs([defineConfig({ presets: [presetZyyv(options)] }), config]);
|
|
443
|
+
}
|
|
444
|
+
const defineUsefulConfig = defineZyyvConfig;
|
|
445
|
+
|
|
446
|
+
//#endregion
|
|
447
|
+
export { animationRegExp, camelToHyphen, cssObj2StrAsync, cssObj2StrSync, deepMerge, src_default as default, defineConfig, defineUsefulConfig, defineZyyvConfig, getKeyframes, isObject, presetUseful, presetZyyv, resolveAnimation, stringifyObj, toArray };
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "unocss-preset-zyyv",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "2.0.0-beta.1",
|
|
5
|
+
"description": "My useful preset about unocss usage.",
|
|
6
|
+
"author": "Chris <https://github.com/zyyv>",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"homepage": "https://github.com/unocss-community/unocss-preset-zyyv#readme",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/unocss-community/unocss-preset-zyyv.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/unocss-community/unocss-preset-zyyv/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"unocss",
|
|
18
|
+
"unocss-community",
|
|
19
|
+
"unocss-preset",
|
|
20
|
+
"unocss-preset-zyyv"
|
|
21
|
+
],
|
|
22
|
+
"sideEffects": false,
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.mts",
|
|
26
|
+
"import": "./dist/index.mjs"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"main": "./dist/index.mjs",
|
|
30
|
+
"module": "./dist/index.mjs",
|
|
31
|
+
"types": "./dist/index.d.mts",
|
|
32
|
+
"typesVersions": {
|
|
33
|
+
"*": {
|
|
34
|
+
"*": [
|
|
35
|
+
"./dist/*",
|
|
36
|
+
"./dist/index.d.ts"
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"files": [
|
|
41
|
+
"dist"
|
|
42
|
+
],
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"unocss": "^0.65.0 || >=65.4.0"
|
|
45
|
+
},
|
|
46
|
+
"peerDependenciesMeta": {
|
|
47
|
+
"unocss": {
|
|
48
|
+
"optional": true
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@unocss/core": "^66.5.10",
|
|
53
|
+
"postcss": "^8.5.6",
|
|
54
|
+
"postcss-js": "^5.0.2",
|
|
55
|
+
"unocss-preset-magicss": "^1.0.1"
|
|
56
|
+
},
|
|
57
|
+
"scripts": {
|
|
58
|
+
"build": "tsdown",
|
|
59
|
+
"stub": "tsdown --watch"
|
|
60
|
+
}
|
|
61
|
+
}
|