@stacksjs/ts-css 0.1.4 → 0.3.2
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/ENGINE.md +677 -0
- package/PLUGIN.md +217 -0
- package/dist/bin/cli.js +29 -38
- package/dist/bin/cssx.js +405 -0
- package/dist/chunk-0h48763m.js +2 -0
- package/dist/chunk-br9jax0b.js +2 -0
- package/dist/chunk-f9gzb0a5.js +3 -0
- package/dist/chunk-genwkevp.js +3 -0
- package/dist/chunk-jj3s4ctf.js +62 -0
- package/dist/chunk-mz87cw2e.js +2 -0
- package/dist/engine/build.d.ts +26 -0
- package/dist/engine/color-modifier.d.ts +8 -0
- package/dist/engine/config.d.ts +5 -0
- package/dist/engine/format.d.ts +20 -0
- package/dist/engine/generator.d.ts +14 -0
- package/dist/engine/index.d.ts +13 -0
- package/dist/engine/index.js +653 -0
- package/dist/engine/parser.d.ts +68 -0
- package/dist/engine/plugin.d.ts +22 -0
- package/dist/engine/preflight-forms.d.ts +6 -0
- package/dist/engine/preflight.d.ts +3 -0
- package/dist/engine/rules-advanced.d.ts +27 -0
- package/dist/engine/rules-effects.d.ts +35 -0
- package/dist/engine/rules-forms.d.ts +8 -0
- package/dist/engine/rules-grid.d.ts +13 -0
- package/dist/engine/rules-icons.d.ts +2 -0
- package/dist/engine/rules-interactivity.d.ts +41 -0
- package/dist/engine/rules-layout.d.ts +28 -0
- package/dist/engine/rules-transforms.d.ts +35 -0
- package/dist/engine/rules-typography.d.ts +47 -0
- package/dist/engine/rules.d.ts +56 -0
- package/dist/engine/scanner.d.ts +16 -0
- package/dist/engine/style/api.d.ts +95 -0
- package/dist/engine/style/collect.d.ts +10 -0
- package/dist/engine/style/evaluate.d.ts +11 -0
- package/dist/engine/style/hash.d.ts +15 -0
- package/dist/engine/style/index.d.ts +56 -0
- package/dist/engine/style/plugin.d.ts +27 -0
- package/dist/engine/style/priority.d.ts +12 -0
- package/dist/engine/style/registry.d.ts +56 -0
- package/dist/engine/style/types.d.ts +54 -0
- package/dist/engine/style/value.d.ts +15 -0
- package/dist/engine/transformer-compile-class.d.ts +34 -0
- package/dist/engine/types.d.ts +156 -0
- package/dist/index.js +1 -60
- package/dist/optimize/index.js +1 -1
- package/dist/parse/index.js +1 -1
- package/dist/parse/list.d.ts +1 -1
- package/dist/select/index.js +1 -1
- package/dist/what/index.js +1 -1
- package/package.json +35 -19
- package/dist/chunk-1kmkypmr.js +0 -3
- package/dist/chunk-2wsah70r.js +0 -2
- package/dist/chunk-9ep6bwwb.js +0 -2
- package/dist/chunk-edwg811g.js +0 -2
- package/dist/chunk-thy3p95k.js +0 -3
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { AttributifyConfig, BracketSyntaxConfig, ParsedClass } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Drop the module-level parse caches. Exposed for long-lived hosts that want
|
|
4
|
+
* to reclaim the memory between builds; correctness never depends on it.
|
|
5
|
+
*/
|
|
6
|
+
export declare function clearParseCaches(): void;
|
|
7
|
+
/**
|
|
8
|
+
* Expand bracket/grouped syntax into individual class names
|
|
9
|
+
* e.g., flex[col jc-center ai-center] -> ['flex-col', 'justify-center', 'items-center']
|
|
10
|
+
* e.g., text[white 2rem 700] -> ['text-white', 'text-[2rem]', 'font-bold']
|
|
11
|
+
* e.g., h[min 100vh] -> ['min-h-[100vh]']
|
|
12
|
+
* e.g., hover:flex[col] -> ['hover:flex-col']
|
|
13
|
+
* e.g., flex[md:col lg:row] -> ['md:flex-col', 'lg:flex-row']
|
|
14
|
+
* e.g., -m[4] or m[-4] -> ['-m-4']
|
|
15
|
+
*/
|
|
16
|
+
export declare function expandBracketSyntax(className: string, config?: BracketSyntaxConfig): string[];
|
|
17
|
+
/**
|
|
18
|
+
* Extract classes from attributify syntax
|
|
19
|
+
* e.g., <div tc-flex tc-items-center tc-bg="blue-500" tc-p="4">
|
|
20
|
+
* Returns classes like: flex, items-center, bg-blue-500, p-4
|
|
21
|
+
*
|
|
22
|
+
* Also supports variant attributes:
|
|
23
|
+
* e.g., <div tc-hover:bg="blue-600" tc-dark:text="white">
|
|
24
|
+
* Returns classes like: hover:bg-blue-600, dark:text-white
|
|
25
|
+
*/
|
|
26
|
+
export declare function extractAttributifyClasses(content: string, config?: AttributifyConfig): Set<string>;
|
|
27
|
+
/**
|
|
28
|
+
* Parses a utility class string into its components
|
|
29
|
+
* Examples: "p-4" -> {raw: "p-4", variants: [], utility: "p", value: "4", important: false, arbitrary: false}
|
|
30
|
+
* "hover:bg-blue-500" -> {raw: "hover:bg-blue-500", variants: ["hover"], utility: "bg", value: "blue-500", important: false, arbitrary: false}
|
|
31
|
+
* "!p-4" -> {raw: "!p-4", variants: [], utility: "p", value: "4", important: true, arbitrary: false}
|
|
32
|
+
* "w-[100px]" -> {raw: "w-[100px]", variants: [], utility: "w", value: "100px", important: false, arbitrary: true}
|
|
33
|
+
*/
|
|
34
|
+
export declare function parseClass(className: string): ParsedClass;
|
|
35
|
+
/**
|
|
36
|
+
* Extracts all utility classes from content
|
|
37
|
+
* Matches class patterns in HTML/JSX attributes and template strings
|
|
38
|
+
* Supports bracket syntax (e.g., flex[col jc-center]) and attributify mode
|
|
39
|
+
*/
|
|
40
|
+
export declare function extractClasses(content: string, options?: ExtractClassesOptions): Set<string>;
|
|
41
|
+
/**
|
|
42
|
+
* Options for class extraction
|
|
43
|
+
*/
|
|
44
|
+
export declare interface ExtractClassesOptions {
|
|
45
|
+
attributify?: AttributifyConfig
|
|
46
|
+
bracketSyntax?: BracketSyntaxConfig
|
|
47
|
+
codeStrings?: CodeStringsConfig
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Extraction from string literals in code, not just from class attributes.
|
|
51
|
+
*
|
|
52
|
+
* Utility classes routinely live in code rather than in markup: a helper that
|
|
53
|
+
* returns a class string, a lookup table of icons keyed by status, a signal
|
|
54
|
+
* holding the current variant. Attribute-scoped extraction cannot see any of
|
|
55
|
+
* it, so those classes silently never generate and the element renders
|
|
56
|
+
* unstyled — with no error, because nothing went wrong as far as the build is
|
|
57
|
+
* concerned.
|
|
58
|
+
*
|
|
59
|
+
* The failure is quiet enough that projects tend to work around it instead of
|
|
60
|
+
* reporting it: pre-generating a whole icon stylesheet, restating class names
|
|
61
|
+
* in a dummy attribute, or moving state into `data-` attributes and styling
|
|
62
|
+
* those instead. All of that goes away if the scanner reads the strings.
|
|
63
|
+
*
|
|
64
|
+
* Only *compound* tokens are taken from code — see `isCodeStringCandidate`.
|
|
65
|
+
*/
|
|
66
|
+
export declare interface CodeStringsConfig {
|
|
67
|
+
enabled?: boolean
|
|
68
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { BunPlugin } from 'bun';
|
|
2
|
+
import type { CssOptions } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Crosswind Bun plugin for processing HTML files
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { plugin } from '@ts-css/core'
|
|
9
|
+
*
|
|
10
|
+
* await Bun.build({
|
|
11
|
+
* entrypoints: ['./src/index.ts'],
|
|
12
|
+
* outdir: './dist',
|
|
13
|
+
* plugins: [plugin()],
|
|
14
|
+
* })
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare function plugin(options?: CssPluginOptions): BunPlugin;
|
|
18
|
+
export declare interface CssPluginOptions {
|
|
19
|
+
config?: CssOptions
|
|
20
|
+
includePreflight?: boolean
|
|
21
|
+
}
|
|
22
|
+
export default plugin;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { UtilityRule } from './rules';
|
|
2
|
+
// Min/Max sizing
|
|
3
|
+
export declare const minMaxSizingRule: UtilityRule;
|
|
4
|
+
// Ring utilities
|
|
5
|
+
export declare const ringRule: UtilityRule;
|
|
6
|
+
// Border opacity utility
|
|
7
|
+
export declare const borderOpacityRule: UtilityRule;
|
|
8
|
+
// Space utilities (child spacing)
|
|
9
|
+
export declare const spaceRule: UtilityRule;
|
|
10
|
+
// Border style utilities
|
|
11
|
+
export declare const borderStyleRule: UtilityRule;
|
|
12
|
+
// Divide utilities (borders between children)
|
|
13
|
+
export declare const divideRule: UtilityRule;
|
|
14
|
+
// Gradient color stops
|
|
15
|
+
export declare const gradientStopsRule: UtilityRule;
|
|
16
|
+
// Flex order
|
|
17
|
+
export declare const flexOrderRule: UtilityRule;
|
|
18
|
+
// Flex basis
|
|
19
|
+
export declare const flexBasisRule: UtilityRule;
|
|
20
|
+
// Justify/Align self
|
|
21
|
+
export declare const justifySelfRule: UtilityRule;
|
|
22
|
+
export declare const alignSelfRule: UtilityRule;
|
|
23
|
+
// Container utility with responsive max-widths
|
|
24
|
+
export declare const containerRule: UtilityRule;
|
|
25
|
+
// Arbitrary properties
|
|
26
|
+
export declare const arbitraryPropertyRule: UtilityRule;
|
|
27
|
+
export declare const advancedRules: UtilityRule[];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { UtilityRule } from './rules';
|
|
2
|
+
// =============================================================================
|
|
3
|
+
// Backgrounds, Borders, Effects utilities
|
|
4
|
+
// =============================================================================
|
|
5
|
+
// Background utilities
|
|
6
|
+
export declare const backgroundAttachmentRule: UtilityRule;
|
|
7
|
+
export declare const backgroundClipRule: UtilityRule;
|
|
8
|
+
/**
|
|
9
|
+
* Linear gradients. `bg-linear-*` is Tailwind v4's name for `bg-gradient-*`;
|
|
10
|
+
* both spellings are accepted so v3 markup keeps working.
|
|
11
|
+
*
|
|
12
|
+
* Three shapes reach here with different parses:
|
|
13
|
+
* bg-linear-to-r utility `bg`, value `linear-to-r`
|
|
14
|
+
* -bg-linear-45 utility `bg`, value `-linear-45`
|
|
15
|
+
* bg-linear-[0.25turn] utility `bg-linear`, value `0.25turn` (arbitrary)
|
|
16
|
+
*/
|
|
17
|
+
export declare const backgroundImageRule: UtilityRule;
|
|
18
|
+
export declare const backgroundOriginRule: UtilityRule;
|
|
19
|
+
export declare const backgroundPositionRule: UtilityRule;
|
|
20
|
+
export declare const backgroundRepeatRule: UtilityRule;
|
|
21
|
+
export declare const backgroundSizeRule: UtilityRule;
|
|
22
|
+
// Border utilities
|
|
23
|
+
export declare const borderStyleRule: UtilityRule;
|
|
24
|
+
export declare const outlineRule: UtilityRule;
|
|
25
|
+
// Effect utilities
|
|
26
|
+
export declare const boxShadowThemeRule: UtilityRule;
|
|
27
|
+
// Shadow color utilities (shadow-{color}, shadow-{color}/{opacity})
|
|
28
|
+
export declare const shadowColorRule: UtilityRule;
|
|
29
|
+
export declare const textShadowRule: UtilityRule;
|
|
30
|
+
export declare const opacityRule: UtilityRule;
|
|
31
|
+
export declare const mixBlendModeRule: UtilityRule;
|
|
32
|
+
export declare const backgroundBlendModeRule: UtilityRule;
|
|
33
|
+
// Mask utilities
|
|
34
|
+
export declare const maskRule: UtilityRule;
|
|
35
|
+
export declare const effectsRules: UtilityRule[];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { UtilityRule } from './rules';
|
|
2
|
+
export declare const formInputRule: UtilityRule;
|
|
3
|
+
export declare const formTextareaRule: UtilityRule;
|
|
4
|
+
export declare const formSelectRule: UtilityRule;
|
|
5
|
+
export declare const formMultiselectRule: UtilityRule;
|
|
6
|
+
export declare const formCheckboxRule: UtilityRule;
|
|
7
|
+
export declare const formRadioRule: UtilityRule;
|
|
8
|
+
export declare const formsRules: UtilityRule[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { UtilityRule } from './rules';
|
|
2
|
+
export declare const gridTemplateColumnsRule: UtilityRule;
|
|
3
|
+
export declare const gridColumnRule: UtilityRule;
|
|
4
|
+
export declare const gridTemplateRowsRule: UtilityRule;
|
|
5
|
+
export declare const gridRowRule: UtilityRule;
|
|
6
|
+
export declare const gridAutoFlowRule: UtilityRule;
|
|
7
|
+
export declare const gridAutoColumnsRule: UtilityRule;
|
|
8
|
+
export declare const gridAutoRowsRule: UtilityRule;
|
|
9
|
+
export declare const gapRule: UtilityRule;
|
|
10
|
+
export declare const placeContentRule: UtilityRule;
|
|
11
|
+
export declare const placeItemsRule: UtilityRule;
|
|
12
|
+
export declare const placeSelfRule: UtilityRule;
|
|
13
|
+
export declare const gridRules: UtilityRule[];
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { UtilityRule } from './rules';
|
|
2
|
+
// Filter utilities
|
|
3
|
+
export declare const filterRule: UtilityRule;
|
|
4
|
+
export declare const backdropFilterRule: UtilityRule;
|
|
5
|
+
// Table utilities
|
|
6
|
+
export declare const borderCollapseRule: UtilityRule;
|
|
7
|
+
export declare const borderSpacingRule: UtilityRule;
|
|
8
|
+
export declare const tableLayoutRule: UtilityRule;
|
|
9
|
+
export declare const captionSideRule: UtilityRule;
|
|
10
|
+
// Interactivity utilities
|
|
11
|
+
export declare const accentColorRule: UtilityRule;
|
|
12
|
+
export declare const appearanceRule: UtilityRule;
|
|
13
|
+
export declare const caretColorRule: UtilityRule;
|
|
14
|
+
export declare const colorSchemeRule: UtilityRule;
|
|
15
|
+
export declare const fieldSizingRule: UtilityRule;
|
|
16
|
+
export declare const cursorRule: UtilityRule;
|
|
17
|
+
export declare const pointerEventsRule: UtilityRule;
|
|
18
|
+
export declare const resizeRule: UtilityRule;
|
|
19
|
+
export declare const scrollBehaviorRule: UtilityRule;
|
|
20
|
+
export declare const scrollMarginRule: UtilityRule;
|
|
21
|
+
export declare const scrollPaddingRule: UtilityRule;
|
|
22
|
+
export declare const scrollSnapRule: UtilityRule;
|
|
23
|
+
export declare const touchActionRule: UtilityRule;
|
|
24
|
+
export declare const userSelectRule: UtilityRule;
|
|
25
|
+
export declare const willChangeRule: UtilityRule;
|
|
26
|
+
// SVG utilities
|
|
27
|
+
export declare const fillRule: UtilityRule;
|
|
28
|
+
export declare const strokeRule: UtilityRule;
|
|
29
|
+
export declare const strokeWidthRule: UtilityRule;
|
|
30
|
+
// SVG stroke-dasharray
|
|
31
|
+
export declare const strokeDasharrayRule: UtilityRule;
|
|
32
|
+
// SVG stroke-dashoffset
|
|
33
|
+
export declare const strokeDashoffsetRule: UtilityRule;
|
|
34
|
+
// SVG stroke-linecap
|
|
35
|
+
export declare const strokeLinecapRule: UtilityRule;
|
|
36
|
+
// SVG stroke-linejoin
|
|
37
|
+
export declare const strokeLinejoinRule: UtilityRule;
|
|
38
|
+
// Accessibility
|
|
39
|
+
export declare const screenReaderRule: UtilityRule;
|
|
40
|
+
export declare const forcedColorAdjustRule: UtilityRule;
|
|
41
|
+
export declare const interactivityRules: UtilityRule[];
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { UtilityRule } from './rules';
|
|
2
|
+
// Layout utilities
|
|
3
|
+
export declare const aspectRatioRule: UtilityRule;
|
|
4
|
+
export declare const columnsRule: UtilityRule;
|
|
5
|
+
// Column fill
|
|
6
|
+
export declare const columnFillRule: UtilityRule;
|
|
7
|
+
// Column gap (different from grid gap)
|
|
8
|
+
export declare const columnGapRule: UtilityRule;
|
|
9
|
+
// Column rule (border between columns)
|
|
10
|
+
export declare const columnRuleRule: UtilityRule;
|
|
11
|
+
// Column span
|
|
12
|
+
export declare const columnSpanRule: UtilityRule;
|
|
13
|
+
export declare const breakRule: UtilityRule;
|
|
14
|
+
export declare const boxDecorationRule: UtilityRule;
|
|
15
|
+
export declare const boxSizingRule: UtilityRule;
|
|
16
|
+
export declare const floatRule: UtilityRule;
|
|
17
|
+
export declare const clearRule: UtilityRule;
|
|
18
|
+
export declare const isolationRule: UtilityRule;
|
|
19
|
+
export declare const containRule: UtilityRule;
|
|
20
|
+
export declare const objectFitRule: UtilityRule;
|
|
21
|
+
export declare const objectPositionRule: UtilityRule;
|
|
22
|
+
export declare const overflowRule: UtilityRule;
|
|
23
|
+
export declare const overscrollRule: UtilityRule;
|
|
24
|
+
export declare const positionRule: UtilityRule;
|
|
25
|
+
export declare const insetRule: UtilityRule;
|
|
26
|
+
export declare const visibilityRule: UtilityRule;
|
|
27
|
+
export declare const zIndexRule: UtilityRule;
|
|
28
|
+
export declare const layoutRules: UtilityRule[];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { UtilityRule } from './rules';
|
|
2
|
+
export declare const TRANSFORM_2D: string;
|
|
3
|
+
export declare const TRANSFORM_3D: string;
|
|
4
|
+
export declare const transformRule: UtilityRule;
|
|
5
|
+
export declare const scaleRule: UtilityRule;
|
|
6
|
+
export declare const rotateRule: UtilityRule;
|
|
7
|
+
export declare const translateRule: UtilityRule;
|
|
8
|
+
export declare const skewRule: UtilityRule;
|
|
9
|
+
export declare const transformOriginRule: UtilityRule;
|
|
10
|
+
export declare const perspectiveRule: UtilityRule;
|
|
11
|
+
export declare const perspectiveOriginRule: UtilityRule;
|
|
12
|
+
export declare const backfaceVisibilityRule: UtilityRule;
|
|
13
|
+
export declare const transformStyleRule: UtilityRule;
|
|
14
|
+
// Transition utilities
|
|
15
|
+
export declare const transitionPropertyRule: UtilityRule;
|
|
16
|
+
export declare const transitionDurationRule: UtilityRule;
|
|
17
|
+
export declare const transitionTimingRule: UtilityRule;
|
|
18
|
+
export declare const transitionDelayRule: UtilityRule;
|
|
19
|
+
export declare const transitionBehaviorRule: UtilityRule;
|
|
20
|
+
export declare const animationRule: UtilityRule;
|
|
21
|
+
// Animation play state
|
|
22
|
+
export declare const animationPlayStateRule: UtilityRule;
|
|
23
|
+
// Animation direction
|
|
24
|
+
export declare const animationDirectionRule: UtilityRule;
|
|
25
|
+
// Animation fill mode
|
|
26
|
+
export declare const animationFillModeRule: UtilityRule;
|
|
27
|
+
// Animation iteration count
|
|
28
|
+
export declare const animationIterationRule: UtilityRule;
|
|
29
|
+
// Animation duration
|
|
30
|
+
export declare const animationDurationRule: UtilityRule;
|
|
31
|
+
// Animation delay
|
|
32
|
+
export declare const animationDelayRule: UtilityRule;
|
|
33
|
+
// Animation timing function
|
|
34
|
+
export declare const animationTimingRule: UtilityRule;
|
|
35
|
+
export declare const transformsRules: UtilityRule[];
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { UtilityRule } from './rules';
|
|
2
|
+
// Typography utilities
|
|
3
|
+
export declare const fontFamilyRule: UtilityRule;
|
|
4
|
+
export declare const fontSmoothingRule: UtilityRule;
|
|
5
|
+
export declare const fontStyleRule: UtilityRule;
|
|
6
|
+
export declare const fontStretchRule: UtilityRule;
|
|
7
|
+
export declare const fontVariantNumericRule: UtilityRule;
|
|
8
|
+
export declare const letterSpacingRule: UtilityRule;
|
|
9
|
+
export declare const lineClampRule: UtilityRule;
|
|
10
|
+
export declare const listStyleImageRule: UtilityRule;
|
|
11
|
+
export declare const listStylePositionRule: UtilityRule;
|
|
12
|
+
export declare const listStyleTypeRule: UtilityRule;
|
|
13
|
+
export declare const textDecorationRule: UtilityRule;
|
|
14
|
+
export declare const underlineOffsetRule: UtilityRule;
|
|
15
|
+
export declare const textTransformRule: UtilityRule;
|
|
16
|
+
export declare const textOverflowRule: UtilityRule;
|
|
17
|
+
export declare const textWrapRule: UtilityRule;
|
|
18
|
+
export declare const textIndentRule: UtilityRule;
|
|
19
|
+
export declare const verticalAlignRule: UtilityRule;
|
|
20
|
+
export declare const whiteSpaceRule: UtilityRule;
|
|
21
|
+
export declare const wordBreakRule: UtilityRule;
|
|
22
|
+
export declare const overflowWrapRule: UtilityRule;
|
|
23
|
+
/**
|
|
24
|
+
* `tab-<integer>` / `tab-[<value>]` — the size of a tab character.
|
|
25
|
+
* Only integers and lengths are valid; an unknown word is not a tab size.
|
|
26
|
+
*/
|
|
27
|
+
export declare const tabSizeRule: UtilityRule;
|
|
28
|
+
export declare const hyphensRule: UtilityRule;
|
|
29
|
+
export declare const contentRule: UtilityRule;
|
|
30
|
+
export declare const lineHeightRule: UtilityRule;
|
|
31
|
+
// Writing mode
|
|
32
|
+
export declare const writingModeRule: UtilityRule;
|
|
33
|
+
// Text orientation
|
|
34
|
+
export declare const textOrientationRule: UtilityRule;
|
|
35
|
+
// Direction (ltr/rtl)
|
|
36
|
+
export declare const directionRule: UtilityRule;
|
|
37
|
+
// Text emphasis
|
|
38
|
+
export declare const textEmphasisRule: UtilityRule;
|
|
39
|
+
// Text emphasis color
|
|
40
|
+
export declare const textEmphasisColorRule: UtilityRule;
|
|
41
|
+
// Word spacing
|
|
42
|
+
export declare const wordSpacingRule: UtilityRule;
|
|
43
|
+
// Font variant caps
|
|
44
|
+
export declare const fontVariantCapsRule: UtilityRule;
|
|
45
|
+
// Font variant ligatures
|
|
46
|
+
export declare const fontVariantLigaturesRule: UtilityRule;
|
|
47
|
+
export declare const typographyRules: UtilityRule[];
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { CssConfig, ParsedClass, UtilityRuleResult } from './types';
|
|
2
|
+
// Resolve a size/spacing token shared by the sizing utilities: fractions,
|
|
3
|
+
// keyword map, theme spacing, off-scale numbers (0.25rem steps), and
|
|
4
|
+
// arbitrary values. Unknown words return undefined — they previously
|
|
5
|
+
// leaked verbatim (`w-sidebar` emitted `width: sidebar;`).
|
|
6
|
+
export declare function resolveSizeToken(parsed: { value?: string, arbitrary: boolean }, config: { theme: { spacing: Record<string, string> } }, sizeMap: Record<string, string>): string | undefined;
|
|
7
|
+
// Helper to apply opacity to color
|
|
8
|
+
export declare function applyOpacity(color: string, opacity: number): string;
|
|
9
|
+
/**
|
|
10
|
+
* Shared helper: resolve a color value (with optional opacity) from theme config.
|
|
11
|
+
* Handles: special keywords, direct colors, color-shade, opacity modifiers (/50, /[0.04]).
|
|
12
|
+
* Returns the resolved CSS color string or undefined if not found.
|
|
13
|
+
*/
|
|
14
|
+
export declare function resolveColorValue(value: string, config: { theme: { colors: Record<string, any> } }, modifierArbitrary?: boolean): string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Built-in utility rules
|
|
17
|
+
* Each rule checks if it matches the parsed class and returns CSS properties
|
|
18
|
+
*/
|
|
19
|
+
// Display utilities
|
|
20
|
+
export declare const displayRule: UtilityRule;
|
|
21
|
+
// Scrollbar utilities
|
|
22
|
+
export declare const scrollbarRule: UtilityRule;
|
|
23
|
+
// Content property for pseudo-elements: content-none, content-empty, content-['hello']
|
|
24
|
+
export declare const contentPropertyRule: UtilityRule;
|
|
25
|
+
// Container utilities (for container queries)
|
|
26
|
+
export declare const containerRule: UtilityRule;
|
|
27
|
+
// Flexbox utilities
|
|
28
|
+
export declare const flexDirectionRule: UtilityRule;
|
|
29
|
+
export declare const flexWrapRule: UtilityRule;
|
|
30
|
+
export declare const flexRule: UtilityRule;
|
|
31
|
+
export declare const flexGrowRule: UtilityRule;
|
|
32
|
+
export declare const flexShrinkRule: UtilityRule;
|
|
33
|
+
export declare const justifyContentRule: UtilityRule;
|
|
34
|
+
export declare const alignItemsRule: UtilityRule;
|
|
35
|
+
export declare const justifyItemsRule: UtilityRule;
|
|
36
|
+
export declare const alignContentRule: UtilityRule;
|
|
37
|
+
// Spacing utilities (margin, padding)
|
|
38
|
+
export declare const spacingRule: UtilityRule;
|
|
39
|
+
// Width and height utilities
|
|
40
|
+
export declare const sizingRule: UtilityRule;
|
|
41
|
+
export declare const colorRule: UtilityRule;
|
|
42
|
+
// Placeholder color utilities (placeholder-{color})
|
|
43
|
+
export declare const placeholderColorRule: UtilityRule;
|
|
44
|
+
// Typography utilities
|
|
45
|
+
export declare const fontSizeRule: UtilityRule;
|
|
46
|
+
export declare const fontWeightRule: UtilityRule;
|
|
47
|
+
export declare const leadingRule: UtilityRule;
|
|
48
|
+
export declare const textAlignRule: UtilityRule;
|
|
49
|
+
// Border utilities
|
|
50
|
+
export declare const borderWidthRule: UtilityRule;
|
|
51
|
+
// Border side width utilities (border-t-0, border-r-2, border-x-4, etc.)
|
|
52
|
+
export declare const borderSideWidthRule: UtilityRule;
|
|
53
|
+
export declare const borderRadiusRule: UtilityRule;
|
|
54
|
+
// Export all rules (order matters - more specific rules first)
|
|
55
|
+
export declare const builtInRules: UtilityRule[];
|
|
56
|
+
export type UtilityRule = (_parsed: ParsedClass, _config: CssConfig) => Record<string, string> | UtilityRuleResult | undefined;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CompileClassTransformer } from './transformer-compile-class';
|
|
2
|
+
import type { ExtractClassesOptions } from './parser';
|
|
3
|
+
export declare interface ScanResult {
|
|
4
|
+
classes: Set<string>
|
|
5
|
+
transformedFiles: Map<string, string>
|
|
6
|
+
unmatchedPatterns: string[]
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Scans files for utility classes using Bun's fast Glob API
|
|
10
|
+
*/
|
|
11
|
+
export declare class Scanner {
|
|
12
|
+
constructor(patterns: string[], transformer?: CompileClassTransformer | null | undefined, extractOptions?: ExtractClassesOptions | undefined);
|
|
13
|
+
scan(): Promise<ScanResult>;
|
|
14
|
+
scanFile(filePath: string): Promise<Set<string>>;
|
|
15
|
+
scanContent(content: string): Set<string>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { CreatedStyles, KeyframeDefinition, StyleArg, StyleProps, StyleRule, VarGroup, VarValue } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Compiles named style objects into atomic class names.
|
|
4
|
+
*
|
|
5
|
+
* Every declaration becomes its own class, deduplicated across the whole
|
|
6
|
+
* program by content hash, so two components that both say `padding: 16`
|
|
7
|
+
* share one rule.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const styles = css.create({
|
|
12
|
+
* card: { padding: 16, ':hover': { transform: 'translateY(-2px)' } },
|
|
13
|
+
* danger: { color: 'red' },
|
|
14
|
+
* sized: (width: number) => ({ width }),
|
|
15
|
+
* })
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function create<T extends Record<string, StyleRule | ((...args: any[]) => StyleRule)>>(styles: T): CreatedStyles<T>;
|
|
19
|
+
/**
|
|
20
|
+
* Merges compiled styles into the props an element needs.
|
|
21
|
+
*
|
|
22
|
+
* Later arguments win, property by property — not class by class — so
|
|
23
|
+
* `props(base, override)` behaves like object spread rather than like the
|
|
24
|
+
* cascade. Falsy arguments are skipped, which makes conditional styles read
|
|
25
|
+
* as `isActive && styles.active`.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* <div {...css.props(styles.card, isActive && styles.active)} />
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function props(...args: StyleArg[]): StyleProps;
|
|
33
|
+
/**
|
|
34
|
+
* Declares a group of CSS custom properties and returns `var(…)` references
|
|
35
|
+
* for each, ready to drop into any style object.
|
|
36
|
+
*
|
|
37
|
+
* A value may itself be conditional, which is how a theme responds to the
|
|
38
|
+
* viewer's colour scheme without any style needing to know about it.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* export const theme = css.defineVars({
|
|
43
|
+
* accent: '#0b7',
|
|
44
|
+
* surface: { default: '#fff', '@media (prefers-color-scheme: dark)': '#111' },
|
|
45
|
+
* })
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function defineVars<T extends Record<string, VarValue>>(vars: T): VarGroup<T>;
|
|
49
|
+
/**
|
|
50
|
+
* Re-declares an existing variable group under a generated class name.
|
|
51
|
+
*
|
|
52
|
+
* Put the returned class on any element and every style beneath it that reads
|
|
53
|
+
* those variables picks up the override — theming without threading props.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* const dark = css.createTheme(theme, { surface: '#111' })
|
|
58
|
+
* <section className={dark}>…</section>
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare function createTheme<T extends Record<string, string>>(vars: T, overrides: Partial<Record<keyof T, string | number>>): string;
|
|
62
|
+
/**
|
|
63
|
+
* Declares an `@keyframes` animation and returns its generated name.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* const fade = css.keyframes({ from: { opacity: 0 }, to: { opacity: 1 } })
|
|
68
|
+
* const styles = css.create({ intro: { animationName: fade } })
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export declare function keyframes(definition: KeyframeDefinition): string;
|
|
72
|
+
/**
|
|
73
|
+
* Declares a value with progressive-enhancement fallbacks.
|
|
74
|
+
*
|
|
75
|
+
* Returns the values in CSS fallback order — least-supported last — so a
|
|
76
|
+
* browser that understands `position: sticky` uses it and one that doesn't
|
|
77
|
+
* keeps the previous declaration.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* css.create({ bar: { position: css.firstThatWorks('sticky', '-webkit-sticky', 'fixed') } })
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export declare function firstThatWorks<T extends string>(...values: T[]): T[];
|
|
85
|
+
/**
|
|
86
|
+
* Freezes build-time constants — media query strings, spacing scales — that
|
|
87
|
+
* styles reference but that never become CSS of their own.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* const breakpoints = css.defineConsts({ md: '@media (min-width: 768px)' })
|
|
92
|
+
* css.create({ grid: { [breakpoints.md]: { display: 'grid' } } })
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export declare function defineConsts<T extends Record<string, string | number>>(consts: T): Readonly<T>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*.styles.ts'])
|
|
2
|
+
* await Bun.write('./dist/styles.css', css)
|
|
3
|
+
* ```
|
|
4
|
+
*/
|
|
5
|
+
export declare function collectStyles(patterns: string[], options?: { minify?: boolean, cwd?: string }): Promise<CollectResult>;
|
|
6
|
+
export declare interface CollectResult {
|
|
7
|
+
css: string
|
|
8
|
+
modules: string[]
|
|
9
|
+
unmatchedPatterns: string[]
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Imports a module for its style side effects, defeating the module cache
|
|
3
|
+
* when — and only when — the result would otherwise be wrong.
|
|
4
|
+
*
|
|
5
|
+
* Styles register themselves while their module evaluates, and a module
|
|
6
|
+
* evaluates once per specifier. Two things therefore have to reach the
|
|
7
|
+
* specifier: the file's mtime, so an edit re-registers the module's rules
|
|
8
|
+
* during a watch rebuild; and the registry generation, so a reset re-runs
|
|
9
|
+
* every module instead of leaving the registry permanently empty.
|
|
10
|
+
*/
|
|
11
|
+
export declare function importStyleModule(path: string): Promise<void>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 40-bit hash rendered in base36 (8 chars or fewer).
|
|
3
|
+
*
|
|
4
|
+
* 32 bits alone collides at roughly 1-in-300 across 5k atomic rules — well
|
|
5
|
+
* inside the range a real design system hits — so a second seeded pass adds
|
|
6
|
+
* another byte, taking that to ~1-in-100,000.
|
|
7
|
+
*/
|
|
8
|
+
export declare function hashString(input: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Class names must start with a letter, so every hash is prefixed. The
|
|
11
|
+
* default `tc` matches the framework's `tc-` class prefix while staying
|
|
12
|
+
* distinct from it — compiled utility groups are `tc-<hash>`, atomic style
|
|
13
|
+
* classes are `tc<hash>`, and the two can never collide.
|
|
14
|
+
*/
|
|
15
|
+
export declare function hashedClassName(input: string, prefix?: string): string;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { create, createTheme, defineConsts, defineVars, firstThatWorks, keyframes, props } from './api';
|
|
2
|
+
import { renderStyles, resetStyles } from './registry';
|
|
3
|
+
export type { AtomicRule, KeyframesRule, VarRule } from './registry';
|
|
4
|
+
export type {
|
|
5
|
+
CompiledStyle,
|
|
6
|
+
CreatedStyles,
|
|
7
|
+
DynamicStyle,
|
|
8
|
+
KeyframeDefinition,
|
|
9
|
+
StyleArg,
|
|
10
|
+
StyleProps,
|
|
11
|
+
StyleRule,
|
|
12
|
+
StyleValue,
|
|
13
|
+
VarGroup,
|
|
14
|
+
VarValue,
|
|
15
|
+
} from './types';
|
|
16
|
+
/**
|
|
17
|
+
* Namespaced entry point, so call sites read as prose.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { css } from '@ts-css/core'
|
|
22
|
+
*
|
|
23
|
+
* const styles = css.create({ card: { padding: 16 } })
|
|
24
|
+
* <div {...css.props(styles.card)} />
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare const css: {
|
|
28
|
+
create: typeof create
|
|
29
|
+
props: typeof props
|
|
30
|
+
defineVars: typeof defineVars
|
|
31
|
+
defineConsts: typeof defineConsts
|
|
32
|
+
createTheme: typeof createTheme
|
|
33
|
+
keyframes: typeof keyframes
|
|
34
|
+
firstThatWorks: typeof firstThatWorks
|
|
35
|
+
render: typeof renderStyles
|
|
36
|
+
reset: typeof resetStyles
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The style object API — typed, atomic, StyleX-shaped.
|
|
40
|
+
*
|
|
41
|
+
* Utility classes are unbeatable for the common case; they run out when a
|
|
42
|
+
* style has to be computed, shared as a token, or merged predictably across
|
|
43
|
+
* component boundaries. This is the escape hatch, and it compiles to the same
|
|
44
|
+
* atomic CSS the utility engine emits.
|
|
45
|
+
*/
|
|
46
|
+
export {
|
|
47
|
+
create,
|
|
48
|
+
createTheme,
|
|
49
|
+
defineConsts,
|
|
50
|
+
defineVars,
|
|
51
|
+
firstThatWorks,
|
|
52
|
+
keyframes,
|
|
53
|
+
props,
|
|
54
|
+
} from './api';
|
|
55
|
+
export { hashedClassName, hashString } from './hash';
|
|
56
|
+
export { renderStyles, resetStyles, styleCount } from './registry';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { BunPlugin } from 'bun';
|
|
2
|
+
/**
|
|
3
|
+
* Bun plugin that collects `css.create()` styles during a build.
|
|
4
|
+
*
|
|
5
|
+
* Style modules register their rules when they evaluate, so the plugin
|
|
6
|
+
* imports each matching module as the bundler loads it and writes the
|
|
7
|
+
* accumulated stylesheet out. Sources pass through untouched — the class
|
|
8
|
+
* names are already plain strings by the time the bundler sees them.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* await Bun.build({
|
|
13
|
+
* entrypoints: ['./src/index.tsx'],
|
|
14
|
+
* outdir: './dist',
|
|
15
|
+
* plugins: [stylePlugin({ output: './dist/styles.css', minify: true })],
|
|
16
|
+
* })
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function stylePlugin(options?: StylePluginOptions): BunPlugin;
|
|
20
|
+
export declare interface StylePluginOptions {
|
|
21
|
+
include?: RegExp
|
|
22
|
+
styleModules?: string[]
|
|
23
|
+
output?: string
|
|
24
|
+
minify?: boolean
|
|
25
|
+
onCSS?: (css: string) => void | Promise<void>
|
|
26
|
+
}
|
|
27
|
+
export default stylePlugin;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare function propertyPriority(property: string): number;
|
|
2
|
+
/**
|
|
3
|
+
* A condition is an at-rule (`@media …`), a pseudo-element (`::before`) or a
|
|
4
|
+
* pseudo-class / nested selector (`:hover`, `&[data-open] &`).
|
|
5
|
+
*/
|
|
6
|
+
export declare function conditionPriority(condition: string): number;
|
|
7
|
+
/**
|
|
8
|
+
* Property class dominates: a longhand always beats a shorthand, however
|
|
9
|
+
* deeply the shorthand is nested. Conditions only order rules that set the
|
|
10
|
+
* same property.
|
|
11
|
+
*/
|
|
12
|
+
export declare function rulePriority(property: string, conditions: readonly string[]): number;
|