From 7bda950debf87e490062ae0bc34849a4b616ec45 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Wed, 6 Mar 2024 15:49:45 +0900 Subject: [PATCH] chore(deps): add unocss-ts --- .prettierignore | 2 +- package.json | 1 + packages/app/src/styles/tw/types.ts | 823 ++++++++++++++---- packages/lib/package.json | 4 +- packages/lib/src/index.ts | 2 +- .../lib/src/{tw/types.ts => tw-types.d.ts} | 13 +- packages/lib/src/tw/index.ts | 4 - packages/lib/uno.config.ts | 19 +- pnpm-lock.yaml | 16 +- 9 files changed, 674 insertions(+), 210 deletions(-) rename packages/lib/src/{tw/types.ts => tw-types.d.ts} (99%) delete mode 100644 packages/lib/src/tw/index.ts diff --git a/.prettierignore b/.prettierignore index df7c445f..a64d05bc 100644 --- a/.prettierignore +++ b/.prettierignore @@ -2,4 +2,4 @@ node_modules dist pnpm-lock.yaml .vercel -tw +tw-types.d.ts diff --git a/package.json b/package.json index 3cf84b9e..76055069 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "@hiogawa/isort-ts": "1.1.2-pre.0", "@hiogawa/theme-script": "^0.0.3", "@hiogawa/tiny-refresh": "0.0.1-pre.11", + "@hiogawa/unocss-ts": "0.0.1-pre.0", "@hiogawa/unocss-typescript-dsl": "2.0.0-pre.8", "@hiogawa/utils": "1.6.1-pre.9", "@hiogawa/utils-react": "1.3.1-pre.0", diff --git a/packages/app/src/styles/tw/types.ts b/packages/app/src/styles/tw/types.ts index 00cf7229..6c5165ab 100644 --- a/packages/app/src/styles/tw/types.ts +++ b/packages/app/src/styles/tw/types.ts @@ -27,7 +27,6 @@ type ApiToString = { export type Api = ApiProperty & ApiMethod & ApiCustom & ApiToString; - // // constants based on unocss config // @@ -43,8 +42,7 @@ export type Theme_aria = | `readonly` | `required` | `selected` - | `current_page` -; + | `current_page`; export type Theme_colors = | `colorPrimary` @@ -141,8 +139,7 @@ export type Theme_colors = | `current` | `transparent` | `black` - | `white` -; + | `white`; export type Theme_animation_keyframes = | `spin_composable` @@ -246,8 +243,7 @@ export type Theme_animation_keyframes = | `back_out_up` | `back_out_down` | `back_out_right` - | `back_out_left` -; + | `back_out_left`; export type Theme_animation_counts = | `spin_composable` @@ -256,8 +252,7 @@ export type Theme_animation_counts = | `pulse` | `pulse_alt` | `bounce` - | `bounce_alt` -; + | `bounce_alt`; export type Theme_animation_durations = | `pulse` @@ -266,8 +261,7 @@ export type Theme_animation_durations = | `bounce_out` | `flip_out_x` | `flip_out_y` - | `hinge` -; + | `hinge`; export type Theme_animation_timingFns = | `pulse` @@ -278,8 +272,7 @@ export type Theme_animation_timingFns = | `light_speed_in_left` | `light_speed_in_right` | `light_speed_out_left` - | `light_speed_out_right` -; + | `light_speed_out_right`; export type Theme_animation_properties = | `bounce_alt` @@ -304,8 +297,7 @@ export type Theme_animation_properties = | `zoom_out_down` | `zoom_out_left` | `zoom_out_right` - | `zoom_out_up` -; + | `zoom_out_up`; export type Theme_width = | `auto` @@ -321,8 +313,7 @@ export type Theme_width = | `6xl` | `7xl` | `prose` - | `screen` -; + | `screen`; export type Theme_height = | `auto` @@ -338,8 +329,7 @@ export type Theme_height = | `6xl` | `7xl` | `prose` - | `screen` -; + | `screen`; export type Theme_maxWidth = | `none` @@ -355,8 +345,7 @@ export type Theme_maxWidth = | `6xl` | `7xl` | `prose` - | `screen` -; + | `screen`; export type Theme_maxHeight = | `none` @@ -372,8 +361,7 @@ export type Theme_maxHeight = | `6xl` | `7xl` | `prose` - | `screen` -; + | `screen`; export type Theme_minWidth = | `none` @@ -389,8 +377,7 @@ export type Theme_minWidth = | `6xl` | `7xl` | `prose` - | `screen` -; + | `screen`; export type Theme_minHeight = | `none` @@ -406,8 +393,7 @@ export type Theme_minHeight = | `6xl` | `7xl` | `prose` - | `screen` -; + | `screen`; export type Theme_inlineSize = | `auto` @@ -423,8 +409,7 @@ export type Theme_inlineSize = | `6xl` | `7xl` | `prose` - | `screen` -; + | `screen`; export type Theme_blockSize = | `auto` @@ -440,8 +425,7 @@ export type Theme_blockSize = | `6xl` | `7xl` | `prose` - | `screen` -; + | `screen`; export type Theme_maxInlineSize = | `none` @@ -457,8 +441,7 @@ export type Theme_maxInlineSize = | `6xl` | `7xl` | `prose` - | `screen` -; + | `screen`; export type Theme_maxBlockSize = | `none` @@ -474,8 +457,7 @@ export type Theme_maxBlockSize = | `6xl` | `7xl` | `prose` - | `screen` -; + | `screen`; export type Theme_minInlineSize = | `none` @@ -491,8 +473,7 @@ export type Theme_minInlineSize = | `6xl` | `7xl` | `prose` - | `screen` -; + | `screen`; export type Theme_minBlockSize = | `none` @@ -508,14 +489,9 @@ export type Theme_minBlockSize = | `6xl` | `7xl` | `prose` - | `screen` -; + | `screen`; -export type Theme_fontFamily = - | `sans` - | `serif` - | `mono` -; +export type Theme_fontFamily = `sans` | `serif` | `mono`; export type Theme_fontSize = | `xs` @@ -530,8 +506,7 @@ export type Theme_fontSize = | `6xl` | `7xl` | `8xl` - | `9xl` -; + | `9xl`; export type Theme_fontWeight = | `thin` @@ -542,24 +517,11 @@ export type Theme_fontWeight = | `semibold` | `bold` | `extrabold` - | `black` -; + | `black`; -export type Theme_breakpoints = - | `sm` - | `md` - | `lg` - | `xl` - | `2xl` -; +export type Theme_breakpoints = `sm` | `md` | `lg` | `xl` | `2xl`; -export type Theme_verticalBreakpoints = - | `sm` - | `md` - | `lg` - | `xl` - | `2xl` -; +export type Theme_verticalBreakpoints = `sm` | `md` | `lg` | `xl` | `2xl`; export type Theme_borderRadius = | `DEFAULT` @@ -570,8 +532,7 @@ export type Theme_borderRadius = | `xl` | `2xl` | `3xl` - | `full` -; + | `full`; export type Theme_lineHeight = | `none` @@ -579,8 +540,7 @@ export type Theme_lineHeight = | `snug` | `normal` | `relaxed` - | `loose` -; + | `loose`; export type Theme_letterSpacing = | `tighter` @@ -588,8 +548,7 @@ export type Theme_letterSpacing = | `normal` | `wide` | `wider` - | `widest` -; + | `widest`; export type Theme_wordSpacing = | `tighter` @@ -597,8 +556,7 @@ export type Theme_wordSpacing = | `normal` | `wide` | `wider` - | `widest` -; + | `widest`; export type Theme_boxShadow = | `DEFAULT` @@ -608,8 +566,7 @@ export type Theme_boxShadow = | `lg` | `xl` | `2xl` - | `inner` -; + | `inner`; export type Theme_textIndent = | `DEFAULT` @@ -619,25 +576,11 @@ export type Theme_textIndent = | `lg` | `xl` | `2xl` - | `3xl` -; + | `3xl`; -export type Theme_textShadow = - | `DEFAULT` - | `none` - | `sm` - | `md` - | `lg` - | `xl` -; +export type Theme_textShadow = `DEFAULT` | `none` | `sm` | `md` | `lg` | `xl`; -export type Theme_textStrokeWidth = - | `DEFAULT` - | `none` - | `sm` - | `md` - | `lg` -; +export type Theme_textStrokeWidth = `DEFAULT` | `none` | `sm` | `md` | `lg`; export type Theme_blur = | `0` @@ -647,8 +590,7 @@ export type Theme_blur = | `lg` | `xl` | `2xl` - | `3xl` -; + | `3xl`; export type Theme_dropShadow = | `DEFAULT` @@ -657,21 +599,11 @@ export type Theme_dropShadow = | `lg` | `xl` | `2xl` - | `none` -; + | `none`; -export type Theme_easing = - | `DEFAULT` - | `linear` - | `in` - | `out` - | `in_out` -; +export type Theme_easing = `DEFAULT` | `linear` | `in` | `out` | `in_out`; -export type Theme_lineWidth = - | `DEFAULT` - | `none` -; +export type Theme_lineWidth = `DEFAULT` | `none`; export type Theme_spacing = | `DEFAULT` @@ -687,8 +619,7 @@ export type Theme_spacing = | `6xl` | `7xl` | `8xl` - | `9xl` -; + | `9xl`; export type Theme_duration = | `75` @@ -700,13 +631,9 @@ export type Theme_duration = | `700` | `1000` | `DEFAULT` - | `none` -; + | `none`; -export type Theme_ringWidth = - | `DEFAULT` - | `none` -; +export type Theme_ringWidth = `DEFAULT` | `none`; export type Theme_preflightBase = | `__un_rotate` @@ -758,8 +685,7 @@ export type Theme_preflightBase = | `__un_backdrop_invert` | `__un_backdrop_opacity` | `__un_backdrop_saturate` - | `__un_backdrop_sepia` -; + | `__un_backdrop_sepia`; export type Theme_containers = | `xs` @@ -773,12 +699,9 @@ export type Theme_containers = | `5xl` | `6xl` | `7xl` - | `prose` -; + | `prose`; -export type Theme_zIndex = - | `auto` -; +export type Theme_zIndex = `auto`; export type Theme_media = | `portrait` @@ -797,12 +720,9 @@ export type Theme_media = | `stylus` | `pointer` | `mouse` - | `hd_color` -; + | `hd_color`; -export type Theme_supports = - | `grid` -; +export type Theme_supports = `grid`; export type Autocomplete_num = | `0` @@ -816,8 +736,7 @@ export type Autocomplete_num = | `10` | `12` | `24` - | `36` -; + | `36`; export type Autocomplete_percent = | `0` @@ -830,8 +749,7 @@ export type Autocomplete_percent = | `70` | `80` | `90` - | `100` -; + | `100`; export type Autocomplete_percentage = | `10%` @@ -843,33 +761,23 @@ export type Autocomplete_percentage = | `70%` | `80%` | `90%` - | `100%` -; + | `100%`; -export type Autocomplete_directions = - | `x` - | `y` - | `t` - | `b` - | `l` - | `r` -; +export type Autocomplete_directions = `x` | `y` | `t` | `b` | `l` | `r`; export type Autocomplete_position = | `relative` | `absolute` | `fixed` | `sticky` - | `static` -; + | `static`; export type Autocomplete_globalKeyword = | `inherit` | `initial` | `revert` | `revert-layer` - | `unset` -; + | `unset`; export type RuleStatic = | `sr_only` @@ -1611,8 +1519,7 @@ export type RuleStatic = | `content_visibility_revert_layer` | `content_visibility_unset` | `content_empty` - | `content_none` -; + | `content_none`; export type RuleDynamic = | `i_ri_zzz_line` @@ -3903,14 +3810,31 @@ export type RuleDynamic = | `placeholder_opacity_${Autocomplete_percent}` | `placeholder_${Theme_colors}` | `intrinsic_size_${Autocomplete_num}` - | `transition_property_${"inherit" | "initial" | "revert" | "revert_layer" | "unset" | "all" | "colors" | "none" | "opacity" | "shadow" | "transform"}` + | `transition_property_${ + | "inherit" + | "initial" + | "revert" + | "revert_layer" + | "unset" + | "all" + | "colors" + | "none" + | "opacity" + | "shadow" + | "transform"}` | `transition_ease_${"linear" | "in" | "out" | "in_out" | "DEFAULT"}` | `ease_${"linear" | "in" | "out" | "in_out" | "DEFAULT"}` | `transition_delay_${Theme_duration}` | `delay_${Theme_duration}` | `transition_duration_${Theme_duration}` | `duration_${Theme_duration}` - | `transition_${"all" | "colors" | "none" | "opacity" | "shadow" | "transform"}` + | `transition_${ + | "all" + | "colors" + | "none" + | "opacity" + | "shadow" + | "transform"}` | `${"backdrop" | "filter"}_sepia` | `${"backdrop" | "filter"}_sepia_${Autocomplete_percent}` | `sepia_${Autocomplete_percent}` @@ -3992,11 +3916,38 @@ export type RuleDynamic = | `word_spacing_${Theme_wordSpacing}` | `tracking_${Theme_letterSpacing}` | `${"leading" | "lh" | "line_height"}_${Theme_lineHeight}` - | `${"font" | "fw"}_${"100" | "200" | "300" | "400" | "500" | "600" | "700" | "800" | "900"}` + | `${"font" | "fw"}_${ + | "100" + | "200" + | "300" + | "400" + | "500" + | "600" + | "700" + | "800" + | "900"}` | `${"font" | "fw"}_${Theme_fontWeight}` | `text_size_${Theme_fontSize}` | `text_${Theme_fontSize}` - | `${"vertical" | "align" | "v"}_${"mid" | "base" | "btm" | "baseline" | "top" | "start" | "middle" | "bottom" | "end" | "text_top" | "text_bottom" | "sub" | "super" | "inherit" | "initial" | "revert" | "revert_layer" | "unset"}` + | `${"vertical" | "align" | "v"}_${ + | "mid" + | "base" + | "btm" + | "baseline" + | "top" + | "start" + | "middle" + | "bottom" + | "end" + | "text_top" + | "text_bottom" + | "sub" + | "super" + | "inherit" + | "initial" + | "revert" + | "revert_layer" + | "unset"}` | `${"vertical" | "align" | "v"}_${Autocomplete_percentage}` | `indent_${Theme_textIndent}` | `${"m" | "p"}_${"bs" | "be" | "is" | "ie"}_${Autocomplete_num}` @@ -4005,7 +3956,51 @@ export type RuleDynamic = | `${"m" | "p"}_${"xy"}` | `${"m" | "p"}${Autocomplete_num}` | `${"m" | "p"}_${Autocomplete_num}` - | `object_${"top" | "top_center" | "top_left" | "top_right" | "bottom" | "bottom_center" | "bottom_left" | "bottom_right" | "left" | "left_center" | "left_top" | "left_bottom" | "right" | "right_center" | "right_top" | "right_bottom" | "center" | "center_top" | "center_bottom" | "center_left" | "center_right" | "center_center" | "t" | "tc" | "tl" | "tr" | "b" | "bc" | "bl" | "br" | "l" | "lc" | "lt" | "lb" | "r" | "rc" | "rt" | "rb" | "c" | "ct" | "cb" | "cl" | "cr" | "cc"}` + | `object_${ + | "top" + | "top_center" + | "top_left" + | "top_right" + | "bottom" + | "bottom_center" + | "bottom_left" + | "bottom_right" + | "left" + | "left_center" + | "left_top" + | "left_bottom" + | "right" + | "right_center" + | "right_top" + | "right_bottom" + | "center" + | "center_top" + | "center_bottom" + | "center_left" + | "center_right" + | "center_center" + | "t" + | "tc" + | "tl" + | "tr" + | "b" + | "bc" + | "bl" + | "br" + | "l" + | "lc" + | "lt" + | "lb" + | "r" + | "rc" + | "rt" + | "rb" + | "c" + | "ct" + | "cb" + | "cl" + | "cr" + | "cc"}` | `stroke_opacity_${Autocomplete_percent}` | `stroke_${Theme_colors}` | `stroke_offset_${Theme_lineWidth}` @@ -4015,9 +4010,109 @@ export type RuleDynamic = | `fill_opacity_${Autocomplete_percent}` | `fill_${Theme_colors}` | `bg_gradient_shape` - | `bg_gradient_shape_${"top" | "top_center" | "top_left" | "top_right" | "bottom" | "bottom_center" | "bottom_left" | "bottom_right" | "left" | "left_center" | "left_top" | "left_bottom" | "right" | "right_center" | "right_top" | "right_bottom" | "center" | "center_top" | "center_bottom" | "center_left" | "center_right" | "center_center" | "t" | "tc" | "tl" | "tr" | "b" | "bc" | "bl" | "br" | "l" | "lc" | "lt" | "lb" | "r" | "rc" | "rt" | "rb" | "c" | "ct" | "cb" | "cl" | "cr" | "cc"}` - | `shape_${"top" | "top_center" | "top_left" | "top_right" | "bottom" | "bottom_center" | "bottom_left" | "bottom_right" | "left" | "left_center" | "left_top" | "left_bottom" | "right" | "right_center" | "right_top" | "right_bottom" | "center" | "center_top" | "center_bottom" | "center_left" | "center_right" | "center_center" | "t" | "tc" | "tl" | "tr" | "b" | "bc" | "bl" | "br" | "l" | "lc" | "lt" | "lb" | "r" | "rc" | "rt" | "rb" | "c" | "ct" | "cb" | "cl" | "cr" | "cc"}` - | `bg_gradient_to_${"t" | "tl" | "tr" | "b" | "bl" | "br" | "l" | "lt" | "lb" | "r" | "rt" | "rb"}` + | `bg_gradient_shape_${ + | "top" + | "top_center" + | "top_left" + | "top_right" + | "bottom" + | "bottom_center" + | "bottom_left" + | "bottom_right" + | "left" + | "left_center" + | "left_top" + | "left_bottom" + | "right" + | "right_center" + | "right_top" + | "right_bottom" + | "center" + | "center_top" + | "center_bottom" + | "center_left" + | "center_right" + | "center_center" + | "t" + | "tc" + | "tl" + | "tr" + | "b" + | "bc" + | "bl" + | "br" + | "l" + | "lc" + | "lt" + | "lb" + | "r" + | "rc" + | "rt" + | "rb" + | "c" + | "ct" + | "cb" + | "cl" + | "cr" + | "cc"}` + | `shape_${ + | "top" + | "top_center" + | "top_left" + | "top_right" + | "bottom" + | "bottom_center" + | "bottom_left" + | "bottom_right" + | "left" + | "left_center" + | "left_top" + | "left_bottom" + | "right" + | "right_center" + | "right_top" + | "right_bottom" + | "center" + | "center_top" + | "center_bottom" + | "center_left" + | "center_right" + | "center_center" + | "t" + | "tc" + | "tl" + | "tr" + | "b" + | "bc" + | "bl" + | "br" + | "l" + | "lc" + | "lt" + | "lb" + | "r" + | "rc" + | "rt" + | "rb" + | "c" + | "ct" + | "cb" + | "cl" + | "cr" + | "cc"}` + | `bg_gradient_to_${ + | "t" + | "tl" + | "tr" + | "b" + | "bl" + | "br" + | "l" + | "lt" + | "lb" + | "r" + | "rt" + | "rb"}` | `bg_gradient_repeating` | `bg_gradient_${"linear" | "radial" | "conic"}` | `bg_gradient_repeating_${"linear" | "radial" | "conic"}` @@ -4029,11 +4124,71 @@ export type RuleDynamic = | `bg_opacity_${Autocomplete_percent}` | `bg_${Theme_colors}` | `border_style` - | `border_${"solid" | "dashed" | "dotted" | "double" | "hidden" | "none" | "groove" | "ridge" | "inset" | "outset" | "inherit" | "initial" | "revert" | "revert_layer" | "unset"}` + | `border_${ + | "solid" + | "dashed" + | "dotted" + | "double" + | "hidden" + | "none" + | "groove" + | "ridge" + | "inset" + | "outset" + | "inherit" + | "initial" + | "revert" + | "revert_layer" + | "unset"}` | `border_${Autocomplete_directions}_style` - | `border_${Autocomplete_directions}_${"solid" | "dashed" | "dotted" | "double" | "hidden" | "none" | "groove" | "ridge" | "inset" | "outset" | "inherit" | "initial" | "revert" | "revert_layer" | "unset"}` - | `border_${Autocomplete_directions}_style_${"solid" | "dashed" | "dotted" | "double" | "hidden" | "none" | "groove" | "ridge" | "inset" | "outset" | "inherit" | "initial" | "revert" | "revert_layer" | "unset"}` - | `border_style_${"solid" | "dashed" | "dotted" | "double" | "hidden" | "none" | "groove" | "ridge" | "inset" | "outset" | "inherit" | "initial" | "revert" | "revert_layer" | "unset"}` + | `border_${Autocomplete_directions}_${ + | "solid" + | "dashed" + | "dotted" + | "double" + | "hidden" + | "none" + | "groove" + | "ridge" + | "inset" + | "outset" + | "inherit" + | "initial" + | "revert" + | "revert_layer" + | "unset"}` + | `border_${Autocomplete_directions}_style_${ + | "solid" + | "dashed" + | "dotted" + | "double" + | "hidden" + | "none" + | "groove" + | "ridge" + | "inset" + | "outset" + | "inherit" + | "initial" + | "revert" + | "revert_layer" + | "unset"}` + | `border_style_${ + | "solid" + | "dashed" + | "dotted" + | "double" + | "hidden" + | "none" + | "groove" + | "ridge" + | "inset" + | "outset" + | "inherit" + | "initial" + | "revert" + | "revert_layer" + | "unset"}` | `border_${"rounded" | "rd"}` | `border_${"rounded" | "rd"}_${Autocomplete_num}` | `${"rounded" | "rd"}` @@ -4044,9 +4199,37 @@ export type RuleDynamic = | `border_${Autocomplete_num}` | `border_${Autocomplete_directions}_${Autocomplete_num}` | `border_${Autocomplete_directions}` - | `${"whitespace" | "ws"}_${"normal" | "nowrap" | "pre" | "pre_line" | "pre_wrap" | "break_spaces"}` - | `${"overflow" | "of"}_${"auto" | "hidden" | "clip" | "visible" | "scroll" | "overlay" | "inherit" | "initial" | "revert" | "revert_layer" | "unset"}` - | `${"overflow" | "of"}_${"x" | "y"}_${"auto" | "hidden" | "clip" | "visible" | "scroll" | "overlay" | "inherit" | "initial" | "revert" | "revert_layer" | "unset"}` + | `${"whitespace" | "ws"}_${ + | "normal" + | "nowrap" + | "pre" + | "pre_line" + | "pre_wrap" + | "break_spaces"}` + | `${"overflow" | "of"}_${ + | "auto" + | "hidden" + | "clip" + | "visible" + | "scroll" + | "overlay" + | "inherit" + | "initial" + | "revert" + | "revert_layer" + | "unset"}` + | `${"overflow" | "of"}_${"x" | "y"}_${ + | "auto" + | "hidden" + | "clip" + | "visible" + | "scroll" + | "overlay" + | "inherit" + | "initial" + | "revert" + | "revert_layer" + | "unset"}` | `divide_opacity` | `divide_opacity_${Autocomplete_percent}` | `divide_${Theme_colors}` @@ -4061,26 +4244,120 @@ export type RuleDynamic = | `gap_${Theme_spacing}` | `gap_${Autocomplete_num}` | `columns_${Autocomplete_num}` - | `list_${"disc" | "circle" | "square" | "decimal" | "zero_decimal" | "greek" | "roman" | "upper_roman" | "alpha" | "upper_alpha" | "latin" | "upper_latin"}` - | `list_${"disc" | "circle" | "square" | "decimal" | "zero_decimal" | "greek" | "roman" | "upper_roman" | "alpha" | "upper_alpha" | "latin" | "upper_latin"}_${"outside" | "inside"}` + | `list_${ + | "disc" + | "circle" + | "square" + | "decimal" + | "zero_decimal" + | "greek" + | "roman" + | "upper_roman" + | "alpha" + | "upper_alpha" + | "latin" + | "upper_latin"}` + | `list_${ + | "disc" + | "circle" + | "square" + | "decimal" + | "zero_decimal" + | "greek" + | "roman" + | "upper_roman" + | "alpha" + | "upper_alpha" + | "latin" + | "upper_latin"}_${"outside" | "inside"}` | `scroll_${"m" | "p" | "ma" | "pa" | "block" | "inline"}` | `scroll_${"m" | "p" | "ma" | "pa" | "block" | "inline"}_${Theme_spacing}` - | `scroll_${"m" | "p" | "ma" | "pa" | "block" | "inline"}_${"x" | "y" | "r" | "l" | "t" | "b" | "bs" | "be" | "is" | "ie"}` - | `scroll_${"m" | "p" | "ma" | "pa" | "block" | "inline"}_${"x" | "y" | "r" | "l" | "t" | "b" | "bs" | "be" | "is" | "ie"}_${Theme_spacing}` + | `scroll_${"m" | "p" | "ma" | "pa" | "block" | "inline"}_${ + | "x" + | "y" + | "r" + | "l" + | "t" + | "b" + | "bs" + | "be" + | "is" + | "ie"}` + | `scroll_${"m" | "p" | "ma" | "pa" | "block" | "inline"}_${ + | "x" + | "y" + | "r" + | "l" + | "t" + | "b" + | "bs" + | "be" + | "is" + | "ie"}_${Theme_spacing}` | `snap_${"x" | "y" | "both"}` | `touch_pan` | `touch_pan_${"x" | "left" | "right" | "y" | "up" | "down"}` | `animate_${"play" | "state" | "play_state"}` - | `animate_${"play" | "state" | "play_state"}_${"paused" | "running" | "inherit" | "initial" | "revert" | "revert_layer" | "unset"}` - | `animate_${"paused" | "running" | "inherit" | "initial" | "revert" | "revert_layer" | "unset"}` + | `animate_${"play" | "state" | "play_state"}_${ + | "paused" + | "running" + | "inherit" + | "initial" + | "revert" + | "revert_layer" + | "unset"}` + | `animate_${ + | "paused" + | "running" + | "inherit" + | "initial" + | "revert" + | "revert_layer" + | "unset"}` | `animate_${"iteration" | "count" | "iteration_count"}` | `animate_${"iteration" | "count" | "iteration_count"}_${Autocomplete_num}` | `animate_direction` - | `animate_direction_${"normal" | "reverse" | "alternate" | "alternate_reverse" | "inherit" | "initial" | "revert" | "revert_layer" | "unset"}` - | `animate_${"normal" | "reverse" | "alternate" | "alternate_reverse" | "inherit" | "initial" | "revert" | "revert_layer" | "unset"}` + | `animate_direction_${ + | "normal" + | "reverse" + | "alternate" + | "alternate_reverse" + | "inherit" + | "initial" + | "revert" + | "revert_layer" + | "unset"}` + | `animate_${ + | "normal" + | "reverse" + | "alternate" + | "alternate_reverse" + | "inherit" + | "initial" + | "revert" + | "revert_layer" + | "unset"}` | `animate_${"fill" | "mode" | "fill_mode"}` - | `animate_${"fill" | "mode" | "fill_mode"}_${"none" | "forwards" | "backwards" | "both" | "inherit" | "initial" | "revert" | "revert_layer" | "unset"}` - | `animate_${"none" | "forwards" | "backwards" | "both" | "inherit" | "initial" | "revert" | "revert_layer" | "unset"}` + | `animate_${"fill" | "mode" | "fill_mode"}_${ + | "none" + | "forwards" + | "backwards" + | "both" + | "inherit" + | "initial" + | "revert" + | "revert_layer" + | "unset"}` + | `animate_${ + | "none" + | "forwards" + | "backwards" + | "both" + | "inherit" + | "initial" + | "revert" + | "revert_layer" + | "unset"}` | `animate_ease` | `animate_ease_${Theme_easing}` | `animate_delay` @@ -4091,10 +4368,101 @@ export type RuleDynamic = | `animate_keyframes_${Theme_animation_keyframes}` | `keyframes_${Theme_animation_keyframes}` | `transform_${"translate" | "rotate" | "scale"}_${Autocomplete_percent}` - | `transform_${"translate" | "rotate" | "scale"}_${"x" | "y" | "z"}_${Autocomplete_percent}` + | `transform_${"translate" | "rotate" | "scale"}_${ + | "x" + | "y" + | "z"}_${Autocomplete_percent}` | `transform_skew_${"x" | "y"}_${Autocomplete_percent}` - | `transform_origin_${"top" | "top_center" | "top_left" | "top_right" | "bottom" | "bottom_center" | "bottom_left" | "bottom_right" | "left" | "left_center" | "left_top" | "left_bottom" | "right" | "right_center" | "right_top" | "right_bottom" | "center" | "center_top" | "center_bottom" | "center_left" | "center_right" | "center_center" | "t" | "tc" | "tl" | "tr" | "b" | "bc" | "bl" | "br" | "l" | "lc" | "lt" | "lb" | "r" | "rc" | "rt" | "rb" | "c" | "ct" | "cb" | "cl" | "cr" | "cc"}` - | `origin_${"top" | "top_center" | "top_left" | "top_right" | "bottom" | "bottom_center" | "bottom_left" | "bottom_right" | "left" | "left_center" | "left_top" | "left_bottom" | "right" | "right_center" | "right_top" | "right_bottom" | "center" | "center_top" | "center_bottom" | "center_left" | "center_right" | "center_center" | "t" | "tc" | "tl" | "tr" | "b" | "bc" | "bl" | "br" | "l" | "lc" | "lt" | "lb" | "r" | "rc" | "rt" | "rb" | "c" | "ct" | "cb" | "cl" | "cr" | "cc"}` + | `transform_origin_${ + | "top" + | "top_center" + | "top_left" + | "top_right" + | "bottom" + | "bottom_center" + | "bottom_left" + | "bottom_right" + | "left" + | "left_center" + | "left_top" + | "left_bottom" + | "right" + | "right_center" + | "right_top" + | "right_bottom" + | "center" + | "center_top" + | "center_bottom" + | "center_left" + | "center_right" + | "center_center" + | "t" + | "tc" + | "tl" + | "tr" + | "b" + | "bc" + | "bl" + | "br" + | "l" + | "lc" + | "lt" + | "lb" + | "r" + | "rc" + | "rt" + | "rb" + | "c" + | "ct" + | "cb" + | "cl" + | "cr" + | "cc"}` + | `origin_${ + | "top" + | "top_center" + | "top_left" + | "top_right" + | "bottom" + | "bottom_center" + | "bottom_left" + | "bottom_right" + | "left" + | "left_center" + | "left_top" + | "left_bottom" + | "right" + | "right_center" + | "right_top" + | "right_bottom" + | "center" + | "center_top" + | "center_bottom" + | "center_left" + | "center_right" + | "center_center" + | "t" + | "tc" + | "tl" + | "tr" + | "b" + | "bc" + | "bl" + | "br" + | "l" + | "lc" + | "lt" + | "lb" + | "r" + | "rc" + | "rt" + | "rb" + | "c" + | "ct" + | "cb" + | "cl" + | "cr" + | "cc"}` | `border_spacing_${"x" | "y"}` | `border_spacing_${"x" | "y"}_${Theme_spacing}` | `border_spacing` @@ -4121,7 +4489,12 @@ export type RuleDynamic = | `aspect_ratio_${"square" | "video"}` | `grid_${"rows" | "cols"}_${Autocomplete_num}` | `grid_${"rows" | "cols"}_none` - | `${"grid_auto_flow" | "auto_flow" | "grid_flow"}_${"row" | "col" | "dense" | "row_dense" | "col_dense"}` + | `${"grid_auto_flow" | "auto_flow" | "grid_flow"}_${ + | "row" + | "col" + | "dense" + | "row_dense" + | "col_dense"}` | `grid_auto_${"rows" | "cols"}_${Autocomplete_num}` | `grid_${"row" | "col"}_${"start" | "end"}_${Autocomplete_num}` | `grid_${"row" | "col"}_span_${Autocomplete_num}` @@ -4132,17 +4505,105 @@ export type RuleDynamic = | `${"position" | "pos"}_inset_${Autocomplete_directions}_${Theme_spacing}` | `${"position" | "pos"}_inset_${"block" | "inline"}_${Theme_spacing}` | `${"position" | "pos"}_inset_${"bs" | "be" | "is" | "ie"}_${Theme_spacing}` - | `${"position" | "pos"}_${"top" | "left" | "right" | "bottom"}_${Theme_spacing}` + | `${"position" | "pos"}_${ + | "top" + | "left" + | "right" + | "bottom"}_${Theme_spacing}` | `${"position" | "pos"}_${Autocomplete_position}` | `${"position" | "pos"}_${Autocomplete_globalKeyword}` - | `${Autocomplete_position}` -; + | `${Autocomplete_position}`; export type Variant = | `print` | `${"at_" | "lt_" | "max_" | ""}${Theme_breakpoints}` - | `${"placeholder_shown" | "backdrop_element" | "indeterminate" | "focus_visible" | "first_of_type" | "first_letter" | "out_of_range" | "focus_within" | "even_of_type" | "last_of_type" | "only_of_type" | "odd_of_type" | "placeholder" | "first_line" | "read_write" | "only_child" | "read_only" | "selection" | "any_link" | "autofill" | "optional" | "required" | "in_range" | "disabled" | "visited" | "default" | "checked" | "invalid" | "enabled" | "target" | "active" | "before" | "marker" | "valid" | "empty" | "hover" | "focus" | "first" | "after" | "link" | "open" | "root" | "even" | "last" | "file" | "odd" | "backdrop"}` - | `${"not" | "is" | "where" | "has"}_${"placeholder_shown" | "indeterminate" | "focus_visible" | "first_of_type" | "out_of_range" | "focus_within" | "even_of_type" | "last_of_type" | "only_of_type" | "odd_of_type" | "read_write" | "only_child" | "read_only" | "any_link" | "autofill" | "optional" | "required" | "in_range" | "disabled" | "visited" | "default" | "checked" | "invalid" | "enabled" | "target" | "active" | "valid" | "empty" | "hover" | "focus" | "first" | "link" | "open" | "root" | "even" | "last" | "odd" | ""}` + | `${ + | "placeholder_shown" + | "backdrop_element" + | "indeterminate" + | "focus_visible" + | "first_of_type" + | "first_letter" + | "out_of_range" + | "focus_within" + | "even_of_type" + | "last_of_type" + | "only_of_type" + | "odd_of_type" + | "placeholder" + | "first_line" + | "read_write" + | "only_child" + | "read_only" + | "selection" + | "any_link" + | "autofill" + | "optional" + | "required" + | "in_range" + | "disabled" + | "visited" + | "default" + | "checked" + | "invalid" + | "enabled" + | "target" + | "active" + | "before" + | "marker" + | "valid" + | "empty" + | "hover" + | "focus" + | "first" + | "after" + | "link" + | "open" + | "root" + | "even" + | "last" + | "file" + | "odd" + | "backdrop"}` + | `${"not" | "is" | "where" | "has"}_${ + | "placeholder_shown" + | "indeterminate" + | "focus_visible" + | "first_of_type" + | "out_of_range" + | "focus_within" + | "even_of_type" + | "last_of_type" + | "only_of_type" + | "odd_of_type" + | "read_write" + | "only_child" + | "read_only" + | "any_link" + | "autofill" + | "optional" + | "required" + | "in_range" + | "disabled" + | "visited" + | "default" + | "checked" + | "invalid" + | "enabled" + | "target" + | "active" + | "valid" + | "empty" + | "hover" + | "focus" + | "first" + | "link" + | "open" + | "root" + | "even" + | "last" + | "odd" + | ""}` | `dark` | `light` | `rtl` @@ -4161,8 +4622,7 @@ export type Variant = | `hover` | `important` | `aria_${Theme_aria}` - | `media_${Theme_media}` -; + | `media_${Theme_media}`; export type Shortcut = | `antd_menu_item_active` @@ -4178,5 +4638,4 @@ export type Shortcut = | `antd_btn` | `antd_link` | `antd_floating` - | `antd_spin` -; + | `antd_spin`; diff --git a/packages/lib/package.json b/packages/lib/package.json index 25993ce8..1aabd590 100644 --- a/packages/lib/package.json +++ b/packages/lib/package.json @@ -27,8 +27,8 @@ "build": "pnpm run --seq /^build:/", "build:theme": "tsx ./src/build-theme.ts > ./src/theme.ts", "build:tsup": "tsup", - "generate-tw": "unocss-typescript-dsl --outDir src/tw", - "generate-tw-test": "unocss-typescript-dsl --stdout | diff src/tw/types.ts -", + "generate-tw": "unocss-ts generate --outFile src/tw-types.d.ts", + "generate-tw-test": "unocss-ts generate | diff src/tw-types.d.ts -", "release": "pnpm publish --no-git-checks --access public" }, "devDependencies": { diff --git a/packages/lib/src/index.ts b/packages/lib/src/index.ts index 8ee3bb7c..3d1dbf8c 100644 --- a/packages/lib/src/index.ts +++ b/packages/lib/src/index.ts @@ -1,8 +1,8 @@ +import { tw } from "@hiogawa/unocss-ts"; import { objectEntries, objectMapValues, objectPickBy } from "@hiogawa/utils"; import type { Preset } from "unocss"; import { name as packageName } from "../package.json"; import { theme } from "./theme"; -import { tw } from "./tw"; // typed css variable name helper // ANTD_VARS.colorText => "var(--antd-colorText)" diff --git a/packages/lib/src/tw/types.ts b/packages/lib/src/tw-types.d.ts similarity index 99% rename from packages/lib/src/tw/types.ts rename to packages/lib/src/tw-types.d.ts index ed5a07fa..7625327b 100644 --- a/packages/lib/src/tw/types.ts +++ b/packages/lib/src/tw-types.d.ts @@ -2,6 +2,12 @@ // AUTO-GENERATED // +import "@hiogawa/unocss-ts"; + +declare module "@hiogawa/unocss-ts" { + interface RuntimeType extends Api {} +} + type Property = RuleStatic | RuleDynamic | Shortcut; type Method = Variant; @@ -25,7 +31,7 @@ type ApiToString = { $: string; }; -export type Api = ApiProperty & ApiMethod & ApiCustom & ApiToString; +type Api = ApiProperty & ApiMethod & ApiCustom & ApiToString; // @@ -1614,9 +1620,6 @@ export type RuleStatic = ; export type RuleDynamic = - | `rounded_full` - | `opacity_${Autocomplete_percent}` - | `ring_${Autocomplete_num}` | `fixed` | `relative` | `absolute` @@ -1628,6 +1631,7 @@ export type RuleDynamic = | `${"max_" | "min_" | ""}${"w" | "h"}_full` | `transition` | `border` + | `bg_${Theme_colors}` | `placeholder_opacity` | `placeholder_opacity_${Autocomplete_percent}` | `placeholder_${Theme_colors}` @@ -1891,7 +1895,6 @@ export type Variant = | `important` | `aria_${Theme_aria}` | `media_${Theme_media}` - | `media_${Theme_media}` ; export type Shortcut = diff --git a/packages/lib/src/tw/index.ts b/packages/lib/src/tw/index.ts deleted file mode 100644 index 97697fa2..00000000 --- a/packages/lib/src/tw/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { createRuntime } from "@hiogawa/unocss-typescript-dsl/dist/runtime"; -import type { Api } from "./types"; - -export const tw = createRuntime() as Api; diff --git a/packages/lib/uno.config.ts b/packages/lib/uno.config.ts index 8df73f84..2b8820e3 100644 --- a/packages/lib/uno.config.ts +++ b/packages/lib/uno.config.ts @@ -1,11 +1,4 @@ -// used to generate tw-api.ts - -import { - dummyPreset, - dummyRule, - dummyVariant, - filterColorPallete, -} from "@hiogawa/unocss-typescript-dsl"; +import { filterColorPallete, presetFixAutocomplete } from "@hiogawa/unocss-ts"; import { defineConfig, presetUno, @@ -15,12 +8,10 @@ import { import { unocssPresetAntd } from "./src"; export default defineConfig({ - presets: [filterColorPallete(presetUno()), unocssPresetAntd(), dummyPreset()], - rules: [ - dummyRule("ring-"), - dummyRule("opacity-"), - dummyRule("rounded-full"), + presets: [ + filterColorPallete(presetUno()), + unocssPresetAntd(), + presetFixAutocomplete(), ], - variants: [dummyVariant("media-$media")], transformers: [transformerDirectives(), transformerVariantGroup()], }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 92b223c8..dfb21b6d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,4 +1,4 @@ -lockfileVersion: '6.1' +lockfileVersion: '6.0' settings: autoInstallPeers: true @@ -26,6 +26,9 @@ importers: '@hiogawa/tiny-refresh': specifier: 0.0.1-pre.11 version: 0.0.1-pre.11(react@18.2.0)(vite@4.4.9) + '@hiogawa/unocss-ts': + specifier: 0.0.1-pre.0 + version: 0.0.1-pre.0(@unocss/config@0.55.7)(unocss@0.55.7) '@hiogawa/unocss-typescript-dsl': specifier: 2.0.0-pre.8 version: 2.0.0-pre.8(@iconify/utils@2.1.9)(@unocss/config@0.55.7)(@unocss/core@0.55.7)(local-pkg@0.4.3)(magic-string@0.30.3) @@ -1380,6 +1383,17 @@ packages: react: 18.2.0 dev: false + /@hiogawa/unocss-ts@0.0.1-pre.0(@unocss/config@0.55.7)(unocss@0.55.7): + resolution: {integrity: sha512-L7s0E8ZLItWrGN4gtNydqj/SnLxR6oPSZxotjFadKKTtPyJa+PhZELLGoVGkhxBQvW1c/OanNi2IgedDIf3YPA==} + hasBin: true + peerDependencies: + '@unocss/config': '*' + unocss: '*' + dependencies: + '@unocss/config': 0.55.7 + unocss: 0.55.7(postcss@8.4.29)(vite@4.4.9) + dev: true + /@hiogawa/unocss-typescript-dsl@2.0.0-pre.8(@iconify/utils@2.1.9)(@unocss/config@0.55.7)(@unocss/core@0.55.7)(local-pkg@0.4.3)(magic-string@0.30.3): resolution: {integrity: sha512-AY2JT6opqjjuW6/bmhO9EijVxUxsUl3kLDtrRkM4sKR67jU9mzv16W1gDp5Frh5m2k+ewgBJOOhKK6lTXyjn4Q==} hasBin: true