@unocss/core 0.12.4 → 0.12.8
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/index.d.ts +7 -2
- package/dist/index.js +44 -5
- package/dist/index.mjs +41 -5
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -194,7 +194,7 @@ interface GeneratorOptions {
|
|
|
194
194
|
*
|
|
195
195
|
* @default true
|
|
196
196
|
*/
|
|
197
|
-
|
|
197
|
+
warn?: boolean;
|
|
198
198
|
}
|
|
199
199
|
interface UserOnlyOptions<Theme extends {} = {}> {
|
|
200
200
|
/**
|
|
@@ -332,6 +332,11 @@ declare class BetterMap<K, V> extends Map<K, V> {
|
|
|
332
332
|
|
|
333
333
|
declare function withLayer<T>(layer: string, rules: Rule<T>[]): Rule<T>[];
|
|
334
334
|
|
|
335
|
+
declare const regexClassGroup: RegExp;
|
|
336
|
+
declare function expandVariantGroup(str: string): string;
|
|
337
|
+
|
|
338
|
+
declare function warnOnce(msg: string): void;
|
|
339
|
+
|
|
335
340
|
declare const extractorSplit: Extractor;
|
|
336
341
|
|
|
337
|
-
export { ArgumentType, Awaitable, BetterMap, BlocklistRule, CSSEntries, CSSObject, ConfigBase, DeepPartial, DynamicMatcher, DynamicRule, DynamicShortcut, DynamicShortcutMatcher, Extractor, ExtractorContext, FlatObjectTuple, GenerateOptions, GenerateResult, GeneratorOptions, ParsedUtil, PartialByKeys, Preflight, Preset, RawUtil, ResolvedConfig, RestArgs, Rule, RuleContext, RuleMeta, Shift, Shortcut, StaticRule, StaticShortcut, StaticShortcutMap, StringifiedUtil, TwoKeyMap, UnoGenerator, UserConfig, UserConfigDefaults, UserOnlyOptions, UserShortcuts, Variant, VariantFunction, VariantHandler, VariantMatchedResult, VariantObject, attributifyRE, createGenerator, e, entriesToCss, escapeRegExp, escapeSelector, extractorSplit, hasScopePlaceholder, hex2rgba, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isValidSelector, mergeDeep, mergeSet, normalizeVariant, toArray, uniq, validateFilterRE, withLayer };
|
|
342
|
+
export { ArgumentType, Awaitable, BetterMap, BlocklistRule, CSSEntries, CSSObject, ConfigBase, DeepPartial, DynamicMatcher, DynamicRule, DynamicShortcut, DynamicShortcutMatcher, Extractor, ExtractorContext, FlatObjectTuple, GenerateOptions, GenerateResult, GeneratorOptions, ParsedUtil, PartialByKeys, Preflight, Preset, RawUtil, ResolvedConfig, RestArgs, Rule, RuleContext, RuleMeta, Shift, Shortcut, StaticRule, StaticShortcut, StaticShortcutMap, StringifiedUtil, TwoKeyMap, UnoGenerator, UserConfig, UserConfigDefaults, UserOnlyOptions, UserShortcuts, Variant, VariantFunction, VariantHandler, VariantMatchedResult, VariantObject, attributifyRE, createGenerator, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit, hasScopePlaceholder, hex2rgba, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isValidSelector, mergeDeep, mergeSet, normalizeVariant, regexClassGroup, toArray, uniq, validateFilterRE, warnOnce, withLayer };
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,7 @@ __export(exports, {
|
|
|
17
17
|
entriesToCss: () => entriesToCss,
|
|
18
18
|
escapeRegExp: () => escapeRegExp,
|
|
19
19
|
escapeSelector: () => escapeSelector,
|
|
20
|
+
expandVariantGroup: () => expandVariantGroup,
|
|
20
21
|
extractorSplit: () => extractorSplit,
|
|
21
22
|
hasScopePlaceholder: () => hasScopePlaceholder,
|
|
22
23
|
hex2rgba: () => hex2rgba,
|
|
@@ -29,9 +30,11 @@ __export(exports, {
|
|
|
29
30
|
mergeDeep: () => mergeDeep,
|
|
30
31
|
mergeSet: () => mergeSet,
|
|
31
32
|
normalizeVariant: () => normalizeVariant,
|
|
33
|
+
regexClassGroup: () => regexClassGroup,
|
|
32
34
|
toArray: () => toArray,
|
|
33
35
|
uniq: () => uniq,
|
|
34
36
|
validateFilterRE: () => validateFilterRE,
|
|
37
|
+
warnOnce: () => warnOnce,
|
|
35
38
|
withLayer: () => withLayer
|
|
36
39
|
});
|
|
37
40
|
|
|
@@ -229,6 +232,34 @@ function withLayer(layer, rules) {
|
|
|
229
232
|
return rules;
|
|
230
233
|
}
|
|
231
234
|
|
|
235
|
+
// src/utils/variantGroup.ts
|
|
236
|
+
var regexClassGroup = /([!\w+:_/-]+?)([:-])\(((?:[!\w\s:/\\,%#.$-]|\[.*?\])*?)\)/gm;
|
|
237
|
+
function expandVariantGroup(str) {
|
|
238
|
+
const replaces = [];
|
|
239
|
+
let match;
|
|
240
|
+
while (match = regexClassGroup.exec(str)) {
|
|
241
|
+
const start = match.index;
|
|
242
|
+
const end = start + match[0].length;
|
|
243
|
+
const [, pre, sep, body] = match;
|
|
244
|
+
const replacement = body.split(/\s/g).map((i) => i.replace(/^(!?)(.*)/, `$1${pre}${sep}$2`)).join(" ");
|
|
245
|
+
replaces.unshift([start, end, replacement]);
|
|
246
|
+
}
|
|
247
|
+
let result = str;
|
|
248
|
+
replaces.forEach(([start, end, replacement]) => {
|
|
249
|
+
result = result.slice(0, start) + replacement + result.slice(end);
|
|
250
|
+
});
|
|
251
|
+
return result;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// src/utils/warn.ts
|
|
255
|
+
var warned = new Set();
|
|
256
|
+
function warnOnce(msg) {
|
|
257
|
+
if (warned.has(msg))
|
|
258
|
+
return;
|
|
259
|
+
console.warn("[unocss]", msg);
|
|
260
|
+
warned.add(msg);
|
|
261
|
+
}
|
|
262
|
+
|
|
232
263
|
// src/extractors/split.ts
|
|
233
264
|
var extractorSplit = {
|
|
234
265
|
name: "split",
|
|
@@ -284,7 +315,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
284
315
|
].reduce((a, p) => mergeDeep(a, p), {});
|
|
285
316
|
return {
|
|
286
317
|
mergeSelectors: true,
|
|
287
|
-
|
|
318
|
+
warn: true,
|
|
288
319
|
blocklist: [],
|
|
289
320
|
safelist: [],
|
|
290
321
|
presets: [],
|
|
@@ -305,7 +336,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
305
336
|
}
|
|
306
337
|
|
|
307
338
|
// package.json
|
|
308
|
-
var version = "0.12.
|
|
339
|
+
var version = "0.12.8";
|
|
309
340
|
|
|
310
341
|
// src/generator/index.ts
|
|
311
342
|
var UnoGenerator = class {
|
|
@@ -587,10 +618,10 @@ var UnoGenerator = class {
|
|
|
587
618
|
}
|
|
588
619
|
}
|
|
589
620
|
}
|
|
621
|
+
if (typeof result === "string")
|
|
622
|
+
result = expandVariantGroup(result).split(/\s+/g);
|
|
590
623
|
if (!result)
|
|
591
624
|
return;
|
|
592
|
-
if (typeof result === "string")
|
|
593
|
-
result = result.split(/ /g);
|
|
594
625
|
return [
|
|
595
626
|
result.flatMap((r) => {
|
|
596
627
|
var _a;
|
|
@@ -601,7 +632,12 @@ var UnoGenerator = class {
|
|
|
601
632
|
}
|
|
602
633
|
async stringifyShortcuts(parent, context, expanded, meta = { layer: this.config.shortcutsLayer }) {
|
|
603
634
|
const selectorMap = new TwoKeyMap();
|
|
604
|
-
const parsed = (await Promise.all(uniq(expanded).map(
|
|
635
|
+
const parsed = (await Promise.all(uniq(expanded).map(async (i) => {
|
|
636
|
+
const result = await this.parseUtil(i, context, true);
|
|
637
|
+
if (!result)
|
|
638
|
+
warnOnce(`unmatched utility "${i}" in shortcut "${parent[1]}"`);
|
|
639
|
+
return result;
|
|
640
|
+
}))).filter(Boolean).sort((a, b) => a[0] - b[0]);
|
|
605
641
|
const [raw, , parentVariants] = parent;
|
|
606
642
|
for (const item of parsed) {
|
|
607
643
|
if (isRawUtil(item))
|
|
@@ -654,6 +690,7 @@ function normalizeEntries(obj) {
|
|
|
654
690
|
entriesToCss,
|
|
655
691
|
escapeRegExp,
|
|
656
692
|
escapeSelector,
|
|
693
|
+
expandVariantGroup,
|
|
657
694
|
extractorSplit,
|
|
658
695
|
hasScopePlaceholder,
|
|
659
696
|
hex2rgba,
|
|
@@ -666,8 +703,10 @@ function normalizeEntries(obj) {
|
|
|
666
703
|
mergeDeep,
|
|
667
704
|
mergeSet,
|
|
668
705
|
normalizeVariant,
|
|
706
|
+
regexClassGroup,
|
|
669
707
|
toArray,
|
|
670
708
|
uniq,
|
|
671
709
|
validateFilterRE,
|
|
710
|
+
warnOnce,
|
|
672
711
|
withLayer
|
|
673
712
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -192,6 +192,34 @@ function withLayer(layer, rules) {
|
|
|
192
192
|
return rules;
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
+
// src/utils/variantGroup.ts
|
|
196
|
+
var regexClassGroup = /([!\w+:_/-]+?)([:-])\(((?:[!\w\s:/\\,%#.$-]|\[.*?\])*?)\)/gm;
|
|
197
|
+
function expandVariantGroup(str) {
|
|
198
|
+
const replaces = [];
|
|
199
|
+
let match;
|
|
200
|
+
while (match = regexClassGroup.exec(str)) {
|
|
201
|
+
const start = match.index;
|
|
202
|
+
const end = start + match[0].length;
|
|
203
|
+
const [, pre, sep, body] = match;
|
|
204
|
+
const replacement = body.split(/\s/g).map((i) => i.replace(/^(!?)(.*)/, `$1${pre}${sep}$2`)).join(" ");
|
|
205
|
+
replaces.unshift([start, end, replacement]);
|
|
206
|
+
}
|
|
207
|
+
let result = str;
|
|
208
|
+
replaces.forEach(([start, end, replacement]) => {
|
|
209
|
+
result = result.slice(0, start) + replacement + result.slice(end);
|
|
210
|
+
});
|
|
211
|
+
return result;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// src/utils/warn.ts
|
|
215
|
+
var warned = new Set();
|
|
216
|
+
function warnOnce(msg) {
|
|
217
|
+
if (warned.has(msg))
|
|
218
|
+
return;
|
|
219
|
+
console.warn("[unocss]", msg);
|
|
220
|
+
warned.add(msg);
|
|
221
|
+
}
|
|
222
|
+
|
|
195
223
|
// src/extractors/split.ts
|
|
196
224
|
var extractorSplit = {
|
|
197
225
|
name: "split",
|
|
@@ -247,7 +275,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
247
275
|
].reduce((a, p) => mergeDeep(a, p), {});
|
|
248
276
|
return {
|
|
249
277
|
mergeSelectors: true,
|
|
250
|
-
|
|
278
|
+
warn: true,
|
|
251
279
|
blocklist: [],
|
|
252
280
|
safelist: [],
|
|
253
281
|
presets: [],
|
|
@@ -268,7 +296,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
268
296
|
}
|
|
269
297
|
|
|
270
298
|
// package.json
|
|
271
|
-
var version = "0.12.
|
|
299
|
+
var version = "0.12.8";
|
|
272
300
|
|
|
273
301
|
// src/generator/index.ts
|
|
274
302
|
var UnoGenerator = class {
|
|
@@ -550,10 +578,10 @@ var UnoGenerator = class {
|
|
|
550
578
|
}
|
|
551
579
|
}
|
|
552
580
|
}
|
|
581
|
+
if (typeof result === "string")
|
|
582
|
+
result = expandVariantGroup(result).split(/\s+/g);
|
|
553
583
|
if (!result)
|
|
554
584
|
return;
|
|
555
|
-
if (typeof result === "string")
|
|
556
|
-
result = result.split(/ /g);
|
|
557
585
|
return [
|
|
558
586
|
result.flatMap((r) => {
|
|
559
587
|
var _a;
|
|
@@ -564,7 +592,12 @@ var UnoGenerator = class {
|
|
|
564
592
|
}
|
|
565
593
|
async stringifyShortcuts(parent, context, expanded, meta = { layer: this.config.shortcutsLayer }) {
|
|
566
594
|
const selectorMap = new TwoKeyMap();
|
|
567
|
-
const parsed = (await Promise.all(uniq(expanded).map(
|
|
595
|
+
const parsed = (await Promise.all(uniq(expanded).map(async (i) => {
|
|
596
|
+
const result = await this.parseUtil(i, context, true);
|
|
597
|
+
if (!result)
|
|
598
|
+
warnOnce(`unmatched utility "${i}" in shortcut "${parent[1]}"`);
|
|
599
|
+
return result;
|
|
600
|
+
}))).filter(Boolean).sort((a, b) => a[0] - b[0]);
|
|
568
601
|
const [raw, , parentVariants] = parent;
|
|
569
602
|
for (const item of parsed) {
|
|
570
603
|
if (isRawUtil(item))
|
|
@@ -616,6 +649,7 @@ export {
|
|
|
616
649
|
entriesToCss,
|
|
617
650
|
escapeRegExp,
|
|
618
651
|
escapeSelector,
|
|
652
|
+
expandVariantGroup,
|
|
619
653
|
extractorSplit,
|
|
620
654
|
hasScopePlaceholder,
|
|
621
655
|
hex2rgba,
|
|
@@ -628,8 +662,10 @@ export {
|
|
|
628
662
|
mergeDeep,
|
|
629
663
|
mergeSet,
|
|
630
664
|
normalizeVariant,
|
|
665
|
+
regexClassGroup,
|
|
631
666
|
toArray,
|
|
632
667
|
uniq,
|
|
633
668
|
validateFilterRE,
|
|
669
|
+
warnOnce,
|
|
634
670
|
withLayer
|
|
635
671
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/core",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.8",
|
|
4
4
|
"description": "The instant on-demand Atomic CSS engine.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"unocss",
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
"exports": {
|
|
27
27
|
".": {
|
|
28
28
|
"require": "./dist/index.js",
|
|
29
|
-
"import": "./dist/index.mjs"
|
|
29
|
+
"import": "./dist/index.mjs",
|
|
30
|
+
"types": "./dist/index.d.ts"
|
|
30
31
|
}
|
|
31
32
|
},
|
|
32
33
|
"main": "dist/index.js",
|