zyzz 0.0.0 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +380 -0
- package/dist/Config.d.ts +170 -0
- package/dist/Config.d.ts.map +1 -0
- package/dist/Config.js +249 -0
- package/dist/Config.js.map +1 -0
- package/dist/Props.d.ts +7 -0
- package/dist/Props.d.ts.map +1 -0
- package/dist/Props.js +3 -0
- package/dist/Props.js.map +1 -0
- package/dist/Style.d.ts +170 -0
- package/dist/Style.d.ts.map +1 -0
- package/dist/Style.js +325 -0
- package/dist/Style.js.map +1 -0
- package/dist/Theme.d.ts +157 -0
- package/dist/Theme.d.ts.map +1 -0
- package/dist/Theme.js +273 -0
- package/dist/Theme.js.map +1 -0
- package/dist/babel/NativeEdits.d.ts +8 -0
- package/dist/babel/NativeEdits.d.ts.map +1 -0
- package/dist/babel/NativeEdits.js +233 -0
- package/dist/babel/NativeEdits.js.map +1 -0
- package/dist/babel/NativeJsx.d.ts +10 -0
- package/dist/babel/NativeJsx.d.ts.map +1 -0
- package/dist/babel/NativeJsx.js +204 -0
- package/dist/babel/NativeJsx.js.map +1 -0
- package/dist/babel/index.d.ts +51 -0
- package/dist/babel/index.d.ts.map +1 -0
- package/dist/babel/index.js +220 -0
- package/dist/babel/index.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +178 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/compiler/Graph.d.ts +64 -0
- package/dist/compiler/Graph.d.ts.map +1 -0
- package/dist/compiler/Graph.js +1111 -0
- package/dist/compiler/Graph.js.map +1 -0
- package/dist/compiler/Native.d.ts +53 -0
- package/dist/compiler/Native.d.ts.map +1 -0
- package/dist/compiler/Native.js +617 -0
- package/dist/compiler/Native.js.map +1 -0
- package/dist/compiler/Source.d.ts +167 -0
- package/dist/compiler/Source.d.ts.map +1 -0
- package/dist/compiler/Source.js +1012 -0
- package/dist/compiler/Source.js.map +1 -0
- package/dist/compiler/Transform.d.ts +57 -0
- package/dist/compiler/Transform.d.ts.map +1 -0
- package/dist/compiler/Transform.js +886 -0
- package/dist/compiler/Transform.js.map +1 -0
- package/dist/compiler/index.d.ts +13 -0
- package/dist/compiler/index.d.ts.map +1 -0
- package/dist/compiler/index.js +13 -0
- package/dist/compiler/index.js.map +1 -0
- package/dist/compiler/internal/Applications.d.ts +35 -0
- package/dist/compiler/internal/Applications.d.ts.map +1 -0
- package/dist/compiler/internal/Applications.js +248 -0
- package/dist/compiler/internal/Applications.js.map +1 -0
- package/dist/compiler/internal/AtRules.d.ts +8 -0
- package/dist/compiler/internal/AtRules.d.ts.map +1 -0
- package/dist/compiler/internal/AtRules.js +180 -0
- package/dist/compiler/internal/AtRules.js.map +1 -0
- package/dist/compiler/internal/Catalogs.d.ts +19 -0
- package/dist/compiler/internal/Catalogs.d.ts.map +1 -0
- package/dist/compiler/internal/Catalogs.js +68 -0
- package/dist/compiler/internal/Catalogs.js.map +1 -0
- package/dist/compiler/internal/ColorProfiles.d.ts +3 -0
- package/dist/compiler/internal/ColorProfiles.d.ts.map +1 -0
- package/dist/compiler/internal/ColorProfiles.js +84 -0
- package/dist/compiler/internal/ColorProfiles.js.map +1 -0
- package/dist/compiler/internal/CompositionBindings.d.ts +16 -0
- package/dist/compiler/internal/CompositionBindings.d.ts.map +1 -0
- package/dist/compiler/internal/CompositionBindings.js +89 -0
- package/dist/compiler/internal/CompositionBindings.js.map +1 -0
- package/dist/compiler/internal/Compositions.d.ts +32 -0
- package/dist/compiler/internal/Compositions.d.ts.map +1 -0
- package/dist/compiler/internal/Compositions.js +464 -0
- package/dist/compiler/internal/Compositions.js.map +1 -0
- package/dist/compiler/internal/Configurations.d.ts +21 -0
- package/dist/compiler/internal/Configurations.d.ts.map +1 -0
- package/dist/compiler/internal/Configurations.js +171 -0
- package/dist/compiler/internal/Configurations.js.map +1 -0
- package/dist/compiler/internal/Contract.d.ts +27 -0
- package/dist/compiler/internal/Contract.d.ts.map +1 -0
- package/dist/compiler/internal/Contract.js +607 -0
- package/dist/compiler/internal/Contract.js.map +1 -0
- package/dist/compiler/internal/Contributions.d.ts +54 -0
- package/dist/compiler/internal/Contributions.d.ts.map +1 -0
- package/dist/compiler/internal/Contributions.js +1109 -0
- package/dist/compiler/internal/Contributions.js.map +1 -0
- package/dist/compiler/internal/Descriptors.d.ts +15 -0
- package/dist/compiler/internal/Descriptors.d.ts.map +1 -0
- package/dist/compiler/internal/Descriptors.js +183 -0
- package/dist/compiler/internal/Descriptors.js.map +1 -0
- package/dist/compiler/internal/Dynamic.d.ts +14 -0
- package/dist/compiler/internal/Dynamic.d.ts.map +1 -0
- package/dist/compiler/internal/Dynamic.js +172 -0
- package/dist/compiler/internal/Dynamic.js.map +1 -0
- package/dist/compiler/internal/Edits.d.ts +12 -0
- package/dist/compiler/internal/Edits.d.ts.map +1 -0
- package/dist/compiler/internal/Edits.js +5 -0
- package/dist/compiler/internal/Edits.js.map +1 -0
- package/dist/compiler/internal/Expression.d.ts +12 -0
- package/dist/compiler/internal/Expression.d.ts.map +1 -0
- package/dist/compiler/internal/Expression.js +98 -0
- package/dist/compiler/internal/Expression.js.map +1 -0
- package/dist/compiler/internal/Functions.d.ts +5 -0
- package/dist/compiler/internal/Functions.d.ts.map +1 -0
- package/dist/compiler/internal/Functions.js +191 -0
- package/dist/compiler/internal/Functions.js.map +1 -0
- package/dist/compiler/internal/Identifiers.d.ts +9 -0
- package/dist/compiler/internal/Identifiers.d.ts.map +1 -0
- package/dist/compiler/internal/Identifiers.js +106 -0
- package/dist/compiler/internal/Identifiers.js.map +1 -0
- package/dist/compiler/internal/Keyframes.d.ts +5 -0
- package/dist/compiler/internal/Keyframes.d.ts.map +1 -0
- package/dist/compiler/internal/Keyframes.js +51 -0
- package/dist/compiler/internal/Keyframes.js.map +1 -0
- package/dist/compiler/internal/Namespaces.d.ts +17 -0
- package/dist/compiler/internal/Namespaces.d.ts.map +1 -0
- package/dist/compiler/internal/Namespaces.js +265 -0
- package/dist/compiler/internal/Namespaces.js.map +1 -0
- package/dist/compiler/internal/NativeBindings.d.ts +74 -0
- package/dist/compiler/internal/NativeBindings.d.ts.map +1 -0
- package/dist/compiler/internal/NativeBindings.js +117 -0
- package/dist/compiler/internal/NativeBindings.js.map +1 -0
- package/dist/compiler/internal/PackedStyles.d.ts +35 -0
- package/dist/compiler/internal/PackedStyles.d.ts.map +1 -0
- package/dist/compiler/internal/PackedStyles.js +345 -0
- package/dist/compiler/internal/PackedStyles.js.map +1 -0
- package/dist/compiler/internal/Properties.d.ts +5 -0
- package/dist/compiler/internal/Properties.d.ts.map +1 -0
- package/dist/compiler/internal/Properties.js +82 -0
- package/dist/compiler/internal/Properties.js.map +1 -0
- package/dist/compiler/internal/RecipeConditions.d.ts +41 -0
- package/dist/compiler/internal/RecipeConditions.d.ts.map +1 -0
- package/dist/compiler/internal/RecipeConditions.js +82 -0
- package/dist/compiler/internal/RecipeConditions.js.map +1 -0
- package/dist/compiler/internal/RecipePayloads.d.ts +31 -0
- package/dist/compiler/internal/RecipePayloads.d.ts.map +1 -0
- package/dist/compiler/internal/RecipePayloads.js +99 -0
- package/dist/compiler/internal/RecipePayloads.js.map +1 -0
- package/dist/compiler/internal/Recipes.d.ts +32 -0
- package/dist/compiler/internal/Recipes.d.ts.map +1 -0
- package/dist/compiler/internal/Recipes.js +339 -0
- package/dist/compiler/internal/Recipes.js.map +1 -0
- package/dist/compiler/internal/Relative.d.ts +19 -0
- package/dist/compiler/internal/Relative.d.ts.map +1 -0
- package/dist/compiler/internal/Relative.js +62 -0
- package/dist/compiler/internal/Relative.js.map +1 -0
- package/dist/compiler/internal/Scope.d.ts +10 -0
- package/dist/compiler/internal/Scope.d.ts.map +1 -0
- package/dist/compiler/internal/Scope.js +28 -0
- package/dist/compiler/internal/Scope.js.map +1 -0
- package/dist/compiler/internal/Selectors.d.ts +12 -0
- package/dist/compiler/internal/Selectors.d.ts.map +1 -0
- package/dist/compiler/internal/Selectors.js +265 -0
- package/dist/compiler/internal/Selectors.js.map +1 -0
- package/dist/compiler/internal/Static.d.ts +39 -0
- package/dist/compiler/internal/Static.d.ts.map +1 -0
- package/dist/compiler/internal/Static.js +532 -0
- package/dist/compiler/internal/Static.js.map +1 -0
- package/dist/compiler/internal/Stylesheets.d.ts +47 -0
- package/dist/compiler/internal/Stylesheets.d.ts.map +1 -0
- package/dist/compiler/internal/Stylesheets.js +272 -0
- package/dist/compiler/internal/Stylesheets.js.map +1 -0
- package/dist/compiler/internal/Syntax.d.ts +17 -0
- package/dist/compiler/internal/Syntax.d.ts.map +1 -0
- package/dist/compiler/internal/Syntax.js +19 -0
- package/dist/compiler/internal/Syntax.js.map +1 -0
- package/dist/compiler/internal/Themes.d.ts +158 -0
- package/dist/compiler/internal/Themes.d.ts.map +1 -0
- package/dist/compiler/internal/Themes.js +1169 -0
- package/dist/compiler/internal/Themes.js.map +1 -0
- package/dist/compiler/internal/Variables.d.ts +31 -0
- package/dist/compiler/internal/Variables.d.ts.map +1 -0
- package/dist/compiler/internal/Variables.js +376 -0
- package/dist/compiler/internal/Variables.js.map +1 -0
- package/dist/compiler/internal/ViewTransitions.d.ts +3 -0
- package/dist/compiler/internal/ViewTransitions.d.ts.map +1 -0
- package/dist/compiler/internal/ViewTransitions.js +68 -0
- package/dist/compiler/internal/ViewTransitions.js.map +1 -0
- package/dist/cx.d.ts +18 -0
- package/dist/cx.d.ts.map +1 -0
- package/dist/cx.js +60 -0
- package/dist/cx.js.map +1 -0
- package/dist/default.d.ts +3225 -0
- package/dist/default.d.ts.map +1 -0
- package/dist/default.js +547 -0
- package/dist/default.js.map +7 -0
- package/dist/default.js.zyzz.json +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/Authoring.d.ts +26 -0
- package/dist/internal/Authoring.d.ts.map +1 -0
- package/dist/internal/Authoring.js +134 -0
- package/dist/internal/Authoring.js.map +1 -0
- package/dist/internal/Binding.d.ts +64 -0
- package/dist/internal/Binding.d.ts.map +1 -0
- package/dist/internal/Binding.js +27 -0
- package/dist/internal/Binding.js.map +1 -0
- package/dist/internal/BindingDomains.d.ts +11 -0
- package/dist/internal/BindingDomains.d.ts.map +1 -0
- package/dist/internal/BindingDomains.js +459 -0
- package/dist/internal/BindingDomains.js.map +1 -0
- package/dist/internal/Cascade.d.ts +45 -0
- package/dist/internal/Cascade.d.ts.map +1 -0
- package/dist/internal/Cascade.js +165 -0
- package/dist/internal/Cascade.js.map +1 -0
- package/dist/internal/Compound.d.ts +132 -0
- package/dist/internal/Compound.d.ts.map +1 -0
- package/dist/internal/Compound.js +2 -0
- package/dist/internal/Compound.js.map +1 -0
- package/dist/internal/Condition.d.ts +33 -0
- package/dist/internal/Condition.d.ts.map +1 -0
- package/dist/internal/Condition.js +180 -0
- package/dist/internal/Condition.js.map +1 -0
- package/dist/internal/Corner.d.ts +9 -0
- package/dist/internal/Corner.d.ts.map +1 -0
- package/dist/internal/Corner.js +14 -0
- package/dist/internal/Corner.js.map +1 -0
- package/dist/internal/FunctionSyntax.d.ts +27 -0
- package/dist/internal/FunctionSyntax.d.ts.map +1 -0
- package/dist/internal/FunctionSyntax.js +91 -0
- package/dist/internal/FunctionSyntax.js.map +1 -0
- package/dist/internal/FunctionValue.d.ts +19 -0
- package/dist/internal/FunctionValue.d.ts.map +1 -0
- package/dist/internal/FunctionValue.js +2 -0
- package/dist/internal/FunctionValue.js.map +1 -0
- package/dist/internal/Geometry.d.ts +8 -0
- package/dist/internal/Geometry.d.ts.map +1 -0
- package/dist/internal/Geometry.js +2 -0
- package/dist/internal/Geometry.js.map +1 -0
- package/dist/internal/Grid.d.ts +15 -0
- package/dist/internal/Grid.d.ts.map +1 -0
- package/dist/internal/Grid.js +2 -0
- package/dist/internal/Grid.js.map +1 -0
- package/dist/internal/Identifier.d.ts +15 -0
- package/dist/internal/Identifier.d.ts.map +1 -0
- package/dist/internal/Identifier.js +2 -0
- package/dist/internal/Identifier.js.map +1 -0
- package/dist/internal/Identity.d.ts +16 -0
- package/dist/internal/Identity.d.ts.map +1 -0
- package/dist/internal/Identity.js +78 -0
- package/dist/internal/Identity.js.map +1 -0
- package/dist/internal/Lexical.d.ts +89 -0
- package/dist/internal/Lexical.d.ts.map +1 -0
- package/dist/internal/Lexical.js +15 -0
- package/dist/internal/Lexical.js.map +1 -0
- package/dist/internal/Literal.d.ts +3459 -0
- package/dist/internal/Literal.d.ts.map +1 -0
- package/dist/internal/Literal.js +3371 -0
- package/dist/internal/Literal.js.map +1 -0
- package/dist/internal/NativeProperties.d.ts +596 -0
- package/dist/internal/NativeProperties.d.ts.map +1 -0
- package/dist/internal/NativeProperties.js +2 -0
- package/dist/internal/NativeProperties.js.map +1 -0
- package/dist/internal/Numeric.d.ts +23 -0
- package/dist/internal/Numeric.d.ts.map +1 -0
- package/dist/internal/Numeric.js +2 -0
- package/dist/internal/Numeric.js.map +1 -0
- package/dist/internal/Query.d.ts +15 -0
- package/dist/internal/Query.d.ts.map +1 -0
- package/dist/internal/Query.js +58 -0
- package/dist/internal/Query.js.map +1 -0
- package/dist/internal/Recipe.d.ts +17 -0
- package/dist/internal/Recipe.d.ts.map +1 -0
- package/dist/internal/Recipe.js +2 -0
- package/dist/internal/Recipe.js.map +1 -0
- package/dist/internal/RuleReference.d.ts +23 -0
- package/dist/internal/RuleReference.d.ts.map +1 -0
- package/dist/internal/RuleReference.js +65 -0
- package/dist/internal/RuleReference.js.map +1 -0
- package/dist/internal/Scheme.d.ts +12 -0
- package/dist/internal/Scheme.d.ts.map +1 -0
- package/dist/internal/Scheme.js +16 -0
- package/dist/internal/Scheme.js.map +1 -0
- package/dist/internal/Shorthands.d.ts +20 -0
- package/dist/internal/Shorthands.d.ts.map +1 -0
- package/dist/internal/Shorthands.js +50 -0
- package/dist/internal/Shorthands.js.map +1 -0
- package/dist/internal/Targets.d.ts +43 -0
- package/dist/internal/Targets.d.ts.map +1 -0
- package/dist/internal/Targets.js +60 -0
- package/dist/internal/Targets.js.map +1 -0
- package/dist/internal/Token.d.ts +104 -0
- package/dist/internal/Token.d.ts.map +1 -0
- package/dist/internal/Token.js +162 -0
- package/dist/internal/Token.js.map +1 -0
- package/dist/internal/Tuple.d.ts +23 -0
- package/dist/internal/Tuple.d.ts.map +1 -0
- package/dist/internal/Tuple.js +2 -0
- package/dist/internal/Tuple.js.map +1 -0
- package/dist/internal/Typography.d.ts +23 -0
- package/dist/internal/Typography.d.ts.map +1 -0
- package/dist/internal/Typography.js +18 -0
- package/dist/internal/Typography.js.map +1 -0
- package/dist/internal/Value.d.ts +74 -0
- package/dist/internal/Value.d.ts.map +1 -0
- package/dist/internal/Value.js +60 -0
- package/dist/internal/Value.js.map +1 -0
- package/dist/metro/Graph.d.ts +8 -0
- package/dist/metro/Graph.d.ts.map +1 -0
- package/dist/metro/Graph.js +63 -0
- package/dist/metro/Graph.js.map +1 -0
- package/dist/metro/Watch.d.ts +21 -0
- package/dist/metro/Watch.d.ts.map +1 -0
- package/dist/metro/Watch.js +51 -0
- package/dist/metro/Watch.js.map +1 -0
- package/dist/metro/index.d.ts +30 -0
- package/dist/metro/index.d.ts.map +1 -0
- package/dist/metro/index.js +52 -0
- package/dist/metro/index.js.map +1 -0
- package/dist/metro/transformer.d.ts +21 -0
- package/dist/metro/transformer.d.ts.map +1 -0
- package/dist/metro/transformer.js +71 -0
- package/dist/metro/transformer.js.map +1 -0
- package/dist/next/index.d.ts +18 -0
- package/dist/next/index.d.ts.map +1 -0
- package/dist/next/index.js +92 -0
- package/dist/next/index.js.map +1 -0
- package/dist/next/loader.d.ts +16 -0
- package/dist/next/loader.d.ts.map +1 -0
- package/dist/next/loader.js +282 -0
- package/dist/next/loader.js.map +1 -0
- package/dist/node/Host.d.ts +80 -0
- package/dist/node/Host.d.ts.map +1 -0
- package/dist/node/Host.js +882 -0
- package/dist/node/Host.js.map +1 -0
- package/dist/node/index.d.ts +7 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +7 -0
- package/dist/node/index.js.map +1 -0
- package/dist/react-native/Host.d.ts +76 -0
- package/dist/react-native/Host.d.ts.map +1 -0
- package/dist/react-native/Host.js +209 -0
- package/dist/react-native/Host.js.map +1 -0
- package/dist/react-native/StyleSheet.d.ts +226 -0
- package/dist/react-native/StyleSheet.d.ts.map +1 -0
- package/dist/react-native/StyleSheet.js +606 -0
- package/dist/react-native/StyleSheet.js.map +1 -0
- package/dist/react-native/Variants.d.ts +38 -0
- package/dist/react-native/Variants.d.ts.map +1 -0
- package/dist/react-native/Variants.js +66 -0
- package/dist/react-native/Variants.js.map +1 -0
- package/dist/react-native/index.d.ts +8 -0
- package/dist/react-native/index.d.ts.map +1 -0
- package/dist/react-native/index.js +8 -0
- package/dist/react-native/index.js.map +1 -0
- package/dist/react-native/internal/Color.d.ts +7 -0
- package/dist/react-native/internal/Color.d.ts.map +1 -0
- package/dist/react-native/internal/Color.js +93 -0
- package/dist/react-native/internal/Color.js.map +1 -0
- package/dist/react-native/internal/NativeSchema.d.ts +5138 -0
- package/dist/react-native/internal/NativeSchema.d.ts.map +1 -0
- package/dist/react-native/internal/NativeSchema.js +3097 -0
- package/dist/react-native/internal/NativeSchema.js.map +1 -0
- package/dist/react-native/internal/Scalar.d.ts +95 -0
- package/dist/react-native/internal/Scalar.d.ts.map +1 -0
- package/dist/react-native/internal/Scalar.js +199 -0
- package/dist/react-native/internal/Scalar.js.map +1 -0
- package/dist/react-native/internal/Values.d.ts +5 -0
- package/dist/react-native/internal/Values.d.ts.map +1 -0
- package/dist/react-native/internal/Values.js +65 -0
- package/dist/react-native/internal/Values.js.map +1 -0
- package/dist/react-native/react.d.ts +22 -0
- package/dist/react-native/react.d.ts.map +1 -0
- package/dist/react-native/react.js +26 -0
- package/dist/react-native/react.js.map +1 -0
- package/dist/reset.css +244 -0
- package/dist/runtime/Appearance.d.ts +55 -0
- package/dist/runtime/Appearance.d.ts.map +1 -0
- package/dist/runtime/Appearance.js +84 -0
- package/dist/runtime/Appearance.js.map +1 -0
- package/dist/runtime/Composition.d.ts +46 -0
- package/dist/runtime/Composition.d.ts.map +1 -0
- package/dist/runtime/Composition.js +52 -0
- package/dist/runtime/Composition.js.map +1 -0
- package/dist/runtime/CompositionHtml.d.ts +15 -0
- package/dist/runtime/CompositionHtml.d.ts.map +1 -0
- package/dist/runtime/CompositionHtml.js +20 -0
- package/dist/runtime/CompositionHtml.js.map +1 -0
- package/dist/runtime/ConditionalRecipe.d.ts +30 -0
- package/dist/runtime/ConditionalRecipe.d.ts.map +1 -0
- package/dist/runtime/ConditionalRecipe.js +39 -0
- package/dist/runtime/ConditionalRecipe.js.map +1 -0
- package/dist/runtime/Dynamic.d.ts +19 -0
- package/dist/runtime/Dynamic.d.ts.map +1 -0
- package/dist/runtime/Dynamic.js +22 -0
- package/dist/runtime/Dynamic.js.map +1 -0
- package/dist/runtime/Html.d.ts +32 -0
- package/dist/runtime/Html.d.ts.map +1 -0
- package/dist/runtime/Html.js +63 -0
- package/dist/runtime/Html.js.map +1 -0
- package/dist/runtime/Native.d.ts +48 -0
- package/dist/runtime/Native.d.ts.map +1 -0
- package/dist/runtime/Native.js +78 -0
- package/dist/runtime/Native.js.map +1 -0
- package/dist/runtime/NativeContext.d.ts +17 -0
- package/dist/runtime/NativeContext.d.ts.map +1 -0
- package/dist/runtime/NativeContext.js +47 -0
- package/dist/runtime/NativeContext.js.map +1 -0
- package/dist/runtime/NativeDynamic.d.ts +47 -0
- package/dist/runtime/NativeDynamic.d.ts.map +1 -0
- package/dist/runtime/NativeDynamic.js +141 -0
- package/dist/runtime/NativeDynamic.js.map +1 -0
- package/dist/runtime/PayloadRecipe.d.ts +22 -0
- package/dist/runtime/PayloadRecipe.d.ts.map +1 -0
- package/dist/runtime/PayloadRecipe.js +59 -0
- package/dist/runtime/PayloadRecipe.js.map +1 -0
- package/dist/runtime/Props.d.ts +21 -0
- package/dist/runtime/Props.d.ts.map +1 -0
- package/dist/runtime/Props.js +17 -0
- package/dist/runtime/Props.js.map +1 -0
- package/dist/runtime/Recipe.d.ts +52 -0
- package/dist/runtime/Recipe.d.ts.map +1 -0
- package/dist/runtime/Recipe.js +30 -0
- package/dist/runtime/Recipe.js.map +1 -0
- package/dist/runtime/Selection.d.ts +31 -0
- package/dist/runtime/Selection.d.ts.map +1 -0
- package/dist/runtime/Selection.js +30 -0
- package/dist/runtime/Selection.js.map +1 -0
- package/dist/runtime/Variable.d.ts +6 -0
- package/dist/runtime/Variable.d.ts.map +1 -0
- package/dist/runtime/Variable.js +10 -0
- package/dist/runtime/Variable.js.map +1 -0
- package/dist/runtime/index.d.ts +33 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +33 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/styleFunction.d.ts +72 -0
- package/dist/styleFunction.d.ts.map +1 -0
- package/dist/styleFunction.js +18 -0
- package/dist/styleFunction.js.map +1 -0
- package/dist/themes/LICENSE.tailwind +21 -0
- package/dist/variable.d.ts +50 -0
- package/dist/variable.d.ts.map +1 -0
- package/dist/variable.js +20 -0
- package/dist/variable.js.map +1 -0
- package/dist/variants.d.ts +84 -0
- package/dist/variants.d.ts.map +1 -0
- package/dist/variants.js +21 -0
- package/dist/variants.js.map +1 -0
- package/dist/vite/index.d.ts +24 -0
- package/dist/vite/index.d.ts.map +1 -0
- package/dist/vite/index.js +1089 -0
- package/dist/vite/index.js.map +1 -0
- package/dist/web/Css.d.ts +81 -0
- package/dist/web/Css.d.ts.map +1 -0
- package/dist/web/Css.js +593 -0
- package/dist/web/Css.js.map +1 -0
- package/dist/web/colorProfile.d.ts +28 -0
- package/dist/web/colorProfile.d.ts.map +1 -0
- package/dist/web/colorProfile.js +8 -0
- package/dist/web/colorProfile.js.map +1 -0
- package/dist/web/counterStyle.d.ts +48 -0
- package/dist/web/counterStyle.d.ts.map +1 -0
- package/dist/web/counterStyle.js +8 -0
- package/dist/web/counterStyle.js.map +1 -0
- package/dist/web/cssFunction.d.ts +80 -0
- package/dist/web/cssFunction.d.ts.map +1 -0
- package/dist/web/cssFunction.js +18 -0
- package/dist/web/cssFunction.js.map +1 -0
- package/dist/web/customMedia.d.ts +12 -0
- package/dist/web/customMedia.d.ts.map +1 -0
- package/dist/web/customMedia.js +7 -0
- package/dist/web/customMedia.js.map +1 -0
- package/dist/web/fontFace.d.ts +26 -0
- package/dist/web/fontFace.d.ts.map +1 -0
- package/dist/web/fontFace.js +7 -0
- package/dist/web/fontFace.js.map +1 -0
- package/dist/web/fontFeatureValues.d.ts +40 -0
- package/dist/web/fontFeatureValues.d.ts.map +1 -0
- package/dist/web/fontFeatureValues.js +7 -0
- package/dist/web/fontFeatureValues.js.map +1 -0
- package/dist/web/fontPaletteValues.d.ts +21 -0
- package/dist/web/fontPaletteValues.d.ts.map +1 -0
- package/dist/web/fontPaletteValues.js +9 -0
- package/dist/web/fontPaletteValues.js.map +1 -0
- package/dist/web/global.d.ts +19 -0
- package/dist/web/global.d.ts.map +1 -0
- package/dist/web/global.js +6 -0
- package/dist/web/global.js.map +1 -0
- package/dist/web/importCss.d.ts +18 -0
- package/dist/web/importCss.d.ts.map +1 -0
- package/dist/web/importCss.js +7 -0
- package/dist/web/importCss.js.map +1 -0
- package/dist/web/index.d.ts +22 -0
- package/dist/web/index.d.ts.map +1 -0
- package/dist/web/index.js +22 -0
- package/dist/web/index.js.map +1 -0
- package/dist/web/internal/Block.d.ts +18 -0
- package/dist/web/internal/Block.d.ts.map +1 -0
- package/dist/web/internal/Block.js +13 -0
- package/dist/web/internal/Block.js.map +1 -0
- package/dist/web/internal/ClassName.d.ts +19 -0
- package/dist/web/internal/ClassName.d.ts.map +1 -0
- package/dist/web/internal/ClassName.js +77 -0
- package/dist/web/internal/ClassName.js.map +1 -0
- package/dist/web/internal/Context.d.ts +11 -0
- package/dist/web/internal/Context.d.ts.map +1 -0
- package/dist/web/internal/Context.js +2 -0
- package/dist/web/internal/Context.js.map +1 -0
- package/dist/web/internal/Contributions.d.ts +70 -0
- package/dist/web/internal/Contributions.d.ts.map +1 -0
- package/dist/web/internal/Contributions.js +109 -0
- package/dist/web/internal/Contributions.js.map +1 -0
- package/dist/web/internal/Namespace.d.ts +13 -0
- package/dist/web/internal/Namespace.d.ts.map +1 -0
- package/dist/web/internal/Namespace.js +13 -0
- package/dist/web/internal/Namespace.js.map +1 -0
- package/dist/web/internal/Themes.d.ts +13 -0
- package/dist/web/internal/Themes.d.ts.map +1 -0
- package/dist/web/internal/Themes.js +96 -0
- package/dist/web/internal/Themes.js.map +1 -0
- package/dist/web/keyframes.d.ts +14 -0
- package/dist/web/keyframes.d.ts.map +1 -0
- package/dist/web/keyframes.js +8 -0
- package/dist/web/keyframes.js.map +1 -0
- package/dist/web/layers.d.ts +4 -0
- package/dist/web/layers.d.ts.map +1 -0
- package/dist/web/layers.js +7 -0
- package/dist/web/layers.js.map +1 -0
- package/dist/web/namespace.d.ts +14 -0
- package/dist/web/namespace.d.ts.map +1 -0
- package/dist/web/namespace.js +7 -0
- package/dist/web/namespace.js.map +1 -0
- package/dist/web/page.d.ts +38 -0
- package/dist/web/page.d.ts.map +1 -0
- package/dist/web/page.js +7 -0
- package/dist/web/page.js.map +1 -0
- package/dist/web/positionTry.d.ts +14 -0
- package/dist/web/positionTry.d.ts.map +1 -0
- package/dist/web/positionTry.js +9 -0
- package/dist/web/positionTry.js.map +1 -0
- package/dist/web/property.d.ts +24 -0
- package/dist/web/property.d.ts.map +1 -0
- package/dist/web/property.js +7 -0
- package/dist/web/property.js.map +1 -0
- package/dist/web/viewTransition.d.ts +29 -0
- package/dist/web/viewTransition.d.ts.map +1 -0
- package/dist/web/viewTransition.js +7 -0
- package/dist/web/viewTransition.js.map +1 -0
- package/package.json +136 -10
- package/src/Config.ts +691 -0
- package/src/Props.ts +8 -0
- package/src/Style.ts +812 -0
- package/src/Theme.ts +784 -0
- package/src/babel/NativeEdits.ts +273 -0
- package/src/babel/NativeJsx.ts +260 -0
- package/src/babel/index.ts +332 -0
- package/src/cli/index.ts +196 -0
- package/src/compiler/Graph.ts +1586 -0
- package/src/compiler/Native.ts +801 -0
- package/src/compiler/Source.ts +1579 -0
- package/src/compiler/Transform.ts +1241 -0
- package/src/compiler/index.ts +12 -0
- package/src/compiler/internal/Applications.ts +378 -0
- package/src/compiler/internal/AtRules.ts +202 -0
- package/src/compiler/internal/Catalogs.ts +114 -0
- package/src/compiler/internal/ColorProfiles.ts +93 -0
- package/src/compiler/internal/CompositionBindings.ts +120 -0
- package/src/compiler/internal/Compositions.ts +629 -0
- package/src/compiler/internal/Configurations.ts +244 -0
- package/src/compiler/internal/Contract.ts +860 -0
- package/src/compiler/internal/Contributions.ts +1507 -0
- package/src/compiler/internal/Descriptors.ts +238 -0
- package/src/compiler/internal/Dynamic.ts +266 -0
- package/src/compiler/internal/Edits.ts +13 -0
- package/src/compiler/internal/Expression.ts +135 -0
- package/src/compiler/internal/Functions.ts +206 -0
- package/src/compiler/internal/Identifiers.ts +124 -0
- package/src/compiler/internal/Keyframes.ts +62 -0
- package/src/compiler/internal/Namespaces.ts +296 -0
- package/src/compiler/internal/NativeBindings.ts +151 -0
- package/src/compiler/internal/PackedStyles.ts +464 -0
- package/src/compiler/internal/Properties.ts +121 -0
- package/src/compiler/internal/RecipeConditions.ts +139 -0
- package/src/compiler/internal/RecipePayloads.ts +132 -0
- package/src/compiler/internal/Recipes.ts +531 -0
- package/src/compiler/internal/Relative.ts +87 -0
- package/src/compiler/internal/Scope.ts +36 -0
- package/src/compiler/internal/Selectors.ts +334 -0
- package/src/compiler/internal/Static.ts +783 -0
- package/src/compiler/internal/Stylesheets.ts +361 -0
- package/src/compiler/internal/Syntax.ts +31 -0
- package/src/compiler/internal/Themes.ts +1794 -0
- package/src/compiler/internal/Variables.ts +497 -0
- package/src/compiler/internal/ViewTransitions.ts +82 -0
- package/src/cx.ts +98 -0
- package/src/default.ts +1177 -0
- package/src/index.ts +20 -0
- package/src/internal/Authoring.ts +199 -0
- package/src/internal/Binding.ts +187 -0
- package/src/internal/BindingDomains.ts +458 -0
- package/src/internal/Cascade.ts +165 -0
- package/src/internal/Compound.ts +522 -0
- package/src/internal/Condition.ts +283 -0
- package/src/internal/Corner.ts +17 -0
- package/src/internal/FunctionSyntax.ts +271 -0
- package/src/internal/FunctionValue.ts +96 -0
- package/src/internal/Geometry.ts +30 -0
- package/src/internal/Grid.ts +67 -0
- package/src/internal/Identifier.ts +14 -0
- package/src/internal/Identity.ts +89 -0
- package/src/internal/Lexical.ts +202 -0
- package/src/internal/Literal.ts +3820 -0
- package/src/internal/NativeProperties.ts +936 -0
- package/src/internal/Numeric.ts +77 -0
- package/src/internal/Query.ts +87 -0
- package/src/internal/Recipe.ts +17 -0
- package/src/internal/RuleReference.ts +102 -0
- package/src/internal/Scheme.ts +20 -0
- package/src/internal/Shorthands.ts +122 -0
- package/src/internal/Targets.ts +162 -0
- package/src/internal/Token.ts +380 -0
- package/src/internal/Tuple.ts +29 -0
- package/src/internal/Typography.ts +51 -0
- package/src/internal/Value.ts +320 -0
- package/src/metro/Graph.ts +78 -0
- package/src/metro/Watch.ts +88 -0
- package/src/metro/index.ts +99 -0
- package/src/metro/transformer.ts +97 -0
- package/src/next/index.ts +114 -0
- package/src/next/loader.ts +369 -0
- package/src/node/Host.ts +1204 -0
- package/src/node/index.ts +6 -0
- package/src/react-native/Host.ts +289 -0
- package/src/react-native/StyleSheet.ts +1084 -0
- package/src/react-native/Variants.ts +122 -0
- package/src/react-native/index.ts +7 -0
- package/src/react-native/internal/Color.ts +110 -0
- package/src/react-native/internal/NativeSchema.ts +3096 -0
- package/src/react-native/internal/Scalar.ts +253 -0
- package/src/react-native/internal/Values.ts +87 -0
- package/src/react-native/react.ts +47 -0
- package/src/reset.css +244 -0
- package/src/runtime/Appearance.ts +155 -0
- package/src/runtime/Composition.ts +87 -0
- package/src/runtime/CompositionHtml.ts +38 -0
- package/src/runtime/ConditionalRecipe.ts +70 -0
- package/src/runtime/Dynamic.ts +51 -0
- package/src/runtime/Html.ts +91 -0
- package/src/runtime/Native.ts +144 -0
- package/src/runtime/NativeContext.ts +74 -0
- package/src/runtime/NativeDynamic.ts +246 -0
- package/src/runtime/PayloadRecipe.ts +96 -0
- package/src/runtime/Props.ts +33 -0
- package/src/runtime/Recipe.ts +74 -0
- package/src/runtime/Selection.ts +82 -0
- package/src/runtime/Variable.ts +15 -0
- package/src/runtime/index.ts +45 -0
- package/src/styleFunction.ts +138 -0
- package/src/themes/LICENSE.tailwind +21 -0
- package/src/variable.ts +105 -0
- package/src/variants.ts +218 -0
- package/src/vite/index.ts +1473 -0
- package/src/web/Css.ts +801 -0
- package/src/web/colorProfile.ts +60 -0
- package/src/web/counterStyle.ts +82 -0
- package/src/web/cssFunction.ts +181 -0
- package/src/web/customMedia.ts +16 -0
- package/src/web/fontFace.ts +41 -0
- package/src/web/fontFeatureValues.ts +79 -0
- package/src/web/fontPaletteValues.ts +42 -0
- package/src/web/global.ts +39 -0
- package/src/web/importCss.ts +23 -0
- package/src/web/index.ts +22 -0
- package/src/web/internal/Block.ts +29 -0
- package/src/web/internal/ClassName.ts +112 -0
- package/src/web/internal/Context.ts +16 -0
- package/src/web/internal/Contributions.ts +219 -0
- package/src/web/internal/Namespace.ts +21 -0
- package/src/web/internal/Themes.ts +133 -0
- package/src/web/keyframes.ts +43 -0
- package/src/web/layers.ts +6 -0
- package/src/web/namespace.ts +19 -0
- package/src/web/page.ts +140 -0
- package/src/web/positionTry.ts +71 -0
- package/src/web/property.ts +35 -0
- package/src/web/viewTransition.ts +89 -0
|
@@ -0,0 +1,1579 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts literal styles and local themes through lexical source analysis.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
import * as Identity from '../internal/Identity.js'
|
|
6
|
+
import * as Identifiers from './internal/Identifiers.js'
|
|
7
|
+
import type * as Ast from '@oxc-project/types'
|
|
8
|
+
import * as AtRules from './internal/AtRules.js'
|
|
9
|
+
import * as Binding from '../internal/Binding.js'
|
|
10
|
+
import * as Condition from '../internal/Condition.js'
|
|
11
|
+
import type * as Composition from '../runtime/Composition.js'
|
|
12
|
+
import * as Compositions from './internal/Compositions.js'
|
|
13
|
+
import * as Contributions from './internal/Contributions.js'
|
|
14
|
+
import * as Css from '../web/Css.js'
|
|
15
|
+
import * as Dynamic from './internal/Dynamic.js'
|
|
16
|
+
import * as Expression from './internal/Expression.js'
|
|
17
|
+
import * as Selectors from './internal/Selectors.js'
|
|
18
|
+
import type * as Namespace from '../web/internal/Namespace.js'
|
|
19
|
+
import * as Syntax from './internal/Syntax.js'
|
|
20
|
+
import * as RuleReference from '../internal/RuleReference.js'
|
|
21
|
+
import type * as Recipe from '../runtime/Recipe.js'
|
|
22
|
+
import type * as StaticRecipe from '../internal/Recipe.js'
|
|
23
|
+
import type * as RecipePayloads from './internal/RecipePayloads.js'
|
|
24
|
+
import * as Recipes from './internal/Recipes.js'
|
|
25
|
+
import * as PackedStyles from './internal/PackedStyles.js'
|
|
26
|
+
import * as Scope from './internal/Scope.js'
|
|
27
|
+
import type * as Shorthands from '../internal/Shorthands.js'
|
|
28
|
+
import * as Static from './internal/Static.js'
|
|
29
|
+
import * as Style from '../Style.js'
|
|
30
|
+
import type * as Theme from '../Theme.js'
|
|
31
|
+
import * as Themes from './internal/Themes.js'
|
|
32
|
+
import * as ThemeValues from '../web/internal/Themes.js'
|
|
33
|
+
import * as Token from '../internal/Token.js'
|
|
34
|
+
import * as Typography from '../internal/Typography.js'
|
|
35
|
+
import * as Value from '../internal/Value.js'
|
|
36
|
+
import * as Variables from './internal/Variables.js'
|
|
37
|
+
import * as Walker from 'oxc-walker'
|
|
38
|
+
|
|
39
|
+
// JavaScript extraction supplies untyped values. Keep structural checks without
|
|
40
|
+
// asserting that those values already satisfy the TypeScript authoring contract.
|
|
41
|
+
const define = Style.define as unknown as (
|
|
42
|
+
styles: Record<string, unknown>,
|
|
43
|
+
options: Style.define.Options,
|
|
44
|
+
) => Style.Definition
|
|
45
|
+
|
|
46
|
+
/** A direct definition call available for a later source rewriter. */
|
|
47
|
+
export type Call = {
|
|
48
|
+
/** Resolved native alternatives for this authoring contract. */
|
|
49
|
+
readonly nativeContext?:
|
|
50
|
+
| {
|
|
51
|
+
/** Default label selected when the provider omits its theme. */
|
|
52
|
+
readonly defaultTheme: string
|
|
53
|
+
/** Compatible alternatives from the owning configuration. */
|
|
54
|
+
readonly themes: Readonly<Record<string, Theme.Definition>>
|
|
55
|
+
}
|
|
56
|
+
| undefined
|
|
57
|
+
/** Class identity available without source rewriting. */
|
|
58
|
+
readonly portable?: string | undefined
|
|
59
|
+
/** Flattened definition identities for nested compositions. */
|
|
60
|
+
readonly portableInputs?: readonly string[] | undefined
|
|
61
|
+
/** Ownership retained by a separately compiled callable. */
|
|
62
|
+
readonly ownership?: Composition.Owner | undefined
|
|
63
|
+
/** CSS-only presence alternative for a runtime composition. */
|
|
64
|
+
readonly compositionCase?: boolean | undefined
|
|
65
|
+
/** Names of precompiled presence alternatives in bitmask order. */
|
|
66
|
+
readonly compositionCases?: readonly string[] | undefined
|
|
67
|
+
/** Fixed runtime applications over an already resolved CSS sequence. */
|
|
68
|
+
readonly runtimeComposition?:
|
|
69
|
+
| readonly {
|
|
70
|
+
/** Original resolved application start retained for selective HTML preparation. */
|
|
71
|
+
readonly applicationStart?: number | undefined
|
|
72
|
+
/** Presence bit for a conditional argument. */
|
|
73
|
+
readonly condition?: number | undefined
|
|
74
|
+
/** Application argument end. */
|
|
75
|
+
readonly end: number
|
|
76
|
+
/** Replaced generated class owner. */
|
|
77
|
+
readonly name: string
|
|
78
|
+
/** Attribute and private variable ownership. */
|
|
79
|
+
readonly owners: readonly Composition.Owner[]
|
|
80
|
+
/** Application argument start. */
|
|
81
|
+
readonly start: number
|
|
82
|
+
}[]
|
|
83
|
+
| undefined
|
|
84
|
+
/** Binding reads preserved by compile-time composition. */
|
|
85
|
+
readonly composition?: readonly string[] | undefined
|
|
86
|
+
/** Finite recipe selection metadata, with all alternatives retained in CSS. */
|
|
87
|
+
readonly recipe?: Recipe.Definition | undefined
|
|
88
|
+
/** Ordered dynamic alternatives retained with scalar binding references. */
|
|
89
|
+
readonly dynamicRecipe?: StaticRecipe.Definition | undefined
|
|
90
|
+
/** Ordered static alternatives retained without CSS selector lowering. */
|
|
91
|
+
readonly staticRecipe?: StaticRecipe.Definition | undefined
|
|
92
|
+
/** Typed payload signatures retained across transformed declarations. */
|
|
93
|
+
readonly recipeTypes?:
|
|
94
|
+
| { readonly [axis: string]: { readonly [choice: string]: string } }
|
|
95
|
+
| undefined
|
|
96
|
+
/** Stable selector identity retained independently of declaration deduplication. */
|
|
97
|
+
readonly identity?: string | undefined
|
|
98
|
+
/** Expanded immutable source data retained for declaration mapping. */
|
|
99
|
+
readonly body?: Ast.ObjectExpression | undefined
|
|
100
|
+
/** Alias targets retained for declaration source locations. */
|
|
101
|
+
readonly shorthands?: Shorthands.Map | undefined
|
|
102
|
+
/** Emitted typography field counts keyed by authored property offsets. */
|
|
103
|
+
readonly typography?: ReadonlyMap<number, number> | undefined
|
|
104
|
+
/** Native HTML attribute output selected by the bound configuration. */
|
|
105
|
+
readonly output?: 'html' | undefined
|
|
106
|
+
/** Typed runtime slots for callback definitions. */
|
|
107
|
+
readonly slots?: Dynamic.Slots | undefined
|
|
108
|
+
/** Authored scalar input type retained in packed declarations. */
|
|
109
|
+
readonly valuesType?: string | undefined
|
|
110
|
+
/** Exclusive UTF-16 offset of the complete call. */
|
|
111
|
+
readonly end: number
|
|
112
|
+
/** Matching name in the extracted style definition. */
|
|
113
|
+
readonly name: string
|
|
114
|
+
/** Inclusive UTF-16 offset of the complete call. */
|
|
115
|
+
readonly start: number
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** A source-owned extraction failure. */
|
|
119
|
+
export type Diagnostic = {
|
|
120
|
+
/** Stable failure category. */
|
|
121
|
+
readonly code:
|
|
122
|
+
| 'invalid_literal'
|
|
123
|
+
| 'invalid_module'
|
|
124
|
+
| 'syntax_error'
|
|
125
|
+
| 'unsupported_syntax'
|
|
126
|
+
/** Exclusive UTF-16 source offset. */
|
|
127
|
+
readonly end: number
|
|
128
|
+
/** Explanation of the supported input boundary. */
|
|
129
|
+
readonly message: string
|
|
130
|
+
/** Portable module identity supplied by the host. */
|
|
131
|
+
readonly source: string
|
|
132
|
+
/** Inclusive UTF-16 source offset. */
|
|
133
|
+
readonly start: number
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Extracts direct style calls and local Theme definitions imported from zyzz.
|
|
138
|
+
* Parses TypeScript and JSX without reading files, loading config, or evaluating source.
|
|
139
|
+
* @param options - Source text and a portable package-relative module identity.
|
|
140
|
+
* @returns Frozen style/theme definitions and rewrite spans. Source text is unchanged.
|
|
141
|
+
* @throws {ExtractError} For syntax errors, unsupported imported references, or invalid literals.
|
|
142
|
+
*/
|
|
143
|
+
export function extract(options: extract.Options): extract.ReturnType {
|
|
144
|
+
const calls: Call[] = []
|
|
145
|
+
const diagnostics: Diagnostic[] = []
|
|
146
|
+
const pending: Ast.CallExpression[] = []
|
|
147
|
+
const recipes = new Set<number>()
|
|
148
|
+
const styles: Style.NamedStyle[] = []
|
|
149
|
+
|
|
150
|
+
function report(
|
|
151
|
+
code: Diagnostic['code'],
|
|
152
|
+
message: string,
|
|
153
|
+
node?: Pick<Ast.Node, 'end' | 'start'>,
|
|
154
|
+
) {
|
|
155
|
+
diagnostics.push({
|
|
156
|
+
code,
|
|
157
|
+
end: node?.end ?? 0,
|
|
158
|
+
message,
|
|
159
|
+
source: options.moduleId,
|
|
160
|
+
start: node?.start ?? 0,
|
|
161
|
+
})
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (
|
|
165
|
+
!options.moduleId ||
|
|
166
|
+
options.moduleId.includes('\\') ||
|
|
167
|
+
options.moduleId.includes(':') ||
|
|
168
|
+
options.moduleId
|
|
169
|
+
.split('/')
|
|
170
|
+
.some((part) => !part || part === '.' || part === '..')
|
|
171
|
+
) {
|
|
172
|
+
report(
|
|
173
|
+
'invalid_module',
|
|
174
|
+
'Expected a portable package-relative module ID without absolute paths, backslashes, or traversal segments.',
|
|
175
|
+
)
|
|
176
|
+
throw new ExtractError(diagnostics)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const namespace = identity(options.moduleId)
|
|
180
|
+
const parsed = options[Themes.context]?.parsed ?? Syntax.parse(options)
|
|
181
|
+
|
|
182
|
+
if (parsed.errors.length) {
|
|
183
|
+
for (const error of parsed.errors) {
|
|
184
|
+
const span = error.labels[0]
|
|
185
|
+
|
|
186
|
+
report('syntax_error', error.message, span)
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
throw new ExtractError(diagnostics)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const program = parsed.program
|
|
193
|
+
const scopeTracker = new Scope.Tracker({ preserveExitedScopes: true })
|
|
194
|
+
|
|
195
|
+
Walker.walk(program, { scopeTracker })
|
|
196
|
+
scopeTracker.freeze()
|
|
197
|
+
|
|
198
|
+
const staticData = Static.create(
|
|
199
|
+
program,
|
|
200
|
+
scopeTracker,
|
|
201
|
+
options[Themes.context]?.constants,
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
const contributions = (() => {
|
|
205
|
+
try {
|
|
206
|
+
return Contributions.scan(
|
|
207
|
+
program,
|
|
208
|
+
scopeTracker,
|
|
209
|
+
namespace,
|
|
210
|
+
options[Themes.context]?.links,
|
|
211
|
+
options[Themes.context]?.factories,
|
|
212
|
+
)
|
|
213
|
+
} catch (error) {
|
|
214
|
+
if (!(error instanceof Themes.InvalidError)) throw error
|
|
215
|
+
|
|
216
|
+
report('unsupported_syntax', error.message, error)
|
|
217
|
+
throw new ExtractError(diagnostics)
|
|
218
|
+
}
|
|
219
|
+
})()
|
|
220
|
+
|
|
221
|
+
const variables = (() => {
|
|
222
|
+
try {
|
|
223
|
+
return Variables.collect(
|
|
224
|
+
program,
|
|
225
|
+
namespace,
|
|
226
|
+
scopeTracker,
|
|
227
|
+
options[Themes.context]?.links,
|
|
228
|
+
options.moduleId,
|
|
229
|
+
)
|
|
230
|
+
} catch (error) {
|
|
231
|
+
if (!(error instanceof Themes.InvalidError)) throw error
|
|
232
|
+
|
|
233
|
+
report('unsupported_syntax', error.message, error)
|
|
234
|
+
throw new ExtractError(diagnostics)
|
|
235
|
+
}
|
|
236
|
+
})()
|
|
237
|
+
|
|
238
|
+
const themes = (() => {
|
|
239
|
+
try {
|
|
240
|
+
return Themes.collect(program, {
|
|
241
|
+
staticBindings: staticData.bindings,
|
|
242
|
+
namespace,
|
|
243
|
+
contributionCalls: new Set(
|
|
244
|
+
contributions.calls.map((call) => call.start),
|
|
245
|
+
),
|
|
246
|
+
linked: options[Themes.context] !== undefined,
|
|
247
|
+
links: options[Themes.context]?.links,
|
|
248
|
+
})
|
|
249
|
+
} catch (error) {
|
|
250
|
+
if (!(error instanceof Themes.InvalidError)) throw error
|
|
251
|
+
|
|
252
|
+
report('unsupported_syntax', error.message, error)
|
|
253
|
+
throw new ExtractError(diagnostics)
|
|
254
|
+
}
|
|
255
|
+
})()
|
|
256
|
+
|
|
257
|
+
const ancestors: Ast.Node[] = []
|
|
258
|
+
const typeAncestors = new Set<Ast.Node>()
|
|
259
|
+
const typeNodes = new Set([
|
|
260
|
+
'TSInterfaceDeclaration',
|
|
261
|
+
'TSTypeAliasDeclaration',
|
|
262
|
+
'TSTypeAnnotation',
|
|
263
|
+
'TSTypeParameterDeclaration',
|
|
264
|
+
'TSTypeParameterInstantiation',
|
|
265
|
+
'TSTypeQuery',
|
|
266
|
+
])
|
|
267
|
+
|
|
268
|
+
Walker.walk(program, {
|
|
269
|
+
enter(node, parent) {
|
|
270
|
+
const declaration = staticData.visitor.enter(node, parent)
|
|
271
|
+
ancestors.push(node)
|
|
272
|
+
if (
|
|
273
|
+
(parent &&
|
|
274
|
+
'typeAnnotation' in parent &&
|
|
275
|
+
parent.typeAnnotation === node) ||
|
|
276
|
+
typeNodes.has(node.type) ||
|
|
277
|
+
(node.type === 'ExportNamedDeclaration' &&
|
|
278
|
+
(node.source !== null || node.exportKind === 'type')) ||
|
|
279
|
+
(node.type === 'ExportSpecifier' && node.exportKind === 'type')
|
|
280
|
+
)
|
|
281
|
+
typeAncestors.add(node)
|
|
282
|
+
|
|
283
|
+
if (
|
|
284
|
+
(node.type !== 'Identifier' && node.type !== 'JSXIdentifier') ||
|
|
285
|
+
!parent ||
|
|
286
|
+
(node.type === 'Identifier'
|
|
287
|
+
? declaration === undefined
|
|
288
|
+
: !Walker.isReferenceIdentifier(node, parent))
|
|
289
|
+
)
|
|
290
|
+
return
|
|
291
|
+
|
|
292
|
+
// Both passes visit identical scopes; skipping type subtrees changes scope IDs.
|
|
293
|
+
if (typeAncestors.size) return
|
|
294
|
+
|
|
295
|
+
const binding =
|
|
296
|
+
node.type === 'Identifier'
|
|
297
|
+
? declaration ?? null
|
|
298
|
+
: scopeTracker.getDeclaration(node.name)
|
|
299
|
+
|
|
300
|
+
contributions.read(node, parent, binding)
|
|
301
|
+
|
|
302
|
+
try {
|
|
303
|
+
if (variables.reference(node, parent, binding)) return
|
|
304
|
+
} catch (error) {
|
|
305
|
+
if (!(error instanceof Themes.InvalidError)) throw error
|
|
306
|
+
|
|
307
|
+
report('unsupported_syntax', error.message, error)
|
|
308
|
+
|
|
309
|
+
return
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
if (themes)
|
|
313
|
+
try {
|
|
314
|
+
if (themes.reference(node, parent, ancestors, binding)) return
|
|
315
|
+
} catch (error) {
|
|
316
|
+
if (!(error instanceof Themes.InvalidError)) throw error
|
|
317
|
+
|
|
318
|
+
report('unsupported_syntax', error.message, error)
|
|
319
|
+
|
|
320
|
+
return
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
if (
|
|
324
|
+
binding?.type !== 'Import' ||
|
|
325
|
+
binding.importNode.source.value !== 'zyzz' ||
|
|
326
|
+
binding.importNode.importKind === 'type'
|
|
327
|
+
)
|
|
328
|
+
return
|
|
329
|
+
|
|
330
|
+
const specifier = binding.node
|
|
331
|
+
|
|
332
|
+
if (specifier.type === 'ImportNamespaceSpecifier') {
|
|
333
|
+
if (parent.type === 'MemberExpression' && parent.object === node) {
|
|
334
|
+
const name = (() => {
|
|
335
|
+
if (parent.property.type === 'Identifier' && !parent.computed) {
|
|
336
|
+
return parent.property.name
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
if (parent.property.type === 'Literal') {
|
|
340
|
+
return parent.property.value
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
return undefined
|
|
344
|
+
})()
|
|
345
|
+
|
|
346
|
+
if (
|
|
347
|
+
name === 'Config' ||
|
|
348
|
+
name === 'cx' ||
|
|
349
|
+
name === 'style' ||
|
|
350
|
+
name === 'Theme' ||
|
|
351
|
+
name === 'variable' ||
|
|
352
|
+
name === 'variants'
|
|
353
|
+
)
|
|
354
|
+
report(
|
|
355
|
+
'unsupported_syntax',
|
|
356
|
+
`Import ${name} by name; namespace authoring calls are not supported yet.`,
|
|
357
|
+
parent,
|
|
358
|
+
)
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
return
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
if (
|
|
365
|
+
specifier.type !== 'ImportSpecifier' ||
|
|
366
|
+
specifier.importKind === 'type' ||
|
|
367
|
+
!['style', 'variants'].includes(
|
|
368
|
+
specifier.imported.type === 'Identifier'
|
|
369
|
+
? specifier.imported.name
|
|
370
|
+
: specifier.imported.value,
|
|
371
|
+
)
|
|
372
|
+
)
|
|
373
|
+
return
|
|
374
|
+
|
|
375
|
+
// Follow only assignment targets; computed keys and default values are reads.
|
|
376
|
+
let target: Ast.Node = node
|
|
377
|
+
let write: Ast.Node | undefined
|
|
378
|
+
|
|
379
|
+
for (let index = ancestors.length - 2; index >= 0; index--) {
|
|
380
|
+
const ancestor = ancestors[index]!
|
|
381
|
+
|
|
382
|
+
if (
|
|
383
|
+
(ancestor.type === 'AssignmentExpression' &&
|
|
384
|
+
ancestor.left === target) ||
|
|
385
|
+
(ancestor.type === 'UpdateExpression' &&
|
|
386
|
+
ancestor.argument === target) ||
|
|
387
|
+
((ancestor.type === 'ForInStatement' ||
|
|
388
|
+
ancestor.type === 'ForOfStatement') &&
|
|
389
|
+
ancestor.left === target)
|
|
390
|
+
) {
|
|
391
|
+
write = ancestor
|
|
392
|
+
break
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
if (
|
|
396
|
+
(ancestor.type === 'Property' && ancestor.value === target) ||
|
|
397
|
+
ancestor.type === 'ObjectPattern' ||
|
|
398
|
+
ancestor.type === 'ArrayPattern' ||
|
|
399
|
+
(ancestor.type === 'RestElement' && ancestor.argument === target) ||
|
|
400
|
+
(ancestor.type === 'AssignmentPattern' && ancestor.left === target)
|
|
401
|
+
)
|
|
402
|
+
target = ancestor
|
|
403
|
+
else break
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
if (write)
|
|
407
|
+
report(
|
|
408
|
+
'unsupported_syntax',
|
|
409
|
+
'Imported style bindings cannot be reassigned.',
|
|
410
|
+
write,
|
|
411
|
+
)
|
|
412
|
+
else if (
|
|
413
|
+
parent.type === 'CallExpression' &&
|
|
414
|
+
parent.callee === node &&
|
|
415
|
+
!parent.optional
|
|
416
|
+
) {
|
|
417
|
+
pending.push(parent)
|
|
418
|
+
if (
|
|
419
|
+
(specifier.imported.type === 'Identifier'
|
|
420
|
+
? specifier.imported.name
|
|
421
|
+
: specifier.imported.value) === 'variants'
|
|
422
|
+
)
|
|
423
|
+
recipes.add(parent.start)
|
|
424
|
+
} else
|
|
425
|
+
report(
|
|
426
|
+
'unsupported_syntax',
|
|
427
|
+
'Use a direct style call; aliases, re-exports, and indirect references are not supported yet.',
|
|
428
|
+
node,
|
|
429
|
+
)
|
|
430
|
+
},
|
|
431
|
+
leave(node) {
|
|
432
|
+
ancestors.pop()
|
|
433
|
+
typeAncestors.delete(node)
|
|
434
|
+
staticData.visitor.leave()
|
|
435
|
+
},
|
|
436
|
+
scopeTracker,
|
|
437
|
+
})
|
|
438
|
+
|
|
439
|
+
Contributions.resolve(contributions)
|
|
440
|
+
|
|
441
|
+
// Imports and reference lists can have a different order from authored calls.
|
|
442
|
+
if (themes)
|
|
443
|
+
for (const entry of themes.styles.values()) {
|
|
444
|
+
pending.push(entry.call)
|
|
445
|
+
if (entry.recipe) recipes.add(entry.call.start)
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
pending.sort((a, b) => a.start - b.start)
|
|
449
|
+
|
|
450
|
+
const staticCalls = new Set(pending.map((call) => call.start))
|
|
451
|
+
const opaque = new Set(variables.references.keys())
|
|
452
|
+
const normalized = new Map<number, Ast.Node | Error>()
|
|
453
|
+
const selectorKeys = new Set<number>()
|
|
454
|
+
for (const call of pending) {
|
|
455
|
+
if (!call.arguments[0]) continue
|
|
456
|
+
try {
|
|
457
|
+
const value = staticData.normalize(call.arguments[0], staticCalls, opaque)
|
|
458
|
+
normalized.set(call.start, value)
|
|
459
|
+
const body =
|
|
460
|
+
value.type === 'ArrowFunctionExpression'
|
|
461
|
+
? staticData.normalize(value.body, staticCalls, opaque)
|
|
462
|
+
: value
|
|
463
|
+
|
|
464
|
+
Walker.walk(body, {
|
|
465
|
+
enter(node) {
|
|
466
|
+
if (
|
|
467
|
+
node.type !== 'Property' ||
|
|
468
|
+
node.computed ||
|
|
469
|
+
node.value.type !== 'ObjectExpression' ||
|
|
470
|
+
!(
|
|
471
|
+
(node.key.type === 'Identifier' &&
|
|
472
|
+
node.key.name === 'selectors') ||
|
|
473
|
+
(node.key.type === 'Literal' && node.key.value === 'selectors')
|
|
474
|
+
)
|
|
475
|
+
)
|
|
476
|
+
return
|
|
477
|
+
|
|
478
|
+
for (const property of node.value.properties)
|
|
479
|
+
if (property.type === 'Property')
|
|
480
|
+
selectorKeys.add(property.key.start)
|
|
481
|
+
},
|
|
482
|
+
})
|
|
483
|
+
} catch (error) {
|
|
484
|
+
if (!(error instanceof Themes.InvalidError)) throw error
|
|
485
|
+
normalized.set(call.start, error)
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
for (const call of pending) {
|
|
490
|
+
try {
|
|
491
|
+
Identifiers.explicit(call)
|
|
492
|
+
} catch (error) {
|
|
493
|
+
report('unsupported_syntax', (error as Error).message, call)
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
if (diagnostics.length) throw new ExtractError(diagnostics)
|
|
497
|
+
|
|
498
|
+
const selectors = (() => {
|
|
499
|
+
try {
|
|
500
|
+
return Selectors.scan(
|
|
501
|
+
program,
|
|
502
|
+
scopeTracker,
|
|
503
|
+
namespace,
|
|
504
|
+
pending,
|
|
505
|
+
options[Themes.context]?.links,
|
|
506
|
+
selectorKeys,
|
|
507
|
+
)
|
|
508
|
+
} catch (error) {
|
|
509
|
+
if (!(error instanceof Themes.InvalidError)) throw error
|
|
510
|
+
|
|
511
|
+
report('unsupported_syntax', error.message, error)
|
|
512
|
+
throw new ExtractError(diagnostics)
|
|
513
|
+
}
|
|
514
|
+
})()
|
|
515
|
+
|
|
516
|
+
for (const call of pending) {
|
|
517
|
+
const explicitId = (() => {
|
|
518
|
+
try {
|
|
519
|
+
return Identifiers.explicit(call)
|
|
520
|
+
} catch (error) {
|
|
521
|
+
report('unsupported_syntax', (error as Error).message, call)
|
|
522
|
+
return undefined
|
|
523
|
+
}
|
|
524
|
+
})()
|
|
525
|
+
const definitionId =
|
|
526
|
+
explicitId === undefined
|
|
527
|
+
? `${namespace}-${call.start}`
|
|
528
|
+
: Identity.requireId(explicitId, 'style')
|
|
529
|
+
let argument = call.arguments[0]
|
|
530
|
+
|
|
531
|
+
if (call.arguments.length === 0)
|
|
532
|
+
argument = {
|
|
533
|
+
end: call.end - 1,
|
|
534
|
+
properties: [],
|
|
535
|
+
start: call.end - 1,
|
|
536
|
+
type: 'ObjectExpression',
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
while (
|
|
540
|
+
argument?.type === 'TSAsExpression' ||
|
|
541
|
+
argument?.type === 'TSSatisfiesExpression'
|
|
542
|
+
)
|
|
543
|
+
argument = argument.expression
|
|
544
|
+
|
|
545
|
+
const original = argument
|
|
546
|
+
|
|
547
|
+
try {
|
|
548
|
+
const value = normalized.get(call.start)
|
|
549
|
+
if (value instanceof Error) throw value
|
|
550
|
+
if (value) argument = value as Ast.Expression
|
|
551
|
+
} catch (error) {
|
|
552
|
+
if (!(error instanceof Themes.InvalidError)) throw error
|
|
553
|
+
|
|
554
|
+
report('unsupported_syntax', error.message, error)
|
|
555
|
+
continue
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
const diagnosticCount = diagnostics.length
|
|
559
|
+
|
|
560
|
+
const dynamic = (() => {
|
|
561
|
+
if (!argument) return undefined
|
|
562
|
+
|
|
563
|
+
try {
|
|
564
|
+
return Dynamic.read(argument, definitionId, staticData.type)
|
|
565
|
+
} catch (error) {
|
|
566
|
+
if (!(error instanceof Themes.InvalidError)) throw error
|
|
567
|
+
|
|
568
|
+
report('unsupported_syntax', error.message, error)
|
|
569
|
+
|
|
570
|
+
return undefined
|
|
571
|
+
}
|
|
572
|
+
})()
|
|
573
|
+
if (diagnostics.length !== diagnosticCount) continue
|
|
574
|
+
|
|
575
|
+
let dynamicValues: RecipePayloads.Bindings | undefined = dynamic
|
|
576
|
+
|
|
577
|
+
function resolveDynamic(node: Ast.Node) {
|
|
578
|
+
try {
|
|
579
|
+
return dynamicValues?.resolve(node)
|
|
580
|
+
} catch (error) {
|
|
581
|
+
if (!(error instanceof Themes.InvalidError)) throw error
|
|
582
|
+
|
|
583
|
+
report('unsupported_syntax', error.message, error)
|
|
584
|
+
|
|
585
|
+
return undefined
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
if (dynamic) {
|
|
590
|
+
try {
|
|
591
|
+
argument = staticData.normalize(
|
|
592
|
+
dynamic.body,
|
|
593
|
+
staticCalls,
|
|
594
|
+
opaque,
|
|
595
|
+
) as Ast.Expression
|
|
596
|
+
} catch (error) {
|
|
597
|
+
if (!(error instanceof Themes.InvalidError)) throw error
|
|
598
|
+
|
|
599
|
+
report('unsupported_syntax', error.message, error)
|
|
600
|
+
continue
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
if (call.arguments.length > 2 || argument?.type !== 'ObjectExpression') {
|
|
605
|
+
report(
|
|
606
|
+
'unsupported_syntax',
|
|
607
|
+
'Expected one literal object or typed callback; spreads and referenced definitions are not supported.',
|
|
608
|
+
call,
|
|
609
|
+
)
|
|
610
|
+
continue
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
const before = diagnostics.length
|
|
614
|
+
let recipe: Recipe.Definition | undefined
|
|
615
|
+
let recipeTypes: Call['recipeTypes']
|
|
616
|
+
let staticRecipe: StaticRecipe.Definition<Ast.ObjectExpression> | undefined
|
|
617
|
+
let dynamicRecipe: StaticRecipe.Definition<Ast.ObjectExpression> | undefined
|
|
618
|
+
if (recipes.has(call.start)) {
|
|
619
|
+
try {
|
|
620
|
+
if (dynamic)
|
|
621
|
+
throw new Themes.InvalidError(
|
|
622
|
+
'Recipes require static top-level objects.',
|
|
623
|
+
original ?? call,
|
|
624
|
+
)
|
|
625
|
+
const expanded = Recipes.expand(argument, {
|
|
626
|
+
identity: definitionId,
|
|
627
|
+
normalize: (node) => staticData.normalize(node, staticCalls, opaque),
|
|
628
|
+
queries: themes?.styles.get(call.start)?.theme[Token.definition]
|
|
629
|
+
.queries,
|
|
630
|
+
resolveType: staticData.type,
|
|
631
|
+
source: options.source,
|
|
632
|
+
})
|
|
633
|
+
argument = expanded.body
|
|
634
|
+
recipe = expanded.recipe
|
|
635
|
+
staticRecipe = expanded.staticRecipe
|
|
636
|
+
dynamicRecipe = expanded.dynamicRecipe
|
|
637
|
+
recipeTypes = expanded.types
|
|
638
|
+
dynamicValues = expanded.bindings
|
|
639
|
+
} catch (error) {
|
|
640
|
+
if (!(error instanceof Themes.InvalidError)) throw error
|
|
641
|
+
report('unsupported_syntax', error.message, error)
|
|
642
|
+
continue
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
const name = `style-${namespace}-${call.start}`
|
|
646
|
+
const locations: Style.SourceLocation[] = []
|
|
647
|
+
const typography = new Map<number, number>()
|
|
648
|
+
const conditionKeys = new Map<string, Ast.Node>()
|
|
649
|
+
|
|
650
|
+
function object(
|
|
651
|
+
argument: Ast.ObjectExpression,
|
|
652
|
+
prefix: readonly string[] = [],
|
|
653
|
+
): Record<string, unknown> {
|
|
654
|
+
const values: Record<string, unknown> = Object.create(null)
|
|
655
|
+
const target = prefix.lastIndexOf('targets')
|
|
656
|
+
if (target !== -1 && prefix.length > 64) {
|
|
657
|
+
report(
|
|
658
|
+
'unsupported_syntax',
|
|
659
|
+
'Target nesting exceeds 64 levels.',
|
|
660
|
+
argument,
|
|
661
|
+
)
|
|
662
|
+
return values
|
|
663
|
+
}
|
|
664
|
+
const depth = prefix.length + 2
|
|
665
|
+
|
|
666
|
+
function localSlot(node: Ast.Node) {
|
|
667
|
+
const slot = resolveDynamic(node)
|
|
668
|
+
|
|
669
|
+
if (
|
|
670
|
+
slot &&
|
|
671
|
+
prefix.some(
|
|
672
|
+
(key) =>
|
|
673
|
+
!Condition.local(key) && !selectors.localConditions.has(key),
|
|
674
|
+
)
|
|
675
|
+
) {
|
|
676
|
+
report(
|
|
677
|
+
'unsupported_syntax',
|
|
678
|
+
'Dynamic values require conditions that select the styled element.',
|
|
679
|
+
node,
|
|
680
|
+
)
|
|
681
|
+
|
|
682
|
+
return undefined
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
return slot
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
const properties: Ast.ObjectExpression['properties'] = []
|
|
689
|
+
for (const entry of argument.properties) {
|
|
690
|
+
const key =
|
|
691
|
+
entry.type === 'Property' && !entry.computed
|
|
692
|
+
? entry.key.type === 'Identifier'
|
|
693
|
+
? entry.key.name
|
|
694
|
+
: entry.key.type === 'Literal'
|
|
695
|
+
? entry.key.value
|
|
696
|
+
: undefined
|
|
697
|
+
: undefined
|
|
698
|
+
if (key !== 'selectors' && key !== 'variables') {
|
|
699
|
+
properties.push(entry)
|
|
700
|
+
continue
|
|
701
|
+
}
|
|
702
|
+
if (
|
|
703
|
+
entry.type !== 'Property' ||
|
|
704
|
+
entry.kind !== 'init' ||
|
|
705
|
+
entry.method ||
|
|
706
|
+
entry.shorthand ||
|
|
707
|
+
entry.value.type !== 'ObjectExpression'
|
|
708
|
+
) {
|
|
709
|
+
report(
|
|
710
|
+
'unsupported_syntax',
|
|
711
|
+
`${key} requires an explicit literal object.`,
|
|
712
|
+
entry,
|
|
713
|
+
)
|
|
714
|
+
continue
|
|
715
|
+
}
|
|
716
|
+
for (const property of entry.value.properties) {
|
|
717
|
+
if (
|
|
718
|
+
property.type !== 'Property' ||
|
|
719
|
+
(key === 'selectors'
|
|
720
|
+
? !selectors.conditions.has(property.key.start)
|
|
721
|
+
: !property.computed ||
|
|
722
|
+
!variables.references.has(property.key.start))
|
|
723
|
+
) {
|
|
724
|
+
report(
|
|
725
|
+
'unsupported_syntax',
|
|
726
|
+
key === 'selectors'
|
|
727
|
+
? 'Selectors require explicit & targets.'
|
|
728
|
+
: 'Variable assignments require declared variable keys.',
|
|
729
|
+
property,
|
|
730
|
+
)
|
|
731
|
+
continue
|
|
732
|
+
}
|
|
733
|
+
properties.push(property)
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
for (const property of properties) {
|
|
738
|
+
if (
|
|
739
|
+
property.type !== 'Property' ||
|
|
740
|
+
property.kind !== 'init' ||
|
|
741
|
+
property.method ||
|
|
742
|
+
(property.computed &&
|
|
743
|
+
!selectors.conditions.has(property.key.start) &&
|
|
744
|
+
!variables.references.has(property.key.start) &&
|
|
745
|
+
!contributions.queryKeys.has(property.key.start)) ||
|
|
746
|
+
property.shorthand ||
|
|
747
|
+
(!selectors.conditions.has(property.key.start) &&
|
|
748
|
+
!variables.references.has(property.key.start) &&
|
|
749
|
+
property.key.type !== 'Identifier' &&
|
|
750
|
+
(property.key.type !== 'Literal' ||
|
|
751
|
+
typeof property.key.value !== 'string'))
|
|
752
|
+
) {
|
|
753
|
+
report(
|
|
754
|
+
'unsupported_syntax',
|
|
755
|
+
'Only explicit literal properties are supported; spreads, computed keys, shorthand, and methods are not evaluated.',
|
|
756
|
+
property,
|
|
757
|
+
)
|
|
758
|
+
continue
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
const key =
|
|
762
|
+
variables.references.get(property.key.start)?.reference.name ??
|
|
763
|
+
selectors.conditions.get(property.key.start) ??
|
|
764
|
+
contributions.queryKeys.get(property.key.start) ??
|
|
765
|
+
(property.key.type === 'Identifier'
|
|
766
|
+
? property.key.name
|
|
767
|
+
: property.key.type === 'Literal'
|
|
768
|
+
? String(property.key.value)
|
|
769
|
+
: '')
|
|
770
|
+
|
|
771
|
+
if (Object.hasOwn(values, key)) {
|
|
772
|
+
report(
|
|
773
|
+
'unsupported_syntax',
|
|
774
|
+
'Duplicate properties are not supported in source definitions yet.',
|
|
775
|
+
property,
|
|
776
|
+
)
|
|
777
|
+
continue
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
if (
|
|
781
|
+
(key === 'targets' || target !== -1) &&
|
|
782
|
+
staticData.absent(property.value)
|
|
783
|
+
)
|
|
784
|
+
continue
|
|
785
|
+
|
|
786
|
+
if (key === 'targets' || prefix.at(-1) === 'targets') {
|
|
787
|
+
const input = Expression.unwrap(property.value)
|
|
788
|
+
if (input.type !== 'ObjectExpression') {
|
|
789
|
+
report(
|
|
790
|
+
'unsupported_syntax',
|
|
791
|
+
'Target branches require static declaration objects.',
|
|
792
|
+
input,
|
|
793
|
+
)
|
|
794
|
+
continue
|
|
795
|
+
}
|
|
796
|
+
values[key] = object(input, [...prefix, key])
|
|
797
|
+
continue
|
|
798
|
+
}
|
|
799
|
+
if (target !== -1 && prefix[target + 1] !== 'web') {
|
|
800
|
+
function nativeValue(input: Ast.Node, depth = 0): unknown {
|
|
801
|
+
const node = Expression.unwrap(input)
|
|
802
|
+
if (depth > 64) {
|
|
803
|
+
report(
|
|
804
|
+
'unsupported_syntax',
|
|
805
|
+
'Native value nesting exceeds 64 levels.',
|
|
806
|
+
node,
|
|
807
|
+
)
|
|
808
|
+
return undefined
|
|
809
|
+
}
|
|
810
|
+
if (node.type === 'ObjectExpression')
|
|
811
|
+
return object(node, [...prefix, key])
|
|
812
|
+
if (node.type === 'ArrayExpression')
|
|
813
|
+
return node.elements.map((entry) => {
|
|
814
|
+
if (!entry || entry.type === 'SpreadElement') {
|
|
815
|
+
report(
|
|
816
|
+
'unsupported_syntax',
|
|
817
|
+
'Native arrays require dense static entries.',
|
|
818
|
+
node,
|
|
819
|
+
)
|
|
820
|
+
return undefined
|
|
821
|
+
}
|
|
822
|
+
return nativeValue(entry, depth + 1)
|
|
823
|
+
})
|
|
824
|
+
if (
|
|
825
|
+
node.type === 'Literal' &&
|
|
826
|
+
(node.value === null ||
|
|
827
|
+
['boolean', 'number', 'string'].includes(typeof node.value))
|
|
828
|
+
)
|
|
829
|
+
return node.value
|
|
830
|
+
if (
|
|
831
|
+
node.type === 'UnaryExpression' &&
|
|
832
|
+
['+', '-'].includes(node.operator) &&
|
|
833
|
+
node.argument.type === 'Literal' &&
|
|
834
|
+
typeof node.argument.value === 'number'
|
|
835
|
+
)
|
|
836
|
+
return (node.operator === '-' ? -1 : 1) * node.argument.value
|
|
837
|
+
if (node.type === 'TemplateLiteral') {
|
|
838
|
+
const value = Expression.template(node)
|
|
839
|
+
if (typeof value === 'string') return value
|
|
840
|
+
}
|
|
841
|
+
report(
|
|
842
|
+
'unsupported_syntax',
|
|
843
|
+
'Native branches require static literal values.',
|
|
844
|
+
node,
|
|
845
|
+
)
|
|
846
|
+
return undefined
|
|
847
|
+
}
|
|
848
|
+
values[key] = nativeValue(property.value)
|
|
849
|
+
continue
|
|
850
|
+
}
|
|
851
|
+
if (Condition.is(key)) {
|
|
852
|
+
conditionKeys.set(
|
|
853
|
+
JSON.stringify([name, ...prefix, key]),
|
|
854
|
+
property.key,
|
|
855
|
+
)
|
|
856
|
+
|
|
857
|
+
const input = Expression.unwrap(property.value)
|
|
858
|
+
|
|
859
|
+
if (input.type !== 'ObjectExpression') {
|
|
860
|
+
report(
|
|
861
|
+
'unsupported_syntax',
|
|
862
|
+
'Conditions require literal declaration objects.',
|
|
863
|
+
input,
|
|
864
|
+
)
|
|
865
|
+
continue
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
locations.push({
|
|
869
|
+
source: options.moduleId,
|
|
870
|
+
start: property.start,
|
|
871
|
+
end: property.end,
|
|
872
|
+
path: [name, ...prefix, key],
|
|
873
|
+
})
|
|
874
|
+
values[key] = object(input, [...prefix, key])
|
|
875
|
+
continue
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
const targets = themes?.styles.get(call.start)?.theme[Token.definition]
|
|
879
|
+
.contract.shorthands?.[key] ?? [key as Style.Declaration['property']]
|
|
880
|
+
|
|
881
|
+
function value(node: Ast.Node, path: readonly string[]): unknown {
|
|
882
|
+
const unwrapped = Expression.unwrap(node)
|
|
883
|
+
const token =
|
|
884
|
+
variables.references.get(unwrapped.start) ??
|
|
885
|
+
themes?.tokens.get(unwrapped.start)
|
|
886
|
+
const reference =
|
|
887
|
+
localSlot(node) ??
|
|
888
|
+
(token && token.end === unwrapped.end ? token.reference : undefined)
|
|
889
|
+
|
|
890
|
+
if (
|
|
891
|
+
dynamicValues &&
|
|
892
|
+
reference &&
|
|
893
|
+
Object.values(dynamicValues.slots).includes(
|
|
894
|
+
reference as Binding.Reference,
|
|
895
|
+
) &&
|
|
896
|
+
path.length > depth
|
|
897
|
+
) {
|
|
898
|
+
report(
|
|
899
|
+
'unsupported_syntax',
|
|
900
|
+
'Dynamic fallback entries are not supported.',
|
|
901
|
+
node,
|
|
902
|
+
)
|
|
903
|
+
|
|
904
|
+
return undefined
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
node = Expression.unwrap(node)
|
|
908
|
+
|
|
909
|
+
const animation = contributions.references.get(node.start)
|
|
910
|
+
if (animation) {
|
|
911
|
+
const kind = contributions.kinds.get(animation)
|
|
912
|
+
if (
|
|
913
|
+
kind &&
|
|
914
|
+
targets.some((target) => !RuleReference.accepts(kind, target))
|
|
915
|
+
) {
|
|
916
|
+
report(
|
|
917
|
+
'unsupported_syntax',
|
|
918
|
+
'Named stylesheet reference is incompatible with this property.',
|
|
919
|
+
node,
|
|
920
|
+
)
|
|
921
|
+
return undefined
|
|
922
|
+
}
|
|
923
|
+
return animation
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
const template =
|
|
927
|
+
node.type === 'TemplateLiteral'
|
|
928
|
+
? Expression.template(node, 0, (expression, prefix) => {
|
|
929
|
+
const animation = contributions.references.get(
|
|
930
|
+
Expression.unwrap(expression).start,
|
|
931
|
+
)
|
|
932
|
+
if (animation) {
|
|
933
|
+
const kind = contributions.kinds.get(animation)
|
|
934
|
+
if (
|
|
935
|
+
kind &&
|
|
936
|
+
targets.some(
|
|
937
|
+
(target) =>
|
|
938
|
+
!RuleReference.acceptsExpression(
|
|
939
|
+
kind,
|
|
940
|
+
target,
|
|
941
|
+
prefix,
|
|
942
|
+
),
|
|
943
|
+
)
|
|
944
|
+
) {
|
|
945
|
+
report(
|
|
946
|
+
'unsupported_syntax',
|
|
947
|
+
'Named stylesheet reference is incompatible with this property.',
|
|
948
|
+
expression,
|
|
949
|
+
)
|
|
950
|
+
return undefined
|
|
951
|
+
}
|
|
952
|
+
return animation
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
const token =
|
|
956
|
+
variables.references.get(expression.start) ??
|
|
957
|
+
themes?.tokens.get(expression.start)
|
|
958
|
+
const slot = localSlot(expression)
|
|
959
|
+
|
|
960
|
+
if (slot) {
|
|
961
|
+
if (path.length > depth) {
|
|
962
|
+
report(
|
|
963
|
+
'unsupported_syntax',
|
|
964
|
+
'Dynamic fallback entries are not supported.',
|
|
965
|
+
expression,
|
|
966
|
+
)
|
|
967
|
+
|
|
968
|
+
return undefined
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
return slot
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
return token?.end === expression.end
|
|
975
|
+
? token.reference
|
|
976
|
+
: undefined
|
|
977
|
+
})
|
|
978
|
+
: undefined
|
|
979
|
+
|
|
980
|
+
if (Token.isExpression(template)) {
|
|
981
|
+
for (const part of template.parts) {
|
|
982
|
+
if (
|
|
983
|
+
typeof part !== 'string' &&
|
|
984
|
+
!(Binding.is(part)
|
|
985
|
+
? (dynamicValues !== undefined &&
|
|
986
|
+
Object.values(dynamicValues.slots).includes(part)) ||
|
|
987
|
+
targets.every((target) =>
|
|
988
|
+
Binding.accepts(part.type, target),
|
|
989
|
+
)
|
|
990
|
+
: targets.every((target) =>
|
|
991
|
+
Token.accepts(part.group, target),
|
|
992
|
+
))
|
|
993
|
+
) {
|
|
994
|
+
report(
|
|
995
|
+
'unsupported_syntax',
|
|
996
|
+
Binding.is(part)
|
|
997
|
+
? 'Variable domain is incompatible with this property.'
|
|
998
|
+
: 'Theme variable domain is incompatible with this property.',
|
|
999
|
+
node,
|
|
1000
|
+
)
|
|
1001
|
+
|
|
1002
|
+
return undefined
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
if (
|
|
1008
|
+
reference &&
|
|
1009
|
+
Token.is(reference) &&
|
|
1010
|
+
!targets.every((target) =>
|
|
1011
|
+
Token.accepts(reference.group, target),
|
|
1012
|
+
) &&
|
|
1013
|
+
!targets.every((target) =>
|
|
1014
|
+
dynamicValues?.accepts(
|
|
1015
|
+
reference as unknown as Binding.Reference,
|
|
1016
|
+
target,
|
|
1017
|
+
),
|
|
1018
|
+
)
|
|
1019
|
+
) {
|
|
1020
|
+
report(
|
|
1021
|
+
'unsupported_syntax',
|
|
1022
|
+
'Theme variable domain is incompatible with this property.',
|
|
1023
|
+
node,
|
|
1024
|
+
)
|
|
1025
|
+
|
|
1026
|
+
return undefined
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
if (
|
|
1030
|
+
reference &&
|
|
1031
|
+
Binding.is(reference) &&
|
|
1032
|
+
!(
|
|
1033
|
+
dynamicValues &&
|
|
1034
|
+
Object.values(dynamicValues.slots).includes(reference) &&
|
|
1035
|
+
reference.type !== 'number'
|
|
1036
|
+
) &&
|
|
1037
|
+
!targets.every(
|
|
1038
|
+
(target) =>
|
|
1039
|
+
Binding.accepts(reference.type, target) ||
|
|
1040
|
+
dynamicValues?.accepts(
|
|
1041
|
+
reference as unknown as Binding.Reference,
|
|
1042
|
+
target,
|
|
1043
|
+
),
|
|
1044
|
+
)
|
|
1045
|
+
) {
|
|
1046
|
+
report(
|
|
1047
|
+
'unsupported_syntax',
|
|
1048
|
+
'Variable domain is incompatible with this property.',
|
|
1049
|
+
node,
|
|
1050
|
+
)
|
|
1051
|
+
|
|
1052
|
+
return undefined
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
let result: unknown
|
|
1056
|
+
|
|
1057
|
+
if (reference) result = reference
|
|
1058
|
+
else if (template !== undefined) result = template
|
|
1059
|
+
else if (
|
|
1060
|
+
node.type === 'Literal' &&
|
|
1061
|
+
(typeof node.value === 'string' || typeof node.value === 'number')
|
|
1062
|
+
)
|
|
1063
|
+
result = node.value
|
|
1064
|
+
else if (
|
|
1065
|
+
node.type === 'UnaryExpression' &&
|
|
1066
|
+
(node.operator === '-' || node.operator === '+') &&
|
|
1067
|
+
node.argument.type === 'Literal' &&
|
|
1068
|
+
typeof node.argument.value === 'number'
|
|
1069
|
+
)
|
|
1070
|
+
result =
|
|
1071
|
+
node.operator === '-' ? -node.argument.value : node.argument.value
|
|
1072
|
+
else if (node.type === 'ArrayExpression' && path.length === depth) {
|
|
1073
|
+
result = node.elements.map((element, index) => {
|
|
1074
|
+
if (!element || element.type === 'SpreadElement') {
|
|
1075
|
+
report(
|
|
1076
|
+
'unsupported_syntax',
|
|
1077
|
+
'Fallback arrays require dense literal entries without spreads.',
|
|
1078
|
+
element ?? node,
|
|
1079
|
+
)
|
|
1080
|
+
|
|
1081
|
+
return undefined
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
return value(element, [...path, String(index)])
|
|
1085
|
+
})
|
|
1086
|
+
} else {
|
|
1087
|
+
report(
|
|
1088
|
+
'unsupported_syntax',
|
|
1089
|
+
'Expected a literal string or number; expressions are not evaluated.',
|
|
1090
|
+
node,
|
|
1091
|
+
)
|
|
1092
|
+
|
|
1093
|
+
return undefined
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
locations.push({
|
|
1097
|
+
end: node.end,
|
|
1098
|
+
path,
|
|
1099
|
+
source: options.moduleId,
|
|
1100
|
+
start: node.start,
|
|
1101
|
+
})
|
|
1102
|
+
|
|
1103
|
+
return result
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
values[key] = value(property.value, [name, ...prefix, key])
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
if (typeof values.typography === 'string') {
|
|
1110
|
+
const theme = themes?.styles.get(call.start)?.theme
|
|
1111
|
+
const mappings = theme?.[Token.definition].contract.shorthands
|
|
1112
|
+
const explicit = new Set(
|
|
1113
|
+
Object.keys(values).flatMap((key) => mappings?.[key] ?? [key]),
|
|
1114
|
+
)
|
|
1115
|
+
const parsed = Value.parse(values.typography, 'fontFamily')
|
|
1116
|
+
const count = Typography.fields(
|
|
1117
|
+
theme,
|
|
1118
|
+
parsed && !('invalid' in parsed) ? parsed.value : values.typography,
|
|
1119
|
+
).filter((field) => !explicit.has(field)).length
|
|
1120
|
+
for (const property of properties) {
|
|
1121
|
+
if (property.type !== 'Property') continue
|
|
1122
|
+
const key =
|
|
1123
|
+
property.key.type === 'Identifier'
|
|
1124
|
+
? property.key.name
|
|
1125
|
+
: property.key.type === 'Literal'
|
|
1126
|
+
? property.key.value
|
|
1127
|
+
: undefined
|
|
1128
|
+
if (key === 'typography') typography.set(property.start, count)
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
return values
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
const values = object(argument)
|
|
1136
|
+
if (diagnostics.length !== before) continue
|
|
1137
|
+
|
|
1138
|
+
try {
|
|
1139
|
+
const definition = define(
|
|
1140
|
+
{ [name]: values },
|
|
1141
|
+
{ locations, theme: themes?.styles.get(call.start)?.theme },
|
|
1142
|
+
)
|
|
1143
|
+
|
|
1144
|
+
function validate(style: Style.NamedStyle, path: readonly string[]) {
|
|
1145
|
+
if (style.targets?.web)
|
|
1146
|
+
validate(style.targets.web, [...path, 'targets', 'web'])
|
|
1147
|
+
for (const rule of style.rules ?? []) {
|
|
1148
|
+
if (rule.condition !== undefined) {
|
|
1149
|
+
const location =
|
|
1150
|
+
conditionKeys.get(JSON.stringify([...path, rule.condition])) ??
|
|
1151
|
+
call
|
|
1152
|
+
|
|
1153
|
+
try {
|
|
1154
|
+
AtRules.transform({
|
|
1155
|
+
filename: options.moduleId,
|
|
1156
|
+
code: Buffer.from(`.z{${rule.condition}{color:red;}}`),
|
|
1157
|
+
errorRecovery: false,
|
|
1158
|
+
})
|
|
1159
|
+
} catch (error) {
|
|
1160
|
+
report(
|
|
1161
|
+
'unsupported_syntax',
|
|
1162
|
+
`Invalid selector or condition: ${(error as Error).message}`,
|
|
1163
|
+
location,
|
|
1164
|
+
)
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
validate(
|
|
1169
|
+
rule.style,
|
|
1170
|
+
rule.condition === undefined ? path : [...path, rule.condition],
|
|
1171
|
+
)
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
for (const style of definition.styles) validate(style, [style.name])
|
|
1176
|
+
|
|
1177
|
+
if (diagnostics.length !== before) continue
|
|
1178
|
+
|
|
1179
|
+
const cssOutput = themes?.styles.get(call.start)?.theme[Token.definition]
|
|
1180
|
+
.contract.cssOutput
|
|
1181
|
+
styles.push(
|
|
1182
|
+
...definition.styles.map((style) =>
|
|
1183
|
+
cssOutput ? Object.freeze({ ...style, cssOutput }) : style,
|
|
1184
|
+
),
|
|
1185
|
+
)
|
|
1186
|
+
|
|
1187
|
+
const shorthands = themes?.styles.get(call.start)?.theme[Token.definition]
|
|
1188
|
+
.contract.shorthands
|
|
1189
|
+
|
|
1190
|
+
const retained = staticRecipe ?? dynamicRecipe
|
|
1191
|
+
const targetRecipe = retained && {
|
|
1192
|
+
...retained,
|
|
1193
|
+
rules: retained.rules.map(({ matches, value }, index) => ({
|
|
1194
|
+
matches,
|
|
1195
|
+
value: define(
|
|
1196
|
+
{ [`${name}-${index}`]: object(value) },
|
|
1197
|
+
{ locations, theme: themes?.styles.get(call.start)?.theme },
|
|
1198
|
+
),
|
|
1199
|
+
})),
|
|
1200
|
+
}
|
|
1201
|
+
calls.push({
|
|
1202
|
+
...(recipe ? { recipe, recipeTypes } : {}),
|
|
1203
|
+
...(staticRecipe
|
|
1204
|
+
? { staticRecipe: targetRecipe }
|
|
1205
|
+
: dynamicRecipe
|
|
1206
|
+
? { dynamicRecipe: targetRecipe }
|
|
1207
|
+
: {}),
|
|
1208
|
+
...(selectors.identities.has(call.start)
|
|
1209
|
+
? { identity: selectors.identities.get(call.start)! }
|
|
1210
|
+
: {}),
|
|
1211
|
+
...(argument !== (dynamic?.body ?? original) &&
|
|
1212
|
+
argument.type === 'ObjectExpression'
|
|
1213
|
+
? { body: argument }
|
|
1214
|
+
: {}),
|
|
1215
|
+
...(shorthands ? { shorthands } : {}),
|
|
1216
|
+
...(typography.size ? { typography } : {}),
|
|
1217
|
+
...(themes?.styles.get(call.start)?.output
|
|
1218
|
+
? { output: 'html' as const }
|
|
1219
|
+
: {}),
|
|
1220
|
+
...(dynamic
|
|
1221
|
+
? {
|
|
1222
|
+
slots: dynamic.slots,
|
|
1223
|
+
valuesType: options.source.slice(
|
|
1224
|
+
dynamic.type.start,
|
|
1225
|
+
dynamic.type.end,
|
|
1226
|
+
),
|
|
1227
|
+
}
|
|
1228
|
+
: {}),
|
|
1229
|
+
...(options.compiler === false
|
|
1230
|
+
? {
|
|
1231
|
+
portable: (() => {
|
|
1232
|
+
if (explicitId !== undefined) return `z-style-${definitionId}`
|
|
1233
|
+
if (
|
|
1234
|
+
dynamic ||
|
|
1235
|
+
recipe ||
|
|
1236
|
+
(!definition.styles[0]!.declarations.length &&
|
|
1237
|
+
!definition.styles[0]!.rules &&
|
|
1238
|
+
!definition.styles[0]!.targets)
|
|
1239
|
+
)
|
|
1240
|
+
return undefined
|
|
1241
|
+
return Identity.style(definition.styles[0]!)
|
|
1242
|
+
})(),
|
|
1243
|
+
}
|
|
1244
|
+
: {}),
|
|
1245
|
+
end: call.end,
|
|
1246
|
+
name,
|
|
1247
|
+
start: call.start,
|
|
1248
|
+
})
|
|
1249
|
+
} catch (error) {
|
|
1250
|
+
if (!(error instanceof Style.InvalidError)) throw error
|
|
1251
|
+
|
|
1252
|
+
for (const diagnostic of error.diagnostics)
|
|
1253
|
+
diagnostics.push({
|
|
1254
|
+
code: 'invalid_literal',
|
|
1255
|
+
end: diagnostic.location?.end ?? call.end,
|
|
1256
|
+
message: diagnostic.message,
|
|
1257
|
+
source: options.moduleId,
|
|
1258
|
+
start: diagnostic.location?.start ?? call.start,
|
|
1259
|
+
})
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
try {
|
|
1264
|
+
for (const entry of options.target === 'native'
|
|
1265
|
+
? []
|
|
1266
|
+
: Compositions.collect({
|
|
1267
|
+
calls,
|
|
1268
|
+
identity: namespace,
|
|
1269
|
+
links: options[Themes.context]?.links,
|
|
1270
|
+
program,
|
|
1271
|
+
source: options.source,
|
|
1272
|
+
styles,
|
|
1273
|
+
})) {
|
|
1274
|
+
calls.push(...(entry.cases ?? []).map((entry) => entry.call), entry.call)
|
|
1275
|
+
styles.push(
|
|
1276
|
+
...(entry.cases ?? []).map((entry) => entry.style),
|
|
1277
|
+
entry.style,
|
|
1278
|
+
)
|
|
1279
|
+
}
|
|
1280
|
+
} catch (error) {
|
|
1281
|
+
if (!(error instanceof Themes.InvalidError)) throw error
|
|
1282
|
+
report('unsupported_syntax', error.message, error)
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
if (themes && !diagnostics.length)
|
|
1286
|
+
for (const [start, token] of themes.tokens) {
|
|
1287
|
+
if (
|
|
1288
|
+
!staticData.used.has(start) &&
|
|
1289
|
+
!themes.staticTokens.some((node) => node.start === start) &&
|
|
1290
|
+
![...calls, ...contributions.calls].some(
|
|
1291
|
+
(call) => start >= call.start && token.end <= call.end,
|
|
1292
|
+
)
|
|
1293
|
+
)
|
|
1294
|
+
report(
|
|
1295
|
+
'unsupported_syntax',
|
|
1296
|
+
'Theme references require a compiled style declaration.',
|
|
1297
|
+
{ start, end: token.end },
|
|
1298
|
+
)
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
let contributionData: readonly Css.Contribution[] = []
|
|
1302
|
+
const contributionStarts = [...variables.registrationStarts]
|
|
1303
|
+
|
|
1304
|
+
try {
|
|
1305
|
+
for (const [index, registration] of variables.registrations.entries()) {
|
|
1306
|
+
try {
|
|
1307
|
+
const css = Css.compile({
|
|
1308
|
+
styles: { styles: [] },
|
|
1309
|
+
contributions: [registration],
|
|
1310
|
+
}).css
|
|
1311
|
+
AtRules.transform({
|
|
1312
|
+
filename: options.moduleId,
|
|
1313
|
+
code: new TextEncoder().encode(css),
|
|
1314
|
+
errorRecovery: false,
|
|
1315
|
+
})
|
|
1316
|
+
} catch (error) {
|
|
1317
|
+
throw new Themes.InvalidError(
|
|
1318
|
+
(error as Error).message,
|
|
1319
|
+
variables.registrationLocations[index]!,
|
|
1320
|
+
)
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
contributionData = [
|
|
1325
|
+
...variables.registrations,
|
|
1326
|
+
...Contributions.extract(
|
|
1327
|
+
contributions,
|
|
1328
|
+
themes?.tokens ?? new Map(),
|
|
1329
|
+
contributionStarts,
|
|
1330
|
+
),
|
|
1331
|
+
...(themes?.calls ?? []).flatMap((call) =>
|
|
1332
|
+
call.options?.layers
|
|
1333
|
+
? [
|
|
1334
|
+
{
|
|
1335
|
+
kind: 'layers' as const,
|
|
1336
|
+
names: call.options.layers as readonly string[],
|
|
1337
|
+
},
|
|
1338
|
+
]
|
|
1339
|
+
: [],
|
|
1340
|
+
),
|
|
1341
|
+
]
|
|
1342
|
+
|
|
1343
|
+
if (contributionData.length) {
|
|
1344
|
+
const rendered = Css.compile({
|
|
1345
|
+
styles: { styles: [] },
|
|
1346
|
+
contributions: contributionData,
|
|
1347
|
+
themes: themes?.themes,
|
|
1348
|
+
}).css
|
|
1349
|
+
AtRules.transform({
|
|
1350
|
+
filename: options.moduleId,
|
|
1351
|
+
code: new TextEncoder().encode(rendered),
|
|
1352
|
+
errorRecovery: false,
|
|
1353
|
+
...(!options[Themes.context]
|
|
1354
|
+
? {
|
|
1355
|
+
visitor: {
|
|
1356
|
+
Rule(rule) {
|
|
1357
|
+
if (
|
|
1358
|
+
rule.type === 'import' &&
|
|
1359
|
+
rule.value.url &&
|
|
1360
|
+
!/^(?:\/|[?#]|[a-z][a-z\d+.-]*:)/i.test(rule.value.url)
|
|
1361
|
+
)
|
|
1362
|
+
throw new Error(
|
|
1363
|
+
'Relative contribution assets require Graph.compile and a relocation host.',
|
|
1364
|
+
)
|
|
1365
|
+
},
|
|
1366
|
+
Url(url) {
|
|
1367
|
+
if (
|
|
1368
|
+
url.url &&
|
|
1369
|
+
!/^(?:\/|[?#]|[a-z][a-z\d+.-]*:)/i.test(url.url)
|
|
1370
|
+
)
|
|
1371
|
+
throw new Error(
|
|
1372
|
+
'Relative contribution assets require Graph.compile and a relocation host.',
|
|
1373
|
+
)
|
|
1374
|
+
},
|
|
1375
|
+
},
|
|
1376
|
+
}
|
|
1377
|
+
: {}),
|
|
1378
|
+
})
|
|
1379
|
+
}
|
|
1380
|
+
} catch (error) {
|
|
1381
|
+
report(
|
|
1382
|
+
'unsupported_syntax',
|
|
1383
|
+
(error as Error).message,
|
|
1384
|
+
error instanceof Themes.InvalidError ? error : contributions.calls[0],
|
|
1385
|
+
)
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
for (const token of themes?.staticTokens ?? [])
|
|
1389
|
+
if (!staticData.used.has(Expression.unwrap(token).start))
|
|
1390
|
+
report(
|
|
1391
|
+
'unsupported_syntax',
|
|
1392
|
+
'Token references must be direct property values in bound theme style calls.',
|
|
1393
|
+
token,
|
|
1394
|
+
)
|
|
1395
|
+
|
|
1396
|
+
if (diagnostics.length) throw new ExtractError(diagnostics)
|
|
1397
|
+
|
|
1398
|
+
function exportedStyle(link: Themes.Link): Themes.Link {
|
|
1399
|
+
const call = calls.find((call) => call.identity === link.binding)
|
|
1400
|
+
const style = call && styles.find((style) => style.name === call.name)
|
|
1401
|
+
return {
|
|
1402
|
+
...link,
|
|
1403
|
+
...(call && style ? { style: PackedStyles.create(call, style) } : {}),
|
|
1404
|
+
...(link.members
|
|
1405
|
+
? {
|
|
1406
|
+
members: Object.fromEntries(
|
|
1407
|
+
Object.entries(link.members).map(([name, member]) => [
|
|
1408
|
+
name,
|
|
1409
|
+
exportedStyle(member),
|
|
1410
|
+
]),
|
|
1411
|
+
),
|
|
1412
|
+
}
|
|
1413
|
+
: {}),
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
return Object.freeze({
|
|
1418
|
+
namespaces: contributionData.filter(
|
|
1419
|
+
(value): value is Extract<Css.Contribution, { kind: 'namespace' }> =>
|
|
1420
|
+
value.kind === 'namespace',
|
|
1421
|
+
),
|
|
1422
|
+
...(contributionData.length
|
|
1423
|
+
? { contributions: contributionData, contributionStarts }
|
|
1424
|
+
: {}),
|
|
1425
|
+
...(contributions.calls.length
|
|
1426
|
+
? { contributionCalls: contributions.calls }
|
|
1427
|
+
: {}),
|
|
1428
|
+
...(options[Themes.context]
|
|
1429
|
+
? {
|
|
1430
|
+
themeExports: Object.freeze({
|
|
1431
|
+
...themes?.exports,
|
|
1432
|
+
...Object.fromEntries(
|
|
1433
|
+
Object.entries(selectors.exports).map(([name, link]) => [
|
|
1434
|
+
name,
|
|
1435
|
+
exportedStyle(link),
|
|
1436
|
+
]),
|
|
1437
|
+
),
|
|
1438
|
+
...contributions.exports,
|
|
1439
|
+
...variables.exports,
|
|
1440
|
+
}),
|
|
1441
|
+
}
|
|
1442
|
+
: {}),
|
|
1443
|
+
calls: Object.freeze(
|
|
1444
|
+
calls
|
|
1445
|
+
.sort((a, b) => a.start - b.start)
|
|
1446
|
+
.map((call) => {
|
|
1447
|
+
const nativeContext =
|
|
1448
|
+
options.target === 'native'
|
|
1449
|
+
? themes?.nativeContext(call.start, call.end)
|
|
1450
|
+
: undefined
|
|
1451
|
+
return Object.freeze(
|
|
1452
|
+
nativeContext ? { ...call, nativeContext } : call,
|
|
1453
|
+
)
|
|
1454
|
+
}),
|
|
1455
|
+
),
|
|
1456
|
+
styles: Object.freeze({ styles: Object.freeze(styles) }),
|
|
1457
|
+
...(variables.calls.length
|
|
1458
|
+
? { variableCalls: Object.freeze(variables.calls) }
|
|
1459
|
+
: {}),
|
|
1460
|
+
themeAliases: Object.freeze(themes?.aliases ?? []),
|
|
1461
|
+
...(themes?.appearances.size
|
|
1462
|
+
? { themeAppearances: Object.freeze([...themes.appearances]) }
|
|
1463
|
+
: {}),
|
|
1464
|
+
...(themes?.scripts.size
|
|
1465
|
+
? { themeScripts: Object.freeze([...themes.scripts]) }
|
|
1466
|
+
: {}),
|
|
1467
|
+
...(themes?.selections.size
|
|
1468
|
+
? { themeSelections: Object.freeze([...themes.selections]) }
|
|
1469
|
+
: {}),
|
|
1470
|
+
themeCalls: Object.freeze(themes?.calls ?? []),
|
|
1471
|
+
...(themes?.staticTokens.length
|
|
1472
|
+
? {
|
|
1473
|
+
staticThemeReferences: Object.freeze(
|
|
1474
|
+
(themes?.staticTokens ?? []).map((node) => ({
|
|
1475
|
+
start: node.start,
|
|
1476
|
+
end: node.end,
|
|
1477
|
+
value: ThemeValues.create().serialize(
|
|
1478
|
+
themes!.tokens.get(node.start)!.reference,
|
|
1479
|
+
),
|
|
1480
|
+
})),
|
|
1481
|
+
),
|
|
1482
|
+
}
|
|
1483
|
+
: {}),
|
|
1484
|
+
themeReferences: Object.freeze(themes?.references ?? []),
|
|
1485
|
+
themes: themes?.themes ?? Object.freeze({}),
|
|
1486
|
+
})
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
/** Input and output of source extraction. */
|
|
1490
|
+
export declare namespace extract {
|
|
1491
|
+
/** Structured source failure. */
|
|
1492
|
+
type ErrorType = ExtractError
|
|
1493
|
+
|
|
1494
|
+
/** Source text supplied by an adapter. */
|
|
1495
|
+
type Options = {
|
|
1496
|
+
/** Native extraction retains applications for native props composition. */
|
|
1497
|
+
readonly target?: 'native' | 'web' | undefined
|
|
1498
|
+
/** Collect portable runtime identities when source rewriting is disabled. */
|
|
1499
|
+
readonly compiler?: boolean | undefined
|
|
1500
|
+
/** Portable identity including package and module path; no filesystem access occurs. */
|
|
1501
|
+
readonly moduleId: string
|
|
1502
|
+
/** Compiler-owned graph context. */
|
|
1503
|
+
readonly [Themes.context]?: Themes.Context | undefined
|
|
1504
|
+
/** Complete module text, parsed as TypeScript with JSX. */
|
|
1505
|
+
readonly source: string
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1508
|
+
/** Ordered public compiler input and spans for later rewriting. */
|
|
1509
|
+
type ReturnType = {
|
|
1510
|
+
/** Module-owned namespace bindings retained when contributions are shared. */
|
|
1511
|
+
readonly namespaces?: readonly Namespace.Definition[] | undefined
|
|
1512
|
+
/** Static stylesheet effects and their source replacements. */
|
|
1513
|
+
readonly contributionStarts?: readonly number[] | undefined
|
|
1514
|
+
readonly contributions?: readonly Css.Contribution[] | undefined
|
|
1515
|
+
readonly contributionCalls?: readonly Contributions.Call[] | undefined
|
|
1516
|
+
/** Explicit variable contracts replaced by fixed slot data. */
|
|
1517
|
+
readonly variableCalls?: readonly Variables.Call[] | undefined
|
|
1518
|
+
/** Direct calls in source order. */
|
|
1519
|
+
readonly calls: readonly Call[]
|
|
1520
|
+
/** Validated definitions accepted by Css.compile. */
|
|
1521
|
+
readonly styles: Style.Definition
|
|
1522
|
+
/** Local bound-authoring initializers and their retained token types. */
|
|
1523
|
+
readonly themeAliases: readonly Themes.Alias[]
|
|
1524
|
+
/** Configuration identities retaining their root controls. */
|
|
1525
|
+
readonly themeAppearances?: readonly string[] | undefined
|
|
1526
|
+
/** Configuration identities retaining their initialization helper. */
|
|
1527
|
+
readonly themeScripts?: readonly string[] | undefined
|
|
1528
|
+
/** Configuration identities whose theme selector is called, passed, or bound. */
|
|
1529
|
+
readonly themeSelections?: readonly string[] | undefined
|
|
1530
|
+
/** Local factory spans replaced by compiled scope data. */
|
|
1531
|
+
readonly themeCalls: readonly Themes.Call[]
|
|
1532
|
+
/** Scope reads replaced by class constants. */
|
|
1533
|
+
readonly staticThemeReferences?:
|
|
1534
|
+
| readonly {
|
|
1535
|
+
readonly start: number
|
|
1536
|
+
readonly end: number
|
|
1537
|
+
readonly value: string
|
|
1538
|
+
}[]
|
|
1539
|
+
| undefined
|
|
1540
|
+
readonly themeReferences: readonly Themes.Reference[]
|
|
1541
|
+
/** Resolved authoring exports when extracted as part of a source graph. */
|
|
1542
|
+
readonly themeExports?: Readonly<Record<string, Themes.Link>> | undefined
|
|
1543
|
+
/** Stable scope keys and validated local theme definitions. */
|
|
1544
|
+
readonly themes: Readonly<Record<string, Theme.Definition>>
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
/** Aggregated source diagnostics; no partial result is returned. */
|
|
1549
|
+
export class ExtractError extends Error {
|
|
1550
|
+
/** Freezes source diagnostics in source order. */
|
|
1551
|
+
constructor(diagnostics: readonly Diagnostic[]) {
|
|
1552
|
+
const ordered = [...diagnostics].sort((a, b) => a.start - b.start)
|
|
1553
|
+
|
|
1554
|
+
super(
|
|
1555
|
+
ordered
|
|
1556
|
+
.map((item) => `${item.source}:${item.start}: ${item.message}`)
|
|
1557
|
+
.join('\n'),
|
|
1558
|
+
)
|
|
1559
|
+
this.diagnostics = Object.freeze(
|
|
1560
|
+
ordered.map((item) => Object.freeze({ ...item })),
|
|
1561
|
+
)
|
|
1562
|
+
}
|
|
1563
|
+
/** Immutable source failures. */
|
|
1564
|
+
readonly diagnostics: readonly Diagnostic[]
|
|
1565
|
+
/** Stable namespaced error identifier. */
|
|
1566
|
+
override name = 'Source.ExtractError'
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
function identity(value: string): string {
|
|
1570
|
+
let first = 2166136261
|
|
1571
|
+
let second = 2246822507
|
|
1572
|
+
|
|
1573
|
+
for (let index = 0; index < value.length; index++) {
|
|
1574
|
+
first = Math.imul(first ^ value.charCodeAt(index), 16777619)
|
|
1575
|
+
second = Math.imul(second ^ value.charCodeAt(index), 3266489909)
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
return `${(first >>> 0).toString(36)}${(second >>> 0).toString(36)}`
|
|
1579
|
+
}
|