rnwind 0.0.1 → 0.0.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/lib/cjs/core/parser/animation.cjs +427 -0
- package/lib/cjs/core/parser/animation.cjs.map +1 -0
- package/lib/cjs/core/parser/animation.d.ts +126 -0
- package/lib/cjs/core/parser/border-dispatcher.cjs +180 -0
- package/lib/cjs/core/parser/border-dispatcher.cjs.map +1 -0
- package/lib/cjs/core/parser/border-dispatcher.d.ts +15 -0
- package/lib/cjs/core/parser/case-convert.cjs +15 -0
- package/lib/cjs/core/parser/case-convert.cjs.map +1 -0
- package/lib/cjs/core/parser/case-convert.d.ts +6 -0
- package/lib/cjs/core/parser/color-properties-dispatcher.cjs +84 -0
- package/lib/cjs/core/parser/color-properties-dispatcher.cjs.map +1 -0
- package/lib/cjs/core/parser/color-properties-dispatcher.d.ts +19 -0
- package/lib/cjs/core/parser/color.cjs +164 -0
- package/lib/cjs/core/parser/color.cjs.map +1 -0
- package/lib/cjs/core/parser/color.d.ts +12 -0
- package/lib/cjs/core/parser/constants.cjs +21 -0
- package/lib/cjs/core/parser/constants.cjs.map +1 -0
- package/lib/cjs/core/parser/constants.d.ts +8 -0
- package/lib/cjs/core/parser/declaration.cjs +347 -0
- package/lib/cjs/core/parser/declaration.cjs.map +1 -0
- package/lib/cjs/core/parser/declaration.d.ts +15 -0
- package/lib/cjs/core/parser/gradient.cjs +132 -0
- package/lib/cjs/core/parser/gradient.cjs.map +1 -0
- package/lib/cjs/core/parser/gradient.d.ts +59 -0
- package/lib/cjs/core/parser/haptics.cjs +73 -0
- package/lib/cjs/core/parser/haptics.cjs.map +1 -0
- package/lib/cjs/core/parser/haptics.d.ts +47 -0
- package/lib/cjs/core/parser/index.d.ts +8 -0
- package/lib/cjs/core/parser/keyframes.cjs +95 -0
- package/lib/cjs/core/parser/keyframes.cjs.map +1 -0
- package/lib/cjs/core/parser/keyframes.d.ts +26 -0
- package/lib/cjs/core/parser/layout-dispatcher.cjs +100 -0
- package/lib/cjs/core/parser/layout-dispatcher.cjs.map +1 -0
- package/lib/cjs/core/parser/layout-dispatcher.d.ts +14 -0
- package/lib/cjs/core/parser/length.cjs +96 -0
- package/lib/cjs/core/parser/length.cjs.map +1 -0
- package/lib/cjs/core/parser/length.d.ts +48 -0
- package/lib/cjs/core/parser/motion-dispatcher.cjs +77 -0
- package/lib/cjs/core/parser/motion-dispatcher.cjs.map +1 -0
- package/lib/cjs/core/parser/motion-dispatcher.d.ts +11 -0
- package/lib/cjs/core/parser/property.cjs +22 -0
- package/lib/cjs/core/parser/property.cjs.map +1 -0
- package/lib/cjs/core/parser/property.d.ts +8 -0
- package/lib/cjs/core/parser/safe-area.cjs +404 -0
- package/lib/cjs/core/parser/safe-area.cjs.map +1 -0
- package/lib/cjs/core/parser/safe-area.d.ts +39 -0
- package/lib/cjs/core/parser/selector.cjs +22 -0
- package/lib/cjs/core/parser/selector.cjs.map +1 -0
- package/lib/cjs/core/parser/selector.d.ts +11 -0
- package/lib/cjs/core/parser/shorthand.cjs +156 -0
- package/lib/cjs/core/parser/shorthand.cjs.map +1 -0
- package/lib/cjs/core/parser/shorthand.d.ts +61 -0
- package/lib/cjs/core/parser/text-truncate.cjs +78 -0
- package/lib/cjs/core/parser/text-truncate.cjs.map +1 -0
- package/lib/cjs/core/parser/text-truncate.d.ts +44 -0
- package/lib/cjs/core/parser/theme-vars.cjs +414 -0
- package/lib/cjs/core/parser/theme-vars.cjs.map +1 -0
- package/lib/cjs/core/parser/theme-vars.d.ts +61 -0
- package/lib/cjs/core/parser/tokens.cjs +304 -0
- package/lib/cjs/core/parser/tokens.cjs.map +1 -0
- package/lib/cjs/core/parser/tokens.d.ts +45 -0
- package/lib/cjs/core/parser/transform.cjs +198 -0
- package/lib/cjs/core/parser/transform.cjs.map +1 -0
- package/lib/cjs/core/parser/transform.d.ts +36 -0
- package/lib/cjs/core/parser/tw-parser.cjs +1567 -0
- package/lib/cjs/core/parser/tw-parser.cjs.map +1 -0
- package/lib/cjs/core/parser/tw-parser.d.ts +194 -0
- package/lib/cjs/core/parser/types.d.ts +37 -0
- package/lib/cjs/core/parser/typography-dispatcher.cjs +93 -0
- package/lib/cjs/core/parser/typography-dispatcher.cjs.map +1 -0
- package/lib/cjs/core/parser/typography-dispatcher.d.ts +11 -0
- package/lib/cjs/core/parser/typography.cjs +97 -0
- package/lib/cjs/core/parser/typography.cjs.map +1 -0
- package/lib/cjs/core/parser/typography.d.ts +43 -0
- package/lib/cjs/core/style-builder/build-style.cjs +397 -0
- package/lib/cjs/core/style-builder/build-style.cjs.map +1 -0
- package/lib/cjs/core/style-builder/build-style.d.ts +54 -0
- package/lib/cjs/core/style-builder/index.d.ts +3 -0
- package/lib/cjs/core/style-builder/union-builder.cjs +326 -0
- package/lib/cjs/core/style-builder/union-builder.cjs.map +1 -0
- package/lib/cjs/core/style-builder/union-builder.d.ts +128 -0
- package/lib/cjs/core/types.d.ts +14 -0
- package/lib/cjs/metro/dts.cjs +127 -0
- package/lib/cjs/metro/dts.cjs.map +1 -0
- package/lib/cjs/metro/dts.d.ts +16 -0
- package/lib/cjs/metro/index.cjs +19 -0
- package/lib/cjs/metro/index.cjs.map +1 -0
- package/lib/cjs/metro/index.d.ts +9 -0
- package/lib/cjs/metro/resolver.cjs +47 -0
- package/lib/cjs/metro/resolver.cjs.map +1 -0
- package/lib/cjs/metro/resolver.d.ts +22 -0
- package/lib/cjs/metro/state.cjs +251 -0
- package/lib/cjs/metro/state.cjs.map +1 -0
- package/lib/cjs/metro/state.d.ts +72 -0
- package/lib/cjs/metro/transform-ast.cjs +1255 -0
- package/lib/cjs/metro/transform-ast.cjs.map +1 -0
- package/lib/cjs/metro/transform-ast.d.ts +73 -0
- package/lib/cjs/metro/transformer.cjs +345 -0
- package/lib/cjs/metro/transformer.cjs.map +1 -0
- package/lib/cjs/metro/transformer.d.ts +47 -0
- package/lib/cjs/metro/warn-unknown-classes.cjs +86 -0
- package/lib/cjs/metro/warn-unknown-classes.cjs.map +1 -0
- package/lib/cjs/metro/warn-unknown-classes.d.ts +21 -0
- package/lib/cjs/metro/with-config.cjs +196 -0
- package/lib/cjs/metro/with-config.cjs.map +1 -0
- package/lib/cjs/metro/with-config.d.ts +57 -0
- package/lib/cjs/runtime/chain-handlers.cjs +37 -0
- package/lib/cjs/runtime/chain-handlers.cjs.map +1 -0
- package/lib/cjs/runtime/chain-handlers.d.ts +33 -0
- package/lib/cjs/runtime/components/rnwind-provider.cjs +98 -0
- package/lib/cjs/runtime/components/rnwind-provider.cjs.map +1 -0
- package/lib/cjs/runtime/components/rnwind-provider.d.ts +84 -0
- package/lib/cjs/runtime/gradient-types.d.ts +58 -0
- package/lib/cjs/runtime/haptics.cjs +113 -0
- package/lib/cjs/runtime/haptics.cjs.map +1 -0
- package/lib/cjs/runtime/haptics.d.ts +48 -0
- package/lib/cjs/runtime/hooks/use-css.cjs +21 -0
- package/lib/cjs/runtime/hooks/use-css.cjs.map +1 -0
- package/lib/cjs/runtime/hooks/use-css.d.ts +11 -0
- package/lib/cjs/runtime/hooks/use-interact.cjs +46 -0
- package/lib/cjs/runtime/hooks/use-interact.cjs.map +1 -0
- package/lib/cjs/runtime/hooks/use-interact.d.ts +42 -0
- package/lib/cjs/runtime/hooks/use-scheme.cjs +68 -0
- package/lib/cjs/runtime/hooks/use-scheme.cjs.map +1 -0
- package/lib/cjs/runtime/hooks/use-scheme.d.ts +34 -0
- package/lib/cjs/runtime/index.cjs +45 -0
- package/lib/cjs/runtime/index.cjs.map +1 -0
- package/lib/cjs/runtime/index.d.ts +27 -0
- package/lib/cjs/runtime/interactive-box.cjs +35 -0
- package/lib/cjs/runtime/interactive-box.cjs.map +1 -0
- package/lib/cjs/runtime/interactive-box.d.ts +40 -0
- package/lib/cjs/runtime/lookup-css.cjs +542 -0
- package/lib/cjs/runtime/lookup-css.cjs.map +1 -0
- package/lib/cjs/runtime/lookup-css.d.ts +164 -0
- package/lib/cjs/runtime/types.d.ts +29 -0
- package/lib/cjs/testing/index.cjs +367 -0
- package/lib/cjs/testing/index.cjs.map +1 -0
- package/lib/cjs/testing/index.d.ts +145 -0
- package/lib/esm/core/parser/animation.d.ts +126 -0
- package/lib/esm/core/parser/animation.mjs +408 -0
- package/lib/esm/core/parser/animation.mjs.map +1 -0
- package/lib/esm/core/parser/border-dispatcher.d.ts +15 -0
- package/lib/esm/core/parser/border-dispatcher.mjs +178 -0
- package/lib/esm/core/parser/border-dispatcher.mjs.map +1 -0
- package/lib/esm/core/parser/case-convert.d.ts +6 -0
- package/lib/esm/core/parser/case-convert.mjs +13 -0
- package/lib/esm/core/parser/case-convert.mjs.map +1 -0
- package/lib/esm/core/parser/color-properties-dispatcher.d.ts +19 -0
- package/lib/esm/core/parser/color-properties-dispatcher.mjs +82 -0
- package/lib/esm/core/parser/color-properties-dispatcher.mjs.map +1 -0
- package/lib/esm/core/parser/color.d.ts +12 -0
- package/lib/esm/core/parser/color.mjs +162 -0
- package/lib/esm/core/parser/color.mjs.map +1 -0
- package/lib/esm/core/parser/constants.d.ts +8 -0
- package/lib/esm/core/parser/constants.mjs +13 -0
- package/lib/esm/core/parser/constants.mjs.map +1 -0
- package/lib/esm/core/parser/declaration.d.ts +15 -0
- package/lib/esm/core/parser/declaration.mjs +345 -0
- package/lib/esm/core/parser/declaration.mjs.map +1 -0
- package/lib/esm/core/parser/gradient.d.ts +59 -0
- package/lib/esm/core/parser/gradient.mjs +130 -0
- package/lib/esm/core/parser/gradient.mjs.map +1 -0
- package/lib/esm/core/parser/haptics.d.ts +47 -0
- package/lib/esm/core/parser/haptics.mjs +71 -0
- package/lib/esm/core/parser/haptics.mjs.map +1 -0
- package/lib/esm/core/parser/index.d.ts +8 -0
- package/lib/esm/core/parser/keyframes.d.ts +26 -0
- package/lib/esm/core/parser/keyframes.mjs +91 -0
- package/lib/esm/core/parser/keyframes.mjs.map +1 -0
- package/lib/esm/core/parser/layout-dispatcher.d.ts +14 -0
- package/lib/esm/core/parser/layout-dispatcher.mjs +98 -0
- package/lib/esm/core/parser/layout-dispatcher.mjs.map +1 -0
- package/lib/esm/core/parser/length.d.ts +48 -0
- package/lib/esm/core/parser/length.mjs +90 -0
- package/lib/esm/core/parser/length.mjs.map +1 -0
- package/lib/esm/core/parser/motion-dispatcher.d.ts +11 -0
- package/lib/esm/core/parser/motion-dispatcher.mjs +75 -0
- package/lib/esm/core/parser/motion-dispatcher.mjs.map +1 -0
- package/lib/esm/core/parser/property.d.ts +8 -0
- package/lib/esm/core/parser/property.mjs +20 -0
- package/lib/esm/core/parser/property.mjs.map +1 -0
- package/lib/esm/core/parser/safe-area.d.ts +39 -0
- package/lib/esm/core/parser/safe-area.mjs +402 -0
- package/lib/esm/core/parser/safe-area.mjs.map +1 -0
- package/lib/esm/core/parser/selector.d.ts +11 -0
- package/lib/esm/core/parser/selector.mjs +20 -0
- package/lib/esm/core/parser/selector.mjs.map +1 -0
- package/lib/esm/core/parser/shorthand.d.ts +61 -0
- package/lib/esm/core/parser/shorthand.mjs +148 -0
- package/lib/esm/core/parser/shorthand.mjs.map +1 -0
- package/lib/esm/core/parser/text-truncate.d.ts +44 -0
- package/lib/esm/core/parser/text-truncate.mjs +75 -0
- package/lib/esm/core/parser/text-truncate.mjs.map +1 -0
- package/lib/esm/core/parser/theme-vars.d.ts +61 -0
- package/lib/esm/core/parser/theme-vars.mjs +409 -0
- package/lib/esm/core/parser/theme-vars.mjs.map +1 -0
- package/lib/esm/core/parser/tokens.d.ts +45 -0
- package/lib/esm/core/parser/tokens.mjs +298 -0
- package/lib/esm/core/parser/tokens.mjs.map +1 -0
- package/lib/esm/core/parser/transform.d.ts +36 -0
- package/lib/esm/core/parser/transform.mjs +193 -0
- package/lib/esm/core/parser/transform.mjs.map +1 -0
- package/lib/esm/core/parser/tw-parser.d.ts +194 -0
- package/lib/esm/core/parser/tw-parser.mjs +1565 -0
- package/lib/esm/core/parser/tw-parser.mjs.map +1 -0
- package/lib/esm/core/parser/types.d.ts +37 -0
- package/lib/esm/core/parser/typography-dispatcher.d.ts +11 -0
- package/lib/esm/core/parser/typography-dispatcher.mjs +91 -0
- package/lib/esm/core/parser/typography-dispatcher.mjs.map +1 -0
- package/lib/esm/core/parser/typography.d.ts +43 -0
- package/lib/esm/core/parser/typography.mjs +91 -0
- package/lib/esm/core/parser/typography.mjs.map +1 -0
- package/lib/esm/core/style-builder/build-style.d.ts +54 -0
- package/lib/esm/core/style-builder/build-style.mjs +395 -0
- package/lib/esm/core/style-builder/build-style.mjs.map +1 -0
- package/lib/esm/core/style-builder/index.d.ts +3 -0
- package/lib/esm/core/style-builder/union-builder.d.ts +128 -0
- package/lib/esm/core/style-builder/union-builder.mjs +324 -0
- package/lib/esm/core/style-builder/union-builder.mjs.map +1 -0
- package/lib/esm/core/types.d.ts +14 -0
- package/lib/esm/metro/dts.d.ts +16 -0
- package/lib/esm/metro/dts.mjs +125 -0
- package/lib/esm/metro/dts.mjs.map +1 -0
- package/lib/esm/metro/index.d.ts +9 -0
- package/lib/esm/metro/index.mjs +6 -0
- package/lib/esm/metro/index.mjs.map +1 -0
- package/lib/esm/metro/resolver.d.ts +22 -0
- package/lib/esm/metro/resolver.mjs +43 -0
- package/lib/esm/metro/resolver.mjs.map +1 -0
- package/lib/esm/metro/state.d.ts +72 -0
- package/lib/esm/metro/state.mjs +243 -0
- package/lib/esm/metro/state.mjs.map +1 -0
- package/lib/esm/metro/transform-ast.d.ts +73 -0
- package/lib/esm/metro/transform-ast.mjs +1234 -0
- package/lib/esm/metro/transform-ast.mjs.map +1 -0
- package/lib/esm/metro/transformer.d.ts +47 -0
- package/lib/esm/metro/transformer.mjs +322 -0
- package/lib/esm/metro/transformer.mjs.map +1 -0
- package/lib/esm/metro/warn-unknown-classes.d.ts +21 -0
- package/lib/esm/metro/warn-unknown-classes.mjs +84 -0
- package/lib/esm/metro/warn-unknown-classes.mjs.map +1 -0
- package/lib/esm/metro/with-config.d.ts +57 -0
- package/lib/esm/metro/with-config.mjs +194 -0
- package/lib/esm/metro/with-config.mjs.map +1 -0
- package/lib/esm/runtime/chain-handlers.d.ts +33 -0
- package/lib/esm/runtime/chain-handlers.mjs +34 -0
- package/lib/esm/runtime/chain-handlers.mjs.map +1 -0
- package/lib/esm/runtime/components/rnwind-provider.d.ts +84 -0
- package/lib/esm/runtime/components/rnwind-provider.mjs +94 -0
- package/lib/esm/runtime/components/rnwind-provider.mjs.map +1 -0
- package/lib/esm/runtime/gradient-types.d.ts +58 -0
- package/lib/esm/runtime/haptics.d.ts +48 -0
- package/lib/esm/runtime/haptics.mjs +110 -0
- package/lib/esm/runtime/haptics.mjs.map +1 -0
- package/lib/esm/runtime/hooks/use-css.d.ts +11 -0
- package/lib/esm/runtime/hooks/use-css.mjs +19 -0
- package/lib/esm/runtime/hooks/use-css.mjs.map +1 -0
- package/lib/esm/runtime/hooks/use-interact.d.ts +42 -0
- package/lib/esm/runtime/hooks/use-interact.mjs +44 -0
- package/lib/esm/runtime/hooks/use-interact.mjs.map +1 -0
- package/lib/esm/runtime/hooks/use-scheme.d.ts +34 -0
- package/lib/esm/runtime/hooks/use-scheme.mjs +63 -0
- package/lib/esm/runtime/hooks/use-scheme.mjs.map +1 -0
- package/lib/esm/runtime/index.d.ts +27 -0
- package/lib/esm/runtime/index.mjs +18 -0
- package/lib/esm/runtime/index.mjs.map +1 -0
- package/lib/esm/runtime/interactive-box.d.ts +40 -0
- package/lib/esm/runtime/interactive-box.mjs +33 -0
- package/lib/esm/runtime/interactive-box.mjs.map +1 -0
- package/lib/esm/runtime/lookup-css.d.ts +164 -0
- package/lib/esm/runtime/lookup-css.mjs +531 -0
- package/lib/esm/runtime/lookup-css.mjs.map +1 -0
- package/lib/esm/runtime/types.d.ts +29 -0
- package/lib/esm/testing/index.d.ts +145 -0
- package/lib/esm/testing/index.mjs +344 -0
- package/lib/esm/testing/index.mjs.map +1 -0
- package/package.json +79 -13
- package/preset.css +1171 -0
- package/src/core/parser/animation.ts +404 -0
- package/src/core/parser/border-dispatcher.ts +176 -0
- package/src/core/parser/case-convert.ts +10 -0
- package/src/core/parser/color-properties-dispatcher.ts +78 -0
- package/src/core/parser/color.ts +157 -0
- package/src/core/parser/constants.ts +11 -0
- package/src/core/parser/declaration.ts +340 -0
- package/src/core/parser/gradient.ts +148 -0
- package/src/core/parser/haptics.ts +88 -0
- package/src/core/parser/index.ts +8 -0
- package/src/core/parser/keyframes.ts +84 -0
- package/src/core/parser/layout-dispatcher.ts +92 -0
- package/src/core/parser/length.ts +100 -0
- package/src/core/parser/motion-dispatcher.ts +89 -0
- package/src/core/parser/property.ts +15 -0
- package/src/core/parser/safe-area.ts +404 -0
- package/src/core/parser/selector.ts +17 -0
- package/src/core/parser/shorthand.ts +152 -0
- package/src/core/parser/text-truncate.ts +79 -0
- package/src/core/parser/theme-vars.ts +412 -0
- package/src/core/parser/tokens.ts +286 -0
- package/src/core/parser/transform.ts +195 -0
- package/src/core/parser/tw-parser.ts +1709 -0
- package/src/core/parser/types.ts +45 -0
- package/src/core/parser/typography-dispatcher.ts +83 -0
- package/src/core/parser/typography.ts +83 -0
- package/src/core/style-builder/build-style.ts +442 -0
- package/src/core/style-builder/index.ts +3 -0
- package/src/core/style-builder/union-builder.ts +328 -0
- package/src/core/types.ts +15 -0
- package/src/metro/dts.ts +128 -0
- package/src/metro/index.ts +9 -0
- package/src/metro/resolver.ts +42 -0
- package/src/metro/state.ts +257 -0
- package/src/metro/transform-ast.ts +1498 -0
- package/src/metro/transformer.ts +347 -0
- package/src/metro/warn-unknown-classes.ts +79 -0
- package/src/metro/with-config.ts +229 -0
- package/src/runtime/chain-handlers.ts +47 -0
- package/src/runtime/components/rnwind-provider.tsx +144 -0
- package/src/runtime/gradient-types.ts +60 -0
- package/src/runtime/haptics.ts +120 -0
- package/src/runtime/hooks/use-css.ts +16 -0
- package/src/runtime/hooks/use-interact.ts +65 -0
- package/src/runtime/hooks/use-scheme.ts +63 -0
- package/src/runtime/index.ts +54 -0
- package/src/runtime/interactive-box.tsx +57 -0
- package/src/runtime/lookup-css.ts +628 -0
- package/src/runtime/types.ts +32 -0
- package/src/testing/index.ts +507 -0
- package/src/types/tailwindcss-node.d.ts +33 -0
- package/src/index.ts +0 -1
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight extractor for user-declared `@theme` and `@variant` blocks
|
|
3
|
+
* inside `:root` / `@layer theme`. Used by the parser to resolve
|
|
4
|
+
* `var(--x)` references that Tailwind's `theme(inline)` leaves
|
|
5
|
+
* unresolved (it only inlines its own known tokens, not user-added ones).
|
|
6
|
+
*
|
|
7
|
+
* Kept regex-free — a linear paren-balanced scan handles nesting without
|
|
8
|
+
* the backtracking risks of `{[^}]*}` patterns. CSS comment blocks are
|
|
9
|
+
* stripped before scanning so slash-star-sequences inside declaration
|
|
10
|
+
* values don't confuse the parser.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* `@custom-variant <name> ...content-up-to-semicolon...;`
|
|
14
|
+
* The `[^;]+` class is constant-width relative to its input (one char
|
|
15
|
+
* per step, no alternation backtracking), so sonarjs/slow-regex doesn't
|
|
16
|
+
* apply — the flagged pattern is a false positive.
|
|
17
|
+
*/
|
|
18
|
+
// eslint-disable-next-line sonarjs/slow-regex
|
|
19
|
+
const CUSTOM_VARIANT_WITH_SELECTOR = /@custom-variant\s+([A-Za-z][A-Za-z0-9_-]*)\s+([^;]+);/g;
|
|
20
|
+
/** Bare `.classname` occurrences (one capture group per class). */
|
|
21
|
+
const CLASS_IN_SELECTOR = /\.([A-Za-z_][\w-]*)/g;
|
|
22
|
+
/**
|
|
23
|
+
* Recursively descend into `{ ... }` blocks, collecting `--x: y;`
|
|
24
|
+
* declarations under the active scheme. When we hit `@variant <name> {`,
|
|
25
|
+
* the child scope's scheme becomes `<name>` until that block closes.
|
|
26
|
+
* @param source Pre-stripped CSS source.
|
|
27
|
+
* @param start Start index of the block body (0 for top-level).
|
|
28
|
+
* @param scheme Active scheme name for declarations inside this scope.
|
|
29
|
+
* @param table Destination table, mutated in place.
|
|
30
|
+
*/
|
|
31
|
+
function walkBlocks(source, start, scheme, table) {
|
|
32
|
+
let index = start;
|
|
33
|
+
while (index < source.length) {
|
|
34
|
+
const step = nextWalkStep(source, index, scheme, table);
|
|
35
|
+
if (step.next === -1)
|
|
36
|
+
return;
|
|
37
|
+
index = step.next;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Decide the next action at `index`: declaration, nested block, or EOF.
|
|
42
|
+
* @param source Pre-stripped CSS.
|
|
43
|
+
* @param index Current scan index.
|
|
44
|
+
* @param scheme Active scheme name.
|
|
45
|
+
* @param table Destination table.
|
|
46
|
+
* @returns Step descriptor with the next scan index (or -1 for EOF).
|
|
47
|
+
*/
|
|
48
|
+
function nextWalkStep(source, index, scheme, table) {
|
|
49
|
+
// Find the next TOP-LEVEL `--` (outside any `( ... )`). That's the only
|
|
50
|
+
// place a custom-property declaration can start. `--foo` that appears
|
|
51
|
+
// inside `var(--foo)` or `calc(... --value(integer) ...)` is part of a
|
|
52
|
+
// value, not a new declaration — accidentally treating it as one would
|
|
53
|
+
// splice into the `@theme` block's declaration list and produce broken
|
|
54
|
+
// CSS that Tailwind rejects downstream.
|
|
55
|
+
const atIndex = findTopLevelDoubleDash(source, index);
|
|
56
|
+
const openIndex = source.indexOf('{', index);
|
|
57
|
+
const closeIndex = source.indexOf('}', index);
|
|
58
|
+
const blockClose = closeIndex === -1 ? Number.POSITIVE_INFINITY : closeIndex;
|
|
59
|
+
if (isDeclarationNext(atIndex, openIndex, blockClose)) {
|
|
60
|
+
return { next: consumeDeclaration(source, atIndex, scheme, table) };
|
|
61
|
+
}
|
|
62
|
+
if (openIndex !== -1 && openIndex < blockClose) {
|
|
63
|
+
return { next: enterBlock(source, index, openIndex, scheme, table) };
|
|
64
|
+
}
|
|
65
|
+
return { next: -1 };
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Find the next `--` in `source` that's not inside a `( ... )` group.
|
|
69
|
+
* Stops early if we hit an unmatched `}` (end of the containing block)
|
|
70
|
+
* — a `--` inside a nested block isn't our concern either.
|
|
71
|
+
* @param source Pre-stripped CSS source.
|
|
72
|
+
* @param from Start index to scan from.
|
|
73
|
+
* @returns Index of the next top-level `--`, or `-1` when none.
|
|
74
|
+
*/
|
|
75
|
+
function findTopLevelDoubleDash(source, from) {
|
|
76
|
+
let parenDepth = 0;
|
|
77
|
+
for (let index = from; index < source.length - 1; index += 1) {
|
|
78
|
+
const ch = source.codePointAt(index);
|
|
79
|
+
if (ch === 40 /* ( */) {
|
|
80
|
+
parenDepth += 1;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
if (ch === 41 /* ) */) {
|
|
84
|
+
if (parenDepth > 0)
|
|
85
|
+
parenDepth -= 1;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (ch === 125 /* } */ && parenDepth === 0)
|
|
89
|
+
return -1;
|
|
90
|
+
if (ch === 45 /* - */ && parenDepth === 0 && source.codePointAt(index + 1) === 45) {
|
|
91
|
+
return index;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return -1;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Whether the next action at the current scan position is a declaration.
|
|
98
|
+
* @param atIndex Index of the next `--`.
|
|
99
|
+
* @param openIndex Index of the next `{`.
|
|
100
|
+
* @param blockClose Index of the next `}` (or `+Infinity` when absent).
|
|
101
|
+
* @returns True when a declaration should be consumed next.
|
|
102
|
+
*/
|
|
103
|
+
function isDeclarationNext(atIndex, openIndex, blockClose) {
|
|
104
|
+
if (atIndex === -1 || atIndex >= blockClose)
|
|
105
|
+
return false;
|
|
106
|
+
return openIndex === -1 || atIndex < openIndex;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Handle a nested `{ ... }` block: recurse with the right scheme, then
|
|
110
|
+
* skip past the matching closing brace.
|
|
111
|
+
* @param source Pre-stripped CSS.
|
|
112
|
+
* @param index Scan position at the start of the header.
|
|
113
|
+
* @param openIndex Index of the opening brace.
|
|
114
|
+
* @param scheme Scheme active in the parent scope.
|
|
115
|
+
* @param table Destination table.
|
|
116
|
+
* @returns Index past the matching closing brace.
|
|
117
|
+
*/
|
|
118
|
+
function enterBlock(source, index, openIndex, scheme, table) {
|
|
119
|
+
const header = source.slice(index, openIndex).trim();
|
|
120
|
+
// Skip blocks that define utilities / at-rules that carry declarations
|
|
121
|
+
// meant for a downstream compiler, not custom-property values for the
|
|
122
|
+
// active theme scheme. `@utility name-*` bodies contain Tailwind v4's
|
|
123
|
+
// `--value(...)` meta-syntax which would otherwise confuse the
|
|
124
|
+
// top-level declaration walker and spill into the extracted theme.
|
|
125
|
+
if (isNonThemeAtRule(header))
|
|
126
|
+
return skipMatchingBrace(source, openIndex + 1);
|
|
127
|
+
const childScheme = variantNameOf(header) ?? scheme;
|
|
128
|
+
walkBlocks(source, openIndex + 1, childScheme, table);
|
|
129
|
+
return skipMatchingBrace(source, openIndex + 1);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Whether a block header belongs to an at-rule whose body should be
|
|
133
|
+
* ignored by the theme-var extractor. `@utility` / `@media` / `@keyframes`
|
|
134
|
+
* / `@supports` / `@container` bodies contain property declarations that
|
|
135
|
+
* are NOT custom-property definitions for the active theme.
|
|
136
|
+
* @param header Text between the outer statement and the opening brace.
|
|
137
|
+
* @returns `true` when the block body should be skipped.
|
|
138
|
+
*/
|
|
139
|
+
function isNonThemeAtRule(header) {
|
|
140
|
+
const trimmed = header.trimStart();
|
|
141
|
+
if (!trimmed.startsWith('@'))
|
|
142
|
+
return false;
|
|
143
|
+
const match = /^@([A-Za-z-]+)/.exec(trimmed);
|
|
144
|
+
if (!match)
|
|
145
|
+
return false;
|
|
146
|
+
const name = match[1];
|
|
147
|
+
return name === 'utility' || name === 'keyframes' || name === 'media' || name === 'supports' || name === 'container';
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Consume one `--name: value;` declaration starting at `start`. Commits
|
|
151
|
+
* the name/value pair into the active scheme's map and returns the index
|
|
152
|
+
* just past the terminating `;`.
|
|
153
|
+
* @param source CSS source.
|
|
154
|
+
* @param start Index of the `--`.
|
|
155
|
+
* @param scheme Active scheme.
|
|
156
|
+
* @param table Destination table.
|
|
157
|
+
* @returns Next scan index.
|
|
158
|
+
*/
|
|
159
|
+
function consumeDeclaration(source, start, scheme, table) {
|
|
160
|
+
const colon = source.indexOf(':', start);
|
|
161
|
+
if (colon === -1)
|
|
162
|
+
return source.length;
|
|
163
|
+
const name = source.slice(start, colon).trim();
|
|
164
|
+
const end = source.indexOf(';', colon);
|
|
165
|
+
const stop = end === -1 ? source.indexOf('}', colon) : end;
|
|
166
|
+
if (stop === -1)
|
|
167
|
+
return source.length;
|
|
168
|
+
const value = source.slice(colon + 1, stop).trim();
|
|
169
|
+
if (name.startsWith('--')) {
|
|
170
|
+
const bucket = table.get(scheme) ?? new Map();
|
|
171
|
+
bucket.set(name, value);
|
|
172
|
+
table.set(scheme, bucket);
|
|
173
|
+
}
|
|
174
|
+
return stop + 1;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Walk forward through the source tracking brace depth; return the index
|
|
178
|
+
* just past the matching `}` for the opener at `start - 1`.
|
|
179
|
+
* @param source CSS source.
|
|
180
|
+
* @param start Index just past the opening brace.
|
|
181
|
+
* @returns Index past the matching closer (or source.length on imbalance).
|
|
182
|
+
*/
|
|
183
|
+
function skipMatchingBrace(source, start) {
|
|
184
|
+
let depth = 1;
|
|
185
|
+
for (let index = start; index < source.length; index += 1) {
|
|
186
|
+
const ch = source[index];
|
|
187
|
+
if (ch === '{')
|
|
188
|
+
depth += 1;
|
|
189
|
+
else if (ch === '}') {
|
|
190
|
+
depth -= 1;
|
|
191
|
+
if (depth === 0)
|
|
192
|
+
return index + 1;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return source.length;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* If `header` text (right before an opening brace) names a variant
|
|
199
|
+
* (`@variant <name>`), return that name. Otherwise null.
|
|
200
|
+
* @param header Text between the previous statement and the next `{`.
|
|
201
|
+
* @returns Variant name, or null when this block isn't a `@variant`.
|
|
202
|
+
*/
|
|
203
|
+
function variantNameOf(header) {
|
|
204
|
+
const match = /^@variant\s+([A-Za-z][A-Za-z0-9_-]*)/.exec(header);
|
|
205
|
+
if (!match)
|
|
206
|
+
return null;
|
|
207
|
+
return match[1] ?? null;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Emit `@custom-variant` declarations for every scheme the user declared
|
|
211
|
+
* but hasn't manually registered. Makes Tailwind accept `light:*` /
|
|
212
|
+
* `dark:*` / etc. as valid class-name prefixes.
|
|
213
|
+
* @param css Stripped CSS source used to detect already-declared variants.
|
|
214
|
+
* @param schemes Non-base scheme names from the extracted table.
|
|
215
|
+
* @returns Zero or more `@custom-variant ... ;` lines.
|
|
216
|
+
*/
|
|
217
|
+
function buildCustomVariantDeclarations(css, schemes) {
|
|
218
|
+
if (schemes.length === 0)
|
|
219
|
+
return [];
|
|
220
|
+
const existing = new Set();
|
|
221
|
+
for (const match of css.matchAll(CUSTOM_VARIANT_REGEX))
|
|
222
|
+
existing.add(match[1]);
|
|
223
|
+
const out = [];
|
|
224
|
+
for (const name of schemes) {
|
|
225
|
+
if (!existing.has(name))
|
|
226
|
+
out.push(`@custom-variant ${name} (&:where(.${name}, .${name} *));`);
|
|
227
|
+
}
|
|
228
|
+
return out;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Re-publish variant-scoped tokens into a flat theme block so Tailwind
|
|
232
|
+
* sees every custom-property name it needs. Values come from the base
|
|
233
|
+
* scheme first, with the FIRST declared non-base scheme layering on top
|
|
234
|
+
* — Tailwind only cares about token shape (color vs length), not the
|
|
235
|
+
* exact value, since rnwind does per-scheme substitution at walk time.
|
|
236
|
+
* @param table Extracted scheme → var-name → value table.
|
|
237
|
+
* @param schemes Non-base scheme names (sorted by declaration order).
|
|
238
|
+
* @returns A single `@theme { ... }` block or `null` when there are no tokens.
|
|
239
|
+
*/
|
|
240
|
+
function buildUnifiedThemeBlock(table, schemes) {
|
|
241
|
+
const unifiedVars = new Map();
|
|
242
|
+
const baseTokens = table.get(BASE_SCHEME);
|
|
243
|
+
if (baseTokens)
|
|
244
|
+
for (const [k, v] of baseTokens)
|
|
245
|
+
unifiedVars.set(k, v);
|
|
246
|
+
if (schemes.length > 0) {
|
|
247
|
+
const firstTokens = table.get(schemes[0]);
|
|
248
|
+
if (firstTokens)
|
|
249
|
+
for (const [k, v] of firstTokens)
|
|
250
|
+
unifiedVars.set(k, v);
|
|
251
|
+
}
|
|
252
|
+
if (unifiedVars.size === 0)
|
|
253
|
+
return null;
|
|
254
|
+
const decls = [...unifiedVars].map(([name, value]) => ` ${name}: ${value};`).join('\n');
|
|
255
|
+
return `@theme {\n${decls}\n}`;
|
|
256
|
+
}
|
|
257
|
+
const CUSTOM_VARIANT_REGEX = /@custom-variant\s+([A-Za-z][A-Za-z0-9_-]*)\b/g;
|
|
258
|
+
const VARIANT_OPEN_REGEX = /@variant\s+[A-Za-z0-9_-]+\s*\{/g;
|
|
259
|
+
/**
|
|
260
|
+
* Strip every `@variant <name> { ... }` block (including nested braces)
|
|
261
|
+
* from a CSS source.
|
|
262
|
+
* @param css Raw CSS.
|
|
263
|
+
* @returns CSS without variant blocks.
|
|
264
|
+
*/
|
|
265
|
+
function stripVariantBlocks(css) {
|
|
266
|
+
let out = '';
|
|
267
|
+
let cursor = 0;
|
|
268
|
+
VARIANT_OPEN_REGEX.lastIndex = 0;
|
|
269
|
+
let match;
|
|
270
|
+
while ((match = VARIANT_OPEN_REGEX.exec(css)) !== null) {
|
|
271
|
+
const openEnd = match.index + match[0].length;
|
|
272
|
+
const closeIndex = findMatchingBrace(css, openEnd);
|
|
273
|
+
if (closeIndex === -1)
|
|
274
|
+
break;
|
|
275
|
+
out += css.slice(cursor, match.index);
|
|
276
|
+
cursor = closeIndex + 1;
|
|
277
|
+
VARIANT_OPEN_REGEX.lastIndex = cursor;
|
|
278
|
+
}
|
|
279
|
+
out += css.slice(cursor);
|
|
280
|
+
return out;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Walk forward from `start` tracking brace depth; return the index of the
|
|
284
|
+
* matching `}` for the opener just before `start`.
|
|
285
|
+
* @param source Source string.
|
|
286
|
+
* @param start Index just past the opening `{`.
|
|
287
|
+
* @returns Index of matching `}`, or `-1` on imbalance.
|
|
288
|
+
*/
|
|
289
|
+
function findMatchingBrace(source, start) {
|
|
290
|
+
let depth = 1;
|
|
291
|
+
for (let index = start; index < source.length; index += 1) {
|
|
292
|
+
const ch = source[index];
|
|
293
|
+
if (ch === '{')
|
|
294
|
+
depth += 1;
|
|
295
|
+
else if (ch === '}') {
|
|
296
|
+
depth -= 1;
|
|
297
|
+
if (depth === 0)
|
|
298
|
+
return index;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return -1;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Drop CSS comment blocks from a source. Keeps the token-declaration
|
|
305
|
+
* scanner simple — comments can contain braces / `--` sequences that
|
|
306
|
+
* would otherwise fool it.
|
|
307
|
+
* @param css Raw CSS source.
|
|
308
|
+
* @returns Source with every comment block removed.
|
|
309
|
+
*/
|
|
310
|
+
function stripComments(css) {
|
|
311
|
+
let out = '';
|
|
312
|
+
let index = 0;
|
|
313
|
+
while (index < css.length) {
|
|
314
|
+
const open = css.indexOf('/*', index);
|
|
315
|
+
if (open === -1) {
|
|
316
|
+
out += css.slice(index);
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
319
|
+
out += css.slice(index, open);
|
|
320
|
+
const close = css.indexOf('*/', open + 2);
|
|
321
|
+
if (close === -1)
|
|
322
|
+
break;
|
|
323
|
+
index = close + 2;
|
|
324
|
+
}
|
|
325
|
+
return out;
|
|
326
|
+
}
|
|
327
|
+
/** Synthetic scheme name used for tokens declared outside any `@variant`. */
|
|
328
|
+
const BASE_SCHEME = 'base';
|
|
329
|
+
/**
|
|
330
|
+
* Extract user-declared theme tokens from a CSS source. Scans for:
|
|
331
|
+
* - classic v4 `@theme` blocks (`@theme { --x: y; ... }`)
|
|
332
|
+
* - `@variant <name> { --x: y; ... }` inside any surrounding block
|
|
333
|
+
*
|
|
334
|
+
* Both flavors contribute to the returned table: vars outside any
|
|
335
|
+
* `@variant` go under `'base'`; vars inside `@variant <name>` go under
|
|
336
|
+
* `<name>`.
|
|
337
|
+
*
|
|
338
|
+
* Not a full CSS parser — just enough to recognise the token-declaration
|
|
339
|
+
* shape Tailwind v4 users actually write.
|
|
340
|
+
* @param css Theme CSS source.
|
|
341
|
+
* @returns Scheme → var-name → value map.
|
|
342
|
+
*/
|
|
343
|
+
function extractThemeVars(css) {
|
|
344
|
+
const table = new Map();
|
|
345
|
+
const stripped = stripComments(css);
|
|
346
|
+
walkBlocks(stripped, 0, BASE_SCHEME, table);
|
|
347
|
+
return table;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Build a `<class-in-selector> → <scheme-name>` alias map from any
|
|
351
|
+
* `@custom-variant <name> (<selector>);` declarations in the theme CSS.
|
|
352
|
+
*
|
|
353
|
+
* Tailwind compiles `dark:opacity-100` to a nested rule whose selector is
|
|
354
|
+
* the user's declared variant selector. When the user writes
|
|
355
|
+
* `@custom-variant dark (&:where(.scheme-dark, .scheme-dark *));`, the
|
|
356
|
+
* generated rule references `.scheme-dark` instead of the literal `.dark`
|
|
357
|
+
* class rnwind's selector matcher defaults to. This alias map lets the
|
|
358
|
+
* parser map those custom selector classes back to their scheme name.
|
|
359
|
+
* @param css Theme CSS source.
|
|
360
|
+
* @returns Class-name → scheme-name map. Empty when no `@custom-variant`
|
|
361
|
+
* declarations are present (rnwind's auto-generated defaults already
|
|
362
|
+
* use the literal scheme name and don't need an alias).
|
|
363
|
+
*/
|
|
364
|
+
function extractSchemeAliases(css) {
|
|
365
|
+
const aliases = new Map();
|
|
366
|
+
const stripped = stripComments(css);
|
|
367
|
+
for (const match of stripped.matchAll(CUSTOM_VARIANT_WITH_SELECTOR)) {
|
|
368
|
+
const schemeName = match[1];
|
|
369
|
+
const selectorBody = match[2];
|
|
370
|
+
for (const cls of selectorBody.matchAll(CLASS_IN_SELECTOR)) {
|
|
371
|
+
const className = cls[1];
|
|
372
|
+
if (className === schemeName)
|
|
373
|
+
continue;
|
|
374
|
+
aliases.set(className, schemeName);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
return aliases;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Rewrite the theme CSS so Tailwind's compiler accepts it:
|
|
381
|
+
* 1. Strip every `@variant <name> { ... }` block — Tailwind rejects
|
|
382
|
+
* them inline because `@variant` is a rnwind concept, not a Tailwind
|
|
383
|
+
* at-rule. The scheme-scoped vars are preserved in the extracted
|
|
384
|
+
* {@link ThemeSchemeTable} and substituted at walk time.
|
|
385
|
+
* 2. Prepend `@custom-variant <name> (&:where(.<name>, .<name> *));`
|
|
386
|
+
* for every scheme name we saw, so Tailwind accepts `light:bg-*`,
|
|
387
|
+
* `dark:bg-*`, etc. as valid class-name prefixes without the user
|
|
388
|
+
* having to duplicate the variant declaration.
|
|
389
|
+
* @param css Theme CSS source.
|
|
390
|
+
* @param table Scheme → var-name → value table from {@link extractThemeVars}.
|
|
391
|
+
* @returns CSS ready to feed `@tailwindcss/node`'s compiler.
|
|
392
|
+
*/
|
|
393
|
+
function compileReadyTheme(css, table) {
|
|
394
|
+
const schemes = [...table.keys()].filter((name) => name !== BASE_SCHEME);
|
|
395
|
+
const stripped = stripVariantBlocks(css);
|
|
396
|
+
const prelude = [];
|
|
397
|
+
const customVariants = buildCustomVariantDeclarations(stripped, schemes);
|
|
398
|
+
if (customVariants.length > 0)
|
|
399
|
+
prelude.push(...customVariants);
|
|
400
|
+
const themeBlock = buildUnifiedThemeBlock(table, schemes);
|
|
401
|
+
if (themeBlock)
|
|
402
|
+
prelude.push(themeBlock);
|
|
403
|
+
if (prelude.length === 0)
|
|
404
|
+
return stripped;
|
|
405
|
+
return `${prelude.join('\n')}\n${stripped}`;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
export { BASE_SCHEME, compileReadyTheme, extractSchemeAliases, extractThemeVars };
|
|
409
|
+
//# sourceMappingURL=theme-vars.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-vars.mjs","sources":["../../../../../src/core/parser/theme-vars.ts"],"sourcesContent":["/**\n * Lightweight extractor for user-declared `@theme` and `@variant` blocks\n * inside `:root` / `@layer theme`. Used by the parser to resolve\n * `var(--x)` references that Tailwind's `theme(inline)` leaves\n * unresolved (it only inlines its own known tokens, not user-added ones).\n *\n * Kept regex-free — a linear paren-balanced scan handles nesting without\n * the backtracking risks of `{[^}]*}` patterns. CSS comment blocks are\n * stripped before scanning so slash-star-sequences inside declaration\n * values don't confuse the parser.\n */\n\n/**\n * `@custom-variant <name> ...content-up-to-semicolon...;`\n * The `[^;]+` class is constant-width relative to its input (one char\n * per step, no alternation backtracking), so sonarjs/slow-regex doesn't\n * apply — the flagged pattern is a false positive.\n */\n// eslint-disable-next-line sonarjs/slow-regex\nconst CUSTOM_VARIANT_WITH_SELECTOR = /@custom-variant\\s+([A-Za-z][A-Za-z0-9_-]*)\\s+([^;]+);/g\n/** Bare `.classname` occurrences (one capture group per class). */\nconst CLASS_IN_SELECTOR = /\\.([A-Za-z_][\\w-]*)/g\n\n/**\n * One iteration step of the block walker — decides whether the next\n * interesting token is a declaration, a nested block, or the end of\n * scope. Kept small to keep {@link walkBlocks} below the cognitive\n * complexity threshold.\n */\ninterface WalkStep {\n /** Next scan index, or `-1` to terminate the outer loop. */\n next: number\n}\n\n/**\n * Recursively descend into `{ ... }` blocks, collecting `--x: y;`\n * declarations under the active scheme. When we hit `@variant <name> {`,\n * the child scope's scheme becomes `<name>` until that block closes.\n * @param source Pre-stripped CSS source.\n * @param start Start index of the block body (0 for top-level).\n * @param scheme Active scheme name for declarations inside this scope.\n * @param table Destination table, mutated in place.\n */\nfunction walkBlocks(source: string, start: number, scheme: string, table: ThemeSchemeTable): void {\n let index = start\n while (index < source.length) {\n const step = nextWalkStep(source, index, scheme, table)\n if (step.next === -1) return\n index = step.next\n }\n}\n\n/**\n * Decide the next action at `index`: declaration, nested block, or EOF.\n * @param source Pre-stripped CSS.\n * @param index Current scan index.\n * @param scheme Active scheme name.\n * @param table Destination table.\n * @returns Step descriptor with the next scan index (or -1 for EOF).\n */\nfunction nextWalkStep(source: string, index: number, scheme: string, table: ThemeSchemeTable): WalkStep {\n // Find the next TOP-LEVEL `--` (outside any `( ... )`). That's the only\n // place a custom-property declaration can start. `--foo` that appears\n // inside `var(--foo)` or `calc(... --value(integer) ...)` is part of a\n // value, not a new declaration — accidentally treating it as one would\n // splice into the `@theme` block's declaration list and produce broken\n // CSS that Tailwind rejects downstream.\n const atIndex = findTopLevelDoubleDash(source, index)\n const openIndex = source.indexOf('{', index)\n const closeIndex = source.indexOf('}', index)\n const blockClose = closeIndex === -1 ? Number.POSITIVE_INFINITY : closeIndex\n if (isDeclarationNext(atIndex, openIndex, blockClose)) {\n return { next: consumeDeclaration(source, atIndex, scheme, table) }\n }\n if (openIndex !== -1 && openIndex < blockClose) {\n return { next: enterBlock(source, index, openIndex, scheme, table) }\n }\n return { next: -1 }\n}\n\n/**\n * Find the next `--` in `source` that's not inside a `( ... )` group.\n * Stops early if we hit an unmatched `}` (end of the containing block)\n * — a `--` inside a nested block isn't our concern either.\n * @param source Pre-stripped CSS source.\n * @param from Start index to scan from.\n * @returns Index of the next top-level `--`, or `-1` when none.\n */\nfunction findTopLevelDoubleDash(source: string, from: number): number {\n let parenDepth = 0\n for (let index = from; index < source.length - 1; index += 1) {\n const ch = source.codePointAt(index)\n if (ch === 40 /* ( */) {\n parenDepth += 1\n continue\n }\n if (ch === 41 /* ) */) {\n if (parenDepth > 0) parenDepth -= 1\n continue\n }\n if (ch === 125 /* } */ && parenDepth === 0) return -1\n if (ch === 45 /* - */ && parenDepth === 0 && source.codePointAt(index + 1) === 45) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Whether the next action at the current scan position is a declaration.\n * @param atIndex Index of the next `--`.\n * @param openIndex Index of the next `{`.\n * @param blockClose Index of the next `}` (or `+Infinity` when absent).\n * @returns True when a declaration should be consumed next.\n */\nfunction isDeclarationNext(atIndex: number, openIndex: number, blockClose: number): boolean {\n if (atIndex === -1 || atIndex >= blockClose) return false\n return openIndex === -1 || atIndex < openIndex\n}\n\n/**\n * Handle a nested `{ ... }` block: recurse with the right scheme, then\n * skip past the matching closing brace.\n * @param source Pre-stripped CSS.\n * @param index Scan position at the start of the header.\n * @param openIndex Index of the opening brace.\n * @param scheme Scheme active in the parent scope.\n * @param table Destination table.\n * @returns Index past the matching closing brace.\n */\nfunction enterBlock(source: string, index: number, openIndex: number, scheme: string, table: ThemeSchemeTable): number {\n const header = source.slice(index, openIndex).trim()\n // Skip blocks that define utilities / at-rules that carry declarations\n // meant for a downstream compiler, not custom-property values for the\n // active theme scheme. `@utility name-*` bodies contain Tailwind v4's\n // `--value(...)` meta-syntax which would otherwise confuse the\n // top-level declaration walker and spill into the extracted theme.\n if (isNonThemeAtRule(header)) return skipMatchingBrace(source, openIndex + 1)\n const childScheme = variantNameOf(header) ?? scheme\n walkBlocks(source, openIndex + 1, childScheme, table)\n return skipMatchingBrace(source, openIndex + 1)\n}\n\n/**\n * Whether a block header belongs to an at-rule whose body should be\n * ignored by the theme-var extractor. `@utility` / `@media` / `@keyframes`\n * / `@supports` / `@container` bodies contain property declarations that\n * are NOT custom-property definitions for the active theme.\n * @param header Text between the outer statement and the opening brace.\n * @returns `true` when the block body should be skipped.\n */\nfunction isNonThemeAtRule(header: string): boolean {\n const trimmed = header.trimStart()\n if (!trimmed.startsWith('@')) return false\n const match = /^@([A-Za-z-]+)/.exec(trimmed)\n if (!match) return false\n const name = match[1]!\n return name === 'utility' || name === 'keyframes' || name === 'media' || name === 'supports' || name === 'container'\n}\n\n/**\n * Consume one `--name: value;` declaration starting at `start`. Commits\n * the name/value pair into the active scheme's map and returns the index\n * just past the terminating `;`.\n * @param source CSS source.\n * @param start Index of the `--`.\n * @param scheme Active scheme.\n * @param table Destination table.\n * @returns Next scan index.\n */\nfunction consumeDeclaration(source: string, start: number, scheme: string, table: ThemeSchemeTable): number {\n const colon = source.indexOf(':', start)\n if (colon === -1) return source.length\n const name = source.slice(start, colon).trim()\n const end = source.indexOf(';', colon)\n const stop = end === -1 ? source.indexOf('}', colon) : end\n if (stop === -1) return source.length\n const value = source.slice(colon + 1, stop).trim()\n if (name.startsWith('--')) {\n const bucket = table.get(scheme) ?? new Map()\n bucket.set(name, value)\n table.set(scheme, bucket)\n }\n return stop + 1\n}\n\n/**\n * Walk forward through the source tracking brace depth; return the index\n * just past the matching `}` for the opener at `start - 1`.\n * @param source CSS source.\n * @param start Index just past the opening brace.\n * @returns Index past the matching closer (or source.length on imbalance).\n */\nfunction skipMatchingBrace(source: string, start: number): number {\n let depth = 1\n for (let index = start; index < source.length; index += 1) {\n const ch = source[index]\n if (ch === '{') depth += 1\n else if (ch === '}') {\n depth -= 1\n if (depth === 0) return index + 1\n }\n }\n return source.length\n}\n\n/**\n * If `header` text (right before an opening brace) names a variant\n * (`@variant <name>`), return that name. Otherwise null.\n * @param header Text between the previous statement and the next `{`.\n * @returns Variant name, or null when this block isn't a `@variant`.\n */\nfunction variantNameOf(header: string): string | null {\n const match = /^@variant\\s+([A-Za-z][A-Za-z0-9_-]*)/.exec(header)\n if (!match) return null\n return match[1] ?? null\n}\n\n/**\n * Emit `@custom-variant` declarations for every scheme the user declared\n * but hasn't manually registered. Makes Tailwind accept `light:*` /\n * `dark:*` / etc. as valid class-name prefixes.\n * @param css Stripped CSS source used to detect already-declared variants.\n * @param schemes Non-base scheme names from the extracted table.\n * @returns Zero or more `@custom-variant ... ;` lines.\n */\nfunction buildCustomVariantDeclarations(css: string, schemes: readonly string[]): string[] {\n if (schemes.length === 0) return []\n const existing = new Set<string>()\n for (const match of css.matchAll(CUSTOM_VARIANT_REGEX)) existing.add(match[1]!)\n const out: string[] = []\n for (const name of schemes) {\n if (!existing.has(name)) out.push(`@custom-variant ${name} (&:where(.${name}, .${name} *));`)\n }\n return out\n}\n\n/**\n * Re-publish variant-scoped tokens into a flat theme block so Tailwind\n * sees every custom-property name it needs. Values come from the base\n * scheme first, with the FIRST declared non-base scheme layering on top\n * — Tailwind only cares about token shape (color vs length), not the\n * exact value, since rnwind does per-scheme substitution at walk time.\n * @param table Extracted scheme → var-name → value table.\n * @param schemes Non-base scheme names (sorted by declaration order).\n * @returns A single `@theme { ... }` block or `null` when there are no tokens.\n */\nfunction buildUnifiedThemeBlock(table: ThemeSchemeTable, schemes: readonly string[]): string | null {\n const unifiedVars = new Map<string, string>()\n const baseTokens = table.get(BASE_SCHEME)\n if (baseTokens) for (const [k, v] of baseTokens) unifiedVars.set(k, v)\n if (schemes.length > 0) {\n const firstTokens = table.get(schemes[0]!)\n if (firstTokens) for (const [k, v] of firstTokens) unifiedVars.set(k, v)\n }\n if (unifiedVars.size === 0) return null\n const decls = [...unifiedVars].map(([name, value]) => ` ${name}: ${value};`).join('\\n')\n return `@theme {\\n${decls}\\n}`\n}\n\nconst CUSTOM_VARIANT_REGEX = /@custom-variant\\s+([A-Za-z][A-Za-z0-9_-]*)\\b/g\nconst VARIANT_OPEN_REGEX = /@variant\\s+[A-Za-z0-9_-]+\\s*\\{/g\n\n/**\n * Strip every `@variant <name> { ... }` block (including nested braces)\n * from a CSS source.\n * @param css Raw CSS.\n * @returns CSS without variant blocks.\n */\nfunction stripVariantBlocks(css: string): string {\n let out = ''\n let cursor = 0\n VARIANT_OPEN_REGEX.lastIndex = 0\n let match: RegExpExecArray | null\n while ((match = VARIANT_OPEN_REGEX.exec(css)) !== null) {\n const openEnd = match.index + match[0].length\n const closeIndex = findMatchingBrace(css, openEnd)\n if (closeIndex === -1) break\n out += css.slice(cursor, match.index)\n cursor = closeIndex + 1\n VARIANT_OPEN_REGEX.lastIndex = cursor\n }\n out += css.slice(cursor)\n return out\n}\n\n/**\n * Walk forward from `start` tracking brace depth; return the index of the\n * matching `}` for the opener just before `start`.\n * @param source Source string.\n * @param start Index just past the opening `{`.\n * @returns Index of matching `}`, or `-1` on imbalance.\n */\nfunction findMatchingBrace(source: string, start: number): number {\n let depth = 1\n for (let index = start; index < source.length; index += 1) {\n const ch = source[index]\n if (ch === '{') depth += 1\n else if (ch === '}') {\n depth -= 1\n if (depth === 0) return index\n }\n }\n return -1\n}\n\n/**\n * Drop CSS comment blocks from a source. Keeps the token-declaration\n * scanner simple — comments can contain braces / `--` sequences that\n * would otherwise fool it.\n * @param css Raw CSS source.\n * @returns Source with every comment block removed.\n */\nfunction stripComments(css: string): string {\n let out = ''\n let index = 0\n while (index < css.length) {\n const open = css.indexOf('/*', index)\n if (open === -1) {\n out += css.slice(index)\n break\n }\n out += css.slice(index, open)\n const close = css.indexOf('*/', open + 2)\n if (close === -1) break\n index = close + 2\n }\n return out\n}\n\n/** Scheme name → (var name → value). The base scheme key is `'base'`. */\nexport type ThemeSchemeTable = Map<string, Map<string, string>>\n\n/** Synthetic scheme name used for tokens declared outside any `@variant`. */\nexport const BASE_SCHEME = 'base'\n\n/**\n * Extract user-declared theme tokens from a CSS source. Scans for:\n * - classic v4 `@theme` blocks (`@theme { --x: y; ... }`)\n * - `@variant <name> { --x: y; ... }` inside any surrounding block\n *\n * Both flavors contribute to the returned table: vars outside any\n * `@variant` go under `'base'`; vars inside `@variant <name>` go under\n * `<name>`.\n *\n * Not a full CSS parser — just enough to recognise the token-declaration\n * shape Tailwind v4 users actually write.\n * @param css Theme CSS source.\n * @returns Scheme → var-name → value map.\n */\nexport function extractThemeVars(css: string): ThemeSchemeTable {\n const table: ThemeSchemeTable = new Map()\n const stripped = stripComments(css)\n walkBlocks(stripped, 0, BASE_SCHEME, table)\n return table\n}\n\n/**\n * Build a `<class-in-selector> → <scheme-name>` alias map from any\n * `@custom-variant <name> (<selector>);` declarations in the theme CSS.\n *\n * Tailwind compiles `dark:opacity-100` to a nested rule whose selector is\n * the user's declared variant selector. When the user writes\n * `@custom-variant dark (&:where(.scheme-dark, .scheme-dark *));`, the\n * generated rule references `.scheme-dark` instead of the literal `.dark`\n * class rnwind's selector matcher defaults to. This alias map lets the\n * parser map those custom selector classes back to their scheme name.\n * @param css Theme CSS source.\n * @returns Class-name → scheme-name map. Empty when no `@custom-variant`\n * declarations are present (rnwind's auto-generated defaults already\n * use the literal scheme name and don't need an alias).\n */\nexport function extractSchemeAliases(css: string): Map<string, string> {\n const aliases = new Map<string, string>()\n const stripped = stripComments(css)\n for (const match of stripped.matchAll(CUSTOM_VARIANT_WITH_SELECTOR)) {\n const schemeName = match[1]!\n const selectorBody = match[2]!\n for (const cls of selectorBody.matchAll(CLASS_IN_SELECTOR)) {\n const className = cls[1]!\n if (className === schemeName) continue\n aliases.set(className, schemeName)\n }\n }\n return aliases\n}\n\n/**\n * Rewrite the theme CSS so Tailwind's compiler accepts it:\n * 1. Strip every `@variant <name> { ... }` block — Tailwind rejects\n * them inline because `@variant` is a rnwind concept, not a Tailwind\n * at-rule. The scheme-scoped vars are preserved in the extracted\n * {@link ThemeSchemeTable} and substituted at walk time.\n * 2. Prepend `@custom-variant <name> (&:where(.<name>, .<name> *));`\n * for every scheme name we saw, so Tailwind accepts `light:bg-*`,\n * `dark:bg-*`, etc. as valid class-name prefixes without the user\n * having to duplicate the variant declaration.\n * @param css Theme CSS source.\n * @param table Scheme → var-name → value table from {@link extractThemeVars}.\n * @returns CSS ready to feed `@tailwindcss/node`'s compiler.\n */\nexport function compileReadyTheme(css: string, table: ThemeSchemeTable): string {\n const schemes = [...table.keys()].filter((name) => name !== BASE_SCHEME)\n const stripped = stripVariantBlocks(css)\n const prelude: string[] = []\n const customVariants = buildCustomVariantDeclarations(stripped, schemes)\n if (customVariants.length > 0) prelude.push(...customVariants)\n const themeBlock = buildUnifiedThemeBlock(table, schemes)\n if (themeBlock) prelude.push(themeBlock)\n if (prelude.length === 0) return stripped\n return `${prelude.join('\\n')}\\n${stripped}`\n}\n"],"names":[],"mappings":"AAAA;;;;;;;;;;AAUG;AAEH;;;;;AAKG;AACH;AACA,MAAM,4BAA4B,GAAG,wDAAwD;AAC7F;AACA,MAAM,iBAAiB,GAAG,sBAAsB;AAahD;;;;;;;;AAQG;AACH,SAAS,UAAU,CAAC,MAAc,EAAE,KAAa,EAAE,MAAc,EAAE,KAAuB,EAAA;IACxF,IAAI,KAAK,GAAG,KAAK;AACjB,IAAA,OAAO,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE;AAC5B,QAAA,MAAM,IAAI,GAAG,YAAY,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC;AACvD,QAAA,IAAI,IAAI,CAAC,IAAI,KAAK,EAAE;YAAE;AACtB,QAAA,KAAK,GAAG,IAAI,CAAC,IAAI;IACnB;AACF;AAEA;;;;;;;AAOG;AACH,SAAS,YAAY,CAAC,MAAc,EAAE,KAAa,EAAE,MAAc,EAAE,KAAuB,EAAA;;;;;;;IAO1F,MAAM,OAAO,GAAG,sBAAsB,CAAC,MAAM,EAAE,KAAK,CAAC;IACrD,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC;IAC5C,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC;AAC7C,IAAA,MAAM,UAAU,GAAG,UAAU,KAAK,EAAE,GAAG,MAAM,CAAC,iBAAiB,GAAG,UAAU;IAC5E,IAAI,iBAAiB,CAAC,OAAO,EAAE,SAAS,EAAE,UAAU,CAAC,EAAE;AACrD,QAAA,OAAO,EAAE,IAAI,EAAE,kBAAkB,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE;IACrE;IACA,IAAI,SAAS,KAAK,EAAE,IAAI,SAAS,GAAG,UAAU,EA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E,IAAA,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC;AAAE,QAAA,OAAO,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC;IAC9D,MAAM,UAAU,GAAG,sBAAsB,CAAC,KAAK,EAAE,OAAO,CAAC;AACzD,IAAA,IAAI,UAAU;AAAE,QAAA,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC;AACxC,IAAA,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;AAAE,QAAA,OAAO,QAAQ;IACzC,OAAO,CAAA,EAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,EAAA,EAAK,QAAQ,CAAA,CAAE;AAC7C;;;;"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Token, TokenOrValue } from 'lightningcss';
|
|
2
|
+
import type { RNStyleValue } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Serialize a list of `TokenOrValue` nodes into a CSS-ish value string.
|
|
5
|
+
* Preserves the CSS form closely enough for downstream numeric coercion.
|
|
6
|
+
* @param tokens Token list from an unparsed declaration or custom-property body.
|
|
7
|
+
* @returns Concatenated CSS-value fragment.
|
|
8
|
+
*/
|
|
9
|
+
export declare function serializeTokens(tokens: readonly TokenOrValue[]): string;
|
|
10
|
+
/**
|
|
11
|
+
* Serialize one `TokenOrValue` node back to CSS text. Handles the shapes
|
|
12
|
+
* Tailwind v4 actually emits in utility-class bodies: raw tokens, `var()`
|
|
13
|
+
* references, and numeric functions (`calc()`).
|
|
14
|
+
* @param token One token node.
|
|
15
|
+
* @returns CSS-value fragment.
|
|
16
|
+
*/
|
|
17
|
+
export declare function serializeToken(token: TokenOrValue): string;
|
|
18
|
+
/**
|
|
19
|
+
* Serialize a raw `Token` back to CSS text. `TokenOrValue` with
|
|
20
|
+
* `type === 'token'` wraps one of these; the discriminated union lets
|
|
21
|
+
* TypeScript narrow per branch without casts.
|
|
22
|
+
* @param token Raw token.
|
|
23
|
+
* @returns CSS text fragment.
|
|
24
|
+
*/
|
|
25
|
+
export declare function serializeRawToken(token: Token): string;
|
|
26
|
+
/**
|
|
27
|
+
* Coerce the flat serialization of an unparsed value into an RN scalar.
|
|
28
|
+
* Handles the shapes Tailwind v4 actually emits: bare numbers, pixel /
|
|
29
|
+
* rem lengths, calc ratios, and `var(--x, fallback)` where we recurse into
|
|
30
|
+
* the fallback. Anything else passes through as a string.
|
|
31
|
+
* @param text Serialized CSS value.
|
|
32
|
+
* @returns Coerced primitive, or `null` when unrepresentable.
|
|
33
|
+
*/
|
|
34
|
+
export declare function coerceUnparsedValue(text: string): RNStyleValue | null;
|
|
35
|
+
/**
|
|
36
|
+
* Substitute every `var(--name [, fallback])` reference in `text` with
|
|
37
|
+
* the value from `table` (or the fallback clause when the name misses).
|
|
38
|
+
* Paren-balanced so nested `var(…)` refs don't confuse the scanner.
|
|
39
|
+
* Iterates to a fixed point so multi-hop substitutions land in one call
|
|
40
|
+
* (with a safety cap so a malformed self-referential token can't loop).
|
|
41
|
+
* @param text Raw CSS value.
|
|
42
|
+
* @param table var name → resolved value map.
|
|
43
|
+
* @returns Substituted text.
|
|
44
|
+
*/
|
|
45
|
+
export declare function substituteThemeVars(text: string, table: ReadonlyMap<string, string>): string;
|