@tamagui/web 3.0.0-beta.831.1 → 3.0.0-beta.889.1
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/dist/cjs/createComponent.cjs +12 -1
- package/dist/cjs/createComponent.native.cjs +12 -1
- package/dist/cjs/createComponent.native.js +12 -1
- package/dist/cjs/createComponent.native.js.map +1 -1
- package/dist/cjs/createStyledHOC.cjs +1 -1
- package/dist/cjs/createStyledHOC.native.cjs +1 -1
- package/dist/cjs/createStyledHOC.native.js +1 -1
- package/dist/cjs/createStyledHOC.native.js.map +1 -1
- package/dist/cjs/createVariable.cjs +0 -10
- package/dist/cjs/createVariable.native.cjs +0 -10
- package/dist/cjs/createVariable.native.js +0 -10
- package/dist/cjs/createVariable.native.js.map +1 -1
- package/dist/cjs/helpers/borderComponents.cjs +62 -0
- package/dist/cjs/helpers/borderComponents.native.cjs +82 -0
- package/dist/cjs/helpers/borderComponents.native.js +84 -0
- package/dist/cjs/helpers/borderComponents.native.js.map +1 -0
- package/dist/cjs/helpers/createDesignSystem.cjs +0 -2
- package/dist/cjs/helpers/createStyledContext.cjs +10 -18
- package/dist/cjs/helpers/createStyledContext.native.cjs +14 -18
- package/dist/cjs/helpers/createStyledContext.native.js +14 -18
- package/dist/cjs/helpers/createStyledContext.native.js.map +1 -1
- package/dist/cjs/helpers/formatDiagnostic.cjs +6 -6
- package/dist/cjs/helpers/formatDiagnostic.native.cjs +6 -6
- package/dist/cjs/helpers/formatDiagnostic.native.js +6 -6
- package/dist/cjs/helpers/formatDiagnostic.native.js.map +1 -1
- package/dist/cjs/helpers/getCSSStylesAtomic.cjs +128 -109
- package/dist/cjs/helpers/getCSSStylesAtomic.native.cjs +11 -3
- package/dist/cjs/helpers/getCSSStylesAtomic.native.js +11 -3
- package/dist/cjs/helpers/getCSSStylesAtomic.native.js.map +1 -1
- package/dist/cjs/helpers/getCSSStylesAtomicCompiled.cjs +13 -1
- package/dist/cjs/helpers/getCSSStylesAtomicCompiled.native.cjs +15 -1
- package/dist/cjs/helpers/getCSSStylesAtomicCompiled.native.js +15 -1
- package/dist/cjs/helpers/getCSSStylesAtomicCompiled.native.js.map +1 -1
- package/dist/cjs/helpers/getDynamicVal.cjs +5 -1
- package/dist/cjs/helpers/getDynamicVal.native.cjs +5 -1
- package/dist/cjs/helpers/getDynamicVal.native.js +5 -1
- package/dist/cjs/helpers/getDynamicVal.native.js.map +1 -1
- package/dist/cjs/helpers/getSplitStyles.cjs +1042 -1715
- package/dist/cjs/helpers/getSplitStyles.native.cjs +1081 -1887
- package/dist/cjs/helpers/getSplitStyles.native.js +1081 -1887
- package/dist/cjs/helpers/getSplitStyles.native.js.map +1 -1
- package/dist/cjs/helpers/grammarConfig.cjs +163 -1
- package/dist/cjs/helpers/grammarConfig.native.cjs +186 -1
- package/dist/cjs/helpers/grammarConfig.native.js +186 -1
- package/dist/cjs/helpers/grammarConfig.native.js.map +1 -1
- package/dist/cjs/helpers/insertStyleRule.cjs +5 -1
- package/dist/cjs/helpers/insertStyleRule.native.cjs +7 -1
- package/dist/cjs/helpers/insertStyleRule.native.js +7 -1
- package/dist/cjs/helpers/insertStyleRule.native.js.map +1 -1
- package/dist/cjs/helpers/log.cjs +9 -8
- package/dist/cjs/helpers/log.native.cjs +9 -8
- package/dist/cjs/helpers/log.native.js +9 -8
- package/dist/cjs/helpers/log.native.js.map +1 -1
- package/dist/cjs/helpers/mergeVariants.cjs +44 -13
- package/dist/cjs/helpers/mergeVariants.native.cjs +79 -14
- package/dist/cjs/helpers/mergeVariants.native.js +79 -14
- package/dist/cjs/helpers/mergeVariants.native.js.map +1 -1
- package/dist/cjs/helpers/nativeOnlyProps.cjs +0 -1
- package/dist/cjs/helpers/nativeOnlyProps.native.cjs +0 -1
- package/dist/cjs/helpers/nativeOnlyProps.native.js +0 -1
- package/dist/cjs/helpers/nativeOnlyProps.native.js.map +1 -1
- package/dist/cjs/helpers/nativeStyleEngine.cjs +34 -14
- package/dist/cjs/helpers/nativeStyleEngine.native.cjs +36 -14
- package/dist/cjs/helpers/nativeStyleEngine.native.js +36 -14
- package/dist/cjs/helpers/nativeStyleEngine.native.js.map +1 -1
- package/dist/cjs/helpers/normalizeValueWithProperty.cjs +7 -8
- package/dist/cjs/helpers/normalizeValueWithProperty.native.cjs +9 -8
- package/dist/cjs/helpers/normalizeValueWithProperty.native.js +9 -8
- package/dist/cjs/helpers/normalizeValueWithProperty.native.js.map +1 -1
- package/dist/cjs/helpers/parseBorderShorthand.native.cjs +25 -56
- package/dist/cjs/helpers/parseBorderShorthand.native.js +25 -56
- package/dist/cjs/helpers/parseBorderShorthand.native.js.map +1 -1
- package/dist/cjs/helpers/parseOutlineShorthand.native.cjs +9 -49
- package/dist/cjs/helpers/parseOutlineShorthand.native.js +9 -49
- package/dist/cjs/helpers/parseOutlineShorthand.native.js.map +1 -1
- package/dist/cjs/helpers/resolveSafeArea.cjs +35 -100
- package/dist/cjs/helpers/resolveVariantStyle.cjs +57 -0
- package/dist/cjs/helpers/resolveVariantStyle.native.cjs +67 -0
- package/dist/cjs/helpers/resolveVariantStyle.native.js +69 -0
- package/dist/cjs/helpers/resolveVariantStyle.native.js.map +1 -0
- package/dist/cjs/helpers/styleStaticConfig.cjs +1 -50
- package/dist/cjs/helpers/styleStaticConfig.native.cjs +1 -51
- package/dist/cjs/helpers/styleStaticConfig.native.js +1 -51
- package/dist/cjs/helpers/styleStaticConfig.native.js.map +1 -1
- package/dist/cjs/helpers/styleStaticConfigCore.cjs +107 -0
- package/dist/cjs/helpers/styleStaticConfigCore.native.cjs +127 -0
- package/dist/cjs/helpers/styleStaticConfigCore.native.js +129 -0
- package/dist/cjs/helpers/styleStaticConfigCore.native.js.map +1 -0
- package/dist/cjs/helpers/styledDynamic.cjs +160 -0
- package/dist/cjs/helpers/styledDynamic.native.cjs +195 -0
- package/dist/cjs/helpers/styledDynamic.native.js +197 -0
- package/dist/cjs/helpers/styledDynamic.native.js.map +1 -0
- package/dist/cjs/helpers/tokenCategories.cjs +15 -38
- package/dist/cjs/helpers/tokenCategories.native.cjs +15 -40
- package/dist/cjs/helpers/tokenCategories.native.js +15 -40
- package/dist/cjs/helpers/tokenCategories.native.js.map +1 -1
- package/dist/cjs/helpers/variableValue.cjs +17 -12
- package/dist/cjs/helpers/variableValue.native.cjs +46 -23
- package/dist/cjs/helpers/variableValue.native.js +46 -23
- package/dist/cjs/helpers/variableValue.native.js.map +1 -1
- package/dist/cjs/helpers/warnOnce.cjs +5 -4
- package/dist/cjs/helpers/warnOnce.native.cjs +6 -4
- package/dist/cjs/helpers/warnOnce.native.js +6 -4
- package/dist/cjs/helpers/warnOnce.native.js.map +1 -1
- package/dist/cjs/hooks/useAnimationDriver.cjs +2 -2
- package/dist/cjs/hooks/useAnimationDriver.native.cjs +2 -2
- package/dist/cjs/hooks/useAnimationDriver.native.js +2 -2
- package/dist/cjs/hooks/useAnimationDriver.native.js.map +1 -1
- package/dist/cjs/hooks/useComponentState.cjs +41 -82
- package/dist/cjs/hooks/useComponentState.native.cjs +45 -84
- package/dist/cjs/hooks/useComponentState.native.js +45 -84
- package/dist/cjs/hooks/useComponentState.native.js.map +1 -1
- package/dist/cjs/hooks/useMedia.cjs +2 -2
- package/dist/cjs/hooks/useMedia.native.cjs +2 -2
- package/dist/cjs/hooks/useMedia.native.js +2 -2
- package/dist/cjs/hooks/useMedia.native.js.map +1 -1
- package/dist/cjs/{helpers/directStyleCSS.native.js → hooks/useStyle.cjs} +16 -8
- package/dist/cjs/{helpers/directStyleCSS.native.cjs → hooks/useStyle.native.cjs} +16 -4
- package/dist/cjs/hooks/useStyle.native.js +34 -0
- package/dist/cjs/hooks/useStyle.native.js.map +1 -0
- package/dist/cjs/hooks/useThemeState.cjs +25 -90
- package/dist/cjs/hooks/useThemeState.native.cjs +34 -94
- package/dist/cjs/hooks/useThemeState.native.js +34 -94
- package/dist/cjs/hooks/useThemeState.native.js.map +1 -1
- package/dist/cjs/index.cjs +6 -3
- package/dist/cjs/index.native.cjs +6 -3
- package/dist/cjs/index.native.js +6 -3
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/static-resolve.cjs +2 -2
- package/dist/cjs/static-resolve.native.cjs +2 -2
- package/dist/cjs/static-resolve.native.js +2 -2
- package/dist/cjs/static-resolve.native.js.map +1 -1
- package/dist/cjs/style.cjs +91 -0
- package/dist/cjs/style.native.cjs +98 -0
- package/dist/cjs/style.native.js +100 -0
- package/dist/cjs/style.native.js.map +1 -0
- package/dist/cjs/styled.cjs +11 -6
- package/dist/cjs/styled.native.cjs +11 -6
- package/dist/cjs/styled.native.js +11 -6
- package/dist/cjs/styled.native.js.map +1 -1
- package/dist/cjs/types.cjs +6 -4
- package/dist/cjs/types.native.cjs +6 -4
- package/dist/cjs/types.native.js +6 -4
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/cjs/views/TamaguiProvider.cjs +1 -2
- package/dist/cjs/views/TamaguiProvider.native.cjs +1 -2
- package/dist/cjs/views/TamaguiProvider.native.js +1 -2
- package/dist/cjs/views/TamaguiProvider.native.js.map +1 -1
- package/dist/cjs/views/Text.cjs +17 -12
- package/dist/cjs/views/Text.native.cjs +1 -0
- package/dist/cjs/views/Text.native.js +1 -0
- package/dist/cjs/views/Text.native.js.map +1 -1
- package/dist/cjs/views/Theme.cjs +3 -3
- package/dist/cjs/views/Theme.native.cjs +3 -3
- package/dist/cjs/views/Theme.native.js +3 -3
- package/dist/cjs/views/Theme.native.js.map +1 -1
- package/dist/cjs/views/ThemeDebug.cjs +1 -4
- package/dist/esm/createComponent.mjs +12 -1
- package/dist/esm/createComponent.mjs.map +1 -1
- package/dist/esm/createComponent.native.js +12 -1
- package/dist/esm/createComponent.native.js.map +1 -1
- package/dist/esm/createStyledHOC.mjs +1 -1
- package/dist/esm/createStyledHOC.mjs.map +1 -1
- package/dist/esm/createStyledHOC.native.js +1 -1
- package/dist/esm/createStyledHOC.native.js.map +1 -1
- package/dist/esm/createVariable.mjs +1 -9
- package/dist/esm/createVariable.mjs.map +1 -1
- package/dist/esm/createVariable.native.js +1 -9
- package/dist/esm/createVariable.native.js.map +1 -1
- package/dist/esm/helpers/borderComponents.mjs +37 -0
- package/dist/esm/helpers/borderComponents.mjs.map +1 -0
- package/dist/esm/helpers/borderComponents.native.js +55 -0
- package/dist/esm/helpers/borderComponents.native.js.map +1 -0
- package/dist/esm/helpers/createDesignSystem.mjs +0 -2
- package/dist/esm/helpers/createDesignSystem.mjs.map +1 -1
- package/dist/esm/helpers/createStyledContext.mjs +10 -18
- package/dist/esm/helpers/createStyledContext.mjs.map +1 -1
- package/dist/esm/helpers/createStyledContext.native.js +14 -18
- package/dist/esm/helpers/createStyledContext.native.js.map +1 -1
- package/dist/esm/helpers/formatDiagnostic.mjs +6 -6
- package/dist/esm/helpers/formatDiagnostic.mjs.map +1 -1
- package/dist/esm/helpers/formatDiagnostic.native.js +6 -6
- package/dist/esm/helpers/formatDiagnostic.native.js.map +1 -1
- package/dist/esm/helpers/getCSSStylesAtomic.mjs +126 -109
- package/dist/esm/helpers/getCSSStylesAtomic.mjs.map +1 -1
- package/dist/esm/helpers/getCSSStylesAtomic.native.js +7 -4
- package/dist/esm/helpers/getCSSStylesAtomic.native.js.map +1 -1
- package/dist/esm/helpers/getCSSStylesAtomicCompiled.mjs +8 -1
- package/dist/esm/helpers/getCSSStylesAtomicCompiled.mjs.map +1 -1
- package/dist/esm/helpers/getCSSStylesAtomicCompiled.native.js +10 -1
- package/dist/esm/helpers/getCSSStylesAtomicCompiled.native.js.map +1 -1
- package/dist/esm/helpers/getDynamicVal.mjs +5 -1
- package/dist/esm/helpers/getDynamicVal.mjs.map +1 -1
- package/dist/esm/helpers/getDynamicVal.native.js +5 -1
- package/dist/esm/helpers/getDynamicVal.native.js.map +1 -1
- package/dist/esm/helpers/getSplitStyles.mjs +1034 -1705
- package/dist/esm/helpers/getSplitStyles.mjs.map +1 -1
- package/dist/esm/helpers/getSplitStyles.native.js +1071 -1871
- package/dist/esm/helpers/getSplitStyles.native.js.map +1 -1
- package/dist/esm/helpers/grammarConfig.mjs +164 -2
- package/dist/esm/helpers/grammarConfig.mjs.map +1 -1
- package/dist/esm/helpers/grammarConfig.native.js +187 -2
- package/dist/esm/helpers/grammarConfig.native.js.map +1 -1
- package/dist/esm/helpers/insertStyleRule.mjs +5 -2
- package/dist/esm/helpers/insertStyleRule.mjs.map +1 -1
- package/dist/esm/helpers/insertStyleRule.native.js +7 -2
- package/dist/esm/helpers/insertStyleRule.native.js.map +1 -1
- package/dist/esm/helpers/log.mjs +9 -8
- package/dist/esm/helpers/log.mjs.map +1 -1
- package/dist/esm/helpers/log.native.js +9 -8
- package/dist/esm/helpers/log.native.js.map +1 -1
- package/dist/esm/helpers/mergeVariants.mjs +44 -13
- package/dist/esm/helpers/mergeVariants.mjs.map +1 -1
- package/dist/esm/helpers/mergeVariants.native.js +79 -14
- package/dist/esm/helpers/mergeVariants.native.js.map +1 -1
- package/dist/esm/helpers/nativeOnlyProps.mjs +0 -1
- package/dist/esm/helpers/nativeOnlyProps.mjs.map +1 -1
- package/dist/esm/helpers/nativeOnlyProps.native.js +0 -1
- package/dist/esm/helpers/nativeOnlyProps.native.js.map +1 -1
- package/dist/esm/helpers/nativeStyleEngine.mjs +34 -15
- package/dist/esm/helpers/nativeStyleEngine.mjs.map +1 -1
- package/dist/esm/helpers/nativeStyleEngine.native.js +36 -15
- package/dist/esm/helpers/nativeStyleEngine.native.js.map +1 -1
- package/dist/esm/helpers/normalizeValueWithProperty.mjs +7 -8
- package/dist/esm/helpers/normalizeValueWithProperty.mjs.map +1 -1
- package/dist/esm/helpers/normalizeValueWithProperty.native.js +9 -8
- package/dist/esm/helpers/normalizeValueWithProperty.native.js.map +1 -1
- package/dist/esm/helpers/parseBorderShorthand.native.js +23 -56
- package/dist/esm/helpers/parseBorderShorthand.native.js.map +1 -1
- package/dist/esm/helpers/parseOutlineShorthand.native.js +10 -49
- package/dist/esm/helpers/parseOutlineShorthand.native.js.map +1 -1
- package/dist/esm/helpers/resolveSafeArea.mjs +35 -97
- package/dist/esm/helpers/resolveSafeArea.mjs.map +1 -1
- package/dist/esm/helpers/resolveVariantStyle.mjs +38 -0
- package/dist/esm/helpers/resolveVariantStyle.mjs.map +1 -0
- package/dist/esm/helpers/resolveVariantStyle.native.js +46 -0
- package/dist/esm/helpers/resolveVariantStyle.native.js.map +1 -0
- package/dist/esm/helpers/styleStaticConfig.mjs +1 -50
- package/dist/esm/helpers/styleStaticConfig.mjs.map +1 -1
- package/dist/esm/helpers/styleStaticConfig.native.js +1 -51
- package/dist/esm/helpers/styleStaticConfig.native.js.map +1 -1
- package/dist/esm/helpers/styleStaticConfigCore.mjs +88 -0
- package/dist/esm/helpers/styleStaticConfigCore.mjs.map +1 -0
- package/dist/esm/helpers/styleStaticConfigCore.native.js +106 -0
- package/dist/esm/helpers/styleStaticConfigCore.native.js.map +1 -0
- package/dist/esm/helpers/styledDynamic.mjs +136 -0
- package/dist/esm/helpers/styledDynamic.mjs.map +1 -0
- package/dist/esm/helpers/styledDynamic.native.js +169 -0
- package/dist/esm/helpers/styledDynamic.native.js.map +1 -0
- package/dist/esm/helpers/tokenCategories.mjs +15 -36
- package/dist/esm/helpers/tokenCategories.mjs.map +1 -1
- package/dist/esm/helpers/tokenCategories.native.js +15 -38
- package/dist/esm/helpers/tokenCategories.native.js.map +1 -1
- package/dist/esm/helpers/variableValue.mjs +17 -12
- package/dist/esm/helpers/variableValue.mjs.map +1 -1
- package/dist/esm/helpers/variableValue.native.js +46 -23
- package/dist/esm/helpers/variableValue.native.js.map +1 -1
- package/dist/esm/helpers/warnOnce.mjs +5 -4
- package/dist/esm/helpers/warnOnce.mjs.map +1 -1
- package/dist/esm/helpers/warnOnce.native.js +6 -4
- package/dist/esm/helpers/warnOnce.native.js.map +1 -1
- package/dist/esm/hooks/useAnimationDriver.mjs +2 -2
- package/dist/esm/hooks/useAnimationDriver.mjs.map +1 -1
- package/dist/esm/hooks/useAnimationDriver.native.js +2 -2
- package/dist/esm/hooks/useAnimationDriver.native.js.map +1 -1
- package/dist/esm/hooks/useComponentState.mjs +41 -82
- package/dist/esm/hooks/useComponentState.mjs.map +1 -1
- package/dist/esm/hooks/useComponentState.native.js +45 -84
- package/dist/esm/hooks/useComponentState.native.js.map +1 -1
- package/dist/esm/hooks/useMedia.mjs +2 -2
- package/dist/esm/hooks/useMedia.mjs.map +1 -1
- package/dist/esm/hooks/useMedia.native.js +2 -2
- package/dist/esm/hooks/useMedia.native.js.map +1 -1
- package/dist/esm/hooks/useStyle.mjs +11 -0
- package/dist/esm/hooks/useStyle.mjs.map +1 -0
- package/dist/esm/hooks/useStyle.native.js +11 -0
- package/dist/esm/hooks/useStyle.native.js.map +1 -0
- package/dist/esm/hooks/useThemeState.mjs +25 -90
- package/dist/esm/hooks/useThemeState.mjs.map +1 -1
- package/dist/esm/hooks/useThemeState.native.js +34 -94
- package/dist/esm/hooks/useThemeState.native.js.map +1 -1
- package/dist/esm/index.js +6 -4
- package/dist/esm/index.mjs +6 -4
- package/dist/esm/index.native.js +6 -4
- package/dist/esm/static-resolve.mjs +3 -3
- package/dist/esm/static-resolve.mjs.map +1 -1
- package/dist/esm/static-resolve.native.js +3 -3
- package/dist/esm/static-resolve.native.js.map +1 -1
- package/dist/esm/style.mjs +58 -0
- package/dist/esm/style.mjs.map +1 -0
- package/dist/esm/style.native.js +63 -0
- package/dist/esm/style.native.js.map +1 -0
- package/dist/esm/styled.mjs +12 -6
- package/dist/esm/styled.mjs.map +1 -1
- package/dist/esm/styled.native.js +12 -6
- package/dist/esm/styled.native.js.map +1 -1
- package/dist/esm/types.mjs +3 -4
- package/dist/esm/types.mjs.map +1 -1
- package/dist/esm/types.native.js +3 -4
- package/dist/esm/types.native.js.map +1 -1
- package/dist/esm/views/TamaguiProvider.mjs +1 -2
- package/dist/esm/views/TamaguiProvider.mjs.map +1 -1
- package/dist/esm/views/TamaguiProvider.native.js +1 -2
- package/dist/esm/views/TamaguiProvider.native.js.map +1 -1
- package/dist/esm/views/Text.mjs +17 -12
- package/dist/esm/views/Text.mjs.map +1 -1
- package/dist/esm/views/Theme.mjs +3 -3
- package/dist/esm/views/Theme.mjs.map +1 -1
- package/dist/esm/views/Theme.native.js +3 -3
- package/dist/esm/views/Theme.native.js.map +1 -1
- package/dist/esm/views/ThemeDebug.mjs +1 -4
- package/dist/esm/views/ThemeDebug.mjs.map +1 -1
- package/package.json +15 -15
- package/src/createComponent.tsx +21 -1
- package/src/createStyledHOC.tsx +4 -2
- package/src/createVariable.ts +0 -10
- package/src/helpers/borderComponents.ts +62 -0
- package/src/helpers/createDesignSystem.ts +0 -2
- package/src/helpers/createStyledContext.tsx +15 -53
- package/src/helpers/formatDiagnostic.ts +9 -9
- package/src/helpers/getCSSStylesAtomic.native.ts +6 -3
- package/src/helpers/getCSSStylesAtomic.ts +192 -207
- package/src/helpers/getCSSStylesAtomicCompiled.ts +13 -1
- package/src/helpers/getDynamicVal.ts +4 -0
- package/src/helpers/getSplitStyles.tsx +2080 -3270
- package/src/helpers/grammarConfig.ts +218 -1
- package/src/helpers/insertStyleRule.tsx +4 -2
- package/src/helpers/log.ts +12 -11
- package/src/helpers/mergeVariants.ts +55 -18
- package/src/helpers/nativeOnlyProps.ts +0 -1
- package/src/helpers/nativeStyleEngine.ts +55 -14
- package/src/helpers/normalizeValueWithProperty.ts +10 -12
- package/src/helpers/parseBorderShorthand.native.ts +23 -45
- package/src/helpers/parseOutlineShorthand.native.ts +9 -40
- package/src/helpers/resolveSafeArea.ts +34 -101
- package/src/helpers/resolveVariantStyle.ts +77 -0
- package/src/helpers/styleFrontend.ts +8 -5
- package/src/helpers/styleStaticConfig.ts +5 -72
- package/src/helpers/styleStaticConfigCore.ts +110 -0
- package/src/helpers/styledDynamic.ts +191 -0
- package/src/helpers/tokenCategories.ts +40 -65
- package/src/helpers/variableValue.ts +20 -15
- package/src/helpers/warnOnce.ts +5 -4
- package/src/hooks/useAnimationDriver.ts +6 -2
- package/src/hooks/useComponentState.ts +55 -183
- package/src/hooks/useMedia.tsx +10 -8
- package/src/hooks/useStyle.ts +10 -0
- package/src/hooks/useThemeState.ts +51 -264
- package/src/index.ts +6 -6
- package/src/internalRuntimeTypes.ts +1 -0
- package/src/static-resolve.ts +7 -4
- package/src/style.ts +97 -0
- package/src/styled.tsx +39 -68
- package/src/types.tsx +105 -169
- package/src/views/TamaguiProvider.tsx +0 -2
- package/src/views/Text.tsx +20 -14
- package/src/views/Theme.tsx +13 -9
- package/src/views/ThemeDebug.tsx +0 -1
- package/types/createComponent.d.ts.map +1 -1
- package/types/createStyledHOC.d.ts +1 -1
- package/types/createStyledHOC.d.ts.map +1 -1
- package/types/createVariable.d.ts +0 -2
- package/types/createVariable.d.ts.map +1 -1
- package/types/helpers/borderComponents.d.ts +10 -0
- package/types/helpers/borderComponents.d.ts.map +1 -0
- package/types/helpers/createDesignSystem.d.ts.map +1 -1
- package/types/helpers/createStyledContext.d.ts.map +1 -1
- package/types/helpers/getCSSStylesAtomic.d.ts +20 -19
- package/types/helpers/getCSSStylesAtomic.d.ts.map +1 -1
- package/types/helpers/getCSSStylesAtomic.native.d.ts +5 -0
- package/types/helpers/getCSSStylesAtomic.native.d.ts.map +1 -1
- package/types/helpers/getCSSStylesAtomicCompiled.d.ts +6 -1
- package/types/helpers/getCSSStylesAtomicCompiled.d.ts.map +1 -1
- package/types/helpers/getDynamicVal.d.ts.map +1 -1
- package/types/helpers/getSplitStyles.d.ts +3 -5
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/helpers/grammarConfig.d.ts +25 -2
- package/types/helpers/grammarConfig.d.ts.map +1 -1
- package/types/helpers/insertStyleRule.d.ts +1 -0
- package/types/helpers/insertStyleRule.d.ts.map +1 -1
- package/types/helpers/log.d.ts.map +1 -1
- package/types/helpers/mergeVariants.d.ts.map +1 -1
- package/types/helpers/nativeOnlyProps.d.ts +0 -1
- package/types/helpers/nativeOnlyProps.d.ts.map +1 -1
- package/types/helpers/nativeStyleEngine.d.ts +6 -0
- package/types/helpers/nativeStyleEngine.d.ts.map +1 -1
- package/types/helpers/normalizeValueWithProperty.d.ts.map +1 -1
- package/types/helpers/parseBorderShorthand.native.d.ts +1 -0
- package/types/helpers/parseBorderShorthand.native.d.ts.map +1 -1
- package/types/helpers/parseOutlineShorthand.native.d.ts.map +1 -1
- package/types/helpers/resolveSafeArea.d.ts +0 -1
- package/types/helpers/resolveSafeArea.d.ts.map +1 -1
- package/types/helpers/resolveVariantStyle.d.ts +3 -0
- package/types/helpers/resolveVariantStyle.d.ts.map +1 -0
- package/types/helpers/styleFrontend.d.ts +3 -5
- package/types/helpers/styleFrontend.d.ts.map +1 -1
- package/types/helpers/styleStaticConfig.d.ts +4 -9
- package/types/helpers/styleStaticConfig.d.ts.map +1 -1
- package/types/helpers/styleStaticConfigCore.d.ts +4 -0
- package/types/helpers/styleStaticConfigCore.d.ts.map +1 -0
- package/types/helpers/styledDynamic.d.ts +18 -0
- package/types/helpers/styledDynamic.d.ts.map +1 -0
- package/types/helpers/tokenCategories.d.ts +0 -1
- package/types/helpers/tokenCategories.d.ts.map +1 -1
- package/types/helpers/variableValue.d.ts.map +1 -1
- package/types/helpers/warnOnce.d.ts.map +1 -1
- package/types/helpers/webPropsToSkip.native.d.ts +68 -68
- package/types/hooks/useAnimationDriver.d.ts.map +1 -1
- package/types/hooks/useComponentState.d.ts.map +1 -1
- package/types/hooks/useMedia.d.ts.map +1 -1
- package/types/hooks/useStyle.d.ts +4 -0
- package/types/hooks/useStyle.d.ts.map +1 -0
- package/types/hooks/useThemeState.d.ts +1 -11
- package/types/hooks/useThemeState.d.ts.map +1 -1
- package/types/index.d.ts +6 -4
- package/types/index.d.ts.map +1 -1
- package/types/internalRuntimeTypes.d.ts +1 -1
- package/types/internalRuntimeTypes.d.ts.map +1 -1
- package/types/static-resolve.d.ts.map +1 -1
- package/types/style.d.ts +18 -0
- package/types/style.d.ts.map +1 -0
- package/types/styled.d.ts +10 -10
- package/types/styled.d.ts.map +1 -1
- package/types/types.d.ts +74 -49
- package/types/types.d.ts.map +1 -1
- package/types/views/TamaguiProvider.d.ts +1 -1
- package/types/views/TamaguiProvider.d.ts.map +1 -1
- package/types/views/Text.d.ts.map +1 -1
- package/types/views/Theme.d.ts.map +1 -1
- package/types/views/ThemeDebug.d.ts.map +1 -1
- package/dist/cjs/helpers/directStyleCSS.cjs +0 -345
- package/dist/cjs/helpers/directStyleCSS.native.js.map +0 -1
- package/dist/cjs/helpers/directStyleCSSCompiled.cjs +0 -40
- package/dist/cjs/helpers/directStyleCSSCompiled.native.cjs +0 -46
- package/dist/cjs/helpers/directStyleCSSCompiled.native.js +0 -48
- package/dist/cjs/helpers/directStyleCSSCompiled.native.js.map +0 -1
- package/dist/cjs/helpers/getVariantExtras.cjs +0 -91
- package/dist/cjs/helpers/getVariantExtras.native.cjs +0 -94
- package/dist/cjs/helpers/getVariantExtras.native.js +0 -96
- package/dist/cjs/helpers/getVariantExtras.native.js.map +0 -1
- package/dist/cjs/helpers/variantResolvers.cjs +0 -87
- package/dist/cjs/helpers/variantResolvers.native.cjs +0 -140
- package/dist/cjs/helpers/variantResolvers.native.js +0 -142
- package/dist/cjs/helpers/variantResolvers.native.js.map +0 -1
- package/dist/esm/helpers/directStyleCSS.mjs +0 -317
- package/dist/esm/helpers/directStyleCSS.mjs.map +0 -1
- package/dist/esm/helpers/directStyleCSS.native.js +0 -1
- package/dist/esm/helpers/directStyleCSSCompiled.mjs +0 -11
- package/dist/esm/helpers/directStyleCSSCompiled.mjs.map +0 -1
- package/dist/esm/helpers/directStyleCSSCompiled.native.js +0 -15
- package/dist/esm/helpers/directStyleCSSCompiled.native.js.map +0 -1
- package/dist/esm/helpers/getVariantExtras.mjs +0 -69
- package/dist/esm/helpers/getVariantExtras.mjs.map +0 -1
- package/dist/esm/helpers/getVariantExtras.native.js +0 -70
- package/dist/esm/helpers/getVariantExtras.native.js.map +0 -1
- package/dist/esm/helpers/variantResolvers.mjs +0 -65
- package/dist/esm/helpers/variantResolvers.mjs.map +0 -1
- package/dist/esm/helpers/variantResolvers.native.js +0 -116
- package/dist/esm/helpers/variantResolvers.native.js.map +0 -1
- package/src/helpers/directStyleCSS.native.ts +0 -1
- package/src/helpers/directStyleCSS.ts +0 -513
- package/src/helpers/directStyleCSSCompiled.ts +0 -32
- package/src/helpers/getVariantExtras.tsx +0 -95
- package/src/helpers/variantResolvers.ts +0 -121
- package/types/helpers/directStyleCSS.d.ts +0 -28
- package/types/helpers/directStyleCSS.d.ts.map +0 -1
- package/types/helpers/directStyleCSS.native.d.ts +0 -2
- package/types/helpers/directStyleCSS.native.d.ts.map +0 -1
- package/types/helpers/directStyleCSSCompiled.d.ts +0 -10
- package/types/helpers/directStyleCSSCompiled.d.ts.map +0 -1
- package/types/helpers/getVariantExtras.d.ts +0 -4
- package/types/helpers/getVariantExtras.d.ts.map +0 -1
- package/types/helpers/variantResolvers.d.ts +0 -9
- package/types/helpers/variantResolvers.d.ts.map +0 -1
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
type MutableRefObject,
|
|
10
10
|
} from 'react'
|
|
11
11
|
import { getConfig, getSetting } from '../config'
|
|
12
|
-
import { formatDiagnostic } from '../helpers/formatDiagnostic'
|
|
13
12
|
import { MISSING_THEME_MESSAGE } from '../constants/constants'
|
|
14
13
|
import type {
|
|
15
14
|
ThemeParsed,
|
|
@@ -29,7 +28,6 @@ const HasRenderedOnce = new WeakMap<object, boolean>()
|
|
|
29
28
|
const HadTheme = new WeakMap<object, boolean>()
|
|
30
29
|
const PendingUpdate = new Map<any, boolean | 'force'>()
|
|
31
30
|
|
|
32
|
-
// TODO this will gain memory over time but its not going to be a ton
|
|
33
31
|
const states: Map<ID, ThemeState | undefined> = new Map()
|
|
34
32
|
const localStates: Map<ID, ThemeState | undefined> = new Map()
|
|
35
33
|
|
|
@@ -43,26 +41,12 @@ export const forceUpdateThemes = () => {
|
|
|
43
41
|
|
|
44
42
|
export const getThemeState = (id: ID) => states.get(id)
|
|
45
43
|
|
|
46
|
-
/**
|
|
47
|
-
* ThemeUpdate layers and the provider chain, both keyed by the id a
|
|
48
|
-
* `<Theme>` pushes into `ThemeStateContext`.
|
|
49
|
-
*
|
|
50
|
-
* A portal renders outside its mount ancestry, so it cannot inherit the CSS
|
|
51
|
-
* custom properties a `<ThemeUpdate background="...">` put on an ancestor node. The
|
|
52
|
-
* portal bridge walks this chain and replays exactly those layers. It cannot
|
|
53
|
-
* use `ThemeState.parentId`: a state that resolves to the same theme as its
|
|
54
|
-
* parent is a copy of the parent state, so its `parentId` skips a level.
|
|
55
|
-
*
|
|
56
|
-
* Only `<Theme>` providers are recorded, which is also the only kind of state
|
|
57
|
-
* whose id can appear in `ThemeStateContext`.
|
|
58
|
-
*/
|
|
59
44
|
const themeUpdateLayers = new Map<ID, ThemeUpdateState>()
|
|
60
45
|
const themeProviderParents = new Map<ID, ID>()
|
|
61
46
|
|
|
62
47
|
export const getThemeUpdateLayer = (id: ID) => themeUpdateLayers.get(id)
|
|
63
48
|
export const getThemeProviderParent = (id: ID) => themeProviderParents.get(id)
|
|
64
49
|
|
|
65
|
-
/** introspection for devtools and leak probes: entries retained per map */
|
|
66
50
|
export const getThemeProviderChainSizes = () => ({
|
|
67
51
|
layers: themeUpdateLayers.size,
|
|
68
52
|
parents: themeProviderParents.size,
|
|
@@ -82,9 +66,6 @@ const registerThemeProviderChain = (
|
|
|
82
66
|
}
|
|
83
67
|
|
|
84
68
|
let cacheVersion = 0
|
|
85
|
-
|
|
86
|
-
// config-generation cache for getNewThemeName. values are derived strings, so
|
|
87
|
-
// the whole memo generation can roll without invalidating mounted ThemeState.
|
|
88
69
|
const themeNameCache = new Map<string, string | null>()
|
|
89
70
|
let themeNameCacheVer = -1
|
|
90
71
|
|
|
@@ -93,11 +74,8 @@ let themes: Record<string, ThemeParsed> | null = null
|
|
|
93
74
|
let rootThemeState: ThemeState | null = null
|
|
94
75
|
export const getRootThemeState = () => rootThemeState
|
|
95
76
|
|
|
96
|
-
// extracts base name without scheme: "light_red_surface1" -> "red_surface1"
|
|
97
77
|
const getThemeBaseName = (name: string) => name.replace(/^(light|dark)_/, '')
|
|
98
78
|
|
|
99
|
-
// useReducer-based force-update; cheaper than useSyncExternalStore's internal
|
|
100
|
-
// useState+useLayoutEffect+useEffect+useDebugValue chain on Hermes.
|
|
101
79
|
const incReducer = (c: number): number => c + 1
|
|
102
80
|
|
|
103
81
|
export const useThemeState = (
|
|
@@ -105,12 +83,6 @@ export const useThemeState = (
|
|
|
105
83
|
isRoot = false,
|
|
106
84
|
keys: MutableRefObject<Set<string> | null>,
|
|
107
85
|
schemeKeys?: MutableRefObject<Set<string> | null>,
|
|
108
|
-
// when true, install the propsKey-watching useIsomorphicLayoutEffect that
|
|
109
|
-
// schedules descendant updates via listenersByParent[id]. Only <Theme>
|
|
110
|
-
// providers actually push their themeState.id into ThemeStateContext, so
|
|
111
|
-
// only they can have descendants subscribed under their id. Leaf styled
|
|
112
|
-
// components pass false (the default) and save one hook slot per mount.
|
|
113
|
-
// Stable per call-site (rule of hooks satisfied).
|
|
114
86
|
cascadeOnChange = false,
|
|
115
87
|
optimizeForFirstRender = false
|
|
116
88
|
): ThemeState => {
|
|
@@ -122,9 +94,7 @@ export const useThemeState = (
|
|
|
122
94
|
if (!parentId && !isRoot) {
|
|
123
95
|
throw new Error(
|
|
124
96
|
process.env.NODE_ENV === 'development'
|
|
125
|
-
? `${MISSING_THEME_MESSAGE}
|
|
126
|
-
|
|
127
|
-
Looked for theme${props.name ? ` "${props.name}"` : ''}, but no parent theme context was found (parentId: ${parentId}).`
|
|
97
|
+
? `${MISSING_THEME_MESSAGE}\n\nLooked for theme${props.name ? ` "${props.name}"` : ''}, but no parent theme context was found (parentId: ${parentId}).`
|
|
128
98
|
: MISSING_THEME_MESSAGE
|
|
129
99
|
)
|
|
130
100
|
}
|
|
@@ -135,83 +105,49 @@ Looked for theme${props.name ? ` "${props.name}"` : ''}, but no parent theme con
|
|
|
135
105
|
id: '',
|
|
136
106
|
name: 'light',
|
|
137
107
|
theme: getConfig().themes.light,
|
|
138
|
-
// inverses: 0,
|
|
139
108
|
}
|
|
140
109
|
)
|
|
141
110
|
}
|
|
142
111
|
|
|
143
|
-
// useId keeps theme-provider ids tied to the React tree. A process-wide
|
|
144
|
-
// counter can let children observe a provider context id whose matching
|
|
145
|
-
// states Map entry was never populated in multi-root/native surfaces.
|
|
146
112
|
const id = useId()
|
|
147
113
|
const propsKey = getPropsKey(props)
|
|
148
114
|
|
|
149
|
-
// only a <Theme> provider pushes its id into ThemeStateContext, so only it can
|
|
150
|
-
// be a step in the chain the portal bridge replays
|
|
151
115
|
if (cascadeOnChange) {
|
|
152
116
|
registerThemeProviderChain(id, parentId, props)
|
|
153
117
|
}
|
|
154
118
|
|
|
155
|
-
// stable ref-bag for render inputs and the optional subscription cleanup.
|
|
156
|
-
// lastSnap caches the last getSnapshot result for the subscription bailout.
|
|
157
119
|
const ref = useRef<ThemeStateRef>(null as any)
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
ref.current.schemeKeys = schemeKeys
|
|
177
|
-
ref.current.parentId = parentId
|
|
178
|
-
}
|
|
179
|
-
ref.current.renderVersion++
|
|
180
|
-
|
|
181
|
-
if (process.env.NODE_ENV === 'development' && globalThis.time)
|
|
182
|
-
globalThis.time`theme-prep-uses`
|
|
120
|
+
const r = (ref.current ||= {
|
|
121
|
+
id,
|
|
122
|
+
parentId,
|
|
123
|
+
props,
|
|
124
|
+
propsKey,
|
|
125
|
+
isRoot,
|
|
126
|
+
keys,
|
|
127
|
+
schemeKeys,
|
|
128
|
+
optimizeForFirstRender,
|
|
129
|
+
renderVersion: 0,
|
|
130
|
+
})
|
|
131
|
+
r.props = props
|
|
132
|
+
r.propsKey = propsKey
|
|
133
|
+
r.isRoot = isRoot
|
|
134
|
+
r.keys = keys
|
|
135
|
+
r.schemeKeys = schemeKeys
|
|
136
|
+
r.parentId = parentId
|
|
137
|
+
r.renderVersion++
|
|
183
138
|
|
|
184
|
-
// manual subscription replaces useSyncExternalStore: same granular bailout
|
|
185
|
-
// (getSnapshot returning the same ref → React doesn't re-render), fewer
|
|
186
|
-
// React-internal hook slots on Hermes. We don't need tearing prevention
|
|
187
|
-
// here: theme/media updates are event-driven, not transition-driven, and
|
|
188
|
-
// useReducer in normal mode already gives same-tick batching.
|
|
189
139
|
const [, forceUpdate] = useReducer(incReducer, 0)
|
|
190
|
-
const state = getSnapshotImpl(
|
|
191
|
-
|
|
140
|
+
const state = getSnapshotImpl(r)
|
|
141
|
+
r.lastSnap = state
|
|
192
142
|
|
|
193
143
|
useEffect(() => {
|
|
194
|
-
const r = ref.current
|
|
195
144
|
const renderVersion = r.renderVersion
|
|
196
145
|
|
|
197
|
-
// strict-mode dev double-invokes effects: cleanup runs between the two
|
|
198
|
-
// invocations with no render in between, so the "unchanged renderVersion
|
|
199
|
-
// means unmount" check below false-positives and deletes this component's
|
|
200
|
-
// registered theme state mid-lifecycle. the registry is only re-populated
|
|
201
|
-
// on this component's next render, so until then children resolve a
|
|
202
|
-
// missing parent and fall back to the root theme state (isNew: true) —
|
|
203
|
-
// which flips getThemedChildren to wrap and re-parents/remounts their
|
|
204
|
-
// hosts, losing focus (keyboard dismiss on first Input tap). per react's
|
|
205
|
-
// strict-mode contract, setup restores whatever cleanup tore down.
|
|
206
146
|
if (r.lastSnap && !states.has(r.id)) {
|
|
207
147
|
states.set(r.id, r.lastSnap)
|
|
208
148
|
localStates.set(r.id, r.lastSnap)
|
|
209
149
|
}
|
|
210
150
|
|
|
211
|
-
// same strict-mode contract for the portal-bridge chain: cleanupThemeState
|
|
212
|
-
// retires both maps, and only a render re-registers them, so a provider torn
|
|
213
|
-
// down between the two effect invocations would lose its layer until it
|
|
214
|
-
// happened to re-render, breaking portal bridging mid-lifecycle.
|
|
215
151
|
if (cascadeOnChange && !themeProviderParents.has(r.id)) {
|
|
216
152
|
registerThemeProviderChain(r.id, r.parentId, r.props)
|
|
217
153
|
}
|
|
@@ -228,11 +164,6 @@ Looked for theme${props.name ? ` "${props.name}"` : ''}, but no parent theme con
|
|
|
228
164
|
const next = getSnapshotImpl(r)
|
|
229
165
|
if (next !== r.lastSnap) {
|
|
230
166
|
r.lastSnap = next
|
|
231
|
-
// native fast path: the component can commit the themed styles
|
|
232
|
-
// straight to the native tree and skip this re-render. state maps
|
|
233
|
-
// are already updated above, so a later natural render resolves
|
|
234
|
-
// the exact same values (mirror consistency). forced updates
|
|
235
|
-
// (config changes) always re-render.
|
|
236
167
|
if (!forced && r.props.nativeUpdate?.(next)) {
|
|
237
168
|
return
|
|
238
169
|
}
|
|
@@ -240,8 +171,7 @@ Looked for theme${props.name ? ` "${props.name}"` : ''}, but no parent theme con
|
|
|
240
171
|
}
|
|
241
172
|
}
|
|
242
173
|
|
|
243
|
-
listenersByParent[pid]
|
|
244
|
-
listenersByParent[pid].add(sid)
|
|
174
|
+
;(listenersByParent[pid] ||= new Set()).add(sid)
|
|
245
175
|
allListeners.set(sid, () => {
|
|
246
176
|
const forced = shouldForce
|
|
247
177
|
PendingUpdate.set(sid, forced ? 'force' : true)
|
|
@@ -263,9 +193,6 @@ Looked for theme${props.name ? ` "${props.name}"` : ''}, but no parent theme con
|
|
|
263
193
|
}
|
|
264
194
|
|
|
265
195
|
return () => {
|
|
266
|
-
// react runs passive cleanup before the next effect as well as on unmount.
|
|
267
|
-
// a newer render bumps renderVersion before that cleanup, so equality here
|
|
268
|
-
// means this is the final unmount cleanup.
|
|
269
196
|
if (r.renderVersion === renderVersion) {
|
|
270
197
|
cleanupThemeState(r)
|
|
271
198
|
}
|
|
@@ -281,15 +208,11 @@ Looked for theme${props.name ? ` "${props.name}"` : ''}, but no parent theme con
|
|
|
281
208
|
}
|
|
282
209
|
if (!propsKey) {
|
|
283
210
|
if (HadTheme.get(keys)) {
|
|
284
|
-
// we're removing the last theme, make sure to notify
|
|
285
211
|
scheduleUpdate(id)
|
|
286
212
|
}
|
|
287
213
|
HadTheme.set(keys, false)
|
|
288
214
|
return
|
|
289
215
|
}
|
|
290
|
-
if (process.env.NODE_ENV === 'development' && props.debug === 'verbose') {
|
|
291
|
-
console.warn(` · useTheme(${id}) scheduleUpdate`, propsKey, states.get(id)?.name)
|
|
292
|
-
}
|
|
293
216
|
scheduleUpdate(id)
|
|
294
217
|
HadTheme.set(keys, true)
|
|
295
218
|
}, [keys, propsKey])
|
|
@@ -317,12 +240,14 @@ type ThemeStateRef = SnapshotRef & {
|
|
|
317
240
|
}
|
|
318
241
|
|
|
319
242
|
const shouldSubscribeToTheme = (r: ThemeStateRef, cascadeOnChange: boolean): boolean =>
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
243
|
+
Boolean(
|
|
244
|
+
r.optimizeForFirstRender ||
|
|
245
|
+
r.isRoot ||
|
|
246
|
+
cascadeOnChange ||
|
|
247
|
+
hasThemeUpdatingProps(r.props) ||
|
|
248
|
+
r.keys.current?.size ||
|
|
249
|
+
r.props.needsUpdate?.()
|
|
250
|
+
)
|
|
326
251
|
|
|
327
252
|
function cleanupThemeSubscription(r: ThemeStateRef) {
|
|
328
253
|
r.unsubscribe?.()
|
|
@@ -336,9 +261,6 @@ function cleanupThemeState(r: ThemeStateRef) {
|
|
|
336
261
|
states.delete(r.id)
|
|
337
262
|
PendingUpdate.delete(r.id)
|
|
338
263
|
}
|
|
339
|
-
// both branches retire the id, and a subscribed <Theme> provider only ever
|
|
340
|
-
// takes the first one, so the portal-bridge chain has to be cleared here
|
|
341
|
-
// rather than inside the unsubscribed branch.
|
|
342
264
|
themeUpdateLayers.delete(r.id)
|
|
343
265
|
themeProviderParents.delete(r.id)
|
|
344
266
|
}
|
|
@@ -357,7 +279,6 @@ const getSnapshotImpl = (r: SnapshotRef): ThemeState => {
|
|
|
357
279
|
let local = localStates.get(id)
|
|
358
280
|
const parentState = states.get(parentId)
|
|
359
281
|
|
|
360
|
-
// fast path: nothing changed since last snapshot
|
|
361
282
|
if (local && !PendingUpdate.has(id)) {
|
|
362
283
|
if (
|
|
363
284
|
parentState &&
|
|
@@ -368,7 +289,6 @@ const getSnapshotImpl = (r: SnapshotRef): ThemeState => {
|
|
|
368
289
|
}
|
|
369
290
|
}
|
|
370
291
|
|
|
371
|
-
// check if this is a scheme-only change (light↔dark) where DynamicColorIOS handles it
|
|
372
292
|
const isSchemeOnlyChange =
|
|
373
293
|
!optimizeForFirstRender &&
|
|
374
294
|
process.env.TAMAGUI_TARGET === 'native' &&
|
|
@@ -379,14 +299,11 @@ const getSnapshotImpl = (r: SnapshotRef): ThemeState => {
|
|
|
379
299
|
local.scheme !== parentState.scheme &&
|
|
380
300
|
getThemeBaseName(local.name) === getThemeBaseName(parentState.name)
|
|
381
301
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
const schemeKeysSize = schemeKeys?.current?.size ?? 0
|
|
386
|
-
allKeysSchemeOptimized = schemeKeysSize === keysSize && keysSize > 0
|
|
387
|
-
}
|
|
302
|
+
const allKeysSchemeOptimized =
|
|
303
|
+
!optimizeForFirstRender &&
|
|
304
|
+
Boolean(keys.current?.size && schemeKeys?.current?.size === keys.current.size)
|
|
388
305
|
|
|
389
|
-
const canSkipForSchemeChange =
|
|
306
|
+
const canSkipForSchemeChange = Boolean(isSchemeOnlyChange && allKeysSchemeOptimized)
|
|
390
307
|
|
|
391
308
|
const needsUpdate = props.passThrough
|
|
392
309
|
? false
|
|
@@ -397,7 +314,7 @@ const getSnapshotImpl = (r: SnapshotRef): ThemeState => {
|
|
|
397
314
|
: !HasRenderedOnce.get(keys)
|
|
398
315
|
? true
|
|
399
316
|
: canSkipForSchemeChange
|
|
400
|
-
? false
|
|
317
|
+
? false
|
|
401
318
|
: keys?.current?.size
|
|
402
319
|
? true
|
|
403
320
|
: props.needsUpdate?.()
|
|
@@ -413,12 +330,6 @@ const getSnapshotImpl = (r: SnapshotRef): ThemeState => {
|
|
|
413
330
|
PendingUpdate.get(id)
|
|
414
331
|
)
|
|
415
332
|
|
|
416
|
-
// ThemeUpdate layer: swap in the merged theme so descendants
|
|
417
|
-
// (which read states.get(parentId).theme) see the patched values. The base
|
|
418
|
-
// is always the PARENT state's theme, never this state's own theme —
|
|
419
|
-
// getNextState can return our previous (already-merged) state, and merging
|
|
420
|
-
// over own output would keep removed patch keys alive. Merged objects are
|
|
421
|
-
// identity-cached per (base theme, values, scheme) so bailouts stay stable.
|
|
422
333
|
let next = nextRaw
|
|
423
334
|
if (props._themeUpdate && nextRaw?.theme) {
|
|
424
335
|
const parentTheme = states.get(parentId)?.theme || nextRaw.theme
|
|
@@ -430,32 +341,11 @@ const getSnapshotImpl = (r: SnapshotRef): ThemeState => {
|
|
|
430
341
|
|
|
431
342
|
PendingUpdate.delete(id)
|
|
432
343
|
|
|
433
|
-
// we always create a new localState for every component
|
|
434
|
-
// that way we can use it to de-opt and avoid renders granularly
|
|
435
|
-
// we always return the localState object in each component
|
|
436
|
-
// the global state (states) should always be up to date with the latest
|
|
437
344
|
if (!local || rerender) {
|
|
438
345
|
local = { ...next }
|
|
439
346
|
localStates.set(id, local)
|
|
440
347
|
}
|
|
441
348
|
|
|
442
|
-
if (process.env.NODE_ENV === 'development' && props.debug === 'verbose') {
|
|
443
|
-
console.groupCollapsed(` ${id} getSnapshot ${rerender}`, local.name, '>', next.name)
|
|
444
|
-
console.info({
|
|
445
|
-
props,
|
|
446
|
-
propsKey,
|
|
447
|
-
isRoot,
|
|
448
|
-
parentId,
|
|
449
|
-
local,
|
|
450
|
-
next,
|
|
451
|
-
needsUpdate,
|
|
452
|
-
isSchemeOnlyChange,
|
|
453
|
-
allKeysSchemeOptimized,
|
|
454
|
-
canSkipForSchemeChange,
|
|
455
|
-
})
|
|
456
|
-
console.groupEnd()
|
|
457
|
-
}
|
|
458
|
-
|
|
459
349
|
if (next !== local) {
|
|
460
350
|
Object.assign(local, next)
|
|
461
351
|
local.id = id
|
|
@@ -477,59 +367,36 @@ const getNextState = (
|
|
|
477
367
|
needsUpdate: boolean | undefined,
|
|
478
368
|
pendingUpdate: boolean | 'force' | undefined
|
|
479
369
|
): [boolean, ThemeState] => {
|
|
480
|
-
const { debug } = props
|
|
481
370
|
const parentState = states.get(parentId)
|
|
482
371
|
|
|
483
372
|
if (props.passThrough) {
|
|
484
373
|
return [false, lastState || parentState || ({ name: '' } as any)]
|
|
485
374
|
}
|
|
486
375
|
|
|
487
|
-
|
|
488
|
-
themes = getConfig().themes
|
|
489
|
-
}
|
|
376
|
+
themes ||= getConfig().themes
|
|
490
377
|
|
|
491
378
|
const name =
|
|
492
|
-
!propsKey && (!lastState || !lastState
|
|
379
|
+
!propsKey && (!lastState || !lastState.isNew)
|
|
493
380
|
? null
|
|
494
381
|
: getNewThemeName(
|
|
495
382
|
parentState?.name,
|
|
496
383
|
props,
|
|
497
384
|
pendingUpdate === 'force' ? true : !!needsUpdate
|
|
498
385
|
)
|
|
499
|
-
const isSameAsParent = parentState && (!name || name === parentState.name)
|
|
386
|
+
const isSameAsParent = Boolean(parentState && (!name || name === parentState.name))
|
|
500
387
|
const shouldRerender = Boolean(
|
|
501
388
|
pendingUpdate === 'force' ||
|
|
502
389
|
(needsUpdate && (pendingUpdate || lastState?.name !== parentState?.name))
|
|
503
390
|
)
|
|
504
391
|
|
|
505
|
-
if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
|
|
506
|
-
const message = ` · useTheme(${id}) getNextState => ${name} needsUpdate ${needsUpdate} shouldRerender ${shouldRerender}`
|
|
507
|
-
if (process.env.TAMAGUI_TARGET === 'native') {
|
|
508
|
-
console.info(message)
|
|
509
|
-
} else {
|
|
510
|
-
console.groupCollapsed(message)
|
|
511
|
-
console.trace({ name, lastState, parentState, props, propsKey, id, isSameAsParent })
|
|
512
|
-
console.groupEnd()
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
|
|
516
392
|
if (isSameAsParent) {
|
|
517
393
|
if (!shouldRerender && lastState && lastState.name === parentState!.name) {
|
|
518
394
|
return [false, lastState]
|
|
519
395
|
}
|
|
520
|
-
return [shouldRerender, { ...parentState
|
|
396
|
+
return [shouldRerender, { ...parentState!, isNew: false }]
|
|
521
397
|
}
|
|
522
398
|
|
|
523
399
|
if (!name) {
|
|
524
|
-
// parentState can be transiently missing when a consumer renders in a
|
|
525
|
-
// separate sync flush (a portal/Toast viewport, or a native multi-root
|
|
526
|
-
// surface) before its provider has populated the module-level `states` map.
|
|
527
|
-
// that's recoverable — the next render resolves it — so fall back to the
|
|
528
|
-
// root theme (or a light stub) instead of throwing. the "no parent context"
|
|
529
|
-
// throw above still catches a genuinely missing provider. going back to
|
|
530
|
-
// useSyncExternalStore would avoid the race but force every themed node out
|
|
531
|
-
// of concurrent rendering, so we keep the manual store and tolerate the
|
|
532
|
-
// ordering here.
|
|
533
400
|
const next = lastState ??
|
|
534
401
|
parentState ??
|
|
535
402
|
rootThemeState ?? {
|
|
@@ -539,8 +406,7 @@ const getNextState = (
|
|
|
539
406
|
}
|
|
540
407
|
|
|
541
408
|
if (shouldRerender) {
|
|
542
|
-
|
|
543
|
-
return [true, updated]
|
|
409
|
+
return [true, { ...(parentState || lastState || next) }]
|
|
544
410
|
}
|
|
545
411
|
|
|
546
412
|
return [false, next]
|
|
@@ -548,13 +414,10 @@ const getNextState = (
|
|
|
548
414
|
|
|
549
415
|
const scheme = getScheme(name)
|
|
550
416
|
const parentInverses = parentState?.inverses ?? 0
|
|
551
|
-
const isInverse = parentState && scheme !== parentState.scheme
|
|
552
|
-
// cumulative from the root: once any level flips scheme, every descendant is
|
|
553
|
-
// considered inverted vs the OS, even sub-themes that match their immediate
|
|
554
|
-
// parent (dark_blue under dark). gates the DynamicColorIOS optimization below.
|
|
417
|
+
const isInverse = Boolean(parentState && scheme !== parentState.scheme)
|
|
555
418
|
const inverses = parentInverses + (isInverse ? 1 : 0)
|
|
556
419
|
|
|
557
|
-
const nextState = {
|
|
420
|
+
const nextState: ThemeState = {
|
|
558
421
|
id,
|
|
559
422
|
name,
|
|
560
423
|
theme: themes[name],
|
|
@@ -564,7 +427,7 @@ const getNextState = (
|
|
|
564
427
|
inverses,
|
|
565
428
|
isInverse,
|
|
566
429
|
isNew: true,
|
|
567
|
-
}
|
|
430
|
+
}
|
|
568
431
|
|
|
569
432
|
if (isRoot) {
|
|
570
433
|
rootThemeState = nextState
|
|
@@ -580,21 +443,7 @@ const getNextState = (
|
|
|
580
443
|
!needsUpdate &&
|
|
581
444
|
nextState.name === lastState.name
|
|
582
445
|
|
|
583
|
-
|
|
584
|
-
console.groupCollapsed(
|
|
585
|
-
` · useTheme(${id}) ⏭️ ${name} shouldAvoidRerender: ${shouldAvoidRerender}`
|
|
586
|
-
)
|
|
587
|
-
console.info({ lastState, needsUpdate, nextState, pendingUpdate })
|
|
588
|
-
console.groupEnd()
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
// we still update the state (not changing identity), that way children can properly resolve the right state
|
|
592
|
-
// but this one wont trigger an update
|
|
593
|
-
if (shouldAvoidRerender) {
|
|
594
|
-
return [false, nextState]
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
return [true, nextState]
|
|
446
|
+
return [!shouldAvoidRerender, nextState]
|
|
598
447
|
}
|
|
599
448
|
|
|
600
449
|
function scheduleUpdate(id: string) {
|
|
@@ -615,8 +464,7 @@ function scheduleUpdate(id: string) {
|
|
|
615
464
|
}
|
|
616
465
|
|
|
617
466
|
visited.forEach((childId) => {
|
|
618
|
-
|
|
619
|
-
cb?.()
|
|
467
|
+
allListeners.get(childId)?.()
|
|
620
468
|
})
|
|
621
469
|
}
|
|
622
470
|
|
|
@@ -634,23 +482,9 @@ export function getNewThemeName(
|
|
|
634
482
|
props: UseThemeWithStateProps,
|
|
635
483
|
forceUpdate = false
|
|
636
484
|
): string | null {
|
|
637
|
-
const { name
|
|
638
|
-
|
|
639
|
-
if (name && reset) {
|
|
640
|
-
throw new Error(
|
|
641
|
-
formatDiagnostic(
|
|
642
|
-
'❌004',
|
|
643
|
-
'Theme',
|
|
644
|
-
'props name and reset are mutually exclusive',
|
|
645
|
-
'Pass either name or reset, not both',
|
|
646
|
-
'name,reset',
|
|
647
|
-
{ name, reset }
|
|
648
|
-
)
|
|
649
|
-
)
|
|
650
|
-
}
|
|
485
|
+
const { name } = props
|
|
651
486
|
|
|
652
|
-
|
|
653
|
-
const cacheKey = `${parentName}|${name || ''}|${reset ? 1 : 0}|${forceUpdate ? 1 : 0}`
|
|
487
|
+
const cacheKey = `${parentName}|${name || ''}|${forceUpdate ? 1 : 0}`
|
|
654
488
|
if (themeNameCacheVer !== cacheVersion) {
|
|
655
489
|
themeNameCache.clear()
|
|
656
490
|
themeNameCacheVer = cacheVersion
|
|
@@ -662,7 +496,6 @@ export function getNewThemeName(
|
|
|
662
496
|
const result = resolveThemeName(
|
|
663
497
|
parentName,
|
|
664
498
|
name ?? undefined,
|
|
665
|
-
reset,
|
|
666
499
|
getConfig().themes,
|
|
667
500
|
forceUpdate
|
|
668
501
|
)
|
|
@@ -673,58 +506,26 @@ export function getNewThemeName(
|
|
|
673
506
|
return result
|
|
674
507
|
}
|
|
675
508
|
|
|
676
|
-
/** current config-generation size for development diagnostics and behavior probes */
|
|
677
509
|
export const getThemeNameCacheSize = () => themeNameCache.size
|
|
678
510
|
|
|
679
|
-
/**
|
|
680
|
-
* Which theme a `<Theme>` node resolves to, given the theme it sits under.
|
|
681
|
-
*
|
|
682
|
-
* Pure: parent name, authored name, and the config's theme map are the whole
|
|
683
|
-
* input. That is what lets the zero-runtime compiler resolve a nested static
|
|
684
|
-
* `<Theme>` chain to the same names the runtime would, instead of guessing at
|
|
685
|
-
* how the composition works. `null` means the node did not change the theme.
|
|
686
|
-
*/
|
|
687
511
|
export function resolveThemeName(
|
|
688
512
|
parentName: string,
|
|
689
513
|
name: string | undefined,
|
|
690
|
-
reset: boolean | undefined,
|
|
691
514
|
themes: Record<string, any>,
|
|
692
515
|
forceUpdate = false
|
|
693
516
|
): string | null {
|
|
694
|
-
if (reset) {
|
|
695
|
-
// For reset, we need to go back to the grandparent theme
|
|
696
|
-
// If parentName is just a scheme (like "dark" or "light"),
|
|
697
|
-
// we should return the opposite scheme or a default
|
|
698
|
-
const isSchemeOnly = parentName === 'light' || parentName === 'dark'
|
|
699
|
-
if (isSchemeOnly) {
|
|
700
|
-
// If parent is just a scheme, go to the opposite scheme
|
|
701
|
-
return parentName === 'light' ? 'dark' : 'light'
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
// For compound themes like "dark_blue", extract the scheme
|
|
705
|
-
const lastPartIndex = parentName.lastIndexOf('_')
|
|
706
|
-
// parentName will have format light_{name} or dark_{name}
|
|
707
|
-
const resetName = lastPartIndex <= 0 ? parentName : parentName.slice(lastPartIndex)
|
|
708
|
-
const scheme = parentName.slice(0, lastPartIndex)
|
|
709
|
-
return themes[resetName] ? resetName : scheme
|
|
710
|
-
}
|
|
711
|
-
|
|
712
517
|
const parentParts = parentName ? parentName.split('_') : []
|
|
713
|
-
|
|
714
518
|
let found: string | null = null
|
|
715
519
|
|
|
716
520
|
if (name) {
|
|
717
521
|
const nameHasScheme = getScheme(name)
|
|
718
|
-
|
|
719
522
|
if (nameHasScheme && name in themes) {
|
|
720
523
|
found = name
|
|
721
524
|
}
|
|
722
|
-
|
|
723
525
|
if (!found && !nameHasScheme) {
|
|
724
526
|
for (let i = parentParts.length; i >= 0; i--) {
|
|
725
527
|
const base = parentParts.slice(0, i).join('_')
|
|
726
528
|
const potential = base ? `${base}_${name}` : name
|
|
727
|
-
|
|
728
529
|
if (potential in themes) {
|
|
729
530
|
found = potential
|
|
730
531
|
break
|
|
@@ -733,29 +534,15 @@ export function resolveThemeName(
|
|
|
733
534
|
}
|
|
734
535
|
}
|
|
735
536
|
|
|
736
|
-
if (
|
|
737
|
-
!forceUpdate &&
|
|
738
|
-
found === parentName &&
|
|
739
|
-
// if its a scheme only sub-theme, we always consider it "new" because it likely inverses
|
|
740
|
-
// and we want to avoid reparenting
|
|
741
|
-
!validSchemes[found]
|
|
742
|
-
) {
|
|
537
|
+
if (!forceUpdate && found === parentName && !validSchemes[found]) {
|
|
743
538
|
return null
|
|
744
539
|
}
|
|
745
540
|
|
|
746
541
|
return found
|
|
747
542
|
}
|
|
748
543
|
|
|
749
|
-
const getPropsKey = ({
|
|
750
|
-
name
|
|
751
|
-
reset,
|
|
752
|
-
forceClassName,
|
|
753
|
-
_themeUpdate,
|
|
754
|
-
}: UseThemeWithStateProps) =>
|
|
755
|
-
`${name || ''}${reset || ''}${forceClassName || ''}${_themeUpdate?.key || ''}`
|
|
544
|
+
const getPropsKey = ({ name, forceClassName, _themeUpdate }: UseThemeWithStateProps) =>
|
|
545
|
+
`${name || ''}${forceClassName || ''}${_themeUpdate?.key || ''}`
|
|
756
546
|
|
|
757
547
|
export const hasThemeUpdatingProps = (props: UseThemeWithStateProps) =>
|
|
758
|
-
'name' in props ||
|
|
759
|
-
'reset' in props ||
|
|
760
|
-
'forceClassName' in props ||
|
|
761
|
-
'_themeUpdate' in props
|
|
548
|
+
'name' in props || 'forceClassName' in props || '_themeUpdate' in props
|
package/src/index.ts
CHANGED
|
@@ -67,15 +67,15 @@ export {
|
|
|
67
67
|
createVariable,
|
|
68
68
|
createCSSVariable,
|
|
69
69
|
getVariable,
|
|
70
|
-
getVariableName,
|
|
71
70
|
getVariableValue,
|
|
72
|
-
getVariableVariable,
|
|
73
71
|
isVariable,
|
|
74
72
|
px,
|
|
75
73
|
variableToString,
|
|
76
74
|
} from './createVariable'
|
|
77
75
|
export { insertFont, updateFont } from './insertFont'
|
|
78
76
|
export { styled } from './styled'
|
|
77
|
+
export { style } from './style'
|
|
78
|
+
export { useStyle } from './hooks/useStyle'
|
|
79
79
|
export { Tamagui } from './Tamagui'
|
|
80
80
|
|
|
81
81
|
export type { TamaguiBuildOptions } from '@tamagui/types'
|
|
@@ -154,7 +154,6 @@ export type {
|
|
|
154
154
|
Size,
|
|
155
155
|
SizeKeys,
|
|
156
156
|
SizeTokens,
|
|
157
|
-
SizeVariantSpreadFunction,
|
|
158
157
|
Space,
|
|
159
158
|
SpaceTokens,
|
|
160
159
|
SpaceValue,
|
|
@@ -164,7 +163,9 @@ export type {
|
|
|
164
163
|
StaticConfig,
|
|
165
164
|
StaticComponentObject,
|
|
166
165
|
StaticConfigPublic,
|
|
166
|
+
StaticShapeStyle,
|
|
167
167
|
StyleObject,
|
|
168
|
+
StylePiece,
|
|
168
169
|
StyleProp,
|
|
169
170
|
StyledContext,
|
|
170
171
|
StyledContextOptions,
|
|
@@ -220,8 +221,6 @@ export type {
|
|
|
220
221
|
VariableVal,
|
|
221
222
|
VariableValGeneric,
|
|
222
223
|
VariableValIn,
|
|
223
|
-
VariantSpreadExtras,
|
|
224
|
-
VariantSpreadFunction,
|
|
225
224
|
WidthHeight,
|
|
226
225
|
WithFlatVariantValues,
|
|
227
226
|
WithShorthands,
|
|
@@ -229,7 +228,7 @@ export type {
|
|
|
229
228
|
ZIndex,
|
|
230
229
|
ZIndexTokens,
|
|
231
230
|
} from './types'
|
|
232
|
-
export {
|
|
231
|
+
export { stylePieceSymbol } from './types'
|
|
233
232
|
|
|
234
233
|
export type { GetRef } from './interfaces/GetRef'
|
|
235
234
|
export {
|
|
@@ -338,6 +337,7 @@ export {
|
|
|
338
337
|
StyleObjectRules,
|
|
339
338
|
StyleObjectValue,
|
|
340
339
|
stylePropsAll,
|
|
340
|
+
stylePropsInput,
|
|
341
341
|
stylePropsText,
|
|
342
342
|
stylePropsTextOnly,
|
|
343
343
|
stylePropsTransform,
|