@unocss/preset-wind4 66.1.0-beta.5 → 66.1.0-beta.7

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.
Files changed (33) hide show
  1. package/dist/index.d.mts +22 -8
  2. package/dist/index.d.ts +22 -8
  3. package/dist/index.mjs +82 -48
  4. package/dist/postprocess.d.mts +3 -3
  5. package/dist/postprocess.d.ts +3 -3
  6. package/dist/rules.d.mts +2 -2
  7. package/dist/rules.d.ts +2 -2
  8. package/dist/rules.mjs +3 -4
  9. package/dist/shared/{preset-wind4.pue_BigB.d.mts → preset-wind4.BOe5kxIw.d.mts} +1 -0
  10. package/dist/shared/{preset-wind4.pue_BigB.d.ts → preset-wind4.BOe5kxIw.d.ts} +1 -0
  11. package/dist/shared/{preset-wind4.MiZzPO05.d.mts → preset-wind4.BXbWGSRz.d.mts} +3 -1
  12. package/dist/shared/{preset-wind4.MiZzPO05.d.ts → preset-wind4.BXbWGSRz.d.ts} +3 -1
  13. package/dist/shared/{preset-wind4.Bv7psfuU.mjs → preset-wind4.BwU-POWl.mjs} +1 -1
  14. package/dist/shared/{preset-wind4.utffEfyI.mjs → preset-wind4.CJ98Gjkm.mjs} +118 -33
  15. package/dist/shared/{preset-wind4.BJEl798_.d.ts → preset-wind4.Ca5oWgxX.d.ts} +1 -1
  16. package/dist/shared/{preset-wind4.D40diWvF.mjs → preset-wind4.CkxnR6p3.mjs} +56 -11
  17. package/dist/shared/{preset-wind4.DIUjJahF.d.mts → preset-wind4.D71xGC6i.d.mts} +1 -1
  18. package/dist/shared/{preset-wind4.DXynlr0l.mjs → preset-wind4.DXr6hHdY.mjs} +1 -1
  19. package/dist/shared/{preset-wind4.DRtfClGs.mjs → preset-wind4.DhDf1e1c.mjs} +1 -1
  20. package/dist/shortcuts.d.mts +1 -1
  21. package/dist/shortcuts.d.ts +1 -1
  22. package/dist/shortcuts.mjs +3 -3
  23. package/dist/theme.d.mts +4 -3
  24. package/dist/theme.d.ts +4 -3
  25. package/dist/theme.mjs +2 -1
  26. package/dist/utils.d.mts +18 -6
  27. package/dist/utils.d.ts +18 -6
  28. package/dist/utils.mjs +1 -2
  29. package/dist/variants.d.mts +3 -3
  30. package/dist/variants.d.ts +3 -3
  31. package/dist/variants.mjs +2 -2
  32. package/package.json +4 -4
  33. package/dist/shared/preset-wind4.DRtKeBWc.mjs +0 -3
package/dist/index.d.mts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as _unocss_core from '@unocss/core';
2
- import { Postprocessor, Preflight, Variant, PresetOptions } from '@unocss/core';
3
- import { T as Theme } from './shared/preset-wind4.MiZzPO05.mjs';
4
- export { r as rules } from './shared/preset-wind4.DIUjJahF.mjs';
2
+ import { Postprocessor, Preflight, Variant, PresetOptions, PreflightContext } from '@unocss/core';
3
+ import { T as Theme } from './shared/preset-wind4.BXbWGSRz.mjs';
4
+ export { r as rules } from './shared/preset-wind4.D71xGC6i.mjs';
5
5
  export { shortcuts } from './shortcuts.mjs';
6
- export { t as theme } from './shared/preset-wind4.pue_BigB.mjs';
6
+ export { t as theme } from './shared/preset-wind4.BOe5kxIw.mjs';
7
7
 
8
8
  declare function postprocessors(options: PresetWind4Options): Postprocessor[];
9
9
 
@@ -63,10 +63,6 @@ interface PresetWind4Options extends PresetOptions {
63
63
  * @default true
64
64
  */
65
65
  arbitraryVariants?: boolean;
66
- /**
67
- * Choose which theme keys to export as CSS variables.
68
- */
69
- themeKeys?: string[] | ((keys: string[]) => string[]);
70
66
  /**
71
67
  * The important option lets you control whether UnoCSS’s utilities should be marked with `!important`.
72
68
  *
@@ -85,6 +81,24 @@ interface PresetWind4Options extends PresetOptions {
85
81
  * @default true
86
82
  */
87
83
  reset?: boolean;
84
+ /**
85
+ * Generate theme keys as CSS variables.
86
+ *
87
+ * - `true`: Generate theme keys fully.
88
+ * - `false`: Disable theme keys. (Not recommended ⚠️)
89
+ * - `'on-demand'`: Generate theme keys only when used.
90
+ *
91
+ * @default 'on-demand'
92
+ */
93
+ themePreflight?: boolean | 'on-demand';
94
+ /**
95
+ * Process theme variables before generating CSS variables.
96
+ *
97
+ * @param vars [key, value][]
98
+ * @param ctx {@link PreflightContext}
99
+ * @returns
100
+ */
101
+ processThemeVars?: (vars: [string, string][], ctx: PreflightContext) => void | [string, string][];
88
102
  }
89
103
  declare const presetWind4: _unocss_core.PresetFactory<Theme, PresetWind4Options>;
90
104
 
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as _unocss_core from '@unocss/core';
2
- import { Postprocessor, Preflight, Variant, PresetOptions } from '@unocss/core';
3
- import { T as Theme } from './shared/preset-wind4.MiZzPO05.js';
4
- export { r as rules } from './shared/preset-wind4.BJEl798_.js';
2
+ import { Postprocessor, Preflight, Variant, PresetOptions, PreflightContext } from '@unocss/core';
3
+ import { T as Theme } from './shared/preset-wind4.BXbWGSRz.js';
4
+ export { r as rules } from './shared/preset-wind4.Ca5oWgxX.js';
5
5
  export { shortcuts } from './shortcuts.js';
6
- export { t as theme } from './shared/preset-wind4.pue_BigB.js';
6
+ export { t as theme } from './shared/preset-wind4.BOe5kxIw.js';
7
7
 
8
8
  declare function postprocessors(options: PresetWind4Options): Postprocessor[];
9
9
 
@@ -63,10 +63,6 @@ interface PresetWind4Options extends PresetOptions {
63
63
  * @default true
64
64
  */
65
65
  arbitraryVariants?: boolean;
66
- /**
67
- * Choose which theme keys to export as CSS variables.
68
- */
69
- themeKeys?: string[] | ((keys: string[]) => string[]);
70
66
  /**
71
67
  * The important option lets you control whether UnoCSS’s utilities should be marked with `!important`.
72
68
  *
@@ -85,6 +81,24 @@ interface PresetWind4Options extends PresetOptions {
85
81
  * @default true
86
82
  */
87
83
  reset?: boolean;
84
+ /**
85
+ * Generate theme keys as CSS variables.
86
+ *
87
+ * - `true`: Generate theme keys fully.
88
+ * - `false`: Disable theme keys. (Not recommended ⚠️)
89
+ * - `'on-demand'`: Generate theme keys only when used.
90
+ *
91
+ * @default 'on-demand'
92
+ */
93
+ themePreflight?: boolean | 'on-demand';
94
+ /**
95
+ * Process theme variables before generating CSS variables.
96
+ *
97
+ * @param vars [key, value][]
98
+ * @param ctx {@link PreflightContext}
99
+ * @returns
100
+ */
101
+ processThemeVars?: (vars: [string, string][], ctx: PreflightContext) => void | [string, string][];
88
102
  }
89
103
  declare const presetWind4: _unocss_core.PresetFactory<Theme, PresetWind4Options>;
90
104
 
package/dist/index.mjs CHANGED
@@ -1,15 +1,14 @@
1
1
  import { LAYER_PREFLIGHTS, definePreset } from '@unocss/core';
2
2
  import { extractorArbitraryVariants } from '@unocss/extractor-arbitrary-variants';
3
- import { F as compressCSS, E as camelToHyphen, g as globalKeywords } from './shared/preset-wind4.D40diWvF.mjs';
3
+ import { a as themeTracking, J as compressCSS, P as PRESET_NAME, w as getThemeByKey, I as hyphenate, p as passThemeKey, g as globalKeywords, t as trackedTheme } from './shared/preset-wind4.CkxnR6p3.mjs';
4
4
  import { alphaPlaceholdersRE } from '@unocss/rule-utils';
5
- import { p as passThemeKey } from './shared/preset-wind4.DRtKeBWc.mjs';
6
5
  import { postprocessors } from './postprocess.mjs';
7
- import { l as variants } from './shared/preset-wind4.DXynlr0l.mjs';
6
+ import { l as variants } from './shared/preset-wind4.DXr6hHdY.mjs';
8
7
  import { theme as theme$1 } from './theme.mjs';
9
- import { s as shortcuts } from './shared/preset-wind4.Bv7psfuU.mjs';
10
- import { r as rules } from './shared/preset-wind4.utffEfyI.mjs';
8
+ import { s as shortcuts } from './shared/preset-wind4.BwU-POWl.mjs';
9
+ import { r as rules } from './shared/preset-wind4.CJ98Gjkm.mjs';
11
10
  import './colors.mjs';
