@unocss/core 66.5.10-beta.1 → 66.5.10

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.d.mts CHANGED
@@ -180,7 +180,7 @@ declare class UnoGeneratorInternal<Theme extends object = object> {
180
180
  constructCustomCSS(context: Readonly<RuleContext<Theme>>, body: CSSObject | CSSEntries, overrideSelector?: string): string;
181
181
  parseUtil(input: string | VariantMatchedResult<Theme>, context: RuleContext<Theme>, internal?: boolean, shortcutPrefix?: string | string[] | undefined): Promise<(ParsedUtil | RawUtil)[] | undefined>;
182
182
  private resolveCSSResult;
183
- stringifyUtil(parsed?: ParsedUtil | RawUtil, context?: RuleContext<Theme>): StringifiedUtil<Theme> | undefined;
183
+ stringifyUtil(parsed?: ParsedUtil | RawUtil, context?: RuleContext<Theme>): StringifiedUtil<Theme>[] | undefined;
184
184
  expandShortcut(input: string, context: RuleContext<Theme>, depth?: number): Promise<[(string | ShortcutInlineValue)[], RuleMeta | undefined] | undefined>;
185
185
  stringifyShortcuts(parent: VariantMatchedResult<Theme>, context: RuleContext<Theme>, expanded: (string | ShortcutInlineValue)[], meta?: RuleMeta): Promise<StringifiedUtil<Theme>[] | undefined>;
186
186
  isBlocked(raw: string): boolean;
@@ -548,7 +548,7 @@ interface VariantObject<Theme extends object = object> {
548
548
  }
549
549
  type Variant<Theme extends object = object> = VariantFunction<Theme> | VariantObject<Theme>;
550
550
  type Preprocessor = (matcher: string) => string | undefined;
551
- type Postprocessor = (util: UtilObject) => void;
551
+ type Postprocessor = (util: UtilObject) => void | UtilObject | (UtilObject | null | undefined)[];
552
552
  type ThemeExtender<Theme extends object = object> = (theme: Theme, config: Readonly<ResolvedConfig<Theme>>) => Theme | void;
553
553
  interface ConfigBase<Theme extends object = object> {
554
554
  /**
package/dist/index.d.ts CHANGED
@@ -180,7 +180,7 @@ declare class UnoGeneratorInternal<Theme extends object = object> {
180
180
  constructCustomCSS(context: Readonly<RuleContext<Theme>>, body: CSSObject | CSSEntries, overrideSelector?: string): string;
181
181
  parseUtil(input: string | VariantMatchedResult<Theme>, context: RuleContext<Theme>, internal?: boolean, shortcutPrefix?: string | string[] | undefined): Promise<(ParsedUtil | RawUtil)[] | undefined>;
182
182
  private resolveCSSResult;
183
- stringifyUtil(parsed?: ParsedUtil | RawUtil, context?: RuleContext<Theme>): StringifiedUtil<Theme> | undefined;
183
+ stringifyUtil(parsed?: ParsedUtil | RawUtil, context?: RuleContext<Theme>): StringifiedUtil<Theme>[] | undefined;
184
184
  expandShortcut(input: string, context: RuleContext<Theme>, depth?: number): Promise<[(string | ShortcutInlineValue)[], RuleMeta | undefined] | undefined>;
185
185
  stringifyShortcuts(parent: VariantMatchedResult<Theme>, context: RuleContext<Theme>, expanded: (string | ShortcutInlineValue)[], meta?: RuleMeta): Promise<StringifiedUtil<Theme>[] | undefined>;
186
186
  isBlocked(raw: string): boolean;
@@ -548,7 +548,7 @@ interface VariantObject<Theme extends object = object> {
548
548
  }
549
549
  type Variant<Theme extends object = object> = VariantFunction<Theme> | VariantObject<Theme>;
550
550
  type Preprocessor = (matcher: string) => string | undefined;
551
- type Postprocessor = (util: UtilObject) => void;
551
+ type Postprocessor = (util: UtilObject) => void | UtilObject | (UtilObject | null | undefined)[];
552
552
  type ThemeExtender<Theme extends object = object> = (theme: Theme, config: Readonly<ResolvedConfig<Theme>>) => Theme | void;
553
553
  interface ConfigBase<Theme extends object = object> {
554
554
  /**
package/dist/index.mjs CHANGED
@@ -654,7 +654,7 @@ function definePreset(preset) {
654
654
  return preset;
655
655
  }
656
656
 
657
- const version = "66.5.10-beta.1";
657
+ const version = "66.5.10";
658
658
 
659
659
  const symbols = {
660
660
  shortcutsNoMerge: "$$symbol-shortcut-no-merge",
@@ -755,7 +755,7 @@ class UnoGeneratorInternal {
755
755
  if (this.config.details)
756
756
  context.variants = [...matched[3]];
757
757
  const expanded = await this.expandShortcut(context.currentSelector, context);
758
- const utils = expanded ? await this.stringifyShortcuts(context.variantMatch, context, expanded[0], expanded[1]) : (await this.parseUtil(context.variantMatch, context))?.map((i) => this.stringifyUtil(i, context)).filter(notNull);
758
+ const utils = expanded ? await this.stringifyShortcuts(context.variantMatch, context, expanded[0], expanded[1]) : (await this.parseUtil(context.variantMatch, context))?.flatMap((i) => this.stringifyUtil(i, context)).filter(notNull);
759
759
  return utils;
760
760
  };
761
761
  const result = (await Promise.all(variantResults.map((i) => handleVariantResult(i)))).flat().filter((x) => !!x);
@@ -1027,19 +1027,32 @@ class UnoGeneratorInternal {
1027
1027
  sort: variantContextResult.sort,
1028
1028
  noMerge: variantContextResult.noMerge
1029
1029
  };
1030
- for (const p of this.config.postprocess)
1031
- p(obj);
1032
- return obj;
1030
+ return this.config.postprocess.reduce(
1031
+ (utilities, p) => {
1032
+ const result = [];
1033
+ for (const util of utilities) {
1034
+ const processed = p(util);
1035
+ if (Array.isArray(processed)) {
1036
+ result.push(...processed.filter(notNull));
1037
+ } else {
1038
+ result.push(processed || util);
1039
+ }
1040
+ }
1041
+ return result;
1042
+ },
1043
+ [obj]
1044
+ );
1033
1045
  }
1034
1046
  constructCustomCSS(context, body, overrideSelector) {
1035
1047
  const normalizedBody = normalizeCSSEntries(body);
1036
1048
  if (isString(normalizedBody))
1037
1049
  return normalizedBody;
1038
- const { selector, entries, parent } = this.applyVariants([0, overrideSelector || context.rawSelector, normalizedBody, void 0, context.variantHandlers]);
1039
- const cssBody = `${selector}{${entriesToCss(entries)}}`;
1040
- if (parent)
1041
- return `${parent}{${cssBody}}`;
1042
- return cssBody;
1050
+ return this.applyVariants([0, overrideSelector || context.rawSelector, normalizedBody, void 0, context.variantHandlers]).map(({ selector, entries, parent }) => {
1051
+ const cssBody = `${selector}{${entriesToCss(entries)}}`;
1052
+ if (parent)
1053
+ return `${parent}{${cssBody}}`;
1054
+ return cssBody;
1055
+ }).join("");
1043
1056
  }
1044
1057
  async parseUtil(input, context, internal = false, shortcutPrefix) {
1045
1058
  const variantResults = isString(input) ? await this.matchVariants(input) : [input];
@@ -1163,25 +1176,30 @@ class UnoGeneratorInternal {
1163
1176
  if (!parsed)
1164
1177
  return;
1165
1178
  if (isRawUtil(parsed))
1166
- return [parsed[0], void 0, parsed[1], void 0, parsed[2], this.config.details ? context : void 0, void 0];
1167
- const {
1168
- selector,
1169
- entries,
1170
- parent,
1171
- layer: variantLayer,
1172
- sort: variantSort,
1173
- noMerge
1174
- } = this.applyVariants(parsed);
1175
- const body = entriesToCss(entries);
1176
- if (!body)
1177
- return;
1178
- const { layer: metaLayer, sort: metaSort, ...meta } = parsed[3] ?? {};
1179
- const ruleMeta = {
1180
- ...meta,
1181
- layer: variantLayer ?? metaLayer,
1182
- sort: variantSort ?? metaSort
1183
- };
1184
- return [parsed[0], selector, body, parent, ruleMeta, this.config.details ? context : void 0, noMerge];
1179
+ return [[parsed[0], void 0, parsed[1], void 0, parsed[2], this.config.details ? context : void 0, void 0]];
1180
+ const utilities = this.applyVariants(parsed);
1181
+ const result = [];
1182
+ for (const util of utilities) {
1183
+ const {
1184
+ selector,
1185
+ entries,
1186
+ parent,
1187
+ layer: variantLayer,
1188
+ sort: variantSort,
1189
+ noMerge
1190
+ } = util;
1191
+ const body = entriesToCss(entries);
1192
+ if (!body)
1193
+ continue;
1194
+ const { layer: metaLayer, sort: metaSort, ...meta } = parsed[3] ?? {};
1195
+ const ruleMeta = {
1196
+ ...meta,
1197
+ layer: variantLayer ?? metaLayer,
1198
+ sort: variantSort ?? metaSort
1199
+ };
1200
+ result.push([parsed[0], selector, body, parent, ruleMeta, this.config.details ? context : void 0, noMerge]);
1201
+ }
1202
+ return result;
1185
1203
  }
1186
1204
  async expandShortcut(input, context, depth = 5) {
1187
1205
  if (depth === 0)
@@ -1267,10 +1285,11 @@ class UnoGeneratorInternal {
1267
1285
  }
1268
1286
  const isNoMerge = Object.fromEntries(item[2])[symbols.shortcutsNoMerge];
1269
1287
  const variants = [...item[4], ...!isNoMerge ? parentVariants : []];
1270
- const { selector, entries, parent: parent2, sort, noMerge, layer } = this.applyVariants(item, variants, raw);
1271
- const selectorMap = layerMap.getFallback(layer ?? meta.layer, new TwoKeyMap());
1272
- const mapItem = selectorMap.getFallback(selector, parent2, [[], item[0]]);
1273
- mapItem[0].push([entries, !!(noMerge ?? item[3]?.noMerge), sort ?? 0]);
1288
+ for (const { selector, entries, parent: parent2, sort, noMerge, layer } of this.applyVariants(item, variants, raw)) {
1289
+ const selectorMap = layerMap.getFallback(layer ?? meta.layer, new TwoKeyMap());
1290
+ const mapItem = selectorMap.getFallback(selector, parent2, [[], item[0]]);
1291
+ mapItem[0].push([entries, !!(noMerge ?? item[3]?.noMerge), sort ?? 0]);
1292
+ }
1274
1293
  }
1275
1294
  return rawStringifiedUtil.concat(layerMap.flatMap(
1276
1295
  (selectorMap, layer) => selectorMap.map(([e2, index], selector, joinedParents) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unocss/core",
3
3
  "type": "module",
4
- "version": "66.5.10-beta.1",
4
+ "version": "66.5.10",
5
5
  "description": "The instant on-demand Atomic CSS engine.",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",