@unocss/core 66.2.2 → 66.2.3

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
@@ -178,6 +178,7 @@ declare class UnoGeneratorInternal<Theme extends object = object> {
178
178
  private applyVariants;
179
179
  constructCustomCSS(context: Readonly<RuleContext<Theme>>, body: CSSObject | CSSEntries, overrideSelector?: string): string;
180
180
  parseUtil(input: string | VariantMatchedResult<Theme>, context: RuleContext<Theme>, internal?: boolean, shortcutPrefix?: string | string[] | undefined): Promise<(ParsedUtil | RawUtil)[] | undefined>;
181
+ private resolveCSSResult;
181
182
  stringifyUtil(parsed?: ParsedUtil | RawUtil, context?: RuleContext<Theme>): StringifiedUtil<Theme> | undefined;
182
183
  expandShortcut(input: string, context: RuleContext<Theme>, depth?: number): Promise<[(string | ShortcutInlineValue)[], RuleMeta | undefined] | undefined>;
183
184
  stringifyShortcuts(parent: VariantMatchedResult<Theme>, context: RuleContext<Theme>, expanded: (string | ShortcutInlineValue)[], meta?: RuleMeta): Promise<StringifiedUtil<Theme>[] | undefined>;
package/dist/index.d.ts CHANGED
@@ -178,6 +178,7 @@ declare class UnoGeneratorInternal<Theme extends object = object> {
178
178
  private applyVariants;
179
179
  constructCustomCSS(context: Readonly<RuleContext<Theme>>, body: CSSObject | CSSEntries, overrideSelector?: string): string;
180
180
  parseUtil(input: string | VariantMatchedResult<Theme>, context: RuleContext<Theme>, internal?: boolean, shortcutPrefix?: string | string[] | undefined): Promise<(ParsedUtil | RawUtil)[] | undefined>;
181
+ private resolveCSSResult;
181
182
  stringifyUtil(parsed?: ParsedUtil | RawUtil, context?: RuleContext<Theme>): StringifiedUtil<Theme> | undefined;
182
183
  expandShortcut(input: string, context: RuleContext<Theme>, depth?: number): Promise<[(string | ShortcutInlineValue)[], RuleMeta | undefined] | undefined>;
183
184
  stringifyShortcuts(parent: VariantMatchedResult<Theme>, context: RuleContext<Theme>, expanded: (string | ShortcutInlineValue)[], meta?: RuleMeta): Promise<StringifiedUtil<Theme>[] | undefined>;
package/dist/index.mjs CHANGED
@@ -656,7 +656,7 @@ function definePreset(preset) {
656
656
  return preset;
657
657
  }
658
658
 
659
- const version = "66.2.2";
659
+ const version = "66.2.3";
660
660
 
661
661
  const symbols = {
662
662
  shortcutsNoMerge: "$$symbol-shortcut-no-merge",
@@ -1049,27 +1049,17 @@ class UnoGeneratorInternal {
1049
1049
  const parse = async ([raw, processed, variantHandlers]) => {
1050
1050
  if (this.config.details)
1051
1051
  context.rules = context.rules ?? [];
1052
+ const scopeContext = {
1053
+ ...context,
1054
+ variantHandlers
1055
+ };
1052
1056
  const staticMatch = this.config.rulesStaticMap[processed];
1053
1057
  if (staticMatch) {
1054
1058
  if (staticMatch[1] && (internal || !staticMatch[2]?.internal)) {
1055
- if (this.config.details)
1056
- context.rules.push(staticMatch);
1057
- const index = this.config.rules.indexOf(staticMatch);
1058
- const entries = normalizeCSSValues(staticMatch[1]).filter((i) => i.length);
1059
- const meta = staticMatch[2];
1060
- if (entries.length) {
1061
- context.generator.activatedRules.add(staticMatch);
1062
- return entries.map((css) => {
1063
- if (isString(css))
1064
- return [index, css, meta];
1065
- return [index, raw, css, meta, variantHandlers];
1066
- });
1067
- }
1059
+ return this.resolveCSSResult(raw, staticMatch[1], staticMatch, scopeContext);
1068
1060
  }
1069
1061
  }
1070
- context.variantHandlers = variantHandlers;
1071
- const { rulesDynamic } = this.config;
1072
- for (const rule of rulesDynamic) {
1062
+ for (const rule of this.config.rulesDynamic) {
1073
1063
  const [matcher, handler, meta] = rule;
1074
1064
  if (meta?.internal && !internal)
1075
1065
  continue;
@@ -1090,71 +1080,24 @@ class UnoGeneratorInternal {
1090
1080
  const match = unprefixed.match(matcher);
1091
1081
  if (!match)
1092
1082
  continue;
1093
- let result = await handler(match, context);
1083
+ let result = await handler(match, scopeContext);
1094
1084
  if (!result)
1095
1085
  continue;
1096
- if (this.config.details)
1097
- context.rules.push(rule);
1098
1086
  if (typeof result !== "string") {
1099
1087
  if (Symbol.asyncIterator in result) {
1100
- const entries2 = [];
1088
+ const entries = [];
1101
1089
  for await (const r of result) {
1102
1090
  if (r)
1103
- entries2.push(r);
1091
+ entries.push(r);
1104
1092
  }
1105
- result = entries2;
1093
+ result = entries;
1106
1094
  } else if (Symbol.iterator in result && !Array.isArray(result)) {
1107
1095
  result = Array.from(result).filter(notNull);
1108
1096
  }
1109
1097
  }
1110
- const entries = normalizeCSSValues(result).filter((i) => i.length);
1111
- if (entries.length) {
1112
- context.generator.activatedRules.add(rule);
1113
- const index = this.config.rules.indexOf(rule);
1114
- return entries.map((css) => {
1115
- if (isString(css))
1116
- return [index, css, meta];
1117
- let variants = variantHandlers;
1118
- let entryMeta = meta;
1119
- for (const entry of css) {
1120
- if (entry[0] === symbols.variants) {
1121
- if (typeof entry[1] === "function") {
1122
- variants = entry[1](variants) || variants;
1123
- } else {
1124
- variants = [
1125
- ...toArray(entry[1]),
1126
- ...variants
1127
- ];
1128
- }
1129
- } else if (entry[0] === symbols.parent) {
1130
- variants = [
1131
- { parent: entry[1] },
1132
- ...variants
1133
- ];
1134
- } else if (entry[0] === symbols.selector) {
1135
- variants = [
1136
- { selector: entry[1] },
1137
- ...variants
1138
- ];
1139
- } else if (entry[0] === symbols.layer) {
1140
- variants = [
1141
- { layer: entry[1] },
1142
- ...variants
1143
- ];
1144
- } else if (entry[0] === symbols.sort) {
1145
- entryMeta = {
1146
- ...entryMeta,
1147
- sort: entry[1]
1148
- };
1149
- } else if (entry[0] === symbols.noMerge) {
1150
- entryMeta = {
1151
- ...entryMeta,
1152
- noMerge: entry[1]
1153
- };
1154
- }
1155
- }
1156
- return [index, raw, css, entryMeta, variants];
1157
- });
1098
+ const resolvedResult = this.resolveCSSResult(raw, result, rule, scopeContext);
1099
+ if (resolvedResult) {
1100
+ return resolvedResult;
1158
1101
  }
1159
1102
  }
1160
1103
  };
@@ -1163,6 +1106,61 @@ class UnoGeneratorInternal {
1163
1106
  return void 0;
1164
1107
  return parsed;
1165
1108
  }
1109
+ resolveCSSResult = (raw, result, rule, context) => {
1110
+ const entries = normalizeCSSValues(result).filter((i) => i.length);
1111
+ if (entries.length) {
1112
+ if (this.config.details) {
1113
+ context.rules.push(rule);
1114
+ }
1115
+ context.generator.activatedRules.add(rule);
1116
+ const index = context.generator.config.rules.indexOf(rule);
1117
+ const meta = rule[2];
1118
+ return entries.map((css) => {
1119
+ if (isString(css))
1120
+ return [index, css, meta];
1121
+ let variants = context.variantHandlers;
1122
+ let entryMeta = meta;
1123
+ for (const entry of css) {
1124
+ if (entry[0] === symbols.variants) {
1125
+ if (typeof entry[1] === "function") {
1126
+ variants = entry[1](variants) || variants;
1127
+ } else {
1128
+ variants = [
1129
+ ...toArray(entry[1]),
1130
+ ...variants
1131
+ ];
1132
+ }
1133
+ } else if (entry[0] === symbols.parent) {
1134
+ variants = [
1135
+ { parent: entry[1] },
1136
+ ...variants
1137
+ ];
1138
+ } else if (entry[0] === symbols.selector) {
1139
+ variants = [
1140
+ { selector: entry[1] },
1141
+ ...variants
1142
+ ];
1143
+ } else if (entry[0] === symbols.layer) {
1144
+ variants = [
1145
+ { layer: entry[1] },
1146
+ ...variants
1147
+ ];
1148
+ } else if (entry[0] === symbols.sort) {
1149
+ entryMeta = {
1150
+ ...entryMeta,
1151
+ sort: entry[1]
1152
+ };
1153
+ } else if (entry[0] === symbols.noMerge) {
1154
+ entryMeta = {
1155
+ ...entryMeta,
1156
+ noMerge: entry[1]
1157
+ };
1158
+ }
1159
+ }
1160
+ return [index, raw, css, entryMeta, variants];
1161
+ });
1162
+ }
1163
+ };
1166
1164
  stringifyUtil(parsed, context) {
1167
1165
  if (!parsed)
1168
1166
  return;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unocss/core",
3
3
  "type": "module",
4
- "version": "66.2.2",
4
+ "version": "66.2.3",
5
5
  "description": "The instant on-demand Atomic CSS engine.",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",