@unocss/core 0.50.6 → 0.50.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.cjs CHANGED
@@ -326,11 +326,12 @@ function createValueHandler(handlers) {
326
326
  return handler;
327
327
  }
328
328
 
329
- const defaultSplitRE = /\\?[\s'"`;{}]+/g;
329
+ const defaultSplitRE = /[\\:]?[\s'"`;{}]+/g;
330
+ const splitWithVariantGroupRE = /([\\:]?[\s"'`;<>*]|:\(|\)"|\)\s)/g;
330
331
  const quotedArbitraryValuesRE = /(?:[\w&:[\]-]|\[\S+=\S+\])+\[\\?['"]?\S+?['"]\]\]?[\w:-]*/g;
331
- const arbitraryPropertyRE = /\[(\\\W|[\w-])+:['"]?\S+?['"]?\]/g;
332
- const arbitraryPropertyCandidateRE = new RegExp(`^${arbitraryPropertyRE.source}$`);
333
- const splitCode = (code) => {
332
+ const arbitraryPropertyRE = /\[(\\\W|[\w-])+:[^\s:]*?("\S+?"|'\S+?'|`\S+?`|[^\s:]+?)[^\s:]*?\)?\]/g;
333
+ const arbitraryPropertyCandidateRE = /^\[(\\\W|[\w-])+:['"]?\S+?['"]?\]$/;
334
+ function splitCode(code) {
334
335
  const result = /* @__PURE__ */ new Set();
335
336
  for (const match of code.matchAll(arbitraryPropertyRE)) {
336
337
  if (!code[match.index - 1]?.match(/^[\s'"`]/))
@@ -340,10 +341,11 @@ const splitCode = (code) => {
340
341
  for (const match of code.matchAll(quotedArbitraryValuesRE))
341
342
  result.add(match[0]);
342
343
  code.split(defaultSplitRE).forEach((match) => {
343
- isValidSelector(match) && !arbitraryPropertyCandidateRE.test(match) && result.add(match);
344
+ if (isValidSelector(match) && !arbitraryPropertyCandidateRE.test(match))
345
+ result.add(match);
344
346
  });
345
347
  return [...result];
346
- };
348
+ }
347
349
  const extractorSplit = {
348
350
  name: "split",
349
351
  order: 0,
@@ -458,7 +460,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
458
460
  let separators = toArray(mergePresets("separators"));
459
461
  if (!separators.length)
460
462
  separators = [":", "-"];
461
- return {
463
+ const resolved = {
462
464
  mergeSelectors: true,
463
465
  warn: true,
464
466
  blocklist: [],
@@ -482,9 +484,13 @@ function resolveConfig(userConfig = {}, defaults = {}) {
482
484
  safelist: mergePresets("safelist"),
483
485
  separators
484
486
  };
487
+ for (const p of sortedPresets)
488
+ p?.configResolved?.(resolved);
489
+ userConfig?.configResolved?.(resolved);
490
+ return resolved;
485
491
  }
486
492
 
487
- const version = "0.50.6";
493
+ const version = "0.50.8";
488
494
 
489
495
  class UnoGenerator {
490
496
  constructor(userConfig = {}, defaults = {}) {
@@ -950,7 +956,9 @@ function createGenerator(config, defaults) {
950
956
  return new UnoGenerator(config, defaults);
951
957
  }
952
958
  const regexScopePlaceholder = /\s\$\$\s+/g;
953
- const hasScopePlaceholder = (css) => css.match(/\s\$\$\s/);
959
+ function hasScopePlaceholder(css) {
960
+ return css.match(/\s\$\$\s/);
961
+ }
954
962
  function applyScope(css, scope) {
955
963
  if (hasScopePlaceholder(css))
956
964
  return css.replace(regexScopePlaceholder, scope ? ` ${scope} ` : " ");
@@ -979,6 +987,7 @@ exports.collapseVariantGroup = collapseVariantGroup;
979
987
  exports.createGenerator = createGenerator;
980
988
  exports.createValueHandler = createValueHandler;
981
989
  exports.cssIdRE = cssIdRE;
990
+ exports.defaultSplitRE = defaultSplitRE;
982
991
  exports.e = e;
983
992
  exports.entriesToCss = entriesToCss;
984
993
  exports.escapeRegExp = escapeRegExp;
@@ -1004,6 +1013,7 @@ exports.notNull = notNull;
1004
1013
  exports.parseVariantGroup = parseVariantGroup;
1005
1014
  exports.quotedArbitraryValuesRE = quotedArbitraryValuesRE;
1006
1015
  exports.regexScopePlaceholder = regexScopePlaceholder;
1016
+ exports.splitWithVariantGroupRE = splitWithVariantGroupRE;
1007
1017
  exports.toArray = toArray;
1008
1018
  exports.toEscapedSelector = toEscapedSelector;
1009
1019
  exports.uniq = uniq;
package/dist/index.d.ts CHANGED
@@ -79,7 +79,7 @@ declare class UnoGenerator<Theme extends {} = {}> {
79
79
  }
80
80
  declare function createGenerator<Theme extends {} = {}>(config?: UserConfig<Theme>, defaults?: UserConfigDefaults<Theme>): UnoGenerator<Theme>;
81
81
  declare const regexScopePlaceholder: RegExp;
82
- declare const hasScopePlaceholder: (css: string) => RegExpMatchArray | null;
82
+ declare function hasScopePlaceholder(css: string): RegExpMatchArray | null;
83
83
  declare function toEscapedSelector(raw: string): string;
84
84
 
85
85
  declare function escapeRegExp(string: string): string;
@@ -510,6 +510,12 @@ interface ConfigBase<Theme extends {} = {}> {
510
510
  */
511
511
  extractors?: Arrayable<AutoCompleteExtractor>;
512
512
  };
513
+ /**
514
+ * Hook to modify the resolved config.
515
+ *
516
+ * First presets runs first and the user config
517
+ */
518
+ configResolved?: (config: ResolvedConfig) => void;
513
519
  /**
514
520
  * Expose internal details for debugging / inspecting
515
521
  *
@@ -572,6 +578,9 @@ interface AutoCompleteExtractor {
572
578
  }
573
579
  interface Preset<Theme extends {} = {}> extends ConfigBase<Theme> {
574
580
  name: string;
581
+ /**
582
+ * Enforce the preset to be applied before or after other presets
583
+ */
575
584
  enforce?: 'pre' | 'post';
576
585
  /**
577
586
  * Preset options for other tools like IDE to consume
@@ -825,10 +834,12 @@ interface GenerateOptions {
825
834
  scope?: string;
826
835
  }
827
836
 
837
+ declare const defaultSplitRE: RegExp;
838
+ declare const splitWithVariantGroupRE: RegExp;
828
839
  declare const quotedArbitraryValuesRE: RegExp;
829
840
  declare const arbitraryPropertyRE: RegExp;
830
841
  declare const extractorSplit: Extractor;
831
842
 
832
843
  declare const extractorSvelte: Extractor;
833
844
 
834
- 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, ExtraContentOptions, 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, collapseVariantGroup, createGenerator, createValueHandler, cssIdRE, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit, extractorSvelte, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isString, isValidSelector, makeRegexClassGroup, mergeDeep, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, parseVariantGroup, quotedArbitraryValuesRE, regexScopePlaceholder, toArray, toEscapedSelector, uniq, validateFilterRE, warnOnce, withLayer };
845
+ 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, ExtraContentOptions, 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, collapseVariantGroup, createGenerator, createValueHandler, cssIdRE, defaultSplitRE, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit, extractorSvelte, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isString, isValidSelector, makeRegexClassGroup, mergeDeep, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, parseVariantGroup, quotedArbitraryValuesRE, regexScopePlaceholder, splitWithVariantGroupRE, toArray, toEscapedSelector, uniq, validateFilterRE, warnOnce, withLayer };
package/dist/index.mjs CHANGED
@@ -322,11 +322,12 @@ function createValueHandler(handlers) {
322
322
  return handler;
323
323
  }
324
324
 
325
- const defaultSplitRE = /\\?[\s'"`;{}]+/g;
325
+ const defaultSplitRE = /[\\:]?[\s'"`;{}]+/g;
326
+ const splitWithVariantGroupRE = /([\\:]?[\s"'`;<>*]|:\(|\)"|\)\s)/g;
326
327
  const quotedArbitraryValuesRE = /(?:[\w&:[\]-]|\[\S+=\S+\])+\[\\?['"]?\S+?['"]\]\]?[\w:-]*/g;
327
- const arbitraryPropertyRE = /\[(\\\W|[\w-])+:['"]?\S+?['"]?\]/g;
328
- const arbitraryPropertyCandidateRE = new RegExp(`^${arbitraryPropertyRE.source}$`);
329
- const splitCode = (code) => {
328
+ const arbitraryPropertyRE = /\[(\\\W|[\w-])+:[^\s:]*?("\S+?"|'\S+?'|`\S+?`|[^\s:]+?)[^\s:]*?\)?\]/g;
329
+ const arbitraryPropertyCandidateRE = /^\[(\\\W|[\w-])+:['"]?\S+?['"]?\]$/;
330
+ function splitCode(code) {
330
331
  const result = /* @__PURE__ */ new Set();
331
332
  for (const match of code.matchAll(arbitraryPropertyRE)) {
332
333
  if (!code[match.index - 1]?.match(/^[\s'"`]/))
@@ -336,10 +337,11 @@ const splitCode = (code) => {
336
337
  for (const match of code.matchAll(quotedArbitraryValuesRE))
337
338
  result.add(match[0]);
338
339
  code.split(defaultSplitRE).forEach((match) => {
339
- isValidSelector(match) && !arbitraryPropertyCandidateRE.test(match) && result.add(match);
340
+ if (isValidSelector(match) && !arbitraryPropertyCandidateRE.test(match))
341
+ result.add(match);
340
342
  });
341
343
  return [...result];
342
- };
344
+ }
343
345
  const extractorSplit = {
344
346
  name: "split",
345
347
  order: 0,
@@ -454,7 +456,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
454
456
  let separators = toArray(mergePresets("separators"));
455
457
  if (!separators.length)
456
458
  separators = [":", "-"];
457
- return {
459
+ const resolved = {
458
460
  mergeSelectors: true,
459
461
  warn: true,
460
462
  blocklist: [],
@@ -478,9 +480,13 @@ function resolveConfig(userConfig = {}, defaults = {}) {
478
480
  safelist: mergePresets("safelist"),
479
481
  separators
480
482
  };
483
+ for (const p of sortedPresets)
484
+ p?.configResolved?.(resolved);
485
+ userConfig?.configResolved?.(resolved);
486
+ return resolved;
481
487
  }
482
488
 
483
- const version = "0.50.6";
489
+ const version = "0.50.8";
484
490
 
485
491
  class UnoGenerator {
486
492
  constructor(userConfig = {}, defaults = {}) {
@@ -946,7 +952,9 @@ function createGenerator(config, defaults) {
946
952
  return new UnoGenerator(config, defaults);
947
953
  }
948
954
  const regexScopePlaceholder = /\s\$\$\s+/g;
949
- const hasScopePlaceholder = (css) => css.match(/\s\$\$\s/);
955
+ function hasScopePlaceholder(css) {
956
+ return css.match(/\s\$\$\s/);
957
+ }
950
958
  function applyScope(css, scope) {
951
959
  if (hasScopePlaceholder(css))
952
960
  return css.replace(regexScopePlaceholder, scope ? ` ${scope} ` : " ");
@@ -963,4 +971,4 @@ function defaultVariantHandler(input, next) {
963
971
  return next(input);
964
972
  }
965
973
 
966
- export { BetterMap, CONTROL_SHORTCUT_NO_MERGE, TwoKeyMap, UnoGenerator, arbitraryPropertyRE, attributifyRE, clearIdenticalEntries, clone, collapseVariantGroup, createGenerator, createValueHandler, cssIdRE, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit, extractorSvelte, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isString, isValidSelector, makeRegexClassGroup, mergeDeep, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, parseVariantGroup, quotedArbitraryValuesRE, regexScopePlaceholder, toArray, toEscapedSelector, uniq, validateFilterRE, warnOnce, withLayer };
974
+ export { BetterMap, CONTROL_SHORTCUT_NO_MERGE, TwoKeyMap, UnoGenerator, arbitraryPropertyRE, attributifyRE, clearIdenticalEntries, clone, collapseVariantGroup, createGenerator, createValueHandler, cssIdRE, defaultSplitRE, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit, extractorSvelte, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isString, isValidSelector, makeRegexClassGroup, mergeDeep, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, parseVariantGroup, quotedArbitraryValuesRE, regexScopePlaceholder, splitWithVariantGroupRE, toArray, toEscapedSelector, uniq, validateFilterRE, warnOnce, withLayer };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/core",
3
- "version": "0.50.6",
3
+ "version": "0.50.8",
4
4
  "description": "The instant on-demand Atomic CSS engine.",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",