@unocss/core 0.31.2 → 0.31.6
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 +90 -4
- package/dist/index.d.ts +17 -1
- package/dist/index.mjs +89 -5
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -222,9 +222,15 @@ function withLayer(layer, rules) {
|
|
|
222
222
|
const regexClassGroup = /([!\w+:_/-]+?)([:-])\(((?:[~!\w\s:/\\,%#.$-]|\[.*?\])*?)\)/gm;
|
|
223
223
|
function expandVariantGroup(str) {
|
|
224
224
|
regexClassGroup.lastIndex = 0;
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
225
|
+
let hasChanged = false;
|
|
226
|
+
do {
|
|
227
|
+
const before = str.toString();
|
|
228
|
+
str = str.replace(regexClassGroup, (_, pre, sep, body) => {
|
|
229
|
+
return body.split(/\s/g).map((i) => i === "~" ? pre : i.replace(/^(!?)(.*)/, `$1${pre}${sep}$2`)).join(" ");
|
|
230
|
+
});
|
|
231
|
+
hasChanged = str.toString() !== before;
|
|
232
|
+
} while (hasChanged);
|
|
233
|
+
return str;
|
|
228
234
|
}
|
|
229
235
|
|
|
230
236
|
const warned = /* @__PURE__ */ new Set();
|
|
@@ -265,6 +271,84 @@ function createValueHandler(handlers) {
|
|
|
265
271
|
return handler;
|
|
266
272
|
}
|
|
267
273
|
|
|
274
|
+
function matchingPair(text, [left, right], i, allowEscape) {
|
|
275
|
+
const len = text.length;
|
|
276
|
+
let stack = +(text[i] === left);
|
|
277
|
+
while (++i < len) {
|
|
278
|
+
const char = text[i];
|
|
279
|
+
if (char === left) {
|
|
280
|
+
stack++;
|
|
281
|
+
} else if (char === right) {
|
|
282
|
+
stack--;
|
|
283
|
+
if (stack === 0)
|
|
284
|
+
return i;
|
|
285
|
+
} else if (allowEscape && char === "\\") {
|
|
286
|
+
i++;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return -1;
|
|
290
|
+
}
|
|
291
|
+
const QUOTES = ["'", '"', "`"];
|
|
292
|
+
function extractQuoted(str, options = {}) {
|
|
293
|
+
const {
|
|
294
|
+
deep = false,
|
|
295
|
+
templateStaticOnly = false,
|
|
296
|
+
details = false,
|
|
297
|
+
range: [rstart, rend] = [0, str.length]
|
|
298
|
+
} = options;
|
|
299
|
+
const result = [];
|
|
300
|
+
let quote;
|
|
301
|
+
const addResult = (start, end) => result.push(details ? {
|
|
302
|
+
value: str.slice(start, end),
|
|
303
|
+
range: [start, end],
|
|
304
|
+
quote
|
|
305
|
+
} : str.slice(start, end));
|
|
306
|
+
let i = rstart;
|
|
307
|
+
while (i < rend) {
|
|
308
|
+
const char = str[i];
|
|
309
|
+
if (QUOTES.includes(char)) {
|
|
310
|
+
quote = char;
|
|
311
|
+
const start = i + 1;
|
|
312
|
+
const isTemplate = quote === "`";
|
|
313
|
+
let templateStart = start;
|
|
314
|
+
let end = start;
|
|
315
|
+
while (end < rend) {
|
|
316
|
+
const nextChar = str[end];
|
|
317
|
+
if (nextChar === quote) {
|
|
318
|
+
if (isTemplate && templateStaticOnly) {
|
|
319
|
+
addResult(templateStart, end);
|
|
320
|
+
break;
|
|
321
|
+
}
|
|
322
|
+
addResult(start, end);
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
325
|
+
if (nextChar === "\\") {
|
|
326
|
+
end += 2;
|
|
327
|
+
} else if (isTemplate && nextChar === "$" && str[end + 1] === "{") {
|
|
328
|
+
const nestStart = end + 2;
|
|
329
|
+
end = matchingPair(str, "{}", end + 1, true);
|
|
330
|
+
if (templateStaticOnly) {
|
|
331
|
+
addResult(templateStart, nestStart - 2);
|
|
332
|
+
}
|
|
333
|
+
templateStart = end + 1;
|
|
334
|
+
if (deep) {
|
|
335
|
+
result.push(...extractQuoted(str, {
|
|
336
|
+
...options,
|
|
337
|
+
range: [nestStart, end]
|
|
338
|
+
}));
|
|
339
|
+
}
|
|
340
|
+
} else {
|
|
341
|
+
end += 1;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
i = end + 1;
|
|
345
|
+
} else {
|
|
346
|
+
i++;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
return result;
|
|
350
|
+
}
|
|
351
|
+
|
|
268
352
|
const splitCode = (code) => code.split(/[\s'"`;>=]+/g).filter(isValidSelector);
|
|
269
353
|
const extractorSplit = {
|
|
270
354
|
name: "split",
|
|
@@ -361,7 +445,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
361
445
|
};
|
|
362
446
|
}
|
|
363
447
|
|
|
364
|
-
const version = "0.31.
|
|
448
|
+
const version = "0.31.6";
|
|
365
449
|
|
|
366
450
|
class UnoGenerator {
|
|
367
451
|
constructor(userConfig = {}, defaults = {}) {
|
|
@@ -747,6 +831,7 @@ exports.entriesToCss = entriesToCss;
|
|
|
747
831
|
exports.escapeRegExp = escapeRegExp;
|
|
748
832
|
exports.escapeSelector = escapeSelector;
|
|
749
833
|
exports.expandVariantGroup = expandVariantGroup;
|
|
834
|
+
exports.extractQuoted = extractQuoted;
|
|
750
835
|
exports.extractorSplit = extractorSplit;
|
|
751
836
|
exports.extractorSvelte = extractorSvelte;
|
|
752
837
|
exports.hasScopePlaceholder = hasScopePlaceholder;
|
|
@@ -756,6 +841,7 @@ exports.isRawUtil = isRawUtil;
|
|
|
756
841
|
exports.isStaticRule = isStaticRule;
|
|
757
842
|
exports.isStaticShortcut = isStaticShortcut;
|
|
758
843
|
exports.isValidSelector = isValidSelector;
|
|
844
|
+
exports.matchingPair = matchingPair;
|
|
759
845
|
exports.mergeDeep = mergeDeep;
|
|
760
846
|
exports.mergeSet = mergeSet;
|
|
761
847
|
exports.normalizeCSSEntries = normalizeCSSEntries;
|
package/dist/index.d.ts
CHANGED
|
@@ -92,6 +92,22 @@ declare type ValueHandler<K extends string> = {
|
|
|
92
92
|
};
|
|
93
93
|
declare function createValueHandler<K extends string>(handlers: Record<K, ValueHandlerCallback>): ValueHandler<K>;
|
|
94
94
|
|
|
95
|
+
declare type Range = [start: number, end: number];
|
|
96
|
+
interface ExtractStringOptions<Details extends boolean = false> {
|
|
97
|
+
deep?: boolean;
|
|
98
|
+
templateStaticOnly?: boolean;
|
|
99
|
+
details?: Details;
|
|
100
|
+
range?: Range;
|
|
101
|
+
}
|
|
102
|
+
interface DetailString {
|
|
103
|
+
value: string;
|
|
104
|
+
range: Range;
|
|
105
|
+
quote: '\'' | '"' | '`';
|
|
106
|
+
}
|
|
107
|
+
declare function matchingPair(text: string, [left, right]: Iterable<string>, i: number, allowEscape?: boolean): number;
|
|
108
|
+
declare function extractQuoted(str: string, options?: ExtractStringOptions<false>): string[];
|
|
109
|
+
declare function extractQuoted(str: string, options: ExtractStringOptions<true>): DetailString[];
|
|
110
|
+
|
|
95
111
|
declare type Awaitable<T> = T | Promise<T>;
|
|
96
112
|
declare type Arrayable<T> = T | T[];
|
|
97
113
|
declare type ArgumentType<T> = T extends ((...args: infer A) => any) ? A : never;
|
|
@@ -621,4 +637,4 @@ declare const extractorSplit: Extractor;
|
|
|
621
637
|
|
|
622
638
|
declare const extractorSvelte: Extractor;
|
|
623
639
|
|
|
624
|
-
export { ArgumentType, Arrayable, AutoCompleteExtractor, AutoCompleteExtractorContext, AutoCompleteExtractorResult, AutoCompleteFunction, AutoCompleteTemplate, Awaitable, BetterMap, BlocklistRule, CONTROL_SHORTCUT_NO_MERGE, CSSColorValue, CSSEntries, CSSObject, CSSValues, ConfigBase, DeepPartial, DynamicMatcher, DynamicRule, DynamicShortcut, DynamicShortcutMatcher, Extractor, ExtractorContext, FilterPattern, FlatObjectTuple, GenerateOptions, GenerateResult, GeneratorOptions, ParsedColorValue, ParsedUtil, PartialByKeys, PluginOptions, Postprocessor, Preflight, PreflightContext, Preprocessor, Preset, PresetOptions, RGBAColorValue, RawUtil, Replacement, RequiredByKey, ResolvedConfig, RestArgs, Rule, RuleContext, RuleMeta, Shift, Shortcut, SourceCodeTransformer, SourceMap, StaticRule, StaticShortcut, StaticShortcutMap, StringifiedUtil, SuggestResult, ThemeExtender, TransformResult, TwoKeyMap, UnoGenerator, UnocssPluginContext, UserConfig, UserConfigDefaults, UserOnlyOptions, UserShortcuts, UtilObject, ValueHandler, ValueHandlerCallback, Variant, VariantContext, VariantFunction, VariantHandler, VariantMatchedResult, VariantObject, attributifyRE, clearIdenticalEntries, clone, createGenerator, createValueHandler, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit, extractorSvelte, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isValidSelector, mergeDeep, mergeSet, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexClassGroup, regexScopePlaceholder, toArray, toEscapedSelector, uniq, validateFilterRE, warnOnce, withLayer };
|
|
640
|
+
export { ArgumentType, Arrayable, AutoCompleteExtractor, AutoCompleteExtractorContext, AutoCompleteExtractorResult, AutoCompleteFunction, AutoCompleteTemplate, Awaitable, BetterMap, BlocklistRule, CONTROL_SHORTCUT_NO_MERGE, CSSColorValue, CSSEntries, CSSObject, CSSValues, ConfigBase, DeepPartial, DetailString, DynamicMatcher, DynamicRule, DynamicShortcut, DynamicShortcutMatcher, ExtractStringOptions, Extractor, ExtractorContext, FilterPattern, FlatObjectTuple, GenerateOptions, GenerateResult, GeneratorOptions, ParsedColorValue, ParsedUtil, PartialByKeys, PluginOptions, Postprocessor, Preflight, PreflightContext, Preprocessor, Preset, PresetOptions, RGBAColorValue, Range, RawUtil, Replacement, RequiredByKey, ResolvedConfig, RestArgs, Rule, RuleContext, RuleMeta, Shift, Shortcut, SourceCodeTransformer, SourceMap, StaticRule, StaticShortcut, StaticShortcutMap, StringifiedUtil, SuggestResult, ThemeExtender, TransformResult, TwoKeyMap, UnoGenerator, UnocssPluginContext, UserConfig, UserConfigDefaults, UserOnlyOptions, UserShortcuts, UtilObject, ValueHandler, ValueHandlerCallback, Variant, VariantContext, VariantFunction, VariantHandler, VariantMatchedResult, VariantObject, attributifyRE, clearIdenticalEntries, clone, createGenerator, createValueHandler, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractQuoted, extractorSplit, extractorSvelte, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isValidSelector, matchingPair, mergeDeep, mergeSet, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexClassGroup, regexScopePlaceholder, toArray, toEscapedSelector, uniq, validateFilterRE, warnOnce, withLayer };
|
package/dist/index.mjs
CHANGED
|
@@ -218,9 +218,15 @@ function withLayer(layer, rules) {
|
|
|
218
218
|
const regexClassGroup = /([!\w+:_/-]+?)([:-])\(((?:[~!\w\s:/\\,%#.$-]|\[.*?\])*?)\)/gm;
|
|
219
219
|
function expandVariantGroup(str) {
|
|
220
220
|
regexClassGroup.lastIndex = 0;
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
221
|
+
let hasChanged = false;
|
|
222
|
+
do {
|
|
223
|
+
const before = str.toString();
|
|
224
|
+
str = str.replace(regexClassGroup, (_, pre, sep, body) => {
|
|
225
|
+
return body.split(/\s/g).map((i) => i === "~" ? pre : i.replace(/^(!?)(.*)/, `$1${pre}${sep}$2`)).join(" ");
|
|
226
|
+
});
|
|
227
|
+
hasChanged = str.toString() !== before;
|
|
228
|
+
} while (hasChanged);
|
|
229
|
+
return str;
|
|
224
230
|
}
|
|
225
231
|
|
|
226
232
|
const warned = /* @__PURE__ */ new Set();
|
|
@@ -261,6 +267,84 @@ function createValueHandler(handlers) {
|
|
|
261
267
|
return handler;
|
|
262
268
|
}
|
|
263
269
|
|
|
270
|
+
function matchingPair(text, [left, right], i, allowEscape) {
|
|
271
|
+
const len = text.length;
|
|
272
|
+
let stack = +(text[i] === left);
|
|
273
|
+
while (++i < len) {
|
|
274
|
+
const char = text[i];
|
|
275
|
+
if (char === left) {
|
|
276
|
+
stack++;
|
|
277
|
+
} else if (char === right) {
|
|
278
|
+
stack--;
|
|
279
|
+
if (stack === 0)
|
|
280
|
+
return i;
|
|
281
|
+
} else if (allowEscape && char === "\\") {
|
|
282
|
+
i++;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return -1;
|
|
286
|
+
}
|
|
287
|
+
const QUOTES = ["'", '"', "`"];
|
|
288
|
+
function extractQuoted(str, options = {}) {
|
|
289
|
+
const {
|
|
290
|
+
deep = false,
|
|
291
|
+
templateStaticOnly = false,
|
|
292
|
+
details = false,
|
|
293
|
+
range: [rstart, rend] = [0, str.length]
|
|
294
|
+
} = options;
|
|
295
|
+
const result = [];
|
|
296
|
+
let quote;
|
|
297
|
+
const addResult = (start, end) => result.push(details ? {
|
|
298
|
+
value: str.slice(start, end),
|
|
299
|
+
range: [start, end],
|
|
300
|
+
quote
|
|
301
|
+
} : str.slice(start, end));
|
|
302
|
+
let i = rstart;
|
|
303
|
+
while (i < rend) {
|
|
304
|
+
const char = str[i];
|
|
305
|
+
if (QUOTES.includes(char)) {
|
|
306
|
+
quote = char;
|
|
307
|
+
const start = i + 1;
|
|
308
|
+
const isTemplate = quote === "`";
|
|
309
|
+
let templateStart = start;
|
|
310
|
+
let end = start;
|
|
311
|
+
while (end < rend) {
|
|
312
|
+
const nextChar = str[end];
|
|
313
|
+
if (nextChar === quote) {
|
|
314
|
+
if (isTemplate && templateStaticOnly) {
|
|
315
|
+
addResult(templateStart, end);
|
|
316
|
+
break;
|
|
317
|
+
}
|
|
318
|
+
addResult(start, end);
|
|
319
|
+
break;
|
|
320
|
+
}
|
|
321
|
+
if (nextChar === "\\") {
|
|
322
|
+
end += 2;
|
|
323
|
+
} else if (isTemplate && nextChar === "$" && str[end + 1] === "{") {
|
|
324
|
+
const nestStart = end + 2;
|
|
325
|
+
end = matchingPair(str, "{}", end + 1, true);
|
|
326
|
+
if (templateStaticOnly) {
|
|
327
|
+
addResult(templateStart, nestStart - 2);
|
|
328
|
+
}
|
|
329
|
+
templateStart = end + 1;
|
|
330
|
+
if (deep) {
|
|
331
|
+
result.push(...extractQuoted(str, {
|
|
332
|
+
...options,
|
|
333
|
+
range: [nestStart, end]
|
|
334
|
+
}));
|
|
335
|
+
}
|
|
336
|
+
} else {
|
|
337
|
+
end += 1;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
i = end + 1;
|
|
341
|
+
} else {
|
|
342
|
+
i++;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
return result;
|
|
346
|
+
}
|
|
347
|
+
|
|
264
348
|
const splitCode = (code) => code.split(/[\s'"`;>=]+/g).filter(isValidSelector);
|
|
265
349
|
const extractorSplit = {
|
|
266
350
|
name: "split",
|
|
@@ -357,7 +441,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
357
441
|
};
|
|
358
442
|
}
|
|
359
443
|
|
|
360
|
-
const version = "0.31.
|
|
444
|
+
const version = "0.31.6";
|
|
361
445
|
|
|
362
446
|
class UnoGenerator {
|
|
363
447
|
constructor(userConfig = {}, defaults = {}) {
|
|
@@ -729,4 +813,4 @@ function toEscapedSelector(raw) {
|
|
|
729
813
|
return `.${e(raw)}`;
|
|
730
814
|
}
|
|
731
815
|
|
|
732
|
-
export { BetterMap, CONTROL_SHORTCUT_NO_MERGE, TwoKeyMap, UnoGenerator, attributifyRE, clearIdenticalEntries, clone, createGenerator, createValueHandler, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit, extractorSvelte, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isValidSelector, mergeDeep, mergeSet, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexClassGroup, regexScopePlaceholder, toArray, toEscapedSelector, uniq, validateFilterRE, warnOnce, withLayer };
|
|
816
|
+
export { BetterMap, CONTROL_SHORTCUT_NO_MERGE, TwoKeyMap, UnoGenerator, attributifyRE, clearIdenticalEntries, clone, createGenerator, createValueHandler, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractQuoted, extractorSplit, extractorSvelte, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isValidSelector, matchingPair, mergeDeep, mergeSet, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexClassGroup, regexScopePlaceholder, toArray, toEscapedSelector, uniq, validateFilterRE, warnOnce, withLayer };
|