@unocss/core 0.48.1 → 0.48.2

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
@@ -358,9 +358,9 @@ function resolvePreset(preset) {
358
358
  i[2] = {};
359
359
  const meta = i[2];
360
360
  if (meta.prefix == null && preset.prefix)
361
- meta.prefix = preset.prefix;
361
+ meta.prefix = toArray(preset.prefix);
362
362
  if (meta.layer == null && preset.layer)
363
- meta.prefix = preset.layer;
363
+ meta.layer = preset.layer;
364
364
  };
365
365
  shortcuts?.forEach(apply);
366
366
  preset.rules?.forEach(apply);
@@ -391,8 +391,10 @@ function resolveConfig(userConfig = {}, defaults = {}) {
391
391
  const rulesSize = rules.length;
392
392
  const rulesDynamic = rules.map((rule, i) => {
393
393
  if (isStaticRule(rule)) {
394
- const prefix = rule[2]?.prefix || "";
395
- rulesStaticMap[prefix + rule[0]] = [i, rule[1], rule[2], rule];
394
+ const prefixes = toArray(rule[2]?.prefix || "");
395
+ prefixes.forEach((prefix) => {
396
+ rulesStaticMap[prefix + rule[0]] = [i, rule[1], rule[2], rule];
397
+ });
396
398
  return void 0;
397
399
  }
398
400
  return [i, ...rule];
@@ -431,7 +433,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
431
433
  };
432
434
  }
433
435
 
434
- const version = "0.48.1";
436
+ const version = "0.48.2";
435
437
 
436
438
  class UnoGenerator {
437
439
  constructor(userConfig = {}, defaults = {}) {
@@ -719,7 +721,7 @@ class UnoGenerator {
719
721
  return `${parent}{${cssBody}}`;
720
722
  return cssBody;
721
723
  }
722
- async parseUtil(input, context, internal = false, shortcutPrefix = void 0) {
724
+ async parseUtil(input, context, internal = false, shortcutPrefix) {
723
725
  const [raw, processed, variantHandlers] = isString(input) ? this.matchVariants(input) : input;
724
726
  if (this.config.details)
725
727
  context.rules = context.rules ?? [];
@@ -744,13 +746,16 @@ class UnoGenerator {
744
746
  continue;
745
747
  let unprefixed = processed;
746
748
  if (meta?.prefix) {
749
+ const prefixes = toArray(meta.prefix);
747
750
  if (shortcutPrefix) {
748
- if (shortcutPrefix !== meta.prefix)
751
+ const shortcutPrefixes = toArray(shortcutPrefix);
752
+ if (!prefixes.some((i2) => shortcutPrefixes.includes(i2)))
749
753
  continue;
750
754
  } else {
751
- if (!processed.startsWith(meta.prefix))
755
+ const prefix = prefixes.find((i2) => processed.startsWith(i2));
756
+ if (prefix == null)
752
757
  continue;
753
- unprefixed = processed.slice(meta.prefix.length);
758
+ unprefixed = processed.slice(prefix.length);
754
759
  }
755
760
  }
756
761
  const match = unprefixed.match(matcher);
@@ -801,9 +806,11 @@ class UnoGenerator {
801
806
  for (const s of this.config.shortcuts) {
802
807
  let unprefixed = input;
803
808
  if (s[2]?.prefix) {
804
- if (!input.startsWith(s[2].prefix))
809
+ const prefixes = toArray(s[2].prefix);
810
+ const prefix = prefixes.find((i) => input.startsWith(i));
811
+ if (prefix == null)
805
812
  continue;
806
- unprefixed = input.slice(s[2].prefix.length);
813
+ unprefixed = input.slice(prefix.length);
807
814
  }
808
815
  if (isStaticShortcut(s)) {
809
816
  if (s[0] === unprefixed) {
package/dist/index.d.ts CHANGED
@@ -71,7 +71,7 @@ declare class UnoGenerator<Theme extends {} = {}> {
71
71
  matchVariants(raw: string, current?: string): VariantMatchedResult<Theme>;
72
72
  private applyVariants;
73
73
  constructCustomCSS(context: Readonly<RuleContext<Theme>>, body: CSSObject | CSSEntries, overrideSelector?: string): string;
74
- parseUtil(input: string | VariantMatchedResult<Theme>, context: RuleContext<Theme>, internal?: boolean, shortcutPrefix?: string | undefined): Promise<(ParsedUtil | RawUtil)[] | undefined>;
74
+ parseUtil(input: string | VariantMatchedResult<Theme>, context: RuleContext<Theme>, internal?: boolean, shortcutPrefix?: string | string[] | undefined): Promise<(ParsedUtil | RawUtil)[] | undefined>;
75
75
  stringifyUtil(parsed?: ParsedUtil | RawUtil, context?: RuleContext<Theme>): StringifiedUtil<Theme> | undefined;
76
76
  expandShortcut(input: string, context: RuleContext<Theme>, depth?: number): [ShortcutValue[], RuleMeta | undefined] | undefined;
77
77
  stringifyShortcuts(parent: VariantMatchedResult<Theme>, context: RuleContext<Theme>, expanded: ShortcutValue[], meta?: RuleMeta): Promise<StringifiedUtil<Theme>[] | undefined>;
@@ -296,7 +296,7 @@ interface RuleMeta {
296
296
  /**
297
297
  * Matching prefix before this util
298
298
  */
299
- prefix?: string;
299
+ prefix?: string | string[];
300
300
  /**
301
301
  * Internal rules will only be matched for shortcuts but not the user code.
302
302
  * @default false
@@ -561,7 +561,7 @@ interface Preset<Theme extends {} = {}> extends ConfigBase<Theme> {
561
561
  /**
562
562
  * Apply prefix to all utilities and shortcuts
563
563
  */
564
- prefix?: string;
564
+ prefix?: string | string[];
565
565
  /**
566
566
  * Apply layer to all utilities and shortcuts
567
567
  */
package/dist/index.mjs CHANGED
@@ -354,9 +354,9 @@ function resolvePreset(preset) {
354
354
  i[2] = {};
355
355
  const meta = i[2];
356
356
  if (meta.prefix == null && preset.prefix)
357
- meta.prefix = preset.prefix;
357
+ meta.prefix = toArray(preset.prefix);
358
358
  if (meta.layer == null && preset.layer)
359
- meta.prefix = preset.layer;
359
+ meta.layer = preset.layer;
360
360
  };
361
361
  shortcuts?.forEach(apply);
362
362
  preset.rules?.forEach(apply);
@@ -387,8 +387,10 @@ function resolveConfig(userConfig = {}, defaults = {}) {
387
387
  const rulesSize = rules.length;
388
388
  const rulesDynamic = rules.map((rule, i) => {
389
389
  if (isStaticRule(rule)) {
390
- const prefix = rule[2]?.prefix || "";
391
- rulesStaticMap[prefix + rule[0]] = [i, rule[1], rule[2], rule];
390
+ const prefixes = toArray(rule[2]?.prefix || "");
391
+ prefixes.forEach((prefix) => {
392
+ rulesStaticMap[prefix + rule[0]] = [i, rule[1], rule[2], rule];
393
+ });
392
394
  return void 0;
393
395
  }
394
396
  return [i, ...rule];
@@ -427,7 +429,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
427
429
  };
428
430
  }
429
431
 
430
- const version = "0.48.1";
432
+ const version = "0.48.2";
431
433
 
432
434
  class UnoGenerator {
433
435
  constructor(userConfig = {}, defaults = {}) {
@@ -715,7 +717,7 @@ class UnoGenerator {
715
717
  return `${parent}{${cssBody}}`;
716
718
  return cssBody;
717
719
  }
718
- async parseUtil(input, context, internal = false, shortcutPrefix = void 0) {
720
+ async parseUtil(input, context, internal = false, shortcutPrefix) {
719
721
  const [raw, processed, variantHandlers] = isString(input) ? this.matchVariants(input) : input;
720
722
  if (this.config.details)
721
723
  context.rules = context.rules ?? [];
@@ -740,13 +742,16 @@ class UnoGenerator {
740
742
  continue;
741
743
  let unprefixed = processed;
742
744
  if (meta?.prefix) {
745
+ const prefixes = toArray(meta.prefix);
743
746
  if (shortcutPrefix) {
744
- if (shortcutPrefix !== meta.prefix)
747
+ const shortcutPrefixes = toArray(shortcutPrefix);
748
+ if (!prefixes.some((i2) => shortcutPrefixes.includes(i2)))
745
749
  continue;
746
750
  } else {
747
- if (!processed.startsWith(meta.prefix))
751
+ const prefix = prefixes.find((i2) => processed.startsWith(i2));
752
+ if (prefix == null)
748
753
  continue;
749
- unprefixed = processed.slice(meta.prefix.length);
754
+ unprefixed = processed.slice(prefix.length);
750
755
  }
751
756
  }
752
757
  const match = unprefixed.match(matcher);
@@ -797,9 +802,11 @@ class UnoGenerator {
797
802
  for (const s of this.config.shortcuts) {
798
803
  let unprefixed = input;
799
804
  if (s[2]?.prefix) {
800
- if (!input.startsWith(s[2].prefix))
805
+ const prefixes = toArray(s[2].prefix);
806
+ const prefix = prefixes.find((i) => input.startsWith(i));
807
+ if (prefix == null)
801
808
  continue;
802
- unprefixed = input.slice(s[2].prefix.length);
809
+ unprefixed = input.slice(prefix.length);
803
810
  }
804
811
  if (isStaticShortcut(s)) {
805
812
  if (s[0] === unprefixed) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/core",
3
- "version": "0.48.1",
3
+ "version": "0.48.2",
4
4
  "description": "The instant on-demand Atomic CSS engine.",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",