react-native-unistyles 1.2.0 → 1.3.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 +30 -38
- package/android/CMakeLists.txt +27 -0
- package/android/build.gradle +75 -0
- package/android/src/main/cxx/cpp-adapter.cpp +132 -0
- package/android/src/main/java/com/unistyles/UnistylesModule.kt +189 -0
- package/android/src/main/java/com/unistyles/UnistylesPackage.kt +18 -0
- package/cxx/UnistylesRuntime.cpp +318 -0
- package/cxx/UnistylesRuntime.h +74 -0
- package/ios/UnistylesHelpers.h +3 -0
- package/ios/UnistylesHelpers.mm +5 -0
- package/ios/UnistylesModule.h +16 -0
- package/ios/UnistylesModule.mm +138 -0
- package/ios/platform/Platform_iOS.h +21 -0
- package/ios/platform/Platform_iOS.mm +132 -0
- package/ios/platform/Platform_macOS.h +20 -0
- package/ios/platform/Platform_macOS.mm +83 -0
- package/lib/commonjs/common.js +60 -0
- package/lib/commonjs/common.js.map +1 -0
- package/lib/commonjs/core/UnistyleRegistry.js +94 -0
- package/lib/commonjs/core/UnistyleRegistry.js.map +1 -0
- package/lib/commonjs/core/Unistyles.js +32 -0
- package/lib/commonjs/core/Unistyles.js.map +1 -0
- package/lib/commonjs/core/UnistylesModule.js +197 -0
- package/lib/commonjs/core/UnistylesModule.js.map +1 -0
- package/lib/commonjs/core/UnistylesModule.native.js +9 -0
- package/lib/commonjs/core/UnistylesModule.native.js.map +1 -0
- package/lib/commonjs/core/UnistylesRuntime.js +140 -0
- package/lib/commonjs/core/UnistylesRuntime.js.map +1 -0
- package/lib/commonjs/core/index.js +13 -0
- package/lib/commonjs/core/index.js.map +1 -0
- package/lib/commonjs/createStyleSheet.js +14 -0
- package/lib/commonjs/createStyleSheet.js.map +1 -0
- package/lib/commonjs/global.js +2 -0
- package/lib/commonjs/global.js.map +1 -0
- package/lib/commonjs/hooks/index.js +24 -3
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/useCSS.js +44 -0
- package/lib/commonjs/hooks/useCSS.js.map +1 -0
- package/lib/commonjs/hooks/useCSS.native.js +9 -0
- package/lib/commonjs/hooks/useCSS.native.js.map +1 -0
- package/lib/commonjs/hooks/useInitialTheme.js +17 -0
- package/lib/commonjs/hooks/useInitialTheme.js.map +1 -0
- package/lib/commonjs/hooks/useUnistyles.js +64 -0
- package/lib/commonjs/hooks/useUnistyles.js.map +1 -0
- package/lib/commonjs/hooks/useVariants.js +14 -0
- package/lib/commonjs/hooks/useVariants.js.map +1 -0
- package/lib/commonjs/index.js +63 -6
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/normalizer/index.js +32 -0
- package/lib/commonjs/normalizer/index.js.map +1 -0
- package/lib/commonjs/normalizer/module.d.js.map +1 -0
- package/lib/commonjs/{utils/normalizeStyles.web.js → normalizer/normalizeStyle.js} +5 -5
- package/lib/commonjs/normalizer/normalizeStyle.js.map +1 -0
- package/lib/commonjs/{utils → normalizer}/normalizer.js +2 -3
- package/lib/commonjs/normalizer/normalizer.js.map +1 -0
- package/lib/commonjs/normalizer/normalizer.macos.js +3 -0
- package/lib/commonjs/normalizer/normalizer.macos.js.map +1 -0
- package/lib/commonjs/plugins/cssMediaQueriesPlugin.js +14 -0
- package/lib/commonjs/plugins/cssMediaQueriesPlugin.js.map +1 -0
- package/lib/commonjs/plugins/index.js +20 -0
- package/lib/commonjs/plugins/index.js.map +1 -0
- package/lib/commonjs/plugins/normalizeWebStylesPlugin.js +12 -0
- package/lib/commonjs/plugins/normalizeWebStylesPlugin.js.map +1 -0
- package/lib/commonjs/types/common.js +2 -0
- package/lib/{module/utils/module.d.js.map → commonjs/types/common.js.map} +1 -1
- package/lib/commonjs/types/index.js +11 -0
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/commonjs/types/plugin.js +6 -0
- package/lib/commonjs/{utils/module.d.js.map → types/plugin.js.map} +1 -1
- package/lib/commonjs/types/stylesheet.js +6 -0
- package/lib/commonjs/types/{mediaQueries.js.map → stylesheet.js.map} +1 -1
- package/lib/commonjs/types/unistyles.js +6 -0
- package/lib/{module/types/mediaQueries.js.map → commonjs/types/unistyles.js.map} +1 -1
- package/lib/commonjs/types/variants.js +2 -0
- package/lib/commonjs/types/variants.js.map +1 -0
- package/lib/commonjs/useStyles.js +47 -0
- package/lib/commonjs/useStyles.js.map +1 -0
- package/lib/commonjs/utils/breakpoints.js +20 -122
- package/lib/commonjs/utils/breakpoints.js.map +1 -1
- package/lib/commonjs/utils/cssMediaQuery.js +244 -0
- package/lib/commonjs/utils/cssMediaQuery.js.map +1 -0
- package/lib/commonjs/utils/generateId.js +15 -0
- package/lib/commonjs/utils/generateId.js.map +1 -0
- package/lib/commonjs/utils/hash32.js +43 -0
- package/lib/commonjs/utils/hash32.js.map +1 -0
- package/lib/commonjs/utils/index.js +22 -54
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/mq.js +38 -0
- package/lib/commonjs/utils/mq.js.map +1 -0
- package/lib/commonjs/utils/mqParser.js +89 -0
- package/lib/commonjs/utils/mqParser.js.map +1 -0
- package/lib/commonjs/utils/styles.js +45 -72
- package/lib/commonjs/utils/styles.js.map +1 -1
- package/lib/commonjs/utils/withPlugins.js +15 -0
- package/lib/commonjs/utils/withPlugins.js.map +1 -0
- package/lib/module/common.js +53 -0
- package/lib/module/common.js.map +1 -0
- package/lib/module/core/UnistyleRegistry.js +87 -0
- package/lib/module/core/UnistyleRegistry.js.map +1 -0
- package/lib/module/core/Unistyles.js +26 -0
- package/lib/module/core/Unistyles.js.map +1 -0
- package/lib/module/core/UnistylesModule.js +190 -0
- package/lib/module/core/UnistylesModule.js.map +1 -0
- package/lib/module/core/UnistylesModule.native.js +3 -0
- package/lib/module/core/UnistylesModule.native.js.map +1 -0
- package/lib/module/core/UnistylesRuntime.js +133 -0
- package/lib/module/core/UnistylesRuntime.js.map +1 -0
- package/lib/module/core/index.js +2 -0
- package/lib/module/core/index.js.map +1 -0
- package/lib/module/createStyleSheet.js +7 -0
- package/lib/module/createStyleSheet.js.map +1 -0
- package/lib/module/global.js +2 -0
- package/lib/module/global.js.map +1 -0
- package/lib/module/hooks/index.js +4 -1
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useCSS.js +37 -0
- package/lib/module/hooks/useCSS.js.map +1 -0
- package/lib/module/hooks/useCSS.native.js +2 -0
- package/lib/module/hooks/useCSS.native.js.map +1 -0
- package/lib/module/hooks/useInitialTheme.js +10 -0
- package/lib/module/hooks/useInitialTheme.js.map +1 -0
- package/lib/module/hooks/useUnistyles.js +57 -0
- package/lib/module/hooks/useUnistyles.js.map +1 -0
- package/lib/module/hooks/useVariants.js +7 -0
- package/lib/module/hooks/useVariants.js.map +1 -0
- package/lib/module/index.js +30 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/normalizer/index.js +3 -0
- package/lib/module/normalizer/index.js.map +1 -0
- package/lib/module/normalizer/module.d.js.map +1 -0
- package/lib/module/{utils/normalizeStyles.web.js → normalizer/normalizeStyle.js} +3 -3
- package/lib/module/normalizer/normalizeStyle.js.map +1 -0
- package/lib/module/{utils → normalizer}/normalizer.js +2 -3
- package/lib/module/normalizer/normalizer.js.map +1 -0
- package/lib/module/normalizer/normalizer.macos.js +2 -0
- package/lib/module/normalizer/normalizer.macos.js.map +1 -0
- package/lib/module/plugins/cssMediaQueriesPlugin.js +7 -0
- package/lib/module/plugins/cssMediaQueriesPlugin.js.map +1 -0
- package/lib/module/plugins/index.js +3 -0
- package/lib/module/plugins/index.js.map +1 -0
- package/lib/module/plugins/normalizeWebStylesPlugin.js +6 -0
- package/lib/module/plugins/normalizeWebStylesPlugin.js.map +1 -0
- package/lib/module/types/common.js +2 -0
- package/lib/module/types/common.js.map +1 -0
- package/lib/module/types/index.js +1 -0
- package/lib/module/types/index.js.map +1 -1
- package/lib/module/types/plugin.js +2 -0
- package/lib/module/types/plugin.js.map +1 -0
- package/lib/module/types/stylesheet.js +2 -0
- package/lib/module/types/stylesheet.js.map +1 -0
- package/lib/module/types/unistyles.js +2 -0
- package/lib/module/types/unistyles.js.map +1 -0
- package/lib/module/types/variants.js +2 -0
- package/lib/module/types/variants.js.map +1 -0
- package/lib/module/useStyles.js +40 -0
- package/lib/module/useStyles.js.map +1 -0
- package/lib/module/utils/breakpoints.js +19 -120
- package/lib/module/utils/breakpoints.js.map +1 -1
- package/lib/module/utils/cssMediaQuery.js +237 -0
- package/lib/module/utils/cssMediaQuery.js.map +1 -0
- package/lib/module/utils/generateId.js +7 -0
- package/lib/module/utils/generateId.js.map +1 -0
- package/lib/module/utils/hash32.js +36 -0
- package/lib/module/utils/hash32.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/mq.js +32 -0
- package/lib/module/utils/mq.js.map +1 -0
- package/lib/module/utils/mqParser.js +78 -0
- package/lib/module/utils/mqParser.js.map +1 -0
- package/lib/module/utils/styles.js +44 -72
- package/lib/module/utils/styles.js.map +1 -1
- package/lib/module/utils/withPlugins.js +8 -0
- package/lib/module/utils/withPlugins.js.map +1 -0
- package/lib/typescript/src/common.d.ts +46 -0
- package/lib/typescript/src/common.d.ts.map +1 -0
- package/lib/typescript/src/core/UnistyleRegistry.d.ts +56 -0
- package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +1 -0
- package/lib/typescript/src/core/Unistyles.d.ts +13 -0
- package/lib/typescript/src/core/Unistyles.d.ts.map +1 -0
- package/lib/typescript/src/core/UnistylesModule.d.ts +19 -0
- package/lib/typescript/src/core/UnistylesModule.d.ts.map +1 -0
- package/lib/typescript/src/core/UnistylesModule.native.d.ts +6 -0
- package/lib/typescript/src/core/UnistylesModule.native.d.ts.map +1 -0
- package/lib/typescript/src/core/UnistylesRuntime.d.ts +81 -0
- package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -0
- package/lib/typescript/src/core/index.d.ts +3 -0
- package/lib/typescript/src/core/index.d.ts.map +1 -0
- package/lib/typescript/src/createStyleSheet.d.ts +8 -0
- package/lib/typescript/src/createStyleSheet.d.ts.map +1 -0
- package/lib/typescript/src/global.d.ts +7 -0
- package/lib/typescript/src/global.d.ts.map +1 -0
- package/lib/typescript/src/hooks/index.d.ts +4 -1
- package/lib/typescript/src/hooks/index.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useCSS.d.ts +3 -0
- package/lib/typescript/src/hooks/useCSS.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useCSS.native.d.ts +3 -0
- package/lib/typescript/src/hooks/useCSS.native.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useInitialTheme.d.ts +3 -0
- package/lib/typescript/src/hooks/useInitialTheme.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useUnistyles.d.ts +14 -0
- package/lib/typescript/src/hooks/useUnistyles.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useVariants.d.ts +3 -0
- package/lib/typescript/src/hooks/useVariants.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +76 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/normalizer/index.d.ts +3 -0
- package/lib/typescript/src/normalizer/index.d.ts.map +1 -0
- package/lib/typescript/src/normalizer/normalizeStyle.d.ts +3 -0
- package/lib/typescript/src/normalizer/normalizeStyle.d.ts.map +1 -0
- package/lib/typescript/src/normalizer/normalizer.d.ts.map +1 -0
- package/lib/typescript/src/normalizer/normalizer.macos.d.ts +1 -0
- package/lib/typescript/src/normalizer/normalizer.macos.d.ts.map +1 -0
- package/lib/typescript/src/plugins/cssMediaQueriesPlugin.d.ts +3 -0
- package/lib/typescript/src/plugins/cssMediaQueriesPlugin.d.ts.map +1 -0
- package/lib/typescript/src/plugins/index.d.ts +3 -0
- package/lib/typescript/src/plugins/index.d.ts.map +1 -0
- package/lib/typescript/src/plugins/normalizeWebStylesPlugin.d.ts +3 -0
- package/lib/typescript/src/plugins/normalizeWebStylesPlugin.d.ts.map +1 -0
- package/lib/typescript/src/types/breakpoints.d.ts +25 -17
- package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/types/common.d.ts +3 -0
- package/lib/typescript/src/types/common.d.ts.map +1 -0
- package/lib/typescript/src/types/core.d.ts +11 -25
- package/lib/typescript/src/types/core.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +7 -2
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/lib/typescript/src/types/plugin.d.ts +7 -0
- package/lib/typescript/src/types/plugin.d.ts.map +1 -0
- package/lib/typescript/src/types/stylesheet.d.ts +40 -0
- package/lib/typescript/src/types/stylesheet.d.ts.map +1 -0
- package/lib/typescript/src/types/unistyles.d.ts +53 -0
- package/lib/typescript/src/types/unistyles.d.ts.map +1 -0
- package/lib/typescript/src/types/variants.d.ts +14 -0
- package/lib/typescript/src/types/variants.d.ts.map +1 -0
- package/lib/typescript/src/useStyles.d.ts +16 -0
- package/lib/typescript/src/useStyles.d.ts.map +1 -0
- package/lib/typescript/src/utils/breakpoints.d.ts +2 -62
- package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/utils/cssMediaQuery.d.ts +4 -0
- package/lib/typescript/src/utils/cssMediaQuery.d.ts.map +1 -0
- package/lib/typescript/src/utils/generateId.d.ts +2 -0
- package/lib/typescript/src/utils/generateId.d.ts.map +1 -0
- package/lib/typescript/src/utils/hash32.d.ts +2 -0
- package/lib/typescript/src/utils/hash32.d.ts.map +1 -0
- package/lib/typescript/src/utils/index.d.ts +7 -6
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/mq.d.ts +26 -0
- package/lib/typescript/src/utils/mq.d.ts.map +1 -0
- package/lib/typescript/src/utils/mqParser.d.ts +16 -0
- package/lib/typescript/src/utils/mqParser.d.ts.map +1 -0
- package/lib/typescript/src/utils/styles.d.ts +3 -49
- package/lib/typescript/src/utils/styles.d.ts.map +1 -1
- package/lib/typescript/src/utils/withPlugins.d.ts +3 -0
- package/lib/typescript/src/utils/withPlugins.d.ts.map +1 -0
- package/package.json +46 -25
- package/react-native-unistyles.podspec +22 -0
- package/src/__tests__/mocks.ts +24 -0
- package/src/common.ts +55 -0
- package/src/core/UnistyleRegistry.ts +108 -0
- package/src/core/Unistyles.ts +35 -0
- package/src/core/UnistylesModule.native.ts +7 -0
- package/src/core/UnistylesModule.ts +230 -0
- package/src/core/UnistylesRuntime.ts +135 -0
- package/src/core/index.ts +2 -0
- package/src/createStyleSheet.ts +8 -0
- package/src/global.ts +6 -0
- package/src/hooks/index.ts +4 -1
- package/src/hooks/useCSS.native.ts +3 -0
- package/src/hooks/useCSS.ts +51 -0
- package/src/hooks/useInitialTheme.ts +11 -0
- package/src/hooks/useUnistyles.ts +64 -0
- package/src/hooks/useVariants.ts +10 -0
- package/src/index.ts +50 -2
- package/src/normalizer/index.ts +2 -0
- package/src/{utils/normalizeStyles.web.ts → normalizer/normalizeStyle.ts} +3 -3
- package/src/normalizer/normalizer.macos.ts +1 -0
- package/src/{utils → normalizer}/normalizer.ts +5 -4
- package/src/plugins/cssMediaQueriesPlugin.ts +8 -0
- package/src/plugins/index.ts +2 -0
- package/src/plugins/normalizeWebStylesPlugin.ts +7 -0
- package/src/types/breakpoints.ts +58 -33
- package/src/types/common.ts +2 -0
- package/src/types/core.ts +11 -36
- package/src/types/index.ts +12 -7
- package/src/types/plugin.ts +7 -0
- package/src/types/stylesheet.ts +49 -0
- package/src/types/unistyles.ts +63 -0
- package/src/types/variants.ts +19 -0
- package/src/useStyles.ts +60 -0
- package/src/utils/breakpoints.ts +28 -124
- package/src/utils/cssMediaQuery.ts +268 -0
- package/src/utils/generateId.ts +10 -0
- package/src/utils/hash32.ts +53 -0
- package/src/utils/index.ts +7 -13
- package/src/utils/mq.ts +57 -0
- package/src/utils/mqParser.ts +99 -0
- package/src/utils/styles.ts +54 -102
- package/src/utils/withPlugins.ts +13 -0
- package/lib/commonjs/UnistylesTheme.js +0 -21
- package/lib/commonjs/UnistylesTheme.js.map +0 -1
- package/lib/commonjs/createUnistyles.js +0 -57
- package/lib/commonjs/createUnistyles.js.map +0 -1
- package/lib/commonjs/hooks/useDimensions.js +0 -10
- package/lib/commonjs/hooks/useDimensions.js.map +0 -1
- package/lib/commonjs/hooks/useDimensions.web.js +0 -34
- package/lib/commonjs/hooks/useDimensions.web.js.map +0 -1
- package/lib/commonjs/types/mediaQueries.js +0 -2
- package/lib/commonjs/utils/common.js +0 -20
- package/lib/commonjs/utils/common.js.map +0 -1
- package/lib/commonjs/utils/mediaQueries.js +0 -189
- package/lib/commonjs/utils/mediaQueries.js.map +0 -1
- package/lib/commonjs/utils/normalizeStyles.js +0 -10
- package/lib/commonjs/utils/normalizeStyles.js.map +0 -1
- package/lib/commonjs/utils/normalizeStyles.web.js.map +0 -1
- package/lib/commonjs/utils/normalizer.js.map +0 -1
- package/lib/module/UnistylesTheme.js +0 -12
- package/lib/module/UnistylesTheme.js.map +0 -1
- package/lib/module/createUnistyles.js +0 -50
- package/lib/module/createUnistyles.js.map +0 -1
- package/lib/module/hooks/useDimensions.js +0 -3
- package/lib/module/hooks/useDimensions.js.map +0 -1
- package/lib/module/hooks/useDimensions.web.js +0 -27
- package/lib/module/hooks/useDimensions.web.js.map +0 -1
- package/lib/module/types/mediaQueries.js +0 -2
- package/lib/module/utils/common.js +0 -12
- package/lib/module/utils/common.js.map +0 -1
- package/lib/module/utils/mediaQueries.js +0 -176
- package/lib/module/utils/mediaQueries.js.map +0 -1
- package/lib/module/utils/normalizeStyles.js +0 -3
- package/lib/module/utils/normalizeStyles.js.map +0 -1
- package/lib/module/utils/normalizeStyles.web.js.map +0 -1
- package/lib/module/utils/normalizer.js.map +0 -1
- package/lib/typescript/examples/expo/src/App.d.ts +0 -3
- package/lib/typescript/examples/expo/src/App.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/examples/Breakpoints.d.ts +0 -3
- package/lib/typescript/examples/expo/src/examples/Breakpoints.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/examples/EmptyStyles.d.ts +0 -3
- package/lib/typescript/examples/expo/src/examples/EmptyStyles.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/examples/Extreme.d.ts +0 -7
- package/lib/typescript/examples/expo/src/examples/Extreme.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/examples/MediaQueries.d.ts +0 -3
- package/lib/typescript/examples/expo/src/examples/MediaQueries.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/examples/Memoization.d.ts +0 -3
- package/lib/typescript/examples/expo/src/examples/Memoization.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/examples/Minimal.d.ts +0 -3
- package/lib/typescript/examples/expo/src/examples/Minimal.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/examples/MinimalWithCreateStyleSheet.d.ts +0 -3
- package/lib/typescript/examples/expo/src/examples/MinimalWithCreateStyleSheet.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/examples/PlatformColors.d.ts +0 -3
- package/lib/typescript/examples/expo/src/examples/PlatformColors.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/examples/Theme.d.ts +0 -3
- package/lib/typescript/examples/expo/src/examples/Theme.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/examples/index.d.ts +0 -9
- package/lib/typescript/examples/expo/src/examples/index.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/index.d.ts +0 -2
- package/lib/typescript/examples/expo/src/index.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/styles/breakpoints.d.ts +0 -8
- package/lib/typescript/examples/expo/src/styles/breakpoints.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/styles/index.d.ts +0 -46
- package/lib/typescript/examples/expo/src/styles/index.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/styles/theme.d.ts +0 -24
- package/lib/typescript/examples/expo/src/styles/theme.d.ts.map +0 -1
- package/lib/typescript/src/UnistylesTheme.d.ts +0 -9
- package/lib/typescript/src/UnistylesTheme.d.ts.map +0 -1
- package/lib/typescript/src/createUnistyles.d.ts +0 -10
- package/lib/typescript/src/createUnistyles.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useDimensions.d.ts +0 -3
- package/lib/typescript/src/hooks/useDimensions.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useDimensions.web.d.ts +0 -3
- package/lib/typescript/src/hooks/useDimensions.web.d.ts.map +0 -1
- package/lib/typescript/src/types/mediaQueries.d.ts +0 -8
- package/lib/typescript/src/types/mediaQueries.d.ts.map +0 -1
- package/lib/typescript/src/utils/common.d.ts +0 -7
- package/lib/typescript/src/utils/common.d.ts.map +0 -1
- package/lib/typescript/src/utils/mediaQueries.d.ts +0 -130
- package/lib/typescript/src/utils/mediaQueries.d.ts.map +0 -1
- package/lib/typescript/src/utils/normalizeStyles.d.ts +0 -2
- package/lib/typescript/src/utils/normalizeStyles.d.ts.map +0 -1
- package/lib/typescript/src/utils/normalizeStyles.web.d.ts +0 -5
- package/lib/typescript/src/utils/normalizeStyles.web.d.ts.map +0 -1
- package/lib/typescript/src/utils/normalizer.d.ts.map +0 -1
- package/src/UnistylesTheme.tsx +0 -17
- package/src/__tests__/createUnistyles.spec.tsx +0 -192
- package/src/createUnistyles.ts +0 -70
- package/src/hooks/useDimensions.ts +0 -4
- package/src/hooks/useDimensions.web.ts +0 -34
- package/src/types/mediaQueries.ts +0 -10
- package/src/utils/common.ts +0 -14
- package/src/utils/mediaQueries.ts +0 -201
- package/src/utils/normalizeStyles.ts +0 -2
- /package/lib/commonjs/{utils → normalizer}/module.d.js +0 -0
- /package/lib/module/{utils → normalizer}/module.d.js +0 -0
- /package/lib/typescript/src/{utils → normalizer}/normalizer.d.ts +0 -0
- /package/src/{utils → normalizer}/module.d.ts +0 -0
@@ -0,0 +1,43 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.murmurhash2_32_gc = void 0;
|
7
|
+
/*
|
8
|
+
Authors: Gary Court and Austin Appleby
|
9
|
+
Compatible with React Native Web
|
10
|
+
https://github.com/necolas/react-native-web/blob/master/packages/react-native-web/src/exports/StyleSheet/compiler/hash.js#L65
|
11
|
+
*/
|
12
|
+
const murmurhash2_32_gc = (str, seed) => {
|
13
|
+
let l = str.length;
|
14
|
+
let h = seed ^ l;
|
15
|
+
let i = 0;
|
16
|
+
let k;
|
17
|
+
while (l >= 4) {
|
18
|
+
k = str.charCodeAt(i) & 0xff | (str.charCodeAt(++i) & 0xff) << 8 | (str.charCodeAt(++i) & 0xff) << 16 | (str.charCodeAt(++i) & 0xff) << 24;
|
19
|
+
k = (k & 0xffff) * 0x5bd1e995 + (((k >>> 16) * 0x5bd1e995 & 0xffff) << 16);
|
20
|
+
k ^= k >>> 24;
|
21
|
+
k = (k & 0xffff) * 0x5bd1e995 + (((k >>> 16) * 0x5bd1e995 & 0xffff) << 16);
|
22
|
+
h = (h & 0xffff) * 0x5bd1e995 + (((h >>> 16) * 0x5bd1e995 & 0xffff) << 16) ^ k;
|
23
|
+
l -= 4;
|
24
|
+
++i;
|
25
|
+
}
|
26
|
+
switch (l) {
|
27
|
+
// @ts-ignore
|
28
|
+
case 3:
|
29
|
+
h ^= (str.charCodeAt(i + 2) & 0xff) << 16;
|
30
|
+
// @ts-ignore
|
31
|
+
case 2:
|
32
|
+
h ^= (str.charCodeAt(i + 1) & 0xff) << 8;
|
33
|
+
case 1:
|
34
|
+
h ^= str.charCodeAt(i) & 0xff;
|
35
|
+
h = (h & 0xffff) * 0x5bd1e995 + (((h >>> 16) * 0x5bd1e995 & 0xffff) << 16);
|
36
|
+
}
|
37
|
+
h ^= h >>> 13;
|
38
|
+
h = (h & 0xffff) * 0x5bd1e995 + (((h >>> 16) * 0x5bd1e995 & 0xffff) << 16);
|
39
|
+
h ^= h >>> 15;
|
40
|
+
return h >>> 0;
|
41
|
+
};
|
42
|
+
exports.murmurhash2_32_gc = murmurhash2_32_gc;
|
43
|
+
//# sourceMappingURL=hash32.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["murmurhash2_32_gc","str","seed","l","length","h","i","k","charCodeAt","exports"],"sourceRoot":"../../../src","sources":["utils/hash32.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACO,MAAMA,iBAAiB,GAAGA,CAACC,GAAW,EAAEC,IAAY,KAAK;EAC5D,IAAIC,CAAC,GAAGF,GAAG,CAACG,MAAM;EAClB,IAAIC,CAAC,GAAGH,IAAI,GAAGC,CAAC;EAChB,IAAIG,CAAC,GAAG,CAAC;EACT,IAAIC,CAAC;EAEL,OAAOJ,CAAC,IAAI,CAAC,EAAE;IACXI,CAAC,GACAN,GAAG,CAACO,UAAU,CAACF,CAAC,CAAC,GAAG,IAAI,GACxB,CAACL,GAAG,CAACO,UAAU,CAAC,EAAEF,CAAC,CAAC,GAAG,IAAI,KAAK,CAAE,GAClC,CAACL,GAAG,CAACO,UAAU,CAAC,EAAEF,CAAC,CAAC,GAAG,IAAI,KAAK,EAAG,GACnC,CAACL,GAAG,CAACO,UAAU,CAAC,EAAEF,CAAC,CAAC,GAAG,IAAI,KAAK,EAAG;IAEpCC,CAAC,GACD,CAACA,CAAC,GAAG,MAAM,IAAI,UAAU,IAAI,CAAE,CAACA,CAAC,KAAK,EAAE,IAAI,UAAU,GAAI,MAAM,KAAK,EAAE,CAAC;IACxEA,CAAC,IAAIA,CAAC,KAAK,EAAE;IACbA,CAAC,GACD,CAACA,CAAC,GAAG,MAAM,IAAI,UAAU,IAAI,CAAE,CAACA,CAAC,KAAK,EAAE,IAAI,UAAU,GAAI,MAAM,KAAK,EAAE,CAAC;IAExEF,CAAC,GACA,CAACA,CAAC,GAAG,MAAM,IAAI,UAAU,IACvB,CAAE,CAACA,CAAC,KAAK,EAAE,IAAI,UAAU,GAAI,MAAM,KAAK,EAAE,CAAC,GAC9CE,CAAC;IAEDJ,CAAC,IAAI,CAAC;IACN,EAAEG,CAAC;EACP;EAEA,QAAQH,CAAC;IACL;IACA,KAAK,CAAC;MACFE,CAAC,IAAI,CAACJ,GAAG,CAACO,UAAU,CAACF,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,KAAK,EAAE;IAC7C;IACA,KAAK,CAAC;MACFD,CAAC,IAAI,CAACJ,GAAG,CAACO,UAAU,CAACF,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,KAAK,CAAC;IAC5C,KAAK,CAAC;MACFD,CAAC,IAAIJ,GAAG,CAACO,UAAU,CAACF,CAAC,CAAC,GAAG,IAAI;MAC7BD,CAAC,GACH,CAACA,CAAC,GAAG,MAAM,IAAI,UAAU,IACxB,CAAE,CAACA,CAAC,KAAK,EAAE,IAAI,UAAU,GAAI,MAAM,KAAK,EAAE,CAAC;EAClD;EAEAA,CAAC,IAAIA,CAAC,KAAK,EAAE;EACbA,CAAC,GAAG,CAACA,CAAC,GAAG,MAAM,IAAI,UAAU,IAAI,CAAE,CAACA,CAAC,KAAK,EAAE,IAAI,UAAU,GAAI,MAAM,KAAK,EAAE,CAAC;EAC5EA,CAAC,IAAIA,CAAC,KAAK,EAAE;EAEb,OAAOA,CAAC,KAAK,CAAC;AAClB,CAAC;AAAAI,OAAA,CAAAT,iBAAA,GAAAA,iBAAA"}
|
@@ -3,37 +3,16 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
|
7
|
-
normalizeStyles: true,
|
8
|
-
getBreakpointFromScreenWidth: true,
|
9
|
-
sortAndValidateBreakpoints: true,
|
10
|
-
getValueForBreakpoint: true,
|
11
|
-
proxifyFunction: true,
|
12
|
-
parseStyle: true,
|
13
|
-
isServer: true,
|
14
|
-
extractValues: true,
|
15
|
-
getKeyForCustomMediaQuery: true,
|
16
|
-
isMediaQuery: true,
|
17
|
-
isWithinTheHeight: true,
|
18
|
-
isWithinTheWidth: true,
|
19
|
-
isWithinTheWidthAndHeight: true
|
20
|
-
};
|
21
|
-
Object.defineProperty(exports, "extractValues", {
|
6
|
+
Object.defineProperty(exports, "generateReactNativeWebId", {
|
22
7
|
enumerable: true,
|
23
8
|
get: function () {
|
24
|
-
return
|
9
|
+
return _generateId.generateReactNativeWebId;
|
25
10
|
}
|
26
11
|
});
|
27
|
-
Object.defineProperty(exports, "
|
12
|
+
Object.defineProperty(exports, "getKeyForUnistylesMediaQuery", {
|
28
13
|
enumerable: true,
|
29
14
|
get: function () {
|
30
|
-
return
|
31
|
-
}
|
32
|
-
});
|
33
|
-
Object.defineProperty(exports, "getKeyForCustomMediaQuery", {
|
34
|
-
enumerable: true,
|
35
|
-
get: function () {
|
36
|
-
return _mediaQueries.getKeyForCustomMediaQuery;
|
15
|
+
return _mqParser.getKeyForUnistylesMediaQuery;
|
37
16
|
}
|
38
17
|
});
|
39
18
|
Object.defineProperty(exports, "getValueForBreakpoint", {
|
@@ -42,40 +21,40 @@ Object.defineProperty(exports, "getValueForBreakpoint", {
|
|
42
21
|
return _breakpoints.getValueForBreakpoint;
|
43
22
|
}
|
44
23
|
});
|
45
|
-
Object.defineProperty(exports, "
|
24
|
+
Object.defineProperty(exports, "isPlatformColor", {
|
46
25
|
enumerable: true,
|
47
26
|
get: function () {
|
48
|
-
return
|
27
|
+
return _styles.isPlatformColor;
|
49
28
|
}
|
50
29
|
});
|
51
|
-
Object.defineProperty(exports, "
|
30
|
+
Object.defineProperty(exports, "isUnistylesMq", {
|
52
31
|
enumerable: true,
|
53
32
|
get: function () {
|
54
|
-
return
|
33
|
+
return _mqParser.isUnistylesMq;
|
55
34
|
}
|
56
35
|
});
|
57
|
-
Object.defineProperty(exports, "
|
36
|
+
Object.defineProperty(exports, "isValidMq", {
|
58
37
|
enumerable: true,
|
59
38
|
get: function () {
|
60
|
-
return
|
39
|
+
return _mqParser.isValidMq;
|
61
40
|
}
|
62
41
|
});
|
63
|
-
Object.defineProperty(exports, "
|
42
|
+
Object.defineProperty(exports, "isWithinTheWidthAndHeight", {
|
64
43
|
enumerable: true,
|
65
44
|
get: function () {
|
66
|
-
return
|
45
|
+
return _mqParser.isWithinTheWidthAndHeight;
|
67
46
|
}
|
68
47
|
});
|
69
|
-
Object.defineProperty(exports, "
|
48
|
+
Object.defineProperty(exports, "mq", {
|
70
49
|
enumerable: true,
|
71
50
|
get: function () {
|
72
|
-
return
|
51
|
+
return _mq.mq;
|
73
52
|
}
|
74
53
|
});
|
75
|
-
Object.defineProperty(exports, "
|
54
|
+
Object.defineProperty(exports, "parseMq", {
|
76
55
|
enumerable: true,
|
77
56
|
get: function () {
|
78
|
-
return
|
57
|
+
return _mqParser.parseMq;
|
79
58
|
}
|
80
59
|
});
|
81
60
|
Object.defineProperty(exports, "parseStyle", {
|
@@ -90,27 +69,16 @@ Object.defineProperty(exports, "proxifyFunction", {
|
|
90
69
|
return _styles.proxifyFunction;
|
91
70
|
}
|
92
71
|
});
|
93
|
-
Object.defineProperty(exports, "
|
72
|
+
Object.defineProperty(exports, "withPlugins", {
|
94
73
|
enumerable: true,
|
95
74
|
get: function () {
|
96
|
-
return
|
75
|
+
return _withPlugins.withPlugins;
|
97
76
|
}
|
98
77
|
});
|
99
|
-
var
|
100
|
-
var
|
101
|
-
Object.keys(_normalizer).forEach(function (key) {
|
102
|
-
if (key === "default" || key === "__esModule") return;
|
103
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
104
|
-
if (key in exports && exports[key] === _normalizer[key]) return;
|
105
|
-
Object.defineProperty(exports, key, {
|
106
|
-
enumerable: true,
|
107
|
-
get: function () {
|
108
|
-
return _normalizer[key];
|
109
|
-
}
|
110
|
-
});
|
111
|
-
});
|
78
|
+
var _mq = require("./mq");
|
79
|
+
var _mqParser = require("./mqParser");
|
112
80
|
var _breakpoints = require("./breakpoints");
|
113
81
|
var _styles = require("./styles");
|
114
|
-
var
|
115
|
-
var
|
82
|
+
var _withPlugins = require("./withPlugins");
|
83
|
+
var _generateId = require("./generateId");
|
116
84
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["_mq","require","_mqParser","_breakpoints","_styles","_withPlugins","_generateId"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,GAAA,GAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA"}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.mq = void 0;
|
7
|
+
var _core = require("../core");
|
8
|
+
const getMQValue = value => {
|
9
|
+
if (typeof value === 'number') {
|
10
|
+
return value;
|
11
|
+
}
|
12
|
+
if (value === null) {
|
13
|
+
return 0;
|
14
|
+
}
|
15
|
+
return _core.unistyles.registry.breakpoints[value] ?? 0;
|
16
|
+
};
|
17
|
+
|
18
|
+
/**
|
19
|
+
* Utility to create cross-platform media queries
|
20
|
+
* @returns - JavaScript symbol to be used in your stylesheet
|
21
|
+
*/
|
22
|
+
const mq = exports.mq = {
|
23
|
+
only: {
|
24
|
+
width: (wMin = 0, wMax = Infinity) => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]`,
|
25
|
+
height: (hMin = 0, hMax = Infinity) => `:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
|
26
|
+
},
|
27
|
+
width: (wMin = 0, wMax = Infinity) => ({
|
28
|
+
and: {
|
29
|
+
height: (hMin = 0, hMax = Infinity) => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
|
30
|
+
}
|
31
|
+
}),
|
32
|
+
height: (hMin = 0, hMax = Infinity) => ({
|
33
|
+
and: {
|
34
|
+
width: (wMin = 0, wMax = Infinity) => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
|
35
|
+
}
|
36
|
+
})
|
37
|
+
};
|
38
|
+
//# sourceMappingURL=mq.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_core","require","getMQValue","value","unistyles","registry","breakpoints","mq","exports","only","width","wMin","wMax","Infinity","height","hMin","hMax","and"],"sourceRoot":"../../../src","sources":["utils/mq.ts"],"mappings":";;;;;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AAqBA,MAAMC,UAAU,GAAIC,KAAwB,IAAK;EAC7C,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOA,KAAK;EAChB;EAEA,IAAIA,KAAK,KAAK,IAAI,EAAE;IAChB,OAAO,CAAC;EACZ;EAEA,OAAOC,eAAS,CAACC,QAAQ,CAACC,WAAW,CAACH,KAAK,CAAC,IAAI,CAAC;AACrD,CAAC;;AAED;AACA;AACA;AACA;AACO,MAAMI,EAAa,GAAAC,OAAA,CAAAD,EAAA,GAAG;EACzBE,IAAI,EAAE;IACFC,KAAK,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGC,QAAQ,KAAO,MAAKX,UAAU,CAACS,IAAI,CAAE,KAAIT,UAAU,CAACU,IAAI,CAAE,GAAwB;IACvIE,MAAM,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGH,QAAQ,KAAO,MAAKX,UAAU,CAACa,IAAI,CAAE,KAAIb,UAAU,CAACc,IAAI,CAAE;EACpH,CAAC;EACDN,KAAK,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGC,QAAQ,MAAM;IAC/DI,GAAG,EAAE;MACDH,MAAM,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGH,QAAQ,KACxD,MAAKX,UAAU,CAACS,IAAI,CAAE,KAAIT,UAAU,CAACU,IAAI,CAAE,OAAMV,UAAU,CAACa,IAAI,CAAE,KAAIb,UAAU,CAACc,IAAI,CAAE;IACjG;EACJ,CAAC,CAAC;EACFF,MAAM,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGH,QAAQ,MAAM;IAChEI,GAAG,EAAE;MACDP,KAAK,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGC,QAAQ,KACvD,MAAKX,UAAU,CAACS,IAAI,CAAE,KAAIT,UAAU,CAACU,IAAI,CAAE,OAAMV,UAAU,CAACa,IAAI,CAAE,KAAIb,UAAU,CAACc,IAAI,CAAE;IACjG;EACJ,CAAC;AACL,CAAC"}
|
@@ -0,0 +1,89 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.parseMq = exports.isWithinTheWidthAndHeight = exports.isValidMq = exports.isUnistylesMq = exports.getKeyForUnistylesMediaQuery = void 0;
|
7
|
+
const IS_UNISTYLES_REGEX = /:([hw])\[(\d+)(?:,\s*(\d+|Infinity))?]/;
|
8
|
+
const UNISTYLES_WIDTH_REGEX = /:(w)\[(\d+)(?:,\s*(\d+|Infinity))?]/;
|
9
|
+
const UNISTYLES_HEIGHT_REGEX = /:(h)\[(\d+)(?:,\s*(\d+|Infinity))?]/;
|
10
|
+
const parseMq = mq => {
|
11
|
+
const [, width, fromW, toW] = UNISTYLES_WIDTH_REGEX.exec(mq) || [];
|
12
|
+
const [, height, fromH, toH] = UNISTYLES_HEIGHT_REGEX.exec(mq) || [];
|
13
|
+
return {
|
14
|
+
width: width ? {
|
15
|
+
from: Number(fromW),
|
16
|
+
to: Number(toW)
|
17
|
+
} : undefined,
|
18
|
+
height: height ? {
|
19
|
+
from: Number(fromH),
|
20
|
+
to: Number(toH)
|
21
|
+
} : undefined
|
22
|
+
};
|
23
|
+
};
|
24
|
+
exports.parseMq = parseMq;
|
25
|
+
const isUnistylesMq = mq => IS_UNISTYLES_REGEX.test(mq);
|
26
|
+
exports.isUnistylesMq = isUnistylesMq;
|
27
|
+
const isValidMq = parsedMq => {
|
28
|
+
const {
|
29
|
+
width,
|
30
|
+
height
|
31
|
+
} = parsedMq;
|
32
|
+
if (width && height) {
|
33
|
+
return width.from <= width.to && height.from <= height.to;
|
34
|
+
}
|
35
|
+
if (width) {
|
36
|
+
return width.from <= width.to;
|
37
|
+
}
|
38
|
+
if (height) {
|
39
|
+
return height.from <= height.to;
|
40
|
+
}
|
41
|
+
return false;
|
42
|
+
};
|
43
|
+
exports.isValidMq = isValidMq;
|
44
|
+
const isWithinTheWidthAndHeight = (parsedMq, screenSize) => {
|
45
|
+
const {
|
46
|
+
width,
|
47
|
+
height
|
48
|
+
} = parsedMq;
|
49
|
+
if (width && height) {
|
50
|
+
return isWithinTheWidth(width, screenSize.width) && isWithinTheHeight(height, screenSize.height);
|
51
|
+
}
|
52
|
+
if (width) {
|
53
|
+
return isWithinTheWidth(width, screenSize.width);
|
54
|
+
}
|
55
|
+
if (height) {
|
56
|
+
return isWithinTheHeight(height, screenSize.height);
|
57
|
+
}
|
58
|
+
return false;
|
59
|
+
};
|
60
|
+
exports.isWithinTheWidthAndHeight = isWithinTheWidthAndHeight;
|
61
|
+
const isWithinTheWidth = (width, screenWidth) => {
|
62
|
+
const {
|
63
|
+
from,
|
64
|
+
to
|
65
|
+
} = width;
|
66
|
+
return screenWidth >= from && screenWidth <= to;
|
67
|
+
};
|
68
|
+
const isWithinTheHeight = (height, screenHeight) => {
|
69
|
+
const {
|
70
|
+
from,
|
71
|
+
to
|
72
|
+
} = height;
|
73
|
+
return screenHeight >= from && screenHeight <= to;
|
74
|
+
};
|
75
|
+
const getKeyForUnistylesMediaQuery = (mediaQueries, screenSize) => {
|
76
|
+
const mq = mediaQueries.find(([key]) => {
|
77
|
+
if (!isUnistylesMq(key)) {
|
78
|
+
return false;
|
79
|
+
}
|
80
|
+
const parsedMq = parseMq(key);
|
81
|
+
if (!isValidMq(parsedMq)) {
|
82
|
+
return false;
|
83
|
+
}
|
84
|
+
return isWithinTheWidthAndHeight(parsedMq, screenSize);
|
85
|
+
});
|
86
|
+
return mq?.at(0);
|
87
|
+
};
|
88
|
+
exports.getKeyForUnistylesMediaQuery = getKeyForUnistylesMediaQuery;
|
89
|
+
//# sourceMappingURL=mqParser.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["IS_UNISTYLES_REGEX","UNISTYLES_WIDTH_REGEX","UNISTYLES_HEIGHT_REGEX","parseMq","mq","width","fromW","toW","exec","height","fromH","toH","from","Number","to","undefined","exports","isUnistylesMq","test","isValidMq","parsedMq","isWithinTheWidthAndHeight","screenSize","isWithinTheWidth","isWithinTheHeight","screenWidth","screenHeight","getKeyForUnistylesMediaQuery","mediaQueries","find","key","at"],"sourceRoot":"../../../src","sources":["utils/mqParser.ts"],"mappings":";;;;;;AAEA,MAAMA,kBAAkB,GAAG,wCAAwC;AACnE,MAAMC,qBAAqB,GAAG,qCAAqC;AACnE,MAAMC,sBAAsB,GAAG,qCAAqC;AAY7D,MAAMC,OAAO,GAAIC,EAAU,IAAwB;EACtD,MAAM,GAAGC,KAAK,EAAEC,KAAK,EAAEC,GAAG,CAAC,GAAGN,qBAAqB,CAACO,IAAI,CAACJ,EAAE,CAAC,IAAI,EAAE;EAClE,MAAM,GAAGK,MAAM,EAAEC,KAAK,EAAEC,GAAG,CAAC,GAAGT,sBAAsB,CAACM,IAAI,CAACJ,EAAE,CAAC,IAAI,EAAE;EAEpE,OAAO;IACHC,KAAK,EAAEA,KAAK,GAAG;MACXO,IAAI,EAAEC,MAAM,CAACP,KAAK,CAAC;MACnBQ,EAAE,EAAED,MAAM,CAACN,GAAG;IAClB,CAAC,GAAGQ,SAAS;IACbN,MAAM,EAAEA,MAAM,GAAG;MACbG,IAAI,EAAEC,MAAM,CAACH,KAAK,CAAC;MACnBI,EAAE,EAAED,MAAM,CAACF,GAAG;IAClB,CAAC,GAAGI;EACR,CAAC;AACL,CAAC;AAAAC,OAAA,CAAAb,OAAA,GAAAA,OAAA;AAEM,MAAMc,aAAa,GAAIb,EAAU,IAAKJ,kBAAkB,CAACkB,IAAI,CAACd,EAAE,CAAC;AAAAY,OAAA,CAAAC,aAAA,GAAAA,aAAA;AAEjE,MAAME,SAAS,GAAIC,QAA2B,IAAK;EACtD,MAAM;IAAEf,KAAK;IAAEI;EAAO,CAAC,GAAGW,QAAQ;EAElC,IAAIf,KAAK,IAAII,MAAM,EAAE;IACjB,OAAOJ,KAAK,CAACO,IAAI,IAAIP,KAAK,CAACS,EAAE,IAAIL,MAAM,CAACG,IAAI,IAAIH,MAAM,CAACK,EAAE;EAC7D;EAEA,IAAIT,KAAK,EAAE;IACP,OAAOA,KAAK,CAACO,IAAI,IAAIP,KAAK,CAACS,EAAE;EACjC;EAEA,IAAIL,MAAM,EAAE;IACR,OAAOA,MAAM,CAACG,IAAI,IAAIH,MAAM,CAACK,EAAE;EACnC;EAEA,OAAO,KAAK;AAChB,CAAC;AAAAE,OAAA,CAAAG,SAAA,GAAAA,SAAA;AAEM,MAAME,yBAAyB,GAAGA,CAACD,QAA2B,EAAEE,UAAsB,KAAc;EACvG,MAAM;IAAEjB,KAAK;IAAEI;EAAO,CAAC,GAAGW,QAAQ;EAElC,IAAIf,KAAK,IAAII,MAAM,EAAE;IACjB,OAAOc,gBAAgB,CAAClB,KAAK,EAAEiB,UAAU,CAACjB,KAAK,CAAC,IAAImB,iBAAiB,CAACf,MAAM,EAAEa,UAAU,CAACb,MAAM,CAAC;EACpG;EAEA,IAAIJ,KAAK,EAAE;IACP,OAAOkB,gBAAgB,CAAClB,KAAK,EAAEiB,UAAU,CAACjB,KAAK,CAAC;EACpD;EAEA,IAAII,MAAM,EAAE;IACR,OAAOe,iBAAiB,CAACf,MAAM,EAAEa,UAAU,CAACb,MAAM,CAAC;EACvD;EAEA,OAAO,KAAK;AAChB,CAAC;AAAAO,OAAA,CAAAK,yBAAA,GAAAA,yBAAA;AAED,MAAME,gBAAgB,GAAGA,CAAClB,KAAiC,EAAEoB,WAAmB,KAAc;EAC1F,MAAM;IAAEb,IAAI;IAAEE;EAAG,CAAC,GAAGT,KAA0B;EAE/C,OAAOoB,WAAW,IAAIb,IAAI,IAAIa,WAAW,IAAIX,EAAE;AACnD,CAAC;AAED,MAAMU,iBAAiB,GAAGA,CAACf,MAAmC,EAAEiB,YAAoB,KAAc;EAC9F,MAAM;IAAEd,IAAI;IAAEE;EAAG,CAAC,GAAGL,MAA2B;EAEhD,OAAOiB,YAAY,IAAId,IAAI,IAAIc,YAAY,IAAIZ,EAAE;AACrD,CAAC;AAEM,MAAMa,4BAA4B,GAAGA,CAACC,YAAsC,EAAEN,UAAsB,KAAuB;EAC9H,MAAMlB,EAAE,GAAGwB,YAAY,CAACC,IAAI,CAAC,CAAC,CAACC,GAAG,CAAC,KAAK;IACpC,IAAI,CAACb,aAAa,CAACa,GAAa,CAAC,EAAE;MAC/B,OAAO,KAAK;IAChB;IAEA,MAAMV,QAAQ,GAAGjB,OAAO,CAAC2B,GAAa,CAAC;IAEvC,IAAI,CAACX,SAAS,CAACC,QAAQ,CAAC,EAAE;MACtB,OAAO,KAAK;IAChB;IAEA,OAAOC,yBAAyB,CAACD,QAAQ,EAAEE,UAAU,CAAC;EAC1D,CAAC,CAAC;EAEF,OAAOlB,EAAE,EAAE2B,EAAE,CAAC,CAAC,CAAC;AACpB,CAAC;AAAAf,OAAA,CAAAW,4BAAA,GAAAA,4BAAA"}
|
@@ -5,31 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.proxifyFunction = exports.parseStyle = exports.isPlatformColor = void 0;
|
7
7
|
var _breakpoints = require("./breakpoints");
|
8
|
-
var
|
9
|
-
var
|
10
|
-
|
11
|
-
|
12
|
-
*
|
13
|
-
* @template B - An object type where keys represent breakpoint names and values represent breakpoint values.
|
14
|
-
*
|
15
|
-
* @param {Function} fn - The function to be proxified.
|
16
|
-
* @param {keyof B & string} breakpoint - The breakpoint name to check against.
|
17
|
-
* @param {ScreenSize} screenSize - An object representing the screen size to be checked against the media queries.
|
18
|
-
* @param breakpointPairs - sorted pairs of breakpoints
|
19
|
-
*
|
20
|
-
* @returns {Function} Returns the proxified function
|
21
|
-
*
|
22
|
-
* @example
|
23
|
-
*
|
24
|
-
* const myFunction = () => ({ ':w[200]': 'value1', sm: 'value2' })
|
25
|
-
* const screenSize = { width: 250, height: 400 }
|
26
|
-
* const breakpoints = { sm: 300, md: 600 }
|
27
|
-
*
|
28
|
-
* const proxifiedFunction = proxifyFunction(myFunction, 'sm', screenSize, breakpoints)
|
29
|
-
* proxifiedFunction() // parsed style based on screenSize and breakpoints
|
30
|
-
*/
|
31
|
-
const proxifyFunction = (fn, breakpoint, screenSize, breakpointPairs) => new Proxy(fn, {
|
32
|
-
apply: (target, thisArg, argumentsList) => parseStyle(target.apply(thisArg, argumentsList), breakpoint, screenSize, breakpointPairs)
|
8
|
+
var _common = require("../common");
|
9
|
+
var _withPlugins = require("./withPlugins");
|
10
|
+
const proxifyFunction = (key, fn, variant) => new Proxy(fn, {
|
11
|
+
apply: (target, thisArg, argumentsList) => (0, _withPlugins.withPlugins)(key, parseStyle(target.apply(thisArg, argumentsList), variant))
|
33
12
|
});
|
34
13
|
exports.proxifyFunction = proxifyFunction;
|
35
14
|
const isPlatformColor = value => {
|
@@ -38,53 +17,47 @@ const isPlatformColor = value => {
|
|
38
17
|
}
|
39
18
|
return _common.isAndroid && 'resource_paths' in value && typeof value.resource_paths === 'object';
|
40
19
|
};
|
41
|
-
|
42
|
-
/**
|
43
|
-
* Parses a style object to resolve custom media queries or breakpoints based on the provided screen size and breakpoints.
|
44
|
-
*
|
45
|
-
* The function processes each key-value pair in the style object. If the value is a function or a valid style (not an object or a 'transform' key),
|
46
|
-
* it is returned as-is. Otherwise, the function attempts to resolve the value based on the provided breakpoint, screen size, and defined breakpoints.
|
47
|
-
*
|
48
|
-
* @template T - The type of the style object.
|
49
|
-
* @template B - An object type where keys represent breakpoint names and values represent breakpoint values.
|
50
|
-
*
|
51
|
-
* @param {CustomNamedStyles<T, B>} style - The style object to be parsed.
|
52
|
-
* @param {keyof B & string} breakpoint - The breakpoint name to check against.
|
53
|
-
* @param {ScreenSize} screenSize - An object representing the screen size to be checked against the media queries.
|
54
|
-
* @param breakpointPairs - sorted pairs of breakpoints
|
55
|
-
*
|
56
|
-
* @returns {Record<string, string | number | Function>} Returns the parsed style object with resolved custom media queries or breakpoints.
|
57
|
-
*
|
58
|
-
* @example
|
59
|
-
*
|
60
|
-
* const style = { fontSize: { sm: '12px', md: '16px' } }
|
61
|
-
* const screenSize = { width: 300, height: 400 }
|
62
|
-
* const breakpoints = { xs: 0, sm: 300, md: 600 }
|
63
|
-
*
|
64
|
-
* const parsedStyle = parseStyle(style, 'sm', screenSize, breakpoints)
|
65
|
-
* // { fontSize: '12px' }
|
66
|
-
*/
|
67
20
|
exports.isPlatformColor = isPlatformColor;
|
68
|
-
const parseStyle = (style,
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
21
|
+
const parseStyle = (style, variant = {}, parseMediaQueries = true) => Object.entries(style || {}).reduce((acc, [key, value]) => {
|
22
|
+
// nested objects
|
23
|
+
if (key === 'shadowOffset' || key === 'textShadowOffset') {
|
24
|
+
acc[key] = parseStyle(value, variant);
|
25
|
+
return acc;
|
26
|
+
}
|
27
|
+
|
28
|
+
// transforms
|
29
|
+
if (key === 'transform' && Array.isArray(value)) {
|
30
|
+
acc[key] = value.map(value => parseStyle(value, variant));
|
31
|
+
return acc;
|
32
|
+
}
|
33
|
+
|
34
|
+
// values or platform colors
|
35
|
+
if (typeof value !== 'object' || isPlatformColor(value)) {
|
36
|
+
acc[key] = value;
|
37
|
+
return acc;
|
38
|
+
}
|
39
|
+
if (key === 'variants') {
|
40
|
+
return {
|
41
|
+
...acc,
|
42
|
+
...Object.keys(value).reduce((acc, key) => ({
|
43
|
+
...acc,
|
44
|
+
// this will parse the styles of the selected variant (or default if it is undefined), if selected variant has no styles then it will fallback to default styles
|
45
|
+
...parseStyle(value[key][variant[key] || 'default'] ?? value[key].default ?? {})
|
46
|
+
}), {})
|
47
|
+
};
|
48
|
+
}
|
49
|
+
|
50
|
+
// don't parse media queries and breakpoints
|
51
|
+
if (!parseMediaQueries) {
|
52
|
+
return {
|
53
|
+
...acc,
|
54
|
+
[key]: value
|
55
|
+
};
|
56
|
+
}
|
57
|
+
return {
|
58
|
+
...acc,
|
59
|
+
[key]: (0, _breakpoints.getValueForBreakpoint)(value)
|
60
|
+
};
|
61
|
+
}, {});
|
89
62
|
exports.parseStyle = parseStyle;
|
90
63
|
//# sourceMappingURL=styles.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_breakpoints","require","
|
1
|
+
{"version":3,"names":["_breakpoints","require","_common","_withPlugins","proxifyFunction","key","fn","variant","Proxy","apply","target","thisArg","argumentsList","withPlugins","parseStyle","exports","isPlatformColor","value","isIOS","semantic","isAndroid","resource_paths","style","parseMediaQueries","Object","entries","reduce","acc","Array","isArray","map","keys","default","getValueForBreakpoint"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAEO,MAAMG,eAAe,GAAGA,CAC3BC,GAAW,EACXC,EAAY,EACZC,OAA0C,KAC/B,IAAIC,KAAK,CAACF,EAAE,EAAE;EACzBG,KAAK,EAAEA,CAACC,MAAM,EAAEC,OAAO,EAAEC,aAAa,KAAK,IAAAC,wBAAW,EAACR,GAAG,EAAES,UAAU,CAACJ,MAAM,CAACD,KAAK,CAACE,OAAO,EAAEC,aAAa,CAAC,EAAEL,OAAO,CAAC;AACzH,CAAC,CAAC;AAAAQ,OAAA,CAAAX,eAAA,GAAAA,eAAA;AAEK,MAAMY,eAAe,GAAkBC,KAAQ,IAAc;EAChE,IAAIC,aAAK,EAAE;IACP,OAAO,UAAU,IAAID,KAAK,IAAI,OAAOA,KAAK,CAACE,QAAQ,KAAK,QAAQ;EACpE;EAEA,OAAOC,iBAAS,IAAI,gBAAgB,IAAIH,KAAK,IAAI,OAAOA,KAAK,CAACI,cAAc,KAAK,QAAQ;AAC7F,CAAC;AAAAN,OAAA,CAAAC,eAAA,GAAAA,eAAA;AAEM,MAAMF,UAAU,GAAGA,CACtBQ,KAAQ,EACRf,OAAyC,GAAG,CAAC,CAAC,EAC9CgB,iBAAiB,GAAG,IAAI,KACpBC,MAAM,CACTC,OAAO,CAACH,KAAK,IAAI,CAAC,CAAC,CAAC,CACpBI,MAAM,CAAC,CAACC,GAAG,EAAE,CAACtB,GAAG,EAAEY,KAAK,CAAC,KAAK;EAC3B;EACA,IAAIZ,GAAG,KAAK,cAAc,IAAIA,GAAG,KAAM,kBAAkB,EAAE;IACvDsB,GAAG,CAACtB,GAAG,CAAC,GAAGS,UAAU,CAACG,KAAK,EAAEV,OAAO,CAAC;IAErC,OAAOoB,GAAG;EACd;;EAEA;EACA,IAAItB,GAAG,KAAK,WAAW,IAAIuB,KAAK,CAACC,OAAO,CAACZ,KAAK,CAAC,EAAE;IAC7CU,GAAG,CAACtB,GAAG,CAAC,GAAGY,KAAK,CAACa,GAAG,CAACb,KAAK,IAAIH,UAAU,CAACG,KAAK,EAAEV,OAAO,CAAC,CAAC;IAEzD,OAAOoB,GAAG;EACd;;EAEA;EACA,IAAI,OAAOV,KAAK,KAAK,QAAQ,IAAID,eAAe,CAACC,KAAK,CAAC,EAAE;IACrDU,GAAG,CAACtB,GAAG,CAAY,GAAGY,KAAK;IAE3B,OAAOU,GAAG;EACd;EAEA,IAAItB,GAAG,KAAK,UAAU,EAAE;IACpB,OAAO;MACH,GAAGsB,GAAG;MACN,GAAIH,MAAM,CACLO,IAAI,CAACd,KAAK,CAAC,CACXS,MAAM,CAAC,CAACC,GAAG,EAAEtB,GAAG,MAAM;QACnB,GAAGsB,GAAG;QACN;QACA,GAAGb,UAAU,CAAEG,KAAK,CAAEZ,GAAG,CAAC,CAACE,OAAO,CAACF,GAAG,CAAyB,IAAI,SAAS,CAAC,IAAKY,KAAK,CAAEZ,GAAG,CAAC,CAAC2B,OAAO,IAAI,CAAC,CAAC;MAC/G,CAAC,CAAC,EAAE,CAAC,CAAC;IACd,CAAC;EACL;;EAEA;EACA,IAAI,CAACT,iBAAiB,EAAE;IACpB,OAAO;MACH,GAAGI,GAAG;MACN,CAACtB,GAAG,GAAGY;IACX,CAAC;EACL;EAEA,OAAO;IACH,GAAGU,GAAG;IACN,CAACtB,GAAG,GAAG,IAAA4B,kCAAqB,EAAChB,KAAgC;EACjE,CAAC;AACL,CAAC,EAAE,CAAC,CAAM,CAAC;AAAAF,OAAA,CAAAD,UAAA,GAAAA,UAAA"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.withPlugins = void 0;
|
7
|
+
var _core = require("../core");
|
8
|
+
const withPlugins = (key, style) => _core.unistyles.registry.plugins.reduce((acc, plugin) => {
|
9
|
+
if (plugin.onParsedStyle) {
|
10
|
+
return plugin.onParsedStyle(key, acc, _core.unistyles.runtime);
|
11
|
+
}
|
12
|
+
return acc;
|
13
|
+
}, style);
|
14
|
+
exports.withPlugins = withPlugins;
|
15
|
+
//# sourceMappingURL=withPlugins.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_core","require","withPlugins","key","style","unistyles","registry","plugins","reduce","acc","plugin","onParsedStyle","runtime","exports"],"sourceRoot":"../../../src","sources":["utils/withPlugins.ts"],"mappings":";;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA;AAEO,MAAMC,WAAW,GAAGA,CACvBC,GAAW,EACXC,KAAc,KACbC,eAAS,CAACC,QAAQ,CAACC,OAAO,CAACC,MAAM,CAAC,CAACC,GAAG,EAAEC,MAAM,KAAK;EACpD,IAAIA,MAAM,CAACC,aAAa,EAAE;IACtB,OAAOD,MAAM,CAACC,aAAa,CAACR,GAAG,EAAEM,GAAG,EAAEJ,eAAS,CAACO,OAAO,CAAC;EAC5D;EAEA,OAAOH,GAAG;AACd,CAAC,EAAEL,KAAK,CAAC;AAAAS,OAAA,CAAAX,WAAA,GAAAA,WAAA"}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import { Platform } from 'react-native';
|
2
|
+
export const warn = message => {
|
3
|
+
console.warn(`🦄 [react-native-unistyles]: ${message}`);
|
4
|
+
};
|
5
|
+
export const isWeb = Platform.OS === 'web';
|
6
|
+
export const isIOS = Platform.OS === 'ios';
|
7
|
+
export const isAndroid = Platform.OS === 'android';
|
8
|
+
export const isMobile = isIOS || isAndroid;
|
9
|
+
export const isServer = typeof window === 'undefined';
|
10
|
+
export const ScreenOrientation = {
|
11
|
+
Landscape: 'landscape',
|
12
|
+
Portrait: 'portrait'
|
13
|
+
};
|
14
|
+
export let IOSContentSizeCategory = /*#__PURE__*/function (IOSContentSizeCategory) {
|
15
|
+
IOSContentSizeCategory["ExtraExtraExtraLarge"] = "xxxLarge";
|
16
|
+
IOSContentSizeCategory["ExtraExtraLarge"] = "xxLarge";
|
17
|
+
IOSContentSizeCategory["ExtraLarge"] = "xLarge";
|
18
|
+
IOSContentSizeCategory["Large"] = "Large";
|
19
|
+
IOSContentSizeCategory["Medium"] = "Medium";
|
20
|
+
IOSContentSizeCategory["Small"] = "Small";
|
21
|
+
IOSContentSizeCategory["ExtraSmall"] = "xSmall";
|
22
|
+
IOSContentSizeCategory["Unspecified"] = "unspecified";
|
23
|
+
return IOSContentSizeCategory;
|
24
|
+
}({});
|
25
|
+
export let AndroidContentSizeCategory = /*#__PURE__*/function (AndroidContentSizeCategory) {
|
26
|
+
AndroidContentSizeCategory["Small"] = "Small";
|
27
|
+
AndroidContentSizeCategory["Default"] = "Default";
|
28
|
+
AndroidContentSizeCategory["Large"] = "Large";
|
29
|
+
AndroidContentSizeCategory["ExtraLarge"] = "ExtraLarge";
|
30
|
+
AndroidContentSizeCategory["Huge"] = "Huge";
|
31
|
+
return AndroidContentSizeCategory;
|
32
|
+
}({});
|
33
|
+
export let UnistylesEventType = /*#__PURE__*/function (UnistylesEventType) {
|
34
|
+
UnistylesEventType["Theme"] = "theme";
|
35
|
+
UnistylesEventType["Layout"] = "layout";
|
36
|
+
UnistylesEventType["Plugin"] = "plugin";
|
37
|
+
UnistylesEventType["DynamicTypeSize"] = "dynamicTypeSize";
|
38
|
+
return UnistylesEventType;
|
39
|
+
}({});
|
40
|
+
export let UnistylesError = /*#__PURE__*/function (UnistylesError) {
|
41
|
+
UnistylesError["RuntimeUnavailable"] = "Unistyles runtime is not available. Make sure you followed the installation instructions";
|
42
|
+
UnistylesError["ThemeNotFound"] = "You are trying to get a theme that is not registered with UnistylesRegistry";
|
43
|
+
UnistylesError["ThemeNotRegistered"] = "You are trying to set a theme that was not registered with UnistylesRegistry";
|
44
|
+
UnistylesError["ThemeNotSelected"] = "Your themes are registered, but you didn't select the initial theme";
|
45
|
+
UnistylesError["ThemesCannotBeEmpty"] = "You are trying to register empty themes object";
|
46
|
+
UnistylesError["BreakpointsCannotBeEmpty"] = "You are trying to register empty breakpoints object";
|
47
|
+
UnistylesError["BreakpointsMustStartFromZero"] = "You are trying to register breakpoints that don't start from 0";
|
48
|
+
UnistylesError["InvalidPluginName"] = "Plugin name can't start from reserved prefix __unistyles";
|
49
|
+
UnistylesError["DuplicatePluginName"] = "You are trying to register a plugin with a name that is already registered";
|
50
|
+
UnistylesError["CantRemoveInternalPlugin"] = "You are trying to remove an internal unistyles plugin";
|
51
|
+
return UnistylesError;
|
52
|
+
}({});
|
53
|
+
//# sourceMappingURL=common.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["Platform","warn","message","console","isWeb","OS","isIOS","isAndroid","isMobile","isServer","window","ScreenOrientation","Landscape","Portrait","IOSContentSizeCategory","AndroidContentSizeCategory","UnistylesEventType","UnistylesError"],"sourceRoot":"../../src","sources":["common.ts"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,OAAO,MAAMC,IAAI,GAAIC,OAAe,IAAK;EACrCC,OAAO,CAACF,IAAI,CAAE,gCAA+BC,OAAQ,EAAC,CAAC;AAC3D,CAAC;AAED,OAAO,MAAME,KAAK,GAAGJ,QAAQ,CAACK,EAAE,KAAK,KAAK;AAC1C,OAAO,MAAMC,KAAK,GAAGN,QAAQ,CAACK,EAAE,KAAK,KAAK;AAC1C,OAAO,MAAME,SAAS,GAAGP,QAAQ,CAACK,EAAE,KAAK,SAAS;AAClD,OAAO,MAAMG,QAAQ,GAAGF,KAAK,IAAIC,SAAS;AAC1C,OAAO,MAAME,QAAQ,GAAG,OAAOC,MAAM,KAAK,WAAW;AAErD,OAAO,MAAMC,iBAAiB,GAAG;EAC7BC,SAAS,EAAE,WAAW;EACtBC,QAAQ,EAAE;AACd,CAAU;AAEV,WAAYC,sBAAsB,0BAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAA,OAAtBA,sBAAsB;AAAA;AAWlC,WAAYC,0BAA0B,0BAA1BA,0BAA0B;EAA1BA,0BAA0B;EAA1BA,0BAA0B;EAA1BA,0BAA0B;EAA1BA,0BAA0B;EAA1BA,0BAA0B;EAAA,OAA1BA,0BAA0B;AAAA;AAQtC,WAAYC,kBAAkB,0BAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA;AAO9B,WAAYC,cAAc,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA"}
|
@@ -0,0 +1,87 @@
|
|
1
|
+
import { isWeb, UnistylesError } from '../common';
|
2
|
+
import { cssMediaQueriesPlugin, normalizeWebStylesPlugin } from '../plugins';
|
3
|
+
export class UnistyleRegistry {
|
4
|
+
config = {};
|
5
|
+
plugins = isWeb ? [normalizeWebStylesPlugin] : [];
|
6
|
+
themeNames = [];
|
7
|
+
themes = {};
|
8
|
+
breakpoints = {};
|
9
|
+
sortedBreakpointPairs = [];
|
10
|
+
constructor(unistylesBridge) {
|
11
|
+
this.unistylesBridge = unistylesBridge;
|
12
|
+
}
|
13
|
+
addThemes = themes => {
|
14
|
+
this.themes = themes;
|
15
|
+
const keys = Object.keys(themes);
|
16
|
+
this.unistylesBridge.themes = keys;
|
17
|
+
this.themeNames = keys;
|
18
|
+
return {
|
19
|
+
addBreakpoints: this.addBreakpoints,
|
20
|
+
addConfig: this.addConfig
|
21
|
+
};
|
22
|
+
};
|
23
|
+
addBreakpoints = breakpoints => {
|
24
|
+
this.breakpoints = breakpoints;
|
25
|
+
this.unistylesBridge.useBreakpoints(breakpoints);
|
26
|
+
this.sortedBreakpointPairs = this.unistylesBridge.sortedBreakpointPairs;
|
27
|
+
return {
|
28
|
+
addThemes: this.addThemes,
|
29
|
+
addConfig: this.addConfig
|
30
|
+
};
|
31
|
+
};
|
32
|
+
addConfig = config => {
|
33
|
+
this.config = config;
|
34
|
+
if (config.adaptiveThemes) {
|
35
|
+
this.unistylesBridge.useAdaptiveThemes(config.adaptiveThemes);
|
36
|
+
}
|
37
|
+
if (config.plugins) {
|
38
|
+
config.plugins.forEach(plugin => this.addPlugin(plugin, false));
|
39
|
+
}
|
40
|
+
if (config.initialTheme) {
|
41
|
+
this.unistylesBridge.useTheme(config.initialTheme);
|
42
|
+
}
|
43
|
+
if (config.experimentalCSSMediaQueries) {
|
44
|
+
this.plugins = [cssMediaQueriesPlugin].concat(this.plugins);
|
45
|
+
this.unistylesBridge.addPlugin(cssMediaQueriesPlugin.name, false);
|
46
|
+
}
|
47
|
+
return {
|
48
|
+
addBreakpoints: this.addBreakpoints,
|
49
|
+
addThemes: this.addThemes
|
50
|
+
};
|
51
|
+
};
|
52
|
+
getTheme = forName => {
|
53
|
+
if (this.themeNames.length === 0) {
|
54
|
+
return {};
|
55
|
+
}
|
56
|
+
if (this.hasTheme(forName)) {
|
57
|
+
return this.themes[forName];
|
58
|
+
}
|
59
|
+
if (this.unistylesBridge.themeName) {
|
60
|
+
throw new Error(UnistylesError.ThemeNotFound);
|
61
|
+
}
|
62
|
+
throw new Error(UnistylesError.ThemeNotSelected);
|
63
|
+
};
|
64
|
+
addPlugin = (plugin, notify = true) => {
|
65
|
+
if (plugin.name.startsWith('__unistyles')) {
|
66
|
+
throw new Error(UnistylesError.InvalidPluginName);
|
67
|
+
}
|
68
|
+
if (this.plugins.some(({
|
69
|
+
name
|
70
|
+
}) => name === plugin.name)) {
|
71
|
+
throw new Error(UnistylesError.DuplicatePluginName);
|
72
|
+
}
|
73
|
+
this.plugins = [plugin].concat(this.plugins);
|
74
|
+
this.unistylesBridge.addPlugin(plugin.name, notify);
|
75
|
+
};
|
76
|
+
removePlugin = plugin => {
|
77
|
+
if (plugin.name.startsWith('__unistyles')) {
|
78
|
+
throw new Error(UnistylesError.CantRemoveInternalPlugin);
|
79
|
+
}
|
80
|
+
this.plugins = this.plugins.filter(({
|
81
|
+
name
|
82
|
+
}) => name !== plugin.name);
|
83
|
+
this.unistylesBridge.removePlugin(plugin.name);
|
84
|
+
};
|
85
|
+
hasTheme = name => name in this.themes;
|
86
|
+
}
|
87
|
+
//# sourceMappingURL=UnistyleRegistry.js.map
|