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,273 @@
|
|
|
1
|
+
/** Applies compiler replacements without reparsing unaffected authoring. @module */
|
|
2
|
+
import type * as Babel from '@babel/core'
|
|
3
|
+
import type * as Edits from '../compiler/internal/Edits.js'
|
|
4
|
+
import * as NativeJsx from './NativeJsx.js'
|
|
5
|
+
|
|
6
|
+
/** Retains original nodes and locations outside compiler-owned spans. */
|
|
7
|
+
export function apply(
|
|
8
|
+
api: typeof Babel,
|
|
9
|
+
ast: Babel.types.File,
|
|
10
|
+
options: Babel.TransformOptions,
|
|
11
|
+
edits: readonly Edits.Edit[],
|
|
12
|
+
callables: WeakSet<Babel.types.Node>,
|
|
13
|
+
) {
|
|
14
|
+
const expressions = edits.filter((edit) => edit.expression)
|
|
15
|
+
const parse = (source: string) => {
|
|
16
|
+
const ast = api.parseSync(source, {
|
|
17
|
+
babelrc: false,
|
|
18
|
+
configFile: false,
|
|
19
|
+
filename: options.filename,
|
|
20
|
+
parserOpts: options.parserOpts,
|
|
21
|
+
})
|
|
22
|
+
if (!ast) throw new Error('Babel did not parse native replacements.')
|
|
23
|
+
return ast.program.body
|
|
24
|
+
}
|
|
25
|
+
const compiled = expressions.length
|
|
26
|
+
? parse(expressions.map((edit) => `(${edit.code});`).join('\n'))
|
|
27
|
+
: []
|
|
28
|
+
const replacements = new Map<
|
|
29
|
+
number,
|
|
30
|
+
{ end: number; node: Babel.types.Expression }
|
|
31
|
+
>()
|
|
32
|
+
for (const [index, edit] of expressions.entries()) {
|
|
33
|
+
const statement = compiled[index]
|
|
34
|
+
if (!statement || !api.types.isExpressionStatement(statement))
|
|
35
|
+
throw new Error('Invalid compiled native expression.')
|
|
36
|
+
callables.add(statement.expression)
|
|
37
|
+
replacements.set(edit.start, { end: edit.end, node: statement.expression })
|
|
38
|
+
}
|
|
39
|
+
// Generated expressions map to their authoring call; unaffected nodes retain precise locations.
|
|
40
|
+
function locate(node: Babel.types.Node, original: Babel.types.Node) {
|
|
41
|
+
api.types.traverseFast(node, (child) => {
|
|
42
|
+
child.loc = original.loc ?? null
|
|
43
|
+
child.start = original.start ?? null
|
|
44
|
+
child.end = original.end ?? null
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
function rewrite(node: Babel.types.Node): Babel.types.Node {
|
|
48
|
+
const replacement =
|
|
49
|
+
api.types.isCallExpression(node) && replacements.get(node.start!)
|
|
50
|
+
if (replacement && replacement.end === node.end) {
|
|
51
|
+
locate(replacement.node, node)
|
|
52
|
+
api.types.inheritsComments(replacement.node, node)
|
|
53
|
+
return replacement.node
|
|
54
|
+
}
|
|
55
|
+
for (const key of api.types.VISITOR_KEYS[node.type] ?? []) {
|
|
56
|
+
const value: unknown = Reflect.get(node, key)
|
|
57
|
+
if (Array.isArray(value)) {
|
|
58
|
+
for (let index = 0; index < value.length; index++)
|
|
59
|
+
if (api.types.isNode(value[index]))
|
|
60
|
+
value[index] = rewrite(value[index])
|
|
61
|
+
} else if (api.types.isNode(value)) Reflect.set(node, key, rewrite(value))
|
|
62
|
+
}
|
|
63
|
+
return node
|
|
64
|
+
}
|
|
65
|
+
rewrite(ast)
|
|
66
|
+
for (const edit of edits) {
|
|
67
|
+
if (edit.expression) continue
|
|
68
|
+
const nodes = edit.code ? parse(edit.code) : []
|
|
69
|
+
if (edit.start === edit.end) {
|
|
70
|
+
for (const node of nodes) {
|
|
71
|
+
api.types.traverseFast(node, (child) => {
|
|
72
|
+
if (child.loc) {
|
|
73
|
+
child.loc.start = { line: 1, column: 0, index: 0 }
|
|
74
|
+
child.loc.end = { line: 1, column: 0, index: 0 }
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
ast.program.body.unshift(...nodes)
|
|
79
|
+
continue
|
|
80
|
+
}
|
|
81
|
+
const index = ast.program.body.findIndex(
|
|
82
|
+
(node) => node.start === edit.start && node.end === edit.end,
|
|
83
|
+
)
|
|
84
|
+
if (index < 0) throw new Error('Missing native statement replacement.')
|
|
85
|
+
for (const node of nodes) locate(node, ast.program.body[index]!)
|
|
86
|
+
ast.program.body.splice(index, 1, ...nodes)
|
|
87
|
+
}
|
|
88
|
+
merge(api, ast, expressions)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function merge(
|
|
92
|
+
api: typeof Babel,
|
|
93
|
+
ast: Babel.types.File,
|
|
94
|
+
expressions: readonly Edits.Edit[],
|
|
95
|
+
) {
|
|
96
|
+
const starts = new Set(expressions.map((edit) => edit.start))
|
|
97
|
+
const body: Babel.types.Statement[] = []
|
|
98
|
+
let previous: Babel.types.VariableDeclaration | undefined
|
|
99
|
+
let merged = false
|
|
100
|
+
for (const statement of ast.program.body) {
|
|
101
|
+
const declaration =
|
|
102
|
+
api.types.isVariableDeclaration(statement) &&
|
|
103
|
+
statement.declarations.every(
|
|
104
|
+
(entry) => entry.init && starts.has(entry.init.start!),
|
|
105
|
+
)
|
|
106
|
+
? statement
|
|
107
|
+
: undefined
|
|
108
|
+
if (declaration && previous?.kind === declaration.kind) {
|
|
109
|
+
previous.declarations.push(...declaration.declarations)
|
|
110
|
+
api.types.inheritsComments(previous, declaration)
|
|
111
|
+
previous.end = declaration.end ?? null
|
|
112
|
+
if (previous.loc && declaration.loc)
|
|
113
|
+
previous.loc = { ...previous.loc, end: declaration.loc.end }
|
|
114
|
+
merged = true
|
|
115
|
+
} else {
|
|
116
|
+
body.push(statement)
|
|
117
|
+
previous = declaration
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (merged) {
|
|
121
|
+
// Babel's block-scoping transform scans the scope once per declaration, regardless of its number of bindings.
|
|
122
|
+
ast.program.body = body
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** Parses rewritten source once and restores original locations from ordered edits. */
|
|
127
|
+
export function parse(
|
|
128
|
+
api: typeof Babel,
|
|
129
|
+
source: string,
|
|
130
|
+
options: Babel.ParserOptions,
|
|
131
|
+
edits: readonly Edits.Edit[],
|
|
132
|
+
parser: (source: string, options: Babel.ParserOptions) => Babel.types.File,
|
|
133
|
+
callables: WeakSet<Babel.types.Node>,
|
|
134
|
+
): Babel.types.File | undefined {
|
|
135
|
+
if (
|
|
136
|
+
options.tokens ||
|
|
137
|
+
options.ranges ||
|
|
138
|
+
(options.startLine !== undefined && options.startLine !== 1) ||
|
|
139
|
+
(options.startColumn !== undefined && options.startColumn !== 0) ||
|
|
140
|
+
(options.startIndex !== undefined && options.startIndex !== 0)
|
|
141
|
+
)
|
|
142
|
+
return undefined
|
|
143
|
+
if (!edits.length) return parser(source, options)
|
|
144
|
+
|
|
145
|
+
type Segment = {
|
|
146
|
+
start: number
|
|
147
|
+
original: number
|
|
148
|
+
replacement?: Edits.Edit
|
|
149
|
+
}
|
|
150
|
+
const segments: Segment[] = []
|
|
151
|
+
const chunks: string[] = []
|
|
152
|
+
let length = 0
|
|
153
|
+
let cursor = 0
|
|
154
|
+
for (const edit of [...edits].sort(
|
|
155
|
+
(a, b) => a.start - b.start || a.end - b.end,
|
|
156
|
+
)) {
|
|
157
|
+
if (edit.start < cursor) return undefined
|
|
158
|
+
if (edit.start > cursor) {
|
|
159
|
+
const chunk = source.slice(cursor, edit.start)
|
|
160
|
+
segments.push({
|
|
161
|
+
start: length,
|
|
162
|
+
original: cursor,
|
|
163
|
+
})
|
|
164
|
+
chunks.push(chunk)
|
|
165
|
+
length += chunk.length
|
|
166
|
+
}
|
|
167
|
+
if (edit.code) {
|
|
168
|
+
segments.push({
|
|
169
|
+
start: length,
|
|
170
|
+
original: edit.start,
|
|
171
|
+
replacement: edit,
|
|
172
|
+
})
|
|
173
|
+
chunks.push(edit.code)
|
|
174
|
+
length += edit.code.length
|
|
175
|
+
}
|
|
176
|
+
cursor = edit.end
|
|
177
|
+
}
|
|
178
|
+
segments.push({
|
|
179
|
+
start: length,
|
|
180
|
+
original: cursor,
|
|
181
|
+
})
|
|
182
|
+
chunks.push(source.slice(cursor))
|
|
183
|
+
const ast = parser(chunks.join(''), options)
|
|
184
|
+
const lines = [0]
|
|
185
|
+
for (let index = 0; index < source.length; index++) {
|
|
186
|
+
const character = source.charCodeAt(index)
|
|
187
|
+
if (character === 13 && source.charCodeAt(index + 1) === 10) index++
|
|
188
|
+
if (
|
|
189
|
+
character === 10 ||
|
|
190
|
+
character === 13 ||
|
|
191
|
+
character === 0x2028 ||
|
|
192
|
+
character === 0x2029
|
|
193
|
+
)
|
|
194
|
+
lines.push(index + 1)
|
|
195
|
+
}
|
|
196
|
+
function segmentAt(value: number): number {
|
|
197
|
+
let low = 0
|
|
198
|
+
let high = segments.length - 1
|
|
199
|
+
while (low < high) {
|
|
200
|
+
const middle = (low + high + 1) >>> 1
|
|
201
|
+
if (segments[middle]!.start <= value) low = middle
|
|
202
|
+
else high = middle - 1
|
|
203
|
+
}
|
|
204
|
+
return low
|
|
205
|
+
}
|
|
206
|
+
function offset(
|
|
207
|
+
value: number,
|
|
208
|
+
end: boolean,
|
|
209
|
+
index = segmentAt(value),
|
|
210
|
+
): number {
|
|
211
|
+
const segment = segments[index]!
|
|
212
|
+
if (segment.replacement) {
|
|
213
|
+
if (end && value > segment.start) return segment.replacement.end
|
|
214
|
+
return segment.original
|
|
215
|
+
}
|
|
216
|
+
return segment.original + value - segment.start
|
|
217
|
+
}
|
|
218
|
+
function position(index: number) {
|
|
219
|
+
let low = 0
|
|
220
|
+
let high = lines.length - 1
|
|
221
|
+
while (low < high) {
|
|
222
|
+
const middle = (low + high + 1) >>> 1
|
|
223
|
+
if (lines[middle]! <= index) low = middle
|
|
224
|
+
else high = middle - 1
|
|
225
|
+
}
|
|
226
|
+
return { line: low + 1, column: index - lines[low]!, index }
|
|
227
|
+
}
|
|
228
|
+
function locate(node: Babel.types.Node | Babel.types.Comment) {
|
|
229
|
+
if (
|
|
230
|
+
node.start === undefined ||
|
|
231
|
+
node.start === null ||
|
|
232
|
+
node.end === undefined ||
|
|
233
|
+
node.end === null
|
|
234
|
+
)
|
|
235
|
+
return
|
|
236
|
+
const index = segmentAt(node.start)
|
|
237
|
+
const segment = segments[index]!
|
|
238
|
+
if (
|
|
239
|
+
node.type === 'CallExpression' &&
|
|
240
|
+
segment.replacement?.expression &&
|
|
241
|
+
node.start === segment.start &&
|
|
242
|
+
node.end === segment.start + segment.replacement.code.length
|
|
243
|
+
)
|
|
244
|
+
callables.add(node)
|
|
245
|
+
const endIndex =
|
|
246
|
+
node.end < (segments[index + 1]?.start ?? Infinity)
|
|
247
|
+
? index
|
|
248
|
+
: segmentAt(node.end)
|
|
249
|
+
node.start = offset(node.start, false, index)
|
|
250
|
+
node.end = offset(node.end, true, endIndex)
|
|
251
|
+
if (node.loc)
|
|
252
|
+
node.loc = {
|
|
253
|
+
...node.loc,
|
|
254
|
+
start: position(node.start),
|
|
255
|
+
end: position(node.end),
|
|
256
|
+
}
|
|
257
|
+
if ('extra' in node && typeof node.extra?.parenStart === 'number')
|
|
258
|
+
node.extra.parenStart = offset(node.extra.parenStart, false)
|
|
259
|
+
}
|
|
260
|
+
const jsx = NativeJsx.prepare(api, ast, callables)
|
|
261
|
+
api.types.traverseFast(ast, (node) => {
|
|
262
|
+
locate(node)
|
|
263
|
+
jsx?.enter(node)
|
|
264
|
+
})
|
|
265
|
+
for (const comment of ast.comments ?? []) locate(comment)
|
|
266
|
+
merge(
|
|
267
|
+
api,
|
|
268
|
+
ast,
|
|
269
|
+
edits.filter((edit) => edit.expression),
|
|
270
|
+
)
|
|
271
|
+
jsx?.finish()
|
|
272
|
+
return ast
|
|
273
|
+
}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/** Subscribes native JSX consumers without conditional hooks in style callables. @module */
|
|
2
|
+
import type * as Babel from '@babel/core'
|
|
3
|
+
|
|
4
|
+
/** Reduces unshadowed immutable local style reads before Babel discovers scopes. */
|
|
5
|
+
export function prepare(
|
|
6
|
+
api: typeof Babel,
|
|
7
|
+
ast: Babel.types.File,
|
|
8
|
+
callables: WeakSet<Babel.types.Node>,
|
|
9
|
+
) {
|
|
10
|
+
const t = api.types
|
|
11
|
+
const bindings = new Map<string, Babel.types.Identifier>()
|
|
12
|
+
const initializers = new Map<
|
|
13
|
+
Babel.types.Identifier,
|
|
14
|
+
Babel.types.CallExpression
|
|
15
|
+
>()
|
|
16
|
+
for (const statement of ast.program.body) {
|
|
17
|
+
const declaration = t.isExportNamedDeclaration(statement)
|
|
18
|
+
? statement.declaration
|
|
19
|
+
: statement
|
|
20
|
+
if (!t.isVariableDeclaration(declaration, { kind: 'const' })) continue
|
|
21
|
+
for (const entry of declaration.declarations)
|
|
22
|
+
if (t.isIdentifier(entry.id) && t.isCallExpression(entry.init)) {
|
|
23
|
+
bindings.set(entry.id.name, entry.id)
|
|
24
|
+
initializers.set(entry.id, entry.init)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (!bindings.size) return
|
|
28
|
+
const attributes: Babel.types.JSXAttribute[] = []
|
|
29
|
+
let dynamicScope = false
|
|
30
|
+
function enter(node: Babel.types.Node) {
|
|
31
|
+
if (t.isTSParameterProperty(node) || t.isWithStatement(node))
|
|
32
|
+
dynamicScope = true
|
|
33
|
+
if (
|
|
34
|
+
t.isCallExpression(node) &&
|
|
35
|
+
t.isIdentifier(node.callee, { name: 'eval' })
|
|
36
|
+
)
|
|
37
|
+
dynamicScope = true
|
|
38
|
+
if (t.isJSXAttribute(node)) attributes.push(node)
|
|
39
|
+
if (
|
|
40
|
+
t.isVariableDeclarator(node) ||
|
|
41
|
+
t.isFunction(node) ||
|
|
42
|
+
t.isClass(node) ||
|
|
43
|
+
t.isCatchClause(node) ||
|
|
44
|
+
t.isImportSpecifier(node) ||
|
|
45
|
+
t.isImportDefaultSpecifier(node) ||
|
|
46
|
+
t.isImportNamespaceSpecifier(node) ||
|
|
47
|
+
t.isAssignmentExpression(node) ||
|
|
48
|
+
t.isUpdateExpression(node) ||
|
|
49
|
+
t.isForInStatement(node) ||
|
|
50
|
+
t.isForOfStatement(node) ||
|
|
51
|
+
(node.type.startsWith('TS') && node.type.endsWith('Declaration'))
|
|
52
|
+
) {
|
|
53
|
+
for (const [name, identifiers] of Object.entries(
|
|
54
|
+
t.getBindingIdentifiers(node, true),
|
|
55
|
+
))
|
|
56
|
+
if (identifiers.some((identifier) => bindings.get(name) !== identifier))
|
|
57
|
+
bindings.delete(name)
|
|
58
|
+
if (
|
|
59
|
+
'id' in node &&
|
|
60
|
+
t.isIdentifier(node.id) &&
|
|
61
|
+
bindings.get(node.id.name) !== node.id
|
|
62
|
+
)
|
|
63
|
+
bindings.delete(node.id.name)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function finish() {
|
|
67
|
+
if (dynamicScope) return
|
|
68
|
+
for (const [name, identifier] of bindings)
|
|
69
|
+
if (!callables.has(initializers.get(identifier)!)) bindings.delete(name)
|
|
70
|
+
if (!bindings.size) return
|
|
71
|
+
for (const attribute of attributes) {
|
|
72
|
+
if (
|
|
73
|
+
!t.isJSXIdentifier(attribute.name, { name: 'style' }) ||
|
|
74
|
+
!t.isJSXExpressionContainer(attribute.value)
|
|
75
|
+
)
|
|
76
|
+
continue
|
|
77
|
+
let value = attribute.value.expression
|
|
78
|
+
while (
|
|
79
|
+
t.isTSAsExpression(value) ||
|
|
80
|
+
t.isTSTypeAssertion(value) ||
|
|
81
|
+
t.isTSNonNullExpression(value) ||
|
|
82
|
+
t.isTSSatisfiesExpression(value) ||
|
|
83
|
+
t.isParenthesizedExpression(value)
|
|
84
|
+
)
|
|
85
|
+
value = value.expression
|
|
86
|
+
if (
|
|
87
|
+
!t.isMemberExpression(value) ||
|
|
88
|
+
value.computed ||
|
|
89
|
+
!t.isIdentifier(value.property, { name: 'style' }) ||
|
|
90
|
+
!t.isCallExpression(value.object) ||
|
|
91
|
+
value.object.arguments.length > 1 ||
|
|
92
|
+
!value.object.arguments.every((argument) => t.isExpression(argument)) ||
|
|
93
|
+
!t.isIdentifier(value.object.callee) ||
|
|
94
|
+
!bindings.has(value.object.callee.name)
|
|
95
|
+
)
|
|
96
|
+
continue
|
|
97
|
+
const call = value.object
|
|
98
|
+
const callee = value.object.callee
|
|
99
|
+
t.inheritsComments(callee, attribute.value.expression)
|
|
100
|
+
t.inheritsComments(callee, value)
|
|
101
|
+
t.inheritsComments(callee, call)
|
|
102
|
+
callables.add(callee)
|
|
103
|
+
attribute.value.expression = call.arguments.length ? call : callee
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return { enter, finish }
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Shares Babel's normal traversal and adds one context read per styled owner. */
|
|
110
|
+
export function visitor(
|
|
111
|
+
api: typeof Babel,
|
|
112
|
+
callables: WeakSet<Babel.types.Node>,
|
|
113
|
+
): Babel.Visitor<Babel.PluginPass> {
|
|
114
|
+
const t = api.types
|
|
115
|
+
type Bindings = Map<'props' | 'style', Babel.types.Identifier>
|
|
116
|
+
type Owners = Map<Babel.NodePath<Babel.types.Function>, Bindings>
|
|
117
|
+
const files = new WeakMap<Babel.BabelFile, Owners>()
|
|
118
|
+
return {
|
|
119
|
+
Program: {
|
|
120
|
+
enter(_, state) {
|
|
121
|
+
files.set(state.file, new Map())
|
|
122
|
+
},
|
|
123
|
+
exit(path, state) {
|
|
124
|
+
const owners = files.get(state.file)!
|
|
125
|
+
if (!owners.size) return
|
|
126
|
+
const hook = path.scope.generateUidIdentifier('useZyzzStyles')
|
|
127
|
+
path.unshiftContainer(
|
|
128
|
+
'body',
|
|
129
|
+
t.importDeclaration(
|
|
130
|
+
[t.importSpecifier(hook, t.identifier('useStyles'))],
|
|
131
|
+
t.stringLiteral('zyzz/react-native/react'),
|
|
132
|
+
),
|
|
133
|
+
)
|
|
134
|
+
for (const [owner, bindings] of owners) {
|
|
135
|
+
if (!t.isBlockStatement(owner.node.body))
|
|
136
|
+
owner.node.body = t.blockStatement([
|
|
137
|
+
t.returnStatement(owner.node.body),
|
|
138
|
+
])
|
|
139
|
+
const context =
|
|
140
|
+
bindings.size > 1
|
|
141
|
+
? owner.scope.generateUidIdentifier('zyzzStyles')
|
|
142
|
+
: undefined
|
|
143
|
+
const declarations = context
|
|
144
|
+
? [t.variableDeclarator(context, t.callExpression(hook, []))]
|
|
145
|
+
: []
|
|
146
|
+
for (const [method, binding] of bindings)
|
|
147
|
+
declarations.push(
|
|
148
|
+
t.variableDeclarator(
|
|
149
|
+
binding,
|
|
150
|
+
t.memberExpression(
|
|
151
|
+
context ?? t.callExpression(hook, []),
|
|
152
|
+
t.identifier(method),
|
|
153
|
+
),
|
|
154
|
+
),
|
|
155
|
+
)
|
|
156
|
+
owner.node.body.body.unshift(
|
|
157
|
+
t.variableDeclaration('var', declarations),
|
|
158
|
+
)
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
JSXAttribute(path, state) {
|
|
163
|
+
if (
|
|
164
|
+
!t.isJSXIdentifier(path.node.name, { name: 'style' }) ||
|
|
165
|
+
!t.isJSXExpressionContainer(path.node.value) ||
|
|
166
|
+
t.isJSXEmptyExpression(path.node.value.expression)
|
|
167
|
+
)
|
|
168
|
+
return
|
|
169
|
+
const binding = owner(path, files.get(state.file)!, 'style')
|
|
170
|
+
let inputs = [path.node.value.expression]
|
|
171
|
+
let value = path.node.value.expression
|
|
172
|
+
while (
|
|
173
|
+
t.isTSAsExpression(value) ||
|
|
174
|
+
t.isTSTypeAssertion(value) ||
|
|
175
|
+
t.isTSNonNullExpression(value) ||
|
|
176
|
+
t.isTSSatisfiesExpression(value) ||
|
|
177
|
+
t.isParenthesizedExpression(value)
|
|
178
|
+
)
|
|
179
|
+
value = value.expression
|
|
180
|
+
if (t.isIdentifier(value) && callables.has(value)) inputs = [value]
|
|
181
|
+
else if (
|
|
182
|
+
t.isCallExpression(value) &&
|
|
183
|
+
t.isIdentifier(value.callee) &&
|
|
184
|
+
callables.has(value.callee)
|
|
185
|
+
)
|
|
186
|
+
inputs = [
|
|
187
|
+
value.callee,
|
|
188
|
+
...value.arguments.filter((argument) => t.isExpression(argument)),
|
|
189
|
+
]
|
|
190
|
+
else if (
|
|
191
|
+
t.isMemberExpression(value) &&
|
|
192
|
+
!value.computed &&
|
|
193
|
+
t.isIdentifier(value.property, { name: 'style' }) &&
|
|
194
|
+
t.isCallExpression(value.object) &&
|
|
195
|
+
value.object.arguments.length <= 1 &&
|
|
196
|
+
value.object.arguments.every((argument) => t.isExpression(argument)) &&
|
|
197
|
+
t.isIdentifier(value.object.callee)
|
|
198
|
+
) {
|
|
199
|
+
const declaration = path.scope.getBinding(value.object.callee.name)
|
|
200
|
+
if (
|
|
201
|
+
declaration?.constant &&
|
|
202
|
+
declaration.path.isVariableDeclarator() &&
|
|
203
|
+
declaration.path.node.init &&
|
|
204
|
+
callables.has(declaration.path.node.init)
|
|
205
|
+
) {
|
|
206
|
+
t.inheritsComments(value.object.callee, path.node.value.expression)
|
|
207
|
+
t.inheritsComments(value.object.callee, value)
|
|
208
|
+
t.inheritsComments(value.object.callee, value.object)
|
|
209
|
+
const input = value.object.arguments[0]
|
|
210
|
+
inputs =
|
|
211
|
+
input && t.isExpression(input)
|
|
212
|
+
? [value.object.callee, input]
|
|
213
|
+
: [value.object.callee]
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
path.node.value.expression = t.callExpression(binding, inputs)
|
|
217
|
+
},
|
|
218
|
+
JSXSpreadAttribute(path, state) {
|
|
219
|
+
const binding = owner(path, files.get(state.file)!, 'props')
|
|
220
|
+
path.node.argument = t.callExpression(binding, [path.node.argument])
|
|
221
|
+
},
|
|
222
|
+
}
|
|
223
|
+
function owner(
|
|
224
|
+
path: Babel.NodePath,
|
|
225
|
+
owners: Owners,
|
|
226
|
+
method: 'props' | 'style',
|
|
227
|
+
): Babel.types.Identifier {
|
|
228
|
+
const parent = path.findParent((candidate) => {
|
|
229
|
+
if (!candidate.isFunction()) return false
|
|
230
|
+
let declaration = candidate.parentPath
|
|
231
|
+
while (declaration.isCallExpression())
|
|
232
|
+
declaration = declaration.parentPath
|
|
233
|
+
const name =
|
|
234
|
+
('id' in candidate.node ? candidate.node.id?.name : undefined) ??
|
|
235
|
+
(declaration.isVariableDeclarator() &&
|
|
236
|
+
t.isIdentifier(declaration.node.id)
|
|
237
|
+
? declaration.node.id.name
|
|
238
|
+
: undefined)
|
|
239
|
+
return (
|
|
240
|
+
(!!name && (/^[A-Z]/.test(name) || /^use[A-Z]/.test(name))) ||
|
|
241
|
+
candidate.parentPath.isExportDefaultDeclaration()
|
|
242
|
+
)
|
|
243
|
+
})
|
|
244
|
+
if (!parent?.isFunction() || parent.isClassMethod())
|
|
245
|
+
throw path.buildCodeFrameError(
|
|
246
|
+
'Native style props must be rendered in a function component or custom hook.',
|
|
247
|
+
)
|
|
248
|
+
let bindings = owners.get(parent)
|
|
249
|
+
if (!bindings) {
|
|
250
|
+
bindings = new Map()
|
|
251
|
+
owners.set(parent, bindings)
|
|
252
|
+
}
|
|
253
|
+
let binding = bindings.get(method)
|
|
254
|
+
if (!binding) {
|
|
255
|
+
binding = parent.scope.generateUidIdentifier(`zyzz${method}`)
|
|
256
|
+
bindings.set(method, binding)
|
|
257
|
+
}
|
|
258
|
+
return binding
|
|
259
|
+
}
|
|
260
|
+
}
|