@unocss/core 0.45.14 → 0.45.19
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.cjs +28 -24
- package/dist/index.d.ts +12 -11
- package/dist/index.mjs +28 -24
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -282,12 +282,12 @@ function createValueHandler(handlers) {
|
|
|
282
282
|
return handler;
|
|
283
283
|
}
|
|
284
284
|
|
|
285
|
-
const splitCode = (code) => code.split(/\\?[\s'"`;={}]+/g).filter(isValidSelector);
|
|
285
|
+
const splitCode = (code) => [...new Set(code.split(/\\?[\s'"`;={}]+/g))].filter(isValidSelector);
|
|
286
286
|
const extractorSplit = {
|
|
287
287
|
name: "split",
|
|
288
288
|
order: 0,
|
|
289
289
|
extract({ code }) {
|
|
290
|
-
return
|
|
290
|
+
return splitCode(code);
|
|
291
291
|
}
|
|
292
292
|
};
|
|
293
293
|
|
|
@@ -374,13 +374,14 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
374
374
|
const rules = mergePresets("rules");
|
|
375
375
|
const rulesStaticMap = {};
|
|
376
376
|
const rulesSize = rules.length;
|
|
377
|
-
rules.
|
|
377
|
+
const rulesDynamic = rules.map((rule, i) => {
|
|
378
378
|
if (isStaticRule(rule)) {
|
|
379
379
|
const prefix = rule[2]?.prefix || "";
|
|
380
380
|
rulesStaticMap[prefix + rule[0]] = [i, rule[1], rule[2], rule];
|
|
381
|
-
|
|
381
|
+
return void 0;
|
|
382
382
|
}
|
|
383
|
-
|
|
383
|
+
return [i, ...rule];
|
|
384
|
+
}).filter(Boolean).reverse();
|
|
384
385
|
const theme = clone([
|
|
385
386
|
...sortedPresets.map((p) => p.theme || {}),
|
|
386
387
|
config.theme || {}
|
|
@@ -402,7 +403,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
402
403
|
layers,
|
|
403
404
|
theme,
|
|
404
405
|
rulesSize,
|
|
405
|
-
rulesDynamic
|
|
406
|
+
rulesDynamic,
|
|
406
407
|
rulesStaticMap,
|
|
407
408
|
preprocess: mergePresets("preprocess"),
|
|
408
409
|
postprocess: mergePresets("postprocess"),
|
|
@@ -415,7 +416,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
415
416
|
};
|
|
416
417
|
}
|
|
417
418
|
|
|
418
|
-
const version = "0.45.
|
|
419
|
+
const version = "0.45.19";
|
|
419
420
|
|
|
420
421
|
class UnoGenerator {
|
|
421
422
|
constructor(userConfig = {}, defaults = {}) {
|
|
@@ -451,7 +452,10 @@ class UnoGenerator {
|
|
|
451
452
|
};
|
|
452
453
|
for (const extractor of this.config.extractors) {
|
|
453
454
|
const result = await extractor.extract(context);
|
|
454
|
-
result
|
|
455
|
+
if (result) {
|
|
456
|
+
for (const token of result)
|
|
457
|
+
set.add(token);
|
|
458
|
+
}
|
|
455
459
|
}
|
|
456
460
|
return set;
|
|
457
461
|
}
|
|
@@ -716,14 +720,13 @@ class UnoGenerator {
|
|
|
716
720
|
}
|
|
717
721
|
async parseUtil(input, context, internal = false) {
|
|
718
722
|
const [raw, processed, variantHandlers] = isString(input) ? this.matchVariants(input) : input;
|
|
719
|
-
|
|
723
|
+
if (this.config.details)
|
|
720
724
|
context.rules = context.rules ?? [];
|
|
721
|
-
context.rules.push(r);
|
|
722
|
-
} : noop;
|
|
723
725
|
const staticMatch = this.config.rulesStaticMap[processed];
|
|
724
726
|
if (staticMatch) {
|
|
725
727
|
if (staticMatch[1] && (internal || !staticMatch[2]?.internal)) {
|
|
726
|
-
|
|
728
|
+
if (this.config.details)
|
|
729
|
+
context.rules.push(staticMatch[3]);
|
|
727
730
|
const index = staticMatch[0];
|
|
728
731
|
const entry = normalizeCSSEntries(staticMatch[1]);
|
|
729
732
|
const meta = staticMatch[2];
|
|
@@ -734,24 +737,24 @@ class UnoGenerator {
|
|
|
734
737
|
}
|
|
735
738
|
}
|
|
736
739
|
context.variantHandlers = variantHandlers;
|
|
737
|
-
const { rulesDynamic
|
|
738
|
-
for (
|
|
739
|
-
|
|
740
|
-
if (!rule)
|
|
740
|
+
const { rulesDynamic } = this.config;
|
|
741
|
+
for (const [i, matcher, handler, meta] of rulesDynamic) {
|
|
742
|
+
if (meta?.internal && !internal)
|
|
741
743
|
continue;
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
744
|
+
let unprefixed = processed;
|
|
745
|
+
if (meta?.prefix) {
|
|
746
|
+
if (!processed.startsWith(meta.prefix))
|
|
747
|
+
continue;
|
|
748
|
+
unprefixed = processed.slice(meta.prefix.length);
|
|
749
|
+
}
|
|
748
750
|
const match = unprefixed.match(matcher);
|
|
749
751
|
if (!match)
|
|
750
752
|
continue;
|
|
751
753
|
const result = await handler(match, context);
|
|
752
754
|
if (!result)
|
|
753
755
|
continue;
|
|
754
|
-
|
|
756
|
+
if (this.config.details)
|
|
757
|
+
context.rules.push([matcher, handler, meta]);
|
|
755
758
|
const entries = normalizeCSSValues(result).filter((i2) => i2.length);
|
|
756
759
|
if (entries.length) {
|
|
757
760
|
return entries.map((e2) => {
|
|
@@ -884,7 +887,8 @@ function applyScope(css, scope) {
|
|
|
884
887
|
function movePseudoElementsEnd(selector) {
|
|
885
888
|
const pseudoElements = selector.match(/::[\w-]+(\([\w-]+\))?/g);
|
|
886
889
|
if (pseudoElements) {
|
|
887
|
-
|
|
890
|
+
for (const e2 of pseudoElements)
|
|
891
|
+
selector = selector.replace(e2, "");
|
|
888
892
|
selector += pseudoElements.join("");
|
|
889
893
|
}
|
|
890
894
|
return selector;
|
package/dist/index.d.ts
CHANGED
|
@@ -129,7 +129,7 @@ declare class BetterMap<K, V> extends Map<K, V> {
|
|
|
129
129
|
map<R>(mapFn: (value: V, key: K) => R): R[];
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
declare function withLayer<T>(layer: string, rules: Rule<T>[]): Rule<T>[];
|
|
132
|
+
declare function withLayer<T extends {}>(layer: string, rules: Rule<T>[]): Rule<T>[];
|
|
133
133
|
|
|
134
134
|
declare const regexClassGroup: RegExp;
|
|
135
135
|
declare function expandVariantGroup(str: string, seperators?: string[], depth?: number): string;
|
|
@@ -183,7 +183,7 @@ interface ParsedColorValue {
|
|
|
183
183
|
*/
|
|
184
184
|
name: string;
|
|
185
185
|
/**
|
|
186
|
-
* Color scale,
|
|
186
|
+
* Color scale, preferably 000 - 999.
|
|
187
187
|
*/
|
|
188
188
|
no: string;
|
|
189
189
|
/**
|
|
@@ -223,7 +223,7 @@ interface RuleContext<Theme extends {} = {}> {
|
|
|
223
223
|
*/
|
|
224
224
|
variantMatch: VariantMatchedResult;
|
|
225
225
|
/**
|
|
226
|
-
*
|
|
226
|
+
* Construct a custom CSS rule.
|
|
227
227
|
* Variants and selector escaping will be handled automatically.
|
|
228
228
|
*/
|
|
229
229
|
constructCSS: (body: CSSEntries | CSSObject, overrideSelector?: string) => string;
|
|
@@ -271,7 +271,7 @@ interface PreflightContext<Theme extends {} = {}> {
|
|
|
271
271
|
}
|
|
272
272
|
interface Extractor {
|
|
273
273
|
name: string;
|
|
274
|
-
extract(ctx: ExtractorContext): Awaitable<Set<string> | undefined>;
|
|
274
|
+
extract(ctx: ExtractorContext): Awaitable<Set<string> | string[] | undefined>;
|
|
275
275
|
order?: number;
|
|
276
276
|
}
|
|
277
277
|
interface RuleMeta {
|
|
@@ -328,11 +328,11 @@ interface VariantHandlerContext {
|
|
|
328
328
|
*/
|
|
329
329
|
prefix: string;
|
|
330
330
|
/**
|
|
331
|
-
* Rewrite the output selector. Often be used to append
|
|
331
|
+
* Rewrite the output selector. Often be used to append pseudo classes.
|
|
332
332
|
*/
|
|
333
333
|
selector: string;
|
|
334
334
|
/**
|
|
335
|
-
* Rewrite the output selector. Often be used to append
|
|
335
|
+
* Rewrite the output selector. Often be used to append pseudo elements.
|
|
336
336
|
*/
|
|
337
337
|
pseudo: string;
|
|
338
338
|
/**
|
|
@@ -375,7 +375,7 @@ interface VariantHandler {
|
|
|
375
375
|
*/
|
|
376
376
|
order?: number;
|
|
377
377
|
/**
|
|
378
|
-
* Rewrite the output selector. Often be used to append
|
|
378
|
+
* Rewrite the output selector. Often be used to append pseudo classes or parents.
|
|
379
379
|
*/
|
|
380
380
|
selector?: (input: string, body: CSSEntries) => string | undefined;
|
|
381
381
|
/**
|
|
@@ -402,7 +402,7 @@ interface VariantObject<Theme extends {} = {}> {
|
|
|
402
402
|
*/
|
|
403
403
|
name?: string;
|
|
404
404
|
/**
|
|
405
|
-
* The entry function to match and rewrite the selector for
|
|
405
|
+
* The entry function to match and rewrite the selector for further processing.
|
|
406
406
|
*/
|
|
407
407
|
match: VariantFunction<Theme>;
|
|
408
408
|
/**
|
|
@@ -621,6 +621,7 @@ interface UnocssPluginContext<Config extends UserConfig = UserConfig> {
|
|
|
621
621
|
onInvalidate: (fn: () => void) => void;
|
|
622
622
|
root: string;
|
|
623
623
|
updateRoot: (root: string) => Promise<LoadConfigResult<Config>>;
|
|
624
|
+
getConfigFileList: () => string[];
|
|
624
625
|
}
|
|
625
626
|
interface SourceMap {
|
|
626
627
|
file?: string;
|
|
@@ -691,7 +692,7 @@ interface ResolvedConfig extends Omit<RequiredByKey<UserConfig, 'mergeSelectors'
|
|
|
691
692
|
preprocess: Preprocessor[];
|
|
692
693
|
postprocess: Postprocessor[];
|
|
693
694
|
rulesSize: number;
|
|
694
|
-
rulesDynamic:
|
|
695
|
+
rulesDynamic: [number, ...DynamicRule][];
|
|
695
696
|
rulesStaticMap: Record<string, [number, CSSObject | CSSEntries, RuleMeta | undefined, Rule] | undefined>;
|
|
696
697
|
autocomplete: {
|
|
697
698
|
templates: (AutoCompleteFunction | AutoCompleteTemplate)[];
|
|
@@ -761,12 +762,12 @@ interface GenerateOptions {
|
|
|
761
762
|
*/
|
|
762
763
|
safelist?: boolean;
|
|
763
764
|
/**
|
|
764
|
-
*
|
|
765
|
+
* Generate minified CSS
|
|
765
766
|
* @default false
|
|
766
767
|
*/
|
|
767
768
|
minify?: boolean;
|
|
768
769
|
/**
|
|
769
|
-
* @
|
|
770
|
+
* @experimental
|
|
770
771
|
*/
|
|
771
772
|
scope?: string;
|
|
772
773
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -278,12 +278,12 @@ function createValueHandler(handlers) {
|
|
|
278
278
|
return handler;
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
-
const splitCode = (code) => code.split(/\\?[\s'"`;={}]+/g).filter(isValidSelector);
|
|
281
|
+
const splitCode = (code) => [...new Set(code.split(/\\?[\s'"`;={}]+/g))].filter(isValidSelector);
|
|
282
282
|
const extractorSplit = {
|
|
283
283
|
name: "split",
|
|
284
284
|
order: 0,
|
|
285
285
|
extract({ code }) {
|
|
286
|
-
return
|
|
286
|
+
return splitCode(code);
|
|
287
287
|
}
|
|
288
288
|
};
|
|
289
289
|
|
|
@@ -370,13 +370,14 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
370
370
|
const rules = mergePresets("rules");
|
|
371
371
|
const rulesStaticMap = {};
|
|
372
372
|
const rulesSize = rules.length;
|
|
373
|
-
rules.
|
|
373
|
+
const rulesDynamic = rules.map((rule, i) => {
|
|
374
374
|
if (isStaticRule(rule)) {
|
|
375
375
|
const prefix = rule[2]?.prefix || "";
|
|
376
376
|
rulesStaticMap[prefix + rule[0]] = [i, rule[1], rule[2], rule];
|
|
377
|
-
|
|
377
|
+
return void 0;
|
|
378
378
|
}
|
|
379
|
-
|
|
379
|
+
return [i, ...rule];
|
|
380
|
+
}).filter(Boolean).reverse();
|
|
380
381
|
const theme = clone([
|
|
381
382
|
...sortedPresets.map((p) => p.theme || {}),
|
|
382
383
|
config.theme || {}
|
|
@@ -398,7 +399,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
398
399
|
layers,
|
|
399
400
|
theme,
|
|
400
401
|
rulesSize,
|
|
401
|
-
rulesDynamic
|
|
402
|
+
rulesDynamic,
|
|
402
403
|
rulesStaticMap,
|
|
403
404
|
preprocess: mergePresets("preprocess"),
|
|
404
405
|
postprocess: mergePresets("postprocess"),
|
|
@@ -411,7 +412,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
411
412
|
};
|
|
412
413
|
}
|
|
413
414
|
|
|
414
|
-
const version = "0.45.
|
|
415
|
+
const version = "0.45.19";
|
|
415
416
|
|
|
416
417
|
class UnoGenerator {
|
|
417
418
|
constructor(userConfig = {}, defaults = {}) {
|
|
@@ -447,7 +448,10 @@ class UnoGenerator {
|
|
|
447
448
|
};
|
|
448
449
|
for (const extractor of this.config.extractors) {
|
|
449
450
|
const result = await extractor.extract(context);
|
|
450
|
-
result
|
|
451
|
+
if (result) {
|
|
452
|
+
for (const token of result)
|
|
453
|
+
set.add(token);
|
|
454
|
+
}
|
|
451
455
|
}
|
|
452
456
|
return set;
|
|
453
457
|
}
|
|
@@ -712,14 +716,13 @@ class UnoGenerator {
|
|
|
712
716
|
}
|
|
713
717
|
async parseUtil(input, context, internal = false) {
|
|
714
718
|
const [raw, processed, variantHandlers] = isString(input) ? this.matchVariants(input) : input;
|
|
715
|
-
|
|
719
|
+
if (this.config.details)
|
|
716
720
|
context.rules = context.rules ?? [];
|
|
717
|
-
context.rules.push(r);
|
|
718
|
-
} : noop;
|
|
719
721
|
const staticMatch = this.config.rulesStaticMap[processed];
|
|
720
722
|
if (staticMatch) {
|
|
721
723
|
if (staticMatch[1] && (internal || !staticMatch[2]?.internal)) {
|
|
722
|
-
|
|
724
|
+
if (this.config.details)
|
|
725
|
+
context.rules.push(staticMatch[3]);
|
|
723
726
|
const index = staticMatch[0];
|
|
724
727
|
const entry = normalizeCSSEntries(staticMatch[1]);
|
|
725
728
|
const meta = staticMatch[2];
|
|
@@ -730,24 +733,24 @@ class UnoGenerator {
|
|
|
730
733
|
}
|
|
731
734
|
}
|
|
732
735
|
context.variantHandlers = variantHandlers;
|
|
733
|
-
const { rulesDynamic
|
|
734
|
-
for (
|
|
735
|
-
|
|
736
|
-
if (!rule)
|
|
736
|
+
const { rulesDynamic } = this.config;
|
|
737
|
+
for (const [i, matcher, handler, meta] of rulesDynamic) {
|
|
738
|
+
if (meta?.internal && !internal)
|
|
737
739
|
continue;
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
740
|
+
let unprefixed = processed;
|
|
741
|
+
if (meta?.prefix) {
|
|
742
|
+
if (!processed.startsWith(meta.prefix))
|
|
743
|
+
continue;
|
|
744
|
+
unprefixed = processed.slice(meta.prefix.length);
|
|
745
|
+
}
|
|
744
746
|
const match = unprefixed.match(matcher);
|
|
745
747
|
if (!match)
|
|
746
748
|
continue;
|
|
747
749
|
const result = await handler(match, context);
|
|
748
750
|
if (!result)
|
|
749
751
|
continue;
|
|
750
|
-
|
|
752
|
+
if (this.config.details)
|
|
753
|
+
context.rules.push([matcher, handler, meta]);
|
|
751
754
|
const entries = normalizeCSSValues(result).filter((i2) => i2.length);
|
|
752
755
|
if (entries.length) {
|
|
753
756
|
return entries.map((e2) => {
|
|
@@ -880,7 +883,8 @@ function applyScope(css, scope) {
|
|
|
880
883
|
function movePseudoElementsEnd(selector) {
|
|
881
884
|
const pseudoElements = selector.match(/::[\w-]+(\([\w-]+\))?/g);
|
|
882
885
|
if (pseudoElements) {
|
|
883
|
-
|
|
886
|
+
for (const e2 of pseudoElements)
|
|
887
|
+
selector = selector.replace(e2, "");
|
|
884
888
|
selector += pseudoElements.join("");
|
|
885
889
|
}
|
|
886
890
|
return selector;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/core",
|
|
3
|
-
"version": "0.45.
|
|
3
|
+
"version": "0.45.19",
|
|
4
4
|
"description": "The instant on-demand Atomic CSS engine.",
|
|
5
5
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"dist"
|
|
38
38
|
],
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"magic-string": "^0.26.
|
|
41
|
-
"unconfig": "^0.3.
|
|
40
|
+
"magic-string": "^0.26.3",
|
|
41
|
+
"unconfig": "^0.3.6"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "unbuild",
|