zyzz 0.0.0 → 0.0.3
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/LICENSE +21 -0
- package/README.md +380 -0
- package/dist/Config.d.ts +170 -0
- package/dist/Config.d.ts.map +1 -0
- package/dist/Config.js +249 -0
- package/dist/Config.js.map +1 -0
- package/dist/Props.d.ts +7 -0
- package/dist/Props.d.ts.map +1 -0
- package/dist/Props.js +3 -0
- package/dist/Props.js.map +1 -0
- package/dist/Style.d.ts +170 -0
- package/dist/Style.d.ts.map +1 -0
- package/dist/Style.js +325 -0
- package/dist/Style.js.map +1 -0
- package/dist/Theme.d.ts +157 -0
- package/dist/Theme.d.ts.map +1 -0
- package/dist/Theme.js +273 -0
- package/dist/Theme.js.map +1 -0
- package/dist/babel/NativeEdits.d.ts +8 -0
- package/dist/babel/NativeEdits.d.ts.map +1 -0
- package/dist/babel/NativeEdits.js +233 -0
- package/dist/babel/NativeEdits.js.map +1 -0
- package/dist/babel/NativeJsx.d.ts +10 -0
- package/dist/babel/NativeJsx.d.ts.map +1 -0
- package/dist/babel/NativeJsx.js +204 -0
- package/dist/babel/NativeJsx.js.map +1 -0
- package/dist/babel/index.d.ts +51 -0
- package/dist/babel/index.d.ts.map +1 -0
- package/dist/babel/index.js +220 -0
- package/dist/babel/index.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +178 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/compiler/Graph.d.ts +64 -0
- package/dist/compiler/Graph.d.ts.map +1 -0
- package/dist/compiler/Graph.js +1111 -0
- package/dist/compiler/Graph.js.map +1 -0
- package/dist/compiler/Native.d.ts +53 -0
- package/dist/compiler/Native.d.ts.map +1 -0
- package/dist/compiler/Native.js +617 -0
- package/dist/compiler/Native.js.map +1 -0
- package/dist/compiler/Source.d.ts +167 -0
- package/dist/compiler/Source.d.ts.map +1 -0
- package/dist/compiler/Source.js +1012 -0
- package/dist/compiler/Source.js.map +1 -0
- package/dist/compiler/Transform.d.ts +57 -0
- package/dist/compiler/Transform.d.ts.map +1 -0
- package/dist/compiler/Transform.js +886 -0
- package/dist/compiler/Transform.js.map +1 -0
- package/dist/compiler/index.d.ts +13 -0
- package/dist/compiler/index.d.ts.map +1 -0
- package/dist/compiler/index.js +13 -0
- package/dist/compiler/index.js.map +1 -0
- package/dist/compiler/internal/Applications.d.ts +35 -0
- package/dist/compiler/internal/Applications.d.ts.map +1 -0
- package/dist/compiler/internal/Applications.js +248 -0
- package/dist/compiler/internal/Applications.js.map +1 -0
- package/dist/compiler/internal/AtRules.d.ts +8 -0
- package/dist/compiler/internal/AtRules.d.ts.map +1 -0
- package/dist/compiler/internal/AtRules.js +180 -0
- package/dist/compiler/internal/AtRules.js.map +1 -0
- package/dist/compiler/internal/Catalogs.d.ts +19 -0
- package/dist/compiler/internal/Catalogs.d.ts.map +1 -0
- package/dist/compiler/internal/Catalogs.js +68 -0
- package/dist/compiler/internal/Catalogs.js.map +1 -0
- package/dist/compiler/internal/ColorProfiles.d.ts +3 -0
- package/dist/compiler/internal/ColorProfiles.d.ts.map +1 -0
- package/dist/compiler/internal/ColorProfiles.js +84 -0
- package/dist/compiler/internal/ColorProfiles.js.map +1 -0
- package/dist/compiler/internal/CompositionBindings.d.ts +16 -0
- package/dist/compiler/internal/CompositionBindings.d.ts.map +1 -0
- package/dist/compiler/internal/CompositionBindings.js +89 -0
- package/dist/compiler/internal/CompositionBindings.js.map +1 -0
- package/dist/compiler/internal/Compositions.d.ts +32 -0
- package/dist/compiler/internal/Compositions.d.ts.map +1 -0
- package/dist/compiler/internal/Compositions.js +464 -0
- package/dist/compiler/internal/Compositions.js.map +1 -0
- package/dist/compiler/internal/Configurations.d.ts +21 -0
- package/dist/compiler/internal/Configurations.d.ts.map +1 -0
- package/dist/compiler/internal/Configurations.js +171 -0
- package/dist/compiler/internal/Configurations.js.map +1 -0
- package/dist/compiler/internal/Contract.d.ts +27 -0
- package/dist/compiler/internal/Contract.d.ts.map +1 -0
- package/dist/compiler/internal/Contract.js +607 -0
- package/dist/compiler/internal/Contract.js.map +1 -0
- package/dist/compiler/internal/Contributions.d.ts +54 -0
- package/dist/compiler/internal/Contributions.d.ts.map +1 -0
- package/dist/compiler/internal/Contributions.js +1109 -0
- package/dist/compiler/internal/Contributions.js.map +1 -0
- package/dist/compiler/internal/Descriptors.d.ts +15 -0
- package/dist/compiler/internal/Descriptors.d.ts.map +1 -0
- package/dist/compiler/internal/Descriptors.js +183 -0
- package/dist/compiler/internal/Descriptors.js.map +1 -0
- package/dist/compiler/internal/Dynamic.d.ts +14 -0
- package/dist/compiler/internal/Dynamic.d.ts.map +1 -0
- package/dist/compiler/internal/Dynamic.js +172 -0
- package/dist/compiler/internal/Dynamic.js.map +1 -0
- package/dist/compiler/internal/Edits.d.ts +12 -0
- package/dist/compiler/internal/Edits.d.ts.map +1 -0
- package/dist/compiler/internal/Edits.js +5 -0
- package/dist/compiler/internal/Edits.js.map +1 -0
- package/dist/compiler/internal/Expression.d.ts +12 -0
- package/dist/compiler/internal/Expression.d.ts.map +1 -0
- package/dist/compiler/internal/Expression.js +98 -0
- package/dist/compiler/internal/Expression.js.map +1 -0
- package/dist/compiler/internal/Functions.d.ts +5 -0
- package/dist/compiler/internal/Functions.d.ts.map +1 -0
- package/dist/compiler/internal/Functions.js +191 -0
- package/dist/compiler/internal/Functions.js.map +1 -0
- package/dist/compiler/internal/Identifiers.d.ts +9 -0
- package/dist/compiler/internal/Identifiers.d.ts.map +1 -0
- package/dist/compiler/internal/Identifiers.js +106 -0
- package/dist/compiler/internal/Identifiers.js.map +1 -0
- package/dist/compiler/internal/Keyframes.d.ts +5 -0
- package/dist/compiler/internal/Keyframes.d.ts.map +1 -0
- package/dist/compiler/internal/Keyframes.js +51 -0
- package/dist/compiler/internal/Keyframes.js.map +1 -0
- package/dist/compiler/internal/Namespaces.d.ts +17 -0
- package/dist/compiler/internal/Namespaces.d.ts.map +1 -0
- package/dist/compiler/internal/Namespaces.js +265 -0
- package/dist/compiler/internal/Namespaces.js.map +1 -0
- package/dist/compiler/internal/NativeBindings.d.ts +74 -0
- package/dist/compiler/internal/NativeBindings.d.ts.map +1 -0
- package/dist/compiler/internal/NativeBindings.js +117 -0
- package/dist/compiler/internal/NativeBindings.js.map +1 -0
- package/dist/compiler/internal/PackedStyles.d.ts +35 -0
- package/dist/compiler/internal/PackedStyles.d.ts.map +1 -0
- package/dist/compiler/internal/PackedStyles.js +345 -0
- package/dist/compiler/internal/PackedStyles.js.map +1 -0
- package/dist/compiler/internal/Properties.d.ts +5 -0
- package/dist/compiler/internal/Properties.d.ts.map +1 -0
- package/dist/compiler/internal/Properties.js +82 -0
- package/dist/compiler/internal/Properties.js.map +1 -0
- package/dist/compiler/internal/RecipeConditions.d.ts +41 -0
- package/dist/compiler/internal/RecipeConditions.d.ts.map +1 -0
- package/dist/compiler/internal/RecipeConditions.js +82 -0
- package/dist/compiler/internal/RecipeConditions.js.map +1 -0
- package/dist/compiler/internal/RecipePayloads.d.ts +31 -0
- package/dist/compiler/internal/RecipePayloads.d.ts.map +1 -0
- package/dist/compiler/internal/RecipePayloads.js +99 -0
- package/dist/compiler/internal/RecipePayloads.js.map +1 -0
- package/dist/compiler/internal/Recipes.d.ts +32 -0
- package/dist/compiler/internal/Recipes.d.ts.map +1 -0
- package/dist/compiler/internal/Recipes.js +339 -0
- package/dist/compiler/internal/Recipes.js.map +1 -0
- package/dist/compiler/internal/Relative.d.ts +19 -0
- package/dist/compiler/internal/Relative.d.ts.map +1 -0
- package/dist/compiler/internal/Relative.js +62 -0
- package/dist/compiler/internal/Relative.js.map +1 -0
- package/dist/compiler/internal/Scope.d.ts +10 -0
- package/dist/compiler/internal/Scope.d.ts.map +1 -0
- package/dist/compiler/internal/Scope.js +28 -0
- package/dist/compiler/internal/Scope.js.map +1 -0
- package/dist/compiler/internal/Selectors.d.ts +12 -0
- package/dist/compiler/internal/Selectors.d.ts.map +1 -0
- package/dist/compiler/internal/Selectors.js +265 -0
- package/dist/compiler/internal/Selectors.js.map +1 -0
- package/dist/compiler/internal/Static.d.ts +39 -0
- package/dist/compiler/internal/Static.d.ts.map +1 -0
- package/dist/compiler/internal/Static.js +532 -0
- package/dist/compiler/internal/Static.js.map +1 -0
- package/dist/compiler/internal/Stylesheets.d.ts +47 -0
- package/dist/compiler/internal/Stylesheets.d.ts.map +1 -0
- package/dist/compiler/internal/Stylesheets.js +272 -0
- package/dist/compiler/internal/Stylesheets.js.map +1 -0
- package/dist/compiler/internal/Syntax.d.ts +17 -0
- package/dist/compiler/internal/Syntax.d.ts.map +1 -0
- package/dist/compiler/internal/Syntax.js +19 -0
- package/dist/compiler/internal/Syntax.js.map +1 -0
- package/dist/compiler/internal/Themes.d.ts +158 -0
- package/dist/compiler/internal/Themes.d.ts.map +1 -0
- package/dist/compiler/internal/Themes.js +1169 -0
- package/dist/compiler/internal/Themes.js.map +1 -0
- package/dist/compiler/internal/Variables.d.ts +31 -0
- package/dist/compiler/internal/Variables.d.ts.map +1 -0
- package/dist/compiler/internal/Variables.js +376 -0
- package/dist/compiler/internal/Variables.js.map +1 -0
- package/dist/compiler/internal/ViewTransitions.d.ts +3 -0
- package/dist/compiler/internal/ViewTransitions.d.ts.map +1 -0
- package/dist/compiler/internal/ViewTransitions.js +68 -0
- package/dist/compiler/internal/ViewTransitions.js.map +1 -0
- package/dist/cx.d.ts +18 -0
- package/dist/cx.d.ts.map +1 -0
- package/dist/cx.js +60 -0
- package/dist/cx.js.map +1 -0
- package/dist/default.d.ts +3225 -0
- package/dist/default.d.ts.map +1 -0
- package/dist/default.js +547 -0
- package/dist/default.js.map +7 -0
- package/dist/default.js.zyzz.json +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/Authoring.d.ts +26 -0
- package/dist/internal/Authoring.d.ts.map +1 -0
- package/dist/internal/Authoring.js +134 -0
- package/dist/internal/Authoring.js.map +1 -0
- package/dist/internal/Binding.d.ts +64 -0
- package/dist/internal/Binding.d.ts.map +1 -0
- package/dist/internal/Binding.js +27 -0
- package/dist/internal/Binding.js.map +1 -0
- package/dist/internal/BindingDomains.d.ts +11 -0
- package/dist/internal/BindingDomains.d.ts.map +1 -0
- package/dist/internal/BindingDomains.js +459 -0
- package/dist/internal/BindingDomains.js.map +1 -0
- package/dist/internal/Cascade.d.ts +45 -0
- package/dist/internal/Cascade.d.ts.map +1 -0
- package/dist/internal/Cascade.js +165 -0
- package/dist/internal/Cascade.js.map +1 -0
- package/dist/internal/Compound.d.ts +132 -0
- package/dist/internal/Compound.d.ts.map +1 -0
- package/dist/internal/Compound.js +2 -0
- package/dist/internal/Compound.js.map +1 -0
- package/dist/internal/Condition.d.ts +33 -0
- package/dist/internal/Condition.d.ts.map +1 -0
- package/dist/internal/Condition.js +180 -0
- package/dist/internal/Condition.js.map +1 -0
- package/dist/internal/Corner.d.ts +9 -0
- package/dist/internal/Corner.d.ts.map +1 -0
- package/dist/internal/Corner.js +14 -0
- package/dist/internal/Corner.js.map +1 -0
- package/dist/internal/FunctionSyntax.d.ts +27 -0
- package/dist/internal/FunctionSyntax.d.ts.map +1 -0
- package/dist/internal/FunctionSyntax.js +91 -0
- package/dist/internal/FunctionSyntax.js.map +1 -0
- package/dist/internal/FunctionValue.d.ts +19 -0
- package/dist/internal/FunctionValue.d.ts.map +1 -0
- package/dist/internal/FunctionValue.js +2 -0
- package/dist/internal/FunctionValue.js.map +1 -0
- package/dist/internal/Geometry.d.ts +8 -0
- package/dist/internal/Geometry.d.ts.map +1 -0
- package/dist/internal/Geometry.js +2 -0
- package/dist/internal/Geometry.js.map +1 -0
- package/dist/internal/Grid.d.ts +15 -0
- package/dist/internal/Grid.d.ts.map +1 -0
- package/dist/internal/Grid.js +2 -0
- package/dist/internal/Grid.js.map +1 -0
- package/dist/internal/Identifier.d.ts +15 -0
- package/dist/internal/Identifier.d.ts.map +1 -0
- package/dist/internal/Identifier.js +2 -0
- package/dist/internal/Identifier.js.map +1 -0
- package/dist/internal/Identity.d.ts +16 -0
- package/dist/internal/Identity.d.ts.map +1 -0
- package/dist/internal/Identity.js +78 -0
- package/dist/internal/Identity.js.map +1 -0
- package/dist/internal/Lexical.d.ts +89 -0
- package/dist/internal/Lexical.d.ts.map +1 -0
- package/dist/internal/Lexical.js +15 -0
- package/dist/internal/Lexical.js.map +1 -0
- package/dist/internal/Literal.d.ts +3459 -0
- package/dist/internal/Literal.d.ts.map +1 -0
- package/dist/internal/Literal.js +3371 -0
- package/dist/internal/Literal.js.map +1 -0
- package/dist/internal/NativeProperties.d.ts +596 -0
- package/dist/internal/NativeProperties.d.ts.map +1 -0
- package/dist/internal/NativeProperties.js +2 -0
- package/dist/internal/NativeProperties.js.map +1 -0
- package/dist/internal/Numeric.d.ts +23 -0
- package/dist/internal/Numeric.d.ts.map +1 -0
- package/dist/internal/Numeric.js +2 -0
- package/dist/internal/Numeric.js.map +1 -0
- package/dist/internal/Query.d.ts +15 -0
- package/dist/internal/Query.d.ts.map +1 -0
- package/dist/internal/Query.js +58 -0
- package/dist/internal/Query.js.map +1 -0
- package/dist/internal/Recipe.d.ts +17 -0
- package/dist/internal/Recipe.d.ts.map +1 -0
- package/dist/internal/Recipe.js +2 -0
- package/dist/internal/Recipe.js.map +1 -0
- package/dist/internal/RuleReference.d.ts +23 -0
- package/dist/internal/RuleReference.d.ts.map +1 -0
- package/dist/internal/RuleReference.js +65 -0
- package/dist/internal/RuleReference.js.map +1 -0
- package/dist/internal/Scheme.d.ts +12 -0
- package/dist/internal/Scheme.d.ts.map +1 -0
- package/dist/internal/Scheme.js +16 -0
- package/dist/internal/Scheme.js.map +1 -0
- package/dist/internal/Shorthands.d.ts +20 -0
- package/dist/internal/Shorthands.d.ts.map +1 -0
- package/dist/internal/Shorthands.js +50 -0
- package/dist/internal/Shorthands.js.map +1 -0
- package/dist/internal/Targets.d.ts +43 -0
- package/dist/internal/Targets.d.ts.map +1 -0
- package/dist/internal/Targets.js +60 -0
- package/dist/internal/Targets.js.map +1 -0
- package/dist/internal/Token.d.ts +104 -0
- package/dist/internal/Token.d.ts.map +1 -0
- package/dist/internal/Token.js +162 -0
- package/dist/internal/Token.js.map +1 -0
- package/dist/internal/Tuple.d.ts +23 -0
- package/dist/internal/Tuple.d.ts.map +1 -0
- package/dist/internal/Tuple.js +2 -0
- package/dist/internal/Tuple.js.map +1 -0
- package/dist/internal/Typography.d.ts +23 -0
- package/dist/internal/Typography.d.ts.map +1 -0
- package/dist/internal/Typography.js +18 -0
- package/dist/internal/Typography.js.map +1 -0
- package/dist/internal/Value.d.ts +74 -0
- package/dist/internal/Value.d.ts.map +1 -0
- package/dist/internal/Value.js +60 -0
- package/dist/internal/Value.js.map +1 -0
- package/dist/metro/Graph.d.ts +8 -0
- package/dist/metro/Graph.d.ts.map +1 -0
- package/dist/metro/Graph.js +63 -0
- package/dist/metro/Graph.js.map +1 -0
- package/dist/metro/Watch.d.ts +21 -0
- package/dist/metro/Watch.d.ts.map +1 -0
- package/dist/metro/Watch.js +51 -0
- package/dist/metro/Watch.js.map +1 -0
- package/dist/metro/index.d.ts +30 -0
- package/dist/metro/index.d.ts.map +1 -0
- package/dist/metro/index.js +52 -0
- package/dist/metro/index.js.map +1 -0
- package/dist/metro/transformer.d.ts +21 -0
- package/dist/metro/transformer.d.ts.map +1 -0
- package/dist/metro/transformer.js +71 -0
- package/dist/metro/transformer.js.map +1 -0
- package/dist/next/index.d.ts +18 -0
- package/dist/next/index.d.ts.map +1 -0
- package/dist/next/index.js +92 -0
- package/dist/next/index.js.map +1 -0
- package/dist/next/loader.d.ts +16 -0
- package/dist/next/loader.d.ts.map +1 -0
- package/dist/next/loader.js +282 -0
- package/dist/next/loader.js.map +1 -0
- package/dist/node/Host.d.ts +80 -0
- package/dist/node/Host.d.ts.map +1 -0
- package/dist/node/Host.js +882 -0
- package/dist/node/Host.js.map +1 -0
- package/dist/node/index.d.ts +7 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +7 -0
- package/dist/node/index.js.map +1 -0
- package/dist/react-native/Host.d.ts +76 -0
- package/dist/react-native/Host.d.ts.map +1 -0
- package/dist/react-native/Host.js +209 -0
- package/dist/react-native/Host.js.map +1 -0
- package/dist/react-native/StyleSheet.d.ts +226 -0
- package/dist/react-native/StyleSheet.d.ts.map +1 -0
- package/dist/react-native/StyleSheet.js +606 -0
- package/dist/react-native/StyleSheet.js.map +1 -0
- package/dist/react-native/Variants.d.ts +38 -0
- package/dist/react-native/Variants.d.ts.map +1 -0
- package/dist/react-native/Variants.js +66 -0
- package/dist/react-native/Variants.js.map +1 -0
- package/dist/react-native/index.d.ts +8 -0
- package/dist/react-native/index.d.ts.map +1 -0
- package/dist/react-native/index.js +8 -0
- package/dist/react-native/index.js.map +1 -0
- package/dist/react-native/internal/Color.d.ts +7 -0
- package/dist/react-native/internal/Color.d.ts.map +1 -0
- package/dist/react-native/internal/Color.js +93 -0
- package/dist/react-native/internal/Color.js.map +1 -0
- package/dist/react-native/internal/NativeSchema.d.ts +5138 -0
- package/dist/react-native/internal/NativeSchema.d.ts.map +1 -0
- package/dist/react-native/internal/NativeSchema.js +3097 -0
- package/dist/react-native/internal/NativeSchema.js.map +1 -0
- package/dist/react-native/internal/Scalar.d.ts +95 -0
- package/dist/react-native/internal/Scalar.d.ts.map +1 -0
- package/dist/react-native/internal/Scalar.js +199 -0
- package/dist/react-native/internal/Scalar.js.map +1 -0
- package/dist/react-native/internal/Values.d.ts +5 -0
- package/dist/react-native/internal/Values.d.ts.map +1 -0
- package/dist/react-native/internal/Values.js +65 -0
- package/dist/react-native/internal/Values.js.map +1 -0
- package/dist/react-native/react.d.ts +22 -0
- package/dist/react-native/react.d.ts.map +1 -0
- package/dist/react-native/react.js +26 -0
- package/dist/react-native/react.js.map +1 -0
- package/dist/reset.css +244 -0
- package/dist/runtime/Appearance.d.ts +55 -0
- package/dist/runtime/Appearance.d.ts.map +1 -0
- package/dist/runtime/Appearance.js +84 -0
- package/dist/runtime/Appearance.js.map +1 -0
- package/dist/runtime/Composition.d.ts +46 -0
- package/dist/runtime/Composition.d.ts.map +1 -0
- package/dist/runtime/Composition.js +52 -0
- package/dist/runtime/Composition.js.map +1 -0
- package/dist/runtime/CompositionHtml.d.ts +15 -0
- package/dist/runtime/CompositionHtml.d.ts.map +1 -0
- package/dist/runtime/CompositionHtml.js +20 -0
- package/dist/runtime/CompositionHtml.js.map +1 -0
- package/dist/runtime/ConditionalRecipe.d.ts +30 -0
- package/dist/runtime/ConditionalRecipe.d.ts.map +1 -0
- package/dist/runtime/ConditionalRecipe.js +39 -0
- package/dist/runtime/ConditionalRecipe.js.map +1 -0
- package/dist/runtime/Dynamic.d.ts +19 -0
- package/dist/runtime/Dynamic.d.ts.map +1 -0
- package/dist/runtime/Dynamic.js +22 -0
- package/dist/runtime/Dynamic.js.map +1 -0
- package/dist/runtime/Html.d.ts +32 -0
- package/dist/runtime/Html.d.ts.map +1 -0
- package/dist/runtime/Html.js +63 -0
- package/dist/runtime/Html.js.map +1 -0
- package/dist/runtime/Native.d.ts +48 -0
- package/dist/runtime/Native.d.ts.map +1 -0
- package/dist/runtime/Native.js +78 -0
- package/dist/runtime/Native.js.map +1 -0
- package/dist/runtime/NativeContext.d.ts +17 -0
- package/dist/runtime/NativeContext.d.ts.map +1 -0
- package/dist/runtime/NativeContext.js +47 -0
- package/dist/runtime/NativeContext.js.map +1 -0
- package/dist/runtime/NativeDynamic.d.ts +47 -0
- package/dist/runtime/NativeDynamic.d.ts.map +1 -0
- package/dist/runtime/NativeDynamic.js +141 -0
- package/dist/runtime/NativeDynamic.js.map +1 -0
- package/dist/runtime/PayloadRecipe.d.ts +22 -0
- package/dist/runtime/PayloadRecipe.d.ts.map +1 -0
- package/dist/runtime/PayloadRecipe.js +59 -0
- package/dist/runtime/PayloadRecipe.js.map +1 -0
- package/dist/runtime/Props.d.ts +21 -0
- package/dist/runtime/Props.d.ts.map +1 -0
- package/dist/runtime/Props.js +17 -0
- package/dist/runtime/Props.js.map +1 -0
- package/dist/runtime/Recipe.d.ts +52 -0
- package/dist/runtime/Recipe.d.ts.map +1 -0
- package/dist/runtime/Recipe.js +30 -0
- package/dist/runtime/Recipe.js.map +1 -0
- package/dist/runtime/Selection.d.ts +31 -0
- package/dist/runtime/Selection.d.ts.map +1 -0
- package/dist/runtime/Selection.js +30 -0
- package/dist/runtime/Selection.js.map +1 -0
- package/dist/runtime/Variable.d.ts +6 -0
- package/dist/runtime/Variable.d.ts.map +1 -0
- package/dist/runtime/Variable.js +10 -0
- package/dist/runtime/Variable.js.map +1 -0
- package/dist/runtime/index.d.ts +33 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +33 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/styleFunction.d.ts +72 -0
- package/dist/styleFunction.d.ts.map +1 -0
- package/dist/styleFunction.js +18 -0
- package/dist/styleFunction.js.map +1 -0
- package/dist/themes/LICENSE.tailwind +21 -0
- package/dist/variable.d.ts +50 -0
- package/dist/variable.d.ts.map +1 -0
- package/dist/variable.js +20 -0
- package/dist/variable.js.map +1 -0
- package/dist/variants.d.ts +84 -0
- package/dist/variants.d.ts.map +1 -0
- package/dist/variants.js +21 -0
- package/dist/variants.js.map +1 -0
- package/dist/vite/index.d.ts +24 -0
- package/dist/vite/index.d.ts.map +1 -0
- package/dist/vite/index.js +1089 -0
- package/dist/vite/index.js.map +1 -0
- package/dist/web/Css.d.ts +81 -0
- package/dist/web/Css.d.ts.map +1 -0
- package/dist/web/Css.js +593 -0
- package/dist/web/Css.js.map +1 -0
- package/dist/web/colorProfile.d.ts +28 -0
- package/dist/web/colorProfile.d.ts.map +1 -0
- package/dist/web/colorProfile.js +8 -0
- package/dist/web/colorProfile.js.map +1 -0
- package/dist/web/counterStyle.d.ts +48 -0
- package/dist/web/counterStyle.d.ts.map +1 -0
- package/dist/web/counterStyle.js +8 -0
- package/dist/web/counterStyle.js.map +1 -0
- package/dist/web/cssFunction.d.ts +80 -0
- package/dist/web/cssFunction.d.ts.map +1 -0
- package/dist/web/cssFunction.js +18 -0
- package/dist/web/cssFunction.js.map +1 -0
- package/dist/web/customMedia.d.ts +12 -0
- package/dist/web/customMedia.d.ts.map +1 -0
- package/dist/web/customMedia.js +7 -0
- package/dist/web/customMedia.js.map +1 -0
- package/dist/web/fontFace.d.ts +26 -0
- package/dist/web/fontFace.d.ts.map +1 -0
- package/dist/web/fontFace.js +7 -0
- package/dist/web/fontFace.js.map +1 -0
- package/dist/web/fontFeatureValues.d.ts +40 -0
- package/dist/web/fontFeatureValues.d.ts.map +1 -0
- package/dist/web/fontFeatureValues.js +7 -0
- package/dist/web/fontFeatureValues.js.map +1 -0
- package/dist/web/fontPaletteValues.d.ts +21 -0
- package/dist/web/fontPaletteValues.d.ts.map +1 -0
- package/dist/web/fontPaletteValues.js +9 -0
- package/dist/web/fontPaletteValues.js.map +1 -0
- package/dist/web/global.d.ts +19 -0
- package/dist/web/global.d.ts.map +1 -0
- package/dist/web/global.js +6 -0
- package/dist/web/global.js.map +1 -0
- package/dist/web/importCss.d.ts +18 -0
- package/dist/web/importCss.d.ts.map +1 -0
- package/dist/web/importCss.js +7 -0
- package/dist/web/importCss.js.map +1 -0
- package/dist/web/index.d.ts +22 -0
- package/dist/web/index.d.ts.map +1 -0
- package/dist/web/index.js +22 -0
- package/dist/web/index.js.map +1 -0
- package/dist/web/internal/Block.d.ts +18 -0
- package/dist/web/internal/Block.d.ts.map +1 -0
- package/dist/web/internal/Block.js +13 -0
- package/dist/web/internal/Block.js.map +1 -0
- package/dist/web/internal/ClassName.d.ts +19 -0
- package/dist/web/internal/ClassName.d.ts.map +1 -0
- package/dist/web/internal/ClassName.js +77 -0
- package/dist/web/internal/ClassName.js.map +1 -0
- package/dist/web/internal/Context.d.ts +11 -0
- package/dist/web/internal/Context.d.ts.map +1 -0
- package/dist/web/internal/Context.js +2 -0
- package/dist/web/internal/Context.js.map +1 -0
- package/dist/web/internal/Contributions.d.ts +70 -0
- package/dist/web/internal/Contributions.d.ts.map +1 -0
- package/dist/web/internal/Contributions.js +109 -0
- package/dist/web/internal/Contributions.js.map +1 -0
- package/dist/web/internal/Namespace.d.ts +13 -0
- package/dist/web/internal/Namespace.d.ts.map +1 -0
- package/dist/web/internal/Namespace.js +13 -0
- package/dist/web/internal/Namespace.js.map +1 -0
- package/dist/web/internal/Themes.d.ts +13 -0
- package/dist/web/internal/Themes.d.ts.map +1 -0
- package/dist/web/internal/Themes.js +96 -0
- package/dist/web/internal/Themes.js.map +1 -0
- package/dist/web/keyframes.d.ts +14 -0
- package/dist/web/keyframes.d.ts.map +1 -0
- package/dist/web/keyframes.js +8 -0
- package/dist/web/keyframes.js.map +1 -0
- package/dist/web/layers.d.ts +4 -0
- package/dist/web/layers.d.ts.map +1 -0
- package/dist/web/layers.js +7 -0
- package/dist/web/layers.js.map +1 -0
- package/dist/web/namespace.d.ts +14 -0
- package/dist/web/namespace.d.ts.map +1 -0
- package/dist/web/namespace.js +7 -0
- package/dist/web/namespace.js.map +1 -0
- package/dist/web/page.d.ts +38 -0
- package/dist/web/page.d.ts.map +1 -0
- package/dist/web/page.js +7 -0
- package/dist/web/page.js.map +1 -0
- package/dist/web/positionTry.d.ts +14 -0
- package/dist/web/positionTry.d.ts.map +1 -0
- package/dist/web/positionTry.js +9 -0
- package/dist/web/positionTry.js.map +1 -0
- package/dist/web/property.d.ts +24 -0
- package/dist/web/property.d.ts.map +1 -0
- package/dist/web/property.js +7 -0
- package/dist/web/property.js.map +1 -0
- package/dist/web/viewTransition.d.ts +29 -0
- package/dist/web/viewTransition.d.ts.map +1 -0
- package/dist/web/viewTransition.js +7 -0
- package/dist/web/viewTransition.js.map +1 -0
- package/package.json +136 -10
- package/src/Config.ts +691 -0
- package/src/Props.ts +8 -0
- package/src/Style.ts +812 -0
- package/src/Theme.ts +784 -0
- package/src/babel/NativeEdits.ts +273 -0
- package/src/babel/NativeJsx.ts +260 -0
- package/src/babel/index.ts +332 -0
- package/src/cli/index.ts +196 -0
- package/src/compiler/Graph.ts +1586 -0
- package/src/compiler/Native.ts +801 -0
- package/src/compiler/Source.ts +1579 -0
- package/src/compiler/Transform.ts +1241 -0
- package/src/compiler/index.ts +12 -0
- package/src/compiler/internal/Applications.ts +378 -0
- package/src/compiler/internal/AtRules.ts +202 -0
- package/src/compiler/internal/Catalogs.ts +114 -0
- package/src/compiler/internal/ColorProfiles.ts +93 -0
- package/src/compiler/internal/CompositionBindings.ts +120 -0
- package/src/compiler/internal/Compositions.ts +629 -0
- package/src/compiler/internal/Configurations.ts +244 -0
- package/src/compiler/internal/Contract.ts +860 -0
- package/src/compiler/internal/Contributions.ts +1507 -0
- package/src/compiler/internal/Descriptors.ts +238 -0
- package/src/compiler/internal/Dynamic.ts +266 -0
- package/src/compiler/internal/Edits.ts +13 -0
- package/src/compiler/internal/Expression.ts +135 -0
- package/src/compiler/internal/Functions.ts +206 -0
- package/src/compiler/internal/Identifiers.ts +124 -0
- package/src/compiler/internal/Keyframes.ts +62 -0
- package/src/compiler/internal/Namespaces.ts +296 -0
- package/src/compiler/internal/NativeBindings.ts +151 -0
- package/src/compiler/internal/PackedStyles.ts +464 -0
- package/src/compiler/internal/Properties.ts +121 -0
- package/src/compiler/internal/RecipeConditions.ts +139 -0
- package/src/compiler/internal/RecipePayloads.ts +132 -0
- package/src/compiler/internal/Recipes.ts +531 -0
- package/src/compiler/internal/Relative.ts +87 -0
- package/src/compiler/internal/Scope.ts +36 -0
- package/src/compiler/internal/Selectors.ts +334 -0
- package/src/compiler/internal/Static.ts +783 -0
- package/src/compiler/internal/Stylesheets.ts +361 -0
- package/src/compiler/internal/Syntax.ts +31 -0
- package/src/compiler/internal/Themes.ts +1794 -0
- package/src/compiler/internal/Variables.ts +497 -0
- package/src/compiler/internal/ViewTransitions.ts +82 -0
- package/src/cx.ts +98 -0
- package/src/default.ts +1177 -0
- package/src/index.ts +20 -0
- package/src/internal/Authoring.ts +199 -0
- package/src/internal/Binding.ts +187 -0
- package/src/internal/BindingDomains.ts +458 -0
- package/src/internal/Cascade.ts +165 -0
- package/src/internal/Compound.ts +522 -0
- package/src/internal/Condition.ts +283 -0
- package/src/internal/Corner.ts +17 -0
- package/src/internal/FunctionSyntax.ts +271 -0
- package/src/internal/FunctionValue.ts +96 -0
- package/src/internal/Geometry.ts +30 -0
- package/src/internal/Grid.ts +67 -0
- package/src/internal/Identifier.ts +14 -0
- package/src/internal/Identity.ts +89 -0
- package/src/internal/Lexical.ts +202 -0
- package/src/internal/Literal.ts +3820 -0
- package/src/internal/NativeProperties.ts +936 -0
- package/src/internal/Numeric.ts +77 -0
- package/src/internal/Query.ts +87 -0
- package/src/internal/Recipe.ts +17 -0
- package/src/internal/RuleReference.ts +102 -0
- package/src/internal/Scheme.ts +20 -0
- package/src/internal/Shorthands.ts +122 -0
- package/src/internal/Targets.ts +162 -0
- package/src/internal/Token.ts +380 -0
- package/src/internal/Tuple.ts +29 -0
- package/src/internal/Typography.ts +51 -0
- package/src/internal/Value.ts +320 -0
- package/src/metro/Graph.ts +78 -0
- package/src/metro/Watch.ts +88 -0
- package/src/metro/index.ts +99 -0
- package/src/metro/transformer.ts +97 -0
- package/src/next/index.ts +114 -0
- package/src/next/loader.ts +369 -0
- package/src/node/Host.ts +1204 -0
- package/src/node/index.ts +6 -0
- package/src/react-native/Host.ts +289 -0
- package/src/react-native/StyleSheet.ts +1084 -0
- package/src/react-native/Variants.ts +122 -0
- package/src/react-native/index.ts +7 -0
- package/src/react-native/internal/Color.ts +110 -0
- package/src/react-native/internal/NativeSchema.ts +3096 -0
- package/src/react-native/internal/Scalar.ts +253 -0
- package/src/react-native/internal/Values.ts +87 -0
- package/src/react-native/react.ts +47 -0
- package/src/reset.css +244 -0
- package/src/runtime/Appearance.ts +155 -0
- package/src/runtime/Composition.ts +87 -0
- package/src/runtime/CompositionHtml.ts +38 -0
- package/src/runtime/ConditionalRecipe.ts +70 -0
- package/src/runtime/Dynamic.ts +51 -0
- package/src/runtime/Html.ts +91 -0
- package/src/runtime/Native.ts +144 -0
- package/src/runtime/NativeContext.ts +74 -0
- package/src/runtime/NativeDynamic.ts +246 -0
- package/src/runtime/PayloadRecipe.ts +96 -0
- package/src/runtime/Props.ts +33 -0
- package/src/runtime/Recipe.ts +74 -0
- package/src/runtime/Selection.ts +82 -0
- package/src/runtime/Variable.ts +15 -0
- package/src/runtime/index.ts +45 -0
- package/src/styleFunction.ts +138 -0
- package/src/themes/LICENSE.tailwind +21 -0
- package/src/variable.ts +105 -0
- package/src/variants.ts +218 -0
- package/src/vite/index.ts +1473 -0
- package/src/web/Css.ts +801 -0
- package/src/web/colorProfile.ts +60 -0
- package/src/web/counterStyle.ts +82 -0
- package/src/web/cssFunction.ts +181 -0
- package/src/web/customMedia.ts +16 -0
- package/src/web/fontFace.ts +41 -0
- package/src/web/fontFeatureValues.ts +79 -0
- package/src/web/fontPaletteValues.ts +42 -0
- package/src/web/global.ts +39 -0
- package/src/web/importCss.ts +23 -0
- package/src/web/index.ts +22 -0
- package/src/web/internal/Block.ts +29 -0
- package/src/web/internal/ClassName.ts +112 -0
- package/src/web/internal/Context.ts +16 -0
- package/src/web/internal/Contributions.ts +219 -0
- package/src/web/internal/Namespace.ts +21 -0
- package/src/web/internal/Themes.ts +133 -0
- package/src/web/keyframes.ts +43 -0
- package/src/web/layers.ts +6 -0
- package/src/web/namespace.ts +19 -0
- package/src/web/page.ts +140 -0
- package/src/web/positionTry.ts +71 -0
- package/src/web/property.ts +35 -0
- package/src/web/viewTransition.ts +89 -0
package/src/Theme.ts
ADDED
|
@@ -0,0 +1,784 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines typed token contracts and compatible immutable theme overrides.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
import { MissingTransformError, style } from './styleFunction.js'
|
|
6
|
+
import * as Authoring from './internal/Authoring.js'
|
|
7
|
+
import * as Identity from './internal/Identity.js'
|
|
8
|
+
import { variants } from './variants.js'
|
|
9
|
+
import type * as Binding from './internal/Binding.js'
|
|
10
|
+
import type * as Literal from './internal/Literal.js'
|
|
11
|
+
import * as Query from './internal/Query.js'
|
|
12
|
+
import * as Token from './internal/Token.js'
|
|
13
|
+
import * as Typography from './internal/Typography.js'
|
|
14
|
+
import type * as Value from './internal/Value.js'
|
|
15
|
+
import type * as Style from './Style.js'
|
|
16
|
+
|
|
17
|
+
/** Complete color-scheme pair or a shared color. */
|
|
18
|
+
export type Color =
|
|
19
|
+
| Literal.Color
|
|
20
|
+
| { readonly dark: Literal.Color; readonly light: Literal.Color }
|
|
21
|
+
|
|
22
|
+
/** Theme-bound authoring signature; execution requires source rewriting. */
|
|
23
|
+
export type StyleFactory<tokens extends Tokens> = {
|
|
24
|
+
(): style.ReturnType
|
|
25
|
+
<
|
|
26
|
+
const values extends Record<string, string | number>,
|
|
27
|
+
const styles extends Record<string, unknown>,
|
|
28
|
+
>(
|
|
29
|
+
styles: ((
|
|
30
|
+
values: values,
|
|
31
|
+
) => styles &
|
|
32
|
+
NoInfer<Style.Accepted<styles, tokens> & Binding.Checked<styles>>) &
|
|
33
|
+
(values extends Binding.Inputs<values> ? unknown : never),
|
|
34
|
+
options?: style.DefinitionOptions,
|
|
35
|
+
): style.Dynamic<values>
|
|
36
|
+
<const styles extends Record<string, unknown>>(
|
|
37
|
+
styles: styles & NoInfer<Style.Accepted<styles, tokens>>,
|
|
38
|
+
options?: style.DefinitionOptions,
|
|
39
|
+
): style.ReturnType
|
|
40
|
+
<const styles extends Style.Properties<tokens>>(
|
|
41
|
+
styles: styles &
|
|
42
|
+
NoInfer<
|
|
43
|
+
(Style.Properties<tokens> extends styles
|
|
44
|
+
? unknown
|
|
45
|
+
: Style.Accepted<styles, tokens>) &
|
|
46
|
+
(Extract<styles, (...args: never[]) => unknown> extends never
|
|
47
|
+
? unknown
|
|
48
|
+
: never)
|
|
49
|
+
>,
|
|
50
|
+
options?: style.DefinitionOptions,
|
|
51
|
+
): style.ReturnType
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Defines scalar tokens and typography sets without defaults or environment access.
|
|
56
|
+
* Colors currently use the supported literal color grammar; spacing and radius
|
|
57
|
+
* values use nonnegative literal lengths or zero. Nested palettes are supported.
|
|
58
|
+
* @throws {InvalidError} If groups, paths, values, or data records are invalid.
|
|
59
|
+
*/
|
|
60
|
+
export function define<const tokens extends Tokens>(
|
|
61
|
+
tokens: tokens & NoInfer<Validated<tokens>>,
|
|
62
|
+
options: style.DefinitionOptions = {},
|
|
63
|
+
): Definition<tokens> {
|
|
64
|
+
return build(
|
|
65
|
+
tokens,
|
|
66
|
+
Object.freeze(
|
|
67
|
+
options.id === undefined
|
|
68
|
+
? {}
|
|
69
|
+
: {
|
|
70
|
+
[Token.identity]: Identity.requireId(options.id, 'Theme.define'),
|
|
71
|
+
[Token.complete]: true as const,
|
|
72
|
+
},
|
|
73
|
+
),
|
|
74
|
+
undefined,
|
|
75
|
+
undefined,
|
|
76
|
+
options.id === undefined
|
|
77
|
+
? undefined
|
|
78
|
+
: Identity.requireId(options.id, 'Theme.define'),
|
|
79
|
+
) as unknown as Definition<tokens>
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** A theme contract with immutable, property-aware portable token references. */
|
|
83
|
+
export type Definition<
|
|
84
|
+
tokens extends Tokens = Tokens,
|
|
85
|
+
boundStyle extends (...args: never[]) => unknown = StyleFactory<tokens>,
|
|
86
|
+
boundVariants extends (...args: never[]) => unknown = variants.Bound<tokens>,
|
|
87
|
+
> = {
|
|
88
|
+
/** Compiled scope class; reading untransformed authoring throws. */
|
|
89
|
+
readonly className: string
|
|
90
|
+
/** Token-aware callable authoring boundary, replaced by the source compiler. */
|
|
91
|
+
readonly style: boundStyle
|
|
92
|
+
/** Internal contract and resolved values, carried without a registry. */
|
|
93
|
+
readonly [Token.definition]: Token.Metadata
|
|
94
|
+
/** Inferred references for use in Style.define declarations. */
|
|
95
|
+
readonly tokens: References<tokens>
|
|
96
|
+
/** Token-aware single-element recipe authoring. */
|
|
97
|
+
readonly variants: boundVariants
|
|
98
|
+
/** Web variable references; source templates retain their identity and fallback. */
|
|
99
|
+
readonly vars: Token.Variables<References<tokens>>
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Overrides existing leaves while retaining the base theme's token identities.
|
|
104
|
+
* Omitted leaves inherit resolved values. Color overrides replace complete pairs.
|
|
105
|
+
* @throws {InvalidError} If the base is invalid or overrides alter its contract.
|
|
106
|
+
*/
|
|
107
|
+
export function extend<
|
|
108
|
+
const tokens extends Tokens,
|
|
109
|
+
const overrides extends Record<string, unknown>,
|
|
110
|
+
const boundStyle extends (...args: never[]) => unknown = StyleFactory<tokens>,
|
|
111
|
+
const boundVariants extends (...args: never[]) => unknown =
|
|
112
|
+
variants.Bound<tokens>,
|
|
113
|
+
>(
|
|
114
|
+
theme: Definition<tokens, boundStyle, boundVariants>,
|
|
115
|
+
overrides: overrides &
|
|
116
|
+
NoInfer<Exact<overrides, Overrides<tokens>>> &
|
|
117
|
+
NoInfer<Validated<overrides>>,
|
|
118
|
+
): Definition<tokens, boundStyle, boundVariants> {
|
|
119
|
+
if (!theme || typeof theme !== 'object')
|
|
120
|
+
throw new InvalidError([], 'Expected a theme definition.')
|
|
121
|
+
|
|
122
|
+
const data = Object.getOwnPropertyDescriptor(theme, Token.definition)
|
|
123
|
+
?.value as Token.Metadata | undefined
|
|
124
|
+
if (!data) throw new InvalidError([], 'Expected a theme definition.')
|
|
125
|
+
|
|
126
|
+
return build(
|
|
127
|
+
overrides,
|
|
128
|
+
data.contract,
|
|
129
|
+
data.values,
|
|
130
|
+
data.queries,
|
|
131
|
+
) as unknown as Definition<tokens, boundStyle, boundVariants>
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
type Exact<input, shape> = {
|
|
135
|
+
[key in keyof input]: key extends keyof shape
|
|
136
|
+
? NonNullable<shape[key]> extends string | number
|
|
137
|
+
? Required<shape>[key]
|
|
138
|
+
: input[key] extends readonly unknown[] | ((...args: never[]) => unknown)
|
|
139
|
+
? never
|
|
140
|
+
: input[key] extends object
|
|
141
|
+
? shape[key] extends Color | undefined
|
|
142
|
+
? Color
|
|
143
|
+
: Exact<input[key], NonNullable<shape[key]>>
|
|
144
|
+
: Required<shape>[key]
|
|
145
|
+
: never
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** Invalid token data with an unambiguous authored path. */
|
|
149
|
+
export class InvalidError extends Error {
|
|
150
|
+
/** Creates an immutable diagnostic path without reading token values. */
|
|
151
|
+
constructor(path: readonly string[], message: string) {
|
|
152
|
+
super(`${JSON.stringify(path)}: ${message}`)
|
|
153
|
+
this.path = Object.freeze([...path])
|
|
154
|
+
}
|
|
155
|
+
/** Stable namespaced error identifier. */
|
|
156
|
+
override name = 'Theme.InvalidError'
|
|
157
|
+
/** Group and nested keys identifying the failure. */
|
|
158
|
+
readonly path: readonly string[]
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** Existing paths with widened values and optional branches. */
|
|
162
|
+
export type Overrides<tokens> = {
|
|
163
|
+
readonly [group in keyof tokens]?: OverrideTree<tokens[group], group>
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
type OverrideTree<tree, group> = tree extends string | number
|
|
167
|
+
? Scalar<group>
|
|
168
|
+
: tree extends { readonly dark: string; readonly light: string }
|
|
169
|
+
? Color
|
|
170
|
+
: {
|
|
171
|
+
readonly [key in keyof tree]?: OverrideTree<
|
|
172
|
+
tree[key],
|
|
173
|
+
group extends 'typography'
|
|
174
|
+
? key extends Typography.Property
|
|
175
|
+
? key
|
|
176
|
+
: group
|
|
177
|
+
: group
|
|
178
|
+
>
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** Nested palette or scale data. */
|
|
182
|
+
export type Palette<leaf> = { readonly [key: string]: leaf | Palette<leaf> }
|
|
183
|
+
|
|
184
|
+
/** Portable reference restricted to its token group. */
|
|
185
|
+
export type Reference<group extends Token.Group = Token.Group> =
|
|
186
|
+
Token.Reference<group>
|
|
187
|
+
|
|
188
|
+
/** The inferred tree replaces scalar values and scheme pairs with references. */
|
|
189
|
+
export type References<tokens> = {
|
|
190
|
+
readonly [group in keyof tokens as group extends Token.Group | 'typography'
|
|
191
|
+
? group
|
|
192
|
+
: never]: ReferenceTree<
|
|
193
|
+
tokens[group],
|
|
194
|
+
Extract<group, Token.Group | 'typography'>
|
|
195
|
+
>
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
type ReferenceTree<
|
|
199
|
+
tree,
|
|
200
|
+
group extends Token.Group | 'typography',
|
|
201
|
+
> = tree extends
|
|
202
|
+
| string
|
|
203
|
+
| number
|
|
204
|
+
| { readonly dark: string; readonly light: string }
|
|
205
|
+
? Reference<Extract<group, Token.Group>>
|
|
206
|
+
: {
|
|
207
|
+
readonly [key in keyof tree]: ReferenceTree<
|
|
208
|
+
tree[key],
|
|
209
|
+
group extends 'typography'
|
|
210
|
+
? key extends Typography.Property
|
|
211
|
+
? key
|
|
212
|
+
: group
|
|
213
|
+
: group
|
|
214
|
+
>
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** Supported scalar groups; composite presets and query metadata follow separately. */
|
|
218
|
+
type Scalar<group> = group extends
|
|
219
|
+
| 'spacing'
|
|
220
|
+
| 'borderRadius'
|
|
221
|
+
| 'margin'
|
|
222
|
+
| 'padding'
|
|
223
|
+
? Literal.Length
|
|
224
|
+
: group extends
|
|
225
|
+
| 'fontFamily'
|
|
226
|
+
| 'fontSize'
|
|
227
|
+
| 'fontWeight'
|
|
228
|
+
| 'letterSpacing'
|
|
229
|
+
| 'lineHeight'
|
|
230
|
+
? Exclude<
|
|
231
|
+
NonNullable<Literal.Properties[group]>,
|
|
232
|
+
'initial' | 'inherit' | 'unset' | 'revert' | 'revert-layer'
|
|
233
|
+
>
|
|
234
|
+
: group extends 'breakpoints' | 'containers'
|
|
235
|
+
? Query.Length
|
|
236
|
+
: Color
|
|
237
|
+
|
|
238
|
+
export type Tokens = {
|
|
239
|
+
/** Colors available to background declarations. */
|
|
240
|
+
readonly backgroundColor?: Palette<Color> | undefined
|
|
241
|
+
/** Colors available to border declarations. */
|
|
242
|
+
readonly borderColor?: Palette<Color> | undefined
|
|
243
|
+
/** Nonnegative corner radii. */
|
|
244
|
+
readonly borderRadius?: Palette<Literal.Length> | undefined
|
|
245
|
+
/** Compile-time viewport width thresholds. */
|
|
246
|
+
readonly breakpoints?: Readonly<Record<string, Query.Length>> | undefined
|
|
247
|
+
/** Shared colors available to every supported color property. */
|
|
248
|
+
readonly color?: Palette<Color> | undefined
|
|
249
|
+
/** Finite CSS container identities for named queries. */
|
|
250
|
+
readonly containerNames?: readonly string[] | undefined
|
|
251
|
+
/** Compile-time container width thresholds. */
|
|
252
|
+
readonly containers?: Readonly<Record<string, Query.Length>> | undefined
|
|
253
|
+
/** Font family token values; does not load font files. */
|
|
254
|
+
readonly fontFamily?:
|
|
255
|
+
| Palette<NonNullable<Literal.Properties['fontFamily']>>
|
|
256
|
+
| undefined
|
|
257
|
+
/** Font size token values. */
|
|
258
|
+
readonly fontSize?:
|
|
259
|
+
| Palette<NonNullable<Literal.Properties['fontSize']>>
|
|
260
|
+
| undefined
|
|
261
|
+
/** Font weight token values. */
|
|
262
|
+
readonly fontWeight?:
|
|
263
|
+
| Palette<NonNullable<Literal.Properties['fontWeight']>>
|
|
264
|
+
| undefined
|
|
265
|
+
/** Letter spacing token values. */
|
|
266
|
+
readonly letterSpacing?:
|
|
267
|
+
| Palette<NonNullable<Literal.Properties['letterSpacing']>>
|
|
268
|
+
| undefined
|
|
269
|
+
/** Line height token values. */
|
|
270
|
+
readonly lineHeight?:
|
|
271
|
+
| Palette<NonNullable<Literal.Properties['lineHeight']>>
|
|
272
|
+
| undefined
|
|
273
|
+
/** Signed spacing for margins, preferred over shared spacing tokens. */
|
|
274
|
+
readonly margin?: Palette<Literal.Length> | undefined
|
|
275
|
+
/** Nonnegative padding, preferred over shared spacing tokens. */
|
|
276
|
+
readonly padding?: Palette<Literal.Length> | undefined
|
|
277
|
+
/** Nonnegative spacing and sizing values. */
|
|
278
|
+
readonly spacing?: Palette<Literal.Length> | undefined
|
|
279
|
+
/** Colors available to text declarations. */
|
|
280
|
+
readonly textColor?: Palette<Color> | undefined
|
|
281
|
+
/** Named sets of font family, size, weight, letter spacing, and line height. */
|
|
282
|
+
readonly typography?: Typography.Sets | undefined
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function build(
|
|
286
|
+
input: unknown,
|
|
287
|
+
contract: Token.Contract,
|
|
288
|
+
base?: Readonly<Record<string, Token.Value>>,
|
|
289
|
+
baseQueries?: Query.Metadata,
|
|
290
|
+
scope?: string,
|
|
291
|
+
) {
|
|
292
|
+
const values: Record<string, Token.Value> = Object.assign(
|
|
293
|
+
Object.create(null),
|
|
294
|
+
base,
|
|
295
|
+
)
|
|
296
|
+
|
|
297
|
+
const queries = {
|
|
298
|
+
breakpoints: Object.assign(
|
|
299
|
+
Object.create(null),
|
|
300
|
+
baseQueries?.breakpoints,
|
|
301
|
+
) as Record<string, string>,
|
|
302
|
+
containerNames: baseQueries?.containerNames ?? [],
|
|
303
|
+
containers: Object.assign(
|
|
304
|
+
Object.create(null),
|
|
305
|
+
baseQueries?.containers,
|
|
306
|
+
) as Record<string, string>,
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
let hasQueries = !!baseQueries
|
|
310
|
+
const active = new Set<object>()
|
|
311
|
+
|
|
312
|
+
function visit(
|
|
313
|
+
value: unknown,
|
|
314
|
+
group: Token.Group | 'typography',
|
|
315
|
+
path: readonly string[],
|
|
316
|
+
) {
|
|
317
|
+
const key = path.join('.')
|
|
318
|
+
const scalar = typeof value === 'string' || typeof value === 'number'
|
|
319
|
+
if (group === 'typography' && scalar)
|
|
320
|
+
throw new InvalidError(
|
|
321
|
+
path,
|
|
322
|
+
'Expected a typography set or a nested set group.',
|
|
323
|
+
)
|
|
324
|
+
const entries = scalar ? undefined : record(value, path)
|
|
325
|
+
const pair =
|
|
326
|
+
['color', 'backgroundColor', 'borderColor', 'textColor'].includes(
|
|
327
|
+
group,
|
|
328
|
+
) && entries?.some(([name]) => name === 'light' || name === 'dark')
|
|
329
|
+
|
|
330
|
+
if (scalar || pair) {
|
|
331
|
+
if (base && !Object.hasOwn(base, key))
|
|
332
|
+
throw new InvalidError(
|
|
333
|
+
path,
|
|
334
|
+
'Extensions cannot add or replace token paths.',
|
|
335
|
+
)
|
|
336
|
+
|
|
337
|
+
if (pair) {
|
|
338
|
+
if (
|
|
339
|
+
!['color', 'backgroundColor', 'borderColor', 'textColor'].includes(
|
|
340
|
+
group,
|
|
341
|
+
) ||
|
|
342
|
+
entries!.length !== 2 ||
|
|
343
|
+
!entries!.some(([name]) => name === 'light') ||
|
|
344
|
+
!entries!.some(([name]) => name === 'dark')
|
|
345
|
+
)
|
|
346
|
+
throw new InvalidError(
|
|
347
|
+
path,
|
|
348
|
+
'Expected a complete light/dark color pair.',
|
|
349
|
+
)
|
|
350
|
+
|
|
351
|
+
const schemes = Object.fromEntries(entries!)
|
|
352
|
+
|
|
353
|
+
values[key] = Object.freeze({
|
|
354
|
+
dark: schemes.dark as string,
|
|
355
|
+
light: schemes.light as string,
|
|
356
|
+
})
|
|
357
|
+
} else {
|
|
358
|
+
values[key] = value as number | string
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
return
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
if (!entries!.length && !base)
|
|
365
|
+
throw new InvalidError(path, 'Token palettes cannot be empty.')
|
|
366
|
+
|
|
367
|
+
if (base && Object.hasOwn(base, key))
|
|
368
|
+
throw new InvalidError(path, 'A token leaf cannot become a palette.')
|
|
369
|
+
|
|
370
|
+
if (active.has(value as object))
|
|
371
|
+
throw new InvalidError(path, 'Cyclic palettes are not supported.')
|
|
372
|
+
|
|
373
|
+
active.add(value as object)
|
|
374
|
+
|
|
375
|
+
for (const [name, child] of entries!) {
|
|
376
|
+
const next = [...path, name]
|
|
377
|
+
if (
|
|
378
|
+
base &&
|
|
379
|
+
!Object.keys(base).some(
|
|
380
|
+
(key) =>
|
|
381
|
+
key === next.join('.') || key.startsWith(`${next.join('.')}.`),
|
|
382
|
+
)
|
|
383
|
+
)
|
|
384
|
+
throw new InvalidError(next, 'Extensions cannot add token paths.')
|
|
385
|
+
|
|
386
|
+
const property =
|
|
387
|
+
group === 'typography' &&
|
|
388
|
+
Typography.properties.includes(name as Typography.Property)
|
|
389
|
+
? (name as Typography.Property)
|
|
390
|
+
: undefined
|
|
391
|
+
if (property && typeof child !== 'string' && typeof child !== 'number')
|
|
392
|
+
throw new InvalidError(
|
|
393
|
+
next,
|
|
394
|
+
'Typography properties require scalar values.',
|
|
395
|
+
)
|
|
396
|
+
|
|
397
|
+
visit(child, property ?? group, next)
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
active.delete(value as object)
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
for (const [group, palette] of record(input, [])) {
|
|
404
|
+
if (palette === undefined) continue
|
|
405
|
+
|
|
406
|
+
if (group === 'containerNames') {
|
|
407
|
+
hasQueries = true
|
|
408
|
+
|
|
409
|
+
if (
|
|
410
|
+
!Array.isArray(palette) ||
|
|
411
|
+
Array.from({ length: palette.length }, (_, index) =>
|
|
412
|
+
Object.getOwnPropertyDescriptor(palette, index),
|
|
413
|
+
).some((field) => !field || !('value' in field)) ||
|
|
414
|
+
palette.some(
|
|
415
|
+
(name) =>
|
|
416
|
+
typeof name !== 'string' ||
|
|
417
|
+
!/^(?:--|-?(?:[_a-zA-Z\u0080-\uffff]|\\(?:[0-9a-fA-F]{1,6}[ \t\n\r\f]?|[^\n\r\f0-9a-fA-F])))(?:[-_a-zA-Z0-9\u0080-\uffff]|\\(?:[0-9a-fA-F]{1,6}[ \t\n\r\f]?|[^\n\r\f0-9a-fA-F]))*$/.test(
|
|
418
|
+
name,
|
|
419
|
+
) ||
|
|
420
|
+
[
|
|
421
|
+
'none',
|
|
422
|
+
'and',
|
|
423
|
+
'not',
|
|
424
|
+
'or',
|
|
425
|
+
'default',
|
|
426
|
+
'inherit',
|
|
427
|
+
'initial',
|
|
428
|
+
'unset',
|
|
429
|
+
'revert',
|
|
430
|
+
'revert-layer',
|
|
431
|
+
].includes(name.toLowerCase()),
|
|
432
|
+
) ||
|
|
433
|
+
new Set(palette).size !== palette.length
|
|
434
|
+
)
|
|
435
|
+
throw new InvalidError(
|
|
436
|
+
[group],
|
|
437
|
+
'Expected unique container identifiers.',
|
|
438
|
+
)
|
|
439
|
+
|
|
440
|
+
if (
|
|
441
|
+
base &&
|
|
442
|
+
JSON.stringify(palette) !== JSON.stringify(baseQueries?.containerNames)
|
|
443
|
+
)
|
|
444
|
+
throw new InvalidError(
|
|
445
|
+
[group],
|
|
446
|
+
'Extensions cannot change container identities.',
|
|
447
|
+
)
|
|
448
|
+
|
|
449
|
+
queries.containerNames = Object.freeze([...palette])
|
|
450
|
+
continue
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
if (group === 'breakpoints' || group === 'containers') {
|
|
454
|
+
hasQueries = true
|
|
455
|
+
|
|
456
|
+
for (const [name, value] of record(palette, [group])) {
|
|
457
|
+
if (
|
|
458
|
+
!/^[a-zA-Z0-9_][a-zA-Z0-9_-]*$/.test(name) ||
|
|
459
|
+
(group === 'breakpoints' &&
|
|
460
|
+
['all', 'screen', 'print'].includes(name)) ||
|
|
461
|
+
!Query.threshold(value)
|
|
462
|
+
)
|
|
463
|
+
throw new InvalidError(
|
|
464
|
+
[group, name],
|
|
465
|
+
'Expected a named nonnegative length threshold.',
|
|
466
|
+
)
|
|
467
|
+
|
|
468
|
+
if (base && !Object.hasOwn(queries[group], name))
|
|
469
|
+
throw new InvalidError(
|
|
470
|
+
[group, name],
|
|
471
|
+
'Extensions cannot add query thresholds.',
|
|
472
|
+
)
|
|
473
|
+
|
|
474
|
+
queries[group][name] = value
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
continue
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
if (
|
|
481
|
+
![
|
|
482
|
+
'backgroundColor',
|
|
483
|
+
'borderColor',
|
|
484
|
+
'borderRadius',
|
|
485
|
+
'color',
|
|
486
|
+
'margin',
|
|
487
|
+
'padding',
|
|
488
|
+
'spacing',
|
|
489
|
+
'fontFamily',
|
|
490
|
+
'fontSize',
|
|
491
|
+
'fontWeight',
|
|
492
|
+
'letterSpacing',
|
|
493
|
+
'lineHeight',
|
|
494
|
+
'textColor',
|
|
495
|
+
'typography',
|
|
496
|
+
].includes(group)
|
|
497
|
+
)
|
|
498
|
+
throw new InvalidError([group], 'Unsupported token group.')
|
|
499
|
+
|
|
500
|
+
if (palette === undefined) continue
|
|
501
|
+
|
|
502
|
+
if (base && !Object.keys(base).some((key) => key.startsWith(`${group}.`)))
|
|
503
|
+
throw new InvalidError([group], 'Extensions cannot add token groups.')
|
|
504
|
+
|
|
505
|
+
// Groups are always records; scalar leaves begin below them.
|
|
506
|
+
const entries = record(palette, [group])
|
|
507
|
+
if (!entries.length && !base)
|
|
508
|
+
throw new InvalidError([group], 'Token palettes cannot be empty.')
|
|
509
|
+
|
|
510
|
+
for (const [name, value] of entries) {
|
|
511
|
+
if (
|
|
512
|
+
group === 'typography' &&
|
|
513
|
+
Typography.properties.includes(name as Typography.Property)
|
|
514
|
+
)
|
|
515
|
+
throw new InvalidError(
|
|
516
|
+
[group, name],
|
|
517
|
+
'Typography properties require a named set.',
|
|
518
|
+
)
|
|
519
|
+
visit(value, group as Token.Group | 'typography', [group, name])
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
type Tree = { [key: string]: Tree | Token.Reference }
|
|
524
|
+
|
|
525
|
+
const tokens: Tree = Object.create(null)
|
|
526
|
+
|
|
527
|
+
for (const [path, value] of Object.entries(values)) {
|
|
528
|
+
const parts = path.split('.')
|
|
529
|
+
let tree = tokens
|
|
530
|
+
|
|
531
|
+
for (const part of parts.slice(0, -1))
|
|
532
|
+
tree = (tree[part] ??= Object.create(null)) as Tree
|
|
533
|
+
|
|
534
|
+
tree[parts.at(-1)!] = Token.create({
|
|
535
|
+
contract,
|
|
536
|
+
group: (parts[0] === 'typography'
|
|
537
|
+
? parts.at(-1)
|
|
538
|
+
: parts[0]) as Token.Group,
|
|
539
|
+
path,
|
|
540
|
+
value,
|
|
541
|
+
})
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
function freeze(tree: Tree) {
|
|
545
|
+
for (const value of Object.values(tree)) if (!Token.is(value)) freeze(value)
|
|
546
|
+
|
|
547
|
+
Object.freeze(tree)
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
freeze(tokens)
|
|
551
|
+
|
|
552
|
+
const definition = Object.freeze(
|
|
553
|
+
Object.defineProperty(
|
|
554
|
+
{
|
|
555
|
+
get className(): string {
|
|
556
|
+
if (scope) return `z_theme-${scope}`
|
|
557
|
+
const id = contract[Token.identity]
|
|
558
|
+
if (!id?.startsWith('id-')) throw new MissingTransformError()
|
|
559
|
+
return `z_theme-${id}-${Identity.hash(JSON.stringify(values))}`
|
|
560
|
+
},
|
|
561
|
+
style: (styles?: unknown, options: style.DefinitionOptions = {}) => {
|
|
562
|
+
if (!contract[Token.identity])
|
|
563
|
+
Identity.requireId(undefined, 'Theme.define')
|
|
564
|
+
return Authoring.create(styles, {
|
|
565
|
+
...options,
|
|
566
|
+
theme: definition as unknown as Definition,
|
|
567
|
+
})
|
|
568
|
+
},
|
|
569
|
+
tokens,
|
|
570
|
+
variants: (
|
|
571
|
+
input: Record<string, unknown>,
|
|
572
|
+
options: style.DefinitionOptions = {},
|
|
573
|
+
) => Authoring.variants(input, options),
|
|
574
|
+
vars: Token.variables(tokens),
|
|
575
|
+
},
|
|
576
|
+
Token.definition,
|
|
577
|
+
{
|
|
578
|
+
value: Object.freeze({
|
|
579
|
+
contract,
|
|
580
|
+
values: Object.freeze(values),
|
|
581
|
+
...(hasQueries
|
|
582
|
+
? {
|
|
583
|
+
queries: Object.freeze({
|
|
584
|
+
breakpoints: Object.freeze(queries.breakpoints),
|
|
585
|
+
containerNames: queries.containerNames,
|
|
586
|
+
containers: Object.freeze(queries.containers),
|
|
587
|
+
}),
|
|
588
|
+
}
|
|
589
|
+
: {}),
|
|
590
|
+
}),
|
|
591
|
+
},
|
|
592
|
+
),
|
|
593
|
+
)
|
|
594
|
+
return definition
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
function record(
|
|
598
|
+
value: unknown,
|
|
599
|
+
path: readonly string[],
|
|
600
|
+
): readonly (readonly [string, unknown])[] {
|
|
601
|
+
if (!value || typeof value !== 'object')
|
|
602
|
+
throw new InvalidError(path, 'Expected a plain data record.')
|
|
603
|
+
|
|
604
|
+
const prototype: object | null = Object.getPrototypeOf(value)
|
|
605
|
+
const constructor: unknown =
|
|
606
|
+
prototype &&
|
|
607
|
+
Object.getOwnPropertyDescriptor(prototype, 'constructor')?.value
|
|
608
|
+
if (
|
|
609
|
+
prototype !== null &&
|
|
610
|
+
(Object.getPrototypeOf(prototype) !== null ||
|
|
611
|
+
typeof constructor !== 'function' ||
|
|
612
|
+
Function.prototype.toString.call(constructor) !==
|
|
613
|
+
Function.prototype.toString.call(Object))
|
|
614
|
+
)
|
|
615
|
+
throw new InvalidError(path, 'Expected a plain data record.')
|
|
616
|
+
|
|
617
|
+
const entries: [string, unknown][] = []
|
|
618
|
+
|
|
619
|
+
for (const key of Reflect.ownKeys(value)) {
|
|
620
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key)!
|
|
621
|
+
if (typeof key === 'string' && key.includes('!'))
|
|
622
|
+
throw new InvalidError(
|
|
623
|
+
[...path, key],
|
|
624
|
+
'Token keys cannot contain !; it is reserved for declaration importance.',
|
|
625
|
+
)
|
|
626
|
+
|
|
627
|
+
if (
|
|
628
|
+
typeof key !== 'string' ||
|
|
629
|
+
!key ||
|
|
630
|
+
key.includes('.') ||
|
|
631
|
+
!descriptor.enumerable ||
|
|
632
|
+
!('value' in descriptor)
|
|
633
|
+
)
|
|
634
|
+
throw new InvalidError(
|
|
635
|
+
path,
|
|
636
|
+
'Expected nonempty keys without dots and enumerable data properties.',
|
|
637
|
+
)
|
|
638
|
+
|
|
639
|
+
entries.push([key, descriptor.value])
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
return entries
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
type Validated<tokens> = Tokens extends tokens
|
|
646
|
+
? tokens
|
|
647
|
+
: Overrides<Tokens> extends tokens
|
|
648
|
+
? tokens
|
|
649
|
+
: {
|
|
650
|
+
[group in keyof tokens]: group extends keyof Tokens
|
|
651
|
+
? group extends 'containerNames'
|
|
652
|
+
? ContainerNames<tokens[group]>
|
|
653
|
+
: ValidPalette<tokens[group], group>
|
|
654
|
+
: never
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
type ContainerNames<names> = names extends readonly string[]
|
|
658
|
+
? UniqueNames<names> & {
|
|
659
|
+
[index in keyof names]: ContainerName<names[index]>
|
|
660
|
+
}
|
|
661
|
+
: names
|
|
662
|
+
|
|
663
|
+
type UniqueNames<
|
|
664
|
+
names extends readonly string[],
|
|
665
|
+
seen extends string = never,
|
|
666
|
+
> = names extends readonly [
|
|
667
|
+
infer name extends string,
|
|
668
|
+
...infer rest extends readonly string[],
|
|
669
|
+
]
|
|
670
|
+
? name extends seen
|
|
671
|
+
? never
|
|
672
|
+
: UniqueNames<rest, seen | name>
|
|
673
|
+
: unknown
|
|
674
|
+
|
|
675
|
+
type ContainerName<name> = name extends string
|
|
676
|
+
? Lowercase<name> extends
|
|
677
|
+
| 'none'
|
|
678
|
+
| 'and'
|
|
679
|
+
| 'not'
|
|
680
|
+
| 'or'
|
|
681
|
+
| 'default'
|
|
682
|
+
| 'inherit'
|
|
683
|
+
| 'initial'
|
|
684
|
+
| 'unset'
|
|
685
|
+
| 'revert'
|
|
686
|
+
| 'revert-layer'
|
|
687
|
+
? never
|
|
688
|
+
: name
|
|
689
|
+
: name
|
|
690
|
+
|
|
691
|
+
type ValidPalette<palette, group> = palette extends undefined
|
|
692
|
+
? undefined
|
|
693
|
+
: {
|
|
694
|
+
[key in keyof palette]: key extends `${string}!${string}`
|
|
695
|
+
? never
|
|
696
|
+
: group extends 'typography'
|
|
697
|
+
? key extends Typography.Property
|
|
698
|
+
? never
|
|
699
|
+
: ValidTree<palette[key], group>
|
|
700
|
+
: ValidTree<palette[key], group>
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
type WeightDigits<
|
|
704
|
+
text extends string,
|
|
705
|
+
digits extends unknown[] = [],
|
|
706
|
+
> = text extends ''
|
|
707
|
+
? digits extends []
|
|
708
|
+
? false
|
|
709
|
+
: true
|
|
710
|
+
: digits['length'] extends 3
|
|
711
|
+
? false
|
|
712
|
+
: text extends `${infer first}${infer rest}`
|
|
713
|
+
? first extends '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
|
|
714
|
+
? WeightDigits<rest, [...digits, unknown]>
|
|
715
|
+
: false
|
|
716
|
+
: false
|
|
717
|
+
|
|
718
|
+
type Weight<value> = value extends number
|
|
719
|
+
? number extends value
|
|
720
|
+
? value
|
|
721
|
+
: `${value}` extends '1000'
|
|
722
|
+
? value
|
|
723
|
+
: `${value}` extends `${infer whole}.${string}`
|
|
724
|
+
? whole extends '0'
|
|
725
|
+
? never
|
|
726
|
+
: WeightDigits<whole> extends true
|
|
727
|
+
? value
|
|
728
|
+
: never
|
|
729
|
+
: `${value}` extends '0'
|
|
730
|
+
? never
|
|
731
|
+
: WeightDigits<`${value}`> extends true
|
|
732
|
+
? value
|
|
733
|
+
: never
|
|
734
|
+
: value
|
|
735
|
+
|
|
736
|
+
type ValidTree<tree, group> = tree extends string | number
|
|
737
|
+
? group extends 'typography'
|
|
738
|
+
? never
|
|
739
|
+
: tree extends Scalar<group>
|
|
740
|
+
? group extends 'breakpoints' | 'containers'
|
|
741
|
+
? tree extends `-${string}`
|
|
742
|
+
? never
|
|
743
|
+
: Literal.Checked<tree>
|
|
744
|
+
: group extends keyof Literal.Properties
|
|
745
|
+
? Literal.Checked<tree> &
|
|
746
|
+
Value.Checked<Record<group, tree>>[group] &
|
|
747
|
+
(group extends 'fontWeight' ? Weight<tree> : unknown) &
|
|
748
|
+
(tree extends string
|
|
749
|
+
? Lowercase<tree> extends
|
|
750
|
+
| 'inherit'
|
|
751
|
+
| 'initial'
|
|
752
|
+
| 'unset'
|
|
753
|
+
| 'revert'
|
|
754
|
+
| 'revert-layer'
|
|
755
|
+
? never
|
|
756
|
+
: unknown
|
|
757
|
+
: unknown)
|
|
758
|
+
: Literal.Checked<tree>
|
|
759
|
+
: never
|
|
760
|
+
: Extract<
|
|
761
|
+
keyof tree,
|
|
762
|
+
group extends 'color' | 'backgroundColor' | 'borderColor' | 'textColor'
|
|
763
|
+
? 'dark' | 'light'
|
|
764
|
+
: never
|
|
765
|
+
> extends never
|
|
766
|
+
? {
|
|
767
|
+
[key in keyof tree]: key extends `${string}!${string}`
|
|
768
|
+
? never
|
|
769
|
+
: group extends 'typography'
|
|
770
|
+
? key extends Typography.Property
|
|
771
|
+
? tree[key] extends string | number
|
|
772
|
+
? ValidTree<tree[key], key>
|
|
773
|
+
: never
|
|
774
|
+
: ValidTree<tree[key], group>
|
|
775
|
+
: ValidTree<tree[key], group>
|
|
776
|
+
}
|
|
777
|
+
: group extends 'color' | 'backgroundColor' | 'borderColor' | 'textColor'
|
|
778
|
+
? {
|
|
779
|
+
readonly dark: Literal.Color &
|
|
780
|
+
Literal.Checked<tree extends { dark: infer value } ? value : never>
|
|
781
|
+
readonly light: Literal.Color &
|
|
782
|
+
Literal.Checked<tree extends { light: infer value } ? value : never>
|
|
783
|
+
} & Record<Exclude<keyof tree, 'dark' | 'light'>, never>
|
|
784
|
+
: never
|