react-native-unistyles 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +1 -1
- package/README.md +38 -30
- package/lib/commonjs/UnistylesTheme.js +21 -0
- package/lib/commonjs/UnistylesTheme.js.map +1 -0
- package/lib/commonjs/createUnistyles.js +57 -0
- package/lib/commonjs/createUnistyles.js.map +1 -0
- package/lib/commonjs/hooks/index.js +3 -24
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/useDimensions.js +10 -0
- package/lib/commonjs/hooks/useDimensions.js.map +1 -0
- package/lib/commonjs/hooks/useDimensions.web.js +34 -0
- package/lib/commonjs/hooks/useDimensions.web.js.map +1 -0
- package/lib/commonjs/index.js +6 -63
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types/index.js +0 -11
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/commonjs/types/mediaQueries.js +2 -0
- package/lib/commonjs/types/{unistyles.js.map → mediaQueries.js.map} +1 -1
- package/lib/commonjs/utils/breakpoints.js +122 -20
- package/lib/commonjs/utils/breakpoints.js.map +1 -1
- package/lib/commonjs/utils/common.js +20 -0
- package/lib/commonjs/utils/common.js.map +1 -0
- package/lib/commonjs/utils/index.js +54 -22
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/mediaQueries.js +189 -0
- package/lib/commonjs/utils/mediaQueries.js.map +1 -0
- package/lib/{module/types/common.js.map → commonjs/utils/module.d.js.map} +1 -1
- package/lib/commonjs/utils/normalizeStyles.js +10 -0
- package/lib/commonjs/utils/normalizeStyles.js.map +1 -0
- package/lib/commonjs/{normalizer/normalizeStyle.js → utils/normalizeStyles.web.js} +5 -5
- package/lib/commonjs/utils/normalizeStyles.web.js.map +1 -0
- package/lib/commonjs/{normalizer → utils}/normalizer.js +3 -2
- package/lib/commonjs/utils/normalizer.js.map +1 -0
- package/lib/commonjs/utils/styles.js +72 -45
- package/lib/commonjs/utils/styles.js.map +1 -1
- package/lib/module/UnistylesTheme.js +12 -0
- package/lib/module/UnistylesTheme.js.map +1 -0
- package/lib/module/createUnistyles.js +50 -0
- package/lib/module/createUnistyles.js.map +1 -0
- package/lib/module/hooks/index.js +1 -4
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useDimensions.js +3 -0
- package/lib/module/hooks/useDimensions.js.map +1 -0
- package/lib/module/hooks/useDimensions.web.js +27 -0
- package/lib/module/hooks/useDimensions.web.js.map +1 -0
- package/lib/module/index.js +2 -30
- package/lib/module/index.js.map +1 -1
- package/lib/module/types/index.js +0 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/module/types/mediaQueries.js +2 -0
- package/lib/{commonjs/types/stylesheet.js.map → module/types/mediaQueries.js.map} +1 -1
- package/lib/module/utils/breakpoints.js +120 -19
- package/lib/module/utils/breakpoints.js.map +1 -1
- package/lib/module/utils/common.js +12 -0
- package/lib/module/utils/common.js.map +1 -0
- package/lib/module/utils/index.js +6 -6
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/mediaQueries.js +176 -0
- package/lib/module/utils/mediaQueries.js.map +1 -0
- package/lib/{commonjs/types/variants.js.map → module/utils/module.d.js.map} +1 -1
- package/lib/module/utils/normalizeStyles.js +3 -0
- package/lib/module/utils/normalizeStyles.js.map +1 -0
- package/lib/module/{normalizer/normalizeStyle.js → utils/normalizeStyles.web.js} +3 -3
- package/lib/module/utils/normalizeStyles.web.js.map +1 -0
- package/lib/module/{normalizer → utils}/normalizer.js +3 -2
- package/lib/module/utils/normalizer.js.map +1 -0
- package/lib/module/utils/styles.js +72 -44
- package/lib/module/utils/styles.js.map +1 -1
- package/lib/typescript/examples/expo/src/App.d.ts +3 -0
- package/lib/typescript/examples/expo/src/App.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/examples/Breakpoints.d.ts +3 -0
- package/lib/typescript/examples/expo/src/examples/Breakpoints.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/examples/EmptyStyles.d.ts +3 -0
- package/lib/typescript/examples/expo/src/examples/EmptyStyles.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/examples/Extreme.d.ts +7 -0
- package/lib/typescript/examples/expo/src/examples/Extreme.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/examples/MediaQueries.d.ts +3 -0
- package/lib/typescript/examples/expo/src/examples/MediaQueries.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/examples/Memoization.d.ts +3 -0
- package/lib/typescript/examples/expo/src/examples/Memoization.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/examples/Minimal.d.ts +3 -0
- package/lib/typescript/examples/expo/src/examples/Minimal.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/examples/MinimalWithCreateStyleSheet.d.ts +3 -0
- package/lib/typescript/examples/expo/src/examples/MinimalWithCreateStyleSheet.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/examples/PlatformColors.d.ts +3 -0
- package/lib/typescript/examples/expo/src/examples/PlatformColors.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/examples/Theme.d.ts +3 -0
- package/lib/typescript/examples/expo/src/examples/Theme.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/examples/index.d.ts +9 -0
- package/lib/typescript/examples/expo/src/examples/index.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/index.d.ts +2 -0
- package/lib/typescript/examples/expo/src/index.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/styles/breakpoints.d.ts +8 -0
- package/lib/typescript/examples/expo/src/styles/breakpoints.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/styles/index.d.ts +46 -0
- package/lib/typescript/examples/expo/src/styles/index.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/styles/theme.d.ts +24 -0
- package/lib/typescript/examples/expo/src/styles/theme.d.ts.map +1 -0
- package/lib/typescript/src/UnistylesTheme.d.ts +9 -0
- package/lib/typescript/src/UnistylesTheme.d.ts.map +1 -0
- package/lib/typescript/src/createUnistyles.d.ts +10 -0
- package/lib/typescript/src/createUnistyles.d.ts.map +1 -0
- package/lib/typescript/src/hooks/index.d.ts +1 -4
- package/lib/typescript/src/hooks/index.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useDimensions.d.ts +3 -0
- package/lib/typescript/src/hooks/useDimensions.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useDimensions.web.d.ts +3 -0
- package/lib/typescript/src/hooks/useDimensions.web.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +2 -76
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types/breakpoints.d.ts +17 -25
- package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/types/core.d.ts +25 -11
- package/lib/typescript/src/types/core.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +2 -7
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/lib/typescript/src/types/mediaQueries.d.ts +8 -0
- package/lib/typescript/src/types/mediaQueries.d.ts.map +1 -0
- package/lib/typescript/src/utils/breakpoints.d.ts +62 -2
- package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/utils/common.d.ts +7 -0
- package/lib/typescript/src/utils/common.d.ts.map +1 -0
- package/lib/typescript/src/utils/index.d.ts +6 -7
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/mediaQueries.d.ts +130 -0
- package/lib/typescript/src/utils/mediaQueries.d.ts.map +1 -0
- package/lib/typescript/src/utils/normalizeStyles.d.ts +2 -0
- package/lib/typescript/src/utils/normalizeStyles.d.ts.map +1 -0
- package/lib/typescript/src/utils/normalizeStyles.web.d.ts +5 -0
- package/lib/typescript/src/utils/normalizeStyles.web.d.ts.map +1 -0
- package/lib/typescript/src/utils/normalizer.d.ts.map +1 -0
- package/lib/typescript/src/utils/styles.d.ts +49 -3
- package/lib/typescript/src/utils/styles.d.ts.map +1 -1
- package/package.json +25 -46
- package/src/UnistylesTheme.tsx +17 -0
- package/src/__tests__/createUnistyles.spec.tsx +192 -0
- package/src/createUnistyles.ts +70 -0
- package/src/hooks/index.ts +1 -4
- package/src/hooks/useDimensions.ts +4 -0
- package/src/hooks/useDimensions.web.ts +34 -0
- package/src/index.ts +2 -50
- package/src/types/breakpoints.ts +33 -58
- package/src/types/core.ts +36 -11
- package/src/types/index.ts +7 -12
- package/src/types/mediaQueries.ts +10 -0
- package/src/utils/breakpoints.ts +124 -28
- package/src/utils/common.ts +14 -0
- package/src/utils/index.ts +13 -7
- package/src/utils/mediaQueries.ts +201 -0
- package/src/utils/normalizeStyles.ts +2 -0
- package/src/{normalizer/normalizeStyle.ts → utils/normalizeStyles.web.ts} +3 -3
- package/src/{normalizer → utils}/normalizer.ts +4 -5
- package/src/utils/styles.ts +102 -54
- package/android/CMakeLists.txt +0 -27
- package/android/build.gradle +0 -75
- package/android/src/main/cxx/cpp-adapter.cpp +0 -132
- package/android/src/main/java/com/unistyles/UnistylesModule.kt +0 -189
- package/android/src/main/java/com/unistyles/UnistylesPackage.kt +0 -18
- package/cxx/UnistylesRuntime.cpp +0 -318
- package/cxx/UnistylesRuntime.h +0 -74
- package/ios/UnistylesHelpers.h +0 -3
- package/ios/UnistylesHelpers.mm +0 -5
- package/ios/UnistylesModule.h +0 -16
- package/ios/UnistylesModule.mm +0 -138
- package/ios/platform/Platform_iOS.h +0 -21
- package/ios/platform/Platform_iOS.mm +0 -132
- package/ios/platform/Platform_macOS.h +0 -20
- package/ios/platform/Platform_macOS.mm +0 -83
- package/lib/commonjs/common.js +0 -60
- package/lib/commonjs/common.js.map +0 -1
- package/lib/commonjs/core/UnistyleRegistry.js +0 -94
- package/lib/commonjs/core/UnistyleRegistry.js.map +0 -1
- package/lib/commonjs/core/Unistyles.js +0 -32
- package/lib/commonjs/core/Unistyles.js.map +0 -1
- package/lib/commonjs/core/UnistylesModule.js +0 -197
- package/lib/commonjs/core/UnistylesModule.js.map +0 -1
- package/lib/commonjs/core/UnistylesModule.native.js +0 -9
- package/lib/commonjs/core/UnistylesModule.native.js.map +0 -1
- package/lib/commonjs/core/UnistylesRuntime.js +0 -140
- package/lib/commonjs/core/UnistylesRuntime.js.map +0 -1
- package/lib/commonjs/core/index.js +0 -13
- package/lib/commonjs/core/index.js.map +0 -1
- package/lib/commonjs/createStyleSheet.js +0 -14
- package/lib/commonjs/createStyleSheet.js.map +0 -1
- package/lib/commonjs/global.js +0 -2
- package/lib/commonjs/global.js.map +0 -1
- package/lib/commonjs/hooks/useCSS.js +0 -44
- package/lib/commonjs/hooks/useCSS.js.map +0 -1
- package/lib/commonjs/hooks/useCSS.native.js +0 -9
- package/lib/commonjs/hooks/useCSS.native.js.map +0 -1
- package/lib/commonjs/hooks/useInitialTheme.js +0 -17
- package/lib/commonjs/hooks/useInitialTheme.js.map +0 -1
- package/lib/commonjs/hooks/useUnistyles.js +0 -64
- package/lib/commonjs/hooks/useUnistyles.js.map +0 -1
- package/lib/commonjs/hooks/useVariants.js +0 -14
- package/lib/commonjs/hooks/useVariants.js.map +0 -1
- package/lib/commonjs/normalizer/index.js +0 -32
- package/lib/commonjs/normalizer/index.js.map +0 -1
- package/lib/commonjs/normalizer/module.d.js.map +0 -1
- package/lib/commonjs/normalizer/normalizeStyle.js.map +0 -1
- package/lib/commonjs/normalizer/normalizer.js.map +0 -1
- package/lib/commonjs/normalizer/normalizer.macos.js +0 -3
- package/lib/commonjs/normalizer/normalizer.macos.js.map +0 -1
- package/lib/commonjs/plugins/cssMediaQueriesPlugin.js +0 -14
- package/lib/commonjs/plugins/cssMediaQueriesPlugin.js.map +0 -1
- package/lib/commonjs/plugins/index.js +0 -20
- package/lib/commonjs/plugins/index.js.map +0 -1
- package/lib/commonjs/plugins/normalizeWebStylesPlugin.js +0 -12
- package/lib/commonjs/plugins/normalizeWebStylesPlugin.js.map +0 -1
- package/lib/commonjs/types/common.js +0 -2
- package/lib/commonjs/types/common.js.map +0 -1
- package/lib/commonjs/types/plugin.js +0 -6
- package/lib/commonjs/types/plugin.js.map +0 -1
- package/lib/commonjs/types/stylesheet.js +0 -6
- package/lib/commonjs/types/unistyles.js +0 -6
- package/lib/commonjs/types/variants.js +0 -2
- package/lib/commonjs/useStyles.js +0 -47
- package/lib/commonjs/useStyles.js.map +0 -1
- package/lib/commonjs/utils/cssMediaQuery.js +0 -244
- package/lib/commonjs/utils/cssMediaQuery.js.map +0 -1
- package/lib/commonjs/utils/generateId.js +0 -15
- package/lib/commonjs/utils/generateId.js.map +0 -1
- package/lib/commonjs/utils/hash32.js +0 -43
- package/lib/commonjs/utils/hash32.js.map +0 -1
- package/lib/commonjs/utils/mq.js +0 -38
- package/lib/commonjs/utils/mq.js.map +0 -1
- package/lib/commonjs/utils/mqParser.js +0 -89
- package/lib/commonjs/utils/mqParser.js.map +0 -1
- package/lib/commonjs/utils/withPlugins.js +0 -15
- package/lib/commonjs/utils/withPlugins.js.map +0 -1
- package/lib/module/common.js +0 -53
- package/lib/module/common.js.map +0 -1
- package/lib/module/core/UnistyleRegistry.js +0 -87
- package/lib/module/core/UnistyleRegistry.js.map +0 -1
- package/lib/module/core/Unistyles.js +0 -26
- package/lib/module/core/Unistyles.js.map +0 -1
- package/lib/module/core/UnistylesModule.js +0 -190
- package/lib/module/core/UnistylesModule.js.map +0 -1
- package/lib/module/core/UnistylesModule.native.js +0 -3
- package/lib/module/core/UnistylesModule.native.js.map +0 -1
- package/lib/module/core/UnistylesRuntime.js +0 -133
- package/lib/module/core/UnistylesRuntime.js.map +0 -1
- package/lib/module/core/index.js +0 -2
- package/lib/module/core/index.js.map +0 -1
- package/lib/module/createStyleSheet.js +0 -7
- package/lib/module/createStyleSheet.js.map +0 -1
- package/lib/module/global.js +0 -2
- package/lib/module/global.js.map +0 -1
- package/lib/module/hooks/useCSS.js +0 -37
- package/lib/module/hooks/useCSS.js.map +0 -1
- package/lib/module/hooks/useCSS.native.js +0 -2
- package/lib/module/hooks/useCSS.native.js.map +0 -1
- package/lib/module/hooks/useInitialTheme.js +0 -10
- package/lib/module/hooks/useInitialTheme.js.map +0 -1
- package/lib/module/hooks/useUnistyles.js +0 -57
- package/lib/module/hooks/useUnistyles.js.map +0 -1
- package/lib/module/hooks/useVariants.js +0 -7
- package/lib/module/hooks/useVariants.js.map +0 -1
- package/lib/module/normalizer/index.js +0 -3
- package/lib/module/normalizer/index.js.map +0 -1
- package/lib/module/normalizer/module.d.js.map +0 -1
- package/lib/module/normalizer/normalizeStyle.js.map +0 -1
- package/lib/module/normalizer/normalizer.js.map +0 -1
- package/lib/module/normalizer/normalizer.macos.js +0 -2
- package/lib/module/normalizer/normalizer.macos.js.map +0 -1
- package/lib/module/plugins/cssMediaQueriesPlugin.js +0 -7
- package/lib/module/plugins/cssMediaQueriesPlugin.js.map +0 -1
- package/lib/module/plugins/index.js +0 -3
- package/lib/module/plugins/index.js.map +0 -1
- package/lib/module/plugins/normalizeWebStylesPlugin.js +0 -6
- package/lib/module/plugins/normalizeWebStylesPlugin.js.map +0 -1
- package/lib/module/types/common.js +0 -2
- package/lib/module/types/plugin.js +0 -2
- package/lib/module/types/plugin.js.map +0 -1
- package/lib/module/types/stylesheet.js +0 -2
- package/lib/module/types/stylesheet.js.map +0 -1
- package/lib/module/types/unistyles.js +0 -2
- package/lib/module/types/unistyles.js.map +0 -1
- package/lib/module/types/variants.js +0 -2
- package/lib/module/types/variants.js.map +0 -1
- package/lib/module/useStyles.js +0 -40
- package/lib/module/useStyles.js.map +0 -1
- package/lib/module/utils/cssMediaQuery.js +0 -237
- package/lib/module/utils/cssMediaQuery.js.map +0 -1
- package/lib/module/utils/generateId.js +0 -7
- package/lib/module/utils/generateId.js.map +0 -1
- package/lib/module/utils/hash32.js +0 -36
- package/lib/module/utils/hash32.js.map +0 -1
- package/lib/module/utils/mq.js +0 -32
- package/lib/module/utils/mq.js.map +0 -1
- package/lib/module/utils/mqParser.js +0 -78
- package/lib/module/utils/mqParser.js.map +0 -1
- package/lib/module/utils/withPlugins.js +0 -8
- package/lib/module/utils/withPlugins.js.map +0 -1
- package/lib/typescript/src/common.d.ts +0 -46
- package/lib/typescript/src/common.d.ts.map +0 -1
- package/lib/typescript/src/core/UnistyleRegistry.d.ts +0 -56
- package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +0 -1
- package/lib/typescript/src/core/Unistyles.d.ts +0 -13
- package/lib/typescript/src/core/Unistyles.d.ts.map +0 -1
- package/lib/typescript/src/core/UnistylesModule.d.ts +0 -19
- package/lib/typescript/src/core/UnistylesModule.d.ts.map +0 -1
- package/lib/typescript/src/core/UnistylesModule.native.d.ts +0 -6
- package/lib/typescript/src/core/UnistylesModule.native.d.ts.map +0 -1
- package/lib/typescript/src/core/UnistylesRuntime.d.ts +0 -81
- package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +0 -1
- package/lib/typescript/src/core/index.d.ts +0 -3
- package/lib/typescript/src/core/index.d.ts.map +0 -1
- package/lib/typescript/src/createStyleSheet.d.ts +0 -8
- package/lib/typescript/src/createStyleSheet.d.ts.map +0 -1
- package/lib/typescript/src/global.d.ts +0 -7
- package/lib/typescript/src/global.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useCSS.d.ts +0 -3
- package/lib/typescript/src/hooks/useCSS.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useCSS.native.d.ts +0 -3
- package/lib/typescript/src/hooks/useCSS.native.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useInitialTheme.d.ts +0 -3
- package/lib/typescript/src/hooks/useInitialTheme.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useUnistyles.d.ts +0 -14
- package/lib/typescript/src/hooks/useUnistyles.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useVariants.d.ts +0 -3
- package/lib/typescript/src/hooks/useVariants.d.ts.map +0 -1
- package/lib/typescript/src/normalizer/index.d.ts +0 -3
- package/lib/typescript/src/normalizer/index.d.ts.map +0 -1
- package/lib/typescript/src/normalizer/normalizeStyle.d.ts +0 -3
- package/lib/typescript/src/normalizer/normalizeStyle.d.ts.map +0 -1
- package/lib/typescript/src/normalizer/normalizer.d.ts.map +0 -1
- package/lib/typescript/src/normalizer/normalizer.macos.d.ts +0 -1
- package/lib/typescript/src/normalizer/normalizer.macos.d.ts.map +0 -1
- package/lib/typescript/src/plugins/cssMediaQueriesPlugin.d.ts +0 -3
- package/lib/typescript/src/plugins/cssMediaQueriesPlugin.d.ts.map +0 -1
- package/lib/typescript/src/plugins/index.d.ts +0 -3
- package/lib/typescript/src/plugins/index.d.ts.map +0 -1
- package/lib/typescript/src/plugins/normalizeWebStylesPlugin.d.ts +0 -3
- package/lib/typescript/src/plugins/normalizeWebStylesPlugin.d.ts.map +0 -1
- package/lib/typescript/src/types/common.d.ts +0 -3
- package/lib/typescript/src/types/common.d.ts.map +0 -1
- package/lib/typescript/src/types/plugin.d.ts +0 -7
- package/lib/typescript/src/types/plugin.d.ts.map +0 -1
- package/lib/typescript/src/types/stylesheet.d.ts +0 -40
- package/lib/typescript/src/types/stylesheet.d.ts.map +0 -1
- package/lib/typescript/src/types/unistyles.d.ts +0 -53
- package/lib/typescript/src/types/unistyles.d.ts.map +0 -1
- package/lib/typescript/src/types/variants.d.ts +0 -14
- package/lib/typescript/src/types/variants.d.ts.map +0 -1
- package/lib/typescript/src/useStyles.d.ts +0 -16
- package/lib/typescript/src/useStyles.d.ts.map +0 -1
- package/lib/typescript/src/utils/cssMediaQuery.d.ts +0 -4
- package/lib/typescript/src/utils/cssMediaQuery.d.ts.map +0 -1
- package/lib/typescript/src/utils/generateId.d.ts +0 -2
- package/lib/typescript/src/utils/generateId.d.ts.map +0 -1
- package/lib/typescript/src/utils/hash32.d.ts +0 -2
- package/lib/typescript/src/utils/hash32.d.ts.map +0 -1
- package/lib/typescript/src/utils/mq.d.ts +0 -26
- package/lib/typescript/src/utils/mq.d.ts.map +0 -1
- package/lib/typescript/src/utils/mqParser.d.ts +0 -16
- package/lib/typescript/src/utils/mqParser.d.ts.map +0 -1
- package/lib/typescript/src/utils/withPlugins.d.ts +0 -3
- package/lib/typescript/src/utils/withPlugins.d.ts.map +0 -1
- package/react-native-unistyles.podspec +0 -22
- package/src/__tests__/mocks.ts +0 -24
- package/src/common.ts +0 -55
- package/src/core/UnistyleRegistry.ts +0 -108
- package/src/core/Unistyles.ts +0 -35
- package/src/core/UnistylesModule.native.ts +0 -7
- package/src/core/UnistylesModule.ts +0 -230
- package/src/core/UnistylesRuntime.ts +0 -135
- package/src/core/index.ts +0 -2
- package/src/createStyleSheet.ts +0 -8
- package/src/global.ts +0 -6
- package/src/hooks/useCSS.native.ts +0 -3
- package/src/hooks/useCSS.ts +0 -51
- package/src/hooks/useInitialTheme.ts +0 -11
- package/src/hooks/useUnistyles.ts +0 -64
- package/src/hooks/useVariants.ts +0 -10
- package/src/normalizer/index.ts +0 -2
- package/src/normalizer/normalizer.macos.ts +0 -1
- package/src/plugins/cssMediaQueriesPlugin.ts +0 -8
- package/src/plugins/index.ts +0 -2
- package/src/plugins/normalizeWebStylesPlugin.ts +0 -7
- package/src/types/common.ts +0 -2
- package/src/types/plugin.ts +0 -7
- package/src/types/stylesheet.ts +0 -49
- package/src/types/unistyles.ts +0 -63
- package/src/types/variants.ts +0 -19
- package/src/useStyles.ts +0 -60
- package/src/utils/cssMediaQuery.ts +0 -268
- package/src/utils/generateId.ts +0 -10
- package/src/utils/hash32.ts +0 -53
- package/src/utils/mq.ts +0 -57
- package/src/utils/mqParser.ts +0 -99
- package/src/utils/withPlugins.ts +0 -13
- /package/lib/commonjs/{normalizer → utils}/module.d.js +0 -0
- /package/lib/module/{normalizer → utils}/module.d.js +0 -0
- /package/lib/typescript/src/{normalizer → utils}/normalizer.d.ts +0 -0
- /package/src/{normalizer → utils}/module.d.ts +0 -0
@@ -1,26 +0,0 @@
|
|
1
|
-
import { UnistylesModule } from './UnistylesModule';
|
2
|
-
import { UnistylesRuntime } from './UnistylesRuntime';
|
3
|
-
import { UnistyleRegistry } from './UnistyleRegistry';
|
4
|
-
import { UnistylesError, isWeb } from '../common';
|
5
|
-
class Unistyles {
|
6
|
-
constructor() {
|
7
|
-
const isInstalled = UnistylesModule?.install() ?? false;
|
8
|
-
if (!isInstalled) {
|
9
|
-
throw new Error(UnistylesError.RuntimeUnavailable);
|
10
|
-
}
|
11
|
-
|
12
|
-
// @ts-ignore
|
13
|
-
// eslint-disable-next-line no-undef
|
14
|
-
this._bridge = (isWeb ? globalThis : global).__UNISTYLES__;
|
15
|
-
this._registry = new UnistyleRegistry(this._bridge);
|
16
|
-
this._runtime = new UnistylesRuntime(this._bridge, this._registry);
|
17
|
-
}
|
18
|
-
get registry() {
|
19
|
-
return this._registry;
|
20
|
-
}
|
21
|
-
get runtime() {
|
22
|
-
return this._runtime;
|
23
|
-
}
|
24
|
-
}
|
25
|
-
export const unistyles = new Unistyles();
|
26
|
-
//# sourceMappingURL=Unistyles.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["UnistylesModule","UnistylesRuntime","UnistyleRegistry","UnistylesError","isWeb","Unistyles","constructor","isInstalled","install","Error","RuntimeUnavailable","_bridge","globalThis","global","__UNISTYLES__","_registry","_runtime","registry","runtime","unistyles"],"sourceRoot":"../../../src","sources":["core/Unistyles.ts"],"mappings":"AAAA,SAASA,eAAe,QAAQ,mBAAmB;AACnD,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,gBAAgB,QAAQ,oBAAoB;AAErD,SAASC,cAAc,EAAEC,KAAK,QAAQ,WAAW;AAEjD,MAAMC,SAAS,CAAC;EAKZC,WAAWA,CAAA,EAAG;IACV,MAAMC,WAAW,GAAGP,eAAe,EAAEQ,OAAO,CAAC,CAAC,IAAI,KAAK;IAEvD,IAAI,CAACD,WAAW,EAAE;MACd,MAAM,IAAIE,KAAK,CAACN,cAAc,CAACO,kBAAkB,CAAC;IACtD;;IAEA;IACA;IACA,IAAI,CAACC,OAAO,GAAG,CAACP,KAAK,GAAGQ,UAAU,GAAGC,MAAM,EAAEC,aAAgC;IAC7E,IAAI,CAACC,SAAS,GAAG,IAAIb,gBAAgB,CAAC,IAAI,CAACS,OAAO,CAAC;IACnD,IAAI,CAACK,QAAQ,GAAG,IAAIf,gBAAgB,CAAC,IAAI,CAACU,OAAO,EAAE,IAAI,CAACI,SAAS,CAAC;EACtE;EAEA,IAAWE,QAAQA,CAAA,EAAG;IAClB,OAAO,IAAI,CAACF,SAAS;EACzB;EAEA,IAAWG,OAAOA,CAAA,EAAG;IACjB,OAAO,IAAI,CAACF,QAAQ;EACxB;AACJ;AAEA,OAAO,MAAMG,SAAS,GAAG,IAAId,SAAS,CAAC,CAAC"}
|
@@ -1,190 +0,0 @@
|
|
1
|
-
import { NativeEventEmitter, NativeModules } from 'react-native';
|
2
|
-
import { normalizeWebStylesPlugin } from '../plugins';
|
3
|
-
import { isServer } from '../common';
|
4
|
-
export class UnistylesBridgeWeb {
|
5
|
-
#timerRef = undefined;
|
6
|
-
#hasAdaptiveThemes = false;
|
7
|
-
#supportsAutomaticColorScheme = false;
|
8
|
-
#screenWidth = isServer ? undefined : window.innerWidth;
|
9
|
-
#screenHeight = isServer ? undefined : window.innerHeight;
|
10
|
-
#themes = [];
|
11
|
-
#breakpoints = {};
|
12
|
-
#colorScheme = this.getPreferredColorScheme();
|
13
|
-
#themeName = '';
|
14
|
-
#enabledPlugins = [normalizeWebStylesPlugin.name];
|
15
|
-
#unistylesEvents = new NativeEventEmitter(NativeModules.Unistyles);
|
16
|
-
#sortedBreakpointPairs = [];
|
17
|
-
#breakpoint = '';
|
18
|
-
#contentSizeCategory = 'unspecified';
|
19
|
-
constructor() {
|
20
|
-
if (!isServer) {
|
21
|
-
this.setupListeners();
|
22
|
-
this.#screenWidth = window.innerWidth;
|
23
|
-
this.#screenHeight = window.innerHeight;
|
24
|
-
}
|
25
|
-
}
|
26
|
-
install() {
|
27
|
-
// @ts-ignore
|
28
|
-
// eslint-disable-next-line no-undef
|
29
|
-
globalThis.__UNISTYLES__ = new Proxy({}, {
|
30
|
-
get: (_target, prop) => {
|
31
|
-
switch (prop) {
|
32
|
-
case 'themeName':
|
33
|
-
return this.getTheme();
|
34
|
-
case 'screenWidth':
|
35
|
-
return this.#screenWidth;
|
36
|
-
case 'screenHeight':
|
37
|
-
return this.#screenHeight;
|
38
|
-
case 'contentSizeCategory':
|
39
|
-
return this.#contentSizeCategory;
|
40
|
-
case 'breakpoint':
|
41
|
-
return this.#breakpoint || undefined;
|
42
|
-
case 'breakpoints':
|
43
|
-
return this.#breakpoints;
|
44
|
-
case 'hasAdaptiveThemes':
|
45
|
-
return this.#hasAdaptiveThemes;
|
46
|
-
case 'sortedBreakpointPairs':
|
47
|
-
return this.#sortedBreakpointPairs;
|
48
|
-
case 'enabledPlugins':
|
49
|
-
return this.#enabledPlugins;
|
50
|
-
case 'colorScheme':
|
51
|
-
return this.#colorScheme;
|
52
|
-
case 'useTheme':
|
53
|
-
return themeName => this.useTheme(themeName);
|
54
|
-
case 'useBreakpoints':
|
55
|
-
return breakpoints => this.useBreakpoints(breakpoints);
|
56
|
-
case 'useAdaptiveThemes':
|
57
|
-
return enable => this.useAdaptiveThemes(enable);
|
58
|
-
case 'addPlugin':
|
59
|
-
return (pluginName, notify) => this.addPlugin(pluginName, notify);
|
60
|
-
case 'removePlugin':
|
61
|
-
return pluginName => this.removePlugin(pluginName);
|
62
|
-
default:
|
63
|
-
return Reflect.get(this, prop);
|
64
|
-
}
|
65
|
-
},
|
66
|
-
set: (target, prop, newValue, receiver) => {
|
67
|
-
switch (prop) {
|
68
|
-
case 'themes':
|
69
|
-
{
|
70
|
-
this.#themes = newValue;
|
71
|
-
this.#supportsAutomaticColorScheme = newValue.includes('light') && newValue.includes('dark');
|
72
|
-
return true;
|
73
|
-
}
|
74
|
-
case 'themeName':
|
75
|
-
{
|
76
|
-
this.#themeName = newValue;
|
77
|
-
this.emitThemeChange();
|
78
|
-
return true;
|
79
|
-
}
|
80
|
-
default:
|
81
|
-
return Reflect.set(target, prop, newValue, receiver);
|
82
|
-
}
|
83
|
-
}
|
84
|
-
});
|
85
|
-
return true;
|
86
|
-
}
|
87
|
-
useTheme(themeName) {
|
88
|
-
this.#themeName = themeName;
|
89
|
-
this.emitThemeChange();
|
90
|
-
}
|
91
|
-
useBreakpoints(breakpoints) {
|
92
|
-
this.#breakpoints = breakpoints;
|
93
|
-
this.#sortedBreakpointPairs = Object.entries(breakpoints).sort(([, a], [, b]) => (a ?? 0) - (b ?? 0));
|
94
|
-
if (!isServer) {
|
95
|
-
this.#breakpoint = this.getBreakpointFromScreenWidth(this.#screenWidth);
|
96
|
-
}
|
97
|
-
}
|
98
|
-
useAdaptiveThemes(enable) {
|
99
|
-
this.#hasAdaptiveThemes = enable;
|
100
|
-
if (!this.#hasAdaptiveThemes || !this.#supportsAutomaticColorScheme) {
|
101
|
-
return;
|
102
|
-
}
|
103
|
-
if (this.#themeName !== this.#colorScheme) {
|
104
|
-
this.#themeName = this.#colorScheme;
|
105
|
-
this.emitThemeChange();
|
106
|
-
}
|
107
|
-
}
|
108
|
-
addPlugin(pluginName, notify) {
|
109
|
-
this.#enabledPlugins = [pluginName].concat(this.#enabledPlugins);
|
110
|
-
if (notify) {
|
111
|
-
this.emitPluginChange();
|
112
|
-
}
|
113
|
-
}
|
114
|
-
removePlugin(pluginName) {
|
115
|
-
this.#enabledPlugins = this.#enabledPlugins.filter(name => name !== pluginName);
|
116
|
-
this.emitPluginChange();
|
117
|
-
}
|
118
|
-
getTheme() {
|
119
|
-
if (this.#themes.length === 1) {
|
120
|
-
return this.#themes.at(0);
|
121
|
-
}
|
122
|
-
return this.#themeName;
|
123
|
-
}
|
124
|
-
setupListeners() {
|
125
|
-
window.addEventListener('resize', () => {
|
126
|
-
clearTimeout(this.#timerRef);
|
127
|
-
this.#timerRef = setTimeout(() => {
|
128
|
-
this.#screenWidth = window.innerWidth;
|
129
|
-
this.#screenHeight = window.innerHeight;
|
130
|
-
this.#breakpoint = this.getBreakpointFromScreenWidth(this.#screenWidth);
|
131
|
-
this.emitLayoutChange();
|
132
|
-
}, 100);
|
133
|
-
});
|
134
|
-
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
|
135
|
-
this.#colorScheme = event.matches ? 'dark' : 'light';
|
136
|
-
if (!this.#supportsAutomaticColorScheme || !this.#hasAdaptiveThemes) {
|
137
|
-
return;
|
138
|
-
}
|
139
|
-
if (this.#colorScheme !== this.#themeName) {
|
140
|
-
this.#themeName = this.#colorScheme;
|
141
|
-
this.emitThemeChange();
|
142
|
-
}
|
143
|
-
});
|
144
|
-
}
|
145
|
-
getBreakpointFromScreenWidth(width) {
|
146
|
-
const breakpoint = this.#sortedBreakpointPairs.find(([, value], index, otherBreakpoints) => {
|
147
|
-
const minVal = value;
|
148
|
-
const maxVal = otherBreakpoints[index + 1]?.[1];
|
149
|
-
if (!maxVal) {
|
150
|
-
return true;
|
151
|
-
}
|
152
|
-
return width >= minVal && width < maxVal;
|
153
|
-
});
|
154
|
-
return breakpoint?.at(0);
|
155
|
-
}
|
156
|
-
getPreferredColorScheme() {
|
157
|
-
if (!isServer && window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
158
|
-
return 'dark';
|
159
|
-
}
|
160
|
-
return 'light';
|
161
|
-
}
|
162
|
-
emitPluginChange() {
|
163
|
-
this.#unistylesEvents.emit('__unistylesOnChange', {
|
164
|
-
type: 'plugin'
|
165
|
-
});
|
166
|
-
}
|
167
|
-
emitThemeChange() {
|
168
|
-
this.#unistylesEvents.emit('__unistylesOnChange', {
|
169
|
-
type: 'theme',
|
170
|
-
payload: {
|
171
|
-
themeName: this.#themeName
|
172
|
-
}
|
173
|
-
});
|
174
|
-
}
|
175
|
-
emitLayoutChange() {
|
176
|
-
this.#unistylesEvents.emit('__unistylesOnChange', {
|
177
|
-
type: 'layout',
|
178
|
-
payload: {
|
179
|
-
breakpoint: this.#breakpoint,
|
180
|
-
orientation: this.#screenWidth > this.#screenHeight ? 'landscape' : 'portrait',
|
181
|
-
screen: {
|
182
|
-
width: this.#screenWidth,
|
183
|
-
height: this.#screenHeight
|
184
|
-
}
|
185
|
-
}
|
186
|
-
});
|
187
|
-
}
|
188
|
-
}
|
189
|
-
export const UnistylesModule = new UnistylesBridgeWeb();
|
190
|
-
//# sourceMappingURL=UnistylesModule.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["NativeEventEmitter","NativeModules","normalizeWebStylesPlugin","isServer","UnistylesBridgeWeb","timerRef","undefined","hasAdaptiveThemes","supportsAutomaticColorScheme","screenWidth","window","innerWidth","screenHeight","innerHeight","themes","breakpoints","colorScheme","getPreferredColorScheme","themeName","enabledPlugins","name","unistylesEvents","Unistyles","sortedBreakpointPairs","breakpoint","contentSizeCategory","constructor","setupListeners","install","globalThis","__UNISTYLES__","Proxy","get","_target","prop","getTheme","useTheme","useBreakpoints","enable","useAdaptiveThemes","pluginName","notify","addPlugin","removePlugin","Reflect","set","target","newValue","receiver","includes","emitThemeChange","Object","entries","sort","a","b","getBreakpointFromScreenWidth","concat","emitPluginChange","filter","length","at","addEventListener","clearTimeout","setTimeout","emitLayoutChange","matchMedia","event","matches","width","find","value","index","otherBreakpoints","minVal","maxVal","emit","type","payload","orientation","screen","height","UnistylesModule"],"sourceRoot":"../../../src","sources":["core/UnistylesModule.ts"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,aAAa,QAAQ,cAAc;AAGhE,SAASC,wBAAwB,QAAQ,YAAY;AACrD,SAASC,QAAQ,QAAQ,WAAW;AAEpC,OAAO,MAAMC,kBAAkB,CAAC;EAC5B,CAACC,QAAQ,GAAmCC,SAAS;EACrD,CAACC,iBAAiB,GAAY,KAAK;EACnC,CAACC,4BAA4B,GAAG,KAAK;EACrC,CAACC,WAAW,GAAGN,QAAQ,GAAGG,SAAS,GAAGI,MAAM,CAACC,UAAU;EACvD,CAACC,YAAY,GAAGT,QAAQ,GAAGG,SAAS,GAAGI,MAAM,CAACG,WAAW;EACzD,CAACC,MAAM,GAAiC,EAAE;EAC1C,CAACC,WAAW,GAAyB,CAAC,CAAC;EACvC,CAACC,WAAW,GAAoB,IAAI,CAACC,uBAAuB,CAAC,CAAC;E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U;QAC5BuD,WAAW,EAAG,IAAI,CAAC,CAACtE,WAAW,GAAe,IAAI,CAAC,CAACG,YAAuB,GACrE,WAAW,GACX,UAAU;QAChBoE,MAAM,EAAE;UACJX,KAAK,EAAE,IAAI,CAAC,CAAC5D,WAAW;UACxBwE,MAAM,EAAE,IAAI,CAAC,CAACrE;QAClB;MACJ;IACJ,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAMsE,eAAe,GAAG,IAAI9E,kBAAkB,CAAC,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["NativeModules","UnistylesModule","Unistyles"],"sourceRoot":"../../../src","sources":["core/UnistylesModule.native.ts"],"mappings":"AAAA,SAASA,aAAa,QAAQ,cAAc;AAM5C,OAAO,MAAMC,eAAe,GAAGD,aAAa,EAAEE,SAAkC"}
|
@@ -1,133 +0,0 @@
|
|
1
|
-
import { ScreenOrientation, UnistylesError } from '../common';
|
2
|
-
/**
|
3
|
-
* Utility to interact with the Unistyles during runtime
|
4
|
-
*/
|
5
|
-
export class UnistylesRuntime {
|
6
|
-
constructor(unistylesBridge, unistylesRegistry) {
|
7
|
-
this.unistylesBridge = unistylesBridge;
|
8
|
-
this.unistylesRegistry = unistylesRegistry;
|
9
|
-
}
|
10
|
-
|
11
|
-
/**
|
12
|
-
* Get the current color scheme
|
13
|
-
* @returns - The current color scheme
|
14
|
-
*/
|
15
|
-
get colorScheme() {
|
16
|
-
return this.unistylesBridge.colorScheme;
|
17
|
-
}
|
18
|
-
|
19
|
-
/**
|
20
|
-
* Get info about adaptive themes
|
21
|
-
* @returns - boolean indicating if the adaptive themes are enabled
|
22
|
-
*/
|
23
|
-
get hasAdaptiveThemes() {
|
24
|
-
return this.unistylesBridge.hasAdaptiveThemes;
|
25
|
-
}
|
26
|
-
|
27
|
-
/**
|
28
|
-
* Get the current theme name
|
29
|
-
* @returns - The current theme name
|
30
|
-
*/
|
31
|
-
get themeName() {
|
32
|
-
return this.unistylesBridge.themeName;
|
33
|
-
}
|
34
|
-
|
35
|
-
/**
|
36
|
-
* Get the current content size category
|
37
|
-
* @returns - The current content size category
|
38
|
-
*/
|
39
|
-
get contentSizeCategory() {
|
40
|
-
return this.unistylesBridge.contentSizeCategory;
|
41
|
-
}
|
42
|
-
|
43
|
-
/**
|
44
|
-
* Get the current breakpoint based on device size
|
45
|
-
* @returns - The current breakpoint
|
46
|
-
*/
|
47
|
-
get breakpoint() {
|
48
|
-
return this.unistylesBridge.breakpoint;
|
49
|
-
}
|
50
|
-
|
51
|
-
/**
|
52
|
-
* Get registered breakpoints with UnitylesRegistry
|
53
|
-
* @returns - The registered breakpoints
|
54
|
-
*/
|
55
|
-
get breakpoints() {
|
56
|
-
return this.unistylesRegistry.breakpoints;
|
57
|
-
}
|
58
|
-
|
59
|
-
/**
|
60
|
-
* Get the names of currently enabled plugins
|
61
|
-
* @returns - The names of currently enabled plugins
|
62
|
-
*/
|
63
|
-
get enabledPlugins() {
|
64
|
-
return this.unistylesBridge.enabledPlugins;
|
65
|
-
}
|
66
|
-
|
67
|
-
/**
|
68
|
-
* Get the screen size
|
69
|
-
* @returns - The screen size { width, height }
|
70
|
-
*/
|
71
|
-
get screen() {
|
72
|
-
return {
|
73
|
-
width: this.unistylesBridge.screenWidth,
|
74
|
-
height: this.unistylesBridge.screenHeight
|
75
|
-
};
|
76
|
-
}
|
77
|
-
|
78
|
-
/**
|
79
|
-
* Get the screen orientation
|
80
|
-
* @returns - The screen orientation
|
81
|
-
*/
|
82
|
-
get orientation() {
|
83
|
-
const {
|
84
|
-
width,
|
85
|
-
height
|
86
|
-
} = this.screen;
|
87
|
-
if (width > height) {
|
88
|
-
return ScreenOrientation.Landscape;
|
89
|
-
}
|
90
|
-
return ScreenOrientation.Portrait;
|
91
|
-
}
|
92
|
-
|
93
|
-
/**
|
94
|
-
* Switch to a different theme
|
95
|
-
* @param name - The name of the theme to switch to
|
96
|
-
* @returns - boolean indicating if the theme was switched
|
97
|
-
*/
|
98
|
-
setTheme = name => {
|
99
|
-
if (name === this.themeName) {
|
100
|
-
return;
|
101
|
-
}
|
102
|
-
if (this.unistylesRegistry.hasTheme(name)) {
|
103
|
-
this.unistylesBridge.useTheme(name);
|
104
|
-
return true;
|
105
|
-
}
|
106
|
-
throw new Error(UnistylesError.ThemeNotRegistered);
|
107
|
-
};
|
108
|
-
|
109
|
-
/**
|
110
|
-
* Enable or disable adaptive themes
|
111
|
-
* @param enable - boolean indicating if adaptive themes should be enabled
|
112
|
-
*/
|
113
|
-
setAdaptiveThemes = enable => {
|
114
|
-
this.unistylesBridge.useAdaptiveThemes(enable);
|
115
|
-
};
|
116
|
-
|
117
|
-
/**
|
118
|
-
* Enable a plugin
|
119
|
-
* @param plugin - Plugin that conforms to UnistylesPlugin interface
|
120
|
-
*/
|
121
|
-
addPlugin = plugin => {
|
122
|
-
this.unistylesRegistry.addPlugin(plugin);
|
123
|
-
};
|
124
|
-
|
125
|
-
/**
|
126
|
-
* Disable a plugin
|
127
|
-
* @param plugin - Plugin that conforms to UnistylesPlugin interface
|
128
|
-
*/
|
129
|
-
removePlugin = plugin => {
|
130
|
-
this.unistylesRegistry.removePlugin(plugin);
|
131
|
-
};
|
132
|
-
}
|
133
|
-
//# sourceMappingURL=UnistylesRuntime.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["ScreenOrientation","UnistylesError","UnistylesRuntime","constructor","unistylesBridge","unistylesRegistry","colorScheme","hasAdaptiveThemes","themeName","contentSizeCategory","breakpoint","breakpoints","enabledPlugins","screen","width","screenWidth","height","screenHeight","orientation","Landscape","Portrait","setTheme","name","hasTheme","useTheme","Error","ThemeNotRegistered","setAdaptiveThemes","enable","useAdaptiveThemes","addPlugin","plugin","removePlugin"],"sourceRoot":"../../../src","sources":["core/UnistylesRuntime.ts"],"mappings":"AAAA,SAASA,iBAAiB,EAAEC,cAAc,QAAQ,WAAW;AAK7D;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,CAAC;EAC1BC,WAAWA,C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;IAEA,OAAOnB,iBAAiB,CAACoB,QAAQ;EACrC;;EAEA;AACJ;AACA;AACA;AACA;EACWC,QAAQ,GAAIC,IAA2B,IAAK;IAC/C,IAAIA,IAAI,KAAK,IAAI,CAACd,SAAS,EAAE;MACzB;IACJ;IAEA,IAAI,IAAI,CAACH,iBAAiB,CAACkB,QAAQ,CAACD,IAAI,CAAC,EAAE;MACvC,IAAI,CAAClB,eAAe,CAACoB,QAAQ,CAACF,IAAI,CAAC;MAEnC,OAAO,IAAI;IACf;IAEA,MAAM,IAAIG,KAAK,CAACxB,cAAc,CAACyB,kBAAkB,CAAC;EACtD,CAAC;;EAED;AACJ;AACA;AACA;EACWC,iBAAiB,GAAIC,MAAe,IAAK;IAC5C,IAAI,CAACxB,eAAe,CAACyB,iBAAiB,CAACD,MAAM,CAAC;EAClD,CAAC;;EAED;AACJ;AACA;AACA;EACWE,SAAS,GAAIC,MAAuB,IAAK;IAC5C,IAAI,CAAC1B,iBAAiB,CAACyB,SAAS,CAACC,MAAM,CAAC;EAC5C,CAAC;;EAED;AACJ;AACA;AACA;EACWC,YAAY,GAAID,MAAuB,IAAK;IAC/C,IAAI,CAAC1B,iBAAiB,CAAC2B,YAAY,CAACD,MAAM,CAAC;EAC/C,CAAC;AACL"}
|
package/lib/module/core/index.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["unistyles"],"sourceRoot":"../../../src","sources":["core/index.ts"],"mappings":"AAAA,SAASA,SAAS,QAAQ,aAAa"}
|
@@ -1,7 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Utility to create a stylesheet with superpowers
|
3
|
-
* Compatible with React Native StyleSheet.create
|
4
|
-
* @param stylesheet - The stylesheet with superpowers to be used
|
5
|
-
*/
|
6
|
-
export const createStyleSheet = stylesheet => stylesheet;
|
7
|
-
//# sourceMappingURL=createStyleSheet.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["createStyleSheet","stylesheet"],"sourceRoot":"../../src","sources":["createStyleSheet.ts"],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,gBAAgB,GAAyCC,UAAa,IAAQA,UAAU"}
|
package/lib/module/global.js
DELETED
package/lib/module/global.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../src","sources":["global.ts"],"mappings":""}
|
@@ -1,37 +0,0 @@
|
|
1
|
-
import { useInsertionEffect, useRef } from 'react';
|
2
|
-
import { unistyles } from '../core';
|
3
|
-
import { generateReactNativeWebId } from '../utils';
|
4
|
-
export const useCSS = stylesheet => {
|
5
|
-
const insertedIds = useRef([]);
|
6
|
-
useInsertionEffect(() => {
|
7
|
-
if (!unistyles.registry.config.experimentalCSSMediaQueries) {
|
8
|
-
return;
|
9
|
-
}
|
10
|
-
Object.entries(stylesheet).forEach(([_key, value]) => {
|
11
|
-
Object.entries(value).forEach(([prop, val]) => {
|
12
|
-
if (!val.toString().includes('@media')) {
|
13
|
-
return;
|
14
|
-
}
|
15
|
-
const id = generateReactNativeWebId(prop, '""');
|
16
|
-
if (insertedIds.current.includes(id)) {
|
17
|
-
return;
|
18
|
-
}
|
19
|
-
const style = document.createElement('style');
|
20
|
-
style.id = id;
|
21
|
-
style.innerHTML = val;
|
22
|
-
document.head.appendChild(style);
|
23
|
-
insertedIds.current = [...insertedIds.current, id];
|
24
|
-
});
|
25
|
-
});
|
26
|
-
return () => {
|
27
|
-
insertedIds.current.forEach(id => {
|
28
|
-
const style = document.getElementById(id);
|
29
|
-
if (style) {
|
30
|
-
style.remove();
|
31
|
-
}
|
32
|
-
});
|
33
|
-
insertedIds.current = [];
|
34
|
-
};
|
35
|
-
}, [stylesheet]);
|
36
|
-
};
|
37
|
-
//# sourceMappingURL=useCSS.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["useInsertionEffect","useRef","unistyles","generateReactNativeWebId","useCSS","stylesheet","insertedIds","registry","config","experimentalCSSMediaQueries","Object","entries","forEach","_key","value","prop","val","toString","includes","id","current","style","document","createElement","innerHTML","head","appendChild","getElementById","remove"],"sourceRoot":"../../../src","sources":["hooks/useCSS.ts"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,MAAM,QAAQ,OAAO;AAClD,SAASC,SAAS,QAAQ,SAAS;AAEnC,SAASC,wBAAwB,QAAQ,UAAU;AAEnD,OAAO,MAAMC,MAAM,GAAOC,UAAoC,IAAK;EAC/D,MAAMC,WAAW,GAAGL,MAAM,CAAgB,EAAE,CAAC;EAE7CD,kBAAkB,CAAC,MAAM;IACrB,IAAI,CAACE,SAAS,CAACK,QAAQ,CAACC,MAAM,CAACC,2BAA2B,EAAE;MACxD;IACJ;IAEAC,MAAM,CACDC,OAAO,CAACN,UAAU,CAAC,CACnBO,OAAO,CAAC,CAAC,CAACC,IAAI,EAAEC,KAAK,CAAC,KAAK;MACxBJ,MAAM,CAACC,OAAO,CAACG,KAAM,CAAC,CACjBF,OAAO,CAAC,CAAC,CAACG,IAAI,EAAEC,GAAG,CAAC,KAAK;QACtB,IAAI,CAACA,GAAG,CAACC,QAAQ,CAAC,CAAC,CAACC,QAAQ,CAAC,QAAQ,CAAC,EAAE;UACpC;QACJ;QAEA,MAAMC,EAAE,GAAGhB,wBAAwB,CAACY,IAAI,EAAE,IAAI,CAAC;QAE/C,IAAIT,WAAW,CAACc,OAAO,CAACF,QAAQ,CAACC,EAAE,CAAC,EAAE;UAClC;QACJ;QAEA,MAAME,KAAK,GAAGC,QAAQ,CAACC,aAAa,CAAC,OAAO,CAAC;QAE7CF,KAAK,CAACF,EAAE,GAAGA,EAAE;QACbE,KAAK,CAACG,SAAS,GAAGR,GAAG;QAErBM,QAAQ,CAACG,IAAI,CAACC,WAAW,CAACL,KAAK,CAAC;QAChCf,WAAW,CAACc,OAAO,GAAG,CAAC,GAAGd,WAAW,CAACc,OAAO,EAAED,EAAE,CAAC;MACtD,CAAC,CAAC;IACV,CAAC,CAAC;IAEN,OAAO,MAAM;MACTb,WAAW,CAACc,OAAO,CAACR,OAAO,CAACO,EAAE,IAAI;QAC9B,MAAME,KAAK,GAAGC,QAAQ,CAACK,cAAc,CAACR,EAAE,CAAC;QAEzC,IAAIE,KAAK,EAAE;UACPA,KAAK,CAACO,MAAM,CAAC,CAAC;QAClB;MACJ,CAAC,CAAC;MAEFtB,WAAW,CAACc,OAAO,GAAG,EAAE;IAC5B,CAAC;EACL,CAAC,EAAE,CAACf,UAAU,CAAC,CAAC;AACpB,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["useCSS","_stylesheet"],"sourceRoot":"../../../src","sources":["hooks/useCSS.native.ts"],"mappings":"AAEA,OAAO,MAAMA,MAAM,GAAOC,WAAqC,IAAW,CAAC,CAAC"}
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import { useMemo } from 'react';
|
2
|
-
import { unistyles } from '../core';
|
3
|
-
export const useInitialTheme = forName => {
|
4
|
-
useMemo(() => {
|
5
|
-
if (!unistyles.runtime.themeName) {
|
6
|
-
unistyles.runtime.setTheme(forName);
|
7
|
-
}
|
8
|
-
}, []);
|
9
|
-
};
|
10
|
-
//# sourceMappingURL=useInitialTheme.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["useMemo","unistyles","useInitialTheme","forName","runtime","themeName","setTheme"],"sourceRoot":"../../../src","sources":["hooks/useInitialTheme.ts"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,SAAS,QAAQ,SAAS;AAGnC,OAAO,MAAMC,eAAe,GAAIC,OAA8B,IAAK;EAC/DH,OAAO,CAAC,MAAM;IACV,IAAI,CAACC,SAAS,CAACG,OAAO,CAACC,SAAS,EAAE;MAC9BJ,SAAS,CAACG,OAAO,CAACE,QAAQ,CAACH,OAAO,CAAC;IACvC;EACJ,CAAC,EAAE,EAAE,CAAC;AACV,CAAC"}
|
@@ -1,57 +0,0 @@
|
|
1
|
-
import { NativeEventEmitter, NativeModules } from 'react-native';
|
2
|
-
import { useEffect, useState } from 'react';
|
3
|
-
import { unistyles } from '../core';
|
4
|
-
import { UnistylesEventType } from '../common';
|
5
|
-
const unistylesEvents = new NativeEventEmitter(NativeModules.Unistyles);
|
6
|
-
export const useUnistyles = () => {
|
7
|
-
const [plugins, setPlugins] = useState(unistyles.runtime.enabledPlugins);
|
8
|
-
const [theme, setTheme] = useState(unistyles.registry.getTheme(unistyles.runtime.themeName));
|
9
|
-
const [contentSizeCategory, setContentSizeCategory] = useState(unistyles.runtime.contentSizeCategory);
|
10
|
-
const [layout, setLayout] = useState({
|
11
|
-
breakpoint: unistyles.runtime.breakpoint,
|
12
|
-
orientation: unistyles.runtime.orientation,
|
13
|
-
screenSize: {
|
14
|
-
width: unistyles.runtime.screen.width,
|
15
|
-
height: unistyles.runtime.screen.height
|
16
|
-
}
|
17
|
-
});
|
18
|
-
useEffect(() => {
|
19
|
-
const subscription = unistylesEvents.addListener('__unistylesOnChange', event => {
|
20
|
-
switch (event.type) {
|
21
|
-
case UnistylesEventType.Theme:
|
22
|
-
{
|
23
|
-
const themeEvent = event;
|
24
|
-
return setTheme(unistyles.registry.getTheme(themeEvent.payload.themeName));
|
25
|
-
}
|
26
|
-
case UnistylesEventType.Layout:
|
27
|
-
{
|
28
|
-
const layoutEvent = event;
|
29
|
-
return setLayout({
|
30
|
-
breakpoint: layoutEvent.payload.breakpoint,
|
31
|
-
orientation: layoutEvent.payload.orientation,
|
32
|
-
screenSize: layoutEvent.payload.screen
|
33
|
-
});
|
34
|
-
}
|
35
|
-
case UnistylesEventType.Plugin:
|
36
|
-
{
|
37
|
-
return setPlugins(unistyles.runtime.enabledPlugins);
|
38
|
-
}
|
39
|
-
case UnistylesEventType.DynamicTypeSize:
|
40
|
-
{
|
41
|
-
const dynamicTypeSizeEvent = event;
|
42
|
-
return setContentSizeCategory(dynamicTypeSizeEvent.payload.contentSizeCategory);
|
43
|
-
}
|
44
|
-
default:
|
45
|
-
return;
|
46
|
-
}
|
47
|
-
});
|
48
|
-
return subscription.remove;
|
49
|
-
}, []);
|
50
|
-
return {
|
51
|
-
plugins,
|
52
|
-
theme,
|
53
|
-
layout,
|
54
|
-
contentSizeCategory
|
55
|
-
};
|
56
|
-
};
|
57
|
-
//# sourceMappingURL=useUnistyles.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["NativeEventEmitter","NativeModules","useEffect","useState","unistyles","UnistylesEventType","unistylesEvents","Unistyles","useUnistyles","plugins","setPlugins","runtime","enabledPlugins","theme","setTheme","registry","getTheme","themeName","contentSizeCategory","setContentSizeCategory","layout","setLayout","breakpoint","orientation","screenSize","width","screen","height","subscription","addListener","event","type","Theme","themeEvent","payload","Layout","layoutEvent","Plugin","DynamicTypeSize","dynamicTypeSizeEvent","remove"],"sourceRoot":"../../../src","sources":["hooks/useUnistyles.ts"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,aAAa,QAAQ,cAAc;AAChE,SAASC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,SAAS,QAAQ,SAAS;AACnC,SAASC,kBAAkB,QAAQ,WAAW;AAG9C,MAAMC,eAAe,GAAG,IAAIN,kBAAkB,CAACC,aAAa,CAACM,SAAS,CAAC;AAEvE,OAAO,MAAMC,YAAY,GAAGA,CAAA,KAAM;EAC9B,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAGP,QAAQ,CAACC,SAAS,CAACO,OAAO,CAACC,cAAc,CAAC;EACxE,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGX,QAAQ,CAACC,SAAS,CAACW,QAAQ,CAACC,QAAQ,CAACZ,SAAS,CAACO,OAAO,CAACM,SAAS,CAAC,CAAC;EAC5F,MAAM,CAACC,mBAAmB,EAAEC,sBAAsB,CAAC,GAAGhB,QAAQ,CAACC,SAAS,CAACO,OAAO,CAACO,mBAAmB,CAAC;EACrG,MAAM,CAACE,MAAM,EAAEC,SAAS,CAAC,GAAGlB,QAAQ,CAAC;IACjCmB,U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N,OAAO;IACH/B,OAAO;IACPI,KAAK;IACLO,MAAM;IACNF;EACJ,CAAC;AACL,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["useRef","useVariants","variantsMap","variantsRef","current"],"sourceRoot":"../../../src","sources":["hooks/useVariants.ts"],"mappings":"AAAA,SAASA,MAAM,QAAQ,OAAO;AAG9B,OAAO,MAAMC,WAAW,GAAIC,WAA8C,IAAK;EAC3E,MAAMC,WAAW,GAAGH,MAAM,CAA6CE,WAAW,CAAC;EAEnFC,WAAW,CAACC,OAAO,GAAGF,WAAW;EAEjC,OAAOC,WAAW,CAACC,OAAO;AAC9B,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["normalizeStyle","preprocessor","normalizeNumericValue","normalizeColor"],"sourceRoot":"../../../src","sources":["normalizer/index.ts"],"mappings":"AAAA,SAASA,cAAc,QAAQ,kBAAkB;AACjD,SAASC,YAAY,EAAEC,qBAAqB,EAAEC,cAAc,QAAQ,cAAc"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["normalizer/module.d.ts"],"mappings":""}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["preprocessor","warn","normalizeBoxShadow","style","requiredBoxShadowProperties","every","prop","join","shadowColor","undefined","shadowOffset","shadowOpacity","shadowRadius","boxShadow","createBoxShadowValue","normalizeTextShadow","requiredTextShadowProperties","textShadowColor","textShadowOffset","textShadowRadius","textShadow","createTextShadowValue","normalizeStyle","normalizedTransform","Array","isArray","transform","createTransformValue","normalizedBoxShadow","normalizedTextShadow"],"sourceRoot":"../../../src","sources":["normalizer/normalizeStyle.ts"],"mappings":"AAAA,SAASA,YAAY,QAAQ,cAAc;AAC3C,SAASC,IAAI,QAAQ,WAAW;AAGhC,MAAMC,kBAAkB,GAAyBC,KAAQ,IAA0B;EAC/E,MAAMC,2BAA2B,GAAG,CAChC,aAAa,EACb,cAAc,EACd,eA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AC,GAC7E;IAAEA,SAAS,EAAE1B,YAAY,CAAC2B,oBAAoB,CAACxB,KAAK,CAACuB,SAAS;EAAE,CAAC,GACjE,CAAC,CAAC;EAER,MAAME,mBAAmB,GACrB,aAAa,IAAIzB,KAAK,IACtB,cAAc,IAAIA,KAAK,IACvB,eAAe,IAAIA,KAAK,IACxB,cAAc,IAAIA,KAAK,GACvBD,kBAAkB,CAACC,KAAkB,CAAC,GAAG,CAAC,CAAC;EAE/C,MAAM0B,oBAAoB,GACtB,iBAAiB,IAAI1B,KAAK,IAC1B,kBAAkB,IAAIA,KAAK,IAC3B,kBAAkB,IAAIA,KAAK,GAC3BY,mBAAmB,CAACZ,KAAmB,CAAC,GAAG,CAAC,CAAC;EAEjD,OAAO;IACH,GAAGA,KAAK;IACR,GAAGoB,mBAAmB;IACtB,GAAGK,mBAAmB;IACtB,GAAGC;EACP,CAAC;AACL,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["normalizeColors","normalizeColor","color","opacity","integer","hex","toString","padStart","length","r","g","b","a","split","map","x","parseInt","filter","num","isNaN","normalizeNumericValue","value","normalizeTransform","key","includes","createTextShadowValue","style","textShadowColor","textShadowOffset","textShadowRadius","offsetX","width","offsetY","height","radius","createBoxShadowValue","shadowColor","shadowOffset","shadowOpacity","shadowRadius","createTransformValue","transforms","transform","Object","keys","undefined","join","Boolean","preprocessor"],"sourceRoot":"../../../src","sources":["normalizer/normalizer.ts"],"mappings":"AAAA;AACA;AACA,OAAOA,eAAe,MAAM,gCAAgC;AAS5D,OAAO,MAAMC,cAAc,GAAGA,CAACC,KAAa,EAAEC,OAAe,GAAG,CAAC,KAAK;EAClE;EACA,IAAIA,OAAO,KAAK,CAAC,EAAE;IACf,OAAOD,KAAK;EAChB;EAEA,MAAME,OAAO,GAAGJ,eAAe,CAACE,KAAK,CAAqB;;EAE1D;EACA,IAAIE,OAAO,KAAK,IAAI,EAAE;IAClB,OAAOF,KAAK;EAChB;EAEA,MAAM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,CAAC;AAEd,OAAO,MAAME,YAA0B,GAAG;EACtCvB,qBAAqB;EACrBU,oBAAoB;EACpBK;AACJ,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["normalizer/normalizer.macos.ts"],"mappings":"AAAA"}
|
@@ -1,7 +0,0 @@
|
|
1
|
-
// prevent recursive import
|
2
|
-
import { createMediaQueryForStyles } from '../utils/cssMediaQuery';
|
3
|
-
export const cssMediaQueriesPlugin = {
|
4
|
-
name: '__unistylesCSSMediaQueries',
|
5
|
-
onParsedStyle: (_key, styles, runtime) => createMediaQueryForStyles(styles, runtime)
|
6
|
-
};
|
7
|
-
//# sourceMappingURL=cssMediaQueriesPlugin.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["createMediaQueryForStyles","cssMediaQueriesPlugin","name","onParsedStyle","_key","styles","runtime"],"sourceRoot":"../../../src","sources":["plugins/cssMediaQueriesPlugin.ts"],"mappings":"AAAA;AACA,SAASA,yBAAyB,QAAQ,wBAAwB;AAGlE,OAAO,MAAMC,qBAAsC,GAAG;EAClDC,IAAI,EAAE,4BAA4B;EAClCC,aAAa,EAAEA,CAACC,IAAI,EAAEC,MAAM,EAAEC,OAAO,KAAKN,yBAAyB,CAACK,MAAM,EAAEC,OAAO;AACvF,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["normalizeWebStylesPlugin","cssMediaQueriesPlugin"],"sourceRoot":"../../../src","sources":["plugins/index.ts"],"mappings":"AAAA,SAASA,wBAAwB,QAAQ,4BAA4B;AACrE,SAASC,qBAAqB,QAAQ,yBAAyB"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["normalizeStyle","normalizeWebStylesPlugin","name","onParsedStyle","_key","styles"],"sourceRoot":"../../../src","sources":["plugins/normalizeWebStylesPlugin.ts"],"mappings":"AACA,SAASA,cAAc,QAAQ,eAAe;AAE9C,OAAO,MAAMC,wBAAyC,GAAG;EACrDC,IAAI,EAAE,+BAA+B;EACrCC,aAAa,EAAEA,CAACC,IAAI,EAAEC,MAAM,KAAKL,cAAc,CAACK,MAAM;AAC1D,CAAC"}
|