12
- import './shared/preset-wind4.DRtfClGs.mjs';
11
+ import './shared/preset-wind4.DhDf1e1c.mjs';
13
12
 
14
13
  const resetCSS = `
15
14
  /*
@@ -397,53 +396,55 @@ input:where([type='button'], [type='reset'], [type='submit']),
397
396
  }
398
397
  `;
399
398
  function reset(options) {
400
- return options.reset === false ? void 0 : {
401
- getCSS: () => compressCSS(resetCSS),
399
+ if (options.reset === false)
400
+ return void 0;
401
+ return {
402
+ getCSS: ({ generator }) => {
403
+ themeTracking("font", "sans");
404
+ themeTracking("font", "mono");
405
+ themeTracking("defaults", ["font", "family"]);
406
+ themeTracking("defaults", ["font", "featureSettings"]);
407
+ themeTracking("defaults", ["font", "variationSettings"]);
408
+ themeTracking("defaults", ["monoFont", "family"]);
409
+ themeTracking("defaults", ["monoFont", "featureSettings"]);
410
+ themeTracking("defaults", ["monoFont", "variationSettings"]);
411
+ return compressCSS(resetCSS, generator.config.envMode === "dev");
412
+ },
402
413
  layer: LAYER_PREFLIGHTS
403
414
  };
404
415
  }
405
416
 
406
- const DefaultCssVarKeys = [
407
- "font",
408
- "colors",
409
- // 'spacing', // spacing is a special case
417
+ const ExcludeCssVarKeys = [
418
+ "spacing",
410
419
  "breakpoint",
411
420
  "verticalBreakpoint",
412
- "container",
413
- "text",
414
- "fontWeight",
415
- "tracking",
416
- "leading",
417
- "textStrokeWidth",
418
- "radius",
419
421
  "shadow",
420
422
  "insetShadow",
421
423
  "dropShadow",
422
424
  "textShadow",
423
- "ease",
424
- "blur",
425
- "perspective",
425
+ "animation",
426
426
  "property",
427
- "defaults"
427
+ "aria",
428
+ "media",
429
+ "supports"
428
430
  ];
429
- function themeToCSSVars(theme2, keys) {
430
- let cssVariables = "";
431
+ function getThemeVarsMap(theme2, keys) {
432
+ const themeMap = /* @__PURE__ */ new Map([
433
+ ["--spacing", theme2.spacing.DEFAULT]
434
+ ]);
431
435
  function process(obj, prefix) {
432
436
  for (const key in obj) {
433
437
  if (key === "DEFAULT" && Object.keys(obj).length === 1) {
434
- cssVariables += `${camelToHyphen(`--${prefix}`)}: ${obj[key].replace(alphaPlaceholdersRE, "1")};
435
- `;
438
+ themeMap.set(hyphenate(`--${prefix}`), obj[key].replace(alphaPlaceholdersRE, "1"));
436
439
  }
437
440
  if (passThemeKey.includes(key))
438
441
  continue;
439
442
  if (Array.isArray(obj[key])) {
440
- cssVariables += `${camelToHyphen(`--${prefix}-${key}`)}: ${obj[key].join(",").replace(alphaPlaceholdersRE, "1")};
441
- `;
443
+ themeMap.set(hyphenate(`--${prefix}-${key}`), obj[key].join(",").replace(alphaPlaceholdersRE, "1"));
442
444
  } else if (typeof obj[key] === "object") {
443
445
  process(obj[key], `${prefix}-${key}`);
444
446
  } else {
445
- cssVariables += `${camelToHyphen(`--${prefix}-${key}`)}: ${obj[key].replace(alphaPlaceholdersRE, "1")};
446
- `;
447
+ themeMap.set(hyphenate(`--${prefix}-${key}`), obj[key].replace(alphaPlaceholdersRE, "1"));
447
448
  }
448
449
  }
449
450
  }
@@ -452,31 +453,57 @@ function themeToCSSVars(theme2, keys) {
452
453
  continue;
453
454
  process(theme2[key], key);
454
455
  }
455
- return cssVariables;
456
+ return themeMap;
456
457
  }
457
458
  function theme(options) {
458
- let themeKeys;
459
- if (typeof options.themeKeys === "function") {
460
- themeKeys = options.themeKeys(DefaultCssVarKeys);
461
- } else {
462
- themeKeys = options.themeKeys ?? DefaultCssVarKeys;
463
- }
464
459
  return {
465
460
  layer: "theme",
466
- getCSS({ theme: theme2 }) {
467
- return compressCSS(`
468
- :root {
469
- --spacing: ${theme2.spacing.DEFAULT};
470
- ${themeToCSSVars(theme2, themeKeys).trim()}
471
- }`);
461
+ getCSS(ctx) {
462
+ const { theme: theme2, generator } = ctx;
463
+ if (options.themePreflight === false) {
464
+ return void 0;
465
+ }
466
+ let deps;
467
+ const generateCSS = (deps2) => {
468
+ if (options.processThemeVars) {
469
+ deps2 = options.processThemeVars(deps2, ctx) ?? deps2;
470
+ }
471
+ if (deps2.length === 0)
472
+ return void 0;
473
+ const depCSS = deps2.map(([key, value]) => `${key}: ${value};`).join("\n");
474
+ return compressCSS(`
475
+ :root, :host {
476
+ ${depCSS}
477
+ }`, generator.config.envMode === "dev");
478
+ };
479
+ if (options.themePreflight === "on-demand") {
480
+ const self = generator.config.presets.find((p) => p.name === PRESET_NAME);
481
+ if (!self || self.meta.themeDeps.size === 0)
482
+ return void 0;
483
+ deps = Array.from(self.meta.themeDeps).map((k) => {
484
+ const [key, prop] = k.split(":");
485
+ let v = getThemeByKey(theme2, key, prop.split("-")) ?? getThemeByKey(theme2, key, [prop]);
486
+ if (typeof v === "object") {
487
+ v = v.DEFAULT;
488
+ }
489
+ if (v) {
490
+ return [`--${hyphenate(`${key}${prop !== "DEFAULT" ? `-${prop}` : ""}`)}`, v];
491
+ }
492
+ return void 0;
493
+ }).filter(Boolean);
494
+ } else {
495
+ const keys = Object.keys(theme2).filter((k) => !ExcludeCssVarKeys.includes(k));
496
+ deps = Array.from(getThemeVarsMap(theme2, keys));
497
+ }
498
+ return generateCSS(deps);
472
499
  }
473
500
  };
474
501
  }
475
502
 
476
503
  const preflights = (options) => {
477
504
  return [
478
- theme(options),
479
- reset(options)
505
+ reset(options),
506
+ theme(options)
480
507
  ].filter(Boolean);
481
508
  };
482
509
 
@@ -496,8 +523,9 @@ const presetWind4 = definePreset((options = {}) => {
496
523
  options.attributifyPseudo = options.attributifyPseudo ?? false;
497
524
  options.variablePrefix = options.variablePrefix ?? "un-";
498
525
  options.important = options.important ?? false;
526
+ options.themePreflight = options.themePreflight ?? "on-demand";
499
527
  return {
500
- name: "@unocss/preset-wind4",
528
+ name: PRESET_NAME,
501
529
  rules,
502
530
  shortcuts,
503
531
  theme: theme$1,
@@ -512,7 +540,13 @@ const presetWind4 = definePreset((options = {}) => {
512
540
  autocomplete: {
513
541
  shorthands
514
542
  },
515
- options
543
+ options,
544
+ meta: {
545
+ themeDeps: trackedTheme
546
+ },
547
+ configResolved() {
548
+ trackedTheme.clear();
549
+ }
516
550
  };
517
551
  });
518
552
 
@@ -1,10 +1,10 @@
1
1
  import { PresetWind4Options } from './index.mjs';
2
2
  export { postprocessors } from './index.mjs';
3
3
  import { Postprocessor } from '@unocss/core';
4
- import './shared/preset-wind4.MiZzPO05.mjs';
5
- import './shared/preset-wind4.DIUjJahF.mjs';
4
+ import './shared/preset-wind4.BXbWGSRz.mjs';
5
+ import './shared/preset-wind4.D71xGC6i.mjs';
6
6
  import './shortcuts.mjs';
7
- import './shared/preset-wind4.pue_BigB.mjs';
7
+ import './shared/preset-wind4.BOe5kxIw.mjs';
8
8
 
9
9
  declare function important(option: PresetWind4Options['important']): Postprocessor[];
10
10
 
@@ -1,10 +1,10 @@
1
1
  import { PresetWind4Options } from './index.js';
2
2
  export { postprocessors } from './index.js';
3
3
  import { Postprocessor } from '@unocss/core';
4
- import './shared/preset-wind4.MiZzPO05.js';
5
- import './shared/preset-wind4.BJEl798_.js';
4
+ import './shared/preset-wind4.BXbWGSRz.js';
5
+ import './shared/preset-wind4.Ca5oWgxX.js';
6
6
  import './shortcuts.js';
7
- import './shared/preset-wind4.pue_BigB.js';
7
+ import './shared/preset-wind4.BOe5kxIw.js';
8
8
 
9
9
  declare function important(option: PresetWind4Options['important']): Postprocessor[];
10
10
 
package/dist/rules.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Rule, CSSEntries, Shortcut, StaticRule } from '@unocss/core';
2
- import { T as Theme } from './shared/preset-wind4.MiZzPO05.mjs';
3
- export { r as rules } from './shared/preset-wind4.DIUjJahF.mjs';
2
+ import { T as Theme } from './shared/preset-wind4.BXbWGSRz.mjs';
3
+ export { r as rules } from './shared/preset-wind4.D71xGC6i.mjs';
4
4
 
5
5
  declare const verticalAligns: Rule<Theme>[];
6
6
  declare const textAligns: Rule<Theme>[];
package/dist/rules.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Rule, CSSEntries, Shortcut, StaticRule } from '@unocss/core';
2
- import { T as Theme } from './shared/preset-wind4.MiZzPO05.js';
3
- export { r as rules } from './shared/preset-wind4.BJEl798_.js';
2
+ import { T as Theme } from './shared/preset-wind4.BXbWGSRz.js';
3
+ export { r as rules } from './shared/preset-wind4.Ca5oWgxX.js';
4
4
 
5
5
  declare const verticalAligns: Rule<Theme>[];
6
6
  declare const textAligns: Rule<Theme>[];
package/dist/rules.mjs CHANGED
@@ -1,6 +1,5 @@
1
- export { d as accents, am as accessibility, H as alignments, a as animations, c as appearance, _ as appearances, U as aspectRatio, aj as backgroundBlendModes, b as backgroundStyles, m as bgColors, g as borderStyles, h as borders, S as boxShadows, N as boxSizing, a7 as breaks, e as carets, n as colorScheme, p as columns, a0 as contains, a5 as contentVisibility, a6 as contents, aB as cssProperty, aA as cssVariables, $ as cursors, Z as displays, u as divides, al as dynamicViewportHeight, x as filters, y as flex, J as flexGridJustifiesAlignments, L as floats, ac as fontSmoothings, ab as fontStyles, ay as fontVariantNumeric, at as fonts, z as gaps, A as grids, j as handlerBorderStyle, ad as hyphens, i as imageRenderings, K as insets, ah as isolations, F as justifies, C as lineClamps, l as listStyle, W as margins, ak as mixBlendModes, Y as notLastChildSelector, ai as objectPositions, k as opacity, G as orders, o as outline, B as overflows, f as overscrolls, V as paddings, D as placeholders, I as placements, a1 as pointerEvents, E as positions, O as questionMark, a2 as resizes, P as rings, r as rules, ag as screenReadersAccess, s as scrollBehaviors, Q as scrolls, R as shadowProperties, T as sizes, X as spaces, az as splitShorthand, an as svgUtilities, au as tabSizes, ao as tables, t as textAligns, q as textDecorations, av as textIndents, a9 as textOverflows, ax as textShadows, aw as textStrokes, aa as textTransforms, a8 as textWraps, ap as touchActions, aq as transformBase, ar as transforms, as as transitions, a3 as userSelects, v as verticalAligns, aC as viewTransition, a4 as whitespaces, w as willChange, ae as writingModes, af as writingOrientations, M as zIndexes } from './shared/preset-wind4.utffEfyI.mjs';
2
- export { a as container, c as containerParent, b as containerShortcuts } from './shared/preset-wind4.DRtfClGs.mjs';
3
- import './shared/preset-wind4.D40diWvF.mjs';
1
+ export { d as accents, am as accessibility, H as alignments, a as animations, c as appearance, _ as appearances, U as aspectRatio, aj as backgroundBlendModes, b as backgroundStyles, m as bgColors, g as borderStyles, h as borders, S as boxShadows, N as boxSizing, a7 as breaks, e as carets, n as colorScheme, p as columns, a0 as contains, a5 as contentVisibility, a6 as contents, aB as cssProperty, aA as cssVariables, $ as cursors, Z as displays, u as divides, al as dynamicViewportHeight, x as filters, y as flex, J as flexGridJustifiesAlignments, L as floats, ac as fontSmoothings, ab as fontStyles, ay as fontVariantNumeric, at as fonts, z as gaps, A as grids, j as handlerBorderStyle, ad as hyphens, i as imageRenderings, K as insets, ah as isolations, F as justifies, C as lineClamps, l as listStyle, W as margins, ak as mixBlendModes, Y as notLastChildSelector, ai as objectPositions, k as opacity, G as orders, o as outline, B as overflows, f as overscrolls, V as paddings, D as placeholders, I as placements, a1 as pointerEvents, E as positions, O as questionMark, a2 as resizes, P as rings, r as rules, ag as screenReadersAccess, s as scrollBehaviors, Q as scrolls, R as shadowProperties, T as sizes, X as spaces, az as splitShorthand, an as svgUtilities, au as tabSizes, ao as tables, t as textAligns, q as textDecorations, av as textIndents, a9 as textOverflows, ax as textShadows, aw as textStrokes, aa as textTransforms, a8 as textWraps, ap as touchActions, aq as transformBase, ar as transforms, as as transitions, a3 as userSelects, v as verticalAligns, aC as viewTransition, a4 as whitespaces, w as willChange, ae as writingModes, af as writingOrientations, M as zIndexes } from './shared/preset-wind4.CJ98Gjkm.mjs';
2
+ export { a as container, c as containerParent, b as containerShortcuts } from './shared/preset-wind4.DhDf1e1c.mjs';
3
+ import './shared/preset-wind4.CkxnR6p3.mjs';
4
4
  import '@unocss/core';
5
5
  import '@unocss/rule-utils';
6
- import './shared/preset-wind4.DRtKeBWc.mjs';
@@ -820,6 +820,7 @@ declare const theme: {
820
820
  defaults: {
821
821
  transition: {
822
822
  duration: string;
823
+ timingFunction: string;
823
824
  };
824
825
  font: {
825
826
  family: string;
@@ -820,6 +820,7 @@ declare const theme: {
820
820
  defaults: {
821
821
  transition: {
822
822
  duration: string;
823
+ timingFunction: string;
823
824
  };
824
825
  font: {
825
826
  family: string;
@@ -1,5 +1,7 @@
1
1
  interface Colors {
2
- [key: string]: Colors | string;
2
+ [key: string]: Colors & {
3
+ DEFAULT?: string;
4
+ } | string;
3
5
  }
4
6
  interface ThemeAnimation {
5
7
  keyframes?: Record<string, string>;
@@ -1,5 +1,7 @@
1
1
  interface Colors {
2
- [key: string]: Colors | string;
2
+ [key: string]: Colors & {
3
+ DEFAULT?: string;
4
+ } | string;
3
5
  }
4
6
  interface ThemeAnimation {
5
7
  keyframes?: Record<string, string>;
@@ -1,4 +1,4 @@
1
- import { b as containerShortcuts } from './preset-wind4.DRtfClGs.mjs';
1
+ import { b as containerShortcuts } from './preset-wind4.DhDf1e1c.mjs';
2
2
 
3
3
  const shortcuts = [
4
4
  ...containerShortcuts
@@ -1,7 +1,6 @@
1
- import { g as globalKeywords, a as h, z as makeGlobalStaticRules, p as positionMap, o as parseColor, S as SpecialColorKey, G as defineProperty, m as colorResolver, A as isCSSMathFn, d as directionMap, u as hasParseableColor, c as cornerMap, l as colorCSSGenerator, B as isSize, j as directionSize, n as numberResolver, k as colorableShadows, i as insetMap, E as camelToHyphen, w as resolveBreakpoints, D as transformXYZ, x as xyzMap, H as bracketTypeRe } from './preset-wind4.D40diWvF.mjs';
1
+ import { g as globalKeywords, b as h, D as makeGlobalStaticRules, f as positionMap, r as parseColor, S as SpecialColorKey, K as defineProperty, a as themeTracking, L as detectThemeValue, q as colorResolver, E as isCSSMathFn, d as directionMap, z as hasParseableColor, c as cornerMap, p as passThemeKey, o as colorCSSGenerator, F as isSize, l as directionSize, n as numberResolver, m as colorableShadows, i as insetMap, I as hyphenate, A as resolveBreakpoints, G as transformXYZ, x as xyzMap, M as bracketTypeRe } from './preset-wind4.CkxnR6p3.mjs';
2
2
  import { notNull, uniq } from '@unocss/core';
3
- import { p as passThemeKey } from './preset-wind4.DRtKeBWc.mjs';
4
- import { a as container, c as containerParent } from './preset-wind4.DRtfClGs.mjs';
3
+ import { a as container, c as containerParent } from './preset-wind4.DhDf1e1c.mjs';
5
4
  import { getStringComponent } from '@unocss/rule-utils';
6
5
 
7
6
  const verticalAlignAlias = {
@@ -139,13 +138,21 @@ function bgGradientColorResolver() {
139
138
  const data = parseColor(body, theme);
140
139
  if (data) {
141
140
  const { color, key, alpha } = data;
142
- if (Object.values(SpecialColorKey).includes(color)) {
143
- css[`--un-gradient-${position}`] = color;
144
- } else {
145
- css[`--un-${position}-opacity`] = alpha;
146
- const value = key ? `var(--colors-${key})` : color;
147
- css[`--un-gradient-${position}`] = `color-mix(in oklab, ${value} var(--un-${position}-opacity), transparent)`;
148
- yield defineProperty(`--un-${position}-opacity`, { syntax: "<percentage>", initialValue: "100%" });
141
+ if (color) {
142
+ if (Object.values(SpecialColorKey).includes(color)) {
143
+ css[`--un-gradient-${position}`] = color;
144
+ } else {
145
+ css[`--un-${position}-opacity`] = alpha;
146
+ const value = key ? `var(--colors-${key})` : color;
147
+ css[`--un-gradient-${position}`] = `color-mix(in oklab, ${value} var(--un-${position}-opacity), transparent)`;
148
+ yield defineProperty(`--un-${position}-opacity`, { syntax: "<percentage>", initialValue: "100%" });
149
+ }
150
+ if (key) {
151
+ themeTracking(`colors`, key);
152
+ }
153
+ if (theme) {
154
+ detectThemeValue(color, theme);
155
+ }
149
156
  }
150
157
  } else {
151
158
  css[`--un-gradient-${position}`] = h.bracket.cssvar(body);
@@ -471,9 +478,13 @@ function handlerRounded([, a = "", s], { theme }) {
471
478
  return cornerMap[a].map((i) => [`border${i}-radius`, "calc(infinity * 1px)"]);
472
479
  const _v = theme.radius?.[_s] ?? h.bracket.cssvar.global.fraction.rem(_s);
473
480
  if (_v != null) {
481
+ const isVar = theme.radius && _s in theme.radius && !passThemeKey.includes(_s);
482
+ if (isVar) {
483
+ themeTracking(`radius`, _s);
484
+ }
474
485
  return cornerMap[a].map((i) => [
475
486
  `border${i}-radius`,
476
- theme.radius && _s in theme.radius && !passThemeKey.includes(_s) ? `var(--radius-${_s})` : _v
487
+ isVar ? `var(--radius-${_s})` : _v
477
488
  ]);
478
489
  }
479
490
  }
@@ -516,7 +527,7 @@ const bgColors = [
516
527
  [/^bg-op(?:acity)?-?(.+)$/, ([, opacity2]) => ({ "--un-bg-opacity": h.bracket.percent.cssvar(opacity2) }), { autocomplete: "bg-(op|opacity)-<percent>" }]
517
528
  ];
518
529
  const colorScheme = [
519
- [/^(?:color-)?scheme-(.+)$/, ([, v]) => ({ "color-scheme": v })]
530
+ [/^(?:color-)?scheme-(.+)$/, ([, v]) => ({ "color-scheme": v.split("-").join(" ") })]
520
531
  ];
521
532
 
522
533
  const columns = [
@@ -614,6 +625,7 @@ function* handlerSpace([, d, s], { theme, symbols }) {
614
625
  let v;
615
626
  const num = numberResolver(s);
616
627
  if (num != null) {
628
+ themeTracking(`spacing`);
617
629
  v = `calc(var(--spacing) * ${num})`;
618
630
  } else {
619
631
  v = theme.spacing?.[s] ?? h.bracket.cssvar.auto.fraction.rem(s || "1");
@@ -711,7 +723,7 @@ const filterBaseKeys = [
711
723
  "drop-shadow"
712
724
  ];
713
725
  const filterProperties = filterBaseKeys.map((i) => defineProperty(`--un-${i}`)).join("\n");
714
- const filterCSS = filterBaseKeys.map((i) => `var(--un-${i})`).join(" ");
726
+ const filterCSS = filterBaseKeys.map((i) => `var(--un-${i},)`).join(" ");
715
727
  const backdropBaseKeys = [
716
728
  "backdrop-blur",
717
729
  "backdrop-brightness",
@@ -724,7 +736,7 @@ const backdropBaseKeys = [
724
736
  "backdrop-sepia"
725
737
  ];
726
738
  const backdropProperties = backdropBaseKeys.map((i) => defineProperty(`--un-${i}`)).join("\n");
727
- const backdropCSS = backdropBaseKeys.map((i) => `var(--un-${i})`).join(" ");
739
+ const backdropCSS = backdropBaseKeys.map((i) => `var(--un-${i},)`).join(" ");
728
740
  function percentWithDefault(str) {
729
741
  let v = h.bracket.cssvar(str || "");
730
742
  if (v != null)
@@ -848,8 +860,10 @@ const flex = [
848
860
  [/^(?:flex-)?grow(?:-(.*))?$/, ([, d = ""]) => ({ "flex-grow": h.bracket.cssvar.number(d) ?? 1 }), { autocomplete: ["flex-grow-<num>", "grow-<num>"] }],
849
861
  [/^(?:flex-)?basis-(.+)$/, ([, d]) => {
850
862
  const v = numberResolver(d);
851
- if (v != null)
863
+ if (v != null) {
864
+ themeTracking(`spacing`);
852
865
  return { "flex-basis": `calc(var(--spacing) * ${v})` };
866
+ }
853
867
  return { "flex-basis": h.bracket.cssvar.auto.rem(d) };
854
868
  }, { autocomplete: ["flex-basis-$spacing", "basis-$spacing"] }],
855
869
  // directions
@@ -872,8 +886,10 @@ const directions = {
872
886
  };
873
887
  function handleGap([, d = "", s]) {
874
888
  const v = numberResolver(s);
875
- if (v != null)
889
+ if (v != null) {
890
+ themeTracking(`spacing`);
876
891
  return { [`${directions[d]}gap`]: `calc(var(--spacing) * ${v})` };
892
+ }
877
893
  return { [`${directions[d]}gap`]: h.bracket.cssvar.global.rem(s) };
878
894
  }
879
895
  const gaps = [
@@ -1075,10 +1091,12 @@ const flexGridJustifiesAlignments = [...justifies, ...alignments, ...placements]
1075
1091
  ]);
1076
1092
  function handleInsetValue(v) {
1077
1093
  const _v = numberResolver(v);
1078
- if (_v != null)
1094
+ if (_v != null) {
1095
+ themeTracking(`spacing`);
1079
1096
  return `calc(var(--spacing) * ${_v})`;
1080
- else
1097
+ } else {
1081
1098
  return h.bracket.cssvar.global.auto.rem(v);
1099
+ }
1082
1100
  }
1083
1101
  function handleInsetValues([, d, v]) {
1084
1102
  const r = handleInsetValue(v);
@@ -1171,7 +1189,7 @@ function hanldeShadow(themeKey) {
1171
1189
  const { theme } = ctx;
1172
1190
  const v = theme[themeKey]?.[d || "DEFAULT"];
1173
1191
  const c = d ? h.bracket.cssvar(d) : void 0;
1174
- const colorVar = camelToHyphen(themeKey);
1192
+ const colorVar = hyphenate(themeKey);
1175
1193
  if ((v != null || c != null) && !hasParseableColor(c, theme)) {
1176
1194
  return [
1177
1195
  {
@@ -1287,7 +1305,11 @@ function getPropName(minmax, hw) {
1287
1305
  return `${minmax || ""}${sizeMapping[hw]}`;
1288
1306
  }
1289
1307
  function getSizeValue(theme, hw, prop) {
1290
- let v = theme.container?.[prop];
1308
+ let v;
1309
+ if (theme.container?.[prop]) {
1310
+ themeTracking("container", prop);
1311
+ v = `var(--container-${prop})`;
1312
+ }
1291
1313
  switch (prop) {
1292
1314
  case "fit":
1293
1315
  case "max":
@@ -1299,6 +1321,7 @@ function getSizeValue(theme, hw, prop) {
1299
1321
  break;
1300
1322
  }
1301
1323
  if (h.number(prop) != null) {
1324
+ themeTracking(`spacing`);
1302
1325
  v = `calc(var(--spacing) * ${h.number(prop)})`;
1303
1326
  }
1304
1327
  return v ?? h.bracket.cssvar.global.auto.none.fraction.rem(prop);
@@ -1696,6 +1719,7 @@ function resolveValue(s, theme) {
1696
1719
  if (!v) {
1697
1720
  const num = numberResolver(s);
1698
1721
  if (num != null) {
1722
+ themeTracking(`spacing`);
1699
1723
  v = `calc(var(--spacing) * ${num})`;
1700
1724
  } else {
1701
1725
  v = h.bracket.cssvar.global.auto.fraction.rem(s);
@@ -1771,10 +1795,16 @@ const transforms = [
1771
1795
  ],
1772
1796
  // perspectives
1773
1797
  [/^(?:transform-)?perspect(?:ive)?-(.+)$/, ([, s], { theme }) => {
1774
- const v = theme.perspective?.[s] ?? h.bracket.cssvar.px.numberWithUnit(s);
1798
+ let v;
1799
+ if (theme.perspective?.[s]) {
1800
+ themeTracking(`perspective`, s);
1801
+ v = `var(--un-perspective-${s})`;
1802
+ } else {
1803
+ v = h.bracket.cssvar.px.numberWithUnit(s);
1804
+ }
1775
1805
  if (v != null) {
1776
1806
  return {
1777
- perspective: s in (theme.perspective ?? {}) ? `var(--un-perspective-${s})` : v
1807
+ perspective: v
1778
1808
  };
1779
1809
  }
1780
1810
  }],
@@ -1816,6 +1846,7 @@ function handleTranslate([, d, b]) {
1816
1846
  translate: "none"
1817
1847
  };
1818
1848
  }
1849
+ themeTracking(`spacing`);
1819
1850
  return [
1820
1851
  [
1821
1852
  ...transformXYZ(d, typeof v === "number" ? `calc(var(--spacing) * ${v})` : v, "translate"),
@@ -1901,6 +1932,8 @@ const transitions = [
1901
1932
  [
1902
1933
  /^transition(?:-(\D+?))?(?:-(\d+))?$/,
1903
1934
  ([, prop, d], { theme }) => {
1935
+ themeTracking("defaults", ["transition", "timingFunction"]);
1936
+ themeTracking("defaults", ["transition", "duration"]);
1904
1937
  const defaultTransition = {
1905
1938
  "transition-property": theme.property?.DEFAULT,
1906
1939
  "transition-timing-function": `var(--un-ease, var(--defaults-transition-timing-function))`,
@@ -1940,9 +1973,15 @@ const transitions = [
1940
1973
  ([, d]) => ({ "transition-delay": h.bracket.cssvar.time(d) })
1941
1974
  ],
1942
1975
  [
1943
- /^(?:transition-)?ease-(.+)$/,
1944
- ([, d], { theme }) => {
1945
- const v = d in (theme.ease ?? {}) ? `var(--ease-${d})` : h.bracket.cssvar(d);
1976
+ /^(?:transition-)?ease(?:-(.+))?$/,
1977
+ ([, d = "DEFAULT"], { theme }) => {
1978
+ let v;
1979
+ if (theme.ease?.[d]) {
1980
+ themeTracking("ease", d);
1981
+ v = `var(--ease${d === "DEFAULT" ? "" : `-${d}`})`;
1982
+ } else {
1983
+ v = h.bracket.cssvar(d);
1984
+ }
1946
1985
  return [
1947
1986
  {
1948
1987
  "--un-ease": v,
@@ -1990,7 +2029,13 @@ const fonts = [
1990
2029
  [
1991
2030
  /^(?:font|fw)-?([^-]+)$/,
1992
2031
  ([, s], { theme }) => {
1993
- const v = theme.fontWeight?.[s] ? `var(--font-weight-${s})` : h.bracket.global.number(s);
2032
+ let v;
2033
+ if (theme.fontWeight?.[s]) {
2034
+ themeTracking(`fontWeight`, s);
2035
+ v = `var(--font-weight-${s})`;
2036
+ } else {
2037
+ v = h.bracket.global.number(s);
2038
+ }
1994
2039
  return {
1995
2040
  "--un-font-weight": v,
1996
2041
  "font-weight": v
@@ -2007,7 +2052,16 @@ const fonts = [
2007
2052
  [
2008
2053
  /^(?:font-)?(?:leading|lh|line-height)-(.+)$/,
2009
2054
  ([, s], { theme }) => {
2010
- const v = theme.leading?.[s] ? `var(--leading-${s})` : numberResolver(s) ? `calc(var(--spacing) * ${numberResolver(s)})` : h.bracket.cssvar.global.rem(s);
2055
+ let v;
2056
+ if (theme.leading?.[s]) {
2057
+ themeTracking("leading", s);
2058
+ v = `var(--leading-${s})`;
2059
+ } else if (numberResolver(s)) {
2060
+ themeTracking("spacing");
2061
+ v = `calc(var(--spacing) * ${numberResolver(s)})`;
2062
+ } else {
2063
+ v = h.bracket.cssvar.global.rem(s);
2064
+ }
2011
2065
  if (v != null) {
2012
2066
  return [
2013
2067
  {
@@ -2030,7 +2084,13 @@ const fonts = [
2030
2084
  [
2031
2085
  /^(?:font-)?tracking-(.+)$/,
2032
2086
  ([, s], { theme }) => {
2033
- const v = theme.tracking?.[s] ? `var(--tracking-${s})` : h.bracket.cssvar.global.rem(s);
2087
+ let v;
2088
+ if (theme.tracking?.[s]) {
2089
+ themeTracking(`tracking`, s);
2090
+ v = `var(--tracking-${s})`;
2091
+ } else {
2092
+ v = h.bracket.cssvar.global.rem(s);
2093
+ }
2034
2094
  return {
2035
2095
  "--un-tracking": v,
2036
2096
  "letter-spacing": v
@@ -2069,7 +2129,13 @@ const fonts = [
2069
2129
  [
2070
2130
  /^font-(.+)$/,
2071
2131
  ([, d], { theme }) => {
2072
- const v = theme.font?.[d] ? `var(--font-${d})` : h.bracket.cssvar.global(d);
2132
+ let v;
2133
+ if (theme.font?.[d]) {
2134
+ themeTracking(`font`, d);
2135
+ v = `var(--font-${d})`;
2136
+ } else {
2137
+ v = h.bracket.cssvar.global(d);
2138
+ }
2073
2139
  return {
2074
2140
  "font-family": v
2075
2141
  };
@@ -2093,6 +2159,7 @@ const textIndents = [
2093
2159
  [/^indent(?:-(.+))?$/, ([, s]) => {
2094
2160
  let v = numberResolver(s);
2095
2161
  if (v != null) {
2162
+ themeTracking(`spacing`);
2096
2163
  return { "text-indent": `calc(var(--spacing) * ${v})` };
2097
2164
  }
2098
2165
  v = h.bracket.cssvar.auto.global.rem(s);
@@ -2104,6 +2171,9 @@ const textIndents = [
2104
2171
  const textStrokes = [
2105
2172
  // widths
2106
2173
  [/^text-stroke(?:-(.+))?$/, ([, s = "DEFAULT"], { theme }) => {
2174
+ if (theme.textStrokeWidth?.[s]) {
2175
+ themeTracking(`textStrokeWidth`, s);
2176
+ }
2107
2177
  return {
2108
2178
  "-webkit-text-stroke-width": theme.textStrokeWidth?.[s] ? passThemeKey.includes(s) ? theme.textStrokeWidth?.[s] : `var(--text-stroke-width-${s})` : h.bracket.cssvar.px(s)
2109
2179
  };
@@ -2154,12 +2224,25 @@ function handleText([, s = "base"], { theme }) {
2154
2224
  return;
2155
2225
  const [size, leading] = split;
2156
2226
  const sizePairs = theme.text?.[size];
2157
- const lineHeight = leading ? theme.leading?.[leading] || h.bracket.cssvar.global.rem(leading) : void 0;
2227
+ let lineHeight;
2228
+ if (leading) {
2229
+ if (theme.leading?.[leading]) {
2230
+ themeTracking(`leading`, leading);
2231
+ lineHeight = `var(--leading-${leading})`;
2232
+ } else {
2233
+ lineHeight = h.bracket.cssvar.global.rem(leading);
2234
+ }
2235
+ }
2158
2236
  if (sizePairs) {
2237
+ themeTracking(`text`, [size, "fontSize"]);
2238
+ themeTracking(`text`, [size, "lineHeight"]);
2239
+ if (sizePairs.letterSpacing) {
2240
+ themeTracking(`text`, [size, "letterSpacing"]);
2241
+ }
2159
2242
  return {
2160
- "font-size": sizePairs.fontSize,
2161
- "line-height": lineHeight ?? sizePairs.lineHeight ?? "1",
2162
- "letter-spacing": sizePairs.letterSpacing
2243
+ "font-size": `var(--text-${size}-font-size)`,
2244
+ "line-height": lineHeight ?? `var(--un-leading, var(--text-${size}-line-height))`,
2245
+ "letter-spacing": sizePairs.letterSpacing ? `var(--text-${size}-letter-spacing)` : void 0
2163
2246
  };
2164
2247
  }
2165
2248
  const fontSize = h.bracketOfLength.rem(size);
@@ -2173,6 +2256,8 @@ function handleText([, s = "base"], { theme }) {
2173
2256
  }
2174
2257
  function handleSize([, s], { theme }) {
2175
2258
  if (theme.text?.[s] != null) {
2259
+ themeTracking(`text`, [s, "fontSize"]);
2260
+ themeTracking(`text`, [s, "lineHeight"]);
2176
2261
  return {
2177
2262
  "font-size": `var(--text-${s}-font-size)`,
2178
2263
  "line-height": `var(--un-leading, var(--text-${s}--line-height))`
@@ -1,5 +1,5 @@
1
1
  import { Rule } from '@unocss/core';
2
- import { T as Theme } from './preset-wind4.MiZzPO05.js';
2
+ import { T as Theme } from './preset-wind4.BXbWGSRz.js';
3
3
 
4
4
  declare const rules: Rule<Theme>[];
5
5
 
@@ -1,6 +1,16 @@
1
- import { escapeSelector, toArray } from '@unocss/core';
1
+ import { toArray, escapeSelector } from '@unocss/core';
2
2
  import { createValueHandler, parseCssColor, getStringComponents, colorToString, getStringComponent } from '@unocss/rule-utils';
3
3
 
4
+ const PRESET_NAME = "@unocss/preset-wind4";
5
+ const passThemeKey = ["DEFAULT", "none"];
6
+ const trackedTheme = /* @__PURE__ */ new Set([]);
7
+ function themeTracking(key, props = "DEFAULT") {
8
+ const k = `${key}:${toArray(props).join("-")}`;
9
+ if (!trackedTheme.has(k)) {
10
+ trackedTheme.add(k);
11
+ }
12
+ }
13
+
4
14
  const directionMap = {
5
15
  "l": ["-left"],
6
16
  "r": ["-right"],
@@ -426,6 +436,7 @@ function directionSize(propertyPrefix) {
426
436
  let v;
427
437
  v = numberResolver(size, spaceMap[size]);
428
438
  if (v != null) {
439
+ themeTracking("spacing");
429
440
  return directionMap[direction].map((i) => [`${propertyPrefix}${i}`, `calc(var(--spacing) * ${v})`]);
430
441
  }
431
442
  v = h.bracket.cssvar.global.auto.fraction.rem(size);
@@ -435,6 +446,7 @@ function directionSize(propertyPrefix) {
435
446
  if (size?.startsWith("-")) {
436
447
  const _v = spaceMap[size.slice(1)];
437
448
  if (_v != null) {
449
+ themeTracking("spacing");
438
450
  v = `calc(var(--spacing) * -${_v})`;
439
451
  return directionMap[direction].map((i) => [`${propertyPrefix}${i}`, v]);
440
452
  }
@@ -496,6 +508,12 @@ function colorCSSGenerator(data, property, varName, ctx) {
496
508
  css[alphaKey] = alpha;
497
509
  css[property] = `color-mix(in oklch, ${value} var(${alphaKey}), transparent)${rawColorComment}`;
498
510
  result.push(defineProperty(alphaKey, { syntax: "<percentage>", initialValue: "100%" }));
511
+ if (key) {
512
+ themeTracking(`colors`, key);
513
+ }
514
+ if (ctx?.theme) {
515
+ detectThemeValue(color, ctx.theme);
516
+ }
499
517
  }
500
518
  return result;
501
519
  }
@@ -556,10 +574,16 @@ function parseThemeColor(theme, keys) {
556
574
  no = scale;
557
575
  _keys = keys.slice(0, -1);
558
576
  }
559
- const colorData = getThemeColor(theme, _keys);
577
+ const colorData = getThemeByKey(theme, "colors", _keys);
560
578
  if (typeof colorData === "object") {
561
- color = colorData[no ?? "400"];
562
- key = [..._keys, no ?? "400"].join("-");
579
+ if (no && colorData[no]) {
580
+ color = colorData[no];
581
+ key = [..._keys, no].join("-");
582
+ } else if (!no && colorData.DEFAULT) {
583
+ color = colorData.DEFAULT;
584
+ no = "DEFAULT";
585
+ key = _keys.join("-");
586
+ }
563
587
  } else if (typeof colorData === "string" && !no) {
564
588
  color = colorData;
565
589
  key = _keys.join("-");
@@ -572,15 +596,18 @@ function parseThemeColor(theme, keys) {
572
596
  key
573
597
  };
574
598
  }
575
- function getThemeColor(theme, keys) {
576
- let obj = theme.colors;
599
+ function getThemeByKey(theme, themeKey, keys) {
600
+ let obj = theme[themeKey];
577
601
  let index = -1;
578
602
  for (const k of keys) {
579
603
  index += 1;
580
604
  if (obj && typeof obj !== "string") {
581
- const camel = keys.slice(index).join("-").replace(/(-[a-z])/g, (n) => n.slice(1).toUpperCase());
605
+ const camel = camelize(keys.slice(index).join("-"));
582
606
  if (obj[camel])
583
607
  return obj[camel];
608
+ const hyphen = keys.slice(index).join("-");
609
+ if (obj[hyphen])
610
+ return obj[hyphen];
584
611
  if (obj[k]) {
585
612
  obj = obj[k];
586
613
  continue;
@@ -629,10 +656,15 @@ function transformXYZ(d, v, name) {
629
656
  return xyzMap[d].map((i) => [`--un-${name}${i}`, v]);
630
657
  return values.map((v2, i) => [`--un-${name}-${xyzArray[i]}`, v2]);
631
658
  }
632
- function camelToHyphen(str) {
633
- return str.replace(/[A-Z]/g, "-$&").toLowerCase();
659
+ function camelize(str) {
660
+ return str.replace(/-(\w)/g, (_, c) => c ? c.toUpperCase() : "");
634
661
  }
635
- function compressCSS(css) {
662
+ function hyphenate(str) {
663
+ return str.replace(/(?:^|\B)([A-Z])/g, "-$1").toLowerCase();
664
+ }
665
+ function compressCSS(css, isDev = false) {
666
+ if (isDev)
667
+ return css.trim();
636
668
  return css.trim().replace(/\s+/g, " ").replace(/\/\*[\s\S]*?\*\//g, "");
637
669
  }
638
670
  function defineProperty(property, options = {}) {
@@ -643,5 +675,18 @@ function defineProperty(property, options = {}) {
643
675
  } = options;
644
676
  return `@property ${property} {syntax: "${syntax}";inherits: ${inherits};${initialValue != null ? `initial-value: ${initialValue};` : ""}}`;
645
677
  }
678
+ function detectThemeValue(value, theme) {
679
+ if (value.startsWith("var(")) {
680
+ const variable = value.match(/var\(--([\w-]+)(?:,.*)?\)/)?.[1];
681
+ if (variable) {
682
+ const [key, ...path] = variable.split("-");
683
+ const themeValue = getThemeByKey(theme, key, path);
684
+ if (themeValue != null) {
685
+ themeTracking(key, path);
686
+ detectThemeValue(themeValue, theme);
687
+ }
688
+ }
689
+ }
690
+ }
646
691
 
647
- export { isCSSMathFn as A, isSize as B, CONTROL_MINI_NO_NEGATIVE as C, transformXYZ as D, camelToHyphen as E, compressCSS as F, defineProperty as G, bracketTypeRe as H, SpecialColorKey as S, h as a, xyzArray as b, cornerMap as c, directionMap as d, cssMathFnRE as e, cssVarFnRE as f, globalKeywords as g, handler as h, insetMap as i, directionSize as j, colorableShadows as k, colorCSSGenerator as l, colorResolver as m, numberResolver as n, parseColor as o, positionMap as p, parseThemeColor as q, getThemeColor as r, splitShorthand as s, colorVariable as t, hasParseableColor as u, valueHandlers as v, resolveBreakpoints as w, xyzMap as x, resolveVerticalBreakpoints as y, makeGlobalStaticRules as z };
692
+ export { resolveBreakpoints as A, resolveVerticalBreakpoints as B, CONTROL_MINI_NO_NEGATIVE as C, makeGlobalStaticRules as D, isCSSMathFn as E, isSize as F, transformXYZ as G, camelize as H, hyphenate as I, compressCSS as J, defineProperty as K, detectThemeValue as L, bracketTypeRe as M, PRESET_NAME as P, SpecialColorKey as S, themeTracking as a, h as b, cornerMap as c, directionMap as d, xyzArray as e, positionMap as f, globalKeywords as g, handler as h, insetMap as i, cssMathFnRE as j, cssVarFnRE as k, directionSize as l, colorableShadows as m, numberResolver as n, colorCSSGenerator as o, passThemeKey as p, colorResolver as q, parseColor as r, splitShorthand as s, trackedTheme as t, parseThemeColor as u, valueHandlers as v, getThemeByKey as w, xyzMap as x, colorVariable as y, hasParseableColor as z };
@@ -1,5 +1,5 @@
1
1
  import { Rule } from '@unocss/core';
2
- import { T as Theme } from './preset-wind4.MiZzPO05.mjs';
2
+ import { T as Theme } from './preset-wind4.BXbWGSRz.mjs';
3
3
 
4
4
  declare const rules: Rule<Theme>[];
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { variantGetParameter, variantMatcher, variantGetBracket, variantParentMatcher, getBracket, hasThemeFn, transformThemeFn, getStringComponent } from '@unocss/rule-utils';
2
- import { a as h, w as resolveBreakpoints, C as CONTROL_MINI_NO_NEGATIVE, e as cssMathFnRE, f as cssVarFnRE, u as hasParseableColor } from './preset-wind4.D40diWvF.mjs';
2
+ import { b as h, A as resolveBreakpoints, C as CONTROL_MINI_NO_NEGATIVE, j as cssMathFnRE, k as cssVarFnRE, z as hasParseableColor } from './preset-wind4.CkxnR6p3.mjs';
3
3
  import { escapeRegExp, escapeSelector } from '@unocss/core';
4
4
 
5
5
  const variantAria = {
@@ -1,5 +1,5 @@
1
1
  import { isString } from '@unocss/core';
2
- import { w as resolveBreakpoints } from './preset-wind4.D40diWvF.mjs';
2
+ import { A as resolveBreakpoints } from './preset-wind4.CkxnR6p3.mjs';
3
3
 
4
4
  const containerParent = [
5
5
  [/^@container(?:\/(\w+))?(?:-(normal))?$/, ([, l, v]) => {
@@ -1,5 +1,5 @@
1
1
  import * as _unocss_core from '@unocss/core';
2
- import { T as Theme } from './shared/preset-wind4.MiZzPO05.mjs';
2
+ import { T as Theme } from './shared/preset-wind4.BXbWGSRz.mjs';
3
3
 
4
4
  declare const shortcuts: _unocss_core.Shortcut<Theme>[];
5
5
 
@@ -1,5 +1,5 @@
1
1
  import * as _unocss_core from '@unocss/core';
2
- import { T as Theme } from './shared/preset-wind4.MiZzPO05.js';
2
+ import { T as Theme } from './shared/preset-wind4.BXbWGSRz.js';
3
3
 
4
4
  declare const shortcuts: _unocss_core.Shortcut<Theme>[];
5
5
 
@@ -1,5 +1,5 @@
1
- export { s as shortcuts } from './shared/preset-wind4.Bv7psfuU.mjs';
2
- import './shared/preset-wind4.DRtfClGs.mjs';
1
+ export { s as shortcuts } from './shared/preset-wind4.BwU-POWl.mjs';
2
+ import './shared/preset-wind4.DhDf1e1c.mjs';
3
3
  import '@unocss/core';
4
- import './shared/preset-wind4.D40diWvF.mjs';
4
+ import './shared/preset-wind4.CkxnR6p3.mjs';
5
5
  import '@unocss/rule-utils';
package/dist/theme.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { colors } from './colors.mjs';
2
- export { t as theme } from './shared/preset-wind4.pue_BigB.mjs';
3
- import { T as Theme } from './shared/preset-wind4.MiZzPO05.mjs';
4
- export { C as Colors, a as ThemeAnimation } from './shared/preset-wind4.MiZzPO05.mjs';
2
+ export { t as theme } from './shared/preset-wind4.BOe5kxIw.mjs';
3
+ import { T as Theme } from './shared/preset-wind4.BXbWGSRz.mjs';
4
+ export { C as Colors, a as ThemeAnimation } from './shared/preset-wind4.BXbWGSRz.mjs';
5
5
 
6
6
  declare const animation: {
7
7
  keyframes: {
@@ -514,6 +514,7 @@ declare const perspective: {
514
514
  declare const defaults: {
515
515
  transition: {
516
516
  duration: string;
517
+ timingFunction: string;
517
518
  };
518
519
  font: {
519
520
  family: string;
package/dist/theme.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { colors } from './colors.js';
2
- export { t as theme } from './shared/preset-wind4.pue_BigB.js';
3
- import { T as Theme } from './shared/preset-wind4.MiZzPO05.js';
4
- export { C as Colors, a as ThemeAnimation } from './shared/preset-wind4.MiZzPO05.js';
2
+ export { t as theme } from './shared/preset-wind4.BOe5kxIw.js';
3
+ import { T as Theme } from './shared/preset-wind4.BXbWGSRz.js';
4
+ export { C as Colors, a as ThemeAnimation } from './shared/preset-wind4.BXbWGSRz.js';
5
5
 
6
6
  declare const animation: {
7
7
  keyframes: {
@@ -514,6 +514,7 @@ declare const perspective: {
514
514
  declare const defaults: {
515
515
  transition: {
516
516
  duration: string;
517
+ timingFunction: string;
517
518
  };
518
519
  font: {
519
520
  family: string;
package/dist/theme.mjs CHANGED
@@ -461,7 +461,8 @@ const perspective = {
461
461
  };
462
462
  const defaults = {
463
463
  transition: {
464
- duration: "150ms"
464
+ duration: "150ms",
465
+ timingFunction: "cubic-bezier(0.4, 0, 0.2, 1)"
465
466
  },
466
467
  font: {
467
468
  family: "var(--font-sans)",
package/dist/utils.d.mts CHANGED
@@ -1,10 +1,20 @@
1
+ import { Arrayable, DynamicMatcher, RuleContext, CSSObject, CSSValueInput, VariantContext, StaticRule } from '@unocss/core';
1
2
  import * as _unocss_rule_utils from '@unocss/rule-utils';
2
3
  export * from '@unocss/rule-utils';
3
- import { DynamicMatcher, RuleContext, CSSObject, CSSValueInput, VariantContext, StaticRule } from '@unocss/core';
4
- import { T as Theme, C as Colors } from './shared/preset-wind4.MiZzPO05.mjs';
4
+ import { T as Theme } from './shared/preset-wind4.BXbWGSRz.mjs';
5
5
 
6
+ declare const PRESET_NAME = "@unocss/preset-wind4";
6
7
  /** Keys will not appear in the theme variable. */
7
8
  declare const passThemeKey: string[];
9
+ /**
10
+ * Used to track theme keys.
11
+ *
12
+ * eg: colors:red-100
13
+ *
14
+ * @internal
15
+ */
16
+ declare const trackedTheme: Set<string>;
17
+ declare function themeTracking(key: string, props?: Arrayable<string>): void;
8
18
 
9
19
  declare function numberWithUnit(str: string): string | undefined;
10
20
  declare function auto(str: string): "auto" | undefined;
@@ -111,7 +121,7 @@ declare function parseThemeColor(theme: Theme, keys: string[]): {
111
121
  no: string | undefined;
112
122
  key: string | undefined;
113
123
  } | undefined;
114
- declare function getThemeColor(theme: Theme, keys: string[]): string | Colors | undefined;
124
+ declare function getThemeByKey(theme: Theme, themeKey: keyof Theme, keys: string[]): any;
115
125
  declare function colorVariable(str: string, varName: string): string;
116
126
  declare function hasParseableColor(color: string | undefined, theme: Theme): boolean;
117
127
  declare function resolveBreakpoints({ theme, generator }: Readonly<VariantContext<Theme>>, key?: 'breakpoint' | 'verticalBreakpoint'): {
@@ -126,12 +136,14 @@ declare function makeGlobalStaticRules(prefix: string, property?: string): Stati
126
136
  declare function isCSSMathFn(value: string | undefined): boolean;
127
137
  declare function isSize(str: string): boolean;
128
138
  declare function transformXYZ(d: string, v: string, name: string): [string, string][];
129
- declare function camelToHyphen(str: string): string;
130
- declare function compressCSS(css: string): string;
139
+ declare function camelize(str: string): string;
140
+ declare function hyphenate(str: string): string;
141
+ declare function compressCSS(css: string, isDev?: boolean): string;
131
142
  declare function defineProperty(property: string, options?: {
132
143
  syntax?: string;
133
144
  inherits?: boolean;
134
145
  initialValue?: unknown;
135
146
  }): string;
147
+ declare function detectThemeValue(value: string, theme: Theme): void;
136
148
 
137
- export { CONTROL_MINI_NO_NEGATIVE, SpecialColorKey, camelToHyphen, colorCSSGenerator, colorResolver, colorVariable, colorableShadows, compressCSS, cornerMap, cssMathFnRE, cssVarFnRE, defineProperty, directionMap, directionSize, getThemeColor, globalKeywords, h, handler, hasParseableColor, insetMap, isCSSMathFn, isSize, makeGlobalStaticRules, numberResolver, parseColor, parseThemeColor, passThemeKey, positionMap, resolveBreakpoints, resolveVerticalBreakpoints, splitShorthand, transformXYZ, handlers as valueHandlers, xyzArray, xyzMap };
149
+ export { CONTROL_MINI_NO_NEGATIVE, PRESET_NAME, SpecialColorKey, camelize, colorCSSGenerator, colorResolver, colorVariable, colorableShadows, compressCSS, cornerMap, cssMathFnRE, cssVarFnRE, defineProperty, detectThemeValue, directionMap, directionSize, getThemeByKey, globalKeywords, h, handler, hasParseableColor, hyphenate, insetMap, isCSSMathFn, isSize, makeGlobalStaticRules, numberResolver, parseColor, parseThemeColor, passThemeKey, positionMap, resolveBreakpoints, resolveVerticalBreakpoints, splitShorthand, themeTracking, trackedTheme, transformXYZ, handlers as valueHandlers, xyzArray, xyzMap };
package/dist/utils.d.ts CHANGED
@@ -1,10 +1,20 @@
1
+ import { Arrayable, DynamicMatcher, RuleContext, CSSObject, CSSValueInput, VariantContext, StaticRule } from '@unocss/core';
1
2
  import * as _unocss_rule_utils from '@unocss/rule-utils';
2
3
  export * from '@unocss/rule-utils';
3
- import { DynamicMatcher, RuleContext, CSSObject, CSSValueInput, VariantContext, StaticRule } from '@unocss/core';
4
- import { T as Theme, C as Colors } from './shared/preset-wind4.MiZzPO05.js';
4
+ import { T as Theme } from './shared/preset-wind4.BXbWGSRz.js';
5
5
 
6
+ declare const PRESET_NAME = "@unocss/preset-wind4";
6
7
  /** Keys will not appear in the theme variable. */
7
8
  declare const passThemeKey: string[];
9
+ /**
10
+ * Used to track theme keys.
11
+ *
12
+ * eg: colors:red-100
13
+ *
14
+ * @internal
15
+ */
16
+ declare const trackedTheme: Set<string>;
17
+ declare function themeTracking(key: string, props?: Arrayable<string>): void;
8
18
 
9
19
  declare function numberWithUnit(str: string): string | undefined;
10
20
  declare function auto(str: string): "auto" | undefined;
@@ -111,7 +121,7 @@ declare function parseThemeColor(theme: Theme, keys: string[]): {
111
121
  no: string | undefined;
112
122
  key: string | undefined;
113
123
  } | undefined;
114
- declare function getThemeColor(theme: Theme, keys: string[]): string | Colors | undefined;
124
+ declare function getThemeByKey(theme: Theme, themeKey: keyof Theme, keys: string[]): any;
115
125
  declare function colorVariable(str: string, varName: string): string;
116
126
  declare function hasParseableColor(color: string | undefined, theme: Theme): boolean;
117
127
  declare function resolveBreakpoints({ theme, generator }: Readonly<VariantContext<Theme>>, key?: 'breakpoint' | 'verticalBreakpoint'): {
@@ -126,12 +136,14 @@ declare function makeGlobalStaticRules(prefix: string, property?: string): Stati
126
136
  declare function isCSSMathFn(value: string | undefined): boolean;
127
137
  declare function isSize(str: string): boolean;
128
138
  declare function transformXYZ(d: string, v: string, name: string): [string, string][];
129
- declare function camelToHyphen(str: string): string;
130
- declare function compressCSS(css: string): string;
139
+ declare function camelize(str: string): string;
140
+ declare function hyphenate(str: string): string;
141
+ declare function compressCSS(css: string, isDev?: boolean): string;
131
142
  declare function defineProperty(property: string, options?: {
132
143
  syntax?: string;
133
144
  inherits?: boolean;
134
145
  initialValue?: unknown;
135
146
  }): string;
147
+ declare function detectThemeValue(value: string, theme: Theme): void;
136
148
 
137
- export { CONTROL_MINI_NO_NEGATIVE, SpecialColorKey, camelToHyphen, colorCSSGenerator, colorResolver, colorVariable, colorableShadows, compressCSS, cornerMap, cssMathFnRE, cssVarFnRE, defineProperty, directionMap, directionSize, getThemeColor, globalKeywords, h, handler, hasParseableColor, insetMap, isCSSMathFn, isSize, makeGlobalStaticRules, numberResolver, parseColor, parseThemeColor, passThemeKey, positionMap, resolveBreakpoints, resolveVerticalBreakpoints, splitShorthand, transformXYZ, handlers as valueHandlers, xyzArray, xyzMap };
149
+ export { CONTROL_MINI_NO_NEGATIVE, PRESET_NAME, SpecialColorKey, camelize, colorCSSGenerator, colorResolver, colorVariable, colorableShadows, compressCSS, cornerMap, cssMathFnRE, cssVarFnRE, defineProperty, detectThemeValue, directionMap, directionSize, getThemeByKey, globalKeywords, h, handler, hasParseableColor, hyphenate, insetMap, isCSSMathFn, isSize, makeGlobalStaticRules, numberResolver, parseColor, parseThemeColor, passThemeKey, positionMap, resolveBreakpoints, resolveVerticalBreakpoints, splitShorthand, themeTracking, trackedTheme, transformXYZ, handlers as valueHandlers, xyzArray, xyzMap };
package/dist/utils.mjs CHANGED
@@ -1,4 +1,3 @@
1
- export { p as passThemeKey } from './shared/preset-wind4.DRtKeBWc.mjs';
2
- export { C as CONTROL_MINI_NO_NEGATIVE, S as SpecialColorKey, E as camelToHyphen, l as colorCSSGenerator, m as colorResolver, t as colorVariable, k as colorableShadows, F as compressCSS, c as cornerMap, e as cssMathFnRE, f as cssVarFnRE, G as defineProperty, d as directionMap, j as directionSize, r as getThemeColor, g as globalKeywords, a as h, h as handler, u as hasParseableColor, i as insetMap, A as isCSSMathFn, B as isSize, z as makeGlobalStaticRules, n as numberResolver, o as parseColor, q as parseThemeColor, p as positionMap, w as resolveBreakpoints, y as resolveVerticalBreakpoints, s as splitShorthand, D as transformXYZ, v as valueHandlers, b as xyzArray, x as xyzMap } from './shared/preset-wind4.D40diWvF.mjs';
1
+ export { C as CONTROL_MINI_NO_NEGATIVE, P as PRESET_NAME, S as SpecialColorKey, H as camelize, o as colorCSSGenerator, q as colorResolver, y as colorVariable, m as colorableShadows, J as compressCSS, c as cornerMap, j as cssMathFnRE, k as cssVarFnRE, K as defineProperty, L as detectThemeValue, d as directionMap, l as directionSize, w as getThemeByKey, g as globalKeywords, b as h, h as handler, z as hasParseableColor, I as hyphenate, i as insetMap, E as isCSSMathFn, F as isSize, D as makeGlobalStaticRules, n as numberResolver, r as parseColor, u as parseThemeColor, p as passThemeKey, f as positionMap, A as resolveBreakpoints, B as resolveVerticalBreakpoints, s as splitShorthand, a as themeTracking, t as trackedTheme, G as transformXYZ, v as valueHandlers, e as xyzArray, x as xyzMap } from './shared/preset-wind4.CkxnR6p3.mjs';
3
2
  export * from '@unocss/rule-utils';
4
3
  import '@unocss/core';
@@ -1,10 +1,10 @@
1
1
  import { VariantObject, Variant, VariantFunction } from '@unocss/core';
2
- import { T as Theme } from './shared/preset-wind4.MiZzPO05.mjs';
2
+ import { T as Theme } from './shared/preset-wind4.BXbWGSRz.mjs';
3
3
  import { PresetWind4Options } from './index.mjs';
4
4
  export { variants } from './index.mjs';
5
- import './shared/preset-wind4.DIUjJahF.mjs';
5
+ import './shared/preset-wind4.D71xGC6i.mjs';
6
6
  import './shortcuts.mjs';
7
- import './shared/preset-wind4.pue_BigB.mjs';
7
+ import './shared/preset-wind4.BOe5kxIw.mjs';
8
8
 
9
9
  declare const variantAria: VariantObject<Theme>;
10
10
  declare const variantTaggedAriaAttributes: Variant<Theme>[];
@@ -1,10 +1,10 @@
1
1
  import { VariantObject, Variant, VariantFunction } from '@unocss/core';
2
- import { T as Theme } from './shared/preset-wind4.MiZzPO05.js';
2
+ import { T as Theme } from './shared/preset-wind4.BXbWGSRz.js';
3
3
  import { PresetWind4Options } from './index.js';
4
4
  export { variants } from './index.js';
5
- import './shared/preset-wind4.BJEl798_.js';
5
+ import './shared/preset-wind4.Ca5oWgxX.js';
6
6
  import './shortcuts.js';
7
- import './shared/preset-wind4.pue_BigB.js';
7
+ import './shared/preset-wind4.BOe5kxIw.js';
8
8
 
9
9
  declare const variantAria: VariantObject<Theme>;
10
10
  declare const variantTaggedAriaAttributes: Variant<Theme>[];
package/dist/variants.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { c as calcMaxWidthBySize, D as placeholderModifier, v as variantAria, b as variantBreakpoints, d as variantChildren, h as variantColorsMediaOrClass, i as variantColorsScheme, e as variantCombinators, g as variantContainerQuery, q as variantContrasts, w as variantCssLayer, p as variantCustomMedia, j as variantDataAttribute, t as variantForcedColors, n as variantImportant, x as variantInternalLayer, m as variantLanguageDirections, r as variantMotions, C as variantNegative, s as variantOrientations, H as variantPartClasses, o as variantPrint, F as variantPseudoClassFunctions, E as variantPseudoClassesAndElements, y as variantScope, u as variantSelector, I as variantStartingStyle, B as variantStickyHover, J as variantSupports, f as variantSvgCombinators, a as variantTaggedAriaAttributes, k as variantTaggedDataAttributes, G as variantTaggedPseudoClasses, A as variantTheme, z as variantVariables, l as variants } from './shared/preset-wind4.DXynlr0l.mjs';
1
+ export { c as calcMaxWidthBySize, D as placeholderModifier, v as variantAria, b as variantBreakpoints, d as variantChildren, h as variantColorsMediaOrClass, i as variantColorsScheme, e as variantCombinators, g as variantContainerQuery, q as variantContrasts, w as variantCssLayer, p as variantCustomMedia, j as variantDataAttribute, t as variantForcedColors, n as variantImportant, x as variantInternalLayer, m as variantLanguageDirections, r as variantMotions, C as variantNegative, s as variantOrientations, H as variantPartClasses, o as variantPrint, F as variantPseudoClassFunctions, E as variantPseudoClassesAndElements, y as variantScope, u as variantSelector, I as variantStartingStyle, B as variantStickyHover, J as variantSupports, f as variantSvgCombinators, a as variantTaggedAriaAttributes, k as variantTaggedDataAttributes, G as variantTaggedPseudoClasses, A as variantTheme, z as variantVariables, l as variants } from './shared/preset-wind4.DXr6hHdY.mjs';
2
2
  import '@unocss/rule-utils';
3
- import './shared/preset-wind4.D40diWvF.mjs';
3
+ import './shared/preset-wind4.CkxnR6p3.mjs';
4
4
  import '@unocss/core';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unocss/preset-wind4",
3
3
  "type": "module",
4
- "version": "66.1.0-beta.5",
4
+ "version": "66.1.0-beta.7",
5
5
  "description": "Tailwind 4 compact preset for UnoCSS",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -65,9 +65,9 @@
65
65
  "dist"
66
66
  ],
67
67
  "dependencies": {
68
- "@unocss/core": "66.1.0-beta.5",
69
- "@unocss/extractor-arbitrary-variants": "66.1.0-beta.5",
70
- "@unocss/rule-utils": "66.1.0-beta.5"
68
+ "@unocss/core": "66.1.0-beta.7",
69
+ "@unocss/extractor-arbitrary-variants": "66.1.0-beta.7",
70
+ "@unocss/rule-utils": "66.1.0-beta.7"
71
71
  },
72
72
  "scripts": {
73
73
  "build": "unbuild",
@@ -1,3 +0,0 @@
1
- const passThemeKey = ["DEFAULT", "none"];
2
-
3
- export { passThemeKey as p };