@unocss/core 0.27.2 → 0.27.5

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
@@ -356,7 +356,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
356
356
  };
357
357
  }
358
358
 
359
- const version = "0.27.2";
359
+ const version = "0.27.5";
360
360
 
361
361
  class UnoGenerator {
362
362
  constructor(userConfig = {}, defaults = {}) {
@@ -483,8 +483,12 @@ class UnoGenerator {
483
483
  const layers = this.config.sortLayers(Array.from(layerSet).sort((a, b) => (this.config.layers[a] ?? 0) - (this.config.layers[b] ?? 0) || a.localeCompare(b)));
484
484
  let preflightsMap = {};
485
485
  if (preflights) {
486
+ const preflightContext = {
487
+ generator: this,
488
+ theme: this.config.theme
489
+ };
486
490
  preflightsMap = Object.fromEntries(await Promise.all(layers.map(async (layer) => {
487
- const preflights2 = await Promise.all(this.config.preflights.filter((i) => (i.layer || "default") === layer).map(async (i) => await i.getCSS()));
491
+ const preflights2 = await Promise.all(this.config.preflights.filter((i) => (i.layer || "default") === layer).map(async (i) => await i.getCSS(preflightContext)));
488
492
  const css = preflights2.filter(Boolean).join(nl);
489
493
  return [layer, css];
490
494
  })));
package/dist/index.d.ts CHANGED
@@ -190,6 +190,16 @@ interface ExtractorContext {
190
190
  code: string;
191
191
  id?: string;
192
192
  }
193
+ interface PreflightContext<Theme extends {} = {}> {
194
+ /**
195
+ * UnoCSS generator instance
196
+ */
197
+ generator: UnoGenerator;
198
+ /**
199
+ * The theme object
200
+ */
201
+ theme: Theme;
202
+ }
193
203
  interface Extractor {
194
204
  name: string;
195
205
  extract(ctx: ExtractorContext): Awaitable<Set<string> | undefined>;
@@ -229,7 +239,7 @@ declare type UserShortcuts<Theme extends {} = {}> = StaticShortcutMap | (StaticS
229
239
  declare type Shortcut<Theme extends {} = {}> = StaticShortcut | DynamicShortcut<Theme>;
230
240
  declare type FilterPattern = ReadonlyArray<string | RegExp> | string | RegExp | null;
231
241
  interface Preflight {
232
- getCSS: () => Promise<string | undefined> | string | undefined;
242
+ getCSS: (context: PreflightContext) => Promise<string | undefined> | string | undefined;
233
243
  layer?: string;
234
244
  }
235
245
  declare type BlocklistRule = string | RegExp;
@@ -534,4 +544,4 @@ declare const extractorSplit: Extractor;
534
544
 
535
545
  declare const extractorSvelte: Extractor;
536
546
 
537
- export { ArgumentType, Arrayable, Awaitable, BetterMap, BlocklistRule, CONTROL_SHORTCUT_NO_MERGE, CSSColorValue, CSSEntries, CSSObject, CSSValues, ConfigBase, DeepPartial, DynamicMatcher, DynamicRule, DynamicShortcut, DynamicShortcutMatcher, Extractor, ExtractorContext, FilterPattern, FlatObjectTuple, GenerateOptions, GenerateResult, GeneratorOptions, ParsedColorValue, ParsedUtil, PartialByKeys, PluginOptions, Postprocessor, Preflight, Preprocessor, Preset, PresetOptions, RGBAColorValue, RawUtil, RequiredByKey, ResolvedConfig, RestArgs, Rule, RuleContext, RuleMeta, Shift, Shortcut, SourceCodeTransformer, SourceMap, StaticRule, StaticShortcut, StaticShortcutMap, StringifiedUtil, ThemeExtender, TransformResult, TwoKeyMap, UnoGenerator, UnocssPluginContext, UserConfig, UserConfigDefaults, UserOnlyOptions, UserShortcuts, UtilObject, ValueHandler, ValueHandlerCallback, Variant, VariantContext, VariantFunction, VariantHandler, VariantMatchedResult, VariantObject, attributifyRE, clearIdenticalEntries, clone, createGenerator, createValueHandler, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit, extractorSvelte, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isValidSelector, mergeDeep, mergeSet, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexClassGroup, regexScopePlaceholder, toArray, uniq, validateFilterRE, warnOnce, withLayer };
547
+ export { ArgumentType, Arrayable, Awaitable, BetterMap, BlocklistRule, CONTROL_SHORTCUT_NO_MERGE, CSSColorValue, CSSEntries, CSSObject, CSSValues, ConfigBase, DeepPartial, DynamicMatcher, DynamicRule, DynamicShortcut, DynamicShortcutMatcher, Extractor, ExtractorContext, FilterPattern, FlatObjectTuple, GenerateOptions, GenerateResult, GeneratorOptions, ParsedColorValue, ParsedUtil, PartialByKeys, PluginOptions, Postprocessor, Preflight, PreflightContext, Preprocessor, Preset, PresetOptions, RGBAColorValue, RawUtil, RequiredByKey, ResolvedConfig, RestArgs, Rule, RuleContext, RuleMeta, Shift, Shortcut, SourceCodeTransformer, SourceMap, StaticRule, StaticShortcut, StaticShortcutMap, StringifiedUtil, ThemeExtender, TransformResult, TwoKeyMap, UnoGenerator, UnocssPluginContext, UserConfig, UserConfigDefaults, UserOnlyOptions, UserShortcuts, UtilObject, ValueHandler, ValueHandlerCallback, Variant, VariantContext, VariantFunction, VariantHandler, VariantMatchedResult, VariantObject, attributifyRE, clearIdenticalEntries, clone, createGenerator, createValueHandler, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit, extractorSvelte, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isValidSelector, mergeDeep, mergeSet, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexClassGroup, regexScopePlaceholder, toArray, uniq, validateFilterRE, warnOnce, withLayer };
package/dist/index.mjs CHANGED
@@ -352,7 +352,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
352
352
  };
353
353
  }
354
354
 
355
- const version = "0.27.2";
355
+ const version = "0.27.5";
356
356
 
357
357
  class UnoGenerator {
358
358
  constructor(userConfig = {}, defaults = {}) {
@@ -479,8 +479,12 @@ class UnoGenerator {
479
479
  const layers = this.config.sortLayers(Array.from(layerSet).sort((a, b) => (this.config.layers[a] ?? 0) - (this.config.layers[b] ?? 0) || a.localeCompare(b)));
480
480
  let preflightsMap = {};
481
481
  if (preflights) {
482
+ const preflightContext = {
483
+ generator: this,
484
+ theme: this.config.theme
485
+ };
482
486
  preflightsMap = Object.fromEntries(await Promise.all(layers.map(async (layer) => {
483
- const preflights2 = await Promise.all(this.config.preflights.filter((i) => (i.layer || "default") === layer).map(async (i) => await i.getCSS()));
487
+ const preflights2 = await Promise.all(this.config.preflights.filter((i) => (i.layer || "default") === layer).map(async (i) => await i.getCSS(preflightContext)));
484
488
  const css = preflights2.filter(Boolean).join(nl);
485
489
  return [layer, css];
486
490
  })));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/core",
3
- "version": "0.27.2",
3
+ "version": "0.27.5",
4
4
  "description": "The instant on-demand Atomic CSS engine.",
5
5
  "keywords": [
6
6
  "unocss",