@unocss/core 0.43.0 → 0.44.0

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 CHANGED
@@ -224,17 +224,23 @@ function withLayer(layer, rules) {
224
224
  }
225
225
 
226
226
  const regexClassGroup = /([!\w+:_/-]+?)([:-])\(((?:[~!\w\s:/\\,%#.$-]|\[.*?\])*?)\)/gm;
227
- function expandVariantGroup(str) {
227
+ function expandVariantGroup(str, seperators = ["-", ":"]) {
228
228
  regexClassGroup.lastIndex = 0;
229
229
  let hasChanged = false;
230
+ let content = str.toString();
230
231
  do {
231
- const before = str.toString();
232
- str = str.replace(regexClassGroup, (_, pre, sep, body) => {
232
+ const before = content;
233
+ content = content.replace(regexClassGroup, (from, pre, sep, body) => {
234
+ if (!seperators.includes(sep))
235
+ return from;
233
236
  return body.split(/\s/g).map((i) => i === "~" ? pre : i.replace(/^(!?)(.*)/, `$1${pre}${sep}$2`)).join(" ");
234
237
  });
235
- hasChanged = str.toString() !== before;
238
+ hasChanged = content !== before;
236
239
  } while (hasChanged);
237
- return str;
240
+ if (typeof str === "string")
241
+ return content;
242
+ else
243
+ return str.overwrite(0, str.length(), content);
238
244
  }
239
245
 
240
246
  const warned = /* @__PURE__ */ new Set();
@@ -275,84 +281,6 @@ function createValueHandler(handlers) {
275
281
  return handler;
276
282
  }
277
283
 
278
- function matchingPair(text, [left, right], i, allowEscape) {
279
- const len = text.length;
280
- let stack = +(text[i] === left);
281
- while (++i < len) {
282
- const char = text[i];
283
- if (char === left) {
284
- stack++;
285
- } else if (char === right) {
286
- stack--;
287
- if (stack === 0)
288
- return i;
289
- } else if (allowEscape && char === "\\") {
290
- i++;
291
- }
292
- }
293
- return -1;
294
- }
295
- const QUOTES = ["'", '"', "`"];
296
- function extractQuoted(str, options = {}) {
297
- const {
298
- deep = false,
299
- templateStaticOnly = false,
300
- details = false,
301
- range: [rstart, rend] = [0, str.length]
302
- } = options;
303
- const result = [];
304
- let quote;
305
- const addResult = (start, end) => result.push(details ? {
306
- value: str.slice(start, end),
307
- range: [start, end],
308
- quote
309
- } : str.slice(start, end));
310
- let i = rstart;
311
- while (i < rend) {
312
- const char = str[i];
313
- if (QUOTES.includes(char)) {
314
- quote = char;
315
- const start = i + 1;
316
- const isTemplate = quote === "`";
317
- let templateStart = start;
318
- let end = start;
319
- while (end < rend) {
320
- const nextChar = str[end];
321
- if (nextChar === quote) {
322
- if (isTemplate && templateStaticOnly) {
323
- addResult(templateStart, end);
324
- break;
325
- }
326
- addResult(start, end);
327
- break;
328
- }
329
- if (nextChar === "\\") {
330
- end += 2;
331
- } else if (isTemplate && nextChar === "$" && str[end + 1] === "{") {
332
- const nestStart = end + 2;
333
- end = matchingPair(str, "{}", end + 1, true);
334
- if (templateStaticOnly) {
335
- addResult(templateStart, nestStart - 2);
336
- }
337
- templateStart = end + 1;
338
- if (deep) {
339
- result.push(...extractQuoted(str, {
340
- ...options,
341
- range: [nestStart, end]
342
- }));
343
- }
344
- } else {
345
- end += 1;
346
- }
347
- }
348
- i = end + 1;
349
- } else {
350
- i++;
351
- }
352
- }
353
- return result;
354
- }
355
-
356
284
  const splitCode = (code) => code.split(/[\s'"`;=]+/g).filter(isValidSelector);
357
285
  const extractorSplit = {
358
286
  name: "split",
@@ -486,7 +414,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
486
414
  };
487
415
  }
488
416
 
489
- const version = "0.43.0";
417
+ const version = "0.44.0";
490
418
 
491
419
  class UnoGenerator {
492
420
  constructor(userConfig = {}, defaults = {}) {
@@ -968,7 +896,6 @@ exports.entriesToCss = entriesToCss;
968
896
  exports.escapeRegExp = escapeRegExp;
969
897
  exports.escapeSelector = escapeSelector;
970
898
  exports.expandVariantGroup = expandVariantGroup;
971
- exports.extractQuoted = extractQuoted;
972
899
  exports.extractorSplit = extractorSplit;
973
900
  exports.extractorSvelte = extractorSvelte;
974
901
  exports.hasScopePlaceholder = hasScopePlaceholder;
@@ -979,7 +906,6 @@ exports.isStaticRule = isStaticRule;
979
906
  exports.isStaticShortcut = isStaticShortcut;
980
907
  exports.isString = isString;
981
908
  exports.isValidSelector = isValidSelector;
982
- exports.matchingPair = matchingPair;
983
909
  exports.mergeDeep = mergeDeep;
984
910
  exports.mergeSet = mergeSet;
985
911
  exports.movePseudoElementsEnd = movePseudoElementsEnd;
package/dist/index.d.ts CHANGED
@@ -133,8 +133,8 @@ declare class BetterMap<K, V> extends Map<K, V> {
133
133
  declare function withLayer<T>(layer: string, rules: Rule<T>[]): Rule<T>[];
134
134
 
135
135
  declare const regexClassGroup: RegExp;
136
- declare function expandVariantGroup(str: string): string;
137
- declare function expandVariantGroup(str: MagicString): MagicString;
136
+ declare function expandVariantGroup(str: string, seperators?: ('-' | ':')[]): string;
137
+ declare function expandVariantGroup(str: MagicString, seperators?: ('-' | ':')[]): MagicString;
138
138
 
139
139
  declare function warnOnce(msg: string): void;
140
140
 
@@ -149,22 +149,6 @@ declare type ValueHandler<K extends string> = {
149
149
  };
150
150
  declare function createValueHandler<K extends string>(handlers: Record<K, ValueHandlerCallback>): ValueHandler<K>;
151
151
 
152
- declare type Range = [start: number, end: number];
153
- interface ExtractStringOptions<Details extends boolean = false> {
154
- deep?: boolean;
155
- templateStaticOnly?: boolean;
156
- details?: Details;
157
- range?: Range;
158
- }
159
- interface DetailString {
160
- value: string;
161
- range: Range;
162
- quote: '\'' | '"' | '`';
163
- }
164
- declare function matchingPair(text: string, [left, right]: Iterable<string>, i: number, allowEscape?: boolean): number;
165
- declare function extractQuoted(str: string, options?: ExtractStringOptions<false>): string[];
166
- declare function extractQuoted(str: string, options: ExtractStringOptions<true>): DetailString[];
167
-
168
152
  declare type Awaitable<T> = T | Promise<T>;
169
153
  declare type Arrayable<T> = T | T[];
170
154
  declare type ArgumentType<T> = T extends ((...args: infer A) => any) ? A : never;
@@ -786,4 +770,4 @@ declare const extractorSplit: Extractor;
786
770
 
787
771
  declare const extractorSvelte: Extractor;
788
772
 
789
- export { ArgumentType, Arrayable, AutoCompleteExtractor, AutoCompleteExtractorContext, AutoCompleteExtractorResult, AutoCompleteFunction, AutoCompleteTemplate, Awaitable, BetterMap, BlocklistRule, CONTROL_SHORTCUT_NO_MERGE, CSSColorValue, CSSEntries, CSSObject, CSSValue, CSSValues, ConfigBase, DeepPartial, DetailString, DynamicMatcher, DynamicRule, DynamicShortcut, DynamicShortcutMatcher, ExtractStringOptions, Extractor, ExtractorContext, FilterPattern, FlatObjectTuple, GenerateOptions, GenerateResult, GeneratorOptions, ParsedColorValue, ParsedUtil, PartialByKeys, PluginOptions, Postprocessor, Preflight, PreflightContext, PreparedRule, Preprocessor, Preset, PresetOptions, RGBAColorValue, Range, RawUtil, Replacement, RequiredByKey, ResolvedConfig, RestArgs, Rule, RuleContext, RuleMeta, Shift, Shortcut, ShortcutValue, SourceCodeTransformer, 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, extractQuoted, extractorSplit, extractorSvelte, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isString, isValidSelector, matchingPair, mergeDeep, mergeSet, movePseudoElementsEnd, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexClassGroup, regexScopePlaceholder, toArray, toEscapedSelector, uniq, validateFilterRE, warnOnce, withLayer };
773
+ export { ArgumentType, Arrayable, AutoCompleteExtractor, AutoCompleteExtractorContext, AutoCompleteExtractorResult, AutoCompleteFunction, AutoCompleteTemplate, Awaitable, BetterMap, BlocklistRule, CONTROL_SHORTCUT_NO_MERGE, CSSColorValue, CSSEntries, CSSObject, CSSValue, CSSValues, 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, 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, mergeSet, movePseudoElementsEnd, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexClassGroup, regexScopePlaceholder, toArray, toEscapedSelector, uniq, validateFilterRE, warnOnce, withLayer };
package/dist/index.mjs CHANGED
@@ -220,17 +220,23 @@ function withLayer(layer, rules) {
220
220
  }
221
221
 
222
222
  const regexClassGroup = /([!\w+:_/-]+?)([:-])\(((?:[~!\w\s:/\\,%#.$-]|\[.*?\])*?)\)/gm;
223
- function expandVariantGroup(str) {
223
+ function expandVariantGroup(str, seperators = ["-", ":"]) {
224
224
  regexClassGroup.lastIndex = 0;
225
225
  let hasChanged = false;
226
+ let content = str.toString();
226
227
  do {
227
- const before = str.toString();
228
- str = str.replace(regexClassGroup, (_, pre, sep, body) => {
228
+ const before = content;
229
+ content = content.replace(regexClassGroup, (from, pre, sep, body) => {
230
+ if (!seperators.includes(sep))
231
+ return from;
229
232
  return body.split(/\s/g).map((i) => i === "~" ? pre : i.replace(/^(!?)(.*)/, `$1${pre}${sep}$2`)).join(" ");
230
233
  });
231
- hasChanged = str.toString() !== before;
234
+ hasChanged = content !== before;
232
235
  } while (hasChanged);
233
- return str;
236
+ if (typeof str === "string")
237
+ return content;
238
+ else
239
+ return str.overwrite(0, str.length(), content);
234
240
  }
235
241
 
236
242
  const warned = /* @__PURE__ */ new Set();
@@ -271,84 +277,6 @@ function createValueHandler(handlers) {
271
277
  return handler;
272
278
  }
273
279
 
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
-
352
280
  const splitCode = (code) => code.split(/[\s'"`;=]+/g).filter(isValidSelector);
353
281
  const extractorSplit = {
354
282
  name: "split",
@@ -482,7 +410,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
482
410
  };
483
411
  }
484
412
 
485
- const version = "0.43.0";
413
+ const version = "0.44.0";
486
414
 
487
415
  class UnoGenerator {
488
416
  constructor(userConfig = {}, defaults = {}) {
@@ -949,4 +877,4 @@ function defaultVariantHandler(input, next) {
949
877
  return next(input);
950
878
  }
951
879
 
952
- export { BetterMap, CONTROL_SHORTCUT_NO_MERGE, TwoKeyMap, UnoGenerator, attributifyRE, clearIdenticalEntries, clone, createGenerator, createValueHandler, cssIdRE, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractQuoted, extractorSplit, extractorSvelte, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isString, isValidSelector, matchingPair, mergeDeep, mergeSet, movePseudoElementsEnd, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexClassGroup, regexScopePlaceholder, toArray, toEscapedSelector, uniq, validateFilterRE, warnOnce, withLayer };
880
+ 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, mergeSet, movePseudoElementsEnd, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexClassGroup, regexScopePlaceholder, toArray, toEscapedSelector, uniq, validateFilterRE, warnOnce, withLayer };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/core",
3
- "version": "0.43.0",
3
+ "version": "0.44.0",
4
4
  "description": "The instant on-demand Atomic CSS engine.",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",