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,801 @@
|
|
|
1
|
+
/** Rewrites shared authoring to native tables and ordered runtime bindings. @module */
|
|
2
|
+
import type * as Ast from '@oxc-project/types'
|
|
3
|
+
import MagicString from 'magic-string'
|
|
4
|
+
import type * as Recipe from '../internal/Recipe.js'
|
|
5
|
+
import * as Source from './Source.js'
|
|
6
|
+
import * as Edits from './internal/Edits.js'
|
|
7
|
+
import * as NativeBindings from './internal/NativeBindings.js'
|
|
8
|
+
import * as Themes from './internal/Themes.js'
|
|
9
|
+
import * as StyleSheet from '../react-native/StyleSheet.js'
|
|
10
|
+
import * as Syntax from './internal/Syntax.js'
|
|
11
|
+
import * as Variants from '../react-native/Variants.js'
|
|
12
|
+
import * as Walker from 'oxc-walker'
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Compiles local style and variants calls for an explicit native context.
|
|
16
|
+
* @param options - Shared source, destination mappings, and selected theme/scheme.
|
|
17
|
+
* @returns Native callables, source map, and static recipe tables.
|
|
18
|
+
* @throws {Source.ExtractError} For invalid source authoring.
|
|
19
|
+
* @throws {CompileError} For native features outside the static source boundary.
|
|
20
|
+
* @throws {StyleSheet.CompileError} For unsupported native declaration values.
|
|
21
|
+
*/
|
|
22
|
+
export function compile(options: compile.Options): compile.ReturnType {
|
|
23
|
+
const typed = !options[Edits.runtime] && /\.[cm]?tsx?$/.test(options.moduleId)
|
|
24
|
+
const extracted =
|
|
25
|
+
options[Themes.context]?.extracted ??
|
|
26
|
+
Source.extract({
|
|
27
|
+
moduleId: options.moduleId,
|
|
28
|
+
source: options.source,
|
|
29
|
+
target: 'native',
|
|
30
|
+
[Themes.context]: options[Themes.context],
|
|
31
|
+
})
|
|
32
|
+
if (
|
|
33
|
+
extracted.contributions?.length ||
|
|
34
|
+
extracted.variableCalls?.length ||
|
|
35
|
+
extracted.themeReferences.length ||
|
|
36
|
+
extracted.themeSelections?.length ||
|
|
37
|
+
(!options.contextual &&
|
|
38
|
+
(extracted.themeAppearances?.length || extracted.themeScripts?.length))
|
|
39
|
+
)
|
|
40
|
+
throw new CompileError(
|
|
41
|
+
'Native static modules do not support CSS contributions, variables, or web theme controls.',
|
|
42
|
+
)
|
|
43
|
+
const parsed = options[Themes.context]?.parsed ?? Syntax.parse(options)
|
|
44
|
+
const names = new Set(options[Themes.context]?.identifiers)
|
|
45
|
+
if (!options[Themes.context]?.identifiers)
|
|
46
|
+
Walker.walk(parsed.program, {
|
|
47
|
+
enter(node) {
|
|
48
|
+
if (node.type === 'Identifier') names.add(node.name)
|
|
49
|
+
},
|
|
50
|
+
})
|
|
51
|
+
let helper = '__zyzzNative'
|
|
52
|
+
while (
|
|
53
|
+
[helper, `${helper}Context`, `${helper}Dynamic`].some((name) =>
|
|
54
|
+
names.has(name),
|
|
55
|
+
)
|
|
56
|
+
)
|
|
57
|
+
helper += '_'
|
|
58
|
+
let dynamicHelper = `${helper}Dynamic`
|
|
59
|
+
while (names.has(dynamicHelper)) dynamicHelper += '_'
|
|
60
|
+
const module = new MagicString(options.source)
|
|
61
|
+
const edits: Edits.Edit[] = []
|
|
62
|
+
function overwrite(
|
|
63
|
+
start: number,
|
|
64
|
+
end: number,
|
|
65
|
+
code: string,
|
|
66
|
+
expression = false,
|
|
67
|
+
) {
|
|
68
|
+
edits.push({ start, end, code, expression })
|
|
69
|
+
module.overwrite(start, end, code)
|
|
70
|
+
}
|
|
71
|
+
const recipes: Record<string, Variants.Definition> = Object.create(null)
|
|
72
|
+
let dynamic = false
|
|
73
|
+
const contexts = new Map<string, string>()
|
|
74
|
+
const compiledCalls = new WeakMap<
|
|
75
|
+
Variants.Definition,
|
|
76
|
+
{
|
|
77
|
+
styles: Readonly<Record<string, StyleSheet.NativeStyle>>
|
|
78
|
+
value: string
|
|
79
|
+
}
|
|
80
|
+
>()
|
|
81
|
+
const factories = new Map<string, { name: string; parameters: string[] }>()
|
|
82
|
+
const literals = new Map<string, string>()
|
|
83
|
+
const initializers = new Map<string, { name: string; values: string[] }>()
|
|
84
|
+
const stylesByName = new Map<
|
|
85
|
+
string,
|
|
86
|
+
(typeof extracted.styles.styles)[number][]
|
|
87
|
+
>()
|
|
88
|
+
for (const style of extracted.styles.styles) {
|
|
89
|
+
const styles = stylesByName.get(style.name)
|
|
90
|
+
if (styles) styles.push(style)
|
|
91
|
+
else stylesByName.set(style.name, [style])
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const staticTables = new Map<Source.Call, Variants.Definition>()
|
|
95
|
+
if (options.contextual) {
|
|
96
|
+
const groups = new Map<
|
|
97
|
+
StyleSheet.compile.Options['themes'],
|
|
98
|
+
Source.Call[]
|
|
99
|
+
>()
|
|
100
|
+
for (const call of extracted.calls) {
|
|
101
|
+
if (
|
|
102
|
+
call.recipe ||
|
|
103
|
+
call.staticRecipe ||
|
|
104
|
+
call.dynamicRecipe ||
|
|
105
|
+
call.slots ||
|
|
106
|
+
call.output === 'html'
|
|
107
|
+
)
|
|
108
|
+
continue
|
|
109
|
+
const themes = call.nativeContext?.themes ?? options.themes
|
|
110
|
+
const group = groups.get(themes)
|
|
111
|
+
if (group) group.push(call)
|
|
112
|
+
else groups.set(themes, [call])
|
|
113
|
+
}
|
|
114
|
+
for (const [themes, calls] of groups) {
|
|
115
|
+
if (calls.length < 2) continue
|
|
116
|
+
try {
|
|
117
|
+
const compiled = StyleSheet.compile({
|
|
118
|
+
fonts: options.fonts,
|
|
119
|
+
platform: options.platform,
|
|
120
|
+
styles: {
|
|
121
|
+
styles: calls.map((call) => ({
|
|
122
|
+
name: call.name,
|
|
123
|
+
declarations: [],
|
|
124
|
+
rules: (stylesByName.get(call.name) ?? []).map((style) => ({
|
|
125
|
+
style,
|
|
126
|
+
})),
|
|
127
|
+
})),
|
|
128
|
+
},
|
|
129
|
+
themes,
|
|
130
|
+
units: options.units,
|
|
131
|
+
})
|
|
132
|
+
for (const call of calls) {
|
|
133
|
+
const styles = Object.fromEntries(
|
|
134
|
+
Object.entries(compiled.styles).map(([theme, schemes]) => [
|
|
135
|
+
theme,
|
|
136
|
+
Object.freeze({
|
|
137
|
+
light: Object.freeze({ '0': schemes.light[call.name]! }),
|
|
138
|
+
dark: Object.freeze({ '0': schemes.dark[call.name]! }),
|
|
139
|
+
}),
|
|
140
|
+
]),
|
|
141
|
+
)
|
|
142
|
+
staticTables.set(
|
|
143
|
+
call,
|
|
144
|
+
Object.freeze({
|
|
145
|
+
axes: Object.freeze({}),
|
|
146
|
+
defaults: Object.freeze({}),
|
|
147
|
+
styles: Object.freeze(styles),
|
|
148
|
+
}),
|
|
149
|
+
)
|
|
150
|
+
}
|
|
151
|
+
} catch (error) {
|
|
152
|
+
// Recompile failures individually to retain authored error order and paths.
|
|
153
|
+
if (!(error instanceof StyleSheet.CompileError)) throw error
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
for (const call of extracted.calls) {
|
|
159
|
+
if (
|
|
160
|
+
(call.recipe && !call.staticRecipe && !call.dynamicRecipe) ||
|
|
161
|
+
call.output === 'html'
|
|
162
|
+
)
|
|
163
|
+
throw new CompileError(
|
|
164
|
+
'Native source compilation does not support named conditions or HTML output.',
|
|
165
|
+
)
|
|
166
|
+
const recipe = call.staticRecipe ??
|
|
167
|
+
call.dynamicRecipe ?? {
|
|
168
|
+
axes: {},
|
|
169
|
+
defaults: {},
|
|
170
|
+
rules: [
|
|
171
|
+
{
|
|
172
|
+
matches: [],
|
|
173
|
+
value: {
|
|
174
|
+
styles: stylesByName.get(call.name) ?? [],
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
],
|
|
178
|
+
}
|
|
179
|
+
overwrite(
|
|
180
|
+
call.start,
|
|
181
|
+
call.end,
|
|
182
|
+
callable(recipe, call.name, call, options, staticTables.get(call)),
|
|
183
|
+
true,
|
|
184
|
+
)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function create(name: string, data: unknown): string {
|
|
188
|
+
const literal = JSON.stringify(data)
|
|
189
|
+
if (!options[Edits.runtime] || extracted.calls.length < 2)
|
|
190
|
+
return `${name}.create(${literal})`
|
|
191
|
+
const key = `${name}:${literal}`
|
|
192
|
+
const cached = literals.get(key)
|
|
193
|
+
if (cached) return cached
|
|
194
|
+
const values: string[] = []
|
|
195
|
+
const structure = literal.replace(
|
|
196
|
+
/"(?:[^"\\]|\\.)*"|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null/g,
|
|
197
|
+
(value: string, offset: number) => {
|
|
198
|
+
// Serialized property names precede colons; only value tokens become parameters.
|
|
199
|
+
if (literal[offset + value.length] === ':') return value
|
|
200
|
+
const parameter = `v${values.length}`
|
|
201
|
+
values.push(value)
|
|
202
|
+
return parameter
|
|
203
|
+
},
|
|
204
|
+
)
|
|
205
|
+
const expression = `${name}.create(${structure})`
|
|
206
|
+
const value =
|
|
207
|
+
values.length > 64
|
|
208
|
+
? `${name}.create(${literal})`
|
|
209
|
+
: factory(expression, values)
|
|
210
|
+
literals.set(key, value)
|
|
211
|
+
return value
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function factory(expression: string, values: string[]): string {
|
|
215
|
+
let definition = factories.get(expression)
|
|
216
|
+
if (!definition) {
|
|
217
|
+
let name = `${helper}Factory${factories.size}`
|
|
218
|
+
while (names.has(name)) name += '_'
|
|
219
|
+
names.add(name)
|
|
220
|
+
definition = { name, parameters: values.map((_, index) => `v${index}`) }
|
|
221
|
+
factories.set(expression, definition)
|
|
222
|
+
}
|
|
223
|
+
const value = `${definition.name}(${values.join(',')})`
|
|
224
|
+
initializers.set(value, { name: definition.name, values })
|
|
225
|
+
return value
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function callable(
|
|
229
|
+
recipe: Recipe.Definition,
|
|
230
|
+
name: string,
|
|
231
|
+
call?: Pick<
|
|
232
|
+
Source.Call,
|
|
233
|
+
'slots' | 'recipe' | 'valuesType' | 'recipeTypes' | 'nativeContext'
|
|
234
|
+
>,
|
|
235
|
+
contextOptions = options,
|
|
236
|
+
compiled?: Variants.Definition,
|
|
237
|
+
bindings?: ReturnType<typeof NativeBindings.prepare>,
|
|
238
|
+
): string {
|
|
239
|
+
if (contextOptions.contextual) {
|
|
240
|
+
const themes = call?.nativeContext?.themes ?? contextOptions.themes
|
|
241
|
+
if (!call?.slots && !call?.recipe?.payloads?.length)
|
|
242
|
+
compiled ??= Variants.compile({
|
|
243
|
+
recipe,
|
|
244
|
+
fonts: contextOptions.fonts,
|
|
245
|
+
platform: contextOptions.platform,
|
|
246
|
+
themes,
|
|
247
|
+
units: contextOptions.units,
|
|
248
|
+
})
|
|
249
|
+
else {
|
|
250
|
+
try {
|
|
251
|
+
bindings = NativeBindings.prepare(recipe, call!, {
|
|
252
|
+
...contextOptions,
|
|
253
|
+
themes,
|
|
254
|
+
})
|
|
255
|
+
} catch (error) {
|
|
256
|
+
if (error instanceof StyleSheet.CompileError) throw error
|
|
257
|
+
throw new CompileError((error as Error).message)
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
const defaultTheme =
|
|
261
|
+
call?.nativeContext?.defaultTheme ?? contextOptions.theme ?? 'default'
|
|
262
|
+
const tables = new Map<string, string>()
|
|
263
|
+
const alternatives = (themes ? Object.keys(themes) : ['default']).map(
|
|
264
|
+
(theme) => ({
|
|
265
|
+
theme,
|
|
266
|
+
schemes: (['light', 'dark'] as const).map((colorScheme) => {
|
|
267
|
+
const value = callable(
|
|
268
|
+
recipe,
|
|
269
|
+
name,
|
|
270
|
+
call,
|
|
271
|
+
{
|
|
272
|
+
...contextOptions,
|
|
273
|
+
contextual: false,
|
|
274
|
+
themes,
|
|
275
|
+
theme,
|
|
276
|
+
colorScheme,
|
|
277
|
+
},
|
|
278
|
+
compiled,
|
|
279
|
+
bindings,
|
|
280
|
+
)
|
|
281
|
+
if (!tables.has(value))
|
|
282
|
+
tables.set(value, `${helper}Table${tables.size}`)
|
|
283
|
+
return { colorScheme, value }
|
|
284
|
+
}),
|
|
285
|
+
}),
|
|
286
|
+
)
|
|
287
|
+
const entries = alternatives.map(
|
|
288
|
+
({ theme, schemes }) =>
|
|
289
|
+
`${JSON.stringify(theme)}:{${schemes.map(({ colorScheme, value }) => `${JSON.stringify(colorScheme)}:${tables.get(value)}`).join(',')}}`,
|
|
290
|
+
)
|
|
291
|
+
const parameters = [...tables.values()].map((name, index) =>
|
|
292
|
+
typed ? `${name}:T${index}` : name,
|
|
293
|
+
)
|
|
294
|
+
const types = typed
|
|
295
|
+
? `<${parameters.map((_, index) => `const T${index} extends (input:never)=>import('zyzz/runtime').Native.Props<object>`).join(',')},>`
|
|
296
|
+
: ''
|
|
297
|
+
const expression = `${types}(${parameters.join(',')})=>${helper}Context.create({${entries.join(',')}},${JSON.stringify(defaultTheme)})`
|
|
298
|
+
let context = contexts.get(expression)
|
|
299
|
+
if (!context) {
|
|
300
|
+
context = `${helper}ContextFactory${contexts.size}`
|
|
301
|
+
while (names.has(context)) context += '_'
|
|
302
|
+
names.add(context)
|
|
303
|
+
contexts.set(expression, context)
|
|
304
|
+
}
|
|
305
|
+
const inputs = [...tables.keys()].map((value) => initializers.get(value))
|
|
306
|
+
if (inputs.every((input) => input !== undefined)) {
|
|
307
|
+
const values: string[] = []
|
|
308
|
+
const arguments_ = inputs.map((input) => {
|
|
309
|
+
const parameters = input.values.map((value) => {
|
|
310
|
+
const parameter = `v${values.length}`
|
|
311
|
+
values.push(value)
|
|
312
|
+
return parameter
|
|
313
|
+
})
|
|
314
|
+
return `${input.name}(${parameters.join(',')})`
|
|
315
|
+
})
|
|
316
|
+
if (values.length <= 64)
|
|
317
|
+
return factory(`${context}(${arguments_.join(',')})`, values)
|
|
318
|
+
}
|
|
319
|
+
return `${context}(${[...tables.keys()].join(',')})`
|
|
320
|
+
}
|
|
321
|
+
if (call?.slots || call?.recipe?.payloads?.length) {
|
|
322
|
+
dynamic = true
|
|
323
|
+
const compiled = (() => {
|
|
324
|
+
try {
|
|
325
|
+
return NativeBindings.compile(recipe, call, contextOptions, bindings)
|
|
326
|
+
} catch (error) {
|
|
327
|
+
if (error instanceof StyleSheet.CompileError) throw error
|
|
328
|
+
throw new CompileError((error as Error).message)
|
|
329
|
+
}
|
|
330
|
+
})()
|
|
331
|
+
const value = create(dynamicHelper, compiled)
|
|
332
|
+
if (!typed) return value
|
|
333
|
+
let input = call.valuesType ?? '{}'
|
|
334
|
+
if (call.recipe) {
|
|
335
|
+
input = `{${Object.entries(recipe.axes)
|
|
336
|
+
.map(([axis, choices]) => {
|
|
337
|
+
const types = choices.map((choice) =>
|
|
338
|
+
call.recipeTypes?.[axis]?.[choice]
|
|
339
|
+
? `{${JSON.stringify(choice)}:${call.recipeTypes[axis]![choice]}}`
|
|
340
|
+
: choice === 'true' || choice === 'false'
|
|
341
|
+
? choice
|
|
342
|
+
: JSON.stringify(choice),
|
|
343
|
+
)
|
|
344
|
+
return `${JSON.stringify(axis)}?:${types.join('|')}|null|undefined`
|
|
345
|
+
})
|
|
346
|
+
.join(';')}}`
|
|
347
|
+
}
|
|
348
|
+
return `(${value} as import('zyzz/runtime').NativeDynamic.${call.recipe ? 'RecipeCallable' : 'Callable'}<${input}>)`
|
|
349
|
+
}
|
|
350
|
+
compiled ??= Variants.compile({
|
|
351
|
+
recipe,
|
|
352
|
+
fonts: contextOptions.fonts,
|
|
353
|
+
platform: contextOptions.platform,
|
|
354
|
+
themes: contextOptions.themes,
|
|
355
|
+
units: contextOptions.units,
|
|
356
|
+
})
|
|
357
|
+
recipes[name] = compiled
|
|
358
|
+
const styles = StyleSheet.select(compiled.styles, {
|
|
359
|
+
theme: contextOptions.theme ?? 'default',
|
|
360
|
+
colorScheme: contextOptions.colorScheme,
|
|
361
|
+
})
|
|
362
|
+
const cached = compiledCalls.get(compiled)
|
|
363
|
+
const value =
|
|
364
|
+
cached &&
|
|
365
|
+
Object.keys(cached.styles).length === Object.keys(styles).length &&
|
|
366
|
+
Object.entries(styles).every(
|
|
367
|
+
([name, style]) => cached.styles[name] === style,
|
|
368
|
+
)
|
|
369
|
+
? cached.value
|
|
370
|
+
: create(helper, {
|
|
371
|
+
axes: compiled.axes,
|
|
372
|
+
defaults: compiled.defaults,
|
|
373
|
+
styles,
|
|
374
|
+
})
|
|
375
|
+
if (options.contextual) compiledCalls.set(compiled, { styles, value })
|
|
376
|
+
if (!typed) return value
|
|
377
|
+
const axes = Object.entries(compiled.axes)
|
|
378
|
+
.map(
|
|
379
|
+
([axis, choices]) =>
|
|
380
|
+
`${JSON.stringify(axis)}:readonly ${JSON.stringify(choices)}`,
|
|
381
|
+
)
|
|
382
|
+
.join(';')
|
|
383
|
+
return `(${value} as import('zyzz/runtime').Native.Callable<{${axes}}>)`
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
const packed: string[] = []
|
|
387
|
+
const explicit = new Set<string>()
|
|
388
|
+
function binding(node: Ast.Node) {
|
|
389
|
+
if (node.type === 'Identifier') explicit.add(node.name)
|
|
390
|
+
else if (node.type === 'ObjectPattern')
|
|
391
|
+
for (const property of node.properties)
|
|
392
|
+
binding(
|
|
393
|
+
property.type === 'RestElement' ? property.argument : property.value,
|
|
394
|
+
)
|
|
395
|
+
else if (node.type === 'ArrayPattern')
|
|
396
|
+
for (const element of node.elements) {
|
|
397
|
+
if (element) binding(element)
|
|
398
|
+
}
|
|
399
|
+
else if (node.type === 'AssignmentPattern') binding(node.left)
|
|
400
|
+
else if (node.type === 'RestElement') binding(node.argument)
|
|
401
|
+
}
|
|
402
|
+
for (const statement of parsed.program.body) {
|
|
403
|
+
if (
|
|
404
|
+
statement.type !== 'ExportNamedDeclaration' ||
|
|
405
|
+
statement.exportKind === 'type'
|
|
406
|
+
)
|
|
407
|
+
continue
|
|
408
|
+
for (const specifier of statement.specifiers)
|
|
409
|
+
if (specifier.exportKind !== 'type')
|
|
410
|
+
explicit.add(
|
|
411
|
+
specifier.exported.type === 'Identifier'
|
|
412
|
+
? specifier.exported.name
|
|
413
|
+
: specifier.exported.value,
|
|
414
|
+
)
|
|
415
|
+
const declaration = statement.declaration
|
|
416
|
+
if (declaration?.type === 'VariableDeclaration') {
|
|
417
|
+
for (const item of declaration.declarations) binding(item.id)
|
|
418
|
+
} else if (
|
|
419
|
+
declaration &&
|
|
420
|
+
'id' in declaration &&
|
|
421
|
+
declaration.id?.type === 'Identifier'
|
|
422
|
+
)
|
|
423
|
+
explicit.add(declaration.id.name)
|
|
424
|
+
}
|
|
425
|
+
for (const statement of parsed.program.body) {
|
|
426
|
+
if (
|
|
427
|
+
(statement.type !== 'ImportDeclaration' &&
|
|
428
|
+
statement.type !== 'ExportNamedDeclaration' &&
|
|
429
|
+
statement.type !== 'ExportAllDeclaration') ||
|
|
430
|
+
!statement.source
|
|
431
|
+
)
|
|
432
|
+
continue
|
|
433
|
+
if (
|
|
434
|
+
(statement.type === 'ImportDeclaration' &&
|
|
435
|
+
statement.importKind === 'type') ||
|
|
436
|
+
(statement.type !== 'ImportDeclaration' &&
|
|
437
|
+
statement.exportKind === 'type')
|
|
438
|
+
)
|
|
439
|
+
continue
|
|
440
|
+
const specifier = statement.source.value
|
|
441
|
+
const exports = options[Themes.context]?.libraries?.[specifier]
|
|
442
|
+
if (!exports) continue
|
|
443
|
+
|
|
444
|
+
let imported: string | undefined
|
|
445
|
+
function original(): string {
|
|
446
|
+
if (imported) return imported
|
|
447
|
+
imported = `${helper}Namespace${packed.length}`
|
|
448
|
+
while (names.has(imported)) imported += '_'
|
|
449
|
+
names.add(imported)
|
|
450
|
+
packed.push(`import * as ${imported} from ${JSON.stringify(specifier)};`)
|
|
451
|
+
return imported
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
function overlay(original: string, expression: string): string {
|
|
455
|
+
let overrides = `${helper}Members${packed.length}`
|
|
456
|
+
while (names.has(overrides)) overrides += '_'
|
|
457
|
+
names.add(overrides)
|
|
458
|
+
packed.push(`const ${overrides}=${expression};`)
|
|
459
|
+
// Getter descriptors retain live bindings outside the recipe contract.
|
|
460
|
+
return `Object.freeze(Object.defineProperties({...${original},...${overrides}},Object.fromEntries(Object.keys(${original}).filter(key=>!Object.hasOwn(${overrides},key)).map(key=>[key,{get:()=>Reflect.get(${original},key)}]))))`
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
function value(
|
|
464
|
+
name: string,
|
|
465
|
+
link = exports![name],
|
|
466
|
+
input?: string,
|
|
467
|
+
path: readonly string[] = [name],
|
|
468
|
+
): string | undefined {
|
|
469
|
+
if (!link || link.kind !== 'style-reference') return undefined
|
|
470
|
+
if (link.members) {
|
|
471
|
+
const source = input ?? `${original()}[${JSON.stringify(name)}]`
|
|
472
|
+
const expression = `{${Object.entries(link.members)
|
|
473
|
+
.map(
|
|
474
|
+
([member, link]) =>
|
|
475
|
+
`[${JSON.stringify(member)}]:${value(`${name}.${member}`, link, `${source}[${JSON.stringify(member)}]`, [...path, member])}`,
|
|
476
|
+
)
|
|
477
|
+
.join(',')}}`
|
|
478
|
+
return overlay(source, expression)
|
|
479
|
+
}
|
|
480
|
+
const recipe = link.style?.staticRecipe ?? link.style?.dynamic?.recipe
|
|
481
|
+
if (
|
|
482
|
+
!recipe ||
|
|
483
|
+
link.style?.output ||
|
|
484
|
+
(link.style?.slots.length && !link.style.dynamic)
|
|
485
|
+
)
|
|
486
|
+
throw new CompileError(
|
|
487
|
+
`Packed native callable ${name} requires a static recipe contract.`,
|
|
488
|
+
)
|
|
489
|
+
const expression = callable(
|
|
490
|
+
recipe,
|
|
491
|
+
`${specifier}:${name}`,
|
|
492
|
+
link.style?.dynamic
|
|
493
|
+
? {
|
|
494
|
+
slots: link.style.dynamic.slots,
|
|
495
|
+
recipe: {
|
|
496
|
+
axes: recipe.axes,
|
|
497
|
+
defaults: recipe.defaults,
|
|
498
|
+
payloads: link.style.dynamic.payloads,
|
|
499
|
+
defaultPayloads: link.style.dynamic.defaultPayloads,
|
|
500
|
+
},
|
|
501
|
+
}
|
|
502
|
+
: undefined,
|
|
503
|
+
)
|
|
504
|
+
if (!link.style?.dynamic || !typed) return expression
|
|
505
|
+
const type = `typeof import(${JSON.stringify(specifier)})${path
|
|
506
|
+
.map((part) => `[${JSON.stringify(part)}]`)
|
|
507
|
+
.join('')}`
|
|
508
|
+
return `(${expression} as import('zyzz/runtime').NativeDynamic.From<${type}>)`
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
function namespace(): string | undefined {
|
|
512
|
+
if (
|
|
513
|
+
!Object.values(exports!).some((link) => link.kind === 'style-reference')
|
|
514
|
+
)
|
|
515
|
+
return undefined
|
|
516
|
+
const imported = original()
|
|
517
|
+
const members = Object.keys(exports!).flatMap((name) => {
|
|
518
|
+
const expression = value(
|
|
519
|
+
name,
|
|
520
|
+
exports![name],
|
|
521
|
+
`${imported}[${JSON.stringify(name)}]`,
|
|
522
|
+
)
|
|
523
|
+
return expression === undefined
|
|
524
|
+
? []
|
|
525
|
+
: [`[${JSON.stringify(name)}]:${expression}`]
|
|
526
|
+
})
|
|
527
|
+
return overlay(imported, `{${members.join(',')}}`)
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
if (statement.type === 'ExportAllDeclaration') {
|
|
531
|
+
if (statement.exported) {
|
|
532
|
+
const expression = namespace()
|
|
533
|
+
if (expression === undefined) continue
|
|
534
|
+
let local = `${helper}Export${packed.length}`
|
|
535
|
+
while (names.has(local)) local += '_'
|
|
536
|
+
names.add(local)
|
|
537
|
+
const name =
|
|
538
|
+
statement.exported.type === 'Identifier'
|
|
539
|
+
? statement.exported.name
|
|
540
|
+
: statement.exported.value
|
|
541
|
+
packed.push(
|
|
542
|
+
`const ${local}=${expression};export {${local} as ${JSON.stringify(name)}};`,
|
|
543
|
+
)
|
|
544
|
+
overwrite(statement.start, statement.end, '')
|
|
545
|
+
continue
|
|
546
|
+
}
|
|
547
|
+
for (const name of Object.keys(exports)) {
|
|
548
|
+
if (name === 'default' || explicit.has(name)) continue
|
|
549
|
+
const expression = value(name)
|
|
550
|
+
if (expression === undefined) continue
|
|
551
|
+
explicit.add(name)
|
|
552
|
+
let local = `${helper}Export${packed.length}`
|
|
553
|
+
while (names.has(local)) local += '_'
|
|
554
|
+
names.add(local)
|
|
555
|
+
packed.push(
|
|
556
|
+
`const ${local}=${expression};export {${local} as ${JSON.stringify(name)}};`,
|
|
557
|
+
)
|
|
558
|
+
}
|
|
559
|
+
continue
|
|
560
|
+
}
|
|
561
|
+
const kept: string[] = []
|
|
562
|
+
for (const specifier of statement.specifiers) {
|
|
563
|
+
if (specifier.type === 'ImportNamespaceSpecifier') {
|
|
564
|
+
const expression = namespace()
|
|
565
|
+
if (expression === undefined) {
|
|
566
|
+
packed.push(
|
|
567
|
+
`import * as ${specifier.local.name} from ${JSON.stringify(statement.source.value)};`,
|
|
568
|
+
)
|
|
569
|
+
} else packed.push(`const ${specifier.local.name}=${expression};`)
|
|
570
|
+
continue
|
|
571
|
+
}
|
|
572
|
+
if (
|
|
573
|
+
(specifier.type === 'ImportSpecifier' &&
|
|
574
|
+
specifier.importKind === 'type') ||
|
|
575
|
+
(specifier.type === 'ExportSpecifier' &&
|
|
576
|
+
specifier.exportKind === 'type')
|
|
577
|
+
) {
|
|
578
|
+
kept.push(options.source.slice(specifier.start, specifier.end))
|
|
579
|
+
continue
|
|
580
|
+
}
|
|
581
|
+
const imported =
|
|
582
|
+
specifier.type === 'ImportDefaultSpecifier'
|
|
583
|
+
? 'default'
|
|
584
|
+
: specifier.type === 'ImportSpecifier'
|
|
585
|
+
? specifier.imported
|
|
586
|
+
: specifier.local
|
|
587
|
+
const name =
|
|
588
|
+
typeof imported === 'string'
|
|
589
|
+
? imported
|
|
590
|
+
: imported.type === 'Identifier'
|
|
591
|
+
? imported.name
|
|
592
|
+
: imported.value
|
|
593
|
+
const expression = value(name)
|
|
594
|
+
if (expression === undefined) {
|
|
595
|
+
if (specifier.type === 'ImportDefaultSpecifier')
|
|
596
|
+
kept.push(`default as ${specifier.local.name}`)
|
|
597
|
+
else kept.push(options.source.slice(specifier.start, specifier.end))
|
|
598
|
+
continue
|
|
599
|
+
}
|
|
600
|
+
if (specifier.type === 'ExportSpecifier') {
|
|
601
|
+
let local = `${helper}Export${packed.length}`
|
|
602
|
+
while (names.has(local)) local += '_'
|
|
603
|
+
names.add(local)
|
|
604
|
+
const exported =
|
|
605
|
+
specifier.exported.type === 'Identifier'
|
|
606
|
+
? specifier.exported.name
|
|
607
|
+
: specifier.exported.value
|
|
608
|
+
packed.push(
|
|
609
|
+
`const ${local}=${expression};export {${local} as ${JSON.stringify(exported)}};`,
|
|
610
|
+
)
|
|
611
|
+
} else packed.push(`const ${specifier.local.name}=${expression};`)
|
|
612
|
+
}
|
|
613
|
+
const keyword = statement.type === 'ImportDeclaration' ? 'import' : 'export'
|
|
614
|
+
overwrite(
|
|
615
|
+
statement.start,
|
|
616
|
+
statement.end,
|
|
617
|
+
kept.length
|
|
618
|
+
? `${keyword} {${kept.join(',')}} from ${JSON.stringify(statement.source.value)};`
|
|
619
|
+
: `import ${JSON.stringify(statement.source.value)};`,
|
|
620
|
+
)
|
|
621
|
+
}
|
|
622
|
+
const compositions: string[] = []
|
|
623
|
+
for (const statement of parsed.program.body) {
|
|
624
|
+
if (
|
|
625
|
+
statement.type === 'ExportAllDeclaration' &&
|
|
626
|
+
statement.source.value === 'zyzz' &&
|
|
627
|
+
statement.exportKind !== 'type'
|
|
628
|
+
)
|
|
629
|
+
throw new CompileError(
|
|
630
|
+
'Native modules require named re-exports from zyzz.',
|
|
631
|
+
)
|
|
632
|
+
if (
|
|
633
|
+
statement.type === 'ExportNamedDeclaration' &&
|
|
634
|
+
statement.source?.value === 'zyzz' &&
|
|
635
|
+
statement.exportKind !== 'type'
|
|
636
|
+
) {
|
|
637
|
+
const cx = statement.specifiers.filter(
|
|
638
|
+
(specifier) =>
|
|
639
|
+
specifier.exportKind !== 'type' &&
|
|
640
|
+
(specifier.local.type === 'Identifier'
|
|
641
|
+
? specifier.local.name
|
|
642
|
+
: specifier.local.value) === 'cx',
|
|
643
|
+
)
|
|
644
|
+
if (!cx.length) continue
|
|
645
|
+
let binding = `${helper}Compose`
|
|
646
|
+
while (names.has(binding)) binding += '_'
|
|
647
|
+
names.add(binding)
|
|
648
|
+
compositions.push(`const ${binding}=${helper}.compose;`)
|
|
649
|
+
const kept = statement.specifiers
|
|
650
|
+
.filter((specifier) => !cx.includes(specifier))
|
|
651
|
+
.map((specifier) =>
|
|
652
|
+
options.source.slice(specifier.start, specifier.end),
|
|
653
|
+
)
|
|
654
|
+
const exports = cx.map(
|
|
655
|
+
(specifier) =>
|
|
656
|
+
`${binding} as ${options.source.slice(specifier.exported.start, specifier.exported.end)}`,
|
|
657
|
+
)
|
|
658
|
+
overwrite(
|
|
659
|
+
statement.start,
|
|
660
|
+
statement.end,
|
|
661
|
+
`${kept.length ? `export {${kept.join(',')}} from 'zyzz';` : ''}export {${exports.join(',')}};`,
|
|
662
|
+
)
|
|
663
|
+
continue
|
|
664
|
+
}
|
|
665
|
+
if (
|
|
666
|
+
statement.type !== 'ImportDeclaration' ||
|
|
667
|
+
statement.source.value !== 'zyzz' ||
|
|
668
|
+
statement.importKind === 'type'
|
|
669
|
+
)
|
|
670
|
+
continue
|
|
671
|
+
const cx = statement.specifiers.filter(
|
|
672
|
+
(specifier) =>
|
|
673
|
+
specifier.type === 'ImportSpecifier' &&
|
|
674
|
+
specifier.importKind !== 'type' &&
|
|
675
|
+
(specifier.imported.type === 'Identifier'
|
|
676
|
+
? specifier.imported.name
|
|
677
|
+
: specifier.imported.value) === 'cx',
|
|
678
|
+
)
|
|
679
|
+
if (!cx.length) continue
|
|
680
|
+
compositions.push(
|
|
681
|
+
...cx.map(
|
|
682
|
+
(specifier) => `const ${specifier.local.name}=${helper}.compose;`,
|
|
683
|
+
),
|
|
684
|
+
)
|
|
685
|
+
const kept = statement.specifiers.filter(
|
|
686
|
+
(specifier) => !cx.includes(specifier),
|
|
687
|
+
)
|
|
688
|
+
const named = kept
|
|
689
|
+
.filter((specifier) => specifier.type === 'ImportSpecifier')
|
|
690
|
+
.map((specifier) => options.source.slice(specifier.start, specifier.end))
|
|
691
|
+
const other = kept
|
|
692
|
+
.filter((specifier) => specifier.type !== 'ImportSpecifier')
|
|
693
|
+
.map((specifier) => options.source.slice(specifier.start, specifier.end))
|
|
694
|
+
const imports = [
|
|
695
|
+
...other,
|
|
696
|
+
...(named.length ? [`{${named.join(',')}}`] : []),
|
|
697
|
+
]
|
|
698
|
+
overwrite(
|
|
699
|
+
statement.start,
|
|
700
|
+
statement.end,
|
|
701
|
+
imports.length ? `import ${imports.join(',')} from 'zyzz';` : '',
|
|
702
|
+
)
|
|
703
|
+
}
|
|
704
|
+
if (extracted.calls.length || compositions.length || packed.length) {
|
|
705
|
+
let offset = 0
|
|
706
|
+
if (options.source.startsWith('#!')) {
|
|
707
|
+
const newline = /\r\n|[\n\r\u2028\u2029]/.exec(options.source)
|
|
708
|
+
offset = newline
|
|
709
|
+
? newline.index + newline[0].length
|
|
710
|
+
: options.source.length
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
for (const node of parsed.program.body) {
|
|
714
|
+
if (node.type !== 'ExpressionStatement' || !node.directive) break
|
|
715
|
+
|
|
716
|
+
offset = node.end
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
const prelude = `\nimport {Native as ${helper}${dynamic ? `,NativeDynamic as ${dynamicHelper}` : ''}${options.contextual ? `,NativeContext as ${helper}Context` : ''}} from 'zyzz/runtime';\n${[...factories].map(([expression, factory]) => `const ${factory.name}=(${factory.parameters.join(',')})=>${expression};`).join('\n')}\n${[...contexts].map(([expression, name]) => `const ${name}=${expression};`).join('\n')}\n${[...compositions, ...packed].join('\n')}\n`
|
|
720
|
+
module.appendLeft(offset, prelude)
|
|
721
|
+
edits.push({ start: offset, end: offset, code: prelude, expression: false })
|
|
722
|
+
}
|
|
723
|
+
return output(module, {
|
|
724
|
+
edits,
|
|
725
|
+
moduleId: options.moduleId,
|
|
726
|
+
recipes: Object.freeze(recipes),
|
|
727
|
+
})
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
/** Native source compilation contracts. */
|
|
731
|
+
export declare namespace compile {
|
|
732
|
+
/** Failures during extraction, table compilation, or explicit context selection. */
|
|
733
|
+
type ErrorType =
|
|
734
|
+
| Source.ExtractError
|
|
735
|
+
| CompileError
|
|
736
|
+
| StyleSheet.CompileError
|
|
737
|
+
| StyleSheet.SelectionError
|
|
738
|
+
| Variants.CompileError
|
|
739
|
+
|
|
740
|
+
/** Explicit source and native context, independent of device state. */
|
|
741
|
+
type Options = Omit<StyleSheet.compile.Options, 'styles'> & {
|
|
742
|
+
/** Internal Babel emission mode; authoring types are still validated. */
|
|
743
|
+
readonly [Edits.runtime]?: boolean | undefined
|
|
744
|
+
/** Compiler-owned graph context. */
|
|
745
|
+
readonly [Themes.context]?: Themes.Context | undefined
|
|
746
|
+
/** Retain every theme and scheme for render-local selection. */
|
|
747
|
+
readonly contextual?: boolean | undefined
|
|
748
|
+
/** Scheme compiled into this module's callables. Recompile to select another scheme. */
|
|
749
|
+
readonly colorScheme: StyleSheet.ColorScheme
|
|
750
|
+
/** Stable source identity, including the TypeScript or JavaScript extension. */
|
|
751
|
+
readonly moduleId: string
|
|
752
|
+
/** Shared local style and variants authoring. */
|
|
753
|
+
readonly source: string
|
|
754
|
+
/** Label selected from supplied themes. Defaults to the token-fallback default table. */
|
|
755
|
+
readonly theme?: string | undefined
|
|
756
|
+
}
|
|
757
|
+
/** Executable source with immutable recipe tables and authored source mappings. */
|
|
758
|
+
type ReturnType = {
|
|
759
|
+
/** Internal node replacements for syntax-tree adapters. */
|
|
760
|
+
readonly [Edits.key]: readonly Edits.Edit[]
|
|
761
|
+
/** Rewritten TypeScript or JavaScript preserving original exports. */
|
|
762
|
+
readonly code: string
|
|
763
|
+
/** Version-three source map encoded as JSON. */
|
|
764
|
+
readonly map: string
|
|
765
|
+
/** All theme/scheme tables for each extracted definition. */
|
|
766
|
+
readonly recipes: Readonly<Record<string, Variants.Definition>>
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
/** An unsupported native source feature. */
|
|
771
|
+
export class CompileError extends Error {
|
|
772
|
+
/** Stable namespaced diagnostic name. */
|
|
773
|
+
override name = 'Native.CompileError'
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
// Keep lazy maps independent of the compiler's parser trees and extracted styles.
|
|
777
|
+
function output(
|
|
778
|
+
module: MagicString,
|
|
779
|
+
options: {
|
|
780
|
+
readonly edits: readonly Edits.Edit[]
|
|
781
|
+
readonly moduleId: string
|
|
782
|
+
readonly recipes: compile.ReturnType['recipes']
|
|
783
|
+
},
|
|
784
|
+
): compile.ReturnType {
|
|
785
|
+
let sourceMap: string | undefined
|
|
786
|
+
|
|
787
|
+
return {
|
|
788
|
+
[Edits.key]: options.edits,
|
|
789
|
+
code: module.toString(),
|
|
790
|
+
get map() {
|
|
791
|
+
return (sourceMap ??= module
|
|
792
|
+
.generateMap({
|
|
793
|
+
hires: true,
|
|
794
|
+
includeContent: true,
|
|
795
|
+
source: options.moduleId,
|
|
796
|
+
})
|
|
797
|
+
.toString())
|
|
798
|
+
},
|
|
799
|
+
recipes: options.recipes,
|
|
800
|
+
}
|
|
801
|
+
}
|