@unocss/rule-utils 66.5.4 → 66.5.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.d.mts CHANGED
@@ -50,16 +50,16 @@ declare function transformThemeFn(code: string, theme: Record<string, any>, thro
50
50
  declare function transformThemeString(code: string, theme: Record<string, any>, throwOnMissing?: boolean): string | undefined;
51
51
  declare function calcMaxWidthBySize(size: string): string;
52
52
 
53
- type ValueHandlerCallback = (str: string) => string | number | undefined;
54
- type ValueHandler<K extends string> = {
55
- [S in K]: ValueHandler<K>;
53
+ type ValueHandlerCallback<T extends object> = (str: string, theme?: T) => string | number | undefined;
54
+ type ValueHandler<K extends string, T extends object> = {
55
+ [S in K]: ValueHandler<K, T>;
56
56
  } & {
57
- (str: string): string | undefined;
57
+ (str: string, theme?: T): string | undefined;
58
58
  __options: {
59
59
  sequence: K[];
60
60
  };
61
61
  };
62
- declare function createValueHandler<K extends string>(handlers: Record<K, ValueHandlerCallback>): ValueHandler<K>;
62
+ declare function createValueHandler<K extends string, T extends object>(handlers: Record<K, ValueHandlerCallback<T>>): ValueHandler<K, T>;
63
63
 
64
64
  declare const iconFnRE: RegExp;
65
65
  declare function hasIconFn(str: string): boolean;
@@ -103,10 +103,10 @@ interface PseudoVariantOptions {
103
103
  */
104
104
  prefix?: string | string[];
105
105
  }
106
- interface PseudoVariantUtilities {
106
+ interface PseudoVariantUtilities<Theme extends object = object> {
107
107
  getBracket: typeof getBracket;
108
108
  h: {
109
- bracket: (s: string) => string | undefined;
109
+ bracket: (s: string, theme?: Theme) => string | undefined;
110
110
  };
111
111
  variantGetBracket: typeof variantGetBracket;
112
112
  }
package/dist/index.d.ts CHANGED
@@ -50,16 +50,16 @@ declare function transformThemeFn(code: string, theme: Record<string, any>, thro
50
50
  declare function transformThemeString(code: string, theme: Record<string, any>, throwOnMissing?: boolean): string | undefined;
51
51
  declare function calcMaxWidthBySize(size: string): string;
52
52
 
53
- type ValueHandlerCallback = (str: string) => string | number | undefined;
54
- type ValueHandler<K extends string> = {
55
- [S in K]: ValueHandler<K>;
53
+ type ValueHandlerCallback<T extends object> = (str: string, theme?: T) => string | number | undefined;
54
+ type ValueHandler<K extends string, T extends object> = {
55
+ [S in K]: ValueHandler<K, T>;
56
56
  } & {
57
- (str: string): string | undefined;
57
+ (str: string, theme?: T): string | undefined;
58
58
  __options: {
59
59
  sequence: K[];
60
60
  };
61
61
  };
62
- declare function createValueHandler<K extends string>(handlers: Record<K, ValueHandlerCallback>): ValueHandler<K>;
62
+ declare function createValueHandler<K extends string, T extends object>(handlers: Record<K, ValueHandlerCallback<T>>): ValueHandler<K, T>;
63
63
 
64
64
  declare const iconFnRE: RegExp;
65
65
  declare function hasIconFn(str: string): boolean;
@@ -103,10 +103,10 @@ interface PseudoVariantOptions {
103
103
  */
104
104
  prefix?: string | string[];
105
105
  }
106
- interface PseudoVariantUtilities {
106
+ interface PseudoVariantUtilities<Theme extends object = object> {
107
107
  getBracket: typeof getBracket;
108
108
  h: {
109
- bracket: (s: string) => string | undefined;
109
+ bracket: (s: string, theme?: Theme) => string | undefined;
110
110
  };
111
111
  variantGetBracket: typeof variantGetBracket;
112
112
  }
package/dist/index.mjs CHANGED
@@ -327,11 +327,11 @@ function calcMaxWidthBySize(size) {
327
327
  }
328
328
 
329
329
  function createValueHandler(handlers) {
330
- const handler = function(str) {
330
+ const handler = function(str, theme) {
331
331
  const s = this.__options?.sequence || [];
332
332
  this.__options.sequence = [];
333
333
  for (const n of s) {
334
- const res = handlers[n](str);
334
+ const res = handlers[n](str, theme);
335
335
  if (res != null)
336
336
  return res;
337
337
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unocss/rule-utils",
3
3
  "type": "module",
4
- "version": "66.5.4",
4
+ "version": "66.5.5",
5
5
  "description": "Utilities for UnoCSS",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -33,8 +33,8 @@
33
33
  "node": ">=14"
34
34
  },
35
35
  "dependencies": {
36
- "magic-string": "^0.30.19",
37
- "@unocss/core": "^66.5.4"
36
+ "magic-string": "^0.30.21",
37
+ "@unocss/core": "^66.5.5"
38
38
  },
39
39
  "scripts": {
40
40
  "build": "unbuild",