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,884 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rewrites extracted style calls into executable modules with CSS and source maps.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
import * as Edits from './internal/Edits.js';
|
|
6
|
+
import * as Token from '../internal/Token.js';
|
|
7
|
+
import * as Applications from './internal/Applications.js';
|
|
8
|
+
import * as Css from '../web/Css.js';
|
|
9
|
+
import * as Expression from './internal/Expression.js';
|
|
10
|
+
import MagicString from 'magic-string';
|
|
11
|
+
import * as Mapping from '@jridgewell/gen-mapping';
|
|
12
|
+
import * as Namespaces from './internal/Namespaces.js';
|
|
13
|
+
import * as Scheme from '../internal/Scheme.js';
|
|
14
|
+
import * as Syntax from './internal/Syntax.js';
|
|
15
|
+
import * as Source from './Source.js';
|
|
16
|
+
import * as Themes from './internal/Themes.js';
|
|
17
|
+
import * as Walker from 'oxc-walker';
|
|
18
|
+
/**
|
|
19
|
+
* Rewrites literal web styles and local themes without evaluation or file access.
|
|
20
|
+
* Direct no-argument applications become props; other definitions become callables.
|
|
21
|
+
* CSS retains ordered composition and receives module-scoped class identities.
|
|
22
|
+
* @param options - Source text and a stable package-relative module identity.
|
|
23
|
+
* @returns Rewritten TypeScript/JSX and CSS with separate version-three maps.
|
|
24
|
+
* @throws {Source.ExtractError} If the source is outside the supported literal subset.
|
|
25
|
+
* @throws {Css.CompileError} If literal CSS compilation fails.
|
|
26
|
+
*/
|
|
27
|
+
export function compile(options) {
|
|
28
|
+
if (options.target === 'native')
|
|
29
|
+
throw new Error('Use Native.compile for native source output.');
|
|
30
|
+
const extracted = options[Themes.context]?.extracted ?? Source.extract(options);
|
|
31
|
+
const portable = options.compiler === false;
|
|
32
|
+
const portableNames = {};
|
|
33
|
+
if (portable) {
|
|
34
|
+
for (const call of extracted.calls) {
|
|
35
|
+
if (!call.portable)
|
|
36
|
+
throw new Error('CSS-only output requires an explicit id for dynamic styles, variants, and compositions.');
|
|
37
|
+
portableNames[call.name] = call.portable;
|
|
38
|
+
}
|
|
39
|
+
for (const [name, theme] of Object.entries(extracted.themes))
|
|
40
|
+
if ((Object.keys(theme[Token.definition].values).length ||
|
|
41
|
+
extracted.themeCalls.some((call) => (call.name === name ||
|
|
42
|
+
Object.values(call.members ?? {}).includes(name)) &&
|
|
43
|
+
(!call.options ||
|
|
44
|
+
Object.hasOwn(call.options, 'themes') ||
|
|
45
|
+
Object.hasOwn(call.options, 'theme')))) &&
|
|
46
|
+
!theme[Token.definition].contract[Token.identity]?.startsWith('id-'))
|
|
47
|
+
throw new Error('CSS-only themes require an explicit id on Config.create or Theme.define.');
|
|
48
|
+
for (const call of extracted.contributionCalls ?? [])
|
|
49
|
+
if (call.name &&
|
|
50
|
+
!/^(?:--)?z-(?:k|counterstyle|positiontry|colorprofile|fontpalettevalues|custommedia|cssfunction)id-/.test(call.name))
|
|
51
|
+
throw new Error('CSS-only named stylesheet declarations require an explicit id.');
|
|
52
|
+
for (const call of extracted.variableCalls ?? [])
|
|
53
|
+
if (Object.values(call.slots).some((slot) => !slot.name.startsWith('--z-vid-')))
|
|
54
|
+
throw new Error('CSS-only output requires an explicit variable id.');
|
|
55
|
+
}
|
|
56
|
+
if (portable) {
|
|
57
|
+
function selectors(style) {
|
|
58
|
+
for (const rule of style.rules ?? []) {
|
|
59
|
+
if (rule.condition &&
|
|
60
|
+
!rule.condition.startsWith('@') &&
|
|
61
|
+
/\.z-style-(?!id-)/.test(rule.condition))
|
|
62
|
+
throw new Error('CSS-only selector references require an explicit style id.');
|
|
63
|
+
selectors(rule.style);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
for (const style of extracted.styles.styles)
|
|
67
|
+
selectors(style);
|
|
68
|
+
}
|
|
69
|
+
const module = new MagicString(options.source);
|
|
70
|
+
const program = Syntax.parse(options).program;
|
|
71
|
+
for (const call of extracted.contributionCalls ?? [])
|
|
72
|
+
module.overwrite(call.start, call.end, (() => {
|
|
73
|
+
const typed = /\.[cm]?tsx?$/.test(options.moduleId);
|
|
74
|
+
if (call.kind === 'cssFunction')
|
|
75
|
+
return `((...args${typed ? ': readonly (string | number)[]' : ''}) => ${JSON.stringify(call.name + '(')} + args.map(value => typeof value === 'string' && value.includes(',') && !value.trimStart().startsWith('{') ? '{' + value + '}' : value).join(',') + ')')${typed ? ` as import('zyzz/web').cssFunction.Reference<${JSON.stringify(call.function?.parameters ?? [])}, ${JSON.stringify(call.function?.returns ?? '*')}>` : ''}`;
|
|
76
|
+
if (call.kind === 'customMedia')
|
|
77
|
+
return `${JSON.stringify(`@media (${call.name})`)}${typed ? ` as unknown as import('zyzz/web').customMedia.Reference` : ''}`;
|
|
78
|
+
if (!call.name)
|
|
79
|
+
return 'void 0';
|
|
80
|
+
return `${JSON.stringify(call.name)}${call.kind === 'keyframes' || !typed ? '' : ` as import('zyzz/web').${call.kind}.Reference`}`;
|
|
81
|
+
})());
|
|
82
|
+
const applications = new Map();
|
|
83
|
+
const calls = new Map(extracted.calls.map((call) => [call.start, call]));
|
|
84
|
+
const definitions = new Map();
|
|
85
|
+
const unusedSelections = new Set();
|
|
86
|
+
const identifiers = new Map();
|
|
87
|
+
const localApplications = Applications.create(program, extracted.calls);
|
|
88
|
+
Walker.walk(program, {
|
|
89
|
+
enter(node, parent) {
|
|
90
|
+
localApplications?.enter(node, parent);
|
|
91
|
+
if (node.type === 'VariableDeclarator' &&
|
|
92
|
+
node.init &&
|
|
93
|
+
node.id.type === 'ObjectPattern' &&
|
|
94
|
+
node.id.properties.every((property) => property.type === 'Property' &&
|
|
95
|
+
(property.key.type === 'Identifier'
|
|
96
|
+
? property.key.name
|
|
97
|
+
: property.key.type === 'Literal'
|
|
98
|
+
? property.key.value
|
|
99
|
+
: undefined) !== 'themes'))
|
|
100
|
+
unusedSelections.add(Expression.unwrap(node.init).start);
|
|
101
|
+
if (node.type === 'Identifier') {
|
|
102
|
+
const references = identifiers.get(node.name) ?? [];
|
|
103
|
+
references.push(node);
|
|
104
|
+
identifiers.set(node.name, references);
|
|
105
|
+
}
|
|
106
|
+
if (node.type !== 'CallExpression')
|
|
107
|
+
return;
|
|
108
|
+
const call = calls.get(node.start);
|
|
109
|
+
if (!call || node.end !== call.end)
|
|
110
|
+
return;
|
|
111
|
+
const folded = !!call.composition ||
|
|
112
|
+
(!call.recipe &&
|
|
113
|
+
!call.slots &&
|
|
114
|
+
parent?.type === 'CallExpression' &&
|
|
115
|
+
parent.callee === node &&
|
|
116
|
+
!parent.optional &&
|
|
117
|
+
parent.arguments.length === 0);
|
|
118
|
+
applications.set(call.start, {
|
|
119
|
+
end: folded && !call.composition ? parent.end : call.end,
|
|
120
|
+
folded,
|
|
121
|
+
});
|
|
122
|
+
let argument = node.arguments[0]
|
|
123
|
+
? Expression.unwrap(node.arguments[0])
|
|
124
|
+
: undefined;
|
|
125
|
+
if (argument?.type === 'ArrowFunctionExpression')
|
|
126
|
+
argument = Expression.unwrap(argument.body);
|
|
127
|
+
if (call.body)
|
|
128
|
+
definitions.set(call.start, call.body);
|
|
129
|
+
else if (argument?.type === 'ObjectExpression')
|
|
130
|
+
definitions.set(call.start, argument);
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
// Scheme rules accompany modules whose runtime helpers can apply a scheme class.
|
|
134
|
+
const schemes = options.schemes ??
|
|
135
|
+
Boolean(extracted.themeAppearances?.length ||
|
|
136
|
+
extracted.themeScripts?.length ||
|
|
137
|
+
extracted.themeSelections?.length);
|
|
138
|
+
const emitted = Css.compile({
|
|
139
|
+
development: options.development,
|
|
140
|
+
scope: options.moduleId,
|
|
141
|
+
composition: options.composition,
|
|
142
|
+
cssOutput: options.cssOutput,
|
|
143
|
+
names: portable ? portableNames : undefined,
|
|
144
|
+
schemes,
|
|
145
|
+
// Keep definition positions stable while removing proven unreachable rules.
|
|
146
|
+
// CSS-only consumers retain executable authoring, and development keeps slots.
|
|
147
|
+
styles: (() => {
|
|
148
|
+
if (portable || options.development)
|
|
149
|
+
return extracted.styles;
|
|
150
|
+
const dead = localApplications?.dead();
|
|
151
|
+
if (!dead?.size)
|
|
152
|
+
return extracted.styles;
|
|
153
|
+
return {
|
|
154
|
+
styles: extracted.styles.styles.map((style) => dead.has(style.name)
|
|
155
|
+
? { cssOutput: style.cssOutput, declarations: [], name: style.name }
|
|
156
|
+
: style),
|
|
157
|
+
};
|
|
158
|
+
})(),
|
|
159
|
+
contributions: extracted.contributions,
|
|
160
|
+
themes: Object.keys(extracted.themes).length ? extracted.themes : undefined,
|
|
161
|
+
});
|
|
162
|
+
let runtime = '__zyzzProps';
|
|
163
|
+
while (identifiers.has(runtime))
|
|
164
|
+
runtime += '_';
|
|
165
|
+
let html = '__zyzzHtml';
|
|
166
|
+
while (identifiers.has(html))
|
|
167
|
+
html += '_';
|
|
168
|
+
let usesHtml = false;
|
|
169
|
+
let conditionalRecipe = '__zyzzConditionalRecipe';
|
|
170
|
+
while (identifiers.has(conditionalRecipe))
|
|
171
|
+
conditionalRecipe += '_';
|
|
172
|
+
let usesConditionalRecipe = false;
|
|
173
|
+
let payloadRecipe = '__zyzzPayloadRecipe';
|
|
174
|
+
while (identifiers.has(payloadRecipe))
|
|
175
|
+
payloadRecipe += '_';
|
|
176
|
+
let usesPayloadRecipe = false;
|
|
177
|
+
let recipe = '__zyzzRecipe';
|
|
178
|
+
while (identifiers.has(recipe))
|
|
179
|
+
recipe += '_';
|
|
180
|
+
let usesRecipe = false;
|
|
181
|
+
let compositionHtml = '__zyzzCompositionHtml';
|
|
182
|
+
while (identifiers.has(compositionHtml))
|
|
183
|
+
compositionHtml += '_';
|
|
184
|
+
let usesCompositionHtml = false;
|
|
185
|
+
const preparedHtml = new Set(extracted.calls.flatMap((call) => call.output === 'html'
|
|
186
|
+
? (call.runtimeComposition ?? []).map((input) => input.name)
|
|
187
|
+
: []));
|
|
188
|
+
function prepareExport(link) {
|
|
189
|
+
if (link.style?.output === 'html') {
|
|
190
|
+
const call = extracted.calls.find((call) => call.identity === link.binding);
|
|
191
|
+
if (call)
|
|
192
|
+
preparedHtml.add(call.name);
|
|
193
|
+
}
|
|
194
|
+
for (const member of Object.values(link.members ?? {}))
|
|
195
|
+
prepareExport(member);
|
|
196
|
+
}
|
|
197
|
+
for (const link of Object.values(extracted.themeExports ?? {}))
|
|
198
|
+
prepareExport(link);
|
|
199
|
+
let composition = '__zyzzComposition';
|
|
200
|
+
while (identifiers.has(composition))
|
|
201
|
+
composition += '_';
|
|
202
|
+
let usesComposition = false;
|
|
203
|
+
const compositions = [];
|
|
204
|
+
const compositionArguments = new Map();
|
|
205
|
+
let appearance = '__zyzzAppearance';
|
|
206
|
+
while (identifiers.has(appearance))
|
|
207
|
+
appearance += '_';
|
|
208
|
+
let usesAppearance = false;
|
|
209
|
+
let selection = '__zyzzSelection';
|
|
210
|
+
while (identifiers.has(selection))
|
|
211
|
+
selection += '_';
|
|
212
|
+
let usesSelection = false;
|
|
213
|
+
let variables = '__zyzzVariable';
|
|
214
|
+
while (identifiers.has(variables))
|
|
215
|
+
variables += '_';
|
|
216
|
+
for (const call of extracted.variableCalls ?? [])
|
|
217
|
+
module.overwrite(call.start, call.end, `${variables}.create(${JSON.stringify(call.slots.value)})`);
|
|
218
|
+
const first = extracted.calls[0];
|
|
219
|
+
const scope = first ? first.name.slice(6, first.name.lastIndexOf('-')) : '';
|
|
220
|
+
const identities = new Map(extracted.calls
|
|
221
|
+
.filter((call) => call.identity)
|
|
222
|
+
.map((call) => [call.name, call.identity]));
|
|
223
|
+
const modes = new Map(extracted.styles.styles.map((style) => [style.name, style.cssOutput]));
|
|
224
|
+
const ownersByClass = new Map();
|
|
225
|
+
for (const [style, value] of Object.entries(emitted.classes))
|
|
226
|
+
for (const name of value.split(' ').filter(Boolean))
|
|
227
|
+
ownersByClass.set(name, ownersByClass.has(name) ? false : style);
|
|
228
|
+
const names = new Map();
|
|
229
|
+
for (const classes of Object.values(emitted.classes))
|
|
230
|
+
for (const name of classes.split(' ').filter(Boolean))
|
|
231
|
+
names.set(name, (() => {
|
|
232
|
+
const owner = ownersByClass.get(name);
|
|
233
|
+
const identity = owner && identities.get(owner);
|
|
234
|
+
if ((modes.get(owner || '') ?? options.cssOutput) === 'grouped' &&
|
|
235
|
+
options.composition === 'independent' &&
|
|
236
|
+
name.startsWith('g_') &&
|
|
237
|
+
identity &&
|
|
238
|
+
!identity.includes(' '))
|
|
239
|
+
return identity;
|
|
240
|
+
if (name.startsWith('g_'))
|
|
241
|
+
return `g_${scope}_${name.slice(2)}`;
|
|
242
|
+
return name.startsWith('z_base')
|
|
243
|
+
? `z-${scope}-${name.slice(2)}`
|
|
244
|
+
: name;
|
|
245
|
+
})());
|
|
246
|
+
const classes = Object.freeze(Object.fromEntries(Object.entries(emitted.classes).map(([name, value]) => [
|
|
247
|
+
name,
|
|
248
|
+
[
|
|
249
|
+
...new Set([
|
|
250
|
+
...value
|
|
251
|
+
.split(' ')
|
|
252
|
+
.filter(Boolean)
|
|
253
|
+
.map((part) => names.get(part)),
|
|
254
|
+
...(identities.has(name) &&
|
|
255
|
+
(!portable || portableNames[name]?.startsWith('z-compose-'))
|
|
256
|
+
? [
|
|
257
|
+
portable
|
|
258
|
+
? identities
|
|
259
|
+
.get(name)
|
|
260
|
+
.split(' ')
|
|
261
|
+
.filter((name) => name.startsWith('z-style-id-'))
|
|
262
|
+
.join(' ')
|
|
263
|
+
: identities.get(name),
|
|
264
|
+
]
|
|
265
|
+
: []),
|
|
266
|
+
]),
|
|
267
|
+
].join(' '),
|
|
268
|
+
])));
|
|
269
|
+
let callable = false;
|
|
270
|
+
const composed = (node) => extracted.calls.some((call) => call.composition && call.start < node.start && node.end <= call.end);
|
|
271
|
+
// Rewrite contained expressions before their enclosing composition reads them.
|
|
272
|
+
const rewrites = [...extracted.calls].sort((a, b) => a.start < b.start && a.end >= b.end
|
|
273
|
+
? 1
|
|
274
|
+
: b.start < a.start && b.end >= a.end
|
|
275
|
+
? -1
|
|
276
|
+
: a.start - b.start);
|
|
277
|
+
for (const call of rewrites) {
|
|
278
|
+
if (call.compositionCase || composed(call))
|
|
279
|
+
continue;
|
|
280
|
+
const application = applications.get(call.start);
|
|
281
|
+
const props = `{${call.output === 'html' ? 'class' : 'className'}:${JSON.stringify(classes[call.name])}}`;
|
|
282
|
+
const composeHtml = call.output === 'html' && preparedHtml.has(call.name);
|
|
283
|
+
if (composeHtml)
|
|
284
|
+
usesCompositionHtml = true;
|
|
285
|
+
const replacement = (() => {
|
|
286
|
+
if (call.runtimeComposition) {
|
|
287
|
+
const helper = call.output === 'html' ? compositionHtml : composition;
|
|
288
|
+
if (call.output === 'html')
|
|
289
|
+
usesCompositionHtml = true;
|
|
290
|
+
else
|
|
291
|
+
usesComposition = true;
|
|
292
|
+
let factory = `${composition}${call.start}`;
|
|
293
|
+
while (identifiers.has(factory))
|
|
294
|
+
factory += '_';
|
|
295
|
+
const inputs = call.runtimeComposition.map((input) => ({
|
|
296
|
+
className: classes[input.name] ??
|
|
297
|
+
options[Themes.context]?.styleClasses?.[input.name] ??
|
|
298
|
+
'',
|
|
299
|
+
condition: input.condition,
|
|
300
|
+
owners: input.owners,
|
|
301
|
+
}));
|
|
302
|
+
compositions.push(`const ${factory}=/*#__PURE__*/${helper}.create(${JSON.stringify({ className: classes[call.name], cases: call.compositionCases?.map((name) => classes[name]), inputs })});`);
|
|
303
|
+
return `${factory}(${call.runtimeComposition
|
|
304
|
+
.map((input) => {
|
|
305
|
+
const key = `${input.start}:${input.end}`;
|
|
306
|
+
const value = compositionArguments.get(key) ??
|
|
307
|
+
module.slice(input.start, input.end);
|
|
308
|
+
compositionArguments.set(key, value);
|
|
309
|
+
return value;
|
|
310
|
+
})
|
|
311
|
+
.join(',')})`;
|
|
312
|
+
}
|
|
313
|
+
if (call.composition)
|
|
314
|
+
return call.composition.reduceRight((result, guard) => `((${guard}${/\.[cm]?tsx?$/.test(options.moduleId) ? ' as unknown' : ''})?${result}:${guard}())`, composeHtml
|
|
315
|
+
? `${compositionHtml}.from({className:${JSON.stringify(classes[call.name])}})`
|
|
316
|
+
: `(${props})`);
|
|
317
|
+
if (call.recipe) {
|
|
318
|
+
const helper = call.recipe.conditions?.length
|
|
319
|
+
? conditionalRecipe
|
|
320
|
+
: recipe;
|
|
321
|
+
if (call.recipe.conditions?.length)
|
|
322
|
+
usesConditionalRecipe = true;
|
|
323
|
+
else
|
|
324
|
+
usesRecipe = true;
|
|
325
|
+
const payload = !!call.recipe.payloads?.length;
|
|
326
|
+
if (payload)
|
|
327
|
+
usesPayloadRecipe = true;
|
|
328
|
+
const selection = `${helper}.create(${JSON.stringify({ axes: call.recipe.axes, defaults: call.recipe.defaults, conditions: call.recipe.conditions, className: classes[call.name], ...(!payload && call.output === 'html' && !composeHtml ? { html: true } : {}) })})`;
|
|
329
|
+
const value = payload
|
|
330
|
+
? `${payloadRecipe}.create({...${JSON.stringify({ ...call.recipe, html: call.output === 'html' && !composeHtml })},select:${selection}})`
|
|
331
|
+
: selection;
|
|
332
|
+
const bound = composeHtml ? `${compositionHtml}.bind(${value})` : value;
|
|
333
|
+
const axes = Object.entries(call.recipe.axes)
|
|
334
|
+
.map(([axis, choices]) => `${JSON.stringify(axis)}:{${choices.map((choice) => `${JSON.stringify(choice)}:${call.recipeTypes?.[axis]?.[choice] ? `(values:${call.recipeTypes[axis][choice]})=>{}` : '{}'}`).join(';')}}`)
|
|
335
|
+
.join(';');
|
|
336
|
+
const conditions = call.recipe.conditions
|
|
337
|
+
?.map((name) => `${JSON.stringify(name)}:unknown`)
|
|
338
|
+
.join(';');
|
|
339
|
+
const type = `import('zyzz').variants.ReturnType<{variants:{${axes}}${conditions ? `;conditions:{${conditions}}` : ''}}${call.output === 'html' ? ',"html"' : ''}>`;
|
|
340
|
+
return /\.[cm]?tsx?$/.test(options.moduleId)
|
|
341
|
+
? `(${bound} as ${type})`
|
|
342
|
+
: bound;
|
|
343
|
+
}
|
|
344
|
+
if (call.slots) {
|
|
345
|
+
const type = `import('zyzz').style.Dynamic<${call.valuesType}${call.output === 'html' ? ',"html"' : ''}>`;
|
|
346
|
+
const typed = /\.[cm]?tsx?$/.test(options.moduleId);
|
|
347
|
+
const slots = Object.entries(call.slots);
|
|
348
|
+
const reads = slots
|
|
349
|
+
.map(([key], index) => `const v${index}=input[${JSON.stringify(key)}]${typed ? ' as string | number' : ''};`)
|
|
350
|
+
.join('');
|
|
351
|
+
const assignments = slots
|
|
352
|
+
.map(([, slot], index) => `${JSON.stringify(slot.name)}:v${index}===''?' ':v${index}`)
|
|
353
|
+
.join(',');
|
|
354
|
+
const className = JSON.stringify(classes[call.name]);
|
|
355
|
+
const value = `(input${typed ? `:Parameters<${type}>[0]` : ''})=>{${reads}const external=input.className;const style=input.style;return {className:external?${className}+" "+external:${className},style:{...input.variables,...style,${assignments}}}}`;
|
|
356
|
+
const result = composeHtml
|
|
357
|
+
? `${compositionHtml}.bind(${value})`
|
|
358
|
+
: call.output === 'html'
|
|
359
|
+
? `${html}.bind(${value})`
|
|
360
|
+
: `(${value})`;
|
|
361
|
+
if (call.output === 'html' && !composeHtml)
|
|
362
|
+
usesHtml = true;
|
|
363
|
+
return typed ? `(${result} as ${type})` : result;
|
|
364
|
+
}
|
|
365
|
+
if (application.folded)
|
|
366
|
+
return composeHtml
|
|
367
|
+
? `${compositionHtml}.from({className:${JSON.stringify(classes[call.name])}})`
|
|
368
|
+
: `(${props})`;
|
|
369
|
+
if (call.output === 'html') {
|
|
370
|
+
if (composeHtml) {
|
|
371
|
+
callable = true;
|
|
372
|
+
return `(${compositionHtml}.bind(${runtime}.create({className:${JSON.stringify(classes[call.name])}}))${/\.[cm]?tsx?$/.test(options.moduleId) ? " as import('zyzz').style.ReturnType<'html'>" : ''})`;
|
|
373
|
+
}
|
|
374
|
+
usesHtml = true;
|
|
375
|
+
return `${html}.create({className:${JSON.stringify(classes[call.name])}})`;
|
|
376
|
+
}
|
|
377
|
+
return `${runtime}.create(${props})`;
|
|
378
|
+
})();
|
|
379
|
+
module.overwrite(call.start, application.end, replacement);
|
|
380
|
+
if (!call.recipe &&
|
|
381
|
+
!call.slots &&
|
|
382
|
+
!call.runtimeComposition &&
|
|
383
|
+
!application.folded &&
|
|
384
|
+
call.output !== 'html')
|
|
385
|
+
callable = true;
|
|
386
|
+
}
|
|
387
|
+
for (const application of localApplications?.find() ?? []) {
|
|
388
|
+
if (extracted.calls.some((call) => call.output === 'html' &&
|
|
389
|
+
call.runtimeComposition?.some((input) => input.applicationStart === application.start)))
|
|
390
|
+
continue;
|
|
391
|
+
if (extracted.calls.some((call) => (call.composition || call.runtimeComposition) &&
|
|
392
|
+
call.start < application.start &&
|
|
393
|
+
application.end <= call.end))
|
|
394
|
+
continue;
|
|
395
|
+
const className = JSON.stringify(classes[application.name]);
|
|
396
|
+
const key = extracted.calls.find((call) => call.name === application.name)?.output ===
|
|
397
|
+
'html'
|
|
398
|
+
? 'class'
|
|
399
|
+
: 'className';
|
|
400
|
+
// Keep a callable guard so bundlers also retain failures before initialization.
|
|
401
|
+
module.overwrite(application.start, application.end, `(${options.source.slice(application.start, application.calleeEnd)}?{${key}:${className}}:${options.source.slice(application.start, application.calleeEnd)}())`);
|
|
402
|
+
}
|
|
403
|
+
for (const call of extracted.themeCalls) {
|
|
404
|
+
const scope = (name) => ({ className: emitted.themes[name] });
|
|
405
|
+
const props = (() => {
|
|
406
|
+
if (!call.members)
|
|
407
|
+
return `{className:${JSON.stringify(emitted.themes[call.name])}}`;
|
|
408
|
+
const script = extracted.themeScripts?.includes(call.name);
|
|
409
|
+
const root = extracted.themeAppearances?.includes(call.name);
|
|
410
|
+
if (script || root)
|
|
411
|
+
usesAppearance = true;
|
|
412
|
+
// Helpers are emitted only when referenced; both share the configured storage key.
|
|
413
|
+
const storage = call.options?.storageKey;
|
|
414
|
+
const helpers = (entries, defaultTheme) => {
|
|
415
|
+
const scriptOptions = storage
|
|
416
|
+
? `,${JSON.stringify({ storageKey: storage })}`
|
|
417
|
+
: '';
|
|
418
|
+
const rootOptions = storage || defaultTheme
|
|
419
|
+
? `,${JSON.stringify({ ...(defaultTheme ? { defaultTheme } : {}), ...(storage ? { storageKey: storage } : {}) })}`
|
|
420
|
+
: '';
|
|
421
|
+
return `${root ? `appearance:${appearance}.root(${entries}${rootOptions}),` : ''}${script ? `script:${appearance}.create(${entries}${scriptOptions}),` : ''}`;
|
|
422
|
+
};
|
|
423
|
+
if (call.options?.themes) {
|
|
424
|
+
const catalog = Object.fromEntries(Object.entries(call.members)
|
|
425
|
+
.filter(([key]) => JSON.parse(key).length === 2)
|
|
426
|
+
.map(([key, name]) => [
|
|
427
|
+
JSON.parse(key)[1],
|
|
428
|
+
emitted.themes[name],
|
|
429
|
+
]));
|
|
430
|
+
const entries = JSON.stringify(Object.entries(catalog));
|
|
431
|
+
const defaultTheme = typeof call.options.defaultTheme === 'string'
|
|
432
|
+
? call.options.defaultTheme
|
|
433
|
+
: undefined;
|
|
434
|
+
if (unusedSelections.has(call.start))
|
|
435
|
+
return `{${helpers(entries, defaultTheme)}theme:${JSON.stringify(scope(call.members['["theme"]']))}}`;
|
|
436
|
+
usesSelection = true;
|
|
437
|
+
return `{${helpers(entries, defaultTheme)}theme:${JSON.stringify(scope(call.members['["theme"]']))},themes:/*#__PURE__*/${selection}.create(${entries},${call.options.output === 'html'})}`;
|
|
438
|
+
}
|
|
439
|
+
if (Object.hasOwn(call.members, '["theme"]'))
|
|
440
|
+
return `{${helpers('[]')}theme:${JSON.stringify(scope(call.members['["theme"]']))}}`;
|
|
441
|
+
return script || root ? `{${helpers('[]').slice(0, -1)}}` : '{}';
|
|
442
|
+
})();
|
|
443
|
+
const assertion = /\.[cm]?tsx?$/.test(options.moduleId)
|
|
444
|
+
? ` as ${call.type ?? `import('zyzz').Theme.Definition<${call.tokenType}>`}`
|
|
445
|
+
: '';
|
|
446
|
+
module.overwrite(call.start, call.end, `(${props}${assertion})`);
|
|
447
|
+
}
|
|
448
|
+
for (const alias of extracted.themeAliases) {
|
|
449
|
+
if (alias.retained) {
|
|
450
|
+
if (/\.[cm]?tsx?$/.test(options.moduleId))
|
|
451
|
+
module.overwrite(alias.start, alias.end, `(${options.source.slice(alias.start, alias.end)} as ${alias.type ?? `import('zyzz').Theme.Definition<${alias.tokenType}>`})`);
|
|
452
|
+
continue;
|
|
453
|
+
}
|
|
454
|
+
const member = alias.recipe ? 'variants' : 'style';
|
|
455
|
+
const members = [...new Set(alias.bindings ?? [member])];
|
|
456
|
+
const value = alias.destructured
|
|
457
|
+
? `{${members.map((member) => `${member}:undefined`).join(',')}}`
|
|
458
|
+
: 'undefined';
|
|
459
|
+
const type = alias.type ?? `import('zyzz').Theme.Definition<${alias.tokenType}>`;
|
|
460
|
+
const assertion = /\.[cm]?tsx?$/.test(options.moduleId)
|
|
461
|
+
? ` as unknown as ${alias.destructured ? `{${members.map((member) => `readonly ${member}:${type}['${member}']`).join(';')}}` : `${type}['${member}']`}`
|
|
462
|
+
: '';
|
|
463
|
+
module.overwrite(alias.start, alias.end, `(${value}${assertion})`);
|
|
464
|
+
}
|
|
465
|
+
const replacements = [
|
|
466
|
+
...extracted.calls.map((call) => ({
|
|
467
|
+
end: applications.get(call.start).end,
|
|
468
|
+
start: call.start,
|
|
469
|
+
})),
|
|
470
|
+
...(extracted.contributionCalls ?? []),
|
|
471
|
+
...(extracted.variableCalls ?? []),
|
|
472
|
+
...extracted.themeAliases,
|
|
473
|
+
...extracted.themeCalls,
|
|
474
|
+
].sort((a, b) => a.start - b.start);
|
|
475
|
+
function replaced(reference) {
|
|
476
|
+
let low = 0;
|
|
477
|
+
let high = replacements.length;
|
|
478
|
+
while (low < high) {
|
|
479
|
+
const middle = (low + high) >>> 1;
|
|
480
|
+
if (replacements[middle].start <= reference.start)
|
|
481
|
+
low = middle + 1;
|
|
482
|
+
else
|
|
483
|
+
high = middle;
|
|
484
|
+
}
|
|
485
|
+
const call = replacements[low - 1];
|
|
486
|
+
return call !== undefined && reference.end <= call.end;
|
|
487
|
+
}
|
|
488
|
+
for (const reference of extracted.staticThemeReferences ?? [])
|
|
489
|
+
if (!replaced(reference))
|
|
490
|
+
module.overwrite(reference.start, reference.end, JSON.stringify(reference.value));
|
|
491
|
+
for (const reference of extracted.themeReferences)
|
|
492
|
+
if (!replaced(reference))
|
|
493
|
+
module.overwrite(reference.start, reference.end, JSON.stringify(emitted.themes[reference.name]));
|
|
494
|
+
replacements.push(...extracted.themeReferences, ...(extracted.staticThemeReferences ?? []));
|
|
495
|
+
replacements.sort((a, b) => a.start - b.start);
|
|
496
|
+
for (const node of program.body) {
|
|
497
|
+
if (node.type !== 'ImportDeclaration' ||
|
|
498
|
+
!['zyzz', 'zyzz/web'].includes(node.source.value))
|
|
499
|
+
continue;
|
|
500
|
+
const removed = new Set();
|
|
501
|
+
for (const specifier of node.specifiers) {
|
|
502
|
+
if (node.importKind === 'type' ||
|
|
503
|
+
specifier.type !== 'ImportSpecifier' ||
|
|
504
|
+
specifier.importKind === 'type' ||
|
|
505
|
+
!(node.source.value === 'zyzz'
|
|
506
|
+
? ['Config', 'cx', 'style', 'Theme', 'variable', 'variants']
|
|
507
|
+
: [
|
|
508
|
+
'Css',
|
|
509
|
+
'cssFunction',
|
|
510
|
+
'customMedia',
|
|
511
|
+
'importCss',
|
|
512
|
+
'namespace',
|
|
513
|
+
'colorProfile',
|
|
514
|
+
'counterStyle',
|
|
515
|
+
'fontPaletteValues',
|
|
516
|
+
'fontFeatureValues',
|
|
517
|
+
'page',
|
|
518
|
+
'property',
|
|
519
|
+
'viewTransition',
|
|
520
|
+
'global',
|
|
521
|
+
'fontFace',
|
|
522
|
+
'keyframes',
|
|
523
|
+
'layers',
|
|
524
|
+
'positionTry',
|
|
525
|
+
]).includes(specifier.imported.type === 'Identifier'
|
|
526
|
+
? specifier.imported.name
|
|
527
|
+
: specifier.imported.value))
|
|
528
|
+
continue;
|
|
529
|
+
// Conservative retention also protects type queries and shadowed references.
|
|
530
|
+
const remaining = identifiers
|
|
531
|
+
.get(specifier.local.name)
|
|
532
|
+
?.some((reference) => !(reference.start >= node.start && reference.end <= node.end) &&
|
|
533
|
+
!replaced(reference));
|
|
534
|
+
if (!remaining)
|
|
535
|
+
removed.add(specifier);
|
|
536
|
+
}
|
|
537
|
+
if (!removed.size)
|
|
538
|
+
continue;
|
|
539
|
+
const retained = node.specifiers.filter((specifier) => !removed.has(specifier));
|
|
540
|
+
if (!retained.length)
|
|
541
|
+
module.remove(node.start, node.end);
|
|
542
|
+
else if (retained.every((specifier) => specifier.type !== 'ImportSpecifier')) {
|
|
543
|
+
module.overwrite(node.start, node.source.start, `import ${retained.map((specifier) => options.source.slice(specifier.start, specifier.end)).join(', ')} from `);
|
|
544
|
+
}
|
|
545
|
+
else {
|
|
546
|
+
// Preserve the import source, attributes, and untouched specifier spelling.
|
|
547
|
+
for (let index = 0; index < node.specifiers.length; index++) {
|
|
548
|
+
const specifier = node.specifiers[index];
|
|
549
|
+
if (!removed.has(specifier))
|
|
550
|
+
continue;
|
|
551
|
+
const next = node.specifiers[index + 1];
|
|
552
|
+
const previous = node.specifiers[index - 1];
|
|
553
|
+
if (next)
|
|
554
|
+
module.remove(specifier.start, next.start);
|
|
555
|
+
else if (previous)
|
|
556
|
+
module.remove(previous.end, specifier.end);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
if (callable ||
|
|
561
|
+
usesRecipe ||
|
|
562
|
+
usesComposition ||
|
|
563
|
+
usesCompositionHtml ||
|
|
564
|
+
usesConditionalRecipe ||
|
|
565
|
+
usesPayloadRecipe ||
|
|
566
|
+
usesHtml ||
|
|
567
|
+
usesSelection ||
|
|
568
|
+
usesAppearance ||
|
|
569
|
+
extracted.variableCalls?.length) {
|
|
570
|
+
// Insertion after a hashbang keeps executable module syntax intact.
|
|
571
|
+
let offset = options.source.startsWith('#!')
|
|
572
|
+
? options.source.indexOf('\n') + 1
|
|
573
|
+
: 0;
|
|
574
|
+
for (const node of program.body) {
|
|
575
|
+
if (node.type !== 'ExpressionStatement' || !node.directive)
|
|
576
|
+
break;
|
|
577
|
+
offset = node.end;
|
|
578
|
+
}
|
|
579
|
+
if (compositions.length)
|
|
580
|
+
module.appendLeft(offset, '\n' + compositions.join('\n') + '\n');
|
|
581
|
+
module.appendLeft(offset, `\nimport { ${[usesAppearance ? `Appearance as ${appearance}` : '', usesComposition ? `Composition as ${composition}` : '', usesCompositionHtml ? `CompositionHtml as ${compositionHtml}` : '', usesConditionalRecipe ? `ConditionalRecipe as ${conditionalRecipe}` : '', usesHtml ? `Html as ${html}` : '', usesPayloadRecipe ? `PayloadRecipe as ${payloadRecipe}` : '', callable ? `Props as ${runtime}` : '', usesRecipe ? `Recipe as ${recipe}` : '', usesSelection ? `Selection as ${selection}` : '', extracted.variableCalls?.length ? `Variable as ${variables}` : ''].filter(Boolean).join(', ')} } from 'zyzz/runtime';\n`);
|
|
582
|
+
}
|
|
583
|
+
const cssMap = new Mapping.GenMapping({ file: `${options.moduleId}.css` });
|
|
584
|
+
Mapping.setSourceContent(cssMap, options.moduleId, options.source);
|
|
585
|
+
const lines = [0];
|
|
586
|
+
for (let index = 0; index < options.source.length; index++)
|
|
587
|
+
if (options.source[index] === '\n')
|
|
588
|
+
lines.push(index + 1);
|
|
589
|
+
function position(offset) {
|
|
590
|
+
let low = 0;
|
|
591
|
+
let high = lines.length;
|
|
592
|
+
while (low + 1 < high) {
|
|
593
|
+
const middle = (low + high) >>> 1;
|
|
594
|
+
if (lines[middle] <= offset)
|
|
595
|
+
low = middle;
|
|
596
|
+
else
|
|
597
|
+
high = middle;
|
|
598
|
+
}
|
|
599
|
+
return { column: offset - lines[low], line: low + 1 };
|
|
600
|
+
}
|
|
601
|
+
const owners = new Map();
|
|
602
|
+
for (const call of extracted.calls)
|
|
603
|
+
for (const name of emitted.classes[call.name].split(' '))
|
|
604
|
+
if (!owners.has(name))
|
|
605
|
+
owners.set(name, call);
|
|
606
|
+
const styles = new Map(extracted.styles.styles.map((style) => [style.name, style]));
|
|
607
|
+
const themeOwners = new Map(extracted.themeCalls.flatMap((call) => [...new Set([call.name, ...Object.values(call.members ?? {})])].map((name) => [emitted.themes[name], { ...call, name }])));
|
|
608
|
+
const linkedOwners = new Map(Object.entries(options[Themes.context]?.owners ?? {}).map(([key, owner]) => [emitted.themes[key], owner]));
|
|
609
|
+
// Literal and scalar-theme rules each occupy one line at this boundary.
|
|
610
|
+
const prefix = emitted.contributionCss ?? '';
|
|
611
|
+
const contributions = (extracted.contributions ?? []).map((definition, index) => ({
|
|
612
|
+
definition,
|
|
613
|
+
start: extracted.contributionStarts?.[index],
|
|
614
|
+
}));
|
|
615
|
+
const rank = (kind) => kind === 'import' ? 0 : kind === 'namespace' ? 1 : 2;
|
|
616
|
+
const layered = contributions.find((value) => value.definition.kind === 'layers' && value.definition.names.length > 0);
|
|
617
|
+
let contributionLine = 1;
|
|
618
|
+
if (layered) {
|
|
619
|
+
if (layered.start !== undefined)
|
|
620
|
+
Mapping.addMapping(cssMap, {
|
|
621
|
+
generated: { line: contributionLine, column: 0 },
|
|
622
|
+
original: position(layered.start),
|
|
623
|
+
source: options.moduleId,
|
|
624
|
+
});
|
|
625
|
+
contributionLine++;
|
|
626
|
+
}
|
|
627
|
+
for (const contribution of contributions.toSorted((a, b) => rank(a.definition.kind) - rank(b.definition.kind))) {
|
|
628
|
+
if (contribution.definition.kind === 'layers')
|
|
629
|
+
continue;
|
|
630
|
+
const rendered = Css.compile({
|
|
631
|
+
styles: { styles: [] },
|
|
632
|
+
contributions: [contribution.definition],
|
|
633
|
+
themes: Object.keys(extracted.themes).length
|
|
634
|
+
? extracted.themes
|
|
635
|
+
: undefined,
|
|
636
|
+
}).contributionCss ?? '';
|
|
637
|
+
if (!rendered)
|
|
638
|
+
continue;
|
|
639
|
+
for (const _ of rendered.split('\n')) {
|
|
640
|
+
if (contribution.start !== undefined)
|
|
641
|
+
Mapping.addMapping(cssMap, {
|
|
642
|
+
generated: { line: contributionLine, column: 0 },
|
|
643
|
+
original: position(contribution.start),
|
|
644
|
+
source: options.moduleId,
|
|
645
|
+
});
|
|
646
|
+
contributionLine++;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
const declarationOwners = new Map();
|
|
650
|
+
const scoped = emitted.scopedCss ?? emitted.css;
|
|
651
|
+
const css = [
|
|
652
|
+
prefix,
|
|
653
|
+
(scoped ? scoped.split('\n') : [])
|
|
654
|
+
.map((rule, index) => {
|
|
655
|
+
const line = index + 1 + (prefix ? prefix.split('\n').length : 0);
|
|
656
|
+
const brace = rule.indexOf('{');
|
|
657
|
+
const name = rule.slice(1, brace);
|
|
658
|
+
const linkedOwner = linkedOwners.get(name);
|
|
659
|
+
if (linkedOwner) {
|
|
660
|
+
const lines = linkedOwner.source
|
|
661
|
+
.slice(0, linkedOwner.call.start)
|
|
662
|
+
.split('\n');
|
|
663
|
+
Mapping.setSourceContent(cssMap, linkedOwner.moduleId, linkedOwner.source);
|
|
664
|
+
Mapping.addMapping(cssMap, {
|
|
665
|
+
generated: { column: 0, line },
|
|
666
|
+
name: linkedOwner.call.name,
|
|
667
|
+
original: { line: lines.length, column: lines.at(-1).length },
|
|
668
|
+
source: linkedOwner.moduleId,
|
|
669
|
+
});
|
|
670
|
+
return rule;
|
|
671
|
+
}
|
|
672
|
+
const themeOwner = themeOwners.get(name);
|
|
673
|
+
if (themeOwner) {
|
|
674
|
+
Mapping.addMapping(cssMap, {
|
|
675
|
+
generated: { column: 0, line },
|
|
676
|
+
name: themeOwner.name,
|
|
677
|
+
original: position(themeOwner.start),
|
|
678
|
+
source: options.moduleId,
|
|
679
|
+
});
|
|
680
|
+
return rule;
|
|
681
|
+
}
|
|
682
|
+
if (Object.values(emitted.themes).includes(name)) {
|
|
683
|
+
// Packed theme declarations have no authored source in this graph.
|
|
684
|
+
Mapping.addMapping(cssMap, { generated: { column: 0, line } });
|
|
685
|
+
return rule;
|
|
686
|
+
}
|
|
687
|
+
if (Object.values(Scheme.classes).includes(name)) {
|
|
688
|
+
// Scheme selection rules accompany the scopes and have no authored source.
|
|
689
|
+
Mapping.addMapping(cssMap, { generated: { column: 0, line } });
|
|
690
|
+
return rule;
|
|
691
|
+
}
|
|
692
|
+
const selector = `.${names.get(name)}`;
|
|
693
|
+
const call = owners.get(name);
|
|
694
|
+
Mapping.addMapping(cssMap, {
|
|
695
|
+
generated: { column: 0, line },
|
|
696
|
+
name: call.name,
|
|
697
|
+
original: position(call.start),
|
|
698
|
+
source: options.moduleId,
|
|
699
|
+
});
|
|
700
|
+
const body = rule.slice(brace);
|
|
701
|
+
const style = styles.get(call.name);
|
|
702
|
+
function declarations(style) {
|
|
703
|
+
return style.rules
|
|
704
|
+
? style.rules.flatMap((rule) => declarations(rule.style))
|
|
705
|
+
: style.declarations;
|
|
706
|
+
}
|
|
707
|
+
const conditionNodes = [];
|
|
708
|
+
function locations(node) {
|
|
709
|
+
return node.properties.flatMap((property) => {
|
|
710
|
+
if (property.type !== 'Property')
|
|
711
|
+
return [];
|
|
712
|
+
const value = Expression.unwrap(property.value);
|
|
713
|
+
if (value.type === 'ObjectExpression') {
|
|
714
|
+
const key = property.key.type === 'Identifier'
|
|
715
|
+
? property.key.name
|
|
716
|
+
: property.key.type === 'Literal'
|
|
717
|
+
? property.key.value
|
|
718
|
+
: undefined;
|
|
719
|
+
if (key !== 'selectors')
|
|
720
|
+
conditionNodes.push(property);
|
|
721
|
+
return locations(value);
|
|
722
|
+
}
|
|
723
|
+
const key = property.key.type === 'Identifier'
|
|
724
|
+
? property.key.name
|
|
725
|
+
: property.key.type === 'Literal'
|
|
726
|
+
? String(property.key.value)
|
|
727
|
+
: '';
|
|
728
|
+
const authoredLocations = value.type === 'ArrayExpression'
|
|
729
|
+
? value.elements.filter((node) => node !== null)
|
|
730
|
+
: [property];
|
|
731
|
+
return (call.shorthands?.[key] ?? [key]).flatMap(() => authoredLocations);
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
const ordered = declarations(style);
|
|
735
|
+
const authored = locations(call.body ?? definitions.get(call.start));
|
|
736
|
+
const openers = new Map();
|
|
737
|
+
const conditionStarts = declarationStarts(body, true, openers);
|
|
738
|
+
const conditions = [];
|
|
739
|
+
function collectConditions(style) {
|
|
740
|
+
for (const rule of style.rules ?? []) {
|
|
741
|
+
if (rule.condition !== undefined)
|
|
742
|
+
conditions.push(rule.condition);
|
|
743
|
+
collectConditions(rule.style);
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
collectConditions(style);
|
|
747
|
+
let conditionCursor = 0;
|
|
748
|
+
for (const start of conditionStarts) {
|
|
749
|
+
const condition = body.slice(start, openers.get(start));
|
|
750
|
+
const index = conditions.indexOf(condition, conditionCursor);
|
|
751
|
+
const node = conditionNodes[index];
|
|
752
|
+
if (!node)
|
|
753
|
+
continue;
|
|
754
|
+
conditionCursor = index + 1;
|
|
755
|
+
Mapping.addMapping(cssMap, {
|
|
756
|
+
generated: { column: selector.length + start, line },
|
|
757
|
+
name: options.source.slice(node.key.start, node.key.end),
|
|
758
|
+
original: position(node.key.start),
|
|
759
|
+
source: options.moduleId,
|
|
760
|
+
});
|
|
761
|
+
}
|
|
762
|
+
const starts = declarationStarts(body);
|
|
763
|
+
const used = declarationOwners.get(call.name) ?? new Set();
|
|
764
|
+
declarationOwners.set(call.name, used);
|
|
765
|
+
let cursor = 1;
|
|
766
|
+
for (let propertyIndex = 0; propertyIndex < ordered.length; propertyIndex++) {
|
|
767
|
+
if (used.has(propertyIndex))
|
|
768
|
+
continue;
|
|
769
|
+
const declaration = ordered[propertyIndex];
|
|
770
|
+
const text = `${declaration.property.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)}:`;
|
|
771
|
+
const start = starts.find((start) => start >= cursor && body.startsWith(text, start)) ?? -1;
|
|
772
|
+
if (start < 0)
|
|
773
|
+
continue;
|
|
774
|
+
const location = authored[propertyIndex];
|
|
775
|
+
used.add(propertyIndex);
|
|
776
|
+
Mapping.addMapping(cssMap, {
|
|
777
|
+
generated: { column: selector.length + start, line },
|
|
778
|
+
name: declaration.property,
|
|
779
|
+
original: position(location.start),
|
|
780
|
+
source: options.moduleId,
|
|
781
|
+
});
|
|
782
|
+
cursor = start + text.length;
|
|
783
|
+
}
|
|
784
|
+
return selector + body;
|
|
785
|
+
})
|
|
786
|
+
.join('\n'),
|
|
787
|
+
]
|
|
788
|
+
.filter(Boolean)
|
|
789
|
+
.join('\n');
|
|
790
|
+
const map = (portable ? new MagicString(options.source) : module).generateMap({
|
|
791
|
+
hires: true,
|
|
792
|
+
includeContent: true,
|
|
793
|
+
source: options.moduleId,
|
|
794
|
+
});
|
|
795
|
+
const namespaced = Namespaces.rewrite(css, extracted.namespaces ?? [], Mapping.toEncodedMap(cssMap), true);
|
|
796
|
+
return Object.freeze({
|
|
797
|
+
classes,
|
|
798
|
+
code: portable ? options.source : module.toString(),
|
|
799
|
+
css: namespaced.css,
|
|
800
|
+
cssMap: namespaced.map ?? Mapping.toEncodedMap(cssMap),
|
|
801
|
+
map: {
|
|
802
|
+
file: options.moduleId,
|
|
803
|
+
mappings: map.mappings,
|
|
804
|
+
names: map.names,
|
|
805
|
+
sources: map.sources,
|
|
806
|
+
sourcesContent: map.sourcesContent,
|
|
807
|
+
version: 3,
|
|
808
|
+
},
|
|
809
|
+
themes: emitted.themes,
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
/** Locates emitted declarations while skipping selectors, conditions, and quoted CSS data. */
|
|
813
|
+
function declarationStarts(body, conditions = false, openers) {
|
|
814
|
+
const starts = [];
|
|
815
|
+
let start = 0;
|
|
816
|
+
let depth = 0;
|
|
817
|
+
let blocks = 0;
|
|
818
|
+
let custom = false;
|
|
819
|
+
let quote = '';
|
|
820
|
+
for (let index = 0; index < body.length; index++) {
|
|
821
|
+
const char = body[index];
|
|
822
|
+
if (char === '\\') {
|
|
823
|
+
index++;
|
|
824
|
+
continue;
|
|
825
|
+
}
|
|
826
|
+
if (quote) {
|
|
827
|
+
if (char === quote)
|
|
828
|
+
quote = '';
|
|
829
|
+
continue;
|
|
830
|
+
}
|
|
831
|
+
if (char === '"' || char === "'") {
|
|
832
|
+
quote = char;
|
|
833
|
+
continue;
|
|
834
|
+
}
|
|
835
|
+
if (char === '/' && body[index + 1] === '*') {
|
|
836
|
+
const end = body.indexOf('*/', index + 2);
|
|
837
|
+
if (end < 0)
|
|
838
|
+
break;
|
|
839
|
+
index = end + 1;
|
|
840
|
+
continue;
|
|
841
|
+
}
|
|
842
|
+
if (char === '(' || char === '[') {
|
|
843
|
+
depth++;
|
|
844
|
+
continue;
|
|
845
|
+
}
|
|
846
|
+
if (char === ')' || char === ']') {
|
|
847
|
+
depth--;
|
|
848
|
+
continue;
|
|
849
|
+
}
|
|
850
|
+
if (depth)
|
|
851
|
+
continue;
|
|
852
|
+
if (char === ':' && body.slice(start, index).trimStart().startsWith('--'))
|
|
853
|
+
custom = true;
|
|
854
|
+
if (char === '{') {
|
|
855
|
+
if (custom)
|
|
856
|
+
blocks++;
|
|
857
|
+
else {
|
|
858
|
+
if (conditions && index > start) {
|
|
859
|
+
starts.push(start);
|
|
860
|
+
openers?.set(start, index);
|
|
861
|
+
}
|
|
862
|
+
start = index + 1;
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
else if (char === '}') {
|
|
866
|
+
if (blocks)
|
|
867
|
+
blocks--;
|
|
868
|
+
else {
|
|
869
|
+
start = index + 1;
|
|
870
|
+
custom = false;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
else if (char === ';' && !blocks) {
|
|
874
|
+
while (/\s/.test(body[start] ?? '') && start < index)
|
|
875
|
+
start++;
|
|
876
|
+
if (!conditions)
|
|
877
|
+
starts.push(start);
|
|
878
|
+
start = index + 1;
|
|
879
|
+
custom = false;
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
return starts;
|
|
883
|
+
}
|
|
884
|
+
//# sourceMappingURL=Transform.js.map
|