@unocss/core 0.46.5 → 0.47.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/dist/index.cjs +18 -3
- package/dist/index.d.ts +46 -45
- package/dist/index.mjs +18 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -219,7 +219,7 @@ function withLayer(layer, rules) {
|
|
|
219
219
|
return rules;
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
-
const regexClassGroup = /((?:[!\w+:_/-]|\[&?>?:?.*\])+?)([:-])\(((?:[~!\w\s:/\\,%#.$-]|\[.*?\])
|
|
222
|
+
const regexClassGroup = /((?:[!\w+:_/-]|\[&?>?:?.*\])+?)([:-])\(((?:[~!\w\s:/\\,%#.$-]|\[.*?\])+?)\)(?!\s*?=>)/gm;
|
|
223
223
|
function expandVariantGroup(str, seperators = ["-", ":"], depth = 5) {
|
|
224
224
|
regexClassGroup.lastIndex = 0;
|
|
225
225
|
let hasChanged = false;
|
|
@@ -282,7 +282,21 @@ function createValueHandler(handlers) {
|
|
|
282
282
|
return handler;
|
|
283
283
|
}
|
|
284
284
|
|
|
285
|
-
const
|
|
285
|
+
const defaultSplitRE = /\\?[\s'"`;{}]+/g;
|
|
286
|
+
const arbitraryPropertyRE = /\[(\\\W|[\w-])+:['"]?\S+?['"]?\]/g;
|
|
287
|
+
const arbitraryPropertyCandidateRE = new RegExp(`^${arbitraryPropertyRE.source}$`);
|
|
288
|
+
const splitCode = (code) => {
|
|
289
|
+
const result = /* @__PURE__ */ new Set();
|
|
290
|
+
for (const match of code.matchAll(arbitraryPropertyRE)) {
|
|
291
|
+
if (!code[match.index - 1]?.match(/^[\s'"`]/))
|
|
292
|
+
continue;
|
|
293
|
+
result.add(match[0]);
|
|
294
|
+
}
|
|
295
|
+
code.split(defaultSplitRE).forEach((match) => {
|
|
296
|
+
isValidSelector(match) && !arbitraryPropertyCandidateRE.test(match) && result.add(match);
|
|
297
|
+
});
|
|
298
|
+
return [...result];
|
|
299
|
+
};
|
|
286
300
|
const extractorSplit = {
|
|
287
301
|
name: "split",
|
|
288
302
|
order: 0,
|
|
@@ -417,7 +431,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
417
431
|
};
|
|
418
432
|
}
|
|
419
433
|
|
|
420
|
-
const version = "0.
|
|
434
|
+
const version = "0.47.1";
|
|
421
435
|
|
|
422
436
|
class UnoGenerator {
|
|
423
437
|
constructor(userConfig = {}, defaults = {}) {
|
|
@@ -904,6 +918,7 @@ exports.BetterMap = BetterMap;
|
|
|
904
918
|
exports.CONTROL_SHORTCUT_NO_MERGE = CONTROL_SHORTCUT_NO_MERGE;
|
|
905
919
|
exports.TwoKeyMap = TwoKeyMap;
|
|
906
920
|
exports.UnoGenerator = UnoGenerator;
|
|
921
|
+
exports.arbitraryPropertyRE = arbitraryPropertyRE;
|
|
907
922
|
exports.attributifyRE = attributifyRE;
|
|
908
923
|
exports.clearIdenticalEntries = clearIdenticalEntries;
|
|
909
924
|
exports.clone = clone;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LoadConfigResult } from 'unconfig';
|
|
2
2
|
import MagicString from 'magic-string';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
type EventsMap = Record<string, any>;
|
|
5
5
|
interface DefaultEvents extends EventsMap {
|
|
6
6
|
[event: string]: (...args: any) => void;
|
|
7
7
|
}
|
|
@@ -137,8 +137,8 @@ declare function expandVariantGroup(str: MagicString, seperators?: string[], dep
|
|
|
137
137
|
|
|
138
138
|
declare function warnOnce(msg: string): void;
|
|
139
139
|
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
type ValueHandlerCallback = (str: string) => string | number | undefined;
|
|
141
|
+
type ValueHandler<K extends string> = {
|
|
142
142
|
[S in K]: ValueHandler<K>;
|
|
143
143
|
} & {
|
|
144
144
|
(str: string): string | undefined;
|
|
@@ -148,27 +148,27 @@ declare type ValueHandler<K extends string> = {
|
|
|
148
148
|
};
|
|
149
149
|
declare function createValueHandler<K extends string>(handlers: Record<K, ValueHandlerCallback>): ValueHandler<K>;
|
|
150
150
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
151
|
+
type Awaitable<T> = T | Promise<T>;
|
|
152
|
+
type Arrayable<T> = T | T[];
|
|
153
|
+
type ArgumentType<T> = T extends ((...args: infer A) => any) ? A : never;
|
|
154
|
+
type Shift<T> = T extends [_: any, ...args: infer A] ? A : never;
|
|
155
|
+
type RestArgs<T> = Shift<ArgumentType<T>>;
|
|
156
|
+
type DeepPartial<T> = {
|
|
157
157
|
[P in keyof T]?: DeepPartial<T[P]>;
|
|
158
158
|
};
|
|
159
|
-
|
|
159
|
+
type FlatObjectTuple<T> = {
|
|
160
160
|
[K in keyof T]: T[K];
|
|
161
161
|
};
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
162
|
+
type PartialByKeys<T, K extends keyof T = keyof T> = FlatObjectTuple<Partial<Pick<T, Extract<keyof T, K>>> & Omit<T, K>>;
|
|
163
|
+
type RequiredByKey<T, K extends keyof T = keyof T> = FlatObjectTuple<Required<Pick<T, Extract<keyof T, K>>> & Omit<T, K>>;
|
|
164
|
+
type CSSObject = Record<string, string | number | undefined>;
|
|
165
|
+
type CSSEntries = [string, string | number | undefined][];
|
|
166
166
|
interface CSSColorValue {
|
|
167
167
|
type: string;
|
|
168
168
|
components: (string | number)[];
|
|
169
169
|
alpha: string | number | undefined;
|
|
170
170
|
}
|
|
171
|
-
|
|
171
|
+
type RGBAColorValue = [number, number, number, number] | [number, number, number];
|
|
172
172
|
interface ParsedColorValue {
|
|
173
173
|
/**
|
|
174
174
|
* Parsed color value.
|
|
@@ -195,7 +195,7 @@ interface ParsedColorValue {
|
|
|
195
195
|
*/
|
|
196
196
|
alpha: string | number | undefined;
|
|
197
197
|
}
|
|
198
|
-
|
|
198
|
+
type PresetOptions = Record<string, any>;
|
|
199
199
|
interface RuleContext<Theme extends {} = {}> {
|
|
200
200
|
/**
|
|
201
201
|
* Unprocessed selector from user input.
|
|
@@ -303,25 +303,25 @@ interface RuleMeta {
|
|
|
303
303
|
*/
|
|
304
304
|
internal?: boolean;
|
|
305
305
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
306
|
+
type CSSValue = CSSObject | CSSEntries;
|
|
307
|
+
type CSSValues = CSSValue | CSSValue[];
|
|
308
|
+
type DynamicMatcher<Theme extends {} = {}> = ((match: RegExpMatchArray, context: Readonly<RuleContext<Theme>>) => Awaitable<CSSValue | string | (CSSValue | string)[] | undefined>);
|
|
309
|
+
type DynamicRule<Theme extends {} = {}> = [RegExp, DynamicMatcher<Theme>] | [RegExp, DynamicMatcher<Theme>, RuleMeta];
|
|
310
|
+
type StaticRule = [string, CSSObject | CSSEntries] | [string, CSSObject | CSSEntries, RuleMeta];
|
|
311
|
+
type Rule<Theme extends {} = {}> = DynamicRule<Theme> | StaticRule;
|
|
312
|
+
type DynamicShortcutMatcher<Theme extends {} = {}> = ((match: RegExpMatchArray, context: Readonly<RuleContext<Theme>>) => (string | ShortcutValue[] | undefined));
|
|
313
|
+
type StaticShortcut = [string, string | ShortcutValue[]] | [string, string | ShortcutValue[], RuleMeta];
|
|
314
|
+
type StaticShortcutMap = Record<string, string | ShortcutValue[]>;
|
|
315
|
+
type DynamicShortcut<Theme extends {} = {}> = [RegExp, DynamicShortcutMatcher<Theme>] | [RegExp, DynamicShortcutMatcher<Theme>, RuleMeta];
|
|
316
|
+
type UserShortcuts<Theme extends {} = {}> = StaticShortcutMap | (StaticShortcut | DynamicShortcut<Theme> | StaticShortcutMap)[];
|
|
317
|
+
type Shortcut<Theme extends {} = {}> = StaticShortcut | DynamicShortcut<Theme>;
|
|
318
|
+
type ShortcutValue = string | CSSValue;
|
|
319
|
+
type FilterPattern = ReadonlyArray<string | RegExp> | string | RegExp | null;
|
|
320
320
|
interface Preflight<Theme extends {} = {}> {
|
|
321
321
|
getCSS: (context: PreflightContext<Theme>) => Promise<string | undefined> | string | undefined;
|
|
322
322
|
layer?: string;
|
|
323
323
|
}
|
|
324
|
-
|
|
324
|
+
type BlocklistRule = string | RegExp;
|
|
325
325
|
interface VariantHandlerContext {
|
|
326
326
|
/**
|
|
327
327
|
* Rewrite the output selector. Often be used to append parents.
|
|
@@ -395,7 +395,7 @@ interface VariantHandler {
|
|
|
395
395
|
*/
|
|
396
396
|
layer?: string | undefined;
|
|
397
397
|
}
|
|
398
|
-
|
|
398
|
+
type VariantFunction<Theme extends {} = {}> = (matcher: string, context: Readonly<VariantContext<Theme>>) => string | VariantHandler | undefined;
|
|
399
399
|
interface VariantObject<Theme extends {} = {}> {
|
|
400
400
|
/**
|
|
401
401
|
* The name of the variant.
|
|
@@ -416,10 +416,10 @@ interface VariantObject<Theme extends {} = {}> {
|
|
|
416
416
|
*/
|
|
417
417
|
autocomplete?: Arrayable<AutoCompleteFunction | AutoCompleteTemplate>;
|
|
418
418
|
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
419
|
+
type Variant<Theme extends {} = {}> = VariantFunction<Theme> | VariantObject<Theme>;
|
|
420
|
+
type Preprocessor = (matcher: string) => string | undefined;
|
|
421
|
+
type Postprocessor = (util: UtilObject) => void;
|
|
422
|
+
type ThemeExtender<T> = (theme: T) => void;
|
|
423
423
|
interface ConfigBase<Theme extends {} = {}> {
|
|
424
424
|
/**
|
|
425
425
|
* Rules to generate CSS utilities
|
|
@@ -502,8 +502,8 @@ interface ConfigBase<Theme extends {} = {}> {
|
|
|
502
502
|
*/
|
|
503
503
|
details?: boolean;
|
|
504
504
|
}
|
|
505
|
-
|
|
506
|
-
|
|
505
|
+
type AutoCompleteTemplate = string;
|
|
506
|
+
type AutoCompleteFunction = (input: string) => Awaitable<string[]>;
|
|
507
507
|
interface AutoCompleteExtractorContext {
|
|
508
508
|
content: string;
|
|
509
509
|
cursor: number;
|
|
@@ -646,7 +646,7 @@ interface TransformResult {
|
|
|
646
646
|
deps?: string[];
|
|
647
647
|
dynamicDeps?: string[];
|
|
648
648
|
}
|
|
649
|
-
|
|
649
|
+
type SourceCodeTransformerEnforce = 'pre' | 'post' | 'default';
|
|
650
650
|
interface SourceCodeTransformer {
|
|
651
651
|
name: string;
|
|
652
652
|
/**
|
|
@@ -714,25 +714,25 @@ interface GenerateResult {
|
|
|
714
714
|
getLayers(includes?: string[], excludes?: string[]): string;
|
|
715
715
|
matched: Set<string>;
|
|
716
716
|
}
|
|
717
|
-
|
|
717
|
+
type VariantMatchedResult<Theme extends {} = {}> = readonly [
|
|
718
718
|
raw: string,
|
|
719
719
|
current: string,
|
|
720
720
|
variantHandlers: VariantHandler[],
|
|
721
721
|
variants: Set<Variant<Theme>>
|
|
722
722
|
];
|
|
723
|
-
|
|
723
|
+
type ParsedUtil = readonly [
|
|
724
724
|
index: number,
|
|
725
725
|
raw: string,
|
|
726
726
|
entries: CSSEntries,
|
|
727
727
|
meta: RuleMeta | undefined,
|
|
728
728
|
variantHandlers: VariantHandler[]
|
|
729
729
|
];
|
|
730
|
-
|
|
730
|
+
type RawUtil = readonly [
|
|
731
731
|
index: number,
|
|
732
732
|
rawCSS: string,
|
|
733
733
|
meta: RuleMeta | undefined
|
|
734
734
|
];
|
|
735
|
-
|
|
735
|
+
type StringifiedUtil<Theme extends {} = {}> = readonly [
|
|
736
736
|
index: number,
|
|
737
737
|
selector: string | undefined,
|
|
738
738
|
body: string,
|
|
@@ -741,7 +741,7 @@ declare type StringifiedUtil<Theme extends {} = {}> = readonly [
|
|
|
741
741
|
context: RuleContext<Theme> | undefined,
|
|
742
742
|
noMerge: boolean | undefined
|
|
743
743
|
];
|
|
744
|
-
|
|
744
|
+
type PreparedRule = readonly [
|
|
745
745
|
selector: [string, number][],
|
|
746
746
|
body: string,
|
|
747
747
|
noMerge: boolean
|
|
@@ -784,8 +784,9 @@ interface GenerateOptions {
|
|
|
784
784
|
scope?: string;
|
|
785
785
|
}
|
|
786
786
|
|
|
787
|
+
declare const arbitraryPropertyRE: RegExp;
|
|
787
788
|
declare const extractorSplit: Extractor;
|
|
788
789
|
|
|
789
790
|
declare const extractorSvelte: Extractor;
|
|
790
791
|
|
|
791
|
-
export { ArgumentType, Arrayable, AutoCompleteExtractor, AutoCompleteExtractorContext, AutoCompleteExtractorResult, AutoCompleteFunction, AutoCompleteTemplate, Awaitable, BetterMap, BlocklistRule, CONTROL_SHORTCUT_NO_MERGE, CSSColorValue, CSSEntries, CSSObject, CSSValue, CSSValues, CliEntryItem, CliOptions, ConfigBase, DeepPartial, DynamicMatcher, DynamicRule, DynamicShortcut, DynamicShortcutMatcher, Extractor, ExtractorContext, FilterPattern, FlatObjectTuple, GenerateOptions, GenerateResult, GeneratorOptions, ParsedColorValue, ParsedUtil, PartialByKeys, PluginOptions, Postprocessor, Preflight, PreflightContext, PreparedRule, Preprocessor, Preset, PresetOptions, RGBAColorValue, RawUtil, Replacement, RequiredByKey, ResolvedConfig, RestArgs, Rule, RuleContext, RuleMeta, Shift, Shortcut, ShortcutValue, SourceCodeTransformer, SourceCodeTransformerEnforce, SourceMap, StaticRule, StaticShortcut, StaticShortcutMap, StringifiedUtil, SuggestResult, ThemeExtender, TransformResult, TwoKeyMap, UnoGenerator, UnocssPluginContext, UserConfig, UserConfigDefaults, UserOnlyOptions, UserShortcuts, UtilObject, ValueHandler, ValueHandlerCallback, Variant, VariantContext, VariantFunction, VariantHandler, VariantHandlerContext, VariantMatchedResult, VariantObject, attributifyRE, clearIdenticalEntries, clone, createGenerator, createValueHandler, cssIdRE, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit, extractorSvelte, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isString, isValidSelector, mergeDeep, movePseudoElementsEnd, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexClassGroup, regexScopePlaceholder, toArray, toEscapedSelector, uniq, validateFilterRE, warnOnce, withLayer };
|
|
792
|
+
export { ArgumentType, Arrayable, AutoCompleteExtractor, AutoCompleteExtractorContext, AutoCompleteExtractorResult, AutoCompleteFunction, AutoCompleteTemplate, Awaitable, BetterMap, BlocklistRule, CONTROL_SHORTCUT_NO_MERGE, CSSColorValue, CSSEntries, CSSObject, CSSValue, CSSValues, CliEntryItem, CliOptions, ConfigBase, DeepPartial, DynamicMatcher, DynamicRule, DynamicShortcut, DynamicShortcutMatcher, Extractor, ExtractorContext, FilterPattern, FlatObjectTuple, GenerateOptions, GenerateResult, GeneratorOptions, ParsedColorValue, ParsedUtil, PartialByKeys, PluginOptions, Postprocessor, Preflight, PreflightContext, PreparedRule, Preprocessor, Preset, PresetOptions, RGBAColorValue, RawUtil, Replacement, RequiredByKey, ResolvedConfig, RestArgs, Rule, RuleContext, RuleMeta, Shift, Shortcut, ShortcutValue, SourceCodeTransformer, SourceCodeTransformerEnforce, SourceMap, StaticRule, StaticShortcut, StaticShortcutMap, StringifiedUtil, SuggestResult, ThemeExtender, TransformResult, TwoKeyMap, UnoGenerator, UnocssPluginContext, UserConfig, UserConfigDefaults, UserOnlyOptions, UserShortcuts, UtilObject, ValueHandler, ValueHandlerCallback, Variant, VariantContext, VariantFunction, VariantHandler, VariantHandlerContext, VariantMatchedResult, VariantObject, arbitraryPropertyRE, attributifyRE, clearIdenticalEntries, clone, createGenerator, createValueHandler, cssIdRE, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit, extractorSvelte, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isString, isValidSelector, mergeDeep, movePseudoElementsEnd, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexClassGroup, regexScopePlaceholder, toArray, toEscapedSelector, uniq, validateFilterRE, warnOnce, withLayer };
|
package/dist/index.mjs
CHANGED
|
@@ -215,7 +215,7 @@ function withLayer(layer, rules) {
|
|
|
215
215
|
return rules;
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
-
const regexClassGroup = /((?:[!\w+:_/-]|\[&?>?:?.*\])+?)([:-])\(((?:[~!\w\s:/\\,%#.$-]|\[.*?\])
|
|
218
|
+
const regexClassGroup = /((?:[!\w+:_/-]|\[&?>?:?.*\])+?)([:-])\(((?:[~!\w\s:/\\,%#.$-]|\[.*?\])+?)\)(?!\s*?=>)/gm;
|
|
219
219
|
function expandVariantGroup(str, seperators = ["-", ":"], depth = 5) {
|
|
220
220
|
regexClassGroup.lastIndex = 0;
|
|
221
221
|
let hasChanged = false;
|
|
@@ -278,7 +278,21 @@ function createValueHandler(handlers) {
|
|
|
278
278
|
return handler;
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
-
const
|
|
281
|
+
const defaultSplitRE = /\\?[\s'"`;{}]+/g;
|
|
282
|
+
const arbitraryPropertyRE = /\[(\\\W|[\w-])+:['"]?\S+?['"]?\]/g;
|
|
283
|
+
const arbitraryPropertyCandidateRE = new RegExp(`^${arbitraryPropertyRE.source}$`);
|
|
284
|
+
const splitCode = (code) => {
|
|
285
|
+
const result = /* @__PURE__ */ new Set();
|
|
286
|
+
for (const match of code.matchAll(arbitraryPropertyRE)) {
|
|
287
|
+
if (!code[match.index - 1]?.match(/^[\s'"`]/))
|
|
288
|
+
continue;
|
|
289
|
+
result.add(match[0]);
|
|
290
|
+
}
|
|
291
|
+
code.split(defaultSplitRE).forEach((match) => {
|
|
292
|
+
isValidSelector(match) && !arbitraryPropertyCandidateRE.test(match) && result.add(match);
|
|
293
|
+
});
|
|
294
|
+
return [...result];
|
|
295
|
+
};
|
|
282
296
|
const extractorSplit = {
|
|
283
297
|
name: "split",
|
|
284
298
|
order: 0,
|
|
@@ -413,7 +427,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
413
427
|
};
|
|
414
428
|
}
|
|
415
429
|
|
|
416
|
-
const version = "0.
|
|
430
|
+
const version = "0.47.1";
|
|
417
431
|
|
|
418
432
|
class UnoGenerator {
|
|
419
433
|
constructor(userConfig = {}, defaults = {}) {
|
|
@@ -896,4 +910,4 @@ function defaultVariantHandler(input, next) {
|
|
|
896
910
|
return next(input);
|
|
897
911
|
}
|
|
898
912
|
|
|
899
|
-
export { BetterMap, CONTROL_SHORTCUT_NO_MERGE, TwoKeyMap, UnoGenerator, attributifyRE, clearIdenticalEntries, clone, createGenerator, createValueHandler, cssIdRE, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit, extractorSvelte, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isString, isValidSelector, mergeDeep, movePseudoElementsEnd, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexClassGroup, regexScopePlaceholder, toArray, toEscapedSelector, uniq, validateFilterRE, warnOnce, withLayer };
|
|
913
|
+
export { BetterMap, CONTROL_SHORTCUT_NO_MERGE, TwoKeyMap, UnoGenerator, arbitraryPropertyRE, attributifyRE, clearIdenticalEntries, clone, createGenerator, createValueHandler, cssIdRE, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit, extractorSvelte, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isString, isValidSelector, mergeDeep, movePseudoElementsEnd, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexClassGroup, regexScopePlaceholder, toArray, toEscapedSelector, uniq, validateFilterRE, warnOnce, withLayer };
|