react-native-unistyles 1.1.6 → 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 +52 -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 +50 -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 -16
- 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 +4 -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 +55 -27
- 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 +62 -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 -18
- 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 -10
- 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/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 -8
- 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 -5
- 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 -12
- 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 @@
|
|
1
|
+
{"version":3,"names":["isWeb","UnistylesError","cssMediaQueriesPlugin","normalizeWebStylesPlugin","UnistyleRegistry","config","plugins","themeNames","themes","breakpoints","sortedBreakpointPairs","constructor","unistylesBridge","addThemes","keys","Object","addBreakpoints","addConfig","useBreakpoints","adaptiveThemes","useAdaptiveThemes","forEach","plugin","addPlugin","initialTheme","useTheme","experimentalCSSMediaQueries","concat","name","getTheme","forName","length","hasTheme","themeName","Error","ThemeNotFound","ThemeNotSelected","notify","startsWith","InvalidPluginName","some","DuplicatePluginName","removePlugin","CantRemoveInternalPlugin","filter"],"sourceRoot":"../../../src","sources":["core/UnistyleRegistry.ts"],"mappings":"AAEA,SAASA,KAAK,EAAEC,cAAc,QAAQ,WAAW;AACjD,SAASC,qBAAqB,EAAEC,wBAAwB,QAAQ,YAAY;AAE5E,OAAO,MAAMC,gBAAgB,CAAC;EACnBC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,OAAO,GAA2BN,KAAK,GACxC,CAACG,wBAAwB,CAAC,GAC1B,EAAE;EACDI,UAAU,GAAiC,EAAE;EAC7CC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,WAAW,GAAyB,CAAC,CAAC;EACtCC,qBAAqB,GAA0F,EAAE;EAExHC,WAAWA,CAASC,eAAgC,EAAE;IAAA,KAAlCA,eAAgC,GAAhCA,eAAgC;EAAG;EAEhDC,SAAS,GAAIL,MAAuB,IAAK;IAC5C,IAAI,CAACA,MAAM,GAAGA,MAAM;IAEpB,MAAMM,IAAI,GAAGC,MAAM,CAACD,IAAI,CAACN,MAAM,CAAiC;IAEhE,IAAI,CAACI,eAAe,CAACJ,MAAM,GAAGM,IAAI;IAClC,IAAI,CAACP,UAAU,GAAGO,IAAI;IAEtB,OAAO;MACHE,cAAc,EAAE,IAAI,CAACA,cAAc;MACnCC,SAAS,EAAE,IAAI,CAACA;IACpB,CAAC;EACL,CAAC;EAEMD,cAAc,GAAIP,WAAiC,IAAK;IAC3D,IAAI,CAACA,WAAW,GAAGA,WAAW;IAC9B,IAAI,CAACG,eAAe,CAACM,cAAc,CAACT,WAAW,CAAC;IAChD,IAAI,CAACC,qBAAqB,GAAG,IAAI,CAACE,eAAe,CAACF,qBAAqB;IAEvE,OAAO;MACHG,SAAS,EAAE,IAAI,CAACA,SAAS;MACzBI,SAAS,EAAE,IAAI,CAACA;IACpB,CAAC;EACL,CAAC;EAEMA,SAAS,GAAIZ,MAAuB,IAAK;IAC5C,IAAI,CAACA,MAAM,GAAGA,MAA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ACM,IAAI,CAACU,UAAU,CAAC,aAAa,CAAC,EAAE;MACvC,MAAM,IAAIJ,KAAK,CAACjC,cAAc,CAACsC,iBAAiB,CAAC;IACrD;IAEA,IAAI,IAAI,CAACjC,OAAO,CAACkC,IAAI,CAAC,CAAC;MAAEZ;IAAK,CAAC,KAAKA,IAAI,KAAKN,MAAM,CAACM,IAAI,CAAC,EAAE;MACvD,MAAM,IAAIM,KAAK,CAACjC,cAAc,CAACwC,mBAAmB,CAAC;IACvD;IAEA,IAAI,CAACnC,OAAO,GAAG,CAACgB,MAAM,CAAC,CAACK,MAAM,CAAC,IAAI,CAACrB,OAAO,CAAC;IAC5C,IAAI,CAACM,eAAe,CAACW,SAAS,CAACD,MAAM,CAACM,IAAI,EAAES,MAAM,CAAC;EACvD,CAAC;EAEMK,YAAY,GAAIpB,MAAuB,IAAK;IAC/C,IAAIA,MAAM,CAACM,IAAI,CAACU,UAAU,CAAC,aAAa,CAAC,EAAE;MACvC,MAAM,IAAIJ,KAAK,CAACjC,cAAc,CAAC0C,wBAAwB,CAAC;IAC5D;IAEA,IAAI,CAACrC,OAAO,GAAG,IAAI,CAACA,OAAO,CAACsC,MAAM,CAAC,CAAC;MAAEhB;IAAK,CAAC,KAAKA,IAAI,KAAKN,MAAM,CAACM,IAAI,CAAC;IACtE,IAAI,CAAChB,eAAe,CAAC8B,YAAY,CAACpB,MAAM,CAACM,IAAI,CAAC;EAClD,CAAC;EAEMI,QAAQ,GAAIJ,IAA2B,IAAKA,IAAI,IAAI,IAAI,CAACpB,MAAM;AAC1E"}
|
@@ -0,0 +1,26 @@
|
|
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
|
@@ -0,0 +1 @@
|
|
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"}
|
@@ -0,0 +1,190 @@
|
|
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
|
@@ -0,0 +1 @@
|
|
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;EAC9D,CAACC,SAAS,GAA0B,EAAE;EACtC,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AACtE,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"}
|
@@ -0,0 +1 @@
|
|
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"}
|
@@ -0,0 +1,133 @@
|
|
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
|
@@ -0,0 +1 @@
|
|
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,CAASC,eAAgC,EAAUC,iBAAmC,EAAE;IAA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;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"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["unistyles"],"sourceRoot":"../../../src","sources":["core/index.ts"],"mappings":"AAAA,SAASA,SAAS,QAAQ,aAAa"}
|
@@ -0,0 +1,7 @@
|
|
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
|
@@ -0,0 +1 @@
|
|
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"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["global.ts"],"mappings":""}
|
@@ -1,2 +1,5 @@
|
|
1
|
-
export {
|
1
|
+
export { useInitialTheme } from './useInitialTheme';
|
2
|
+
export { useUnistyles } from './useUnistyles';
|
3
|
+
export { useVariants } from './useVariants';
|
4
|
+
export { useCSS } from './useCSS';
|
2
5
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["useInitialTheme","useUnistyles","useVariants","useCSS"],"sourceRoot":"../../../src","sources":["hooks/index.ts"],"mappings":"AAAA,SAASA,eAAe,QAAQ,mBAAmB;AACnD,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAASC,MAAM,QAAQ,UAAU"}
|
@@ -0,0 +1,37 @@
|
|
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
|
@@ -0,0 +1 @@
|
|
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"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["useCSS","_stylesheet"],"sourceRoot":"../../../src","sources":["hooks/useCSS.native.ts"],"mappings":"AAEA,OAAO,MAAMA,MAAM,GAAOC,WAAqC,IAAW,CAAC,CAAC"}
|
@@ -0,0 +1,10 @@
|
|
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
|
@@ -0,0 +1 @@
|
|
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"}
|
@@ -0,0 +1,57 @@
|
|
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
|
@@ -0,0 +1 @@
|
|
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,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ACA,KAAKrB,kBAAkB,CAACgC,MAAM;UAAE;YAC5B,OAAO3B,UAAU,CAACN,SAAS,CAACO,OAAO,CAACC,cAAc,CAAC;UACvD;QACA,KAAKP,kBAAkB,CAACiC,eAAe;UAAE;YACrC,MAAMC,oBAAoB,GAAGT,KAAsC;YAEnE,OAAOX,sBAAsB,CAACoB,oBAAoB,CAACL,OAAO,CAAChB,mBAAmB,CAAC;UACnF;QACA;UACI;MACR;IACJ,CACJ,CAAC;IAED,OAAOU,YAAY,CAACY,MAAM;EAC9B,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO;IACH/B,OAAO;IACPI,KAAK;IACLO,MAAM;IACNF;EACJ,CAAC;AACL,CAAC"}
|
@@ -0,0 +1 @@
|
|
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"}
|
package/lib/module/index.js
CHANGED
@@ -1,3 +1,31 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
import { unistyles } from './core';
|
2
|
+
import { mq } from './utils';
|
3
|
+
import { useInitialTheme } from './hooks';
|
4
|
+
import { ScreenOrientation, AndroidContentSizeCategory, IOSContentSizeCategory } from './common';
|
5
|
+
import { useStyles } from './useStyles';
|
6
|
+
import { createStyleSheet } from './createStyleSheet';
|
7
|
+
|
8
|
+
/**
|
9
|
+
* Utility to interact with the Unistyles
|
10
|
+
* (should be called only once)
|
11
|
+
*/
|
12
|
+
const UnistylesRegistry = {
|
13
|
+
/**
|
14
|
+
* Register themes to be used in the app
|
15
|
+
* @param themes - Key value pair of themes
|
16
|
+
*/
|
17
|
+
addThemes: unistyles.registry.addThemes,
|
18
|
+
/**
|
19
|
+
* Register breakpoints to be used in the app
|
20
|
+
* @param breakpoints - Key value pair of breakpoints
|
21
|
+
*/
|
22
|
+
addBreakpoints: unistyles.registry.addBreakpoints,
|
23
|
+
/**
|
24
|
+
* Register additional config to customize the Unistyles
|
25
|
+
* @param config - Key value pair of config
|
26
|
+
*/
|
27
|
+
addConfig: unistyles.registry.addConfig
|
28
|
+
};
|
29
|
+
const UnistylesRuntime = unistyles.runtime;
|
30
|
+
export { mq, useStyles, useInitialTheme, createStyleSheet, ScreenOrientation, AndroidContentSizeCategory, IOSContentSizeCategory, UnistylesRegistry, UnistylesRuntime };
|
3
31
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["unistyles","mq","useInitialTheme","ScreenOrientation","AndroidContentSizeCategory","IOSContentSizeCategory","useStyles","createStyleSheet","UnistylesRegistry","addThemes","registry","addBreakpoints","addConfig","UnistylesRuntime","runtime"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,SAASA,SAAS,QAAQ,QAAQ;AAClC,SAASC,EAAE,QAAQ,SAAS;AAC5B,SAASC,eAAe,QAAQ,SAAS;AAGzC,SAASC,iBAAiB,EAAEC,0BAA0B,EAAEC,sBAAsB,QAAQ,UAAU;AAChG,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,gBAAgB,QAAQ,oBAAoB;;AAErD;AACA;AACA;AACA;AACA,MAAMC,iBAAiB,GAAG;EACtB;AACJ;AACA;AACA;EACIC,SAAS,EAAET,SAAS,CAACU,QAAQ,CAACD,SAAS;EACvC;AACJ;AACA;AACA;EACIE,cAAc,EAAEX,SAAS,CAACU,QAAQ,CAACC,cAAc;EACjD;AACJ;AACA;AACA;EACIC,SAAS,EAAEZ,SAAS,CAACU,QAAQ,CAACE;AAClC,CAAC;AAED,MAAMC,gBAAgB,GAAGb,SAAS,CAACc,OAAO;AAE1C,SACIb,EAAE,EACFK,SAAS,EACTJ,eAAe,EACfK,gBAAgB,EAChBJ,iBAAiB,EACjBC,0BAA0B,EAC1BC,sBAAsB,EACtBG,iBAAiB,EACjBK,gBAAgB"}
|
@@ -0,0 +1 @@
|
|
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"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["normalizer/module.d.ts"],"mappings":""}
|