zyzz 0.0.0 → 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/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 +167 -0
- package/dist/Style.d.ts.map +1 -0
- package/dist/Style.js +284 -0
- package/dist/Style.js.map +1 -0
- package/dist/Theme.d.ts +154 -0
- package/dist/Theme.d.ts.map +1 -0
- package/dist/Theme.js +257 -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 +165 -0
- package/dist/compiler/Source.d.ts.map +1 -0
- package/dist/compiler/Source.js +990 -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 +884 -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 +600 -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 +2008 -0
- package/dist/default.d.ts.map +1 -0
- package/dist/default.js +243 -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 +49 -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/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 +690 -0
- package/src/Props.ts +8 -0
- package/src/Style.ts +748 -0
- package/src/Theme.ts +713 -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 +1550 -0
- package/src/compiler/Transform.ts +1235 -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 +846 -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 +484 -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 +120 -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/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
|
@@ -0,0 +1,1084 @@
|
|
|
1
|
+
/** Compiles portable declarations into immutable native theme tables. @module */
|
|
2
|
+
import type * as Style from '../Style.js'
|
|
3
|
+
import type * as Theme from '../Theme.js'
|
|
4
|
+
import * as Token from '../internal/Token.js'
|
|
5
|
+
import type * as Native from '../internal/NativeProperties.js'
|
|
6
|
+
import * as Values from './internal/Values.js'
|
|
7
|
+
import * as Color from './internal/Color.js'
|
|
8
|
+
import * as Scalar from './internal/Scalar.js'
|
|
9
|
+
|
|
10
|
+
const properties = Scalar.properties
|
|
11
|
+
|
|
12
|
+
/** Frozen native overlay style with zero physical offsets. */
|
|
13
|
+
export const absoluteFill = Object.freeze({
|
|
14
|
+
bottom: 0,
|
|
15
|
+
left: 0,
|
|
16
|
+
position: 'absolute',
|
|
17
|
+
right: 0,
|
|
18
|
+
top: 0,
|
|
19
|
+
} as const)
|
|
20
|
+
|
|
21
|
+
/** Explicit theme alternative, never inferred from a device. */
|
|
22
|
+
export type ColorScheme = 'dark' | 'light'
|
|
23
|
+
|
|
24
|
+
/** Failure to represent the supplied definitions on the native target. */
|
|
25
|
+
export class CompileError extends Error {
|
|
26
|
+
/** Copies and freezes diagnostic paths in authored order. */
|
|
27
|
+
constructor(diagnostics: readonly Diagnostic[]) {
|
|
28
|
+
super(
|
|
29
|
+
diagnostics
|
|
30
|
+
.map(({ message, path }) => `${JSON.stringify(path)}: ${message}`)
|
|
31
|
+
.join('\n'),
|
|
32
|
+
)
|
|
33
|
+
this.diagnostics = Object.freeze(
|
|
34
|
+
diagnostics.map((diagnostic) =>
|
|
35
|
+
Object.freeze({
|
|
36
|
+
...diagnostic,
|
|
37
|
+
path: Object.freeze([...diagnostic.path]),
|
|
38
|
+
}),
|
|
39
|
+
),
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
/** Target capability failures, including the selected table when relevant. */
|
|
43
|
+
readonly diagnostics: readonly Diagnostic[]
|
|
44
|
+
/** Stable namespaced error identifier. */
|
|
45
|
+
override name = 'StyleSheet.CompileError'
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Resolves portable tokens into two static scheme tables per supplied theme.
|
|
50
|
+
* px defaults to one native logical unit. rem and font families require mappings.
|
|
51
|
+
* No device state, CSS parser, stylesheet registration, or runtime binding is used.
|
|
52
|
+
* @throws {CompileError} For unsupported semantics or invalid conversion inputs.
|
|
53
|
+
*/
|
|
54
|
+
export function compile<
|
|
55
|
+
const name extends string,
|
|
56
|
+
const themeName extends string = 'default',
|
|
57
|
+
const definition extends Style.Definition<name> = Style.Definition<name>,
|
|
58
|
+
const platform extends 'ios' | 'android' | undefined = undefined,
|
|
59
|
+
>(
|
|
60
|
+
options: compile.Options<name, themeName> & {
|
|
61
|
+
styles: definition
|
|
62
|
+
platform?: platform
|
|
63
|
+
},
|
|
64
|
+
): compile.ReturnType<name, themeName, definition, platform> {
|
|
65
|
+
for (const key of Object.keys(options))
|
|
66
|
+
if (!['fonts', 'platform', 'styles', 'themes', 'units'].includes(key))
|
|
67
|
+
fail('invalid_options', 'Unknown native compiler option.', [key])
|
|
68
|
+
|
|
69
|
+
if (
|
|
70
|
+
options.platform !== undefined &&
|
|
71
|
+
!['android', 'ios'].includes(options.platform)
|
|
72
|
+
)
|
|
73
|
+
fail('invalid_options', 'Expected an explicit ios or android platform.', [
|
|
74
|
+
'platform',
|
|
75
|
+
])
|
|
76
|
+
|
|
77
|
+
for (const [unit, scale] of Object.entries(options.units ?? {}))
|
|
78
|
+
if (
|
|
79
|
+
!['px', 'rem'].includes(unit) ||
|
|
80
|
+
(scale !== undefined &&
|
|
81
|
+
(typeof scale !== 'number' || !Number.isFinite(scale) || scale <= 0))
|
|
82
|
+
)
|
|
83
|
+
fail(
|
|
84
|
+
'invalid_options',
|
|
85
|
+
'Unit scales must be positive finite px or rem conversions.',
|
|
86
|
+
['units', unit],
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
for (const [family, mapped] of Object.entries(options.fonts ?? {}))
|
|
90
|
+
if (!family || typeof mapped !== 'string' || !mapped.trim())
|
|
91
|
+
fail('invalid_options', 'Font mappings require nonempty family names.', [
|
|
92
|
+
'fonts',
|
|
93
|
+
family,
|
|
94
|
+
])
|
|
95
|
+
|
|
96
|
+
if (!options.styles || !Array.isArray(options.styles.styles))
|
|
97
|
+
fail('invalid_options', 'Expected a Style.define result.', ['styles'])
|
|
98
|
+
|
|
99
|
+
const names = new Set<string>()
|
|
100
|
+
let scalar = true
|
|
101
|
+
for (const style of options.styles.styles) {
|
|
102
|
+
if (!style.name || names.has(style.name))
|
|
103
|
+
fail('invalid_options', 'Style names must be nonempty and unique.', [
|
|
104
|
+
style.name,
|
|
105
|
+
])
|
|
106
|
+
names.add(style.name)
|
|
107
|
+
for (const part of sequence(style)) {
|
|
108
|
+
if ((part.targets?.android || part.targets?.ios) && !options.platform)
|
|
109
|
+
fail(
|
|
110
|
+
'invalid_options',
|
|
111
|
+
'Platform branches require an explicit platform.',
|
|
112
|
+
[style.name, 'targets'],
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
const declared = new Set<string>()
|
|
116
|
+
for (const declaration of part.declarations) {
|
|
117
|
+
if (
|
|
118
|
+
typeof declaration.value !== 'number' &&
|
|
119
|
+
typeof declaration.value !== 'string'
|
|
120
|
+
)
|
|
121
|
+
scalar = false
|
|
122
|
+
const path = [style.name, declaration.property]
|
|
123
|
+
if (!Object.hasOwn(properties, declaration.property))
|
|
124
|
+
fail(
|
|
125
|
+
'unsupported_feature',
|
|
126
|
+
'Property is outside the native subset.',
|
|
127
|
+
path,
|
|
128
|
+
)
|
|
129
|
+
if (declaration.important || declared.has(declaration.property))
|
|
130
|
+
fail(
|
|
131
|
+
'unsupported_feature',
|
|
132
|
+
'Importance and fallback declarations are not supported on native.',
|
|
133
|
+
path,
|
|
134
|
+
)
|
|
135
|
+
declared.add(declaration.property)
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const themes: readonly (readonly [string, Theme.Definition | undefined])[] =
|
|
141
|
+
options.themes === undefined
|
|
142
|
+
? [['default', undefined]]
|
|
143
|
+
: Object.entries(options.themes)
|
|
144
|
+
if (!themes.length)
|
|
145
|
+
fail(
|
|
146
|
+
'invalid_options',
|
|
147
|
+
'Supply at least one theme, or omit themes for a default table.',
|
|
148
|
+
['themes'],
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
const tables: Record<
|
|
152
|
+
string,
|
|
153
|
+
Readonly<Record<ColorScheme, Readonly<Record<string, NativeStyle>>>>
|
|
154
|
+
> = Object.create(null)
|
|
155
|
+
const interned = new Map<string, NativeStyle>()
|
|
156
|
+
const diagnostics: Diagnostic[] = []
|
|
157
|
+
let independent: Readonly<Record<string, NativeStyle>> | undefined
|
|
158
|
+
|
|
159
|
+
for (const [label, theme] of themes) {
|
|
160
|
+
if (!label)
|
|
161
|
+
fail('invalid_options', 'Theme labels must be nonempty.', [
|
|
162
|
+
'themes',
|
|
163
|
+
label,
|
|
164
|
+
])
|
|
165
|
+
const metadata =
|
|
166
|
+
theme &&
|
|
167
|
+
(Object.getOwnPropertyDescriptor(theme, Token.definition)?.value as
|
|
168
|
+
| Token.Metadata
|
|
169
|
+
| undefined)
|
|
170
|
+
if (options.themes !== undefined && !metadata)
|
|
171
|
+
fail(
|
|
172
|
+
'invalid_options',
|
|
173
|
+
'Expected a Theme.define or Config theme handle.',
|
|
174
|
+
['themes', label],
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
const schemes = {} as Record<
|
|
178
|
+
ColorScheme,
|
|
179
|
+
Readonly<Record<string, NativeStyle>>
|
|
180
|
+
>
|
|
181
|
+
const resolution = { schemeIndependent: true }
|
|
182
|
+
for (const scheme of ['light', 'dark'] as const) {
|
|
183
|
+
if (independent) {
|
|
184
|
+
schemes[scheme] = independent
|
|
185
|
+
continue
|
|
186
|
+
}
|
|
187
|
+
if (
|
|
188
|
+
scheme === 'dark' &&
|
|
189
|
+
resolution.schemeIndependent &&
|
|
190
|
+
!diagnostics.length
|
|
191
|
+
) {
|
|
192
|
+
schemes.dark = schemes.light
|
|
193
|
+
continue
|
|
194
|
+
}
|
|
195
|
+
const compiled: Record<string, NativeStyle> = Object.create(null)
|
|
196
|
+
for (const style of options.styles.styles) {
|
|
197
|
+
const output: Record<string, unknown> = {}
|
|
198
|
+
let lineHeight: number | string | undefined
|
|
199
|
+
for (const part of sequence(style)) {
|
|
200
|
+
for (const declaration of part.declarations) {
|
|
201
|
+
const property = declaration.property as keyof typeof properties
|
|
202
|
+
const path = [label, scheme, style.name, property]
|
|
203
|
+
try {
|
|
204
|
+
const value = resolve(
|
|
205
|
+
declaration.value,
|
|
206
|
+
metadata,
|
|
207
|
+
scheme,
|
|
208
|
+
path,
|
|
209
|
+
resolution,
|
|
210
|
+
)
|
|
211
|
+
if (property === 'lineHeight') {
|
|
212
|
+
lineHeight = value
|
|
213
|
+
continue
|
|
214
|
+
}
|
|
215
|
+
if (property === 'fontVariant') {
|
|
216
|
+
if (typeof value !== 'string')
|
|
217
|
+
fail(
|
|
218
|
+
'unsupported_value',
|
|
219
|
+
'Expected static font variants.',
|
|
220
|
+
path,
|
|
221
|
+
)
|
|
222
|
+
try {
|
|
223
|
+
output.fontVariant = Values.parse({
|
|
224
|
+
fontVariant:
|
|
225
|
+
value === 'normal' ? [] : value.trim().split(/\s+/),
|
|
226
|
+
}).fontVariant
|
|
227
|
+
} catch {
|
|
228
|
+
fail(
|
|
229
|
+
'unsupported_value',
|
|
230
|
+
'Font variant keywords require an explicit native equivalent.',
|
|
231
|
+
path,
|
|
232
|
+
)
|
|
233
|
+
}
|
|
234
|
+
continue
|
|
235
|
+
}
|
|
236
|
+
if (property === 'textShadow') {
|
|
237
|
+
const entries = shadows(value, options, path, true)
|
|
238
|
+
if (entries.length > 1)
|
|
239
|
+
fail(
|
|
240
|
+
'unsupported_value',
|
|
241
|
+
'Native text supports one shadow.',
|
|
242
|
+
path,
|
|
243
|
+
)
|
|
244
|
+
const shadow = entries[0]
|
|
245
|
+
output.textShadowColor = shadow?.color ?? 'transparent'
|
|
246
|
+
output.textShadowOffset = Object.freeze({
|
|
247
|
+
width: shadow?.offsetX ?? 0,
|
|
248
|
+
height: shadow?.offsetY ?? 0,
|
|
249
|
+
})
|
|
250
|
+
output.textShadowRadius = shadow?.blurRadius ?? 0
|
|
251
|
+
continue
|
|
252
|
+
}
|
|
253
|
+
if (property === 'boxShadow') {
|
|
254
|
+
output.boxShadow = shadows(value, options, path)
|
|
255
|
+
continue
|
|
256
|
+
}
|
|
257
|
+
if (property === 'transform') {
|
|
258
|
+
output.transform = transform(value, options, path)
|
|
259
|
+
continue
|
|
260
|
+
}
|
|
261
|
+
if (property === 'transformOrigin') {
|
|
262
|
+
output.transformOrigin = origin(value, options, path)
|
|
263
|
+
continue
|
|
264
|
+
}
|
|
265
|
+
const kind = properties[property]
|
|
266
|
+
const converted = convert(kind, value, options, path)
|
|
267
|
+
if (property === 'padding' || property === 'margin') {
|
|
268
|
+
const values =
|
|
269
|
+
typeof value === 'string'
|
|
270
|
+
? value.trim().split(/\s+/)
|
|
271
|
+
: [value]
|
|
272
|
+
const [top, right = top, bottom = top, left = right] =
|
|
273
|
+
values.map((value) =>
|
|
274
|
+
length(value, options, property === 'margin', path),
|
|
275
|
+
)
|
|
276
|
+
output[`${property}Top`] = top!
|
|
277
|
+
output[`${property}Right`] = right!
|
|
278
|
+
output[`${property}Bottom`] = bottom!
|
|
279
|
+
output[`${property}Left`] = left!
|
|
280
|
+
} else if (
|
|
281
|
+
property === 'borderColor' ||
|
|
282
|
+
property === 'borderWidth'
|
|
283
|
+
) {
|
|
284
|
+
for (const side of ['Top', 'Right', 'Bottom', 'Left'])
|
|
285
|
+
output[
|
|
286
|
+
`border${side}${property === 'borderColor' ? 'Color' : 'Width'}`
|
|
287
|
+
] = converted
|
|
288
|
+
} else if (property === 'borderRadius') {
|
|
289
|
+
for (const corner of [
|
|
290
|
+
'TopLeft',
|
|
291
|
+
'TopRight',
|
|
292
|
+
'BottomRight',
|
|
293
|
+
'BottomLeft',
|
|
294
|
+
])
|
|
295
|
+
output[`border${corner}Radius`] = converted
|
|
296
|
+
} else if (property === 'gap') {
|
|
297
|
+
output.columnGap = converted
|
|
298
|
+
output.rowGap = converted
|
|
299
|
+
} else output[property] = converted
|
|
300
|
+
} catch (error) {
|
|
301
|
+
if (!(error instanceof CompileError)) throw error
|
|
302
|
+
diagnostics.push(...error.diagnostics)
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
for (const branch of ['native', options.platform] as const) {
|
|
306
|
+
if (!branch || !part.targets?.[branch]) continue
|
|
307
|
+
try {
|
|
308
|
+
const native = Values.parse(part.targets[branch])
|
|
309
|
+
Object.assign(output, native)
|
|
310
|
+
if (native.lineHeight !== undefined) lineHeight = undefined
|
|
311
|
+
} catch (error) {
|
|
312
|
+
if (error instanceof CompileError) throw error
|
|
313
|
+
diagnostics.push({
|
|
314
|
+
code: 'unsupported_value',
|
|
315
|
+
message: (error as Error).message,
|
|
316
|
+
path: [label, scheme, style.name, 'targets', branch],
|
|
317
|
+
})
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
if (lineHeight !== undefined) {
|
|
322
|
+
const path = [label, scheme, style.name, 'lineHeight']
|
|
323
|
+
try {
|
|
324
|
+
if (typeof lineHeight === 'number') {
|
|
325
|
+
if (
|
|
326
|
+
!Number.isFinite(lineHeight) ||
|
|
327
|
+
lineHeight < 0 ||
|
|
328
|
+
typeof output.fontSize !== 'number'
|
|
329
|
+
)
|
|
330
|
+
fail(
|
|
331
|
+
'unsupported_value',
|
|
332
|
+
'Numeric lineHeight requires an explicit fontSize in the same style.',
|
|
333
|
+
path,
|
|
334
|
+
)
|
|
335
|
+
output.lineHeight = lineHeight * output.fontSize
|
|
336
|
+
if (!Number.isFinite(output.lineHeight))
|
|
337
|
+
fail(
|
|
338
|
+
'unsupported_value',
|
|
339
|
+
'Converted lineHeight must be finite.',
|
|
340
|
+
path,
|
|
341
|
+
)
|
|
342
|
+
} else output.lineHeight = length(lineHeight, options, false, path)
|
|
343
|
+
} catch (error) {
|
|
344
|
+
if (!(error instanceof CompileError)) throw error
|
|
345
|
+
diagnostics.push(...error.diagnostics)
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
const key = JSON.stringify(
|
|
349
|
+
Object.entries(output).sort(([a], [b]) =>
|
|
350
|
+
a < b ? -1 : a > b ? 1 : 0,
|
|
351
|
+
),
|
|
352
|
+
)
|
|
353
|
+
let shared = interned.get(key)
|
|
354
|
+
if (!shared) {
|
|
355
|
+
shared = Object.freeze(output) as NativeStyle
|
|
356
|
+
interned.set(key, shared)
|
|
357
|
+
}
|
|
358
|
+
compiled[style.name] = shared
|
|
359
|
+
}
|
|
360
|
+
schemes[scheme] = Object.freeze(compiled)
|
|
361
|
+
if (scalar && !diagnostics.length) independent = schemes[scheme]
|
|
362
|
+
}
|
|
363
|
+
tables[label] = Object.freeze(schemes)
|
|
364
|
+
}
|
|
365
|
+
if (diagnostics.length) throw new CompileError(diagnostics)
|
|
366
|
+
return Object.freeze({
|
|
367
|
+
styles: Object.freeze(tables) as compile.ReturnType<
|
|
368
|
+
name,
|
|
369
|
+
themeName,
|
|
370
|
+
definition,
|
|
371
|
+
platform
|
|
372
|
+
>['styles'],
|
|
373
|
+
})
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/** Native compilation options and results. */
|
|
377
|
+
export declare namespace compile {
|
|
378
|
+
/** Caller-owned mappings and portable definitions. */
|
|
379
|
+
type Options<
|
|
380
|
+
name extends string = string,
|
|
381
|
+
themeName extends string = string,
|
|
382
|
+
> = {
|
|
383
|
+
/** Exact authored font-family text mapped to an installed native family. */
|
|
384
|
+
readonly fonts?: Readonly<Record<string, string>> | undefined
|
|
385
|
+
/** Explicit destination for platform overrides. Required when platform branches exist. */
|
|
386
|
+
readonly platform?: 'android' | 'ios' | undefined
|
|
387
|
+
/** Immutable shared definitions, also accepted by Css.compile. */
|
|
388
|
+
readonly styles: Style.Definition<name>
|
|
389
|
+
/** Explicit output labels. Omission creates the token-fallback default table. */
|
|
390
|
+
readonly themes?: Readonly<Record<themeName, Theme.Definition>> | undefined
|
|
391
|
+
/** Positive logical-unit scales. px defaults to one, rem has no default. */
|
|
392
|
+
readonly units?:
|
|
393
|
+
| { readonly px?: number | undefined; readonly rem?: number | undefined }
|
|
394
|
+
| undefined
|
|
395
|
+
}
|
|
396
|
+
/** Complete immutable light/dark tables with inferred labels and style names. */
|
|
397
|
+
type ReturnType<
|
|
398
|
+
name extends string = string,
|
|
399
|
+
themeName extends string = string,
|
|
400
|
+
definition extends Style.Definition<name> = Style.Definition<name>,
|
|
401
|
+
platform = undefined,
|
|
402
|
+
> = {
|
|
403
|
+
/** Precompiled tables, suitable for identity-preserving selection. */
|
|
404
|
+
readonly styles: Readonly<
|
|
405
|
+
Record<
|
|
406
|
+
themeName,
|
|
407
|
+
Readonly<Record<ColorScheme, Compiled<definition, platform, name>>>
|
|
408
|
+
>
|
|
409
|
+
>
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* Composes existing native styles in order without flattening or mutating them.
|
|
415
|
+
* A falsy operand returns the other operand unchanged. Two present operands
|
|
416
|
+
* produce an array consumed by the native renderer or flatten.
|
|
417
|
+
*/
|
|
418
|
+
export function compose<
|
|
419
|
+
const first extends object | Falsy,
|
|
420
|
+
const second extends object | Falsy,
|
|
421
|
+
>(first: first, second: second): compose.ReturnType<first, second>
|
|
422
|
+
export function compose(
|
|
423
|
+
first: object | Falsy,
|
|
424
|
+
second: object | Falsy,
|
|
425
|
+
): object | Falsy {
|
|
426
|
+
if (!first) return second
|
|
427
|
+
if (!second) return first
|
|
428
|
+
return [first, second]
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/** Identity and mutable pair inference for native composition. */
|
|
432
|
+
export declare namespace compose {
|
|
433
|
+
/** Statically absent operands preserve the other operand's exact type. */
|
|
434
|
+
type ReturnType<first, second> = first extends Falsy
|
|
435
|
+
? second
|
|
436
|
+
: second extends Falsy
|
|
437
|
+
? first
|
|
438
|
+
: [first, second]
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/** A structured native capability or conversion failure. */
|
|
442
|
+
export type Diagnostic = {
|
|
443
|
+
/** Stable category of rejected input. */
|
|
444
|
+
readonly code: 'invalid_options' | 'unsupported_feature' | 'unsupported_value'
|
|
445
|
+
/** Explanation of the supported boundary. */
|
|
446
|
+
readonly message: string
|
|
447
|
+
/** Theme, scheme, style, and property where applicable. */
|
|
448
|
+
readonly path: readonly string[]
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Flattens nested native arrays with shallow, last-declaration-wins precedence.
|
|
453
|
+
* Plain objects retain identity. Falsy values yield undefined outside arrays
|
|
454
|
+
* and are ignored inside them. Structured values remain caller-owned.
|
|
455
|
+
* This is native property merging, not CSS shorthand or cascade resolution.
|
|
456
|
+
*/
|
|
457
|
+
export function flatten<const input extends object | Falsy>(
|
|
458
|
+
styles: input,
|
|
459
|
+
): flatten.ReturnType<input>
|
|
460
|
+
export function flatten(styles: unknown): object | undefined {
|
|
461
|
+
if (!styles || typeof styles !== 'object') return undefined
|
|
462
|
+
if (!Array.isArray(styles)) return styles
|
|
463
|
+
|
|
464
|
+
const result: Record<string, unknown> = {}
|
|
465
|
+
for (const style of styles) {
|
|
466
|
+
const flattened = flatten(style as StyleProp<Record<string, unknown>>)
|
|
467
|
+
if (!flattened) continue
|
|
468
|
+
|
|
469
|
+
// Native flattening includes enumerable inherited declarations.
|
|
470
|
+
for (const key in flattened)
|
|
471
|
+
Object.defineProperty(result, key, {
|
|
472
|
+
configurable: true,
|
|
473
|
+
enumerable: true,
|
|
474
|
+
value: flattened[key],
|
|
475
|
+
writable: true,
|
|
476
|
+
})
|
|
477
|
+
}
|
|
478
|
+
return result
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/** Conservative property inference for merged native arrays. */
|
|
482
|
+
export declare namespace flatten {
|
|
483
|
+
/** Object identity, merged array properties, or absence according to the input. */
|
|
484
|
+
type ReturnType<input> = input extends Falsy
|
|
485
|
+
? undefined
|
|
486
|
+
: input extends readonly unknown[]
|
|
487
|
+
? Merged<Leaves<input>>
|
|
488
|
+
: input
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
/** Native style output, with converted logical-unit lengths and ordered transforms. */
|
|
492
|
+
export type NativeStyle = Readonly<Native.Output>
|
|
493
|
+
|
|
494
|
+
type Compiled<definition, platform, name extends string> =
|
|
495
|
+
definition extends Style.Definition<string, infer input>
|
|
496
|
+
? unknown extends input
|
|
497
|
+
? Readonly<Record<name, NativeStyle>>
|
|
498
|
+
: Readonly<{
|
|
499
|
+
[key in keyof input as `${Extract<key, number | string>}`]: Omit<
|
|
500
|
+
NativeStyle,
|
|
501
|
+
'overflow'
|
|
502
|
+
> & {
|
|
503
|
+
readonly overflow?: Extract<
|
|
504
|
+
platform extends keyof input[key]
|
|
505
|
+
? input[key][platform]
|
|
506
|
+
: 'native' extends keyof input[key]
|
|
507
|
+
? input[key]['native']
|
|
508
|
+
: undefined,
|
|
509
|
+
NativeStyle['overflow']
|
|
510
|
+
>
|
|
511
|
+
}
|
|
512
|
+
}>
|
|
513
|
+
: Readonly<Record<name, NativeStyle>>
|
|
514
|
+
|
|
515
|
+
/** Optional native authoring constraint used with satisfies before Style.define. */
|
|
516
|
+
export type Properties = {
|
|
517
|
+
/** Portable literals or property-compatible scalar theme references. */
|
|
518
|
+
readonly [property in keyof typeof properties]?:
|
|
519
|
+
| Atom<(typeof properties)[property]>
|
|
520
|
+
| Reference<property>
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Looks up an existing table without allocating or resolving device state.
|
|
525
|
+
* @throws {SelectionError} For unknown own theme labels or color schemes.
|
|
526
|
+
*/
|
|
527
|
+
export function select<const tables extends Tables>(
|
|
528
|
+
styles: tables,
|
|
529
|
+
options: NoInfer<select.Options<keyof tables & string>>,
|
|
530
|
+
): tables[keyof tables][ColorScheme]
|
|
531
|
+
export function select<name extends string, themeName extends string>(
|
|
532
|
+
styles: Tables<name, themeName>,
|
|
533
|
+
options: NoInfer<select.Options<themeName>>,
|
|
534
|
+
): Readonly<Record<name, NativeStyle>> {
|
|
535
|
+
if (
|
|
536
|
+
!styles ||
|
|
537
|
+
!options ||
|
|
538
|
+
(options.colorScheme !== 'light' && options.colorScheme !== 'dark') ||
|
|
539
|
+
!Object.hasOwn(styles, options.theme)
|
|
540
|
+
)
|
|
541
|
+
throw new SelectionError(
|
|
542
|
+
'Select an existing theme label and light or dark colorScheme.',
|
|
543
|
+
)
|
|
544
|
+
return styles[options.theme][options.colorScheme]
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
/** Native lookup options. */
|
|
548
|
+
export declare namespace select {
|
|
549
|
+
/** Both choices are explicit. No environment defaults are consulted. */
|
|
550
|
+
type Options<themeName extends string = string> = {
|
|
551
|
+
/** Precompiled color scheme. */
|
|
552
|
+
readonly colorScheme: ColorScheme
|
|
553
|
+
/** Own label in the compiled tables. */
|
|
554
|
+
readonly theme: themeName
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/** Rejected lookup of a precompiled native table. */
|
|
559
|
+
export class SelectionError extends Error {
|
|
560
|
+
/** Explains the invalid selection without compiling replacement styles. */
|
|
561
|
+
constructor(message: string) {
|
|
562
|
+
super(message)
|
|
563
|
+
}
|
|
564
|
+
/** Stable namespaced error identifier. */
|
|
565
|
+
override name = 'StyleSheet.SelectionError'
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
/** Native styles, nested arrays, and conditional absence for composition. */
|
|
569
|
+
export type StyleProp<style extends object = NativeStyle> =
|
|
570
|
+
| Falsy
|
|
571
|
+
| style
|
|
572
|
+
| StyleArray<style>
|
|
573
|
+
|
|
574
|
+
/** Finite style tables indexed by the caller's labels and both schemes. */
|
|
575
|
+
export type Tables<
|
|
576
|
+
name extends string = string,
|
|
577
|
+
themeName extends string = string,
|
|
578
|
+
> = Readonly<
|
|
579
|
+
Record<
|
|
580
|
+
themeName,
|
|
581
|
+
Readonly<Record<ColorScheme, Readonly<Record<name, NativeStyle>>>>
|
|
582
|
+
>
|
|
583
|
+
>
|
|
584
|
+
|
|
585
|
+
type Falsy = '' | false | null | undefined
|
|
586
|
+
type Keys<value> = value extends unknown ? keyof value : never
|
|
587
|
+
// Bound recursive generic inputs while retaining useful keys at every normal nesting depth.
|
|
588
|
+
type Leaves<
|
|
589
|
+
input,
|
|
590
|
+
depth extends readonly unknown[] = [],
|
|
591
|
+
> = depth['length'] extends 12
|
|
592
|
+
? object
|
|
593
|
+
: input extends readonly (infer item)[]
|
|
594
|
+
? Leaves<item, [...depth, 0]>
|
|
595
|
+
: Exclude<input, Falsy>
|
|
596
|
+
type Merged<style> = {
|
|
597
|
+
[key in Keys<style>]?: style extends unknown
|
|
598
|
+
? key extends keyof style
|
|
599
|
+
? style[key]
|
|
600
|
+
: never
|
|
601
|
+
: never
|
|
602
|
+
}
|
|
603
|
+
// Match React Native's mutable outer array and readonly nested-array contract.
|
|
604
|
+
type StyleArray<style extends object> = Array<
|
|
605
|
+
style | Falsy | readonly (style | Falsy)[] | StyleArray<style>
|
|
606
|
+
>
|
|
607
|
+
type Length = 0 | '0' | `${number}px` | `${number}rem`
|
|
608
|
+
type Box =
|
|
609
|
+
| Length
|
|
610
|
+
| `${Length} ${Length}`
|
|
611
|
+
| `${Length} ${Length} ${Length}`
|
|
612
|
+
| `${Length} ${Length} ${Length} ${Length}`
|
|
613
|
+
type Weight =
|
|
614
|
+
| 'bold'
|
|
615
|
+
| 'normal'
|
|
616
|
+
| 100
|
|
617
|
+
| 200
|
|
618
|
+
| 300
|
|
619
|
+
| 400
|
|
620
|
+
| 500
|
|
621
|
+
| 600
|
|
622
|
+
| 700
|
|
623
|
+
| 800
|
|
624
|
+
| 900
|
|
625
|
+
type Atom<kind> = kind extends readonly string[]
|
|
626
|
+
? kind[number]
|
|
627
|
+
: kind extends 'color'
|
|
628
|
+
? Color.Value
|
|
629
|
+
: kind extends 'shadow' | 'textShadow' | 'fontVariant'
|
|
630
|
+
? string
|
|
631
|
+
: kind extends 'origin'
|
|
632
|
+
? Exclude<
|
|
633
|
+
Style.LiteralDeclarations['transformOrigin'],
|
|
634
|
+
readonly unknown[] | undefined
|
|
635
|
+
>
|
|
636
|
+
: kind extends 'transform'
|
|
637
|
+
? Exclude<
|
|
638
|
+
Style.LiteralDeclarations['transform'],
|
|
639
|
+
readonly unknown[] | undefined
|
|
640
|
+
>
|
|
641
|
+
: kind extends 'font'
|
|
642
|
+
? string
|
|
643
|
+
: kind extends 'size'
|
|
644
|
+
? Length | `${number}%` | 'auto'
|
|
645
|
+
: kind extends 'dimension' | 'offset'
|
|
646
|
+
? Length | `${number}%`
|
|
647
|
+
: kind extends 'integer' | 'number' | 'opacity'
|
|
648
|
+
? number
|
|
649
|
+
: kind extends 'ratio'
|
|
650
|
+
? number | `${number} / ${number}`
|
|
651
|
+
: kind extends 'weight'
|
|
652
|
+
? Weight
|
|
653
|
+
: kind extends 'line'
|
|
654
|
+
? Length | number
|
|
655
|
+
: kind extends 'box' | 'boxSigned'
|
|
656
|
+
? Box
|
|
657
|
+
: Length
|
|
658
|
+
|
|
659
|
+
type Reference<property extends keyof typeof properties> = {
|
|
660
|
+
[group in Token.Group]: property extends Token.Properties<group>
|
|
661
|
+
? Token.Reference<group> & { readonly [Token.web]?: never }
|
|
662
|
+
: never
|
|
663
|
+
}[Token.Group]
|
|
664
|
+
|
|
665
|
+
function convert(
|
|
666
|
+
kind: (typeof properties)[keyof typeof properties],
|
|
667
|
+
value: number | string,
|
|
668
|
+
options: compile.Options,
|
|
669
|
+
path: readonly string[],
|
|
670
|
+
): number | string {
|
|
671
|
+
try {
|
|
672
|
+
return Scalar.convert(kind, value, options, path)
|
|
673
|
+
} catch (error) {
|
|
674
|
+
fail('unsupported_value', (error as Error).message, path)
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
function fail(
|
|
679
|
+
code: Diagnostic['code'],
|
|
680
|
+
message: string,
|
|
681
|
+
path: readonly string[],
|
|
682
|
+
): never {
|
|
683
|
+
throw new CompileError([{ code, message, path }])
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
function length(
|
|
687
|
+
value: number | string,
|
|
688
|
+
options: compile.Options,
|
|
689
|
+
signed: boolean,
|
|
690
|
+
path: readonly string[],
|
|
691
|
+
): number {
|
|
692
|
+
try {
|
|
693
|
+
return Scalar.length(value, options, signed, path)
|
|
694
|
+
} catch (error) {
|
|
695
|
+
fail('unsupported_value', (error as Error).message, path)
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
type Origin = [number | `${number}%`, number | `${number}%`, number]
|
|
700
|
+
|
|
701
|
+
function origin(
|
|
702
|
+
value: number | string,
|
|
703
|
+
options: compile.Options,
|
|
704
|
+
path: readonly string[],
|
|
705
|
+
): Origin {
|
|
706
|
+
const parts = String(value).trim().toLowerCase().split(/\s+/)
|
|
707
|
+
if (!parts[0] || parts.length > 3)
|
|
708
|
+
fail(
|
|
709
|
+
'unsupported_value',
|
|
710
|
+
'Expected one to three transform-origin values.',
|
|
711
|
+
path,
|
|
712
|
+
)
|
|
713
|
+
let [x, y = 'center', z = '0'] = parts as [string, string?, string?]
|
|
714
|
+
const horizontal = ['left', 'center', 'right']
|
|
715
|
+
const vertical = ['top', 'center', 'bottom']
|
|
716
|
+
|
|
717
|
+
if (parts.length === 1 && (x === 'top' || x === 'bottom'))
|
|
718
|
+
[x, y] = ['center', x]
|
|
719
|
+
else if (x === 'top' || x === 'bottom' || y === 'left' || y === 'right') {
|
|
720
|
+
if (!vertical.includes(x) || !horizontal.includes(y))
|
|
721
|
+
fail(
|
|
722
|
+
'unsupported_value',
|
|
723
|
+
'Transform-origin keywords must identify different axes.',
|
|
724
|
+
path,
|
|
725
|
+
)
|
|
726
|
+
;[x, y] = [y, x]
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
const values = [x, y].map((part, index) => {
|
|
730
|
+
const keywords = index === 0 ? horizontal : vertical
|
|
731
|
+
const keyword = keywords.indexOf(part)
|
|
732
|
+
if (keyword !== -1) return `${keyword * 50}%` as `${number}%`
|
|
733
|
+
if (/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)%$/.test(part)) {
|
|
734
|
+
if (!Number.isFinite(Number(part.slice(0, -1))))
|
|
735
|
+
fail(
|
|
736
|
+
'unsupported_value',
|
|
737
|
+
'Transform-origin percentages must be finite.',
|
|
738
|
+
path,
|
|
739
|
+
)
|
|
740
|
+
return part as `${number}%`
|
|
741
|
+
}
|
|
742
|
+
return length(part, options, true, path)
|
|
743
|
+
})
|
|
744
|
+
// Native declares mutable origin arrays but reads them without mutation. Compiler-owned tuples remain frozen.
|
|
745
|
+
return Object.freeze([
|
|
746
|
+
values[0]!,
|
|
747
|
+
values[1]!,
|
|
748
|
+
length(z, options, true, path),
|
|
749
|
+
]) as Origin
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
function resolve(
|
|
753
|
+
value: Style.Declaration['value'],
|
|
754
|
+
metadata: Token.Metadata | undefined,
|
|
755
|
+
scheme: ColorScheme,
|
|
756
|
+
path: readonly string[],
|
|
757
|
+
resolution: { schemeIndependent: boolean },
|
|
758
|
+
): number | string {
|
|
759
|
+
if (typeof value === 'number' || typeof value === 'string') return value
|
|
760
|
+
if (
|
|
761
|
+
!Token.is(value) ||
|
|
762
|
+
Object.getOwnPropertyDescriptor(value, Token.web)?.value
|
|
763
|
+
)
|
|
764
|
+
fail(
|
|
765
|
+
'unsupported_feature',
|
|
766
|
+
'Web variables, expressions, and dynamic bindings are not native scalar tokens.',
|
|
767
|
+
path,
|
|
768
|
+
)
|
|
769
|
+
const shared =
|
|
770
|
+
metadata &&
|
|
771
|
+
(metadata.contract === value.contract ||
|
|
772
|
+
(metadata.contract[Token.identity] !== undefined &&
|
|
773
|
+
metadata.contract[Token.identity] === value.contract[Token.identity]))
|
|
774
|
+
const resolved = shared
|
|
775
|
+
? Object.hasOwn(metadata.values, value.path)
|
|
776
|
+
? metadata.values[value.path]
|
|
777
|
+
: undefined
|
|
778
|
+
: value.value
|
|
779
|
+
if (resolved === undefined)
|
|
780
|
+
fail('unsupported_value', 'Theme is missing a live token.', path)
|
|
781
|
+
if (typeof resolved === 'object' && resolved.light !== resolved.dark)
|
|
782
|
+
resolution.schemeIndependent = false
|
|
783
|
+
const scalar = typeof resolved === 'object' ? resolved[scheme] : resolved
|
|
784
|
+
if (typeof scalar !== 'string' && typeof scalar !== 'number')
|
|
785
|
+
fail(
|
|
786
|
+
'unsupported_value',
|
|
787
|
+
'Expected a complete scalar color-scheme pair.',
|
|
788
|
+
path,
|
|
789
|
+
)
|
|
790
|
+
return scalar
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
type TransformValues = {
|
|
794
|
+
matrix: number[]
|
|
795
|
+
perspective: number
|
|
796
|
+
rotate: string
|
|
797
|
+
rotateX: string
|
|
798
|
+
rotateY: string
|
|
799
|
+
rotateZ: string
|
|
800
|
+
scale: number
|
|
801
|
+
scaleX: number
|
|
802
|
+
scaleY: number
|
|
803
|
+
skewX: string
|
|
804
|
+
skewY: string
|
|
805
|
+
translateX: number | `${number}%`
|
|
806
|
+
translateY: number | `${number}%`
|
|
807
|
+
}
|
|
808
|
+
type Transform = {
|
|
809
|
+
[key in keyof TransformValues]: {
|
|
810
|
+
readonly [name in key]: TransformValues[key]
|
|
811
|
+
}
|
|
812
|
+
}[keyof TransformValues]
|
|
813
|
+
|
|
814
|
+
function transform(
|
|
815
|
+
value: number | string,
|
|
816
|
+
options: compile.Options,
|
|
817
|
+
path: readonly string[],
|
|
818
|
+
): readonly Transform[] {
|
|
819
|
+
if (typeof value !== 'string' || !value.trim())
|
|
820
|
+
fail('unsupported_value', 'Expected a static transform list.', path)
|
|
821
|
+
let remaining = value.trim()
|
|
822
|
+
const output: Transform[] = []
|
|
823
|
+
if (remaining === 'none') return Object.freeze(output)
|
|
824
|
+
|
|
825
|
+
while (remaining) {
|
|
826
|
+
const match = /^([a-z][a-z0-9]*)\(([^()]*)\)/i.exec(remaining)
|
|
827
|
+
if (!match)
|
|
828
|
+
fail('unsupported_value', 'Expected literal transform arguments.', path)
|
|
829
|
+
const name = match[1]!.toLowerCase()
|
|
830
|
+
const args = match[2]!.split(',').map((argument) => argument.trim())
|
|
831
|
+
const limit =
|
|
832
|
+
name === 'matrix'
|
|
833
|
+
? 6
|
|
834
|
+
: name === 'matrix3d'
|
|
835
|
+
? 16
|
|
836
|
+
: name === 'translate' || name === 'scale'
|
|
837
|
+
? 2
|
|
838
|
+
: 1
|
|
839
|
+
if (!args[0] || args.length > limit || args.some((arg) => !arg))
|
|
840
|
+
fail('unsupported_value', 'Invalid transform argument count.', path)
|
|
841
|
+
const argument = args[0]!
|
|
842
|
+
|
|
843
|
+
if (name === 'matrix' || name === 'matrix3d') {
|
|
844
|
+
if (
|
|
845
|
+
args.length !== limit ||
|
|
846
|
+
args.some(
|
|
847
|
+
(arg) =>
|
|
848
|
+
!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i.test(arg) ||
|
|
849
|
+
!Number.isFinite(Number(arg)),
|
|
850
|
+
)
|
|
851
|
+
)
|
|
852
|
+
fail(
|
|
853
|
+
'unsupported_value',
|
|
854
|
+
'Matrices require six or sixteen finite numbers.',
|
|
855
|
+
path,
|
|
856
|
+
)
|
|
857
|
+
const values = args.map(Number)
|
|
858
|
+
const matrix =
|
|
859
|
+
name === 'matrix'
|
|
860
|
+
? [
|
|
861
|
+
values[0]!,
|
|
862
|
+
values[1]!,
|
|
863
|
+
0,
|
|
864
|
+
0,
|
|
865
|
+
values[2]!,
|
|
866
|
+
values[3]!,
|
|
867
|
+
0,
|
|
868
|
+
0,
|
|
869
|
+
0,
|
|
870
|
+
0,
|
|
871
|
+
1,
|
|
872
|
+
0,
|
|
873
|
+
values[4]!,
|
|
874
|
+
values[5]!,
|
|
875
|
+
0,
|
|
876
|
+
1,
|
|
877
|
+
]
|
|
878
|
+
: values
|
|
879
|
+
const px = options.units?.px ?? 1
|
|
880
|
+
// Conjugate the matrix by the length scale, including projective components.
|
|
881
|
+
for (const index of [12, 13, 14]) matrix[index] = matrix[index]! * px
|
|
882
|
+
for (const index of [3, 7, 11]) matrix[index] = matrix[index]! / px
|
|
883
|
+
if (!matrix.every(Number.isFinite))
|
|
884
|
+
fail(
|
|
885
|
+
'unsupported_value',
|
|
886
|
+
'Converted matrix values must be finite.',
|
|
887
|
+
path,
|
|
888
|
+
)
|
|
889
|
+
Object.freeze(matrix)
|
|
890
|
+
output.push({ matrix })
|
|
891
|
+
} else if (
|
|
892
|
+
name === 'translate' ||
|
|
893
|
+
name === 'translatex' ||
|
|
894
|
+
name === 'translatey'
|
|
895
|
+
) {
|
|
896
|
+
const values = args.map((arg) => {
|
|
897
|
+
if (/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)%$/.test(arg)) {
|
|
898
|
+
if (!Number.isFinite(Number(arg.slice(0, -1))))
|
|
899
|
+
fail(
|
|
900
|
+
'unsupported_value',
|
|
901
|
+
'Transform percentages must be finite.',
|
|
902
|
+
path,
|
|
903
|
+
)
|
|
904
|
+
return arg as `${number}%`
|
|
905
|
+
}
|
|
906
|
+
return length(arg, options, true, path)
|
|
907
|
+
})
|
|
908
|
+
if (name === 'translatey') output.push({ translateY: values[0]! })
|
|
909
|
+
else {
|
|
910
|
+
output.push({ translateX: values[0]! })
|
|
911
|
+
if (name === 'translate') output.push({ translateY: values[1] ?? 0 })
|
|
912
|
+
}
|
|
913
|
+
} else if (name === 'scale' || name === 'scalex' || name === 'scaley') {
|
|
914
|
+
const values = args.map((arg) => {
|
|
915
|
+
if (
|
|
916
|
+
!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i.test(arg) ||
|
|
917
|
+
!Number.isFinite(Number(arg))
|
|
918
|
+
)
|
|
919
|
+
fail('unsupported_value', 'Scale requires finite numbers.', path)
|
|
920
|
+
return Number(arg)
|
|
921
|
+
})
|
|
922
|
+
if (name === 'scale' && values.length === 1)
|
|
923
|
+
output.push({ scale: values[0]! })
|
|
924
|
+
else if (name === 'scaley') output.push({ scaleY: values[0]! })
|
|
925
|
+
else {
|
|
926
|
+
output.push({ scaleX: values[0]! })
|
|
927
|
+
if (name === 'scale') output.push({ scaleY: values[1]! })
|
|
928
|
+
}
|
|
929
|
+
} else if (
|
|
930
|
+
['rotate', 'rotatex', 'rotatey', 'rotatez', 'skewx', 'skewy'].includes(
|
|
931
|
+
name,
|
|
932
|
+
)
|
|
933
|
+
) {
|
|
934
|
+
const angle =
|
|
935
|
+
/^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?)(deg|grad|rad|turn)$/i.exec(
|
|
936
|
+
argument,
|
|
937
|
+
)
|
|
938
|
+
if (!angle && argument !== '0')
|
|
939
|
+
fail(
|
|
940
|
+
'unsupported_value',
|
|
941
|
+
'Rotation and skew require literal angles.',
|
|
942
|
+
path,
|
|
943
|
+
)
|
|
944
|
+
const unit = angle?.[2]?.toLowerCase() ?? 'deg'
|
|
945
|
+
const number =
|
|
946
|
+
Number(angle?.[1] ?? 0) *
|
|
947
|
+
(unit === 'turn' ? 360 : unit === 'grad' ? 0.9 : 1)
|
|
948
|
+
if (!Number.isFinite(number))
|
|
949
|
+
fail('unsupported_value', 'Transform angles must be finite.', path)
|
|
950
|
+
const converted = `${number}${unit === 'rad' ? 'rad' : 'deg'}`
|
|
951
|
+
const property =
|
|
952
|
+
name === 'rotate'
|
|
953
|
+
? name
|
|
954
|
+
: `${name.slice(0, -1)}${name.at(-1)!.toUpperCase()}`
|
|
955
|
+
// Native transform entries have one key. Normalize CSS's case-insensitive function names.
|
|
956
|
+
output.push({ [property]: converted } as Transform)
|
|
957
|
+
} else if (name === 'perspective') {
|
|
958
|
+
const distance = length(argument, options, false, path)
|
|
959
|
+
// CSS clamps perspective distances below one CSS pixel before unit conversion.
|
|
960
|
+
output.push({ perspective: Math.max(distance, options.units?.px ?? 1) })
|
|
961
|
+
} else
|
|
962
|
+
fail(
|
|
963
|
+
'unsupported_feature',
|
|
964
|
+
'Transform function is outside the native subset.',
|
|
965
|
+
[...path, match[1]!],
|
|
966
|
+
)
|
|
967
|
+
|
|
968
|
+
remaining = remaining.slice(match[0].length).trimStart()
|
|
969
|
+
}
|
|
970
|
+
if (output.length > 1 && output.some((entry) => 'matrix' in entry)) {
|
|
971
|
+
let combined = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]
|
|
972
|
+
for (const entry of output) {
|
|
973
|
+
const matrix = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]
|
|
974
|
+
const [key, value] = Object.entries(entry)[0]!
|
|
975
|
+
if (key === 'matrix') matrix.splice(0, 16, ...(value as number[]))
|
|
976
|
+
else if (key.startsWith('translate')) {
|
|
977
|
+
if (typeof value !== 'number')
|
|
978
|
+
fail(
|
|
979
|
+
'unsupported_value',
|
|
980
|
+
'Matrix composition requires absolute translations.',
|
|
981
|
+
path,
|
|
982
|
+
)
|
|
983
|
+
matrix[key === 'translateX' ? 12 : 13] = value
|
|
984
|
+
} else if (key === 'perspective') matrix[11] = -1 / (value as number)
|
|
985
|
+
else if (key.startsWith('scale')) {
|
|
986
|
+
if (key !== 'scaleY') matrix[0] = value as number
|
|
987
|
+
if (key !== 'scaleX') matrix[5] = value as number
|
|
988
|
+
} else {
|
|
989
|
+
const angle =
|
|
990
|
+
Number.parseFloat(value as string) *
|
|
991
|
+
((value as string).endsWith('rad') ? 1 : Math.PI / 180)
|
|
992
|
+
if (key === 'skewX') matrix[4] = Math.tan(angle)
|
|
993
|
+
else if (key === 'skewY') matrix[1] = Math.tan(angle)
|
|
994
|
+
else {
|
|
995
|
+
const [a, b] =
|
|
996
|
+
key === 'rotateX' ? [1, 2] : key === 'rotateY' ? [2, 0] : [0, 1]
|
|
997
|
+
matrix[a! * 4 + a!] = Math.cos(angle)
|
|
998
|
+
matrix[b! * 4 + b!] = Math.cos(angle)
|
|
999
|
+
matrix[a! * 4 + b!] = Math.sin(angle)
|
|
1000
|
+
matrix[b! * 4 + a!] = -Math.sin(angle)
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
combined = combined.map((_, index) => {
|
|
1004
|
+
const row = index % 4
|
|
1005
|
+
const column = Math.floor(index / 4)
|
|
1006
|
+
return [0, 1, 2, 3].reduce(
|
|
1007
|
+
(sum, k) => sum + combined[k * 4 + row]! * matrix[column * 4 + k]!,
|
|
1008
|
+
0,
|
|
1009
|
+
)
|
|
1010
|
+
})
|
|
1011
|
+
}
|
|
1012
|
+
if (!combined.every(Number.isFinite))
|
|
1013
|
+
fail('unsupported_value', 'Converted matrix values must be finite.', path)
|
|
1014
|
+
Object.freeze(combined)
|
|
1015
|
+
// React Native requires a matrix to be the only transform entry.
|
|
1016
|
+
return Object.freeze([Object.freeze({ matrix: combined })])
|
|
1017
|
+
}
|
|
1018
|
+
return Object.freeze(output.map((entry) => Object.freeze(entry)))
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
function shadows(
|
|
1022
|
+
value: number | string,
|
|
1023
|
+
options: compile.Options,
|
|
1024
|
+
path: readonly string[],
|
|
1025
|
+
text = false,
|
|
1026
|
+
): Extract<NonNullable<Native.Output['boxShadow']>, readonly unknown[]> {
|
|
1027
|
+
if (value === 'none') return Object.freeze([])
|
|
1028
|
+
if (typeof value !== 'string')
|
|
1029
|
+
fail('unsupported_value', 'Expected a static shadow list.', path)
|
|
1030
|
+
return Object.freeze(
|
|
1031
|
+
value.split(/,(?![^()]*\))/).map((shadow) => {
|
|
1032
|
+
const parts = shadow.trim().match(/[a-z]+\([^()]*\)|[^\s]+/gi) ?? []
|
|
1033
|
+
const lengths: number[] = []
|
|
1034
|
+
let color: string | undefined
|
|
1035
|
+
let inset = false
|
|
1036
|
+
for (const part of parts) {
|
|
1037
|
+
if (part === 'inset' && !inset) {
|
|
1038
|
+
inset = true
|
|
1039
|
+
continue
|
|
1040
|
+
}
|
|
1041
|
+
const parsed = Color.parse(part)
|
|
1042
|
+
if (parsed !== undefined && color === undefined) {
|
|
1043
|
+
color = parsed
|
|
1044
|
+
continue
|
|
1045
|
+
}
|
|
1046
|
+
lengths.push(length(part, options, true, path))
|
|
1047
|
+
}
|
|
1048
|
+
if (
|
|
1049
|
+
lengths.length < 2 ||
|
|
1050
|
+
lengths.length > (text ? 3 : 4) ||
|
|
1051
|
+
(text && inset) ||
|
|
1052
|
+
(lengths[2] ?? 0) < 0 ||
|
|
1053
|
+
color === undefined
|
|
1054
|
+
)
|
|
1055
|
+
fail(
|
|
1056
|
+
'unsupported_value',
|
|
1057
|
+
'Shadows require two to four lengths, a nonnegative blur, and an explicit absolute color.',
|
|
1058
|
+
path,
|
|
1059
|
+
)
|
|
1060
|
+
return Object.freeze({
|
|
1061
|
+
offsetX: lengths[0]!,
|
|
1062
|
+
offsetY: lengths[1]!,
|
|
1063
|
+
blurRadius: lengths[2] ?? 0,
|
|
1064
|
+
spreadDistance: lengths[3] ?? 0,
|
|
1065
|
+
color,
|
|
1066
|
+
inset,
|
|
1067
|
+
})
|
|
1068
|
+
}),
|
|
1069
|
+
)
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
function sequence(style: Style.NamedStyle): readonly Style.NamedStyle[] {
|
|
1073
|
+
const parts = [style]
|
|
1074
|
+
for (const rule of style.rules ?? []) {
|
|
1075
|
+
if (rule.condition !== undefined)
|
|
1076
|
+
fail(
|
|
1077
|
+
'unsupported_feature',
|
|
1078
|
+
'Selectors, queries, and nested rules are not supported on native.',
|
|
1079
|
+
[style.name],
|
|
1080
|
+
)
|
|
1081
|
+
parts.push(...sequence(rule.style))
|
|
1082
|
+
}
|
|
1083
|
+
return parts
|
|
1084
|
+
}
|